Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.0 commit in: /
Date: Sat, 20 Apr 2019 23:28:19
Message-Id: 1555702105.c4f7d776860d5e4ae21a8206edb1b12736b0b5a8.mpagano@gentoo
1 commit: c4f7d776860d5e4ae21a8206edb1b12736b0b5a8
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 19 19:28:25 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Apr 19 19:28:25 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c4f7d776
7
8 Add incremental 5.0.8 patch over full one
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 1007_linux-5.0.8.patch | 36401 ++++-------------------------------------------
13 1 file changed, 2776 insertions(+), 33625 deletions(-)
14
15 diff --git a/1007_linux-5.0.8.patch b/1007_linux-5.0.8.patch
16 index 2e45798..91bf104 100644
17 --- a/1007_linux-5.0.8.patch
18 +++ b/1007_linux-5.0.8.patch
19 @@ -1,242 +1,17 @@
20 -diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
21 -index e133ccd60228..acfe3d0f78d1 100644
22 ---- a/Documentation/DMA-API.txt
23 -+++ b/Documentation/DMA-API.txt
24 -@@ -195,6 +195,14 @@ Requesting the required mask does not alter the current mask. If you
25 - wish to take advantage of it, you should issue a dma_set_mask()
26 - call to set the mask to the value returned.
27 -
28 -+::
29 -+
30 -+ size_t
31 -+ dma_direct_max_mapping_size(struct device *dev);
32 -+
33 -+Returns the maximum size of a mapping for the device. The size parameter
34 -+of the mapping functions like dma_map_single(), dma_map_page() and
35 -+others should not be larger than the returned value.
36 -
37 - Part Id - Streaming DMA mappings
38 - --------------------------------
39 -diff --git a/Documentation/arm/kernel_mode_neon.txt b/Documentation/arm/kernel_mode_neon.txt
40 -index 525452726d31..b9e060c5b61e 100644
41 ---- a/Documentation/arm/kernel_mode_neon.txt
42 -+++ b/Documentation/arm/kernel_mode_neon.txt
43 -@@ -6,7 +6,7 @@ TL;DR summary
44 - * Use only NEON instructions, or VFP instructions that don't rely on support
45 - code
46 - * Isolate your NEON code in a separate compilation unit, and compile it with
47 -- '-mfpu=neon -mfloat-abi=softfp'
48 -+ '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'
49 - * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your
50 - NEON code
51 - * Don't sleep in your NEON code, and be aware that it will be executed with
52 -@@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken.
53 - Therefore, the recommended and only supported way of using NEON/VFP in the
54 - kernel is by adhering to the following rules:
55 - * isolate the NEON code in a separate compilation unit and compile it with
56 -- '-mfpu=neon -mfloat-abi=softfp';
57 -+ '-march=armv7-a -mfpu=neon -mfloat-abi=softfp';
58 - * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls
59 - into the unit containing the NEON code from a compilation unit which is *not*
60 - built with the GCC flag '-mfpu=neon' set.
61 -diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt
62 -index 1f09d043d086..ddb8ce5333ba 100644
63 ---- a/Documentation/arm64/silicon-errata.txt
64 -+++ b/Documentation/arm64/silicon-errata.txt
65 -@@ -44,6 +44,8 @@ stable kernels.
66 -
67 - | Implementor | Component | Erratum ID | Kconfig |
68 - +----------------+-----------------+-----------------+-----------------------------+
69 -+| Allwinner | A64/R18 | UNKNOWN1 | SUN50I_ERRATUM_UNKNOWN1 |
70 -+| | | | |
71 - | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 |
72 - | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
73 - | ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 |
74 -diff --git a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
75 -index a10c1f89037d..e1fe02f3e3e9 100644
76 ---- a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
77 -+++ b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
78 -@@ -11,11 +11,13 @@ New driver handles the following
79 -
80 - Required properties:
81 - - compatible: Must be "samsung,exynos-adc-v1"
82 -- for exynos4412/5250 controllers.
83 -+ for Exynos5250 controllers.
84 - Must be "samsung,exynos-adc-v2" for
85 - future controllers.
86 - Must be "samsung,exynos3250-adc" for
87 - controllers compatible with ADC of Exynos3250.
88 -+ Must be "samsung,exynos4212-adc" for
89 -+ controllers compatible with ADC of Exynos4212 and Exynos4412.
90 - Must be "samsung,exynos7-adc" for
91 - the ADC in Exynos7 and compatibles
92 - Must be "samsung,s3c2410-adc" for
93 -diff --git a/Documentation/process/stable-kernel-rules.rst b/Documentation/process/stable-kernel-rules.rst
94 -index 0de6f6145cc6..7ba8cd567f84 100644
95 ---- a/Documentation/process/stable-kernel-rules.rst
96 -+++ b/Documentation/process/stable-kernel-rules.rst
97 -@@ -38,6 +38,9 @@ Procedure for submitting patches to the -stable tree
98 - - If the patch covers files in net/ or drivers/net please follow netdev stable
99 - submission guidelines as described in
100 - :ref:`Documentation/networking/netdev-FAQ.rst <netdev-FAQ>`
101 -+ after first checking the stable networking queue at
102 -+ https://patchwork.ozlabs.org/bundle/davem/stable/?series=&submitter=&state=*&q=&archive=
103 -+ to ensure the requested patch is not already queued up.
104 - - Security patches should not be handled (solely) by the -stable review
105 - process but should follow the procedures in
106 - :ref:`Documentation/admin-guide/security-bugs.rst <securitybugs>`.
107 -diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
108 -index 356156f5c52d..ba8927c0d45c 100644
109 ---- a/Documentation/virtual/kvm/api.txt
110 -+++ b/Documentation/virtual/kvm/api.txt
111 -@@ -13,7 +13,7 @@ of a virtual machine. The ioctls belong to three classes
112 -
113 - - VM ioctls: These query and set attributes that affect an entire virtual
114 - machine, for example memory layout. In addition a VM ioctl is used to
115 -- create virtual cpus (vcpus).
116 -+ create virtual cpus (vcpus) and devices.
117 -
118 - Only run VM ioctls from the same process (address space) that was used
119 - to create the VM.
120 -@@ -24,6 +24,11 @@ of a virtual machine. The ioctls belong to three classes
121 - Only run vcpu ioctls from the same thread that was used to create the
122 - vcpu.
123 -
124 -+ - device ioctls: These query and set attributes that control the operation
125 -+ of a single device.
126 -+
127 -+ device ioctls must be issued from the same process (address space) that
128 -+ was used to create the VM.
129 -
130 - 2. File descriptors
131 - -------------------
132 -@@ -32,10 +37,11 @@ The kvm API is centered around file descriptors. An initial
133 - open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
134 - can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
135 - handle will create a VM file descriptor which can be used to issue VM
136 --ioctls. A KVM_CREATE_VCPU ioctl on a VM fd will create a virtual cpu
137 --and return a file descriptor pointing to it. Finally, ioctls on a vcpu
138 --fd can be used to control the vcpu, including the important task of
139 --actually running guest code.
140 -+ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
141 -+create a virtual cpu or device and return a file descriptor pointing to
142 -+the new resource. Finally, ioctls on a vcpu or device fd can be used
143 -+to control the vcpu or device. For vcpus, this includes the important
144 -+task of actually running guest code.
145 -
146 - In general file descriptors can be migrated among processes by means
147 - of fork() and the SCM_RIGHTS facility of unix domain socket. These
148 diff --git a/Makefile b/Makefile
149 -index d5713e7b1e50..f7666051de66 100644
150 +index af99c77c7066..f7666051de66 100644
151 --- a/Makefile
152 +++ b/Makefile
153 @@ -1,7 +1,7 @@
154 # SPDX-License-Identifier: GPL-2.0
155 VERSION = 5
156 PATCHLEVEL = 0
157 --SUBLEVEL = 0
158 +-SUBLEVEL = 7
159 +SUBLEVEL = 8
160 EXTRAVERSION =
161 NAME = Shy Crocodile
162
163 -@@ -15,19 +15,6 @@ NAME = Shy Crocodile
164 - PHONY := _all
165 - _all:
166 -
167 --# Do not use make's built-in rules and variables
168 --# (this increases performance and avoids hard-to-debug behaviour)
169 --MAKEFLAGS += -rR
170 --
171 --# Avoid funny character set dependencies
172 --unexport LC_ALL
173 --LC_COLLATE=C
174 --LC_NUMERIC=C
175 --export LC_COLLATE LC_NUMERIC
176 --
177 --# Avoid interference with shell env settings
178 --unexport GREP_OPTIONS
179 --
180 - # We are using a recursive build, so we need to do a little thinking
181 - # to get the ordering right.
182 - #
183 -@@ -44,6 +31,21 @@ unexport GREP_OPTIONS
184 - # descending is started. They are now explicitly listed as the
185 - # prepare rule.
186 -
187 -+ifneq ($(sub-make-done),1)
188 -+
189 -+# Do not use make's built-in rules and variables
190 -+# (this increases performance and avoids hard-to-debug behaviour)
191 -+MAKEFLAGS += -rR
192 -+
193 -+# Avoid funny character set dependencies
194 -+unexport LC_ALL
195 -+LC_COLLATE=C
196 -+LC_NUMERIC=C
197 -+export LC_COLLATE LC_NUMERIC
198 -+
199 -+# Avoid interference with shell env settings
200 -+unexport GREP_OPTIONS
201 -+
202 - # Beautify output
203 - # ---------------------------------------------------------------------------
204 - #
205 -@@ -112,7 +114,6 @@ export quiet Q KBUILD_VERBOSE
206 -
207 - # KBUILD_SRC is not intended to be used by the regular user (for now),
208 - # it is set on invocation of make with KBUILD_OUTPUT or O= specified.
209 --ifeq ($(KBUILD_SRC),)
210 -
211 - # OK, Make called in directory where kernel src resides
212 - # Do we want to locate output files in a separate directory?
213 -@@ -142,6 +143,24 @@ $(if $(KBUILD_OUTPUT),, \
214 - # 'sub-make' below.
215 - MAKEFLAGS += --include-dir=$(CURDIR)
216 -
217 -+need-sub-make := 1
218 -+else
219 -+
220 -+# Do not print "Entering directory ..." at all for in-tree build.
221 -+MAKEFLAGS += --no-print-directory
222 -+
223 -+endif # ifneq ($(KBUILD_OUTPUT),)
224 -+
225 -+ifneq ($(filter 3.%,$(MAKE_VERSION)),)
226 -+# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
227 -+# We need to invoke sub-make to avoid implicit rules in the top Makefile.
228 -+need-sub-make := 1
229 -+# Cancel implicit rules for this Makefile.
230 -+$(lastword $(MAKEFILE_LIST)): ;
231 -+endif
232 -+
233 -+ifeq ($(need-sub-make),1)
234 -+
235 - PHONY += $(MAKECMDGOALS) sub-make
236 -
237 - $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
238 -@@ -149,16 +168,15 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
239 -
240 - # Invoke a second make in the output directory, passing relevant variables
241 - sub-make:
242 -- $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
243 -+ $(Q)$(MAKE) sub-make-done=1 \
244 -+ $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
245 - -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
246 -
247 --# Leave processing to above invocation of make
248 --skip-makefile := 1
249 --endif # ifneq ($(KBUILD_OUTPUT),)
250 --endif # ifeq ($(KBUILD_SRC),)
251 -+endif # need-sub-make
252 -+endif # sub-make-done
253 -
254 - # We process the rest of the Makefile if this is the final invocation of make
255 --ifeq ($(skip-makefile),)
256 -+ifeq ($(need-sub-make),)
257 -
258 - # Do not print "Entering directory ...",
259 - # but we want to display it when entering to the output directory
260 -@@ -492,7 +510,7 @@ endif
261 +@@ -510,7 +510,7 @@ endif
262 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
263 ifneq ($(CROSS_COMPILE),)
264 CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
265 @@ -245,55 +20,6 @@ index d5713e7b1e50..f7666051de66 100644
266 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
267 GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
268 endif
269 -@@ -625,12 +643,15 @@ ifeq ($(may-sync-config),1)
270 - -include include/config/auto.conf.cmd
271 -
272 - # To avoid any implicit rule to kick in, define an empty command
273 --$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
274 -+$(KCONFIG_CONFIG): ;
275 -
276 - # The actual configuration files used during the build are stored in
277 - # include/generated/ and include/config/. Update them if .config is newer than
278 - # include/config/auto.conf (which mirrors .config).
279 --include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
280 -+#
281 -+# This exploits the 'multi-target pattern rule' trick.
282 -+# The syncconfig should be executed only once to make all the targets.
283 -+%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
284 - $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
285 - else
286 - # External modules and some install targets need include/generated/autoconf.h
287 -@@ -944,9 +965,11 @@ mod_sign_cmd = true
288 - endif
289 - export mod_sign_cmd
290 -
291 -+HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
292 -+
293 - ifdef CONFIG_STACK_VALIDATION
294 - has_libelf := $(call try-run,\
295 -- echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
296 -+ echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
297 - ifeq ($(has_libelf),1)
298 - objtool_target := tools/objtool FORCE
299 - else
300 -@@ -1754,7 +1777,7 @@ $(cmd_files): ; # Do not try to update included dependency files
301 -
302 - endif # ifeq ($(config-targets),1)
303 - endif # ifeq ($(mixed-targets),1)
304 --endif # skip-makefile
305 -+endif # need-sub-make
306 -
307 - PHONY += FORCE
308 - FORCE:
309 -diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl
310 -index 7b56a53be5e3..e09558edae73 100644
311 ---- a/arch/alpha/kernel/syscalls/syscall.tbl
312 -+++ b/arch/alpha/kernel/syscalls/syscall.tbl
313 -@@ -451,3 +451,4 @@
314 - 520 common preadv2 sys_preadv2
315 - 521 common pwritev2 sys_pwritev2
316 - 522 common statx sys_statx
317 -+523 common io_pgetevents sys_io_pgetevents
318 diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
319 index dce5be5df97b..edcff79879e7 100644
320 --- a/arch/arm/boot/dts/am335x-evm.dts
321 @@ -382,181 +108,6 @@ index b128998097ce..2c2d8b5b8cf5 100644
322 };
323 };
324
325 -diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
326 -index 608d17454179..5892a9f7622f 100644
327 ---- a/arch/arm/boot/dts/exynos3250.dtsi
328 -+++ b/arch/arm/boot/dts/exynos3250.dtsi
329 -@@ -168,6 +168,9 @@
330 - interrupt-controller;
331 - #interrupt-cells = <3>;
332 - interrupt-parent = <&gic>;
333 -+ clock-names = "clkout8";
334 -+ clocks = <&cmu CLK_FIN_PLL>;
335 -+ #clock-cells = <1>;
336 - };
337 -
338 - mipi_phy: video-phy {
339 -diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
340 -index 3a9eb1e91c45..8a64c4e8c474 100644
341 ---- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
342 -+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
343 -@@ -49,7 +49,7 @@
344 - };
345 -
346 - emmc_pwrseq: pwrseq {
347 -- pinctrl-0 = <&sd1_cd>;
348 -+ pinctrl-0 = <&emmc_rstn>;
349 - pinctrl-names = "default";
350 - compatible = "mmc-pwrseq-emmc";
351 - reset-gpios = <&gpk1 2 GPIO_ACTIVE_LOW>;
352 -@@ -165,12 +165,6 @@
353 - cpu0-supply = <&buck2_reg>;
354 - };
355 -
356 --/* RSTN signal for eMMC */
357 --&sd1_cd {
358 -- samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
359 -- samsung,pin-drv = <EXYNOS4_PIN_DRV_LV1>;
360 --};
361 --
362 - &pinctrl_1 {
363 - gpio_power_key: power_key {
364 - samsung,pins = "gpx1-3";
365 -@@ -188,6 +182,11 @@
366 - samsung,pins = "gpx3-7";
367 - samsung,pin-pud = <EXYNOS_PIN_PULL_DOWN>;
368 - };
369 -+
370 -+ emmc_rstn: emmc-rstn {
371 -+ samsung,pins = "gpk1-2";
372 -+ samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
373 -+ };
374 - };
375 -
376 - &ehci {
377 -diff --git a/arch/arm/boot/dts/exynos5422-odroid-core.dtsi b/arch/arm/boot/dts/exynos5422-odroid-core.dtsi
378 -index bf09eab90f8a..6bf3661293ee 100644
379 ---- a/arch/arm/boot/dts/exynos5422-odroid-core.dtsi
380 -+++ b/arch/arm/boot/dts/exynos5422-odroid-core.dtsi
381 -@@ -468,7 +468,7 @@
382 - buck8_reg: BUCK8 {
383 - regulator-name = "vdd_1.8v_ldo";
384 - regulator-min-microvolt = <800000>;
385 -- regulator-max-microvolt = <1500000>;
386 -+ regulator-max-microvolt = <2000000>;
387 - regulator-always-on;
388 - regulator-boot-on;
389 - };
390 -diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi
391 -index b7303a4e4236..ed0d6fb20122 100644
392 ---- a/arch/arm/boot/dts/lpc32xx.dtsi
393 -+++ b/arch/arm/boot/dts/lpc32xx.dtsi
394 -@@ -230,7 +230,7 @@
395 - status = "disabled";
396 - };
397 -
398 -- i2s1: i2s@2009C000 {
399 -+ i2s1: i2s@2009c000 {
400 - compatible = "nxp,lpc3220-i2s";
401 - reg = <0x2009C000 0x1000>;
402 - };
403 -@@ -273,7 +273,7 @@
404 - status = "disabled";
405 - };
406 -
407 -- i2c1: i2c@400A0000 {
408 -+ i2c1: i2c@400a0000 {
409 - compatible = "nxp,pnx-i2c";
410 - reg = <0x400A0000 0x100>;
411 - interrupt-parent = <&sic1>;
412 -@@ -284,7 +284,7 @@
413 - clocks = <&clk LPC32XX_CLK_I2C1>;
414 - };
415 -
416 -- i2c2: i2c@400A8000 {
417 -+ i2c2: i2c@400a8000 {
418 - compatible = "nxp,pnx-i2c";
419 - reg = <0x400A8000 0x100>;
420 - interrupt-parent = <&sic1>;
421 -@@ -295,7 +295,7 @@
422 - clocks = <&clk LPC32XX_CLK_I2C2>;
423 - };
424 -
425 -- mpwm: mpwm@400E8000 {
426 -+ mpwm: mpwm@400e8000 {
427 - compatible = "nxp,lpc3220-motor-pwm";
428 - reg = <0x400E8000 0x78>;
429 - status = "disabled";
430 -@@ -394,7 +394,7 @@
431 - #gpio-cells = <3>; /* bank, pin, flags */
432 - };
433 -
434 -- timer4: timer@4002C000 {
435 -+ timer4: timer@4002c000 {
436 - compatible = "nxp,lpc3220-timer";
437 - reg = <0x4002C000 0x1000>;
438 - interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
439 -@@ -412,7 +412,7 @@
440 - status = "disabled";
441 - };
442 -
443 -- watchdog: watchdog@4003C000 {
444 -+ watchdog: watchdog@4003c000 {
445 - compatible = "nxp,pnx4008-wdt";
446 - reg = <0x4003C000 0x1000>;
447 - clocks = <&clk LPC32XX_CLK_WDOG>;
448 -@@ -451,7 +451,7 @@
449 - status = "disabled";
450 - };
451 -
452 -- timer1: timer@4004C000 {
453 -+ timer1: timer@4004c000 {
454 - compatible = "nxp,lpc3220-timer";
455 - reg = <0x4004C000 0x1000>;
456 - interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
457 -@@ -475,7 +475,7 @@
458 - status = "disabled";
459 - };
460 -
461 -- pwm1: pwm@4005C000 {
462 -+ pwm1: pwm@4005c000 {
463 - compatible = "nxp,lpc3220-pwm";
464 - reg = <0x4005C000 0x4>;
465 - clocks = <&clk LPC32XX_CLK_PWM1>;
466 -@@ -484,7 +484,7 @@
467 - status = "disabled";
468 - };
469 -
470 -- pwm2: pwm@4005C004 {
471 -+ pwm2: pwm@4005c004 {
472 - compatible = "nxp,lpc3220-pwm";
473 - reg = <0x4005C004 0x4>;
474 - clocks = <&clk LPC32XX_CLK_PWM2>;
475 -diff --git a/arch/arm/boot/dts/meson8b.dtsi b/arch/arm/boot/dts/meson8b.dtsi
476 -index 22d775460767..dc125769fe85 100644
477 ---- a/arch/arm/boot/dts/meson8b.dtsi
478 -+++ b/arch/arm/boot/dts/meson8b.dtsi
479 -@@ -270,9 +270,7 @@
480 - groups = "eth_tx_clk",
481 - "eth_tx_en",
482 - "eth_txd1_0",
483 -- "eth_txd1_1",
484 - "eth_txd0_0",
485 -- "eth_txd0_1",
486 - "eth_rx_clk",
487 - "eth_rx_dv",
488 - "eth_rxd1",
489 -@@ -281,7 +279,9 @@
490 - "eth_mdc",
491 - "eth_ref_clk",
492 - "eth_txd2",
493 -- "eth_txd3";
494 -+ "eth_txd3",
495 -+ "eth_rxd3",
496 -+ "eth_rxd2";
497 - function = "ethernet";
498 - bias-disable;
499 - };
500 diff --git a/arch/arm/boot/dts/rk3288-tinker.dtsi b/arch/arm/boot/dts/rk3288-tinker.dtsi
501 index aa107ee41b8b..ef653c3209bc 100644
502 --- a/arch/arm/boot/dts/rk3288-tinker.dtsi
503 @@ -622,317 +173,6 @@ index 1c01a6f843d8..28a2e45752fe 100644
504 #define PIN_PC9__TIOA4 PINMUX_PIN(PIN_PC9, 4, 2)
505 #define PIN_PC10 74
506 #define PIN_PC10__GPIO PINMUX_PIN(PIN_PC10, 0, 0)
507 -diff --git a/arch/arm/crypto/crct10dif-ce-core.S b/arch/arm/crypto/crct10dif-ce-core.S
508 -index ce45ba0c0687..16019b5961e7 100644
509 ---- a/arch/arm/crypto/crct10dif-ce-core.S
510 -+++ b/arch/arm/crypto/crct10dif-ce-core.S
511 -@@ -124,10 +124,10 @@ ENTRY(crc_t10dif_pmull)
512 - vext.8 q10, qzr, q0, #4
513 -
514 - // receive the initial 64B data, xor the initial crc value
515 -- vld1.64 {q0-q1}, [arg2, :128]!
516 -- vld1.64 {q2-q3}, [arg2, :128]!
517 -- vld1.64 {q4-q5}, [arg2, :128]!
518 -- vld1.64 {q6-q7}, [arg2, :128]!
519 -+ vld1.64 {q0-q1}, [arg2]!
520 -+ vld1.64 {q2-q3}, [arg2]!
521 -+ vld1.64 {q4-q5}, [arg2]!
522 -+ vld1.64 {q6-q7}, [arg2]!
523 - CPU_LE( vrev64.8 q0, q0 )
524 - CPU_LE( vrev64.8 q1, q1 )
525 - CPU_LE( vrev64.8 q2, q2 )
526 -@@ -167,7 +167,7 @@ CPU_LE( vrev64.8 q7, q7 )
527 - _fold_64_B_loop:
528 -
529 - .macro fold64, reg1, reg2
530 -- vld1.64 {q11-q12}, [arg2, :128]!
531 -+ vld1.64 {q11-q12}, [arg2]!
532 -
533 - vmull.p64 q8, \reg1\()h, d21
534 - vmull.p64 \reg1, \reg1\()l, d20
535 -@@ -238,7 +238,7 @@ _16B_reduction_loop:
536 - vmull.p64 q7, d15, d21
537 - veor.8 q7, q7, q8
538 -
539 -- vld1.64 {q0}, [arg2, :128]!
540 -+ vld1.64 {q0}, [arg2]!
541 - CPU_LE( vrev64.8 q0, q0 )
542 - vswp d0, d1
543 - veor.8 q7, q7, q0
544 -@@ -335,7 +335,7 @@ _less_than_128:
545 - vmov.i8 q0, #0
546 - vmov s3, arg1_low32 // get the initial crc value
547 -
548 -- vld1.64 {q7}, [arg2, :128]!
549 -+ vld1.64 {q7}, [arg2]!
550 - CPU_LE( vrev64.8 q7, q7 )
551 - vswp d14, d15
552 - veor.8 q7, q7, q0
553 -diff --git a/arch/arm/crypto/crct10dif-ce-glue.c b/arch/arm/crypto/crct10dif-ce-glue.c
554 -index d428355cf38d..14c19c70a841 100644
555 ---- a/arch/arm/crypto/crct10dif-ce-glue.c
556 -+++ b/arch/arm/crypto/crct10dif-ce-glue.c
557 -@@ -35,26 +35,15 @@ static int crct10dif_update(struct shash_desc *desc, const u8 *data,
558 - unsigned int length)
559 - {
560 - u16 *crc = shash_desc_ctx(desc);
561 -- unsigned int l;
562 -
563 -- if (!may_use_simd()) {
564 -- *crc = crc_t10dif_generic(*crc, data, length);
565 -+ if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE && may_use_simd()) {
566 -+ kernel_neon_begin();
567 -+ *crc = crc_t10dif_pmull(*crc, data, length);
568 -+ kernel_neon_end();
569 - } else {
570 -- if (unlikely((u32)data % CRC_T10DIF_PMULL_CHUNK_SIZE)) {
571 -- l = min_t(u32, length, CRC_T10DIF_PMULL_CHUNK_SIZE -
572 -- ((u32)data % CRC_T10DIF_PMULL_CHUNK_SIZE));
573 --
574 -- *crc = crc_t10dif_generic(*crc, data, l);
575 --
576 -- length -= l;
577 -- data += l;
578 -- }
579 -- if (length > 0) {
580 -- kernel_neon_begin();
581 -- *crc = crc_t10dif_pmull(*crc, data, length);
582 -- kernel_neon_end();
583 -- }
584 -+ *crc = crc_t10dif_generic(*crc, data, length);
585 - }
586 -+
587 - return 0;
588 - }
589 -
590 -diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
591 -index 69772e742a0a..83ae97c049d9 100644
592 ---- a/arch/arm/include/asm/barrier.h
593 -+++ b/arch/arm/include/asm/barrier.h
594 -@@ -11,6 +11,8 @@
595 - #define sev() __asm__ __volatile__ ("sev" : : : "memory")
596 - #define wfe() __asm__ __volatile__ ("wfe" : : : "memory")
597 - #define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
598 -+#else
599 -+#define wfe() do { } while (0)
600 - #endif
601 -
602 - #if __LINUX_ARM_ARCH__ >= 7
603 -diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
604 -index 120f4c9bbfde..57fe73ea0f72 100644
605 ---- a/arch/arm/include/asm/processor.h
606 -+++ b/arch/arm/include/asm/processor.h
607 -@@ -89,7 +89,11 @@ extern void release_thread(struct task_struct *);
608 - unsigned long get_wchan(struct task_struct *p);
609 -
610 - #if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
611 --#define cpu_relax() smp_mb()
612 -+#define cpu_relax() \
613 -+ do { \
614 -+ smp_mb(); \
615 -+ __asm__ __volatile__("nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;"); \
616 -+ } while (0)
617 - #else
618 - #define cpu_relax() barrier()
619 - #endif
620 -diff --git a/arch/arm/include/asm/v7m.h b/arch/arm/include/asm/v7m.h
621 -index 187ccf6496ad..2cb00d15831b 100644
622 ---- a/arch/arm/include/asm/v7m.h
623 -+++ b/arch/arm/include/asm/v7m.h
624 -@@ -49,7 +49,7 @@
625 - * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01.
626 - */
627 - #define EXC_RET_STACK_MASK 0x00000004
628 --#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd
629 -+#define EXC_RET_THREADMODE_PROCESSSTACK (3 << 2)
630 -
631 - /* Cache related definitions */
632 -
633 -diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
634 -index 773424843d6e..62db1c9746cb 100644
635 ---- a/arch/arm/kernel/entry-header.S
636 -+++ b/arch/arm/kernel/entry-header.S
637 -@@ -127,7 +127,8 @@
638 - */
639 - .macro v7m_exception_slow_exit ret_r0
640 - cpsid i
641 -- ldr lr, =EXC_RET_THREADMODE_PROCESSSTACK
642 -+ ldr lr, =exc_ret
643 -+ ldr lr, [lr]
644 -
645 - @ read original r12, sp, lr, pc and xPSR
646 - add r12, sp, #S_IP
647 -diff --git a/arch/arm/kernel/entry-v7m.S b/arch/arm/kernel/entry-v7m.S
648 -index abcf47848525..19d2dcd6530d 100644
649 ---- a/arch/arm/kernel/entry-v7m.S
650 -+++ b/arch/arm/kernel/entry-v7m.S
651 -@@ -146,3 +146,7 @@ ENTRY(vector_table)
652 - .rept CONFIG_CPU_V7M_NUM_IRQ
653 - .long __irq_entry @ External Interrupts
654 - .endr
655 -+ .align 2
656 -+ .globl exc_ret
657 -+exc_ret:
658 -+ .space 4
659 -diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
660 -index dd2eb5f76b9f..76300f3813e8 100644
661 ---- a/arch/arm/kernel/machine_kexec.c
662 -+++ b/arch/arm/kernel/machine_kexec.c
663 -@@ -91,8 +91,11 @@ void machine_crash_nonpanic_core(void *unused)
664 -
665 - set_cpu_online(smp_processor_id(), false);
666 - atomic_dec(&waiting_for_crash_ipi);
667 -- while (1)
668 -+
669 -+ while (1) {
670 - cpu_relax();
671 -+ wfe();
672 -+ }
673 - }
674 -
675 - void crash_smp_send_stop(void)
676 -diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
677 -index 1d6f5ea522f4..a3ce7c5365fa 100644
678 ---- a/arch/arm/kernel/smp.c
679 -+++ b/arch/arm/kernel/smp.c
680 -@@ -604,8 +604,10 @@ static void ipi_cpu_stop(unsigned int cpu)
681 - local_fiq_disable();
682 - local_irq_disable();
683 -
684 -- while (1)
685 -+ while (1) {
686 - cpu_relax();
687 -+ wfe();
688 -+ }
689 - }
690 -
691 - static DEFINE_PER_CPU(struct completion *, cpu_completion);
692 -diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c
693 -index 0bee233fef9a..314cfb232a63 100644
694 ---- a/arch/arm/kernel/unwind.c
695 -+++ b/arch/arm/kernel/unwind.c
696 -@@ -93,7 +93,7 @@ extern const struct unwind_idx __start_unwind_idx[];
697 - static const struct unwind_idx *__origin_unwind_idx;
698 - extern const struct unwind_idx __stop_unwind_idx[];
699 -
700 --static DEFINE_SPINLOCK(unwind_lock);
701 -+static DEFINE_RAW_SPINLOCK(unwind_lock);
702 - static LIST_HEAD(unwind_tables);
703 -
704 - /* Convert a prel31 symbol to an absolute address */
705 -@@ -201,7 +201,7 @@ static const struct unwind_idx *unwind_find_idx(unsigned long addr)
706 - /* module unwind tables */
707 - struct unwind_table *table;
708 -
709 -- spin_lock_irqsave(&unwind_lock, flags);
710 -+ raw_spin_lock_irqsave(&unwind_lock, flags);
711 - list_for_each_entry(table, &unwind_tables, list) {
712 - if (addr >= table->begin_addr &&
713 - addr < table->end_addr) {
714 -@@ -213,7 +213,7 @@ static const struct unwind_idx *unwind_find_idx(unsigned long addr)
715 - break;
716 - }
717 - }
718 -- spin_unlock_irqrestore(&unwind_lock, flags);
719 -+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
720 - }
721 -
722 - pr_debug("%s: idx = %p\n", __func__, idx);
723 -@@ -529,9 +529,9 @@ struct unwind_table *unwind_table_add(unsigned long start, unsigned long size,
724 - tab->begin_addr = text_addr;
725 - tab->end_addr = text_addr + text_size;
726 -
727 -- spin_lock_irqsave(&unwind_lock, flags);
728 -+ raw_spin_lock_irqsave(&unwind_lock, flags);
729 - list_add_tail(&tab->list, &unwind_tables);
730 -- spin_unlock_irqrestore(&unwind_lock, flags);
731 -+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
732 -
733 - return tab;
734 - }
735 -@@ -543,9 +543,9 @@ void unwind_table_del(struct unwind_table *tab)
736 - if (!tab)
737 - return;
738 -
739 -- spin_lock_irqsave(&unwind_lock, flags);
740 -+ raw_spin_lock_irqsave(&unwind_lock, flags);
741 - list_del(&tab->list);
742 -- spin_unlock_irqrestore(&unwind_lock, flags);
743 -+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
744 -
745 - kfree(tab);
746 - }
747 -diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
748 -index ad25fd1872c7..0bff0176db2c 100644
749 ---- a/arch/arm/lib/Makefile
750 -+++ b/arch/arm/lib/Makefile
751 -@@ -39,7 +39,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S
752 - $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S
753 -
754 - ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
755 -- NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon
756 -+ NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
757 - CFLAGS_xor-neon.o += $(NEON_FLAGS)
758 - obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o
759 - endif
760 -diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
761 -index 2c40aeab3eaa..c691b901092f 100644
762 ---- a/arch/arm/lib/xor-neon.c
763 -+++ b/arch/arm/lib/xor-neon.c
764 -@@ -14,7 +14,7 @@
765 - MODULE_LICENSE("GPL");
766 -
767 - #ifndef __ARM_NEON__
768 --#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon'
769 -+#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
770 - #endif
771 -
772 - /*
773 -diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
774 -index bfeb25aaf9a2..326e870d7123 100644
775 ---- a/arch/arm/mach-imx/cpuidle-imx6q.c
776 -+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
777 -@@ -16,30 +16,23 @@
778 - #include "cpuidle.h"
779 - #include "hardware.h"
780 -
781 --static atomic_t master = ATOMIC_INIT(0);
782 --static DEFINE_SPINLOCK(master_lock);
783 -+static int num_idle_cpus = 0;
784 -+static DEFINE_SPINLOCK(cpuidle_lock);
785 -
786 - static int imx6q_enter_wait(struct cpuidle_device *dev,
787 - struct cpuidle_driver *drv, int index)
788 - {
789 -- if (atomic_inc_return(&master) == num_online_cpus()) {
790 -- /*
791 -- * With this lock, we prevent other cpu to exit and enter
792 -- * this function again and become the master.
793 -- */
794 -- if (!spin_trylock(&master_lock))
795 -- goto idle;
796 -+ spin_lock(&cpuidle_lock);
797 -+ if (++num_idle_cpus == num_online_cpus())
798 - imx6_set_lpm(WAIT_UNCLOCKED);
799 -- cpu_do_idle();
800 -- imx6_set_lpm(WAIT_CLOCKED);
801 -- spin_unlock(&master_lock);
802 -- goto done;
803 -- }
804 -+ spin_unlock(&cpuidle_lock);
805 -
806 --idle:
807 - cpu_do_idle();
808 --done:
809 -- atomic_dec(&master);
810 -+
811 -+ spin_lock(&cpuidle_lock);
812 -+ if (num_idle_cpus-- == num_online_cpus())
813 -+ imx6_set_lpm(WAIT_CLOCKED);
814 -+ spin_unlock(&cpuidle_lock);
815 -
816 - return index;
817 - }
818 diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
819 index c4c0a8ea11e4..ee410ae7369e 100644
820 --- a/arch/arm/mach-omap1/board-ams-delta.c
821 @@ -953,174 +193,6 @@ index c4c0a8ea11e4..ee410ae7369e 100644
822 .ngpio = LATCH2_NGPIO,
823 };
824
825 -diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
826 -index 058a37e6d11c..fd6e0671f957 100644
827 ---- a/arch/arm/mach-omap2/prm_common.c
828 -+++ b/arch/arm/mach-omap2/prm_common.c
829 -@@ -523,8 +523,10 @@ void omap_prm_reset_system(void)
830 -
831 - prm_ll_data->reset_system();
832 -
833 -- while (1)
834 -+ while (1) {
835 - cpu_relax();
836 -+ wfe();
837 -+ }
838 - }
839 -
840 - /**
841 -diff --git a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
842 -index 058ce73137e8..5d819b6ea428 100644
843 ---- a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
844 -+++ b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
845 -@@ -65,16 +65,16 @@ static int osiris_dvs_notify(struct notifier_block *nb,
846 -
847 - switch (val) {
848 - case CPUFREQ_PRECHANGE:
849 -- if (old_dvs & !new_dvs ||
850 -- cur_dvs & !new_dvs) {
851 -+ if ((old_dvs && !new_dvs) ||
852 -+ (cur_dvs && !new_dvs)) {
853 - pr_debug("%s: exiting dvs\n", __func__);
854 - cur_dvs = false;
855 - gpio_set_value(OSIRIS_GPIO_DVS, 1);
856 - }
857 - break;
858 - case CPUFREQ_POSTCHANGE:
859 -- if (!old_dvs & new_dvs ||
860 -- !cur_dvs & new_dvs) {
861 -+ if ((!old_dvs && new_dvs) ||
862 -+ (!cur_dvs && new_dvs)) {
863 - pr_debug("entering dvs\n");
864 - cur_dvs = true;
865 - gpio_set_value(OSIRIS_GPIO_DVS, 0);
866 -diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
867 -index 8e50daa99151..dc526ef2e9b3 100644
868 ---- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
869 -+++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
870 -@@ -40,6 +40,7 @@
871 - struct regulator_quirk {
872 - struct list_head list;
873 - const struct of_device_id *id;
874 -+ struct device_node *np;
875 - struct of_phandle_args irq_args;
876 - struct i2c_msg i2c_msg;
877 - bool shared; /* IRQ line is shared */
878 -@@ -101,6 +102,9 @@ static int regulator_quirk_notify(struct notifier_block *nb,
879 - if (!pos->shared)
880 - continue;
881 -
882 -+ if (pos->np->parent != client->dev.parent->of_node)
883 -+ continue;
884 -+
885 - dev_info(&client->dev, "clearing %s@0x%02x interrupts\n",
886 - pos->id->compatible, pos->i2c_msg.addr);
887 -
888 -@@ -165,6 +169,7 @@ static int __init rcar_gen2_regulator_quirk(void)
889 - memcpy(&quirk->i2c_msg, id->data, sizeof(quirk->i2c_msg));
890 -
891 - quirk->id = id;
892 -+ quirk->np = np;
893 - quirk->i2c_msg.addr = addr;
894 -
895 - ret = of_irq_parse_one(np, 0, argsa);
896 -diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
897 -index b03202cddddb..f74cdce6d4da 100644
898 ---- a/arch/arm/mm/copypage-v4mc.c
899 -+++ b/arch/arm/mm/copypage-v4mc.c
900 -@@ -45,6 +45,7 @@ static void mc_copy_user_page(void *from, void *to)
901 - int tmp;
902 -
903 - asm volatile ("\
904 -+ .syntax unified\n\
905 - ldmia %0!, {r2, r3, ip, lr} @ 4\n\
906 - 1: mcr p15, 0, %1, c7, c6, 1 @ 1 invalidate D line\n\
907 - stmia %1!, {r2, r3, ip, lr} @ 4\n\
908 -@@ -56,7 +57,7 @@ static void mc_copy_user_page(void *from, void *to)
909 - ldmia %0!, {r2, r3, ip, lr} @ 4\n\
910 - subs %2, %2, #1 @ 1\n\
911 - stmia %1!, {r2, r3, ip, lr} @ 4\n\
912 -- ldmneia %0!, {r2, r3, ip, lr} @ 4\n\
913 -+ ldmiane %0!, {r2, r3, ip, lr} @ 4\n\
914 - bne 1b @ "
915 - : "+&r" (from), "+&r" (to), "=&r" (tmp)
916 - : "2" (PAGE_SIZE / 64)
917 -diff --git a/arch/arm/mm/copypage-v4wb.c b/arch/arm/mm/copypage-v4wb.c
918 -index cd3e165afeed..6d336740aae4 100644
919 ---- a/arch/arm/mm/copypage-v4wb.c
920 -+++ b/arch/arm/mm/copypage-v4wb.c
921 -@@ -27,6 +27,7 @@ static void v4wb_copy_user_page(void *kto, const void *kfrom)
922 - int tmp;
923 -
924 - asm volatile ("\
925 -+ .syntax unified\n\
926 - ldmia %1!, {r3, r4, ip, lr} @ 4\n\
927 - 1: mcr p15, 0, %0, c7, c6, 1 @ 1 invalidate D line\n\
928 - stmia %0!, {r3, r4, ip, lr} @ 4\n\
929 -@@ -38,7 +39,7 @@ static void v4wb_copy_user_page(void *kto, const void *kfrom)
930 - ldmia %1!, {r3, r4, ip, lr} @ 4\n\
931 - subs %2, %2, #1 @ 1\n\
932 - stmia %0!, {r3, r4, ip, lr} @ 4\n\
933 -- ldmneia %1!, {r3, r4, ip, lr} @ 4\n\
934 -+ ldmiane %1!, {r3, r4, ip, lr} @ 4\n\
935 - bne 1b @ 1\n\
936 - mcr p15, 0, %1, c7, c10, 4 @ 1 drain WB"
937 - : "+&r" (kto), "+&r" (kfrom), "=&r" (tmp)
938 -diff --git a/arch/arm/mm/copypage-v4wt.c b/arch/arm/mm/copypage-v4wt.c
939 -index 8614572e1296..3851bb396442 100644
940 ---- a/arch/arm/mm/copypage-v4wt.c
941 -+++ b/arch/arm/mm/copypage-v4wt.c
942 -@@ -25,6 +25,7 @@ static void v4wt_copy_user_page(void *kto, const void *kfrom)
943 - int tmp;
944 -
945 - asm volatile ("\
946 -+ .syntax unified\n\
947 - ldmia %1!, {r3, r4, ip, lr} @ 4\n\
948 - 1: stmia %0!, {r3, r4, ip, lr} @ 4\n\
949 - ldmia %1!, {r3, r4, ip, lr} @ 4+1\n\
950 -@@ -34,7 +35,7 @@ static void v4wt_copy_user_page(void *kto, const void *kfrom)
951 - ldmia %1!, {r3, r4, ip, lr} @ 4\n\
952 - subs %2, %2, #1 @ 1\n\
953 - stmia %0!, {r3, r4, ip, lr} @ 4\n\
954 -- ldmneia %1!, {r3, r4, ip, lr} @ 4\n\
955 -+ ldmiane %1!, {r3, r4, ip, lr} @ 4\n\
956 - bne 1b @ 1\n\
957 - mcr p15, 0, %2, c7, c7, 0 @ flush ID cache"
958 - : "+&r" (kto), "+&r" (kfrom), "=&r" (tmp)
959 -diff --git a/arch/arm/mm/proc-v7m.S b/arch/arm/mm/proc-v7m.S
960 -index 47a5acc64433..92e84181933a 100644
961 ---- a/arch/arm/mm/proc-v7m.S
962 -+++ b/arch/arm/mm/proc-v7m.S
963 -@@ -139,6 +139,9 @@ __v7m_setup_cont:
964 - cpsie i
965 - svc #0
966 - 1: cpsid i
967 -+ ldr r0, =exc_ret
968 -+ orr lr, lr, #EXC_RET_THREADMODE_PROCESSSTACK
969 -+ str lr, [r0]
970 - ldmia sp, {r0-r3, r12}
971 - str r5, [r12, #11 * 4] @ restore the original SVC vector entry
972 - mov lr, r6 @ restore LR
973 -diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
974 -index 610235028cc7..c14205cd6bf5 100644
975 ---- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
976 -+++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
977 -@@ -118,6 +118,7 @@
978 - reset-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
979 - clocks = <&pmic>;
980 - clock-names = "ext_clock";
981 -+ post-power-on-delay-ms = <10>;
982 - power-off-delay-us = <10>;
983 - };
984 -
985 -@@ -300,7 +301,6 @@
986 -
987 - dwmmc_0: dwmmc0@f723d000 {
988 - cap-mmc-highspeed;
989 -- mmc-hs200-1_8v;
990 - non-removable;
991 - bus-width = <0x8>;
992 - vmmc-supply = <&ldo19>;
993 diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
994 index 040b36ef0dd2..520ed8e474be 100644
995 --- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
996 @@ -1246,126 +318,6 @@ index ecd7f19c3542..97aa65455b4a 100644
997 };
998
999 rmiim1_pins: rmiim1-pins {
1000 -diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts b/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts
1001 -index 13a0a028df98..e5699d0d91e4 100644
1002 ---- a/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts
1003 -+++ b/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts
1004 -@@ -101,6 +101,7 @@
1005 - sdio_pwrseq: sdio-pwrseq {
1006 - compatible = "mmc-pwrseq-simple";
1007 - reset-gpios = <&gpio 7 GPIO_ACTIVE_LOW>; /* WIFI_EN */
1008 -+ post-power-on-delay-ms = <10>;
1009 - };
1010 - };
1011 -
1012 -diff --git a/arch/arm64/crypto/aes-ce-ccm-core.S b/arch/arm64/crypto/aes-ce-ccm-core.S
1013 -index e3a375c4cb83..1b151442dac1 100644
1014 ---- a/arch/arm64/crypto/aes-ce-ccm-core.S
1015 -+++ b/arch/arm64/crypto/aes-ce-ccm-core.S
1016 -@@ -74,12 +74,13 @@ ENTRY(ce_aes_ccm_auth_data)
1017 - beq 10f
1018 - ext v0.16b, v0.16b, v0.16b, #1 /* rotate out the mac bytes */
1019 - b 7b
1020 --8: mov w7, w8
1021 -+8: cbz w8, 91f
1022 -+ mov w7, w8
1023 - add w8, w8, #16
1024 - 9: ext v1.16b, v1.16b, v1.16b, #1
1025 - adds w7, w7, #1
1026 - bne 9b
1027 -- eor v0.16b, v0.16b, v1.16b
1028 -+91: eor v0.16b, v0.16b, v1.16b
1029 - st1 {v0.16b}, [x0]
1030 - 10: str w8, [x3]
1031 - ret
1032 -diff --git a/arch/arm64/crypto/aes-ce-ccm-glue.c b/arch/arm64/crypto/aes-ce-ccm-glue.c
1033 -index 68b11aa690e4..986191e8c058 100644
1034 ---- a/arch/arm64/crypto/aes-ce-ccm-glue.c
1035 -+++ b/arch/arm64/crypto/aes-ce-ccm-glue.c
1036 -@@ -125,7 +125,7 @@ static void ccm_update_mac(struct crypto_aes_ctx *key, u8 mac[], u8 const in[],
1037 - abytes -= added;
1038 - }
1039 -
1040 -- while (abytes > AES_BLOCK_SIZE) {
1041 -+ while (abytes >= AES_BLOCK_SIZE) {
1042 - __aes_arm64_encrypt(key->key_enc, mac, mac,
1043 - num_rounds(key));
1044 - crypto_xor(mac, in, AES_BLOCK_SIZE);
1045 -@@ -139,8 +139,6 @@ static void ccm_update_mac(struct crypto_aes_ctx *key, u8 mac[], u8 const in[],
1046 - num_rounds(key));
1047 - crypto_xor(mac, in, abytes);
1048 - *macp = abytes;
1049 -- } else {
1050 -- *macp = 0;
1051 - }
1052 - }
1053 - }
1054 -diff --git a/arch/arm64/crypto/aes-neonbs-core.S b/arch/arm64/crypto/aes-neonbs-core.S
1055 -index e613a87f8b53..8432c8d0dea6 100644
1056 ---- a/arch/arm64/crypto/aes-neonbs-core.S
1057 -+++ b/arch/arm64/crypto/aes-neonbs-core.S
1058 -@@ -971,18 +971,22 @@ CPU_LE( rev x8, x8 )
1059 -
1060 - 8: next_ctr v0
1061 - st1 {v0.16b}, [x24]
1062 -- cbz x23, 0f
1063 -+ cbz x23, .Lctr_done
1064 -
1065 - cond_yield_neon 98b
1066 - b 99b
1067 -
1068 --0: frame_pop
1069 -+.Lctr_done:
1070 -+ frame_pop
1071 - ret
1072 -
1073 - /*
1074 - * If we are handling the tail of the input (x6 != NULL), return the
1075 - * final keystream block back to the caller.
1076 - */
1077 -+0: cbz x25, 8b
1078 -+ st1 {v0.16b}, [x25]
1079 -+ b 8b
1080 - 1: cbz x25, 8b
1081 - st1 {v1.16b}, [x25]
1082 - b 8b
1083 -diff --git a/arch/arm64/crypto/crct10dif-ce-glue.c b/arch/arm64/crypto/crct10dif-ce-glue.c
1084 -index b461d62023f2..567c24f3d224 100644
1085 ---- a/arch/arm64/crypto/crct10dif-ce-glue.c
1086 -+++ b/arch/arm64/crypto/crct10dif-ce-glue.c
1087 -@@ -39,26 +39,13 @@ static int crct10dif_update(struct shash_desc *desc, const u8 *data,
1088 - unsigned int length)
1089 - {
1090 - u16 *crc = shash_desc_ctx(desc);
1091 -- unsigned int l;
1092 -
1093 -- if (unlikely((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE)) {
1094 -- l = min_t(u32, length, CRC_T10DIF_PMULL_CHUNK_SIZE -
1095 -- ((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE));
1096 --
1097 -- *crc = crc_t10dif_generic(*crc, data, l);
1098 --
1099 -- length -= l;
1100 -- data += l;
1101 -- }
1102 --
1103 -- if (length > 0) {
1104 -- if (may_use_simd()) {
1105 -- kernel_neon_begin();
1106 -- *crc = crc_t10dif_pmull(*crc, data, length);
1107 -- kernel_neon_end();
1108 -- } else {
1109 -- *crc = crc_t10dif_generic(*crc, data, length);
1110 -- }
1111 -+ if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE && may_use_simd()) {
1112 -+ kernel_neon_begin();
1113 -+ *crc = crc_t10dif_pmull(*crc, data, length);
1114 -+ kernel_neon_end();
1115 -+ } else {
1116 -+ *crc = crc_t10dif_generic(*crc, data, length);
1117 - }
1118 -
1119 - return 0;
1120 diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
1121 index cccb83ad7fa8..e1d95f08f8e1 100644
1122 --- a/arch/arm64/include/asm/futex.h
1123 @@ -1418,57 +370,6 @@ index cccb83ad7fa8..e1d95f08f8e1 100644
1124 ret, oldval, uaddr, tmp, oparg);
1125 break;
1126 default:
1127 -diff --git a/arch/arm64/include/asm/hardirq.h b/arch/arm64/include/asm/hardirq.h
1128 -index 1473fc2f7ab7..89691c86640a 100644
1129 ---- a/arch/arm64/include/asm/hardirq.h
1130 -+++ b/arch/arm64/include/asm/hardirq.h
1131 -@@ -17,8 +17,12 @@
1132 - #define __ASM_HARDIRQ_H
1133 -
1134 - #include <linux/cache.h>
1135 -+#include <linux/percpu.h>
1136 - #include <linux/threads.h>
1137 -+#include <asm/barrier.h>
1138 - #include <asm/irq.h>
1139 -+#include <asm/kvm_arm.h>
1140 -+#include <asm/sysreg.h>
1141 -
1142 - #define NR_IPI 7
1143 -
1144 -@@ -37,6 +41,33 @@ u64 smp_irq_stat_cpu(unsigned int cpu);
1145 -
1146 - #define __ARCH_IRQ_EXIT_IRQS_DISABLED 1
1147 -
1148 -+struct nmi_ctx {
1149 -+ u64 hcr;
1150 -+};
1151 -+
1152 -+DECLARE_PER_CPU(struct nmi_ctx, nmi_contexts);
1153 -+
1154 -+#define arch_nmi_enter() \
1155 -+ do { \
1156 -+ if (is_kernel_in_hyp_mode()) { \
1157 -+ struct nmi_ctx *nmi_ctx = this_cpu_ptr(&nmi_contexts); \
1158 -+ nmi_ctx->hcr = read_sysreg(hcr_el2); \
1159 -+ if (!(nmi_ctx->hcr & HCR_TGE)) { \
1160 -+ write_sysreg(nmi_ctx->hcr | HCR_TGE, hcr_el2); \
1161 -+ isb(); \
1162 -+ } \
1163 -+ } \
1164 -+ } while (0)
1165 -+
1166 -+#define arch_nmi_exit() \
1167 -+ do { \
1168 -+ if (is_kernel_in_hyp_mode()) { \
1169 -+ struct nmi_ctx *nmi_ctx = this_cpu_ptr(&nmi_contexts); \
1170 -+ if (!(nmi_ctx->hcr & HCR_TGE)) \
1171 -+ write_sysreg(nmi_ctx->hcr, hcr_el2); \
1172 -+ } \
1173 -+ } while (0)
1174 -+
1175 - static inline void ack_bad_irq(unsigned int irq)
1176 - {
1177 - extern unsigned long irq_err_count;
1178 diff --git a/arch/arm64/include/asm/module.h b/arch/arm64/include/asm/module.h
1179 index 905e1bb0e7bd..cd9f4e9d04d3 100644
1180 --- a/arch/arm64/include/asm/module.h
1181 @@ -1497,86 +398,6 @@ index 8e4431a8821f..07b298120182 100644
1182 pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n");
1183 return -EINVAL;
1184 }
1185 -diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
1186 -index 780a12f59a8f..92fa81798fb9 100644
1187 ---- a/arch/arm64/kernel/irq.c
1188 -+++ b/arch/arm64/kernel/irq.c
1189 -@@ -33,6 +33,9 @@
1190 -
1191 - unsigned long irq_err_count;
1192 -
1193 -+/* Only access this in an NMI enter/exit */
1194 -+DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
1195 -+
1196 - DEFINE_PER_CPU(unsigned long *, irq_stack_ptr);
1197 -
1198 - int arch_show_interrupts(struct seq_file *p, int prec)
1199 -diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
1200 -index ce46c4cdf368..691854b77c7f 100644
1201 ---- a/arch/arm64/kernel/kgdb.c
1202 -+++ b/arch/arm64/kernel/kgdb.c
1203 -@@ -244,27 +244,33 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
1204 -
1205 - static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr)
1206 - {
1207 -+ if (user_mode(regs))
1208 -+ return DBG_HOOK_ERROR;
1209 -+
1210 - kgdb_handle_exception(1, SIGTRAP, 0, regs);
1211 -- return 0;
1212 -+ return DBG_HOOK_HANDLED;
1213 - }
1214 - NOKPROBE_SYMBOL(kgdb_brk_fn)
1215 -
1216 - static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr)
1217 - {
1218 -+ if (user_mode(regs))
1219 -+ return DBG_HOOK_ERROR;
1220 -+
1221 - compiled_break = 1;
1222 - kgdb_handle_exception(1, SIGTRAP, 0, regs);
1223 -
1224 -- return 0;
1225 -+ return DBG_HOOK_HANDLED;
1226 - }
1227 - NOKPROBE_SYMBOL(kgdb_compiled_brk_fn);
1228 -
1229 - static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
1230 - {
1231 -- if (!kgdb_single_step)
1232 -+ if (user_mode(regs) || !kgdb_single_step)
1233 - return DBG_HOOK_ERROR;
1234 -
1235 - kgdb_handle_exception(1, SIGTRAP, 0, regs);
1236 -- return 0;
1237 -+ return DBG_HOOK_HANDLED;
1238 - }
1239 - NOKPROBE_SYMBOL(kgdb_step_brk_fn);
1240 -
1241 -diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
1242 -index f17afb99890c..7fb6f3aa5ceb 100644
1243 ---- a/arch/arm64/kernel/probes/kprobes.c
1244 -+++ b/arch/arm64/kernel/probes/kprobes.c
1245 -@@ -450,6 +450,9 @@ kprobe_single_step_handler(struct pt_regs *regs, unsigned int esr)
1246 - struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
1247 - int retval;
1248 -
1249 -+ if (user_mode(regs))
1250 -+ return DBG_HOOK_ERROR;
1251 -+
1252 - /* return error if this is not our step */
1253 - retval = kprobe_ss_hit(kcb, instruction_pointer(regs));
1254 -
1255 -@@ -466,6 +469,9 @@ kprobe_single_step_handler(struct pt_regs *regs, unsigned int esr)
1256 - int __kprobes
1257 - kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
1258 - {
1259 -+ if (user_mode(regs))
1260 -+ return DBG_HOOK_ERROR;
1261 -+
1262 - kprobe_handler(regs);
1263 - return DBG_HOOK_HANDLED;
1264 - }
1265 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
1266 index 4e2fb877f8d5..92bfeb3e8d7c 100644
1267 --- a/arch/arm64/kernel/traps.c
1268 @@ -1625,55 +446,6 @@ index 4e2fb877f8d5..92bfeb3e8d7c 100644
1269
1270 return ret;
1271 }
1272 -diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
1273 -index c936aa40c3f4..b6dac3a68508 100644
1274 ---- a/arch/arm64/kvm/sys_regs.c
1275 -+++ b/arch/arm64/kvm/sys_regs.c
1276 -@@ -1476,7 +1476,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
1277 -
1278 - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 },
1279 - { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 },
1280 -- { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x70 },
1281 -+ { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 },
1282 - };
1283 -
1284 - static bool trap_dbgidr(struct kvm_vcpu *vcpu,
1285 -diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
1286 -index efb7b2cbead5..ef46925096f0 100644
1287 ---- a/arch/arm64/mm/fault.c
1288 -+++ b/arch/arm64/mm/fault.c
1289 -@@ -824,11 +824,12 @@ void __init hook_debug_fault_code(int nr,
1290 - debug_fault_info[nr].name = name;
1291 - }
1292 -
1293 --asmlinkage int __exception do_debug_exception(unsigned long addr,
1294 -+asmlinkage int __exception do_debug_exception(unsigned long addr_if_watchpoint,
1295 - unsigned int esr,
1296 - struct pt_regs *regs)
1297 - {
1298 - const struct fault_info *inf = esr_to_debug_fault_info(esr);
1299 -+ unsigned long pc = instruction_pointer(regs);
1300 - int rv;
1301 -
1302 - /*
1303 -@@ -838,14 +839,14 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
1304 - if (interrupts_enabled(regs))
1305 - trace_hardirqs_off();
1306 -
1307 -- if (user_mode(regs) && !is_ttbr0_addr(instruction_pointer(regs)))
1308 -+ if (user_mode(regs) && !is_ttbr0_addr(pc))
1309 - arm64_apply_bp_hardening();
1310 -
1311 -- if (!inf->fn(addr, esr, regs)) {
1312 -+ if (!inf->fn(addr_if_watchpoint, esr, regs)) {
1313 - rv = 1;
1314 - } else {
1315 - arm64_notify_die(inf->name, regs,
1316 -- inf->sig, inf->code, (void __user *)addr, esr);
1317 -+ inf->sig, inf->code, (void __user *)pc, esr);
1318 - rv = 0;
1319 - }
1320 -
1321 diff --git a/arch/csky/include/asm/syscall.h b/arch/csky/include/asm/syscall.h
1322 index d637445737b7..9a9cd81e66c1 100644
1323 --- a/arch/csky/include/asm/syscall.h
1324 @@ -1706,137 +478,6 @@ index d637445737b7..9a9cd81e66c1 100644
1325 }
1326
1327 static inline int
1328 -diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
1329 -index f801f3708a89..ba0f26cfad61 100644
1330 ---- a/arch/h8300/Makefile
1331 -+++ b/arch/h8300/Makefile
1332 -@@ -27,7 +27,7 @@ KBUILD_LDFLAGS += $(ldflags-y)
1333 - CHECKFLAGS += -msize-long
1334 -
1335 - ifeq ($(CROSS_COMPILE),)
1336 --CROSS_COMPILE := h8300-unknown-linux-
1337 -+CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
1338 - endif
1339 -
1340 - core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
1341 -diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
1342 -index f00ca53f8c14..482513b9af2c 100644
1343 ---- a/arch/m68k/Makefile
1344 -+++ b/arch/m68k/Makefile
1345 -@@ -58,7 +58,10 @@ cpuflags-$(CONFIG_M5206e) := $(call cc-option,-mcpu=5206e,-m5200)
1346 - cpuflags-$(CONFIG_M5206) := $(call cc-option,-mcpu=5206,-m5200)
1347 -
1348 - KBUILD_AFLAGS += $(cpuflags-y)
1349 --KBUILD_CFLAGS += $(cpuflags-y) -pipe
1350 -+KBUILD_CFLAGS += $(cpuflags-y)
1351 -+
1352 -+KBUILD_CFLAGS += -pipe -ffreestanding
1353 -+
1354 - ifdef CONFIG_MMU
1355 - # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
1356 - KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2
1357 -diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
1358 -index e77672539e8e..e4456e450f94 100644
1359 ---- a/arch/mips/include/asm/jump_label.h
1360 -+++ b/arch/mips/include/asm/jump_label.h
1361 -@@ -21,15 +21,15 @@
1362 - #endif
1363 -
1364 - #ifdef CONFIG_CPU_MICROMIPS
1365 --#define NOP_INSN "nop32"
1366 -+#define B_INSN "b32"
1367 - #else
1368 --#define NOP_INSN "nop"
1369 -+#define B_INSN "b"
1370 - #endif
1371 -
1372 - static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
1373 - {
1374 -- asm_volatile_goto("1:\t" NOP_INSN "\n\t"
1375 -- "nop\n\t"
1376 -+ asm_volatile_goto("1:\t" B_INSN " 2f\n\t"
1377 -+ "2:\tnop\n\t"
1378 - ".pushsection __jump_table, \"aw\"\n\t"
1379 - WORD_INSN " 1b, %l[l_yes], %0\n\t"
1380 - ".popsection\n\t"
1381 -diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
1382 -index d2abd98471e8..41204a49cf95 100644
1383 ---- a/arch/mips/include/asm/kvm_host.h
1384 -+++ b/arch/mips/include/asm/kvm_host.h
1385 -@@ -1134,7 +1134,7 @@ static inline void kvm_arch_hardware_unsetup(void) {}
1386 - static inline void kvm_arch_sync_events(struct kvm *kvm) {}
1387 - static inline void kvm_arch_free_memslot(struct kvm *kvm,
1388 - struct kvm_memory_slot *free, struct kvm_memory_slot *dont) {}
1389 --static inline void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots) {}
1390 -+static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
1391 - static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
1392 - static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
1393 - static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
1394 -diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
1395 -index ba150c755fcc..85b6c60f285d 100644
1396 ---- a/arch/mips/kernel/irq.c
1397 -+++ b/arch/mips/kernel/irq.c
1398 -@@ -52,6 +52,7 @@ asmlinkage void spurious_interrupt(void)
1399 - void __init init_IRQ(void)
1400 - {
1401 - int i;
1402 -+ unsigned int order = get_order(IRQ_STACK_SIZE);
1403 -
1404 - for (i = 0; i < NR_IRQS; i++)
1405 - irq_set_noprobe(i);
1406 -@@ -62,8 +63,7 @@ void __init init_IRQ(void)
1407 - arch_init_irq();
1408 -
1409 - for_each_possible_cpu(i) {
1410 -- int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
1411 -- void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
1412 -+ void *s = (void *)__get_free_pages(GFP_KERNEL, order);
1413 -
1414 - irq_stack[i] = s;
1415 - pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
1416 -diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
1417 -index cb7e9ed7a453..33ee0d18fb0a 100644
1418 ---- a/arch/mips/kernel/vmlinux.lds.S
1419 -+++ b/arch/mips/kernel/vmlinux.lds.S
1420 -@@ -140,6 +140,13 @@ SECTIONS
1421 - PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
1422 - #endif
1423 -
1424 -+#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
1425 -+ .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
1426 -+ *(.appended_dtb)
1427 -+ KEEP(*(.appended_dtb))
1428 -+ }
1429 -+#endif
1430 -+
1431 - #ifdef CONFIG_RELOCATABLE
1432 - . = ALIGN(4);
1433 -
1434 -@@ -164,11 +171,6 @@ SECTIONS
1435 - __appended_dtb = .;
1436 - /* leave space for appended DTB */
1437 - . += 0x100000;
1438 --#elif defined(CONFIG_MIPS_ELF_APPENDED_DTB)
1439 -- .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
1440 -- *(.appended_dtb)
1441 -- KEEP(*(.appended_dtb))
1442 -- }
1443 - #endif
1444 - /*
1445 - * Align to 64K in attempt to eliminate holes before the
1446 -diff --git a/arch/mips/loongson64/lemote-2f/irq.c b/arch/mips/loongson64/lemote-2f/irq.c
1447 -index 9e33e45aa17c..b213cecb8e3a 100644
1448 ---- a/arch/mips/loongson64/lemote-2f/irq.c
1449 -+++ b/arch/mips/loongson64/lemote-2f/irq.c
1450 -@@ -103,7 +103,7 @@ static struct irqaction ip6_irqaction = {
1451 - static struct irqaction cascade_irqaction = {
1452 - .handler = no_action,
1453 - .name = "cascade",
1454 -- .flags = IRQF_NO_THREAD,
1455 -+ .flags = IRQF_NO_THREAD | IRQF_NO_SUSPEND,
1456 - };
1457 -
1458 - void __init mach_init_irq(void)
1459 diff --git a/arch/parisc/include/asm/ptrace.h b/arch/parisc/include/asm/ptrace.h
1460 index 2a27b275ab09..9ff033d261ab 100644
1461 --- a/arch/parisc/include/asm/ptrace.h
1462 @@ -1889,167 +530,6 @@ index f2cf86ac279b..25946624ce6a 100644
1463 cpunum = smp_processor_id();
1464
1465 init_cpu_topology();
1466 -diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h
1467 -index 5b0177733994..46130ef4941c 100644
1468 ---- a/arch/powerpc/include/asm/book3s/64/hugetlb.h
1469 -+++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h
1470 -@@ -35,6 +35,14 @@ static inline int hstate_get_psize(struct hstate *hstate)
1471 - #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
1472 - static inline bool gigantic_page_supported(void)
1473 - {
1474 -+ /*
1475 -+ * We used gigantic page reservation with hypervisor assist in some case.
1476 -+ * We cannot use runtime allocation of gigantic pages in those platforms
1477 -+ * This is hash translation mode LPARs.
1478 -+ */
1479 -+ if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled())
1480 -+ return false;
1481 -+
1482 - return true;
1483 - }
1484 - #endif
1485 -diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
1486 -index 0f98f00da2ea..19693b8add93 100644
1487 ---- a/arch/powerpc/include/asm/kvm_host.h
1488 -+++ b/arch/powerpc/include/asm/kvm_host.h
1489 -@@ -837,7 +837,7 @@ struct kvm_vcpu_arch {
1490 - static inline void kvm_arch_hardware_disable(void) {}
1491 - static inline void kvm_arch_hardware_unsetup(void) {}
1492 - static inline void kvm_arch_sync_events(struct kvm *kvm) {}
1493 --static inline void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots) {}
1494 -+static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
1495 - static inline void kvm_arch_flush_shadow_all(struct kvm *kvm) {}
1496 - static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
1497 - static inline void kvm_arch_exit(void) {}
1498 -diff --git a/arch/powerpc/include/asm/powernv.h b/arch/powerpc/include/asm/powernv.h
1499 -index 2f3ff7a27881..d85fcfea32ca 100644
1500 ---- a/arch/powerpc/include/asm/powernv.h
1501 -+++ b/arch/powerpc/include/asm/powernv.h
1502 -@@ -23,6 +23,8 @@ extern int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea,
1503 - unsigned long *flags, unsigned long *status,
1504 - int count);
1505 -
1506 -+void pnv_program_cpu_hotplug_lpcr(unsigned int cpu, u64 lpcr_val);
1507 -+
1508 - void pnv_tm_init(void);
1509 - #else
1510 - static inline void powernv_set_nmmu_ptcr(unsigned long ptcr) { }
1511 -diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
1512 -index 19a8834e0398..0690a306f6ca 100644
1513 ---- a/arch/powerpc/include/asm/ppc-opcode.h
1514 -+++ b/arch/powerpc/include/asm/ppc-opcode.h
1515 -@@ -302,6 +302,7 @@
1516 - /* Misc instructions for BPF compiler */
1517 - #define PPC_INST_LBZ 0x88000000
1518 - #define PPC_INST_LD 0xe8000000
1519 -+#define PPC_INST_LDX 0x7c00002a
1520 - #define PPC_INST_LHZ 0xa0000000
1521 - #define PPC_INST_LWZ 0x80000000
1522 - #define PPC_INST_LHBRX 0x7c00062c
1523 -@@ -309,6 +310,7 @@
1524 - #define PPC_INST_STB 0x98000000
1525 - #define PPC_INST_STH 0xb0000000
1526 - #define PPC_INST_STD 0xf8000000
1527 -+#define PPC_INST_STDX 0x7c00012a
1528 - #define PPC_INST_STDU 0xf8000001
1529 - #define PPC_INST_STW 0x90000000
1530 - #define PPC_INST_STWU 0x94000000
1531 -diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
1532 -index a4a718dbfec6..f85e2b01c3df 100644
1533 ---- a/arch/powerpc/include/asm/topology.h
1534 -+++ b/arch/powerpc/include/asm/topology.h
1535 -@@ -132,6 +132,8 @@ static inline void shared_proc_topology_init(void) {}
1536 - #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
1537 - #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
1538 - #define topology_core_id(cpu) (cpu_to_core_id(cpu))
1539 -+
1540 -+int dlpar_cpu_readd(int cpu);
1541 - #endif
1542 - #endif
1543 -
1544 -diff --git a/arch/powerpc/include/asm/vdso_datapage.h b/arch/powerpc/include/asm/vdso_datapage.h
1545 -index 1afe90ade595..bbc06bd72b1f 100644
1546 ---- a/arch/powerpc/include/asm/vdso_datapage.h
1547 -+++ b/arch/powerpc/include/asm/vdso_datapage.h
1548 -@@ -82,10 +82,10 @@ struct vdso_data {
1549 - __u32 icache_block_size; /* L1 i-cache block size */
1550 - __u32 dcache_log_block_size; /* L1 d-cache log block size */
1551 - __u32 icache_log_block_size; /* L1 i-cache log block size */
1552 -- __s32 wtom_clock_sec; /* Wall to monotonic clock */
1553 -- __s32 wtom_clock_nsec;
1554 -- struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */
1555 -- __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */
1556 -+ __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */
1557 -+ __s32 wtom_clock_nsec; /* Wall to monotonic clock nsec */
1558 -+ __s64 wtom_clock_sec; /* Wall to monotonic clock sec */
1559 -+ struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */
1560 - __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
1561 - __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
1562 - };
1563 -diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
1564 -index 0768dfd8a64e..fdd528cdb2ee 100644
1565 ---- a/arch/powerpc/kernel/entry_32.S
1566 -+++ b/arch/powerpc/kernel/entry_32.S
1567 -@@ -745,6 +745,9 @@ fast_exception_return:
1568 - mtcr r10
1569 - lwz r10,_LINK(r11)
1570 - mtlr r10
1571 -+ /* Clear the exception_marker on the stack to avoid confusing stacktrace */
1572 -+ li r10, 0
1573 -+ stw r10, 8(r11)
1574 - REST_GPR(10, r11)
1575 - #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
1576 - mtspr SPRN_NRI, r0
1577 -@@ -982,6 +985,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
1578 - mtcrf 0xFF,r10
1579 - mtlr r11
1580 -
1581 -+ /* Clear the exception_marker on the stack to avoid confusing stacktrace */
1582 -+ li r10, 0
1583 -+ stw r10, 8(r1)
1584 - /*
1585 - * Once we put values in SRR0 and SRR1, we are in a state
1586 - * where exceptions are not recoverable, since taking an
1587 -@@ -1021,6 +1027,9 @@ exc_exit_restart_end:
1588 - mtlr r11
1589 - lwz r10,_CCR(r1)
1590 - mtcrf 0xff,r10
1591 -+ /* Clear the exception_marker on the stack to avoid confusing stacktrace */
1592 -+ li r10, 0
1593 -+ stw r10, 8(r1)
1594 - REST_2GPRS(9, r1)
1595 - .globl exc_exit_restart
1596 - exc_exit_restart:
1597 -diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
1598 -index 435927f549c4..a2c168b395d2 100644
1599 ---- a/arch/powerpc/kernel/entry_64.S
1600 -+++ b/arch/powerpc/kernel/entry_64.S
1601 -@@ -1002,6 +1002,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
1602 - ld r2,_NIP(r1)
1603 - mtspr SPRN_SRR0,r2
1604 -
1605 -+ /*
1606 -+ * Leaving a stale exception_marker on the stack can confuse
1607 -+ * the reliable stack unwinder later on. Clear it.
1608 -+ */
1609 -+ li r2,0
1610 -+ std r2,STACK_FRAME_OVERHEAD-16(r1)
1611 -+
1612 - ld r0,GPR0(r1)
1613 - ld r2,GPR2(r1)
1614 - ld r3,GPR3(r1)
1615 -diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
1616 -index afb638778f44..447defdd4503 100644
1617 ---- a/arch/powerpc/kernel/exceptions-64e.S
1618 -+++ b/arch/powerpc/kernel/exceptions-64e.S
1619 -@@ -349,6 +349,7 @@ ret_from_mc_except:
1620 - #define GEN_BTB_FLUSH
1621 - #define CRIT_BTB_FLUSH
1622 - #define DBG_BTB_FLUSH
1623 -+#define MC_BTB_FLUSH
1624 - #define GDBELL_BTB_FLUSH
1625 - #endif
1626 -
1627 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
1628 index 9e253ce27e08..4fee6c9887db 100644
1629 --- a/arch/powerpc/kernel/exceptions-64s.S
1630 @@ -2090,28784 +570,3132 @@ index 9e253ce27e08..4fee6c9887db 100644
1631 std r3,RESULT(r1)
1632 bl save_nvgprs
1633 RECONCILE_IRQ_STATE(r10, r11)
1634 -diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
1635 -index ce393df243aa..71bad4b6f80d 100644
1636 ---- a/arch/powerpc/kernel/process.c
1637 -+++ b/arch/powerpc/kernel/process.c
1638 -@@ -176,7 +176,7 @@ static void __giveup_fpu(struct task_struct *tsk)
1639 -
1640 - save_fpu(tsk);
1641 - msr = tsk->thread.regs->msr;
1642 -- msr &= ~MSR_FP;
1643 -+ msr &= ~(MSR_FP|MSR_FE0|MSR_FE1);
1644 - #ifdef CONFIG_VSX
1645 - if (cpu_has_feature(CPU_FTR_VSX))
1646 - msr &= ~MSR_VSX;
1647 -diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
1648 -index cdd5d1d3ae41..d9ac7d94656e 100644
1649 ---- a/arch/powerpc/kernel/ptrace.c
1650 -+++ b/arch/powerpc/kernel/ptrace.c
1651 -@@ -33,6 +33,7 @@
1652 - #include <linux/hw_breakpoint.h>
1653 - #include <linux/perf_event.h>
1654 - #include <linux/context_tracking.h>
1655 -+#include <linux/nospec.h>
1656 -
1657 - #include <linux/uaccess.h>
1658 - #include <linux/pkeys.h>
1659 -@@ -274,6 +275,8 @@ static int set_user_trap(struct task_struct *task, unsigned long trap)
1660 - */
1661 - int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data)
1662 - {
1663 -+ unsigned int regs_max;
1664 -+
1665 - if ((task->thread.regs == NULL) || !data)
1666 - return -EIO;
1667 -
1668 -@@ -297,7 +300,9 @@ int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data)
1669 +diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
1670 +index bba3da6ef157..6ea9e1804233 100644
1671 +--- a/arch/riscv/include/asm/syscall.h
1672 ++++ b/arch/riscv/include/asm/syscall.h
1673 +@@ -79,10 +79,11 @@ static inline void syscall_get_arguments(struct task_struct *task,
1674 + if (i == 0) {
1675 + args[0] = regs->orig_a0;
1676 + args++;
1677 +- i++;
1678 + n--;
1679 ++ } else {
1680 ++ i--;
1681 }
1682 - #endif
1683 +- memcpy(args, &regs->a1 + i * sizeof(regs->a1), n * sizeof(args[0]));
1684 ++ memcpy(args, &regs->a1 + i, n * sizeof(args[0]));
1685 + }
1686
1687 -- if (regno < (sizeof(struct user_pt_regs) / sizeof(unsigned long))) {
1688 -+ regs_max = sizeof(struct user_pt_regs) / sizeof(unsigned long);
1689 -+ if (regno < regs_max) {
1690 -+ regno = array_index_nospec(regno, regs_max);
1691 - *data = ((unsigned long *)task->thread.regs)[regno];
1692 - return 0;
1693 - }
1694 -@@ -321,6 +326,7 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data)
1695 - return set_user_dscr(task, data);
1696 -
1697 - if (regno <= PT_MAX_PUT_REG) {
1698 -+ regno = array_index_nospec(regno, PT_MAX_PUT_REG + 1);
1699 - ((unsigned long *)task->thread.regs)[regno] = data;
1700 - return 0;
1701 - }
1702 -@@ -561,6 +567,7 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,
1703 - /*
1704 - * Copy out only the low-order word of vrsave.
1705 - */
1706 -+ int start, end;
1707 - union {
1708 - elf_vrreg_t reg;
1709 - u32 word;
1710 -@@ -569,8 +576,10 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,
1711 -
1712 - vrsave.word = target->thread.vrsave;
1713 -
1714 -+ start = 33 * sizeof(vector128);
1715 -+ end = start + sizeof(vrsave);
1716 - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
1717 -- 33 * sizeof(vector128), -1);
1718 -+ start, end);
1719 - }
1720 -
1721 - return ret;
1722 -@@ -608,6 +617,7 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,
1723 - /*
1724 - * We use only the first word of vrsave.
1725 - */
1726 -+ int start, end;
1727 - union {
1728 - elf_vrreg_t reg;
1729 - u32 word;
1730 -@@ -616,8 +626,10 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,
1731 -
1732 - vrsave.word = target->thread.vrsave;
1733 -
1734 -+ start = 33 * sizeof(vector128);
1735 -+ end = start + sizeof(vrsave);
1736 - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
1737 -- 33 * sizeof(vector128), -1);
1738 -+ start, end);
1739 - if (!ret)
1740 - target->thread.vrsave = vrsave.word;
1741 - }
1742 -diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
1743 -index 9b8631533e02..b33bafb8fcea 100644
1744 ---- a/arch/powerpc/kernel/security.c
1745 -+++ b/arch/powerpc/kernel/security.c
1746 -@@ -190,29 +190,22 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
1747 - bcs = security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED);
1748 - ccd = security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED);
1749 -
1750 -- if (bcs || ccd || count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
1751 -- bool comma = false;
1752 -+ if (bcs || ccd) {
1753 - seq_buf_printf(&s, "Mitigation: ");
1754 -
1755 -- if (bcs) {
1756 -+ if (bcs)
1757 - seq_buf_printf(&s, "Indirect branch serialisation (kernel only)");
1758 -- comma = true;
1759 -- }
1760 -
1761 -- if (ccd) {
1762 -- if (comma)
1763 -- seq_buf_printf(&s, ", ");
1764 -- seq_buf_printf(&s, "Indirect branch cache disabled");
1765 -- comma = true;
1766 -- }
1767 --
1768 -- if (comma)
1769 -+ if (bcs && ccd)
1770 - seq_buf_printf(&s, ", ");
1771 -
1772 -- seq_buf_printf(&s, "Software count cache flush");
1773 -+ if (ccd)
1774 -+ seq_buf_printf(&s, "Indirect branch cache disabled");
1775 -+ } else if (count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
1776 -+ seq_buf_printf(&s, "Mitigation: Software count cache flush");
1777 -
1778 - if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW)
1779 -- seq_buf_printf(&s, "(hardware accelerated)");
1780 -+ seq_buf_printf(&s, " (hardware accelerated)");
1781 - } else if (btb_flush_enabled) {
1782 - seq_buf_printf(&s, "Mitigation: Branch predictor state flush");
1783 - } else {
1784 -diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
1785 -index 3f15edf25a0d..6e521a3f67ca 100644
1786 ---- a/arch/powerpc/kernel/smp.c
1787 -+++ b/arch/powerpc/kernel/smp.c
1788 -@@ -358,13 +358,12 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask)
1789 - * NMI IPIs may not be recoverable, so should not be used as ongoing part of
1790 - * a running system. They can be used for crash, debug, halt/reboot, etc.
1791 - *
1792 -- * NMI IPIs are globally single threaded. No more than one in progress at
1793 -- * any time.
1794 -- *
1795 - * The IPI call waits with interrupts disabled until all targets enter the
1796 -- * NMI handler, then the call returns.
1797 -+ * NMI handler, then returns. Subsequent IPIs can be issued before targets
1798 -+ * have returned from their handlers, so there is no guarantee about
1799 -+ * concurrency or re-entrancy.
1800 - *
1801 -- * No new NMI can be initiated until targets exit the handler.
1802 -+ * A new NMI can be issued before all targets exit the handler.
1803 - *
1804 - * The IPI call may time out without all targets entering the NMI handler.
1805 - * In that case, there is some logic to recover (and ignore subsequent
1806 -@@ -375,7 +374,7 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask)
1807 -
1808 - static atomic_t __nmi_ipi_lock = ATOMIC_INIT(0);
1809 - static struct cpumask nmi_ipi_pending_mask;
1810 --static int nmi_ipi_busy_count = 0;
1811 -+static bool nmi_ipi_busy = false;
1812 - static void (*nmi_ipi_function)(struct pt_regs *) = NULL;
1813 -
1814 - static void nmi_ipi_lock_start(unsigned long *flags)
1815 -@@ -414,7 +413,7 @@ static void nmi_ipi_unlock_end(unsigned long *flags)
1816 - */
1817 - int smp_handle_nmi_ipi(struct pt_regs *regs)
1818 - {
1819 -- void (*fn)(struct pt_regs *);
1820 -+ void (*fn)(struct pt_regs *) = NULL;
1821 - unsigned long flags;
1822 - int me = raw_smp_processor_id();
1823 - int ret = 0;
1824 -@@ -425,29 +424,17 @@ int smp_handle_nmi_ipi(struct pt_regs *regs)
1825 - * because the caller may have timed out.
1826 - */
1827 - nmi_ipi_lock_start(&flags);
1828 -- if (!nmi_ipi_busy_count)
1829 -- goto out;
1830 -- if (!cpumask_test_cpu(me, &nmi_ipi_pending_mask))
1831 -- goto out;
1832 --
1833 -- fn = nmi_ipi_function;
1834 -- if (!fn)
1835 -- goto out;
1836 --
1837 -- cpumask_clear_cpu(me, &nmi_ipi_pending_mask);
1838 -- nmi_ipi_busy_count++;
1839 -- nmi_ipi_unlock();
1840 --
1841 -- ret = 1;
1842 --
1843 -- fn(regs);
1844 --
1845 -- nmi_ipi_lock();
1846 -- if (nmi_ipi_busy_count > 1) /* Can race with caller time-out */
1847 -- nmi_ipi_busy_count--;
1848 --out:
1849 -+ if (cpumask_test_cpu(me, &nmi_ipi_pending_mask)) {
1850 -+ cpumask_clear_cpu(me, &nmi_ipi_pending_mask);
1851 -+ fn = READ_ONCE(nmi_ipi_function);
1852 -+ WARN_ON_ONCE(!fn);
1853 -+ ret = 1;
1854 + static inline void syscall_set_arguments(struct task_struct *task,
1855 +@@ -94,10 +95,11 @@ static inline void syscall_set_arguments(struct task_struct *task,
1856 + if (i == 0) {
1857 + regs->orig_a0 = args[0];
1858 + args++;
1859 +- i++;
1860 + n--;
1861 +- }
1862 +- memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
1863 ++ } else {
1864 ++ i--;
1865 + }
1866 - nmi_ipi_unlock_end(&flags);
1867 -
1868 -+ if (fn)
1869 -+ fn(regs);
1870 -+
1871 - return ret;
1872 ++ memcpy(&regs->a1 + i, args, n * sizeof(regs->a1));
1873 }
1874
1875 -@@ -473,7 +460,7 @@ static void do_smp_send_nmi_ipi(int cpu, bool safe)
1876 - * - cpu is the target CPU (must not be this CPU), or NMI_IPI_ALL_OTHERS.
1877 - * - fn is the target callback function.
1878 - * - delay_us > 0 is the delay before giving up waiting for targets to
1879 -- * complete executing the handler, == 0 specifies indefinite delay.
1880 -+ * begin executing the handler, == 0 specifies indefinite delay.
1881 - */
1882 - int __smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us, bool safe)
1883 - {
1884 -@@ -487,31 +474,33 @@ int __smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us, bool
1885 - if (unlikely(!smp_ops))
1886 - return 0;
1887 + static inline int syscall_get_arch(void)
1888 +diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
1889 +index 7d2d7c801dba..0ecfac84ba91 100644
1890 +--- a/arch/x86/events/amd/core.c
1891 ++++ b/arch/x86/events/amd/core.c
1892 +@@ -3,10 +3,14 @@
1893 + #include <linux/types.h>
1894 + #include <linux/init.h>
1895 + #include <linux/slab.h>
1896 ++#include <linux/delay.h>
1897 + #include <asm/apicdef.h>
1898 ++#include <asm/nmi.h>
1899
1900 -- /* Take the nmi_ipi_busy count/lock with interrupts hard disabled */
1901 - nmi_ipi_lock_start(&flags);
1902 -- while (nmi_ipi_busy_count) {
1903 -+ while (nmi_ipi_busy) {
1904 - nmi_ipi_unlock_end(&flags);
1905 -- spin_until_cond(nmi_ipi_busy_count == 0);
1906 -+ spin_until_cond(!nmi_ipi_busy);
1907 - nmi_ipi_lock_start(&flags);
1908 - }
1909 --
1910 -+ nmi_ipi_busy = true;
1911 - nmi_ipi_function = fn;
1912 + #include "../perf_event.h"
1913
1914 -+ WARN_ON_ONCE(!cpumask_empty(&nmi_ipi_pending_mask));
1915 ++static DEFINE_PER_CPU(unsigned int, perf_nmi_counter);
1916 +
1917 - if (cpu < 0) {
1918 - /* ALL_OTHERS */
1919 - cpumask_copy(&nmi_ipi_pending_mask, cpu_online_mask);
1920 - cpumask_clear_cpu(me, &nmi_ipi_pending_mask);
1921 - } else {
1922 -- /* cpumask starts clear */
1923 - cpumask_set_cpu(cpu, &nmi_ipi_pending_mask);
1924 + static __initconst const u64 amd_hw_cache_event_ids
1925 + [PERF_COUNT_HW_CACHE_MAX]
1926 + [PERF_COUNT_HW_CACHE_OP_MAX]
1927 +@@ -429,6 +433,132 @@ static void amd_pmu_cpu_dead(int cpu)
1928 }
1929 -- nmi_ipi_busy_count++;
1930 -+
1931 - nmi_ipi_unlock();
1932 + }
1933
1934 -+ /* Interrupts remain hard disabled */
1935 ++/*
1936 ++ * When a PMC counter overflows, an NMI is used to process the event and
1937 ++ * reset the counter. NMI latency can result in the counter being updated
1938 ++ * before the NMI can run, which can result in what appear to be spurious
1939 ++ * NMIs. This function is intended to wait for the NMI to run and reset
1940 ++ * the counter to avoid possible unhandled NMI messages.
1941 ++ */
1942 ++#define OVERFLOW_WAIT_COUNT 50
1943 +
1944 - do_smp_send_nmi_ipi(cpu, safe);
1945 -
1946 - nmi_ipi_lock();
1947 -- /* nmi_ipi_busy_count is held here, so unlock/lock is okay */
1948 -+ /* nmi_ipi_busy is set here, so unlock/lock is okay */
1949 - while (!cpumask_empty(&nmi_ipi_pending_mask)) {
1950 - nmi_ipi_unlock();
1951 - udelay(1);
1952 -@@ -523,29 +512,15 @@ int __smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us, bool
1953 - }
1954 - }
1955 -
1956 -- while (nmi_ipi_busy_count > 1) {
1957 -- nmi_ipi_unlock();
1958 -- udelay(1);
1959 -- nmi_ipi_lock();
1960 -- if (delay_us) {
1961 -- delay_us--;
1962 -- if (!delay_us)
1963 -- break;
1964 -- }
1965 -- }
1966 --
1967 - if (!cpumask_empty(&nmi_ipi_pending_mask)) {
1968 - /* Timeout waiting for CPUs to call smp_handle_nmi_ipi */
1969 - ret = 0;
1970 - cpumask_clear(&nmi_ipi_pending_mask);
1971 - }
1972 -- if (nmi_ipi_busy_count > 1) {
1973 -- /* Timeout waiting for CPUs to execute fn */
1974 -- ret = 0;
1975 -- nmi_ipi_busy_count = 1;
1976 -- }
1977 -
1978 -- nmi_ipi_busy_count--;
1979 -+ nmi_ipi_function = NULL;
1980 -+ nmi_ipi_busy = false;
1981 ++static void amd_pmu_wait_on_overflow(int idx)
1982 ++{
1983 ++ unsigned int i;
1984 ++ u64 counter;
1985 +
1986 - nmi_ipi_unlock_end(&flags);
1987 -
1988 - return ret;
1989 -@@ -613,17 +588,8 @@ void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
1990 - static void nmi_stop_this_cpu(struct pt_regs *regs)
1991 - {
1992 - /*
1993 -- * This is a special case because it never returns, so the NMI IPI
1994 -- * handling would never mark it as done, which makes any later
1995 -- * smp_send_nmi_ipi() call spin forever. Mark it done now.
1996 -- *
1997 - * IRQs are already hard disabled by the smp_handle_nmi_ipi.
1998 - */
1999 -- nmi_ipi_lock();
2000 -- if (nmi_ipi_busy_count > 1)
2001 -- nmi_ipi_busy_count--;
2002 -- nmi_ipi_unlock();
2003 --
2004 - spin_begin();
2005 - while (1)
2006 - spin_cpu_relax();
2007 -diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
2008 -index 64936b60d521..7a1de34f38c8 100644
2009 ---- a/arch/powerpc/kernel/traps.c
2010 -+++ b/arch/powerpc/kernel/traps.c
2011 -@@ -763,15 +763,15 @@ void machine_check_exception(struct pt_regs *regs)
2012 - if (check_io_access(regs))
2013 - goto bail;
2014 -
2015 -- /* Must die if the interrupt is not recoverable */
2016 -- if (!(regs->msr & MSR_RI))
2017 -- nmi_panic(regs, "Unrecoverable Machine check");
2018 --
2019 - if (!nested)
2020 - nmi_exit();
2021 -
2022 - die("Machine check", regs, SIGBUS);
2023 -
2024 -+ /* Must die if the interrupt is not recoverable */
2025 -+ if (!(regs->msr & MSR_RI))
2026 -+ nmi_panic(regs, "Unrecoverable Machine check");
2027 ++ /*
2028 ++ * Wait for the counter to be reset if it has overflowed. This loop
2029 ++ * should exit very, very quickly, but just in case, don't wait
2030 ++ * forever...
2031 ++ */
2032 ++ for (i = 0; i < OVERFLOW_WAIT_COUNT; i++) {
2033 ++ rdmsrl(x86_pmu_event_addr(idx), counter);
2034 ++ if (counter & (1ULL << (x86_pmu.cntval_bits - 1)))
2035 ++ break;
2036 +
2037 - return;
2038 -
2039 - bail:
2040 -@@ -1542,8 +1542,8 @@ bail:
2041 -
2042 - void StackOverflow(struct pt_regs *regs)
2043 - {
2044 -- printk(KERN_CRIT "Kernel stack overflow in process %p, r1=%lx\n",
2045 -- current, regs->gpr[1]);
2046 -+ pr_crit("Kernel stack overflow in process %s[%d], r1=%lx\n",
2047 -+ current->comm, task_pid_nr(current), regs->gpr[1]);
2048 - debugger(regs);
2049 - show_regs(regs);
2050 - panic("kernel stack overflow");
2051 -diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
2052 -index a4ed9edfd5f0..1f324c28705b 100644
2053 ---- a/arch/powerpc/kernel/vdso64/gettimeofday.S
2054 -+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
2055 -@@ -92,7 +92,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
2056 - * At this point, r4,r5 contain our sec/nsec values.
2057 - */
2058 -
2059 -- lwa r6,WTOM_CLOCK_SEC(r3)
2060 -+ ld r6,WTOM_CLOCK_SEC(r3)
2061 - lwa r9,WTOM_CLOCK_NSEC(r3)
2062 -
2063 - /* We now have our result in r6,r9. We create a fake dependency
2064 -@@ -125,7 +125,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime)
2065 - bne cr6,75f
2066 -
2067 - /* CLOCK_MONOTONIC_COARSE */
2068 -- lwa r6,WTOM_CLOCK_SEC(r3)
2069 -+ ld r6,WTOM_CLOCK_SEC(r3)
2070 - lwa r9,WTOM_CLOCK_NSEC(r3)
2071 -
2072 - /* check if counter has updated */
2073 -diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
2074 -index 9b8d50a7cbaf..45b06e239d1f 100644
2075 ---- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
2076 -+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
2077 -@@ -58,6 +58,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
2078 - #define STACK_SLOT_DAWR (SFS-56)
2079 - #define STACK_SLOT_DAWRX (SFS-64)
2080 - #define STACK_SLOT_HFSCR (SFS-72)
2081 -+#define STACK_SLOT_AMR (SFS-80)
2082 -+#define STACK_SLOT_UAMOR (SFS-88)
2083 - /* the following is used by the P9 short path */
2084 - #define STACK_SLOT_NVGPRS (SFS-152) /* 18 gprs */
2085 -
2086 -@@ -726,11 +728,9 @@ BEGIN_FTR_SECTION
2087 - mfspr r5, SPRN_TIDR
2088 - mfspr r6, SPRN_PSSCR
2089 - mfspr r7, SPRN_PID
2090 -- mfspr r8, SPRN_IAMR
2091 - std r5, STACK_SLOT_TID(r1)
2092 - std r6, STACK_SLOT_PSSCR(r1)
2093 - std r7, STACK_SLOT_PID(r1)
2094 -- std r8, STACK_SLOT_IAMR(r1)
2095 - mfspr r5, SPRN_HFSCR
2096 - std r5, STACK_SLOT_HFSCR(r1)
2097 - END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
2098 -@@ -738,11 +738,18 @@ BEGIN_FTR_SECTION
2099 - mfspr r5, SPRN_CIABR
2100 - mfspr r6, SPRN_DAWR
2101 - mfspr r7, SPRN_DAWRX
2102 -+ mfspr r8, SPRN_IAMR
2103 - std r5, STACK_SLOT_CIABR(r1)
2104 - std r6, STACK_SLOT_DAWR(r1)
2105 - std r7, STACK_SLOT_DAWRX(r1)
2106 -+ std r8, STACK_SLOT_IAMR(r1)
2107 - END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
2108 -
2109 -+ mfspr r5, SPRN_AMR
2110 -+ std r5, STACK_SLOT_AMR(r1)
2111 -+ mfspr r6, SPRN_UAMOR
2112 -+ std r6, STACK_SLOT_UAMOR(r1)
2113 ++ /* Might be in IRQ context, so can't sleep */
2114 ++ udelay(1);
2115 ++ }
2116 ++}
2117 ++
2118 ++static void amd_pmu_disable_all(void)
2119 ++{
2120 ++ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
2121 ++ int idx;
2122 +
2123 - BEGIN_FTR_SECTION
2124 - /* Set partition DABR */
2125 - /* Do this before re-enabling PMU to avoid P7 DABR corruption bug */
2126 -@@ -1631,22 +1638,25 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300)
2127 - mtspr SPRN_PSPB, r0
2128 - mtspr SPRN_WORT, r0
2129 - BEGIN_FTR_SECTION
2130 -- mtspr SPRN_IAMR, r0
2131 - mtspr SPRN_TCSCR, r0
2132 - /* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */
2133 - li r0, 1
2134 - sldi r0, r0, 31
2135 - mtspr SPRN_MMCRS, r0
2136 - END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
2137 --8:
2138 -
2139 -- /* Save and reset AMR and UAMOR before turning on the MMU */
2140 -+ /* Save and restore AMR, IAMR and UAMOR before turning on the MMU */
2141 -+ ld r8, STACK_SLOT_IAMR(r1)
2142 -+ mtspr SPRN_IAMR, r8
2143 ++ x86_pmu_disable_all();
2144 +
2145 -+8: /* Power7 jumps back in here */
2146 - mfspr r5,SPRN_AMR
2147 - mfspr r6,SPRN_UAMOR
2148 - std r5,VCPU_AMR(r9)
2149 - std r6,VCPU_UAMOR(r9)
2150 -- li r6,0
2151 -- mtspr SPRN_AMR,r6
2152 -+ ld r5,STACK_SLOT_AMR(r1)
2153 -+ ld r6,STACK_SLOT_UAMOR(r1)
2154 -+ mtspr SPRN_AMR, r5
2155 - mtspr SPRN_UAMOR, r6
2156 -
2157 - /* Switch DSCR back to host value */
2158 -@@ -1746,11 +1756,9 @@ BEGIN_FTR_SECTION
2159 - ld r5, STACK_SLOT_TID(r1)
2160 - ld r6, STACK_SLOT_PSSCR(r1)
2161 - ld r7, STACK_SLOT_PID(r1)
2162 -- ld r8, STACK_SLOT_IAMR(r1)
2163 - mtspr SPRN_TIDR, r5
2164 - mtspr SPRN_PSSCR, r6
2165 - mtspr SPRN_PID, r7
2166 -- mtspr SPRN_IAMR, r8
2167 - END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
2168 -
2169 - #ifdef CONFIG_PPC_RADIX_MMU
2170 -diff --git a/arch/powerpc/lib/memcmp_64.S b/arch/powerpc/lib/memcmp_64.S
2171 -index 844d8e774492..b7f6f6e0b6e8 100644
2172 ---- a/arch/powerpc/lib/memcmp_64.S
2173 -+++ b/arch/powerpc/lib/memcmp_64.S
2174 -@@ -215,11 +215,20 @@ _GLOBAL_TOC(memcmp)
2175 - beq .Lzero
2176 -
2177 - .Lcmp_rest_lt8bytes:
2178 -- /* Here we have only less than 8 bytes to compare with. at least s1
2179 -- * Address is aligned with 8 bytes.
2180 -- * The next double words are load and shift right with appropriate
2181 -- * bits.
2182 + /*
2183 -+ * Here we have less than 8 bytes to compare. At least s1 is aligned to
2184 -+ * 8 bytes, but s2 may not be. We must make sure s2 + 7 doesn't cross a
2185 -+ * page boundary, otherwise we might read past the end of the buffer and
2186 -+ * trigger a page fault. We use 4K as the conservative minimum page
2187 -+ * size. If we detect that case we go to the byte-by-byte loop.
2188 -+ *
2189 -+ * Otherwise the next double word is loaded from s1 and s2, and shifted
2190 -+ * right to compare the appropriate bits.
2191 - */
2192 -+ clrldi r6,r4,(64-12) // r6 = r4 & 0xfff
2193 -+ cmpdi r6,0xff8
2194 -+ bgt .Lshort
2195 ++ * This shouldn't be called from NMI context, but add a safeguard here
2196 ++ * to return, since if we're in NMI context we can't wait for an NMI
2197 ++ * to reset an overflowed counter value.
2198 ++ */
2199 ++ if (in_nmi())
2200 ++ return;
2201 +
2202 - subfic r6,r5,8
2203 - slwi r6,r6,3
2204 - LD rA,0,r3
2205 -diff --git a/arch/powerpc/mm/hugetlbpage-radix.c b/arch/powerpc/mm/hugetlbpage-radix.c
2206 -index 2486bee0f93e..97c7a39ebc00 100644
2207 ---- a/arch/powerpc/mm/hugetlbpage-radix.c
2208 -+++ b/arch/powerpc/mm/hugetlbpage-radix.c
2209 -@@ -1,6 +1,7 @@
2210 - // SPDX-License-Identifier: GPL-2.0
2211 - #include <linux/mm.h>
2212 - #include <linux/hugetlb.h>
2213 -+#include <linux/security.h>
2214 - #include <asm/pgtable.h>
2215 - #include <asm/pgalloc.h>
2216 - #include <asm/cacheflush.h>
2217 -@@ -73,7 +74,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
2218 - if (addr) {
2219 - addr = ALIGN(addr, huge_page_size(h));
2220 - vma = find_vma(mm, addr);
2221 -- if (high_limit - len >= addr &&
2222 -+ if (high_limit - len >= addr && addr >= mmap_min_addr &&
2223 - (!vma || addr + len <= vm_start_gap(vma)))
2224 - return addr;
2225 - }
2226 -@@ -83,7 +84,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
2227 - */
2228 - info.flags = VM_UNMAPPED_AREA_TOPDOWN;
2229 - info.length = len;
2230 -- info.low_limit = PAGE_SIZE;
2231 -+ info.low_limit = max(PAGE_SIZE, mmap_min_addr);
2232 - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW);
2233 - info.align_mask = PAGE_MASK & ~huge_page_mask(h);
2234 - info.align_offset = 0;
2235 -diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
2236 -index 87f0dd004295..b5d1c45c1475 100644
2237 ---- a/arch/powerpc/mm/numa.c
2238 -+++ b/arch/powerpc/mm/numa.c
2239 -@@ -1460,13 +1460,6 @@ static void reset_topology_timer(void)
2240 -
2241 - #ifdef CONFIG_SMP
2242 -
2243 --static void stage_topology_update(int core_id)
2244 --{
2245 -- cpumask_or(&cpu_associativity_changes_mask,
2246 -- &cpu_associativity_changes_mask, cpu_sibling_mask(core_id));
2247 -- reset_topology_timer();
2248 --}
2249 --
2250 - static int dt_update_callback(struct notifier_block *nb,
2251 - unsigned long action, void *data)
2252 - {
2253 -@@ -1479,7 +1472,7 @@ static int dt_update_callback(struct notifier_block *nb,
2254 - !of_prop_cmp(update->prop->name, "ibm,associativity")) {
2255 - u32 core_id;
2256 - of_property_read_u32(update->dn, "reg", &core_id);
2257 -- stage_topology_update(core_id);
2258 -+ rc = dlpar_cpu_readd(core_id);
2259 - rc = NOTIFY_OK;
2260 - }
2261 - break;
2262 -diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
2263 -index bc3914d54e26..5986df48359b 100644
2264 ---- a/arch/powerpc/mm/slb.c
2265 -+++ b/arch/powerpc/mm/slb.c
2266 -@@ -69,6 +69,11 @@ static void assert_slb_presence(bool present, unsigned long ea)
2267 - if (!cpu_has_feature(CPU_FTR_ARCH_206))
2268 - return;
2269 -
2270 + /*
2271 -+ * slbfee. requires bit 24 (PPC bit 39) be clear in RB. Hardware
2272 -+ * ignores all other bits from 0-27, so just clear them all.
2273 ++ * Check each counter for overflow and wait for it to be reset by the
2274 ++ * NMI if it has overflowed. This relies on the fact that all active
2275 ++ * counters are always enabled when this function is caled and
2276 ++ * ARCH_PERFMON_EVENTSEL_INT is always set.
2277 + */
2278 -+ ea &= ~((1UL << 28) - 1);
2279 - asm volatile(__PPC_SLBFEE_DOT(%0, %1) : "=r"(tmp) : "r"(ea) : "cr0");
2280 -
2281 - WARN_ON(present == (tmp == 0));
2282 -diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
2283 -index c2d5192ed64f..e52e30bf7d86 100644
2284 ---- a/arch/powerpc/net/bpf_jit.h
2285 -+++ b/arch/powerpc/net/bpf_jit.h
2286 -@@ -51,6 +51,8 @@
2287 - #define PPC_LIS(r, i) PPC_ADDIS(r, 0, i)
2288 - #define PPC_STD(r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \
2289 - ___PPC_RA(base) | ((i) & 0xfffc))
2290 -+#define PPC_STDX(r, base, b) EMIT(PPC_INST_STDX | ___PPC_RS(r) | \
2291 -+ ___PPC_RA(base) | ___PPC_RB(b))
2292 - #define PPC_STDU(r, base, i) EMIT(PPC_INST_STDU | ___PPC_RS(r) | \
2293 - ___PPC_RA(base) | ((i) & 0xfffc))
2294 - #define PPC_STW(r, base, i) EMIT(PPC_INST_STW | ___PPC_RS(r) | \
2295 -@@ -65,7 +67,9 @@
2296 - #define PPC_LBZ(r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \
2297 - ___PPC_RA(base) | IMM_L(i))
2298 - #define PPC_LD(r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \
2299 -- ___PPC_RA(base) | IMM_L(i))
2300 -+ ___PPC_RA(base) | ((i) & 0xfffc))
2301 -+#define PPC_LDX(r, base, b) EMIT(PPC_INST_LDX | ___PPC_RT(r) | \
2302 -+ ___PPC_RA(base) | ___PPC_RB(b))
2303 - #define PPC_LWZ(r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \
2304 - ___PPC_RA(base) | IMM_L(i))
2305 - #define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \
2306 -@@ -85,17 +89,6 @@
2307 - ___PPC_RA(a) | ___PPC_RB(b))
2308 - #define PPC_BPF_STDCX(s, a, b) EMIT(PPC_INST_STDCX | ___PPC_RS(s) | \
2309 - ___PPC_RA(a) | ___PPC_RB(b))
2310 --
2311 --#ifdef CONFIG_PPC64
2312 --#define PPC_BPF_LL(r, base, i) do { PPC_LD(r, base, i); } while(0)
2313 --#define PPC_BPF_STL(r, base, i) do { PPC_STD(r, base, i); } while(0)
2314 --#define PPC_BPF_STLU(r, base, i) do { PPC_STDU(r, base, i); } while(0)
2315 --#else
2316 --#define PPC_BPF_LL(r, base, i) do { PPC_LWZ(r, base, i); } while(0)
2317 --#define PPC_BPF_STL(r, base, i) do { PPC_STW(r, base, i); } while(0)
2318 --#define PPC_BPF_STLU(r, base, i) do { PPC_STWU(r, base, i); } while(0)
2319 --#endif
2320 --
2321 - #define PPC_CMPWI(a, i) EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i))
2322 - #define PPC_CMPDI(a, i) EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i))
2323 - #define PPC_CMPW(a, b) EMIT(PPC_INST_CMPW | ___PPC_RA(a) | \
2324 -diff --git a/arch/powerpc/net/bpf_jit32.h b/arch/powerpc/net/bpf_jit32.h
2325 -index 6f4daacad296..ade04547703f 100644
2326 ---- a/arch/powerpc/net/bpf_jit32.h
2327 -+++ b/arch/powerpc/net/bpf_jit32.h
2328 -@@ -123,6 +123,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
2329 - #define PPC_NTOHS_OFFS(r, base, i) PPC_LHZ_OFFS(r, base, i)
2330 - #endif
2331 -
2332 -+#define PPC_BPF_LL(r, base, i) do { PPC_LWZ(r, base, i); } while(0)
2333 -+#define PPC_BPF_STL(r, base, i) do { PPC_STW(r, base, i); } while(0)
2334 -+#define PPC_BPF_STLU(r, base, i) do { PPC_STWU(r, base, i); } while(0)
2335 ++ for (idx = 0; idx < x86_pmu.num_counters; idx++) {
2336 ++ if (!test_bit(idx, cpuc->active_mask))
2337 ++ continue;
2338 ++
2339 ++ amd_pmu_wait_on_overflow(idx);
2340 ++ }
2341 ++}
2342 ++
2343 ++static void amd_pmu_disable_event(struct perf_event *event)
2344 ++{
2345 ++ x86_pmu_disable_event(event);
2346 ++
2347 ++ /*
2348 ++ * This can be called from NMI context (via x86_pmu_stop). The counter
2349 ++ * may have overflowed, but either way, we'll never see it get reset
2350 ++ * by the NMI if we're already in the NMI. And the NMI latency support
2351 ++ * below will take care of any pending NMI that might have been
2352 ++ * generated by the overflow.
2353 ++ */
2354 ++ if (in_nmi())
2355 ++ return;
2356 ++
2357 ++ amd_pmu_wait_on_overflow(event->hw.idx);
2358 ++}
2359 +
2360 - #define SEEN_DATAREF 0x10000 /* might call external helpers */
2361 - #define SEEN_XREG 0x20000 /* X reg is used */
2362 - #define SEEN_MEM 0x40000 /* SEEN_MEM+(1<<n) = use mem[n] for temporary
2363 -diff --git a/arch/powerpc/net/bpf_jit64.h b/arch/powerpc/net/bpf_jit64.h
2364 -index 3609be4692b3..47f441f351a6 100644
2365 ---- a/arch/powerpc/net/bpf_jit64.h
2366 -+++ b/arch/powerpc/net/bpf_jit64.h
2367 -@@ -68,6 +68,26 @@ static const int b2p[] = {
2368 - /* PPC NVR range -- update this if we ever use NVRs below r27 */
2369 - #define BPF_PPC_NVR_MIN 27
2370 -
2371 +/*
2372 -+ * WARNING: These can use TMP_REG_2 if the offset is not at word boundary,
2373 -+ * so ensure that it isn't in use already.
2374 ++ * Because of NMI latency, if multiple PMC counters are active or other sources
2375 ++ * of NMIs are received, the perf NMI handler can handle one or more overflowed
2376 ++ * PMC counters outside of the NMI associated with the PMC overflow. If the NMI
2377 ++ * doesn't arrive at the LAPIC in time to become a pending NMI, then the kernel
2378 ++ * back-to-back NMI support won't be active. This PMC handler needs to take into
2379 ++ * account that this can occur, otherwise this could result in unknown NMI
2380 ++ * messages being issued. Examples of this is PMC overflow while in the NMI
2381 ++ * handler when multiple PMCs are active or PMC overflow while handling some
2382 ++ * other source of an NMI.
2383 ++ *
2384 ++ * Attempt to mitigate this by using the number of active PMCs to determine
2385 ++ * whether to return NMI_HANDLED if the perf NMI handler did not handle/reset
2386 ++ * any PMCs. The per-CPU perf_nmi_counter variable is set to a minimum of the
2387 ++ * number of active PMCs or 2. The value of 2 is used in case an NMI does not
2388 ++ * arrive at the LAPIC in time to be collapsed into an already pending NMI.
2389 + */
2390 -+#define PPC_BPF_LL(r, base, i) do { \
2391 -+ if ((i) % 4) { \
2392 -+ PPC_LI(b2p[TMP_REG_2], (i)); \
2393 -+ PPC_LDX(r, base, b2p[TMP_REG_2]); \
2394 -+ } else \
2395 -+ PPC_LD(r, base, i); \
2396 -+ } while(0)
2397 -+#define PPC_BPF_STL(r, base, i) do { \
2398 -+ if ((i) % 4) { \
2399 -+ PPC_LI(b2p[TMP_REG_2], (i)); \
2400 -+ PPC_STDX(r, base, b2p[TMP_REG_2]); \
2401 -+ } else \
2402 -+ PPC_STD(r, base, i); \
2403 -+ } while(0)
2404 -+#define PPC_BPF_STLU(r, base, i) do { PPC_STDU(r, base, i); } while(0)
2405 ++static int amd_pmu_handle_irq(struct pt_regs *regs)
2406 ++{
2407 ++ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
2408 ++ int active, handled;
2409 +
2410 - #define SEEN_FUNC 0x1000 /* might call external helpers */
2411 - #define SEEN_STACK 0x2000 /* uses BPF stack */
2412 - #define SEEN_TAILCALL 0x4000 /* uses tail calls */
2413 -diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
2414 -index 7ce57657d3b8..b1a116eecae2 100644
2415 ---- a/arch/powerpc/net/bpf_jit_comp64.c
2416 -+++ b/arch/powerpc/net/bpf_jit_comp64.c
2417 -@@ -252,7 +252,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32
2418 - * if (tail_call_cnt > MAX_TAIL_CALL_CNT)
2419 - * goto out;
2420 - */
2421 -- PPC_LD(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx));
2422 -+ PPC_BPF_LL(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx));
2423 - PPC_CMPLWI(b2p[TMP_REG_1], MAX_TAIL_CALL_CNT);
2424 - PPC_BCC(COND_GT, out);
2425 -
2426 -@@ -265,7 +265,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32
2427 - /* prog = array->ptrs[index]; */
2428 - PPC_MULI(b2p[TMP_REG_1], b2p_index, 8);
2429 - PPC_ADD(b2p[TMP_REG_1], b2p[TMP_REG_1], b2p_bpf_array);
2430 -- PPC_LD(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_array, ptrs));
2431 -+ PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_array, ptrs));
2432 -
2433 - /*
2434 - * if (prog == NULL)
2435 -@@ -275,7 +275,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32
2436 - PPC_BCC(COND_EQ, out);
2437 -
2438 - /* goto *(prog->bpf_func + prologue_size); */
2439 -- PPC_LD(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_prog, bpf_func));
2440 -+ PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_prog, bpf_func));
2441 - #ifdef PPC64_ELF_ABI_v1
2442 - /* skip past the function descriptor */
2443 - PPC_ADDI(b2p[TMP_REG_1], b2p[TMP_REG_1],
2444 -@@ -606,7 +606,7 @@ bpf_alu32_trunc:
2445 - * the instructions generated will remain the
2446 - * same across all passes
2447 - */
2448 -- PPC_STD(dst_reg, 1, bpf_jit_stack_local(ctx));
2449 -+ PPC_BPF_STL(dst_reg, 1, bpf_jit_stack_local(ctx));
2450 - PPC_ADDI(b2p[TMP_REG_1], 1, bpf_jit_stack_local(ctx));
2451 - PPC_LDBRX(dst_reg, 0, b2p[TMP_REG_1]);
2452 - break;
2453 -@@ -662,7 +662,7 @@ emit_clear:
2454 - PPC_LI32(b2p[TMP_REG_1], imm);
2455 - src_reg = b2p[TMP_REG_1];
2456 - }
2457 -- PPC_STD(src_reg, dst_reg, off);
2458 -+ PPC_BPF_STL(src_reg, dst_reg, off);
2459 - break;
2460 -
2461 - /*
2462 -@@ -709,7 +709,7 @@ emit_clear:
2463 - break;
2464 - /* dst = *(u64 *)(ul) (src + off) */
2465 - case BPF_LDX | BPF_MEM | BPF_DW:
2466 -- PPC_LD(dst_reg, src_reg, off);
2467 -+ PPC_BPF_LL(dst_reg, src_reg, off);
2468 - break;
2469 -
2470 - /*
2471 -diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
2472 -index 4a9a72d01c3c..35be81fd2dc2 100644
2473 ---- a/arch/powerpc/platforms/44x/Kconfig
2474 -+++ b/arch/powerpc/platforms/44x/Kconfig
2475 -@@ -180,6 +180,7 @@ config CURRITUCK
2476 - depends on PPC_47x
2477 - select SWIOTLB
2478 - select 476FPE
2479 -+ select FORCE_PCI
2480 - select PPC4xx_PCI_EXPRESS
2481 - help
2482 - This option enables support for the IBM Currituck (476fpe) evaluation board
2483 -diff --git a/arch/powerpc/platforms/83xx/suspend-asm.S b/arch/powerpc/platforms/83xx/suspend-asm.S
2484 -index 3d1ecd211776..8137f77abad5 100644
2485 ---- a/arch/powerpc/platforms/83xx/suspend-asm.S
2486 -+++ b/arch/powerpc/platforms/83xx/suspend-asm.S
2487 -@@ -26,13 +26,13 @@
2488 - #define SS_MSR 0x74
2489 - #define SS_SDR1 0x78
2490 - #define SS_LR 0x7c
2491 --#define SS_SPRG 0x80 /* 4 SPRGs */
2492 --#define SS_DBAT 0x90 /* 8 DBATs */
2493 --#define SS_IBAT 0xd0 /* 8 IBATs */
2494 --#define SS_TB 0x110
2495 --#define SS_CR 0x118
2496 --#define SS_GPREG 0x11c /* r12-r31 */
2497 --#define STATE_SAVE_SIZE 0x16c
2498 -+#define SS_SPRG 0x80 /* 8 SPRGs */
2499 -+#define SS_DBAT 0xa0 /* 8 DBATs */
2500 -+#define SS_IBAT 0xe0 /* 8 IBATs */
2501 -+#define SS_TB 0x120
2502 -+#define SS_CR 0x128
2503 -+#define SS_GPREG 0x12c /* r12-r31 */
2504 -+#define STATE_SAVE_SIZE 0x17c
2505 -
2506 - .section .data
2507 - .align 5
2508 -@@ -103,6 +103,16 @@ _GLOBAL(mpc83xx_enter_deep_sleep)
2509 - stw r7, SS_SPRG+12(r3)
2510 - stw r8, SS_SDR1(r3)
2511 -
2512 -+ mfspr r4, SPRN_SPRG4
2513 -+ mfspr r5, SPRN_SPRG5
2514 -+ mfspr r6, SPRN_SPRG6
2515 -+ mfspr r7, SPRN_SPRG7
2516 ++ /*
2517 ++ * Obtain the active count before calling x86_pmu_handle_irq() since
2518 ++ * it is possible that x86_pmu_handle_irq() may make a counter
2519 ++ * inactive (through x86_pmu_stop).
2520 ++ */
2521 ++ active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
2522 +
2523 -+ stw r4, SS_SPRG+16(r3)
2524 -+ stw r5, SS_SPRG+20(r3)
2525 -+ stw r6, SS_SPRG+24(r3)
2526 -+ stw r7, SS_SPRG+28(r3)
2527 ++ /* Process any counter overflows */
2528 ++ handled = x86_pmu_handle_irq(regs);
2529 +
2530 - mfspr r4, SPRN_DBAT0U
2531 - mfspr r5, SPRN_DBAT0L
2532 - mfspr r6, SPRN_DBAT1U
2533 -@@ -493,6 +503,16 @@ mpc83xx_deep_resume:
2534 - mtspr SPRN_IBAT7U, r6
2535 - mtspr SPRN_IBAT7L, r7
2536 -
2537 -+ lwz r4, SS_SPRG+16(r3)
2538 -+ lwz r5, SS_SPRG+20(r3)
2539 -+ lwz r6, SS_SPRG+24(r3)
2540 -+ lwz r7, SS_SPRG+28(r3)
2541 ++ /*
2542 ++ * If a counter was handled, record the number of possible remaining
2543 ++ * NMIs that can occur.
2544 ++ */
2545 ++ if (handled) {
2546 ++ this_cpu_write(perf_nmi_counter,
2547 ++ min_t(unsigned int, 2, active));
2548 +
2549 -+ mtspr SPRN_SPRG4, r4
2550 -+ mtspr SPRN_SPRG5, r5
2551 -+ mtspr SPRN_SPRG6, r6
2552 -+ mtspr SPRN_SPRG7, r7
2553 ++ return handled;
2554 ++ }
2555 +
2556 - lwz r4, SS_SPRG+0(r3)
2557 - lwz r5, SS_SPRG+4(r3)
2558 - lwz r6, SS_SPRG+8(r3)
2559 -diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
2560 -index ecf703ee3a76..ac4ee88efc80 100644
2561 ---- a/arch/powerpc/platforms/embedded6xx/wii.c
2562 -+++ b/arch/powerpc/platforms/embedded6xx/wii.c
2563 -@@ -83,6 +83,10 @@ unsigned long __init wii_mmu_mapin_mem2(unsigned long top)
2564 - /* MEM2 64MB@0x10000000 */
2565 - delta = wii_hole_start + wii_hole_size;
2566 - size = top - delta;
2567 ++ if (!this_cpu_read(perf_nmi_counter))
2568 ++ return NMI_DONE;
2569 +
2570 -+ if (__map_without_bats)
2571 -+ return delta;
2572 ++ this_cpu_dec(perf_nmi_counter);
2573 +
2574 - for (bl = 128<<10; bl < max_size; bl <<= 1) {
2575 - if (bl * 2 > size)
2576 - break;
2577 -diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
2578 -index 35f699ebb662..e52f9b06dd9c 100644
2579 ---- a/arch/powerpc/platforms/powernv/idle.c
2580 -+++ b/arch/powerpc/platforms/powernv/idle.c
2581 -@@ -458,7 +458,8 @@ EXPORT_SYMBOL_GPL(pnv_power9_force_smt4_release);
2582 - #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
2583 -
2584 - #ifdef CONFIG_HOTPLUG_CPU
2585 --static void pnv_program_cpu_hotplug_lpcr(unsigned int cpu, u64 lpcr_val)
2586 ++ return NMI_HANDLED;
2587 ++}
2588 +
2589 -+void pnv_program_cpu_hotplug_lpcr(unsigned int cpu, u64 lpcr_val)
2590 - {
2591 - u64 pir = get_hard_smp_processor_id(cpu);
2592 + static struct event_constraint *
2593 + amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
2594 + struct perf_event *event)
2595 +@@ -621,11 +751,11 @@ static ssize_t amd_event_sysfs_show(char *page, u64 config)
2596
2597 -@@ -481,20 +482,6 @@ unsigned long pnv_cpu_offline(unsigned int cpu)
2598 - {
2599 - unsigned long srr1;
2600 - u32 idle_states = pnv_get_supported_cpuidle_states();
2601 -- u64 lpcr_val;
2602 --
2603 -- /*
2604 -- * We don't want to take decrementer interrupts while we are
2605 -- * offline, so clear LPCR:PECE1. We keep PECE2 (and
2606 -- * LPCR_PECE_HVEE on P9) enabled as to let IPIs in.
2607 -- *
2608 -- * If the CPU gets woken up by a special wakeup, ensure that
2609 -- * the SLW engine sets LPCR with decrementer bit cleared, else
2610 -- * the CPU will come back to the kernel due to a spurious
2611 -- * wakeup.
2612 -- */
2613 -- lpcr_val = mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1;
2614 -- pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val);
2615 + static __initconst const struct x86_pmu amd_pmu = {
2616 + .name = "AMD",
2617 +- .handle_irq = x86_pmu_handle_irq,
2618 +- .disable_all = x86_pmu_disable_all,
2619 ++ .handle_irq = amd_pmu_handle_irq,
2620 ++ .disable_all = amd_pmu_disable_all,
2621 + .enable_all = x86_pmu_enable_all,
2622 + .enable = x86_pmu_enable_event,
2623 +- .disable = x86_pmu_disable_event,
2624 ++ .disable = amd_pmu_disable_event,
2625 + .hw_config = amd_pmu_hw_config,
2626 + .schedule_events = x86_schedule_events,
2627 + .eventsel = MSR_K7_EVNTSEL0,
2628 +@@ -732,7 +862,7 @@ void amd_pmu_enable_virt(void)
2629 + cpuc->perf_ctr_virt_mask = 0;
2630
2631 - __ppc64_runlatch_off();
2632 -
2633 -@@ -526,16 +513,6 @@ unsigned long pnv_cpu_offline(unsigned int cpu)
2634 -
2635 - __ppc64_runlatch_on();
2636 -
2637 -- /*
2638 -- * Re-enable decrementer interrupts in LPCR.
2639 -- *
2640 -- * Further, we want stop states to be woken up by decrementer
2641 -- * for non-hotplug cases. So program the LPCR via stop api as
2642 -- * well.
2643 -- */
2644 -- lpcr_val = mfspr(SPRN_LPCR) | (u64)LPCR_PECE1;
2645 -- pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val);
2646 --
2647 - return srr1;
2648 + /* Reload all events */
2649 +- x86_pmu_disable_all();
2650 ++ amd_pmu_disable_all();
2651 + x86_pmu_enable_all(0);
2652 }
2653 - #endif
2654 -diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c b/arch/powerpc/platforms/powernv/opal-msglog.c
2655 -index acd3206dfae3..06628c71cef6 100644
2656 ---- a/arch/powerpc/platforms/powernv/opal-msglog.c
2657 -+++ b/arch/powerpc/platforms/powernv/opal-msglog.c
2658 -@@ -98,7 +98,7 @@ static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj,
2659 + EXPORT_SYMBOL_GPL(amd_pmu_enable_virt);
2660 +@@ -750,7 +880,7 @@ void amd_pmu_disable_virt(void)
2661 + cpuc->perf_ctr_virt_mask = AMD64_EVENTSEL_HOSTONLY;
2662 +
2663 + /* Reload all events */
2664 +- x86_pmu_disable_all();
2665 ++ amd_pmu_disable_all();
2666 + x86_pmu_enable_all(0);
2667 }
2668 + EXPORT_SYMBOL_GPL(amd_pmu_disable_virt);
2669 +diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
2670 +index e2b1447192a8..81911e11a15d 100644
2671 +--- a/arch/x86/events/core.c
2672 ++++ b/arch/x86/events/core.c
2673 +@@ -1349,8 +1349,9 @@ void x86_pmu_stop(struct perf_event *event, int flags)
2674 + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
2675 + struct hw_perf_event *hwc = &event->hw;
2676
2677 - static struct bin_attribute opal_msglog_attr = {
2678 -- .attr = {.name = "msglog", .mode = 0444},
2679 -+ .attr = {.name = "msglog", .mode = 0400},
2680 - .read = opal_msglog_read
2681 - };
2682 +- if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) {
2683 ++ if (test_bit(hwc->idx, cpuc->active_mask)) {
2684 + x86_pmu.disable(event);
2685 ++ __clear_bit(hwc->idx, cpuc->active_mask);
2686 + cpuc->events[hwc->idx] = NULL;
2687 + WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
2688 + hwc->state |= PERF_HES_STOPPED;
2689 +@@ -1447,16 +1448,8 @@ int x86_pmu_handle_irq(struct pt_regs *regs)
2690 + apic_write(APIC_LVTPC, APIC_DM_NMI);
2691
2692 -diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
2693 -index 697449afb3f7..e28f03e1eb5e 100644
2694 ---- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
2695 -+++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
2696 -@@ -313,7 +313,6 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
2697 - page_shift);
2698 - tbl->it_level_size = 1ULL << (level_shift - 3);
2699 - tbl->it_indirect_levels = levels - 1;
2700 -- tbl->it_allocated_size = total_allocated;
2701 - tbl->it_userspace = uas;
2702 - tbl->it_nid = nid;
2703 -
2704 -diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
2705 -index 145373f0e5dc..2d62c58f9a4c 100644
2706 ---- a/arch/powerpc/platforms/powernv/pci-ioda.c
2707 -+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
2708 -@@ -2594,8 +2594,13 @@ static long pnv_pci_ioda2_create_table_userspace(
2709 - int num, __u32 page_shift, __u64 window_size, __u32 levels,
2710 - struct iommu_table **ptbl)
2711 - {
2712 -- return pnv_pci_ioda2_create_table(table_group,
2713 -+ long ret = pnv_pci_ioda2_create_table(table_group,
2714 - num, page_shift, window_size, levels, true, ptbl);
2715 -+
2716 -+ if (!ret)
2717 -+ (*ptbl)->it_allocated_size = pnv_pci_ioda2_get_table_size(
2718 -+ page_shift, window_size, levels);
2719 -+ return ret;
2720 - }
2721 + for (idx = 0; idx < x86_pmu.num_counters; idx++) {
2722 +- if (!test_bit(idx, cpuc->active_mask)) {
2723 +- /*
2724 +- * Though we deactivated the counter some cpus
2725 +- * might still deliver spurious interrupts still
2726 +- * in flight. Catch them:
2727 +- */
2728 +- if (__test_and_clear_bit(idx, cpuc->running))
2729 +- handled++;
2730 ++ if (!test_bit(idx, cpuc->active_mask))
2731 + continue;
2732 +- }
2733
2734 - static void pnv_ioda2_take_ownership(struct iommu_table_group *table_group)
2735 -diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
2736 -index 0d354e19ef92..db09c7022635 100644
2737 ---- a/arch/powerpc/platforms/powernv/smp.c
2738 -+++ b/arch/powerpc/platforms/powernv/smp.c
2739 -@@ -39,6 +39,7 @@
2740 - #include <asm/cpuidle.h>
2741 - #include <asm/kexec.h>
2742 - #include <asm/reg.h>
2743 -+#include <asm/powernv.h>
2744 + event = cpuc->events[idx];
2745
2746 - #include "powernv.h"
2747 +diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
2748 +index ad7b210aa3f6..8e790ec219a5 100644
2749 +--- a/arch/x86/include/asm/bitops.h
2750 ++++ b/arch/x86/include/asm/bitops.h
2751 +@@ -36,22 +36,17 @@
2752 + * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
2753 + */
2754
2755 -@@ -153,6 +154,7 @@ static void pnv_smp_cpu_kill_self(void)
2756 - {
2757 - unsigned int cpu;
2758 - unsigned long srr1, wmask;
2759 -+ u64 lpcr_val;
2760 +-#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
2761 +-/* Technically wrong, but this avoids compilation errors on some gcc
2762 +- versions. */
2763 +-#define BITOP_ADDR(x) "=m" (*(volatile long *) (x))
2764 +-#else
2765 +-#define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
2766 +-#endif
2767 ++#define RLONG_ADDR(x) "m" (*(volatile long *) (x))
2768 ++#define WBYTE_ADDR(x) "+m" (*(volatile char *) (x))
2769
2770 - /* Standard hot unplug procedure */
2771 - /*
2772 -@@ -174,6 +176,19 @@ static void pnv_smp_cpu_kill_self(void)
2773 - if (cpu_has_feature(CPU_FTR_ARCH_207S))
2774 - wmask = SRR1_WAKEMASK_P8;
2775 +-#define ADDR BITOP_ADDR(addr)
2776 ++#define ADDR RLONG_ADDR(addr)
2777
2778 -+ /*
2779 -+ * We don't want to take decrementer interrupts while we are
2780 -+ * offline, so clear LPCR:PECE1. We keep PECE2 (and
2781 -+ * LPCR_PECE_HVEE on P9) enabled so as to let IPIs in.
2782 -+ *
2783 -+ * If the CPU gets woken up by a special wakeup, ensure that
2784 -+ * the SLW engine sets LPCR with decrementer bit cleared, else
2785 -+ * the CPU will come back to the kernel due to a spurious
2786 -+ * wakeup.
2787 -+ */
2788 -+ lpcr_val = mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1;
2789 -+ pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val);
2790 -+
2791 - while (!generic_check_cpu_restart(cpu)) {
2792 - /*
2793 - * Clear IPI flag, since we don't handle IPIs while
2794 -@@ -246,6 +261,16 @@ static void pnv_smp_cpu_kill_self(void)
2795 + /*
2796 + * We do the locked ops that don't return the old value as
2797 + * a mask operation on a byte.
2798 + */
2799 + #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
2800 +-#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
2801 ++#define CONST_MASK_ADDR(nr, addr) WBYTE_ADDR((void *)(addr) + ((nr)>>3))
2802 + #define CONST_MASK(nr) (1 << ((nr) & 7))
2803
2804 + /**
2805 +@@ -79,7 +74,7 @@ set_bit(long nr, volatile unsigned long *addr)
2806 + : "memory");
2807 + } else {
2808 + asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
2809 +- : BITOP_ADDR(addr) : "Ir" (nr) : "memory");
2810 ++ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
2811 }
2812 -
2813 -+ /*
2814 -+ * Re-enable decrementer interrupts in LPCR.
2815 -+ *
2816 -+ * Further, we want stop states to be woken up by decrementer
2817 -+ * for non-hotplug cases. So program the LPCR via stop api as
2818 -+ * well.
2819 -+ */
2820 -+ lpcr_val = mfspr(SPRN_LPCR) | (u64)LPCR_PECE1;
2821 -+ pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val);
2822 -+
2823 - DBG("CPU%d coming online...\n", cpu);
2824 }
2825
2826 -diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
2827 -index 2f8e62163602..97feb6e79f1a 100644
2828 ---- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
2829 -+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
2830 -@@ -802,6 +802,25 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add)
2831 - return rc;
2832 +@@ -94,7 +89,7 @@ set_bit(long nr, volatile unsigned long *addr)
2833 + */
2834 + static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
2835 + {
2836 +- asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory");
2837 ++ asm volatile(__ASM_SIZE(bts) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
2838 }
2839
2840 -+int dlpar_cpu_readd(int cpu)
2841 -+{
2842 -+ struct device_node *dn;
2843 -+ struct device *dev;
2844 -+ u32 drc_index;
2845 -+ int rc;
2846 -+
2847 -+ dev = get_cpu_device(cpu);
2848 -+ dn = dev->of_node;
2849 -+
2850 -+ rc = of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);
2851 -+
2852 -+ rc = dlpar_cpu_remove_by_index(drc_index);
2853 -+ if (!rc)
2854 -+ rc = dlpar_cpu_add(drc_index);
2855 -+
2856 -+ return rc;
2857 -+}
2858 -+
2859 - int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
2860 - {
2861 - u32 count, drc_index;
2862 -diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
2863 -index 6ed22127391b..921f12182f3e 100644
2864 ---- a/arch/powerpc/platforms/pseries/pseries_energy.c
2865 -+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
2866 -@@ -77,18 +77,27 @@ static u32 cpu_to_drc_index(int cpu)
2867 -
2868 - ret = drc.drc_index_start + (thread_index * drc.sequential_inc);
2869 + /**
2870 +@@ -116,8 +111,7 @@ clear_bit(long nr, volatile unsigned long *addr)
2871 + : "iq" ((u8)~CONST_MASK(nr)));
2872 } else {
2873 -- const __be32 *indexes;
2874 --
2875 -- indexes = of_get_property(dn, "ibm,drc-indexes", NULL);
2876 -- if (indexes == NULL)
2877 -- goto err_of_node_put;
2878 -+ u32 nr_drc_indexes, thread_drc_index;
2879 -
2880 - /*
2881 -- * The first element indexes[0] is the number of drc_indexes
2882 -- * returned in the list. Hence thread_index+1 will get the
2883 -- * drc_index corresponding to core number thread_index.
2884 -+ * The first element of ibm,drc-indexes array is the
2885 -+ * number of drc_indexes returned in the list. Hence
2886 -+ * thread_index+1 will get the drc_index corresponding
2887 -+ * to core number thread_index.
2888 - */
2889 -- ret = indexes[thread_index + 1];
2890 -+ rc = of_property_read_u32_index(dn, "ibm,drc-indexes",
2891 -+ 0, &nr_drc_indexes);
2892 -+ if (rc)
2893 -+ goto err_of_node_put;
2894 -+
2895 -+ WARN_ON_ONCE(thread_index > nr_drc_indexes);
2896 -+ rc = of_property_read_u32_index(dn, "ibm,drc-indexes",
2897 -+ thread_index + 1,
2898 -+ &thread_drc_index);
2899 -+ if (rc)
2900 -+ goto err_of_node_put;
2901 -+
2902 -+ ret = thread_drc_index;
2903 - }
2904 -
2905 - rc = 0;
2906 -diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
2907 -index d97d52772789..452dcfd7e5dd 100644
2908 ---- a/arch/powerpc/platforms/pseries/ras.c
2909 -+++ b/arch/powerpc/platforms/pseries/ras.c
2910 -@@ -550,6 +550,7 @@ static void pseries_print_mce_info(struct pt_regs *regs,
2911 - "UE",
2912 - "SLB",
2913 - "ERAT",
2914 -+ "Unknown",
2915 - "TLB",
2916 - "D-Cache",
2917 - "Unknown",
2918 -diff --git a/arch/powerpc/xmon/ppc-dis.c b/arch/powerpc/xmon/ppc-dis.c
2919 -index 9deea5ee13f6..27f1e6415036 100644
2920 ---- a/arch/powerpc/xmon/ppc-dis.c
2921 -+++ b/arch/powerpc/xmon/ppc-dis.c
2922 -@@ -158,7 +158,7 @@ int print_insn_powerpc (unsigned long insn, unsigned long memaddr)
2923 - dialect |= (PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_POWER7
2924 - | PPC_OPCODE_POWER8 | PPC_OPCODE_POWER9 | PPC_OPCODE_HTM
2925 - | PPC_OPCODE_ALTIVEC | PPC_OPCODE_ALTIVEC2
2926 -- | PPC_OPCODE_VSX | PPC_OPCODE_VSX3),
2927 -+ | PPC_OPCODE_VSX | PPC_OPCODE_VSX3);
2928 -
2929 - /* Get the major opcode of the insn. */
2930 - opcode = NULL;
2931 -diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
2932 -index bba3da6ef157..6ea9e1804233 100644
2933 ---- a/arch/riscv/include/asm/syscall.h
2934 -+++ b/arch/riscv/include/asm/syscall.h
2935 -@@ -79,10 +79,11 @@ static inline void syscall_get_arguments(struct task_struct *task,
2936 - if (i == 0) {
2937 - args[0] = regs->orig_a0;
2938 - args++;
2939 -- i++;
2940 - n--;
2941 -+ } else {
2942 -+ i--;
2943 + asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
2944 +- : BITOP_ADDR(addr)
2945 +- : "Ir" (nr));
2946 ++ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
2947 }
2948 -- memcpy(args, &regs->a1 + i * sizeof(regs->a1), n * sizeof(args[0]));
2949 -+ memcpy(args, &regs->a1 + i, n * sizeof(args[0]));
2950 - }
2951 -
2952 - static inline void syscall_set_arguments(struct task_struct *task,
2953 -@@ -94,10 +95,11 @@ static inline void syscall_set_arguments(struct task_struct *task,
2954 - if (i == 0) {
2955 - regs->orig_a0 = args[0];
2956 - args++;
2957 -- i++;
2958 - n--;
2959 -- }
2960 -- memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
2961 -+ } else {
2962 -+ i--;
2963 -+ }
2964 -+ memcpy(&regs->a1 + i, args, n * sizeof(regs->a1));
2965 }
2966
2967 - static inline int syscall_get_arch(void)
2968 -diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
2969 -index d5d24889c3bc..c2b8c8c6c9be 100644
2970 ---- a/arch/s390/include/asm/kvm_host.h
2971 -+++ b/arch/s390/include/asm/kvm_host.h
2972 -@@ -878,7 +878,7 @@ static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
2973 - static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
2974 - static inline void kvm_arch_free_memslot(struct kvm *kvm,
2975 - struct kvm_memory_slot *free, struct kvm_memory_slot *dont) {}
2976 --static inline void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots) {}
2977 -+static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
2978 - static inline void kvm_arch_flush_shadow_all(struct kvm *kvm) {}
2979 - static inline void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
2980 - struct kvm_memory_slot *slot) {}
2981 -diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
2982 -index bfabeb1889cc..1266194afb02 100644
2983 ---- a/arch/s390/kernel/perf_cpum_sf.c
2984 -+++ b/arch/s390/kernel/perf_cpum_sf.c
2985 -@@ -1600,7 +1600,7 @@ static void aux_sdb_init(unsigned long sdb)
2986 +@@ -137,7 +131,7 @@ static __always_inline void clear_bit_unlock(long nr, volatile unsigned long *ad
2987
2988 - /*
2989 - * aux_buffer_setup() - Setup AUX buffer for diagnostic mode sampling
2990 -- * @cpu: On which to allocate, -1 means current
2991 -+ * @event: Event the buffer is setup for, event->cpu == -1 means current
2992 - * @pages: Array of pointers to buffer pages passed from perf core
2993 - * @nr_pages: Total pages
2994 - * @snapshot: Flag for snapshot mode
2995 -@@ -1612,8 +1612,8 @@ static void aux_sdb_init(unsigned long sdb)
2996 - *
2997 - * Return the private AUX buffer structure if success or NULL if fails.
2998 - */
2999 --static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
3000 -- bool snapshot)
3001 -+static void *aux_buffer_setup(struct perf_event *event, void **pages,
3002 -+ int nr_pages, bool snapshot)
3003 + static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)
3004 {
3005 - struct sf_buffer *sfb;
3006 - struct aux_buffer *aux;
3007 -diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
3008 -index 7ed90a759135..01a3f4964d57 100644
3009 ---- a/arch/s390/kernel/setup.c
3010 -+++ b/arch/s390/kernel/setup.c
3011 -@@ -369,7 +369,7 @@ void __init arch_call_rest_init(void)
3012 - : : [_frame] "a" (frame));
3013 +- asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr));
3014 ++ asm volatile(__ASM_SIZE(btr) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
3015 }
3016
3017 --static void __init setup_lowcore(void)
3018 -+static void __init setup_lowcore_dat_off(void)
3019 - {
3020 - struct lowcore *lc;
3021 -
3022 -@@ -380,19 +380,16 @@ static void __init setup_lowcore(void)
3023 - lc = memblock_alloc_low(sizeof(*lc), sizeof(*lc));
3024 - lc->restart_psw.mask = PSW_KERNEL_BITS;
3025 - lc->restart_psw.addr = (unsigned long) restart_int_handler;
3026 -- lc->external_new_psw.mask = PSW_KERNEL_BITS |
3027 -- PSW_MASK_DAT | PSW_MASK_MCHECK;
3028 -+ lc->external_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_MCHECK;
3029 - lc->external_new_psw.addr = (unsigned long) ext_int_handler;
3030 - lc->svc_new_psw.mask = PSW_KERNEL_BITS |
3031 -- PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
3032 -+ PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
3033 - lc->svc_new_psw.addr = (unsigned long) system_call;
3034 -- lc->program_new_psw.mask = PSW_KERNEL_BITS |
3035 -- PSW_MASK_DAT | PSW_MASK_MCHECK;
3036 -+ lc->program_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_MCHECK;
3037 - lc->program_new_psw.addr = (unsigned long) pgm_check_handler;
3038 - lc->mcck_new_psw.mask = PSW_KERNEL_BITS;
3039 - lc->mcck_new_psw.addr = (unsigned long) mcck_int_handler;
3040 -- lc->io_new_psw.mask = PSW_KERNEL_BITS |
3041 -- PSW_MASK_DAT | PSW_MASK_MCHECK;
3042 -+ lc->io_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_MCHECK;
3043 - lc->io_new_psw.addr = (unsigned long) io_int_handler;
3044 - lc->clock_comparator = clock_comparator_max;
3045 - lc->nodat_stack = ((unsigned long) &init_thread_union)
3046 -@@ -452,6 +449,16 @@ static void __init setup_lowcore(void)
3047 - lowcore_ptr[0] = lc;
3048 + static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr)
3049 +@@ -145,7 +139,7 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile
3050 + bool negative;
3051 + asm volatile(LOCK_PREFIX "andb %2,%1"
3052 + CC_SET(s)
3053 +- : CC_OUT(s) (negative), ADDR
3054 ++ : CC_OUT(s) (negative), WBYTE_ADDR(addr)
3055 + : "ir" ((char) ~(1 << nr)) : "memory");
3056 + return negative;
3057 }
3058 -
3059 -+static void __init setup_lowcore_dat_on(void)
3060 -+{
3061 -+ __ctl_clear_bit(0, 28);
3062 -+ S390_lowcore.external_new_psw.mask |= PSW_MASK_DAT;
3063 -+ S390_lowcore.svc_new_psw.mask |= PSW_MASK_DAT;
3064 -+ S390_lowcore.program_new_psw.mask |= PSW_MASK_DAT;
3065 -+ S390_lowcore.io_new_psw.mask |= PSW_MASK_DAT;
3066 -+ __ctl_set_bit(0, 28);
3067 -+}
3068 -+
3069 - static struct resource code_resource = {
3070 - .name = "Kernel code",
3071 - .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
3072 -@@ -1072,7 +1079,7 @@ void __init setup_arch(char **cmdline_p)
3073 - #endif
3074 -
3075 - setup_resources();
3076 -- setup_lowcore();
3077 -+ setup_lowcore_dat_off();
3078 - smp_fill_possible_mask();
3079 - cpu_detect_mhz_feature();
3080 - cpu_init();
3081 -@@ -1085,6 +1092,12 @@ void __init setup_arch(char **cmdline_p)
3082 - */
3083 - paging_init();
3084 -
3085 -+ /*
3086 -+ * After paging_init created the kernel page table, the new PSWs
3087 -+ * in lowcore can now run with DAT enabled.
3088 -+ */
3089 -+ setup_lowcore_dat_on();
3090 -+
3091 - /* Setup default console */
3092 - conmode_default();
3093 - set_preferred_console();
3094 -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
3095 -index 68261430fe6e..64d5a3327030 100644
3096 ---- a/arch/x86/Kconfig
3097 -+++ b/arch/x86/Kconfig
3098 -@@ -2221,14 +2221,8 @@ config RANDOMIZE_MEMORY_PHYSICAL_PADDING
3099 - If unsure, leave at the default value.
3100 -
3101 - config HOTPLUG_CPU
3102 -- bool "Support for hot-pluggable CPUs"
3103 -+ def_bool y
3104 - depends on SMP
3105 -- ---help---
3106 -- Say Y here to allow turning CPUs off and on. CPUs can be
3107 -- controlled through /sys/devices/system/cpu.
3108 -- ( Note: power management support will enable this option
3109 -- automatically on SMP systems. )
3110 -- Say N if you want to disable CPU hotplug.
3111 -
3112 - config BOOTPARAM_HOTPLUG_CPU0
3113 - bool "Set default setting of cpu0_hotpluggable"
3114 -diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
3115 -index 9b5adae9cc40..e2839b5c246c 100644
3116 ---- a/arch/x86/boot/Makefile
3117 -+++ b/arch/x86/boot/Makefile
3118 -@@ -100,7 +100,7 @@ $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
3119 - AFLAGS_header.o += -I$(objtree)/$(obj)
3120 - $(obj)/header.o: $(obj)/zoffset.h
3121 -
3122 --LDFLAGS_setup.elf := -T
3123 -+LDFLAGS_setup.elf := -m elf_i386 -T
3124 - $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
3125 - $(call if_changed,ld)
3126 -
3127 -diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
3128 -index 9e2157371491..f8debf7aeb4c 100644
3129 ---- a/arch/x86/boot/compressed/pgtable_64.c
3130 -+++ b/arch/x86/boot/compressed/pgtable_64.c
3131 -@@ -1,5 +1,7 @@
3132 -+#include <linux/efi.h>
3133 - #include <asm/e820/types.h>
3134 - #include <asm/processor.h>
3135 -+#include <asm/efi.h>
3136 - #include "pgtable.h"
3137 - #include "../string.h"
3138 -
3139 -@@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char *option);
3140 -
3141 - static unsigned long find_trampoline_placement(void)
3142 +@@ -161,13 +155,9 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile
3143 + * __clear_bit() is non-atomic and implies release semantics before the memory
3144 + * operation. It can be used for an unlock if no other CPUs can concurrently
3145 + * modify other bits in the word.
3146 +- *
3147 +- * No memory barrier is required here, because x86 cannot reorder stores past
3148 +- * older loads. Same principle as spin_unlock.
3149 + */
3150 + static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *addr)
3151 {
3152 -- unsigned long bios_start, ebda_start;
3153 -+ unsigned long bios_start = 0, ebda_start = 0;
3154 - unsigned long trampoline_start;
3155 - struct boot_e820_entry *entry;
3156 -+ char *signature;
3157 - int i;
3158 -
3159 - /*
3160 -@@ -47,8 +50,18 @@ static unsigned long find_trampoline_placement(void)
3161 - * This code is based on reserve_bios_regions().
3162 - */
3163 -
3164 -- ebda_start = *(unsigned short *)0x40e << 4;
3165 -- bios_start = *(unsigned short *)0x413 << 10;
3166 -+ /*
3167 -+ * EFI systems may not provide legacy ROM. The memory may not be mapped
3168 -+ * at all.
3169 -+ *
3170 -+ * Only look for values in the legacy ROM for non-EFI system.
3171 -+ */
3172 -+ signature = (char *)&boot_params->efi_info.efi_loader_signature;
3173 -+ if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) &&
3174 -+ strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) {
3175 -+ ebda_start = *(unsigned short *)0x40e << 4;
3176 -+ bios_start = *(unsigned short *)0x413 << 10;
3177 -+ }
3178 -
3179 - if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
3180 - bios_start = BIOS_START_MAX;
3181 -diff --git a/arch/x86/crypto/aegis128-aesni-glue.c b/arch/x86/crypto/aegis128-aesni-glue.c
3182 -index 2a356b948720..3ea71b871813 100644
3183 ---- a/arch/x86/crypto/aegis128-aesni-glue.c
3184 -+++ b/arch/x86/crypto/aegis128-aesni-glue.c
3185 -@@ -119,31 +119,20 @@ static void crypto_aegis128_aesni_process_ad(
3186 +- barrier();
3187 + __clear_bit(nr, addr);
3188 }
3189
3190 - static void crypto_aegis128_aesni_process_crypt(
3191 -- struct aegis_state *state, struct aead_request *req,
3192 -+ struct aegis_state *state, struct skcipher_walk *walk,
3193 - const struct aegis_crypt_ops *ops)
3194 +@@ -182,7 +172,7 @@ static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *
3195 + */
3196 + static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
3197 {
3198 -- struct skcipher_walk walk;
3199 -- u8 *src, *dst;
3200 -- unsigned int chunksize, base;
3201 --
3202 -- ops->skcipher_walk_init(&walk, req, false);
3203 --
3204 -- while (walk.nbytes) {
3205 -- src = walk.src.virt.addr;
3206 -- dst = walk.dst.virt.addr;
3207 -- chunksize = walk.nbytes;
3208 --
3209 -- ops->crypt_blocks(state, chunksize, src, dst);
3210 --
3211 -- base = chunksize & ~(AEGIS128_BLOCK_SIZE - 1);
3212 -- src += base;
3213 -- dst += base;
3214 -- chunksize &= AEGIS128_BLOCK_SIZE - 1;
3215 --
3216 -- if (chunksize > 0)
3217 -- ops->crypt_tail(state, chunksize, src, dst);
3218 -+ while (walk->nbytes >= AEGIS128_BLOCK_SIZE) {
3219 -+ ops->crypt_blocks(state,
3220 -+ round_down(walk->nbytes, AEGIS128_BLOCK_SIZE),
3221 -+ walk->src.virt.addr, walk->dst.virt.addr);
3222 -+ skcipher_walk_done(walk, walk->nbytes % AEGIS128_BLOCK_SIZE);
3223 -+ }
3224 +- asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr));
3225 ++ asm volatile(__ASM_SIZE(btc) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
3226 + }
3227
3228 -- skcipher_walk_done(&walk, 0);
3229 -+ if (walk->nbytes) {
3230 -+ ops->crypt_tail(state, walk->nbytes, walk->src.virt.addr,
3231 -+ walk->dst.virt.addr);
3232 -+ skcipher_walk_done(walk, 0);
3233 + /**
3234 +@@ -202,8 +192,7 @@ static __always_inline void change_bit(long nr, volatile unsigned long *addr)
3235 + : "iq" ((u8)CONST_MASK(nr)));
3236 + } else {
3237 + asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
3238 +- : BITOP_ADDR(addr)
3239 +- : "Ir" (nr));
3240 ++ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
3241 }
3242 }
3243
3244 -@@ -186,13 +175,16 @@ static void crypto_aegis128_aesni_crypt(struct aead_request *req,
3245 - {
3246 - struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3247 - struct aegis_ctx *ctx = crypto_aegis128_aesni_ctx(tfm);
3248 -+ struct skcipher_walk walk;
3249 - struct aegis_state state;
3250 +@@ -248,8 +237,8 @@ static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long *
3251
3252 -+ ops->skcipher_walk_init(&walk, req, true);
3253 -+
3254 - kernel_fpu_begin();
3255 -
3256 - crypto_aegis128_aesni_init(&state, ctx->key.bytes, req->iv);
3257 - crypto_aegis128_aesni_process_ad(&state, req->src, req->assoclen);
3258 -- crypto_aegis128_aesni_process_crypt(&state, req, ops);
3259 -+ crypto_aegis128_aesni_process_crypt(&state, &walk, ops);
3260 - crypto_aegis128_aesni_final(&state, tag_xor, req->assoclen, cryptlen);
3261 -
3262 - kernel_fpu_end();
3263 -diff --git a/arch/x86/crypto/aegis128l-aesni-glue.c b/arch/x86/crypto/aegis128l-aesni-glue.c
3264 -index dbe8bb980da1..1b1b39c66c5e 100644
3265 ---- a/arch/x86/crypto/aegis128l-aesni-glue.c
3266 -+++ b/arch/x86/crypto/aegis128l-aesni-glue.c
3267 -@@ -119,31 +119,20 @@ static void crypto_aegis128l_aesni_process_ad(
3268 + asm(__ASM_SIZE(bts) " %2,%1"
3269 + CC_SET(c)
3270 +- : CC_OUT(c) (oldbit), ADDR
3271 +- : "Ir" (nr));
3272 ++ : CC_OUT(c) (oldbit)
3273 ++ : ADDR, "Ir" (nr) : "memory");
3274 + return oldbit;
3275 }
3276
3277 - static void crypto_aegis128l_aesni_process_crypt(
3278 -- struct aegis_state *state, struct aead_request *req,
3279 -+ struct aegis_state *state, struct skcipher_walk *walk,
3280 - const struct aegis_crypt_ops *ops)
3281 - {
3282 -- struct skcipher_walk walk;
3283 -- u8 *src, *dst;
3284 -- unsigned int chunksize, base;
3285 --
3286 -- ops->skcipher_walk_init(&walk, req, false);
3287 --
3288 -- while (walk.nbytes) {
3289 -- src = walk.src.virt.addr;
3290 -- dst = walk.dst.virt.addr;
3291 -- chunksize = walk.nbytes;
3292 --
3293 -- ops->crypt_blocks(state, chunksize, src, dst);
3294 --
3295 -- base = chunksize & ~(AEGIS128L_BLOCK_SIZE - 1);
3296 -- src += base;
3297 -- dst += base;
3298 -- chunksize &= AEGIS128L_BLOCK_SIZE - 1;
3299 --
3300 -- if (chunksize > 0)
3301 -- ops->crypt_tail(state, chunksize, src, dst);
3302 -+ while (walk->nbytes >= AEGIS128L_BLOCK_SIZE) {
3303 -+ ops->crypt_blocks(state, round_down(walk->nbytes,
3304 -+ AEGIS128L_BLOCK_SIZE),
3305 -+ walk->src.virt.addr, walk->dst.virt.addr);
3306 -+ skcipher_walk_done(walk, walk->nbytes % AEGIS128L_BLOCK_SIZE);
3307 -+ }
3308 +@@ -288,8 +277,8 @@ static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long
3309
3310 -- skcipher_walk_done(&walk, 0);
3311 -+ if (walk->nbytes) {
3312 -+ ops->crypt_tail(state, walk->nbytes, walk->src.virt.addr,
3313 -+ walk->dst.virt.addr);
3314 -+ skcipher_walk_done(walk, 0);
3315 - }
3316 + asm volatile(__ASM_SIZE(btr) " %2,%1"
3317 + CC_SET(c)
3318 +- : CC_OUT(c) (oldbit), ADDR
3319 +- : "Ir" (nr));
3320 ++ : CC_OUT(c) (oldbit)
3321 ++ : ADDR, "Ir" (nr) : "memory");
3322 + return oldbit;
3323 }
3324
3325 -@@ -186,13 +175,16 @@ static void crypto_aegis128l_aesni_crypt(struct aead_request *req,
3326 - {
3327 - struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3328 - struct aegis_ctx *ctx = crypto_aegis128l_aesni_ctx(tfm);
3329 -+ struct skcipher_walk walk;
3330 - struct aegis_state state;
3331 -
3332 -+ ops->skcipher_walk_init(&walk, req, true);
3333 -+
3334 - kernel_fpu_begin();
3335 -
3336 - crypto_aegis128l_aesni_init(&state, ctx->key.bytes, req->iv);
3337 - crypto_aegis128l_aesni_process_ad(&state, req->src, req->assoclen);
3338 -- crypto_aegis128l_aesni_process_crypt(&state, req, ops);
3339 -+ crypto_aegis128l_aesni_process_crypt(&state, &walk, ops);
3340 - crypto_aegis128l_aesni_final(&state, tag_xor, req->assoclen, cryptlen);
3341 -
3342 - kernel_fpu_end();
3343 -diff --git a/arch/x86/crypto/aegis256-aesni-glue.c b/arch/x86/crypto/aegis256-aesni-glue.c
3344 -index 8bebda2de92f..6227ca3220a0 100644
3345 ---- a/arch/x86/crypto/aegis256-aesni-glue.c
3346 -+++ b/arch/x86/crypto/aegis256-aesni-glue.c
3347 -@@ -119,31 +119,20 @@ static void crypto_aegis256_aesni_process_ad(
3348 - }
3349 +@@ -300,8 +289,8 @@ static __always_inline bool __test_and_change_bit(long nr, volatile unsigned lon
3350
3351 - static void crypto_aegis256_aesni_process_crypt(
3352 -- struct aegis_state *state, struct aead_request *req,
3353 -+ struct aegis_state *state, struct skcipher_walk *walk,
3354 - const struct aegis_crypt_ops *ops)
3355 - {
3356 -- struct skcipher_walk walk;
3357 -- u8 *src, *dst;
3358 -- unsigned int chunksize, base;
3359 --
3360 -- ops->skcipher_walk_init(&walk, req, false);
3361 --
3362 -- while (walk.nbytes) {
3363 -- src = walk.src.virt.addr;
3364 -- dst = walk.dst.virt.addr;
3365 -- chunksize = walk.nbytes;
3366 --
3367 -- ops->crypt_blocks(state, chunksize, src, dst);
3368 --
3369 -- base = chunksize & ~(AEGIS256_BLOCK_SIZE - 1);
3370 -- src += base;
3371 -- dst += base;
3372 -- chunksize &= AEGIS256_BLOCK_SIZE - 1;
3373 --
3374 -- if (chunksize > 0)
3375 -- ops->crypt_tail(state, chunksize, src, dst);
3376 -+ while (walk->nbytes >= AEGIS256_BLOCK_SIZE) {
3377 -+ ops->crypt_blocks(state,
3378 -+ round_down(walk->nbytes, AEGIS256_BLOCK_SIZE),
3379 -+ walk->src.virt.addr, walk->dst.virt.addr);
3380 -+ skcipher_walk_done(walk, walk->nbytes % AEGIS256_BLOCK_SIZE);
3381 -+ }
3382 + asm volatile(__ASM_SIZE(btc) " %2,%1"
3383 + CC_SET(c)
3384 +- : CC_OUT(c) (oldbit), ADDR
3385 +- : "Ir" (nr) : "memory");
3386 ++ : CC_OUT(c) (oldbit)
3387 ++ : ADDR, "Ir" (nr) : "memory");
3388
3389 -- skcipher_walk_done(&walk, 0);
3390 -+ if (walk->nbytes) {
3391 -+ ops->crypt_tail(state, walk->nbytes, walk->src.virt.addr,
3392 -+ walk->dst.virt.addr);
3393 -+ skcipher_walk_done(walk, 0);
3394 - }
3395 + return oldbit;
3396 }
3397 +@@ -332,7 +321,7 @@ static __always_inline bool variable_test_bit(long nr, volatile const unsigned l
3398 + asm volatile(__ASM_SIZE(bt) " %2,%1"
3399 + CC_SET(c)
3400 + : CC_OUT(c) (oldbit)
3401 +- : "m" (*(unsigned long *)addr), "Ir" (nr));
3402 ++ : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory");
3403
3404 -@@ -186,13 +175,16 @@ static void crypto_aegis256_aesni_crypt(struct aead_request *req,
3405 - {
3406 - struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3407 - struct aegis_ctx *ctx = crypto_aegis256_aesni_ctx(tfm);
3408 -+ struct skcipher_walk walk;
3409 - struct aegis_state state;
3410 + return oldbit;
3411 + }
3412 +diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
3413 +index 55d392c6bd29..2fd165f1cffa 100644
3414 +--- a/arch/x86/include/asm/string_32.h
3415 ++++ b/arch/x86/include/asm/string_32.h
3416 +@@ -179,14 +179,7 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)
3417 + * No 3D Now!
3418 + */
3419
3420 -+ ops->skcipher_walk_init(&walk, req, true);
3421 -+
3422 - kernel_fpu_begin();
3423 -
3424 - crypto_aegis256_aesni_init(&state, ctx->key, req->iv);
3425 - crypto_aegis256_aesni_process_ad(&state, req->src, req->assoclen);
3426 -- crypto_aegis256_aesni_process_crypt(&state, req, ops);
3427 -+ crypto_aegis256_aesni_process_crypt(&state, &walk, ops);
3428 - crypto_aegis256_aesni_final(&state, tag_xor, req->assoclen, cryptlen);
3429 -
3430 - kernel_fpu_end();
3431 -diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
3432 -index 1321700d6647..ae30c8b6ec4d 100644
3433 ---- a/arch/x86/crypto/aesni-intel_glue.c
3434 -+++ b/arch/x86/crypto/aesni-intel_glue.c
3435 -@@ -821,11 +821,14 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
3436 - scatterwalk_map_and_copy(assoc, req->src, 0, assoclen, 0);
3437 - }
3438 +-#if (__GNUC__ >= 4)
3439 + #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
3440 +-#else
3441 +-#define memcpy(t, f, n) \
3442 +- (__builtin_constant_p((n)) \
3443 +- ? __constant_memcpy((t), (f), (n)) \
3444 +- : __memcpy((t), (f), (n)))
3445 +-#endif
3446
3447 -- src_sg = scatterwalk_ffwd(src_start, req->src, req->assoclen);
3448 -- scatterwalk_start(&src_sg_walk, src_sg);
3449 -- if (req->src != req->dst) {
3450 -- dst_sg = scatterwalk_ffwd(dst_start, req->dst, req->assoclen);
3451 -- scatterwalk_start(&dst_sg_walk, dst_sg);
3452 -+ if (left) {
3453 -+ src_sg = scatterwalk_ffwd(src_start, req->src, req->assoclen);
3454 -+ scatterwalk_start(&src_sg_walk, src_sg);
3455 -+ if (req->src != req->dst) {
3456 -+ dst_sg = scatterwalk_ffwd(dst_start, req->dst,
3457 -+ req->assoclen);
3458 -+ scatterwalk_start(&dst_sg_walk, dst_sg);
3459 -+ }
3460 - }
3461 + #endif
3462 + #endif /* !CONFIG_FORTIFY_SOURCE */
3463 +@@ -282,12 +275,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
3464
3465 - kernel_fpu_begin();
3466 -diff --git a/arch/x86/crypto/morus1280_glue.c b/arch/x86/crypto/morus1280_glue.c
3467 -index 0dccdda1eb3a..7e600f8bcdad 100644
3468 ---- a/arch/x86/crypto/morus1280_glue.c
3469 -+++ b/arch/x86/crypto/morus1280_glue.c
3470 -@@ -85,31 +85,20 @@ static void crypto_morus1280_glue_process_ad(
3471 -
3472 - static void crypto_morus1280_glue_process_crypt(struct morus1280_state *state,
3473 - struct morus1280_ops ops,
3474 -- struct aead_request *req)
3475 -+ struct skcipher_walk *walk)
3476 - {
3477 -- struct skcipher_walk walk;
3478 -- u8 *cursor_src, *cursor_dst;
3479 -- unsigned int chunksize, base;
3480 --
3481 -- ops.skcipher_walk_init(&walk, req, false);
3482 --
3483 -- while (walk.nbytes) {
3484 -- cursor_src = walk.src.virt.addr;
3485 -- cursor_dst = walk.dst.virt.addr;
3486 -- chunksize = walk.nbytes;
3487 --
3488 -- ops.crypt_blocks(state, cursor_src, cursor_dst, chunksize);
3489 --
3490 -- base = chunksize & ~(MORUS1280_BLOCK_SIZE - 1);
3491 -- cursor_src += base;
3492 -- cursor_dst += base;
3493 -- chunksize &= MORUS1280_BLOCK_SIZE - 1;
3494 --
3495 -- if (chunksize > 0)
3496 -- ops.crypt_tail(state, cursor_src, cursor_dst,
3497 -- chunksize);
3498 -+ while (walk->nbytes >= MORUS1280_BLOCK_SIZE) {
3499 -+ ops.crypt_blocks(state, walk->src.virt.addr,
3500 -+ walk->dst.virt.addr,
3501 -+ round_down(walk->nbytes,
3502 -+ MORUS1280_BLOCK_SIZE));
3503 -+ skcipher_walk_done(walk, walk->nbytes % MORUS1280_BLOCK_SIZE);
3504 -+ }
3505 + {
3506 + int d0, d1;
3507 +-#if __GNUC__ == 4 && __GNUC_MINOR__ == 0
3508 +- /* Workaround for broken gcc 4.0 */
3509 +- register unsigned long eax asm("%eax") = pattern;
3510 +-#else
3511 + unsigned long eax = pattern;
3512 +-#endif
3513
3514 -- skcipher_walk_done(&walk, 0);
3515 -+ if (walk->nbytes) {
3516 -+ ops.crypt_tail(state, walk->src.virt.addr, walk->dst.virt.addr,
3517 -+ walk->nbytes);
3518 -+ skcipher_walk_done(walk, 0);
3519 - }
3520 - }
3521 + switch (count % 4) {
3522 + case 0:
3523 +@@ -321,15 +309,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
3524 + #define __HAVE_ARCH_MEMSET
3525 + extern void *memset(void *, int, size_t);
3526 + #ifndef CONFIG_FORTIFY_SOURCE
3527 +-#if (__GNUC__ >= 4)
3528 + #define memset(s, c, count) __builtin_memset(s, c, count)
3529 +-#else
3530 +-#define memset(s, c, count) \
3531 +- (__builtin_constant_p(c) \
3532 +- ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \
3533 +- (count)) \
3534 +- : __memset((s), (c), (count)))
3535 +-#endif
3536 + #endif /* !CONFIG_FORTIFY_SOURCE */
3537
3538 -@@ -147,12 +136,15 @@ static void crypto_morus1280_glue_crypt(struct aead_request *req,
3539 - struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3540 - struct morus1280_ctx *ctx = crypto_aead_ctx(tfm);
3541 - struct morus1280_state state;
3542 -+ struct skcipher_walk walk;
3543 -+
3544 -+ ops.skcipher_walk_init(&walk, req, true);
3545 -
3546 - kernel_fpu_begin();
3547 -
3548 - ctx->ops->init(&state, &ctx->key, req->iv);
3549 - crypto_morus1280_glue_process_ad(&state, ctx->ops, req->src, req->assoclen);
3550 -- crypto_morus1280_glue_process_crypt(&state, ops, req);
3551 -+ crypto_morus1280_glue_process_crypt(&state, ops, &walk);
3552 - ctx->ops->final(&state, tag_xor, req->assoclen, cryptlen);
3553 -
3554 - kernel_fpu_end();
3555 -diff --git a/arch/x86/crypto/morus640_glue.c b/arch/x86/crypto/morus640_glue.c
3556 -index 7b58fe4d9bd1..cb3a81732016 100644
3557 ---- a/arch/x86/crypto/morus640_glue.c
3558 -+++ b/arch/x86/crypto/morus640_glue.c
3559 -@@ -85,31 +85,19 @@ static void crypto_morus640_glue_process_ad(
3560 -
3561 - static void crypto_morus640_glue_process_crypt(struct morus640_state *state,
3562 - struct morus640_ops ops,
3563 -- struct aead_request *req)
3564 -+ struct skcipher_walk *walk)
3565 - {
3566 -- struct skcipher_walk walk;
3567 -- u8 *cursor_src, *cursor_dst;
3568 -- unsigned int chunksize, base;
3569 --
3570 -- ops.skcipher_walk_init(&walk, req, false);
3571 --
3572 -- while (walk.nbytes) {
3573 -- cursor_src = walk.src.virt.addr;
3574 -- cursor_dst = walk.dst.virt.addr;
3575 -- chunksize = walk.nbytes;
3576 --
3577 -- ops.crypt_blocks(state, cursor_src, cursor_dst, chunksize);
3578 --
3579 -- base = chunksize & ~(MORUS640_BLOCK_SIZE - 1);
3580 -- cursor_src += base;
3581 -- cursor_dst += base;
3582 -- chunksize &= MORUS640_BLOCK_SIZE - 1;
3583 --
3584 -- if (chunksize > 0)
3585 -- ops.crypt_tail(state, cursor_src, cursor_dst,
3586 -- chunksize);
3587 -+ while (walk->nbytes >= MORUS640_BLOCK_SIZE) {
3588 -+ ops.crypt_blocks(state, walk->src.virt.addr,
3589 -+ walk->dst.virt.addr,
3590 -+ round_down(walk->nbytes, MORUS640_BLOCK_SIZE));
3591 -+ skcipher_walk_done(walk, walk->nbytes % MORUS640_BLOCK_SIZE);
3592 -+ }
3593 + #define __HAVE_ARCH_MEMSET16
3594 +diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h
3595 +index 4e4194e21a09..75314c3dbe47 100644
3596 +--- a/arch/x86/include/asm/string_64.h
3597 ++++ b/arch/x86/include/asm/string_64.h
3598 +@@ -14,21 +14,6 @@
3599 + extern void *memcpy(void *to, const void *from, size_t len);
3600 + extern void *__memcpy(void *to, const void *from, size_t len);
3601
3602 -- skcipher_walk_done(&walk, 0);
3603 -+ if (walk->nbytes) {
3604 -+ ops.crypt_tail(state, walk->src.virt.addr, walk->dst.virt.addr,
3605 -+ walk->nbytes);
3606 -+ skcipher_walk_done(walk, 0);
3607 - }
3608 - }
3609 +-#ifndef CONFIG_FORTIFY_SOURCE
3610 +-#if (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || __GNUC__ < 4
3611 +-#define memcpy(dst, src, len) \
3612 +-({ \
3613 +- size_t __len = (len); \
3614 +- void *__ret; \
3615 +- if (__builtin_constant_p(len) && __len >= 64) \
3616 +- __ret = __memcpy((dst), (src), __len); \
3617 +- else \
3618 +- __ret = __builtin_memcpy((dst), (src), __len); \
3619 +- __ret; \
3620 +-})
3621 +-#endif
3622 +-#endif /* !CONFIG_FORTIFY_SOURCE */
3623 +-
3624 + #define __HAVE_ARCH_MEMSET
3625 + void *memset(void *s, int c, size_t n);
3626 + void *__memset(void *s, int c, size_t n);
3627 +diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
3628 +index ef05bea7010d..6b5c710846f5 100644
3629 +--- a/arch/x86/include/asm/xen/hypercall.h
3630 ++++ b/arch/x86/include/asm/xen/hypercall.h
3631 +@@ -206,6 +206,9 @@ xen_single_call(unsigned int call,
3632 + __HYPERCALL_DECLS;
3633 + __HYPERCALL_5ARG(a1, a2, a3, a4, a5);
3634
3635 -@@ -143,12 +131,15 @@ static void crypto_morus640_glue_crypt(struct aead_request *req,
3636 - struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3637 - struct morus640_ctx *ctx = crypto_aead_ctx(tfm);
3638 - struct morus640_state state;
3639 -+ struct skcipher_walk walk;
3640 ++ if (call >= PAGE_SIZE / sizeof(hypercall_page[0]))
3641 ++ return -EINVAL;
3642 +
3643 -+ ops.skcipher_walk_init(&walk, req, true);
3644 -
3645 - kernel_fpu_begin();
3646 + asm volatile(CALL_NOSPEC
3647 + : __HYPERCALL_5PARAM
3648 + : [thunk_target] "a" (&hypercall_page[call])
3649 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
3650 +index f13a3a24d360..a9b8e38d78ad 100644
3651 +--- a/arch/x86/kvm/svm.c
3652 ++++ b/arch/x86/kvm/svm.c
3653 +@@ -6422,11 +6422,11 @@ e_free:
3654 + return ret;
3655 + }
3656
3657 - ctx->ops->init(&state, &ctx->key, req->iv);
3658 - crypto_morus640_glue_process_ad(&state, ctx->ops, req->src, req->assoclen);
3659 -- crypto_morus640_glue_process_crypt(&state, ops, req);
3660 -+ crypto_morus640_glue_process_crypt(&state, ops, &walk);
3661 - ctx->ops->final(&state, tag_xor, req->assoclen, cryptlen);
3662 +-static int get_num_contig_pages(int idx, struct page **inpages,
3663 +- unsigned long npages)
3664 ++static unsigned long get_num_contig_pages(unsigned long idx,
3665 ++ struct page **inpages, unsigned long npages)
3666 + {
3667 + unsigned long paddr, next_paddr;
3668 +- int i = idx + 1, pages = 1;
3669 ++ unsigned long i = idx + 1, pages = 1;
3670
3671 - kernel_fpu_end();
3672 -diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
3673 -index 7d2d7c801dba..0ecfac84ba91 100644
3674 ---- a/arch/x86/events/amd/core.c
3675 -+++ b/arch/x86/events/amd/core.c
3676 -@@ -3,10 +3,14 @@
3677 - #include <linux/types.h>
3678 - #include <linux/init.h>
3679 - #include <linux/slab.h>
3680 -+#include <linux/delay.h>
3681 - #include <asm/apicdef.h>
3682 -+#include <asm/nmi.h>
3683 + /* find the number of contiguous pages starting from idx */
3684 + paddr = __sme_page_pa(inpages[idx]);
3685 +@@ -6445,12 +6445,12 @@ static int get_num_contig_pages(int idx, struct page **inpages,
3686
3687 - #include "../perf_event.h"
3688 + static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
3689 + {
3690 +- unsigned long vaddr, vaddr_end, next_vaddr, npages, size;
3691 ++ unsigned long vaddr, vaddr_end, next_vaddr, npages, pages, size, i;
3692 + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
3693 + struct kvm_sev_launch_update_data params;
3694 + struct sev_data_launch_update_data *data;
3695 + struct page **inpages;
3696 +- int i, ret, pages;
3697 ++ int ret;
3698
3699 -+static DEFINE_PER_CPU(unsigned int, perf_nmi_counter);
3700 -+
3701 - static __initconst const u64 amd_hw_cache_event_ids
3702 - [PERF_COUNT_HW_CACHE_MAX]
3703 - [PERF_COUNT_HW_CACHE_OP_MAX]
3704 -@@ -429,6 +433,132 @@ static void amd_pmu_cpu_dead(int cpu)
3705 + if (!sev_guest(kvm))
3706 + return -ENOTTY;
3707 +diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
3708 +index f014e1aeee96..f90b3a948291 100644
3709 +--- a/arch/x86/kvm/vmx/nested.c
3710 ++++ b/arch/x86/kvm/vmx/nested.c
3711 +@@ -500,6 +500,17 @@ static void nested_vmx_disable_intercept_for_msr(unsigned long *msr_bitmap_l1,
3712 }
3713 }
3714
3715 -+/*
3716 -+ * When a PMC counter overflows, an NMI is used to process the event and
3717 -+ * reset the counter. NMI latency can result in the counter being updated
3718 -+ * before the NMI can run, which can result in what appear to be spurious
3719 -+ * NMIs. This function is intended to wait for the NMI to run and reset
3720 -+ * the counter to avoid possible unhandled NMI messages.
3721 -+ */
3722 -+#define OVERFLOW_WAIT_COUNT 50
3723 -+
3724 -+static void amd_pmu_wait_on_overflow(int idx)
3725 -+{
3726 -+ unsigned int i;
3727 -+ u64 counter;
3728 ++static inline void enable_x2apic_msr_intercepts(unsigned long *msr_bitmap) {
3729 ++ int msr;
3730 +
3731 -+ /*
3732 -+ * Wait for the counter to be reset if it has overflowed. This loop
3733 -+ * should exit very, very quickly, but just in case, don't wait
3734 -+ * forever...
3735 -+ */
3736 -+ for (i = 0; i < OVERFLOW_WAIT_COUNT; i++) {
3737 -+ rdmsrl(x86_pmu_event_addr(idx), counter);
3738 -+ if (counter & (1ULL << (x86_pmu.cntval_bits - 1)))
3739 -+ break;
3740 ++ for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
3741 ++ unsigned word = msr / BITS_PER_LONG;
3742 +
3743 -+ /* Might be in IRQ context, so can't sleep */
3744 -+ udelay(1);
3745 ++ msr_bitmap[word] = ~0;
3746 ++ msr_bitmap[word + (0x800 / sizeof(long))] = ~0;
3747 + }
3748 +}
3749 +
3750 -+static void amd_pmu_disable_all(void)
3751 -+{
3752 -+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3753 -+ int idx;
3754 -+
3755 -+ x86_pmu_disable_all();
3756 -+
3757 + /*
3758 + * Merge L0's and L1's MSR bitmap, return false to indicate that
3759 + * we do not use the hardware.
3760 +@@ -541,39 +552,44 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
3761 + return false;
3762 +
3763 + msr_bitmap_l1 = (unsigned long *)kmap(page);
3764 +- if (nested_cpu_has_apic_reg_virt(vmcs12)) {
3765 +- /*
3766 +- * L0 need not intercept reads for MSRs between 0x800 and 0x8ff, it
3767 +- * just lets the processor take the value from the virtual-APIC page;
3768 +- * take those 256 bits directly from the L1 bitmap.
3769 +- */
3770 +- for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
3771 +- unsigned word = msr / BITS_PER_LONG;
3772 +- msr_bitmap_l0[word] = msr_bitmap_l1[word];
3773 +- msr_bitmap_l0[word + (0x800 / sizeof(long))] = ~0;
3774 +- }
3775 +- } else {
3776 +- for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
3777 +- unsigned word = msr / BITS_PER_LONG;
3778 +- msr_bitmap_l0[word] = ~0;
3779 +- msr_bitmap_l0[word + (0x800 / sizeof(long))] = ~0;
3780 +- }
3781 +- }
3782 +
3783 +- nested_vmx_disable_intercept_for_msr(
3784 +- msr_bitmap_l1, msr_bitmap_l0,
3785 +- X2APIC_MSR(APIC_TASKPRI),
3786 +- MSR_TYPE_W);
3787 + /*
3788 -+ * This shouldn't be called from NMI context, but add a safeguard here
3789 -+ * to return, since if we're in NMI context we can't wait for an NMI
3790 -+ * to reset an overflowed counter value.
3791 ++ * To keep the control flow simple, pay eight 8-byte writes (sixteen
3792 ++ * 4-byte writes on 32-bit systems) up front to enable intercepts for
3793 ++ * the x2APIC MSR range and selectively disable them below.
3794 + */
3795 -+ if (in_nmi())
3796 -+ return;
3797 ++ enable_x2apic_msr_intercepts(msr_bitmap_l0);
3798 +
3799 -+ /*
3800 -+ * Check each counter for overflow and wait for it to be reset by the
3801 -+ * NMI if it has overflowed. This relies on the fact that all active
3802 -+ * counters are always enabled when this function is caled and
3803 -+ * ARCH_PERFMON_EVENTSEL_INT is always set.
3804 -+ */
3805 -+ for (idx = 0; idx < x86_pmu.num_counters; idx++) {
3806 -+ if (!test_bit(idx, cpuc->active_mask))
3807 -+ continue;
3808 -+
3809 -+ amd_pmu_wait_on_overflow(idx);
3810 -+ }
3811 -+}
3812 -+
3813 -+static void amd_pmu_disable_event(struct perf_event *event)
3814 -+{
3815 -+ x86_pmu_disable_event(event);
3816 -+
3817 -+ /*
3818 -+ * This can be called from NMI context (via x86_pmu_stop). The counter
3819 -+ * may have overflowed, but either way, we'll never see it get reset
3820 -+ * by the NMI if we're already in the NMI. And the NMI latency support
3821 -+ * below will take care of any pending NMI that might have been
3822 -+ * generated by the overflow.
3823 -+ */
3824 -+ if (in_nmi())
3825 -+ return;
3826 -+
3827 -+ amd_pmu_wait_on_overflow(event->hw.idx);
3828 -+}
3829 -+
3830 -+/*
3831 -+ * Because of NMI latency, if multiple PMC counters are active or other sources
3832 -+ * of NMIs are received, the perf NMI handler can handle one or more overflowed
3833 -+ * PMC counters outside of the NMI associated with the PMC overflow. If the NMI
3834 -+ * doesn't arrive at the LAPIC in time to become a pending NMI, then the kernel
3835 -+ * back-to-back NMI support won't be active. This PMC handler needs to take into
3836 -+ * account that this can occur, otherwise this could result in unknown NMI
3837 -+ * messages being issued. Examples of this is PMC overflow while in the NMI
3838 -+ * handler when multiple PMCs are active or PMC overflow while handling some
3839 -+ * other source of an NMI.
3840 -+ *
3841 -+ * Attempt to mitigate this by using the number of active PMCs to determine
3842 -+ * whether to return NMI_HANDLED if the perf NMI handler did not handle/reset
3843 -+ * any PMCs. The per-CPU perf_nmi_counter variable is set to a minimum of the
3844 -+ * number of active PMCs or 2. The value of 2 is used in case an NMI does not
3845 -+ * arrive at the LAPIC in time to be collapsed into an already pending NMI.
3846 -+ */
3847 -+static int amd_pmu_handle_irq(struct pt_regs *regs)
3848 -+{
3849 -+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3850 -+ int active, handled;
3851 -+
3852 -+ /*
3853 -+ * Obtain the active count before calling x86_pmu_handle_irq() since
3854 -+ * it is possible that x86_pmu_handle_irq() may make a counter
3855 -+ * inactive (through x86_pmu_stop).
3856 -+ */
3857 -+ active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
3858 -+
3859 -+ /* Process any counter overflows */
3860 -+ handled = x86_pmu_handle_irq(regs);
3861 -+
3862 -+ /*
3863 -+ * If a counter was handled, record the number of possible remaining
3864 -+ * NMIs that can occur.
3865 -+ */
3866 -+ if (handled) {
3867 -+ this_cpu_write(perf_nmi_counter,
3868 -+ min_t(unsigned int, 2, active));
3869 -+
3870 -+ return handled;
3871 -+ }
3872 -+
3873 -+ if (!this_cpu_read(perf_nmi_counter))
3874 -+ return NMI_DONE;
3875 -+
3876 -+ this_cpu_dec(perf_nmi_counter);
3877 -+
3878 -+ return NMI_HANDLED;
3879 -+}
3880 -+
3881 - static struct event_constraint *
3882 - amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
3883 - struct perf_event *event)
3884 -@@ -621,11 +751,11 @@ static ssize_t amd_event_sysfs_show(char *page, u64 config)
3885 -
3886 - static __initconst const struct x86_pmu amd_pmu = {
3887 - .name = "AMD",
3888 -- .handle_irq = x86_pmu_handle_irq,
3889 -- .disable_all = x86_pmu_disable_all,
3890 -+ .handle_irq = amd_pmu_handle_irq,
3891 -+ .disable_all = amd_pmu_disable_all,
3892 - .enable_all = x86_pmu_enable_all,
3893 - .enable = x86_pmu_enable_event,
3894 -- .disable = x86_pmu_disable_event,
3895 -+ .disable = amd_pmu_disable_event,
3896 - .hw_config = amd_pmu_hw_config,
3897 - .schedule_events = x86_schedule_events,
3898 - .eventsel = MSR_K7_EVNTSEL0,
3899 -@@ -732,7 +862,7 @@ void amd_pmu_enable_virt(void)
3900 - cpuc->perf_ctr_virt_mask = 0;
3901 -
3902 - /* Reload all events */
3903 -- x86_pmu_disable_all();
3904 -+ amd_pmu_disable_all();
3905 - x86_pmu_enable_all(0);
3906 - }
3907 - EXPORT_SYMBOL_GPL(amd_pmu_enable_virt);
3908 -@@ -750,7 +880,7 @@ void amd_pmu_disable_virt(void)
3909 - cpuc->perf_ctr_virt_mask = AMD64_EVENTSEL_HOSTONLY;
3910 -
3911 - /* Reload all events */
3912 -- x86_pmu_disable_all();
3913 -+ amd_pmu_disable_all();
3914 - x86_pmu_enable_all(0);
3915 - }
3916 - EXPORT_SYMBOL_GPL(amd_pmu_disable_virt);
3917 -diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
3918 -index b684f0294f35..81911e11a15d 100644
3919 ---- a/arch/x86/events/core.c
3920 -+++ b/arch/x86/events/core.c
3921 -@@ -1349,8 +1349,9 @@ void x86_pmu_stop(struct perf_event *event, int flags)
3922 - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3923 - struct hw_perf_event *hwc = &event->hw;
3924 -
3925 -- if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) {
3926 -+ if (test_bit(hwc->idx, cpuc->active_mask)) {
3927 - x86_pmu.disable(event);
3928 -+ __clear_bit(hwc->idx, cpuc->active_mask);
3929 - cpuc->events[hwc->idx] = NULL;
3930 - WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
3931 - hwc->state |= PERF_HES_STOPPED;
3932 -@@ -1447,16 +1448,8 @@ int x86_pmu_handle_irq(struct pt_regs *regs)
3933 - apic_write(APIC_LVTPC, APIC_DM_NMI);
3934 -
3935 - for (idx = 0; idx < x86_pmu.num_counters; idx++) {
3936 -- if (!test_bit(idx, cpuc->active_mask)) {
3937 -- /*
3938 -- * Though we deactivated the counter some cpus
3939 -- * might still deliver spurious interrupts still
3940 -- * in flight. Catch them:
3941 -- */
3942 -- if (__test_and_clear_bit(idx, cpuc->running))
3943 -- handled++;
3944 -+ if (!test_bit(idx, cpuc->active_mask))
3945 - continue;
3946 -- }
3947 -
3948 - event = cpuc->events[idx];
3949 -
3950 -@@ -1995,7 +1988,7 @@ static int x86_pmu_commit_txn(struct pmu *pmu)
3951 - */
3952 - static void free_fake_cpuc(struct cpu_hw_events *cpuc)
3953 - {
3954 -- kfree(cpuc->shared_regs);
3955 -+ intel_cpuc_finish(cpuc);
3956 - kfree(cpuc);
3957 - }
3958 -
3959 -@@ -2007,14 +2000,11 @@ static struct cpu_hw_events *allocate_fake_cpuc(void)
3960 - cpuc = kzalloc(sizeof(*cpuc), GFP_KERNEL);
3961 - if (!cpuc)
3962 - return ERR_PTR(-ENOMEM);
3963 --
3964 -- /* only needed, if we have extra_regs */
3965 -- if (x86_pmu.extra_regs) {
3966 -- cpuc->shared_regs = allocate_shared_regs(cpu);
3967 -- if (!cpuc->shared_regs)
3968 -- goto error;
3969 -- }
3970 - cpuc->is_fake = 1;
3971 -+
3972 -+ if (intel_cpuc_prepare(cpuc, cpu))
3973 -+ goto error;
3974 -+
3975 - return cpuc;
3976 - error:
3977 - free_fake_cpuc(cpuc);
3978 -diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
3979 -index a01ef1b0f883..7cdd7b13bbda 100644
3980 ---- a/arch/x86/events/intel/bts.c
3981 -+++ b/arch/x86/events/intel/bts.c
3982 -@@ -77,10 +77,12 @@ static size_t buf_size(struct page *page)
3983 - }
3984 -
3985 - static void *
3986 --bts_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool overwrite)
3987 -+bts_buffer_setup_aux(struct perf_event *event, void **pages,
3988 -+ int nr_pages, bool overwrite)
3989 - {
3990 - struct bts_buffer *buf;
3991 - struct page *page;
3992 -+ int cpu = event->cpu;
3993 - int node = (cpu == -1) ? cpu : cpu_to_node(cpu);
3994 - unsigned long offset;
3995 - size_t size = nr_pages << PAGE_SHIFT;
3996 -diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
3997 -index 730978dff63f..2480feb07df3 100644
3998 ---- a/arch/x86/events/intel/core.c
3999 -+++ b/arch/x86/events/intel/core.c
4000 -@@ -1999,6 +1999,39 @@ static void intel_pmu_nhm_enable_all(int added)
4001 - intel_pmu_enable_all(added);
4002 - }
4003 -
4004 -+static void intel_set_tfa(struct cpu_hw_events *cpuc, bool on)
4005 -+{
4006 -+ u64 val = on ? MSR_TFA_RTM_FORCE_ABORT : 0;
4007 -+
4008 -+ if (cpuc->tfa_shadow != val) {
4009 -+ cpuc->tfa_shadow = val;
4010 -+ wrmsrl(MSR_TSX_FORCE_ABORT, val);
4011 -+ }
4012 -+}
4013 -+
4014 -+static void intel_tfa_commit_scheduling(struct cpu_hw_events *cpuc, int idx, int cntr)
4015 -+{
4016 -+ /*
4017 -+ * We're going to use PMC3, make sure TFA is set before we touch it.
4018 -+ */
4019 -+ if (cntr == 3 && !cpuc->is_fake)
4020 -+ intel_set_tfa(cpuc, true);
4021 -+}
4022 -+
4023 -+static void intel_tfa_pmu_enable_all(int added)
4024 -+{
4025 -+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
4026 -+
4027 -+ /*
4028 -+ * If we find PMC3 is no longer used when we enable the PMU, we can
4029 -+ * clear TFA.
4030 -+ */
4031 -+ if (!test_bit(3, cpuc->active_mask))
4032 -+ intel_set_tfa(cpuc, false);
4033 -+
4034 -+ intel_pmu_enable_all(added);
4035 -+}
4036 -+
4037 - static void enable_counter_freeze(void)
4038 - {
4039 - update_debugctlmsr(get_debugctlmsr() |
4040 -@@ -2768,6 +2801,35 @@ intel_stop_scheduling(struct cpu_hw_events *cpuc)
4041 - raw_spin_unlock(&excl_cntrs->lock);
4042 - }
4043 -
4044 -+static struct event_constraint *
4045 -+dyn_constraint(struct cpu_hw_events *cpuc, struct event_constraint *c, int idx)
4046 -+{
4047 -+ WARN_ON_ONCE(!cpuc->constraint_list);
4048 -+
4049 -+ if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
4050 -+ struct event_constraint *cx;
4051 -+
4052 -+ /*
4053 -+ * grab pre-allocated constraint entry
4054 -+ */
4055 -+ cx = &cpuc->constraint_list[idx];
4056 -+
4057 -+ /*
4058 -+ * initialize dynamic constraint
4059 -+ * with static constraint
4060 -+ */
4061 -+ *cx = *c;
4062 -+
4063 -+ /*
4064 -+ * mark constraint as dynamic
4065 -+ */
4066 -+ cx->flags |= PERF_X86_EVENT_DYNAMIC;
4067 -+ c = cx;
4068 -+ }
4069 -+
4070 -+ return c;
4071 -+}
4072 -+
4073 - static struct event_constraint *
4074 - intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
4075 - int idx, struct event_constraint *c)
4076 -@@ -2798,27 +2860,7 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
4077 - * only needed when constraint has not yet
4078 - * been cloned (marked dynamic)
4079 - */
4080 -- if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
4081 -- struct event_constraint *cx;
4082 --
4083 -- /*
4084 -- * grab pre-allocated constraint entry
4085 -- */
4086 -- cx = &cpuc->constraint_list[idx];
4087 --
4088 -- /*
4089 -- * initialize dynamic constraint
4090 -- * with static constraint
4091 -- */
4092 -- *cx = *c;
4093 --
4094 -- /*
4095 -- * mark constraint as dynamic, so we
4096 -- * can free it later on
4097 -- */
4098 -- cx->flags |= PERF_X86_EVENT_DYNAMIC;
4099 -- c = cx;
4100 -- }
4101 -+ c = dyn_constraint(cpuc, c, idx);
4102 -
4103 - /*
4104 - * From here on, the constraint is dynamic.
4105 -@@ -3345,6 +3387,26 @@ glp_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
4106 - return c;
4107 - }
4108 -
4109 -+static bool allow_tsx_force_abort = true;
4110 -+
4111 -+static struct event_constraint *
4112 -+tfa_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
4113 -+ struct perf_event *event)
4114 -+{
4115 -+ struct event_constraint *c = hsw_get_event_constraints(cpuc, idx, event);
4116 -+
4117 -+ /*
4118 -+ * Without TFA we must not use PMC3.
4119 -+ */
4120 -+ if (!allow_tsx_force_abort && test_bit(3, c->idxmsk) && idx >= 0) {
4121 -+ c = dyn_constraint(cpuc, c, idx);
4122 -+ c->idxmsk64 &= ~(1ULL << 3);
4123 -+ c->weight--;
4124 -+ }
4125 -+
4126 -+ return c;
4127 -+}
4128 -+
4129 - /*
4130 - * Broadwell:
4131 - *
4132 -@@ -3398,7 +3460,7 @@ ssize_t intel_event_sysfs_show(char *page, u64 config)
4133 - return x86_event_sysfs_show(page, config, event);
4134 - }
4135 -
4136 --struct intel_shared_regs *allocate_shared_regs(int cpu)
4137 -+static struct intel_shared_regs *allocate_shared_regs(int cpu)
4138 - {
4139 - struct intel_shared_regs *regs;
4140 - int i;
4141 -@@ -3430,23 +3492,24 @@ static struct intel_excl_cntrs *allocate_excl_cntrs(int cpu)
4142 - return c;
4143 - }
4144 -
4145 --static int intel_pmu_cpu_prepare(int cpu)
4146 --{
4147 -- struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
4148 -
4149 -+int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu)
4150 -+{
4151 - if (x86_pmu.extra_regs || x86_pmu.lbr_sel_map) {
4152 - cpuc->shared_regs = allocate_shared_regs(cpu);
4153 - if (!cpuc->shared_regs)
4154 - goto err;
4155 - }
4156 -
4157 -- if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
4158 -+ if (x86_pmu.flags & (PMU_FL_EXCL_CNTRS | PMU_FL_TFA)) {
4159 - size_t sz = X86_PMC_IDX_MAX * sizeof(struct event_constraint);
4160 -
4161 -- cpuc->constraint_list = kzalloc(sz, GFP_KERNEL);
4162 -+ cpuc->constraint_list = kzalloc_node(sz, GFP_KERNEL, cpu_to_node(cpu));
4163 - if (!cpuc->constraint_list)
4164 - goto err_shared_regs;
4165 -+ }
4166 -
4167 -+ if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
4168 - cpuc->excl_cntrs = allocate_excl_cntrs(cpu);
4169 - if (!cpuc->excl_cntrs)
4170 - goto err_constraint_list;
4171 -@@ -3468,6 +3531,11 @@ err:
4172 - return -ENOMEM;
4173 - }
4174 -
4175 -+static int intel_pmu_cpu_prepare(int cpu)
4176 -+{
4177 -+ return intel_cpuc_prepare(&per_cpu(cpu_hw_events, cpu), cpu);
4178 -+}
4179 -+
4180 - static void flip_smm_bit(void *data)
4181 - {
4182 - unsigned long set = *(unsigned long *)data;
4183 -@@ -3542,9 +3610,8 @@ static void intel_pmu_cpu_starting(int cpu)
4184 - }
4185 - }
4186 -
4187 --static void free_excl_cntrs(int cpu)
4188 -+static void free_excl_cntrs(struct cpu_hw_events *cpuc)
4189 - {
4190 -- struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
4191 - struct intel_excl_cntrs *c;
4192 -
4193 - c = cpuc->excl_cntrs;
4194 -@@ -3552,9 +3619,10 @@ static void free_excl_cntrs(int cpu)
4195 - if (c->core_id == -1 || --c->refcnt == 0)
4196 - kfree(c);
4197 - cpuc->excl_cntrs = NULL;
4198 -- kfree(cpuc->constraint_list);
4199 -- cpuc->constraint_list = NULL;
4200 - }
4201 -+
4202 -+ kfree(cpuc->constraint_list);
4203 -+ cpuc->constraint_list = NULL;
4204 - }
4205 -
4206 - static void intel_pmu_cpu_dying(int cpu)
4207 -@@ -3565,9 +3633,8 @@ static void intel_pmu_cpu_dying(int cpu)
4208 - disable_counter_freeze();
4209 - }
4210 -
4211 --static void intel_pmu_cpu_dead(int cpu)
4212 -+void intel_cpuc_finish(struct cpu_hw_events *cpuc)
4213 - {
4214 -- struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
4215 - struct intel_shared_regs *pc;
4216 -
4217 - pc = cpuc->shared_regs;
4218 -@@ -3577,7 +3644,12 @@ static void intel_pmu_cpu_dead(int cpu)
4219 - cpuc->shared_regs = NULL;
4220 - }
4221 -
4222 -- free_excl_cntrs(cpu);
4223 -+ free_excl_cntrs(cpuc);
4224 -+}
4225 -+
4226 -+static void intel_pmu_cpu_dead(int cpu)
4227 -+{
4228 -+ intel_cpuc_finish(&per_cpu(cpu_hw_events, cpu));
4229 - }
4230 -
4231 - static void intel_pmu_sched_task(struct perf_event_context *ctx,
4232 -@@ -4070,8 +4142,11 @@ static struct attribute *intel_pmu_caps_attrs[] = {
4233 - NULL
4234 - };
4235 -
4236 -+static DEVICE_BOOL_ATTR(allow_tsx_force_abort, 0644, allow_tsx_force_abort);
4237 -+
4238 - static struct attribute *intel_pmu_attrs[] = {
4239 - &dev_attr_freeze_on_smi.attr,
4240 -+ NULL, /* &dev_attr_allow_tsx_force_abort.attr.attr */
4241 - NULL,
4242 - };
4243 -
4244 -@@ -4564,6 +4639,15 @@ __init int intel_pmu_init(void)
4245 - tsx_attr = hsw_tsx_events_attrs;
4246 - intel_pmu_pebs_data_source_skl(
4247 - boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X);
4248 -+
4249 -+ if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) {
4250 -+ x86_pmu.flags |= PMU_FL_TFA;
4251 -+ x86_pmu.get_event_constraints = tfa_get_event_constraints;
4252 -+ x86_pmu.enable_all = intel_tfa_pmu_enable_all;
4253 -+ x86_pmu.commit_scheduling = intel_tfa_commit_scheduling;
4254 -+ intel_pmu_attrs[1] = &dev_attr_allow_tsx_force_abort.attr.attr;
4255 -+ }
4256 -+
4257 - pr_cont("Skylake events, ");
4258 - name = "skylake";
4259 - break;
4260 -@@ -4715,7 +4799,7 @@ static __init int fixup_ht_bug(void)
4261 - hardlockup_detector_perf_restart();
4262 -
4263 - for_each_online_cpu(c)
4264 -- free_excl_cntrs(c);
4265 -+ free_excl_cntrs(&per_cpu(cpu_hw_events, c));
4266 -
4267 - cpus_read_unlock();
4268 - pr_info("PMU erratum BJ122, BV98, HSD29 workaround disabled, HT off\n");
4269 -diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
4270 -index 9494ca68fd9d..c0e86ff21f81 100644
4271 ---- a/arch/x86/events/intel/pt.c
4272 -+++ b/arch/x86/events/intel/pt.c
4273 -@@ -1114,10 +1114,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages,
4274 - * Return: Our private PT buffer structure.
4275 - */
4276 - static void *
4277 --pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot)
4278 -+pt_buffer_setup_aux(struct perf_event *event, void **pages,
4279 -+ int nr_pages, bool snapshot)
4280 - {
4281 - struct pt_buffer *buf;
4282 -- int node, ret;
4283 -+ int node, ret, cpu = event->cpu;
4284 -
4285 - if (!nr_pages)
4286 - return NULL;
4287 -diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
4288 -index 27a461414b30..2690135bf83f 100644
4289 ---- a/arch/x86/events/intel/uncore.c
4290 -+++ b/arch/x86/events/intel/uncore.c
4291 -@@ -740,6 +740,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
4292 - /* fixed counters have event field hardcoded to zero */
4293 - hwc->config = 0ULL;
4294 - } else if (is_freerunning_event(event)) {
4295 -+ hwc->config = event->attr.config;
4296 - if (!check_valid_freerunning_event(box, event))
4297 - return -EINVAL;
4298 - event->hw.idx = UNCORE_PMC_IDX_FREERUNNING;
4299 -diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
4300 -index cb46d602a6b8..853a49a8ccf6 100644
4301 ---- a/arch/x86/events/intel/uncore.h
4302 -+++ b/arch/x86/events/intel/uncore.h
4303 -@@ -292,8 +292,8 @@ static inline
4304 - unsigned int uncore_freerunning_counter(struct intel_uncore_box *box,
4305 - struct perf_event *event)
4306 - {
4307 -- unsigned int type = uncore_freerunning_type(event->attr.config);
4308 -- unsigned int idx = uncore_freerunning_idx(event->attr.config);
4309 -+ unsigned int type = uncore_freerunning_type(event->hw.config);
4310 -+ unsigned int idx = uncore_freerunning_idx(event->hw.config);
4311 - struct intel_uncore_pmu *pmu = box->pmu;
4312 -
4313 - return pmu->type->freerunning[type].counter_base +
4314 -@@ -377,7 +377,7 @@ static inline
4315 - unsigned int uncore_freerunning_bits(struct intel_uncore_box *box,
4316 - struct perf_event *event)
4317 - {
4318 -- unsigned int type = uncore_freerunning_type(event->attr.config);
4319 -+ unsigned int type = uncore_freerunning_type(event->hw.config);
4320 -
4321 - return box->pmu->type->freerunning[type].bits;
4322 - }
4323 -@@ -385,7 +385,7 @@ unsigned int uncore_freerunning_bits(struct intel_uncore_box *box,
4324 - static inline int uncore_num_freerunning(struct intel_uncore_box *box,
4325 - struct perf_event *event)
4326 - {
4327 -- unsigned int type = uncore_freerunning_type(event->attr.config);
4328 -+ unsigned int type = uncore_freerunning_type(event->hw.config);
4329 -
4330 - return box->pmu->type->freerunning[type].num_counters;
4331 - }
4332 -@@ -399,8 +399,8 @@ static inline int uncore_num_freerunning_types(struct intel_uncore_box *box,
4333 - static inline bool check_valid_freerunning_event(struct intel_uncore_box *box,
4334 - struct perf_event *event)
4335 - {
4336 -- unsigned int type = uncore_freerunning_type(event->attr.config);
4337 -- unsigned int idx = uncore_freerunning_idx(event->attr.config);
4338 -+ unsigned int type = uncore_freerunning_type(event->hw.config);
4339 -+ unsigned int idx = uncore_freerunning_idx(event->hw.config);
4340 -
4341 - return (type < uncore_num_freerunning_types(box, event)) &&
4342 - (idx < uncore_num_freerunning(box, event));
4343 -diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c
4344 -index 2593b0d7aeee..ef7faf486a1a 100644
4345 ---- a/arch/x86/events/intel/uncore_snb.c
4346 -+++ b/arch/x86/events/intel/uncore_snb.c
4347 -@@ -448,9 +448,11 @@ static int snb_uncore_imc_event_init(struct perf_event *event)
4348 -
4349 - /* must be done before validate_group */
4350 - event->hw.event_base = base;
4351 -- event->hw.config = cfg;
4352 - event->hw.idx = idx;
4353 -
4354 -+ /* Convert to standard encoding format for freerunning counters */
4355 -+ event->hw.config = ((cfg - 1) << 8) | 0x10ff;
4356 -+
4357 - /* no group validation needed, we have free running counters */
4358 -
4359 - return 0;
4360 -diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
4361 -index d46fd6754d92..acd72e669c04 100644
4362 ---- a/arch/x86/events/perf_event.h
4363 -+++ b/arch/x86/events/perf_event.h
4364 -@@ -242,6 +242,11 @@ struct cpu_hw_events {
4365 - struct intel_excl_cntrs *excl_cntrs;
4366 - int excl_thread_id; /* 0 or 1 */
4367 -
4368 -+ /*
4369 -+ * SKL TSX_FORCE_ABORT shadow
4370 -+ */
4371 -+ u64 tfa_shadow;
4372 -+
4373 - /*
4374 - * AMD specific bits
4375 - */
4376 -@@ -681,6 +686,7 @@ do { \
4377 - #define PMU_FL_EXCL_CNTRS 0x4 /* has exclusive counter requirements */
4378 - #define PMU_FL_EXCL_ENABLED 0x8 /* exclusive counter active */
4379 - #define PMU_FL_PEBS_ALL 0x10 /* all events are valid PEBS events */
4380 -+#define PMU_FL_TFA 0x20 /* deal with TSX force abort */
4381 -
4382 - #define EVENT_VAR(_id) event_attr_##_id
4383 - #define EVENT_PTR(_id) &event_attr_##_id.attr.attr
4384 -@@ -889,7 +895,8 @@ struct event_constraint *
4385 - x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
4386 - struct perf_event *event);
4387 -
4388 --struct intel_shared_regs *allocate_shared_regs(int cpu);
4389 -+extern int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu);
4390 -+extern void intel_cpuc_finish(struct cpu_hw_events *cpuc);
4391 -
4392 - int intel_pmu_init(void);
4393 -
4394 -@@ -1025,9 +1032,13 @@ static inline int intel_pmu_init(void)
4395 - return 0;
4396 - }
4397 -
4398 --static inline struct intel_shared_regs *allocate_shared_regs(int cpu)
4399 -+static inline int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu)
4400 -+{
4401 -+ return 0;
4402 -+}
4403 -+
4404 -+static inline void intel_cpuc_finish(struct cpu_hw_events *cpuc)
4405 - {
4406 -- return NULL;
4407 - }
4408 -
4409 - static inline int is_ht_workaround_enabled(void)
4410 -diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
4411 -index 7abb09e2eeb8..d3f42b6bbdac 100644
4412 ---- a/arch/x86/hyperv/hv_init.c
4413 -+++ b/arch/x86/hyperv/hv_init.c
4414 -@@ -406,6 +406,13 @@ void hyperv_cleanup(void)
4415 - /* Reset our OS id */
4416 - wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
4417 -
4418 -+ /*
4419 -+ * Reset hypercall page reference before reset the page,
4420 -+ * let hypercall operations fail safely rather than
4421 -+ * panic the kernel for using invalid hypercall page
4422 -+ */
4423 -+ hv_hypercall_pg = NULL;
4424 -+
4425 - /* Reset the hypercall page */
4426 - hypercall_msr.as_uint64 = 0;
4427 - wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
4428 -diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
4429 -index ad7b210aa3f6..8e790ec219a5 100644
4430 ---- a/arch/x86/include/asm/bitops.h
4431 -+++ b/arch/x86/include/asm/bitops.h
4432 -@@ -36,22 +36,17 @@
4433 - * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
4434 - */
4435 -
4436 --#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
4437 --/* Technically wrong, but this avoids compilation errors on some gcc
4438 -- versions. */
4439 --#define BITOP_ADDR(x) "=m" (*(volatile long *) (x))
4440 --#else
4441 --#define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
4442 --#endif
4443 -+#define RLONG_ADDR(x) "m" (*(volatile long *) (x))
4444 -+#define WBYTE_ADDR(x) "+m" (*(volatile char *) (x))
4445 -
4446 --#define ADDR BITOP_ADDR(addr)
4447 -+#define ADDR RLONG_ADDR(addr)
4448 -
4449 - /*
4450 - * We do the locked ops that don't return the old value as
4451 - * a mask operation on a byte.
4452 - */
4453 - #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
4454 --#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
4455 -+#define CONST_MASK_ADDR(nr, addr) WBYTE_ADDR((void *)(addr) + ((nr)>>3))
4456 - #define CONST_MASK(nr) (1 << ((nr) & 7))
4457 -
4458 - /**
4459 -@@ -79,7 +74,7 @@ set_bit(long nr, volatile unsigned long *addr)
4460 - : "memory");
4461 - } else {
4462 - asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
4463 -- : BITOP_ADDR(addr) : "Ir" (nr) : "memory");
4464 -+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
4465 - }
4466 - }
4467 -
4468 -@@ -94,7 +89,7 @@ set_bit(long nr, volatile unsigned long *addr)
4469 - */
4470 - static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
4471 - {
4472 -- asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory");
4473 -+ asm volatile(__ASM_SIZE(bts) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
4474 - }
4475 -
4476 - /**
4477 -@@ -116,8 +111,7 @@ clear_bit(long nr, volatile unsigned long *addr)
4478 - : "iq" ((u8)~CONST_MASK(nr)));
4479 - } else {
4480 - asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
4481 -- : BITOP_ADDR(addr)
4482 -- : "Ir" (nr));
4483 -+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
4484 - }
4485 - }
4486 -
4487 -@@ -137,7 +131,7 @@ static __always_inline void clear_bit_unlock(long nr, volatile unsigned long *ad
4488 -
4489 - static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)
4490 - {
4491 -- asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr));
4492 -+ asm volatile(__ASM_SIZE(btr) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
4493 - }
4494 -
4495 - static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr)
4496 -@@ -145,7 +139,7 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile
4497 - bool negative;
4498 - asm volatile(LOCK_PREFIX "andb %2,%1"
4499 - CC_SET(s)
4500 -- : CC_OUT(s) (negative), ADDR
4501 -+ : CC_OUT(s) (negative), WBYTE_ADDR(addr)
4502 - : "ir" ((char) ~(1 << nr)) : "memory");
4503 - return negative;
4504 - }
4505 -@@ -161,13 +155,9 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile
4506 - * __clear_bit() is non-atomic and implies release semantics before the memory
4507 - * operation. It can be used for an unlock if no other CPUs can concurrently
4508 - * modify other bits in the word.
4509 -- *
4510 -- * No memory barrier is required here, because x86 cannot reorder stores past
4511 -- * older loads. Same principle as spin_unlock.
4512 - */
4513 - static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *addr)
4514 - {
4515 -- barrier();
4516 - __clear_bit(nr, addr);
4517 - }
4518 -
4519 -@@ -182,7 +172,7 @@ static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *
4520 - */
4521 - static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
4522 - {
4523 -- asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr));
4524 -+ asm volatile(__ASM_SIZE(btc) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
4525 - }
4526 -
4527 - /**
4528 -@@ -202,8 +192,7 @@ static __always_inline void change_bit(long nr, volatile unsigned long *addr)
4529 - : "iq" ((u8)CONST_MASK(nr)));
4530 - } else {
4531 - asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
4532 -- : BITOP_ADDR(addr)
4533 -- : "Ir" (nr));
4534 -+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
4535 - }
4536 - }
4537 -
4538 -@@ -248,8 +237,8 @@ static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long *
4539 -
4540 - asm(__ASM_SIZE(bts) " %2,%1"
4541 - CC_SET(c)
4542 -- : CC_OUT(c) (oldbit), ADDR
4543 -- : "Ir" (nr));
4544 -+ : CC_OUT(c) (oldbit)
4545 -+ : ADDR, "Ir" (nr) : "memory");
4546 - return oldbit;
4547 - }
4548 -
4549 -@@ -288,8 +277,8 @@ static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long
4550 -
4551 - asm volatile(__ASM_SIZE(btr) " %2,%1"
4552 - CC_SET(c)
4553 -- : CC_OUT(c) (oldbit), ADDR
4554 -- : "Ir" (nr));
4555 -+ : CC_OUT(c) (oldbit)
4556 -+ : ADDR, "Ir" (nr) : "memory");
4557 - return oldbit;
4558 - }
4559 -
4560 -@@ -300,8 +289,8 @@ static __always_inline bool __test_and_change_bit(long nr, volatile unsigned lon
4561 -
4562 - asm volatile(__ASM_SIZE(btc) " %2,%1"
4563 - CC_SET(c)
4564 -- : CC_OUT(c) (oldbit), ADDR
4565 -- : "Ir" (nr) : "memory");
4566 -+ : CC_OUT(c) (oldbit)
4567 -+ : ADDR, "Ir" (nr) : "memory");
4568 -
4569 - return oldbit;
4570 - }
4571 -@@ -332,7 +321,7 @@ static __always_inline bool variable_test_bit(long nr, volatile const unsigned l
4572 - asm volatile(__ASM_SIZE(bt) " %2,%1"
4573 - CC_SET(c)
4574 - : CC_OUT(c) (oldbit)
4575 -- : "m" (*(unsigned long *)addr), "Ir" (nr));
4576 -+ : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory");
4577 -
4578 - return oldbit;
4579 - }
4580 -diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
4581 -index 6d6122524711..981ff9479648 100644
4582 ---- a/arch/x86/include/asm/cpufeatures.h
4583 -+++ b/arch/x86/include/asm/cpufeatures.h
4584 -@@ -344,6 +344,7 @@
4585 - /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
4586 - #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
4587 - #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
4588 -+#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
4589 - #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
4590 - #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
4591 - #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
4592 -diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
4593 -index 180373360e34..71d763ad2637 100644
4594 ---- a/arch/x86/include/asm/kvm_host.h
4595 -+++ b/arch/x86/include/asm/kvm_host.h
4596 -@@ -352,6 +352,7 @@ struct kvm_mmu_page {
4597 - };
4598 -
4599 - struct kvm_pio_request {
4600 -+ unsigned long linear_rip;
4601 - unsigned long count;
4602 - int in;
4603 - int port;
4604 -@@ -570,6 +571,7 @@ struct kvm_vcpu_arch {
4605 - bool tpr_access_reporting;
4606 - u64 ia32_xss;
4607 - u64 microcode_version;
4608 -+ u64 arch_capabilities;
4609 -
4610 - /*
4611 - * Paging state of the vcpu
4612 -@@ -1255,7 +1257,7 @@ void kvm_mmu_clear_dirty_pt_masked(struct kvm *kvm,
4613 - struct kvm_memory_slot *slot,
4614 - gfn_t gfn_offset, unsigned long mask);
4615 - void kvm_mmu_zap_all(struct kvm *kvm);
4616 --void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, struct kvm_memslots *slots);
4617 -+void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);
4618 - unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
4619 - void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
4620 -
4621 -diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
4622 -index 8e40c2446fd1..ca5bc0eacb95 100644
4623 ---- a/arch/x86/include/asm/msr-index.h
4624 -+++ b/arch/x86/include/asm/msr-index.h
4625 -@@ -666,6 +666,12 @@
4626 -
4627 - #define MSR_IA32_TSC_DEADLINE 0x000006E0
4628 -
4629 -+
4630 -+#define MSR_TSX_FORCE_ABORT 0x0000010F
4631 -+
4632 -+#define MSR_TFA_RTM_FORCE_ABORT_BIT 0
4633 -+#define MSR_TFA_RTM_FORCE_ABORT BIT_ULL(MSR_TFA_RTM_FORCE_ABORT_BIT)
4634 -+
4635 - /* P4/Xeon+ specific */
4636 - #define MSR_IA32_MCG_EAX 0x00000180
4637 - #define MSR_IA32_MCG_EBX 0x00000181
4638 -diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
4639 -index 55d392c6bd29..2fd165f1cffa 100644
4640 ---- a/arch/x86/include/asm/string_32.h
4641 -+++ b/arch/x86/include/asm/string_32.h
4642 -@@ -179,14 +179,7 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)
4643 - * No 3D Now!
4644 - */
4645 -
4646 --#if (__GNUC__ >= 4)
4647 - #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
4648 --#else
4649 --#define memcpy(t, f, n) \
4650 -- (__builtin_constant_p((n)) \
4651 -- ? __constant_memcpy((t), (f), (n)) \
4652 -- : __memcpy((t), (f), (n)))
4653 --#endif
4654 -
4655 - #endif
4656 - #endif /* !CONFIG_FORTIFY_SOURCE */
4657 -@@ -282,12 +275,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
4658 -
4659 - {
4660 - int d0, d1;
4661 --#if __GNUC__ == 4 && __GNUC_MINOR__ == 0
4662 -- /* Workaround for broken gcc 4.0 */
4663 -- register unsigned long eax asm("%eax") = pattern;
4664 --#else
4665 - unsigned long eax = pattern;
4666 --#endif
4667 -
4668 - switch (count % 4) {
4669 - case 0:
4670 -@@ -321,15 +309,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
4671 - #define __HAVE_ARCH_MEMSET
4672 - extern void *memset(void *, int, size_t);
4673 - #ifndef CONFIG_FORTIFY_SOURCE
4674 --#if (__GNUC__ >= 4)
4675 - #define memset(s, c, count) __builtin_memset(s, c, count)
4676 --#else
4677 --#define memset(s, c, count) \
4678 -- (__builtin_constant_p(c) \
4679 -- ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \
4680 -- (count)) \
4681 -- : __memset((s), (c), (count)))
4682 --#endif
4683 - #endif /* !CONFIG_FORTIFY_SOURCE */
4684 -
4685 - #define __HAVE_ARCH_MEMSET16
4686 -diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h
4687 -index 4e4194e21a09..75314c3dbe47 100644
4688 ---- a/arch/x86/include/asm/string_64.h
4689 -+++ b/arch/x86/include/asm/string_64.h
4690 -@@ -14,21 +14,6 @@
4691 - extern void *memcpy(void *to, const void *from, size_t len);
4692 - extern void *__memcpy(void *to, const void *from, size_t len);
4693 -
4694 --#ifndef CONFIG_FORTIFY_SOURCE
4695 --#if (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || __GNUC__ < 4
4696 --#define memcpy(dst, src, len) \
4697 --({ \
4698 -- size_t __len = (len); \
4699 -- void *__ret; \
4700 -- if (__builtin_constant_p(len) && __len >= 64) \
4701 -- __ret = __memcpy((dst), (src), __len); \
4702 -- else \
4703 -- __ret = __builtin_memcpy((dst), (src), __len); \
4704 -- __ret; \
4705 --})
4706 --#endif
4707 --#endif /* !CONFIG_FORTIFY_SOURCE */
4708 --
4709 - #define __HAVE_ARCH_MEMSET
4710 - void *memset(void *s, int c, size_t n);
4711 - void *__memset(void *s, int c, size_t n);
4712 -diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
4713 -index c1334aaaa78d..f3aed639dccd 100644
4714 ---- a/arch/x86/include/asm/uaccess.h
4715 -+++ b/arch/x86/include/asm/uaccess.h
4716 -@@ -76,7 +76,7 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
4717 - #endif
4718 -
4719 - /**
4720 -- * access_ok: - Checks if a user space pointer is valid
4721 -+ * access_ok - Checks if a user space pointer is valid
4722 - * @addr: User space pointer to start of block to check
4723 - * @size: Size of block to check
4724 - *
4725 -@@ -85,12 +85,12 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
4726 - *
4727 - * Checks if a pointer to a block of memory in user space is valid.
4728 - *
4729 -- * Returns true (nonzero) if the memory block may be valid, false (zero)
4730 -- * if it is definitely invalid.
4731 -- *
4732 - * Note that, depending on architecture, this function probably just
4733 - * checks that the pointer is in the user space range - after calling
4734 - * this function, memory access functions may still return -EFAULT.
4735 -+ *
4736 -+ * Return: true (nonzero) if the memory block may be valid, false (zero)
4737 -+ * if it is definitely invalid.
4738 - */
4739 - #define access_ok(addr, size) \
4740 - ({ \
4741 -@@ -135,7 +135,7 @@ extern int __get_user_bad(void);
4742 - __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
4743 -
4744 - /**
4745 -- * get_user: - Get a simple variable from user space.
4746 -+ * get_user - Get a simple variable from user space.
4747 - * @x: Variable to store result.
4748 - * @ptr: Source address, in user space.
4749 - *
4750 -@@ -149,7 +149,7 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
4751 - * @ptr must have pointer-to-simple-variable type, and the result of
4752 - * dereferencing @ptr must be assignable to @x without a cast.
4753 - *
4754 -- * Returns zero on success, or -EFAULT on error.
4755 -+ * Return: zero on success, or -EFAULT on error.
4756 - * On error, the variable @x is set to zero.
4757 - */
4758 - /*
4759 -@@ -227,7 +227,7 @@ extern void __put_user_4(void);
4760 - extern void __put_user_8(void);
4761 -
4762 - /**
4763 -- * put_user: - Write a simple value into user space.
4764 -+ * put_user - Write a simple value into user space.
4765 - * @x: Value to copy to user space.
4766 - * @ptr: Destination address, in user space.
4767 - *
4768 -@@ -241,7 +241,7 @@ extern void __put_user_8(void);
4769 - * @ptr must have pointer-to-simple-variable type, and @x must be assignable
4770 - * to the result of dereferencing @ptr.
4771 - *
4772 -- * Returns zero on success, or -EFAULT on error.
4773 -+ * Return: zero on success, or -EFAULT on error.
4774 - */
4775 - #define put_user(x, ptr) \
4776 - ({ \
4777 -@@ -503,7 +503,7 @@ struct __large_struct { unsigned long buf[100]; };
4778 - } while (0)
4779 -
4780 - /**
4781 -- * __get_user: - Get a simple variable from user space, with less checking.
4782 -+ * __get_user - Get a simple variable from user space, with less checking.
4783 - * @x: Variable to store result.
4784 - * @ptr: Source address, in user space.
4785 - *
4786 -@@ -520,7 +520,7 @@ struct __large_struct { unsigned long buf[100]; };
4787 - * Caller must check the pointer with access_ok() before calling this
4788 - * function.
4789 - *
4790 -- * Returns zero on success, or -EFAULT on error.
4791 -+ * Return: zero on success, or -EFAULT on error.
4792 - * On error, the variable @x is set to zero.
4793 - */
4794 -
4795 -@@ -528,7 +528,7 @@ struct __large_struct { unsigned long buf[100]; };
4796 - __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
4797 -
4798 - /**
4799 -- * __put_user: - Write a simple value into user space, with less checking.
4800 -+ * __put_user - Write a simple value into user space, with less checking.
4801 - * @x: Value to copy to user space.
4802 - * @ptr: Destination address, in user space.
4803 - *
4804 -@@ -545,7 +545,7 @@ struct __large_struct { unsigned long buf[100]; };
4805 - * Caller must check the pointer with access_ok() before calling this
4806 - * function.
4807 - *
4808 -- * Returns zero on success, or -EFAULT on error.
4809 -+ * Return: zero on success, or -EFAULT on error.
4810 - */
4811 -
4812 - #define __put_user(x, ptr) \
4813 -diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
4814 -index 1f86e1b0a5cd..499578f7e6d7 100644
4815 ---- a/arch/x86/include/asm/unwind.h
4816 -+++ b/arch/x86/include/asm/unwind.h
4817 -@@ -23,6 +23,12 @@ struct unwind_state {
4818 - #elif defined(CONFIG_UNWINDER_FRAME_POINTER)
4819 - bool got_irq;
4820 - unsigned long *bp, *orig_sp, ip;
4821 -+ /*
4822 -+ * If non-NULL: The current frame is incomplete and doesn't contain a
4823 -+ * valid BP. When looking for the next frame, use this instead of the
4824 -+ * non-existent saved BP.
4825 -+ */
4826 -+ unsigned long *next_bp;
4827 - struct pt_regs *regs;
4828 - #else
4829 - unsigned long *sp;
4830 -diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
4831 -index ef05bea7010d..6b5c710846f5 100644
4832 ---- a/arch/x86/include/asm/xen/hypercall.h
4833 -+++ b/arch/x86/include/asm/xen/hypercall.h
4834 -@@ -206,6 +206,9 @@ xen_single_call(unsigned int call,
4835 - __HYPERCALL_DECLS;
4836 - __HYPERCALL_5ARG(a1, a2, a3, a4, a5);
4837 -
4838 -+ if (call >= PAGE_SIZE / sizeof(hypercall_page[0]))
4839 -+ return -EINVAL;
4840 -+
4841 - asm volatile(CALL_NOSPEC
4842 - : __HYPERCALL_5PARAM
4843 - : [thunk_target] "a" (&hypercall_page[call])
4844 -diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
4845 -index 69f6bbb41be0..01004bfb1a1b 100644
4846 ---- a/arch/x86/kernel/cpu/amd.c
4847 -+++ b/arch/x86/kernel/cpu/amd.c
4848 -@@ -819,11 +819,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c)
4849 - static void init_amd_zn(struct cpuinfo_x86 *c)
4850 - {
4851 - set_cpu_cap(c, X86_FEATURE_ZEN);
4852 -- /*
4853 -- * Fix erratum 1076: CPB feature bit not being set in CPUID. It affects
4854 -- * all up to and including B1.
4855 -- */
4856 -- if (c->x86_model <= 1 && c->x86_stepping <= 1)
4857 -+
4858 -+ /* Fix erratum 1076: CPB feature bit not being set in CPUID. */
4859 -+ if (!cpu_has(c, X86_FEATURE_CPB))
4860 - set_cpu_cap(c, X86_FEATURE_CPB);
4861 - }
4862 -
4863 -diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
4864 -index 8257a59704ae..763d4264d16a 100644
4865 ---- a/arch/x86/kernel/ftrace.c
4866 -+++ b/arch/x86/kernel/ftrace.c
4867 -@@ -49,7 +49,7 @@ int ftrace_arch_code_modify_post_process(void)
4868 - union ftrace_code_union {
4869 - char code[MCOUNT_INSN_SIZE];
4870 - struct {
4871 -- unsigned char e8;
4872 -+ unsigned char op;
4873 - int offset;
4874 - } __attribute__((packed));
4875 - };
4876 -@@ -59,20 +59,23 @@ static int ftrace_calc_offset(long ip, long addr)
4877 - return (int)(addr - ip);
4878 - }
4879 -
4880 --static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
4881 -+static unsigned char *
4882 -+ftrace_text_replace(unsigned char op, unsigned long ip, unsigned long addr)
4883 - {
4884 - static union ftrace_code_union calc;
4885 -
4886 -- calc.e8 = 0xe8;
4887 -+ calc.op = op;
4888 - calc.offset = ftrace_calc_offset(ip + MCOUNT_INSN_SIZE, addr);
4889 -
4890 -- /*
4891 -- * No locking needed, this must be called via kstop_machine
4892 -- * which in essence is like running on a uniprocessor machine.
4893 -- */
4894 - return calc.code;
4895 - }
4896 -
4897 -+static unsigned char *
4898 -+ftrace_call_replace(unsigned long ip, unsigned long addr)
4899 -+{
4900 -+ return ftrace_text_replace(0xe8, ip, addr);
4901 -+}
4902 -+
4903 - static inline int
4904 - within(unsigned long addr, unsigned long start, unsigned long end)
4905 - {
4906 -@@ -664,22 +667,6 @@ int __init ftrace_dyn_arch_init(void)
4907 - return 0;
4908 - }
4909 -
4910 --#if defined(CONFIG_X86_64) || defined(CONFIG_FUNCTION_GRAPH_TRACER)
4911 --static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
4912 --{
4913 -- static union ftrace_code_union calc;
4914 --
4915 -- /* Jmp not a call (ignore the .e8) */
4916 -- calc.e8 = 0xe9;
4917 -- calc.offset = ftrace_calc_offset(ip + MCOUNT_INSN_SIZE, addr);
4918 --
4919 -- /*
4920 -- * ftrace external locks synchronize the access to the static variable.
4921 -- */
4922 -- return calc.code;
4923 --}
4924 --#endif
4925 --
4926 - /* Currently only x86_64 supports dynamic trampolines */
4927 - #ifdef CONFIG_X86_64
4928 -
4929 -@@ -891,8 +878,8 @@ static void *addr_from_call(void *ptr)
4930 - return NULL;
4931 -
4932 - /* Make sure this is a call */
4933 -- if (WARN_ON_ONCE(calc.e8 != 0xe8)) {
4934 -- pr_warn("Expected e8, got %x\n", calc.e8);
4935 -+ if (WARN_ON_ONCE(calc.op != 0xe8)) {
4936 -+ pr_warn("Expected e8, got %x\n", calc.op);
4937 - return NULL;
4938 - }
4939 -
4940 -@@ -963,6 +950,11 @@ void arch_ftrace_trampoline_free(struct ftrace_ops *ops)
4941 - #ifdef CONFIG_DYNAMIC_FTRACE
4942 - extern void ftrace_graph_call(void);
4943 -
4944 -+static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
4945 -+{
4946 -+ return ftrace_text_replace(0xe9, ip, addr);
4947 -+}
4948 -+
4949 - static int ftrace_mod_jmp(unsigned long ip, void *func)
4950 - {
4951 - unsigned char *new;
4952 -diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
4953 -index 53917a3ebf94..1f3b77367948 100644
4954 ---- a/arch/x86/kernel/kexec-bzimage64.c
4955 -+++ b/arch/x86/kernel/kexec-bzimage64.c
4956 -@@ -218,6 +218,9 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
4957 - params->screen_info.ext_mem_k = 0;
4958 - params->alt_mem_k = 0;
4959 -
4960 -+ /* Always fill in RSDP: it is either 0 or a valid value */
4961 -+ params->acpi_rsdp_addr = boot_params.acpi_rsdp_addr;
4962 -+
4963 - /* Default APM info */
4964 - memset(&params->apm_bios_info, 0, sizeof(params->apm_bios_info));
4965 -
4966 -@@ -256,7 +259,6 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
4967 - setup_efi_state(params, params_load_addr, efi_map_offset, efi_map_sz,
4968 - efi_setup_data_offset);
4969 - #endif
4970 --
4971 - /* Setup EDD info */
4972 - memcpy(params->eddbuf, boot_params.eddbuf,
4973 - EDDMAXNR * sizeof(struct edd_info));
4974 -diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
4975 -index 6adf6e6c2933..544bd41a514c 100644
4976 ---- a/arch/x86/kernel/kprobes/opt.c
4977 -+++ b/arch/x86/kernel/kprobes/opt.c
4978 -@@ -141,6 +141,11 @@ asm (
4979 -
4980 - void optprobe_template_func(void);
4981 - STACK_FRAME_NON_STANDARD(optprobe_template_func);
4982 -+NOKPROBE_SYMBOL(optprobe_template_func);
4983 -+NOKPROBE_SYMBOL(optprobe_template_entry);
4984 -+NOKPROBE_SYMBOL(optprobe_template_val);
4985 -+NOKPROBE_SYMBOL(optprobe_template_call);
4986 -+NOKPROBE_SYMBOL(optprobe_template_end);
4987 -
4988 - #define TMPL_MOVE_IDX \
4989 - ((long)optprobe_template_val - (long)optprobe_template_entry)
4990 -diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
4991 -index e811d4d1c824..d908a37bf3f3 100644
4992 ---- a/arch/x86/kernel/kvmclock.c
4993 -+++ b/arch/x86/kernel/kvmclock.c
4994 -@@ -104,12 +104,8 @@ static u64 kvm_sched_clock_read(void)
4995 -
4996 - static inline void kvm_sched_clock_init(bool stable)
4997 - {
4998 -- if (!stable) {
4999 -- pv_ops.time.sched_clock = kvm_clock_read;
5000 -+ if (!stable)
5001 - clear_sched_clock_stable();
5002 -- return;
5003 -- }
5004 --
5005 - kvm_sched_clock_offset = kvm_clock_read();
5006 - pv_ops.time.sched_clock = kvm_sched_clock_read;
5007 -
5008 -diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
5009 -index 3dc26f95d46e..9b9fd4826e7a 100644
5010 ---- a/arch/x86/kernel/unwind_frame.c
5011 -+++ b/arch/x86/kernel/unwind_frame.c
5012 -@@ -320,10 +320,14 @@ bool unwind_next_frame(struct unwind_state *state)
5013 - }
5014 -
5015 - /* Get the next frame pointer: */
5016 -- if (state->regs)
5017 -+ if (state->next_bp) {
5018 -+ next_bp = state->next_bp;
5019 -+ state->next_bp = NULL;
5020 -+ } else if (state->regs) {
5021 - next_bp = (unsigned long *)state->regs->bp;
5022 -- else
5023 -+ } else {
5024 - next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task, *state->bp);
5025 -+ }
5026 -
5027 - /* Move to the next frame if it's safe: */
5028 - if (!update_stack_state(state, next_bp))
5029 -@@ -398,6 +402,21 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
5030 -
5031 - bp = get_frame_pointer(task, regs);
5032 -
5033 -+ /*
5034 -+ * If we crash with IP==0, the last successfully executed instruction
5035 -+ * was probably an indirect function call with a NULL function pointer.
5036 -+ * That means that SP points into the middle of an incomplete frame:
5037 -+ * *SP is a return pointer, and *(SP-sizeof(unsigned long)) is where we
5038 -+ * would have written a frame pointer if we hadn't crashed.
5039 -+ * Pretend that the frame is complete and that BP points to it, but save
5040 -+ * the real BP so that we can use it when looking for the next frame.
5041 -+ */
5042 -+ if (regs && regs->ip == 0 &&
5043 -+ (unsigned long *)kernel_stack_pointer(regs) >= first_frame) {
5044 -+ state->next_bp = bp;
5045 -+ bp = ((unsigned long *)kernel_stack_pointer(regs)) - 1;
5046 -+ }
5047 -+
5048 - /* Initialize stack info and make sure the frame data is accessible: */
5049 - get_stack_info(bp, state->task, &state->stack_info,
5050 - &state->stack_mask);
5051 -@@ -410,7 +429,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
5052 - */
5053 - while (!unwind_done(state) &&
5054 - (!on_stack(&state->stack_info, first_frame, sizeof(long)) ||
5055 -- state->bp < first_frame))
5056 -+ (state->next_bp == NULL && state->bp < first_frame)))
5057 - unwind_next_frame(state);
5058 - }
5059 - EXPORT_SYMBOL_GPL(__unwind_start);
5060 -diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
5061 -index 26038eacf74a..89be1be1790c 100644
5062 ---- a/arch/x86/kernel/unwind_orc.c
5063 -+++ b/arch/x86/kernel/unwind_orc.c
5064 -@@ -113,6 +113,20 @@ static struct orc_entry *orc_ftrace_find(unsigned long ip)
5065 - }
5066 - #endif
5067 -
5068 -+/*
5069 -+ * If we crash with IP==0, the last successfully executed instruction
5070 -+ * was probably an indirect function call with a NULL function pointer,
5071 -+ * and we don't have unwind information for NULL.
5072 -+ * This hardcoded ORC entry for IP==0 allows us to unwind from a NULL function
5073 -+ * pointer into its parent and then continue normally from there.
5074 -+ */
5075 -+static struct orc_entry null_orc_entry = {
5076 -+ .sp_offset = sizeof(long),
5077 -+ .sp_reg = ORC_REG_SP,
5078 -+ .bp_reg = ORC_REG_UNDEFINED,
5079 -+ .type = ORC_TYPE_CALL
5080 -+};
5081 -+
5082 - static struct orc_entry *orc_find(unsigned long ip)
5083 - {
5084 - static struct orc_entry *orc;
5085 -@@ -120,6 +134,9 @@ static struct orc_entry *orc_find(unsigned long ip)
5086 - if (!orc_init)
5087 - return NULL;
5088 -
5089 -+ if (ip == 0)
5090 -+ return &null_orc_entry;
5091 -+
5092 - /* For non-init vmlinux addresses, use the fast lookup table: */
5093 - if (ip >= LOOKUP_START_IP && ip < LOOKUP_STOP_IP) {
5094 - unsigned int idx, start, stop;
5095 -diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
5096 -index 0d618ee634ac..ee3b5c7d662e 100644
5097 ---- a/arch/x86/kernel/vmlinux.lds.S
5098 -+++ b/arch/x86/kernel/vmlinux.lds.S
5099 -@@ -401,7 +401,7 @@ SECTIONS
5100 - * Per-cpu symbols which need to be offset from __per_cpu_load
5101 - * for the boot processor.
5102 - */
5103 --#define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
5104 -+#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load
5105 - INIT_PER_CPU(gdt_page);
5106 - INIT_PER_CPU(irq_stack_union);
5107 -
5108 -diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
5109 -index f2d1d230d5b8..9ab33cab9486 100644
5110 ---- a/arch/x86/kvm/mmu.c
5111 -+++ b/arch/x86/kvm/mmu.c
5112 -@@ -5635,13 +5635,8 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end)
5113 - {
5114 - struct kvm_memslots *slots;
5115 - struct kvm_memory_slot *memslot;
5116 -- bool flush_tlb = true;
5117 -- bool flush = false;
5118 - int i;
5119 -
5120 -- if (kvm_available_flush_tlb_with_range())
5121 -- flush_tlb = false;
5122 --
5123 - spin_lock(&kvm->mmu_lock);
5124 - for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
5125 - slots = __kvm_memslots(kvm, i);
5126 -@@ -5653,17 +5648,12 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end)
5127 - if (start >= end)
5128 - continue;
5129 -
5130 -- flush |= slot_handle_level_range(kvm, memslot,
5131 -- kvm_zap_rmapp, PT_PAGE_TABLE_LEVEL,
5132 -- PT_MAX_HUGEPAGE_LEVEL, start,
5133 -- end - 1, flush_tlb);
5134 -+ slot_handle_level_range(kvm, memslot, kvm_zap_rmapp,
5135 -+ PT_PAGE_TABLE_LEVEL, PT_MAX_HUGEPAGE_LEVEL,
5136 -+ start, end - 1, true);
5137 - }
5138 - }
5139 -
5140 -- if (flush)
5141 -- kvm_flush_remote_tlbs_with_address(kvm, gfn_start,
5142 -- gfn_end - gfn_start + 1);
5143 --
5144 - spin_unlock(&kvm->mmu_lock);
5145 - }
5146 -
5147 -@@ -5901,13 +5891,30 @@ static bool kvm_has_zapped_obsolete_pages(struct kvm *kvm)
5148 - return unlikely(!list_empty_careful(&kvm->arch.zapped_obsolete_pages));
5149 - }
5150 -
5151 --void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, struct kvm_memslots *slots)
5152 -+void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen)
5153 - {
5154 -+ gen &= MMIO_GEN_MASK;
5155 -+
5156 -+ /*
5157 -+ * Shift to eliminate the "update in-progress" flag, which isn't
5158 -+ * included in the spte's generation number.
5159 -+ */
5160 -+ gen >>= 1;
5161 -+
5162 -+ /*
5163 -+ * Generation numbers are incremented in multiples of the number of
5164 -+ * address spaces in order to provide unique generations across all
5165 -+ * address spaces. Strip what is effectively the address space
5166 -+ * modifier prior to checking for a wrap of the MMIO generation so
5167 -+ * that a wrap in any address space is detected.
5168 -+ */
5169 -+ gen &= ~((u64)KVM_ADDRESS_SPACE_NUM - 1);
5170 -+
5171 - /*
5172 -- * The very rare case: if the generation-number is round,
5173 -+ * The very rare case: if the MMIO generation number has wrapped,
5174 - * zap all shadow pages.
5175 - */
5176 -- if (unlikely((slots->generation & MMIO_GEN_MASK) == 0)) {
5177 -+ if (unlikely(gen == 0)) {
5178 - kvm_debug_ratelimited("kvm: zapping shadow pages for mmio generation wraparound\n");
5179 - kvm_mmu_invalidate_zap_all_pages(kvm);
5180 - }
5181 -diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
5182 -index f13a3a24d360..a9b8e38d78ad 100644
5183 ---- a/arch/x86/kvm/svm.c
5184 -+++ b/arch/x86/kvm/svm.c
5185 -@@ -6422,11 +6422,11 @@ e_free:
5186 - return ret;
5187 - }
5188 -
5189 --static int get_num_contig_pages(int idx, struct page **inpages,
5190 -- unsigned long npages)
5191 -+static unsigned long get_num_contig_pages(unsigned long idx,
5192 -+ struct page **inpages, unsigned long npages)
5193 - {
5194 - unsigned long paddr, next_paddr;
5195 -- int i = idx + 1, pages = 1;
5196 -+ unsigned long i = idx + 1, pages = 1;
5197 -
5198 - /* find the number of contiguous pages starting from idx */
5199 - paddr = __sme_page_pa(inpages[idx]);
5200 -@@ -6445,12 +6445,12 @@ static int get_num_contig_pages(int idx, struct page **inpages,
5201 -
5202 - static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
5203 - {
5204 -- unsigned long vaddr, vaddr_end, next_vaddr, npages, size;
5205 -+ unsigned long vaddr, vaddr_end, next_vaddr, npages, pages, size, i;
5206 - struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
5207 - struct kvm_sev_launch_update_data params;
5208 - struct sev_data_launch_update_data *data;
5209 - struct page **inpages;
5210 -- int i, ret, pages;
5211 -+ int ret;
5212 -
5213 - if (!sev_guest(kvm))
5214 - return -ENOTTY;
5215 -diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
5216 -index d737a51a53ca..f90b3a948291 100644
5217 ---- a/arch/x86/kvm/vmx/nested.c
5218 -+++ b/arch/x86/kvm/vmx/nested.c
5219 -@@ -500,6 +500,17 @@ static void nested_vmx_disable_intercept_for_msr(unsigned long *msr_bitmap_l1,
5220 - }
5221 - }
5222 -
5223 -+static inline void enable_x2apic_msr_intercepts(unsigned long *msr_bitmap) {
5224 -+ int msr;
5225 -+
5226 -+ for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
5227 -+ unsigned word = msr / BITS_PER_LONG;
5228 -+
5229 -+ msr_bitmap[word] = ~0;
5230 -+ msr_bitmap[word + (0x800 / sizeof(long))] = ~0;
5231 -+ }
5232 -+}
5233 -+
5234 - /*
5235 - * Merge L0's and L1's MSR bitmap, return false to indicate that
5236 - * we do not use the hardware.
5237 -@@ -541,39 +552,44 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
5238 - return false;
5239 -
5240 - msr_bitmap_l1 = (unsigned long *)kmap(page);
5241 -- if (nested_cpu_has_apic_reg_virt(vmcs12)) {
5242 -- /*
5243 -- * L0 need not intercept reads for MSRs between 0x800 and 0x8ff, it
5244 -- * just lets the processor take the value from the virtual-APIC page;
5245 -- * take those 256 bits directly from the L1 bitmap.
5246 -- */
5247 -- for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
5248 -- unsigned word = msr / BITS_PER_LONG;
5249 -- msr_bitmap_l0[word] = msr_bitmap_l1[word];
5250 -- msr_bitmap_l0[word + (0x800 / sizeof(long))] = ~0;
5251 -- }
5252 -- } else {
5253 -- for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
5254 -- unsigned word = msr / BITS_PER_LONG;
5255 -- msr_bitmap_l0[word] = ~0;
5256 -- msr_bitmap_l0[word + (0x800 / sizeof(long))] = ~0;
5257 -- }
5258 -- }
5259 -
5260 -- nested_vmx_disable_intercept_for_msr(
5261 -- msr_bitmap_l1, msr_bitmap_l0,
5262 -- X2APIC_MSR(APIC_TASKPRI),
5263 -- MSR_TYPE_W);
5264 -+ /*
5265 -+ * To keep the control flow simple, pay eight 8-byte writes (sixteen
5266 -+ * 4-byte writes on 32-bit systems) up front to enable intercepts for
5267 -+ * the x2APIC MSR range and selectively disable them below.
5268 -+ */
5269 -+ enable_x2apic_msr_intercepts(msr_bitmap_l0);
5270 -+
5271 -+ if (nested_cpu_has_virt_x2apic_mode(vmcs12)) {
5272 -+ if (nested_cpu_has_apic_reg_virt(vmcs12)) {
5273 -+ /*
5274 -+ * L0 need not intercept reads for MSRs between 0x800
5275 -+ * and 0x8ff, it just lets the processor take the value
5276 -+ * from the virtual-APIC page; take those 256 bits
5277 -+ * directly from the L1 bitmap.
5278 -+ */
5279 -+ for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
5280 -+ unsigned word = msr / BITS_PER_LONG;
5281 -+
5282 -+ msr_bitmap_l0[word] = msr_bitmap_l1[word];
5283 -+ }
5284 -+ }
5285 -
5286 -- if (nested_cpu_has_vid(vmcs12)) {
5287 -- nested_vmx_disable_intercept_for_msr(
5288 -- msr_bitmap_l1, msr_bitmap_l0,
5289 -- X2APIC_MSR(APIC_EOI),
5290 -- MSR_TYPE_W);
5291 - nested_vmx_disable_intercept_for_msr(
5292 - msr_bitmap_l1, msr_bitmap_l0,
5293 -- X2APIC_MSR(APIC_SELF_IPI),
5294 -- MSR_TYPE_W);
5295 -+ X2APIC_MSR(APIC_TASKPRI),
5296 -+ MSR_TYPE_R | MSR_TYPE_W);
5297 -+
5298 -+ if (nested_cpu_has_vid(vmcs12)) {
5299 -+ nested_vmx_disable_intercept_for_msr(
5300 -+ msr_bitmap_l1, msr_bitmap_l0,
5301 -+ X2APIC_MSR(APIC_EOI),
5302 -+ MSR_TYPE_W);
5303 -+ nested_vmx_disable_intercept_for_msr(
5304 -+ msr_bitmap_l1, msr_bitmap_l0,
5305 -+ X2APIC_MSR(APIC_SELF_IPI),
5306 -+ MSR_TYPE_W);
5307 -+ }
5308 - }
5309 -
5310 - if (spec_ctrl)
5311 -@@ -2765,7 +2781,7 @@ static int nested_vmx_check_vmentry_hw(struct kvm_vcpu *vcpu)
5312 - "add $%c[wordsize], %%" _ASM_SP "\n\t" /* un-adjust RSP */
5313 -
5314 - /* Check if vmlaunch or vmresume is needed */
5315 -- "cmpl $0, %c[launched](%% " _ASM_CX")\n\t"
5316 -+ "cmpb $0, %c[launched](%% " _ASM_CX")\n\t"
5317 -
5318 - "call vmx_vmenter\n\t"
5319 -
5320 -@@ -4035,25 +4051,50 @@ int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsigned long exit_qualification,
5321 - /* Addr = segment_base + offset */
5322 - /* offset = base + [index * scale] + displacement */
5323 - off = exit_qualification; /* holds the displacement */
5324 -+ if (addr_size == 1)
5325 -+ off = (gva_t)sign_extend64(off, 31);
5326 -+ else if (addr_size == 0)
5327 -+ off = (gva_t)sign_extend64(off, 15);
5328 - if (base_is_valid)
5329 - off += kvm_register_read(vcpu, base_reg);
5330 - if (index_is_valid)
5331 - off += kvm_register_read(vcpu, index_reg)<<scaling;
5332 - vmx_get_segment(vcpu, &s, seg_reg);
5333 -- *ret = s.base + off;
5334 -
5335 -+ /*
5336 -+ * The effective address, i.e. @off, of a memory operand is truncated
5337 -+ * based on the address size of the instruction. Note that this is
5338 -+ * the *effective address*, i.e. the address prior to accounting for
5339 -+ * the segment's base.
5340 -+ */
5341 - if (addr_size == 1) /* 32 bit */
5342 -- *ret &= 0xffffffff;
5343 -+ off &= 0xffffffff;
5344 -+ else if (addr_size == 0) /* 16 bit */
5345 -+ off &= 0xffff;
5346 -
5347 - /* Checks for #GP/#SS exceptions. */
5348 - exn = false;
5349 - if (is_long_mode(vcpu)) {
5350 -+ /*
5351 -+ * The virtual/linear address is never truncated in 64-bit
5352 -+ * mode, e.g. a 32-bit address size can yield a 64-bit virtual
5353 -+ * address when using FS/GS with a non-zero base.
5354 -+ */
5355 -+ *ret = s.base + off;
5356 -+
5357 - /* Long mode: #GP(0)/#SS(0) if the memory address is in a
5358 - * non-canonical form. This is the only check on the memory
5359 - * destination for long mode!
5360 - */
5361 - exn = is_noncanonical_address(*ret, vcpu);
5362 - } else if (is_protmode(vcpu)) {
5363 -+ /*
5364 -+ * When not in long mode, the virtual/linear address is
5365 -+ * unconditionally truncated to 32 bits regardless of the
5366 -+ * address size.
5367 -+ */
5368 -+ *ret = (s.base + off) & 0xffffffff;
5369 -+
5370 - /* Protected mode: apply checks for segment validity in the
5371 - * following order:
5372 - * - segment type check (#GP(0) may be thrown)
5373 -@@ -4077,10 +4118,16 @@ int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsigned long exit_qualification,
5374 - /* Protected mode: #GP(0)/#SS(0) if the segment is unusable.
5375 - */
5376 - exn = (s.unusable != 0);
5377 -- /* Protected mode: #GP(0)/#SS(0) if the memory
5378 -- * operand is outside the segment limit.
5379 -+
5380 -+ /*
5381 -+ * Protected mode: #GP(0)/#SS(0) if the memory operand is
5382 -+ * outside the segment limit. All CPUs that support VMX ignore
5383 -+ * limit checks for flat segments, i.e. segments with base==0,
5384 -+ * limit==0xffffffff and of type expand-up data or code.
5385 - */
5386 -- exn = exn || (off + sizeof(u64) > s.limit);
5387 -+ if (!(s.base == 0 && s.limit == 0xffffffff &&
5388 -+ ((s.type & 8) || !(s.type & 4))))
5389 -+ exn = exn || (off + sizeof(u64) > s.limit);
5390 - }
5391 - if (exn) {
5392 - kvm_queue_exception_e(vcpu,
5393 -diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
5394 -index 30a6bcd735ec..a0a770816429 100644
5395 ---- a/arch/x86/kvm/vmx/vmx.c
5396 -+++ b/arch/x86/kvm/vmx/vmx.c
5397 -@@ -1679,12 +1679,6 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
5398 -
5399 - msr_info->data = to_vmx(vcpu)->spec_ctrl;
5400 - break;
5401 -- case MSR_IA32_ARCH_CAPABILITIES:
5402 -- if (!msr_info->host_initiated &&
5403 -- !guest_cpuid_has(vcpu, X86_FEATURE_ARCH_CAPABILITIES))
5404 -- return 1;
5405 -- msr_info->data = to_vmx(vcpu)->arch_capabilities;
5406 -- break;
5407 - case MSR_IA32_SYSENTER_CS:
5408 - msr_info->data = vmcs_read32(GUEST_SYSENTER_CS);
5409 - break;
5410 -@@ -1891,11 +1885,6 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
5411 - vmx_disable_intercept_for_msr(vmx->vmcs01.msr_bitmap, MSR_IA32_PRED_CMD,
5412 - MSR_TYPE_W);
5413 - break;
5414 -- case MSR_IA32_ARCH_CAPABILITIES:
5415 -- if (!msr_info->host_initiated)
5416 -- return 1;
5417 -- vmx->arch_capabilities = data;
5418 -- break;
5419 - case MSR_IA32_CR_PAT:
5420 - if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
5421 - if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
5422 -@@ -4083,8 +4072,6 @@ static void vmx_vcpu_setup(struct vcpu_vmx *vmx)
5423 - ++vmx->nmsrs;
5424 - }
5425 -
5426 -- vmx->arch_capabilities = kvm_get_arch_capabilities();
5427 --
5428 - vm_exit_controls_init(vmx, vmx_vmexit_ctrl());
5429 -
5430 - /* 22.2.1, 20.8.1 */
5431 -@@ -6399,7 +6386,7 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
5432 - "mov %%" _ASM_AX", %%cr2 \n\t"
5433 - "3: \n\t"
5434 - /* Check if vmlaunch or vmresume is needed */
5435 -- "cmpl $0, %c[launched](%%" _ASM_CX ") \n\t"
5436 -+ "cmpb $0, %c[launched](%%" _ASM_CX ") \n\t"
5437 - /* Load guest registers. Don't clobber flags. */
5438 - "mov %c[rax](%%" _ASM_CX "), %%" _ASM_AX " \n\t"
5439 - "mov %c[rbx](%%" _ASM_CX "), %%" _ASM_BX " \n\t"
5440 -@@ -6449,10 +6436,15 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
5441 - "mov %%r13, %c[r13](%%" _ASM_CX ") \n\t"
5442 - "mov %%r14, %c[r14](%%" _ASM_CX ") \n\t"
5443 - "mov %%r15, %c[r15](%%" _ASM_CX ") \n\t"
5444 -+
5445 - /*
5446 -- * Clear host registers marked as clobbered to prevent
5447 -- * speculative use.
5448 -- */
5449 -+ * Clear all general purpose registers (except RSP, which is loaded by
5450 -+ * the CPU during VM-Exit) to prevent speculative use of the guest's
5451 -+ * values, even those that are saved/loaded via the stack. In theory,
5452 -+ * an L1 cache miss when restoring registers could lead to speculative
5453 -+ * execution with the guest's values. Zeroing XORs are dirt cheap,
5454 -+ * i.e. the extra paranoia is essentially free.
5455 -+ */
5456 - "xor %%r8d, %%r8d \n\t"
5457 - "xor %%r9d, %%r9d \n\t"
5458 - "xor %%r10d, %%r10d \n\t"
5459 -@@ -6467,8 +6459,11 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
5460 -
5461 - "xor %%eax, %%eax \n\t"
5462 - "xor %%ebx, %%ebx \n\t"
5463 -+ "xor %%ecx, %%ecx \n\t"
5464 -+ "xor %%edx, %%edx \n\t"
5465 - "xor %%esi, %%esi \n\t"
5466 - "xor %%edi, %%edi \n\t"
5467 -+ "xor %%ebp, %%ebp \n\t"
5468 - "pop %%" _ASM_BP "; pop %%" _ASM_DX " \n\t"
5469 - : ASM_CALL_CONSTRAINT
5470 - : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp),
5471 -diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
5472 -index 0ac0a64c7790..1abae731c3e4 100644
5473 ---- a/arch/x86/kvm/vmx/vmx.h
5474 -+++ b/arch/x86/kvm/vmx/vmx.h
5475 -@@ -191,7 +191,6 @@ struct vcpu_vmx {
5476 - u64 msr_guest_kernel_gs_base;
5477 - #endif
5478 -
5479 -- u64 arch_capabilities;
5480 - u64 spec_ctrl;
5481 -
5482 - u32 vm_entry_controls_shadow;
5483 -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
5484 -index 941f932373d0..7ee802a92bc8 100644
5485 ---- a/arch/x86/kvm/x86.c
5486 -+++ b/arch/x86/kvm/x86.c
5487 -@@ -2443,6 +2443,11 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
5488 - if (msr_info->host_initiated)
5489 - vcpu->arch.microcode_version = data;
5490 - break;
5491 -+ case MSR_IA32_ARCH_CAPABILITIES:
5492 -+ if (!msr_info->host_initiated)
5493 -+ return 1;
5494 -+ vcpu->arch.arch_capabilities = data;
5495 -+ break;
5496 - case MSR_EFER:
5497 - return set_efer(vcpu, data);
5498 - case MSR_K7_HWCR:
5499 -@@ -2747,6 +2752,12 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
5500 - case MSR_IA32_UCODE_REV:
5501 - msr_info->data = vcpu->arch.microcode_version;
5502 - break;
5503 -+ case MSR_IA32_ARCH_CAPABILITIES:
5504 -+ if (!msr_info->host_initiated &&
5505 -+ !guest_cpuid_has(vcpu, X86_FEATURE_ARCH_CAPABILITIES))
5506 -+ return 1;
5507 -+ msr_info->data = vcpu->arch.arch_capabilities;
5508 -+ break;
5509 - case MSR_IA32_TSC:
5510 - msr_info->data = kvm_scale_tsc(vcpu, rdtsc()) + vcpu->arch.tsc_offset;
5511 - break;
5512 -@@ -6522,14 +6533,27 @@ int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
5513 - }
5514 - EXPORT_SYMBOL_GPL(kvm_emulate_instruction_from_buffer);
5515 -
5516 -+static int complete_fast_pio_out(struct kvm_vcpu *vcpu)
5517 -+{
5518 -+ vcpu->arch.pio.count = 0;
5519 -+
5520 -+ if (unlikely(!kvm_is_linear_rip(vcpu, vcpu->arch.pio.linear_rip)))
5521 -+ return 1;
5522 -+
5523 -+ return kvm_skip_emulated_instruction(vcpu);
5524 -+}
5525 -+
5526 - static int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size,
5527 - unsigned short port)
5528 - {
5529 - unsigned long val = kvm_register_read(vcpu, VCPU_REGS_RAX);
5530 - int ret = emulator_pio_out_emulated(&vcpu->arch.emulate_ctxt,
5531 - size, port, &val, 1);
5532 -- /* do not return to emulator after return from userspace */
5533 -- vcpu->arch.pio.count = 0;
5534 -+
5535 -+ if (!ret) {
5536 -+ vcpu->arch.pio.linear_rip = kvm_get_linear_rip(vcpu);
5537 -+ vcpu->arch.complete_userspace_io = complete_fast_pio_out;
5538 -+ }
5539 - return ret;
5540 - }
5541 -
5542 -@@ -6540,6 +6564,11 @@ static int complete_fast_pio_in(struct kvm_vcpu *vcpu)
5543 - /* We should only ever be called with arch.pio.count equal to 1 */
5544 - BUG_ON(vcpu->arch.pio.count != 1);
5545 -
5546 -+ if (unlikely(!kvm_is_linear_rip(vcpu, vcpu->arch.pio.linear_rip))) {
5547 -+ vcpu->arch.pio.count = 0;
5548 -+ return 1;
5549 -+ }
5550 -+
5551 - /* For size less than 4 we merge, else we zero extend */
5552 - val = (vcpu->arch.pio.size < 4) ? kvm_register_read(vcpu, VCPU_REGS_RAX)
5553 - : 0;
5554 -@@ -6552,7 +6581,7 @@ static int complete_fast_pio_in(struct kvm_vcpu *vcpu)
5555 - vcpu->arch.pio.port, &val, 1);
5556 - kvm_register_write(vcpu, VCPU_REGS_RAX, val);
5557 -
5558 -- return 1;
5559 -+ return kvm_skip_emulated_instruction(vcpu);
5560 - }
5561 -
5562 - static int kvm_fast_pio_in(struct kvm_vcpu *vcpu, int size,
5563 -@@ -6571,6 +6600,7 @@ static int kvm_fast_pio_in(struct kvm_vcpu *vcpu, int size,
5564 - return ret;
5565 - }
5566 -
5567 -+ vcpu->arch.pio.linear_rip = kvm_get_linear_rip(vcpu);
5568 - vcpu->arch.complete_userspace_io = complete_fast_pio_in;
5569 -
5570 - return 0;
5571 -@@ -6578,16 +6608,13 @@ static int kvm_fast_pio_in(struct kvm_vcpu *vcpu, int size,
5572 -
5573 - int kvm_fast_pio(struct kvm_vcpu *vcpu, int size, unsigned short port, int in)
5574 - {
5575 -- int ret = kvm_skip_emulated_instruction(vcpu);
5576 -+ int ret;
5577 -
5578 -- /*
5579 -- * TODO: we might be squashing a KVM_GUESTDBG_SINGLESTEP-triggered
5580 -- * KVM_EXIT_DEBUG here.
5581 -- */
5582 - if (in)
5583 -- return kvm_fast_pio_in(vcpu, size, port) && ret;
5584 -+ ret = kvm_fast_pio_in(vcpu, size, port);
5585 - else
5586 -- return kvm_fast_pio_out(vcpu, size, port) && ret;
5587 -+ ret = kvm_fast_pio_out(vcpu, size, port);
5588 -+ return ret && kvm_skip_emulated_instruction(vcpu);
5589 - }
5590 - EXPORT_SYMBOL_GPL(kvm_fast_pio);
5591 -
5592 -@@ -8725,6 +8752,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
5593 -
5594 - int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
5595 - {
5596 -+ vcpu->arch.arch_capabilities = kvm_get_arch_capabilities();
5597 - vcpu->arch.msr_platform_info = MSR_PLATFORM_INFO_CPUID_FAULT;
5598 - kvm_vcpu_mtrr_init(vcpu);
5599 - vcpu_load(vcpu);
5600 -@@ -9348,13 +9376,13 @@ out_free:
5601 - return -ENOMEM;
5602 - }
5603 -
5604 --void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots)
5605 -+void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen)
5606 - {
5607 - /*
5608 - * memslots->generation has been incremented.
5609 - * mmio generation may have reached its maximum value.
5610 - */
5611 -- kvm_mmu_invalidate_mmio_sptes(kvm, slots);
5612 -+ kvm_mmu_invalidate_mmio_sptes(kvm, gen);
5613 - }
5614 -
5615 - int kvm_arch_prepare_memory_region(struct kvm *kvm,
5616 -diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
5617 -index 224cd0a47568..20ede17202bf 100644
5618 ---- a/arch/x86/kvm/x86.h
5619 -+++ b/arch/x86/kvm/x86.h
5620 -@@ -181,6 +181,11 @@ static inline bool emul_is_noncanonical_address(u64 la,
5621 - static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
5622 - gva_t gva, gfn_t gfn, unsigned access)
5623 - {
5624 -+ u64 gen = kvm_memslots(vcpu->kvm)->generation;
5625 -+
5626 -+ if (unlikely(gen & 1))
5627 -+ return;
5628 -+
5629 - /*
5630 - * If this is a shadow nested page table, the "GVA" is
5631 - * actually a nGPA.
5632 -@@ -188,7 +193,7 @@ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
5633 - vcpu->arch.mmio_gva = mmu_is_nested(vcpu) ? 0 : gva & PAGE_MASK;
5634 - vcpu->arch.access = access;
5635 - vcpu->arch.mmio_gfn = gfn;
5636 -- vcpu->arch.mmio_gen = kvm_memslots(vcpu->kvm)->generation;
5637 -+ vcpu->arch.mmio_gen = gen;
5638 - }
5639 -
5640 - static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
5641 -diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
5642 -index bfd94e7812fc..7d290777246d 100644
5643 ---- a/arch/x86/lib/usercopy_32.c
5644 -+++ b/arch/x86/lib/usercopy_32.c
5645 -@@ -54,13 +54,13 @@ do { \
5646 - } while (0)
5647 -
5648 - /**
5649 -- * clear_user: - Zero a block of memory in user space.
5650 -+ * clear_user - Zero a block of memory in user space.
5651 - * @to: Destination address, in user space.
5652 - * @n: Number of bytes to zero.
5653 - *
5654 - * Zero a block of memory in user space.
5655 - *
5656 -- * Returns number of bytes that could not be cleared.
5657 -+ * Return: number of bytes that could not be cleared.
5658 - * On success, this will be zero.
5659 - */
5660 - unsigned long
5661 -@@ -74,14 +74,14 @@ clear_user(void __user *to, unsigned long n)
5662 - EXPORT_SYMBOL(clear_user);
5663 -
5664 - /**
5665 -- * __clear_user: - Zero a block of memory in user space, with less checking.
5666 -+ * __clear_user - Zero a block of memory in user space, with less checking.
5667 - * @to: Destination address, in user space.
5668 - * @n: Number of bytes to zero.
5669 - *
5670 - * Zero a block of memory in user space. Caller must check
5671 - * the specified block with access_ok() before calling this function.
5672 - *
5673 -- * Returns number of bytes that could not be cleared.
5674 -+ * Return: number of bytes that could not be cleared.
5675 - * On success, this will be zero.
5676 - */
5677 - unsigned long
5678 -diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
5679 -index 30a5111ae5fd..527e69b12002 100644
5680 ---- a/arch/x86/pci/fixup.c
5681 -+++ b/arch/x86/pci/fixup.c
5682 -@@ -635,6 +635,22 @@ static void quirk_no_aersid(struct pci_dev *pdev)
5683 - DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
5684 - PCI_CLASS_BRIDGE_PCI, 8, quirk_no_aersid);
5685 -
5686 -+static void quirk_intel_th_dnv(struct pci_dev *dev)
5687 -+{
5688 -+ struct resource *r = &dev->resource[4];
5689 -+
5690 -+ /*
5691 -+ * Denverton reports 2k of RTIT_BAR (intel_th resource 4), which
5692 -+ * appears to be 4 MB in reality.
5693 -+ */
5694 -+ if (r->end == r->start + 0x7ff) {
5695 -+ r->start = 0;
5696 -+ r->end = 0x3fffff;
5697 -+ r->flags |= IORESOURCE_UNSET;
5698 -+ }
5699 -+}
5700 -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x19e1, quirk_intel_th_dnv);
5701 -+
5702 - #ifdef CONFIG_PHYS_ADDR_T_64BIT
5703 -
5704 - #define AMD_141b_MMIO_BASE(x) (0x80 + (x) * 0x8)
5705 -diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
5706 -index 17456a1d3f04..6c571ae86947 100644
5707 ---- a/arch/x86/platform/efi/quirks.c
5708 -+++ b/arch/x86/platform/efi/quirks.c
5709 -@@ -717,7 +717,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
5710 - * "efi_mm" cannot be used to check if the page fault had occurred
5711 - * in the firmware context because efi=old_map doesn't use efi_pgd.
5712 - */
5713 -- if (efi_rts_work.efi_rts_id == NONE)
5714 -+ if (efi_rts_work.efi_rts_id == EFI_NONE)
5715 - return;
5716 -
5717 - /*
5718 -@@ -742,7 +742,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
5719 - * because this case occurs *very* rarely and hence could be improved
5720 - * on a need by basis.
5721 - */
5722 -- if (efi_rts_work.efi_rts_id == RESET_SYSTEM) {
5723 -+ if (efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
5724 - pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
5725 - machine_real_restart(MRR_BIOS);
5726 - return;
5727 -diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
5728 -index 4463fa72db94..96cb20de08af 100644
5729 ---- a/arch/x86/realmode/rm/Makefile
5730 -+++ b/arch/x86/realmode/rm/Makefile
5731 -@@ -47,7 +47,7 @@ $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
5732 - targets += realmode.lds
5733 - $(obj)/realmode.lds: $(obj)/pasyms.h
5734 -
5735 --LDFLAGS_realmode.elf := --emit-relocs -T
5736 -+LDFLAGS_realmode.elf := -m elf_i386 --emit-relocs -T
5737 - CPPFLAGS_realmode.lds += -P -C -I$(objtree)/$(obj)
5738 -
5739 - targets += realmode.elf
5740 -diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
5741 -index 0f4fe206dcc2..20701977e6c0 100644
5742 ---- a/arch/x86/xen/mmu_pv.c
5743 -+++ b/arch/x86/xen/mmu_pv.c
5744 -@@ -2114,10 +2114,10 @@ void __init xen_relocate_p2m(void)
5745 - pt = early_memremap(pt_phys, PAGE_SIZE);
5746 - clear_page(pt);
5747 - for (idx_pte = 0;
5748 -- idx_pte < min(n_pte, PTRS_PER_PTE);
5749 -- idx_pte++) {
5750 -- set_pte(pt + idx_pte,
5751 -- pfn_pte(p2m_pfn, PAGE_KERNEL));
5752 -+ idx_pte < min(n_pte, PTRS_PER_PTE);
5753 -+ idx_pte++) {
5754 -+ pt[idx_pte] = pfn_pte(p2m_pfn,
5755 -+ PAGE_KERNEL);
5756 - p2m_pfn++;
5757 - }
5758 - n_pte -= PTRS_PER_PTE;
5759 -@@ -2125,8 +2125,7 @@ void __init xen_relocate_p2m(void)
5760 - make_lowmem_page_readonly(__va(pt_phys));
5761 - pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE,
5762 - PFN_DOWN(pt_phys));
5763 -- set_pmd(pmd + idx_pt,
5764 -- __pmd(_PAGE_TABLE | pt_phys));
5765 -+ pmd[idx_pt] = __pmd(_PAGE_TABLE | pt_phys);
5766 - pt_phys += PAGE_SIZE;
5767 - }
5768 - n_pt -= PTRS_PER_PMD;
5769 -@@ -2134,7 +2133,7 @@ void __init xen_relocate_p2m(void)
5770 - make_lowmem_page_readonly(__va(pmd_phys));
5771 - pin_pagetable_pfn(MMUEXT_PIN_L2_TABLE,
5772 - PFN_DOWN(pmd_phys));
5773 -- set_pud(pud + idx_pmd, __pud(_PAGE_TABLE | pmd_phys));
5774 -+ pud[idx_pmd] = __pud(_PAGE_TABLE | pmd_phys);
5775 - pmd_phys += PAGE_SIZE;
5776 - }
5777 - n_pmd -= PTRS_PER_PUD;
5778 -diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
5779 -index 74969a437a37..2e73395f0560 100644
5780 ---- a/arch/xtensa/kernel/process.c
5781 -+++ b/arch/xtensa/kernel/process.c
5782 -@@ -321,8 +321,8 @@ unsigned long get_wchan(struct task_struct *p)
5783 -
5784 - /* Stack layout: sp-4: ra, sp-3: sp' */
5785 -
5786 -- pc = MAKE_PC_FROM_RA(*(unsigned long*)sp - 4, sp);
5787 -- sp = *(unsigned long *)sp - 3;
5788 -+ pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), sp);
5789 -+ sp = SPILL_SLOT(sp, 1);
5790 - } while (count++ < 16);
5791 - return 0;
5792 - }
5793 -diff --git a/arch/xtensa/kernel/stacktrace.c b/arch/xtensa/kernel/stacktrace.c
5794 -index 174c11f13bba..b9f82510c650 100644
5795 ---- a/arch/xtensa/kernel/stacktrace.c
5796 -+++ b/arch/xtensa/kernel/stacktrace.c
5797 -@@ -253,10 +253,14 @@ static int return_address_cb(struct stackframe *frame, void *data)
5798 - return 1;
5799 - }
5800 -
5801 -+/*
5802 -+ * level == 0 is for the return address from the caller of this function,
5803 -+ * not from this function itself.
5804 -+ */
5805 - unsigned long return_address(unsigned level)
5806 - {
5807 - struct return_addr_data r = {
5808 -- .skip = level + 1,
5809 -+ .skip = level,
5810 - };
5811 - walk_stackframe(stack_pointer(NULL), return_address_cb, &r);
5812 - return r.addr;
5813 -diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
5814 -index cd307767a134..e5ed28629271 100644
5815 ---- a/block/bfq-iosched.c
5816 -+++ b/block/bfq-iosched.c
5817 -@@ -747,6 +747,7 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq,
5818 -
5819 - inc_counter:
5820 - bfqq->weight_counter->num_active++;
5821 -+ bfqq->ref++;
5822 - }
5823 -
5824 - /*
5825 -@@ -771,6 +772,7 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd,
5826 -
5827 - reset_entity_pointer:
5828 - bfqq->weight_counter = NULL;
5829 -+ bfq_put_queue(bfqq);
5830 - }
5831 -
5832 - /*
5833 -@@ -782,9 +784,6 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd,
5834 - {
5835 - struct bfq_entity *entity = bfqq->entity.parent;
5836 -
5837 -- __bfq_weights_tree_remove(bfqd, bfqq,
5838 -- &bfqd->queue_weights_tree);
5839 --
5840 - for_each_entity(entity) {
5841 - struct bfq_sched_data *sd = entity->my_sched_data;
5842 -
5843 -@@ -818,6 +817,15 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd,
5844 - bfqd->num_groups_with_pending_reqs--;
5845 - }
5846 - }
5847 -+
5848 -+ /*
5849 -+ * Next function is invoked last, because it causes bfqq to be
5850 -+ * freed if the following holds: bfqq is not in service and
5851 -+ * has no dispatched request. DO NOT use bfqq after the next
5852 -+ * function invocation.
5853 -+ */
5854 -+ __bfq_weights_tree_remove(bfqd, bfqq,
5855 -+ &bfqd->queue_weights_tree);
5856 - }
5857 -
5858 - /*
5859 -@@ -1011,7 +1019,8 @@ bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd,
5860 -
5861 - static int bfqq_process_refs(struct bfq_queue *bfqq)
5862 - {
5863 -- return bfqq->ref - bfqq->allocated - bfqq->entity.on_st;
5864 -+ return bfqq->ref - bfqq->allocated - bfqq->entity.on_st -
5865 -+ (bfqq->weight_counter != NULL);
5866 - }
5867 -
5868 - /* Empty burst list and add just bfqq (see comments on bfq_handle_burst) */
5869 -@@ -2224,7 +2233,8 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
5870 -
5871 - if (in_service_bfqq && in_service_bfqq != bfqq &&
5872 - likely(in_service_bfqq != &bfqd->oom_bfqq) &&
5873 -- bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) &&
5874 -+ bfq_rq_close_to_sector(io_struct, request,
5875 -+ bfqd->in_serv_last_pos) &&
5876 - bfqq->entity.parent == in_service_bfqq->entity.parent &&
5877 - bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) {
5878 - new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq);
5879 -@@ -2764,6 +2774,8 @@ update_rate_and_reset:
5880 - bfq_update_rate_reset(bfqd, rq);
5881 - update_last_values:
5882 - bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq);
5883 -+ if (RQ_BFQQ(rq) == bfqd->in_service_queue)
5884 -+ bfqd->in_serv_last_pos = bfqd->last_position;
5885 - bfqd->last_dispatch = now_ns;
5886 - }
5887 -
5888 -diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
5889 -index 0b02bf302de0..746bd570b85a 100644
5890 ---- a/block/bfq-iosched.h
5891 -+++ b/block/bfq-iosched.h
5892 -@@ -537,6 +537,9 @@ struct bfq_data {
5893 - /* on-disk position of the last served request */
5894 - sector_t last_position;
5895 -
5896 -+ /* position of the last served request for the in-service queue */
5897 -+ sector_t in_serv_last_pos;
5898 -+
5899 - /* time of last request completion (ns) */
5900 - u64 last_completion;
5901 -
5902 -diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
5903 -index 72adbbe975d5..4aab1a8191f0 100644
5904 ---- a/block/bfq-wf2q.c
5905 -+++ b/block/bfq-wf2q.c
5906 -@@ -1667,15 +1667,15 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq,
5907 -
5908 - bfqd->busy_queues--;
5909 -
5910 -- if (!bfqq->dispatched)
5911 -- bfq_weights_tree_remove(bfqd, bfqq);
5912 --
5913 - if (bfqq->wr_coeff > 1)
5914 - bfqd->wr_busy_queues--;
5915 -
5916 - bfqg_stats_update_dequeue(bfqq_group(bfqq));
5917 -
5918 - bfq_deactivate_bfqq(bfqd, bfqq, true, expiration);
5919 -+
5920 -+ if (!bfqq->dispatched)
5921 -+ bfq_weights_tree_remove(bfqd, bfqq);
5922 - }
5923 -
5924 - /*
5925 -diff --git a/block/bio.c b/block/bio.c
5926 -index 4db1008309ed..a06f58bd4c72 100644
5927 ---- a/block/bio.c
5928 -+++ b/block/bio.c
5929 -@@ -1238,8 +1238,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
5930 - }
5931 - }
5932 -
5933 -- if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes)
5934 -+ if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) {
5935 -+ if (!map_data)
5936 -+ __free_page(page);
5937 - break;
5938 -+ }
5939 -
5940 - len -= bytes;
5941 - offset = 0;
5942 -diff --git a/block/blk-core.c b/block/blk-core.c
5943 -index 6b78ec56a4f2..5bde73a49399 100644
5944 ---- a/block/blk-core.c
5945 -+++ b/block/blk-core.c
5946 -@@ -1246,8 +1246,6 @@ static int blk_cloned_rq_check_limits(struct request_queue *q,
5947 - */
5948 - blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq)
5949 - {
5950 -- blk_qc_t unused;
5951 --
5952 - if (blk_cloned_rq_check_limits(q, rq))
5953 - return BLK_STS_IOERR;
5954 -
5955 -@@ -1263,7 +1261,7 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *
5956 - * bypass a potential scheduler on the bottom device for
5957 - * insert.
5958 - */
5959 -- return blk_mq_try_issue_directly(rq->mq_hctx, rq, &unused, true, true);
5960 -+ return blk_mq_request_issue_directly(rq, true);
5961 - }
5962 - EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
5963 -
5964 -diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
5965 -index 140933e4a7d1..0c98b6c1ca49 100644
5966 ---- a/block/blk-mq-sched.c
5967 -+++ b/block/blk-mq-sched.c
5968 -@@ -423,10 +423,12 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
5969 - * busy in case of 'none' scheduler, and this way may save
5970 - * us one extra enqueue & dequeue to sw queue.
5971 - */
5972 -- if (!hctx->dispatch_busy && !e && !run_queue_async)
5973 -+ if (!hctx->dispatch_busy && !e && !run_queue_async) {
5974 - blk_mq_try_issue_list_directly(hctx, list);
5975 -- else
5976 -- blk_mq_insert_requests(hctx, ctx, list);
5977 -+ if (list_empty(list))
5978 -+ return;
5979 -+ }
5980 -+ blk_mq_insert_requests(hctx, ctx, list);
5981 - }
5982 -
5983 - blk_mq_run_hw_queue(hctx, run_queue_async);
5984 -diff --git a/block/blk-mq.c b/block/blk-mq.c
5985 -index 9437a5eb07cf..16f9675c57e6 100644
5986 ---- a/block/blk-mq.c
5987 -+++ b/block/blk-mq.c
5988 -@@ -1076,7 +1076,13 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode,
5989 - hctx = container_of(wait, struct blk_mq_hw_ctx, dispatch_wait);
5990 -
5991 - spin_lock(&hctx->dispatch_wait_lock);
5992 -- list_del_init(&wait->entry);
5993 -+ if (!list_empty(&wait->entry)) {
5994 -+ struct sbitmap_queue *sbq;
5995 -+
5996 -+ list_del_init(&wait->entry);
5997 -+ sbq = &hctx->tags->bitmap_tags;
5998 -+ atomic_dec(&sbq->ws_active);
5999 -+ }
6000 - spin_unlock(&hctx->dispatch_wait_lock);
6001 -
6002 - blk_mq_run_hw_queue(hctx, true);
6003 -@@ -1092,6 +1098,7 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode,
6004 - static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx,
6005 - struct request *rq)
6006 - {
6007 -+ struct sbitmap_queue *sbq = &hctx->tags->bitmap_tags;
6008 - struct wait_queue_head *wq;
6009 - wait_queue_entry_t *wait;
6010 - bool ret;
6011 -@@ -1115,7 +1122,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx,
6012 - if (!list_empty_careful(&wait->entry))
6013 - return false;
6014 -
6015 -- wq = &bt_wait_ptr(&hctx->tags->bitmap_tags, hctx)->wait;
6016 -+ wq = &bt_wait_ptr(sbq, hctx)->wait;
6017 -
6018 - spin_lock_irq(&wq->lock);
6019 - spin_lock(&hctx->dispatch_wait_lock);
6020 -@@ -1125,6 +1132,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx,
6021 - return false;
6022 - }
6023 -
6024 -+ atomic_inc(&sbq->ws_active);
6025 - wait->flags &= ~WQ_FLAG_EXCLUSIVE;
6026 - __add_wait_queue(wq, wait);
6027 -
6028 -@@ -1145,6 +1153,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx,
6029 - * someone else gets the wakeup.
6030 - */
6031 - list_del_init(&wait->entry);
6032 -+ atomic_dec(&sbq->ws_active);
6033 - spin_unlock(&hctx->dispatch_wait_lock);
6034 - spin_unlock_irq(&wq->lock);
6035 -
6036 -@@ -1796,74 +1805,76 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
6037 - return ret;
6038 - }
6039 -
6040 --blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
6041 -+static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
6042 - struct request *rq,
6043 - blk_qc_t *cookie,
6044 -- bool bypass, bool last)
6045 -+ bool bypass_insert, bool last)
6046 - {
6047 - struct request_queue *q = rq->q;
6048 - bool run_queue = true;
6049 -- blk_status_t ret = BLK_STS_RESOURCE;
6050 -- int srcu_idx;
6051 -- bool force = false;
6052 -
6053 -- hctx_lock(hctx, &srcu_idx);
6054 - /*
6055 -- * hctx_lock is needed before checking quiesced flag.
6056 -+ * RCU or SRCU read lock is needed before checking quiesced flag.
6057 - *
6058 -- * When queue is stopped or quiesced, ignore 'bypass', insert
6059 -- * and return BLK_STS_OK to caller, and avoid driver to try to
6060 -- * dispatch again.
6061 -+ * When queue is stopped or quiesced, ignore 'bypass_insert' from
6062 -+ * blk_mq_request_issue_directly(), and return BLK_STS_OK to caller,
6063 -+ * and avoid driver to try to dispatch again.
6064 - */
6065 -- if (unlikely(blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q))) {
6066 -+ if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q)) {
6067 - run_queue = false;
6068 -- bypass = false;
6069 -- goto out_unlock;
6070 -+ bypass_insert = false;
6071 -+ goto insert;
6072 - }
6073 -
6074 -- if (unlikely(q->elevator && !bypass))
6075 -- goto out_unlock;
6076 -+ if (q->elevator && !bypass_insert)
6077 -+ goto insert;
6078 -
6079 - if (!blk_mq_get_dispatch_budget(hctx))
6080 -- goto out_unlock;
6081 -+ goto insert;
6082 -
6083 - if (!blk_mq_get_driver_tag(rq)) {
6084 - blk_mq_put_dispatch_budget(hctx);
6085 -- goto out_unlock;
6086 -+ goto insert;
6087 - }
6088 -
6089 -- /*
6090 -- * Always add a request that has been through
6091 -- *.queue_rq() to the hardware dispatch list.
6092 -- */
6093 -- force = true;
6094 -- ret = __blk_mq_issue_directly(hctx, rq, cookie, last);
6095 --out_unlock:
6096 -+ return __blk_mq_issue_directly(hctx, rq, cookie, last);
6097 -+insert:
6098 -+ if (bypass_insert)
6099 -+ return BLK_STS_RESOURCE;
6100 -+
6101 -+ blk_mq_request_bypass_insert(rq, run_queue);
6102 -+ return BLK_STS_OK;
6103 -+}
6104 -+
6105 -+static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
6106 -+ struct request *rq, blk_qc_t *cookie)
6107 -+{
6108 -+ blk_status_t ret;
6109 -+ int srcu_idx;
6110 -+
6111 -+ might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
6112 -+
6113 -+ hctx_lock(hctx, &srcu_idx);
6114 -+
6115 -+ ret = __blk_mq_try_issue_directly(hctx, rq, cookie, false, true);
6116 -+ if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE)
6117 -+ blk_mq_request_bypass_insert(rq, true);
6118 -+ else if (ret != BLK_STS_OK)
6119 -+ blk_mq_end_request(rq, ret);
6120 -+
6121 -+ hctx_unlock(hctx, srcu_idx);
6122 -+}
6123 -+
6124 -+blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)
6125 -+{
6126 -+ blk_status_t ret;
6127 -+ int srcu_idx;
6128 -+ blk_qc_t unused_cookie;
6129 -+ struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
6130 -+
6131 -+ hctx_lock(hctx, &srcu_idx);
6132 -+ ret = __blk_mq_try_issue_directly(hctx, rq, &unused_cookie, true, last);
6133 - hctx_unlock(hctx, srcu_idx);
6134 -- switch (ret) {
6135 -- case BLK_STS_OK:
6136 -- break;
6137 -- case BLK_STS_DEV_RESOURCE:
6138 -- case BLK_STS_RESOURCE:
6139 -- if (force) {
6140 -- blk_mq_request_bypass_insert(rq, run_queue);
6141 -- /*
6142 -- * We have to return BLK_STS_OK for the DM
6143 -- * to avoid livelock. Otherwise, we return
6144 -- * the real result to indicate whether the
6145 -- * request is direct-issued successfully.
6146 -- */
6147 -- ret = bypass ? BLK_STS_OK : ret;
6148 -- } else if (!bypass) {
6149 -- blk_mq_sched_insert_request(rq, false,
6150 -- run_queue, false);
6151 -- }
6152 -- break;
6153 -- default:
6154 -- if (!bypass)
6155 -- blk_mq_end_request(rq, ret);
6156 -- break;
6157 -- }
6158 -
6159 - return ret;
6160 - }
6161 -@@ -1871,20 +1882,22 @@ out_unlock:
6162 - void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
6163 - struct list_head *list)
6164 - {
6165 -- blk_qc_t unused;
6166 -- blk_status_t ret = BLK_STS_OK;
6167 --
6168 - while (!list_empty(list)) {
6169 -+ blk_status_t ret;
6170 - struct request *rq = list_first_entry(list, struct request,
6171 - queuelist);
6172 -
6173 - list_del_init(&rq->queuelist);
6174 -- if (ret == BLK_STS_OK)
6175 -- ret = blk_mq_try_issue_directly(hctx, rq, &unused,
6176 -- false,
6177 -+ ret = blk_mq_request_issue_directly(rq, list_empty(list));
6178 -+ if (ret != BLK_STS_OK) {
6179 -+ if (ret == BLK_STS_RESOURCE ||
6180 -+ ret == BLK_STS_DEV_RESOURCE) {
6181 -+ blk_mq_request_bypass_insert(rq,
6182 - list_empty(list));
6183 -- else
6184 -- blk_mq_sched_insert_request(rq, false, true, false);
6185 -+ break;
6186 -+ }
6187 -+ blk_mq_end_request(rq, ret);
6188 -+ }
6189 - }
6190 -
6191 - /*
6192 -@@ -1892,7 +1905,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
6193 - * the driver there was more coming, but that turned out to
6194 - * be a lie.
6195 - */
6196 -- if (ret != BLK_STS_OK && hctx->queue->mq_ops->commit_rqs)
6197 -+ if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs)
6198 - hctx->queue->mq_ops->commit_rqs(hctx);
6199 - }
6200 -
6201 -@@ -2005,13 +2018,13 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
6202 - if (same_queue_rq) {
6203 - data.hctx = same_queue_rq->mq_hctx;
6204 - blk_mq_try_issue_directly(data.hctx, same_queue_rq,
6205 -- &cookie, false, true);
6206 -+ &cookie);
6207 - }
6208 - } else if ((q->nr_hw_queues > 1 && is_sync) || (!q->elevator &&
6209 - !data.hctx->dispatch_busy)) {
6210 - blk_mq_put_ctx(data.ctx);
6211 - blk_mq_bio_to_request(rq, bio);
6212 -- blk_mq_try_issue_directly(data.hctx, rq, &cookie, false, true);
6213 -+ blk_mq_try_issue_directly(data.hctx, rq, &cookie);
6214 - } else {
6215 - blk_mq_put_ctx(data.ctx);
6216 - blk_mq_bio_to_request(rq, bio);
6217 -diff --git a/block/blk-mq.h b/block/blk-mq.h
6218 -index d0b3dd54ef8d..a3a684a8c633 100644
6219 ---- a/block/blk-mq.h
6220 -+++ b/block/blk-mq.h
6221 -@@ -67,10 +67,8 @@ void blk_mq_request_bypass_insert(struct request *rq, bool run_queue);
6222 - void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
6223 - struct list_head *list);
6224 -
6225 --blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
6226 -- struct request *rq,
6227 -- blk_qc_t *cookie,
6228 -- bool bypass, bool last);
6229 -+/* Used by blk_insert_cloned_request() to issue request directly */
6230 -+blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last);
6231 - void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
6232 - struct list_head *list);
6233 -
6234 -diff --git a/crypto/aead.c b/crypto/aead.c
6235 -index 189c52d1f63a..4908b5e846f0 100644
6236 ---- a/crypto/aead.c
6237 -+++ b/crypto/aead.c
6238 -@@ -61,8 +61,10 @@ int crypto_aead_setkey(struct crypto_aead *tfm,
6239 - else
6240 - err = crypto_aead_alg(tfm)->setkey(tfm, key, keylen);
6241 -
6242 -- if (err)
6243 -+ if (unlikely(err)) {
6244 -+ crypto_aead_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
6245 - return err;
6246 -+ }
6247 -
6248 - crypto_aead_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6249 - return 0;
6250 -diff --git a/crypto/aegis128.c b/crypto/aegis128.c
6251 -index c22f4414856d..789716f92e4c 100644
6252 ---- a/crypto/aegis128.c
6253 -+++ b/crypto/aegis128.c
6254 -@@ -290,19 +290,19 @@ static void crypto_aegis128_process_crypt(struct aegis_state *state,
6255 - const struct aegis128_ops *ops)
6256 - {
6257 - struct skcipher_walk walk;
6258 -- u8 *src, *dst;
6259 -- unsigned int chunksize;
6260 -
6261 - ops->skcipher_walk_init(&walk, req, false);
6262 -
6263 - while (walk.nbytes) {
6264 -- src = walk.src.virt.addr;
6265 -- dst = walk.dst.virt.addr;
6266 -- chunksize = walk.nbytes;
6267 -+ unsigned int nbytes = walk.nbytes;
6268 -
6269 -- ops->crypt_chunk(state, dst, src, chunksize);
6270 -+ if (nbytes < walk.total)
6271 -+ nbytes = round_down(nbytes, walk.stride);
6272 -
6273 -- skcipher_walk_done(&walk, 0);
6274 -+ ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
6275 -+ nbytes);
6276 -+
6277 -+ skcipher_walk_done(&walk, walk.nbytes - nbytes);
6278 - }
6279 - }
6280 -
6281 -diff --git a/crypto/aegis128l.c b/crypto/aegis128l.c
6282 -index b6fb21ebdc3e..73811448cb6b 100644
6283 ---- a/crypto/aegis128l.c
6284 -+++ b/crypto/aegis128l.c
6285 -@@ -353,19 +353,19 @@ static void crypto_aegis128l_process_crypt(struct aegis_state *state,
6286 - const struct aegis128l_ops *ops)
6287 - {
6288 - struct skcipher_walk walk;
6289 -- u8 *src, *dst;
6290 -- unsigned int chunksize;
6291 -
6292 - ops->skcipher_walk_init(&walk, req, false);
6293 -
6294 - while (walk.nbytes) {
6295 -- src = walk.src.virt.addr;
6296 -- dst = walk.dst.virt.addr;
6297 -- chunksize = walk.nbytes;
6298 -+ unsigned int nbytes = walk.nbytes;
6299 -
6300 -- ops->crypt_chunk(state, dst, src, chunksize);
6301 -+ if (nbytes < walk.total)
6302 -+ nbytes = round_down(nbytes, walk.stride);
6303 -
6304 -- skcipher_walk_done(&walk, 0);
6305 -+ ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
6306 -+ nbytes);
6307 -+
6308 -+ skcipher_walk_done(&walk, walk.nbytes - nbytes);
6309 - }
6310 - }
6311 -
6312 -diff --git a/crypto/aegis256.c b/crypto/aegis256.c
6313 -index 11f0f8ec9c7c..8a71e9c06193 100644
6314 ---- a/crypto/aegis256.c
6315 -+++ b/crypto/aegis256.c
6316 -@@ -303,19 +303,19 @@ static void crypto_aegis256_process_crypt(struct aegis_state *state,
6317 - const struct aegis256_ops *ops)
6318 - {
6319 - struct skcipher_walk walk;
6320 -- u8 *src, *dst;
6321 -- unsigned int chunksize;
6322 -
6323 - ops->skcipher_walk_init(&walk, req, false);
6324 -
6325 - while (walk.nbytes) {
6326 -- src = walk.src.virt.addr;
6327 -- dst = walk.dst.virt.addr;
6328 -- chunksize = walk.nbytes;
6329 -+ unsigned int nbytes = walk.nbytes;
6330 -
6331 -- ops->crypt_chunk(state, dst, src, chunksize);
6332 -+ if (nbytes < walk.total)
6333 -+ nbytes = round_down(nbytes, walk.stride);
6334 -
6335 -- skcipher_walk_done(&walk, 0);
6336 -+ ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
6337 -+ nbytes);
6338 -+
6339 -+ skcipher_walk_done(&walk, walk.nbytes - nbytes);
6340 - }
6341 - }
6342 -
6343 -diff --git a/crypto/ahash.c b/crypto/ahash.c
6344 -index 5d320a811f75..81e2767e2164 100644
6345 ---- a/crypto/ahash.c
6346 -+++ b/crypto/ahash.c
6347 -@@ -86,17 +86,17 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
6348 - int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
6349 - {
6350 - unsigned int alignmask = walk->alignmask;
6351 -- unsigned int nbytes = walk->entrylen;
6352 -
6353 - walk->data -= walk->offset;
6354 -
6355 -- if (nbytes && walk->offset & alignmask && !err) {
6356 -- walk->offset = ALIGN(walk->offset, alignmask + 1);
6357 -- nbytes = min(nbytes,
6358 -- ((unsigned int)(PAGE_SIZE)) - walk->offset);
6359 -- walk->entrylen -= nbytes;
6360 -+ if (walk->entrylen && (walk->offset & alignmask) && !err) {
6361 -+ unsigned int nbytes;
6362 -
6363 -+ walk->offset = ALIGN(walk->offset, alignmask + 1);
6364 -+ nbytes = min(walk->entrylen,
6365 -+ (unsigned int)(PAGE_SIZE - walk->offset));
6366 - if (nbytes) {
6367 -+ walk->entrylen -= nbytes;
6368 - walk->data += walk->offset;
6369 - return nbytes;
6370 - }
6371 -@@ -116,7 +116,7 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
6372 - if (err)
6373 - return err;
6374 -
6375 -- if (nbytes) {
6376 -+ if (walk->entrylen) {
6377 - walk->offset = 0;
6378 - walk->pg++;
6379 - return hash_walk_next(walk);
6380 -@@ -190,6 +190,21 @@ static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key,
6381 - return ret;
6382 - }
6383 -
6384 -+static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
6385 -+ unsigned int keylen)
6386 -+{
6387 -+ return -ENOSYS;
6388 -+}
6389 -+
6390 -+static void ahash_set_needkey(struct crypto_ahash *tfm)
6391 -+{
6392 -+ const struct hash_alg_common *alg = crypto_hash_alg_common(tfm);
6393 -+
6394 -+ if (tfm->setkey != ahash_nosetkey &&
6395 -+ !(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
6396 -+ crypto_ahash_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
6397 -+}
6398 -+
6399 - int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
6400 - unsigned int keylen)
6401 - {
6402 -@@ -201,20 +216,16 @@ int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
6403 - else
6404 - err = tfm->setkey(tfm, key, keylen);
6405 -
6406 -- if (err)
6407 -+ if (unlikely(err)) {
6408 -+ ahash_set_needkey(tfm);
6409 - return err;
6410 -+ }
6411 -
6412 - crypto_ahash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6413 - return 0;
6414 - }
6415 - EXPORT_SYMBOL_GPL(crypto_ahash_setkey);
6416 -
6417 --static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
6418 -- unsigned int keylen)
6419 --{
6420 -- return -ENOSYS;
6421 --}
6422 --
6423 - static inline unsigned int ahash_align_buffer_size(unsigned len,
6424 - unsigned long mask)
6425 - {
6426 -@@ -489,8 +500,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
6427 -
6428 - if (alg->setkey) {
6429 - hash->setkey = alg->setkey;
6430 -- if (!(alg->halg.base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
6431 -- crypto_ahash_set_flags(hash, CRYPTO_TFM_NEED_KEY);
6432 -+ ahash_set_needkey(hash);
6433 - }
6434 -
6435 - return 0;
6436 -diff --git a/crypto/cfb.c b/crypto/cfb.c
6437 -index e81e45673498..4abfe32ff845 100644
6438 ---- a/crypto/cfb.c
6439 -+++ b/crypto/cfb.c
6440 -@@ -77,12 +77,14 @@ static int crypto_cfb_encrypt_segment(struct skcipher_walk *walk,
6441 - do {
6442 - crypto_cfb_encrypt_one(tfm, iv, dst);
6443 - crypto_xor(dst, src, bsize);
6444 -- memcpy(iv, dst, bsize);
6445 -+ iv = dst;
6446 -
6447 - src += bsize;
6448 - dst += bsize;
6449 - } while ((nbytes -= bsize) >= bsize);
6450 -
6451 -+ memcpy(walk->iv, iv, bsize);
6452 -+
6453 - return nbytes;
6454 - }
6455 -
6456 -@@ -162,7 +164,7 @@ static int crypto_cfb_decrypt_inplace(struct skcipher_walk *walk,
6457 - const unsigned int bsize = crypto_cfb_bsize(tfm);
6458 - unsigned int nbytes = walk->nbytes;
6459 - u8 *src = walk->src.virt.addr;
6460 -- u8 *iv = walk->iv;
6461 -+ u8 * const iv = walk->iv;
6462 - u8 tmp[MAX_CIPHER_BLOCKSIZE];
6463 -
6464 - do {
6465 -@@ -172,8 +174,6 @@ static int crypto_cfb_decrypt_inplace(struct skcipher_walk *walk,
6466 - src += bsize;
6467 - } while ((nbytes -= bsize) >= bsize);
6468 -
6469 -- memcpy(walk->iv, iv, bsize);
6470 --
6471 - return nbytes;
6472 - }
6473 -
6474 -@@ -298,6 +298,12 @@ static int crypto_cfb_create(struct crypto_template *tmpl, struct rtattr **tb)
6475 - inst->alg.base.cra_blocksize = 1;
6476 - inst->alg.base.cra_alignmask = alg->cra_alignmask;
6477 -
6478 -+ /*
6479 -+ * To simplify the implementation, configure the skcipher walk to only
6480 -+ * give a partial block at the very end, never earlier.
6481 -+ */
6482 -+ inst->alg.chunksize = alg->cra_blocksize;
6483 -+
6484 - inst->alg.ivsize = alg->cra_blocksize;
6485 - inst->alg.min_keysize = alg->cra_cipher.cia_min_keysize;
6486 - inst->alg.max_keysize = alg->cra_cipher.cia_max_keysize;
6487 -diff --git a/crypto/morus1280.c b/crypto/morus1280.c
6488 -index 3889c188f266..b83576b4eb55 100644
6489 ---- a/crypto/morus1280.c
6490 -+++ b/crypto/morus1280.c
6491 -@@ -366,18 +366,19 @@ static void crypto_morus1280_process_crypt(struct morus1280_state *state,
6492 - const struct morus1280_ops *ops)
6493 - {
6494 - struct skcipher_walk walk;
6495 -- u8 *dst;
6496 -- const u8 *src;
6497 -
6498 - ops->skcipher_walk_init(&walk, req, false);
6499 -
6500 - while (walk.nbytes) {
6501 -- src = walk.src.virt.addr;
6502 -- dst = walk.dst.virt.addr;
6503 -+ unsigned int nbytes = walk.nbytes;
6504 -
6505 -- ops->crypt_chunk(state, dst, src, walk.nbytes);
6506 -+ if (nbytes < walk.total)
6507 -+ nbytes = round_down(nbytes, walk.stride);
6508 -
6509 -- skcipher_walk_done(&walk, 0);
6510 -+ ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
6511 -+ nbytes);
6512 -+
6513 -+ skcipher_walk_done(&walk, walk.nbytes - nbytes);
6514 - }
6515 - }
6516 -
6517 -diff --git a/crypto/morus640.c b/crypto/morus640.c
6518 -index da06ec2f6a80..b6a477444f6d 100644
6519 ---- a/crypto/morus640.c
6520 -+++ b/crypto/morus640.c
6521 -@@ -365,18 +365,19 @@ static void crypto_morus640_process_crypt(struct morus640_state *state,
6522 - const struct morus640_ops *ops)
6523 - {
6524 - struct skcipher_walk walk;
6525 -- u8 *dst;
6526 -- const u8 *src;
6527 -
6528 - ops->skcipher_walk_init(&walk, req, false);
6529 -
6530 - while (walk.nbytes) {
6531 -- src = walk.src.virt.addr;
6532 -- dst = walk.dst.virt.addr;
6533 -+ unsigned int nbytes = walk.nbytes;
6534 -
6535 -- ops->crypt_chunk(state, dst, src, walk.nbytes);
6536 -+ if (nbytes < walk.total)
6537 -+ nbytes = round_down(nbytes, walk.stride);
6538 -
6539 -- skcipher_walk_done(&walk, 0);
6540 -+ ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
6541 -+ nbytes);
6542 -+
6543 -+ skcipher_walk_done(&walk, walk.nbytes - nbytes);
6544 - }
6545 - }
6546 -
6547 -diff --git a/crypto/ofb.c b/crypto/ofb.c
6548 -index 886631708c5e..cab0b80953fe 100644
6549 ---- a/crypto/ofb.c
6550 -+++ b/crypto/ofb.c
6551 -@@ -5,9 +5,6 @@
6552 - *
6553 - * Copyright (C) 2018 ARM Limited or its affiliates.
6554 - * All rights reserved.
6555 -- *
6556 -- * Based loosely on public domain code gleaned from libtomcrypt
6557 -- * (https://github.com/libtom/libtomcrypt).
6558 - */
6559 -
6560 - #include <crypto/algapi.h>
6561 -@@ -21,7 +18,6 @@
6562 -
6563 - struct crypto_ofb_ctx {
6564 - struct crypto_cipher *child;
6565 -- int cnt;
6566 - };
6567 -
6568 -
6569 -@@ -41,58 +37,40 @@ static int crypto_ofb_setkey(struct crypto_skcipher *parent, const u8 *key,
6570 - return err;
6571 - }
6572 -
6573 --static int crypto_ofb_encrypt_segment(struct crypto_ofb_ctx *ctx,
6574 -- struct skcipher_walk *walk,
6575 -- struct crypto_cipher *tfm)
6576 -+static int crypto_ofb_crypt(struct skcipher_request *req)
6577 - {
6578 -- int bsize = crypto_cipher_blocksize(tfm);
6579 -- int nbytes = walk->nbytes;
6580 --
6581 -- u8 *src = walk->src.virt.addr;
6582 -- u8 *dst = walk->dst.virt.addr;
6583 -- u8 *iv = walk->iv;
6584 --
6585 -- do {
6586 -- if (ctx->cnt == bsize) {
6587 -- if (nbytes < bsize)
6588 -- break;
6589 -- crypto_cipher_encrypt_one(tfm, iv, iv);
6590 -- ctx->cnt = 0;
6591 -- }
6592 -- *dst = *src ^ iv[ctx->cnt];
6593 -- src++;
6594 -- dst++;
6595 -- ctx->cnt++;
6596 -- } while (--nbytes);
6597 -- return nbytes;
6598 --}
6599 --
6600 --static int crypto_ofb_encrypt(struct skcipher_request *req)
6601 --{
6602 -- struct skcipher_walk walk;
6603 - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
6604 -- unsigned int bsize;
6605 - struct crypto_ofb_ctx *ctx = crypto_skcipher_ctx(tfm);
6606 -- struct crypto_cipher *child = ctx->child;
6607 -- int ret = 0;
6608 -+ struct crypto_cipher *cipher = ctx->child;
6609 -+ const unsigned int bsize = crypto_cipher_blocksize(cipher);
6610 -+ struct skcipher_walk walk;
6611 -+ int err;
6612 -
6613 -- bsize = crypto_cipher_blocksize(child);
6614 -- ctx->cnt = bsize;
6615 -+ err = skcipher_walk_virt(&walk, req, false);
6616 -
6617 -- ret = skcipher_walk_virt(&walk, req, false);
6618 -+ while (walk.nbytes >= bsize) {
6619 -+ const u8 *src = walk.src.virt.addr;
6620 -+ u8 *dst = walk.dst.virt.addr;
6621 -+ u8 * const iv = walk.iv;
6622 -+ unsigned int nbytes = walk.nbytes;
6623 -
6624 -- while (walk.nbytes) {
6625 -- ret = crypto_ofb_encrypt_segment(ctx, &walk, child);
6626 -- ret = skcipher_walk_done(&walk, ret);
6627 -- }
6628 -+ do {
6629 -+ crypto_cipher_encrypt_one(cipher, iv, iv);
6630 -+ crypto_xor_cpy(dst, src, iv, bsize);
6631 -+ dst += bsize;
6632 -+ src += bsize;
6633 -+ } while ((nbytes -= bsize) >= bsize);
6634 -
6635 -- return ret;
6636 --}
6637 -+ err = skcipher_walk_done(&walk, nbytes);
6638 -+ }
6639 -
6640 --/* OFB encrypt and decrypt are identical */
6641 --static int crypto_ofb_decrypt(struct skcipher_request *req)
6642 --{
6643 -- return crypto_ofb_encrypt(req);
6644 -+ if (walk.nbytes) {
6645 -+ crypto_cipher_encrypt_one(cipher, walk.iv, walk.iv);
6646 -+ crypto_xor_cpy(walk.dst.virt.addr, walk.src.virt.addr, walk.iv,
6647 -+ walk.nbytes);
6648 -+ err = skcipher_walk_done(&walk, 0);
6649 -+ }
6650 -+ return err;
6651 - }
6652 -
6653 - static int crypto_ofb_init_tfm(struct crypto_skcipher *tfm)
6654 -@@ -165,13 +143,18 @@ static int crypto_ofb_create(struct crypto_template *tmpl, struct rtattr **tb)
6655 - if (err)
6656 - goto err_drop_spawn;
6657 -
6658 -+ /* OFB mode is a stream cipher. */
6659 -+ inst->alg.base.cra_blocksize = 1;
6660 -+
6661 -+ /*
6662 -+ * To simplify the implementation, configure the skcipher walk to only
6663 -+ * give a partial block at the very end, never earlier.
6664 -+ */
6665 -+ inst->alg.chunksize = alg->cra_blocksize;
6666 -+
6667 - inst->alg.base.cra_priority = alg->cra_priority;
6668 -- inst->alg.base.cra_blocksize = alg->cra_blocksize;
6669 - inst->alg.base.cra_alignmask = alg->cra_alignmask;
6670 -
6671 -- /* We access the data as u32s when xoring. */
6672 -- inst->alg.base.cra_alignmask |= __alignof__(u32) - 1;
6673 --
6674 - inst->alg.ivsize = alg->cra_blocksize;
6675 - inst->alg.min_keysize = alg->cra_cipher.cia_min_keysize;
6676 - inst->alg.max_keysize = alg->cra_cipher.cia_max_keysize;
6677 -@@ -182,8 +165,8 @@ static int crypto_ofb_create(struct crypto_template *tmpl, struct rtattr **tb)
6678 - inst->alg.exit = crypto_ofb_exit_tfm;
6679 -
6680 - inst->alg.setkey = crypto_ofb_setkey;
6681 -- inst->alg.encrypt = crypto_ofb_encrypt;
6682 -- inst->alg.decrypt = crypto_ofb_decrypt;
6683 -+ inst->alg.encrypt = crypto_ofb_crypt;
6684 -+ inst->alg.decrypt = crypto_ofb_crypt;
6685 -
6686 - inst->free = crypto_ofb_free;
6687 -
6688 -diff --git a/crypto/pcbc.c b/crypto/pcbc.c
6689 -index 8aa10144407c..1b182dfedc94 100644
6690 ---- a/crypto/pcbc.c
6691 -+++ b/crypto/pcbc.c
6692 -@@ -51,7 +51,7 @@ static int crypto_pcbc_encrypt_segment(struct skcipher_request *req,
6693 - unsigned int nbytes = walk->nbytes;
6694 - u8 *src = walk->src.virt.addr;
6695 - u8 *dst = walk->dst.virt.addr;
6696 -- u8 *iv = walk->iv;
6697 -+ u8 * const iv = walk->iv;
6698 -
6699 - do {
6700 - crypto_xor(iv, src, bsize);
6701 -@@ -72,7 +72,7 @@ static int crypto_pcbc_encrypt_inplace(struct skcipher_request *req,
6702 - int bsize = crypto_cipher_blocksize(tfm);
6703 - unsigned int nbytes = walk->nbytes;
6704 - u8 *src = walk->src.virt.addr;
6705 -- u8 *iv = walk->iv;
6706 -+ u8 * const iv = walk->iv;
6707 - u8 tmpbuf[MAX_CIPHER_BLOCKSIZE];
6708 -
6709 - do {
6710 -@@ -84,8 +84,6 @@ static int crypto_pcbc_encrypt_inplace(struct skcipher_request *req,
6711 - src += bsize;
6712 - } while ((nbytes -= bsize) >= bsize);
6713 -
6714 -- memcpy(walk->iv, iv, bsize);
6715 --
6716 - return nbytes;
6717 - }
6718 -
6719 -@@ -121,7 +119,7 @@ static int crypto_pcbc_decrypt_segment(struct skcipher_request *req,
6720 - unsigned int nbytes = walk->nbytes;
6721 - u8 *src = walk->src.virt.addr;
6722 - u8 *dst = walk->dst.virt.addr;
6723 -- u8 *iv = walk->iv;
6724 -+ u8 * const iv = walk->iv;
6725 -
6726 - do {
6727 - crypto_cipher_decrypt_one(tfm, dst, src);
6728 -@@ -132,8 +130,6 @@ static int crypto_pcbc_decrypt_segment(struct skcipher_request *req,
6729 - dst += bsize;
6730 - } while ((nbytes -= bsize) >= bsize);
6731 -
6732 -- memcpy(walk->iv, iv, bsize);
6733 --
6734 - return nbytes;
6735 - }
6736 -
6737 -@@ -144,7 +140,7 @@ static int crypto_pcbc_decrypt_inplace(struct skcipher_request *req,
6738 - int bsize = crypto_cipher_blocksize(tfm);
6739 - unsigned int nbytes = walk->nbytes;
6740 - u8 *src = walk->src.virt.addr;
6741 -- u8 *iv = walk->iv;
6742 -+ u8 * const iv = walk->iv;
6743 - u8 tmpbuf[MAX_CIPHER_BLOCKSIZE] __aligned(__alignof__(u32));
6744 -
6745 - do {
6746 -@@ -156,8 +152,6 @@ static int crypto_pcbc_decrypt_inplace(struct skcipher_request *req,
6747 - src += bsize;
6748 - } while ((nbytes -= bsize) >= bsize);
6749 -
6750 -- memcpy(walk->iv, iv, bsize);
6751 --
6752 - return nbytes;
6753 - }
6754 -
6755 -diff --git a/crypto/shash.c b/crypto/shash.c
6756 -index 44d297b82a8f..40311ccad3fa 100644
6757 ---- a/crypto/shash.c
6758 -+++ b/crypto/shash.c
6759 -@@ -53,6 +53,13 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
6760 - return err;
6761 - }
6762 -
6763 -+static void shash_set_needkey(struct crypto_shash *tfm, struct shash_alg *alg)
6764 -+{
6765 -+ if (crypto_shash_alg_has_setkey(alg) &&
6766 -+ !(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
6767 -+ crypto_shash_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
6768 -+}
6769 -+
6770 - int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
6771 - unsigned int keylen)
6772 - {
6773 -@@ -65,8 +72,10 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
6774 - else
6775 - err = shash->setkey(tfm, key, keylen);
6776 -
6777 -- if (err)
6778 -+ if (unlikely(err)) {
6779 -+ shash_set_needkey(tfm, shash);
6780 - return err;
6781 -+ }
6782 -
6783 - crypto_shash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6784 - return 0;
6785 -@@ -373,7 +382,8 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
6786 - crt->final = shash_async_final;
6787 - crt->finup = shash_async_finup;
6788 - crt->digest = shash_async_digest;
6789 -- crt->setkey = shash_async_setkey;
6790 -+ if (crypto_shash_alg_has_setkey(alg))
6791 -+ crt->setkey = shash_async_setkey;
6792 -
6793 - crypto_ahash_set_flags(crt, crypto_shash_get_flags(shash) &
6794 - CRYPTO_TFM_NEED_KEY);
6795 -@@ -395,9 +405,7 @@ static int crypto_shash_init_tfm(struct crypto_tfm *tfm)
6796 -
6797 - hash->descsize = alg->descsize;
6798 -
6799 -- if (crypto_shash_alg_has_setkey(alg) &&
6800 -- !(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
6801 -- crypto_shash_set_flags(hash, CRYPTO_TFM_NEED_KEY);
6802 -+ shash_set_needkey(hash, alg);
6803 -
6804 - return 0;
6805 - }
6806 -diff --git a/crypto/skcipher.c b/crypto/skcipher.c
6807 -index 2a969296bc24..de09ff60991e 100644
6808 ---- a/crypto/skcipher.c
6809 -+++ b/crypto/skcipher.c
6810 -@@ -585,6 +585,12 @@ static unsigned int crypto_skcipher_extsize(struct crypto_alg *alg)
6811 - return crypto_alg_extsize(alg);
6812 - }
6813 -
6814 -+static void skcipher_set_needkey(struct crypto_skcipher *tfm)
6815 -+{
6816 -+ if (tfm->keysize)
6817 -+ crypto_skcipher_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
6818 -+}
6819 -+
6820 - static int skcipher_setkey_blkcipher(struct crypto_skcipher *tfm,
6821 - const u8 *key, unsigned int keylen)
6822 - {
6823 -@@ -598,8 +604,10 @@ static int skcipher_setkey_blkcipher(struct crypto_skcipher *tfm,
6824 - err = crypto_blkcipher_setkey(blkcipher, key, keylen);
6825 - crypto_skcipher_set_flags(tfm, crypto_blkcipher_get_flags(blkcipher) &
6826 - CRYPTO_TFM_RES_MASK);
6827 -- if (err)
6828 -+ if (unlikely(err)) {
6829 -+ skcipher_set_needkey(tfm);
6830 - return err;
6831 -+ }
6832 -
6833 - crypto_skcipher_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6834 - return 0;
6835 -@@ -677,8 +685,7 @@ static int crypto_init_skcipher_ops_blkcipher(struct crypto_tfm *tfm)
6836 - skcipher->ivsize = crypto_blkcipher_ivsize(blkcipher);
6837 - skcipher->keysize = calg->cra_blkcipher.max_keysize;
6838 -
6839 -- if (skcipher->keysize)
6840 -- crypto_skcipher_set_flags(skcipher, CRYPTO_TFM_NEED_KEY);
6841 -+ skcipher_set_needkey(skcipher);
6842 -
6843 - return 0;
6844 - }
6845 -@@ -698,8 +705,10 @@ static int skcipher_setkey_ablkcipher(struct crypto_skcipher *tfm,
6846 - crypto_skcipher_set_flags(tfm,
6847 - crypto_ablkcipher_get_flags(ablkcipher) &
6848 - CRYPTO_TFM_RES_MASK);
6849 -- if (err)
6850 -+ if (unlikely(err)) {
6851 -+ skcipher_set_needkey(tfm);
6852 - return err;
6853 -+ }
6854 -
6855 - crypto_skcipher_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6856 - return 0;
6857 -@@ -776,8 +785,7 @@ static int crypto_init_skcipher_ops_ablkcipher(struct crypto_tfm *tfm)
6858 - sizeof(struct ablkcipher_request);
6859 - skcipher->keysize = calg->cra_ablkcipher.max_keysize;
6860 -
6861 -- if (skcipher->keysize)
6862 -- crypto_skcipher_set_flags(skcipher, CRYPTO_TFM_NEED_KEY);
6863 -+ skcipher_set_needkey(skcipher);
6864 -
6865 - return 0;
6866 - }
6867 -@@ -820,8 +828,10 @@ static int skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
6868 - else
6869 - err = cipher->setkey(tfm, key, keylen);
6870 -
6871 -- if (err)
6872 -+ if (unlikely(err)) {
6873 -+ skcipher_set_needkey(tfm);
6874 - return err;
6875 -+ }
6876 -
6877 - crypto_skcipher_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
6878 - return 0;
6879 -@@ -852,8 +862,7 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
6880 - skcipher->ivsize = alg->ivsize;
6881 - skcipher->keysize = alg->max_keysize;
6882 -
6883 -- if (skcipher->keysize)
6884 -- crypto_skcipher_set_flags(skcipher, CRYPTO_TFM_NEED_KEY);
6885 -+ skcipher_set_needkey(skcipher);
6886 -
6887 - if (alg->exit)
6888 - skcipher->base.exit = crypto_skcipher_exit_tfm;
6889 -diff --git a/crypto/testmgr.c b/crypto/testmgr.c
6890 -index 0f684a414acb..b8e4a3ccbfe0 100644
6891 ---- a/crypto/testmgr.c
6892 -+++ b/crypto/testmgr.c
6893 -@@ -1894,14 +1894,21 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
6894 -
6895 - err = alg_test_hash(desc, driver, type, mask);
6896 - if (err)
6897 -- goto out;
6898 -+ return err;
6899 -
6900 - tfm = crypto_alloc_shash(driver, type, mask);
6901 - if (IS_ERR(tfm)) {
6902 -+ if (PTR_ERR(tfm) == -ENOENT) {
6903 -+ /*
6904 -+ * This crc32c implementation is only available through
6905 -+ * ahash API, not the shash API, so the remaining part
6906 -+ * of the test is not applicable to it.
6907 -+ */
6908 -+ return 0;
6909 -+ }
6910 - printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
6911 - "%ld\n", driver, PTR_ERR(tfm));
6912 -- err = PTR_ERR(tfm);
6913 -- goto out;
6914 -+ return PTR_ERR(tfm);
6915 - }
6916 -
6917 - do {
6918 -@@ -1928,7 +1935,6 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
6919 -
6920 - crypto_free_shash(tfm);
6921 -
6922 --out:
6923 - return err;
6924 - }
6925 -
6926 -diff --git a/crypto/testmgr.h b/crypto/testmgr.h
6927 -index e8f47d7b92cd..ca8e8ebef309 100644
6928 ---- a/crypto/testmgr.h
6929 -+++ b/crypto/testmgr.h
6930 -@@ -12870,6 +12870,31 @@ static const struct cipher_testvec aes_cfb_tv_template[] = {
6931 - "\x75\xa3\x85\x74\x1a\xb9\xce\xf8"
6932 - "\x20\x31\x62\x3d\x55\xb1\xe4\x71",
6933 - .len = 64,
6934 -+ .also_non_np = 1,
6935 -+ .np = 2,
6936 -+ .tap = { 31, 33 },
6937 -+ }, { /* > 16 bytes, not a multiple of 16 bytes */
6938 -+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
6939 -+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
6940 -+ .klen = 16,
6941 -+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
6942 -+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
6943 -+ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
6944 -+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
6945 -+ "\xae",
6946 -+ .ctext = "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20"
6947 -+ "\x33\x34\x49\xf8\xe8\x3c\xfb\x4a"
6948 -+ "\xc8",
6949 -+ .len = 17,
6950 -+ }, { /* < 16 bytes */
6951 -+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
6952 -+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
6953 -+ .klen = 16,
6954 -+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
6955 -+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
6956 -+ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f",
6957 -+ .ctext = "\x3b\x3f\xd9\x2e\xb7\x2d\xad",
6958 -+ .len = 7,
6959 - },
6960 - };
6961 -
6962 -@@ -16656,8 +16681,7 @@ static const struct cipher_testvec aes_ctr_rfc3686_tv_template[] = {
6963 - };
6964 -
6965 - static const struct cipher_testvec aes_ofb_tv_template[] = {
6966 -- /* From NIST Special Publication 800-38A, Appendix F.5 */
6967 -- {
6968 -+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
6969 - .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
6970 - "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
6971 - .klen = 16,
6972 -@@ -16680,6 +16704,31 @@ static const struct cipher_testvec aes_ofb_tv_template[] = {
6973 - "\x30\x4c\x65\x28\xf6\x59\xc7\x78"
6974 - "\x66\xa5\x10\xd9\xc1\xd6\xae\x5e",
6975 - .len = 64,
6976 -+ .also_non_np = 1,
6977 -+ .np = 2,
6978 -+ .tap = { 31, 33 },
6979 -+ }, { /* > 16 bytes, not a multiple of 16 bytes */
6980 -+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
6981 -+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
6982 -+ .klen = 16,
6983 -+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
6984 -+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
6985 -+ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
6986 -+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
6987 -+ "\xae",
6988 -+ .ctext = "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20"
6989 -+ "\x33\x34\x49\xf8\xe8\x3c\xfb\x4a"
6990 -+ "\x77",
6991 -+ .len = 17,
6992 -+ }, { /* < 16 bytes */
6993 -+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
6994 -+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
6995 -+ .klen = 16,
6996 -+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
6997 -+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
6998 -+ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f",
6999 -+ .ctext = "\x3b\x3f\xd9\x2e\xb7\x2d\xad",
7000 -+ .len = 7,
7001 - }
7002 - };
7003 -
7004 -diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
7005 -index f0b52266b3ac..d73afb562ad9 100644
7006 ---- a/drivers/acpi/acpi_video.c
7007 -+++ b/drivers/acpi/acpi_video.c
7008 -@@ -2124,21 +2124,29 @@ static int __init intel_opregion_present(void)
7009 - return opregion;
7010 - }
7011 -
7012 -+/* Check if the chassis-type indicates there is no builtin LCD panel */
7013 - static bool dmi_is_desktop(void)
7014 - {
7015 - const char *chassis_type;
7016 -+ unsigned long type;
7017 -
7018 - chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
7019 - if (!chassis_type)
7020 - return false;
7021 -
7022 -- if (!strcmp(chassis_type, "3") || /* 3: Desktop */
7023 -- !strcmp(chassis_type, "4") || /* 4: Low Profile Desktop */
7024 -- !strcmp(chassis_type, "5") || /* 5: Pizza Box */
7025 -- !strcmp(chassis_type, "6") || /* 6: Mini Tower */
7026 -- !strcmp(chassis_type, "7") || /* 7: Tower */
7027 -- !strcmp(chassis_type, "11")) /* 11: Main Server Chassis */
7028 -+ if (kstrtoul(chassis_type, 10, &type) != 0)
7029 -+ return false;
7030 -+
7031 -+ switch (type) {
7032 -+ case 0x03: /* Desktop */
7033 -+ case 0x04: /* Low Profile Desktop */
7034 -+ case 0x05: /* Pizza Box */
7035 -+ case 0x06: /* Mini Tower */
7036 -+ case 0x07: /* Tower */
7037 -+ case 0x10: /* Lunch Box */
7038 -+ case 0x11: /* Main Server Chassis */
7039 - return true;
7040 -+ }
7041 -
7042 - return false;
7043 - }
7044 -diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
7045 -index e10fec99a182..4424997ecf30 100644
7046 ---- a/drivers/acpi/acpica/evgpe.c
7047 -+++ b/drivers/acpi/acpica/evgpe.c
7048 -@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
7049 -
7050 - ACPI_FUNCTION_TRACE(ev_enable_gpe);
7051 -
7052 -- /* Enable the requested GPE */
7053 -+ /* Clear the GPE status */
7054 -+ status = acpi_hw_clear_gpe(gpe_event_info);
7055 -+ if (ACPI_FAILURE(status))
7056 -+ return_ACPI_STATUS(status);
7057 -
7058 -+ /* Enable the requested GPE */
7059 - status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
7060 - return_ACPI_STATUS(status);
7061 - }
7062 -diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
7063 -index 8638f43cfc3d..79d86da1c892 100644
7064 ---- a/drivers/acpi/acpica/nsobject.c
7065 -+++ b/drivers/acpi/acpica/nsobject.c
7066 -@@ -186,6 +186,10 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
7067 - }
7068 - }
7069 -
7070 -+ if (obj_desc->common.type == ACPI_TYPE_REGION) {
7071 -+ acpi_ut_remove_address_range(obj_desc->region.space_id, node);
7072 -+ }
7073 -+
7074 - /* Clear the Node entry in all cases */
7075 -
7076 - node->object = NULL;
7077 -diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
7078 -index 217a782c3e55..7aa08884ed48 100644
7079 ---- a/drivers/acpi/cppc_acpi.c
7080 -+++ b/drivers/acpi/cppc_acpi.c
7081 -@@ -1108,8 +1108,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
7082 - cpc_read(cpunum, nominal_reg, &nom);
7083 - perf_caps->nominal_perf = nom;
7084 -
7085 -- cpc_read(cpunum, guaranteed_reg, &guaranteed);
7086 -- perf_caps->guaranteed_perf = guaranteed;
7087 -+ if (guaranteed_reg->type != ACPI_TYPE_BUFFER ||
7088 -+ IS_NULL_REG(&guaranteed_reg->cpc_entry.reg)) {
7089 -+ perf_caps->guaranteed_perf = 0;
7090 -+ } else {
7091 -+ cpc_read(cpunum, guaranteed_reg, &guaranteed);
7092 -+ perf_caps->guaranteed_perf = guaranteed;
7093 -+ }
7094 -
7095 - cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear);
7096 - perf_caps->lowest_nonlinear_perf = min_nonlinear;
7097 -diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
7098 -index 545e91420cde..8940054d6250 100644
7099 ---- a/drivers/acpi/device_sysfs.c
7100 -+++ b/drivers/acpi/device_sysfs.c
7101 -@@ -202,11 +202,15 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
7102 - {
7103 - struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
7104 - const union acpi_object *of_compatible, *obj;
7105 -+ acpi_status status;
7106 - int len, count;
7107 - int i, nval;
7108 - char *c;
7109 -
7110 -- acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
7111 -+ status = acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
7112 -+ if (ACPI_FAILURE(status))
7113 -+ return -ENODEV;
7114 -+
7115 - /* DT strings are all in lower case */
7116 - for (c = buf.pointer; *c != '\0'; c++)
7117 - *c = tolower(*c);
7118 -diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
7119 -index e18ade5d74e9..f75f8f870ce3 100644
7120 ---- a/drivers/acpi/nfit/core.c
7121 -+++ b/drivers/acpi/nfit/core.c
7122 -@@ -415,7 +415,7 @@ static int cmd_to_func(struct nfit_mem *nfit_mem, unsigned int cmd,
7123 - if (call_pkg) {
7124 - int i;
7125 -
7126 -- if (nfit_mem->family != call_pkg->nd_family)
7127 -+ if (nfit_mem && nfit_mem->family != call_pkg->nd_family)
7128 - return -ENOTTY;
7129 -
7130 - for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++)
7131 -@@ -424,6 +424,10 @@ static int cmd_to_func(struct nfit_mem *nfit_mem, unsigned int cmd,
7132 - return call_pkg->nd_command;
7133 - }
7134 -
7135 -+ /* In the !call_pkg case, bus commands == bus functions */
7136 -+ if (!nfit_mem)
7137 -+ return cmd;
7138 -+
7139 - /* Linux ND commands == NVDIMM_FAMILY_INTEL function numbers */
7140 - if (nfit_mem->family == NVDIMM_FAMILY_INTEL)
7141 - return cmd;
7142 -@@ -454,17 +458,18 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
7143 - if (cmd_rc)
7144 - *cmd_rc = -EINVAL;
7145 -
7146 -+ if (cmd == ND_CMD_CALL)
7147 -+ call_pkg = buf;
7148 -+ func = cmd_to_func(nfit_mem, cmd, call_pkg);
7149 -+ if (func < 0)
7150 -+ return func;
7151 -+
7152 - if (nvdimm) {
7153 - struct acpi_device *adev = nfit_mem->adev;
7154 -
7155 - if (!adev)
7156 - return -ENOTTY;
7157 -
7158 -- if (cmd == ND_CMD_CALL)
7159 -- call_pkg = buf;
7160 -- func = cmd_to_func(nfit_mem, cmd, call_pkg);
7161 -- if (func < 0)
7162 -- return func;
7163 - dimm_name = nvdimm_name(nvdimm);
7164 - cmd_name = nvdimm_cmd_name(cmd);
7165 - cmd_mask = nvdimm_cmd_mask(nvdimm);
7166 -@@ -475,12 +480,9 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
7167 - } else {
7168 - struct acpi_device *adev = to_acpi_dev(acpi_desc);
7169 -
7170 -- func = cmd;
7171 - cmd_name = nvdimm_bus_cmd_name(cmd);
7172 - cmd_mask = nd_desc->cmd_mask;
7173 -- dsm_mask = cmd_mask;
7174 -- if (cmd == ND_CMD_CALL)
7175 -- dsm_mask = nd_desc->bus_dsm_mask;
7176 -+ dsm_mask = nd_desc->bus_dsm_mask;
7177 - desc = nd_cmd_bus_desc(cmd);
7178 - guid = to_nfit_uuid(NFIT_DEV_BUS);
7179 - handle = adev->handle;
7180 -@@ -554,6 +556,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
7181 - return -EINVAL;
7182 - }
7183 -
7184 -+ if (out_obj->type != ACPI_TYPE_BUFFER) {
7185 -+ dev_dbg(dev, "%s unexpected output object type cmd: %s type: %d\n",
7186 -+ dimm_name, cmd_name, out_obj->type);
7187 -+ rc = -EINVAL;
7188 -+ goto out;
7189 -+ }
7190 -+
7191 - if (call_pkg) {
7192 - call_pkg->nd_fw_size = out_obj->buffer.length;
7193 - memcpy(call_pkg->nd_payload + call_pkg->nd_size_in,
7194 -@@ -572,13 +581,6 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
7195 - return 0;
7196 - }
7197 -
7198 -- if (out_obj->package.type != ACPI_TYPE_BUFFER) {
7199 -- dev_dbg(dev, "%s unexpected output object type cmd: %s type: %d\n",
7200 -- dimm_name, cmd_name, out_obj->type);
7201 -- rc = -EINVAL;
7202 -- goto out;
7203 -- }
7204 --
7205 - dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
7206 - cmd_name, out_obj->buffer.length);
7207 - print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
7208 -@@ -1759,14 +1761,14 @@ static bool acpi_nvdimm_has_method(struct acpi_device *adev, char *method)
7209 -
7210 - __weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
7211 - {
7212 -+ struct device *dev = &nfit_mem->adev->dev;
7213 - struct nd_intel_smart smart = { 0 };
7214 - union acpi_object in_buf = {
7215 -- .type = ACPI_TYPE_BUFFER,
7216 -- .buffer.pointer = (char *) &smart,
7217 -- .buffer.length = sizeof(smart),
7218 -+ .buffer.type = ACPI_TYPE_BUFFER,
7219 -+ .buffer.length = 0,
7220 - };
7221 - union acpi_object in_obj = {
7222 -- .type = ACPI_TYPE_PACKAGE,
7223 -+ .package.type = ACPI_TYPE_PACKAGE,
7224 - .package.count = 1,
7225 - .package.elements = &in_buf,
7226 - };
7227 -@@ -1781,8 +1783,15 @@ __weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
7228 - return;
7229 -
7230 - out_obj = acpi_evaluate_dsm(handle, guid, revid, func, &in_obj);
7231 -- if (!out_obj)
7232 -+ if (!out_obj || out_obj->type != ACPI_TYPE_BUFFER
7233 -+ || out_obj->buffer.length < sizeof(smart)) {
7234 -+ dev_dbg(dev->parent, "%s: failed to retrieve initial health\n",
7235 -+ dev_name(dev));
7236 -+ ACPI_FREE(out_obj);
7237 - return;
7238 -+ }
7239 -+ memcpy(&smart, out_obj->buffer.pointer, sizeof(smart));
7240 -+ ACPI_FREE(out_obj);
7241 -
7242 - if (smart.flags & ND_INTEL_SMART_SHUTDOWN_VALID) {
7243 - if (smart.shutdown_state)
7244 -@@ -1793,7 +1802,6 @@ __weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
7245 - set_bit(NFIT_MEM_DIRTY_COUNT, &nfit_mem->flags);
7246 - nfit_mem->dirty_shutdown = smart.shutdown_count;
7247 - }
7248 -- ACPI_FREE(out_obj);
7249 - }
7250 -
7251 - static void populate_shutdown_status(struct nfit_mem *nfit_mem)
7252 -@@ -1915,18 +1923,19 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
7253 - | 1 << ND_CMD_SET_CONFIG_DATA;
7254 - if (family == NVDIMM_FAMILY_INTEL
7255 - && (dsm_mask & label_mask) == label_mask)
7256 -- return 0;
7257 --
7258 -- if (acpi_nvdimm_has_method(adev_dimm, "_LSI")
7259 -- && acpi_nvdimm_has_method(adev_dimm, "_LSR")) {
7260 -- dev_dbg(dev, "%s: has _LSR\n", dev_name(&adev_dimm->dev));
7261 -- set_bit(NFIT_MEM_LSR, &nfit_mem->flags);
7262 -- }
7263 -+ /* skip _LS{I,R,W} enabling */;
7264 -+ else {
7265 -+ if (acpi_nvdimm_has_method(adev_dimm, "_LSI")
7266 -+ && acpi_nvdimm_has_method(adev_dimm, "_LSR")) {
7267 -+ dev_dbg(dev, "%s: has _LSR\n", dev_name(&adev_dimm->dev));
7268 -+ set_bit(NFIT_MEM_LSR, &nfit_mem->flags);
7269 -+ }
7270 -
7271 -- if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags)
7272 -- && acpi_nvdimm_has_method(adev_dimm, "_LSW")) {
7273 -- dev_dbg(dev, "%s: has _LSW\n", dev_name(&adev_dimm->dev));
7274 -- set_bit(NFIT_MEM_LSW, &nfit_mem->flags);
7275 -+ if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags)
7276 -+ && acpi_nvdimm_has_method(adev_dimm, "_LSW")) {
7277 -+ dev_dbg(dev, "%s: has _LSW\n", dev_name(&adev_dimm->dev));
7278 -+ set_bit(NFIT_MEM_LSW, &nfit_mem->flags);
7279 -+ }
7280 - }
7281 -
7282 - populate_shutdown_status(nfit_mem);
7283 -@@ -3004,14 +3013,16 @@ static int ars_register(struct acpi_nfit_desc *acpi_desc,
7284 - {
7285 - int rc;
7286 -
7287 -- if (no_init_ars || test_bit(ARS_FAILED, &nfit_spa->ars_state))
7288 -+ if (test_bit(ARS_FAILED, &nfit_spa->ars_state))
7289 - return acpi_nfit_register_region(acpi_desc, nfit_spa);
7290 -
7291 - set_bit(ARS_REQ_SHORT, &nfit_spa->ars_state);
7292 -- set_bit(ARS_REQ_LONG, &nfit_spa->ars_state);
7293 -+ if (!no_init_ars)
7294 -+ set_bit(ARS_REQ_LONG, &nfit_spa->ars_state);
7295 -
7296 - switch (acpi_nfit_query_poison(acpi_desc)) {
7297 - case 0:
7298 -+ case -ENOSPC:
7299 - case -EAGAIN:
7300 - rc = ars_start(acpi_desc, nfit_spa, ARS_REQ_SHORT);
7301 - /* shouldn't happen, try again later */
7302 -@@ -3036,7 +3047,6 @@ static int ars_register(struct acpi_nfit_desc *acpi_desc,
7303 - break;
7304 - case -EBUSY:
7305 - case -ENOMEM:
7306 -- case -ENOSPC:
7307 - /*
7308 - * BIOS was using ARS, wait for it to complete (or
7309 - * resources to become available) and then perform our
7310 -diff --git a/drivers/android/binder.c b/drivers/android/binder.c
7311 -index 4d2b2ad1ee0e..01f80cbd2741 100644
7312 ---- a/drivers/android/binder.c
7313 -+++ b/drivers/android/binder.c
7314 -@@ -329,6 +329,8 @@ struct binder_error {
7315 - * (invariant after initialized)
7316 - * @min_priority: minimum scheduling priority
7317 - * (invariant after initialized)
7318 -+ * @txn_security_ctx: require sender's security context
7319 -+ * (invariant after initialized)
7320 - * @async_todo: list of async work items
7321 - * (protected by @proc->inner_lock)
7322 - *
7323 -@@ -365,6 +367,7 @@ struct binder_node {
7324 - * invariant after initialization
7325 - */
7326 - u8 accept_fds:1;
7327 -+ u8 txn_security_ctx:1;
7328 - u8 min_priority;
7329 - };
7330 - bool has_async_transaction;
7331 -@@ -615,6 +618,7 @@ struct binder_transaction {
7332 - long saved_priority;
7333 - kuid_t sender_euid;
7334 - struct list_head fd_fixups;
7335 -+ binder_uintptr_t security_ctx;
7336 - /**
7337 - * @lock: protects @from, @to_proc, and @to_thread
7338 - *
7339 -@@ -1152,6 +1156,7 @@ static struct binder_node *binder_init_node_ilocked(
7340 - node->work.type = BINDER_WORK_NODE;
7341 - node->min_priority = flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
7342 - node->accept_fds = !!(flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
7343 -+ node->txn_security_ctx = !!(flags & FLAT_BINDER_FLAG_TXN_SECURITY_CTX);
7344 - spin_lock_init(&node->lock);
7345 - INIT_LIST_HEAD(&node->work.entry);
7346 - INIT_LIST_HEAD(&node->async_todo);
7347 -@@ -2778,6 +2783,8 @@ static void binder_transaction(struct binder_proc *proc,
7348 - binder_size_t last_fixup_min_off = 0;
7349 - struct binder_context *context = proc->context;
7350 - int t_debug_id = atomic_inc_return(&binder_last_id);
7351 -+ char *secctx = NULL;
7352 -+ u32 secctx_sz = 0;
7353 -
7354 - e = binder_transaction_log_add(&binder_transaction_log);
7355 - e->debug_id = t_debug_id;
7356 -@@ -3020,6 +3027,20 @@ static void binder_transaction(struct binder_proc *proc,
7357 - t->flags = tr->flags;
7358 - t->priority = task_nice(current);
7359 -
7360 -+ if (target_node && target_node->txn_security_ctx) {
7361 -+ u32 secid;
7362 -+
7363 -+ security_task_getsecid(proc->tsk, &secid);
7364 -+ ret = security_secid_to_secctx(secid, &secctx, &secctx_sz);
7365 -+ if (ret) {
7366 -+ return_error = BR_FAILED_REPLY;
7367 -+ return_error_param = ret;
7368 -+ return_error_line = __LINE__;
7369 -+ goto err_get_secctx_failed;
7370 -+ }
7371 -+ extra_buffers_size += ALIGN(secctx_sz, sizeof(u64));
7372 -+ }
7373 -+
7374 - trace_binder_transaction(reply, t, target_node);
7375 -
7376 - t->buffer = binder_alloc_new_buf(&target_proc->alloc, tr->data_size,
7377 -@@ -3036,6 +3057,19 @@ static void binder_transaction(struct binder_proc *proc,
7378 - t->buffer = NULL;
7379 - goto err_binder_alloc_buf_failed;
7380 - }
7381 -+ if (secctx) {
7382 -+ size_t buf_offset = ALIGN(tr->data_size, sizeof(void *)) +
7383 -+ ALIGN(tr->offsets_size, sizeof(void *)) +
7384 -+ ALIGN(extra_buffers_size, sizeof(void *)) -
7385 -+ ALIGN(secctx_sz, sizeof(u64));
7386 -+ char *kptr = t->buffer->data + buf_offset;
7387 -+
7388 -+ t->security_ctx = (uintptr_t)kptr +
7389 -+ binder_alloc_get_user_buffer_offset(&target_proc->alloc);
7390 -+ memcpy(kptr, secctx, secctx_sz);
7391 -+ security_release_secctx(secctx, secctx_sz);
7392 -+ secctx = NULL;
7393 -+ }
7394 - t->buffer->debug_id = t->debug_id;
7395 - t->buffer->transaction = t;
7396 - t->buffer->target_node = target_node;
7397 -@@ -3305,6 +3339,9 @@ err_copy_data_failed:
7398 - t->buffer->transaction = NULL;
7399 - binder_alloc_free_buf(&target_proc->alloc, t->buffer);
7400 - err_binder_alloc_buf_failed:
7401 -+ if (secctx)
7402 -+ security_release_secctx(secctx, secctx_sz);
7403 -+err_get_secctx_failed:
7404 - kfree(tcomplete);
7405 - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
7406 - err_alloc_tcomplete_failed:
7407 -@@ -4036,11 +4073,13 @@ retry:
7408 -
7409 - while (1) {
7410 - uint32_t cmd;
7411 -- struct binder_transaction_data tr;
7412 -+ struct binder_transaction_data_secctx tr;
7413 -+ struct binder_transaction_data *trd = &tr.transaction_data;
7414 - struct binder_work *w = NULL;
7415 - struct list_head *list = NULL;
7416 - struct binder_transaction *t = NULL;
7417 - struct binder_thread *t_from;
7418 -+ size_t trsize = sizeof(*trd);
7419 -
7420 - binder_inner_proc_lock(proc);
7421 - if (!binder_worklist_empty_ilocked(&thread->todo))
7422 -@@ -4240,8 +4279,8 @@ retry:
7423 - if (t->buffer->target_node) {
7424 - struct binder_node *target_node = t->buffer->target_node;
7425 -
7426 -- tr.target.ptr = target_node->ptr;
7427 -- tr.cookie = target_node->cookie;
7428 -+ trd->target.ptr = target_node->ptr;
7429 -+ trd->cookie = target_node->cookie;
7430 - t->saved_priority = task_nice(current);
7431 - if (t->priority < target_node->min_priority &&
7432 - !(t->flags & TF_ONE_WAY))
7433 -@@ -4251,22 +4290,23 @@ retry:
7434 - binder_set_nice(target_node->min_priority);
7435 - cmd = BR_TRANSACTION;
7436 - } else {
7437 -- tr.target.ptr = 0;
7438 -- tr.cookie = 0;
7439 -+ trd->target.ptr = 0;
7440 -+ trd->cookie = 0;
7441 - cmd = BR_REPLY;
7442 - }
7443 -- tr.code = t->code;
7444 -- tr.flags = t->flags;
7445 -- tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid);
7446 -+ trd->code = t->code;
7447 -+ trd->flags = t->flags;
7448 -+ trd->sender_euid = from_kuid(current_user_ns(), t->sender_euid);
7449 -
7450 - t_from = binder_get_txn_from(t);
7451 - if (t_from) {
7452 - struct task_struct *sender = t_from->proc->tsk;
7453 -
7454 -- tr.sender_pid = task_tgid_nr_ns(sender,
7455 -- task_active_pid_ns(current));
7456 -+ trd->sender_pid =
7457 -+ task_tgid_nr_ns(sender,
7458 -+ task_active_pid_ns(current));
7459 - } else {
7460 -- tr.sender_pid = 0;
7461 -+ trd->sender_pid = 0;
7462 - }
7463 -
7464 - ret = binder_apply_fd_fixups(t);
7465 -@@ -4297,15 +4337,20 @@ retry:
7466 - }
7467 - continue;
7468 - }
7469 -- tr.data_size = t->buffer->data_size;
7470 -- tr.offsets_size = t->buffer->offsets_size;
7471 -- tr.data.ptr.buffer = (binder_uintptr_t)
7472 -+ trd->data_size = t->buffer->data_size;
7473 -+ trd->offsets_size = t->buffer->offsets_size;
7474 -+ trd->data.ptr.buffer = (binder_uintptr_t)
7475 - ((uintptr_t)t->buffer->data +
7476 - binder_alloc_get_user_buffer_offset(&proc->alloc));
7477 -- tr.data.ptr.offsets = tr.data.ptr.buffer +
7478 -+ trd->data.ptr.offsets = trd->data.ptr.buffer +
7479 - ALIGN(t->buffer->data_size,
7480 - sizeof(void *));
7481 -
7482 -+ tr.secctx = t->security_ctx;
7483 -+ if (t->security_ctx) {
7484 -+ cmd = BR_TRANSACTION_SEC_CTX;
7485 -+ trsize = sizeof(tr);
7486 -+ }
7487 - if (put_user(cmd, (uint32_t __user *)ptr)) {
7488 - if (t_from)
7489 - binder_thread_dec_tmpref(t_from);
7490 -@@ -4316,7 +4361,7 @@ retry:
7491 - return -EFAULT;
7492 - }
7493 - ptr += sizeof(uint32_t);
7494 -- if (copy_to_user(ptr, &tr, sizeof(tr))) {
7495 -+ if (copy_to_user(ptr, &tr, trsize)) {
7496 - if (t_from)
7497 - binder_thread_dec_tmpref(t_from);
7498 -
7499 -@@ -4325,7 +4370,7 @@ retry:
7500 -
7501 - return -EFAULT;
7502 - }
7503 -- ptr += sizeof(tr);
7504 -+ ptr += trsize;
7505 -
7506 - trace_binder_transaction_received(t);
7507 - binder_stat_br(proc, thread, cmd);
7508 -@@ -4333,16 +4378,18 @@ retry:
7509 - "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
7510 - proc->pid, thread->pid,
7511 - (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
7512 -- "BR_REPLY",
7513 -+ (cmd == BR_TRANSACTION_SEC_CTX) ?
7514 -+ "BR_TRANSACTION_SEC_CTX" : "BR_REPLY",
7515 - t->debug_id, t_from ? t_from->proc->pid : 0,
7516 - t_from ? t_from->pid : 0, cmd,
7517 - t->buffer->data_size, t->buffer->offsets_size,
7518 -- (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets);
7519 -+ (u64)trd->data.ptr.buffer,
7520 -+ (u64)trd->data.ptr.offsets);
7521 -
7522 - if (t_from)
7523 - binder_thread_dec_tmpref(t_from);
7524 - t->buffer->allow_user_free = 1;
7525 -- if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) {
7526 -+ if (cmd != BR_REPLY && !(t->flags & TF_ONE_WAY)) {
7527 - binder_inner_proc_lock(thread->proc);
7528 - t->to_parent = thread->transaction_stack;
7529 - t->to_thread = thread;
7530 -@@ -4690,7 +4737,8 @@ out:
7531 - return ret;
7532 - }
7533 -
7534 --static int binder_ioctl_set_ctx_mgr(struct file *filp)
7535 -+static int binder_ioctl_set_ctx_mgr(struct file *filp,
7536 -+ struct flat_binder_object *fbo)
7537 - {
7538 - int ret = 0;
7539 - struct binder_proc *proc = filp->private_data;
7540 -@@ -4719,7 +4767,7 @@ static int binder_ioctl_set_ctx_mgr(struct file *filp)
7541 - } else {
7542 - context->binder_context_mgr_uid = curr_euid;
7543 - }
7544 -- new_node = binder_new_node(proc, NULL);
7545 -+ new_node = binder_new_node(proc, fbo);
7546 - if (!new_node) {
7547 - ret = -ENOMEM;
7548 - goto out;
7549 -@@ -4842,8 +4890,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7550 - binder_inner_proc_unlock(proc);
7551 - break;
7552 - }
7553 -+ case BINDER_SET_CONTEXT_MGR_EXT: {
7554 -+ struct flat_binder_object fbo;
7555 -+
7556 -+ if (copy_from_user(&fbo, ubuf, sizeof(fbo))) {
7557 -+ ret = -EINVAL;
7558 -+ goto err;
7559 -+ }
7560 -+ ret = binder_ioctl_set_ctx_mgr(filp, &fbo);
7561 -+ if (ret)
7562 -+ goto err;
7563 -+ break;
7564 -+ }
7565 - case BINDER_SET_CONTEXT_MGR:
7566 -- ret = binder_ioctl_set_ctx_mgr(filp);
7567 -+ ret = binder_ioctl_set_ctx_mgr(filp, NULL);
7568 - if (ret)
7569 - goto err;
7570 - break;
7571 -diff --git a/drivers/base/dd.c b/drivers/base/dd.c
7572 -index 8ac10af17c00..d62487d02455 100644
7573 ---- a/drivers/base/dd.c
7574 -+++ b/drivers/base/dd.c
7575 -@@ -968,9 +968,9 @@ static void __device_release_driver(struct device *dev, struct device *parent)
7576 - drv->remove(dev);
7577 -
7578 - device_links_driver_cleanup(dev);
7579 -- arch_teardown_dma_ops(dev);
7580 -
7581 - devres_release_all(dev);
7582 -+ arch_teardown_dma_ops(dev);
7583 - dev->driver = NULL;
7584 - dev_set_drvdata(dev, NULL);
7585 - if (dev->pm_domain && dev->pm_domain->dismiss)
7586 -diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
7587 -index 5fa1898755a3..7c84f64c74f7 100644
7588 ---- a/drivers/base/power/wakeup.c
7589 -+++ b/drivers/base/power/wakeup.c
7590 -@@ -118,7 +118,6 @@ void wakeup_source_drop(struct wakeup_source *ws)
7591 - if (!ws)
7592 - return;
7593 -
7594 -- del_timer_sync(&ws->timer);
7595 - __pm_relax(ws);
7596 - }
7597 - EXPORT_SYMBOL_GPL(wakeup_source_drop);
7598 -@@ -205,6 +204,13 @@ void wakeup_source_remove(struct wakeup_source *ws)
7599 - list_del_rcu(&ws->entry);
7600 - raw_spin_unlock_irqrestore(&events_lock, flags);
7601 - synchronize_srcu(&wakeup_srcu);
7602 -+
7603 -+ del_timer_sync(&ws->timer);
7604 -+ /*
7605 -+ * Clear timer.function to make wakeup_source_not_registered() treat
7606 -+ * this wakeup source as not registered.
7607 -+ */
7608 -+ ws->timer.function = NULL;
7609 - }
7610 - EXPORT_SYMBOL_GPL(wakeup_source_remove);
7611 -
7612 -diff --git a/drivers/block/loop.c b/drivers/block/loop.c
7613 -index cf5538942834..9a8d83bc1e75 100644
7614 ---- a/drivers/block/loop.c
7615 -+++ b/drivers/block/loop.c
7616 -@@ -656,7 +656,7 @@ static int loop_validate_file(struct file *file, struct block_device *bdev)
7617 - return -EBADF;
7618 -
7619 - l = f->f_mapping->host->i_bdev->bd_disk->private_data;
7620 -- if (l->lo_state == Lo_unbound) {
7621 -+ if (l->lo_state != Lo_bound) {
7622 - return -EINVAL;
7623 - }
7624 - f = l->lo_backing_file;
7625 -@@ -1089,16 +1089,12 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
7626 - kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
7627 - }
7628 - mapping_set_gfp_mask(filp->f_mapping, gfp);
7629 -- lo->lo_state = Lo_unbound;
7630 - /* This is safe: open() is still holding a reference. */
7631 - module_put(THIS_MODULE);
7632 - blk_mq_unfreeze_queue(lo->lo_queue);
7633 -
7634 - partscan = lo->lo_flags & LO_FLAGS_PARTSCAN && bdev;
7635 - lo_number = lo->lo_number;
7636 -- lo->lo_flags = 0;
7637 -- if (!part_shift)
7638 -- lo->lo_disk->flags |= GENHD_FL_NO_PART_SCAN;
7639 - loop_unprepare_queue(lo);
7640 - out_unlock:
7641 - mutex_unlock(&loop_ctl_mutex);
7642 -@@ -1120,6 +1116,23 @@ out_unlock:
7643 - /* Device is gone, no point in returning error */
7644 - err = 0;
7645 - }
7646 -+
7647 -+ /*
7648 -+ * lo->lo_state is set to Lo_unbound here after above partscan has
7649 -+ * finished.
7650 -+ *
7651 -+ * There cannot be anybody else entering __loop_clr_fd() as
7652 -+ * lo->lo_backing_file is already cleared and Lo_rundown state
7653 -+ * protects us from all the other places trying to change the 'lo'
7654 -+ * device.
7655 -+ */
7656 -+ mutex_lock(&loop_ctl_mutex);
7657 -+ lo->lo_flags = 0;
7658 -+ if (!part_shift)
7659 -+ lo->lo_disk->flags |= GENHD_FL_NO_PART_SCAN;
7660 -+ lo->lo_state = Lo_unbound;
7661 -+ mutex_unlock(&loop_ctl_mutex);
7662 -+
7663 - /*
7664 - * Need not hold loop_ctl_mutex to fput backing file.
7665 - * Calling fput holding loop_ctl_mutex triggers a circular
7666 -diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
7667 -index 04ca65912638..684854d3b0ad 100644
7668 ---- a/drivers/block/zram/zram_drv.c
7669 -+++ b/drivers/block/zram/zram_drv.c
7670 -@@ -290,18 +290,8 @@ static ssize_t idle_store(struct device *dev,
7671 - struct zram *zram = dev_to_zram(dev);
7672 - unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
7673 - int index;
7674 -- char mode_buf[8];
7675 -- ssize_t sz;
7676 -
7677 -- sz = strscpy(mode_buf, buf, sizeof(mode_buf));
7678 -- if (sz <= 0)
7679 -- return -EINVAL;
7680 --
7681 -- /* ignore trailing new line */
7682 -- if (mode_buf[sz - 1] == '\n')
7683 -- mode_buf[sz - 1] = 0x00;
7684 --
7685 -- if (strcmp(mode_buf, "all"))
7686 -+ if (!sysfs_streq(buf, "all"))
7687 - return -EINVAL;
7688 -
7689 - down_read(&zram->init_lock);
7690 -@@ -635,25 +625,15 @@ static ssize_t writeback_store(struct device *dev,
7691 - struct bio bio;
7692 - struct bio_vec bio_vec;
7693 - struct page *page;
7694 -- ssize_t ret, sz;
7695 -- char mode_buf[8];
7696 -- int mode = -1;
7697 -+ ssize_t ret;
7698 -+ int mode;
7699 - unsigned long blk_idx = 0;
7700 -
7701 -- sz = strscpy(mode_buf, buf, sizeof(mode_buf));
7702 -- if (sz <= 0)
7703 -- return -EINVAL;
7704 --
7705 -- /* ignore trailing newline */
7706 -- if (mode_buf[sz - 1] == '\n')
7707 -- mode_buf[sz - 1] = 0x00;
7708 --
7709 -- if (!strcmp(mode_buf, "idle"))
7710 -+ if (sysfs_streq(buf, "idle"))
7711 - mode = IDLE_WRITEBACK;
7712 -- else if (!strcmp(mode_buf, "huge"))
7713 -+ else if (sysfs_streq(buf, "huge"))
7714 - mode = HUGE_WRITEBACK;
7715 --
7716 -- if (mode == -1)
7717 -+ else
7718 - return -EINVAL;
7719 -
7720 - down_read(&zram->init_lock);
7721 -diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
7722 -index 41405de27d66..c91bba00df4e 100644
7723 ---- a/drivers/bluetooth/btrtl.c
7724 -+++ b/drivers/bluetooth/btrtl.c
7725 -@@ -552,10 +552,9 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
7726 - hdev->bus);
7727 -
7728 - if (!btrtl_dev->ic_info) {
7729 -- rtl_dev_err(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
7730 -+ rtl_dev_info(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
7731 - lmp_subver, hci_rev, hci_ver);
7732 -- ret = -EINVAL;
7733 -- goto err_free;
7734 -+ return btrtl_dev;
7735 - }
7736 -
7737 - if (btrtl_dev->ic_info->has_rom_version) {
7738 -@@ -610,6 +609,11 @@ int btrtl_download_firmware(struct hci_dev *hdev,
7739 - * standard btusb. Once that firmware is uploaded, the subver changes
7740 - * to a different value.
7741 - */
7742 -+ if (!btrtl_dev->ic_info) {
7743 -+ rtl_dev_info(hdev, "rtl: assuming no firmware upload needed\n");
7744 -+ return 0;
7745 -+ }
7746 -+
7747 - switch (btrtl_dev->ic_info->lmp_subver) {
7748 - case RTL_ROM_LMP_8723A:
7749 - case RTL_ROM_LMP_3499:
7750 -diff --git a/drivers/bluetooth/h4_recv.h b/drivers/bluetooth/h4_recv.h
7751 -index b432651f8236..307d82166f48 100644
7752 ---- a/drivers/bluetooth/h4_recv.h
7753 -+++ b/drivers/bluetooth/h4_recv.h
7754 -@@ -60,6 +60,10 @@ static inline struct sk_buff *h4_recv_buf(struct hci_dev *hdev,
7755 - const struct h4_recv_pkt *pkts,
7756 - int pkts_count)
7757 - {
7758 -+ /* Check for error from previous call */
7759 -+ if (IS_ERR(skb))
7760 -+ skb = NULL;
7761 -+
7762 - while (count) {
7763 - int i, len;
7764 -
7765 -diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
7766 -index fb97a3bf069b..5d97d77627c1 100644
7767 ---- a/drivers/bluetooth/hci_h4.c
7768 -+++ b/drivers/bluetooth/hci_h4.c
7769 -@@ -174,6 +174,10 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
7770 - struct hci_uart *hu = hci_get_drvdata(hdev);
7771 - u8 alignment = hu->alignment ? hu->alignment : 1;
7772 -
7773 -+ /* Check for error from previous call */
7774 -+ if (IS_ERR(skb))
7775 -+ skb = NULL;
7776 -+
7777 - while (count) {
7778 - int i, len;
7779 -
7780 -diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
7781 -index fbf7b4df23ab..9562e72c1ae5 100644
7782 ---- a/drivers/bluetooth/hci_ldisc.c
7783 -+++ b/drivers/bluetooth/hci_ldisc.c
7784 -@@ -207,11 +207,11 @@ void hci_uart_init_work(struct work_struct *work)
7785 - err = hci_register_dev(hu->hdev);
7786 - if (err < 0) {
7787 - BT_ERR("Can't register HCI device");
7788 -+ clear_bit(HCI_UART_PROTO_READY, &hu->flags);
7789 -+ hu->proto->close(hu);
7790 - hdev = hu->hdev;
7791 - hu->hdev = NULL;
7792 - hci_free_dev(hdev);
7793 -- clear_bit(HCI_UART_PROTO_READY, &hu->flags);
7794 -- hu->proto->close(hu);
7795 - return;
7796 - }
7797 -
7798 -@@ -616,6 +616,7 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
7799 - static int hci_uart_register_dev(struct hci_uart *hu)
7800 - {
7801 - struct hci_dev *hdev;
7802 -+ int err;
7803 -
7804 - BT_DBG("");
7805 -
7806 -@@ -659,11 +660,22 @@ static int hci_uart_register_dev(struct hci_uart *hu)
7807 - else
7808 - hdev->dev_type = HCI_PRIMARY;
7809 -
7810 -+ /* Only call open() for the protocol after hdev is fully initialized as
7811 -+ * open() (or a timer/workqueue it starts) may attempt to reference it.
7812 -+ */
7813 -+ err = hu->proto->open(hu);
7814 -+ if (err) {
7815 -+ hu->hdev = NULL;
7816 -+ hci_free_dev(hdev);
7817 -+ return err;
7818 -+ }
7819 -+
7820 - if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags))
7821 - return 0;
7822 -
7823 - if (hci_register_dev(hdev) < 0) {
7824 - BT_ERR("Can't register HCI device");
7825 -+ hu->proto->close(hu);
7826 - hu->hdev = NULL;
7827 - hci_free_dev(hdev);
7828 - return -ENODEV;
7829 -@@ -683,20 +695,14 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
7830 - if (!p)
7831 - return -EPROTONOSUPPORT;
7832 -
7833 -- err = p->open(hu);
7834 -- if (err)
7835 -- return err;
7836 --
7837 - hu->proto = p;
7838 -- set_bit(HCI_UART_PROTO_READY, &hu->flags);
7839 -
7840 - err = hci_uart_register_dev(hu);
7841 - if (err) {
7842 -- clear_bit(HCI_UART_PROTO_READY, &hu->flags);
7843 -- p->close(hu);
7844 - return err;
7845 - }
7846 -
7847 -+ set_bit(HCI_UART_PROTO_READY, &hu->flags);
7848 - return 0;
7849 - }
7850 -
7851 -diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
7852 -index 614ecdbb4ab7..933268b8d6a5 100644
7853 ---- a/drivers/cdrom/cdrom.c
7854 -+++ b/drivers/cdrom/cdrom.c
7855 -@@ -265,6 +265,7 @@
7856 - /* #define ERRLOGMASK (CD_WARNING|CD_OPEN|CD_COUNT_TRACKS|CD_CLOSE) */
7857 - /* #define ERRLOGMASK (CD_WARNING|CD_REG_UNREG|CD_DO_IOCTL|CD_OPEN|CD_CLOSE|CD_COUNT_TRACKS) */
7858 -
7859 -+#include <linux/atomic.h>
7860 - #include <linux/module.h>
7861 - #include <linux/fs.h>
7862 - #include <linux/major.h>
7863 -@@ -3692,9 +3693,9 @@ static struct ctl_table_header *cdrom_sysctl_header;
7864 -
7865 - static void cdrom_sysctl_register(void)
7866 - {
7867 -- static int initialized;
7868 -+ static atomic_t initialized = ATOMIC_INIT(0);
7869 -
7870 -- if (initialized == 1)
7871 -+ if (!atomic_add_unless(&initialized, 1, 1))
7872 - return;
7873 -
7874 - cdrom_sysctl_header = register_sysctl_table(cdrom_root_table);
7875 -@@ -3705,8 +3706,6 @@ static void cdrom_sysctl_register(void)
7876 - cdrom_sysctl_settings.debug = debug;
7877 - cdrom_sysctl_settings.lock = lockdoor;
7878 - cdrom_sysctl_settings.check = check_media_type;
7879 --
7880 -- initialized = 1;
7881 - }
7882 -
7883 - static void cdrom_sysctl_unregister(void)
7884 -diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
7885 -index 2e2ffe7010aa..51c77f0e47b2 100644
7886 ---- a/drivers/char/Kconfig
7887 -+++ b/drivers/char/Kconfig
7888 -@@ -351,7 +351,7 @@ config XILINX_HWICAP
7889 -
7890 - config R3964
7891 - tristate "Siemens R3964 line discipline"
7892 -- depends on TTY
7893 -+ depends on TTY && BROKEN
7894 - ---help---
7895 - This driver allows synchronous communication with devices using the
7896 - Siemens R3964 packet protocol. Unless you are dealing with special
7897 -diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
7898 -index c0a5b1f3a986..4ccc39e00ced 100644
7899 ---- a/drivers/char/applicom.c
7900 -+++ b/drivers/char/applicom.c
7901 -@@ -32,6 +32,7 @@
7902 - #include <linux/wait.h>
7903 - #include <linux/init.h>
7904 - #include <linux/fs.h>
7905 -+#include <linux/nospec.h>
7906 -
7907 - #include <asm/io.h>
7908 - #include <linux/uaccess.h>
7909 -@@ -386,7 +387,11 @@ static ssize_t ac_write(struct file *file, const char __user *buf, size_t count,
7910 - TicCard = st_loc.tic_des_from_pc; /* tic number to send */
7911 - IndexCard = NumCard - 1;
7912 -
7913 -- if((NumCard < 1) || (NumCard > MAX_BOARD) || !apbs[IndexCard].RamIO)
7914 -+ if (IndexCard >= MAX_BOARD)
7915 -+ return -EINVAL;
7916 -+ IndexCard = array_index_nospec(IndexCard, MAX_BOARD);
7917 -+
7918 -+ if (!apbs[IndexCard].RamIO)
7919 - return -EINVAL;
7920 -
7921 - #ifdef DEBUG
7922 -@@ -697,6 +702,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
7923 - unsigned char IndexCard;
7924 - void __iomem *pmem;
7925 - int ret = 0;
7926 -+ static int warncount = 10;
7927 - volatile unsigned char byte_reset_it;
7928 - struct st_ram_io *adgl;
7929 - void __user *argp = (void __user *)arg;
7930 -@@ -711,16 +717,12 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
7931 - mutex_lock(&ac_mutex);
7932 - IndexCard = adgl->num_card-1;
7933 -
7934 -- if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
7935 -- static int warncount = 10;
7936 -- if (warncount) {
7937 -- printk( KERN_WARNING "APPLICOM driver IOCTL, bad board number %d\n",(int)IndexCard+1);
7938 -- warncount--;
7939 -- }
7940 -- kfree(adgl);
7941 -- mutex_unlock(&ac_mutex);
7942 -- return -EINVAL;
7943 -- }
7944 -+ if (cmd != 6 && IndexCard >= MAX_BOARD)
7945 -+ goto err;
7946 -+ IndexCard = array_index_nospec(IndexCard, MAX_BOARD);
7947 -+
7948 -+ if (cmd != 6 && !apbs[IndexCard].RamIO)
7949 -+ goto err;
7950 -
7951 - switch (cmd) {
7952 -
7953 -@@ -838,5 +840,16 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
7954 - kfree(adgl);
7955 - mutex_unlock(&ac_mutex);
7956 - return 0;
7957 -+
7958 -+err:
7959 -+ if (warncount) {
7960 -+ pr_warn("APPLICOM driver IOCTL, bad board number %d\n",
7961 -+ (int)IndexCard + 1);
7962 -+ warncount--;
7963 -+ }
7964 -+ kfree(adgl);
7965 -+ mutex_unlock(&ac_mutex);
7966 -+ return -EINVAL;
7967 -+
7968 - }
7969 -
7970 -diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
7971 -index 4a22b4b41aef..9bffcd37cc7b 100644
7972 ---- a/drivers/char/hpet.c
7973 -+++ b/drivers/char/hpet.c
7974 -@@ -377,7 +377,7 @@ static __init int hpet_mmap_enable(char *str)
7975 - pr_info("HPET mmap %s\n", hpet_mmap_enabled ? "enabled" : "disabled");
7976 - return 1;
7977 - }
7978 --__setup("hpet_mmap", hpet_mmap_enable);
7979 -+__setup("hpet_mmap=", hpet_mmap_enable);
7980 -
7981 - static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
7982 - {
7983 -diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
7984 -index b89df66ea1ae..7abd604e938c 100644
7985 ---- a/drivers/char/hw_random/virtio-rng.c
7986 -+++ b/drivers/char/hw_random/virtio-rng.c
7987 -@@ -73,7 +73,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
7988 -
7989 - if (!vi->busy) {
7990 - vi->busy = true;
7991 -- init_completion(&vi->have_data);
7992 -+ reinit_completion(&vi->have_data);
7993 - register_buffer(vi, buf, size);
7994 - }
7995 -
7996 -diff --git a/drivers/char/ipmi/ipmi_si.h b/drivers/char/ipmi/ipmi_si.h
7997 -index 52f6152d1fcb..7ae52c17618e 100644
7998 ---- a/drivers/char/ipmi/ipmi_si.h
7999 -+++ b/drivers/char/ipmi/ipmi_si.h
8000 -@@ -25,7 +25,9 @@ void ipmi_irq_finish_setup(struct si_sm_io *io);
8001 - int ipmi_si_remove_by_dev(struct device *dev);
8002 - void ipmi_si_remove_by_data(int addr_space, enum si_type si_type,
8003 - unsigned long addr);
8004 --int ipmi_si_hardcode_find_bmc(void);
8005 -+void ipmi_hardcode_init(void);
8006 -+void ipmi_si_hardcode_exit(void);
8007 -+int ipmi_si_hardcode_match(int addr_type, unsigned long addr);
8008 - void ipmi_si_platform_init(void);
8009 - void ipmi_si_platform_shutdown(void);
8010 -
8011 -diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
8012 -index 487642809c58..1e5783961b0d 100644
8013 ---- a/drivers/char/ipmi/ipmi_si_hardcode.c
8014 -+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
8015 -@@ -3,6 +3,7 @@
8016 - #define pr_fmt(fmt) "ipmi_hardcode: " fmt
8017 -
8018 - #include <linux/moduleparam.h>
8019 -+#include <linux/platform_device.h>
8020 - #include "ipmi_si.h"
8021 -
8022 - /*
8023 -@@ -12,23 +13,22 @@
8024 -
8025 - #define SI_MAX_PARMS 4
8026 -
8027 --static char *si_type[SI_MAX_PARMS];
8028 - #define MAX_SI_TYPE_STR 30
8029 --static char si_type_str[MAX_SI_TYPE_STR];
8030 -+static char si_type_str[MAX_SI_TYPE_STR] __initdata;
8031 - static unsigned long addrs[SI_MAX_PARMS];
8032 - static unsigned int num_addrs;
8033 - static unsigned int ports[SI_MAX_PARMS];
8034 - static unsigned int num_ports;
8035 --static int irqs[SI_MAX_PARMS];
8036 --static unsigned int num_irqs;
8037 --static int regspacings[SI_MAX_PARMS];
8038 --static unsigned int num_regspacings;
8039 --static int regsizes[SI_MAX_PARMS];
8040 --static unsigned int num_regsizes;
8041 --static int regshifts[SI_MAX_PARMS];
8042 --static unsigned int num_regshifts;
8043 --static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */
8044 --static unsigned int num_slave_addrs;
8045 -+static int irqs[SI_MAX_PARMS] __initdata;
8046 -+static unsigned int num_irqs __initdata;
8047 -+static int regspacings[SI_MAX_PARMS] __initdata;
8048 -+static unsigned int num_regspacings __initdata;
8049 -+static int regsizes[SI_MAX_PARMS] __initdata;
8050 -+static unsigned int num_regsizes __initdata;
8051 -+static int regshifts[SI_MAX_PARMS] __initdata;
8052 -+static unsigned int num_regshifts __initdata;
8053 -+static int slave_addrs[SI_MAX_PARMS] __initdata;
8054 -+static unsigned int num_slave_addrs __initdata;
8055 -
8056 - module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0);
8057 - MODULE_PARM_DESC(type, "Defines the type of each interface, each"
8058 -@@ -73,12 +73,133 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for"
8059 - " overridden by this parm. This is an array indexed"
8060 - " by interface number.");
8061 -
8062 --int ipmi_si_hardcode_find_bmc(void)
8063 -+static struct platform_device *ipmi_hc_pdevs[SI_MAX_PARMS];
8064 -+
8065 -+static void __init ipmi_hardcode_init_one(const char *si_type_str,
8066 -+ unsigned int i,
8067 -+ unsigned long addr,
8068 -+ unsigned int flags)
8069 - {
8070 -- int ret = -ENODEV;
8071 -- int i;
8072 -- struct si_sm_io io;
8073 -+ struct platform_device *pdev;
8074 -+ unsigned int num_r = 1, size;
8075 -+ struct resource r[4];
8076 -+ struct property_entry p[6];
8077 -+ enum si_type si_type;
8078 -+ unsigned int regspacing, regsize;
8079 -+ int rv;
8080 -+
8081 -+ memset(p, 0, sizeof(p));
8082 -+ memset(r, 0, sizeof(r));
8083 -+
8084 -+ if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
8085 -+ size = 2;
8086 -+ si_type = SI_KCS;
8087 -+ } else if (strcmp(si_type_str, "smic") == 0) {
8088 -+ size = 2;
8089 -+ si_type = SI_SMIC;
8090 -+ } else if (strcmp(si_type_str, "bt") == 0) {
8091 -+ size = 3;
8092 -+ si_type = SI_BT;
8093 -+ } else if (strcmp(si_type_str, "invalid") == 0) {
8094 -+ /*
8095 -+ * Allow a firmware-specified interface to be
8096 -+ * disabled.
8097 -+ */
8098 -+ size = 1;
8099 -+ si_type = SI_TYPE_INVALID;
8100 -+ } else {
8101 -+ pr_warn("Interface type specified for interface %d, was invalid: %s\n",
8102 -+ i, si_type_str);
8103 -+ return;
8104 -+ }
8105 -+
8106 -+ regsize = regsizes[i];
8107 -+ if (regsize == 0)
8108 -+ regsize = DEFAULT_REGSIZE;
8109 -+
8110 -+ p[0] = PROPERTY_ENTRY_U8("ipmi-type", si_type);
8111 -+ p[1] = PROPERTY_ENTRY_U8("slave-addr", slave_addrs[i]);
8112 -+ p[2] = PROPERTY_ENTRY_U8("addr-source", SI_HARDCODED);
8113 -+ p[3] = PROPERTY_ENTRY_U8("reg-shift", regshifts[i]);
8114 -+ p[4] = PROPERTY_ENTRY_U8("reg-size", regsize);
8115 -+ /* Last entry must be left NULL to terminate it. */
8116 -+
8117 -+ /*
8118 -+ * Register spacing is derived from the resources in
8119 -+ * the IPMI platform code.
8120 -+ */
8121 -+ regspacing = regspacings[i];
8122 -+ if (regspacing == 0)
8123 -+ regspacing = regsize;
8124 -+
8125 -+ r[0].start = addr;
8126 -+ r[0].end = r[0].start + regsize - 1;
8127 -+ r[0].name = "IPMI Address 1";
8128 -+ r[0].flags = flags;
8129 -+
8130 -+ if (size > 1) {
8131 -+ r[1].start = r[0].start + regspacing;
8132 -+ r[1].end = r[1].start + regsize - 1;
8133 -+ r[1].name = "IPMI Address 2";
8134 -+ r[1].flags = flags;
8135 -+ num_r++;
8136 -+ }
8137 -+
8138 -+ if (size > 2) {
8139 -+ r[2].start = r[1].start + regspacing;
8140 -+ r[2].end = r[2].start + regsize - 1;
8141 -+ r[2].name = "IPMI Address 3";
8142 -+ r[2].flags = flags;
8143 -+ num_r++;
8144 -+ }
8145 -+
8146 -+ if (irqs[i]) {
8147 -+ r[num_r].start = irqs[i];
8148 -+ r[num_r].end = irqs[i];
8149 -+ r[num_r].name = "IPMI IRQ";
8150 -+ r[num_r].flags = IORESOURCE_IRQ;
8151 -+ num_r++;
8152 -+ }
8153 -+
8154 -+ pdev = platform_device_alloc("hardcode-ipmi-si", i);
8155 -+ if (!pdev) {
8156 -+ pr_err("Error allocating IPMI platform device %d\n", i);
8157 -+ return;
8158 -+ }
8159 -+
8160 -+ rv = platform_device_add_resources(pdev, r, num_r);
8161 -+ if (rv) {
8162 -+ dev_err(&pdev->dev,
8163 -+ "Unable to add hard-code resources: %d\n", rv);
8164 -+ goto err;
8165 -+ }
8166 -+
8167 -+ rv = platform_device_add_properties(pdev, p);
8168 -+ if (rv) {
8169 -+ dev_err(&pdev->dev,
8170 -+ "Unable to add hard-code properties: %d\n", rv);
8171 -+ goto err;
8172 -+ }
8173 -+
8174 -+ rv = platform_device_add(pdev);
8175 -+ if (rv) {
8176 -+ dev_err(&pdev->dev,
8177 -+ "Unable to add hard-code device: %d\n", rv);
8178 -+ goto err;
8179 -+ }
8180 -+
8181 -+ ipmi_hc_pdevs[i] = pdev;
8182 -+ return;
8183 -+
8184 -+err:
8185 -+ platform_device_put(pdev);
8186 -+}
8187 -+
8188 -+void __init ipmi_hardcode_init(void)
8189 -+{
8190 -+ unsigned int i;
8191 - char *str;
8192 -+ char *si_type[SI_MAX_PARMS];
8193 -
8194 - /* Parse out the si_type string into its components. */
8195 - str = si_type_str;
8196 -@@ -95,54 +216,45 @@ int ipmi_si_hardcode_find_bmc(void)
8197 - }
8198 - }
8199 -
8200 -- memset(&io, 0, sizeof(io));
8201 - for (i = 0; i < SI_MAX_PARMS; i++) {
8202 -- if (!ports[i] && !addrs[i])
8203 -- continue;
8204 --
8205 -- io.addr_source = SI_HARDCODED;
8206 -- pr_info("probing via hardcoded address\n");
8207 --
8208 -- if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
8209 -- io.si_type = SI_KCS;
8210 -- } else if (strcmp(si_type[i], "smic") == 0) {
8211 -- io.si_type = SI_SMIC;
8212 -- } else if (strcmp(si_type[i], "bt") == 0) {
8213 -- io.si_type = SI_BT;
8214 -- } else {
8215 -- pr_warn("Interface type specified for interface %d, was invalid: %s\n",
8216 -- i, si_type[i]);
8217 -- continue;
8218 -- }
8219 -+ if (i < num_ports && ports[i])
8220 -+ ipmi_hardcode_init_one(si_type[i], i, ports[i],
8221 -+ IORESOURCE_IO);
8222 -+ if (i < num_addrs && addrs[i])
8223 -+ ipmi_hardcode_init_one(si_type[i], i, addrs[i],
8224 -+ IORESOURCE_MEM);
8225 -+ }
8226 -+}
8227 -
8228 -- if (ports[i]) {
8229 -- /* An I/O port */
8230 -- io.addr_data = ports[i];
8231 -- io.addr_type = IPMI_IO_ADDR_SPACE;
8232 -- } else if (addrs[i]) {
8233 -- /* A memory port */
8234 -- io.addr_data = addrs[i];
8235 -- io.addr_type = IPMI_MEM_ADDR_SPACE;
8236 -- } else {
8237 -- pr_warn("Interface type specified for interface %d, but port and address were not set or set to zero\n",
8238 -- i);
8239 -- continue;
8240 -- }
8241 -+void ipmi_si_hardcode_exit(void)
8242 -+{
8243 -+ unsigned int i;
8244 -
8245 -- io.addr = NULL;
8246 -- io.regspacing = regspacings[i];
8247 -- if (!io.regspacing)
8248 -- io.regspacing = DEFAULT_REGSPACING;
8249 -- io.regsize = regsizes[i];
8250 -- if (!io.regsize)
8251 -- io.regsize = DEFAULT_REGSIZE;
8252 -- io.regshift = regshifts[i];
8253 -- io.irq = irqs[i];
8254 -- if (io.irq)
8255 -- io.irq_setup = ipmi_std_irq_setup;
8256 -- io.slave_addr = slave_addrs[i];
8257 --
8258 -- ret = ipmi_si_add_smi(&io);
8259 -+ for (i = 0; i < SI_MAX_PARMS; i++) {
8260 -+ if (ipmi_hc_pdevs[i])
8261 -+ platform_device_unregister(ipmi_hc_pdevs[i]);
8262 - }
8263 -- return ret;
8264 -+}
8265 -+
8266 -+/*
8267 -+ * Returns true of the given address exists as a hardcoded address,
8268 -+ * false if not.
8269 -+ */
8270 -+int ipmi_si_hardcode_match(int addr_type, unsigned long addr)
8271 -+{
8272 -+ unsigned int i;
8273 -+
8274 -+ if (addr_type == IPMI_IO_ADDR_SPACE) {
8275 -+ for (i = 0; i < num_ports; i++) {
8276 -+ if (ports[i] == addr)
8277 -+ return 1;
8278 -+ }
8279 -+ } else {
8280 -+ for (i = 0; i < num_addrs; i++) {
8281 -+ if (addrs[i] == addr)
8282 -+ return 1;
8283 -+ }
8284 -+ }
8285 -+
8286 -+ return 0;
8287 - }
8288 -diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
8289 -index dc8603d34320..5294abc4c96c 100644
8290 ---- a/drivers/char/ipmi/ipmi_si_intf.c
8291 -+++ b/drivers/char/ipmi/ipmi_si_intf.c
8292 -@@ -1862,6 +1862,18 @@ int ipmi_si_add_smi(struct si_sm_io *io)
8293 - int rv = 0;
8294 - struct smi_info *new_smi, *dup;
8295 -
8296 -+ /*
8297 -+ * If the user gave us a hard-coded device at the same
8298 -+ * address, they presumably want us to use it and not what is
8299 -+ * in the firmware.
8300 -+ */
8301 -+ if (io->addr_source != SI_HARDCODED &&
8302 -+ ipmi_si_hardcode_match(io->addr_type, io->addr_data)) {
8303 -+ dev_info(io->dev,
8304 -+ "Hard-coded device at this address already exists");
8305 -+ return -ENODEV;
8306 -+ }
8307 -+
8308 - if (!io->io_setup) {
8309 - if (io->addr_type == IPMI_IO_ADDR_SPACE) {
8310 - io->io_setup = ipmi_si_port_setup;
8311 -@@ -2085,11 +2097,16 @@ static int try_smi_init(struct smi_info *new_smi)
8312 - WARN_ON(new_smi->io.dev->init_name != NULL);
8313 -
8314 - out_err:
8315 -+ if (rv && new_smi->io.io_cleanup) {
8316 -+ new_smi->io.io_cleanup(&new_smi->io);
8317 -+ new_smi->io.io_cleanup = NULL;
8318 -+ }
8319 -+
8320 - kfree(init_name);
8321 - return rv;
8322 - }
8323 -
8324 --static int init_ipmi_si(void)
8325 -+static int __init init_ipmi_si(void)
8326 - {
8327 - struct smi_info *e;
8328 - enum ipmi_addr_src type = SI_INVALID;
8329 -@@ -2097,11 +2114,9 @@ static int init_ipmi_si(void)
8330 - if (initialized)
8331 - return 0;
8332 -
8333 -- pr_info("IPMI System Interface driver\n");
8334 -+ ipmi_hardcode_init();
8335 -
8336 -- /* If the user gave us a device, they presumably want us to use it */
8337 -- if (!ipmi_si_hardcode_find_bmc())
8338 -- goto do_scan;
8339 -+ pr_info("IPMI System Interface driver\n");
8340 -
8341 - ipmi_si_platform_init();
8342 -
8343 -@@ -2113,7 +2128,6 @@ static int init_ipmi_si(void)
8344 - with multiple BMCs we assume that there will be several instances
8345 - of a given type so if we succeed in registering a type then also
8346 - try to register everything else of the same type */
8347 --do_scan:
8348 - mutex_lock(&smi_infos_lock);
8349 - list_for_each_entry(e, &smi_infos, link) {
8350 - /* Try to register a device if it has an IRQ and we either
8351 -@@ -2299,6 +2313,8 @@ static void cleanup_ipmi_si(void)
8352 - list_for_each_entry_safe(e, tmp_e, &smi_infos, link)
8353 - cleanup_one_si(e);
8354 - mutex_unlock(&smi_infos_lock);
8355 -+
8356 -+ ipmi_si_hardcode_exit();
8357 - }
8358 - module_exit(cleanup_ipmi_si);
8359 -
8360 -diff --git a/drivers/char/ipmi/ipmi_si_mem_io.c b/drivers/char/ipmi/ipmi_si_mem_io.c
8361 -index fd0ec8d6bf0e..75583612ab10 100644
8362 ---- a/drivers/char/ipmi/ipmi_si_mem_io.c
8363 -+++ b/drivers/char/ipmi/ipmi_si_mem_io.c
8364 -@@ -81,8 +81,6 @@ int ipmi_si_mem_setup(struct si_sm_io *io)
8365 - if (!addr)
8366 - return -ENODEV;
8367 -
8368 -- io->io_cleanup = mem_cleanup;
8369 --
8370 - /*
8371 - * Figure out the actual readb/readw/readl/etc routine to use based
8372 - * upon the register size.
8373 -@@ -141,5 +139,8 @@ int ipmi_si_mem_setup(struct si_sm_io *io)
8374 - mem_region_cleanup(io, io->io_size);
8375 - return -EIO;
8376 - }
8377 -+
8378 -+ io->io_cleanup = mem_cleanup;
8379 -+
8380 - return 0;
8381 - }
8382 -diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
8383 -index 15cf819f884f..8158d03542f4 100644
8384 ---- a/drivers/char/ipmi/ipmi_si_platform.c
8385 -+++ b/drivers/char/ipmi/ipmi_si_platform.c
8386 -@@ -128,8 +128,6 @@ ipmi_get_info_from_resources(struct platform_device *pdev,
8387 - if (res_second->start > io->addr_data)
8388 - io->regspacing = res_second->start - io->addr_data;
8389 - }
8390 -- io->regsize = DEFAULT_REGSIZE;
8391 -- io->regshift = 0;
8392 -
8393 - return res;
8394 - }
8395 -@@ -137,7 +135,7 @@ ipmi_get_info_from_resources(struct platform_device *pdev,
8396 - static int platform_ipmi_probe(struct platform_device *pdev)
8397 - {
8398 - struct si_sm_io io;
8399 -- u8 type, slave_addr, addr_source;
8400 -+ u8 type, slave_addr, addr_source, regsize, regshift;
8401 - int rv;
8402 -
8403 - rv = device_property_read_u8(&pdev->dev, "addr-source", &addr_source);
8404 -@@ -149,7 +147,7 @@ static int platform_ipmi_probe(struct platform_device *pdev)
8405 - if (addr_source == SI_SMBIOS) {
8406 - if (!si_trydmi)
8407 - return -ENODEV;
8408 -- } else {
8409 -+ } else if (addr_source != SI_HARDCODED) {
8410 - if (!si_tryplatform)
8411 - return -ENODEV;
8412 - }
8413 -@@ -169,11 +167,23 @@ static int platform_ipmi_probe(struct platform_device *pdev)
8414 - case SI_BT:
8415 - io.si_type = type;
8416 - break;
8417 -+ case SI_TYPE_INVALID: /* User disabled this in hardcode. */
8418 -+ return -ENODEV;
8419 - default:
8420 - dev_err(&pdev->dev, "ipmi-type property is invalid\n");
8421 - return -EINVAL;
8422 - }
8423 -
8424 -+ io.regsize = DEFAULT_REGSIZE;
8425 -+ rv = device_property_read_u8(&pdev->dev, "reg-size", &regsize);
8426 -+ if (!rv)
8427 -+ io.regsize = regsize;
8428 -+
8429 -+ io.regshift = 0;
8430 -+ rv = device_property_read_u8(&pdev->dev, "reg-shift", &regshift);
8431 -+ if (!rv)
8432 -+ io.regshift = regshift;
8433 -+
8434 - if (!ipmi_get_info_from_resources(pdev, &io))
8435 - return -EINVAL;
8436 -
8437 -@@ -193,7 +203,8 @@ static int platform_ipmi_probe(struct platform_device *pdev)
8438 -
8439 - io.dev = &pdev->dev;
8440 -
8441 -- pr_info("ipmi_si: SMBIOS: %s %#lx regsize %d spacing %d irq %d\n",
8442 -+ pr_info("ipmi_si: %s: %s %#lx regsize %d spacing %d irq %d\n",
8443 -+ ipmi_addr_src_to_str(addr_source),
8444 - (io.addr_type == IPMI_IO_ADDR_SPACE) ? "io" : "mem",
8445 - io.addr_data, io.regsize, io.regspacing, io.irq);
8446 -
8447 -@@ -358,6 +369,9 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
8448 - goto err_free;
8449 - }
8450 -
8451 -+ io.regsize = DEFAULT_REGSIZE;
8452 -+ io.regshift = 0;
8453 -+
8454 - res = ipmi_get_info_from_resources(pdev, &io);
8455 - if (!res) {
8456 - rv = -EINVAL;
8457 -@@ -420,8 +434,9 @@ static int ipmi_remove(struct platform_device *pdev)
8458 - }
8459 -
8460 - static const struct platform_device_id si_plat_ids[] = {
8461 -- { "dmi-ipmi-si", 0 },
8462 -- { }
8463 -+ { "dmi-ipmi-si", 0 },
8464 -+ { "hardcode-ipmi-si", 0 },
8465 -+ { }
8466 - };
8467 -
8468 - struct platform_driver ipmi_platform_driver = {
8469 -diff --git a/drivers/char/ipmi/ipmi_si_port_io.c b/drivers/char/ipmi/ipmi_si_port_io.c
8470 -index ef6dffcea9fa..03924c32b6e9 100644
8471 ---- a/drivers/char/ipmi/ipmi_si_port_io.c
8472 -+++ b/drivers/char/ipmi/ipmi_si_port_io.c
8473 -@@ -68,8 +68,6 @@ int ipmi_si_port_setup(struct si_sm_io *io)
8474 - if (!addr)
8475 - return -ENODEV;
8476 -
8477 -- io->io_cleanup = port_cleanup;
8478 --
8479 - /*
8480 - * Figure out the actual inb/inw/inl/etc routine to use based
8481 - * upon the register size.
8482 -@@ -109,5 +107,8 @@ int ipmi_si_port_setup(struct si_sm_io *io)
8483 - return -EIO;
8484 - }
8485 - }
8486 -+
8487 -+ io->io_cleanup = port_cleanup;
8488 -+
8489 - return 0;
8490 - }
8491 -diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
8492 -index 64dc560859f2..13dc614b7ebc 100644
8493 ---- a/drivers/char/tpm/st33zp24/st33zp24.c
8494 -+++ b/drivers/char/tpm/st33zp24/st33zp24.c
8495 -@@ -436,7 +436,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
8496 - goto out_err;
8497 - }
8498 -
8499 -- return len;
8500 -+ return 0;
8501 - out_err:
8502 - st33zp24_cancel(chip);
8503 - release_locality(chip);
8504 -diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
8505 -index d9439f9abe78..88d2e01a651d 100644
8506 ---- a/drivers/char/tpm/tpm-interface.c
8507 -+++ b/drivers/char/tpm/tpm-interface.c
8508 -@@ -230,10 +230,19 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
8509 - if (rc < 0) {
8510 - if (rc != -EPIPE)
8511 - dev_err(&chip->dev,
8512 -- "%s: tpm_send: error %d\n", __func__, rc);
8513 -+ "%s: send(): error %d\n", __func__, rc);
8514 - goto out;
8515 - }
8516 -
8517 -+ /* A sanity check. send() should just return zero on success e.g.
8518 -+ * not the command length.
8519 -+ */
8520 -+ if (rc > 0) {
8521 -+ dev_warn(&chip->dev,
8522 -+ "%s: send(): invalid value %d\n", __func__, rc);
8523 -+ rc = 0;
8524 -+ }
8525 -+
8526 - if (chip->flags & TPM_CHIP_FLAG_IRQ)
8527 - goto out_recv;
8528 -
8529 -diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
8530 -index 66a14526aaf4..a290b30a0c35 100644
8531 ---- a/drivers/char/tpm/tpm_atmel.c
8532 -+++ b/drivers/char/tpm/tpm_atmel.c
8533 -@@ -105,7 +105,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
8534 - iowrite8(buf[i], priv->iobase);
8535 - }
8536 -
8537 -- return count;
8538 -+ return 0;
8539 - }
8540 -
8541 - static void tpm_atml_cancel(struct tpm_chip *chip)
8542 -diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
8543 -index 36952ef98f90..763fc7e6c005 100644
8544 ---- a/drivers/char/tpm/tpm_crb.c
8545 -+++ b/drivers/char/tpm/tpm_crb.c
8546 -@@ -287,19 +287,29 @@ static int crb_recv(struct tpm_chip *chip, u8 *buf, size_t count)
8547 - struct crb_priv *priv = dev_get_drvdata(&chip->dev);
8548 - unsigned int expected;
8549 -
8550 -- /* sanity check */
8551 -- if (count < 6)
8552 -+ /* A sanity check that the upper layer wants to get at least the header
8553 -+ * as that is the minimum size for any TPM response.
8554 -+ */
8555 -+ if (count < TPM_HEADER_SIZE)
8556 - return -EIO;
8557 -
8558 -+ /* If this bit is set, according to the spec, the TPM is in
8559 -+ * unrecoverable condition.
8560 -+ */
8561 - if (ioread32(&priv->regs_t->ctrl_sts) & CRB_CTRL_STS_ERROR)
8562 - return -EIO;
8563 -
8564 -- memcpy_fromio(buf, priv->rsp, 6);
8565 -- expected = be32_to_cpup((__be32 *) &buf[2]);
8566 -- if (expected > count || expected < 6)
8567 -+ /* Read the first 8 bytes in order to get the length of the response.
8568 -+ * We read exactly a quad word in order to make sure that the remaining
8569 -+ * reads will be aligned.
8570 -+ */
8571 -+ memcpy_fromio(buf, priv->rsp, 8);
8572 -+
8573 -+ expected = be32_to_cpup((__be32 *)&buf[2]);
8574 -+ if (expected > count || expected < TPM_HEADER_SIZE)
8575 - return -EIO;
8576 -
8577 -- memcpy_fromio(&buf[6], &priv->rsp[6], expected - 6);
8578 -+ memcpy_fromio(&buf[8], &priv->rsp[8], expected - 8);
8579 -
8580 - return expected;
8581 - }
8582 -diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
8583 -index 95ce2e9ccdc6..32a8e27c5382 100644
8584 ---- a/drivers/char/tpm/tpm_i2c_atmel.c
8585 -+++ b/drivers/char/tpm/tpm_i2c_atmel.c
8586 -@@ -65,7 +65,11 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
8587 - dev_dbg(&chip->dev,
8588 - "%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
8589 - (int)min_t(size_t, 64, len), buf, len, status);
8590 -- return status;
8591 -+
8592 -+ if (status < 0)
8593 -+ return status;
8594 -+
8595 -+ return 0;
8596 - }
8597 -
8598 - static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
8599 -diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
8600 -index 9086edc9066b..977fd42daa1b 100644
8601 ---- a/drivers/char/tpm/tpm_i2c_infineon.c
8602 -+++ b/drivers/char/tpm/tpm_i2c_infineon.c
8603 -@@ -587,7 +587,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
8604 - /* go and do it */
8605 - iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
8606 -
8607 -- return len;
8608 -+ return 0;
8609 - out_err:
8610 - tpm_tis_i2c_ready(chip);
8611 - /* The TPM needs some time to clean up here,
8612 -diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
8613 -index 217f7f1cbde8..058220edb8b3 100644
8614 ---- a/drivers/char/tpm/tpm_i2c_nuvoton.c
8615 -+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
8616 -@@ -467,7 +467,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
8617 - }
8618 -
8619 - dev_dbg(dev, "%s() -> %zd\n", __func__, len);
8620 -- return len;
8621 -+ return 0;
8622 - }
8623 -
8624 - static bool i2c_nuvoton_req_canceled(struct tpm_chip *chip, u8 status)
8625 -diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
8626 -index 07b5a487d0c8..757ca45b39b8 100644
8627 ---- a/drivers/char/tpm/tpm_ibmvtpm.c
8628 -+++ b/drivers/char/tpm/tpm_ibmvtpm.c
8629 -@@ -139,14 +139,14 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
8630 - }
8631 -
8632 - /**
8633 -- * tpm_ibmvtpm_send - Send tpm request
8634 -- *
8635 -+ * tpm_ibmvtpm_send() - Send a TPM command
8636 - * @chip: tpm chip struct
8637 - * @buf: buffer contains data to send
8638 - * @count: size of buffer
8639 - *
8640 - * Return:
8641 -- * Number of bytes sent or < 0 on error.
8642 -+ * 0 on success,
8643 -+ * -errno on error
8644 - */
8645 - static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
8646 - {
8647 -@@ -192,7 +192,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
8648 - rc = 0;
8649 - ibmvtpm->tpm_processing_cmd = false;
8650 - } else
8651 -- rc = count;
8652 -+ rc = 0;
8653 -
8654 - spin_unlock(&ibmvtpm->rtce_lock);
8655 - return rc;
8656 -diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
8657 -index d8f10047fbba..97f6d4fe0aee 100644
8658 ---- a/drivers/char/tpm/tpm_infineon.c
8659 -+++ b/drivers/char/tpm/tpm_infineon.c
8660 -@@ -354,7 +354,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
8661 - for (i = 0; i < count; i++) {
8662 - wait_and_send(chip, buf[i]);
8663 - }
8664 -- return count;
8665 -+ return 0;
8666 - }
8667 -
8668 - static void tpm_inf_cancel(struct tpm_chip *chip)
8669 -diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
8670 -index 5d6cce74cd3f..9bee3c5eb4bf 100644
8671 ---- a/drivers/char/tpm/tpm_nsc.c
8672 -+++ b/drivers/char/tpm/tpm_nsc.c
8673 -@@ -226,7 +226,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
8674 - }
8675 - outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND);
8676 -
8677 -- return count;
8678 -+ return 0;
8679 - }
8680 -
8681 - static void tpm_nsc_cancel(struct tpm_chip *chip)
8682 -diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
8683 -index bf7e49cfa643..bb0c2e160562 100644
8684 ---- a/drivers/char/tpm/tpm_tis_core.c
8685 -+++ b/drivers/char/tpm/tpm_tis_core.c
8686 -@@ -481,7 +481,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
8687 - goto out_err;
8688 - }
8689 - }
8690 -- return len;
8691 -+ return 0;
8692 - out_err:
8693 - tpm_tis_ready(chip);
8694 - return rc;
8695 -diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
8696 -index 87a0ce47f201..ecbb63f8d231 100644
8697 ---- a/drivers/char/tpm/tpm_vtpm_proxy.c
8698 -+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
8699 -@@ -335,7 +335,6 @@ static int vtpm_proxy_is_driver_command(struct tpm_chip *chip,
8700 - static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count)
8701 - {
8702 - struct proxy_dev *proxy_dev = dev_get_drvdata(&chip->dev);
8703 -- int rc = 0;
8704 -
8705 - if (count > sizeof(proxy_dev->buffer)) {
8706 - dev_err(&chip->dev,
8707 -@@ -366,7 +365,7 @@ static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count)
8708 -
8709 - wake_up_interruptible(&proxy_dev->wq);
8710 -
8711 -- return rc;
8712 -+ return 0;
8713 - }
8714 -
8715 - static void vtpm_proxy_tpm_op_cancel(struct tpm_chip *chip)
8716 -diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
8717 -index b150f87f38f5..5a327eb7f63a 100644
8718 ---- a/drivers/char/tpm/xen-tpmfront.c
8719 -+++ b/drivers/char/tpm/xen-tpmfront.c
8720 -@@ -173,7 +173,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
8721 - return -ETIME;
8722 - }
8723 -
8724 -- return count;
8725 -+ return 0;
8726 - }
8727 -
8728 - static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
8729 -diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c
8730 -index 545dceec0bbf..fdfe2e423d15 100644
8731 ---- a/drivers/clk/clk-fractional-divider.c
8732 -+++ b/drivers/clk/clk-fractional-divider.c
8733 -@@ -79,7 +79,7 @@ static long clk_fd_round_rate(struct clk_hw *hw, unsigned long rate,
8734 - unsigned long m, n;
8735 - u64 ret;
8736 -
8737 -- if (!rate || rate >= *parent_rate)
8738 -+ if (!rate || (!clk_hw_can_set_rate_parent(hw) && rate >= *parent_rate))
8739 - return *parent_rate;
8740 -
8741 - if (fd->approximation)
8742 -diff --git a/drivers/clk/clk-twl6040.c b/drivers/clk/clk-twl6040.c
8743 -index ea846f77750b..0cad5748bf0e 100644
8744 ---- a/drivers/clk/clk-twl6040.c
8745 -+++ b/drivers/clk/clk-twl6040.c
8746 -@@ -41,6 +41,43 @@ static int twl6040_pdmclk_is_prepared(struct clk_hw *hw)
8747 - return pdmclk->enabled;
8748 - }
8749 -
8750 -+static int twl6040_pdmclk_reset_one_clock(struct twl6040_pdmclk *pdmclk,
8751 -+ unsigned int reg)
8752 -+{
8753 -+ const u8 reset_mask = TWL6040_HPLLRST; /* Same for HPPLL and LPPLL */
8754 -+ int ret;
8755 -+
8756 -+ ret = twl6040_set_bits(pdmclk->twl6040, reg, reset_mask);
8757 -+ if (ret < 0)
8758 -+ return ret;
8759 -+
8760 -+ ret = twl6040_clear_bits(pdmclk->twl6040, reg, reset_mask);
8761 -+ if (ret < 0)
8762 -+ return ret;
8763 -+
8764 -+ return 0;
8765 -+}
8766 -+
8767 -+/*
8768 -+ * TWL6040A2 Phoenix Audio IC erratum #6: "PDM Clock Generation Issue At
8769 -+ * Cold Temperature". This affects cold boot and deeper idle states it
8770 -+ * seems. The workaround consists of resetting HPPLL and LPPLL.
8771 -+ */
8772 -+static int twl6040_pdmclk_quirk_reset_clocks(struct twl6040_pdmclk *pdmclk)
8773 -+{
8774 -+ int ret;
8775 -+
8776 -+ ret = twl6040_pdmclk_reset_one_clock(pdmclk, TWL6040_REG_HPPLLCTL);
8777 -+ if (ret)
8778 -+ return ret;
8779 -+
8780 -+ ret = twl6040_pdmclk_reset_one_clock(pdmclk, TWL6040_REG_LPPLLCTL);
8781 -+ if (ret)
8782 -+ return ret;
8783 -+
8784 -+ return 0;
8785 -+}
8786 -+
8787 - static int twl6040_pdmclk_prepare(struct clk_hw *hw)
8788 - {
8789 - struct twl6040_pdmclk *pdmclk = container_of(hw, struct twl6040_pdmclk,
8790 -@@ -48,8 +85,20 @@ static int twl6040_pdmclk_prepare(struct clk_hw *hw)
8791 - int ret;
8792 -
8793 - ret = twl6040_power(pdmclk->twl6040, 1);
8794 -- if (!ret)
8795 -- pdmclk->enabled = 1;
8796 -+ if (ret)
8797 -+ return ret;
8798 -+
8799 -+ ret = twl6040_pdmclk_quirk_reset_clocks(pdmclk);
8800 -+ if (ret)
8801 -+ goto out_err;
8802 -+
8803 -+ pdmclk->enabled = 1;
8804 -+
8805 -+ return 0;
8806 -+
8807 -+out_err:
8808 -+ dev_err(pdmclk->dev, "%s: error %i\n", __func__, ret);
8809 -+ twl6040_power(pdmclk->twl6040, 0);
8810 -
8811 - return ret;
8812 - }
8813 -diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c
8814 -index 5ef7d9ba2195..b40160eb3372 100644
8815 ---- a/drivers/clk/ingenic/cgu.c
8816 -+++ b/drivers/clk/ingenic/cgu.c
8817 -@@ -426,16 +426,16 @@ ingenic_clk_round_rate(struct clk_hw *hw, unsigned long req_rate,
8818 - struct ingenic_clk *ingenic_clk = to_ingenic_clk(hw);
8819 - struct ingenic_cgu *cgu = ingenic_clk->cgu;
8820 - const struct ingenic_cgu_clk_info *clk_info;
8821 -- long rate = *parent_rate;
8822 -+ unsigned int div = 1;
8823 -
8824 - clk_info = &cgu->clock_info[ingenic_clk->idx];
8825 -
8826 - if (clk_info->type & CGU_CLK_DIV)
8827 -- rate /= ingenic_clk_calc_div(clk_info, *parent_rate, req_rate);
8828 -+ div = ingenic_clk_calc_div(clk_info, *parent_rate, req_rate);
8829 - else if (clk_info->type & CGU_CLK_FIXDIV)
8830 -- rate /= clk_info->fixdiv.div;
8831 -+ div = clk_info->fixdiv.div;
8832 -
8833 -- return rate;
8834 -+ return DIV_ROUND_UP(*parent_rate, div);
8835 - }
8836 -
8837 - static int
8838 -@@ -455,7 +455,7 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate,
8839 -
8840 - if (clk_info->type & CGU_CLK_DIV) {
8841 - div = ingenic_clk_calc_div(clk_info, parent_rate, req_rate);
8842 -- rate = parent_rate / div;
8843 -+ rate = DIV_ROUND_UP(parent_rate, div);
8844 -
8845 - if (rate != req_rate)
8846 - return -EINVAL;
8847 -diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h
8848 -index 502bcbb61b04..e12716d8ce3c 100644
8849 ---- a/drivers/clk/ingenic/cgu.h
8850 -+++ b/drivers/clk/ingenic/cgu.h
8851 -@@ -80,7 +80,7 @@ struct ingenic_cgu_mux_info {
8852 - * @reg: offset of the divider control register within the CGU
8853 - * @shift: number of bits to left shift the divide value by (ie. the index of
8854 - * the lowest bit of the divide value within its control register)
8855 -- * @div: number of bits to divide the divider value by (i.e. if the
8856 -+ * @div: number to divide the divider value by (i.e. if the
8857 - * effective divider value is the value written to the register
8858 - * multiplied by some constant)
8859 - * @bits: the size of the divide value in bits
8860 -diff --git a/drivers/clk/rockchip/clk-rk3328.c b/drivers/clk/rockchip/clk-rk3328.c
8861 -index faa94adb2a37..65ab5c2f48b0 100644
8862 ---- a/drivers/clk/rockchip/clk-rk3328.c
8863 -+++ b/drivers/clk/rockchip/clk-rk3328.c
8864 -@@ -78,17 +78,17 @@ static struct rockchip_pll_rate_table rk3328_pll_rates[] = {
8865 -
8866 - static struct rockchip_pll_rate_table rk3328_pll_frac_rates[] = {
8867 - /* _mhz, _refdiv, _fbdiv, _postdiv1, _postdiv2, _dsmpd, _frac */
8868 -- RK3036_PLL_RATE(1016064000, 3, 127, 1, 1, 0, 134217),
8869 -+ RK3036_PLL_RATE(1016064000, 3, 127, 1, 1, 0, 134218),
8870 - /* vco = 1016064000 */
8871 -- RK3036_PLL_RATE(983040000, 24, 983, 1, 1, 0, 671088),
8872 -+ RK3036_PLL_RATE(983040000, 24, 983, 1, 1, 0, 671089),
8873 - /* vco = 983040000 */
8874 -- RK3036_PLL_RATE(491520000, 24, 983, 2, 1, 0, 671088),
8875 -+ RK3036_PLL_RATE(491520000, 24, 983, 2, 1, 0, 671089),
8876 - /* vco = 983040000 */
8877 -- RK3036_PLL_RATE(61440000, 6, 215, 7, 2, 0, 671088),
8878 -+ RK3036_PLL_RATE(61440000, 6, 215, 7, 2, 0, 671089),
8879 - /* vco = 860156000 */
8880 -- RK3036_PLL_RATE(56448000, 12, 451, 4, 4, 0, 9797894),
8881 -+ RK3036_PLL_RATE(56448000, 12, 451, 4, 4, 0, 9797895),
8882 - /* vco = 903168000 */
8883 -- RK3036_PLL_RATE(40960000, 12, 409, 4, 5, 0, 10066329),
8884 -+ RK3036_PLL_RATE(40960000, 12, 409, 4, 5, 0, 10066330),
8885 - /* vco = 819200000 */
8886 - { /* sentinel */ },
8887 - };
8888 -diff --git a/drivers/clk/samsung/clk-exynos5-subcmu.c b/drivers/clk/samsung/clk-exynos5-subcmu.c
8889 -index 93306283d764..8ae44b5db4c2 100644
8890 ---- a/drivers/clk/samsung/clk-exynos5-subcmu.c
8891 -+++ b/drivers/clk/samsung/clk-exynos5-subcmu.c
8892 -@@ -136,15 +136,20 @@ static int __init exynos5_clk_register_subcmu(struct device *parent,
8893 - {
8894 - struct of_phandle_args genpdspec = { .np = pd_node };
8895 - struct platform_device *pdev;
8896 -+ int ret;
8897 -+
8898 -+ pdev = platform_device_alloc("exynos5-subcmu", PLATFORM_DEVID_AUTO);
8899 -+ if (!pdev)
8900 -+ return -ENOMEM;
8901 -
8902 -- pdev = platform_device_alloc(info->pd_name, -1);
8903 - pdev->dev.parent = parent;
8904 -- pdev->driver_override = "exynos5-subcmu";
8905 - platform_set_drvdata(pdev, (void *)info);
8906 - of_genpd_add_device(&genpdspec, &pdev->dev);
8907 -- platform_device_add(pdev);
8908 -+ ret = platform_device_add(pdev);
8909 -+ if (ret)
8910 -+ platform_device_put(pdev);
8911 -
8912 -- return 0;
8913 -+ return ret;
8914 - }
8915 -
8916 - static int __init exynos5_clk_probe(struct platform_device *pdev)
8917 -diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
8918 -index 40630eb950fc..85d7f301149b 100644
8919 ---- a/drivers/clk/ti/clkctrl.c
8920 -+++ b/drivers/clk/ti/clkctrl.c
8921 -@@ -530,7 +530,7 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
8922 - * Create default clkdm name, replace _cm from end of parent
8923 - * node name with _clkdm
8924 - */
8925 -- provider->clkdm_name[strlen(provider->clkdm_name) - 5] = 0;
8926 -+ provider->clkdm_name[strlen(provider->clkdm_name) - 2] = 0;
8927 - } else {
8928 - provider->clkdm_name = kasprintf(GFP_KERNEL, "%pOFn", node);
8929 - if (!provider->clkdm_name) {
8930 -diff --git a/drivers/clk/uniphier/clk-uniphier-cpugear.c b/drivers/clk/uniphier/clk-uniphier-cpugear.c
8931 -index ec11f55594ad..5d2d42b7e182 100644
8932 ---- a/drivers/clk/uniphier/clk-uniphier-cpugear.c
8933 -+++ b/drivers/clk/uniphier/clk-uniphier-cpugear.c
8934 -@@ -47,7 +47,7 @@ static int uniphier_clk_cpugear_set_parent(struct clk_hw *hw, u8 index)
8935 - return ret;
8936 -
8937 - ret = regmap_write_bits(gear->regmap,
8938 -- gear->regbase + UNIPHIER_CLK_CPUGEAR_SET,
8939 -+ gear->regbase + UNIPHIER_CLK_CPUGEAR_UPD,
8940 - UNIPHIER_CLK_CPUGEAR_UPD_BIT,
8941 - UNIPHIER_CLK_CPUGEAR_UPD_BIT);
8942 - if (ret)
8943 -diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
8944 -index a9e26f6a81a1..8dfd3bc448d0 100644
8945 ---- a/drivers/clocksource/Kconfig
8946 -+++ b/drivers/clocksource/Kconfig
8947 -@@ -360,6 +360,16 @@ config ARM64_ERRATUM_858921
8948 - The workaround will be dynamically enabled when an affected
8949 - core is detected.
8950 -
8951 -+config SUN50I_ERRATUM_UNKNOWN1
8952 -+ bool "Workaround for Allwinner A64 erratum UNKNOWN1"
8953 -+ default y
8954 -+ depends on ARM_ARCH_TIMER && ARM64 && ARCH_SUNXI
8955 -+ select ARM_ARCH_TIMER_OOL_WORKAROUND
8956 -+ help
8957 -+ This option enables a workaround for instability in the timer on
8958 -+ the Allwinner A64 SoC. The workaround will only be active if the
8959 -+ allwinner,erratum-unknown1 property is found in the timer node.
8960 -+
8961 - config ARM_GLOBAL_TIMER
8962 - bool "Support for the ARM global timer" if COMPILE_TEST
8963 - select TIMER_OF if OF
8964 -diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
8965 -index 9a7d4dc00b6e..a8b20b65bd4b 100644
8966 ---- a/drivers/clocksource/arm_arch_timer.c
8967 -+++ b/drivers/clocksource/arm_arch_timer.c
8968 -@@ -326,6 +326,48 @@ static u64 notrace arm64_1188873_read_cntvct_el0(void)
8969 - }
8970 - #endif
8971 -
8972 -+#ifdef CONFIG_SUN50I_ERRATUM_UNKNOWN1
8973 -+/*
8974 -+ * The low bits of the counter registers are indeterminate while bit 10 or
8975 -+ * greater is rolling over. Since the counter value can jump both backward
8976 -+ * (7ff -> 000 -> 800) and forward (7ff -> fff -> 800), ignore register values
8977 -+ * with all ones or all zeros in the low bits. Bound the loop by the maximum
8978 -+ * number of CPU cycles in 3 consecutive 24 MHz counter periods.
8979 -+ */
8980 -+#define __sun50i_a64_read_reg(reg) ({ \
8981 -+ u64 _val; \
8982 -+ int _retries = 150; \
8983 -+ \
8984 -+ do { \
8985 -+ _val = read_sysreg(reg); \
8986 -+ _retries--; \
8987 -+ } while (((_val + 1) & GENMASK(9, 0)) <= 1 && _retries); \
8988 -+ \
8989 -+ WARN_ON_ONCE(!_retries); \
8990 -+ _val; \
8991 -+})
8992 -+
8993 -+static u64 notrace sun50i_a64_read_cntpct_el0(void)
8994 -+{
8995 -+ return __sun50i_a64_read_reg(cntpct_el0);
8996 -+}
8997 -+
8998 -+static u64 notrace sun50i_a64_read_cntvct_el0(void)
8999 -+{
9000 -+ return __sun50i_a64_read_reg(cntvct_el0);
9001 -+}
9002 -+
9003 -+static u32 notrace sun50i_a64_read_cntp_tval_el0(void)
9004 -+{
9005 -+ return read_sysreg(cntp_cval_el0) - sun50i_a64_read_cntpct_el0();
9006 -+}
9007 -+
9008 -+static u32 notrace sun50i_a64_read_cntv_tval_el0(void)
9009 -+{
9010 -+ return read_sysreg(cntv_cval_el0) - sun50i_a64_read_cntvct_el0();
9011 -+}
9012 -+#endif
9013 -+
9014 - #ifdef CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND
9015 - DEFINE_PER_CPU(const struct arch_timer_erratum_workaround *, timer_unstable_counter_workaround);
9016 - EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround);
9017 -@@ -423,6 +465,19 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
9018 - .read_cntvct_el0 = arm64_1188873_read_cntvct_el0,
9019 - },
9020 - #endif
9021 -+#ifdef CONFIG_SUN50I_ERRATUM_UNKNOWN1
9022 -+ {
9023 -+ .match_type = ate_match_dt,
9024 -+ .id = "allwinner,erratum-unknown1",
9025 -+ .desc = "Allwinner erratum UNKNOWN1",
9026 -+ .read_cntp_tval_el0 = sun50i_a64_read_cntp_tval_el0,
9027 -+ .read_cntv_tval_el0 = sun50i_a64_read_cntv_tval_el0,
9028 -+ .read_cntpct_el0 = sun50i_a64_read_cntpct_el0,
9029 -+ .read_cntvct_el0 = sun50i_a64_read_cntvct_el0,
9030 -+ .set_next_event_phys = erratum_set_next_event_tval_phys,
9031 -+ .set_next_event_virt = erratum_set_next_event_tval_virt,
9032 -+ },
9033 -+#endif
9034 - };
9035 -
9036 - typedef bool (*ate_match_fn_t)(const struct arch_timer_erratum_workaround *,
9037 -diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
9038 -index 7a244b681876..d55c30f6981d 100644
9039 ---- a/drivers/clocksource/exynos_mct.c
9040 -+++ b/drivers/clocksource/exynos_mct.c
9041 -@@ -388,6 +388,13 @@ static void exynos4_mct_tick_start(unsigned long cycles,
9042 - exynos4_mct_write(tmp, mevt->base + MCT_L_TCON_OFFSET);
9043 - }
9044 -
9045 -+static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
9046 -+{
9047 -+ /* Clear the MCT tick interrupt */
9048 -+ if (readl_relaxed(reg_base + mevt->base + MCT_L_INT_CSTAT_OFFSET) & 1)
9049 -+ exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET);
9050 -+}
9051 -+
9052 - static int exynos4_tick_set_next_event(unsigned long cycles,
9053 - struct clock_event_device *evt)
9054 - {
9055 -@@ -404,6 +411,7 @@ static int set_state_shutdown(struct clock_event_device *evt)
9056 -
9057 - mevt = container_of(evt, struct mct_clock_event_device, evt);
9058 - exynos4_mct_tick_stop(mevt);
9059 -+ exynos4_mct_tick_clear(mevt);
9060 - return 0;
9061 - }
9062 -
9063 -@@ -420,8 +428,11 @@ static int set_state_periodic(struct clock_event_device *evt)
9064 - return 0;
9065 - }
9066 -
9067 --static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
9068 -+static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
9069 - {
9070 -+ struct mct_clock_event_device *mevt = dev_id;
9071 -+ struct clock_event_device *evt = &mevt->evt;
9072 -+
9073 - /*
9074 - * This is for supporting oneshot mode.
9075 - * Mct would generate interrupt periodically
9076 -@@ -430,16 +441,6 @@ static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
9077 - if (!clockevent_state_periodic(&mevt->evt))
9078 - exynos4_mct_tick_stop(mevt);
9079 -
9080 -- /* Clear the MCT tick interrupt */
9081 -- if (readl_relaxed(reg_base + mevt->base + MCT_L_INT_CSTAT_OFFSET) & 1)
9082 -- exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET);
9083 --}
9084 --
9085 --static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
9086 --{
9087 -- struct mct_clock_event_device *mevt = dev_id;
9088 -- struct clock_event_device *evt = &mevt->evt;
9089 --
9090 - exynos4_mct_tick_clear(mevt);
9091 -
9092 - evt->event_handler(evt);
9093 -diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
9094 -index 431892200a08..ead71bfac689 100644
9095 ---- a/drivers/clocksource/timer-riscv.c
9096 -+++ b/drivers/clocksource/timer-riscv.c
9097 -@@ -58,7 +58,7 @@ static u64 riscv_sched_clock(void)
9098 - static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = {
9099 - .name = "riscv_clocksource",
9100 - .rating = 300,
9101 -- .mask = CLOCKSOURCE_MASK(BITS_PER_LONG),
9102 -+ .mask = CLOCKSOURCE_MASK(64),
9103 - .flags = CLOCK_SOURCE_IS_CONTINUOUS,
9104 - .read = riscv_clocksource_rdtime,
9105 - };
9106 -@@ -103,8 +103,7 @@ static int __init riscv_timer_init_dt(struct device_node *n)
9107 - cs = per_cpu_ptr(&riscv_clocksource, cpuid);
9108 - clocksource_register_hz(cs, riscv_timebase);
9109 -
9110 -- sched_clock_register(riscv_sched_clock,
9111 -- BITS_PER_LONG, riscv_timebase);
9112 -+ sched_clock_register(riscv_sched_clock, 64, riscv_timebase);
9113 -
9114 - error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING,
9115 - "clockevents/riscv/timer:starting",
9116 -diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
9117 -index ed5e42461094..ad48fd52cb53 100644
9118 ---- a/drivers/connector/cn_proc.c
9119 -+++ b/drivers/connector/cn_proc.c
9120 -@@ -250,6 +250,7 @@ void proc_coredump_connector(struct task_struct *task)
9121 - {
9122 - struct cn_msg *msg;
9123 - struct proc_event *ev;
9124 -+ struct task_struct *parent;
9125 - __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
9126 -
9127 - if (atomic_read(&proc_event_num_listeners) < 1)
9128 -@@ -262,8 +263,14 @@ void proc_coredump_connector(struct task_struct *task)
9129 - ev->what = PROC_EVENT_COREDUMP;
9130 - ev->event_data.coredump.process_pid = task->pid;
9131 - ev->event_data.coredump.process_tgid = task->tgid;
9132 -- ev->event_data.coredump.parent_pid = task->real_parent->pid;
9133 -- ev->event_data.coredump.parent_tgid = task->real_parent->tgid;
9134 -+
9135 -+ rcu_read_lock();
9136 -+ if (pid_alive(task)) {
9137 -+ parent = rcu_dereference(task->real_parent);
9138 -+ ev->event_data.coredump.parent_pid = parent->pid;
9139 -+ ev->event_data.coredump.parent_tgid = parent->tgid;
9140 -+ }
9141 -+ rcu_read_unlock();
9142 -
9143 - memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
9144 - msg->ack = 0; /* not used */
9145 -@@ -276,6 +283,7 @@ void proc_exit_connector(struct task_struct *task)
9146 - {
9147 - struct cn_msg *msg;
9148 - struct proc_event *ev;
9149 -+ struct task_struct *parent;
9150 - __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
9151 -
9152 - if (atomic_read(&proc_event_num_listeners) < 1)
9153 -@@ -290,8 +298,14 @@ void proc_exit_connector(struct task_struct *task)
9154 - ev->event_data.exit.process_tgid = task->tgid;
9155 - ev->event_data.exit.exit_code = task->exit_code;
9156 - ev->event_data.exit.exit_signal = task->exit_signal;
9157 -- ev->event_data.exit.parent_pid = task->real_parent->pid;
9158 -- ev->event_data.exit.parent_tgid = task->real_parent->tgid;
9159 -+
9160 -+ rcu_read_lock();
9161 -+ if (pid_alive(task)) {
9162 -+ parent = rcu_dereference(task->real_parent);
9163 -+ ev->event_data.exit.parent_pid = parent->pid;
9164 -+ ev->event_data.exit.parent_tgid = parent->tgid;
9165 -+ }
9166 -+ rcu_read_unlock();
9167 -
9168 - memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
9169 - msg->ack = 0; /* not used */
9170 -diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
9171 -index d62fd374d5c7..c72258a44ba4 100644
9172 ---- a/drivers/cpufreq/acpi-cpufreq.c
9173 -+++ b/drivers/cpufreq/acpi-cpufreq.c
9174 -@@ -916,8 +916,10 @@ static void __init acpi_cpufreq_boost_init(void)
9175 - {
9176 - int ret;
9177 -
9178 -- if (!(boot_cpu_has(X86_FEATURE_CPB) || boot_cpu_has(X86_FEATURE_IDA)))
9179 -+ if (!(boot_cpu_has(X86_FEATURE_CPB) || boot_cpu_has(X86_FEATURE_IDA))) {
9180 -+ pr_debug("Boost capabilities not present in the processor\n");
9181 - return;
9182 -+ }
9183 -
9184 - acpi_cpufreq_driver.set_boost = set_boost;
9185 - acpi_cpufreq_driver.boost_enabled = boost_state(0);
9186 -diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
9187 -index e35a886e00bc..ef0e33e21b98 100644
9188 ---- a/drivers/cpufreq/cpufreq.c
9189 -+++ b/drivers/cpufreq/cpufreq.c
9190 -@@ -545,13 +545,13 @@ EXPORT_SYMBOL_GPL(cpufreq_policy_transition_delay_us);
9191 - * SYSFS INTERFACE *
9192 - *********************************************************************/
9193 - static ssize_t show_boost(struct kobject *kobj,
9194 -- struct attribute *attr, char *buf)
9195 -+ struct kobj_attribute *attr, char *buf)
9196 - {
9197 - return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
9198 - }
9199 -
9200 --static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
9201 -- const char *buf, size_t count)
9202 -+static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr,
9203 -+ const char *buf, size_t count)
9204 - {
9205 - int ret, enable;
9206 -
9207 -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
9208 -index dd66decf2087..a579ca4552df 100644
9209 ---- a/drivers/cpufreq/intel_pstate.c
9210 -+++ b/drivers/cpufreq/intel_pstate.c
9211 -@@ -383,7 +383,10 @@ static int intel_pstate_get_cppc_guranteed(int cpu)
9212 - if (ret)
9213 - return ret;
9214 -
9215 -- return cppc_perf.guaranteed_perf;
9216 -+ if (cppc_perf.guaranteed_perf)
9217 -+ return cppc_perf.guaranteed_perf;
9218 -+
9219 -+ return cppc_perf.nominal_perf;
9220 - }
9221 -
9222 - #else /* CONFIG_ACPI_CPPC_LIB */
9223 -@@ -895,7 +898,7 @@ static void intel_pstate_update_policies(void)
9224 - /************************** sysfs begin ************************/
9225 - #define show_one(file_name, object) \
9226 - static ssize_t show_##file_name \
9227 -- (struct kobject *kobj, struct attribute *attr, char *buf) \
9228 -+ (struct kobject *kobj, struct kobj_attribute *attr, char *buf) \
9229 - { \
9230 - return sprintf(buf, "%u\n", global.object); \
9231 - }
9232 -@@ -904,7 +907,7 @@ static ssize_t intel_pstate_show_status(char *buf);
9233 - static int intel_pstate_update_status(const char *buf, size_t size);
9234 -
9235 - static ssize_t show_status(struct kobject *kobj,
9236 -- struct attribute *attr, char *buf)
9237 -+ struct kobj_attribute *attr, char *buf)
9238 - {
9239 - ssize_t ret;
9240 -
9241 -@@ -915,7 +918,7 @@ static ssize_t show_status(struct kobject *kobj,
9242 - return ret;
9243 - }
9244 -
9245 --static ssize_t store_status(struct kobject *a, struct attribute *b,
9246 -+static ssize_t store_status(struct kobject *a, struct kobj_attribute *b,
9247 - const char *buf, size_t count)
9248 - {
9249 - char *p = memchr(buf, '\n', count);
9250 -@@ -929,7 +932,7 @@ static ssize_t store_status(struct kobject *a, struct attribute *b,
9251 - }
9252 -
9253 - static ssize_t show_turbo_pct(struct kobject *kobj,
9254 -- struct attribute *attr, char *buf)
9255 -+ struct kobj_attribute *attr, char *buf)
9256 - {
9257 - struct cpudata *cpu;
9258 - int total, no_turbo, turbo_pct;
9259 -@@ -955,7 +958,7 @@ static ssize_t show_turbo_pct(struct kobject *kobj,
9260 - }
9261 -
9262 - static ssize_t show_num_pstates(struct kobject *kobj,
9263 -- struct attribute *attr, char *buf)
9264 -+ struct kobj_attribute *attr, char *buf)
9265 - {
9266 - struct cpudata *cpu;
9267 - int total;
9268 -@@ -976,7 +979,7 @@ static ssize_t show_num_pstates(struct kobject *kobj,
9269 - }
9270 -
9271 - static ssize_t show_no_turbo(struct kobject *kobj,
9272 -- struct attribute *attr, char *buf)
9273 -+ struct kobj_attribute *attr, char *buf)
9274 - {
9275 - ssize_t ret;
9276 -
9277 -@@ -998,7 +1001,7 @@ static ssize_t show_no_turbo(struct kobject *kobj,
9278 - return ret;
9279 - }
9280 -
9281 --static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
9282 -+static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
9283 - const char *buf, size_t count)
9284 - {
9285 - unsigned int input;
9286 -@@ -1045,7 +1048,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
9287 - return count;
9288 - }
9289 -
9290 --static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
9291 -+static ssize_t store_max_perf_pct(struct kobject *a, struct kobj_attribute *b,
9292 - const char *buf, size_t count)
9293 - {
9294 - unsigned int input;
9295 -@@ -1075,7 +1078,7 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
9296 - return count;
9297 - }
9298 -
9299 --static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
9300 -+static ssize_t store_min_perf_pct(struct kobject *a, struct kobj_attribute *b,
9301 - const char *buf, size_t count)
9302 - {
9303 - unsigned int input;
9304 -@@ -1107,12 +1110,13 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
9305 - }
9306 -
9307 - static ssize_t show_hwp_dynamic_boost(struct kobject *kobj,
9308 -- struct attribute *attr, char *buf)
9309 -+ struct kobj_attribute *attr, char *buf)
9310 - {
9311 - return sprintf(buf, "%u\n", hwp_boost);
9312 - }
9313 -
9314 --static ssize_t store_hwp_dynamic_boost(struct kobject *a, struct attribute *b,
9315 -+static ssize_t store_hwp_dynamic_boost(struct kobject *a,
9316 -+ struct kobj_attribute *b,
9317 - const char *buf, size_t count)
9318 - {
9319 - unsigned int input;
9320 -diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
9321 -index 46254e583982..74e0e0c20c46 100644
9322 ---- a/drivers/cpufreq/pxa2xx-cpufreq.c
9323 -+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
9324 -@@ -143,7 +143,7 @@ static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
9325 - return ret;
9326 - }
9327 -
9328 --static void __init pxa_cpufreq_init_voltages(void)
9329 -+static void pxa_cpufreq_init_voltages(void)
9330 - {
9331 - vcc_core = regulator_get(NULL, "vcc_core");
9332 - if (IS_ERR(vcc_core)) {
9333 -@@ -159,7 +159,7 @@ static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
9334 - return 0;
9335 - }
9336 -
9337 --static void __init pxa_cpufreq_init_voltages(void) { }
9338 -+static void pxa_cpufreq_init_voltages(void) { }
9339 - #endif
9340 -
9341 - static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
9342 -diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
9343 -index 2a3675c24032..a472b814058f 100644
9344 ---- a/drivers/cpufreq/qcom-cpufreq-kryo.c
9345 -+++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
9346 -@@ -75,7 +75,7 @@ static enum _msm8996_version qcom_cpufreq_kryo_get_msm_id(void)
9347 -
9348 - static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
9349 - {
9350 -- struct opp_table *opp_tables[NR_CPUS] = {0};
9351 -+ struct opp_table **opp_tables;
9352 - enum _msm8996_version msm8996_version;
9353 - struct nvmem_cell *speedbin_nvmem;
9354 - struct device_node *np;
9355 -@@ -133,6 +133,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
9356 - }
9357 - kfree(speedbin);
9358 -
9359 -+ opp_tables = kcalloc(num_possible_cpus(), sizeof(*opp_tables), GFP_KERNEL);
9360 -+ if (!opp_tables)
9361 -+ return -ENOMEM;
9362 -+
9363 - for_each_possible_cpu(cpu) {
9364 - cpu_dev = get_cpu_device(cpu);
9365 - if (NULL == cpu_dev) {
9366 -@@ -151,8 +155,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
9367 -
9368 - cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
9369 - NULL, 0);
9370 -- if (!IS_ERR(cpufreq_dt_pdev))
9371 -+ if (!IS_ERR(cpufreq_dt_pdev)) {
9372 -+ platform_set_drvdata(pdev, opp_tables);
9373 - return 0;
9374 -+ }
9375 -
9376 - ret = PTR_ERR(cpufreq_dt_pdev);
9377 - dev_err(cpu_dev, "Failed to register platform device\n");
9378 -@@ -163,13 +169,23 @@ free_opp:
9379 - break;
9380 - dev_pm_opp_put_supported_hw(opp_tables[cpu]);
9381 - }
9382 -+ kfree(opp_tables);
9383 -
9384 - return ret;
9385 - }
9386 -
9387 - static int qcom_cpufreq_kryo_remove(struct platform_device *pdev)
9388 - {
9389 -+ struct opp_table **opp_tables = platform_get_drvdata(pdev);
9390 -+ unsigned int cpu;
9391 -+
9392 - platform_device_unregister(cpufreq_dt_pdev);
9393 -+
9394 -+ for_each_possible_cpu(cpu)
9395 -+ dev_pm_opp_put_supported_hw(opp_tables[cpu]);
9396 -+
9397 -+ kfree(opp_tables);
9398 -+
9399 - return 0;
9400 - }
9401 -
9402 -diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
9403 -index 99449738faa4..632ccf82c5d3 100644
9404 ---- a/drivers/cpufreq/scpi-cpufreq.c
9405 -+++ b/drivers/cpufreq/scpi-cpufreq.c
9406 -@@ -189,8 +189,8 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
9407 - cpufreq_cooling_unregister(priv->cdev);
9408 - clk_put(priv->clk);
9409 - dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
9410 -- kfree(priv);
9411 - dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
9412 -+ kfree(priv);
9413 -
9414 - return 0;
9415 - }
9416 -diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c
9417 -index 43530254201a..4bb154f6c54c 100644
9418 ---- a/drivers/cpufreq/tegra124-cpufreq.c
9419 -+++ b/drivers/cpufreq/tegra124-cpufreq.c
9420 -@@ -134,6 +134,8 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
9421 -
9422 - platform_set_drvdata(pdev, priv);
9423 -
9424 -+ of_node_put(np);
9425 -+
9426 - return 0;
9427 -
9428 - out_switch_to_pllx:
9429 -diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
9430 -index bb93e5cf6a4a..9fddf828a76f 100644
9431 ---- a/drivers/cpuidle/governor.c
9432 -+++ b/drivers/cpuidle/governor.c
9433 -@@ -89,6 +89,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
9434 - mutex_lock(&cpuidle_lock);
9435 - if (__cpuidle_find_governor(gov->name) == NULL) {
9436 - ret = 0;
9437 -+ list_add_tail(&gov->governor_list, &cpuidle_governors);
9438 - if (!cpuidle_curr_governor ||
9439 - !strncasecmp(param_governor, gov->name, CPUIDLE_NAME_LEN) ||
9440 - (cpuidle_curr_governor->rating < gov->rating &&
9441 -diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
9442 -index 5e63742b0d22..53ab1f140a26 100644
9443 ---- a/drivers/crypto/amcc/crypto4xx_trng.c
9444 -+++ b/drivers/crypto/amcc/crypto4xx_trng.c
9445 -@@ -80,8 +80,10 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
9446 -
9447 - /* Find the TRNG device node and map it */
9448 - trng = of_find_matching_node(NULL, ppc4xx_trng_match);
9449 -- if (!trng || !of_device_is_available(trng))
9450 -+ if (!trng || !of_device_is_available(trng)) {
9451 -+ of_node_put(trng);
9452 - return;
9453 -+ }
9454 -
9455 - dev->trng_base = of_iomap(trng, 0);
9456 - of_node_put(trng);
9457 -diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
9458 -index 80ae69f906fb..1c4f3a046dc5 100644
9459 ---- a/drivers/crypto/caam/caamalg.c
9460 -+++ b/drivers/crypto/caam/caamalg.c
9461 -@@ -1040,6 +1040,7 @@ static void init_aead_job(struct aead_request *req,
9462 - if (unlikely(req->src != req->dst)) {
9463 - if (edesc->dst_nents == 1) {
9464 - dst_dma = sg_dma_address(req->dst);
9465 -+ out_options = 0;
9466 - } else {
9467 - dst_dma = edesc->sec4_sg_dma +
9468 - sec4_sg_index *
9469 -diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
9470 -index bb1a2cdf1951..0f11811a3585 100644
9471 ---- a/drivers/crypto/caam/caamhash.c
9472 -+++ b/drivers/crypto/caam/caamhash.c
9473 -@@ -113,6 +113,7 @@ struct caam_hash_ctx {
9474 - struct caam_hash_state {
9475 - dma_addr_t buf_dma;
9476 - dma_addr_t ctx_dma;
9477 -+ int ctx_dma_len;
9478 - u8 buf_0[CAAM_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned;
9479 - int buflen_0;
9480 - u8 buf_1[CAAM_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned;
9481 -@@ -165,6 +166,7 @@ static inline int map_seq_out_ptr_ctx(u32 *desc, struct device *jrdev,
9482 - struct caam_hash_state *state,
9483 - int ctx_len)
9484 - {
9485 -+ state->ctx_dma_len = ctx_len;
9486 - state->ctx_dma = dma_map_single(jrdev, state->caam_ctx,
9487 - ctx_len, DMA_FROM_DEVICE);
9488 - if (dma_mapping_error(jrdev, state->ctx_dma)) {
9489 -@@ -178,18 +180,6 @@ static inline int map_seq_out_ptr_ctx(u32 *desc, struct device *jrdev,
9490 - return 0;
9491 - }
9492 -
9493 --/* Map req->result, and append seq_out_ptr command that points to it */
9494 --static inline dma_addr_t map_seq_out_ptr_result(u32 *desc, struct device *jrdev,
9495 -- u8 *result, int digestsize)
9496 --{
9497 -- dma_addr_t dst_dma;
9498 --
9499 -- dst_dma = dma_map_single(jrdev, result, digestsize, DMA_FROM_DEVICE);
9500 -- append_seq_out_ptr(desc, dst_dma, digestsize, 0);
9501 --
9502 -- return dst_dma;
9503 --}
9504 --
9505 - /* Map current buffer in state (if length > 0) and put it in link table */
9506 - static inline int buf_map_to_sec4_sg(struct device *jrdev,
9507 - struct sec4_sg_entry *sec4_sg,
9508 -@@ -218,6 +208,7 @@ static inline int ctx_map_to_sec4_sg(struct device *jrdev,
9509 - struct caam_hash_state *state, int ctx_len,
9510 - struct sec4_sg_entry *sec4_sg, u32 flag)
9511 - {
9512 -+ state->ctx_dma_len = ctx_len;
9513 - state->ctx_dma = dma_map_single(jrdev, state->caam_ctx, ctx_len, flag);
9514 - if (dma_mapping_error(jrdev, state->ctx_dma)) {
9515 - dev_err(jrdev, "unable to map ctx\n");
9516 -@@ -426,7 +417,6 @@ static int ahash_setkey(struct crypto_ahash *ahash,
9517 -
9518 - /*
9519 - * ahash_edesc - s/w-extended ahash descriptor
9520 -- * @dst_dma: physical mapped address of req->result
9521 - * @sec4_sg_dma: physical mapped address of h/w link table
9522 - * @src_nents: number of segments in input scatterlist
9523 - * @sec4_sg_bytes: length of dma mapped sec4_sg space
9524 -@@ -434,7 +424,6 @@ static int ahash_setkey(struct crypto_ahash *ahash,
9525 - * @sec4_sg: h/w link table
9526 - */
9527 - struct ahash_edesc {
9528 -- dma_addr_t dst_dma;
9529 - dma_addr_t sec4_sg_dma;
9530 - int src_nents;
9531 - int sec4_sg_bytes;
9532 -@@ -450,8 +439,6 @@ static inline void ahash_unmap(struct device *dev,
9533 -
9534 - if (edesc->src_nents)
9535 - dma_unmap_sg(dev, req->src, edesc->src_nents, DMA_TO_DEVICE);
9536 -- if (edesc->dst_dma)
9537 -- dma_unmap_single(dev, edesc->dst_dma, dst_len, DMA_FROM_DEVICE);
9538 -
9539 - if (edesc->sec4_sg_bytes)
9540 - dma_unmap_single(dev, edesc->sec4_sg_dma,
9541 -@@ -468,12 +455,10 @@ static inline void ahash_unmap_ctx(struct device *dev,
9542 - struct ahash_edesc *edesc,
9543 - struct ahash_request *req, int dst_len, u32 flag)
9544 - {
9545 -- struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
9546 -- struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
9547 - struct caam_hash_state *state = ahash_request_ctx(req);
9548 -
9549 - if (state->ctx_dma) {
9550 -- dma_unmap_single(dev, state->ctx_dma, ctx->ctx_len, flag);
9551 -+ dma_unmap_single(dev, state->ctx_dma, state->ctx_dma_len, flag);
9552 - state->ctx_dma = 0;
9553 - }
9554 - ahash_unmap(dev, edesc, req, dst_len);
9555 -@@ -486,9 +471,9 @@ static void ahash_done(struct device *jrdev, u32 *desc, u32 err,
9556 - struct ahash_edesc *edesc;
9557 - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
9558 - int digestsize = crypto_ahash_digestsize(ahash);
9559 -+ struct caam_hash_state *state = ahash_request_ctx(req);
9560 - #ifdef DEBUG
9561 - struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
9562 -- struct caam_hash_state *state = ahash_request_ctx(req);
9563 -
9564 - dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
9565 - #endif
9566 -@@ -497,17 +482,14 @@ static void ahash_done(struct device *jrdev, u32 *desc, u32 err,
9567 - if (err)
9568 - caam_jr_strstatus(jrdev, err);
9569 -
9570 -- ahash_unmap(jrdev, edesc, req, digestsize);
9571 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9572 -+ memcpy(req->result, state->caam_ctx, digestsize);
9573 - kfree(edesc);
9574 -
9575 - #ifdef DEBUG
9576 - print_hex_dump(KERN_ERR, "ctx@"__stringify(__LINE__)": ",
9577 - DUMP_PREFIX_ADDRESS, 16, 4, state->caam_ctx,
9578 - ctx->ctx_len, 1);
9579 -- if (req->result)
9580 -- print_hex_dump(KERN_ERR, "result@"__stringify(__LINE__)": ",
9581 -- DUMP_PREFIX_ADDRESS, 16, 4, req->result,
9582 -- digestsize, 1);
9583 - #endif
9584 -
9585 - req->base.complete(&req->base, err);
9586 -@@ -555,9 +537,9 @@ static void ahash_done_ctx_src(struct device *jrdev, u32 *desc, u32 err,
9587 - struct ahash_edesc *edesc;
9588 - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
9589 - int digestsize = crypto_ahash_digestsize(ahash);
9590 -+ struct caam_hash_state *state = ahash_request_ctx(req);
9591 - #ifdef DEBUG
9592 - struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
9593 -- struct caam_hash_state *state = ahash_request_ctx(req);
9594 -
9595 - dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
9596 - #endif
9597 -@@ -566,17 +548,14 @@ static void ahash_done_ctx_src(struct device *jrdev, u32 *desc, u32 err,
9598 - if (err)
9599 - caam_jr_strstatus(jrdev, err);
9600 -
9601 -- ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_TO_DEVICE);
9602 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_BIDIRECTIONAL);
9603 -+ memcpy(req->result, state->caam_ctx, digestsize);
9604 - kfree(edesc);
9605 -
9606 - #ifdef DEBUG
9607 - print_hex_dump(KERN_ERR, "ctx@"__stringify(__LINE__)": ",
9608 - DUMP_PREFIX_ADDRESS, 16, 4, state->caam_ctx,
9609 - ctx->ctx_len, 1);
9610 -- if (req->result)
9611 -- print_hex_dump(KERN_ERR, "result@"__stringify(__LINE__)": ",
9612 -- DUMP_PREFIX_ADDRESS, 16, 4, req->result,
9613 -- digestsize, 1);
9614 - #endif
9615 -
9616 - req->base.complete(&req->base, err);
9617 -@@ -837,7 +816,7 @@ static int ahash_final_ctx(struct ahash_request *req)
9618 - edesc->sec4_sg_bytes = sec4_sg_bytes;
9619 -
9620 - ret = ctx_map_to_sec4_sg(jrdev, state, ctx->ctx_len,
9621 -- edesc->sec4_sg, DMA_TO_DEVICE);
9622 -+ edesc->sec4_sg, DMA_BIDIRECTIONAL);
9623 - if (ret)
9624 - goto unmap_ctx;
9625 -
9626 -@@ -857,14 +836,7 @@ static int ahash_final_ctx(struct ahash_request *req)
9627 -
9628 - append_seq_in_ptr(desc, edesc->sec4_sg_dma, ctx->ctx_len + buflen,
9629 - LDST_SGF);
9630 --
9631 -- edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
9632 -- digestsize);
9633 -- if (dma_mapping_error(jrdev, edesc->dst_dma)) {
9634 -- dev_err(jrdev, "unable to map dst\n");
9635 -- ret = -ENOMEM;
9636 -- goto unmap_ctx;
9637 -- }
9638 -+ append_seq_out_ptr(desc, state->ctx_dma, digestsize, 0);
9639 -
9640 - #ifdef DEBUG
9641 - print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
9642 -@@ -877,7 +849,7 @@ static int ahash_final_ctx(struct ahash_request *req)
9643 -
9644 - return -EINPROGRESS;
9645 - unmap_ctx:
9646 -- ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9647 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_BIDIRECTIONAL);
9648 - kfree(edesc);
9649 - return ret;
9650 - }
9651 -@@ -931,7 +903,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
9652 - edesc->src_nents = src_nents;
9653 -
9654 - ret = ctx_map_to_sec4_sg(jrdev, state, ctx->ctx_len,
9655 -- edesc->sec4_sg, DMA_TO_DEVICE);
9656 -+ edesc->sec4_sg, DMA_BIDIRECTIONAL);
9657 - if (ret)
9658 - goto unmap_ctx;
9659 -
9660 -@@ -945,13 +917,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
9661 - if (ret)
9662 - goto unmap_ctx;
9663 -
9664 -- edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
9665 -- digestsize);
9666 -- if (dma_mapping_error(jrdev, edesc->dst_dma)) {
9667 -- dev_err(jrdev, "unable to map dst\n");
9668 -- ret = -ENOMEM;
9669 -- goto unmap_ctx;
9670 -- }
9671 -+ append_seq_out_ptr(desc, state->ctx_dma, digestsize, 0);
9672 -
9673 - #ifdef DEBUG
9674 - print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
9675 -@@ -964,7 +930,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
9676 -
9677 - return -EINPROGRESS;
9678 - unmap_ctx:
9679 -- ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9680 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_BIDIRECTIONAL);
9681 - kfree(edesc);
9682 - return ret;
9683 - }
9684 -@@ -1023,10 +989,8 @@ static int ahash_digest(struct ahash_request *req)
9685 -
9686 - desc = edesc->hw_desc;
9687 -
9688 -- edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
9689 -- digestsize);
9690 -- if (dma_mapping_error(jrdev, edesc->dst_dma)) {
9691 -- dev_err(jrdev, "unable to map dst\n");
9692 -+ ret = map_seq_out_ptr_ctx(desc, jrdev, state, digestsize);
9693 -+ if (ret) {
9694 - ahash_unmap(jrdev, edesc, req, digestsize);
9695 - kfree(edesc);
9696 - return -ENOMEM;
9697 -@@ -1041,7 +1005,7 @@ static int ahash_digest(struct ahash_request *req)
9698 - if (!ret) {
9699 - ret = -EINPROGRESS;
9700 - } else {
9701 -- ahash_unmap(jrdev, edesc, req, digestsize);
9702 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9703 - kfree(edesc);
9704 - }
9705 -
9706 -@@ -1083,12 +1047,9 @@ static int ahash_final_no_ctx(struct ahash_request *req)
9707 - append_seq_in_ptr(desc, state->buf_dma, buflen, 0);
9708 - }
9709 -
9710 -- edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
9711 -- digestsize);
9712 -- if (dma_mapping_error(jrdev, edesc->dst_dma)) {
9713 -- dev_err(jrdev, "unable to map dst\n");
9714 -+ ret = map_seq_out_ptr_ctx(desc, jrdev, state, digestsize);
9715 -+ if (ret)
9716 - goto unmap;
9717 -- }
9718 -
9719 - #ifdef DEBUG
9720 - print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
9721 -@@ -1099,7 +1060,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
9722 - if (!ret) {
9723 - ret = -EINPROGRESS;
9724 - } else {
9725 -- ahash_unmap(jrdev, edesc, req, digestsize);
9726 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9727 - kfree(edesc);
9728 - }
9729 -
9730 -@@ -1298,12 +1259,9 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
9731 - goto unmap;
9732 - }
9733 -
9734 -- edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
9735 -- digestsize);
9736 -- if (dma_mapping_error(jrdev, edesc->dst_dma)) {
9737 -- dev_err(jrdev, "unable to map dst\n");
9738 -+ ret = map_seq_out_ptr_ctx(desc, jrdev, state, digestsize);
9739 -+ if (ret)
9740 - goto unmap;
9741 -- }
9742 -
9743 - #ifdef DEBUG
9744 - print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
9745 -@@ -1314,7 +1272,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
9746 - if (!ret) {
9747 - ret = -EINPROGRESS;
9748 - } else {
9749 -- ahash_unmap(jrdev, edesc, req, digestsize);
9750 -+ ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
9751 - kfree(edesc);
9752 - }
9753 -
9754 -@@ -1446,6 +1404,7 @@ static int ahash_init(struct ahash_request *req)
9755 - state->final = ahash_final_no_ctx;
9756 -
9757 - state->ctx_dma = 0;
9758 -+ state->ctx_dma_len = 0;
9759 - state->current_buf = 0;
9760 - state->buf_dma = 0;
9761 - state->buflen_0 = 0;
9762 -diff --git a/drivers/crypto/cavium/zip/zip_main.c b/drivers/crypto/cavium/zip/zip_main.c
9763 -index be055b9547f6..6183f9128a8a 100644
9764 ---- a/drivers/crypto/cavium/zip/zip_main.c
9765 -+++ b/drivers/crypto/cavium/zip/zip_main.c
9766 -@@ -351,6 +351,7 @@ static struct pci_driver zip_driver = {
9767 -
9768 - static struct crypto_alg zip_comp_deflate = {
9769 - .cra_name = "deflate",
9770 -+ .cra_driver_name = "deflate-cavium",
9771 - .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
9772 - .cra_ctxsize = sizeof(struct zip_kernel_ctx),
9773 - .cra_priority = 300,
9774 -@@ -365,6 +366,7 @@ static struct crypto_alg zip_comp_deflate = {
9775 -
9776 - static struct crypto_alg zip_comp_lzs = {
9777 - .cra_name = "lzs",
9778 -+ .cra_driver_name = "lzs-cavium",
9779 - .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
9780 - .cra_ctxsize = sizeof(struct zip_kernel_ctx),
9781 - .cra_priority = 300,
9782 -@@ -384,7 +386,7 @@ static struct scomp_alg zip_scomp_deflate = {
9783 - .decompress = zip_scomp_decompress,
9784 - .base = {
9785 - .cra_name = "deflate",
9786 -- .cra_driver_name = "deflate-scomp",
9787 -+ .cra_driver_name = "deflate-scomp-cavium",
9788 - .cra_module = THIS_MODULE,
9789 - .cra_priority = 300,
9790 - }
9791 -@@ -397,7 +399,7 @@ static struct scomp_alg zip_scomp_lzs = {
9792 - .decompress = zip_scomp_decompress,
9793 - .base = {
9794 - .cra_name = "lzs",
9795 -- .cra_driver_name = "lzs-scomp",
9796 -+ .cra_driver_name = "lzs-scomp-cavium",
9797 - .cra_module = THIS_MODULE,
9798 - .cra_priority = 300,
9799 - }
9800 -diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
9801 -index dd948e1df9e5..3bcb6bce666e 100644
9802 ---- a/drivers/crypto/ccree/cc_buffer_mgr.c
9803 -+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
9804 -@@ -614,10 +614,10 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req)
9805 - hw_iv_size, DMA_BIDIRECTIONAL);
9806 - }
9807 -
9808 -- /*In case a pool was set, a table was
9809 -- *allocated and should be released
9810 -- */
9811 -- if (areq_ctx->mlli_params.curr_pool) {
9812 -+ /* Release pool */
9813 -+ if ((areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI ||
9814 -+ areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) &&
9815 -+ (areq_ctx->mlli_params.mlli_virt_addr)) {
9816 - dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n",
9817 - &areq_ctx->mlli_params.mlli_dma_addr,
9818 - areq_ctx->mlli_params.mlli_virt_addr);
9819 -diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
9820 -index cc92b031fad1..4ec93079daaf 100644
9821 ---- a/drivers/crypto/ccree/cc_cipher.c
9822 -+++ b/drivers/crypto/ccree/cc_cipher.c
9823 -@@ -80,6 +80,7 @@ static int validate_keys_sizes(struct cc_cipher_ctx *ctx_p, u32 size)
9824 - default:
9825 - break;
9826 - }
9827 -+ break;
9828 - case S_DIN_to_DES:
9829 - if (size == DES3_EDE_KEY_SIZE || size == DES_KEY_SIZE)
9830 - return 0;
9831 -@@ -652,6 +653,8 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
9832 - unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm);
9833 - unsigned int len;
9834 -
9835 -+ cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
9836 -+
9837 - switch (ctx_p->cipher_mode) {
9838 - case DRV_CIPHER_CBC:
9839 - /*
9840 -@@ -681,7 +684,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
9841 - break;
9842 - }
9843 -
9844 -- cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
9845 - kzfree(req_ctx->iv);
9846 -
9847 - skcipher_request_complete(req, err);
9848 -@@ -799,7 +801,8 @@ static int cc_cipher_decrypt(struct skcipher_request *req)
9849 -
9850 - memset(req_ctx, 0, sizeof(*req_ctx));
9851 -
9852 -- if (ctx_p->cipher_mode == DRV_CIPHER_CBC) {
9853 -+ if ((ctx_p->cipher_mode == DRV_CIPHER_CBC) &&
9854 -+ (req->cryptlen >= ivsize)) {
9855 -
9856 - /* Allocate and save the last IV sized bytes of the source,
9857 - * which will be lost in case of in-place decryption.
9858 -diff --git a/drivers/crypto/rockchip/rk3288_crypto.c b/drivers/crypto/rockchip/rk3288_crypto.c
9859 -index c9d622abd90c..0ce4a65b95f5 100644
9860 ---- a/drivers/crypto/rockchip/rk3288_crypto.c
9861 -+++ b/drivers/crypto/rockchip/rk3288_crypto.c
9862 -@@ -119,7 +119,7 @@ static int rk_load_data(struct rk_crypto_info *dev,
9863 - count = (dev->left_bytes > PAGE_SIZE) ?
9864 - PAGE_SIZE : dev->left_bytes;
9865 -
9866 -- if (!sg_pcopy_to_buffer(dev->first, dev->nents,
9867 -+ if (!sg_pcopy_to_buffer(dev->first, dev->src_nents,
9868 - dev->addr_vir, count,
9869 - dev->total - dev->left_bytes)) {
9870 - dev_err(dev->dev, "[%s:%d] pcopy err\n",
9871 -diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h
9872 -index d5fb4013fb42..54ee5b3ed9db 100644
9873 ---- a/drivers/crypto/rockchip/rk3288_crypto.h
9874 -+++ b/drivers/crypto/rockchip/rk3288_crypto.h
9875 -@@ -207,7 +207,8 @@ struct rk_crypto_info {
9876 - void *addr_vir;
9877 - int aligned;
9878 - int align_size;
9879 -- size_t nents;
9880 -+ size_t src_nents;
9881 -+ size_t dst_nents;
9882 - unsigned int total;
9883 - unsigned int count;
9884 - dma_addr_t addr_in;
9885 -@@ -244,6 +245,7 @@ struct rk_cipher_ctx {
9886 - struct rk_crypto_info *dev;
9887 - unsigned int keylen;
9888 - u32 mode;
9889 -+ u8 iv[AES_BLOCK_SIZE];
9890 - };
9891 -
9892 - enum alg_type {
9893 -diff --git a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
9894 -index 639c15c5364b..23305f22072f 100644
9895 ---- a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
9896 -+++ b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
9897 -@@ -242,6 +242,17 @@ static void crypto_dma_start(struct rk_crypto_info *dev)
9898 - static int rk_set_data_start(struct rk_crypto_info *dev)
9899 - {
9900 - int err;
9901 -+ struct ablkcipher_request *req =
9902 -+ ablkcipher_request_cast(dev->async_req);
9903 -+ struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
9904 -+ struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(tfm);
9905 -+ u32 ivsize = crypto_ablkcipher_ivsize(tfm);
9906 -+ u8 *src_last_blk = page_address(sg_page(dev->sg_src)) +
9907 -+ dev->sg_src->offset + dev->sg_src->length - ivsize;
9908 -+
9909 -+ /* store the iv that need to be updated in chain mode */
9910 -+ if (ctx->mode & RK_CRYPTO_DEC)
9911 -+ memcpy(ctx->iv, src_last_blk, ivsize);
9912 -
9913 - err = dev->load_data(dev, dev->sg_src, dev->sg_dst);
9914 - if (!err)
9915 -@@ -260,8 +271,9 @@ static int rk_ablk_start(struct rk_crypto_info *dev)
9916 - dev->total = req->nbytes;
9917 - dev->sg_src = req->src;
9918 - dev->first = req->src;
9919 -- dev->nents = sg_nents(req->src);
9920 -+ dev->src_nents = sg_nents(req->src);
9921 - dev->sg_dst = req->dst;
9922 -+ dev->dst_nents = sg_nents(req->dst);
9923 - dev->aligned = 1;
9924 -
9925 - spin_lock_irqsave(&dev->lock, flags);
9926 -@@ -285,6 +297,28 @@ static void rk_iv_copyback(struct rk_crypto_info *dev)
9927 - memcpy_fromio(req->info, dev->reg + RK_CRYPTO_AES_IV_0, ivsize);
9928 - }
9929 -
9930 -+static void rk_update_iv(struct rk_crypto_info *dev)
9931 -+{
9932 -+ struct ablkcipher_request *req =
9933 -+ ablkcipher_request_cast(dev->async_req);
9934 -+ struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
9935 -+ struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(tfm);
9936 -+ u32 ivsize = crypto_ablkcipher_ivsize(tfm);
9937 -+ u8 *new_iv = NULL;
9938 -+
9939 -+ if (ctx->mode & RK_CRYPTO_DEC) {
9940 -+ new_iv = ctx->iv;
9941 -+ } else {
9942 -+ new_iv = page_address(sg_page(dev->sg_dst)) +
9943 -+ dev->sg_dst->offset + dev->sg_dst->length - ivsize;
9944 -+ }
9945 -+
9946 -+ if (ivsize == DES_BLOCK_SIZE)
9947 -+ memcpy_toio(dev->reg + RK_CRYPTO_TDES_IV_0, new_iv, ivsize);
9948 -+ else if (ivsize == AES_BLOCK_SIZE)
9949 -+ memcpy_toio(dev->reg + RK_CRYPTO_AES_IV_0, new_iv, ivsize);
9950 -+}
9951 -+
9952 - /* return:
9953 - * true some err was occurred
9954 - * fault no err, continue
9955 -@@ -297,7 +331,7 @@ static int rk_ablk_rx(struct rk_crypto_info *dev)
9956 -
9957 - dev->unload_data(dev);
9958 - if (!dev->aligned) {
9959 -- if (!sg_pcopy_from_buffer(req->dst, dev->nents,
9960 -+ if (!sg_pcopy_from_buffer(req->dst, dev->dst_nents,
9961 - dev->addr_vir, dev->count,
9962 - dev->total - dev->left_bytes -
9963 - dev->count)) {
9964 -@@ -306,6 +340,7 @@ static int rk_ablk_rx(struct rk_crypto_info *dev)
9965 - }
9966 - }
9967 - if (dev->left_bytes) {
9968 -+ rk_update_iv(dev);
9969 - if (dev->aligned) {
9970 - if (sg_is_last(dev->sg_src)) {
9971 - dev_err(dev->dev, "[%s:%d] Lack of data\n",
9972 -diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
9973 -index 821a506b9e17..c336ae75e361 100644
9974 ---- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c
9975 -+++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
9976 -@@ -206,7 +206,7 @@ static int rk_ahash_start(struct rk_crypto_info *dev)
9977 - dev->sg_dst = NULL;
9978 - dev->sg_src = req->src;
9979 - dev->first = req->src;
9980 -- dev->nents = sg_nents(req->src);
9981 -+ dev->src_nents = sg_nents(req->src);
9982 - rctx = ahash_request_ctx(req);
9983 - rctx->mode = 0;
9984 -
9985 -diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
9986 -index 4a09af3cd546..7b9a7fb28bb9 100644
9987 ---- a/drivers/dma/imx-dma.c
9988 -+++ b/drivers/dma/imx-dma.c
9989 -@@ -285,7 +285,7 @@ static inline int imxdma_sg_next(struct imxdma_desc *d)
9990 - struct scatterlist *sg = d->sg;
9991 - unsigned long now;
9992 -
9993 -- now = min(d->len, sg_dma_len(sg));
9994 -+ now = min_t(size_t, d->len, sg_dma_len(sg));
9995 - if (d->len != IMX_DMA_LENGTH_LOOP)
9996 - d->len -= now;
9997 -
9998 -diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
9999 -index 43d4b00b8138..411f91fde734 100644
10000 ---- a/drivers/dma/qcom/hidma.c
10001 -+++ b/drivers/dma/qcom/hidma.c
10002 -@@ -138,24 +138,25 @@ static void hidma_process_completed(struct hidma_chan *mchan)
10003 - desc = &mdesc->desc;
10004 - last_cookie = desc->cookie;
10005 -
10006 -+ llstat = hidma_ll_status(mdma->lldev, mdesc->tre_ch);
10007 -+
10008 - spin_lock_irqsave(&mchan->lock, irqflags);
10009 -+ if (llstat == DMA_COMPLETE) {
10010 -+ mchan->last_success = last_cookie;
10011 -+ result.result = DMA_TRANS_NOERROR;
10012 -+ } else {
10013 -+ result.result = DMA_TRANS_ABORTED;
10014 -+ }
10015 -+
10016 - dma_cookie_complete(desc);
10017 - spin_unlock_irqrestore(&mchan->lock, irqflags);
10018 -
10019 -- llstat = hidma_ll_status(mdma->lldev, mdesc->tre_ch);
10020 - dmaengine_desc_get_callback(desc, &cb);
10021 -
10022 - dma_run_dependencies(desc);
10023 -
10024 - spin_lock_irqsave(&mchan->lock, irqflags);
10025 - list_move(&mdesc->node, &mchan->free);
10026 --
10027 -- if (llstat == DMA_COMPLETE) {
10028 -- mchan->last_success = last_cookie;
10029 -- result.result = DMA_TRANS_NOERROR;
10030 -- } else
10031 -- result.result = DMA_TRANS_ABORTED;
10032 --
10033 - spin_unlock_irqrestore(&mchan->lock, irqflags);
10034 -
10035 - dmaengine_desc_callback_invoke(&cb, &result);
10036 -@@ -415,6 +416,7 @@ hidma_prep_dma_memcpy(struct dma_chan *dmach, dma_addr_t dest, dma_addr_t src,
10037 - if (!mdesc)
10038 - return NULL;
10039 -
10040 -+ mdesc->desc.flags = flags;
10041 - hidma_ll_set_transfer_params(mdma->lldev, mdesc->tre_ch,
10042 - src, dest, len, flags,
10043 - HIDMA_TRE_MEMCPY);
10044 -@@ -447,6 +449,7 @@ hidma_prep_dma_memset(struct dma_chan *dmach, dma_addr_t dest, int value,
10045 - if (!mdesc)
10046 - return NULL;
10047 -
10048 -+ mdesc->desc.flags = flags;
10049 - hidma_ll_set_transfer_params(mdma->lldev, mdesc->tre_ch,
10050 - value, dest, len, flags,
10051 - HIDMA_TRE_MEMSET);
10052 -diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
10053 -index 7f7184c3cf95..59403f6d008a 100644
10054 ---- a/drivers/dma/sh/usb-dmac.c
10055 -+++ b/drivers/dma/sh/usb-dmac.c
10056 -@@ -694,6 +694,8 @@ static int usb_dmac_runtime_resume(struct device *dev)
10057 - #endif /* CONFIG_PM */
10058 -
10059 - static const struct dev_pm_ops usb_dmac_pm = {
10060 -+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
10061 -+ pm_runtime_force_resume)
10062 - SET_RUNTIME_PM_OPS(usb_dmac_runtime_suspend, usb_dmac_runtime_resume,
10063 - NULL)
10064 - };
10065 -diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
10066 -index 9a558e30c461..8219ab88a507 100644
10067 ---- a/drivers/dma/tegra20-apb-dma.c
10068 -+++ b/drivers/dma/tegra20-apb-dma.c
10069 -@@ -636,7 +636,10 @@ static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc,
10070 -
10071 - sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node);
10072 - dma_desc = sgreq->dma_desc;
10073 -- dma_desc->bytes_transferred += sgreq->req_len;
10074 -+ /* if we dma for long enough the transfer count will wrap */
10075 -+ dma_desc->bytes_transferred =
10076 -+ (dma_desc->bytes_transferred + sgreq->req_len) %
10077 -+ dma_desc->bytes_requested;
10078 -
10079 - /* Callback need to be call */
10080 - if (!dma_desc->cb_count)
10081 -diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
10082 -index a7902fccdcfa..6090d25dce85 100644
10083 ---- a/drivers/firmware/efi/cper.c
10084 -+++ b/drivers/firmware/efi/cper.c
10085 -@@ -546,19 +546,24 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header);
10086 - int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
10087 - {
10088 - struct acpi_hest_generic_data *gdata;
10089 -- unsigned int data_len, gedata_len;
10090 -+ unsigned int data_len, record_size;
10091 - int rc;
10092 -
10093 - rc = cper_estatus_check_header(estatus);
10094 - if (rc)
10095 - return rc;
10096 -+
10097 - data_len = estatus->data_length;
10098 -
10099 - apei_estatus_for_each_section(estatus, gdata) {
10100 -- gedata_len = acpi_hest_get_error_length(gdata);
10101 -- if (gedata_len > data_len - acpi_hest_get_size(gdata))
10102 -+ if (sizeof(struct acpi_hest_generic_data) > data_len)
10103 -+ return -EINVAL;
10104 -+
10105 -+ record_size = acpi_hest_get_record_size(gdata);
10106 -+ if (record_size > data_len)
10107 - return -EINVAL;
10108 -- data_len -= acpi_hest_get_record_size(gdata);
10109 -+
10110 -+ data_len -= record_size;
10111 - }
10112 - if (data_len)
10113 - return -EINVAL;
10114 -diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
10115 -index c037c6c5d0b7..04e6ecd72cd9 100644
10116 ---- a/drivers/firmware/efi/libstub/arm-stub.c
10117 -+++ b/drivers/firmware/efi/libstub/arm-stub.c
10118 -@@ -367,6 +367,11 @@ void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
10119 - paddr = in->phys_addr;
10120 - size = in->num_pages * EFI_PAGE_SIZE;
10121 -
10122 -+ if (novamap()) {
10123 -+ in->virt_addr = in->phys_addr;
10124 -+ continue;
10125 -+ }
10126 -+
10127 - /*
10128 - * Make the mapping compatible with 64k pages: this allows
10129 - * a 4k page size kernel to kexec a 64k page size kernel and
10130 -diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
10131 -index e94975f4655b..442f51c2a53d 100644
10132 ---- a/drivers/firmware/efi/libstub/efi-stub-helper.c
10133 -+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
10134 -@@ -34,6 +34,7 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE;
10135 -
10136 - static int __section(.data) __nokaslr;
10137 - static int __section(.data) __quiet;
10138 -+static int __section(.data) __novamap;
10139 -
10140 - int __pure nokaslr(void)
10141 - {
10142 -@@ -43,6 +44,10 @@ int __pure is_quiet(void)
10143 - {
10144 - return __quiet;
10145 - }
10146 -+int __pure novamap(void)
10147 -+{
10148 -+ return __novamap;
10149 -+}
10150 -
10151 - #define EFI_MMAP_NR_SLACK_SLOTS 8
10152 -
10153 -@@ -482,6 +487,11 @@ efi_status_t efi_parse_options(char const *cmdline)
10154 - __chunk_size = -1UL;
10155 - }
10156 -
10157 -+ if (!strncmp(str, "novamap", 7)) {
10158 -+ str += strlen("novamap");
10159 -+ __novamap = 1;
10160 -+ }
10161 -+
10162 - /* Group words together, delimited by "," */
10163 - while (*str && *str != ' ' && *str != ',')
10164 - str++;
10165 -diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
10166 -index 32799cf039ef..337b52c4702c 100644
10167 ---- a/drivers/firmware/efi/libstub/efistub.h
10168 -+++ b/drivers/firmware/efi/libstub/efistub.h
10169 -@@ -27,6 +27,7 @@
10170 -
10171 - extern int __pure nokaslr(void);
10172 - extern int __pure is_quiet(void);
10173 -+extern int __pure novamap(void);
10174 -
10175 - #define pr_efi(sys_table, msg) do { \
10176 - if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \
10177 -diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
10178 -index 0dc7b4987cc2..f8f89f995e9d 100644
10179 ---- a/drivers/firmware/efi/libstub/fdt.c
10180 -+++ b/drivers/firmware/efi/libstub/fdt.c
10181 -@@ -327,6 +327,9 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
10182 - if (status == EFI_SUCCESS) {
10183 - efi_set_virtual_address_map_t *svam;
10184 -
10185 -+ if (novamap())
10186 -+ return EFI_SUCCESS;
10187 -+
10188 - /* Install the new virtual address map */
10189 - svam = sys_table->runtime->set_virtual_address_map;
10190 - status = svam(runtime_entry_count * desc_size, desc_size,
10191 -diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
10192 -index 8986757eafaf..aac972b056d9 100644
10193 ---- a/drivers/firmware/efi/memattr.c
10194 -+++ b/drivers/firmware/efi/memattr.c
10195 -@@ -94,7 +94,7 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
10196 -
10197 - if (!(md->attribute & EFI_MEMORY_RUNTIME))
10198 - continue;
10199 -- if (md->virt_addr == 0) {
10200 -+ if (md->virt_addr == 0 && md->phys_addr != 0) {
10201 - /* no virtual mapping has been installed by the stub */
10202 - break;
10203 - }
10204 -diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
10205 -index e2abfdb5cee6..698745c249e8 100644
10206 ---- a/drivers/firmware/efi/runtime-wrappers.c
10207 -+++ b/drivers/firmware/efi/runtime-wrappers.c
10208 -@@ -85,7 +85,7 @@ struct efi_runtime_work efi_rts_work;
10209 - pr_err("Failed to queue work to efi_rts_wq.\n"); \
10210 - \
10211 - exit: \
10212 -- efi_rts_work.efi_rts_id = NONE; \
10213 -+ efi_rts_work.efi_rts_id = EFI_NONE; \
10214 - efi_rts_work.status; \
10215 - })
10216 -
10217 -@@ -175,50 +175,50 @@ static void efi_call_rts(struct work_struct *work)
10218 - arg5 = efi_rts_work.arg5;
10219 -
10220 - switch (efi_rts_work.efi_rts_id) {
10221 -- case GET_TIME:
10222 -+ case EFI_GET_TIME:
10223 - status = efi_call_virt(get_time, (efi_time_t *)arg1,
10224 - (efi_time_cap_t *)arg2);
10225 - break;
10226 -- case SET_TIME:
10227 -+ case EFI_SET_TIME:
10228 - status = efi_call_virt(set_time, (efi_time_t *)arg1);
10229 - break;
10230 -- case GET_WAKEUP_TIME:
10231 -+ case EFI_GET_WAKEUP_TIME:
10232 - status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1,
10233 - (efi_bool_t *)arg2, (efi_time_t *)arg3);
10234 - break;
10235 -- case SET_WAKEUP_TIME:
10236 -+ case EFI_SET_WAKEUP_TIME:
10237 - status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1,
10238 - (efi_time_t *)arg2);
10239 - break;
10240 -- case GET_VARIABLE:
10241 -+ case EFI_GET_VARIABLE:
10242 - status = efi_call_virt(get_variable, (efi_char16_t *)arg1,
10243 - (efi_guid_t *)arg2, (u32 *)arg3,
10244 - (unsigned long *)arg4, (void *)arg5);
10245 - break;
10246 -- case GET_NEXT_VARIABLE:
10247 -+ case EFI_GET_NEXT_VARIABLE:
10248 - status = efi_call_virt(get_next_variable, (unsigned long *)arg1,
10249 - (efi_char16_t *)arg2,
10250 - (efi_guid_t *)arg3);
10251 - break;
10252 -- case SET_VARIABLE:
10253 -+ case EFI_SET_VARIABLE:
10254 - status = efi_call_virt(set_variable, (efi_char16_t *)arg1,
10255 - (efi_guid_t *)arg2, *(u32 *)arg3,
10256 - *(unsigned long *)arg4, (void *)arg5);
10257 - break;
10258 -- case QUERY_VARIABLE_INFO:
10259 -+ case EFI_QUERY_VARIABLE_INFO:
10260 - status = efi_call_virt(query_variable_info, *(u32 *)arg1,
10261 - (u64 *)arg2, (u64 *)arg3, (u64 *)arg4);
10262 - break;
10263 -- case GET_NEXT_HIGH_MONO_COUNT:
10264 -+ case EFI_GET_NEXT_HIGH_MONO_COUNT:
10265 - status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1);
10266 - break;
10267 -- case UPDATE_CAPSULE:
10268 -+ case EFI_UPDATE_CAPSULE:
10269 - status = efi_call_virt(update_capsule,
10270 - (efi_capsule_header_t **)arg1,
10271 - *(unsigned long *)arg2,
10272 - *(unsigned long *)arg3);
10273 - break;
10274 -- case QUERY_CAPSULE_CAPS:
10275 -+ case EFI_QUERY_CAPSULE_CAPS:
10276 - status = efi_call_virt(query_capsule_caps,
10277 - (efi_capsule_header_t **)arg1,
10278 - *(unsigned long *)arg2, (u64 *)arg3,
10279 -@@ -242,7 +242,7 @@ static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
10280 -
10281 - if (down_interruptible(&efi_runtime_lock))
10282 - return EFI_ABORTED;
10283 -- status = efi_queue_work(GET_TIME, tm, tc, NULL, NULL, NULL);
10284 -+ status = efi_queue_work(EFI_GET_TIME, tm, tc, NULL, NULL, NULL);
10285 - up(&efi_runtime_lock);
10286 - return status;
10287 - }
10288 -@@ -253,7 +253,7 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm)
10289 -
10290 - if (down_interruptible(&efi_runtime_lock))
10291 - return EFI_ABORTED;
10292 -- status = efi_queue_work(SET_TIME, tm, NULL, NULL, NULL, NULL);
10293 -+ status = efi_queue_work(EFI_SET_TIME, tm, NULL, NULL, NULL, NULL);
10294 - up(&efi_runtime_lock);
10295 - return status;
10296 - }
10297 -@@ -266,7 +266,7 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled,
10298 -
10299 - if (down_interruptible(&efi_runtime_lock))
10300 - return EFI_ABORTED;
10301 -- status = efi_queue_work(GET_WAKEUP_TIME, enabled, pending, tm, NULL,
10302 -+ status = efi_queue_work(EFI_GET_WAKEUP_TIME, enabled, pending, tm, NULL,
10303 - NULL);
10304 - up(&efi_runtime_lock);
10305 - return status;
10306 -@@ -278,7 +278,7 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
10307 -
10308 - if (down_interruptible(&efi_runtime_lock))
10309 - return EFI_ABORTED;
10310 -- status = efi_queue_work(SET_WAKEUP_TIME, &enabled, tm, NULL, NULL,
10311 -+ status = efi_queue_work(EFI_SET_WAKEUP_TIME, &enabled, tm, NULL, NULL,
10312 - NULL);
10313 - up(&efi_runtime_lock);
10314 - return status;
10315 -@@ -294,7 +294,7 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name,
10316 -
10317 - if (down_interruptible(&efi_runtime_lock))
10318 - return EFI_ABORTED;
10319 -- status = efi_queue_work(GET_VARIABLE, name, vendor, attr, data_size,
10320 -+ status = efi_queue_work(EFI_GET_VARIABLE, name, vendor, attr, data_size,
10321 - data);
10322 - up(&efi_runtime_lock);
10323 - return status;
10324 -@@ -308,7 +308,7 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
10325 -
10326 - if (down_interruptible(&efi_runtime_lock))
10327 - return EFI_ABORTED;
10328 -- status = efi_queue_work(GET_NEXT_VARIABLE, name_size, name, vendor,
10329 -+ status = efi_queue_work(EFI_GET_NEXT_VARIABLE, name_size, name, vendor,
10330 - NULL, NULL);
10331 - up(&efi_runtime_lock);
10332 - return status;
10333 -@@ -324,7 +324,7 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name,
10334 -
10335 - if (down_interruptible(&efi_runtime_lock))
10336 - return EFI_ABORTED;
10337 -- status = efi_queue_work(SET_VARIABLE, name, vendor, &attr, &data_size,
10338 -+ status = efi_queue_work(EFI_SET_VARIABLE, name, vendor, &attr, &data_size,
10339 - data);
10340 - up(&efi_runtime_lock);
10341 - return status;
10342 -@@ -359,7 +359,7 @@ static efi_status_t virt_efi_query_variable_info(u32 attr,
10343 -
10344 - if (down_interruptible(&efi_runtime_lock))
10345 - return EFI_ABORTED;
10346 -- status = efi_queue_work(QUERY_VARIABLE_INFO, &attr, storage_space,
10347 -+ status = efi_queue_work(EFI_QUERY_VARIABLE_INFO, &attr, storage_space,
10348 - remaining_space, max_variable_size, NULL);
10349 - up(&efi_runtime_lock);
10350 - return status;
10351 -@@ -391,7 +391,7 @@ static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
10352 -
10353 - if (down_interruptible(&efi_runtime_lock))
10354 - return EFI_ABORTED;
10355 -- status = efi_queue_work(GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL,
10356 -+ status = efi_queue_work(EFI_GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL,
10357 - NULL, NULL);
10358 - up(&efi_runtime_lock);
10359 - return status;
10360 -@@ -407,7 +407,7 @@ static void virt_efi_reset_system(int reset_type,
10361 - "could not get exclusive access to the firmware\n");
10362 - return;
10363 - }
10364 -- efi_rts_work.efi_rts_id = RESET_SYSTEM;
10365 -+ efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
10366 - __efi_call_virt(reset_system, reset_type, status, data_size, data);
10367 - up(&efi_runtime_lock);
10368 - }
10369 -@@ -423,7 +423,7 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules,
10370 -
10371 - if (down_interruptible(&efi_runtime_lock))
10372 - return EFI_ABORTED;
10373 -- status = efi_queue_work(UPDATE_CAPSULE, capsules, &count, &sg_list,
10374 -+ status = efi_queue_work(EFI_UPDATE_CAPSULE, capsules, &count, &sg_list,
10375 - NULL, NULL);
10376 - up(&efi_runtime_lock);
10377 - return status;
10378 -@@ -441,7 +441,7 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules,
10379 -
10380 - if (down_interruptible(&efi_runtime_lock))
10381 - return EFI_ABORTED;
10382 -- status = efi_queue_work(QUERY_CAPSULE_CAPS, capsules, &count,
10383 -+ status = efi_queue_work(EFI_QUERY_CAPSULE_CAPS, capsules, &count,
10384 - max_size, reset_type, NULL);
10385 - up(&efi_runtime_lock);
10386 - return status;
10387 -diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
10388 -index 6bc8e6640d71..c51462f5aa1e 100644
10389 ---- a/drivers/firmware/iscsi_ibft.c
10390 -+++ b/drivers/firmware/iscsi_ibft.c
10391 -@@ -542,6 +542,7 @@ static umode_t __init ibft_check_tgt_for(void *data, int type)
10392 - case ISCSI_BOOT_TGT_NIC_ASSOC:
10393 - case ISCSI_BOOT_TGT_CHAP_TYPE:
10394 - rc = S_IRUGO;
10395 -+ break;
10396 - case ISCSI_BOOT_TGT_NAME:
10397 - if (tgt->tgt_name_len)
10398 - rc = S_IRUGO;
10399 -diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c
10400 -index 226f6e6fe01b..8e3f6a776e02 100644
10401 ---- a/drivers/gnss/sirf.c
10402 -+++ b/drivers/gnss/sirf.c
10403 -@@ -310,30 +310,26 @@ static int sirf_probe(struct serdev_device *serdev)
10404 - ret = -ENODEV;
10405 - goto err_put_device;
10406 - }
10407 -+
10408 -+ ret = regulator_enable(data->vcc);
10409 -+ if (ret)
10410 -+ goto err_put_device;
10411 -+
10412 -+ /* Wait for chip to boot into hibernate mode. */
10413 -+ msleep(SIRF_BOOT_DELAY);
10414 - }
10415 -
10416 - if (data->wakeup) {
10417 - ret = gpiod_to_irq(data->wakeup);
10418 - if (ret < 0)
10419 -- goto err_put_device;
10420 --
10421 -+ goto err_disable_vcc;
10422 - data->irq = ret;
10423 -
10424 -- ret = devm_request_threaded_irq(dev, data->irq, NULL,
10425 -- sirf_wakeup_handler,
10426 -+ ret = request_threaded_irq(data->irq, NULL, sirf_wakeup_handler,
10427 - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
10428 - "wakeup", data);
10429 - if (ret)
10430 -- goto err_put_device;
10431 -- }
10432 --
10433 -- if (data->on_off) {
10434 -- ret = regulator_enable(data->vcc);
10435 -- if (ret)
10436 -- goto err_put_device;
10437 --
10438 -- /* Wait for chip to boot into hibernate mode */
10439 -- msleep(SIRF_BOOT_DELAY);
10440 -+ goto err_disable_vcc;
10441 - }
10442 -
10443 - if (IS_ENABLED(CONFIG_PM)) {
10444 -@@ -342,7 +338,7 @@ static int sirf_probe(struct serdev_device *serdev)
10445 - } else {
10446 - ret = sirf_runtime_resume(dev);
10447 - if (ret < 0)
10448 -- goto err_disable_vcc;
10449 -+ goto err_free_irq;
10450 - }
10451 -
10452 - ret = gnss_register_device(gdev);
10453 -@@ -356,6 +352,9 @@ err_disable_rpm:
10454 - pm_runtime_disable(dev);
10455 - else
10456 - sirf_runtime_suspend(dev);
10457 -+err_free_irq:
10458 -+ if (data->wakeup)
10459 -+ free_irq(data->irq, data);
10460 - err_disable_vcc:
10461 - if (data->on_off)
10462 - regulator_disable(data->vcc);
10463 -@@ -376,6 +375,9 @@ static void sirf_remove(struct serdev_device *serdev)
10464 - else
10465 - sirf_runtime_suspend(&serdev->dev);
10466 -
10467 -+ if (data->wakeup)
10468 -+ free_irq(data->irq, data);
10469 -+
10470 - if (data->on_off)
10471 - regulator_disable(data->vcc);
10472 -
10473 -diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
10474 -index 91b90c0cea73..12acdac85820 100644
10475 ---- a/drivers/gpio/gpio-adnp.c
10476 -+++ b/drivers/gpio/gpio-adnp.c
10477 -@@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
10478 - if (err < 0)
10479 - goto out;
10480 -
10481 -- if (err & BIT(pos))
10482 -- err = -EACCES;
10483 -+ if (value & BIT(pos)) {
10484 -+ err = -EPERM;
10485 -+ goto out;
10486 -+ }
10487 -
10488 - err = 0;
10489 -
10490 -diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
10491 -index 0ecd2369c2ca..a09d2f9ebacc 100644
10492 ---- a/drivers/gpio/gpio-exar.c
10493 -+++ b/drivers/gpio/gpio-exar.c
10494 -@@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev)
10495 - mutex_init(&exar_gpio->lock);
10496 -
10497 - index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
10498 -+ if (index < 0)
10499 -+ goto err_destroy;
10500 -
10501 - sprintf(exar_gpio->name, "exar_gpio%d", index);
10502 - exar_gpio->gpio_chip.label = exar_gpio->name;
10503 -diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
10504 -index f4e9921fa966..7f33024b6d83 100644
10505 ---- a/drivers/gpio/gpio-omap.c
10506 -+++ b/drivers/gpio/gpio-omap.c
10507 -@@ -883,14 +883,16 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
10508 - if (trigger)
10509 - omap_set_gpio_triggering(bank, offset, trigger);
10510 -
10511 -- /* For level-triggered GPIOs, the clearing must be done after
10512 -- * the HW source is cleared, thus after the handler has run */
10513 -- if (bank->level_mask & BIT(offset)) {
10514 -- omap_set_gpio_irqenable(bank, offset, 0);
10515 -+ omap_set_gpio_irqenable(bank, offset, 1);
10516 -+
10517 -+ /*
10518 -+ * For level-triggered GPIOs, clearing must be done after the source
10519 -+ * is cleared, thus after the handler has run. OMAP4 needs this done
10520 -+ * after enabing the interrupt to clear the wakeup status.
10521 -+ */
10522 -+ if (bank->level_mask & BIT(offset))
10523 - omap_clear_gpio_irqstatus(bank, offset);
10524 -- }
10525 -
10526 -- omap_set_gpio_irqenable(bank, offset, 1);
10527 - raw_spin_unlock_irqrestore(&bank->lock, flags);
10528 - }
10529 -
10530 -diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
10531 -index 0dc96419efe3..d8a985fc6a5d 100644
10532 ---- a/drivers/gpio/gpio-pca953x.c
10533 -+++ b/drivers/gpio/gpio-pca953x.c
10534 -@@ -587,7 +587,8 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
10535 -
10536 - static void pca953x_irq_shutdown(struct irq_data *d)
10537 - {
10538 -- struct pca953x_chip *chip = irq_data_get_irq_chip_data(d);
10539 -+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
10540 -+ struct pca953x_chip *chip = gpiochip_get_data(gc);
10541 - u8 mask = 1 << (d->hwirq % BANK_SZ);
10542 -
10543 - chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;
10544 -diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
10545 -index a6e1891217e2..a1dd2f1c0d02 100644
10546 ---- a/drivers/gpio/gpiolib-of.c
10547 -+++ b/drivers/gpio/gpiolib-of.c
10548 -@@ -86,7 +86,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
10549 - if (IS_ENABLED(CONFIG_REGULATOR) &&
10550 - (of_device_is_compatible(np, "regulator-fixed") ||
10551 - of_device_is_compatible(np, "reg-fixed-voltage") ||
10552 -- of_device_is_compatible(np, "regulator-gpio"))) {
10553 -+ (of_device_is_compatible(np, "regulator-gpio") &&
10554 -+ strcmp(propname, "enable-gpio") == 0))) {
10555 - /*
10556 - * The regulator GPIO handles are specified such that the
10557 - * presence or absence of "enable-active-high" solely controls
10558 -diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
10559 -index bacdaef77b6c..278dd55ff476 100644
10560 ---- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
10561 -+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
10562 -@@ -738,7 +738,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)
10563 - }
10564 -
10565 - ring->vm_inv_eng = inv_eng - 1;
10566 -- change_bit(inv_eng - 1, (unsigned long *)(&vm_inv_engs[vmhub]));
10567 -+ vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
10568 -
10569 - dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
10570 - ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
10571 -diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
10572 -index 636d14a60952..83c8a0407537 100644
10573 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
10574 -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
10575 -@@ -886,6 +886,7 @@ static void emulated_link_detect(struct dc_link *link)
10576 - return;
10577 - }
10578 -
10579 -+ /* dc_sink_create returns a new reference */
10580 - link->local_sink = sink;
10581 -
10582 - edid_status = dm_helpers_read_local_edid(
10583 -@@ -952,6 +953,8 @@ static int dm_resume(void *handle)
10584 - if (aconnector->fake_enable && aconnector->dc_link->local_sink)
10585 - aconnector->fake_enable = false;
10586 -
10587 -+ if (aconnector->dc_sink)
10588 -+ dc_sink_release(aconnector->dc_sink);
10589 - aconnector->dc_sink = NULL;
10590 - amdgpu_dm_update_connector_after_detect(aconnector);
10591 - mutex_unlock(&aconnector->hpd_lock);
10592 -@@ -1061,6 +1064,8 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10593 -
10594 -
10595 - sink = aconnector->dc_link->local_sink;
10596 -+ if (sink)
10597 -+ dc_sink_retain(sink);
10598 -
10599 - /*
10600 - * Edid mgmt connector gets first update only in mode_valid hook and then
10601 -@@ -1085,21 +1090,24 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10602 - * to it anymore after disconnect, so on next crtc to connector
10603 - * reshuffle by UMD we will get into unwanted dc_sink release
10604 - */
10605 -- if (aconnector->dc_sink != aconnector->dc_em_sink)
10606 -- dc_sink_release(aconnector->dc_sink);
10607 -+ dc_sink_release(aconnector->dc_sink);
10608 - }
10609 - aconnector->dc_sink = sink;
10610 -+ dc_sink_retain(aconnector->dc_sink);
10611 - amdgpu_dm_update_freesync_caps(connector,
10612 - aconnector->edid);
10613 - } else {
10614 - amdgpu_dm_update_freesync_caps(connector, NULL);
10615 -- if (!aconnector->dc_sink)
10616 -+ if (!aconnector->dc_sink) {
10617 - aconnector->dc_sink = aconnector->dc_em_sink;
10618 -- else if (aconnector->dc_sink != aconnector->dc_em_sink)
10619 - dc_sink_retain(aconnector->dc_sink);
10620 -+ }
10621 - }
10622 -
10623 - mutex_unlock(&dev->mode_config.mutex);
10624 -+
10625 -+ if (sink)
10626 -+ dc_sink_release(sink);
10627 - return;
10628 - }
10629 -
10630 -@@ -1107,8 +1115,10 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10631 - * TODO: temporary guard to look for proper fix
10632 - * if this sink is MST sink, we should not do anything
10633 - */
10634 -- if (sink && sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
10635 -+ if (sink && sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
10636 -+ dc_sink_release(sink);
10637 - return;
10638 -+ }
10639 -
10640 - if (aconnector->dc_sink == sink) {
10641 - /*
10642 -@@ -1117,6 +1127,8 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10643 - */
10644 - DRM_DEBUG_DRIVER("DCHPD: connector_id=%d: dc_sink didn't change.\n",
10645 - aconnector->connector_id);
10646 -+ if (sink)
10647 -+ dc_sink_release(sink);
10648 - return;
10649 - }
10650 -
10651 -@@ -1138,6 +1150,7 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10652 - amdgpu_dm_update_freesync_caps(connector, NULL);
10653 -
10654 - aconnector->dc_sink = sink;
10655 -+ dc_sink_retain(aconnector->dc_sink);
10656 - if (sink->dc_edid.length == 0) {
10657 - aconnector->edid = NULL;
10658 - drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
10659 -@@ -1158,11 +1171,15 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
10660 - amdgpu_dm_update_freesync_caps(connector, NULL);
10661 - drm_connector_update_edid_property(connector, NULL);
10662 - aconnector->num_modes = 0;
10663 -+ dc_sink_release(aconnector->dc_sink);
10664 - aconnector->dc_sink = NULL;
10665 - aconnector->edid = NULL;
10666 - }
10667 -
10668 - mutex_unlock(&dev->mode_config.mutex);
10669 -+
10670 -+ if (sink)
10671 -+ dc_sink_release(sink);
10672 - }
10673 -
10674 - static void handle_hpd_irq(void *param)
10675 -@@ -2908,6 +2925,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
10676 - }
10677 - } else {
10678 - sink = aconnector->dc_sink;
10679 -+ dc_sink_retain(sink);
10680 - }
10681 -
10682 - stream = dc_create_stream_for_sink(sink);
10683 -@@ -2974,8 +2992,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
10684 - stream->ignore_msa_timing_param = true;
10685 -
10686 - finish:
10687 -- if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL && aconnector->base.force != DRM_FORCE_ON)
10688 -- dc_sink_release(sink);
10689 -+ dc_sink_release(sink);
10690 -
10691 - return stream;
10692 - }
10693 -@@ -3233,6 +3250,14 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
10694 - dm->backlight_dev = NULL;
10695 - }
10696 - #endif
10697 -+
10698 -+ if (aconnector->dc_em_sink)
10699 -+ dc_sink_release(aconnector->dc_em_sink);
10700 -+ aconnector->dc_em_sink = NULL;
10701 -+ if (aconnector->dc_sink)
10702 -+ dc_sink_release(aconnector->dc_sink);
10703 -+ aconnector->dc_sink = NULL;
10704 -+
10705 - drm_dp_cec_unregister_connector(&aconnector->dm_dp_aux.aux);
10706 - drm_connector_unregister(connector);
10707 - drm_connector_cleanup(connector);
10708 -@@ -3330,10 +3355,12 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
10709 - (edid->extensions + 1) * EDID_LENGTH,
10710 - &init_params);
10711 -
10712 -- if (aconnector->base.force == DRM_FORCE_ON)
10713 -+ if (aconnector->base.force == DRM_FORCE_ON) {
10714 - aconnector->dc_sink = aconnector->dc_link->local_sink ?
10715 - aconnector->dc_link->local_sink :
10716 - aconnector->dc_em_sink;
10717 -+ dc_sink_retain(aconnector->dc_sink);
10718 -+ }
10719 - }
10720 -
10721 - static void handle_edid_mgmt(struct amdgpu_dm_connector *aconnector)
10722 -@@ -4948,7 +4975,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
10723 - static void amdgpu_dm_crtc_copy_transient_flags(struct drm_crtc_state *crtc_state,
10724 - struct dc_stream_state *stream_state)
10725 - {
10726 -- stream_state->mode_changed = crtc_state->mode_changed;
10727 -+ stream_state->mode_changed =
10728 -+ crtc_state->mode_changed || crtc_state->active_changed;
10729 - }
10730 -
10731 - static int amdgpu_dm_atomic_commit(struct drm_device *dev,
10732 -@@ -4969,10 +4997,22 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
10733 - */
10734 - for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
10735 - struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
10736 -+ struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
10737 - struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
10738 -
10739 -- if (drm_atomic_crtc_needs_modeset(new_crtc_state) && dm_old_crtc_state->stream)
10740 -+ if (drm_atomic_crtc_needs_modeset(new_crtc_state)
10741 -+ && dm_old_crtc_state->stream) {
10742 -+ /*
10743 -+ * CRC capture was enabled but not disabled.
10744 -+ * Release the vblank reference.
10745 -+ */
10746 -+ if (dm_new_crtc_state->crc_enabled) {
10747 -+ drm_crtc_vblank_put(crtc);
10748 -+ dm_new_crtc_state->crc_enabled = false;
10749 -+ }
10750 -+
10751 - manage_dm_interrupts(adev, acrtc, false);
10752 -+ }
10753 - }
10754 - /*
10755 - * Add check here for SoC's that support hardware cursor plane, to
10756 -diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
10757 -index f088ac585978..26b651148c67 100644
10758 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
10759 -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
10760 -@@ -66,6 +66,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
10761 - {
10762 - struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state);
10763 - struct dc_stream_state *stream_state = crtc_state->stream;
10764 -+ bool enable;
10765 -
10766 - enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name);
10767 -
10768 -@@ -80,28 +81,27 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
10769 - return -EINVAL;
10770 - }
10771 -
10772 -+ enable = (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO);
10773 -+
10774 -+ if (!dc_stream_configure_crc(stream_state->ctx->dc, stream_state,
10775 -+ enable, enable))
10776 -+ return -EINVAL;
10777 -+
10778 - /* When enabling CRC, we should also disable dithering. */
10779 -- if (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO) {
10780 -- if (dc_stream_configure_crc(stream_state->ctx->dc,
10781 -- stream_state,
10782 -- true, true)) {
10783 -- crtc_state->crc_enabled = true;
10784 -- dc_stream_set_dither_option(stream_state,
10785 -- DITHER_OPTION_TRUN8);
10786 -- }
10787 -- else
10788 -- return -EINVAL;
10789 -- } else {
10790 -- if (dc_stream_configure_crc(stream_state->ctx->dc,
10791 -- stream_state,
10792 -- false, false)) {
10793 -- crtc_state->crc_enabled = false;
10794 -- dc_stream_set_dither_option(stream_state,
10795 -- DITHER_OPTION_DEFAULT);
10796 -- }
10797 -- else
10798 -- return -EINVAL;
10799 -- }
10800 -+ dc_stream_set_dither_option(stream_state,
10801 -+ enable ? DITHER_OPTION_TRUN8
10802 -+ : DITHER_OPTION_DEFAULT);
10803 -+
10804 -+ /*
10805 -+ * Reading the CRC requires the vblank interrupt handler to be
10806 -+ * enabled. Keep a reference until CRC capture stops.
10807 -+ */
10808 -+ if (!crtc_state->crc_enabled && enable)
10809 -+ drm_crtc_vblank_get(crtc);
10810 -+ else if (crtc_state->crc_enabled && !enable)
10811 -+ drm_crtc_vblank_put(crtc);
10812 -+
10813 -+ crtc_state->crc_enabled = enable;
10814 -
10815 - /* Reset crc_skipped on dm state */
10816 - crtc_state->crc_skip_count = 0;
10817 -diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
10818 -index 1b0d209d8367..3b95a637b508 100644
10819 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
10820 -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
10821 -@@ -239,6 +239,7 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
10822 - &init_params);
10823 -
10824 - dc_sink->priv = aconnector;
10825 -+ /* dc_link_add_remote_sink returns a new reference */
10826 - aconnector->dc_sink = dc_sink;
10827 -
10828 - if (aconnector->dc_sink)
10829 -diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
10830 -index 43e4a2be0fa6..57cc11d0e9a5 100644
10831 ---- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
10832 -+++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
10833 -@@ -1355,12 +1355,12 @@ void dcn_bw_update_from_pplib(struct dc *dc)
10834 - struct dm_pp_clock_levels_with_voltage fclks = {0}, dcfclks = {0};
10835 - bool res;
10836 -
10837 -- kernel_fpu_begin();
10838 --
10839 - /* TODO: This is not the proper way to obtain fabric_and_dram_bandwidth, should be min(fclk, memclk) */
10840 - res = dm_pp_get_clock_levels_by_type_with_voltage(
10841 - ctx, DM_PP_CLOCK_TYPE_FCLK, &fclks);
10842 -
10843 -+ kernel_fpu_begin();
10844 -+
10845 - if (res)
10846 - res = verify_clock_values(&fclks);
10847 -
10848 -@@ -1379,9 +1379,13 @@ void dcn_bw_update_from_pplib(struct dc *dc)
10849 - } else
10850 - BREAK_TO_DEBUGGER();
10851 -
10852 -+ kernel_fpu_end();
10853 -+
10854 - res = dm_pp_get_clock_levels_by_type_with_voltage(
10855 - ctx, DM_PP_CLOCK_TYPE_DCFCLK, &dcfclks);
10856 -
10857 -+ kernel_fpu_begin();
10858 -+
10859 - if (res)
10860 - res = verify_clock_values(&dcfclks);
10861 -
10862 -diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
10863 -index 5fd52094d459..1f92e7e8e3d3 100644
10864 ---- a/drivers/gpu/drm/amd/display/dc/core/dc.c
10865 -+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
10866 -@@ -1078,6 +1078,9 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c
10867 - /* pplib is notified if disp_num changed */
10868 - dc->hwss.optimize_bandwidth(dc, context);
10869 -
10870 -+ for (i = 0; i < context->stream_count; i++)
10871 -+ context->streams[i]->mode_changed = false;
10872 -+
10873 - dc_release_state(dc->current_state);
10874 -
10875 - dc->current_state = context;
10876 -diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
10877 -index b0265dbebd4c..583eb367850f 100644
10878 ---- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
10879 -+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
10880 -@@ -792,6 +792,7 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
10881 - sink->dongle_max_pix_clk = sink_caps.max_hdmi_pixel_clock;
10882 - sink->converter_disable_audio = converter_disable_audio;
10883 -
10884 -+ /* dc_sink_create returns a new reference */
10885 - link->local_sink = sink;
10886 -
10887 - edid_status = dm_helpers_read_local_edid(
10888 -diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
10889 -index 41883c981789..a684b38332ac 100644
10890 ---- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
10891 -+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
10892 -@@ -2334,9 +2334,10 @@ static void dcn10_apply_ctx_for_surface(
10893 - }
10894 - }
10895 -
10896 -- if (!pipe_ctx->plane_state &&
10897 -- old_pipe_ctx->plane_state &&
10898 -- old_pipe_ctx->stream_res.tg == tg) {
10899 -+ if ((!pipe_ctx->plane_state ||
10900 -+ pipe_ctx->stream_res.tg != old_pipe_ctx->stream_res.tg) &&
10901 -+ old_pipe_ctx->plane_state &&
10902 -+ old_pipe_ctx->stream_res.tg == tg) {
10903 -
10904 - dc->hwss.plane_atomic_disconnect(dc, old_pipe_ctx);
10905 - removed_pipe[i] = true;
10906 -diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
10907 -index c8f5c00dd1e7..86e3fb27c125 100644
10908 ---- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
10909 -+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
10910 -@@ -3491,14 +3491,14 @@ static int smu7_get_gpu_power(struct pp_hwmgr *hwmgr, u32 *query)
10911 -
10912 - smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PmStatusLogStart);
10913 - cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC,
10914 -- ixSMU_PM_STATUS_94, 0);
10915 -+ ixSMU_PM_STATUS_95, 0);
10916 -
10917 - for (i = 0; i < 10; i++) {
10918 -- mdelay(1);
10919 -+ mdelay(500);
10920 - smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PmStatusLogSample);
10921 - tmp = cgs_read_ind_register(hwmgr->device,
10922 - CGS_IND_REG__SMC,
10923 -- ixSMU_PM_STATUS_94);
10924 -+ ixSMU_PM_STATUS_95);
10925 - if (tmp != 0)
10926 - break;
10927 - }
10928 -diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
10929 -index f4290f6b0c38..2323ba9310d9 100644
10930 ---- a/drivers/gpu/drm/drm_atomic_helper.c
10931 -+++ b/drivers/gpu/drm/drm_atomic_helper.c
10932 -@@ -1611,6 +1611,15 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
10933 - if (old_plane_state->fb != new_plane_state->fb)
10934 - return -EINVAL;
10935 -
10936 -+ /*
10937 -+ * FIXME: Since prepare_fb and cleanup_fb are always called on
10938 -+ * the new_plane_state for async updates we need to block framebuffer
10939 -+ * changes. This prevents use of a fb that's been cleaned up and
10940 -+ * double cleanups from occuring.
10941 -+ */
10942 -+ if (old_plane_state->fb != new_plane_state->fb)
10943 -+ return -EINVAL;
10944 -+
10945 - funcs = plane->helper_private;
10946 - if (!funcs->atomic_async_update)
10947 - return -EINVAL;
10948 -diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
10949 -index 529414556962..1a244c53252c 100644
10950 ---- a/drivers/gpu/drm/drm_dp_mst_topology.c
10951 -+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
10952 -@@ -3286,6 +3286,7 @@ static int drm_dp_mst_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs
10953 - msg.u.i2c_read.transactions[i].i2c_dev_id = msgs[i].addr;
10954 - msg.u.i2c_read.transactions[i].num_bytes = msgs[i].len;
10955 - msg.u.i2c_read.transactions[i].bytes = msgs[i].buf;
10956 -+ msg.u.i2c_read.transactions[i].no_stop_bit = !(msgs[i].flags & I2C_M_STOP);
10957 - }
10958 - msg.u.i2c_read.read_i2c_device_id = msgs[num - 1].addr;
10959 - msg.u.i2c_read.num_bytes_read = msgs[num - 1].len;
10960 -diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
10961 -index d73703a695e8..edd8cb497f3b 100644
10962 ---- a/drivers/gpu/drm/drm_fb_helper.c
10963 -+++ b/drivers/gpu/drm/drm_fb_helper.c
10964 -@@ -2891,7 +2891,7 @@ int drm_fb_helper_fbdev_setup(struct drm_device *dev,
10965 - return 0;
10966 -
10967 - err_drm_fb_helper_fini:
10968 -- drm_fb_helper_fini(fb_helper);
10969 -+ drm_fb_helper_fbdev_teardown(dev);
10970 -
10971 - return ret;
10972 - }
10973 -@@ -3170,9 +3170,7 @@ static void drm_fbdev_client_unregister(struct drm_client_dev *client)
10974 -
10975 - static int drm_fbdev_client_restore(struct drm_client_dev *client)
10976 - {
10977 -- struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
10978 --
10979 -- drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);
10980 -+ drm_fb_helper_lastclose(client->dev);
10981 -
10982 - return 0;
10983 - }
10984 -diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
10985 -index 004191d01772..15b919f90c5a 100644
10986 ---- a/drivers/gpu/drm/drm_mode_object.c
10987 -+++ b/drivers/gpu/drm/drm_mode_object.c
10988 -@@ -465,6 +465,7 @@ static int set_property_atomic(struct drm_mode_object *obj,
10989 -
10990 - drm_modeset_acquire_init(&ctx, 0);
10991 - state->acquire_ctx = &ctx;
10992 -+
10993 - retry:
10994 - if (prop == state->dev->mode_config.dpms_property) {
10995 - if (obj->type != DRM_MODE_OBJECT_CONNECTOR) {
10996 -diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
10997 -index 5f650d8fc66b..4cfb56893b7f 100644
10998 ---- a/drivers/gpu/drm/drm_plane.c
10999 -+++ b/drivers/gpu/drm/drm_plane.c
11000 -@@ -220,6 +220,9 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
11001 - format_modifier_count++;
11002 - }
11003 -
11004 -+ if (format_modifier_count)
11005 -+ config->allow_fb_modifiers = true;
11006 -+
11007 - plane->modifier_count = format_modifier_count;
11008 - plane->modifiers = kmalloc_array(format_modifier_count,
11009 - sizeof(format_modifiers[0]),
11010 -diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
11011 -index 77ae634eb11c..bd95fd6b4ac8 100644
11012 ---- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
11013 -+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
11014 -@@ -1446,7 +1446,7 @@ static inline int cmd_address_audit(struct parser_exec_state *s,
11015 - }
11016 -
11017 - if (index_mode) {
11018 -- if (guest_gma >= I915_GTT_PAGE_SIZE / sizeof(u64)) {
11019 -+ if (guest_gma >= I915_GTT_PAGE_SIZE) {
11020 - ret = -EFAULT;
11021 - goto err;
11022 - }
11023 -diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
11024 -index c7103dd2d8d5..563ab8590061 100644
11025 ---- a/drivers/gpu/drm/i915/gvt/gtt.c
11026 -+++ b/drivers/gpu/drm/i915/gvt/gtt.c
11027 -@@ -1942,7 +1942,7 @@ void _intel_vgpu_mm_release(struct kref *mm_ref)
11028 - */
11029 - void intel_vgpu_unpin_mm(struct intel_vgpu_mm *mm)
11030 - {
11031 -- atomic_dec(&mm->pincount);
11032 -+ atomic_dec_if_positive(&mm->pincount);
11033 - }
11034 -
11035 - /**
11036 -diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
11037 -index 55bb7885e228..8fff49affc11 100644
11038 ---- a/drivers/gpu/drm/i915/gvt/scheduler.c
11039 -+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
11040 -@@ -1475,8 +1475,9 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
11041 - intel_runtime_pm_put(dev_priv);
11042 - }
11043 -
11044 -- if (ret && (vgpu_is_vm_unhealthy(ret))) {
11045 -- enter_failsafe_mode(vgpu, GVT_FAILSAFE_GUEST_ERR);
11046 -+ if (ret) {
11047 -+ if (vgpu_is_vm_unhealthy(ret))
11048 -+ enter_failsafe_mode(vgpu, GVT_FAILSAFE_GUEST_ERR);
11049 - intel_vgpu_destroy_workload(workload);
11050 - return ERR_PTR(ret);
11051 - }
11052 -diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
11053 -index b1c31967194b..489c1e656ff6 100644
11054 ---- a/drivers/gpu/drm/i915/i915_drv.h
11055 -+++ b/drivers/gpu/drm/i915/i915_drv.h
11056 -@@ -2293,7 +2293,8 @@ intel_info(const struct drm_i915_private *dev_priv)
11057 - INTEL_DEVID(dev_priv) == 0x5915 || \
11058 - INTEL_DEVID(dev_priv) == 0x591E)
11059 - #define IS_AML_ULX(dev_priv) (INTEL_DEVID(dev_priv) == 0x591C || \
11060 -- INTEL_DEVID(dev_priv) == 0x87C0)
11061 -+ INTEL_DEVID(dev_priv) == 0x87C0 || \
11062 -+ INTEL_DEVID(dev_priv) == 0x87CA)
11063 - #define IS_SKL_GT2(dev_priv) (IS_SKYLAKE(dev_priv) && \
11064 - (dev_priv)->info.gt == 2)
11065 - #define IS_SKL_GT3(dev_priv) (IS_SKYLAKE(dev_priv) && \
11066 -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
11067 -index 067054cf4a86..60bed3f27775 100644
11068 ---- a/drivers/gpu/drm/i915/i915_reg.h
11069 -+++ b/drivers/gpu/drm/i915/i915_reg.h
11070 -@@ -9205,7 +9205,7 @@ enum skl_power_gate {
11071 - #define TRANS_DDI_FUNC_CTL2(tran) _MMIO_TRANS2(tran, \
11072 - _TRANS_DDI_FUNC_CTL2_A)
11073 - #define PORT_SYNC_MODE_ENABLE (1 << 4)
11074 --#define PORT_SYNC_MODE_MASTER_SELECT(x) ((x) < 0)
11075 -+#define PORT_SYNC_MODE_MASTER_SELECT(x) ((x) << 0)
11076 - #define PORT_SYNC_MODE_MASTER_SELECT_MASK (0x7 << 0)
11077 - #define PORT_SYNC_MODE_MASTER_SELECT_SHIFT 0
11078 -
11079 -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
11080 -index 22a74608c6e4..dcd1df5322e8 100644
11081 ---- a/drivers/gpu/drm/i915/intel_dp.c
11082 -+++ b/drivers/gpu/drm/i915/intel_dp.c
11083 -@@ -1845,42 +1845,6 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
11084 - return false;
11085 - }
11086 -
11087 --/* Optimize link config in order: max bpp, min lanes, min clock */
11088 --static bool
11089 --intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
11090 -- struct intel_crtc_state *pipe_config,
11091 -- const struct link_config_limits *limits)
11092 --{
11093 -- struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
11094 -- int bpp, clock, lane_count;
11095 -- int mode_rate, link_clock, link_avail;
11096 --
11097 -- for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
11098 -- mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
11099 -- bpp);
11100 --
11101 -- for (lane_count = limits->min_lane_count;
11102 -- lane_count <= limits->max_lane_count;
11103 -- lane_count <<= 1) {
11104 -- for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
11105 -- link_clock = intel_dp->common_rates[clock];
11106 -- link_avail = intel_dp_max_data_rate(link_clock,
11107 -- lane_count);
11108 --
11109 -- if (mode_rate <= link_avail) {
11110 -- pipe_config->lane_count = lane_count;
11111 -- pipe_config->pipe_bpp = bpp;
11112 -- pipe_config->port_clock = link_clock;
11113 --
11114 -- return true;
11115 -- }
11116 -- }
11117 -- }
11118 -- }
11119 --
11120 -- return false;
11121 --}
11122 --
11123 - static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc)
11124 - {
11125 - int i, num_bpc;
11126 -@@ -2013,15 +1977,13 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
11127 - limits.min_bpp = 6 * 3;
11128 - limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
11129 -
11130 -- if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
11131 -+ if (intel_dp_is_edp(intel_dp)) {
11132 - /*
11133 - * Use the maximum clock and number of lanes the eDP panel
11134 -- * advertizes being capable of. The eDP 1.3 and earlier panels
11135 -- * are generally designed to support only a single clock and
11136 -- * lane configuration, and typically these values correspond to
11137 -- * the native resolution of the panel. With eDP 1.4 rate select
11138 -- * and DSC, this is decreasingly the case, and we need to be
11139 -- * able to select less than maximum link config.
11140 -+ * advertizes being capable of. The panels are generally
11141 -+ * designed to support only a single clock and lane
11142 -+ * configuration, and typically these values correspond to the
11143 -+ * native resolution of the panel.
11144 - */
11145 - limits.min_lane_count = limits.max_lane_count;
11146 - limits.min_clock = limits.max_clock;
11147 -@@ -2035,22 +1997,11 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
11148 - intel_dp->common_rates[limits.max_clock],
11149 - limits.max_bpp, adjusted_mode->crtc_clock);
11150 -
11151 -- if (intel_dp_is_edp(intel_dp))
11152 -- /*
11153 -- * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
11154 -- * section A.1: "It is recommended that the minimum number of
11155 -- * lanes be used, using the minimum link rate allowed for that
11156 -- * lane configuration."
11157 -- *
11158 -- * Note that we use the max clock and lane count for eDP 1.3 and
11159 -- * earlier, and fast vs. wide is irrelevant.
11160 -- */
11161 -- ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config,
11162 -- &limits);
11163 -- else
11164 -- /* Optimize for slow and wide. */
11165 -- ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
11166 -- &limits);
11167 -+ /*
11168 -+ * Optimize for slow and wide. This is the place to add alternative
11169 -+ * optimization policy.
11170 -+ */
11171 -+ ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits);
11172 -
11173 - /* enable compression if the mode doesn't fit available BW */
11174 - if (!ret) {
11175 -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
11176 -index cb307a2abf06..7316b4ab1b85 100644
11177 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
11178 -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
11179 -@@ -23,11 +23,14 @@ struct dpu_mdss {
11180 - struct dpu_irq_controller irq_controller;
11181 - };
11182 -
11183 --static irqreturn_t dpu_mdss_irq(int irq, void *arg)
11184 -+static void dpu_mdss_irq(struct irq_desc *desc)
11185 - {
11186 -- struct dpu_mdss *dpu_mdss = arg;
11187 -+ struct dpu_mdss *dpu_mdss = irq_desc_get_handler_data(desc);
11188 -+ struct irq_chip *chip = irq_desc_get_chip(desc);
11189 - u32 interrupts;
11190 -
11191 -+ chained_irq_enter(chip, desc);
11192 -+
11193 - interrupts = readl_relaxed(dpu_mdss->mmio + HW_INTR_STATUS);
11194 -
11195 - while (interrupts) {
11196 -@@ -39,20 +42,20 @@ static irqreturn_t dpu_mdss_irq(int irq, void *arg)
11197 - hwirq);
11198 - if (mapping == 0) {
11199 - DRM_ERROR("couldn't find irq mapping for %lu\n", hwirq);
11200 -- return IRQ_NONE;
11201 -+ break;
11202 - }
11203 -
11204 - rc = generic_handle_irq(mapping);
11205 - if (rc < 0) {
11206 - DRM_ERROR("handle irq fail: irq=%lu mapping=%u rc=%d\n",
11207 - hwirq, mapping, rc);
11208 -- return IRQ_NONE;
11209 -+ break;
11210 - }
11211 -
11212 - interrupts &= ~(1 << hwirq);
11213 - }
11214 -
11215 -- return IRQ_HANDLED;
11216 -+ chained_irq_exit(chip, desc);
11217 - }
11218 -
11219 - static void dpu_mdss_irq_mask(struct irq_data *irqd)
11220 -@@ -83,16 +86,16 @@ static struct irq_chip dpu_mdss_irq_chip = {
11221 - .irq_unmask = dpu_mdss_irq_unmask,
11222 - };
11223 -
11224 -+static struct lock_class_key dpu_mdss_lock_key, dpu_mdss_request_key;
11225 -+
11226 - static int dpu_mdss_irqdomain_map(struct irq_domain *domain,
11227 - unsigned int irq, irq_hw_number_t hwirq)
11228 - {
11229 - struct dpu_mdss *dpu_mdss = domain->host_data;
11230 -- int ret;
11231 -
11232 -+ irq_set_lockdep_class(irq, &dpu_mdss_lock_key, &dpu_mdss_request_key);
11233 - irq_set_chip_and_handler(irq, &dpu_mdss_irq_chip, handle_level_irq);
11234 -- ret = irq_set_chip_data(irq, dpu_mdss);
11235 --
11236 -- return ret;
11237 -+ return irq_set_chip_data(irq, dpu_mdss);
11238 - }
11239 -
11240 - static const struct irq_domain_ops dpu_mdss_irqdomain_ops = {
11241 -@@ -159,11 +162,13 @@ static void dpu_mdss_destroy(struct drm_device *dev)
11242 - struct msm_drm_private *priv = dev->dev_private;
11243 - struct dpu_mdss *dpu_mdss = to_dpu_mdss(priv->mdss);
11244 - struct dss_module_power *mp = &dpu_mdss->mp;
11245 -+ int irq;
11246 -
11247 - pm_runtime_suspend(dev->dev);
11248 - pm_runtime_disable(dev->dev);
11249 - _dpu_mdss_irq_domain_fini(dpu_mdss);
11250 -- free_irq(platform_get_irq(pdev, 0), dpu_mdss);
11251 -+ irq = platform_get_irq(pdev, 0);
11252 -+ irq_set_chained_handler_and_data(irq, NULL, NULL);
11253 - msm_dss_put_clk(mp->clk_config, mp->num_clk);
11254 - devm_kfree(&pdev->dev, mp->clk_config);
11255 -
11256 -@@ -187,6 +192,7 @@ int dpu_mdss_init(struct drm_device *dev)
11257 - struct dpu_mdss *dpu_mdss;
11258 - struct dss_module_power *mp;
11259 - int ret = 0;
11260 -+ int irq;
11261 -
11262 - dpu_mdss = devm_kzalloc(dev->dev, sizeof(*dpu_mdss), GFP_KERNEL);
11263 - if (!dpu_mdss)
11264 -@@ -219,12 +225,12 @@ int dpu_mdss_init(struct drm_device *dev)
11265 - if (ret)
11266 - goto irq_domain_error;
11267 -
11268 -- ret = request_irq(platform_get_irq(pdev, 0),
11269 -- dpu_mdss_irq, 0, "dpu_mdss_isr", dpu_mdss);
11270 -- if (ret) {
11271 -- DPU_ERROR("failed to init irq: %d\n", ret);
11272 -+ irq = platform_get_irq(pdev, 0);
11273 -+ if (irq < 0)
11274 - goto irq_error;
11275 -- }
11276 -+
11277 -+ irq_set_chained_handler_and_data(irq, dpu_mdss_irq,
11278 -+ dpu_mdss);
11279 -
11280 - pm_runtime_enable(dev->dev);
11281 -
11282 -diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
11283 -index 6a4ca139cf5d..8fd8124d72ba 100644
11284 ---- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
11285 -+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
11286 -@@ -750,7 +750,9 @@ static int nv17_tv_set_property(struct drm_encoder *encoder,
11287 - /* Disable the crtc to ensure a full modeset is
11288 - * performed whenever it's turned on again. */
11289 - if (crtc)
11290 -- drm_crtc_force_disable(crtc);
11291 -+ drm_crtc_helper_set_mode(crtc, &crtc->mode,
11292 -+ crtc->x, crtc->y,
11293 -+ crtc->primary->fb);
11294 - }
11295 -
11296 - return 0;
11297 -diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
11298 -index f471537c852f..1e14c6921454 100644
11299 ---- a/drivers/gpu/drm/radeon/evergreen_cs.c
11300 -+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
11301 -@@ -1299,6 +1299,7 @@ static int evergreen_cs_handle_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
11302 - return -EINVAL;
11303 - }
11304 - ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff);
11305 -+ break;
11306 - case CB_TARGET_MASK:
11307 - track->cb_target_mask = radeon_get_ib_value(p, idx);
11308 - track->cb_dirty = true;
11309 -diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
11310 -index 9c7007d45408..f9a90ff24e6d 100644
11311 ---- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
11312 -+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
11313 -@@ -331,6 +331,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu,
11314 - dev_dbg(rcdu->dev,
11315 - "connected entity %pOF is disabled, skipping\n",
11316 - entity);
11317 -+ of_node_put(entity);
11318 - return -ENODEV;
11319 - }
11320 -
11321 -@@ -366,6 +367,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu,
11322 - dev_warn(rcdu->dev,
11323 - "no encoder found for endpoint %pOF, skipping\n",
11324 - ep->local_node);
11325 -+ of_node_put(entity);
11326 - return -ENODEV;
11327 - }
11328 -
11329 -diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
11330 -index fb70fb486fbf..cdbb47566cac 100644
11331 ---- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
11332 -+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
11333 -@@ -511,6 +511,18 @@ static void vop_core_clks_disable(struct vop *vop)
11334 - clk_disable(vop->hclk);
11335 - }
11336 -
11337 -+static void vop_win_disable(struct vop *vop, const struct vop_win_data *win)
11338 -+{
11339 -+ if (win->phy->scl && win->phy->scl->ext) {
11340 -+ VOP_SCL_SET_EXT(vop, win, yrgb_hor_scl_mode, SCALE_NONE);
11341 -+ VOP_SCL_SET_EXT(vop, win, yrgb_ver_scl_mode, SCALE_NONE);
11342 -+ VOP_SCL_SET_EXT(vop, win, cbcr_hor_scl_mode, SCALE_NONE);
11343 -+ VOP_SCL_SET_EXT(vop, win, cbcr_ver_scl_mode, SCALE_NONE);
11344 -+ }
11345 -+
11346 -+ VOP_WIN_SET(vop, win, enable, 0);
11347 -+}
11348 -+
11349 - static int vop_enable(struct drm_crtc *crtc)
11350 - {
11351 - struct vop *vop = to_vop(crtc);
11352 -@@ -556,7 +568,7 @@ static int vop_enable(struct drm_crtc *crtc)
11353 - struct vop_win *vop_win = &vop->win[i];
11354 - const struct vop_win_data *win = vop_win->data;
11355 -
11356 -- VOP_WIN_SET(vop, win, enable, 0);
11357 -+ vop_win_disable(vop, win);
11358 - }
11359 - spin_unlock(&vop->reg_lock);
11360 -
11361 -@@ -700,7 +712,7 @@ static void vop_plane_atomic_disable(struct drm_plane *plane,
11362 -
11363 - spin_lock(&vop->reg_lock);
11364 -
11365 -- VOP_WIN_SET(vop, win, enable, 0);
11366 -+ vop_win_disable(vop, win);
11367 -
11368 - spin_unlock(&vop->reg_lock);
11369 - }
11370 -@@ -1476,7 +1488,7 @@ static int vop_initial(struct vop *vop)
11371 - int channel = i * 2 + 1;
11372 -
11373 - VOP_WIN_SET(vop, win, channel, (channel + 1) << 4 | channel);
11374 -- VOP_WIN_SET(vop, win, enable, 0);
11375 -+ vop_win_disable(vop, win);
11376 - VOP_WIN_SET(vop, win, gate, 1);
11377 - }
11378 -
11379 -diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
11380 -index e2942c9a11a7..35ddbec1375a 100644
11381 ---- a/drivers/gpu/drm/scheduler/sched_entity.c
11382 -+++ b/drivers/gpu/drm/scheduler/sched_entity.c
11383 -@@ -52,12 +52,12 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
11384 - {
11385 - int i;
11386 -
11387 -- if (!(entity && rq_list && num_rq_list > 0 && rq_list[0]))
11388 -+ if (!(entity && rq_list && (num_rq_list == 0 || rq_list[0])))
11389 - return -EINVAL;
11390 -
11391 - memset(entity, 0, sizeof(struct drm_sched_entity));
11392 - INIT_LIST_HEAD(&entity->list);
11393 -- entity->rq = rq_list[0];
11394 -+ entity->rq = NULL;
11395 - entity->guilty = guilty;
11396 - entity->num_rq_list = num_rq_list;
11397 - entity->rq_list = kcalloc(num_rq_list, sizeof(struct drm_sched_rq *),
11398 -@@ -67,6 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
11399 -
11400 - for (i = 0; i < num_rq_list; ++i)
11401 - entity->rq_list[i] = rq_list[i];
11402 -+
11403 -+ if (num_rq_list)
11404 -+ entity->rq = rq_list[0];
11405 -+
11406 - entity->last_scheduled = NULL;
11407 -
11408 - spin_lock_init(&entity->rq_lock);
11409 -@@ -165,6 +169,9 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)
11410 - struct task_struct *last_user;
11411 - long ret = timeout;
11412 -
11413 -+ if (!entity->rq)
11414 -+ return 0;
11415 -+
11416 - sched = entity->rq->sched;
11417 - /**
11418 - * The client will not queue more IBs during this fini, consume existing
11419 -@@ -264,20 +271,24 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity)
11420 - */
11421 - void drm_sched_entity_fini(struct drm_sched_entity *entity)
11422 - {
11423 -- struct drm_gpu_scheduler *sched;
11424 -+ struct drm_gpu_scheduler *sched = NULL;
11425 -
11426 -- sched = entity->rq->sched;
11427 -- drm_sched_rq_remove_entity(entity->rq, entity);
11428 -+ if (entity->rq) {
11429 -+ sched = entity->rq->sched;
11430 -+ drm_sched_rq_remove_entity(entity->rq, entity);
11431 -+ }
11432 -
11433 - /* Consumption of existing IBs wasn't completed. Forcefully
11434 - * remove them here.
11435 - */
11436 - if (spsc_queue_peek(&entity->job_queue)) {
11437 -- /* Park the kernel for a moment to make sure it isn't processing
11438 -- * our enity.
11439 -- */
11440 -- kthread_park(sched->thread);
11441 -- kthread_unpark(sched->thread);
11442 -+ if (sched) {
11443 -+ /* Park the kernel for a moment to make sure it isn't processing
11444 -+ * our enity.
11445 -+ */
11446 -+ kthread_park(sched->thread);
11447 -+ kthread_unpark(sched->thread);
11448 -+ }
11449 - if (entity->dependency) {
11450 - dma_fence_remove_callback(entity->dependency,
11451 - &entity->cb);
11452 -@@ -362,9 +373,11 @@ void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
11453 - for (i = 0; i < entity->num_rq_list; ++i)
11454 - drm_sched_entity_set_rq_priority(&entity->rq_list[i], priority);
11455 -
11456 -- drm_sched_rq_remove_entity(entity->rq, entity);
11457 -- drm_sched_entity_set_rq_priority(&entity->rq, priority);
11458 -- drm_sched_rq_add_entity(entity->rq, entity);
11459 -+ if (entity->rq) {
11460 -+ drm_sched_rq_remove_entity(entity->rq, entity);
11461 -+ drm_sched_entity_set_rq_priority(&entity->rq, priority);
11462 -+ drm_sched_rq_add_entity(entity->rq, entity);
11463 -+ }
11464 -
11465 - spin_unlock(&entity->rq_lock);
11466 - }
11467 -diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
11468 -index dc47720c99ba..39d8509d96a0 100644
11469 ---- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
11470 -+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
11471 -@@ -48,8 +48,13 @@ static enum drm_mode_status
11472 - sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
11473 - const struct drm_display_mode *mode)
11474 - {
11475 -- /* This is max for HDMI 2.0b (4K@60Hz) */
11476 -- if (mode->clock > 594000)
11477 -+ /*
11478 -+ * Controller support maximum of 594 MHz, which correlates to
11479 -+ * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than
11480 -+ * 340 MHz scrambling has to be enabled. Because scrambling is
11481 -+ * not yet implemented, just limit to 340 MHz for now.
11482 -+ */
11483 -+ if (mode->clock > 340000)
11484 - return MODE_CLOCK_HIGH;
11485 -
11486 - return MODE_OK;
11487 -diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
11488 -index a63e3011e971..bd4f0b88bbd7 100644
11489 ---- a/drivers/gpu/drm/udl/udl_drv.c
11490 -+++ b/drivers/gpu/drm/udl/udl_drv.c
11491 -@@ -51,6 +51,7 @@ static struct drm_driver driver = {
11492 - .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
11493 - .load = udl_driver_load,
11494 - .unload = udl_driver_unload,
11495 -+ .release = udl_driver_release,
11496 -
11497 - /* gem hooks */
11498 - .gem_free_object_unlocked = udl_gem_free_object,
11499 -diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
11500 -index e9e9b1ff678e..4ae67d882eae 100644
11501 ---- a/drivers/gpu/drm/udl/udl_drv.h
11502 -+++ b/drivers/gpu/drm/udl/udl_drv.h
11503 -@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb);
11504 -
11505 - int udl_driver_load(struct drm_device *dev, unsigned long flags);
11506 - void udl_driver_unload(struct drm_device *dev);
11507 -+void udl_driver_release(struct drm_device *dev);
11508 -
11509 - int udl_fbdev_init(struct drm_device *dev);
11510 - void udl_fbdev_cleanup(struct drm_device *dev);
11511 -diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
11512 -index 1b014d92855b..19055dda3140 100644
11513 ---- a/drivers/gpu/drm/udl/udl_main.c
11514 -+++ b/drivers/gpu/drm/udl/udl_main.c
11515 -@@ -378,6 +378,12 @@ void udl_driver_unload(struct drm_device *dev)
11516 - udl_free_urb_list(dev);
11517 -
11518 - udl_fbdev_cleanup(dev);
11519 -- udl_modeset_cleanup(dev);
11520 - kfree(udl);
11521 - }
11522 -+
11523 -+void udl_driver_release(struct drm_device *dev)
11524 -+{
11525 -+ udl_modeset_cleanup(dev);
11526 -+ drm_dev_fini(dev);
11527 -+ kfree(dev);
11528 -+}
11529 -diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
11530 -index 5930facd6d2d..11a8f99ba18c 100644
11531 ---- a/drivers/gpu/drm/vgem/vgem_drv.c
11532 -+++ b/drivers/gpu/drm/vgem/vgem_drv.c
11533 -@@ -191,13 +191,9 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
11534 - ret = drm_gem_handle_create(file, &obj->base, handle);
11535 - drm_gem_object_put_unlocked(&obj->base);
11536 - if (ret)
11537 -- goto err;
11538 -+ return ERR_PTR(ret);
11539 -
11540 - return &obj->base;
11541 --
11542 --err:
11543 -- __vgem_gem_destroy(obj);
11544 -- return ERR_PTR(ret);
11545 - }
11546 -
11547 - static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
11548 -diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
11549 -index f39a183d59c2..e7e946035027 100644
11550 ---- a/drivers/gpu/drm/virtio/virtgpu_object.c
11551 -+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
11552 -@@ -28,10 +28,21 @@
11553 - static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
11554 - uint32_t *resid)
11555 - {
11556 -+#if 0
11557 - int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
11558 -
11559 - if (handle < 0)
11560 - return handle;
11561 -+#else
11562 -+ static int handle;
11563 -+
11564 -+ /*
11565 -+ * FIXME: dirty hack to avoid re-using IDs, virglrenderer
11566 -+ * can't deal with that. Needs fixing in virglrenderer, also
11567 -+ * should figure a better way to handle that in the guest.
11568 -+ */
11569 -+ handle++;
11570 -+#endif
11571 -
11572 - *resid = handle + 1;
11573 - return 0;
11574 -@@ -39,7 +50,9 @@ static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
11575 -
11576 - static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
11577 - {
11578 -+#if 0
11579 - ida_free(&vgdev->resource_ida, id - 1);
11580 -+#endif
11581 - }
11582 -
11583 - static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
11584 -diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
11585 -index eb56ee893761..1054f535178a 100644
11586 ---- a/drivers/gpu/drm/vkms/vkms_crtc.c
11587 -+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
11588 -@@ -4,13 +4,17 @@
11589 - #include <drm/drm_atomic_helper.h>
11590 - #include <drm/drm_crtc_helper.h>
11591 -
11592 --static void _vblank_handle(struct vkms_output *output)
11593 -+static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
11594 - {
11595 -+ struct vkms_output *output = container_of(timer, struct vkms_output,
11596 -+ vblank_hrtimer);
11597 - struct drm_crtc *crtc = &output->crtc;
11598 - struct vkms_crtc_state *state = to_vkms_crtc_state(crtc->state);
11599 -+ int ret_overrun;
11600 - bool ret;
11601 -
11602 - spin_lock(&output->lock);
11603 -+
11604 - ret = drm_crtc_handle_vblank(crtc);
11605 - if (!ret)
11606 - DRM_ERROR("vkms failure on handling vblank");
11607 -@@ -31,19 +35,9 @@ static void _vblank_handle(struct vkms_output *output)
11608 - DRM_WARN("failed to queue vkms_crc_work_handle");
11609 - }
11610 -
11611 -- spin_unlock(&output->lock);
11612 --}
11613 --
11614 --static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
11615 --{
11616 -- struct vkms_output *output = container_of(timer, struct vkms_output,
11617 -- vblank_hrtimer);
11618 -- int ret_overrun;
11619 --
11620 -- _vblank_handle(output);
11621 --
11622 - ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
11623 - output->period_ns);
11624 -+ spin_unlock(&output->lock);
11625 -
11626 - return HRTIMER_RESTART;
11627 - }
11628 -@@ -81,6 +75,9 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
11629 -
11630 - *vblank_time = output->vblank_hrtimer.node.expires;
11631 -
11632 -+ if (!in_vblank_irq)
11633 -+ *vblank_time -= output->period_ns;
11634 -+
11635 - return true;
11636 - }
11637 -
11638 -@@ -98,6 +95,7 @@ static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
11639 - vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
11640 - if (!vkms_state)
11641 - return;
11642 -+ INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
11643 -
11644 - crtc->state = &vkms_state->base;
11645 - crtc->state->crtc = crtc;
11646 -diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
11647 -index 138b0bb325cf..69048e73377d 100644
11648 ---- a/drivers/gpu/drm/vkms/vkms_gem.c
11649 -+++ b/drivers/gpu/drm/vkms/vkms_gem.c
11650 -@@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
11651 -
11652 - ret = drm_gem_handle_create(file, &obj->gem, handle);
11653 - drm_gem_object_put_unlocked(&obj->gem);
11654 -- if (ret) {
11655 -- drm_gem_object_release(&obj->gem);
11656 -- kfree(obj);
11657 -+ if (ret)
11658 - return ERR_PTR(ret);
11659 -- }
11660 -
11661 - return &obj->gem;
11662 - }
11663 -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
11664 -index b913a56f3426..2a9112515f46 100644
11665 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
11666 -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
11667 -@@ -564,11 +564,9 @@ static int vmw_fb_set_par(struct fb_info *info)
11668 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11669 - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
11670 - };
11671 -- struct drm_display_mode *old_mode;
11672 - struct drm_display_mode *mode;
11673 - int ret;
11674 -
11675 -- old_mode = par->set_mode;
11676 - mode = drm_mode_duplicate(vmw_priv->dev, &new_mode);
11677 - if (!mode) {
11678 - DRM_ERROR("Could not create new fb mode.\n");
11679 -@@ -579,11 +577,7 @@ static int vmw_fb_set_par(struct fb_info *info)
11680 - mode->vdisplay = var->yres;
11681 - vmw_guess_mode_timing(mode);
11682 -
11683 -- if (old_mode && drm_mode_equal(old_mode, mode)) {
11684 -- drm_mode_destroy(vmw_priv->dev, mode);
11685 -- mode = old_mode;
11686 -- old_mode = NULL;
11687 -- } else if (!vmw_kms_validate_mode_vram(vmw_priv,
11688 -+ if (!vmw_kms_validate_mode_vram(vmw_priv,
11689 - mode->hdisplay *
11690 - DIV_ROUND_UP(var->bits_per_pixel, 8),
11691 - mode->vdisplay)) {
11692 -@@ -620,8 +614,8 @@ static int vmw_fb_set_par(struct fb_info *info)
11693 - schedule_delayed_work(&par->local_work, 0);
11694 -
11695 - out_unlock:
11696 -- if (old_mode)
11697 -- drm_mode_destroy(vmw_priv->dev, old_mode);
11698 -+ if (par->set_mode)
11699 -+ drm_mode_destroy(vmw_priv->dev, par->set_mode);
11700 - par->set_mode = mode;
11701 -
11702 - mutex_unlock(&par->bo_mutex);
11703 -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
11704 -index b93c558dd86e..7da752ca1c34 100644
11705 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
11706 -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
11707 -@@ -57,7 +57,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
11708 -
11709 - id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL);
11710 - if (id < 0)
11711 -- return id;
11712 -+ return (id != -ENOMEM ? 0 : id);
11713 -
11714 - spin_lock(&gman->lock);
11715 -
11716 -diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
11717 -index 15ed6177a7a3..f040c8a7f9a9 100644
11718 ---- a/drivers/hid/hid-logitech-hidpp.c
11719 -+++ b/drivers/hid/hid-logitech-hidpp.c
11720 -@@ -2608,8 +2608,9 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
11721 - input_report_rel(mydata->input, REL_Y, v);
11722 -
11723 - v = hid_snto32(data[6], 8);
11724 -- hidpp_scroll_counter_handle_scroll(
11725 -- &hidpp->vertical_wheel_counter, v);
11726 -+ if (v != 0)
11727 -+ hidpp_scroll_counter_handle_scroll(
11728 -+ &hidpp->vertical_wheel_counter, v);
11729 -
11730 - input_sync(mydata->input);
11731 - }
11732 -diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
11733 -index 742191bb24c6..45e33c7ba9a6 100644
11734 ---- a/drivers/hid/intel-ish-hid/ipc/ipc.c
11735 -+++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
11736 -@@ -91,7 +91,10 @@ static bool check_generated_interrupt(struct ishtp_device *dev)
11737 - IPC_INT_FROM_ISH_TO_HOST_CHV_AB(pisr_val);
11738 - } else {
11739 - pisr_val = ish_reg_read(dev, IPC_REG_PISR_BXT);
11740 -- interrupt_generated = IPC_INT_FROM_ISH_TO_HOST_BXT(pisr_val);
11741 -+ interrupt_generated = !!pisr_val;
11742 -+ /* only busy-clear bit is RW, others are RO */
11743 -+ if (pisr_val)
11744 -+ ish_reg_write(dev, IPC_REG_PISR_BXT, pisr_val);
11745 - }
11746 -
11747 - return interrupt_generated;
11748 -@@ -839,11 +842,11 @@ int ish_hw_start(struct ishtp_device *dev)
11749 - {
11750 - ish_set_host_rdy(dev);
11751 -
11752 -+ set_host_ready(dev);
11753 -+
11754 - /* After that we can enable ISH DMA operation and wakeup ISHFW */
11755 - ish_wakeup(dev);
11756 -
11757 -- set_host_ready(dev);
11758 --
11759 - /* wait for FW-initiated reset flow */
11760 - if (!dev->recvd_hw_ready)
11761 - wait_event_interruptible_timeout(dev->wait_hw_ready,
11762 -diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c
11763 -index 728dc6d4561a..a271d6d169b1 100644
11764 ---- a/drivers/hid/intel-ish-hid/ishtp/bus.c
11765 -+++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
11766 -@@ -675,7 +675,8 @@ int ishtp_cl_device_bind(struct ishtp_cl *cl)
11767 - spin_lock_irqsave(&cl->dev->device_list_lock, flags);
11768 - list_for_each_entry(cl_device, &cl->dev->device_list,
11769 - device_link) {
11770 -- if (cl_device->fw_client->client_id == cl->fw_client_id) {
11771 -+ if (cl_device->fw_client &&
11772 -+ cl_device->fw_client->client_id == cl->fw_client_id) {
11773 - cl->device = cl_device;
11774 - rv = 0;
11775 - break;
11776 -@@ -735,6 +736,7 @@ void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
11777 - spin_lock_irqsave(&ishtp_dev->device_list_lock, flags);
11778 - list_for_each_entry_safe(cl_device, n, &ishtp_dev->device_list,
11779 - device_link) {
11780 -+ cl_device->fw_client = NULL;
11781 - if (warm_reset && cl_device->reference_count)
11782 - continue;
11783 -
11784 -diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
11785 -index 6f929bfa9fcd..d0f1dfe2bcbb 100644
11786 ---- a/drivers/hwmon/Kconfig
11787 -+++ b/drivers/hwmon/Kconfig
11788 -@@ -1759,6 +1759,7 @@ config SENSORS_VT8231
11789 - config SENSORS_W83773G
11790 - tristate "Nuvoton W83773G"
11791 - depends on I2C
11792 -+ select REGMAP_I2C
11793 - help
11794 - If you say yes here you get support for the Nuvoton W83773G hardware
11795 - monitoring chip.
11796 -diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
11797 -index 391118c8aae8..c888f4aca45c 100644
11798 ---- a/drivers/hwmon/occ/common.c
11799 -+++ b/drivers/hwmon/occ/common.c
11800 -@@ -889,6 +889,8 @@ static int occ_setup_sensor_attrs(struct occ *occ)
11801 - s++;
11802 - }
11803 - }
11804 -+
11805 -+ s = (sensors->power.num_sensors * 4) + 1;
11806 - } else {
11807 - for (i = 0; i < sensors->power.num_sensors; ++i) {
11808 - s = i + 1;
11809 -@@ -917,11 +919,11 @@ static int occ_setup_sensor_attrs(struct occ *occ)
11810 - show_power, NULL, 3, i);
11811 - attr++;
11812 - }
11813 -- }
11814 -
11815 -- if (sensors->caps.num_sensors >= 1) {
11816 - s = sensors->power.num_sensors + 1;
11817 -+ }
11818 -
11819 -+ if (sensors->caps.num_sensors >= 1) {
11820 - snprintf(attr->name, sizeof(attr->name), "power%d_label", s);
11821 - attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL,
11822 - 0, 0);
11823 -diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
11824 -index abe8249b893b..f21eb28b6782 100644
11825 ---- a/drivers/hwtracing/coresight/coresight-etm-perf.c
11826 -+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
11827 -@@ -177,15 +177,15 @@ static void etm_free_aux(void *data)
11828 - schedule_work(&event_data->work);
11829 - }
11830 -
11831 --static void *etm_setup_aux(int event_cpu, void **pages,
11832 -+static void *etm_setup_aux(struct perf_event *event, void **pages,
11833 - int nr_pages, bool overwrite)
11834 - {
11835 -- int cpu;
11836 -+ int cpu = event->cpu;
11837 - cpumask_t *mask;
11838 - struct coresight_device *sink;
11839 - struct etm_event_data *event_data = NULL;
11840 -
11841 -- event_data = alloc_event_data(event_cpu);
11842 -+ event_data = alloc_event_data(cpu);
11843 - if (!event_data)
11844 - return NULL;
11845 - INIT_WORK(&event_data->work, free_event_data);
11846 -diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
11847 -index 53e2fb6e86f6..fe76b176974a 100644
11848 ---- a/drivers/hwtracing/coresight/coresight-etm4x.c
11849 -+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
11850 -@@ -55,7 +55,8 @@ static void etm4_os_unlock(struct etmv4_drvdata *drvdata)
11851 -
11852 - static bool etm4_arch_supported(u8 arch)
11853 - {
11854 -- switch (arch) {
11855 -+ /* Mask out the minor version number */
11856 -+ switch (arch & 0xf0) {
11857 - case ETM_ARCH_V4:
11858 - break;
11859 - default:
11860 -diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
11861 -index 8426b7970c14..cc287cf6eb29 100644
11862 ---- a/drivers/hwtracing/intel_th/gth.c
11863 -+++ b/drivers/hwtracing/intel_th/gth.c
11864 -@@ -607,6 +607,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
11865 - {
11866 - struct gth_device *gth = dev_get_drvdata(&thdev->dev);
11867 - int port = othdev->output.port;
11868 -+ int master;
11869 -
11870 - if (thdev->host_mode)
11871 - return;
11872 -@@ -615,6 +616,9 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
11873 - othdev->output.port = -1;
11874 - othdev->output.active = false;
11875 - gth->output[port].output = NULL;
11876 -+ for (master = 0; master < TH_CONFIGURABLE_MASTERS; master++)
11877 -+ if (gth->master[master] == port)
11878 -+ gth->master[master] = -1;
11879 - spin_unlock(&gth->gth_lock);
11880 - }
11881 -
11882 -diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
11883 -index 93ce3aa740a9..c7ba8acfd4d5 100644
11884 ---- a/drivers/hwtracing/stm/core.c
11885 -+++ b/drivers/hwtracing/stm/core.c
11886 -@@ -244,6 +244,9 @@ static int find_free_channels(unsigned long *bitmap, unsigned int start,
11887 - ;
11888 - if (i == width)
11889 - return pos;
11890 -+
11891 -+ /* step over [pos..pos+i) to continue search */
11892 -+ pos += i;
11893 - }
11894 -
11895 - return -1;
11896 -@@ -732,7 +735,7 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)
11897 - struct stm_device *stm = stmf->stm;
11898 - struct stp_policy_id *id;
11899 - char *ids[] = { NULL, NULL };
11900 -- int ret = -EINVAL;
11901 -+ int ret = -EINVAL, wlimit = 1;
11902 - u32 size;
11903 -
11904 - if (stmf->output.nr_chans)
11905 -@@ -760,8 +763,10 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)
11906 - if (id->__reserved_0 || id->__reserved_1)
11907 - goto err_free;
11908 -
11909 -- if (id->width < 1 ||
11910 -- id->width > PAGE_SIZE / stm->data->sw_mmiosz)
11911 -+ if (stm->data->sw_mmiosz)
11912 -+ wlimit = PAGE_SIZE / stm->data->sw_mmiosz;
11913 -+
11914 -+ if (id->width < 1 || id->width > wlimit)
11915 - goto err_free;
11916 -
11917 - ids[0] = id->id;
11918 -diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
11919 -index b4a0b2b99a78..6b4ef1d38fb2 100644
11920 ---- a/drivers/i2c/busses/i2c-designware-core.h
11921 -+++ b/drivers/i2c/busses/i2c-designware-core.h
11922 -@@ -215,6 +215,7 @@
11923 - * @disable_int: function to disable all interrupts
11924 - * @init: function to initialize the I2C hardware
11925 - * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE
11926 -+ * @suspended: set to true if the controller is suspended
11927 - *
11928 - * HCNT and LCNT parameters can be used if the platform knows more accurate
11929 - * values than the one computed based only on the input clock frequency.
11930 -@@ -270,6 +271,7 @@ struct dw_i2c_dev {
11931 - int (*set_sda_hold_time)(struct dw_i2c_dev *dev);
11932 - int mode;
11933 - struct i2c_bus_recovery_info rinfo;
11934 -+ bool suspended;
11935 - };
11936 -
11937 - #define ACCESS_SWAP 0x00000001
11938 -diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
11939 -index 8d1bc44d2530..bb8e3f149979 100644
11940 ---- a/drivers/i2c/busses/i2c-designware-master.c
11941 -+++ b/drivers/i2c/busses/i2c-designware-master.c
11942 -@@ -426,6 +426,12 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
11943 -
11944 - pm_runtime_get_sync(dev->dev);
11945 -
11946 -+ if (dev->suspended) {
11947 -+ dev_err(dev->dev, "Error %s call while suspended\n", __func__);
11948 -+ ret = -ESHUTDOWN;
11949 -+ goto done_nolock;
11950 -+ }
11951 -+
11952 - reinit_completion(&dev->cmd_complete);
11953 - dev->msgs = msgs;
11954 - dev->msgs_num = num;
11955 -diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
11956 -index d50f80487214..76810deb2de6 100644
11957 ---- a/drivers/i2c/busses/i2c-designware-pcidrv.c
11958 -+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
11959 -@@ -176,6 +176,7 @@ static int i2c_dw_pci_suspend(struct device *dev)
11960 - struct pci_dev *pdev = to_pci_dev(dev);
11961 - struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
11962 -
11963 -+ i_dev->suspended = true;
11964 - i_dev->disable(i_dev);
11965 -
11966 - return 0;
11967 -@@ -185,8 +186,12 @@ static int i2c_dw_pci_resume(struct device *dev)
11968 - {
11969 - struct pci_dev *pdev = to_pci_dev(dev);
11970 - struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
11971 -+ int ret;
11972 -
11973 -- return i_dev->init(i_dev);
11974 -+ ret = i_dev->init(i_dev);
11975 -+ i_dev->suspended = false;
11976 -+
11977 -+ return ret;
11978 - }
11979 - #endif
11980 -
11981 -diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
11982 -index 9eaac3be1f63..ead5e7de3e4d 100644
11983 ---- a/drivers/i2c/busses/i2c-designware-platdrv.c
11984 -+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
11985 -@@ -454,6 +454,8 @@ static int dw_i2c_plat_suspend(struct device *dev)
11986 - {
11987 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
11988 -
11989 -+ i_dev->suspended = true;
11990 -+
11991 - if (i_dev->shared_with_punit)
11992 - return 0;
11993 -
11994 -@@ -471,6 +473,7 @@ static int dw_i2c_plat_resume(struct device *dev)
11995 - i2c_dw_prepare_clk(i_dev, true);
11996 -
11997 - i_dev->init(i_dev);
11998 -+ i_dev->suspended = false;
11999 -
12000 - return 0;
12001 - }
12002 -diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
12003 -index c77adbbea0c7..e85dc8583896 100644
12004 ---- a/drivers/i2c/busses/i2c-tegra.c
12005 -+++ b/drivers/i2c/busses/i2c-tegra.c
12006 -@@ -118,6 +118,9 @@
12007 - #define I2C_MST_FIFO_STATUS_TX_MASK 0xff0000
12008 - #define I2C_MST_FIFO_STATUS_TX_SHIFT 16
12009 -
12010 -+/* Packet header size in bytes */
12011 -+#define I2C_PACKET_HEADER_SIZE 12
12012 -+
12013 - /*
12014 - * msg_end_type: The bus control which need to be send at end of transfer.
12015 - * @MSG_END_STOP: Send stop pulse at end of transfer.
12016 -@@ -836,12 +839,13 @@ static const struct i2c_algorithm tegra_i2c_algo = {
12017 - /* payload size is only 12 bit */
12018 - static const struct i2c_adapter_quirks tegra_i2c_quirks = {
12019 - .flags = I2C_AQ_NO_ZERO_LEN,
12020 -- .max_read_len = 4096,
12021 -- .max_write_len = 4096,
12022 -+ .max_read_len = SZ_4K,
12023 -+ .max_write_len = SZ_4K - I2C_PACKET_HEADER_SIZE,
12024 - };
12025 -
12026 - static const struct i2c_adapter_quirks tegra194_i2c_quirks = {
12027 - .flags = I2C_AQ_NO_ZERO_LEN,
12028 -+ .max_write_len = SZ_64K - I2C_PACKET_HEADER_SIZE,
12029 - };
12030 -
12031 - static const struct tegra_i2c_hw_feature tegra20_i2c_hw = {
12032 -diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
12033 -index 28460f6a60cc..af87a16ac3a5 100644
12034 ---- a/drivers/i2c/i2c-core-base.c
12035 -+++ b/drivers/i2c/i2c-core-base.c
12036 -@@ -430,7 +430,7 @@ static int i2c_device_remove(struct device *dev)
12037 - dev_pm_clear_wake_irq(&client->dev);
12038 - device_init_wakeup(&client->dev, false);
12039 -
12040 -- client->irq = 0;
12041 -+ client->irq = client->init_irq;
12042 -
12043 - return status;
12044 - }
12045 -@@ -741,10 +741,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
12046 - client->flags = info->flags;
12047 - client->addr = info->addr;
12048 -
12049 -- client->irq = info->irq;
12050 -- if (!client->irq)
12051 -- client->irq = i2c_dev_irq_from_resources(info->resources,
12052 -+ client->init_irq = info->irq;
12053 -+ if (!client->init_irq)
12054 -+ client->init_irq = i2c_dev_irq_from_resources(info->resources,
12055 - info->num_resources);
12056 -+ client->irq = client->init_irq;
12057 -
12058 - strlcpy(client->name, info->type, sizeof(client->name));
12059 -
12060 -diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
12061 -index 6cb7ad608bcd..0f01cdba9d2c 100644
12062 ---- a/drivers/i2c/i2c-core-of.c
12063 -+++ b/drivers/i2c/i2c-core-of.c
12064 -@@ -121,6 +121,17 @@ static int of_dev_node_match(struct device *dev, void *data)
12065 - return dev->of_node == data;
12066 - }
12067 -
12068 -+static int of_dev_or_parent_node_match(struct device *dev, void *data)
12069 -+{
12070 -+ if (dev->of_node == data)
12071 -+ return 1;
12072 -+
12073 -+ if (dev->parent)
12074 -+ return dev->parent->of_node == data;
12075 -+
12076 -+ return 0;
12077 -+}
12078 -+
12079 - /* must call put_device() when done with returned i2c_client device */
12080 - struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
12081 - {
12082 -@@ -145,7 +156,8 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
12083 - struct device *dev;
12084 - struct i2c_adapter *adapter;
12085 -
12086 -- dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
12087 -+ dev = bus_find_device(&i2c_bus_type, NULL, node,
12088 -+ of_dev_or_parent_node_match);
12089 - if (!dev)
12090 - return NULL;
12091 -
12092 -diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
12093 -index fa2d2b5767f3..1ca2c4d39f87 100644
12094 ---- a/drivers/iio/adc/exynos_adc.c
12095 -+++ b/drivers/iio/adc/exynos_adc.c
12096 -@@ -115,6 +115,7 @@
12097 - #define MAX_ADC_V2_CHANNELS 10
12098 - #define MAX_ADC_V1_CHANNELS 8
12099 - #define MAX_EXYNOS3250_ADC_CHANNELS 2
12100 -+#define MAX_EXYNOS4212_ADC_CHANNELS 4
12101 - #define MAX_S5PV210_ADC_CHANNELS 10
12102 -
12103 - /* Bit definitions common for ADC_V1 and ADC_V2 */
12104 -@@ -271,6 +272,19 @@ static void exynos_adc_v1_start_conv(struct exynos_adc *info,
12105 - writel(con1 | ADC_CON_EN_START, ADC_V1_CON(info->regs));
12106 - }
12107 -
12108 -+/* Exynos4212 and 4412 is like ADCv1 but with four channels only */
12109 -+static const struct exynos_adc_data exynos4212_adc_data = {
12110 -+ .num_channels = MAX_EXYNOS4212_ADC_CHANNELS,
12111 -+ .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */
12112 -+ .needs_adc_phy = true,
12113 -+ .phy_offset = EXYNOS_ADCV1_PHY_OFFSET,
12114 -+
12115 -+ .init_hw = exynos_adc_v1_init_hw,
12116 -+ .exit_hw = exynos_adc_v1_exit_hw,
12117 -+ .clear_irq = exynos_adc_v1_clear_irq,
12118 -+ .start_conv = exynos_adc_v1_start_conv,
12119 -+};
12120 -+
12121 - static const struct exynos_adc_data exynos_adc_v1_data = {
12122 - .num_channels = MAX_ADC_V1_CHANNELS,
12123 - .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */
12124 -@@ -492,6 +506,9 @@ static const struct of_device_id exynos_adc_match[] = {
12125 - }, {
12126 - .compatible = "samsung,s5pv210-adc",
12127 - .data = &exynos_adc_s5pv210_data,
12128 -+ }, {
12129 -+ .compatible = "samsung,exynos4212-adc",
12130 -+ .data = &exynos4212_adc_data,
12131 - }, {
12132 - .compatible = "samsung,exynos-adc-v1",
12133 - .data = &exynos_adc_v1_data,
12134 -@@ -929,7 +946,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
12135 - struct iio_dev *indio_dev = platform_get_drvdata(pdev);
12136 - struct exynos_adc *info = iio_priv(indio_dev);
12137 -
12138 -- if (IS_REACHABLE(CONFIG_INPUT)) {
12139 -+ if (IS_REACHABLE(CONFIG_INPUT) && info->input) {
12140 - free_irq(info->tsirq, info);
12141 - input_unregister_device(info->input);
12142 - }
12143 -diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
12144 -index c30c002f1fef..4735f8a1ca9d 100644
12145 ---- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
12146 -+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
12147 -@@ -423,18 +423,14 @@ static irqreturn_t pm8xxx_eoc_irq(int irq, void *d)
12148 - static struct pm8xxx_chan_info *
12149 - pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan)
12150 - {
12151 -- struct pm8xxx_chan_info *ch;
12152 - int i;
12153 -
12154 - for (i = 0; i < adc->nchans; i++) {
12155 -- ch = &adc->chans[i];
12156 -+ struct pm8xxx_chan_info *ch = &adc->chans[i];
12157 - if (ch->hwchan->amux_channel == chan)
12158 -- break;
12159 -+ return ch;
12160 - }
12161 -- if (i == adc->nchans)
12162 -- return NULL;
12163 --
12164 -- return ch;
12165 -+ return NULL;
12166 - }
12167 -
12168 - static int pm8xxx_read_channel_rsv(struct pm8xxx_xoadc *adc,
12169 -diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
12170 -index 84f077b2b90a..81bded0d37d1 100644
12171 ---- a/drivers/infiniband/core/cma.c
12172 -+++ b/drivers/infiniband/core/cma.c
12173 -@@ -2966,13 +2966,22 @@ static void addr_handler(int status, struct sockaddr *src_addr,
12174 - {
12175 - struct rdma_id_private *id_priv = context;
12176 - struct rdma_cm_event event = {};
12177 -+ struct sockaddr *addr;
12178 -+ struct sockaddr_storage old_addr;
12179 -
12180 - mutex_lock(&id_priv->handler_mutex);
12181 - if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY,
12182 - RDMA_CM_ADDR_RESOLVED))
12183 - goto out;
12184 -
12185 -- memcpy(cma_src_addr(id_priv), src_addr, rdma_addr_size(src_addr));
12186 -+ /*
12187 -+ * Store the previous src address, so that if we fail to acquire
12188 -+ * matching rdma device, old address can be restored back, which helps
12189 -+ * to cancel the cma listen operation correctly.
12190 -+ */
12191 -+ addr = cma_src_addr(id_priv);
12192 -+ memcpy(&old_addr, addr, rdma_addr_size(addr));
12193 -+ memcpy(addr, src_addr, rdma_addr_size(src_addr));
12194 - if (!status && !id_priv->cma_dev) {
12195 - status = cma_acquire_dev_by_src_ip(id_priv);
12196 - if (status)
12197 -@@ -2983,6 +2992,8 @@ static void addr_handler(int status, struct sockaddr *src_addr,
12198 - }
12199 -
12200 - if (status) {
12201 -+ memcpy(addr, &old_addr,
12202 -+ rdma_addr_size((struct sockaddr *)&old_addr));
12203 - if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
12204 - RDMA_CM_ADDR_BOUND))
12205 - goto out;
12206 -diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
12207 -index 8221813219e5..25a81fbb0d4d 100644
12208 ---- a/drivers/infiniband/hw/cxgb4/cm.c
12209 -+++ b/drivers/infiniband/hw/cxgb4/cm.c
12210 -@@ -1903,8 +1903,10 @@ static int abort_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
12211 - }
12212 - mutex_unlock(&ep->com.mutex);
12213 -
12214 -- if (release)
12215 -+ if (release) {
12216 -+ close_complete_upcall(ep, -ECONNRESET);
12217 - release_ep_resources(ep);
12218 -+ }
12219 - c4iw_put_ep(&ep->com);
12220 - return 0;
12221 - }
12222 -@@ -3606,7 +3608,6 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
12223 - if (close) {
12224 - if (abrupt) {
12225 - set_bit(EP_DISC_ABORT, &ep->com.history);
12226 -- close_complete_upcall(ep, -ECONNRESET);
12227 - ret = send_abort(ep);
12228 - } else {
12229 - set_bit(EP_DISC_CLOSE, &ep->com.history);
12230 -diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
12231 -index 6db2276f5c13..15ec3e1feb09 100644
12232 ---- a/drivers/infiniband/hw/hfi1/hfi.h
12233 -+++ b/drivers/infiniband/hw/hfi1/hfi.h
12234 -@@ -1435,7 +1435,7 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
12235 - struct hfi1_devdata *dd, u8 hw_pidx, u8 port);
12236 - void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd);
12237 - int hfi1_rcd_put(struct hfi1_ctxtdata *rcd);
12238 --void hfi1_rcd_get(struct hfi1_ctxtdata *rcd);
12239 -+int hfi1_rcd_get(struct hfi1_ctxtdata *rcd);
12240 - struct hfi1_ctxtdata *hfi1_rcd_get_by_index_safe(struct hfi1_devdata *dd,
12241 - u16 ctxt);
12242 - struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt);
12243 -diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
12244 -index 7835eb52e7c5..c532ceb0bb9a 100644
12245 ---- a/drivers/infiniband/hw/hfi1/init.c
12246 -+++ b/drivers/infiniband/hw/hfi1/init.c
12247 -@@ -215,12 +215,12 @@ static void hfi1_rcd_free(struct kref *kref)
12248 - struct hfi1_ctxtdata *rcd =
12249 - container_of(kref, struct hfi1_ctxtdata, kref);
12250 -
12251 -- hfi1_free_ctxtdata(rcd->dd, rcd);
12252 --
12253 - spin_lock_irqsave(&rcd->dd->uctxt_lock, flags);
12254 - rcd->dd->rcd[rcd->ctxt] = NULL;
12255 - spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags);
12256 -
12257 -+ hfi1_free_ctxtdata(rcd->dd, rcd);
12258 -+
12259 - kfree(rcd);
12260 - }
12261 -
12262 -@@ -243,10 +243,13 @@ int hfi1_rcd_put(struct hfi1_ctxtdata *rcd)
12263 - * @rcd: pointer to an initialized rcd data structure
12264 - *
12265 - * Use this to get a reference after the init.
12266 -+ *
12267 -+ * Return : reflect kref_get_unless_zero(), which returns non-zero on
12268 -+ * increment, otherwise 0.
12269 - */
12270 --void hfi1_rcd_get(struct hfi1_ctxtdata *rcd)
12271 -+int hfi1_rcd_get(struct hfi1_ctxtdata *rcd)
12272 - {
12273 -- kref_get(&rcd->kref);
12274 -+ return kref_get_unless_zero(&rcd->kref);
12275 - }
12276 -
12277 - /**
12278 -@@ -326,7 +329,8 @@ struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt)
12279 - spin_lock_irqsave(&dd->uctxt_lock, flags);
12280 - if (dd->rcd[ctxt]) {
12281 - rcd = dd->rcd[ctxt];
12282 -- hfi1_rcd_get(rcd);
12283 -+ if (!hfi1_rcd_get(rcd))
12284 -+ rcd = NULL;
12285 - }
12286 - spin_unlock_irqrestore(&dd->uctxt_lock, flags);
12287 -
12288 -diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c
12289 -index fedaf8260105..8c79a480f2b7 100644
12290 ---- a/drivers/infiniband/hw/mlx4/cm.c
12291 -+++ b/drivers/infiniband/hw/mlx4/cm.c
12292 -@@ -39,7 +39,7 @@
12293 -
12294 - #include "mlx4_ib.h"
12295 -
12296 --#define CM_CLEANUP_CACHE_TIMEOUT (5 * HZ)
12297 -+#define CM_CLEANUP_CACHE_TIMEOUT (30 * HZ)
12298 -
12299 - struct id_map_entry {
12300 - struct rb_node node;
12301 -diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
12302 -index 4ee32964e1dd..948eb6e25219 100644
12303 ---- a/drivers/infiniband/hw/mlx5/odp.c
12304 -+++ b/drivers/infiniband/hw/mlx5/odp.c
12305 -@@ -560,7 +560,7 @@ static int pagefault_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr,
12306 - struct ib_umem_odp *odp_mr = to_ib_umem_odp(mr->umem);
12307 - bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE;
12308 - bool prefetch = flags & MLX5_PF_FLAGS_PREFETCH;
12309 -- u64 access_mask = ODP_READ_ALLOWED_BIT;
12310 -+ u64 access_mask;
12311 - u64 start_idx, page_mask;
12312 - struct ib_umem_odp *odp;
12313 - size_t size;
12314 -@@ -582,6 +582,7 @@ next_mr:
12315 - page_shift = mr->umem->page_shift;
12316 - page_mask = ~(BIT(page_shift) - 1);
12317 - start_idx = (io_virt - (mr->mmkey.iova & page_mask)) >> page_shift;
12318 -+ access_mask = ODP_READ_ALLOWED_BIT;
12319 -
12320 - if (prefetch && !downgrade && !mr->umem->writable) {
12321 - /* prefetch with write-access must
12322 -diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
12323 -index c6cc3e4ab71d..c45b8359b389 100644
12324 ---- a/drivers/infiniband/sw/rdmavt/qp.c
12325 -+++ b/drivers/infiniband/sw/rdmavt/qp.c
12326 -@@ -2785,6 +2785,18 @@ again:
12327 - }
12328 - EXPORT_SYMBOL(rvt_copy_sge);
12329 -
12330 -+static enum ib_wc_status loopback_qp_drop(struct rvt_ibport *rvp,
12331 -+ struct rvt_qp *sqp)
12332 -+{
12333 -+ rvp->n_pkt_drops++;
12334 -+ /*
12335 -+ * For RC, the requester would timeout and retry so
12336 -+ * shortcut the timeouts and just signal too many retries.
12337 -+ */
12338 -+ return sqp->ibqp.qp_type == IB_QPT_RC ?
12339 -+ IB_WC_RETRY_EXC_ERR : IB_WC_SUCCESS;
12340 -+}
12341 -+
12342 - /**
12343 - * ruc_loopback - handle UC and RC loopback requests
12344 - * @sqp: the sending QP
12345 -@@ -2857,17 +2869,14 @@ again:
12346 - }
12347 - spin_unlock_irqrestore(&sqp->s_lock, flags);
12348 -
12349 -- if (!qp || !(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) ||
12350 -+ if (!qp) {
12351 -+ send_status = loopback_qp_drop(rvp, sqp);
12352 -+ goto serr_no_r_lock;
12353 -+ }
12354 -+ spin_lock_irqsave(&qp->r_lock, flags);
12355 -+ if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) ||
12356 - qp->ibqp.qp_type != sqp->ibqp.qp_type) {
12357 -- rvp->n_pkt_drops++;
12358 -- /*
12359 -- * For RC, the requester would timeout and retry so
12360 -- * shortcut the timeouts and just signal too many retries.
12361 -- */
12362 -- if (sqp->ibqp.qp_type == IB_QPT_RC)
12363 -- send_status = IB_WC_RETRY_EXC_ERR;
12364 -- else
12365 -- send_status = IB_WC_SUCCESS;
12366 -+ send_status = loopback_qp_drop(rvp, sqp);
12367 - goto serr;
12368 - }
12369 -
12370 -@@ -2893,18 +2902,8 @@ again:
12371 - goto send_comp;
12372 -
12373 - case IB_WR_SEND_WITH_INV:
12374 -- if (!rvt_invalidate_rkey(qp, wqe->wr.ex.invalidate_rkey)) {
12375 -- wc.wc_flags = IB_WC_WITH_INVALIDATE;
12376 -- wc.ex.invalidate_rkey = wqe->wr.ex.invalidate_rkey;
12377 -- }
12378 -- goto send;
12379 --
12380 - case IB_WR_SEND_WITH_IMM:
12381 -- wc.wc_flags = IB_WC_WITH_IMM;
12382 -- wc.ex.imm_data = wqe->wr.ex.imm_data;
12383 -- /* FALLTHROUGH */
12384 - case IB_WR_SEND:
12385 --send:
12386 - ret = rvt_get_rwqe(qp, false);
12387 - if (ret < 0)
12388 - goto op_err;
12389 -@@ -2912,6 +2911,22 @@ send:
12390 - goto rnr_nak;
12391 - if (wqe->length > qp->r_len)
12392 - goto inv_err;
12393 -+ switch (wqe->wr.opcode) {
12394 -+ case IB_WR_SEND_WITH_INV:
12395 -+ if (!rvt_invalidate_rkey(qp,
12396 -+ wqe->wr.ex.invalidate_rkey)) {
12397 -+ wc.wc_flags = IB_WC_WITH_INVALIDATE;
12398 -+ wc.ex.invalidate_rkey =
12399 -+ wqe->wr.ex.invalidate_rkey;
12400 -+ }
12401 -+ break;
12402 -+ case IB_WR_SEND_WITH_IMM:
12403 -+ wc.wc_flags = IB_WC_WITH_IMM;
12404 -+ wc.ex.imm_data = wqe->wr.ex.imm_data;
12405 -+ break;
12406 -+ default:
12407 -+ break;
12408 -+ }
12409 - break;
12410 -
12411 - case IB_WR_RDMA_WRITE_WITH_IMM:
12412 -@@ -3041,6 +3056,7 @@ do_write:
12413 - wqe->wr.send_flags & IB_SEND_SOLICITED);
12414 -
12415 - send_comp:
12416 -+ spin_unlock_irqrestore(&qp->r_lock, flags);
12417 - spin_lock_irqsave(&sqp->s_lock, flags);
12418 - rvp->n_loop_pkts++;
12419 - flush_send:
12420 -@@ -3067,6 +3083,7 @@ rnr_nak:
12421 - }
12422 - if (sqp->s_rnr_retry_cnt < 7)
12423 - sqp->s_rnr_retry--;
12424 -+ spin_unlock_irqrestore(&qp->r_lock, flags);
12425 - spin_lock_irqsave(&sqp->s_lock, flags);
12426 - if (!(ib_rvt_state_ops[sqp->state] & RVT_PROCESS_RECV_OK))
12427 - goto clr_busy;
12428 -@@ -3095,6 +3112,8 @@ err:
12429 - rvt_rc_error(qp, wc.status);
12430 -
12431 - serr:
12432 -+ spin_unlock_irqrestore(&qp->r_lock, flags);
12433 -+serr_no_r_lock:
12434 - spin_lock_irqsave(&sqp->s_lock, flags);
12435 - rvt_send_complete(sqp, wqe, send_status);
12436 - if (sqp->ibqp.qp_type == IB_QPT_RC) {
12437 -diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
12438 -index 23520df7650f..55cd6e0b409c 100644
12439 ---- a/drivers/input/misc/soc_button_array.c
12440 -+++ b/drivers/input/misc/soc_button_array.c
12441 -@@ -373,7 +373,7 @@ static struct soc_button_info soc_button_PNP0C40[] = {
12442 - { "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
12443 - { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
12444 - { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false },
12445 -- { "rotation_lock", 4, EV_SW, SW_ROTATE_LOCK, false, false },
12446 -+ { "rotation_lock", 4, EV_KEY, KEY_ROTATE_LOCK_TOGGLE, false, false },
12447 - { }
12448 - };
12449 -
12450 -diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
12451 -index 225ae6980182..628ef617bb2f 100644
12452 ---- a/drivers/input/mouse/elan_i2c_core.c
12453 -+++ b/drivers/input/mouse/elan_i2c_core.c
12454 -@@ -1337,6 +1337,7 @@ static const struct acpi_device_id elan_acpi_id[] = {
12455 - { "ELAN0000", 0 },
12456 - { "ELAN0100", 0 },
12457 - { "ELAN0600", 0 },
12458 -+ { "ELAN0601", 0 },
12459 - { "ELAN0602", 0 },
12460 - { "ELAN0605", 0 },
12461 - { "ELAN0608", 0 },
12462 -diff --git a/drivers/input/tablet/wacom_serial4.c b/drivers/input/tablet/wacom_serial4.c
12463 -index 38bfaca48eab..150f9eecaca7 100644
12464 ---- a/drivers/input/tablet/wacom_serial4.c
12465 -+++ b/drivers/input/tablet/wacom_serial4.c
12466 -@@ -187,6 +187,7 @@ enum {
12467 - MODEL_DIGITIZER_II = 0x5544, /* UD */
12468 - MODEL_GRAPHIRE = 0x4554, /* ET */
12469 - MODEL_PENPARTNER = 0x4354, /* CT */
12470 -+ MODEL_ARTPAD_II = 0x4B54, /* KT */
12471 - };
12472 -
12473 - static void wacom_handle_model_response(struct wacom *wacom)
12474 -@@ -245,6 +246,7 @@ static void wacom_handle_model_response(struct wacom *wacom)
12475 - wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL;
12476 - break;
12477 -
12478 -+ case MODEL_ARTPAD_II:
12479 - case MODEL_DIGITIZER_II:
12480 - wacom->dev->name = "Wacom Digitizer II";
12481 - wacom->dev->id.version = MODEL_DIGITIZER_II;
12482 -diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
12483 -index 2a7b78bb98b4..e628ef23418f 100644
12484 ---- a/drivers/iommu/amd_iommu.c
12485 -+++ b/drivers/iommu/amd_iommu.c
12486 -@@ -2605,7 +2605,12 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
12487 -
12488 - /* Everything is mapped - write the right values into s->dma_address */
12489 - for_each_sg(sglist, s, nelems, i) {
12490 -- s->dma_address += address + s->offset;
12491 -+ /*
12492 -+ * Add in the remaining piece of the scatter-gather offset that
12493 -+ * was masked out when we were determining the physical address
12494 -+ * via (sg_phys(s) & PAGE_MASK) earlier.
12495 -+ */
12496 -+ s->dma_address += address + (s->offset & ~PAGE_MASK);
12497 - s->dma_length = s->length;
12498 - }
12499 -
12500 -diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
12501 -index 78188bf7e90d..dbd6824dfffa 100644
12502 ---- a/drivers/iommu/intel-iommu.c
12503 -+++ b/drivers/iommu/intel-iommu.c
12504 -@@ -2485,7 +2485,8 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
12505 - if (dev && dev_is_pci(dev)) {
12506 - struct pci_dev *pdev = to_pci_dev(info->dev);
12507 -
12508 -- if (!pci_ats_disabled() &&
12509 -+ if (!pdev->untrusted &&
12510 -+ !pci_ats_disabled() &&
12511 - ecap_dev_iotlb_support(iommu->ecap) &&
12512 - pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS) &&
12513 - dmar_find_matched_atsr_unit(pdev))
12514 -diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
12515 -index cec29bf45c9b..18a8330e1882 100644
12516 ---- a/drivers/iommu/io-pgtable-arm-v7s.c
12517 -+++ b/drivers/iommu/io-pgtable-arm-v7s.c
12518 -@@ -161,6 +161,14 @@
12519 -
12520 - #define ARM_V7S_TCR_PD1 BIT(5)
12521 -
12522 -+#ifdef CONFIG_ZONE_DMA32
12523 -+#define ARM_V7S_TABLE_GFP_DMA GFP_DMA32
12524 -+#define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA32
12525 -+#else
12526 -+#define ARM_V7S_TABLE_GFP_DMA GFP_DMA
12527 -+#define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA
12528 -+#endif
12529 -+
12530 - typedef u32 arm_v7s_iopte;
12531 -
12532 - static bool selftest_running;
12533 -@@ -198,13 +206,16 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp,
12534 - void *table = NULL;
12535 -
12536 - if (lvl == 1)
12537 -- table = (void *)__get_dma_pages(__GFP_ZERO, get_order(size));
12538 -+ table = (void *)__get_free_pages(
12539 -+ __GFP_ZERO | ARM_V7S_TABLE_GFP_DMA, get_order(size));
12540 - else if (lvl == 2)
12541 -- table = kmem_cache_zalloc(data->l2_tables, gfp | GFP_DMA);
12542 -+ table = kmem_cache_zalloc(data->l2_tables, gfp);
12543 - phys = virt_to_phys(table);
12544 -- if (phys != (arm_v7s_iopte)phys)
12545 -+ if (phys != (arm_v7s_iopte)phys) {
12546 - /* Doesn't fit in PTE */
12547 -+ dev_err(dev, "Page table does not fit in PTE: %pa", &phys);
12548 - goto out_free;
12549 -+ }
12550 - if (table && !(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)) {
12551 - dma = dma_map_single(dev, table, size, DMA_TO_DEVICE);
12552 - if (dma_mapping_error(dev, dma))
12553 -@@ -217,7 +228,8 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp,
12554 - if (dma != phys)
12555 - goto out_unmap;
12556 - }
12557 -- kmemleak_ignore(table);
12558 -+ if (lvl == 2)
12559 -+ kmemleak_ignore(table);
12560 - return table;
12561 -
12562 - out_unmap:
12563 -@@ -733,7 +745,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
12564 - data->l2_tables = kmem_cache_create("io-pgtable_armv7s_l2",
12565 - ARM_V7S_TABLE_SIZE(2),
12566 - ARM_V7S_TABLE_SIZE(2),
12567 -- SLAB_CACHE_DMA, NULL);
12568 -+ ARM_V7S_TABLE_SLAB_FLAGS, NULL);
12569 - if (!data->l2_tables)
12570 - goto out_free_data;
12571 -
12572 -diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
12573 -index f8d3ba247523..2de8122e218f 100644
12574 ---- a/drivers/iommu/iova.c
12575 -+++ b/drivers/iommu/iova.c
12576 -@@ -207,8 +207,10 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
12577 - curr_iova = rb_entry(curr, struct iova, node);
12578 - } while (curr && new_pfn <= curr_iova->pfn_hi);
12579 -
12580 -- if (limit_pfn < size || new_pfn < iovad->start_pfn)
12581 -+ if (limit_pfn < size || new_pfn < iovad->start_pfn) {
12582 -+ iovad->max32_alloc_size = size;
12583 - goto iova32_full;
12584 -+ }
12585 -
12586 - /* pfn_lo will point to size aligned address if size_aligned is set */
12587 - new->pfn_lo = new_pfn;
12588 -@@ -222,7 +224,6 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
12589 - return 0;
12590 -
12591 - iova32_full:
12592 -- iovad->max32_alloc_size = size;
12593 - spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
12594 - return -ENOMEM;
12595 - }
12596 -diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
12597 -index 0e65f609352e..83364fedbf0a 100644
12598 ---- a/drivers/irqchip/irq-brcmstb-l2.c
12599 -+++ b/drivers/irqchip/irq-brcmstb-l2.c
12600 -@@ -129,8 +129,9 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
12601 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
12602 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
12603 - struct brcmstb_l2_intc_data *b = gc->private;
12604 -+ unsigned long flags;
12605 -
12606 -- irq_gc_lock(gc);
12607 -+ irq_gc_lock_irqsave(gc, flags);
12608 - /* Save the current mask */
12609 - b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
12610 -
12611 -@@ -139,7 +140,7 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
12612 - irq_reg_writel(gc, ~gc->wake_active, ct->regs.disable);
12613 - irq_reg_writel(gc, gc->wake_active, ct->regs.enable);
12614 - }
12615 -- irq_gc_unlock(gc);
12616 -+ irq_gc_unlock_irqrestore(gc, flags);
12617 - }
12618 -
12619 - static void brcmstb_l2_intc_resume(struct irq_data *d)
12620 -@@ -147,8 +148,9 @@ static void brcmstb_l2_intc_resume(struct irq_data *d)
12621 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
12622 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
12623 - struct brcmstb_l2_intc_data *b = gc->private;
12624 -+ unsigned long flags;
12625 -
12626 -- irq_gc_lock(gc);
12627 -+ irq_gc_lock_irqsave(gc, flags);
12628 - if (ct->chip.irq_ack) {
12629 - /* Clear unmasked non-wakeup interrupts */
12630 - irq_reg_writel(gc, ~b->saved_mask & ~gc->wake_active,
12631 -@@ -158,7 +160,7 @@ static void brcmstb_l2_intc_resume(struct irq_data *d)
12632 - /* Restore the saved mask */
12633 - irq_reg_writel(gc, b->saved_mask, ct->regs.disable);
12634 - irq_reg_writel(gc, ~b->saved_mask, ct->regs.enable);
12635 -- irq_gc_unlock(gc);
12636 -+ irq_gc_unlock_irqrestore(gc, flags);
12637 - }
12638 -
12639 - static int __init brcmstb_l2_intc_of_init(struct device_node *np,
12640 -diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
12641 -index c3aba3fc818d..93e32a59640c 100644
12642 ---- a/drivers/irqchip/irq-gic-v3-its.c
12643 -+++ b/drivers/irqchip/irq-gic-v3-its.c
12644 -@@ -1482,7 +1482,7 @@ static int lpi_range_cmp(void *priv, struct list_head *a, struct list_head *b)
12645 - ra = container_of(a, struct lpi_range, entry);
12646 - rb = container_of(b, struct lpi_range, entry);
12647 -
12648 -- return rb->base_id - ra->base_id;
12649 -+ return ra->base_id - rb->base_id;
12650 - }
12651 -
12652 - static void merge_lpi_ranges(void)
12653 -@@ -1955,6 +1955,8 @@ static int its_alloc_tables(struct its_node *its)
12654 - indirect = its_parse_indirect_baser(its, baser,
12655 - psz, &order,
12656 - its->device_ids);
12657 -+ break;
12658 -+
12659 - case GITS_BASER_TYPE_VCPU:
12660 - indirect = its_parse_indirect_baser(its, baser,
12661 - psz, &order,
12662 -diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
12663 -index 4d85645c87f7..0928fd1f0e0c 100644
12664 ---- a/drivers/isdn/hardware/mISDN/hfcmulti.c
12665 -+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
12666 -@@ -4365,7 +4365,8 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
12667 - if (m->clock2)
12668 - test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);
12669 -
12670 -- if (ent->device == 0xB410) {
12671 -+ if (ent->vendor == PCI_VENDOR_ID_DIGIUM &&
12672 -+ ent->device == PCI_DEVICE_ID_DIGIUM_HFC4S) {
12673 - test_and_set_bit(HFC_CHIP_B410P, &hc->chip);
12674 - test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip);
12675 - test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
12676 -diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
12677 -index 3d79a6380761..723f2f17497a 100644
12678 ---- a/drivers/leds/leds-lp55xx-common.c
12679 -+++ b/drivers/leds/leds-lp55xx-common.c
12680 -@@ -201,7 +201,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
12681 -
12682 - if (!fw) {
12683 - dev_err(dev, "firmware request failed\n");
12684 -- goto out;
12685 -+ return;
12686 - }
12687 -
12688 - /* handling firmware data is chip dependent */
12689 -@@ -214,9 +214,9 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
12690 -
12691 - mutex_unlock(&chip->lock);
12692 -
12693 --out:
12694 - /* firmware should be released for other channel use */
12695 - release_firmware(chip->fw);
12696 -+ chip->fw = NULL;
12697 - }
12698 -
12699 - static int lp55xx_request_firmware(struct lp55xx_chip *chip)
12700 -diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
12701 -index 956004366699..886710043025 100644
12702 ---- a/drivers/md/bcache/extents.c
12703 -+++ b/drivers/md/bcache/extents.c
12704 -@@ -538,6 +538,7 @@ static bool bch_extent_bad(struct btree_keys *bk, const struct bkey *k)
12705 - {
12706 - struct btree *b = container_of(bk, struct btree, keys);
12707 - unsigned int i, stale;
12708 -+ char buf[80];
12709 -
12710 - if (!KEY_PTRS(k) ||
12711 - bch_extent_invalid(bk, k))
12712 -@@ -547,19 +548,19 @@ static bool bch_extent_bad(struct btree_keys *bk, const struct bkey *k)
12713 - if (!ptr_available(b->c, k, i))
12714 - return true;
12715 -
12716 -- if (!expensive_debug_checks(b->c) && KEY_DIRTY(k))
12717 -- return false;
12718 --
12719 - for (i = 0; i < KEY_PTRS(k); i++) {
12720 - stale = ptr_stale(b->c, k, i);
12721 -
12722 -+ if (stale && KEY_DIRTY(k)) {
12723 -+ bch_extent_to_text(buf, sizeof(buf), k);
12724 -+ pr_info("stale dirty pointer, stale %u, key: %s",
12725 -+ stale, buf);
12726 -+ }
12727 -+
12728 - btree_bug_on(stale > BUCKET_GC_GEN_MAX, b,
12729 - "key too stale: %i, need_gc %u",
12730 - stale, b->c->need_gc);
12731 -
12732 -- btree_bug_on(stale && KEY_DIRTY(k) && KEY_SIZE(k),
12733 -- b, "stale dirty pointer");
12734 --
12735 - if (stale)
12736 - return true;
12737 -
12738 -diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
12739 -index 15070412a32e..f101bfe8657a 100644
12740 ---- a/drivers/md/bcache/request.c
12741 -+++ b/drivers/md/bcache/request.c
12742 -@@ -392,10 +392,11 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
12743 -
12744 - /*
12745 - * Flag for bypass if the IO is for read-ahead or background,
12746 -- * unless the read-ahead request is for metadata (eg, for gfs2).
12747 -+ * unless the read-ahead request is for metadata
12748 -+ * (eg, for gfs2 or xfs).
12749 - */
12750 - if (bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND) &&
12751 -- !(bio->bi_opf & REQ_PRIO))
12752 -+ !(bio->bi_opf & (REQ_META|REQ_PRIO)))
12753 - goto skip;
12754 -
12755 - if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) ||
12756 -@@ -877,7 +878,7 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
12757 - }
12758 -
12759 - if (!(bio->bi_opf & REQ_RAHEAD) &&
12760 -- !(bio->bi_opf & REQ_PRIO) &&
12761 -+ !(bio->bi_opf & (REQ_META|REQ_PRIO)) &&
12762 - s->iop.c->gc_stats.in_use < CUTOFF_CACHE_READA)
12763 - reada = min_t(sector_t, dc->readahead >> 9,
12764 - get_capacity(bio->bi_disk) - bio_end_sector(bio));
12765 -diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
12766 -index 557a8a3270a1..e5daf91310f6 100644
12767 ---- a/drivers/md/bcache/sysfs.c
12768 -+++ b/drivers/md/bcache/sysfs.c
12769 -@@ -287,8 +287,12 @@ STORE(__cached_dev)
12770 - sysfs_strtoul_clamp(writeback_rate_update_seconds,
12771 - dc->writeback_rate_update_seconds,
12772 - 1, WRITEBACK_RATE_UPDATE_SECS_MAX);
12773 -- d_strtoul(writeback_rate_i_term_inverse);
12774 -- d_strtoul_nonzero(writeback_rate_p_term_inverse);
12775 -+ sysfs_strtoul_clamp(writeback_rate_i_term_inverse,
12776 -+ dc->writeback_rate_i_term_inverse,
12777 -+ 1, UINT_MAX);
12778 -+ sysfs_strtoul_clamp(writeback_rate_p_term_inverse,
12779 -+ dc->writeback_rate_p_term_inverse,
12780 -+ 1, UINT_MAX);
12781 - d_strtoul_nonzero(writeback_rate_minimum);
12782 -
12783 - sysfs_strtoul_clamp(io_error_limit, dc->error_limit, 0, INT_MAX);
12784 -@@ -299,7 +303,9 @@ STORE(__cached_dev)
12785 - dc->io_disable = v ? 1 : 0;
12786 - }
12787 -
12788 -- d_strtoi_h(sequential_cutoff);
12789 -+ sysfs_strtoul_clamp(sequential_cutoff,
12790 -+ dc->sequential_cutoff,
12791 -+ 0, UINT_MAX);
12792 - d_strtoi_h(readahead);
12793 -
12794 - if (attr == &sysfs_clear_stats)
12795 -@@ -778,8 +784,17 @@ STORE(__bch_cache_set)
12796 - c->error_limit = strtoul_or_return(buf);
12797 -
12798 - /* See count_io_errors() for why 88 */
12799 -- if (attr == &sysfs_io_error_halflife)
12800 -- c->error_decay = strtoul_or_return(buf) / 88;
12801 -+ if (attr == &sysfs_io_error_halflife) {
12802 -+ unsigned long v = 0;
12803 -+ ssize_t ret;
12804 -+
12805 -+ ret = strtoul_safe_clamp(buf, v, 0, UINT_MAX);
12806 -+ if (!ret) {
12807 -+ c->error_decay = v / 88;
12808 -+ return size;
12809 -+ }
12810 -+ return ret;
12811 -+ }
12812 -
12813 - if (attr == &sysfs_io_disable) {
12814 - v = strtoul_or_return(buf);
12815 -diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h
12816 -index 3fe82425859c..0ad2715a884e 100644
12817 ---- a/drivers/md/bcache/sysfs.h
12818 -+++ b/drivers/md/bcache/sysfs.h
12819 -@@ -81,9 +81,16 @@ do { \
12820 -
12821 - #define sysfs_strtoul_clamp(file, var, min, max) \
12822 - do { \
12823 -- if (attr == &sysfs_ ## file) \
12824 -- return strtoul_safe_clamp(buf, var, min, max) \
12825 -- ?: (ssize_t) size; \
12826 -+ if (attr == &sysfs_ ## file) { \
12827 -+ unsigned long v = 0; \
12828 -+ ssize_t ret; \
12829 -+ ret = strtoul_safe_clamp(buf, v, min, max); \
12830 -+ if (!ret) { \
12831 -+ var = v; \
12832 -+ return size; \
12833 -+ } \
12834 -+ return ret; \
12835 -+ } \
12836 - } while (0)
12837 -
12838 - #define strtoul_or_return(cp) \
12839 -diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h
12840 -index 6a743d3bb338..4e4c6810dc3c 100644
12841 ---- a/drivers/md/bcache/writeback.h
12842 -+++ b/drivers/md/bcache/writeback.h
12843 -@@ -71,6 +71,9 @@ static inline bool should_writeback(struct cached_dev *dc, struct bio *bio,
12844 - in_use > bch_cutoff_writeback_sync)
12845 - return false;
12846 -
12847 -+ if (bio_op(bio) == REQ_OP_DISCARD)
12848 -+ return false;
12849 -+
12850 - if (dc->partial_stripes_expensive &&
12851 - bcache_dev_stripe_dirty(dc, bio->bi_iter.bi_sector,
12852 - bio_sectors(bio)))
12853 -diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
12854 -index 95c6d86ab5e8..c4ef1fceead6 100644
12855 ---- a/drivers/md/dm-core.h
12856 -+++ b/drivers/md/dm-core.h
12857 -@@ -115,6 +115,7 @@ struct mapped_device {
12858 - struct srcu_struct io_barrier;
12859 - };
12860 -
12861 -+void disable_discard(struct mapped_device *md);
12862 - void disable_write_same(struct mapped_device *md);
12863 - void disable_write_zeroes(struct mapped_device *md);
12864 -
12865 -diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
12866 -index 457200ca6287..f535fd8ac82d 100644
12867 ---- a/drivers/md/dm-integrity.c
12868 -+++ b/drivers/md/dm-integrity.c
12869 -@@ -913,7 +913,7 @@ static void copy_from_journal(struct dm_integrity_c *ic, unsigned section, unsig
12870 - static bool ranges_overlap(struct dm_integrity_range *range1, struct dm_integrity_range *range2)
12871 - {
12872 - return range1->logical_sector < range2->logical_sector + range2->n_sectors &&
12873 -- range2->logical_sector + range2->n_sectors > range2->logical_sector;
12874 -+ range1->logical_sector + range1->n_sectors > range2->logical_sector;
12875 - }
12876 -
12877 - static bool add_new_range(struct dm_integrity_c *ic, struct dm_integrity_range *new_range, bool check_waiting)
12878 -@@ -959,8 +959,6 @@ static void remove_range_unlocked(struct dm_integrity_c *ic, struct dm_integrity
12879 - struct dm_integrity_range *last_range =
12880 - list_first_entry(&ic->wait_list, struct dm_integrity_range, wait_entry);
12881 - struct task_struct *last_range_task;
12882 -- if (!ranges_overlap(range, last_range))
12883 -- break;
12884 - last_range_task = last_range->task;
12885 - list_del(&last_range->wait_entry);
12886 - if (!add_new_range(ic, last_range, false)) {
12887 -@@ -1368,8 +1366,8 @@ again:
12888 - checksums_ptr - checksums, !dio->write ? TAG_CMP : TAG_WRITE);
12889 - if (unlikely(r)) {
12890 - if (r > 0) {
12891 -- DMERR("Checksum failed at sector 0x%llx",
12892 -- (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size)));
12893 -+ DMERR_LIMIT("Checksum failed at sector 0x%llx",
12894 -+ (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size)));
12895 - r = -EILSEQ;
12896 - atomic64_inc(&ic->number_of_mismatches);
12897 - }
12898 -@@ -1561,8 +1559,8 @@ retry_kmap:
12899 -
12900 - integrity_sector_checksum(ic, logical_sector, mem + bv.bv_offset, checksums_onstack);
12901 - if (unlikely(memcmp(checksums_onstack, journal_entry_tag(ic, je), ic->tag_size))) {
12902 -- DMERR("Checksum failed when reading from journal, at sector 0x%llx",
12903 -- (unsigned long long)logical_sector);
12904 -+ DMERR_LIMIT("Checksum failed when reading from journal, at sector 0x%llx",
12905 -+ (unsigned long long)logical_sector);
12906 - }
12907 - }
12908 - #endif
12909 -@@ -3185,7 +3183,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
12910 - journal_watermark = val;
12911 - else if (sscanf(opt_string, "commit_time:%u%c", &val, &dummy) == 1)
12912 - sync_msec = val;
12913 -- else if (!memcmp(opt_string, "meta_device:", strlen("meta_device:"))) {
12914 -+ else if (!strncmp(opt_string, "meta_device:", strlen("meta_device:"))) {
12915 - if (ic->meta_dev) {
12916 - dm_put_device(ti, ic->meta_dev);
12917 - ic->meta_dev = NULL;
12918 -@@ -3204,17 +3202,17 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
12919 - goto bad;
12920 - }
12921 - ic->sectors_per_block = val >> SECTOR_SHIFT;
12922 -- } else if (!memcmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
12923 -+ } else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
12924 - r = get_alg_and_key(opt_string, &ic->internal_hash_alg, &ti->error,
12925 - "Invalid internal_hash argument");
12926 - if (r)
12927 - goto bad;
12928 -- } else if (!memcmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
12929 -+ } else if (!strncmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
12930 - r = get_alg_and_key(opt_string, &ic->journal_crypt_alg, &ti->error,
12931 - "Invalid journal_crypt argument");
12932 - if (r)
12933 - goto bad;
12934 -- } else if (!memcmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
12935 -+ } else if (!strncmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
12936 - r = get_alg_and_key(opt_string, &ic->journal_mac_alg, &ti->error,
12937 - "Invalid journal_mac argument");
12938 - if (r)
12939 -diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
12940 -index a20531e5f3b4..582265e043a6 100644
12941 ---- a/drivers/md/dm-rq.c
12942 -+++ b/drivers/md/dm-rq.c
12943 -@@ -206,11 +206,14 @@ static void dm_done(struct request *clone, blk_status_t error, bool mapped)
12944 - }
12945 -
12946 - if (unlikely(error == BLK_STS_TARGET)) {
12947 -- if (req_op(clone) == REQ_OP_WRITE_SAME &&
12948 -- !clone->q->limits.max_write_same_sectors)
12949 -+ if (req_op(clone) == REQ_OP_DISCARD &&
12950 -+ !clone->q->limits.max_discard_sectors)
12951 -+ disable_discard(tio->md);
12952 -+ else if (req_op(clone) == REQ_OP_WRITE_SAME &&
12953 -+ !clone->q->limits.max_write_same_sectors)
12954 - disable_write_same(tio->md);
12955 -- if (req_op(clone) == REQ_OP_WRITE_ZEROES &&
12956 -- !clone->q->limits.max_write_zeroes_sectors)
12957 -+ else if (req_op(clone) == REQ_OP_WRITE_ZEROES &&
12958 -+ !clone->q->limits.max_write_zeroes_sectors)
12959 - disable_write_zeroes(tio->md);
12960 - }
12961 -
12962 -diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
12963 -index 4b1be754cc41..eb257e4dcb1c 100644
12964 ---- a/drivers/md/dm-table.c
12965 -+++ b/drivers/md/dm-table.c
12966 -@@ -1852,6 +1852,36 @@ static bool dm_table_supports_secure_erase(struct dm_table *t)
12967 - return true;
12968 - }
12969 -
12970 -+static int device_requires_stable_pages(struct dm_target *ti,
12971 -+ struct dm_dev *dev, sector_t start,
12972 -+ sector_t len, void *data)
12973 -+{
12974 -+ struct request_queue *q = bdev_get_queue(dev->bdev);
12975 -+
12976 -+ return q && bdi_cap_stable_pages_required(q->backing_dev_info);
12977 -+}
12978 -+
12979 -+/*
12980 -+ * If any underlying device requires stable pages, a table must require
12981 -+ * them as well. Only targets that support iterate_devices are considered:
12982 -+ * don't want error, zero, etc to require stable pages.
12983 -+ */
12984 -+static bool dm_table_requires_stable_pages(struct dm_table *t)
12985 -+{
12986 -+ struct dm_target *ti;
12987 -+ unsigned i;
12988 -+
12989 -+ for (i = 0; i < dm_table_get_num_targets(t); i++) {
12990 -+ ti = dm_table_get_target(t, i);
12991 -+
12992 -+ if (ti->type->iterate_devices &&
12993 -+ ti->type->iterate_devices(ti, device_requires_stable_pages, NULL))
12994 -+ return true;
12995 -+ }
12996 -+
12997 -+ return false;
12998 -+}
12999 -+
13000 - void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
13001 - struct queue_limits *limits)
13002 - {
13003 -@@ -1909,6 +1939,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
13004 -
13005 - dm_table_verify_integrity(t);
13006 -
13007 -+ /*
13008 -+ * Some devices don't use blk_integrity but still want stable pages
13009 -+ * because they do their own checksumming.
13010 -+ */
13011 -+ if (dm_table_requires_stable_pages(t))
13012 -+ q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES;
13013 -+ else
13014 -+ q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES;
13015 -+
13016 - /*
13017 - * Determine whether or not this queue's I/O timings contribute
13018 - * to the entropy pool, Only request-based targets use this.
13019 -diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
13020 -index e83b63608262..254c26eb963a 100644
13021 ---- a/drivers/md/dm-thin.c
13022 -+++ b/drivers/md/dm-thin.c
13023 -@@ -3283,6 +3283,13 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
13024 - as.argc = argc;
13025 - as.argv = argv;
13026 -
13027 -+ /* make sure metadata and data are different devices */
13028 -+ if (!strcmp(argv[0], argv[1])) {
13029 -+ ti->error = "Error setting metadata or data device";
13030 -+ r = -EINVAL;
13031 -+ goto out_unlock;
13032 -+ }
13033 -+
13034 - /*
13035 - * Set default pool features.
13036 - */
13037 -@@ -4167,6 +4174,12 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
13038 - tc->sort_bio_list = RB_ROOT;
13039 -
13040 - if (argc == 3) {
13041 -+ if (!strcmp(argv[0], argv[2])) {
13042 -+ ti->error = "Error setting origin device";
13043 -+ r = -EINVAL;
13044 -+ goto bad_origin_dev;
13045 -+ }
13046 -+
13047 - r = dm_get_device(ti, argv[2], FMODE_READ, &origin_dev);
13048 - if (r) {
13049 - ti->error = "Error opening origin device";
13050 -diff --git a/drivers/md/dm.c b/drivers/md/dm.c
13051 -index 515e6af9bed2..4986eea520b6 100644
13052 ---- a/drivers/md/dm.c
13053 -+++ b/drivers/md/dm.c
13054 -@@ -963,6 +963,15 @@ static void dec_pending(struct dm_io *io, blk_status_t error)
13055 - }
13056 - }
13057 -
13058 -+void disable_discard(struct mapped_device *md)
13059 -+{
13060 -+ struct queue_limits *limits = dm_get_queue_limits(md);
13061 -+
13062 -+ /* device doesn't really support DISCARD, disable it */
13063 -+ limits->max_discard_sectors = 0;
13064 -+ blk_queue_flag_clear(QUEUE_FLAG_DISCARD, md->queue);
13065 -+}
13066 -+
13067 - void disable_write_same(struct mapped_device *md)
13068 - {
13069 - struct queue_limits *limits = dm_get_queue_limits(md);
13070 -@@ -988,11 +997,14 @@ static void clone_endio(struct bio *bio)
13071 - dm_endio_fn endio = tio->ti->type->end_io;
13072 -
13073 - if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) {
13074 -- if (bio_op(bio) == REQ_OP_WRITE_SAME &&
13075 -- !bio->bi_disk->queue->limits.max_write_same_sectors)
13076 -+ if (bio_op(bio) == REQ_OP_DISCARD &&
13077 -+ !bio->bi_disk->queue->limits.max_discard_sectors)
13078 -+ disable_discard(md);
13079 -+ else if (bio_op(bio) == REQ_OP_WRITE_SAME &&
13080 -+ !bio->bi_disk->queue->limits.max_write_same_sectors)
13081 - disable_write_same(md);
13082 -- if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
13083 -- !bio->bi_disk->queue->limits.max_write_zeroes_sectors)
13084 -+ else if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
13085 -+ !bio->bi_disk->queue->limits.max_write_zeroes_sectors)
13086 - disable_write_zeroes(md);
13087 - }
13088 -
13089 -@@ -1060,15 +1072,7 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
13090 - return -EINVAL;
13091 - }
13092 -
13093 -- /*
13094 -- * BIO based queue uses its own splitting. When multipage bvecs
13095 -- * is switched on, size of the incoming bio may be too big to
13096 -- * be handled in some targets, such as crypt.
13097 -- *
13098 -- * When these targets are ready for the big bio, we can remove
13099 -- * the limit.
13100 -- */
13101 -- ti->max_io_len = min_t(uint32_t, len, BIO_MAX_PAGES * PAGE_SIZE);
13102 -+ ti->max_io_len = (uint32_t) len;
13103 -
13104 - return 0;
13105 - }
13106 -diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
13107 -index abb5d382f64d..3b6880dd648d 100644
13108 ---- a/drivers/md/raid10.c
13109 -+++ b/drivers/md/raid10.c
13110 -@@ -3939,6 +3939,8 @@ static int raid10_run(struct mddev *mddev)
13111 - set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
13112 - mddev->sync_thread = md_register_thread(md_do_sync, mddev,
13113 - "reshape");
13114 -+ if (!mddev->sync_thread)
13115 -+ goto out_free_conf;
13116 - }
13117 -
13118 - return 0;
13119 -@@ -4670,7 +4672,6 @@ read_more:
13120 - atomic_inc(&r10_bio->remaining);
13121 - read_bio->bi_next = NULL;
13122 - generic_make_request(read_bio);
13123 -- sector_nr += nr_sectors;
13124 - sectors_done += nr_sectors;
13125 - if (sector_nr <= last)
13126 - goto read_more;
13127 -diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
13128 -index cecea901ab8c..5b68f2d0da60 100644
13129 ---- a/drivers/md/raid5.c
13130 -+++ b/drivers/md/raid5.c
13131 -@@ -7402,6 +7402,8 @@ static int raid5_run(struct mddev *mddev)
13132 - set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
13133 - mddev->sync_thread = md_register_thread(md_do_sync, mddev,
13134 - "reshape");
13135 -+ if (!mddev->sync_thread)
13136 -+ goto abort;
13137 - }
13138 -
13139 - /* Ok, everything is just fine now */
13140 -diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
13141 -index 96807e134886..8abb1a510a81 100644
13142 ---- a/drivers/media/dvb-frontends/lgdt330x.c
13143 -+++ b/drivers/media/dvb-frontends/lgdt330x.c
13144 -@@ -783,7 +783,7 @@ static int lgdt3303_read_status(struct dvb_frontend *fe,
13145 -
13146 - if ((buf[0] & 0x02) == 0x00)
13147 - *status |= FE_HAS_SYNC;
13148 -- if ((buf[0] & 0xfd) == 0x01)
13149 -+ if ((buf[0] & 0x01) == 0x01)
13150 - *status |= FE_HAS_VITERBI | FE_HAS_LOCK;
13151 - break;
13152 - default:
13153 -diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
13154 -index b168bf3635b6..8b0b8b5aa531 100644
13155 ---- a/drivers/media/i2c/cx25840/cx25840-core.c
13156 -+++ b/drivers/media/i2c/cx25840/cx25840-core.c
13157 -@@ -5216,8 +5216,9 @@ static int cx25840_probe(struct i2c_client *client,
13158 - * those extra inputs. So, let's add it only when needed.
13159 - */
13160 - state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
13161 -+ state->pads[CX25840_PAD_INPUT].sig_type = PAD_SIGNAL_ANALOG;
13162 - state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
13163 -- state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
13164 -+ state->pads[CX25840_PAD_VID_OUT].sig_type = PAD_SIGNAL_DV;
13165 - sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
13166 -
13167 - ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
13168 -diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h
13169 -index c323b1af1f83..9efefa15d090 100644
13170 ---- a/drivers/media/i2c/cx25840/cx25840-core.h
13171 -+++ b/drivers/media/i2c/cx25840/cx25840-core.h
13172 -@@ -40,7 +40,6 @@ enum cx25840_model {
13173 - enum cx25840_media_pads {
13174 - CX25840_PAD_INPUT,
13175 - CX25840_PAD_VID_OUT,
13176 -- CX25840_PAD_VBI_OUT,
13177 -
13178 - CX25840_NUM_PADS
13179 - };
13180 -diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
13181 -index d639b9bcf64a..7a759b4b88cf 100644
13182 ---- a/drivers/media/i2c/mt9m111.c
13183 -+++ b/drivers/media/i2c/mt9m111.c
13184 -@@ -1273,6 +1273,8 @@ static int mt9m111_probe(struct i2c_client *client,
13185 - mt9m111->rect.top = MT9M111_MIN_DARK_ROWS;
13186 - mt9m111->rect.width = MT9M111_MAX_WIDTH;
13187 - mt9m111->rect.height = MT9M111_MAX_HEIGHT;
13188 -+ mt9m111->width = mt9m111->rect.width;
13189 -+ mt9m111->height = mt9m111->rect.height;
13190 - mt9m111->fmt = &mt9m111_colour_fmts[0];
13191 - mt9m111->lastpage = -1;
13192 - mutex_init(&mt9m111->power_lock);
13193 -diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
13194 -index bef3f3aae0ed..9f8fc1ad9b1a 100644
13195 ---- a/drivers/media/i2c/ov5640.c
13196 -+++ b/drivers/media/i2c/ov5640.c
13197 -@@ -1893,7 +1893,7 @@ static void ov5640_reset(struct ov5640_dev *sensor)
13198 - usleep_range(1000, 2000);
13199 -
13200 - gpiod_set_value_cansleep(sensor->reset_gpio, 0);
13201 -- usleep_range(5000, 10000);
13202 -+ usleep_range(20000, 25000);
13203 - }
13204 -
13205 - static int ov5640_set_power_on(struct ov5640_dev *sensor)
13206 -diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
13207 -index 177688afd9a6..8835b831cdc0 100644
13208 ---- a/drivers/media/i2c/ov7740.c
13209 -+++ b/drivers/media/i2c/ov7740.c
13210 -@@ -1101,6 +1101,9 @@ static int ov7740_probe(struct i2c_client *client,
13211 - if (ret)
13212 - return ret;
13213 -
13214 -+ pm_runtime_set_active(&client->dev);
13215 -+ pm_runtime_enable(&client->dev);
13216 -+
13217 - ret = ov7740_detect(ov7740);
13218 - if (ret)
13219 - goto error_detect;
13220 -@@ -1123,8 +1126,6 @@ static int ov7740_probe(struct i2c_client *client,
13221 - if (ret)
13222 - goto error_async_register;
13223 -
13224 -- pm_runtime_set_active(&client->dev);
13225 -- pm_runtime_enable(&client->dev);
13226 - pm_runtime_idle(&client->dev);
13227 -
13228 - return 0;
13229 -@@ -1134,6 +1135,8 @@ error_async_register:
13230 - error_init_controls:
13231 - ov7740_free_controls(ov7740);
13232 - error_detect:
13233 -+ pm_runtime_disable(&client->dev);
13234 -+ pm_runtime_set_suspended(&client->dev);
13235 - ov7740_set_power(ov7740, 0);
13236 - media_entity_cleanup(&ov7740->subdev.entity);
13237 -
13238 -diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
13239 -index 2a5d5002c27e..f761e4d8bf2a 100644
13240 ---- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
13241 -+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
13242 -@@ -702,7 +702,7 @@ end:
13243 - v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, to_vb2_v4l2_buffer(vb));
13244 - }
13245 -
13246 --static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx,
13247 -+static struct vb2_v4l2_buffer *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx,
13248 - enum v4l2_buf_type type)
13249 - {
13250 - if (V4L2_TYPE_IS_OUTPUT(type))
13251 -@@ -714,7 +714,7 @@ static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx,
13252 - static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
13253 - {
13254 - struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q);
13255 -- struct vb2_buffer *vb;
13256 -+ struct vb2_v4l2_buffer *vb;
13257 - int ret = 0;
13258 -
13259 - ret = pm_runtime_get_sync(ctx->jpeg->dev);
13260 -@@ -724,14 +724,14 @@ static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
13261 - return 0;
13262 - err:
13263 - while ((vb = mtk_jpeg_buf_remove(ctx, q->type)))
13264 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_QUEUED);
13265 -+ v4l2_m2m_buf_done(vb, VB2_BUF_STATE_QUEUED);
13266 - return ret;
13267 - }
13268 -
13269 - static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
13270 - {
13271 - struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q);
13272 -- struct vb2_buffer *vb;
13273 -+ struct vb2_v4l2_buffer *vb;
13274 -
13275 - /*
13276 - * STREAMOFF is an acknowledgment for source change event.
13277 -@@ -743,7 +743,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
13278 - struct mtk_jpeg_src_buf *src_buf;
13279 -
13280 - vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13281 -- src_buf = mtk_jpeg_vb2_to_srcbuf(vb);
13282 -+ src_buf = mtk_jpeg_vb2_to_srcbuf(&vb->vb2_buf);
13283 - mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param);
13284 - ctx->state = MTK_JPEG_RUNNING;
13285 - } else if (V4L2_TYPE_IS_OUTPUT(q->type)) {
13286 -@@ -751,7 +751,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
13287 - }
13288 -
13289 - while ((vb = mtk_jpeg_buf_remove(ctx, q->type)))
13290 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_ERROR);
13291 -+ v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
13292 -
13293 - pm_runtime_put_sync(ctx->jpeg->dev);
13294 - }
13295 -@@ -807,7 +807,7 @@ static void mtk_jpeg_device_run(void *priv)
13296 - {
13297 - struct mtk_jpeg_ctx *ctx = priv;
13298 - struct mtk_jpeg_dev *jpeg = ctx->jpeg;
13299 -- struct vb2_buffer *src_buf, *dst_buf;
13300 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
13301 - enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
13302 - unsigned long flags;
13303 - struct mtk_jpeg_src_buf *jpeg_src_buf;
13304 -@@ -817,11 +817,11 @@ static void mtk_jpeg_device_run(void *priv)
13305 -
13306 - src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13307 - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
13308 -- jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf);
13309 -+ jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf);
13310 -
13311 - if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) {
13312 -- for (i = 0; i < dst_buf->num_planes; i++)
13313 -- vb2_set_plane_payload(dst_buf, i, 0);
13314 -+ for (i = 0; i < dst_buf->vb2_buf.num_planes; i++)
13315 -+ vb2_set_plane_payload(&dst_buf->vb2_buf, i, 0);
13316 - buf_state = VB2_BUF_STATE_DONE;
13317 - goto dec_end;
13318 - }
13319 -@@ -833,8 +833,8 @@ static void mtk_jpeg_device_run(void *priv)
13320 - return;
13321 - }
13322 -
13323 -- mtk_jpeg_set_dec_src(ctx, src_buf, &bs);
13324 -- if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, dst_buf, &fb))
13325 -+ mtk_jpeg_set_dec_src(ctx, &src_buf->vb2_buf, &bs);
13326 -+ if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb))
13327 - goto dec_end;
13328 -
13329 - spin_lock_irqsave(&jpeg->hw_lock, flags);
13330 -@@ -849,8 +849,8 @@ static void mtk_jpeg_device_run(void *priv)
13331 - dec_end:
13332 - v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
13333 - v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
13334 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state);
13335 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state);
13336 -+ v4l2_m2m_buf_done(src_buf, buf_state);
13337 -+ v4l2_m2m_buf_done(dst_buf, buf_state);
13338 - v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
13339 - }
13340 -
13341 -@@ -921,7 +921,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
13342 - {
13343 - struct mtk_jpeg_dev *jpeg = priv;
13344 - struct mtk_jpeg_ctx *ctx;
13345 -- struct vb2_buffer *src_buf, *dst_buf;
13346 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
13347 - struct mtk_jpeg_src_buf *jpeg_src_buf;
13348 - enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
13349 - u32 dec_irq_ret;
13350 -@@ -938,7 +938,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
13351 -
13352 - src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
13353 - dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
13354 -- jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf);
13355 -+ jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf);
13356 -
13357 - if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW)
13358 - mtk_jpeg_dec_reset(jpeg->dec_reg_base);
13359 -@@ -948,15 +948,15 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
13360 - goto dec_end;
13361 - }
13362 -
13363 -- for (i = 0; i < dst_buf->num_planes; i++)
13364 -- vb2_set_plane_payload(dst_buf, i,
13365 -+ for (i = 0; i < dst_buf->vb2_buf.num_planes; i++)
13366 -+ vb2_set_plane_payload(&dst_buf->vb2_buf, i,
13367 - jpeg_src_buf->dec_param.comp_size[i]);
13368 -
13369 - buf_state = VB2_BUF_STATE_DONE;
13370 -
13371 - dec_end:
13372 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state);
13373 -- v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state);
13374 -+ v4l2_m2m_buf_done(src_buf, buf_state);
13375 -+ v4l2_m2m_buf_done(dst_buf, buf_state);
13376 - v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
13377 - return IRQ_HANDLED;
13378 - }
13379 -diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
13380 -index 27b078cf98e3..f60f499c596b 100644
13381 ---- a/drivers/media/platform/mx2_emmaprp.c
13382 -+++ b/drivers/media/platform/mx2_emmaprp.c
13383 -@@ -274,7 +274,7 @@ static void emmaprp_device_run(void *priv)
13384 - {
13385 - struct emmaprp_ctx *ctx = priv;
13386 - struct emmaprp_q_data *s_q_data, *d_q_data;
13387 -- struct vb2_buffer *src_buf, *dst_buf;
13388 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
13389 - struct emmaprp_dev *pcdev = ctx->dev;
13390 - unsigned int s_width, s_height;
13391 - unsigned int d_width, d_height;
13392 -@@ -294,8 +294,8 @@ static void emmaprp_device_run(void *priv)
13393 - d_height = d_q_data->height;
13394 - d_size = d_width * d_height;
13395 -
13396 -- p_in = vb2_dma_contig_plane_dma_addr(src_buf, 0);
13397 -- p_out = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
13398 -+ p_in = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
13399 -+ p_out = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
13400 - if (!p_in || !p_out) {
13401 - v4l2_err(&pcdev->v4l2_dev,
13402 - "Acquiring kernel pointers to buffers failed\n");
13403 -diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
13404 -index f0719ce24b97..aef8d8dab6ab 100644
13405 ---- a/drivers/media/platform/rcar-vin/rcar-core.c
13406 -+++ b/drivers/media/platform/rcar-vin/rcar-core.c
13407 -@@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags,
13408 - !is_media_entity_v4l2_video_device(link->sink->entity))
13409 - return 0;
13410 -
13411 -- /* If any entity is in use don't allow link changes. */
13412 -+ /*
13413 -+ * Don't allow link changes if any entity in the graph is
13414 -+ * streaming, modifying the CHSEL register fields can disrupt
13415 -+ * running streams.
13416 -+ */
13417 - media_device_for_each_entity(entity, &group->mdev)
13418 -- if (entity->use_count)
13419 -+ if (entity->stream_count)
13420 - return -EBUSY;
13421 -
13422 - mutex_lock(&group->lock);
13423 -diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
13424 -index 5c653287185f..b096227a9722 100644
13425 ---- a/drivers/media/platform/rockchip/rga/rga.c
13426 -+++ b/drivers/media/platform/rockchip/rga/rga.c
13427 -@@ -43,7 +43,7 @@ static void device_run(void *prv)
13428 - {
13429 - struct rga_ctx *ctx = prv;
13430 - struct rockchip_rga *rga = ctx->rga;
13431 -- struct vb2_buffer *src, *dst;
13432 -+ struct vb2_v4l2_buffer *src, *dst;
13433 - unsigned long flags;
13434 -
13435 - spin_lock_irqsave(&rga->ctrl_lock, flags);
13436 -@@ -53,8 +53,8 @@ static void device_run(void *prv)
13437 - src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13438 - dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
13439 -
13440 -- rga_buf_map(src);
13441 -- rga_buf_map(dst);
13442 -+ rga_buf_map(&src->vb2_buf);
13443 -+ rga_buf_map(&dst->vb2_buf);
13444 -
13445 - rga_hw_start(rga);
13446 -
13447 -diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
13448 -index 57ab1d1085d1..971c47165010 100644
13449 ---- a/drivers/media/platform/s5p-g2d/g2d.c
13450 -+++ b/drivers/media/platform/s5p-g2d/g2d.c
13451 -@@ -513,7 +513,7 @@ static void device_run(void *prv)
13452 - {
13453 - struct g2d_ctx *ctx = prv;
13454 - struct g2d_dev *dev = ctx->dev;
13455 -- struct vb2_buffer *src, *dst;
13456 -+ struct vb2_v4l2_buffer *src, *dst;
13457 - unsigned long flags;
13458 - u32 cmd = 0;
13459 -
13460 -@@ -528,10 +528,10 @@ static void device_run(void *prv)
13461 - spin_lock_irqsave(&dev->ctrl_lock, flags);
13462 -
13463 - g2d_set_src_size(dev, &ctx->in);
13464 -- g2d_set_src_addr(dev, vb2_dma_contig_plane_dma_addr(src, 0));
13465 -+ g2d_set_src_addr(dev, vb2_dma_contig_plane_dma_addr(&src->vb2_buf, 0));
13466 -
13467 - g2d_set_dst_size(dev, &ctx->out);
13468 -- g2d_set_dst_addr(dev, vb2_dma_contig_plane_dma_addr(dst, 0));
13469 -+ g2d_set_dst_addr(dev, vb2_dma_contig_plane_dma_addr(&dst->vb2_buf, 0));
13470 -
13471 - g2d_set_rop4(dev, ctx->rop);
13472 - g2d_set_flip(dev, ctx->flip);
13473 -diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
13474 -index 3f9000b70385..370942b67d86 100644
13475 ---- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
13476 -+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
13477 -@@ -793,14 +793,14 @@ static void skip(struct s5p_jpeg_buffer *buf, long len);
13478 - static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx)
13479 - {
13480 - struct s5p_jpeg *jpeg = ctx->jpeg;
13481 -- struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13482 -+ struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13483 - struct s5p_jpeg_buffer jpeg_buffer;
13484 - unsigned int word;
13485 - int c, x, components;
13486 -
13487 - jpeg_buffer.size = 2; /* Ls */
13488 - jpeg_buffer.data =
13489 -- (unsigned long)vb2_plane_vaddr(vb, 0) + ctx->out_q.sos + 2;
13490 -+ (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) + ctx->out_q.sos + 2;
13491 - jpeg_buffer.curr = 0;
13492 -
13493 - word = 0;
13494 -@@ -830,14 +830,14 @@ static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx)
13495 - static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx)
13496 - {
13497 - struct s5p_jpeg *jpeg = ctx->jpeg;
13498 -- struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13499 -+ struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13500 - struct s5p_jpeg_buffer jpeg_buffer;
13501 - unsigned int word;
13502 - int c, i, n, j;
13503 -
13504 - for (j = 0; j < ctx->out_q.dht.n; ++j) {
13505 - jpeg_buffer.size = ctx->out_q.dht.len[j];
13506 -- jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(vb, 0) +
13507 -+ jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) +
13508 - ctx->out_q.dht.marker[j];
13509 - jpeg_buffer.curr = 0;
13510 -
13511 -@@ -889,13 +889,13 @@ static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx)
13512 - static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
13513 - {
13514 - struct s5p_jpeg *jpeg = ctx->jpeg;
13515 -- struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13516 -+ struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13517 - struct s5p_jpeg_buffer jpeg_buffer;
13518 - int c, x, components;
13519 -
13520 - jpeg_buffer.size = ctx->out_q.sof_len;
13521 - jpeg_buffer.data =
13522 -- (unsigned long)vb2_plane_vaddr(vb, 0) + ctx->out_q.sof;
13523 -+ (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) + ctx->out_q.sof;
13524 - jpeg_buffer.curr = 0;
13525 -
13526 - skip(&jpeg_buffer, 5); /* P, Y, X */
13527 -@@ -920,14 +920,14 @@ static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
13528 - static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx)
13529 - {
13530 - struct s5p_jpeg *jpeg = ctx->jpeg;
13531 -- struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13532 -+ struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13533 - struct s5p_jpeg_buffer jpeg_buffer;
13534 - unsigned int word;
13535 - int c, i, j;
13536 -
13537 - for (j = 0; j < ctx->out_q.dqt.n; ++j) {
13538 - jpeg_buffer.size = ctx->out_q.dqt.len[j];
13539 -- jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(vb, 0) +
13540 -+ jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) +
13541 - ctx->out_q.dqt.marker[j];
13542 - jpeg_buffer.curr = 0;
13543 -
13544 -@@ -1293,13 +1293,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
13545 - return 0;
13546 - }
13547 -
13548 --static int enum_fmt(struct s5p_jpeg_fmt *sjpeg_formats, int n,
13549 -+static int enum_fmt(struct s5p_jpeg_ctx *ctx,
13550 -+ struct s5p_jpeg_fmt *sjpeg_formats, int n,
13551 - struct v4l2_fmtdesc *f, u32 type)
13552 - {
13553 - int i, num = 0;
13554 -+ unsigned int fmt_ver_flag = ctx->jpeg->variant->fmt_ver_flag;
13555 -
13556 - for (i = 0; i < n; ++i) {
13557 -- if (sjpeg_formats[i].flags & type) {
13558 -+ if (sjpeg_formats[i].flags & type &&
13559 -+ sjpeg_formats[i].flags & fmt_ver_flag) {
13560 - /* index-th format of type type found ? */
13561 - if (num == f->index)
13562 - break;
13563 -@@ -1326,11 +1329,11 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
13564 - struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
13565 -
13566 - if (ctx->mode == S5P_JPEG_ENCODE)
13567 -- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
13568 -+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
13569 - SJPEG_FMT_FLAG_ENC_CAPTURE);
13570 -
13571 -- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
13572 -- SJPEG_FMT_FLAG_DEC_CAPTURE);
13573 -+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
13574 -+ SJPEG_FMT_FLAG_DEC_CAPTURE);
13575 - }
13576 -
13577 - static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
13578 -@@ -1339,11 +1342,11 @@ static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
13579 - struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
13580 -
13581 - if (ctx->mode == S5P_JPEG_ENCODE)
13582 -- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
13583 -+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
13584 - SJPEG_FMT_FLAG_ENC_OUTPUT);
13585 -
13586 -- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
13587 -- SJPEG_FMT_FLAG_DEC_OUTPUT);
13588 -+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
13589 -+ SJPEG_FMT_FLAG_DEC_OUTPUT);
13590 - }
13591 -
13592 - static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
13593 -@@ -2072,15 +2075,15 @@ static void s5p_jpeg_device_run(void *priv)
13594 - {
13595 - struct s5p_jpeg_ctx *ctx = priv;
13596 - struct s5p_jpeg *jpeg = ctx->jpeg;
13597 -- struct vb2_buffer *src_buf, *dst_buf;
13598 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
13599 - unsigned long src_addr, dst_addr, flags;
13600 -
13601 - spin_lock_irqsave(&ctx->jpeg->slock, flags);
13602 -
13603 - src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13604 - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
13605 -- src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
13606 -- dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
13607 -+ src_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
13608 -+ dst_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
13609 -
13610 - s5p_jpeg_reset(jpeg->regs);
13611 - s5p_jpeg_poweron(jpeg->regs);
13612 -@@ -2153,7 +2156,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13613 - {
13614 - struct s5p_jpeg *jpeg = ctx->jpeg;
13615 - struct s5p_jpeg_fmt *fmt;
13616 -- struct vb2_buffer *vb;
13617 -+ struct vb2_v4l2_buffer *vb;
13618 - struct s5p_jpeg_addr jpeg_addr = {};
13619 - u32 pix_size, padding_bytes = 0;
13620 -
13621 -@@ -2172,7 +2175,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13622 - vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
13623 - }
13624 -
13625 -- jpeg_addr.y = vb2_dma_contig_plane_dma_addr(vb, 0);
13626 -+ jpeg_addr.y = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
13627 -
13628 - if (fmt->colplanes == 2) {
13629 - jpeg_addr.cb = jpeg_addr.y + pix_size - padding_bytes;
13630 -@@ -2190,7 +2193,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13631 - static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
13632 - {
13633 - struct s5p_jpeg *jpeg = ctx->jpeg;
13634 -- struct vb2_buffer *vb;
13635 -+ struct vb2_v4l2_buffer *vb;
13636 - unsigned int jpeg_addr = 0;
13637 -
13638 - if (ctx->mode == S5P_JPEG_ENCODE)
13639 -@@ -2198,7 +2201,7 @@ static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
13640 - else
13641 - vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13642 -
13643 -- jpeg_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
13644 -+ jpeg_addr = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
13645 - if (jpeg->variant->version == SJPEG_EXYNOS5433 &&
13646 - ctx->mode == S5P_JPEG_DECODE)
13647 - jpeg_addr += ctx->out_q.sos;
13648 -@@ -2314,7 +2317,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13649 - {
13650 - struct s5p_jpeg *jpeg = ctx->jpeg;
13651 - struct s5p_jpeg_fmt *fmt;
13652 -- struct vb2_buffer *vb;
13653 -+ struct vb2_v4l2_buffer *vb;
13654 - struct s5p_jpeg_addr jpeg_addr = {};
13655 - u32 pix_size;
13656 -
13657 -@@ -2328,7 +2331,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13658 - fmt = ctx->cap_q.fmt;
13659 - }
13660 -
13661 -- jpeg_addr.y = vb2_dma_contig_plane_dma_addr(vb, 0);
13662 -+ jpeg_addr.y = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
13663 -
13664 - if (fmt->colplanes == 2) {
13665 - jpeg_addr.cb = jpeg_addr.y + pix_size;
13666 -@@ -2346,7 +2349,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
13667 - static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
13668 - {
13669 - struct s5p_jpeg *jpeg = ctx->jpeg;
13670 -- struct vb2_buffer *vb;
13671 -+ struct vb2_v4l2_buffer *vb;
13672 - unsigned int jpeg_addr = 0;
13673 -
13674 - if (ctx->mode == S5P_JPEG_ENCODE)
13675 -@@ -2354,7 +2357,7 @@ static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
13676 - else
13677 - vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
13678 -
13679 -- jpeg_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
13680 -+ jpeg_addr = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
13681 - exynos3250_jpeg_jpgadr(jpeg->regs, jpeg_addr);
13682 - }
13683 -
13684 -diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
13685 -index 09ae64a0004c..d277cc674349 100644
13686 ---- a/drivers/media/platform/sh_veu.c
13687 -+++ b/drivers/media/platform/sh_veu.c
13688 -@@ -273,13 +273,13 @@ static void sh_veu_process(struct sh_veu_dev *veu,
13689 - static void sh_veu_device_run(void *priv)
13690 - {
13691 - struct sh_veu_dev *veu = priv;
13692 -- struct vb2_buffer *src_buf, *dst_buf;
13693 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
13694 -
13695 - src_buf = v4l2_m2m_next_src_buf(veu->m2m_ctx);
13696 - dst_buf = v4l2_m2m_next_dst_buf(veu->m2m_ctx);
13697 -
13698 - if (src_buf && dst_buf)
13699 -- sh_veu_process(veu, src_buf, dst_buf);
13700 -+ sh_veu_process(veu, &src_buf->vb2_buf, &dst_buf->vb2_buf);
13701 - }
13702 -
13703 - /* ========== video ioctls ========== */
13704 -diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
13705 -index 6950585edb5a..d16f54cdc3b0 100644
13706 ---- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
13707 -+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
13708 -@@ -793,7 +793,7 @@ static const struct regmap_config sun6i_csi_regmap_config = {
13709 - .reg_bits = 32,
13710 - .reg_stride = 4,
13711 - .val_bits = 32,
13712 -- .max_register = 0x1000,
13713 -+ .max_register = 0x9c,
13714 - };
13715 -
13716 - static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev,
13717 -diff --git a/drivers/media/platform/vimc/Makefile b/drivers/media/platform/vimc/Makefile
13718 -index 4b2e3de7856e..c4fc8e7d365a 100644
13719 ---- a/drivers/media/platform/vimc/Makefile
13720 -+++ b/drivers/media/platform/vimc/Makefile
13721 -@@ -5,6 +5,7 @@ vimc_common-objs := vimc-common.o
13722 - vimc_debayer-objs := vimc-debayer.o
13723 - vimc_scaler-objs := vimc-scaler.o
13724 - vimc_sensor-objs := vimc-sensor.o
13725 -+vimc_streamer-objs := vimc-streamer.o
13726 -
13727 - obj-$(CONFIG_VIDEO_VIMC) += vimc.o vimc_capture.o vimc_common.o vimc-debayer.o \
13728 -- vimc_scaler.o vimc_sensor.o
13729 -+ vimc_scaler.o vimc_sensor.o vimc_streamer.o
13730 -diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
13731 -index 3f7e9ed56633..80d7515ec420 100644
13732 ---- a/drivers/media/platform/vimc/vimc-capture.c
13733 -+++ b/drivers/media/platform/vimc/vimc-capture.c
13734 -@@ -24,6 +24,7 @@
13735 - #include <media/videobuf2-vmalloc.h>
13736 -
13737 - #include "vimc-common.h"
13738 -+#include "vimc-streamer.h"
13739 -
13740 - #define VIMC_CAP_DRV_NAME "vimc-capture"
13741 -
13742 -@@ -44,7 +45,7 @@ struct vimc_cap_device {
13743 - spinlock_t qlock;
13744 - struct mutex lock;
13745 - u32 sequence;
13746 -- struct media_pipeline pipe;
13747 -+ struct vimc_stream stream;
13748 - };
13749 -
13750 - static const struct v4l2_pix_format fmt_default = {
13751 -@@ -248,14 +249,13 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
13752 - vcap->sequence = 0;
13753 -
13754 - /* Start the media pipeline */
13755 -- ret = media_pipeline_start(entity, &vcap->pipe);
13756 -+ ret = media_pipeline_start(entity, &vcap->stream.pipe);
13757 - if (ret) {
13758 - vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED);
13759 - return ret;
13760 - }
13761 -
13762 -- /* Enable streaming from the pipe */
13763 -- ret = vimc_pipeline_s_stream(&vcap->vdev.entity, 1);
13764 -+ ret = vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 1);
13765 - if (ret) {
13766 - media_pipeline_stop(entity);
13767 - vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED);
13768 -@@ -273,8 +273,7 @@ static void vimc_cap_stop_streaming(struct vb2_queue *vq)
13769 - {
13770 - struct vimc_cap_device *vcap = vb2_get_drv_priv(vq);
13771 -
13772 -- /* Disable streaming from the pipe */
13773 -- vimc_pipeline_s_stream(&vcap->vdev.entity, 0);
13774 -+ vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 0);
13775 -
13776 - /* Stop the media pipeline */
13777 - media_pipeline_stop(&vcap->vdev.entity);
13778 -@@ -355,8 +354,8 @@ static void vimc_cap_comp_unbind(struct device *comp, struct device *master,
13779 - kfree(vcap);
13780 - }
13781 -
13782 --static void vimc_cap_process_frame(struct vimc_ent_device *ved,
13783 -- struct media_pad *sink, const void *frame)
13784 -+static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
13785 -+ const void *frame)
13786 - {
13787 - struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device,
13788 - ved);
13789 -@@ -370,7 +369,7 @@ static void vimc_cap_process_frame(struct vimc_ent_device *ved,
13790 - typeof(*vimc_buf), list);
13791 - if (!vimc_buf) {
13792 - spin_unlock(&vcap->qlock);
13793 -- return;
13794 -+ return ERR_PTR(-EAGAIN);
13795 - }
13796 -
13797 - /* Remove this entry from the list */
13798 -@@ -391,6 +390,7 @@ static void vimc_cap_process_frame(struct vimc_ent_device *ved,
13799 - vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, 0,
13800 - vcap->format.sizeimage);
13801 - vb2_buffer_done(&vimc_buf->vb2.vb2_buf, VB2_BUF_STATE_DONE);
13802 -+ return NULL;
13803 - }
13804 -
13805 - static int vimc_cap_comp_bind(struct device *comp, struct device *master,
13806 -diff --git a/drivers/media/platform/vimc/vimc-common.c b/drivers/media/platform/vimc/vimc-common.c
13807 -index 867e24dbd6b5..c1a74bb2df58 100644
13808 ---- a/drivers/media/platform/vimc/vimc-common.c
13809 -+++ b/drivers/media/platform/vimc/vimc-common.c
13810 -@@ -207,41 +207,6 @@ const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat)
13811 - }
13812 - EXPORT_SYMBOL_GPL(vimc_pix_map_by_pixelformat);
13813 -
13814 --int vimc_propagate_frame(struct media_pad *src, const void *frame)
13815 --{
13816 -- struct media_link *link;
13817 --
13818 -- if (!(src->flags & MEDIA_PAD_FL_SOURCE))
13819 -- return -EINVAL;
13820 --
13821 -- /* Send this frame to all sink pads that are direct linked */
13822 -- list_for_each_entry(link, &src->entity->links, list) {
13823 -- if (link->source == src &&
13824 -- (link->flags & MEDIA_LNK_FL_ENABLED)) {
13825 -- struct vimc_ent_device *ved = NULL;
13826 -- struct media_entity *entity = link->sink->entity;
13827 --
13828 -- if (is_media_entity_v4l2_subdev(entity)) {
13829 -- struct v4l2_subdev *sd =
13830 -- container_of(entity, struct v4l2_subdev,
13831 -- entity);
13832 -- ved = v4l2_get_subdevdata(sd);
13833 -- } else if (is_media_entity_v4l2_video_device(entity)) {
13834 -- struct video_device *vdev =
13835 -- container_of(entity,
13836 -- struct video_device,
13837 -- entity);
13838 -- ved = video_get_drvdata(vdev);
13839 -- }
13840 -- if (ved && ved->process_frame)
13841 -- ved->process_frame(ved, link->sink, frame);
13842 -- }
13843 -- }
13844 --
13845 -- return 0;
13846 --}
13847 --EXPORT_SYMBOL_GPL(vimc_propagate_frame);
13848 --
13849 - /* Helper function to allocate and initialize pads */
13850 - struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag)
13851 - {
13852 -diff --git a/drivers/media/platform/vimc/vimc-common.h b/drivers/media/platform/vimc/vimc-common.h
13853 -index 2e9981b18166..6ed969d9efbb 100644
13854 ---- a/drivers/media/platform/vimc/vimc-common.h
13855 -+++ b/drivers/media/platform/vimc/vimc-common.h
13856 -@@ -113,23 +113,12 @@ struct vimc_pix_map {
13857 - struct vimc_ent_device {
13858 - struct media_entity *ent;
13859 - struct media_pad *pads;
13860 -- void (*process_frame)(struct vimc_ent_device *ved,
13861 -- struct media_pad *sink, const void *frame);
13862 -+ void * (*process_frame)(struct vimc_ent_device *ved,
13863 -+ const void *frame);
13864 - void (*vdev_get_format)(struct vimc_ent_device *ved,
13865 - struct v4l2_pix_format *fmt);
13866 - };
13867 -
13868 --/**
13869 -- * vimc_propagate_frame - propagate a frame through the topology
13870 -- *
13871 -- * @src: the source pad where the frame is being originated
13872 -- * @frame: the frame to be propagated
13873 -- *
13874 -- * This function will call the process_frame callback from the vimc_ent_device
13875 -- * struct of the nodes directly connected to the @src pad
13876 -- */
13877 --int vimc_propagate_frame(struct media_pad *src, const void *frame);
13878 --
13879 - /**
13880 - * vimc_pads_init - initialize pads
13881 - *
13882 -diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c
13883 -index 77887f66f323..7d77c63b99d2 100644
13884 ---- a/drivers/media/platform/vimc/vimc-debayer.c
13885 -+++ b/drivers/media/platform/vimc/vimc-debayer.c
13886 -@@ -321,7 +321,6 @@ static void vimc_deb_set_rgb_mbus_fmt_rgb888_1x24(struct vimc_deb_device *vdeb,
13887 - static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable)
13888 - {
13889 - struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd);
13890 -- int ret;
13891 -
13892 - if (enable) {
13893 - const struct vimc_pix_map *vpix;
13894 -@@ -351,22 +350,10 @@ static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable)
13895 - if (!vdeb->src_frame)
13896 - return -ENOMEM;
13897 -
13898 -- /* Turn the stream on in the subdevices directly connected */
13899 -- ret = vimc_pipeline_s_stream(&vdeb->sd.entity, 1);
13900 -- if (ret) {
13901 -- vfree(vdeb->src_frame);
13902 -- vdeb->src_frame = NULL;
13903 -- return ret;
13904 -- }
13905 - } else {
13906 - if (!vdeb->src_frame)
13907 - return 0;
13908 -
13909 -- /* Disable streaming from the pipe */
13910 -- ret = vimc_pipeline_s_stream(&vdeb->sd.entity, 0);
13911 -- if (ret)
13912 -- return ret;
13913 --
13914 - vfree(vdeb->src_frame);
13915 - vdeb->src_frame = NULL;
13916 - }
13917 -@@ -480,9 +467,8 @@ static void vimc_deb_calc_rgb_sink(struct vimc_deb_device *vdeb,
13918 - }
13919 - }
13920 -
13921 --static void vimc_deb_process_frame(struct vimc_ent_device *ved,
13922 -- struct media_pad *sink,
13923 -- const void *sink_frame)
13924 -+static void *vimc_deb_process_frame(struct vimc_ent_device *ved,
13925 -+ const void *sink_frame)
13926 - {
13927 - struct vimc_deb_device *vdeb = container_of(ved, struct vimc_deb_device,
13928 - ved);
13929 -@@ -491,7 +477,7 @@ static void vimc_deb_process_frame(struct vimc_ent_device *ved,
13930 -
13931 - /* If the stream in this node is not active, just return */
13932 - if (!vdeb->src_frame)
13933 -- return;
13934 -+ return ERR_PTR(-EINVAL);
13935 -
13936 - for (i = 0; i < vdeb->sink_fmt.height; i++)
13937 - for (j = 0; j < vdeb->sink_fmt.width; j++) {
13938 -@@ -499,12 +485,8 @@ static void vimc_deb_process_frame(struct vimc_ent_device *ved,
13939 - vdeb->set_rgb_src(vdeb, i, j, rgb);
13940 - }
13941 -
13942 -- /* Propagate the frame through all source pads */
13943 -- for (i = 1; i < vdeb->sd.entity.num_pads; i++) {
13944 -- struct media_pad *pad = &vdeb->sd.entity.pads[i];
13945 -+ return vdeb->src_frame;
13946 -
13947 -- vimc_propagate_frame(pad, vdeb->src_frame);
13948 -- }
13949 - }
13950 -
13951 - static void vimc_deb_comp_unbind(struct device *comp, struct device *master,
13952 -diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c
13953 -index b0952ee86296..39b2a73dfcc1 100644
13954 ---- a/drivers/media/platform/vimc/vimc-scaler.c
13955 -+++ b/drivers/media/platform/vimc/vimc-scaler.c
13956 -@@ -217,7 +217,6 @@ static const struct v4l2_subdev_pad_ops vimc_sca_pad_ops = {
13957 - static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable)
13958 - {
13959 - struct vimc_sca_device *vsca = v4l2_get_subdevdata(sd);
13960 -- int ret;
13961 -
13962 - if (enable) {
13963 - const struct vimc_pix_map *vpix;
13964 -@@ -245,22 +244,10 @@ static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable)
13965 - if (!vsca->src_frame)
13966 - return -ENOMEM;
13967 -
13968 -- /* Turn the stream on in the subdevices directly connected */
13969 -- ret = vimc_pipeline_s_stream(&vsca->sd.entity, 1);
13970 -- if (ret) {
13971 -- vfree(vsca->src_frame);
13972 -- vsca->src_frame = NULL;
13973 -- return ret;
13974 -- }
13975 - } else {
13976 - if (!vsca->src_frame)
13977 - return 0;
13978 -
13979 -- /* Disable streaming from the pipe */
13980 -- ret = vimc_pipeline_s_stream(&vsca->sd.entity, 0);
13981 -- if (ret)
13982 -- return ret;
13983 --
13984 - vfree(vsca->src_frame);
13985 - vsca->src_frame = NULL;
13986 - }
13987 -@@ -346,26 +333,19 @@ static void vimc_sca_fill_src_frame(const struct vimc_sca_device *const vsca,
13988 - vimc_sca_scale_pix(vsca, i, j, sink_frame);
13989 - }
13990 -
13991 --static void vimc_sca_process_frame(struct vimc_ent_device *ved,
13992 -- struct media_pad *sink,
13993 -- const void *sink_frame)
13994 -+static void *vimc_sca_process_frame(struct vimc_ent_device *ved,
13995 -+ const void *sink_frame)
13996 - {
13997 - struct vimc_sca_device *vsca = container_of(ved, struct vimc_sca_device,
13998 - ved);
13999 -- unsigned int i;
14000 -
14001 - /* If the stream in this node is not active, just return */
14002 - if (!vsca->src_frame)
14003 -- return;
14004 -+ return ERR_PTR(-EINVAL);
14005 -
14006 - vimc_sca_fill_src_frame(vsca, sink_frame);
14007 -
14008 -- /* Propagate the frame through all source pads */
14009 -- for (i = 1; i < vsca->sd.entity.num_pads; i++) {
14010 -- struct media_pad *pad = &vsca->sd.entity.pads[i];
14011 --
14012 -- vimc_propagate_frame(pad, vsca->src_frame);
14013 -- }
14014 -+ return vsca->src_frame;
14015 - };
14016 -
14017 - static void vimc_sca_comp_unbind(struct device *comp, struct device *master,
14018 -diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
14019 -index 32ca9c6172b1..93961a1e694f 100644
14020 ---- a/drivers/media/platform/vimc/vimc-sensor.c
14021 -+++ b/drivers/media/platform/vimc/vimc-sensor.c
14022 -@@ -16,8 +16,6 @@
14023 - */
14024 -
14025 - #include <linux/component.h>
14026 --#include <linux/freezer.h>
14027 --#include <linux/kthread.h>
14028 - #include <linux/module.h>
14029 - #include <linux/mod_devicetable.h>
14030 - #include <linux/platform_device.h>
14031 -@@ -201,38 +199,27 @@ static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = {
14032 - .set_fmt = vimc_sen_set_fmt,
14033 - };
14034 -
14035 --static int vimc_sen_tpg_thread(void *data)
14036 -+static void *vimc_sen_process_frame(struct vimc_ent_device *ved,
14037 -+ const void *sink_frame)
14038 - {
14039 -- struct vimc_sen_device *vsen = data;
14040 -- unsigned int i;
14041 --
14042 -- set_freezable();
14043 -- set_current_state(TASK_UNINTERRUPTIBLE);
14044 --
14045 -- for (;;) {
14046 -- try_to_freeze();
14047 -- if (kthread_should_stop())
14048 -- break;
14049 --
14050 -- tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
14051 -+ struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device,
14052 -+ ved);
14053 -+ const struct vimc_pix_map *vpix;
14054 -+ unsigned int frame_size;
14055 -
14056 -- /* Send the frame to all source pads */
14057 -- for (i = 0; i < vsen->sd.entity.num_pads; i++)
14058 -- vimc_propagate_frame(&vsen->sd.entity.pads[i],
14059 -- vsen->frame);
14060 -+ /* Calculate the frame size */
14061 -+ vpix = vimc_pix_map_by_code(vsen->mbus_format.code);
14062 -+ frame_size = vsen->mbus_format.width * vpix->bpp *
14063 -+ vsen->mbus_format.height;
14064 -
14065 -- /* 60 frames per second */
14066 -- schedule_timeout(HZ/60);
14067 -- }
14068 --
14069 -- return 0;
14070 -+ tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
14071 -+ return vsen->frame;
14072 - }
14073 -
14074 - static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
14075 - {
14076 - struct vimc_sen_device *vsen =
14077 - container_of(sd, struct vimc_sen_device, sd);
14078 -- int ret;
14079 -
14080 - if (enable) {
14081 - const struct vimc_pix_map *vpix;
14082 -@@ -258,26 +245,8 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
14083 - /* configure the test pattern generator */
14084 - vimc_sen_tpg_s_format(vsen);
14085 -
14086 -- /* Initialize the image generator thread */
14087 -- vsen->kthread_sen = kthread_run(vimc_sen_tpg_thread, vsen,
14088 -- "%s-sen", vsen->sd.v4l2_dev->name);
14089 -- if (IS_ERR(vsen->kthread_sen)) {
14090 -- dev_err(vsen->dev, "%s: kernel_thread() failed\n",
14091 -- vsen->sd.name);
14092 -- vfree(vsen->frame);
14093 -- vsen->frame = NULL;
14094 -- return PTR_ERR(vsen->kthread_sen);
14095 -- }
14096 - } else {
14097 -- if (!vsen->kthread_sen)
14098 -- return 0;
14099 --
14100 -- /* Stop image generator */
14101 -- ret = kthread_stop(vsen->kthread_sen);
14102 -- if (ret)
14103 -- return ret;
14104 -
14105 -- vsen->kthread_sen = NULL;
14106 - vfree(vsen->frame);
14107 - vsen->frame = NULL;
14108 - return 0;
14109 -@@ -413,6 +382,7 @@ static int vimc_sen_comp_bind(struct device *comp, struct device *master,
14110 - if (ret)
14111 - goto err_free_hdl;
14112 -
14113 -+ vsen->ved.process_frame = vimc_sen_process_frame;
14114 - dev_set_drvdata(comp, &vsen->ved);
14115 - vsen->dev = comp;
14116 -
14117 -diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c
14118 -new file mode 100644
14119 -index 000000000000..fcc897fb247b
14120 ---- /dev/null
14121 -+++ b/drivers/media/platform/vimc/vimc-streamer.c
14122 -@@ -0,0 +1,188 @@
14123 -+// SPDX-License-Identifier: GPL-2.0+
14124 -+/*
14125 -+ * vimc-streamer.c Virtual Media Controller Driver
14126 -+ *
14127 -+ * Copyright (C) 2018 Lucas A. M. Magalhães <lucmaga@×××××.com>
14128 -+ *
14129 -+ */
14130 -+
14131 -+#include <linux/init.h>
14132 -+#include <linux/module.h>
14133 -+#include <linux/freezer.h>
14134 -+#include <linux/kthread.h>
14135 -+
14136 -+#include "vimc-streamer.h"
14137 -+
14138 -+/**
14139 -+ * vimc_get_source_entity - get the entity connected with the first sink pad
14140 -+ *
14141 -+ * @ent: reference media_entity
14142 -+ *
14143 -+ * Helper function that returns the media entity containing the source pad
14144 -+ * linked with the first sink pad from the given media entity pad list.
14145 -+ */
14146 -+static struct media_entity *vimc_get_source_entity(struct media_entity *ent)
14147 -+{
14148 -+ struct media_pad *pad;
14149 -+ int i;
14150 -+
14151 -+ for (i = 0; i < ent->num_pads; i++) {
14152 -+ if (ent->pads[i].flags & MEDIA_PAD_FL_SOURCE)
14153 -+ continue;
14154 -+ pad = media_entity_remote_pad(&ent->pads[i]);
14155 -+ return pad ? pad->entity : NULL;
14156 -+ }
14157 -+ return NULL;
14158 -+}
14159 -+
14160 -+/*
14161 -+ * vimc_streamer_pipeline_terminate - Disable stream in all ved in stream
14162 -+ *
14163 -+ * @stream: the pointer to the stream structure with the pipeline to be
14164 -+ * disabled.
14165 -+ *
14166 -+ * Calls s_stream to disable the stream in each entity of the pipeline
14167 -+ *
14168 -+ */
14169 -+static void vimc_streamer_pipeline_terminate(struct vimc_stream *stream)
14170 -+{
14171 -+ struct media_entity *entity;
14172 -+ struct v4l2_subdev *sd;
14173 -+
14174 -+ while (stream->pipe_size) {
14175 -+ stream->pipe_size--;
14176 -+ entity = stream->ved_pipeline[stream->pipe_size]->ent;
14177 -+ entity = vimc_get_source_entity(entity);
14178 -+ stream->ved_pipeline[stream->pipe_size] = NULL;
14179 -+
14180 -+ if (!is_media_entity_v4l2_subdev(entity))
14181 -+ continue;
14182 -+
14183 -+ sd = media_entity_to_v4l2_subdev(entity);
14184 -+ v4l2_subdev_call(sd, video, s_stream, 0);
14185 -+ }
14186 -+}
14187 -+
14188 -+/*
14189 -+ * vimc_streamer_pipeline_init - initializes the stream structure
14190 -+ *
14191 -+ * @stream: the pointer to the stream structure to be initialized
14192 -+ * @ved: the pointer to the vimc entity initializing the stream
14193 -+ *
14194 -+ * Initializes the stream structure. Walks through the entity graph to
14195 -+ * construct the pipeline used later on the streamer thread.
14196 -+ * Calls s_stream to enable stream in all entities of the pipeline.
14197 -+ */
14198 -+static int vimc_streamer_pipeline_init(struct vimc_stream *stream,
14199 -+ struct vimc_ent_device *ved)
14200 -+{
14201 -+ struct media_entity *entity;
14202 -+ struct video_device *vdev;
14203 -+ struct v4l2_subdev *sd;
14204 -+ int ret = 0;
14205 -+
14206 -+ stream->pipe_size = 0;
14207 -+ while (stream->pipe_size < VIMC_STREAMER_PIPELINE_MAX_SIZE) {
14208 -+ if (!ved) {
14209 -+ vimc_streamer_pipeline_terminate(stream);
14210 -+ return -EINVAL;
14211 -+ }
14212 -+ stream->ved_pipeline[stream->pipe_size++] = ved;
14213 -+
14214 -+ entity = vimc_get_source_entity(ved->ent);
14215 -+ /* Check if the end of the pipeline was reached*/
14216 -+ if (!entity)
14217 -+ return 0;
14218 -+
14219 -+ if (is_media_entity_v4l2_subdev(entity)) {
14220 -+ sd = media_entity_to_v4l2_subdev(entity);
14221 -+ ret = v4l2_subdev_call(sd, video, s_stream, 1);
14222 -+ if (ret && ret != -ENOIOCTLCMD) {
14223 -+ vimc_streamer_pipeline_terminate(stream);
14224 -+ return ret;
14225 -+ }
14226 -+ ved = v4l2_get_subdevdata(sd);
14227 -+ } else {
14228 -+ vdev = container_of(entity,
14229 -+ struct video_device,
14230 -+ entity);
14231 -+ ved = video_get_drvdata(vdev);
14232 -+ }
14233 -+ }
14234 -+
14235 -+ vimc_streamer_pipeline_terminate(stream);
14236 -+ return -EINVAL;
14237 -+}
14238 -+
14239 -+static int vimc_streamer_thread(void *data)
14240 -+{
14241 -+ struct vimc_stream *stream = data;
14242 -+ int i;
14243 -+
14244 -+ set_freezable();
14245 -+ set_current_state(TASK_UNINTERRUPTIBLE);
14246 -+
14247 -+ for (;;) {
14248 -+ try_to_freeze();
14249 -+ if (kthread_should_stop())
14250 -+ break;
14251 -+
14252 -+ for (i = stream->pipe_size - 1; i >= 0; i--) {
14253 -+ stream->frame = stream->ved_pipeline[i]->process_frame(
14254 -+ stream->ved_pipeline[i],
14255 -+ stream->frame);
14256 -+ if (!stream->frame)
14257 -+ break;
14258 -+ if (IS_ERR(stream->frame))
14259 -+ break;
14260 -+ }
14261 -+ //wait for 60hz
14262 -+ schedule_timeout(HZ / 60);
14263 -+ }
14264 -+
14265 -+ return 0;
14266 -+}
14267 -+
14268 -+int vimc_streamer_s_stream(struct vimc_stream *stream,
14269 -+ struct vimc_ent_device *ved,
14270 -+ int enable)
14271 -+{
14272 -+ int ret;
14273 -+
14274 -+ if (!stream || !ved)
14275 -+ return -EINVAL;
14276 -+
14277 -+ if (enable) {
14278 -+ if (stream->kthread)
14279 -+ return 0;
14280 -+
14281 -+ ret = vimc_streamer_pipeline_init(stream, ved);
14282 -+ if (ret)
14283 -+ return ret;
14284 -+
14285 -+ stream->kthread = kthread_run(vimc_streamer_thread, stream,
14286 -+ "vimc-streamer thread");
14287 -+
14288 -+ if (IS_ERR(stream->kthread))
14289 -+ return PTR_ERR(stream->kthread);
14290 -+
14291 -+ } else {
14292 -+ if (!stream->kthread)
14293 -+ return 0;
14294 -+
14295 -+ ret = kthread_stop(stream->kthread);
14296 -+ if (ret)
14297 -+ return ret;
14298 -+
14299 -+ stream->kthread = NULL;
14300 -+
14301 -+ vimc_streamer_pipeline_terminate(stream);
14302 -+ }
14303 -+
14304 -+ return 0;
14305 -+}
14306 -+EXPORT_SYMBOL_GPL(vimc_streamer_s_stream);
14307 -+
14308 -+MODULE_DESCRIPTION("Virtual Media Controller Driver (VIMC) Streamer");
14309 -+MODULE_AUTHOR("Lucas A. M. Magalhães <lucmaga@×××××.com>");
14310 -+MODULE_LICENSE("GPL");
14311 -diff --git a/drivers/media/platform/vimc/vimc-streamer.h b/drivers/media/platform/vimc/vimc-streamer.h
14312 -new file mode 100644
14313 -index 000000000000..752af2e2d5a2
14314 ---- /dev/null
14315 -+++ b/drivers/media/platform/vimc/vimc-streamer.h
14316 -@@ -0,0 +1,38 @@
14317 -+/* SPDX-License-Identifier: GPL-2.0+ */
14318 -+/*
14319 -+ * vimc-streamer.h Virtual Media Controller Driver
14320 -+ *
14321 -+ * Copyright (C) 2018 Lucas A. M. Magalhães <lucmaga@×××××.com>
14322 -+ *
14323 -+ */
14324 -+
14325 -+#ifndef _VIMC_STREAMER_H_
14326 -+#define _VIMC_STREAMER_H_
14327 -+
14328 -+#include <media/media-device.h>
14329 -+
14330 -+#include "vimc-common.h"
14331 -+
14332 -+#define VIMC_STREAMER_PIPELINE_MAX_SIZE 16
14333 -+
14334 -+struct vimc_stream {
14335 -+ struct media_pipeline pipe;
14336 -+ struct vimc_ent_device *ved_pipeline[VIMC_STREAMER_PIPELINE_MAX_SIZE];
14337 -+ unsigned int pipe_size;
14338 -+ u8 *frame;
14339 -+ struct task_struct *kthread;
14340 -+};
14341 -+
14342 -+/**
14343 -+ * vimc_streamer_s_streamer - start/stop the stream
14344 -+ *
14345 -+ * @stream: the pointer to the stream to start or stop
14346 -+ * @ved: The last entity of the streamer pipeline
14347 -+ * @enable: any non-zero number start the stream, zero stop
14348 -+ *
14349 -+ */
14350 -+int vimc_streamer_s_stream(struct vimc_stream *stream,
14351 -+ struct vimc_ent_device *ved,
14352 -+ int enable);
14353 -+
14354 -+#endif //_VIMC_STREAMER_H_
14355 -diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
14356 -index 66a174979b3c..81745644f720 100644
14357 ---- a/drivers/media/rc/rc-main.c
14358 -+++ b/drivers/media/rc/rc-main.c
14359 -@@ -274,6 +274,7 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
14360 - unsigned int new_keycode)
14361 - {
14362 - int old_keycode = rc_map->scan[index].keycode;
14363 -+ int i;
14364 -
14365 - /* Did the user wish to remove the mapping? */
14366 - if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {
14367 -@@ -288,9 +289,20 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
14368 - old_keycode == KEY_RESERVED ? "New" : "Replacing",
14369 - rc_map->scan[index].scancode, new_keycode);
14370 - rc_map->scan[index].keycode = new_keycode;
14371 -+ __set_bit(new_keycode, dev->input_dev->keybit);
14372 - }
14373 -
14374 - if (old_keycode != KEY_RESERVED) {
14375 -+ /* A previous mapping was updated... */
14376 -+ __clear_bit(old_keycode, dev->input_dev->keybit);
14377 -+ /* ... but another scancode might use the same keycode */
14378 -+ for (i = 0; i < rc_map->len; i++) {
14379 -+ if (rc_map->scan[i].keycode == old_keycode) {
14380 -+ __set_bit(old_keycode, dev->input_dev->keybit);
14381 -+ break;
14382 -+ }
14383 -+ }
14384 -+
14385 - /* Possibly shrink the keytable, failure is not a problem */
14386 - ir_resize_table(dev, rc_map, GFP_ATOMIC);
14387 - }
14388 -@@ -1750,7 +1762,6 @@ static int rc_prepare_rx_device(struct rc_dev *dev)
14389 - set_bit(EV_REP, dev->input_dev->evbit);
14390 - set_bit(EV_MSC, dev->input_dev->evbit);
14391 - set_bit(MSC_SCAN, dev->input_dev->mscbit);
14392 -- bitmap_fill(dev->input_dev->keybit, KEY_CNT);
14393 -
14394 - /* Pointer/mouse events */
14395 - set_bit(EV_REL, dev->input_dev->evbit);
14396 -diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
14397 -index d45415cbe6e7..14cff91b7aea 100644
14398 ---- a/drivers/media/usb/uvc/uvc_ctrl.c
14399 -+++ b/drivers/media/usb/uvc/uvc_ctrl.c
14400 -@@ -1212,7 +1212,7 @@ static void uvc_ctrl_fill_event(struct uvc_video_chain *chain,
14401 -
14402 - __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl);
14403 -
14404 -- memset(ev->reserved, 0, sizeof(ev->reserved));
14405 -+ memset(ev, 0, sizeof(*ev));
14406 - ev->type = V4L2_EVENT_CTRL;
14407 - ev->id = v4l2_ctrl.id;
14408 - ev->u.ctrl.value = value;
14409 -diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
14410 -index b62cbd800111..33a22c016456 100644
14411 ---- a/drivers/media/usb/uvc/uvc_driver.c
14412 -+++ b/drivers/media/usb/uvc/uvc_driver.c
14413 -@@ -1106,11 +1106,19 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
14414 - return -EINVAL;
14415 - }
14416 -
14417 -- /* Make sure the terminal type MSB is not null, otherwise it
14418 -- * could be confused with a unit.
14419 -+ /*
14420 -+ * Reject invalid terminal types that would cause issues:
14421 -+ *
14422 -+ * - The high byte must be non-zero, otherwise it would be
14423 -+ * confused with a unit.
14424 -+ *
14425 -+ * - Bit 15 must be 0, as we use it internally as a terminal
14426 -+ * direction flag.
14427 -+ *
14428 -+ * Other unknown types are accepted.
14429 - */
14430 - type = get_unaligned_le16(&buffer[4]);
14431 -- if ((type & 0xff00) == 0) {
14432 -+ if ((type & 0x7f00) == 0 || (type & 0x8000) != 0) {
14433 - uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
14434 - "interface %d INPUT_TERMINAL %d has invalid "
14435 - "type 0x%04x, skipping\n", udev->devnum,
14436 -diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
14437 -index 84525ff04745..e314657a1843 100644
14438 ---- a/drivers/media/usb/uvc/uvc_video.c
14439 -+++ b/drivers/media/usb/uvc/uvc_video.c
14440 -@@ -676,6 +676,14 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
14441 - if (!uvc_hw_timestamps_param)
14442 - return;
14443 -
14444 -+ /*
14445 -+ * We will get called from __vb2_queue_cancel() if there are buffers
14446 -+ * done but not dequeued by the user, but the sample array has already
14447 -+ * been released at that time. Just bail out in that case.
14448 -+ */
14449 -+ if (!clock->samples)
14450 -+ return;
14451 -+
14452 - spin_lock_irqsave(&clock->lock, flags);
14453 -
14454 - if (clock->count < clock->size)
14455 -diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
14456 -index 5e3806feb5d7..8a82427c4d54 100644
14457 ---- a/drivers/media/v4l2-core/v4l2-ctrls.c
14458 -+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
14459 -@@ -1387,7 +1387,7 @@ static u32 user_flags(const struct v4l2_ctrl *ctrl)
14460 -
14461 - static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
14462 - {
14463 -- memset(ev->reserved, 0, sizeof(ev->reserved));
14464 -+ memset(ev, 0, sizeof(*ev));
14465 - ev->type = V4L2_EVENT_CTRL;
14466 - ev->id = ctrl->id;
14467 - ev->u.ctrl.changes = changes;
14468 -diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
14469 -index a530972c5a7e..e0173bf4b0dc 100644
14470 ---- a/drivers/mfd/sm501.c
14471 -+++ b/drivers/mfd/sm501.c
14472 -@@ -1145,6 +1145,9 @@ static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm,
14473 - lookup = devm_kzalloc(&pdev->dev,
14474 - sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
14475 - GFP_KERNEL);
14476 -+ if (!lookup)
14477 -+ return -ENOMEM;
14478 -+
14479 - lookup->dev_id = "i2c-gpio";
14480 - if (iic->pin_sda < 32)
14481 - lookup->table[0].chip_label = "SM501-LOW";
14482 -diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
14483 -index 5d28d9e454f5..08f4a512afad 100644
14484 ---- a/drivers/misc/cxl/guest.c
14485 -+++ b/drivers/misc/cxl/guest.c
14486 -@@ -267,6 +267,7 @@ static int guest_reset(struct cxl *adapter)
14487 - int i, rc;
14488 -
14489 - pr_devel("Adapter reset request\n");
14490 -+ spin_lock(&adapter->afu_list_lock);
14491 - for (i = 0; i < adapter->slices; i++) {
14492 - if ((afu = adapter->afu[i])) {
14493 - pci_error_handlers(afu, CXL_ERROR_DETECTED_EVENT,
14494 -@@ -283,6 +284,7 @@ static int guest_reset(struct cxl *adapter)
14495 - pci_error_handlers(afu, CXL_RESUME_EVENT, 0);
14496 - }
14497 - }
14498 -+ spin_unlock(&adapter->afu_list_lock);
14499 - return rc;
14500 - }
14501 -
14502 -diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
14503 -index c79ba1c699ad..300531d6136f 100644
14504 ---- a/drivers/misc/cxl/pci.c
14505 -+++ b/drivers/misc/cxl/pci.c
14506 -@@ -1805,7 +1805,7 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
14507 - /* There should only be one entry, but go through the list
14508 - * anyway
14509 - */
14510 -- if (afu->phb == NULL)
14511 -+ if (afu == NULL || afu->phb == NULL)
14512 - return result;
14513 -
14514 - list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
14515 -@@ -1832,7 +1832,8 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
14516 - {
14517 - struct cxl *adapter = pci_get_drvdata(pdev);
14518 - struct cxl_afu *afu;
14519 -- pci_ers_result_t result = PCI_ERS_RESULT_NEED_RESET, afu_result;
14520 -+ pci_ers_result_t result = PCI_ERS_RESULT_NEED_RESET;
14521 -+ pci_ers_result_t afu_result = PCI_ERS_RESULT_NEED_RESET;
14522 - int i;
14523 -
14524 - /* At this point, we could still have an interrupt pending.
14525 -@@ -1843,6 +1844,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
14526 -
14527 - /* If we're permanently dead, give up. */
14528 - if (state == pci_channel_io_perm_failure) {
14529 -+ spin_lock(&adapter->afu_list_lock);
14530 - for (i = 0; i < adapter->slices; i++) {
14531 - afu = adapter->afu[i];
14532 - /*
14533 -@@ -1851,6 +1853,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
14534 - */
14535 - cxl_vphb_error_detected(afu, state);
14536 - }
14537 -+ spin_unlock(&adapter->afu_list_lock);
14538 - return PCI_ERS_RESULT_DISCONNECT;
14539 - }
14540 -
14541 -@@ -1932,11 +1935,17 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
14542 - * * In slot_reset, free the old resources and allocate new ones.
14543 - * * In resume, clear the flag to allow things to start.
14544 - */
14545 -+
14546 -+ /* Make sure no one else changes the afu list */
14547 -+ spin_lock(&adapter->afu_list_lock);
14548 -+
14549 - for (i = 0; i < adapter->slices; i++) {
14550 - afu = adapter->afu[i];
14551 -
14552 -- afu_result = cxl_vphb_error_detected(afu, state);
14553 -+ if (afu == NULL)
14554 -+ continue;
14555 -
14556 -+ afu_result = cxl_vphb_error_detected(afu, state);
14557 - cxl_context_detach_all(afu);
14558 - cxl_ops->afu_deactivate_mode(afu, afu->current_mode);
14559 - pci_deconfigure_afu(afu);
14560 -@@ -1948,6 +1957,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
14561 - (result == PCI_ERS_RESULT_NEED_RESET))
14562 - result = PCI_ERS_RESULT_NONE;
14563 - }
14564 -+ spin_unlock(&adapter->afu_list_lock);
14565 -
14566 - /* should take the context lock here */
14567 - if (cxl_adapter_context_lock(adapter) != 0)
14568 -@@ -1980,14 +1990,18 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
14569 - */
14570 - cxl_adapter_context_unlock(adapter);
14571 -
14572 -+ spin_lock(&adapter->afu_list_lock);
14573 - for (i = 0; i < adapter->slices; i++) {
14574 - afu = adapter->afu[i];
14575 -
14576 -+ if (afu == NULL)
14577 -+ continue;
14578 -+
14579 - if (pci_configure_afu(afu, adapter, pdev))
14580 -- goto err;
14581 -+ goto err_unlock;
14582 -
14583 - if (cxl_afu_select_best_mode(afu))
14584 -- goto err;
14585 -+ goto err_unlock;
14586 -
14587 - if (afu->phb == NULL)
14588 - continue;
14589 -@@ -1999,16 +2013,16 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
14590 - ctx = cxl_get_context(afu_dev);
14591 -
14592 - if (ctx && cxl_release_context(ctx))
14593 -- goto err;
14594 -+ goto err_unlock;
14595 -
14596 - ctx = cxl_dev_context_init(afu_dev);
14597 - if (IS_ERR(ctx))
14598 -- goto err;
14599 -+ goto err_unlock;
14600 -
14601 - afu_dev->dev.archdata.cxl_ctx = ctx;
14602 -
14603 - if (cxl_ops->afu_check_and_enable(afu))
14604 -- goto err;
14605 -+ goto err_unlock;
14606 -
14607 - afu_dev->error_state = pci_channel_io_normal;
14608 -
14609 -@@ -2029,8 +2043,13 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
14610 - result = PCI_ERS_RESULT_DISCONNECT;
14611 - }
14612 - }
14613 -+
14614 -+ spin_unlock(&adapter->afu_list_lock);
14615 - return result;
14616 -
14617 -+err_unlock:
14618 -+ spin_unlock(&adapter->afu_list_lock);
14619 -+
14620 - err:
14621 - /* All the bits that happen in both error_detected and cxl_remove
14622 - * should be idempotent, so we don't need to worry about leaving a mix
14623 -@@ -2051,10 +2070,11 @@ static void cxl_pci_resume(struct pci_dev *pdev)
14624 - * This is not the place to be checking if everything came back up
14625 - * properly, because there's no return value: do that in slot_reset.
14626 - */
14627 -+ spin_lock(&adapter->afu_list_lock);
14628 - for (i = 0; i < adapter->slices; i++) {
14629 - afu = adapter->afu[i];
14630 -
14631 -- if (afu->phb == NULL)
14632 -+ if (afu == NULL || afu->phb == NULL)
14633 - continue;
14634 -
14635 - list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
14636 -@@ -2063,6 +2083,7 @@ static void cxl_pci_resume(struct pci_dev *pdev)
14637 - afu_dev->driver->err_handler->resume(afu_dev);
14638 - }
14639 - }
14640 -+ spin_unlock(&adapter->afu_list_lock);
14641 - }
14642 -
14643 - static const struct pci_error_handlers cxl_err_handler = {
14644 -diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
14645 -index fc3872fe7b25..c383322ec2ba 100644
14646 ---- a/drivers/misc/mei/bus.c
14647 -+++ b/drivers/misc/mei/bus.c
14648 -@@ -541,17 +541,9 @@ int mei_cldev_enable(struct mei_cl_device *cldev)
14649 - goto out;
14650 - }
14651 -
14652 -- if (!mei_cl_bus_module_get(cldev)) {
14653 -- dev_err(&cldev->dev, "get hw module failed");
14654 -- ret = -ENODEV;
14655 -- goto out;
14656 -- }
14657 --
14658 - ret = mei_cl_connect(cl, cldev->me_cl, NULL);
14659 -- if (ret < 0) {
14660 -+ if (ret < 0)
14661 - dev_err(&cldev->dev, "cannot connect\n");
14662 -- mei_cl_bus_module_put(cldev);
14663 -- }
14664 -
14665 - out:
14666 - mutex_unlock(&bus->device_lock);
14667 -@@ -614,7 +606,6 @@ int mei_cldev_disable(struct mei_cl_device *cldev)
14668 - if (err < 0)
14669 - dev_err(bus->dev, "Could not disconnect from the ME client\n");
14670 -
14671 -- mei_cl_bus_module_put(cldev);
14672 - out:
14673 - /* Flush queues and remove any pending read */
14674 - mei_cl_flush_queues(cl, NULL);
14675 -@@ -725,9 +716,16 @@ static int mei_cl_device_probe(struct device *dev)
14676 - if (!id)
14677 - return -ENODEV;
14678 -
14679 -+ if (!mei_cl_bus_module_get(cldev)) {
14680 -+ dev_err(&cldev->dev, "get hw module failed");
14681 -+ return -ENODEV;
14682 -+ }
14683 -+
14684 - ret = cldrv->probe(cldev, id);
14685 -- if (ret)
14686 -+ if (ret) {
14687 -+ mei_cl_bus_module_put(cldev);
14688 - return ret;
14689 -+ }
14690 -
14691 - __module_get(THIS_MODULE);
14692 - return 0;
14693 -@@ -755,6 +753,7 @@ static int mei_cl_device_remove(struct device *dev)
14694 -
14695 - mei_cldev_unregister_callbacks(cldev);
14696 -
14697 -+ mei_cl_bus_module_put(cldev);
14698 - module_put(THIS_MODULE);
14699 - dev->driver = NULL;
14700 - return ret;
14701 -diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
14702 -index 8f7616557c97..e6207f614816 100644
14703 ---- a/drivers/misc/mei/hbm.c
14704 -+++ b/drivers/misc/mei/hbm.c
14705 -@@ -1029,29 +1029,36 @@ static void mei_hbm_config_features(struct mei_device *dev)
14706 - dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
14707 - dev->hbm_f_pg_supported = 1;
14708 -
14709 -+ dev->hbm_f_dc_supported = 0;
14710 - if (dev->version.major_version >= HBM_MAJOR_VERSION_DC)
14711 - dev->hbm_f_dc_supported = 1;
14712 -
14713 -+ dev->hbm_f_ie_supported = 0;
14714 - if (dev->version.major_version >= HBM_MAJOR_VERSION_IE)
14715 - dev->hbm_f_ie_supported = 1;
14716 -
14717 - /* disconnect on connect timeout instead of link reset */
14718 -+ dev->hbm_f_dot_supported = 0;
14719 - if (dev->version.major_version >= HBM_MAJOR_VERSION_DOT)
14720 - dev->hbm_f_dot_supported = 1;
14721 -
14722 - /* Notification Event Support */
14723 -+ dev->hbm_f_ev_supported = 0;
14724 - if (dev->version.major_version >= HBM_MAJOR_VERSION_EV)
14725 - dev->hbm_f_ev_supported = 1;
14726 -
14727 - /* Fixed Address Client Support */
14728 -+ dev->hbm_f_fa_supported = 0;
14729 - if (dev->version.major_version >= HBM_MAJOR_VERSION_FA)
14730 - dev->hbm_f_fa_supported = 1;
14731 -
14732 - /* OS ver message Support */
14733 -+ dev->hbm_f_os_supported = 0;
14734 - if (dev->version.major_version >= HBM_MAJOR_VERSION_OS)
14735 - dev->hbm_f_os_supported = 1;
14736 -
14737 - /* DMA Ring Support */
14738 -+ dev->hbm_f_dr_supported = 0;
14739 - if (dev->version.major_version > HBM_MAJOR_VERSION_DR ||
14740 - (dev->version.major_version == HBM_MAJOR_VERSION_DR &&
14741 - dev->version.minor_version >= HBM_MINOR_VERSION_DR))
14742 -diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
14743 -index f8240b87df22..f69acb5d4a50 100644
14744 ---- a/drivers/misc/vmw_balloon.c
14745 -+++ b/drivers/misc/vmw_balloon.c
14746 -@@ -1287,7 +1287,7 @@ static void vmballoon_reset(struct vmballoon *b)
14747 - vmballoon_pop(b);
14748 -
14749 - if (vmballoon_send_start(b, VMW_BALLOON_CAPABILITIES))
14750 -- return;
14751 -+ goto unlock;
14752 -
14753 - if ((b->capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) {
14754 - if (vmballoon_init_batching(b)) {
14755 -@@ -1298,7 +1298,7 @@ static void vmballoon_reset(struct vmballoon *b)
14756 - * The guest will retry in one second.
14757 - */
14758 - vmballoon_send_start(b, 0);
14759 -- return;
14760 -+ goto unlock;
14761 - }
14762 - } else if ((b->capabilities & VMW_BALLOON_BASIC_CMDS) != 0) {
14763 - vmballoon_deinit_batching(b);
14764 -@@ -1314,6 +1314,7 @@ static void vmballoon_reset(struct vmballoon *b)
14765 - if (vmballoon_send_guest_id(b))
14766 - pr_err("failed to send guest ID to the host\n");
14767 -
14768 -+unlock:
14769 - up_write(&b->conf_sem);
14770 - }
14771 -
14772 -diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
14773 -index b27a1e620233..1e6b07c176dc 100644
14774 ---- a/drivers/mmc/core/core.c
14775 -+++ b/drivers/mmc/core/core.c
14776 -@@ -2381,9 +2381,9 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
14777 - return card->pref_erase;
14778 -
14779 - max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
14780 -- if (max_discard && mmc_can_trim(card)) {
14781 -+ if (mmc_can_trim(card)) {
14782 - max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
14783 -- if (max_trim < max_discard)
14784 -+ if (max_trim < max_discard || max_discard == 0)
14785 - max_discard = max_trim;
14786 - } else if (max_discard < card->erase_size) {
14787 - max_discard = 0;
14788 -diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
14789 -index c712b7deb3a9..7c8f203f9a24 100644
14790 ---- a/drivers/mmc/host/alcor.c
14791 -+++ b/drivers/mmc/host/alcor.c
14792 -@@ -48,7 +48,6 @@ struct alcor_sdmmc_host {
14793 - struct mmc_command *cmd;
14794 - struct mmc_data *data;
14795 - unsigned int dma_on:1;
14796 -- unsigned int early_data:1;
14797 -
14798 - struct mutex cmd_mutex;
14799 -
14800 -@@ -144,8 +143,7 @@ static void alcor_data_set_dma(struct alcor_sdmmc_host *host)
14801 - host->sg_count--;
14802 - }
14803 -
14804 --static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host,
14805 -- bool early)
14806 -+static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host)
14807 - {
14808 - struct alcor_pci_priv *priv = host->alcor_pci;
14809 - struct mmc_data *data = host->data;
14810 -@@ -155,13 +153,6 @@ static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host,
14811 - ctrl |= AU6601_DATA_WRITE;
14812 -
14813 - if (data->host_cookie == COOKIE_MAPPED) {
14814 -- if (host->early_data) {
14815 -- host->early_data = false;
14816 -- return;
14817 -- }
14818 --
14819 -- host->early_data = early;
14820 --
14821 - alcor_data_set_dma(host);
14822 - ctrl |= AU6601_DATA_DMA_MODE;
14823 - host->dma_on = 1;
14824 -@@ -231,6 +222,7 @@ static void alcor_prepare_sg_miter(struct alcor_sdmmc_host *host)
14825 - static void alcor_prepare_data(struct alcor_sdmmc_host *host,
14826 - struct mmc_command *cmd)
14827 - {
14828 -+ struct alcor_pci_priv *priv = host->alcor_pci;
14829 - struct mmc_data *data = cmd->data;
14830 -
14831 - if (!data)
14832 -@@ -248,7 +240,7 @@ static void alcor_prepare_data(struct alcor_sdmmc_host *host,
14833 - if (data->host_cookie != COOKIE_MAPPED)
14834 - alcor_prepare_sg_miter(host);
14835 -
14836 -- alcor_trigger_data_transfer(host, true);
14837 -+ alcor_write8(priv, 0, AU6601_DATA_XFER_CTRL);
14838 - }
14839 -
14840 - static void alcor_send_cmd(struct alcor_sdmmc_host *host,
14841 -@@ -435,7 +427,7 @@ static int alcor_cmd_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
14842 - if (!host->data)
14843 - return false;
14844 -
14845 -- alcor_trigger_data_transfer(host, false);
14846 -+ alcor_trigger_data_transfer(host);
14847 - host->cmd = NULL;
14848 - return true;
14849 - }
14850 -@@ -456,7 +448,7 @@ static void alcor_cmd_irq_thread(struct alcor_sdmmc_host *host, u32 intmask)
14851 - if (!host->data)
14852 - alcor_request_complete(host, 1);
14853 - else
14854 -- alcor_trigger_data_transfer(host, false);
14855 -+ alcor_trigger_data_transfer(host);
14856 - host->cmd = NULL;
14857 - }
14858 -
14859 -@@ -487,15 +479,9 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
14860 - break;
14861 - case AU6601_INT_READ_BUF_RDY:
14862 - alcor_trf_block_pio(host, true);
14863 -- if (!host->blocks)
14864 -- break;
14865 -- alcor_trigger_data_transfer(host, false);
14866 - return 1;
14867 - case AU6601_INT_WRITE_BUF_RDY:
14868 - alcor_trf_block_pio(host, false);
14869 -- if (!host->blocks)
14870 -- break;
14871 -- alcor_trigger_data_transfer(host, false);
14872 - return 1;
14873 - case AU6601_INT_DMA_END:
14874 - if (!host->sg_count)
14875 -@@ -508,8 +494,14 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
14876 - break;
14877 - }
14878 -
14879 -- if (intmask & AU6601_INT_DATA_END)
14880 -- return 0;
14881 -+ if (intmask & AU6601_INT_DATA_END) {
14882 -+ if (!host->dma_on && host->blocks) {
14883 -+ alcor_trigger_data_transfer(host);
14884 -+ return 1;
14885 -+ } else {
14886 -+ return 0;
14887 -+ }
14888 -+ }
14889 -
14890 - return 1;
14891 - }
14892 -@@ -1044,14 +1036,27 @@ static void alcor_init_mmc(struct alcor_sdmmc_host *host)
14893 - mmc->caps2 = MMC_CAP2_NO_SDIO;
14894 - mmc->ops = &alcor_sdc_ops;
14895 -
14896 -- /* Hardware cannot do scatter lists */
14897 -+ /* The hardware does DMA data transfer of 4096 bytes to/from a single
14898 -+ * buffer address. Scatterlists are not supported, but upon DMA
14899 -+ * completion (signalled via IRQ), the original vendor driver does
14900 -+ * then immediately set up another DMA transfer of the next 4096
14901 -+ * bytes.
14902 -+ *
14903 -+ * This means that we need to handle the I/O in 4096 byte chunks.
14904 -+ * Lacking a way to limit the sglist entries to 4096 bytes, we instead
14905 -+ * impose that only one segment is provided, with maximum size 4096,
14906 -+ * which also happens to be the minimum size. This means that the
14907 -+ * single-entry sglist handled by this driver can be handed directly
14908 -+ * to the hardware, nice and simple.
14909 -+ *
14910 -+ * Unfortunately though, that means we only do 4096 bytes I/O per
14911 -+ * MMC command. A future improvement would be to make the driver
14912 -+ * accept sg lists and entries of any size, and simply iterate
14913 -+ * through them 4096 bytes at a time.
14914 -+ */
14915 - mmc->max_segs = AU6601_MAX_DMA_SEGMENTS;
14916 - mmc->max_seg_size = AU6601_MAX_DMA_BLOCK_SIZE;
14917 --
14918 -- mmc->max_blk_size = mmc->max_seg_size;
14919 -- mmc->max_blk_count = mmc->max_segs;
14920 --
14921 -- mmc->max_req_size = mmc->max_seg_size * mmc->max_segs;
14922 -+ mmc->max_req_size = mmc->max_seg_size;
14923 - }
14924 -
14925 - static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
14926 -diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
14927 -index 4d17032d15ee..7b530e5a86da 100644
14928 ---- a/drivers/mmc/host/mxcmmc.c
14929 -+++ b/drivers/mmc/host/mxcmmc.c
14930 -@@ -292,11 +292,8 @@ static void mxcmci_swap_buffers(struct mmc_data *data)
14931 - struct scatterlist *sg;
14932 - int i;
14933 -
14934 -- for_each_sg(data->sg, sg, data->sg_len, i) {
14935 -- void *buf = kmap_atomic(sg_page(sg) + sg->offset);
14936 -- buffer_swap32(buf, sg->length);
14937 -- kunmap_atomic(buf);
14938 -- }
14939 -+ for_each_sg(data->sg, sg, data->sg_len, i)
14940 -+ buffer_swap32(sg_virt(sg), sg->length);
14941 - }
14942 - #else
14943 - static inline void mxcmci_swap_buffers(struct mmc_data *data) {}
14944 -@@ -613,7 +610,6 @@ static int mxcmci_transfer_data(struct mxcmci_host *host)
14945 - {
14946 - struct mmc_data *data = host->req->data;
14947 - struct scatterlist *sg;
14948 -- void *buf;
14949 - int stat, i;
14950 -
14951 - host->data = data;
14952 -@@ -621,18 +617,14 @@ static int mxcmci_transfer_data(struct mxcmci_host *host)
14953 -
14954 - if (data->flags & MMC_DATA_READ) {
14955 - for_each_sg(data->sg, sg, data->sg_len, i) {
14956 -- buf = kmap_atomic(sg_page(sg) + sg->offset);
14957 -- stat = mxcmci_pull(host, buf, sg->length);
14958 -- kunmap(buf);
14959 -+ stat = mxcmci_pull(host, sg_virt(sg), sg->length);
14960 - if (stat)
14961 - return stat;
14962 - host->datasize += sg->length;
14963 - }
14964 - } else {
14965 - for_each_sg(data->sg, sg, data->sg_len, i) {
14966 -- buf = kmap_atomic(sg_page(sg) + sg->offset);
14967 -- stat = mxcmci_push(host, buf, sg->length);
14968 -- kunmap(buf);
14969 -+ stat = mxcmci_push(host, sg_virt(sg), sg->length);
14970 - if (stat)
14971 - return stat;
14972 - host->datasize += sg->length;
14973 -diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
14974 -index c60a7625b1fa..b2873a2432b6 100644
14975 ---- a/drivers/mmc/host/omap.c
14976 -+++ b/drivers/mmc/host/omap.c
14977 -@@ -920,7 +920,7 @@ static inline void set_cmd_timeout(struct mmc_omap_host *host, struct mmc_reques
14978 - reg &= ~(1 << 5);
14979 - OMAP_MMC_WRITE(host, SDIO, reg);
14980 - /* Set maximum timeout */
14981 -- OMAP_MMC_WRITE(host, CTO, 0xff);
14982 -+ OMAP_MMC_WRITE(host, CTO, 0xfd);
14983 - }
14984 -
14985 - static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req)
14986 -diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
14987 -index 8779bbaa6b69..194a81888792 100644
14988 ---- a/drivers/mmc/host/pxamci.c
14989 -+++ b/drivers/mmc/host/pxamci.c
14990 -@@ -162,7 +162,7 @@ static void pxamci_dma_irq(void *param);
14991 - static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
14992 - {
14993 - struct dma_async_tx_descriptor *tx;
14994 -- enum dma_data_direction direction;
14995 -+ enum dma_transfer_direction direction;
14996 - struct dma_slave_config config;
14997 - struct dma_chan *chan;
14998 - unsigned int nob = data->blocks;
14999 -diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
15000 -index 31a351a20dc0..d9be22b310e6 100644
15001 ---- a/drivers/mmc/host/renesas_sdhi_core.c
15002 -+++ b/drivers/mmc/host/renesas_sdhi_core.c
15003 -@@ -634,6 +634,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
15004 - struct renesas_sdhi *priv;
15005 - struct resource *res;
15006 - int irq, ret, i;
15007 -+ u16 ver;
15008 -
15009 - of_data = of_device_get_match_data(&pdev->dev);
15010 -
15011 -@@ -723,6 +724,13 @@ int renesas_sdhi_probe(struct platform_device *pdev,
15012 - host->ops.start_signal_voltage_switch =
15013 - renesas_sdhi_start_signal_voltage_switch;
15014 - host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
15015 -+
15016 -+ /* SDR and HS200/400 registers requires HW reset */
15017 -+ if (of_data && of_data->scc_offset) {
15018 -+ priv->scc_ctl = host->ctl + of_data->scc_offset;
15019 -+ host->mmc->caps |= MMC_CAP_HW_RESET;
15020 -+ host->hw_reset = renesas_sdhi_hw_reset;
15021 -+ }
15022 - }
15023 -
15024 - /* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
15025 -@@ -759,12 +767,17 @@ int renesas_sdhi_probe(struct platform_device *pdev,
15026 - if (ret)
15027 - goto efree;
15028 -
15029 -+ ver = sd_ctrl_read16(host, CTL_VERSION);
15030 -+ /* GEN2_SDR104 is first known SDHI to use 32bit block count */
15031 -+ if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)
15032 -+ mmc_data->max_blk_count = U16_MAX;
15033 -+
15034 - ret = tmio_mmc_host_probe(host);
15035 - if (ret < 0)
15036 - goto edisclk;
15037 -
15038 - /* One Gen2 SDHI incarnation does NOT have a CBSY bit */
15039 -- if (sd_ctrl_read16(host, CTL_VERSION) == SDHI_VER_GEN2_SDR50)
15040 -+ if (ver == SDHI_VER_GEN2_SDR50)
15041 - mmc_data->flags &= ~TMIO_MMC_HAVE_CBSY;
15042 -
15043 - /* Enable tuning iff we have an SCC and a supported mode */
15044 -@@ -775,8 +788,6 @@ int renesas_sdhi_probe(struct platform_device *pdev,
15045 - const struct renesas_sdhi_scc *taps = of_data->taps;
15046 - bool hit = false;
15047 -
15048 -- host->mmc->caps |= MMC_CAP_HW_RESET;
15049 --
15050 - for (i = 0; i < of_data->taps_num; i++) {
15051 - if (taps[i].clk_rate == 0 ||
15052 - taps[i].clk_rate == host->mmc->f_max) {
15053 -@@ -789,12 +800,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
15054 - if (!hit)
15055 - dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n");
15056 -
15057 -- priv->scc_ctl = host->ctl + of_data->scc_offset;
15058 - host->init_tuning = renesas_sdhi_init_tuning;
15059 - host->prepare_tuning = renesas_sdhi_prepare_tuning;
15060 - host->select_tuning = renesas_sdhi_select_tuning;
15061 - host->check_scc_error = renesas_sdhi_check_scc_error;
15062 -- host->hw_reset = renesas_sdhi_hw_reset;
15063 - host->prepare_hs400_tuning =
15064 - renesas_sdhi_prepare_hs400_tuning;
15065 - host->hs400_downgrade = renesas_sdhi_disable_scc;
15066 -diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
15067 -index 00d41b312c79..a6f25c796aed 100644
15068 ---- a/drivers/mmc/host/sdhci-esdhc-imx.c
15069 -+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
15070 -@@ -979,6 +979,7 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
15071 - case MMC_TIMING_UHS_SDR25:
15072 - case MMC_TIMING_UHS_SDR50:
15073 - case MMC_TIMING_UHS_SDR104:
15074 -+ case MMC_TIMING_MMC_HS:
15075 - case MMC_TIMING_MMC_HS200:
15076 - writel(m, host->ioaddr + ESDHC_MIX_CTRL);
15077 - break;
15078 -diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
15079 -index c11c18a9aacb..9ec300ec94ba 100644
15080 ---- a/drivers/mmc/host/sdhci-omap.c
15081 -+++ b/drivers/mmc/host/sdhci-omap.c
15082 -@@ -797,6 +797,43 @@ void sdhci_omap_reset(struct sdhci_host *host, u8 mask)
15083 - sdhci_reset(host, mask);
15084 - }
15085 -
15086 -+#define CMD_ERR_MASK (SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX |\
15087 -+ SDHCI_INT_TIMEOUT)
15088 -+#define CMD_MASK (CMD_ERR_MASK | SDHCI_INT_RESPONSE)
15089 -+
15090 -+static u32 sdhci_omap_irq(struct sdhci_host *host, u32 intmask)
15091 -+{
15092 -+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
15093 -+ struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
15094 -+
15095 -+ if (omap_host->is_tuning && host->cmd && !host->data_early &&
15096 -+ (intmask & CMD_ERR_MASK)) {
15097 -+
15098 -+ /*
15099 -+ * Since we are not resetting data lines during tuning
15100 -+ * operation, data error or data complete interrupts
15101 -+ * might still arrive. Mark this request as a failure
15102 -+ * but still wait for the data interrupt
15103 -+ */
15104 -+ if (intmask & SDHCI_INT_TIMEOUT)
15105 -+ host->cmd->error = -ETIMEDOUT;
15106 -+ else
15107 -+ host->cmd->error = -EILSEQ;
15108 -+
15109 -+ host->cmd = NULL;
15110 -+
15111 -+ /*
15112 -+ * Sometimes command error interrupts and command complete
15113 -+ * interrupt will arrive together. Clear all command related
15114 -+ * interrupts here.
15115 -+ */
15116 -+ sdhci_writel(host, intmask & CMD_MASK, SDHCI_INT_STATUS);
15117 -+ intmask &= ~CMD_MASK;
15118 -+ }
15119 -+
15120 -+ return intmask;
15121 -+}
15122 -+
15123 - static struct sdhci_ops sdhci_omap_ops = {
15124 - .set_clock = sdhci_omap_set_clock,
15125 - .set_power = sdhci_omap_set_power,
15126 -@@ -807,6 +844,7 @@ static struct sdhci_ops sdhci_omap_ops = {
15127 - .platform_send_init_74_clocks = sdhci_omap_init_74_clocks,
15128 - .reset = sdhci_omap_reset,
15129 - .set_uhs_signaling = sdhci_omap_set_uhs_signaling,
15130 -+ .irq = sdhci_omap_irq,
15131 - };
15132 -
15133 - static int sdhci_omap_set_capabilities(struct sdhci_omap_host *omap_host)
15134 -diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
15135 -index 21bf8ac78380..390e896dadc7 100644
15136 ---- a/drivers/net/Kconfig
15137 -+++ b/drivers/net/Kconfig
15138 -@@ -213,8 +213,8 @@ config GENEVE
15139 -
15140 - config GTP
15141 - tristate "GPRS Tunneling Protocol datapath (GTP-U)"
15142 -- depends on INET && NET_UDP_TUNNEL
15143 -- select NET_IP_TUNNEL
15144 -+ depends on INET
15145 -+ select NET_UDP_TUNNEL
15146 - ---help---
15147 - This allows one to create gtp virtual interfaces that provide
15148 - the GPRS Tunneling Protocol datapath (GTP-U). This tunneling protocol
15149 -diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
15150 -index ddc1f9ca8ebc..4543ac97f077 100644
15151 ---- a/drivers/net/dsa/lantiq_gswip.c
15152 -+++ b/drivers/net/dsa/lantiq_gswip.c
15153 -@@ -1069,10 +1069,10 @@ static int gswip_probe(struct platform_device *pdev)
15154 - version = gswip_switch_r(priv, GSWIP_VERSION);
15155 -
15156 - /* bring up the mdio bus */
15157 -- gphy_fw_np = of_find_compatible_node(pdev->dev.of_node, NULL,
15158 -- "lantiq,gphy-fw");
15159 -+ gphy_fw_np = of_get_compatible_child(dev->of_node, "lantiq,gphy-fw");
15160 - if (gphy_fw_np) {
15161 - err = gswip_gphy_fw_list(priv, gphy_fw_np, version);
15162 -+ of_node_put(gphy_fw_np);
15163 - if (err) {
15164 - dev_err(dev, "gphy fw probe failed\n");
15165 - return err;
15166 -@@ -1080,13 +1080,12 @@ static int gswip_probe(struct platform_device *pdev)
15167 - }
15168 -
15169 - /* bring up the mdio bus */
15170 -- mdio_np = of_find_compatible_node(pdev->dev.of_node, NULL,
15171 -- "lantiq,xrx200-mdio");
15172 -+ mdio_np = of_get_compatible_child(dev->of_node, "lantiq,xrx200-mdio");
15173 - if (mdio_np) {
15174 - err = gswip_mdio(priv, mdio_np);
15175 - if (err) {
15176 - dev_err(dev, "mdio probe failed\n");
15177 -- goto gphy_fw;
15178 -+ goto put_mdio_node;
15179 - }
15180 - }
15181 -
15182 -@@ -1099,7 +1098,7 @@ static int gswip_probe(struct platform_device *pdev)
15183 - dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
15184 - priv->hw_info->cpu_port);
15185 - err = -EINVAL;
15186 -- goto mdio_bus;
15187 -+ goto disable_switch;
15188 - }
15189 -
15190 - platform_set_drvdata(pdev, priv);
15191 -@@ -1109,10 +1108,14 @@ static int gswip_probe(struct platform_device *pdev)
15192 - (version & GSWIP_VERSION_MOD_MASK) >> GSWIP_VERSION_MOD_SHIFT);
15193 - return 0;
15194 -
15195 -+disable_switch:
15196 -+ gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
15197 -+ dsa_unregister_switch(priv->ds);
15198 - mdio_bus:
15199 - if (mdio_np)
15200 - mdiobus_unregister(priv->ds->slave_mii_bus);
15201 --gphy_fw:
15202 -+put_mdio_node:
15203 -+ of_node_put(mdio_np);
15204 - for (i = 0; i < priv->num_gphy_fw; i++)
15205 - gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
15206 - return err;
15207 -@@ -1131,8 +1134,10 @@ static int gswip_remove(struct platform_device *pdev)
15208 -
15209 - dsa_unregister_switch(priv->ds);
15210 -
15211 -- if (priv->ds->slave_mii_bus)
15212 -+ if (priv->ds->slave_mii_bus) {
15213 - mdiobus_unregister(priv->ds->slave_mii_bus);
15214 -+ of_node_put(priv->ds->slave_mii_bus->dev.of_node);
15215 -+ }
15216 -
15217 - for (i = 0; i < priv->num_gphy_fw; i++)
15218 - gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
15219 -diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
15220 -index 7e3c00bd9532..6cba05a80892 100644
15221 ---- a/drivers/net/dsa/mv88e6xxx/chip.c
15222 -+++ b/drivers/net/dsa/mv88e6xxx/chip.c
15223 -@@ -442,12 +442,20 @@ out_mapping:
15224 -
15225 - static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
15226 - {
15227 -+ static struct lock_class_key lock_key;
15228 -+ static struct lock_class_key request_key;
15229 - int err;
15230 -
15231 - err = mv88e6xxx_g1_irq_setup_common(chip);
15232 - if (err)
15233 - return err;
15234 -
15235 -+ /* These lock classes tells lockdep that global 1 irqs are in
15236 -+ * a different category than their parent GPIO, so it won't
15237 -+ * report false recursion.
15238 -+ */
15239 -+ irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
15240 -+
15241 - err = request_threaded_irq(chip->irq, NULL,
15242 - mv88e6xxx_g1_irq_thread_fn,
15243 - IRQF_ONESHOT | IRQF_SHARED,
15244 -@@ -559,6 +567,9 @@ static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
15245 - goto restore_link;
15246 - }
15247 -
15248 -+ if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
15249 -+ mode = chip->info->ops->port_max_speed_mode(port);
15250 -+
15251 - if (chip->info->ops->port_set_pause) {
15252 - err = chip->info->ops->port_set_pause(chip, port, pause);
15253 - if (err)
15254 -@@ -3042,6 +3053,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
15255 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15256 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15257 - .port_set_speed = mv88e6341_port_set_speed,
15258 -+ .port_max_speed_mode = mv88e6341_port_max_speed_mode,
15259 - .port_tag_remap = mv88e6095_port_tag_remap,
15260 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15261 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15262 -@@ -3360,6 +3372,7 @@ static const struct mv88e6xxx_ops mv88e6190_ops = {
15263 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15264 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15265 - .port_set_speed = mv88e6390_port_set_speed,
15266 -+ .port_max_speed_mode = mv88e6390_port_max_speed_mode,
15267 - .port_tag_remap = mv88e6390_port_tag_remap,
15268 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15269 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15270 -@@ -3404,6 +3417,7 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = {
15271 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15272 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15273 - .port_set_speed = mv88e6390x_port_set_speed,
15274 -+ .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
15275 - .port_tag_remap = mv88e6390_port_tag_remap,
15276 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15277 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15278 -@@ -3448,6 +3462,7 @@ static const struct mv88e6xxx_ops mv88e6191_ops = {
15279 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15280 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15281 - .port_set_speed = mv88e6390_port_set_speed,
15282 -+ .port_max_speed_mode = mv88e6390_port_max_speed_mode,
15283 - .port_tag_remap = mv88e6390_port_tag_remap,
15284 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15285 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15286 -@@ -3541,6 +3556,7 @@ static const struct mv88e6xxx_ops mv88e6290_ops = {
15287 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15288 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15289 - .port_set_speed = mv88e6390_port_set_speed,
15290 -+ .port_max_speed_mode = mv88e6390_port_max_speed_mode,
15291 - .port_tag_remap = mv88e6390_port_tag_remap,
15292 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15293 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15294 -@@ -3672,6 +3688,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {
15295 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15296 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15297 - .port_set_speed = mv88e6341_port_set_speed,
15298 -+ .port_max_speed_mode = mv88e6341_port_max_speed_mode,
15299 - .port_tag_remap = mv88e6095_port_tag_remap,
15300 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15301 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15302 -@@ -3847,6 +3864,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {
15303 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15304 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15305 - .port_set_speed = mv88e6390_port_set_speed,
15306 -+ .port_max_speed_mode = mv88e6390_port_max_speed_mode,
15307 - .port_tag_remap = mv88e6390_port_tag_remap,
15308 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15309 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15310 -@@ -3895,6 +3913,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
15311 - .port_set_duplex = mv88e6xxx_port_set_duplex,
15312 - .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
15313 - .port_set_speed = mv88e6390x_port_set_speed,
15314 -+ .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
15315 - .port_tag_remap = mv88e6390_port_tag_remap,
15316 - .port_set_frame_mode = mv88e6351_port_set_frame_mode,
15317 - .port_set_egress_floods = mv88e6352_port_set_egress_floods,
15318 -@@ -4222,7 +4241,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15319 - .name = "Marvell 88E6190",
15320 - .num_databases = 4096,
15321 - .num_ports = 11, /* 10 + Z80 */
15322 -- .num_internal_phys = 11,
15323 -+ .num_internal_phys = 9,
15324 - .num_gpio = 16,
15325 - .max_vid = 8191,
15326 - .port_base_addr = 0x0,
15327 -@@ -4245,7 +4264,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15328 - .name = "Marvell 88E6190X",
15329 - .num_databases = 4096,
15330 - .num_ports = 11, /* 10 + Z80 */
15331 -- .num_internal_phys = 11,
15332 -+ .num_internal_phys = 9,
15333 - .num_gpio = 16,
15334 - .max_vid = 8191,
15335 - .port_base_addr = 0x0,
15336 -@@ -4268,7 +4287,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15337 - .name = "Marvell 88E6191",
15338 - .num_databases = 4096,
15339 - .num_ports = 11, /* 10 + Z80 */
15340 -- .num_internal_phys = 11,
15341 -+ .num_internal_phys = 9,
15342 - .max_vid = 8191,
15343 - .port_base_addr = 0x0,
15344 - .phy_base_addr = 0x0,
15345 -@@ -4315,7 +4334,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15346 - .name = "Marvell 88E6290",
15347 - .num_databases = 4096,
15348 - .num_ports = 11, /* 10 + Z80 */
15349 -- .num_internal_phys = 11,
15350 -+ .num_internal_phys = 9,
15351 - .num_gpio = 16,
15352 - .max_vid = 8191,
15353 - .port_base_addr = 0x0,
15354 -@@ -4477,7 +4496,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15355 - .name = "Marvell 88E6390",
15356 - .num_databases = 4096,
15357 - .num_ports = 11, /* 10 + Z80 */
15358 -- .num_internal_phys = 11,
15359 -+ .num_internal_phys = 9,
15360 - .num_gpio = 16,
15361 - .max_vid = 8191,
15362 - .port_base_addr = 0x0,
15363 -@@ -4500,7 +4519,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
15364 - .name = "Marvell 88E6390X",
15365 - .num_databases = 4096,
15366 - .num_ports = 11, /* 10 + Z80 */
15367 -- .num_internal_phys = 11,
15368 -+ .num_internal_phys = 9,
15369 - .num_gpio = 16,
15370 - .max_vid = 8191,
15371 - .port_base_addr = 0x0,
15372 -@@ -4847,6 +4866,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
15373 - if (err)
15374 - goto out;
15375 -
15376 -+ mv88e6xxx_ports_cmode_init(chip);
15377 - mv88e6xxx_phy_init(chip);
15378 -
15379 - if (chip->info->ops->get_eeprom) {
15380 -diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
15381 -index 546651d8c3e1..dfb1af65c205 100644
15382 ---- a/drivers/net/dsa/mv88e6xxx/chip.h
15383 -+++ b/drivers/net/dsa/mv88e6xxx/chip.h
15384 -@@ -377,6 +377,9 @@ struct mv88e6xxx_ops {
15385 - */
15386 - int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
15387 -
15388 -+ /* What interface mode should be used for maximum speed? */
15389 -+ phy_interface_t (*port_max_speed_mode)(int port);
15390 -+
15391 - int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
15392 -
15393 - int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
15394 -diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
15395 -index 79ab51e69aee..c44b2822e4dd 100644
15396 ---- a/drivers/net/dsa/mv88e6xxx/port.c
15397 -+++ b/drivers/net/dsa/mv88e6xxx/port.c
15398 -@@ -190,7 +190,7 @@ int mv88e6xxx_port_set_duplex(struct mv88e6xxx_chip *chip, int port, int dup)
15399 - /* normal duplex detection */
15400 - break;
15401 - default:
15402 -- return -EINVAL;
15403 -+ return -EOPNOTSUPP;
15404 - }
15405 -
15406 - err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_MAC_CTL, reg);
15407 -@@ -312,6 +312,14 @@ int mv88e6341_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
15408 - return mv88e6xxx_port_set_speed(chip, port, speed, !port, true);
15409 - }
15410 -
15411 -+phy_interface_t mv88e6341_port_max_speed_mode(int port)
15412 -+{
15413 -+ if (port == 5)
15414 -+ return PHY_INTERFACE_MODE_2500BASEX;
15415 -+
15416 -+ return PHY_INTERFACE_MODE_NA;
15417 -+}
15418 -+
15419 - /* Support 10, 100, 200, 1000 Mbps (e.g. 88E6352 family) */
15420 - int mv88e6352_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
15421 - {
15422 -@@ -345,6 +353,14 @@ int mv88e6390_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
15423 - return mv88e6xxx_port_set_speed(chip, port, speed, true, true);
15424 - }
15425 -
15426 -+phy_interface_t mv88e6390_port_max_speed_mode(int port)
15427 -+{
15428 -+ if (port == 9 || port == 10)
15429 -+ return PHY_INTERFACE_MODE_2500BASEX;
15430 -+
15431 -+ return PHY_INTERFACE_MODE_NA;
15432 -+}
15433 -+
15434 - /* Support 10, 100, 200, 1000, 2500, 10000 Mbps (e.g. 88E6190X) */
15435 - int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
15436 - {
15437 -@@ -360,6 +376,14 @@ int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
15438 - return mv88e6xxx_port_set_speed(chip, port, speed, true, true);
15439 - }
15440 -
15441 -+phy_interface_t mv88e6390x_port_max_speed_mode(int port)
15442 -+{
15443 -+ if (port == 9 || port == 10)
15444 -+ return PHY_INTERFACE_MODE_XAUI;
15445 -+
15446 -+ return PHY_INTERFACE_MODE_NA;
15447 -+}
15448 -+
15449 - int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
15450 - phy_interface_t mode)
15451 - {
15452 -@@ -403,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
15453 - return 0;
15454 -
15455 - lane = mv88e6390x_serdes_get_lane(chip, port);
15456 -- if (lane < 0)
15457 -+ if (lane < 0 && lane != -ENODEV)
15458 - return lane;
15459 -
15460 -- if (chip->ports[port].serdes_irq) {
15461 -- err = mv88e6390_serdes_irq_disable(chip, port, lane);
15462 -+ if (lane >= 0) {
15463 -+ if (chip->ports[port].serdes_irq) {
15464 -+ err = mv88e6390_serdes_irq_disable(chip, port, lane);
15465 -+ if (err)
15466 -+ return err;
15467 -+ }
15468 -+
15469 -+ err = mv88e6390x_serdes_power(chip, port, false);
15470 - if (err)
15471 - return err;
15472 - }
15473 -
15474 -- err = mv88e6390x_serdes_power(chip, port, false);
15475 -- if (err)
15476 -- return err;
15477 -+ chip->ports[port].cmode = 0;
15478 -
15479 - if (cmode) {
15480 - err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
15481 -@@ -428,6 +456,12 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
15482 - if (err)
15483 - return err;
15484 -
15485 -+ chip->ports[port].cmode = cmode;
15486 -+
15487 -+ lane = mv88e6390x_serdes_get_lane(chip, port);
15488 -+ if (lane < 0)
15489 -+ return lane;
15490 -+
15491 - err = mv88e6390x_serdes_power(chip, port, true);
15492 - if (err)
15493 - return err;
15494 -@@ -439,8 +473,6 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
15495 - }
15496 - }
15497 -
15498 -- chip->ports[port].cmode = cmode;
15499 --
15500 - return 0;
15501 - }
15502 -
15503 -@@ -448,6 +480,8 @@ int mv88e6390_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
15504 - phy_interface_t mode)
15505 - {
15506 - switch (mode) {
15507 -+ case PHY_INTERFACE_MODE_NA:
15508 -+ return 0;
15509 - case PHY_INTERFACE_MODE_XGMII:
15510 - case PHY_INTERFACE_MODE_XAUI:
15511 - case PHY_INTERFACE_MODE_RXAUI:
15512 -diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h
15513 -index 4aadf321edb7..c7bed263a0f4 100644
15514 ---- a/drivers/net/dsa/mv88e6xxx/port.h
15515 -+++ b/drivers/net/dsa/mv88e6xxx/port.h
15516 -@@ -285,6 +285,10 @@ int mv88e6352_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
15517 - int mv88e6390_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
15518 - int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
15519 -
15520 -+phy_interface_t mv88e6341_port_max_speed_mode(int port);
15521 -+phy_interface_t mv88e6390_port_max_speed_mode(int port);
15522 -+phy_interface_t mv88e6390x_port_max_speed_mode(int port);
15523 -+
15524 - int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state);
15525 -
15526 - int mv88e6xxx_port_set_vlan_map(struct mv88e6xxx_chip *chip, int port, u16 map);
15527 -diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
15528 -index 7e97e620bd44..a26850c888cf 100644
15529 ---- a/drivers/net/dsa/qca8k.c
15530 -+++ b/drivers/net/dsa/qca8k.c
15531 -@@ -620,22 +620,6 @@ qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy)
15532 - qca8k_port_set_status(priv, port, 1);
15533 - }
15534 -
15535 --static int
15536 --qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum)
15537 --{
15538 -- struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
15539 --
15540 -- return mdiobus_read(priv->bus, phy, regnum);
15541 --}
15542 --
15543 --static int
15544 --qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val)
15545 --{
15546 -- struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
15547 --
15548 -- return mdiobus_write(priv->bus, phy, regnum, val);
15549 --}
15550 --
15551 - static void
15552 - qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data)
15553 - {
15554 -@@ -876,8 +860,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = {
15555 - .setup = qca8k_setup,
15556 - .adjust_link = qca8k_adjust_link,
15557 - .get_strings = qca8k_get_strings,
15558 -- .phy_read = qca8k_phy_read,
15559 -- .phy_write = qca8k_phy_write,
15560 - .get_ethtool_stats = qca8k_get_ethtool_stats,
15561 - .get_sset_count = qca8k_get_sset_count,
15562 - .get_mac_eee = qca8k_get_mac_eee,
15563 -diff --git a/drivers/net/ethernet/8390/mac8390.c b/drivers/net/ethernet/8390/mac8390.c
15564 -index 342ae08ec3c2..d60a86aa8aa8 100644
15565 ---- a/drivers/net/ethernet/8390/mac8390.c
15566 -+++ b/drivers/net/ethernet/8390/mac8390.c
15567 -@@ -153,8 +153,6 @@ static void dayna_block_input(struct net_device *dev, int count,
15568 - static void dayna_block_output(struct net_device *dev, int count,
15569 - const unsigned char *buf, int start_page);
15570 -
15571 --#define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c))
15572 --
15573 - /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
15574 - static void slow_sane_get_8390_hdr(struct net_device *dev,
15575 - struct e8390_pkt_hdr *hdr, int ring_page);
15576 -@@ -233,19 +231,26 @@ static enum mac8390_type mac8390_ident(struct nubus_rsrc *fres)
15577 -
15578 - static enum mac8390_access mac8390_testio(unsigned long membase)
15579 - {
15580 -- unsigned long outdata = 0xA5A0B5B0;
15581 -- unsigned long indata = 0x00000000;
15582 -+ u32 outdata = 0xA5A0B5B0;
15583 -+ u32 indata = 0;
15584 -+
15585 - /* Try writing 32 bits */
15586 -- memcpy_toio((void __iomem *)membase, &outdata, 4);
15587 -- /* Now compare them */
15588 -- if (memcmp_withio(&outdata, membase, 4) == 0)
15589 -+ nubus_writel(outdata, membase);
15590 -+ /* Now read it back */
15591 -+ indata = nubus_readl(membase);
15592 -+ if (outdata == indata)
15593 - return ACCESS_32;
15594 -+
15595 -+ outdata = 0xC5C0D5D0;
15596 -+ indata = 0;
15597 -+
15598 - /* Write 16 bit output */
15599 - word_memcpy_tocard(membase, &outdata, 4);
15600 - /* Now read it back */
15601 - word_memcpy_fromcard(&indata, membase, 4);
15602 - if (outdata == indata)
15603 - return ACCESS_16;
15604 -+
15605 - return ACCESS_UNKNOWN;
15606 - }
15607 -
15608 -diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
15609 -index 74550ccc7a20..e2ffb159cbe2 100644
15610 ---- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
15611 -+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
15612 -@@ -186,11 +186,12 @@ static void aq_rx_checksum(struct aq_ring_s *self,
15613 - }
15614 - if (buff->is_ip_cso) {
15615 - __skb_incr_checksum_unnecessary(skb);
15616 -- if (buff->is_udp_cso || buff->is_tcp_cso)
15617 -- __skb_incr_checksum_unnecessary(skb);
15618 - } else {
15619 - skb->ip_summed = CHECKSUM_NONE;
15620 - }
15621 -+
15622 -+ if (buff->is_udp_cso || buff->is_tcp_cso)
15623 -+ __skb_incr_checksum_unnecessary(skb);
15624 - }
15625 -
15626 - #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
15627 -diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
15628 -index 803f7990d32b..40ca339ec3df 100644
15629 ---- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
15630 -+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
15631 -@@ -1129,6 +1129,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
15632 - tpa_info = &rxr->rx_tpa[agg_id];
15633 -
15634 - if (unlikely(cons != rxr->rx_next_cons)) {
15635 -+ netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n",
15636 -+ cons, rxr->rx_next_cons);
15637 - bnxt_sched_reset(bp, rxr);
15638 - return;
15639 - }
15640 -@@ -1581,15 +1583,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
15641 - }
15642 -
15643 - cons = rxcmp->rx_cmp_opaque;
15644 -- rx_buf = &rxr->rx_buf_ring[cons];
15645 -- data = rx_buf->data;
15646 -- data_ptr = rx_buf->data_ptr;
15647 - if (unlikely(cons != rxr->rx_next_cons)) {
15648 - int rc1 = bnxt_discard_rx(bp, cpr, raw_cons, rxcmp);
15649 -
15650 -+ netdev_warn(bp->dev, "RX cons %x != expected cons %x\n",
15651 -+ cons, rxr->rx_next_cons);
15652 - bnxt_sched_reset(bp, rxr);
15653 - return rc1;
15654 - }
15655 -+ rx_buf = &rxr->rx_buf_ring[cons];
15656 -+ data = rx_buf->data;
15657 -+ data_ptr = rx_buf->data_ptr;
15658 - prefetch(data_ptr);
15659 -
15660 - misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1);
15661 -@@ -1606,11 +1610,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
15662 -
15663 - rx_buf->data = NULL;
15664 - if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) {
15665 -+ u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2);
15666 -+
15667 - bnxt_reuse_rx_data(rxr, cons, data);
15668 - if (agg_bufs)
15669 - bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs);
15670 -
15671 - rc = -EIO;
15672 -+ if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
15673 -+ netdev_warn(bp->dev, "RX buffer error %x\n", rx_err);
15674 -+ bnxt_sched_reset(bp, rxr);
15675 -+ }
15676 - goto next_rx;
15677 - }
15678 -
15679 -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
15680 -index 503cfadff4ac..d4ee9f9c8c34 100644
15681 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
15682 -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
15683 -@@ -1328,10 +1328,11 @@ int nicvf_stop(struct net_device *netdev)
15684 - struct nicvf_cq_poll *cq_poll = NULL;
15685 - union nic_mbx mbx = {};
15686 -
15687 -- cancel_delayed_work_sync(&nic->link_change_work);
15688 --
15689 - /* wait till all queued set_rx_mode tasks completes */
15690 -- drain_workqueue(nic->nicvf_rx_mode_wq);
15691 -+ if (nic->nicvf_rx_mode_wq) {
15692 -+ cancel_delayed_work_sync(&nic->link_change_work);
15693 -+ drain_workqueue(nic->nicvf_rx_mode_wq);
15694 -+ }
15695 -
15696 - mbx.msg.msg = NIC_MBOX_MSG_SHUTDOWN;
15697 - nicvf_send_msg_to_pf(nic, &mbx);
15698 -@@ -1452,7 +1453,8 @@ int nicvf_open(struct net_device *netdev)
15699 - struct nicvf_cq_poll *cq_poll = NULL;
15700 -
15701 - /* wait till all queued set_rx_mode tasks completes if any */
15702 -- drain_workqueue(nic->nicvf_rx_mode_wq);
15703 -+ if (nic->nicvf_rx_mode_wq)
15704 -+ drain_workqueue(nic->nicvf_rx_mode_wq);
15705 -
15706 - netif_carrier_off(netdev);
15707 -
15708 -@@ -1550,10 +1552,12 @@ int nicvf_open(struct net_device *netdev)
15709 - /* Send VF config done msg to PF */
15710 - nicvf_send_cfg_done(nic);
15711 -
15712 -- INIT_DELAYED_WORK(&nic->link_change_work,
15713 -- nicvf_link_status_check_task);
15714 -- queue_delayed_work(nic->nicvf_rx_mode_wq,
15715 -- &nic->link_change_work, 0);
15716 -+ if (nic->nicvf_rx_mode_wq) {
15717 -+ INIT_DELAYED_WORK(&nic->link_change_work,
15718 -+ nicvf_link_status_check_task);
15719 -+ queue_delayed_work(nic->nicvf_rx_mode_wq,
15720 -+ &nic->link_change_work, 0);
15721 -+ }
15722 -
15723 - return 0;
15724 - cleanup:
15725 -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
15726 -index 5b4d3badcb73..e246f9733bb8 100644
15727 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
15728 -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
15729 -@@ -105,20 +105,19 @@ static inline struct pgcache *nicvf_alloc_page(struct nicvf *nic,
15730 - /* Check if page can be recycled */
15731 - if (page) {
15732 - ref_count = page_ref_count(page);
15733 -- /* Check if this page has been used once i.e 'put_page'
15734 -- * called after packet transmission i.e internal ref_count
15735 -- * and page's ref_count are equal i.e page can be recycled.
15736 -+ /* This page can be recycled if internal ref_count and page's
15737 -+ * ref_count are equal, indicating that the page has been used
15738 -+ * once for packet transmission. For non-XDP mode, internal
15739 -+ * ref_count is always '1'.
15740 - */
15741 -- if (rbdr->is_xdp && (ref_count == pgcache->ref_count))
15742 -- pgcache->ref_count--;
15743 -- else
15744 -- page = NULL;
15745 --
15746 -- /* In non-XDP mode, page's ref_count needs to be '1' for it
15747 -- * to be recycled.
15748 -- */
15749 -- if (!rbdr->is_xdp && (ref_count != 1))
15750 -+ if (rbdr->is_xdp) {
15751 -+ if (ref_count == pgcache->ref_count)
15752 -+ pgcache->ref_count--;
15753 -+ else
15754 -+ page = NULL;
15755 -+ } else if (ref_count != 1) {
15756 - page = NULL;
15757 -+ }
15758 - }
15759 -
15760 - if (!page) {
15761 -@@ -365,11 +364,10 @@ static void nicvf_free_rbdr(struct nicvf *nic, struct rbdr *rbdr)
15762 - while (head < rbdr->pgcnt) {
15763 - pgcache = &rbdr->pgcache[head];
15764 - if (pgcache->page && page_ref_count(pgcache->page) != 0) {
15765 -- if (!rbdr->is_xdp) {
15766 -- put_page(pgcache->page);
15767 -- continue;
15768 -+ if (rbdr->is_xdp) {
15769 -+ page_ref_sub(pgcache->page,
15770 -+ pgcache->ref_count - 1);
15771 - }
15772 -- page_ref_sub(pgcache->page, pgcache->ref_count - 1);
15773 - put_page(pgcache->page);
15774 - }
15775 - head++;
15776 -diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
15777 -index 9a7f70db20c7..733d9172425b 100644
15778 ---- a/drivers/net/ethernet/cisco/enic/enic_main.c
15779 -+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
15780 -@@ -119,7 +119,7 @@ static void enic_init_affinity_hint(struct enic *enic)
15781 -
15782 - for (i = 0; i < enic->intr_count; i++) {
15783 - if (enic_is_err_intr(enic, i) || enic_is_notify_intr(enic, i) ||
15784 -- (enic->msix[i].affinity_mask &&
15785 -+ (cpumask_available(enic->msix[i].affinity_mask) &&
15786 - !cpumask_empty(enic->msix[i].affinity_mask)))
15787 - continue;
15788 - if (zalloc_cpumask_var(&enic->msix[i].affinity_mask,
15789 -@@ -148,7 +148,7 @@ static void enic_set_affinity_hint(struct enic *enic)
15790 - for (i = 0; i < enic->intr_count; i++) {
15791 - if (enic_is_err_intr(enic, i) ||
15792 - enic_is_notify_intr(enic, i) ||
15793 -- !enic->msix[i].affinity_mask ||
15794 -+ !cpumask_available(enic->msix[i].affinity_mask) ||
15795 - cpumask_empty(enic->msix[i].affinity_mask))
15796 - continue;
15797 - err = irq_set_affinity_hint(enic->msix_entry[i].vector,
15798 -@@ -161,7 +161,7 @@ static void enic_set_affinity_hint(struct enic *enic)
15799 - for (i = 0; i < enic->wq_count; i++) {
15800 - int wq_intr = enic_msix_wq_intr(enic, i);
15801 -
15802 -- if (enic->msix[wq_intr].affinity_mask &&
15803 -+ if (cpumask_available(enic->msix[wq_intr].affinity_mask) &&
15804 - !cpumask_empty(enic->msix[wq_intr].affinity_mask))
15805 - netif_set_xps_queue(enic->netdev,
15806 - enic->msix[wq_intr].affinity_mask,
15807 -diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
15808 -index 36eab37d8a40..09c774fe8853 100644
15809 ---- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
15810 -+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
15811 -@@ -192,6 +192,7 @@ struct hnae3_ae_dev {
15812 - const struct hnae3_ae_ops *ops;
15813 - struct list_head node;
15814 - u32 flag;
15815 -+ u8 override_pci_need_reset; /* fix to stop multiple reset happening */
15816 - enum hnae3_dev_type dev_type;
15817 - enum hnae3_reset_type reset_type;
15818 - void *priv;
15819 -diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
15820 -index 1bf7a5f116a0..d84c50068f66 100644
15821 ---- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
15822 -+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
15823 -@@ -1852,7 +1852,9 @@ static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
15824 -
15825 - /* request the reset */
15826 - if (ae_dev->ops->reset_event) {
15827 -- ae_dev->ops->reset_event(pdev, NULL);
15828 -+ if (!ae_dev->override_pci_need_reset)
15829 -+ ae_dev->ops->reset_event(pdev, NULL);
15830 -+
15831 - return PCI_ERS_RESULT_RECOVERED;
15832 - }
15833 -
15834 -@@ -2476,6 +2478,8 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
15835 - desc = &ring->desc[ring->next_to_clean];
15836 - desc_cb = &ring->desc_cb[ring->next_to_clean];
15837 - bd_base_info = le32_to_cpu(desc->rx.bd_base_info);
15838 -+ /* make sure HW write desc complete */
15839 -+ dma_rmb();
15840 - if (!hnae3_get_bit(bd_base_info, HNS3_RXD_VLD_B))
15841 - return -ENXIO;
15842 -
15843 -diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
15844 -index d0f654123b9b..3ea72e4d9dc4 100644
15845 ---- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
15846 -+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
15847 -@@ -1094,10 +1094,10 @@ static int hclge_log_rocee_ovf_error(struct hclge_dev *hdev)
15848 - return 0;
15849 - }
15850 -
15851 --static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
15852 -+static enum hnae3_reset_type
15853 -+hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
15854 - {
15855 -- enum hnae3_reset_type reset_type = HNAE3_FUNC_RESET;
15856 -- struct hnae3_ae_dev *ae_dev = hdev->ae_dev;
15857 -+ enum hnae3_reset_type reset_type = HNAE3_NONE_RESET;
15858 - struct device *dev = &hdev->pdev->dev;
15859 - struct hclge_desc desc[2];
15860 - unsigned int status;
15861 -@@ -1110,17 +1110,20 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
15862 - if (ret) {
15863 - dev_err(dev, "failed(%d) to query ROCEE RAS INT SRC\n", ret);
15864 - /* reset everything for now */
15865 -- HCLGE_SET_DEFAULT_RESET_REQUEST(HNAE3_GLOBAL_RESET);
15866 -- return ret;
15867 -+ return HNAE3_GLOBAL_RESET;
15868 - }
15869 -
15870 - status = le32_to_cpu(desc[0].data[0]);
15871 -
15872 -- if (status & HCLGE_ROCEE_RERR_INT_MASK)
15873 -+ if (status & HCLGE_ROCEE_RERR_INT_MASK) {
15874 - dev_warn(dev, "ROCEE RAS AXI rresp error\n");
15875 -+ reset_type = HNAE3_FUNC_RESET;
15876 -+ }
15877 -
15878 -- if (status & HCLGE_ROCEE_BERR_INT_MASK)
15879 -+ if (status & HCLGE_ROCEE_BERR_INT_MASK) {
15880 - dev_warn(dev, "ROCEE RAS AXI bresp error\n");
15881 -+ reset_type = HNAE3_FUNC_RESET;
15882 -+ }
15883 -
15884 - if (status & HCLGE_ROCEE_ECC_INT_MASK) {
15885 - dev_warn(dev, "ROCEE RAS 2bit ECC error\n");
15886 -@@ -1132,9 +1135,9 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
15887 - if (ret) {
15888 - dev_err(dev, "failed(%d) to process ovf error\n", ret);
15889 - /* reset everything for now */
15890 -- HCLGE_SET_DEFAULT_RESET_REQUEST(HNAE3_GLOBAL_RESET);
15891 -- return ret;
15892 -+ return HNAE3_GLOBAL_RESET;
15893 - }
15894 -+ reset_type = HNAE3_FUNC_RESET;
15895 - }
15896 -
15897 - /* clear error status */
15898 -@@ -1143,12 +1146,10 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
15899 - if (ret) {
15900 - dev_err(dev, "failed(%d) to clear ROCEE RAS error\n", ret);
15901 - /* reset everything for now */
15902 -- reset_type = HNAE3_GLOBAL_RESET;
15903 -+ return HNAE3_GLOBAL_RESET;
15904 - }
15905 -
15906 -- HCLGE_SET_DEFAULT_RESET_REQUEST(reset_type);
15907 --
15908 -- return ret;
15909 -+ return reset_type;
15910 - }
15911 -
15912 - static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en)
15913 -@@ -1178,15 +1179,18 @@ static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en)
15914 - return ret;
15915 - }
15916 -
15917 --static int hclge_handle_rocee_ras_error(struct hnae3_ae_dev *ae_dev)
15918 -+static void hclge_handle_rocee_ras_error(struct hnae3_ae_dev *ae_dev)
15919 - {
15920 -+ enum hnae3_reset_type reset_type = HNAE3_NONE_RESET;
15921 - struct hclge_dev *hdev = ae_dev->priv;
15922 -
15923 - if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
15924 - hdev->pdev->revision < 0x21)
15925 -- return HNAE3_NONE_RESET;
15926 -+ return;
15927 -
15928 -- return hclge_log_and_clear_rocee_ras_error(hdev);
15929 -+ reset_type = hclge_log_and_clear_rocee_ras_error(hdev);
15930 -+ if (reset_type != HNAE3_NONE_RESET)
15931 -+ HCLGE_SET_DEFAULT_RESET_REQUEST(reset_type);
15932 - }
15933 -
15934 - static const struct hclge_hw_blk hw_blk[] = {
15935 -@@ -1259,8 +1263,10 @@ pci_ers_result_t hclge_handle_hw_ras_error(struct hnae3_ae_dev *ae_dev)
15936 - hclge_handle_all_ras_errors(hdev);
15937 - } else {
15938 - if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
15939 -- hdev->pdev->revision < 0x21)
15940 -+ hdev->pdev->revision < 0x21) {
15941 -+ ae_dev->override_pci_need_reset = 1;
15942 - return PCI_ERS_RESULT_RECOVERED;
15943 -+ }
15944 - }
15945 -
15946 - if (status & HCLGE_RAS_REG_ROCEE_ERR_MASK) {
15947 -@@ -1269,8 +1275,11 @@ pci_ers_result_t hclge_handle_hw_ras_error(struct hnae3_ae_dev *ae_dev)
15948 - }
15949 -
15950 - if (status & HCLGE_RAS_REG_NFE_MASK ||
15951 -- status & HCLGE_RAS_REG_ROCEE_ERR_MASK)
15952 -+ status & HCLGE_RAS_REG_ROCEE_ERR_MASK) {
15953 -+ ae_dev->override_pci_need_reset = 0;
15954 - return PCI_ERS_RESULT_NEED_RESET;
15955 -+ }
15956 -+ ae_dev->override_pci_need_reset = 1;
15957 -
15958 - return PCI_ERS_RESULT_RECOVERED;
15959 - }
15960 -diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
15961 -index 5ecbb1adcf3b..51cfe95f3e24 100644
15962 ---- a/drivers/net/ethernet/ibm/ibmvnic.c
15963 -+++ b/drivers/net/ethernet/ibm/ibmvnic.c
15964 -@@ -1885,6 +1885,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter,
15965 - */
15966 - adapter->state = VNIC_PROBED;
15967 -
15968 -+ reinit_completion(&adapter->init_done);
15969 - rc = init_crq_queue(adapter);
15970 - if (rc) {
15971 - netdev_err(adapter->netdev,
15972 -@@ -4625,7 +4626,7 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter)
15973 - old_num_rx_queues = adapter->req_rx_queues;
15974 - old_num_tx_queues = adapter->req_tx_queues;
15975 -
15976 -- init_completion(&adapter->init_done);
15977 -+ reinit_completion(&adapter->init_done);
15978 - adapter->init_done_rc = 0;
15979 - ibmvnic_send_crq_init(adapter);
15980 - if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
15981 -@@ -4680,7 +4681,6 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
15982 -
15983 - adapter->from_passive_init = false;
15984 -
15985 -- init_completion(&adapter->init_done);
15986 - adapter->init_done_rc = 0;
15987 - ibmvnic_send_crq_init(adapter);
15988 - if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
15989 -@@ -4759,6 +4759,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
15990 - INIT_WORK(&adapter->ibmvnic_reset, __ibmvnic_reset);
15991 - INIT_LIST_HEAD(&adapter->rwi_list);
15992 - spin_lock_init(&adapter->rwi_lock);
15993 -+ init_completion(&adapter->init_done);
15994 - adapter->resetting = false;
15995 -
15996 - adapter->mac_change_pending = false;
15997 -diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
15998 -index 189f231075c2..7acc61e4f645 100644
15999 ---- a/drivers/net/ethernet/intel/e1000e/netdev.c
16000 -+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
16001 -@@ -2106,7 +2106,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
16002 - if (strlen(netdev->name) < (IFNAMSIZ - 5))
16003 - snprintf(adapter->rx_ring->name,
16004 - sizeof(adapter->rx_ring->name) - 1,
16005 -- "%s-rx-0", netdev->name);
16006 -+ "%.14s-rx-0", netdev->name);
16007 - else
16008 - memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
16009 - err = request_irq(adapter->msix_entries[vector].vector,
16010 -@@ -2122,7 +2122,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
16011 - if (strlen(netdev->name) < (IFNAMSIZ - 5))
16012 - snprintf(adapter->tx_ring->name,
16013 - sizeof(adapter->tx_ring->name) - 1,
16014 -- "%s-tx-0", netdev->name);
16015 -+ "%.14s-tx-0", netdev->name);
16016 - else
16017 - memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
16018 - err = request_irq(adapter->msix_entries[vector].vector,
16019 -@@ -5309,8 +5309,13 @@ static void e1000_watchdog_task(struct work_struct *work)
16020 - /* 8000ES2LAN requires a Rx packet buffer work-around
16021 - * on link down event; reset the controller to flush
16022 - * the Rx packet buffer.
16023 -+ *
16024 -+ * If the link is lost the controller stops DMA, but
16025 -+ * if there is queued Tx work it cannot be done. So
16026 -+ * reset the controller to flush the Tx packet buffers.
16027 - */
16028 -- if (adapter->flags & FLAG_RX_NEEDS_RESTART)
16029 -+ if ((adapter->flags & FLAG_RX_NEEDS_RESTART) ||
16030 -+ e1000_desc_unused(tx_ring) + 1 < tx_ring->count)
16031 - adapter->flags |= FLAG_RESTART_NOW;
16032 - else
16033 - pm_schedule_suspend(netdev->dev.parent,
16034 -@@ -5333,14 +5338,6 @@ link_up:
16035 - adapter->gotc_old = adapter->stats.gotc;
16036 - spin_unlock(&adapter->stats64_lock);
16037 -
16038 -- /* If the link is lost the controller stops DMA, but
16039 -- * if there is queued Tx work it cannot be done. So
16040 -- * reset the controller to flush the Tx packet buffers.
16041 -- */
16042 -- if (!netif_carrier_ok(netdev) &&
16043 -- (e1000_desc_unused(tx_ring) + 1 < tx_ring->count))
16044 -- adapter->flags |= FLAG_RESTART_NOW;
16045 --
16046 - /* If reset is necessary, do it outside of interrupt context. */
16047 - if (adapter->flags & FLAG_RESTART_NOW) {
16048 - schedule_work(&adapter->reset_task);
16049 -@@ -7351,6 +7348,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
16050 -
16051 - e1000_print_device_info(adapter);
16052 -
16053 -+ dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);
16054 -+
16055 - if (pci_dev_run_wake(pdev))
16056 - pm_runtime_put_noidle(&pdev->dev);
16057 -
16058 -diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
16059 -index 2e5693107fa4..8d602247eb44 100644
16060 ---- a/drivers/net/ethernet/intel/ice/ice_switch.c
16061 -+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
16062 -@@ -1538,9 +1538,20 @@ ice_remove_rule_internal(struct ice_hw *hw, u8 recp_id,
16063 - } else if (!list_elem->vsi_list_info) {
16064 - status = ICE_ERR_DOES_NOT_EXIST;
16065 - goto exit;
16066 -+ } else if (list_elem->vsi_list_info->ref_cnt > 1) {
16067 -+ /* a ref_cnt > 1 indicates that the vsi_list is being
16068 -+ * shared by multiple rules. Decrement the ref_cnt and
16069 -+ * remove this rule, but do not modify the list, as it
16070 -+ * is in-use by other rules.
16071 -+ */
16072 -+ list_elem->vsi_list_info->ref_cnt--;
16073 -+ remove_rule = true;
16074 - } else {
16075 -- if (list_elem->vsi_list_info->ref_cnt > 1)
16076 -- list_elem->vsi_list_info->ref_cnt--;
16077 -+ /* a ref_cnt of 1 indicates the vsi_list is only used
16078 -+ * by one rule. However, the original removal request is only
16079 -+ * for a single VSI. Update the vsi_list first, and only
16080 -+ * remove the rule if there are no further VSIs in this list.
16081 -+ */
16082 - vsi_handle = f_entry->fltr_info.vsi_handle;
16083 - status = ice_rem_update_vsi_list(hw, vsi_handle, list_elem);
16084 - if (status)
16085 -diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
16086 -index 16066c2d5b3a..931beac3359d 100644
16087 ---- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
16088 -+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
16089 -@@ -1380,13 +1380,9 @@ static void mvpp2_port_reset(struct mvpp2_port *port)
16090 - for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
16091 - mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
16092 -
16093 -- val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
16094 -- ~MVPP2_GMAC_PORT_RESET_MASK;
16095 -+ val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) |
16096 -+ MVPP2_GMAC_PORT_RESET_MASK;
16097 - writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
16098 --
16099 -- while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
16100 -- MVPP2_GMAC_PORT_RESET_MASK)
16101 -- continue;
16102 - }
16103 -
16104 - /* Change maximum receive size of the port */
16105 -@@ -4543,12 +4539,15 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
16106 - const struct phylink_link_state *state)
16107 - {
16108 - u32 an, ctrl0, ctrl2, ctrl4;
16109 -+ u32 old_ctrl2;
16110 -
16111 - an = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
16112 - ctrl0 = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
16113 - ctrl2 = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
16114 - ctrl4 = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
16115 -
16116 -+ old_ctrl2 = ctrl2;
16117 -+
16118 - /* Force link down */
16119 - an &= ~MVPP2_GMAC_FORCE_LINK_PASS;
16120 - an |= MVPP2_GMAC_FORCE_LINK_DOWN;
16121 -@@ -4621,6 +4620,12 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
16122 - writel(ctrl2, port->base + MVPP2_GMAC_CTRL_2_REG);
16123 - writel(ctrl4, port->base + MVPP22_GMAC_CTRL_4_REG);
16124 - writel(an, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
16125 -+
16126 -+ if (old_ctrl2 & MVPP2_GMAC_PORT_RESET_MASK) {
16127 -+ while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
16128 -+ MVPP2_GMAC_PORT_RESET_MASK)
16129 -+ continue;
16130 -+ }
16131 - }
16132 -
16133 - static void mvpp2_mac_config(struct net_device *dev, unsigned int mode,
16134 -diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
16135 -index 57727fe1501e..8b3495ee2b6e 100644
16136 ---- a/drivers/net/ethernet/marvell/sky2.c
16137 -+++ b/drivers/net/ethernet/marvell/sky2.c
16138 -@@ -46,6 +46,7 @@
16139 - #include <linux/mii.h>
16140 - #include <linux/of_device.h>
16141 - #include <linux/of_net.h>
16142 -+#include <linux/dmi.h>
16143 -
16144 - #include <asm/irq.h>
16145 -
16146 -@@ -93,7 +94,7 @@ static int copybreak __read_mostly = 128;
16147 - module_param(copybreak, int, 0);
16148 - MODULE_PARM_DESC(copybreak, "Receive copy threshold");
16149 -
16150 --static int disable_msi = 0;
16151 -+static int disable_msi = -1;
16152 - module_param(disable_msi, int, 0);
16153 - MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
16154 -
16155 -@@ -4917,6 +4918,24 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
16156 - return buf;
16157 - }
16158 -
16159 -+static const struct dmi_system_id msi_blacklist[] = {
16160 -+ {
16161 -+ .ident = "Dell Inspiron 1545",
16162 -+ .matches = {
16163 -+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
16164 -+ DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1545"),
16165 -+ },
16166 -+ },
16167 -+ {
16168 -+ .ident = "Gateway P-79",
16169 -+ .matches = {
16170 -+ DMI_MATCH(DMI_SYS_VENDOR, "Gateway"),
16171 -+ DMI_MATCH(DMI_PRODUCT_NAME, "P-79"),
16172 -+ },
16173 -+ },
16174 -+ {}
16175 -+};
16176 -+
16177 - static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
16178 - {
16179 - struct net_device *dev, *dev1;
16180 -@@ -5028,6 +5047,9 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
16181 - goto err_out_free_pci;
16182 - }
16183 -
16184 -+ if (disable_msi == -1)
16185 -+ disable_msi = !!dmi_check_system(msi_blacklist);
16186 -+
16187 - if (!disable_msi && pci_enable_msi(pdev) == 0) {
16188 - err = sky2_test_msi(hw);
16189 - if (err) {
16190 -diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
16191 -index e65bc3c95630..857588e2488d 100644
16192 ---- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
16193 -+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
16194 -@@ -2645,6 +2645,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
16195 - if (!priv->cmd.context)
16196 - return -ENOMEM;
16197 -
16198 -+ if (mlx4_is_mfunc(dev))
16199 -+ mutex_lock(&priv->cmd.slave_cmd_mutex);
16200 - down_write(&priv->cmd.switch_sem);
16201 - for (i = 0; i < priv->cmd.max_cmds; ++i) {
16202 - priv->cmd.context[i].token = i;
16203 -@@ -2670,6 +2672,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
16204 - down(&priv->cmd.poll_sem);
16205 - priv->cmd.use_events = 1;
16206 - up_write(&priv->cmd.switch_sem);
16207 -+ if (mlx4_is_mfunc(dev))
16208 -+ mutex_unlock(&priv->cmd.slave_cmd_mutex);
16209 -
16210 - return err;
16211 - }
16212 -@@ -2682,6 +2686,8 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
16213 - struct mlx4_priv *priv = mlx4_priv(dev);
16214 - int i;
16215 -
16216 -+ if (mlx4_is_mfunc(dev))
16217 -+ mutex_lock(&priv->cmd.slave_cmd_mutex);
16218 - down_write(&priv->cmd.switch_sem);
16219 - priv->cmd.use_events = 0;
16220 -
16221 -@@ -2689,9 +2695,12 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
16222 - down(&priv->cmd.event_sem);
16223 -
16224 - kfree(priv->cmd.context);
16225 -+ priv->cmd.context = NULL;
16226 -
16227 - up(&priv->cmd.poll_sem);
16228 - up_write(&priv->cmd.switch_sem);
16229 -+ if (mlx4_is_mfunc(dev))
16230 -+ mutex_unlock(&priv->cmd.slave_cmd_mutex);
16231 - }
16232 -
16233 - struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)
16234 -diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
16235 -index eb13d3618162..4356f3a58002 100644
16236 ---- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
16237 -+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
16238 -@@ -2719,13 +2719,13 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc)
16239 - int total_pages;
16240 - int total_mem;
16241 - int page_offset = (be32_to_cpu(qpc->params2) >> 6) & 0x3f;
16242 -+ int tot;
16243 -
16244 - sq_size = 1 << (log_sq_size + log_sq_sride + 4);
16245 - rq_size = (srq|rss|xrc) ? 0 : (1 << (log_rq_size + log_rq_stride + 4));
16246 - total_mem = sq_size + rq_size;
16247 -- total_pages =
16248 -- roundup_pow_of_two((total_mem + (page_offset << 6)) >>
16249 -- page_shift);
16250 -+ tot = (total_mem + (page_offset << 6)) >> page_shift;
16251 -+ total_pages = !tot ? 1 : roundup_pow_of_two(tot);
16252 -
16253 - return total_pages;
16254 - }
16255 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
16256 -index eac245a93f91..4ab0d030b544 100644
16257 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
16258 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
16259 -@@ -122,7 +122,9 @@ out:
16260 - return err;
16261 - }
16262 -
16263 --/* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B]) */
16264 -+/* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B])
16265 -+ * minimum speed value is 40Gbps
16266 -+ */
16267 - static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
16268 - {
16269 - u32 speed;
16270 -@@ -130,10 +132,9 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
16271 - int err;
16272 -
16273 - err = mlx5e_port_linkspeed(priv->mdev, &speed);
16274 -- if (err) {
16275 -- mlx5_core_warn(priv->mdev, "cannot get port speed\n");
16276 -- return 0;
16277 -- }
16278 -+ if (err)
16279 -+ speed = SPEED_40000;
16280 -+ speed = max_t(u32, speed, SPEED_40000);
16281 -
16282 - xoff = (301 + 216 * priv->dcbx.cable_len / 100) * speed / 1000 + 272 * mtu / 100;
16283 -
16284 -@@ -142,7 +143,7 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
16285 - }
16286 -
16287 - static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
16288 -- u32 xoff, unsigned int mtu)
16289 -+ u32 xoff, unsigned int max_mtu)
16290 - {
16291 - int i;
16292 -
16293 -@@ -154,11 +155,12 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
16294 - }
16295 -
16296 - if (port_buffer->buffer[i].size <
16297 -- (xoff + mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
16298 -+ (xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
16299 - return -ENOMEM;
16300 -
16301 - port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff;
16302 -- port_buffer->buffer[i].xon = port_buffer->buffer[i].xoff - mtu;
16303 -+ port_buffer->buffer[i].xon =
16304 -+ port_buffer->buffer[i].xoff - max_mtu;
16305 - }
16306 -
16307 - return 0;
16308 -@@ -166,7 +168,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
16309 -
16310 - /**
16311 - * update_buffer_lossy()
16312 -- * mtu: device's MTU
16313 -+ * max_mtu: netdev's max_mtu
16314 - * pfc_en: <input> current pfc configuration
16315 - * buffer: <input> current prio to buffer mapping
16316 - * xoff: <input> xoff value
16317 -@@ -183,7 +185,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
16318 - * Return 0 if no error.
16319 - * Set change to true if buffer configuration is modified.
16320 - */
16321 --static int update_buffer_lossy(unsigned int mtu,
16322 -+static int update_buffer_lossy(unsigned int max_mtu,
16323 - u8 pfc_en, u8 *buffer, u32 xoff,
16324 - struct mlx5e_port_buffer *port_buffer,
16325 - bool *change)
16326 -@@ -220,7 +222,7 @@ static int update_buffer_lossy(unsigned int mtu,
16327 - }
16328 -
16329 - if (changed) {
16330 -- err = update_xoff_threshold(port_buffer, xoff, mtu);
16331 -+ err = update_xoff_threshold(port_buffer, xoff, max_mtu);
16332 - if (err)
16333 - return err;
16334 -
16335 -@@ -230,6 +232,7 @@ static int update_buffer_lossy(unsigned int mtu,
16336 - return 0;
16337 - }
16338 -
16339 -+#define MINIMUM_MAX_MTU 9216
16340 - int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16341 - u32 change, unsigned int mtu,
16342 - struct ieee_pfc *pfc,
16343 -@@ -241,12 +244,14 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16344 - bool update_prio2buffer = false;
16345 - u8 buffer[MLX5E_MAX_PRIORITY];
16346 - bool update_buffer = false;
16347 -+ unsigned int max_mtu;
16348 - u32 total_used = 0;
16349 - u8 curr_pfc_en;
16350 - int err;
16351 - int i;
16352 -
16353 - mlx5e_dbg(HW, priv, "%s: change=%x\n", __func__, change);
16354 -+ max_mtu = max_t(unsigned int, priv->netdev->max_mtu, MINIMUM_MAX_MTU);
16355 -
16356 - err = mlx5e_port_query_buffer(priv, &port_buffer);
16357 - if (err)
16358 -@@ -254,7 +259,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16359 -
16360 - if (change & MLX5E_PORT_BUFFER_CABLE_LEN) {
16361 - update_buffer = true;
16362 -- err = update_xoff_threshold(&port_buffer, xoff, mtu);
16363 -+ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
16364 - if (err)
16365 - return err;
16366 - }
16367 -@@ -264,7 +269,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16368 - if (err)
16369 - return err;
16370 -
16371 -- err = update_buffer_lossy(mtu, pfc->pfc_en, buffer, xoff,
16372 -+ err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff,
16373 - &port_buffer, &update_buffer);
16374 - if (err)
16375 - return err;
16376 -@@ -276,8 +281,8 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16377 - if (err)
16378 - return err;
16379 -
16380 -- err = update_buffer_lossy(mtu, curr_pfc_en, prio2buffer, xoff,
16381 -- &port_buffer, &update_buffer);
16382 -+ err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer,
16383 -+ xoff, &port_buffer, &update_buffer);
16384 - if (err)
16385 - return err;
16386 - }
16387 -@@ -301,7 +306,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16388 - return -EINVAL;
16389 -
16390 - update_buffer = true;
16391 -- err = update_xoff_threshold(&port_buffer, xoff, mtu);
16392 -+ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
16393 - if (err)
16394 - return err;
16395 - }
16396 -@@ -309,7 +314,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
16397 - /* Need to update buffer configuration if xoff value is changed */
16398 - if (!update_buffer && xoff != priv->dcbx.xoff) {
16399 - update_buffer = true;
16400 -- err = update_xoff_threshold(&port_buffer, xoff, mtu);
16401 -+ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
16402 - if (err)
16403 - return err;
16404 - }
16405 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
16406 -index 3078491cc0d0..1539cf3de5dc 100644
16407 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
16408 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
16409 -@@ -45,7 +45,9 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
16410 - if (err)
16411 - return err;
16412 -
16413 -+ mutex_lock(&mdev->mlx5e_res.td.list_lock);
16414 - list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list);
16415 -+ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
16416 -
16417 - return 0;
16418 - }
16419 -@@ -53,8 +55,10 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
16420 - void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
16421 - struct mlx5e_tir *tir)
16422 - {
16423 -+ mutex_lock(&mdev->mlx5e_res.td.list_lock);
16424 - mlx5_core_destroy_tir(mdev, tir->tirn);
16425 - list_del(&tir->list);
16426 -+ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
16427 - }
16428 -
16429 - static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
16430 -@@ -114,6 +118,7 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev)
16431 - }
16432 -
16433 - INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list);
16434 -+ mutex_init(&mdev->mlx5e_res.td.list_lock);
16435 -
16436 - return 0;
16437 -
16438 -@@ -141,15 +146,17 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
16439 - {
16440 - struct mlx5_core_dev *mdev = priv->mdev;
16441 - struct mlx5e_tir *tir;
16442 -- int err = -ENOMEM;
16443 -+ int err = 0;
16444 - u32 tirn = 0;
16445 - int inlen;
16446 - void *in;
16447 -
16448 - inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
16449 - in = kvzalloc(inlen, GFP_KERNEL);
16450 -- if (!in)
16451 -+ if (!in) {
16452 -+ err = -ENOMEM;
16453 - goto out;
16454 -+ }
16455 -
16456 - if (enable_uc_lb)
16457 - MLX5_SET(modify_tir_in, in, ctx.self_lb_block,
16458 -@@ -157,6 +164,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
16459 -
16460 - MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
16461 -
16462 -+ mutex_lock(&mdev->mlx5e_res.td.list_lock);
16463 - list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
16464 - tirn = tir->tirn;
16465 - err = mlx5_core_modify_tir(mdev, tirn, in, inlen);
16466 -@@ -168,6 +176,7 @@ out:
16467 - kvfree(in);
16468 - if (err)
16469 - netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err);
16470 -+ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
16471 -
16472 - return err;
16473 - }
16474 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
16475 -index 47233b9a4f81..e6099f51d25f 100644
16476 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
16477 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
16478 -@@ -357,6 +357,9 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
16479 -
16480 - if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
16481 - priv->channels.params = new_channels.params;
16482 -+ if (!netif_is_rxfh_configured(priv->netdev))
16483 -+ mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
16484 -+ MLX5E_INDIR_RQT_SIZE, count);
16485 - goto out;
16486 - }
16487 -
16488 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
16489 -index 5b492b67f4e1..13c48883ed61 100644
16490 ---- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
16491 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
16492 -@@ -1812,7 +1812,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
16493 - u64 node_guid;
16494 - int err = 0;
16495 -
16496 -- if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
16497 -+ if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager))
16498 - return -EPERM;
16499 - if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
16500 - return -EINVAL;
16501 -@@ -1886,7 +1886,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
16502 - {
16503 - struct mlx5_vport *evport;
16504 -
16505 -- if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
16506 -+ if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager))
16507 - return -EPERM;
16508 - if (!LEGAL_VPORT(esw, vport))
16509 - return -EINVAL;
16510 -@@ -2059,19 +2059,24 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
16511 - int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
16512 - u32 max_rate, u32 min_rate)
16513 - {
16514 -- u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
16515 -- bool min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
16516 -- fw_max_bw_share >= MLX5_MIN_BW_SHARE;
16517 -- bool max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
16518 - struct mlx5_vport *evport;
16519 -+ u32 fw_max_bw_share;
16520 - u32 previous_min_rate;
16521 - u32 divider;
16522 -+ bool min_rate_supported;
16523 -+ bool max_rate_supported;
16524 - int err = 0;
16525 -
16526 - if (!ESW_ALLOWED(esw))
16527 - return -EPERM;
16528 - if (!LEGAL_VPORT(esw, vport))
16529 - return -EINVAL;
16530 -+
16531 -+ fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
16532 -+ min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
16533 -+ fw_max_bw_share >= MLX5_MIN_BW_SHARE;
16534 -+ max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
16535 -+
16536 - if ((min_rate && !min_rate_supported) || (max_rate && !max_rate_supported))
16537 - return -EOPNOTSUPP;
16538 -
16539 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
16540 -index 5cf5f2a9d51f..8de64e88c670 100644
16541 ---- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
16542 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
16543 -@@ -217,15 +217,21 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
16544 - void *cmd;
16545 - int ret;
16546 -
16547 -+ rcu_read_lock();
16548 -+ flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
16549 -+ rcu_read_unlock();
16550 -+
16551 -+ if (!flow) {
16552 -+ WARN_ONCE(1, "Received NULL pointer for handle\n");
16553 -+ return -EINVAL;
16554 -+ }
16555 -+
16556 - buf = kzalloc(size, GFP_ATOMIC);
16557 - if (!buf)
16558 - return -ENOMEM;
16559 -
16560 - cmd = (buf + 1);
16561 -
16562 -- rcu_read_lock();
16563 -- flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
16564 -- rcu_read_unlock();
16565 - mlx5_fpga_tls_flow_to_cmd(flow, cmd);
16566 -
16567 - MLX5_SET(tls_cmd, cmd, swid, ntohl(handle));
16568 -@@ -238,6 +244,8 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
16569 - buf->complete = mlx_tls_kfree_complete;
16570 -
16571 - ret = mlx5_fpga_sbu_conn_sendmsg(mdev->fpga->tls->conn, buf);
16572 -+ if (ret < 0)
16573 -+ kfree(buf);
16574 -
16575 - return ret;
16576 - }
16577 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
16578 -index be81b319b0dc..694edd899322 100644
16579 ---- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
16580 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
16581 -@@ -163,26 +163,6 @@ static struct mlx5_profile profile[] = {
16582 - .size = 8,
16583 - .limit = 4
16584 - },
16585 -- .mr_cache[16] = {
16586 -- .size = 8,
16587 -- .limit = 4
16588 -- },
16589 -- .mr_cache[17] = {
16590 -- .size = 8,
16591 -- .limit = 4
16592 -- },
16593 -- .mr_cache[18] = {
16594 -- .size = 8,
16595 -- .limit = 4
16596 -- },
16597 -- .mr_cache[19] = {
16598 -- .size = 4,
16599 -- .limit = 2
16600 -- },
16601 -- .mr_cache[20] = {
16602 -- .size = 4,
16603 -- .limit = 2
16604 -- },
16605 - },
16606 - };
16607 -
16608 -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/qp.c b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
16609 -index 370ca94b6775..c7c2920c05c4 100644
16610 ---- a/drivers/net/ethernet/mellanox/mlx5/core/qp.c
16611 -+++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
16612 -@@ -40,6 +40,9 @@
16613 - #include "mlx5_core.h"
16614 - #include "lib/eq.h"
16615 -
16616 -+static int mlx5_core_drain_dct(struct mlx5_core_dev *dev,
16617 -+ struct mlx5_core_dct *dct);
16618 -+
16619 - static struct mlx5_core_rsc_common *
16620 - mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
16621 - {
16622 -@@ -227,13 +230,42 @@ static void destroy_resource_common(struct mlx5_core_dev *dev,
16623 - wait_for_completion(&qp->common.free);
16624 - }
16625 -
16626 -+static int _mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
16627 -+ struct mlx5_core_dct *dct, bool need_cleanup)
16628 -+{
16629 -+ u32 out[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
16630 -+ u32 in[MLX5_ST_SZ_DW(destroy_dct_in)] = {0};
16631 -+ struct mlx5_core_qp *qp = &dct->mqp;
16632 -+ int err;
16633 -+
16634 -+ err = mlx5_core_drain_dct(dev, dct);
16635 -+ if (err) {
16636 -+ if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
16637 -+ goto destroy;
16638 -+ } else {
16639 -+ mlx5_core_warn(
16640 -+ dev, "failed drain DCT 0x%x with error 0x%x\n",
16641 -+ qp->qpn, err);
16642 -+ return err;
16643 -+ }
16644 -+ }
16645 -+ wait_for_completion(&dct->drained);
16646 -+destroy:
16647 -+ if (need_cleanup)
16648 -+ destroy_resource_common(dev, &dct->mqp);
16649 -+ MLX5_SET(destroy_dct_in, in, opcode, MLX5_CMD_OP_DESTROY_DCT);
16650 -+ MLX5_SET(destroy_dct_in, in, dctn, qp->qpn);
16651 -+ MLX5_SET(destroy_dct_in, in, uid, qp->uid);
16652 -+ err = mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
16653 -+ (void *)&out, sizeof(out));
16654 -+ return err;
16655 -+}
16656 -+
16657 - int mlx5_core_create_dct(struct mlx5_core_dev *dev,
16658 - struct mlx5_core_dct *dct,
16659 - u32 *in, int inlen)
16660 - {
16661 - u32 out[MLX5_ST_SZ_DW(create_dct_out)] = {0};
16662 -- u32 din[MLX5_ST_SZ_DW(destroy_dct_in)] = {0};
16663 -- u32 dout[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
16664 - struct mlx5_core_qp *qp = &dct->mqp;
16665 - int err;
16666 -
16667 -@@ -254,11 +286,7 @@ int mlx5_core_create_dct(struct mlx5_core_dev *dev,
16668 -
16669 - return 0;
16670 - err_cmd:
16671 -- MLX5_SET(destroy_dct_in, din, opcode, MLX5_CMD_OP_DESTROY_DCT);
16672 -- MLX5_SET(destroy_dct_in, din, dctn, qp->qpn);
16673 -- MLX5_SET(destroy_dct_in, din, uid, qp->uid);
16674 -- mlx5_cmd_exec(dev, (void *)&in, sizeof(din),
16675 -- (void *)&out, sizeof(dout));
16676 -+ _mlx5_core_destroy_dct(dev, dct, false);
16677 - return err;
16678 - }
16679 - EXPORT_SYMBOL_GPL(mlx5_core_create_dct);
16680 -@@ -323,29 +351,7 @@ static int mlx5_core_drain_dct(struct mlx5_core_dev *dev,
16681 - int mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
16682 - struct mlx5_core_dct *dct)
16683 - {
16684 -- u32 out[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
16685 -- u32 in[MLX5_ST_SZ_DW(destroy_dct_in)] = {0};
16686 -- struct mlx5_core_qp *qp = &dct->mqp;
16687 -- int err;
16688 --
16689 -- err = mlx5_core_drain_dct(dev, dct);
16690 -- if (err) {
16691 -- if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
16692 -- goto destroy;
16693 -- } else {
16694 -- mlx5_core_warn(dev, "failed drain DCT 0x%x with error 0x%x\n", qp->qpn, err);
16695 -- return err;
16696 -- }
16697 -- }
16698 -- wait_for_completion(&dct->drained);
16699 --destroy:
16700 -- destroy_resource_common(dev, &dct->mqp);
16701 -- MLX5_SET(destroy_dct_in, in, opcode, MLX5_CMD_OP_DESTROY_DCT);
16702 -- MLX5_SET(destroy_dct_in, in, dctn, qp->qpn);
16703 -- MLX5_SET(destroy_dct_in, in, uid, qp->uid);
16704 -- err = mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
16705 -- (void *)&out, sizeof(out));
16706 -- return err;
16707 -+ return _mlx5_core_destroy_dct(dev, dct, true);
16708 - }
16709 - EXPORT_SYMBOL_GPL(mlx5_core_destroy_dct);
16710 -
16711 -diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
16712 -index b65e274b02e9..cbdee5164be7 100644
16713 ---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
16714 -+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
16715 -@@ -2105,7 +2105,7 @@ static void mlxsw_sp_port_get_prio_strings(u8 **p, int prio)
16716 - int i;
16717 -
16718 - for (i = 0; i < MLXSW_SP_PORT_HW_PRIO_STATS_LEN; i++) {
16719 -- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
16720 -+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
16721 - mlxsw_sp_port_hw_prio_stats[i].str, prio);
16722 - *p += ETH_GSTRING_LEN;
16723 - }
16724 -@@ -2116,7 +2116,7 @@ static void mlxsw_sp_port_get_tc_strings(u8 **p, int tc)
16725 - int i;
16726 -
16727 - for (i = 0; i < MLXSW_SP_PORT_HW_TC_STATS_LEN; i++) {
16728 -- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
16729 -+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
16730 - mlxsw_sp_port_hw_tc_stats[i].str, tc);
16731 - *p += ETH_GSTRING_LEN;
16732 - }
16733 -diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
16734 -index 4d1b4a24907f..13e6bf13ac4d 100644
16735 ---- a/drivers/net/ethernet/microchip/lan743x_main.c
16736 -+++ b/drivers/net/ethernet/microchip/lan743x_main.c
16737 -@@ -585,8 +585,7 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
16738 -
16739 - if (adapter->csr.flags &
16740 - LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR) {
16741 -- flags = LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR |
16742 -- LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET |
16743 -+ flags = LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET |
16744 - LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET |
16745 - LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR |
16746 - LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR;
16747 -@@ -599,12 +598,6 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
16748 - /* map TX interrupt to vector */
16749 - int_vec_map1 |= INT_VEC_MAP1_TX_VEC_(index, vector);
16750 - lan743x_csr_write(adapter, INT_VEC_MAP1, int_vec_map1);
16751 -- if (flags &
16752 -- LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR) {
16753 -- int_vec_en_auto_clr |= INT_VEC_EN_(vector);
16754 -- lan743x_csr_write(adapter, INT_VEC_EN_AUTO_CLR,
16755 -- int_vec_en_auto_clr);
16756 -- }
16757 -
16758 - /* Remove TX interrupt from shared mask */
16759 - intr->vector_list[0].int_mask &= ~int_bit;
16760 -@@ -1902,7 +1895,17 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index)
16761 - return ((++index) % rx->ring_size);
16762 - }
16763 -
16764 --static int lan743x_rx_allocate_ring_element(struct lan743x_rx *rx, int index)
16765 -+static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx)
16766 -+{
16767 -+ int length = 0;
16768 -+
16769 -+ length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING);
16770 -+ return __netdev_alloc_skb(rx->adapter->netdev,
16771 -+ length, GFP_ATOMIC | GFP_DMA);
16772 -+}
16773 -+
16774 -+static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index,
16775 -+ struct sk_buff *skb)
16776 - {
16777 - struct lan743x_rx_buffer_info *buffer_info;
16778 - struct lan743x_rx_descriptor *descriptor;
16779 -@@ -1911,9 +1914,7 @@ static int lan743x_rx_allocate_ring_element(struct lan743x_rx *rx, int index)
16780 - length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING);
16781 - descriptor = &rx->ring_cpu_ptr[index];
16782 - buffer_info = &rx->buffer_info[index];
16783 -- buffer_info->skb = __netdev_alloc_skb(rx->adapter->netdev,
16784 -- length,
16785 -- GFP_ATOMIC | GFP_DMA);
16786 -+ buffer_info->skb = skb;
16787 - if (!(buffer_info->skb))
16788 - return -ENOMEM;
16789 - buffer_info->dma_ptr = dma_map_single(&rx->adapter->pdev->dev,
16790 -@@ -2060,8 +2061,19 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
16791 - /* packet is available */
16792 - if (first_index == last_index) {
16793 - /* single buffer packet */
16794 -+ struct sk_buff *new_skb = NULL;
16795 - int packet_length;
16796 -
16797 -+ new_skb = lan743x_rx_allocate_skb(rx);
16798 -+ if (!new_skb) {
16799 -+ /* failed to allocate next skb.
16800 -+ * Memory is very low.
16801 -+ * Drop this packet and reuse buffer.
16802 -+ */
16803 -+ lan743x_rx_reuse_ring_element(rx, first_index);
16804 -+ goto process_extension;
16805 -+ }
16806 -+
16807 - buffer_info = &rx->buffer_info[first_index];
16808 - skb = buffer_info->skb;
16809 - descriptor = &rx->ring_cpu_ptr[first_index];
16810 -@@ -2081,7 +2093,7 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
16811 - skb_put(skb, packet_length - 4);
16812 - skb->protocol = eth_type_trans(skb,
16813 - rx->adapter->netdev);
16814 -- lan743x_rx_allocate_ring_element(rx, first_index);
16815 -+ lan743x_rx_init_ring_element(rx, first_index, new_skb);
16816 - } else {
16817 - int index = first_index;
16818 -
16819 -@@ -2094,26 +2106,23 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
16820 - if (first_index <= last_index) {
16821 - while ((index >= first_index) &&
16822 - (index <= last_index)) {
16823 -- lan743x_rx_release_ring_element(rx,
16824 -- index);
16825 -- lan743x_rx_allocate_ring_element(rx,
16826 -- index);
16827 -+ lan743x_rx_reuse_ring_element(rx,
16828 -+ index);
16829 - index = lan743x_rx_next_index(rx,
16830 - index);
16831 - }
16832 - } else {
16833 - while ((index >= first_index) ||
16834 - (index <= last_index)) {
16835 -- lan743x_rx_release_ring_element(rx,
16836 -- index);
16837 -- lan743x_rx_allocate_ring_element(rx,
16838 -- index);
16839 -+ lan743x_rx_reuse_ring_element(rx,
16840 -+ index);
16841 - index = lan743x_rx_next_index(rx,
16842 - index);
16843 - }
16844 - }
16845 - }
16846 -
16847 -+process_extension:
16848 - if (extension_index >= 0) {
16849 - descriptor = &rx->ring_cpu_ptr[extension_index];
16850 - buffer_info = &rx->buffer_info[extension_index];
16851 -@@ -2290,7 +2299,9 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
16852 -
16853 - rx->last_head = 0;
16854 - for (index = 0; index < rx->ring_size; index++) {
16855 -- ret = lan743x_rx_allocate_ring_element(rx, index);
16856 -+ struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx);
16857 -+
16858 -+ ret = lan743x_rx_init_ring_element(rx, index, new_skb);
16859 - if (ret)
16860 - goto cleanup;
16861 - }
16862 -diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
16863 -index ca3ea2fbfcd0..80d87798c62b 100644
16864 ---- a/drivers/net/ethernet/mscc/ocelot_board.c
16865 -+++ b/drivers/net/ethernet/mscc/ocelot_board.c
16866 -@@ -267,6 +267,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
16867 - struct phy *serdes;
16868 - void __iomem *regs;
16869 - char res_name[8];
16870 -+ int phy_mode;
16871 - u32 port;
16872 -
16873 - if (of_property_read_u32(portnp, "reg", &port))
16874 -@@ -292,11 +293,11 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
16875 - if (err)
16876 - return err;
16877 -
16878 -- err = of_get_phy_mode(portnp);
16879 -- if (err < 0)
16880 -+ phy_mode = of_get_phy_mode(portnp);
16881 -+ if (phy_mode < 0)
16882 - ocelot->ports[port]->phy_mode = PHY_INTERFACE_MODE_NA;
16883 - else
16884 -- ocelot->ports[port]->phy_mode = err;
16885 -+ ocelot->ports[port]->phy_mode = phy_mode;
16886 -
16887 - switch (ocelot->ports[port]->phy_mode) {
16888 - case PHY_INTERFACE_MODE_NA:
16889 -@@ -304,6 +305,13 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
16890 - case PHY_INTERFACE_MODE_SGMII:
16891 - break;
16892 - case PHY_INTERFACE_MODE_QSGMII:
16893 -+ /* Ensure clock signals and speed is set on all
16894 -+ * QSGMII links
16895 -+ */
16896 -+ ocelot_port_writel(ocelot->ports[port],
16897 -+ DEV_CLOCK_CFG_LINK_SPEED
16898 -+ (OCELOT_SPEED_1000),
16899 -+ DEV_CLOCK_CFG);
16900 - break;
16901 - default:
16902 - dev_err(ocelot->dev,
16903 -diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
16904 -index 69d7aebda09b..73db94e55fd0 100644
16905 ---- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
16906 -+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
16907 -@@ -196,7 +196,7 @@ static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev)
16908 - ret = dev_queue_xmit(skb);
16909 - nfp_repr_inc_tx_stats(netdev, len, ret);
16910 -
16911 -- return ret;
16912 -+ return NETDEV_TX_OK;
16913 - }
16914 -
16915 - static int nfp_repr_stop(struct net_device *netdev)
16916 -@@ -384,7 +384,7 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
16917 - netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
16918 - netdev->gso_max_segs = NFP_NET_LSO_MAX_SEGS;
16919 -
16920 -- netdev->priv_flags |= IFF_NO_QUEUE;
16921 -+ netdev->priv_flags |= IFF_NO_QUEUE | IFF_DISABLE_NETPOLL;
16922 - netdev->features |= NETIF_F_LLTX;
16923 -
16924 - if (nfp_app_has_tc(app)) {
16925 -diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
16926 -index 6e36b88ca7c9..365cddbfc684 100644
16927 ---- a/drivers/net/ethernet/realtek/r8169.c
16928 -+++ b/drivers/net/ethernet/realtek/r8169.c
16929 -@@ -28,6 +28,7 @@
16930 - #include <linux/pm_runtime.h>
16931 - #include <linux/firmware.h>
16932 - #include <linux/prefetch.h>
16933 -+#include <linux/pci-aspm.h>
16934 - #include <linux/ipv6.h>
16935 - #include <net/ip6_checksum.h>
16936 -
16937 -@@ -5332,7 +5333,7 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
16938 - tp->cp_cmd |= PktCntrDisable | INTT_1;
16939 - RTL_W16(tp, CPlusCmd, tp->cp_cmd);
16940 -
16941 -- RTL_W16(tp, IntrMitigate, 0x5151);
16942 -+ RTL_W16(tp, IntrMitigate, 0x5100);
16943 -
16944 - /* Work around for RxFIFO overflow. */
16945 - if (tp->mac_version == RTL_GIGA_MAC_VER_11) {
16946 -@@ -6435,7 +6436,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
16947 - set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags);
16948 - }
16949 -
16950 -- if (status & RTL_EVENT_NAPI) {
16951 -+ if (status & (RTL_EVENT_NAPI | LinkChg)) {
16952 - rtl_irq_disable(tp);
16953 - napi_schedule_irqoff(&tp->napi);
16954 - }
16955 -@@ -7224,6 +7225,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
16956 - return rc;
16957 - }
16958 -
16959 -+ /* Disable ASPM completely as that cause random device stop working
16960 -+ * problems as well as full system hangs for some PCIe devices users.
16961 -+ */
16962 -+ pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
16963 -+
16964 - /* enable device (incl. PCI PM wakeup and hotplug setup) */
16965 - rc = pcim_enable_device(pdev);
16966 - if (rc < 0) {
16967 -diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
16968 -index d28c8f9ca55b..8154b38c08f7 100644
16969 ---- a/drivers/net/ethernet/renesas/ravb_main.c
16970 -+++ b/drivers/net/ethernet/renesas/ravb_main.c
16971 -@@ -458,7 +458,7 @@ static int ravb_dmac_init(struct net_device *ndev)
16972 - RCR_EFFS | RCR_ENCF | RCR_ETS0 | RCR_ESF | 0x18000000, RCR);
16973 -
16974 - /* Set FIFO size */
16975 -- ravb_write(ndev, TGC_TQP_AVBMODE1 | 0x00222200, TGC);
16976 -+ ravb_write(ndev, TGC_TQP_AVBMODE1 | 0x00112200, TGC);
16977 -
16978 - /* Timestamp enable */
16979 - ravb_write(ndev, TCCR_TFEN, TCCR);
16980 -diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
16981 -index d8c5bc412219..c0c75c111abb 100644
16982 ---- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
16983 -+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
16984 -@@ -111,10 +111,11 @@ static unsigned int is_jumbo_frm(int len, int enh_desc)
16985 -
16986 - static void refill_desc3(void *priv_ptr, struct dma_desc *p)
16987 - {
16988 -- struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
16989 -+ struct stmmac_rx_queue *rx_q = priv_ptr;
16990 -+ struct stmmac_priv *priv = rx_q->priv_data;
16991 -
16992 - /* Fill DES3 in case of RING mode */
16993 -- if (priv->dma_buf_sz >= BUF_SIZE_8KiB)
16994 -+ if (priv->dma_buf_sz == BUF_SIZE_16KiB)
16995 - p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB);
16996 - }
16997 -
16998 -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
16999 -index 685d20472358..019ab99e65bb 100644
17000 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
17001 -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
17002 -@@ -474,7 +474,7 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv,
17003 - struct dma_desc *p, struct sk_buff *skb)
17004 - {
17005 - struct skb_shared_hwtstamps shhwtstamp;
17006 -- u64 ns;
17007 -+ u64 ns = 0;
17008 -
17009 - if (!priv->hwts_tx_en)
17010 - return;
17011 -@@ -513,7 +513,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
17012 - {
17013 - struct skb_shared_hwtstamps *shhwtstamp = NULL;
17014 - struct dma_desc *desc = p;
17015 -- u64 ns;
17016 -+ u64 ns = 0;
17017 -
17018 - if (!priv->hwts_rx_en)
17019 - return;
17020 -@@ -558,8 +558,8 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
17021 - u32 snap_type_sel = 0;
17022 - u32 ts_master_en = 0;
17023 - u32 ts_event_en = 0;
17024 -+ u32 sec_inc = 0;
17025 - u32 value = 0;
17026 -- u32 sec_inc;
17027 - bool xmac;
17028 -
17029 - xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;
17030 -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
17031 -index 2293e21f789f..cc60b3fb0892 100644
17032 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
17033 -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
17034 -@@ -105,7 +105,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
17035 - struct stmmac_priv *priv =
17036 - container_of(ptp, struct stmmac_priv, ptp_clock_ops);
17037 - unsigned long flags;
17038 -- u64 ns;
17039 -+ u64 ns = 0;
17040 -
17041 - spin_lock_irqsave(&priv->ptp_lock, flags);
17042 - stmmac_get_systime(priv, priv->ptpaddr, &ns);
17043 -diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
17044 -index e859ae2e42d5..49f41b64077b 100644
17045 ---- a/drivers/net/hyperv/hyperv_net.h
17046 -+++ b/drivers/net/hyperv/hyperv_net.h
17047 -@@ -987,6 +987,7 @@ struct netvsc_device {
17048 -
17049 - wait_queue_head_t wait_drain;
17050 - bool destroy;
17051 -+ bool tx_disable; /* if true, do not wake up queue again */
17052 -
17053 - /* Receive buffer allocated by us but manages by NetVSP */
17054 - void *recv_buf;
17055 -diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
17056 -index 813d195bbd57..e0dce373cdd9 100644
17057 ---- a/drivers/net/hyperv/netvsc.c
17058 -+++ b/drivers/net/hyperv/netvsc.c
17059 -@@ -110,6 +110,7 @@ static struct netvsc_device *alloc_net_device(void)
17060 -
17061 - init_waitqueue_head(&net_device->wait_drain);
17062 - net_device->destroy = false;
17063 -+ net_device->tx_disable = false;
17064 -
17065 - net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
17066 - net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
17067 -@@ -719,7 +720,7 @@ static void netvsc_send_tx_complete(struct net_device *ndev,
17068 - } else {
17069 - struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx);
17070 -
17071 -- if (netif_tx_queue_stopped(txq) &&
17072 -+ if (netif_tx_queue_stopped(txq) && !net_device->tx_disable &&
17073 - (hv_get_avail_to_write_percent(&channel->outbound) >
17074 - RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) {
17075 - netif_tx_wake_queue(txq);
17076 -@@ -874,7 +875,8 @@ static inline int netvsc_send_pkt(
17077 - } else if (ret == -EAGAIN) {
17078 - netif_tx_stop_queue(txq);
17079 - ndev_ctx->eth_stats.stop_queue++;
17080 -- if (atomic_read(&nvchan->queue_sends) < 1) {
17081 -+ if (atomic_read(&nvchan->queue_sends) < 1 &&
17082 -+ !net_device->tx_disable) {
17083 - netif_tx_wake_queue(txq);
17084 - ndev_ctx->eth_stats.wake_queue++;
17085 - ret = -ENOSPC;
17086 -diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
17087 -index cf4897043e83..b20fb0fb595b 100644
17088 ---- a/drivers/net/hyperv/netvsc_drv.c
17089 -+++ b/drivers/net/hyperv/netvsc_drv.c
17090 -@@ -109,6 +109,15 @@ static void netvsc_set_rx_mode(struct net_device *net)
17091 - rcu_read_unlock();
17092 - }
17093 -
17094 -+static void netvsc_tx_enable(struct netvsc_device *nvscdev,
17095 -+ struct net_device *ndev)
17096 -+{
17097 -+ nvscdev->tx_disable = false;
17098 -+ virt_wmb(); /* ensure queue wake up mechanism is on */
17099 -+
17100 -+ netif_tx_wake_all_queues(ndev);
17101 -+}
17102 -+
17103 - static int netvsc_open(struct net_device *net)
17104 - {
17105 - struct net_device_context *ndev_ctx = netdev_priv(net);
17106 -@@ -129,7 +138,7 @@ static int netvsc_open(struct net_device *net)
17107 - rdev = nvdev->extension;
17108 - if (!rdev->link_state) {
17109 - netif_carrier_on(net);
17110 -- netif_tx_wake_all_queues(net);
17111 -+ netvsc_tx_enable(nvdev, net);
17112 - }
17113 -
17114 - if (vf_netdev) {
17115 -@@ -184,6 +193,17 @@ static int netvsc_wait_until_empty(struct netvsc_device *nvdev)
17116 - }
17117 - }
17118 -
17119 -+static void netvsc_tx_disable(struct netvsc_device *nvscdev,
17120 -+ struct net_device *ndev)
17121 -+{
17122 -+ if (nvscdev) {
17123 -+ nvscdev->tx_disable = true;
17124 -+ virt_wmb(); /* ensure txq will not wake up after stop */
17125 -+ }
17126 -+
17127 -+ netif_tx_disable(ndev);
17128 -+}
17129 -+
17130 - static int netvsc_close(struct net_device *net)
17131 - {
17132 - struct net_device_context *net_device_ctx = netdev_priv(net);
17133 -@@ -192,7 +212,7 @@ static int netvsc_close(struct net_device *net)
17134 - struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
17135 - int ret;
17136 -
17137 -- netif_tx_disable(net);
17138 -+ netvsc_tx_disable(nvdev, net);
17139 -
17140 - /* No need to close rndis filter if it is removed already */
17141 - if (!nvdev)
17142 -@@ -920,7 +940,7 @@ static int netvsc_detach(struct net_device *ndev,
17143 -
17144 - /* If device was up (receiving) then shutdown */
17145 - if (netif_running(ndev)) {
17146 -- netif_tx_disable(ndev);
17147 -+ netvsc_tx_disable(nvdev, ndev);
17148 -
17149 - ret = rndis_filter_close(nvdev);
17150 - if (ret) {
17151 -@@ -1908,7 +1928,7 @@ static void netvsc_link_change(struct work_struct *w)
17152 - if (rdev->link_state) {
17153 - rdev->link_state = false;
17154 - netif_carrier_on(net);
17155 -- netif_tx_wake_all_queues(net);
17156 -+ netvsc_tx_enable(net_device, net);
17157 - } else {
17158 - notify = true;
17159 - }
17160 -@@ -1918,7 +1938,7 @@ static void netvsc_link_change(struct work_struct *w)
17161 - if (!rdev->link_state) {
17162 - rdev->link_state = true;
17163 - netif_carrier_off(net);
17164 -- netif_tx_stop_all_queues(net);
17165 -+ netvsc_tx_disable(net_device, net);
17166 - }
17167 - kfree(event);
17168 - break;
17169 -@@ -1927,7 +1947,7 @@ static void netvsc_link_change(struct work_struct *w)
17170 - if (!rdev->link_state) {
17171 - rdev->link_state = true;
17172 - netif_carrier_off(net);
17173 -- netif_tx_stop_all_queues(net);
17174 -+ netvsc_tx_disable(net_device, net);
17175 - event->event = RNDIS_STATUS_MEDIA_CONNECT;
17176 - spin_lock_irqsave(&ndev_ctx->lock, flags);
17177 - list_add(&event->list, &ndev_ctx->reconfig_events);
17178 -diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c
17179 -index 3ddaf9595697..68af4c75ffb3 100644
17180 ---- a/drivers/net/phy/meson-gxl.c
17181 -+++ b/drivers/net/phy/meson-gxl.c
17182 -@@ -211,6 +211,7 @@ static int meson_gxl_ack_interrupt(struct phy_device *phydev)
17183 - static int meson_gxl_config_intr(struct phy_device *phydev)
17184 - {
17185 - u16 val;
17186 -+ int ret;
17187 -
17188 - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
17189 - val = INTSRC_ANEG_PR
17190 -@@ -223,6 +224,11 @@ static int meson_gxl_config_intr(struct phy_device *phydev)
17191 - val = 0;
17192 - }
17193 -
17194 -+ /* Ack any pending IRQ */
17195 -+ ret = meson_gxl_ack_interrupt(phydev);
17196 -+ if (ret)
17197 -+ return ret;
17198 -+
17199 - return phy_write(phydev, INTSRC_MASK, val);
17200 - }
17201 -
17202 -diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
17203 -index 03af927fa5ad..e39bf0428dd9 100644
17204 ---- a/drivers/net/phy/phy-c45.c
17205 -+++ b/drivers/net/phy/phy-c45.c
17206 -@@ -147,9 +147,15 @@ int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask)
17207 - mmd_mask &= ~BIT(devad);
17208 -
17209 - /* The link state is latched low so that momentary link
17210 -- * drops can be detected. Do not double-read the status
17211 -- * register if the link is down.
17212 -+ * drops can be detected. Do not double-read the status
17213 -+ * in polling mode to detect such short link drops.
17214 - */
17215 -+ if (!phy_polling_mode(phydev)) {
17216 -+ val = phy_read_mmd(phydev, devad, MDIO_STAT1);
17217 -+ if (val < 0)
17218 -+ return val;
17219 -+ }
17220 -+
17221 - val = phy_read_mmd(phydev, devad, MDIO_STAT1);
17222 - if (val < 0)
17223 - return val;
17224 -diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
17225 -index 46c86725a693..adf79614c2db 100644
17226 ---- a/drivers/net/phy/phy_device.c
17227 -+++ b/drivers/net/phy/phy_device.c
17228 -@@ -1683,10 +1683,15 @@ int genphy_update_link(struct phy_device *phydev)
17229 - {
17230 - int status;
17231 -
17232 -- /* Do a fake read */
17233 -- status = phy_read(phydev, MII_BMSR);
17234 -- if (status < 0)
17235 -- return status;
17236 -+ /* The link state is latched low so that momentary link
17237 -+ * drops can be detected. Do not double-read the status
17238 -+ * in polling mode to detect such short link drops.
17239 -+ */
17240 -+ if (!phy_polling_mode(phydev)) {
17241 -+ status = phy_read(phydev, MII_BMSR);
17242 -+ if (status < 0)
17243 -+ return status;
17244 -+ }
17245 -
17246 - /* Read link and autonegotiation status */
17247 - status = phy_read(phydev, MII_BMSR);
17248 -@@ -1827,7 +1832,7 @@ int genphy_soft_reset(struct phy_device *phydev)
17249 - {
17250 - int ret;
17251 -
17252 -- ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
17253 -+ ret = phy_set_bits(phydev, MII_BMCR, BMCR_RESET);
17254 - if (ret < 0)
17255 - return ret;
17256 -
17257 -diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
17258 -index 8f09edd811e9..50c60550f295 100644
17259 ---- a/drivers/net/ppp/pptp.c
17260 -+++ b/drivers/net/ppp/pptp.c
17261 -@@ -532,6 +532,7 @@ static void pptp_sock_destruct(struct sock *sk)
17262 - pppox_unbind_sock(sk);
17263 - }
17264 - skb_queue_purge(&sk->sk_receive_queue);
17265 -+ dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1));
17266 - }
17267 -
17268 - static int pptp_create(struct net *net, struct socket *sock, int kern)
17269 -diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
17270 -index a5ef97010eb3..5541e1c19936 100644
17271 ---- a/drivers/net/team/team_mode_loadbalance.c
17272 -+++ b/drivers/net/team/team_mode_loadbalance.c
17273 -@@ -325,6 +325,20 @@ static int lb_bpf_func_set(struct team *team, struct team_gsetter_ctx *ctx)
17274 - return 0;
17275 - }
17276 -
17277 -+static void lb_bpf_func_free(struct team *team)
17278 -+{
17279 -+ struct lb_priv *lb_priv = get_lb_priv(team);
17280 -+ struct bpf_prog *fp;
17281 -+
17282 -+ if (!lb_priv->ex->orig_fprog)
17283 -+ return;
17284 -+
17285 -+ __fprog_destroy(lb_priv->ex->orig_fprog);
17286 -+ fp = rcu_dereference_protected(lb_priv->fp,
17287 -+ lockdep_is_held(&team->lock));
17288 -+ bpf_prog_destroy(fp);
17289 -+}
17290 -+
17291 - static int lb_tx_method_get(struct team *team, struct team_gsetter_ctx *ctx)
17292 - {
17293 - struct lb_priv *lb_priv = get_lb_priv(team);
17294 -@@ -639,6 +653,7 @@ static void lb_exit(struct team *team)
17295 -
17296 - team_options_unregister(team, lb_options,
17297 - ARRAY_SIZE(lb_options));
17298 -+ lb_bpf_func_free(team);
17299 - cancel_delayed_work_sync(&lb_priv->ex->stats.refresh_dw);
17300 - free_percpu(lb_priv->pcpu_stats);
17301 - kfree(lb_priv->ex);
17302 -diff --git a/drivers/net/tun.c b/drivers/net/tun.c
17303 -index 53f4f37b0ffd..448d5439ff6a 100644
17304 ---- a/drivers/net/tun.c
17305 -+++ b/drivers/net/tun.c
17306 -@@ -1763,9 +1763,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17307 - int skb_xdp = 1;
17308 - bool frags = tun_napi_frags_enabled(tfile);
17309 -
17310 -- if (!(tun->dev->flags & IFF_UP))
17311 -- return -EIO;
17312 --
17313 - if (!(tun->flags & IFF_NO_PI)) {
17314 - if (len < sizeof(pi))
17315 - return -EINVAL;
17316 -@@ -1867,6 +1864,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17317 - err = skb_copy_datagram_from_iter(skb, 0, from, len);
17318 -
17319 - if (err) {
17320 -+ err = -EFAULT;
17321 -+drop:
17322 - this_cpu_inc(tun->pcpu_stats->rx_dropped);
17323 - kfree_skb(skb);
17324 - if (frags) {
17325 -@@ -1874,7 +1873,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17326 - mutex_unlock(&tfile->napi_mutex);
17327 - }
17328 -
17329 -- return -EFAULT;
17330 -+ return err;
17331 - }
17332 - }
17333 -
17334 -@@ -1958,6 +1957,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17335 - !tfile->detached)
17336 - rxhash = __skb_get_hash_symmetric(skb);
17337 -
17338 -+ rcu_read_lock();
17339 -+ if (unlikely(!(tun->dev->flags & IFF_UP))) {
17340 -+ err = -EIO;
17341 -+ rcu_read_unlock();
17342 -+ goto drop;
17343 -+ }
17344 -+
17345 - if (frags) {
17346 - /* Exercise flow dissector code path. */
17347 - u32 headlen = eth_get_headlen(skb->data, skb_headlen(skb));
17348 -@@ -1965,6 +1971,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17349 - if (unlikely(headlen > skb_headlen(skb))) {
17350 - this_cpu_inc(tun->pcpu_stats->rx_dropped);
17351 - napi_free_frags(&tfile->napi);
17352 -+ rcu_read_unlock();
17353 - mutex_unlock(&tfile->napi_mutex);
17354 - WARN_ON(1);
17355 - return -ENOMEM;
17356 -@@ -1992,6 +1999,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
17357 - } else {
17358 - netif_rx_ni(skb);
17359 - }
17360 -+ rcu_read_unlock();
17361 -
17362 - stats = get_cpu_ptr(tun->pcpu_stats);
17363 - u64_stats_update_begin(&stats->syncp);
17364 -diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
17365 -index 820a2fe7d027..aff995be2a31 100644
17366 ---- a/drivers/net/usb/aqc111.c
17367 -+++ b/drivers/net/usb/aqc111.c
17368 -@@ -1301,6 +1301,20 @@ static const struct driver_info trendnet_info = {
17369 - .tx_fixup = aqc111_tx_fixup,
17370 - };
17371 -
17372 -+static const struct driver_info qnap_info = {
17373 -+ .description = "QNAP QNA-UC5G1T USB to 5GbE Adapter",
17374 -+ .bind = aqc111_bind,
17375 -+ .unbind = aqc111_unbind,
17376 -+ .status = aqc111_status,
17377 -+ .link_reset = aqc111_link_reset,
17378 -+ .reset = aqc111_reset,
17379 -+ .stop = aqc111_stop,
17380 -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX |
17381 -+ FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
17382 -+ .rx_fixup = aqc111_rx_fixup,
17383 -+ .tx_fixup = aqc111_tx_fixup,
17384 -+};
17385 -+
17386 - static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
17387 - {
17388 - struct usbnet *dev = usb_get_intfdata(intf);
17389 -@@ -1455,6 +1469,7 @@ static const struct usb_device_id products[] = {
17390 - {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)},
17391 - {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)},
17392 - {AQC111_USB_ETH_DEV(0x20f4, 0xe05a, trendnet_info)},
17393 -+ {AQC111_USB_ETH_DEV(0x1c04, 0x0015, qnap_info)},
17394 - { },/* END */
17395 - };
17396 - MODULE_DEVICE_TABLE(usb, products);
17397 -diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
17398 -index 5512a1038721..3e9b2c319e45 100644
17399 ---- a/drivers/net/usb/cdc_ether.c
17400 -+++ b/drivers/net/usb/cdc_ether.c
17401 -@@ -851,6 +851,14 @@ static const struct usb_device_id products[] = {
17402 - .driver_info = 0,
17403 - },
17404 -
17405 -+/* QNAP QNA-UC5G1T USB to 5GbE Adapter (based on AQC111U) */
17406 -+{
17407 -+ USB_DEVICE_AND_INTERFACE_INFO(0x1c04, 0x0015, USB_CLASS_COMM,
17408 -+ USB_CDC_SUBCLASS_ETHERNET,
17409 -+ USB_CDC_PROTO_NONE),
17410 -+ .driver_info = 0,
17411 -+},
17412 -+
17413 - /* WHITELIST!!!
17414 - *
17415 - * CDC Ether uses two interfaces, not necessarily consecutive.
17416 -diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
17417 -index 18af2f8eee96..9195f3476b1d 100644
17418 ---- a/drivers/net/usb/qmi_wwan.c
17419 -+++ b/drivers/net/usb/qmi_wwan.c
17420 -@@ -976,6 +976,13 @@ static const struct usb_device_id products[] = {
17421 - 0xff),
17422 - .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr,
17423 - },
17424 -+ { /* Quectel EG12/EM12 */
17425 -+ USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x0512,
17426 -+ USB_CLASS_VENDOR_SPEC,
17427 -+ USB_SUBCLASS_VENDOR_SPEC,
17428 -+ 0xff),
17429 -+ .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr,
17430 -+ },
17431 -
17432 - /* 3. Combined interface devices matching on interface number */
17433 - {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
17434 -@@ -1196,6 +1203,7 @@ static const struct usb_device_id products[] = {
17435 - {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
17436 - {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */
17437 - {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */
17438 -+ {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */
17439 - {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */
17440 - {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
17441 - {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
17442 -@@ -1343,17 +1351,20 @@ static bool quectel_ec20_detected(struct usb_interface *intf)
17443 - return false;
17444 - }
17445 -
17446 --static bool quectel_ep06_diag_detected(struct usb_interface *intf)
17447 -+static bool quectel_diag_detected(struct usb_interface *intf)
17448 - {
17449 - struct usb_device *dev = interface_to_usbdev(intf);
17450 - struct usb_interface_descriptor intf_desc = intf->cur_altsetting->desc;
17451 -+ u16 id_vendor = le16_to_cpu(dev->descriptor.idVendor);
17452 -+ u16 id_product = le16_to_cpu(dev->descriptor.idProduct);
17453 -
17454 -- if (le16_to_cpu(dev->descriptor.idVendor) == 0x2c7c &&
17455 -- le16_to_cpu(dev->descriptor.idProduct) == 0x0306 &&
17456 -- intf_desc.bNumEndpoints == 2)
17457 -- return true;
17458 -+ if (id_vendor != 0x2c7c || intf_desc.bNumEndpoints != 2)
17459 -+ return false;
17460 -
17461 -- return false;
17462 -+ if (id_product == 0x0306 || id_product == 0x0512)
17463 -+ return true;
17464 -+ else
17465 -+ return false;
17466 - }
17467 -
17468 - static int qmi_wwan_probe(struct usb_interface *intf,
17469 -@@ -1390,13 +1401,13 @@ static int qmi_wwan_probe(struct usb_interface *intf,
17470 - return -ENODEV;
17471 - }
17472 -
17473 -- /* Quectel EP06/EM06/EG06 supports dynamic interface configuration, so
17474 -+ /* Several Quectel modems supports dynamic interface configuration, so
17475 - * we need to match on class/subclass/protocol. These values are
17476 - * identical for the diagnostic- and QMI-interface, but bNumEndpoints is
17477 - * different. Ignore the current interface if the number of endpoints
17478 - * the number for the diag interface (two).
17479 - */
17480 -- if (quectel_ep06_diag_detected(intf))
17481 -+ if (quectel_diag_detected(intf))
17482 - return -ENODEV;
17483 -
17484 - return usbnet_probe(intf, id);
17485 -diff --git a/drivers/net/veth.c b/drivers/net/veth.c
17486 -index f412ea1cef18..b203d1867959 100644
17487 ---- a/drivers/net/veth.c
17488 -+++ b/drivers/net/veth.c
17489 -@@ -115,7 +115,8 @@ static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
17490 - p += sizeof(ethtool_stats_keys);
17491 - for (i = 0; i < dev->real_num_rx_queues; i++) {
17492 - for (j = 0; j < VETH_RQ_STATS_LEN; j++) {
17493 -- snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s",
17494 -+ snprintf(p, ETH_GSTRING_LEN,
17495 -+ "rx_queue_%u_%.11s",
17496 - i, veth_rq_stats_desc[j].desc);
17497 - p += ETH_GSTRING_LEN;
17498 - }
17499 -diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
17500 -index 7c1430ed0244..cd15c32b2e43 100644
17501 ---- a/drivers/net/vrf.c
17502 -+++ b/drivers/net/vrf.c
17503 -@@ -1273,9 +1273,14 @@ static void vrf_setup(struct net_device *dev)
17504 -
17505 - /* default to no qdisc; user can add if desired */
17506 - dev->priv_flags |= IFF_NO_QUEUE;
17507 -+ dev->priv_flags |= IFF_NO_RX_HANDLER;
17508 -
17509 -- dev->min_mtu = 0;
17510 -- dev->max_mtu = 0;
17511 -+ /* VRF devices do not care about MTU, but if the MTU is set
17512 -+ * too low then the ipv4 and ipv6 protocols are disabled
17513 -+ * which breaks networking.
17514 -+ */
17515 -+ dev->min_mtu = IPV6_MIN_MTU;
17516 -+ dev->max_mtu = ETH_MAX_MTU;
17517 - }
17518 -
17519 - static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],
17520 -diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
17521 -index 2aae11feff0c..5006daed2e96 100644
17522 ---- a/drivers/net/vxlan.c
17523 -+++ b/drivers/net/vxlan.c
17524 -@@ -1657,6 +1657,14 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
17525 - goto drop;
17526 - }
17527 -
17528 -+ rcu_read_lock();
17529 -+
17530 -+ if (unlikely(!(vxlan->dev->flags & IFF_UP))) {
17531 -+ rcu_read_unlock();
17532 -+ atomic_long_inc(&vxlan->dev->rx_dropped);
17533 -+ goto drop;
17534 -+ }
17535 -+
17536 - stats = this_cpu_ptr(vxlan->dev->tstats);
17537 - u64_stats_update_begin(&stats->syncp);
17538 - stats->rx_packets++;
17539 -@@ -1664,6 +1672,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
17540 - u64_stats_update_end(&stats->syncp);
17541 -
17542 - gro_cells_receive(&vxlan->gro_cells, skb);
17543 -+
17544 -+ rcu_read_unlock();
17545 -+
17546 - return 0;
17547 -
17548 - drop:
17549 -@@ -2693,6 +2704,8 @@ static void vxlan_uninit(struct net_device *dev)
17550 - {
17551 - struct vxlan_dev *vxlan = netdev_priv(dev);
17552 -
17553 -+ gro_cells_destroy(&vxlan->gro_cells);
17554 -+
17555 - vxlan_fdb_delete_default(vxlan, vxlan->cfg.vni);
17556 -
17557 - free_percpu(dev->tstats);
17558 -@@ -3794,7 +3807,6 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head)
17559 -
17560 - vxlan_flush(vxlan, true);
17561 -
17562 -- gro_cells_destroy(&vxlan->gro_cells);
17563 - list_del(&vxlan->next);
17564 - unregister_netdevice_queue(dev, head);
17565 - }
17566 -@@ -4172,10 +4184,8 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head)
17567 - /* If vxlan->dev is in the same netns, it has already been added
17568 - * to the list by the previous loop.
17569 - */
17570 -- if (!net_eq(dev_net(vxlan->dev), net)) {
17571 -- gro_cells_destroy(&vxlan->gro_cells);
17572 -+ if (!net_eq(dev_net(vxlan->dev), net))
17573 - unregister_netdevice_queue(vxlan->dev, head);
17574 -- }
17575 - }
17576 -
17577 - for (h = 0; h < PORT_HASH_SIZE; ++h)
17578 -diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
17579 -index 2a5668b4f6bc..1a1ea4bbf8a0 100644
17580 ---- a/drivers/net/wireless/ath/ath10k/ce.c
17581 -+++ b/drivers/net/wireless/ath/ath10k/ce.c
17582 -@@ -500,14 +500,8 @@ static int _ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,
17583 - write_index = CE_RING_IDX_INCR(nentries_mask, write_index);
17584 -
17585 - /* WORKAROUND */
17586 -- if (!(flags & CE_SEND_FLAG_GATHER)) {
17587 -- if (ar->hw_params.shadow_reg_support)
17588 -- ath10k_ce_shadow_src_ring_write_index_set(ar, ce_state,
17589 -- write_index);
17590 -- else
17591 -- ath10k_ce_src_ring_write_index_set(ar, ctrl_addr,
17592 -- write_index);
17593 -- }
17594 -+ if (!(flags & CE_SEND_FLAG_GATHER))
17595 -+ ath10k_ce_src_ring_write_index_set(ar, ctrl_addr, write_index);
17596 -
17597 - src_ring->write_index = write_index;
17598 - exit:
17599 -@@ -581,8 +575,14 @@ static int _ath10k_ce_send_nolock_64(struct ath10k_ce_pipe *ce_state,
17600 - /* Update Source Ring Write Index */
17601 - write_index = CE_RING_IDX_INCR(nentries_mask, write_index);
17602 -
17603 -- if (!(flags & CE_SEND_FLAG_GATHER))
17604 -- ath10k_ce_src_ring_write_index_set(ar, ctrl_addr, write_index);
17605 -+ if (!(flags & CE_SEND_FLAG_GATHER)) {
17606 -+ if (ar->hw_params.shadow_reg_support)
17607 -+ ath10k_ce_shadow_src_ring_write_index_set(ar, ce_state,
17608 -+ write_index);
17609 -+ else
17610 -+ ath10k_ce_src_ring_write_index_set(ar, ctrl_addr,
17611 -+ write_index);
17612 -+ }
17613 -
17614 - src_ring->write_index = write_index;
17615 - exit:
17616 -@@ -1404,12 +1404,12 @@ static int ath10k_ce_alloc_shadow_base(struct ath10k *ar,
17617 - u32 nentries)
17618 - {
17619 - src_ring->shadow_base_unaligned = kcalloc(nentries,
17620 -- sizeof(struct ce_desc),
17621 -+ sizeof(struct ce_desc_64),
17622 - GFP_KERNEL);
17623 - if (!src_ring->shadow_base_unaligned)
17624 - return -ENOMEM;
17625 -
17626 -- src_ring->shadow_base = (struct ce_desc *)
17627 -+ src_ring->shadow_base = (struct ce_desc_64 *)
17628 - PTR_ALIGN(src_ring->shadow_base_unaligned,
17629 - CE_DESC_RING_ALIGN);
17630 - return 0;
17631 -@@ -1461,7 +1461,7 @@ ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
17632 - ret = ath10k_ce_alloc_shadow_base(ar, src_ring, nentries);
17633 - if (ret) {
17634 - dma_free_coherent(ar->dev,
17635 -- (nentries * sizeof(struct ce_desc) +
17636 -+ (nentries * sizeof(struct ce_desc_64) +
17637 - CE_DESC_RING_ALIGN),
17638 - src_ring->base_addr_owner_space_unaligned,
17639 - base_addr);
17640 -diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h
17641 -index ead9987c3259..463e2fc8b501 100644
17642 ---- a/drivers/net/wireless/ath/ath10k/ce.h
17643 -+++ b/drivers/net/wireless/ath/ath10k/ce.h
17644 -@@ -118,7 +118,7 @@ struct ath10k_ce_ring {
17645 - u32 base_addr_ce_space;
17646 -
17647 - char *shadow_base_unaligned;
17648 -- struct ce_desc *shadow_base;
17649 -+ struct ce_desc_64 *shadow_base;
17650 -
17651 - /* keep last */
17652 - void *per_transfer_context[0];
17653 -diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
17654 -index 4778a455d81a..068f1a7e07d3 100644
17655 ---- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
17656 -+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
17657 -@@ -696,11 +696,12 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
17658 - " %llu ", stats->ht[j][i]);
17659 - len += scnprintf(buf + len, size - len, "\n");
17660 - len += scnprintf(buf + len, size - len,
17661 -- " BW %s (20,40,80,160 MHz)\n", str[j]);
17662 -+ " BW %s (20,5,10,40,80,160 MHz)\n", str[j]);
17663 - len += scnprintf(buf + len, size - len,
17664 -- " %llu %llu %llu %llu\n",
17665 -+ " %llu %llu %llu %llu %llu %llu\n",
17666 - stats->bw[j][0], stats->bw[j][1],
17667 -- stats->bw[j][2], stats->bw[j][3]);
17668 -+ stats->bw[j][2], stats->bw[j][3],
17669 -+ stats->bw[j][4], stats->bw[j][5]);
17670 - len += scnprintf(buf + len, size - len,
17671 - " NSS %s (1x1,2x2,3x3,4x4)\n", str[j]);
17672 - len += scnprintf(buf + len, size - len,
17673 -diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
17674 -index f42bac204ef8..ecf34ce7acf0 100644
17675 ---- a/drivers/net/wireless/ath/ath10k/htt_rx.c
17676 -+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
17677 -@@ -2130,9 +2130,15 @@ static bool ath10k_htt_rx_proc_rx_ind_hl(struct ath10k_htt *htt,
17678 - hdr = (struct ieee80211_hdr *)skb->data;
17679 - rx_status = IEEE80211_SKB_RXCB(skb);
17680 - rx_status->chains |= BIT(0);
17681 -- rx_status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
17682 -- rx->ppdu.combined_rssi;
17683 -- rx_status->flag &= ~RX_FLAG_NO_SIGNAL_VAL;
17684 -+ if (rx->ppdu.combined_rssi == 0) {
17685 -+ /* SDIO firmware does not provide signal */
17686 -+ rx_status->signal = 0;
17687 -+ rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
17688 -+ } else {
17689 -+ rx_status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
17690 -+ rx->ppdu.combined_rssi;
17691 -+ rx_status->flag &= ~RX_FLAG_NO_SIGNAL_VAL;
17692 -+ }
17693 -
17694 - spin_lock_bh(&ar->data_lock);
17695 - ch = ar->scan_channel;
17696 -diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
17697 -index 2034ccc7cc72..1d5d0209ebeb 100644
17698 ---- a/drivers/net/wireless/ath/ath10k/wmi.h
17699 -+++ b/drivers/net/wireless/ath/ath10k/wmi.h
17700 -@@ -5003,7 +5003,7 @@ enum wmi_rate_preamble {
17701 - #define ATH10K_FW_SKIPPED_RATE_CTRL(flags) (((flags) >> 6) & 0x1)
17702 -
17703 - #define ATH10K_VHT_MCS_NUM 10
17704 --#define ATH10K_BW_NUM 4
17705 -+#define ATH10K_BW_NUM 6
17706 - #define ATH10K_NSS_NUM 4
17707 - #define ATH10K_LEGACY_NUM 12
17708 - #define ATH10K_GI_NUM 2
17709 -diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
17710 -index c070a9e51ebf..fae572b38416 100644
17711 ---- a/drivers/net/wireless/ath/ath9k/init.c
17712 -+++ b/drivers/net/wireless/ath/ath9k/init.c
17713 -@@ -636,15 +636,15 @@ static int ath9k_of_init(struct ath_softc *sc)
17714 - ret = ath9k_eeprom_request(sc, eeprom_name);
17715 - if (ret)
17716 - return ret;
17717 -+
17718 -+ ah->ah_flags &= ~AH_USE_EEPROM;
17719 -+ ah->ah_flags |= AH_NO_EEP_SWAP;
17720 - }
17721 -
17722 - mac = of_get_mac_address(np);
17723 - if (mac)
17724 - ether_addr_copy(common->macaddr, mac);
17725 -
17726 -- ah->ah_flags &= ~AH_USE_EEPROM;
17727 -- ah->ah_flags |= AH_NO_EEP_SWAP;
17728 --
17729 - return 0;
17730 - }
17731 -
17732 -diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c
17733 -index 9b2f9f543952..5a44f9d0ff02 100644
17734 ---- a/drivers/net/wireless/ath/wil6210/cfg80211.c
17735 -+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
17736 -@@ -1580,6 +1580,12 @@ static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len,
17737 - u8 *buf, *dpos;
17738 - const u8 *spos;
17739 -
17740 -+ if (!ies1)
17741 -+ ies1_len = 0;
17742 -+
17743 -+ if (!ies2)
17744 -+ ies2_len = 0;
17745 -+
17746 - if (ies1_len == 0 && ies2_len == 0) {
17747 - *merged_ies = NULL;
17748 - *merged_len = 0;
17749 -@@ -1589,17 +1595,19 @@ static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len,
17750 - buf = kmalloc(ies1_len + ies2_len, GFP_KERNEL);
17751 - if (!buf)
17752 - return -ENOMEM;
17753 -- memcpy(buf, ies1, ies1_len);
17754 -+ if (ies1)
17755 -+ memcpy(buf, ies1, ies1_len);
17756 - dpos = buf + ies1_len;
17757 - spos = ies2;
17758 -- while (spos + 1 < ies2 + ies2_len) {
17759 -+ while (spos && (spos + 1 < ies2 + ies2_len)) {
17760 - /* IE tag at offset 0, length at offset 1 */
17761 - u16 ielen = 2 + spos[1];
17762 -
17763 - if (spos + ielen > ies2 + ies2_len)
17764 - break;
17765 - if (spos[0] == WLAN_EID_VENDOR_SPECIFIC &&
17766 -- !_wil_cfg80211_find_ie(ies1, ies1_len, spos, ielen)) {
17767 -+ (!ies1 || !_wil_cfg80211_find_ie(ies1, ies1_len,
17768 -+ spos, ielen))) {
17769 - memcpy(dpos, spos, ielen);
17770 - dpos += ielen;
17771 - }
17772 -diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
17773 -index 1f1e95a15a17..0ce1d8174e6d 100644
17774 ---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
17775 -+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
17776 -@@ -149,7 +149,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
17777 - return err;
17778 - }
17779 -
17780 -- err = request_firmware(&clm, clm_name, bus->dev);
17781 -+ err = firmware_request_nowarn(&clm, clm_name, bus->dev);
17782 - if (err) {
17783 - brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n",
17784 - err);
17785 -diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
17786 -index 0d6c313b6669..19ec55cef802 100644
17787 ---- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
17788 -+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
17789 -@@ -127,13 +127,17 @@ static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
17790 -
17791 - static int iwl_configure_rxq(struct iwl_mvm *mvm)
17792 - {
17793 -- int i, num_queues, size;
17794 -+ int i, num_queues, size, ret;
17795 - struct iwl_rfh_queue_config *cmd;
17796 -+ struct iwl_host_cmd hcmd = {
17797 -+ .id = WIDE_ID(DATA_PATH_GROUP, RFH_QUEUE_CONFIG_CMD),
17798 -+ .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
17799 -+ };
17800 -
17801 - /* Do not configure default queue, it is configured via context info */
17802 - num_queues = mvm->trans->num_rx_queues - 1;
17803 -
17804 -- size = sizeof(*cmd) + num_queues * sizeof(struct iwl_rfh_queue_data);
17805 -+ size = struct_size(cmd, data, num_queues);
17806 -
17807 - cmd = kzalloc(size, GFP_KERNEL);
17808 - if (!cmd)
17809 -@@ -154,10 +158,14 @@ static int iwl_configure_rxq(struct iwl_mvm *mvm)
17810 - cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid);
17811 - }
17812 -
17813 -- return iwl_mvm_send_cmd_pdu(mvm,
17814 -- WIDE_ID(DATA_PATH_GROUP,
17815 -- RFH_QUEUE_CONFIG_CMD),
17816 -- 0, size, cmd);
17817 -+ hcmd.data[0] = cmd;
17818 -+ hcmd.len[0] = size;
17819 -+
17820 -+ ret = iwl_mvm_send_cmd(mvm, &hcmd);
17821 -+
17822 -+ kfree(cmd);
17823 -+
17824 -+ return ret;
17825 - }
17826 -
17827 - static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm)
17828 -diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
17829 -index 9e850c25877b..c596c7b13504 100644
17830 ---- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
17831 -+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
17832 -@@ -499,7 +499,7 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
17833 - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
17834 - struct iwl_rb_allocator *rba = &trans_pcie->rba;
17835 - struct list_head local_empty;
17836 -- int pending = atomic_xchg(&rba->req_pending, 0);
17837 -+ int pending = atomic_read(&rba->req_pending);
17838 -
17839 - IWL_DEBUG_RX(trans, "Pending allocation requests = %d\n", pending);
17840 -
17841 -@@ -554,11 +554,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
17842 - i++;
17843 - }
17844 -
17845 -+ atomic_dec(&rba->req_pending);
17846 - pending--;
17847 -+
17848 - if (!pending) {
17849 -- pending = atomic_xchg(&rba->req_pending, 0);
17850 -+ pending = atomic_read(&rba->req_pending);
17851 - IWL_DEBUG_RX(trans,
17852 -- "Pending allocation requests = %d\n",
17853 -+ "Got more pending allocation requests = %d\n",
17854 - pending);
17855 - }
17856 -
17857 -@@ -570,12 +572,15 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
17858 - spin_unlock(&rba->lock);
17859 -
17860 - atomic_inc(&rba->req_ready);
17861 -+
17862 - }
17863 -
17864 - spin_lock(&rba->lock);
17865 - /* return unused rbds to the allocator empty list */
17866 - list_splice_tail(&local_empty, &rba->rbd_empty);
17867 - spin_unlock(&rba->lock);
17868 -+
17869 -+ IWL_DEBUG_RX(trans, "%s, exit.\n", __func__);
17870 - }
17871 -
17872 - /*
17873 -diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
17874 -index 789337ea676a..6ede6168bd85 100644
17875 ---- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
17876 -+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
17877 -@@ -433,8 +433,6 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
17878 - skb_tail_pointer(skb),
17879 - MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp);
17880 -
17881 -- cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
17882 --
17883 - lbtf_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n",
17884 - cardp->rx_urb);
17885 - ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC);
17886 -diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
17887 -index 1467af22e394..883752f640b4 100644
17888 ---- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
17889 -+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
17890 -@@ -4310,11 +4310,13 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
17891 - wiphy->mgmt_stypes = mwifiex_mgmt_stypes;
17892 - wiphy->max_remain_on_channel_duration = 5000;
17893 - wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
17894 -- BIT(NL80211_IFTYPE_ADHOC) |
17895 - BIT(NL80211_IFTYPE_P2P_CLIENT) |
17896 - BIT(NL80211_IFTYPE_P2P_GO) |
17897 - BIT(NL80211_IFTYPE_AP);
17898 -
17899 -+ if (ISSUPP_ADHOC_ENABLED(adapter->fw_cap_info))
17900 -+ wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
17901 -+
17902 - wiphy->bands[NL80211_BAND_2GHZ] = &mwifiex_band_2ghz;
17903 - if (adapter->config_bands & BAND_A)
17904 - wiphy->bands[NL80211_BAND_5GHZ] = &mwifiex_band_5ghz;
17905 -@@ -4374,11 +4376,13 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
17906 - wiphy->available_antennas_tx = BIT(adapter->number_of_antenna) - 1;
17907 - wiphy->available_antennas_rx = BIT(adapter->number_of_antenna) - 1;
17908 -
17909 -- wiphy->features |= NL80211_FEATURE_HT_IBSS |
17910 -- NL80211_FEATURE_INACTIVITY_TIMER |
17911 -+ wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER |
17912 - NL80211_FEATURE_LOW_PRIORITY_SCAN |
17913 - NL80211_FEATURE_NEED_OBSS_SCAN;
17914 -
17915 -+ if (ISSUPP_ADHOC_ENABLED(adapter->fw_cap_info))
17916 -+ wiphy->features |= NL80211_FEATURE_HT_IBSS;
17917 -+
17918 - if (ISSUPP_RANDOM_MAC(adapter->fw_cap_info))
17919 - wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR |
17920 - NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |
17921 -diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
17922 -index 530e5593765c..a1529920d877 100644
17923 ---- a/drivers/net/wireless/mediatek/mt76/eeprom.c
17924 -+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
17925 -@@ -54,22 +54,30 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len)
17926 - part = np->name;
17927 -
17928 - mtd = get_mtd_device_nm(part);
17929 -- if (IS_ERR(mtd))
17930 -- return PTR_ERR(mtd);
17931 -+ if (IS_ERR(mtd)) {
17932 -+ ret = PTR_ERR(mtd);
17933 -+ goto out_put_node;
17934 -+ }
17935 -
17936 -- if (size <= sizeof(*list))
17937 -- return -EINVAL;
17938 -+ if (size <= sizeof(*list)) {
17939 -+ ret = -EINVAL;
17940 -+ goto out_put_node;
17941 -+ }
17942 -
17943 - offset = be32_to_cpup(list);
17944 - ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data);
17945 - put_mtd_device(mtd);
17946 - if (ret)
17947 -- return ret;
17948 -+ goto out_put_node;
17949 -
17950 -- if (retlen < len)
17951 -- return -EINVAL;
17952 -+ if (retlen < len) {
17953 -+ ret = -EINVAL;
17954 -+ goto out_put_node;
17955 -+ }
17956 -
17957 -- return 0;
17958 -+out_put_node:
17959 -+ of_node_put(np);
17960 -+ return ret;
17961 - #else
17962 - return -ENOENT;
17963 - #endif
17964 -diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
17965 -index 5cd508a68609..6d29ba4046c3 100644
17966 ---- a/drivers/net/wireless/mediatek/mt76/mt76.h
17967 -+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
17968 -@@ -713,6 +713,19 @@ static inline bool mt76u_check_sg(struct mt76_dev *dev)
17969 - udev->speed == USB_SPEED_WIRELESS));
17970 - }
17971 -
17972 -+static inline int
17973 -+mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int timeout)
17974 -+{
17975 -+ struct usb_interface *intf = to_usb_interface(dev->dev);
17976 -+ struct usb_device *udev = interface_to_usbdev(intf);
17977 -+ struct mt76_usb *usb = &dev->usb;
17978 -+ unsigned int pipe;
17979 -+ int sent;
17980 -+
17981 -+ pipe = usb_sndbulkpipe(udev, usb->out_ep[MT_EP_OUT_INBAND_CMD]);
17982 -+ return usb_bulk_msg(udev, pipe, data, len, &sent, timeout);
17983 -+}
17984 -+
17985 - int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
17986 - u8 req_type, u16 val, u16 offset,
17987 - void *buf, size_t len);
17988 -diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
17989 -index c08bf371e527..7c9dfa54fee8 100644
17990 ---- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
17991 -+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
17992 -@@ -309,7 +309,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
17993 - ccmp_pn[6] = pn >> 32;
17994 - ccmp_pn[7] = pn >> 40;
17995 - txwi->iv = *((__le32 *)&ccmp_pn[0]);
17996 -- txwi->eiv = *((__le32 *)&ccmp_pn[1]);
17997 -+ txwi->eiv = *((__le32 *)&ccmp_pn[4]);
17998 - }
17999 -
18000 - spin_lock_bh(&dev->mt76.lock);
18001 -diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
18002 -index 6db789f90269..2ca393e267af 100644
18003 ---- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
18004 -+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
18005 -@@ -121,18 +121,14 @@ static int
18006 - __mt76x02u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb,
18007 - int cmd, bool wait_resp)
18008 - {
18009 -- struct usb_interface *intf = to_usb_interface(dev->dev);
18010 -- struct usb_device *udev = interface_to_usbdev(intf);
18011 - struct mt76_usb *usb = &dev->usb;
18012 -- unsigned int pipe;
18013 -- int ret, sent;
18014 -+ int ret;
18015 - u8 seq = 0;
18016 - u32 info;
18017 -
18018 - if (test_bit(MT76_REMOVED, &dev->state))
18019 - return 0;
18020 -
18021 -- pipe = usb_sndbulkpipe(udev, usb->out_ep[MT_EP_OUT_INBAND_CMD]);
18022 - if (wait_resp) {
18023 - seq = ++usb->mcu.msg_seq & 0xf;
18024 - if (!seq)
18025 -@@ -146,7 +142,7 @@ __mt76x02u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb,
18026 - if (ret)
18027 - return ret;
18028 -
18029 -- ret = usb_bulk_msg(udev, pipe, skb->data, skb->len, &sent, 500);
18030 -+ ret = mt76u_bulk_msg(dev, skb->data, skb->len, 500);
18031 - if (ret)
18032 - return ret;
18033 -
18034 -@@ -268,14 +264,12 @@ void mt76x02u_mcu_fw_reset(struct mt76x02_dev *dev)
18035 - EXPORT_SYMBOL_GPL(mt76x02u_mcu_fw_reset);
18036 -
18037 - static int
18038 --__mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, struct mt76u_buf *buf,
18039 -+__mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, u8 *data,
18040 - const void *fw_data, int len, u32 dst_addr)
18041 - {
18042 -- u8 *data = sg_virt(&buf->urb->sg[0]);
18043 -- DECLARE_COMPLETION_ONSTACK(cmpl);
18044 - __le32 info;
18045 - u32 val;
18046 -- int err;
18047 -+ int err, data_len;
18048 -
18049 - info = cpu_to_le32(FIELD_PREP(MT_MCU_MSG_PORT, CPU_TX_PORT) |
18050 - FIELD_PREP(MT_MCU_MSG_LEN, len) |
18051 -@@ -291,25 +285,12 @@ __mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, struct mt76u_buf *buf,
18052 - mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE,
18053 - MT_FCE_DMA_LEN, len << 16);
18054 -
18055 -- buf->len = MT_CMD_HDR_LEN + len + sizeof(info);
18056 -- err = mt76u_submit_buf(&dev->mt76, USB_DIR_OUT,
18057 -- MT_EP_OUT_INBAND_CMD,
18058 -- buf, GFP_KERNEL,
18059 -- mt76u_mcu_complete_urb, &cmpl);
18060 -- if (err < 0)
18061 -- return err;
18062 --
18063 -- if (!wait_for_completion_timeout(&cmpl,
18064 -- msecs_to_jiffies(1000))) {
18065 -- dev_err(dev->mt76.dev, "firmware upload timed out\n");
18066 -- usb_kill_urb(buf->urb);
18067 -- return -ETIMEDOUT;
18068 -- }
18069 -+ data_len = MT_CMD_HDR_LEN + len + sizeof(info);
18070 -
18071 -- if (mt76u_urb_error(buf->urb)) {
18072 -- dev_err(dev->mt76.dev, "firmware upload failed: %d\n",
18073 -- buf->urb->status);
18074 -- return buf->urb->status;
18075 -+ err = mt76u_bulk_msg(&dev->mt76, data, data_len, 1000);
18076 -+ if (err) {
18077 -+ dev_err(dev->mt76.dev, "firmware upload failed: %d\n", err);
18078 -+ return err;
18079 - }
18080 -
18081 - val = mt76_rr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX);
18082 -@@ -322,17 +303,16 @@ __mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, struct mt76u_buf *buf,
18083 - int mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, const void *data,
18084 - int data_len, u32 max_payload, u32 offset)
18085 - {
18086 -- int err, len, pos = 0, max_len = max_payload - 8;
18087 -- struct mt76u_buf buf;
18088 -+ int len, err = 0, pos = 0, max_len = max_payload - 8;
18089 -+ u8 *buf;
18090 -
18091 -- err = mt76u_buf_alloc(&dev->mt76, &buf, 1, max_payload, max_payload,
18092 -- GFP_KERNEL);
18093 -- if (err < 0)
18094 -- return err;
18095 -+ buf = kmalloc(max_payload, GFP_KERNEL);
18096 -+ if (!buf)
18097 -+ return -ENOMEM;
18098 -
18099 - while (data_len > 0) {
18100 - len = min_t(int, data_len, max_len);
18101 -- err = __mt76x02u_mcu_fw_send_data(dev, &buf, data + pos,
18102 -+ err = __mt76x02u_mcu_fw_send_data(dev, buf, data + pos,
18103 - len, offset + pos);
18104 - if (err < 0)
18105 - break;
18106 -@@ -341,7 +321,7 @@ int mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, const void *data,
18107 - pos += len;
18108 - usleep_range(5000, 10000);
18109 - }
18110 -- mt76u_buf_free(&buf);
18111 -+ kfree(buf);
18112 -
18113 - return err;
18114 - }
18115 -diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
18116 -index b061263453d4..61cde0f9f58f 100644
18117 ---- a/drivers/net/wireless/mediatek/mt76/usb.c
18118 -+++ b/drivers/net/wireless/mediatek/mt76/usb.c
18119 -@@ -326,7 +326,6 @@ int mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf,
18120 -
18121 - return mt76u_fill_rx_sg(dev, buf, nsgs, len, sglen);
18122 - }
18123 --EXPORT_SYMBOL_GPL(mt76u_buf_alloc);
18124 -
18125 - void mt76u_buf_free(struct mt76u_buf *buf)
18126 - {
18127 -@@ -838,16 +837,9 @@ int mt76u_alloc_queues(struct mt76_dev *dev)
18128 -
18129 - err = mt76u_alloc_rx(dev);
18130 - if (err < 0)
18131 -- goto err;
18132 --
18133 -- err = mt76u_alloc_tx(dev);
18134 -- if (err < 0)
18135 -- goto err;
18136 -+ return err;
18137 -
18138 -- return 0;
18139 --err:
18140 -- mt76u_queues_deinit(dev);
18141 -- return err;
18142 -+ return mt76u_alloc_tx(dev);
18143 - }
18144 - EXPORT_SYMBOL_GPL(mt76u_alloc_queues);
18145 -
18146 -diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.h b/drivers/net/wireless/mediatek/mt7601u/eeprom.h
18147 -index 662d12703b69..57b503ae63f1 100644
18148 ---- a/drivers/net/wireless/mediatek/mt7601u/eeprom.h
18149 -+++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.h
18150 -@@ -17,7 +17,7 @@
18151 -
18152 - struct mt7601u_dev;
18153 -
18154 --#define MT7601U_EE_MAX_VER 0x0c
18155 -+#define MT7601U_EE_MAX_VER 0x0d
18156 - #define MT7601U_EEPROM_SIZE 256
18157 -
18158 - #define MT7601U_DEFAULT_TX_POWER 6
18159 -diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
18160 -index 26b187336875..2e12de813a5b 100644
18161 ---- a/drivers/net/wireless/ti/wlcore/main.c
18162 -+++ b/drivers/net/wireless/ti/wlcore/main.c
18163 -@@ -1085,8 +1085,11 @@ static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt)
18164 - goto out;
18165 -
18166 - ret = wl12xx_fetch_firmware(wl, plt);
18167 -- if (ret < 0)
18168 -- goto out;
18169 -+ if (ret < 0) {
18170 -+ kfree(wl->fw_status);
18171 -+ kfree(wl->raw_fw_status);
18172 -+ kfree(wl->tx_res_if);
18173 -+ }
18174 -
18175 - out:
18176 - return ret;
18177 -diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
18178 -index a11bf4e6b451..6d6e9a12150b 100644
18179 ---- a/drivers/nvdimm/label.c
18180 -+++ b/drivers/nvdimm/label.c
18181 -@@ -755,7 +755,7 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
18182 -
18183 - static int __pmem_label_update(struct nd_region *nd_region,
18184 - struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm,
18185 -- int pos)
18186 -+ int pos, unsigned long flags)
18187 - {
18188 - struct nd_namespace_common *ndns = &nspm->nsio.common;
18189 - struct nd_interleave_set *nd_set = nd_region->nd_set;
18190 -@@ -796,7 +796,7 @@ static int __pmem_label_update(struct nd_region *nd_region,
18191 - memcpy(nd_label->uuid, nspm->uuid, NSLABEL_UUID_LEN);
18192 - if (nspm->alt_name)
18193 - memcpy(nd_label->name, nspm->alt_name, NSLABEL_NAME_LEN);
18194 -- nd_label->flags = __cpu_to_le32(NSLABEL_FLAG_UPDATING);
18195 -+ nd_label->flags = __cpu_to_le32(flags);
18196 - nd_label->nlabel = __cpu_to_le16(nd_region->ndr_mappings);
18197 - nd_label->position = __cpu_to_le16(pos);
18198 - nd_label->isetcookie = __cpu_to_le64(cookie);
18199 -@@ -1249,13 +1249,13 @@ static int del_labels(struct nd_mapping *nd_mapping, u8 *uuid)
18200 - int nd_pmem_namespace_label_update(struct nd_region *nd_region,
18201 - struct nd_namespace_pmem *nspm, resource_size_t size)
18202 - {
18203 -- int i;
18204 -+ int i, rc;
18205 -
18206 - for (i = 0; i < nd_region->ndr_mappings; i++) {
18207 - struct nd_mapping *nd_mapping = &nd_region->mapping[i];
18208 - struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
18209 - struct resource *res;
18210 -- int rc, count = 0;
18211 -+ int count = 0;
18212 -
18213 - if (size == 0) {
18214 - rc = del_labels(nd_mapping, nspm->uuid);
18215 -@@ -1273,7 +1273,20 @@ int nd_pmem_namespace_label_update(struct nd_region *nd_region,
18216 - if (rc < 0)
18217 - return rc;
18218 -
18219 -- rc = __pmem_label_update(nd_region, nd_mapping, nspm, i);
18220 -+ rc = __pmem_label_update(nd_region, nd_mapping, nspm, i,
18221 -+ NSLABEL_FLAG_UPDATING);
18222 -+ if (rc)
18223 -+ return rc;
18224 -+ }
18225 -+
18226 -+ if (size == 0)
18227 -+ return 0;
18228 -+
18229 -+ /* Clear the UPDATING flag per UEFI 2.7 expectations */
18230 -+ for (i = 0; i < nd_region->ndr_mappings; i++) {
18231 -+ struct nd_mapping *nd_mapping = &nd_region->mapping[i];
18232 -+
18233 -+ rc = __pmem_label_update(nd_region, nd_mapping, nspm, i, 0);
18234 - if (rc)
18235 - return rc;
18236 - }
18237 -diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
18238 -index 4b077555ac70..33a3b23b3db7 100644
18239 ---- a/drivers/nvdimm/namespace_devs.c
18240 -+++ b/drivers/nvdimm/namespace_devs.c
18241 -@@ -138,6 +138,7 @@ bool nd_is_uuid_unique(struct device *dev, u8 *uuid)
18242 - bool pmem_should_map_pages(struct device *dev)
18243 - {
18244 - struct nd_region *nd_region = to_nd_region(dev->parent);
18245 -+ struct nd_namespace_common *ndns = to_ndns(dev);
18246 - struct nd_namespace_io *nsio;
18247 -
18248 - if (!IS_ENABLED(CONFIG_ZONE_DEVICE))
18249 -@@ -149,6 +150,9 @@ bool pmem_should_map_pages(struct device *dev)
18250 - if (is_nd_pfn(dev) || is_nd_btt(dev))
18251 - return false;
18252 -
18253 -+ if (ndns->force_raw)
18254 -+ return false;
18255 -+
18256 - nsio = to_nd_namespace_io(dev);
18257 - if (region_intersects(nsio->res.start, resource_size(&nsio->res),
18258 - IORESOURCE_SYSTEM_RAM,
18259 -diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
18260 -index 6f22272e8d80..7760c1b91853 100644
18261 ---- a/drivers/nvdimm/pfn_devs.c
18262 -+++ b/drivers/nvdimm/pfn_devs.c
18263 -@@ -593,7 +593,7 @@ static unsigned long init_altmap_base(resource_size_t base)
18264 -
18265 - static unsigned long init_altmap_reserve(resource_size_t base)
18266 - {
18267 -- unsigned long reserve = PHYS_PFN(SZ_8K);
18268 -+ unsigned long reserve = PFN_UP(SZ_8K);
18269 - unsigned long base_pfn = PHYS_PFN(base);
18270 -
18271 - reserve += base_pfn - PFN_SECTION_ALIGN_DOWN(base_pfn);
18272 -@@ -678,7 +678,7 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun
18273 - if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM,
18274 - IORES_DESC_NONE) == REGION_MIXED
18275 - || !IS_ALIGNED(end, nd_pfn->align)
18276 -- || nd_region_conflict(nd_region, start, size + adjust))
18277 -+ || nd_region_conflict(nd_region, start, size))
18278 - *end_trunc = end - phys_pmem_align_down(nd_pfn, end);
18279 - }
18280 -
18281 -diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
18282 -index 89accc76d71c..c37d5bbd72ab 100644
18283 ---- a/drivers/nvme/host/fc.c
18284 -+++ b/drivers/nvme/host/fc.c
18285 -@@ -3018,7 +3018,10 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
18286 -
18287 - ctrl->ctrl.opts = opts;
18288 - ctrl->ctrl.nr_reconnects = 0;
18289 -- ctrl->ctrl.numa_node = dev_to_node(lport->dev);
18290 -+ if (lport->dev)
18291 -+ ctrl->ctrl.numa_node = dev_to_node(lport->dev);
18292 -+ else
18293 -+ ctrl->ctrl.numa_node = NUMA_NO_NODE;
18294 - INIT_LIST_HEAD(&ctrl->ctrl_list);
18295 - ctrl->lport = lport;
18296 - ctrl->rport = rport;
18297 -diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
18298 -index 88d260f31835..02c63c463222 100644
18299 ---- a/drivers/nvme/target/core.c
18300 -+++ b/drivers/nvme/target/core.c
18301 -@@ -1171,6 +1171,15 @@ static void nvmet_release_p2p_ns_map(struct nvmet_ctrl *ctrl)
18302 - put_device(ctrl->p2p_client);
18303 - }
18304 -
18305 -+static void nvmet_fatal_error_handler(struct work_struct *work)
18306 -+{
18307 -+ struct nvmet_ctrl *ctrl =
18308 -+ container_of(work, struct nvmet_ctrl, fatal_err_work);
18309 -+
18310 -+ pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
18311 -+ ctrl->ops->delete_ctrl(ctrl);
18312 -+}
18313 -+
18314 - u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
18315 - struct nvmet_req *req, u32 kato, struct nvmet_ctrl **ctrlp)
18316 - {
18317 -@@ -1213,6 +1222,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
18318 - INIT_WORK(&ctrl->async_event_work, nvmet_async_event_work);
18319 - INIT_LIST_HEAD(&ctrl->async_events);
18320 - INIT_RADIX_TREE(&ctrl->p2p_ns_map, GFP_KERNEL);
18321 -+ INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
18322 -
18323 - memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
18324 - memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
18325 -@@ -1316,21 +1326,11 @@ void nvmet_ctrl_put(struct nvmet_ctrl *ctrl)
18326 - kref_put(&ctrl->ref, nvmet_ctrl_free);
18327 - }
18328 -
18329 --static void nvmet_fatal_error_handler(struct work_struct *work)
18330 --{
18331 -- struct nvmet_ctrl *ctrl =
18332 -- container_of(work, struct nvmet_ctrl, fatal_err_work);
18333 --
18334 -- pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
18335 -- ctrl->ops->delete_ctrl(ctrl);
18336 --}
18337 --
18338 - void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl)
18339 - {
18340 - mutex_lock(&ctrl->lock);
18341 - if (!(ctrl->csts & NVME_CSTS_CFS)) {
18342 - ctrl->csts |= NVME_CSTS_CFS;
18343 -- INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
18344 - schedule_work(&ctrl->fatal_err_work);
18345 - }
18346 - mutex_unlock(&ctrl->lock);
18347 -diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
18348 -index f7301bb4ef3b..3ce65927e11c 100644
18349 ---- a/drivers/nvmem/core.c
18350 -+++ b/drivers/nvmem/core.c
18351 -@@ -686,9 +686,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
18352 - if (rval)
18353 - goto err_remove_cells;
18354 -
18355 -- rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
18356 -- if (rval)
18357 -- goto err_remove_cells;
18358 -+ blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
18359 -
18360 - return nvmem;
18361 -
18362 -diff --git a/drivers/opp/core.c b/drivers/opp/core.c
18363 -index 18f1639dbc4a..f5d2fa195f5f 100644
18364 ---- a/drivers/opp/core.c
18365 -+++ b/drivers/opp/core.c
18366 -@@ -743,7 +743,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
18367 - old_freq, freq);
18368 -
18369 - /* Scaling up? Configure required OPPs before frequency */
18370 -- if (freq > old_freq) {
18371 -+ if (freq >= old_freq) {
18372 - ret = _set_required_opps(dev, opp_table, opp);
18373 - if (ret)
18374 - goto put_opp;
18375 -diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
18376 -index 9c8249f74479..6296dbb83d47 100644
18377 ---- a/drivers/parport/parport_pc.c
18378 -+++ b/drivers/parport/parport_pc.c
18379 -@@ -1377,7 +1377,7 @@ static struct superio_struct *find_superio(struct parport *p)
18380 - {
18381 - int i;
18382 - for (i = 0; i < NR_SUPERIOS; i++)
18383 -- if (superios[i].io != p->base)
18384 -+ if (superios[i].io == p->base)
18385 - return &superios[i];
18386 - return NULL;
18387 - }
18388 -diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
18389 -index 721d60a5d9e4..9c5614f21b8e 100644
18390 ---- a/drivers/pci/controller/dwc/pcie-designware-host.c
18391 -+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
18392 -@@ -439,7 +439,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
18393 - if (ret)
18394 - pci->num_viewport = 2;
18395 -
18396 -- if (IS_ENABLED(CONFIG_PCI_MSI)) {
18397 -+ if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled()) {
18398 - /*
18399 - * If a specific SoC driver needs to change the
18400 - * default number of vectors, it needs to implement
18401 -diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
18402 -index d185ea5fe996..a7f703556790 100644
18403 ---- a/drivers/pci/controller/dwc/pcie-qcom.c
18404 -+++ b/drivers/pci/controller/dwc/pcie-qcom.c
18405 -@@ -1228,7 +1228,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
18406 -
18407 - pcie->ops = of_device_get_match_data(dev);
18408 -
18409 -- pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW);
18410 -+ pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_HIGH);
18411 - if (IS_ERR(pcie->reset)) {
18412 - ret = PTR_ERR(pcie->reset);
18413 - goto err_pm_runtime_put;
18414 -diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
18415 -index 750081c1cb48..6eecae447af3 100644
18416 ---- a/drivers/pci/controller/pci-aardvark.c
18417 -+++ b/drivers/pci/controller/pci-aardvark.c
18418 -@@ -499,7 +499,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
18419 - bridge->data = pcie;
18420 - bridge->ops = &advk_pci_bridge_emul_ops;
18421 -
18422 -- pci_bridge_emul_init(bridge);
18423 -+ pci_bridge_emul_init(bridge, 0);
18424 -
18425 - }
18426 -
18427 -diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
18428 -index fa0fc46edb0c..d3a0419e42f2 100644
18429 ---- a/drivers/pci/controller/pci-mvebu.c
18430 -+++ b/drivers/pci/controller/pci-mvebu.c
18431 -@@ -583,7 +583,7 @@ static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
18432 - bridge->data = port;
18433 - bridge->ops = &mvebu_pci_bridge_emul_ops;
18434 -
18435 -- pci_bridge_emul_init(bridge);
18436 -+ pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR);
18437 - }
18438 -
18439 - static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys)
18440 -diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
18441 -index 55e471c18e8d..c42fe5c4319f 100644
18442 ---- a/drivers/pci/controller/pcie-mediatek.c
18443 -+++ b/drivers/pci/controller/pcie-mediatek.c
18444 -@@ -654,7 +654,6 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port)
18445 - struct resource *mem = &pcie->mem;
18446 - const struct mtk_pcie_soc *soc = port->pcie->soc;
18447 - u32 val;
18448 -- size_t size;
18449 - int err;
18450 -
18451 - /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */
18452 -@@ -706,8 +705,8 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port)
18453 - mtk_pcie_enable_msi(port);
18454 -
18455 - /* Set AHB to PCIe translation windows */
18456 -- size = mem->end - mem->start;
18457 -- val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size));
18458 -+ val = lower_32_bits(mem->start) |
18459 -+ AHB2PCIE_SIZE(fls(resource_size(mem)));
18460 - writel(val, port->base + PCIE_AHB_TRANS_BASE0_L);
18461 -
18462 - val = upper_32_bits(mem->start);
18463 -diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
18464 -index 3f3df4c29f6e..905282a8ddaa 100644
18465 ---- a/drivers/pci/hotplug/pciehp_ctrl.c
18466 -+++ b/drivers/pci/hotplug/pciehp_ctrl.c
18467 -@@ -115,6 +115,10 @@ static void remove_board(struct controller *ctrl, bool safe_removal)
18468 - * removed from the slot/adapter.
18469 - */
18470 - msleep(1000);
18471 -+
18472 -+ /* Ignore link or presence changes caused by power off */
18473 -+ atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
18474 -+ &ctrl->pending_events);
18475 - }
18476 -
18477 - /* turn off Green LED */
18478 -diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
18479 -index 7dd443aea5a5..8bfcb8cd0900 100644
18480 ---- a/drivers/pci/hotplug/pciehp_hpc.c
18481 -+++ b/drivers/pci/hotplug/pciehp_hpc.c
18482 -@@ -156,9 +156,9 @@ static void pcie_do_write_cmd(struct controller *ctrl, u16 cmd,
18483 - slot_ctrl |= (cmd & mask);
18484 - ctrl->cmd_busy = 1;
18485 - smp_mb();
18486 -+ ctrl->slot_ctrl = slot_ctrl;
18487 - pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl);
18488 - ctrl->cmd_started = jiffies;
18489 -- ctrl->slot_ctrl = slot_ctrl;
18490 -
18491 - /*
18492 - * Controllers with the Intel CF118 and similar errata advertise
18493 -@@ -736,12 +736,25 @@ void pcie_clear_hotplug_events(struct controller *ctrl)
18494 -
18495 - void pcie_enable_interrupt(struct controller *ctrl)
18496 - {
18497 -- pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_HPIE, PCI_EXP_SLTCTL_HPIE);
18498 -+ u16 mask;
18499 -+
18500 -+ mask = PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_DLLSCE;
18501 -+ pcie_write_cmd(ctrl, mask, mask);
18502 - }
18503 -
18504 - void pcie_disable_interrupt(struct controller *ctrl)
18505 - {
18506 -- pcie_write_cmd(ctrl, 0, PCI_EXP_SLTCTL_HPIE);
18507 -+ u16 mask;
18508 -+
18509 -+ /*
18510 -+ * Mask hot-plug interrupt to prevent it triggering immediately
18511 -+ * when the link goes inactive (we still get PME when any of the
18512 -+ * enabled events is detected). Same goes with Link Layer State
18513 -+ * changed event which generates PME immediately when the link goes
18514 -+ * inactive so mask it as well.
18515 -+ */
18516 -+ mask = PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_DLLSCE;
18517 -+ pcie_write_cmd(ctrl, 0, mask);
18518 - }
18519 -
18520 - /*
18521 -diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c
18522 -index 129738362d90..83fb077d0b41 100644
18523 ---- a/drivers/pci/pci-bridge-emul.c
18524 -+++ b/drivers/pci/pci-bridge-emul.c
18525 -@@ -24,29 +24,6 @@
18526 - #define PCI_CAP_PCIE_START PCI_BRIDGE_CONF_END
18527 - #define PCI_CAP_PCIE_END (PCI_CAP_PCIE_START + PCI_EXP_SLTSTA2 + 2)
18528 -
18529 --/*
18530 -- * Initialize a pci_bridge_emul structure to represent a fake PCI
18531 -- * bridge configuration space. The caller needs to have initialized
18532 -- * the PCI configuration space with whatever values make sense
18533 -- * (typically at least vendor, device, revision), the ->ops pointer,
18534 -- * and optionally ->data and ->has_pcie.
18535 -- */
18536 --void pci_bridge_emul_init(struct pci_bridge_emul *bridge)
18537 --{
18538 -- bridge->conf.class_revision |= PCI_CLASS_BRIDGE_PCI << 16;
18539 -- bridge->conf.header_type = PCI_HEADER_TYPE_BRIDGE;
18540 -- bridge->conf.cache_line_size = 0x10;
18541 -- bridge->conf.status = PCI_STATUS_CAP_LIST;
18542 --
18543 -- if (bridge->has_pcie) {
18544 -- bridge->conf.capabilities_pointer = PCI_CAP_PCIE_START;
18545 -- bridge->pcie_conf.cap_id = PCI_CAP_ID_EXP;
18546 -- /* Set PCIe v2, root port, slot support */
18547 -- bridge->pcie_conf.cap = PCI_EXP_TYPE_ROOT_PORT << 4 | 2 |
18548 -- PCI_EXP_FLAGS_SLOT;
18549 -- }
18550 --}
18551 --
18552 - struct pci_bridge_reg_behavior {
18553 - /* Read-only bits */
18554 - u32 ro;
18555 -@@ -283,6 +260,61 @@ const static struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = {
18556 - },
18557 - };
18558 -
18559 -+/*
18560 -+ * Initialize a pci_bridge_emul structure to represent a fake PCI
18561 -+ * bridge configuration space. The caller needs to have initialized
18562 -+ * the PCI configuration space with whatever values make sense
18563 -+ * (typically at least vendor, device, revision), the ->ops pointer,
18564 -+ * and optionally ->data and ->has_pcie.
18565 -+ */
18566 -+int pci_bridge_emul_init(struct pci_bridge_emul *bridge,
18567 -+ unsigned int flags)
18568 -+{
18569 -+ bridge->conf.class_revision |= PCI_CLASS_BRIDGE_PCI << 16;
18570 -+ bridge->conf.header_type = PCI_HEADER_TYPE_BRIDGE;
18571 -+ bridge->conf.cache_line_size = 0x10;
18572 -+ bridge->conf.status = PCI_STATUS_CAP_LIST;
18573 -+ bridge->pci_regs_behavior = kmemdup(pci_regs_behavior,
18574 -+ sizeof(pci_regs_behavior),
18575 -+ GFP_KERNEL);
18576 -+ if (!bridge->pci_regs_behavior)
18577 -+ return -ENOMEM;
18578 -+
18579 -+ if (bridge->has_pcie) {
18580 -+ bridge->conf.capabilities_pointer = PCI_CAP_PCIE_START;
18581 -+ bridge->pcie_conf.cap_id = PCI_CAP_ID_EXP;
18582 -+ /* Set PCIe v2, root port, slot support */
18583 -+ bridge->pcie_conf.cap = PCI_EXP_TYPE_ROOT_PORT << 4 | 2 |
18584 -+ PCI_EXP_FLAGS_SLOT;
18585 -+ bridge->pcie_cap_regs_behavior =
18586 -+ kmemdup(pcie_cap_regs_behavior,
18587 -+ sizeof(pcie_cap_regs_behavior),
18588 -+ GFP_KERNEL);
18589 -+ if (!bridge->pcie_cap_regs_behavior) {
18590 -+ kfree(bridge->pci_regs_behavior);
18591 -+ return -ENOMEM;
18592 -+ }
18593 -+ }
18594 -+
18595 -+ if (flags & PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR) {
18596 -+ bridge->pci_regs_behavior[PCI_PREF_MEMORY_BASE / 4].ro = ~0;
18597 -+ bridge->pci_regs_behavior[PCI_PREF_MEMORY_BASE / 4].rw = 0;
18598 -+ }
18599 -+
18600 -+ return 0;
18601 -+}
18602 -+
18603 -+/*
18604 -+ * Cleanup a pci_bridge_emul structure that was previously initilized
18605 -+ * using pci_bridge_emul_init().
18606 -+ */
18607 -+void pci_bridge_emul_cleanup(struct pci_bridge_emul *bridge)
18608 -+{
18609 -+ if (bridge->has_pcie)
18610 -+ kfree(bridge->pcie_cap_regs_behavior);
18611 -+ kfree(bridge->pci_regs_behavior);
18612 -+}
18613 -+
18614 - /*
18615 - * Should be called by the PCI controller driver when reading the PCI
18616 - * configuration space of the fake bridge. It will call back the
18617 -@@ -312,11 +344,11 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where,
18618 - reg -= PCI_CAP_PCIE_START;
18619 - read_op = bridge->ops->read_pcie;
18620 - cfgspace = (u32 *) &bridge->pcie_conf;
18621 -- behavior = pcie_cap_regs_behavior;
18622 -+ behavior = bridge->pcie_cap_regs_behavior;
18623 - } else {
18624 - read_op = bridge->ops->read_base;
18625 - cfgspace = (u32 *) &bridge->conf;
18626 -- behavior = pci_regs_behavior;
18627 -+ behavior = bridge->pci_regs_behavior;
18628 - }
18629 -
18630 - if (read_op)
18631 -@@ -383,11 +415,11 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,
18632 - reg -= PCI_CAP_PCIE_START;
18633 - write_op = bridge->ops->write_pcie;
18634 - cfgspace = (u32 *) &bridge->pcie_conf;
18635 -- behavior = pcie_cap_regs_behavior;
18636 -+ behavior = bridge->pcie_cap_regs_behavior;
18637 - } else {
18638 - write_op = bridge->ops->write_base;
18639 - cfgspace = (u32 *) &bridge->conf;
18640 -- behavior = pci_regs_behavior;
18641 -+ behavior = bridge->pci_regs_behavior;
18642 - }
18643 -
18644 - /* Keep all bits, except the RW bits */
18645 -diff --git a/drivers/pci/pci-bridge-emul.h b/drivers/pci/pci-bridge-emul.h
18646 -index 9d510ccf738b..e65b1b79899d 100644
18647 ---- a/drivers/pci/pci-bridge-emul.h
18648 -+++ b/drivers/pci/pci-bridge-emul.h
18649 -@@ -107,15 +107,26 @@ struct pci_bridge_emul_ops {
18650 - u32 old, u32 new, u32 mask);
18651 - };
18652 -
18653 -+struct pci_bridge_reg_behavior;
18654 -+
18655 - struct pci_bridge_emul {
18656 - struct pci_bridge_emul_conf conf;
18657 - struct pci_bridge_emul_pcie_conf pcie_conf;
18658 - struct pci_bridge_emul_ops *ops;
18659 -+ struct pci_bridge_reg_behavior *pci_regs_behavior;
18660 -+ struct pci_bridge_reg_behavior *pcie_cap_regs_behavior;
18661 - void *data;
18662 - bool has_pcie;
18663 - };
18664 -
18665 --void pci_bridge_emul_init(struct pci_bridge_emul *bridge);
18666 -+enum {
18667 -+ PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR = BIT(0),
18668 -+};
18669 -+
18670 -+int pci_bridge_emul_init(struct pci_bridge_emul *bridge,
18671 -+ unsigned int flags);
18672 -+void pci_bridge_emul_cleanup(struct pci_bridge_emul *bridge);
18673 -+
18674 - int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where,
18675 - int size, u32 *value);
18676 - int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,
18677 -diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
18678 -index e435d12e61a0..7b77754a82de 100644
18679 ---- a/drivers/pci/pcie/dpc.c
18680 -+++ b/drivers/pci/pcie/dpc.c
18681 -@@ -202,6 +202,28 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
18682 - pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, status);
18683 - }
18684 -
18685 -+static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
18686 -+ struct aer_err_info *info)
18687 -+{
18688 -+ int pos = dev->aer_cap;
18689 -+ u32 status, mask, sev;
18690 -+
18691 -+ pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
18692 -+ pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
18693 -+ status &= ~mask;
18694 -+ if (!status)
18695 -+ return 0;
18696 -+
18697 -+ pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
18698 -+ status &= sev;
18699 -+ if (status)
18700 -+ info->severity = AER_FATAL;
18701 -+ else
18702 -+ info->severity = AER_NONFATAL;
18703 -+
18704 -+ return 1;
18705 -+}
18706 -+
18707 - static irqreturn_t dpc_handler(int irq, void *context)
18708 - {
18709 - struct aer_err_info info;
18710 -@@ -229,9 +251,12 @@ static irqreturn_t dpc_handler(int irq, void *context)
18711 - /* show RP PIO error detail information */
18712 - if (dpc->rp_extensions && reason == 3 && ext_reason == 0)
18713 - dpc_process_rp_pio_error(dpc);
18714 -- else if (reason == 0 && aer_get_device_error_info(pdev, &info)) {
18715 -+ else if (reason == 0 &&
18716 -+ dpc_get_aer_uncorrect_severity(pdev, &info) &&
18717 -+ aer_get_device_error_info(pdev, &info)) {
18718 - aer_print_error(pdev, &info);
18719 - pci_cleanup_aer_uncorrect_error_status(pdev);
18720 -+ pci_aer_clear_fatal_status(pdev);
18721 - }
18722 -
18723 - /* We configure DPC so it only triggers on ERR_FATAL */
18724 -diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
18725 -index 0dbcf429089f..efa5b552914b 100644
18726 ---- a/drivers/pci/pcie/pme.c
18727 -+++ b/drivers/pci/pcie/pme.c
18728 -@@ -363,6 +363,16 @@ static bool pcie_pme_check_wakeup(struct pci_bus *bus)
18729 - return false;
18730 - }
18731 -
18732 -+static void pcie_pme_disable_interrupt(struct pci_dev *port,
18733 -+ struct pcie_pme_service_data *data)
18734 -+{
18735 -+ spin_lock_irq(&data->lock);
18736 -+ pcie_pme_interrupt_enable(port, false);
18737 -+ pcie_clear_root_pme_status(port);
18738 -+ data->noirq = true;
18739 -+ spin_unlock_irq(&data->lock);
18740 -+}
18741 -+
18742 - /**
18743 - * pcie_pme_suspend - Suspend PCIe PME service device.
18744 - * @srv: PCIe service device to suspend.
18745 -@@ -387,11 +397,7 @@ static int pcie_pme_suspend(struct pcie_device *srv)
18746 - return 0;
18747 - }
18748 -
18749 -- spin_lock_irq(&data->lock);
18750 -- pcie_pme_interrupt_enable(port, false);
18751 -- pcie_clear_root_pme_status(port);
18752 -- data->noirq = true;
18753 -- spin_unlock_irq(&data->lock);
18754 -+ pcie_pme_disable_interrupt(port, data);
18755 -
18756 - synchronize_irq(srv->irq);
18757 -
18758 -@@ -426,35 +432,12 @@ static int pcie_pme_resume(struct pcie_device *srv)
18759 - * @srv - PCIe service device to remove.
18760 - */
18761 - static void pcie_pme_remove(struct pcie_device *srv)
18762 --{
18763 -- pcie_pme_suspend(srv);
18764 -- free_irq(srv->irq, srv);
18765 -- kfree(get_service_data(srv));
18766 --}
18767 --
18768 --static int pcie_pme_runtime_suspend(struct pcie_device *srv)
18769 --{
18770 -- struct pcie_pme_service_data *data = get_service_data(srv);
18771 --
18772 -- spin_lock_irq(&data->lock);
18773 -- pcie_pme_interrupt_enable(srv->port, false);
18774 -- pcie_clear_root_pme_status(srv->port);
18775 -- data->noirq = true;
18776 -- spin_unlock_irq(&data->lock);
18777 --
18778 -- return 0;
18779 --}
18780 --
18781 --static int pcie_pme_runtime_resume(struct pcie_device *srv)
18782 - {
18783 - struct pcie_pme_service_data *data = get_service_data(srv);
18784 -
18785 -- spin_lock_irq(&data->lock);
18786 -- pcie_pme_interrupt_enable(srv->port, true);
18787 -- data->noirq = false;
18788 -- spin_unlock_irq(&data->lock);
18789 --
18790 -- return 0;
18791 -+ pcie_pme_disable_interrupt(srv->port, data);
18792 -+ free_irq(srv->irq, srv);
18793 -+ kfree(data);
18794 - }
18795 -
18796 - static struct pcie_port_service_driver pcie_pme_driver = {
18797 -@@ -464,8 +447,6 @@ static struct pcie_port_service_driver pcie_pme_driver = {
18798 -
18799 - .probe = pcie_pme_probe,
18800 - .suspend = pcie_pme_suspend,
18801 -- .runtime_suspend = pcie_pme_runtime_suspend,
18802 -- .runtime_resume = pcie_pme_runtime_resume,
18803 - .resume = pcie_pme_resume,
18804 - .remove = pcie_pme_remove,
18805 - };
18806 -diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
18807 -index 257b9f6f2ebb..c46a3fcb341e 100644
18808 ---- a/drivers/pci/probe.c
18809 -+++ b/drivers/pci/probe.c
18810 -@@ -2071,11 +2071,8 @@ static void pci_configure_ltr(struct pci_dev *dev)
18811 - {
18812 - #ifdef CONFIG_PCIEASPM
18813 - struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
18814 -- u32 cap;
18815 - struct pci_dev *bridge;
18816 --
18817 -- if (!host->native_ltr)
18818 -- return;
18819 -+ u32 cap, ctl;
18820 -
18821 - if (!pci_is_pcie(dev))
18822 - return;
18823 -@@ -2084,22 +2081,35 @@ static void pci_configure_ltr(struct pci_dev *dev)
18824 - if (!(cap & PCI_EXP_DEVCAP2_LTR))
18825 - return;
18826 -
18827 -- /*
18828 -- * Software must not enable LTR in an Endpoint unless the Root
18829 -- * Complex and all intermediate Switches indicate support for LTR.
18830 -- * PCIe r3.1, sec 6.18.
18831 -- */
18832 -- if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
18833 -- dev->ltr_path = 1;
18834 -- else {
18835 -+ pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl);
18836 -+ if (ctl & PCI_EXP_DEVCTL2_LTR_EN) {
18837 -+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
18838 -+ dev->ltr_path = 1;
18839 -+ return;
18840 -+ }
18841 -+
18842 - bridge = pci_upstream_bridge(dev);
18843 - if (bridge && bridge->ltr_path)
18844 - dev->ltr_path = 1;
18845 -+
18846 -+ return;
18847 - }
18848 -
18849 -- if (dev->ltr_path)
18850 -+ if (!host->native_ltr)
18851 -+ return;
18852 -+
18853 -+ /*
18854 -+ * Software must not enable LTR in an Endpoint unless the Root
18855 -+ * Complex and all intermediate Switches indicate support for LTR.
18856 -+ * PCIe r4.0, sec 6.18.
18857 -+ */
18858 -+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
18859 -+ ((bridge = pci_upstream_bridge(dev)) &&
18860 -+ bridge->ltr_path)) {
18861 - pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
18862 - PCI_EXP_DEVCTL2_LTR_EN);
18863 -+ dev->ltr_path = 1;
18864 -+ }
18865 - #endif
18866 - }
18867 -
18868 -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
18869 -index e2a879e93d86..fba03a7d5c7f 100644
18870 ---- a/drivers/pci/quirks.c
18871 -+++ b/drivers/pci/quirks.c
18872 -@@ -3877,6 +3877,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128,
18873 - /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */
18874 - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130,
18875 - quirk_dma_func1_alias);
18876 -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9170,
18877 -+ quirk_dma_func1_alias);
18878 - /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */
18879 - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9172,
18880 - quirk_dma_func1_alias);
18881 -diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
18882 -index 8e46a9dad2fa..7cb766dafe85 100644
18883 ---- a/drivers/perf/arm_spe_pmu.c
18884 -+++ b/drivers/perf/arm_spe_pmu.c
18885 -@@ -824,10 +824,10 @@ static void arm_spe_pmu_read(struct perf_event *event)
18886 - {
18887 - }
18888 -
18889 --static void *arm_spe_pmu_setup_aux(int cpu, void **pages, int nr_pages,
18890 -- bool snapshot)
18891 -+static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages,
18892 -+ int nr_pages, bool snapshot)
18893 - {
18894 -- int i;
18895 -+ int i, cpu = event->cpu;
18896 - struct page **pglist;
18897 - struct arm_spe_pmu_buf *buf;
18898 -
18899 -diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
18900 -index 5163097b43df..4bbd9ede38c8 100644
18901 ---- a/drivers/phy/allwinner/phy-sun4i-usb.c
18902 -+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
18903 -@@ -485,8 +485,11 @@ static int sun4i_usb_phy_set_mode(struct phy *_phy,
18904 - struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
18905 - int new_mode;
18906 -
18907 -- if (phy->index != 0)
18908 -+ if (phy->index != 0) {
18909 -+ if (mode == PHY_MODE_USB_HOST)
18910 -+ return 0;
18911 - return -EINVAL;
18912 -+ }
18913 -
18914 - switch (mode) {
18915 - case PHY_MODE_USB_HOST:
18916 -diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
18917 -index ea87d739f534..a4ae1ac5369e 100644
18918 ---- a/drivers/pinctrl/meson/pinctrl-meson.c
18919 -+++ b/drivers/pinctrl/meson/pinctrl-meson.c
18920 -@@ -31,6 +31,9 @@
18921 - * In some cases the register ranges for pull enable and pull
18922 - * direction are the same and thus there are only 3 register ranges.
18923 - *
18924 -+ * Since Meson G12A SoC, the ao register ranges for gpio, pull enable
18925 -+ * and pull direction are the same, so there are only 2 register ranges.
18926 -+ *
18927 - * For the pull and GPIO configuration every bank uses a contiguous
18928 - * set of bits in the register sets described above; the same register
18929 - * can be shared by more banks with different offsets.
18930 -@@ -488,23 +491,22 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc,
18931 - return PTR_ERR(pc->reg_mux);
18932 - }
18933 -
18934 -- pc->reg_pull = meson_map_resource(pc, gpio_np, "pull");
18935 -- if (IS_ERR(pc->reg_pull)) {
18936 -- dev_err(pc->dev, "pull registers not found\n");
18937 -- return PTR_ERR(pc->reg_pull);
18938 -+ pc->reg_gpio = meson_map_resource(pc, gpio_np, "gpio");
18939 -+ if (IS_ERR(pc->reg_gpio)) {
18940 -+ dev_err(pc->dev, "gpio registers not found\n");
18941 -+ return PTR_ERR(pc->reg_gpio);
18942 - }
18943 -
18944 -+ pc->reg_pull = meson_map_resource(pc, gpio_np, "pull");
18945 -+ /* Use gpio region if pull one is not present */
18946 -+ if (IS_ERR(pc->reg_pull))
18947 -+ pc->reg_pull = pc->reg_gpio;
18948 -+
18949 - pc->reg_pullen = meson_map_resource(pc, gpio_np, "pull-enable");
18950 - /* Use pull region if pull-enable one is not present */
18951 - if (IS_ERR(pc->reg_pullen))
18952 - pc->reg_pullen = pc->reg_pull;
18953 -
18954 -- pc->reg_gpio = meson_map_resource(pc, gpio_np, "gpio");
18955 -- if (IS_ERR(pc->reg_gpio)) {
18956 -- dev_err(pc->dev, "gpio registers not found\n");
18957 -- return PTR_ERR(pc->reg_gpio);
18958 -- }
18959 --
18960 - return 0;
18961 - }
18962 -
18963 -diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c
18964 -index 0f140a802137..7f76000cc12e 100644
18965 ---- a/drivers/pinctrl/meson/pinctrl-meson8b.c
18966 -+++ b/drivers/pinctrl/meson/pinctrl-meson8b.c
18967 -@@ -346,6 +346,8 @@ static const unsigned int eth_rx_dv_pins[] = { DIF_1_P };
18968 - static const unsigned int eth_rx_clk_pins[] = { DIF_1_N };
18969 - static const unsigned int eth_txd0_1_pins[] = { DIF_2_P };
18970 - static const unsigned int eth_txd1_1_pins[] = { DIF_2_N };
18971 -+static const unsigned int eth_rxd3_pins[] = { DIF_2_P };
18972 -+static const unsigned int eth_rxd2_pins[] = { DIF_2_N };
18973 - static const unsigned int eth_tx_en_pins[] = { DIF_3_P };
18974 - static const unsigned int eth_ref_clk_pins[] = { DIF_3_N };
18975 - static const unsigned int eth_mdc_pins[] = { DIF_4_P };
18976 -@@ -599,6 +601,8 @@ static struct meson_pmx_group meson8b_cbus_groups[] = {
18977 - GROUP(eth_ref_clk, 6, 8),
18978 - GROUP(eth_mdc, 6, 9),
18979 - GROUP(eth_mdio_en, 6, 10),
18980 -+ GROUP(eth_rxd3, 7, 22),
18981 -+ GROUP(eth_rxd2, 7, 23),
18982 - };
18983 -
18984 - static struct meson_pmx_group meson8b_aobus_groups[] = {
18985 -@@ -748,7 +752,7 @@ static const char * const ethernet_groups[] = {
18986 - "eth_tx_clk", "eth_tx_en", "eth_txd1_0", "eth_txd1_1",
18987 - "eth_txd0_0", "eth_txd0_1", "eth_rx_clk", "eth_rx_dv",
18988 - "eth_rxd1", "eth_rxd0", "eth_mdio_en", "eth_mdc", "eth_ref_clk",
18989 -- "eth_txd2", "eth_txd3"
18990 -+ "eth_txd2", "eth_txd3", "eth_rxd3", "eth_rxd2"
18991 - };
18992 -
18993 - static const char * const i2c_a_groups[] = {
18994 -diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
18995 -index e40908dc37e0..1ce286f7b286 100644
18996 ---- a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
18997 -+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
18998 -@@ -391,29 +391,33 @@ FM(IP12_23_20) IP12_23_20 FM(IP13_23_20) IP13_23_20 FM(IP14_23_20) IP14_23_20 FM
18999 - FM(IP12_27_24) IP12_27_24 FM(IP13_27_24) IP13_27_24 FM(IP14_27_24) IP14_27_24 FM(IP15_27_24) IP15_27_24 \
19000 - FM(IP12_31_28) IP12_31_28 FM(IP13_31_28) IP13_31_28 FM(IP14_31_28) IP14_31_28 FM(IP15_31_28) IP15_31_28
19001 -
19002 -+/* The bit numbering in MOD_SEL fields is reversed */
19003 -+#define REV4(f0, f1, f2, f3) f0 f2 f1 f3
19004 -+#define REV8(f0, f1, f2, f3, f4, f5, f6, f7) f0 f4 f2 f6 f1 f5 f3 f7
19005 -+
19006 - /* MOD_SEL0 */ /* 0 */ /* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 7 */
19007 --#define MOD_SEL0_30_29 FM(SEL_ADGB_0) FM(SEL_ADGB_1) FM(SEL_ADGB_2) F_(0, 0)
19008 -+#define MOD_SEL0_30_29 REV4(FM(SEL_ADGB_0), FM(SEL_ADGB_1), FM(SEL_ADGB_2), F_(0, 0))
19009 - #define MOD_SEL0_28 FM(SEL_DRIF0_0) FM(SEL_DRIF0_1)
19010 --#define MOD_SEL0_27_26 FM(SEL_FM_0) FM(SEL_FM_1) FM(SEL_FM_2) F_(0, 0)
19011 -+#define MOD_SEL0_27_26 REV4(FM(SEL_FM_0), FM(SEL_FM_1), FM(SEL_FM_2), F_(0, 0))
19012 - #define MOD_SEL0_25 FM(SEL_FSO_0) FM(SEL_FSO_1)
19013 - #define MOD_SEL0_24 FM(SEL_HSCIF0_0) FM(SEL_HSCIF0_1)
19014 - #define MOD_SEL0_23 FM(SEL_HSCIF1_0) FM(SEL_HSCIF1_1)
19015 - #define MOD_SEL0_22 FM(SEL_HSCIF2_0) FM(SEL_HSCIF2_1)
19016 --#define MOD_SEL0_21_20 FM(SEL_I2C1_0) FM(SEL_I2C1_1) FM(SEL_I2C1_2) FM(SEL_I2C1_3)
19017 --#define MOD_SEL0_19_18_17 FM(SEL_I2C2_0) FM(SEL_I2C2_1) FM(SEL_I2C2_2) FM(SEL_I2C2_3) FM(SEL_I2C2_4) F_(0, 0) F_(0, 0) F_(0, 0)
19018 -+#define MOD_SEL0_21_20 REV4(FM(SEL_I2C1_0), FM(SEL_I2C1_1), FM(SEL_I2C1_2), FM(SEL_I2C1_3))
19019 -+#define MOD_SEL0_19_18_17 REV8(FM(SEL_I2C2_0), FM(SEL_I2C2_1), FM(SEL_I2C2_2), FM(SEL_I2C2_3), FM(SEL_I2C2_4), F_(0, 0), F_(0, 0), F_(0, 0))
19020 - #define MOD_SEL0_16 FM(SEL_NDFC_0) FM(SEL_NDFC_1)
19021 - #define MOD_SEL0_15 FM(SEL_PWM0_0) FM(SEL_PWM0_1)
19022 - #define MOD_SEL0_14 FM(SEL_PWM1_0) FM(SEL_PWM1_1)
19023 --#define MOD_SEL0_13_12 FM(SEL_PWM2_0) FM(SEL_PWM2_1) FM(SEL_PWM2_2) F_(0, 0)
19024 --#define MOD_SEL0_11_10 FM(SEL_PWM3_0) FM(SEL_PWM3_1) FM(SEL_PWM3_2) F_(0, 0)
19025 -+#define MOD_SEL0_13_12 REV4(FM(SEL_PWM2_0), FM(SEL_PWM2_1), FM(SEL_PWM2_2), F_(0, 0))
19026 -+#define MOD_SEL0_11_10 REV4(FM(SEL_PWM3_0), FM(SEL_PWM3_1), FM(SEL_PWM3_2), F_(0, 0))
19027 - #define MOD_SEL0_9 FM(SEL_PWM4_0) FM(SEL_PWM4_1)
19028 - #define MOD_SEL0_8 FM(SEL_PWM5_0) FM(SEL_PWM5_1)
19029 - #define MOD_SEL0_7 FM(SEL_PWM6_0) FM(SEL_PWM6_1)
19030 --#define MOD_SEL0_6_5 FM(SEL_REMOCON_0) FM(SEL_REMOCON_1) FM(SEL_REMOCON_2) F_(0, 0)
19031 -+#define MOD_SEL0_6_5 REV4(FM(SEL_REMOCON_0), FM(SEL_REMOCON_1), FM(SEL_REMOCON_2), F_(0, 0))
19032 - #define MOD_SEL0_4 FM(SEL_SCIF_0) FM(SEL_SCIF_1)
19033 - #define MOD_SEL0_3 FM(SEL_SCIF0_0) FM(SEL_SCIF0_1)
19034 - #define MOD_SEL0_2 FM(SEL_SCIF2_0) FM(SEL_SCIF2_1)
19035 --#define MOD_SEL0_1_0 FM(SEL_SPEED_PULSE_IF_0) FM(SEL_SPEED_PULSE_IF_1) FM(SEL_SPEED_PULSE_IF_2) F_(0, 0)
19036 -+#define MOD_SEL0_1_0 REV4(FM(SEL_SPEED_PULSE_IF_0), FM(SEL_SPEED_PULSE_IF_1), FM(SEL_SPEED_PULSE_IF_2), F_(0, 0))
19037 -
19038 - /* MOD_SEL1 */ /* 0 */ /* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 7 */
19039 - #define MOD_SEL1_31 FM(SEL_SIMCARD_0) FM(SEL_SIMCARD_1)
19040 -@@ -422,18 +426,18 @@ FM(IP12_31_28) IP12_31_28 FM(IP13_31_28) IP13_31_28 FM(IP14_31_28) IP14_31_28 FM
19041 - #define MOD_SEL1_28 FM(SEL_USB_20_CH0_0) FM(SEL_USB_20_CH0_1)
19042 - #define MOD_SEL1_26 FM(SEL_DRIF2_0) FM(SEL_DRIF2_1)
19043 - #define MOD_SEL1_25 FM(SEL_DRIF3_0) FM(SEL_DRIF3_1)
19044 --#define MOD_SEL1_24_23_22 FM(SEL_HSCIF3_0) FM(SEL_HSCIF3_1) FM(SEL_HSCIF3_2) FM(SEL_HSCIF3_3) FM(SEL_HSCIF3_4) F_(0, 0) F_(0, 0) F_(0, 0)
19045 --#define MOD_SEL1_21_20_19 FM(SEL_HSCIF4_0) FM(SEL_HSCIF4_1) FM(SEL_HSCIF4_2) FM(SEL_HSCIF4_3) FM(SEL_HSCIF4_4) F_(0, 0) F_(0, 0) F_(0, 0)
19046 -+#define MOD_SEL1_24_23_22 REV8(FM(SEL_HSCIF3_0), FM(SEL_HSCIF3_1), FM(SEL_HSCIF3_2), FM(SEL_HSCIF3_3), FM(SEL_HSCIF3_4), F_(0, 0), F_(0, 0), F_(0, 0))
19047 -+#define MOD_SEL1_21_20_19 REV8(FM(SEL_HSCIF4_0), FM(SEL_HSCIF4_1), FM(SEL_HSCIF4_2), FM(SEL_HSCIF4_3), FM(SEL_HSCIF4_4), F_(0, 0), F_(0, 0), F_(0, 0))
19048 - #define MOD_SEL1_18 FM(SEL_I2C6_0) FM(SEL_I2C6_1)
19049 - #define MOD_SEL1_17 FM(SEL_I2C7_0) FM(SEL_I2C7_1)
19050 - #define MOD_SEL1_16 FM(SEL_MSIOF2_0) FM(SEL_MSIOF2_1)
19051 - #define MOD_SEL1_15 FM(SEL_MSIOF3_0) FM(SEL_MSIOF3_1)
19052 --#define MOD_SEL1_14_13 FM(SEL_SCIF3_0) FM(SEL_SCIF3_1) FM(SEL_SCIF3_2) F_(0, 0)
19053 --#define MOD_SEL1_12_11 FM(SEL_SCIF4_0) FM(SEL_SCIF4_1) FM(SEL_SCIF4_2) F_(0, 0)
19054 --#define MOD_SEL1_10_9 FM(SEL_SCIF5_0) FM(SEL_SCIF5_1) FM(SEL_SCIF5_2) F_(0, 0)
19055 -+#define MOD_SEL1_14_13 REV4(FM(SEL_SCIF3_0), FM(SEL_SCIF3_1), FM(SEL_SCIF3_2), F_(0, 0))
19056 -+#define MOD_SEL1_12_11 REV4(FM(SEL_SCIF4_0), FM(SEL_SCIF4_1), FM(SEL_SCIF4_2), F_(0, 0))
19057 -+#define MOD_SEL1_10_9 REV4(FM(SEL_SCIF5_0), FM(SEL_SCIF5_1), FM(SEL_SCIF5_2), F_(0, 0))
19058 - #define MOD_SEL1_8 FM(SEL_VIN4_0) FM(SEL_VIN4_1)
19059 - #define MOD_SEL1_7 FM(SEL_VIN5_0) FM(SEL_VIN5_1)
19060 --#define MOD_SEL1_6_5 FM(SEL_ADGC_0) FM(SEL_ADGC_1) FM(SEL_ADGC_2) F_(0, 0)
19061 -+#define MOD_SEL1_6_5 REV4(FM(SEL_ADGC_0), FM(SEL_ADGC_1), FM(SEL_ADGC_2), F_(0, 0))
19062 - #define MOD_SEL1_4 FM(SEL_SSI9_0) FM(SEL_SSI9_1)
19063 -
19064 - #define PINMUX_MOD_SELS \
19065 -diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77995.c b/drivers/pinctrl/sh-pfc/pfc-r8a77995.c
19066 -index 84d78db381e3..9e377e3b9cb3 100644
19067 ---- a/drivers/pinctrl/sh-pfc/pfc-r8a77995.c
19068 -+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77995.c
19069 -@@ -381,6 +381,9 @@ FM(IP12_23_20) IP12_23_20 \
19070 - FM(IP12_27_24) IP12_27_24 \
19071 - FM(IP12_31_28) IP12_31_28 \
19072 -
19073 -+/* The bit numbering in MOD_SEL fields is reversed */
19074 -+#define REV4(f0, f1, f2, f3) f0 f2 f1 f3
19075 -+
19076 - /* MOD_SEL0 */ /* 0 */ /* 1 */ /* 2 */ /* 3 */
19077 - #define MOD_SEL0_30 FM(SEL_MSIOF2_0) FM(SEL_MSIOF2_1)
19078 - #define MOD_SEL0_29 FM(SEL_I2C3_0) FM(SEL_I2C3_1)
19079 -@@ -388,10 +391,10 @@ FM(IP12_31_28) IP12_31_28 \
19080 - #define MOD_SEL0_27 FM(SEL_MSIOF3_0) FM(SEL_MSIOF3_1)
19081 - #define MOD_SEL0_26 FM(SEL_HSCIF3_0) FM(SEL_HSCIF3_1)
19082 - #define MOD_SEL0_25 FM(SEL_SCIF4_0) FM(SEL_SCIF4_1)
19083 --#define MOD_SEL0_24_23 FM(SEL_PWM0_0) FM(SEL_PWM0_1) FM(SEL_PWM0_2) F_(0, 0)
19084 --#define MOD_SEL0_22_21 FM(SEL_PWM1_0) FM(SEL_PWM1_1) FM(SEL_PWM1_2) F_(0, 0)
19085 --#define MOD_SEL0_20_19 FM(SEL_PWM2_0) FM(SEL_PWM2_1) FM(SEL_PWM2_2) F_(0, 0)
19086 --#define MOD_SEL0_18_17 FM(SEL_PWM3_0) FM(SEL_PWM3_1) FM(SEL_PWM3_2) F_(0, 0)
19087 -+#define MOD_SEL0_24_23 REV4(FM(SEL_PWM0_0), FM(SEL_PWM0_1), FM(SEL_PWM0_2), F_(0, 0))
19088 -+#define MOD_SEL0_22_21 REV4(FM(SEL_PWM1_0), FM(SEL_PWM1_1), FM(SEL_PWM1_2), F_(0, 0))
19089 -+#define MOD_SEL0_20_19 REV4(FM(SEL_PWM2_0), FM(SEL_PWM2_1), FM(SEL_PWM2_2), F_(0, 0))
19090 -+#define MOD_SEL0_18_17 REV4(FM(SEL_PWM3_0), FM(SEL_PWM3_1), FM(SEL_PWM3_2), F_(0, 0))
19091 - #define MOD_SEL0_15 FM(SEL_IRQ_0_0) FM(SEL_IRQ_0_1)
19092 - #define MOD_SEL0_14 FM(SEL_IRQ_1_0) FM(SEL_IRQ_1_1)
19093 - #define MOD_SEL0_13 FM(SEL_IRQ_2_0) FM(SEL_IRQ_2_1)
19094 -diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
19095 -index b6d44550d98c..eca16d00e310 100644
19096 ---- a/drivers/platform/mellanox/mlxreg-hotplug.c
19097 -+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
19098 -@@ -248,7 +248,8 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv,
19099 - struct mlxreg_core_item *item)
19100 - {
19101 - struct mlxreg_core_data *data;
19102 -- u32 asserted, regval, bit;
19103 -+ unsigned long asserted;
19104 -+ u32 regval, bit;
19105 - int ret;
19106 -
19107 - /*
19108 -@@ -281,7 +282,7 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv,
19109 - asserted = item->cache ^ regval;
19110 - item->cache = regval;
19111 -
19112 -- for_each_set_bit(bit, (unsigned long *)&asserted, 8) {
19113 -+ for_each_set_bit(bit, &asserted, 8) {
19114 - data = item->data + bit;
19115 - if (regval & BIT(bit)) {
19116 - if (item->inversed)
19117 -diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
19118 -index 1589dffab9fa..8b53a9ceb897 100644
19119 ---- a/drivers/platform/x86/ideapad-laptop.c
19120 -+++ b/drivers/platform/x86/ideapad-laptop.c
19121 -@@ -989,7 +989,7 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
19122 - .ident = "Lenovo RESCUER R720-15IKBN",
19123 - .matches = {
19124 - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
19125 -- DMI_MATCH(DMI_BOARD_NAME, "80WW"),
19126 -+ DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo R720-15IKBN"),
19127 - },
19128 - },
19129 - {
19130 -diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
19131 -index e28bcf61b126..bc0d55a59015 100644
19132 ---- a/drivers/platform/x86/intel-hid.c
19133 -+++ b/drivers/platform/x86/intel-hid.c
19134 -@@ -363,7 +363,7 @@ wakeup:
19135 - * the 5-button array, but still send notifies with power button
19136 - * event code to this device object on power button actions.
19137 - *
19138 -- * Report the power button press; catch and ignore the button release.
19139 -+ * Report the power button press and release.
19140 - */
19141 - if (!priv->array) {
19142 - if (event == 0xce) {
19143 -@@ -372,8 +372,11 @@ wakeup:
19144 - return;
19145 - }
19146 -
19147 -- if (event == 0xcf)
19148 -+ if (event == 0xcf) {
19149 -+ input_report_key(priv->input_dev, KEY_POWER, 0);
19150 -+ input_sync(priv->input_dev);
19151 - return;
19152 -+ }
19153 - }
19154 -
19155 - /* 0xC0 is for HID events, other values are for 5 button array */
19156 -diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
19157 -index 22dbf115782e..c37e74ee609d 100644
19158 ---- a/drivers/platform/x86/intel_pmc_core.c
19159 -+++ b/drivers/platform/x86/intel_pmc_core.c
19160 -@@ -380,7 +380,8 @@ static int pmc_core_ppfear_show(struct seq_file *s, void *unused)
19161 - index < PPFEAR_MAX_NUM_ENTRIES; index++, iter++)
19162 - pf_regs[index] = pmc_core_reg_read_byte(pmcdev, iter);
19163 -
19164 -- for (index = 0; map[index].name; index++)
19165 -+ for (index = 0; map[index].name &&
19166 -+ index < pmcdev->map->ppfear_buckets * 8; index++)
19167 - pmc_core_display_map(s, index, pf_regs[index / 8], map);
19168 -
19169 - return 0;
19170 -diff --git a/drivers/platform/x86/intel_pmc_core.h b/drivers/platform/x86/intel_pmc_core.h
19171 -index 89554cba5758..1a0104d2cbf0 100644
19172 ---- a/drivers/platform/x86/intel_pmc_core.h
19173 -+++ b/drivers/platform/x86/intel_pmc_core.h
19174 -@@ -32,7 +32,7 @@
19175 - #define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64
19176 - #define PMC_BASE_ADDR_MASK ~(SPT_PMC_MMIO_REG_LEN - 1)
19177 - #define MTPMC_MASK 0xffff0000
19178 --#define PPFEAR_MAX_NUM_ENTRIES 5
19179 -+#define PPFEAR_MAX_NUM_ENTRIES 12
19180 - #define SPT_PPFEAR_NUM_ENTRIES 5
19181 - #define SPT_PMC_READ_DISABLE_BIT 0x16
19182 - #define SPT_PMC_MSG_FULL_STS_BIT 0x18
19183 -diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
19184 -index c843eaff8ad0..c3ed7b476676 100644
19185 ---- a/drivers/power/supply/cpcap-charger.c
19186 -+++ b/drivers/power/supply/cpcap-charger.c
19187 -@@ -458,6 +458,7 @@ static void cpcap_usb_detect(struct work_struct *work)
19188 - goto out_err;
19189 - }
19190 -
19191 -+ power_supply_changed(ddata->usb);
19192 - return;
19193 -
19194 - out_err:
19195 -diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c
19196 -index 21e20483bd91..e0239cf3f56d 100644
19197 ---- a/drivers/regulator/act8865-regulator.c
19198 -+++ b/drivers/regulator/act8865-regulator.c
19199 -@@ -131,7 +131,7 @@
19200 - * ACT8865 voltage number
19201 - */
19202 - #define ACT8865_VOLTAGE_NUM 64
19203 --#define ACT8600_SUDCDC_VOLTAGE_NUM 255
19204 -+#define ACT8600_SUDCDC_VOLTAGE_NUM 256
19205 -
19206 - struct act8865 {
19207 - struct regmap *regmap;
19208 -@@ -222,7 +222,8 @@ static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = {
19209 - REGULATOR_LINEAR_RANGE(3000000, 0, 63, 0),
19210 - REGULATOR_LINEAR_RANGE(3000000, 64, 159, 100000),
19211 - REGULATOR_LINEAR_RANGE(12600000, 160, 191, 200000),
19212 -- REGULATOR_LINEAR_RANGE(19000000, 191, 255, 400000),
19213 -+ REGULATOR_LINEAR_RANGE(19000000, 192, 247, 400000),
19214 -+ REGULATOR_LINEAR_RANGE(41400000, 248, 255, 0),
19215 - };
19216 -
19217 - static struct regulator_ops act8865_ops = {
19218 -diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
19219 -index b9d7b45c7295..e2caf11598c7 100644
19220 ---- a/drivers/regulator/core.c
19221 -+++ b/drivers/regulator/core.c
19222 -@@ -1349,7 +1349,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
19223 - * We'll only apply the initial system load if an
19224 - * initial mode wasn't specified.
19225 - */
19226 -+ regulator_lock(rdev);
19227 - drms_uA_update(rdev);
19228 -+ regulator_unlock(rdev);
19229 - }
19230 -
19231 - if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
19232 -diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
19233 -index b94e3a721721..cd93cf53e23c 100644
19234 ---- a/drivers/regulator/max77620-regulator.c
19235 -+++ b/drivers/regulator/max77620-regulator.c
19236 -@@ -1,7 +1,7 @@
19237 - /*
19238 - * Maxim MAX77620 Regulator driver
19239 - *
19240 -- * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
19241 -+ * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
19242 - *
19243 - * Author: Mallikarjun Kasoju <mkasoju@××××××.com>
19244 - * Laxman Dewangan <ldewangan@××××××.com>
19245 -@@ -803,6 +803,14 @@ static int max77620_regulator_probe(struct platform_device *pdev)
19246 - rdesc = &rinfo[id].desc;
19247 - pmic->rinfo[id] = &max77620_regs_info[id];
19248 - pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL;
19249 -+ pmic->reg_pdata[id].active_fps_src = -1;
19250 -+ pmic->reg_pdata[id].active_fps_pd_slot = -1;
19251 -+ pmic->reg_pdata[id].active_fps_pu_slot = -1;
19252 -+ pmic->reg_pdata[id].suspend_fps_src = -1;
19253 -+ pmic->reg_pdata[id].suspend_fps_pd_slot = -1;
19254 -+ pmic->reg_pdata[id].suspend_fps_pu_slot = -1;
19255 -+ pmic->reg_pdata[id].power_ok = -1;
19256 -+ pmic->reg_pdata[id].ramp_rate_setting = -1;
19257 -
19258 - ret = max77620_read_slew_rate(pmic, id);
19259 - if (ret < 0)
19260 -diff --git a/drivers/regulator/mcp16502.c b/drivers/regulator/mcp16502.c
19261 -index 3479ae009b0b..0fc4963bd5b0 100644
19262 ---- a/drivers/regulator/mcp16502.c
19263 -+++ b/drivers/regulator/mcp16502.c
19264 -@@ -17,6 +17,7 @@
19265 - #include <linux/regmap.h>
19266 - #include <linux/regulator/driver.h>
19267 - #include <linux/suspend.h>
19268 -+#include <linux/gpio/consumer.h>
19269 -
19270 - #define VDD_LOW_SEL 0x0D
19271 - #define VDD_HIGH_SEL 0x3F
19272 -diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
19273 -index 095d25f3d2ea..58a1fe583a6c 100644
19274 ---- a/drivers/regulator/s2mpa01.c
19275 -+++ b/drivers/regulator/s2mpa01.c
19276 -@@ -298,13 +298,13 @@ static const struct regulator_desc regulators[] = {
19277 - regulator_desc_ldo(2, STEP_50_MV),
19278 - regulator_desc_ldo(3, STEP_50_MV),
19279 - regulator_desc_ldo(4, STEP_50_MV),
19280 -- regulator_desc_ldo(5, STEP_50_MV),
19281 -+ regulator_desc_ldo(5, STEP_25_MV),
19282 - regulator_desc_ldo(6, STEP_25_MV),
19283 - regulator_desc_ldo(7, STEP_50_MV),
19284 - regulator_desc_ldo(8, STEP_50_MV),
19285 - regulator_desc_ldo(9, STEP_50_MV),
19286 - regulator_desc_ldo(10, STEP_50_MV),
19287 -- regulator_desc_ldo(11, STEP_25_MV),
19288 -+ regulator_desc_ldo(11, STEP_50_MV),
19289 - regulator_desc_ldo(12, STEP_50_MV),
19290 - regulator_desc_ldo(13, STEP_50_MV),
19291 - regulator_desc_ldo(14, STEP_50_MV),
19292 -@@ -315,11 +315,11 @@ static const struct regulator_desc regulators[] = {
19293 - regulator_desc_ldo(19, STEP_50_MV),
19294 - regulator_desc_ldo(20, STEP_50_MV),
19295 - regulator_desc_ldo(21, STEP_50_MV),
19296 -- regulator_desc_ldo(22, STEP_25_MV),
19297 -- regulator_desc_ldo(23, STEP_25_MV),
19298 -+ regulator_desc_ldo(22, STEP_50_MV),
19299 -+ regulator_desc_ldo(23, STEP_50_MV),
19300 - regulator_desc_ldo(24, STEP_50_MV),
19301 - regulator_desc_ldo(25, STEP_50_MV),
19302 -- regulator_desc_ldo(26, STEP_50_MV),
19303 -+ regulator_desc_ldo(26, STEP_25_MV),
19304 - regulator_desc_buck1_4(1),
19305 - regulator_desc_buck1_4(2),
19306 - regulator_desc_buck1_4(3),
19307 -diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
19308 -index ee4a23ab0663..134c62db36c5 100644
19309 ---- a/drivers/regulator/s2mps11.c
19310 -+++ b/drivers/regulator/s2mps11.c
19311 -@@ -362,7 +362,7 @@ static const struct regulator_desc s2mps11_regulators[] = {
19312 - regulator_desc_s2mps11_ldo(32, STEP_50_MV),
19313 - regulator_desc_s2mps11_ldo(33, STEP_50_MV),
19314 - regulator_desc_s2mps11_ldo(34, STEP_50_MV),
19315 -- regulator_desc_s2mps11_ldo(35, STEP_50_MV),
19316 -+ regulator_desc_s2mps11_ldo(35, STEP_25_MV),
19317 - regulator_desc_s2mps11_ldo(36, STEP_50_MV),
19318 - regulator_desc_s2mps11_ldo(37, STEP_50_MV),
19319 - regulator_desc_s2mps11_ldo(38, STEP_50_MV),
19320 -@@ -372,8 +372,8 @@ static const struct regulator_desc s2mps11_regulators[] = {
19321 - regulator_desc_s2mps11_buck1_4(4),
19322 - regulator_desc_s2mps11_buck5,
19323 - regulator_desc_s2mps11_buck67810(6, MIN_600_MV, STEP_6_25_MV),
19324 -- regulator_desc_s2mps11_buck67810(7, MIN_600_MV, STEP_6_25_MV),
19325 -- regulator_desc_s2mps11_buck67810(8, MIN_600_MV, STEP_6_25_MV),
19326 -+ regulator_desc_s2mps11_buck67810(7, MIN_600_MV, STEP_12_5_MV),
19327 -+ regulator_desc_s2mps11_buck67810(8, MIN_600_MV, STEP_12_5_MV),
19328 - regulator_desc_s2mps11_buck9,
19329 - regulator_desc_s2mps11_buck67810(10, MIN_750_MV, STEP_12_5_MV),
19330 - };
19331 -diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
19332 -index a10cec0e86eb..0b3b9de45c60 100644
19333 ---- a/drivers/s390/cio/vfio_ccw_drv.c
19334 -+++ b/drivers/s390/cio/vfio_ccw_drv.c
19335 -@@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
19336 - {
19337 - struct vfio_ccw_private *private;
19338 - struct irb *irb;
19339 -+ bool is_final;
19340 -
19341 - private = container_of(work, struct vfio_ccw_private, io_work);
19342 - irb = &private->irb;
19343 -
19344 -+ is_final = !(scsw_actl(&irb->scsw) &
19345 -+ (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
19346 - if (scsw_is_solicited(&irb->scsw)) {
19347 - cp_update_scsw(&private->cp, &irb->scsw);
19348 -- cp_free(&private->cp);
19349 -+ if (is_final)
19350 -+ cp_free(&private->cp);
19351 - }
19352 - memcpy(private->io_region->irb_area, irb, sizeof(*irb));
19353 -
19354 - if (private->io_trigger)
19355 - eventfd_signal(private->io_trigger, 1);
19356 -
19357 -- if (private->mdev)
19358 -+ if (private->mdev && is_final)
19359 - private->state = VFIO_CCW_STATE_IDLE;
19360 - }
19361 -
19362 -diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
19363 -index 31c6c847eaca..e9824c35c34f 100644
19364 ---- a/drivers/s390/crypto/vfio_ap_drv.c
19365 -+++ b/drivers/s390/crypto/vfio_ap_drv.c
19366 -@@ -15,7 +15,6 @@
19367 - #include "vfio_ap_private.h"
19368 -
19369 - #define VFIO_AP_ROOT_NAME "vfio_ap"
19370 --#define VFIO_AP_DEV_TYPE_NAME "ap_matrix"
19371 - #define VFIO_AP_DEV_NAME "matrix"
19372 -
19373 - MODULE_AUTHOR("IBM Corporation");
19374 -@@ -24,10 +23,6 @@ MODULE_LICENSE("GPL v2");
19375 -
19376 - static struct ap_driver vfio_ap_drv;
19377 -
19378 --static struct device_type vfio_ap_dev_type = {
19379 -- .name = VFIO_AP_DEV_TYPE_NAME,
19380 --};
19381 --
19382 - struct ap_matrix_dev *matrix_dev;
19383 -
19384 - /* Only type 10 adapters (CEX4 and later) are supported
19385 -@@ -62,6 +57,22 @@ static void vfio_ap_matrix_dev_release(struct device *dev)
19386 - kfree(matrix_dev);
19387 - }
19388 -
19389 -+static int matrix_bus_match(struct device *dev, struct device_driver *drv)
19390 -+{
19391 -+ return 1;
19392 -+}
19393 -+
19394 -+static struct bus_type matrix_bus = {
19395 -+ .name = "matrix",
19396 -+ .match = &matrix_bus_match,
19397 -+};
19398 -+
19399 -+static struct device_driver matrix_driver = {
19400 -+ .name = "vfio_ap",
19401 -+ .bus = &matrix_bus,
19402 -+ .suppress_bind_attrs = true,
19403 -+};
19404 -+
19405 - static int vfio_ap_matrix_dev_create(void)
19406 - {
19407 - int ret;
19408 -@@ -71,6 +82,10 @@ static int vfio_ap_matrix_dev_create(void)
19409 - if (IS_ERR(root_device))
19410 - return PTR_ERR(root_device);
19411 -
19412 -+ ret = bus_register(&matrix_bus);
19413 -+ if (ret)
19414 -+ goto bus_register_err;
19415 -+
19416 - matrix_dev = kzalloc(sizeof(*matrix_dev), GFP_KERNEL);
19417 - if (!matrix_dev) {
19418 - ret = -ENOMEM;
19419 -@@ -87,30 +102,41 @@ static int vfio_ap_matrix_dev_create(void)
19420 - mutex_init(&matrix_dev->lock);
19421 - INIT_LIST_HEAD(&matrix_dev->mdev_list);
19422 -
19423 -- matrix_dev->device.type = &vfio_ap_dev_type;
19424 - dev_set_name(&matrix_dev->device, "%s", VFIO_AP_DEV_NAME);
19425 - matrix_dev->device.parent = root_device;
19426 -+ matrix_dev->device.bus = &matrix_bus;
19427 - matrix_dev->device.release = vfio_ap_matrix_dev_release;
19428 -- matrix_dev->device.driver = &vfio_ap_drv.driver;
19429 -+ matrix_dev->vfio_ap_drv = &vfio_ap_drv;
19430 -
19431 - ret = device_register(&matrix_dev->device);
19432 - if (ret)
19433 - goto matrix_reg_err;
19434 -
19435 -+ ret = driver_register(&matrix_driver);
19436 -+ if (ret)
19437 -+ goto matrix_drv_err;
19438 -+
19439 - return 0;
19440 -
19441 -+matrix_drv_err:
19442 -+ device_unregister(&matrix_dev->device);
19443 - matrix_reg_err:
19444 - put_device(&matrix_dev->device);
19445 - matrix_alloc_err:
19446 -+ bus_unregister(&matrix_bus);
19447 -+bus_register_err:
19448 - root_device_unregister(root_device);
19449 --
19450 - return ret;
19451 - }
19452 -
19453 - static void vfio_ap_matrix_dev_destroy(void)
19454 - {
19455 -+ struct device *root_device = matrix_dev->device.parent;
19456 -+
19457 -+ driver_unregister(&matrix_driver);
19458 - device_unregister(&matrix_dev->device);
19459 -- root_device_unregister(matrix_dev->device.parent);
19460 -+ bus_unregister(&matrix_bus);
19461 -+ root_device_unregister(root_device);
19462 - }
19463 -
19464 - static int __init vfio_ap_init(void)
19465 -diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
19466 -index 272ef427dcc0..900b9cf20ca5 100644
19467 ---- a/drivers/s390/crypto/vfio_ap_ops.c
19468 -+++ b/drivers/s390/crypto/vfio_ap_ops.c
19469 -@@ -198,8 +198,8 @@ static int vfio_ap_verify_queue_reserved(unsigned long *apid,
19470 - qres.apqi = apqi;
19471 - qres.reserved = false;
19472 -
19473 -- ret = driver_for_each_device(matrix_dev->device.driver, NULL, &qres,
19474 -- vfio_ap_has_queue);
19475 -+ ret = driver_for_each_device(&matrix_dev->vfio_ap_drv->driver, NULL,
19476 -+ &qres, vfio_ap_has_queue);
19477 - if (ret)
19478 - return ret;
19479 -
19480 -diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
19481 -index 5675492233c7..76b7f98e47e9 100644
19482 ---- a/drivers/s390/crypto/vfio_ap_private.h
19483 -+++ b/drivers/s390/crypto/vfio_ap_private.h
19484 -@@ -40,6 +40,7 @@ struct ap_matrix_dev {
19485 - struct ap_config_info info;
19486 - struct list_head mdev_list;
19487 - struct mutex lock;
19488 -+ struct ap_driver *vfio_ap_drv;
19489 - };
19490 -
19491 - extern struct ap_matrix_dev *matrix_dev;
19492 -diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c
19493 -index ed8e58f09054..3e132592c1fe 100644
19494 ---- a/drivers/s390/net/ism_drv.c
19495 -+++ b/drivers/s390/net/ism_drv.c
19496 -@@ -141,10 +141,13 @@ static int register_ieq(struct ism_dev *ism)
19497 -
19498 - static int unregister_sba(struct ism_dev *ism)
19499 - {
19500 -+ int ret;
19501 -+
19502 - if (!ism->sba)
19503 - return 0;
19504 -
19505 -- if (ism_cmd_simple(ism, ISM_UNREG_SBA))
19506 -+ ret = ism_cmd_simple(ism, ISM_UNREG_SBA);
19507 -+ if (ret && ret != ISM_ERROR)
19508 - return -EIO;
19509 -
19510 - dma_free_coherent(&ism->pdev->dev, PAGE_SIZE,
19511 -@@ -158,10 +161,13 @@ static int unregister_sba(struct ism_dev *ism)
19512 -
19513 - static int unregister_ieq(struct ism_dev *ism)
19514 - {
19515 -+ int ret;
19516 -+
19517 - if (!ism->ieq)
19518 - return 0;
19519 -
19520 -- if (ism_cmd_simple(ism, ISM_UNREG_IEQ))
19521 -+ ret = ism_cmd_simple(ism, ISM_UNREG_IEQ);
19522 -+ if (ret && ret != ISM_ERROR)
19523 - return -EIO;
19524 -
19525 - dma_free_coherent(&ism->pdev->dev, PAGE_SIZE,
19526 -@@ -287,7 +293,7 @@ static int ism_unregister_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb)
19527 - cmd.request.dmb_tok = dmb->dmb_tok;
19528 -
19529 - ret = ism_cmd(ism, &cmd);
19530 -- if (ret)
19531 -+ if (ret && ret != ISM_ERROR)
19532 - goto out;
19533 -
19534 - ism_free_dmb(ism, dmb);
19535 -diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
19536 -index 744a64680d5b..e8fc28dba8df 100644
19537 ---- a/drivers/s390/scsi/zfcp_erp.c
19538 -+++ b/drivers/s390/scsi/zfcp_erp.c
19539 -@@ -624,6 +624,20 @@ static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
19540 - add_timer(&erp_action->timer);
19541 - }
19542 -
19543 -+void zfcp_erp_port_forced_reopen_all(struct zfcp_adapter *adapter,
19544 -+ int clear, char *dbftag)
19545 -+{
19546 -+ unsigned long flags;
19547 -+ struct zfcp_port *port;
19548 -+
19549 -+ write_lock_irqsave(&adapter->erp_lock, flags);
19550 -+ read_lock(&adapter->port_list_lock);
19551 -+ list_for_each_entry(port, &adapter->port_list, list)
19552 -+ _zfcp_erp_port_forced_reopen(port, clear, dbftag);
19553 -+ read_unlock(&adapter->port_list_lock);
19554 -+ write_unlock_irqrestore(&adapter->erp_lock, flags);
19555 -+}
19556 -+
19557 - static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter,
19558 - int clear, char *dbftag)
19559 - {
19560 -@@ -1341,6 +1355,9 @@ static void zfcp_erp_try_rport_unblock(struct zfcp_port *port)
19561 - struct zfcp_scsi_dev *zsdev = sdev_to_zfcp(sdev);
19562 - int lun_status;
19563 -
19564 -+ if (sdev->sdev_state == SDEV_DEL ||
19565 -+ sdev->sdev_state == SDEV_CANCEL)
19566 -+ continue;
19567 - if (zsdev->port != port)
19568 - continue;
19569 - /* LUN under port of interest */
19570 -diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
19571 -index 3fce47b0b21b..c6acca521ffe 100644
19572 ---- a/drivers/s390/scsi/zfcp_ext.h
19573 -+++ b/drivers/s390/scsi/zfcp_ext.h
19574 -@@ -70,6 +70,8 @@ extern void zfcp_erp_port_reopen(struct zfcp_port *port, int clear,
19575 - char *dbftag);
19576 - extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, char *);
19577 - extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *);
19578 -+extern void zfcp_erp_port_forced_reopen_all(struct zfcp_adapter *adapter,
19579 -+ int clear, char *dbftag);
19580 - extern void zfcp_erp_set_lun_status(struct scsi_device *, u32);
19581 - extern void zfcp_erp_clear_lun_status(struct scsi_device *, u32);
19582 - extern void zfcp_erp_lun_reopen(struct scsi_device *, int, char *);
19583 -diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
19584 -index f4f6a07c5222..221d0dfb8493 100644
19585 ---- a/drivers/s390/scsi/zfcp_scsi.c
19586 -+++ b/drivers/s390/scsi/zfcp_scsi.c
19587 -@@ -368,6 +368,10 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
19588 - struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
19589 - int ret = SUCCESS, fc_ret;
19590 -
19591 -+ if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) {
19592 -+ zfcp_erp_port_forced_reopen_all(adapter, 0, "schrh_p");
19593 -+ zfcp_erp_wait(adapter);
19594 -+ }
19595 - zfcp_erp_adapter_reopen(adapter, 0, "schrh_1");
19596 - zfcp_erp_wait(adapter);
19597 - fc_ret = fc_block_scsi_eh(scpnt);
19598 -diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
19599 -index ae1d56da671d..1a738fe9f26b 100644
19600 ---- a/drivers/s390/virtio/virtio_ccw.c
19601 -+++ b/drivers/s390/virtio/virtio_ccw.c
19602 -@@ -272,6 +272,8 @@ static void virtio_ccw_drop_indicators(struct virtio_ccw_device *vcdev)
19603 - {
19604 - struct virtio_ccw_vq_info *info;
19605 -
19606 -+ if (!vcdev->airq_info)
19607 -+ return;
19608 - list_for_each_entry(info, &vcdev->virtqueues, node)
19609 - drop_airq_indicator(info->vq, vcdev->airq_info);
19610 - }
19611 -@@ -413,7 +415,7 @@ static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev,
19612 - ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_VQ_CONF);
19613 - if (ret)
19614 - return ret;
19615 -- return vcdev->config_block->num;
19616 -+ return vcdev->config_block->num ?: -ENOENT;
19617 - }
19618 -
19619 - static void virtio_ccw_del_vq(struct virtqueue *vq, struct ccw1 *ccw)
19620 -diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
19621 -index d5a6aa9676c8..a3adc954f40f 100644
19622 ---- a/drivers/scsi/aacraid/commsup.c
19623 -+++ b/drivers/scsi/aacraid/commsup.c
19624 -@@ -1303,8 +1303,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
19625 - ADD : DELETE;
19626 - break;
19627 - }
19628 -- case AifBuManagerEvent:
19629 -- aac_handle_aif_bu(dev, aifcmd);
19630 -+ break;
19631 -+ case AifBuManagerEvent:
19632 -+ aac_handle_aif_bu(dev, aifcmd);
19633 - break;
19634 - }
19635 -
19636 -diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
19637 -index 7e56a11836c1..ccefface7e31 100644
19638 ---- a/drivers/scsi/aacraid/linit.c
19639 -+++ b/drivers/scsi/aacraid/linit.c
19640 -@@ -413,13 +413,16 @@ static int aac_slave_configure(struct scsi_device *sdev)
19641 - if (chn < AAC_MAX_BUSES && tid < AAC_MAX_TARGETS && aac->sa_firmware) {
19642 - devtype = aac->hba_map[chn][tid].devtype;
19643 -
19644 -- if (devtype == AAC_DEVTYPE_NATIVE_RAW)
19645 -+ if (devtype == AAC_DEVTYPE_NATIVE_RAW) {
19646 - depth = aac->hba_map[chn][tid].qd_limit;
19647 -- else if (devtype == AAC_DEVTYPE_ARC_RAW)
19648 -+ set_timeout = 1;
19649 -+ goto common_config;
19650 -+ }
19651 -+ if (devtype == AAC_DEVTYPE_ARC_RAW) {
19652 - set_qd_dev_type = true;
19653 --
19654 -- set_timeout = 1;
19655 -- goto common_config;
19656 -+ set_timeout = 1;
19657 -+ goto common_config;
19658 -+ }
19659 - }
19660 -
19661 - if (aac->jbod && (sdev->type == TYPE_DISK))
19662 -diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
19663 -index 2e4e7159ebf9..a75e74ad1698 100644
19664 ---- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
19665 -+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
19666 -@@ -1438,7 +1438,7 @@ bind_err:
19667 - static struct bnx2fc_interface *
19668 - bnx2fc_interface_create(struct bnx2fc_hba *hba,
19669 - struct net_device *netdev,
19670 -- enum fip_state fip_mode)
19671 -+ enum fip_mode fip_mode)
19672 - {
19673 - struct fcoe_ctlr_device *ctlr_dev;
19674 - struct bnx2fc_interface *interface;
19675 -diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
19676 -index cd19be3f3405..8ba8862d3292 100644
19677 ---- a/drivers/scsi/fcoe/fcoe.c
19678 -+++ b/drivers/scsi/fcoe/fcoe.c
19679 -@@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
19680 - * Returns: pointer to a struct fcoe_interface or NULL on error
19681 - */
19682 - static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
19683 -- enum fip_state fip_mode)
19684 -+ enum fip_mode fip_mode)
19685 - {
19686 - struct fcoe_ctlr_device *ctlr_dev;
19687 - struct fcoe_ctlr *ctlr;
19688 -diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
19689 -index 54da3166da8d..7dc4ffa24430 100644
19690 ---- a/drivers/scsi/fcoe/fcoe_ctlr.c
19691 -+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
19692 -@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
19693 - * fcoe_ctlr_init() - Initialize the FCoE Controller instance
19694 - * @fip: The FCoE controller to initialize
19695 - */
19696 --void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
19697 -+void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
19698 - {
19699 - fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
19700 - fip->mode = mode;
19701 -@@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
19702 - mutex_unlock(&fip->ctlr_mutex);
19703 - fc_linkup(fip->lp);
19704 - } else if (fip->state == FIP_ST_LINK_WAIT) {
19705 -- fcoe_ctlr_set_state(fip, fip->mode);
19706 -+ if (fip->mode == FIP_MODE_NON_FIP)
19707 -+ fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
19708 -+ else
19709 -+ fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
19710 - switch (fip->mode) {
19711 - default:
19712 - LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
19713 -diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
19714 -index f4909cd206d3..f15d5e1d56b1 100644
19715 ---- a/drivers/scsi/fcoe/fcoe_transport.c
19716 -+++ b/drivers/scsi/fcoe/fcoe_transport.c
19717 -@@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
19718 - int rc = -ENODEV;
19719 - struct net_device *netdev = NULL;
19720 - struct fcoe_transport *ft = NULL;
19721 -- enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
19722 -+ enum fip_mode fip_mode = (enum fip_mode)kp->arg;
19723 -
19724 - mutex_lock(&ft_mutex);
19725 -
19726 -diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
19727 -index bc17fa0d8375..62d158574281 100644
19728 ---- a/drivers/scsi/hisi_sas/hisi_sas_main.c
19729 -+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
19730 -@@ -10,6 +10,7 @@
19731 - */
19732 -
19733 - #include "hisi_sas.h"
19734 -+#include "../libsas/sas_internal.h"
19735 - #define DRV_NAME "hisi_sas"
19736 -
19737 - #define DEV_IS_GONE(dev) \
19738 -@@ -872,7 +873,8 @@ static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, struct sas_task
19739 - spin_lock_irqsave(&task->task_state_lock, flags);
19740 - task->task_state_flags &=
19741 - ~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR);
19742 -- task->task_state_flags |= SAS_TASK_STATE_DONE;
19743 -+ if (!slot->is_internal && task->task_proto != SAS_PROTOCOL_SMP)
19744 -+ task->task_state_flags |= SAS_TASK_STATE_DONE;
19745 - spin_unlock_irqrestore(&task->task_state_lock, flags);
19746 - }
19747 -
19748 -@@ -1972,9 +1974,18 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type,
19749 -
19750 - static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
19751 - {
19752 -+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
19753 -+ struct sas_phy *sphy = sas_phy->phy;
19754 -+ struct sas_phy_data *d = sphy->hostdata;
19755 -+
19756 - phy->phy_attached = 0;
19757 - phy->phy_type = 0;
19758 - phy->port = NULL;
19759 -+
19760 -+ if (d->enable)
19761 -+ sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
19762 -+ else
19763 -+ sphy->negotiated_linkrate = SAS_PHY_DISABLED;
19764 - }
19765 -
19766 - void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
19767 -diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
19768 -index 1135e74646e2..8cec5230fe31 100644
19769 ---- a/drivers/scsi/ibmvscsi/ibmvscsi.c
19770 -+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
19771 -@@ -96,6 +96,7 @@ static int client_reserve = 1;
19772 - static char partition_name[96] = "UNKNOWN";
19773 - static unsigned int partition_number = -1;
19774 - static LIST_HEAD(ibmvscsi_head);
19775 -+static DEFINE_SPINLOCK(ibmvscsi_driver_lock);
19776 -
19777 - static struct scsi_transport_template *ibmvscsi_transport_template;
19778 -
19779 -@@ -2270,7 +2271,9 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
19780 - }
19781 -
19782 - dev_set_drvdata(&vdev->dev, hostdata);
19783 -+ spin_lock(&ibmvscsi_driver_lock);
19784 - list_add_tail(&hostdata->host_list, &ibmvscsi_head);
19785 -+ spin_unlock(&ibmvscsi_driver_lock);
19786 - return 0;
19787 -
19788 - add_srp_port_failed:
19789 -@@ -2292,15 +2295,27 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
19790 - static int ibmvscsi_remove(struct vio_dev *vdev)
19791 - {
19792 - struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev);
19793 -- list_del(&hostdata->host_list);
19794 -- unmap_persist_bufs(hostdata);
19795 -+ unsigned long flags;
19796 -+
19797 -+ srp_remove_host(hostdata->host);
19798 -+ scsi_remove_host(hostdata->host);
19799 -+
19800 -+ purge_requests(hostdata, DID_ERROR);
19801 -+
19802 -+ spin_lock_irqsave(hostdata->host->host_lock, flags);
19803 - release_event_pool(&hostdata->pool, hostdata);
19804 -+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
19805 -+
19806 - ibmvscsi_release_crq_queue(&hostdata->queue, hostdata,
19807 - max_events);
19808 -
19809 - kthread_stop(hostdata->work_thread);
19810 -- srp_remove_host(hostdata->host);
19811 -- scsi_remove_host(hostdata->host);
19812 -+ unmap_persist_bufs(hostdata);
19813 -+
19814 -+ spin_lock(&ibmvscsi_driver_lock);
19815 -+ list_del(&hostdata->host_list);
19816 -+ spin_unlock(&ibmvscsi_driver_lock);
19817 -+
19818 - scsi_host_put(hostdata->host);
19819 -
19820 - return 0;
19821 -diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
19822 -index fcbff83c0097..c9811d1aa007 100644
19823 ---- a/drivers/scsi/megaraid/megaraid_sas_base.c
19824 -+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
19825 -@@ -4188,6 +4188,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
19826 - if (megasas_create_frame_pool(instance)) {
19827 - dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating frame DMA pool\n");
19828 - megasas_free_cmds(instance);
19829 -+ return -ENOMEM;
19830 - }
19831 -
19832 - return 0;
19833 -diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
19834 -index 9bbc19fc190b..9f9431a4cc0e 100644
19835 ---- a/drivers/scsi/qedf/qedf_main.c
19836 -+++ b/drivers/scsi/qedf/qedf_main.c
19837 -@@ -1418,7 +1418,7 @@ static struct libfc_function_template qedf_lport_template = {
19838 -
19839 - static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
19840 - {
19841 -- fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
19842 -+ fcoe_ctlr_init(&qedf->ctlr, FIP_MODE_AUTO);
19843 -
19844 - qedf->ctlr.send = qedf_fip_send;
19845 - qedf->ctlr.get_src_addr = qedf_get_src_mac;
19846 -diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
19847 -index 8d1acc802a67..7f8946844a5e 100644
19848 ---- a/drivers/scsi/qla2xxx/qla_init.c
19849 -+++ b/drivers/scsi/qla2xxx/qla_init.c
19850 -@@ -644,11 +644,14 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
19851 - break;
19852 - case DSC_LS_PORT_UNAVAIL:
19853 - default:
19854 -- if (fcport->loop_id != FC_NO_LOOP_ID)
19855 -- qla2x00_clear_loop_id(fcport);
19856 --
19857 -- fcport->loop_id = loop_id;
19858 -- fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
19859 -+ if (fcport->loop_id == FC_NO_LOOP_ID) {
19860 -+ qla2x00_find_new_loop_id(vha, fcport);
19861 -+ fcport->fw_login_state =
19862 -+ DSC_LS_PORT_UNAVAIL;
19863 -+ }
19864 -+ ql_dbg(ql_dbg_disc, vha, 0x20e5,
19865 -+ "%s %d %8phC\n", __func__, __LINE__,
19866 -+ fcport->port_name);
19867 - qla24xx_fcport_handle_login(vha, fcport);
19868 - break;
19869 - }
19870 -@@ -1471,29 +1474,6 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
19871 - return 0;
19872 - }
19873 -
19874 --static
19875 --void qla24xx_handle_rscn_event(fc_port_t *fcport, struct event_arg *ea)
19876 --{
19877 -- fcport->rscn_gen++;
19878 --
19879 -- ql_dbg(ql_dbg_disc, fcport->vha, 0x210c,
19880 -- "%s %8phC DS %d LS %d\n",
19881 -- __func__, fcport->port_name, fcport->disc_state,
19882 -- fcport->fw_login_state);
19883 --
19884 -- if (fcport->flags & FCF_ASYNC_SENT)
19885 -- return;
19886 --
19887 -- switch (fcport->disc_state) {
19888 -- case DSC_DELETED:
19889 -- case DSC_LOGIN_COMPLETE:
19890 -- qla24xx_post_gpnid_work(fcport->vha, &ea->id);
19891 -- break;
19892 -- default:
19893 -- break;
19894 -- }
19895 --}
19896 --
19897 - int qla24xx_post_newsess_work(struct scsi_qla_host *vha, port_id_t *id,
19898 - u8 *port_name, u8 *node_name, void *pla, u8 fc4_type)
19899 - {
19900 -@@ -1560,8 +1540,6 @@ static void qla_handle_els_plogi_done(scsi_qla_host_t *vha,
19901 -
19902 - void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea)
19903 - {
19904 -- fc_port_t *f, *tf;
19905 -- uint32_t id = 0, mask, rid;
19906 - fc_port_t *fcport;
19907 -
19908 - switch (ea->event) {
19909 -@@ -1574,10 +1552,6 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea)
19910 - case FCME_RSCN:
19911 - if (test_bit(UNLOADING, &vha->dpc_flags))
19912 - return;
19913 -- switch (ea->id.b.rsvd_1) {
19914 -- case RSCN_PORT_ADDR:
19915 --#define BIGSCAN 1
19916 --#if defined BIGSCAN & BIGSCAN > 0
19917 - {
19918 - unsigned long flags;
19919 - fcport = qla2x00_find_fcport_by_nportid
19920 -@@ -1596,59 +1570,6 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea)
19921 - }
19922 - spin_unlock_irqrestore(&vha->work_lock, flags);
19923 - }
19924 --#else
19925 -- {
19926 -- int rc;
19927 -- fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1);
19928 -- if (!fcport) {
19929 -- /* cable moved */
19930 -- rc = qla24xx_post_gpnid_work(vha, &ea->id);
19931 -- if (rc) {
19932 -- ql_log(ql_log_warn, vha, 0xd044,
19933 -- "RSCN GPNID work failed %06x\n",
19934 -- ea->id.b24);
19935 -- }
19936 -- } else {
19937 -- ea->fcport = fcport;
19938 -- fcport->scan_needed = 1;
19939 -- qla24xx_handle_rscn_event(fcport, ea);
19940 -- }
19941 -- }
19942 --#endif
19943 -- break;
19944 -- case RSCN_AREA_ADDR:
19945 -- case RSCN_DOM_ADDR:
19946 -- if (ea->id.b.rsvd_1 == RSCN_AREA_ADDR) {
19947 -- mask = 0xffff00;
19948 -- ql_dbg(ql_dbg_async, vha, 0x5044,
19949 -- "RSCN: Area 0x%06x was affected\n",
19950 -- ea->id.b24);
19951 -- } else {
19952 -- mask = 0xff0000;
19953 -- ql_dbg(ql_dbg_async, vha, 0x507a,
19954 -- "RSCN: Domain 0x%06x was affected\n",
19955 -- ea->id.b24);
19956 -- }
19957 --
19958 -- rid = ea->id.b24 & mask;
19959 -- list_for_each_entry_safe(f, tf, &vha->vp_fcports,
19960 -- list) {
19961 -- id = f->d_id.b24 & mask;
19962 -- if (rid == id) {
19963 -- ea->fcport = f;
19964 -- qla24xx_handle_rscn_event(f, ea);
19965 -- }
19966 -- }
19967 -- break;
19968 -- case RSCN_FAB_ADDR:
19969 -- default:
19970 -- ql_log(ql_log_warn, vha, 0xd045,
19971 -- "RSCN: Fabric was affected. Addr format %d\n",
19972 -- ea->id.b.rsvd_1);
19973 -- qla2x00_mark_all_devices_lost(vha, 1);
19974 -- set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
19975 -- set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
19976 -- }
19977 - break;
19978 - case FCME_GNL_DONE:
19979 - qla24xx_handle_gnl_done_event(vha, ea);
19980 -@@ -1709,11 +1630,7 @@ void qla_rscn_replay(fc_port_t *fcport)
19981 - ea.event = FCME_RSCN;
19982 - ea.id = fcport->d_id;
19983 - ea.id.b.rsvd_1 = RSCN_PORT_ADDR;
19984 --#if defined BIGSCAN & BIGSCAN > 0
19985 - qla2x00_fcport_event_handler(fcport->vha, &ea);
19986 --#else
19987 -- qla24xx_post_gpnid_work(fcport->vha, &ea.id);
19988 --#endif
19989 - }
19990 - }
19991 -
19992 -@@ -5051,6 +4968,13 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
19993 - (area != vha->d_id.b.area || domain != vha->d_id.b.domain))
19994 - continue;
19995 -
19996 -+ /* Bypass if not same domain and area of adapter. */
19997 -+ if (area && domain && ((area != vha->d_id.b.area) ||
19998 -+ (domain != vha->d_id.b.domain)) &&
19999 -+ (ha->current_topology == ISP_CFG_NL))
20000 -+ continue;
20001 -+
20002 -+
20003 - /* Bypass invalid local loop ID. */
20004 - if (loop_id > LAST_LOCAL_LOOP_ID)
20005 - continue;
20006 -diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
20007 -index 8507c43b918c..1a20e5d8f057 100644
20008 ---- a/drivers/scsi/qla2xxx/qla_isr.c
20009 -+++ b/drivers/scsi/qla2xxx/qla_isr.c
20010 -@@ -3410,7 +3410,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
20011 - min_vecs++;
20012 - }
20013 -
20014 -- if (USER_CTRL_IRQ(ha)) {
20015 -+ if (USER_CTRL_IRQ(ha) || !ha->mqiobase) {
20016 - /* user wants to control IRQ setting for target mode */
20017 - ret = pci_alloc_irq_vectors(ha->pdev, min_vecs,
20018 - ha->msix_count, PCI_IRQ_MSIX);
20019 -diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
20020 -index c6ef83d0d99b..7e35ce2162d0 100644
20021 ---- a/drivers/scsi/qla2xxx/qla_os.c
20022 -+++ b/drivers/scsi/qla2xxx/qla_os.c
20023 -@@ -6936,7 +6936,7 @@ static int qla2xxx_map_queues(struct Scsi_Host *shost)
20024 - scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata;
20025 - struct blk_mq_queue_map *qmap = &shost->tag_set.map[0];
20026 -
20027 -- if (USER_CTRL_IRQ(vha->hw))
20028 -+ if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase)
20029 - rc = blk_mq_map_queues(qmap);
20030 - else
20031 - rc = blk_mq_pci_map_queues(qmap, vha->hw->pdev, vha->irq_offset);
20032 -diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
20033 -index a6828391d6b3..5a6e8e12701a 100644
20034 ---- a/drivers/scsi/scsi_lib.c
20035 -+++ b/drivers/scsi/scsi_lib.c
20036 -@@ -2598,8 +2598,10 @@ void scsi_device_resume(struct scsi_device *sdev)
20037 - * device deleted during suspend)
20038 - */
20039 - mutex_lock(&sdev->state_mutex);
20040 -- sdev->quiesced_by = NULL;
20041 -- blk_clear_pm_only(sdev->request_queue);
20042 -+ if (sdev->quiesced_by) {
20043 -+ sdev->quiesced_by = NULL;
20044 -+ blk_clear_pm_only(sdev->request_queue);
20045 -+ }
20046 - if (sdev->sdev_state == SDEV_QUIESCE)
20047 - scsi_device_set_state(sdev, SDEV_RUNNING);
20048 - mutex_unlock(&sdev->state_mutex);
20049 -diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
20050 -index dd0d516f65e2..53380e07b40e 100644
20051 ---- a/drivers/scsi/scsi_scan.c
20052 -+++ b/drivers/scsi/scsi_scan.c
20053 -@@ -220,7 +220,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
20054 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
20055 -
20056 - sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
20057 -- GFP_ATOMIC);
20058 -+ GFP_KERNEL);
20059 - if (!sdev)
20060 - goto out;
20061 -
20062 -@@ -788,7 +788,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
20063 - */
20064 - sdev->inquiry = kmemdup(inq_result,
20065 - max_t(size_t, sdev->inquiry_len, 36),
20066 -- GFP_ATOMIC);
20067 -+ GFP_KERNEL);
20068 - if (sdev->inquiry == NULL)
20069 - return SCSI_SCAN_NO_RESPONSE;
20070 -
20071 -@@ -1079,7 +1079,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
20072 - if (!sdev)
20073 - goto out;
20074 -
20075 -- result = kmalloc(result_len, GFP_ATOMIC |
20076 -+ result = kmalloc(result_len, GFP_KERNEL |
20077 - ((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
20078 - if (!result)
20079 - goto out_free_sdev;
20080 -diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
20081 -index 5464d467e23e..d64553c0a051 100644
20082 ---- a/drivers/scsi/sd.c
20083 -+++ b/drivers/scsi/sd.c
20084 -@@ -1398,11 +1398,6 @@ static void sd_release(struct gendisk *disk, fmode_t mode)
20085 - scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
20086 - }
20087 -
20088 -- /*
20089 -- * XXX and what if there are packets in flight and this close()
20090 -- * XXX is followed by a "rmmod sd_mod"?
20091 -- */
20092 --
20093 - scsi_disk_put(sdkp);
20094 - }
20095 -
20096 -@@ -3047,6 +3042,58 @@ static void sd_read_security(struct scsi_disk *sdkp, unsigned char *buffer)
20097 - sdkp->security = 1;
20098 - }
20099 -
20100 -+/*
20101 -+ * Determine the device's preferred I/O size for reads and writes
20102 -+ * unless the reported value is unreasonably small, large, not a
20103 -+ * multiple of the physical block size, or simply garbage.
20104 -+ */
20105 -+static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp,
20106 -+ unsigned int dev_max)
20107 -+{
20108 -+ struct scsi_device *sdp = sdkp->device;
20109 -+ unsigned int opt_xfer_bytes =
20110 -+ logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
20111 -+
20112 -+ if (sdkp->opt_xfer_blocks == 0)
20113 -+ return false;
20114 -+
20115 -+ if (sdkp->opt_xfer_blocks > dev_max) {
20116 -+ sd_first_printk(KERN_WARNING, sdkp,
20117 -+ "Optimal transfer size %u logical blocks " \
20118 -+ "> dev_max (%u logical blocks)\n",
20119 -+ sdkp->opt_xfer_blocks, dev_max);
20120 -+ return false;
20121 -+ }
20122 -+
20123 -+ if (sdkp->opt_xfer_blocks > SD_DEF_XFER_BLOCKS) {
20124 -+ sd_first_printk(KERN_WARNING, sdkp,
20125 -+ "Optimal transfer size %u logical blocks " \
20126 -+ "> sd driver limit (%u logical blocks)\n",
20127 -+ sdkp->opt_xfer_blocks, SD_DEF_XFER_BLOCKS);
20128 -+ return false;
20129 -+ }
20130 -+
20131 -+ if (opt_xfer_bytes < PAGE_SIZE) {
20132 -+ sd_first_printk(KERN_WARNING, sdkp,
20133 -+ "Optimal transfer size %u bytes < " \
20134 -+ "PAGE_SIZE (%u bytes)\n",
20135 -+ opt_xfer_bytes, (unsigned int)PAGE_SIZE);
20136 -+ return false;
20137 -+ }
20138 -+
20139 -+ if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) {
20140 -+ sd_first_printk(KERN_WARNING, sdkp,
20141 -+ "Optimal transfer size %u bytes not a " \
20142 -+ "multiple of physical block size (%u bytes)\n",
20143 -+ opt_xfer_bytes, sdkp->physical_block_size);
20144 -+ return false;
20145 -+ }
20146 -+
20147 -+ sd_first_printk(KERN_INFO, sdkp, "Optimal transfer size %u bytes\n",
20148 -+ opt_xfer_bytes);
20149 -+ return true;
20150 -+}
20151 -+
20152 - /**
20153 - * sd_revalidate_disk - called the first time a new disk is seen,
20154 - * performs disk spin up, read_capacity, etc.
20155 -@@ -3125,15 +3172,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
20156 - dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);
20157 - q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
20158 -
20159 -- /*
20160 -- * Determine the device's preferred I/O size for reads and writes
20161 -- * unless the reported value is unreasonably small, large, or
20162 -- * garbage.
20163 -- */
20164 -- if (sdkp->opt_xfer_blocks &&
20165 -- sdkp->opt_xfer_blocks <= dev_max &&
20166 -- sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
20167 -- logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) {
20168 -+ if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
20169 - q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
20170 - rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
20171 - } else
20172 -@@ -3447,9 +3486,21 @@ static void scsi_disk_release(struct device *dev)
20173 - {
20174 - struct scsi_disk *sdkp = to_scsi_disk(dev);
20175 - struct gendisk *disk = sdkp->disk;
20176 --
20177 -+ struct request_queue *q = disk->queue;
20178 -+
20179 - ida_free(&sd_index_ida, sdkp->index);
20180 -
20181 -+ /*
20182 -+ * Wait until all requests that are in progress have completed.
20183 -+ * This is necessary to avoid that e.g. scsi_end_request() crashes
20184 -+ * due to clearing the disk->private_data pointer. Wait from inside
20185 -+ * scsi_disk_release() instead of from sd_release() to avoid that
20186 -+ * freezing and unfreezing the request queue affects user space I/O
20187 -+ * in case multiple processes open a /dev/sd... node concurrently.
20188 -+ */
20189 -+ blk_mq_freeze_queue(q);
20190 -+ blk_mq_unfreeze_queue(q);
20191 -+
20192 - disk->private_data = NULL;
20193 - put_disk(disk);
20194 - put_device(&sdkp->device->sdev_gendev);
20195 -diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
20196 -index 772b976e4ee4..464cba521fb6 100644
20197 ---- a/drivers/scsi/virtio_scsi.c
20198 -+++ b/drivers/scsi/virtio_scsi.c
20199 -@@ -594,7 +594,6 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
20200 - return FAILED;
20201 -
20202 - memset(cmd, 0, sizeof(*cmd));
20203 -- cmd->sc = sc;
20204 - cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
20205 - .type = VIRTIO_SCSI_T_TMF,
20206 - .subtype = cpu_to_virtio32(vscsi->vdev,
20207 -@@ -653,7 +652,6 @@ static int virtscsi_abort(struct scsi_cmnd *sc)
20208 - return FAILED;
20209 -
20210 - memset(cmd, 0, sizeof(*cmd));
20211 -- cmd->sc = sc;
20212 - cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
20213 - .type = VIRTIO_SCSI_T_TMF,
20214 - .subtype = VIRTIO_SCSI_T_TMF_ABORT_TASK,
20215 -diff --git a/drivers/soc/qcom/qcom_gsbi.c b/drivers/soc/qcom/qcom_gsbi.c
20216 -index 09c669e70d63..038abc377fdb 100644
20217 ---- a/drivers/soc/qcom/qcom_gsbi.c
20218 -+++ b/drivers/soc/qcom/qcom_gsbi.c
20219 -@@ -138,7 +138,7 @@ static int gsbi_probe(struct platform_device *pdev)
20220 - struct resource *res;
20221 - void __iomem *base;
20222 - struct gsbi_info *gsbi;
20223 -- int i;
20224 -+ int i, ret;
20225 - u32 mask, gsbi_num;
20226 - const struct crci_config *config = NULL;
20227 -
20228 -@@ -221,7 +221,10 @@ static int gsbi_probe(struct platform_device *pdev)
20229 -
20230 - platform_set_drvdata(pdev, gsbi);
20231 -
20232 -- return of_platform_populate(node, NULL, NULL, &pdev->dev);
20233 -+ ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
20234 -+ if (ret)
20235 -+ clk_disable_unprepare(gsbi->hclk);
20236 -+ return ret;
20237 - }
20238 -
20239 - static int gsbi_remove(struct platform_device *pdev)
20240 -diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
20241 -index c7beb6841289..ab8f731a3426 100644
20242 ---- a/drivers/soc/qcom/rpmh.c
20243 -+++ b/drivers/soc/qcom/rpmh.c
20244 -@@ -80,6 +80,7 @@ void rpmh_tx_done(const struct tcs_request *msg, int r)
20245 - struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request,
20246 - msg);
20247 - struct completion *compl = rpm_msg->completion;
20248 -+ bool free = rpm_msg->needs_free;
20249 -
20250 - rpm_msg->err = r;
20251 -
20252 -@@ -94,7 +95,7 @@ void rpmh_tx_done(const struct tcs_request *msg, int r)
20253 - complete(compl);
20254 -
20255 - exit:
20256 -- if (rpm_msg->needs_free)
20257 -+ if (free)
20258 - kfree(rpm_msg);
20259 - }
20260 -
20261 -@@ -348,11 +349,12 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
20262 - {
20263 - struct batch_cache_req *req;
20264 - struct rpmh_request *rpm_msgs;
20265 -- DECLARE_COMPLETION_ONSTACK(compl);
20266 -+ struct completion *compls;
20267 - struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
20268 - unsigned long time_left;
20269 - int count = 0;
20270 -- int ret, i, j;
20271 -+ int ret, i;
20272 -+ void *ptr;
20273 -
20274 - if (!cmd || !n)
20275 - return -EINVAL;
20276 -@@ -362,10 +364,15 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
20277 - if (!count)
20278 - return -EINVAL;
20279 -
20280 -- req = kzalloc(sizeof(*req) + count * sizeof(req->rpm_msgs[0]),
20281 -+ ptr = kzalloc(sizeof(*req) +
20282 -+ count * (sizeof(req->rpm_msgs[0]) + sizeof(*compls)),
20283 - GFP_ATOMIC);
20284 -- if (!req)
20285 -+ if (!ptr)
20286 - return -ENOMEM;
20287 -+
20288 -+ req = ptr;
20289 -+ compls = ptr + sizeof(*req) + count * sizeof(*rpm_msgs);
20290 -+
20291 - req->count = count;
20292 - rpm_msgs = req->rpm_msgs;
20293 -
20294 -@@ -380,25 +387,26 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
20295 - }
20296 -
20297 - for (i = 0; i < count; i++) {
20298 -- rpm_msgs[i].completion = &compl;
20299 -+ struct completion *compl = &compls[i];
20300 -+
20301 -+ init_completion(compl);
20302 -+ rpm_msgs[i].completion = compl;
20303 - ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msgs[i].msg);
20304 - if (ret) {
20305 - pr_err("Error(%d) sending RPMH message addr=%#x\n",
20306 - ret, rpm_msgs[i].msg.cmds[0].addr);
20307 -- for (j = i; j < count; j++)
20308 -- rpmh_tx_done(&rpm_msgs[j].msg, ret);
20309 - break;
20310 - }
20311 - }
20312 -
20313 - time_left = RPMH_TIMEOUT_MS;
20314 -- for (i = 0; i < count; i++) {
20315 -- time_left = wait_for_completion_timeout(&compl, time_left);
20316 -+ while (i--) {
20317 -+ time_left = wait_for_completion_timeout(&compls[i], time_left);
20318 - if (!time_left) {
20319 - /*
20320 - * Better hope they never finish because they'll signal
20321 -- * the completion on our stack and that's bad once
20322 -- * we've returned from the function.
20323 -+ * the completion that we're going to free once
20324 -+ * we've returned from this function.
20325 - */
20326 - WARN_ON(1);
20327 - ret = -ETIMEDOUT;
20328 -@@ -407,7 +415,7 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
20329 - }
20330 -
20331 - exit:
20332 -- kfree(req);
20333 -+ kfree(ptr);
20334 -
20335 - return ret;
20336 - }
20337 -diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
20338 -index a33ee8ef8b6b..51625703399e 100644
20339 ---- a/drivers/soc/tegra/fuse/fuse-tegra.c
20340 -+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
20341 -@@ -137,13 +137,17 @@ static int tegra_fuse_probe(struct platform_device *pdev)
20342 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
20343 - fuse->phys = res->start;
20344 - fuse->base = devm_ioremap_resource(&pdev->dev, res);
20345 -- if (IS_ERR(fuse->base))
20346 -- return PTR_ERR(fuse->base);
20347 -+ if (IS_ERR(fuse->base)) {
20348 -+ err = PTR_ERR(fuse->base);
20349 -+ fuse->base = base;
20350 -+ return err;
20351 -+ }
20352 -
20353 - fuse->clk = devm_clk_get(&pdev->dev, "fuse");
20354 - if (IS_ERR(fuse->clk)) {
20355 - dev_err(&pdev->dev, "failed to get FUSE clock: %ld",
20356 - PTR_ERR(fuse->clk));
20357 -+ fuse->base = base;
20358 - return PTR_ERR(fuse->clk);
20359 - }
20360 -
20361 -@@ -152,8 +156,10 @@ static int tegra_fuse_probe(struct platform_device *pdev)
20362 -
20363 - if (fuse->soc->probe) {
20364 - err = fuse->soc->probe(fuse);
20365 -- if (err < 0)
20366 -+ if (err < 0) {
20367 -+ fuse->base = base;
20368 - return err;
20369 -+ }
20370 - }
20371 -
20372 - if (tegra_fuse_create_sysfs(&pdev->dev, fuse->soc->info->size,
20373 -diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
20374 -index a4aee26028cd..53b35c56a557 100644
20375 ---- a/drivers/spi/spi-gpio.c
20376 -+++ b/drivers/spi/spi-gpio.c
20377 -@@ -428,7 +428,8 @@ static int spi_gpio_probe(struct platform_device *pdev)
20378 - return status;
20379 -
20380 - master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
20381 -- master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL;
20382 -+ master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL |
20383 -+ SPI_CS_HIGH;
20384 - master->flags = master_flags;
20385 - master->bus_num = pdev->id;
20386 - /* The master needs to think there is a chipselect even if not connected */
20387 -@@ -455,7 +456,6 @@ static int spi_gpio_probe(struct platform_device *pdev)
20388 - spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3;
20389 - }
20390 - spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer;
20391 -- spi_gpio->bitbang.flags = SPI_CS_HIGH;
20392 -
20393 - status = spi_bitbang_start(&spi_gpio->bitbang);
20394 - if (status)
20395 -diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
20396 -index 2fd8881fcd65..8be304379628 100644
20397 ---- a/drivers/spi/spi-omap2-mcspi.c
20398 -+++ b/drivers/spi/spi-omap2-mcspi.c
20399 -@@ -623,8 +623,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
20400 - cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
20401 - cfg.src_addr_width = width;
20402 - cfg.dst_addr_width = width;
20403 -- cfg.src_maxburst = es;
20404 -- cfg.dst_maxburst = es;
20405 -+ cfg.src_maxburst = 1;
20406 -+ cfg.dst_maxburst = 1;
20407 -
20408 - rx = xfer->rx_buf;
20409 - tx = xfer->tx_buf;
20410 -diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
20411 -index d84b893a64d7..3e82eaad0f2d 100644
20412 ---- a/drivers/spi/spi-pxa2xx.c
20413 -+++ b/drivers/spi/spi-pxa2xx.c
20414 -@@ -1696,6 +1696,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
20415 - platform_info->enable_dma = false;
20416 - } else {
20417 - master->can_dma = pxa2xx_spi_can_dma;
20418 -+ master->max_dma_len = MAX_DMA_LEN;
20419 - }
20420 - }
20421 -
20422 -diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
20423 -index 5f19016bbf10..b9fb6493cd6b 100644
20424 ---- a/drivers/spi/spi-ti-qspi.c
20425 -+++ b/drivers/spi/spi-ti-qspi.c
20426 -@@ -490,8 +490,8 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
20427 - ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
20428 - if (qspi->ctrl_base) {
20429 - regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
20430 -- MEM_CS_EN(spi->chip_select),
20431 -- MEM_CS_MASK);
20432 -+ MEM_CS_MASK,
20433 -+ MEM_CS_EN(spi->chip_select));
20434 - }
20435 - qspi->mmap_enabled = true;
20436 - }
20437 -@@ -503,7 +503,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
20438 - ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
20439 - if (qspi->ctrl_base)
20440 - regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
20441 -- 0, MEM_CS_MASK);
20442 -+ MEM_CS_MASK, 0);
20443 - qspi->mmap_enabled = false;
20444 - }
20445 -
20446 -diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
20447 -index 90a8a9f1ac7d..910826df4a31 100644
20448 ---- a/drivers/staging/android/ashmem.c
20449 -+++ b/drivers/staging/android/ashmem.c
20450 -@@ -75,6 +75,9 @@ struct ashmem_range {
20451 - /* LRU list of unpinned pages, protected by ashmem_mutex */
20452 - static LIST_HEAD(ashmem_lru_list);
20453 -
20454 -+static atomic_t ashmem_shrink_inflight = ATOMIC_INIT(0);
20455 -+static DECLARE_WAIT_QUEUE_HEAD(ashmem_shrink_wait);
20456 -+
20457 - /*
20458 - * long lru_count - The count of pages on our LRU list.
20459 - *
20460 -@@ -168,19 +171,15 @@ static inline void lru_del(struct ashmem_range *range)
20461 - * @end: The ending page (inclusive)
20462 - *
20463 - * This function is protected by ashmem_mutex.
20464 -- *
20465 -- * Return: 0 if successful, or -ENOMEM if there is an error
20466 - */
20467 --static int range_alloc(struct ashmem_area *asma,
20468 -- struct ashmem_range *prev_range, unsigned int purged,
20469 -- size_t start, size_t end)
20470 -+static void range_alloc(struct ashmem_area *asma,
20471 -+ struct ashmem_range *prev_range, unsigned int purged,
20472 -+ size_t start, size_t end,
20473 -+ struct ashmem_range **new_range)
20474 - {
20475 -- struct ashmem_range *range;
20476 --
20477 -- range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL);
20478 -- if (!range)
20479 -- return -ENOMEM;
20480 -+ struct ashmem_range *range = *new_range;
20481 -
20482 -+ *new_range = NULL;
20483 - range->asma = asma;
20484 - range->pgstart = start;
20485 - range->pgend = end;
20486 -@@ -190,8 +189,6 @@ static int range_alloc(struct ashmem_area *asma,
20487 -
20488 - if (range_on_lru(range))
20489 - lru_add(range);
20490 --
20491 -- return 0;
20492 - }
20493 -
20494 - /**
20495 -@@ -438,7 +435,6 @@ out:
20496 - static unsigned long
20497 - ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
20498 - {
20499 -- struct ashmem_range *range, *next;
20500 - unsigned long freed = 0;
20501 -
20502 - /* We might recurse into filesystem code, so bail out if necessary */
20503 -@@ -448,21 +444,33 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
20504 - if (!mutex_trylock(&ashmem_mutex))
20505 - return -1;
20506 -
20507 -- list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
20508 -+ while (!list_empty(&ashmem_lru_list)) {
20509 -+ struct ashmem_range *range =
20510 -+ list_first_entry(&ashmem_lru_list, typeof(*range), lru);
20511 - loff_t start = range->pgstart * PAGE_SIZE;
20512 - loff_t end = (range->pgend + 1) * PAGE_SIZE;
20513 -+ struct file *f = range->asma->file;
20514 -
20515 -- range->asma->file->f_op->fallocate(range->asma->file,
20516 -- FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
20517 -- start, end - start);
20518 -+ get_file(f);
20519 -+ atomic_inc(&ashmem_shrink_inflight);
20520 - range->purged = ASHMEM_WAS_PURGED;
20521 - lru_del(range);
20522 -
20523 - freed += range_size(range);
20524 -+ mutex_unlock(&ashmem_mutex);
20525 -+ f->f_op->fallocate(f,
20526 -+ FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
20527 -+ start, end - start);
20528 -+ fput(f);
20529 -+ if (atomic_dec_and_test(&ashmem_shrink_inflight))
20530 -+ wake_up_all(&ashmem_shrink_wait);
20531 -+ if (!mutex_trylock(&ashmem_mutex))
20532 -+ goto out;
20533 - if (--sc->nr_to_scan <= 0)
20534 - break;
20535 - }
20536 - mutex_unlock(&ashmem_mutex);
20537 -+out:
20538 - return freed;
20539 - }
20540 -
20541 -@@ -582,7 +590,8 @@ static int get_name(struct ashmem_area *asma, void __user *name)
20542 - *
20543 - * Caller must hold ashmem_mutex.
20544 - */
20545 --static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
20546 -+static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend,
20547 -+ struct ashmem_range **new_range)
20548 - {
20549 - struct ashmem_range *range, *next;
20550 - int ret = ASHMEM_NOT_PURGED;
20551 -@@ -635,7 +644,7 @@ static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
20552 - * second half and adjust the first chunk's endpoint.
20553 - */
20554 - range_alloc(asma, range, range->purged,
20555 -- pgend + 1, range->pgend);
20556 -+ pgend + 1, range->pgend, new_range);
20557 - range_shrink(range, range->pgstart, pgstart - 1);
20558 - break;
20559 - }
20560 -@@ -649,7 +658,8 @@ static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
20561 - *
20562 - * Caller must hold ashmem_mutex.
20563 - */
20564 --static int ashmem_unpin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
20565 -+static int ashmem_unpin(struct ashmem_area *asma, size_t pgstart, size_t pgend,
20566 -+ struct ashmem_range **new_range)
20567 - {
20568 - struct ashmem_range *range, *next;
20569 - unsigned int purged = ASHMEM_NOT_PURGED;
20570 -@@ -675,7 +685,8 @@ restart:
20571 - }
20572 - }
20573 -
20574 -- return range_alloc(asma, range, purged, pgstart, pgend);
20575 -+ range_alloc(asma, range, purged, pgstart, pgend, new_range);
20576 -+ return 0;
20577 - }
20578 -
20579 - /*
20580 -@@ -708,11 +719,19 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
20581 - struct ashmem_pin pin;
20582 - size_t pgstart, pgend;
20583 - int ret = -EINVAL;
20584 -+ struct ashmem_range *range = NULL;
20585 -
20586 - if (copy_from_user(&pin, p, sizeof(pin)))
20587 - return -EFAULT;
20588 -
20589 -+ if (cmd == ASHMEM_PIN || cmd == ASHMEM_UNPIN) {
20590 -+ range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL);
20591 -+ if (!range)
20592 -+ return -ENOMEM;
20593 -+ }
20594 -+
20595 - mutex_lock(&ashmem_mutex);
20596 -+ wait_event(ashmem_shrink_wait, !atomic_read(&ashmem_shrink_inflight));
20597 -
20598 - if (!asma->file)
20599 - goto out_unlock;
20600 -@@ -735,10 +754,10 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
20601 -
20602 - switch (cmd) {
20603 - case ASHMEM_PIN:
20604 -- ret = ashmem_pin(asma, pgstart, pgend);
20605 -+ ret = ashmem_pin(asma, pgstart, pgend, &range);
20606 - break;
20607 - case ASHMEM_UNPIN:
20608 -- ret = ashmem_unpin(asma, pgstart, pgend);
20609 -+ ret = ashmem_unpin(asma, pgstart, pgend, &range);
20610 - break;
20611 - case ASHMEM_GET_PIN_STATUS:
20612 - ret = ashmem_get_pin_status(asma, pgstart, pgend);
20613 -@@ -747,6 +766,8 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
20614 -
20615 - out_unlock:
20616 - mutex_unlock(&ashmem_mutex);
20617 -+ if (range)
20618 -+ kmem_cache_free(ashmem_range_cachep, range);
20619 -
20620 - return ret;
20621 - }
20622 -diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
20623 -index 0383f7548d48..20f2103a4ebf 100644
20624 ---- a/drivers/staging/android/ion/ion_system_heap.c
20625 -+++ b/drivers/staging/android/ion/ion_system_heap.c
20626 -@@ -223,10 +223,10 @@ static void ion_system_heap_destroy_pools(struct ion_page_pool **pools)
20627 - static int ion_system_heap_create_pools(struct ion_page_pool **pools)
20628 - {
20629 - int i;
20630 -- gfp_t gfp_flags = low_order_gfp_flags;
20631 -
20632 - for (i = 0; i < NUM_ORDERS; i++) {
20633 - struct ion_page_pool *pool;
20634 -+ gfp_t gfp_flags = low_order_gfp_flags;
20635 -
20636 - if (orders[i] > 4)
20637 - gfp_flags = high_order_gfp_flags;
20638 -diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
20639 -index a7d569cfca5d..0dff1ac057cd 100644
20640 ---- a/drivers/staging/comedi/comedidev.h
20641 -+++ b/drivers/staging/comedi/comedidev.h
20642 -@@ -1001,6 +1001,8 @@ int comedi_dio_insn_config(struct comedi_device *dev,
20643 - unsigned int mask);
20644 - unsigned int comedi_dio_update_state(struct comedi_subdevice *s,
20645 - unsigned int *data);
20646 -+unsigned int comedi_bytes_per_scan_cmd(struct comedi_subdevice *s,
20647 -+ struct comedi_cmd *cmd);
20648 - unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s);
20649 - unsigned int comedi_nscans_left(struct comedi_subdevice *s,
20650 - unsigned int nscans);
20651 -diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
20652 -index eefa62f42c0f..5a32b8fc000e 100644
20653 ---- a/drivers/staging/comedi/drivers.c
20654 -+++ b/drivers/staging/comedi/drivers.c
20655 -@@ -394,11 +394,13 @@ unsigned int comedi_dio_update_state(struct comedi_subdevice *s,
20656 - EXPORT_SYMBOL_GPL(comedi_dio_update_state);
20657 -
20658 - /**
20659 -- * comedi_bytes_per_scan() - Get length of asynchronous command "scan" in bytes
20660 -+ * comedi_bytes_per_scan_cmd() - Get length of asynchronous command "scan" in
20661 -+ * bytes
20662 - * @s: COMEDI subdevice.
20663 -+ * @cmd: COMEDI command.
20664 - *
20665 - * Determines the overall scan length according to the subdevice type and the
20666 -- * number of channels in the scan.
20667 -+ * number of channels in the scan for the specified command.
20668 - *
20669 - * For digital input, output or input/output subdevices, samples for
20670 - * multiple channels are assumed to be packed into one or more unsigned
20671 -@@ -408,9 +410,9 @@ EXPORT_SYMBOL_GPL(comedi_dio_update_state);
20672 - *
20673 - * Returns the overall scan length in bytes.
20674 - */
20675 --unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s)
20676 -+unsigned int comedi_bytes_per_scan_cmd(struct comedi_subdevice *s,
20677 -+ struct comedi_cmd *cmd)
20678 - {
20679 -- struct comedi_cmd *cmd = &s->async->cmd;
20680 - unsigned int num_samples;
20681 - unsigned int bits_per_sample;
20682 -
20683 -@@ -427,6 +429,29 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s)
20684 - }
20685 - return comedi_samples_to_bytes(s, num_samples);
20686 - }
20687 -+EXPORT_SYMBOL_GPL(comedi_bytes_per_scan_cmd);
20688 -+
20689 -+/**
20690 -+ * comedi_bytes_per_scan() - Get length of asynchronous command "scan" in bytes
20691 -+ * @s: COMEDI subdevice.
20692 -+ *
20693 -+ * Determines the overall scan length according to the subdevice type and the
20694 -+ * number of channels in the scan for the current command.
20695 -+ *
20696 -+ * For digital input, output or input/output subdevices, samples for
20697 -+ * multiple channels are assumed to be packed into one or more unsigned
20698 -+ * short or unsigned int values according to the subdevice's %SDF_LSAMPL
20699 -+ * flag. For other types of subdevice, samples are assumed to occupy a
20700 -+ * whole unsigned short or unsigned int according to the %SDF_LSAMPL flag.
20701 -+ *
20702 -+ * Returns the overall scan length in bytes.
20703 -+ */
20704 -+unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s)
20705 -+{
20706 -+ struct comedi_cmd *cmd = &s->async->cmd;
20707 -+
20708 -+ return comedi_bytes_per_scan_cmd(s, cmd);
20709 -+}
20710 - EXPORT_SYMBOL_GPL(comedi_bytes_per_scan);
20711 -
20712 - static unsigned int __comedi_nscans_left(struct comedi_subdevice *s,
20713 -diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
20714 -index e70a461e723f..405573e927cf 100644
20715 ---- a/drivers/staging/comedi/drivers/ni_660x.c
20716 -+++ b/drivers/staging/comedi/drivers/ni_660x.c
20717 -@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev,
20718 - case NI_660X_PFI_OUTPUT_DIO:
20719 - if (chan > 31)
20720 - return -EINVAL;
20721 -+ break;
20722 - default:
20723 - return -EINVAL;
20724 - }
20725 -diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
20726 -index 5edf59ac6706..b04dad8c7092 100644
20727 ---- a/drivers/staging/comedi/drivers/ni_mio_common.c
20728 -+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
20729 -@@ -3545,6 +3545,7 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
20730 - struct comedi_subdevice *s, struct comedi_cmd *cmd)
20731 - {
20732 - struct ni_private *devpriv = dev->private;
20733 -+ unsigned int bytes_per_scan;
20734 - int err = 0;
20735 -
20736 - /* Step 1 : check if triggers are trivially valid */
20737 -@@ -3579,9 +3580,12 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
20738 - err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
20739 - err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
20740 - cmd->chanlist_len);
20741 -- err |= comedi_check_trigger_arg_max(&cmd->stop_arg,
20742 -- s->async->prealloc_bufsz /
20743 -- comedi_bytes_per_scan(s));
20744 -+ bytes_per_scan = comedi_bytes_per_scan_cmd(s, cmd);
20745 -+ if (bytes_per_scan) {
20746 -+ err |= comedi_check_trigger_arg_max(&cmd->stop_arg,
20747 -+ s->async->prealloc_bufsz /
20748 -+ bytes_per_scan);
20749 -+ }
20750 -
20751 - if (err)
20752 - return 3;
20753 -diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c
20754 -index 833f052f79d0..b21ed5b4c711 100644
20755 ---- a/drivers/staging/erofs/dir.c
20756 -+++ b/drivers/staging/erofs/dir.c
20757 -@@ -23,6 +23,21 @@ static const unsigned char erofs_filetype_table[EROFS_FT_MAX] = {
20758 - [EROFS_FT_SYMLINK] = DT_LNK,
20759 - };
20760 -
20761 -+static void debug_one_dentry(unsigned char d_type, const char *de_name,
20762 -+ unsigned int de_namelen)
20763 -+{
20764 -+#ifdef CONFIG_EROFS_FS_DEBUG
20765 -+ /* since the on-disk name could not have the trailing '\0' */
20766 -+ unsigned char dbg_namebuf[EROFS_NAME_LEN + 1];
20767 -+
20768 -+ memcpy(dbg_namebuf, de_name, de_namelen);
20769 -+ dbg_namebuf[de_namelen] = '\0';
20770 -+
20771 -+ debugln("found dirent %s de_len %u d_type %d", dbg_namebuf,
20772 -+ de_namelen, d_type);
20773 -+#endif
20774 -+}
20775 -+
20776 - static int erofs_fill_dentries(struct dir_context *ctx,
20777 - void *dentry_blk, unsigned int *ofs,
20778 - unsigned int nameoff, unsigned int maxsize)
20779 -@@ -33,14 +48,10 @@ static int erofs_fill_dentries(struct dir_context *ctx,
20780 - de = dentry_blk + *ofs;
20781 - while (de < end) {
20782 - const char *de_name;
20783 -- int de_namelen;
20784 -+ unsigned int de_namelen;
20785 - unsigned char d_type;
20786 --#ifdef CONFIG_EROFS_FS_DEBUG
20787 -- unsigned int dbg_namelen;
20788 -- unsigned char dbg_namebuf[EROFS_NAME_LEN];
20789 --#endif
20790 -
20791 -- if (unlikely(de->file_type < EROFS_FT_MAX))
20792 -+ if (de->file_type < EROFS_FT_MAX)
20793 - d_type = erofs_filetype_table[de->file_type];
20794 - else
20795 - d_type = DT_UNKNOWN;
20796 -@@ -48,26 +59,20 @@ static int erofs_fill_dentries(struct dir_context *ctx,
20797 - nameoff = le16_to_cpu(de->nameoff);
20798 - de_name = (char *)dentry_blk + nameoff;
20799 -
20800 -- de_namelen = unlikely(de + 1 >= end) ?
20801 -- /* last directory entry */
20802 -- strnlen(de_name, maxsize - nameoff) :
20803 -- le16_to_cpu(de[1].nameoff) - nameoff;
20804 -+ /* the last dirent in the block? */
20805 -+ if (de + 1 >= end)
20806 -+ de_namelen = strnlen(de_name, maxsize - nameoff);
20807 -+ else
20808 -+ de_namelen = le16_to_cpu(de[1].nameoff) - nameoff;
20809 -
20810 - /* a corrupted entry is found */
20811 -- if (unlikely(de_namelen < 0)) {
20812 -+ if (unlikely(nameoff + de_namelen > maxsize ||
20813 -+ de_namelen > EROFS_NAME_LEN)) {
20814 - DBG_BUGON(1);
20815 - return -EIO;
20816 - }
20817 -
20818 --#ifdef CONFIG_EROFS_FS_DEBUG
20819 -- dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen);
20820 -- memcpy(dbg_namebuf, de_name, dbg_namelen);
20821 -- dbg_namebuf[dbg_namelen] = '\0';
20822 --
20823 -- debugln("%s, found de_name %s de_len %d d_type %d", __func__,
20824 -- dbg_namebuf, de_namelen, d_type);
20825 --#endif
20826 --
20827 -+ debug_one_dentry(d_type, de_name, de_namelen);
20828 - if (!dir_emit(ctx, de_name, de_namelen,
20829 - le64_to_cpu(de->nid), d_type))
20830 - /* stopped by some reason */
20831 -diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
20832 -index d7fbf5f4600f..f99954dbfdb5 100644
20833 ---- a/drivers/staging/erofs/inode.c
20834 -+++ b/drivers/staging/erofs/inode.c
20835 -@@ -185,16 +185,16 @@ static int fill_inode(struct inode *inode, int isdir)
20836 - /* setup the new inode */
20837 - if (S_ISREG(inode->i_mode)) {
20838 - #ifdef CONFIG_EROFS_FS_XATTR
20839 -- if (vi->xattr_isize)
20840 -- inode->i_op = &erofs_generic_xattr_iops;
20841 -+ inode->i_op = &erofs_generic_xattr_iops;
20842 - #endif
20843 - inode->i_fop = &generic_ro_fops;
20844 - } else if (S_ISDIR(inode->i_mode)) {
20845 - inode->i_op =
20846 - #ifdef CONFIG_EROFS_FS_XATTR
20847 -- vi->xattr_isize ? &erofs_dir_xattr_iops :
20848 --#endif
20849 -+ &erofs_dir_xattr_iops;
20850 -+#else
20851 - &erofs_dir_iops;
20852 -+#endif
20853 - inode->i_fop = &erofs_dir_fops;
20854 - } else if (S_ISLNK(inode->i_mode)) {
20855 - /* by default, page_get_link is used for symlink */
20856 -diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
20857 -index e049d00c087a..16249d7f0895 100644
20858 ---- a/drivers/staging/erofs/internal.h
20859 -+++ b/drivers/staging/erofs/internal.h
20860 -@@ -354,12 +354,17 @@ static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid)
20861 - return blknr_to_addr(sbi->meta_blkaddr) + (nid << sbi->islotbits);
20862 - }
20863 -
20864 --#define inode_set_inited_xattr(inode) (EROFS_V(inode)->flags |= 1)
20865 --#define inode_has_inited_xattr(inode) (EROFS_V(inode)->flags & 1)
20866 -+/* atomic flag definitions */
20867 -+#define EROFS_V_EA_INITED_BIT 0
20868 -+
20869 -+/* bitlock definitions (arranged in reverse order) */
20870 -+#define EROFS_V_BL_XATTR_BIT (BITS_PER_LONG - 1)
20871 -
20872 - struct erofs_vnode {
20873 - erofs_nid_t nid;
20874 -- unsigned int flags;
20875 -+
20876 -+ /* atomic flags (including bitlocks) */
20877 -+ unsigned long flags;
20878 -
20879 - unsigned char data_mapping_mode;
20880 - /* inline size in bytes */
20881 -diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
20882 -index 5596c52e246d..ecc51ef0753f 100644
20883 ---- a/drivers/staging/erofs/namei.c
20884 -+++ b/drivers/staging/erofs/namei.c
20885 -@@ -15,74 +15,77 @@
20886 -
20887 - #include <trace/events/erofs.h>
20888 -
20889 --/* based on the value of qn->len is accurate */
20890 --static inline int dirnamecmp(struct qstr *qn,
20891 -- struct qstr *qd, unsigned int *matched)
20892 -+struct erofs_qstr {
20893 -+ const unsigned char *name;
20894 -+ const unsigned char *end;
20895 -+};
20896 -+
20897 -+/* based on the end of qn is accurate and it must have the trailing '\0' */
20898 -+static inline int dirnamecmp(const struct erofs_qstr *qn,
20899 -+ const struct erofs_qstr *qd,
20900 -+ unsigned int *matched)
20901 - {
20902 -- unsigned int i = *matched, len = min(qn->len, qd->len);
20903 --loop:
20904 -- if (unlikely(i >= len)) {
20905 -- *matched = i;
20906 -- if (qn->len < qd->len) {
20907 -- /*
20908 -- * actually (qn->len == qd->len)
20909 -- * when qd->name[i] == '\0'
20910 -- */
20911 -- return qd->name[i] == '\0' ? 0 : -1;
20912 -+ unsigned int i = *matched;
20913 -+
20914 -+ /*
20915 -+ * on-disk error, let's only BUG_ON in the debugging mode.
20916 -+ * otherwise, it will return 1 to just skip the invalid name
20917 -+ * and go on (in consideration of the lookup performance).
20918 -+ */
20919 -+ DBG_BUGON(qd->name > qd->end);
20920 -+
20921 -+ /* qd could not have trailing '\0' */
20922 -+ /* However it is absolutely safe if < qd->end */
20923 -+ while (qd->name + i < qd->end && qd->name[i] != '\0') {
20924 -+ if (qn->name[i] != qd->name[i]) {
20925 -+ *matched = i;
20926 -+ return qn->name[i] > qd->name[i] ? 1 : -1;
20927 - }
20928 -- return (qn->len > qd->len);
20929 -+ ++i;
20930 - }
20931 --
20932 -- if (qn->name[i] != qd->name[i]) {
20933 -- *matched = i;
20934 -- return qn->name[i] > qd->name[i] ? 1 : -1;
20935 -- }
20936 --
20937 -- ++i;
20938 -- goto loop;
20939 -+ *matched = i;
20940 -+ /* See comments in __d_alloc on the terminating NUL character */
20941 -+ return qn->name[i] == '\0' ? 0 : 1;
20942 - }
20943 -
20944 --static struct erofs_dirent *find_target_dirent(
20945 -- struct qstr *name,
20946 -- u8 *data, int maxsize)
20947 -+#define nameoff_from_disk(off, sz) (le16_to_cpu(off) & ((sz) - 1))
20948 -+
20949 -+static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name,
20950 -+ u8 *data,
20951 -+ unsigned int dirblksize,
20952 -+ const int ndirents)
20953 - {
20954 -- unsigned int ndirents, head, back;
20955 -+ int head, back;
20956 - unsigned int startprfx, endprfx;
20957 - struct erofs_dirent *const de = (struct erofs_dirent *)data;
20958 -
20959 -- /* make sure that maxsize is valid */
20960 -- BUG_ON(maxsize < sizeof(struct erofs_dirent));
20961 --
20962 -- ndirents = le16_to_cpu(de->nameoff) / sizeof(*de);
20963 --
20964 -- /* corrupted dir (may be unnecessary...) */
20965 -- BUG_ON(!ndirents);
20966 --
20967 -- head = 0;
20968 -+ /* since the 1st dirent has been evaluated previously */
20969 -+ head = 1;
20970 - back = ndirents - 1;
20971 - startprfx = endprfx = 0;
20972 -
20973 - while (head <= back) {
20974 -- unsigned int mid = head + (back - head) / 2;
20975 -- unsigned int nameoff = le16_to_cpu(de[mid].nameoff);
20976 -+ const int mid = head + (back - head) / 2;
20977 -+ const int nameoff = nameoff_from_disk(de[mid].nameoff,
20978 -+ dirblksize);
20979 - unsigned int matched = min(startprfx, endprfx);
20980 --
20981 -- struct qstr dname = QSTR_INIT(data + nameoff,
20982 -- unlikely(mid >= ndirents - 1) ?
20983 -- maxsize - nameoff :
20984 -- le16_to_cpu(de[mid + 1].nameoff) - nameoff);
20985 -+ struct erofs_qstr dname = {
20986 -+ .name = data + nameoff,
20987 -+ .end = unlikely(mid >= ndirents - 1) ?
20988 -+ data + dirblksize :
20989 -+ data + nameoff_from_disk(de[mid + 1].nameoff,
20990 -+ dirblksize)
20991 -+ };
20992 -
20993 - /* string comparison without already matched prefix */
20994 - int ret = dirnamecmp(name, &dname, &matched);
20995 -
20996 -- if (unlikely(!ret))
20997 -+ if (unlikely(!ret)) {
20998 - return de + mid;
20999 -- else if (ret > 0) {
21000 -+ } else if (ret > 0) {
21001 - head = mid + 1;
21002 - startprfx = matched;
21003 -- } else if (unlikely(mid < 1)) /* fix "mid" overflow */
21004 -- break;
21005 -- else {
21006 -+ } else {
21007 - back = mid - 1;
21008 - endprfx = matched;
21009 - }
21010 -@@ -91,12 +94,12 @@ static struct erofs_dirent *find_target_dirent(
21011 - return ERR_PTR(-ENOENT);
21012 - }
21013 -
21014 --static struct page *find_target_block_classic(
21015 -- struct inode *dir,
21016 -- struct qstr *name, int *_diff)
21017 -+static struct page *find_target_block_classic(struct inode *dir,
21018 -+ struct erofs_qstr *name,
21019 -+ int *_ndirents)
21020 - {
21021 - unsigned int startprfx, endprfx;
21022 -- unsigned int head, back;
21023 -+ int head, back;
21024 - struct address_space *const mapping = dir->i_mapping;
21025 - struct page *candidate = ERR_PTR(-ENOENT);
21026 -
21027 -@@ -105,41 +108,43 @@ static struct page *find_target_block_classic(
21028 - back = inode_datablocks(dir) - 1;
21029 -
21030 - while (head <= back) {
21031 -- unsigned int mid = head + (back - head) / 2;
21032 -+ const int mid = head + (back - head) / 2;
21033 - struct page *page = read_mapping_page(mapping, mid, NULL);
21034 -
21035 -- if (IS_ERR(page)) {
21036 --exact_out:
21037 -- if (!IS_ERR(candidate)) /* valid candidate */
21038 -- put_page(candidate);
21039 -- return page;
21040 -- } else {
21041 -- int diff;
21042 -- unsigned int ndirents, matched;
21043 -- struct qstr dname;
21044 -+ if (!IS_ERR(page)) {
21045 - struct erofs_dirent *de = kmap_atomic(page);
21046 -- unsigned int nameoff = le16_to_cpu(de->nameoff);
21047 --
21048 -- ndirents = nameoff / sizeof(*de);
21049 -+ const int nameoff = nameoff_from_disk(de->nameoff,
21050 -+ EROFS_BLKSIZ);
21051 -+ const int ndirents = nameoff / sizeof(*de);
21052 -+ int diff;
21053 -+ unsigned int matched;
21054 -+ struct erofs_qstr dname;
21055 -
21056 -- /* corrupted dir (should have one entry at least) */
21057 -- BUG_ON(!ndirents || nameoff > PAGE_SIZE);
21058 -+ if (unlikely(!ndirents)) {
21059 -+ DBG_BUGON(1);
21060 -+ kunmap_atomic(de);
21061 -+ put_page(page);
21062 -+ page = ERR_PTR(-EIO);
21063 -+ goto out;
21064 -+ }
21065 -
21066 - matched = min(startprfx, endprfx);
21067 -
21068 - dname.name = (u8 *)de + nameoff;
21069 -- dname.len = ndirents == 1 ?
21070 -- /* since the rest of the last page is 0 */
21071 -- EROFS_BLKSIZ - nameoff
21072 -- : le16_to_cpu(de[1].nameoff) - nameoff;
21073 -+ if (ndirents == 1)
21074 -+ dname.end = (u8 *)de + EROFS_BLKSIZ;
21075 -+ else
21076 -+ dname.end = (u8 *)de +
21077 -+ nameoff_from_disk(de[1].nameoff,
21078 -+ EROFS_BLKSIZ);
21079 -
21080 - /* string comparison without already matched prefix */
21081 - diff = dirnamecmp(name, &dname, &matched);
21082 - kunmap_atomic(de);
21083 -
21084 - if (unlikely(!diff)) {
21085 -- *_diff = 0;
21086 -- goto exact_out;
21087 -+ *_ndirents = 0;
21088 -+ goto out;
21089 - } else if (diff > 0) {
21090 - head = mid + 1;
21091 - startprfx = matched;
21092 -@@ -147,45 +152,51 @@ exact_out:
21093 - if (likely(!IS_ERR(candidate)))
21094 - put_page(candidate);
21095 - candidate = page;
21096 -+ *_ndirents = ndirents;
21097 - } else {
21098 - put_page(page);
21099 -
21100 -- if (unlikely(mid < 1)) /* fix "mid" overflow */
21101 -- break;
21102 --
21103 - back = mid - 1;
21104 - endprfx = matched;
21105 - }
21106 -+ continue;
21107 - }
21108 -+out: /* free if the candidate is valid */
21109 -+ if (!IS_ERR(candidate))
21110 -+ put_page(candidate);
21111 -+ return page;
21112 - }
21113 -- *_diff = 1;
21114 - return candidate;
21115 - }
21116 -
21117 - int erofs_namei(struct inode *dir,
21118 -- struct qstr *name,
21119 -- erofs_nid_t *nid, unsigned int *d_type)
21120 -+ struct qstr *name,
21121 -+ erofs_nid_t *nid, unsigned int *d_type)
21122 - {
21123 -- int diff;
21124 -+ int ndirents;
21125 - struct page *page;
21126 -- u8 *data;
21127 -+ void *data;
21128 - struct erofs_dirent *de;
21129 -+ struct erofs_qstr qn;
21130 -
21131 - if (unlikely(!dir->i_size))
21132 - return -ENOENT;
21133 -
21134 -- diff = 1;
21135 -- page = find_target_block_classic(dir, name, &diff);
21136 -+ qn.name = name->name;
21137 -+ qn.end = name->name + name->len;
21138 -+
21139 -+ ndirents = 0;
21140 -+ page = find_target_block_classic(dir, &qn, &ndirents);
21141 -
21142 - if (unlikely(IS_ERR(page)))
21143 - return PTR_ERR(page);
21144 -
21145 - data = kmap_atomic(page);
21146 - /* the target page has been mapped */
21147 -- de = likely(diff) ?
21148 -- /* since the rest of the last page is 0 */
21149 -- find_target_dirent(name, data, EROFS_BLKSIZ) :
21150 -- (struct erofs_dirent *)data;
21151 -+ if (ndirents)
21152 -+ de = find_target_dirent(&qn, data, EROFS_BLKSIZ, ndirents);
21153 -+ else
21154 -+ de = (struct erofs_dirent *)data;
21155 -
21156 - if (likely(!IS_ERR(de))) {
21157 - *nid = le64_to_cpu(de->nid);
21158 -diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
21159 -index 4ac1099a39c6..d850be1abc84 100644
21160 ---- a/drivers/staging/erofs/unzip_vle.c
21161 -+++ b/drivers/staging/erofs/unzip_vle.c
21162 -@@ -107,15 +107,30 @@ enum z_erofs_vle_work_role {
21163 - Z_EROFS_VLE_WORK_SECONDARY,
21164 - Z_EROFS_VLE_WORK_PRIMARY,
21165 - /*
21166 -- * The current work has at least been linked with the following
21167 -- * processed chained works, which means if the processing page
21168 -- * is the tail partial page of the work, the current work can
21169 -- * safely use the whole page, as illustrated below:
21170 -- * +--------------+-------------------------------------------+
21171 -- * | tail page | head page (of the previous work) |
21172 -- * +--------------+-------------------------------------------+
21173 -- * /\ which belongs to the current work
21174 -- * [ (*) this page can be used for the current work itself. ]
21175 -+ * The current work was the tail of an exist chain, and the previous
21176 -+ * processed chained works are all decided to be hooked up to it.
21177 -+ * A new chain should be created for the remaining unprocessed works,
21178 -+ * therefore different from Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
21179 -+ * the next work cannot reuse the whole page in the following scenario:
21180 -+ * ________________________________________________________________
21181 -+ * | tail (partial) page | head (partial) page |
21182 -+ * | (belongs to the next work) | (belongs to the current work) |
21183 -+ * |_______PRIMARY_FOLLOWED_______|________PRIMARY_HOOKED___________|
21184 -+ */
21185 -+ Z_EROFS_VLE_WORK_PRIMARY_HOOKED,
21186 -+ /*
21187 -+ * The current work has been linked with the processed chained works,
21188 -+ * and could be also linked with the potential remaining works, which
21189 -+ * means if the processing page is the tail partial page of the work,
21190 -+ * the current work can safely use the whole page (since the next work
21191 -+ * is under control) for in-place decompression, as illustrated below:
21192 -+ * ________________________________________________________________
21193 -+ * | tail (partial) page | head (partial) page |
21194 -+ * | (of the current work) | (of the previous work) |
21195 -+ * | PRIMARY_FOLLOWED or | |
21196 -+ * |_____PRIMARY_HOOKED____|____________PRIMARY_FOLLOWED____________|
21197 -+ *
21198 -+ * [ (*) the above page can be used for the current work itself. ]
21199 - */
21200 - Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
21201 - Z_EROFS_VLE_WORK_MAX
21202 -@@ -315,10 +330,10 @@ static int z_erofs_vle_work_add_page(
21203 - return ret ? 0 : -EAGAIN;
21204 - }
21205 -
21206 --static inline bool try_to_claim_workgroup(
21207 -- struct z_erofs_vle_workgroup *grp,
21208 -- z_erofs_vle_owned_workgrp_t *owned_head,
21209 -- bool *hosted)
21210 -+static enum z_erofs_vle_work_role
21211 -+try_to_claim_workgroup(struct z_erofs_vle_workgroup *grp,
21212 -+ z_erofs_vle_owned_workgrp_t *owned_head,
21213 -+ bool *hosted)
21214 - {
21215 - DBG_BUGON(*hosted == true);
21216 -
21217 -@@ -332,6 +347,9 @@ retry:
21218 -
21219 - *owned_head = &grp->next;
21220 - *hosted = true;
21221 -+ /* lucky, I am the followee :) */
21222 -+ return Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED;
21223 -+
21224 - } else if (grp->next == Z_EROFS_VLE_WORKGRP_TAIL) {
21225 - /*
21226 - * type 2, link to the end of a existing open chain,
21227 -@@ -341,12 +359,11 @@ retry:
21228 - if (cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL,
21229 - *owned_head) != Z_EROFS_VLE_WORKGRP_TAIL)
21230 - goto retry;
21231 --
21232 - *owned_head = Z_EROFS_VLE_WORKGRP_TAIL;
21233 -- } else
21234 -- return false; /* :( better luck next time */
21235 -+ return Z_EROFS_VLE_WORK_PRIMARY_HOOKED;
21236 -+ }
21237 -
21238 -- return true; /* lucky, I am the followee :) */
21239 -+ return Z_EROFS_VLE_WORK_PRIMARY; /* :( better luck next time */
21240 - }
21241 -
21242 - struct z_erofs_vle_work_finder {
21243 -@@ -424,12 +441,9 @@ z_erofs_vle_work_lookup(const struct z_erofs_vle_work_finder *f)
21244 - *f->hosted = false;
21245 - if (!primary)
21246 - *f->role = Z_EROFS_VLE_WORK_SECONDARY;
21247 -- /* claim the workgroup if possible */
21248 -- else if (try_to_claim_workgroup(grp, f->owned_head, f->hosted))
21249 -- *f->role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED;
21250 -- else
21251 -- *f->role = Z_EROFS_VLE_WORK_PRIMARY;
21252 --
21253 -+ else /* claim the workgroup if possible */
21254 -+ *f->role = try_to_claim_workgroup(grp, f->owned_head,
21255 -+ f->hosted);
21256 - return work;
21257 - }
21258 -
21259 -@@ -493,6 +507,9 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f,
21260 - return work;
21261 - }
21262 -
21263 -+#define builder_is_hooked(builder) \
21264 -+ ((builder)->role >= Z_EROFS_VLE_WORK_PRIMARY_HOOKED)
21265 -+
21266 - #define builder_is_followed(builder) \
21267 - ((builder)->role >= Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED)
21268 -
21269 -@@ -686,7 +703,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
21270 - struct z_erofs_vle_work_builder *const builder = &fe->builder;
21271 - const loff_t offset = page_offset(page);
21272 -
21273 -- bool tight = builder_is_followed(builder);
21274 -+ bool tight = builder_is_hooked(builder);
21275 - struct z_erofs_vle_work *work = builder->work;
21276 -
21277 - enum z_erofs_cache_alloctype cache_strategy;
21278 -@@ -704,8 +721,12 @@ repeat:
21279 -
21280 - /* lucky, within the range of the current map_blocks */
21281 - if (offset + cur >= map->m_la &&
21282 -- offset + cur < map->m_la + map->m_llen)
21283 -+ offset + cur < map->m_la + map->m_llen) {
21284 -+ /* didn't get a valid unzip work previously (very rare) */
21285 -+ if (!builder->work)
21286 -+ goto restart_now;
21287 - goto hitted;
21288 -+ }
21289 -
21290 - /* go ahead the next map_blocks */
21291 - debugln("%s: [out-of-range] pos %llu", __func__, offset + cur);
21292 -@@ -719,6 +740,7 @@ repeat:
21293 - if (unlikely(err))
21294 - goto err_out;
21295 -
21296 -+restart_now:
21297 - if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED)))
21298 - goto hitted;
21299 -
21300 -@@ -740,7 +762,7 @@ repeat:
21301 - map->m_plen / PAGE_SIZE,
21302 - cache_strategy, page_pool, GFP_KERNEL);
21303 -
21304 -- tight &= builder_is_followed(builder);
21305 -+ tight &= builder_is_hooked(builder);
21306 - work = builder->work;
21307 - hitted:
21308 - cur = end - min_t(unsigned int, offset + end - map->m_la, end);
21309 -@@ -755,6 +777,9 @@ hitted:
21310 - (tight ? Z_EROFS_PAGE_TYPE_EXCLUSIVE :
21311 - Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED));
21312 -
21313 -+ if (cur)
21314 -+ tight &= builder_is_followed(builder);
21315 -+
21316 - retry:
21317 - err = z_erofs_vle_work_add_page(builder, page, page_type);
21318 - /* should allocate an additional staging page for pagevec */
21319 -@@ -952,6 +977,7 @@ repeat:
21320 - overlapped = false;
21321 - compressed_pages = grp->compressed_pages;
21322 -
21323 -+ err = 0;
21324 - for (i = 0; i < clusterpages; ++i) {
21325 - unsigned int pagenr;
21326 -
21327 -@@ -961,26 +987,39 @@ repeat:
21328 - DBG_BUGON(!page);
21329 - DBG_BUGON(!page->mapping);
21330 -
21331 -- if (z_erofs_is_stagingpage(page))
21332 -- continue;
21333 -+ if (!z_erofs_is_stagingpage(page)) {
21334 - #ifdef EROFS_FS_HAS_MANAGED_CACHE
21335 -- if (page->mapping == MNGD_MAPPING(sbi)) {
21336 -- DBG_BUGON(!PageUptodate(page));
21337 -- continue;
21338 -- }
21339 -+ if (page->mapping == MNGD_MAPPING(sbi)) {
21340 -+ if (unlikely(!PageUptodate(page)))
21341 -+ err = -EIO;
21342 -+ continue;
21343 -+ }
21344 - #endif
21345 -
21346 -- /* only non-head page could be reused as a compressed page */
21347 -- pagenr = z_erofs_onlinepage_index(page);
21348 -+ /*
21349 -+ * only if non-head page can be selected
21350 -+ * for inplace decompression
21351 -+ */
21352 -+ pagenr = z_erofs_onlinepage_index(page);
21353 -
21354 -- DBG_BUGON(pagenr >= nr_pages);
21355 -- DBG_BUGON(pages[pagenr]);
21356 -- ++sparsemem_pages;
21357 -- pages[pagenr] = page;
21358 -+ DBG_BUGON(pagenr >= nr_pages);
21359 -+ DBG_BUGON(pages[pagenr]);
21360 -+ ++sparsemem_pages;
21361 -+ pages[pagenr] = page;
21362 -
21363 -- overlapped = true;
21364 -+ overlapped = true;
21365 -+ }
21366 -+
21367 -+ /* PG_error needs checking for inplaced and staging pages */
21368 -+ if (unlikely(PageError(page))) {
21369 -+ DBG_BUGON(PageUptodate(page));
21370 -+ err = -EIO;
21371 -+ }
21372 - }
21373 -
21374 -+ if (unlikely(err))
21375 -+ goto out;
21376 -+
21377 - llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
21378 -
21379 - if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
21380 -@@ -992,11 +1031,10 @@ repeat:
21381 - if (llen > grp->llen)
21382 - llen = grp->llen;
21383 -
21384 -- err = z_erofs_vle_unzip_fast_percpu(compressed_pages,
21385 -- clusterpages, pages, llen, work->pageofs,
21386 -- z_erofs_onlinepage_endio);
21387 -+ err = z_erofs_vle_unzip_fast_percpu(compressed_pages, clusterpages,
21388 -+ pages, llen, work->pageofs);
21389 - if (err != -ENOTSUPP)
21390 -- goto out_percpu;
21391 -+ goto out;
21392 -
21393 - if (sparsemem_pages >= nr_pages)
21394 - goto skip_allocpage;
21395 -@@ -1010,6 +1048,10 @@ repeat:
21396 -
21397 - skip_allocpage:
21398 - vout = erofs_vmap(pages, nr_pages);
21399 -+ if (!vout) {
21400 -+ err = -ENOMEM;
21401 -+ goto out;
21402 -+ }
21403 -
21404 - err = z_erofs_vle_unzip_vmap(compressed_pages,
21405 - clusterpages, vout, llen, work->pageofs, overlapped);
21406 -@@ -1017,8 +1059,25 @@ skip_allocpage:
21407 - erofs_vunmap(vout, nr_pages);
21408 -
21409 - out:
21410 -+ /* must handle all compressed pages before endding pages */
21411 -+ for (i = 0; i < clusterpages; ++i) {
21412 -+ page = compressed_pages[i];
21413 -+
21414 -+#ifdef EROFS_FS_HAS_MANAGED_CACHE
21415 -+ if (page->mapping == MNGD_MAPPING(sbi))
21416 -+ continue;
21417 -+#endif
21418 -+ /* recycle all individual staging pages */
21419 -+ (void)z_erofs_gather_if_stagingpage(page_pool, page);
21420 -+
21421 -+ WRITE_ONCE(compressed_pages[i], NULL);
21422 -+ }
21423 -+
21424 - for (i = 0; i < nr_pages; ++i) {
21425 - page = pages[i];
21426 -+ if (!page)
21427 -+ continue;
21428 -+
21429 - DBG_BUGON(!page->mapping);
21430 -
21431 - /* recycle all individual staging pages */
21432 -@@ -1031,20 +1090,6 @@ out:
21433 - z_erofs_onlinepage_endio(page);
21434 - }
21435 -
21436 --out_percpu:
21437 -- for (i = 0; i < clusterpages; ++i) {
21438 -- page = compressed_pages[i];
21439 --
21440 --#ifdef EROFS_FS_HAS_MANAGED_CACHE
21441 -- if (page->mapping == MNGD_MAPPING(sbi))
21442 -- continue;
21443 --#endif
21444 -- /* recycle all individual staging pages */
21445 -- (void)z_erofs_gather_if_stagingpage(page_pool, page);
21446 --
21447 -- WRITE_ONCE(compressed_pages[i], NULL);
21448 -- }
21449 --
21450 - if (pages == z_pagemap_global)
21451 - mutex_unlock(&z_pagemap_global_lock);
21452 - else if (unlikely(pages != pages_onstack))
21453 -@@ -1172,6 +1217,7 @@ repeat:
21454 - if (page->mapping == mc) {
21455 - WRITE_ONCE(grp->compressed_pages[nr], page);
21456 -
21457 -+ ClearPageError(page);
21458 - if (!PagePrivate(page)) {
21459 - /*
21460 - * impossible to be !PagePrivate(page) for
21461 -diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h
21462 -index 5a4e1b62c0d1..c0dfd6906aa8 100644
21463 ---- a/drivers/staging/erofs/unzip_vle.h
21464 -+++ b/drivers/staging/erofs/unzip_vle.h
21465 -@@ -218,8 +218,7 @@ extern int z_erofs_vle_plain_copy(struct page **compressed_pages,
21466 -
21467 - extern int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
21468 - unsigned clusterpages, struct page **pages,
21469 -- unsigned outlen, unsigned short pageofs,
21470 -- void (*endio)(struct page *));
21471 -+ unsigned int outlen, unsigned short pageofs);
21472 -
21473 - extern int z_erofs_vle_unzip_vmap(struct page **compressed_pages,
21474 - unsigned clusterpages, void *vaddr, unsigned llen,
21475 -diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c
21476 -index 52797bd89da1..3e8b0ff2efeb 100644
21477 ---- a/drivers/staging/erofs/unzip_vle_lz4.c
21478 -+++ b/drivers/staging/erofs/unzip_vle_lz4.c
21479 -@@ -125,8 +125,7 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
21480 - unsigned int clusterpages,
21481 - struct page **pages,
21482 - unsigned int outlen,
21483 -- unsigned short pageofs,
21484 -- void (*endio)(struct page *))
21485 -+ unsigned short pageofs)
21486 - {
21487 - void *vin, *vout;
21488 - unsigned int nr_pages, i, j;
21489 -@@ -137,10 +136,13 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
21490 -
21491 - nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE);
21492 -
21493 -- if (clusterpages == 1)
21494 -+ if (clusterpages == 1) {
21495 - vin = kmap_atomic(compressed_pages[0]);
21496 -- else
21497 -+ } else {
21498 - vin = erofs_vmap(compressed_pages, clusterpages);
21499 -+ if (!vin)
21500 -+ return -ENOMEM;
21501 -+ }
21502 -
21503 - preempt_disable();
21504 - vout = erofs_pcpubuf[smp_processor_id()].data;
21505 -@@ -148,19 +150,16 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
21506 - ret = z_erofs_unzip_lz4(vin, vout + pageofs,
21507 - clusterpages * PAGE_SIZE, outlen);
21508 -
21509 -- if (ret >= 0) {
21510 -- outlen = ret;
21511 -- ret = 0;
21512 -- }
21513 -+ if (ret < 0)
21514 -+ goto out;
21515 -+ ret = 0;
21516 -
21517 - for (i = 0; i < nr_pages; ++i) {
21518 - j = min((unsigned int)PAGE_SIZE - pageofs, outlen);
21519 -
21520 - if (pages[i]) {
21521 -- if (ret < 0) {
21522 -- SetPageError(pages[i]);
21523 -- } else if (clusterpages == 1 &&
21524 -- pages[i] == compressed_pages[0]) {
21525 -+ if (clusterpages == 1 &&
21526 -+ pages[i] == compressed_pages[0]) {
21527 - memcpy(vin + pageofs, vout + pageofs, j);
21528 - } else {
21529 - void *dst = kmap_atomic(pages[i]);
21530 -@@ -168,12 +167,13 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
21531 - memcpy(dst + pageofs, vout + pageofs, j);
21532 - kunmap_atomic(dst);
21533 - }
21534 -- endio(pages[i]);
21535 - }
21536 - vout += PAGE_SIZE;
21537 - outlen -= j;
21538 - pageofs = 0;
21539 - }
21540 -+
21541 -+out:
21542 - preempt_enable();
21543 -
21544 - if (clusterpages == 1)
21545 -diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
21546 -index 80dca6a4adbe..6cb05ae31233 100644
21547 ---- a/drivers/staging/erofs/xattr.c
21548 -+++ b/drivers/staging/erofs/xattr.c
21549 -@@ -44,19 +44,48 @@ static inline void xattr_iter_end_final(struct xattr_iter *it)
21550 -
21551 - static int init_inode_xattrs(struct inode *inode)
21552 - {
21553 -+ struct erofs_vnode *const vi = EROFS_V(inode);
21554 - struct xattr_iter it;
21555 - unsigned int i;
21556 - struct erofs_xattr_ibody_header *ih;
21557 - struct super_block *sb;
21558 - struct erofs_sb_info *sbi;
21559 -- struct erofs_vnode *vi;
21560 - bool atomic_map;
21561 -+ int ret = 0;
21562 -
21563 -- if (likely(inode_has_inited_xattr(inode)))
21564 -+ /* the most case is that xattrs of this inode are initialized. */
21565 -+ if (test_bit(EROFS_V_EA_INITED_BIT, &vi->flags))
21566 - return 0;
21567 -
21568 -- vi = EROFS_V(inode);
21569 -- BUG_ON(!vi->xattr_isize);
21570 -+ if (wait_on_bit_lock(&vi->flags, EROFS_V_BL_XATTR_BIT, TASK_KILLABLE))
21571 -+ return -ERESTARTSYS;
21572 -+
21573 -+ /* someone has initialized xattrs for us? */
21574 -+ if (test_bit(EROFS_V_EA_INITED_BIT, &vi->flags))
21575 -+ goto out_unlock;
21576 -+
21577 -+ /*
21578 -+ * bypass all xattr operations if ->xattr_isize is not greater than
21579 -+ * sizeof(struct erofs_xattr_ibody_header), in detail:
21580 -+ * 1) it is not enough to contain erofs_xattr_ibody_header then
21581 -+ * ->xattr_isize should be 0 (it means no xattr);
21582 -+ * 2) it is just to contain erofs_xattr_ibody_header, which is on-disk
21583 -+ * undefined right now (maybe use later with some new sb feature).
21584 -+ */
21585 -+ if (vi->xattr_isize == sizeof(struct erofs_xattr_ibody_header)) {
21586 -+ errln("xattr_isize %d of nid %llu is not supported yet",
21587 -+ vi->xattr_isize, vi->nid);
21588 -+ ret = -ENOTSUPP;
21589 -+ goto out_unlock;
21590 -+ } else if (vi->xattr_isize < sizeof(struct erofs_xattr_ibody_header)) {
21591 -+ if (unlikely(vi->xattr_isize)) {
21592 -+ DBG_BUGON(1);
21593 -+ ret = -EIO;
21594 -+ goto out_unlock; /* xattr ondisk layout error */
21595 -+ }
21596 -+ ret = -ENOATTR;
21597 -+ goto out_unlock;
21598 -+ }
21599 -
21600 - sb = inode->i_sb;
21601 - sbi = EROFS_SB(sb);
21602 -@@ -64,8 +93,10 @@ static int init_inode_xattrs(struct inode *inode)
21603 - it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
21604 -
21605 - it.page = erofs_get_inline_page(inode, it.blkaddr);
21606 -- if (IS_ERR(it.page))
21607 -- return PTR_ERR(it.page);
21608 -+ if (IS_ERR(it.page)) {
21609 -+ ret = PTR_ERR(it.page);
21610 -+ goto out_unlock;
21611 -+ }
21612 -
21613 - /* read in shared xattr array (non-atomic, see kmalloc below) */
21614 - it.kaddr = kmap(it.page);
21615 -@@ -78,7 +109,8 @@ static int init_inode_xattrs(struct inode *inode)
21616 - sizeof(uint), GFP_KERNEL);
21617 - if (vi->xattr_shared_xattrs == NULL) {
21618 - xattr_iter_end(&it, atomic_map);
21619 -- return -ENOMEM;
21620 -+ ret = -ENOMEM;
21621 -+ goto out_unlock;
21622 - }
21623 -
21624 - /* let's skip ibody header */
21625 -@@ -92,8 +124,12 @@ static int init_inode_xattrs(struct inode *inode)
21626 -
21627 - it.page = erofs_get_meta_page(sb,
21628 - ++it.blkaddr, S_ISDIR(inode->i_mode));
21629 -- if (IS_ERR(it.page))
21630 -- return PTR_ERR(it.page);
21631 -+ if (IS_ERR(it.page)) {
21632 -+ kfree(vi->xattr_shared_xattrs);
21633 -+ vi->xattr_shared_xattrs = NULL;
21634 -+ ret = PTR_ERR(it.page);
21635 -+ goto out_unlock;
21636 -+ }
21637 -
21638 - it.kaddr = kmap_atomic(it.page);
21639 - atomic_map = true;
21640 -@@ -105,8 +141,11 @@ static int init_inode_xattrs(struct inode *inode)
21641 - }
21642 - xattr_iter_end(&it, atomic_map);
21643 -
21644 -- inode_set_inited_xattr(inode);
21645 -- return 0;
21646 -+ set_bit(EROFS_V_EA_INITED_BIT, &vi->flags);
21647 -+
21648 -+out_unlock:
21649 -+ clear_and_wake_up_bit(EROFS_V_BL_XATTR_BIT, &vi->flags);
21650 -+ return ret;
21651 - }
21652 -
21653 - /*
21654 -@@ -422,7 +461,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
21655 - struct dentry *unused, struct inode *inode,
21656 - const char *name, void *buffer, size_t size)
21657 - {
21658 -- struct erofs_vnode *const vi = EROFS_V(inode);
21659 - struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
21660 -
21661 - switch (handler->flags) {
21662 -@@ -440,9 +478,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
21663 - return -EINVAL;
21664 - }
21665 -
21666 -- if (!vi->xattr_isize)
21667 -- return -ENOATTR;
21668 --
21669 - return erofs_getxattr(inode, handler->flags, name, buffer, size);
21670 - }
21671 -
21672 -diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
21673 -index dc93e85808e0..7839d869d25d 100644
21674 ---- a/drivers/staging/iio/addac/adt7316.c
21675 -+++ b/drivers/staging/iio/addac/adt7316.c
21676 -@@ -651,17 +651,10 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev,
21677 - u8 config3;
21678 - int ret;
21679 -
21680 -- chip->dac_bits = 8;
21681 --
21682 -- if (buf[0] == '1') {
21683 -+ if (buf[0] == '1')
21684 - config3 = chip->config3 | ADT7316_DA_HIGH_RESOLUTION;
21685 -- if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516)
21686 -- chip->dac_bits = 12;
21687 -- else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517)
21688 -- chip->dac_bits = 10;
21689 -- } else {
21690 -+ else
21691 - config3 = chip->config3 & (~ADT7316_DA_HIGH_RESOLUTION);
21692 -- }
21693 -
21694 - ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, config3);
21695 - if (ret)
21696 -@@ -2123,6 +2116,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
21697 - else
21698 - return -ENODEV;
21699 -
21700 -+ if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516)
21701 -+ chip->dac_bits = 12;
21702 -+ else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517)
21703 -+ chip->dac_bits = 10;
21704 -+ else
21705 -+ chip->dac_bits = 8;
21706 -+
21707 - chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", GPIOD_OUT_LOW);
21708 - if (IS_ERR(chip->ldac_pin)) {
21709 - ret = PTR_ERR(chip->ldac_pin);
21710 -diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
21711 -index 28f41caba05d..fb442499f806 100644
21712 ---- a/drivers/staging/media/imx/imx-ic-prpencvf.c
21713 -+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
21714 -@@ -680,12 +680,23 @@ static int prp_start(struct prp_priv *priv)
21715 - goto out_free_nfb4eof_irq;
21716 - }
21717 -
21718 -+ /* start upstream */
21719 -+ ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 1);
21720 -+ ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0;
21721 -+ if (ret) {
21722 -+ v4l2_err(&ic_priv->sd,
21723 -+ "upstream stream on failed: %d\n", ret);
21724 -+ goto out_free_eof_irq;
21725 -+ }
21726 -+
21727 - /* start the EOF timeout timer */
21728 - mod_timer(&priv->eof_timeout_timer,
21729 - jiffies + msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT));
21730 -
21731 - return 0;
21732 -
21733 -+out_free_eof_irq:
21734 -+ devm_free_irq(ic_priv->dev, priv->eof_irq, priv);
21735 - out_free_nfb4eof_irq:
21736 - devm_free_irq(ic_priv->dev, priv->nfb4eof_irq, priv);
21737 - out_unsetup:
21738 -@@ -717,6 +728,12 @@ static void prp_stop(struct prp_priv *priv)
21739 - if (ret == 0)
21740 - v4l2_warn(&ic_priv->sd, "wait last EOF timeout\n");
21741 -
21742 -+ /* stop upstream */
21743 -+ ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
21744 -+ if (ret && ret != -ENOIOCTLCMD)
21745 -+ v4l2_warn(&ic_priv->sd,
21746 -+ "upstream stream off failed: %d\n", ret);
21747 -+
21748 - devm_free_irq(ic_priv->dev, priv->eof_irq, priv);
21749 - devm_free_irq(ic_priv->dev, priv->nfb4eof_irq, priv);
21750 -
21751 -@@ -1148,15 +1165,6 @@ static int prp_s_stream(struct v4l2_subdev *sd, int enable)
21752 - if (ret)
21753 - goto out;
21754 -
21755 -- /* start/stop upstream */
21756 -- ret = v4l2_subdev_call(priv->src_sd, video, s_stream, enable);
21757 -- ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0;
21758 -- if (ret) {
21759 -- if (enable)
21760 -- prp_stop(priv);
21761 -- goto out;
21762 -- }
21763 --
21764 - update_count:
21765 - priv->stream_count += enable ? 1 : -1;
21766 - if (priv->stream_count < 0)
21767 -diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
21768 -index 4223f8d418ae..be1e9e52b2a0 100644
21769 ---- a/drivers/staging/media/imx/imx-media-csi.c
21770 -+++ b/drivers/staging/media/imx/imx-media-csi.c
21771 -@@ -629,7 +629,7 @@ out_put_ipu:
21772 - return ret;
21773 - }
21774 -
21775 --static void csi_idmac_stop(struct csi_priv *priv)
21776 -+static void csi_idmac_wait_last_eof(struct csi_priv *priv)
21777 - {
21778 - unsigned long flags;
21779 - int ret;
21780 -@@ -646,7 +646,10 @@ static void csi_idmac_stop(struct csi_priv *priv)
21781 - &priv->last_eof_comp, msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT));
21782 - if (ret == 0)
21783 - v4l2_warn(&priv->sd, "wait last EOF timeout\n");
21784 -+}
21785 -
21786 -+static void csi_idmac_stop(struct csi_priv *priv)
21787 -+{
21788 - devm_free_irq(priv->dev, priv->eof_irq, priv);
21789 - devm_free_irq(priv->dev, priv->nfb4eof_irq, priv);
21790 -
21791 -@@ -722,10 +725,16 @@ static int csi_start(struct csi_priv *priv)
21792 -
21793 - output_fi = &priv->frame_interval[priv->active_output_pad];
21794 -
21795 -+ /* start upstream */
21796 -+ ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 1);
21797 -+ ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0;
21798 -+ if (ret)
21799 -+ return ret;
21800 -+
21801 - if (priv->dest == IPU_CSI_DEST_IDMAC) {
21802 - ret = csi_idmac_start(priv);
21803 - if (ret)
21804 -- return ret;
21805 -+ goto stop_upstream;
21806 - }
21807 -
21808 - ret = csi_setup(priv);
21809 -@@ -753,11 +762,26 @@ fim_off:
21810 - idmac_stop:
21811 - if (priv->dest == IPU_CSI_DEST_IDMAC)
21812 - csi_idmac_stop(priv);
21813 -+stop_upstream:
21814 -+ v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
21815 - return ret;
21816 - }
21817 -
21818 - static void csi_stop(struct csi_priv *priv)
21819 - {
21820 -+ if (priv->dest == IPU_CSI_DEST_IDMAC)
21821 -+ csi_idmac_wait_last_eof(priv);
21822 -+
21823 -+ /*
21824 -+ * Disable the CSI asap, after syncing with the last EOF.
21825 -+ * Doing so after the IDMA channel is disabled has shown to
21826 -+ * create hard system-wide hangs.
21827 -+ */
21828 -+ ipu_csi_disable(priv->csi);
21829 -+
21830 -+ /* stop upstream */
21831 -+ v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
21832 -+
21833 - if (priv->dest == IPU_CSI_DEST_IDMAC) {
21834 - csi_idmac_stop(priv);
21835 -
21836 -@@ -765,8 +789,6 @@ static void csi_stop(struct csi_priv *priv)
21837 - if (priv->fim)
21838 - imx_media_fim_set_stream(priv->fim, NULL, false);
21839 - }
21840 --
21841 -- ipu_csi_disable(priv->csi);
21842 - }
21843 -
21844 - static const struct csi_skip_desc csi_skip[12] = {
21845 -@@ -927,23 +949,13 @@ static int csi_s_stream(struct v4l2_subdev *sd, int enable)
21846 - goto update_count;
21847 -
21848 - if (enable) {
21849 -- /* upstream must be started first, before starting CSI */
21850 -- ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 1);
21851 -- ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0;
21852 -- if (ret)
21853 -- goto out;
21854 --
21855 - dev_dbg(priv->dev, "stream ON\n");
21856 - ret = csi_start(priv);
21857 -- if (ret) {
21858 -- v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
21859 -+ if (ret)
21860 - goto out;
21861 -- }
21862 - } else {
21863 - dev_dbg(priv->dev, "stream OFF\n");
21864 -- /* CSI must be stopped first, then stop upstream */
21865 - csi_stop(priv);
21866 -- v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
21867 - }
21868 -
21869 - update_count:
21870 -@@ -1787,7 +1799,7 @@ static int imx_csi_parse_endpoint(struct device *dev,
21871 - struct v4l2_fwnode_endpoint *vep,
21872 - struct v4l2_async_subdev *asd)
21873 - {
21874 -- return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
21875 -+ return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
21876 - }
21877 -
21878 - static int imx_csi_async_register(struct csi_priv *priv)
21879 -diff --git a/drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c b/drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c
21880 -index 5282236d1bb1..06daea66fb49 100644
21881 ---- a/drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c
21882 -+++ b/drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c
21883 -@@ -80,7 +80,7 @@ rk3288_vpu_jpeg_enc_set_qtable(struct rockchip_vpu_dev *vpu,
21884 - void rk3288_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21885 - {
21886 - struct rockchip_vpu_dev *vpu = ctx->dev;
21887 -- struct vb2_buffer *src_buf, *dst_buf;
21888 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
21889 - struct rockchip_vpu_jpeg_ctx jpeg_ctx;
21890 - u32 reg;
21891 -
21892 -@@ -88,7 +88,7 @@ void rk3288_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21893 - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
21894 -
21895 - memset(&jpeg_ctx, 0, sizeof(jpeg_ctx));
21896 -- jpeg_ctx.buffer = vb2_plane_vaddr(dst_buf, 0);
21897 -+ jpeg_ctx.buffer = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
21898 - jpeg_ctx.width = ctx->dst_fmt.width;
21899 - jpeg_ctx.height = ctx->dst_fmt.height;
21900 - jpeg_ctx.quality = ctx->jpeg_quality;
21901 -@@ -99,7 +99,7 @@ void rk3288_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21902 - VEPU_REG_ENC_CTRL);
21903 -
21904 - rk3288_vpu_set_src_img_ctrl(vpu, ctx);
21905 -- rk3288_vpu_jpeg_enc_set_buffers(vpu, ctx, src_buf);
21906 -+ rk3288_vpu_jpeg_enc_set_buffers(vpu, ctx, &src_buf->vb2_buf);
21907 - rk3288_vpu_jpeg_enc_set_qtable(vpu,
21908 - rockchip_vpu_jpeg_get_qtable(&jpeg_ctx, 0),
21909 - rockchip_vpu_jpeg_get_qtable(&jpeg_ctx, 1));
21910 -diff --git a/drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c b/drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c
21911 -index dbc86d95fe3b..3d438797692e 100644
21912 ---- a/drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c
21913 -+++ b/drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c
21914 -@@ -111,7 +111,7 @@ rk3399_vpu_jpeg_enc_set_qtable(struct rockchip_vpu_dev *vpu,
21915 - void rk3399_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21916 - {
21917 - struct rockchip_vpu_dev *vpu = ctx->dev;
21918 -- struct vb2_buffer *src_buf, *dst_buf;
21919 -+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
21920 - struct rockchip_vpu_jpeg_ctx jpeg_ctx;
21921 - u32 reg;
21922 -
21923 -@@ -119,7 +119,7 @@ void rk3399_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21924 - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
21925 -
21926 - memset(&jpeg_ctx, 0, sizeof(jpeg_ctx));
21927 -- jpeg_ctx.buffer = vb2_plane_vaddr(dst_buf, 0);
21928 -+ jpeg_ctx.buffer = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
21929 - jpeg_ctx.width = ctx->dst_fmt.width;
21930 - jpeg_ctx.height = ctx->dst_fmt.height;
21931 - jpeg_ctx.quality = ctx->jpeg_quality;
21932 -@@ -130,7 +130,7 @@ void rk3399_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx)
21933 - VEPU_REG_ENCODE_START);
21934 -
21935 - rk3399_vpu_set_src_img_ctrl(vpu, ctx);
21936 -- rk3399_vpu_jpeg_enc_set_buffers(vpu, ctx, src_buf);
21937 -+ rk3399_vpu_jpeg_enc_set_buffers(vpu, ctx, &src_buf->vb2_buf);
21938 - rk3399_vpu_jpeg_enc_set_qtable(vpu,
21939 - rockchip_vpu_jpeg_get_qtable(&jpeg_ctx, 0),
21940 - rockchip_vpu_jpeg_get_qtable(&jpeg_ctx, 1));
21941 -diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c
21942 -index 513b6e79b985..e1f50efd0922 100644
21943 ---- a/drivers/staging/mt7621-spi/spi-mt7621.c
21944 -+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
21945 -@@ -330,6 +330,7 @@ static int mt7621_spi_probe(struct platform_device *pdev)
21946 - int status = 0;
21947 - struct clk *clk;
21948 - struct mt7621_spi_ops *ops;
21949 -+ int ret;
21950 -
21951 - match = of_match_device(mt7621_spi_match, &pdev->dev);
21952 - if (!match)
21953 -@@ -377,7 +378,11 @@ static int mt7621_spi_probe(struct platform_device *pdev)
21954 - rs->pending_write = 0;
21955 - dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq);
21956 -
21957 -- device_reset(&pdev->dev);
21958 -+ ret = device_reset(&pdev->dev);
21959 -+ if (ret) {
21960 -+ dev_err(&pdev->dev, "SPI reset failed!\n");
21961 -+ return ret;
21962 -+ }
21963 -
21964 - mt7621_spi_reset(rs);
21965 -
21966 -diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
21967 -index 80b8d4153414..a54286498a47 100644
21968 ---- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
21969 -+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
21970 -@@ -45,7 +45,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon)
21971 - {
21972 - unsigned char lob;
21973 - int ret, i;
21974 -- struct dcon_gpio *pin = &gpios_asis[0];
21975 -+ const struct dcon_gpio *pin = &gpios_asis[0];
21976 -
21977 - for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) {
21978 - gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name,
21979 -diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
21980 -index 947c79532e10..d5383974d40e 100644
21981 ---- a/drivers/staging/speakup/speakup_soft.c
21982 -+++ b/drivers/staging/speakup/speakup_soft.c
21983 -@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
21984 - return -EINVAL;
21985 -
21986 - spin_lock_irqsave(&speakup_info.spinlock, flags);
21987 -+ synth_soft.alive = 1;
21988 - while (1) {
21989 - prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
21990 -- if (!unicode)
21991 -- synth_buffer_skip_nonlatin1();
21992 -- if (!synth_buffer_empty() || speakup_info.flushing)
21993 -- break;
21994 -+ if (synth_current() == &synth_soft) {
21995 -+ if (!unicode)
21996 -+ synth_buffer_skip_nonlatin1();
21997 -+ if (!synth_buffer_empty() || speakup_info.flushing)
21998 -+ break;
21999 -+ }
22000 - spin_unlock_irqrestore(&speakup_info.spinlock, flags);
22001 - if (fp->f_flags & O_NONBLOCK) {
22002 - finish_wait(&speakup_event, &wait);
22003 -@@ -233,6 +236,8 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
22004 -
22005 - /* Keep 3 bytes available for a 16bit UTF-8-encoded character */
22006 - while (chars_sent <= count - bytes_per_ch) {
22007 -+ if (synth_current() != &synth_soft)
22008 -+ break;
22009 - if (speakup_info.flushing) {
22010 - speakup_info.flushing = 0;
22011 - ch = '\x18';
22012 -@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct file *fp, struct poll_table_struct *wait)
22013 - poll_wait(fp, &speakup_event, wait);
22014 -
22015 - spin_lock_irqsave(&speakup_info.spinlock, flags);
22016 -- if (!synth_buffer_empty() || speakup_info.flushing)
22017 -+ if (synth_current() == &synth_soft &&
22018 -+ (!synth_buffer_empty() || speakup_info.flushing))
22019 - ret = EPOLLIN | EPOLLRDNORM;
22020 - spin_unlock_irqrestore(&speakup_info.spinlock, flags);
22021 - return ret;
22022 -diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h
22023 -index c8e688878fc7..ac6a74883af4 100644
22024 ---- a/drivers/staging/speakup/spk_priv.h
22025 -+++ b/drivers/staging/speakup/spk_priv.h
22026 -@@ -74,6 +74,7 @@ int synth_request_region(unsigned long start, unsigned long n);
22027 - int synth_release_region(unsigned long start, unsigned long n);
22028 - int synth_add(struct spk_synth *in_synth);
22029 - void synth_remove(struct spk_synth *in_synth);
22030 -+struct spk_synth *synth_current(void);
22031 -
22032 - extern struct speakup_info_t speakup_info;
22033 -
22034 -diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
22035 -index 25f259ee4ffc..3568bfb89912 100644
22036 ---- a/drivers/staging/speakup/synth.c
22037 -+++ b/drivers/staging/speakup/synth.c
22038 -@@ -481,4 +481,10 @@ void synth_remove(struct spk_synth *in_synth)
22039 - }
22040 - EXPORT_SYMBOL_GPL(synth_remove);
22041 -
22042 -+struct spk_synth *synth_current(void)
22043 -+{
22044 -+ return synth;
22045 -+}
22046 -+EXPORT_SYMBOL_GPL(synth_current);
22047 -+
22048 - short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };
22049 -diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
22050 -index c9097e7367d8..2e28fbcdfe8e 100644
22051 ---- a/drivers/staging/vt6655/device_main.c
22052 -+++ b/drivers/staging/vt6655/device_main.c
22053 -@@ -1033,8 +1033,6 @@ static void vnt_interrupt_process(struct vnt_private *priv)
22054 - return;
22055 - }
22056 -
22057 -- MACvIntDisable(priv->PortOffset);
22058 --
22059 - spin_lock_irqsave(&priv->lock, flags);
22060 -
22061 - /* Read low level stats */
22062 -@@ -1122,8 +1120,6 @@ static void vnt_interrupt_process(struct vnt_private *priv)
22063 - }
22064 -
22065 - spin_unlock_irqrestore(&priv->lock, flags);
22066 --
22067 -- MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
22068 - }
22069 -
22070 - static void vnt_interrupt_work(struct work_struct *work)
22071 -@@ -1133,14 +1129,17 @@ static void vnt_interrupt_work(struct work_struct *work)
22072 -
22073 - if (priv->vif)
22074 - vnt_interrupt_process(priv);
22075 -+
22076 -+ MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
22077 - }
22078 -
22079 - static irqreturn_t vnt_interrupt(int irq, void *arg)
22080 - {
22081 - struct vnt_private *priv = arg;
22082 -
22083 -- if (priv->vif)
22084 -- schedule_work(&priv->interrupt_work);
22085 -+ schedule_work(&priv->interrupt_work);
22086 -+
22087 -+ MACvIntDisable(priv->PortOffset);
22088 -
22089 - return IRQ_HANDLED;
22090 - }
22091 -diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
22092 -index 721689048648..5e5149c9a92d 100644
22093 ---- a/drivers/staging/wilc1000/linux_wlan.c
22094 -+++ b/drivers/staging/wilc1000/linux_wlan.c
22095 -@@ -1086,8 +1086,8 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
22096 - vif->wilc = *wilc;
22097 - vif->ndev = ndev;
22098 - wl->vif[i] = vif;
22099 -- wl->vif_num = i;
22100 -- vif->idx = wl->vif_num;
22101 -+ wl->vif_num = i + 1;
22102 -+ vif->idx = i;
22103 -
22104 - ndev->netdev_ops = &wilc_netdev_ops;
22105 -
22106 -diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
22107 -index bd15a564fe24..3ad2659630e8 100644
22108 ---- a/drivers/target/iscsi/iscsi_target.c
22109 -+++ b/drivers/target/iscsi/iscsi_target.c
22110 -@@ -4040,9 +4040,9 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
22111 - struct se_cmd *se_cmd = &cmd->se_cmd;
22112 -
22113 - if (se_cmd->se_tfo != NULL) {
22114 -- spin_lock(&se_cmd->t_state_lock);
22115 -+ spin_lock_irq(&se_cmd->t_state_lock);
22116 - se_cmd->transport_state |= CMD_T_FABRIC_STOP;
22117 -- spin_unlock(&se_cmd->t_state_lock);
22118 -+ spin_unlock_irq(&se_cmd->t_state_lock);
22119 - }
22120 - }
22121 - spin_unlock_bh(&conn->cmd_lock);
22122 -diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
22123 -index 0840d27381ea..e0a04bfc873e 100644
22124 ---- a/drivers/tty/Kconfig
22125 -+++ b/drivers/tty/Kconfig
22126 -@@ -441,4 +441,28 @@ config VCC
22127 - depends on SUN_LDOMS
22128 - help
22129 - Support for Sun logical domain consoles.
22130 -+
22131 -+config LDISC_AUTOLOAD
22132 -+ bool "Automatically load TTY Line Disciplines"
22133 -+ default y
22134 -+ help
22135 -+ Historically the kernel has always automatically loaded any
22136 -+ line discipline that is in a kernel module when a user asks
22137 -+ for it to be loaded with the TIOCSETD ioctl, or through other
22138 -+ means. This is not always the best thing to do on systems
22139 -+ where you know you will not be using some of the more
22140 -+ "ancient" line disciplines, so prevent the kernel from doing
22141 -+ this unless the request is coming from a process with the
22142 -+ CAP_SYS_MODULE permissions.
22143 -+
22144 -+ Say 'Y' here if you trust your userspace users to do the right
22145 -+ thing, or if you have only provided the line disciplines that
22146 -+ you know you will be using, or if you wish to continue to use
22147 -+ the traditional method of on-demand loading of these modules
22148 -+ by any user.
22149 -+
22150 -+ This functionality can be changed at runtime with the
22151 -+ dev.tty.ldisc_autoload sysctl, this configuration option will
22152 -+ only set the default value of this functionality.
22153 -+
22154 - endif # TTY
22155 -diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
22156 -index a1a85805d010..2488de1c4bc4 100644
22157 ---- a/drivers/tty/serial/8250/8250_of.c
22158 -+++ b/drivers/tty/serial/8250/8250_of.c
22159 -@@ -130,6 +130,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
22160 - port->flags |= UPF_IOREMAP;
22161 - }
22162 -
22163 -+ /* Compatibility with the deprecated pxa driver and 8250_pxa drivers. */
22164 -+ if (of_device_is_compatible(np, "mrvl,mmp-uart"))
22165 -+ port->regshift = 2;
22166 -+
22167 - /* Check for registers offset within the devices address range */
22168 - if (of_property_read_u32(np, "reg-shift", &prop) == 0)
22169 - port->regshift = prop;
22170 -diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
22171 -index 48bd694a5fa1..bbe5cba21522 100644
22172 ---- a/drivers/tty/serial/8250/8250_pci.c
22173 -+++ b/drivers/tty/serial/8250/8250_pci.c
22174 -@@ -2027,6 +2027,111 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
22175 - .setup = pci_default_setup,
22176 - .exit = pci_plx9050_exit,
22177 - },
22178 -+ {
22179 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22180 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB,
22181 -+ .subvendor = PCI_ANY_ID,
22182 -+ .subdevice = PCI_ANY_ID,
22183 -+ .setup = pci_pericom_setup,
22184 -+ },
22185 -+ {
22186 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22187 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S,
22188 -+ .subvendor = PCI_ANY_ID,
22189 -+ .subdevice = PCI_ANY_ID,
22190 -+ .setup = pci_pericom_setup,
22191 -+ },
22192 -+ {
22193 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22194 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB,
22195 -+ .subvendor = PCI_ANY_ID,
22196 -+ .subdevice = PCI_ANY_ID,
22197 -+ .setup = pci_pericom_setup,
22198 -+ },
22199 -+ {
22200 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22201 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4,
22202 -+ .subvendor = PCI_ANY_ID,
22203 -+ .subdevice = PCI_ANY_ID,
22204 -+ .setup = pci_pericom_setup,
22205 -+ },
22206 -+ {
22207 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22208 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB,
22209 -+ .subvendor = PCI_ANY_ID,
22210 -+ .subdevice = PCI_ANY_ID,
22211 -+ .setup = pci_pericom_setup,
22212 -+ },
22213 -+ {
22214 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22215 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM,
22216 -+ .subvendor = PCI_ANY_ID,
22217 -+ .subdevice = PCI_ANY_ID,
22218 -+ .setup = pci_pericom_setup,
22219 -+ },
22220 -+ {
22221 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22222 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4,
22223 -+ .subvendor = PCI_ANY_ID,
22224 -+ .subdevice = PCI_ANY_ID,
22225 -+ .setup = pci_pericom_setup,
22226 -+ },
22227 -+ {
22228 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22229 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4,
22230 -+ .subvendor = PCI_ANY_ID,
22231 -+ .subdevice = PCI_ANY_ID,
22232 -+ .setup = pci_pericom_setup,
22233 -+ },
22234 -+ {
22235 -+ .vendor = PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
22236 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4,
22237 -+ .subvendor = PCI_ANY_ID,
22238 -+ .subdevice = PCI_ANY_ID,
22239 -+ .setup = pci_pericom_setup,
22240 -+ },
22241 -+ {
22242 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22243 -+ .device = PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4,
22244 -+ .subvendor = PCI_ANY_ID,
22245 -+ .subdevice = PCI_ANY_ID,
22246 -+ .setup = pci_pericom_setup,
22247 -+ },
22248 -+ {
22249 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22250 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4,
22251 -+ .subvendor = PCI_ANY_ID,
22252 -+ .subdevice = PCI_ANY_ID,
22253 -+ .setup = pci_pericom_setup,
22254 -+ },
22255 -+ {
22256 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22257 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4,
22258 -+ .subvendor = PCI_ANY_ID,
22259 -+ .subdevice = PCI_ANY_ID,
22260 -+ .setup = pci_pericom_setup,
22261 -+ },
22262 -+ {
22263 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22264 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4,
22265 -+ .subvendor = PCI_ANY_ID,
22266 -+ .subdevice = PCI_ANY_ID,
22267 -+ .setup = pci_pericom_setup,
22268 -+ },
22269 -+ {
22270 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22271 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM,
22272 -+ .subvendor = PCI_ANY_ID,
22273 -+ .subdevice = PCI_ANY_ID,
22274 -+ .setup = pci_pericom_setup,
22275 -+ },
22276 -+ {
22277 -+ .vendor = PCI_VENDOR_ID_ACCESIO,
22278 -+ .device = PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM,
22279 -+ .subvendor = PCI_ANY_ID,
22280 -+ .subdevice = PCI_ANY_ID,
22281 -+ .setup = pci_pericom_setup,
22282 -+ },
22283 - /*
22284 - * SBS Technologies, Inc., PMC-OCTALPRO 232
22285 - */
22286 -@@ -4575,10 +4680,10 @@ static const struct pci_device_id serial_pci_tbl[] = {
22287 - */
22288 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB,
22289 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22290 -- pbn_pericom_PI7C9X7954 },
22291 -+ pbn_pericom_PI7C9X7952 },
22292 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S,
22293 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22294 -- pbn_pericom_PI7C9X7954 },
22295 -+ pbn_pericom_PI7C9X7952 },
22296 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB,
22297 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22298 - pbn_pericom_PI7C9X7954 },
22299 -@@ -4587,10 +4692,10 @@ static const struct pci_device_id serial_pci_tbl[] = {
22300 - pbn_pericom_PI7C9X7954 },
22301 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB,
22302 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22303 -- pbn_pericom_PI7C9X7954 },
22304 -+ pbn_pericom_PI7C9X7952 },
22305 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2,
22306 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22307 -- pbn_pericom_PI7C9X7954 },
22308 -+ pbn_pericom_PI7C9X7952 },
22309 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB,
22310 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22311 - pbn_pericom_PI7C9X7954 },
22312 -@@ -4599,10 +4704,10 @@ static const struct pci_device_id serial_pci_tbl[] = {
22313 - pbn_pericom_PI7C9X7954 },
22314 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB,
22315 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22316 -- pbn_pericom_PI7C9X7954 },
22317 -+ pbn_pericom_PI7C9X7952 },
22318 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM,
22319 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22320 -- pbn_pericom_PI7C9X7954 },
22321 -+ pbn_pericom_PI7C9X7952 },
22322 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB,
22323 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22324 - pbn_pericom_PI7C9X7954 },
22325 -@@ -4611,13 +4716,13 @@ static const struct pci_device_id serial_pci_tbl[] = {
22326 - pbn_pericom_PI7C9X7954 },
22327 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1,
22328 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22329 -- pbn_pericom_PI7C9X7954 },
22330 -+ pbn_pericom_PI7C9X7951 },
22331 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2,
22332 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22333 -- pbn_pericom_PI7C9X7954 },
22334 -+ pbn_pericom_PI7C9X7952 },
22335 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2,
22336 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22337 -- pbn_pericom_PI7C9X7954 },
22338 -+ pbn_pericom_PI7C9X7952 },
22339 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4,
22340 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22341 - pbn_pericom_PI7C9X7954 },
22342 -@@ -4626,16 +4731,16 @@ static const struct pci_device_id serial_pci_tbl[] = {
22343 - pbn_pericom_PI7C9X7954 },
22344 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S,
22345 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22346 -- pbn_pericom_PI7C9X7954 },
22347 -+ pbn_pericom_PI7C9X7952 },
22348 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
22349 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22350 - pbn_pericom_PI7C9X7954 },
22351 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2,
22352 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22353 -- pbn_pericom_PI7C9X7954 },
22354 -+ pbn_pericom_PI7C9X7952 },
22355 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2,
22356 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22357 -- pbn_pericom_PI7C9X7954 },
22358 -+ pbn_pericom_PI7C9X7952 },
22359 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4,
22360 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22361 - pbn_pericom_PI7C9X7954 },
22362 -@@ -4644,13 +4749,13 @@ static const struct pci_device_id serial_pci_tbl[] = {
22363 - pbn_pericom_PI7C9X7954 },
22364 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM,
22365 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22366 -- pbn_pericom_PI7C9X7954 },
22367 -+ pbn_pericom_PI7C9X7952 },
22368 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4,
22369 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22370 -- pbn_pericom_PI7C9X7958 },
22371 -+ pbn_pericom_PI7C9X7954 },
22372 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4,
22373 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22374 -- pbn_pericom_PI7C9X7958 },
22375 -+ pbn_pericom_PI7C9X7954 },
22376 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8,
22377 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22378 - pbn_pericom_PI7C9X7958 },
22379 -@@ -4659,19 +4764,19 @@ static const struct pci_device_id serial_pci_tbl[] = {
22380 - pbn_pericom_PI7C9X7958 },
22381 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4,
22382 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22383 -- pbn_pericom_PI7C9X7958 },
22384 -+ pbn_pericom_PI7C9X7954 },
22385 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8,
22386 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22387 - pbn_pericom_PI7C9X7958 },
22388 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM,
22389 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22390 -- pbn_pericom_PI7C9X7958 },
22391 -+ pbn_pericom_PI7C9X7954 },
22392 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM,
22393 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22394 - pbn_pericom_PI7C9X7958 },
22395 - { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM,
22396 - PCI_ANY_ID, PCI_ANY_ID, 0, 0,
22397 -- pbn_pericom_PI7C9X7958 },
22398 -+ pbn_pericom_PI7C9X7954 },
22399 - /*
22400 - * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke)
22401 - */
22402 -diff --git a/drivers/tty/serial/8250/8250_pxa.c b/drivers/tty/serial/8250/8250_pxa.c
22403 -index b9bcbe20a2be..c47188860e32 100644
22404 ---- a/drivers/tty/serial/8250/8250_pxa.c
22405 -+++ b/drivers/tty/serial/8250/8250_pxa.c
22406 -@@ -113,6 +113,10 @@ static int serial_pxa_probe(struct platform_device *pdev)
22407 - if (ret)
22408 - return ret;
22409 -
22410 -+ ret = of_alias_get_id(pdev->dev.of_node, "serial");
22411 -+ if (ret >= 0)
22412 -+ uart.port.line = ret;
22413 -+
22414 - uart.port.type = PORT_XSCALE;
22415 - uart.port.iotype = UPIO_MEM32;
22416 - uart.port.mapbase = mmres->start;
22417 -diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
22418 -index 05147fe24343..0b4f36905321 100644
22419 ---- a/drivers/tty/serial/atmel_serial.c
22420 -+++ b/drivers/tty/serial/atmel_serial.c
22421 -@@ -166,6 +166,8 @@ struct atmel_uart_port {
22422 - unsigned int pending_status;
22423 - spinlock_t lock_suspended;
22424 -
22425 -+ bool hd_start_rx; /* can start RX during half-duplex operation */
22426 -+
22427 - /* ISO7816 */
22428 - unsigned int fidi_min;
22429 - unsigned int fidi_max;
22430 -@@ -231,6 +233,13 @@ static inline void atmel_uart_write_char(struct uart_port *port, u8 value)
22431 - __raw_writeb(value, port->membase + ATMEL_US_THR);
22432 - }
22433 -
22434 -+static inline int atmel_uart_is_half_duplex(struct uart_port *port)
22435 -+{
22436 -+ return ((port->rs485.flags & SER_RS485_ENABLED) &&
22437 -+ !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
22438 -+ (port->iso7816.flags & SER_ISO7816_ENABLED);
22439 -+}
22440 -+
22441 - #ifdef CONFIG_SERIAL_ATMEL_PDC
22442 - static bool atmel_use_pdc_rx(struct uart_port *port)
22443 - {
22444 -@@ -608,10 +617,9 @@ static void atmel_stop_tx(struct uart_port *port)
22445 - /* Disable interrupts */
22446 - atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
22447 -
22448 -- if (((port->rs485.flags & SER_RS485_ENABLED) &&
22449 -- !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
22450 -- port->iso7816.flags & SER_ISO7816_ENABLED)
22451 -+ if (atmel_uart_is_half_duplex(port))
22452 - atmel_start_rx(port);
22453 -+
22454 - }
22455 -
22456 - /*
22457 -@@ -628,9 +636,7 @@ static void atmel_start_tx(struct uart_port *port)
22458 - return;
22459 -
22460 - if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
22461 -- if (((port->rs485.flags & SER_RS485_ENABLED) &&
22462 -- !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
22463 -- port->iso7816.flags & SER_ISO7816_ENABLED)
22464 -+ if (atmel_uart_is_half_duplex(port))
22465 - atmel_stop_rx(port);
22466 -
22467 - if (atmel_use_pdc_tx(port))
22468 -@@ -928,11 +934,14 @@ static void atmel_complete_tx_dma(void *arg)
22469 - */
22470 - if (!uart_circ_empty(xmit))
22471 - atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
22472 -- else if (((port->rs485.flags & SER_RS485_ENABLED) &&
22473 -- !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
22474 -- port->iso7816.flags & SER_ISO7816_ENABLED) {
22475 -- /* DMA done, stop TX, start RX for RS485 */
22476 -- atmel_start_rx(port);
22477 -+ else if (atmel_uart_is_half_duplex(port)) {
22478 -+ /*
22479 -+ * DMA done, re-enable TXEMPTY and signal that we can stop
22480 -+ * TX and start RX for RS485
22481 -+ */
22482 -+ atmel_port->hd_start_rx = true;
22483 -+ atmel_uart_writel(port, ATMEL_US_IER,
22484 -+ atmel_port->tx_done_mask);
22485 - }
22486 -
22487 - spin_unlock_irqrestore(&port->lock, flags);
22488 -@@ -1288,6 +1297,10 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
22489 - sg_dma_len(&atmel_port->sg_rx)/2,
22490 - DMA_DEV_TO_MEM,
22491 - DMA_PREP_INTERRUPT);
22492 -+ if (!desc) {
22493 -+ dev_err(port->dev, "Preparing DMA cyclic failed\n");
22494 -+ goto chan_err;
22495 -+ }
22496 - desc->callback = atmel_complete_rx_dma;
22497 - desc->callback_param = port;
22498 - atmel_port->desc_rx = desc;
22499 -@@ -1376,9 +1389,20 @@ atmel_handle_transmit(struct uart_port *port, unsigned int pending)
22500 - struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
22501 -
22502 - if (pending & atmel_port->tx_done_mask) {
22503 -- /* Either PDC or interrupt transmission */
22504 - atmel_uart_writel(port, ATMEL_US_IDR,
22505 - atmel_port->tx_done_mask);
22506 -+
22507 -+ /* Start RX if flag was set and FIFO is empty */
22508 -+ if (atmel_port->hd_start_rx) {
22509 -+ if (!(atmel_uart_readl(port, ATMEL_US_CSR)
22510 -+ & ATMEL_US_TXEMPTY))
22511 -+ dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n");
22512 -+
22513 -+ atmel_port->hd_start_rx = false;
22514 -+ atmel_start_rx(port);
22515 -+ return;
22516 -+ }
22517 -+
22518 - atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
22519 - }
22520 - }
22521 -@@ -1508,9 +1532,7 @@ static void atmel_tx_pdc(struct uart_port *port)
22522 - atmel_uart_writel(port, ATMEL_US_IER,
22523 - atmel_port->tx_done_mask);
22524 - } else {
22525 -- if (((port->rs485.flags & SER_RS485_ENABLED) &&
22526 -- !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
22527 -- port->iso7816.flags & SER_ISO7816_ENABLED) {
22528 -+ if (atmel_uart_is_half_duplex(port)) {
22529 - /* DMA done, stop TX, start RX for RS485 */
22530 - atmel_start_rx(port);
22531 - }
22532 -diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
22533 -index 6fb312e7af71..bfe5e9e034ec 100644
22534 ---- a/drivers/tty/serial/kgdboc.c
22535 -+++ b/drivers/tty/serial/kgdboc.c
22536 -@@ -148,8 +148,10 @@ static int configure_kgdboc(void)
22537 - char *cptr = config;
22538 - struct console *cons;
22539 -
22540 -- if (!strlen(config) || isspace(config[0]))
22541 -+ if (!strlen(config) || isspace(config[0])) {
22542 -+ err = 0;
22543 - goto noconfig;
22544 -+ }
22545 -
22546 - kgdboc_io_ops.is_console = 0;
22547 - kgdb_tty_driver = NULL;
22548 -diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
22549 -index 4f479841769a..0fdf3a760aa0 100644
22550 ---- a/drivers/tty/serial/max310x.c
22551 -+++ b/drivers/tty/serial/max310x.c
22552 -@@ -1416,6 +1416,8 @@ static int max310x_spi_probe(struct spi_device *spi)
22553 - if (spi->dev.of_node) {
22554 - const struct of_device_id *of_id =
22555 - of_match_device(max310x_dt_ids, &spi->dev);
22556 -+ if (!of_id)
22557 -+ return -ENODEV;
22558 -
22559 - devtype = (struct max310x_devtype *)of_id->data;
22560 - } else {
22561 -diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
22562 -index 231f751d1ef4..7e7b1559fa36 100644
22563 ---- a/drivers/tty/serial/mvebu-uart.c
22564 -+++ b/drivers/tty/serial/mvebu-uart.c
22565 -@@ -810,6 +810,9 @@ static int mvebu_uart_probe(struct platform_device *pdev)
22566 - return -EINVAL;
22567 - }
22568 -
22569 -+ if (!match)
22570 -+ return -ENODEV;
22571 -+
22572 - /* Assume that all UART ports have a DT alias or none has */
22573 - id = of_alias_get_id(pdev->dev.of_node, "serial");
22574 - if (!pdev->dev.of_node || id < 0)
22575 -diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
22576 -index 27235a526cce..4c188f4079b3 100644
22577 ---- a/drivers/tty/serial/mxs-auart.c
22578 -+++ b/drivers/tty/serial/mxs-auart.c
22579 -@@ -1686,6 +1686,10 @@ static int mxs_auart_probe(struct platform_device *pdev)
22580 -
22581 - s->port.mapbase = r->start;
22582 - s->port.membase = ioremap(r->start, resource_size(r));
22583 -+ if (!s->port.membase) {
22584 -+ ret = -ENOMEM;
22585 -+ goto out_disable_clks;
22586 -+ }
22587 - s->port.ops = &mxs_auart_ops;
22588 - s->port.iotype = UPIO_MEM;
22589 - s->port.fifosize = MXS_AUART_FIFO_SIZE;
22590 -diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
22591 -index 38016609c7fa..d30502c58106 100644
22592 ---- a/drivers/tty/serial/qcom_geni_serial.c
22593 -+++ b/drivers/tty/serial/qcom_geni_serial.c
22594 -@@ -1117,7 +1117,7 @@ static int __init qcom_geni_console_setup(struct console *co, char *options)
22595 - {
22596 - struct uart_port *uport;
22597 - struct qcom_geni_serial_port *port;
22598 -- int baud;
22599 -+ int baud = 9600;
22600 - int bits = 8;
22601 - int parity = 'n';
22602 - int flow = 'n';
22603 -diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
22604 -index 64bbeb7d7e0c..93bd90f1ff14 100644
22605 ---- a/drivers/tty/serial/sh-sci.c
22606 -+++ b/drivers/tty/serial/sh-sci.c
22607 -@@ -838,19 +838,9 @@ static void sci_transmit_chars(struct uart_port *port)
22608 -
22609 - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
22610 - uart_write_wakeup(port);
22611 -- if (uart_circ_empty(xmit)) {
22612 -+ if (uart_circ_empty(xmit))
22613 - sci_stop_tx(port);
22614 -- } else {
22615 -- ctrl = serial_port_in(port, SCSCR);
22616 --
22617 -- if (port->type != PORT_SCI) {
22618 -- serial_port_in(port, SCxSR); /* Dummy read */
22619 -- sci_clear_SCxSR(port, SCxSR_TDxE_CLEAR(port));
22620 -- }
22621 -
22622 -- ctrl |= SCSCR_TIE;
22623 -- serial_port_out(port, SCSCR, ctrl);
22624 -- }
22625 - }
22626 -
22627 - /* On SH3, SCIF may read end-of-break as a space->mark char */
22628 -diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
22629 -index 094f2958cb2b..ee9f18c52d29 100644
22630 ---- a/drivers/tty/serial/xilinx_uartps.c
22631 -+++ b/drivers/tty/serial/xilinx_uartps.c
22632 -@@ -364,7 +364,13 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)
22633 - cdns_uart_handle_tx(dev_id);
22634 - isrstatus &= ~CDNS_UART_IXR_TXEMPTY;
22635 - }
22636 -- if (isrstatus & CDNS_UART_IXR_RXMASK)
22637 -+
22638 -+ /*
22639 -+ * Skip RX processing if RX is disabled as RXEMPTY will never be set
22640 -+ * as read bytes will not be removed from the FIFO.
22641 -+ */
22642 -+ if (isrstatus & CDNS_UART_IXR_RXMASK &&
22643 -+ !(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS))
22644 - cdns_uart_handle_rx(dev_id, isrstatus);
22645 -
22646 - spin_unlock(&port->lock);
22647 -diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
22648 -index 77070c2d1240..ec145a59f199 100644
22649 ---- a/drivers/tty/tty_buffer.c
22650 -+++ b/drivers/tty/tty_buffer.c
22651 -@@ -26,7 +26,7 @@
22652 - * Byte threshold to limit memory consumption for flip buffers.
22653 - * The actual memory limit is > 2x this amount.
22654 - */
22655 --#define TTYB_DEFAULT_MEM_LIMIT 65536
22656 -+#define TTYB_DEFAULT_MEM_LIMIT (640 * 1024UL)
22657 -
22658 - /*
22659 - * We default to dicing tty buffer allocations to this many characters
22660 -diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
22661 -index 21ffcce16927..5fa250157025 100644
22662 ---- a/drivers/tty/tty_io.c
22663 -+++ b/drivers/tty/tty_io.c
22664 -@@ -513,6 +513,8 @@ static const struct file_operations hung_up_tty_fops = {
22665 - static DEFINE_SPINLOCK(redirect_lock);
22666 - static struct file *redirect;
22667 -
22668 -+extern void tty_sysctl_init(void);
22669 -+
22670 - /**
22671 - * tty_wakeup - request more data
22672 - * @tty: terminal
22673 -@@ -3483,6 +3485,7 @@ void console_sysfs_notify(void)
22674 - */
22675 - int __init tty_init(void)
22676 - {
22677 -+ tty_sysctl_init();
22678 - cdev_init(&tty_cdev, &tty_fops);
22679 - if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
22680 - register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
22681 -diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
22682 -index 45eda69b150c..e38f104db174 100644
22683 ---- a/drivers/tty/tty_ldisc.c
22684 -+++ b/drivers/tty/tty_ldisc.c
22685 -@@ -156,6 +156,13 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
22686 - * takes tty_ldiscs_lock to guard against ldisc races
22687 - */
22688 -
22689 -+#if defined(CONFIG_LDISC_AUTOLOAD)
22690 -+ #define INITIAL_AUTOLOAD_STATE 1
22691 -+#else
22692 -+ #define INITIAL_AUTOLOAD_STATE 0
22693 -+#endif
22694 -+static int tty_ldisc_autoload = INITIAL_AUTOLOAD_STATE;
22695 -+
22696 - static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
22697 - {
22698 - struct tty_ldisc *ld;
22699 -@@ -170,6 +177,8 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
22700 - */
22701 - ldops = get_ldops(disc);
22702 - if (IS_ERR(ldops)) {
22703 -+ if (!capable(CAP_SYS_MODULE) && !tty_ldisc_autoload)
22704 -+ return ERR_PTR(-EPERM);
22705 - request_module("tty-ldisc-%d", disc);
22706 - ldops = get_ldops(disc);
22707 - if (IS_ERR(ldops))
22708 -@@ -845,3 +854,41 @@ void tty_ldisc_deinit(struct tty_struct *tty)
22709 - tty_ldisc_put(tty->ldisc);
22710 - tty->ldisc = NULL;
22711 - }
22712 -+
22713 -+static int zero;
22714 -+static int one = 1;
22715 -+static struct ctl_table tty_table[] = {
22716 -+ {
22717 -+ .procname = "ldisc_autoload",
22718 -+ .data = &tty_ldisc_autoload,
22719 -+ .maxlen = sizeof(tty_ldisc_autoload),
22720 -+ .mode = 0644,
22721 -+ .proc_handler = proc_dointvec,
22722 -+ .extra1 = &zero,
22723 -+ .extra2 = &one,
22724 -+ },
22725 -+ { }
22726 -+};
22727 -+
22728 -+static struct ctl_table tty_dir_table[] = {
22729 -+ {
22730 -+ .procname = "tty",
22731 -+ .mode = 0555,
22732 -+ .child = tty_table,
22733 -+ },
22734 -+ { }
22735 -+};
22736 -+
22737 -+static struct ctl_table tty_root_table[] = {
22738 -+ {
22739 -+ .procname = "dev",
22740 -+ .mode = 0555,
22741 -+ .child = tty_dir_table,
22742 -+ },
22743 -+ { }
22744 -+};
22745 -+
22746 -+void tty_sysctl_init(void)
22747 -+{
22748 -+ register_sysctl_table(tty_root_table);
22749 -+}
22750 -diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
22751 -index bba75560d11e..9646ff63e77a 100644
22752 ---- a/drivers/tty/vt/vt.c
22753 -+++ b/drivers/tty/vt/vt.c
22754 -@@ -935,8 +935,11 @@ static void flush_scrollback(struct vc_data *vc)
22755 - {
22756 - WARN_CONSOLE_UNLOCKED();
22757 -
22758 -+ set_origin(vc);
22759 - if (vc->vc_sw->con_flush_scrollback)
22760 - vc->vc_sw->con_flush_scrollback(vc);
22761 -+ else
22762 -+ vc->vc_sw->con_switch(vc);
22763 - }
22764 -
22765 - /*
22766 -@@ -1503,8 +1506,10 @@ static void csi_J(struct vc_data *vc, int vpar)
22767 - count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
22768 - start = (unsigned short *)vc->vc_origin;
22769 - break;
22770 -+ case 3: /* include scrollback */
22771 -+ flush_scrollback(vc);
22772 -+ /* fallthrough */
22773 - case 2: /* erase whole display */
22774 -- case 3: /* (and scrollback buffer later) */
22775 - vc_uniscr_clear_lines(vc, 0, vc->vc_rows);
22776 - count = vc->vc_cols * vc->vc_rows;
22777 - start = (unsigned short *)vc->vc_origin;
22778 -@@ -1513,13 +1518,7 @@ static void csi_J(struct vc_data *vc, int vpar)
22779 - return;
22780 - }
22781 - scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
22782 -- if (vpar == 3) {
22783 -- set_origin(vc);
22784 -- flush_scrollback(vc);
22785 -- if (con_is_visible(vc))
22786 -- update_screen(vc);
22787 -- } else if (con_should_update(vc))
22788 -- do_update_region(vc, (unsigned long) start, count);
22789 -+ update_region(vc, (unsigned long) start, count);
22790 - vc->vc_need_wrap = 0;
22791 - }
22792 -
22793 -diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
22794 -index 772851bee99b..12025358bb3c 100644
22795 ---- a/drivers/usb/chipidea/ci_hdrc_tegra.c
22796 -+++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
22797 -@@ -130,6 +130,7 @@ static int tegra_udc_remove(struct platform_device *pdev)
22798 - {
22799 - struct tegra_udc *udc = platform_get_drvdata(pdev);
22800 -
22801 -+ ci_hdrc_remove_device(udc->dev);
22802 - usb_phy_set_suspend(udc->phy, 1);
22803 - clk_disable_unprepare(udc->clk);
22804 -
22805 -diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
22806 -index 7bfcbb23c2a4..016e4004fe9d 100644
22807 ---- a/drivers/usb/chipidea/core.c
22808 -+++ b/drivers/usb/chipidea/core.c
22809 -@@ -954,8 +954,15 @@ static int ci_hdrc_probe(struct platform_device *pdev)
22810 - } else if (ci->platdata->usb_phy) {
22811 - ci->usb_phy = ci->platdata->usb_phy;
22812 - } else {
22813 -+ ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, "phys",
22814 -+ 0);
22815 - ci->phy = devm_phy_get(dev->parent, "usb-phy");
22816 -- ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
22817 -+
22818 -+ /* Fallback to grabbing any registered USB2 PHY */
22819 -+ if (IS_ERR(ci->usb_phy) &&
22820 -+ PTR_ERR(ci->usb_phy) != -EPROBE_DEFER)
22821 -+ ci->usb_phy = devm_usb_get_phy(dev->parent,
22822 -+ USB_PHY_TYPE_USB2);
22823 -
22824 - /* if both generic PHY and USB PHY layers aren't enabled */
22825 - if (PTR_ERR(ci->phy) == -ENOSYS &&
22826 -diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
22827 -index 739f8960811a..ec666eb4b7b4 100644
22828 ---- a/drivers/usb/class/cdc-acm.c
22829 -+++ b/drivers/usb/class/cdc-acm.c
22830 -@@ -558,10 +558,8 @@ static void acm_softint(struct work_struct *work)
22831 - clear_bit(EVENT_RX_STALL, &acm->flags);
22832 - }
22833 -
22834 -- if (test_bit(EVENT_TTY_WAKEUP, &acm->flags)) {
22835 -+ if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
22836 - tty_port_tty_wakeup(&acm->port);
22837 -- clear_bit(EVENT_TTY_WAKEUP, &acm->flags);
22838 -- }
22839 - }
22840 -
22841 - /*
22842 -diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
22843 -index 48277bbc15e4..73c8e6591746 100644
22844 ---- a/drivers/usb/common/common.c
22845 -+++ b/drivers/usb/common/common.c
22846 -@@ -145,6 +145,8 @@ enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0)
22847 -
22848 - do {
22849 - controller = of_find_node_with_property(controller, "phys");
22850 -+ if (!of_device_is_available(controller))
22851 -+ continue;
22852 - index = 0;
22853 - do {
22854 - if (arg0 == -1) {
22855 -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
22856 -index 6c9b76bcc2e1..8d1dbe36db92 100644
22857 ---- a/drivers/usb/dwc3/gadget.c
22858 -+++ b/drivers/usb/dwc3/gadget.c
22859 -@@ -3339,6 +3339,8 @@ int dwc3_gadget_init(struct dwc3 *dwc)
22860 - goto err4;
22861 - }
22862 -
22863 -+ dwc3_gadget_set_speed(&dwc->gadget, dwc->maximum_speed);
22864 -+
22865 - return 0;
22866 -
22867 - err4:
22868 -diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
22869 -index 1e5430438703..0f8d16de7a37 100644
22870 ---- a/drivers/usb/gadget/function/f_fs.c
22871 -+++ b/drivers/usb/gadget/function/f_fs.c
22872 -@@ -1082,6 +1082,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
22873 - * condition with req->complete callback.
22874 - */
22875 - usb_ep_dequeue(ep->ep, req);
22876 -+ wait_for_completion(&done);
22877 - interrupted = ep->status < 0;
22878 - }
22879 -
22880 -diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
22881 -index 75b113a5b25c..f3816a5c861e 100644
22882 ---- a/drivers/usb/gadget/function/f_hid.c
22883 -+++ b/drivers/usb/gadget/function/f_hid.c
22884 -@@ -391,20 +391,20 @@ try_again:
22885 - req->complete = f_hidg_req_complete;
22886 - req->context = hidg;
22887 -
22888 -+ spin_unlock_irqrestore(&hidg->write_spinlock, flags);
22889 -+
22890 - status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC);
22891 - if (status < 0) {
22892 - ERROR(hidg->func.config->cdev,
22893 - "usb_ep_queue error on int endpoint %zd\n", status);
22894 -- goto release_write_pending_unlocked;
22895 -+ goto release_write_pending;
22896 - } else {
22897 - status = count;
22898 - }
22899 -- spin_unlock_irqrestore(&hidg->write_spinlock, flags);
22900 -
22901 - return status;
22902 - release_write_pending:
22903 - spin_lock_irqsave(&hidg->write_spinlock, flags);
22904 --release_write_pending_unlocked:
22905 - hidg->write_pending = 0;
22906 - spin_unlock_irqrestore(&hidg->write_spinlock, flags);
22907 -
22908 -diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
22909 -index 86cff5c28eff..ba841c569c48 100644
22910 ---- a/drivers/usb/host/xhci-dbgcap.c
22911 -+++ b/drivers/usb/host/xhci-dbgcap.c
22912 -@@ -516,7 +516,6 @@ static int xhci_do_dbc_stop(struct xhci_hcd *xhci)
22913 - return -1;
22914 -
22915 - writel(0, &dbc->regs->control);
22916 -- xhci_dbc_mem_cleanup(xhci);
22917 - dbc->state = DS_DISABLED;
22918 -
22919 - return 0;
22920 -@@ -562,8 +561,10 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci)
22921 - ret = xhci_do_dbc_stop(xhci);
22922 - spin_unlock_irqrestore(&dbc->lock, flags);
22923 -
22924 -- if (!ret)
22925 -+ if (!ret) {
22926 -+ xhci_dbc_mem_cleanup(xhci);
22927 - pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
22928 -+ }
22929 - }
22930 -
22931 - static void
22932 -diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
22933 -index e2eece693655..96a740543183 100644
22934 ---- a/drivers/usb/host/xhci-hub.c
22935 -+++ b/drivers/usb/host/xhci-hub.c
22936 -@@ -1545,20 +1545,25 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
22937 - port_index = max_ports;
22938 - while (port_index--) {
22939 - u32 t1, t2;
22940 --
22941 -+ int retries = 10;
22942 -+retry:
22943 - t1 = readl(ports[port_index]->addr);
22944 - t2 = xhci_port_state_to_neutral(t1);
22945 - portsc_buf[port_index] = 0;
22946 -
22947 -- /* Bail out if a USB3 port has a new device in link training */
22948 -- if ((hcd->speed >= HCD_USB3) &&
22949 -+ /*
22950 -+ * Give a USB3 port in link training time to finish, but don't
22951 -+ * prevent suspend as port might be stuck
22952 -+ */
22953 -+ if ((hcd->speed >= HCD_USB3) && retries-- &&
22954 - (t1 & PORT_PLS_MASK) == XDEV_POLLING) {
22955 -- bus_state->bus_suspended = 0;
22956 - spin_unlock_irqrestore(&xhci->lock, flags);
22957 -- xhci_dbg(xhci, "Bus suspend bailout, port in polling\n");
22958 -- return -EBUSY;
22959 -+ msleep(XHCI_PORT_POLLING_LFPS_TIME);
22960 -+ spin_lock_irqsave(&xhci->lock, flags);
22961 -+ xhci_dbg(xhci, "port %d polling in bus suspend, waiting\n",
22962 -+ port_index);
22963 -+ goto retry;
22964 - }
22965 --
22966 - /* suspend ports in U0, or bail out for new connect changes */
22967 - if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) {
22968 - if ((t1 & PORT_CSC) && wake_enabled) {
22969 -diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
22970 -index a9ec7051f286..c2fe218e051f 100644
22971 ---- a/drivers/usb/host/xhci-pci.c
22972 -+++ b/drivers/usb/host/xhci-pci.c
22973 -@@ -194,6 +194,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
22974 - xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
22975 - if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
22976 - (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
22977 -+ pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
22978 - pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
22979 - xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
22980 - if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
22981 -diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
22982 -index a6e463715779..671bce18782c 100644
22983 ---- a/drivers/usb/host/xhci-rcar.c
22984 -+++ b/drivers/usb/host/xhci-rcar.c
22985 -@@ -246,6 +246,7 @@ int xhci_rcar_init_quirk(struct usb_hcd *hcd)
22986 - if (!xhci_rcar_wait_for_pll_active(hcd))
22987 - return -ETIMEDOUT;
22988 -
22989 -+ xhci->quirks |= XHCI_TRUST_TX_LENGTH;
22990 - return xhci_rcar_download_firmware(hcd);
22991 - }
22992 -
22993 -diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
22994 -index 40fa25c4d041..9215a28dad40 100644
22995 ---- a/drivers/usb/host/xhci-ring.c
22996 -+++ b/drivers/usb/host/xhci-ring.c
22997 -@@ -1647,10 +1647,13 @@ static void handle_port_status(struct xhci_hcd *xhci,
22998 - }
22999 - }
23000 -
23001 -- if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_U0 &&
23002 -- DEV_SUPERSPEED_ANY(portsc)) {
23003 -+ if ((portsc & PORT_PLC) &&
23004 -+ DEV_SUPERSPEED_ANY(portsc) &&
23005 -+ ((portsc & PORT_PLS_MASK) == XDEV_U0 ||
23006 -+ (portsc & PORT_PLS_MASK) == XDEV_U1 ||
23007 -+ (portsc & PORT_PLS_MASK) == XDEV_U2)) {
23008 - xhci_dbg(xhci, "resume SS port %d finished\n", port_id);
23009 -- /* We've just brought the device into U0 through either the
23010 -+ /* We've just brought the device into U0/1/2 through either the
23011 - * Resume state after a device remote wakeup, or through the
23012 - * U3Exit state after a host-initiated resume. If it's a device
23013 - * initiated remote wake, don't pass up the link state change,
23014 -diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
23015 -index 938ff06c0349..efb0cad8710e 100644
23016 ---- a/drivers/usb/host/xhci-tegra.c
23017 -+++ b/drivers/usb/host/xhci-tegra.c
23018 -@@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev,
23019 - device_link_del(tegra->genpd_dl_ss);
23020 - if (tegra->genpd_dl_host)
23021 - device_link_del(tegra->genpd_dl_host);
23022 -- if (tegra->genpd_dev_ss)
23023 -+ if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss))
23024 - dev_pm_domain_detach(tegra->genpd_dev_ss, true);
23025 -- if (tegra->genpd_dev_host)
23026 -+ if (!IS_ERR_OR_NULL(tegra->genpd_dev_host))
23027 - dev_pm_domain_detach(tegra->genpd_dev_host, true);
23028 - }
23029 -
23030 -diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
23031 -index 652dc36e3012..9334cdee382a 100644
23032 ---- a/drivers/usb/host/xhci.h
23033 -+++ b/drivers/usb/host/xhci.h
23034 -@@ -452,6 +452,14 @@ struct xhci_op_regs {
23035 - */
23036 - #define XHCI_DEFAULT_BESL 4
23037 -
23038 -+/*
23039 -+ * USB3 specification define a 360ms tPollingLFPSTiemout for USB3 ports
23040 -+ * to complete link training. usually link trainig completes much faster
23041 -+ * so check status 10 times with 36ms sleep in places we need to wait for
23042 -+ * polling to complete.
23043 -+ */
23044 -+#define XHCI_PORT_POLLING_LFPS_TIME 36
23045 -+
23046 - /**
23047 - * struct xhci_intr_reg - Interrupt Register Set
23048 - * @irq_pending: IMAN - Interrupt Management Register. Used to enable
23049 -diff --git a/drivers/usb/mtu3/Kconfig b/drivers/usb/mtu3/Kconfig
23050 -index 40bbf1f53337..fe58904f350b 100644
23051 ---- a/drivers/usb/mtu3/Kconfig
23052 -+++ b/drivers/usb/mtu3/Kconfig
23053 -@@ -4,6 +4,7 @@ config USB_MTU3
23054 - tristate "MediaTek USB3 Dual Role controller"
23055 - depends on USB || USB_GADGET
23056 - depends on ARCH_MEDIATEK || COMPILE_TEST
23057 -+ depends on EXTCON || !EXTCON
23058 - select USB_XHCI_MTK if USB_SUPPORT && USB_XHCI_HCD
23059 - help
23060 - Say Y or M here if your system runs on MediaTek SoCs with
23061 -diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
23062 -index c0777a374a88..e732949f6567 100644
23063 ---- a/drivers/usb/serial/cp210x.c
23064 -+++ b/drivers/usb/serial/cp210x.c
23065 -@@ -61,6 +61,7 @@ static const struct usb_device_id id_table[] = {
23066 - { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
23067 - { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
23068 - { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
23069 -+ { USB_DEVICE(0x0B00, 0x3070) }, /* Ingenico 3070 */
23070 - { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
23071 - { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
23072 - { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
23073 -@@ -79,6 +80,7 @@ static const struct usb_device_id id_table[] = {
23074 - { USB_DEVICE(0x10C4, 0x804E) }, /* Software Bisque Paramount ME build-in converter */
23075 - { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */
23076 - { USB_DEVICE(0x10C4, 0x8054) }, /* Enfora GSM2228 */
23077 -+ { USB_DEVICE(0x10C4, 0x8056) }, /* Lorenz Messtechnik devices */
23078 - { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */
23079 - { USB_DEVICE(0x10C4, 0x806F) }, /* IMS USB to RS422 Converter Cable */
23080 - { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */
23081 -@@ -1353,8 +1355,13 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
23082 - if (priv->partnum == CP210X_PARTNUM_CP2105)
23083 - req_type = REQTYPE_INTERFACE_TO_HOST;
23084 -
23085 -+ result = usb_autopm_get_interface(serial->interface);
23086 -+ if (result)
23087 -+ return result;
23088 -+
23089 - result = cp210x_read_vendor_block(serial, req_type,
23090 - CP210X_READ_LATCH, &buf, sizeof(buf));
23091 -+ usb_autopm_put_interface(serial->interface);
23092 - if (result < 0)
23093 - return result;
23094 -
23095 -@@ -1375,6 +1382,10 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
23096 -
23097 - buf.mask = BIT(gpio);
23098 -
23099 -+ result = usb_autopm_get_interface(serial->interface);
23100 -+ if (result)
23101 -+ goto out;
23102 -+
23103 - if (priv->partnum == CP210X_PARTNUM_CP2105) {
23104 - result = cp210x_write_vendor_block(serial,
23105 - REQTYPE_HOST_TO_INTERFACE,
23106 -@@ -1392,6 +1403,8 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
23107 - NULL, 0, USB_CTRL_SET_TIMEOUT);
23108 - }
23109 -
23110 -+ usb_autopm_put_interface(serial->interface);
23111 -+out:
23112 - if (result < 0) {
23113 - dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n",
23114 - result);
23115 -diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
23116 -index 77ef4c481f3c..1d8461ae2c34 100644
23117 ---- a/drivers/usb/serial/ftdi_sio.c
23118 -+++ b/drivers/usb/serial/ftdi_sio.c
23119 -@@ -609,6 +609,8 @@ static const struct usb_device_id id_table_combined[] = {
23120 - .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
23121 - { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID),
23122 - .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
23123 -+ { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLX_PLUS_PID) },
23124 -+ { USB_DEVICE(FTDI_VID, FTDI_NT_ORION_IO_PID) },
23125 - { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) },
23126 - { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) },
23127 - { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) },
23128 -@@ -1025,6 +1027,8 @@ static const struct usb_device_id id_table_combined[] = {
23129 - { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
23130 - { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
23131 - { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) },
23132 -+ /* EZPrototypes devices */
23133 -+ { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },
23134 - { } /* Terminating entry */
23135 - };
23136 -
23137 -diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
23138 -index 975d02666c5a..5755f0df0025 100644
23139 ---- a/drivers/usb/serial/ftdi_sio_ids.h
23140 -+++ b/drivers/usb/serial/ftdi_sio_ids.h
23141 -@@ -567,7 +567,9 @@
23142 - /*
23143 - * NovaTech product ids (FTDI_VID)
23144 - */
23145 --#define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */
23146 -+#define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */
23147 -+#define FTDI_NT_ORIONLX_PLUS_PID 0x7c91 /* OrionLX+ Substation Automation Platform */
23148 -+#define FTDI_NT_ORION_IO_PID 0x7c92 /* Orion I/O */
23149 -
23150 - /*
23151 - * Synapse Wireless product ids (FTDI_VID)
23152 -@@ -1308,6 +1310,12 @@
23153 - #define IONICS_VID 0x1c0c
23154 - #define IONICS_PLUGCOMPUTER_PID 0x0102
23155 -
23156 -+/*
23157 -+ * EZPrototypes (PID reseller)
23158 -+ */
23159 -+#define EZPROTOTYPES_VID 0x1c40
23160 -+#define HJELMSLUND_USB485_ISO_PID 0x0477
23161 -+
23162 - /*
23163 - * Dresden Elektronik Sensor Terminal Board
23164 - */
23165 -diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
23166 -index fc52ac75fbf6..18110225d506 100644
23167 ---- a/drivers/usb/serial/mos7720.c
23168 -+++ b/drivers/usb/serial/mos7720.c
23169 -@@ -366,8 +366,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
23170 - if (!urbtrack)
23171 - return -ENOMEM;
23172 -
23173 -- kref_get(&mos_parport->ref_count);
23174 -- urbtrack->mos_parport = mos_parport;
23175 - urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC);
23176 - if (!urbtrack->urb) {
23177 - kfree(urbtrack);
23178 -@@ -388,6 +386,8 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
23179 - usb_sndctrlpipe(usbdev, 0),
23180 - (unsigned char *)urbtrack->setup,
23181 - NULL, 0, async_complete, urbtrack);
23182 -+ kref_get(&mos_parport->ref_count);
23183 -+ urbtrack->mos_parport = mos_parport;
23184 - kref_init(&urbtrack->ref_count);
23185 - INIT_LIST_HEAD(&urbtrack->urblist_entry);
23186 -
23187 -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
23188 -index aef15497ff31..83869065b802 100644
23189 ---- a/drivers/usb/serial/option.c
23190 -+++ b/drivers/usb/serial/option.c
23191 -@@ -246,6 +246,7 @@ static void option_instat_callback(struct urb *urb);
23192 - #define QUECTEL_PRODUCT_EC25 0x0125
23193 - #define QUECTEL_PRODUCT_BG96 0x0296
23194 - #define QUECTEL_PRODUCT_EP06 0x0306
23195 -+#define QUECTEL_PRODUCT_EM12 0x0512
23196 -
23197 - #define CMOTECH_VENDOR_ID 0x16d8
23198 - #define CMOTECH_PRODUCT_6001 0x6001
23199 -@@ -1066,7 +1067,8 @@ static const struct usb_device_id option_ids[] = {
23200 - .driver_info = RSVD(3) },
23201 - { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
23202 - { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
23203 -- { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
23204 -+ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000), /* SIMCom SIM5218 */
23205 -+ .driver_info = NCTRL(0) | NCTRL(1) | NCTRL(2) | NCTRL(3) | RSVD(4) },
23206 - /* Quectel products using Qualcomm vendor ID */
23207 - { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)},
23208 - { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20),
23209 -@@ -1087,6 +1089,9 @@ static const struct usb_device_id option_ids[] = {
23210 - { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
23211 - .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
23212 - { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
23213 -+ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0xff, 0xff),
23214 -+ .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
23215 -+ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) },
23216 - { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
23217 - { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
23218 - { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
23219 -@@ -1148,6 +1153,8 @@ static const struct usb_device_id option_ids[] = {
23220 - .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
23221 - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
23222 - .driver_info = NCTRL(0) | RSVD(3) },
23223 -+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1102, 0xff), /* Telit ME910 (ECM) */
23224 -+ .driver_info = NCTRL(0) },
23225 - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
23226 - .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
23227 - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
23228 -@@ -1938,10 +1945,12 @@ static const struct usb_device_id option_ids[] = {
23229 - .driver_info = RSVD(4) },
23230 - { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */
23231 - .driver_info = RSVD(4) },
23232 -- { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
23233 -- { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
23234 -- { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
23235 -- { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
23236 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
23237 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
23238 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
23239 -+ { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2031, 0xff), /* Olicard 600 */
23240 -+ .driver_info = RSVD(4) },
23241 -+ { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
23242 - { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
23243 - { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
23244 - { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) },
23245 -diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
23246 -index f1c39a3c7534..d34e945e5d09 100644
23247 ---- a/drivers/usb/typec/tcpm/tcpm.c
23248 -+++ b/drivers/usb/typec/tcpm/tcpm.c
23249 -@@ -37,6 +37,7 @@
23250 - S(SRC_ATTACHED), \
23251 - S(SRC_STARTUP), \
23252 - S(SRC_SEND_CAPABILITIES), \
23253 -+ S(SRC_SEND_CAPABILITIES_TIMEOUT), \
23254 - S(SRC_NEGOTIATE_CAPABILITIES), \
23255 - S(SRC_TRANSITION_SUPPLY), \
23256 - S(SRC_READY), \
23257 -@@ -2966,10 +2967,34 @@ static void run_state_machine(struct tcpm_port *port)
23258 - /* port->hard_reset_count = 0; */
23259 - port->caps_count = 0;
23260 - port->pd_capable = true;
23261 -- tcpm_set_state_cond(port, hard_reset_state(port),
23262 -+ tcpm_set_state_cond(port, SRC_SEND_CAPABILITIES_TIMEOUT,
23263 - PD_T_SEND_SOURCE_CAP);
23264 - }
23265 - break;
23266 -+ case SRC_SEND_CAPABILITIES_TIMEOUT:
23267 -+ /*
23268 -+ * Error recovery for a PD_DATA_SOURCE_CAP reply timeout.
23269 -+ *
23270 -+ * PD 2.0 sinks are supposed to accept src-capabilities with a
23271 -+ * 3.0 header and simply ignore any src PDOs which the sink does
23272 -+ * not understand such as PPS but some 2.0 sinks instead ignore
23273 -+ * the entire PD_DATA_SOURCE_CAP message, causing contract
23274 -+ * negotiation to fail.
23275 -+ *
23276 -+ * After PD_N_HARD_RESET_COUNT hard-reset attempts, we try
23277 -+ * sending src-capabilities with a lower PD revision to
23278 -+ * make these broken sinks work.
23279 -+ */
23280 -+ if (port->hard_reset_count < PD_N_HARD_RESET_COUNT) {
23281 -+ tcpm_set_state(port, HARD_RESET_SEND, 0);
23282 -+ } else if (port->negotiated_rev > PD_REV20) {
23283 -+ port->negotiated_rev--;
23284 -+ port->hard_reset_count = 0;
23285 -+ tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
23286 -+ } else {
23287 -+ tcpm_set_state(port, hard_reset_state(port), 0);
23288 -+ }
23289 -+ break;
23290 - case SRC_NEGOTIATE_CAPABILITIES:
23291 - ret = tcpm_pd_check_request(port);
23292 - if (ret < 0) {
23293 -diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c
23294 -index 423208e19383..6770afd40765 100644
23295 ---- a/drivers/usb/typec/tcpm/wcove.c
23296 -+++ b/drivers/usb/typec/tcpm/wcove.c
23297 -@@ -615,8 +615,13 @@ static int wcove_typec_probe(struct platform_device *pdev)
23298 - wcove->dev = &pdev->dev;
23299 - wcove->regmap = pmic->regmap;
23300 -
23301 -- irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr,
23302 -- platform_get_irq(pdev, 0));
23303 -+ irq = platform_get_irq(pdev, 0);
23304 -+ if (irq < 0) {
23305 -+ dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
23306 -+ return irq;
23307 -+ }
23308 -+
23309 -+ irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr, irq);
23310 - if (irq < 0)
23311 - return irq;
23312 -
23313 -diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
23314 -index 1c0033ad8738..e1109b15636d 100644
23315 ---- a/drivers/usb/typec/tps6598x.c
23316 -+++ b/drivers/usb/typec/tps6598x.c
23317 -@@ -110,6 +110,20 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
23318 - return 0;
23319 - }
23320 -
23321 -+static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
23322 -+ void *val, size_t len)
23323 -+{
23324 -+ u8 data[TPS_MAX_LEN + 1];
23325 -+
23326 -+ if (!tps->i2c_protocol)
23327 -+ return regmap_raw_write(tps->regmap, reg, val, len);
23328 -+
23329 -+ data[0] = len;
23330 -+ memcpy(&data[1], val, len);
23331 -+
23332 -+ return regmap_raw_write(tps->regmap, reg, data, sizeof(data));
23333 -+}
23334 -+
23335 - static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val)
23336 - {
23337 - return tps6598x_block_read(tps, reg, val, sizeof(u16));
23338 -@@ -127,23 +141,23 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val)
23339 -
23340 - static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val)
23341 - {
23342 -- return regmap_raw_write(tps->regmap, reg, &val, sizeof(u16));
23343 -+ return tps6598x_block_write(tps, reg, &val, sizeof(u16));
23344 - }
23345 -
23346 - static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val)
23347 - {
23348 -- return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
23349 -+ return tps6598x_block_write(tps, reg, &val, sizeof(u32));
23350 - }
23351 -
23352 - static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
23353 - {
23354 -- return regmap_raw_write(tps->regmap, reg, &val, sizeof(u64));
23355 -+ return tps6598x_block_write(tps, reg, &val, sizeof(u64));
23356 - }
23357 -
23358 - static inline int
23359 - tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
23360 - {
23361 -- return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
23362 -+ return tps6598x_block_write(tps, reg, &val, sizeof(u32));
23363 - }
23364 -
23365 - static int tps6598x_read_partner_identity(struct tps6598x *tps)
23366 -@@ -229,8 +243,8 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
23367 - return -EBUSY;
23368 -
23369 - if (in_len) {
23370 -- ret = regmap_raw_write(tps->regmap, TPS_REG_DATA1,
23371 -- in_data, in_len);
23372 -+ ret = tps6598x_block_write(tps, TPS_REG_DATA1,
23373 -+ in_data, in_len);
23374 - if (ret)
23375 - return ret;
23376 - }
23377 -diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
23378 -index feb90764a811..53b8ceea9bde 100644
23379 ---- a/drivers/video/backlight/pwm_bl.c
23380 -+++ b/drivers/video/backlight/pwm_bl.c
23381 -@@ -435,7 +435,7 @@ static int pwm_backlight_initial_power_state(const struct pwm_bl_data *pb)
23382 - */
23383 -
23384 - /* if the enable GPIO is disabled, do not enable the backlight */
23385 -- if (pb->enable_gpio && gpiod_get_value(pb->enable_gpio) == 0)
23386 -+ if (pb->enable_gpio && gpiod_get_value_cansleep(pb->enable_gpio) == 0)
23387 - return FB_BLANK_POWERDOWN;
23388 -
23389 - /* The regulator is disabled, do not enable the backlight */
23390 -diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
23391 -index cb43a2258c51..4721491e6c8c 100644
23392 ---- a/drivers/video/fbdev/core/fbmem.c
23393 -+++ b/drivers/video/fbdev/core/fbmem.c
23394 -@@ -431,6 +431,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
23395 - {
23396 - unsigned int x;
23397 -
23398 -+ if (image->width > info->var.xres || image->height > info->var.yres)
23399 -+ return;
23400 -+
23401 - if (rotate == FB_ROTATE_UR) {
23402 - for (x = 0;
23403 - x < num && image->dx + image->width <= info->var.xres;
23404 -diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
23405 -index a0b07c331255..a38b65b97be0 100644
23406 ---- a/drivers/virtio/virtio_ring.c
23407 -+++ b/drivers/virtio/virtio_ring.c
23408 -@@ -871,6 +871,8 @@ static struct virtqueue *vring_create_virtqueue_split(
23409 - GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
23410 - if (queue)
23411 - break;
23412 -+ if (!may_reduce_num)
23413 -+ return NULL;
23414 - }
23415 -
23416 - if (!num)
23417 -diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
23418 -index cba6b586bfbd..d97fcfc5e558 100644
23419 ---- a/drivers/xen/gntdev-dmabuf.c
23420 -+++ b/drivers/xen/gntdev-dmabuf.c
23421 -@@ -80,6 +80,12 @@ struct gntdev_dmabuf_priv {
23422 - struct list_head imp_list;
23423 - /* This is the lock which protects dma_buf_xxx lists. */
23424 - struct mutex lock;
23425 -+ /*
23426 -+ * We reference this file while exporting dma-bufs, so
23427 -+ * the grant device context is not destroyed while there are
23428 -+ * external users alive.
23429 -+ */
23430 -+ struct file *filp;
23431 - };
23432 -
23433 - /* DMA buffer export support. */
23434 -@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
23435 -
23436 - dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
23437 - list_del(&gntdev_dmabuf->next);
23438 -+ fput(gntdev_dmabuf->priv->filp);
23439 - kfree(gntdev_dmabuf);
23440 - }
23441 -
23442 -@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
23443 - mutex_lock(&args->dmabuf_priv->lock);
23444 - list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
23445 - mutex_unlock(&args->dmabuf_priv->lock);
23446 -+ get_file(gntdev_dmabuf->priv->filp);
23447 - return 0;
23448 -
23449 - fail:
23450 -@@ -834,7 +842,7 @@ long gntdev_ioctl_dmabuf_imp_release(struct gntdev_priv *priv,
23451 - return dmabuf_imp_release(priv->dmabuf_priv, op.fd);
23452 - }
23453 -
23454 --struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void)
23455 -+struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp)
23456 - {
23457 - struct gntdev_dmabuf_priv *priv;
23458 -
23459 -@@ -847,6 +855,8 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void)
23460 - INIT_LIST_HEAD(&priv->exp_wait_list);
23461 - INIT_LIST_HEAD(&priv->imp_list);
23462 -
23463 -+ priv->filp = filp;
23464 -+
23465 - return priv;
23466 - }
23467 -
23468 -diff --git a/drivers/xen/gntdev-dmabuf.h b/drivers/xen/gntdev-dmabuf.h
23469 -index 7220a53d0fc5..3d9b9cf9d5a1 100644
23470 ---- a/drivers/xen/gntdev-dmabuf.h
23471 -+++ b/drivers/xen/gntdev-dmabuf.h
23472 -@@ -14,7 +14,7 @@
23473 - struct gntdev_dmabuf_priv;
23474 - struct gntdev_priv;
23475 -
23476 --struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void);
23477 -+struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp);
23478 -
23479 - void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv);
23480 -
23481 -diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
23482 -index 5efc5eee9544..7cf9c51318aa 100644
23483 ---- a/drivers/xen/gntdev.c
23484 -+++ b/drivers/xen/gntdev.c
23485 -@@ -600,7 +600,7 @@ static int gntdev_open(struct inode *inode, struct file *flip)
23486 - mutex_init(&priv->lock);
23487 -
23488 - #ifdef CONFIG_XEN_GNTDEV_DMABUF
23489 -- priv->dmabuf_priv = gntdev_dmabuf_init();
23490 -+ priv->dmabuf_priv = gntdev_dmabuf_init(flip);
23491 - if (IS_ERR(priv->dmabuf_priv)) {
23492 - ret = PTR_ERR(priv->dmabuf_priv);
23493 - kfree(priv);
23494 -diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
23495 -index 5a0db6dec8d1..aaee1e6584e6 100644
23496 ---- a/fs/9p/v9fs_vfs.h
23497 -+++ b/fs/9p/v9fs_vfs.h
23498 -@@ -40,6 +40,9 @@
23499 - */
23500 - #define P9_LOCK_TIMEOUT (30*HZ)
23501 -
23502 -+/* flags for v9fs_stat2inode() & v9fs_stat2inode_dotl() */
23503 -+#define V9FS_STAT2INODE_KEEP_ISIZE 1
23504 -+
23505 - extern struct file_system_type v9fs_fs_type;
23506 - extern const struct address_space_operations v9fs_addr_operations;
23507 - extern const struct file_operations v9fs_file_operations;
23508 -@@ -61,8 +64,10 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
23509 - struct inode *inode, umode_t mode, dev_t);
23510 - void v9fs_evict_inode(struct inode *inode);
23511 - ino_t v9fs_qid2ino(struct p9_qid *qid);
23512 --void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);
23513 --void v9fs_stat2inode_dotl(struct p9_stat_dotl *, struct inode *);
23514 -+void v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
23515 -+ struct super_block *sb, unsigned int flags);
23516 -+void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
23517 -+ unsigned int flags);
23518 - int v9fs_dir_release(struct inode *inode, struct file *filp);
23519 - int v9fs_file_open(struct inode *inode, struct file *file);
23520 - void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
23521 -@@ -83,4 +88,18 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode)
23522 - }
23523 -
23524 - int v9fs_open_to_dotl_flags(int flags);
23525 -+
23526 -+static inline void v9fs_i_size_write(struct inode *inode, loff_t i_size)
23527 -+{
23528 -+ /*
23529 -+ * 32-bit need the lock, concurrent updates could break the
23530 -+ * sequences and make i_size_read() loop forever.
23531 -+ * 64-bit updates are atomic and can skip the locking.
23532 -+ */
23533 -+ if (sizeof(i_size) > sizeof(long))
23534 -+ spin_lock(&inode->i_lock);
23535 -+ i_size_write(inode, i_size);
23536 -+ if (sizeof(i_size) > sizeof(long))
23537 -+ spin_unlock(&inode->i_lock);
23538 -+}
23539 - #endif
23540 -diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
23541 -index a25efa782fcc..9a1125305d84 100644
23542 ---- a/fs/9p/vfs_file.c
23543 -+++ b/fs/9p/vfs_file.c
23544 -@@ -446,7 +446,11 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
23545 - i_size = i_size_read(inode);
23546 - if (iocb->ki_pos > i_size) {
23547 - inode_add_bytes(inode, iocb->ki_pos - i_size);
23548 -- i_size_write(inode, iocb->ki_pos);
23549 -+ /*
23550 -+ * Need to serialize against i_size_write() in
23551 -+ * v9fs_stat2inode()
23552 -+ */
23553 -+ v9fs_i_size_write(inode, iocb->ki_pos);
23554 - }
23555 - return retval;
23556 - }
23557 -diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
23558 -index 85ff859d3af5..72b779bc0942 100644
23559 ---- a/fs/9p/vfs_inode.c
23560 -+++ b/fs/9p/vfs_inode.c
23561 -@@ -538,7 +538,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
23562 - if (retval)
23563 - goto error;
23564 -
23565 -- v9fs_stat2inode(st, inode, sb);
23566 -+ v9fs_stat2inode(st, inode, sb, 0);
23567 - v9fs_cache_inode_get_cookie(inode);
23568 - unlock_new_inode(inode);
23569 - return inode;
23570 -@@ -1092,7 +1092,7 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat,
23571 - if (IS_ERR(st))
23572 - return PTR_ERR(st);
23573 -
23574 -- v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb);
23575 -+ v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb, 0);
23576 - generic_fillattr(d_inode(dentry), stat);
23577 -
23578 - p9stat_free(st);
23579 -@@ -1170,12 +1170,13 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
23580 - * @stat: Plan 9 metadata (mistat) structure
23581 - * @inode: inode to populate
23582 - * @sb: superblock of filesystem
23583 -+ * @flags: control flags (e.g. V9FS_STAT2INODE_KEEP_ISIZE)
23584 - *
23585 - */
23586 -
23587 - void
23588 - v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
23589 -- struct super_block *sb)
23590 -+ struct super_block *sb, unsigned int flags)
23591 - {
23592 - umode_t mode;
23593 - char ext[32];
23594 -@@ -1216,10 +1217,11 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
23595 - mode = p9mode2perm(v9ses, stat);
23596 - mode |= inode->i_mode & ~S_IALLUGO;
23597 - inode->i_mode = mode;
23598 -- i_size_write(inode, stat->length);
23599 -
23600 -+ if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE))
23601 -+ v9fs_i_size_write(inode, stat->length);
23602 - /* not real number of blocks, but 512 byte ones ... */
23603 -- inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
23604 -+ inode->i_blocks = (stat->length + 512 - 1) >> 9;
23605 - v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;
23606 - }
23607 -
23608 -@@ -1416,9 +1418,9 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
23609 - {
23610 - int umode;
23611 - dev_t rdev;
23612 -- loff_t i_size;
23613 - struct p9_wstat *st;
23614 - struct v9fs_session_info *v9ses;
23615 -+ unsigned int flags;
23616 -
23617 - v9ses = v9fs_inode2v9ses(inode);
23618 - st = p9_client_stat(fid);
23619 -@@ -1431,16 +1433,13 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
23620 - if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
23621 - goto out;
23622 -
23623 -- spin_lock(&inode->i_lock);
23624 - /*
23625 - * We don't want to refresh inode->i_size,
23626 - * because we may have cached data
23627 - */
23628 -- i_size = inode->i_size;
23629 -- v9fs_stat2inode(st, inode, inode->i_sb);
23630 -- if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
23631 -- inode->i_size = i_size;
23632 -- spin_unlock(&inode->i_lock);
23633 -+ flags = (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) ?
23634 -+ V9FS_STAT2INODE_KEEP_ISIZE : 0;
23635 -+ v9fs_stat2inode(st, inode, inode->i_sb, flags);
23636 - out:
23637 - p9stat_free(st);
23638 - kfree(st);
23639 -diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
23640 -index 4823e1c46999..a950a927a626 100644
23641 ---- a/fs/9p/vfs_inode_dotl.c
23642 -+++ b/fs/9p/vfs_inode_dotl.c
23643 -@@ -143,7 +143,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
23644 - if (retval)
23645 - goto error;
23646 -
23647 -- v9fs_stat2inode_dotl(st, inode);
23648 -+ v9fs_stat2inode_dotl(st, inode, 0);
23649 - v9fs_cache_inode_get_cookie(inode);
23650 - retval = v9fs_get_acl(inode, fid);
23651 - if (retval)
23652 -@@ -496,7 +496,7 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat,
23653 - if (IS_ERR(st))
23654 - return PTR_ERR(st);
23655 -
23656 -- v9fs_stat2inode_dotl(st, d_inode(dentry));
23657 -+ v9fs_stat2inode_dotl(st, d_inode(dentry), 0);
23658 - generic_fillattr(d_inode(dentry), stat);
23659 - /* Change block size to what the server returned */
23660 - stat->blksize = st->st_blksize;
23661 -@@ -607,11 +607,13 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
23662 - * v9fs_stat2inode_dotl - populate an inode structure with stat info
23663 - * @stat: stat structure
23664 - * @inode: inode to populate
23665 -+ * @flags: ctrl flags (e.g. V9FS_STAT2INODE_KEEP_ISIZE)
23666 - *
23667 - */
23668 -
23669 - void
23670 --v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
23671 -+v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
23672 -+ unsigned int flags)
23673 - {
23674 - umode_t mode;
23675 - struct v9fs_inode *v9inode = V9FS_I(inode);
23676 -@@ -631,7 +633,8 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
23677 - mode |= inode->i_mode & ~S_IALLUGO;
23678 - inode->i_mode = mode;
23679 -
23680 -- i_size_write(inode, stat->st_size);
23681 -+ if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE))
23682 -+ v9fs_i_size_write(inode, stat->st_size);
23683 - inode->i_blocks = stat->st_blocks;
23684 - } else {
23685 - if (stat->st_result_mask & P9_STATS_ATIME) {
23686 -@@ -661,8 +664,9 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
23687 - }
23688 - if (stat->st_result_mask & P9_STATS_RDEV)
23689 - inode->i_rdev = new_decode_dev(stat->st_rdev);
23690 -- if (stat->st_result_mask & P9_STATS_SIZE)
23691 -- i_size_write(inode, stat->st_size);
23692 -+ if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE) &&
23693 -+ stat->st_result_mask & P9_STATS_SIZE)
23694 -+ v9fs_i_size_write(inode, stat->st_size);
23695 - if (stat->st_result_mask & P9_STATS_BLOCKS)
23696 - inode->i_blocks = stat->st_blocks;
23697 - }
23698 -@@ -928,9 +932,9 @@ v9fs_vfs_get_link_dotl(struct dentry *dentry,
23699 -
23700 - int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
23701 - {
23702 -- loff_t i_size;
23703 - struct p9_stat_dotl *st;
23704 - struct v9fs_session_info *v9ses;
23705 -+ unsigned int flags;
23706 -
23707 - v9ses = v9fs_inode2v9ses(inode);
23708 - st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
23709 -@@ -942,16 +946,13 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
23710 - if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
23711 - goto out;
23712 -
23713 -- spin_lock(&inode->i_lock);
23714 - /*
23715 - * We don't want to refresh inode->i_size,
23716 - * because we may have cached data
23717 - */
23718 -- i_size = inode->i_size;
23719 -- v9fs_stat2inode_dotl(st, inode);
23720 -- if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
23721 -- inode->i_size = i_size;
23722 -- spin_unlock(&inode->i_lock);
23723 -+ flags = (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) ?
23724 -+ V9FS_STAT2INODE_KEEP_ISIZE : 0;
23725 -+ v9fs_stat2inode_dotl(st, inode, flags);
23726 - out:
23727 - kfree(st);
23728 - return 0;
23729 -diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
23730 -index 48ce50484e80..eeab9953af89 100644
23731 ---- a/fs/9p/vfs_super.c
23732 -+++ b/fs/9p/vfs_super.c
23733 -@@ -172,7 +172,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
23734 - goto release_sb;
23735 - }
23736 - d_inode(root)->i_ino = v9fs_qid2ino(&st->qid);
23737 -- v9fs_stat2inode_dotl(st, d_inode(root));
23738 -+ v9fs_stat2inode_dotl(st, d_inode(root), 0);
23739 - kfree(st);
23740 - } else {
23741 - struct p9_wstat *st = NULL;
23742 -@@ -183,7 +183,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
23743 - }
23744 -
23745 - d_inode(root)->i_ino = v9fs_qid2ino(&st->qid);
23746 -- v9fs_stat2inode(st, d_inode(root), sb);
23747 -+ v9fs_stat2inode(st, d_inode(root), sb, 0);
23748 -
23749 - p9stat_free(st);
23750 - kfree(st);
23751 -diff --git a/fs/aio.c b/fs/aio.c
23752 -index aaaaf4d12c73..3d9669d011b9 100644
23753 ---- a/fs/aio.c
23754 -+++ b/fs/aio.c
23755 -@@ -167,9 +167,13 @@ struct kioctx {
23756 - unsigned id;
23757 - };
23758 -
23759 -+/*
23760 -+ * First field must be the file pointer in all the
23761 -+ * iocb unions! See also 'struct kiocb' in <linux/fs.h>
23762 -+ */
23763 - struct fsync_iocb {
23764 -- struct work_struct work;
23765 - struct file *file;
23766 -+ struct work_struct work;
23767 - bool datasync;
23768 - };
23769 -
23770 -@@ -183,8 +187,15 @@ struct poll_iocb {
23771 - struct work_struct work;
23772 - };
23773 -
23774 -+/*
23775 -+ * NOTE! Each of the iocb union members has the file pointer
23776 -+ * as the first entry in their struct definition. So you can
23777 -+ * access the file pointer through any of the sub-structs,
23778 -+ * or directly as just 'ki_filp' in this struct.
23779 -+ */
23780 - struct aio_kiocb {
23781 - union {
23782 -+ struct file *ki_filp;
23783 - struct kiocb rw;
23784 - struct fsync_iocb fsync;
23785 - struct poll_iocb poll;
23786 -@@ -1060,6 +1071,8 @@ static inline void iocb_put(struct aio_kiocb *iocb)
23787 - {
23788 - if (refcount_read(&iocb->ki_refcnt) == 0 ||
23789 - refcount_dec_and_test(&iocb->ki_refcnt)) {
23790 -+ if (iocb->ki_filp)
23791 -+ fput(iocb->ki_filp);
23792 - percpu_ref_put(&iocb->ki_ctx->reqs);
23793 - kmem_cache_free(kiocb_cachep, iocb);
23794 - }
23795 -@@ -1424,7 +1437,6 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2)
23796 - file_end_write(kiocb->ki_filp);
23797 - }
23798 -
23799 -- fput(kiocb->ki_filp);
23800 - aio_complete(iocb, res, res2);
23801 - }
23802 -
23803 -@@ -1432,9 +1444,6 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
23804 - {
23805 - int ret;
23806 -
23807 -- req->ki_filp = fget(iocb->aio_fildes);
23808 -- if (unlikely(!req->ki_filp))
23809 -- return -EBADF;
23810 - req->ki_complete = aio_complete_rw;
23811 - req->private = NULL;
23812 - req->ki_pos = iocb->aio_offset;
23813 -@@ -1451,7 +1460,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
23814 - ret = ioprio_check_cap(iocb->aio_reqprio);
23815 - if (ret) {
23816 - pr_debug("aio ioprio check cap error: %d\n", ret);
23817 -- goto out_fput;
23818 -+ return ret;
23819 - }
23820 -
23821 - req->ki_ioprio = iocb->aio_reqprio;
23822 -@@ -1460,14 +1469,10 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
23823 -
23824 - ret = kiocb_set_rw_flags(req, iocb->aio_rw_flags);
23825 - if (unlikely(ret))
23826 -- goto out_fput;
23827 -+ return ret;
23828 -
23829 - req->ki_flags &= ~IOCB_HIPRI; /* no one is going to poll for this I/O */
23830 - return 0;
23831 --
23832 --out_fput:
23833 -- fput(req->ki_filp);
23834 -- return ret;
23835 - }
23836 -
23837 - static int aio_setup_rw(int rw, const struct iocb *iocb, struct iovec **iovec,
23838 -@@ -1521,24 +1526,19 @@ static ssize_t aio_read(struct kiocb *req, const struct iocb *iocb,
23839 - if (ret)
23840 - return ret;
23841 - file = req->ki_filp;
23842 --
23843 -- ret = -EBADF;
23844 - if (unlikely(!(file->f_mode & FMODE_READ)))
23845 -- goto out_fput;
23846 -+ return -EBADF;
23847 - ret = -EINVAL;
23848 - if (unlikely(!file->f_op->read_iter))
23849 -- goto out_fput;
23850 -+ return -EINVAL;
23851 -
23852 - ret = aio_setup_rw(READ, iocb, &iovec, vectored, compat, &iter);
23853 - if (ret)
23854 -- goto out_fput;
23855 -+ return ret;
23856 - ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter));
23857 - if (!ret)
23858 - aio_rw_done(req, call_read_iter(file, req, &iter));
23859 - kfree(iovec);
23860 --out_fput:
23861 -- if (unlikely(ret))
23862 -- fput(file);
23863 - return ret;
23864 - }
23865 -
23866 -@@ -1555,16 +1555,14 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb,
23867 - return ret;
23868 - file = req->ki_filp;
23869 -
23870 -- ret = -EBADF;
23871 - if (unlikely(!(file->f_mode & FMODE_WRITE)))
23872 -- goto out_fput;
23873 -- ret = -EINVAL;
23874 -+ return -EBADF;
23875 - if (unlikely(!file->f_op->write_iter))
23876 -- goto out_fput;
23877 -+ return -EINVAL;
23878 -
23879 - ret = aio_setup_rw(WRITE, iocb, &iovec, vectored, compat, &iter);
23880 - if (ret)
23881 -- goto out_fput;
23882 -+ return ret;
23883 - ret = rw_verify_area(WRITE, file, &req->ki_pos, iov_iter_count(&iter));
23884 - if (!ret) {
23885 - /*
23886 -@@ -1582,9 +1580,6 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb,
23887 - aio_rw_done(req, call_write_iter(file, req, &iter));
23888 - }
23889 - kfree(iovec);
23890 --out_fput:
23891 -- if (unlikely(ret))
23892 -- fput(file);
23893 - return ret;
23894 - }
23895 -
23896 -@@ -1594,7 +1589,6 @@ static void aio_fsync_work(struct work_struct *work)
23897 - int ret;
23898 -
23899 - ret = vfs_fsync(req->file, req->datasync);
23900 -- fput(req->file);
23901 - aio_complete(container_of(req, struct aio_kiocb, fsync), ret, 0);
23902 - }
23903 -
23904 -@@ -1605,13 +1599,8 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,
23905 - iocb->aio_rw_flags))
23906 - return -EINVAL;
23907 -
23908 -- req->file = fget(iocb->aio_fildes);
23909 -- if (unlikely(!req->file))
23910 -- return -EBADF;
23911 -- if (unlikely(!req->file->f_op->fsync)) {
23912 -- fput(req->file);
23913 -+ if (unlikely(!req->file->f_op->fsync))
23914 - return -EINVAL;
23915 -- }
23916 -
23917 - req->datasync = datasync;
23918 - INIT_WORK(&req->work, aio_fsync_work);
23919 -@@ -1621,10 +1610,7 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,
23920 -
23921 - static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask)
23922 - {
23923 -- struct file *file = iocb->poll.file;
23924 --
23925 - aio_complete(iocb, mangle_poll(mask), 0);
23926 -- fput(file);
23927 - }
23928 -
23929 - static void aio_poll_complete_work(struct work_struct *work)
23930 -@@ -1680,6 +1666,7 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
23931 - struct poll_iocb *req = container_of(wait, struct poll_iocb, wait);
23932 - struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll);
23933 - __poll_t mask = key_to_poll(key);
23934 -+ unsigned long flags;
23935 -
23936 - req->woken = true;
23937 -
23938 -@@ -1688,10 +1675,15 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
23939 - if (!(mask & req->events))
23940 - return 0;
23941 -
23942 -- /* try to complete the iocb inline if we can: */
23943 -- if (spin_trylock(&iocb->ki_ctx->ctx_lock)) {
23944 -+ /*
23945 -+ * Try to complete the iocb inline if we can. Use
23946 -+ * irqsave/irqrestore because not all filesystems (e.g. fuse)
23947 -+ * call this function with IRQs disabled and because IRQs
23948 -+ * have to be disabled before ctx_lock is obtained.
23949 -+ */
23950 -+ if (spin_trylock_irqsave(&iocb->ki_ctx->ctx_lock, flags)) {
23951 - list_del(&iocb->ki_list);
23952 -- spin_unlock(&iocb->ki_ctx->ctx_lock);
23953 -+ spin_unlock_irqrestore(&iocb->ki_ctx->ctx_lock, flags);
23954 -
23955 - list_del_init(&req->wait.entry);
23956 - aio_poll_complete(iocb, mask);
23957 -@@ -1743,9 +1735,6 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb)
23958 -
23959 - INIT_WORK(&req->work, aio_poll_complete_work);
23960 - req->events = demangle_poll(iocb->aio_buf) | EPOLLERR | EPOLLHUP;
23961 -- req->file = fget(iocb->aio_fildes);
23962 -- if (unlikely(!req->file))
23963 -- return -EBADF;
23964 -
23965 - req->head = NULL;
23966 - req->woken = false;
23967 -@@ -1788,10 +1777,8 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb)
23968 - spin_unlock_irq(&ctx->ctx_lock);
23969 -
23970 - out:
23971 -- if (unlikely(apt.error)) {
23972 -- fput(req->file);
23973 -+ if (unlikely(apt.error))
23974 - return apt.error;
23975 -- }
23976 -
23977 - if (mask)
23978 - aio_poll_complete(aiocb, mask);
23979 -@@ -1829,6 +1816,11 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
23980 - if (unlikely(!req))
23981 - goto out_put_reqs_available;
23982 -
23983 -+ req->ki_filp = fget(iocb->aio_fildes);
23984 -+ ret = -EBADF;
23985 -+ if (unlikely(!req->ki_filp))
23986 -+ goto out_put_req;
23987 -+
23988 - if (iocb->aio_flags & IOCB_FLAG_RESFD) {
23989 - /*
23990 - * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
23991 -diff --git a/fs/block_dev.c b/fs/block_dev.c
23992 -index 58a4c1217fa8..06ef48ad1998 100644
23993 ---- a/fs/block_dev.c
23994 -+++ b/fs/block_dev.c
23995 -@@ -298,10 +298,10 @@ static void blkdev_bio_end_io(struct bio *bio)
23996 - struct blkdev_dio *dio = bio->bi_private;
23997 - bool should_dirty = dio->should_dirty;
23998 -
23999 -- if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
24000 -- if (bio->bi_status && !dio->bio.bi_status)
24001 -- dio->bio.bi_status = bio->bi_status;
24002 -- } else {
24003 -+ if (bio->bi_status && !dio->bio.bi_status)
24004 -+ dio->bio.bi_status = bio->bi_status;
24005 -+
24006 -+ if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) {
24007 - if (!dio->is_sync) {
24008 - struct kiocb *iocb = dio->iocb;
24009 - ssize_t ret;
24010 -diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
24011 -index 3b66c957ea6f..5810463dc6d2 100644
24012 ---- a/fs/btrfs/acl.c
24013 -+++ b/fs/btrfs/acl.c
24014 -@@ -9,6 +9,7 @@
24015 - #include <linux/posix_acl_xattr.h>
24016 - #include <linux/posix_acl.h>
24017 - #include <linux/sched.h>
24018 -+#include <linux/sched/mm.h>
24019 - #include <linux/slab.h>
24020 -
24021 - #include "ctree.h"
24022 -@@ -72,8 +73,16 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
24023 - }
24024 -
24025 - if (acl) {
24026 -+ unsigned int nofs_flag;
24027 -+
24028 - size = posix_acl_xattr_size(acl->a_count);
24029 -+ /*
24030 -+ * We're holding a transaction handle, so use a NOFS memory
24031 -+ * allocation context to avoid deadlock if reclaim happens.
24032 -+ */
24033 -+ nofs_flag = memalloc_nofs_save();
24034 - value = kmalloc(size, GFP_KERNEL);
24035 -+ memalloc_nofs_restore(nofs_flag);
24036 - if (!value) {
24037 - ret = -ENOMEM;
24038 - goto out;
24039 -diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
24040 -index 8750c835f535..c4dea3b7349e 100644
24041 ---- a/fs/btrfs/dev-replace.c
24042 -+++ b/fs/btrfs/dev-replace.c
24043 -@@ -862,6 +862,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
24044 - btrfs_destroy_dev_replace_tgtdev(tgt_device);
24045 - break;
24046 - default:
24047 -+ up_write(&dev_replace->rwsem);
24048 - result = -EINVAL;
24049 - }
24050 -
24051 -diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
24052 -index 6a2a2a951705..888d72dda794 100644
24053 ---- a/fs/btrfs/disk-io.c
24054 -+++ b/fs/btrfs/disk-io.c
24055 -@@ -17,6 +17,7 @@
24056 - #include <linux/semaphore.h>
24057 - #include <linux/error-injection.h>
24058 - #include <linux/crc32c.h>
24059 -+#include <linux/sched/mm.h>
24060 - #include <asm/unaligned.h>
24061 - #include "ctree.h"
24062 - #include "disk-io.h"
24063 -@@ -1258,10 +1259,17 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
24064 - struct btrfs_root *tree_root = fs_info->tree_root;
24065 - struct btrfs_root *root;
24066 - struct btrfs_key key;
24067 -+ unsigned int nofs_flag;
24068 - int ret = 0;
24069 - uuid_le uuid = NULL_UUID_LE;
24070 -
24071 -+ /*
24072 -+ * We're holding a transaction handle, so use a NOFS memory allocation
24073 -+ * context to avoid deadlock if reclaim happens.
24074 -+ */
24075 -+ nofs_flag = memalloc_nofs_save();
24076 - root = btrfs_alloc_root(fs_info, GFP_KERNEL);
24077 -+ memalloc_nofs_restore(nofs_flag);
24078 - if (!root)
24079 - return ERR_PTR(-ENOMEM);
24080 -
24081 -diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
24082 -index d81035b7ea7d..1b68700bc1c5 100644
24083 ---- a/fs/btrfs/extent-tree.c
24084 -+++ b/fs/btrfs/extent-tree.c
24085 -@@ -4808,6 +4808,7 @@ skip_async:
24086 - }
24087 -
24088 - struct reserve_ticket {
24089 -+ u64 orig_bytes;
24090 - u64 bytes;
24091 - int error;
24092 - struct list_head list;
24093 -@@ -5030,7 +5031,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info,
24094 - !test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state));
24095 - }
24096 -
24097 --static void wake_all_tickets(struct list_head *head)
24098 -+static bool wake_all_tickets(struct list_head *head)
24099 - {
24100 - struct reserve_ticket *ticket;
24101 -
24102 -@@ -5039,7 +5040,10 @@ static void wake_all_tickets(struct list_head *head)
24103 - list_del_init(&ticket->list);
24104 - ticket->error = -ENOSPC;
24105 - wake_up(&ticket->wait);
24106 -+ if (ticket->bytes != ticket->orig_bytes)
24107 -+ return true;
24108 - }
24109 -+ return false;
24110 - }
24111 -
24112 - /*
24113 -@@ -5094,8 +5098,12 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
24114 - if (flush_state > COMMIT_TRANS) {
24115 - commit_cycles++;
24116 - if (commit_cycles > 2) {
24117 -- wake_all_tickets(&space_info->tickets);
24118 -- space_info->flush = 0;
24119 -+ if (wake_all_tickets(&space_info->tickets)) {
24120 -+ flush_state = FLUSH_DELAYED_ITEMS_NR;
24121 -+ commit_cycles--;
24122 -+ } else {
24123 -+ space_info->flush = 0;
24124 -+ }
24125 - } else {
24126 - flush_state = FLUSH_DELAYED_ITEMS_NR;
24127 - }
24128 -@@ -5147,10 +5155,11 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
24129 -
24130 - static int wait_reserve_ticket(struct btrfs_fs_info *fs_info,
24131 - struct btrfs_space_info *space_info,
24132 -- struct reserve_ticket *ticket, u64 orig_bytes)
24133 -+ struct reserve_ticket *ticket)
24134 -
24135 - {
24136 - DEFINE_WAIT(wait);
24137 -+ u64 reclaim_bytes = 0;
24138 - int ret = 0;
24139 -
24140 - spin_lock(&space_info->lock);
24141 -@@ -5171,14 +5180,12 @@ static int wait_reserve_ticket(struct btrfs_fs_info *fs_info,
24142 - ret = ticket->error;
24143 - if (!list_empty(&ticket->list))
24144 - list_del_init(&ticket->list);
24145 -- if (ticket->bytes && ticket->bytes < orig_bytes) {
24146 -- u64 num_bytes = orig_bytes - ticket->bytes;
24147 -- update_bytes_may_use(space_info, -num_bytes);
24148 -- trace_btrfs_space_reservation(fs_info, "space_info",
24149 -- space_info->flags, num_bytes, 0);
24150 -- }
24151 -+ if (ticket->bytes && ticket->bytes < ticket->orig_bytes)
24152 -+ reclaim_bytes = ticket->orig_bytes - ticket->bytes;
24153 - spin_unlock(&space_info->lock);
24154 -
24155 -+ if (reclaim_bytes)
24156 -+ space_info_add_old_bytes(fs_info, space_info, reclaim_bytes);
24157 - return ret;
24158 - }
24159 -
24160 -@@ -5204,6 +5211,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
24161 - {
24162 - struct reserve_ticket ticket;
24163 - u64 used;
24164 -+ u64 reclaim_bytes = 0;
24165 - int ret = 0;
24166 -
24167 - ASSERT(orig_bytes);
24168 -@@ -5239,6 +5247,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
24169 - * the list and we will do our own flushing further down.
24170 - */
24171 - if (ret && flush != BTRFS_RESERVE_NO_FLUSH) {
24172 -+ ticket.orig_bytes = orig_bytes;
24173 - ticket.bytes = orig_bytes;
24174 - ticket.error = 0;
24175 - init_waitqueue_head(&ticket.wait);
24176 -@@ -5279,25 +5288,21 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
24177 - return ret;
24178 -
24179 - if (flush == BTRFS_RESERVE_FLUSH_ALL)
24180 -- return wait_reserve_ticket(fs_info, space_info, &ticket,
24181 -- orig_bytes);
24182 -+ return wait_reserve_ticket(fs_info, space_info, &ticket);
24183 -
24184 - ret = 0;
24185 - priority_reclaim_metadata_space(fs_info, space_info, &ticket);
24186 - spin_lock(&space_info->lock);
24187 - if (ticket.bytes) {
24188 -- if (ticket.bytes < orig_bytes) {
24189 -- u64 num_bytes = orig_bytes - ticket.bytes;
24190 -- update_bytes_may_use(space_info, -num_bytes);
24191 -- trace_btrfs_space_reservation(fs_info, "space_info",
24192 -- space_info->flags,
24193 -- num_bytes, 0);
24194 --
24195 -- }
24196 -+ if (ticket.bytes < orig_bytes)
24197 -+ reclaim_bytes = orig_bytes - ticket.bytes;
24198 - list_del_init(&ticket.list);
24199 - ret = -ENOSPC;
24200 - }
24201 - spin_unlock(&space_info->lock);
24202 -+
24203 -+ if (reclaim_bytes)
24204 -+ space_info_add_old_bytes(fs_info, space_info, reclaim_bytes);
24205 - ASSERT(list_empty(&ticket.list));
24206 - return ret;
24207 - }
24208 -@@ -6115,7 +6120,7 @@ static void btrfs_calculate_inode_block_rsv_size(struct btrfs_fs_info *fs_info,
24209 - *
24210 - * This is overestimating in most cases.
24211 - */
24212 -- qgroup_rsv_size = outstanding_extents * fs_info->nodesize;
24213 -+ qgroup_rsv_size = (u64)outstanding_extents * fs_info->nodesize;
24214 -
24215 - spin_lock(&block_rsv->lock);
24216 - block_rsv->size = reserve_size;
24217 -@@ -8690,6 +8695,8 @@ struct walk_control {
24218 - u64 refs[BTRFS_MAX_LEVEL];
24219 - u64 flags[BTRFS_MAX_LEVEL];
24220 - struct btrfs_key update_progress;
24221 -+ struct btrfs_key drop_progress;
24222 -+ int drop_level;
24223 - int stage;
24224 - int level;
24225 - int shared_level;
24226 -@@ -9028,6 +9035,16 @@ skip:
24227 - ret);
24228 - }
24229 - }
24230 -+
24231 -+ /*
24232 -+ * We need to update the next key in our walk control so we can
24233 -+ * update the drop_progress key accordingly. We don't care if
24234 -+ * find_next_key doesn't find a key because that means we're at
24235 -+ * the end and are going to clean up now.
24236 -+ */
24237 -+ wc->drop_level = level;
24238 -+ find_next_key(path, level, &wc->drop_progress);
24239 -+
24240 - ret = btrfs_free_extent(trans, root, bytenr, fs_info->nodesize,
24241 - parent, root->root_key.objectid,
24242 - level - 1, 0);
24243 -@@ -9378,12 +9395,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
24244 - }
24245 -
24246 - if (wc->stage == DROP_REFERENCE) {
24247 -- level = wc->level;
24248 -- btrfs_node_key(path->nodes[level],
24249 -- &root_item->drop_progress,
24250 -- path->slots[level]);
24251 -- root_item->drop_level = level;
24252 -- }
24253 -+ wc->drop_level = wc->level;
24254 -+ btrfs_node_key_to_cpu(path->nodes[wc->drop_level],
24255 -+ &wc->drop_progress,
24256 -+ path->slots[wc->drop_level]);
24257 -+ }
24258 -+ btrfs_cpu_key_to_disk(&root_item->drop_progress,
24259 -+ &wc->drop_progress);
24260 -+ root_item->drop_level = wc->drop_level;
24261 -
24262 - BUG_ON(wc->level == 0);
24263 - if (btrfs_should_end_transaction(trans) ||
24264 -diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
24265 -index 52abe4082680..1bfb7207bbf0 100644
24266 ---- a/fs/btrfs/extent_io.c
24267 -+++ b/fs/btrfs/extent_io.c
24268 -@@ -2985,11 +2985,11 @@ static int __do_readpage(struct extent_io_tree *tree,
24269 - */
24270 - if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags) &&
24271 - prev_em_start && *prev_em_start != (u64)-1 &&
24272 -- *prev_em_start != em->orig_start)
24273 -+ *prev_em_start != em->start)
24274 - force_bio_submit = true;
24275 -
24276 - if (prev_em_start)
24277 -- *prev_em_start = em->orig_start;
24278 -+ *prev_em_start = em->start;
24279 -
24280 - free_extent_map(em);
24281 - em = NULL;
24282 -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
24283 -index 9c8e1734429c..1d64a6b8e413 100644
24284 ---- a/fs/btrfs/ioctl.c
24285 -+++ b/fs/btrfs/ioctl.c
24286 -@@ -501,6 +501,16 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
24287 - if (!capable(CAP_SYS_ADMIN))
24288 - return -EPERM;
24289 -
24290 -+ /*
24291 -+ * If the fs is mounted with nologreplay, which requires it to be
24292 -+ * mounted in RO mode as well, we can not allow discard on free space
24293 -+ * inside block groups, because log trees refer to extents that are not
24294 -+ * pinned in a block group's free space cache (pinning the extents is
24295 -+ * precisely the first phase of replaying a log tree).
24296 -+ */
24297 -+ if (btrfs_test_opt(fs_info, NOLOGREPLAY))
24298 -+ return -EROFS;
24299 -+
24300 - rcu_read_lock();
24301 - list_for_each_entry_rcu(device, &fs_info->fs_devices->devices,
24302 - dev_list) {
24303 -@@ -3206,21 +3216,6 @@ out:
24304 - return ret;
24305 - }
24306 -
24307 --static void btrfs_double_inode_unlock(struct inode *inode1, struct inode *inode2)
24308 --{
24309 -- inode_unlock(inode1);
24310 -- inode_unlock(inode2);
24311 --}
24312 --
24313 --static void btrfs_double_inode_lock(struct inode *inode1, struct inode *inode2)
24314 --{
24315 -- if (inode1 < inode2)
24316 -- swap(inode1, inode2);
24317 --
24318 -- inode_lock_nested(inode1, I_MUTEX_PARENT);
24319 -- inode_lock_nested(inode2, I_MUTEX_CHILD);
24320 --}
24321 --
24322 - static void btrfs_double_extent_unlock(struct inode *inode1, u64 loff1,
24323 - struct inode *inode2, u64 loff2, u64 len)
24324 - {
24325 -@@ -3989,7 +3984,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
24326 - if (same_inode)
24327 - inode_lock(inode_in);
24328 - else
24329 -- btrfs_double_inode_lock(inode_in, inode_out);
24330 -+ lock_two_nondirectories(inode_in, inode_out);
24331 -
24332 - /*
24333 - * Now that the inodes are locked, we need to start writeback ourselves
24334 -@@ -4039,7 +4034,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
24335 - if (same_inode)
24336 - inode_unlock(inode_in);
24337 - else
24338 -- btrfs_double_inode_unlock(inode_in, inode_out);
24339 -+ unlock_two_nondirectories(inode_in, inode_out);
24340 -
24341 - return ret;
24342 - }
24343 -@@ -4069,7 +4064,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
24344 - if (same_inode)
24345 - inode_unlock(src_inode);
24346 - else
24347 -- btrfs_double_inode_unlock(src_inode, dst_inode);
24348 -+ unlock_two_nondirectories(src_inode, dst_inode);
24349 -
24350 - return ret < 0 ? ret : len;
24351 - }
24352 -diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
24353 -index dc6140013ae8..61d22a56c0ba 100644
24354 ---- a/fs/btrfs/props.c
24355 -+++ b/fs/btrfs/props.c
24356 -@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
24357 -
24358 - static int prop_compression_validate(const char *value, size_t len)
24359 - {
24360 -- if (!strncmp("lzo", value, len))
24361 -+ if (!strncmp("lzo", value, 3))
24362 - return 0;
24363 -- else if (!strncmp("zlib", value, len))
24364 -+ else if (!strncmp("zlib", value, 4))
24365 - return 0;
24366 -- else if (!strncmp("zstd", value, len))
24367 -+ else if (!strncmp("zstd", value, 4))
24368 - return 0;
24369 -
24370 - return -EINVAL;
24371 -@@ -396,7 +396,7 @@ static int prop_compression_apply(struct inode *inode,
24372 - btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
24373 - } else if (!strncmp("zlib", value, 4)) {
24374 - type = BTRFS_COMPRESS_ZLIB;
24375 -- } else if (!strncmp("zstd", value, len)) {
24376 -+ } else if (!strncmp("zstd", value, 4)) {
24377 - type = BTRFS_COMPRESS_ZSTD;
24378 - btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD);
24379 - } else {
24380 -diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
24381 -index 4e473a998219..e28fb43e943b 100644
24382 ---- a/fs/btrfs/qgroup.c
24383 -+++ b/fs/btrfs/qgroup.c
24384 -@@ -1917,8 +1917,8 @@ static int qgroup_trace_new_subtree_blocks(struct btrfs_trans_handle* trans,
24385 - int i;
24386 -
24387 - /* Level sanity check */
24388 -- if (cur_level < 0 || cur_level >= BTRFS_MAX_LEVEL ||
24389 -- root_level < 0 || root_level >= BTRFS_MAX_LEVEL ||
24390 -+ if (cur_level < 0 || cur_level >= BTRFS_MAX_LEVEL - 1 ||
24391 -+ root_level < 0 || root_level >= BTRFS_MAX_LEVEL - 1 ||
24392 - root_level < cur_level) {
24393 - btrfs_err_rl(fs_info,
24394 - "%s: bad levels, cur_level=%d root_level=%d",
24395 -@@ -2842,16 +2842,15 @@ out:
24396 - /*
24397 - * Two limits to commit transaction in advance.
24398 - *
24399 -- * For RATIO, it will be 1/RATIO of the remaining limit
24400 -- * (excluding data and prealloc meta) as threshold.
24401 -+ * For RATIO, it will be 1/RATIO of the remaining limit as threshold.
24402 - * For SIZE, it will be in byte unit as threshold.
24403 - */
24404 --#define QGROUP_PERTRANS_RATIO 32
24405 --#define QGROUP_PERTRANS_SIZE SZ_32M
24406 -+#define QGROUP_FREE_RATIO 32
24407 -+#define QGROUP_FREE_SIZE SZ_32M
24408 - static bool qgroup_check_limits(struct btrfs_fs_info *fs_info,
24409 - const struct btrfs_qgroup *qg, u64 num_bytes)
24410 - {
24411 -- u64 limit;
24412 -+ u64 free;
24413 - u64 threshold;
24414 -
24415 - if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
24416 -@@ -2870,20 +2869,21 @@ static bool qgroup_check_limits(struct btrfs_fs_info *fs_info,
24417 - */
24418 - if ((qg->lim_flags & (BTRFS_QGROUP_LIMIT_MAX_RFER |
24419 - BTRFS_QGROUP_LIMIT_MAX_EXCL))) {
24420 -- if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL)
24421 -- limit = qg->max_excl;
24422 -- else
24423 -- limit = qg->max_rfer;
24424 -- threshold = (limit - qg->rsv.values[BTRFS_QGROUP_RSV_DATA] -
24425 -- qg->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC]) /
24426 -- QGROUP_PERTRANS_RATIO;
24427 -- threshold = min_t(u64, threshold, QGROUP_PERTRANS_SIZE);
24428 -+ if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) {
24429 -+ free = qg->max_excl - qgroup_rsv_total(qg) - qg->excl;
24430 -+ threshold = min_t(u64, qg->max_excl / QGROUP_FREE_RATIO,
24431 -+ QGROUP_FREE_SIZE);
24432 -+ } else {
24433 -+ free = qg->max_rfer - qgroup_rsv_total(qg) - qg->rfer;
24434 -+ threshold = min_t(u64, qg->max_rfer / QGROUP_FREE_RATIO,
24435 -+ QGROUP_FREE_SIZE);
24436 -+ }
24437 -
24438 - /*
24439 - * Use transaction_kthread to commit transaction, so we no
24440 - * longer need to bother nested transaction nor lock context.
24441 - */
24442 -- if (qg->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS] > threshold)
24443 -+ if (free < threshold)
24444 - btrfs_commit_transaction_locksafe(fs_info);
24445 - }
24446 -
24447 -diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
24448 -index e74455eb42f9..6976e2280771 100644
24449 ---- a/fs/btrfs/raid56.c
24450 -+++ b/fs/btrfs/raid56.c
24451 -@@ -2429,8 +2429,9 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
24452 - bitmap_clear(rbio->dbitmap, pagenr, 1);
24453 - kunmap(p);
24454 -
24455 -- for (stripe = 0; stripe < rbio->real_stripes; stripe++)
24456 -+ for (stripe = 0; stripe < nr_data; stripe++)
24457 - kunmap(page_in_rbio(rbio, stripe, pagenr, 0));
24458 -+ kunmap(p_page);
24459 - }
24460 -
24461 - __free_page(p_page);
24462 -diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
24463 -index 6dcd36d7b849..1aeac70d0531 100644
24464 ---- a/fs/btrfs/scrub.c
24465 -+++ b/fs/btrfs/scrub.c
24466 -@@ -584,6 +584,7 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
24467 - sctx->pages_per_rd_bio = SCRUB_PAGES_PER_RD_BIO;
24468 - sctx->curr = -1;
24469 - sctx->fs_info = fs_info;
24470 -+ INIT_LIST_HEAD(&sctx->csum_list);
24471 - for (i = 0; i < SCRUB_BIOS_PER_SCTX; ++i) {
24472 - struct scrub_bio *sbio;
24473 -
24474 -@@ -608,7 +609,6 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
24475 - atomic_set(&sctx->workers_pending, 0);
24476 - atomic_set(&sctx->cancel_req, 0);
24477 - sctx->csum_size = btrfs_super_csum_size(fs_info->super_copy);
24478 -- INIT_LIST_HEAD(&sctx->csum_list);
24479 -
24480 - spin_lock_init(&sctx->list_lock);
24481 - spin_lock_init(&sctx->stat_lock);
24482 -@@ -3770,16 +3770,6 @@ fail_scrub_workers:
24483 - return -ENOMEM;
24484 - }
24485 -
24486 --static noinline_for_stack void scrub_workers_put(struct btrfs_fs_info *fs_info)
24487 --{
24488 -- if (--fs_info->scrub_workers_refcnt == 0) {
24489 -- btrfs_destroy_workqueue(fs_info->scrub_workers);
24490 -- btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers);
24491 -- btrfs_destroy_workqueue(fs_info->scrub_parity_workers);
24492 -- }
24493 -- WARN_ON(fs_info->scrub_workers_refcnt < 0);
24494 --}
24495 --
24496 - int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
24497 - u64 end, struct btrfs_scrub_progress *progress,
24498 - int readonly, int is_dev_replace)
24499 -@@ -3788,6 +3778,9 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
24500 - int ret;
24501 - struct btrfs_device *dev;
24502 - unsigned int nofs_flag;
24503 -+ struct btrfs_workqueue *scrub_workers = NULL;
24504 -+ struct btrfs_workqueue *scrub_wr_comp = NULL;
24505 -+ struct btrfs_workqueue *scrub_parity = NULL;
24506 -
24507 - if (btrfs_fs_closing(fs_info))
24508 - return -EINVAL;
24509 -@@ -3927,9 +3920,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
24510 -
24511 - mutex_lock(&fs_info->scrub_lock);
24512 - dev->scrub_ctx = NULL;
24513 -- scrub_workers_put(fs_info);
24514 -+ if (--fs_info->scrub_workers_refcnt == 0) {
24515 -+ scrub_workers = fs_info->scrub_workers;
24516 -+ scrub_wr_comp = fs_info->scrub_wr_completion_workers;
24517 -+ scrub_parity = fs_info->scrub_parity_workers;
24518 -+ }
24519 - mutex_unlock(&fs_info->scrub_lock);
24520 -
24521 -+ btrfs_destroy_workqueue(scrub_workers);
24522 -+ btrfs_destroy_workqueue(scrub_wr_comp);
24523 -+ btrfs_destroy_workqueue(scrub_parity);
24524 - scrub_put_ctx(sctx);
24525 -
24526 - return ret;
24527 -diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
24528 -index ac232b3d6d7e..7f3b74a55073 100644
24529 ---- a/fs/btrfs/tree-log.c
24530 -+++ b/fs/btrfs/tree-log.c
24531 -@@ -3517,9 +3517,16 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
24532 - }
24533 - btrfs_release_path(path);
24534 -
24535 -- /* find the first key from this transaction again */
24536 -+ /*
24537 -+ * Find the first key from this transaction again. See the note for
24538 -+ * log_new_dir_dentries, if we're logging a directory recursively we
24539 -+ * won't be holding its i_mutex, which means we can modify the directory
24540 -+ * while we're logging it. If we remove an entry between our first
24541 -+ * search and this search we'll not find the key again and can just
24542 -+ * bail.
24543 -+ */
24544 - ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
24545 -- if (WARN_ON(ret != 0))
24546 -+ if (ret != 0)
24547 - goto done;
24548 -
24549 - /*
24550 -@@ -4481,6 +4488,19 @@ static int logged_inode_size(struct btrfs_root *log, struct btrfs_inode *inode,
24551 - item = btrfs_item_ptr(path->nodes[0], path->slots[0],
24552 - struct btrfs_inode_item);
24553 - *size_ret = btrfs_inode_size(path->nodes[0], item);
24554 -+ /*
24555 -+ * If the in-memory inode's i_size is smaller then the inode
24556 -+ * size stored in the btree, return the inode's i_size, so
24557 -+ * that we get a correct inode size after replaying the log
24558 -+ * when before a power failure we had a shrinking truncate
24559 -+ * followed by addition of a new name (rename / new hard link).
24560 -+ * Otherwise return the inode size from the btree, to avoid
24561 -+ * data loss when replaying a log due to previously doing a
24562 -+ * write that expands the inode's size and logging a new name
24563 -+ * immediately after.
24564 -+ */
24565 -+ if (*size_ret > inode->vfs_inode.i_size)
24566 -+ *size_ret = inode->vfs_inode.i_size;
24567 - }
24568 -
24569 - btrfs_release_path(path);
24570 -@@ -4642,15 +4662,8 @@ static int btrfs_log_trailing_hole(struct btrfs_trans_handle *trans,
24571 - struct btrfs_file_extent_item);
24572 -
24573 - if (btrfs_file_extent_type(leaf, extent) ==
24574 -- BTRFS_FILE_EXTENT_INLINE) {
24575 -- len = btrfs_file_extent_ram_bytes(leaf, extent);
24576 -- ASSERT(len == i_size ||
24577 -- (len == fs_info->sectorsize &&
24578 -- btrfs_file_extent_compression(leaf, extent) !=
24579 -- BTRFS_COMPRESS_NONE) ||
24580 -- (len < i_size && i_size < fs_info->sectorsize));
24581 -+ BTRFS_FILE_EXTENT_INLINE)
24582 - return 0;
24583 -- }
24584 -
24585 - len = btrfs_file_extent_num_bytes(leaf, extent);
24586 - /* Last extent goes beyond i_size, no need to log a hole. */
24587 -diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
24588 -index 15561926ab32..88a323a453d8 100644
24589 ---- a/fs/btrfs/volumes.c
24590 -+++ b/fs/btrfs/volumes.c
24591 -@@ -6413,7 +6413,7 @@ static void btrfs_end_bio(struct bio *bio)
24592 - if (bio_op(bio) == REQ_OP_WRITE)
24593 - btrfs_dev_stat_inc_and_print(dev,
24594 - BTRFS_DEV_STAT_WRITE_ERRS);
24595 -- else
24596 -+ else if (!(bio->bi_opf & REQ_RAHEAD))
24597 - btrfs_dev_stat_inc_and_print(dev,
24598 - BTRFS_DEV_STAT_READ_ERRS);
24599 - if (bio->bi_opf & REQ_PREFLUSH)
24600 -@@ -6782,10 +6782,10 @@ static int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
24601 - }
24602 -
24603 - if ((type & BTRFS_BLOCK_GROUP_RAID10 && sub_stripes != 2) ||
24604 -- (type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes < 1) ||
24605 -+ (type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes != 2) ||
24606 - (type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes < 2) ||
24607 - (type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) ||
24608 -- (type & BTRFS_BLOCK_GROUP_DUP && num_stripes > 2) ||
24609 -+ (type & BTRFS_BLOCK_GROUP_DUP && num_stripes != 2) ||
24610 - ((type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 &&
24611 - num_stripes != 1)) {
24612 - btrfs_err(fs_info,
24613 -diff --git a/fs/buffer.c b/fs/buffer.c
24614 -index 48318fb74938..cab7a026876b 100644
24615 ---- a/fs/buffer.c
24616 -+++ b/fs/buffer.c
24617 -@@ -3027,6 +3027,13 @@ void guard_bio_eod(int op, struct bio *bio)
24618 - /* Uhhuh. We've got a bio that straddles the device size! */
24619 - truncated_bytes = bio->bi_iter.bi_size - (maxsector << 9);
24620 -
24621 -+ /*
24622 -+ * The bio contains more than one segment which spans EOD, just return
24623 -+ * and let IO layer turn it into an EIO
24624 -+ */
24625 -+ if (truncated_bytes > bvec->bv_len)
24626 -+ return;
24627 -+
24628 - /* Truncate the bio.. */
24629 - bio->bi_iter.bi_size -= truncated_bytes;
24630 - bvec->bv_len -= truncated_bytes;
24631 -diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
24632 -index d9b99abe1243..5d83c924cc47 100644
24633 ---- a/fs/cifs/cifs_dfs_ref.c
24634 -+++ b/fs/cifs/cifs_dfs_ref.c
24635 -@@ -285,9 +285,9 @@ static void dump_referral(const struct dfs_info3_param *ref)
24636 - {
24637 - cifs_dbg(FYI, "DFS: ref path: %s\n", ref->path_name);
24638 - cifs_dbg(FYI, "DFS: node path: %s\n", ref->node_name);
24639 -- cifs_dbg(FYI, "DFS: fl: %hd, srv_type: %hd\n",
24640 -+ cifs_dbg(FYI, "DFS: fl: %d, srv_type: %d\n",
24641 - ref->flags, ref->server_type);
24642 -- cifs_dbg(FYI, "DFS: ref_flags: %hd, path_consumed: %hd\n",
24643 -+ cifs_dbg(FYI, "DFS: ref_flags: %d, path_consumed: %d\n",
24644 - ref->ref_flag, ref->path_consumed);
24645 - }
24646 -
24647 -diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
24648 -index 42f0d67f1054..ed49222abecb 100644
24649 ---- a/fs/cifs/cifs_fs_sb.h
24650 -+++ b/fs/cifs/cifs_fs_sb.h
24651 -@@ -58,6 +58,7 @@ struct cifs_sb_info {
24652 - spinlock_t tlink_tree_lock;
24653 - struct tcon_link *master_tlink;
24654 - struct nls_table *local_nls;
24655 -+ unsigned int bsize;
24656 - unsigned int rsize;
24657 - unsigned int wsize;
24658 - unsigned long actimeo; /* attribute cache timeout (jiffies) */
24659 -diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
24660 -index 62d48d486d8f..07cad54b84f1 100644
24661 ---- a/fs/cifs/cifsfs.c
24662 -+++ b/fs/cifs/cifsfs.c
24663 -@@ -554,10 +554,13 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
24664 -
24665 - seq_printf(s, ",rsize=%u", cifs_sb->rsize);
24666 - seq_printf(s, ",wsize=%u", cifs_sb->wsize);
24667 -+ seq_printf(s, ",bsize=%u", cifs_sb->bsize);
24668 - seq_printf(s, ",echo_interval=%lu",
24669 - tcon->ses->server->echo_interval / HZ);
24670 - if (tcon->snapshot_time)
24671 - seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
24672 -+ if (tcon->handle_timeout)
24673 -+ seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
24674 - /* convert actimeo and display it in seconds */
24675 - seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
24676 -
24677 -diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
24678 -index 94dbdbe5be34..6c934ab3722b 100644
24679 ---- a/fs/cifs/cifsglob.h
24680 -+++ b/fs/cifs/cifsglob.h
24681 -@@ -59,6 +59,12 @@
24682 - */
24683 - #define CIFS_MAX_ACTIMEO (1 << 30)
24684 -
24685 -+/*
24686 -+ * Max persistent and resilient handle timeout (milliseconds).
24687 -+ * Windows durable max was 960000 (16 minutes)
24688 -+ */
24689 -+#define SMB3_MAX_HANDLE_TIMEOUT 960000
24690 -+
24691 - /*
24692 - * MAX_REQ is the maximum number of requests that WE will send
24693 - * on one socket concurrently.
24694 -@@ -236,6 +242,8 @@ struct smb_version_operations {
24695 - int * (*get_credits_field)(struct TCP_Server_Info *, const int);
24696 - unsigned int (*get_credits)(struct mid_q_entry *);
24697 - __u64 (*get_next_mid)(struct TCP_Server_Info *);
24698 -+ void (*revert_current_mid)(struct TCP_Server_Info *server,
24699 -+ const unsigned int val);
24700 - /* data offset from read response message */
24701 - unsigned int (*read_data_offset)(char *);
24702 - /*
24703 -@@ -557,6 +565,7 @@ struct smb_vol {
24704 - bool resilient:1; /* noresilient not required since not fored for CA */
24705 - bool domainauto:1;
24706 - bool rdma:1;
24707 -+ unsigned int bsize;
24708 - unsigned int rsize;
24709 - unsigned int wsize;
24710 - bool sockopt_tcp_nodelay:1;
24711 -@@ -569,6 +578,7 @@ struct smb_vol {
24712 - struct nls_table *local_nls;
24713 - unsigned int echo_interval; /* echo interval in secs */
24714 - __u64 snapshot_time; /* needed for timewarp tokens */
24715 -+ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
24716 - unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
24717 - };
24718 -
24719 -@@ -770,6 +780,22 @@ get_next_mid(struct TCP_Server_Info *server)
24720 - return cpu_to_le16(mid);
24721 - }
24722 -
24723 -+static inline void
24724 -+revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
24725 -+{
24726 -+ if (server->ops->revert_current_mid)
24727 -+ server->ops->revert_current_mid(server, val);
24728 -+}
24729 -+
24730 -+static inline void
24731 -+revert_current_mid_from_hdr(struct TCP_Server_Info *server,
24732 -+ const struct smb2_sync_hdr *shdr)
24733 -+{
24734 -+ unsigned int num = le16_to_cpu(shdr->CreditCharge);
24735 -+
24736 -+ return revert_current_mid(server, num > 0 ? num : 1);
24737 -+}
24738 -+
24739 - static inline __u16
24740 - get_mid(const struct smb_hdr *smb)
24741 - {
24742 -@@ -1009,6 +1035,7 @@ struct cifs_tcon {
24743 - __u32 vol_serial_number;
24744 - __le64 vol_create_time;
24745 - __u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */
24746 -+ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
24747 - __u32 ss_flags; /* sector size flags */
24748 - __u32 perf_sector_size; /* best sector size for perf */
24749 - __u32 max_chunks;
24750 -@@ -1422,6 +1449,7 @@ struct mid_q_entry {
24751 - struct kref refcount;
24752 - struct TCP_Server_Info *server; /* server corresponding to this mid */
24753 - __u64 mid; /* multiplex id */
24754 -+ __u16 credits; /* number of credits consumed by this mid */
24755 - __u32 pid; /* process id */
24756 - __u32 sequence_number; /* for CIFS signing */
24757 - unsigned long when_alloc; /* when mid was created */
24758 -diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
24759 -index bb54ccf8481c..551924beb86f 100644
24760 ---- a/fs/cifs/cifssmb.c
24761 -+++ b/fs/cifs/cifssmb.c
24762 -@@ -2125,12 +2125,13 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
24763 -
24764 - wdata2->cfile = find_writable_file(CIFS_I(inode), false);
24765 - if (!wdata2->cfile) {
24766 -- cifs_dbg(VFS, "No writable handles for inode\n");
24767 -+ cifs_dbg(VFS, "No writable handle to retry writepages\n");
24768 - rc = -EBADF;
24769 -- break;
24770 -+ } else {
24771 -+ wdata2->pid = wdata2->cfile->pid;
24772 -+ rc = server->ops->async_writev(wdata2,
24773 -+ cifs_writedata_release);
24774 - }
24775 -- wdata2->pid = wdata2->cfile->pid;
24776 -- rc = server->ops->async_writev(wdata2, cifs_writedata_release);
24777 -
24778 - for (j = 0; j < nr_pages; j++) {
24779 - unlock_page(wdata2->pages[j]);
24780 -@@ -2145,6 +2146,7 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
24781 - kref_put(&wdata2->refcount, cifs_writedata_release);
24782 - if (is_retryable_error(rc))
24783 - continue;
24784 -+ i += nr_pages;
24785 - break;
24786 - }
24787 -
24788 -@@ -2152,6 +2154,13 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
24789 - i += nr_pages;
24790 - } while (i < wdata->nr_pages);
24791 -
24792 -+ /* cleanup remaining pages from the original wdata */
24793 -+ for (; i < wdata->nr_pages; i++) {
24794 -+ SetPageError(wdata->pages[i]);
24795 -+ end_page_writeback(wdata->pages[i]);
24796 -+ put_page(wdata->pages[i]);
24797 -+ }
24798 -+
24799 - if (rc != 0 && !is_retryable_error(rc))
24800 - mapping_set_error(inode->i_mapping, rc);
24801 - kref_put(&wdata->refcount, cifs_writedata_release);
24802 -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
24803 -index 8463c940e0e5..44e6ec85f832 100644
24804 ---- a/fs/cifs/connect.c
24805 -+++ b/fs/cifs/connect.c
24806 -@@ -102,8 +102,8 @@ enum {
24807 - Opt_backupuid, Opt_backupgid, Opt_uid,
24808 - Opt_cruid, Opt_gid, Opt_file_mode,
24809 - Opt_dirmode, Opt_port,
24810 -- Opt_rsize, Opt_wsize, Opt_actimeo,
24811 -- Opt_echo_interval, Opt_max_credits,
24812 -+ Opt_blocksize, Opt_rsize, Opt_wsize, Opt_actimeo,
24813 -+ Opt_echo_interval, Opt_max_credits, Opt_handletimeout,
24814 - Opt_snapshot,
24815 -
24816 - /* Mount options which take string value */
24817 -@@ -204,9 +204,11 @@ static const match_table_t cifs_mount_option_tokens = {
24818 - { Opt_dirmode, "dirmode=%s" },
24819 - { Opt_dirmode, "dir_mode=%s" },
24820 - { Opt_port, "port=%s" },
24821 -+ { Opt_blocksize, "bsize=%s" },
24822 - { Opt_rsize, "rsize=%s" },
24823 - { Opt_wsize, "wsize=%s" },
24824 - { Opt_actimeo, "actimeo=%s" },
24825 -+ { Opt_handletimeout, "handletimeout=%s" },
24826 - { Opt_echo_interval, "echo_interval=%s" },
24827 - { Opt_max_credits, "max_credits=%s" },
24828 - { Opt_snapshot, "snapshot=%s" },
24829 -@@ -1486,6 +1488,11 @@ cifs_parse_devname(const char *devname, struct smb_vol *vol)
24830 - const char *delims = "/\\";
24831 - size_t len;
24832 -
24833 -+ if (unlikely(!devname || !*devname)) {
24834 -+ cifs_dbg(VFS, "Device name not specified.\n");
24835 -+ return -EINVAL;
24836 -+ }
24837 -+
24838 - /* make sure we have a valid UNC double delimiter prefix */
24839 - len = strspn(devname, delims);
24840 - if (len != 2)
24841 -@@ -1571,7 +1578,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
24842 - vol->cred_uid = current_uid();
24843 - vol->linux_uid = current_uid();
24844 - vol->linux_gid = current_gid();
24845 --
24846 -+ vol->bsize = 1024 * 1024; /* can improve cp performance significantly */
24847 - /*
24848 - * default to SFM style remapping of seven reserved characters
24849 - * unless user overrides it or we negotiate CIFS POSIX where
24850 -@@ -1594,6 +1601,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
24851 -
24852 - vol->actimeo = CIFS_DEF_ACTIMEO;
24853 -
24854 -+ /* Most clients set timeout to 0, allows server to use its default */
24855 -+ vol->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */
24856 -+
24857 - /* offer SMB2.1 and later (SMB3 etc). Secure and widely accepted */
24858 - vol->ops = &smb30_operations;
24859 - vol->vals = &smbdefault_values;
24860 -@@ -1944,6 +1954,26 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
24861 - }
24862 - port = (unsigned short)option;
24863 - break;
24864 -+ case Opt_blocksize:
24865 -+ if (get_option_ul(args, &option)) {
24866 -+ cifs_dbg(VFS, "%s: Invalid blocksize value\n",
24867 -+ __func__);
24868 -+ goto cifs_parse_mount_err;
24869 -+ }
24870 -+ /*
24871 -+ * inode blocksize realistically should never need to be
24872 -+ * less than 16K or greater than 16M and default is 1MB.
24873 -+ * Note that small inode block sizes (e.g. 64K) can lead
24874 -+ * to very poor performance of common tools like cp and scp
24875 -+ */
24876 -+ if ((option < CIFS_MAX_MSGSIZE) ||
24877 -+ (option > (4 * SMB3_DEFAULT_IOSIZE))) {
24878 -+ cifs_dbg(VFS, "%s: Invalid blocksize\n",
24879 -+ __func__);
24880 -+ goto cifs_parse_mount_err;
24881 -+ }
24882 -+ vol->bsize = option;
24883 -+ break;
24884 - case Opt_rsize:
24885 - if (get_option_ul(args, &option)) {
24886 - cifs_dbg(VFS, "%s: Invalid rsize value\n",
24887 -@@ -1972,6 +2002,18 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
24888 - goto cifs_parse_mount_err;
24889 - }
24890 - break;
24891 -+ case Opt_handletimeout:
24892 -+ if (get_option_ul(args, &option)) {
24893 -+ cifs_dbg(VFS, "%s: Invalid handletimeout value\n",
24894 -+ __func__);
24895 -+ goto cifs_parse_mount_err;
24896 -+ }
24897 -+ vol->handle_timeout = option;
24898 -+ if (vol->handle_timeout > SMB3_MAX_HANDLE_TIMEOUT) {
24899 -+ cifs_dbg(VFS, "Invalid handle cache timeout, longer than 16 minutes\n");
24900 -+ goto cifs_parse_mount_err;
24901 -+ }
24902 -+ break;
24903 - case Opt_echo_interval:
24904 - if (get_option_ul(args, &option)) {
24905 - cifs_dbg(VFS, "%s: Invalid echo interval value\n",
24906 -@@ -3138,6 +3180,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info)
24907 - return 0;
24908 - if (tcon->snapshot_time != volume_info->snapshot_time)
24909 - return 0;
24910 -+ if (tcon->handle_timeout != volume_info->handle_timeout)
24911 -+ return 0;
24912 - return 1;
24913 - }
24914 -
24915 -@@ -3252,6 +3296,16 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
24916 - tcon->snapshot_time = volume_info->snapshot_time;
24917 - }
24918 -
24919 -+ if (volume_info->handle_timeout) {
24920 -+ if (ses->server->vals->protocol_id == 0) {
24921 -+ cifs_dbg(VFS,
24922 -+ "Use SMB2.1 or later for handle timeout option\n");
24923 -+ rc = -EOPNOTSUPP;
24924 -+ goto out_fail;
24925 -+ } else
24926 -+ tcon->handle_timeout = volume_info->handle_timeout;
24927 -+ }
24928 -+
24929 - tcon->ses = ses;
24930 - if (volume_info->password) {
24931 - tcon->password = kstrdup(volume_info->password, GFP_KERNEL);
24932 -@@ -3839,6 +3893,7 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
24933 - spin_lock_init(&cifs_sb->tlink_tree_lock);
24934 - cifs_sb->tlink_tree = RB_ROOT;
24935 -
24936 -+ cifs_sb->bsize = pvolume_info->bsize;
24937 - /*
24938 - * Temporarily set r/wsize for matching superblock. If we end up using
24939 - * new sb then client will later negotiate it downward if needed.
24940 -diff --git a/fs/cifs/file.c b/fs/cifs/file.c
24941 -index 659ce1b92c44..8d107587208f 100644
24942 ---- a/fs/cifs/file.c
24943 -+++ b/fs/cifs/file.c
24944 -@@ -1645,8 +1645,20 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
24945 - rc = server->ops->mand_unlock_range(cfile, flock, xid);
24946 -
24947 - out:
24948 -- if (flock->fl_flags & FL_POSIX && !rc)
24949 -+ if (flock->fl_flags & FL_POSIX) {
24950 -+ /*
24951 -+ * If this is a request to remove all locks because we
24952 -+ * are closing the file, it doesn't matter if the
24953 -+ * unlocking failed as both cifs.ko and the SMB server
24954 -+ * remove the lock on file close
24955 -+ */
24956 -+ if (rc) {
24957 -+ cifs_dbg(VFS, "%s failed rc=%d\n", __func__, rc);
24958 -+ if (!(flock->fl_flags & FL_CLOSE))
24959 -+ return rc;
24960 -+ }
24961 - rc = locks_lock_file_wait(file, flock);
24962 -+ }
24963 - return rc;
24964 - }
24965 -
24966 -@@ -3028,14 +3040,16 @@ cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
24967 - * these pages but not on the region from pos to ppos+len-1.
24968 - */
24969 - written = cifs_user_writev(iocb, from);
24970 -- if (written > 0 && CIFS_CACHE_READ(cinode)) {
24971 -+ if (CIFS_CACHE_READ(cinode)) {
24972 - /*
24973 -- * Windows 7 server can delay breaking level2 oplock if a write
24974 -- * request comes - break it on the client to prevent reading
24975 -- * an old data.
24976 -+ * We have read level caching and we have just sent a write
24977 -+ * request to the server thus making data in the cache stale.
24978 -+ * Zap the cache and set oplock/lease level to NONE to avoid
24979 -+ * reading stale data from the cache. All subsequent read
24980 -+ * operations will read new data from the server.
24981 - */
24982 - cifs_zap_mapping(inode);
24983 -- cifs_dbg(FYI, "Set no oplock for inode=%p after a write operation\n",
24984 -+ cifs_dbg(FYI, "Set Oplock/Lease to NONE for inode=%p after write\n",
24985 - inode);
24986 - cinode->oplock = 0;
24987 - }
24988 -diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
24989 -index 478003644916..53fdb5df0d2e 100644
24990 ---- a/fs/cifs/inode.c
24991 -+++ b/fs/cifs/inode.c
24992 -@@ -2080,7 +2080,7 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
24993 - return rc;
24994 -
24995 - generic_fillattr(inode, stat);
24996 -- stat->blksize = CIFS_MAX_MSGSIZE;
24997 -+ stat->blksize = cifs_sb->bsize;
24998 - stat->ino = CIFS_I(inode)->uniqueid;
24999 -
25000 - /* old CIFS Unix Extensions doesn't return create time */
25001 -diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
25002 -index 32a6c020478f..20a88776f04d 100644
25003 ---- a/fs/cifs/smb1ops.c
25004 -+++ b/fs/cifs/smb1ops.c
25005 -@@ -308,7 +308,7 @@ coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
25006 - remaining = tgt_total_cnt - total_in_tgt;
25007 -
25008 - if (remaining < 0) {
25009 -- cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%hu\n",
25010 -+ cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n",
25011 - tgt_total_cnt, total_in_tgt);
25012 - return -EPROTO;
25013 - }
25014 -diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
25015 -index b204e84b87fb..b0e76d27d752 100644
25016 ---- a/fs/cifs/smb2file.c
25017 -+++ b/fs/cifs/smb2file.c
25018 -@@ -68,7 +68,9 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
25019 -
25020 -
25021 - if (oparms->tcon->use_resilient) {
25022 -- nr_ioctl_req.Timeout = 0; /* use server default (120 seconds) */
25023 -+ /* default timeout is 0, servers pick default (120 seconds) */
25024 -+ nr_ioctl_req.Timeout =
25025 -+ cpu_to_le32(oparms->tcon->handle_timeout);
25026 - nr_ioctl_req.Reserved = 0;
25027 - rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid,
25028 - fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY,
25029 -diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
25030 -index 7b8b58fb4d3f..58700d2ba8cd 100644
25031 ---- a/fs/cifs/smb2misc.c
25032 -+++ b/fs/cifs/smb2misc.c
25033 -@@ -517,7 +517,6 @@ smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp,
25034 - __u8 lease_state;
25035 - struct list_head *tmp;
25036 - struct cifsFileInfo *cfile;
25037 -- struct TCP_Server_Info *server = tcon->ses->server;
25038 - struct cifs_pending_open *open;
25039 - struct cifsInodeInfo *cinode;
25040 - int ack_req = le32_to_cpu(rsp->Flags &
25041 -@@ -537,13 +536,25 @@ smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp,
25042 - cifs_dbg(FYI, "lease key match, lease break 0x%x\n",
25043 - le32_to_cpu(rsp->NewLeaseState));
25044 -
25045 -- server->ops->set_oplock_level(cinode, lease_state, 0, NULL);
25046 --
25047 - if (ack_req)
25048 - cfile->oplock_break_cancelled = false;
25049 - else
25050 - cfile->oplock_break_cancelled = true;
25051 -
25052 -+ set_bit(CIFS_INODE_PENDING_OPLOCK_BREAK, &cinode->flags);
25053 -+
25054 -+ /*
25055 -+ * Set or clear flags depending on the lease state being READ.
25056 -+ * HANDLE caching flag should be added when the client starts
25057 -+ * to defer closing remote file handles with HANDLE leases.
25058 -+ */
25059 -+ if (lease_state & SMB2_LEASE_READ_CACHING_HE)
25060 -+ set_bit(CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2,
25061 -+ &cinode->flags);
25062 -+ else
25063 -+ clear_bit(CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2,
25064 -+ &cinode->flags);
25065 -+
25066 - queue_work(cifsoplockd_wq, &cfile->oplock_break);
25067 - kfree(lw);
25068 - return true;
25069 -diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
25070 -index 6f96e2292856..b29f711ab965 100644
25071 ---- a/fs/cifs/smb2ops.c
25072 -+++ b/fs/cifs/smb2ops.c
25073 -@@ -219,6 +219,15 @@ smb2_get_next_mid(struct TCP_Server_Info *server)
25074 - return mid;
25075 - }
25076 -
25077 -+static void
25078 -+smb2_revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
25079 -+{
25080 -+ spin_lock(&GlobalMid_Lock);
25081 -+ if (server->CurrentMid >= val)
25082 -+ server->CurrentMid -= val;
25083 -+ spin_unlock(&GlobalMid_Lock);
25084 -+}
25085 -+
25086 - static struct mid_q_entry *
25087 - smb2_find_mid(struct TCP_Server_Info *server, char *buf)
25088 - {
25089 -@@ -2594,6 +2603,15 @@ smb2_downgrade_oplock(struct TCP_Server_Info *server,
25090 - server->ops->set_oplock_level(cinode, 0, 0, NULL);
25091 - }
25092 -
25093 -+static void
25094 -+smb21_downgrade_oplock(struct TCP_Server_Info *server,
25095 -+ struct cifsInodeInfo *cinode, bool set_level2)
25096 -+{
25097 -+ server->ops->set_oplock_level(cinode,
25098 -+ set_level2 ? SMB2_LEASE_READ_CACHING_HE :
25099 -+ 0, 0, NULL);
25100 -+}
25101 -+
25102 - static void
25103 - smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
25104 - unsigned int epoch, bool *purge_cache)
25105 -@@ -3541,6 +3559,7 @@ struct smb_version_operations smb20_operations = {
25106 - .get_credits = smb2_get_credits,
25107 - .wait_mtu_credits = cifs_wait_mtu_credits,
25108 - .get_next_mid = smb2_get_next_mid,
25109 -+ .revert_current_mid = smb2_revert_current_mid,
25110 - .read_data_offset = smb2_read_data_offset,
25111 - .read_data_length = smb2_read_data_length,
25112 - .map_error = map_smb2_to_linux_error,
25113 -@@ -3636,6 +3655,7 @@ struct smb_version_operations smb21_operations = {
25114 - .get_credits = smb2_get_credits,
25115 - .wait_mtu_credits = smb2_wait_mtu_credits,
25116 - .get_next_mid = smb2_get_next_mid,
25117 -+ .revert_current_mid = smb2_revert_current_mid,
25118 - .read_data_offset = smb2_read_data_offset,
25119 - .read_data_length = smb2_read_data_length,
25120 - .map_error = map_smb2_to_linux_error,
25121 -@@ -3646,7 +3666,7 @@ struct smb_version_operations smb21_operations = {
25122 - .print_stats = smb2_print_stats,
25123 - .is_oplock_break = smb2_is_valid_oplock_break,
25124 - .handle_cancelled_mid = smb2_handle_cancelled_mid,
25125 -- .downgrade_oplock = smb2_downgrade_oplock,
25126 -+ .downgrade_oplock = smb21_downgrade_oplock,
25127 - .need_neg = smb2_need_neg,
25128 - .negotiate = smb2_negotiate,
25129 - .negotiate_wsize = smb2_negotiate_wsize,
25130 -@@ -3732,6 +3752,7 @@ struct smb_version_operations smb30_operations = {
25131 - .get_credits = smb2_get_credits,
25132 - .wait_mtu_credits = smb2_wait_mtu_credits,
25133 - .get_next_mid = smb2_get_next_mid,
25134 -+ .revert_current_mid = smb2_revert_current_mid,
25135 - .read_data_offset = smb2_read_data_offset,
25136 - .read_data_length = smb2_read_data_length,
25137 - .map_error = map_smb2_to_linux_error,
25138 -@@ -3743,7 +3764,7 @@ struct smb_version_operations smb30_operations = {
25139 - .dump_share_caps = smb2_dump_share_caps,
25140 - .is_oplock_break = smb2_is_valid_oplock_break,
25141 - .handle_cancelled_mid = smb2_handle_cancelled_mid,
25142 -- .downgrade_oplock = smb2_downgrade_oplock,
25143 -+ .downgrade_oplock = smb21_downgrade_oplock,
25144 - .need_neg = smb2_need_neg,
25145 - .negotiate = smb2_negotiate,
25146 - .negotiate_wsize = smb3_negotiate_wsize,
25147 -@@ -3837,6 +3858,7 @@ struct smb_version_operations smb311_operations = {
25148 - .get_credits = smb2_get_credits,
25149 - .wait_mtu_credits = smb2_wait_mtu_credits,
25150 - .get_next_mid = smb2_get_next_mid,
25151 -+ .revert_current_mid = smb2_revert_current_mid,
25152 - .read_data_offset = smb2_read_data_offset,
25153 - .read_data_length = smb2_read_data_length,
25154 - .map_error = map_smb2_to_linux_error,
25155 -@@ -3848,7 +3870,7 @@ struct smb_version_operations smb311_operations = {
25156 - .dump_share_caps = smb2_dump_share_caps,
25157 - .is_oplock_break = smb2_is_valid_oplock_break,
25158 - .handle_cancelled_mid = smb2_handle_cancelled_mid,
25159 -- .downgrade_oplock = smb2_downgrade_oplock,
25160 -+ .downgrade_oplock = smb21_downgrade_oplock,
25161 - .need_neg = smb2_need_neg,
25162 - .negotiate = smb2_negotiate,
25163 - .negotiate_wsize = smb3_negotiate_wsize,
25164 -diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
25165 -index 77b3aaa39b35..068febe37fe4 100644
25166 ---- a/fs/cifs/smb2pdu.c
25167 -+++ b/fs/cifs/smb2pdu.c
25168 -@@ -986,8 +986,14 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
25169 - rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
25170 - FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
25171 - (char *)pneg_inbuf, inbuflen, (char **)&pneg_rsp, &rsplen);
25172 --
25173 -- if (rc != 0) {
25174 -+ if (rc == -EOPNOTSUPP) {
25175 -+ /*
25176 -+ * Old Windows versions or Netapp SMB server can return
25177 -+ * not supported error. Client should accept it.
25178 -+ */
25179 -+ cifs_dbg(VFS, "Server does not support validate negotiate\n");
25180 -+ return 0;
25181 -+ } else if (rc != 0) {
25182 - cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
25183 - rc = -EIO;
25184 - goto out_free_inbuf;
25185 -@@ -1605,9 +1611,16 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
25186 - iov[1].iov_base = unc_path;
25187 - iov[1].iov_len = unc_path_len;
25188 -
25189 -- /* 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1 */
25190 -+ /*
25191 -+ * 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1
25192 -+ * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
25193 -+ * (Samba servers don't always set the flag so also check if null user)
25194 -+ */
25195 - if ((ses->server->dialect == SMB311_PROT_ID) &&
25196 -- !smb3_encryption_required(tcon))
25197 -+ !smb3_encryption_required(tcon) &&
25198 -+ !(ses->session_flags &
25199 -+ (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
25200 -+ ((ses->user_name != NULL) || (ses->sectype == Kerberos)))
25201 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
25202 -
25203 - memset(&rqst, 0, sizeof(struct smb_rqst));
25204 -@@ -1824,8 +1837,9 @@ add_lease_context(struct TCP_Server_Info *server, struct kvec *iov,
25205 - }
25206 -
25207 - static struct create_durable_v2 *
25208 --create_durable_v2_buf(struct cifs_fid *pfid)
25209 -+create_durable_v2_buf(struct cifs_open_parms *oparms)
25210 - {
25211 -+ struct cifs_fid *pfid = oparms->fid;
25212 - struct create_durable_v2 *buf;
25213 -
25214 - buf = kzalloc(sizeof(struct create_durable_v2), GFP_KERNEL);
25215 -@@ -1839,7 +1853,14 @@ create_durable_v2_buf(struct cifs_fid *pfid)
25216 - (struct create_durable_v2, Name));
25217 - buf->ccontext.NameLength = cpu_to_le16(4);
25218 -
25219 -- buf->dcontext.Timeout = 0; /* Should this be configurable by workload */
25220 -+ /*
25221 -+ * NB: Handle timeout defaults to 0, which allows server to choose
25222 -+ * (most servers default to 120 seconds) and most clients default to 0.
25223 -+ * This can be overridden at mount ("handletimeout=") if the user wants
25224 -+ * a different persistent (or resilient) handle timeout for all opens
25225 -+ * opens on a particular SMB3 mount.
25226 -+ */
25227 -+ buf->dcontext.Timeout = cpu_to_le32(oparms->tcon->handle_timeout);
25228 - buf->dcontext.Flags = cpu_to_le32(SMB2_DHANDLE_FLAG_PERSISTENT);
25229 - generate_random_uuid(buf->dcontext.CreateGuid);
25230 - memcpy(pfid->create_guid, buf->dcontext.CreateGuid, 16);
25231 -@@ -1892,7 +1913,7 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec,
25232 - struct smb2_create_req *req = iov[0].iov_base;
25233 - unsigned int num = *num_iovec;
25234 -
25235 -- iov[num].iov_base = create_durable_v2_buf(oparms->fid);
25236 -+ iov[num].iov_base = create_durable_v2_buf(oparms);
25237 - if (iov[num].iov_base == NULL)
25238 - return -ENOMEM;
25239 - iov[num].iov_len = sizeof(struct create_durable_v2);
25240 -diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
25241 -index 7b351c65ee46..63264db78b89 100644
25242 ---- a/fs/cifs/smb2transport.c
25243 -+++ b/fs/cifs/smb2transport.c
25244 -@@ -576,6 +576,7 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
25245 - struct TCP_Server_Info *server)
25246 - {
25247 - struct mid_q_entry *temp;
25248 -+ unsigned int credits = le16_to_cpu(shdr->CreditCharge);
25249 -
25250 - if (server == NULL) {
25251 - cifs_dbg(VFS, "Null TCP session in smb2_mid_entry_alloc\n");
25252 -@@ -586,6 +587,7 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
25253 - memset(temp, 0, sizeof(struct mid_q_entry));
25254 - kref_init(&temp->refcount);
25255 - temp->mid = le64_to_cpu(shdr->MessageId);
25256 -+ temp->credits = credits > 0 ? credits : 1;
25257 - temp->pid = current->pid;
25258 - temp->command = shdr->Command; /* Always LE */
25259 - temp->when_alloc = jiffies;
25260 -@@ -674,13 +676,18 @@ smb2_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
25261 - smb2_seq_num_into_buf(ses->server, shdr);
25262 -
25263 - rc = smb2_get_mid_entry(ses, shdr, &mid);
25264 -- if (rc)
25265 -+ if (rc) {
25266 -+ revert_current_mid_from_hdr(ses->server, shdr);
25267 - return ERR_PTR(rc);
25268 -+ }
25269 -+
25270 - rc = smb2_sign_rqst(rqst, ses->server);
25271 - if (rc) {
25272 -+ revert_current_mid_from_hdr(ses->server, shdr);
25273 - cifs_delete_mid(mid);
25274 - return ERR_PTR(rc);
25275 - }
25276 -+
25277 - return mid;
25278 - }
25279 -
25280 -@@ -695,11 +702,14 @@ smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
25281 - smb2_seq_num_into_buf(server, shdr);
25282 -
25283 - mid = smb2_mid_entry_alloc(shdr, server);
25284 -- if (mid == NULL)
25285 -+ if (mid == NULL) {
25286 -+ revert_current_mid_from_hdr(server, shdr);
25287 - return ERR_PTR(-ENOMEM);
25288 -+ }
25289 -
25290 - rc = smb2_sign_rqst(rqst, server);
25291 - if (rc) {
25292 -+ revert_current_mid_from_hdr(server, shdr);
25293 - DeleteMidQEntry(mid);
25294 - return ERR_PTR(rc);
25295 - }
25296 -diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
25297 -index 53532bd3f50d..9544eb99b5a2 100644
25298 ---- a/fs/cifs/transport.c
25299 -+++ b/fs/cifs/transport.c
25300 -@@ -647,6 +647,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
25301 - cifs_in_send_dec(server);
25302 -
25303 - if (rc < 0) {
25304 -+ revert_current_mid(server, mid->credits);
25305 - server->sequence_number -= 2;
25306 - cifs_delete_mid(mid);
25307 - }
25308 -@@ -868,6 +869,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
25309 - for (i = 0; i < num_rqst; i++) {
25310 - midQ[i] = ses->server->ops->setup_request(ses, &rqst[i]);
25311 - if (IS_ERR(midQ[i])) {
25312 -+ revert_current_mid(ses->server, i);
25313 - for (j = 0; j < i; j++)
25314 - cifs_delete_mid(midQ[j]);
25315 - mutex_unlock(&ses->server->srv_mutex);
25316 -@@ -897,8 +899,10 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
25317 - for (i = 0; i < num_rqst; i++)
25318 - cifs_save_when_sent(midQ[i]);
25319 -
25320 -- if (rc < 0)
25321 -+ if (rc < 0) {
25322 -+ revert_current_mid(ses->server, num_rqst);
25323 - ses->server->sequence_number -= 2;
25324 -+ }
25325 -
25326 - mutex_unlock(&ses->server->srv_mutex);
25327 -
25328 -diff --git a/fs/dax.c b/fs/dax.c
25329 -index 6959837cc465..05cca2214ae3 100644
25330 ---- a/fs/dax.c
25331 -+++ b/fs/dax.c
25332 -@@ -843,9 +843,8 @@ unlock_pte:
25333 - static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
25334 - struct address_space *mapping, void *entry)
25335 - {
25336 -- unsigned long pfn;
25337 -+ unsigned long pfn, index, count;
25338 - long ret = 0;
25339 -- size_t size;
25340 -
25341 - /*
25342 - * A page got tagged dirty in DAX mapping? Something is seriously
25343 -@@ -894,17 +893,18 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
25344 - xas_unlock_irq(xas);
25345 -
25346 - /*
25347 -- * Even if dax_writeback_mapping_range() was given a wbc->range_start
25348 -- * in the middle of a PMD, the 'index' we are given will be aligned to
25349 -- * the start index of the PMD, as will the pfn we pull from 'entry'.
25350 -+ * If dax_writeback_mapping_range() was given a wbc->range_start
25351 -+ * in the middle of a PMD, the 'index' we use needs to be
25352 -+ * aligned to the start of the PMD.
25353 - * This allows us to flush for PMD_SIZE and not have to worry about
25354 - * partial PMD writebacks.
25355 - */
25356 - pfn = dax_to_pfn(entry);
25357 -- size = PAGE_SIZE << dax_entry_order(entry);
25358 -+ count = 1UL << dax_entry_order(entry);
25359 -+ index = xas->xa_index & ~(count - 1);
25360 -
25361 -- dax_entry_mkclean(mapping, xas->xa_index, pfn);
25362 -- dax_flush(dax_dev, page_address(pfn_to_page(pfn)), size);
25363 -+ dax_entry_mkclean(mapping, index, pfn);
25364 -+ dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE);
25365 - /*
25366 - * After we have flushed the cache, we can clear the dirty tag. There
25367 - * cannot be new dirty data in the pfn after the flush has completed as
25368 -@@ -917,8 +917,7 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
25369 - xas_clear_mark(xas, PAGECACHE_TAG_DIRTY);
25370 - dax_wake_entry(xas, entry, false);
25371 -
25372 -- trace_dax_writeback_one(mapping->host, xas->xa_index,
25373 -- size >> PAGE_SHIFT);
25374 -+ trace_dax_writeback_one(mapping->host, index, count);
25375 - return ret;
25376 -
25377 - put_unlocked:
25378 -diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
25379 -index c53814539070..553a3f3300ae 100644
25380 ---- a/fs/devpts/inode.c
25381 -+++ b/fs/devpts/inode.c
25382 -@@ -455,6 +455,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
25383 - s->s_blocksize_bits = 10;
25384 - s->s_magic = DEVPTS_SUPER_MAGIC;
25385 - s->s_op = &devpts_sops;
25386 -+ s->s_d_op = &simple_dentry_operations;
25387 - s->s_time_gran = 1;
25388 -
25389 - error = -ENOMEM;
25390 -diff --git a/fs/exec.c b/fs/exec.c
25391 -index fb72d36f7823..bcf383730bea 100644
25392 ---- a/fs/exec.c
25393 -+++ b/fs/exec.c
25394 -@@ -932,7 +932,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
25395 - bytes = kernel_read(file, *buf + pos, i_size - pos, &pos);
25396 - if (bytes < 0) {
25397 - ret = bytes;
25398 -- goto out;
25399 -+ goto out_free;
25400 - }
25401 -
25402 - if (bytes == 0)
25403 -diff --git a/fs/ext2/super.c b/fs/ext2/super.c
25404 -index 73b2d528237f..a9ea38182578 100644
25405 ---- a/fs/ext2/super.c
25406 -+++ b/fs/ext2/super.c
25407 -@@ -757,7 +757,8 @@ static loff_t ext2_max_size(int bits)
25408 - {
25409 - loff_t res = EXT2_NDIR_BLOCKS;
25410 - int meta_blocks;
25411 -- loff_t upper_limit;
25412 -+ unsigned int upper_limit;
25413 -+ unsigned int ppb = 1 << (bits-2);
25414 -
25415 - /* This is calculated to be the largest file size for a
25416 - * dense, file such that the total number of
25417 -@@ -771,24 +772,34 @@ static loff_t ext2_max_size(int bits)
25418 - /* total blocks in file system block size */
25419 - upper_limit >>= (bits - 9);
25420 -
25421 -+ /* Compute how many blocks we can address by block tree */
25422 -+ res += 1LL << (bits-2);
25423 -+ res += 1LL << (2*(bits-2));
25424 -+ res += 1LL << (3*(bits-2));
25425 -+ /* Does block tree limit file size? */
25426 -+ if (res < upper_limit)
25427 -+ goto check_lfs;
25428 -
25429 -+ res = upper_limit;
25430 -+ /* How many metadata blocks are needed for addressing upper_limit? */
25431 -+ upper_limit -= EXT2_NDIR_BLOCKS;
25432 - /* indirect blocks */
25433 - meta_blocks = 1;
25434 -+ upper_limit -= ppb;
25435 - /* double indirect blocks */
25436 -- meta_blocks += 1 + (1LL << (bits-2));
25437 -- /* tripple indirect blocks */
25438 -- meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2)));
25439 --
25440 -- upper_limit -= meta_blocks;
25441 -- upper_limit <<= bits;
25442 --
25443 -- res += 1LL << (bits-2);
25444 -- res += 1LL << (2*(bits-2));
25445 -- res += 1LL << (3*(bits-2));
25446 -+ if (upper_limit < ppb * ppb) {
25447 -+ meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb);
25448 -+ res -= meta_blocks;
25449 -+ goto check_lfs;
25450 -+ }
25451 -+ meta_blocks += 1 + ppb;
25452 -+ upper_limit -= ppb * ppb;
25453 -+ /* tripple indirect blocks for the rest */
25454 -+ meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) +
25455 -+ DIV_ROUND_UP(upper_limit, ppb*ppb);
25456 -+ res -= meta_blocks;
25457 -+check_lfs:
25458 - res <<= bits;
25459 -- if (res > upper_limit)
25460 -- res = upper_limit;
25461 --
25462 - if (res > MAX_LFS_FILESIZE)
25463 - res = MAX_LFS_FILESIZE;
25464 -
25465 -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
25466 -index 185a05d3257e..508a37ec9271 100644
25467 ---- a/fs/ext4/ext4.h
25468 -+++ b/fs/ext4/ext4.h
25469 -@@ -426,6 +426,9 @@ struct flex_groups {
25470 - /* Flags that are appropriate for non-directories/regular files. */
25471 - #define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
25472 -
25473 -+/* The only flags that should be swapped */
25474 -+#define EXT4_FL_SHOULD_SWAP (EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL)
25475 -+
25476 - /* Mask out flags that are inappropriate for the given type of inode. */
25477 - static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
25478 - {
25479 -diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
25480 -index 15b6dd733780..df908ef79cce 100644
25481 ---- a/fs/ext4/ext4_jbd2.h
25482 -+++ b/fs/ext4/ext4_jbd2.h
25483 -@@ -384,7 +384,7 @@ static inline void ext4_update_inode_fsync_trans(handle_t *handle,
25484 - {
25485 - struct ext4_inode_info *ei = EXT4_I(inode);
25486 -
25487 -- if (ext4_handle_valid(handle)) {
25488 -+ if (ext4_handle_valid(handle) && !is_handle_aborted(handle)) {
25489 - ei->i_sync_tid = handle->h_transaction->t_tid;
25490 - if (datasync)
25491 - ei->i_datasync_tid = handle->h_transaction->t_tid;
25492 -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
25493 -index 240b6dea5441..252bbbb5a2f4 100644
25494 ---- a/fs/ext4/extents.c
25495 -+++ b/fs/ext4/extents.c
25496 -@@ -2956,14 +2956,17 @@ again:
25497 - if (err < 0)
25498 - goto out;
25499 -
25500 -- } else if (sbi->s_cluster_ratio > 1 && end >= ex_end) {
25501 -+ } else if (sbi->s_cluster_ratio > 1 && end >= ex_end &&
25502 -+ partial.state == initial) {
25503 - /*
25504 -- * If there's an extent to the right its first cluster
25505 -- * contains the immediate right boundary of the
25506 -- * truncated/punched region. Set partial_cluster to
25507 -- * its negative value so it won't be freed if shared
25508 -- * with the current extent. The end < ee_block case
25509 -- * is handled in ext4_ext_rm_leaf().
25510 -+ * If we're punching, there's an extent to the right.
25511 -+ * If the partial cluster hasn't been set, set it to
25512 -+ * that extent's first cluster and its state to nofree
25513 -+ * so it won't be freed should it contain blocks to be
25514 -+ * removed. If it's already set (tofree/nofree), we're
25515 -+ * retrying and keep the original partial cluster info
25516 -+ * so a cluster marked tofree as a result of earlier
25517 -+ * extent removal is not lost.
25518 - */
25519 - lblk = ex_end + 1;
25520 - err = ext4_ext_search_right(inode, path, &lblk, &pblk,
25521 -diff --git a/fs/ext4/file.c b/fs/ext4/file.c
25522 -index 69d65d49837b..98ec11f69cd4 100644
25523 ---- a/fs/ext4/file.c
25524 -+++ b/fs/ext4/file.c
25525 -@@ -125,7 +125,7 @@ ext4_unaligned_aio(struct inode *inode, struct iov_iter *from, loff_t pos)
25526 - struct super_block *sb = inode->i_sb;
25527 - int blockmask = sb->s_blocksize - 1;
25528 -
25529 -- if (pos >= i_size_read(inode))
25530 -+ if (pos >= ALIGN(i_size_read(inode), sb->s_blocksize))
25531 - return 0;
25532 -
25533 - if ((pos | iov_iter_alignment(from)) & blockmask)
25534 -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
25535 -index bf7fa1507e81..e1801b288847 100644
25536 ---- a/fs/ext4/indirect.c
25537 -+++ b/fs/ext4/indirect.c
25538 -@@ -1219,6 +1219,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
25539 - ext4_lblk_t offsets[4], offsets2[4];
25540 - Indirect chain[4], chain2[4];
25541 - Indirect *partial, *partial2;
25542 -+ Indirect *p = NULL, *p2 = NULL;
25543 - ext4_lblk_t max_block;
25544 - __le32 nr = 0, nr2 = 0;
25545 - int n = 0, n2 = 0;
25546 -@@ -1260,7 +1261,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
25547 - }
25548 -
25549 -
25550 -- partial = ext4_find_shared(inode, n, offsets, chain, &nr);
25551 -+ partial = p = ext4_find_shared(inode, n, offsets, chain, &nr);
25552 - if (nr) {
25553 - if (partial == chain) {
25554 - /* Shared branch grows from the inode */
25555 -@@ -1285,13 +1286,11 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
25556 - partial->p + 1,
25557 - (__le32 *)partial->bh->b_data+addr_per_block,
25558 - (chain+n-1) - partial);
25559 -- BUFFER_TRACE(partial->bh, "call brelse");
25560 -- brelse(partial->bh);
25561 - partial--;
25562 - }
25563 -
25564 - end_range:
25565 -- partial2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
25566 -+ partial2 = p2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
25567 - if (nr2) {
25568 - if (partial2 == chain2) {
25569 - /*
25570 -@@ -1321,16 +1320,14 @@ end_range:
25571 - (__le32 *)partial2->bh->b_data,
25572 - partial2->p,
25573 - (chain2+n2-1) - partial2);
25574 -- BUFFER_TRACE(partial2->bh, "call brelse");
25575 -- brelse(partial2->bh);
25576 - partial2--;
25577 - }
25578 - goto do_indirects;
25579 - }
25580 -
25581 - /* Punch happened within the same level (n == n2) */
25582 -- partial = ext4_find_shared(inode, n, offsets, chain, &nr);
25583 -- partial2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
25584 -+ partial = p = ext4_find_shared(inode, n, offsets, chain, &nr);
25585 -+ partial2 = p2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
25586 -
25587 - /* Free top, but only if partial2 isn't its subtree. */
25588 - if (nr) {
25589 -@@ -1387,11 +1384,7 @@ end_range:
25590 - partial->p + 1,
25591 - partial2->p,
25592 - (chain+n-1) - partial);
25593 -- BUFFER_TRACE(partial->bh, "call brelse");
25594 -- brelse(partial->bh);
25595 -- BUFFER_TRACE(partial2->bh, "call brelse");
25596 -- brelse(partial2->bh);
25597 -- return 0;
25598 -+ goto cleanup;
25599 - }
25600 -
25601 - /*
25602 -@@ -1406,8 +1399,6 @@ end_range:
25603 - partial->p + 1,
25604 - (__le32 *)partial->bh->b_data+addr_per_block,
25605 - (chain+n-1) - partial);
25606 -- BUFFER_TRACE(partial->bh, "call brelse");
25607 -- brelse(partial->bh);
25608 - partial--;
25609 - }
25610 - if (partial2 > chain2 && depth2 <= depth) {
25611 -@@ -1415,11 +1406,21 @@ end_range:
25612 - (__le32 *)partial2->bh->b_data,
25613 - partial2->p,
25614 - (chain2+n2-1) - partial2);
25615 -- BUFFER_TRACE(partial2->bh, "call brelse");
25616 -- brelse(partial2->bh);
25617 - partial2--;
25618 - }
25619 - }
25620 -+
25621 -+cleanup:
25622 -+ while (p && p > chain) {
25623 -+ BUFFER_TRACE(p->bh, "call brelse");
25624 -+ brelse(p->bh);
25625 -+ p--;
25626 -+ }
25627 -+ while (p2 && p2 > chain2) {
25628 -+ BUFFER_TRACE(p2->bh, "call brelse");
25629 -+ brelse(p2->bh);
25630 -+ p2--;
25631 -+ }
25632 - return 0;
25633 -
25634 - do_indirects:
25635 -@@ -1427,7 +1428,7 @@ do_indirects:
25636 - switch (offsets[0]) {
25637 - default:
25638 - if (++n >= n2)
25639 -- return 0;
25640 -+ break;
25641 - nr = i_data[EXT4_IND_BLOCK];
25642 - if (nr) {
25643 - ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
25644 -@@ -1435,7 +1436,7 @@ do_indirects:
25645 - }
25646 - case EXT4_IND_BLOCK:
25647 - if (++n >= n2)
25648 -- return 0;
25649 -+ break;
25650 - nr = i_data[EXT4_DIND_BLOCK];
25651 - if (nr) {
25652 - ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
25653 -@@ -1443,7 +1444,7 @@ do_indirects:
25654 - }
25655 - case EXT4_DIND_BLOCK:
25656 - if (++n >= n2)
25657 -- return 0;
25658 -+ break;
25659 - nr = i_data[EXT4_TIND_BLOCK];
25660 - if (nr) {
25661 - ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
25662 -@@ -1452,5 +1453,5 @@ do_indirects:
25663 - case EXT4_TIND_BLOCK:
25664 - ;
25665 - }
25666 -- return 0;
25667 -+ goto cleanup;
25668 - }
25669 -diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
25670 -index d37dafa1d133..2e76fb55d94a 100644
25671 ---- a/fs/ext4/ioctl.c
25672 -+++ b/fs/ext4/ioctl.c
25673 -@@ -63,18 +63,20 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
25674 - loff_t isize;
25675 - struct ext4_inode_info *ei1;
25676 - struct ext4_inode_info *ei2;
25677 -+ unsigned long tmp;
25678 -
25679 - ei1 = EXT4_I(inode1);
25680 - ei2 = EXT4_I(inode2);
25681 -
25682 - swap(inode1->i_version, inode2->i_version);
25683 -- swap(inode1->i_blocks, inode2->i_blocks);
25684 -- swap(inode1->i_bytes, inode2->i_bytes);
25685 - swap(inode1->i_atime, inode2->i_atime);
25686 - swap(inode1->i_mtime, inode2->i_mtime);
25687 -
25688 - memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
25689 -- swap(ei1->i_flags, ei2->i_flags);
25690 -+ tmp = ei1->i_flags & EXT4_FL_SHOULD_SWAP;
25691 -+ ei1->i_flags = (ei2->i_flags & EXT4_FL_SHOULD_SWAP) |
25692 -+ (ei1->i_flags & ~EXT4_FL_SHOULD_SWAP);
25693 -+ ei2->i_flags = tmp | (ei2->i_flags & ~EXT4_FL_SHOULD_SWAP);
25694 - swap(ei1->i_disksize, ei2->i_disksize);
25695 - ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
25696 - ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
25697 -@@ -115,28 +117,41 @@ static long swap_inode_boot_loader(struct super_block *sb,
25698 - int err;
25699 - struct inode *inode_bl;
25700 - struct ext4_inode_info *ei_bl;
25701 --
25702 -- if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
25703 -- IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
25704 -- ext4_has_inline_data(inode))
25705 -- return -EINVAL;
25706 --
25707 -- if (IS_RDONLY(inode) || IS_APPEND(inode) || IS_IMMUTABLE(inode) ||
25708 -- !inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
25709 -- return -EPERM;
25710 -+ qsize_t size, size_bl, diff;
25711 -+ blkcnt_t blocks;
25712 -+ unsigned short bytes;
25713 -
25714 - inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO, EXT4_IGET_SPECIAL);
25715 - if (IS_ERR(inode_bl))
25716 - return PTR_ERR(inode_bl);
25717 - ei_bl = EXT4_I(inode_bl);
25718 -
25719 -- filemap_flush(inode->i_mapping);
25720 -- filemap_flush(inode_bl->i_mapping);
25721 --
25722 - /* Protect orig inodes against a truncate and make sure,
25723 - * that only 1 swap_inode_boot_loader is running. */
25724 - lock_two_nondirectories(inode, inode_bl);
25725 -
25726 -+ if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
25727 -+ IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
25728 -+ ext4_has_inline_data(inode)) {
25729 -+ err = -EINVAL;
25730 -+ goto journal_err_out;
25731 -+ }
25732 -+
25733 -+ if (IS_RDONLY(inode) || IS_APPEND(inode) || IS_IMMUTABLE(inode) ||
25734 -+ !inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) {
25735 -+ err = -EPERM;
25736 -+ goto journal_err_out;
25737 -+ }
25738 -+
25739 -+ down_write(&EXT4_I(inode)->i_mmap_sem);
25740 -+ err = filemap_write_and_wait(inode->i_mapping);
25741 -+ if (err)
25742 -+ goto err_out;
25743 -+
25744 -+ err = filemap_write_and_wait(inode_bl->i_mapping);
25745 -+ if (err)
25746 -+ goto err_out;
25747 -+
25748 - /* Wait for all existing dio workers */
25749 - inode_dio_wait(inode);
25750 - inode_dio_wait(inode_bl);
25751 -@@ -147,7 +162,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
25752 - handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);
25753 - if (IS_ERR(handle)) {
25754 - err = -EINVAL;
25755 -- goto journal_err_out;
25756 -+ goto err_out;
25757 - }
25758 -
25759 - /* Protect extent tree against block allocations via delalloc */
25760 -@@ -170,6 +185,13 @@ static long swap_inode_boot_loader(struct super_block *sb,
25761 - memset(ei_bl->i_data, 0, sizeof(ei_bl->i_data));
25762 - }
25763 -
25764 -+ err = dquot_initialize(inode);
25765 -+ if (err)
25766 -+ goto err_out1;
25767 -+
25768 -+ size = (qsize_t)(inode->i_blocks) * (1 << 9) + inode->i_bytes;
25769 -+ size_bl = (qsize_t)(inode_bl->i_blocks) * (1 << 9) + inode_bl->i_bytes;
25770 -+ diff = size - size_bl;
25771 - swap_inode_data(inode, inode_bl);
25772 -
25773 - inode->i_ctime = inode_bl->i_ctime = current_time(inode);
25774 -@@ -183,27 +205,51 @@ static long swap_inode_boot_loader(struct super_block *sb,
25775 -
25776 - err = ext4_mark_inode_dirty(handle, inode);
25777 - if (err < 0) {
25778 -+ /* No need to update quota information. */
25779 - ext4_warning(inode->i_sb,
25780 - "couldn't mark inode #%lu dirty (err %d)",
25781 - inode->i_ino, err);
25782 - /* Revert all changes: */
25783 - swap_inode_data(inode, inode_bl);
25784 - ext4_mark_inode_dirty(handle, inode);
25785 -- } else {
25786 -- err = ext4_mark_inode_dirty(handle, inode_bl);
25787 -- if (err < 0) {
25788 -- ext4_warning(inode_bl->i_sb,
25789 -- "couldn't mark inode #%lu dirty (err %d)",
25790 -- inode_bl->i_ino, err);
25791 -- /* Revert all changes: */
25792 -- swap_inode_data(inode, inode_bl);
25793 -- ext4_mark_inode_dirty(handle, inode);
25794 -- ext4_mark_inode_dirty(handle, inode_bl);
25795 -- }
25796 -+ goto err_out1;
25797 -+ }
25798 -+
25799 -+ blocks = inode_bl->i_blocks;
25800 -+ bytes = inode_bl->i_bytes;
25801 -+ inode_bl->i_blocks = inode->i_blocks;
25802 -+ inode_bl->i_bytes = inode->i_bytes;
25803 -+ err = ext4_mark_inode_dirty(handle, inode_bl);
25804 -+ if (err < 0) {
25805 -+ /* No need to update quota information. */
25806 -+ ext4_warning(inode_bl->i_sb,
25807 -+ "couldn't mark inode #%lu dirty (err %d)",
25808 -+ inode_bl->i_ino, err);
25809 -+ goto revert;
25810 -+ }
25811 -+
25812 -+ /* Bootloader inode should not be counted into quota information. */
25813 -+ if (diff > 0)
25814 -+ dquot_free_space(inode, diff);
25815 -+ else
25816 -+ err = dquot_alloc_space(inode, -1 * diff);
25817 -+
25818 -+ if (err < 0) {
25819 -+revert:
25820 -+ /* Revert all changes: */
25821 -+ inode_bl->i_blocks = blocks;
25822 -+ inode_bl->i_bytes = bytes;
25823 -+ swap_inode_data(inode, inode_bl);
25824 -+ ext4_mark_inode_dirty(handle, inode);
25825 -+ ext4_mark_inode_dirty(handle, inode_bl);
25826 - }
25827 -+
25828 -+err_out1:
25829 - ext4_journal_stop(handle);
25830 - ext4_double_up_write_data_sem(inode, inode_bl);
25831 -
25832 -+err_out:
25833 -+ up_write(&EXT4_I(inode)->i_mmap_sem);
25834 - journal_err_out:
25835 - unlock_two_nondirectories(inode, inode_bl);
25836 - iput(inode_bl);
25837 -diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
25838 -index 48421de803b7..3d9b18505c0c 100644
25839 ---- a/fs/ext4/resize.c
25840 -+++ b/fs/ext4/resize.c
25841 -@@ -1960,7 +1960,8 @@ retry:
25842 - le16_to_cpu(es->s_reserved_gdt_blocks);
25843 - n_group = n_desc_blocks * EXT4_DESC_PER_BLOCK(sb);
25844 - n_blocks_count = (ext4_fsblk_t)n_group *
25845 -- EXT4_BLOCKS_PER_GROUP(sb);
25846 -+ EXT4_BLOCKS_PER_GROUP(sb) +
25847 -+ le32_to_cpu(es->s_first_data_block);
25848 - n_group--; /* set to last group number */
25849 - }
25850 -
25851 -diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
25852 -index 1cb0fcc67d2d..caf77fe8ac07 100644
25853 ---- a/fs/f2fs/extent_cache.c
25854 -+++ b/fs/f2fs/extent_cache.c
25855 -@@ -506,7 +506,7 @@ static void f2fs_update_extent_tree_range(struct inode *inode,
25856 - unsigned int end = fofs + len;
25857 - unsigned int pos = (unsigned int)fofs;
25858 - bool updated = false;
25859 -- bool leftmost;
25860 -+ bool leftmost = false;
25861 -
25862 - if (!et)
25863 - return;
25864 -diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
25865 -index 12fabd6735dd..279bc00489cc 100644
25866 ---- a/fs/f2fs/f2fs.h
25867 -+++ b/fs/f2fs/f2fs.h
25868 -@@ -456,7 +456,6 @@ struct f2fs_flush_device {
25869 -
25870 - /* for inline stuff */
25871 - #define DEF_INLINE_RESERVED_SIZE 1
25872 --#define DEF_MIN_INLINE_SIZE 1
25873 - static inline int get_extra_isize(struct inode *inode);
25874 - static inline int get_inline_xattr_addrs(struct inode *inode);
25875 - #define MAX_INLINE_DATA(inode) (sizeof(__le32) * \
25876 -diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
25877 -index bba56b39dcc5..ae2b45e75847 100644
25878 ---- a/fs/f2fs/file.c
25879 -+++ b/fs/f2fs/file.c
25880 -@@ -1750,10 +1750,12 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
25881 -
25882 - down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
25883 -
25884 -- if (!get_dirty_pages(inode))
25885 -- goto skip_flush;
25886 --
25887 -- f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING,
25888 -+ /*
25889 -+ * Should wait end_io to count F2FS_WB_CP_DATA correctly by
25890 -+ * f2fs_is_atomic_file.
25891 -+ */
25892 -+ if (get_dirty_pages(inode))
25893 -+ f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING,
25894 - "Unexpected flush for atomic writes: ino=%lu, npages=%u",
25895 - inode->i_ino, get_dirty_pages(inode));
25896 - ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
25897 -@@ -1761,7 +1763,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
25898 - up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
25899 - goto out;
25900 - }
25901 --skip_flush:
25902 -+
25903 - set_inode_flag(inode, FI_ATOMIC_FILE);
25904 - clear_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST);
25905 - up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
25906 -diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
25907 -index d636cbcf68f2..aacbb864ec1e 100644
25908 ---- a/fs/f2fs/inline.c
25909 -+++ b/fs/f2fs/inline.c
25910 -@@ -659,6 +659,12 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
25911 - if (IS_ERR(ipage))
25912 - return PTR_ERR(ipage);
25913 -
25914 -+ /*
25915 -+ * f2fs_readdir was protected by inode.i_rwsem, it is safe to access
25916 -+ * ipage without page's lock held.
25917 -+ */
25918 -+ unlock_page(ipage);
25919 -+
25920 - inline_dentry = inline_data_addr(inode, ipage);
25921 -
25922 - make_dentry_ptr_inline(inode, &d, inline_dentry);
25923 -@@ -667,7 +673,7 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
25924 - if (!err)
25925 - ctx->pos = d.max;
25926 -
25927 -- f2fs_put_page(ipage, 1);
25928 -+ f2fs_put_page(ipage, 0);
25929 - return err < 0 ? err : 0;
25930 - }
25931 -
25932 -diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
25933 -index 9b79056d705d..e1b1d390b329 100644
25934 ---- a/fs/f2fs/segment.c
25935 -+++ b/fs/f2fs/segment.c
25936 -@@ -215,7 +215,8 @@ void f2fs_register_inmem_page(struct inode *inode, struct page *page)
25937 - }
25938 -
25939 - static int __revoke_inmem_pages(struct inode *inode,
25940 -- struct list_head *head, bool drop, bool recover)
25941 -+ struct list_head *head, bool drop, bool recover,
25942 -+ bool trylock)
25943 - {
25944 - struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
25945 - struct inmem_pages *cur, *tmp;
25946 -@@ -227,7 +228,16 @@ static int __revoke_inmem_pages(struct inode *inode,
25947 - if (drop)
25948 - trace_f2fs_commit_inmem_page(page, INMEM_DROP);
25949 -
25950 -- lock_page(page);
25951 -+ if (trylock) {
25952 ++ if (nested_cpu_has_virt_x2apic_mode(vmcs12)) {
25953 ++ if (nested_cpu_has_apic_reg_virt(vmcs12)) {
25954 + /*
25955 -+ * to avoid deadlock in between page lock and
25956 -+ * inmem_lock.
25957 ++ * L0 need not intercept reads for MSRs between 0x800
25958 ++ * and 0x8ff, it just lets the processor take the value
25959 ++ * from the virtual-APIC page; take those 256 bits
25960 ++ * directly from the L1 bitmap.
25961 + */
25962 -+ if (!trylock_page(page))
25963 -+ continue;
25964 -+ } else {
25965 -+ lock_page(page);
25966 -+ }
25967 -
25968 - f2fs_wait_on_page_writeback(page, DATA, true, true);
25969 -
25970 -@@ -318,13 +328,19 @@ void f2fs_drop_inmem_pages(struct inode *inode)
25971 - struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
25972 - struct f2fs_inode_info *fi = F2FS_I(inode);
25973 -
25974 -- mutex_lock(&fi->inmem_lock);
25975 -- __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
25976 -- spin_lock(&sbi->inode_lock[ATOMIC_FILE]);
25977 -- if (!list_empty(&fi->inmem_ilist))
25978 -- list_del_init(&fi->inmem_ilist);
25979 -- spin_unlock(&sbi->inode_lock[ATOMIC_FILE]);
25980 -- mutex_unlock(&fi->inmem_lock);
25981 -+ while (!list_empty(&fi->inmem_pages)) {
25982 -+ mutex_lock(&fi->inmem_lock);
25983 -+ __revoke_inmem_pages(inode, &fi->inmem_pages,
25984 -+ true, false, true);
25985 ++ for (msr = 0x800; msr <= 0x8ff; msr += BITS_PER_LONG) {
25986 ++ unsigned word = msr / BITS_PER_LONG;
25987 +
25988 -+ if (list_empty(&fi->inmem_pages)) {
25989 -+ spin_lock(&sbi->inode_lock[ATOMIC_FILE]);
25990 -+ if (!list_empty(&fi->inmem_ilist))
25991 -+ list_del_init(&fi->inmem_ilist);
25992 -+ spin_unlock(&sbi->inode_lock[ATOMIC_FILE]);
25993 ++ msr_bitmap_l0[word] = msr_bitmap_l1[word];
25994 ++ }
25995 + }
25996 -+ mutex_unlock(&fi->inmem_lock);
25997 -+ }
25998 -
25999 - clear_inode_flag(inode, FI_ATOMIC_FILE);
26000 - fi->i_gc_failures[GC_FAILURE_ATOMIC] = 0;
26001 -@@ -429,12 +445,15 @@ retry:
26002 - * recovery or rewrite & commit last transaction. For other
26003 - * error number, revoking was done by filesystem itself.
26004 - */
26005 -- err = __revoke_inmem_pages(inode, &revoke_list, false, true);
26006 -+ err = __revoke_inmem_pages(inode, &revoke_list,
26007 -+ false, true, false);
26008 -
26009 - /* drop all uncommitted pages */
26010 -- __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
26011 -+ __revoke_inmem_pages(inode, &fi->inmem_pages,
26012 -+ true, false, false);
26013 - } else {
26014 -- __revoke_inmem_pages(inode, &revoke_list, false, false);
26015 -+ __revoke_inmem_pages(inode, &revoke_list,
26016 -+ false, false, false);
26017 - }
26018 -
26019 - return err;
26020 -diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
26021 -index c46a1d4318d4..5892fa3c885f 100644
26022 ---- a/fs/f2fs/super.c
26023 -+++ b/fs/f2fs/super.c
26024 -@@ -834,12 +834,13 @@ static int parse_options(struct super_block *sb, char *options)
26025 - "set with inline_xattr option");
26026 - return -EINVAL;
26027 - }
26028 -- if (!F2FS_OPTION(sbi).inline_xattr_size ||
26029 -- F2FS_OPTION(sbi).inline_xattr_size >=
26030 -- DEF_ADDRS_PER_INODE -
26031 -- F2FS_TOTAL_EXTRA_ATTR_SIZE -
26032 -- DEF_INLINE_RESERVED_SIZE -
26033 -- DEF_MIN_INLINE_SIZE) {
26034 -+ if (F2FS_OPTION(sbi).inline_xattr_size <
26035 -+ sizeof(struct f2fs_xattr_header) / sizeof(__le32) ||
26036 -+ F2FS_OPTION(sbi).inline_xattr_size >
26037 -+ DEF_ADDRS_PER_INODE -
26038 -+ F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) -
26039 -+ DEF_INLINE_RESERVED_SIZE -
26040 -+ MIN_INLINE_DENTRY_SIZE / sizeof(__le32)) {
26041 - f2fs_msg(sb, KERN_ERR,
26042 - "inline xattr size is out of range");
26043 - return -EINVAL;
26044 -@@ -915,6 +916,10 @@ static int f2fs_drop_inode(struct inode *inode)
26045 - sb_start_intwrite(inode->i_sb);
26046 - f2fs_i_size_write(inode, 0);
26047
26048 -+ f2fs_submit_merged_write_cond(F2FS_I_SB(inode),
26049 -+ inode, NULL, 0, DATA);
26050 -+ truncate_inode_pages_final(inode->i_mapping);
26051 +- if (nested_cpu_has_vid(vmcs12)) {
26052 +- nested_vmx_disable_intercept_for_msr(
26053 +- msr_bitmap_l1, msr_bitmap_l0,
26054 +- X2APIC_MSR(APIC_EOI),
26055 +- MSR_TYPE_W);
26056 + nested_vmx_disable_intercept_for_msr(
26057 + msr_bitmap_l1, msr_bitmap_l0,
26058 +- X2APIC_MSR(APIC_SELF_IPI),
26059 +- MSR_TYPE_W);
26060 ++ X2APIC_MSR(APIC_TASKPRI),
26061 ++ MSR_TYPE_R | MSR_TYPE_W);
26062 +
26063 - if (F2FS_HAS_BLOCKS(inode))
26064 - f2fs_truncate(inode);
26065 -
26066 -diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
26067 -index 0575edbe3ed6..f1ab9000b294 100644
26068 ---- a/fs/f2fs/sysfs.c
26069 -+++ b/fs/f2fs/sysfs.c
26070 -@@ -278,10 +278,16 @@ out:
26071 - return count;
26072 ++ if (nested_cpu_has_vid(vmcs12)) {
26073 ++ nested_vmx_disable_intercept_for_msr(
26074 ++ msr_bitmap_l1, msr_bitmap_l0,
26075 ++ X2APIC_MSR(APIC_EOI),
26076 ++ MSR_TYPE_W);
26077 ++ nested_vmx_disable_intercept_for_msr(
26078 ++ msr_bitmap_l1, msr_bitmap_l0,
26079 ++ X2APIC_MSR(APIC_SELF_IPI),
26080 ++ MSR_TYPE_W);
26081 ++ }
26082 }
26083
26084 -- *ui = t;
26085 -
26086 -- if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
26087 -- f2fs_reset_iostat(sbi);
26088 -+ if (!strcmp(a->attr.name, "iostat_enable")) {
26089 -+ sbi->iostat_enable = !!t;
26090 -+ if (!sbi->iostat_enable)
26091 -+ f2fs_reset_iostat(sbi);
26092 -+ return count;
26093 -+ }
26094 -+
26095 -+ *ui = (unsigned int)t;
26096 -+
26097 - return count;
26098 + if (spec_ctrl)
26099 +diff --git a/arch/xtensa/kernel/stacktrace.c b/arch/xtensa/kernel/stacktrace.c
26100 +index 174c11f13bba..b9f82510c650 100644
26101 +--- a/arch/xtensa/kernel/stacktrace.c
26102 ++++ b/arch/xtensa/kernel/stacktrace.c
26103 +@@ -253,10 +253,14 @@ static int return_address_cb(struct stackframe *frame, void *data)
26104 + return 1;
26105 }
26106
26107 -diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c
26108 -index ce2a5eb210b6..d0ab533a9ce8 100644
26109 ---- a/fs/f2fs/trace.c
26110 -+++ b/fs/f2fs/trace.c
26111 -@@ -14,7 +14,7 @@
26112 - #include "trace.h"
26113 -
26114 - static RADIX_TREE(pids, GFP_ATOMIC);
26115 --static struct mutex pids_lock;
26116 -+static spinlock_t pids_lock;
26117 - static struct last_io_info last_io;
26118 -
26119 - static inline void __print_last_io(void)
26120 -@@ -58,23 +58,29 @@ void f2fs_trace_pid(struct page *page)
26121 -
26122 - set_page_private(page, (unsigned long)pid);
26123 ++/*
26124 ++ * level == 0 is for the return address from the caller of this function,
26125 ++ * not from this function itself.
26126 ++ */
26127 + unsigned long return_address(unsigned level)
26128 + {
26129 + struct return_addr_data r = {
26130 +- .skip = level + 1,
26131 ++ .skip = level,
26132 + };
26133 + walk_stackframe(stack_pointer(NULL), return_address_cb, &r);
26134 + return r.addr;
26135 +diff --git a/block/bio.c b/block/bio.c
26136 +index 4db1008309ed..a06f58bd4c72 100644
26137 +--- a/block/bio.c
26138 ++++ b/block/bio.c
26139 +@@ -1238,8 +1238,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
26140 + }
26141 + }
26142
26143 -+retry:
26144 - if (radix_tree_preload(GFP_NOFS))
26145 - return;
26146 +- if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes)
26147 ++ if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) {
26148 ++ if (!map_data)
26149 ++ __free_page(page);
26150 + break;
26151 ++ }
26152
26153 -- mutex_lock(&pids_lock);
26154 -+ spin_lock(&pids_lock);
26155 - p = radix_tree_lookup(&pids, pid);
26156 - if (p == current)
26157 - goto out;
26158 - if (p)
26159 - radix_tree_delete(&pids, pid);
26160 -
26161 -- f2fs_radix_tree_insert(&pids, pid, current);
26162 -+ if (radix_tree_insert(&pids, pid, current)) {
26163 -+ spin_unlock(&pids_lock);
26164 -+ radix_tree_preload_end();
26165 -+ cond_resched();
26166 -+ goto retry;
26167 -+ }
26168 + len -= bytes;
26169 + offset = 0;
26170 +diff --git a/block/blk-core.c b/block/blk-core.c
26171 +index 6b78ec56a4f2..5bde73a49399 100644
26172 +--- a/block/blk-core.c
26173 ++++ b/block/blk-core.c
26174 +@@ -1246,8 +1246,6 @@ static int blk_cloned_rq_check_limits(struct request_queue *q,
26175 + */
26176 + blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq)
26177 + {
26178 +- blk_qc_t unused;
26179 +-
26180 + if (blk_cloned_rq_check_limits(q, rq))
26181 + return BLK_STS_IOERR;
26182
26183 - trace_printk("%3x:%3x %4x %-16s\n",
26184 - MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
26185 - pid, current->comm);
26186 - out:
26187 -- mutex_unlock(&pids_lock);
26188 -+ spin_unlock(&pids_lock);
26189 - radix_tree_preload_end();
26190 +@@ -1263,7 +1261,7 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *
26191 + * bypass a potential scheduler on the bottom device for
26192 + * insert.
26193 + */
26194 +- return blk_mq_try_issue_directly(rq->mq_hctx, rq, &unused, true, true);
26195 ++ return blk_mq_request_issue_directly(rq, true);
26196 }
26197 + EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
26198
26199 -@@ -119,7 +125,7 @@ void f2fs_trace_ios(struct f2fs_io_info *fio, int flush)
26200 +diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
26201 +index 140933e4a7d1..0c98b6c1ca49 100644
26202 +--- a/block/blk-mq-sched.c
26203 ++++ b/block/blk-mq-sched.c
26204 +@@ -423,10 +423,12 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
26205 + * busy in case of 'none' scheduler, and this way may save
26206 + * us one extra enqueue & dequeue to sw queue.
26207 + */
26208 +- if (!hctx->dispatch_busy && !e && !run_queue_async)
26209 ++ if (!hctx->dispatch_busy && !e && !run_queue_async) {
26210 + blk_mq_try_issue_list_directly(hctx, list);
26211 +- else
26212 +- blk_mq_insert_requests(hctx, ctx, list);
26213 ++ if (list_empty(list))
26214 ++ return;
26215 ++ }
26216 ++ blk_mq_insert_requests(hctx, ctx, list);
26217 + }
26218
26219 - void f2fs_build_trace_ios(void)
26220 - {
26221 -- mutex_init(&pids_lock);
26222 -+ spin_lock_init(&pids_lock);
26223 + blk_mq_run_hw_queue(hctx, run_queue_async);
26224 +diff --git a/block/blk-mq.c b/block/blk-mq.c
26225 +index b9283b63d116..16f9675c57e6 100644
26226 +--- a/block/blk-mq.c
26227 ++++ b/block/blk-mq.c
26228 +@@ -1805,74 +1805,76 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
26229 + return ret;
26230 }
26231
26232 - #define PIDVEC_SIZE 128
26233 -@@ -147,7 +153,7 @@ void f2fs_destroy_trace_ios(void)
26234 - pid_t next_pid = 0;
26235 - unsigned int found;
26236 -
26237 -- mutex_lock(&pids_lock);
26238 -+ spin_lock(&pids_lock);
26239 - while ((found = gang_lookup_pids(pid, next_pid, PIDVEC_SIZE))) {
26240 - unsigned idx;
26241 -
26242 -@@ -155,5 +161,5 @@ void f2fs_destroy_trace_ios(void)
26243 - for (idx = 0; idx < found; idx++)
26244 - radix_tree_delete(&pids, pid[idx]);
26245 - }
26246 -- mutex_unlock(&pids_lock);
26247 -+ spin_unlock(&pids_lock);
26248 - }
26249 -diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
26250 -index 18d5ffbc5e8c..73b92985198b 100644
26251 ---- a/fs/f2fs/xattr.c
26252 -+++ b/fs/f2fs/xattr.c
26253 -@@ -224,11 +224,11 @@ static struct f2fs_xattr_entry *__find_inline_xattr(struct inode *inode,
26254 +-blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26255 ++static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26256 + struct request *rq,
26257 + blk_qc_t *cookie,
26258 +- bool bypass, bool last)
26259 ++ bool bypass_insert, bool last)
26260 {
26261 - struct f2fs_xattr_entry *entry;
26262 - unsigned int inline_size = inline_xattr_size(inode);
26263 -+ void *max_addr = base_addr + inline_size;
26264 -
26265 - list_for_each_xattr(entry, base_addr) {
26266 -- if ((void *)entry + sizeof(__u32) > base_addr + inline_size ||
26267 -- (void *)XATTR_NEXT_ENTRY(entry) + sizeof(__u32) >
26268 -- base_addr + inline_size) {
26269 -+ if ((void *)entry + sizeof(__u32) > max_addr ||
26270 -+ (void *)XATTR_NEXT_ENTRY(entry) > max_addr) {
26271 - *last_addr = entry;
26272 - return NULL;
26273 - }
26274 -@@ -239,6 +239,13 @@ static struct f2fs_xattr_entry *__find_inline_xattr(struct inode *inode,
26275 - if (!memcmp(entry->e_name, name, len))
26276 - break;
26277 + struct request_queue *q = rq->q;
26278 + bool run_queue = true;
26279 +- blk_status_t ret = BLK_STS_RESOURCE;
26280 +- int srcu_idx;
26281 +- bool force = false;
26282 +
26283 +- hctx_lock(hctx, &srcu_idx);
26284 + /*
26285 +- * hctx_lock is needed before checking quiesced flag.
26286 ++ * RCU or SRCU read lock is needed before checking quiesced flag.
26287 + *
26288 +- * When queue is stopped or quiesced, ignore 'bypass', insert
26289 +- * and return BLK_STS_OK to caller, and avoid driver to try to
26290 +- * dispatch again.
26291 ++ * When queue is stopped or quiesced, ignore 'bypass_insert' from
26292 ++ * blk_mq_request_issue_directly(), and return BLK_STS_OK to caller,
26293 ++ * and avoid driver to try to dispatch again.
26294 + */
26295 +- if (unlikely(blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q))) {
26296 ++ if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q)) {
26297 + run_queue = false;
26298 +- bypass = false;
26299 +- goto out_unlock;
26300 ++ bypass_insert = false;
26301 ++ goto insert;
26302 }
26303 -+
26304 -+ /* inline xattr header or entry across max inline xattr size */
26305 -+ if (IS_XATTR_LAST_ENTRY(entry) &&
26306 -+ (void *)entry + sizeof(__u32) > max_addr) {
26307 -+ *last_addr = entry;
26308 -+ return NULL;
26309 -+ }
26310 - return entry;
26311 - }
26312
26313 -diff --git a/fs/file.c b/fs/file.c
26314 -index 3209ee271c41..a10487aa0a84 100644
26315 ---- a/fs/file.c
26316 -+++ b/fs/file.c
26317 -@@ -457,6 +457,7 @@ struct files_struct init_files = {
26318 - .full_fds_bits = init_files.full_fds_bits_init,
26319 - },
26320 - .file_lock = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
26321 -+ .resize_wait = __WAIT_QUEUE_HEAD_INITIALIZER(init_files.resize_wait),
26322 - };
26323 +- if (unlikely(q->elevator && !bypass))
26324 +- goto out_unlock;
26325 ++ if (q->elevator && !bypass_insert)
26326 ++ goto insert;
26327
26328 - static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)
26329 -diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
26330 -index b92740edc416..4b038f25f256 100644
26331 ---- a/fs/gfs2/glock.c
26332 -+++ b/fs/gfs2/glock.c
26333 -@@ -107,7 +107,7 @@ static int glock_wake_function(wait_queue_entry_t *wait, unsigned int mode,
26334 + if (!blk_mq_get_dispatch_budget(hctx))
26335 +- goto out_unlock;
26336 ++ goto insert;
26337
26338 - static wait_queue_head_t *glock_waitqueue(struct lm_lockname *name)
26339 - {
26340 -- u32 hash = jhash2((u32 *)name, sizeof(*name) / 4, 0);
26341 -+ u32 hash = jhash2((u32 *)name, ht_parms.key_len / 4, 0);
26342 + if (!blk_mq_get_driver_tag(rq)) {
26343 + blk_mq_put_dispatch_budget(hctx);
26344 +- goto out_unlock;
26345 ++ goto insert;
26346 + }
26347
26348 - return glock_wait_table + hash_32(hash, GLOCK_WAIT_TABLE_BITS);
26349 - }
26350 -diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
26351 -index 2eb55c3361a8..efd0ce9489ae 100644
26352 ---- a/fs/jbd2/commit.c
26353 -+++ b/fs/jbd2/commit.c
26354 -@@ -694,9 +694,11 @@ void jbd2_journal_commit_transaction(journal_t *journal)
26355 - the last tag we set up. */
26356 -
26357 - tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG);
26358 --
26359 -- jbd2_descriptor_block_csum_set(journal, descriptor);
26360 - start_journal_io:
26361 -+ if (descriptor)
26362 -+ jbd2_descriptor_block_csum_set(journal,
26363 -+ descriptor);
26364 +- /*
26365 +- * Always add a request that has been through
26366 +- *.queue_rq() to the hardware dispatch list.
26367 +- */
26368 +- force = true;
26369 +- ret = __blk_mq_issue_directly(hctx, rq, cookie, last);
26370 +-out_unlock:
26371 ++ return __blk_mq_issue_directly(hctx, rq, cookie, last);
26372 ++insert:
26373 ++ if (bypass_insert)
26374 ++ return BLK_STS_RESOURCE;
26375 +
26376 - for (i = 0; i < bufs; i++) {
26377 - struct buffer_head *bh = wbuf[i];
26378 - /*
26379 -diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
26380 -index 8ef6b6daaa7a..88f2a49338a1 100644
26381 ---- a/fs/jbd2/journal.c
26382 -+++ b/fs/jbd2/journal.c
26383 -@@ -1356,6 +1356,10 @@ static int journal_reset(journal_t *journal)
26384 - return jbd2_journal_start_thread(journal);
26385 - }
26386 -
26387 -+/*
26388 -+ * This function expects that the caller will have locked the journal
26389 -+ * buffer head, and will return with it unlocked
26390 -+ */
26391 - static int jbd2_write_superblock(journal_t *journal, int write_flags)
26392 - {
26393 - struct buffer_head *bh = journal->j_sb_buffer;
26394 -@@ -1365,7 +1369,6 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
26395 - trace_jbd2_write_superblock(journal, write_flags);
26396 - if (!(journal->j_flags & JBD2_BARRIER))
26397 - write_flags &= ~(REQ_FUA | REQ_PREFLUSH);
26398 -- lock_buffer(bh);
26399 - if (buffer_write_io_error(bh)) {
26400 - /*
26401 - * Oh, dear. A previous attempt to write the journal
26402 -@@ -1424,6 +1427,7 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
26403 - jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
26404 - tail_block, tail_tid);
26405 -
26406 -+ lock_buffer(journal->j_sb_buffer);
26407 - sb->s_sequence = cpu_to_be32(tail_tid);
26408 - sb->s_start = cpu_to_be32(tail_block);
26409 -
26410 -@@ -1454,18 +1458,17 @@ static void jbd2_mark_journal_empty(journal_t *journal, int write_op)
26411 - journal_superblock_t *sb = journal->j_superblock;
26412 -
26413 - BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
26414 -- read_lock(&journal->j_state_lock);
26415 -- /* Is it already empty? */
26416 -- if (sb->s_start == 0) {
26417 -- read_unlock(&journal->j_state_lock);
26418 -+ lock_buffer(journal->j_sb_buffer);
26419 -+ if (sb->s_start == 0) { /* Is it already empty? */
26420 -+ unlock_buffer(journal->j_sb_buffer);
26421 - return;
26422 - }
26423 ++ blk_mq_request_bypass_insert(rq, run_queue);
26424 ++ return BLK_STS_OK;
26425 ++}
26426 +
26427 - jbd_debug(1, "JBD2: Marking journal as empty (seq %d)\n",
26428 - journal->j_tail_sequence);
26429 -
26430 - sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
26431 - sb->s_start = cpu_to_be32(0);
26432 -- read_unlock(&journal->j_state_lock);
26433 -
26434 - jbd2_write_superblock(journal, write_op);
26435 -
26436 -@@ -1488,9 +1491,8 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
26437 - journal_superblock_t *sb = journal->j_superblock;
26438 - int errcode;
26439 -
26440 -- read_lock(&journal->j_state_lock);
26441 -+ lock_buffer(journal->j_sb_buffer);
26442 - errcode = journal->j_errno;
26443 -- read_unlock(&journal->j_state_lock);
26444 - if (errcode == -ESHUTDOWN)
26445 - errcode = 0;
26446 - jbd_debug(1, "JBD2: updating superblock error (errno %d)\n", errcode);
26447 -@@ -1894,28 +1896,27 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
26448 -
26449 - sb = journal->j_superblock;
26450 -
26451 -+ /* Load the checksum driver if necessary */
26452 -+ if ((journal->j_chksum_driver == NULL) &&
26453 -+ INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
26454 -+ journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
26455 -+ if (IS_ERR(journal->j_chksum_driver)) {
26456 -+ printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
26457 -+ journal->j_chksum_driver = NULL;
26458 -+ return 0;
26459 -+ }
26460 -+ /* Precompute checksum seed for all metadata */
26461 -+ journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
26462 -+ sizeof(sb->s_uuid));
26463 -+ }
26464 ++static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26465 ++ struct request *rq, blk_qc_t *cookie)
26466 ++{
26467 ++ blk_status_t ret;
26468 ++ int srcu_idx;
26469 +
26470 -+ lock_buffer(journal->j_sb_buffer);
26471 ++ might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
26472 +
26473 - /* If enabling v3 checksums, update superblock */
26474 - if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
26475 - sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
26476 - sb->s_feature_compat &=
26477 - ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
26478 --
26479 -- /* Load the checksum driver */
26480 -- if (journal->j_chksum_driver == NULL) {
26481 -- journal->j_chksum_driver = crypto_alloc_shash("crc32c",
26482 -- 0, 0);
26483 -- if (IS_ERR(journal->j_chksum_driver)) {
26484 -- printk(KERN_ERR "JBD2: Cannot load crc32c "
26485 -- "driver.\n");
26486 -- journal->j_chksum_driver = NULL;
26487 -- return 0;
26488 -- }
26489 --
26490 -- /* Precompute checksum seed for all metadata */
26491 -- journal->j_csum_seed = jbd2_chksum(journal, ~0,
26492 -- sb->s_uuid,
26493 -- sizeof(sb->s_uuid));
26494 -- }
26495 - }
26496 -
26497 - /* If enabling v1 checksums, downgrade superblock */
26498 -@@ -1927,6 +1928,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
26499 - sb->s_feature_compat |= cpu_to_be32(compat);
26500 - sb->s_feature_ro_compat |= cpu_to_be32(ro);
26501 - sb->s_feature_incompat |= cpu_to_be32(incompat);
26502 -+ unlock_buffer(journal->j_sb_buffer);
26503 -
26504 - return 1;
26505 - #undef COMPAT_FEATURE_ON
26506 -diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
26507 -index cc35537232f2..f0d8dabe1ff5 100644
26508 ---- a/fs/jbd2/transaction.c
26509 -+++ b/fs/jbd2/transaction.c
26510 -@@ -1252,11 +1252,12 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh)
26511 - struct journal_head *jh;
26512 - char *committed_data = NULL;
26513 -
26514 -- JBUFFER_TRACE(jh, "entry");
26515 - if (jbd2_write_access_granted(handle, bh, true))
26516 - return 0;
26517 -
26518 - jh = jbd2_journal_add_journal_head(bh);
26519 -+ JBUFFER_TRACE(jh, "entry");
26520 ++ hctx_lock(hctx, &srcu_idx);
26521 +
26522 - /*
26523 - * Do this first --- it can drop the journal lock, so we want to
26524 - * make sure that obtaining the committed_data is done
26525 -@@ -1367,15 +1368,17 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
26526 -
26527 - if (is_handle_aborted(handle))
26528 - return -EROFS;
26529 -- if (!buffer_jbd(bh)) {
26530 -- ret = -EUCLEAN;
26531 -- goto out;
26532 -- }
26533 -+ if (!buffer_jbd(bh))
26534 -+ return -EUCLEAN;
26535 ++ ret = __blk_mq_try_issue_directly(hctx, rq, cookie, false, true);
26536 ++ if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE)
26537 ++ blk_mq_request_bypass_insert(rq, true);
26538 ++ else if (ret != BLK_STS_OK)
26539 ++ blk_mq_end_request(rq, ret);
26540 +
26541 - /*
26542 - * We don't grab jh reference here since the buffer must be part
26543 - * of the running transaction.
26544 - */
26545 - jh = bh2jh(bh);
26546 -+ jbd_debug(5, "journal_head %p\n", jh);
26547 -+ JBUFFER_TRACE(jh, "entry");
26548 ++ hctx_unlock(hctx, srcu_idx);
26549 ++}
26550 +
26551 - /*
26552 - * This and the following assertions are unreliable since we may see jh
26553 - * in inconsistent state unless we grab bh_state lock. But this is
26554 -@@ -1409,9 +1412,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
26555 - }
26556 ++blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)
26557 ++{
26558 ++ blk_status_t ret;
26559 ++ int srcu_idx;
26560 ++ blk_qc_t unused_cookie;
26561 ++ struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
26562 ++
26563 ++ hctx_lock(hctx, &srcu_idx);
26564 ++ ret = __blk_mq_try_issue_directly(hctx, rq, &unused_cookie, true, last);
26565 + hctx_unlock(hctx, srcu_idx);
26566 +- switch (ret) {
26567 +- case BLK_STS_OK:
26568 +- break;
26569 +- case BLK_STS_DEV_RESOURCE:
26570 +- case BLK_STS_RESOURCE:
26571 +- if (force) {
26572 +- blk_mq_request_bypass_insert(rq, run_queue);
26573 +- /*
26574 +- * We have to return BLK_STS_OK for the DM
26575 +- * to avoid livelock. Otherwise, we return
26576 +- * the real result to indicate whether the
26577 +- * request is direct-issued successfully.
26578 +- */
26579 +- ret = bypass ? BLK_STS_OK : ret;
26580 +- } else if (!bypass) {
26581 +- blk_mq_sched_insert_request(rq, false,
26582 +- run_queue, false);
26583 +- }
26584 +- break;
26585 +- default:
26586 +- if (!bypass)
26587 +- blk_mq_end_request(rq, ret);
26588 +- break;
26589 +- }
26590
26591 - journal = transaction->t_journal;
26592 -- jbd_debug(5, "journal_head %p\n", jh);
26593 -- JBUFFER_TRACE(jh, "entry");
26594 + return ret;
26595 + }
26596 +@@ -1880,20 +1882,22 @@ out_unlock:
26597 + void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
26598 + struct list_head *list)
26599 + {
26600 +- blk_qc_t unused;
26601 +- blk_status_t ret = BLK_STS_OK;
26602 -
26603 - jbd_lock_bh_state(bh);
26604 -
26605 - if (jh->b_modified == 0) {
26606 -@@ -1609,14 +1609,21 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
26607 - /* However, if the buffer is still owned by a prior
26608 - * (committing) transaction, we can't drop it yet... */
26609 - JBUFFER_TRACE(jh, "belongs to older transaction");
26610 -- /* ... but we CAN drop it from the new transaction if we
26611 -- * have also modified it since the original commit. */
26612 -+ /* ... but we CAN drop it from the new transaction through
26613 -+ * marking the buffer as freed and set j_next_transaction to
26614 -+ * the new transaction, so that not only the commit code
26615 -+ * knows it should clear dirty bits when it is done with the
26616 -+ * buffer, but also the buffer can be checkpointed only
26617 -+ * after the new transaction commits. */
26618 -
26619 -- if (jh->b_next_transaction) {
26620 -- J_ASSERT(jh->b_next_transaction == transaction);
26621 -+ set_buffer_freed(bh);
26622 -+
26623 -+ if (!jh->b_next_transaction) {
26624 - spin_lock(&journal->j_list_lock);
26625 -- jh->b_next_transaction = NULL;
26626 -+ jh->b_next_transaction = transaction;
26627 - spin_unlock(&journal->j_list_lock);
26628 -+ } else {
26629 -+ J_ASSERT(jh->b_next_transaction == transaction);
26630 -
26631 - /*
26632 - * only drop a reference if this transaction modified
26633 -diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
26634 -index fdf527b6d79c..d71c9405874a 100644
26635 ---- a/fs/kernfs/mount.c
26636 -+++ b/fs/kernfs/mount.c
26637 -@@ -196,8 +196,10 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
26638 - return dentry;
26639 -
26640 - knparent = find_next_ancestor(kn, NULL);
26641 -- if (WARN_ON(!knparent))
26642 -+ if (WARN_ON(!knparent)) {
26643 -+ dput(dentry);
26644 - return ERR_PTR(-EINVAL);
26645 -+ }
26646 + while (!list_empty(list)) {
26647 ++ blk_status_t ret;
26648 + struct request *rq = list_first_entry(list, struct request,
26649 + queuelist);
26650
26651 - do {
26652 - struct dentry *dtmp;
26653 -@@ -206,8 +208,10 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
26654 - if (kn == knparent)
26655 - return dentry;
26656 - kntmp = find_next_ancestor(kn, knparent);
26657 -- if (WARN_ON(!kntmp))
26658 -+ if (WARN_ON(!kntmp)) {
26659 -+ dput(dentry);
26660 - return ERR_PTR(-EINVAL);
26661 + list_del_init(&rq->queuelist);
26662 +- if (ret == BLK_STS_OK)
26663 +- ret = blk_mq_try_issue_directly(hctx, rq, &unused,
26664 +- false,
26665 ++ ret = blk_mq_request_issue_directly(rq, list_empty(list));
26666 ++ if (ret != BLK_STS_OK) {
26667 ++ if (ret == BLK_STS_RESOURCE ||
26668 ++ ret == BLK_STS_DEV_RESOURCE) {
26669 ++ blk_mq_request_bypass_insert(rq,
26670 + list_empty(list));
26671 +- else
26672 +- blk_mq_sched_insert_request(rq, false, true, false);
26673 ++ break;
26674 ++ }
26675 ++ blk_mq_end_request(rq, ret);
26676 + }
26677 - dtmp = lookup_one_len_unlocked(kntmp->name, dentry,
26678 - strlen(kntmp->name));
26679 - dput(dentry);
26680 -diff --git a/fs/lockd/host.c b/fs/lockd/host.c
26681 -index 93fb7cf0b92b..f0b5c987d6ae 100644
26682 ---- a/fs/lockd/host.c
26683 -+++ b/fs/lockd/host.c
26684 -@@ -290,12 +290,11 @@ void nlmclnt_release_host(struct nlm_host *host)
26685 -
26686 - WARN_ON_ONCE(host->h_server);
26687 -
26688 -- if (refcount_dec_and_test(&host->h_count)) {
26689 -+ if (refcount_dec_and_mutex_lock(&host->h_count, &nlm_host_mutex)) {
26690 - WARN_ON_ONCE(!list_empty(&host->h_lockowners));
26691 - WARN_ON_ONCE(!list_empty(&host->h_granted));
26692 - WARN_ON_ONCE(!list_empty(&host->h_reclaim));
26693 -
26694 -- mutex_lock(&nlm_host_mutex);
26695 - nlm_destroy_host_locked(host);
26696 - mutex_unlock(&nlm_host_mutex);
26697 }
26698 -diff --git a/fs/locks.c b/fs/locks.c
26699 -index ff6af2c32601..5f468cd95f68 100644
26700 ---- a/fs/locks.c
26701 -+++ b/fs/locks.c
26702 -@@ -1160,6 +1160,11 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
26703 - */
26704 - error = -EDEADLK;
26705 - spin_lock(&blocked_lock_lock);
26706 -+ /*
26707 -+ * Ensure that we don't find any locks blocked on this
26708 -+ * request during deadlock detection.
26709 -+ */
26710 -+ __locks_wake_up_blocks(request);
26711 - if (likely(!posix_locks_deadlock(request, fl))) {
26712 - error = FILE_LOCK_DEFERRED;
26713 - __locks_insert_block(fl, request,
26714 -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
26715 -index 557a5d636183..44258c516305 100644
26716 ---- a/fs/nfs/nfs4proc.c
26717 -+++ b/fs/nfs/nfs4proc.c
26718 -@@ -947,6 +947,13 @@ nfs4_sequence_process_interrupted(struct nfs_client *client,
26719 -
26720 - #endif /* !CONFIG_NFS_V4_1 */
26721 -
26722 -+static void nfs41_sequence_res_init(struct nfs4_sequence_res *res)
26723 -+{
26724 -+ res->sr_timestamp = jiffies;
26725 -+ res->sr_status_flags = 0;
26726 -+ res->sr_status = 1;
26727 -+}
26728 -+
26729 - static
26730 - void nfs4_sequence_attach_slot(struct nfs4_sequence_args *args,
26731 - struct nfs4_sequence_res *res,
26732 -@@ -958,10 +965,6 @@ void nfs4_sequence_attach_slot(struct nfs4_sequence_args *args,
26733 - args->sa_slot = slot;
26734 -
26735 - res->sr_slot = slot;
26736 -- res->sr_timestamp = jiffies;
26737 -- res->sr_status_flags = 0;
26738 -- res->sr_status = 1;
26739 --
26740 +
26741 + /*
26742 +@@ -1901,7 +1905,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
26743 + * the driver there was more coming, but that turned out to
26744 + * be a lie.
26745 + */
26746 +- if (ret != BLK_STS_OK && hctx->queue->mq_ops->commit_rqs)
26747 ++ if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs)
26748 + hctx->queue->mq_ops->commit_rqs(hctx);
26749 }
26750
26751 - int nfs4_setup_sequence(struct nfs_client *client,
26752 -@@ -1007,6 +1010,7 @@ int nfs4_setup_sequence(struct nfs_client *client,
26753 +@@ -2014,13 +2018,13 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
26754 + if (same_queue_rq) {
26755 + data.hctx = same_queue_rq->mq_hctx;
26756 + blk_mq_try_issue_directly(data.hctx, same_queue_rq,
26757 +- &cookie, false, true);
26758 ++ &cookie);
26759 + }
26760 + } else if ((q->nr_hw_queues > 1 && is_sync) || (!q->elevator &&
26761 + !data.hctx->dispatch_busy)) {
26762 + blk_mq_put_ctx(data.ctx);
26763 + blk_mq_bio_to_request(rq, bio);
26764 +- blk_mq_try_issue_directly(data.hctx, rq, &cookie, false, true);
26765 ++ blk_mq_try_issue_directly(data.hctx, rq, &cookie);
26766 + } else {
26767 + blk_mq_put_ctx(data.ctx);
26768 + blk_mq_bio_to_request(rq, bio);
26769 +diff --git a/block/blk-mq.h b/block/blk-mq.h
26770 +index d0b3dd54ef8d..a3a684a8c633 100644
26771 +--- a/block/blk-mq.h
26772 ++++ b/block/blk-mq.h
26773 +@@ -67,10 +67,8 @@ void blk_mq_request_bypass_insert(struct request *rq, bool run_queue);
26774 + void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
26775 + struct list_head *list);
26776
26777 - trace_nfs4_setup_sequence(session, args);
26778 - out_start:
26779 -+ nfs41_sequence_res_init(res);
26780 - rpc_call_start(task);
26781 - return 0;
26782 +-blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26783 +- struct request *rq,
26784 +- blk_qc_t *cookie,
26785 +- bool bypass, bool last);
26786 ++/* Used by blk_insert_cloned_request() to issue request directly */
26787 ++blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last);
26788 + void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
26789 + struct list_head *list);
26790
26791 -@@ -2934,7 +2938,8 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
26792 - }
26793 +diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
26794 +index e10fec99a182..4424997ecf30 100644
26795 +--- a/drivers/acpi/acpica/evgpe.c
26796 ++++ b/drivers/acpi/acpica/evgpe.c
26797 +@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
26798
26799 - out:
26800 -- nfs4_sequence_free_slot(&opendata->o_res.seq_res);
26801 -+ if (!opendata->cancelled)
26802 -+ nfs4_sequence_free_slot(&opendata->o_res.seq_res);
26803 - return ret;
26804 - }
26805 + ACPI_FUNCTION_TRACE(ev_enable_gpe);
26806
26807 -@@ -6302,7 +6307,6 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl,
26808 - p->arg.seqid = seqid;
26809 - p->res.seqid = seqid;
26810 - p->lsp = lsp;
26811 -- refcount_inc(&lsp->ls_count);
26812 - /* Ensure we don't close file until we're done freeing locks! */
26813 - p->ctx = get_nfs_open_context(ctx);
26814 - p->l_ctx = nfs_get_lock_context(ctx);
26815 -@@ -6527,7 +6531,6 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
26816 - p->res.lock_seqid = p->arg.lock_seqid;
26817 - p->lsp = lsp;
26818 - p->server = server;
26819 -- refcount_inc(&lsp->ls_count);
26820 - p->ctx = get_nfs_open_context(ctx);
26821 - locks_init_lock(&p->fl);
26822 - locks_copy_lock(&p->fl, fl);
26823 -diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
26824 -index e54d899c1848..a8951f1f7b4e 100644
26825 ---- a/fs/nfs/pagelist.c
26826 -+++ b/fs/nfs/pagelist.c
26827 -@@ -988,6 +988,17 @@ static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
26828 - }
26829 - }
26830 +- /* Enable the requested GPE */
26831 ++ /* Clear the GPE status */
26832 ++ status = acpi_hw_clear_gpe(gpe_event_info);
26833 ++ if (ACPI_FAILURE(status))
26834 ++ return_ACPI_STATUS(status);
26835
26836 -+static void
26837 -+nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc,
26838 -+ struct nfs_page *req)
26839 -+{
26840 -+ LIST_HEAD(head);
26841 -+
26842 -+ nfs_list_remove_request(req);
26843 -+ nfs_list_add_request(req, &head);
26844 -+ desc->pg_completion_ops->error_cleanup(&head);
26845 -+}
26846 -+
26847 - /**
26848 - * nfs_pageio_add_request - Attempt to coalesce a request into a page list.
26849 - * @desc: destination io descriptor
26850 -@@ -1025,10 +1036,8 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
26851 - nfs_page_group_unlock(req);
26852 - desc->pg_moreio = 1;
26853 - nfs_pageio_doio(desc);
26854 -- if (desc->pg_error < 0)
26855 -- return 0;
26856 -- if (mirror->pg_recoalesce)
26857 -- return 0;
26858 -+ if (desc->pg_error < 0 || mirror->pg_recoalesce)
26859 -+ goto out_cleanup_subreq;
26860 - /* retry add_request for this subreq */
26861 - nfs_page_group_lock(req);
26862 - continue;
26863 -@@ -1061,6 +1070,10 @@ err_ptr:
26864 - desc->pg_error = PTR_ERR(subreq);
26865 - nfs_page_group_unlock(req);
26866 - return 0;
26867 -+out_cleanup_subreq:
26868 -+ if (req != subreq)
26869 -+ nfs_pageio_cleanup_request(desc, subreq);
26870 -+ return 0;
26871 ++ /* Enable the requested GPE */
26872 + status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
26873 + return_ACPI_STATUS(status);
26874 }
26875 -
26876 - static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
26877 -@@ -1079,7 +1092,6 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
26878 - struct nfs_page *req;
26879 -
26880 - req = list_first_entry(&head, struct nfs_page, wb_list);
26881 -- nfs_list_remove_request(req);
26882 - if (__nfs_pageio_add_request(desc, req))
26883 - continue;
26884 - if (desc->pg_error < 0) {
26885 -@@ -1168,11 +1180,14 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
26886 - if (nfs_pgio_has_mirroring(desc))
26887 - desc->pg_mirror_idx = midx;
26888 - if (!nfs_pageio_add_request_mirror(desc, dupreq))
26889 -- goto out_failed;
26890 -+ goto out_cleanup_subreq;
26891 +diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
26892 +index 8638f43cfc3d..79d86da1c892 100644
26893 +--- a/drivers/acpi/acpica/nsobject.c
26894 ++++ b/drivers/acpi/acpica/nsobject.c
26895 +@@ -186,6 +186,10 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
26896 + }
26897 }
26898
26899 - return 1;
26900 -
26901 -+out_cleanup_subreq:
26902 -+ if (req != dupreq)
26903 -+ nfs_pageio_cleanup_request(desc, dupreq);
26904 - out_failed:
26905 - nfs_pageio_error_cleanup(desc);
26906 - return 0;
26907 -@@ -1194,7 +1209,7 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc,
26908 - desc->pg_mirror_idx = mirror_idx;
26909 - for (;;) {
26910 - nfs_pageio_doio(desc);
26911 -- if (!mirror->pg_recoalesce)
26912 -+ if (desc->pg_error < 0 || !mirror->pg_recoalesce)
26913 - break;
26914 - if (!nfs_do_recoalesce(desc))
26915 - break;
26916 -diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
26917 -index 9eb8086ea841..c9cf46e0c040 100644
26918 ---- a/fs/nfsd/nfs3proc.c
26919 -+++ b/fs/nfsd/nfs3proc.c
26920 -@@ -463,8 +463,19 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
26921 - &resp->common, nfs3svc_encode_entry);
26922 - memcpy(resp->verf, argp->verf, 8);
26923 - resp->count = resp->buffer - argp->buffer;
26924 -- if (resp->offset)
26925 -- xdr_encode_hyper(resp->offset, argp->cookie);
26926 -+ if (resp->offset) {
26927 -+ loff_t offset = argp->cookie;
26928 -+
26929 -+ if (unlikely(resp->offset1)) {
26930 -+ /* we ended up with offset on a page boundary */
26931 -+ *resp->offset = htonl(offset >> 32);
26932 -+ *resp->offset1 = htonl(offset & 0xffffffff);
26933 -+ resp->offset1 = NULL;
26934 -+ } else {
26935 -+ xdr_encode_hyper(resp->offset, offset);
26936 -+ }
26937 -+ resp->offset = NULL;
26938 ++ if (obj_desc->common.type == ACPI_TYPE_REGION) {
26939 ++ acpi_ut_remove_address_range(obj_desc->region.space_id, node);
26940 + }
26941 ++
26942 + /* Clear the Node entry in all cases */
26943
26944 - RETURN_STATUS(nfserr);
26945 - }
26946 -@@ -533,6 +544,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
26947 - } else {
26948 - xdr_encode_hyper(resp->offset, offset);
26949 - }
26950 -+ resp->offset = NULL;
26951 - }
26952 -
26953 - RETURN_STATUS(nfserr);
26954 -diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
26955 -index 9b973f4f7d01..83919116d5cb 100644
26956 ---- a/fs/nfsd/nfs3xdr.c
26957 -+++ b/fs/nfsd/nfs3xdr.c
26958 -@@ -921,6 +921,7 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
26959 - } else {
26960 - xdr_encode_hyper(cd->offset, offset64);
26961 - }
26962 -+ cd->offset = NULL;
26963 - }
26964 + node->object = NULL;
26965 +diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
26966 +index 2e2ffe7010aa..51c77f0e47b2 100644
26967 +--- a/drivers/char/Kconfig
26968 ++++ b/drivers/char/Kconfig
26969 +@@ -351,7 +351,7 @@ config XILINX_HWICAP
26970
26971 - /*
26972 -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
26973 -index fb3c9844c82a..6a45fb00c5fc 100644
26974 ---- a/fs/nfsd/nfs4state.c
26975 -+++ b/fs/nfsd/nfs4state.c
26976 -@@ -1544,16 +1544,16 @@ static u32 nfsd4_get_drc_mem(struct nfsd4_channel_attrs *ca)
26977 - {
26978 - u32 slotsize = slot_bytes(ca);
26979 - u32 num = ca->maxreqs;
26980 -- int avail;
26981 -+ unsigned long avail, total_avail;
26982 -
26983 - spin_lock(&nfsd_drc_lock);
26984 -- avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION,
26985 -- nfsd_drc_max_mem - nfsd_drc_mem_used);
26986 -+ total_avail = nfsd_drc_max_mem - nfsd_drc_mem_used;
26987 -+ avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION, total_avail);
26988 - /*
26989 - * Never use more than a third of the remaining memory,
26990 - * unless it's the only way to give this client a slot:
26991 - */
26992 -- avail = clamp_t(int, avail, slotsize, avail/3);
26993 -+ avail = clamp_t(int, avail, slotsize, total_avail/3);
26994 - num = min_t(int, num, avail / slotsize);
26995 - nfsd_drc_mem_used += num * slotsize;
26996 - spin_unlock(&nfsd_drc_lock);
26997 -diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
26998 -index 72a7681f4046..f2feb2d11bae 100644
26999 ---- a/fs/nfsd/nfsctl.c
27000 -+++ b/fs/nfsd/nfsctl.c
27001 -@@ -1126,7 +1126,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
27002 - case 'Y':
27003 - case 'y':
27004 - case '1':
27005 -- if (nn->nfsd_serv)
27006 -+ if (!nn->nfsd_serv)
27007 - return -EBUSY;
27008 - nfsd4_end_grace(nn);
27009 - break;
27010 -diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
27011 -index 0e4166cc23a0..4ac775e32240 100644
27012 ---- a/fs/ocfs2/cluster/nodemanager.c
27013 -+++ b/fs/ocfs2/cluster/nodemanager.c
27014 -@@ -621,13 +621,15 @@ static void o2nm_node_group_drop_item(struct config_group *group,
27015 - struct o2nm_node *node = to_o2nm_node(item);
27016 - struct o2nm_cluster *cluster = to_o2nm_cluster(group->cg_item.ci_parent);
27017 -
27018 -- o2net_disconnect_node(node);
27019 -+ if (cluster->cl_nodes[node->nd_num] == node) {
27020 -+ o2net_disconnect_node(node);
27021 -
27022 -- if (cluster->cl_has_local &&
27023 -- (cluster->cl_local_node == node->nd_num)) {
27024 -- cluster->cl_has_local = 0;
27025 -- cluster->cl_local_node = O2NM_INVALID_NODE_NUM;
27026 -- o2net_stop_listening(node);
27027 -+ if (cluster->cl_has_local &&
27028 -+ (cluster->cl_local_node == node->nd_num)) {
27029 -+ cluster->cl_has_local = 0;
27030 -+ cluster->cl_local_node = O2NM_INVALID_NODE_NUM;
27031 -+ o2net_stop_listening(node);
27032 -+ }
27033 + config R3964
27034 + tristate "Siemens R3964 line discipline"
27035 +- depends on TTY
27036 ++ depends on TTY && BROKEN
27037 + ---help---
27038 + This driver allows synchronous communication with devices using the
27039 + Siemens R3964 packet protocol. Unless you are dealing with special
27040 +diff --git a/drivers/clk/meson/meson-aoclk.c b/drivers/clk/meson/meson-aoclk.c
27041 +index 258c8d259ea1..f965845917e3 100644
27042 +--- a/drivers/clk/meson/meson-aoclk.c
27043 ++++ b/drivers/clk/meson/meson-aoclk.c
27044 +@@ -65,20 +65,15 @@ int meson_aoclkc_probe(struct platform_device *pdev)
27045 + return ret;
27046 }
27047
27048 - /* XXX call into net to stop this node from trading messages */
27049 -diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
27050 -index a35259eebc56..1dc9a08e8bdc 100644
27051 ---- a/fs/ocfs2/refcounttree.c
27052 -+++ b/fs/ocfs2/refcounttree.c
27053 -@@ -4719,22 +4719,23 @@ out:
27054 -
27055 - /* Lock an inode and grab a bh pointing to the inode. */
27056 - int ocfs2_reflink_inodes_lock(struct inode *s_inode,
27057 -- struct buffer_head **bh1,
27058 -+ struct buffer_head **bh_s,
27059 - struct inode *t_inode,
27060 -- struct buffer_head **bh2)
27061 -+ struct buffer_head **bh_t)
27062 - {
27063 -- struct inode *inode1;
27064 -- struct inode *inode2;
27065 -+ struct inode *inode1 = s_inode;
27066 -+ struct inode *inode2 = t_inode;
27067 - struct ocfs2_inode_info *oi1;
27068 - struct ocfs2_inode_info *oi2;
27069 -+ struct buffer_head *bh1 = NULL;
27070 -+ struct buffer_head *bh2 = NULL;
27071 - bool same_inode = (s_inode == t_inode);
27072 -+ bool need_swap = (inode1->i_ino > inode2->i_ino);
27073 - int status;
27074 -
27075 - /* First grab the VFS and rw locks. */
27076 - lock_two_nondirectories(s_inode, t_inode);
27077 -- inode1 = s_inode;
27078 -- inode2 = t_inode;
27079 -- if (inode1->i_ino > inode2->i_ino)
27080 -+ if (need_swap)
27081 - swap(inode1, inode2);
27082 -
27083 - status = ocfs2_rw_lock(inode1, 1);
27084 -@@ -4757,17 +4758,13 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
27085 - trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno,
27086 - (unsigned long long)oi2->ip_blkno);
27087 -
27088 -- if (*bh1)
27089 -- *bh1 = NULL;
27090 -- if (*bh2)
27091 -- *bh2 = NULL;
27092 --
27093 - /* We always want to lock the one with the lower lockid first. */
27094 - if (oi1->ip_blkno > oi2->ip_blkno)
27095 - mlog_errno(-ENOLCK);
27096 -
27097 - /* lock id1 */
27098 -- status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET);
27099 -+ status = ocfs2_inode_lock_nested(inode1, &bh1, 1,
27100 -+ OI_LS_REFLINK_TARGET);
27101 - if (status < 0) {
27102 - if (status != -ENOENT)
27103 - mlog_errno(status);
27104 -@@ -4776,15 +4773,25 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
27105 -
27106 - /* lock id2 */
27107 - if (!same_inode) {
27108 -- status = ocfs2_inode_lock_nested(inode2, bh2, 1,
27109 -+ status = ocfs2_inode_lock_nested(inode2, &bh2, 1,
27110 - OI_LS_REFLINK_TARGET);
27111 - if (status < 0) {
27112 - if (status != -ENOENT)
27113 - mlog_errno(status);
27114 - goto out_cl1;
27115 - }
27116 -- } else
27117 -- *bh2 = *bh1;
27118 -+ } else {
27119 -+ bh2 = bh1;
27120 -+ }
27121 -+
27122 +- /* Populate regmap */
27123 +- for (clkid = 0; clkid < data->num_clks; clkid++)
27124 + /*
27125 -+ * If we swapped inode order above, we have to swap the buffer heads
27126 -+ * before passing them back to the caller.
27127 ++ * Populate regmap and register all clks
27128 + */
27129 -+ if (need_swap)
27130 -+ swap(bh1, bh2);
27131 -+ *bh_s = bh1;
27132 -+ *bh_t = bh2;
27133 -
27134 - trace_ocfs2_double_lock_end(
27135 - (unsigned long long)oi1->ip_blkno,
27136 -@@ -4794,8 +4801,7 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
27137 -
27138 - out_cl1:
27139 - ocfs2_inode_unlock(inode1, 1);
27140 -- brelse(*bh1);
27141 -- *bh1 = NULL;
27142 -+ brelse(bh1);
27143 - out_rw2:
27144 - ocfs2_rw_unlock(inode2, 1);
27145 - out_i2:
27146 -diff --git a/fs/open.c b/fs/open.c
27147 -index 0285ce7dbd51..f1c2f855fd43 100644
27148 ---- a/fs/open.c
27149 -+++ b/fs/open.c
27150 -@@ -733,6 +733,12 @@ static int do_dentry_open(struct file *f,
27151 - return 0;
27152 ++ for (clkid = 0; clkid < data->num_clks; clkid++) {
27153 + data->clks[clkid]->map = regmap;
27154 +
27155 +- /* Register all clks */
27156 +- for (clkid = 0; clkid < data->hw_data->num; clkid++) {
27157 +- if (!data->hw_data->hws[clkid])
27158 +- continue;
27159 +-
27160 + ret = devm_clk_hw_register(dev, data->hw_data->hws[clkid]);
27161 +- if (ret) {
27162 +- dev_err(dev, "Clock registration failed\n");
27163 ++ if (ret)
27164 + return ret;
27165 +- }
27166 }
27167
27168 -+ /* Any file opened for execve()/uselib() has to be a regular file. */
27169 -+ if (unlikely(f->f_flags & FMODE_EXEC && !S_ISREG(inode->i_mode))) {
27170 -+ error = -EACCES;
27171 -+ goto cleanup_file;
27172 -+ }
27173 -+
27174 - if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) {
27175 - error = get_write_access(inode);
27176 - if (unlikely(error))
27177 -diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
27178 -index 9e62dcf06fc4..68b3303e4b46 100644
27179 ---- a/fs/overlayfs/copy_up.c
27180 -+++ b/fs/overlayfs/copy_up.c
27181 -@@ -443,6 +443,24 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)
27182 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
27183 +diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
27184 +index c7103dd2d8d5..563ab8590061 100644
27185 +--- a/drivers/gpu/drm/i915/gvt/gtt.c
27186 ++++ b/drivers/gpu/drm/i915/gvt/gtt.c
27187 +@@ -1942,7 +1942,7 @@ void _intel_vgpu_mm_release(struct kref *mm_ref)
27188 + */
27189 + void intel_vgpu_unpin_mm(struct intel_vgpu_mm *mm)
27190 {
27191 - int err;
27192 +- atomic_dec(&mm->pincount);
27193 ++ atomic_dec_if_positive(&mm->pincount);
27194 + }
27195
27196 -+ /*
27197 -+ * Copy up data first and then xattrs. Writing data after
27198 -+ * xattrs will remove security.capability xattr automatically.
27199 -+ */
27200 -+ if (S_ISREG(c->stat.mode) && !c->metacopy) {
27201 -+ struct path upperpath, datapath;
27202 -+
27203 -+ ovl_path_upper(c->dentry, &upperpath);
27204 -+ if (WARN_ON(upperpath.dentry != NULL))
27205 -+ return -EIO;
27206 -+ upperpath.dentry = temp;
27207 -+
27208 -+ ovl_path_lowerdata(c->dentry, &datapath);
27209 -+ err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size);
27210 -+ if (err)
27211 -+ return err;
27212 -+ }
27213 -+
27214 - err = ovl_copy_xattr(c->lowerpath.dentry, temp);
27215 - if (err)
27216 - return err;
27217 -@@ -460,19 +478,6 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)
27218 - return err;
27219 + /**
27220 +diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
27221 +index 55bb7885e228..8fff49affc11 100644
27222 +--- a/drivers/gpu/drm/i915/gvt/scheduler.c
27223 ++++ b/drivers/gpu/drm/i915/gvt/scheduler.c
27224 +@@ -1475,8 +1475,9 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
27225 + intel_runtime_pm_put(dev_priv);
27226 + }
27227 +
27228 +- if (ret && (vgpu_is_vm_unhealthy(ret))) {
27229 +- enter_failsafe_mode(vgpu, GVT_FAILSAFE_GUEST_ERR);
27230 ++ if (ret) {
27231 ++ if (vgpu_is_vm_unhealthy(ret))
27232 ++ enter_failsafe_mode(vgpu, GVT_FAILSAFE_GUEST_ERR);
27233 + intel_vgpu_destroy_workload(workload);
27234 + return ERR_PTR(ret);
27235 }
27236 +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
27237 +index 22a74608c6e4..dcd1df5322e8 100644
27238 +--- a/drivers/gpu/drm/i915/intel_dp.c
27239 ++++ b/drivers/gpu/drm/i915/intel_dp.c
27240 +@@ -1845,42 +1845,6 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
27241 + return false;
27242 + }
27243
27244 -- if (S_ISREG(c->stat.mode) && !c->metacopy) {
27245 -- struct path upperpath, datapath;
27246 +-/* Optimize link config in order: max bpp, min lanes, min clock */
27247 +-static bool
27248 +-intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
27249 +- struct intel_crtc_state *pipe_config,
27250 +- const struct link_config_limits *limits)
27251 +-{
27252 +- struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
27253 +- int bpp, clock, lane_count;
27254 +- int mode_rate, link_clock, link_avail;
27255 +-
27256 +- for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
27257 +- mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
27258 +- bpp);
27259 +-
27260 +- for (lane_count = limits->min_lane_count;
27261 +- lane_count <= limits->max_lane_count;
27262 +- lane_count <<= 1) {
27263 +- for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
27264 +- link_clock = intel_dp->common_rates[clock];
27265 +- link_avail = intel_dp_max_data_rate(link_clock,
27266 +- lane_count);
27267 -
27268 -- ovl_path_upper(c->dentry, &upperpath);
27269 -- BUG_ON(upperpath.dentry != NULL);
27270 -- upperpath.dentry = temp;
27271 +- if (mode_rate <= link_avail) {
27272 +- pipe_config->lane_count = lane_count;
27273 +- pipe_config->pipe_bpp = bpp;
27274 +- pipe_config->port_clock = link_clock;
27275 -
27276 -- ovl_path_lowerdata(c->dentry, &datapath);
27277 -- err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size);
27278 -- if (err)
27279 -- return err;
27280 +- return true;
27281 +- }
27282 +- }
27283 +- }
27284 - }
27285 -
27286 - if (c->metacopy) {
27287 - err = ovl_check_setxattr(c->dentry, temp, OVL_XATTR_METACOPY,
27288 - NULL, 0, -EOPNOTSUPP);
27289 -@@ -737,6 +742,8 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
27290 +- return false;
27291 +-}
27292 +-
27293 + static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc)
27294 {
27295 - struct path upperpath, datapath;
27296 - int err;
27297 -+ char *capability = NULL;
27298 -+ ssize_t uninitialized_var(cap_size);
27299 -
27300 - ovl_path_upper(c->dentry, &upperpath);
27301 - if (WARN_ON(upperpath.dentry == NULL))
27302 -@@ -746,15 +753,37 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
27303 - if (WARN_ON(datapath.dentry == NULL))
27304 - return -EIO;
27305 -
27306 -+ if (c->stat.size) {
27307 -+ err = cap_size = ovl_getxattr(upperpath.dentry, XATTR_NAME_CAPS,
27308 -+ &capability, 0);
27309 -+ if (err < 0 && err != -ENODATA)
27310 -+ goto out;
27311 -+ }
27312 -+
27313 - err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size);
27314 - if (err)
27315 -- return err;
27316 -+ goto out_free;
27317 -+
27318 -+ /*
27319 -+ * Writing to upper file will clear security.capability xattr. We
27320 -+ * don't want that to happen for normal copy-up operation.
27321 -+ */
27322 -+ if (capability) {
27323 -+ err = ovl_do_setxattr(upperpath.dentry, XATTR_NAME_CAPS,
27324 -+ capability, cap_size, 0);
27325 -+ if (err)
27326 -+ goto out_free;
27327 -+ }
27328 -+
27329 + int i, num_bpc;
27330 +@@ -2013,15 +1977,13 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
27331 + limits.min_bpp = 6 * 3;
27332 + limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
27333
27334 - err = vfs_removexattr(upperpath.dentry, OVL_XATTR_METACOPY);
27335 - if (err)
27336 -- return err;
27337 -+ goto out_free;
27338 +- if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
27339 ++ if (intel_dp_is_edp(intel_dp)) {
27340 + /*
27341 + * Use the maximum clock and number of lanes the eDP panel
27342 +- * advertizes being capable of. The eDP 1.3 and earlier panels
27343 +- * are generally designed to support only a single clock and
27344 +- * lane configuration, and typically these values correspond to
27345 +- * the native resolution of the panel. With eDP 1.4 rate select
27346 +- * and DSC, this is decreasingly the case, and we need to be
27347 +- * able to select less than maximum link config.
27348 ++ * advertizes being capable of. The panels are generally
27349 ++ * designed to support only a single clock and lane
27350 ++ * configuration, and typically these values correspond to the
27351 ++ * native resolution of the panel.
27352 + */
27353 + limits.min_lane_count = limits.max_lane_count;
27354 + limits.min_clock = limits.max_clock;
27355 +@@ -2035,22 +1997,11 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
27356 + intel_dp->common_rates[limits.max_clock],
27357 + limits.max_bpp, adjusted_mode->crtc_clock);
27358
27359 - ovl_set_upperdata(d_inode(c->dentry));
27360 -+out_free:
27361 -+ kfree(capability);
27362 -+out:
27363 - return err;
27364 - }
27365 +- if (intel_dp_is_edp(intel_dp))
27366 +- /*
27367 +- * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
27368 +- * section A.1: "It is recommended that the minimum number of
27369 +- * lanes be used, using the minimum link rate allowed for that
27370 +- * lane configuration."
27371 +- *
27372 +- * Note that we use the max clock and lane count for eDP 1.3 and
27373 +- * earlier, and fast vs. wide is irrelevant.
27374 +- */
27375 +- ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config,
27376 +- &limits);
27377 +- else
27378 +- /* Optimize for slow and wide. */
27379 +- ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
27380 +- &limits);
27381 ++ /*
27382 ++ * Optimize for slow and wide. This is the place to add alternative
27383 ++ * optimization policy.
27384 ++ */
27385 ++ ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits);
27386
27387 -diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
27388 -index 5e45cb3630a0..9c6018287d57 100644
27389 ---- a/fs/overlayfs/overlayfs.h
27390 -+++ b/fs/overlayfs/overlayfs.h
27391 -@@ -277,6 +277,8 @@ int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir);
27392 - int ovl_check_metacopy_xattr(struct dentry *dentry);
27393 - bool ovl_is_metacopy_dentry(struct dentry *dentry);
27394 - char *ovl_get_redirect_xattr(struct dentry *dentry, int padding);
27395 -+ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
27396 -+ size_t padding);
27397 -
27398 - static inline bool ovl_is_impuredir(struct dentry *dentry)
27399 + /* enable compression if the mode doesn't fit available BW */
27400 + if (!ret) {
27401 +diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
27402 +index dc47720c99ba..39d8509d96a0 100644
27403 +--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
27404 ++++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
27405 +@@ -48,8 +48,13 @@ static enum drm_mode_status
27406 + sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
27407 + const struct drm_display_mode *mode)
27408 {
27409 -diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
27410 -index 7c01327b1852..4035e640f402 100644
27411 ---- a/fs/overlayfs/util.c
27412 -+++ b/fs/overlayfs/util.c
27413 -@@ -863,28 +863,49 @@ bool ovl_is_metacopy_dentry(struct dentry *dentry)
27414 - return (oe->numlower > 1);
27415 - }
27416 +- /* This is max for HDMI 2.0b (4K@60Hz) */
27417 +- if (mode->clock > 594000)
27418 ++ /*
27419 ++ * Controller support maximum of 594 MHz, which correlates to
27420 ++ * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than
27421 ++ * 340 MHz scrambling has to be enabled. Because scrambling is
27422 ++ * not yet implemented, just limit to 340 MHz for now.
27423 ++ */
27424 ++ if (mode->clock > 340000)
27425 + return MODE_CLOCK_HIGH;
27426
27427 --char *ovl_get_redirect_xattr(struct dentry *dentry, int padding)
27428 -+ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
27429 -+ size_t padding)
27430 - {
27431 -- int res;
27432 -- char *s, *next, *buf = NULL;
27433 -+ ssize_t res;
27434 -+ char *buf = NULL;
27435 -
27436 -- res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, NULL, 0);
27437 -+ res = vfs_getxattr(dentry, name, NULL, 0);
27438 - if (res < 0) {
27439 - if (res == -ENODATA || res == -EOPNOTSUPP)
27440 -- return NULL;
27441 -+ return -ENODATA;
27442 - goto fail;
27443 - }
27444 + return MODE_OK;
27445 +diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
27446 +index a63e3011e971..bd4f0b88bbd7 100644
27447 +--- a/drivers/gpu/drm/udl/udl_drv.c
27448 ++++ b/drivers/gpu/drm/udl/udl_drv.c
27449 +@@ -51,6 +51,7 @@ static struct drm_driver driver = {
27450 + .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
27451 + .load = udl_driver_load,
27452 + .unload = udl_driver_unload,
27453 ++ .release = udl_driver_release,
27454
27455 -- buf = kzalloc(res + padding + 1, GFP_KERNEL);
27456 -- if (!buf)
27457 -- return ERR_PTR(-ENOMEM);
27458 -+ if (res != 0) {
27459 -+ buf = kzalloc(res + padding, GFP_KERNEL);
27460 -+ if (!buf)
27461 -+ return -ENOMEM;
27462 + /* gem hooks */
27463 + .gem_free_object_unlocked = udl_gem_free_object,
27464 +diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
27465 +index e9e9b1ff678e..4ae67d882eae 100644
27466 +--- a/drivers/gpu/drm/udl/udl_drv.h
27467 ++++ b/drivers/gpu/drm/udl/udl_drv.h
27468 +@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb);
27469
27470 -- if (res == 0)
27471 -- goto invalid;
27472 -+ res = vfs_getxattr(dentry, name, buf, res);
27473 -+ if (res < 0)
27474 -+ goto fail;
27475 -+ }
27476 -+ *value = buf;
27477 -+
27478 -+ return res;
27479 -+
27480 -+fail:
27481 -+ pr_warn_ratelimited("overlayfs: failed to get xattr %s: err=%zi)\n",
27482 -+ name, res);
27483 -+ kfree(buf);
27484 -+ return res;
27485 -+}
27486 + int udl_driver_load(struct drm_device *dev, unsigned long flags);
27487 + void udl_driver_unload(struct drm_device *dev);
27488 ++void udl_driver_release(struct drm_device *dev);
27489
27490 -- res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, buf, res);
27491 -+char *ovl_get_redirect_xattr(struct dentry *dentry, int padding)
27492 -+{
27493 -+ int res;
27494 -+ char *s, *next, *buf = NULL;
27495 -+
27496 -+ res = ovl_getxattr(dentry, OVL_XATTR_REDIRECT, &buf, padding + 1);
27497 -+ if (res == -ENODATA)
27498 -+ return NULL;
27499 - if (res < 0)
27500 -- goto fail;
27501 -+ return ERR_PTR(res);
27502 - if (res == 0)
27503 - goto invalid;
27504 -
27505 -@@ -900,15 +921,9 @@ char *ovl_get_redirect_xattr(struct dentry *dentry, int padding)
27506 - }
27507 + int udl_fbdev_init(struct drm_device *dev);
27508 + void udl_fbdev_cleanup(struct drm_device *dev);
27509 +diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
27510 +index 1b014d92855b..19055dda3140 100644
27511 +--- a/drivers/gpu/drm/udl/udl_main.c
27512 ++++ b/drivers/gpu/drm/udl/udl_main.c
27513 +@@ -378,6 +378,12 @@ void udl_driver_unload(struct drm_device *dev)
27514 + udl_free_urb_list(dev);
27515
27516 - return buf;
27517 --
27518 --err_free:
27519 -- kfree(buf);
27520 -- return ERR_PTR(res);
27521 --fail:
27522 -- pr_warn_ratelimited("overlayfs: failed to get redirect (%i)\n", res);
27523 -- goto err_free;
27524 - invalid:
27525 - pr_warn_ratelimited("overlayfs: invalid redirect (%s)\n", buf);
27526 - res = -EINVAL;
27527 -- goto err_free;
27528 -+ kfree(buf);
27529 -+ return ERR_PTR(res);
27530 + udl_fbdev_cleanup(dev);
27531 +- udl_modeset_cleanup(dev);
27532 + kfree(udl);
27533 }
27534 -diff --git a/fs/pipe.c b/fs/pipe.c
27535 -index bdc5d3c0977d..c51750ed4011 100644
27536 ---- a/fs/pipe.c
27537 -+++ b/fs/pipe.c
27538 -@@ -234,6 +234,14 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
27539 - .get = generic_pipe_buf_get,
27540 - };
27541 -
27542 -+static const struct pipe_buf_operations anon_pipe_buf_nomerge_ops = {
27543 -+ .can_merge = 0,
27544 -+ .confirm = generic_pipe_buf_confirm,
27545 -+ .release = anon_pipe_buf_release,
27546 -+ .steal = anon_pipe_buf_steal,
27547 -+ .get = generic_pipe_buf_get,
27548 -+};
27549 +
27550 - static const struct pipe_buf_operations packet_pipe_buf_ops = {
27551 - .can_merge = 0,
27552 - .confirm = generic_pipe_buf_confirm,
27553 -@@ -242,6 +250,12 @@ static const struct pipe_buf_operations packet_pipe_buf_ops = {
27554 - .get = generic_pipe_buf_get,
27555 - };
27556 -
27557 -+void pipe_buf_mark_unmergeable(struct pipe_buffer *buf)
27558 ++void udl_driver_release(struct drm_device *dev)
27559 +{
27560 -+ if (buf->ops == &anon_pipe_buf_ops)
27561 -+ buf->ops = &anon_pipe_buf_nomerge_ops;
27562 ++ udl_modeset_cleanup(dev);
27563 ++ drm_dev_fini(dev);
27564 ++ kfree(dev);
27565 +}
27566 -+
27567 - static ssize_t
27568 - pipe_read(struct kiocb *iocb, struct iov_iter *to)
27569 - {
27570 -diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
27571 -index 4d598a399bbf..d65390727541 100644
27572 ---- a/fs/proc/proc_sysctl.c
27573 -+++ b/fs/proc/proc_sysctl.c
27574 -@@ -1626,7 +1626,8 @@ static void drop_sysctl_table(struct ctl_table_header *header)
27575 - if (--header->nreg)
27576 - return;
27577 -
27578 -- put_links(header);
27579 -+ if (parent)
27580 -+ put_links(header);
27581 - start_unregistering(header);
27582 - if (!--header->count)
27583 - kfree_rcu(header, rcu);
27584 -diff --git a/fs/read_write.c b/fs/read_write.c
27585 -index ff3c5e6f87cf..27b69b85d49f 100644
27586 ---- a/fs/read_write.c
27587 -+++ b/fs/read_write.c
27588 -@@ -1238,6 +1238,9 @@ COMPAT_SYSCALL_DEFINE5(preadv64v2, unsigned long, fd,
27589 - const struct compat_iovec __user *,vec,
27590 - unsigned long, vlen, loff_t, pos, rwf_t, flags)
27591 - {
27592 -+ if (pos == -1)
27593 -+ return do_compat_readv(fd, vec, vlen, flags);
27594 -+
27595 - return do_compat_preadv64(fd, vec, vlen, pos, flags);
27596 - }
27597 - #endif
27598 -@@ -1344,6 +1347,9 @@ COMPAT_SYSCALL_DEFINE5(pwritev64v2, unsigned long, fd,
27599 - const struct compat_iovec __user *,vec,
27600 - unsigned long, vlen, loff_t, pos, rwf_t, flags)
27601 +diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
27602 +index f39a183d59c2..e7e946035027 100644
27603 +--- a/drivers/gpu/drm/virtio/virtgpu_object.c
27604 ++++ b/drivers/gpu/drm/virtio/virtgpu_object.c
27605 +@@ -28,10 +28,21 @@
27606 + static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
27607 + uint32_t *resid)
27608 {
27609 -+ if (pos == -1)
27610 -+ return do_compat_writev(fd, vec, vlen, flags);
27611 -+
27612 - return do_compat_pwritev64(fd, vec, vlen, pos, flags);
27613 - }
27614 - #endif
27615 -diff --git a/fs/splice.c b/fs/splice.c
27616 -index de2ede048473..90c29675d573 100644
27617 ---- a/fs/splice.c
27618 -+++ b/fs/splice.c
27619 -@@ -1597,6 +1597,8 @@ retry:
27620 - */
27621 - obuf->flags &= ~PIPE_BUF_FLAG_GIFT;
27622 -
27623 -+ pipe_buf_mark_unmergeable(obuf);
27624 -+
27625 - obuf->len = len;
27626 - opipe->nrbufs++;
27627 - ibuf->offset += obuf->len;
27628 -@@ -1671,6 +1673,8 @@ static int link_pipe(struct pipe_inode_info *ipipe,
27629 - */
27630 - obuf->flags &= ~PIPE_BUF_FLAG_GIFT;
27631 ++#if 0
27632 + int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
27633
27634 -+ pipe_buf_mark_unmergeable(obuf);
27635 + if (handle < 0)
27636 + return handle;
27637 ++#else
27638 ++ static int handle;
27639 +
27640 - if (obuf->len > len)
27641 - obuf->len = len;
27642 -
27643 -diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
27644 -index b647f0bd150c..94220ba85628 100644
27645 ---- a/fs/udf/truncate.c
27646 -+++ b/fs/udf/truncate.c
27647 -@@ -260,6 +260,9 @@ void udf_truncate_extents(struct inode *inode)
27648 - epos.block = eloc;
27649 - epos.bh = udf_tread(sb,
27650 - udf_get_lb_pblock(sb, &eloc, 0));
27651 -+ /* Error reading indirect block? */
27652 -+ if (!epos.bh)
27653 -+ return;
27654 - if (elen)
27655 - indirect_ext_len =
27656 - (elen + sb->s_blocksize - 1) >>
27657 -diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
27658 -index 3d7a6a9c2370..f8f6f04c4453 100644
27659 ---- a/include/asm-generic/vmlinux.lds.h
27660 -+++ b/include/asm-generic/vmlinux.lds.h
27661 -@@ -733,7 +733,7 @@
27662 - KEEP(*(.orc_unwind_ip)) \
27663 - __stop_orc_unwind_ip = .; \
27664 - } \
27665 -- . = ALIGN(6); \
27666 -+ . = ALIGN(2); \
27667 - .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \
27668 - __start_orc_unwind = .; \
27669 - KEEP(*(.orc_unwind)) \
27670 -diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h
27671 -index bfe1639df02d..97fc498dc767 100644
27672 ---- a/include/drm/drm_cache.h
27673 -+++ b/include/drm/drm_cache.h
27674 -@@ -47,6 +47,24 @@ static inline bool drm_arch_can_wc_memory(void)
27675 - return false;
27676 - #elif defined(CONFIG_MIPS) && defined(CONFIG_CPU_LOONGSON3)
27677 - return false;
27678 -+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
27679 + /*
27680 -+ * The DRM driver stack is designed to work with cache coherent devices
27681 -+ * only, but permits an optimization to be enabled in some cases, where
27682 -+ * for some buffers, both the CPU and the GPU use uncached mappings,
27683 -+ * removing the need for DMA snooping and allocation in the CPU caches.
27684 -+ *
27685 -+ * The use of uncached GPU mappings relies on the correct implementation
27686 -+ * of the PCIe NoSnoop TLP attribute by the platform, otherwise the GPU
27687 -+ * will use cached mappings nonetheless. On x86 platforms, this does not
27688 -+ * seem to matter, as uncached CPU mappings will snoop the caches in any
27689 -+ * case. However, on ARM and arm64, enabling this optimization on a
27690 -+ * platform where NoSnoop is ignored results in loss of coherency, which
27691 -+ * breaks correct operation of the device. Since we have no way of
27692 -+ * detecting whether NoSnoop works or not, just disable this
27693 -+ * optimization entirely for ARM and arm64.
27694 ++ * FIXME: dirty hack to avoid re-using IDs, virglrenderer
27695 ++ * can't deal with that. Needs fixing in virglrenderer, also
27696 ++ * should figure a better way to handle that in the guest.
27697 + */
27698 -+ return false;
27699 - #else
27700 - return true;
27701 - #endif
27702 -diff --git a/include/linux/atalk.h b/include/linux/atalk.h
27703 -index 23f805562f4e..840cf92307ba 100644
27704 ---- a/include/linux/atalk.h
27705 -+++ b/include/linux/atalk.h
27706 -@@ -161,16 +161,26 @@ extern int sysctl_aarp_resolve_time;
27707 - extern void atalk_register_sysctl(void);
27708 - extern void atalk_unregister_sysctl(void);
27709 - #else
27710 --#define atalk_register_sysctl() do { } while(0)
27711 --#define atalk_unregister_sysctl() do { } while(0)
27712 -+static inline int atalk_register_sysctl(void)
27713 -+{
27714 -+ return 0;
27715 -+}
27716 -+static inline void atalk_unregister_sysctl(void)
27717 -+{
27718 -+}
27719 - #endif
27720 ++ handle++;
27721 ++#endif
27722
27723 - #ifdef CONFIG_PROC_FS
27724 - extern int atalk_proc_init(void);
27725 - extern void atalk_proc_exit(void);
27726 - #else
27727 --#define atalk_proc_init() ({ 0; })
27728 --#define atalk_proc_exit() do { } while(0)
27729 -+static inline int atalk_proc_init(void)
27730 -+{
27731 -+ return 0;
27732 -+}
27733 -+static inline void atalk_proc_exit(void)
27734 -+{
27735 -+}
27736 - #endif /* CONFIG_PROC_FS */
27737 + *resid = handle + 1;
27738 + return 0;
27739 +@@ -39,7 +50,9 @@ static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
27740
27741 - #endif /* __LINUX_ATALK_H__ */
27742 -diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
27743 -index 50fb0dee23e8..d35b8ec1c485 100644
27744 ---- a/include/linux/bitrev.h
27745 -+++ b/include/linux/bitrev.h
27746 -@@ -34,41 +34,41 @@ static inline u32 __bitrev32(u32 x)
27747 + static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
27748 + {
27749 ++#if 0
27750 + ida_free(&vgdev->resource_ida, id - 1);
27751 ++#endif
27752 + }
27753
27754 - #define __constant_bitrev32(x) \
27755 - ({ \
27756 -- u32 __x = x; \
27757 -- __x = (__x >> 16) | (__x << 16); \
27758 -- __x = ((__x & (u32)0xFF00FF00UL) >> 8) | ((__x & (u32)0x00FF00FFUL) << 8); \
27759 -- __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \
27760 -- __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \
27761 -- __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \
27762 -- __x; \
27763 -+ u32 ___x = x; \
27764 -+ ___x = (___x >> 16) | (___x << 16); \
27765 -+ ___x = ((___x & (u32)0xFF00FF00UL) >> 8) | ((___x & (u32)0x00FF00FFUL) << 8); \
27766 -+ ___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4); \
27767 -+ ___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2); \
27768 -+ ___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1); \
27769 -+ ___x; \
27770 - })
27771 + static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
27772 +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
27773 +index 15ed6177a7a3..f040c8a7f9a9 100644
27774 +--- a/drivers/hid/hid-logitech-hidpp.c
27775 ++++ b/drivers/hid/hid-logitech-hidpp.c
27776 +@@ -2608,8 +2608,9 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
27777 + input_report_rel(mydata->input, REL_Y, v);
27778
27779 - #define __constant_bitrev16(x) \
27780 - ({ \
27781 -- u16 __x = x; \
27782 -- __x = (__x >> 8) | (__x << 8); \
27783 -- __x = ((__x & (u16)0xF0F0U) >> 4) | ((__x & (u16)0x0F0FU) << 4); \
27784 -- __x = ((__x & (u16)0xCCCCU) >> 2) | ((__x & (u16)0x3333U) << 2); \
27785 -- __x = ((__x & (u16)0xAAAAU) >> 1) | ((__x & (u16)0x5555U) << 1); \
27786 -- __x; \
27787 -+ u16 ___x = x; \
27788 -+ ___x = (___x >> 8) | (___x << 8); \
27789 -+ ___x = ((___x & (u16)0xF0F0U) >> 4) | ((___x & (u16)0x0F0FU) << 4); \
27790 -+ ___x = ((___x & (u16)0xCCCCU) >> 2) | ((___x & (u16)0x3333U) << 2); \
27791 -+ ___x = ((___x & (u16)0xAAAAU) >> 1) | ((___x & (u16)0x5555U) << 1); \
27792 -+ ___x; \
27793 - })
27794 + v = hid_snto32(data[6], 8);
27795 +- hidpp_scroll_counter_handle_scroll(
27796 +- &hidpp->vertical_wheel_counter, v);
27797 ++ if (v != 0)
27798 ++ hidpp_scroll_counter_handle_scroll(
27799 ++ &hidpp->vertical_wheel_counter, v);
27800
27801 - #define __constant_bitrev8x4(x) \
27802 - ({ \
27803 -- u32 __x = x; \
27804 -- __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \
27805 -- __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \
27806 -- __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \
27807 -- __x; \
27808 -+ u32 ___x = x; \
27809 -+ ___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4); \
27810 -+ ___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2); \
27811 -+ ___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1); \
27812 -+ ___x; \
27813 - })
27814 + input_sync(mydata->input);
27815 + }
27816 +diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
27817 +index 6f929bfa9fcd..d0f1dfe2bcbb 100644
27818 +--- a/drivers/hwmon/Kconfig
27819 ++++ b/drivers/hwmon/Kconfig
27820 +@@ -1759,6 +1759,7 @@ config SENSORS_VT8231
27821 + config SENSORS_W83773G
27822 + tristate "Nuvoton W83773G"
27823 + depends on I2C
27824 ++ select REGMAP_I2C
27825 + help
27826 + If you say yes here you get support for the Nuvoton W83773G hardware
27827 + monitoring chip.
27828 +diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
27829 +index 391118c8aae8..c888f4aca45c 100644
27830 +--- a/drivers/hwmon/occ/common.c
27831 ++++ b/drivers/hwmon/occ/common.c
27832 +@@ -889,6 +889,8 @@ static int occ_setup_sensor_attrs(struct occ *occ)
27833 + s++;
27834 + }
27835 + }
27836 ++
27837 ++ s = (sensors->power.num_sensors * 4) + 1;
27838 + } else {
27839 + for (i = 0; i < sensors->power.num_sensors; ++i) {
27840 + s = i + 1;
27841 +@@ -917,11 +919,11 @@ static int occ_setup_sensor_attrs(struct occ *occ)
27842 + show_power, NULL, 3, i);
27843 + attr++;
27844 + }
27845 +- }
27846
27847 - #define __constant_bitrev8(x) \
27848 - ({ \
27849 -- u8 __x = x; \
27850 -- __x = (__x >> 4) | (__x << 4); \
27851 -- __x = ((__x & (u8)0xCCU) >> 2) | ((__x & (u8)0x33U) << 2); \
27852 -- __x = ((__x & (u8)0xAAU) >> 1) | ((__x & (u8)0x55U) << 1); \
27853 -- __x; \
27854 -+ u8 ___x = x; \
27855 -+ ___x = (___x >> 4) | (___x << 4); \
27856 -+ ___x = ((___x & (u8)0xCCU) >> 2) | ((___x & (u8)0x33U) << 2); \
27857 -+ ___x = ((___x & (u8)0xAAU) >> 1) | ((___x & (u8)0x55U) << 1); \
27858 -+ ___x; \
27859 - })
27860 +- if (sensors->caps.num_sensors >= 1) {
27861 + s = sensors->power.num_sensors + 1;
27862 ++ }
27863 +
27864 ++ if (sensors->caps.num_sensors >= 1) {
27865 + snprintf(attr->name, sizeof(attr->name), "power%d_label", s);
27866 + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL,
27867 + 0, 0);
27868 +diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
27869 +index 4ee32964e1dd..948eb6e25219 100644
27870 +--- a/drivers/infiniband/hw/mlx5/odp.c
27871 ++++ b/drivers/infiniband/hw/mlx5/odp.c
27872 +@@ -560,7 +560,7 @@ static int pagefault_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr,
27873 + struct ib_umem_odp *odp_mr = to_ib_umem_odp(mr->umem);
27874 + bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE;
27875 + bool prefetch = flags & MLX5_PF_FLAGS_PREFETCH;
27876 +- u64 access_mask = ODP_READ_ALLOWED_BIT;
27877 ++ u64 access_mask;
27878 + u64 start_idx, page_mask;
27879 + struct ib_umem_odp *odp;
27880 + size_t size;
27881 +@@ -582,6 +582,7 @@ next_mr:
27882 + page_shift = mr->umem->page_shift;
27883 + page_mask = ~(BIT(page_shift) - 1);
27884 + start_idx = (io_virt - (mr->mmkey.iova & page_mask)) >> page_shift;
27885 ++ access_mask = ODP_READ_ALLOWED_BIT;
27886 +
27887 + if (prefetch && !downgrade && !mr->umem->writable) {
27888 + /* prefetch with write-access must
27889 +diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
27890 +index 95c6d86ab5e8..c4ef1fceead6 100644
27891 +--- a/drivers/md/dm-core.h
27892 ++++ b/drivers/md/dm-core.h
27893 +@@ -115,6 +115,7 @@ struct mapped_device {
27894 + struct srcu_struct io_barrier;
27895 + };
27896
27897 - #define bitrev32(x) \
27898 -diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
27899 -index a420c07904bc..337d5049ff93 100644
27900 ---- a/include/linux/ceph/libceph.h
27901 -+++ b/include/linux/ceph/libceph.h
27902 -@@ -294,6 +294,8 @@ extern void ceph_destroy_client(struct ceph_client *client);
27903 - extern int __ceph_open_session(struct ceph_client *client,
27904 - unsigned long started);
27905 - extern int ceph_open_session(struct ceph_client *client);
27906 -+int ceph_wait_for_latest_osdmap(struct ceph_client *client,
27907 -+ unsigned long timeout);
27908 -
27909 - /* pagevec.c */
27910 - extern void ceph_release_page_vector(struct page **pages, int num_pages);
27911 -diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
27912 -index 8fcbae1b8db0..120d1d40704b 100644
27913 ---- a/include/linux/cgroup-defs.h
27914 -+++ b/include/linux/cgroup-defs.h
27915 -@@ -602,7 +602,7 @@ struct cgroup_subsys {
27916 - void (*cancel_fork)(struct task_struct *task);
27917 - void (*fork)(struct task_struct *task);
27918 - void (*exit)(struct task_struct *task);
27919 -- void (*free)(struct task_struct *task);
27920 -+ void (*release)(struct task_struct *task);
27921 - void (*bind)(struct cgroup_subsys_state *root_css);
27922 -
27923 - bool early_init:1;
27924 -diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
27925 -index 9968332cceed..81f58b4a5418 100644
27926 ---- a/include/linux/cgroup.h
27927 -+++ b/include/linux/cgroup.h
27928 -@@ -121,6 +121,7 @@ extern int cgroup_can_fork(struct task_struct *p);
27929 - extern void cgroup_cancel_fork(struct task_struct *p);
27930 - extern void cgroup_post_fork(struct task_struct *p);
27931 - void cgroup_exit(struct task_struct *p);
27932 -+void cgroup_release(struct task_struct *p);
27933 - void cgroup_free(struct task_struct *p);
27934 -
27935 - int cgroup_init_early(void);
27936 -@@ -697,6 +698,7 @@ static inline int cgroup_can_fork(struct task_struct *p) { return 0; }
27937 - static inline void cgroup_cancel_fork(struct task_struct *p) {}
27938 - static inline void cgroup_post_fork(struct task_struct *p) {}
27939 - static inline void cgroup_exit(struct task_struct *p) {}
27940 -+static inline void cgroup_release(struct task_struct *p) {}
27941 - static inline void cgroup_free(struct task_struct *p) {}
27942 -
27943 - static inline int cgroup_init_early(void) { return 0; }
27944 -diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
27945 -index e443fa9fa859..b7cf80a71293 100644
27946 ---- a/include/linux/clk-provider.h
27947 -+++ b/include/linux/clk-provider.h
27948 -@@ -792,6 +792,9 @@ unsigned int __clk_get_enable_count(struct clk *clk);
27949 - unsigned long clk_hw_get_rate(const struct clk_hw *hw);
27950 - unsigned long __clk_get_flags(struct clk *clk);
27951 - unsigned long clk_hw_get_flags(const struct clk_hw *hw);
27952 -+#define clk_hw_can_set_rate_parent(hw) \
27953 -+ (clk_hw_get_flags((hw)) & CLK_SET_RATE_PARENT)
27954 -+
27955 - bool clk_hw_is_prepared(const struct clk_hw *hw);
27956 - bool clk_hw_rate_is_protected(const struct clk_hw *hw);
27957 - bool clk_hw_is_enabled(const struct clk_hw *hw);
27958 -diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
27959 -index c86d6d8bdfed..0b427d5df0fe 100644
27960 ---- a/include/linux/cpufreq.h
27961 -+++ b/include/linux/cpufreq.h
27962 -@@ -254,20 +254,12 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
27963 - static struct freq_attr _name = \
27964 - __ATTR(_name, 0200, NULL, store_##_name)
27965 -
27966 --struct global_attr {
27967 -- struct attribute attr;
27968 -- ssize_t (*show)(struct kobject *kobj,
27969 -- struct attribute *attr, char *buf);
27970 -- ssize_t (*store)(struct kobject *a, struct attribute *b,
27971 -- const char *c, size_t count);
27972 --};
27973 --
27974 - #define define_one_global_ro(_name) \
27975 --static struct global_attr _name = \
27976 -+static struct kobj_attribute _name = \
27977 - __ATTR(_name, 0444, show_##_name, NULL)
27978 -
27979 - #define define_one_global_rw(_name) \
27980 --static struct global_attr _name = \
27981 -+static struct kobj_attribute _name = \
27982 - __ATTR(_name, 0644, show_##_name, store_##_name)
27983 -
27984 -
27985 -diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
27986 -index e528baebad69..bee4bb9f81bc 100644
27987 ---- a/include/linux/device-mapper.h
27988 -+++ b/include/linux/device-mapper.h
27989 -@@ -609,7 +609,7 @@ do { \
27990 - */
27991 - #define dm_target_offset(ti, sector) ((sector) - (ti)->begin)
27992 ++void disable_discard(struct mapped_device *md);
27993 + void disable_write_same(struct mapped_device *md);
27994 + void disable_write_zeroes(struct mapped_device *md);
27995
27996 --static inline sector_t to_sector(unsigned long n)
27997 -+static inline sector_t to_sector(unsigned long long n)
27998 +diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
27999 +index 2e823252d797..f535fd8ac82d 100644
28000 +--- a/drivers/md/dm-integrity.c
28001 ++++ b/drivers/md/dm-integrity.c
28002 +@@ -913,7 +913,7 @@ static void copy_from_journal(struct dm_integrity_c *ic, unsigned section, unsig
28003 + static bool ranges_overlap(struct dm_integrity_range *range1, struct dm_integrity_range *range2)
28004 {
28005 - return (n >> SECTOR_SHIFT);
28006 + return range1->logical_sector < range2->logical_sector + range2->n_sectors &&
28007 +- range2->logical_sector + range2->n_sectors > range2->logical_sector;
28008 ++ range1->logical_sector + range1->n_sectors > range2->logical_sector;
28009 }
28010 -diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
28011 -index f6ded992c183..5b21f14802e1 100644
28012 ---- a/include/linux/dma-mapping.h
28013 -+++ b/include/linux/dma-mapping.h
28014 -@@ -130,6 +130,7 @@ struct dma_map_ops {
28015 - enum dma_data_direction direction);
28016 - int (*dma_supported)(struct device *dev, u64 mask);
28017 - u64 (*get_required_mask)(struct device *dev);
28018 -+ size_t (*max_mapping_size)(struct device *dev);
28019 - };
28020
28021 - #define DMA_MAPPING_ERROR (~(dma_addr_t)0)
28022 -@@ -257,6 +258,8 @@ static inline void dma_direct_sync_sg_for_cpu(struct device *dev,
28023 - }
28024 - #endif
28025 + static bool add_new_range(struct dm_integrity_c *ic, struct dm_integrity_range *new_range, bool check_waiting)
28026 +@@ -959,8 +959,6 @@ static void remove_range_unlocked(struct dm_integrity_c *ic, struct dm_integrity
28027 + struct dm_integrity_range *last_range =
28028 + list_first_entry(&ic->wait_list, struct dm_integrity_range, wait_entry);
28029 + struct task_struct *last_range_task;
28030 +- if (!ranges_overlap(range, last_range))
28031 +- break;
28032 + last_range_task = last_range->task;
28033 + list_del(&last_range->wait_entry);
28034 + if (!add_new_range(ic, last_range, false)) {
28035 +@@ -3185,7 +3183,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
28036 + journal_watermark = val;
28037 + else if (sscanf(opt_string, "commit_time:%u%c", &val, &dummy) == 1)
28038 + sync_msec = val;
28039 +- else if (!memcmp(opt_string, "meta_device:", strlen("meta_device:"))) {
28040 ++ else if (!strncmp(opt_string, "meta_device:", strlen("meta_device:"))) {
28041 + if (ic->meta_dev) {
28042 + dm_put_device(ti, ic->meta_dev);
28043 + ic->meta_dev = NULL;
28044 +@@ -3204,17 +3202,17 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
28045 + goto bad;
28046 + }
28047 + ic->sectors_per_block = val >> SECTOR_SHIFT;
28048 +- } else if (!memcmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
28049 ++ } else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
28050 + r = get_alg_and_key(opt_string, &ic->internal_hash_alg, &ti->error,
28051 + "Invalid internal_hash argument");
28052 + if (r)
28053 + goto bad;
28054 +- } else if (!memcmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
28055 ++ } else if (!strncmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
28056 + r = get_alg_and_key(opt_string, &ic->journal_crypt_alg, &ti->error,
28057 + "Invalid journal_crypt argument");
28058 + if (r)
28059 + goto bad;
28060 +- } else if (!memcmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
28061 ++ } else if (!strncmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
28062 + r = get_alg_and_key(opt_string, &ic->journal_mac_alg, &ti->error,
28063 + "Invalid journal_mac argument");
28064 + if (r)
28065 +diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
28066 +index a20531e5f3b4..582265e043a6 100644
28067 +--- a/drivers/md/dm-rq.c
28068 ++++ b/drivers/md/dm-rq.c
28069 +@@ -206,11 +206,14 @@ static void dm_done(struct request *clone, blk_status_t error, bool mapped)
28070 + }
28071
28072 -+size_t dma_direct_max_mapping_size(struct device *dev);
28073 -+
28074 - #ifdef CONFIG_HAS_DMA
28075 - #include <asm/dma-mapping.h>
28076 -
28077 -@@ -460,6 +463,7 @@ int dma_supported(struct device *dev, u64 mask);
28078 - int dma_set_mask(struct device *dev, u64 mask);
28079 - int dma_set_coherent_mask(struct device *dev, u64 mask);
28080 - u64 dma_get_required_mask(struct device *dev);
28081 -+size_t dma_max_mapping_size(struct device *dev);
28082 - #else /* CONFIG_HAS_DMA */
28083 - static inline dma_addr_t dma_map_page_attrs(struct device *dev,
28084 - struct page *page, size_t offset, size_t size,
28085 -@@ -561,6 +565,10 @@ static inline u64 dma_get_required_mask(struct device *dev)
28086 - {
28087 - return 0;
28088 + if (unlikely(error == BLK_STS_TARGET)) {
28089 +- if (req_op(clone) == REQ_OP_WRITE_SAME &&
28090 +- !clone->q->limits.max_write_same_sectors)
28091 ++ if (req_op(clone) == REQ_OP_DISCARD &&
28092 ++ !clone->q->limits.max_discard_sectors)
28093 ++ disable_discard(tio->md);
28094 ++ else if (req_op(clone) == REQ_OP_WRITE_SAME &&
28095 ++ !clone->q->limits.max_write_same_sectors)
28096 + disable_write_same(tio->md);
28097 +- if (req_op(clone) == REQ_OP_WRITE_ZEROES &&
28098 +- !clone->q->limits.max_write_zeroes_sectors)
28099 ++ else if (req_op(clone) == REQ_OP_WRITE_ZEROES &&
28100 ++ !clone->q->limits.max_write_zeroes_sectors)
28101 + disable_write_zeroes(tio->md);
28102 + }
28103 +
28104 +diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
28105 +index 4b1be754cc41..eb257e4dcb1c 100644
28106 +--- a/drivers/md/dm-table.c
28107 ++++ b/drivers/md/dm-table.c
28108 +@@ -1852,6 +1852,36 @@ static bool dm_table_supports_secure_erase(struct dm_table *t)
28109 + return true;
28110 }
28111 -+static inline size_t dma_max_mapping_size(struct device *dev)
28112 +
28113 ++static int device_requires_stable_pages(struct dm_target *ti,
28114 ++ struct dm_dev *dev, sector_t start,
28115 ++ sector_t len, void *data)
28116 +{
28117 -+ return 0;
28118 ++ struct request_queue *q = bdev_get_queue(dev->bdev);
28119 ++
28120 ++ return q && bdi_cap_stable_pages_required(q->backing_dev_info);
28121 +}
28122 - #endif /* CONFIG_HAS_DMA */
28123 -
28124 - static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
28125 -diff --git a/include/linux/efi.h b/include/linux/efi.h
28126 -index 28604a8d0aa9..a86485ac7c87 100644
28127 ---- a/include/linux/efi.h
28128 -+++ b/include/linux/efi.h
28129 -@@ -1699,19 +1699,19 @@ extern int efi_tpm_eventlog_init(void);
28130 - * fault happened while executing an efi runtime service.
28131 - */
28132 - enum efi_rts_ids {
28133 -- NONE,
28134 -- GET_TIME,
28135 -- SET_TIME,
28136 -- GET_WAKEUP_TIME,
28137 -- SET_WAKEUP_TIME,
28138 -- GET_VARIABLE,
28139 -- GET_NEXT_VARIABLE,
28140 -- SET_VARIABLE,
28141 -- QUERY_VARIABLE_INFO,
28142 -- GET_NEXT_HIGH_MONO_COUNT,
28143 -- RESET_SYSTEM,
28144 -- UPDATE_CAPSULE,
28145 -- QUERY_CAPSULE_CAPS,
28146 -+ EFI_NONE,
28147 -+ EFI_GET_TIME,
28148 -+ EFI_SET_TIME,
28149 -+ EFI_GET_WAKEUP_TIME,
28150 -+ EFI_SET_WAKEUP_TIME,
28151 -+ EFI_GET_VARIABLE,
28152 -+ EFI_GET_NEXT_VARIABLE,
28153 -+ EFI_SET_VARIABLE,
28154 -+ EFI_QUERY_VARIABLE_INFO,
28155 -+ EFI_GET_NEXT_HIGH_MONO_COUNT,
28156 -+ EFI_RESET_SYSTEM,
28157 -+ EFI_UPDATE_CAPSULE,
28158 -+ EFI_QUERY_CAPSULE_CAPS,
28159 - };
28160 -
28161 - /*
28162 -diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
28163 -index d7711048ef93..c524ad7d31da 100644
28164 ---- a/include/linux/f2fs_fs.h
28165 -+++ b/include/linux/f2fs_fs.h
28166 -@@ -489,12 +489,12 @@ typedef __le32 f2fs_hash_t;
28167 -
28168 - /*
28169 - * space utilization of regular dentry and inline dentry (w/o extra reservation)
28170 -- * regular dentry inline dentry
28171 -- * bitmap 1 * 27 = 27 1 * 23 = 23
28172 -- * reserved 1 * 3 = 3 1 * 7 = 7
28173 -- * dentry 11 * 214 = 2354 11 * 182 = 2002
28174 -- * filename 8 * 214 = 1712 8 * 182 = 1456
28175 -- * total 4096 3488
28176 -+ * regular dentry inline dentry (def) inline dentry (min)
28177 -+ * bitmap 1 * 27 = 27 1 * 23 = 23 1 * 1 = 1
28178 -+ * reserved 1 * 3 = 3 1 * 7 = 7 1 * 1 = 1
28179 -+ * dentry 11 * 214 = 2354 11 * 182 = 2002 11 * 2 = 22
28180 -+ * filename 8 * 214 = 1712 8 * 182 = 1456 8 * 2 = 16
28181 -+ * total 4096 3488 40
28182 - *
28183 - * Note: there are more reserved space in inline dentry than in regular
28184 - * dentry, when converting inline dentry we should handle this carefully.
28185 -@@ -506,6 +506,7 @@ typedef __le32 f2fs_hash_t;
28186 - #define SIZE_OF_RESERVED (PAGE_SIZE - ((SIZE_OF_DIR_ENTRY + \
28187 - F2FS_SLOT_LEN) * \
28188 - NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP))
28189 -+#define MIN_INLINE_DENTRY_SIZE 40 /* just include '.' and '..' entries */
28190 -
28191 - /* One directory entry slot representing F2FS_SLOT_LEN-sized file name */
28192 - struct f2fs_dir_entry {
28193 -diff --git a/include/linux/filter.h b/include/linux/filter.h
28194 -index e532fcc6e4b5..3358646a8e7a 100644
28195 ---- a/include/linux/filter.h
28196 -+++ b/include/linux/filter.h
28197 -@@ -874,7 +874,9 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
28198 - unsigned int alignment,
28199 - bpf_jit_fill_hole_t bpf_fill_ill_insns);
28200 - void bpf_jit_binary_free(struct bpf_binary_header *hdr);
28201 --
28202 -+u64 bpf_jit_alloc_exec_limit(void);
28203 -+void *bpf_jit_alloc_exec(unsigned long size);
28204 -+void bpf_jit_free_exec(void *addr);
28205 - void bpf_jit_free(struct bpf_prog *fp);
28206 -
28207 - int bpf_jit_get_func_addr(const struct bpf_prog *prog,
28208 -diff --git a/include/linux/fs.h b/include/linux/fs.h
28209 -index 29d8e2cfed0e..fd423fec8d83 100644
28210 ---- a/include/linux/fs.h
28211 -+++ b/include/linux/fs.h
28212 -@@ -304,13 +304,19 @@ enum rw_hint {
28213 -
28214 - struct kiocb {
28215 - struct file *ki_filp;
28216 +
28217 -+ /* The 'ki_filp' pointer is shared in a union for aio */
28218 -+ randomized_struct_fields_start
28219 ++/*
28220 ++ * If any underlying device requires stable pages, a table must require
28221 ++ * them as well. Only targets that support iterate_devices are considered:
28222 ++ * don't want error, zero, etc to require stable pages.
28223 ++ */
28224 ++static bool dm_table_requires_stable_pages(struct dm_table *t)
28225 ++{
28226 ++ struct dm_target *ti;
28227 ++ unsigned i;
28228 +
28229 - loff_t ki_pos;
28230 - void (*ki_complete)(struct kiocb *iocb, long ret, long ret2);
28231 - void *private;
28232 - int ki_flags;
28233 - u16 ki_hint;
28234 - u16 ki_ioprio; /* See linux/ioprio.h */
28235 --} __randomize_layout;
28236 ++ for (i = 0; i < dm_table_get_num_targets(t); i++) {
28237 ++ ti = dm_table_get_target(t, i);
28238 +
28239 -+ randomized_struct_fields_end
28240 -+};
28241 -
28242 - static inline bool is_sync_kiocb(struct kiocb *kiocb)
28243 - {
28244 -diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
28245 -index 0fbbcdf0c178..da0af631ded5 100644
28246 ---- a/include/linux/hardirq.h
28247 -+++ b/include/linux/hardirq.h
28248 -@@ -60,8 +60,14 @@ extern void irq_enter(void);
28249 - */
28250 - extern void irq_exit(void);
28251 -
28252 -+#ifndef arch_nmi_enter
28253 -+#define arch_nmi_enter() do { } while (0)
28254 -+#define arch_nmi_exit() do { } while (0)
28255 -+#endif
28256 ++ if (ti->type->iterate_devices &&
28257 ++ ti->type->iterate_devices(ti, device_requires_stable_pages, NULL))
28258 ++ return true;
28259 ++ }
28260 +
28261 - #define nmi_enter() \
28262 - do { \
28263 -+ arch_nmi_enter(); \
28264 - printk_nmi_enter(); \
28265 - lockdep_off(); \
28266 - ftrace_nmi_enter(); \
28267 -@@ -80,6 +86,7 @@ extern void irq_exit(void);
28268 - ftrace_nmi_exit(); \
28269 - lockdep_on(); \
28270 - printk_nmi_exit(); \
28271 -+ arch_nmi_exit(); \
28272 - } while (0)
28273 -
28274 - #endif /* LINUX_HARDIRQ_H */
28275 -diff --git a/include/linux/i2c.h b/include/linux/i2c.h
28276 -index 65b4eaed1d96..7e748648c7d3 100644
28277 ---- a/include/linux/i2c.h
28278 -+++ b/include/linux/i2c.h
28279 -@@ -333,6 +333,7 @@ struct i2c_client {
28280 - char name[I2C_NAME_SIZE];
28281 - struct i2c_adapter *adapter; /* the adapter we sit on */
28282 - struct device dev; /* the device structure */
28283 -+ int init_irq; /* irq set at initialization */
28284 - int irq; /* irq issued by device */
28285 - struct list_head detected;
28286 - #if IS_ENABLED(CONFIG_I2C_SLAVE)
28287 -diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
28288 -index dd1e40ddac7d..875c41b23f20 100644
28289 ---- a/include/linux/irqdesc.h
28290 -+++ b/include/linux/irqdesc.h
28291 -@@ -65,6 +65,7 @@ struct irq_desc {
28292 - unsigned int core_internal_state__do_not_mess_with_it;
28293 - unsigned int depth; /* nested irq disables */
28294 - unsigned int wake_depth; /* nested wake enables */
28295 -+ unsigned int tot_count;
28296 - unsigned int irq_count; /* For detecting broken IRQs */
28297 - unsigned long last_unhandled; /* Aging timer for unhandled count */
28298 - unsigned int irqs_unhandled;
28299 -diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h
28300 -index d314150658a4..a61dc075e2ce 100644
28301 ---- a/include/linux/kasan-checks.h
28302 -+++ b/include/linux/kasan-checks.h
28303 -@@ -2,7 +2,7 @@
28304 - #ifndef _LINUX_KASAN_CHECKS_H
28305 - #define _LINUX_KASAN_CHECKS_H
28306 -
28307 --#ifdef CONFIG_KASAN
28308 -+#if defined(__SANITIZE_ADDRESS__) || defined(__KASAN_INTERNAL)
28309 - void kasan_check_read(const volatile void *p, unsigned int size);
28310 - void kasan_check_write(const volatile void *p, unsigned int size);
28311 - #else
28312 -diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
28313 -index c38cc5eb7e73..cf761ff58224 100644
28314 ---- a/include/linux/kvm_host.h
28315 -+++ b/include/linux/kvm_host.h
28316 -@@ -634,7 +634,7 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
28317 - struct kvm_memory_slot *dont);
28318 - int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
28319 - unsigned long npages);
28320 --void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots);
28321 -+void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen);
28322 - int kvm_arch_prepare_memory_region(struct kvm *kvm,
28323 - struct kvm_memory_slot *memslot,
28324 - const struct kvm_userspace_memory_region *mem,
28325 -diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
28326 -index 83ae11cbd12c..7391f5fe4eda 100644
28327 ---- a/include/linux/memcontrol.h
28328 -+++ b/include/linux/memcontrol.h
28329 -@@ -561,7 +561,10 @@ struct mem_cgroup *lock_page_memcg(struct page *page);
28330 - void __unlock_page_memcg(struct mem_cgroup *memcg);
28331 - void unlock_page_memcg(struct page *page);
28332 -
28333 --/* idx can be of type enum memcg_stat_item or node_stat_item */
28334 -+/*
28335 -+ * idx can be of type enum memcg_stat_item or node_stat_item.
28336 -+ * Keep in sync with memcg_exact_page_state().
28337 -+ */
28338 - static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
28339 - int idx)
28340 ++ return false;
28341 ++}
28342 ++
28343 + void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
28344 + struct queue_limits *limits)
28345 {
28346 -diff --git a/include/linux/mii.h b/include/linux/mii.h
28347 -index 6fee8b1a4400..5cd824c1c0ca 100644
28348 ---- a/include/linux/mii.h
28349 -+++ b/include/linux/mii.h
28350 -@@ -469,7 +469,7 @@ static inline u32 linkmode_adv_to_lcl_adv_t(unsigned long *advertising)
28351 - if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
28352 - advertising))
28353 - lcl_adv |= ADVERTISE_PAUSE_CAP;
28354 -- if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
28355 -+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
28356 - advertising))
28357 - lcl_adv |= ADVERTISE_PAUSE_ASYM;
28358 -
28359 -diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
28360 -index 54299251d40d..4f001619f854 100644
28361 ---- a/include/linux/mlx5/driver.h
28362 -+++ b/include/linux/mlx5/driver.h
28363 -@@ -591,6 +591,8 @@ enum mlx5_pagefault_type_flags {
28364 - };
28365 +@@ -1909,6 +1939,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
28366
28367 - struct mlx5_td {
28368 -+ /* protects tirs list changes while tirs refresh */
28369 -+ struct mutex list_lock;
28370 - struct list_head tirs_list;
28371 - u32 tdn;
28372 - };
28373 -diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
28374 -index 4eb26d278046..280ae96dc4c3 100644
28375 ---- a/include/linux/page-isolation.h
28376 -+++ b/include/linux/page-isolation.h
28377 -@@ -41,16 +41,6 @@ int move_freepages_block(struct zone *zone, struct page *page,
28378 + dm_table_verify_integrity(t);
28379
28380 - /*
28381 - * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE.
28382 -- * If specified range includes migrate types other than MOVABLE or CMA,
28383 -- * this will fail with -EBUSY.
28384 -- *
28385 -- * For isolating all pages in the range finally, the caller have to
28386 -- * free all pages in the range. test_page_isolated() can be used for
28387 -- * test it.
28388 -- *
28389 -- * The following flags are allowed (they can be combined in a bit mask)
28390 -- * SKIP_HWPOISON - ignore hwpoison pages
28391 -- * REPORT_FAILURE - report details about the failure to isolate the range
28392 - */
28393 - int
28394 - start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
28395 -diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
28396 -index e1a051724f7e..7cbbd891bfcd 100644
28397 ---- a/include/linux/perf_event.h
28398 -+++ b/include/linux/perf_event.h
28399 -@@ -409,7 +409,7 @@ struct pmu {
28400 ++ /*
28401 ++ * Some devices don't use blk_integrity but still want stable pages
28402 ++ * because they do their own checksumming.
28403 ++ */
28404 ++ if (dm_table_requires_stable_pages(t))
28405 ++ q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES;
28406 ++ else
28407 ++ q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES;
28408 ++
28409 /*
28410 - * Set up pmu-private data structures for an AUX area
28411 - */
28412 -- void *(*setup_aux) (int cpu, void **pages,
28413 -+ void *(*setup_aux) (struct perf_event *event, void **pages,
28414 - int nr_pages, bool overwrite);
28415 - /* optional */
28416 -
28417 -diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
28418 -index 5a3bb3b7c9ad..3ecd7ea212ae 100644
28419 ---- a/include/linux/pipe_fs_i.h
28420 -+++ b/include/linux/pipe_fs_i.h
28421 -@@ -182,6 +182,7 @@ void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
28422 - int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *);
28423 - int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
28424 - void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
28425 -+void pipe_buf_mark_unmergeable(struct pipe_buffer *buf);
28426 -
28427 - extern const struct pipe_buf_operations nosteal_pipe_buf_ops;
28428 -
28429 -diff --git a/include/linux/property.h b/include/linux/property.h
28430 -index 3789ec755fb6..65d3420dd5d1 100644
28431 ---- a/include/linux/property.h
28432 -+++ b/include/linux/property.h
28433 -@@ -258,7 +258,7 @@ struct property_entry {
28434 - #define PROPERTY_ENTRY_STRING(_name_, _val_) \
28435 - (struct property_entry) { \
28436 - .name = _name_, \
28437 -- .length = sizeof(_val_), \
28438 -+ .length = sizeof(const char *), \
28439 - .type = DEV_PROP_STRING, \
28440 - { .value = { .str = _val_ } }, \
28441 - }
28442 -diff --git a/include/linux/relay.h b/include/linux/relay.h
28443 -index e1bdf01a86e2..c759f96e39c1 100644
28444 ---- a/include/linux/relay.h
28445 -+++ b/include/linux/relay.h
28446 -@@ -66,7 +66,7 @@ struct rchan
28447 - struct kref kref; /* channel refcount */
28448 - void *private_data; /* for user-defined data */
28449 - size_t last_toobig; /* tried to log event > subbuf size */
28450 -- struct rchan_buf ** __percpu buf; /* per-cpu channel buffers */
28451 -+ struct rchan_buf * __percpu *buf; /* per-cpu channel buffers */
28452 - int is_global; /* One global buffer ? */
28453 - struct list_head list; /* for channel list */
28454 - struct dentry *parent; /* parent dentry passed to open */
28455 -diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
28456 -index 5b9ae62272bb..503778920448 100644
28457 ---- a/include/linux/ring_buffer.h
28458 -+++ b/include/linux/ring_buffer.h
28459 -@@ -128,7 +128,7 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts,
28460 - unsigned long *lost_events);
28461 -
28462 - struct ring_buffer_iter *
28463 --ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu);
28464 -+ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu, gfp_t flags);
28465 - void ring_buffer_read_prepare_sync(void);
28466 - void ring_buffer_read_start(struct ring_buffer_iter *iter);
28467 - void ring_buffer_read_finish(struct ring_buffer_iter *iter);
28468 -diff --git a/include/linux/sched.h b/include/linux/sched.h
28469 -index f9b43c989577..9b35aff09f70 100644
28470 ---- a/include/linux/sched.h
28471 -+++ b/include/linux/sched.h
28472 -@@ -1748,9 +1748,9 @@ static __always_inline bool need_resched(void)
28473 - static inline unsigned int task_cpu(const struct task_struct *p)
28474 - {
28475 - #ifdef CONFIG_THREAD_INFO_IN_TASK
28476 -- return p->cpu;
28477 -+ return READ_ONCE(p->cpu);
28478 - #else
28479 -- return task_thread_info(p)->cpu;
28480 -+ return READ_ONCE(task_thread_info(p)->cpu);
28481 - #endif
28482 + * Determine whether or not this queue's I/O timings contribute
28483 + * to the entropy pool, Only request-based targets use this.
28484 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
28485 +index 515e6af9bed2..4986eea520b6 100644
28486 +--- a/drivers/md/dm.c
28487 ++++ b/drivers/md/dm.c
28488 +@@ -963,6 +963,15 @@ static void dec_pending(struct dm_io *io, blk_status_t error)
28489 + }
28490 }
28491
28492 -diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
28493 -index c31d3a47a47c..57c7ed3fe465 100644
28494 ---- a/include/linux/sched/topology.h
28495 -+++ b/include/linux/sched/topology.h
28496 -@@ -176,10 +176,10 @@ typedef int (*sched_domain_flags_f)(void);
28497 - #define SDTL_OVERLAP 0x01
28498 -
28499 - struct sd_data {
28500 -- struct sched_domain **__percpu sd;
28501 -- struct sched_domain_shared **__percpu sds;
28502 -- struct sched_group **__percpu sg;
28503 -- struct sched_group_capacity **__percpu sgc;
28504 -+ struct sched_domain *__percpu *sd;
28505 -+ struct sched_domain_shared *__percpu *sds;
28506 -+ struct sched_group *__percpu *sg;
28507 -+ struct sched_group_capacity *__percpu *sgc;
28508 - };
28509 -
28510 - struct sched_domain_topology_level {
28511 -diff --git a/include/linux/slab.h b/include/linux/slab.h
28512 -index 11b45f7ae405..9449b19c5f10 100644
28513 ---- a/include/linux/slab.h
28514 -+++ b/include/linux/slab.h
28515 -@@ -32,6 +32,8 @@
28516 - #define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U)
28517 - /* Use GFP_DMA memory */
28518 - #define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U)
28519 -+/* Use GFP_DMA32 memory */
28520 -+#define SLAB_CACHE_DMA32 ((slab_flags_t __force)0x00008000U)
28521 - /* DEBUG: Store the last owner for bug hunting */
28522 - #define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U)
28523 - /* Panic if kmem_cache_create() fails */
28524 -diff --git a/include/linux/string.h b/include/linux/string.h
28525 -index 7927b875f80c..6ab0a6fa512e 100644
28526 ---- a/include/linux/string.h
28527 -+++ b/include/linux/string.h
28528 -@@ -150,6 +150,9 @@ extern void * memscan(void *,int,__kernel_size_t);
28529 - #ifndef __HAVE_ARCH_MEMCMP
28530 - extern int memcmp(const void *,const void *,__kernel_size_t);
28531 - #endif
28532 -+#ifndef __HAVE_ARCH_BCMP
28533 -+extern int bcmp(const void *,const void *,__kernel_size_t);
28534 -+#endif
28535 - #ifndef __HAVE_ARCH_MEMCHR
28536 - extern void * memchr(const void *,int,__kernel_size_t);
28537 - #endif
28538 -diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
28539 -index 7c007ed7505f..29bc3a203283 100644
28540 ---- a/include/linux/swiotlb.h
28541 -+++ b/include/linux/swiotlb.h
28542 -@@ -76,6 +76,8 @@ bool swiotlb_map(struct device *dev, phys_addr_t *phys, dma_addr_t *dma_addr,
28543 - size_t size, enum dma_data_direction dir, unsigned long attrs);
28544 - void __init swiotlb_exit(void);
28545 - unsigned int swiotlb_max_segment(void);
28546 -+size_t swiotlb_max_mapping_size(struct device *dev);
28547 -+bool is_swiotlb_active(void);
28548 - #else
28549 - #define swiotlb_force SWIOTLB_NO_FORCE
28550 - static inline bool is_swiotlb_buffer(phys_addr_t paddr)
28551 -@@ -95,6 +97,15 @@ static inline unsigned int swiotlb_max_segment(void)
28552 - {
28553 - return 0;
28554 - }
28555 -+static inline size_t swiotlb_max_mapping_size(struct device *dev)
28556 ++void disable_discard(struct mapped_device *md)
28557 +{
28558 -+ return SIZE_MAX;
28559 -+}
28560 ++ struct queue_limits *limits = dm_get_queue_limits(md);
28561 +
28562 -+static inline bool is_swiotlb_active(void)
28563 -+{
28564 -+ return false;
28565 ++ /* device doesn't really support DISCARD, disable it */
28566 ++ limits->max_discard_sectors = 0;
28567 ++ blk_queue_flag_clear(QUEUE_FLAG_DISCARD, md->queue);
28568 +}
28569 - #endif /* CONFIG_SWIOTLB */
28570 -
28571 - extern void swiotlb_print_info(void);
28572 -diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
28573 -index fab02133a919..3dc70adfe5f5 100644
28574 ---- a/include/linux/virtio_ring.h
28575 -+++ b/include/linux/virtio_ring.h
28576 -@@ -63,7 +63,7 @@ struct virtqueue;
28577 - /*
28578 - * Creates a virtqueue and allocates the descriptor ring. If
28579 - * may_reduce_num is set, then this may allocate a smaller ring than
28580 -- * expected. The caller should query virtqueue_get_ring_size to learn
28581 -+ * expected. The caller should query virtqueue_get_vring_size to learn
28582 - * the actual size of the ring.
28583 - */
28584 - struct virtqueue *vring_create_virtqueue(unsigned int index,
28585 -diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
28586 -index ec9d6bc65855..fabee6db0abb 100644
28587 ---- a/include/net/bluetooth/bluetooth.h
28588 -+++ b/include/net/bluetooth/bluetooth.h
28589 -@@ -276,7 +276,7 @@ int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
28590 - int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
28591 - int bt_sock_wait_ready(struct sock *sk, unsigned long flags);
28592 -
28593 --void bt_accept_enqueue(struct sock *parent, struct sock *sk);
28594 -+void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh);
28595 - void bt_accept_unlink(struct sock *sk);
28596 - struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
28597 ++
28598 + void disable_write_same(struct mapped_device *md)
28599 + {
28600 + struct queue_limits *limits = dm_get_queue_limits(md);
28601 +@@ -988,11 +997,14 @@ static void clone_endio(struct bio *bio)
28602 + dm_endio_fn endio = tio->ti->type->end_io;
28603
28604 -diff --git a/include/net/ip.h b/include/net/ip.h
28605 -index be3cad9c2e4c..583526aad1d0 100644
28606 ---- a/include/net/ip.h
28607 -+++ b/include/net/ip.h
28608 -@@ -677,7 +677,7 @@ int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
28609 - unsigned char __user *data, int optlen);
28610 - void ip_options_undo(struct ip_options *opt);
28611 - void ip_forward_options(struct sk_buff *skb);
28612 --int ip_options_rcv_srr(struct sk_buff *skb);
28613 -+int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev);
28614 + if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) {
28615 +- if (bio_op(bio) == REQ_OP_WRITE_SAME &&
28616 +- !bio->bi_disk->queue->limits.max_write_same_sectors)
28617 ++ if (bio_op(bio) == REQ_OP_DISCARD &&
28618 ++ !bio->bi_disk->queue->limits.max_discard_sectors)
28619 ++ disable_discard(md);
28620 ++ else if (bio_op(bio) == REQ_OP_WRITE_SAME &&
28621 ++ !bio->bi_disk->queue->limits.max_write_same_sectors)
28622 + disable_write_same(md);
28623 +- if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
28624 +- !bio->bi_disk->queue->limits.max_write_zeroes_sectors)
28625 ++ else if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
28626 ++ !bio->bi_disk->queue->limits.max_write_zeroes_sectors)
28627 + disable_write_zeroes(md);
28628 + }
28629
28630 - /*
28631 - * Functions provided by ip_sockglue.c
28632 -diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
28633 -index 99d4148e0f90..1c3126c14930 100644
28634 ---- a/include/net/net_namespace.h
28635 -+++ b/include/net/net_namespace.h
28636 -@@ -58,6 +58,7 @@ struct net {
28637 - */
28638 - spinlock_t rules_mod_lock;
28639 +@@ -1060,15 +1072,7 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
28640 + return -EINVAL;
28641 + }
28642
28643 -+ u32 hash_mix;
28644 - atomic64_t cookie_gen;
28645 +- /*
28646 +- * BIO based queue uses its own splitting. When multipage bvecs
28647 +- * is switched on, size of the incoming bio may be too big to
28648 +- * be handled in some targets, such as crypt.
28649 +- *
28650 +- * When these targets are ready for the big bio, we can remove
28651 +- * the limit.
28652 +- */
28653 +- ti->max_io_len = min_t(uint32_t, len, BIO_MAX_PAGES * PAGE_SIZE);
28654 ++ ti->max_io_len = (uint32_t) len;
28655
28656 - struct list_head list; /* list of network namespaces */
28657 -diff --git a/include/net/netfilter/br_netfilter.h b/include/net/netfilter/br_netfilter.h
28658 -index 4cd56808ac4e..89808ce293c4 100644
28659 ---- a/include/net/netfilter/br_netfilter.h
28660 -+++ b/include/net/netfilter/br_netfilter.h
28661 -@@ -43,7 +43,6 @@ static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
28662 + return 0;
28663 }
28664 +diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
28665 +index 82a97866e0cf..7c8f203f9a24 100644
28666 +--- a/drivers/mmc/host/alcor.c
28667 ++++ b/drivers/mmc/host/alcor.c
28668 +@@ -48,7 +48,6 @@ struct alcor_sdmmc_host {
28669 + struct mmc_command *cmd;
28670 + struct mmc_data *data;
28671 + unsigned int dma_on:1;
28672 +- unsigned int early_data:1;
28673
28674 - struct net_device *setup_pre_routing(struct sk_buff *skb);
28675 --void br_netfilter_enable(void);
28676 + struct mutex cmd_mutex;
28677
28678 - #if IS_ENABLED(CONFIG_IPV6)
28679 - int br_validate_ipv6(struct net *net, struct sk_buff *skb);
28680 -diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
28681 -index b4984bbbe157..0612439909dc 100644
28682 ---- a/include/net/netfilter/nf_tables.h
28683 -+++ b/include/net/netfilter/nf_tables.h
28684 -@@ -416,7 +416,8 @@ struct nft_set {
28685 - unsigned char *udata;
28686 - /* runtime data below here */
28687 - const struct nft_set_ops *ops ____cacheline_aligned;
28688 -- u16 flags:14,
28689 -+ u16 flags:13,
28690 -+ bound:1,
28691 - genmask:2;
28692 - u8 klen;
28693 - u8 dlen;
28694 -@@ -690,10 +691,12 @@ static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
28695 - gcb->elems[gcb->head.cnt++] = elem;
28696 +@@ -144,8 +143,7 @@ static void alcor_data_set_dma(struct alcor_sdmmc_host *host)
28697 + host->sg_count--;
28698 }
28699
28700 -+struct nft_expr_ops;
28701 - /**
28702 - * struct nft_expr_type - nf_tables expression type
28703 - *
28704 - * @select_ops: function to select nft_expr_ops
28705 -+ * @release_ops: release nft_expr_ops
28706 - * @ops: default ops, used when no select_ops functions is present
28707 - * @list: used internally
28708 - * @name: Identifier
28709 -@@ -706,6 +709,7 @@ static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
28710 - struct nft_expr_type {
28711 - const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *,
28712 - const struct nlattr * const tb[]);
28713 -+ void (*release_ops)(const struct nft_expr_ops *ops);
28714 - const struct nft_expr_ops *ops;
28715 - struct list_head list;
28716 - const char *name;
28717 -@@ -1329,15 +1333,12 @@ struct nft_trans_rule {
28718 - struct nft_trans_set {
28719 - struct nft_set *set;
28720 - u32 set_id;
28721 -- bool bound;
28722 - };
28723 -
28724 - #define nft_trans_set(trans) \
28725 - (((struct nft_trans_set *)trans->data)->set)
28726 - #define nft_trans_set_id(trans) \
28727 - (((struct nft_trans_set *)trans->data)->set_id)
28728 --#define nft_trans_set_bound(trans) \
28729 -- (((struct nft_trans_set *)trans->data)->bound)
28730 -
28731 - struct nft_trans_chain {
28732 - bool update;
28733 -diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h
28734 -index 16a842456189..d9b665151f3d 100644
28735 ---- a/include/net/netns/hash.h
28736 -+++ b/include/net/netns/hash.h
28737 -@@ -2,16 +2,10 @@
28738 - #ifndef __NET_NS_HASH_H__
28739 - #define __NET_NS_HASH_H__
28740 +-static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host,
28741 +- bool early)
28742 ++static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host)
28743 + {
28744 + struct alcor_pci_priv *priv = host->alcor_pci;
28745 + struct mmc_data *data = host->data;
28746 +@@ -155,13 +153,6 @@ static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host,
28747 + ctrl |= AU6601_DATA_WRITE;
28748
28749 --#include <asm/cache.h>
28750 + if (data->host_cookie == COOKIE_MAPPED) {
28751 +- if (host->early_data) {
28752 +- host->early_data = false;
28753 +- return;
28754 +- }
28755 -
28756 --struct net;
28757 -+#include <net/net_namespace.h>
28758 -
28759 - static inline u32 net_hash_mix(const struct net *net)
28760 +- host->early_data = early;
28761 +-
28762 + alcor_data_set_dma(host);
28763 + ctrl |= AU6601_DATA_DMA_MODE;
28764 + host->dma_on = 1;
28765 +@@ -231,6 +222,7 @@ static void alcor_prepare_sg_miter(struct alcor_sdmmc_host *host)
28766 + static void alcor_prepare_data(struct alcor_sdmmc_host *host,
28767 + struct mmc_command *cmd)
28768 {
28769 --#ifdef CONFIG_NET_NS
28770 -- return (u32)(((unsigned long)net) >> ilog2(sizeof(*net)));
28771 --#else
28772 -- return 0;
28773 --#endif
28774 -+ return net->hash_mix;
28775 - }
28776 - #endif
28777 -diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
28778 -index 9481f2c142e2..e7eb4aa6ccc9 100644
28779 ---- a/include/net/sch_generic.h
28780 -+++ b/include/net/sch_generic.h
28781 -@@ -51,7 +51,10 @@ struct qdisc_size_table {
28782 - struct qdisc_skb_head {
28783 - struct sk_buff *head;
28784 - struct sk_buff *tail;
28785 -- __u32 qlen;
28786 -+ union {
28787 -+ u32 qlen;
28788 -+ atomic_t atomic_qlen;
28789 -+ };
28790 - spinlock_t lock;
28791 - };
28792 ++ struct alcor_pci_priv *priv = host->alcor_pci;
28793 + struct mmc_data *data = cmd->data;
28794
28795 -@@ -408,27 +411,19 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
28796 - BUILD_BUG_ON(sizeof(qcb->data) < sz);
28797 - }
28798 + if (!data)
28799 +@@ -248,7 +240,7 @@ static void alcor_prepare_data(struct alcor_sdmmc_host *host,
28800 + if (data->host_cookie != COOKIE_MAPPED)
28801 + alcor_prepare_sg_miter(host);
28802
28803 --static inline int qdisc_qlen_cpu(const struct Qdisc *q)
28804 --{
28805 -- return this_cpu_ptr(q->cpu_qstats)->qlen;
28806 --}
28807 --
28808 - static inline int qdisc_qlen(const struct Qdisc *q)
28809 - {
28810 - return q->q.qlen;
28811 +- alcor_trigger_data_transfer(host, true);
28812 ++ alcor_write8(priv, 0, AU6601_DATA_XFER_CTRL);
28813 }
28814
28815 --static inline int qdisc_qlen_sum(const struct Qdisc *q)
28816 -+static inline u32 qdisc_qlen_sum(const struct Qdisc *q)
28817 - {
28818 -- __u32 qlen = q->qstats.qlen;
28819 -- int i;
28820 -+ u32 qlen = q->qstats.qlen;
28821 -
28822 -- if (q->flags & TCQ_F_NOLOCK) {
28823 -- for_each_possible_cpu(i)
28824 -- qlen += per_cpu_ptr(q->cpu_qstats, i)->qlen;
28825 -- } else {
28826 -+ if (q->flags & TCQ_F_NOLOCK)
28827 -+ qlen += atomic_read(&q->q.atomic_qlen);
28828 -+ else
28829 - qlen += q->q.qlen;
28830 -- }
28831 + static void alcor_send_cmd(struct alcor_sdmmc_host *host,
28832 +@@ -435,7 +427,7 @@ static int alcor_cmd_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
28833 + if (!host->data)
28834 + return false;
28835
28836 - return qlen;
28837 +- alcor_trigger_data_transfer(host, false);
28838 ++ alcor_trigger_data_transfer(host);
28839 + host->cmd = NULL;
28840 + return true;
28841 }
28842 -@@ -825,14 +820,14 @@ static inline void qdisc_qstats_cpu_backlog_inc(struct Qdisc *sch,
28843 - this_cpu_add(sch->cpu_qstats->backlog, qdisc_pkt_len(skb));
28844 +@@ -456,7 +448,7 @@ static void alcor_cmd_irq_thread(struct alcor_sdmmc_host *host, u32 intmask)
28845 + if (!host->data)
28846 + alcor_request_complete(host, 1);
28847 + else
28848 +- alcor_trigger_data_transfer(host, false);
28849 ++ alcor_trigger_data_transfer(host);
28850 + host->cmd = NULL;
28851 }
28852
28853 --static inline void qdisc_qstats_cpu_qlen_inc(struct Qdisc *sch)
28854 -+static inline void qdisc_qstats_atomic_qlen_inc(struct Qdisc *sch)
28855 - {
28856 -- this_cpu_inc(sch->cpu_qstats->qlen);
28857 -+ atomic_inc(&sch->q.atomic_qlen);
28858 - }
28859 +@@ -487,15 +479,9 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
28860 + break;
28861 + case AU6601_INT_READ_BUF_RDY:
28862 + alcor_trf_block_pio(host, true);
28863 +- if (!host->blocks)
28864 +- break;
28865 +- alcor_trigger_data_transfer(host, false);
28866 + return 1;
28867 + case AU6601_INT_WRITE_BUF_RDY:
28868 + alcor_trf_block_pio(host, false);
28869 +- if (!host->blocks)
28870 +- break;
28871 +- alcor_trigger_data_transfer(host, false);
28872 + return 1;
28873 + case AU6601_INT_DMA_END:
28874 + if (!host->sg_count)
28875 +@@ -508,8 +494,14 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask)
28876 + break;
28877 + }
28878
28879 --static inline void qdisc_qstats_cpu_qlen_dec(struct Qdisc *sch)
28880 -+static inline void qdisc_qstats_atomic_qlen_dec(struct Qdisc *sch)
28881 - {
28882 -- this_cpu_dec(sch->cpu_qstats->qlen);
28883 -+ atomic_dec(&sch->q.atomic_qlen);
28884 - }
28885 +- if (intmask & AU6601_INT_DATA_END)
28886 +- return 0;
28887 ++ if (intmask & AU6601_INT_DATA_END) {
28888 ++ if (!host->dma_on && host->blocks) {
28889 ++ alcor_trigger_data_transfer(host);
28890 ++ return 1;
28891 ++ } else {
28892 ++ return 0;
28893 ++ }
28894 ++ }
28895
28896 - static inline void qdisc_qstats_cpu_requeues_inc(struct Qdisc *sch)
28897 -diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
28898 -index 32ee65a30aff..1c6e6c0766ca 100644
28899 ---- a/include/net/sctp/checksum.h
28900 -+++ b/include/net/sctp/checksum.h
28901 -@@ -61,7 +61,7 @@ static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2,
28902 - static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
28903 - unsigned int offset)
28904 - {
28905 -- struct sctphdr *sh = sctp_hdr(skb);
28906 -+ struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
28907 - const struct skb_checksum_ops ops = {
28908 - .update = sctp_csum_update,
28909 - .combine = sctp_csum_combine,
28910 -diff --git a/include/net/sock.h b/include/net/sock.h
28911 -index f43f935cb113..89d0d94d5db2 100644
28912 ---- a/include/net/sock.h
28913 -+++ b/include/net/sock.h
28914 -@@ -710,6 +710,12 @@ static inline void sk_add_node_rcu(struct sock *sk, struct hlist_head *list)
28915 - hlist_add_head_rcu(&sk->sk_node, list);
28916 + return 1;
28917 + }
28918 +diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
28919 +index c11c18a9aacb..9ec300ec94ba 100644
28920 +--- a/drivers/mmc/host/sdhci-omap.c
28921 ++++ b/drivers/mmc/host/sdhci-omap.c
28922 +@@ -797,6 +797,43 @@ void sdhci_omap_reset(struct sdhci_host *host, u8 mask)
28923 + sdhci_reset(host, mask);
28924 }
28925
28926 -+static inline void sk_add_node_tail_rcu(struct sock *sk, struct hlist_head *list)
28927 ++#define CMD_ERR_MASK (SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX |\
28928 ++ SDHCI_INT_TIMEOUT)
28929 ++#define CMD_MASK (CMD_ERR_MASK | SDHCI_INT_RESPONSE)
28930 ++
28931 ++static u32 sdhci_omap_irq(struct sdhci_host *host, u32 intmask)
28932 +{
28933 -+ sock_hold(sk);
28934 -+ hlist_add_tail_rcu(&sk->sk_node, list);
28935 -+}
28936 ++ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
28937 ++ struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
28938 +
28939 - static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
28940 - {
28941 - hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list);
28942 -diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
28943 -index cb8a273732cf..bb8092fa1e36 100644
28944 ---- a/include/scsi/libfcoe.h
28945 -+++ b/include/scsi/libfcoe.h
28946 -@@ -79,7 +79,7 @@ enum fip_state {
28947 - * It must not change after fcoe_ctlr_init() sets it.
28948 - */
28949 - enum fip_mode {
28950 -- FIP_MODE_AUTO = FIP_ST_AUTO,
28951 -+ FIP_MODE_AUTO,
28952 - FIP_MODE_NON_FIP,
28953 - FIP_MODE_FABRIC,
28954 - FIP_MODE_VN2VN,
28955 -@@ -250,7 +250,7 @@ struct fcoe_rport {
28956 - };
28957 -
28958 - /* FIP API functions */
28959 --void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_state);
28960 -+void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_mode);
28961 - void fcoe_ctlr_destroy(struct fcoe_ctlr *);
28962 - void fcoe_ctlr_link_up(struct fcoe_ctlr *);
28963 - int fcoe_ctlr_link_down(struct fcoe_ctlr *);
28964 -diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h
28965 -index b9ba520f7e4b..2832134e5397 100644
28966 ---- a/include/uapi/linux/android/binder.h
28967 -+++ b/include/uapi/linux/android/binder.h
28968 -@@ -41,6 +41,14 @@ enum {
28969 - enum {
28970 - FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
28971 - FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
28972 ++ if (omap_host->is_tuning && host->cmd && !host->data_early &&
28973 ++ (intmask & CMD_ERR_MASK)) {
28974 +
28975 -+ /**
28976 -+ * @FLAT_BINDER_FLAG_TXN_SECURITY_CTX: request security contexts
28977 -+ *
28978 -+ * Only when set, causes senders to include their security
28979 -+ * context
28980 -+ */
28981 -+ FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000,
28982 - };
28983 -
28984 - #ifdef BINDER_IPC_32BIT
28985 -@@ -218,6 +226,7 @@ struct binder_node_info_for_ref {
28986 - #define BINDER_VERSION _IOWR('b', 9, struct binder_version)
28987 - #define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
28988 - #define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref)
28989 -+#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
28990 -
28991 - /*
28992 - * NOTE: Two special error codes you should check for when calling
28993 -@@ -276,6 +285,11 @@ struct binder_transaction_data {
28994 - } data;
28995 - };
28996 -
28997 -+struct binder_transaction_data_secctx {
28998 -+ struct binder_transaction_data transaction_data;
28999 -+ binder_uintptr_t secctx;
29000 -+};
29001 ++ /*
29002 ++ * Since we are not resetting data lines during tuning
29003 ++ * operation, data error or data complete interrupts
29004 ++ * might still arrive. Mark this request as a failure
29005 ++ * but still wait for the data interrupt
29006 ++ */
29007 ++ if (intmask & SDHCI_INT_TIMEOUT)
29008 ++ host->cmd->error = -ETIMEDOUT;
29009 ++ else
29010 ++ host->cmd->error = -EILSEQ;
29011 +
29012 - struct binder_transaction_data_sg {
29013 - struct binder_transaction_data transaction_data;
29014 - binder_size_t buffers_size;
29015 -@@ -311,6 +325,11 @@ enum binder_driver_return_protocol {
29016 - BR_OK = _IO('r', 1),
29017 - /* No parameters! */
29018 -
29019 -+ BR_TRANSACTION_SEC_CTX = _IOR('r', 2,
29020 -+ struct binder_transaction_data_secctx),
29021 -+ /*
29022 -+ * binder_transaction_data_secctx: the received command.
29023 -+ */
29024 - BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
29025 - BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
29026 - /*
29027 -diff --git a/kernel/audit.h b/kernel/audit.h
29028 -index 91421679a168..6ffb70575082 100644
29029 ---- a/kernel/audit.h
29030 -+++ b/kernel/audit.h
29031 -@@ -314,7 +314,7 @@ extern void audit_trim_trees(void);
29032 - extern int audit_tag_tree(char *old, char *new);
29033 - extern const char *audit_tree_path(struct audit_tree *tree);
29034 - extern void audit_put_tree(struct audit_tree *tree);
29035 --extern void audit_kill_trees(struct list_head *list);
29036 -+extern void audit_kill_trees(struct audit_context *context);
29037 - #else
29038 - #define audit_remove_tree_rule(rule) BUG()
29039 - #define audit_add_tree_rule(rule) -EINVAL
29040 -@@ -323,7 +323,7 @@ extern void audit_kill_trees(struct list_head *list);
29041 - #define audit_put_tree(tree) (void)0
29042 - #define audit_tag_tree(old, new) -EINVAL
29043 - #define audit_tree_path(rule) "" /* never called */
29044 --#define audit_kill_trees(list) BUG()
29045 -+#define audit_kill_trees(context) BUG()
29046 - #endif
29047 -
29048 - extern char *audit_unpack_string(void **bufp, size_t *remain, size_t len);
29049 -diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
29050 -index d4af4d97f847..abfb112f26aa 100644
29051 ---- a/kernel/audit_tree.c
29052 -+++ b/kernel/audit_tree.c
29053 -@@ -524,13 +524,14 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
29054 - return 0;
29055 - }
29056 ++ host->cmd = NULL;
29057 ++
29058 ++ /*
29059 ++ * Sometimes command error interrupts and command complete
29060 ++ * interrupt will arrive together. Clear all command related
29061 ++ * interrupts here.
29062 ++ */
29063 ++ sdhci_writel(host, intmask & CMD_MASK, SDHCI_INT_STATUS);
29064 ++ intmask &= ~CMD_MASK;
29065 ++ }
29066 ++
29067 ++ return intmask;
29068 ++}
29069 ++
29070 + static struct sdhci_ops sdhci_omap_ops = {
29071 + .set_clock = sdhci_omap_set_clock,
29072 + .set_power = sdhci_omap_set_power,
29073 +@@ -807,6 +844,7 @@ static struct sdhci_ops sdhci_omap_ops = {
29074 + .platform_send_init_74_clocks = sdhci_omap_init_74_clocks,
29075 + .reset = sdhci_omap_reset,
29076 + .set_uhs_signaling = sdhci_omap_set_uhs_signaling,
29077 ++ .irq = sdhci_omap_irq,
29078 + };
29079
29080 --static void audit_tree_log_remove_rule(struct audit_krule *rule)
29081 -+static void audit_tree_log_remove_rule(struct audit_context *context,
29082 -+ struct audit_krule *rule)
29083 - {
29084 - struct audit_buffer *ab;
29085 + static int sdhci_omap_set_capabilities(struct sdhci_omap_host *omap_host)
29086 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
29087 +index 803f7990d32b..40ca339ec3df 100644
29088 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
29089 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
29090 +@@ -1129,6 +1129,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
29091 + tpa_info = &rxr->rx_tpa[agg_id];
29092
29093 - if (!audit_enabled)
29094 - return;
29095 -- ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
29096 -+ ab = audit_log_start(context, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
29097 - if (unlikely(!ab))
29098 + if (unlikely(cons != rxr->rx_next_cons)) {
29099 ++ netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n",
29100 ++ cons, rxr->rx_next_cons);
29101 + bnxt_sched_reset(bp, rxr);
29102 return;
29103 - audit_log_format(ab, "op=remove_rule dir=");
29104 -@@ -540,7 +541,7 @@ static void audit_tree_log_remove_rule(struct audit_krule *rule)
29105 - audit_log_end(ab);
29106 - }
29107 + }
29108 +@@ -1581,15 +1583,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
29109 + }
29110
29111 --static void kill_rules(struct audit_tree *tree)
29112 -+static void kill_rules(struct audit_context *context, struct audit_tree *tree)
29113 - {
29114 - struct audit_krule *rule, *next;
29115 - struct audit_entry *entry;
29116 -@@ -551,7 +552,7 @@ static void kill_rules(struct audit_tree *tree)
29117 - list_del_init(&rule->rlist);
29118 - if (rule->tree) {
29119 - /* not a half-baked one */
29120 -- audit_tree_log_remove_rule(rule);
29121 -+ audit_tree_log_remove_rule(context, rule);
29122 - if (entry->rule.exe)
29123 - audit_remove_mark(entry->rule.exe);
29124 - rule->tree = NULL;
29125 -@@ -633,7 +634,7 @@ static void trim_marked(struct audit_tree *tree)
29126 - tree->goner = 1;
29127 - spin_unlock(&hash_lock);
29128 - mutex_lock(&audit_filter_mutex);
29129 -- kill_rules(tree);
29130 -+ kill_rules(audit_context(), tree);
29131 - list_del_init(&tree->list);
29132 - mutex_unlock(&audit_filter_mutex);
29133 - prune_one(tree);
29134 -@@ -973,8 +974,10 @@ static void audit_schedule_prune(void)
29135 - * ... and that one is done if evict_chunk() decides to delay until the end
29136 - * of syscall. Runs synchronously.
29137 - */
29138 --void audit_kill_trees(struct list_head *list)
29139 -+void audit_kill_trees(struct audit_context *context)
29140 - {
29141 -+ struct list_head *list = &context->killed_trees;
29142 -+
29143 - audit_ctl_lock();
29144 - mutex_lock(&audit_filter_mutex);
29145 -
29146 -@@ -982,7 +985,7 @@ void audit_kill_trees(struct list_head *list)
29147 - struct audit_tree *victim;
29148 -
29149 - victim = list_entry(list->next, struct audit_tree, list);
29150 -- kill_rules(victim);
29151 -+ kill_rules(context, victim);
29152 - list_del_init(&victim->list);
29153 -
29154 - mutex_unlock(&audit_filter_mutex);
29155 -@@ -1017,7 +1020,7 @@ static void evict_chunk(struct audit_chunk *chunk)
29156 - list_del_init(&owner->same_root);
29157 - spin_unlock(&hash_lock);
29158 - if (!postponed) {
29159 -- kill_rules(owner);
29160 -+ kill_rules(audit_context(), owner);
29161 - list_move(&owner->list, &prune_list);
29162 - need_prune = 1;
29163 - } else {
29164 -diff --git a/kernel/auditsc.c b/kernel/auditsc.c
29165 -index 6593a5207fb0..b585ceb2f7a2 100644
29166 ---- a/kernel/auditsc.c
29167 -+++ b/kernel/auditsc.c
29168 -@@ -1444,6 +1444,9 @@ void __audit_free(struct task_struct *tsk)
29169 - if (!context)
29170 - return;
29171 + cons = rxcmp->rx_cmp_opaque;
29172 +- rx_buf = &rxr->rx_buf_ring[cons];
29173 +- data = rx_buf->data;
29174 +- data_ptr = rx_buf->data_ptr;
29175 + if (unlikely(cons != rxr->rx_next_cons)) {
29176 + int rc1 = bnxt_discard_rx(bp, cpr, raw_cons, rxcmp);
29177
29178 -+ if (!list_empty(&context->killed_trees))
29179 -+ audit_kill_trees(context);
29180 -+
29181 - /* We are called either by do_exit() or the fork() error handling code;
29182 - * in the former case tsk == current and in the latter tsk is a
29183 - * random task_struct that doesn't doesn't have any meaningful data we
29184 -@@ -1460,9 +1463,6 @@ void __audit_free(struct task_struct *tsk)
29185 - audit_log_exit();
29186 ++ netdev_warn(bp->dev, "RX cons %x != expected cons %x\n",
29187 ++ cons, rxr->rx_next_cons);
29188 + bnxt_sched_reset(bp, rxr);
29189 + return rc1;
29190 }
29191 ++ rx_buf = &rxr->rx_buf_ring[cons];
29192 ++ data = rx_buf->data;
29193 ++ data_ptr = rx_buf->data_ptr;
29194 + prefetch(data_ptr);
29195
29196 -- if (!list_empty(&context->killed_trees))
29197 -- audit_kill_trees(&context->killed_trees);
29198 --
29199 - audit_set_context(tsk, NULL);
29200 - audit_free_context(context);
29201 - }
29202 -@@ -1537,6 +1537,9 @@ void __audit_syscall_exit(int success, long return_code)
29203 - if (!context)
29204 - return;
29205 + misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1);
29206 +@@ -1606,11 +1610,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
29207
29208 -+ if (!list_empty(&context->killed_trees))
29209 -+ audit_kill_trees(context);
29210 + rx_buf->data = NULL;
29211 + if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) {
29212 ++ u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2);
29213 +
29214 - if (!context->dummy && context->in_syscall) {
29215 - if (success)
29216 - context->return_valid = AUDITSC_SUCCESS;
29217 -@@ -1571,9 +1574,6 @@ void __audit_syscall_exit(int success, long return_code)
29218 - context->in_syscall = 0;
29219 - context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
29220 -
29221 -- if (!list_empty(&context->killed_trees))
29222 -- audit_kill_trees(&context->killed_trees);
29223 --
29224 - audit_free_names(context);
29225 - unroll_tree_refs(context, NULL, 0);
29226 - audit_free_aux(context);
29227 -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
29228 -index 5fcce2f4209d..d53825b6fcd9 100644
29229 ---- a/kernel/bpf/verifier.c
29230 -+++ b/kernel/bpf/verifier.c
29231 -@@ -3187,7 +3187,7 @@ do_sim:
29232 - *dst_reg = *ptr_reg;
29233 - }
29234 - ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true);
29235 -- if (!ptr_is_dst_reg)
29236 -+ if (!ptr_is_dst_reg && ret)
29237 - *dst_reg = tmp;
29238 - return !ret ? -EFAULT : 0;
29239 - }
29240 -diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
29241 -index f31bd61c9466..f84bf28f36ba 100644
29242 ---- a/kernel/cgroup/cgroup.c
29243 -+++ b/kernel/cgroup/cgroup.c
29244 -@@ -197,7 +197,7 @@ static u64 css_serial_nr_next = 1;
29245 - */
29246 - static u16 have_fork_callback __read_mostly;
29247 - static u16 have_exit_callback __read_mostly;
29248 --static u16 have_free_callback __read_mostly;
29249 -+static u16 have_release_callback __read_mostly;
29250 - static u16 have_canfork_callback __read_mostly;
29251 -
29252 - /* cgroup namespace for init task */
29253 -@@ -2033,7 +2033,7 @@ struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
29254 - struct cgroup_namespace *ns)
29255 - {
29256 - struct dentry *dentry;
29257 -- bool new_sb;
29258 -+ bool new_sb = false;
29259 -
29260 - dentry = kernfs_mount(fs_type, flags, root->kf_root, magic, &new_sb);
29261 + bnxt_reuse_rx_data(rxr, cons, data);
29262 + if (agg_bufs)
29263 + bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs);
29264
29265 -@@ -2043,6 +2043,7 @@ struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
29266 - */
29267 - if (!IS_ERR(dentry) && ns != &init_cgroup_ns) {
29268 - struct dentry *nsdentry;
29269 -+ struct super_block *sb = dentry->d_sb;
29270 - struct cgroup *cgrp;
29271 -
29272 - mutex_lock(&cgroup_mutex);
29273 -@@ -2053,12 +2054,14 @@ struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
29274 - spin_unlock_irq(&css_set_lock);
29275 - mutex_unlock(&cgroup_mutex);
29276 -
29277 -- nsdentry = kernfs_node_dentry(cgrp->kn, dentry->d_sb);
29278 -+ nsdentry = kernfs_node_dentry(cgrp->kn, sb);
29279 - dput(dentry);
29280 -+ if (IS_ERR(nsdentry))
29281 -+ deactivate_locked_super(sb);
29282 - dentry = nsdentry;
29283 + rc = -EIO;
29284 ++ if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
29285 ++ netdev_warn(bp->dev, "RX buffer error %x\n", rx_err);
29286 ++ bnxt_sched_reset(bp, rxr);
29287 ++ }
29288 + goto next_rx;
29289 }
29290
29291 -- if (IS_ERR(dentry) || !new_sb)
29292 -+ if (!new_sb)
29293 - cgroup_put(&root->cgrp);
29294 +diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
29295 +index 503cfadff4ac..d4ee9f9c8c34 100644
29296 +--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
29297 ++++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
29298 +@@ -1328,10 +1328,11 @@ int nicvf_stop(struct net_device *netdev)
29299 + struct nicvf_cq_poll *cq_poll = NULL;
29300 + union nic_mbx mbx = {};
29301
29302 - return dentry;
29303 -@@ -5313,7 +5316,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
29304 +- cancel_delayed_work_sync(&nic->link_change_work);
29305 +-
29306 + /* wait till all queued set_rx_mode tasks completes */
29307 +- drain_workqueue(nic->nicvf_rx_mode_wq);
29308 ++ if (nic->nicvf_rx_mode_wq) {
29309 ++ cancel_delayed_work_sync(&nic->link_change_work);
29310 ++ drain_workqueue(nic->nicvf_rx_mode_wq);
29311 ++ }
29312
29313 - have_fork_callback |= (bool)ss->fork << ss->id;
29314 - have_exit_callback |= (bool)ss->exit << ss->id;
29315 -- have_free_callback |= (bool)ss->free << ss->id;
29316 -+ have_release_callback |= (bool)ss->release << ss->id;
29317 - have_canfork_callback |= (bool)ss->can_fork << ss->id;
29318 + mbx.msg.msg = NIC_MBOX_MSG_SHUTDOWN;
29319 + nicvf_send_msg_to_pf(nic, &mbx);
29320 +@@ -1452,7 +1453,8 @@ int nicvf_open(struct net_device *netdev)
29321 + struct nicvf_cq_poll *cq_poll = NULL;
29322
29323 - /* At system boot, before all subsystems have been
29324 -@@ -5749,16 +5752,19 @@ void cgroup_exit(struct task_struct *tsk)
29325 - } while_each_subsys_mask();
29326 - }
29327 + /* wait till all queued set_rx_mode tasks completes if any */
29328 +- drain_workqueue(nic->nicvf_rx_mode_wq);
29329 ++ if (nic->nicvf_rx_mode_wq)
29330 ++ drain_workqueue(nic->nicvf_rx_mode_wq);
29331
29332 --void cgroup_free(struct task_struct *task)
29333 -+void cgroup_release(struct task_struct *task)
29334 - {
29335 -- struct css_set *cset = task_css_set(task);
29336 - struct cgroup_subsys *ss;
29337 - int ssid;
29338 -
29339 -- do_each_subsys_mask(ss, ssid, have_free_callback) {
29340 -- ss->free(task);
29341 -+ do_each_subsys_mask(ss, ssid, have_release_callback) {
29342 -+ ss->release(task);
29343 - } while_each_subsys_mask();
29344 -+}
29345 + netif_carrier_off(netdev);
29346
29347 -+void cgroup_free(struct task_struct *task)
29348 -+{
29349 -+ struct css_set *cset = task_css_set(task);
29350 - put_css_set(cset);
29351 - }
29352 +@@ -1550,10 +1552,12 @@ int nicvf_open(struct net_device *netdev)
29353 + /* Send VF config done msg to PF */
29354 + nicvf_send_cfg_done(nic);
29355
29356 -diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c
29357 -index 9829c67ebc0a..c9960baaa14f 100644
29358 ---- a/kernel/cgroup/pids.c
29359 -+++ b/kernel/cgroup/pids.c
29360 -@@ -247,7 +247,7 @@ static void pids_cancel_fork(struct task_struct *task)
29361 - pids_uncharge(pids, 1);
29362 - }
29363 +- INIT_DELAYED_WORK(&nic->link_change_work,
29364 +- nicvf_link_status_check_task);
29365 +- queue_delayed_work(nic->nicvf_rx_mode_wq,
29366 +- &nic->link_change_work, 0);
29367 ++ if (nic->nicvf_rx_mode_wq) {
29368 ++ INIT_DELAYED_WORK(&nic->link_change_work,
29369 ++ nicvf_link_status_check_task);
29370 ++ queue_delayed_work(nic->nicvf_rx_mode_wq,
29371 ++ &nic->link_change_work, 0);
29372 ++ }
29373
29374 --static void pids_free(struct task_struct *task)
29375 -+static void pids_release(struct task_struct *task)
29376 - {
29377 - struct pids_cgroup *pids = css_pids(task_css(task, pids_cgrp_id));
29378 -
29379 -@@ -342,7 +342,7 @@ struct cgroup_subsys pids_cgrp_subsys = {
29380 - .cancel_attach = pids_cancel_attach,
29381 - .can_fork = pids_can_fork,
29382 - .cancel_fork = pids_cancel_fork,
29383 -- .free = pids_free,
29384 -+ .release = pids_release,
29385 - .legacy_cftypes = pids_files,
29386 - .dfl_cftypes = pids_files,
29387 - .threaded = true,
29388 -diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
29389 -index d503d1a9007c..bb95a35e8c2d 100644
29390 ---- a/kernel/cgroup/rstat.c
29391 -+++ b/kernel/cgroup/rstat.c
29392 -@@ -87,7 +87,6 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
29393 - struct cgroup *root, int cpu)
29394 - {
29395 - struct cgroup_rstat_cpu *rstatc;
29396 -- struct cgroup *parent;
29397 -
29398 - if (pos == root)
29399 - return NULL;
29400 -@@ -115,8 +114,8 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
29401 - * However, due to the way we traverse, @pos will be the first
29402 - * child in most cases. The only exception is @root.
29403 + return 0;
29404 + cleanup:
29405 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
29406 +index 5ecbb1adcf3b..51cfe95f3e24 100644
29407 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
29408 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
29409 +@@ -1885,6 +1885,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter,
29410 */
29411 -- parent = cgroup_parent(pos);
29412 -- if (parent && rstatc->updated_next) {
29413 -+ if (rstatc->updated_next) {
29414 -+ struct cgroup *parent = cgroup_parent(pos);
29415 - struct cgroup_rstat_cpu *prstatc = cgroup_rstat_cpu(parent, cpu);
29416 - struct cgroup_rstat_cpu *nrstatc;
29417 - struct cgroup **nextp;
29418 -@@ -140,9 +139,12 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
29419 - * updated stat.
29420 - */
29421 - smp_mb();
29422 -+
29423 -+ return pos;
29424 - }
29425 + adapter->state = VNIC_PROBED;
29426
29427 -- return pos;
29428 -+ /* only happens for @root */
29429 -+ return NULL;
29430 - }
29431 ++ reinit_completion(&adapter->init_done);
29432 + rc = init_crq_queue(adapter);
29433 + if (rc) {
29434 + netdev_err(adapter->netdev,
29435 +@@ -4625,7 +4626,7 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter)
29436 + old_num_rx_queues = adapter->req_rx_queues;
29437 + old_num_tx_queues = adapter->req_tx_queues;
29438
29439 - /* see cgroup_rstat_flush() */
29440 -diff --git a/kernel/cpu.c b/kernel/cpu.c
29441 -index d1c6d152da89..6754f3ecfd94 100644
29442 ---- a/kernel/cpu.c
29443 -+++ b/kernel/cpu.c
29444 -@@ -313,6 +313,15 @@ void cpus_write_unlock(void)
29445 +- init_completion(&adapter->init_done);
29446 ++ reinit_completion(&adapter->init_done);
29447 + adapter->init_done_rc = 0;
29448 + ibmvnic_send_crq_init(adapter);
29449 + if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
29450 +@@ -4680,7 +4681,6 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
29451
29452 - void lockdep_assert_cpus_held(void)
29453 - {
29454 -+ /*
29455 -+ * We can't have hotplug operations before userspace starts running,
29456 -+ * and some init codepaths will knowingly not take the hotplug lock.
29457 -+ * This is all valid, so mute lockdep until it makes sense to report
29458 -+ * unheld locks.
29459 -+ */
29460 -+ if (system_state < SYSTEM_RUNNING)
29461 -+ return;
29462 -+
29463 - percpu_rwsem_assert_held(&cpu_hotplug_lock);
29464 - }
29465 + adapter->from_passive_init = false;
29466
29467 -@@ -555,6 +564,20 @@ static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
29468 - cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);
29469 - }
29470 +- init_completion(&adapter->init_done);
29471 + adapter->init_done_rc = 0;
29472 + ibmvnic_send_crq_init(adapter);
29473 + if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
29474 +@@ -4759,6 +4759,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
29475 + INIT_WORK(&adapter->ibmvnic_reset, __ibmvnic_reset);
29476 + INIT_LIST_HEAD(&adapter->rwi_list);
29477 + spin_lock_init(&adapter->rwi_lock);
29478 ++ init_completion(&adapter->init_done);
29479 + adapter->resetting = false;
29480
29481 -+static inline bool can_rollback_cpu(struct cpuhp_cpu_state *st)
29482 -+{
29483 -+ if (IS_ENABLED(CONFIG_HOTPLUG_CPU))
29484 -+ return true;
29485 -+ /*
29486 -+ * When CPU hotplug is disabled, then taking the CPU down is not
29487 -+ * possible because takedown_cpu() and the architecture and
29488 -+ * subsystem specific mechanisms are not available. So the CPU
29489 -+ * which would be completely unplugged again needs to stay around
29490 -+ * in the current state.
29491 -+ */
29492 -+ return st->state <= CPUHP_BRINGUP_CPU;
29493 -+}
29494 -+
29495 - static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
29496 - enum cpuhp_state target)
29497 - {
29498 -@@ -565,8 +588,10 @@ static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
29499 - st->state++;
29500 - ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);
29501 - if (ret) {
29502 -- st->target = prev_state;
29503 -- undo_cpu_up(cpu, st);
29504 -+ if (can_rollback_cpu(st)) {
29505 -+ st->target = prev_state;
29506 -+ undo_cpu_up(cpu, st);
29507 -+ }
29508 - break;
29509 - }
29510 - }
29511 -diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
29512 -index 355d16acee6d..6310ad01f915 100644
29513 ---- a/kernel/dma/direct.c
29514 -+++ b/kernel/dma/direct.c
29515 -@@ -380,3 +380,14 @@ int dma_direct_supported(struct device *dev, u64 mask)
29516 - */
29517 - return mask >= __phys_to_dma(dev, min_mask);
29518 - }
29519 -+
29520 -+size_t dma_direct_max_mapping_size(struct device *dev)
29521 -+{
29522 -+ size_t size = SIZE_MAX;
29523 -+
29524 -+ /* If SWIOTLB is active, use its maximum mapping size */
29525 -+ if (is_swiotlb_active())
29526 -+ size = swiotlb_max_mapping_size(dev);
29527 -+
29528 -+ return size;
29529 -+}
29530 -diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
29531 -index a11006b6d8e8..5753008ab286 100644
29532 ---- a/kernel/dma/mapping.c
29533 -+++ b/kernel/dma/mapping.c
29534 -@@ -357,3 +357,17 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
29535 - ops->cache_sync(dev, vaddr, size, dir);
29536 + adapter->mac_change_pending = false;
29537 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
29538 +index eac245a93f91..4ab0d030b544 100644
29539 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
29540 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
29541 +@@ -122,7 +122,9 @@ out:
29542 + return err;
29543 }
29544 - EXPORT_SYMBOL(dma_cache_sync);
29545 -+
29546 -+size_t dma_max_mapping_size(struct device *dev)
29547 -+{
29548 -+ const struct dma_map_ops *ops = get_dma_ops(dev);
29549 -+ size_t size = SIZE_MAX;
29550 -+
29551 -+ if (dma_is_direct(ops))
29552 -+ size = dma_direct_max_mapping_size(dev);
29553 -+ else if (ops && ops->max_mapping_size)
29554 -+ size = ops->max_mapping_size(dev);
29555 -+
29556 -+ return size;
29557 -+}
29558 -+EXPORT_SYMBOL_GPL(dma_max_mapping_size);
29559 -diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
29560 -index 1fb6fd68b9c7..c873f9cc2146 100644
29561 ---- a/kernel/dma/swiotlb.c
29562 -+++ b/kernel/dma/swiotlb.c
29563 -@@ -662,3 +662,17 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask)
29564 +
29565 +-/* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B]) */
29566 ++/* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B])
29567 ++ * minimum speed value is 40Gbps
29568 ++ */
29569 + static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
29570 {
29571 - return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
29572 - }
29573 -+
29574 -+size_t swiotlb_max_mapping_size(struct device *dev)
29575 -+{
29576 -+ return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
29577 -+}
29578 -+
29579 -+bool is_swiotlb_active(void)
29580 -+{
29581 -+ /*
29582 -+ * When SWIOTLB is initialized, even if io_tlb_start points to physical
29583 -+ * address zero, io_tlb_end surely doesn't.
29584 -+ */
29585 -+ return io_tlb_end != 0;
29586 -+}
29587 -diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
29588 -index 5ab4fe3b1dcc..878c62ec0190 100644
29589 ---- a/kernel/events/ring_buffer.c
29590 -+++ b/kernel/events/ring_buffer.c
29591 -@@ -658,7 +658,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
29592 - goto out;
29593 - }
29594 + u32 speed;
29595 +@@ -130,10 +132,9 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
29596 + int err;
29597
29598 -- rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages,
29599 -+ rb->aux_priv = event->pmu->setup_aux(event, rb->aux_pages, nr_pages,
29600 - overwrite);
29601 - if (!rb->aux_priv)
29602 - goto out;
29603 -diff --git a/kernel/exit.c b/kernel/exit.c
29604 -index 2639a30a8aa5..2166c2d92ddc 100644
29605 ---- a/kernel/exit.c
29606 -+++ b/kernel/exit.c
29607 -@@ -219,6 +219,7 @@ repeat:
29608 - }
29609 + err = mlx5e_port_linkspeed(priv->mdev, &speed);
29610 +- if (err) {
29611 +- mlx5_core_warn(priv->mdev, "cannot get port speed\n");
29612 +- return 0;
29613 +- }
29614 ++ if (err)
29615 ++ speed = SPEED_40000;
29616 ++ speed = max_t(u32, speed, SPEED_40000);
29617
29618 - write_unlock_irq(&tasklist_lock);
29619 -+ cgroup_release(p);
29620 - release_thread(p);
29621 - call_rcu(&p->rcu, delayed_put_task_struct);
29622 + xoff = (301 + 216 * priv->dcbx.cable_len / 100) * speed / 1000 + 272 * mtu / 100;
29623
29624 -diff --git a/kernel/futex.c b/kernel/futex.c
29625 -index a0514e01c3eb..52668d44e07b 100644
29626 ---- a/kernel/futex.c
29627 -+++ b/kernel/futex.c
29628 -@@ -3440,6 +3440,10 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int p
29629 - {
29630 - u32 uval, uninitialized_var(nval), mval;
29631 +@@ -142,7 +143,7 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
29632 + }
29633
29634 -+ /* Futex address must be 32bit aligned */
29635 -+ if ((((unsigned long)uaddr) % sizeof(*uaddr)) != 0)
29636 -+ return -1;
29637 -+
29638 - retry:
29639 - if (get_user(uval, uaddr))
29640 - return -1;
29641 -diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
29642 -index 34e969069488..b07a2acc4eec 100644
29643 ---- a/kernel/irq/chip.c
29644 -+++ b/kernel/irq/chip.c
29645 -@@ -855,7 +855,11 @@ void handle_percpu_irq(struct irq_desc *desc)
29646 + static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
29647 +- u32 xoff, unsigned int mtu)
29648 ++ u32 xoff, unsigned int max_mtu)
29649 {
29650 - struct irq_chip *chip = irq_desc_get_chip(desc);
29651 + int i;
29652
29653 -- kstat_incr_irqs_this_cpu(desc);
29654 -+ /*
29655 -+ * PER CPU interrupts are not serialized. Do not touch
29656 -+ * desc->tot_count.
29657 -+ */
29658 -+ __kstat_incr_irqs_this_cpu(desc);
29659 +@@ -154,11 +155,12 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
29660 + }
29661
29662 - if (chip->irq_ack)
29663 - chip->irq_ack(&desc->irq_data);
29664 -@@ -884,7 +888,11 @@ void handle_percpu_devid_irq(struct irq_desc *desc)
29665 - unsigned int irq = irq_desc_get_irq(desc);
29666 - irqreturn_t res;
29667 + if (port_buffer->buffer[i].size <
29668 +- (xoff + mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
29669 ++ (xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
29670 + return -ENOMEM;
29671
29672 -- kstat_incr_irqs_this_cpu(desc);
29673 -+ /*
29674 -+ * PER CPU interrupts are not serialized. Do not touch
29675 -+ * desc->tot_count.
29676 -+ */
29677 -+ __kstat_incr_irqs_this_cpu(desc);
29678 + port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff;
29679 +- port_buffer->buffer[i].xon = port_buffer->buffer[i].xoff - mtu;
29680 ++ port_buffer->buffer[i].xon =
29681 ++ port_buffer->buffer[i].xoff - max_mtu;
29682 + }
29683
29684 - if (chip->irq_ack)
29685 - chip->irq_ack(&desc->irq_data);
29686 -@@ -1376,6 +1384,10 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info)
29687 - int irq_chip_set_wake_parent(struct irq_data *data, unsigned int on)
29688 - {
29689 - data = data->parent_data;
29690 -+
29691 -+ if (data->chip->flags & IRQCHIP_SKIP_SET_WAKE)
29692 -+ return 0;
29693 -+
29694 - if (data->chip->irq_set_wake)
29695 - return data->chip->irq_set_wake(data, on);
29696 + return 0;
29697 +@@ -166,7 +168,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
29698
29699 -diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
29700 -index ca6afa267070..e74e7eea76cf 100644
29701 ---- a/kernel/irq/internals.h
29702 -+++ b/kernel/irq/internals.h
29703 -@@ -242,12 +242,18 @@ static inline void irq_state_set_masked(struct irq_desc *desc)
29704 + /**
29705 + * update_buffer_lossy()
29706 +- * mtu: device's MTU
29707 ++ * max_mtu: netdev's max_mtu
29708 + * pfc_en: <input> current pfc configuration
29709 + * buffer: <input> current prio to buffer mapping
29710 + * xoff: <input> xoff value
29711 +@@ -183,7 +185,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
29712 + * Return 0 if no error.
29713 + * Set change to true if buffer configuration is modified.
29714 + */
29715 +-static int update_buffer_lossy(unsigned int mtu,
29716 ++static int update_buffer_lossy(unsigned int max_mtu,
29717 + u8 pfc_en, u8 *buffer, u32 xoff,
29718 + struct mlx5e_port_buffer *port_buffer,
29719 + bool *change)
29720 +@@ -220,7 +222,7 @@ static int update_buffer_lossy(unsigned int mtu,
29721 + }
29722
29723 - #undef __irqd_to_state
29724 + if (changed) {
29725 +- err = update_xoff_threshold(port_buffer, xoff, mtu);
29726 ++ err = update_xoff_threshold(port_buffer, xoff, max_mtu);
29727 + if (err)
29728 + return err;
29729
29730 --static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc)
29731 -+static inline void __kstat_incr_irqs_this_cpu(struct irq_desc *desc)
29732 - {
29733 - __this_cpu_inc(*desc->kstat_irqs);
29734 - __this_cpu_inc(kstat.irqs_sum);
29735 +@@ -230,6 +232,7 @@ static int update_buffer_lossy(unsigned int mtu,
29736 + return 0;
29737 }
29738
29739 -+static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc)
29740 -+{
29741 -+ __kstat_incr_irqs_this_cpu(desc);
29742 -+ desc->tot_count++;
29743 -+}
29744 -+
29745 - static inline int irq_desc_get_node(struct irq_desc *desc)
29746 - {
29747 - return irq_common_data_get_node(&desc->irq_common_data);
29748 -diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
29749 -index ef8ad36cadcf..e16e022eae09 100644
29750 ---- a/kernel/irq/irqdesc.c
29751 -+++ b/kernel/irq/irqdesc.c
29752 -@@ -119,6 +119,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
29753 - desc->depth = 1;
29754 - desc->irq_count = 0;
29755 - desc->irqs_unhandled = 0;
29756 -+ desc->tot_count = 0;
29757 - desc->name = NULL;
29758 - desc->owner = owner;
29759 - for_each_possible_cpu(cpu)
29760 -@@ -557,6 +558,7 @@ int __init early_irq_init(void)
29761 - alloc_masks(&desc[i], node);
29762 - raw_spin_lock_init(&desc[i].lock);
29763 - lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
29764 -+ mutex_init(&desc[i].request_mutex);
29765 - desc_set_defaults(i, &desc[i], node, NULL, NULL);
29766 - }
29767 - return arch_early_irq_init();
29768 -@@ -919,11 +921,15 @@ unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
29769 - unsigned int kstat_irqs(unsigned int irq)
29770 - {
29771 - struct irq_desc *desc = irq_to_desc(irq);
29772 -- int cpu;
29773 - unsigned int sum = 0;
29774 -+ int cpu;
29775 -
29776 - if (!desc || !desc->kstat_irqs)
29777 - return 0;
29778 -+ if (!irq_settings_is_per_cpu_devid(desc) &&
29779 -+ !irq_settings_is_per_cpu(desc))
29780 -+ return desc->tot_count;
29781 -+
29782 - for_each_possible_cpu(cpu)
29783 - sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
29784 - return sum;
29785 -diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
29786 -index 95932333a48b..e805fe3bf87f 100644
29787 ---- a/kernel/locking/lockdep.c
29788 -+++ b/kernel/locking/lockdep.c
29789 -@@ -3535,6 +3535,9 @@ static int __lock_downgrade(struct lockdep_map *lock, unsigned long ip)
29790 - unsigned int depth;
29791 ++#define MINIMUM_MAX_MTU 9216
29792 + int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29793 + u32 change, unsigned int mtu,
29794 + struct ieee_pfc *pfc,
29795 +@@ -241,12 +244,14 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29796 + bool update_prio2buffer = false;
29797 + u8 buffer[MLX5E_MAX_PRIORITY];
29798 + bool update_buffer = false;
29799 ++ unsigned int max_mtu;
29800 + u32 total_used = 0;
29801 + u8 curr_pfc_en;
29802 + int err;
29803 int i;
29804
29805 -+ if (unlikely(!debug_locks))
29806 -+ return 0;
29807 -+
29808 - depth = curr->lockdep_depth;
29809 - /*
29810 - * This function is about (re)setting the class of a held lock,
29811 -diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
29812 -index 9180158756d2..38d44d27e37a 100644
29813 ---- a/kernel/rcu/tree.c
29814 -+++ b/kernel/rcu/tree.c
29815 -@@ -1557,14 +1557,23 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)
29816 - }
29817 + mlx5e_dbg(HW, priv, "%s: change=%x\n", __func__, change);
29818 ++ max_mtu = max_t(unsigned int, priv->netdev->max_mtu, MINIMUM_MAX_MTU);
29819
29820 - /*
29821 -- * Awaken the grace-period kthread. Don't do a self-awaken, and don't
29822 -- * bother awakening when there is nothing for the grace-period kthread
29823 -- * to do (as in several CPUs raced to awaken, and we lost), and finally
29824 -- * don't try to awaken a kthread that has not yet been created.
29825 -+ * Awaken the grace-period kthread. Don't do a self-awaken (unless in
29826 -+ * an interrupt or softirq handler), and don't bother awakening when there
29827 -+ * is nothing for the grace-period kthread to do (as in several CPUs raced
29828 -+ * to awaken, and we lost), and finally don't try to awaken a kthread that
29829 -+ * has not yet been created. If all those checks are passed, track some
29830 -+ * debug information and awaken.
29831 -+ *
29832 -+ * So why do the self-wakeup when in an interrupt or softirq handler
29833 -+ * in the grace-period kthread's context? Because the kthread might have
29834 -+ * been interrupted just as it was going to sleep, and just after the final
29835 -+ * pre-sleep check of the awaken condition. In this case, a wakeup really
29836 -+ * is required, and is therefore supplied.
29837 - */
29838 - static void rcu_gp_kthread_wake(void)
29839 - {
29840 -- if (current == rcu_state.gp_kthread ||
29841 -+ if ((current == rcu_state.gp_kthread &&
29842 -+ !in_interrupt() && !in_serving_softirq()) ||
29843 - !READ_ONCE(rcu_state.gp_flags) ||
29844 - !rcu_state.gp_kthread)
29845 - return;
29846 -diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
29847 -index 1971869c4072..f4ca36d92138 100644
29848 ---- a/kernel/rcu/update.c
29849 -+++ b/kernel/rcu/update.c
29850 -@@ -52,6 +52,7 @@
29851 - #include <linux/tick.h>
29852 - #include <linux/rcupdate_wait.h>
29853 - #include <linux/sched/isolation.h>
29854 -+#include <linux/kprobes.h>
29855 -
29856 - #define CREATE_TRACE_POINTS
29857 -
29858 -@@ -249,6 +250,7 @@ int notrace debug_lockdep_rcu_enabled(void)
29859 - current->lockdep_recursion == 0;
29860 - }
29861 - EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
29862 -+NOKPROBE_SYMBOL(debug_lockdep_rcu_enabled);
29863 + err = mlx5e_port_query_buffer(priv, &port_buffer);
29864 + if (err)
29865 +@@ -254,7 +259,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29866
29867 - /**
29868 - * rcu_read_lock_held() - might we be in RCU read-side critical section?
29869 -diff --git a/kernel/resource.c b/kernel/resource.c
29870 -index 915c02e8e5dd..ca7ed5158cff 100644
29871 ---- a/kernel/resource.c
29872 -+++ b/kernel/resource.c
29873 -@@ -382,7 +382,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
29874 - int (*func)(struct resource *, void *))
29875 - {
29876 - struct resource res;
29877 -- int ret = -1;
29878 -+ int ret = -EINVAL;
29879 -
29880 - while (start < end &&
29881 - !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
29882 -@@ -462,7 +462,7 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
29883 - unsigned long flags;
29884 - struct resource res;
29885 - unsigned long pfn, end_pfn;
29886 -- int ret = -1;
29887 -+ int ret = -EINVAL;
29888 -
29889 - start = (u64) start_pfn << PAGE_SHIFT;
29890 - end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
29891 -diff --git a/kernel/sched/core.c b/kernel/sched/core.c
29892 -index d8d76a65cfdd..01a2489de94e 100644
29893 ---- a/kernel/sched/core.c
29894 -+++ b/kernel/sched/core.c
29895 -@@ -107,11 +107,12 @@ struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
29896 - * [L] ->on_rq
29897 - * RELEASE (rq->lock)
29898 - *
29899 -- * If we observe the old CPU in task_rq_lock, the acquire of
29900 -+ * If we observe the old CPU in task_rq_lock(), the acquire of
29901 - * the old rq->lock will fully serialize against the stores.
29902 - *
29903 -- * If we observe the new CPU in task_rq_lock, the acquire will
29904 -- * pair with the WMB to ensure we must then also see migrating.
29905 -+ * If we observe the new CPU in task_rq_lock(), the address
29906 -+ * dependency headed by '[L] rq = task_rq()' and the acquire
29907 -+ * will pair with the WMB to ensure we then also see migrating.
29908 - */
29909 - if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) {
29910 - rq_pin_lock(rq, rf);
29911 -@@ -928,7 +929,7 @@ static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf,
29912 - {
29913 - lockdep_assert_held(&rq->lock);
29914 -
29915 -- p->on_rq = TASK_ON_RQ_MIGRATING;
29916 -+ WRITE_ONCE(p->on_rq, TASK_ON_RQ_MIGRATING);
29917 - dequeue_task(rq, p, DEQUEUE_NOCLOCK);
29918 - set_task_cpu(p, new_cpu);
29919 - rq_unlock(rq, rf);
29920 -diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
29921 -index de3de997e245..8039d62ae36e 100644
29922 ---- a/kernel/sched/debug.c
29923 -+++ b/kernel/sched/debug.c
29924 -@@ -315,6 +315,7 @@ void register_sched_domain_sysctl(void)
29925 - {
29926 - static struct ctl_table *cpu_entries;
29927 - static struct ctl_table **cpu_idx;
29928 -+ static bool init_done = false;
29929 - char buf[32];
29930 - int i;
29931 + if (change & MLX5E_PORT_BUFFER_CABLE_LEN) {
29932 + update_buffer = true;
29933 +- err = update_xoff_threshold(&port_buffer, xoff, mtu);
29934 ++ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
29935 + if (err)
29936 + return err;
29937 + }
29938 +@@ -264,7 +269,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29939 + if (err)
29940 + return err;
29941
29942 -@@ -344,7 +345,10 @@ void register_sched_domain_sysctl(void)
29943 - if (!cpumask_available(sd_sysctl_cpus)) {
29944 - if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
29945 - return;
29946 -+ }
29947 +- err = update_buffer_lossy(mtu, pfc->pfc_en, buffer, xoff,
29948 ++ err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff,
29949 + &port_buffer, &update_buffer);
29950 + if (err)
29951 + return err;
29952 +@@ -276,8 +281,8 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29953 + if (err)
29954 + return err;
29955
29956 -+ if (!init_done) {
29957 -+ init_done = true;
29958 - /* init to possible to not have holes in @cpu_entries */
29959 - cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
29960 +- err = update_buffer_lossy(mtu, curr_pfc_en, prio2buffer, xoff,
29961 +- &port_buffer, &update_buffer);
29962 ++ err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer,
29963 ++ xoff, &port_buffer, &update_buffer);
29964 + if (err)
29965 + return err;
29966 }
29967 -diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
29968 -index 310d0637fe4b..5e61a1a99e38 100644
29969 ---- a/kernel/sched/fair.c
29970 -+++ b/kernel/sched/fair.c
29971 -@@ -7713,10 +7713,10 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq)
29972 - if (cfs_rq->last_h_load_update == now)
29973 - return;
29974 +@@ -301,7 +306,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29975 + return -EINVAL;
29976
29977 -- cfs_rq->h_load_next = NULL;
29978 -+ WRITE_ONCE(cfs_rq->h_load_next, NULL);
29979 - for_each_sched_entity(se) {
29980 - cfs_rq = cfs_rq_of(se);
29981 -- cfs_rq->h_load_next = se;
29982 -+ WRITE_ONCE(cfs_rq->h_load_next, se);
29983 - if (cfs_rq->last_h_load_update == now)
29984 - break;
29985 + update_buffer = true;
29986 +- err = update_xoff_threshold(&port_buffer, xoff, mtu);
29987 ++ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
29988 + if (err)
29989 + return err;
29990 }
29991 -@@ -7726,7 +7726,7 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq)
29992 - cfs_rq->last_h_load_update = now;
29993 +@@ -309,7 +314,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
29994 + /* Need to update buffer configuration if xoff value is changed */
29995 + if (!update_buffer && xoff != priv->dcbx.xoff) {
29996 + update_buffer = true;
29997 +- err = update_xoff_threshold(&port_buffer, xoff, mtu);
29998 ++ err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
29999 + if (err)
30000 + return err;
30001 }
30002 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
30003 +index 3078491cc0d0..1539cf3de5dc 100644
30004 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
30005 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
30006 +@@ -45,7 +45,9 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
30007 + if (err)
30008 + return err;
30009
30010 -- while ((se = cfs_rq->h_load_next) != NULL) {
30011 -+ while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) {
30012 - load = cfs_rq->h_load;
30013 - load = div64_ul(load * se->avg.load_avg,
30014 - cfs_rq_load_avg(cfs_rq) + 1);
30015 -diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
30016 -index d04530bf251f..425a5589e5f6 100644
30017 ---- a/kernel/sched/sched.h
30018 -+++ b/kernel/sched/sched.h
30019 -@@ -1460,9 +1460,9 @@ static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
30020 - */
30021 - smp_wmb();
30022 - #ifdef CONFIG_THREAD_INFO_IN_TASK
30023 -- p->cpu = cpu;
30024 -+ WRITE_ONCE(p->cpu, cpu);
30025 - #else
30026 -- task_thread_info(p)->cpu = cpu;
30027 -+ WRITE_ONCE(task_thread_info(p)->cpu, cpu);
30028 - #endif
30029 - p->wake_cpu = cpu;
30030 - #endif
30031 -@@ -1563,7 +1563,7 @@ static inline int task_on_rq_queued(struct task_struct *p)
30032 ++ mutex_lock(&mdev->mlx5e_res.td.list_lock);
30033 + list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list);
30034 ++ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
30035
30036 - static inline int task_on_rq_migrating(struct task_struct *p)
30037 - {
30038 -- return p->on_rq == TASK_ON_RQ_MIGRATING;
30039 -+ return READ_ONCE(p->on_rq) == TASK_ON_RQ_MIGRATING;
30040 + return 0;
30041 }
30042 -
30043 - /*
30044 -diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
30045 -index 3f35ba1d8fde..efca2489d881 100644
30046 ---- a/kernel/sched/topology.c
30047 -+++ b/kernel/sched/topology.c
30048 -@@ -676,7 +676,7 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
30049 +@@ -53,8 +55,10 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
30050 + void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
30051 + struct mlx5e_tir *tir)
30052 + {
30053 ++ mutex_lock(&mdev->mlx5e_res.td.list_lock);
30054 + mlx5_core_destroy_tir(mdev, tir->tirn);
30055 + list_del(&tir->list);
30056 ++ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
30057 }
30058
30059 - struct s_data {
30060 -- struct sched_domain ** __percpu sd;
30061 -+ struct sched_domain * __percpu *sd;
30062 - struct root_domain *rd;
30063 - };
30064 + static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
30065 +@@ -114,6 +118,7 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev)
30066 + }
30067
30068 -diff --git a/kernel/sysctl.c b/kernel/sysctl.c
30069 -index ba4d9e85feb8..28ec71d914c7 100644
30070 ---- a/kernel/sysctl.c
30071 -+++ b/kernel/sysctl.c
30072 -@@ -127,6 +127,7 @@ static int __maybe_unused one = 1;
30073 - static int __maybe_unused two = 2;
30074 - static int __maybe_unused four = 4;
30075 - static unsigned long one_ul = 1;
30076 -+static unsigned long long_max = LONG_MAX;
30077 - static int one_hundred = 100;
30078 - static int one_thousand = 1000;
30079 - #ifdef CONFIG_PRINTK
30080 -@@ -1722,6 +1723,8 @@ static struct ctl_table fs_table[] = {
30081 - .maxlen = sizeof(files_stat.max_files),
30082 - .mode = 0644,
30083 - .proc_handler = proc_doulongvec_minmax,
30084 -+ .extra1 = &zero,
30085 -+ .extra2 = &long_max,
30086 - },
30087 - {
30088 - .procname = "nr_open",
30089 -@@ -2579,7 +2582,16 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
30090 - {
30091 - struct do_proc_dointvec_minmax_conv_param *param = data;
30092 - if (write) {
30093 -- int val = *negp ? -*lvalp : *lvalp;
30094 -+ int val;
30095 -+ if (*negp) {
30096 -+ if (*lvalp > (unsigned long) INT_MAX + 1)
30097 -+ return -EINVAL;
30098 -+ val = -*lvalp;
30099 -+ } else {
30100 -+ if (*lvalp > (unsigned long) INT_MAX)
30101 -+ return -EINVAL;
30102 -+ val = *lvalp;
30103 -+ }
30104 - if ((param->min && *param->min > val) ||
30105 - (param->max && *param->max < val))
30106 - return -EINVAL;
30107 -diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
30108 -index 2c97e8c2d29f..0519a8805aab 100644
30109 ---- a/kernel/time/alarmtimer.c
30110 -+++ b/kernel/time/alarmtimer.c
30111 -@@ -594,7 +594,7 @@ static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now)
30112 - {
30113 - struct alarm *alarm = &timr->it.alarm.alarmtimer;
30114 + INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list);
30115 ++ mutex_init(&mdev->mlx5e_res.td.list_lock);
30116
30117 -- return ktime_sub(now, alarm->node.expires);
30118 -+ return ktime_sub(alarm->node.expires, now);
30119 - }
30120 + return 0;
30121
30122 - /**
30123 -diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
30124 -index 06e864a334bb..b49affb4666b 100644
30125 ---- a/kernel/trace/ring_buffer.c
30126 -+++ b/kernel/trace/ring_buffer.c
30127 -@@ -4205,6 +4205,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
30128 - * ring_buffer_read_prepare - Prepare for a non consuming read of the buffer
30129 - * @buffer: The ring buffer to read from
30130 - * @cpu: The cpu buffer to iterate over
30131 -+ * @flags: gfp flags to use for memory allocation
30132 - *
30133 - * This performs the initial preparations necessary to iterate
30134 - * through the buffer. Memory is allocated, buffer recording
30135 -@@ -4222,7 +4223,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
30136 - * This overall must be paired with ring_buffer_read_finish.
30137 - */
30138 - struct ring_buffer_iter *
30139 --ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
30140 -+ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu, gfp_t flags)
30141 +@@ -141,15 +146,17 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
30142 {
30143 - struct ring_buffer_per_cpu *cpu_buffer;
30144 - struct ring_buffer_iter *iter;
30145 -@@ -4230,7 +4231,7 @@ ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
30146 - if (!cpumask_test_cpu(cpu, buffer->cpumask))
30147 - return NULL;
30148 -
30149 -- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
30150 -+ iter = kmalloc(sizeof(*iter), flags);
30151 - if (!iter)
30152 - return NULL;
30153 -
30154 -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
30155 -index c4238b441624..89158aa93fa6 100644
30156 ---- a/kernel/trace/trace.c
30157 -+++ b/kernel/trace/trace.c
30158 -@@ -3904,7 +3904,8 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
30159 - if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
30160 - for_each_tracing_cpu(cpu) {
30161 - iter->buffer_iter[cpu] =
30162 -- ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu);
30163 -+ ring_buffer_read_prepare(iter->trace_buffer->buffer,
30164 -+ cpu, GFP_KERNEL);
30165 - }
30166 - ring_buffer_read_prepare_sync();
30167 - for_each_tracing_cpu(cpu) {
30168 -@@ -3914,7 +3915,8 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
30169 - } else {
30170 - cpu = iter->cpu_file;
30171 - iter->buffer_iter[cpu] =
30172 -- ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu);
30173 -+ ring_buffer_read_prepare(iter->trace_buffer->buffer,
30174 -+ cpu, GFP_KERNEL);
30175 - ring_buffer_read_prepare_sync();
30176 - ring_buffer_read_start(iter->buffer_iter[cpu]);
30177 - tracing_iter_reset(iter, cpu);
30178 -@@ -5626,7 +5628,6 @@ out:
30179 - return ret;
30180 + struct mlx5_core_dev *mdev = priv->mdev;
30181 + struct mlx5e_tir *tir;
30182 +- int err = -ENOMEM;
30183 ++ int err = 0;
30184 + u32 tirn = 0;
30185 + int inlen;
30186 + void *in;
30187
30188 - fail:
30189 -- kfree(iter->trace);
30190 - kfree(iter);
30191 - __trace_array_put(tr);
30192 - mutex_unlock(&trace_types_lock);
30193 -diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c
30194 -index dd1f43588d70..fa100ed3b4de 100644
30195 ---- a/kernel/trace/trace_dynevent.c
30196 -+++ b/kernel/trace/trace_dynevent.c
30197 -@@ -74,7 +74,7 @@ int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type)
30198 - static int create_dyn_event(int argc, char **argv)
30199 - {
30200 - struct dyn_event_operations *ops;
30201 -- int ret;
30202 -+ int ret = -ENODEV;
30203 -
30204 - if (argv[0][0] == '-' || argv[0][0] == '!')
30205 - return dyn_event_release(argc, argv, NULL);
30206 -diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
30207 -index 76217bbef815..4629a6104474 100644
30208 ---- a/kernel/trace/trace_event_perf.c
30209 -+++ b/kernel/trace/trace_event_perf.c
30210 -@@ -299,15 +299,13 @@ int perf_uprobe_init(struct perf_event *p_event,
30211 -
30212 - if (!p_event->attr.uprobe_path)
30213 - return -EINVAL;
30214 -- path = kzalloc(PATH_MAX, GFP_KERNEL);
30215 -- if (!path)
30216 -- return -ENOMEM;
30217 -- ret = strncpy_from_user(
30218 -- path, u64_to_user_ptr(p_event->attr.uprobe_path), PATH_MAX);
30219 -- if (ret == PATH_MAX)
30220 -- return -E2BIG;
30221 -- if (ret < 0)
30222 -- goto out;
30223 -+
30224 -+ path = strndup_user(u64_to_user_ptr(p_event->attr.uprobe_path),
30225 -+ PATH_MAX);
30226 -+ if (IS_ERR(path)) {
30227 -+ ret = PTR_ERR(path);
30228 -+ return (ret == -EINVAL) ? -E2BIG : ret;
30229 -+ }
30230 - if (path[0] == '\0') {
30231 - ret = -EINVAL;
30232 + inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
30233 + in = kvzalloc(inlen, GFP_KERNEL);
30234 +- if (!in)
30235 ++ if (!in) {
30236 ++ err = -ENOMEM;
30237 goto out;
30238 -diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
30239 -index 27821480105e..217ef481fbbb 100644
30240 ---- a/kernel/trace/trace_events_filter.c
30241 -+++ b/kernel/trace/trace_events_filter.c
30242 -@@ -1301,7 +1301,7 @@ static int parse_pred(const char *str, void *data,
30243 - /* go past the last quote */
30244 - i++;
30245 -
30246 -- } else if (isdigit(str[i])) {
30247 -+ } else if (isdigit(str[i]) || str[i] == '-') {
30248 -
30249 - /* Make sure the field is not a string */
30250 - if (is_string_field(field)) {
30251 -@@ -1314,6 +1314,9 @@ static int parse_pred(const char *str, void *data,
30252 - goto err_free;
30253 - }
30254 ++ }
30255
30256 -+ if (str[i] == '-')
30257 -+ i++;
30258 -+
30259 - /* We allow 0xDEADBEEF */
30260 - while (isalnum(str[i]))
30261 - i++;
30262 -diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
30263 -index 449d90cfa151..55b72b1c63a0 100644
30264 ---- a/kernel/trace/trace_events_hist.c
30265 -+++ b/kernel/trace/trace_events_hist.c
30266 -@@ -4695,9 +4695,10 @@ static inline void add_to_key(char *compound_key, void *key,
30267 - /* ensure NULL-termination */
30268 - if (size > key_field->size - 1)
30269 - size = key_field->size - 1;
30270 -- }
30271 + if (enable_uc_lb)
30272 + MLX5_SET(modify_tir_in, in, ctx.self_lb_block,
30273 +@@ -157,6 +164,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
30274
30275 -- memcpy(compound_key + key_field->offset, key, size);
30276 -+ strncpy(compound_key + key_field->offset, (char *)key, size);
30277 -+ } else
30278 -+ memcpy(compound_key + key_field->offset, key, size);
30279 - }
30280 + MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
30281
30282 - static void
30283 -diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c
30284 -index d953c163a079..810d78a8d14c 100644
30285 ---- a/kernel/trace/trace_kdb.c
30286 -+++ b/kernel/trace/trace_kdb.c
30287 -@@ -51,14 +51,16 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)
30288 - if (cpu_file == RING_BUFFER_ALL_CPUS) {
30289 - for_each_tracing_cpu(cpu) {
30290 - iter.buffer_iter[cpu] =
30291 -- ring_buffer_read_prepare(iter.trace_buffer->buffer, cpu);
30292 -+ ring_buffer_read_prepare(iter.trace_buffer->buffer,
30293 -+ cpu, GFP_ATOMIC);
30294 - ring_buffer_read_start(iter.buffer_iter[cpu]);
30295 - tracing_iter_reset(&iter, cpu);
30296 - }
30297 - } else {
30298 - iter.cpu_file = cpu_file;
30299 - iter.buffer_iter[cpu_file] =
30300 -- ring_buffer_read_prepare(iter.trace_buffer->buffer, cpu_file);
30301 -+ ring_buffer_read_prepare(iter.trace_buffer->buffer,
30302 -+ cpu_file, GFP_ATOMIC);
30303 - ring_buffer_read_start(iter.buffer_iter[cpu_file]);
30304 - tracing_iter_reset(&iter, cpu_file);
30305 - }
30306 -diff --git a/kernel/watchdog.c b/kernel/watchdog.c
30307 -index 977918d5d350..bbc4940f21af 100644
30308 ---- a/kernel/watchdog.c
30309 -+++ b/kernel/watchdog.c
30310 -@@ -547,13 +547,15 @@ static void softlockup_start_all(void)
30311 ++ mutex_lock(&mdev->mlx5e_res.td.list_lock);
30312 + list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
30313 + tirn = tir->tirn;
30314 + err = mlx5_core_modify_tir(mdev, tirn, in, inlen);
30315 +@@ -168,6 +176,7 @@ out:
30316 + kvfree(in);
30317 + if (err)
30318 + netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err);
30319 ++ mutex_unlock(&mdev->mlx5e_res.td.list_lock);
30320
30321 - int lockup_detector_online_cpu(unsigned int cpu)
30322 - {
30323 -- watchdog_enable(cpu);
30324 -+ if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
30325 -+ watchdog_enable(cpu);
30326 - return 0;
30327 + return err;
30328 }
30329 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
30330 +index 5cf5f2a9d51f..8de64e88c670 100644
30331 +--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
30332 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
30333 +@@ -217,15 +217,21 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
30334 + void *cmd;
30335 + int ret;
30336
30337 - int lockup_detector_offline_cpu(unsigned int cpu)
30338 - {
30339 -- watchdog_disable(cpu);
30340 -+ if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
30341 -+ watchdog_disable(cpu);
30342 - return 0;
30343 - }
30344 ++ rcu_read_lock();
30345 ++ flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
30346 ++ rcu_read_unlock();
30347 ++
30348 ++ if (!flow) {
30349 ++ WARN_ONCE(1, "Received NULL pointer for handle\n");
30350 ++ return -EINVAL;
30351 ++ }
30352 ++
30353 + buf = kzalloc(size, GFP_ATOMIC);
30354 + if (!buf)
30355 + return -ENOMEM;
30356 +
30357 + cmd = (buf + 1);
30358 +
30359 +- rcu_read_lock();
30360 +- flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
30361 +- rcu_read_unlock();
30362 + mlx5_fpga_tls_flow_to_cmd(flow, cmd);
30363
30364 -diff --git a/lib/bsearch.c b/lib/bsearch.c
30365 -index 18b445b010c3..82512fe7b33c 100644
30366 ---- a/lib/bsearch.c
30367 -+++ b/lib/bsearch.c
30368 -@@ -11,6 +11,7 @@
30369 + MLX5_SET(tls_cmd, cmd, swid, ntohl(handle));
30370 +@@ -238,6 +244,8 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
30371 + buf->complete = mlx_tls_kfree_complete;
30372
30373 - #include <linux/export.h>
30374 - #include <linux/bsearch.h>
30375 -+#include <linux/kprobes.h>
30376 + ret = mlx5_fpga_sbu_conn_sendmsg(mdev->fpga->tls->conn, buf);
30377 ++ if (ret < 0)
30378 ++ kfree(buf);
30379
30380 - /*
30381 - * bsearch - binary search an array of elements
30382 -@@ -53,3 +54,4 @@ void *bsearch(const void *key, const void *base, size_t num, size_t size,
30383 - return NULL;
30384 + return ret;
30385 }
30386 - EXPORT_SYMBOL(bsearch);
30387 -+NOKPROBE_SYMBOL(bsearch);
30388 -diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
30389 -index 4e90d443d1b0..e723eacf7868 100644
30390 ---- a/lib/raid6/Makefile
30391 -+++ b/lib/raid6/Makefile
30392 -@@ -39,7 +39,7 @@ endif
30393 - ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
30394 - NEON_FLAGS := -ffreestanding
30395 - ifeq ($(ARCH),arm)
30396 --NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon
30397 -+NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon
30398 - endif
30399 - CFLAGS_recov_neon_inner.o += $(NEON_FLAGS)
30400 - ifeq ($(ARCH),arm64)
30401 -diff --git a/lib/rhashtable.c b/lib/rhashtable.c
30402 -index 852ffa5160f1..4edcf3310513 100644
30403 ---- a/lib/rhashtable.c
30404 -+++ b/lib/rhashtable.c
30405 -@@ -416,8 +416,12 @@ static void rht_deferred_worker(struct work_struct *work)
30406 - else if (tbl->nest)
30407 - err = rhashtable_rehash_alloc(ht, tbl, tbl->size);
30408 -
30409 -- if (!err)
30410 -- err = rhashtable_rehash_table(ht);
30411 -+ if (!err || err == -EEXIST) {
30412 -+ int nerr;
30413 -+
30414 -+ nerr = rhashtable_rehash_table(ht);
30415 -+ err = err ?: nerr;
30416 -+ }
30417 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
30418 +index be81b319b0dc..694edd899322 100644
30419 +--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
30420 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
30421 +@@ -163,26 +163,6 @@ static struct mlx5_profile profile[] = {
30422 + .size = 8,
30423 + .limit = 4
30424 + },
30425 +- .mr_cache[16] = {
30426 +- .size = 8,
30427 +- .limit = 4
30428 +- },
30429 +- .mr_cache[17] = {
30430 +- .size = 8,
30431 +- .limit = 4
30432 +- },
30433 +- .mr_cache[18] = {
30434 +- .size = 8,
30435 +- .limit = 4
30436 +- },
30437 +- .mr_cache[19] = {
30438 +- .size = 4,
30439 +- .limit = 2
30440 +- },
30441 +- .mr_cache[20] = {
30442 +- .size = 4,
30443 +- .limit = 2
30444 +- },
30445 + },
30446 + };
30447
30448 - mutex_unlock(&ht->mutex);
30449 +diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
30450 +index 69d7aebda09b..73db94e55fd0 100644
30451 +--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
30452 ++++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
30453 +@@ -196,7 +196,7 @@ static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev)
30454 + ret = dev_queue_xmit(skb);
30455 + nfp_repr_inc_tx_stats(netdev, len, ret);
30456
30457 -diff --git a/lib/string.c b/lib/string.c
30458 -index 38e4ca08e757..3ab861c1a857 100644
30459 ---- a/lib/string.c
30460 -+++ b/lib/string.c
30461 -@@ -866,6 +866,26 @@ __visible int memcmp(const void *cs, const void *ct, size_t count)
30462 - EXPORT_SYMBOL(memcmp);
30463 - #endif
30464 +- return ret;
30465 ++ return NETDEV_TX_OK;
30466 + }
30467
30468 -+#ifndef __HAVE_ARCH_BCMP
30469 -+/**
30470 -+ * bcmp - returns 0 if and only if the buffers have identical contents.
30471 -+ * @a: pointer to first buffer.
30472 -+ * @b: pointer to second buffer.
30473 -+ * @len: size of buffers.
30474 -+ *
30475 -+ * The sign or magnitude of a non-zero return value has no particular
30476 -+ * meaning, and architectures may implement their own more efficient bcmp(). So
30477 -+ * while this particular implementation is a simple (tail) call to memcmp, do
30478 -+ * not rely on anything but whether the return value is zero or non-zero.
30479 -+ */
30480 -+#undef bcmp
30481 -+int bcmp(const void *a, const void *b, size_t len)
30482 -+{
30483 -+ return memcmp(a, b, len);
30484 -+}
30485 -+EXPORT_SYMBOL(bcmp);
30486 -+#endif
30487 -+
30488 - #ifndef __HAVE_ARCH_MEMSCAN
30489 - /**
30490 - * memscan - Find a character in an area of memory.
30491 -diff --git a/mm/cma.c b/mm/cma.c
30492 -index c7b39dd3b4f6..f4f3a8a57d86 100644
30493 ---- a/mm/cma.c
30494 -+++ b/mm/cma.c
30495 -@@ -353,12 +353,14 @@ int __init cma_declare_contiguous(phys_addr_t base,
30496 -
30497 - ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
30498 - if (ret)
30499 -- goto err;
30500 -+ goto free_mem;
30501 -
30502 - pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
30503 - &base);
30504 - return 0;
30505 + static int nfp_repr_stop(struct net_device *netdev)
30506 +@@ -384,7 +384,7 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
30507 + netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
30508 + netdev->gso_max_segs = NFP_NET_LSO_MAX_SEGS;
30509
30510 -+free_mem:
30511 -+ memblock_free(base, size);
30512 - err:
30513 - pr_err("Failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M);
30514 - return ret;
30515 -diff --git a/mm/debug.c b/mm/debug.c
30516 -index 1611cf00a137..854d5f84047d 100644
30517 ---- a/mm/debug.c
30518 -+++ b/mm/debug.c
30519 -@@ -79,7 +79,7 @@ void __dump_page(struct page *page, const char *reason)
30520 - pr_warn("ksm ");
30521 - else if (mapping) {
30522 - pr_warn("%ps ", mapping->a_ops);
30523 -- if (mapping->host->i_dentry.first) {
30524 -+ if (mapping->host && mapping->host->i_dentry.first) {
30525 - struct dentry *dentry;
30526 - dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias);
30527 - pr_warn("name:\"%pd\" ", dentry);
30528 -diff --git a/mm/huge_memory.c b/mm/huge_memory.c
30529 -index faf357eaf0ce..8b03c698f86e 100644
30530 ---- a/mm/huge_memory.c
30531 -+++ b/mm/huge_memory.c
30532 -@@ -753,6 +753,21 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
30533 - spinlock_t *ptl;
30534 +- netdev->priv_flags |= IFF_NO_QUEUE;
30535 ++ netdev->priv_flags |= IFF_NO_QUEUE | IFF_DISABLE_NETPOLL;
30536 + netdev->features |= NETIF_F_LLTX;
30537
30538 - ptl = pmd_lock(mm, pmd);
30539 -+ if (!pmd_none(*pmd)) {
30540 -+ if (write) {
30541 -+ if (pmd_pfn(*pmd) != pfn_t_to_pfn(pfn)) {
30542 -+ WARN_ON_ONCE(!is_huge_zero_pmd(*pmd));
30543 -+ goto out_unlock;
30544 -+ }
30545 -+ entry = pmd_mkyoung(*pmd);
30546 -+ entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
30547 -+ if (pmdp_set_access_flags(vma, addr, pmd, entry, 1))
30548 -+ update_mmu_cache_pmd(vma, addr, pmd);
30549 -+ }
30550 -+
30551 -+ goto out_unlock;
30552 -+ }
30553 -+
30554 - entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
30555 - if (pfn_t_devmap(pfn))
30556 - entry = pmd_mkdevmap(entry);
30557 -@@ -764,11 +779,16 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
30558 - if (pgtable) {
30559 - pgtable_trans_huge_deposit(mm, pmd, pgtable);
30560 - mm_inc_nr_ptes(mm);
30561 -+ pgtable = NULL;
30562 - }
30563 + if (nfp_app_has_tc(app)) {
30564 +diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
30565 +index f55d177ae894..365cddbfc684 100644
30566 +--- a/drivers/net/ethernet/realtek/r8169.c
30567 ++++ b/drivers/net/ethernet/realtek/r8169.c
30568 +@@ -28,6 +28,7 @@
30569 + #include <linux/pm_runtime.h>
30570 + #include <linux/firmware.h>
30571 + #include <linux/prefetch.h>
30572 ++#include <linux/pci-aspm.h>
30573 + #include <linux/ipv6.h>
30574 + #include <net/ip6_checksum.h>
30575
30576 - set_pmd_at(mm, addr, pmd, entry);
30577 - update_mmu_cache_pmd(vma, addr, pmd);
30578 -+
30579 -+out_unlock:
30580 - spin_unlock(ptl);
30581 -+ if (pgtable)
30582 -+ pte_free(mm, pgtable);
30583 - }
30584 +@@ -5332,7 +5333,7 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
30585 + tp->cp_cmd |= PktCntrDisable | INTT_1;
30586 + RTL_W16(tp, CPlusCmd, tp->cp_cmd);
30587
30588 - vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
30589 -@@ -819,6 +839,20 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr,
30590 - spinlock_t *ptl;
30591 +- RTL_W16(tp, IntrMitigate, 0x5151);
30592 ++ RTL_W16(tp, IntrMitigate, 0x5100);
30593
30594 - ptl = pud_lock(mm, pud);
30595 -+ if (!pud_none(*pud)) {
30596 -+ if (write) {
30597 -+ if (pud_pfn(*pud) != pfn_t_to_pfn(pfn)) {
30598 -+ WARN_ON_ONCE(!is_huge_zero_pud(*pud));
30599 -+ goto out_unlock;
30600 -+ }
30601 -+ entry = pud_mkyoung(*pud);
30602 -+ entry = maybe_pud_mkwrite(pud_mkdirty(entry), vma);
30603 -+ if (pudp_set_access_flags(vma, addr, pud, entry, 1))
30604 -+ update_mmu_cache_pud(vma, addr, pud);
30605 -+ }
30606 -+ goto out_unlock;
30607 -+ }
30608 -+
30609 - entry = pud_mkhuge(pfn_t_pud(pfn, prot));
30610 - if (pfn_t_devmap(pfn))
30611 - entry = pud_mkdevmap(entry);
30612 -@@ -828,6 +862,8 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr,
30613 + /* Work around for RxFIFO overflow. */
30614 + if (tp->mac_version == RTL_GIGA_MAC_VER_11) {
30615 +@@ -7224,6 +7225,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
30616 + return rc;
30617 }
30618 - set_pud_at(mm, addr, pud, entry);
30619 - update_mmu_cache_pud(vma, addr, pud);
30620 +
30621 ++ /* Disable ASPM completely as that cause random device stop working
30622 ++ * problems as well as full system hangs for some PCIe devices users.
30623 ++ */
30624 ++ pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
30625 +
30626 -+out_unlock:
30627 - spin_unlock(ptl);
30628 - }
30629 + /* enable device (incl. PCI PM wakeup and hotplug setup) */
30630 + rc = pcim_enable_device(pdev);
30631 + if (rc < 0) {
30632 +diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
30633 +index e859ae2e42d5..49f41b64077b 100644
30634 +--- a/drivers/net/hyperv/hyperv_net.h
30635 ++++ b/drivers/net/hyperv/hyperv_net.h
30636 +@@ -987,6 +987,7 @@ struct netvsc_device {
30637
30638 -diff --git a/mm/kasan/common.c b/mm/kasan/common.c
30639 -index 09b534fbba17..80bbe62b16cd 100644
30640 ---- a/mm/kasan/common.c
30641 -+++ b/mm/kasan/common.c
30642 -@@ -14,6 +14,8 @@
30643 - *
30644 - */
30645 + wait_queue_head_t wait_drain;
30646 + bool destroy;
30647 ++ bool tx_disable; /* if true, do not wake up queue again */
30648
30649 -+#define __KASAN_INTERNAL
30650 -+
30651 - #include <linux/export.h>
30652 - #include <linux/interrupt.h>
30653 - #include <linux/init.h>
30654 -diff --git a/mm/memcontrol.c b/mm/memcontrol.c
30655 -index af7f18b32389..5bbf2de02a0f 100644
30656 ---- a/mm/memcontrol.c
30657 -+++ b/mm/memcontrol.c
30658 -@@ -248,6 +248,12 @@ enum res_type {
30659 - iter != NULL; \
30660 - iter = mem_cgroup_iter(NULL, iter, NULL))
30661 + /* Receive buffer allocated by us but manages by NetVSP */
30662 + void *recv_buf;
30663 +diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
30664 +index 813d195bbd57..e0dce373cdd9 100644
30665 +--- a/drivers/net/hyperv/netvsc.c
30666 ++++ b/drivers/net/hyperv/netvsc.c
30667 +@@ -110,6 +110,7 @@ static struct netvsc_device *alloc_net_device(void)
30668
30669 -+static inline bool should_force_charge(void)
30670 -+{
30671 -+ return tsk_is_oom_victim(current) || fatal_signal_pending(current) ||
30672 -+ (current->flags & PF_EXITING);
30673 -+}
30674 -+
30675 - /* Some nice accessors for the vmpressure. */
30676 - struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg)
30677 - {
30678 -@@ -1389,8 +1395,13 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
30679 - };
30680 - bool ret;
30681 + init_waitqueue_head(&net_device->wait_drain);
30682 + net_device->destroy = false;
30683 ++ net_device->tx_disable = false;
30684
30685 -- mutex_lock(&oom_lock);
30686 -- ret = out_of_memory(&oc);
30687 -+ if (mutex_lock_killable(&oom_lock))
30688 -+ return true;
30689 -+ /*
30690 -+ * A few threads which were not waiting at mutex_lock_killable() can
30691 -+ * fail to bail out. Therefore, check again after holding oom_lock.
30692 -+ */
30693 -+ ret = should_force_charge() || out_of_memory(&oc);
30694 - mutex_unlock(&oom_lock);
30695 - return ret;
30696 - }
30697 -@@ -2209,9 +2220,7 @@ retry:
30698 - * bypass the last charges so that they can exit quickly and
30699 - * free their memory.
30700 - */
30701 -- if (unlikely(tsk_is_oom_victim(current) ||
30702 -- fatal_signal_pending(current) ||
30703 -- current->flags & PF_EXITING))
30704 -+ if (unlikely(should_force_charge()))
30705 - goto force;
30706 + net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
30707 + net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
30708 +@@ -719,7 +720,7 @@ static void netvsc_send_tx_complete(struct net_device *ndev,
30709 + } else {
30710 + struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx);
30711
30712 - /*
30713 -@@ -3873,6 +3882,22 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb)
30714 - return &memcg->cgwb_domain;
30715 +- if (netif_tx_queue_stopped(txq) &&
30716 ++ if (netif_tx_queue_stopped(txq) && !net_device->tx_disable &&
30717 + (hv_get_avail_to_write_percent(&channel->outbound) >
30718 + RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) {
30719 + netif_tx_wake_queue(txq);
30720 +@@ -874,7 +875,8 @@ static inline int netvsc_send_pkt(
30721 + } else if (ret == -EAGAIN) {
30722 + netif_tx_stop_queue(txq);
30723 + ndev_ctx->eth_stats.stop_queue++;
30724 +- if (atomic_read(&nvchan->queue_sends) < 1) {
30725 ++ if (atomic_read(&nvchan->queue_sends) < 1 &&
30726 ++ !net_device->tx_disable) {
30727 + netif_tx_wake_queue(txq);
30728 + ndev_ctx->eth_stats.wake_queue++;
30729 + ret = -ENOSPC;
30730 +diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
30731 +index cf4897043e83..b20fb0fb595b 100644
30732 +--- a/drivers/net/hyperv/netvsc_drv.c
30733 ++++ b/drivers/net/hyperv/netvsc_drv.c
30734 +@@ -109,6 +109,15 @@ static void netvsc_set_rx_mode(struct net_device *net)
30735 + rcu_read_unlock();
30736 }
30737
30738 -+/*
30739 -+ * idx can be of type enum memcg_stat_item or node_stat_item.
30740 -+ * Keep in sync with memcg_exact_page().
30741 -+ */
30742 -+static unsigned long memcg_exact_page_state(struct mem_cgroup *memcg, int idx)
30743 ++static void netvsc_tx_enable(struct netvsc_device *nvscdev,
30744 ++ struct net_device *ndev)
30745 +{
30746 -+ long x = atomic_long_read(&memcg->stat[idx]);
30747 -+ int cpu;
30748 ++ nvscdev->tx_disable = false;
30749 ++ virt_wmb(); /* ensure queue wake up mechanism is on */
30750 +
30751 -+ for_each_online_cpu(cpu)
30752 -+ x += per_cpu_ptr(memcg->stat_cpu, cpu)->count[idx];
30753 -+ if (x < 0)
30754 -+ x = 0;
30755 -+ return x;
30756 ++ netif_tx_wake_all_queues(ndev);
30757 +}
30758 +
30759 - /**
30760 - * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
30761 - * @wb: bdi_writeback in question
30762 -@@ -3898,10 +3923,10 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
30763 - struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
30764 - struct mem_cgroup *parent;
30765 -
30766 -- *pdirty = memcg_page_state(memcg, NR_FILE_DIRTY);
30767 -+ *pdirty = memcg_exact_page_state(memcg, NR_FILE_DIRTY);
30768 -
30769 - /* this should eventually include NR_UNSTABLE_NFS */
30770 -- *pwriteback = memcg_page_state(memcg, NR_WRITEBACK);
30771 -+ *pwriteback = memcg_exact_page_state(memcg, NR_WRITEBACK);
30772 - *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
30773 - (1 << LRU_ACTIVE_FILE));
30774 - *pheadroom = PAGE_COUNTER_MAX;
30775 -diff --git a/mm/memory-failure.c b/mm/memory-failure.c
30776 -index 831be5ff5f4d..fc8b51744579 100644
30777 ---- a/mm/memory-failure.c
30778 -+++ b/mm/memory-failure.c
30779 -@@ -1825,19 +1825,17 @@ static int soft_offline_in_use_page(struct page *page, int flags)
30780 - struct page *hpage = compound_head(page);
30781 -
30782 - if (!PageHuge(page) && PageTransHuge(hpage)) {
30783 -- lock_page(hpage);
30784 -- if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
30785 -- unlock_page(hpage);
30786 -- if (!PageAnon(hpage))
30787 -+ lock_page(page);
30788 -+ if (!PageAnon(page) || unlikely(split_huge_page(page))) {
30789 -+ unlock_page(page);
30790 -+ if (!PageAnon(page))
30791 - pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page));
30792 - else
30793 - pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page));
30794 -- put_hwpoison_page(hpage);
30795 -+ put_hwpoison_page(page);
30796 - return -EBUSY;
30797 - }
30798 -- unlock_page(hpage);
30799 -- get_hwpoison_page(page);
30800 -- put_hwpoison_page(hpage);
30801 -+ unlock_page(page);
30802 + static int netvsc_open(struct net_device *net)
30803 + {
30804 + struct net_device_context *ndev_ctx = netdev_priv(net);
30805 +@@ -129,7 +138,7 @@ static int netvsc_open(struct net_device *net)
30806 + rdev = nvdev->extension;
30807 + if (!rdev->link_state) {
30808 + netif_carrier_on(net);
30809 +- netif_tx_wake_all_queues(net);
30810 ++ netvsc_tx_enable(nvdev, net);
30811 }
30812
30813 - /*
30814 -diff --git a/mm/memory.c b/mm/memory.c
30815 -index e11ca9dd823f..8d3f38fa530d 100644
30816 ---- a/mm/memory.c
30817 -+++ b/mm/memory.c
30818 -@@ -1546,10 +1546,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
30819 - WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte)));
30820 - goto out_unlock;
30821 - }
30822 -- entry = *pte;
30823 -- goto out_mkwrite;
30824 -- } else
30825 -- goto out_unlock;
30826 -+ entry = pte_mkyoung(*pte);
30827 -+ entry = maybe_mkwrite(pte_mkdirty(entry), vma);
30828 -+ if (ptep_set_access_flags(vma, addr, pte, entry, 1))
30829 -+ update_mmu_cache(vma, addr, pte);
30830 -+ }
30831 -+ goto out_unlock;
30832 + if (vf_netdev) {
30833 +@@ -184,6 +193,17 @@ static int netvsc_wait_until_empty(struct netvsc_device *nvdev)
30834 }
30835 + }
30836
30837 - /* Ok, finally just insert the thing.. */
30838 -@@ -1558,7 +1560,6 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
30839 - else
30840 - entry = pte_mkspecial(pfn_t_pte(pfn, prot));
30841 -
30842 --out_mkwrite:
30843 - if (mkwrite) {
30844 - entry = pte_mkyoung(entry);
30845 - entry = maybe_mkwrite(pte_mkdirty(entry), vma);
30846 -@@ -3517,10 +3518,13 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
30847 - * but allow concurrent faults).
30848 - * The mmap_sem may have been released depending on flags and our
30849 - * return value. See filemap_fault() and __lock_page_or_retry().
30850 -+ * If mmap_sem is released, vma may become invalid (for example
30851 -+ * by other thread calling munmap()).
30852 - */
30853 - static vm_fault_t do_fault(struct vm_fault *vmf)
30854 - {
30855 - struct vm_area_struct *vma = vmf->vma;
30856 -+ struct mm_struct *vm_mm = vma->vm_mm;
30857 - vm_fault_t ret;
30858 -
30859 - /*
30860 -@@ -3561,7 +3565,7 @@ static vm_fault_t do_fault(struct vm_fault *vmf)
30861 -
30862 - /* preallocated pagetable is unused: free it */
30863 - if (vmf->prealloc_pte) {
30864 -- pte_free(vma->vm_mm, vmf->prealloc_pte);
30865 -+ pte_free(vm_mm, vmf->prealloc_pte);
30866 - vmf->prealloc_pte = NULL;
30867 - }
30868 - return ret;
30869 -diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
30870 -index 1ad28323fb9f..11593a03c051 100644
30871 ---- a/mm/memory_hotplug.c
30872 -+++ b/mm/memory_hotplug.c
30873 -@@ -1560,7 +1560,7 @@ static int __ref __offline_pages(unsigned long start_pfn,
30874 - {
30875 - unsigned long pfn, nr_pages;
30876 - long offlined_pages;
30877 -- int ret, node;
30878 -+ int ret, node, nr_isolate_pageblock;
30879 - unsigned long flags;
30880 - unsigned long valid_start, valid_end;
30881 - struct zone *zone;
30882 -@@ -1586,10 +1586,11 @@ static int __ref __offline_pages(unsigned long start_pfn,
30883 - ret = start_isolate_page_range(start_pfn, end_pfn,
30884 - MIGRATE_MOVABLE,
30885 - SKIP_HWPOISON | REPORT_FAILURE);
30886 -- if (ret) {
30887 -+ if (ret < 0) {
30888 - reason = "failure to isolate range";
30889 - goto failed_removal;
30890 - }
30891 -+ nr_isolate_pageblock = ret;
30892 -
30893 - arg.start_pfn = start_pfn;
30894 - arg.nr_pages = nr_pages;
30895 -@@ -1642,8 +1643,16 @@ static int __ref __offline_pages(unsigned long start_pfn,
30896 - /* Ok, all of our target is isolated.
30897 - We cannot do rollback at this point. */
30898 - offline_isolated_pages(start_pfn, end_pfn);
30899 -- /* reset pagetype flags and makes migrate type to be MOVABLE */
30900 -- undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
30901 ++static void netvsc_tx_disable(struct netvsc_device *nvscdev,
30902 ++ struct net_device *ndev)
30903 ++{
30904 ++ if (nvscdev) {
30905 ++ nvscdev->tx_disable = true;
30906 ++ virt_wmb(); /* ensure txq will not wake up after stop */
30907 ++ }
30908 +
30909 -+ /*
30910 -+ * Onlining will reset pagetype flags and makes migrate type
30911 -+ * MOVABLE, so just need to decrease the number of isolated
30912 -+ * pageblocks zone counter here.
30913 -+ */
30914 -+ spin_lock_irqsave(&zone->lock, flags);
30915 -+ zone->nr_isolate_pageblock -= nr_isolate_pageblock;
30916 -+ spin_unlock_irqrestore(&zone->lock, flags);
30917 ++ netif_tx_disable(ndev);
30918 ++}
30919 +
30920 - /* removal success */
30921 - adjust_managed_page_count(pfn_to_page(start_pfn), -offlined_pages);
30922 - zone->present_pages -= offlined_pages;
30923 -@@ -1675,12 +1684,12 @@ static int __ref __offline_pages(unsigned long start_pfn,
30924 -
30925 - failed_removal_isolated:
30926 - undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
30927 -+ memory_notify(MEM_CANCEL_OFFLINE, &arg);
30928 - failed_removal:
30929 - pr_debug("memory offlining [mem %#010llx-%#010llx] failed due to %s\n",
30930 - (unsigned long long) start_pfn << PAGE_SHIFT,
30931 - ((unsigned long long) end_pfn << PAGE_SHIFT) - 1,
30932 - reason);
30933 -- memory_notify(MEM_CANCEL_OFFLINE, &arg);
30934 - /* pushback to free area */
30935 - mem_hotplug_done();
30936 - return ret;
30937 -diff --git a/mm/mempolicy.c b/mm/mempolicy.c
30938 -index ee2bce59d2bf..c2275c1e6d2a 100644
30939 ---- a/mm/mempolicy.c
30940 -+++ b/mm/mempolicy.c
30941 -@@ -350,7 +350,7 @@ static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask)
30942 + static int netvsc_close(struct net_device *net)
30943 {
30944 - if (!pol)
30945 - return;
30946 -- if (!mpol_store_user_nodemask(pol) &&
30947 -+ if (!mpol_store_user_nodemask(pol) && !(pol->flags & MPOL_F_LOCAL) &&
30948 - nodes_equal(pol->w.cpuset_mems_allowed, *newmask))
30949 - return;
30950 -
30951 -@@ -428,6 +428,13 @@ static inline bool queue_pages_required(struct page *page,
30952 - return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT);
30953 - }
30954 + struct net_device_context *net_device_ctx = netdev_priv(net);
30955 +@@ -192,7 +212,7 @@ static int netvsc_close(struct net_device *net)
30956 + struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
30957 + int ret;
30958
30959 -+/*
30960 -+ * queue_pages_pmd() has three possible return values:
30961 -+ * 1 - pages are placed on the right node or queued successfully.
30962 -+ * 0 - THP was split.
30963 -+ * -EIO - is migration entry or MPOL_MF_STRICT was specified and an existing
30964 -+ * page was already on a node that does not follow the policy.
30965 -+ */
30966 - static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,
30967 - unsigned long end, struct mm_walk *walk)
30968 - {
30969 -@@ -437,7 +444,7 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,
30970 - unsigned long flags;
30971 +- netif_tx_disable(net);
30972 ++ netvsc_tx_disable(nvdev, net);
30973
30974 - if (unlikely(is_pmd_migration_entry(*pmd))) {
30975 -- ret = 1;
30976 -+ ret = -EIO;
30977 - goto unlock;
30978 - }
30979 - page = pmd_page(*pmd);
30980 -@@ -454,8 +461,15 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,
30981 - ret = 1;
30982 - flags = qp->flags;
30983 - /* go to thp migration */
30984 -- if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
30985 -+ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
30986 -+ if (!vma_migratable(walk->vma)) {
30987 -+ ret = -EIO;
30988 -+ goto unlock;
30989 -+ }
30990 -+
30991 - migrate_page_add(page, qp->pagelist, flags);
30992 -+ } else
30993 -+ ret = -EIO;
30994 - unlock:
30995 - spin_unlock(ptl);
30996 - out:
30997 -@@ -480,8 +494,10 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
30998 - ptl = pmd_trans_huge_lock(pmd, vma);
30999 - if (ptl) {
31000 - ret = queue_pages_pmd(pmd, ptl, addr, end, walk);
31001 -- if (ret)
31002 -+ if (ret > 0)
31003 - return 0;
31004 -+ else if (ret < 0)
31005 -+ return ret;
31006 - }
31007 + /* No need to close rndis filter if it is removed already */
31008 + if (!nvdev)
31009 +@@ -920,7 +940,7 @@ static int netvsc_detach(struct net_device *ndev,
31010
31011 - if (pmd_trans_unstable(pmd))
31012 -@@ -502,11 +518,16 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
31013 - continue;
31014 - if (!queue_pages_required(page, qp))
31015 - continue;
31016 -- migrate_page_add(page, qp->pagelist, flags);
31017 -+ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
31018 -+ if (!vma_migratable(vma))
31019 -+ break;
31020 -+ migrate_page_add(page, qp->pagelist, flags);
31021 -+ } else
31022 -+ break;
31023 - }
31024 - pte_unmap_unlock(pte - 1, ptl);
31025 - cond_resched();
31026 -- return 0;
31027 -+ return addr != end ? -EIO : 0;
31028 - }
31029 + /* If device was up (receiving) then shutdown */
31030 + if (netif_running(ndev)) {
31031 +- netif_tx_disable(ndev);
31032 ++ netvsc_tx_disable(nvdev, ndev);
31033
31034 - static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
31035 -@@ -576,7 +597,12 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
31036 - unsigned long endvma = vma->vm_end;
31037 - unsigned long flags = qp->flags;
31038 + ret = rndis_filter_close(nvdev);
31039 + if (ret) {
31040 +@@ -1908,7 +1928,7 @@ static void netvsc_link_change(struct work_struct *w)
31041 + if (rdev->link_state) {
31042 + rdev->link_state = false;
31043 + netif_carrier_on(net);
31044 +- netif_tx_wake_all_queues(net);
31045 ++ netvsc_tx_enable(net_device, net);
31046 + } else {
31047 + notify = true;
31048 + }
31049 +@@ -1918,7 +1938,7 @@ static void netvsc_link_change(struct work_struct *w)
31050 + if (!rdev->link_state) {
31051 + rdev->link_state = true;
31052 + netif_carrier_off(net);
31053 +- netif_tx_stop_all_queues(net);
31054 ++ netvsc_tx_disable(net_device, net);
31055 + }
31056 + kfree(event);
31057 + break;
31058 +@@ -1927,7 +1947,7 @@ static void netvsc_link_change(struct work_struct *w)
31059 + if (!rdev->link_state) {
31060 + rdev->link_state = true;
31061 + netif_carrier_off(net);
31062 +- netif_tx_stop_all_queues(net);
31063 ++ netvsc_tx_disable(net_device, net);
31064 + event->event = RNDIS_STATUS_MEDIA_CONNECT;
31065 + spin_lock_irqsave(&ndev_ctx->lock, flags);
31066 + list_add(&event->list, &ndev_ctx->reconfig_events);
31067 +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
31068 +index 74bebbdb4b15..9195f3476b1d 100644
31069 +--- a/drivers/net/usb/qmi_wwan.c
31070 ++++ b/drivers/net/usb/qmi_wwan.c
31071 +@@ -1203,6 +1203,7 @@ static const struct usb_device_id products[] = {
31072 + {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
31073 + {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */
31074 + {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */
31075 ++ {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */
31076 + {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */
31077 + {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
31078 + {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
31079 +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
31080 +index 6d1a1abbed27..cd15c32b2e43 100644
31081 +--- a/drivers/net/vrf.c
31082 ++++ b/drivers/net/vrf.c
31083 +@@ -1275,8 +1275,12 @@ static void vrf_setup(struct net_device *dev)
31084 + dev->priv_flags |= IFF_NO_QUEUE;
31085 + dev->priv_flags |= IFF_NO_RX_HANDLER;
31086
31087 -- if (!vma_migratable(vma))
31088 -+ /*
31089 -+ * Need check MPOL_MF_STRICT to return -EIO if possible
31090 -+ * regardless of vma_migratable
31091 +- dev->min_mtu = 0;
31092 +- dev->max_mtu = 0;
31093 ++ /* VRF devices do not care about MTU, but if the MTU is set
31094 ++ * too low then the ipv4 and ipv6 protocols are disabled
31095 ++ * which breaks networking.
31096 + */
31097 -+ if (!vma_migratable(vma) &&
31098 -+ !(flags & MPOL_MF_STRICT))
31099 - return 1;
31100 -
31101 - if (endvma > end)
31102 -@@ -603,7 +629,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
31103 - }
31104 -
31105 - /* queue pages from current vma */
31106 -- if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
31107 -+ if (flags & MPOL_MF_VALID)
31108 - return 0;
31109 - return 1;
31110 ++ dev->min_mtu = IPV6_MIN_MTU;
31111 ++ dev->max_mtu = ETH_MAX_MTU;
31112 }
31113 -diff --git a/mm/migrate.c b/mm/migrate.c
31114 -index 181f5d2718a9..76e237b4610c 100644
31115 ---- a/mm/migrate.c
31116 -+++ b/mm/migrate.c
31117 -@@ -248,10 +248,8 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
31118 - pte = swp_entry_to_pte(entry);
31119 - } else if (is_device_public_page(new)) {
31120 - pte = pte_mkdevmap(pte);
31121 -- flush_dcache_page(new);
31122 - }
31123 -- } else
31124 -- flush_dcache_page(new);
31125 -+ }
31126
31127 - #ifdef CONFIG_HUGETLB_PAGE
31128 - if (PageHuge(new)) {
31129 -@@ -995,6 +993,13 @@ static int move_to_new_page(struct page *newpage, struct page *page,
31130 + static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],
31131 +diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
31132 +index 3f3df4c29f6e..905282a8ddaa 100644
31133 +--- a/drivers/pci/hotplug/pciehp_ctrl.c
31134 ++++ b/drivers/pci/hotplug/pciehp_ctrl.c
31135 +@@ -115,6 +115,10 @@ static void remove_board(struct controller *ctrl, bool safe_removal)
31136 + * removed from the slot/adapter.
31137 */
31138 - if (!PageMappingFlags(page))
31139 - page->mapping = NULL;
31140 -+
31141 -+ if (unlikely(is_zone_device_page(newpage))) {
31142 -+ if (is_device_public_page(newpage))
31143 -+ flush_dcache_page(newpage);
31144 -+ } else
31145 -+ flush_dcache_page(newpage);
31146 + msleep(1000);
31147 +
31148 ++ /* Ignore link or presence changes caused by power off */
31149 ++ atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
31150 ++ &ctrl->pending_events);
31151 }
31152 - out:
31153 - return rc;
31154 -diff --git a/mm/oom_kill.c b/mm/oom_kill.c
31155 -index 26ea8636758f..da0e44914085 100644
31156 ---- a/mm/oom_kill.c
31157 -+++ b/mm/oom_kill.c
31158 -@@ -928,7 +928,8 @@ static void __oom_kill_process(struct task_struct *victim)
31159 - */
31160 - static int oom_kill_memcg_member(struct task_struct *task, void *unused)
31161 - {
31162 -- if (task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) {
31163 -+ if (task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN &&
31164 -+ !is_global_init(task)) {
31165 - get_task_struct(task);
31166 - __oom_kill_process(task);
31167 - }
31168 -diff --git a/mm/page_alloc.c b/mm/page_alloc.c
31169 -index 0b9f577b1a2a..20dd3283bb1b 100644
31170 ---- a/mm/page_alloc.c
31171 -+++ b/mm/page_alloc.c
31172 -@@ -1945,8 +1945,8 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
31173 -
31174 - arch_alloc_page(page, order);
31175 - kernel_map_pages(page, 1 << order, 1);
31176 -- kernel_poison_pages(page, 1 << order, 1);
31177 - kasan_alloc_pages(page, order);
31178 -+ kernel_poison_pages(page, 1 << order, 1);
31179 - set_page_owner(page, order, gfp_flags);
31180 - }
31181
31182 -@@ -8160,7 +8160,7 @@ int alloc_contig_range(unsigned long start, unsigned long end,
31183 + /* turn off Green LED */
31184 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
31185 +index e2a879e93d86..fba03a7d5c7f 100644
31186 +--- a/drivers/pci/quirks.c
31187 ++++ b/drivers/pci/quirks.c
31188 +@@ -3877,6 +3877,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128,
31189 + /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */
31190 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130,
31191 + quirk_dma_func1_alias);
31192 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9170,
31193 ++ quirk_dma_func1_alias);
31194 + /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */
31195 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9172,
31196 + quirk_dma_func1_alias);
31197 +diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
31198 +index 0840d27381ea..e0a04bfc873e 100644
31199 +--- a/drivers/tty/Kconfig
31200 ++++ b/drivers/tty/Kconfig
31201 +@@ -441,4 +441,28 @@ config VCC
31202 + depends on SUN_LDOMS
31203 + help
31204 + Support for Sun logical domain consoles.
31205 ++
31206 ++config LDISC_AUTOLOAD
31207 ++ bool "Automatically load TTY Line Disciplines"
31208 ++ default y
31209 ++ help
31210 ++ Historically the kernel has always automatically loaded any
31211 ++ line discipline that is in a kernel module when a user asks
31212 ++ for it to be loaded with the TIOCSETD ioctl, or through other
31213 ++ means. This is not always the best thing to do on systems
31214 ++ where you know you will not be using some of the more
31215 ++ "ancient" line disciplines, so prevent the kernel from doing
31216 ++ this unless the request is coming from a process with the
31217 ++ CAP_SYS_MODULE permissions.
31218 ++
31219 ++ Say 'Y' here if you trust your userspace users to do the right
31220 ++ thing, or if you have only provided the line disciplines that
31221 ++ you know you will be using, or if you wish to continue to use
31222 ++ the traditional method of on-demand loading of these modules
31223 ++ by any user.
31224 ++
31225 ++ This functionality can be changed at runtime with the
31226 ++ dev.tty.ldisc_autoload sysctl, this configuration option will
31227 ++ only set the default value of this functionality.
31228 ++
31229 + endif # TTY
31230 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
31231 +index 21ffcce16927..5fa250157025 100644
31232 +--- a/drivers/tty/tty_io.c
31233 ++++ b/drivers/tty/tty_io.c
31234 +@@ -513,6 +513,8 @@ static const struct file_operations hung_up_tty_fops = {
31235 + static DEFINE_SPINLOCK(redirect_lock);
31236 + static struct file *redirect;
31237
31238 - ret = start_isolate_page_range(pfn_max_align_down(start),
31239 - pfn_max_align_up(end), migratetype, 0);
31240 -- if (ret)
31241 -+ if (ret < 0)
31242 - return ret;
31243 ++extern void tty_sysctl_init(void);
31244 ++
31245 + /**
31246 + * tty_wakeup - request more data
31247 + * @tty: terminal
31248 +@@ -3483,6 +3485,7 @@ void console_sysfs_notify(void)
31249 + */
31250 + int __init tty_init(void)
31251 + {
31252 ++ tty_sysctl_init();
31253 + cdev_init(&tty_cdev, &tty_fops);
31254 + if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
31255 + register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
31256 +diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
31257 +index 45eda69b150c..e38f104db174 100644
31258 +--- a/drivers/tty/tty_ldisc.c
31259 ++++ b/drivers/tty/tty_ldisc.c
31260 +@@ -156,6 +156,13 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
31261 + * takes tty_ldiscs_lock to guard against ldisc races
31262 + */
31263
31264 - /*
31265 -diff --git a/mm/page_ext.c b/mm/page_ext.c
31266 -index 8c78b8d45117..f116431c3dee 100644
31267 ---- a/mm/page_ext.c
31268 -+++ b/mm/page_ext.c
31269 -@@ -273,6 +273,7 @@ static void free_page_ext(void *addr)
31270 - table_size = get_entry_size() * PAGES_PER_SECTION;
31271 -
31272 - BUG_ON(PageReserved(page));
31273 -+ kmemleak_free(addr);
31274 - free_pages_exact(addr, table_size);
31275 - }
31276 - }
31277 -diff --git a/mm/page_isolation.c b/mm/page_isolation.c
31278 -index ce323e56b34d..019280712e1b 100644
31279 ---- a/mm/page_isolation.c
31280 -+++ b/mm/page_isolation.c
31281 -@@ -59,7 +59,8 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
31282 - * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself.
31283 - * We just check MOVABLE pages.
31284 ++#if defined(CONFIG_LDISC_AUTOLOAD)
31285 ++ #define INITIAL_AUTOLOAD_STATE 1
31286 ++#else
31287 ++ #define INITIAL_AUTOLOAD_STATE 0
31288 ++#endif
31289 ++static int tty_ldisc_autoload = INITIAL_AUTOLOAD_STATE;
31290 ++
31291 + static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
31292 + {
31293 + struct tty_ldisc *ld;
31294 +@@ -170,6 +177,8 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
31295 */
31296 -- if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype, flags))
31297 -+ if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype,
31298 -+ isol_flags))
31299 - ret = 0;
31300 -
31301 - /*
31302 -@@ -160,27 +161,36 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages)
31303 - return NULL;
31304 + ldops = get_ldops(disc);
31305 + if (IS_ERR(ldops)) {
31306 ++ if (!capable(CAP_SYS_MODULE) && !tty_ldisc_autoload)
31307 ++ return ERR_PTR(-EPERM);
31308 + request_module("tty-ldisc-%d", disc);
31309 + ldops = get_ldops(disc);
31310 + if (IS_ERR(ldops))
31311 +@@ -845,3 +854,41 @@ void tty_ldisc_deinit(struct tty_struct *tty)
31312 + tty_ldisc_put(tty->ldisc);
31313 + tty->ldisc = NULL;
31314 }
31315 -
31316 --/*
31317 -- * start_isolate_page_range() -- make page-allocation-type of range of pages
31318 -- * to be MIGRATE_ISOLATE.
31319 -- * @start_pfn: The lower PFN of the range to be isolated.
31320 -- * @end_pfn: The upper PFN of the range to be isolated.
31321 -- * @migratetype: migrate type to set in error recovery.
31322 -+/**
31323 -+ * start_isolate_page_range() - make page-allocation-type of range of pages to
31324 -+ * be MIGRATE_ISOLATE.
31325 -+ * @start_pfn: The lower PFN of the range to be isolated.
31326 -+ * @end_pfn: The upper PFN of the range to be isolated.
31327 -+ * start_pfn/end_pfn must be aligned to pageblock_order.
31328 -+ * @migratetype: Migrate type to set in error recovery.
31329 -+ * @flags: The following flags are allowed (they can be combined in
31330 -+ * a bit mask)
31331 -+ * SKIP_HWPOISON - ignore hwpoison pages
31332 -+ * REPORT_FAILURE - report details about the failure to
31333 -+ * isolate the range
31334 - *
31335 - * Making page-allocation-type to be MIGRATE_ISOLATE means free pages in
31336 - * the range will never be allocated. Any free pages and pages freed in the
31337 -- * future will not be allocated again.
31338 -- *
31339 -- * start_pfn/end_pfn must be aligned to pageblock_order.
31340 -- * Return 0 on success and -EBUSY if any part of range cannot be isolated.
31341 -+ * future will not be allocated again. If specified range includes migrate types
31342 -+ * other than MOVABLE or CMA, this will fail with -EBUSY. For isolating all
31343 -+ * pages in the range finally, the caller have to free all pages in the range.
31344 -+ * test_page_isolated() can be used for test it.
31345 - *
31346 - * There is no high level synchronization mechanism that prevents two threads
31347 -- * from trying to isolate overlapping ranges. If this happens, one thread
31348 -+ * from trying to isolate overlapping ranges. If this happens, one thread
31349 - * will notice pageblocks in the overlapping range already set to isolate.
31350 - * This happens in set_migratetype_isolate, and set_migratetype_isolate
31351 -- * returns an error. We then clean up by restoring the migration type on
31352 -- * pageblocks we may have modified and return -EBUSY to caller. This
31353 -+ * returns an error. We then clean up by restoring the migration type on
31354 -+ * pageblocks we may have modified and return -EBUSY to caller. This
31355 - * prevents two threads from simultaneously working on overlapping ranges.
31356 -+ *
31357 -+ * Return: the number of isolated pageblocks on success and -EBUSY if any part
31358 -+ * of range cannot be isolated.
31359 - */
31360 - int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
31361 - unsigned migratetype, int flags)
31362 -@@ -188,6 +198,7 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
31363 - unsigned long pfn;
31364 - unsigned long undo_pfn;
31365 - struct page *page;
31366 -+ int nr_isolate_pageblock = 0;
31367 -
31368 - BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages));
31369 - BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages));
31370 -@@ -196,13 +207,15 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
31371 - pfn < end_pfn;
31372 - pfn += pageblock_nr_pages) {
31373 - page = __first_valid_page(pfn, pageblock_nr_pages);
31374 -- if (page &&
31375 -- set_migratetype_isolate(page, migratetype, flags)) {
31376 -- undo_pfn = pfn;
31377 -- goto undo;
31378 -+ if (page) {
31379 -+ if (set_migratetype_isolate(page, migratetype, flags)) {
31380 -+ undo_pfn = pfn;
31381 -+ goto undo;
31382 -+ }
31383 -+ nr_isolate_pageblock++;
31384 - }
31385 ++
31386 ++static int zero;
31387 ++static int one = 1;
31388 ++static struct ctl_table tty_table[] = {
31389 ++ {
31390 ++ .procname = "ldisc_autoload",
31391 ++ .data = &tty_ldisc_autoload,
31392 ++ .maxlen = sizeof(tty_ldisc_autoload),
31393 ++ .mode = 0644,
31394 ++ .proc_handler = proc_dointvec,
31395 ++ .extra1 = &zero,
31396 ++ .extra2 = &one,
31397 ++ },
31398 ++ { }
31399 ++};
31400 ++
31401 ++static struct ctl_table tty_dir_table[] = {
31402 ++ {
31403 ++ .procname = "tty",
31404 ++ .mode = 0555,
31405 ++ .child = tty_table,
31406 ++ },
31407 ++ { }
31408 ++};
31409 ++
31410 ++static struct ctl_table tty_root_table[] = {
31411 ++ {
31412 ++ .procname = "dev",
31413 ++ .mode = 0555,
31414 ++ .child = tty_dir_table,
31415 ++ },
31416 ++ { }
31417 ++};
31418 ++
31419 ++void tty_sysctl_init(void)
31420 ++{
31421 ++ register_sysctl_table(tty_root_table);
31422 ++}
31423 +diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
31424 +index a0b07c331255..a38b65b97be0 100644
31425 +--- a/drivers/virtio/virtio_ring.c
31426 ++++ b/drivers/virtio/virtio_ring.c
31427 +@@ -871,6 +871,8 @@ static struct virtqueue *vring_create_virtqueue_split(
31428 + GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
31429 + if (queue)
31430 + break;
31431 ++ if (!may_reduce_num)
31432 ++ return NULL;
31433 }
31434 -- return 0;
31435 -+ return nr_isolate_pageblock;
31436 - undo:
31437 - for (pfn = start_pfn;
31438 - pfn < undo_pfn;
31439 -diff --git a/mm/page_poison.c b/mm/page_poison.c
31440 -index f0c15e9017c0..21d4f97cb49b 100644
31441 ---- a/mm/page_poison.c
31442 -+++ b/mm/page_poison.c
31443 -@@ -6,6 +6,7 @@
31444 - #include <linux/page_ext.h>
31445 - #include <linux/poison.h>
31446 - #include <linux/ratelimit.h>
31447 -+#include <linux/kasan.h>
31448 -
31449 - static bool want_page_poisoning __read_mostly;
31450 -
31451 -@@ -40,7 +41,10 @@ static void poison_page(struct page *page)
31452 - {
31453 - void *addr = kmap_atomic(page);
31454
31455 -+ /* KASAN still think the page is in-use, so skip it. */
31456 -+ kasan_disable_current();
31457 - memset(addr, PAGE_POISON, PAGE_SIZE);
31458 -+ kasan_enable_current();
31459 - kunmap_atomic(addr);
31460 - }
31461 + if (!num)
31462 +diff --git a/fs/block_dev.c b/fs/block_dev.c
31463 +index 58a4c1217fa8..06ef48ad1998 100644
31464 +--- a/fs/block_dev.c
31465 ++++ b/fs/block_dev.c
31466 +@@ -298,10 +298,10 @@ static void blkdev_bio_end_io(struct bio *bio)
31467 + struct blkdev_dio *dio = bio->bi_private;
31468 + bool should_dirty = dio->should_dirty;
31469
31470 -diff --git a/mm/slab.c b/mm/slab.c
31471 -index 91c1863df93d..2f2aa8eaf7d9 100644
31472 ---- a/mm/slab.c
31473 -+++ b/mm/slab.c
31474 -@@ -550,14 +550,6 @@ static void start_cpu_timer(int cpu)
31475 +- if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
31476 +- if (bio->bi_status && !dio->bio.bi_status)
31477 +- dio->bio.bi_status = bio->bi_status;
31478 +- } else {
31479 ++ if (bio->bi_status && !dio->bio.bi_status)
31480 ++ dio->bio.bi_status = bio->bi_status;
31481 ++
31482 ++ if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) {
31483 + if (!dio->is_sync) {
31484 + struct kiocb *iocb = dio->iocb;
31485 + ssize_t ret;
31486 +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
31487 +index 6e1119496721..1d64a6b8e413 100644
31488 +--- a/fs/btrfs/ioctl.c
31489 ++++ b/fs/btrfs/ioctl.c
31490 +@@ -501,6 +501,16 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
31491 + if (!capable(CAP_SYS_ADMIN))
31492 + return -EPERM;
31493
31494 - static void init_arraycache(struct array_cache *ac, int limit, int batch)
31495 - {
31496 -- /*
31497 -- * The array_cache structures contain pointers to free object.
31498 -- * However, when such objects are allocated or transferred to another
31499 -- * cache the pointers are not cleared and they could be counted as
31500 -- * valid references during a kmemleak scan. Therefore, kmemleak must
31501 -- * not scan such objects.
31502 -- */
31503 -- kmemleak_no_scan(ac);
31504 - if (ac) {
31505 - ac->avail = 0;
31506 - ac->limit = limit;
31507 -@@ -573,6 +565,14 @@ static struct array_cache *alloc_arraycache(int node, int entries,
31508 - struct array_cache *ac = NULL;
31509 -
31510 - ac = kmalloc_node(memsize, gfp, node);
31511 + /*
31512 -+ * The array_cache structures contain pointers to free object.
31513 -+ * However, when such objects are allocated or transferred to another
31514 -+ * cache the pointers are not cleared and they could be counted as
31515 -+ * valid references during a kmemleak scan. Therefore, kmemleak must
31516 -+ * not scan such objects.
31517 ++ * If the fs is mounted with nologreplay, which requires it to be
31518 ++ * mounted in RO mode as well, we can not allow discard on free space
31519 ++ * inside block groups, because log trees refer to extents that are not
31520 ++ * pinned in a block group's free space cache (pinning the extents is
31521 ++ * precisely the first phase of replaying a log tree).
31522 + */
31523 -+ kmemleak_no_scan(ac);
31524 - init_arraycache(ac, entries, batchcount);
31525 - return ac;
31526 - }
31527 -@@ -667,6 +667,7 @@ static struct alien_cache *__alloc_alien_cache(int node, int entries,
31528 -
31529 - alc = kmalloc_node(memsize, gfp, node);
31530 - if (alc) {
31531 -+ kmemleak_no_scan(alc);
31532 - init_arraycache(&alc->ac, entries, batch);
31533 - spin_lock_init(&alc->lock);
31534 - }
31535 -@@ -2111,6 +2112,8 @@ done:
31536 - cachep->allocflags = __GFP_COMP;
31537 - if (flags & SLAB_CACHE_DMA)
31538 - cachep->allocflags |= GFP_DMA;
31539 -+ if (flags & SLAB_CACHE_DMA32)
31540 -+ cachep->allocflags |= GFP_DMA32;
31541 - if (flags & SLAB_RECLAIM_ACCOUNT)
31542 - cachep->allocflags |= __GFP_RECLAIMABLE;
31543 - cachep->size = size;
31544 -diff --git a/mm/slab.h b/mm/slab.h
31545 -index 384105318779..27834ead5f14 100644
31546 ---- a/mm/slab.h
31547 -+++ b/mm/slab.h
31548 -@@ -127,7 +127,8 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size,
31549 -
31550 -
31551 - /* Legal flag mask for kmem_cache_create(), for various configurations */
31552 --#define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
31553 -+#define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \
31554 -+ SLAB_CACHE_DMA32 | SLAB_PANIC | \
31555 - SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS )
31556 -
31557 - #if defined(CONFIG_DEBUG_SLAB)
31558 -diff --git a/mm/slab_common.c b/mm/slab_common.c
31559 -index f9d89c1b5977..333618231f8d 100644
31560 ---- a/mm/slab_common.c
31561 -+++ b/mm/slab_common.c
31562 -@@ -53,7 +53,7 @@ static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
31563 - SLAB_FAILSLAB | SLAB_KASAN)
31564 -
31565 - #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \
31566 -- SLAB_ACCOUNT)
31567 -+ SLAB_CACHE_DMA32 | SLAB_ACCOUNT)
31568 -
31569 - /*
31570 - * Merge control. If this is set then no merging of slab caches will occur.
31571 -diff --git a/mm/slub.c b/mm/slub.c
31572 -index dc777761b6b7..1673100fd534 100644
31573 ---- a/mm/slub.c
31574 -+++ b/mm/slub.c
31575 -@@ -3591,6 +3591,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
31576 - if (s->flags & SLAB_CACHE_DMA)
31577 - s->allocflags |= GFP_DMA;
31578 -
31579 -+ if (s->flags & SLAB_CACHE_DMA32)
31580 -+ s->allocflags |= GFP_DMA32;
31581 ++ if (btrfs_test_opt(fs_info, NOLOGREPLAY))
31582 ++ return -EROFS;
31583 +
31584 - if (s->flags & SLAB_RECLAIM_ACCOUNT)
31585 - s->allocflags |= __GFP_RECLAIMABLE;
31586 -
31587 -@@ -5681,6 +5684,8 @@ static char *create_unique_id(struct kmem_cache *s)
31588 - */
31589 - if (s->flags & SLAB_CACHE_DMA)
31590 - *p++ = 'd';
31591 -+ if (s->flags & SLAB_CACHE_DMA32)
31592 -+ *p++ = 'D';
31593 - if (s->flags & SLAB_RECLAIM_ACCOUNT)
31594 - *p++ = 'a';
31595 - if (s->flags & SLAB_CONSISTENCY_CHECKS)
31596 -diff --git a/mm/sparse.c b/mm/sparse.c
31597 -index 7ea5dc6c6b19..b3771f35a0ed 100644
31598 ---- a/mm/sparse.c
31599 -+++ b/mm/sparse.c
31600 -@@ -197,7 +197,7 @@ static inline int next_present_section_nr(int section_nr)
31601 - }
31602 - #define for_each_present_section_nr(start, section_nr) \
31603 - for (section_nr = next_present_section_nr(start-1); \
31604 -- ((section_nr >= 0) && \
31605 -+ ((section_nr != -1) && \
31606 - (section_nr <= __highest_present_section_nr)); \
31607 - section_nr = next_present_section_nr(section_nr))
31608 -
31609 -@@ -556,7 +556,7 @@ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
31610 - }
31611 + rcu_read_lock();
31612 + list_for_each_entry_rcu(device, &fs_info->fs_devices->devices,
31613 + dev_list) {
31614 +diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
31615 +index dc6140013ae8..61d22a56c0ba 100644
31616 +--- a/fs/btrfs/props.c
31617 ++++ b/fs/btrfs/props.c
31618 +@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
31619
31620 - #ifdef CONFIG_MEMORY_HOTREMOVE
31621 --/* Mark all memory sections within the pfn range as online */
31622 -+/* Mark all memory sections within the pfn range as offline */
31623 - void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
31624 + static int prop_compression_validate(const char *value, size_t len)
31625 {
31626 - unsigned long pfn;
31627 -diff --git a/mm/swapfile.c b/mm/swapfile.c
31628 -index dbac1d49469d..67f60e051814 100644
31629 ---- a/mm/swapfile.c
31630 -+++ b/mm/swapfile.c
31631 -@@ -98,6 +98,15 @@ static atomic_t proc_poll_event = ATOMIC_INIT(0);
31632 +- if (!strncmp("lzo", value, len))
31633 ++ if (!strncmp("lzo", value, 3))
31634 + return 0;
31635 +- else if (!strncmp("zlib", value, len))
31636 ++ else if (!strncmp("zlib", value, 4))
31637 + return 0;
31638 +- else if (!strncmp("zstd", value, len))
31639 ++ else if (!strncmp("zstd", value, 4))
31640 + return 0;
31641
31642 - atomic_t nr_rotate_swap = ATOMIC_INIT(0);
31643 + return -EINVAL;
31644 +@@ -396,7 +396,7 @@ static int prop_compression_apply(struct inode *inode,
31645 + btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
31646 + } else if (!strncmp("zlib", value, 4)) {
31647 + type = BTRFS_COMPRESS_ZLIB;
31648 +- } else if (!strncmp("zstd", value, len)) {
31649 ++ } else if (!strncmp("zstd", value, 4)) {
31650 + type = BTRFS_COMPRESS_ZSTD;
31651 + btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD);
31652 + } else {
31653 +diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
31654 +index f2c0d863fb52..07cad54b84f1 100644
31655 +--- a/fs/cifs/cifsfs.c
31656 ++++ b/fs/cifs/cifsfs.c
31657 +@@ -559,6 +559,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
31658 + tcon->ses->server->echo_interval / HZ);
31659 + if (tcon->snapshot_time)
31660 + seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
31661 ++ if (tcon->handle_timeout)
31662 ++ seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
31663 + /* convert actimeo and display it in seconds */
31664 + seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
31665
31666 -+static struct swap_info_struct *swap_type_to_swap_info(int type)
31667 -+{
31668 -+ if (type >= READ_ONCE(nr_swapfiles))
31669 -+ return NULL;
31670 -+
31671 -+ smp_rmb(); /* Pairs with smp_wmb in alloc_swap_info. */
31672 -+ return READ_ONCE(swap_info[type]);
31673 -+}
31674 -+
31675 - static inline unsigned char swap_count(unsigned char ent)
31676 - {
31677 - return ent & ~SWAP_HAS_CACHE; /* may include COUNT_CONTINUED flag */
31678 -@@ -1044,12 +1053,14 @@ noswap:
31679 - /* The only caller of this function is now suspend routine */
31680 - swp_entry_t get_swap_page_of_type(int type)
31681 - {
31682 -- struct swap_info_struct *si;
31683 -+ struct swap_info_struct *si = swap_type_to_swap_info(type);
31684 - pgoff_t offset;
31685 +diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
31686 +index 1b25e6e95d45..6c934ab3722b 100644
31687 +--- a/fs/cifs/cifsglob.h
31688 ++++ b/fs/cifs/cifsglob.h
31689 +@@ -59,6 +59,12 @@
31690 + */
31691 + #define CIFS_MAX_ACTIMEO (1 << 30)
31692
31693 -- si = swap_info[type];
31694 -+ if (!si)
31695 -+ goto fail;
31696 ++/*
31697 ++ * Max persistent and resilient handle timeout (milliseconds).
31698 ++ * Windows durable max was 960000 (16 minutes)
31699 ++ */
31700 ++#define SMB3_MAX_HANDLE_TIMEOUT 960000
31701 +
31702 - spin_lock(&si->lock);
31703 -- if (si && (si->flags & SWP_WRITEOK)) {
31704 -+ if (si->flags & SWP_WRITEOK) {
31705 - atomic_long_dec(&nr_swap_pages);
31706 - /* This is called for allocating swap entry, not cache */
31707 - offset = scan_swap_map(si, 1);
31708 -@@ -1060,6 +1071,7 @@ swp_entry_t get_swap_page_of_type(int type)
31709 - atomic_long_inc(&nr_swap_pages);
31710 - }
31711 - spin_unlock(&si->lock);
31712 -+fail:
31713 - return (swp_entry_t) {0};
31714 - }
31715 + /*
31716 + * MAX_REQ is the maximum number of requests that WE will send
31717 + * on one socket concurrently.
31718 +@@ -572,6 +578,7 @@ struct smb_vol {
31719 + struct nls_table *local_nls;
31720 + unsigned int echo_interval; /* echo interval in secs */
31721 + __u64 snapshot_time; /* needed for timewarp tokens */
31722 ++ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
31723 + unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
31724 + };
31725
31726 -@@ -1071,9 +1083,9 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry)
31727 - if (!entry.val)
31728 - goto out;
31729 - type = swp_type(entry);
31730 -- if (type >= nr_swapfiles)
31731 -+ p = swap_type_to_swap_info(type);
31732 -+ if (!p)
31733 - goto bad_nofile;
31734 -- p = swap_info[type];
31735 - if (!(p->flags & SWP_USED))
31736 - goto bad_device;
31737 - offset = swp_offset(entry);
31738 -@@ -1697,10 +1709,9 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
31739 - sector_t swapdev_block(int type, pgoff_t offset)
31740 - {
31741 - struct block_device *bdev;
31742 -+ struct swap_info_struct *si = swap_type_to_swap_info(type);
31743 +@@ -1028,6 +1035,7 @@ struct cifs_tcon {
31744 + __u32 vol_serial_number;
31745 + __le64 vol_create_time;
31746 + __u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */
31747 ++ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
31748 + __u32 ss_flags; /* sector size flags */
31749 + __u32 perf_sector_size; /* best sector size for perf */
31750 + __u32 max_chunks;
31751 +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
31752 +index 9d4e60123db4..44e6ec85f832 100644
31753 +--- a/fs/cifs/connect.c
31754 ++++ b/fs/cifs/connect.c
31755 +@@ -103,7 +103,7 @@ enum {
31756 + Opt_cruid, Opt_gid, Opt_file_mode,
31757 + Opt_dirmode, Opt_port,
31758 + Opt_blocksize, Opt_rsize, Opt_wsize, Opt_actimeo,
31759 +- Opt_echo_interval, Opt_max_credits,
31760 ++ Opt_echo_interval, Opt_max_credits, Opt_handletimeout,
31761 + Opt_snapshot,
31762
31763 -- if ((unsigned int)type >= nr_swapfiles)
31764 -- return 0;
31765 -- if (!(swap_info[type]->flags & SWP_WRITEOK))
31766 -+ if (!si || !(si->flags & SWP_WRITEOK))
31767 - return 0;
31768 - return map_swap_entry(swp_entry(type, offset), &bdev);
31769 - }
31770 -@@ -2258,7 +2269,7 @@ static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
31771 - struct swap_extent *se;
31772 - pgoff_t offset;
31773 -
31774 -- sis = swap_info[swp_type(entry)];
31775 -+ sis = swp_swap_info(entry);
31776 - *bdev = sis->bdev;
31777 -
31778 - offset = swp_offset(entry);
31779 -@@ -2700,9 +2711,7 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
31780 - if (!l)
31781 - return SEQ_START_TOKEN;
31782 -
31783 -- for (type = 0; type < nr_swapfiles; type++) {
31784 -- smp_rmb(); /* read nr_swapfiles before swap_info[type] */
31785 -- si = swap_info[type];
31786 -+ for (type = 0; (si = swap_type_to_swap_info(type)); type++) {
31787 - if (!(si->flags & SWP_USED) || !si->swap_map)
31788 - continue;
31789 - if (!--l)
31790 -@@ -2722,9 +2731,7 @@ static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
31791 - else
31792 - type = si->type + 1;
31793 + /* Mount options which take string value */
31794 +@@ -208,6 +208,7 @@ static const match_table_t cifs_mount_option_tokens = {
31795 + { Opt_rsize, "rsize=%s" },
31796 + { Opt_wsize, "wsize=%s" },
31797 + { Opt_actimeo, "actimeo=%s" },
31798 ++ { Opt_handletimeout, "handletimeout=%s" },
31799 + { Opt_echo_interval, "echo_interval=%s" },
31800 + { Opt_max_credits, "max_credits=%s" },
31801 + { Opt_snapshot, "snapshot=%s" },
31802 +@@ -1600,6 +1601,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
31803
31804 -- for (; type < nr_swapfiles; type++) {
31805 -- smp_rmb(); /* read nr_swapfiles before swap_info[type] */
31806 -- si = swap_info[type];
31807 -+ for (; (si = swap_type_to_swap_info(type)); type++) {
31808 - if (!(si->flags & SWP_USED) || !si->swap_map)
31809 - continue;
31810 - ++*pos;
31811 -@@ -2831,14 +2838,14 @@ static struct swap_info_struct *alloc_swap_info(void)
31812 - }
31813 - if (type >= nr_swapfiles) {
31814 - p->type = type;
31815 -- swap_info[type] = p;
31816 -+ WRITE_ONCE(swap_info[type], p);
31817 - /*
31818 - * Write swap_info[type] before nr_swapfiles, in case a
31819 - * racing procfs swap_start() or swap_next() is reading them.
31820 - * (We never shrink nr_swapfiles, we never free this entry.)
31821 - */
31822 - smp_wmb();
31823 -- nr_swapfiles++;
31824 -+ WRITE_ONCE(nr_swapfiles, nr_swapfiles + 1);
31825 - } else {
31826 - kvfree(p);
31827 - p = swap_info[type];
31828 -@@ -3358,7 +3365,7 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
31829 - {
31830 - struct swap_info_struct *p;
31831 - struct swap_cluster_info *ci;
31832 -- unsigned long offset, type;
31833 -+ unsigned long offset;
31834 - unsigned char count;
31835 - unsigned char has_cache;
31836 - int err = -EINVAL;
31837 -@@ -3366,10 +3373,10 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
31838 - if (non_swap_entry(entry))
31839 - goto out;
31840 + vol->actimeo = CIFS_DEF_ACTIMEO;
31841
31842 -- type = swp_type(entry);
31843 -- if (type >= nr_swapfiles)
31844 -+ p = swp_swap_info(entry);
31845 -+ if (!p)
31846 - goto bad_file;
31847 -- p = swap_info[type];
31848 ++ /* Most clients set timeout to 0, allows server to use its default */
31849 ++ vol->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */
31850 +
31851 - offset = swp_offset(entry);
31852 - if (unlikely(offset >= p->max))
31853 - goto out;
31854 -@@ -3466,7 +3473,7 @@ int swapcache_prepare(swp_entry_t entry)
31855 -
31856 - struct swap_info_struct *swp_swap_info(swp_entry_t entry)
31857 - {
31858 -- return swap_info[swp_type(entry)];
31859 -+ return swap_type_to_swap_info(swp_type(entry));
31860 + /* offer SMB2.1 and later (SMB3 etc). Secure and widely accepted */
31861 + vol->ops = &smb30_operations;
31862 + vol->vals = &smbdefault_values;
31863 +@@ -1998,6 +2002,18 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
31864 + goto cifs_parse_mount_err;
31865 + }
31866 + break;
31867 ++ case Opt_handletimeout:
31868 ++ if (get_option_ul(args, &option)) {
31869 ++ cifs_dbg(VFS, "%s: Invalid handletimeout value\n",
31870 ++ __func__);
31871 ++ goto cifs_parse_mount_err;
31872 ++ }
31873 ++ vol->handle_timeout = option;
31874 ++ if (vol->handle_timeout > SMB3_MAX_HANDLE_TIMEOUT) {
31875 ++ cifs_dbg(VFS, "Invalid handle cache timeout, longer than 16 minutes\n");
31876 ++ goto cifs_parse_mount_err;
31877 ++ }
31878 ++ break;
31879 + case Opt_echo_interval:
31880 + if (get_option_ul(args, &option)) {
31881 + cifs_dbg(VFS, "%s: Invalid echo interval value\n",
31882 +@@ -3164,6 +3180,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info)
31883 + return 0;
31884 + if (tcon->snapshot_time != volume_info->snapshot_time)
31885 + return 0;
31886 ++ if (tcon->handle_timeout != volume_info->handle_timeout)
31887 ++ return 0;
31888 + return 1;
31889 }
31890
31891 - struct swap_info_struct *page_swap_info(struct page *page)
31892 -diff --git a/mm/vmalloc.c b/mm/vmalloc.c
31893 -index 871e41c55e23..583630bf247d 100644
31894 ---- a/mm/vmalloc.c
31895 -+++ b/mm/vmalloc.c
31896 -@@ -498,7 +498,11 @@ nocache:
31897 +@@ -3278,6 +3296,16 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
31898 + tcon->snapshot_time = volume_info->snapshot_time;
31899 }
31900
31901 - found:
31902 -- if (addr + size > vend)
31903 -+ /*
31904 -+ * Check also calculated address against the vstart,
31905 -+ * because it can be 0 because of big align request.
31906 -+ */
31907 -+ if (addr + size > vend || addr < vstart)
31908 - goto overflow;
31909 -
31910 - va->va_start = addr;
31911 -@@ -2248,7 +2252,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
31912 - if (!(area->flags & VM_USERMAP))
31913 - return -EINVAL;
31914 -
31915 -- if (kaddr + size > area->addr + area->size)
31916 -+ if (kaddr + size > area->addr + get_vm_area_size(area))
31917 - return -EINVAL;
31918 ++ if (volume_info->handle_timeout) {
31919 ++ if (ses->server->vals->protocol_id == 0) {
31920 ++ cifs_dbg(VFS,
31921 ++ "Use SMB2.1 or later for handle timeout option\n");
31922 ++ rc = -EOPNOTSUPP;
31923 ++ goto out_fail;
31924 ++ } else
31925 ++ tcon->handle_timeout = volume_info->handle_timeout;
31926 ++ }
31927 ++
31928 + tcon->ses = ses;
31929 + if (volume_info->password) {
31930 + tcon->password = kstrdup(volume_info->password, GFP_KERNEL);
31931 +diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
31932 +index b204e84b87fb..b0e76d27d752 100644
31933 +--- a/fs/cifs/smb2file.c
31934 ++++ b/fs/cifs/smb2file.c
31935 +@@ -68,7 +68,9 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
31936
31937 - do {
31938 -diff --git a/net/9p/client.c b/net/9p/client.c
31939 -index 357214a51f13..b85d51f4b8eb 100644
31940 ---- a/net/9p/client.c
31941 -+++ b/net/9p/client.c
31942 -@@ -1061,7 +1061,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
31943 - p9_debug(P9_DEBUG_ERROR,
31944 - "Please specify a msize of at least 4k\n");
31945 - err = -EINVAL;
31946 -- goto free_client;
31947 -+ goto close_trans;
31948 - }
31949
31950 - err = p9_client_version(clnt);
31951 -diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
31952 -index deacc52d7ff1..8d12198eaa94 100644
31953 ---- a/net/bluetooth/af_bluetooth.c
31954 -+++ b/net/bluetooth/af_bluetooth.c
31955 -@@ -154,15 +154,25 @@ void bt_sock_unlink(struct bt_sock_list *l, struct sock *sk)
31956 + if (oparms->tcon->use_resilient) {
31957 +- nr_ioctl_req.Timeout = 0; /* use server default (120 seconds) */
31958 ++ /* default timeout is 0, servers pick default (120 seconds) */
31959 ++ nr_ioctl_req.Timeout =
31960 ++ cpu_to_le32(oparms->tcon->handle_timeout);
31961 + nr_ioctl_req.Reserved = 0;
31962 + rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid,
31963 + fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY,
31964 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
31965 +index 53642a237bf9..068febe37fe4 100644
31966 +--- a/fs/cifs/smb2pdu.c
31967 ++++ b/fs/cifs/smb2pdu.c
31968 +@@ -1837,8 +1837,9 @@ add_lease_context(struct TCP_Server_Info *server, struct kvec *iov,
31969 }
31970 - EXPORT_SYMBOL(bt_sock_unlink);
31971
31972 --void bt_accept_enqueue(struct sock *parent, struct sock *sk)
31973 -+void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh)
31974 + static struct create_durable_v2 *
31975 +-create_durable_v2_buf(struct cifs_fid *pfid)
31976 ++create_durable_v2_buf(struct cifs_open_parms *oparms)
31977 {
31978 - BT_DBG("parent %p, sk %p", parent, sk);
31979 -
31980 - sock_hold(sk);
31981 -- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
31982 -+
31983 -+ if (bh)
31984 -+ bh_lock_sock_nested(sk);
31985 -+ else
31986 -+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
31987 -+
31988 - list_add_tail(&bt_sk(sk)->accept_q, &bt_sk(parent)->accept_q);
31989 - bt_sk(sk)->parent = parent;
31990 -- release_sock(sk);
31991 -+
31992 -+ if (bh)
31993 -+ bh_unlock_sock(sk);
31994 -+ else
31995 -+ release_sock(sk);
31996 -+
31997 - parent->sk_ack_backlog++;
31998 - }
31999 - EXPORT_SYMBOL(bt_accept_enqueue);
32000 -diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
32001 -index 1506e1632394..d4e2a166ae17 100644
32002 ---- a/net/bluetooth/hci_sock.c
32003 -+++ b/net/bluetooth/hci_sock.c
32004 -@@ -831,8 +831,6 @@ static int hci_sock_release(struct socket *sock)
32005 - if (!sk)
32006 - return 0;
32007 -
32008 -- hdev = hci_pi(sk)->hdev;
32009 --
32010 - switch (hci_pi(sk)->channel) {
32011 - case HCI_CHANNEL_MONITOR:
32012 - atomic_dec(&monitor_promisc);
32013 -@@ -854,6 +852,7 @@ static int hci_sock_release(struct socket *sock)
32014 -
32015 - bt_sock_unlink(&hci_sk_list, sk);
32016 -
32017 -+ hdev = hci_pi(sk)->hdev;
32018 - if (hdev) {
32019 - if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
32020 - /* When releasing a user channel exclusive access,
32021 -diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
32022 -index 2a7fb517d460..ccdc5c67d22a 100644
32023 ---- a/net/bluetooth/l2cap_core.c
32024 -+++ b/net/bluetooth/l2cap_core.c
32025 -@@ -3337,16 +3337,22 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
32026 -
32027 - while (len >= L2CAP_CONF_OPT_SIZE) {
32028 - len -= l2cap_get_conf_opt(&req, &type, &olen, &val);
32029 -+ if (len < 0)
32030 -+ break;
32031 -
32032 - hint = type & L2CAP_CONF_HINT;
32033 - type &= L2CAP_CONF_MASK;
32034 -
32035 - switch (type) {
32036 - case L2CAP_CONF_MTU:
32037 -+ if (olen != 2)
32038 -+ break;
32039 - mtu = val;
32040 - break;
32041 -
32042 - case L2CAP_CONF_FLUSH_TO:
32043 -+ if (olen != 2)
32044 -+ break;
32045 - chan->flush_to = val;
32046 - break;
32047 -
32048 -@@ -3354,26 +3360,30 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
32049 - break;
32050 -
32051 - case L2CAP_CONF_RFC:
32052 -- if (olen == sizeof(rfc))
32053 -- memcpy(&rfc, (void *) val, olen);
32054 -+ if (olen != sizeof(rfc))
32055 -+ break;
32056 -+ memcpy(&rfc, (void *) val, olen);
32057 - break;
32058 -
32059 - case L2CAP_CONF_FCS:
32060 -+ if (olen != 1)
32061 -+ break;
32062 - if (val == L2CAP_FCS_NONE)
32063 - set_bit(CONF_RECV_NO_FCS, &chan->conf_state);
32064 - break;
32065 -
32066 - case L2CAP_CONF_EFS:
32067 -- if (olen == sizeof(efs)) {
32068 -- remote_efs = 1;
32069 -- memcpy(&efs, (void *) val, olen);
32070 -- }
32071 -+ if (olen != sizeof(efs))
32072 -+ break;
32073 -+ remote_efs = 1;
32074 -+ memcpy(&efs, (void *) val, olen);
32075 - break;
32076 -
32077 - case L2CAP_CONF_EWS:
32078 -+ if (olen != 2)
32079 -+ break;
32080 - if (!(chan->conn->local_fixed_chan & L2CAP_FC_A2MP))
32081 - return -ECONNREFUSED;
32082 --
32083 - set_bit(FLAG_EXT_CTRL, &chan->flags);
32084 - set_bit(CONF_EWS_RECV, &chan->conf_state);
32085 - chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW;
32086 -@@ -3383,7 +3393,6 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
32087 - default:
32088 - if (hint)
32089 - break;
32090 --
32091 - result = L2CAP_CONF_UNKNOWN;
32092 - *((u8 *) ptr++) = type;
32093 - break;
32094 -@@ -3548,58 +3557,65 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
32095 ++ struct cifs_fid *pfid = oparms->fid;
32096 + struct create_durable_v2 *buf;
32097
32098 - while (len >= L2CAP_CONF_OPT_SIZE) {
32099 - len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val);
32100 -+ if (len < 0)
32101 -+ break;
32102 + buf = kzalloc(sizeof(struct create_durable_v2), GFP_KERNEL);
32103 +@@ -1852,7 +1853,14 @@ create_durable_v2_buf(struct cifs_fid *pfid)
32104 + (struct create_durable_v2, Name));
32105 + buf->ccontext.NameLength = cpu_to_le16(4);
32106
32107 - switch (type) {
32108 - case L2CAP_CONF_MTU:
32109 -+ if (olen != 2)
32110 -+ break;
32111 - if (val < L2CAP_DEFAULT_MIN_MTU) {
32112 - *result = L2CAP_CONF_UNACCEPT;
32113 - chan->imtu = L2CAP_DEFAULT_MIN_MTU;
32114 - } else
32115 - chan->imtu = val;
32116 -- l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu, endptr - ptr);
32117 -+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu,
32118 -+ endptr - ptr);
32119 - break;
32120 +- buf->dcontext.Timeout = 0; /* Should this be configurable by workload */
32121 ++ /*
32122 ++ * NB: Handle timeout defaults to 0, which allows server to choose
32123 ++ * (most servers default to 120 seconds) and most clients default to 0.
32124 ++ * This can be overridden at mount ("handletimeout=") if the user wants
32125 ++ * a different persistent (or resilient) handle timeout for all opens
32126 ++ * opens on a particular SMB3 mount.
32127 ++ */
32128 ++ buf->dcontext.Timeout = cpu_to_le32(oparms->tcon->handle_timeout);
32129 + buf->dcontext.Flags = cpu_to_le32(SMB2_DHANDLE_FLAG_PERSISTENT);
32130 + generate_random_uuid(buf->dcontext.CreateGuid);
32131 + memcpy(pfid->create_guid, buf->dcontext.CreateGuid, 16);
32132 +@@ -1905,7 +1913,7 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec,
32133 + struct smb2_create_req *req = iov[0].iov_base;
32134 + unsigned int num = *num_iovec;
32135
32136 - case L2CAP_CONF_FLUSH_TO:
32137 -+ if (olen != 2)
32138 -+ break;
32139 - chan->flush_to = val;
32140 -- l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO,
32141 -- 2, chan->flush_to, endptr - ptr);
32142 -+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, 2,
32143 -+ chan->flush_to, endptr - ptr);
32144 - break;
32145 +- iov[num].iov_base = create_durable_v2_buf(oparms->fid);
32146 ++ iov[num].iov_base = create_durable_v2_buf(oparms);
32147 + if (iov[num].iov_base == NULL)
32148 + return -ENOMEM;
32149 + iov[num].iov_len = sizeof(struct create_durable_v2);
32150 +diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
32151 +index 50fb0dee23e8..d35b8ec1c485 100644
32152 +--- a/include/linux/bitrev.h
32153 ++++ b/include/linux/bitrev.h
32154 +@@ -34,41 +34,41 @@ static inline u32 __bitrev32(u32 x)
32155
32156 - case L2CAP_CONF_RFC:
32157 -- if (olen == sizeof(rfc))
32158 -- memcpy(&rfc, (void *)val, olen);
32159 --
32160 -+ if (olen != sizeof(rfc))
32161 -+ break;
32162 -+ memcpy(&rfc, (void *)val, olen);
32163 - if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
32164 - rfc.mode != chan->mode)
32165 - return -ECONNREFUSED;
32166 --
32167 - chan->fcs = 0;
32168 --
32169 -- l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
32170 -- sizeof(rfc), (unsigned long) &rfc, endptr - ptr);
32171 -+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
32172 -+ (unsigned long) &rfc, endptr - ptr);
32173 - break;
32174 + #define __constant_bitrev32(x) \
32175 + ({ \
32176 +- u32 __x = x; \
32177 +- __x = (__x >> 16) | (__x << 16); \
32178 +- __x = ((__x & (u32)0xFF00FF00UL) >> 8) | ((__x & (u32)0x00FF00FFUL) << 8); \
32179 +- __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \
32180 +- __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \
32181 +- __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \
32182 +- __x; \
32183 ++ u32 ___x = x; \
32184 ++ ___x = (___x >> 16) | (___x << 16); \
32185 ++ ___x = ((___x & (u32)0xFF00FF00UL) >> 8) | ((___x & (u32)0x00FF00FFUL) << 8); \
32186 ++ ___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4); \
32187 ++ ___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2); \
32188 ++ ___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1); \
32189 ++ ___x; \
32190 + })
32191
32192 - case L2CAP_CONF_EWS:
32193 -+ if (olen != 2)
32194 -+ break;
32195 - chan->ack_win = min_t(u16, val, chan->ack_win);
32196 - l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2,
32197 - chan->tx_win, endptr - ptr);
32198 - break;
32199 + #define __constant_bitrev16(x) \
32200 + ({ \
32201 +- u16 __x = x; \
32202 +- __x = (__x >> 8) | (__x << 8); \
32203 +- __x = ((__x & (u16)0xF0F0U) >> 4) | ((__x & (u16)0x0F0FU) << 4); \
32204 +- __x = ((__x & (u16)0xCCCCU) >> 2) | ((__x & (u16)0x3333U) << 2); \
32205 +- __x = ((__x & (u16)0xAAAAU) >> 1) | ((__x & (u16)0x5555U) << 1); \
32206 +- __x; \
32207 ++ u16 ___x = x; \
32208 ++ ___x = (___x >> 8) | (___x << 8); \
32209 ++ ___x = ((___x & (u16)0xF0F0U) >> 4) | ((___x & (u16)0x0F0FU) << 4); \
32210 ++ ___x = ((___x & (u16)0xCCCCU) >> 2) | ((___x & (u16)0x3333U) << 2); \
32211 ++ ___x = ((___x & (u16)0xAAAAU) >> 1) | ((___x & (u16)0x5555U) << 1); \
32212 ++ ___x; \
32213 + })
32214
32215 - case L2CAP_CONF_EFS:
32216 -- if (olen == sizeof(efs)) {
32217 -- memcpy(&efs, (void *)val, olen);
32218 --
32219 -- if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
32220 -- efs.stype != L2CAP_SERV_NOTRAFIC &&
32221 -- efs.stype != chan->local_stype)
32222 -- return -ECONNREFUSED;
32223 --
32224 -- l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
32225 -- (unsigned long) &efs, endptr - ptr);
32226 -- }
32227 -+ if (olen != sizeof(efs))
32228 -+ break;
32229 -+ memcpy(&efs, (void *)val, olen);
32230 -+ if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
32231 -+ efs.stype != L2CAP_SERV_NOTRAFIC &&
32232 -+ efs.stype != chan->local_stype)
32233 -+ return -ECONNREFUSED;
32234 -+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
32235 -+ (unsigned long) &efs, endptr - ptr);
32236 - break;
32237 + #define __constant_bitrev8x4(x) \
32238 + ({ \
32239 +- u32 __x = x; \
32240 +- __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \
32241 +- __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \
32242 +- __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \
32243 +- __x; \
32244 ++ u32 ___x = x; \
32245 ++ ___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4); \
32246 ++ ___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2); \
32247 ++ ___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1); \
32248 ++ ___x; \
32249 + })
32250
32251 - case L2CAP_CONF_FCS:
32252 -+ if (olen != 1)
32253 -+ break;
32254 - if (*result == L2CAP_CONF_PENDING)
32255 - if (val == L2CAP_FCS_NONE)
32256 - set_bit(CONF_RECV_NO_FCS,
32257 -@@ -3728,13 +3744,18 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
32258 -
32259 - while (len >= L2CAP_CONF_OPT_SIZE) {
32260 - len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val);
32261 -+ if (len < 0)
32262 -+ break;
32263 + #define __constant_bitrev8(x) \
32264 + ({ \
32265 +- u8 __x = x; \
32266 +- __x = (__x >> 4) | (__x << 4); \
32267 +- __x = ((__x & (u8)0xCCU) >> 2) | ((__x & (u8)0x33U) << 2); \
32268 +- __x = ((__x & (u8)0xAAU) >> 1) | ((__x & (u8)0x55U) << 1); \
32269 +- __x; \
32270 ++ u8 ___x = x; \
32271 ++ ___x = (___x >> 4) | (___x << 4); \
32272 ++ ___x = ((___x & (u8)0xCCU) >> 2) | ((___x & (u8)0x33U) << 2); \
32273 ++ ___x = ((___x & (u8)0xAAU) >> 1) | ((___x & (u8)0x55U) << 1); \
32274 ++ ___x; \
32275 + })
32276
32277 - switch (type) {
32278 - case L2CAP_CONF_RFC:
32279 -- if (olen == sizeof(rfc))
32280 -- memcpy(&rfc, (void *)val, olen);
32281 -+ if (olen != sizeof(rfc))
32282 -+ break;
32283 -+ memcpy(&rfc, (void *)val, olen);
32284 - break;
32285 - case L2CAP_CONF_EWS:
32286 -+ if (olen != 2)
32287 -+ break;
32288 - txwin_ext = val;
32289 - break;
32290 - }
32291 -diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
32292 -index 686bdc6b35b0..a3a2cd55e23a 100644
32293 ---- a/net/bluetooth/l2cap_sock.c
32294 -+++ b/net/bluetooth/l2cap_sock.c
32295 -@@ -1252,7 +1252,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
32296 -
32297 - l2cap_sock_init(sk, parent);
32298 -
32299 -- bt_accept_enqueue(parent, sk);
32300 -+ bt_accept_enqueue(parent, sk, false);
32301 -
32302 - release_sock(parent);
32303 -
32304 -diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
32305 -index aa0db1d1bd9b..b1f49fcc0478 100644
32306 ---- a/net/bluetooth/rfcomm/sock.c
32307 -+++ b/net/bluetooth/rfcomm/sock.c
32308 -@@ -988,7 +988,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
32309 - rfcomm_pi(sk)->channel = channel;
32310 -
32311 - sk->sk_state = BT_CONFIG;
32312 -- bt_accept_enqueue(parent, sk);
32313 -+ bt_accept_enqueue(parent, sk, true);
32314 -
32315 - /* Accept connection and return socket DLC */
32316 - *d = rfcomm_pi(sk)->dlc;
32317 -diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
32318 -index 529b38996d8b..9a580999ca57 100644
32319 ---- a/net/bluetooth/sco.c
32320 -+++ b/net/bluetooth/sco.c
32321 -@@ -193,7 +193,7 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk,
32322 - conn->sk = sk;
32323 -
32324 - if (parent)
32325 -- bt_accept_enqueue(parent, sk);
32326 -+ bt_accept_enqueue(parent, sk, true);
32327 - }
32328 + #define bitrev32(x) \
32329 +diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
32330 +index 83ae11cbd12c..7391f5fe4eda 100644
32331 +--- a/include/linux/memcontrol.h
32332 ++++ b/include/linux/memcontrol.h
32333 +@@ -561,7 +561,10 @@ struct mem_cgroup *lock_page_memcg(struct page *page);
32334 + void __unlock_page_memcg(struct mem_cgroup *memcg);
32335 + void unlock_page_memcg(struct page *page);
32336
32337 - static int sco_chan_add(struct sco_conn *conn, struct sock *sk,
32338 -diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
32339 -index ac92b2eb32b1..e4777614a8a0 100644
32340 ---- a/net/bridge/br_multicast.c
32341 -+++ b/net/bridge/br_multicast.c
32342 -@@ -599,6 +599,7 @@ static int br_ip4_multicast_add_group(struct net_bridge *br,
32343 - if (ipv4_is_local_multicast(group))
32344 - return 0;
32345 +-/* idx can be of type enum memcg_stat_item or node_stat_item */
32346 ++/*
32347 ++ * idx can be of type enum memcg_stat_item or node_stat_item.
32348 ++ * Keep in sync with memcg_exact_page_state().
32349 ++ */
32350 + static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
32351 + int idx)
32352 + {
32353 +diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
32354 +index 54299251d40d..4f001619f854 100644
32355 +--- a/include/linux/mlx5/driver.h
32356 ++++ b/include/linux/mlx5/driver.h
32357 +@@ -591,6 +591,8 @@ enum mlx5_pagefault_type_flags {
32358 + };
32359
32360 -+ memset(&br_group, 0, sizeof(br_group));
32361 - br_group.u.ip4 = group;
32362 - br_group.proto = htons(ETH_P_IP);
32363 - br_group.vid = vid;
32364 -@@ -1489,6 +1490,7 @@ static void br_ip4_multicast_leave_group(struct net_bridge *br,
32365 + struct mlx5_td {
32366 ++ /* protects tirs list changes while tirs refresh */
32367 ++ struct mutex list_lock;
32368 + struct list_head tirs_list;
32369 + u32 tdn;
32370 + };
32371 +diff --git a/include/linux/string.h b/include/linux/string.h
32372 +index 7927b875f80c..6ab0a6fa512e 100644
32373 +--- a/include/linux/string.h
32374 ++++ b/include/linux/string.h
32375 +@@ -150,6 +150,9 @@ extern void * memscan(void *,int,__kernel_size_t);
32376 + #ifndef __HAVE_ARCH_MEMCMP
32377 + extern int memcmp(const void *,const void *,__kernel_size_t);
32378 + #endif
32379 ++#ifndef __HAVE_ARCH_BCMP
32380 ++extern int bcmp(const void *,const void *,__kernel_size_t);
32381 ++#endif
32382 + #ifndef __HAVE_ARCH_MEMCHR
32383 + extern void * memchr(const void *,int,__kernel_size_t);
32384 + #endif
32385 +diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
32386 +index fab02133a919..3dc70adfe5f5 100644
32387 +--- a/include/linux/virtio_ring.h
32388 ++++ b/include/linux/virtio_ring.h
32389 +@@ -63,7 +63,7 @@ struct virtqueue;
32390 + /*
32391 + * Creates a virtqueue and allocates the descriptor ring. If
32392 + * may_reduce_num is set, then this may allocate a smaller ring than
32393 +- * expected. The caller should query virtqueue_get_ring_size to learn
32394 ++ * expected. The caller should query virtqueue_get_vring_size to learn
32395 + * the actual size of the ring.
32396 + */
32397 + struct virtqueue *vring_create_virtqueue(unsigned int index,
32398 +diff --git a/include/net/ip.h b/include/net/ip.h
32399 +index be3cad9c2e4c..583526aad1d0 100644
32400 +--- a/include/net/ip.h
32401 ++++ b/include/net/ip.h
32402 +@@ -677,7 +677,7 @@ int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
32403 + unsigned char __user *data, int optlen);
32404 + void ip_options_undo(struct ip_options *opt);
32405 + void ip_forward_options(struct sk_buff *skb);
32406 +-int ip_options_rcv_srr(struct sk_buff *skb);
32407 ++int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev);
32408
32409 - own_query = port ? &port->ip4_own_query : &br->ip4_own_query;
32410 + /*
32411 + * Functions provided by ip_sockglue.c
32412 +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
32413 +index 99d4148e0f90..1c3126c14930 100644
32414 +--- a/include/net/net_namespace.h
32415 ++++ b/include/net/net_namespace.h
32416 +@@ -58,6 +58,7 @@ struct net {
32417 + */
32418 + spinlock_t rules_mod_lock;
32419
32420 -+ memset(&br_group, 0, sizeof(br_group));
32421 - br_group.u.ip4 = group;
32422 - br_group.proto = htons(ETH_P_IP);
32423 - br_group.vid = vid;
32424 -@@ -1512,6 +1514,7 @@ static void br_ip6_multicast_leave_group(struct net_bridge *br,
32425 ++ u32 hash_mix;
32426 + atomic64_t cookie_gen;
32427
32428 - own_query = port ? &port->ip6_own_query : &br->ip6_own_query;
32429 + struct list_head list; /* list of network namespaces */
32430 +diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
32431 +index 3d58acf94dd2..0612439909dc 100644
32432 +--- a/include/net/netfilter/nf_tables.h
32433 ++++ b/include/net/netfilter/nf_tables.h
32434 +@@ -691,10 +691,12 @@ static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
32435 + gcb->elems[gcb->head.cnt++] = elem;
32436 + }
32437
32438 -+ memset(&br_group, 0, sizeof(br_group));
32439 - br_group.u.ip6 = *group;
32440 - br_group.proto = htons(ETH_P_IPV6);
32441 - br_group.vid = vid;
32442 -diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
32443 -index c93c35bb73dd..40d058378b52 100644
32444 ---- a/net/bridge/br_netfilter_hooks.c
32445 -+++ b/net/bridge/br_netfilter_hooks.c
32446 -@@ -881,11 +881,6 @@ static const struct nf_br_ops br_ops = {
32447 - .br_dev_xmit_hook = br_nf_dev_xmit,
32448 - };
32449 ++struct nft_expr_ops;
32450 + /**
32451 + * struct nft_expr_type - nf_tables expression type
32452 + *
32453 + * @select_ops: function to select nft_expr_ops
32454 ++ * @release_ops: release nft_expr_ops
32455 + * @ops: default ops, used when no select_ops functions is present
32456 + * @list: used internally
32457 + * @name: Identifier
32458 +@@ -707,6 +709,7 @@ static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
32459 + struct nft_expr_type {
32460 + const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *,
32461 + const struct nlattr * const tb[]);
32462 ++ void (*release_ops)(const struct nft_expr_ops *ops);
32463 + const struct nft_expr_ops *ops;
32464 + struct list_head list;
32465 + const char *name;
32466 +diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h
32467 +index 16a842456189..d9b665151f3d 100644
32468 +--- a/include/net/netns/hash.h
32469 ++++ b/include/net/netns/hash.h
32470 +@@ -2,16 +2,10 @@
32471 + #ifndef __NET_NS_HASH_H__
32472 + #define __NET_NS_HASH_H__
32473
32474 --void br_netfilter_enable(void)
32475 --{
32476 --}
32477 --EXPORT_SYMBOL_GPL(br_netfilter_enable);
32478 --
32479 - /* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because
32480 - * br_dev_queue_push_xmit is called afterwards */
32481 - static const struct nf_hook_ops br_nf_ops[] = {
32482 -diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
32483 -index 6693e209efe8..f77888ec93f1 100644
32484 ---- a/net/bridge/netfilter/ebtables.c
32485 -+++ b/net/bridge/netfilter/ebtables.c
32486 -@@ -31,10 +31,6 @@
32487 - /* needed for logical [in,out]-dev filtering */
32488 - #include "../br_private.h"
32489 -
32490 --#define BUGPRINT(format, args...) printk("kernel msg: ebtables bug: please "\
32491 -- "report to author: "format, ## args)
32492 --/* #define BUGPRINT(format, args...) */
32493 +-#include <asm/cache.h>
32494 -
32495 - /* Each cpu has its own set of counters, so there is no need for write_lock in
32496 - * the softirq
32497 - * For reading or updating the counters, the user context needs to
32498 -@@ -466,8 +462,6 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
32499 - /* we make userspace set this right,
32500 - * so there is no misunderstanding
32501 - */
32502 -- BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set "
32503 -- "in distinguisher\n");
32504 - return -EINVAL;
32505 - }
32506 - if (i != NF_BR_NUMHOOKS)
32507 -@@ -485,18 +479,14 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
32508 - offset += e->next_offset;
32509 - }
32510 - }
32511 -- if (offset != limit) {
32512 -- BUGPRINT("entries_size too small\n");
32513 -+ if (offset != limit)
32514 - return -EINVAL;
32515 -- }
32516 +-struct net;
32517 ++#include <net/net_namespace.h>
32518
32519 - /* check if all valid hooks have a chain */
32520 - for (i = 0; i < NF_BR_NUMHOOKS; i++) {
32521 - if (!newinfo->hook_entry[i] &&
32522 -- (valid_hooks & (1 << i))) {
32523 -- BUGPRINT("Valid hook without chain\n");
32524 -+ (valid_hooks & (1 << i)))
32525 - return -EINVAL;
32526 -- }
32527 - }
32528 - return 0;
32529 + static inline u32 net_hash_mix(const struct net *net)
32530 + {
32531 +-#ifdef CONFIG_NET_NS
32532 +- return (u32)(((unsigned long)net) >> ilog2(sizeof(*net)));
32533 +-#else
32534 +- return 0;
32535 +-#endif
32536 ++ return net->hash_mix;
32537 }
32538 -@@ -523,26 +513,20 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
32539 - /* this checks if the previous chain has as many entries
32540 - * as it said it has
32541 - */
32542 -- if (*n != *cnt) {
32543 -- BUGPRINT("nentries does not equal the nr of entries "
32544 -- "in the chain\n");
32545 -+ if (*n != *cnt)
32546 - return -EINVAL;
32547 -- }
32548 -+
32549 - if (((struct ebt_entries *)e)->policy != EBT_DROP &&
32550 - ((struct ebt_entries *)e)->policy != EBT_ACCEPT) {
32551 - /* only RETURN from udc */
32552 - if (i != NF_BR_NUMHOOKS ||
32553 -- ((struct ebt_entries *)e)->policy != EBT_RETURN) {
32554 -- BUGPRINT("bad policy\n");
32555 -+ ((struct ebt_entries *)e)->policy != EBT_RETURN)
32556 - return -EINVAL;
32557 -- }
32558 - }
32559 - if (i == NF_BR_NUMHOOKS) /* it's a user defined chain */
32560 - (*udc_cnt)++;
32561 -- if (((struct ebt_entries *)e)->counter_offset != *totalcnt) {
32562 -- BUGPRINT("counter_offset != totalcnt");
32563 -+ if (((struct ebt_entries *)e)->counter_offset != *totalcnt)
32564 - return -EINVAL;
32565 -- }
32566 - *n = ((struct ebt_entries *)e)->nentries;
32567 - *cnt = 0;
32568 - return 0;
32569 -@@ -550,15 +534,13 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
32570 - /* a plain old entry, heh */
32571 - if (sizeof(struct ebt_entry) > e->watchers_offset ||
32572 - e->watchers_offset > e->target_offset ||
32573 -- e->target_offset >= e->next_offset) {
32574 -- BUGPRINT("entry offsets not in right order\n");
32575 -+ e->target_offset >= e->next_offset)
32576 - return -EINVAL;
32577 -- }
32578 + #endif
32579 +diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
32580 +index e960c4f46ee0..b07a2acc4eec 100644
32581 +--- a/kernel/irq/chip.c
32582 ++++ b/kernel/irq/chip.c
32583 +@@ -1384,6 +1384,10 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info)
32584 + int irq_chip_set_wake_parent(struct irq_data *data, unsigned int on)
32585 + {
32586 + data = data->parent_data;
32587 +
32588 - /* this is not checked anywhere else */
32589 -- if (e->next_offset - e->target_offset < sizeof(struct ebt_entry_target)) {
32590 -- BUGPRINT("target size too small\n");
32591 -+ if (e->next_offset - e->target_offset < sizeof(struct ebt_entry_target))
32592 - return -EINVAL;
32593 -- }
32594 ++ if (data->chip->flags & IRQCHIP_SKIP_SET_WAKE)
32595 ++ return 0;
32596 +
32597 - (*cnt)++;
32598 - (*totalcnt)++;
32599 - return 0;
32600 -@@ -678,18 +660,15 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
32601 - if (e->bitmask == 0)
32602 - return 0;
32603 + if (data->chip->irq_set_wake)
32604 + return data->chip->irq_set_wake(data, on);
32605
32606 -- if (e->bitmask & ~EBT_F_MASK) {
32607 -- BUGPRINT("Unknown flag for bitmask\n");
32608 -+ if (e->bitmask & ~EBT_F_MASK)
32609 - return -EINVAL;
32610 -- }
32611 -- if (e->invflags & ~EBT_INV_MASK) {
32612 -- BUGPRINT("Unknown flag for inv bitmask\n");
32613 -+
32614 -+ if (e->invflags & ~EBT_INV_MASK)
32615 - return -EINVAL;
32616 -- }
32617 -- if ((e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3)) {
32618 -- BUGPRINT("NOPROTO & 802_3 not allowed\n");
32619 -+
32620 -+ if ((e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3))
32621 - return -EINVAL;
32622 -- }
32623 -+
32624 - /* what hook do we belong to? */
32625 - for (i = 0; i < NF_BR_NUMHOOKS; i++) {
32626 - if (!newinfo->hook_entry[i])
32627 -@@ -748,13 +727,11 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
32628 - t->u.target = target;
32629 - if (t->u.target == &ebt_standard_target) {
32630 - if (gap < sizeof(struct ebt_standard_target)) {
32631 -- BUGPRINT("Standard target size too big\n");
32632 - ret = -EFAULT;
32633 - goto cleanup_watchers;
32634 - }
32635 - if (((struct ebt_standard_target *)t)->verdict <
32636 - -NUM_STANDARD_TARGETS) {
32637 -- BUGPRINT("Invalid standard target\n");
32638 - ret = -EFAULT;
32639 - goto cleanup_watchers;
32640 - }
32641 -@@ -813,10 +790,9 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
32642 - if (strcmp(t->u.name, EBT_STANDARD_TARGET))
32643 - goto letscontinue;
32644 - if (e->target_offset + sizeof(struct ebt_standard_target) >
32645 -- e->next_offset) {
32646 -- BUGPRINT("Standard target size too big\n");
32647 -+ e->next_offset)
32648 - return -1;
32649 -- }
32650 -+
32651 - verdict = ((struct ebt_standard_target *)t)->verdict;
32652 - if (verdict >= 0) { /* jump to another chain */
32653 - struct ebt_entries *hlp2 =
32654 -@@ -825,14 +801,12 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
32655 - if (hlp2 == cl_s[i].cs.chaininfo)
32656 - break;
32657 - /* bad destination or loop */
32658 -- if (i == udc_cnt) {
32659 -- BUGPRINT("bad destination\n");
32660 -+ if (i == udc_cnt)
32661 - return -1;
32662 -- }
32663 -- if (cl_s[i].cs.n) {
32664 -- BUGPRINT("loop\n");
32665 -+
32666 -+ if (cl_s[i].cs.n)
32667 - return -1;
32668 -- }
32669 -+
32670 - if (cl_s[i].hookmask & (1 << hooknr))
32671 - goto letscontinue;
32672 - /* this can't be 0, so the loop test is correct */
32673 -@@ -865,24 +839,21 @@ static int translate_table(struct net *net, const char *name,
32674 - i = 0;
32675 - while (i < NF_BR_NUMHOOKS && !newinfo->hook_entry[i])
32676 - i++;
32677 -- if (i == NF_BR_NUMHOOKS) {
32678 -- BUGPRINT("No valid hooks specified\n");
32679 -+ if (i == NF_BR_NUMHOOKS)
32680 - return -EINVAL;
32681 -- }
32682 -- if (newinfo->hook_entry[i] != (struct ebt_entries *)newinfo->entries) {
32683 -- BUGPRINT("Chains don't start at beginning\n");
32684 -+
32685 -+ if (newinfo->hook_entry[i] != (struct ebt_entries *)newinfo->entries)
32686 - return -EINVAL;
32687 -- }
32688 -+
32689 - /* make sure chains are ordered after each other in same order
32690 - * as their corresponding hooks
32691 - */
32692 - for (j = i + 1; j < NF_BR_NUMHOOKS; j++) {
32693 - if (!newinfo->hook_entry[j])
32694 - continue;
32695 -- if (newinfo->hook_entry[j] <= newinfo->hook_entry[i]) {
32696 -- BUGPRINT("Hook order must be followed\n");
32697 -+ if (newinfo->hook_entry[j] <= newinfo->hook_entry[i])
32698 - return -EINVAL;
32699 -- }
32700 -+
32701 - i = j;
32702 +diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
32703 +index 84fa255d0329..e16e022eae09 100644
32704 +--- a/kernel/irq/irqdesc.c
32705 ++++ b/kernel/irq/irqdesc.c
32706 +@@ -558,6 +558,7 @@ int __init early_irq_init(void)
32707 + alloc_masks(&desc[i], node);
32708 + raw_spin_lock_init(&desc[i].lock);
32709 + lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
32710 ++ mutex_init(&desc[i].request_mutex);
32711 + desc_set_defaults(i, &desc[i], node, NULL, NULL);
32712 }
32713 + return arch_early_irq_init();
32714 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
32715 +index 310d0637fe4b..5e61a1a99e38 100644
32716 +--- a/kernel/sched/fair.c
32717 ++++ b/kernel/sched/fair.c
32718 +@@ -7713,10 +7713,10 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq)
32719 + if (cfs_rq->last_h_load_update == now)
32720 + return;
32721
32722 -@@ -900,15 +871,11 @@ static int translate_table(struct net *net, const char *name,
32723 - if (ret != 0)
32724 - return ret;
32725 +- cfs_rq->h_load_next = NULL;
32726 ++ WRITE_ONCE(cfs_rq->h_load_next, NULL);
32727 + for_each_sched_entity(se) {
32728 + cfs_rq = cfs_rq_of(se);
32729 +- cfs_rq->h_load_next = se;
32730 ++ WRITE_ONCE(cfs_rq->h_load_next, se);
32731 + if (cfs_rq->last_h_load_update == now)
32732 + break;
32733 + }
32734 +@@ -7726,7 +7726,7 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq)
32735 + cfs_rq->last_h_load_update = now;
32736 + }
32737
32738 -- if (i != j) {
32739 -- BUGPRINT("nentries does not equal the nr of entries in the "
32740 -- "(last) chain\n");
32741 -+ if (i != j)
32742 - return -EINVAL;
32743 -- }
32744 -- if (k != newinfo->nentries) {
32745 -- BUGPRINT("Total nentries is wrong\n");
32746 -+
32747 -+ if (k != newinfo->nentries)
32748 - return -EINVAL;
32749 -- }
32750 +- while ((se = cfs_rq->h_load_next) != NULL) {
32751 ++ while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) {
32752 + load = cfs_rq->h_load;
32753 + load = div64_ul(load * se->avg.load_avg,
32754 + cfs_rq_load_avg(cfs_rq) + 1);
32755 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
32756 +index 2c97e8c2d29f..0519a8805aab 100644
32757 +--- a/kernel/time/alarmtimer.c
32758 ++++ b/kernel/time/alarmtimer.c
32759 +@@ -594,7 +594,7 @@ static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now)
32760 + {
32761 + struct alarm *alarm = &timr->it.alarm.alarmtimer;
32762
32763 - /* get the location of the udc, put them in an array
32764 - * while we're at it, allocate the chainstack
32765 -@@ -942,7 +909,6 @@ static int translate_table(struct net *net, const char *name,
32766 - ebt_get_udc_positions, newinfo, &i, cl_s);
32767 - /* sanity check */
32768 - if (i != udc_cnt) {
32769 -- BUGPRINT("i != udc_cnt\n");
32770 - vfree(cl_s);
32771 - return -EFAULT;
32772 - }
32773 -@@ -1042,7 +1008,6 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
32774 - goto free_unlock;
32775 +- return ktime_sub(now, alarm->node.expires);
32776 ++ return ktime_sub(alarm->node.expires, now);
32777 + }
32778 +
32779 + /**
32780 +diff --git a/lib/string.c b/lib/string.c
32781 +index 38e4ca08e757..3ab861c1a857 100644
32782 +--- a/lib/string.c
32783 ++++ b/lib/string.c
32784 +@@ -866,6 +866,26 @@ __visible int memcmp(const void *cs, const void *ct, size_t count)
32785 + EXPORT_SYMBOL(memcmp);
32786 + #endif
32787 +
32788 ++#ifndef __HAVE_ARCH_BCMP
32789 ++/**
32790 ++ * bcmp - returns 0 if and only if the buffers have identical contents.
32791 ++ * @a: pointer to first buffer.
32792 ++ * @b: pointer to second buffer.
32793 ++ * @len: size of buffers.
32794 ++ *
32795 ++ * The sign or magnitude of a non-zero return value has no particular
32796 ++ * meaning, and architectures may implement their own more efficient bcmp(). So
32797 ++ * while this particular implementation is a simple (tail) call to memcmp, do
32798 ++ * not rely on anything but whether the return value is zero or non-zero.
32799 ++ */
32800 ++#undef bcmp
32801 ++int bcmp(const void *a, const void *b, size_t len)
32802 ++{
32803 ++ return memcmp(a, b, len);
32804 ++}
32805 ++EXPORT_SYMBOL(bcmp);
32806 ++#endif
32807 ++
32808 + #ifndef __HAVE_ARCH_MEMSCAN
32809 + /**
32810 + * memscan - Find a character in an area of memory.
32811 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
32812 +index faf357eaf0ce..8b03c698f86e 100644
32813 +--- a/mm/huge_memory.c
32814 ++++ b/mm/huge_memory.c
32815 +@@ -753,6 +753,21 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
32816 + spinlock_t *ptl;
32817
32818 - if (repl->num_counters && repl->num_counters != t->private->nentries) {
32819 -- BUGPRINT("Wrong nr. of counters requested\n");
32820 - ret = -EINVAL;
32821 - goto free_unlock;
32822 + ptl = pmd_lock(mm, pmd);
32823 ++ if (!pmd_none(*pmd)) {
32824 ++ if (write) {
32825 ++ if (pmd_pfn(*pmd) != pfn_t_to_pfn(pfn)) {
32826 ++ WARN_ON_ONCE(!is_huge_zero_pmd(*pmd));
32827 ++ goto out_unlock;
32828 ++ }
32829 ++ entry = pmd_mkyoung(*pmd);
32830 ++ entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
32831 ++ if (pmdp_set_access_flags(vma, addr, pmd, entry, 1))
32832 ++ update_mmu_cache_pmd(vma, addr, pmd);
32833 ++ }
32834 ++
32835 ++ goto out_unlock;
32836 ++ }
32837 ++
32838 + entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
32839 + if (pfn_t_devmap(pfn))
32840 + entry = pmd_mkdevmap(entry);
32841 +@@ -764,11 +779,16 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
32842 + if (pgtable) {
32843 + pgtable_trans_huge_deposit(mm, pmd, pgtable);
32844 + mm_inc_nr_ptes(mm);
32845 ++ pgtable = NULL;
32846 }
32847 -@@ -1118,15 +1083,12 @@ static int do_replace(struct net *net, const void __user *user,
32848 - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
32849 - return -EFAULT;
32850 -
32851 -- if (len != sizeof(tmp) + tmp.entries_size) {
32852 -- BUGPRINT("Wrong len argument\n");
32853 -+ if (len != sizeof(tmp) + tmp.entries_size)
32854 - return -EINVAL;
32855 -- }
32856
32857 -- if (tmp.entries_size == 0) {
32858 -- BUGPRINT("Entries_size never zero\n");
32859 -+ if (tmp.entries_size == 0)
32860 - return -EINVAL;
32861 -- }
32862 + set_pmd_at(mm, addr, pmd, entry);
32863 + update_mmu_cache_pmd(vma, addr, pmd);
32864 +
32865 - /* overflow check */
32866 - if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) /
32867 - NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
32868 -@@ -1153,7 +1115,6 @@ static int do_replace(struct net *net, const void __user *user,
32869 - }
32870 - if (copy_from_user(
32871 - newinfo->entries, tmp.entries, tmp.entries_size) != 0) {
32872 -- BUGPRINT("Couldn't copy entries from userspace\n");
32873 - ret = -EFAULT;
32874 - goto free_entries;
32875 - }
32876 -@@ -1194,10 +1155,8 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
32877 -
32878 - if (input_table == NULL || (repl = input_table->table) == NULL ||
32879 - repl->entries == NULL || repl->entries_size == 0 ||
32880 -- repl->counters != NULL || input_table->private != NULL) {
32881 -- BUGPRINT("Bad table data for ebt_register_table!!!\n");
32882 -+ repl->counters != NULL || input_table->private != NULL)
32883 - return -EINVAL;
32884 -- }
32885 -
32886 - /* Don't add one table to multiple lists. */
32887 - table = kmemdup(input_table, sizeof(struct ebt_table), GFP_KERNEL);
32888 -@@ -1235,13 +1194,10 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
32889 - ((char *)repl->hook_entry[i] - repl->entries);
32890 - }
32891 - ret = translate_table(net, repl->name, newinfo);
32892 -- if (ret != 0) {
32893 -- BUGPRINT("Translate_table failed\n");
32894 -+ if (ret != 0)
32895 - goto free_chainstack;
32896 -- }
32897 ++out_unlock:
32898 + spin_unlock(ptl);
32899 ++ if (pgtable)
32900 ++ pte_free(mm, pgtable);
32901 + }
32902
32903 - if (table->check && table->check(newinfo, table->valid_hooks)) {
32904 -- BUGPRINT("The table doesn't like its own initial data, lol\n");
32905 - ret = -EINVAL;
32906 - goto free_chainstack;
32907 - }
32908 -@@ -1252,7 +1208,6 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
32909 - list_for_each_entry(t, &net->xt.tables[NFPROTO_BRIDGE], list) {
32910 - if (strcmp(t->name, table->name) == 0) {
32911 - ret = -EEXIST;
32912 -- BUGPRINT("Table name already exists\n");
32913 - goto free_unlock;
32914 - }
32915 - }
32916 -@@ -1320,7 +1275,6 @@ static int do_update_counters(struct net *net, const char *name,
32917 - goto free_tmp;
32918 + vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
32919 +@@ -819,6 +839,20 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr,
32920 + spinlock_t *ptl;
32921
32922 - if (num_counters != t->private->nentries) {
32923 -- BUGPRINT("Wrong nr of counters\n");
32924 - ret = -EINVAL;
32925 - goto unlock_mutex;
32926 + ptl = pud_lock(mm, pud);
32927 ++ if (!pud_none(*pud)) {
32928 ++ if (write) {
32929 ++ if (pud_pfn(*pud) != pfn_t_to_pfn(pfn)) {
32930 ++ WARN_ON_ONCE(!is_huge_zero_pud(*pud));
32931 ++ goto out_unlock;
32932 ++ }
32933 ++ entry = pud_mkyoung(*pud);
32934 ++ entry = maybe_pud_mkwrite(pud_mkdirty(entry), vma);
32935 ++ if (pudp_set_access_flags(vma, addr, pud, entry, 1))
32936 ++ update_mmu_cache_pud(vma, addr, pud);
32937 ++ }
32938 ++ goto out_unlock;
32939 ++ }
32940 ++
32941 + entry = pud_mkhuge(pfn_t_pud(pfn, prot));
32942 + if (pfn_t_devmap(pfn))
32943 + entry = pud_mkdevmap(entry);
32944 +@@ -828,6 +862,8 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr,
32945 }
32946 -@@ -1447,10 +1401,8 @@ static int copy_counters_to_user(struct ebt_table *t,
32947 - if (num_counters == 0)
32948 - return 0;
32949 -
32950 -- if (num_counters != nentries) {
32951 -- BUGPRINT("Num_counters wrong\n");
32952 -+ if (num_counters != nentries)
32953 - return -EINVAL;
32954 -- }
32955 -
32956 - counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp)));
32957 - if (!counterstmp)
32958 -@@ -1496,15 +1448,11 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
32959 - (tmp.num_counters ? nentries * sizeof(struct ebt_counter) : 0))
32960 - return -EINVAL;
32961 -
32962 -- if (tmp.nentries != nentries) {
32963 -- BUGPRINT("Nentries wrong\n");
32964 -+ if (tmp.nentries != nentries)
32965 - return -EINVAL;
32966 -- }
32967 -
32968 -- if (tmp.entries_size != entries_size) {
32969 -- BUGPRINT("Wrong size\n");
32970 -+ if (tmp.entries_size != entries_size)
32971 - return -EINVAL;
32972 -- }
32973 -
32974 - ret = copy_counters_to_user(t, oldcounters, tmp.counters,
32975 - tmp.num_counters, nentries);
32976 -@@ -1576,7 +1524,6 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
32977 - }
32978 - mutex_unlock(&ebt_mutex);
32979 - if (copy_to_user(user, &tmp, *len) != 0) {
32980 -- BUGPRINT("c2u Didn't work\n");
32981 - ret = -EFAULT;
32982 - break;
32983 - }
32984 -diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
32985 -index 9cab80207ced..79eac465ec65 100644
32986 ---- a/net/ceph/ceph_common.c
32987 -+++ b/net/ceph/ceph_common.c
32988 -@@ -738,7 +738,6 @@ int __ceph_open_session(struct ceph_client *client, unsigned long started)
32989 + set_pud_at(mm, addr, pud, entry);
32990 + update_mmu_cache_pud(vma, addr, pud);
32991 ++
32992 ++out_unlock:
32993 + spin_unlock(ptl);
32994 }
32995 - EXPORT_SYMBOL(__ceph_open_session);
32996
32997 --
32998 - int ceph_open_session(struct ceph_client *client)
32999 - {
33000 - int ret;
33001 -@@ -754,6 +753,23 @@ int ceph_open_session(struct ceph_client *client)
33002 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
33003 +index 79a7d2a06bba..5bbf2de02a0f 100644
33004 +--- a/mm/memcontrol.c
33005 ++++ b/mm/memcontrol.c
33006 +@@ -3882,6 +3882,22 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb)
33007 + return &memcg->cgwb_domain;
33008 }
33009 - EXPORT_SYMBOL(ceph_open_session);
33010
33011 -+int ceph_wait_for_latest_osdmap(struct ceph_client *client,
33012 -+ unsigned long timeout)
33013 ++/*
33014 ++ * idx can be of type enum memcg_stat_item or node_stat_item.
33015 ++ * Keep in sync with memcg_exact_page().
33016 ++ */
33017 ++static unsigned long memcg_exact_page_state(struct mem_cgroup *memcg, int idx)
33018 +{
33019 -+ u64 newest_epoch;
33020 -+ int ret;
33021 -+
33022 -+ ret = ceph_monc_get_version(&client->monc, "osdmap", &newest_epoch);
33023 -+ if (ret)
33024 -+ return ret;
33025 -+
33026 -+ if (client->osdc.osdmap->epoch >= newest_epoch)
33027 -+ return 0;
33028 ++ long x = atomic_long_read(&memcg->stat[idx]);
33029 ++ int cpu;
33030 +
33031 -+ ceph_osdc_maybe_request_map(&client->osdc);
33032 -+ return ceph_monc_wait_osdmap(&client->monc, newest_epoch, timeout);
33033 ++ for_each_online_cpu(cpu)
33034 ++ x += per_cpu_ptr(memcg->stat_cpu, cpu)->count[idx];
33035 ++ if (x < 0)
33036 ++ x = 0;
33037 ++ return x;
33038 +}
33039 -+EXPORT_SYMBOL(ceph_wait_for_latest_osdmap);
33040 -
33041 - static int __init init_ceph_lib(void)
33042 - {
33043 -diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
33044 -index 18deb3d889c4..a53e4fbb6319 100644
33045 ---- a/net/ceph/mon_client.c
33046 -+++ b/net/ceph/mon_client.c
33047 -@@ -922,6 +922,15 @@ int ceph_monc_blacklist_add(struct ceph_mon_client *monc,
33048 - mutex_unlock(&monc->mutex);
33049 -
33050 - ret = wait_generic_request(req);
33051 -+ if (!ret)
33052 -+ /*
33053 -+ * Make sure we have the osdmap that includes the blacklist
33054 -+ * entry. This is needed to ensure that the OSDs pick up the
33055 -+ * new blacklist before processing any future requests from
33056 -+ * this client.
33057 -+ */
33058 -+ ret = ceph_wait_for_latest_osdmap(monc->client, 0);
33059 +
33060 - out:
33061 - put_generic_request(req);
33062 - return ret;
33063 -diff --git a/net/core/datagram.c b/net/core/datagram.c
33064 -index b2651bb6d2a3..e657289db4ac 100644
33065 ---- a/net/core/datagram.c
33066 -+++ b/net/core/datagram.c
33067 -@@ -279,7 +279,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
33068 - break;
33069 + /**
33070 + * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
33071 + * @wb: bdi_writeback in question
33072 +@@ -3907,10 +3923,10 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
33073 + struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
33074 + struct mem_cgroup *parent;
33075 +
33076 +- *pdirty = memcg_page_state(memcg, NR_FILE_DIRTY);
33077 ++ *pdirty = memcg_exact_page_state(memcg, NR_FILE_DIRTY);
33078 +
33079 + /* this should eventually include NR_UNSTABLE_NFS */
33080 +- *pwriteback = memcg_page_state(memcg, NR_WRITEBACK);
33081 ++ *pwriteback = memcg_exact_page_state(memcg, NR_WRITEBACK);
33082 + *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
33083 + (1 << LRU_ACTIVE_FILE));
33084 + *pheadroom = PAGE_COUNTER_MAX;
33085 +diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
33086 +index ac92b2eb32b1..e4777614a8a0 100644
33087 +--- a/net/bridge/br_multicast.c
33088 ++++ b/net/bridge/br_multicast.c
33089 +@@ -599,6 +599,7 @@ static int br_ip4_multicast_add_group(struct net_bridge *br,
33090 + if (ipv4_is_local_multicast(group))
33091 + return 0;
33092 +
33093 ++ memset(&br_group, 0, sizeof(br_group));
33094 + br_group.u.ip4 = group;
33095 + br_group.proto = htons(ETH_P_IP);
33096 + br_group.vid = vid;
33097 +@@ -1489,6 +1490,7 @@ static void br_ip4_multicast_leave_group(struct net_bridge *br,
33098 +
33099 + own_query = port ? &port->ip4_own_query : &br->ip4_own_query;
33100
33101 - sk_busy_loop(sk, flags & MSG_DONTWAIT);
33102 -- } while (!skb_queue_empty(&sk->sk_receive_queue));
33103 -+ } while (sk->sk_receive_queue.prev != *last);
33104 ++ memset(&br_group, 0, sizeof(br_group));
33105 + br_group.u.ip4 = group;
33106 + br_group.proto = htons(ETH_P_IP);
33107 + br_group.vid = vid;
33108 +@@ -1512,6 +1514,7 @@ static void br_ip6_multicast_leave_group(struct net_bridge *br,
33109
33110 - error = -EAGAIN;
33111 + own_query = port ? &port->ip6_own_query : &br->ip6_own_query;
33112
33113 ++ memset(&br_group, 0, sizeof(br_group));
33114 + br_group.u.ip6 = *group;
33115 + br_group.proto = htons(ETH_P_IPV6);
33116 + br_group.vid = vid;
33117 diff --git a/net/core/dev.c b/net/core/dev.c
33118 index 5d03889502eb..12824e007e06 100644
33119 --- a/net/core/dev.c
33120 @@ -30959,119 +3787,6 @@ index 158264f7cfaf..3a7f19a61768 100644
33121 }
33122
33123 ret = -EFAULT;
33124 -diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
33125 -index 9bf1b9ad1780..ac679f74ba47 100644
33126 ---- a/net/core/gen_stats.c
33127 -+++ b/net/core/gen_stats.c
33128 -@@ -291,7 +291,6 @@ __gnet_stats_copy_queue_cpu(struct gnet_stats_queue *qstats,
33129 - for_each_possible_cpu(i) {
33130 - const struct gnet_stats_queue *qcpu = per_cpu_ptr(q, i);
33131 -
33132 -- qstats->qlen = 0;
33133 - qstats->backlog += qcpu->backlog;
33134 - qstats->drops += qcpu->drops;
33135 - qstats->requeues += qcpu->requeues;
33136 -@@ -307,7 +306,6 @@ void __gnet_stats_copy_queue(struct gnet_stats_queue *qstats,
33137 - if (cpu) {
33138 - __gnet_stats_copy_queue_cpu(qstats, cpu);
33139 - } else {
33140 -- qstats->qlen = q->qlen;
33141 - qstats->backlog = q->backlog;
33142 - qstats->drops = q->drops;
33143 - qstats->requeues = q->requeues;
33144 -diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
33145 -index acf45ddbe924..e095fb871d91 100644
33146 ---- a/net/core/gro_cells.c
33147 -+++ b/net/core/gro_cells.c
33148 -@@ -13,22 +13,36 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
33149 - {
33150 - struct net_device *dev = skb->dev;
33151 - struct gro_cell *cell;
33152 -+ int res;
33153 -
33154 -- if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev))
33155 -- return netif_rx(skb);
33156 -+ rcu_read_lock();
33157 -+ if (unlikely(!(dev->flags & IFF_UP)))
33158 -+ goto drop;
33159 -+
33160 -+ if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
33161 -+ res = netif_rx(skb);
33162 -+ goto unlock;
33163 -+ }
33164 -
33165 - cell = this_cpu_ptr(gcells->cells);
33166 -
33167 - if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
33168 -+drop:
33169 - atomic_long_inc(&dev->rx_dropped);
33170 - kfree_skb(skb);
33171 -- return NET_RX_DROP;
33172 -+ res = NET_RX_DROP;
33173 -+ goto unlock;
33174 - }
33175 -
33176 - __skb_queue_tail(&cell->napi_skbs, skb);
33177 - if (skb_queue_len(&cell->napi_skbs) == 1)
33178 - napi_schedule(&cell->napi);
33179 -- return NET_RX_SUCCESS;
33180 -+
33181 -+ res = NET_RX_SUCCESS;
33182 -+
33183 -+unlock:
33184 -+ rcu_read_unlock();
33185 -+ return res;
33186 - }
33187 - EXPORT_SYMBOL(gro_cells_receive);
33188 -
33189 -diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
33190 -index ff9fd2bb4ce4..aec26584f0ca 100644
33191 ---- a/net/core/net-sysfs.c
33192 -+++ b/net/core/net-sysfs.c
33193 -@@ -934,6 +934,8 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
33194 - if (error)
33195 - return error;
33196 -
33197 -+ dev_hold(queue->dev);
33198 -+
33199 - if (dev->sysfs_rx_queue_group) {
33200 - error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group);
33201 - if (error) {
33202 -@@ -943,7 +945,6 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
33203 - }
33204 -
33205 - kobject_uevent(kobj, KOBJ_ADD);
33206 -- dev_hold(queue->dev);
33207 -
33208 - return error;
33209 - }
33210 -@@ -1472,6 +1473,8 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
33211 - if (error)
33212 - return error;
33213 -
33214 -+ dev_hold(queue->dev);
33215 -+
33216 - #ifdef CONFIG_BQL
33217 - error = sysfs_create_group(kobj, &dql_group);
33218 - if (error) {
33219 -@@ -1481,7 +1484,6 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
33220 - #endif
33221 -
33222 - kobject_uevent(kobj, KOBJ_ADD);
33223 -- dev_hold(queue->dev);
33224 -
33225 - return 0;
33226 - }
33227 -@@ -1547,6 +1549,9 @@ static int register_queue_kobjects(struct net_device *dev)
33228 - error:
33229 - netdev_queue_update_kobjects(dev, txq, 0);
33230 - net_rx_queue_update_kobjects(dev, rxq, 0);
33231 -+#ifdef CONFIG_SYSFS
33232 -+ kset_unregister(dev->queues_kset);
33233 -+#endif
33234 - return error;
33235 - }
33236 -
33237 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
33238 index b02fb19df2cc..40c249c574c1 100644
33239 --- a/net/core/net_namespace.c
33240 @@ -31097,154 +3812,6 @@ index 2415d9cb9b89..ef2cd5712098 100644
33241 return -E2BIG;
33242
33243 lp = NAPI_GRO_CB(p)->last;
33244 -diff --git a/net/core/skmsg.c b/net/core/skmsg.c
33245 -index 8c826603bf36..8bc0ba1ebabe 100644
33246 ---- a/net/core/skmsg.c
33247 -+++ b/net/core/skmsg.c
33248 -@@ -545,6 +545,7 @@ static void sk_psock_destroy_deferred(struct work_struct *gc)
33249 - struct sk_psock *psock = container_of(gc, struct sk_psock, gc);
33250 -
33251 - /* No sk_callback_lock since already detached. */
33252 -+ strp_stop(&psock->parser.strp);
33253 - strp_done(&psock->parser.strp);
33254 -
33255 - cancel_work_sync(&psock->work);
33256 -diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
33257 -index d5740bad5b18..57d84e9b7b6f 100644
33258 ---- a/net/dccp/ipv6.c
33259 -+++ b/net/dccp/ipv6.c
33260 -@@ -436,8 +436,8 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,
33261 - newnp->ipv6_mc_list = NULL;
33262 - newnp->ipv6_ac_list = NULL;
33263 - newnp->ipv6_fl_list = NULL;
33264 -- newnp->mcast_oif = inet6_iif(skb);
33265 -- newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
33266 -+ newnp->mcast_oif = inet_iif(skb);
33267 -+ newnp->mcast_hops = ip_hdr(skb)->ttl;
33268 -
33269 - /*
33270 - * No need to charge this sock to the relevant IPv6 refcnt debug socks count
33271 -diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
33272 -index b8cd43c9ed5b..a97bf326b231 100644
33273 ---- a/net/hsr/hsr_device.c
33274 -+++ b/net/hsr/hsr_device.c
33275 -@@ -94,9 +94,8 @@ static void hsr_check_announce(struct net_device *hsr_dev,
33276 - && (old_operstate != IF_OPER_UP)) {
33277 - /* Went up */
33278 - hsr->announce_count = 0;
33279 -- hsr->announce_timer.expires = jiffies +
33280 -- msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL);
33281 -- add_timer(&hsr->announce_timer);
33282 -+ mod_timer(&hsr->announce_timer,
33283 -+ jiffies + msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL));
33284 - }
33285 -
33286 - if ((hsr_dev->operstate != IF_OPER_UP) && (old_operstate == IF_OPER_UP))
33287 -@@ -332,6 +331,7 @@ static void hsr_announce(struct timer_list *t)
33288 - {
33289 - struct hsr_priv *hsr;
33290 - struct hsr_port *master;
33291 -+ unsigned long interval;
33292 -
33293 - hsr = from_timer(hsr, t, announce_timer);
33294 -
33295 -@@ -343,18 +343,16 @@ static void hsr_announce(struct timer_list *t)
33296 - hsr->protVersion);
33297 - hsr->announce_count++;
33298 -
33299 -- hsr->announce_timer.expires = jiffies +
33300 -- msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL);
33301 -+ interval = msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL);
33302 - } else {
33303 - send_hsr_supervision_frame(master, HSR_TLV_LIFE_CHECK,
33304 - hsr->protVersion);
33305 -
33306 -- hsr->announce_timer.expires = jiffies +
33307 -- msecs_to_jiffies(HSR_LIFE_CHECK_INTERVAL);
33308 -+ interval = msecs_to_jiffies(HSR_LIFE_CHECK_INTERVAL);
33309 - }
33310 -
33311 - if (is_admin_up(master->dev))
33312 -- add_timer(&hsr->announce_timer);
33313 -+ mod_timer(&hsr->announce_timer, jiffies + interval);
33314 -
33315 - rcu_read_unlock();
33316 - }
33317 -@@ -486,7 +484,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
33318 -
33319 - res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER);
33320 - if (res)
33321 -- return res;
33322 -+ goto err_add_port;
33323 -
33324 - res = register_netdevice(hsr_dev);
33325 - if (res)
33326 -@@ -506,6 +504,8 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
33327 - fail:
33328 - hsr_for_each_port(hsr, port)
33329 - hsr_del_port(port);
33330 -+err_add_port:
33331 -+ hsr_del_node(&hsr->self_node_db);
33332 -
33333 - return res;
33334 - }
33335 -diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
33336 -index 286ceb41ac0c..9af16cb68f76 100644
33337 ---- a/net/hsr/hsr_framereg.c
33338 -+++ b/net/hsr/hsr_framereg.c
33339 -@@ -124,6 +124,18 @@ int hsr_create_self_node(struct list_head *self_node_db,
33340 - return 0;
33341 - }
33342 -
33343 -+void hsr_del_node(struct list_head *self_node_db)
33344 -+{
33345 -+ struct hsr_node *node;
33346 -+
33347 -+ rcu_read_lock();
33348 -+ node = list_first_or_null_rcu(self_node_db, struct hsr_node, mac_list);
33349 -+ rcu_read_unlock();
33350 -+ if (node) {
33351 -+ list_del_rcu(&node->mac_list);
33352 -+ kfree(node);
33353 -+ }
33354 -+}
33355 -
33356 - /* Allocate an hsr_node and add it to node_db. 'addr' is the node's AddressA;
33357 - * seq_out is used to initialize filtering of outgoing duplicate frames
33358 -diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
33359 -index 370b45998121..531fd3dfcac1 100644
33360 ---- a/net/hsr/hsr_framereg.h
33361 -+++ b/net/hsr/hsr_framereg.h
33362 -@@ -16,6 +16,7 @@
33363 -
33364 - struct hsr_node;
33365 -
33366 -+void hsr_del_node(struct list_head *self_node_db);
33367 - struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],
33368 - u16 seq_out);
33369 - struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
33370 -diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
33371 -index 437070d1ffb1..79e98e21cdd7 100644
33372 ---- a/net/ipv4/fou.c
33373 -+++ b/net/ipv4/fou.c
33374 -@@ -1024,7 +1024,7 @@ static int gue_err(struct sk_buff *skb, u32 info)
33375 - int ret;
33376 -
33377 - len = sizeof(struct udphdr) + sizeof(struct guehdr);
33378 -- if (!pskb_may_pull(skb, len))
33379 -+ if (!pskb_may_pull(skb, transport_offset + len))
33380 - return -EINVAL;
33381 -
33382 - guehdr = (struct guehdr *)&udp_hdr(skb)[1];
33383 -@@ -1059,7 +1059,7 @@ static int gue_err(struct sk_buff *skb, u32 info)
33384 -
33385 - optlen = guehdr->hlen << 2;
33386 -
33387 -- if (!pskb_may_pull(skb, len + optlen))
33388 -+ if (!pskb_may_pull(skb, transport_offset + len + optlen))
33389 - return -EINVAL;
33390 -
33391 - guehdr = (struct guehdr *)&udp_hdr(skb)[1];
33392 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
33393 index 6ae89f2b541b..2d5734079e6b 100644
33394 --- a/net/ipv4/ip_gre.c
33395 @@ -31350,73 +3917,6 @@ index 32a35043c9f5..3db31bb9df50 100644
33396 rt2 = skb_rtable(skb);
33397 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
33398 skb_dst_drop(skb);
33399 -diff --git a/net/ipv4/route.c b/net/ipv4/route.c
33400 -index 7bb9128c8363..e04cdb58a602 100644
33401 ---- a/net/ipv4/route.c
33402 -+++ b/net/ipv4/route.c
33403 -@@ -1303,6 +1303,10 @@ static void ip_del_fnhe(struct fib_nh *nh, __be32 daddr)
33404 - if (fnhe->fnhe_daddr == daddr) {
33405 - rcu_assign_pointer(*fnhe_p, rcu_dereference_protected(
33406 - fnhe->fnhe_next, lockdep_is_held(&fnhe_lock)));
33407 -+ /* set fnhe_daddr to 0 to ensure it won't bind with
33408 -+ * new dsts in rt_bind_exception().
33409 -+ */
33410 -+ fnhe->fnhe_daddr = 0;
33411 - fnhe_flush_routes(fnhe);
33412 - kfree_rcu(fnhe, rcu);
33413 - break;
33414 -@@ -2144,12 +2148,13 @@ int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
33415 - int our = 0;
33416 - int err = -EINVAL;
33417 -
33418 -- if (in_dev)
33419 -- our = ip_check_mc_rcu(in_dev, daddr, saddr,
33420 -- ip_hdr(skb)->protocol);
33421 -+ if (!in_dev)
33422 -+ return err;
33423 -+ our = ip_check_mc_rcu(in_dev, daddr, saddr,
33424 -+ ip_hdr(skb)->protocol);
33425 -
33426 - /* check l3 master if no match yet */
33427 -- if ((!in_dev || !our) && netif_is_l3_slave(dev)) {
33428 -+ if (!our && netif_is_l3_slave(dev)) {
33429 - struct in_device *l3_in_dev;
33430 -
33431 - l3_in_dev = __in_dev_get_rcu(skb->dev);
33432 -diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
33433 -index 606f868d9f3f..e531344611a0 100644
33434 ---- a/net/ipv4/syncookies.c
33435 -+++ b/net/ipv4/syncookies.c
33436 -@@ -216,7 +216,12 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,
33437 - refcount_set(&req->rsk_refcnt, 1);
33438 - tcp_sk(child)->tsoffset = tsoff;
33439 - sock_rps_save_rxhash(child, skb);
33440 -- inet_csk_reqsk_queue_add(sk, req, child);
33441 -+ if (!inet_csk_reqsk_queue_add(sk, req, child)) {
33442 -+ bh_unlock_sock(child);
33443 -+ sock_put(child);
33444 -+ child = NULL;
33445 -+ reqsk_put(req);
33446 -+ }
33447 - } else {
33448 - reqsk_free(req);
33449 - }
33450 -diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
33451 -index cf3c5095c10e..ce365cbba1d1 100644
33452 ---- a/net/ipv4/tcp.c
33453 -+++ b/net/ipv4/tcp.c
33454 -@@ -1914,6 +1914,11 @@ static int tcp_inq_hint(struct sock *sk)
33455 - inq = tp->rcv_nxt - tp->copied_seq;
33456 - release_sock(sk);
33457 - }
33458 -+ /* After receiving a FIN, tell the user-space to continue reading
33459 -+ * by returning a non-zero inq.
33460 -+ */
33461 -+ if (inq == 0 && sock_flag(sk, SOCK_DONE))
33462 -+ inq = 1;
33463 - return inq;
33464 - }
33465 -
33466 diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
33467 index cd4814f7e962..359da68d7c06 100644
33468 --- a/net/ipv4/tcp_dctcp.c
33469 @@ -31480,47 +3980,11 @@ index cd4814f7e962..359da68d7c06 100644
33470 default:
33471 /* Don't care for the rest. */
33472 break;
33473 -diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
33474 -index 76858b14ebe9..7b1ef897b398 100644
33475 ---- a/net/ipv4/tcp_input.c
33476 -+++ b/net/ipv4/tcp_input.c
33477 -@@ -6519,7 +6519,13 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
33478 - af_ops->send_synack(fastopen_sk, dst, &fl, req,
33479 - &foc, TCP_SYNACK_FASTOPEN);
33480 - /* Add the child socket directly into the accept queue */
33481 -- inet_csk_reqsk_queue_add(sk, req, fastopen_sk);
33482 -+ if (!inet_csk_reqsk_queue_add(sk, req, fastopen_sk)) {
33483 -+ reqsk_fastopen_remove(fastopen_sk, req, false);
33484 -+ bh_unlock_sock(fastopen_sk);
33485 -+ sock_put(fastopen_sk);
33486 -+ reqsk_put(req);
33487 -+ goto drop;
33488 -+ }
33489 - sk->sk_data_ready(sk);
33490 - bh_unlock_sock(fastopen_sk);
33491 - sock_put(fastopen_sk);
33492 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
33493 -index ec3cea9d6828..00852f47a73d 100644
33494 +index 1aae9ab57fe9..00852f47a73d 100644
33495 --- a/net/ipv4/tcp_ipv4.c
33496 +++ b/net/ipv4/tcp_ipv4.c
33497 -@@ -1734,15 +1734,8 @@ EXPORT_SYMBOL(tcp_add_backlog);
33498 - int tcp_filter(struct sock *sk, struct sk_buff *skb)
33499 - {
33500 - struct tcphdr *th = (struct tcphdr *)skb->data;
33501 -- unsigned int eaten = skb->len;
33502 -- int err;
33503 -
33504 -- err = sk_filter_trim_cap(sk, skb, th->doff * 4);
33505 -- if (!err) {
33506 -- eaten -= skb->len;
33507 -- TCP_SKB_CB(skb)->end_seq -= eaten;
33508 -- }
33509 -- return err;
33510 -+ return sk_filter_trim_cap(sk, skb, th->doff * 4);
33511 - }
33512 - EXPORT_SYMBOL(tcp_filter);
33513 -
33514 -@@ -2585,7 +2578,8 @@ static void __net_exit tcp_sk_exit(struct net *net)
33515 +@@ -2578,7 +2578,8 @@ static void __net_exit tcp_sk_exit(struct net *net)
33516 {
33517 int cpu;
33518
33519 @@ -31530,40 +3994,6 @@ index ec3cea9d6828..00852f47a73d 100644
33520
33521 for_each_possible_cpu(cpu)
33522 inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.tcp_sk, cpu));
33523 -diff --git a/net/ipv6/fou6.c b/net/ipv6/fou6.c
33524 -index 867474abe269..ec4e2ed95f36 100644
33525 ---- a/net/ipv6/fou6.c
33526 -+++ b/net/ipv6/fou6.c
33527 -@@ -94,7 +94,7 @@ static int gue6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
33528 - int ret;
33529 -
33530 - len = sizeof(struct udphdr) + sizeof(struct guehdr);
33531 -- if (!pskb_may_pull(skb, len))
33532 -+ if (!pskb_may_pull(skb, transport_offset + len))
33533 - return -EINVAL;
33534 -
33535 - guehdr = (struct guehdr *)&udp_hdr(skb)[1];
33536 -@@ -129,7 +129,7 @@ static int gue6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
33537 -
33538 - optlen = guehdr->hlen << 2;
33539 -
33540 -- if (!pskb_may_pull(skb, len + optlen))
33541 -+ if (!pskb_may_pull(skb, transport_offset + len + optlen))
33542 - return -EINVAL;
33543 -
33544 - guehdr = (struct guehdr *)&udp_hdr(skb)[1];
33545 -diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
33546 -index 17c455ff69ff..7858fa9ea103 100644
33547 ---- a/net/ipv6/ila/ila_xlat.c
33548 -+++ b/net/ipv6/ila/ila_xlat.c
33549 -@@ -420,6 +420,7 @@ int ila_xlat_nl_cmd_flush(struct sk_buff *skb, struct genl_info *info)
33550 -
33551 - done:
33552 - rhashtable_walk_stop(&iter);
33553 -+ rhashtable_walk_exit(&iter);
33554 - return ret;
33555 - }
33556 -
33557 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
33558 index 26f25b6e2833..438f1a5fd19a 100644
33559 --- a/net/ipv6/ip6_gre.c
33560 @@ -31666,79 +4096,20 @@ index 0c6403cf8b52..ade1390c6348 100644
33561 IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
33562 - if (IS_ERR(rt) || rt->dst.dev->type != ARPHRD_TUNNEL) {
33563 + if (IS_ERR(rt) || rt->dst.dev->type != ARPHRD_TUNNEL6) {
33564 - if (!IS_ERR(rt))
33565 - ip_rt_put(rt);
33566 - goto out;
33567 -@@ -636,7 +636,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
33568 - } else {
33569 - if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos,
33570 - skb2->dev) ||
33571 -- skb_dst(skb2)->dev->type != ARPHRD_TUNNEL)
33572 -+ skb_dst(skb2)->dev->type != ARPHRD_TUNNEL6)
33573 - goto out;
33574 - }
33575 -
33576 -diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
33577 -index cc01aa3f2b5e..af91a1a402f1 100644
33578 ---- a/net/ipv6/ip6mr.c
33579 -+++ b/net/ipv6/ip6mr.c
33580 -@@ -1964,10 +1964,10 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
33581 -
33582 - static inline int ip6mr_forward2_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
33583 - {
33584 -- __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
33585 -- IPSTATS_MIB_OUTFORWDATAGRAMS);
33586 -- __IP6_ADD_STATS(net, ip6_dst_idev(skb_dst(skb)),
33587 -- IPSTATS_MIB_OUTOCTETS, skb->len);
33588 -+ IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
33589 -+ IPSTATS_MIB_OUTFORWDATAGRAMS);
33590 -+ IP6_ADD_STATS(net, ip6_dst_idev(skb_dst(skb)),
33591 -+ IPSTATS_MIB_OUTOCTETS, skb->len);
33592 - return dst_output(net, sk, skb);
33593 - }
33594 -
33595 -diff --git a/net/ipv6/route.c b/net/ipv6/route.c
33596 -index 8dad1d690b78..0086acc16f3c 100644
33597 ---- a/net/ipv6/route.c
33598 -+++ b/net/ipv6/route.c
33599 -@@ -1040,14 +1040,20 @@ static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt)
33600 - struct rt6_info *nrt;
33601 -
33602 - if (!fib6_info_hold_safe(rt))
33603 -- return NULL;
33604 -+ goto fallback;
33605 -
33606 - nrt = ip6_dst_alloc(dev_net(dev), dev, flags);
33607 -- if (nrt)
33608 -- ip6_rt_copy_init(nrt, rt);
33609 -- else
33610 -+ if (!nrt) {
33611 - fib6_info_release(rt);
33612 -+ goto fallback;
33613 -+ }
33614 -
33615 -+ ip6_rt_copy_init(nrt, rt);
33616 -+ return nrt;
33617 -+
33618 -+fallback:
33619 -+ nrt = dev_net(dev)->ipv6.ip6_null_entry;
33620 -+ dst_hold(&nrt->dst);
33621 - return nrt;
33622 - }
33623 -
33624 -@@ -1096,10 +1102,6 @@ restart:
33625 - dst_hold(&rt->dst);
33626 + if (!IS_ERR(rt))
33627 + ip_rt_put(rt);
33628 + goto out;
33629 +@@ -636,7 +636,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
33630 } else {
33631 - rt = ip6_create_rt_rcu(f6i);
33632 -- if (!rt) {
33633 -- rt = net->ipv6.ip6_null_entry;
33634 -- dst_hold(&rt->dst);
33635 -- }
33636 + if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos,
33637 + skb2->dev) ||
33638 +- skb_dst(skb2)->dev->type != ARPHRD_TUNNEL)
33639 ++ skb_dst(skb2)->dev->type != ARPHRD_TUNNEL6)
33640 + goto out;
33641 }
33642
33643 - rcu_read_unlock();
33644 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
33645 -index 09e440e8dfae..b2109b74857d 100644
33646 +index 07e21a82ce4c..b2109b74857d 100644
33647 --- a/net/ipv6/sit.c
33648 +++ b/net/ipv6/sit.c
33649 @@ -669,6 +669,10 @@ static int ipip6_rcv(struct sk_buff *skb)
33650 @@ -31752,38 +4123,6 @@ index 09e440e8dfae..b2109b74857d 100644
33651 err = IP_ECN_decapsulate(iph, skb);
33652 if (unlikely(err)) {
33653 if (log_ecn_error)
33654 -@@ -778,8 +782,9 @@ static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
33655 - pbw0 = tunnel->ip6rd.prefixlen >> 5;
33656 - pbi0 = tunnel->ip6rd.prefixlen & 0x1f;
33657 -
33658 -- d = (ntohl(v6dst->s6_addr32[pbw0]) << pbi0) >>
33659 -- tunnel->ip6rd.relay_prefixlen;
33660 -+ d = tunnel->ip6rd.relay_prefixlen < 32 ?
33661 -+ (ntohl(v6dst->s6_addr32[pbw0]) << pbi0) >>
33662 -+ tunnel->ip6rd.relay_prefixlen : 0;
33663 -
33664 - pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen;
33665 - if (pbi1 > 0)
33666 -diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
33667 -index b81eb7cb815e..8505d96483d5 100644
33668 ---- a/net/ipv6/tcp_ipv6.c
33669 -+++ b/net/ipv6/tcp_ipv6.c
33670 -@@ -1112,11 +1112,11 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
33671 - newnp->ipv6_fl_list = NULL;
33672 - newnp->pktoptions = NULL;
33673 - newnp->opt = NULL;
33674 -- newnp->mcast_oif = tcp_v6_iif(skb);
33675 -- newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
33676 -- newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
33677 -+ newnp->mcast_oif = inet_iif(skb);
33678 -+ newnp->mcast_hops = ip_hdr(skb)->ttl;
33679 -+ newnp->rcv_flowinfo = 0;
33680 - if (np->repflow)
33681 -- newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));
33682 -+ newnp->flow_label = 0;
33683 -
33684 - /*
33685 - * No need to charge this sock to the relevant IPv6 refcnt debug socks count
33686 diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
33687 index 571d824e4e24..b919db02c7f9 100644
33688 --- a/net/kcm/kcmsock.c
33689 @@ -31833,150 +4172,10 @@ index 571d824e4e24..b919db02c7f9 100644
33690 proto_unregister(&kcm_proto);
33691 destroy_workqueue(kcm_wq);
33692
33693 -diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
33694 -index 0ae6899edac0..37a69df17cab 100644
33695 ---- a/net/l2tp/l2tp_ip6.c
33696 -+++ b/net/l2tp/l2tp_ip6.c
33697 -@@ -674,9 +674,6 @@ static int l2tp_ip6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
33698 - if (flags & MSG_OOB)
33699 - goto out;
33700 -
33701 -- if (addr_len)
33702 -- *addr_len = sizeof(*lsa);
33703 --
33704 - if (flags & MSG_ERRQUEUE)
33705 - return ipv6_recv_error(sk, msg, len, addr_len);
33706 -
33707 -@@ -706,6 +703,7 @@ static int l2tp_ip6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
33708 - lsa->l2tp_conn_id = 0;
33709 - if (ipv6_addr_type(&lsa->l2tp_addr) & IPV6_ADDR_LINKLOCAL)
33710 - lsa->l2tp_scope_id = inet6_iif(skb);
33711 -+ *addr_len = sizeof(*lsa);
33712 - }
33713 -
33714 - if (np->rxopt.all)
33715 -diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
33716 -index db4d46332e86..9dd4c2048a2b 100644
33717 ---- a/net/netfilter/nf_conntrack_core.c
33718 -+++ b/net/netfilter/nf_conntrack_core.c
33719 -@@ -901,10 +901,18 @@ __nf_conntrack_confirm(struct sk_buff *skb)
33720 - * REJECT will give spurious warnings here.
33721 - */
33722 -
33723 -- /* No external references means no one else could have
33724 -- * confirmed us.
33725 -+ /* Another skb with the same unconfirmed conntrack may
33726 -+ * win the race. This may happen for bridge(br_flood)
33727 -+ * or broadcast/multicast packets do skb_clone with
33728 -+ * unconfirmed conntrack.
33729 - */
33730 -- WARN_ON(nf_ct_is_confirmed(ct));
33731 -+ if (unlikely(nf_ct_is_confirmed(ct))) {
33732 -+ WARN_ON_ONCE(1);
33733 -+ nf_conntrack_double_unlock(hash, reply_hash);
33734 -+ local_bh_enable();
33735 -+ return NF_DROP;
33736 -+ }
33737 -+
33738 - pr_debug("Confirming conntrack %p\n", ct);
33739 - /* We have to check the DYING flag after unlink to prevent
33740 - * a race against nf_ct_get_next_corpse() possibly called from
33741 -diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
33742 -index 4dcbd51a8e97..74fb3fa34db4 100644
33743 ---- a/net/netfilter/nf_conntrack_proto_tcp.c
33744 -+++ b/net/netfilter/nf_conntrack_proto_tcp.c
33745 -@@ -828,6 +828,12 @@ static noinline bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb,
33746 - return true;
33747 - }
33748 -
33749 -+static bool nf_conntrack_tcp_established(const struct nf_conn *ct)
33750 -+{
33751 -+ return ct->proto.tcp.state == TCP_CONNTRACK_ESTABLISHED &&
33752 -+ test_bit(IPS_ASSURED_BIT, &ct->status);
33753 -+}
33754 -+
33755 - /* Returns verdict for packet, or -1 for invalid. */
33756 - static int tcp_packet(struct nf_conn *ct,
33757 - struct sk_buff *skb,
33758 -@@ -1030,16 +1036,38 @@ static int tcp_packet(struct nf_conn *ct,
33759 - new_state = TCP_CONNTRACK_ESTABLISHED;
33760 - break;
33761 - case TCP_CONNTRACK_CLOSE:
33762 -- if (index == TCP_RST_SET
33763 -- && (ct->proto.tcp.seen[!dir].flags & IP_CT_TCP_FLAG_MAXACK_SET)
33764 -- && before(ntohl(th->seq), ct->proto.tcp.seen[!dir].td_maxack)) {
33765 -- /* Invalid RST */
33766 -- spin_unlock_bh(&ct->lock);
33767 -- nf_ct_l4proto_log_invalid(skb, ct, "invalid rst");
33768 -- return -NF_ACCEPT;
33769 -+ if (index != TCP_RST_SET)
33770 -+ break;
33771 -+
33772 -+ if (ct->proto.tcp.seen[!dir].flags & IP_CT_TCP_FLAG_MAXACK_SET) {
33773 -+ u32 seq = ntohl(th->seq);
33774 -+
33775 -+ if (before(seq, ct->proto.tcp.seen[!dir].td_maxack)) {
33776 -+ /* Invalid RST */
33777 -+ spin_unlock_bh(&ct->lock);
33778 -+ nf_ct_l4proto_log_invalid(skb, ct, "invalid rst");
33779 -+ return -NF_ACCEPT;
33780 -+ }
33781 -+
33782 -+ if (!nf_conntrack_tcp_established(ct) ||
33783 -+ seq == ct->proto.tcp.seen[!dir].td_maxack)
33784 -+ break;
33785 -+
33786 -+ /* Check if rst is part of train, such as
33787 -+ * foo:80 > bar:4379: P, 235946583:235946602(19) ack 42
33788 -+ * foo:80 > bar:4379: R, 235946602:235946602(0) ack 42
33789 -+ */
33790 -+ if (ct->proto.tcp.last_index == TCP_ACK_SET &&
33791 -+ ct->proto.tcp.last_dir == dir &&
33792 -+ seq == ct->proto.tcp.last_end)
33793 -+ break;
33794 -+
33795 -+ /* ... RST sequence number doesn't match exactly, keep
33796 -+ * established state to allow a possible challenge ACK.
33797 -+ */
33798 -+ new_state = old_state;
33799 - }
33800 -- if (index == TCP_RST_SET
33801 -- && ((test_bit(IPS_SEEN_REPLY_BIT, &ct->status)
33802 -+ if (((test_bit(IPS_SEEN_REPLY_BIT, &ct->status)
33803 - && ct->proto.tcp.last_index == TCP_SYN_SET)
33804 - || (!test_bit(IPS_ASSURED_BIT, &ct->status)
33805 - && ct->proto.tcp.last_index == TCP_ACK_SET))
33806 -@@ -1055,7 +1083,7 @@ static int tcp_packet(struct nf_conn *ct,
33807 - * segments we ignored. */
33808 - goto in_window;
33809 - }
33810 -- /* Just fall through */
33811 -+ break;
33812 - default:
33813 - /* Keep compilers happy. */
33814 - break;
33815 -@@ -1090,6 +1118,8 @@ static int tcp_packet(struct nf_conn *ct,
33816 - if (ct->proto.tcp.retrans >= tn->tcp_max_retrans &&
33817 - timeouts[new_state] > timeouts[TCP_CONNTRACK_RETRANS])
33818 - timeout = timeouts[TCP_CONNTRACK_RETRANS];
33819 -+ else if (unlikely(index == TCP_RST_SET))
33820 -+ timeout = timeouts[TCP_CONNTRACK_CLOSE];
33821 - else if ((ct->proto.tcp.seen[0].flags | ct->proto.tcp.seen[1].flags) &
33822 - IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED &&
33823 - timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK])
33824 diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
33825 -index 4893f248dfdc..acb124ce92ec 100644
33826 +index e1724f9d8b9d..acb124ce92ec 100644
33827 --- a/net/netfilter/nf_tables_api.c
33828 +++ b/net/netfilter/nf_tables_api.c
33829 -@@ -127,7 +127,7 @@ static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set)
33830 - list_for_each_entry_reverse(trans, &net->nft.commit_list, list) {
33831 - if (trans->msg_type == NFT_MSG_NEWSET &&
33832 - nft_trans_set(trans) == set) {
33833 -- nft_trans_set_bound(trans) = true;
33834 -+ set->bound = true;
33835 - break;
33836 - }
33837 - }
33838 @@ -2119,9 +2119,11 @@ err1:
33839 static void nf_tables_expr_destroy(const struct nft_ctx *ctx,
33840 struct nft_expr *expr)
33841 @@ -32024,77 +4223,6 @@ index 4893f248dfdc..acb124ce92ec 100644
33842 }
33843 kvfree(info);
33844 return err;
33845 -@@ -6617,8 +6627,7 @@ static void nf_tables_abort_release(struct nft_trans *trans)
33846 - nf_tables_rule_destroy(&trans->ctx, nft_trans_rule(trans));
33847 - break;
33848 - case NFT_MSG_NEWSET:
33849 -- if (!nft_trans_set_bound(trans))
33850 -- nft_set_destroy(nft_trans_set(trans));
33851 -+ nft_set_destroy(nft_trans_set(trans));
33852 - break;
33853 - case NFT_MSG_NEWSETELEM:
33854 - nft_set_elem_destroy(nft_trans_elem_set(trans),
33855 -@@ -6691,8 +6700,11 @@ static int __nf_tables_abort(struct net *net)
33856 - break;
33857 - case NFT_MSG_NEWSET:
33858 - trans->ctx.table->use--;
33859 -- if (!nft_trans_set_bound(trans))
33860 -- list_del_rcu(&nft_trans_set(trans)->list);
33861 -+ if (nft_trans_set(trans)->bound) {
33862 -+ nft_trans_destroy(trans);
33863 -+ break;
33864 -+ }
33865 -+ list_del_rcu(&nft_trans_set(trans)->list);
33866 - break;
33867 - case NFT_MSG_DELSET:
33868 - trans->ctx.table->use++;
33869 -@@ -6700,8 +6712,11 @@ static int __nf_tables_abort(struct net *net)
33870 - nft_trans_destroy(trans);
33871 - break;
33872 - case NFT_MSG_NEWSETELEM:
33873 -+ if (nft_trans_elem_set(trans)->bound) {
33874 -+ nft_trans_destroy(trans);
33875 -+ break;
33876 -+ }
33877 - te = (struct nft_trans_elem *)trans->data;
33878 --
33879 - te->set->ops->remove(net, te->set, &te->elem);
33880 - atomic_dec(&te->set->nelems);
33881 - break;
33882 -diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
33883 -index a50500232b0a..7e8dae82ca52 100644
33884 ---- a/net/netfilter/nf_tables_core.c
33885 -+++ b/net/netfilter/nf_tables_core.c
33886 -@@ -98,21 +98,23 @@ static noinline void nft_update_chain_stats(const struct nft_chain *chain,
33887 - const struct nft_pktinfo *pkt)
33888 - {
33889 - struct nft_base_chain *base_chain;
33890 -+ struct nft_stats __percpu *pstats;
33891 - struct nft_stats *stats;
33892 -
33893 - base_chain = nft_base_chain(chain);
33894 -- if (!rcu_access_pointer(base_chain->stats))
33895 -- return;
33896 -
33897 -- local_bh_disable();
33898 -- stats = this_cpu_ptr(rcu_dereference(base_chain->stats));
33899 -- if (stats) {
33900 -+ rcu_read_lock();
33901 -+ pstats = READ_ONCE(base_chain->stats);
33902 -+ if (pstats) {
33903 -+ local_bh_disable();
33904 -+ stats = this_cpu_ptr(pstats);
33905 - u64_stats_update_begin(&stats->syncp);
33906 - stats->pkts++;
33907 - stats->bytes += pkt->skb->len;
33908 - u64_stats_update_end(&stats->syncp);
33909 -+ local_bh_enable();
33910 - }
33911 -- local_bh_enable();
33912 -+ rcu_read_unlock();
33913 - }
33914 -
33915 - struct nft_jumpstack {
33916 diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
33917 index 0a4bad55a8aa..469f9da5073b 100644
33918 --- a/net/netfilter/nft_compat.c
33919 @@ -32554,54 +4682,6 @@ index 0a4bad55a8aa..469f9da5073b 100644
33920 }
33921
33922 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT);
33923 -diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
33924 -index 4034d70bff39..b2e39cb6a590 100644
33925 ---- a/net/netfilter/xt_physdev.c
33926 -+++ b/net/netfilter/xt_physdev.c
33927 -@@ -96,8 +96,7 @@ match_outdev:
33928 - static int physdev_mt_check(const struct xt_mtchk_param *par)
33929 - {
33930 - const struct xt_physdev_info *info = par->matchinfo;
33931 --
33932 -- br_netfilter_enable();
33933 -+ static bool brnf_probed __read_mostly;
33934 -
33935 - if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
33936 - info->bitmask & ~XT_PHYSDEV_OP_MASK)
33937 -@@ -111,6 +110,12 @@ static int physdev_mt_check(const struct xt_mtchk_param *par)
33938 - if (par->hook_mask & (1 << NF_INET_LOCAL_OUT))
33939 - return -EINVAL;
33940 - }
33941 -+
33942 -+ if (!brnf_probed) {
33943 -+ brnf_probed = true;
33944 -+ request_module("br_netfilter");
33945 -+ }
33946 -+
33947 - return 0;
33948 - }
33949 -
33950 -diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
33951 -index 25eeb6d2a75a..f0ec068e1d02 100644
33952 ---- a/net/netlink/genetlink.c
33953 -+++ b/net/netlink/genetlink.c
33954 -@@ -366,7 +366,7 @@ int genl_register_family(struct genl_family *family)
33955 - start, end + 1, GFP_KERNEL);
33956 - if (family->id < 0) {
33957 - err = family->id;
33958 -- goto errout_locked;
33959 -+ goto errout_free;
33960 - }
33961 -
33962 - err = genl_validate_assign_mc_groups(family);
33963 -@@ -385,6 +385,7 @@ int genl_register_family(struct genl_family *family)
33964 -
33965 - errout_remove:
33966 - idr_remove(&genl_fam_idr, family->id);
33967 -+errout_free:
33968 - kfree(family->attrbuf);
33969 - errout_locked:
33970 - genl_unlock_all();
33971 diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
33972 index 691da853bef5..4bdf5e3ac208 100644
33973 --- a/net/openvswitch/flow_netlink.c
33974 @@ -32623,28 +4703,6 @@ index 691da853bef5..4bdf5e3ac208 100644
33975
33976 if (new_acts_size > MAX_ACTIONS_BUFSIZE) {
33977 if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) {
33978 -diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
33979 -index 1cd1d83a4be0..8406bf11eef4 100644
33980 ---- a/net/packet/af_packet.c
33981 -+++ b/net/packet/af_packet.c
33982 -@@ -3245,7 +3245,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
33983 - }
33984 -
33985 - mutex_lock(&net->packet.sklist_lock);
33986 -- sk_add_node_rcu(sk, &net->packet.sklist);
33987 -+ sk_add_node_tail_rcu(sk, &net->packet.sklist);
33988 - mutex_unlock(&net->packet.sklist_lock);
33989 -
33990 - preempt_disable();
33991 -@@ -4211,7 +4211,7 @@ static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order)
33992 - struct pgv *pg_vec;
33993 - int i;
33994 -
33995 -- pg_vec = kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL);
33996 -+ pg_vec = kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL | __GFP_NOWARN);
33997 - if (unlikely(!pg_vec))
33998 - goto out;
33999 -
34000 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
34001 index c16f0a362c32..a729c47db781 100644
34002 --- a/net/rds/tcp.c
34003 @@ -32658,85 +4716,6 @@ index c16f0a362c32..a729c47db781 100644
34004 continue;
34005 if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn)) {
34006 list_move_tail(&tc->t_tcp_node, &tmp_list);
34007 -diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c
34008 -index 7ca57741b2fb..7849f286bb93 100644
34009 ---- a/net/rose/rose_subr.c
34010 -+++ b/net/rose/rose_subr.c
34011 -@@ -105,16 +105,17 @@ void rose_write_internal(struct sock *sk, int frametype)
34012 - struct sk_buff *skb;
34013 - unsigned char *dptr;
34014 - unsigned char lci1, lci2;
34015 -- char buffer[100];
34016 -- int len, faclen = 0;
34017 -+ int maxfaclen = 0;
34018 -+ int len, faclen;
34019 -+ int reserve;
34020 -
34021 -- len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1;
34022 -+ reserve = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1;
34023 -+ len = ROSE_MIN_LEN;
34024 -
34025 - switch (frametype) {
34026 - case ROSE_CALL_REQUEST:
34027 - len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN;
34028 -- faclen = rose_create_facilities(buffer, rose);
34029 -- len += faclen;
34030 -+ maxfaclen = 256;
34031 - break;
34032 - case ROSE_CALL_ACCEPTED:
34033 - case ROSE_CLEAR_REQUEST:
34034 -@@ -123,15 +124,16 @@ void rose_write_internal(struct sock *sk, int frametype)
34035 - break;
34036 - }
34037 -
34038 -- if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
34039 -+ skb = alloc_skb(reserve + len + maxfaclen, GFP_ATOMIC);
34040 -+ if (!skb)
34041 - return;
34042 -
34043 - /*
34044 - * Space for AX.25 header and PID.
34045 - */
34046 -- skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1);
34047 -+ skb_reserve(skb, reserve);
34048 -
34049 -- dptr = skb_put(skb, skb_tailroom(skb));
34050 -+ dptr = skb_put(skb, len);
34051 -
34052 - lci1 = (rose->lci >> 8) & 0x0F;
34053 - lci2 = (rose->lci >> 0) & 0xFF;
34054 -@@ -146,7 +148,8 @@ void rose_write_internal(struct sock *sk, int frametype)
34055 - dptr += ROSE_ADDR_LEN;
34056 - memcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN);
34057 - dptr += ROSE_ADDR_LEN;
34058 -- memcpy(dptr, buffer, faclen);
34059 -+ faclen = rose_create_facilities(dptr, rose);
34060 -+ skb_put(skb, faclen);
34061 - dptr += faclen;
34062 - break;
34063 -
34064 -diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
34065 -index b2adfa825363..5cf6d9f4761d 100644
34066 ---- a/net/rxrpc/conn_client.c
34067 -+++ b/net/rxrpc/conn_client.c
34068 -@@ -353,7 +353,7 @@ static int rxrpc_get_client_conn(struct rxrpc_sock *rx,
34069 - * normally have to take channel_lock but we do this before anyone else
34070 - * can see the connection.
34071 - */
34072 -- list_add_tail(&call->chan_wait_link, &candidate->waiting_calls);
34073 -+ list_add(&call->chan_wait_link, &candidate->waiting_calls);
34074 -
34075 - if (cp->exclusive) {
34076 - call->conn = candidate;
34077 -@@ -432,7 +432,7 @@ found_extant_conn:
34078 - call->conn = conn;
34079 - call->security_ix = conn->security_ix;
34080 - call->service_id = conn->service_id;
34081 -- list_add(&call->chan_wait_link, &conn->waiting_calls);
34082 -+ list_add_tail(&call->chan_wait_link, &conn->waiting_calls);
34083 - spin_unlock(&conn->channel_lock);
34084 - _leave(" = 0 [extant %d]", conn->debug_id);
34085 - return 0;
34086 diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c
34087 index 1a0c682fd734..fd62fe6c8e73 100644
34088 --- a/net/sched/act_sample.c
34089 @@ -32773,92 +4752,6 @@ index 1a0c682fd734..fd62fe6c8e73 100644
34090 s->psample_group_num = psample_group_num;
34091 RCU_INIT_POINTER(s->psample_group, psample_group);
34092
34093 -diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
34094 -index 12ca9d13db83..bf67ae5ac1c3 100644
34095 ---- a/net/sched/cls_flower.c
34096 -+++ b/net/sched/cls_flower.c
34097 -@@ -1327,46 +1327,46 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
34098 - if (err < 0)
34099 - goto errout;
34100 -
34101 -- if (!handle) {
34102 -- handle = 1;
34103 -- err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
34104 -- INT_MAX, GFP_KERNEL);
34105 -- } else if (!fold) {
34106 -- /* user specifies a handle and it doesn't exist */
34107 -- err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
34108 -- handle, GFP_KERNEL);
34109 -- }
34110 -- if (err)
34111 -- goto errout;
34112 -- fnew->handle = handle;
34113 --
34114 - if (tb[TCA_FLOWER_FLAGS]) {
34115 - fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
34116 -
34117 - if (!tc_flags_valid(fnew->flags)) {
34118 - err = -EINVAL;
34119 -- goto errout_idr;
34120 -+ goto errout;
34121 - }
34122 - }
34123 -
34124 - err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], ovr,
34125 - tp->chain->tmplt_priv, extack);
34126 - if (err)
34127 -- goto errout_idr;
34128 -+ goto errout;
34129 -
34130 - err = fl_check_assign_mask(head, fnew, fold, mask);
34131 - if (err)
34132 -- goto errout_idr;
34133 -+ goto errout;
34134 -+
34135 -+ if (!handle) {
34136 -+ handle = 1;
34137 -+ err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
34138 -+ INT_MAX, GFP_KERNEL);
34139 -+ } else if (!fold) {
34140 -+ /* user specifies a handle and it doesn't exist */
34141 -+ err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
34142 -+ handle, GFP_KERNEL);
34143 -+ }
34144 -+ if (err)
34145 -+ goto errout_mask;
34146 -+ fnew->handle = handle;
34147 -
34148 - if (!fold && __fl_lookup(fnew->mask, &fnew->mkey)) {
34149 - err = -EEXIST;
34150 -- goto errout_mask;
34151 -+ goto errout_idr;
34152 - }
34153 -
34154 - err = rhashtable_insert_fast(&fnew->mask->ht, &fnew->ht_node,
34155 - fnew->mask->filter_ht_params);
34156 - if (err)
34157 -- goto errout_mask;
34158 -+ goto errout_idr;
34159 -
34160 - if (!tc_skip_hw(fnew->flags)) {
34161 - err = fl_hw_replace_filter(tp, fnew, extack);
34162 -@@ -1405,12 +1405,13 @@ errout_mask_ht:
34163 - rhashtable_remove_fast(&fnew->mask->ht, &fnew->ht_node,
34164 - fnew->mask->filter_ht_params);
34165 -
34166 --errout_mask:
34167 -- fl_mask_put(head, fnew->mask, false);
34168 --
34169 - errout_idr:
34170 - if (!fold)
34171 - idr_remove(&head->handle_idr, fnew->handle);
34172 -+
34173 -+errout_mask:
34174 -+ fl_mask_put(head, fnew->mask, false);
34175 -+
34176 - errout:
34177 - tcf_exts_destroy(&fnew->exts);
34178 - kfree(fnew);
34179 diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
34180 index 0e408ee9dcec..5ba07cd11e31 100644
34181 --- a/net/sched/cls_matchall.c
34182 @@ -32867,491 +4760,26 @@ index 0e408ee9dcec..5ba07cd11e31 100644
34183
34184 static void *mall_get(struct tcf_proto *tp, u32 handle)
34185 {
34186 -+ struct cls_mall_head *head = rtnl_dereference(tp->root);
34187 -+
34188 -+ if (head && head->handle == handle)
34189 -+ return head;
34190 -+
34191 - return NULL;
34192 - }
34193 -
34194 -diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
34195 -index 968a85fe4d4a..de31f2f3b973 100644
34196 ---- a/net/sched/sch_generic.c
34197 -+++ b/net/sched/sch_generic.c
34198 -@@ -68,7 +68,7 @@ static inline struct sk_buff *__skb_dequeue_bad_txq(struct Qdisc *q)
34199 - skb = __skb_dequeue(&q->skb_bad_txq);
34200 - if (qdisc_is_percpu_stats(q)) {
34201 - qdisc_qstats_cpu_backlog_dec(q, skb);
34202 -- qdisc_qstats_cpu_qlen_dec(q);
34203 -+ qdisc_qstats_atomic_qlen_dec(q);
34204 - } else {
34205 - qdisc_qstats_backlog_dec(q, skb);
34206 - q->q.qlen--;
34207 -@@ -108,7 +108,7 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc *q,
34208 -
34209 - if (qdisc_is_percpu_stats(q)) {
34210 - qdisc_qstats_cpu_backlog_inc(q, skb);
34211 -- qdisc_qstats_cpu_qlen_inc(q);
34212 -+ qdisc_qstats_atomic_qlen_inc(q);
34213 - } else {
34214 - qdisc_qstats_backlog_inc(q, skb);
34215 - q->q.qlen++;
34216 -@@ -147,7 +147,7 @@ static inline int dev_requeue_skb_locked(struct sk_buff *skb, struct Qdisc *q)
34217 -
34218 - qdisc_qstats_cpu_requeues_inc(q);
34219 - qdisc_qstats_cpu_backlog_inc(q, skb);
34220 -- qdisc_qstats_cpu_qlen_inc(q);
34221 -+ qdisc_qstats_atomic_qlen_inc(q);
34222 -
34223 - skb = next;
34224 - }
34225 -@@ -252,7 +252,7 @@ static struct sk_buff *dequeue_skb(struct Qdisc *q, bool *validate,
34226 - skb = __skb_dequeue(&q->gso_skb);
34227 - if (qdisc_is_percpu_stats(q)) {
34228 - qdisc_qstats_cpu_backlog_dec(q, skb);
34229 -- qdisc_qstats_cpu_qlen_dec(q);
34230 -+ qdisc_qstats_atomic_qlen_dec(q);
34231 - } else {
34232 - qdisc_qstats_backlog_dec(q, skb);
34233 - q->q.qlen--;
34234 -@@ -645,7 +645,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
34235 - if (unlikely(err))
34236 - return qdisc_drop_cpu(skb, qdisc, to_free);
34237 -
34238 -- qdisc_qstats_cpu_qlen_inc(qdisc);
34239 -+ qdisc_qstats_atomic_qlen_inc(qdisc);
34240 - /* Note: skb can not be used after skb_array_produce(),
34241 - * so we better not use qdisc_qstats_cpu_backlog_inc()
34242 - */
34243 -@@ -670,7 +670,7 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
34244 - if (likely(skb)) {
34245 - qdisc_qstats_cpu_backlog_dec(qdisc, skb);
34246 - qdisc_bstats_cpu_update(qdisc, skb);
34247 -- qdisc_qstats_cpu_qlen_dec(qdisc);
34248 -+ qdisc_qstats_atomic_qlen_dec(qdisc);
34249 - }
34250 -
34251 - return skb;
34252 -@@ -714,7 +714,6 @@ static void pfifo_fast_reset(struct Qdisc *qdisc)
34253 - struct gnet_stats_queue *q = per_cpu_ptr(qdisc->cpu_qstats, i);
34254 -
34255 - q->backlog = 0;
34256 -- q->qlen = 0;
34257 - }
34258 - }
34259 -
34260 -diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
34261 -index 6abc8b274270..951afdeea5e9 100644
34262 ---- a/net/sctp/protocol.c
34263 -+++ b/net/sctp/protocol.c
34264 -@@ -600,6 +600,7 @@ out:
34265 - static int sctp_v4_addr_to_user(struct sctp_sock *sp, union sctp_addr *addr)
34266 - {
34267 - /* No address mapping for V4 sockets */
34268 -+ memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
34269 - return sizeof(struct sockaddr_in);
34270 - }
34271 -
34272 -diff --git a/net/sctp/socket.c b/net/sctp/socket.c
34273 -index 65d6d04546ae..5f68420b4b0d 100644
34274 ---- a/net/sctp/socket.c
34275 -+++ b/net/sctp/socket.c
34276 -@@ -999,7 +999,7 @@ static int sctp_setsockopt_bindx(struct sock *sk,
34277 - if (unlikely(addrs_size <= 0))
34278 - return -EINVAL;
34279 -
34280 -- kaddrs = vmemdup_user(addrs, addrs_size);
34281 -+ kaddrs = memdup_user(addrs, addrs_size);
34282 - if (unlikely(IS_ERR(kaddrs)))
34283 - return PTR_ERR(kaddrs);
34284 -
34285 -@@ -1007,7 +1007,7 @@ static int sctp_setsockopt_bindx(struct sock *sk,
34286 - addr_buf = kaddrs;
34287 - while (walk_size < addrs_size) {
34288 - if (walk_size + sizeof(sa_family_t) > addrs_size) {
34289 -- kvfree(kaddrs);
34290 -+ kfree(kaddrs);
34291 - return -EINVAL;
34292 - }
34293 -
34294 -@@ -1018,7 +1018,7 @@ static int sctp_setsockopt_bindx(struct sock *sk,
34295 - * causes the address buffer to overflow return EINVAL.
34296 - */
34297 - if (!af || (walk_size + af->sockaddr_len) > addrs_size) {
34298 -- kvfree(kaddrs);
34299 -+ kfree(kaddrs);
34300 - return -EINVAL;
34301 - }
34302 - addrcnt++;
34303 -@@ -1054,7 +1054,7 @@ static int sctp_setsockopt_bindx(struct sock *sk,
34304 - }
34305 -
34306 - out:
34307 -- kvfree(kaddrs);
34308 -+ kfree(kaddrs);
34309 -
34310 - return err;
34311 - }
34312 -@@ -1329,7 +1329,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
34313 - if (unlikely(addrs_size <= 0))
34314 - return -EINVAL;
34315 -
34316 -- kaddrs = vmemdup_user(addrs, addrs_size);
34317 -+ kaddrs = memdup_user(addrs, addrs_size);
34318 - if (unlikely(IS_ERR(kaddrs)))
34319 - return PTR_ERR(kaddrs);
34320 -
34321 -@@ -1349,7 +1349,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
34322 - err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id);
34323 -
34324 - out_free:
34325 -- kvfree(kaddrs);
34326 -+ kfree(kaddrs);
34327 -
34328 - return err;
34329 - }
34330 -@@ -1866,6 +1866,7 @@ static int sctp_sendmsg_check_sflags(struct sctp_association *asoc,
34331 -
34332 - pr_debug("%s: aborting association:%p\n", __func__, asoc);
34333 - sctp_primitive_ABORT(net, asoc, chunk);
34334 -+ iov_iter_revert(&msg->msg_iter, msg_len);
34335 -
34336 - return 0;
34337 - }
34338 -diff --git a/net/sctp/stream.c b/net/sctp/stream.c
34339 -index 2936ed17bf9e..3b47457862cc 100644
34340 ---- a/net/sctp/stream.c
34341 -+++ b/net/sctp/stream.c
34342 -@@ -230,8 +230,6 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt,
34343 - for (i = 0; i < stream->outcnt; i++)
34344 - SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
34345 -
34346 -- sched->init(stream);
34347 --
34348 - in:
34349 - sctp_stream_interleave_init(stream);
34350 - if (!incnt)
34351 -diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
34352 -index d7ec6132c046..d455537c8fc6 100644
34353 ---- a/net/sunrpc/clnt.c
34354 -+++ b/net/sunrpc/clnt.c
34355 -@@ -66,9 +66,6 @@ static void call_decode(struct rpc_task *task);
34356 - static void call_bind(struct rpc_task *task);
34357 - static void call_bind_status(struct rpc_task *task);
34358 - static void call_transmit(struct rpc_task *task);
34359 --#if defined(CONFIG_SUNRPC_BACKCHANNEL)
34360 --static void call_bc_transmit(struct rpc_task *task);
34361 --#endif /* CONFIG_SUNRPC_BACKCHANNEL */
34362 - static void call_status(struct rpc_task *task);
34363 - static void call_transmit_status(struct rpc_task *task);
34364 - static void call_refresh(struct rpc_task *task);
34365 -@@ -80,6 +77,7 @@ static void call_connect_status(struct rpc_task *task);
34366 - static __be32 *rpc_encode_header(struct rpc_task *task);
34367 - static __be32 *rpc_verify_header(struct rpc_task *task);
34368 - static int rpc_ping(struct rpc_clnt *clnt);
34369 -+static void rpc_check_timeout(struct rpc_task *task);
34370 -
34371 - static void rpc_register_client(struct rpc_clnt *clnt)
34372 - {
34373 -@@ -1131,6 +1129,8 @@ rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
34374 - EXPORT_SYMBOL_GPL(rpc_call_async);
34375 -
34376 - #if defined(CONFIG_SUNRPC_BACKCHANNEL)
34377 -+static void call_bc_encode(struct rpc_task *task);
34378 -+
34379 - /**
34380 - * rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run
34381 - * rpc_execute against it
34382 -@@ -1152,7 +1152,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
34383 - task = rpc_new_task(&task_setup_data);
34384 - xprt_init_bc_request(req, task);
34385 -
34386 -- task->tk_action = call_bc_transmit;
34387 -+ task->tk_action = call_bc_encode;
34388 - atomic_inc(&task->tk_count);
34389 - WARN_ON_ONCE(atomic_read(&task->tk_count) != 2);
34390 - rpc_execute(task);
34391 -@@ -1786,7 +1786,12 @@ call_encode(struct rpc_task *task)
34392 - xprt_request_enqueue_receive(task);
34393 - xprt_request_enqueue_transmit(task);
34394 - out:
34395 -- task->tk_action = call_bind;
34396 -+ task->tk_action = call_transmit;
34397 -+ /* Check that the connection is OK */
34398 -+ if (!xprt_bound(task->tk_xprt))
34399 -+ task->tk_action = call_bind;
34400 -+ else if (!xprt_connected(task->tk_xprt))
34401 -+ task->tk_action = call_connect;
34402 - }
34403 -
34404 - /*
34405 -@@ -1937,8 +1942,7 @@ call_connect_status(struct rpc_task *task)
34406 - break;
34407 - if (clnt->cl_autobind) {
34408 - rpc_force_rebind(clnt);
34409 -- task->tk_action = call_bind;
34410 -- return;
34411 -+ goto out_retry;
34412 - }
34413 - /* fall through */
34414 - case -ECONNRESET:
34415 -@@ -1958,16 +1962,19 @@ call_connect_status(struct rpc_task *task)
34416 - /* fall through */
34417 - case -ENOTCONN:
34418 - case -EAGAIN:
34419 -- /* Check for timeouts before looping back to call_bind */
34420 - case -ETIMEDOUT:
34421 -- task->tk_action = call_timeout;
34422 -- return;
34423 -+ goto out_retry;
34424 - case 0:
34425 - clnt->cl_stats->netreconn++;
34426 - task->tk_action = call_transmit;
34427 - return;
34428 - }
34429 - rpc_exit(task, status);
34430 -+ return;
34431 -+out_retry:
34432 -+ /* Check for timeouts before looping back to call_bind */
34433 -+ task->tk_action = call_bind;
34434 -+ rpc_check_timeout(task);
34435 - }
34436 -
34437 - /*
34438 -@@ -1978,13 +1985,19 @@ call_transmit(struct rpc_task *task)
34439 - {
34440 - dprint_status(task);
34441 -
34442 -- task->tk_status = 0;
34443 -+ task->tk_action = call_transmit_status;
34444 - if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) {
34445 - if (!xprt_prepare_transmit(task))
34446 - return;
34447 -- xprt_transmit(task);
34448 -+ task->tk_status = 0;
34449 -+ if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) {
34450 -+ if (!xprt_connected(task->tk_xprt)) {
34451 -+ task->tk_status = -ENOTCONN;
34452 -+ return;
34453 -+ }
34454 -+ xprt_transmit(task);
34455 -+ }
34456 - }
34457 -- task->tk_action = call_transmit_status;
34458 - xprt_end_transmit(task);
34459 - }
34460 -
34461 -@@ -2038,7 +2051,7 @@ call_transmit_status(struct rpc_task *task)
34462 - trace_xprt_ping(task->tk_xprt,
34463 - task->tk_status);
34464 - rpc_exit(task, task->tk_status);
34465 -- break;
34466 -+ return;
34467 - }
34468 - /* fall through */
34469 - case -ECONNRESET:
34470 -@@ -2046,11 +2059,24 @@ call_transmit_status(struct rpc_task *task)
34471 - case -EADDRINUSE:
34472 - case -ENOTCONN:
34473 - case -EPIPE:
34474 -+ task->tk_action = call_bind;
34475 -+ task->tk_status = 0;
34476 - break;
34477 - }
34478 -+ rpc_check_timeout(task);
34479 - }
34480 -
34481 - #if defined(CONFIG_SUNRPC_BACKCHANNEL)
34482 -+static void call_bc_transmit(struct rpc_task *task);
34483 -+static void call_bc_transmit_status(struct rpc_task *task);
34484 -+
34485 -+static void
34486 -+call_bc_encode(struct rpc_task *task)
34487 -+{
34488 -+ xprt_request_enqueue_transmit(task);
34489 -+ task->tk_action = call_bc_transmit;
34490 -+}
34491 -+
34492 - /*
34493 - * 5b. Send the backchannel RPC reply. On error, drop the reply. In
34494 - * addition, disconnect on connectivity errors.
34495 -@@ -2058,26 +2084,23 @@ call_transmit_status(struct rpc_task *task)
34496 - static void
34497 - call_bc_transmit(struct rpc_task *task)
34498 - {
34499 -- struct rpc_rqst *req = task->tk_rqstp;
34500 --
34501 -- if (rpc_task_need_encode(task))
34502 -- xprt_request_enqueue_transmit(task);
34503 -- if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
34504 -- goto out_wakeup;
34505 --
34506 -- if (!xprt_prepare_transmit(task))
34507 -- goto out_retry;
34508 --
34509 -- if (task->tk_status < 0) {
34510 -- printk(KERN_NOTICE "RPC: Could not send backchannel reply "
34511 -- "error: %d\n", task->tk_status);
34512 -- goto out_done;
34513 -+ task->tk_action = call_bc_transmit_status;
34514 -+ if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) {
34515 -+ if (!xprt_prepare_transmit(task))
34516 -+ return;
34517 -+ task->tk_status = 0;
34518 -+ xprt_transmit(task);
34519 - }
34520 -+ xprt_end_transmit(task);
34521 -+}
34522 -
34523 -- xprt_transmit(task);
34524 -+static void
34525 -+call_bc_transmit_status(struct rpc_task *task)
34526 -+{
34527 -+ struct rpc_rqst *req = task->tk_rqstp;
34528 -
34529 -- xprt_end_transmit(task);
34530 - dprint_status(task);
34531 -+
34532 - switch (task->tk_status) {
34533 - case 0:
34534 - /* Success */
34535 -@@ -2091,8 +2114,14 @@ call_bc_transmit(struct rpc_task *task)
34536 - case -ENOTCONN:
34537 - case -EPIPE:
34538 - break;
34539 -+ case -ENOBUFS:
34540 -+ rpc_delay(task, HZ>>2);
34541 -+ /* fall through */
34542 -+ case -EBADSLT:
34543 - case -EAGAIN:
34544 -- goto out_retry;
34545 -+ task->tk_status = 0;
34546 -+ task->tk_action = call_bc_transmit;
34547 -+ return;
34548 - case -ETIMEDOUT:
34549 - /*
34550 - * Problem reaching the server. Disconnect and let the
34551 -@@ -2111,18 +2140,11 @@ call_bc_transmit(struct rpc_task *task)
34552 - * We were unable to reply and will have to drop the
34553 - * request. The server should reconnect and retransmit.
34554 - */
34555 -- WARN_ON_ONCE(task->tk_status == -EAGAIN);
34556 - printk(KERN_NOTICE "RPC: Could not send backchannel reply "
34557 - "error: %d\n", task->tk_status);
34558 - break;
34559 - }
34560 --out_wakeup:
34561 -- rpc_wake_up_queued_task(&req->rq_xprt->pending, task);
34562 --out_done:
34563 - task->tk_action = rpc_exit_task;
34564 -- return;
34565 --out_retry:
34566 -- task->tk_status = 0;
34567 - }
34568 - #endif /* CONFIG_SUNRPC_BACKCHANNEL */
34569 -
34570 -@@ -2178,7 +2200,7 @@ call_status(struct rpc_task *task)
34571 - case -EPIPE:
34572 - case -ENOTCONN:
34573 - case -EAGAIN:
34574 -- task->tk_action = call_encode;
34575 -+ task->tk_action = call_timeout;
34576 - break;
34577 - case -EIO:
34578 - /* shutdown or soft timeout */
34579 -@@ -2192,20 +2214,13 @@ call_status(struct rpc_task *task)
34580 - }
34581 - }
34582 -
34583 --/*
34584 -- * 6a. Handle RPC timeout
34585 -- * We do not release the request slot, so we keep using the
34586 -- * same XID for all retransmits.
34587 -- */
34588 - static void
34589 --call_timeout(struct rpc_task *task)
34590 -+rpc_check_timeout(struct rpc_task *task)
34591 - {
34592 - struct rpc_clnt *clnt = task->tk_client;
34593 -
34594 -- if (xprt_adjust_timeout(task->tk_rqstp) == 0) {
34595 -- dprintk("RPC: %5u call_timeout (minor)\n", task->tk_pid);
34596 -- goto retry;
34597 -- }
34598 -+ if (xprt_adjust_timeout(task->tk_rqstp) == 0)
34599 -+ return;
34600 -
34601 - dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid);
34602 - task->tk_timeouts++;
34603 -@@ -2241,10 +2256,19 @@ call_timeout(struct rpc_task *task)
34604 - * event? RFC2203 requires the server to drop all such requests.
34605 - */
34606 - rpcauth_invalcred(task);
34607 -+}
34608 -
34609 --retry:
34610 -+/*
34611 -+ * 6a. Handle RPC timeout
34612 -+ * We do not release the request slot, so we keep using the
34613 -+ * same XID for all retransmits.
34614 -+ */
34615 -+static void
34616 -+call_timeout(struct rpc_task *task)
34617 -+{
34618 - task->tk_action = call_encode;
34619 - task->tk_status = 0;
34620 -+ rpc_check_timeout(task);
34621 - }
34622 -
34623 - /*
34624 -diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
34625 -index a6a060925e5d..43590a968b73 100644
34626 ---- a/net/sunrpc/svcsock.c
34627 -+++ b/net/sunrpc/svcsock.c
34628 -@@ -349,12 +349,16 @@ static ssize_t svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov,
34629 - /*
34630 - * Set socket snd and rcv buffer lengths
34631 - */
34632 --static void svc_sock_setbufsize(struct socket *sock, unsigned int snd,
34633 -- unsigned int rcv)
34634 -+static void svc_sock_setbufsize(struct svc_sock *svsk, unsigned int nreqs)
34635 - {
34636 -+ unsigned int max_mesg = svsk->sk_xprt.xpt_server->sv_max_mesg;
34637 -+ struct socket *sock = svsk->sk_sock;
34638 ++ struct cls_mall_head *head = rtnl_dereference(tp->root);
34639 +
34640 -+ nreqs = min(nreqs, INT_MAX / 2 / max_mesg);
34641 ++ if (head && head->handle == handle)
34642 ++ return head;
34643 +
34644 - lock_sock(sock->sk);
34645 -- sock->sk->sk_sndbuf = snd * 2;
34646 -- sock->sk->sk_rcvbuf = rcv * 2;
34647 -+ sock->sk->sk_sndbuf = nreqs * max_mesg * 2;
34648 -+ sock->sk->sk_rcvbuf = nreqs * max_mesg * 2;
34649 - sock->sk->sk_write_space(sock->sk);
34650 - release_sock(sock->sk);
34651 + return NULL;
34652 + }
34653 +
34654 +diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
34655 +index 6abc8b274270..951afdeea5e9 100644
34656 +--- a/net/sctp/protocol.c
34657 ++++ b/net/sctp/protocol.c
34658 +@@ -600,6 +600,7 @@ out:
34659 + static int sctp_v4_addr_to_user(struct sctp_sock *sp, union sctp_addr *addr)
34660 + {
34661 + /* No address mapping for V4 sockets */
34662 ++ memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
34663 + return sizeof(struct sockaddr_in);
34664 }
34665 -@@ -516,9 +520,7 @@ static int svc_udp_recvfrom(struct svc_rqst *rqstp)
34666 - * provides an upper bound on the number of threads
34667 - * which will access the socket.
34668 - */
34669 -- svc_sock_setbufsize(svsk->sk_sock,
34670 -- (serv->sv_nrthreads+3) * serv->sv_max_mesg,
34671 -- (serv->sv_nrthreads+3) * serv->sv_max_mesg);
34672 -+ svc_sock_setbufsize(svsk, serv->sv_nrthreads + 3);
34673 -
34674 - clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
34675 - skb = NULL;
34676 -@@ -681,9 +683,7 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
34677 - * receive and respond to one request.
34678 - * svc_udp_recvfrom will re-adjust if necessary
34679 - */
34680 -- svc_sock_setbufsize(svsk->sk_sock,
34681 -- 3 * svsk->sk_xprt.xpt_server->sv_max_mesg,
34682 -- 3 * svsk->sk_xprt.xpt_server->sv_max_mesg);
34683 -+ svc_sock_setbufsize(svsk, 3);
34684
34685 - /* data might have come in before data_ready set up */
34686 - set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
34687 diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
34688 index 21113bfd4eca..a5ae9c036b9c 100644
34689 --- a/net/sunrpc/xprtrdma/verbs.c
34690 @@ -33365,240 +4793,6 @@ index 21113bfd4eca..a5ae9c036b9c 100644
34691 drain_workqueue(buf->rb_completion_wq);
34692
34693 /* Deferred Reply processing might have scheduled
34694 -diff --git a/net/tipc/net.c b/net/tipc/net.c
34695 -index f076edb74338..7ce1e86b024f 100644
34696 ---- a/net/tipc/net.c
34697 -+++ b/net/tipc/net.c
34698 -@@ -163,12 +163,9 @@ void tipc_sched_net_finalize(struct net *net, u32 addr)
34699 -
34700 - void tipc_net_stop(struct net *net)
34701 - {
34702 -- u32 self = tipc_own_addr(net);
34703 --
34704 -- if (!self)
34705 -+ if (!tipc_own_id(net))
34706 - return;
34707 -
34708 -- tipc_nametbl_withdraw(net, TIPC_CFG_SRV, self, self, self);
34709 - rtnl_lock();
34710 - tipc_bearer_stop(net);
34711 - tipc_node_stop(net);
34712 -diff --git a/net/tipc/socket.c b/net/tipc/socket.c
34713 -index 70343ac448b1..4dca9161f99b 100644
34714 ---- a/net/tipc/socket.c
34715 -+++ b/net/tipc/socket.c
34716 -@@ -1333,7 +1333,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
34717 -
34718 - if (unlikely(!dest)) {
34719 - dest = &tsk->peer;
34720 -- if (!syn || dest->family != AF_TIPC)
34721 -+ if (!syn && dest->family != AF_TIPC)
34722 - return -EDESTADDRREQ;
34723 - }
34724 -
34725 -@@ -2349,6 +2349,16 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
34726 - return 0;
34727 - }
34728 -
34729 -+static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr)
34730 -+{
34731 -+ if (addr->family != AF_TIPC)
34732 -+ return false;
34733 -+ if (addr->addrtype == TIPC_SERVICE_RANGE)
34734 -+ return (addr->addr.nameseq.lower <= addr->addr.nameseq.upper);
34735 -+ return (addr->addrtype == TIPC_SERVICE_ADDR ||
34736 -+ addr->addrtype == TIPC_SOCKET_ADDR);
34737 -+}
34738 -+
34739 - /**
34740 - * tipc_connect - establish a connection to another TIPC port
34741 - * @sock: socket structure
34742 -@@ -2384,18 +2394,18 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
34743 - if (!tipc_sk_type_connectionless(sk))
34744 - res = -EINVAL;
34745 - goto exit;
34746 -- } else if (dst->family != AF_TIPC) {
34747 -- res = -EINVAL;
34748 - }
34749 -- if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME)
34750 -+ if (!tipc_sockaddr_is_sane(dst)) {
34751 - res = -EINVAL;
34752 -- if (res)
34753 - goto exit;
34754 --
34755 -+ }
34756 - /* DGRAM/RDM connect(), just save the destaddr */
34757 - if (tipc_sk_type_connectionless(sk)) {
34758 - memcpy(&tsk->peer, dest, destlen);
34759 - goto exit;
34760 -+ } else if (dst->addrtype == TIPC_SERVICE_RANGE) {
34761 -+ res = -EINVAL;
34762 -+ goto exit;
34763 - }
34764 -
34765 - previous = sk->sk_state;
34766 -diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c
34767 -index a457c0fbbef1..f5edb213d760 100644
34768 ---- a/net/tipc/topsrv.c
34769 -+++ b/net/tipc/topsrv.c
34770 -@@ -365,6 +365,7 @@ static int tipc_conn_rcv_sub(struct tipc_topsrv *srv,
34771 - struct tipc_subscription *sub;
34772 -
34773 - if (tipc_sub_read(s, filter) & TIPC_SUB_CANCEL) {
34774 -+ s->filter &= __constant_ntohl(~TIPC_SUB_CANCEL);
34775 - tipc_conn_delete_sub(con, s);
34776 - return 0;
34777 - }
34778 -diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
34779 -index 3ae3a33da70b..602715fc9a75 100644
34780 ---- a/net/vmw_vsock/virtio_transport_common.c
34781 -+++ b/net/vmw_vsock/virtio_transport_common.c
34782 -@@ -662,6 +662,8 @@ static int virtio_transport_reset(struct vsock_sock *vsk,
34783 - */
34784 - static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)
34785 - {
34786 -+ const struct virtio_transport *t;
34787 -+ struct virtio_vsock_pkt *reply;
34788 - struct virtio_vsock_pkt_info info = {
34789 - .op = VIRTIO_VSOCK_OP_RST,
34790 - .type = le16_to_cpu(pkt->hdr.type),
34791 -@@ -672,15 +674,21 @@ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)
34792 - if (le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_RST)
34793 - return 0;
34794 -
34795 -- pkt = virtio_transport_alloc_pkt(&info, 0,
34796 -- le64_to_cpu(pkt->hdr.dst_cid),
34797 -- le32_to_cpu(pkt->hdr.dst_port),
34798 -- le64_to_cpu(pkt->hdr.src_cid),
34799 -- le32_to_cpu(pkt->hdr.src_port));
34800 -- if (!pkt)
34801 -+ reply = virtio_transport_alloc_pkt(&info, 0,
34802 -+ le64_to_cpu(pkt->hdr.dst_cid),
34803 -+ le32_to_cpu(pkt->hdr.dst_port),
34804 -+ le64_to_cpu(pkt->hdr.src_cid),
34805 -+ le32_to_cpu(pkt->hdr.src_port));
34806 -+ if (!reply)
34807 - return -ENOMEM;
34808 -
34809 -- return virtio_transport_get_ops()->send_pkt(pkt);
34810 -+ t = virtio_transport_get_ops();
34811 -+ if (!t) {
34812 -+ virtio_transport_free_pkt(reply);
34813 -+ return -ENOTCONN;
34814 -+ }
34815 -+
34816 -+ return t->send_pkt(reply);
34817 - }
34818 -
34819 - static void virtio_transport_wait_close(struct sock *sk, long timeout)
34820 -diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
34821 -index eff31348e20b..20a511398389 100644
34822 ---- a/net/x25/af_x25.c
34823 -+++ b/net/x25/af_x25.c
34824 -@@ -820,8 +820,13 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
34825 - sock->state = SS_CONNECTED;
34826 - rc = 0;
34827 - out_put_neigh:
34828 -- if (rc)
34829 -+ if (rc) {
34830 -+ read_lock_bh(&x25_list_lock);
34831 - x25_neigh_put(x25->neighbour);
34832 -+ x25->neighbour = NULL;
34833 -+ read_unlock_bh(&x25_list_lock);
34834 -+ x25->state = X25_STATE_0;
34835 -+ }
34836 - out_put_route:
34837 - x25_route_put(rt);
34838 - out:
34839 -diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
34840 -index 85e4fe4f18cc..f3031c8907d9 100644
34841 ---- a/net/xdp/xsk.c
34842 -+++ b/net/xdp/xsk.c
34843 -@@ -407,6 +407,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
34844 - if (sxdp->sxdp_family != AF_XDP)
34845 - return -EINVAL;
34846 -
34847 -+ flags = sxdp->sxdp_flags;
34848 -+ if (flags & ~(XDP_SHARED_UMEM | XDP_COPY | XDP_ZEROCOPY))
34849 -+ return -EINVAL;
34850 -+
34851 - mutex_lock(&xs->mutex);
34852 - if (xs->dev) {
34853 - err = -EBUSY;
34854 -@@ -425,7 +429,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
34855 - }
34856 -
34857 - qid = sxdp->sxdp_queue_id;
34858 -- flags = sxdp->sxdp_flags;
34859 -
34860 - if (flags & XDP_SHARED_UMEM) {
34861 - struct xdp_sock *umem_xs;
34862 -diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
34863 -index 7aad82406422..d3319a80788a 100644
34864 ---- a/scripts/gdb/linux/constants.py.in
34865 -+++ b/scripts/gdb/linux/constants.py.in
34866 -@@ -37,12 +37,12 @@
34867 - import gdb
34868 -
34869 - /* linux/fs.h */
34870 --LX_VALUE(MS_RDONLY)
34871 --LX_VALUE(MS_SYNCHRONOUS)
34872 --LX_VALUE(MS_MANDLOCK)
34873 --LX_VALUE(MS_DIRSYNC)
34874 --LX_VALUE(MS_NOATIME)
34875 --LX_VALUE(MS_NODIRATIME)
34876 -+LX_VALUE(SB_RDONLY)
34877 -+LX_VALUE(SB_SYNCHRONOUS)
34878 -+LX_VALUE(SB_MANDLOCK)
34879 -+LX_VALUE(SB_DIRSYNC)
34880 -+LX_VALUE(SB_NOATIME)
34881 -+LX_VALUE(SB_NODIRATIME)
34882 -
34883 - /* linux/mount.h */
34884 - LX_VALUE(MNT_NOSUID)
34885 -diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py
34886 -index 0aebd7565b03..2f01a958eb22 100644
34887 ---- a/scripts/gdb/linux/proc.py
34888 -+++ b/scripts/gdb/linux/proc.py
34889 -@@ -114,11 +114,11 @@ def info_opts(lst, opt):
34890 - return opts
34891 -
34892 -
34893 --FS_INFO = {constants.LX_MS_SYNCHRONOUS: ",sync",
34894 -- constants.LX_MS_MANDLOCK: ",mand",
34895 -- constants.LX_MS_DIRSYNC: ",dirsync",
34896 -- constants.LX_MS_NOATIME: ",noatime",
34897 -- constants.LX_MS_NODIRATIME: ",nodiratime"}
34898 -+FS_INFO = {constants.LX_SB_SYNCHRONOUS: ",sync",
34899 -+ constants.LX_SB_MANDLOCK: ",mand",
34900 -+ constants.LX_SB_DIRSYNC: ",dirsync",
34901 -+ constants.LX_SB_NOATIME: ",noatime",
34902 -+ constants.LX_SB_NODIRATIME: ",nodiratime"}
34903 -
34904 - MNT_INFO = {constants.LX_MNT_NOSUID: ",nosuid",
34905 - constants.LX_MNT_NODEV: ",nodev",
34906 -@@ -184,7 +184,7 @@ values of that process namespace"""
34907 - fstype = superblock['s_type']['name'].string()
34908 - s_flags = int(superblock['s_flags'])
34909 - m_flags = int(vfs['mnt']['mnt_flags'])
34910 -- rd = "ro" if (s_flags & constants.LX_MS_RDONLY) else "rw"
34911 -+ rd = "ro" if (s_flags & constants.LX_SB_RDONLY) else "rw"
34912 -
34913 - gdb.write(
34914 - "{} {} {} {}{}{} 0 0\n"
34915 -diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
34916 -index 26bf886bd168..588a3bc29ecc 100644
34917 ---- a/scripts/mod/modpost.c
34918 -+++ b/scripts/mod/modpost.c
34919 -@@ -640,7 +640,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
34920 - info->sechdrs[sym->st_shndx].sh_offset -
34921 - (info->hdr->e_type != ET_REL ?
34922 - info->sechdrs[sym->st_shndx].sh_addr : 0);
34923 -- crc = *crcp;
34924 -+ crc = TO_NATIVE(*crcp);
34925 - }
34926 - sym_update_crc(symname + strlen("__crc_"), mod, crc,
34927 - export);
34928 diff --git a/scripts/package/Makefile b/scripts/package/Makefile
34929 index 453fecee62f0..aa39c2b5e46a 100644
34930 --- a/scripts/package/Makefile
34931 @@ -33693,226 +4887,6 @@ index edcad61fe3cd..f030961c5165 100755
34932
34933 clean:
34934 rm -rf debian/*tmp debian/files
34935 -diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
34936 -index 379682e2a8d5..f6c2bcb2ab14 100644
34937 ---- a/security/apparmor/policy_unpack.c
34938 -+++ b/security/apparmor/policy_unpack.c
34939 -@@ -579,6 +579,7 @@ fail:
34940 - kfree(profile->secmark[i].label);
34941 - kfree(profile->secmark);
34942 - profile->secmark_count = 0;
34943 -+ profile->secmark = NULL;
34944 - }
34945 -
34946 - e->pos = pos;
34947 -diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
34948 -index f0e36c3492ba..07b11b5aaf1f 100644
34949 ---- a/security/selinux/hooks.c
34950 -+++ b/security/selinux/hooks.c
34951 -@@ -959,8 +959,11 @@ static int selinux_sb_clone_mnt_opts(const struct super_block *oldsb,
34952 - BUG_ON(!(oldsbsec->flags & SE_SBINITIALIZED));
34953 -
34954 - /* if fs is reusing a sb, make sure that the contexts match */
34955 -- if (newsbsec->flags & SE_SBINITIALIZED)
34956 -+ if (newsbsec->flags & SE_SBINITIALIZED) {
34957 -+ if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) && !set_context)
34958 -+ *set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
34959 - return selinux_cmp_sb_context(oldsb, newsb);
34960 -+ }
34961 -
34962 - mutex_lock(&newsbsec->lock);
34963 -
34964 -@@ -3241,12 +3244,16 @@ static int selinux_inode_setsecurity(struct inode *inode, const char *name,
34965 - const void *value, size_t size, int flags)
34966 - {
34967 - struct inode_security_struct *isec = inode_security_novalidate(inode);
34968 -+ struct superblock_security_struct *sbsec = inode->i_sb->s_security;
34969 - u32 newsid;
34970 - int rc;
34971 -
34972 - if (strcmp(name, XATTR_SELINUX_SUFFIX))
34973 - return -EOPNOTSUPP;
34974 -
34975 -+ if (!(sbsec->flags & SBLABEL_MNT))
34976 -+ return -EOPNOTSUPP;
34977 -+
34978 - if (!value || !size)
34979 - return -EACCES;
34980 -
34981 -@@ -5120,6 +5127,9 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
34982 - return -EINVAL;
34983 - }
34984 -
34985 -+ if (walk_size + len > addrlen)
34986 -+ return -EINVAL;
34987 -+
34988 - err = -EINVAL;
34989 - switch (optname) {
34990 - /* Bind checks */
34991 -@@ -6392,7 +6402,10 @@ static void selinux_inode_invalidate_secctx(struct inode *inode)
34992 - */
34993 - static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
34994 - {
34995 -- return selinux_inode_setsecurity(inode, XATTR_SELINUX_SUFFIX, ctx, ctxlen, 0);
34996 -+ int rc = selinux_inode_setsecurity(inode, XATTR_SELINUX_SUFFIX,
34997 -+ ctx, ctxlen, 0);
34998 -+ /* Do not return error when suppressing label (SBLABEL_MNT not set). */
34999 -+ return rc == -EOPNOTSUPP ? 0 : rc;
35000 - }
35001 -
35002 - /*
35003 -diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
35004 -index 9f0c480489ef..9cbf6927abe9 100644
35005 ---- a/sound/ac97/bus.c
35006 -+++ b/sound/ac97/bus.c
35007 -@@ -84,7 +84,7 @@ ac97_of_get_child_device(struct ac97_controller *ac97_ctrl, int idx,
35008 - if ((idx != of_property_read_u32(node, "reg", &reg)) ||
35009 - !of_device_is_compatible(node, compat))
35010 - continue;
35011 -- return of_node_get(node);
35012 -+ return node;
35013 - }
35014 -
35015 - return NULL;
35016 -diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
35017 -index 467039b342b5..41abb8bd466a 100644
35018 ---- a/sound/core/oss/pcm_oss.c
35019 -+++ b/sound/core/oss/pcm_oss.c
35020 -@@ -940,6 +940,28 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
35021 - oss_frame_size = snd_pcm_format_physical_width(params_format(params)) *
35022 - params_channels(params) / 8;
35023 -
35024 -+ err = snd_pcm_oss_period_size(substream, params, sparams);
35025 -+ if (err < 0)
35026 -+ goto failure;
35027 -+
35028 -+ n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
35029 -+ err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
35030 -+ if (err < 0)
35031 -+ goto failure;
35032 -+
35033 -+ err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
35034 -+ runtime->oss.periods, NULL);
35035 -+ if (err < 0)
35036 -+ goto failure;
35037 -+
35038 -+ snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
35039 -+
35040 -+ err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams);
35041 -+ if (err < 0) {
35042 -+ pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
35043 -+ goto failure;
35044 -+ }
35045 -+
35046 - #ifdef CONFIG_SND_PCM_OSS_PLUGINS
35047 - snd_pcm_oss_plugin_clear(substream);
35048 - if (!direct) {
35049 -@@ -974,27 +996,6 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
35050 - }
35051 - #endif
35052 -
35053 -- err = snd_pcm_oss_period_size(substream, params, sparams);
35054 -- if (err < 0)
35055 -- goto failure;
35056 --
35057 -- n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
35058 -- err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
35059 -- if (err < 0)
35060 -- goto failure;
35061 --
35062 -- err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
35063 -- runtime->oss.periods, NULL);
35064 -- if (err < 0)
35065 -- goto failure;
35066 --
35067 -- snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
35068 --
35069 -- if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) {
35070 -- pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
35071 -- goto failure;
35072 -- }
35073 --
35074 - if (runtime->oss.trigger) {
35075 - sw_params->start_threshold = 1;
35076 - } else {
35077 -diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
35078 -index 818dff1de545..e08c6c6ca029 100644
35079 ---- a/sound/core/pcm_native.c
35080 -+++ b/sound/core/pcm_native.c
35081 -@@ -1426,8 +1426,15 @@ static int snd_pcm_pause(struct snd_pcm_substream *substream, int push)
35082 - static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state)
35083 - {
35084 - struct snd_pcm_runtime *runtime = substream->runtime;
35085 -- if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
35086 -+ switch (runtime->status->state) {
35087 -+ case SNDRV_PCM_STATE_SUSPENDED:
35088 -+ return -EBUSY;
35089 -+ /* unresumable PCM state; return -EBUSY for skipping suspend */
35090 -+ case SNDRV_PCM_STATE_OPEN:
35091 -+ case SNDRV_PCM_STATE_SETUP:
35092 -+ case SNDRV_PCM_STATE_DISCONNECTED:
35093 - return -EBUSY;
35094 -+ }
35095 - runtime->trigger_master = substream;
35096 - return 0;
35097 - }
35098 -@@ -1506,6 +1513,14 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)
35099 - /* FIXME: the open/close code should lock this as well */
35100 - if (substream->runtime == NULL)
35101 - continue;
35102 -+
35103 -+ /*
35104 -+ * Skip BE dai link PCM's that are internal and may
35105 -+ * not have their substream ops set.
35106 -+ */
35107 -+ if (!substream->ops)
35108 -+ continue;
35109 -+
35110 - err = snd_pcm_suspend(substream);
35111 - if (err < 0 && err != -EBUSY)
35112 - return err;
35113 -diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
35114 -index ee601d7f0926..c0690d1ecd55 100644
35115 ---- a/sound/core/rawmidi.c
35116 -+++ b/sound/core/rawmidi.c
35117 -@@ -30,6 +30,7 @@
35118 - #include <linux/module.h>
35119 - #include <linux/delay.h>
35120 - #include <linux/mm.h>
35121 -+#include <linux/nospec.h>
35122 - #include <sound/rawmidi.h>
35123 - #include <sound/info.h>
35124 - #include <sound/control.h>
35125 -@@ -601,6 +602,7 @@ static int __snd_rawmidi_info_select(struct snd_card *card,
35126 - return -ENXIO;
35127 - if (info->stream < 0 || info->stream > 1)
35128 - return -EINVAL;
35129 -+ info->stream = array_index_nospec(info->stream, 2);
35130 - pstr = &rmidi->streams[info->stream];
35131 - if (pstr->substream_count == 0)
35132 - return -ENOENT;
35133 -diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
35134 -index 278ebb993122..c93945917235 100644
35135 ---- a/sound/core/seq/oss/seq_oss_synth.c
35136 -+++ b/sound/core/seq/oss/seq_oss_synth.c
35137 -@@ -617,13 +617,14 @@ int
35138 - snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf)
35139 - {
35140 - struct seq_oss_synth *rec;
35141 -+ struct seq_oss_synthinfo *info = get_synthinfo_nospec(dp, dev);
35142 -
35143 -- if (dev < 0 || dev >= dp->max_synthdev)
35144 -+ if (!info)
35145 - return -ENXIO;
35146 -
35147 -- if (dp->synths[dev].is_midi) {
35148 -+ if (info->is_midi) {
35149 - struct midi_info minf;
35150 -- snd_seq_oss_midi_make_info(dp, dp->synths[dev].midi_mapped, &minf);
35151 -+ snd_seq_oss_midi_make_info(dp, info->midi_mapped, &minf);
35152 - inf->synth_type = SYNTH_TYPE_MIDI;
35153 - inf->synth_subtype = 0;
35154 - inf->nr_voices = 16;
35155 diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
35156 index 7d4640d1fe9f..38e7deab6384 100644
35157 --- a/sound/core/seq/seq_clientmgr.c
35158 @@ -33944,268 +4918,11 @@ index 7d4640d1fe9f..38e7deab6384 100644
35159 queuefree(q);
35160
35161 return 0;
35162 -diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
35163 -index d91874275d2c..5b46e8dcc2dd 100644
35164 ---- a/sound/firewire/bebob/bebob.c
35165 -+++ b/sound/firewire/bebob/bebob.c
35166 -@@ -448,7 +448,19 @@ static const struct ieee1394_device_id bebob_id_table[] = {
35167 - /* Focusrite, SaffirePro 26 I/O */
35168 - SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000003, &saffirepro_26_spec),
35169 - /* Focusrite, SaffirePro 10 I/O */
35170 -- SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, 0x00000006, &saffirepro_10_spec),
35171 -+ {
35172 -+ // The combination of vendor_id and model_id is the same as the
35173 -+ // same as the one of Liquid Saffire 56.
35174 -+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
35175 -+ IEEE1394_MATCH_MODEL_ID |
35176 -+ IEEE1394_MATCH_SPECIFIER_ID |
35177 -+ IEEE1394_MATCH_VERSION,
35178 -+ .vendor_id = VEN_FOCUSRITE,
35179 -+ .model_id = 0x000006,
35180 -+ .specifier_id = 0x00a02d,
35181 -+ .version = 0x010001,
35182 -+ .driver_data = (kernel_ulong_t)&saffirepro_10_spec,
35183 -+ },
35184 - /* Focusrite, Saffire(no label and LE) */
35185 - SND_BEBOB_DEV_ENTRY(VEN_FOCUSRITE, MODEL_FOCUSRITE_SAFFIRE_BOTH,
35186 - &saffire_spec),
35187 -diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
35188 -index ed50b222d36e..eee184b05d93 100644
35189 ---- a/sound/firewire/dice/dice.c
35190 -+++ b/sound/firewire/dice/dice.c
35191 -@@ -18,6 +18,7 @@ MODULE_LICENSE("GPL v2");
35192 - #define OUI_ALESIS 0x000595
35193 - #define OUI_MAUDIO 0x000d6c
35194 - #define OUI_MYTEK 0x001ee8
35195 -+#define OUI_SSL 0x0050c2 // Actually ID reserved by IEEE.
35196 -
35197 - #define DICE_CATEGORY_ID 0x04
35198 - #define WEISS_CATEGORY_ID 0x00
35199 -@@ -196,7 +197,7 @@ static int dice_probe(struct fw_unit *unit,
35200 - struct snd_dice *dice;
35201 - int err;
35202 -
35203 -- if (!entry->driver_data) {
35204 -+ if (!entry->driver_data && entry->vendor_id != OUI_SSL) {
35205 - err = check_dice_category(unit);
35206 - if (err < 0)
35207 - return -ENODEV;
35208 -@@ -361,6 +362,15 @@ static const struct ieee1394_device_id dice_id_table[] = {
35209 - .model_id = 0x000002,
35210 - .driver_data = (kernel_ulong_t)snd_dice_detect_mytek_formats,
35211 - },
35212 -+ // Solid State Logic, Duende Classic and Mini.
35213 -+ // NOTE: each field of GUID in config ROM is not compliant to standard
35214 -+ // DICE scheme.
35215 -+ {
35216 -+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
35217 -+ IEEE1394_MATCH_MODEL_ID,
35218 -+ .vendor_id = OUI_SSL,
35219 -+ .model_id = 0x000070,
35220 -+ },
35221 - {
35222 - .match_flags = IEEE1394_MATCH_VERSION,
35223 - .version = DICE_INTERFACE,
35224 -diff --git a/sound/firewire/motu/amdtp-motu.c b/sound/firewire/motu/amdtp-motu.c
35225 -index f0555a24d90e..6c9b743ea74b 100644
35226 ---- a/sound/firewire/motu/amdtp-motu.c
35227 -+++ b/sound/firewire/motu/amdtp-motu.c
35228 -@@ -136,7 +136,9 @@ static void read_pcm_s32(struct amdtp_stream *s,
35229 - byte = (u8 *)buffer + p->pcm_byte_offset;
35230 -
35231 - for (c = 0; c < channels; ++c) {
35232 -- *dst = (byte[0] << 24) | (byte[1] << 16) | byte[2];
35233 -+ *dst = (byte[0] << 24) |
35234 -+ (byte[1] << 16) |
35235 -+ (byte[2] << 8);
35236 - byte += 3;
35237 - dst++;
35238 - }
35239 -diff --git a/sound/firewire/motu/motu.c b/sound/firewire/motu/motu.c
35240 -index 220e61926ea4..513291ba0ab0 100644
35241 ---- a/sound/firewire/motu/motu.c
35242 -+++ b/sound/firewire/motu/motu.c
35243 -@@ -36,7 +36,7 @@ static void name_card(struct snd_motu *motu)
35244 - fw_csr_iterator_init(&it, motu->unit->directory);
35245 - while (fw_csr_iterator_next(&it, &key, &val)) {
35246 - switch (key) {
35247 -- case CSR_VERSION:
35248 -+ case CSR_MODEL:
35249 - version = val;
35250 - break;
35251 - }
35252 -@@ -46,7 +46,7 @@ static void name_card(struct snd_motu *motu)
35253 - strcpy(motu->card->shortname, motu->spec->name);
35254 - strcpy(motu->card->mixername, motu->spec->name);
35255 - snprintf(motu->card->longname, sizeof(motu->card->longname),
35256 -- "MOTU %s (version:%d), GUID %08x%08x at %s, S%d",
35257 -+ "MOTU %s (version:%06x), GUID %08x%08x at %s, S%d",
35258 - motu->spec->name, version,
35259 - fw_dev->config_rom[3], fw_dev->config_rom[4],
35260 - dev_name(&motu->unit->device), 100 << fw_dev->max_speed);
35261 -@@ -237,20 +237,20 @@ static const struct snd_motu_spec motu_audio_express = {
35262 - #define SND_MOTU_DEV_ENTRY(model, data) \
35263 - { \
35264 - .match_flags = IEEE1394_MATCH_VENDOR_ID | \
35265 -- IEEE1394_MATCH_MODEL_ID | \
35266 -- IEEE1394_MATCH_SPECIFIER_ID, \
35267 -+ IEEE1394_MATCH_SPECIFIER_ID | \
35268 -+ IEEE1394_MATCH_VERSION, \
35269 - .vendor_id = OUI_MOTU, \
35270 -- .model_id = model, \
35271 - .specifier_id = OUI_MOTU, \
35272 -+ .version = model, \
35273 - .driver_data = (kernel_ulong_t)data, \
35274 - }
35275 -
35276 - static const struct ieee1394_device_id motu_id_table[] = {
35277 -- SND_MOTU_DEV_ENTRY(0x101800, &motu_828mk2),
35278 -- SND_MOTU_DEV_ENTRY(0x107800, &snd_motu_spec_traveler),
35279 -- SND_MOTU_DEV_ENTRY(0x106800, &motu_828mk3), /* FireWire only. */
35280 -- SND_MOTU_DEV_ENTRY(0x100800, &motu_828mk3), /* Hybrid. */
35281 -- SND_MOTU_DEV_ENTRY(0x104800, &motu_audio_express),
35282 -+ SND_MOTU_DEV_ENTRY(0x000003, &motu_828mk2),
35283 -+ SND_MOTU_DEV_ENTRY(0x000009, &snd_motu_spec_traveler),
35284 -+ SND_MOTU_DEV_ENTRY(0x000015, &motu_828mk3), /* FireWire only. */
35285 -+ SND_MOTU_DEV_ENTRY(0x000035, &motu_828mk3), /* Hybrid. */
35286 -+ SND_MOTU_DEV_ENTRY(0x000033, &motu_audio_express),
35287 - { }
35288 - };
35289 - MODULE_DEVICE_TABLE(ieee1394, motu_id_table);
35290 -diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c
35291 -index 617ff1aa818f..27eb0270a711 100644
35292 ---- a/sound/hda/hdac_i915.c
35293 -+++ b/sound/hda/hdac_i915.c
35294 -@@ -144,9 +144,9 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
35295 - return -ENODEV;
35296 - if (!acomp->ops) {
35297 - request_module("i915");
35298 -- /* 10s timeout */
35299 -+ /* 60s timeout */
35300 - wait_for_completion_timeout(&bind_complete,
35301 -- msecs_to_jiffies(10 * 1000));
35302 -+ msecs_to_jiffies(60 * 1000));
35303 - }
35304 - if (!acomp->ops) {
35305 - dev_info(bus->dev, "couldn't bind with audio component\n");
35306 -diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
35307 -index 9f8d59e7e89f..b238e903b9d7 100644
35308 ---- a/sound/pci/hda/hda_codec.c
35309 -+++ b/sound/pci/hda/hda_codec.c
35310 -@@ -2917,6 +2917,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
35311 - hda_jackpoll_work(&codec->jackpoll_work.work);
35312 - else
35313 - snd_hda_jack_report_sync(codec);
35314 -+ codec->core.dev.power.power_state = PMSG_ON;
35315 - snd_hdac_leave_pm(&codec->core);
35316 - }
35317 -
35318 -@@ -2950,10 +2951,62 @@ static int hda_codec_runtime_resume(struct device *dev)
35319 - }
35320 - #endif /* CONFIG_PM */
35321 -
35322 -+#ifdef CONFIG_PM_SLEEP
35323 -+static int hda_codec_force_resume(struct device *dev)
35324 -+{
35325 -+ int ret;
35326 -+
35327 -+ /* The get/put pair below enforces the runtime resume even if the
35328 -+ * device hasn't been used at suspend time. This trick is needed to
35329 -+ * update the jack state change during the sleep.
35330 -+ */
35331 -+ pm_runtime_get_noresume(dev);
35332 -+ ret = pm_runtime_force_resume(dev);
35333 -+ pm_runtime_put(dev);
35334 -+ return ret;
35335 -+}
35336 -+
35337 -+static int hda_codec_pm_suspend(struct device *dev)
35338 -+{
35339 -+ dev->power.power_state = PMSG_SUSPEND;
35340 -+ return pm_runtime_force_suspend(dev);
35341 -+}
35342 -+
35343 -+static int hda_codec_pm_resume(struct device *dev)
35344 -+{
35345 -+ dev->power.power_state = PMSG_RESUME;
35346 -+ return hda_codec_force_resume(dev);
35347 -+}
35348 -+
35349 -+static int hda_codec_pm_freeze(struct device *dev)
35350 -+{
35351 -+ dev->power.power_state = PMSG_FREEZE;
35352 -+ return pm_runtime_force_suspend(dev);
35353 -+}
35354 -+
35355 -+static int hda_codec_pm_thaw(struct device *dev)
35356 -+{
35357 -+ dev->power.power_state = PMSG_THAW;
35358 -+ return hda_codec_force_resume(dev);
35359 -+}
35360 -+
35361 -+static int hda_codec_pm_restore(struct device *dev)
35362 -+{
35363 -+ dev->power.power_state = PMSG_RESTORE;
35364 -+ return hda_codec_force_resume(dev);
35365 -+}
35366 -+#endif /* CONFIG_PM_SLEEP */
35367 -+
35368 - /* referred in hda_bind.c */
35369 - const struct dev_pm_ops hda_codec_driver_pm = {
35370 -- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
35371 -- pm_runtime_force_resume)
35372 -+#ifdef CONFIG_PM_SLEEP
35373 -+ .suspend = hda_codec_pm_suspend,
35374 -+ .resume = hda_codec_pm_resume,
35375 -+ .freeze = hda_codec_pm_freeze,
35376 -+ .thaw = hda_codec_pm_thaw,
35377 -+ .poweroff = hda_codec_pm_suspend,
35378 -+ .restore = hda_codec_pm_restore,
35379 -+#endif /* CONFIG_PM_SLEEP */
35380 - SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume,
35381 - NULL)
35382 - };
35383 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
35384 -index e5c49003e75f..2ec91085fa3e 100644
35385 +index ece256a3b48f..2ec91085fa3e 100644
35386 --- a/sound/pci/hda/hda_intel.c
35387 +++ b/sound/pci/hda/hda_intel.c
35388 -@@ -947,7 +947,7 @@ static void __azx_runtime_suspend(struct azx *chip)
35389 - display_power(chip, false);
35390 - }
35391 -
35392 --static void __azx_runtime_resume(struct azx *chip)
35393 -+static void __azx_runtime_resume(struct azx *chip, bool from_rt)
35394 - {
35395 - struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
35396 - struct hdac_bus *bus = azx_bus(chip);
35397 -@@ -964,7 +964,7 @@ static void __azx_runtime_resume(struct azx *chip)
35398 - azx_init_pci(chip);
35399 - hda_intel_init_chip(chip, true);
35400 -
35401 -- if (status) {
35402 -+ if (status && from_rt) {
35403 - list_for_each_codec(codec, &chip->bus)
35404 - if (status & (1 << codec->addr))
35405 - schedule_delayed_work(&codec->jackpoll_work,
35406 -@@ -1016,7 +1016,7 @@ static int azx_resume(struct device *dev)
35407 - chip->msi = 0;
35408 - if (azx_acquire_irq(chip, 1) < 0)
35409 - return -EIO;
35410 -- __azx_runtime_resume(chip);
35411 -+ __azx_runtime_resume(chip, false);
35412 - snd_power_change_state(card, SNDRV_CTL_POWER_D0);
35413 -
35414 - trace_azx_resume(chip);
35415 -@@ -1081,7 +1081,7 @@ static int azx_runtime_resume(struct device *dev)
35416 - chip = card->private_data;
35417 - if (!azx_has_pm_runtime(chip))
35418 - return 0;
35419 -- __azx_runtime_resume(chip);
35420 -+ __azx_runtime_resume(chip, true);
35421 -
35422 - /* disable controller Wake Up event*/
35423 - azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
35424 -@@ -2142,12 +2142,18 @@ static struct snd_pci_quirk power_save_blacklist[] = {
35425 +@@ -2142,6 +2142,8 @@ static struct snd_pci_quirk power_save_blacklist[] = {
35426 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
35427 /* https://bugzilla.kernel.org/show_bug.cgi?id=199607 */
35428 SND_PCI_QUIRK(0x8086, 0x2057, "Intel NUC5i7RYB", 0),
35429 @@ -34213,79 +4930,21 @@ index e5c49003e75f..2ec91085fa3e 100644
35430 + SND_PCI_QUIRK(0x8086, 0x2064, "Intel SDP 8086:2064", 0),
35431 /* https://bugzilla.redhat.com/show_bug.cgi?id=1520902 */
35432 SND_PCI_QUIRK(0x8086, 0x2068, "Intel NUC7i3BNB", 0),
35433 -- /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
35434 -- SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0),
35435 /* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */
35436 - SND_PCI_QUIRK(0x17aa, 0x2227, "Lenovo X1 Carbon 3rd Gen", 0),
35437 -+ /* https://bugzilla.redhat.com/show_bug.cgi?id=1689623 */
35438 -+ SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0),
35439 -+ /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
35440 -+ SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0),
35441 +@@ -2150,6 +2152,8 @@ static struct snd_pci_quirk power_save_blacklist[] = {
35442 + SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0),
35443 + /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
35444 + SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0),
35445 + /* https://bugs.launchpad.net/bugs/1821663 */
35446 + SND_PCI_QUIRK(0x1631, 0xe017, "Packard Bell NEC IMEDIA 5204", 0),
35447 {}
35448 };
35449 #endif /* CONFIG_PM */
35450 -diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
35451 -index a4ee7656d9ee..fb65ad31e86c 100644
35452 ---- a/sound/pci/hda/patch_conexant.c
35453 -+++ b/sound/pci/hda/patch_conexant.c
35454 -@@ -936,6 +936,9 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
35455 - SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35456 - SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35457 - SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35458 -+ SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35459 -+ SND_PCI_QUIRK(0x103c, 0x8457, "HP Z2 G4 mini", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35460 -+ SND_PCI_QUIRK(0x103c, 0x8458, "HP Z2 G4 mini premium", CXT_FIXUP_HP_MIC_NO_PRESENCE),
35461 - SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
35462 - SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
35463 - SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
35464 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
35465 -index 1ffa36e987b4..84fae0df59e9 100644
35466 +index 00c27b3b8c14..84fae0df59e9 100644
35467 --- a/sound/pci/hda/patch_realtek.c
35468 +++ b/sound/pci/hda/patch_realtek.c
35469 -@@ -118,6 +118,7 @@ struct alc_spec {
35470 - unsigned int has_alc5505_dsp:1;
35471 - unsigned int no_depop_delay:1;
35472 - unsigned int done_hp_init:1;
35473 -+ unsigned int no_shutup_pins:1;
35474 -
35475 - /* for PLL fix */
35476 - hda_nid_t pll_nid;
35477 -@@ -476,6 +477,14 @@ static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
35478 - set_eapd(codec, *p, on);
35479 - }
35480 -
35481 -+static void alc_shutup_pins(struct hda_codec *codec)
35482 -+{
35483 -+ struct alc_spec *spec = codec->spec;
35484 -+
35485 -+ if (!spec->no_shutup_pins)
35486 -+ snd_hda_shutup_pins(codec);
35487 -+}
35488 -+
35489 - /* generic shutup callback;
35490 - * just turning off EAPD and a little pause for avoiding pop-noise
35491 - */
35492 -@@ -486,7 +495,7 @@ static void alc_eapd_shutup(struct hda_codec *codec)
35493 - alc_auto_setup_eapd(codec, false);
35494 - if (!spec->no_depop_delay)
35495 - msleep(200);
35496 -- snd_hda_shutup_pins(codec);
35497 -+ alc_shutup_pins(codec);
35498 - }
35499 -
35500 - /* generic EAPD initialization */
35501 -@@ -814,7 +823,7 @@ static inline void alc_shutup(struct hda_codec *codec)
35502 - if (spec && spec->shutup)
35503 - spec->shutup(codec);
35504 - else
35505 -- snd_hda_shutup_pins(codec);
35506 -+ alc_shutup_pins(codec);
35507 - }
35508 -
35509 - static void alc_reboot_notify(struct hda_codec *codec)
35510 -@@ -1855,8 +1864,8 @@ enum {
35511 +@@ -1864,8 +1864,8 @@ enum {
35512 ALC887_FIXUP_BASS_CHMAP,
35513 ALC1220_FIXUP_GB_DUAL_CODECS,
35514 ALC1220_FIXUP_CLEVO_P950,
35515 @@ -34296,7 +4955,7 @@ index 1ffa36e987b4..84fae0df59e9 100644
35516 };
35517
35518 static void alc889_fixup_coef(struct hda_codec *codec,
35519 -@@ -2061,7 +2070,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
35520 +@@ -2070,7 +2070,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
35521 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
35522 const struct hda_fixup *fix, int action);
35523
35524 @@ -34305,7 +4964,7 @@ index 1ffa36e987b4..84fae0df59e9 100644
35525 const struct hda_fixup *fix,
35526 int action)
35527 {
35528 -@@ -2313,18 +2322,18 @@ static const struct hda_fixup alc882_fixups[] = {
35529 +@@ -2322,18 +2322,18 @@ static const struct hda_fixup alc882_fixups[] = {
35530 .type = HDA_FIXUP_FUNC,
35531 .v.func = alc1220_fixup_clevo_p950,
35532 },
35533 @@ -34328,7 +4987,7 @@ index 1ffa36e987b4..84fae0df59e9 100644
35534 },
35535 };
35536
35537 -@@ -2402,8 +2411,9 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
35538 +@@ -2411,8 +2411,9 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
35539 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
35540 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
35541 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
35542 @@ -34340,424 +4999,41 @@ index 1ffa36e987b4..84fae0df59e9 100644
35543 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
35544 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
35545 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
35546 -@@ -2950,7 +2960,7 @@ static void alc269_shutup(struct hda_codec *codec)
35547 - (alc_get_coef0(codec) & 0x00ff) == 0x018) {
35548 - msleep(150);
35549 - }
35550 -- snd_hda_shutup_pins(codec);
35551 -+ alc_shutup_pins(codec);
35552 - }
35553 -
35554 - static struct coef_fw alc282_coefs[] = {
35555 -@@ -3053,14 +3063,15 @@ static void alc282_shutup(struct hda_codec *codec)
35556 - if (hp_pin_sense)
35557 - msleep(85);
35558 -
35559 -- snd_hda_codec_write(codec, hp_pin, 0,
35560 -- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35561 -+ if (!spec->no_shutup_pins)
35562 -+ snd_hda_codec_write(codec, hp_pin, 0,
35563 -+ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35564 -
35565 - if (hp_pin_sense)
35566 - msleep(100);
35567 -
35568 - alc_auto_setup_eapd(codec, false);
35569 -- snd_hda_shutup_pins(codec);
35570 -+ alc_shutup_pins(codec);
35571 - alc_write_coef_idx(codec, 0x78, coef78);
35572 - }
35573 -
35574 -@@ -3166,15 +3177,16 @@ static void alc283_shutup(struct hda_codec *codec)
35575 - if (hp_pin_sense)
35576 - msleep(100);
35577 -
35578 -- snd_hda_codec_write(codec, hp_pin, 0,
35579 -- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35580 -+ if (!spec->no_shutup_pins)
35581 -+ snd_hda_codec_write(codec, hp_pin, 0,
35582 -+ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35583 -
35584 - alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
35585 -
35586 - if (hp_pin_sense)
35587 - msleep(100);
35588 - alc_auto_setup_eapd(codec, false);
35589 -- snd_hda_shutup_pins(codec);
35590 -+ alc_shutup_pins(codec);
35591 - alc_write_coef_idx(codec, 0x43, 0x9614);
35592 - }
35593 -
35594 -@@ -3240,14 +3252,15 @@ static void alc256_shutup(struct hda_codec *codec)
35595 - /* NOTE: call this before clearing the pin, otherwise codec stalls */
35596 - alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
35597 -
35598 -- snd_hda_codec_write(codec, hp_pin, 0,
35599 -- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35600 -+ if (!spec->no_shutup_pins)
35601 -+ snd_hda_codec_write(codec, hp_pin, 0,
35602 -+ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35603 -
35604 - if (hp_pin_sense)
35605 - msleep(100);
35606 -
35607 - alc_auto_setup_eapd(codec, false);
35608 -- snd_hda_shutup_pins(codec);
35609 -+ alc_shutup_pins(codec);
35610 - }
35611 -
35612 - static void alc225_init(struct hda_codec *codec)
35613 -@@ -3334,7 +3347,7 @@ static void alc225_shutup(struct hda_codec *codec)
35614 - msleep(100);
35615 -
35616 - alc_auto_setup_eapd(codec, false);
35617 -- snd_hda_shutup_pins(codec);
35618 -+ alc_shutup_pins(codec);
35619 - }
35620 -
35621 - static void alc_default_init(struct hda_codec *codec)
35622 -@@ -3388,14 +3401,15 @@ static void alc_default_shutup(struct hda_codec *codec)
35623 - if (hp_pin_sense)
35624 - msleep(85);
35625 -
35626 -- snd_hda_codec_write(codec, hp_pin, 0,
35627 -- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35628 -+ if (!spec->no_shutup_pins)
35629 -+ snd_hda_codec_write(codec, hp_pin, 0,
35630 -+ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35631 -
35632 - if (hp_pin_sense)
35633 - msleep(100);
35634 -
35635 - alc_auto_setup_eapd(codec, false);
35636 -- snd_hda_shutup_pins(codec);
35637 -+ alc_shutup_pins(codec);
35638 - }
35639 -
35640 - static void alc294_hp_init(struct hda_codec *codec)
35641 -@@ -3412,8 +3426,9 @@ static void alc294_hp_init(struct hda_codec *codec)
35642 -
35643 - msleep(100);
35644 -
35645 -- snd_hda_codec_write(codec, hp_pin, 0,
35646 -- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35647 -+ if (!spec->no_shutup_pins)
35648 -+ snd_hda_codec_write(codec, hp_pin, 0,
35649 -+ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
35650 -
35651 - alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
35652 - alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
35653 -@@ -5007,16 +5022,12 @@ static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
35654 - }
35655 - }
35656 -
35657 --static void alc_no_shutup(struct hda_codec *codec)
35658 --{
35659 --}
35660 --
35661 - static void alc_fixup_no_shutup(struct hda_codec *codec,
35662 - const struct hda_fixup *fix, int action)
35663 - {
35664 - if (action == HDA_FIXUP_ACT_PRE_PROBE) {
35665 - struct alc_spec *spec = codec->spec;
35666 -- spec->shutup = alc_no_shutup;
35667 -+ spec->no_shutup_pins = 1;
35668 - }
35669 - }
35670 -
35671 -@@ -5479,7 +5490,7 @@ static void alc_headset_btn_callback(struct hda_codec *codec,
35672 - jack->jack->button_state = report;
35673 - }
35674 -
35675 --static void alc_fixup_headset_jack(struct hda_codec *codec,
35676 -+static void alc295_fixup_chromebook(struct hda_codec *codec,
35677 - const struct hda_fixup *fix, int action)
35678 - {
35679 -
35680 -@@ -5489,6 +5500,16 @@ static void alc_fixup_headset_jack(struct hda_codec *codec,
35681 - alc_headset_btn_callback);
35682 - snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false,
35683 - SND_JACK_HEADSET, alc_headset_btn_keymap);
35684 -+ switch (codec->core.vendor_id) {
35685 -+ case 0x10ec0295:
35686 -+ alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
35687 -+ alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
35688 -+ break;
35689 -+ case 0x10ec0236:
35690 -+ alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
35691 -+ alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
35692 -+ break;
35693 -+ }
35694 - break;
35695 - case HDA_FIXUP_ACT_INIT:
35696 - switch (codec->core.vendor_id) {
35697 -@@ -5641,6 +5662,7 @@ enum {
35698 - ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
35699 - ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
35700 - ALC233_FIXUP_LENOVO_MULTI_CODECS,
35701 -+ ALC233_FIXUP_ACER_HEADSET_MIC,
35702 - ALC294_FIXUP_LENOVO_MIC_LOCATION,
35703 - ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
35704 - ALC700_FIXUP_INTEL_REFERENCE,
35705 -@@ -5658,9 +5680,16 @@ enum {
35706 - ALC294_FIXUP_ASUS_MIC,
35707 - ALC294_FIXUP_ASUS_HEADSET_MIC,
35708 - ALC294_FIXUP_ASUS_SPK,
35709 -- ALC225_FIXUP_HEADSET_JACK,
35710 - ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
35711 - ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
35712 -+ ALC255_FIXUP_ACER_HEADSET_MIC,
35713 -+ ALC295_FIXUP_CHROME_BOOK,
35714 -+ ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
35715 -+ ALC225_FIXUP_WYSE_AUTO_MUTE,
35716 -+ ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
35717 -+ ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
35718 -+ ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
35719 -+ ALC299_FIXUP_PREDATOR_SPK,
35720 - };
35721 -
35722 - static const struct hda_fixup alc269_fixups[] = {
35723 -@@ -6461,6 +6490,16 @@ static const struct hda_fixup alc269_fixups[] = {
35724 - .type = HDA_FIXUP_FUNC,
35725 - .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
35726 - },
35727 -+ [ALC233_FIXUP_ACER_HEADSET_MIC] = {
35728 -+ .type = HDA_FIXUP_VERBS,
35729 -+ .v.verbs = (const struct hda_verb[]) {
35730 -+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
35731 -+ { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
35732 -+ { }
35733 -+ },
35734 -+ .chained = true,
35735 -+ .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
35736 -+ },
35737 - [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
35738 - .type = HDA_FIXUP_PINS,
35739 - .v.pins = (const struct hda_pintbl[]) {
35740 -@@ -6603,9 +6642,9 @@ static const struct hda_fixup alc269_fixups[] = {
35741 - .chained = true,
35742 - .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
35743 - },
35744 -- [ALC225_FIXUP_HEADSET_JACK] = {
35745 -+ [ALC295_FIXUP_CHROME_BOOK] = {
35746 - .type = HDA_FIXUP_FUNC,
35747 -- .v.func = alc_fixup_headset_jack,
35748 -+ .v.func = alc295_fixup_chromebook,
35749 - },
35750 - [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
35751 - .type = HDA_FIXUP_PINS,
35752 -@@ -6627,6 +6666,64 @@ static const struct hda_fixup alc269_fixups[] = {
35753 - .chained = true,
35754 - .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
35755 - },
35756 -+ [ALC255_FIXUP_ACER_HEADSET_MIC] = {
35757 -+ .type = HDA_FIXUP_PINS,
35758 -+ .v.pins = (const struct hda_pintbl[]) {
35759 -+ { 0x19, 0x03a11130 },
35760 -+ { 0x1a, 0x90a60140 }, /* use as internal mic */
35761 -+ { }
35762 -+ },
35763 -+ .chained = true,
35764 -+ .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
35765 -+ },
35766 -+ [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
35767 -+ .type = HDA_FIXUP_PINS,
35768 -+ .v.pins = (const struct hda_pintbl[]) {
35769 -+ { 0x16, 0x01011020 }, /* Rear Line out */
35770 -+ { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
35771 -+ { }
35772 -+ },
35773 -+ .chained = true,
35774 -+ .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
35775 -+ },
35776 -+ [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
35777 -+ .type = HDA_FIXUP_FUNC,
35778 -+ .v.func = alc_fixup_auto_mute_via_amp,
35779 -+ .chained = true,
35780 -+ .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
35781 -+ },
35782 -+ [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
35783 -+ .type = HDA_FIXUP_FUNC,
35784 -+ .v.func = alc_fixup_disable_mic_vref,
35785 -+ .chained = true,
35786 -+ .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
35787 -+ },
35788 -+ [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
35789 +@@ -5661,6 +5662,7 @@ enum {
35790 + ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
35791 + ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
35792 + ALC233_FIXUP_LENOVO_MULTI_CODECS,
35793 ++ ALC233_FIXUP_ACER_HEADSET_MIC,
35794 + ALC294_FIXUP_LENOVO_MIC_LOCATION,
35795 + ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
35796 + ALC700_FIXUP_INTEL_REFERENCE,
35797 +@@ -6488,6 +6490,16 @@ static const struct hda_fixup alc269_fixups[] = {
35798 + .type = HDA_FIXUP_FUNC,
35799 + .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
35800 + },
35801 ++ [ALC233_FIXUP_ACER_HEADSET_MIC] = {
35802 + .type = HDA_FIXUP_VERBS,
35803 + .v.verbs = (const struct hda_verb[]) {
35804 -+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
35805 -+ { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
35806 -+ { }
35807 -+ },
35808 -+ .chained = true,
35809 -+ .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
35810 -+ },
35811 -+ [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
35812 -+ .type = HDA_FIXUP_PINS,
35813 -+ .v.pins = (const struct hda_pintbl[]) {
35814 -+ { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
35815 ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
35816 ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
35817 + { }
35818 + },
35819 + .chained = true,
35820 -+ .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
35821 -+ },
35822 -+ [ALC299_FIXUP_PREDATOR_SPK] = {
35823 -+ .type = HDA_FIXUP_PINS,
35824 -+ .v.pins = (const struct hda_pintbl[]) {
35825 -+ { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
35826 -+ { }
35827 -+ }
35828 ++ .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
35829 + },
35830 - };
35831 -
35832 - static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35833 -@@ -6643,9 +6740,15 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35834 - SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
35835 - SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
35836 - SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
35837 -- SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
35838 -- SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
35839 -- SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
35840 -+ SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
35841 -+ SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
35842 -+ SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
35843 -+ SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35844 -+ SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35845 -+ SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35846 -+ SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35847 + [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
35848 + .type = HDA_FIXUP_PINS,
35849 + .v.pins = (const struct hda_pintbl[]) {
35850 +@@ -6735,6 +6747,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35851 + SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35852 + SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35853 + SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
35854 + SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
35855 -+ SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
35856 + SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
35857 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
35858 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
35859 - SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
35860 -@@ -6677,6 +6780,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35861 - SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
35862 - SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
35863 - SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
35864 -+ SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
35865 - SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
35866 - SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
35867 - SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
35868 -@@ -6689,6 +6793,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35869 - SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
35870 - SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
35871 - SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
35872 -+ SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
35873 -+ SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
35874 - SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
35875 - SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
35876 - SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
35877 -@@ -6751,11 +6857,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35878 - SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
35879 - SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
35880 - SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
35881 -+ SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35882 -+ SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35883 - SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
35884 - SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
35885 - SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
35886 -- SND_PCI_QUIRK(0x103c, 0x82bf, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35887 -- SND_PCI_QUIRK(0x103c, 0x82c0, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35888 -+ SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35889 -+ SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
35890 - SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
35891 - SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
35892 - SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
35893 -@@ -6771,7 +6879,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
35894 - SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
35895 - SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
35896 - SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
35897 -- SND_PCI_QUIRK(0x1043, 0x14a1, "ASUS UX533FD", ALC294_FIXUP_ASUS_SPK),
35898 - SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
35899 - SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
35900 - SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
35901 -@@ -7036,7 +7143,8 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
35902 - {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
35903 - {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
35904 - {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
35905 -- {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-sense-combo"},
35906 -+ {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"},
35907 -+ {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
35908 - {}
35909 - };
35910 - #define ALC225_STANDARD_PINS \
35911 -@@ -7257,6 +7365,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
35912 - {0x14, 0x90170110},
35913 - {0x1b, 0x90a70130},
35914 - {0x21, 0x03211020}),
35915 -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
35916 -+ {0x12, 0x90a60130},
35917 -+ {0x14, 0x90170110},
35918 -+ {0x21, 0x03211020}),
35919 -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
35920 -+ {0x12, 0x90a60130},
35921 -+ {0x14, 0x90170110},
35922 -+ {0x21, 0x04211020}),
35923 -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
35924 -+ {0x1a, 0x90a70130},
35925 -+ {0x1b, 0x90170110},
35926 -+ {0x21, 0x03211020}),
35927 - SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
35928 - {0x12, 0xb7a60130},
35929 - {0x13, 0xb8a61140},
35930 -@@ -7388,6 +7508,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
35931 - {0x14, 0x90170110},
35932 - {0x1b, 0x90a70130},
35933 - {0x21, 0x04211020}),
35934 -+ SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
35935 -+ {0x12, 0x90a60130},
35936 -+ {0x17, 0x90170110},
35937 -+ {0x21, 0x03211020}),
35938 - SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
35939 - {0x12, 0x90a60130},
35940 - {0x17, 0x90170110},
35941 -diff --git a/sound/soc/codecs/pcm186x.c b/sound/soc/codecs/pcm186x.c
35942 -index 809b7e9f03ca..c5fcc632f670 100644
35943 ---- a/sound/soc/codecs/pcm186x.c
35944 -+++ b/sound/soc/codecs/pcm186x.c
35945 -@@ -42,7 +42,7 @@ struct pcm186x_priv {
35946 - bool is_master_mode;
35947 - };
35948 -
35949 --static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 4000, 50);
35950 -+static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 50, 0);
35951 -
35952 - static const struct snd_kcontrol_new pcm1863_snd_controls[] = {
35953 - SOC_DOUBLE_R_S_TLV("ADC Capture Volume", PCM186X_PGA_VAL_CH1_L,
35954 -@@ -158,7 +158,7 @@ static const struct snd_soc_dapm_widget pcm1863_dapm_widgets[] = {
35955 - * Put the codec into SLEEP mode when not in use, allowing the
35956 - * Energysense mechanism to operate.
35957 - */
35958 -- SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1, 0),
35959 -+ SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1, 1),
35960 - };
35961 -
35962 - static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
35963 -@@ -184,8 +184,8 @@ static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
35964 - * Put the codec into SLEEP mode when not in use, allowing the
35965 - * Energysense mechanism to operate.
35966 - */
35967 -- SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1, 0),
35968 -- SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1, 0),
35969 -+ SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1, 1),
35970 -+ SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1, 1),
35971 - };
35972 -
35973 - static const struct snd_soc_dapm_route pcm1863_dapm_routes[] = {
35974 -diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
35975 -index 81f2fe2c6d23..60f87a0d99f4 100644
35976 ---- a/sound/soc/fsl/fsl-asoc-card.c
35977 -+++ b/sound/soc/fsl/fsl-asoc-card.c
35978 -@@ -689,6 +689,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
35979 - asrc_fail:
35980 - of_node_put(asrc_np);
35981 - of_node_put(codec_np);
35982 -+ put_device(&cpu_pdev->dev);
35983 - fail:
35984 - of_node_put(cpu_np);
35985 -
35986 diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
35987 -index 57b484768a58..3623aa9a6f2e 100644
35988 +index afe67c865330..3623aa9a6f2e 100644
35989 --- a/sound/soc/fsl/fsl_esai.c
35990 +++ b/sound/soc/fsl/fsl_esai.c
35991 @@ -54,6 +54,8 @@ struct fsl_esai {
35992 @@ -34793,32 +5069,7 @@ index 57b484768a58..3623aa9a6f2e 100644
35993
35994 return 0;
35995 }
35996 -@@ -398,7 +392,8 @@ static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
35997 - break;
35998 - case SND_SOC_DAIFMT_RIGHT_J:
35999 - /* Data on rising edge of bclk, frame high, right aligned */
36000 -- xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCR_xWA;
36001 -+ xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP;
36002 -+ xcr |= ESAI_xCR_xWA;
36003 - break;
36004 - case SND_SOC_DAIFMT_DSP_A:
36005 - /* Data on rising edge of bclk, frame high, 1clk before data */
36006 -@@ -455,12 +450,12 @@ static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
36007 - return -EINVAL;
36008 - }
36009 -
36010 -- mask = ESAI_xCR_xFSL | ESAI_xCR_xFSR;
36011 -+ mask = ESAI_xCR_xFSL | ESAI_xCR_xFSR | ESAI_xCR_xWA;
36012 - regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, mask, xcr);
36013 - regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, mask, xcr);
36014 -
36015 - mask = ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCCR_xFSP |
36016 -- ESAI_xCCR_xFSD | ESAI_xCCR_xCKD | ESAI_xCR_xWA;
36017 -+ ESAI_xCCR_xFSD | ESAI_xCCR_xCKD;
36018 - regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, mask, xccr);
36019 - regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, mask, xccr);
36020 -
36021 -@@ -595,6 +590,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
36022 +@@ -596,6 +590,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
36023 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
36024 u8 i, channels = substream->runtime->channels;
36025 u32 pins = DIV_ROUND_UP(channels, esai_priv->slots);
36026 @@ -34826,7 +5077,7 @@ index 57b484768a58..3623aa9a6f2e 100644
36027
36028 switch (cmd) {
36029 case SNDRV_PCM_TRIGGER_START:
36030 -@@ -607,15 +603,38 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
36031 +@@ -608,15 +603,38 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
36032 for (i = 0; tx && i < channels; i++)
36033 regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0);
36034
36035 @@ -34865,7 +5116,7 @@ index 57b484768a58..3623aa9a6f2e 100644
36036
36037 /* Disable and reset FIFO */
36038 regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx),
36039 -@@ -905,6 +924,15 @@ static int fsl_esai_probe(struct platform_device *pdev)
36040 +@@ -906,6 +924,15 @@ static int fsl_esai_probe(struct platform_device *pdev)
36041 return ret;
36042 }
36043
36044 @@ -34881,46 +5132,6 @@ index 57b484768a58..3623aa9a6f2e 100644
36045 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component,
36046 &fsl_esai_dai, 1);
36047 if (ret) {
36048 -diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
36049 -index c29200cf755a..9b9a7ec52905 100644
36050 ---- a/sound/soc/fsl/imx-sgtl5000.c
36051 -+++ b/sound/soc/fsl/imx-sgtl5000.c
36052 -@@ -108,6 +108,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
36053 - ret = -EPROBE_DEFER;
36054 - goto fail;
36055 - }
36056 -+ put_device(&ssi_pdev->dev);
36057 - codec_dev = of_find_i2c_device_by_node(codec_np);
36058 - if (!codec_dev) {
36059 - dev_err(&pdev->dev, "failed to find codec platform device\n");
36060 -diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
36061 -index b807a47515eb..336895f7fd1e 100644
36062 ---- a/sound/soc/generic/simple-card-utils.c
36063 -+++ b/sound/soc/generic/simple-card-utils.c
36064 -@@ -283,12 +283,20 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep)
36065 - /* use endpoint/port reg if exist */
36066 - ret = of_graph_parse_endpoint(ep, &info);
36067 - if (ret == 0) {
36068 -- if (info.id)
36069 -+ /*
36070 -+ * Because it will count port/endpoint if it doesn't have "reg".
36071 -+ * But, we can't judge whether it has "no reg", or "reg = <0>"
36072 -+ * only of_graph_parse_endpoint().
36073 -+ * We need to check "reg" property
36074 -+ */
36075 -+ if (of_get_property(ep, "reg", NULL))
36076 - return info.id;
36077 -- if (info.port)
36078 -+
36079 -+ node = of_get_parent(ep);
36080 -+ of_node_put(node);
36081 -+ if (of_get_property(node, "reg", NULL))
36082 - return info.port;
36083 - }
36084 --
36085 - node = of_graph_get_port_parent(ep);
36086 -
36087 - /*
36088 diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
36089 index 91a2436ce952..e9623da911d5 100644
36090 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
36091 @@ -34943,45 +5154,6 @@ index 91a2436ce952..e9623da911d5 100644
36092 .ops = &sst_platform_ops,
36093 .compr_ops = &sst_platform_compr_ops,
36094 .pcm_new = sst_pcm_new,
36095 -diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
36096 -index 4715527054e5..5661025e8cec 100644
36097 ---- a/sound/soc/qcom/common.c
36098 -+++ b/sound/soc/qcom/common.c
36099 -@@ -42,6 +42,9 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
36100 - link = card->dai_link;
36101 - for_each_child_of_node(dev->of_node, np) {
36102 - cpu = of_get_child_by_name(np, "cpu");
36103 -+ platform = of_get_child_by_name(np, "platform");
36104 -+ codec = of_get_child_by_name(np, "codec");
36105 -+
36106 - if (!cpu) {
36107 - dev_err(dev, "Can't find cpu DT node\n");
36108 - ret = -EINVAL;
36109 -@@ -63,8 +66,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
36110 - goto err;
36111 - }
36112 -
36113 -- platform = of_get_child_by_name(np, "platform");
36114 -- codec = of_get_child_by_name(np, "codec");
36115 - if (codec && platform) {
36116 - link->platform_of_node = of_parse_phandle(platform,
36117 - "sound-dai",
36118 -@@ -100,10 +101,15 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
36119 - link->dpcm_capture = 1;
36120 - link->stream_name = link->name;
36121 - link++;
36122 -+
36123 -+ of_node_put(cpu);
36124 -+ of_node_put(codec);
36125 -+ of_node_put(platform);
36126 - }
36127 -
36128 - return 0;
36129 - err:
36130 -+ of_node_put(np);
36131 - of_node_put(cpu);
36132 - of_node_put(codec);
36133 - of_node_put(platform);
36134 diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
36135 index a7f413cb704d..b14ab512c2ce 100644
36136 --- a/sound/xen/xen_snd_front_alsa.c
36137 @@ -34995,1024 +5167,3 @@ index a7f413cb704d..b14ab512c2ce 100644
36138 if (!stream->buffer)
36139 return -ENOMEM;
36140
36141 -diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
36142 -index 5467c6bf9ceb..bb9dca65eb5f 100644
36143 ---- a/tools/build/Makefile.feature
36144 -+++ b/tools/build/Makefile.feature
36145 -@@ -70,7 +70,6 @@ FEATURE_TESTS_BASIC := \
36146 - sched_getcpu \
36147 - sdt \
36148 - setns \
36149 -- libopencsd \
36150 - libaio
36151 -
36152 - # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
36153 -@@ -84,6 +83,7 @@ FEATURE_TESTS_EXTRA := \
36154 - libbabeltrace \
36155 - libbfd-liberty \
36156 - libbfd-liberty-z \
36157 -+ libopencsd \
36158 - libunwind-debug-frame \
36159 - libunwind-debug-frame-arm \
36160 - libunwind-debug-frame-aarch64 \
36161 -diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
36162 -index 20cdaa4fc112..e903b86b742f 100644
36163 ---- a/tools/build/feature/test-all.c
36164 -+++ b/tools/build/feature/test-all.c
36165 -@@ -170,14 +170,14 @@
36166 - # include "test-setns.c"
36167 - #undef main
36168 -
36169 --#define main main_test_libopencsd
36170 --# include "test-libopencsd.c"
36171 --#undef main
36172 --
36173 - #define main main_test_libaio
36174 - # include "test-libaio.c"
36175 - #undef main
36176 -
36177 -+#define main main_test_reallocarray
36178 -+# include "test-reallocarray.c"
36179 -+#undef main
36180 -+
36181 - int main(int argc, char *argv[])
36182 - {
36183 - main_test_libpython();
36184 -@@ -217,8 +217,8 @@ int main(int argc, char *argv[])
36185 - main_test_sched_getcpu();
36186 - main_test_sdt();
36187 - main_test_setns();
36188 -- main_test_libopencsd();
36189 - main_test_libaio();
36190 -+ main_test_reallocarray();
36191 -
36192 - return 0;
36193 - }
36194 -diff --git a/tools/build/feature/test-reallocarray.c b/tools/build/feature/test-reallocarray.c
36195 -index 8170de35150d..8f6743e31da7 100644
36196 ---- a/tools/build/feature/test-reallocarray.c
36197 -+++ b/tools/build/feature/test-reallocarray.c
36198 -@@ -6,3 +6,5 @@ int main(void)
36199 - {
36200 - return !!reallocarray(NULL, 1, 1);
36201 - }
36202 -+
36203 -+#undef _GNU_SOURCE
36204 -diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
36205 -index 34d9c3619c96..78fd86b85087 100644
36206 ---- a/tools/lib/bpf/Makefile
36207 -+++ b/tools/lib/bpf/Makefile
36208 -@@ -162,7 +162,8 @@ endif
36209 -
36210 - TARGETS = $(CMD_TARGETS)
36211 -
36212 --all: fixdep all_cmd
36213 -+all: fixdep
36214 -+ $(Q)$(MAKE) all_cmd
36215 -
36216 - all_cmd: $(CMD_TARGETS) check
36217 -
36218 -diff --git a/tools/lib/lockdep/run_tests.sh b/tools/lib/lockdep/run_tests.sh
36219 -index c8fbd0306960..11f425662b43 100755
36220 ---- a/tools/lib/lockdep/run_tests.sh
36221 -+++ b/tools/lib/lockdep/run_tests.sh
36222 -@@ -11,7 +11,7 @@ find tests -name '*.c' | sort | while read -r i; do
36223 - testname=$(basename "$i" .c)
36224 - echo -ne "$testname... "
36225 - if gcc -o "tests/$testname" -pthread "$i" liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &&
36226 -- timeout 1 "tests/$testname" 2>&1 | "tests/${testname}.sh"; then
36227 -+ timeout 1 "tests/$testname" 2>&1 | /bin/bash "tests/${testname}.sh"; then
36228 - echo "PASSED!"
36229 - else
36230 - echo "FAILED!"
36231 -@@ -24,7 +24,7 @@ find tests -name '*.c' | sort | while read -r i; do
36232 - echo -ne "(PRELOAD) $testname... "
36233 - if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
36234 - timeout 1 ./lockdep "tests/$testname" 2>&1 |
36235 -- "tests/${testname}.sh"; then
36236 -+ /bin/bash "tests/${testname}.sh"; then
36237 - echo "PASSED!"
36238 - else
36239 - echo "FAILED!"
36240 -@@ -37,7 +37,7 @@ find tests -name '*.c' | sort | while read -r i; do
36241 - echo -ne "(PRELOAD + Valgrind) $testname... "
36242 - if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
36243 - { timeout 10 valgrind --read-var-info=yes ./lockdep "./tests/$testname" >& "tests/${testname}.vg.out"; true; } &&
36244 -- "tests/${testname}.sh" < "tests/${testname}.vg.out" &&
36245 -+ /bin/bash "tests/${testname}.sh" < "tests/${testname}.vg.out" &&
36246 - ! grep -Eq '(^==[0-9]*== (Invalid |Uninitialised ))|Mismatched free|Source and destination overlap| UME ' "tests/${testname}.vg.out"; then
36247 - echo "PASSED!"
36248 - else
36249 -diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
36250 -index abd4fa5d3088..87494c7c619d 100644
36251 ---- a/tools/lib/traceevent/event-parse.c
36252 -+++ b/tools/lib/traceevent/event-parse.c
36253 -@@ -2457,7 +2457,7 @@ static int arg_num_eval(struct tep_print_arg *arg, long long *val)
36254 - static char *arg_eval (struct tep_print_arg *arg)
36255 - {
36256 - long long val;
36257 -- static char buf[20];
36258 -+ static char buf[24];
36259 -
36260 - switch (arg->type) {
36261 - case TEP_PRINT_ATOM:
36262 -diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
36263 -index c9d038f91af6..53f8be0f4a1f 100644
36264 ---- a/tools/objtool/Makefile
36265 -+++ b/tools/objtool/Makefile
36266 -@@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
36267 - OBJTOOL := $(OUTPUT)objtool
36268 - OBJTOOL_IN := $(OBJTOOL)-in.o
36269 -
36270 -+LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null)
36271 -+LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
36272 -+
36273 - all: $(OBJTOOL)
36274 -
36275 - INCLUDES := -I$(srctree)/tools/include \
36276 - -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
36277 - -I$(srctree)/tools/objtool/arch/$(ARCH)/include
36278 - WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
36279 --CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES)
36280 --LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
36281 -+CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
36282 -+LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
36283 -
36284 - # Allow old libelf to be used:
36285 - elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
36286 -diff --git a/tools/objtool/check.c b/tools/objtool/check.c
36287 -index 0414a0d52262..5dde107083c6 100644
36288 ---- a/tools/objtool/check.c
36289 -+++ b/tools/objtool/check.c
36290 -@@ -2184,9 +2184,10 @@ static void cleanup(struct objtool_file *file)
36291 - elf_close(file->elf);
36292 - }
36293 -
36294 -+static struct objtool_file file;
36295 -+
36296 - int check(const char *_objname, bool orc)
36297 - {
36298 -- struct objtool_file file;
36299 - int ret, warnings = 0;
36300 -
36301 - objname = _objname;
36302 -diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
36303 -index b441c88cafa1..cf4a8329c4c0 100644
36304 ---- a/tools/perf/Makefile.config
36305 -+++ b/tools/perf/Makefile.config
36306 -@@ -218,6 +218,8 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
36307 - FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
36308 - FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
36309 -
36310 -+FEATURE_CHECK_LDFLAGS-libaio = -lrt
36311 -+
36312 - CFLAGS += -fno-omit-frame-pointer
36313 - CFLAGS += -ggdb3
36314 - CFLAGS += -funwind-tables
36315 -@@ -386,7 +388,8 @@ ifeq ($(feature-setns), 1)
36316 - $(call detected,CONFIG_SETNS)
36317 - endif
36318 -
36319 --ifndef NO_CORESIGHT
36320 -+ifdef CORESIGHT
36321 -+ $(call feature_check,libopencsd)
36322 - ifeq ($(feature-libopencsd), 1)
36323 - CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
36324 - LDFLAGS += $(LIBOPENCSD_LDFLAGS)
36325 -diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
36326 -index 0ee6795d82cc..77f8f069f1e7 100644
36327 ---- a/tools/perf/Makefile.perf
36328 -+++ b/tools/perf/Makefile.perf
36329 -@@ -102,7 +102,7 @@ include ../scripts/utilities.mak
36330 - # When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
36331 - # llvm-config is not in $PATH.
36332 - #
36333 --# Define NO_CORESIGHT if you do not want support for CoreSight trace decoding.
36334 -+# Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
36335 - #
36336 - # Define NO_AIO if you do not want support of Posix AIO based trace
36337 - # streaming for record mode. Currently Posix AIO trace streaming is
36338 -diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
36339 -index d340d2e42776..13758a0b367b 100644
36340 ---- a/tools/perf/builtin-c2c.c
36341 -+++ b/tools/perf/builtin-c2c.c
36342 -@@ -2055,6 +2055,12 @@ static int setup_nodes(struct perf_session *session)
36343 - if (!set)
36344 - return -ENOMEM;
36345 -
36346 -+ nodes[node] = set;
36347 -+
36348 -+ /* empty node, skip */
36349 -+ if (cpu_map__empty(map))
36350 -+ continue;
36351 -+
36352 - for (cpu = 0; cpu < map->nr; cpu++) {
36353 - set_bit(map->map[cpu], set);
36354 -
36355 -@@ -2063,8 +2069,6 @@ static int setup_nodes(struct perf_session *session)
36356 -
36357 - cpu2node[map->map[cpu]] = node;
36358 - }
36359 --
36360 -- nodes[node] = set;
36361 - }
36362 -
36363 - setup_nodes_header();
36364 -diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
36365 -index ac221f137ed2..cff4d10daf49 100644
36366 ---- a/tools/perf/builtin-script.c
36367 -+++ b/tools/perf/builtin-script.c
36368 -@@ -148,6 +148,7 @@ static struct {
36369 - unsigned int print_ip_opts;
36370 - u64 fields;
36371 - u64 invalid_fields;
36372 -+ u64 user_set_fields;
36373 - } output[OUTPUT_TYPE_MAX] = {
36374 -
36375 - [PERF_TYPE_HARDWARE] = {
36376 -@@ -344,7 +345,7 @@ static int perf_evsel__do_check_stype(struct perf_evsel *evsel,
36377 - if (attr->sample_type & sample_type)
36378 - return 0;
36379 -
36380 -- if (output[type].user_set) {
36381 -+ if (output[type].user_set_fields & field) {
36382 - if (allow_user_set)
36383 - return 0;
36384 - evname = perf_evsel__name(evsel);
36385 -@@ -2627,10 +2628,13 @@ parse:
36386 - pr_warning("\'%s\' not valid for %s events. Ignoring.\n",
36387 - all_output_options[i].str, event_type(j));
36388 - } else {
36389 -- if (change == REMOVE)
36390 -+ if (change == REMOVE) {
36391 - output[j].fields &= ~all_output_options[i].field;
36392 -- else
36393 -+ output[j].user_set_fields &= ~all_output_options[i].field;
36394 -+ } else {
36395 - output[j].fields |= all_output_options[i].field;
36396 -+ output[j].user_set_fields |= all_output_options[i].field;
36397 -+ }
36398 - output[j].user_set = true;
36399 - output[j].wildcard_set = true;
36400 - }
36401 -diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
36402 -index b36061cd1ab8..91cdbf504535 100644
36403 ---- a/tools/perf/builtin-trace.c
36404 -+++ b/tools/perf/builtin-trace.c
36405 -@@ -1039,6 +1039,9 @@ static const size_t trace__entry_str_size = 2048;
36406 -
36407 - static struct file *thread_trace__files_entry(struct thread_trace *ttrace, int fd)
36408 - {
36409 -+ if (fd < 0)
36410 -+ return NULL;
36411 -+
36412 - if (fd > ttrace->files.max) {
36413 - struct file *nfiles = realloc(ttrace->files.table, (fd + 1) * sizeof(struct file));
36414 -
36415 -@@ -3865,7 +3868,8 @@ int cmd_trace(int argc, const char **argv)
36416 - goto init_augmented_syscall_tp;
36417 - }
36418 -
36419 -- if (strcmp(perf_evsel__name(evsel), "raw_syscalls:sys_enter") == 0) {
36420 -+ if (trace.syscalls.events.augmented->priv == NULL &&
36421 -+ strstr(perf_evsel__name(evsel), "syscalls:sys_enter")) {
36422 - struct perf_evsel *augmented = trace.syscalls.events.augmented;
36423 - if (perf_evsel__init_augmented_syscall_tp(augmented, evsel) ||
36424 - perf_evsel__init_augmented_syscall_tp_args(augmented))
36425 -diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
36426 -index 5cbba70bcdd0..ea7acf403727 100644
36427 ---- a/tools/perf/tests/evsel-tp-sched.c
36428 -+++ b/tools/perf/tests/evsel-tp-sched.c
36429 -@@ -43,7 +43,7 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes
36430 - return -1;
36431 - }
36432 -
36433 -- if (perf_evsel__test_field(evsel, "prev_comm", 16, true))
36434 -+ if (perf_evsel__test_field(evsel, "prev_comm", 16, false))
36435 - ret = -1;
36436 -
36437 - if (perf_evsel__test_field(evsel, "prev_pid", 4, true))
36438 -@@ -55,7 +55,7 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes
36439 - if (perf_evsel__test_field(evsel, "prev_state", sizeof(long), true))
36440 - ret = -1;
36441 -
36442 -- if (perf_evsel__test_field(evsel, "next_comm", 16, true))
36443 -+ if (perf_evsel__test_field(evsel, "next_comm", 16, false))
36444 - ret = -1;
36445 -
36446 - if (perf_evsel__test_field(evsel, "next_pid", 4, true))
36447 -@@ -73,7 +73,7 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes
36448 - return -1;
36449 - }
36450 -
36451 -- if (perf_evsel__test_field(evsel, "comm", 16, true))
36452 -+ if (perf_evsel__test_field(evsel, "comm", 16, false))
36453 - ret = -1;
36454 -
36455 - if (perf_evsel__test_field(evsel, "pid", 4, true))
36456 -diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c
36457 -index d66c66315987..ea68db08b8e7 100644
36458 ---- a/tools/perf/trace/beauty/msg_flags.c
36459 -+++ b/tools/perf/trace/beauty/msg_flags.c
36460 -@@ -29,7 +29,7 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
36461 - return scnprintf(bf, size, "NONE");
36462 - #define P_MSG_FLAG(n) \
36463 - if (flags & MSG_##n) { \
36464 -- printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
36465 -+ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
36466 - flags &= ~MSG_##n; \
36467 - }
36468 -
36469 -diff --git a/tools/perf/trace/beauty/waitid_options.c b/tools/perf/trace/beauty/waitid_options.c
36470 -index 6897fab40dcc..d4d10b33ba0e 100644
36471 ---- a/tools/perf/trace/beauty/waitid_options.c
36472 -+++ b/tools/perf/trace/beauty/waitid_options.c
36473 -@@ -11,7 +11,7 @@ static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size,
36474 -
36475 - #define P_OPTION(n) \
36476 - if (options & W##n) { \
36477 -- printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : #n); \
36478 -+ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
36479 - options &= ~W##n; \
36480 - }
36481 -
36482 -diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
36483 -index 70de8f6b3aee..9142fd294e76 100644
36484 ---- a/tools/perf/util/annotate.c
36485 -+++ b/tools/perf/util/annotate.c
36486 -@@ -1889,6 +1889,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,
36487 - struct annotation_options *options,
36488 - struct arch **parch)
36489 - {
36490 -+ struct annotation *notes = symbol__annotation(sym);
36491 - struct annotate_args args = {
36492 - .privsize = privsize,
36493 - .evsel = evsel,
36494 -@@ -1919,6 +1920,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,
36495 -
36496 - args.ms.map = map;
36497 - args.ms.sym = sym;
36498 -+ notes->start = map__rip_2objdump(map, sym->start);
36499 -
36500 - return symbol__disassemble(sym, &args);
36501 - }
36502 -@@ -2794,8 +2796,6 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *ev
36503 -
36504 - symbol__calc_percent(sym, evsel);
36505 -
36506 -- notes->start = map__rip_2objdump(map, sym->start);
36507 --
36508 - annotation__set_offsets(notes, size);
36509 - annotation__mark_jump_targets(notes, sym);
36510 - annotation__compute_ipc(notes, size);
36511 -diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
36512 -index f69961c4a4f3..2921ce08b198 100644
36513 ---- a/tools/perf/util/auxtrace.c
36514 -+++ b/tools/perf/util/auxtrace.c
36515 -@@ -1278,9 +1278,9 @@ static int __auxtrace_mmap__read(struct perf_mmap *map,
36516 - }
36517 -
36518 - /* padding must be written by fn() e.g. record__process_auxtrace() */
36519 -- padding = size & 7;
36520 -+ padding = size & (PERF_AUXTRACE_RECORD_ALIGNMENT - 1);
36521 - if (padding)
36522 -- padding = 8 - padding;
36523 -+ padding = PERF_AUXTRACE_RECORD_ALIGNMENT - padding;
36524 -
36525 - memset(&ev, 0, sizeof(ev));
36526 - ev.auxtrace.header.type = PERF_RECORD_AUXTRACE;
36527 -diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
36528 -index 8e50f96d4b23..fac32482db61 100644
36529 ---- a/tools/perf/util/auxtrace.h
36530 -+++ b/tools/perf/util/auxtrace.h
36531 -@@ -40,6 +40,9 @@ struct record_opts;
36532 - struct auxtrace_info_event;
36533 - struct events_stats;
36534 -
36535 -+/* Auxtrace records must have the same alignment as perf event records */
36536 -+#define PERF_AUXTRACE_RECORD_ALIGNMENT 8
36537 -+
36538 - enum auxtrace_type {
36539 - PERF_AUXTRACE_UNKNOWN,
36540 - PERF_AUXTRACE_INTEL_PT,
36541 -diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
36542 -index 4503f3ca45ab..7c0b975dd2f0 100644
36543 ---- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
36544 -+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
36545 -@@ -26,6 +26,7 @@
36546 -
36547 - #include "../cache.h"
36548 - #include "../util.h"
36549 -+#include "../auxtrace.h"
36550 -
36551 - #include "intel-pt-insn-decoder.h"
36552 - #include "intel-pt-pkt-decoder.h"
36553 -@@ -250,19 +251,15 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
36554 - if (!(decoder->tsc_ctc_ratio_n % decoder->tsc_ctc_ratio_d))
36555 - decoder->tsc_ctc_mult = decoder->tsc_ctc_ratio_n /
36556 - decoder->tsc_ctc_ratio_d;
36557 --
36558 -- /*
36559 -- * Allow for timestamps appearing to backwards because a TSC
36560 -- * packet has slipped past a MTC packet, so allow 2 MTC ticks
36561 -- * or ...
36562 -- */
36563 -- decoder->tsc_slip = multdiv(2 << decoder->mtc_shift,
36564 -- decoder->tsc_ctc_ratio_n,
36565 -- decoder->tsc_ctc_ratio_d);
36566 - }
36567 -- /* ... or 0x100 paranoia */
36568 -- if (decoder->tsc_slip < 0x100)
36569 -- decoder->tsc_slip = 0x100;
36570 -+
36571 -+ /*
36572 -+ * A TSC packet can slip past MTC packets so that the timestamp appears
36573 -+ * to go backwards. One estimate is that can be up to about 40 CPU
36574 -+ * cycles, which is certainly less than 0x1000 TSC ticks, but accept
36575 -+ * slippage an order of magnitude more to be on the safe side.
36576 -+ */
36577 -+ decoder->tsc_slip = 0x10000;
36578 -
36579 - intel_pt_log("timestamp: mtc_shift %u\n", decoder->mtc_shift);
36580 - intel_pt_log("timestamp: tsc_ctc_ratio_n %u\n", decoder->tsc_ctc_ratio_n);
36581 -@@ -1394,7 +1391,6 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)
36582 - {
36583 - intel_pt_log("ERROR: Buffer overflow\n");
36584 - intel_pt_clear_tx_flags(decoder);
36585 -- decoder->cbr = 0;
36586 - decoder->timestamp_insn_cnt = 0;
36587 - decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC;
36588 - decoder->overflow = true;
36589 -@@ -2575,6 +2571,34 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2)
36590 - }
36591 - }
36592 -
36593 -+#define MAX_PADDING (PERF_AUXTRACE_RECORD_ALIGNMENT - 1)
36594 -+
36595 -+/**
36596 -+ * adj_for_padding - adjust overlap to account for padding.
36597 -+ * @buf_b: second buffer
36598 -+ * @buf_a: first buffer
36599 -+ * @len_a: size of first buffer
36600 -+ *
36601 -+ * @buf_a might have up to 7 bytes of padding appended. Adjust the overlap
36602 -+ * accordingly.
36603 -+ *
36604 -+ * Return: A pointer into @buf_b from where non-overlapped data starts
36605 -+ */
36606 -+static unsigned char *adj_for_padding(unsigned char *buf_b,
36607 -+ unsigned char *buf_a, size_t len_a)
36608 -+{
36609 -+ unsigned char *p = buf_b - MAX_PADDING;
36610 -+ unsigned char *q = buf_a + len_a - MAX_PADDING;
36611 -+ int i;
36612 -+
36613 -+ for (i = MAX_PADDING; i; i--, p++, q++) {
36614 -+ if (*p != *q)
36615 -+ break;
36616 -+ }
36617 -+
36618 -+ return p;
36619 -+}
36620 -+
36621 - /**
36622 - * intel_pt_find_overlap_tsc - determine start of non-overlapped trace data
36623 - * using TSC.
36624 -@@ -2625,8 +2649,11 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,
36625 -
36626 - /* Same TSC, so buffers are consecutive */
36627 - if (!cmp && rem_b >= rem_a) {
36628 -+ unsigned char *start;
36629 -+
36630 - *consecutive = true;
36631 -- return buf_b + len_b - (rem_b - rem_a);
36632 -+ start = buf_b + len_b - (rem_b - rem_a);
36633 -+ return adj_for_padding(start, buf_a, len_a);
36634 - }
36635 - if (cmp < 0)
36636 - return buf_b; /* tsc_a < tsc_b => no overlap */
36637 -@@ -2689,7 +2716,7 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a,
36638 - found = memmem(buf_a, len_a, buf_b, len_a);
36639 - if (found) {
36640 - *consecutive = true;
36641 -- return buf_b + len_a;
36642 -+ return adj_for_padding(buf_b + len_a, buf_a, len_a);
36643 - }
36644 -
36645 - /* Try again at next PSB in buffer 'a' */
36646 -diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
36647 -index 2e72373ec6df..4493fc13a6fa 100644
36648 ---- a/tools/perf/util/intel-pt.c
36649 -+++ b/tools/perf/util/intel-pt.c
36650 -@@ -2522,6 +2522,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
36651 - }
36652 -
36653 - pt->timeless_decoding = intel_pt_timeless_decoding(pt);
36654 -+ if (pt->timeless_decoding && !pt->tc.time_mult)
36655 -+ pt->tc.time_mult = 1;
36656 - pt->have_tsc = intel_pt_have_tsc(pt);
36657 - pt->sampling_mode = false;
36658 - pt->est_tsc = !pt->timeless_decoding;
36659 -diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
36660 -index 11a234740632..ccd3275feeaa 100644
36661 ---- a/tools/perf/util/pmu.c
36662 -+++ b/tools/perf/util/pmu.c
36663 -@@ -734,10 +734,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
36664 -
36665 - if (!is_arm_pmu_core(name)) {
36666 - pname = pe->pmu ? pe->pmu : "cpu";
36667 -+
36668 -+ /*
36669 -+ * uncore alias may be from different PMU
36670 -+ * with common prefix
36671 -+ */
36672 -+ if (pmu_is_uncore(name) &&
36673 -+ !strncmp(pname, name, strlen(pname)))
36674 -+ goto new_alias;
36675 -+
36676 - if (strcmp(pname, name))
36677 - continue;
36678 - }
36679 -
36680 -+new_alias:
36681 - /* need type casts to override 'const' */
36682 - __perf_pmu__new_alias(head, NULL, (char *)pe->name,
36683 - (char *)pe->desc, (char *)pe->event,
36684 -diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
36685 -index 18a59fba97ff..cc4773157b9b 100644
36686 ---- a/tools/perf/util/probe-event.c
36687 -+++ b/tools/perf/util/probe-event.c
36688 -@@ -157,8 +157,10 @@ static struct map *kernel_get_module_map(const char *module)
36689 - if (module && strchr(module, '/'))
36690 - return dso__new_map(module);
36691 -
36692 -- if (!module)
36693 -- module = "kernel";
36694 -+ if (!module) {
36695 -+ pos = machine__kernel_map(host_machine);
36696 -+ return map__get(pos);
36697 -+ }
36698 -
36699 - for (pos = maps__first(maps); pos; pos = map__next(pos)) {
36700 - /* short_name is "[module]" */
36701 -diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
36702 -index 68b2570304ec..08073a4d59a4 100644
36703 ---- a/tools/perf/util/s390-cpumsf.c
36704 -+++ b/tools/perf/util/s390-cpumsf.c
36705 -@@ -301,6 +301,11 @@ static bool s390_cpumsf_validate(int machine_type,
36706 - *dsdes = 85;
36707 - *bsdes = 32;
36708 - break;
36709 -+ case 2964:
36710 -+ case 2965:
36711 -+ *dsdes = 112;
36712 -+ *bsdes = 32;
36713 -+ break;
36714 - default:
36715 - /* Illegal trailer entry */
36716 - return false;
36717 -diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
36718 -index 87ef16a1b17e..7059d1be2d09 100644
36719 ---- a/tools/perf/util/scripting-engines/trace-event-python.c
36720 -+++ b/tools/perf/util/scripting-engines/trace-event-python.c
36721 -@@ -733,8 +733,7 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
36722 - Py_FatalError("couldn't create Python dictionary");
36723 -
36724 - pydict_set_item_string_decref(dict, "ev_name", _PyUnicode_FromString(perf_evsel__name(evsel)));
36725 -- pydict_set_item_string_decref(dict, "attr", _PyUnicode_FromStringAndSize(
36726 -- (const char *)&evsel->attr, sizeof(evsel->attr)));
36727 -+ pydict_set_item_string_decref(dict, "attr", _PyBytes_FromStringAndSize((const char *)&evsel->attr, sizeof(evsel->attr)));
36728 -
36729 - pydict_set_item_string_decref(dict_sample, "pid",
36730 - _PyLong_FromLong(sample->pid));
36731 -@@ -1494,34 +1493,40 @@ static void _free_command_line(wchar_t **command_line, int num)
36732 - static int python_start_script(const char *script, int argc, const char **argv)
36733 - {
36734 - struct tables *tables = &tables_global;
36735 -+ PyMODINIT_FUNC (*initfunc)(void);
36736 - #if PY_MAJOR_VERSION < 3
36737 - const char **command_line;
36738 - #else
36739 - wchar_t **command_line;
36740 - #endif
36741 -- char buf[PATH_MAX];
36742 -+ /*
36743 -+ * Use a non-const name variable to cope with python 2.6's
36744 -+ * PyImport_AppendInittab prototype
36745 -+ */
36746 -+ char buf[PATH_MAX], name[19] = "perf_trace_context";
36747 - int i, err = 0;
36748 - FILE *fp;
36749 -
36750 - #if PY_MAJOR_VERSION < 3
36751 -+ initfunc = initperf_trace_context;
36752 - command_line = malloc((argc + 1) * sizeof(const char *));
36753 - command_line[0] = script;
36754 - for (i = 1; i < argc + 1; i++)
36755 - command_line[i] = argv[i - 1];
36756 - #else
36757 -+ initfunc = PyInit_perf_trace_context;
36758 - command_line = malloc((argc + 1) * sizeof(wchar_t *));
36759 - command_line[0] = Py_DecodeLocale(script, NULL);
36760 - for (i = 1; i < argc + 1; i++)
36761 - command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
36762 - #endif
36763 -
36764 -+ PyImport_AppendInittab(name, initfunc);
36765 - Py_Initialize();
36766 -
36767 - #if PY_MAJOR_VERSION < 3
36768 -- initperf_trace_context();
36769 - PySys_SetArgv(argc + 1, (char **)command_line);
36770 - #else
36771 -- PyInit_perf_trace_context();
36772 - PySys_SetArgv(argc + 1, command_line);
36773 - #endif
36774 -
36775 -diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
36776 -index 6c1a83768eb0..d0334c33da54 100644
36777 ---- a/tools/perf/util/sort.c
36778 -+++ b/tools/perf/util/sort.c
36779 -@@ -230,8 +230,14 @@ static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
36780 - if (sym_l == sym_r)
36781 - return 0;
36782 -
36783 -- if (sym_l->inlined || sym_r->inlined)
36784 -- return strcmp(sym_l->name, sym_r->name);
36785 -+ if (sym_l->inlined || sym_r->inlined) {
36786 -+ int ret = strcmp(sym_l->name, sym_r->name);
36787 -+
36788 -+ if (ret)
36789 -+ return ret;
36790 -+ if ((sym_l->start <= sym_r->end) && (sym_l->end >= sym_r->start))
36791 -+ return 0;
36792 -+ }
36793 -
36794 - if (sym_l->start != sym_r->start)
36795 - return (int64_t)(sym_r->start - sym_l->start);
36796 -diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
36797 -index dc86597d0cc4..ccf42c4e83f0 100644
36798 ---- a/tools/perf/util/srcline.c
36799 -+++ b/tools/perf/util/srcline.c
36800 -@@ -104,7 +104,7 @@ static struct symbol *new_inline_sym(struct dso *dso,
36801 - } else {
36802 - /* create a fake symbol for the inline frame */
36803 - inline_sym = symbol__new(base_sym ? base_sym->start : 0,
36804 -- base_sym ? base_sym->end : 0,
36805 -+ base_sym ? (base_sym->end - base_sym->start) : 0,
36806 - base_sym ? base_sym->binding : 0,
36807 - base_sym ? base_sym->type : 0,
36808 - funcname);
36809 -diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
36810 -index 48efad6d0f90..ca5f2e4796ea 100644
36811 ---- a/tools/perf/util/symbol.c
36812 -+++ b/tools/perf/util/symbol.c
36813 -@@ -710,6 +710,8 @@ static int map_groups__split_kallsyms_for_kcore(struct map_groups *kmaps, struct
36814 - }
36815 -
36816 - pos->start -= curr_map->start - curr_map->pgoff;
36817 -+ if (pos->end > curr_map->end)
36818 -+ pos->end = curr_map->end;
36819 - if (pos->end)
36820 - pos->end -= curr_map->start - curr_map->pgoff;
36821 - symbols__insert(&curr_map->dso->symbols, pos);
36822 -diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
36823 -index 41ab7a3668b3..936f726f7cd9 100644
36824 ---- a/tools/testing/selftests/bpf/Makefile
36825 -+++ b/tools/testing/selftests/bpf/Makefile
36826 -@@ -96,6 +96,7 @@ $(BPFOBJ): force
36827 - CLANG ?= clang
36828 - LLC ?= llc
36829 - LLVM_OBJCOPY ?= llvm-objcopy
36830 -+LLVM_READELF ?= llvm-readelf
36831 - BTF_PAHOLE ?= pahole
36832 -
36833 - PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
36834 -@@ -132,7 +133,7 @@ BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
36835 - BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
36836 - BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
36837 - $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
36838 -- readelf -S ./llvm_btf_verify.o | grep BTF; \
36839 -+ $(LLVM_READELF) -S ./llvm_btf_verify.o | grep BTF; \
36840 - /bin/rm -f ./llvm_btf_verify.o)
36841 -
36842 - ifneq ($(BTF_LLVM_PROBE),)
36843 -diff --git a/tools/testing/selftests/bpf/test_map_in_map.c b/tools/testing/selftests/bpf/test_map_in_map.c
36844 -index ce923e67e08e..2985f262846e 100644
36845 ---- a/tools/testing/selftests/bpf/test_map_in_map.c
36846 -+++ b/tools/testing/selftests/bpf/test_map_in_map.c
36847 -@@ -27,6 +27,7 @@ SEC("xdp_mimtest")
36848 - int xdp_mimtest0(struct xdp_md *ctx)
36849 - {
36850 - int value = 123;
36851 -+ int *value_p;
36852 - int key = 0;
36853 - void *map;
36854 -
36855 -@@ -35,6 +36,9 @@ int xdp_mimtest0(struct xdp_md *ctx)
36856 - return XDP_DROP;
36857 -
36858 - bpf_map_update_elem(map, &key, &value, 0);
36859 -+ value_p = bpf_map_lookup_elem(map, &key);
36860 -+ if (!value_p || *value_p != 123)
36861 -+ return XDP_DROP;
36862 -
36863 - map = bpf_map_lookup_elem(&mim_hash, &key);
36864 - if (!map)
36865 -diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
36866 -index e2b9eee37187..6e05a22b346c 100644
36867 ---- a/tools/testing/selftests/bpf/test_maps.c
36868 -+++ b/tools/testing/selftests/bpf/test_maps.c
36869 -@@ -43,7 +43,7 @@ static int map_flags;
36870 - } \
36871 - })
36872 -
36873 --static void test_hashmap(int task, void *data)
36874 -+static void test_hashmap(unsigned int task, void *data)
36875 - {
36876 - long long key, next_key, first_key, value;
36877 - int fd;
36878 -@@ -133,7 +133,7 @@ static void test_hashmap(int task, void *data)
36879 - close(fd);
36880 - }
36881 -
36882 --static void test_hashmap_sizes(int task, void *data)
36883 -+static void test_hashmap_sizes(unsigned int task, void *data)
36884 - {
36885 - int fd, i, j;
36886 -
36887 -@@ -153,7 +153,7 @@ static void test_hashmap_sizes(int task, void *data)
36888 - }
36889 - }
36890 -
36891 --static void test_hashmap_percpu(int task, void *data)
36892 -+static void test_hashmap_percpu(unsigned int task, void *data)
36893 - {
36894 - unsigned int nr_cpus = bpf_num_possible_cpus();
36895 - BPF_DECLARE_PERCPU(long, value);
36896 -@@ -280,7 +280,7 @@ static int helper_fill_hashmap(int max_entries)
36897 - return fd;
36898 - }
36899 -
36900 --static void test_hashmap_walk(int task, void *data)
36901 -+static void test_hashmap_walk(unsigned int task, void *data)
36902 - {
36903 - int fd, i, max_entries = 1000;
36904 - long long key, value, next_key;
36905 -@@ -351,7 +351,7 @@ static void test_hashmap_zero_seed(void)
36906 - close(second);
36907 - }
36908 -
36909 --static void test_arraymap(int task, void *data)
36910 -+static void test_arraymap(unsigned int task, void *data)
36911 - {
36912 - int key, next_key, fd;
36913 - long long value;
36914 -@@ -406,7 +406,7 @@ static void test_arraymap(int task, void *data)
36915 - close(fd);
36916 - }
36917 -
36918 --static void test_arraymap_percpu(int task, void *data)
36919 -+static void test_arraymap_percpu(unsigned int task, void *data)
36920 - {
36921 - unsigned int nr_cpus = bpf_num_possible_cpus();
36922 - BPF_DECLARE_PERCPU(long, values);
36923 -@@ -502,7 +502,7 @@ static void test_arraymap_percpu_many_keys(void)
36924 - close(fd);
36925 - }
36926 -
36927 --static void test_devmap(int task, void *data)
36928 -+static void test_devmap(unsigned int task, void *data)
36929 - {
36930 - int fd;
36931 - __u32 key, value;
36932 -@@ -517,7 +517,7 @@ static void test_devmap(int task, void *data)
36933 - close(fd);
36934 - }
36935 -
36936 --static void test_queuemap(int task, void *data)
36937 -+static void test_queuemap(unsigned int task, void *data)
36938 - {
36939 - const int MAP_SIZE = 32;
36940 - __u32 vals[MAP_SIZE + MAP_SIZE/2], val;
36941 -@@ -575,7 +575,7 @@ static void test_queuemap(int task, void *data)
36942 - close(fd);
36943 - }
36944 -
36945 --static void test_stackmap(int task, void *data)
36946 -+static void test_stackmap(unsigned int task, void *data)
36947 - {
36948 - const int MAP_SIZE = 32;
36949 - __u32 vals[MAP_SIZE + MAP_SIZE/2], val;
36950 -@@ -641,7 +641,7 @@ static void test_stackmap(int task, void *data)
36951 - #define SOCKMAP_PARSE_PROG "./sockmap_parse_prog.o"
36952 - #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o"
36953 - #define SOCKMAP_TCP_MSG_PROG "./sockmap_tcp_msg_prog.o"
36954 --static void test_sockmap(int tasks, void *data)
36955 -+static void test_sockmap(unsigned int tasks, void *data)
36956 - {
36957 - struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_msg, *bpf_map_break;
36958 - int map_fd_msg = 0, map_fd_rx = 0, map_fd_tx = 0, map_fd_break;
36959 -@@ -1258,10 +1258,11 @@ static void test_map_large(void)
36960 - }
36961 -
36962 - #define run_parallel(N, FN, DATA) \
36963 -- printf("Fork %d tasks to '" #FN "'\n", N); \
36964 -+ printf("Fork %u tasks to '" #FN "'\n", N); \
36965 - __run_parallel(N, FN, DATA)
36966 -
36967 --static void __run_parallel(int tasks, void (*fn)(int task, void *data),
36968 -+static void __run_parallel(unsigned int tasks,
36969 -+ void (*fn)(unsigned int task, void *data),
36970 - void *data)
36971 - {
36972 - pid_t pid[tasks];
36973 -@@ -1302,7 +1303,7 @@ static void test_map_stress(void)
36974 - #define DO_UPDATE 1
36975 - #define DO_DELETE 0
36976 -
36977 --static void test_update_delete(int fn, void *data)
36978 -+static void test_update_delete(unsigned int fn, void *data)
36979 - {
36980 - int do_update = ((int *)data)[1];
36981 - int fd = ((int *)data)[0];
36982 -diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
36983 -index 2fd90d456892..9a967983abed 100644
36984 ---- a/tools/testing/selftests/bpf/test_verifier.c
36985 -+++ b/tools/testing/selftests/bpf/test_verifier.c
36986 -@@ -34,6 +34,7 @@
36987 - #include <linux/if_ether.h>
36988 -
36989 - #include <bpf/bpf.h>
36990 -+#include <bpf/libbpf.h>
36991 -
36992 - #ifdef HAVE_GENHDR
36993 - # include "autoconf.h"
36994 -@@ -59,6 +60,7 @@
36995 -
36996 - #define UNPRIV_SYSCTL "kernel/unprivileged_bpf_disabled"
36997 - static bool unpriv_disabled = false;
36998 -+static int skips;
36999 -
37000 - struct bpf_test {
37001 - const char *descr;
37002 -@@ -15946,6 +15948,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
37003 - pflags |= BPF_F_ANY_ALIGNMENT;
37004 - fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags,
37005 - "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1);
37006 -+ if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) {
37007 -+ printf("SKIP (unsupported program type %d)\n", prog_type);
37008 -+ skips++;
37009 -+ goto close_fds;
37010 -+ }
37011 -
37012 - expected_ret = unpriv && test->result_unpriv != UNDEF ?
37013 - test->result_unpriv : test->result;
37014 -@@ -16099,7 +16106,7 @@ static bool test_as_unpriv(struct bpf_test *test)
37015 -
37016 - static int do_test(bool unpriv, unsigned int from, unsigned int to)
37017 - {
37018 -- int i, passes = 0, errors = 0, skips = 0;
37019 -+ int i, passes = 0, errors = 0;
37020 -
37021 - for (i = from; i < to; i++) {
37022 - struct bpf_test *test = &tests[i];
37023 -diff --git a/tools/testing/selftests/firmware/config b/tools/testing/selftests/firmware/config
37024 -index 913a25a4a32b..bf634dda0720 100644
37025 ---- a/tools/testing/selftests/firmware/config
37026 -+++ b/tools/testing/selftests/firmware/config
37027 -@@ -1,6 +1,5 @@
37028 - CONFIG_TEST_FIRMWARE=y
37029 - CONFIG_FW_LOADER=y
37030 - CONFIG_FW_LOADER_USER_HELPER=y
37031 --CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
37032 - CONFIG_IKCONFIG=y
37033 - CONFIG_IKCONFIG_PROC=y
37034 -diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
37035 -index 466cf2f91ba0..a4320c4b44dc 100755
37036 ---- a/tools/testing/selftests/firmware/fw_filesystem.sh
37037 -+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
37038 -@@ -155,8 +155,11 @@ read_firmwares()
37039 - {
37040 - for i in $(seq 0 3); do
37041 - config_set_read_fw_idx $i
37042 -- # Verify the contents match
37043 -- if ! diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
37044 -+ # Verify the contents are what we expect.
37045 -+ # -Z required for now -- check for yourself, md5sum
37046 -+ # on $FW and DIR/read_firmware will yield the same. Even
37047 -+ # cmp agrees, so something is off.
37048 -+ if ! diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
37049 - echo "request #$i: firmware was not loaded" >&2
37050 - exit 1
37051 - fi
37052 -@@ -168,7 +171,7 @@ read_firmwares_expect_nofile()
37053 - for i in $(seq 0 3); do
37054 - config_set_read_fw_idx $i
37055 - # Ensures contents differ
37056 -- if diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
37057 -+ if diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
37058 - echo "request $i: file was not expected to match" >&2
37059 - exit 1
37060 - fi
37061 -diff --git a/tools/testing/selftests/firmware/fw_lib.sh b/tools/testing/selftests/firmware/fw_lib.sh
37062 -index 6c5f1b2ffb74..1cbb12e284a6 100755
37063 ---- a/tools/testing/selftests/firmware/fw_lib.sh
37064 -+++ b/tools/testing/selftests/firmware/fw_lib.sh
37065 -@@ -91,7 +91,7 @@ verify_reqs()
37066 - if [ "$TEST_REQS_FW_SYSFS_FALLBACK" = "yes" ]; then
37067 - if [ ! "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
37068 - echo "usermode helper disabled so ignoring test"
37069 -- exit $ksft_skip
37070 -+ exit 0
37071 - fi
37072 - fi
37073 - }
37074 -diff --git a/tools/testing/selftests/ir/ir_loopback.c b/tools/testing/selftests/ir/ir_loopback.c
37075 -index 858c19caf224..8cdf1b89ac9c 100644
37076 ---- a/tools/testing/selftests/ir/ir_loopback.c
37077 -+++ b/tools/testing/selftests/ir/ir_loopback.c
37078 -@@ -27,6 +27,8 @@
37079 -
37080 - #define TEST_SCANCODES 10
37081 - #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
37082 -+#define SYSFS_PATH_MAX 256
37083 -+#define DNAME_PATH_MAX 256
37084 -
37085 - static const struct {
37086 - enum rc_proto proto;
37087 -@@ -56,7 +58,7 @@ static const struct {
37088 - int lirc_open(const char *rc)
37089 - {
37090 - struct dirent *dent;
37091 -- char buf[100];
37092 -+ char buf[SYSFS_PATH_MAX + DNAME_PATH_MAX];
37093 - DIR *d;
37094 - int fd;
37095 -
37096 -diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
37097 -index 7e632b465ab4..6d7a81306f8a 100644
37098 ---- a/tools/testing/selftests/seccomp/seccomp_bpf.c
37099 -+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
37100 -@@ -2971,6 +2971,12 @@ TEST(get_metadata)
37101 - struct seccomp_metadata md;
37102 - long ret;
37103 -
37104 -+ /* Only real root can get metadata. */
37105 -+ if (geteuid()) {
37106 -+ XFAIL(return, "get_metadata requires real root");
37107 -+ return;
37108 -+ }
37109 -+
37110 - ASSERT_EQ(0, pipe(pipefd));
37111 -
37112 - pid = fork();
37113 -diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
37114 -index 30251e288629..5cc22cdaa5ba 100644
37115 ---- a/virt/kvm/arm/mmu.c
37116 -+++ b/virt/kvm/arm/mmu.c
37117 -@@ -2353,7 +2353,7 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
37118 - return 0;
37119 - }
37120 -
37121 --void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots)
37122 -+void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen)
37123 - {
37124 - }
37125 -
37126 -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
37127 -index 076bc38963bf..b4f2d892a1d3 100644
37128 ---- a/virt/kvm/kvm_main.c
37129 -+++ b/virt/kvm/kvm_main.c
37130 -@@ -874,6 +874,7 @@ static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
37131 - int as_id, struct kvm_memslots *slots)
37132 - {
37133 - struct kvm_memslots *old_memslots = __kvm_memslots(kvm, as_id);
37134 -+ u64 gen;
37135 -
37136 - /*
37137 - * Set the low bit in the generation, which disables SPTE caching
37138 -@@ -896,9 +897,11 @@ static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
37139 - * space 0 will use generations 0, 4, 8, ... while * address space 1 will
37140 - * use generations 2, 6, 10, 14, ...
37141 - */
37142 -- slots->generation += KVM_ADDRESS_SPACE_NUM * 2 - 1;
37143 -+ gen = slots->generation + KVM_ADDRESS_SPACE_NUM * 2 - 1;
37144 -
37145 -- kvm_arch_memslots_updated(kvm, slots);
37146 -+ kvm_arch_memslots_updated(kvm, gen);
37147 -+
37148 -+ slots->generation = gen;
37149 -
37150 - return old_memslots;
37151 - }
37152 -@@ -2899,6 +2902,9 @@ static long kvm_device_ioctl(struct file *filp, unsigned int ioctl,
37153 - {
37154 - struct kvm_device *dev = filp->private_data;
37155 -
37156 -+ if (dev->kvm->mm != current->mm)
37157 -+ return -EIO;
37158 -+
37159 - switch (ioctl) {
37160 - case KVM_SET_DEVICE_ATTR:
37161 - return kvm_device_ioctl_attr(dev, dev->ops->set_attr, arg);