Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.10 commit in: /
Date: Sun, 30 Oct 2022 09:33:13
Message-Id: 1667122373.44b00d2dfe78ec70b2cd9efa0b1a8865c2ab9b00.mpagano@gentoo
1 commit: 44b00d2dfe78ec70b2cd9efa0b1a8865c2ab9b00
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 30 09:32:53 2022 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 30 09:32:53 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=44b00d2d
7
8 Linux patch 5.10.152
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1151_linux-5.10.152.patch | 3209 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 3213 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 9f9c67d6..2d158649 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -647,6 +647,10 @@ Patch: 1150_linux-5.10.151.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.10.151
23
24 +Patch: 1151_linux-5.10.152.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.10.152
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/1151_linux-5.10.152.patch b/1151_linux-5.10.152.patch
33 new file mode 100644
34 index 00000000..e772b821
35 --- /dev/null
36 +++ b/1151_linux-5.10.152.patch
37 @@ -0,0 +1,3209 @@
38 +diff --git a/Documentation/arm64/silicon-errata.rst b/Documentation/arm64/silicon-errata.rst
39 +index 22a07c208fee0..4f3206495217c 100644
40 +--- a/Documentation/arm64/silicon-errata.rst
41 ++++ b/Documentation/arm64/silicon-errata.rst
42 +@@ -76,10 +76,14 @@ stable kernels.
43 + +----------------+-----------------+-----------------+-----------------------------+
44 + | ARM | Cortex-A57 | #1319537 | ARM64_ERRATUM_1319367 |
45 + +----------------+-----------------+-----------------+-----------------------------+
46 ++| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 |
47 +++----------------+-----------------+-----------------+-----------------------------+
48 + | ARM | Cortex-A72 | #853709 | N/A |
49 + +----------------+-----------------+-----------------+-----------------------------+
50 + | ARM | Cortex-A72 | #1319367 | ARM64_ERRATUM_1319367 |
51 + +----------------+-----------------+-----------------+-----------------------------+
52 ++| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 |
53 +++----------------+-----------------+-----------------+-----------------------------+
54 + | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 |
55 + +----------------+-----------------+-----------------+-----------------------------+
56 + | ARM | Cortex-A76 | #1188873,1418040| ARM64_ERRATUM_1418040 |
57 +diff --git a/Makefile b/Makefile
58 +index 0e22d4c8bc79b..a0750d0519820 100644
59 +--- a/Makefile
60 ++++ b/Makefile
61 +@@ -1,7 +1,7 @@
62 + # SPDX-License-Identifier: GPL-2.0
63 + VERSION = 5
64 + PATCHLEVEL = 10
65 +-SUBLEVEL = 151
66 ++SUBLEVEL = 152
67 + EXTRAVERSION =
68 + NAME = Dare mighty things
69 +
70 +@@ -842,7 +842,9 @@ else
71 + DEBUG_CFLAGS += -g
72 + endif
73 +
74 +-ifneq ($(LLVM_IAS),1)
75 ++ifeq ($(LLVM_IAS),1)
76 ++KBUILD_AFLAGS += -g
77 ++else
78 + KBUILD_AFLAGS += -Wa,-gdwarf-2
79 + endif
80 +
81 +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
82 +index af65ab83e63d4..34bd4cba81e66 100644
83 +--- a/arch/arm64/Kconfig
84 ++++ b/arch/arm64/Kconfig
85 +@@ -481,6 +481,22 @@ config ARM64_ERRATUM_834220
86 +
87 + If unsure, say Y.
88 +
89 ++config ARM64_ERRATUM_1742098
90 ++ bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence"
91 ++ depends on COMPAT
92 ++ default y
93 ++ help
94 ++ This option removes the AES hwcap for aarch32 user-space to
95 ++ workaround erratum 1742098 on Cortex-A57 and Cortex-A72.
96 ++
97 ++ Affected parts may corrupt the AES state if an interrupt is
98 ++ taken between a pair of AES instructions. These instructions
99 ++ are only present if the cryptography extensions are present.
100 ++ All software should have a fallback implementation for CPUs
101 ++ that don't implement the cryptography extensions.
102 ++
103 ++ If unsure, say Y.
104 ++
105 + config ARM64_ERRATUM_845719
106 + bool "Cortex-A53: 845719: a load might read incorrect data"
107 + depends on COMPAT
108 +diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lte-sku.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lte-sku.dtsi
109 +index 44956e3165a16..469aad4e5948c 100644
110 +--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lte-sku.dtsi
111 ++++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lte-sku.dtsi
112 +@@ -9,6 +9,10 @@
113 + label = "proximity-wifi-lte";
114 + };
115 +
116 ++&mpss_mem {
117 ++ reg = <0x0 0x86000000 0x0 0x8c00000>;
118 ++};
119 ++
120 + &remoteproc_mpss {
121 + firmware-name = "qcom/sc7180-trogdor/modem/mba.mbn",
122 + "qcom/sc7180-trogdor/modem/qdsp6sw.mbn";
123 +diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
124 +index 5b2a616c6257b..cb2c47f13a8a4 100644
125 +--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
126 ++++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
127 +@@ -39,7 +39,7 @@
128 + };
129 +
130 + mpss_mem: memory@86000000 {
131 +- reg = <0x0 0x86000000 0x0 0x8c00000>;
132 ++ reg = <0x0 0x86000000 0x0 0x2000000>;
133 + no-map;
134 + };
135 +
136 +diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h
137 +index 53030d3c03a2c..d2080a41f6e6f 100644
138 +--- a/arch/arm64/include/asm/cpucaps.h
139 ++++ b/arch/arm64/include/asm/cpucaps.h
140 +@@ -68,7 +68,8 @@
141 + #define ARM64_WORKAROUND_1508412 58
142 + #define ARM64_SPECTRE_BHB 59
143 + #define ARM64_WORKAROUND_2457168 60
144 ++#define ARM64_WORKAROUND_1742098 61
145 +
146 +-#define ARM64_NCAPS 61
147 ++#define ARM64_NCAPS 62
148 +
149 + #endif /* __ASM_CPUCAPS_H */
150 +diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
151 +index aaacca6fd52f6..5d6f19bc628c2 100644
152 +--- a/arch/arm64/kernel/cpu_errata.c
153 ++++ b/arch/arm64/kernel/cpu_errata.c
154 +@@ -356,6 +356,14 @@ static const struct midr_range erratum_1463225[] = {
155 + };
156 + #endif
157 +
158 ++#ifdef CONFIG_ARM64_ERRATUM_1742098
159 ++static struct midr_range broken_aarch32_aes[] = {
160 ++ MIDR_RANGE(MIDR_CORTEX_A57, 0, 1, 0xf, 0xf),
161 ++ MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
162 ++ {},
163 ++};
164 ++#endif
165 ++
166 + const struct arm64_cpu_capabilities arm64_errata[] = {
167 + #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
168 + {
169 +@@ -554,6 +562,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
170 + /* Cortex-A510 r0p0-r1p1 */
171 + CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1)
172 + },
173 ++#endif
174 ++#ifdef CONFIG_ARM64_ERRATUM_1742098
175 ++ {
176 ++ .desc = "ARM erratum 1742098",
177 ++ .capability = ARM64_WORKAROUND_1742098,
178 ++ CAP_MIDR_RANGE_LIST(broken_aarch32_aes),
179 ++ .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
180 ++ },
181 + #endif
182 + {
183 + }
184 +diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
185 +index e72c90b826568..f3767c1445933 100644
186 +--- a/arch/arm64/kernel/cpufeature.c
187 ++++ b/arch/arm64/kernel/cpufeature.c
188 +@@ -76,6 +76,7 @@
189 + #include <asm/cpufeature.h>
190 + #include <asm/cpu_ops.h>
191 + #include <asm/fpsimd.h>
192 ++#include <asm/hwcap.h>
193 + #include <asm/mmu_context.h>
194 + #include <asm/mte.h>
195 + #include <asm/processor.h>
196 +@@ -1730,6 +1731,14 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap)
197 + }
198 + #endif /* CONFIG_ARM64_MTE */
199 +
200 ++static void elf_hwcap_fixup(void)
201 ++{
202 ++#ifdef CONFIG_ARM64_ERRATUM_1742098
203 ++ if (cpus_have_const_cap(ARM64_WORKAROUND_1742098))
204 ++ compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES;
205 ++#endif /* ARM64_ERRATUM_1742098 */
206 ++}
207 ++
208 + /* Internal helper functions to match cpu capability type */
209 + static bool
210 + cpucap_late_cpu_optional(const struct arm64_cpu_capabilities *cap)
211 +@@ -2735,8 +2744,10 @@ void __init setup_cpu_features(void)
212 + setup_system_capabilities();
213 + setup_elf_hwcaps(arm64_elf_hwcaps);
214 +
215 +- if (system_supports_32bit_el0())
216 ++ if (system_supports_32bit_el0()) {
217 + setup_elf_hwcaps(compat_elf_hwcaps);
218 ++ elf_hwcap_fixup();
219 ++ }
220 +
221 + if (system_uses_ttbr0_pan())
222 + pr_info("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n");
223 +diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
224 +index 4358bc3193067..f35af19b70555 100644
225 +--- a/arch/arm64/kernel/topology.c
226 ++++ b/arch/arm64/kernel/topology.c
227 +@@ -22,46 +22,6 @@
228 + #include <asm/cputype.h>
229 + #include <asm/topology.h>
230 +
231 +-void store_cpu_topology(unsigned int cpuid)
232 +-{
233 +- struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
234 +- u64 mpidr;
235 +-
236 +- if (cpuid_topo->package_id != -1)
237 +- goto topology_populated;
238 +-
239 +- mpidr = read_cpuid_mpidr();
240 +-
241 +- /* Uniprocessor systems can rely on default topology values */
242 +- if (mpidr & MPIDR_UP_BITMASK)
243 +- return;
244 +-
245 +- /*
246 +- * This would be the place to create cpu topology based on MPIDR.
247 +- *
248 +- * However, it cannot be trusted to depict the actual topology; some
249 +- * pieces of the architecture enforce an artificial cap on Aff0 values
250 +- * (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an
251 +- * artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up
252 +- * having absolutely no relationship to the actual underlying system
253 +- * topology, and cannot be reasonably used as core / package ID.
254 +- *
255 +- * If the MT bit is set, Aff0 *could* be used to define a thread ID, but
256 +- * we still wouldn't be able to obtain a sane core ID. This means we
257 +- * need to entirely ignore MPIDR for any topology deduction.
258 +- */
259 +- cpuid_topo->thread_id = -1;
260 +- cpuid_topo->core_id = cpuid;
261 +- cpuid_topo->package_id = cpu_to_node(cpuid);
262 +-
263 +- pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n",
264 +- cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
265 +- cpuid_topo->thread_id, mpidr);
266 +-
267 +-topology_populated:
268 +- update_siblings_masks(cpuid);
269 +-}
270 +-
271 + #ifdef CONFIG_ACPI
272 + static bool __init acpi_cpu_is_threaded(int cpu)
273 + {
274 +diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c
275 +index b9518f94bd435..23710bf5a86b6 100644
276 +--- a/arch/arm64/kvm/vgic/vgic-its.c
277 ++++ b/arch/arm64/kvm/vgic/vgic-its.c
278 +@@ -2096,7 +2096,7 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz,
279 +
280 + memset(entry, 0, esz);
281 +
282 +- while (len > 0) {
283 ++ while (true) {
284 + int next_offset;
285 + size_t byte_offset;
286 +
287 +@@ -2109,6 +2109,9 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz,
288 + return next_offset;
289 +
290 + byte_offset = next_offset * esz;
291 ++ if (byte_offset >= len)
292 ++ break;
293 ++
294 + id += next_offset;
295 + gpa += byte_offset;
296 + len -= byte_offset;
297 +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
298 +index 1b894c3275781..557c4a8c4087d 100644
299 +--- a/arch/riscv/Kconfig
300 ++++ b/arch/riscv/Kconfig
301 +@@ -35,7 +35,7 @@ config RISCV
302 + select CLINT_TIMER if !MMU
303 + select COMMON_CLK
304 + select EDAC_SUPPORT
305 +- select GENERIC_ARCH_TOPOLOGY if SMP
306 ++ select GENERIC_ARCH_TOPOLOGY
307 + select GENERIC_ATOMIC64 if !64BIT
308 + select GENERIC_CLOCKEVENTS
309 + select GENERIC_EARLY_IOREMAP
310 +diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
311 +index 117f3212a8e4b..cc85858f7fe8e 100644
312 +--- a/arch/riscv/kernel/setup.c
313 ++++ b/arch/riscv/kernel/setup.c
314 +@@ -54,10 +54,17 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
315 + static void __init parse_dtb(void)
316 + {
317 + /* Early scan of device tree from init memory */
318 +- if (early_init_dt_scan(dtb_early_va))
319 +- return;
320 ++ if (early_init_dt_scan(dtb_early_va)) {
321 ++ const char *name = of_flat_dt_get_machine_name();
322 ++
323 ++ if (name) {
324 ++ pr_info("Machine model: %s\n", name);
325 ++ dump_stack_set_arch_desc("%s (DT)", name);
326 ++ }
327 ++ } else {
328 ++ pr_err("No DTB passed to the kernel\n");
329 ++ }
330 +
331 +- pr_err("No DTB passed to the kernel\n");
332 + #ifdef CONFIG_CMDLINE_FORCE
333 + strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
334 + pr_info("Forcing kernel command line to: %s\n", boot_command_line);
335 +diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
336 +index 0b04e0eae3ab5..0e0aed380e281 100644
337 +--- a/arch/riscv/kernel/smpboot.c
338 ++++ b/arch/riscv/kernel/smpboot.c
339 +@@ -46,6 +46,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
340 + int cpuid;
341 + int ret;
342 +
343 ++ store_cpu_topology(smp_processor_id());
344 ++
345 + /* This covers non-smp usecase mandated by "nosmp" option */
346 + if (max_cpus == 0)
347 + return;
348 +@@ -152,8 +154,8 @@ asmlinkage __visible void smp_callin(void)
349 + mmgrab(mm);
350 + current->active_mm = mm;
351 +
352 ++ store_cpu_topology(curr_cpuid);
353 + notify_cpu_starting(curr_cpuid);
354 +- update_siblings_masks(curr_cpuid);
355 + set_cpu_online(curr_cpuid, 1);
356 +
357 + /*
358 +diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
359 +index 159646da3c6bc..d64e690139950 100644
360 +--- a/arch/x86/Kconfig
361 ++++ b/arch/x86/Kconfig
362 +@@ -1945,7 +1945,6 @@ config EFI
363 + config EFI_STUB
364 + bool "EFI stub support"
365 + depends on EFI && !X86_USE_3DNOW
366 +- depends on $(cc-option,-mabi=ms) || X86_32
367 + select RELOCATABLE
368 + help
369 + This kernel feature allows a bzImage to be loaded directly
370 +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
371 +index cc3b79c066853..95234f46b0fb9 100644
372 +--- a/arch/x86/events/intel/pt.c
373 ++++ b/arch/x86/events/intel/pt.c
374 +@@ -13,6 +13,8 @@
375 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
376 +
377 + #include <linux/types.h>
378 ++#include <linux/bits.h>
379 ++#include <linux/limits.h>
380 + #include <linux/slab.h>
381 + #include <linux/device.h>
382 +
383 +@@ -1348,11 +1350,37 @@ static void pt_addr_filters_fini(struct perf_event *event)
384 + event->hw.addr_filters = NULL;
385 + }
386 +
387 +-static inline bool valid_kernel_ip(unsigned long ip)
388 ++#ifdef CONFIG_X86_64
389 ++static u64 canonical_address(u64 vaddr, u8 vaddr_bits)
390 + {
391 +- return virt_addr_valid(ip) && kernel_ip(ip);
392 ++ return ((s64)vaddr << (64 - vaddr_bits)) >> (64 - vaddr_bits);
393 + }
394 +
395 ++static u64 is_canonical_address(u64 vaddr, u8 vaddr_bits)
396 ++{
397 ++ return canonical_address(vaddr, vaddr_bits) == vaddr;
398 ++}
399 ++
400 ++/* Clamp to a canonical address greater-than-or-equal-to the address given */
401 ++static u64 clamp_to_ge_canonical_addr(u64 vaddr, u8 vaddr_bits)
402 ++{
403 ++ return is_canonical_address(vaddr, vaddr_bits) ?
404 ++ vaddr :
405 ++ -BIT_ULL(vaddr_bits - 1);
406 ++}
407 ++
408 ++/* Clamp to a canonical address less-than-or-equal-to the address given */
409 ++static u64 clamp_to_le_canonical_addr(u64 vaddr, u8 vaddr_bits)
410 ++{
411 ++ return is_canonical_address(vaddr, vaddr_bits) ?
412 ++ vaddr :
413 ++ BIT_ULL(vaddr_bits - 1) - 1;
414 ++}
415 ++#else
416 ++#define clamp_to_ge_canonical_addr(x, y) (x)
417 ++#define clamp_to_le_canonical_addr(x, y) (x)
418 ++#endif
419 ++
420 + static int pt_event_addr_filters_validate(struct list_head *filters)
421 + {
422 + struct perf_addr_filter *filter;
423 +@@ -1367,14 +1395,6 @@ static int pt_event_addr_filters_validate(struct list_head *filters)
424 + filter->action == PERF_ADDR_FILTER_ACTION_START)
425 + return -EOPNOTSUPP;
426 +
427 +- if (!filter->path.dentry) {
428 +- if (!valid_kernel_ip(filter->offset))
429 +- return -EINVAL;
430 +-
431 +- if (!valid_kernel_ip(filter->offset + filter->size))
432 +- return -EINVAL;
433 +- }
434 +-
435 + if (++range > intel_pt_validate_hw_cap(PT_CAP_num_address_ranges))
436 + return -EOPNOTSUPP;
437 + }
438 +@@ -1398,9 +1418,26 @@ static void pt_event_addr_filters_sync(struct perf_event *event)
439 + if (filter->path.dentry && !fr[range].start) {
440 + msr_a = msr_b = 0;
441 + } else {
442 +- /* apply the offset */
443 +- msr_a = fr[range].start;
444 +- msr_b = msr_a + fr[range].size - 1;
445 ++ unsigned long n = fr[range].size - 1;
446 ++ unsigned long a = fr[range].start;
447 ++ unsigned long b;
448 ++
449 ++ if (a > ULONG_MAX - n)
450 ++ b = ULONG_MAX;
451 ++ else
452 ++ b = a + n;
453 ++ /*
454 ++ * Apply the offset. 64-bit addresses written to the
455 ++ * MSRs must be canonical, but the range can encompass
456 ++ * non-canonical addresses. Since software cannot
457 ++ * execute at non-canonical addresses, adjusting to
458 ++ * canonical addresses does not affect the result of the
459 ++ * address filter.
460 ++ */
461 ++ msr_a = clamp_to_ge_canonical_addr(a, boot_cpu_data.x86_virt_bits);
462 ++ msr_b = clamp_to_le_canonical_addr(b, boot_cpu_data.x86_virt_bits);
463 ++ if (msr_b < msr_a)
464 ++ msr_a = msr_b = 0;
465 + }
466 +
467 + filters->filter[range].msr_a = msr_a;
468 +diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
469 +index bf1ed2ddc74bd..7a983119bc403 100644
470 +--- a/arch/x86/include/asm/iommu.h
471 ++++ b/arch/x86/include/asm/iommu.h
472 +@@ -17,8 +17,10 @@ arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
473 + {
474 + u64 start = rmrr->base_address;
475 + u64 end = rmrr->end_address + 1;
476 ++ int entry_type;
477 +
478 +- if (e820__mapped_all(start, end, E820_TYPE_RESERVED))
479 ++ entry_type = e820__get_entry_type(start, end);
480 ++ if (entry_type == E820_TYPE_RESERVED || entry_type == E820_TYPE_NVS)
481 + return 0;
482 +
483 + pr_err(FW_BUG "No firmware reserved region can cover this RMRR [%#018Lx-%#018Lx], contact BIOS vendor for fixes\n",
484 +diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
485 +index c879364413390..234a96f25248d 100644
486 +--- a/arch/x86/kernel/cpu/microcode/amd.c
487 ++++ b/arch/x86/kernel/cpu/microcode/amd.c
488 +@@ -441,7 +441,13 @@ apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_p
489 + return ret;
490 +
491 + native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
492 +- if (rev >= mc->hdr.patch_id)
493 ++
494 ++ /*
495 ++ * Allow application of the same revision to pick up SMT-specific
496 ++ * changes even if the revision of the other SMT thread is already
497 ++ * up-to-date.
498 ++ */
499 ++ if (rev > mc->hdr.patch_id)
500 + return ret;
501 +
502 + if (!__apply_microcode_amd(mc)) {
503 +@@ -523,8 +529,12 @@ void load_ucode_amd_ap(unsigned int cpuid_1_eax)
504 +
505 + native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
506 +
507 +- /* Check whether we have saved a new patch already: */
508 +- if (*new_rev && rev < mc->hdr.patch_id) {
509 ++ /*
510 ++ * Check whether a new patch has been saved already. Also, allow application of
511 ++ * the same revision in order to pick up SMT-thread-specific configuration even
512 ++ * if the sibling SMT thread already has an up-to-date revision.
513 ++ */
514 ++ if (*new_rev && rev <= mc->hdr.patch_id) {
515 + if (!__apply_microcode_amd(mc)) {
516 + *new_rev = mc->hdr.patch_id;
517 + return;
518 +diff --git a/block/blk-wbt.c b/block/blk-wbt.c
519 +index 35d81b5deae1c..6f63920f073c6 100644
520 +--- a/block/blk-wbt.c
521 ++++ b/block/blk-wbt.c
522 +@@ -838,9 +838,11 @@ int wbt_init(struct request_queue *q)
523 + rwb->last_comp = rwb->last_issue = jiffies;
524 + rwb->win_nsec = RWB_WINDOW_NSEC;
525 + rwb->enable_state = WBT_STATE_ON_DEFAULT;
526 +- rwb->wc = 1;
527 ++ rwb->wc = test_bit(QUEUE_FLAG_WC, &q->queue_flags);
528 + rwb->rq_depth.default_depth = RWB_DEF_DEPTH;
529 +- wbt_update_limits(rwb);
530 ++ rwb->min_lat_nsec = wbt_default_latency_nsec(q);
531 ++
532 ++ wbt_queue_depth_changed(&rwb->rqos);
533 +
534 + /*
535 + * Assign rwb and add the stats callback.
536 +@@ -848,10 +850,5 @@ int wbt_init(struct request_queue *q)
537 + rq_qos_add(q, &rwb->rqos);
538 + blk_stat_add_callback(q, rwb->cb);
539 +
540 +- rwb->min_lat_nsec = wbt_default_latency_nsec(q);
541 +-
542 +- wbt_queue_depth_changed(&rwb->rqos);
543 +- wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags));
544 +-
545 + return 0;
546 + }
547 +diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
548 +index 72f1fb77abcd0..e648158368a7d 100644
549 +--- a/drivers/acpi/acpi_extlog.c
550 ++++ b/drivers/acpi/acpi_extlog.c
551 +@@ -12,6 +12,7 @@
552 + #include <linux/ratelimit.h>
553 + #include <linux/edac.h>
554 + #include <linux/ras.h>
555 ++#include <acpi/ghes.h>
556 + #include <asm/cpu.h>
557 + #include <asm/mce.h>
558 +
559 +@@ -138,8 +139,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
560 + int cpu = mce->extcpu;
561 + struct acpi_hest_generic_status *estatus, *tmp;
562 + struct acpi_hest_generic_data *gdata;
563 +- const guid_t *fru_id = &guid_null;
564 +- char *fru_text = "";
565 ++ const guid_t *fru_id;
566 ++ char *fru_text;
567 + guid_t *sec_type;
568 + static u32 err_seq;
569 +
570 +@@ -160,17 +161,23 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
571 +
572 + /* log event via trace */
573 + err_seq++;
574 +- gdata = (struct acpi_hest_generic_data *)(tmp + 1);
575 +- if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
576 +- fru_id = (guid_t *)gdata->fru_id;
577 +- if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
578 +- fru_text = gdata->fru_text;
579 +- sec_type = (guid_t *)gdata->section_type;
580 +- if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
581 +- struct cper_sec_mem_err *mem = (void *)(gdata + 1);
582 +- if (gdata->error_data_length >= sizeof(*mem))
583 +- trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
584 +- (u8)gdata->error_severity);
585 ++ apei_estatus_for_each_section(tmp, gdata) {
586 ++ if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
587 ++ fru_id = (guid_t *)gdata->fru_id;
588 ++ else
589 ++ fru_id = &guid_null;
590 ++ if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
591 ++ fru_text = gdata->fru_text;
592 ++ else
593 ++ fru_text = "";
594 ++ sec_type = (guid_t *)gdata->section_type;
595 ++ if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
596 ++ struct cper_sec_mem_err *mem = (void *)(gdata + 1);
597 ++
598 ++ if (gdata->error_data_length >= sizeof(*mem))
599 ++ trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
600 ++ (u8)gdata->error_severity);
601 ++ }
602 + }
603 +
604 + out:
605 +diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
606 +index e39d59ad64964..b13713199ad94 100644
607 +--- a/drivers/acpi/video_detect.c
608 ++++ b/drivers/acpi/video_detect.c
609 +@@ -500,6 +500,70 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
610 + DMI_MATCH(DMI_BOARD_NAME, "PF5LUXG"),
611 + },
612 + },
613 ++ /*
614 ++ * More Tongfang devices with the same issue as the Clevo NL5xRU and
615 ++ * NL5xNU/TUXEDO Aura 15 Gen1 and Gen2. See the description above.
616 ++ */
617 ++ {
618 ++ .callback = video_detect_force_native,
619 ++ .ident = "TongFang GKxNRxx",
620 ++ .matches = {
621 ++ DMI_MATCH(DMI_BOARD_NAME, "GKxNRxx"),
622 ++ },
623 ++ },
624 ++ {
625 ++ .callback = video_detect_force_native,
626 ++ .ident = "TongFang GKxNRxx",
627 ++ .matches = {
628 ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
629 ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1501A1650TI"),
630 ++ },
631 ++ },
632 ++ {
633 ++ .callback = video_detect_force_native,
634 ++ .ident = "TongFang GKxNRxx",
635 ++ .matches = {
636 ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
637 ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1501A2060"),
638 ++ },
639 ++ },
640 ++ {
641 ++ .callback = video_detect_force_native,
642 ++ .ident = "TongFang GKxNRxx",
643 ++ .matches = {
644 ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
645 ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1701A1650TI"),
646 ++ },
647 ++ },
648 ++ {
649 ++ .callback = video_detect_force_native,
650 ++ .ident = "TongFang GKxNRxx",
651 ++ .matches = {
652 ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
653 ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1701A2060"),
654 ++ },
655 ++ },
656 ++ {
657 ++ .callback = video_detect_force_native,
658 ++ .ident = "TongFang GMxNGxx",
659 ++ .matches = {
660 ++ DMI_MATCH(DMI_BOARD_NAME, "GMxNGxx"),
661 ++ },
662 ++ },
663 ++ {
664 ++ .callback = video_detect_force_native,
665 ++ .ident = "TongFang GMxZGxx",
666 ++ .matches = {
667 ++ DMI_MATCH(DMI_BOARD_NAME, "GMxZGxx"),
668 ++ },
669 ++ },
670 ++ {
671 ++ .callback = video_detect_force_native,
672 ++ .ident = "TongFang GMxRGxx",
673 ++ .matches = {
674 ++ DMI_MATCH(DMI_BOARD_NAME, "GMxRGxx"),
675 ++ },
676 ++ },
677 + /*
678 + * Desktops which falsely report a backlight and which our heuristics
679 + * for this do not catch.
680 +diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
681 +index d1f284f0c83d9..1ce8973569933 100644
682 +--- a/drivers/ata/ahci.h
683 ++++ b/drivers/ata/ahci.h
684 +@@ -254,7 +254,7 @@ enum {
685 + PCS_7 = 0x94, /* 7+ port PCS (Denverton) */
686 +
687 + /* em constants */
688 +- EM_MAX_SLOTS = 8,
689 ++ EM_MAX_SLOTS = SATA_PMP_MAX_PORTS,
690 + EM_MAX_RETRY = 5,
691 +
692 + /* em_ctl bits */
693 +diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
694 +index 388baf528fa81..189f75d537414 100644
695 +--- a/drivers/ata/ahci_imx.c
696 ++++ b/drivers/ata/ahci_imx.c
697 +@@ -1230,4 +1230,4 @@ module_platform_driver(imx_ahci_driver);
698 + MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver");
699 + MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@×××××××××.com>");
700 + MODULE_LICENSE("GPL");
701 +-MODULE_ALIAS("ahci:imx");
702 ++MODULE_ALIAS("platform:" DRV_NAME);
703 +diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
704 +index 8272a3a002a34..51647926e6051 100644
705 +--- a/drivers/base/arch_topology.c
706 ++++ b/drivers/base/arch_topology.c
707 +@@ -596,4 +596,23 @@ void __init init_cpu_topology(void)
708 + else if (of_have_populated_dt() && parse_dt_topology())
709 + reset_cpu_topology();
710 + }
711 ++
712 ++void store_cpu_topology(unsigned int cpuid)
713 ++{
714 ++ struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
715 ++
716 ++ if (cpuid_topo->package_id != -1)
717 ++ goto topology_populated;
718 ++
719 ++ cpuid_topo->thread_id = -1;
720 ++ cpuid_topo->core_id = cpuid;
721 ++ cpuid_topo->package_id = cpu_to_node(cpuid);
722 ++
723 ++ pr_debug("CPU%u: package %d core %d thread %d\n",
724 ++ cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
725 ++ cpuid_topo->thread_id);
726 ++
727 ++topology_populated:
728 ++ update_siblings_masks(cpuid);
729 ++}
730 + #endif
731 +diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
732 +index 7fdd30e92e429..9b3d24721d7b2 100644
733 +--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
734 ++++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
735 +@@ -215,6 +215,7 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
736 + int speed = 0, pvs = 0, pvs_ver = 0;
737 + u8 *speedbin;
738 + size_t len;
739 ++ int ret = 0;
740 +
741 + speedbin = nvmem_cell_read(speedbin_nvmem, &len);
742 +
743 +@@ -232,7 +233,8 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
744 + break;
745 + default:
746 + dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
747 +- return -ENODEV;
748 ++ ret = -ENODEV;
749 ++ goto len_error;
750 + }
751 +
752 + snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
753 +@@ -240,8 +242,9 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
754 +
755 + drv->versions = (1 << speed);
756 +
757 ++len_error:
758 + kfree(speedbin);
759 +- return 0;
760 ++ return ret;
761 + }
762 +
763 + static const struct qcom_cpufreq_match_data match_data_kryo = {
764 +@@ -264,7 +267,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
765 + struct nvmem_cell *speedbin_nvmem;
766 + struct device_node *np;
767 + struct device *cpu_dev;
768 +- char *pvs_name = "speedXX-pvsXX-vXX";
769 ++ char pvs_name_buffer[] = "speedXX-pvsXX-vXX";
770 ++ char *pvs_name = pvs_name_buffer;
771 + unsigned cpu;
772 + const struct of_device_id *match;
773 + int ret;
774 +diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
775 +index 65f816b40c328..dc147cc2436e9 100644
776 +--- a/drivers/dma/mxs-dma.c
777 ++++ b/drivers/dma/mxs-dma.c
778 +@@ -167,29 +167,11 @@ static struct mxs_dma_type mxs_dma_types[] = {
779 + }
780 + };
781 +
782 +-static const struct platform_device_id mxs_dma_ids[] = {
783 +- {
784 +- .name = "imx23-dma-apbh",
785 +- .driver_data = (kernel_ulong_t) &mxs_dma_types[0],
786 +- }, {
787 +- .name = "imx23-dma-apbx",
788 +- .driver_data = (kernel_ulong_t) &mxs_dma_types[1],
789 +- }, {
790 +- .name = "imx28-dma-apbh",
791 +- .driver_data = (kernel_ulong_t) &mxs_dma_types[2],
792 +- }, {
793 +- .name = "imx28-dma-apbx",
794 +- .driver_data = (kernel_ulong_t) &mxs_dma_types[3],
795 +- }, {
796 +- /* end of list */
797 +- }
798 +-};
799 +-
800 + static const struct of_device_id mxs_dma_dt_ids[] = {
801 +- { .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_ids[0], },
802 +- { .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], },
803 +- { .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], },
804 +- { .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], },
805 ++ { .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_types[0], },
806 ++ { .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_types[1], },
807 ++ { .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_types[2], },
808 ++ { .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_types[3], },
809 + { /* sentinel */ }
810 + };
811 + MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids);
812 +@@ -688,7 +670,7 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan,
813 + return mxs_chan->status;
814 + }
815 +
816 +-static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
817 ++static int mxs_dma_init(struct mxs_dma_engine *mxs_dma)
818 + {
819 + int ret;
820 +
821 +@@ -759,11 +741,9 @@ static struct dma_chan *mxs_dma_xlate(struct of_phandle_args *dma_spec,
822 + ofdma->of_node);
823 + }
824 +
825 +-static int __init mxs_dma_probe(struct platform_device *pdev)
826 ++static int mxs_dma_probe(struct platform_device *pdev)
827 + {
828 + struct device_node *np = pdev->dev.of_node;
829 +- const struct platform_device_id *id_entry;
830 +- const struct of_device_id *of_id;
831 + const struct mxs_dma_type *dma_type;
832 + struct mxs_dma_engine *mxs_dma;
833 + struct resource *iores;
834 +@@ -779,13 +759,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
835 + return ret;
836 + }
837 +
838 +- of_id = of_match_device(mxs_dma_dt_ids, &pdev->dev);
839 +- if (of_id)
840 +- id_entry = of_id->data;
841 +- else
842 +- id_entry = platform_get_device_id(pdev);
843 +-
844 +- dma_type = (struct mxs_dma_type *)id_entry->driver_data;
845 ++ dma_type = (struct mxs_dma_type *)of_device_get_match_data(&pdev->dev);
846 + mxs_dma->type = dma_type->type;
847 + mxs_dma->dev_id = dma_type->id;
848 +
849 +@@ -865,11 +839,7 @@ static struct platform_driver mxs_dma_driver = {
850 + .name = "mxs-dma",
851 + .of_match_table = mxs_dma_dt_ids,
852 + },
853 +- .id_table = mxs_dma_ids,
854 ++ .probe = mxs_dma_probe,
855 + };
856 +
857 +-static int __init mxs_dma_module_init(void)
858 +-{
859 +- return platform_driver_probe(&mxs_dma_driver, mxs_dma_probe);
860 +-}
861 +-subsys_initcall(mxs_dma_module_init);
862 ++builtin_platform_driver(mxs_dma_driver);
863 +diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
864 +index 6a311cd934403..e6de627342695 100644
865 +--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
866 ++++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
867 +@@ -213,14 +213,14 @@ static int virtio_gpu_cursor_prepare_fb(struct drm_plane *plane,
868 + }
869 +
870 + static void virtio_gpu_cursor_cleanup_fb(struct drm_plane *plane,
871 +- struct drm_plane_state *old_state)
872 ++ struct drm_plane_state *state)
873 + {
874 + struct virtio_gpu_framebuffer *vgfb;
875 +
876 +- if (!plane->state->fb)
877 ++ if (!state->fb)
878 + return;
879 +
880 +- vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
881 ++ vgfb = to_virtio_gpu_framebuffer(state->fb);
882 + if (vgfb->fence) {
883 + dma_fence_put(&vgfb->fence->f);
884 + vgfb->fence = NULL;
885 +diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
886 +index fc4c074597539..28158d2f23523 100644
887 +--- a/drivers/hid/hid-magicmouse.c
888 ++++ b/drivers/hid/hid-magicmouse.c
889 +@@ -387,7 +387,7 @@ static int magicmouse_raw_event(struct hid_device *hdev,
890 + magicmouse_raw_event(hdev, report, data + 2, data[1]);
891 + magicmouse_raw_event(hdev, report, data + 2 + data[1],
892 + size - 2 - data[1]);
893 +- break;
894 ++ return 0;
895 + default:
896 + return 0;
897 + }
898 +diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
899 +index bb9211215a688..032129292957e 100644
900 +--- a/drivers/hwmon/coretemp.c
901 ++++ b/drivers/hwmon/coretemp.c
902 +@@ -46,9 +46,6 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
903 + #define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
904 + #define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
905 +
906 +-#define TO_CORE_ID(cpu) (cpu_data(cpu).cpu_core_id)
907 +-#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
908 +-
909 + #ifdef CONFIG_SMP
910 + #define for_each_sibling(i, cpu) \
911 + for_each_cpu(i, topology_sibling_cpumask(cpu))
912 +@@ -91,6 +88,8 @@ struct temp_data {
913 + struct platform_data {
914 + struct device *hwmon_dev;
915 + u16 pkg_id;
916 ++ u16 cpu_map[NUM_REAL_CORES];
917 ++ struct ida ida;
918 + struct cpumask cpumask;
919 + struct temp_data *core_data[MAX_CORE_DATA];
920 + struct device_attribute name_attr;
921 +@@ -441,7 +440,7 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
922 + MSR_IA32_THERM_STATUS;
923 + tdata->is_pkg_data = pkg_flag;
924 + tdata->cpu = cpu;
925 +- tdata->cpu_core_id = TO_CORE_ID(cpu);
926 ++ tdata->cpu_core_id = topology_core_id(cpu);
927 + tdata->attr_size = MAX_CORE_ATTRS;
928 + mutex_init(&tdata->update_lock);
929 + return tdata;
930 +@@ -454,7 +453,7 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,
931 + struct platform_data *pdata = platform_get_drvdata(pdev);
932 + struct cpuinfo_x86 *c = &cpu_data(cpu);
933 + u32 eax, edx;
934 +- int err, attr_no;
935 ++ int err, index, attr_no;
936 +
937 + /*
938 + * Find attr number for sysfs:
939 +@@ -462,14 +461,26 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,
940 + * The attr number is always core id + 2
941 + * The Pkgtemp will always show up as temp1_*, if available
942 + */
943 +- attr_no = pkg_flag ? PKG_SYSFS_ATTR_NO : TO_ATTR_NO(cpu);
944 ++ if (pkg_flag) {
945 ++ attr_no = PKG_SYSFS_ATTR_NO;
946 ++ } else {
947 ++ index = ida_alloc(&pdata->ida, GFP_KERNEL);
948 ++ if (index < 0)
949 ++ return index;
950 ++ pdata->cpu_map[index] = topology_core_id(cpu);
951 ++ attr_no = index + BASE_SYSFS_ATTR_NO;
952 ++ }
953 +
954 +- if (attr_no > MAX_CORE_DATA - 1)
955 +- return -ERANGE;
956 ++ if (attr_no > MAX_CORE_DATA - 1) {
957 ++ err = -ERANGE;
958 ++ goto ida_free;
959 ++ }
960 +
961 + tdata = init_temp_data(cpu, pkg_flag);
962 +- if (!tdata)
963 +- return -ENOMEM;
964 ++ if (!tdata) {
965 ++ err = -ENOMEM;
966 ++ goto ida_free;
967 ++ }
968 +
969 + /* Test if we can access the status register */
970 + err = rdmsr_safe_on_cpu(cpu, tdata->status_reg, &eax, &edx);
971 +@@ -505,6 +516,9 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,
972 + exit_free:
973 + pdata->core_data[attr_no] = NULL;
974 + kfree(tdata);
975 ++ida_free:
976 ++ if (!pkg_flag)
977 ++ ida_free(&pdata->ida, index);
978 + return err;
979 + }
980 +
981 +@@ -524,6 +538,9 @@ static void coretemp_remove_core(struct platform_data *pdata, int indx)
982 +
983 + kfree(pdata->core_data[indx]);
984 + pdata->core_data[indx] = NULL;
985 ++
986 ++ if (indx >= BASE_SYSFS_ATTR_NO)
987 ++ ida_free(&pdata->ida, indx - BASE_SYSFS_ATTR_NO);
988 + }
989 +
990 + static int coretemp_probe(struct platform_device *pdev)
991 +@@ -537,6 +554,7 @@ static int coretemp_probe(struct platform_device *pdev)
992 + return -ENOMEM;
993 +
994 + pdata->pkg_id = pdev->id;
995 ++ ida_init(&pdata->ida);
996 + platform_set_drvdata(pdev, pdata);
997 +
998 + pdata->hwmon_dev = devm_hwmon_device_register_with_groups(dev, DRVNAME,
999 +@@ -553,6 +571,7 @@ static int coretemp_remove(struct platform_device *pdev)
1000 + if (pdata->core_data[i])
1001 + coretemp_remove_core(pdata, i);
1002 +
1003 ++ ida_destroy(&pdata->ida);
1004 + return 0;
1005 + }
1006 +
1007 +@@ -647,7 +666,7 @@ static int coretemp_cpu_offline(unsigned int cpu)
1008 + struct platform_device *pdev = coretemp_get_pdev(cpu);
1009 + struct platform_data *pd;
1010 + struct temp_data *tdata;
1011 +- int indx, target;
1012 ++ int i, indx = -1, target;
1013 +
1014 + /*
1015 + * Don't execute this on suspend as the device remove locks
1016 +@@ -660,12 +679,19 @@ static int coretemp_cpu_offline(unsigned int cpu)
1017 + if (!pdev)
1018 + return 0;
1019 +
1020 +- /* The core id is too big, just return */
1021 +- indx = TO_ATTR_NO(cpu);
1022 +- if (indx > MAX_CORE_DATA - 1)
1023 ++ pd = platform_get_drvdata(pdev);
1024 ++
1025 ++ for (i = 0; i < NUM_REAL_CORES; i++) {
1026 ++ if (pd->cpu_map[i] == topology_core_id(cpu)) {
1027 ++ indx = i + BASE_SYSFS_ATTR_NO;
1028 ++ break;
1029 ++ }
1030 ++ }
1031 ++
1032 ++ /* Too many cores and this core is not populated, just return */
1033 ++ if (indx < 0)
1034 + return 0;
1035 +
1036 +- pd = platform_get_drvdata(pdev);
1037 + tdata = pd->core_data[indx];
1038 +
1039 + cpumask_clear_cpu(cpu, &pd->cpumask);
1040 +diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
1041 +index 09e599069a81d..06c87c79bae76 100644
1042 +--- a/drivers/i2c/busses/i2c-qcom-cci.c
1043 ++++ b/drivers/i2c/busses/i2c-qcom-cci.c
1044 +@@ -638,6 +638,11 @@ static int cci_probe(struct platform_device *pdev)
1045 + if (ret < 0)
1046 + goto error;
1047 +
1048 ++ pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
1049 ++ pm_runtime_use_autosuspend(dev);
1050 ++ pm_runtime_set_active(dev);
1051 ++ pm_runtime_enable(dev);
1052 ++
1053 + for (i = 0; i < cci->data->num_masters; i++) {
1054 + if (!cci->master[i].cci)
1055 + continue;
1056 +@@ -649,14 +654,12 @@ static int cci_probe(struct platform_device *pdev)
1057 + }
1058 + }
1059 +
1060 +- pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
1061 +- pm_runtime_use_autosuspend(dev);
1062 +- pm_runtime_set_active(dev);
1063 +- pm_runtime_enable(dev);
1064 +-
1065 + return 0;
1066 +
1067 + error_i2c:
1068 ++ pm_runtime_disable(dev);
1069 ++ pm_runtime_dont_use_autosuspend(dev);
1070 ++
1071 + for (--i ; i >= 0; i--) {
1072 + if (cci->master[i].cci) {
1073 + i2c_del_adapter(&cci->master[i].adap);
1074 +diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
1075 +index c48cf737b521d..f23329b7f97cd 100644
1076 +--- a/drivers/iommu/intel/iommu.c
1077 ++++ b/drivers/iommu/intel/iommu.c
1078 +@@ -2846,6 +2846,7 @@ static int __init si_domain_init(int hw)
1079 +
1080 + if (md_domain_init(si_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
1081 + domain_exit(si_domain);
1082 ++ si_domain = NULL;
1083 + return -EFAULT;
1084 + }
1085 +
1086 +@@ -3505,6 +3506,10 @@ free_iommu:
1087 + disable_dmar_iommu(iommu);
1088 + free_dmar_iommu(iommu);
1089 + }
1090 ++ if (si_domain) {
1091 ++ domain_exit(si_domain);
1092 ++ si_domain = NULL;
1093 ++ }
1094 +
1095 + kfree(g_iommus);
1096 +
1097 +diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
1098 +index ea13170a6a2cf..de34a87d1130e 100644
1099 +--- a/drivers/media/platform/qcom/venus/vdec.c
1100 ++++ b/drivers/media/platform/qcom/venus/vdec.c
1101 +@@ -158,6 +158,8 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
1102 + else
1103 + return NULL;
1104 + fmt = find_format(inst, pixmp->pixelformat, f->type);
1105 ++ if (!fmt)
1106 ++ return NULL;
1107 + }
1108 +
1109 + pixmp->width = clamp(pixmp->width, frame_width_min(inst),
1110 +diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
1111 +index de4cf6eb5258b..142319c48405d 100644
1112 +--- a/drivers/media/rc/mceusb.c
1113 ++++ b/drivers/media/rc/mceusb.c
1114 +@@ -1077,7 +1077,7 @@ static int mceusb_set_timeout(struct rc_dev *dev, unsigned int timeout)
1115 + struct mceusb_dev *ir = dev->priv;
1116 + unsigned int units;
1117 +
1118 +- units = DIV_ROUND_CLOSEST(timeout, MCE_TIME_UNIT);
1119 ++ units = DIV_ROUND_UP(timeout, MCE_TIME_UNIT);
1120 +
1121 + cmdbuf[2] = units >> 8;
1122 + cmdbuf[3] = units;
1123 +diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
1124 +index 66a00b7c751f7..6622e32621874 100644
1125 +--- a/drivers/mmc/core/block.c
1126 ++++ b/drivers/mmc/core/block.c
1127 +@@ -1069,6 +1069,11 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
1128 + nr = blk_rq_sectors(req);
1129 +
1130 + do {
1131 ++ unsigned int erase_arg = card->erase_arg;
1132 ++
1133 ++ if (mmc_card_broken_sd_discard(card))
1134 ++ erase_arg = SD_ERASE_ARG;
1135 ++
1136 + err = 0;
1137 + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
1138 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1139 +@@ -1079,7 +1084,7 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
1140 + card->ext_csd.generic_cmd6_time);
1141 + }
1142 + if (!err)
1143 +- err = mmc_erase(card, from, nr, card->erase_arg);
1144 ++ err = mmc_erase(card, from, nr, erase_arg);
1145 + } while (err == -EIO && !mmc_blk_reset(md, card->host, type));
1146 + if (err)
1147 + status = BLK_STS_IOERR;
1148 +diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h
1149 +index 7bd392d55cfa5..5c6986131faff 100644
1150 +--- a/drivers/mmc/core/card.h
1151 ++++ b/drivers/mmc/core/card.h
1152 +@@ -70,6 +70,7 @@ struct mmc_fixup {
1153 + #define EXT_CSD_REV_ANY (-1u)
1154 +
1155 + #define CID_MANFID_SANDISK 0x2
1156 ++#define CID_MANFID_SANDISK_SD 0x3
1157 + #define CID_MANFID_ATP 0x9
1158 + #define CID_MANFID_TOSHIBA 0x11
1159 + #define CID_MANFID_MICRON 0x13
1160 +@@ -222,4 +223,9 @@ static inline int mmc_card_broken_hpi(const struct mmc_card *c)
1161 + return c->quirks & MMC_QUIRK_BROKEN_HPI;
1162 + }
1163 +
1164 ++static inline int mmc_card_broken_sd_discard(const struct mmc_card *c)
1165 ++{
1166 ++ return c->quirks & MMC_QUIRK_BROKEN_SD_DISCARD;
1167 ++}
1168 ++
1169 + #endif
1170 +diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
1171 +index d68e6e513a4f4..c8c0f50a2076d 100644
1172 +--- a/drivers/mmc/core/quirks.h
1173 ++++ b/drivers/mmc/core/quirks.h
1174 +@@ -99,6 +99,12 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
1175 + MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
1176 + MMC_QUIRK_TRIM_BROKEN),
1177 +
1178 ++ /*
1179 ++ * Some SD cards reports discard support while they don't
1180 ++ */
1181 ++ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
1182 ++ MMC_QUIRK_BROKEN_SD_DISCARD),
1183 ++
1184 + END_FIXUP
1185 + };
1186 +
1187 +diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
1188 +index d50b691f6c44e..67211fc42d242 100644
1189 +--- a/drivers/mmc/host/sdhci-tegra.c
1190 ++++ b/drivers/mmc/host/sdhci-tegra.c
1191 +@@ -760,7 +760,7 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1192 + */
1193 + host_clk = tegra_host->ddr_signaling ? clock * 2 : clock;
1194 + clk_set_rate(pltfm_host->clk, host_clk);
1195 +- tegra_host->curr_clk_rate = host_clk;
1196 ++ tegra_host->curr_clk_rate = clk_get_rate(pltfm_host->clk);
1197 + if (tegra_host->ddr_signaling)
1198 + host->max_clk = host_clk;
1199 + else
1200 +diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
1201 +index 00fafc0f85121..430eccea8e5e9 100644
1202 +--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
1203 ++++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
1204 +@@ -419,8 +419,10 @@ int hnae_ae_register(struct hnae_ae_dev *hdev, struct module *owner)
1205 + hdev->cls_dev.release = hnae_release;
1206 + (void)dev_set_name(&hdev->cls_dev, "hnae%d", hdev->id);
1207 + ret = device_register(&hdev->cls_dev);
1208 +- if (ret)
1209 ++ if (ret) {
1210 ++ put_device(&hdev->cls_dev);
1211 + return ret;
1212 ++ }
1213 +
1214 + __module_get(THIS_MODULE);
1215 +
1216 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
1217 +index 63054061966e6..cc5f5c237774f 100644
1218 +--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
1219 ++++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
1220 +@@ -2081,9 +2081,6 @@ static int i40e_set_ringparam(struct net_device *netdev,
1221 + */
1222 + rx_rings[i].tail = hw->hw_addr + I40E_PRTGEN_STATUS;
1223 + err = i40e_setup_rx_descriptors(&rx_rings[i]);
1224 +- if (err)
1225 +- goto rx_unwind;
1226 +- err = i40e_alloc_rx_bi(&rx_rings[i]);
1227 + if (err)
1228 + goto rx_unwind;
1229 +
1230 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
1231 +index c7f243ddbcf72..ea6a984c6d12b 100644
1232 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
1233 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
1234 +@@ -3409,12 +3409,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
1235 + if (ring->vsi->type == I40E_VSI_MAIN)
1236 + xdp_rxq_info_unreg_mem_model(&ring->xdp_rxq);
1237 +
1238 +- kfree(ring->rx_bi);
1239 + ring->xsk_pool = i40e_xsk_pool(ring);
1240 + if (ring->xsk_pool) {
1241 +- ret = i40e_alloc_rx_bi_zc(ring);
1242 +- if (ret)
1243 +- return ret;
1244 + ring->rx_buf_len =
1245 + xsk_pool_get_rx_frame_size(ring->xsk_pool);
1246 + /* For AF_XDP ZC, we disallow packets to span on
1247 +@@ -3432,9 +3428,6 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
1248 + ring->queue_index);
1249 +
1250 + } else {
1251 +- ret = i40e_alloc_rx_bi(ring);
1252 +- if (ret)
1253 +- return ret;
1254 + ring->rx_buf_len = vsi->rx_buf_len;
1255 + if (ring->vsi->type == I40E_VSI_MAIN) {
1256 + ret = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq,
1257 +@@ -12684,6 +12677,14 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi,
1258 + i40e_reset_and_rebuild(pf, true, true);
1259 + }
1260 +
1261 ++ if (!i40e_enabled_xdp_vsi(vsi) && prog) {
1262 ++ if (i40e_realloc_rx_bi_zc(vsi, true))
1263 ++ return -ENOMEM;
1264 ++ } else if (i40e_enabled_xdp_vsi(vsi) && !prog) {
1265 ++ if (i40e_realloc_rx_bi_zc(vsi, false))
1266 ++ return -ENOMEM;
1267 ++ }
1268 ++
1269 + for (i = 0; i < vsi->num_queue_pairs; i++)
1270 + WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog);
1271 +
1272 +@@ -12916,6 +12917,7 @@ int i40e_queue_pair_disable(struct i40e_vsi *vsi, int queue_pair)
1273 +
1274 + i40e_queue_pair_disable_irq(vsi, queue_pair);
1275 + err = i40e_queue_pair_toggle_rings(vsi, queue_pair, false /* off */);
1276 ++ i40e_clean_rx_ring(vsi->rx_rings[queue_pair]);
1277 + i40e_queue_pair_toggle_napi(vsi, queue_pair, false /* off */);
1278 + i40e_queue_pair_clean_rings(vsi, queue_pair);
1279 + i40e_queue_pair_reset_stats(vsi, queue_pair);
1280 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
1281 +index 5ad28129fab2a..43be33d87e391 100644
1282 +--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
1283 ++++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
1284 +@@ -1305,14 +1305,6 @@ err:
1285 + return -ENOMEM;
1286 + }
1287 +
1288 +-int i40e_alloc_rx_bi(struct i40e_ring *rx_ring)
1289 +-{
1290 +- unsigned long sz = sizeof(*rx_ring->rx_bi) * rx_ring->count;
1291 +-
1292 +- rx_ring->rx_bi = kzalloc(sz, GFP_KERNEL);
1293 +- return rx_ring->rx_bi ? 0 : -ENOMEM;
1294 +-}
1295 +-
1296 + static void i40e_clear_rx_bi(struct i40e_ring *rx_ring)
1297 + {
1298 + memset(rx_ring->rx_bi, 0, sizeof(*rx_ring->rx_bi) * rx_ring->count);
1299 +@@ -1443,6 +1435,11 @@ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring)
1300 +
1301 + rx_ring->xdp_prog = rx_ring->vsi->xdp_prog;
1302 +
1303 ++ rx_ring->rx_bi =
1304 ++ kcalloc(rx_ring->count, sizeof(*rx_ring->rx_bi), GFP_KERNEL);
1305 ++ if (!rx_ring->rx_bi)
1306 ++ return -ENOMEM;
1307 ++
1308 + return 0;
1309 + }
1310 +
1311 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
1312 +index 93ac201f68b8e..af843e8169f7d 100644
1313 +--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h
1314 ++++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
1315 +@@ -465,7 +465,6 @@ int __i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size);
1316 + bool __i40e_chk_linearize(struct sk_buff *skb);
1317 + int i40e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
1318 + u32 flags);
1319 +-int i40e_alloc_rx_bi(struct i40e_ring *rx_ring);
1320 +
1321 + /**
1322 + * i40e_get_head - Retrieve head from head writeback
1323 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1324 +index 75e4a698c3db2..7f12261236293 100644
1325 +--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1326 ++++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1327 +@@ -9,14 +9,6 @@
1328 + #include "i40e_txrx_common.h"
1329 + #include "i40e_xsk.h"
1330 +
1331 +-int i40e_alloc_rx_bi_zc(struct i40e_ring *rx_ring)
1332 +-{
1333 +- unsigned long sz = sizeof(*rx_ring->rx_bi_zc) * rx_ring->count;
1334 +-
1335 +- rx_ring->rx_bi_zc = kzalloc(sz, GFP_KERNEL);
1336 +- return rx_ring->rx_bi_zc ? 0 : -ENOMEM;
1337 +-}
1338 +-
1339 + void i40e_clear_rx_bi_zc(struct i40e_ring *rx_ring)
1340 + {
1341 + memset(rx_ring->rx_bi_zc, 0,
1342 +@@ -28,6 +20,58 @@ static struct xdp_buff **i40e_rx_bi(struct i40e_ring *rx_ring, u32 idx)
1343 + return &rx_ring->rx_bi_zc[idx];
1344 + }
1345 +
1346 ++/**
1347 ++ * i40e_realloc_rx_xdp_bi - reallocate SW ring for either XSK or normal buffer
1348 ++ * @rx_ring: Current rx ring
1349 ++ * @pool_present: is pool for XSK present
1350 ++ *
1351 ++ * Try allocating memory and return ENOMEM, if failed to allocate.
1352 ++ * If allocation was successful, substitute buffer with allocated one.
1353 ++ * Returns 0 on success, negative on failure
1354 ++ */
1355 ++static int i40e_realloc_rx_xdp_bi(struct i40e_ring *rx_ring, bool pool_present)
1356 ++{
1357 ++ size_t elem_size = pool_present ? sizeof(*rx_ring->rx_bi_zc) :
1358 ++ sizeof(*rx_ring->rx_bi);
1359 ++ void *sw_ring = kcalloc(rx_ring->count, elem_size, GFP_KERNEL);
1360 ++
1361 ++ if (!sw_ring)
1362 ++ return -ENOMEM;
1363 ++
1364 ++ if (pool_present) {
1365 ++ kfree(rx_ring->rx_bi);
1366 ++ rx_ring->rx_bi = NULL;
1367 ++ rx_ring->rx_bi_zc = sw_ring;
1368 ++ } else {
1369 ++ kfree(rx_ring->rx_bi_zc);
1370 ++ rx_ring->rx_bi_zc = NULL;
1371 ++ rx_ring->rx_bi = sw_ring;
1372 ++ }
1373 ++ return 0;
1374 ++}
1375 ++
1376 ++/**
1377 ++ * i40e_realloc_rx_bi_zc - reallocate rx SW rings
1378 ++ * @vsi: Current VSI
1379 ++ * @zc: is zero copy set
1380 ++ *
1381 ++ * Reallocate buffer for rx_rings that might be used by XSK.
1382 ++ * XDP requires more memory, than rx_buf provides.
1383 ++ * Returns 0 on success, negative on failure
1384 ++ */
1385 ++int i40e_realloc_rx_bi_zc(struct i40e_vsi *vsi, bool zc)
1386 ++{
1387 ++ struct i40e_ring *rx_ring;
1388 ++ unsigned long q;
1389 ++
1390 ++ for_each_set_bit(q, vsi->af_xdp_zc_qps, vsi->alloc_queue_pairs) {
1391 ++ rx_ring = vsi->rx_rings[q];
1392 ++ if (i40e_realloc_rx_xdp_bi(rx_ring, zc))
1393 ++ return -ENOMEM;
1394 ++ }
1395 ++ return 0;
1396 ++}
1397 ++
1398 + /**
1399 + * i40e_xsk_pool_enable - Enable/associate an AF_XDP buffer pool to a
1400 + * certain ring/qid
1401 +@@ -68,6 +112,10 @@ static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
1402 + if (err)
1403 + return err;
1404 +
1405 ++ err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], true);
1406 ++ if (err)
1407 ++ return err;
1408 ++
1409 + err = i40e_queue_pair_enable(vsi, qid);
1410 + if (err)
1411 + return err;
1412 +@@ -112,6 +160,9 @@ static int i40e_xsk_pool_disable(struct i40e_vsi *vsi, u16 qid)
1413 + xsk_pool_dma_unmap(pool, I40E_RX_DMA_ATTR);
1414 +
1415 + if (if_running) {
1416 ++ err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], false);
1417 ++ if (err)
1418 ++ return err;
1419 + err = i40e_queue_pair_enable(vsi, qid);
1420 + if (err)
1421 + return err;
1422 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.h b/drivers/net/ethernet/intel/i40e/i40e_xsk.h
1423 +index 7adfd8539247c..36f5b6d206010 100644
1424 +--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.h
1425 ++++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.h
1426 +@@ -17,7 +17,7 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget);
1427 +
1428 + bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi, struct i40e_ring *tx_ring);
1429 + int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags);
1430 +-int i40e_alloc_rx_bi_zc(struct i40e_ring *rx_ring);
1431 ++int i40e_realloc_rx_bi_zc(struct i40e_vsi *vsi, bool zc);
1432 + void i40e_clear_rx_bi_zc(struct i40e_ring *rx_ring);
1433 +
1434 + #endif /* _I40E_XSK_H_ */
1435 +diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1436 +index e42520f909fe2..cb12d0171517e 100644
1437 +--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1438 ++++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1439 +@@ -2383,11 +2383,15 @@ err_out:
1440 + * than the full array, but leave the qcq shells in place
1441 + */
1442 + for (i = lif->nxqs; i < lif->ionic->ntxqs_per_lif; i++) {
1443 +- lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
1444 +- ionic_qcq_free(lif, lif->txqcqs[i]);
1445 ++ if (lif->txqcqs && lif->txqcqs[i]) {
1446 ++ lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
1447 ++ ionic_qcq_free(lif, lif->txqcqs[i]);
1448 ++ }
1449 +
1450 +- lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
1451 +- ionic_qcq_free(lif, lif->rxqcqs[i]);
1452 ++ if (lif->rxqcqs && lif->rxqcqs[i]) {
1453 ++ lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
1454 ++ ionic_qcq_free(lif, lif->rxqcqs[i]);
1455 ++ }
1456 + }
1457 +
1458 + return err;
1459 +diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
1460 +index 5b7413305be63..eb1be73020822 100644
1461 +--- a/drivers/net/ethernet/sfc/ef10.c
1462 ++++ b/drivers/net/ethernet/sfc/ef10.c
1463 +@@ -3255,6 +3255,30 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
1464 + bool was_enabled = efx->port_enabled;
1465 + int rc;
1466 +
1467 ++#ifdef CONFIG_SFC_SRIOV
1468 ++ /* If this function is a VF and we have access to the parent PF,
1469 ++ * then use the PF control path to attempt to change the VF MAC address.
1470 ++ */
1471 ++ if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
1472 ++ struct efx_nic *efx_pf = pci_get_drvdata(efx->pci_dev->physfn);
1473 ++ struct efx_ef10_nic_data *nic_data = efx->nic_data;
1474 ++ u8 mac[ETH_ALEN];
1475 ++
1476 ++ /* net_dev->dev_addr can be zeroed by efx_net_stop in
1477 ++ * efx_ef10_sriov_set_vf_mac, so pass in a copy.
1478 ++ */
1479 ++ ether_addr_copy(mac, efx->net_dev->dev_addr);
1480 ++
1481 ++ rc = efx_ef10_sriov_set_vf_mac(efx_pf, nic_data->vf_index, mac);
1482 ++ if (!rc)
1483 ++ return 0;
1484 ++
1485 ++ netif_dbg(efx, drv, efx->net_dev,
1486 ++ "Updating VF mac via PF failed (%d), setting directly\n",
1487 ++ rc);
1488 ++ }
1489 ++#endif
1490 ++
1491 + efx_device_detach_sync(efx);
1492 + efx_net_stop(efx->net_dev);
1493 +
1494 +@@ -3277,40 +3301,6 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
1495 + efx_net_open(efx->net_dev);
1496 + efx_device_attach_if_not_resetting(efx);
1497 +
1498 +-#ifdef CONFIG_SFC_SRIOV
1499 +- if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
1500 +- struct efx_ef10_nic_data *nic_data = efx->nic_data;
1501 +- struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
1502 +-
1503 +- if (rc == -EPERM) {
1504 +- struct efx_nic *efx_pf;
1505 +-
1506 +- /* Switch to PF and change MAC address on vport */
1507 +- efx_pf = pci_get_drvdata(pci_dev_pf);
1508 +-
1509 +- rc = efx_ef10_sriov_set_vf_mac(efx_pf,
1510 +- nic_data->vf_index,
1511 +- efx->net_dev->dev_addr);
1512 +- } else if (!rc) {
1513 +- struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
1514 +- struct efx_ef10_nic_data *nic_data = efx_pf->nic_data;
1515 +- unsigned int i;
1516 +-
1517 +- /* MAC address successfully changed by VF (with MAC
1518 +- * spoofing) so update the parent PF if possible.
1519 +- */
1520 +- for (i = 0; i < efx_pf->vf_count; ++i) {
1521 +- struct ef10_vf *vf = nic_data->vf + i;
1522 +-
1523 +- if (vf->efx == efx) {
1524 +- ether_addr_copy(vf->mac,
1525 +- efx->net_dev->dev_addr);
1526 +- return 0;
1527 +- }
1528 +- }
1529 +- }
1530 +- } else
1531 +-#endif
1532 + if (rc == -EPERM) {
1533 + netif_err(efx, drv, efx->net_dev,
1534 + "Cannot change MAC address; use sfboot to enable"
1535 +diff --git a/drivers/net/ethernet/sfc/filter.h b/drivers/net/ethernet/sfc/filter.h
1536 +index 40b2af8bfb81c..2ac3c8f1b04b5 100644
1537 +--- a/drivers/net/ethernet/sfc/filter.h
1538 ++++ b/drivers/net/ethernet/sfc/filter.h
1539 +@@ -157,7 +157,8 @@ struct efx_filter_spec {
1540 + u32 flags:6;
1541 + u32 dmaq_id:12;
1542 + u32 rss_context;
1543 +- __be16 outer_vid __aligned(4); /* allow jhash2() of match values */
1544 ++ u32 vport_id;
1545 ++ __be16 outer_vid;
1546 + __be16 inner_vid;
1547 + u8 loc_mac[ETH_ALEN];
1548 + u8 rem_mac[ETH_ALEN];
1549 +diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c
1550 +index 2c09afac5beb4..36b46ddb67107 100644
1551 +--- a/drivers/net/ethernet/sfc/rx_common.c
1552 ++++ b/drivers/net/ethernet/sfc/rx_common.c
1553 +@@ -676,17 +676,17 @@ bool efx_filter_spec_equal(const struct efx_filter_spec *left,
1554 + (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX)))
1555 + return false;
1556 +
1557 +- return memcmp(&left->outer_vid, &right->outer_vid,
1558 ++ return memcmp(&left->vport_id, &right->vport_id,
1559 + sizeof(struct efx_filter_spec) -
1560 +- offsetof(struct efx_filter_spec, outer_vid)) == 0;
1561 ++ offsetof(struct efx_filter_spec, vport_id)) == 0;
1562 + }
1563 +
1564 + u32 efx_filter_spec_hash(const struct efx_filter_spec *spec)
1565 + {
1566 +- BUILD_BUG_ON(offsetof(struct efx_filter_spec, outer_vid) & 3);
1567 +- return jhash2((const u32 *)&spec->outer_vid,
1568 ++ BUILD_BUG_ON(offsetof(struct efx_filter_spec, vport_id) & 3);
1569 ++ return jhash2((const u32 *)&spec->vport_id,
1570 + (sizeof(struct efx_filter_spec) -
1571 +- offsetof(struct efx_filter_spec, outer_vid)) / 4,
1572 ++ offsetof(struct efx_filter_spec, vport_id)) / 4,
1573 + 0);
1574 + }
1575 +
1576 +diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
1577 +index a0f338cf14247..367878493e704 100644
1578 +--- a/drivers/net/hyperv/hyperv_net.h
1579 ++++ b/drivers/net/hyperv/hyperv_net.h
1580 +@@ -977,7 +977,8 @@ struct net_device_context {
1581 + u32 vf_alloc;
1582 + /* Serial number of the VF to team with */
1583 + u32 vf_serial;
1584 +-
1585 ++ /* completion variable to confirm vf association */
1586 ++ struct completion vf_add;
1587 + /* Is the current data path through the VF NIC? */
1588 + bool data_path_is_vf;
1589 +
1590 +diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
1591 +index 6a7ab930ef70d..d15da8287df32 100644
1592 +--- a/drivers/net/hyperv/netvsc.c
1593 ++++ b/drivers/net/hyperv/netvsc.c
1594 +@@ -1327,6 +1327,10 @@ static void netvsc_send_vf(struct net_device *ndev,
1595 +
1596 + net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
1597 + net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
1598 ++
1599 ++ if (net_device_ctx->vf_alloc)
1600 ++ complete(&net_device_ctx->vf_add);
1601 ++
1602 + netdev_info(ndev, "VF slot %u %s\n",
1603 + net_device_ctx->vf_serial,
1604 + net_device_ctx->vf_alloc ? "added" : "removed");
1605 +diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
1606 +index 18484370da0d4..f2020be43cfea 100644
1607 +--- a/drivers/net/hyperv/netvsc_drv.c
1608 ++++ b/drivers/net/hyperv/netvsc_drv.c
1609 +@@ -2290,6 +2290,7 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
1610 + {
1611 + struct device *parent = vf_netdev->dev.parent;
1612 + struct net_device_context *ndev_ctx;
1613 ++ struct net_device *ndev;
1614 + struct pci_dev *pdev;
1615 + u32 serial;
1616 +
1617 +@@ -2316,6 +2317,18 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
1618 + return hv_get_drvdata(ndev_ctx->device_ctx);
1619 + }
1620 +
1621 ++ /* Fallback path to check synthetic vf with
1622 ++ * help of mac addr
1623 ++ */
1624 ++ list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) {
1625 ++ ndev = hv_get_drvdata(ndev_ctx->device_ctx);
1626 ++ if (ether_addr_equal(vf_netdev->perm_addr, ndev->perm_addr)) {
1627 ++ netdev_notice(vf_netdev,
1628 ++ "falling back to mac addr based matching\n");
1629 ++ return ndev;
1630 ++ }
1631 ++ }
1632 ++
1633 + netdev_notice(vf_netdev,
1634 + "no netdev found for vf serial:%u\n", serial);
1635 + return NULL;
1636 +@@ -2406,6 +2419,11 @@ static int netvsc_vf_changed(struct net_device *vf_netdev)
1637 + return NOTIFY_OK;
1638 + net_device_ctx->data_path_is_vf = vf_is_up;
1639 +
1640 ++ if (vf_is_up && !net_device_ctx->vf_alloc) {
1641 ++ netdev_info(ndev, "Waiting for the VF association from host\n");
1642 ++ wait_for_completion(&net_device_ctx->vf_add);
1643 ++ }
1644 ++
1645 + netvsc_switch_datapath(ndev, vf_is_up);
1646 + netdev_info(ndev, "Data path switched %s VF: %s\n",
1647 + vf_is_up ? "to" : "from", vf_netdev->name);
1648 +@@ -2429,6 +2447,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
1649 +
1650 + netvsc_vf_setxdp(vf_netdev, NULL);
1651 +
1652 ++ reinit_completion(&net_device_ctx->vf_add);
1653 + netdev_rx_handler_unregister(vf_netdev);
1654 + netdev_upper_dev_unlink(vf_netdev, ndev);
1655 + RCU_INIT_POINTER(net_device_ctx->vf_netdev, NULL);
1656 +@@ -2466,6 +2485,7 @@ static int netvsc_probe(struct hv_device *dev,
1657 +
1658 + INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
1659 +
1660 ++ init_completion(&net_device_ctx->vf_add);
1661 + spin_lock_init(&net_device_ctx->lock);
1662 + INIT_LIST_HEAD(&net_device_ctx->reconfig_events);
1663 + INIT_DELAYED_WORK(&net_device_ctx->vf_takeover, netvsc_vf_setup);
1664 +diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
1665 +index 3a8849716459a..db651649e0b80 100644
1666 +--- a/drivers/net/phy/dp83822.c
1667 ++++ b/drivers/net/phy/dp83822.c
1668 +@@ -268,8 +268,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
1669 + DP83822_EEE_ERROR_CHANGE_INT_EN);
1670 +
1671 + if (!dp83822->fx_enabled)
1672 +- misr_status |= DP83822_MDI_XOVER_INT_EN |
1673 +- DP83822_ANEG_ERR_INT_EN |
1674 ++ misr_status |= DP83822_ANEG_ERR_INT_EN |
1675 + DP83822_WOL_PKT_INT_EN;
1676 +
1677 + err = phy_write(phydev, MII_DP83822_MISR2, misr_status);
1678 +diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
1679 +index f86acad0aad44..c8031e297faf4 100644
1680 +--- a/drivers/net/phy/dp83867.c
1681 ++++ b/drivers/net/phy/dp83867.c
1682 +@@ -757,6 +757,14 @@ static int dp83867_config_init(struct phy_device *phydev)
1683 + else
1684 + val &= ~DP83867_SGMII_TYPE;
1685 + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_SGMIICTL, val);
1686 ++
1687 ++ /* This is a SW workaround for link instability if RX_CTRL is
1688 ++ * not strapped to mode 3 or 4 in HW. This is required for SGMII
1689 ++ * in addition to clearing bit 7, handled above.
1690 ++ */
1691 ++ if (dp83867->rxctrl_strap_quirk)
1692 ++ phy_set_bits_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4,
1693 ++ BIT(8));
1694 + }
1695 +
1696 + val = phy_read(phydev, DP83867_CFG3);
1697 +diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
1698 +index 43ddbe61dc58e..935cd296887f2 100644
1699 +--- a/drivers/net/usb/cdc_ether.c
1700 ++++ b/drivers/net/usb/cdc_ether.c
1701 +@@ -763,6 +763,13 @@ static const struct usb_device_id products[] = {
1702 + },
1703 + #endif
1704 +
1705 ++/* Lenovo ThinkPad OneLink+ Dock (based on Realtek RTL8153) */
1706 ++{
1707 ++ USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3054, USB_CLASS_COMM,
1708 ++ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
1709 ++ .driver_info = 0,
1710 ++},
1711 ++
1712 + /* ThinkPad USB-C Dock (based on Realtek RTL8153) */
1713 + {
1714 + USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM,
1715 +diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
1716 +index a526242a3e36d..f9a79d67d6d4f 100644
1717 +--- a/drivers/net/usb/r8152.c
1718 ++++ b/drivers/net/usb/r8152.c
1719 +@@ -6870,6 +6870,7 @@ static const struct usb_device_id rtl8152_table[] = {
1720 + {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)},
1721 + {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
1722 + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
1723 ++ {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054)},
1724 + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)},
1725 + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069)},
1726 + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082)},
1727 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
1728 +index e9c13804760e7..3f106771d15be 100644
1729 +--- a/drivers/nvme/host/core.c
1730 ++++ b/drivers/nvme/host/core.c
1731 +@@ -3232,8 +3232,12 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1732 + return ret;
1733 +
1734 + if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
1735 ++ /*
1736 ++ * Do not return errors unless we are in a controller reset,
1737 ++ * the controller works perfectly fine without hwmon.
1738 ++ */
1739 + ret = nvme_hwmon_init(ctrl);
1740 +- if (ret < 0)
1741 ++ if (ret == -EINTR)
1742 + return ret;
1743 + }
1744 +
1745 +@@ -4485,6 +4489,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
1746 +
1747 + void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
1748 + {
1749 ++ nvme_hwmon_exit(ctrl);
1750 + nvme_fault_inject_fini(&ctrl->fault_inject);
1751 + dev_pm_qos_hide_latency_tolerance(ctrl->device);
1752 + cdev_device_del(&ctrl->cdev, ctrl->device);
1753 +diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c
1754 +index 552dbc04567bc..9e6e56c20ec99 100644
1755 +--- a/drivers/nvme/host/hwmon.c
1756 ++++ b/drivers/nvme/host/hwmon.c
1757 +@@ -12,7 +12,7 @@
1758 +
1759 + struct nvme_hwmon_data {
1760 + struct nvme_ctrl *ctrl;
1761 +- struct nvme_smart_log log;
1762 ++ struct nvme_smart_log *log;
1763 + struct mutex read_lock;
1764 + };
1765 +
1766 +@@ -60,14 +60,14 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,
1767 + static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data)
1768 + {
1769 + return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
1770 +- NVME_CSI_NVM, &data->log, sizeof(data->log), 0);
1771 ++ NVME_CSI_NVM, data->log, sizeof(*data->log), 0);
1772 + }
1773 +
1774 + static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
1775 + u32 attr, int channel, long *val)
1776 + {
1777 + struct nvme_hwmon_data *data = dev_get_drvdata(dev);
1778 +- struct nvme_smart_log *log = &data->log;
1779 ++ struct nvme_smart_log *log = data->log;
1780 + int temp;
1781 + int err;
1782 +
1783 +@@ -163,7 +163,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
1784 + case hwmon_temp_max:
1785 + case hwmon_temp_min:
1786 + if ((!channel && data->ctrl->wctemp) ||
1787 +- (channel && data->log.temp_sensor[channel - 1])) {
1788 ++ (channel && data->log->temp_sensor[channel - 1])) {
1789 + if (data->ctrl->quirks &
1790 + NVME_QUIRK_NO_TEMP_THRESH_CHANGE)
1791 + return 0444;
1792 +@@ -176,7 +176,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
1793 + break;
1794 + case hwmon_temp_input:
1795 + case hwmon_temp_label:
1796 +- if (!channel || data->log.temp_sensor[channel - 1])
1797 ++ if (!channel || data->log->temp_sensor[channel - 1])
1798 + return 0444;
1799 + break;
1800 + default:
1801 +@@ -223,33 +223,57 @@ static const struct hwmon_chip_info nvme_hwmon_chip_info = {
1802 +
1803 + int nvme_hwmon_init(struct nvme_ctrl *ctrl)
1804 + {
1805 +- struct device *dev = ctrl->dev;
1806 ++ struct device *dev = ctrl->device;
1807 + struct nvme_hwmon_data *data;
1808 + struct device *hwmon;
1809 + int err;
1810 +
1811 +- data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
1812 ++ data = kzalloc(sizeof(*data), GFP_KERNEL);
1813 + if (!data)
1814 +- return 0;
1815 ++ return -ENOMEM;
1816 ++
1817 ++ data->log = kzalloc(sizeof(*data->log), GFP_KERNEL);
1818 ++ if (!data->log) {
1819 ++ err = -ENOMEM;
1820 ++ goto err_free_data;
1821 ++ }
1822 +
1823 + data->ctrl = ctrl;
1824 + mutex_init(&data->read_lock);
1825 +
1826 + err = nvme_hwmon_get_smart_log(data);
1827 + if (err) {
1828 +- dev_warn(ctrl->device,
1829 +- "Failed to read smart log (error %d)\n", err);
1830 +- devm_kfree(dev, data);
1831 +- return err;
1832 ++ dev_warn(dev, "Failed to read smart log (error %d)\n", err);
1833 ++ goto err_free_log;
1834 + }
1835 +
1836 +- hwmon = devm_hwmon_device_register_with_info(dev, "nvme", data,
1837 +- &nvme_hwmon_chip_info,
1838 +- NULL);
1839 ++ hwmon = hwmon_device_register_with_info(dev, "nvme",
1840 ++ data, &nvme_hwmon_chip_info,
1841 ++ NULL);
1842 + if (IS_ERR(hwmon)) {
1843 + dev_warn(dev, "Failed to instantiate hwmon device\n");
1844 +- devm_kfree(dev, data);
1845 ++ err = PTR_ERR(hwmon);
1846 ++ goto err_free_log;
1847 + }
1848 +-
1849 ++ ctrl->hwmon_device = hwmon;
1850 + return 0;
1851 ++
1852 ++err_free_log:
1853 ++ kfree(data->log);
1854 ++err_free_data:
1855 ++ kfree(data);
1856 ++ return err;
1857 ++}
1858 ++
1859 ++void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
1860 ++{
1861 ++ if (ctrl->hwmon_device) {
1862 ++ struct nvme_hwmon_data *data =
1863 ++ dev_get_drvdata(ctrl->hwmon_device);
1864 ++
1865 ++ hwmon_device_unregister(ctrl->hwmon_device);
1866 ++ ctrl->hwmon_device = NULL;
1867 ++ kfree(data->log);
1868 ++ kfree(data);
1869 ++ }
1870 + }
1871 +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
1872 +index 58cf9e39d613e..abae7ef2ac511 100644
1873 +--- a/drivers/nvme/host/nvme.h
1874 ++++ b/drivers/nvme/host/nvme.h
1875 +@@ -257,6 +257,9 @@ struct nvme_ctrl {
1876 + struct rw_semaphore namespaces_rwsem;
1877 + struct device ctrl_device;
1878 + struct device *device; /* char device */
1879 ++#ifdef CONFIG_NVME_HWMON
1880 ++ struct device *hwmon_device;
1881 ++#endif
1882 + struct cdev cdev;
1883 + struct work_struct reset_work;
1884 + struct work_struct delete_work;
1885 +@@ -876,11 +879,16 @@ static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
1886 +
1887 + #ifdef CONFIG_NVME_HWMON
1888 + int nvme_hwmon_init(struct nvme_ctrl *ctrl);
1889 ++void nvme_hwmon_exit(struct nvme_ctrl *ctrl);
1890 + #else
1891 + static inline int nvme_hwmon_init(struct nvme_ctrl *ctrl)
1892 + {
1893 + return 0;
1894 + }
1895 ++
1896 ++static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
1897 ++{
1898 ++}
1899 + #endif
1900 +
1901 + u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1902 +diff --git a/drivers/xen/gntdev-common.h b/drivers/xen/gntdev-common.h
1903 +index 40ef379c28ab0..9c286b2a19001 100644
1904 +--- a/drivers/xen/gntdev-common.h
1905 ++++ b/drivers/xen/gntdev-common.h
1906 +@@ -44,9 +44,10 @@ struct gntdev_unmap_notify {
1907 + };
1908 +
1909 + struct gntdev_grant_map {
1910 ++ atomic_t in_use;
1911 + struct mmu_interval_notifier notifier;
1912 ++ bool notifier_init;
1913 + struct list_head next;
1914 +- struct vm_area_struct *vma;
1915 + int index;
1916 + int count;
1917 + int flags;
1918 +diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
1919 +index 54fee4087bf10..ff195b5717630 100644
1920 +--- a/drivers/xen/gntdev.c
1921 ++++ b/drivers/xen/gntdev.c
1922 +@@ -276,6 +276,9 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
1923 + */
1924 + }
1925 +
1926 ++ if (use_ptemod && map->notifier_init)
1927 ++ mmu_interval_notifier_remove(&map->notifier);
1928 ++
1929 + if (map->notify.flags & UNMAP_NOTIFY_SEND_EVENT) {
1930 + notify_remote_via_evtchn(map->notify.event);
1931 + evtchn_put(map->notify.event);
1932 +@@ -288,21 +291,14 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
1933 + static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)
1934 + {
1935 + struct gntdev_grant_map *map = data;
1936 +- unsigned int pgnr = (addr - map->vma->vm_start) >> PAGE_SHIFT;
1937 +- int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte;
1938 ++ unsigned int pgnr = (addr - map->pages_vm_start) >> PAGE_SHIFT;
1939 ++ int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte |
1940 ++ (1 << _GNTMAP_guest_avail0);
1941 + u64 pte_maddr;
1942 +
1943 + BUG_ON(pgnr >= map->count);
1944 + pte_maddr = arbitrary_virt_to_machine(pte).maddr;
1945 +
1946 +- /*
1947 +- * Set the PTE as special to force get_user_pages_fast() fall
1948 +- * back to the slow path. If this is not supported as part of
1949 +- * the grant map, it will be done afterwards.
1950 +- */
1951 +- if (xen_feature(XENFEAT_gnttab_map_avail_bits))
1952 +- flags |= (1 << _GNTMAP_guest_avail0);
1953 +-
1954 + gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr, flags,
1955 + map->grants[pgnr].ref,
1956 + map->grants[pgnr].domid);
1957 +@@ -311,14 +307,6 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)
1958 + return 0;
1959 + }
1960 +
1961 +-#ifdef CONFIG_X86
1962 +-static int set_grant_ptes_as_special(pte_t *pte, unsigned long addr, void *data)
1963 +-{
1964 +- set_pte_at(current->mm, addr, pte, pte_mkspecial(*pte));
1965 +- return 0;
1966 +-}
1967 +-#endif
1968 +-
1969 + int gntdev_map_grant_pages(struct gntdev_grant_map *map)
1970 + {
1971 + size_t alloced = 0;
1972 +@@ -493,11 +481,7 @@ static void gntdev_vma_close(struct vm_area_struct *vma)
1973 + struct gntdev_priv *priv = file->private_data;
1974 +
1975 + pr_debug("gntdev_vma_close %p\n", vma);
1976 +- if (use_ptemod) {
1977 +- WARN_ON(map->vma != vma);
1978 +- mmu_interval_notifier_remove(&map->notifier);
1979 +- map->vma = NULL;
1980 +- }
1981 ++
1982 + vma->vm_private_data = NULL;
1983 + gntdev_put_map(priv, map);
1984 + }
1985 +@@ -525,29 +509,30 @@ static bool gntdev_invalidate(struct mmu_interval_notifier *mn,
1986 + struct gntdev_grant_map *map =
1987 + container_of(mn, struct gntdev_grant_map, notifier);
1988 + unsigned long mstart, mend;
1989 ++ unsigned long map_start, map_end;
1990 +
1991 + if (!mmu_notifier_range_blockable(range))
1992 + return false;
1993 +
1994 ++ map_start = map->pages_vm_start;
1995 ++ map_end = map->pages_vm_start + (map->count << PAGE_SHIFT);
1996 ++
1997 + /*
1998 + * If the VMA is split or otherwise changed the notifier is not
1999 + * updated, but we don't want to process VA's outside the modified
2000 + * VMA. FIXME: It would be much more understandable to just prevent
2001 + * modifying the VMA in the first place.
2002 + */
2003 +- if (map->vma->vm_start >= range->end ||
2004 +- map->vma->vm_end <= range->start)
2005 ++ if (map_start >= range->end || map_end <= range->start)
2006 + return true;
2007 +
2008 +- mstart = max(range->start, map->vma->vm_start);
2009 +- mend = min(range->end, map->vma->vm_end);
2010 ++ mstart = max(range->start, map_start);
2011 ++ mend = min(range->end, map_end);
2012 + pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n",
2013 +- map->index, map->count,
2014 +- map->vma->vm_start, map->vma->vm_end,
2015 +- range->start, range->end, mstart, mend);
2016 +- unmap_grant_pages(map,
2017 +- (mstart - map->vma->vm_start) >> PAGE_SHIFT,
2018 +- (mend - mstart) >> PAGE_SHIFT);
2019 ++ map->index, map->count, map_start, map_end,
2020 ++ range->start, range->end, mstart, mend);
2021 ++ unmap_grant_pages(map, (mstart - map_start) >> PAGE_SHIFT,
2022 ++ (mend - mstart) >> PAGE_SHIFT);
2023 +
2024 + return true;
2025 + }
2026 +@@ -1027,18 +1012,15 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
2027 + return -EINVAL;
2028 +
2029 + pr_debug("map %d+%d at %lx (pgoff %lx)\n",
2030 +- index, count, vma->vm_start, vma->vm_pgoff);
2031 ++ index, count, vma->vm_start, vma->vm_pgoff);
2032 +
2033 + mutex_lock(&priv->lock);
2034 + map = gntdev_find_map_index(priv, index, count);
2035 + if (!map)
2036 + goto unlock_out;
2037 +- if (use_ptemod && map->vma)
2038 ++ if (!atomic_add_unless(&map->in_use, 1, 1))
2039 + goto unlock_out;
2040 +- if (atomic_read(&map->live_grants)) {
2041 +- err = -EAGAIN;
2042 +- goto unlock_out;
2043 +- }
2044 ++
2045 + refcount_inc(&map->users);
2046 +
2047 + vma->vm_ops = &gntdev_vmops;
2048 +@@ -1059,15 +1041,16 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
2049 + map->flags |= GNTMAP_readonly;
2050 + }
2051 +
2052 ++ map->pages_vm_start = vma->vm_start;
2053 ++
2054 + if (use_ptemod) {
2055 +- map->vma = vma;
2056 + err = mmu_interval_notifier_insert_locked(
2057 + &map->notifier, vma->vm_mm, vma->vm_start,
2058 + vma->vm_end - vma->vm_start, &gntdev_mmu_ops);
2059 +- if (err) {
2060 +- map->vma = NULL;
2061 ++ if (err)
2062 + goto out_unlock_put;
2063 +- }
2064 ++
2065 ++ map->notifier_init = true;
2066 + }
2067 + mutex_unlock(&priv->lock);
2068 +
2069 +@@ -1084,7 +1067,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
2070 + */
2071 + mmu_interval_read_begin(&map->notifier);
2072 +
2073 +- map->pages_vm_start = vma->vm_start;
2074 + err = apply_to_page_range(vma->vm_mm, vma->vm_start,
2075 + vma->vm_end - vma->vm_start,
2076 + find_grant_ptes, map);
2077 +@@ -1102,23 +1084,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
2078 + err = vm_map_pages_zero(vma, map->pages, map->count);
2079 + if (err)
2080 + goto out_put_map;
2081 +- } else {
2082 +-#ifdef CONFIG_X86
2083 +- /*
2084 +- * If the PTEs were not made special by the grant map
2085 +- * hypercall, do so here.
2086 +- *
2087 +- * This is racy since the mapping is already visible
2088 +- * to userspace but userspace should be well-behaved
2089 +- * enough to not touch it until the mmap() call
2090 +- * returns.
2091 +- */
2092 +- if (!xen_feature(XENFEAT_gnttab_map_avail_bits)) {
2093 +- apply_to_page_range(vma->vm_mm, vma->vm_start,
2094 +- vma->vm_end - vma->vm_start,
2095 +- set_grant_ptes_as_special, NULL);
2096 +- }
2097 +-#endif
2098 + }
2099 +
2100 + return 0;
2101 +@@ -1130,13 +1095,8 @@ unlock_out:
2102 + out_unlock_put:
2103 + mutex_unlock(&priv->lock);
2104 + out_put_map:
2105 +- if (use_ptemod) {
2106 ++ if (use_ptemod)
2107 + unmap_grant_pages(map, 0, map->count);
2108 +- if (map->vma) {
2109 +- mmu_interval_notifier_remove(&map->notifier);
2110 +- map->vma = NULL;
2111 +- }
2112 +- }
2113 + gntdev_put_map(priv, map);
2114 + return err;
2115 + }
2116 +diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
2117 +index baff31a147e7d..92cb16c0e5ee1 100644
2118 +--- a/fs/btrfs/backref.c
2119 ++++ b/fs/btrfs/backref.c
2120 +@@ -137,6 +137,7 @@ struct share_check {
2121 + u64 root_objectid;
2122 + u64 inum;
2123 + int share_count;
2124 ++ bool have_delayed_delete_refs;
2125 + };
2126 +
2127 + static inline int extent_is_shared(struct share_check *sc)
2128 +@@ -817,16 +818,11 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
2129 + struct preftrees *preftrees, struct share_check *sc)
2130 + {
2131 + struct btrfs_delayed_ref_node *node;
2132 +- struct btrfs_delayed_extent_op *extent_op = head->extent_op;
2133 + struct btrfs_key key;
2134 +- struct btrfs_key tmp_op_key;
2135 + struct rb_node *n;
2136 + int count;
2137 + int ret = 0;
2138 +
2139 +- if (extent_op && extent_op->update_key)
2140 +- btrfs_disk_key_to_cpu(&tmp_op_key, &extent_op->key);
2141 +-
2142 + spin_lock(&head->lock);
2143 + for (n = rb_first_cached(&head->ref_tree); n; n = rb_next(n)) {
2144 + node = rb_entry(n, struct btrfs_delayed_ref_node,
2145 +@@ -852,10 +848,16 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
2146 + case BTRFS_TREE_BLOCK_REF_KEY: {
2147 + /* NORMAL INDIRECT METADATA backref */
2148 + struct btrfs_delayed_tree_ref *ref;
2149 ++ struct btrfs_key *key_ptr = NULL;
2150 ++
2151 ++ if (head->extent_op && head->extent_op->update_key) {
2152 ++ btrfs_disk_key_to_cpu(&key, &head->extent_op->key);
2153 ++ key_ptr = &key;
2154 ++ }
2155 +
2156 + ref = btrfs_delayed_node_to_tree_ref(node);
2157 + ret = add_indirect_ref(fs_info, preftrees, ref->root,
2158 +- &tmp_op_key, ref->level + 1,
2159 ++ key_ptr, ref->level + 1,
2160 + node->bytenr, count, sc,
2161 + GFP_ATOMIC);
2162 + break;
2163 +@@ -881,13 +883,22 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
2164 + key.offset = ref->offset;
2165 +
2166 + /*
2167 +- * Found a inum that doesn't match our known inum, we
2168 +- * know it's shared.
2169 ++ * If we have a share check context and a reference for
2170 ++ * another inode, we can't exit immediately. This is
2171 ++ * because even if this is a BTRFS_ADD_DELAYED_REF
2172 ++ * reference we may find next a BTRFS_DROP_DELAYED_REF
2173 ++ * which cancels out this ADD reference.
2174 ++ *
2175 ++ * If this is a DROP reference and there was no previous
2176 ++ * ADD reference, then we need to signal that when we
2177 ++ * process references from the extent tree (through
2178 ++ * add_inline_refs() and add_keyed_refs()), we should
2179 ++ * not exit early if we find a reference for another
2180 ++ * inode, because one of the delayed DROP references
2181 ++ * may cancel that reference in the extent tree.
2182 + */
2183 +- if (sc && sc->inum && ref->objectid != sc->inum) {
2184 +- ret = BACKREF_FOUND_SHARED;
2185 +- goto out;
2186 +- }
2187 ++ if (sc && count < 0)
2188 ++ sc->have_delayed_delete_refs = true;
2189 +
2190 + ret = add_indirect_ref(fs_info, preftrees, ref->root,
2191 + &key, 0, node->bytenr, count, sc,
2192 +@@ -917,7 +928,7 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
2193 + }
2194 + if (!ret)
2195 + ret = extent_is_shared(sc);
2196 +-out:
2197 ++
2198 + spin_unlock(&head->lock);
2199 + return ret;
2200 + }
2201 +@@ -1020,7 +1031,8 @@ static int add_inline_refs(const struct btrfs_fs_info *fs_info,
2202 + key.type = BTRFS_EXTENT_DATA_KEY;
2203 + key.offset = btrfs_extent_data_ref_offset(leaf, dref);
2204 +
2205 +- if (sc && sc->inum && key.objectid != sc->inum) {
2206 ++ if (sc && sc->inum && key.objectid != sc->inum &&
2207 ++ !sc->have_delayed_delete_refs) {
2208 + ret = BACKREF_FOUND_SHARED;
2209 + break;
2210 + }
2211 +@@ -1030,6 +1042,7 @@ static int add_inline_refs(const struct btrfs_fs_info *fs_info,
2212 + ret = add_indirect_ref(fs_info, preftrees, root,
2213 + &key, 0, bytenr, count,
2214 + sc, GFP_NOFS);
2215 ++
2216 + break;
2217 + }
2218 + default:
2219 +@@ -1119,7 +1132,8 @@ static int add_keyed_refs(struct btrfs_fs_info *fs_info,
2220 + key.type = BTRFS_EXTENT_DATA_KEY;
2221 + key.offset = btrfs_extent_data_ref_offset(leaf, dref);
2222 +
2223 +- if (sc && sc->inum && key.objectid != sc->inum) {
2224 ++ if (sc && sc->inum && key.objectid != sc->inum &&
2225 ++ !sc->have_delayed_delete_refs) {
2226 + ret = BACKREF_FOUND_SHARED;
2227 + break;
2228 + }
2229 +@@ -1542,6 +1556,7 @@ int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
2230 + .root_objectid = root->root_key.objectid,
2231 + .inum = inum,
2232 + .share_count = 0,
2233 ++ .have_delayed_delete_refs = false,
2234 + };
2235 +
2236 + ulist_init(roots);
2237 +@@ -1576,6 +1591,7 @@ int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
2238 + break;
2239 + bytenr = node->val;
2240 + shared.share_count = 0;
2241 ++ shared.have_delayed_delete_refs = false;
2242 + cond_resched();
2243 + }
2244 +
2245 +diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
2246 +index bc957e6ca48b9..f442ef8b65dad 100644
2247 +--- a/fs/cifs/cifsfs.c
2248 ++++ b/fs/cifs/cifsfs.c
2249 +@@ -1221,8 +1221,11 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
2250 + ssize_t rc;
2251 + struct cifsFileInfo *cfile = dst_file->private_data;
2252 +
2253 +- if (cfile->swapfile)
2254 +- return -EOPNOTSUPP;
2255 ++ if (cfile->swapfile) {
2256 ++ rc = -EOPNOTSUPP;
2257 ++ free_xid(xid);
2258 ++ return rc;
2259 ++ }
2260 +
2261 + rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
2262 + len, flags);
2263 +diff --git a/fs/cifs/file.c b/fs/cifs/file.c
2264 +index a648146e49cfa..144064dc0d38a 100644
2265 +--- a/fs/cifs/file.c
2266 ++++ b/fs/cifs/file.c
2267 +@@ -1735,11 +1735,13 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
2268 + struct cifsFileInfo *cfile;
2269 + __u32 type;
2270 +
2271 +- rc = -EACCES;
2272 + xid = get_xid();
2273 +
2274 +- if (!(fl->fl_flags & FL_FLOCK))
2275 +- return -ENOLCK;
2276 ++ if (!(fl->fl_flags & FL_FLOCK)) {
2277 ++ rc = -ENOLCK;
2278 ++ free_xid(xid);
2279 ++ return rc;
2280 ++ }
2281 +
2282 + cfile = (struct cifsFileInfo *)file->private_data;
2283 + tcon = tlink_tcon(cfile->tlink);
2284 +@@ -1758,8 +1760,9 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
2285 + * if no lock or unlock then nothing to do since we do not
2286 + * know what it is
2287 + */
2288 ++ rc = -EOPNOTSUPP;
2289 + free_xid(xid);
2290 +- return -EOPNOTSUPP;
2291 ++ return rc;
2292 + }
2293 +
2294 + rc = cifs_setlk(file, fl, type, wait_flag, posix_lck, lock, unlock,
2295 +diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
2296 +index d58c5ffeca0d9..cf6fd138d8d5c 100644
2297 +--- a/fs/cifs/sess.c
2298 ++++ b/fs/cifs/sess.c
2299 +@@ -306,6 +306,7 @@ out:
2300 + cifs_put_tcp_session(chan->server, 0);
2301 + unload_nls(vol.local_nls);
2302 +
2303 ++ free_xid(xid);
2304 + return rc;
2305 + }
2306 +
2307 +diff --git a/fs/fcntl.c b/fs/fcntl.c
2308 +index 71b43538fa44c..fcf34f83bf6a8 100644
2309 +--- a/fs/fcntl.c
2310 ++++ b/fs/fcntl.c
2311 +@@ -148,12 +148,17 @@ void f_delown(struct file *filp)
2312 +
2313 + pid_t f_getown(struct file *filp)
2314 + {
2315 +- pid_t pid;
2316 +- read_lock(&filp->f_owner.lock);
2317 +- pid = pid_vnr(filp->f_owner.pid);
2318 +- if (filp->f_owner.pid_type == PIDTYPE_PGID)
2319 +- pid = -pid;
2320 +- read_unlock(&filp->f_owner.lock);
2321 ++ pid_t pid = 0;
2322 ++
2323 ++ read_lock_irq(&filp->f_owner.lock);
2324 ++ rcu_read_lock();
2325 ++ if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) {
2326 ++ pid = pid_vnr(filp->f_owner.pid);
2327 ++ if (filp->f_owner.pid_type == PIDTYPE_PGID)
2328 ++ pid = -pid;
2329 ++ }
2330 ++ rcu_read_unlock();
2331 ++ read_unlock_irq(&filp->f_owner.lock);
2332 + return pid;
2333 + }
2334 +
2335 +@@ -200,11 +205,14 @@ static int f_setown_ex(struct file *filp, unsigned long arg)
2336 + static int f_getown_ex(struct file *filp, unsigned long arg)
2337 + {
2338 + struct f_owner_ex __user *owner_p = (void __user *)arg;
2339 +- struct f_owner_ex owner;
2340 ++ struct f_owner_ex owner = {};
2341 + int ret = 0;
2342 +
2343 +- read_lock(&filp->f_owner.lock);
2344 +- owner.pid = pid_vnr(filp->f_owner.pid);
2345 ++ read_lock_irq(&filp->f_owner.lock);
2346 ++ rcu_read_lock();
2347 ++ if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type))
2348 ++ owner.pid = pid_vnr(filp->f_owner.pid);
2349 ++ rcu_read_unlock();
2350 + switch (filp->f_owner.pid_type) {
2351 + case PIDTYPE_PID:
2352 + owner.type = F_OWNER_TID;
2353 +@@ -223,7 +231,7 @@ static int f_getown_ex(struct file *filp, unsigned long arg)
2354 + ret = -EINVAL;
2355 + break;
2356 + }
2357 +- read_unlock(&filp->f_owner.lock);
2358 ++ read_unlock_irq(&filp->f_owner.lock);
2359 +
2360 + if (!ret) {
2361 + ret = copy_to_user(owner_p, &owner, sizeof(owner));
2362 +@@ -241,10 +249,10 @@ static int f_getowner_uids(struct file *filp, unsigned long arg)
2363 + uid_t src[2];
2364 + int err;
2365 +
2366 +- read_lock(&filp->f_owner.lock);
2367 ++ read_lock_irq(&filp->f_owner.lock);
2368 + src[0] = from_kuid(user_ns, filp->f_owner.uid);
2369 + src[1] = from_kuid(user_ns, filp->f_owner.euid);
2370 +- read_unlock(&filp->f_owner.lock);
2371 ++ read_unlock_irq(&filp->f_owner.lock);
2372 +
2373 + err = put_user(src[0], &dst[0]);
2374 + err |= put_user(src[1], &dst[1]);
2375 +diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
2376 +index c46bf7f581a14..856474b0a1ae7 100644
2377 +--- a/fs/ocfs2/namei.c
2378 ++++ b/fs/ocfs2/namei.c
2379 +@@ -231,6 +231,7 @@ static int ocfs2_mknod(struct inode *dir,
2380 + handle_t *handle = NULL;
2381 + struct ocfs2_super *osb;
2382 + struct ocfs2_dinode *dirfe;
2383 ++ struct ocfs2_dinode *fe = NULL;
2384 + struct buffer_head *new_fe_bh = NULL;
2385 + struct inode *inode = NULL;
2386 + struct ocfs2_alloc_context *inode_ac = NULL;
2387 +@@ -381,6 +382,7 @@ static int ocfs2_mknod(struct inode *dir,
2388 + goto leave;
2389 + }
2390 +
2391 ++ fe = (struct ocfs2_dinode *) new_fe_bh->b_data;
2392 + if (S_ISDIR(mode)) {
2393 + status = ocfs2_fill_new_dir(osb, handle, dir, inode,
2394 + new_fe_bh, data_ac, meta_ac);
2395 +@@ -453,8 +455,11 @@ roll_back:
2396 + leave:
2397 + if (status < 0 && did_quota_inode)
2398 + dquot_free_inode(inode);
2399 +- if (handle)
2400 ++ if (handle) {
2401 ++ if (status < 0 && fe)
2402 ++ ocfs2_set_links_count(fe, 0);
2403 + ocfs2_commit_trans(osb, handle);
2404 ++ }
2405 +
2406 + ocfs2_inode_unlock(dir, 1);
2407 + if (did_block_signals)
2408 +@@ -631,18 +636,9 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
2409 + return status;
2410 + }
2411 +
2412 +- status = __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
2413 ++ return __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
2414 + parent_fe_bh, handle, inode_ac,
2415 + fe_blkno, suballoc_loc, suballoc_bit);
2416 +- if (status < 0) {
2417 +- u64 bg_blkno = ocfs2_which_suballoc_group(fe_blkno, suballoc_bit);
2418 +- int tmp = ocfs2_free_suballoc_bits(handle, inode_ac->ac_inode,
2419 +- inode_ac->ac_bh, suballoc_bit, bg_blkno, 1);
2420 +- if (tmp)
2421 +- mlog_errno(tmp);
2422 +- }
2423 +-
2424 +- return status;
2425 + }
2426 +
2427 + static int ocfs2_mkdir(struct inode *dir,
2428 +@@ -2023,8 +2019,11 @@ bail:
2429 + ocfs2_clusters_to_bytes(osb->sb, 1));
2430 + if (status < 0 && did_quota_inode)
2431 + dquot_free_inode(inode);
2432 +- if (handle)
2433 ++ if (handle) {
2434 ++ if (status < 0 && fe)
2435 ++ ocfs2_set_links_count(fe, 0);
2436 + ocfs2_commit_trans(osb, handle);
2437 ++ }
2438 +
2439 + ocfs2_inode_unlock(dir, 1);
2440 + if (did_block_signals)
2441 +diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
2442 +index ef18f0d71b11b..8b75a04836b63 100644
2443 +--- a/fs/proc/task_mmu.c
2444 ++++ b/fs/proc/task_mmu.c
2445 +@@ -951,7 +951,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
2446 + vma = vma->vm_next;
2447 + }
2448 +
2449 +- show_vma_header_prefix(m, priv->mm->mmap->vm_start,
2450 ++ show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0,
2451 + last_vma_end, 0, 0, 0, 0);
2452 + seq_pad(m, ' ');
2453 + seq_puts(m, "[rollup]\n");
2454 +diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
2455 +index 896e563e2c181..9cb0a3d7874f2 100644
2456 +--- a/include/linux/kvm_host.h
2457 ++++ b/include/linux/kvm_host.h
2458 +@@ -911,6 +911,8 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
2459 + struct kvm_enable_cap *cap);
2460 + long kvm_arch_vm_ioctl(struct file *filp,
2461 + unsigned int ioctl, unsigned long arg);
2462 ++long kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
2463 ++ unsigned long arg);
2464 +
2465 + int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
2466 + int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
2467 +diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
2468 +index 42df06c6b19ce..ef870d1f4f5f7 100644
2469 +--- a/include/linux/mmc/card.h
2470 ++++ b/include/linux/mmc/card.h
2471 +@@ -270,6 +270,7 @@ struct mmc_card {
2472 + #define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
2473 + #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */
2474 + #define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */
2475 ++#define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14) /* Disable broken SD discard support */
2476 +
2477 + bool reenable_cmdq; /* Re-enable Command Queue */
2478 +
2479 +diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
2480 +index bed2387af456d..e7e8c318925de 100644
2481 +--- a/include/net/sch_generic.h
2482 ++++ b/include/net/sch_generic.h
2483 +@@ -1178,7 +1178,6 @@ static inline void __qdisc_reset_queue(struct qdisc_skb_head *qh)
2484 + static inline void qdisc_reset_queue(struct Qdisc *sch)
2485 + {
2486 + __qdisc_reset_queue(&sch->q);
2487 +- sch->qstats.backlog = 0;
2488 + }
2489 +
2490 + static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
2491 +diff --git a/include/net/sock_reuseport.h b/include/net/sock_reuseport.h
2492 +index 505f1e18e9bf9..3eac185ae2e8a 100644
2493 +--- a/include/net/sock_reuseport.h
2494 ++++ b/include/net/sock_reuseport.h
2495 +@@ -38,21 +38,20 @@ extern struct sock *reuseport_select_sock(struct sock *sk,
2496 + extern int reuseport_attach_prog(struct sock *sk, struct bpf_prog *prog);
2497 + extern int reuseport_detach_prog(struct sock *sk);
2498 +
2499 +-static inline bool reuseport_has_conns(struct sock *sk, bool set)
2500 ++static inline bool reuseport_has_conns(struct sock *sk)
2501 + {
2502 + struct sock_reuseport *reuse;
2503 + bool ret = false;
2504 +
2505 + rcu_read_lock();
2506 + reuse = rcu_dereference(sk->sk_reuseport_cb);
2507 +- if (reuse) {
2508 +- if (set)
2509 +- reuse->has_conns = 1;
2510 +- ret = reuse->has_conns;
2511 +- }
2512 ++ if (reuse && reuse->has_conns)
2513 ++ ret = true;
2514 + rcu_read_unlock();
2515 +
2516 + return ret;
2517 + }
2518 +
2519 ++void reuseport_has_conns_set(struct sock *sk);
2520 ++
2521 + #endif /* _SOCK_REUSEPORT_H */
2522 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
2523 +index a5245362ce7a8..b7cb9147f0c59 100644
2524 +--- a/kernel/trace/trace.c
2525 ++++ b/kernel/trace/trace.c
2526 +@@ -6008,12 +6008,12 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
2527 + if (tr->current_trace->reset)
2528 + tr->current_trace->reset(tr);
2529 +
2530 ++#ifdef CONFIG_TRACER_MAX_TRACE
2531 ++ had_max_tr = tr->current_trace->use_max_tr;
2532 ++
2533 + /* Current trace needs to be nop_trace before synchronize_rcu */
2534 + tr->current_trace = &nop_trace;
2535 +
2536 +-#ifdef CONFIG_TRACER_MAX_TRACE
2537 +- had_max_tr = tr->allocated_snapshot;
2538 +-
2539 + if (had_max_tr && !t->use_max_tr) {
2540 + /*
2541 + * We need to make sure that the update_max_tr sees that
2542 +@@ -6025,14 +6025,14 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
2543 + synchronize_rcu();
2544 + free_snapshot(tr);
2545 + }
2546 +-#endif
2547 +
2548 +-#ifdef CONFIG_TRACER_MAX_TRACE
2549 +- if (t->use_max_tr && !had_max_tr) {
2550 ++ if (t->use_max_tr && !tr->allocated_snapshot) {
2551 + ret = tracing_alloc_snapshot_instance(tr);
2552 + if (ret < 0)
2553 + goto out;
2554 + }
2555 ++#else
2556 ++ tr->current_trace = &nop_trace;
2557 + #endif
2558 +
2559 + if (t->init) {
2560 +diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
2561 +index 829db9eba0cb9..aaf64b9539150 100644
2562 +--- a/net/atm/mpoa_proc.c
2563 ++++ b/net/atm/mpoa_proc.c
2564 +@@ -219,11 +219,12 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
2565 + if (!page)
2566 + return -ENOMEM;
2567 +
2568 +- for (p = page, len = 0; len < nbytes; p++, len++) {
2569 ++ for (p = page, len = 0; len < nbytes; p++) {
2570 + if (get_user(*p, buff++)) {
2571 + free_page((unsigned long)page);
2572 + return -EFAULT;
2573 + }
2574 ++ len += 1;
2575 + if (*p == '\0' || *p == '\n')
2576 + break;
2577 + }
2578 +diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
2579 +index b065f0a103ed0..49f9c2c4ffd5a 100644
2580 +--- a/net/core/sock_reuseport.c
2581 ++++ b/net/core/sock_reuseport.c
2582 +@@ -18,6 +18,22 @@ DEFINE_SPINLOCK(reuseport_lock);
2583 +
2584 + static DEFINE_IDA(reuseport_ida);
2585 +
2586 ++void reuseport_has_conns_set(struct sock *sk)
2587 ++{
2588 ++ struct sock_reuseport *reuse;
2589 ++
2590 ++ if (!rcu_access_pointer(sk->sk_reuseport_cb))
2591 ++ return;
2592 ++
2593 ++ spin_lock_bh(&reuseport_lock);
2594 ++ reuse = rcu_dereference_protected(sk->sk_reuseport_cb,
2595 ++ lockdep_is_held(&reuseport_lock));
2596 ++ if (likely(reuse))
2597 ++ reuse->has_conns = 1;
2598 ++ spin_unlock_bh(&reuseport_lock);
2599 ++}
2600 ++EXPORT_SYMBOL(reuseport_has_conns_set);
2601 ++
2602 + static struct sock_reuseport *__reuseport_alloc(unsigned int max_socks)
2603 + {
2604 + unsigned int size = sizeof(struct sock_reuseport) +
2605 +diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
2606 +index baf4765be6d78..908324b46328f 100644
2607 +--- a/net/hsr/hsr_forward.c
2608 ++++ b/net/hsr/hsr_forward.c
2609 +@@ -108,15 +108,15 @@ struct sk_buff *hsr_get_untagged_frame(struct hsr_frame_info *frame,
2610 + struct hsr_port *port)
2611 + {
2612 + if (!frame->skb_std) {
2613 +- if (frame->skb_hsr) {
2614 ++ if (frame->skb_hsr)
2615 + frame->skb_std =
2616 + create_stripped_skb_hsr(frame->skb_hsr, frame);
2617 +- } else {
2618 +- /* Unexpected */
2619 +- WARN_ONCE(1, "%s:%d: Unexpected frame received (port_src %s)\n",
2620 +- __FILE__, __LINE__, port->dev->name);
2621 ++ else
2622 ++ netdev_warn_once(port->dev,
2623 ++ "Unexpected frame received in hsr_get_untagged_frame()\n");
2624 ++
2625 ++ if (!frame->skb_std)
2626 + return NULL;
2627 +- }
2628 + }
2629 +
2630 + return skb_clone(frame->skb_std, GFP_ATOMIC);
2631 +diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
2632 +index 4a8550c49202d..112c6e892d305 100644
2633 +--- a/net/ipv4/datagram.c
2634 ++++ b/net/ipv4/datagram.c
2635 +@@ -70,7 +70,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
2636 + }
2637 + inet->inet_daddr = fl4->daddr;
2638 + inet->inet_dport = usin->sin_port;
2639 +- reuseport_has_conns(sk, true);
2640 ++ reuseport_has_conns_set(sk);
2641 + sk->sk_state = TCP_ESTABLISHED;
2642 + sk_set_txhash(sk);
2643 + inet->inet_id = prandom_u32();
2644 +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
2645 +index 4446aa8237ff0..b093daaa3deb9 100644
2646 +--- a/net/ipv4/udp.c
2647 ++++ b/net/ipv4/udp.c
2648 +@@ -446,7 +446,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
2649 + result = lookup_reuseport(net, sk, skb,
2650 + saddr, sport, daddr, hnum);
2651 + /* Fall back to scoring if group has connections */
2652 +- if (result && !reuseport_has_conns(sk, false))
2653 ++ if (result && !reuseport_has_conns(sk))
2654 + return result;
2655 +
2656 + result = result ? : sk;
2657 +diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
2658 +index 206f66310a88d..f4559e5bc84bf 100644
2659 +--- a/net/ipv6/datagram.c
2660 ++++ b/net/ipv6/datagram.c
2661 +@@ -256,7 +256,7 @@ ipv4_connected:
2662 + goto out;
2663 + }
2664 +
2665 +- reuseport_has_conns(sk, true);
2666 ++ reuseport_has_conns_set(sk);
2667 + sk->sk_state = TCP_ESTABLISHED;
2668 + sk_set_txhash(sk);
2669 + out:
2670 +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
2671 +index 9b504bf492144..514e6a55959fe 100644
2672 +--- a/net/ipv6/udp.c
2673 ++++ b/net/ipv6/udp.c
2674 +@@ -179,7 +179,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
2675 + result = lookup_reuseport(net, sk, skb,
2676 + saddr, sport, daddr, hnum);
2677 + /* Fall back to scoring if group has connections */
2678 +- if (result && !reuseport_has_conns(sk, false))
2679 ++ if (result && !reuseport_has_conns(sk))
2680 + return result;
2681 +
2682 + result = result ? : sk;
2683 +diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
2684 +index 6e18aa4177828..d8ffe41143856 100644
2685 +--- a/net/sched/sch_api.c
2686 ++++ b/net/sched/sch_api.c
2687 +@@ -1081,12 +1081,13 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
2688 +
2689 + skip:
2690 + if (!ingress) {
2691 +- notify_and_destroy(net, skb, n, classid,
2692 +- rtnl_dereference(dev->qdisc), new);
2693 ++ old = rtnl_dereference(dev->qdisc);
2694 + if (new && !new->ops->attach)
2695 + qdisc_refcount_inc(new);
2696 + rcu_assign_pointer(dev->qdisc, new ? : &noop_qdisc);
2697 +
2698 ++ notify_and_destroy(net, skb, n, classid, old, new);
2699 ++
2700 + if (new && new->ops->attach)
2701 + new->ops->attach(new);
2702 + } else {
2703 +diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
2704 +index 1c281cc81f577..794c7377cd7e9 100644
2705 +--- a/net/sched/sch_atm.c
2706 ++++ b/net/sched/sch_atm.c
2707 +@@ -575,7 +575,6 @@ static void atm_tc_reset(struct Qdisc *sch)
2708 + pr_debug("atm_tc_reset(sch %p,[qdisc %p])\n", sch, p);
2709 + list_for_each_entry(flow, &p->flows, list)
2710 + qdisc_reset(flow->q);
2711 +- sch->q.qlen = 0;
2712 + }
2713 +
2714 + static void atm_tc_destroy(struct Qdisc *sch)
2715 +diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
2716 +index c580139fcedec..5dc7a3c310c9d 100644
2717 +--- a/net/sched/sch_cake.c
2718 ++++ b/net/sched/sch_cake.c
2719 +@@ -2224,8 +2224,12 @@ retry:
2720 +
2721 + static void cake_reset(struct Qdisc *sch)
2722 + {
2723 ++ struct cake_sched_data *q = qdisc_priv(sch);
2724 + u32 c;
2725 +
2726 ++ if (!q->tins)
2727 ++ return;
2728 ++
2729 + for (c = 0; c < CAKE_MAX_TINS; c++)
2730 + cake_clear_tin(sch, c);
2731 + }
2732 +diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
2733 +index 4a78fcf5d4f98..9a3dff02b7a2b 100644
2734 +--- a/net/sched/sch_cbq.c
2735 ++++ b/net/sched/sch_cbq.c
2736 +@@ -1053,7 +1053,6 @@ cbq_reset(struct Qdisc *sch)
2737 + cl->cpriority = cl->priority;
2738 + }
2739 + }
2740 +- sch->q.qlen = 0;
2741 + }
2742 +
2743 +
2744 +diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
2745 +index 2adbd945bf15a..25d2daaa81227 100644
2746 +--- a/net/sched/sch_choke.c
2747 ++++ b/net/sched/sch_choke.c
2748 +@@ -315,8 +315,6 @@ static void choke_reset(struct Qdisc *sch)
2749 + rtnl_qdisc_drop(skb, sch);
2750 + }
2751 +
2752 +- sch->q.qlen = 0;
2753 +- sch->qstats.backlog = 0;
2754 + if (q->tab)
2755 + memset(q->tab, 0, (q->tab_mask + 1) * sizeof(struct sk_buff *));
2756 + q->head = q->tail = 0;
2757 +diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
2758 +index dde564670ad8c..08424aac6da82 100644
2759 +--- a/net/sched/sch_drr.c
2760 ++++ b/net/sched/sch_drr.c
2761 +@@ -443,8 +443,6 @@ static void drr_reset_qdisc(struct Qdisc *sch)
2762 + qdisc_reset(cl->qdisc);
2763 + }
2764 + }
2765 +- sch->qstats.backlog = 0;
2766 +- sch->q.qlen = 0;
2767 + }
2768 +
2769 + static void drr_destroy_qdisc(struct Qdisc *sch)
2770 +diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
2771 +index 76ed1a05ded27..a75bc7f80cd7e 100644
2772 +--- a/net/sched/sch_dsmark.c
2773 ++++ b/net/sched/sch_dsmark.c
2774 +@@ -408,8 +408,6 @@ static void dsmark_reset(struct Qdisc *sch)
2775 + pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
2776 + if (p->q)
2777 + qdisc_reset(p->q);
2778 +- sch->qstats.backlog = 0;
2779 +- sch->q.qlen = 0;
2780 + }
2781 +
2782 + static void dsmark_destroy(struct Qdisc *sch)
2783 +diff --git a/net/sched/sch_etf.c b/net/sched/sch_etf.c
2784 +index c48f91075b5c6..d96103b0e2bf5 100644
2785 +--- a/net/sched/sch_etf.c
2786 ++++ b/net/sched/sch_etf.c
2787 +@@ -445,9 +445,6 @@ static void etf_reset(struct Qdisc *sch)
2788 + timesortedlist_clear(sch);
2789 + __qdisc_reset_queue(&sch->q);
2790 +
2791 +- sch->qstats.backlog = 0;
2792 +- sch->q.qlen = 0;
2793 +-
2794 + q->last = 0;
2795 + }
2796 +
2797 +diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c
2798 +index 9c224872ef035..05817c55692f0 100644
2799 +--- a/net/sched/sch_ets.c
2800 ++++ b/net/sched/sch_ets.c
2801 +@@ -722,8 +722,6 @@ static void ets_qdisc_reset(struct Qdisc *sch)
2802 + }
2803 + for (band = 0; band < q->nbands; band++)
2804 + qdisc_reset(q->classes[band].qdisc);
2805 +- sch->qstats.backlog = 0;
2806 +- sch->q.qlen = 0;
2807 + }
2808 +
2809 + static void ets_qdisc_destroy(struct Qdisc *sch)
2810 +diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
2811 +index 99e8db2621984..01d6eea5b0ce9 100644
2812 +--- a/net/sched/sch_fq_codel.c
2813 ++++ b/net/sched/sch_fq_codel.c
2814 +@@ -347,8 +347,6 @@ static void fq_codel_reset(struct Qdisc *sch)
2815 + codel_vars_init(&flow->cvars);
2816 + }
2817 + memset(q->backlogs, 0, q->flows_cnt * sizeof(u32));
2818 +- sch->q.qlen = 0;
2819 +- sch->qstats.backlog = 0;
2820 + q->memory_usage = 0;
2821 + }
2822 +
2823 +diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
2824 +index c70802785518f..cf04f70e96bf1 100644
2825 +--- a/net/sched/sch_fq_pie.c
2826 ++++ b/net/sched/sch_fq_pie.c
2827 +@@ -521,9 +521,6 @@ static void fq_pie_reset(struct Qdisc *sch)
2828 + INIT_LIST_HEAD(&flow->flowchain);
2829 + pie_vars_init(&flow->vars);
2830 + }
2831 +-
2832 +- sch->q.qlen = 0;
2833 +- sch->qstats.backlog = 0;
2834 + }
2835 +
2836 + static void fq_pie_destroy(struct Qdisc *sch)
2837 +diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
2838 +index d1902fca98447..cdc43a06aa9bc 100644
2839 +--- a/net/sched/sch_hfsc.c
2840 ++++ b/net/sched/sch_hfsc.c
2841 +@@ -1484,8 +1484,6 @@ hfsc_reset_qdisc(struct Qdisc *sch)
2842 + }
2843 + q->eligible = RB_ROOT;
2844 + qdisc_watchdog_cancel(&q->watchdog);
2845 +- sch->qstats.backlog = 0;
2846 +- sch->q.qlen = 0;
2847 + }
2848 +
2849 + static void
2850 +diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
2851 +index cd70dbcbd72fd..c3ba018fd083e 100644
2852 +--- a/net/sched/sch_htb.c
2853 ++++ b/net/sched/sch_htb.c
2854 +@@ -966,8 +966,6 @@ static void htb_reset(struct Qdisc *sch)
2855 + }
2856 + qdisc_watchdog_cancel(&q->watchdog);
2857 + __qdisc_reset_queue(&q->direct_queue);
2858 +- sch->q.qlen = 0;
2859 +- sch->qstats.backlog = 0;
2860 + memset(q->hlevel, 0, sizeof(q->hlevel));
2861 + memset(q->row_mask, 0, sizeof(q->row_mask));
2862 + }
2863 +diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
2864 +index 5c27b4270b908..1c6dbcfa89b87 100644
2865 +--- a/net/sched/sch_multiq.c
2866 ++++ b/net/sched/sch_multiq.c
2867 +@@ -152,7 +152,6 @@ multiq_reset(struct Qdisc *sch)
2868 +
2869 + for (band = 0; band < q->bands; band++)
2870 + qdisc_reset(q->queues[band]);
2871 +- sch->q.qlen = 0;
2872 + q->curband = 0;
2873 + }
2874 +
2875 +diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
2876 +index 3eabb871a1d52..1c805fe05b82a 100644
2877 +--- a/net/sched/sch_prio.c
2878 ++++ b/net/sched/sch_prio.c
2879 +@@ -135,8 +135,6 @@ prio_reset(struct Qdisc *sch)
2880 +
2881 + for (prio = 0; prio < q->bands; prio++)
2882 + qdisc_reset(q->queues[prio]);
2883 +- sch->qstats.backlog = 0;
2884 +- sch->q.qlen = 0;
2885 + }
2886 +
2887 + static int prio_offload(struct Qdisc *sch, struct tc_prio_qopt *qopt)
2888 +diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
2889 +index af8c63a9ec18c..1d1d81aeb389f 100644
2890 +--- a/net/sched/sch_qfq.c
2891 ++++ b/net/sched/sch_qfq.c
2892 +@@ -1458,8 +1458,6 @@ static void qfq_reset_qdisc(struct Qdisc *sch)
2893 + qdisc_reset(cl->qdisc);
2894 + }
2895 + }
2896 +- sch->qstats.backlog = 0;
2897 +- sch->q.qlen = 0;
2898 + }
2899 +
2900 + static void qfq_destroy_qdisc(struct Qdisc *sch)
2901 +diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
2902 +index 40adf1f07a82d..f1e013e3f04a9 100644
2903 +--- a/net/sched/sch_red.c
2904 ++++ b/net/sched/sch_red.c
2905 +@@ -176,8 +176,6 @@ static void red_reset(struct Qdisc *sch)
2906 + struct red_sched_data *q = qdisc_priv(sch);
2907 +
2908 + qdisc_reset(q->qdisc);
2909 +- sch->qstats.backlog = 0;
2910 +- sch->q.qlen = 0;
2911 + red_restart(&q->vars);
2912 + }
2913 +
2914 +diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
2915 +index b2724057629f6..9ded56228ea10 100644
2916 +--- a/net/sched/sch_sfb.c
2917 ++++ b/net/sched/sch_sfb.c
2918 +@@ -455,9 +455,8 @@ static void sfb_reset(struct Qdisc *sch)
2919 + {
2920 + struct sfb_sched_data *q = qdisc_priv(sch);
2921 +
2922 +- qdisc_reset(q->qdisc);
2923 +- sch->qstats.backlog = 0;
2924 +- sch->q.qlen = 0;
2925 ++ if (likely(q->qdisc))
2926 ++ qdisc_reset(q->qdisc);
2927 + q->slot = 0;
2928 + q->double_buffering = false;
2929 + sfb_zero_all_buckets(q);
2930 +diff --git a/net/sched/sch_skbprio.c b/net/sched/sch_skbprio.c
2931 +index 7a5e4c4547156..df72fb83d9c7d 100644
2932 +--- a/net/sched/sch_skbprio.c
2933 ++++ b/net/sched/sch_skbprio.c
2934 +@@ -213,9 +213,6 @@ static void skbprio_reset(struct Qdisc *sch)
2935 + struct skbprio_sched_data *q = qdisc_priv(sch);
2936 + int prio;
2937 +
2938 +- sch->qstats.backlog = 0;
2939 +- sch->q.qlen = 0;
2940 +-
2941 + for (prio = 0; prio < SKBPRIO_MAX_PRIORITY; prio++)
2942 + __skb_queue_purge(&q->qdiscs[prio]);
2943 +
2944 +diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
2945 +index ab8835a72cee6..7f33b31c7b8bd 100644
2946 +--- a/net/sched/sch_taprio.c
2947 ++++ b/net/sched/sch_taprio.c
2948 +@@ -1626,8 +1626,6 @@ static void taprio_reset(struct Qdisc *sch)
2949 + if (q->qdiscs[i])
2950 + qdisc_reset(q->qdiscs[i]);
2951 + }
2952 +- sch->qstats.backlog = 0;
2953 +- sch->q.qlen = 0;
2954 + }
2955 +
2956 + static void taprio_destroy(struct Qdisc *sch)
2957 +diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
2958 +index 6eb17004a9e44..7461e5c67d50a 100644
2959 +--- a/net/sched/sch_tbf.c
2960 ++++ b/net/sched/sch_tbf.c
2961 +@@ -316,8 +316,6 @@ static void tbf_reset(struct Qdisc *sch)
2962 + struct tbf_sched_data *q = qdisc_priv(sch);
2963 +
2964 + qdisc_reset(q->qdisc);
2965 +- sch->qstats.backlog = 0;
2966 +- sch->q.qlen = 0;
2967 + q->t_c = ktime_get_ns();
2968 + q->tokens = q->buffer;
2969 + q->ptokens = q->mtu;
2970 +diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
2971 +index 6af6b95bdb672..79aaab51cbf5c 100644
2972 +--- a/net/sched/sch_teql.c
2973 ++++ b/net/sched/sch_teql.c
2974 +@@ -124,7 +124,6 @@ teql_reset(struct Qdisc *sch)
2975 + struct teql_sched_data *dat = qdisc_priv(sch);
2976 +
2977 + skb_queue_purge(&dat->q);
2978 +- sch->q.qlen = 0;
2979 + }
2980 +
2981 + static void
2982 +diff --git a/net/tipc/discover.c b/net/tipc/discover.c
2983 +index 14bc20604051d..2ae268b674650 100644
2984 +--- a/net/tipc/discover.c
2985 ++++ b/net/tipc/discover.c
2986 +@@ -147,8 +147,8 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
2987 + {
2988 + struct net *net = d->net;
2989 + struct tipc_net *tn = tipc_net(net);
2990 +- bool trial = time_before(jiffies, tn->addr_trial_end);
2991 + u32 self = tipc_own_addr(net);
2992 ++ bool trial = time_before(jiffies, tn->addr_trial_end) && !self;
2993 +
2994 + if (mtyp == DSC_TRIAL_FAIL_MSG) {
2995 + if (!trial)
2996 +diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c
2997 +index 13f3143609f9e..d9e2c0fea3f2b 100644
2998 +--- a/net/tipc/topsrv.c
2999 ++++ b/net/tipc/topsrv.c
3000 +@@ -568,7 +568,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
3001 + sub.seq.upper = upper;
3002 + sub.timeout = TIPC_WAIT_FOREVER;
3003 + sub.filter = filter;
3004 +- *(u32 *)&sub.usr_handle = port;
3005 ++ *(u64 *)&sub.usr_handle = (u64)port;
3006 +
3007 + con = tipc_conn_alloc(tipc_topsrv(net));
3008 + if (IS_ERR(con))
3009 +diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
3010 +index 31d631fa846ef..3db8bd2158d9b 100644
3011 +--- a/security/selinux/ss/services.c
3012 ++++ b/security/selinux/ss/services.c
3013 +@@ -2011,7 +2011,8 @@ static inline int convert_context_handle_invalid_context(
3014 + * in `newc'. Verify that the context is valid
3015 + * under the new policy.
3016 + */
3017 +-static int convert_context(struct context *oldc, struct context *newc, void *p)
3018 ++static int convert_context(struct context *oldc, struct context *newc, void *p,
3019 ++ gfp_t gfp_flags)
3020 + {
3021 + struct convert_context_args *args;
3022 + struct ocontext *oc;
3023 +@@ -2025,7 +2026,7 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
3024 + args = p;
3025 +
3026 + if (oldc->str) {
3027 +- s = kstrdup(oldc->str, GFP_KERNEL);
3028 ++ s = kstrdup(oldc->str, gfp_flags);
3029 + if (!s)
3030 + return -ENOMEM;
3031 +
3032 +diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
3033 +index 656d50b09f762..1981c5af13e0a 100644
3034 +--- a/security/selinux/ss/sidtab.c
3035 ++++ b/security/selinux/ss/sidtab.c
3036 +@@ -325,7 +325,7 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context,
3037 + }
3038 +
3039 + rc = convert->func(context, &dst_convert->context,
3040 +- convert->args);
3041 ++ convert->args, GFP_ATOMIC);
3042 + if (rc) {
3043 + context_destroy(&dst->context);
3044 + goto out_unlock;
3045 +@@ -404,7 +404,7 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst,
3046 + while (i < SIDTAB_LEAF_ENTRIES && *pos < count) {
3047 + rc = convert->func(&esrc->ptr_leaf->entries[i].context,
3048 + &edst->ptr_leaf->entries[i].context,
3049 +- convert->args);
3050 ++ convert->args, GFP_KERNEL);
3051 + if (rc)
3052 + return rc;
3053 + (*pos)++;
3054 +diff --git a/security/selinux/ss/sidtab.h b/security/selinux/ss/sidtab.h
3055 +index 4eff0e49dcb22..9fce0d553fe2c 100644
3056 +--- a/security/selinux/ss/sidtab.h
3057 ++++ b/security/selinux/ss/sidtab.h
3058 +@@ -65,7 +65,7 @@ struct sidtab_isid_entry {
3059 + };
3060 +
3061 + struct sidtab_convert_params {
3062 +- int (*func)(struct context *oldc, struct context *newc, void *args);
3063 ++ int (*func)(struct context *oldc, struct context *newc, void *args, gfp_t gfp_flags);
3064 + void *args;
3065 + struct sidtab *target;
3066 + };
3067 +diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
3068 +index 3a0a7930cd10a..c56a4d9c3be94 100644
3069 +--- a/tools/perf/util/parse-events.c
3070 ++++ b/tools/perf/util/parse-events.c
3071 +@@ -356,6 +356,12 @@ __add_event(struct list_head *list, int *idx,
3072 + struct perf_cpu_map *cpus = pmu ? perf_cpu_map__get(pmu->cpus) :
3073 + cpu_list ? perf_cpu_map__new(cpu_list) : NULL;
3074 +
3075 ++ if (pmu)
3076 ++ perf_pmu__warn_invalid_formats(pmu);
3077 ++
3078 ++ if (pmu && attr->type == PERF_TYPE_RAW)
3079 ++ perf_pmu__warn_invalid_config(pmu, attr->config, name);
3080 ++
3081 + if (init_attr)
3082 + event_attr_init(attr);
3083 +
3084 +diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
3085 +index d41caeb35cf6c..ac45da0302a73 100644
3086 +--- a/tools/perf/util/pmu.c
3087 ++++ b/tools/perf/util/pmu.c
3088 +@@ -862,6 +862,23 @@ static struct perf_pmu *pmu_lookup(const char *name)
3089 + return pmu;
3090 + }
3091 +
3092 ++void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu)
3093 ++{
3094 ++ struct perf_pmu_format *format;
3095 ++
3096 ++ /* fake pmu doesn't have format list */
3097 ++ if (pmu == &perf_pmu__fake)
3098 ++ return;
3099 ++
3100 ++ list_for_each_entry(format, &pmu->format, list)
3101 ++ if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) {
3102 ++ pr_warning("WARNING: '%s' format '%s' requires 'perf_event_attr::config%d'"
3103 ++ "which is not supported by this version of perf!\n",
3104 ++ pmu->name, format->name, format->value);
3105 ++ return;
3106 ++ }
3107 ++}
3108 ++
3109 + static struct perf_pmu *pmu_find(const char *name)
3110 + {
3111 + struct perf_pmu *pmu;
3112 +@@ -1716,3 +1733,36 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu)
3113 +
3114 + return nr_caps;
3115 + }
3116 ++
3117 ++void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
3118 ++ char *name)
3119 ++{
3120 ++ struct perf_pmu_format *format;
3121 ++ __u64 masks = 0, bits;
3122 ++ char buf[100];
3123 ++ unsigned int i;
3124 ++
3125 ++ list_for_each_entry(format, &pmu->format, list) {
3126 ++ if (format->value != PERF_PMU_FORMAT_VALUE_CONFIG)
3127 ++ continue;
3128 ++
3129 ++ for_each_set_bit(i, format->bits, PERF_PMU_FORMAT_BITS)
3130 ++ masks |= 1ULL << i;
3131 ++ }
3132 ++
3133 ++ /*
3134 ++ * Kernel doesn't export any valid format bits.
3135 ++ */
3136 ++ if (masks == 0)
3137 ++ return;
3138 ++
3139 ++ bits = config & ~masks;
3140 ++ if (bits == 0)
3141 ++ return;
3142 ++
3143 ++ bitmap_scnprintf((unsigned long *)&bits, sizeof(bits) * 8, buf, sizeof(buf));
3144 ++
3145 ++ pr_warning("WARNING: event '%s' not valid (bits %s of config "
3146 ++ "'%llx' not supported by kernel)!\n",
3147 ++ name ?: "N/A", buf, config);
3148 ++}
3149 +diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
3150 +index a64e9c9ce731a..7d208b8507695 100644
3151 +--- a/tools/perf/util/pmu.h
3152 ++++ b/tools/perf/util/pmu.h
3153 +@@ -15,6 +15,7 @@ enum {
3154 + PERF_PMU_FORMAT_VALUE_CONFIG,
3155 + PERF_PMU_FORMAT_VALUE_CONFIG1,
3156 + PERF_PMU_FORMAT_VALUE_CONFIG2,
3157 ++ PERF_PMU_FORMAT_VALUE_CONFIG_END,
3158 + };
3159 +
3160 + #define PERF_PMU_FORMAT_BITS 64
3161 +@@ -120,4 +121,8 @@ int perf_pmu__convert_scale(const char *scale, char **end, double *sval);
3162 +
3163 + int perf_pmu__caps_parse(struct perf_pmu *pmu);
3164 +
3165 ++void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
3166 ++ char *name);
3167 ++void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu);
3168 ++
3169 + #endif /* __PMU_H */
3170 +diff --git a/tools/perf/util/pmu.l b/tools/perf/util/pmu.l
3171 +index a15d9fbd7c0ed..58b4926cfaca9 100644
3172 +--- a/tools/perf/util/pmu.l
3173 ++++ b/tools/perf/util/pmu.l
3174 +@@ -27,8 +27,6 @@ num_dec [0-9]+
3175 +
3176 + {num_dec} { return value(10); }
3177 + config { return PP_CONFIG; }
3178 +-config1 { return PP_CONFIG1; }
3179 +-config2 { return PP_CONFIG2; }
3180 + - { return '-'; }
3181 + : { return ':'; }
3182 + , { return ','; }
3183 +diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y
3184 +index bfd7e8509869b..283efe059819d 100644
3185 +--- a/tools/perf/util/pmu.y
3186 ++++ b/tools/perf/util/pmu.y
3187 +@@ -20,7 +20,7 @@ do { \
3188 +
3189 + %}
3190 +
3191 +-%token PP_CONFIG PP_CONFIG1 PP_CONFIG2
3192 ++%token PP_CONFIG
3193 + %token PP_VALUE PP_ERROR
3194 + %type <num> PP_VALUE
3195 + %type <bits> bit_term
3196 +@@ -47,18 +47,11 @@ PP_CONFIG ':' bits
3197 + $3));
3198 + }
3199 + |
3200 +-PP_CONFIG1 ':' bits
3201 ++PP_CONFIG PP_VALUE ':' bits
3202 + {
3203 + ABORT_ON(perf_pmu__new_format(format, name,
3204 +- PERF_PMU_FORMAT_VALUE_CONFIG1,
3205 +- $3));
3206 +-}
3207 +-|
3208 +-PP_CONFIG2 ':' bits
3209 +-{
3210 +- ABORT_ON(perf_pmu__new_format(format, name,
3211 +- PERF_PMU_FORMAT_VALUE_CONFIG2,
3212 +- $3));
3213 ++ $2,
3214 ++ $4));
3215 + }
3216 +
3217 + bits:
3218 +diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
3219 +index c4cce817a4522..564d5c145fbe7 100644
3220 +--- a/virt/kvm/kvm_main.c
3221 ++++ b/virt/kvm/kvm_main.c
3222 +@@ -3966,6 +3966,12 @@ struct compat_kvm_clear_dirty_log {
3223 + };
3224 + };
3225 +
3226 ++long __weak kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
3227 ++ unsigned long arg)
3228 ++{
3229 ++ return -ENOTTY;
3230 ++}
3231 ++
3232 + static long kvm_vm_compat_ioctl(struct file *filp,
3233 + unsigned int ioctl, unsigned long arg)
3234 + {
3235 +@@ -3974,6 +3980,11 @@ static long kvm_vm_compat_ioctl(struct file *filp,
3236 +
3237 + if (kvm->mm != current->mm || kvm->vm_bugged)
3238 + return -EIO;
3239 ++
3240 ++ r = kvm_arch_vm_compat_ioctl(filp, ioctl, arg);
3241 ++ if (r != -ENOTTY)
3242 ++ return r;
3243 ++
3244 + switch (ioctl) {
3245 + #ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
3246 + case KVM_CLEAR_DIRTY_LOG: {