Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.15 commit in: /
Date: Wed, 29 Dec 2021 13:05:42
Message-Id: 1640783110.6a800ed523206259aa9754f876b9ccb29e412871.mpagano@gentoo
1 commit: 6a800ed523206259aa9754f876b9ccb29e412871
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Dec 29 13:05:10 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 29 13:05:10 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=6a800ed5
7
8 Linux patch 5.15.12
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1011_linux-5.15.12.patch | 4959 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4963 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 5388e982..259cde90 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -87,6 +87,10 @@ Patch: 1010_linux-5.15.11.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.15.11
23
24 +Patch: 1011_linux-5.15.12.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.15.12
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1011_linux-5.15.12.patch b/1011_linux-5.15.12.patch
33 new file mode 100644
34 index 00000000..3842ad02
35 --- /dev/null
36 +++ b/1011_linux-5.15.12.patch
37 @@ -0,0 +1,4959 @@
38 +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
39 +index 1396fd2d90319..a454f438bd621 100644
40 +--- a/Documentation/admin-guide/kernel-parameters.txt
41 ++++ b/Documentation/admin-guide/kernel-parameters.txt
42 +@@ -2403,8 +2403,12 @@
43 + Default is 1 (enabled)
44 +
45 + kvm-intel.emulate_invalid_guest_state=
46 +- [KVM,Intel] Enable emulation of invalid guest states
47 +- Default is 0 (disabled)
48 ++ [KVM,Intel] Disable emulation of invalid guest state.
49 ++ Ignored if kvm-intel.enable_unrestricted_guest=1, as
50 ++ guest state is never invalid for unrestricted guests.
51 ++ This param doesn't apply to nested guests (L2), as KVM
52 ++ never emulates invalid L2 guest state.
53 ++ Default is 1 (enabled)
54 +
55 + kvm-intel.flexpriority=
56 + [KVM,Intel] Disable FlexPriority feature (TPR shadow).
57 +diff --git a/Documentation/hwmon/lm90.rst b/Documentation/hwmon/lm90.rst
58 +index 3da8c6e06a365..05391fb4042d9 100644
59 +--- a/Documentation/hwmon/lm90.rst
60 ++++ b/Documentation/hwmon/lm90.rst
61 +@@ -265,6 +265,16 @@ Supported chips:
62 +
63 + https://www.ti.com/litv/pdf/sbos686
64 +
65 ++ * Texas Instruments TMP461
66 ++
67 ++ Prefix: 'tmp461'
68 ++
69 ++ Addresses scanned: I2C 0x48 through 0x4F
70 ++
71 ++ Datasheet: Publicly available at TI website
72 ++
73 ++ https://www.ti.com/lit/gpn/tmp461
74 ++
75 + Author: Jean Delvare <jdelvare@××××.de>
76 +
77 +
78 +diff --git a/Documentation/networking/bonding.rst b/Documentation/networking/bonding.rst
79 +index 31cfd7d674a6c..c0a789b008063 100644
80 +--- a/Documentation/networking/bonding.rst
81 ++++ b/Documentation/networking/bonding.rst
82 +@@ -196,11 +196,12 @@ ad_actor_sys_prio
83 + ad_actor_system
84 +
85 + In an AD system, this specifies the mac-address for the actor in
86 +- protocol packet exchanges (LACPDUs). The value cannot be NULL or
87 +- multicast. It is preferred to have the local-admin bit set for this
88 +- mac but driver does not enforce it. If the value is not given then
89 +- system defaults to using the masters' mac address as actors' system
90 +- address.
91 ++ protocol packet exchanges (LACPDUs). The value cannot be a multicast
92 ++ address. If the all-zeroes MAC is specified, bonding will internally
93 ++ use the MAC of the bond itself. It is preferred to have the
94 ++ local-admin bit set for this mac but driver does not enforce it. If
95 ++ the value is not given then system defaults to using the masters'
96 ++ mac address as actors' system address.
97 +
98 + This parameter has effect only in 802.3ad mode and is available through
99 + SysFs interface.
100 +diff --git a/Documentation/sound/hd-audio/models.rst b/Documentation/sound/hd-audio/models.rst
101 +index 0ea967d345838..d25335993e553 100644
102 +--- a/Documentation/sound/hd-audio/models.rst
103 ++++ b/Documentation/sound/hd-audio/models.rst
104 +@@ -326,6 +326,8 @@ usi-headset
105 + Headset support on USI machines
106 + dual-codecs
107 + Lenovo laptops with dual codecs
108 ++alc285-hp-amp-init
109 ++ HP laptops which require speaker amplifier initialization (ALC285)
110 +
111 + ALC680
112 + ======
113 +diff --git a/Makefile b/Makefile
114 +index 37a1144c32df7..474b2a2292ca4 100644
115 +--- a/Makefile
116 ++++ b/Makefile
117 +@@ -1,7 +1,7 @@
118 + # SPDX-License-Identifier: GPL-2.0
119 + VERSION = 5
120 + PATCHLEVEL = 15
121 +-SUBLEVEL = 11
122 ++SUBLEVEL = 12
123 + EXTRAVERSION =
124 + NAME = Trick or Treat
125 +
126 +diff --git a/arch/arm/boot/dts/imx6qdl-wandboard.dtsi b/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
127 +index b62a0dbb033ff..ec6fba5ee8fde 100644
128 +--- a/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
129 ++++ b/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
130 +@@ -309,6 +309,7 @@
131 +
132 + ethphy: ethernet-phy@1 {
133 + reg = <1>;
134 ++ qca,clk-out-frequency = <125000000>;
135 + };
136 + };
137 + };
138 +diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
139 +index 241b73d64df73..d8e28abd468c0 100644
140 +--- a/arch/arm/kernel/entry-armv.S
141 ++++ b/arch/arm/kernel/entry-armv.S
142 +@@ -597,11 +597,9 @@ call_fpe:
143 + tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2
144 + reteq lr
145 + and r8, r0, #0x00000f00 @ mask out CP number
146 +- THUMB( lsr r8, r8, #8 )
147 + mov r7, #1
148 +- add r6, r10, #TI_USED_CP
149 +- ARM( strb r7, [r6, r8, lsr #8] ) @ set appropriate used_cp[]
150 +- THUMB( strb r7, [r6, r8] ) @ set appropriate used_cp[]
151 ++ add r6, r10, r8, lsr #8 @ add used_cp[] array offset first
152 ++ strb r7, [r6, #TI_USED_CP] @ set appropriate used_cp[]
153 + #ifdef CONFIG_IWMMXT
154 + @ Test if we need to give access to iWMMXt coprocessors
155 + ldr r5, [r10, #TI_FLAGS]
156 +@@ -610,7 +608,7 @@ call_fpe:
157 + bcs iwmmxt_task_enable
158 + #endif
159 + ARM( add pc, pc, r8, lsr #6 )
160 +- THUMB( lsl r8, r8, #2 )
161 ++ THUMB( lsr r8, r8, #6 )
162 + THUMB( add pc, r8 )
163 + nop
164 +
165 +diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
166 +index 0fc814bbc34b1..8796a69c78e00 100644
167 +--- a/arch/arm/kernel/head-nommu.S
168 ++++ b/arch/arm/kernel/head-nommu.S
169 +@@ -114,6 +114,7 @@ ENTRY(secondary_startup)
170 + add r12, r12, r10
171 + ret r12
172 + 1: bl __after_proc_init
173 ++ ldr r7, __secondary_data @ reload r7
174 + ldr sp, [r7, #12] @ set up the stack pointer
175 + mov fp, #0
176 + b secondary_start_kernel
177 +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
178 +index fee914c716aa2..0758ea0717f98 100644
179 +--- a/arch/arm64/Kconfig
180 ++++ b/arch/arm64/Kconfig
181 +@@ -1264,7 +1264,8 @@ config KUSER_HELPERS
182 +
183 + config COMPAT_VDSO
184 + bool "Enable vDSO for 32-bit applications"
185 +- depends on !CPU_BIG_ENDIAN && "$(CROSS_COMPILE_COMPAT)" != ""
186 ++ depends on !CPU_BIG_ENDIAN
187 ++ depends on (CC_IS_CLANG && LD_IS_LLD) || "$(CROSS_COMPILE_COMPAT)" != ""
188 + select GENERIC_COMPAT_VDSO
189 + default y
190 + help
191 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts
192 +index d13980ed7a79a..7ec5ac850a0dc 100644
193 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts
194 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts
195 +@@ -69,7 +69,7 @@
196 + pinctrl-0 = <&emac_rgmii_pins>;
197 + phy-supply = <&reg_gmac_3v3>;
198 + phy-handle = <&ext_rgmii_phy>;
199 +- phy-mode = "rgmii";
200 ++ phy-mode = "rgmii-id";
201 + status = "okay";
202 + };
203 +
204 +diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
205 +index c4b1a59ba424b..51c4f61007cdb 100644
206 +--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
207 ++++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
208 +@@ -719,7 +719,7 @@
209 + clock-names = "i2c";
210 + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL
211 + QORIQ_CLK_PLL_DIV(16)>;
212 +- scl-gpio = <&gpio2 15 GPIO_ACTIVE_HIGH>;
213 ++ scl-gpios = <&gpio2 15 GPIO_ACTIVE_HIGH>;
214 + status = "disabled";
215 + };
216 +
217 +@@ -768,7 +768,7 @@
218 + clock-names = "i2c";
219 + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL
220 + QORIQ_CLK_PLL_DIV(16)>;
221 +- scl-gpio = <&gpio2 16 GPIO_ACTIVE_HIGH>;
222 ++ scl-gpios = <&gpio2 16 GPIO_ACTIVE_HIGH>;
223 + status = "disabled";
224 + };
225 +
226 +diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
227 +index 764d1900d5aab..3514269ac75fb 100644
228 +--- a/arch/arm64/kernel/vdso32/Makefile
229 ++++ b/arch/arm64/kernel/vdso32/Makefile
230 +@@ -10,18 +10,15 @@ include $(srctree)/lib/vdso/Makefile
231 +
232 + # Same as cc-*option, but using CC_COMPAT instead of CC
233 + ifeq ($(CONFIG_CC_IS_CLANG), y)
234 +-CC_COMPAT_CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE_COMPAT:%-=%))
235 +-
236 + CC_COMPAT ?= $(CC)
237 +-CC_COMPAT += $(CC_COMPAT_CLANG_FLAGS)
238 +-
239 +-ifneq ($(LLVM),)
240 +-LD_COMPAT ?= $(LD)
241 ++CC_COMPAT += --target=arm-linux-gnueabi
242 + else
243 +-LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld
244 ++CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc
245 + endif
246 ++
247 ++ifeq ($(CONFIG_LD_IS_LLD), y)
248 ++LD_COMPAT ?= $(LD)
249 + else
250 +-CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc
251 + LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld
252 + endif
253 +
254 +@@ -47,10 +44,6 @@ VDSO_CPPFLAGS += $(LINUXINCLUDE)
255 + # Common C and assembly flags
256 + # From top-level Makefile
257 + VDSO_CAFLAGS := $(VDSO_CPPFLAGS)
258 +-ifneq ($(shell $(CC_COMPAT) --version 2>&1 | head -n 1 | grep clang),)
259 +-VDSO_CAFLAGS += --target=$(notdir $(CROSS_COMPILE_COMPAT:%-=%))
260 +-endif
261 +-
262 + VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
263 + ifdef CONFIG_DEBUG_INFO
264 + VDSO_CAFLAGS += -g
265 +diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h
266 +index fceb9cf02fb3a..71aa0921d6c72 100644
267 +--- a/arch/parisc/include/asm/futex.h
268 ++++ b/arch/parisc/include/asm/futex.h
269 +@@ -16,7 +16,7 @@ static inline void
270 + _futex_spin_lock_irqsave(u32 __user *uaddr, unsigned long int *flags)
271 + {
272 + extern u32 lws_lock_start[];
273 +- long index = ((long)uaddr & 0x3f8) >> 1;
274 ++ long index = ((long)uaddr & 0x7f8) >> 1;
275 + arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
276 + local_irq_save(*flags);
277 + arch_spin_lock(s);
278 +@@ -26,7 +26,7 @@ static inline void
279 + _futex_spin_unlock_irqrestore(u32 __user *uaddr, unsigned long int *flags)
280 + {
281 + extern u32 lws_lock_start[];
282 +- long index = ((long)uaddr & 0x3f8) >> 1;
283 ++ long index = ((long)uaddr & 0x7f8) >> 1;
284 + arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
285 + arch_spin_unlock(s);
286 + local_irq_restore(*flags);
287 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
288 +index 3f24a0af1e047..9842dcb2041e5 100644
289 +--- a/arch/parisc/kernel/syscall.S
290 ++++ b/arch/parisc/kernel/syscall.S
291 +@@ -478,7 +478,7 @@ lws_start:
292 + extrd,u %r1,PSW_W_BIT,1,%r1
293 + /* sp must be aligned on 4, so deposit the W bit setting into
294 + * the bottom of sp temporarily */
295 +- or,ev %r1,%r30,%r30
296 ++ or,od %r1,%r30,%r30
297 +
298 + /* Clip LWS number to a 32-bit value for 32-bit processes */
299 + depdi 0, 31, 32, %r20
300 +diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
301 +index cefe1d81e2e8b..9e50da3ed01a3 100644
302 +--- a/arch/x86/include/asm/kvm-x86-ops.h
303 ++++ b/arch/x86/include/asm/kvm-x86-ops.h
304 +@@ -47,6 +47,7 @@ KVM_X86_OP(set_dr7)
305 + KVM_X86_OP(cache_reg)
306 + KVM_X86_OP(get_rflags)
307 + KVM_X86_OP(set_rflags)
308 ++KVM_X86_OP(get_if_flag)
309 + KVM_X86_OP(tlb_flush_all)
310 + KVM_X86_OP(tlb_flush_current)
311 + KVM_X86_OP_NULL(tlb_remote_flush)
312 +diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
313 +index a11785ebf628b..75e21715ecb46 100644
314 +--- a/arch/x86/include/asm/kvm_host.h
315 ++++ b/arch/x86/include/asm/kvm_host.h
316 +@@ -1341,6 +1341,7 @@ struct kvm_x86_ops {
317 + void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
318 + unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
319 + void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
320 ++ bool (*get_if_flag)(struct kvm_vcpu *vcpu);
321 +
322 + void (*tlb_flush_all)(struct kvm_vcpu *vcpu);
323 + void (*tlb_flush_current)(struct kvm_vcpu *vcpu);
324 +diff --git a/arch/x86/include/asm/pkru.h b/arch/x86/include/asm/pkru.h
325 +index ccc539faa5bbc..4d8b9448fe8d2 100644
326 +--- a/arch/x86/include/asm/pkru.h
327 ++++ b/arch/x86/include/asm/pkru.h
328 +@@ -4,8 +4,8 @@
329 +
330 + #include <asm/fpu/xstate.h>
331 +
332 +-#define PKRU_AD_BIT 0x1
333 +-#define PKRU_WD_BIT 0x2
334 ++#define PKRU_AD_BIT 0x1u
335 ++#define PKRU_WD_BIT 0x2u
336 + #define PKRU_BITS_PER_PKEY 2
337 +
338 + #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
339 +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
340 +index d71267081153f..48596f9fddf45 100644
341 +--- a/arch/x86/kernel/setup.c
342 ++++ b/arch/x86/kernel/setup.c
343 +@@ -713,9 +713,6 @@ static void __init early_reserve_memory(void)
344 +
345 + early_reserve_initrd();
346 +
347 +- if (efi_enabled(EFI_BOOT))
348 +- efi_memblock_x86_reserve_range();
349 +-
350 + memblock_x86_reserve_range_setup_data();
351 +
352 + reserve_ibft_region();
353 +@@ -742,28 +739,6 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
354 + return 0;
355 + }
356 +
357 +-static char *prepare_command_line(void)
358 +-{
359 +-#ifdef CONFIG_CMDLINE_BOOL
360 +-#ifdef CONFIG_CMDLINE_OVERRIDE
361 +- strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
362 +-#else
363 +- if (builtin_cmdline[0]) {
364 +- /* append boot loader cmdline to builtin */
365 +- strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
366 +- strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
367 +- strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
368 +- }
369 +-#endif
370 +-#endif
371 +-
372 +- strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
373 +-
374 +- parse_early_param();
375 +-
376 +- return command_line;
377 +-}
378 +-
379 + /*
380 + * Determine if we were loaded by an EFI loader. If so, then we have also been
381 + * passed the efi memmap, systab, etc., so we should use these data structures
382 +@@ -852,23 +827,6 @@ void __init setup_arch(char **cmdline_p)
383 +
384 + x86_init.oem.arch_setup();
385 +
386 +- /*
387 +- * x86_configure_nx() is called before parse_early_param() (called by
388 +- * prepare_command_line()) to detect whether hardware doesn't support
389 +- * NX (so that the early EHCI debug console setup can safely call
390 +- * set_fixmap()). It may then be called again from within noexec_setup()
391 +- * during parsing early parameters to honor the respective command line
392 +- * option.
393 +- */
394 +- x86_configure_nx();
395 +-
396 +- /*
397 +- * This parses early params and it needs to run before
398 +- * early_reserve_memory() because latter relies on such settings
399 +- * supplied as early params.
400 +- */
401 +- *cmdline_p = prepare_command_line();
402 +-
403 + /*
404 + * Do some memory reservations *before* memory is added to memblock, so
405 + * memblock allocations won't overwrite it.
406 +@@ -902,6 +860,36 @@ void __init setup_arch(char **cmdline_p)
407 + bss_resource.start = __pa_symbol(__bss_start);
408 + bss_resource.end = __pa_symbol(__bss_stop)-1;
409 +
410 ++#ifdef CONFIG_CMDLINE_BOOL
411 ++#ifdef CONFIG_CMDLINE_OVERRIDE
412 ++ strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
413 ++#else
414 ++ if (builtin_cmdline[0]) {
415 ++ /* append boot loader cmdline to builtin */
416 ++ strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
417 ++ strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
418 ++ strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
419 ++ }
420 ++#endif
421 ++#endif
422 ++
423 ++ strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
424 ++ *cmdline_p = command_line;
425 ++
426 ++ /*
427 ++ * x86_configure_nx() is called before parse_early_param() to detect
428 ++ * whether hardware doesn't support NX (so that the early EHCI debug
429 ++ * console setup can safely call set_fixmap()). It may then be called
430 ++ * again from within noexec_setup() during parsing early parameters
431 ++ * to honor the respective command line option.
432 ++ */
433 ++ x86_configure_nx();
434 ++
435 ++ parse_early_param();
436 ++
437 ++ if (efi_enabled(EFI_BOOT))
438 ++ efi_memblock_x86_reserve_range();
439 ++
440 + #ifdef CONFIG_MEMORY_HOTPLUG
441 + /*
442 + * Memory used by the kernel cannot be hot-removed because Linux
443 +diff --git a/arch/x86/kvm/mmu/tdp_iter.c b/arch/x86/kvm/mmu/tdp_iter.c
444 +index b3ed302c1a359..caa96c270b954 100644
445 +--- a/arch/x86/kvm/mmu/tdp_iter.c
446 ++++ b/arch/x86/kvm/mmu/tdp_iter.c
447 +@@ -26,6 +26,7 @@ static gfn_t round_gfn_for_level(gfn_t gfn, int level)
448 + */
449 + void tdp_iter_restart(struct tdp_iter *iter)
450 + {
451 ++ iter->yielded = false;
452 + iter->yielded_gfn = iter->next_last_level_gfn;
453 + iter->level = iter->root_level;
454 +
455 +@@ -160,6 +161,11 @@ static bool try_step_up(struct tdp_iter *iter)
456 + */
457 + void tdp_iter_next(struct tdp_iter *iter)
458 + {
459 ++ if (iter->yielded) {
460 ++ tdp_iter_restart(iter);
461 ++ return;
462 ++ }
463 ++
464 + if (try_step_down(iter))
465 + return;
466 +
467 +diff --git a/arch/x86/kvm/mmu/tdp_iter.h b/arch/x86/kvm/mmu/tdp_iter.h
468 +index b1748b988d3ae..e19cabbcb65c8 100644
469 +--- a/arch/x86/kvm/mmu/tdp_iter.h
470 ++++ b/arch/x86/kvm/mmu/tdp_iter.h
471 +@@ -45,6 +45,12 @@ struct tdp_iter {
472 + * iterator walks off the end of the paging structure.
473 + */
474 + bool valid;
475 ++ /*
476 ++ * True if KVM dropped mmu_lock and yielded in the middle of a walk, in
477 ++ * which case tdp_iter_next() needs to restart the walk at the root
478 ++ * level instead of advancing to the next entry.
479 ++ */
480 ++ bool yielded;
481 + };
482 +
483 + /*
484 +diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
485 +index 0e4227b59d7bb..4954cd01c1f0e 100644
486 +--- a/arch/x86/kvm/mmu/tdp_mmu.c
487 ++++ b/arch/x86/kvm/mmu/tdp_mmu.c
488 +@@ -501,6 +501,8 @@ static inline bool tdp_mmu_set_spte_atomic_no_dirty_log(struct kvm *kvm,
489 + struct tdp_iter *iter,
490 + u64 new_spte)
491 + {
492 ++ WARN_ON_ONCE(iter->yielded);
493 ++
494 + lockdep_assert_held_read(&kvm->mmu_lock);
495 +
496 + /*
497 +@@ -611,6 +613,8 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter,
498 + u64 new_spte, bool record_acc_track,
499 + bool record_dirty_log)
500 + {
501 ++ WARN_ON_ONCE(iter->yielded);
502 ++
503 + lockdep_assert_held_write(&kvm->mmu_lock);
504 +
505 + /*
506 +@@ -676,18 +680,19 @@ static inline void tdp_mmu_set_spte_no_dirty_log(struct kvm *kvm,
507 + * If this function should yield and flush is set, it will perform a remote
508 + * TLB flush before yielding.
509 + *
510 +- * If this function yields, it will also reset the tdp_iter's walk over the
511 +- * paging structure and the calling function should skip to the next
512 +- * iteration to allow the iterator to continue its traversal from the
513 +- * paging structure root.
514 ++ * If this function yields, iter->yielded is set and the caller must skip to
515 ++ * the next iteration, where tdp_iter_next() will reset the tdp_iter's walk
516 ++ * over the paging structures to allow the iterator to continue its traversal
517 ++ * from the paging structure root.
518 + *
519 +- * Return true if this function yielded and the iterator's traversal was reset.
520 +- * Return false if a yield was not needed.
521 ++ * Returns true if this function yielded.
522 + */
523 +-static inline bool tdp_mmu_iter_cond_resched(struct kvm *kvm,
524 +- struct tdp_iter *iter, bool flush,
525 +- bool shared)
526 ++static inline bool __must_check tdp_mmu_iter_cond_resched(struct kvm *kvm,
527 ++ struct tdp_iter *iter,
528 ++ bool flush, bool shared)
529 + {
530 ++ WARN_ON(iter->yielded);
531 ++
532 + /* Ensure forward progress has been made before yielding. */
533 + if (iter->next_last_level_gfn == iter->yielded_gfn)
534 + return false;
535 +@@ -707,12 +712,10 @@ static inline bool tdp_mmu_iter_cond_resched(struct kvm *kvm,
536 +
537 + WARN_ON(iter->gfn > iter->next_last_level_gfn);
538 +
539 +- tdp_iter_restart(iter);
540 +-
541 +- return true;
542 ++ iter->yielded = true;
543 + }
544 +
545 +- return false;
546 ++ return iter->yielded;
547 + }
548 +
549 + /*
550 +diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
551 +index 1fce044beebea..e64f16237b60b 100644
552 +--- a/arch/x86/kvm/svm/svm.c
553 ++++ b/arch/x86/kvm/svm/svm.c
554 +@@ -1517,6 +1517,15 @@ static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
555 + to_svm(vcpu)->vmcb->save.rflags = rflags;
556 + }
557 +
558 ++static bool svm_get_if_flag(struct kvm_vcpu *vcpu)
559 ++{
560 ++ struct vmcb *vmcb = to_svm(vcpu)->vmcb;
561 ++
562 ++ return sev_es_guest(vcpu->kvm)
563 ++ ? vmcb->control.int_state & SVM_GUEST_INTERRUPT_MASK
564 ++ : kvm_get_rflags(vcpu) & X86_EFLAGS_IF;
565 ++}
566 ++
567 + static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
568 + {
569 + switch (reg) {
570 +@@ -3485,14 +3494,7 @@ bool svm_interrupt_blocked(struct kvm_vcpu *vcpu)
571 + if (!gif_set(svm))
572 + return true;
573 +
574 +- if (sev_es_guest(vcpu->kvm)) {
575 +- /*
576 +- * SEV-ES guests to not expose RFLAGS. Use the VMCB interrupt mask
577 +- * bit to determine the state of the IF flag.
578 +- */
579 +- if (!(vmcb->control.int_state & SVM_GUEST_INTERRUPT_MASK))
580 +- return true;
581 +- } else if (is_guest_mode(vcpu)) {
582 ++ if (is_guest_mode(vcpu)) {
583 + /* As long as interrupts are being delivered... */
584 + if ((svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK)
585 + ? !(svm->vmcb01.ptr->save.rflags & X86_EFLAGS_IF)
586 +@@ -3503,7 +3505,7 @@ bool svm_interrupt_blocked(struct kvm_vcpu *vcpu)
587 + if (nested_exit_on_intr(svm))
588 + return false;
589 + } else {
590 +- if (!(kvm_get_rflags(vcpu) & X86_EFLAGS_IF))
591 ++ if (!svm_get_if_flag(vcpu))
592 + return true;
593 + }
594 +
595 +@@ -4562,6 +4564,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
596 + .cache_reg = svm_cache_reg,
597 + .get_rflags = svm_get_rflags,
598 + .set_rflags = svm_set_rflags,
599 ++ .get_if_flag = svm_get_if_flag,
600 +
601 + .tlb_flush_all = svm_flush_tlb,
602 + .tlb_flush_current = svm_flush_tlb,
603 +diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
604 +index 4e212f04268bb..7d280e6f5488a 100644
605 +--- a/arch/x86/kvm/vmx/vmx.c
606 ++++ b/arch/x86/kvm/vmx/vmx.c
607 +@@ -1359,6 +1359,11 @@ void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
608 + vmx->emulation_required = vmx_emulation_required(vcpu);
609 + }
610 +
611 ++static bool vmx_get_if_flag(struct kvm_vcpu *vcpu)
612 ++{
613 ++ return vmx_get_rflags(vcpu) & X86_EFLAGS_IF;
614 ++}
615 ++
616 + u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu)
617 + {
618 + u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
619 +@@ -3966,8 +3971,7 @@ static int vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector)
620 + if (pi_test_and_set_on(&vmx->pi_desc))
621 + return 0;
622 +
623 +- if (vcpu != kvm_get_running_vcpu() &&
624 +- !kvm_vcpu_trigger_posted_interrupt(vcpu, false))
625 ++ if (!kvm_vcpu_trigger_posted_interrupt(vcpu, false))
626 + kvm_vcpu_kick(vcpu);
627 +
628 + return 0;
629 +@@ -5861,18 +5865,14 @@ static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
630 + vmx_flush_pml_buffer(vcpu);
631 +
632 + /*
633 +- * We should never reach this point with a pending nested VM-Enter, and
634 +- * more specifically emulation of L2 due to invalid guest state (see
635 +- * below) should never happen as that means we incorrectly allowed a
636 +- * nested VM-Enter with an invalid vmcs12.
637 ++ * KVM should never reach this point with a pending nested VM-Enter.
638 ++ * More specifically, short-circuiting VM-Entry to emulate L2 due to
639 ++ * invalid guest state should never happen as that means KVM knowingly
640 ++ * allowed a nested VM-Enter with an invalid vmcs12. More below.
641 + */
642 + if (KVM_BUG_ON(vmx->nested.nested_run_pending, vcpu->kvm))
643 + return -EIO;
644 +
645 +- /* If guest state is invalid, start emulating */
646 +- if (vmx->emulation_required)
647 +- return handle_invalid_guest_state(vcpu);
648 +-
649 + if (is_guest_mode(vcpu)) {
650 + /*
651 + * PML is never enabled when running L2, bail immediately if a
652 +@@ -5894,10 +5894,30 @@ static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
653 + */
654 + nested_mark_vmcs12_pages_dirty(vcpu);
655 +
656 ++ /*
657 ++ * Synthesize a triple fault if L2 state is invalid. In normal
658 ++ * operation, nested VM-Enter rejects any attempt to enter L2
659 ++ * with invalid state. However, those checks are skipped if
660 ++ * state is being stuffed via RSM or KVM_SET_NESTED_STATE. If
661 ++ * L2 state is invalid, it means either L1 modified SMRAM state
662 ++ * or userspace provided bad state. Synthesize TRIPLE_FAULT as
663 ++ * doing so is architecturally allowed in the RSM case, and is
664 ++ * the least awful solution for the userspace case without
665 ++ * risking false positives.
666 ++ */
667 ++ if (vmx->emulation_required) {
668 ++ nested_vmx_vmexit(vcpu, EXIT_REASON_TRIPLE_FAULT, 0, 0);
669 ++ return 1;
670 ++ }
671 ++
672 + if (nested_vmx_reflect_vmexit(vcpu))
673 + return 1;
674 + }
675 +
676 ++ /* If guest state is invalid, start emulating. L2 is handled above. */
677 ++ if (vmx->emulation_required)
678 ++ return handle_invalid_guest_state(vcpu);
679 ++
680 + if (exit_reason.failed_vmentry) {
681 + dump_vmcs(vcpu);
682 + vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
683 +@@ -6591,9 +6611,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
684 + * consistency check VM-Exit due to invalid guest state and bail.
685 + */
686 + if (unlikely(vmx->emulation_required)) {
687 +-
688 +- /* We don't emulate invalid state of a nested guest */
689 +- vmx->fail = is_guest_mode(vcpu);
690 ++ vmx->fail = 0;
691 +
692 + vmx->exit_reason.full = EXIT_REASON_INVALID_STATE;
693 + vmx->exit_reason.failed_vmentry = 1;
694 +@@ -7573,6 +7591,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
695 + .cache_reg = vmx_cache_reg,
696 + .get_rflags = vmx_get_rflags,
697 + .set_rflags = vmx_set_rflags,
698 ++ .get_if_flag = vmx_get_if_flag,
699 +
700 + .tlb_flush_all = vmx_flush_tlb_all,
701 + .tlb_flush_current = vmx_flush_tlb_current,
702 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
703 +index dea578586fa4e..ccb256c377a6e 100644
704 +--- a/arch/x86/kvm/x86.c
705 ++++ b/arch/x86/kvm/x86.c
706 +@@ -8880,14 +8880,7 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
707 + {
708 + struct kvm_run *kvm_run = vcpu->run;
709 +
710 +- /*
711 +- * if_flag is obsolete and useless, so do not bother
712 +- * setting it for SEV-ES guests. Userspace can just
713 +- * use kvm_run->ready_for_interrupt_injection.
714 +- */
715 +- kvm_run->if_flag = !vcpu->arch.guest_state_protected
716 +- && (kvm_get_rflags(vcpu) & X86_EFLAGS_IF) != 0;
717 +-
718 ++ kvm_run->if_flag = static_call(kvm_x86_get_if_flag)(vcpu);
719 + kvm_run->cr8 = kvm_get_cr8(vcpu);
720 + kvm_run->apic_base = kvm_get_apic_base(vcpu);
721 +
722 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
723 +index a7fdd86fad057..6bce40e2506e5 100644
724 +--- a/drivers/base/power/main.c
725 ++++ b/drivers/base/power/main.c
726 +@@ -1906,7 +1906,7 @@ int dpm_prepare(pm_message_t state)
727 + device_block_probing();
728 +
729 + mutex_lock(&dpm_list_mtx);
730 +- while (!list_empty(&dpm_list)) {
731 ++ while (!list_empty(&dpm_list) && !error) {
732 + struct device *dev = to_device(dpm_list.next);
733 +
734 + get_device(dev);
735 +diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
736 +index 6f225dddc74f4..4566e730ef2b8 100644
737 +--- a/drivers/bus/sunxi-rsb.c
738 ++++ b/drivers/bus/sunxi-rsb.c
739 +@@ -687,11 +687,11 @@ err_clk_disable:
740 +
741 + static void sunxi_rsb_hw_exit(struct sunxi_rsb *rsb)
742 + {
743 +- /* Keep the clock and PM reference counts consistent. */
744 +- if (pm_runtime_status_suspended(rsb->dev))
745 +- pm_runtime_resume(rsb->dev);
746 + reset_control_assert(rsb->rstc);
747 +- clk_disable_unprepare(rsb->clk);
748 ++
749 ++ /* Keep the clock and PM reference counts consistent. */
750 ++ if (!pm_runtime_status_suspended(rsb->dev))
751 ++ clk_disable_unprepare(rsb->clk);
752 + }
753 +
754 + static int __maybe_unused sunxi_rsb_runtime_suspend(struct device *dev)
755 +diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
756 +index b404cc46cbda7..fe91090e04a46 100644
757 +--- a/drivers/char/ipmi/ipmi_msghandler.c
758 ++++ b/drivers/char/ipmi/ipmi_msghandler.c
759 +@@ -2932,7 +2932,7 @@ cleanup_bmc_device(struct kref *ref)
760 + * with removing the device attributes while reading a device
761 + * attribute.
762 + */
763 +- schedule_work(&bmc->remove_work);
764 ++ queue_work(remove_work_wq, &bmc->remove_work);
765 + }
766 +
767 + /*
768 +@@ -5148,22 +5148,27 @@ static int ipmi_init_msghandler(void)
769 + if (initialized)
770 + goto out;
771 +
772 +- init_srcu_struct(&ipmi_interfaces_srcu);
773 +-
774 +- timer_setup(&ipmi_timer, ipmi_timeout, 0);
775 +- mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
776 +-
777 +- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
778 ++ rv = init_srcu_struct(&ipmi_interfaces_srcu);
779 ++ if (rv)
780 ++ goto out;
781 +
782 + remove_work_wq = create_singlethread_workqueue("ipmi-msghandler-remove-wq");
783 + if (!remove_work_wq) {
784 + pr_err("unable to create ipmi-msghandler-remove-wq workqueue");
785 + rv = -ENOMEM;
786 +- goto out;
787 ++ goto out_wq;
788 + }
789 +
790 ++ timer_setup(&ipmi_timer, ipmi_timeout, 0);
791 ++ mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
792 ++
793 ++ atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
794 ++
795 + initialized = true;
796 +
797 ++out_wq:
798 ++ if (rv)
799 ++ cleanup_srcu_struct(&ipmi_interfaces_srcu);
800 + out:
801 + mutex_unlock(&ipmi_interfaces_mutex);
802 + return rv;
803 +diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
804 +index 20d5af92966d4..8d7a8898e80b0 100644
805 +--- a/drivers/char/ipmi/ipmi_ssif.c
806 ++++ b/drivers/char/ipmi/ipmi_ssif.c
807 +@@ -1659,6 +1659,9 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
808 + }
809 + }
810 +
811 ++ ssif_info->client = client;
812 ++ i2c_set_clientdata(client, ssif_info);
813 ++
814 + rv = ssif_check_and_remove(client, ssif_info);
815 + /* If rv is 0 and addr source is not SI_ACPI, continue probing */
816 + if (!rv && ssif_info->addr_source == SI_ACPI) {
817 +@@ -1679,9 +1682,6 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
818 + ipmi_addr_src_to_str(ssif_info->addr_source),
819 + client->addr, client->adapter->name, slave_addr);
820 +
821 +- ssif_info->client = client;
822 +- i2c_set_clientdata(client, ssif_info);
823 +-
824 + /* Now check for system interface capabilities */
825 + msg[0] = IPMI_NETFN_APP_REQUEST << 2;
826 + msg[1] = IPMI_GET_SYSTEM_INTERFACE_CAPABILITIES_CMD;
827 +@@ -1881,6 +1881,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
828 +
829 + dev_err(&ssif_info->client->dev,
830 + "Unable to start IPMI SSIF: %d\n", rv);
831 ++ i2c_set_clientdata(client, NULL);
832 + kfree(ssif_info);
833 + }
834 + kfree(resp);
835 +diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
836 +index 026903e3ef543..08b9e2cf4f2d6 100644
837 +--- a/drivers/gpio/gpio-dln2.c
838 ++++ b/drivers/gpio/gpio-dln2.c
839 +@@ -46,6 +46,7 @@
840 + struct dln2_gpio {
841 + struct platform_device *pdev;
842 + struct gpio_chip gpio;
843 ++ struct irq_chip irqchip;
844 +
845 + /*
846 + * Cache pin direction to save us one transfer, since the hardware has
847 +@@ -383,15 +384,6 @@ static void dln2_irq_bus_unlock(struct irq_data *irqd)
848 + mutex_unlock(&dln2->irq_lock);
849 + }
850 +
851 +-static struct irq_chip dln2_gpio_irqchip = {
852 +- .name = "dln2-irq",
853 +- .irq_mask = dln2_irq_mask,
854 +- .irq_unmask = dln2_irq_unmask,
855 +- .irq_set_type = dln2_irq_set_type,
856 +- .irq_bus_lock = dln2_irq_bus_lock,
857 +- .irq_bus_sync_unlock = dln2_irq_bus_unlock,
858 +-};
859 +-
860 + static void dln2_gpio_event(struct platform_device *pdev, u16 echo,
861 + const void *data, int len)
862 + {
863 +@@ -473,8 +465,15 @@ static int dln2_gpio_probe(struct platform_device *pdev)
864 + dln2->gpio.direction_output = dln2_gpio_direction_output;
865 + dln2->gpio.set_config = dln2_gpio_set_config;
866 +
867 ++ dln2->irqchip.name = "dln2-irq",
868 ++ dln2->irqchip.irq_mask = dln2_irq_mask,
869 ++ dln2->irqchip.irq_unmask = dln2_irq_unmask,
870 ++ dln2->irqchip.irq_set_type = dln2_irq_set_type,
871 ++ dln2->irqchip.irq_bus_lock = dln2_irq_bus_lock,
872 ++ dln2->irqchip.irq_bus_sync_unlock = dln2_irq_bus_unlock,
873 ++
874 + girq = &dln2->gpio.irq;
875 +- girq->chip = &dln2_gpio_irqchip;
876 ++ girq->chip = &dln2->irqchip;
877 + /* The event comes from the outside so no parent handler */
878 + girq->parent_handler = NULL;
879 + girq->num_parents = 0;
880 +diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
881 +index d24f1c9264bc9..dd3b23c9580b1 100644
882 +--- a/drivers/gpio/gpio-virtio.c
883 ++++ b/drivers/gpio/gpio-virtio.c
884 +@@ -81,11 +81,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
885 + virtqueue_kick(vgpio->request_vq);
886 + mutex_unlock(&vgpio->lock);
887 +
888 +- if (!wait_for_completion_timeout(&line->completion, HZ)) {
889 +- dev_err(dev, "GPIO operation timed out\n");
890 +- ret = -ETIMEDOUT;
891 +- goto out;
892 +- }
893 ++ wait_for_completion(&line->completion);
894 +
895 + if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
896 + dev_err(dev, "GPIO request failed: %d\n", gpio);
897 +diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
898 +index 5838c44cbf6f0..3196189429bcf 100644
899 +--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
900 ++++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
901 +@@ -1224,12 +1224,14 @@ static int mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
902 + return MODE_BAD;
903 + }
904 +
905 +- if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
906 +- return MODE_BAD;
907 ++ if (hdmi->conf) {
908 ++ if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
909 ++ return MODE_BAD;
910 +
911 +- if (hdmi->conf->max_mode_clock &&
912 +- mode->clock > hdmi->conf->max_mode_clock)
913 +- return MODE_CLOCK_HIGH;
914 ++ if (hdmi->conf->max_mode_clock &&
915 ++ mode->clock > hdmi->conf->max_mode_clock)
916 ++ return MODE_CLOCK_HIGH;
917 ++ }
918 +
919 + if (mode->clock < 27000)
920 + return MODE_CLOCK_LOW;
921 +diff --git a/drivers/hid/hid-holtek-mouse.c b/drivers/hid/hid-holtek-mouse.c
922 +index b7172c48ef9f0..7c907939bfae1 100644
923 +--- a/drivers/hid/hid-holtek-mouse.c
924 ++++ b/drivers/hid/hid-holtek-mouse.c
925 +@@ -65,8 +65,23 @@ static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
926 + static int holtek_mouse_probe(struct hid_device *hdev,
927 + const struct hid_device_id *id)
928 + {
929 ++ int ret;
930 ++
931 + if (!hid_is_usb(hdev))
932 + return -EINVAL;
933 ++
934 ++ ret = hid_parse(hdev);
935 ++ if (ret) {
936 ++ hid_err(hdev, "hid parse failed: %d\n", ret);
937 ++ return ret;
938 ++ }
939 ++
940 ++ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
941 ++ if (ret) {
942 ++ hid_err(hdev, "hw start failed: %d\n", ret);
943 ++ return ret;
944 ++ }
945 ++
946 + return 0;
947 + }
948 +
949 +diff --git a/drivers/hid/hid-vivaldi.c b/drivers/hid/hid-vivaldi.c
950 +index cd7ada48b1d9f..72957a9f71170 100644
951 +--- a/drivers/hid/hid-vivaldi.c
952 ++++ b/drivers/hid/hid-vivaldi.c
953 +@@ -57,6 +57,9 @@ static int vivaldi_probe(struct hid_device *hdev,
954 + int ret;
955 +
956 + drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
957 ++ if (!drvdata)
958 ++ return -ENOMEM;
959 ++
960 + hid_set_drvdata(hdev, drvdata);
961 +
962 + ret = hid_parse(hdev);
963 +diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
964 +index c4578e8f34bb5..ccdaeafed0bb7 100644
965 +--- a/drivers/hwmon/Kconfig
966 ++++ b/drivers/hwmon/Kconfig
967 +@@ -1317,7 +1317,7 @@ config SENSORS_LM90
968 + Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6654, MAX6657, MAX6658,
969 + MAX6659, MAX6680, MAX6681, MAX6692, MAX6695, MAX6696,
970 + ON Semiconductor NCT1008, Winbond/Nuvoton W83L771W/G/AWG/ASG,
971 +- Philips SA56004, GMT G781, and Texas Instruments TMP451
972 ++ Philips SA56004, GMT G781, Texas Instruments TMP451 and TMP461
973 + sensor chips.
974 +
975 + This driver can also be built as a module. If so, the module
976 +diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
977 +index 567b7c521f388..74019dff2550e 100644
978 +--- a/drivers/hwmon/lm90.c
979 ++++ b/drivers/hwmon/lm90.c
980 +@@ -35,13 +35,14 @@
981 + * explicitly as max6659, or if its address is not 0x4c.
982 + * These chips lack the remote temperature offset feature.
983 + *
984 +- * This driver also supports the MAX6654 chip made by Maxim. This chip can
985 +- * be at 9 different addresses, similar to MAX6680/MAX6681. The MAX6654 is
986 +- * otherwise similar to MAX6657/MAX6658/MAX6659. Extended range is available
987 +- * by setting the configuration register accordingly, and is done during
988 +- * initialization. Extended precision is only available at conversion rates
989 +- * of 1 Hz and slower. Note that extended precision is not enabled by
990 +- * default, as this driver initializes all chips to 2 Hz by design.
991 ++ * This driver also supports the MAX6654 chip made by Maxim. This chip can be
992 ++ * at 9 different addresses, similar to MAX6680/MAX6681. The MAX6654 is similar
993 ++ * to MAX6657/MAX6658/MAX6659, but does not support critical temperature
994 ++ * limits. Extended range is available by setting the configuration register
995 ++ * accordingly, and is done during initialization. Extended precision is only
996 ++ * available at conversion rates of 1 Hz and slower. Note that extended
997 ++ * precision is not enabled by default, as this driver initializes all chips
998 ++ * to 2 Hz by design.
999 + *
1000 + * This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and
1001 + * MAX6692 chips made by Maxim. These are again similar to the LM86,
1002 +@@ -69,10 +70,10 @@
1003 + * This driver also supports the G781 from GMT. This device is compatible
1004 + * with the ADM1032.
1005 + *
1006 +- * This driver also supports TMP451 from Texas Instruments. This device is
1007 +- * supported in both compatibility and extended mode. It's mostly compatible
1008 +- * with ADT7461 except for local temperature low byte register and max
1009 +- * conversion rate.
1010 ++ * This driver also supports TMP451 and TMP461 from Texas Instruments.
1011 ++ * Those devices are supported in both compatibility and extended mode.
1012 ++ * They are mostly compatible with ADT7461 except for local temperature
1013 ++ * low byte register and max conversion rate.
1014 + *
1015 + * Since the LM90 was the first chipset supported by this driver, most
1016 + * comments will refer to this chipset, but are actually general and
1017 +@@ -112,7 +113,7 @@ static const unsigned short normal_i2c[] = {
1018 + 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
1019 +
1020 + enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
1021 +- max6646, w83l771, max6696, sa56004, g781, tmp451, max6654 };
1022 ++ max6646, w83l771, max6696, sa56004, g781, tmp451, tmp461, max6654 };
1023 +
1024 + /*
1025 + * The LM90 registers
1026 +@@ -168,8 +169,12 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
1027 +
1028 + #define LM90_MAX_CONVRATE_MS 16000 /* Maximum conversion rate in ms */
1029 +
1030 +-/* TMP451 registers */
1031 ++/* TMP451/TMP461 registers */
1032 + #define TMP451_REG_R_LOCAL_TEMPL 0x15
1033 ++#define TMP451_REG_CONALERT 0x22
1034 ++
1035 ++#define TMP461_REG_CHEN 0x16
1036 ++#define TMP461_REG_DFC 0x24
1037 +
1038 + /*
1039 + * Device flags
1040 +@@ -182,7 +187,10 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
1041 + #define LM90_HAVE_EMERGENCY_ALARM (1 << 5)/* emergency alarm */
1042 + #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */
1043 + #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */
1044 +-#define LM90_PAUSE_FOR_CONFIG (1 << 8) /* Pause conversion for config */
1045 ++#define LM90_HAVE_EXTENDED_TEMP (1 << 8) /* extended temperature support*/
1046 ++#define LM90_PAUSE_FOR_CONFIG (1 << 9) /* Pause conversion for config */
1047 ++#define LM90_HAVE_CRIT (1 << 10)/* Chip supports CRIT/OVERT register */
1048 ++#define LM90_HAVE_CRIT_ALRM_SWP (1 << 11)/* critical alarm bits swapped */
1049 +
1050 + /* LM90 status */
1051 + #define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */
1052 +@@ -192,6 +200,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
1053 + #define LM90_STATUS_RHIGH (1 << 4) /* remote high temp limit tripped */
1054 + #define LM90_STATUS_LLOW (1 << 5) /* local low temp limit tripped */
1055 + #define LM90_STATUS_LHIGH (1 << 6) /* local high temp limit tripped */
1056 ++#define LM90_STATUS_BUSY (1 << 7) /* conversion is ongoing */
1057 +
1058 + #define MAX6696_STATUS2_R2THRM (1 << 1) /* remote2 THERM limit tripped */
1059 + #define MAX6696_STATUS2_R2OPEN (1 << 2) /* remote2 is an open circuit */
1060 +@@ -229,6 +238,7 @@ static const struct i2c_device_id lm90_id[] = {
1061 + { "w83l771", w83l771 },
1062 + { "sa56004", sa56004 },
1063 + { "tmp451", tmp451 },
1064 ++ { "tmp461", tmp461 },
1065 + { }
1066 + };
1067 + MODULE_DEVICE_TABLE(i2c, lm90_id);
1068 +@@ -326,6 +336,10 @@ static const struct of_device_id __maybe_unused lm90_of_match[] = {
1069 + .compatible = "ti,tmp451",
1070 + .data = (void *)tmp451
1071 + },
1072 ++ {
1073 ++ .compatible = "ti,tmp461",
1074 ++ .data = (void *)tmp461
1075 ++ },
1076 + { },
1077 + };
1078 + MODULE_DEVICE_TABLE(of, lm90_of_match);
1079 +@@ -344,38 +358,43 @@ struct lm90_params {
1080 + static const struct lm90_params lm90_params[] = {
1081 + [adm1032] = {
1082 + .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1083 +- | LM90_HAVE_BROKEN_ALERT,
1084 ++ | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_CRIT,
1085 + .alert_alarms = 0x7c,
1086 + .max_convrate = 10,
1087 + },
1088 + [adt7461] = {
1089 + .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1090 +- | LM90_HAVE_BROKEN_ALERT,
1091 ++ | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP
1092 ++ | LM90_HAVE_CRIT,
1093 + .alert_alarms = 0x7c,
1094 + .max_convrate = 10,
1095 + },
1096 + [g781] = {
1097 + .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1098 +- | LM90_HAVE_BROKEN_ALERT,
1099 ++ | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_CRIT,
1100 + .alert_alarms = 0x7c,
1101 + .max_convrate = 8,
1102 + },
1103 + [lm86] = {
1104 +- .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
1105 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1106 ++ | LM90_HAVE_CRIT,
1107 + .alert_alarms = 0x7b,
1108 + .max_convrate = 9,
1109 + },
1110 + [lm90] = {
1111 +- .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
1112 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1113 ++ | LM90_HAVE_CRIT,
1114 + .alert_alarms = 0x7b,
1115 + .max_convrate = 9,
1116 + },
1117 + [lm99] = {
1118 +- .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
1119 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1120 ++ | LM90_HAVE_CRIT,
1121 + .alert_alarms = 0x7b,
1122 + .max_convrate = 9,
1123 + },
1124 + [max6646] = {
1125 ++ .flags = LM90_HAVE_CRIT,
1126 + .alert_alarms = 0x7c,
1127 + .max_convrate = 6,
1128 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1129 +@@ -386,43 +405,51 @@ static const struct lm90_params lm90_params[] = {
1130 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1131 + },
1132 + [max6657] = {
1133 +- .flags = LM90_PAUSE_FOR_CONFIG,
1134 ++ .flags = LM90_PAUSE_FOR_CONFIG | LM90_HAVE_CRIT,
1135 + .alert_alarms = 0x7c,
1136 + .max_convrate = 8,
1137 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1138 + },
1139 + [max6659] = {
1140 +- .flags = LM90_HAVE_EMERGENCY,
1141 ++ .flags = LM90_HAVE_EMERGENCY | LM90_HAVE_CRIT,
1142 + .alert_alarms = 0x7c,
1143 + .max_convrate = 8,
1144 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1145 + },
1146 + [max6680] = {
1147 +- .flags = LM90_HAVE_OFFSET,
1148 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_CRIT
1149 ++ | LM90_HAVE_CRIT_ALRM_SWP,
1150 + .alert_alarms = 0x7c,
1151 + .max_convrate = 7,
1152 + },
1153 + [max6696] = {
1154 + .flags = LM90_HAVE_EMERGENCY
1155 +- | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3,
1156 ++ | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3 | LM90_HAVE_CRIT,
1157 + .alert_alarms = 0x1c7c,
1158 + .max_convrate = 6,
1159 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1160 + },
1161 + [w83l771] = {
1162 +- .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
1163 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT | LM90_HAVE_CRIT,
1164 + .alert_alarms = 0x7c,
1165 + .max_convrate = 8,
1166 + },
1167 + [sa56004] = {
1168 +- .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
1169 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT | LM90_HAVE_CRIT,
1170 + .alert_alarms = 0x7b,
1171 + .max_convrate = 9,
1172 + .reg_local_ext = SA56004_REG_R_LOCAL_TEMPL,
1173 + },
1174 + [tmp451] = {
1175 + .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1176 +- | LM90_HAVE_BROKEN_ALERT,
1177 ++ | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP | LM90_HAVE_CRIT,
1178 ++ .alert_alarms = 0x7c,
1179 ++ .max_convrate = 9,
1180 ++ .reg_local_ext = TMP451_REG_R_LOCAL_TEMPL,
1181 ++ },
1182 ++ [tmp461] = {
1183 ++ .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
1184 ++ | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP | LM90_HAVE_CRIT,
1185 + .alert_alarms = 0x7c,
1186 + .max_convrate = 9,
1187 + .reg_local_ext = TMP451_REG_R_LOCAL_TEMPL,
1188 +@@ -651,20 +678,22 @@ static int lm90_update_limits(struct device *dev)
1189 + struct i2c_client *client = data->client;
1190 + int val;
1191 +
1192 +- val = lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT);
1193 +- if (val < 0)
1194 +- return val;
1195 +- data->temp8[LOCAL_CRIT] = val;
1196 ++ if (data->flags & LM90_HAVE_CRIT) {
1197 ++ val = lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT);
1198 ++ if (val < 0)
1199 ++ return val;
1200 ++ data->temp8[LOCAL_CRIT] = val;
1201 +
1202 +- val = lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT);
1203 +- if (val < 0)
1204 +- return val;
1205 +- data->temp8[REMOTE_CRIT] = val;
1206 ++ val = lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT);
1207 ++ if (val < 0)
1208 ++ return val;
1209 ++ data->temp8[REMOTE_CRIT] = val;
1210 +
1211 +- val = lm90_read_reg(client, LM90_REG_R_TCRIT_HYST);
1212 +- if (val < 0)
1213 +- return val;
1214 +- data->temp_hyst = val;
1215 ++ val = lm90_read_reg(client, LM90_REG_R_TCRIT_HYST);
1216 ++ if (val < 0)
1217 ++ return val;
1218 ++ data->temp_hyst = val;
1219 ++ }
1220 +
1221 + val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH);
1222 + if (val < 0)
1223 +@@ -792,7 +821,7 @@ static int lm90_update_device(struct device *dev)
1224 + val = lm90_read_reg(client, LM90_REG_R_STATUS);
1225 + if (val < 0)
1226 + return val;
1227 +- data->alarms = val; /* lower 8 bit of alarms */
1228 ++ data->alarms = val & ~LM90_STATUS_BUSY;
1229 +
1230 + if (data->kind == max6696) {
1231 + val = lm90_select_remote_channel(data, 1);
1232 +@@ -998,7 +1027,7 @@ static int lm90_get_temp11(struct lm90_data *data, int index)
1233 + s16 temp11 = data->temp11[index];
1234 + int temp;
1235 +
1236 +- if (data->kind == adt7461 || data->kind == tmp451)
1237 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1238 + temp = temp_from_u16_adt7461(data, temp11);
1239 + else if (data->kind == max6646)
1240 + temp = temp_from_u16(temp11);
1241 +@@ -1035,7 +1064,7 @@ static int lm90_set_temp11(struct lm90_data *data, int index, long val)
1242 + val -= 16000;
1243 + }
1244 +
1245 +- if (data->kind == adt7461 || data->kind == tmp451)
1246 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1247 + data->temp11[index] = temp_to_u16_adt7461(data, val);
1248 + else if (data->kind == max6646)
1249 + data->temp11[index] = temp_to_u8(val) << 8;
1250 +@@ -1062,7 +1091,7 @@ static int lm90_get_temp8(struct lm90_data *data, int index)
1251 + s8 temp8 = data->temp8[index];
1252 + int temp;
1253 +
1254 +- if (data->kind == adt7461 || data->kind == tmp451)
1255 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1256 + temp = temp_from_u8_adt7461(data, temp8);
1257 + else if (data->kind == max6646)
1258 + temp = temp_from_u8(temp8);
1259 +@@ -1098,7 +1127,7 @@ static int lm90_set_temp8(struct lm90_data *data, int index, long val)
1260 + val -= 16000;
1261 + }
1262 +
1263 +- if (data->kind == adt7461 || data->kind == tmp451)
1264 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1265 + data->temp8[index] = temp_to_u8_adt7461(data, val);
1266 + else if (data->kind == max6646)
1267 + data->temp8[index] = temp_to_u8(val);
1268 +@@ -1116,7 +1145,7 @@ static int lm90_get_temphyst(struct lm90_data *data, int index)
1269 + {
1270 + int temp;
1271 +
1272 +- if (data->kind == adt7461 || data->kind == tmp451)
1273 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1274 + temp = temp_from_u8_adt7461(data, data->temp8[index]);
1275 + else if (data->kind == max6646)
1276 + temp = temp_from_u8(data->temp8[index]);
1277 +@@ -1136,15 +1165,15 @@ static int lm90_set_temphyst(struct lm90_data *data, long val)
1278 + int temp;
1279 + int err;
1280 +
1281 +- if (data->kind == adt7461 || data->kind == tmp451)
1282 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP)
1283 + temp = temp_from_u8_adt7461(data, data->temp8[LOCAL_CRIT]);
1284 + else if (data->kind == max6646)
1285 + temp = temp_from_u8(data->temp8[LOCAL_CRIT]);
1286 + else
1287 + temp = temp_from_s8(data->temp8[LOCAL_CRIT]);
1288 +
1289 +- /* prevent integer underflow */
1290 +- val = max(val, -128000l);
1291 ++ /* prevent integer overflow/underflow */
1292 ++ val = clamp_val(val, -128000l, 255000l);
1293 +
1294 + data->temp_hyst = hyst_to_reg(temp - val);
1295 + err = i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
1296 +@@ -1175,6 +1204,7 @@ static const u8 lm90_temp_emerg_index[3] = {
1297 + static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
1298 + static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
1299 + static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
1300 ++static const u8 lm90_crit_alarm_bits_swapped[3] = { 1, 0, 9 };
1301 + static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
1302 + static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
1303 +
1304 +@@ -1200,7 +1230,10 @@ static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val)
1305 + *val = (data->alarms >> lm90_max_alarm_bits[channel]) & 1;
1306 + break;
1307 + case hwmon_temp_crit_alarm:
1308 +- *val = (data->alarms >> lm90_crit_alarm_bits[channel]) & 1;
1309 ++ if (data->flags & LM90_HAVE_CRIT_ALRM_SWP)
1310 ++ *val = (data->alarms >> lm90_crit_alarm_bits_swapped[channel]) & 1;
1311 ++ else
1312 ++ *val = (data->alarms >> lm90_crit_alarm_bits[channel]) & 1;
1313 + break;
1314 + case hwmon_temp_emergency_alarm:
1315 + *val = (data->alarms >> lm90_emergency_alarm_bits[channel]) & 1;
1316 +@@ -1448,12 +1481,11 @@ static int lm90_detect(struct i2c_client *client,
1317 + if (man_id < 0 || chip_id < 0 || config1 < 0 || convrate < 0)
1318 + return -ENODEV;
1319 +
1320 +- if (man_id == 0x01 || man_id == 0x5C || man_id == 0x41) {
1321 ++ if (man_id == 0x01 || man_id == 0x5C || man_id == 0xA1) {
1322 + config2 = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG2);
1323 + if (config2 < 0)
1324 + return -ENODEV;
1325 +- } else
1326 +- config2 = 0; /* Make compiler happy */
1327 ++ }
1328 +
1329 + if ((address == 0x4C || address == 0x4D)
1330 + && man_id == 0x01) { /* National Semiconductor */
1331 +@@ -1627,18 +1659,26 @@ static int lm90_detect(struct i2c_client *client,
1332 + && convrate <= 0x08)
1333 + name = "g781";
1334 + } else
1335 +- if (address == 0x4C
1336 +- && man_id == 0x55) { /* Texas Instruments */
1337 +- int local_ext;
1338 ++ if (man_id == 0x55 && chip_id == 0x00 &&
1339 ++ (config1 & 0x1B) == 0x00 && convrate <= 0x09) {
1340 ++ int local_ext, conalert, chen, dfc;
1341 +
1342 + local_ext = i2c_smbus_read_byte_data(client,
1343 + TMP451_REG_R_LOCAL_TEMPL);
1344 +-
1345 +- if (chip_id == 0x00 /* TMP451 */
1346 +- && (config1 & 0x1B) == 0x00
1347 +- && convrate <= 0x09
1348 +- && (local_ext & 0x0F) == 0x00)
1349 +- name = "tmp451";
1350 ++ conalert = i2c_smbus_read_byte_data(client,
1351 ++ TMP451_REG_CONALERT);
1352 ++ chen = i2c_smbus_read_byte_data(client, TMP461_REG_CHEN);
1353 ++ dfc = i2c_smbus_read_byte_data(client, TMP461_REG_DFC);
1354 ++
1355 ++ if ((local_ext & 0x0F) == 0x00 &&
1356 ++ (conalert & 0xf1) == 0x01 &&
1357 ++ (chen & 0xfc) == 0x00 &&
1358 ++ (dfc & 0xfc) == 0x00) {
1359 ++ if (address == 0x4c && !(chen & 0x03))
1360 ++ name = "tmp451";
1361 ++ else if (address >= 0x48 && address <= 0x4f)
1362 ++ name = "tmp461";
1363 ++ }
1364 + }
1365 +
1366 + if (!name) { /* identification failed */
1367 +@@ -1685,7 +1725,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
1368 + lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
1369 +
1370 + /* Check Temperature Range Select */
1371 +- if (data->kind == adt7461 || data->kind == tmp451) {
1372 ++ if (data->flags & LM90_HAVE_EXTENDED_TEMP) {
1373 + if (config & 0x04)
1374 + data->flags |= LM90_FLAG_ADT7461_EXT;
1375 + }
1376 +@@ -1878,11 +1918,14 @@ static int lm90_probe(struct i2c_client *client)
1377 + info->config = data->channel_config;
1378 +
1379 + data->channel_config[0] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX |
1380 +- HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM |
1381 +- HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM;
1382 ++ HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM;
1383 + data->channel_config[1] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX |
1384 +- HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM |
1385 +- HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | HWMON_T_FAULT;
1386 ++ HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_FAULT;
1387 ++
1388 ++ if (data->flags & LM90_HAVE_CRIT) {
1389 ++ data->channel_config[0] |= HWMON_T_CRIT | HWMON_T_CRIT_ALARM | HWMON_T_CRIT_HYST;
1390 ++ data->channel_config[1] |= HWMON_T_CRIT | HWMON_T_CRIT_ALARM | HWMON_T_CRIT_HYST;
1391 ++ }
1392 +
1393 + if (data->flags & LM90_HAVE_OFFSET)
1394 + data->channel_config[1] |= HWMON_T_OFFSET;
1395 +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
1396 +index 51dd134952e77..96fe73ba689c1 100644
1397 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
1398 ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
1399 +@@ -1604,11 +1604,17 @@ static int hns_roce_config_global_param(struct hns_roce_dev *hr_dev)
1400 + {
1401 + struct hns_roce_cmq_desc desc;
1402 + struct hns_roce_cmq_req *req = (struct hns_roce_cmq_req *)desc.data;
1403 ++ u32 clock_cycles_of_1us;
1404 +
1405 + hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_CFG_GLOBAL_PARAM,
1406 + false);
1407 +
1408 +- hr_reg_write(req, CFG_GLOBAL_PARAM_1US_CYCLES, 0x3e8);
1409 ++ if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08)
1410 ++ clock_cycles_of_1us = HNS_ROCE_1NS_CFG;
1411 ++ else
1412 ++ clock_cycles_of_1us = HNS_ROCE_1US_CFG;
1413 ++
1414 ++ hr_reg_write(req, CFG_GLOBAL_PARAM_1US_CYCLES, clock_cycles_of_1us);
1415 + hr_reg_write(req, CFG_GLOBAL_PARAM_UDP_PORT, ROCE_V2_UDP_DPORT);
1416 +
1417 + return hns_roce_cmq_send(hr_dev, &desc, 1);
1418 +@@ -4812,6 +4818,30 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp,
1419 + return ret;
1420 + }
1421 +
1422 ++static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout)
1423 ++{
1424 ++#define QP_ACK_TIMEOUT_MAX_HIP08 20
1425 ++#define QP_ACK_TIMEOUT_OFFSET 10
1426 ++#define QP_ACK_TIMEOUT_MAX 31
1427 ++
1428 ++ if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
1429 ++ if (*timeout > QP_ACK_TIMEOUT_MAX_HIP08) {
1430 ++ ibdev_warn(&hr_dev->ib_dev,
1431 ++ "Local ACK timeout shall be 0 to 20.\n");
1432 ++ return false;
1433 ++ }
1434 ++ *timeout += QP_ACK_TIMEOUT_OFFSET;
1435 ++ } else if (hr_dev->pci_dev->revision > PCI_REVISION_ID_HIP08) {
1436 ++ if (*timeout > QP_ACK_TIMEOUT_MAX) {
1437 ++ ibdev_warn(&hr_dev->ib_dev,
1438 ++ "Local ACK timeout shall be 0 to 31.\n");
1439 ++ return false;
1440 ++ }
1441 ++ }
1442 ++
1443 ++ return true;
1444 ++}
1445 ++
1446 + static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
1447 + const struct ib_qp_attr *attr,
1448 + int attr_mask,
1449 +@@ -4821,6 +4851,7 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
1450 + struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
1451 + struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
1452 + int ret = 0;
1453 ++ u8 timeout;
1454 +
1455 + if (attr_mask & IB_QP_AV) {
1456 + ret = hns_roce_v2_set_path(ibqp, attr, attr_mask, context,
1457 +@@ -4830,12 +4861,10 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
1458 + }
1459 +
1460 + if (attr_mask & IB_QP_TIMEOUT) {
1461 +- if (attr->timeout < 31) {
1462 +- hr_reg_write(context, QPC_AT, attr->timeout);
1463 ++ timeout = attr->timeout;
1464 ++ if (check_qp_timeout_cfg_range(hr_dev, &timeout)) {
1465 ++ hr_reg_write(context, QPC_AT, timeout);
1466 + hr_reg_clear(qpc_mask, QPC_AT);
1467 +- } else {
1468 +- ibdev_warn(&hr_dev->ib_dev,
1469 +- "Local ACK timeout shall be 0 to 30.\n");
1470 + }
1471 + }
1472 +
1473 +@@ -4892,7 +4921,9 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
1474 + set_access_flags(hr_qp, context, qpc_mask, attr, attr_mask);
1475 +
1476 + if (attr_mask & IB_QP_MIN_RNR_TIMER) {
1477 +- hr_reg_write(context, QPC_MIN_RNR_TIME, attr->min_rnr_timer);
1478 ++ hr_reg_write(context, QPC_MIN_RNR_TIME,
1479 ++ hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08 ?
1480 ++ HNS_ROCE_RNR_TIMER_10NS : attr->min_rnr_timer);
1481 + hr_reg_clear(qpc_mask, QPC_MIN_RNR_TIME);
1482 + }
1483 +
1484 +@@ -5509,6 +5540,16 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
1485 +
1486 + hr_reg_write(cq_context, CQC_CQ_MAX_CNT, cq_count);
1487 + hr_reg_clear(cqc_mask, CQC_CQ_MAX_CNT);
1488 ++
1489 ++ if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
1490 ++ if (cq_period * HNS_ROCE_CLOCK_ADJUST > USHRT_MAX) {
1491 ++ dev_info(hr_dev->dev,
1492 ++ "cq_period(%u) reached the upper limit, adjusted to 65.\n",
1493 ++ cq_period);
1494 ++ cq_period = HNS_ROCE_MAX_CQ_PERIOD;
1495 ++ }
1496 ++ cq_period *= HNS_ROCE_CLOCK_ADJUST;
1497 ++ }
1498 + hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period);
1499 + hr_reg_clear(cqc_mask, CQC_CQ_PERIOD);
1500 +
1501 +@@ -5904,6 +5945,15 @@ static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq,
1502 + hr_reg_write(eqc, EQC_EQ_PROD_INDX, HNS_ROCE_EQ_INIT_PROD_IDX);
1503 + hr_reg_write(eqc, EQC_EQ_MAX_CNT, eq->eq_max_cnt);
1504 +
1505 ++ if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
1506 ++ if (eq->eq_period * HNS_ROCE_CLOCK_ADJUST > USHRT_MAX) {
1507 ++ dev_info(hr_dev->dev, "eq_period(%u) reached the upper limit, adjusted to 65.\n",
1508 ++ eq->eq_period);
1509 ++ eq->eq_period = HNS_ROCE_MAX_EQ_PERIOD;
1510 ++ }
1511 ++ eq->eq_period *= HNS_ROCE_CLOCK_ADJUST;
1512 ++ }
1513 ++
1514 + hr_reg_write(eqc, EQC_EQ_PERIOD, eq->eq_period);
1515 + hr_reg_write(eqc, EQC_EQE_REPORT_TIMER, HNS_ROCE_EQ_INIT_REPORT_TIMER);
1516 + hr_reg_write(eqc, EQC_EQE_BA_L, bt_ba >> 3);
1517 +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
1518 +index 4d904d5e82be4..35c61da7ba156 100644
1519 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
1520 ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
1521 +@@ -1444,6 +1444,14 @@ struct hns_roce_dip {
1522 + struct list_head node; /* all dips are on a list */
1523 + };
1524 +
1525 ++/* only for RNR timeout issue of HIP08 */
1526 ++#define HNS_ROCE_CLOCK_ADJUST 1000
1527 ++#define HNS_ROCE_MAX_CQ_PERIOD 65
1528 ++#define HNS_ROCE_MAX_EQ_PERIOD 65
1529 ++#define HNS_ROCE_RNR_TIMER_10NS 1
1530 ++#define HNS_ROCE_1US_CFG 999
1531 ++#define HNS_ROCE_1NS_CFG 0
1532 ++
1533 + #define HNS_ROCE_AEQ_DEFAULT_BURST_NUM 0x0
1534 + #define HNS_ROCE_AEQ_DEFAULT_INTERVAL 0x0
1535 + #define HNS_ROCE_CEQ_DEFAULT_BURST_NUM 0x0
1536 +diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
1537 +index 6eee9deadd122..e64ef6903fb4f 100644
1538 +--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
1539 ++++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
1540 +@@ -259,7 +259,7 @@ static int alloc_srq_wrid(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
1541 +
1542 + static void free_srq_wrid(struct hns_roce_srq *srq)
1543 + {
1544 +- kfree(srq->wrid);
1545 ++ kvfree(srq->wrid);
1546 + srq->wrid = NULL;
1547 + }
1548 +
1549 +diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
1550 +index ac11943a5ddb0..bf2f30d67949d 100644
1551 +--- a/drivers/infiniband/hw/qib/qib_user_sdma.c
1552 ++++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
1553 +@@ -941,7 +941,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
1554 + &addrlimit) ||
1555 + addrlimit > type_max(typeof(pkt->addrlimit))) {
1556 + ret = -EINVAL;
1557 +- goto free_pbc;
1558 ++ goto free_pkt;
1559 + }
1560 + pkt->addrlimit = addrlimit;
1561 +
1562 +diff --git a/drivers/input/misc/iqs626a.c b/drivers/input/misc/iqs626a.c
1563 +index d57e996732cf4..23b5dd9552dcc 100644
1564 +--- a/drivers/input/misc/iqs626a.c
1565 ++++ b/drivers/input/misc/iqs626a.c
1566 +@@ -456,9 +456,10 @@ struct iqs626_private {
1567 + unsigned int suspend_mode;
1568 + };
1569 +
1570 +-static int iqs626_parse_events(struct iqs626_private *iqs626,
1571 +- const struct fwnode_handle *ch_node,
1572 +- enum iqs626_ch_id ch_id)
1573 ++static noinline_for_stack int
1574 ++iqs626_parse_events(struct iqs626_private *iqs626,
1575 ++ const struct fwnode_handle *ch_node,
1576 ++ enum iqs626_ch_id ch_id)
1577 + {
1578 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;
1579 + struct i2c_client *client = iqs626->client;
1580 +@@ -604,9 +605,10 @@ static int iqs626_parse_events(struct iqs626_private *iqs626,
1581 + return 0;
1582 + }
1583 +
1584 +-static int iqs626_parse_ati_target(struct iqs626_private *iqs626,
1585 +- const struct fwnode_handle *ch_node,
1586 +- enum iqs626_ch_id ch_id)
1587 ++static noinline_for_stack int
1588 ++iqs626_parse_ati_target(struct iqs626_private *iqs626,
1589 ++ const struct fwnode_handle *ch_node,
1590 ++ enum iqs626_ch_id ch_id)
1591 + {
1592 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;
1593 + struct i2c_client *client = iqs626->client;
1594 +@@ -885,9 +887,10 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
1595 + return 0;
1596 + }
1597 +
1598 +-static int iqs626_parse_channel(struct iqs626_private *iqs626,
1599 +- const struct fwnode_handle *ch_node,
1600 +- enum iqs626_ch_id ch_id)
1601 ++static noinline_for_stack int
1602 ++iqs626_parse_channel(struct iqs626_private *iqs626,
1603 ++ const struct fwnode_handle *ch_node,
1604 ++ enum iqs626_ch_id ch_id)
1605 + {
1606 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;
1607 + struct i2c_client *client = iqs626->client;
1608 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
1609 +index 956d9cd347964..ece97f8c6a3e3 100644
1610 +--- a/drivers/input/mouse/elantech.c
1611 ++++ b/drivers/input/mouse/elantech.c
1612 +@@ -1588,7 +1588,13 @@ static const struct dmi_system_id no_hw_res_dmi_table[] = {
1613 + */
1614 + static int elantech_change_report_id(struct psmouse *psmouse)
1615 + {
1616 +- unsigned char param[2] = { 0x10, 0x03 };
1617 ++ /*
1618 ++ * NOTE: the code is expecting to receive param[] as an array of 3
1619 ++ * items (see __ps2_command()), even if in this case only 2 are
1620 ++ * actually needed. Make sure the array size is 3 to avoid potential
1621 ++ * stack out-of-bound accesses.
1622 ++ */
1623 ++ unsigned char param[3] = { 0x10, 0x03 };
1624 +
1625 + if (elantech_write_reg_params(psmouse, 0x7, param) ||
1626 + elantech_read_reg_params(psmouse, 0x7, param) ||
1627 +diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
1628 +index 05de92c0293bc..eb66cd2689b7c 100644
1629 +--- a/drivers/input/touchscreen/atmel_mxt_ts.c
1630 ++++ b/drivers/input/touchscreen/atmel_mxt_ts.c
1631 +@@ -1882,7 +1882,7 @@ static int mxt_read_info_block(struct mxt_data *data)
1632 + if (error) {
1633 + dev_err(&client->dev, "Error %d parsing object table\n", error);
1634 + mxt_free_object_table(data);
1635 +- goto err_free_mem;
1636 ++ return error;
1637 + }
1638 +
1639 + data->object_table = (struct mxt_object *)(id_buf + MXT_OBJECT_START);
1640 +diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
1641 +index 68f542bb809f4..b9e2219efbb8f 100644
1642 +--- a/drivers/input/touchscreen/elants_i2c.c
1643 ++++ b/drivers/input/touchscreen/elants_i2c.c
1644 +@@ -117,6 +117,19 @@
1645 + #define ELAN_POWERON_DELAY_USEC 500
1646 + #define ELAN_RESET_DELAY_MSEC 20
1647 +
1648 ++/* FW boot code version */
1649 ++#define BC_VER_H_BYTE_FOR_EKTH3900x1_I2C 0x72
1650 ++#define BC_VER_H_BYTE_FOR_EKTH3900x2_I2C 0x82
1651 ++#define BC_VER_H_BYTE_FOR_EKTH3900x3_I2C 0x92
1652 ++#define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C 0x6D
1653 ++#define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C 0x6E
1654 ++#define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C 0x77
1655 ++#define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C 0x78
1656 ++#define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB 0x67
1657 ++#define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB 0x68
1658 ++#define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB 0x74
1659 ++#define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB 0x75
1660 ++
1661 + enum elants_chip_id {
1662 + EKTH3500,
1663 + EKTF3624,
1664 +@@ -736,6 +749,37 @@ static int elants_i2c_validate_remark_id(struct elants_data *ts,
1665 + return 0;
1666 + }
1667 +
1668 ++static bool elants_i2c_should_check_remark_id(struct elants_data *ts)
1669 ++{
1670 ++ struct i2c_client *client = ts->client;
1671 ++ const u8 bootcode_version = ts->iap_version;
1672 ++ bool check;
1673 ++
1674 ++ /* I2C eKTH3900 and eKTH5312 are NOT support Remark ID */
1675 ++ if ((bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x1_I2C) ||
1676 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x2_I2C) ||
1677 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x3_I2C) ||
1678 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C) ||
1679 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C) ||
1680 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C) ||
1681 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C) ||
1682 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB) ||
1683 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB) ||
1684 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB) ||
1685 ++ (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB)) {
1686 ++ dev_dbg(&client->dev,
1687 ++ "eKTH3900/eKTH5312(0x%02x) are not support remark id\n",
1688 ++ bootcode_version);
1689 ++ check = false;
1690 ++ } else if (bootcode_version >= 0x60) {
1691 ++ check = true;
1692 ++ } else {
1693 ++ check = false;
1694 ++ }
1695 ++
1696 ++ return check;
1697 ++}
1698 ++
1699 + static int elants_i2c_do_update_firmware(struct i2c_client *client,
1700 + const struct firmware *fw,
1701 + bool force)
1702 +@@ -749,7 +793,7 @@ static int elants_i2c_do_update_firmware(struct i2c_client *client,
1703 + u16 send_id;
1704 + int page, n_fw_pages;
1705 + int error;
1706 +- bool check_remark_id = ts->iap_version >= 0x60;
1707 ++ bool check_remark_id = elants_i2c_should_check_remark_id(ts);
1708 +
1709 + /* Recovery mode detection! */
1710 + if (force) {
1711 +diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
1712 +index 4f53d3c57e698..5051a1766aac6 100644
1713 +--- a/drivers/input/touchscreen/goodix.c
1714 ++++ b/drivers/input/touchscreen/goodix.c
1715 +@@ -162,6 +162,7 @@ static const struct goodix_chip_id goodix_chip_ids[] = {
1716 + { .id = "911", .data = &gt911_chip_data },
1717 + { .id = "9271", .data = &gt911_chip_data },
1718 + { .id = "9110", .data = &gt911_chip_data },
1719 ++ { .id = "9111", .data = &gt911_chip_data },
1720 + { .id = "927", .data = &gt911_chip_data },
1721 + { .id = "928", .data = &gt911_chip_data },
1722 +
1723 +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1724 +index 240c5af793dce..368f10405e132 100644
1725 +--- a/drivers/mmc/core/core.c
1726 ++++ b/drivers/mmc/core/core.c
1727 +@@ -2264,7 +2264,7 @@ void mmc_start_host(struct mmc_host *host)
1728 + _mmc_detect_change(host, 0, false);
1729 + }
1730 +
1731 +-void mmc_stop_host(struct mmc_host *host)
1732 ++void __mmc_stop_host(struct mmc_host *host)
1733 + {
1734 + if (host->slot.cd_irq >= 0) {
1735 + mmc_gpio_set_cd_wake(host, false);
1736 +@@ -2273,6 +2273,11 @@ void mmc_stop_host(struct mmc_host *host)
1737 +
1738 + host->rescan_disable = 1;
1739 + cancel_delayed_work_sync(&host->detect);
1740 ++}
1741 ++
1742 ++void mmc_stop_host(struct mmc_host *host)
1743 ++{
1744 ++ __mmc_stop_host(host);
1745 +
1746 + /* clear pm flags now and let card drivers set them as needed */
1747 + host->pm_flags = 0;
1748 +diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
1749 +index 7931a4f0137d2..f5f3f623ea492 100644
1750 +--- a/drivers/mmc/core/core.h
1751 ++++ b/drivers/mmc/core/core.h
1752 +@@ -70,6 +70,7 @@ static inline void mmc_delay(unsigned int ms)
1753 +
1754 + void mmc_rescan(struct work_struct *work);
1755 + void mmc_start_host(struct mmc_host *host);
1756 ++void __mmc_stop_host(struct mmc_host *host);
1757 + void mmc_stop_host(struct mmc_host *host);
1758 +
1759 + void _mmc_detect_change(struct mmc_host *host, unsigned long delay,
1760 +diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
1761 +index d4683b1d263fd..cf140f4ec8643 100644
1762 +--- a/drivers/mmc/core/host.c
1763 ++++ b/drivers/mmc/core/host.c
1764 +@@ -80,9 +80,18 @@ static void mmc_host_classdev_release(struct device *dev)
1765 + kfree(host);
1766 + }
1767 +
1768 ++static int mmc_host_classdev_shutdown(struct device *dev)
1769 ++{
1770 ++ struct mmc_host *host = cls_dev_to_mmc_host(dev);
1771 ++
1772 ++ __mmc_stop_host(host);
1773 ++ return 0;
1774 ++}
1775 ++
1776 + static struct class mmc_host_class = {
1777 + .name = "mmc_host",
1778 + .dev_release = mmc_host_classdev_release,
1779 ++ .shutdown_pre = mmc_host_classdev_shutdown,
1780 + .pm = MMC_HOST_CLASS_DEV_PM_OPS,
1781 + };
1782 +
1783 +diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
1784 +index 7cd9c0ec2fcfe..8fdd0bbbfa21f 100644
1785 +--- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
1786 ++++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
1787 +@@ -135,6 +135,7 @@ static void meson_mx_sdhc_start_cmd(struct mmc_host *mmc,
1788 + struct mmc_command *cmd)
1789 + {
1790 + struct meson_mx_sdhc_host *host = mmc_priv(mmc);
1791 ++ bool manual_stop = false;
1792 + u32 ictl, send;
1793 + int pack_len;
1794 +
1795 +@@ -172,12 +173,27 @@ static void meson_mx_sdhc_start_cmd(struct mmc_host *mmc,
1796 + else
1797 + /* software flush: */
1798 + ictl |= MESON_SDHC_ICTL_DATA_XFER_OK;
1799 ++
1800 ++ /*
1801 ++ * Mimic the logic from the vendor driver where (only)
1802 ++ * SD_IO_RW_EXTENDED commands with more than one block set the
1803 ++ * MESON_SDHC_MISC_MANUAL_STOP bit. This fixes the firmware
1804 ++ * download in the brcmfmac driver for a BCM43362/1 card.
1805 ++ * Without this sdio_memcpy_toio() (with a size of 219557
1806 ++ * bytes) times out if MESON_SDHC_MISC_MANUAL_STOP is not set.
1807 ++ */
1808 ++ manual_stop = cmd->data->blocks > 1 &&
1809 ++ cmd->opcode == SD_IO_RW_EXTENDED;
1810 + } else {
1811 + pack_len = 0;
1812 +
1813 + ictl |= MESON_SDHC_ICTL_RESP_OK;
1814 + }
1815 +
1816 ++ regmap_update_bits(host->regmap, MESON_SDHC_MISC,
1817 ++ MESON_SDHC_MISC_MANUAL_STOP,
1818 ++ manual_stop ? MESON_SDHC_MISC_MANUAL_STOP : 0);
1819 ++
1820 + if (cmd->opcode == MMC_STOP_TRANSMISSION)
1821 + send |= MESON_SDHC_SEND_DATA_STOP;
1822 +
1823 +diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c
1824 +index fdaa11f92fe6f..a75d3dd34d18c 100644
1825 +--- a/drivers/mmc/host/mmci_stm32_sdmmc.c
1826 ++++ b/drivers/mmc/host/mmci_stm32_sdmmc.c
1827 +@@ -441,6 +441,8 @@ static int sdmmc_dlyb_phase_tuning(struct mmci_host *host, u32 opcode)
1828 + return -EINVAL;
1829 + }
1830 +
1831 ++ writel_relaxed(0, dlyb->base + DLYB_CR);
1832 ++
1833 + phase = end_of_len - max_len / 2;
1834 + sdmmc_dlyb_set_cfgr(dlyb, dlyb->unit, phase, false);
1835 +
1836 +diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
1837 +index a5001875876b9..9762ffab2e236 100644
1838 +--- a/drivers/mmc/host/sdhci-tegra.c
1839 ++++ b/drivers/mmc/host/sdhci-tegra.c
1840 +@@ -356,23 +356,6 @@ static void tegra_sdhci_set_tap(struct sdhci_host *host, unsigned int tap)
1841 + }
1842 + }
1843 +
1844 +-static void tegra_sdhci_hs400_enhanced_strobe(struct mmc_host *mmc,
1845 +- struct mmc_ios *ios)
1846 +-{
1847 +- struct sdhci_host *host = mmc_priv(mmc);
1848 +- u32 val;
1849 +-
1850 +- val = sdhci_readl(host, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL);
1851 +-
1852 +- if (ios->enhanced_strobe)
1853 +- val |= SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE;
1854 +- else
1855 +- val &= ~SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE;
1856 +-
1857 +- sdhci_writel(host, val, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL);
1858 +-
1859 +-}
1860 +-
1861 + static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
1862 + {
1863 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1864 +@@ -793,6 +776,32 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1865 + }
1866 + }
1867 +
1868 ++static void tegra_sdhci_hs400_enhanced_strobe(struct mmc_host *mmc,
1869 ++ struct mmc_ios *ios)
1870 ++{
1871 ++ struct sdhci_host *host = mmc_priv(mmc);
1872 ++ u32 val;
1873 ++
1874 ++ val = sdhci_readl(host, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL);
1875 ++
1876 ++ if (ios->enhanced_strobe) {
1877 ++ val |= SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE;
1878 ++ /*
1879 ++ * When CMD13 is sent from mmc_select_hs400es() after
1880 ++ * switching to HS400ES mode, the bus is operating at
1881 ++ * either MMC_HIGH_26_MAX_DTR or MMC_HIGH_52_MAX_DTR.
1882 ++ * To meet Tegra SDHCI requirement at HS400ES mode, force SDHCI
1883 ++ * interface clock to MMC_HS200_MAX_DTR (200 MHz) so that host
1884 ++ * controller CAR clock and the interface clock are rate matched.
1885 ++ */
1886 ++ tegra_sdhci_set_clock(host, MMC_HS200_MAX_DTR);
1887 ++ } else {
1888 ++ val &= ~SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE;
1889 ++ }
1890 ++
1891 ++ sdhci_writel(host, val, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL);
1892 ++}
1893 ++
1894 + static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host *host)
1895 + {
1896 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1897 +diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
1898 +index a8fde3bc458f6..b93337b5a7211 100644
1899 +--- a/drivers/net/bonding/bond_options.c
1900 ++++ b/drivers/net/bonding/bond_options.c
1901 +@@ -1526,7 +1526,7 @@ static int bond_option_ad_actor_system_set(struct bonding *bond,
1902 + mac = (u8 *)&newval->value;
1903 + }
1904 +
1905 +- if (!is_valid_ether_addr(mac))
1906 ++ if (is_multicast_ether_addr(mac))
1907 + goto err;
1908 +
1909 + netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac);
1910 +diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h
1911 +index 1e46e80f3d6f8..7c2328529ff8e 100644
1912 +--- a/drivers/net/ethernet/intel/ice/ice_txrx.h
1913 ++++ b/drivers/net/ethernet/intel/ice/ice_txrx.h
1914 +@@ -164,17 +164,10 @@ struct ice_tx_offload_params {
1915 + };
1916 +
1917 + struct ice_rx_buf {
1918 +- union {
1919 +- struct {
1920 +- dma_addr_t dma;
1921 +- struct page *page;
1922 +- unsigned int page_offset;
1923 +- u16 pagecnt_bias;
1924 +- };
1925 +- struct {
1926 +- struct xdp_buff *xdp;
1927 +- };
1928 +- };
1929 ++ dma_addr_t dma;
1930 ++ struct page *page;
1931 ++ unsigned int page_offset;
1932 ++ u16 pagecnt_bias;
1933 + };
1934 +
1935 + struct ice_q_stats {
1936 +@@ -270,6 +263,7 @@ struct ice_ring {
1937 + union {
1938 + struct ice_tx_buf *tx_buf;
1939 + struct ice_rx_buf *rx_buf;
1940 ++ struct xdp_buff **xdp_buf;
1941 + };
1942 + /* CL2 - 2nd cacheline starts here */
1943 + u16 q_index; /* Queue number of ring */
1944 +diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
1945 +index 5a9f61deeb38d..37c7dc6b44a9f 100644
1946 +--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
1947 ++++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
1948 +@@ -364,7 +364,7 @@ bool ice_alloc_rx_bufs_zc(struct ice_ring *rx_ring, u16 count)
1949 + {
1950 + union ice_32b_rx_flex_desc *rx_desc;
1951 + u16 ntu = rx_ring->next_to_use;
1952 +- struct ice_rx_buf *rx_buf;
1953 ++ struct xdp_buff **xdp;
1954 + bool ok = true;
1955 + dma_addr_t dma;
1956 +
1957 +@@ -372,26 +372,26 @@ bool ice_alloc_rx_bufs_zc(struct ice_ring *rx_ring, u16 count)
1958 + return true;
1959 +
1960 + rx_desc = ICE_RX_DESC(rx_ring, ntu);
1961 +- rx_buf = &rx_ring->rx_buf[ntu];
1962 ++ xdp = &rx_ring->xdp_buf[ntu];
1963 +
1964 + do {
1965 +- rx_buf->xdp = xsk_buff_alloc(rx_ring->xsk_pool);
1966 +- if (!rx_buf->xdp) {
1967 ++ *xdp = xsk_buff_alloc(rx_ring->xsk_pool);
1968 ++ if (!xdp) {
1969 + ok = false;
1970 + break;
1971 + }
1972 +
1973 +- dma = xsk_buff_xdp_get_dma(rx_buf->xdp);
1974 ++ dma = xsk_buff_xdp_get_dma(*xdp);
1975 + rx_desc->read.pkt_addr = cpu_to_le64(dma);
1976 + rx_desc->wb.status_error0 = 0;
1977 +
1978 + rx_desc++;
1979 +- rx_buf++;
1980 ++ xdp++;
1981 + ntu++;
1982 +
1983 + if (unlikely(ntu == rx_ring->count)) {
1984 + rx_desc = ICE_RX_DESC(rx_ring, 0);
1985 +- rx_buf = rx_ring->rx_buf;
1986 ++ xdp = rx_ring->xdp_buf;
1987 + ntu = 0;
1988 + }
1989 + } while (--count);
1990 +@@ -421,19 +421,19 @@ static void ice_bump_ntc(struct ice_ring *rx_ring)
1991 + /**
1992 + * ice_construct_skb_zc - Create an sk_buff from zero-copy buffer
1993 + * @rx_ring: Rx ring
1994 +- * @rx_buf: zero-copy Rx buffer
1995 ++ * @xdp_arr: Pointer to the SW ring of xdp_buff pointers
1996 + *
1997 + * This function allocates a new skb from a zero-copy Rx buffer.
1998 + *
1999 + * Returns the skb on success, NULL on failure.
2000 + */
2001 + static struct sk_buff *
2002 +-ice_construct_skb_zc(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf)
2003 ++ice_construct_skb_zc(struct ice_ring *rx_ring, struct xdp_buff **xdp_arr)
2004 + {
2005 +- unsigned int metasize = rx_buf->xdp->data - rx_buf->xdp->data_meta;
2006 +- unsigned int datasize = rx_buf->xdp->data_end - rx_buf->xdp->data;
2007 +- unsigned int datasize_hard = rx_buf->xdp->data_end -
2008 +- rx_buf->xdp->data_hard_start;
2009 ++ struct xdp_buff *xdp = *xdp_arr;
2010 ++ unsigned int metasize = xdp->data - xdp->data_meta;
2011 ++ unsigned int datasize = xdp->data_end - xdp->data;
2012 ++ unsigned int datasize_hard = xdp->data_end - xdp->data_hard_start;
2013 + struct sk_buff *skb;
2014 +
2015 + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize_hard,
2016 +@@ -441,13 +441,13 @@ ice_construct_skb_zc(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf)
2017 + if (unlikely(!skb))
2018 + return NULL;
2019 +
2020 +- skb_reserve(skb, rx_buf->xdp->data - rx_buf->xdp->data_hard_start);
2021 +- memcpy(__skb_put(skb, datasize), rx_buf->xdp->data, datasize);
2022 ++ skb_reserve(skb, xdp->data - xdp->data_hard_start);
2023 ++ memcpy(__skb_put(skb, datasize), xdp->data, datasize);
2024 + if (metasize)
2025 + skb_metadata_set(skb, metasize);
2026 +
2027 +- xsk_buff_free(rx_buf->xdp);
2028 +- rx_buf->xdp = NULL;
2029 ++ xsk_buff_free(xdp);
2030 ++ *xdp_arr = NULL;
2031 + return skb;
2032 + }
2033 +
2034 +@@ -521,7 +521,7 @@ int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget)
2035 + while (likely(total_rx_packets < (unsigned int)budget)) {
2036 + union ice_32b_rx_flex_desc *rx_desc;
2037 + unsigned int size, xdp_res = 0;
2038 +- struct ice_rx_buf *rx_buf;
2039 ++ struct xdp_buff **xdp;
2040 + struct sk_buff *skb;
2041 + u16 stat_err_bits;
2042 + u16 vlan_tag = 0;
2043 +@@ -544,18 +544,18 @@ int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget)
2044 + if (!size)
2045 + break;
2046 +
2047 +- rx_buf = &rx_ring->rx_buf[rx_ring->next_to_clean];
2048 +- rx_buf->xdp->data_end = rx_buf->xdp->data + size;
2049 +- xsk_buff_dma_sync_for_cpu(rx_buf->xdp, rx_ring->xsk_pool);
2050 ++ xdp = &rx_ring->xdp_buf[rx_ring->next_to_clean];
2051 ++ (*xdp)->data_end = (*xdp)->data + size;
2052 ++ xsk_buff_dma_sync_for_cpu(*xdp, rx_ring->xsk_pool);
2053 +
2054 +- xdp_res = ice_run_xdp_zc(rx_ring, rx_buf->xdp);
2055 ++ xdp_res = ice_run_xdp_zc(rx_ring, *xdp);
2056 + if (xdp_res) {
2057 + if (xdp_res & (ICE_XDP_TX | ICE_XDP_REDIR))
2058 + xdp_xmit |= xdp_res;
2059 + else
2060 +- xsk_buff_free(rx_buf->xdp);
2061 ++ xsk_buff_free(*xdp);
2062 +
2063 +- rx_buf->xdp = NULL;
2064 ++ *xdp = NULL;
2065 + total_rx_bytes += size;
2066 + total_rx_packets++;
2067 + cleaned_count++;
2068 +@@ -565,7 +565,7 @@ int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget)
2069 + }
2070 +
2071 + /* XDP_PASS path */
2072 +- skb = ice_construct_skb_zc(rx_ring, rx_buf);
2073 ++ skb = ice_construct_skb_zc(rx_ring, xdp);
2074 + if (!skb) {
2075 + rx_ring->rx_stats.alloc_buf_failed++;
2076 + break;
2077 +@@ -810,15 +810,15 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi)
2078 + */
2079 + void ice_xsk_clean_rx_ring(struct ice_ring *rx_ring)
2080 + {
2081 +- u16 i;
2082 +-
2083 +- for (i = 0; i < rx_ring->count; i++) {
2084 +- struct ice_rx_buf *rx_buf = &rx_ring->rx_buf[i];
2085 ++ u16 count_mask = rx_ring->count - 1;
2086 ++ u16 ntc = rx_ring->next_to_clean;
2087 ++ u16 ntu = rx_ring->next_to_use;
2088 +
2089 +- if (!rx_buf->xdp)
2090 +- continue;
2091 ++ for ( ; ntc != ntu; ntc = (ntc + 1) & count_mask) {
2092 ++ struct xdp_buff **xdp = &rx_ring->xdp_buf[ntc];
2093 +
2094 +- rx_buf->xdp = NULL;
2095 ++ xsk_buff_free(*xdp);
2096 ++ *xdp = NULL;
2097 + }
2098 + }
2099 +
2100 +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
2101 +index 533199d819501..82a712f77cb34 100644
2102 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
2103 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
2104 +@@ -9247,7 +9247,7 @@ static int __maybe_unused igb_suspend(struct device *dev)
2105 + return __igb_shutdown(to_pci_dev(dev), NULL, 0);
2106 + }
2107 +
2108 +-static int __maybe_unused igb_resume(struct device *dev)
2109 ++static int __maybe_unused __igb_resume(struct device *dev, bool rpm)
2110 + {
2111 + struct pci_dev *pdev = to_pci_dev(dev);
2112 + struct net_device *netdev = pci_get_drvdata(pdev);
2113 +@@ -9290,17 +9290,24 @@ static int __maybe_unused igb_resume(struct device *dev)
2114 +
2115 + wr32(E1000_WUS, ~0);
2116 +
2117 +- rtnl_lock();
2118 ++ if (!rpm)
2119 ++ rtnl_lock();
2120 + if (!err && netif_running(netdev))
2121 + err = __igb_open(netdev, true);
2122 +
2123 + if (!err)
2124 + netif_device_attach(netdev);
2125 +- rtnl_unlock();
2126 ++ if (!rpm)
2127 ++ rtnl_unlock();
2128 +
2129 + return err;
2130 + }
2131 +
2132 ++static int __maybe_unused igb_resume(struct device *dev)
2133 ++{
2134 ++ return __igb_resume(dev, false);
2135 ++}
2136 ++
2137 + static int __maybe_unused igb_runtime_idle(struct device *dev)
2138 + {
2139 + struct net_device *netdev = dev_get_drvdata(dev);
2140 +@@ -9319,7 +9326,7 @@ static int __maybe_unused igb_runtime_suspend(struct device *dev)
2141 +
2142 + static int __maybe_unused igb_runtime_resume(struct device *dev)
2143 + {
2144 +- return igb_resume(dev);
2145 ++ return __igb_resume(dev, true);
2146 + }
2147 +
2148 + static void igb_shutdown(struct pci_dev *pdev)
2149 +@@ -9435,7 +9442,7 @@ static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
2150 + * @pdev: Pointer to PCI device
2151 + *
2152 + * Restart the card from scratch, as if from a cold-boot. Implementation
2153 +- * resembles the first-half of the igb_resume routine.
2154 ++ * resembles the first-half of the __igb_resume routine.
2155 + **/
2156 + static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
2157 + {
2158 +@@ -9475,7 +9482,7 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
2159 + *
2160 + * This callback is called when the error recovery driver tells us that
2161 + * its OK to resume normal operation. Implementation resembles the
2162 +- * second-half of the igb_resume routine.
2163 ++ * second-half of the __igb_resume routine.
2164 + */
2165 + static void igb_io_resume(struct pci_dev *pdev)
2166 + {
2167 +diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
2168 +index 44c670807fb3c..aa543b29799ed 100644
2169 +--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
2170 ++++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
2171 +@@ -54,12 +54,14 @@ int prestera_port_pvid_set(struct prestera_port *port, u16 vid)
2172 + struct prestera_port *prestera_port_find_by_hwid(struct prestera_switch *sw,
2173 + u32 dev_id, u32 hw_id)
2174 + {
2175 +- struct prestera_port *port = NULL;
2176 ++ struct prestera_port *port = NULL, *tmp;
2177 +
2178 + read_lock(&sw->port_list_lock);
2179 +- list_for_each_entry(port, &sw->port_list, list) {
2180 +- if (port->dev_id == dev_id && port->hw_id == hw_id)
2181 ++ list_for_each_entry(tmp, &sw->port_list, list) {
2182 ++ if (tmp->dev_id == dev_id && tmp->hw_id == hw_id) {
2183 ++ port = tmp;
2184 + break;
2185 ++ }
2186 + }
2187 + read_unlock(&sw->port_list_lock);
2188 +
2189 +@@ -68,12 +70,14 @@ struct prestera_port *prestera_port_find_by_hwid(struct prestera_switch *sw,
2190 +
2191 + struct prestera_port *prestera_find_port(struct prestera_switch *sw, u32 id)
2192 + {
2193 +- struct prestera_port *port = NULL;
2194 ++ struct prestera_port *port = NULL, *tmp;
2195 +
2196 + read_lock(&sw->port_list_lock);
2197 +- list_for_each_entry(port, &sw->port_list, list) {
2198 +- if (port->id == id)
2199 ++ list_for_each_entry(tmp, &sw->port_list, list) {
2200 ++ if (tmp->id == id) {
2201 ++ port = tmp;
2202 + break;
2203 ++ }
2204 + }
2205 + read_unlock(&sw->port_list_lock);
2206 +
2207 +@@ -703,23 +707,27 @@ static int prestera_netdev_port_event(struct net_device *lower,
2208 + struct net_device *dev,
2209 + unsigned long event, void *ptr)
2210 + {
2211 +- struct netdev_notifier_changeupper_info *info = ptr;
2212 ++ struct netdev_notifier_info *info = ptr;
2213 ++ struct netdev_notifier_changeupper_info *cu_info;
2214 + struct prestera_port *port = netdev_priv(dev);
2215 + struct netlink_ext_ack *extack;
2216 + struct net_device *upper;
2217 +
2218 +- extack = netdev_notifier_info_to_extack(&info->info);
2219 +- upper = info->upper_dev;
2220 ++ extack = netdev_notifier_info_to_extack(info);
2221 ++ cu_info = container_of(info,
2222 ++ struct netdev_notifier_changeupper_info,
2223 ++ info);
2224 +
2225 + switch (event) {
2226 + case NETDEV_PRECHANGEUPPER:
2227 ++ upper = cu_info->upper_dev;
2228 + if (!netif_is_bridge_master(upper) &&
2229 + !netif_is_lag_master(upper)) {
2230 + NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
2231 + return -EINVAL;
2232 + }
2233 +
2234 +- if (!info->linking)
2235 ++ if (!cu_info->linking)
2236 + break;
2237 +
2238 + if (netdev_has_any_upper_dev(upper)) {
2239 +@@ -728,7 +736,7 @@ static int prestera_netdev_port_event(struct net_device *lower,
2240 + }
2241 +
2242 + if (netif_is_lag_master(upper) &&
2243 +- !prestera_lag_master_check(upper, info->upper_info, extack))
2244 ++ !prestera_lag_master_check(upper, cu_info->upper_info, extack))
2245 + return -EOPNOTSUPP;
2246 + if (netif_is_lag_master(upper) && vlan_uses_dev(dev)) {
2247 + NL_SET_ERR_MSG_MOD(extack,
2248 +@@ -744,14 +752,15 @@ static int prestera_netdev_port_event(struct net_device *lower,
2249 + break;
2250 +
2251 + case NETDEV_CHANGEUPPER:
2252 ++ upper = cu_info->upper_dev;
2253 + if (netif_is_bridge_master(upper)) {
2254 +- if (info->linking)
2255 ++ if (cu_info->linking)
2256 + return prestera_bridge_port_join(upper, port,
2257 + extack);
2258 + else
2259 + prestera_bridge_port_leave(upper, port);
2260 + } else if (netif_is_lag_master(upper)) {
2261 +- if (info->linking)
2262 ++ if (cu_info->linking)
2263 + return prestera_lag_port_add(port, upper);
2264 + else
2265 + prestera_lag_port_del(port);
2266 +diff --git a/drivers/net/ethernet/micrel/ks8851_par.c b/drivers/net/ethernet/micrel/ks8851_par.c
2267 +index 2e8fcce50f9d1..c6f517c07bb9a 100644
2268 +--- a/drivers/net/ethernet/micrel/ks8851_par.c
2269 ++++ b/drivers/net/ethernet/micrel/ks8851_par.c
2270 +@@ -321,6 +321,8 @@ static int ks8851_probe_par(struct platform_device *pdev)
2271 + return ret;
2272 +
2273 + netdev->irq = platform_get_irq(pdev, 0);
2274 ++ if (netdev->irq < 0)
2275 ++ return netdev->irq;
2276 +
2277 + return ks8851_probe_common(netdev, dev, msg_enable);
2278 + }
2279 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
2280 +index 7160b42f51ddd..d0111cb3b40e1 100644
2281 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
2282 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
2283 +@@ -201,7 +201,7 @@ int qlcnic_sriov_get_vf_vport_info(struct qlcnic_adapter *,
2284 + struct qlcnic_info *, u16);
2285 + int qlcnic_sriov_cfg_vf_guest_vlan(struct qlcnic_adapter *, u16, u8);
2286 + void qlcnic_sriov_free_vlans(struct qlcnic_adapter *);
2287 +-void qlcnic_sriov_alloc_vlans(struct qlcnic_adapter *);
2288 ++int qlcnic_sriov_alloc_vlans(struct qlcnic_adapter *);
2289 + bool qlcnic_sriov_check_any_vlan(struct qlcnic_vf_info *);
2290 + void qlcnic_sriov_del_vlan_id(struct qlcnic_sriov *,
2291 + struct qlcnic_vf_info *, u16);
2292 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2293 +index dd03be3fc82a9..42a44c97572ae 100644
2294 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2295 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2296 +@@ -432,7 +432,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter,
2297 + struct qlcnic_cmd_args *cmd)
2298 + {
2299 + struct qlcnic_sriov *sriov = adapter->ahw->sriov;
2300 +- int i, num_vlans;
2301 ++ int i, num_vlans, ret;
2302 + u16 *vlans;
2303 +
2304 + if (sriov->allowed_vlans)
2305 +@@ -443,7 +443,9 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter,
2306 + dev_info(&adapter->pdev->dev, "Number of allowed Guest VLANs = %d\n",
2307 + sriov->num_allowed_vlans);
2308 +
2309 +- qlcnic_sriov_alloc_vlans(adapter);
2310 ++ ret = qlcnic_sriov_alloc_vlans(adapter);
2311 ++ if (ret)
2312 ++ return ret;
2313 +
2314 + if (!sriov->any_vlan)
2315 + return 0;
2316 +@@ -2154,7 +2156,7 @@ static int qlcnic_sriov_vf_resume(struct qlcnic_adapter *adapter)
2317 + return err;
2318 + }
2319 +
2320 +-void qlcnic_sriov_alloc_vlans(struct qlcnic_adapter *adapter)
2321 ++int qlcnic_sriov_alloc_vlans(struct qlcnic_adapter *adapter)
2322 + {
2323 + struct qlcnic_sriov *sriov = adapter->ahw->sriov;
2324 + struct qlcnic_vf_info *vf;
2325 +@@ -2164,7 +2166,11 @@ void qlcnic_sriov_alloc_vlans(struct qlcnic_adapter *adapter)
2326 + vf = &sriov->vf_info[i];
2327 + vf->sriov_vlans = kcalloc(sriov->num_allowed_vlans,
2328 + sizeof(*vf->sriov_vlans), GFP_KERNEL);
2329 ++ if (!vf->sriov_vlans)
2330 ++ return -ENOMEM;
2331 + }
2332 ++
2333 ++ return 0;
2334 + }
2335 +
2336 + void qlcnic_sriov_free_vlans(struct qlcnic_adapter *adapter)
2337 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
2338 +index 447720b93e5ab..e90fa97c0ae6c 100644
2339 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
2340 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
2341 +@@ -597,7 +597,9 @@ static int __qlcnic_pci_sriov_enable(struct qlcnic_adapter *adapter,
2342 + if (err)
2343 + goto del_flr_queue;
2344 +
2345 +- qlcnic_sriov_alloc_vlans(adapter);
2346 ++ err = qlcnic_sriov_alloc_vlans(adapter);
2347 ++ if (err)
2348 ++ goto del_flr_queue;
2349 +
2350 + return err;
2351 +
2352 +diff --git a/drivers/net/ethernet/sfc/falcon/rx.c b/drivers/net/ethernet/sfc/falcon/rx.c
2353 +index 966f13e7475dd..11a6aee852e92 100644
2354 +--- a/drivers/net/ethernet/sfc/falcon/rx.c
2355 ++++ b/drivers/net/ethernet/sfc/falcon/rx.c
2356 +@@ -728,7 +728,10 @@ static void ef4_init_rx_recycle_ring(struct ef4_nic *efx,
2357 + efx->rx_bufs_per_page);
2358 + rx_queue->page_ring = kcalloc(page_ring_size,
2359 + sizeof(*rx_queue->page_ring), GFP_KERNEL);
2360 +- rx_queue->page_ptr_mask = page_ring_size - 1;
2361 ++ if (!rx_queue->page_ring)
2362 ++ rx_queue->page_ptr_mask = 0;
2363 ++ else
2364 ++ rx_queue->page_ptr_mask = page_ring_size - 1;
2365 + }
2366 +
2367 + void ef4_init_rx_queue(struct ef4_rx_queue *rx_queue)
2368 +diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c
2369 +index 68fc7d317693b..0983abc0cc5f0 100644
2370 +--- a/drivers/net/ethernet/sfc/rx_common.c
2371 ++++ b/drivers/net/ethernet/sfc/rx_common.c
2372 +@@ -150,7 +150,10 @@ static void efx_init_rx_recycle_ring(struct efx_rx_queue *rx_queue)
2373 + efx->rx_bufs_per_page);
2374 + rx_queue->page_ring = kcalloc(page_ring_size,
2375 + sizeof(*rx_queue->page_ring), GFP_KERNEL);
2376 +- rx_queue->page_ptr_mask = page_ring_size - 1;
2377 ++ if (!rx_queue->page_ring)
2378 ++ rx_queue->page_ptr_mask = 0;
2379 ++ else
2380 ++ rx_queue->page_ptr_mask = page_ring_size - 1;
2381 + }
2382 +
2383 + static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue)
2384 +diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
2385 +index b008b4e8a2a5a..0641a1d392b86 100644
2386 +--- a/drivers/net/ethernet/smsc/smc911x.c
2387 ++++ b/drivers/net/ethernet/smsc/smc911x.c
2388 +@@ -2070,6 +2070,11 @@ static int smc911x_drv_probe(struct platform_device *pdev)
2389 +
2390 + ndev->dma = (unsigned char)-1;
2391 + ndev->irq = platform_get_irq(pdev, 0);
2392 ++ if (ndev->irq < 0) {
2393 ++ ret = ndev->irq;
2394 ++ goto release_both;
2395 ++ }
2396 ++
2397 + lp = netdev_priv(ndev);
2398 + lp->netdev = ndev;
2399 + #ifdef SMC_DYNAMIC_BUS_CONFIG
2400 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
2401 +index d046e33b8a297..fac788718c045 100644
2402 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
2403 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
2404 +@@ -26,7 +26,7 @@
2405 + #define ETHER_CLK_SEL_FREQ_SEL_125M (BIT(9) | BIT(8))
2406 + #define ETHER_CLK_SEL_FREQ_SEL_50M BIT(9)
2407 + #define ETHER_CLK_SEL_FREQ_SEL_25M BIT(8)
2408 +-#define ETHER_CLK_SEL_FREQ_SEL_2P5M BIT(0)
2409 ++#define ETHER_CLK_SEL_FREQ_SEL_2P5M 0
2410 + #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_IN BIT(0)
2411 + #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC BIT(10)
2412 + #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV BIT(11)
2413 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
2414 +index 580cc035536bd..be9b58b2abf9b 100644
2415 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
2416 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
2417 +@@ -102,7 +102,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
2418 + time.tv_nsec = priv->plat->est->btr_reserve[0];
2419 + time.tv_sec = priv->plat->est->btr_reserve[1];
2420 + basetime = timespec64_to_ktime(time);
2421 +- cycle_time = priv->plat->est->ctr[1] * NSEC_PER_SEC +
2422 ++ cycle_time = (u64)priv->plat->est->ctr[1] * NSEC_PER_SEC +
2423 + priv->plat->est->ctr[0];
2424 + time = stmmac_calc_tas_basetime(basetime,
2425 + current_time_ns,
2426 +diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
2427 +index 185c8a3986816..1d1808afd5295 100644
2428 +--- a/drivers/net/fjes/fjes_main.c
2429 ++++ b/drivers/net/fjes/fjes_main.c
2430 +@@ -1261,6 +1261,11 @@ static int fjes_probe(struct platform_device *plat_dev)
2431 + hw->hw_res.start = res->start;
2432 + hw->hw_res.size = resource_size(res);
2433 + hw->hw_res.irq = platform_get_irq(plat_dev, 0);
2434 ++ if (hw->hw_res.irq < 0) {
2435 ++ err = hw->hw_res.irq;
2436 ++ goto err_free_control_wq;
2437 ++ }
2438 ++
2439 + err = fjes_hw_init(&adapter->hw);
2440 + if (err)
2441 + goto err_free_control_wq;
2442 +diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
2443 +index 8666110bec555..35728f1af6a6a 100644
2444 +--- a/drivers/net/hamradio/mkiss.c
2445 ++++ b/drivers/net/hamradio/mkiss.c
2446 +@@ -792,13 +792,14 @@ static void mkiss_close(struct tty_struct *tty)
2447 + */
2448 + netif_stop_queue(ax->dev);
2449 +
2450 +- /* Free all AX25 frame buffers. */
2451 ++ unregister_netdev(ax->dev);
2452 ++
2453 ++ /* Free all AX25 frame buffers after unreg. */
2454 + kfree(ax->rbuff);
2455 + kfree(ax->xbuff);
2456 +
2457 + ax->tty = NULL;
2458 +
2459 +- unregister_netdev(ax->dev);
2460 + free_netdev(ax->dev);
2461 + }
2462 +
2463 +diff --git a/drivers/net/tun.c b/drivers/net/tun.c
2464 +index 1572878c34031..45a67e72a02c6 100644
2465 +--- a/drivers/net/tun.c
2466 ++++ b/drivers/net/tun.c
2467 +@@ -209,6 +209,9 @@ struct tun_struct {
2468 + struct tun_prog __rcu *steering_prog;
2469 + struct tun_prog __rcu *filter_prog;
2470 + struct ethtool_link_ksettings link_ksettings;
2471 ++ /* init args */
2472 ++ struct file *file;
2473 ++ struct ifreq *ifr;
2474 + };
2475 +
2476 + struct veth {
2477 +@@ -216,6 +219,9 @@ struct veth {
2478 + __be16 h_vlan_TCI;
2479 + };
2480 +
2481 ++static void tun_flow_init(struct tun_struct *tun);
2482 ++static void tun_flow_uninit(struct tun_struct *tun);
2483 ++
2484 + static int tun_napi_receive(struct napi_struct *napi, int budget)
2485 + {
2486 + struct tun_file *tfile = container_of(napi, struct tun_file, napi);
2487 +@@ -953,6 +959,49 @@ static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)
2488 +
2489 + static const struct ethtool_ops tun_ethtool_ops;
2490 +
2491 ++static int tun_net_init(struct net_device *dev)
2492 ++{
2493 ++ struct tun_struct *tun = netdev_priv(dev);
2494 ++ struct ifreq *ifr = tun->ifr;
2495 ++ int err;
2496 ++
2497 ++ dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
2498 ++ if (!dev->tstats)
2499 ++ return -ENOMEM;
2500 ++
2501 ++ spin_lock_init(&tun->lock);
2502 ++
2503 ++ err = security_tun_dev_alloc_security(&tun->security);
2504 ++ if (err < 0) {
2505 ++ free_percpu(dev->tstats);
2506 ++ return err;
2507 ++ }
2508 ++
2509 ++ tun_flow_init(tun);
2510 ++
2511 ++ dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
2512 ++ TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
2513 ++ NETIF_F_HW_VLAN_STAG_TX;
2514 ++ dev->features = dev->hw_features | NETIF_F_LLTX;
2515 ++ dev->vlan_features = dev->features &
2516 ++ ~(NETIF_F_HW_VLAN_CTAG_TX |
2517 ++ NETIF_F_HW_VLAN_STAG_TX);
2518 ++
2519 ++ tun->flags = (tun->flags & ~TUN_FEATURES) |
2520 ++ (ifr->ifr_flags & TUN_FEATURES);
2521 ++
2522 ++ INIT_LIST_HEAD(&tun->disabled);
2523 ++ err = tun_attach(tun, tun->file, false, ifr->ifr_flags & IFF_NAPI,
2524 ++ ifr->ifr_flags & IFF_NAPI_FRAGS, false);
2525 ++ if (err < 0) {
2526 ++ tun_flow_uninit(tun);
2527 ++ security_tun_dev_free_security(tun->security);
2528 ++ free_percpu(dev->tstats);
2529 ++ return err;
2530 ++ }
2531 ++ return 0;
2532 ++}
2533 ++
2534 + /* Net device detach from fd. */
2535 + static void tun_net_uninit(struct net_device *dev)
2536 + {
2537 +@@ -1169,6 +1218,7 @@ static int tun_net_change_carrier(struct net_device *dev, bool new_carrier)
2538 + }
2539 +
2540 + static const struct net_device_ops tun_netdev_ops = {
2541 ++ .ndo_init = tun_net_init,
2542 + .ndo_uninit = tun_net_uninit,
2543 + .ndo_open = tun_net_open,
2544 + .ndo_stop = tun_net_close,
2545 +@@ -1252,6 +1302,7 @@ static int tun_xdp_tx(struct net_device *dev, struct xdp_buff *xdp)
2546 + }
2547 +
2548 + static const struct net_device_ops tap_netdev_ops = {
2549 ++ .ndo_init = tun_net_init,
2550 + .ndo_uninit = tun_net_uninit,
2551 + .ndo_open = tun_net_open,
2552 + .ndo_stop = tun_net_close,
2553 +@@ -1292,7 +1343,7 @@ static void tun_flow_uninit(struct tun_struct *tun)
2554 + #define MAX_MTU 65535
2555 +
2556 + /* Initialize net device. */
2557 +-static void tun_net_init(struct net_device *dev)
2558 ++static void tun_net_initialize(struct net_device *dev)
2559 + {
2560 + struct tun_struct *tun = netdev_priv(dev);
2561 +
2562 +@@ -2206,11 +2257,6 @@ static void tun_free_netdev(struct net_device *dev)
2563 + BUG_ON(!(list_empty(&tun->disabled)));
2564 +
2565 + free_percpu(dev->tstats);
2566 +- /* We clear tstats so that tun_set_iff() can tell if
2567 +- * tun_free_netdev() has been called from register_netdevice().
2568 +- */
2569 +- dev->tstats = NULL;
2570 +-
2571 + tun_flow_uninit(tun);
2572 + security_tun_dev_free_security(tun->security);
2573 + __tun_set_ebpf(tun, &tun->steering_prog, NULL);
2574 +@@ -2716,41 +2762,16 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
2575 + tun->rx_batched = 0;
2576 + RCU_INIT_POINTER(tun->steering_prog, NULL);
2577 +
2578 +- dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
2579 +- if (!dev->tstats) {
2580 +- err = -ENOMEM;
2581 +- goto err_free_dev;
2582 +- }
2583 +-
2584 +- spin_lock_init(&tun->lock);
2585 +-
2586 +- err = security_tun_dev_alloc_security(&tun->security);
2587 +- if (err < 0)
2588 +- goto err_free_stat;
2589 +-
2590 +- tun_net_init(dev);
2591 +- tun_flow_init(tun);
2592 ++ tun->ifr = ifr;
2593 ++ tun->file = file;
2594 +
2595 +- dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
2596 +- TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
2597 +- NETIF_F_HW_VLAN_STAG_TX;
2598 +- dev->features = dev->hw_features | NETIF_F_LLTX;
2599 +- dev->vlan_features = dev->features &
2600 +- ~(NETIF_F_HW_VLAN_CTAG_TX |
2601 +- NETIF_F_HW_VLAN_STAG_TX);
2602 +-
2603 +- tun->flags = (tun->flags & ~TUN_FEATURES) |
2604 +- (ifr->ifr_flags & TUN_FEATURES);
2605 +-
2606 +- INIT_LIST_HEAD(&tun->disabled);
2607 +- err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI,
2608 +- ifr->ifr_flags & IFF_NAPI_FRAGS, false);
2609 +- if (err < 0)
2610 +- goto err_free_flow;
2611 ++ tun_net_initialize(dev);
2612 +
2613 + err = register_netdevice(tun->dev);
2614 +- if (err < 0)
2615 +- goto err_detach;
2616 ++ if (err < 0) {
2617 ++ free_netdev(dev);
2618 ++ return err;
2619 ++ }
2620 + /* free_netdev() won't check refcnt, to avoid race
2621 + * with dev_put() we need publish tun after registration.
2622 + */
2623 +@@ -2767,24 +2788,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
2624 +
2625 + strcpy(ifr->ifr_name, tun->dev->name);
2626 + return 0;
2627 +-
2628 +-err_detach:
2629 +- tun_detach_all(dev);
2630 +- /* We are here because register_netdevice() has failed.
2631 +- * If register_netdevice() already called tun_free_netdev()
2632 +- * while dealing with the error, dev->stats has been cleared.
2633 +- */
2634 +- if (!dev->tstats)
2635 +- goto err_free_dev;
2636 +-
2637 +-err_free_flow:
2638 +- tun_flow_uninit(tun);
2639 +- security_tun_dev_free_security(tun->security);
2640 +-err_free_stat:
2641 +- free_percpu(dev->tstats);
2642 +-err_free_dev:
2643 +- free_netdev(dev);
2644 +- return err;
2645 + }
2646 +
2647 + static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
2648 +diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
2649 +index 38cda590895cc..9aa92076500af 100644
2650 +--- a/drivers/net/usb/asix_common.c
2651 ++++ b/drivers/net/usb/asix_common.c
2652 +@@ -9,6 +9,8 @@
2653 +
2654 + #include "asix.h"
2655 +
2656 ++#define AX_HOST_EN_RETRIES 30
2657 ++
2658 + int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
2659 + u16 size, void *data, int in_pm)
2660 + {
2661 +@@ -68,7 +70,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
2662 + int i, ret;
2663 + u8 smsr;
2664 +
2665 +- for (i = 0; i < 30; ++i) {
2666 ++ for (i = 0; i < AX_HOST_EN_RETRIES; ++i) {
2667 + ret = asix_set_sw_mii(dev, in_pm);
2668 + if (ret == -ENODEV || ret == -ETIMEDOUT)
2669 + break;
2670 +@@ -77,13 +79,13 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
2671 + 0, 0, 1, &smsr, in_pm);
2672 + if (ret == -ENODEV)
2673 + break;
2674 +- else if (ret < 0)
2675 ++ else if (ret < sizeof(smsr))
2676 + continue;
2677 + else if (smsr & AX_HOST_EN)
2678 + break;
2679 + }
2680 +
2681 +- return ret;
2682 ++ return i >= AX_HOST_EN_RETRIES ? -ETIMEDOUT : ret;
2683 + }
2684 +
2685 + static void reset_asix_rx_fixup_info(struct asix_rx_fixup_info *rx)
2686 +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
2687 +index a0401a9dade5b..3e1a83a22fdd6 100644
2688 +--- a/drivers/net/usb/lan78xx.c
2689 ++++ b/drivers/net/usb/lan78xx.c
2690 +@@ -76,6 +76,8 @@
2691 + #define LAN7801_USB_PRODUCT_ID (0x7801)
2692 + #define LAN78XX_EEPROM_MAGIC (0x78A5)
2693 + #define LAN78XX_OTP_MAGIC (0x78F3)
2694 ++#define AT29M2AF_USB_VENDOR_ID (0x07C9)
2695 ++#define AT29M2AF_USB_PRODUCT_ID (0x0012)
2696 +
2697 + #define MII_READ 1
2698 + #define MII_WRITE 0
2699 +@@ -4734,6 +4736,10 @@ static const struct usb_device_id products[] = {
2700 + /* LAN7801 USB Gigabit Ethernet Device */
2701 + USB_DEVICE(LAN78XX_USB_VENDOR_ID, LAN7801_USB_PRODUCT_ID),
2702 + },
2703 ++ {
2704 ++ /* ATM2-AF USB Gigabit Ethernet Device */
2705 ++ USB_DEVICE(AT29M2AF_USB_VENDOR_ID, AT29M2AF_USB_PRODUCT_ID),
2706 ++ },
2707 + {},
2708 + };
2709 + MODULE_DEVICE_TABLE(usb, products);
2710 +diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
2711 +index d3da350777a4d..c08e0857e8a70 100644
2712 +--- a/drivers/net/usb/r8152.c
2713 ++++ b/drivers/net/usb/r8152.c
2714 +@@ -32,7 +32,7 @@
2715 + #define NETNEXT_VERSION "12"
2716 +
2717 + /* Information for net */
2718 +-#define NET_VERSION "11"
2719 ++#define NET_VERSION "12"
2720 +
2721 + #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
2722 + #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@×××××××.com>"
2723 +@@ -4016,6 +4016,11 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
2724 + ocp_write_word(tp, type, PLA_BP_BA, 0);
2725 + }
2726 +
2727 ++static inline void rtl_reset_ocp_base(struct r8152 *tp)
2728 ++{
2729 ++ tp->ocp_base = -1;
2730 ++}
2731 ++
2732 + static int rtl_phy_patch_request(struct r8152 *tp, bool request, bool wait)
2733 + {
2734 + u16 data, check;
2735 +@@ -4087,8 +4092,6 @@ static int rtl_post_ram_code(struct r8152 *tp, u16 key_addr, bool wait)
2736 +
2737 + rtl_phy_patch_request(tp, false, wait);
2738 +
2739 +- ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, tp->ocp_base);
2740 +-
2741 + return 0;
2742 + }
2743 +
2744 +@@ -4800,6 +4803,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
2745 + u32 len;
2746 + u8 *data;
2747 +
2748 ++ rtl_reset_ocp_base(tp);
2749 ++
2750 + if (sram_read(tp, SRAM_GPHY_FW_VER) >= __le16_to_cpu(phy->version)) {
2751 + dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n");
2752 + return;
2753 +@@ -4845,7 +4850,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
2754 + }
2755 + }
2756 +
2757 +- ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, tp->ocp_base);
2758 ++ rtl_reset_ocp_base(tp);
2759 ++
2760 + rtl_phy_patch_request(tp, false, wait);
2761 +
2762 + if (sram_read(tp, SRAM_GPHY_FW_VER) == __le16_to_cpu(phy->version))
2763 +@@ -4861,6 +4867,8 @@ static int rtl8152_fw_phy_ver(struct r8152 *tp, struct fw_phy_ver *phy_ver)
2764 + ver_addr = __le16_to_cpu(phy_ver->ver.addr);
2765 + ver = __le16_to_cpu(phy_ver->ver.data);
2766 +
2767 ++ rtl_reset_ocp_base(tp);
2768 ++
2769 + if (sram_read(tp, ver_addr) >= ver) {
2770 + dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n");
2771 + return 0;
2772 +@@ -4877,6 +4885,8 @@ static void rtl8152_fw_phy_fixup(struct r8152 *tp, struct fw_phy_fixup *fix)
2773 + {
2774 + u16 addr, data;
2775 +
2776 ++ rtl_reset_ocp_base(tp);
2777 ++
2778 + addr = __le16_to_cpu(fix->setting.addr);
2779 + data = ocp_reg_read(tp, addr);
2780 +
2781 +@@ -4908,6 +4918,8 @@ static void rtl8152_fw_phy_union_apply(struct r8152 *tp, struct fw_phy_union *ph
2782 + u32 length;
2783 + int i, num;
2784 +
2785 ++ rtl_reset_ocp_base(tp);
2786 ++
2787 + num = phy->pre_num;
2788 + for (i = 0; i < num; i++)
2789 + sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr),
2790 +@@ -4938,6 +4950,8 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
2791 + u32 length, i, num;
2792 + __le16 *data;
2793 +
2794 ++ rtl_reset_ocp_base(tp);
2795 ++
2796 + mode_reg = __le16_to_cpu(phy->mode_reg);
2797 + sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_pre));
2798 + sram_write(tp, __le16_to_cpu(phy->ba_reg),
2799 +@@ -5107,6 +5121,7 @@ post_fw:
2800 + if (rtl_fw->post_fw)
2801 + rtl_fw->post_fw(tp);
2802 +
2803 ++ rtl_reset_ocp_base(tp);
2804 + strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE);
2805 + dev_info(&tp->intf->dev, "load %s successfully\n", rtl_fw->version);
2806 + }
2807 +@@ -6584,6 +6599,21 @@ static bool rtl8153_in_nway(struct r8152 *tp)
2808 + return true;
2809 + }
2810 +
2811 ++static void r8156_mdio_force_mode(struct r8152 *tp)
2812 ++{
2813 ++ u16 data;
2814 ++
2815 ++ /* Select force mode through 0xa5b4 bit 15
2816 ++ * 0: MDIO force mode
2817 ++ * 1: MMD force mode
2818 ++ */
2819 ++ data = ocp_reg_read(tp, 0xa5b4);
2820 ++ if (data & BIT(15)) {
2821 ++ data &= ~BIT(15);
2822 ++ ocp_reg_write(tp, 0xa5b4, data);
2823 ++ }
2824 ++}
2825 ++
2826 + static void set_carrier(struct r8152 *tp)
2827 + {
2828 + struct net_device *netdev = tp->netdev;
2829 +@@ -8016,6 +8046,7 @@ static void r8156_init(struct r8152 *tp)
2830 + ocp_data |= ACT_ODMA;
2831 + ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_CONFIG, ocp_data);
2832 +
2833 ++ r8156_mdio_force_mode(tp);
2834 + rtl_tally_reset(tp);
2835 +
2836 + tp->coalesce = 15000; /* 15 us */
2837 +@@ -8145,6 +8176,7 @@ static void r8156b_init(struct r8152 *tp)
2838 + ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
2839 + ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
2840 +
2841 ++ r8156_mdio_force_mode(tp);
2842 + rtl_tally_reset(tp);
2843 +
2844 + tp->coalesce = 15000; /* 15 us */
2845 +@@ -8467,6 +8499,8 @@ static int rtl8152_resume(struct usb_interface *intf)
2846 +
2847 + mutex_lock(&tp->control);
2848 +
2849 ++ rtl_reset_ocp_base(tp);
2850 ++
2851 + if (test_bit(SELECTIVE_SUSPEND, &tp->flags))
2852 + ret = rtl8152_runtime_resume(tp);
2853 + else
2854 +@@ -8482,6 +8516,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
2855 + struct r8152 *tp = usb_get_intfdata(intf);
2856 +
2857 + clear_bit(SELECTIVE_SUSPEND, &tp->flags);
2858 ++ rtl_reset_ocp_base(tp);
2859 + tp->rtl_ops.init(tp);
2860 + queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
2861 + set_ethernet_addr(tp, true);
2862 +diff --git a/drivers/net/veth.c b/drivers/net/veth.c
2863 +index 50eb43e5bf459..2acdb8ad6c713 100644
2864 +--- a/drivers/net/veth.c
2865 ++++ b/drivers/net/veth.c
2866 +@@ -879,8 +879,12 @@ static int veth_xdp_rcv(struct veth_rq *rq, int budget,
2867 +
2868 + stats->xdp_bytes += skb->len;
2869 + skb = veth_xdp_rcv_skb(rq, skb, bq, stats);
2870 +- if (skb)
2871 +- napi_gro_receive(&rq->xdp_napi, skb);
2872 ++ if (skb) {
2873 ++ if (skb_shared(skb) || skb_unclone(skb, GFP_ATOMIC))
2874 ++ netif_receive_skb(skb);
2875 ++ else
2876 ++ napi_gro_receive(&rq->xdp_napi, skb);
2877 ++ }
2878 + }
2879 + done++;
2880 + }
2881 +diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
2882 +index 6e6fefeb21ead..cc39c0e18b474 100644
2883 +--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
2884 ++++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
2885 +@@ -1243,6 +1243,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
2886 + raw_spin_lock_init(&pc->irq_lock[i]);
2887 + }
2888 +
2889 ++ pc->pctl_desc = *pdata->pctl_desc;
2890 ++ pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
2891 ++ if (IS_ERR(pc->pctl_dev)) {
2892 ++ gpiochip_remove(&pc->gpio_chip);
2893 ++ return PTR_ERR(pc->pctl_dev);
2894 ++ }
2895 ++
2896 ++ pc->gpio_range = *pdata->gpio_range;
2897 ++ pc->gpio_range.base = pc->gpio_chip.base;
2898 ++ pc->gpio_range.gc = &pc->gpio_chip;
2899 ++ pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
2900 ++
2901 + girq = &pc->gpio_chip.irq;
2902 + girq->chip = &bcm2835_gpio_irq_chip;
2903 + girq->parent_handler = bcm2835_gpio_irq_handler;
2904 +@@ -1250,8 +1262,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
2905 + girq->parents = devm_kcalloc(dev, BCM2835_NUM_IRQS,
2906 + sizeof(*girq->parents),
2907 + GFP_KERNEL);
2908 +- if (!girq->parents)
2909 ++ if (!girq->parents) {
2910 ++ pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
2911 + return -ENOMEM;
2912 ++ }
2913 +
2914 + if (is_7211) {
2915 + pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
2916 +@@ -1306,21 +1320,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
2917 + err = gpiochip_add_data(&pc->gpio_chip, pc);
2918 + if (err) {
2919 + dev_err(dev, "could not add GPIO chip\n");
2920 ++ pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
2921 + return err;
2922 + }
2923 +
2924 +- pc->pctl_desc = *pdata->pctl_desc;
2925 +- pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
2926 +- if (IS_ERR(pc->pctl_dev)) {
2927 +- gpiochip_remove(&pc->gpio_chip);
2928 +- return PTR_ERR(pc->pctl_dev);
2929 +- }
2930 +-
2931 +- pc->gpio_range = *pdata->gpio_range;
2932 +- pc->gpio_range.base = pc->gpio_chip.base;
2933 +- pc->gpio_range.gc = &pc->gpio_chip;
2934 +- pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
2935 +-
2936 + return 0;
2937 + }
2938 +
2939 +diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
2940 +index 45ebdeba985ae..12163d3c4bcb0 100644
2941 +--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
2942 ++++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
2943 +@@ -285,8 +285,12 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
2944 + desc = (const struct mtk_pin_desc *)hw->soc->pins;
2945 + *gpio_chip = &hw->chip;
2946 +
2947 +- /* Be greedy to guess first gpio_n is equal to eint_n */
2948 +- if (desc[eint_n].eint.eint_n == eint_n)
2949 ++ /*
2950 ++ * Be greedy to guess first gpio_n is equal to eint_n.
2951 ++ * Only eint virtual eint number is greater than gpio number.
2952 ++ */
2953 ++ if (hw->soc->npins > eint_n &&
2954 ++ desc[eint_n].eint.eint_n == eint_n)
2955 + *gpio_n = eint_n;
2956 + else
2957 + *gpio_n = mtk_xt_find_eint_num(hw, eint_n);
2958 +diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
2959 +index dfd8888a222a4..8934b4878fa85 100644
2960 +--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
2961 ++++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
2962 +@@ -1251,10 +1251,10 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
2963 + bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
2964 + bank->gpio_chip.base = args.args[1];
2965 +
2966 +- npins = args.args[2];
2967 +- while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
2968 +- ++i, &args))
2969 +- npins += args.args[2];
2970 ++ /* get the last defined gpio line (offset + nb of pins) */
2971 ++ npins = args.args[0] + args.args[2];
2972 ++ while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, ++i, &args))
2973 ++ npins = max(npins, (int)(args.args[0] + args.args[2]));
2974 + } else {
2975 + bank_nr = pctl->nbanks;
2976 + bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;
2977 +diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
2978 +index 69690e26bb6d4..2734a771d1f00 100644
2979 +--- a/drivers/platform/x86/Makefile
2980 ++++ b/drivers/platform/x86/Makefile
2981 +@@ -67,7 +67,7 @@ obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
2982 + obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
2983 +
2984 + # Intel
2985 +-obj-$(CONFIG_X86_PLATFORM_DRIVERS_INTEL) += intel/
2986 ++obj-y += intel/
2987 +
2988 + # MSI
2989 + obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
2990 +diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c
2991 +index 54b88bedecdf1..d3efd514614c0 100644
2992 +--- a/drivers/platform/x86/amd-pmc.c
2993 ++++ b/drivers/platform/x86/amd-pmc.c
2994 +@@ -375,7 +375,8 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
2995 + }
2996 +
2997 + static const struct dev_pm_ops amd_pmc_pm_ops = {
2998 +- SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(amd_pmc_suspend, amd_pmc_resume)
2999 ++ .suspend_noirq = amd_pmc_suspend,
3000 ++ .resume_noirq = amd_pmc_resume,
3001 + };
3002 +
3003 + static const struct pci_device_id pmc_pci_ids[] = {
3004 +diff --git a/drivers/platform/x86/intel/Kconfig b/drivers/platform/x86/intel/Kconfig
3005 +index 0b21468e1bd01..02e4481b384e4 100644
3006 +--- a/drivers/platform/x86/intel/Kconfig
3007 ++++ b/drivers/platform/x86/intel/Kconfig
3008 +@@ -3,19 +3,6 @@
3009 + # Intel x86 Platform Specific Drivers
3010 + #
3011 +
3012 +-menuconfig X86_PLATFORM_DRIVERS_INTEL
3013 +- bool "Intel x86 Platform Specific Device Drivers"
3014 +- default y
3015 +- help
3016 +- Say Y here to get to see options for device drivers for
3017 +- various Intel x86 platforms, including vendor-specific
3018 +- drivers. This option alone does not add any kernel code.
3019 +-
3020 +- If you say N, all options in this submenu will be skipped
3021 +- and disabled.
3022 +-
3023 +-if X86_PLATFORM_DRIVERS_INTEL
3024 +-
3025 + source "drivers/platform/x86/intel/atomisp2/Kconfig"
3026 + source "drivers/platform/x86/intel/int1092/Kconfig"
3027 + source "drivers/platform/x86/intel/int33fe/Kconfig"
3028 +@@ -167,5 +154,3 @@ config INTEL_UNCORE_FREQ_CONTROL
3029 +
3030 + To compile this driver as a module, choose M here: the module
3031 + will be called intel-uncore-frequency.
3032 +-
3033 +-endif # X86_PLATFORM_DRIVERS_INTEL
3034 +diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c b/drivers/platform/x86/intel/pmc/pltdrv.c
3035 +index 73797680b895c..15ca8afdd973d 100644
3036 +--- a/drivers/platform/x86/intel/pmc/pltdrv.c
3037 ++++ b/drivers/platform/x86/intel/pmc/pltdrv.c
3038 +@@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
3039 +
3040 + retval = platform_device_register(pmc_core_device);
3041 + if (retval)
3042 +- kfree(pmc_core_device);
3043 ++ platform_device_put(pmc_core_device);
3044 +
3045 + return retval;
3046 + }
3047 +diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
3048 +index 46feafe4e201c..d8cc4b270644a 100644
3049 +--- a/drivers/spi/spi-armada-3700.c
3050 ++++ b/drivers/spi/spi-armada-3700.c
3051 +@@ -901,7 +901,7 @@ static int a3700_spi_probe(struct platform_device *pdev)
3052 + return 0;
3053 +
3054 + error_clk:
3055 +- clk_disable_unprepare(spi->clk);
3056 ++ clk_unprepare(spi->clk);
3057 + error:
3058 + spi_master_put(master);
3059 + out:
3060 +diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c
3061 +index d167039af519e..1aa843f2ecc7c 100644
3062 +--- a/drivers/tee/optee/shm_pool.c
3063 ++++ b/drivers/tee/optee/shm_pool.c
3064 +@@ -41,10 +41,8 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
3065 + goto err;
3066 + }
3067 +
3068 +- for (i = 0; i < nr_pages; i++) {
3069 +- pages[i] = page;
3070 +- page++;
3071 +- }
3072 ++ for (i = 0; i < nr_pages; i++)
3073 ++ pages[i] = page + i;
3074 +
3075 + shm->flags |= TEE_SHM_REGISTER;
3076 + rc = optee_shm_register(shm->ctx, shm, pages, nr_pages,
3077 +diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
3078 +index 8a9384a64f3e2..499fccba3d74b 100644
3079 +--- a/drivers/tee/tee_shm.c
3080 ++++ b/drivers/tee/tee_shm.c
3081 +@@ -1,11 +1,11 @@
3082 + // SPDX-License-Identifier: GPL-2.0-only
3083 + /*
3084 +- * Copyright (c) 2015-2016, Linaro Limited
3085 ++ * Copyright (c) 2015-2017, 2019-2021 Linaro Limited
3086 + */
3087 ++#include <linux/anon_inodes.h>
3088 + #include <linux/device.h>
3089 +-#include <linux/dma-buf.h>
3090 +-#include <linux/fdtable.h>
3091 + #include <linux/idr.h>
3092 ++#include <linux/mm.h>
3093 + #include <linux/sched.h>
3094 + #include <linux/slab.h>
3095 + #include <linux/tee_drv.h>
3096 +@@ -28,16 +28,8 @@ static void release_registered_pages(struct tee_shm *shm)
3097 + }
3098 + }
3099 +
3100 +-static void tee_shm_release(struct tee_shm *shm)
3101 ++static void tee_shm_release(struct tee_device *teedev, struct tee_shm *shm)
3102 + {
3103 +- struct tee_device *teedev = shm->ctx->teedev;
3104 +-
3105 +- if (shm->flags & TEE_SHM_DMA_BUF) {
3106 +- mutex_lock(&teedev->mutex);
3107 +- idr_remove(&teedev->idr, shm->id);
3108 +- mutex_unlock(&teedev->mutex);
3109 +- }
3110 +-
3111 + if (shm->flags & TEE_SHM_POOL) {
3112 + struct tee_shm_pool_mgr *poolm;
3113 +
3114 +@@ -64,45 +56,6 @@ static void tee_shm_release(struct tee_shm *shm)
3115 + tee_device_put(teedev);
3116 + }
3117 +
3118 +-static struct sg_table *tee_shm_op_map_dma_buf(struct dma_buf_attachment
3119 +- *attach, enum dma_data_direction dir)
3120 +-{
3121 +- return NULL;
3122 +-}
3123 +-
3124 +-static void tee_shm_op_unmap_dma_buf(struct dma_buf_attachment *attach,
3125 +- struct sg_table *table,
3126 +- enum dma_data_direction dir)
3127 +-{
3128 +-}
3129 +-
3130 +-static void tee_shm_op_release(struct dma_buf *dmabuf)
3131 +-{
3132 +- struct tee_shm *shm = dmabuf->priv;
3133 +-
3134 +- tee_shm_release(shm);
3135 +-}
3136 +-
3137 +-static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
3138 +-{
3139 +- struct tee_shm *shm = dmabuf->priv;
3140 +- size_t size = vma->vm_end - vma->vm_start;
3141 +-
3142 +- /* Refuse sharing shared memory provided by application */
3143 +- if (shm->flags & TEE_SHM_USER_MAPPED)
3144 +- return -EINVAL;
3145 +-
3146 +- return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT,
3147 +- size, vma->vm_page_prot);
3148 +-}
3149 +-
3150 +-static const struct dma_buf_ops tee_shm_dma_buf_ops = {
3151 +- .map_dma_buf = tee_shm_op_map_dma_buf,
3152 +- .unmap_dma_buf = tee_shm_op_unmap_dma_buf,
3153 +- .release = tee_shm_op_release,
3154 +- .mmap = tee_shm_op_mmap,
3155 +-};
3156 +-
3157 + struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)
3158 + {
3159 + struct tee_device *teedev = ctx->teedev;
3160 +@@ -137,6 +90,7 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)
3161 + goto err_dev_put;
3162 + }
3163 +
3164 ++ refcount_set(&shm->refcount, 1);
3165 + shm->flags = flags | TEE_SHM_POOL;
3166 + shm->ctx = ctx;
3167 + if (flags & TEE_SHM_DMA_BUF)
3168 +@@ -150,10 +104,7 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)
3169 + goto err_kfree;
3170 + }
3171 +
3172 +-
3173 + if (flags & TEE_SHM_DMA_BUF) {
3174 +- DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
3175 +-
3176 + mutex_lock(&teedev->mutex);
3177 + shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL);
3178 + mutex_unlock(&teedev->mutex);
3179 +@@ -161,28 +112,11 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)
3180 + ret = ERR_PTR(shm->id);
3181 + goto err_pool_free;
3182 + }
3183 +-
3184 +- exp_info.ops = &tee_shm_dma_buf_ops;
3185 +- exp_info.size = shm->size;
3186 +- exp_info.flags = O_RDWR;
3187 +- exp_info.priv = shm;
3188 +-
3189 +- shm->dmabuf = dma_buf_export(&exp_info);
3190 +- if (IS_ERR(shm->dmabuf)) {
3191 +- ret = ERR_CAST(shm->dmabuf);
3192 +- goto err_rem;
3193 +- }
3194 + }
3195 +
3196 + teedev_ctx_get(ctx);
3197 +
3198 + return shm;
3199 +-err_rem:
3200 +- if (flags & TEE_SHM_DMA_BUF) {
3201 +- mutex_lock(&teedev->mutex);
3202 +- idr_remove(&teedev->idr, shm->id);
3203 +- mutex_unlock(&teedev->mutex);
3204 +- }
3205 + err_pool_free:
3206 + poolm->ops->free(poolm, shm);
3207 + err_kfree:
3208 +@@ -243,6 +177,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
3209 + goto err;
3210 + }
3211 +
3212 ++ refcount_set(&shm->refcount, 1);
3213 + shm->flags = flags | TEE_SHM_REGISTER;
3214 + shm->ctx = ctx;
3215 + shm->id = -1;
3216 +@@ -303,22 +238,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
3217 + goto err;
3218 + }
3219 +
3220 +- if (flags & TEE_SHM_DMA_BUF) {
3221 +- DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
3222 +-
3223 +- exp_info.ops = &tee_shm_dma_buf_ops;
3224 +- exp_info.size = shm->size;
3225 +- exp_info.flags = O_RDWR;
3226 +- exp_info.priv = shm;
3227 +-
3228 +- shm->dmabuf = dma_buf_export(&exp_info);
3229 +- if (IS_ERR(shm->dmabuf)) {
3230 +- ret = ERR_CAST(shm->dmabuf);
3231 +- teedev->desc->ops->shm_unregister(ctx, shm);
3232 +- goto err;
3233 +- }
3234 +- }
3235 +-
3236 + return shm;
3237 + err:
3238 + if (shm) {
3239 +@@ -336,6 +255,35 @@ err:
3240 + }
3241 + EXPORT_SYMBOL_GPL(tee_shm_register);
3242 +
3243 ++static int tee_shm_fop_release(struct inode *inode, struct file *filp)
3244 ++{
3245 ++ tee_shm_put(filp->private_data);
3246 ++ return 0;
3247 ++}
3248 ++
3249 ++static int tee_shm_fop_mmap(struct file *filp, struct vm_area_struct *vma)
3250 ++{
3251 ++ struct tee_shm *shm = filp->private_data;
3252 ++ size_t size = vma->vm_end - vma->vm_start;
3253 ++
3254 ++ /* Refuse sharing shared memory provided by application */
3255 ++ if (shm->flags & TEE_SHM_USER_MAPPED)
3256 ++ return -EINVAL;
3257 ++
3258 ++ /* check for overflowing the buffer's size */
3259 ++ if (vma->vm_pgoff + vma_pages(vma) > shm->size >> PAGE_SHIFT)
3260 ++ return -EINVAL;
3261 ++
3262 ++ return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT,
3263 ++ size, vma->vm_page_prot);
3264 ++}
3265 ++
3266 ++static const struct file_operations tee_shm_fops = {
3267 ++ .owner = THIS_MODULE,
3268 ++ .release = tee_shm_fop_release,
3269 ++ .mmap = tee_shm_fop_mmap,
3270 ++};
3271 ++
3272 + /**
3273 + * tee_shm_get_fd() - Increase reference count and return file descriptor
3274 + * @shm: Shared memory handle
3275 +@@ -348,10 +296,11 @@ int tee_shm_get_fd(struct tee_shm *shm)
3276 + if (!(shm->flags & TEE_SHM_DMA_BUF))
3277 + return -EINVAL;
3278 +
3279 +- get_dma_buf(shm->dmabuf);
3280 +- fd = dma_buf_fd(shm->dmabuf, O_CLOEXEC);
3281 ++ /* matched by tee_shm_put() in tee_shm_op_release() */
3282 ++ refcount_inc(&shm->refcount);
3283 ++ fd = anon_inode_getfd("tee_shm", &tee_shm_fops, shm, O_RDWR);
3284 + if (fd < 0)
3285 +- dma_buf_put(shm->dmabuf);
3286 ++ tee_shm_put(shm);
3287 + return fd;
3288 + }
3289 +
3290 +@@ -361,17 +310,7 @@ int tee_shm_get_fd(struct tee_shm *shm)
3291 + */
3292 + void tee_shm_free(struct tee_shm *shm)
3293 + {
3294 +- /*
3295 +- * dma_buf_put() decreases the dmabuf reference counter and will
3296 +- * call tee_shm_release() when the last reference is gone.
3297 +- *
3298 +- * In the case of driver private memory we call tee_shm_release
3299 +- * directly instead as it doesn't have a reference counter.
3300 +- */
3301 +- if (shm->flags & TEE_SHM_DMA_BUF)
3302 +- dma_buf_put(shm->dmabuf);
3303 +- else
3304 +- tee_shm_release(shm);
3305 ++ tee_shm_put(shm);
3306 + }
3307 + EXPORT_SYMBOL_GPL(tee_shm_free);
3308 +
3309 +@@ -478,10 +417,15 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id)
3310 + teedev = ctx->teedev;
3311 + mutex_lock(&teedev->mutex);
3312 + shm = idr_find(&teedev->idr, id);
3313 ++ /*
3314 ++ * If the tee_shm was found in the IDR it must have a refcount
3315 ++ * larger than 0 due to the guarantee in tee_shm_put() below. So
3316 ++ * it's safe to use refcount_inc().
3317 ++ */
3318 + if (!shm || shm->ctx != ctx)
3319 + shm = ERR_PTR(-EINVAL);
3320 +- else if (shm->flags & TEE_SHM_DMA_BUF)
3321 +- get_dma_buf(shm->dmabuf);
3322 ++ else
3323 ++ refcount_inc(&shm->refcount);
3324 + mutex_unlock(&teedev->mutex);
3325 + return shm;
3326 + }
3327 +@@ -493,7 +437,24 @@ EXPORT_SYMBOL_GPL(tee_shm_get_from_id);
3328 + */
3329 + void tee_shm_put(struct tee_shm *shm)
3330 + {
3331 +- if (shm->flags & TEE_SHM_DMA_BUF)
3332 +- dma_buf_put(shm->dmabuf);
3333 ++ struct tee_device *teedev = shm->ctx->teedev;
3334 ++ bool do_release = false;
3335 ++
3336 ++ mutex_lock(&teedev->mutex);
3337 ++ if (refcount_dec_and_test(&shm->refcount)) {
3338 ++ /*
3339 ++ * refcount has reached 0, we must now remove it from the
3340 ++ * IDR before releasing the mutex. This will guarantee that
3341 ++ * the refcount_inc() in tee_shm_get_from_id() never starts
3342 ++ * from 0.
3343 ++ */
3344 ++ if (shm->flags & TEE_SHM_DMA_BUF)
3345 ++ idr_remove(&teedev->idr, shm->id);
3346 ++ do_release = true;
3347 ++ }
3348 ++ mutex_unlock(&teedev->mutex);
3349 ++
3350 ++ if (do_release)
3351 ++ tee_shm_release(teedev, shm);
3352 + }
3353 + EXPORT_SYMBOL_GPL(tee_shm_put);
3354 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
3355 +index 01c00ae8e06d6..daa83525749b3 100644
3356 +--- a/fs/ext4/extents.c
3357 ++++ b/fs/ext4/extents.c
3358 +@@ -136,15 +136,25 @@ int ext4_datasem_ensure_credits(handle_t *handle, struct inode *inode,
3359 + static int ext4_ext_get_access(handle_t *handle, struct inode *inode,
3360 + struct ext4_ext_path *path)
3361 + {
3362 ++ int err = 0;
3363 ++
3364 + if (path->p_bh) {
3365 + /* path points to block */
3366 + BUFFER_TRACE(path->p_bh, "get_write_access");
3367 +- return ext4_journal_get_write_access(handle, inode->i_sb,
3368 +- path->p_bh, EXT4_JTR_NONE);
3369 ++ err = ext4_journal_get_write_access(handle, inode->i_sb,
3370 ++ path->p_bh, EXT4_JTR_NONE);
3371 ++ /*
3372 ++ * The extent buffer's verified bit will be set again in
3373 ++ * __ext4_ext_dirty(). We could leave an inconsistent
3374 ++ * buffer if the extents updating procudure break off du
3375 ++ * to some error happens, force to check it again.
3376 ++ */
3377 ++ if (!err)
3378 ++ clear_buffer_verified(path->p_bh);
3379 + }
3380 + /* path points to leaf/index in inode body */
3381 + /* we use in-core data, no need to protect them */
3382 +- return 0;
3383 ++ return err;
3384 + }
3385 +
3386 + /*
3387 +@@ -165,6 +175,9 @@ static int __ext4_ext_dirty(const char *where, unsigned int line,
3388 + /* path points to block */
3389 + err = __ext4_handle_dirty_metadata(where, line, handle,
3390 + inode, path->p_bh);
3391 ++ /* Extents updating done, re-set verified flag */
3392 ++ if (!err)
3393 ++ set_buffer_verified(path->p_bh);
3394 + } else {
3395 + /* path points to leaf/index in inode body */
3396 + err = ext4_mark_inode_dirty(handle, inode);
3397 +@@ -354,9 +367,13 @@ static int ext4_valid_extent_idx(struct inode *inode,
3398 +
3399 + static int ext4_valid_extent_entries(struct inode *inode,
3400 + struct ext4_extent_header *eh,
3401 +- ext4_fsblk_t *pblk, int depth)
3402 ++ ext4_lblk_t lblk, ext4_fsblk_t *pblk,
3403 ++ int depth)
3404 + {
3405 + unsigned short entries;
3406 ++ ext4_lblk_t lblock = 0;
3407 ++ ext4_lblk_t prev = 0;
3408 ++
3409 + if (eh->eh_entries == 0)
3410 + return 1;
3411 +
3412 +@@ -365,31 +382,51 @@ static int ext4_valid_extent_entries(struct inode *inode,
3413 + if (depth == 0) {
3414 + /* leaf entries */
3415 + struct ext4_extent *ext = EXT_FIRST_EXTENT(eh);
3416 +- ext4_lblk_t lblock = 0;
3417 +- ext4_lblk_t prev = 0;
3418 +- int len = 0;
3419 ++
3420 ++ /*
3421 ++ * The logical block in the first entry should equal to
3422 ++ * the number in the index block.
3423 ++ */
3424 ++ if (depth != ext_depth(inode) &&
3425 ++ lblk != le32_to_cpu(ext->ee_block))
3426 ++ return 0;
3427 + while (entries) {
3428 + if (!ext4_valid_extent(inode, ext))
3429 + return 0;
3430 +
3431 + /* Check for overlapping extents */
3432 + lblock = le32_to_cpu(ext->ee_block);
3433 +- len = ext4_ext_get_actual_len(ext);
3434 + if ((lblock <= prev) && prev) {
3435 + *pblk = ext4_ext_pblock(ext);
3436 + return 0;
3437 + }
3438 ++ prev = lblock + ext4_ext_get_actual_len(ext) - 1;
3439 + ext++;
3440 + entries--;
3441 +- prev = lblock + len - 1;
3442 + }
3443 + } else {
3444 + struct ext4_extent_idx *ext_idx = EXT_FIRST_INDEX(eh);
3445 ++
3446 ++ /*
3447 ++ * The logical block in the first entry should equal to
3448 ++ * the number in the parent index block.
3449 ++ */
3450 ++ if (depth != ext_depth(inode) &&
3451 ++ lblk != le32_to_cpu(ext_idx->ei_block))
3452 ++ return 0;
3453 + while (entries) {
3454 + if (!ext4_valid_extent_idx(inode, ext_idx))
3455 + return 0;
3456 ++
3457 ++ /* Check for overlapping index extents */
3458 ++ lblock = le32_to_cpu(ext_idx->ei_block);
3459 ++ if ((lblock <= prev) && prev) {
3460 ++ *pblk = ext4_idx_pblock(ext_idx);
3461 ++ return 0;
3462 ++ }
3463 + ext_idx++;
3464 + entries--;
3465 ++ prev = lblock;
3466 + }
3467 + }
3468 + return 1;
3469 +@@ -397,7 +434,7 @@ static int ext4_valid_extent_entries(struct inode *inode,
3470 +
3471 + static int __ext4_ext_check(const char *function, unsigned int line,
3472 + struct inode *inode, struct ext4_extent_header *eh,
3473 +- int depth, ext4_fsblk_t pblk)
3474 ++ int depth, ext4_fsblk_t pblk, ext4_lblk_t lblk)
3475 + {
3476 + const char *error_msg;
3477 + int max = 0, err = -EFSCORRUPTED;
3478 +@@ -423,7 +460,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
3479 + error_msg = "invalid eh_entries";
3480 + goto corrupted;
3481 + }
3482 +- if (!ext4_valid_extent_entries(inode, eh, &pblk, depth)) {
3483 ++ if (!ext4_valid_extent_entries(inode, eh, lblk, &pblk, depth)) {
3484 + error_msg = "invalid extent entries";
3485 + goto corrupted;
3486 + }
3487 +@@ -453,7 +490,7 @@ corrupted:
3488 + }
3489 +
3490 + #define ext4_ext_check(inode, eh, depth, pblk) \
3491 +- __ext4_ext_check(__func__, __LINE__, (inode), (eh), (depth), (pblk))
3492 ++ __ext4_ext_check(__func__, __LINE__, (inode), (eh), (depth), (pblk), 0)
3493 +
3494 + int ext4_ext_check_inode(struct inode *inode)
3495 + {
3496 +@@ -486,16 +523,18 @@ static void ext4_cache_extents(struct inode *inode,
3497 +
3498 + static struct buffer_head *
3499 + __read_extent_tree_block(const char *function, unsigned int line,
3500 +- struct inode *inode, ext4_fsblk_t pblk, int depth,
3501 +- int flags)
3502 ++ struct inode *inode, struct ext4_extent_idx *idx,
3503 ++ int depth, int flags)
3504 + {
3505 + struct buffer_head *bh;
3506 + int err;
3507 + gfp_t gfp_flags = __GFP_MOVABLE | GFP_NOFS;
3508 ++ ext4_fsblk_t pblk;
3509 +
3510 + if (flags & EXT4_EX_NOFAIL)
3511 + gfp_flags |= __GFP_NOFAIL;
3512 +
3513 ++ pblk = ext4_idx_pblock(idx);
3514 + bh = sb_getblk_gfp(inode->i_sb, pblk, gfp_flags);
3515 + if (unlikely(!bh))
3516 + return ERR_PTR(-ENOMEM);
3517 +@@ -508,8 +547,8 @@ __read_extent_tree_block(const char *function, unsigned int line,
3518 + }
3519 + if (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))
3520 + return bh;
3521 +- err = __ext4_ext_check(function, line, inode,
3522 +- ext_block_hdr(bh), depth, pblk);
3523 ++ err = __ext4_ext_check(function, line, inode, ext_block_hdr(bh),
3524 ++ depth, pblk, le32_to_cpu(idx->ei_block));
3525 + if (err)
3526 + goto errout;
3527 + set_buffer_verified(bh);
3528 +@@ -527,8 +566,8 @@ errout:
3529 +
3530 + }
3531 +
3532 +-#define read_extent_tree_block(inode, pblk, depth, flags) \
3533 +- __read_extent_tree_block(__func__, __LINE__, (inode), (pblk), \
3534 ++#define read_extent_tree_block(inode, idx, depth, flags) \
3535 ++ __read_extent_tree_block(__func__, __LINE__, (inode), (idx), \
3536 + (depth), (flags))
3537 +
3538 + /*
3539 +@@ -578,8 +617,7 @@ int ext4_ext_precache(struct inode *inode)
3540 + i--;
3541 + continue;
3542 + }
3543 +- bh = read_extent_tree_block(inode,
3544 +- ext4_idx_pblock(path[i].p_idx++),
3545 ++ bh = read_extent_tree_block(inode, path[i].p_idx++,
3546 + depth - i - 1,
3547 + EXT4_EX_FORCE_CACHE);
3548 + if (IS_ERR(bh)) {
3549 +@@ -884,8 +922,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
3550 + path[ppos].p_depth = i;
3551 + path[ppos].p_ext = NULL;
3552 +
3553 +- bh = read_extent_tree_block(inode, path[ppos].p_block, --i,
3554 +- flags);
3555 ++ bh = read_extent_tree_block(inode, path[ppos].p_idx, --i, flags);
3556 + if (IS_ERR(bh)) {
3557 + ret = PTR_ERR(bh);
3558 + goto err;
3559 +@@ -1494,7 +1531,6 @@ static int ext4_ext_search_right(struct inode *inode,
3560 + struct ext4_extent_header *eh;
3561 + struct ext4_extent_idx *ix;
3562 + struct ext4_extent *ex;
3563 +- ext4_fsblk_t block;
3564 + int depth; /* Note, NOT eh_depth; depth from top of tree */
3565 + int ee_len;
3566 +
3567 +@@ -1561,20 +1597,17 @@ got_index:
3568 + * follow it and find the closest allocated
3569 + * block to the right */
3570 + ix++;
3571 +- block = ext4_idx_pblock(ix);
3572 + while (++depth < path->p_depth) {
3573 + /* subtract from p_depth to get proper eh_depth */
3574 +- bh = read_extent_tree_block(inode, block,
3575 +- path->p_depth - depth, 0);
3576 ++ bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0);
3577 + if (IS_ERR(bh))
3578 + return PTR_ERR(bh);
3579 + eh = ext_block_hdr(bh);
3580 + ix = EXT_FIRST_INDEX(eh);
3581 +- block = ext4_idx_pblock(ix);
3582 + put_bh(bh);
3583 + }
3584 +
3585 +- bh = read_extent_tree_block(inode, block, path->p_depth - depth, 0);
3586 ++ bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0);
3587 + if (IS_ERR(bh))
3588 + return PTR_ERR(bh);
3589 + eh = ext_block_hdr(bh);
3590 +@@ -2953,9 +2986,9 @@ again:
3591 + ext_debug(inode, "move to level %d (block %llu)\n",
3592 + i + 1, ext4_idx_pblock(path[i].p_idx));
3593 + memset(path + i + 1, 0, sizeof(*path));
3594 +- bh = read_extent_tree_block(inode,
3595 +- ext4_idx_pblock(path[i].p_idx), depth - i - 1,
3596 +- EXT4_EX_NOCACHE);
3597 ++ bh = read_extent_tree_block(inode, path[i].p_idx,
3598 ++ depth - i - 1,
3599 ++ EXT4_EX_NOCACHE);
3600 + if (IS_ERR(bh)) {
3601 + /* should we reset i_size? */
3602 + err = PTR_ERR(bh);
3603 +diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
3604 +index 1d2d29dcd41ce..6a3b3bec7989d 100644
3605 +--- a/fs/f2fs/xattr.c
3606 ++++ b/fs/f2fs/xattr.c
3607 +@@ -684,8 +684,17 @@ static int __f2fs_setxattr(struct inode *inode, int index,
3608 + }
3609 +
3610 + last = here;
3611 +- while (!IS_XATTR_LAST_ENTRY(last))
3612 ++ while (!IS_XATTR_LAST_ENTRY(last)) {
3613 ++ if ((void *)(last) + sizeof(__u32) > last_base_addr ||
3614 ++ (void *)XATTR_NEXT_ENTRY(last) > last_base_addr) {
3615 ++ f2fs_err(F2FS_I_SB(inode), "inode (%lu) has invalid last xattr entry, entry_size: %zu",
3616 ++ inode->i_ino, ENTRY_SIZE(last));
3617 ++ set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK);
3618 ++ error = -EFSCORRUPTED;
3619 ++ goto exit;
3620 ++ }
3621 + last = XATTR_NEXT_ENTRY(last);
3622 ++ }
3623 +
3624 + newsize = XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + len + size);
3625 +
3626 +diff --git a/fs/io_uring.c b/fs/io_uring.c
3627 +index e9b06e339c4b0..0006fc7479ca3 100644
3628 +--- a/fs/io_uring.c
3629 ++++ b/fs/io_uring.c
3630 +@@ -2879,9 +2879,13 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
3631 + req->flags |= REQ_F_ISREG;
3632 +
3633 + kiocb->ki_pos = READ_ONCE(sqe->off);
3634 +- if (kiocb->ki_pos == -1 && !(file->f_mode & FMODE_STREAM)) {
3635 +- req->flags |= REQ_F_CUR_POS;
3636 +- kiocb->ki_pos = file->f_pos;
3637 ++ if (kiocb->ki_pos == -1) {
3638 ++ if (!(file->f_mode & FMODE_STREAM)) {
3639 ++ req->flags |= REQ_F_CUR_POS;
3640 ++ kiocb->ki_pos = file->f_pos;
3641 ++ } else {
3642 ++ kiocb->ki_pos = 0;
3643 ++ }
3644 + }
3645 + kiocb->ki_hint = ki_hint_validate(file_write_hint(kiocb->ki_filp));
3646 + kiocb->ki_flags = iocb_flags(kiocb->ki_filp);
3647 +diff --git a/fs/ksmbd/ndr.c b/fs/ksmbd/ndr.c
3648 +index 8317f7ca402b4..5052be9261d91 100644
3649 +--- a/fs/ksmbd/ndr.c
3650 ++++ b/fs/ksmbd/ndr.c
3651 +@@ -148,7 +148,7 @@ static int ndr_read_int16(struct ndr *n, __u16 *value)
3652 + static int ndr_read_int32(struct ndr *n, __u32 *value)
3653 + {
3654 + if (n->offset + sizeof(__u32) > n->length)
3655 +- return 0;
3656 ++ return -EINVAL;
3657 +
3658 + if (value)
3659 + *value = le32_to_cpu(*(__le32 *)ndr_get_field(n));
3660 +diff --git a/fs/ksmbd/smb2ops.c b/fs/ksmbd/smb2ops.c
3661 +index fb6a65d231391..2a6205103df2c 100644
3662 +--- a/fs/ksmbd/smb2ops.c
3663 ++++ b/fs/ksmbd/smb2ops.c
3664 +@@ -272,9 +272,6 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
3665 + if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
3666 + conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;
3667 +
3668 +- if (conn->cipher_type)
3669 +- conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
3670 +-
3671 + if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
3672 + conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
3673 +
3674 +diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
3675 +index ad0ea5d36f2ee..cb71cbfc5fc9b 100644
3676 +--- a/fs/ksmbd/smb2pdu.c
3677 ++++ b/fs/ksmbd/smb2pdu.c
3678 +@@ -917,6 +917,25 @@ static void decode_encrypt_ctxt(struct ksmbd_conn *conn,
3679 + }
3680 + }
3681 +
3682 ++/**
3683 ++ * smb3_encryption_negotiated() - checks if server and client agreed on enabling encryption
3684 ++ * @conn: smb connection
3685 ++ *
3686 ++ * Return: true if connection should be encrypted, else false
3687 ++ */
3688 ++static bool smb3_encryption_negotiated(struct ksmbd_conn *conn)
3689 ++{
3690 ++ if (!conn->ops->generate_encryptionkey)
3691 ++ return false;
3692 ++
3693 ++ /*
3694 ++ * SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag.
3695 ++ * SMB 3.1.1 uses the cipher_type field.
3696 ++ */
3697 ++ return (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
3698 ++ conn->cipher_type;
3699 ++}
3700 ++
3701 + static void decode_compress_ctxt(struct ksmbd_conn *conn,
3702 + struct smb2_compression_ctx *pneg_ctxt)
3703 + {
3704 +@@ -1471,8 +1490,7 @@ static int ntlm_authenticate(struct ksmbd_work *work)
3705 + (req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
3706 + sess->sign = true;
3707 +
3708 +- if (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION &&
3709 +- conn->ops->generate_encryptionkey &&
3710 ++ if (smb3_encryption_negotiated(conn) &&
3711 + !(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
3712 + rc = conn->ops->generate_encryptionkey(sess);
3713 + if (rc) {
3714 +@@ -1562,8 +1580,7 @@ static int krb5_authenticate(struct ksmbd_work *work)
3715 + (req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
3716 + sess->sign = true;
3717 +
3718 +- if ((conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) &&
3719 +- conn->ops->generate_encryptionkey) {
3720 ++ if (smb3_encryption_negotiated(conn)) {
3721 + retval = conn->ops->generate_encryptionkey(sess);
3722 + if (retval) {
3723 + ksmbd_debug(SMB,
3724 +@@ -2964,6 +2981,10 @@ int smb2_open(struct ksmbd_work *work)
3725 + &pntsd_size, &fattr);
3726 + posix_acl_release(fattr.cf_acls);
3727 + posix_acl_release(fattr.cf_dacls);
3728 ++ if (rc) {
3729 ++ kfree(pntsd);
3730 ++ goto err_out;
3731 ++ }
3732 +
3733 + rc = ksmbd_vfs_set_sd_xattr(conn,
3734 + user_ns,
3735 +diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
3736 +index 4b54529f8176b..242f8bcb34a4c 100644
3737 +--- a/fs/netfs/read_helper.c
3738 ++++ b/fs/netfs/read_helper.c
3739 +@@ -958,7 +958,7 @@ int netfs_readpage(struct file *file,
3740 + rreq = netfs_alloc_read_request(ops, netfs_priv, file);
3741 + if (!rreq) {
3742 + if (netfs_priv)
3743 +- ops->cleanup(netfs_priv, page_file_mapping(page));
3744 ++ ops->cleanup(page_file_mapping(page), netfs_priv);
3745 + unlock_page(page);
3746 + return -ENOMEM;
3747 + }
3748 +@@ -1185,7 +1185,7 @@ have_page:
3749 + goto error;
3750 + have_page_no_wait:
3751 + if (netfs_priv)
3752 +- ops->cleanup(netfs_priv, mapping);
3753 ++ ops->cleanup(mapping, netfs_priv);
3754 + *_page = page;
3755 + _leave(" = 0");
3756 + return 0;
3757 +@@ -1196,7 +1196,7 @@ error:
3758 + unlock_page(page);
3759 + put_page(page);
3760 + if (netfs_priv)
3761 +- ops->cleanup(netfs_priv, mapping);
3762 ++ ops->cleanup(mapping, netfs_priv);
3763 + _leave(" = %d", ret);
3764 + return ret;
3765 + }
3766 +diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
3767 +index 17715a6c7a409..a0ccba636bf99 100644
3768 +--- a/fs/nfsd/nfs3proc.c
3769 ++++ b/fs/nfsd/nfs3proc.c
3770 +@@ -439,22 +439,19 @@ nfsd3_proc_link(struct svc_rqst *rqstp)
3771 +
3772 + static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
3773 + struct nfsd3_readdirres *resp,
3774 +- int count)
3775 ++ u32 count)
3776 + {
3777 + struct xdr_buf *buf = &resp->dirlist;
3778 + struct xdr_stream *xdr = &resp->xdr;
3779 +
3780 +- count = min_t(u32, count, svc_max_payload(rqstp));
3781 ++ count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp));
3782 +
3783 + memset(buf, 0, sizeof(*buf));
3784 +
3785 + /* Reserve room for the NULL ptr & eof flag (-2 words) */
3786 + buf->buflen = count - XDR_UNIT * 2;
3787 + buf->pages = rqstp->rq_next_page;
3788 +- while (count > 0) {
3789 +- rqstp->rq_next_page++;
3790 +- count -= PAGE_SIZE;
3791 +- }
3792 ++ rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
3793 +
3794 + /* This is xdr_init_encode(), but it assumes that
3795 + * the head kvec has already been consumed. */
3796 +@@ -463,7 +460,7 @@ static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
3797 + xdr->page_ptr = buf->pages;
3798 + xdr->iov = NULL;
3799 + xdr->p = page_address(*buf->pages);
3800 +- xdr->end = xdr->p + (PAGE_SIZE >> 2);
3801 ++ xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
3802 + xdr->rqst = NULL;
3803 + }
3804 +
3805 +diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
3806 +index 90fcd6178823b..19c568b8a527f 100644
3807 +--- a/fs/nfsd/nfsproc.c
3808 ++++ b/fs/nfsd/nfsproc.c
3809 +@@ -557,17 +557,17 @@ nfsd_proc_rmdir(struct svc_rqst *rqstp)
3810 +
3811 + static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
3812 + struct nfsd_readdirres *resp,
3813 +- int count)
3814 ++ u32 count)
3815 + {
3816 + struct xdr_buf *buf = &resp->dirlist;
3817 + struct xdr_stream *xdr = &resp->xdr;
3818 +
3819 +- count = min_t(u32, count, PAGE_SIZE);
3820 ++ count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp));
3821 +
3822 + memset(buf, 0, sizeof(*buf));
3823 +
3824 + /* Reserve room for the NULL ptr & eof flag (-2 words) */
3825 +- buf->buflen = count - sizeof(__be32) * 2;
3826 ++ buf->buflen = count - XDR_UNIT * 2;
3827 + buf->pages = rqstp->rq_next_page;
3828 + rqstp->rq_next_page++;
3829 +
3830 +@@ -578,7 +578,7 @@ static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
3831 + xdr->page_ptr = buf->pages;
3832 + xdr->iov = NULL;
3833 + xdr->p = page_address(*buf->pages);
3834 +- xdr->end = xdr->p + (PAGE_SIZE >> 2);
3835 ++ xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
3836 + xdr->rqst = NULL;
3837 + }
3838 +
3839 +diff --git a/include/linux/compiler.h b/include/linux/compiler.h
3840 +index 3d5af56337bdb..429dcebe2b992 100644
3841 +--- a/include/linux/compiler.h
3842 ++++ b/include/linux/compiler.h
3843 +@@ -121,7 +121,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
3844 + asm volatile(__stringify_label(c) ":\n\t" \
3845 + ".pushsection .discard.reachable\n\t" \
3846 + ".long " __stringify_label(c) "b - .\n\t" \
3847 +- ".popsection\n\t"); \
3848 ++ ".popsection\n\t" : : "i" (c)); \
3849 + })
3850 + #define annotate_reachable() __annotate_reachable(__COUNTER__)
3851 +
3852 +@@ -129,7 +129,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
3853 + asm volatile(__stringify_label(c) ":\n\t" \
3854 + ".pushsection .discard.unreachable\n\t" \
3855 + ".long " __stringify_label(c) "b - .\n\t" \
3856 +- ".popsection\n\t"); \
3857 ++ ".popsection\n\t" : : "i" (c)); \
3858 + })
3859 + #define annotate_unreachable() __annotate_unreachable(__COUNTER__)
3860 +
3861 +diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
3862 +index fa2cd8c63dcc9..24359b4a96053 100644
3863 +--- a/include/linux/instrumentation.h
3864 ++++ b/include/linux/instrumentation.h
3865 +@@ -11,7 +11,7 @@
3866 + asm volatile(__stringify(c) ": nop\n\t" \
3867 + ".pushsection .discard.instr_begin\n\t" \
3868 + ".long " __stringify(c) "b - .\n\t" \
3869 +- ".popsection\n\t"); \
3870 ++ ".popsection\n\t" : : "i" (c)); \
3871 + })
3872 + #define instrumentation_begin() __instrumentation_begin(__COUNTER__)
3873 +
3874 +@@ -50,7 +50,7 @@
3875 + asm volatile(__stringify(c) ": nop\n\t" \
3876 + ".pushsection .discard.instr_end\n\t" \
3877 + ".long " __stringify(c) "b - .\n\t" \
3878 +- ".popsection\n\t"); \
3879 ++ ".popsection\n\t" : : "i" (c)); \
3880 + })
3881 + #define instrumentation_end() __instrumentation_end(__COUNTER__)
3882 + #else
3883 +diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
3884 +index ef4a69865737c..c383630d3f065 100644
3885 +--- a/include/linux/ipv6.h
3886 ++++ b/include/linux/ipv6.h
3887 +@@ -282,7 +282,6 @@ struct ipv6_pinfo {
3888 + __be32 rcv_flowinfo;
3889 +
3890 + __u32 dst_cookie;
3891 +- __u32 rx_dst_cookie;
3892 +
3893 + struct ipv6_mc_socklist __rcu *ipv6_mc_list;
3894 + struct ipv6_ac_socklist *ipv6_ac_list;
3895 +diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
3896 +index 3ebfea0781f10..feda1dc7f98ee 100644
3897 +--- a/include/linux/tee_drv.h
3898 ++++ b/include/linux/tee_drv.h
3899 +@@ -195,7 +195,7 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
3900 + * @offset: offset of buffer in user space
3901 + * @pages: locked pages from userspace
3902 + * @num_pages: number of locked pages
3903 +- * @dmabuf: dmabuf used to for exporting to user space
3904 ++ * @refcount: reference counter
3905 + * @flags: defined by TEE_SHM_* in tee_drv.h
3906 + * @id: unique id of a shared memory object on this device
3907 + *
3908 +@@ -210,7 +210,7 @@ struct tee_shm {
3909 + unsigned int offset;
3910 + struct page **pages;
3911 + size_t num_pages;
3912 +- struct dma_buf *dmabuf;
3913 ++ refcount_t refcount;
3914 + u32 flags;
3915 + int id;
3916 + };
3917 +diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
3918 +index 04e87f4b9417c..a960de68ac69e 100644
3919 +--- a/include/linux/virtio_net.h
3920 ++++ b/include/linux/virtio_net.h
3921 +@@ -7,9 +7,27 @@
3922 + #include <uapi/linux/udp.h>
3923 + #include <uapi/linux/virtio_net.h>
3924 +
3925 ++static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
3926 ++{
3927 ++ switch (gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
3928 ++ case VIRTIO_NET_HDR_GSO_TCPV4:
3929 ++ return protocol == cpu_to_be16(ETH_P_IP);
3930 ++ case VIRTIO_NET_HDR_GSO_TCPV6:
3931 ++ return protocol == cpu_to_be16(ETH_P_IPV6);
3932 ++ case VIRTIO_NET_HDR_GSO_UDP:
3933 ++ return protocol == cpu_to_be16(ETH_P_IP) ||
3934 ++ protocol == cpu_to_be16(ETH_P_IPV6);
3935 ++ default:
3936 ++ return false;
3937 ++ }
3938 ++}
3939 ++
3940 + static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
3941 + const struct virtio_net_hdr *hdr)
3942 + {
3943 ++ if (skb->protocol)
3944 ++ return 0;
3945 ++
3946 + switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
3947 + case VIRTIO_NET_HDR_GSO_TCPV4:
3948 + case VIRTIO_NET_HDR_GSO_UDP:
3949 +@@ -88,9 +106,12 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
3950 + if (!skb->protocol) {
3951 + __be16 protocol = dev_parse_header_protocol(skb);
3952 +
3953 +- virtio_net_hdr_set_proto(skb, hdr);
3954 +- if (protocol && protocol != skb->protocol)
3955 ++ if (!protocol)
3956 ++ virtio_net_hdr_set_proto(skb, hdr);
3957 ++ else if (!virtio_net_hdr_match_proto(protocol, hdr->gso_type))
3958 + return -EINVAL;
3959 ++ else
3960 ++ skb->protocol = protocol;
3961 + }
3962 + retry:
3963 + if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
3964 +diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
3965 +index 89163ef8cf4be..9e1111f5915bd 100644
3966 +--- a/include/net/inet_sock.h
3967 ++++ b/include/net/inet_sock.h
3968 +@@ -207,11 +207,10 @@ struct inet_sock {
3969 + __be32 inet_saddr;
3970 + __s16 uc_ttl;
3971 + __u16 cmsg_flags;
3972 ++ struct ip_options_rcu __rcu *inet_opt;
3973 + __be16 inet_sport;
3974 + __u16 inet_id;
3975 +
3976 +- struct ip_options_rcu __rcu *inet_opt;
3977 +- int rx_dst_ifindex;
3978 + __u8 tos;
3979 + __u8 min_ttl;
3980 + __u8 mc_ttl;
3981 +diff --git a/include/net/sock.h b/include/net/sock.h
3982 +index 7ac5075f9c18a..dfb92f91d5be5 100644
3983 +--- a/include/net/sock.h
3984 ++++ b/include/net/sock.h
3985 +@@ -259,6 +259,8 @@ struct bpf_local_storage;
3986 + * @sk_rcvbuf: size of receive buffer in bytes
3987 + * @sk_wq: sock wait queue and async head
3988 + * @sk_rx_dst: receive input route used by early demux
3989 ++ * @sk_rx_dst_ifindex: ifindex for @sk_rx_dst
3990 ++ * @sk_rx_dst_cookie: cookie for @sk_rx_dst
3991 + * @sk_dst_cache: destination cache
3992 + * @sk_dst_pending_confirm: need to confirm neighbour
3993 + * @sk_policy: flow policy
3994 +@@ -430,7 +432,10 @@ struct sock {
3995 + #ifdef CONFIG_XFRM
3996 + struct xfrm_policy __rcu *sk_policy[2];
3997 + #endif
3998 +- struct dst_entry *sk_rx_dst;
3999 ++ struct dst_entry __rcu *sk_rx_dst;
4000 ++ int sk_rx_dst_ifindex;
4001 ++ u32 sk_rx_dst_cookie;
4002 ++
4003 + struct dst_entry __rcu *sk_dst_cache;
4004 + atomic_t sk_omem_alloc;
4005 + int sk_sndbuf;
4006 +diff --git a/include/uapi/linux/byteorder/big_endian.h b/include/uapi/linux/byteorder/big_endian.h
4007 +index 2199adc6a6c20..80aa5c41a7636 100644
4008 +--- a/include/uapi/linux/byteorder/big_endian.h
4009 ++++ b/include/uapi/linux/byteorder/big_endian.h
4010 +@@ -9,6 +9,7 @@
4011 + #define __BIG_ENDIAN_BITFIELD
4012 + #endif
4013 +
4014 ++#include <linux/stddef.h>
4015 + #include <linux/types.h>
4016 + #include <linux/swab.h>
4017 +
4018 +diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
4019 +index 601c904fd5cd9..cd98982e7523e 100644
4020 +--- a/include/uapi/linux/byteorder/little_endian.h
4021 ++++ b/include/uapi/linux/byteorder/little_endian.h
4022 +@@ -9,6 +9,7 @@
4023 + #define __LITTLE_ENDIAN_BITFIELD
4024 + #endif
4025 +
4026 ++#include <linux/stddef.h>
4027 + #include <linux/types.h>
4028 + #include <linux/swab.h>
4029 +
4030 +diff --git a/kernel/crash_core.c b/kernel/crash_core.c
4031 +index eb53f5ec62c90..256cf6db573cd 100644
4032 +--- a/kernel/crash_core.c
4033 ++++ b/kernel/crash_core.c
4034 +@@ -6,6 +6,7 @@
4035 +
4036 + #include <linux/buildid.h>
4037 + #include <linux/crash_core.h>
4038 ++#include <linux/init.h>
4039 + #include <linux/utsname.h>
4040 + #include <linux/vmalloc.h>
4041 +
4042 +@@ -295,6 +296,16 @@ int __init parse_crashkernel_low(char *cmdline,
4043 + "crashkernel=", suffix_tbl[SUFFIX_LOW]);
4044 + }
4045 +
4046 ++/*
4047 ++ * Add a dummy early_param handler to mark crashkernel= as a known command line
4048 ++ * parameter and suppress incorrect warnings in init/main.c.
4049 ++ */
4050 ++static int __init parse_crashkernel_dummy(char *arg)
4051 ++{
4052 ++ return 0;
4053 ++}
4054 ++early_param("crashkernel", parse_crashkernel_dummy);
4055 ++
4056 + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
4057 + void *data, size_t data_len)
4058 + {
4059 +diff --git a/kernel/ucount.c b/kernel/ucount.c
4060 +index eb03f3c68375d..16feb710ee638 100644
4061 +--- a/kernel/ucount.c
4062 ++++ b/kernel/ucount.c
4063 +@@ -258,15 +258,16 @@ void dec_ucount(struct ucounts *ucounts, enum ucount_type type)
4064 + long inc_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v)
4065 + {
4066 + struct ucounts *iter;
4067 ++ long max = LONG_MAX;
4068 + long ret = 0;
4069 +
4070 + for (iter = ucounts; iter; iter = iter->ns->ucounts) {
4071 +- long max = READ_ONCE(iter->ns->ucount_max[type]);
4072 + long new = atomic_long_add_return(v, &iter->ucount[type]);
4073 + if (new < 0 || new > max)
4074 + ret = LONG_MAX;
4075 + else if (iter == ucounts)
4076 + ret = new;
4077 ++ max = READ_ONCE(iter->ns->ucount_max[type]);
4078 + }
4079 + return ret;
4080 + }
4081 +@@ -306,15 +307,16 @@ long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum ucount_type type)
4082 + {
4083 + /* Caller must hold a reference to ucounts */
4084 + struct ucounts *iter;
4085 ++ long max = LONG_MAX;
4086 + long dec, ret = 0;
4087 +
4088 + for (iter = ucounts; iter; iter = iter->ns->ucounts) {
4089 +- long max = READ_ONCE(iter->ns->ucount_max[type]);
4090 + long new = atomic_long_add_return(1, &iter->ucount[type]);
4091 + if (new < 0 || new > max)
4092 + goto unwind;
4093 + if (iter == ucounts)
4094 + ret = new;
4095 ++ max = READ_ONCE(iter->ns->ucount_max[type]);
4096 + /*
4097 + * Grab an extra ucount reference for the caller when
4098 + * the rlimit count was previously 0.
4099 +@@ -333,15 +335,16 @@ unwind:
4100 + return 0;
4101 + }
4102 +
4103 +-bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsigned long max)
4104 ++bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsigned long rlimit)
4105 + {
4106 + struct ucounts *iter;
4107 +- if (get_ucounts_value(ucounts, type) > max)
4108 +- return true;
4109 ++ long max = rlimit;
4110 ++ if (rlimit > LONG_MAX)
4111 ++ max = LONG_MAX;
4112 + for (iter = ucounts; iter; iter = iter->ns->ucounts) {
4113 +- max = READ_ONCE(iter->ns->ucount_max[type]);
4114 + if (get_ucounts_value(iter, type) > max)
4115 + return true;
4116 ++ max = READ_ONCE(iter->ns->ucount_max[type]);
4117 + }
4118 + return false;
4119 + }
4120 +diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
4121 +index f94d19a690dfa..d3bc110430f9d 100644
4122 +--- a/mm/damon/dbgfs.c
4123 ++++ b/mm/damon/dbgfs.c
4124 +@@ -309,10 +309,12 @@ static int dbgfs_before_terminate(struct damon_ctx *ctx)
4125 + if (!targetid_is_pid(ctx))
4126 + return 0;
4127 +
4128 ++ mutex_lock(&ctx->kdamond_lock);
4129 + damon_for_each_target_safe(t, next, ctx) {
4130 + put_pid((struct pid *)t->id);
4131 + damon_destroy_target(t);
4132 + }
4133 ++ mutex_unlock(&ctx->kdamond_lock);
4134 + return 0;
4135 + }
4136 +
4137 +diff --git a/mm/kfence/core.c b/mm/kfence/core.c
4138 +index 4b69236aea722..84555b8233efc 100644
4139 +--- a/mm/kfence/core.c
4140 ++++ b/mm/kfence/core.c
4141 +@@ -578,6 +578,7 @@ static const struct file_operations objects_fops = {
4142 + .open = open_objects,
4143 + .read = seq_read,
4144 + .llseek = seq_lseek,
4145 ++ .release = seq_release,
4146 + };
4147 +
4148 + static int __init kfence_debugfs_init(void)
4149 +diff --git a/mm/memory-failure.c b/mm/memory-failure.c
4150 +index bdbbb32211a58..f66977a171966 100644
4151 +--- a/mm/memory-failure.c
4152 ++++ b/mm/memory-failure.c
4153 +@@ -1437,17 +1437,12 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags)
4154 + if (!(flags & MF_COUNT_INCREASED)) {
4155 + res = get_hwpoison_page(p, flags);
4156 + if (!res) {
4157 +- /*
4158 +- * Check "filter hit" and "race with other subpage."
4159 +- */
4160 + lock_page(head);
4161 +- if (PageHWPoison(head)) {
4162 +- if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
4163 +- || (p != head && TestSetPageHWPoison(head))) {
4164 ++ if (hwpoison_filter(p)) {
4165 ++ if (TestClearPageHWPoison(head))
4166 + num_poisoned_pages_dec();
4167 +- unlock_page(head);
4168 +- return 0;
4169 +- }
4170 ++ unlock_page(head);
4171 ++ return 0;
4172 + }
4173 + unlock_page(head);
4174 + res = MF_FAILED;
4175 +@@ -2206,6 +2201,7 @@ retry:
4176 + } else if (ret == 0) {
4177 + if (soft_offline_free_page(page) && try_again) {
4178 + try_again = false;
4179 ++ flags &= ~MF_COUNT_INCREASED;
4180 + goto retry;
4181 + }
4182 + }
4183 +diff --git a/mm/mempolicy.c b/mm/mempolicy.c
4184 +index d12e0608fced2..fa9ed9c98739a 100644
4185 +--- a/mm/mempolicy.c
4186 ++++ b/mm/mempolicy.c
4187 +@@ -2140,8 +2140,7 @@ struct page *alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma,
4188 + * memory with both reclaim and compact as well.
4189 + */
4190 + if (!page && (gfp & __GFP_DIRECT_RECLAIM))
4191 +- page = __alloc_pages_node(hpage_node,
4192 +- gfp, order);
4193 ++ page = __alloc_pages(gfp, order, hpage_node, nmask);
4194 +
4195 + goto out;
4196 + }
4197 +diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
4198 +index 2631efc6e359f..aa7785687e757 100644
4199 +--- a/net/ax25/af_ax25.c
4200 ++++ b/net/ax25/af_ax25.c
4201 +@@ -85,8 +85,10 @@ static void ax25_kill_by_device(struct net_device *dev)
4202 + again:
4203 + ax25_for_each(s, &ax25_list) {
4204 + if (s->ax25_dev == ax25_dev) {
4205 +- s->ax25_dev = NULL;
4206 + spin_unlock_bh(&ax25_list_lock);
4207 ++ lock_sock(s->sk);
4208 ++ s->ax25_dev = NULL;
4209 ++ release_sock(s->sk);
4210 + ax25_disconnect(s, ENETUNREACH);
4211 + spin_lock_bh(&ax25_list_lock);
4212 +
4213 +diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
4214 +index 793b0db9d9a36..9922497e59f8c 100644
4215 +--- a/net/bridge/br_ioctl.c
4216 ++++ b/net/bridge/br_ioctl.c
4217 +@@ -71,7 +71,8 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
4218 +
4219 + num = br_fdb_fillbuf(br, buf, maxnum, offset);
4220 + if (num > 0) {
4221 +- if (copy_to_user(userbuf, buf, num*sizeof(struct __fdb_entry)))
4222 ++ if (copy_to_user(userbuf, buf,
4223 ++ array_size(num, sizeof(struct __fdb_entry))))
4224 + num = -EFAULT;
4225 + }
4226 + kfree(buf);
4227 +@@ -188,7 +189,7 @@ int br_dev_siocdevprivate(struct net_device *dev, struct ifreq *rq, void __user
4228 + return -ENOMEM;
4229 +
4230 + get_port_ifindices(br, indices, num);
4231 +- if (copy_to_user(argp, indices, num * sizeof(int)))
4232 ++ if (copy_to_user(argp, indices, array_size(num, sizeof(int))))
4233 + num = -EFAULT;
4234 + kfree(indices);
4235 + return num;
4236 +@@ -336,7 +337,8 @@ static int old_deviceless(struct net *net, void __user *uarg)
4237 +
4238 + args[2] = get_bridge_ifindices(net, indices, args[2]);
4239 +
4240 +- ret = copy_to_user(uarg, indices, args[2]*sizeof(int))
4241 ++ ret = copy_to_user((void __user *)args[1], indices,
4242 ++ array_size(args[2], sizeof(int)))
4243 + ? -EFAULT : args[2];
4244 +
4245 + kfree(indices);
4246 +diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
4247 +index 64062b7ce61df..3a9422a5873eb 100644
4248 +--- a/net/ipv4/af_inet.c
4249 ++++ b/net/ipv4/af_inet.c
4250 +@@ -158,7 +158,7 @@ void inet_sock_destruct(struct sock *sk)
4251 +
4252 + kfree(rcu_dereference_protected(inet->inet_opt, 1));
4253 + dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1));
4254 +- dst_release(sk->sk_rx_dst);
4255 ++ dst_release(rcu_dereference_protected(sk->sk_rx_dst, 1));
4256 + sk_refcnt_debug_dec(sk);
4257 + }
4258 + EXPORT_SYMBOL(inet_sock_destruct);
4259 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
4260 +index 844c6e5a82891..f48f1059b31a6 100644
4261 +--- a/net/ipv4/tcp.c
4262 ++++ b/net/ipv4/tcp.c
4263 +@@ -3039,8 +3039,7 @@ int tcp_disconnect(struct sock *sk, int flags)
4264 + icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
4265 + memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
4266 + __sk_dst_reset(sk);
4267 +- dst_release(sk->sk_rx_dst);
4268 +- sk->sk_rx_dst = NULL;
4269 ++ dst_release(xchg((__force struct dst_entry **)&sk->sk_rx_dst, NULL));
4270 + tcp_saved_syn_free(tp);
4271 + tp->compressed_ack = 0;
4272 + tp->segs_in = 0;
4273 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
4274 +index 141e85e6422b1..f3b6239674361 100644
4275 +--- a/net/ipv4/tcp_input.c
4276 ++++ b/net/ipv4/tcp_input.c
4277 +@@ -5770,7 +5770,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
4278 + trace_tcp_probe(sk, skb);
4279 +
4280 + tcp_mstamp_refresh(tp);
4281 +- if (unlikely(!sk->sk_rx_dst))
4282 ++ if (unlikely(!rcu_access_pointer(sk->sk_rx_dst)))
4283 + inet_csk(sk)->icsk_af_ops->sk_rx_dst_set(sk, skb);
4284 + /*
4285 + * Header prediction.
4286 +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
4287 +index 5b8ce65dfc067..0fe9461647da5 100644
4288 +--- a/net/ipv4/tcp_ipv4.c
4289 ++++ b/net/ipv4/tcp_ipv4.c
4290 +@@ -1698,16 +1698,19 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
4291 + struct sock *rsk;
4292 +
4293 + if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
4294 +- struct dst_entry *dst = sk->sk_rx_dst;
4295 ++ struct dst_entry *dst;
4296 ++
4297 ++ dst = rcu_dereference_protected(sk->sk_rx_dst,
4298 ++ lockdep_sock_is_held(sk));
4299 +
4300 + sock_rps_save_rxhash(sk, skb);
4301 + sk_mark_napi_id(sk, skb);
4302 + if (dst) {
4303 +- if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||
4304 ++ if (sk->sk_rx_dst_ifindex != skb->skb_iif ||
4305 + !INDIRECT_CALL_1(dst->ops->check, ipv4_dst_check,
4306 + dst, 0)) {
4307 ++ RCU_INIT_POINTER(sk->sk_rx_dst, NULL);
4308 + dst_release(dst);
4309 +- sk->sk_rx_dst = NULL;
4310 + }
4311 + }
4312 + tcp_rcv_established(sk, skb);
4313 +@@ -1783,12 +1786,12 @@ int tcp_v4_early_demux(struct sk_buff *skb)
4314 + skb->sk = sk;
4315 + skb->destructor = sock_edemux;
4316 + if (sk_fullsock(sk)) {
4317 +- struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
4318 ++ struct dst_entry *dst = rcu_dereference(sk->sk_rx_dst);
4319 +
4320 + if (dst)
4321 + dst = dst_check(dst, 0);
4322 + if (dst &&
4323 +- inet_sk(sk)->rx_dst_ifindex == skb->skb_iif)
4324 ++ sk->sk_rx_dst_ifindex == skb->skb_iif)
4325 + skb_dst_set_noref(skb, dst);
4326 + }
4327 + }
4328 +@@ -2200,8 +2203,8 @@ void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
4329 + struct dst_entry *dst = skb_dst(skb);
4330 +
4331 + if (dst && dst_hold_safe(dst)) {
4332 +- sk->sk_rx_dst = dst;
4333 +- inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
4334 ++ rcu_assign_pointer(sk->sk_rx_dst, dst);
4335 ++ sk->sk_rx_dst_ifindex = skb->skb_iif;
4336 + }
4337 + }
4338 + EXPORT_SYMBOL(inet_sk_rx_dst_set);
4339 +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
4340 +index 3f6823bdd31e5..be07e3d2b77bc 100644
4341 +--- a/net/ipv4/udp.c
4342 ++++ b/net/ipv4/udp.c
4343 +@@ -2251,7 +2251,7 @@ bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
4344 + struct dst_entry *old;
4345 +
4346 + if (dst_hold_safe(dst)) {
4347 +- old = xchg(&sk->sk_rx_dst, dst);
4348 ++ old = xchg((__force struct dst_entry **)&sk->sk_rx_dst, dst);
4349 + dst_release(old);
4350 + return old != dst;
4351 + }
4352 +@@ -2441,7 +2441,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
4353 + struct dst_entry *dst = skb_dst(skb);
4354 + int ret;
4355 +
4356 +- if (unlikely(sk->sk_rx_dst != dst))
4357 ++ if (unlikely(rcu_dereference(sk->sk_rx_dst) != dst))
4358 + udp_sk_rx_dst_set(sk, dst);
4359 +
4360 + ret = udp_unicast_rcv_skb(sk, skb, uh);
4361 +@@ -2600,7 +2600,7 @@ int udp_v4_early_demux(struct sk_buff *skb)
4362 +
4363 + skb->sk = sk;
4364 + skb->destructor = sock_efree;
4365 +- dst = READ_ONCE(sk->sk_rx_dst);
4366 ++ dst = rcu_dereference(sk->sk_rx_dst);
4367 +
4368 + if (dst)
4369 + dst = dst_check(dst, 0);
4370 +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
4371 +index b03dd02c9f13c..8eedf59e9cf25 100644
4372 +--- a/net/ipv6/tcp_ipv6.c
4373 ++++ b/net/ipv6/tcp_ipv6.c
4374 +@@ -107,9 +107,9 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
4375 + if (dst && dst_hold_safe(dst)) {
4376 + const struct rt6_info *rt = (const struct rt6_info *)dst;
4377 +
4378 +- sk->sk_rx_dst = dst;
4379 +- inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
4380 +- tcp_inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
4381 ++ rcu_assign_pointer(sk->sk_rx_dst, dst);
4382 ++ sk->sk_rx_dst_ifindex = skb->skb_iif;
4383 ++ sk->sk_rx_dst_cookie = rt6_get_cookie(rt);
4384 + }
4385 + }
4386 +
4387 +@@ -1504,16 +1504,19 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
4388 + opt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));
4389 +
4390 + if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
4391 +- struct dst_entry *dst = sk->sk_rx_dst;
4392 ++ struct dst_entry *dst;
4393 ++
4394 ++ dst = rcu_dereference_protected(sk->sk_rx_dst,
4395 ++ lockdep_sock_is_held(sk));
4396 +
4397 + sock_rps_save_rxhash(sk, skb);
4398 + sk_mark_napi_id(sk, skb);
4399 + if (dst) {
4400 +- if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||
4401 ++ if (sk->sk_rx_dst_ifindex != skb->skb_iif ||
4402 + INDIRECT_CALL_1(dst->ops->check, ip6_dst_check,
4403 +- dst, np->rx_dst_cookie) == NULL) {
4404 ++ dst, sk->sk_rx_dst_cookie) == NULL) {
4405 ++ RCU_INIT_POINTER(sk->sk_rx_dst, NULL);
4406 + dst_release(dst);
4407 +- sk->sk_rx_dst = NULL;
4408 + }
4409 + }
4410 +
4411 +@@ -1875,12 +1878,12 @@ INDIRECT_CALLABLE_SCOPE void tcp_v6_early_demux(struct sk_buff *skb)
4412 + skb->sk = sk;
4413 + skb->destructor = sock_edemux;
4414 + if (sk_fullsock(sk)) {
4415 +- struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
4416 ++ struct dst_entry *dst = rcu_dereference(sk->sk_rx_dst);
4417 +
4418 + if (dst)
4419 +- dst = dst_check(dst, tcp_inet6_sk(sk)->rx_dst_cookie);
4420 ++ dst = dst_check(dst, sk->sk_rx_dst_cookie);
4421 + if (dst &&
4422 +- inet_sk(sk)->rx_dst_ifindex == skb->skb_iif)
4423 ++ sk->sk_rx_dst_ifindex == skb->skb_iif)
4424 + skb_dst_set_noref(skb, dst);
4425 + }
4426 + }
4427 +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
4428 +index be6dc64ece29f..7bee95d8d2df0 100644
4429 +--- a/net/ipv6/udp.c
4430 ++++ b/net/ipv6/udp.c
4431 +@@ -884,7 +884,7 @@ static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
4432 + if (udp_sk_rx_dst_set(sk, dst)) {
4433 + const struct rt6_info *rt = (const struct rt6_info *)dst;
4434 +
4435 +- inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
4436 ++ sk->sk_rx_dst_cookie = rt6_get_cookie(rt);
4437 + }
4438 + }
4439 +
4440 +@@ -956,7 +956,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
4441 + struct dst_entry *dst = skb_dst(skb);
4442 + int ret;
4443 +
4444 +- if (unlikely(sk->sk_rx_dst != dst))
4445 ++ if (unlikely(rcu_dereference(sk->sk_rx_dst) != dst))
4446 + udp6_sk_rx_dst_set(sk, dst);
4447 +
4448 + if (!uh->check && !udp_sk(sk)->no_check6_rx) {
4449 +@@ -1070,10 +1070,10 @@ INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb)
4450 +
4451 + skb->sk = sk;
4452 + skb->destructor = sock_efree;
4453 +- dst = READ_ONCE(sk->sk_rx_dst);
4454 ++ dst = rcu_dereference(sk->sk_rx_dst);
4455 +
4456 + if (dst)
4457 +- dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);
4458 ++ dst = dst_check(dst, sk->sk_rx_dst_cookie);
4459 + if (dst) {
4460 + /* set noref for now.
4461 + * any place which wants to hold dst has to call
4462 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
4463 +index d3f62fd12f0b5..1bf83b8d84021 100644
4464 +--- a/net/mac80211/cfg.c
4465 ++++ b/net/mac80211/cfg.c
4466 +@@ -1226,7 +1226,10 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
4467 + return 0;
4468 +
4469 + error:
4470 ++ mutex_lock(&local->mtx);
4471 + ieee80211_vif_release_channel(sdata);
4472 ++ mutex_unlock(&local->mtx);
4473 ++
4474 + return err;
4475 + }
4476 +
4477 +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
4478 +index c0851fec11d46..c207728226372 100644
4479 +--- a/net/netfilter/nf_tables_api.c
4480 ++++ b/net/netfilter/nf_tables_api.c
4481 +@@ -4481,9 +4481,9 @@ struct nft_set_elem_catchall {
4482 + static void nft_set_catchall_destroy(const struct nft_ctx *ctx,
4483 + struct nft_set *set)
4484 + {
4485 +- struct nft_set_elem_catchall *catchall;
4486 ++ struct nft_set_elem_catchall *next, *catchall;
4487 +
4488 +- list_for_each_entry_rcu(catchall, &set->catchall_list, list) {
4489 ++ list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
4490 + list_del_rcu(&catchall->list);
4491 + nft_set_elem_destroy(set, catchall->elem, true);
4492 + kfree_rcu(catchall);
4493 +diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
4494 +index 691ef4cffdd90..7f83f9697fc14 100644
4495 +--- a/net/netfilter/nfnetlink_log.c
4496 ++++ b/net/netfilter/nfnetlink_log.c
4497 +@@ -556,7 +556,8 @@ __build_packet_message(struct nfnl_log_net *log,
4498 + goto nla_put_failure;
4499 +
4500 + if (indev && skb->dev &&
4501 +- skb->mac_header != skb->network_header) {
4502 ++ skb_mac_header_was_set(skb) &&
4503 ++ skb_mac_header_len(skb) != 0) {
4504 + struct nfulnl_msg_packet_hw phw;
4505 + int len;
4506 +
4507 +diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
4508 +index 4acc4b8e9fe5a..959527708e382 100644
4509 +--- a/net/netfilter/nfnetlink_queue.c
4510 ++++ b/net/netfilter/nfnetlink_queue.c
4511 +@@ -560,7 +560,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
4512 + goto nla_put_failure;
4513 +
4514 + if (indev && entskb->dev &&
4515 +- skb_mac_header_was_set(entskb)) {
4516 ++ skb_mac_header_was_set(entskb) &&
4517 ++ skb_mac_header_len(entskb) != 0) {
4518 + struct nfqnl_msg_packet_hw phw;
4519 + int len;
4520 +
4521 +diff --git a/net/phonet/pep.c b/net/phonet/pep.c
4522 +index a1525916885ae..72018e5e4d8ef 100644
4523 +--- a/net/phonet/pep.c
4524 ++++ b/net/phonet/pep.c
4525 +@@ -946,6 +946,8 @@ static int pep_ioctl(struct sock *sk, int cmd, unsigned long arg)
4526 + ret = -EBUSY;
4527 + else if (sk->sk_state == TCP_ESTABLISHED)
4528 + ret = -EISCONN;
4529 ++ else if (!pn->pn_sk.sobject)
4530 ++ ret = -EADDRNOTAVAIL;
4531 + else
4532 + ret = pep_sock_enable(sk, NULL, 0);
4533 + release_sock(sk);
4534 +diff --git a/sound/core/jack.c b/sound/core/jack.c
4535 +index 32350c6aba849..537df1e98f8ac 100644
4536 +--- a/sound/core/jack.c
4537 ++++ b/sound/core/jack.c
4538 +@@ -509,6 +509,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
4539 + return -ENOMEM;
4540 +
4541 + jack->id = kstrdup(id, GFP_KERNEL);
4542 ++ if (jack->id == NULL) {
4543 ++ kfree(jack);
4544 ++ return -ENOMEM;
4545 ++ }
4546 +
4547 + /* don't creat input device for phantom jack */
4548 + if (!phantom_jack) {
4549 +diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
4550 +index 6f30231bdb884..befa9809ff001 100644
4551 +--- a/sound/core/rawmidi.c
4552 ++++ b/sound/core/rawmidi.c
4553 +@@ -447,6 +447,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
4554 + err = -ENOMEM;
4555 + goto __error;
4556 + }
4557 ++ rawmidi_file->user_pversion = 0;
4558 + init_waitqueue_entry(&wait, current);
4559 + add_wait_queue(&rmidi->open_wait, &wait);
4560 + while (1) {
4561 +diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c
4562 +index e1b69c65c3c88..e2b7be67f0e30 100644
4563 +--- a/sound/drivers/opl3/opl3_midi.c
4564 ++++ b/sound/drivers/opl3/opl3_midi.c
4565 +@@ -397,7 +397,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
4566 + }
4567 + if (instr_4op) {
4568 + vp2 = &opl3->voices[voice + 3];
4569 +- if (vp->state > 0) {
4570 ++ if (vp2->state > 0) {
4571 + opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK +
4572 + voice_offset + 3);
4573 + reg_val = vp->keyon_reg & ~OPL3_KEYON_BIT;
4574 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
4575 +index 415701bd10ac8..ffcde7409d2a5 100644
4576 +--- a/sound/pci/hda/patch_hdmi.c
4577 ++++ b/sound/pci/hda/patch_hdmi.c
4578 +@@ -2947,7 +2947,8 @@ static int parse_intel_hdmi(struct hda_codec *codec)
4579 +
4580 + /* Intel Haswell and onwards; audio component with eld notifier */
4581 + static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
4582 +- const int *port_map, int port_num, int dev_num)
4583 ++ const int *port_map, int port_num, int dev_num,
4584 ++ bool send_silent_stream)
4585 + {
4586 + struct hdmi_spec *spec;
4587 + int err;
4588 +@@ -2980,7 +2981,7 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
4589 + * Enable silent stream feature, if it is enabled via
4590 + * module param or Kconfig option
4591 + */
4592 +- if (enable_silent_stream)
4593 ++ if (send_silent_stream)
4594 + spec->send_silent_stream = true;
4595 +
4596 + return parse_intel_hdmi(codec);
4597 +@@ -2988,12 +2989,18 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
4598 +
4599 + static int patch_i915_hsw_hdmi(struct hda_codec *codec)
4600 + {
4601 +- return intel_hsw_common_init(codec, 0x08, NULL, 0, 3);
4602 ++ return intel_hsw_common_init(codec, 0x08, NULL, 0, 3,
4603 ++ enable_silent_stream);
4604 + }
4605 +
4606 + static int patch_i915_glk_hdmi(struct hda_codec *codec)
4607 + {
4608 +- return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3);
4609 ++ /*
4610 ++ * Silent stream calls audio component .get_power() from
4611 ++ * .pin_eld_notify(). On GLK this will deadlock in i915 due
4612 ++ * to the audio vs. CDCLK workaround.
4613 ++ */
4614 ++ return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false);
4615 + }
4616 +
4617 + static int patch_i915_icl_hdmi(struct hda_codec *codec)
4618 +@@ -3004,7 +3011,8 @@ static int patch_i915_icl_hdmi(struct hda_codec *codec)
4619 + */
4620 + static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb};
4621 +
4622 +- return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3);
4623 ++ return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3,
4624 ++ enable_silent_stream);
4625 + }
4626 +
4627 + static int patch_i915_tgl_hdmi(struct hda_codec *codec)
4628 +@@ -3016,7 +3024,8 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec)
4629 + static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
4630 + int ret;
4631 +
4632 +- ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4);
4633 ++ ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4,
4634 ++ enable_silent_stream);
4635 + if (!ret) {
4636 + struct hdmi_spec *spec = codec->spec;
4637 +
4638 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4639 +index 3599f4c85ebf7..28255e752c4a1 100644
4640 +--- a/sound/pci/hda/patch_realtek.c
4641 ++++ b/sound/pci/hda/patch_realtek.c
4642 +@@ -6546,6 +6546,23 @@ static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
4643 + alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
4644 + }
4645 +
4646 ++static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
4647 ++ const struct hda_fixup *fix,
4648 ++ int action)
4649 ++{
4650 ++ /*
4651 ++ * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
4652 ++ * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
4653 ++ * needs an additional quirk for sound working after suspend and resume.
4654 ++ */
4655 ++ if (codec->core.vendor_id == 0x10ec0256) {
4656 ++ alc_update_coef_idx(codec, 0x10, 1<<9, 0);
4657 ++ snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
4658 ++ } else {
4659 ++ snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
4660 ++ }
4661 ++}
4662 ++
4663 + enum {
4664 + ALC269_FIXUP_GPIO2,
4665 + ALC269_FIXUP_SONY_VAIO,
4666 +@@ -6766,6 +6783,7 @@ enum {
4667 + ALC256_FIXUP_SET_COEF_DEFAULTS,
4668 + ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
4669 + ALC233_FIXUP_NO_AUDIO_JACK,
4670 ++ ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME,
4671 + };
4672 +
4673 + static const struct hda_fixup alc269_fixups[] = {
4674 +@@ -8490,6 +8508,12 @@ static const struct hda_fixup alc269_fixups[] = {
4675 + .type = HDA_FIXUP_FUNC,
4676 + .v.func = alc233_fixup_no_audio_jack,
4677 + },
4678 ++ [ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = {
4679 ++ .type = HDA_FIXUP_FUNC,
4680 ++ .v.func = alc256_fixup_mic_no_presence_and_resume,
4681 ++ .chained = true,
4682 ++ .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4683 ++ },
4684 + };
4685 +
4686 + static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4687 +@@ -8660,6 +8684,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4688 + SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
4689 + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
4690 + SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
4691 ++ SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
4692 + SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
4693 + SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
4694 + SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
4695 +@@ -8705,6 +8730,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4696 + SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
4697 + SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
4698 + SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
4699 ++ SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
4700 + SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
4701 + SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
4702 + SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4703 +@@ -8829,7 +8855,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4704 + SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
4705 + SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4706 + SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4707 +- SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4708 ++ SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME),
4709 + SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4710 + SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4711 + SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
4712 +@@ -9123,6 +9149,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
4713 + {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
4714 + {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
4715 + {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
4716 ++ {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
4717 + {}
4718 + };
4719 + #define ALC225_STANDARD_PINS \
4720 +diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
4721 +index 5ac2b1444694d..757d1362b5f48 100644
4722 +--- a/sound/soc/codecs/rt5682.c
4723 ++++ b/sound/soc/codecs/rt5682.c
4724 +@@ -927,6 +927,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
4725 + unsigned int val, count;
4726 +
4727 + if (jack_insert) {
4728 ++ snd_soc_dapm_mutex_lock(dapm);
4729 ++
4730 + snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
4731 + RT5682_PWR_VREF2 | RT5682_PWR_MB,
4732 + RT5682_PWR_VREF2 | RT5682_PWR_MB);
4733 +@@ -973,6 +975,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
4734 + snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
4735 + RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
4736 + RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
4737 ++
4738 ++ snd_soc_dapm_mutex_unlock(dapm);
4739 + } else {
4740 + rt5682_enable_push_button_irq(component, false);
4741 + snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
4742 +diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c
4743 +index 172e79cbe0daf..6549e7fef3e32 100644
4744 +--- a/sound/soc/codecs/tas2770.c
4745 ++++ b/sound/soc/codecs/tas2770.c
4746 +@@ -291,11 +291,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
4747 + ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
4748 + TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
4749 + break;
4750 +- case 19200:
4751 ++ case 192000:
4752 + ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
4753 + TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
4754 + break;
4755 +- case 17640:
4756 ++ case 176400:
4757 + ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
4758 + TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
4759 + break;
4760 +diff --git a/sound/soc/meson/aiu-encoder-i2s.c b/sound/soc/meson/aiu-encoder-i2s.c
4761 +index 9322245521463..67729de41a73e 100644
4762 +--- a/sound/soc/meson/aiu-encoder-i2s.c
4763 ++++ b/sound/soc/meson/aiu-encoder-i2s.c
4764 +@@ -18,7 +18,6 @@
4765 + #define AIU_RST_SOFT_I2S_FAST BIT(0)
4766 +
4767 + #define AIU_I2S_DAC_CFG_MSB_FIRST BIT(2)
4768 +-#define AIU_I2S_MISC_HOLD_EN BIT(2)
4769 + #define AIU_CLK_CTRL_I2S_DIV_EN BIT(0)
4770 + #define AIU_CLK_CTRL_I2S_DIV GENMASK(3, 2)
4771 + #define AIU_CLK_CTRL_AOCLK_INVERT BIT(6)
4772 +@@ -36,37 +35,6 @@ static void aiu_encoder_i2s_divider_enable(struct snd_soc_component *component,
4773 + enable ? AIU_CLK_CTRL_I2S_DIV_EN : 0);
4774 + }
4775 +
4776 +-static void aiu_encoder_i2s_hold(struct snd_soc_component *component,
4777 +- bool enable)
4778 +-{
4779 +- snd_soc_component_update_bits(component, AIU_I2S_MISC,
4780 +- AIU_I2S_MISC_HOLD_EN,
4781 +- enable ? AIU_I2S_MISC_HOLD_EN : 0);
4782 +-}
4783 +-
4784 +-static int aiu_encoder_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
4785 +- struct snd_soc_dai *dai)
4786 +-{
4787 +- struct snd_soc_component *component = dai->component;
4788 +-
4789 +- switch (cmd) {
4790 +- case SNDRV_PCM_TRIGGER_START:
4791 +- case SNDRV_PCM_TRIGGER_RESUME:
4792 +- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
4793 +- aiu_encoder_i2s_hold(component, false);
4794 +- return 0;
4795 +-
4796 +- case SNDRV_PCM_TRIGGER_STOP:
4797 +- case SNDRV_PCM_TRIGGER_SUSPEND:
4798 +- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
4799 +- aiu_encoder_i2s_hold(component, true);
4800 +- return 0;
4801 +-
4802 +- default:
4803 +- return -EINVAL;
4804 +- }
4805 +-}
4806 +-
4807 + static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component,
4808 + struct snd_pcm_hw_params *params)
4809 + {
4810 +@@ -353,7 +321,6 @@ static void aiu_encoder_i2s_shutdown(struct snd_pcm_substream *substream,
4811 + }
4812 +
4813 + const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops = {
4814 +- .trigger = aiu_encoder_i2s_trigger,
4815 + .hw_params = aiu_encoder_i2s_hw_params,
4816 + .hw_free = aiu_encoder_i2s_hw_free,
4817 + .set_fmt = aiu_encoder_i2s_set_fmt,
4818 +diff --git a/sound/soc/meson/aiu-fifo-i2s.c b/sound/soc/meson/aiu-fifo-i2s.c
4819 +index 2388a2d0b3a6c..57e6e7160d2f2 100644
4820 +--- a/sound/soc/meson/aiu-fifo-i2s.c
4821 ++++ b/sound/soc/meson/aiu-fifo-i2s.c
4822 +@@ -20,6 +20,8 @@
4823 + #define AIU_MEM_I2S_CONTROL_MODE_16BIT BIT(6)
4824 + #define AIU_MEM_I2S_BUF_CNTL_INIT BIT(0)
4825 + #define AIU_RST_SOFT_I2S_FAST BIT(0)
4826 ++#define AIU_I2S_MISC_HOLD_EN BIT(2)
4827 ++#define AIU_I2S_MISC_FORCE_LEFT_RIGHT BIT(4)
4828 +
4829 + #define AIU_FIFO_I2S_BLOCK 256
4830 +
4831 +@@ -90,6 +92,10 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
4832 + unsigned int val;
4833 + int ret;
4834 +
4835 ++ snd_soc_component_update_bits(component, AIU_I2S_MISC,
4836 ++ AIU_I2S_MISC_HOLD_EN,
4837 ++ AIU_I2S_MISC_HOLD_EN);
4838 ++
4839 + ret = aiu_fifo_hw_params(substream, params, dai);
4840 + if (ret)
4841 + return ret;
4842 +@@ -117,6 +123,19 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
4843 + snd_soc_component_update_bits(component, AIU_MEM_I2S_MASKS,
4844 + AIU_MEM_I2S_MASKS_IRQ_BLOCK, val);
4845 +
4846 ++ /*
4847 ++ * Most (all?) supported SoCs have this bit set by default. The vendor
4848 ++ * driver however sets it manually (depending on the version either
4849 ++ * while un-setting AIU_I2S_MISC_HOLD_EN or right before that). Follow
4850 ++ * the same approach for consistency with the vendor driver.
4851 ++ */
4852 ++ snd_soc_component_update_bits(component, AIU_I2S_MISC,
4853 ++ AIU_I2S_MISC_FORCE_LEFT_RIGHT,
4854 ++ AIU_I2S_MISC_FORCE_LEFT_RIGHT);
4855 ++
4856 ++ snd_soc_component_update_bits(component, AIU_I2S_MISC,
4857 ++ AIU_I2S_MISC_HOLD_EN, 0);
4858 ++
4859 + return 0;
4860 + }
4861 +
4862 +diff --git a/sound/soc/meson/aiu-fifo.c b/sound/soc/meson/aiu-fifo.c
4863 +index 4ad23267cace5..d67ff4cdabd5a 100644
4864 +--- a/sound/soc/meson/aiu-fifo.c
4865 ++++ b/sound/soc/meson/aiu-fifo.c
4866 +@@ -5,6 +5,7 @@
4867 +
4868 + #include <linux/bitfield.h>
4869 + #include <linux/clk.h>
4870 ++#include <linux/dma-mapping.h>
4871 + #include <sound/pcm_params.h>
4872 + #include <sound/soc.h>
4873 + #include <sound/soc-dai.h>
4874 +@@ -179,6 +180,11 @@ int aiu_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd,
4875 + struct snd_card *card = rtd->card->snd_card;
4876 + struct aiu_fifo *fifo = dai->playback_dma_data;
4877 + size_t size = fifo->pcm->buffer_bytes_max;
4878 ++ int ret;
4879 ++
4880 ++ ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
4881 ++ if (ret)
4882 ++ return ret;
4883 +
4884 + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
4885 + card->dev, size, size);
4886 +diff --git a/sound/soc/sof/intel/pci-tgl.c b/sound/soc/sof/intel/pci-tgl.c
4887 +index d04ce84fe7cc2..beb2fb3cd0141 100644
4888 +--- a/sound/soc/sof/intel/pci-tgl.c
4889 ++++ b/sound/soc/sof/intel/pci-tgl.c
4890 +@@ -117,8 +117,12 @@ static const struct pci_device_id sof_pci_ids[] = {
4891 + .driver_data = (unsigned long)&adls_desc},
4892 + { PCI_DEVICE(0x8086, 0x51c8), /* ADL-P */
4893 + .driver_data = (unsigned long)&adl_desc},
4894 ++ { PCI_DEVICE(0x8086, 0x51cd), /* ADL-P */
4895 ++ .driver_data = (unsigned long)&adl_desc},
4896 + { PCI_DEVICE(0x8086, 0x51cc), /* ADL-M */
4897 + .driver_data = (unsigned long)&adl_desc},
4898 ++ { PCI_DEVICE(0x8086, 0x54c8), /* ADL-N */
4899 ++ .driver_data = (unsigned long)&adl_desc},
4900 + { 0, }
4901 + };
4902 + MODULE_DEVICE_TABLE(pci, sof_pci_ids);
4903 +diff --git a/sound/soc/tegra/tegra_asoc_machine.c b/sound/soc/tegra/tegra_asoc_machine.c
4904 +index 78fb423df550b..2e549b69061ca 100644
4905 +--- a/sound/soc/tegra/tegra_asoc_machine.c
4906 ++++ b/sound/soc/tegra/tegra_asoc_machine.c
4907 +@@ -116,16 +116,24 @@ static const struct snd_kcontrol_new tegra_machine_controls[] = {
4908 + SOC_DAPM_PIN_SWITCH("Headset Mic"),
4909 + SOC_DAPM_PIN_SWITCH("Internal Mic 1"),
4910 + SOC_DAPM_PIN_SWITCH("Internal Mic 2"),
4911 ++ SOC_DAPM_PIN_SWITCH("Headphones"),
4912 ++ SOC_DAPM_PIN_SWITCH("Mic Jack"),
4913 + };
4914 +
4915 + int tegra_asoc_machine_init(struct snd_soc_pcm_runtime *rtd)
4916 + {
4917 + struct snd_soc_card *card = rtd->card;
4918 + struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
4919 ++ const char *jack_name;
4920 + int err;
4921 +
4922 + if (machine->gpiod_hp_det && machine->asoc->add_hp_jack) {
4923 +- err = snd_soc_card_jack_new(card, "Headphones Jack",
4924 ++ if (machine->asoc->hp_jack_name)
4925 ++ jack_name = machine->asoc->hp_jack_name;
4926 ++ else
4927 ++ jack_name = "Headphones Jack";
4928 ++
4929 ++ err = snd_soc_card_jack_new(card, jack_name,
4930 + SND_JACK_HEADPHONE,
4931 + &tegra_machine_hp_jack,
4932 + tegra_machine_hp_jack_pins,
4933 +@@ -658,6 +666,7 @@ static struct snd_soc_card snd_soc_tegra_max98090 = {
4934 + static const struct tegra_asoc_data tegra_max98090_data = {
4935 + .mclk_rate = tegra_machine_mclk_rate_12mhz,
4936 + .card = &snd_soc_tegra_max98090,
4937 ++ .hp_jack_name = "Headphones",
4938 + .add_common_dapm_widgets = true,
4939 + .add_common_controls = true,
4940 + .add_common_snd_ops = true,
4941 +diff --git a/sound/soc/tegra/tegra_asoc_machine.h b/sound/soc/tegra/tegra_asoc_machine.h
4942 +index d6a8d13205516..6f795d7dff7c1 100644
4943 +--- a/sound/soc/tegra/tegra_asoc_machine.h
4944 ++++ b/sound/soc/tegra/tegra_asoc_machine.h
4945 +@@ -14,6 +14,7 @@ struct snd_soc_pcm_runtime;
4946 + struct tegra_asoc_data {
4947 + unsigned int (*mclk_rate)(unsigned int srate);
4948 + const char *codec_dev_name;
4949 ++ const char *hp_jack_name;
4950 + struct snd_soc_card *card;
4951 + unsigned int mclk_id;
4952 + bool hp_jack_gpio_active_low;
4953 +diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
4954 +index 35314277fb586..1876d148ea0ae 100644
4955 +--- a/tools/testing/selftests/kvm/include/kvm_util.h
4956 ++++ b/tools/testing/selftests/kvm/include/kvm_util.h
4957 +@@ -69,15 +69,6 @@ enum vm_guest_mode {
4958 +
4959 + #endif
4960 +
4961 +-#if defined(__x86_64__)
4962 +-unsigned long vm_compute_max_gfn(struct kvm_vm *vm);
4963 +-#else
4964 +-static inline unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
4965 +-{
4966 +- return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
4967 +-}
4968 +-#endif
4969 +-
4970 + #define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT)
4971 + #define PTES_PER_MIN_PAGE ptes_per_page(MIN_PAGE_SIZE)
4972 +
4973 +@@ -318,6 +309,7 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm);
4974 +
4975 + unsigned int vm_get_page_size(struct kvm_vm *vm);
4976 + unsigned int vm_get_page_shift(struct kvm_vm *vm);
4977 ++unsigned long vm_compute_max_gfn(struct kvm_vm *vm);
4978 + uint64_t vm_get_max_gfn(struct kvm_vm *vm);
4979 + int vm_get_fd(struct kvm_vm *vm);
4980 +
4981 +diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
4982 +index c439fb653fde2..e9d0ab9567fbf 100644
4983 +--- a/tools/testing/selftests/kvm/lib/kvm_util.c
4984 ++++ b/tools/testing/selftests/kvm/lib/kvm_util.c
4985 +@@ -2282,6 +2282,11 @@ unsigned int vm_get_page_shift(struct kvm_vm *vm)
4986 + return vm->page_shift;
4987 + }
4988 +
4989 ++unsigned long __attribute__((weak)) vm_compute_max_gfn(struct kvm_vm *vm)
4990 ++{
4991 ++ return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
4992 ++}
4993 ++
4994 + uint64_t vm_get_max_gfn(struct kvm_vm *vm)
4995 + {
4996 + return vm->max_gfn;