Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Fri, 24 Apr 2020 12:02:34
Message-Id: 1587729736.3787c4cd245ebd74bb1b515a36f9f711c5df3728.mpagano@gentoo
1 commit: 3787c4cd245ebd74bb1b515a36f9f711c5df3728
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 24 12:02:16 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Apr 24 12:02:16 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3787c4cd
7
8 Linux patch 4.14.177
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1176_linux-4.14.177.patch | 7135 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 7139 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 1de9582..f56b415 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -747,6 +747,10 @@ Patch: 1175_linux-4.14.176.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.176
23
24 +Patch: 1176_linux-4.14.177.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.177
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/1176_linux-4.14.177.patch b/1176_linux-4.14.177.patch
33 new file mode 100644
34 index 0000000..9f308a1
35 --- /dev/null
36 +++ b/1176_linux-4.14.177.patch
37 @@ -0,0 +1,7135 @@
38 +diff --git a/Documentation/sound/hd-audio/index.rst b/Documentation/sound/hd-audio/index.rst
39 +index f8a72ffffe66..6e12de9fc34e 100644
40 +--- a/Documentation/sound/hd-audio/index.rst
41 ++++ b/Documentation/sound/hd-audio/index.rst
42 +@@ -8,3 +8,4 @@ HD-Audio
43 + models
44 + controls
45 + dp-mst
46 ++ realtek-pc-beep
47 +diff --git a/Documentation/sound/hd-audio/realtek-pc-beep.rst b/Documentation/sound/hd-audio/realtek-pc-beep.rst
48 +new file mode 100644
49 +index 000000000000..be47c6f76a6e
50 +--- /dev/null
51 ++++ b/Documentation/sound/hd-audio/realtek-pc-beep.rst
52 +@@ -0,0 +1,129 @@
53 ++===============================
54 ++Realtek PC Beep Hidden Register
55 ++===============================
56 ++
57 ++This file documents the "PC Beep Hidden Register", which is present in certain
58 ++Realtek HDA codecs and controls a muxer and pair of passthrough mixers that can
59 ++route audio between pins but aren't themselves exposed as HDA widgets. As far
60 ++as I can tell, these hidden routes are designed to allow flexible PC Beep output
61 ++for codecs that don't have mixer widgets in their output paths. Why it's easier
62 ++to hide a mixer behind an undocumented vendor register than to just expose it
63 ++as a widget, I have no idea.
64 ++
65 ++Register Description
66 ++====================
67 ++
68 ++The register is accessed via processing coefficient 0x36 on NID 20h. Bits not
69 ++identified below have no discernible effect on my machine, a Dell XPS 13 9350::
70 ++
71 ++ MSB LSB
72 ++ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 ++ | |h|S|L| | B |R| | Known bits
74 ++ +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
75 ++ |0|0|1|1| 0x7 |0|0x0|1| 0x7 | Reset value
76 ++ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 ++
78 ++1Ah input select (B): 2 bits
79 ++ When zero, expose the PC Beep line (from the internal beep generator, when
80 ++ enabled with the Set Beep Generation verb on NID 01h, or else from the
81 ++ external PCBEEP pin) on the 1Ah pin node. When nonzero, expose the headphone
82 ++ jack (or possibly Line In on some machines) input instead. If PC Beep is
83 ++ selected, the 1Ah boost control has no effect.
84 ++
85 ++Amplify 1Ah loopback, left (L): 1 bit
86 ++ Amplify the left channel of 1Ah before mixing it into outputs as specified
87 ++ by h and S bits. Does not affect the level of 1Ah exposed to other widgets.
88 ++
89 ++Amplify 1Ah loopback, right (R): 1 bit
90 ++ Amplify the right channel of 1Ah before mixing it into outputs as specified
91 ++ by h and S bits. Does not affect the level of 1Ah exposed to other widgets.
92 ++
93 ++Loopback 1Ah to 21h [active low] (h): 1 bit
94 ++ When zero, mix 1Ah (possibly with amplification, depending on L and R bits)
95 ++ into 21h (headphone jack on my machine). Mixed signal respects the mute
96 ++ setting on 21h.
97 ++
98 ++Loopback 1Ah to 14h (S): 1 bit
99 ++ When one, mix 1Ah (possibly with amplification, depending on L and R bits)
100 ++ into 14h (internal speaker on my machine). Mixed signal **ignores** the mute
101 ++ setting on 14h and is present whenever 14h is configured as an output.
102 ++
103 ++Path diagrams
104 ++=============
105 ++
106 ++1Ah input selection (DIV is the PC Beep divider set on NID 01h)::
107 ++
108 ++ <Beep generator> <PCBEEP pin> <Headphone jack>
109 ++ | | |
110 ++ +--DIV--+--!DIV--+ {1Ah boost control}
111 ++ | |
112 ++ +--(b == 0)--+--(b != 0)--+
113 ++ |
114 ++ >1Ah (Beep/Headphone Mic/Line In)<
115 ++
116 ++Loopback of 1Ah to 21h/14h::
117 ++
118 ++ <1Ah (Beep/Headphone Mic/Line In)>
119 ++ |
120 ++ {amplify if L/R}
121 ++ |
122 ++ +-----!h-----+-----S-----+
123 ++ | |
124 ++ {21h mute control} |
125 ++ | |
126 ++ >21h (Headphone)< >14h (Internal Speaker)<
127 ++
128 ++Background
129 ++==========
130 ++
131 ++All Realtek HDA codecs have a vendor-defined widget with node ID 20h which
132 ++provides access to a bank of registers that control various codec functions.
133 ++Registers are read and written via the standard HDA processing coefficient
134 ++verbs (Set/Get Coefficient Index, Set/Get Processing Coefficient). The node is
135 ++named "Realtek Vendor Registers" in public datasheets' verb listings and,
136 ++apart from that, is entirely undocumented.
137 ++
138 ++This particular register, exposed at coefficient 0x36 and named in commits from
139 ++Realtek, is of note: unlike most registers, which seem to control detailed
140 ++amplifier parameters not in scope of the HDA specification, it controls audio
141 ++routing which could just as easily have been defined using standard HDA mixer
142 ++and selector widgets.
143 ++
144 ++Specifically, it selects between two sources for the input pin widget with Node
145 ++ID (NID) 1Ah: the widget's signal can come either from an audio jack (on my
146 ++laptop, a Dell XPS 13 9350, it's the headphone jack, but comments in Realtek
147 ++commits indicate that it might be a Line In on some machines) or from the PC
148 ++Beep line (which is itself multiplexed between the codec's internal beep
149 ++generator and external PCBEEP pin, depending on if the beep generator is
150 ++enabled via verbs on NID 01h). Additionally, it can mix (with optional
151 ++amplification) that signal onto the 21h and/or 14h output pins.
152 ++
153 ++The register's reset value is 0x3717, corresponding to PC Beep on 1Ah that is
154 ++then amplified and mixed into both the headphones and the speakers. Not only
155 ++does this violate the HDA specification, which says that "[a vendor defined
156 ++beep input pin] connection may be maintained *only* while the Link reset
157 ++(**RST#**) is asserted", it means that we cannot ignore the register if we care
158 ++about the input that 1Ah would otherwise expose or if the PCBEEP trace is
159 ++poorly shielded and picks up chassis noise (both of which are the case on my
160 ++machine).
161 ++
162 ++Unfortunately, there are lots of ways to get this register configuration wrong.
163 ++Linux, it seems, has gone through most of them. For one, the register resets
164 ++after S3 suspend: judging by existing code, this isn't the case for all vendor
165 ++registers, and it's led to some fixes that improve behavior on cold boot but
166 ++don't last after suspend. Other fixes have successfully switched the 1Ah input
167 ++away from PC Beep but have failed to disable both loopback paths. On my
168 ++machine, this means that the headphone input is amplified and looped back to
169 ++the headphone output, which uses the exact same pins! As you might expect, this
170 ++causes terrible headphone noise, the character of which is controlled by the
171 ++1Ah boost control. (If you've seen instructions online to fix XPS 13 headphone
172 ++noise by changing "Headphone Mic Boost" in ALSA, now you know why.)
173 ++
174 ++The information here has been obtained through black-box reverse engineering of
175 ++the ALC256 codec's behavior and is not guaranteed to be correct. It likely
176 ++also applies for the ALC255, ALC257, ALC235, and ALC236, since those codecs
177 ++seem to be close relatives of the ALC256. (They all share one initialization
178 ++function.) Additionally, other codecs like the ALC225 and ALC285 also have this
179 ++register, judging by existing fixups in ``patch_realtek.c``, but specific
180 ++data (e.g. node IDs, bit positions, pin mappings) for those codecs may differ
181 ++from what I've described here.
182 +diff --git a/Makefile b/Makefile
183 +index 9db2e7f90769..d81fb98737f7 100644
184 +--- a/Makefile
185 ++++ b/Makefile
186 +@@ -1,7 +1,7 @@
187 + # SPDX-License-Identifier: GPL-2.0
188 + VERSION = 4
189 + PATCHLEVEL = 14
190 +-SUBLEVEL = 176
191 ++SUBLEVEL = 177
192 + EXTRAVERSION =
193 + NAME = Petit Gorille
194 +
195 +diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
196 +index b18fb70c5dcf..e13aca6e6d4b 100644
197 +--- a/arch/arm/net/bpf_jit_32.c
198 ++++ b/arch/arm/net/bpf_jit_32.c
199 +@@ -796,7 +796,11 @@ static inline void emit_a32_rsh_i64(const u8 dst[], bool dstk,
200 + }
201 +
202 + /* Do LSR operation */
203 +- if (val < 32) {
204 ++ if (val == 0) {
205 ++ /* An immediate value of 0 encodes a shift amount of 32
206 ++ * for LSR. To shift by 0, don't do anything.
207 ++ */
208 ++ } else if (val < 32) {
209 + emit(ARM_MOV_SI(tmp2[1], rd, SRTYPE_LSR, val), ctx);
210 + emit(ARM_ORR_SI(rd, tmp2[1], rm, SRTYPE_ASL, 32 - val), ctx);
211 + emit(ARM_MOV_SI(rm, rm, SRTYPE_LSR, val), ctx);
212 +@@ -829,7 +833,11 @@ static inline void emit_a32_arsh_i64(const u8 dst[], bool dstk,
213 + }
214 +
215 + /* Do ARSH operation */
216 +- if (val < 32) {
217 ++ if (val == 0) {
218 ++ /* An immediate value of 0 encodes a shift amount of 32
219 ++ * for ASR. To shift by 0, don't do anything.
220 ++ */
221 ++ } else if (val < 32) {
222 + emit(ARM_MOV_SI(tmp2[1], rd, SRTYPE_LSR, val), ctx);
223 + emit(ARM_ORR_SI(rd, tmp2[1], rm, SRTYPE_ASL, 32 - val), ctx);
224 + emit(ARM_MOV_SI(rm, rm, SRTYPE_ASR, val), ctx);
225 +diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
226 +index a4dc115d7659..092046704cbc 100644
227 +--- a/arch/arm64/kernel/armv8_deprecated.c
228 ++++ b/arch/arm64/kernel/armv8_deprecated.c
229 +@@ -607,7 +607,7 @@ static struct undef_hook setend_hooks[] = {
230 + },
231 + {
232 + /* Thumb mode */
233 +- .instr_mask = 0x0000fff7,
234 ++ .instr_mask = 0xfffffff7,
235 + .instr_val = 0x0000b650,
236 + .pstate_mask = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_MASK),
237 + .pstate_val = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_USR),
238 +diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
239 +index 05fdae70e9f6..53df84b2a07f 100644
240 +--- a/arch/arm64/kernel/perf_event.c
241 ++++ b/arch/arm64/kernel/perf_event.c
242 +@@ -262,12 +262,6 @@ static const unsigned armv8_a73_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
243 +
244 + [C(L1D)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_RD,
245 + [C(L1D)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR,
246 +-
247 +- [C(NODE)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD,
248 +- [C(NODE)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR,
249 +-
250 +- [C(NODE)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD,
251 +- [C(NODE)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR,
252 + };
253 +
254 + static const unsigned armv8_thunder_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
255 +diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
256 +index ee5ce03c9315..2ff327651ebe 100644
257 +--- a/arch/arm64/kernel/process.c
258 ++++ b/arch/arm64/kernel/process.c
259 +@@ -186,11 +186,9 @@ void __show_regs(struct pt_regs *regs)
260 + }
261 +
262 + show_regs_print_info(KERN_DEFAULT);
263 +- print_symbol("PC is at %s\n", instruction_pointer(regs));
264 +- print_symbol("LR is at %s\n", lr);
265 +- printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n",
266 +- regs->pc, lr, regs->pstate);
267 +- printk("sp : %016llx\n", sp);
268 ++ print_symbol("pc : %s\n", regs->pc);
269 ++ print_symbol("lr : %s\n", lr);
270 ++ printk("sp : %016llx pstate : %08llx\n", sp, regs->pstate);
271 +
272 + i = top_reg;
273 +
274 +diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
275 +index 5ae9c86c30d1..b30d23431fe1 100644
276 +--- a/arch/arm64/kernel/traps.c
277 ++++ b/arch/arm64/kernel/traps.c
278 +@@ -59,55 +59,9 @@ static const char *handler[]= {
279 +
280 + int show_unhandled_signals = 0;
281 +
282 +-/*
283 +- * Dump out the contents of some kernel memory nicely...
284 +- */
285 +-static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
286 +- unsigned long top)
287 +-{
288 +- unsigned long first;
289 +- mm_segment_t fs;
290 +- int i;
291 +-
292 +- /*
293 +- * We need to switch to kernel mode so that we can use __get_user
294 +- * to safely read from kernel space.
295 +- */
296 +- fs = get_fs();
297 +- set_fs(KERNEL_DS);
298 +-
299 +- printk("%s%s(0x%016lx to 0x%016lx)\n", lvl, str, bottom, top);
300 +-
301 +- for (first = bottom & ~31; first < top; first += 32) {
302 +- unsigned long p;
303 +- char str[sizeof(" 12345678") * 8 + 1];
304 +-
305 +- memset(str, ' ', sizeof(str));
306 +- str[sizeof(str) - 1] = '\0';
307 +-
308 +- for (p = first, i = 0; i < (32 / 8)
309 +- && p < top; i++, p += 8) {
310 +- if (p >= bottom && p < top) {
311 +- unsigned long val;
312 +-
313 +- if (__get_user(val, (unsigned long *)p) == 0)
314 +- sprintf(str + i * 17, " %016lx", val);
315 +- else
316 +- sprintf(str + i * 17, " ????????????????");
317 +- }
318 +- }
319 +- printk("%s%04lx:%s\n", lvl, first & 0xffff, str);
320 +- }
321 +-
322 +- set_fs(fs);
323 +-}
324 +-
325 + static void dump_backtrace_entry(unsigned long where)
326 + {
327 +- /*
328 +- * Note that 'where' can have a physical address, but it's not handled.
329 +- */
330 +- print_ip_sym(where);
331 ++ printk(" %pS\n", (void *)where);
332 + }
333 +
334 + static void __dump_instr(const char *lvl, struct pt_regs *regs)
335 +@@ -177,10 +131,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
336 + #endif
337 +
338 + printk("Call trace:\n");
339 +- while (1) {
340 +- unsigned long stack;
341 +- int ret;
342 +-
343 ++ do {
344 + /* skip until specified stack frame */
345 + if (!skip) {
346 + dump_backtrace_entry(frame.pc);
347 +@@ -195,17 +146,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
348 + */
349 + dump_backtrace_entry(regs->pc);
350 + }
351 +- ret = unwind_frame(tsk, &frame);
352 +- if (ret < 0)
353 +- break;
354 +- if (in_entry_text(frame.pc)) {
355 +- stack = frame.fp - offsetof(struct pt_regs, stackframe);
356 +-
357 +- if (on_accessible_stack(tsk, stack))
358 +- dump_mem("", "Exception stack", stack,
359 +- stack + sizeof(struct pt_regs));
360 +- }
361 +- }
362 ++ } while (!unwind_frame(tsk, &frame));
363 +
364 + put_task_stack(tsk);
365 + }
366 +diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
367 +index b3aec101a65d..a27b3d70393f 100644
368 +--- a/arch/mips/cavium-octeon/octeon-irq.c
369 ++++ b/arch/mips/cavium-octeon/octeon-irq.c
370 +@@ -2199,6 +2199,9 @@ static int octeon_irq_cib_map(struct irq_domain *d,
371 + }
372 +
373 + cd = kzalloc(sizeof(*cd), GFP_KERNEL);
374 ++ if (!cd)
375 ++ return -ENOMEM;
376 ++
377 + cd->host_data = host_data;
378 + cd->bit = hw;
379 +
380 +diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
381 +index 197ced1eaaa0..4a16115b47eb 100644
382 +--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
383 ++++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
384 +@@ -108,6 +108,12 @@ extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
385 + extern int hash__has_transparent_hugepage(void);
386 + #endif
387 +
388 ++static inline pmd_t hash__pmd_mkdevmap(pmd_t pmd)
389 ++{
390 ++ BUG();
391 ++ return pmd;
392 ++}
393 ++
394 + #endif /* !__ASSEMBLY__ */
395 +
396 + #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
397 +diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
398 +index 8d40cf03cb67..2194866225f8 100644
399 +--- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
400 ++++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
401 +@@ -181,7 +181,7 @@ static inline void mark_hpte_slot_valid(unsigned char *hpte_slot_array,
402 + */
403 + static inline int hash__pmd_trans_huge(pmd_t pmd)
404 + {
405 +- return !!((pmd_val(pmd) & (_PAGE_PTE | H_PAGE_THP_HUGE)) ==
406 ++ return !!((pmd_val(pmd) & (_PAGE_PTE | H_PAGE_THP_HUGE | _PAGE_DEVMAP)) ==
407 + (_PAGE_PTE | H_PAGE_THP_HUGE));
408 + }
409 +
410 +@@ -209,6 +209,12 @@ extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
411 + unsigned long addr, pmd_t *pmdp);
412 + extern int hash__has_transparent_hugepage(void);
413 + #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
414 ++
415 ++static inline pmd_t hash__pmd_mkdevmap(pmd_t pmd)
416 ++{
417 ++ return __pmd(pmd_val(pmd) | (_PAGE_PTE | H_PAGE_THP_HUGE | _PAGE_DEVMAP));
418 ++}
419 ++
420 + #endif /* __ASSEMBLY__ */
421 +
422 + #endif /* _ASM_POWERPC_BOOK3S_64_HASH_64K_H */
423 +diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
424 +index 4dd13b503dbb..bcb79a96a6c8 100644
425 +--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
426 ++++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
427 +@@ -1179,7 +1179,9 @@ extern void serialize_against_pte_lookup(struct mm_struct *mm);
428 +
429 + static inline pmd_t pmd_mkdevmap(pmd_t pmd)
430 + {
431 +- return __pmd(pmd_val(pmd) | (_PAGE_PTE | _PAGE_DEVMAP));
432 ++ if (radix_enabled())
433 ++ return radix__pmd_mkdevmap(pmd);
434 ++ return hash__pmd_mkdevmap(pmd);
435 + }
436 +
437 + static inline int pmd_devmap(pmd_t pmd)
438 +diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
439 +index 19c44e1495ae..7a1fc49aaf99 100644
440 +--- a/arch/powerpc/include/asm/book3s/64/radix.h
441 ++++ b/arch/powerpc/include/asm/book3s/64/radix.h
442 +@@ -289,6 +289,11 @@ extern pmd_t radix__pmdp_huge_get_and_clear(struct mm_struct *mm,
443 + extern int radix__has_transparent_hugepage(void);
444 + #endif
445 +
446 ++static inline pmd_t radix__pmd_mkdevmap(pmd_t pmd)
447 ++{
448 ++ return __pmd(pmd_val(pmd) | (_PAGE_PTE | _PAGE_DEVMAP));
449 ++}
450 ++
451 + extern int __meminit radix__vmemmap_create_mapping(unsigned long start,
452 + unsigned long page_size,
453 + unsigned long phys);
454 +diff --git a/arch/powerpc/include/asm/setjmp.h b/arch/powerpc/include/asm/setjmp.h
455 +index 279d03a1eec6..6941fe202bc8 100644
456 +--- a/arch/powerpc/include/asm/setjmp.h
457 ++++ b/arch/powerpc/include/asm/setjmp.h
458 +@@ -12,7 +12,9 @@
459 +
460 + #define JMP_BUF_LEN 23
461 +
462 +-extern long setjmp(long *);
463 +-extern void longjmp(long *, long);
464 ++typedef long jmp_buf[JMP_BUF_LEN];
465 ++
466 ++extern int setjmp(jmp_buf env) __attribute__((returns_twice));
467 ++extern void longjmp(jmp_buf env, int val) __attribute__((noreturn));
468 +
469 + #endif /* _ASM_POWERPC_SETJMP_H */
470 +diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
471 +index 5607ce67d178..681f966b7211 100644
472 +--- a/arch/powerpc/kernel/Makefile
473 ++++ b/arch/powerpc/kernel/Makefile
474 +@@ -5,9 +5,6 @@
475 +
476 + CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
477 +
478 +-# Avoid clang warnings around longjmp/setjmp declarations
479 +-CFLAGS_crash.o += -ffreestanding
480 +-
481 + subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
482 +
483 + ifeq ($(CONFIG_PPC64),y)
484 +diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
485 +index 74fc20431082..01b823bdb49c 100644
486 +--- a/arch/powerpc/kernel/idle_book3s.S
487 ++++ b/arch/powerpc/kernel/idle_book3s.S
488 +@@ -163,8 +163,11 @@ core_idle_lock_held:
489 + bne- core_idle_lock_held
490 + blr
491 +
492 +-/* Reuse an unused pt_regs slot for IAMR */
493 ++/* Reuse some unused pt_regs slots for AMR/IAMR/UAMOR/UAMOR */
494 ++#define PNV_POWERSAVE_AMR _TRAP
495 + #define PNV_POWERSAVE_IAMR _DAR
496 ++#define PNV_POWERSAVE_UAMOR _DSISR
497 ++#define PNV_POWERSAVE_AMOR RESULT
498 +
499 + /*
500 + * Pass requested state in r3:
501 +@@ -198,8 +201,16 @@ pnv_powersave_common:
502 + SAVE_NVGPRS(r1)
503 +
504 + BEGIN_FTR_SECTION
505 ++ mfspr r4, SPRN_AMR
506 + mfspr r5, SPRN_IAMR
507 ++ mfspr r6, SPRN_UAMOR
508 ++ std r4, PNV_POWERSAVE_AMR(r1)
509 + std r5, PNV_POWERSAVE_IAMR(r1)
510 ++ std r6, PNV_POWERSAVE_UAMOR(r1)
511 ++BEGIN_FTR_SECTION_NESTED(42)
512 ++ mfspr r7, SPRN_AMOR
513 ++ std r7, PNV_POWERSAVE_AMOR(r1)
514 ++END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
515 + END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
516 +
517 + mfcr r5
518 +@@ -951,12 +962,20 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
519 + REST_GPR(2, r1)
520 +
521 + BEGIN_FTR_SECTION
522 +- /* IAMR was saved in pnv_powersave_common() */
523 ++ /* These regs were saved in pnv_powersave_common() */
524 ++ ld r4, PNV_POWERSAVE_AMR(r1)
525 + ld r5, PNV_POWERSAVE_IAMR(r1)
526 ++ ld r6, PNV_POWERSAVE_UAMOR(r1)
527 ++ mtspr SPRN_AMR, r4
528 + mtspr SPRN_IAMR, r5
529 ++ mtspr SPRN_UAMOR, r6
530 ++BEGIN_FTR_SECTION_NESTED(42)
531 ++ ld r7, PNV_POWERSAVE_AMOR(r1)
532 ++ mtspr SPRN_AMOR, r7
533 ++END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
534 + /*
535 +- * We don't need an isync here because the upcoming mtmsrd is
536 +- * execution synchronizing.
537 ++ * We don't need an isync here after restoring IAMR because the upcoming
538 ++ * mtmsrd is execution synchronizing.
539 + */
540 + END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
541 +
542 +diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
543 +index 10b46b35c059..07d3f3b40246 100644
544 +--- a/arch/powerpc/kernel/kprobes.c
545 ++++ b/arch/powerpc/kernel/kprobes.c
546 +@@ -279,6 +279,9 @@ int kprobe_handler(struct pt_regs *regs)
547 + if (user_mode(regs))
548 + return 0;
549 +
550 ++ if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR))
551 ++ return 0;
552 ++
553 + /*
554 + * We don't want to be preempted for the entire
555 + * duration of kprobe processing
556 +diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
557 +index b75bf6e74209..3e8edb1387cc 100644
558 +--- a/arch/powerpc/kernel/signal_64.c
559 ++++ b/arch/powerpc/kernel/signal_64.c
560 +@@ -469,8 +469,10 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
561 + err |= __get_user(tsk->thread.ckpt_regs.ccr,
562 + &sc->gp_regs[PT_CCR]);
563 +
564 ++ /* Don't allow userspace to set the trap value */
565 ++ regs->trap = 0;
566 ++
567 + /* These regs are not checkpointed; they can go in 'regs'. */
568 +- err |= __get_user(regs->trap, &sc->gp_regs[PT_TRAP]);
569 + err |= __get_user(regs->dar, &sc->gp_regs[PT_DAR]);
570 + err |= __get_user(regs->dsisr, &sc->gp_regs[PT_DSISR]);
571 + err |= __get_user(regs->result, &sc->gp_regs[PT_RESULT]);
572 +diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
573 +index 048b8e9f4492..63964af9a162 100644
574 +--- a/arch/powerpc/mm/tlb_nohash_low.S
575 ++++ b/arch/powerpc/mm/tlb_nohash_low.S
576 +@@ -400,7 +400,7 @@ _GLOBAL(set_context)
577 + * extern void loadcam_entry(unsigned int index)
578 + *
579 + * Load TLBCAM[index] entry in to the L2 CAM MMU
580 +- * Must preserve r7, r8, r9, and r10
581 ++ * Must preserve r7, r8, r9, r10 and r11
582 + */
583 + _GLOBAL(loadcam_entry)
584 + mflr r5
585 +@@ -436,6 +436,10 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)
586 + */
587 + _GLOBAL(loadcam_multi)
588 + mflr r8
589 ++ /* Don't switch to AS=1 if already there */
590 ++ mfmsr r11
591 ++ andi. r11,r11,MSR_IS
592 ++ bne 10f
593 +
594 + /*
595 + * Set up temporary TLB entry that is the same as what we're
596 +@@ -461,6 +465,7 @@ _GLOBAL(loadcam_multi)
597 + mtmsr r6
598 + isync
599 +
600 ++10:
601 + mr r9,r3
602 + add r10,r3,r4
603 + 2: bl loadcam_entry
604 +@@ -469,6 +474,10 @@ _GLOBAL(loadcam_multi)
605 + mr r3,r9
606 + blt 2b
607 +
608 ++ /* Don't return to AS=0 if we were in AS=1 at function start */
609 ++ andi. r11,r11,MSR_IS
610 ++ bne 3f
611 ++
612 + /* Return to AS=0 and clear the temporary entry */
613 + mfmsr r6
614 + rlwinm. r6,r6,0,~(MSR_IS|MSR_DS)
615 +@@ -484,6 +493,7 @@ _GLOBAL(loadcam_multi)
616 + tlbwe
617 + isync
618 +
619 ++3:
620 + mtlr r8
621 + blr
622 + #endif
623 +diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
624 +index b7f937563827..d1fee2d35b49 100644
625 +--- a/arch/powerpc/platforms/maple/setup.c
626 ++++ b/arch/powerpc/platforms/maple/setup.c
627 +@@ -299,23 +299,6 @@ static int __init maple_probe(void)
628 + return 1;
629 + }
630 +
631 +-define_machine(maple) {
632 +- .name = "Maple",
633 +- .probe = maple_probe,
634 +- .setup_arch = maple_setup_arch,
635 +- .init_IRQ = maple_init_IRQ,
636 +- .pci_irq_fixup = maple_pci_irq_fixup,
637 +- .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
638 +- .restart = maple_restart,
639 +- .halt = maple_halt,
640 +- .get_boot_time = maple_get_boot_time,
641 +- .set_rtc_time = maple_set_rtc_time,
642 +- .get_rtc_time = maple_get_rtc_time,
643 +- .calibrate_decr = generic_calibrate_decr,
644 +- .progress = maple_progress,
645 +- .power_save = power4_idle,
646 +-};
647 +-
648 + #ifdef CONFIG_EDAC
649 + /*
650 + * Register a platform device for CPC925 memory controller on
651 +@@ -372,3 +355,20 @@ static int __init maple_cpc925_edac_setup(void)
652 + }
653 + machine_device_initcall(maple, maple_cpc925_edac_setup);
654 + #endif
655 ++
656 ++define_machine(maple) {
657 ++ .name = "Maple",
658 ++ .probe = maple_probe,
659 ++ .setup_arch = maple_setup_arch,
660 ++ .init_IRQ = maple_init_IRQ,
661 ++ .pci_irq_fixup = maple_pci_irq_fixup,
662 ++ .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
663 ++ .restart = maple_restart,
664 ++ .halt = maple_halt,
665 ++ .get_boot_time = maple_get_boot_time,
666 ++ .set_rtc_time = maple_set_rtc_time,
667 ++ .get_rtc_time = maple_get_rtc_time,
668 ++ .calibrate_decr = generic_calibrate_decr,
669 ++ .progress = maple_progress,
670 ++ .power_save = power4_idle,
671 ++};
672 +diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
673 +index c0ae3847b8db..215b14a373cb 100644
674 +--- a/arch/powerpc/platforms/pseries/lpar.c
675 ++++ b/arch/powerpc/platforms/pseries/lpar.c
676 +@@ -1060,7 +1060,7 @@ static int __init vpa_debugfs_init(void)
677 + {
678 + char name[16];
679 + long i;
680 +- static struct dentry *vpa_dir;
681 ++ struct dentry *vpa_dir;
682 +
683 + if (!firmware_has_feature(FW_FEATURE_SPLPAR))
684 + return 0;
685 +diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
686 +index a820370883d9..b7ae5a027714 100644
687 +--- a/arch/powerpc/sysdev/xive/common.c
688 ++++ b/arch/powerpc/sysdev/xive/common.c
689 +@@ -72,13 +72,6 @@ static u32 xive_ipi_irq;
690 + /* Xive state for each CPU */
691 + static DEFINE_PER_CPU(struct xive_cpu *, xive_cpu);
692 +
693 +-/*
694 +- * A "disabled" interrupt should never fire, to catch problems
695 +- * we set its logical number to this
696 +- */
697 +-#define XIVE_BAD_IRQ 0x7fffffff
698 +-#define XIVE_MAX_IRQ (XIVE_BAD_IRQ - 1)
699 +-
700 + /* An invalid CPU target */
701 + #define XIVE_INVALID_TARGET (-1)
702 +
703 +@@ -1073,7 +1066,7 @@ static int xive_setup_cpu_ipi(unsigned int cpu)
704 + xc = per_cpu(xive_cpu, cpu);
705 +
706 + /* Check if we are already setup */
707 +- if (xc->hw_ipi != 0)
708 ++ if (xc->hw_ipi != XIVE_BAD_IRQ)
709 + return 0;
710 +
711 + /* Grab an IPI from the backend, this will populate xc->hw_ipi */
712 +@@ -1110,7 +1103,7 @@ static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc)
713 + /* Disable the IPI and free the IRQ data */
714 +
715 + /* Already cleaned up ? */
716 +- if (xc->hw_ipi == 0)
717 ++ if (xc->hw_ipi == XIVE_BAD_IRQ)
718 + return;
719 +
720 + /* Mask the IPI */
721 +@@ -1266,6 +1259,7 @@ static int xive_prepare_cpu(unsigned int cpu)
722 + if (np)
723 + xc->chip_id = of_get_ibm_chip_id(np);
724 + of_node_put(np);
725 ++ xc->hw_ipi = XIVE_BAD_IRQ;
726 +
727 + per_cpu(xive_cpu, cpu) = xc;
728 + }
729 +diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
730 +index aac61374afeb..30cdcbfa1c04 100644
731 +--- a/arch/powerpc/sysdev/xive/native.c
732 ++++ b/arch/powerpc/sysdev/xive/native.c
733 +@@ -310,7 +310,7 @@ static void xive_native_put_ipi(unsigned int cpu, struct xive_cpu *xc)
734 + s64 rc;
735 +
736 + /* Free the IPI */
737 +- if (!xc->hw_ipi)
738 ++ if (xc->hw_ipi == XIVE_BAD_IRQ)
739 + return;
740 + for (;;) {
741 + rc = opal_xive_free_irq(xc->hw_ipi);
742 +@@ -318,7 +318,7 @@ static void xive_native_put_ipi(unsigned int cpu, struct xive_cpu *xc)
743 + msleep(1);
744 + continue;
745 + }
746 +- xc->hw_ipi = 0;
747 ++ xc->hw_ipi = XIVE_BAD_IRQ;
748 + break;
749 + }
750 + }
751 +diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
752 +index 7fc41bf30fd5..10235098a726 100644
753 +--- a/arch/powerpc/sysdev/xive/spapr.c
754 ++++ b/arch/powerpc/sysdev/xive/spapr.c
755 +@@ -443,11 +443,11 @@ static int xive_spapr_get_ipi(unsigned int cpu, struct xive_cpu *xc)
756 +
757 + static void xive_spapr_put_ipi(unsigned int cpu, struct xive_cpu *xc)
758 + {
759 +- if (!xc->hw_ipi)
760 ++ if (xc->hw_ipi == XIVE_BAD_IRQ)
761 + return;
762 +
763 + xive_irq_bitmap_free(xc->hw_ipi);
764 +- xc->hw_ipi = 0;
765 ++ xc->hw_ipi = XIVE_BAD_IRQ;
766 + }
767 + #endif /* CONFIG_SMP */
768 +
769 +diff --git a/arch/powerpc/sysdev/xive/xive-internal.h b/arch/powerpc/sysdev/xive/xive-internal.h
770 +index f34abed0c05f..48808dbb25dc 100644
771 +--- a/arch/powerpc/sysdev/xive/xive-internal.h
772 ++++ b/arch/powerpc/sysdev/xive/xive-internal.h
773 +@@ -9,6 +9,13 @@
774 + #ifndef __XIVE_INTERNAL_H
775 + #define __XIVE_INTERNAL_H
776 +
777 ++/*
778 ++ * A "disabled" interrupt should never fire, to catch problems
779 ++ * we set its logical number to this
780 ++ */
781 ++#define XIVE_BAD_IRQ 0x7fffffff
782 ++#define XIVE_MAX_IRQ (XIVE_BAD_IRQ - 1)
783 ++
784 + /* Each CPU carry one of these with various per-CPU state */
785 + struct xive_cpu {
786 + #ifdef CONFIG_SMP
787 +diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
788 +index a60c44b4a3e5..93974b0a5a99 100644
789 +--- a/arch/powerpc/xmon/Makefile
790 ++++ b/arch/powerpc/xmon/Makefile
791 +@@ -1,9 +1,6 @@
792 + # SPDX-License-Identifier: GPL-2.0
793 + # Makefile for xmon
794 +
795 +-# Avoid clang warnings around longjmp/setjmp declarations
796 +-subdir-ccflags-y := -ffreestanding
797 +-
798 + subdir-ccflags-$(CONFIG_PPC_WERROR) += -Werror
799 +
800 + GCOV_PROFILE := n
801 +diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c
802 +index 53a5316cc4b7..35c842aa8705 100644
803 +--- a/arch/s390/kernel/diag.c
804 ++++ b/arch/s390/kernel/diag.c
805 +@@ -79,7 +79,7 @@ static int show_diag_stat(struct seq_file *m, void *v)
806 +
807 + static void *show_diag_stat_start(struct seq_file *m, loff_t *pos)
808 + {
809 +- return *pos <= nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
810 ++ return *pos <= NR_DIAG_STAT ? (void *)((unsigned long) *pos + 1) : NULL;
811 + }
812 +
813 + static void *show_diag_stat_next(struct seq_file *m, void *v, loff_t *pos)
814 +diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
815 +index 6fe2e1875058..675d4be0c2b7 100644
816 +--- a/arch/s390/kernel/processor.c
817 ++++ b/arch/s390/kernel/processor.c
818 +@@ -157,8 +157,9 @@ static void show_cpu_mhz(struct seq_file *m, unsigned long n)
819 + static int show_cpuinfo(struct seq_file *m, void *v)
820 + {
821 + unsigned long n = (unsigned long) v - 1;
822 ++ unsigned long first = cpumask_first(cpu_online_mask);
823 +
824 +- if (!n)
825 ++ if (n == first)
826 + show_cpu_summary(m, v);
827 + if (!machine_has_cpu_mhz)
828 + return 0;
829 +@@ -171,6 +172,8 @@ static inline void *c_update(loff_t *pos)
830 + {
831 + if (*pos)
832 + *pos = cpumask_next(*pos - 1, cpu_online_mask);
833 ++ else
834 ++ *pos = cpumask_first(cpu_online_mask);
835 + return *pos < nr_cpu_ids ? (void *)*pos + 1 : NULL;
836 + }
837 +
838 +diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
839 +index 061906f98dc5..0120383219c0 100644
840 +--- a/arch/s390/kvm/vsie.c
841 ++++ b/arch/s390/kvm/vsie.c
842 +@@ -1027,6 +1027,7 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
843 + scb_s->iprcc = PGM_ADDRESSING;
844 + scb_s->pgmilc = 4;
845 + scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, 4);
846 ++ rc = 1;
847 + }
848 + return rc;
849 + }
850 +diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
851 +index ec9292917d3f..a29d2e88b00e 100644
852 +--- a/arch/s390/mm/gmap.c
853 ++++ b/arch/s390/mm/gmap.c
854 +@@ -762,14 +762,18 @@ static void gmap_call_notifier(struct gmap *gmap, unsigned long start,
855 + static inline unsigned long *gmap_table_walk(struct gmap *gmap,
856 + unsigned long gaddr, int level)
857 + {
858 ++ const int asce_type = gmap->asce & _ASCE_TYPE_MASK;
859 + unsigned long *table;
860 +
861 + if ((gmap->asce & _ASCE_TYPE_MASK) + 4 < (level * 4))
862 + return NULL;
863 + if (gmap_is_shadow(gmap) && gmap->removed)
864 + return NULL;
865 +- if (gaddr & (-1UL << (31 + ((gmap->asce & _ASCE_TYPE_MASK) >> 2)*11)))
866 ++
867 ++ if (asce_type != _ASCE_TYPE_REGION1 &&
868 ++ gaddr & (-1UL << (31 + (asce_type >> 2) * 11)))
869 + return NULL;
870 ++
871 + table = gmap->table;
872 + switch (gmap->asce & _ASCE_TYPE_MASK) {
873 + case _ASCE_TYPE_REGION1:
874 +@@ -1683,6 +1687,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
875 + goto out_free;
876 + } else if (*table & _REGION_ENTRY_ORIGIN) {
877 + rc = -EAGAIN; /* Race with shadow */
878 ++ goto out_free;
879 + }
880 + crst_table_init(s_r3t, _REGION3_ENTRY_EMPTY);
881 + /* mark as invalid as long as the parent table is not protected */
882 +diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
883 +index 37380c0d5999..01d628ea3402 100644
884 +--- a/arch/x86/boot/compressed/head_32.S
885 ++++ b/arch/x86/boot/compressed/head_32.S
886 +@@ -106,7 +106,7 @@ ENTRY(startup_32)
887 + notl %eax
888 + andl %eax, %ebx
889 + cmpl $LOAD_PHYSICAL_ADDR, %ebx
890 +- jge 1f
891 ++ jae 1f
892 + #endif
893 + movl $LOAD_PHYSICAL_ADDR, %ebx
894 + 1:
895 +diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
896 +index 39fdede523f2..a25127916e67 100644
897 +--- a/arch/x86/boot/compressed/head_64.S
898 ++++ b/arch/x86/boot/compressed/head_64.S
899 +@@ -105,7 +105,7 @@ ENTRY(startup_32)
900 + notl %eax
901 + andl %eax, %ebx
902 + cmpl $LOAD_PHYSICAL_ADDR, %ebx
903 +- jge 1f
904 ++ jae 1f
905 + #endif
906 + movl $LOAD_PHYSICAL_ADDR, %ebx
907 + 1:
908 +@@ -280,7 +280,7 @@ ENTRY(startup_64)
909 + notq %rax
910 + andq %rax, %rbp
911 + cmpq $LOAD_PHYSICAL_ADDR, %rbp
912 +- jge 1f
913 ++ jae 1f
914 + #endif
915 + movq $LOAD_PHYSICAL_ADDR, %rbp
916 + 1:
917 +diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
918 +index 49adabd94f88..c19974a49378 100644
919 +--- a/arch/x86/entry/entry_32.S
920 ++++ b/arch/x86/entry/entry_32.S
921 +@@ -1057,6 +1057,7 @@ ENTRY(int3)
922 + END(int3)
923 +
924 + ENTRY(general_protection)
925 ++ ASM_CLAC
926 + pushl $do_general_protection
927 + jmp common_exception
928 + END(general_protection)
929 +diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
930 +index b4bef819d5d5..157cfaf1064c 100644
931 +--- a/arch/x86/include/asm/cpufeatures.h
932 ++++ b/arch/x86/include/asm/cpufeatures.h
933 +@@ -205,7 +205,7 @@
934 + #define X86_FEATURE_RETPOLINE ( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
935 + #define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* "" AMD Retpoline mitigation for Spectre variant 2 */
936 + #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */
937 +-
938 ++#define X86_FEATURE_CDP_L2 ( 7*32+15) /* Code and Data Prioritization L2 */
939 + #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16) /* "" MSR SPEC_CTRL is implemented */
940 + #define X86_FEATURE_SSBD ( 7*32+17) /* Speculative Store Bypass Disable */
941 + #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */
942 +diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
943 +index 2cdf654ed132..9529fe69e1d9 100644
944 +--- a/arch/x86/include/asm/kvm_host.h
945 ++++ b/arch/x86/include/asm/kvm_host.h
946 +@@ -1032,7 +1032,7 @@ struct kvm_x86_ops {
947 + bool (*mpx_supported)(void);
948 + bool (*xsaves_supported)(void);
949 +
950 +- int (*check_nested_events)(struct kvm_vcpu *vcpu, bool external_intr);
951 ++ int (*check_nested_events)(struct kvm_vcpu *vcpu);
952 +
953 + void (*sched_in)(struct kvm_vcpu *kvm, int cpu);
954 +
955 +diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h
956 +index 209492849566..5c524d4f71cd 100644
957 +--- a/arch/x86/include/asm/microcode_amd.h
958 ++++ b/arch/x86/include/asm/microcode_amd.h
959 +@@ -41,7 +41,7 @@ struct microcode_amd {
960 + unsigned int mpb[0];
961 + };
962 +
963 +-#define PATCH_MAX_SIZE PAGE_SIZE
964 ++#define PATCH_MAX_SIZE (3 * PAGE_SIZE)
965 +
966 + #ifdef CONFIG_MICROCODE_AMD
967 + extern void __init load_ucode_amd_bsp(unsigned int family);
968 +diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
969 +index 6a4b1a54ff47..98a337e3835d 100644
970 +--- a/arch/x86/include/asm/pgtable.h
971 ++++ b/arch/x86/include/asm/pgtable.h
972 +@@ -588,12 +588,15 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
973 + return __pmd(val);
974 + }
975 +
976 +-/* mprotect needs to preserve PAT bits when updating vm_page_prot */
977 ++/*
978 ++ * mprotect needs to preserve PAT and encryption bits when updating
979 ++ * vm_page_prot
980 ++ */
981 + #define pgprot_modify pgprot_modify
982 + static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
983 + {
984 + pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
985 +- pgprotval_t addbits = pgprot_val(newprot);
986 ++ pgprotval_t addbits = pgprot_val(newprot) & ~_PAGE_CHG_MASK;
987 + return __pgprot(preservebits | addbits);
988 + }
989 +
990 +diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
991 +index 85f8279c885a..e6c870c24065 100644
992 +--- a/arch/x86/include/asm/pgtable_types.h
993 ++++ b/arch/x86/include/asm/pgtable_types.h
994 +@@ -124,7 +124,7 @@
995 + */
996 + #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \
997 + _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \
998 +- _PAGE_SOFT_DIRTY | _PAGE_DEVMAP)
999 ++ _PAGE_SOFT_DIRTY | _PAGE_DEVMAP | _PAGE_ENC)
1000 + #define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE)
1001 +
1002 + /*
1003 +diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
1004 +index 6dda3595acf8..40d7072be709 100644
1005 +--- a/arch/x86/kernel/acpi/boot.c
1006 ++++ b/arch/x86/kernel/acpi/boot.c
1007 +@@ -1738,7 +1738,7 @@ int __acpi_acquire_global_lock(unsigned int *lock)
1008 + new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1009 + val = cmpxchg(lock, old, new);
1010 + } while (unlikely (val != old));
1011 +- return (new < 3) ? -1 : 0;
1012 ++ return ((new & 0x3) < 3) ? -1 : 0;
1013 + }
1014 +
1015 + int __acpi_release_global_lock(unsigned int *lock)
1016 +diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
1017 +index dde437f5d14f..596e7640d895 100644
1018 +--- a/arch/x86/kernel/acpi/cstate.c
1019 ++++ b/arch/x86/kernel/acpi/cstate.c
1020 +@@ -133,7 +133,8 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
1021 +
1022 + /* Make sure we are running on right CPU */
1023 +
1024 +- retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx);
1025 ++ retval = call_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx,
1026 ++ false);
1027 + if (retval == 0) {
1028 + /* Use the hint in CST */
1029 + percpu_entry->states[cx->index].eax = cx->address;
1030 +diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
1031 +index 3f731d7f04bf..07742b69d914 100644
1032 +--- a/arch/x86/kernel/cpu/intel_rdt.c
1033 ++++ b/arch/x86/kernel/cpu/intel_rdt.c
1034 +@@ -135,6 +135,40 @@ struct rdt_resource rdt_resources_all[] = {
1035 + .format_str = "%d=%0*x",
1036 + .fflags = RFTYPE_RES_CACHE,
1037 + },
1038 ++ [RDT_RESOURCE_L2DATA] =
1039 ++ {
1040 ++ .rid = RDT_RESOURCE_L2DATA,
1041 ++ .name = "L2DATA",
1042 ++ .domains = domain_init(RDT_RESOURCE_L2DATA),
1043 ++ .msr_base = IA32_L2_CBM_BASE,
1044 ++ .msr_update = cat_wrmsr,
1045 ++ .cache_level = 2,
1046 ++ .cache = {
1047 ++ .min_cbm_bits = 1,
1048 ++ .cbm_idx_mult = 2,
1049 ++ .cbm_idx_offset = 0,
1050 ++ },
1051 ++ .parse_ctrlval = parse_cbm,
1052 ++ .format_str = "%d=%0*x",
1053 ++ .fflags = RFTYPE_RES_CACHE,
1054 ++ },
1055 ++ [RDT_RESOURCE_L2CODE] =
1056 ++ {
1057 ++ .rid = RDT_RESOURCE_L2CODE,
1058 ++ .name = "L2CODE",
1059 ++ .domains = domain_init(RDT_RESOURCE_L2CODE),
1060 ++ .msr_base = IA32_L2_CBM_BASE,
1061 ++ .msr_update = cat_wrmsr,
1062 ++ .cache_level = 2,
1063 ++ .cache = {
1064 ++ .min_cbm_bits = 1,
1065 ++ .cbm_idx_mult = 2,
1066 ++ .cbm_idx_offset = 1,
1067 ++ },
1068 ++ .parse_ctrlval = parse_cbm,
1069 ++ .format_str = "%d=%0*x",
1070 ++ .fflags = RFTYPE_RES_CACHE,
1071 ++ },
1072 + [RDT_RESOURCE_MBA] =
1073 + {
1074 + .rid = RDT_RESOURCE_MBA,
1075 +@@ -259,15 +293,15 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
1076 + r->alloc_enabled = true;
1077 + }
1078 +
1079 +-static void rdt_get_cdp_l3_config(int type)
1080 ++static void rdt_get_cdp_config(int level, int type)
1081 + {
1082 +- struct rdt_resource *r_l3 = &rdt_resources_all[RDT_RESOURCE_L3];
1083 ++ struct rdt_resource *r_l = &rdt_resources_all[level];
1084 + struct rdt_resource *r = &rdt_resources_all[type];
1085 +
1086 +- r->num_closid = r_l3->num_closid / 2;
1087 +- r->cache.cbm_len = r_l3->cache.cbm_len;
1088 +- r->default_ctrl = r_l3->default_ctrl;
1089 +- r->cache.shareable_bits = r_l3->cache.shareable_bits;
1090 ++ r->num_closid = r_l->num_closid / 2;
1091 ++ r->cache.cbm_len = r_l->cache.cbm_len;
1092 ++ r->default_ctrl = r_l->default_ctrl;
1093 ++ r->cache.shareable_bits = r_l->cache.shareable_bits;
1094 + r->data_width = (r->cache.cbm_len + 3) / 4;
1095 + r->alloc_capable = true;
1096 + /*
1097 +@@ -277,6 +311,18 @@ static void rdt_get_cdp_l3_config(int type)
1098 + r->alloc_enabled = false;
1099 + }
1100 +
1101 ++static void rdt_get_cdp_l3_config(void)
1102 ++{
1103 ++ rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3DATA);
1104 ++ rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3CODE);
1105 ++}
1106 ++
1107 ++static void rdt_get_cdp_l2_config(void)
1108 ++{
1109 ++ rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2DATA);
1110 ++ rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2CODE);
1111 ++}
1112 ++
1113 + static int get_cache_id(int cpu, int level)
1114 + {
1115 + struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
1116 +@@ -486,6 +532,8 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
1117 + d->id = id;
1118 + cpumask_set_cpu(cpu, &d->cpu_mask);
1119 +
1120 ++ rdt_domain_reconfigure_cdp(r);
1121 ++
1122 + if (r->alloc_capable && domain_setup_ctrlval(r, d)) {
1123 + kfree(d);
1124 + return;
1125 +@@ -729,15 +777,15 @@ static __init bool get_rdt_alloc_resources(void)
1126 +
1127 + if (rdt_cpu_has(X86_FEATURE_CAT_L3)) {
1128 + rdt_get_cache_alloc_cfg(1, &rdt_resources_all[RDT_RESOURCE_L3]);
1129 +- if (rdt_cpu_has(X86_FEATURE_CDP_L3)) {
1130 +- rdt_get_cdp_l3_config(RDT_RESOURCE_L3DATA);
1131 +- rdt_get_cdp_l3_config(RDT_RESOURCE_L3CODE);
1132 +- }
1133 ++ if (rdt_cpu_has(X86_FEATURE_CDP_L3))
1134 ++ rdt_get_cdp_l3_config();
1135 + ret = true;
1136 + }
1137 + if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {
1138 + /* CPUID 0x10.2 fields are same format at 0x10.1 */
1139 + rdt_get_cache_alloc_cfg(2, &rdt_resources_all[RDT_RESOURCE_L2]);
1140 ++ if (rdt_cpu_has(X86_FEATURE_CDP_L2))
1141 ++ rdt_get_cdp_l2_config();
1142 + ret = true;
1143 + }
1144 +
1145 +diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
1146 +index a43a72d8e88e..b43a786ec15f 100644
1147 +--- a/arch/x86/kernel/cpu/intel_rdt.h
1148 ++++ b/arch/x86/kernel/cpu/intel_rdt.h
1149 +@@ -7,12 +7,15 @@
1150 + #include <linux/jump_label.h>
1151 +
1152 + #define IA32_L3_QOS_CFG 0xc81
1153 ++#define IA32_L2_QOS_CFG 0xc82
1154 + #define IA32_L3_CBM_BASE 0xc90
1155 + #define IA32_L2_CBM_BASE 0xd10
1156 + #define IA32_MBA_THRTL_BASE 0xd50
1157 +
1158 + #define L3_QOS_CDP_ENABLE 0x01ULL
1159 +
1160 ++#define L2_QOS_CDP_ENABLE 0x01ULL
1161 ++
1162 + /*
1163 + * Event IDs are used to program IA32_QM_EVTSEL before reading event
1164 + * counter from IA32_QM_CTR
1165 +@@ -354,6 +357,8 @@ enum {
1166 + RDT_RESOURCE_L3DATA,
1167 + RDT_RESOURCE_L3CODE,
1168 + RDT_RESOURCE_L2,
1169 ++ RDT_RESOURCE_L2DATA,
1170 ++ RDT_RESOURCE_L2CODE,
1171 + RDT_RESOURCE_MBA,
1172 +
1173 + /* Must be the last */
1174 +@@ -437,5 +442,6 @@ void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);
1175 + void cqm_handle_limbo(struct work_struct *work);
1176 + bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);
1177 + void __check_limbo(struct rdt_domain *d, bool force_free);
1178 ++void rdt_domain_reconfigure_cdp(struct rdt_resource *r);
1179 +
1180 + #endif /* _ASM_X86_INTEL_RDT_H */
1181 +diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
1182 +index 0ec30b2384c0..60c63b23e3ba 100644
1183 +--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
1184 ++++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
1185 +@@ -922,6 +922,7 @@ out_destroy:
1186 + kernfs_remove(kn);
1187 + return ret;
1188 + }
1189 ++
1190 + static void l3_qos_cfg_update(void *arg)
1191 + {
1192 + bool *enable = arg;
1193 +@@ -929,8 +930,17 @@ static void l3_qos_cfg_update(void *arg)
1194 + wrmsrl(IA32_L3_QOS_CFG, *enable ? L3_QOS_CDP_ENABLE : 0ULL);
1195 + }
1196 +
1197 +-static int set_l3_qos_cfg(struct rdt_resource *r, bool enable)
1198 ++static void l2_qos_cfg_update(void *arg)
1199 ++{
1200 ++ bool *enable = arg;
1201 ++
1202 ++ wrmsrl(IA32_L2_QOS_CFG, *enable ? L2_QOS_CDP_ENABLE : 0ULL);
1203 ++}
1204 ++
1205 ++static int set_cache_qos_cfg(int level, bool enable)
1206 + {
1207 ++ void (*update)(void *arg);
1208 ++ struct rdt_resource *r_l;
1209 + cpumask_var_t cpu_mask;
1210 + struct rdt_domain *d;
1211 + int cpu;
1212 +@@ -938,16 +948,24 @@ static int set_l3_qos_cfg(struct rdt_resource *r, bool enable)
1213 + if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
1214 + return -ENOMEM;
1215 +
1216 +- list_for_each_entry(d, &r->domains, list) {
1217 ++ if (level == RDT_RESOURCE_L3)
1218 ++ update = l3_qos_cfg_update;
1219 ++ else if (level == RDT_RESOURCE_L2)
1220 ++ update = l2_qos_cfg_update;
1221 ++ else
1222 ++ return -EINVAL;
1223 ++
1224 ++ r_l = &rdt_resources_all[level];
1225 ++ list_for_each_entry(d, &r_l->domains, list) {
1226 + /* Pick one CPU from each domain instance to update MSR */
1227 + cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
1228 + }
1229 + cpu = get_cpu();
1230 + /* Update QOS_CFG MSR on this cpu if it's in cpu_mask. */
1231 + if (cpumask_test_cpu(cpu, cpu_mask))
1232 +- l3_qos_cfg_update(&enable);
1233 ++ update(&enable);
1234 + /* Update QOS_CFG MSR on all other cpus in cpu_mask. */
1235 +- smp_call_function_many(cpu_mask, l3_qos_cfg_update, &enable, 1);
1236 ++ smp_call_function_many(cpu_mask, update, &enable, 1);
1237 + put_cpu();
1238 +
1239 + free_cpumask_var(cpu_mask);
1240 +@@ -955,52 +973,99 @@ static int set_l3_qos_cfg(struct rdt_resource *r, bool enable)
1241 + return 0;
1242 + }
1243 +
1244 +-static int cdp_enable(void)
1245 ++static int cdp_enable(int level, int data_type, int code_type)
1246 + {
1247 +- struct rdt_resource *r_l3data = &rdt_resources_all[RDT_RESOURCE_L3DATA];
1248 +- struct rdt_resource *r_l3code = &rdt_resources_all[RDT_RESOURCE_L3CODE];
1249 +- struct rdt_resource *r_l3 = &rdt_resources_all[RDT_RESOURCE_L3];
1250 ++ struct rdt_resource *r_ldata = &rdt_resources_all[data_type];
1251 ++ struct rdt_resource *r_lcode = &rdt_resources_all[code_type];
1252 ++ struct rdt_resource *r_l = &rdt_resources_all[level];
1253 + int ret;
1254 +
1255 +- if (!r_l3->alloc_capable || !r_l3data->alloc_capable ||
1256 +- !r_l3code->alloc_capable)
1257 ++ if (!r_l->alloc_capable || !r_ldata->alloc_capable ||
1258 ++ !r_lcode->alloc_capable)
1259 + return -EINVAL;
1260 +
1261 +- ret = set_l3_qos_cfg(r_l3, true);
1262 ++ ret = set_cache_qos_cfg(level, true);
1263 + if (!ret) {
1264 +- r_l3->alloc_enabled = false;
1265 +- r_l3data->alloc_enabled = true;
1266 +- r_l3code->alloc_enabled = true;
1267 ++ r_l->alloc_enabled = false;
1268 ++ r_ldata->alloc_enabled = true;
1269 ++ r_lcode->alloc_enabled = true;
1270 + }
1271 + return ret;
1272 + }
1273 +
1274 +-static void cdp_disable(void)
1275 ++static int cdpl3_enable(void)
1276 + {
1277 +- struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3];
1278 ++ return cdp_enable(RDT_RESOURCE_L3, RDT_RESOURCE_L3DATA,
1279 ++ RDT_RESOURCE_L3CODE);
1280 ++}
1281 ++
1282 ++static int cdpl2_enable(void)
1283 ++{
1284 ++ return cdp_enable(RDT_RESOURCE_L2, RDT_RESOURCE_L2DATA,
1285 ++ RDT_RESOURCE_L2CODE);
1286 ++}
1287 ++
1288 ++static void cdp_disable(int level, int data_type, int code_type)
1289 ++{
1290 ++ struct rdt_resource *r = &rdt_resources_all[level];
1291 +
1292 + r->alloc_enabled = r->alloc_capable;
1293 +
1294 +- if (rdt_resources_all[RDT_RESOURCE_L3DATA].alloc_enabled) {
1295 +- rdt_resources_all[RDT_RESOURCE_L3DATA].alloc_enabled = false;
1296 +- rdt_resources_all[RDT_RESOURCE_L3CODE].alloc_enabled = false;
1297 +- set_l3_qos_cfg(r, false);
1298 ++ if (rdt_resources_all[data_type].alloc_enabled) {
1299 ++ rdt_resources_all[data_type].alloc_enabled = false;
1300 ++ rdt_resources_all[code_type].alloc_enabled = false;
1301 ++ set_cache_qos_cfg(level, false);
1302 + }
1303 + }
1304 +
1305 ++static void cdpl3_disable(void)
1306 ++{
1307 ++ cdp_disable(RDT_RESOURCE_L3, RDT_RESOURCE_L3DATA, RDT_RESOURCE_L3CODE);
1308 ++}
1309 ++
1310 ++static void cdpl2_disable(void)
1311 ++{
1312 ++ cdp_disable(RDT_RESOURCE_L2, RDT_RESOURCE_L2DATA, RDT_RESOURCE_L2CODE);
1313 ++}
1314 ++
1315 ++static void cdp_disable_all(void)
1316 ++{
1317 ++ if (rdt_resources_all[RDT_RESOURCE_L3DATA].alloc_enabled)
1318 ++ cdpl3_disable();
1319 ++ if (rdt_resources_all[RDT_RESOURCE_L2DATA].alloc_enabled)
1320 ++ cdpl2_disable();
1321 ++}
1322 ++
1323 + static int parse_rdtgroupfs_options(char *data)
1324 + {
1325 + char *token, *o = data;
1326 + int ret = 0;
1327 +
1328 + while ((token = strsep(&o, ",")) != NULL) {
1329 +- if (!*token)
1330 +- return -EINVAL;
1331 ++ if (!*token) {
1332 ++ ret = -EINVAL;
1333 ++ goto out;
1334 ++ }
1335 +
1336 +- if (!strcmp(token, "cdp"))
1337 +- ret = cdp_enable();
1338 ++ if (!strcmp(token, "cdp")) {
1339 ++ ret = cdpl3_enable();
1340 ++ if (ret)
1341 ++ goto out;
1342 ++ } else if (!strcmp(token, "cdpl2")) {
1343 ++ ret = cdpl2_enable();
1344 ++ if (ret)
1345 ++ goto out;
1346 ++ } else {
1347 ++ ret = -EINVAL;
1348 ++ goto out;
1349 ++ }
1350 + }
1351 +
1352 ++ return 0;
1353 ++
1354 ++out:
1355 ++ pr_err("Invalid mount option \"%s\"\n", token);
1356 ++
1357 + return ret;
1358 + }
1359 +
1360 +@@ -1155,7 +1220,7 @@ out_mongrp:
1361 + out_info:
1362 + kernfs_remove(kn_info);
1363 + out_cdp:
1364 +- cdp_disable();
1365 ++ cdp_disable_all();
1366 + out:
1367 + mutex_unlock(&rdtgroup_mutex);
1368 + cpus_read_unlock();
1369 +@@ -1322,7 +1387,7 @@ static void rdt_kill_sb(struct super_block *sb)
1370 + /*Put everything back to default values. */
1371 + for_each_alloc_enabled_rdt_resource(r)
1372 + reset_all_ctrls(r);
1373 +- cdp_disable();
1374 ++ cdp_disable_all();
1375 + rmdir_all_sub();
1376 + static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
1377 + static_branch_disable_cpuslocked(&rdt_mon_enable_key);
1378 +@@ -1692,6 +1757,19 @@ out_unlock:
1379 + return ret;
1380 + }
1381 +
1382 ++/* Restore the qos cfg state when a domain comes online */
1383 ++void rdt_domain_reconfigure_cdp(struct rdt_resource *r)
1384 ++{
1385 ++ if (!r->alloc_capable)
1386 ++ return;
1387 ++
1388 ++ if (r == &rdt_resources_all[RDT_RESOURCE_L2DATA])
1389 ++ l2_qos_cfg_update(&r->alloc_enabled);
1390 ++
1391 ++ if (r == &rdt_resources_all[RDT_RESOURCE_L3DATA])
1392 ++ l3_qos_cfg_update(&r->alloc_enabled);
1393 ++}
1394 ++
1395 + /*
1396 + * We allow creating mon groups only with in a directory called "mon_groups"
1397 + * which is present in every ctrl_mon group. Check if this is a valid
1398 +@@ -1840,7 +1918,8 @@ static int rdtgroup_rmdir(struct kernfs_node *kn)
1399 + * If the rdtgroup is a mon group and parent directory
1400 + * is a valid "mon_groups" directory, remove the mon group.
1401 + */
1402 +- if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn)
1403 ++ if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn &&
1404 ++ rdtgrp != &rdtgroup_default)
1405 + ret = rdtgroup_rmdir_ctrl(kn, rdtgrp, tmpmask);
1406 + else if (rdtgrp->type == RDTMON_GROUP &&
1407 + is_mon_groups(parent_kn, kn->name))
1408 +diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
1409 +index ed7ce5184a77..0b9c7150cb23 100644
1410 +--- a/arch/x86/kernel/cpu/scattered.c
1411 ++++ b/arch/x86/kernel/cpu/scattered.c
1412 +@@ -28,6 +28,7 @@ static const struct cpuid_bit cpuid_bits[] = {
1413 + { X86_FEATURE_CAT_L3, CPUID_EBX, 1, 0x00000010, 0 },
1414 + { X86_FEATURE_CAT_L2, CPUID_EBX, 2, 0x00000010, 0 },
1415 + { X86_FEATURE_CDP_L3, CPUID_ECX, 2, 0x00000010, 1 },
1416 ++ { X86_FEATURE_CDP_L2, CPUID_ECX, 2, 0x00000010, 2 },
1417 + { X86_FEATURE_MBA, CPUID_EBX, 3, 0x00000010, 0 },
1418 + { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 },
1419 + { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 },
1420 +diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
1421 +index 1152afad524f..6ec1cfd0addd 100644
1422 +--- a/arch/x86/kvm/cpuid.c
1423 ++++ b/arch/x86/kvm/cpuid.c
1424 +@@ -494,7 +494,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1425 + entry->edx |= F(SPEC_CTRL);
1426 + if (boot_cpu_has(X86_FEATURE_STIBP))
1427 + entry->edx |= F(INTEL_STIBP);
1428 +- if (boot_cpu_has(X86_FEATURE_SSBD))
1429 ++ if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
1430 ++ boot_cpu_has(X86_FEATURE_AMD_SSBD))
1431 + entry->edx |= F(SPEC_CTRL_SSBD);
1432 + /*
1433 + * We emulate ARCH_CAPABILITIES in software even
1434 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
1435 +index f85680b86524..f8e3f3c48283 100644
1436 +--- a/arch/x86/kvm/vmx.c
1437 ++++ b/arch/x86/kvm/vmx.c
1438 +@@ -1674,43 +1674,15 @@ static void vmcs_load(struct vmcs *vmcs)
1439 + }
1440 +
1441 + #ifdef CONFIG_KEXEC_CORE
1442 +-/*
1443 +- * This bitmap is used to indicate whether the vmclear
1444 +- * operation is enabled on all cpus. All disabled by
1445 +- * default.
1446 +- */
1447 +-static cpumask_t crash_vmclear_enabled_bitmap = CPU_MASK_NONE;
1448 +-
1449 +-static inline void crash_enable_local_vmclear(int cpu)
1450 +-{
1451 +- cpumask_set_cpu(cpu, &crash_vmclear_enabled_bitmap);
1452 +-}
1453 +-
1454 +-static inline void crash_disable_local_vmclear(int cpu)
1455 +-{
1456 +- cpumask_clear_cpu(cpu, &crash_vmclear_enabled_bitmap);
1457 +-}
1458 +-
1459 +-static inline int crash_local_vmclear_enabled(int cpu)
1460 +-{
1461 +- return cpumask_test_cpu(cpu, &crash_vmclear_enabled_bitmap);
1462 +-}
1463 +-
1464 + static void crash_vmclear_local_loaded_vmcss(void)
1465 + {
1466 + int cpu = raw_smp_processor_id();
1467 + struct loaded_vmcs *v;
1468 +
1469 +- if (!crash_local_vmclear_enabled(cpu))
1470 +- return;
1471 +-
1472 + list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu),
1473 + loaded_vmcss_on_cpu_link)
1474 + vmcs_clear(v->vmcs);
1475 + }
1476 +-#else
1477 +-static inline void crash_enable_local_vmclear(int cpu) { }
1478 +-static inline void crash_disable_local_vmclear(int cpu) { }
1479 + #endif /* CONFIG_KEXEC_CORE */
1480 +
1481 + static void __loaded_vmcs_clear(void *arg)
1482 +@@ -1722,19 +1694,24 @@ static void __loaded_vmcs_clear(void *arg)
1483 + return; /* vcpu migration can race with cpu offline */
1484 + if (per_cpu(current_vmcs, cpu) == loaded_vmcs->vmcs)
1485 + per_cpu(current_vmcs, cpu) = NULL;
1486 +- crash_disable_local_vmclear(cpu);
1487 ++
1488 ++ vmcs_clear(loaded_vmcs->vmcs);
1489 ++ if (loaded_vmcs->shadow_vmcs && loaded_vmcs->launched)
1490 ++ vmcs_clear(loaded_vmcs->shadow_vmcs);
1491 ++
1492 + list_del(&loaded_vmcs->loaded_vmcss_on_cpu_link);
1493 +
1494 + /*
1495 +- * we should ensure updating loaded_vmcs->loaded_vmcss_on_cpu_link
1496 +- * is before setting loaded_vmcs->vcpu to -1 which is done in
1497 +- * loaded_vmcs_init. Otherwise, other cpu can see vcpu = -1 fist
1498 +- * then adds the vmcs into percpu list before it is deleted.
1499 ++ * Ensure all writes to loaded_vmcs, including deleting it from its
1500 ++ * current percpu list, complete before setting loaded_vmcs->vcpu to
1501 ++ * -1, otherwise a different cpu can see vcpu == -1 first and add
1502 ++ * loaded_vmcs to its percpu list before it's deleted from this cpu's
1503 ++ * list. Pairs with the smp_rmb() in vmx_vcpu_load_vmcs().
1504 + */
1505 + smp_wmb();
1506 +
1507 +- loaded_vmcs_init(loaded_vmcs);
1508 +- crash_enable_local_vmclear(cpu);
1509 ++ loaded_vmcs->cpu = -1;
1510 ++ loaded_vmcs->launched = 0;
1511 + }
1512 +
1513 + static void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs)
1514 +@@ -2497,18 +2474,17 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
1515 + if (!already_loaded) {
1516 + loaded_vmcs_clear(vmx->loaded_vmcs);
1517 + local_irq_disable();
1518 +- crash_disable_local_vmclear(cpu);
1519 +
1520 + /*
1521 +- * Read loaded_vmcs->cpu should be before fetching
1522 +- * loaded_vmcs->loaded_vmcss_on_cpu_link.
1523 +- * See the comments in __loaded_vmcs_clear().
1524 ++ * Ensure loaded_vmcs->cpu is read before adding loaded_vmcs to
1525 ++ * this cpu's percpu list, otherwise it may not yet be deleted
1526 ++ * from its previous cpu's percpu list. Pairs with the
1527 ++ * smb_wmb() in __loaded_vmcs_clear().
1528 + */
1529 + smp_rmb();
1530 +
1531 + list_add(&vmx->loaded_vmcs->loaded_vmcss_on_cpu_link,
1532 + &per_cpu(loaded_vmcss_on_cpu, cpu));
1533 +- crash_enable_local_vmclear(cpu);
1534 + local_irq_enable();
1535 + }
1536 +
1537 +@@ -3800,21 +3776,6 @@ static int hardware_enable(void)
1538 + if (cr4_read_shadow() & X86_CR4_VMXE)
1539 + return -EBUSY;
1540 +
1541 +- INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu));
1542 +- INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu));
1543 +- spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
1544 +-
1545 +- /*
1546 +- * Now we can enable the vmclear operation in kdump
1547 +- * since the loaded_vmcss_on_cpu list on this cpu
1548 +- * has been initialized.
1549 +- *
1550 +- * Though the cpu is not in VMX operation now, there
1551 +- * is no problem to enable the vmclear operation
1552 +- * for the loaded_vmcss_on_cpu list is empty!
1553 +- */
1554 +- crash_enable_local_vmclear(cpu);
1555 +-
1556 + rdmsrl(MSR_IA32_FEATURE_CONTROL, old);
1557 +
1558 + test_bits = FEATURE_CONTROL_LOCKED;
1559 +@@ -6198,8 +6159,13 @@ static int vmx_nmi_allowed(struct kvm_vcpu *vcpu)
1560 +
1561 + static int vmx_interrupt_allowed(struct kvm_vcpu *vcpu)
1562 + {
1563 +- return (!to_vmx(vcpu)->nested.nested_run_pending &&
1564 +- vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) &&
1565 ++ if (to_vmx(vcpu)->nested.nested_run_pending)
1566 ++ return false;
1567 ++
1568 ++ if (is_guest_mode(vcpu) && nested_exit_on_intr(vcpu))
1569 ++ return true;
1570 ++
1571 ++ return (vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) &&
1572 + !(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) &
1573 + (GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS));
1574 + }
1575 +@@ -11659,7 +11625,7 @@ static void vmcs12_save_pending_event(struct kvm_vcpu *vcpu,
1576 + }
1577 + }
1578 +
1579 +-static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr)
1580 ++static int vmx_check_nested_events(struct kvm_vcpu *vcpu)
1581 + {
1582 + struct vcpu_vmx *vmx = to_vmx(vcpu);
1583 + unsigned long exit_qual;
1584 +@@ -11697,8 +11663,7 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr)
1585 + return 0;
1586 + }
1587 +
1588 +- if ((kvm_cpu_has_interrupt(vcpu) || external_intr) &&
1589 +- nested_exit_on_intr(vcpu)) {
1590 ++ if (kvm_cpu_has_interrupt(vcpu) && nested_exit_on_intr(vcpu)) {
1591 + if (block_nested_events)
1592 + return -EBUSY;
1593 + nested_vmx_vmexit(vcpu, EXIT_REASON_EXTERNAL_INTERRUPT, 0, 0);
1594 +@@ -12254,17 +12219,8 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
1595 + vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
1596 +
1597 + if (likely(!vmx->fail)) {
1598 +- /*
1599 +- * TODO: SDM says that with acknowledge interrupt on
1600 +- * exit, bit 31 of the VM-exit interrupt information
1601 +- * (valid interrupt) is always set to 1 on
1602 +- * EXIT_REASON_EXTERNAL_INTERRUPT, so we shouldn't
1603 +- * need kvm_cpu_has_interrupt(). See the commit
1604 +- * message for details.
1605 +- */
1606 +- if (nested_exit_intr_ack_set(vcpu) &&
1607 +- exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
1608 +- kvm_cpu_has_interrupt(vcpu)) {
1609 ++ if (exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
1610 ++ nested_exit_intr_ack_set(vcpu)) {
1611 + int irq = kvm_cpu_get_interrupt(vcpu);
1612 + WARN_ON(irq < 0);
1613 + vmcs12->vm_exit_intr_info = irq |
1614 +@@ -12940,7 +12896,7 @@ module_exit(vmx_exit)
1615 +
1616 + static int __init vmx_init(void)
1617 + {
1618 +- int r;
1619 ++ int r, cpu;
1620 +
1621 + r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx),
1622 + __alignof__(struct vcpu_vmx), THIS_MODULE);
1623 +@@ -12962,6 +12918,12 @@ static int __init vmx_init(void)
1624 + }
1625 + }
1626 +
1627 ++ for_each_possible_cpu(cpu) {
1628 ++ INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu));
1629 ++ INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu));
1630 ++ spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
1631 ++ }
1632 ++
1633 + #ifdef CONFIG_KEXEC_CORE
1634 + rcu_assign_pointer(crash_vmclear_loaded_vmcss,
1635 + crash_vmclear_local_loaded_vmcss);
1636 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
1637 +index d6851636edab..5f44827e4962 100644
1638 +--- a/arch/x86/kvm/x86.c
1639 ++++ b/arch/x86/kvm/x86.c
1640 +@@ -6638,7 +6638,7 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
1641 + kvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr);
1642 + }
1643 +
1644 +-static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
1645 ++static int inject_pending_event(struct kvm_vcpu *vcpu)
1646 + {
1647 + int r;
1648 +
1649 +@@ -6665,7 +6665,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
1650 + }
1651 +
1652 + if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) {
1653 +- r = kvm_x86_ops->check_nested_events(vcpu, req_int_win);
1654 ++ r = kvm_x86_ops->check_nested_events(vcpu);
1655 + if (r != 0)
1656 + return r;
1657 + }
1658 +@@ -6706,7 +6706,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
1659 + * KVM_REQ_EVENT only on certain events and not unconditionally?
1660 + */
1661 + if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) {
1662 +- r = kvm_x86_ops->check_nested_events(vcpu, req_int_win);
1663 ++ r = kvm_x86_ops->check_nested_events(vcpu);
1664 + if (r != 0)
1665 + return r;
1666 + }
1667 +@@ -7152,7 +7152,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1668 + goto out;
1669 + }
1670 +
1671 +- if (inject_pending_event(vcpu, req_int_win) != 0)
1672 ++ if (inject_pending_event(vcpu) != 0)
1673 + req_immediate_exit = true;
1674 + else {
1675 + /* Enable NMI/IRQ window open exits if needed.
1676 +@@ -7360,7 +7360,7 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
1677 + static inline bool kvm_vcpu_running(struct kvm_vcpu *vcpu)
1678 + {
1679 + if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events)
1680 +- kvm_x86_ops->check_nested_events(vcpu, false);
1681 ++ kvm_x86_ops->check_nested_events(vcpu);
1682 +
1683 + return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE &&
1684 + !vcpu->arch.apf.halted);
1685 +@@ -8584,6 +8584,13 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
1686 + {
1687 + int i;
1688 +
1689 ++ /*
1690 ++ * Clear out the previous array pointers for the KVM_MR_MOVE case. The
1691 ++ * old arrays will be freed by __kvm_set_memory_region() if installing
1692 ++ * the new memslot is successful.
1693 ++ */
1694 ++ memset(&slot->arch, 0, sizeof(slot->arch));
1695 ++
1696 + for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) {
1697 + struct kvm_lpage_info *linfo;
1698 + unsigned long ugfn;
1699 +@@ -8657,6 +8664,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
1700 + const struct kvm_userspace_memory_region *mem,
1701 + enum kvm_mr_change change)
1702 + {
1703 ++ if (change == KVM_MR_MOVE)
1704 ++ return kvm_arch_create_memslot(kvm, memslot,
1705 ++ mem->memory_size >> PAGE_SHIFT);
1706 ++
1707 + return 0;
1708 + }
1709 +
1710 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
1711 +index 93863c6173e6..959bee9fa911 100644
1712 +--- a/block/bfq-iosched.c
1713 ++++ b/block/bfq-iosched.c
1714 +@@ -4541,20 +4541,28 @@ static void bfq_prepare_request(struct request *rq, struct bio *bio)
1715 + spin_unlock_irq(&bfqd->lock);
1716 + }
1717 +
1718 +-static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)
1719 ++static void
1720 ++bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq)
1721 + {
1722 +- struct bfq_data *bfqd = bfqq->bfqd;
1723 + enum bfqq_expiration reason;
1724 + unsigned long flags;
1725 +
1726 + spin_lock_irqsave(&bfqd->lock, flags);
1727 +- bfq_clear_bfqq_wait_request(bfqq);
1728 +
1729 ++ /*
1730 ++ * Considering that bfqq may be in race, we should firstly check
1731 ++ * whether bfqq is in service before doing something on it. If
1732 ++ * the bfqq in race is not in service, it has already been expired
1733 ++ * through __bfq_bfqq_expire func and its wait_request flags has
1734 ++ * been cleared in __bfq_bfqd_reset_in_service func.
1735 ++ */
1736 + if (bfqq != bfqd->in_service_queue) {
1737 + spin_unlock_irqrestore(&bfqd->lock, flags);
1738 + return;
1739 + }
1740 +
1741 ++ bfq_clear_bfqq_wait_request(bfqq);
1742 ++
1743 + if (bfq_bfqq_budget_timeout(bfqq))
1744 + /*
1745 + * Also here the queue can be safely expired
1746 +@@ -4599,7 +4607,7 @@ static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer)
1747 + * early.
1748 + */
1749 + if (bfqq)
1750 +- bfq_idle_slice_timer_body(bfqq);
1751 ++ bfq_idle_slice_timer_body(bfqd, bfqq);
1752 +
1753 + return HRTIMER_NORESTART;
1754 + }
1755 +diff --git a/block/blk-ioc.c b/block/blk-ioc.c
1756 +index f23311e4b201..e56a480b6f92 100644
1757 +--- a/block/blk-ioc.c
1758 ++++ b/block/blk-ioc.c
1759 +@@ -87,6 +87,7 @@ static void ioc_destroy_icq(struct io_cq *icq)
1760 + * making it impossible to determine icq_cache. Record it in @icq.
1761 + */
1762 + icq->__rcu_icq_cache = et->icq_cache;
1763 ++ icq->flags |= ICQ_DESTROYED;
1764 + call_rcu(&icq->__rcu_head, icq_free_icq_rcu);
1765 + }
1766 +
1767 +@@ -230,15 +231,21 @@ static void __ioc_clear_queue(struct list_head *icq_list)
1768 + {
1769 + unsigned long flags;
1770 +
1771 ++ rcu_read_lock();
1772 + while (!list_empty(icq_list)) {
1773 + struct io_cq *icq = list_entry(icq_list->next,
1774 + struct io_cq, q_node);
1775 + struct io_context *ioc = icq->ioc;
1776 +
1777 + spin_lock_irqsave(&ioc->lock, flags);
1778 ++ if (icq->flags & ICQ_DESTROYED) {
1779 ++ spin_unlock_irqrestore(&ioc->lock, flags);
1780 ++ continue;
1781 ++ }
1782 + ioc_destroy_icq(icq);
1783 + spin_unlock_irqrestore(&ioc->lock, flags);
1784 + }
1785 ++ rcu_read_unlock();
1786 + }
1787 +
1788 + /**
1789 +diff --git a/block/blk-settings.c b/block/blk-settings.c
1790 +index 6c2faaa38cc1..e0a744921ed3 100644
1791 +--- a/block/blk-settings.c
1792 ++++ b/block/blk-settings.c
1793 +@@ -717,6 +717,9 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
1794 + printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
1795 + top, bottom);
1796 + }
1797 ++
1798 ++ t->backing_dev_info->io_pages =
1799 ++ t->limits.max_sectors >> (PAGE_SHIFT - 9);
1800 + }
1801 + EXPORT_SYMBOL(disk_stack_limits);
1802 +
1803 +diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
1804 +index 7f9aff4b8d62..9fdc13a2f2d5 100644
1805 +--- a/drivers/acpi/processor_throttling.c
1806 ++++ b/drivers/acpi/processor_throttling.c
1807 +@@ -909,13 +909,6 @@ static long __acpi_processor_get_throttling(void *data)
1808 + return pr->throttling.acpi_processor_get_throttling(pr);
1809 + }
1810 +
1811 +-static int call_on_cpu(int cpu, long (*fn)(void *), void *arg, bool direct)
1812 +-{
1813 +- if (direct || (is_percpu_thread() && cpu == smp_processor_id()))
1814 +- return fn(arg);
1815 +- return work_on_cpu(cpu, fn, arg);
1816 +-}
1817 +-
1818 + static int acpi_processor_get_throttling(struct acpi_processor *pr)
1819 + {
1820 + if (!pr)
1821 +diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
1822 +index 85aa76116a30..7924d0635718 100644
1823 +--- a/drivers/ata/libata-pmp.c
1824 ++++ b/drivers/ata/libata-pmp.c
1825 +@@ -764,6 +764,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
1826 +
1827 + if (dev->flags & ATA_DFLAG_DETACH) {
1828 + detach = 1;
1829 ++ rc = -ENODEV;
1830 + goto fail;
1831 + }
1832 +
1833 +diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
1834 +index eb0c4ee20525..2f81d6534270 100644
1835 +--- a/drivers/ata/libata-scsi.c
1836 ++++ b/drivers/ata/libata-scsi.c
1837 +@@ -4571,22 +4571,19 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
1838 + */
1839 + shost->max_host_blocked = 1;
1840 +
1841 +- rc = scsi_add_host_with_dma(ap->scsi_host,
1842 +- &ap->tdev, ap->host->dev);
1843 ++ rc = scsi_add_host_with_dma(shost, &ap->tdev, ap->host->dev);
1844 + if (rc)
1845 +- goto err_add;
1846 ++ goto err_alloc;
1847 + }
1848 +
1849 + return 0;
1850 +
1851 +- err_add:
1852 +- scsi_host_put(host->ports[i]->scsi_host);
1853 + err_alloc:
1854 + while (--i >= 0) {
1855 + struct Scsi_Host *shost = host->ports[i]->scsi_host;
1856 +
1857 ++ /* scsi_host_put() is in ata_devres_release() */
1858 + scsi_remove_host(shost);
1859 +- scsi_host_put(shost);
1860 + }
1861 + return rc;
1862 + }
1863 +diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
1864 +index 41be9ff7d70a..3da53cc6cf2b 100644
1865 +--- a/drivers/base/arch_topology.c
1866 ++++ b/drivers/base/arch_topology.c
1867 +@@ -96,7 +96,7 @@ subsys_initcall(register_cpu_capacity_sysctl);
1868 + static u32 capacity_scale;
1869 + static u32 *raw_capacity;
1870 +
1871 +-static int __init free_raw_capacity(void)
1872 ++static int free_raw_capacity(void)
1873 + {
1874 + kfree(raw_capacity);
1875 + raw_capacity = NULL;
1876 +diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
1877 +index f01d4a8a783a..b12e373aa956 100644
1878 +--- a/drivers/block/null_blk.c
1879 ++++ b/drivers/block/null_blk.c
1880 +@@ -622,6 +622,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
1881 + if (tag != -1U) {
1882 + cmd = &nq->cmds[tag];
1883 + cmd->tag = tag;
1884 ++ cmd->error = BLK_STS_OK;
1885 + cmd->nq = nq;
1886 + if (nq->dev->irqmode == NULL_IRQ_TIMER) {
1887 + hrtimer_init(&cmd->timer, CLOCK_MONOTONIC,
1888 +@@ -1399,6 +1400,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
1889 + cmd->timer.function = null_cmd_timer_expired;
1890 + }
1891 + cmd->rq = bd->rq;
1892 ++ cmd->error = BLK_STS_OK;
1893 + cmd->nq = nq;
1894 +
1895 + blk_mq_start_request(bd->rq);
1896 +@@ -1593,7 +1595,12 @@ static void null_nvm_unregister(struct nullb *nullb) {}
1897 +
1898 + static void null_del_dev(struct nullb *nullb)
1899 + {
1900 +- struct nullb_device *dev = nullb->dev;
1901 ++ struct nullb_device *dev;
1902 ++
1903 ++ if (!nullb)
1904 ++ return;
1905 ++
1906 ++ dev = nullb->dev;
1907 +
1908 + ida_simple_remove(&nullb_indexes, nullb->index);
1909 +
1910 +@@ -1919,6 +1926,7 @@ out_cleanup_queues:
1911 + cleanup_queues(nullb);
1912 + out_free_nullb:
1913 + kfree(nullb);
1914 ++ dev->nullb = NULL;
1915 + out:
1916 + return rv;
1917 + }
1918 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
1919 +index f2b1994d58a0..557cf52f674b 100644
1920 +--- a/drivers/block/rbd.c
1921 ++++ b/drivers/block/rbd.c
1922 +@@ -3847,6 +3847,10 @@ static void cancel_tasks_sync(struct rbd_device *rbd_dev)
1923 + cancel_work_sync(&rbd_dev->unlock_work);
1924 + }
1925 +
1926 ++/*
1927 ++ * header_rwsem must not be held to avoid a deadlock with
1928 ++ * rbd_dev_refresh() when flushing notifies.
1929 ++ */
1930 + static void rbd_unregister_watch(struct rbd_device *rbd_dev)
1931 + {
1932 + WARN_ON(waitqueue_active(&rbd_dev->lock_waitq));
1933 +@@ -6044,9 +6048,10 @@ static int rbd_dev_header_name(struct rbd_device *rbd_dev)
1934 +
1935 + static void rbd_dev_image_release(struct rbd_device *rbd_dev)
1936 + {
1937 +- rbd_dev_unprobe(rbd_dev);
1938 + if (rbd_dev->opts)
1939 + rbd_unregister_watch(rbd_dev);
1940 ++
1941 ++ rbd_dev_unprobe(rbd_dev);
1942 + rbd_dev->image_format = 0;
1943 + kfree(rbd_dev->spec->image_id);
1944 + rbd_dev->spec->image_id = NULL;
1945 +@@ -6057,6 +6062,9 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev)
1946 + * device. If this image is the one being mapped (i.e., not a
1947 + * parent), initiate a watch on its header object before using that
1948 + * object to get detailed information about the rbd image.
1949 ++ *
1950 ++ * On success, returns with header_rwsem held for write if called
1951 ++ * with @depth == 0.
1952 + */
1953 + static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
1954 + {
1955 +@@ -6087,9 +6095,12 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
1956 + }
1957 + }
1958 +
1959 ++ if (!depth)
1960 ++ down_write(&rbd_dev->header_rwsem);
1961 ++
1962 + ret = rbd_dev_header_info(rbd_dev);
1963 + if (ret)
1964 +- goto err_out_watch;
1965 ++ goto err_out_probe;
1966 +
1967 + /*
1968 + * If this image is the one being mapped, we have pool name and
1969 +@@ -6133,10 +6144,11 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
1970 + return 0;
1971 +
1972 + err_out_probe:
1973 +- rbd_dev_unprobe(rbd_dev);
1974 +-err_out_watch:
1975 ++ if (!depth)
1976 ++ up_write(&rbd_dev->header_rwsem);
1977 + if (!depth)
1978 + rbd_unregister_watch(rbd_dev);
1979 ++ rbd_dev_unprobe(rbd_dev);
1980 + err_out_format:
1981 + rbd_dev->image_format = 0;
1982 + kfree(rbd_dev->spec->image_id);
1983 +@@ -6194,12 +6206,9 @@ static ssize_t do_rbd_add(struct bus_type *bus,
1984 + goto err_out_rbd_dev;
1985 + }
1986 +
1987 +- down_write(&rbd_dev->header_rwsem);
1988 + rc = rbd_dev_image_probe(rbd_dev, 0);
1989 +- if (rc < 0) {
1990 +- up_write(&rbd_dev->header_rwsem);
1991 ++ if (rc < 0)
1992 + goto err_out_rbd_dev;
1993 +- }
1994 +
1995 + /* If we are mapping a snapshot it must be marked read-only */
1996 +
1997 +diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
1998 +index 1b76d9585902..2ca2cc56bcef 100644
1999 +--- a/drivers/bus/sunxi-rsb.c
2000 ++++ b/drivers/bus/sunxi-rsb.c
2001 +@@ -345,7 +345,7 @@ static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr,
2002 + if (ret)
2003 + goto unlock;
2004 +
2005 +- *buf = readl(rsb->regs + RSB_DATA);
2006 ++ *buf = readl(rsb->regs + RSB_DATA) & GENMASK(len * 8 - 1, 0);
2007 +
2008 + unlock:
2009 + mutex_unlock(&rsb->lock);
2010 +diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
2011 +index c82d9fd2f05a..f72a272eeb9b 100644
2012 +--- a/drivers/char/ipmi/ipmi_msghandler.c
2013 ++++ b/drivers/char/ipmi/ipmi_msghandler.c
2014 +@@ -2647,7 +2647,9 @@ get_guid(ipmi_smi_t intf)
2015 + if (rv)
2016 + /* Send failed, no GUID available. */
2017 + intf->bmc->guid_set = 0;
2018 +- wait_event(intf->waitq, intf->bmc->guid_set != 2);
2019 ++ else
2020 ++ wait_event(intf->waitq, intf->bmc->guid_set != 2);
2021 ++
2022 + intf->null_user_handler = NULL;
2023 + }
2024 +
2025 +diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
2026 +index 791770a563fc..6fac6383d024 100644
2027 +--- a/drivers/clk/at91/clk-usb.c
2028 ++++ b/drivers/clk/at91/clk-usb.c
2029 +@@ -78,6 +78,9 @@ static int at91sam9x5_clk_usb_determine_rate(struct clk_hw *hw,
2030 + tmp_parent_rate = req->rate * div;
2031 + tmp_parent_rate = clk_hw_round_rate(parent,
2032 + tmp_parent_rate);
2033 ++ if (!tmp_parent_rate)
2034 ++ continue;
2035 ++
2036 + tmp_rate = DIV_ROUND_CLOSEST(tmp_parent_rate, div);
2037 + if (tmp_rate < req->rate)
2038 + tmp_diff = req->rate - tmp_rate;
2039 +diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
2040 +index 8341a128dab1..44b6f23cc851 100644
2041 +--- a/drivers/clk/clk.c
2042 ++++ b/drivers/clk/clk.c
2043 +@@ -2172,18 +2172,16 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
2044 +
2045 + core->dentry = d;
2046 +
2047 +- d = debugfs_create_u32("clk_rate", S_IRUGO, core->dentry,
2048 +- (u32 *)&core->rate);
2049 ++ d = debugfs_create_ulong("clk_rate", 0444, core->dentry, &core->rate);
2050 + if (!d)
2051 + goto err_out;
2052 +
2053 +- d = debugfs_create_u32("clk_accuracy", S_IRUGO, core->dentry,
2054 +- (u32 *)&core->accuracy);
2055 ++ d = debugfs_create_ulong("clk_accuracy", 0444, core->dentry,
2056 ++ &core->accuracy);
2057 + if (!d)
2058 + goto err_out;
2059 +
2060 +- d = debugfs_create_u32("clk_phase", S_IRUGO, core->dentry,
2061 +- (u32 *)&core->phase);
2062 ++ d = debugfs_create_u32("clk_phase", 0444, core->dentry, &core->phase);
2063 + if (!d)
2064 + goto err_out;
2065 +
2066 +@@ -2192,23 +2190,23 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
2067 + if (!d)
2068 + goto err_out;
2069 +
2070 +- d = debugfs_create_u32("clk_prepare_count", S_IRUGO, core->dentry,
2071 +- (u32 *)&core->prepare_count);
2072 ++ d = debugfs_create_u32("clk_prepare_count", 0444, core->dentry,
2073 ++ &core->prepare_count);
2074 + if (!d)
2075 + goto err_out;
2076 +
2077 +- d = debugfs_create_u32("clk_enable_count", S_IRUGO, core->dentry,
2078 +- (u32 *)&core->enable_count);
2079 ++ d = debugfs_create_u32("clk_enable_count", 0444, core->dentry,
2080 ++ &core->enable_count);
2081 + if (!d)
2082 + goto err_out;
2083 +
2084 +- d = debugfs_create_u32("clk_notifier_count", S_IRUGO, core->dentry,
2085 +- (u32 *)&core->notifier_count);
2086 ++ d = debugfs_create_u32("clk_notifier_count", 0444, core->dentry,
2087 ++ &core->notifier_count);
2088 + if (!d)
2089 + goto err_out;
2090 +
2091 + if (core->num_parents > 1) {
2092 +- d = debugfs_create_file("clk_possible_parents", S_IRUGO,
2093 ++ d = debugfs_create_file("clk_possible_parents", 0444,
2094 + core->dentry, core, &possible_parents_fops);
2095 + if (!d)
2096 + goto err_out;
2097 +@@ -2304,22 +2302,22 @@ static int __init clk_debug_init(void)
2098 + if (!rootdir)
2099 + return -ENOMEM;
2100 +
2101 +- d = debugfs_create_file("clk_summary", S_IRUGO, rootdir, &all_lists,
2102 ++ d = debugfs_create_file("clk_summary", 0444, rootdir, &all_lists,
2103 + &clk_summary_fops);
2104 + if (!d)
2105 + return -ENOMEM;
2106 +
2107 +- d = debugfs_create_file("clk_dump", S_IRUGO, rootdir, &all_lists,
2108 ++ d = debugfs_create_file("clk_dump", 0444, rootdir, &all_lists,
2109 + &clk_dump_fops);
2110 + if (!d)
2111 + return -ENOMEM;
2112 +
2113 +- d = debugfs_create_file("clk_orphan_summary", S_IRUGO, rootdir,
2114 ++ d = debugfs_create_file("clk_orphan_summary", 0444, rootdir,
2115 + &orphan_list, &clk_summary_fops);
2116 + if (!d)
2117 + return -ENOMEM;
2118 +
2119 +- d = debugfs_create_file("clk_orphan_dump", S_IRUGO, rootdir,
2120 ++ d = debugfs_create_file("clk_orphan_dump", 0444, rootdir,
2121 + &orphan_list, &clk_dump_fops);
2122 + if (!d)
2123 + return -ENOMEM;
2124 +diff --git a/drivers/clk/tegra/clk-tegra-pmc.c b/drivers/clk/tegra/clk-tegra-pmc.c
2125 +index a35579a3f884..476dab494c44 100644
2126 +--- a/drivers/clk/tegra/clk-tegra-pmc.c
2127 ++++ b/drivers/clk/tegra/clk-tegra-pmc.c
2128 +@@ -60,16 +60,16 @@ struct pmc_clk_init_data {
2129 +
2130 + static DEFINE_SPINLOCK(clk_out_lock);
2131 +
2132 +-static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
2133 +- "clk_m_div4", "extern1",
2134 ++static const char *clk_out1_parents[] = { "osc", "osc_div2",
2135 ++ "osc_div4", "extern1",
2136 + };
2137 +
2138 +-static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
2139 +- "clk_m_div4", "extern2",
2140 ++static const char *clk_out2_parents[] = { "osc", "osc_div2",
2141 ++ "osc_div4", "extern2",
2142 + };
2143 +
2144 +-static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
2145 +- "clk_m_div4", "extern3",
2146 ++static const char *clk_out3_parents[] = { "osc", "osc_div2",
2147 ++ "osc_div4", "extern3",
2148 + };
2149 +
2150 + static struct pmc_clk_init_data pmc_clks[] = {
2151 +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
2152 +index 33854bf127f9..25c9a6cdd861 100644
2153 +--- a/drivers/cpufreq/powernv-cpufreq.c
2154 ++++ b/drivers/cpufreq/powernv-cpufreq.c
2155 +@@ -1041,6 +1041,12 @@ free_and_return:
2156 +
2157 + static inline void clean_chip_info(void)
2158 + {
2159 ++ int i;
2160 ++
2161 ++ /* flush any pending work items */
2162 ++ if (chips)
2163 ++ for (i = 0; i < nr_chips; i++)
2164 ++ cancel_work_sync(&chips[i].throttle);
2165 + kfree(chips);
2166 + }
2167 +
2168 +diff --git a/drivers/crypto/caam/caamalg_desc.c b/drivers/crypto/caam/caamalg_desc.c
2169 +index b23c7b72525c..a3d507fb9ea5 100644
2170 +--- a/drivers/crypto/caam/caamalg_desc.c
2171 ++++ b/drivers/crypto/caam/caamalg_desc.c
2172 +@@ -1280,7 +1280,13 @@ EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_givencap);
2173 + */
2174 + void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata)
2175 + {
2176 +- __be64 sector_size = cpu_to_be64(512);
2177 ++ /*
2178 ++ * Set sector size to a big value, practically disabling
2179 ++ * sector size segmentation in xts implementation. We cannot
2180 ++ * take full advantage of this HW feature with existing
2181 ++ * crypto API / dm-crypt SW architecture.
2182 ++ */
2183 ++ __be64 sector_size = cpu_to_be64(BIT(15));
2184 + u32 *key_jump_cmd;
2185 +
2186 + init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);
2187 +@@ -1332,7 +1338,13 @@ EXPORT_SYMBOL(cnstr_shdsc_xts_ablkcipher_encap);
2188 + */
2189 + void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata)
2190 + {
2191 +- __be64 sector_size = cpu_to_be64(512);
2192 ++ /*
2193 ++ * Set sector size to a big value, practically disabling
2194 ++ * sector size segmentation in xts implementation. We cannot
2195 ++ * take full advantage of this HW feature with existing
2196 ++ * crypto API / dm-crypt SW architecture.
2197 ++ */
2198 ++ __be64 sector_size = cpu_to_be64(BIT(15));
2199 + u32 *key_jump_cmd;
2200 +
2201 + init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);
2202 +diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
2203 +index e1e1e8110790..5a4b8aee22a8 100644
2204 +--- a/drivers/crypto/mxs-dcp.c
2205 ++++ b/drivers/crypto/mxs-dcp.c
2206 +@@ -25,6 +25,7 @@
2207 + #include <crypto/sha.h>
2208 + #include <crypto/internal/hash.h>
2209 + #include <crypto/internal/skcipher.h>
2210 ++#include <crypto/scatterwalk.h>
2211 +
2212 + #define DCP_MAX_CHANS 4
2213 + #define DCP_BUF_SZ PAGE_SIZE
2214 +@@ -621,49 +622,46 @@ static int dcp_sha_req_to_buf(struct crypto_async_request *arq)
2215 + struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
2216 + struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
2217 + struct hash_alg_common *halg = crypto_hash_alg_common(tfm);
2218 +- const int nents = sg_nents(req->src);
2219 +
2220 + uint8_t *in_buf = sdcp->coh->sha_in_buf;
2221 + uint8_t *out_buf = sdcp->coh->sha_out_buf;
2222 +
2223 +- uint8_t *src_buf;
2224 +-
2225 + struct scatterlist *src;
2226 +
2227 +- unsigned int i, len, clen;
2228 ++ unsigned int i, len, clen, oft = 0;
2229 + int ret;
2230 +
2231 + int fin = rctx->fini;
2232 + if (fin)
2233 + rctx->fini = 0;
2234 +
2235 +- for_each_sg(req->src, src, nents, i) {
2236 +- src_buf = sg_virt(src);
2237 +- len = sg_dma_len(src);
2238 +-
2239 +- do {
2240 +- if (actx->fill + len > DCP_BUF_SZ)
2241 +- clen = DCP_BUF_SZ - actx->fill;
2242 +- else
2243 +- clen = len;
2244 +-
2245 +- memcpy(in_buf + actx->fill, src_buf, clen);
2246 +- len -= clen;
2247 +- src_buf += clen;
2248 +- actx->fill += clen;
2249 ++ src = req->src;
2250 ++ len = req->nbytes;
2251 +
2252 +- /*
2253 +- * If we filled the buffer and still have some
2254 +- * more data, submit the buffer.
2255 +- */
2256 +- if (len && actx->fill == DCP_BUF_SZ) {
2257 +- ret = mxs_dcp_run_sha(req);
2258 +- if (ret)
2259 +- return ret;
2260 +- actx->fill = 0;
2261 +- rctx->init = 0;
2262 +- }
2263 +- } while (len);
2264 ++ while (len) {
2265 ++ if (actx->fill + len > DCP_BUF_SZ)
2266 ++ clen = DCP_BUF_SZ - actx->fill;
2267 ++ else
2268 ++ clen = len;
2269 ++
2270 ++ scatterwalk_map_and_copy(in_buf + actx->fill, src, oft, clen,
2271 ++ 0);
2272 ++
2273 ++ len -= clen;
2274 ++ oft += clen;
2275 ++ actx->fill += clen;
2276 ++
2277 ++ /*
2278 ++ * If we filled the buffer and still have some
2279 ++ * more data, submit the buffer.
2280 ++ */
2281 ++ if (len && actx->fill == DCP_BUF_SZ) {
2282 ++ ret = mxs_dcp_run_sha(req);
2283 ++ if (ret)
2284 ++ return ret;
2285 ++ actx->fill = 0;
2286 ++ rctx->init = 0;
2287 ++ }
2288 + }
2289 +
2290 + if (fin) {
2291 +diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
2292 +index f50072b51aef..b39b7e6d4e4d 100644
2293 +--- a/drivers/firmware/efi/efi.c
2294 ++++ b/drivers/firmware/efi/efi.c
2295 +@@ -550,7 +550,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
2296 + }
2297 + }
2298 +
2299 +- if (efi_enabled(EFI_MEMMAP))
2300 ++ if (!IS_ENABLED(CONFIG_X86_32) && efi_enabled(EFI_MEMMAP))
2301 + efi_memattr_init();
2302 +
2303 + /* Parse the EFI Properties table if it exists */
2304 +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
2305 +index f0777a7a4305..d5b42cc86d71 100644
2306 +--- a/drivers/gpio/gpiolib.c
2307 ++++ b/drivers/gpio/gpiolib.c
2308 +@@ -1245,31 +1245,14 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
2309 + struct gpio_desc *desc = &gdev->descs[i];
2310 +
2311 + desc->gdev = gdev;
2312 +- /*
2313 +- * REVISIT: most hardware initializes GPIOs as inputs
2314 +- * (often with pullups enabled) so power usage is
2315 +- * minimized. Linux code should set the gpio direction
2316 +- * first thing; but until it does, and in case
2317 +- * chip->get_direction is not set, we may expose the
2318 +- * wrong direction in sysfs.
2319 +- */
2320 +-
2321 +- if (chip->get_direction) {
2322 +- /*
2323 +- * If we have .get_direction, set up the initial
2324 +- * direction flag from the hardware.
2325 +- */
2326 +- int dir = chip->get_direction(chip, i);
2327 +
2328 +- if (!dir)
2329 +- set_bit(FLAG_IS_OUT, &desc->flags);
2330 +- } else if (!chip->direction_input) {
2331 +- /*
2332 +- * If the chip lacks the .direction_input callback
2333 +- * we logically assume all lines are outputs.
2334 +- */
2335 +- set_bit(FLAG_IS_OUT, &desc->flags);
2336 +- }
2337 ++ /* REVISIT: most hardware initializes GPIOs as inputs (often
2338 ++ * with pullups enabled) so power usage is minimized. Linux
2339 ++ * code should set the gpio direction first thing; but until
2340 ++ * it does, and in case chip->get_direction is not set, we may
2341 ++ * expose the wrong direction in sysfs.
2342 ++ */
2343 ++ desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0;
2344 + }
2345 +
2346 + #ifdef CONFIG_PINCTRL
2347 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
2348 +index 61fff25b4ce7..ecd4eba221c0 100644
2349 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
2350 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
2351 +@@ -550,9 +550,9 @@ kfd_gtt_out:
2352 + return 0;
2353 +
2354 + kfd_gtt_no_free_chunk:
2355 +- pr_debug("Allocation failed with mem_obj = %p\n", mem_obj);
2356 ++ pr_debug("Allocation failed with mem_obj = %p\n", *mem_obj);
2357 + mutex_unlock(&kfd->gtt_sa_lock);
2358 +- kfree(mem_obj);
2359 ++ kfree(*mem_obj);
2360 + return -ENOMEM;
2361 + }
2362 +
2363 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
2364 +index f0d819fc16cd..42eaeae86bb8 100644
2365 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
2366 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
2367 +@@ -1043,10 +1043,12 @@ static bool drm_dp_port_setup_pdt(struct drm_dp_mst_port *port)
2368 + lct = drm_dp_calculate_rad(port, rad);
2369 +
2370 + port->mstb = drm_dp_add_mst_branch_device(lct, rad);
2371 +- port->mstb->mgr = port->mgr;
2372 +- port->mstb->port_parent = port;
2373 ++ if (port->mstb) {
2374 ++ port->mstb->mgr = port->mgr;
2375 ++ port->mstb->port_parent = port;
2376 +
2377 +- send_link = true;
2378 ++ send_link = true;
2379 ++ }
2380 + break;
2381 + }
2382 + return send_link;
2383 +@@ -2038,6 +2040,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
2384 + int ret = 0;
2385 + struct drm_dp_mst_branch *mstb = NULL;
2386 +
2387 ++ mutex_lock(&mgr->payload_lock);
2388 + mutex_lock(&mgr->lock);
2389 + if (mst_state == mgr->mst_state)
2390 + goto out_unlock;
2391 +@@ -2096,7 +2099,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
2392 + /* this can fail if the device is gone */
2393 + drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, 0);
2394 + ret = 0;
2395 +- memset(mgr->payloads, 0, mgr->max_payloads * sizeof(struct drm_dp_payload));
2396 ++ memset(mgr->payloads, 0,
2397 ++ mgr->max_payloads * sizeof(mgr->payloads[0]));
2398 ++ memset(mgr->proposed_vcpis, 0,
2399 ++ mgr->max_payloads * sizeof(mgr->proposed_vcpis[0]));
2400 + mgr->payload_mask = 0;
2401 + set_bit(0, &mgr->payload_mask);
2402 + mgr->vcpi_mask = 0;
2403 +@@ -2104,6 +2110,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
2404 +
2405 + out_unlock:
2406 + mutex_unlock(&mgr->lock);
2407 ++ mutex_unlock(&mgr->payload_lock);
2408 + if (mstb)
2409 + drm_dp_put_mst_branch_device(mstb);
2410 + return ret;
2411 +diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
2412 +index 1235c9877d6f..2078d7706a67 100644
2413 +--- a/drivers/gpu/drm/drm_pci.c
2414 ++++ b/drivers/gpu/drm/drm_pci.c
2415 +@@ -46,8 +46,6 @@
2416 + drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
2417 + {
2418 + drm_dma_handle_t *dmah;
2419 +- unsigned long addr;
2420 +- size_t sz;
2421 +
2422 + /* pci_alloc_consistent only guarantees alignment to the smallest
2423 + * PAGE_SIZE order which is greater than or equal to the requested size.
2424 +@@ -61,22 +59,13 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
2425 + return NULL;
2426 +
2427 + dmah->size = size;
2428 +- dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP);
2429 ++ dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL);
2430 +
2431 + if (dmah->vaddr == NULL) {
2432 + kfree(dmah);
2433 + return NULL;
2434 + }
2435 +
2436 +- memset(dmah->vaddr, 0, size);
2437 +-
2438 +- /* XXX - Is virt_to_page() legal for consistent mem? */
2439 +- /* Reserve */
2440 +- for (addr = (unsigned long)dmah->vaddr, sz = size;
2441 +- sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) {
2442 +- SetPageReserved(virt_to_page((void *)addr));
2443 +- }
2444 +-
2445 + return dmah;
2446 + }
2447 +
2448 +@@ -89,19 +78,9 @@ EXPORT_SYMBOL(drm_pci_alloc);
2449 + */
2450 + void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
2451 + {
2452 +- unsigned long addr;
2453 +- size_t sz;
2454 +-
2455 +- if (dmah->vaddr) {
2456 +- /* XXX - Is virt_to_page() legal for consistent mem? */
2457 +- /* Unreserve */
2458 +- for (addr = (unsigned long)dmah->vaddr, sz = dmah->size;
2459 +- sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) {
2460 +- ClearPageReserved(virt_to_page((void *)addr));
2461 +- }
2462 ++ if (dmah->vaddr)
2463 + dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
2464 + dmah->busaddr);
2465 +- }
2466 + }
2467 +
2468 + /**
2469 +diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
2470 +index 9e62f893958a..81158ae8bfe3 100644
2471 +--- a/drivers/i2c/busses/i2c-st.c
2472 ++++ b/drivers/i2c/busses/i2c-st.c
2473 +@@ -437,6 +437,7 @@ static void st_i2c_wr_fill_tx_fifo(struct st_i2c_dev *i2c_dev)
2474 + /**
2475 + * st_i2c_rd_fill_tx_fifo() - Fill the Tx FIFO in read mode
2476 + * @i2c_dev: Controller's private data
2477 ++ * @max: Maximum amount of data to fill into the Tx FIFO
2478 + *
2479 + * This functions fills the Tx FIFO with fixed pattern when
2480 + * in read mode to trigger clock.
2481 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
2482 +index 136f6e7bf797..0d0f977a2f39 100644
2483 +--- a/drivers/input/serio/i8042-x86ia64io.h
2484 ++++ b/drivers/input/serio/i8042-x86ia64io.h
2485 +@@ -534,6 +534,17 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
2486 + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
2487 + },
2488 + },
2489 ++ {
2490 ++ /*
2491 ++ * Acer Aspire 5738z
2492 ++ * Touchpad stops working in mux mode when dis- + re-enabled
2493 ++ * with the touchpad enable/disable toggle hotkey
2494 ++ */
2495 ++ .matches = {
2496 ++ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
2497 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
2498 ++ },
2499 ++ },
2500 + { }
2501 + };
2502 +
2503 +diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
2504 +index 3054c0971759..74c8638aac2b 100644
2505 +--- a/drivers/iommu/amd_iommu_types.h
2506 ++++ b/drivers/iommu/amd_iommu_types.h
2507 +@@ -348,7 +348,7 @@
2508 +
2509 + #define DTE_GCR3_VAL_A(x) (((x) >> 12) & 0x00007ULL)
2510 + #define DTE_GCR3_VAL_B(x) (((x) >> 15) & 0x0ffffULL)
2511 +-#define DTE_GCR3_VAL_C(x) (((x) >> 31) & 0xfffffULL)
2512 ++#define DTE_GCR3_VAL_C(x) (((x) >> 31) & 0x1fffffULL)
2513 +
2514 + #define DTE_GCR3_INDEX_A 0
2515 + #define DTE_GCR3_INDEX_B 1
2516 +diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
2517 +index f5573bb9f450..837459762eb3 100644
2518 +--- a/drivers/iommu/intel-svm.c
2519 ++++ b/drivers/iommu/intel-svm.c
2520 +@@ -613,14 +613,15 @@ static irqreturn_t prq_event_thread(int irq, void *d)
2521 + * any faults on kernel addresses. */
2522 + if (!svm->mm)
2523 + goto bad_req;
2524 +- /* If the mm is already defunct, don't handle faults. */
2525 +- if (!mmget_not_zero(svm->mm))
2526 +- goto bad_req;
2527 +
2528 + /* If address is not canonical, return invalid response */
2529 + if (!is_canonical_address(address))
2530 + goto bad_req;
2531 +
2532 ++ /* If the mm is already defunct, don't handle faults. */
2533 ++ if (!mmget_not_zero(svm->mm))
2534 ++ goto bad_req;
2535 ++
2536 + down_read(&svm->mm->mmap_sem);
2537 + vma = find_extend_vma(svm->mm, address);
2538 + if (!vma || address < vma->vm_start)
2539 +diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
2540 +index 799df1e598db..84b23d902d5b 100644
2541 +--- a/drivers/irqchip/irq-gic-v3-its.c
2542 ++++ b/drivers/irqchip/irq-gic-v3-its.c
2543 +@@ -2591,12 +2591,18 @@ static int its_vpe_set_irqchip_state(struct irq_data *d,
2544 + return 0;
2545 + }
2546 +
2547 ++static int its_vpe_retrigger(struct irq_data *d)
2548 ++{
2549 ++ return !its_vpe_set_irqchip_state(d, IRQCHIP_STATE_PENDING, true);
2550 ++}
2551 ++
2552 + static struct irq_chip its_vpe_irq_chip = {
2553 + .name = "GICv4-vpe",
2554 + .irq_mask = its_vpe_mask_irq,
2555 + .irq_unmask = its_vpe_unmask_irq,
2556 + .irq_eoi = irq_chip_eoi_parent,
2557 + .irq_set_affinity = its_vpe_set_affinity,
2558 ++ .irq_retrigger = its_vpe_retrigger,
2559 + .irq_set_irqchip_state = its_vpe_set_irqchip_state,
2560 + .irq_set_vcpu_affinity = its_vpe_set_vcpu_affinity,
2561 + };
2562 +diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
2563 +index f7fdbf5d183b..c98358be0bc8 100644
2564 +--- a/drivers/irqchip/irq-mbigen.c
2565 ++++ b/drivers/irqchip/irq-mbigen.c
2566 +@@ -231,10 +231,16 @@ static int mbigen_irq_domain_alloc(struct irq_domain *domain,
2567 + return 0;
2568 + }
2569 +
2570 ++static void mbigen_irq_domain_free(struct irq_domain *domain, unsigned int virq,
2571 ++ unsigned int nr_irqs)
2572 ++{
2573 ++ platform_msi_domain_free(domain, virq, nr_irqs);
2574 ++}
2575 ++
2576 + static const struct irq_domain_ops mbigen_domain_ops = {
2577 + .translate = mbigen_domain_translate,
2578 + .alloc = mbigen_irq_domain_alloc,
2579 +- .free = irq_domain_free_irqs_common,
2580 ++ .free = mbigen_irq_domain_free,
2581 + };
2582 +
2583 + static int mbigen_of_create_domain(struct platform_device *pdev,
2584 +diff --git a/drivers/irqchip/irq-versatile-fpga.c b/drivers/irqchip/irq-versatile-fpga.c
2585 +index 928858dada75..f1386733d3bc 100644
2586 +--- a/drivers/irqchip/irq-versatile-fpga.c
2587 ++++ b/drivers/irqchip/irq-versatile-fpga.c
2588 +@@ -6,6 +6,7 @@
2589 + #include <linux/irq.h>
2590 + #include <linux/io.h>
2591 + #include <linux/irqchip.h>
2592 ++#include <linux/irqchip/chained_irq.h>
2593 + #include <linux/irqchip/versatile-fpga.h>
2594 + #include <linux/irqdomain.h>
2595 + #include <linux/module.h>
2596 +@@ -68,12 +69,16 @@ static void fpga_irq_unmask(struct irq_data *d)
2597 +
2598 + static void fpga_irq_handle(struct irq_desc *desc)
2599 + {
2600 ++ struct irq_chip *chip = irq_desc_get_chip(desc);
2601 + struct fpga_irq_data *f = irq_desc_get_handler_data(desc);
2602 +- u32 status = readl(f->base + IRQ_STATUS);
2603 ++ u32 status;
2604 ++
2605 ++ chained_irq_enter(chip, desc);
2606 +
2607 ++ status = readl(f->base + IRQ_STATUS);
2608 + if (status == 0) {
2609 + do_bad_IRQ(desc);
2610 +- return;
2611 ++ goto out;
2612 + }
2613 +
2614 + do {
2615 +@@ -82,6 +87,9 @@ static void fpga_irq_handle(struct irq_desc *desc)
2616 + status &= ~(1 << irq);
2617 + generic_handle_irq(irq_find_mapping(f->domain, irq));
2618 + } while (status);
2619 ++
2620 ++out:
2621 ++ chained_irq_exit(chip, desc);
2622 + }
2623 +
2624 + /*
2625 +@@ -204,6 +212,9 @@ int __init fpga_irq_of_init(struct device_node *node,
2626 + if (of_property_read_u32(node, "valid-mask", &valid_mask))
2627 + valid_mask = 0;
2628 +
2629 ++ writel(clear_mask, base + IRQ_ENABLE_CLEAR);
2630 ++ writel(clear_mask, base + FIQ_ENABLE_CLEAR);
2631 ++
2632 + /* Some chips are cascaded from a parent IRQ */
2633 + parent_irq = irq_of_parse_and_map(node, 0);
2634 + if (!parent_irq) {
2635 +@@ -213,9 +224,6 @@ int __init fpga_irq_of_init(struct device_node *node,
2636 +
2637 + fpga_irq_init(base, node->name, 0, parent_irq, valid_mask, node);
2638 +
2639 +- writel(clear_mask, base + IRQ_ENABLE_CLEAR);
2640 +- writel(clear_mask, base + FIQ_ENABLE_CLEAR);
2641 +-
2642 + /*
2643 + * On Versatile AB/PB, some secondary interrupts have a direct
2644 + * pass-thru to the primary controller for IRQs 20 and 22-31 which need
2645 +diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
2646 +index b1b68e01b889..53cd31199f21 100644
2647 +--- a/drivers/md/dm-flakey.c
2648 ++++ b/drivers/md/dm-flakey.c
2649 +@@ -70,6 +70,11 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
2650 + arg_name = dm_shift_arg(as);
2651 + argc--;
2652 +
2653 ++ if (!arg_name) {
2654 ++ ti->error = "Insufficient feature arguments";
2655 ++ return -EINVAL;
2656 ++ }
2657 ++
2658 + /*
2659 + * drop_writes
2660 + */
2661 +diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
2662 +index e13f90832b6b..285148100cde 100644
2663 +--- a/drivers/md/dm-verity-fec.c
2664 ++++ b/drivers/md/dm-verity-fec.c
2665 +@@ -552,6 +552,7 @@ void verity_fec_dtr(struct dm_verity *v)
2666 + mempool_destroy(f->rs_pool);
2667 + mempool_destroy(f->prealloc_pool);
2668 + mempool_destroy(f->extra_pool);
2669 ++ mempool_destroy(f->output_pool);
2670 + kmem_cache_destroy(f->cache);
2671 +
2672 + if (f->data_bufio)
2673 +diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
2674 +index e3b67b145027..4d658a0c6025 100644
2675 +--- a/drivers/md/dm-zoned-metadata.c
2676 ++++ b/drivers/md/dm-zoned-metadata.c
2677 +@@ -1105,7 +1105,6 @@ static int dmz_init_zone(struct dmz_metadata *zmd, struct dm_zone *zone,
2678 +
2679 + if (blkz->type == BLK_ZONE_TYPE_CONVENTIONAL) {
2680 + set_bit(DMZ_RND, &zone->flags);
2681 +- zmd->nr_rnd_zones++;
2682 + } else if (blkz->type == BLK_ZONE_TYPE_SEQWRITE_REQ ||
2683 + blkz->type == BLK_ZONE_TYPE_SEQWRITE_PREF) {
2684 + set_bit(DMZ_SEQ, &zone->flags);
2685 +diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
2686 +index 42e383a48ffe..b6dcae1ecc1b 100644
2687 +--- a/drivers/media/platform/ti-vpe/cal.c
2688 ++++ b/drivers/media/platform/ti-vpe/cal.c
2689 +@@ -544,16 +544,16 @@ static void enable_irqs(struct cal_ctx *ctx)
2690 +
2691 + static void disable_irqs(struct cal_ctx *ctx)
2692 + {
2693 ++ u32 val;
2694 ++
2695 + /* Disable IRQ_WDMA_END 0/1 */
2696 +- reg_write_field(ctx->dev,
2697 +- CAL_HL_IRQENABLE_CLR(2),
2698 +- CAL_HL_IRQ_CLEAR,
2699 +- CAL_HL_IRQ_MASK(ctx->csi2_port));
2700 ++ val = 0;
2701 ++ set_field(&val, CAL_HL_IRQ_CLEAR, CAL_HL_IRQ_MASK(ctx->csi2_port));
2702 ++ reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(2), val);
2703 + /* Disable IRQ_WDMA_START 0/1 */
2704 +- reg_write_field(ctx->dev,
2705 +- CAL_HL_IRQENABLE_CLR(3),
2706 +- CAL_HL_IRQ_CLEAR,
2707 +- CAL_HL_IRQ_MASK(ctx->csi2_port));
2708 ++ val = 0;
2709 ++ set_field(&val, CAL_HL_IRQ_CLEAR, CAL_HL_IRQ_MASK(ctx->csi2_port));
2710 ++ reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(3), val);
2711 + /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */
2712 + reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0);
2713 + }
2714 +diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
2715 +index 95d0f2df0ad4..672831d5ee32 100644
2716 +--- a/drivers/mfd/dln2.c
2717 ++++ b/drivers/mfd/dln2.c
2718 +@@ -93,6 +93,11 @@ struct dln2_mod_rx_slots {
2719 + spinlock_t lock;
2720 + };
2721 +
2722 ++enum dln2_endpoint {
2723 ++ DLN2_EP_OUT = 0,
2724 ++ DLN2_EP_IN = 1,
2725 ++};
2726 ++
2727 + struct dln2_dev {
2728 + struct usb_device *usb_dev;
2729 + struct usb_interface *interface;
2730 +@@ -740,10 +745,10 @@ static int dln2_probe(struct usb_interface *interface,
2731 + hostif->desc.bNumEndpoints < 2)
2732 + return -ENODEV;
2733 +
2734 +- epin = &hostif->endpoint[0].desc;
2735 +- epout = &hostif->endpoint[1].desc;
2736 ++ epout = &hostif->endpoint[DLN2_EP_OUT].desc;
2737 + if (!usb_endpoint_is_bulk_out(epout))
2738 + return -ENODEV;
2739 ++ epin = &hostif->endpoint[DLN2_EP_IN].desc;
2740 + if (!usb_endpoint_is_bulk_in(epin))
2741 + return -ENODEV;
2742 +
2743 +diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
2744 +index ff296a4bf3d2..dc6a9432a4b6 100644
2745 +--- a/drivers/mfd/rts5227.c
2746 ++++ b/drivers/mfd/rts5227.c
2747 +@@ -369,6 +369,7 @@ static const struct pcr_ops rts522a_pcr_ops = {
2748 + void rts522a_init_params(struct rtsx_pcr *pcr)
2749 + {
2750 + rts5227_init_params(pcr);
2751 ++ pcr->ops = &rts522a_pcr_ops;
2752 +
2753 + pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
2754 + }
2755 +diff --git a/drivers/misc/echo/echo.c b/drivers/misc/echo/echo.c
2756 +index 9597e9523cac..fff13176f9b8 100644
2757 +--- a/drivers/misc/echo/echo.c
2758 ++++ b/drivers/misc/echo/echo.c
2759 +@@ -454,7 +454,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
2760 + */
2761 + ec->factor = 0;
2762 + ec->shift = 0;
2763 +- if ((ec->nonupdate_dwell == 0)) {
2764 ++ if (!ec->nonupdate_dwell) {
2765 + int p, logp, shift;
2766 +
2767 + /* Determine:
2768 +diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
2769 +index 8b66e52ca3cc..9734e6903fe6 100644
2770 +--- a/drivers/mtd/devices/phram.c
2771 ++++ b/drivers/mtd/devices/phram.c
2772 +@@ -247,22 +247,25 @@ static int phram_setup(const char *val)
2773 +
2774 + ret = parse_num64(&start, token[1]);
2775 + if (ret) {
2776 +- kfree(name);
2777 + parse_err("illegal start address\n");
2778 ++ goto error;
2779 + }
2780 +
2781 + ret = parse_num64(&len, token[2]);
2782 + if (ret) {
2783 +- kfree(name);
2784 + parse_err("illegal device length\n");
2785 ++ goto error;
2786 + }
2787 +
2788 + ret = register_device(name, start, len);
2789 +- if (!ret)
2790 +- pr_info("%s device: %#llx at %#llx\n", name, len, start);
2791 +- else
2792 +- kfree(name);
2793 ++ if (ret)
2794 ++ goto error;
2795 ++
2796 ++ pr_info("%s device: %#llx at %#llx\n", name, len, start);
2797 ++ return 0;
2798 +
2799 ++error:
2800 ++ kfree(name);
2801 + return ret;
2802 + }
2803 +
2804 +diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c
2805 +index 018c75faadb3..e1c283ccbbde 100644
2806 +--- a/drivers/mtd/lpddr/lpddr_cmds.c
2807 ++++ b/drivers/mtd/lpddr/lpddr_cmds.c
2808 +@@ -81,7 +81,6 @@ struct mtd_info *lpddr_cmdset(struct map_info *map)
2809 + shared = kmalloc(sizeof(struct flchip_shared) * lpddr->numchips,
2810 + GFP_KERNEL);
2811 + if (!shared) {
2812 +- kfree(lpddr);
2813 + kfree(mtd);
2814 + return NULL;
2815 + }
2816 +diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
2817 +index 7f8d269dd75a..814618c0b632 100644
2818 +--- a/drivers/net/dsa/bcm_sf2_cfp.c
2819 ++++ b/drivers/net/dsa/bcm_sf2_cfp.c
2820 +@@ -130,17 +130,14 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
2821 + (fs->m_ext.vlan_etype || fs->m_ext.data[1]))
2822 + return -EINVAL;
2823 +
2824 +- if (fs->location != RX_CLS_LOC_ANY && fs->location >= CFP_NUM_RULES)
2825 ++ if (fs->location != RX_CLS_LOC_ANY &&
2826 ++ fs->location > bcm_sf2_cfp_rule_size(priv))
2827 + return -EINVAL;
2828 +
2829 + if (fs->location != RX_CLS_LOC_ANY &&
2830 + test_bit(fs->location, priv->cfp.used))
2831 + return -EBUSY;
2832 +
2833 +- if (fs->location != RX_CLS_LOC_ANY &&
2834 +- fs->location > bcm_sf2_cfp_rule_size(priv))
2835 +- return -EINVAL;
2836 +-
2837 + ip_frag = be32_to_cpu(fs->m_ext.data[0]);
2838 +
2839 + /* We do not support discarding packets, check that the
2840 +@@ -333,7 +330,7 @@ static int bcm_sf2_cfp_rule_del(struct bcm_sf2_priv *priv, int port,
2841 + int ret;
2842 + u32 reg;
2843 +
2844 +- if (loc >= CFP_NUM_RULES)
2845 ++ if (loc > bcm_sf2_cfp_rule_size(priv))
2846 + return -EINVAL;
2847 +
2848 + /* Refuse deletion of unused rules, and the default reserved rule */
2849 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
2850 +index c65d2cdcc7cf..8556962e6824 100644
2851 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
2852 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
2853 +@@ -515,7 +515,7 @@ static void xgbe_isr_task(unsigned long data)
2854 + xgbe_disable_rx_tx_ints(pdata);
2855 +
2856 + /* Turn on polling */
2857 +- __napi_schedule_irqoff(&pdata->napi);
2858 ++ __napi_schedule(&pdata->napi);
2859 + }
2860 + } else {
2861 + /* Don't clear Rx/Tx status if doing per channel DMA
2862 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
2863 +index 9f9d6cae39d5..758f2b836328 100644
2864 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
2865 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
2866 +@@ -246,6 +246,9 @@ static int cxgb4_ptp_fineadjtime(struct adapter *adapter, s64 delta)
2867 + FW_PTP_CMD_PORTID_V(0));
2868 + c.retval_len16 = cpu_to_be32(FW_CMD_LEN16_V(sizeof(c) / 16));
2869 + c.u.ts.sc = FW_PTP_SC_ADJ_FTIME;
2870 ++ c.u.ts.sign = (delta < 0) ? 1 : 0;
2871 ++ if (delta < 0)
2872 ++ delta = -delta;
2873 + c.u.ts.tm = cpu_to_be64(delta);
2874 +
2875 + err = t4_wr_mbox(adapter, adapter->mbox, &c, sizeof(c), NULL);
2876 +diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
2877 +index 7d95f0866fb0..e1de97effcd2 100644
2878 +--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
2879 ++++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
2880 +@@ -398,7 +398,8 @@ static int cmdq_sync_cmd_direct_resp(struct hinic_cmdq *cmdq,
2881 +
2882 + spin_unlock_bh(&cmdq->cmdq_lock);
2883 +
2884 +- if (!wait_for_completion_timeout(&done, CMDQ_TIMEOUT)) {
2885 ++ if (!wait_for_completion_timeout(&done,
2886 ++ msecs_to_jiffies(CMDQ_TIMEOUT))) {
2887 + spin_lock_bh(&cmdq->cmdq_lock);
2888 +
2889 + if (cmdq->errcode[curr_prod_idx] == &errcode)
2890 +diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
2891 +index 46aba02b8672..5763e333a9af 100644
2892 +--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
2893 ++++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
2894 +@@ -373,50 +373,6 @@ static int wait_for_db_state(struct hinic_hwdev *hwdev)
2895 + return -EFAULT;
2896 + }
2897 +
2898 +-static int wait_for_io_stopped(struct hinic_hwdev *hwdev)
2899 +-{
2900 +- struct hinic_cmd_io_status cmd_io_status;
2901 +- struct hinic_hwif *hwif = hwdev->hwif;
2902 +- struct pci_dev *pdev = hwif->pdev;
2903 +- struct hinic_pfhwdev *pfhwdev;
2904 +- unsigned long end;
2905 +- u16 out_size;
2906 +- int err;
2907 +-
2908 +- if (!HINIC_IS_PF(hwif) && !HINIC_IS_PPF(hwif)) {
2909 +- dev_err(&pdev->dev, "Unsupported PCI Function type\n");
2910 +- return -EINVAL;
2911 +- }
2912 +-
2913 +- pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev);
2914 +-
2915 +- cmd_io_status.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
2916 +-
2917 +- end = jiffies + msecs_to_jiffies(IO_STATUS_TIMEOUT);
2918 +- do {
2919 +- err = hinic_msg_to_mgmt(&pfhwdev->pf_to_mgmt, HINIC_MOD_COMM,
2920 +- HINIC_COMM_CMD_IO_STATUS_GET,
2921 +- &cmd_io_status, sizeof(cmd_io_status),
2922 +- &cmd_io_status, &out_size,
2923 +- HINIC_MGMT_MSG_SYNC);
2924 +- if ((err) || (out_size != sizeof(cmd_io_status))) {
2925 +- dev_err(&pdev->dev, "Failed to get IO status, ret = %d\n",
2926 +- err);
2927 +- return err;
2928 +- }
2929 +-
2930 +- if (cmd_io_status.status == IO_STOPPED) {
2931 +- dev_info(&pdev->dev, "IO stopped\n");
2932 +- return 0;
2933 +- }
2934 +-
2935 +- msleep(20);
2936 +- } while (time_before(jiffies, end));
2937 +-
2938 +- dev_err(&pdev->dev, "Wait for IO stopped - Timeout\n");
2939 +- return -ETIMEDOUT;
2940 +-}
2941 +-
2942 + /**
2943 + * clear_io_resource - set the IO resources as not active in the NIC
2944 + * @hwdev: the NIC HW device
2945 +@@ -436,11 +392,8 @@ static int clear_io_resources(struct hinic_hwdev *hwdev)
2946 + return -EINVAL;
2947 + }
2948 +
2949 +- err = wait_for_io_stopped(hwdev);
2950 +- if (err) {
2951 +- dev_err(&pdev->dev, "IO has not stopped yet\n");
2952 +- return err;
2953 +- }
2954 ++ /* sleep 100ms to wait for firmware stopping I/O */
2955 ++ msleep(100);
2956 +
2957 + cmd_clear_io_res.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
2958 +
2959 +diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
2960 +index 278dc13f3dae..9fcf2e5e0003 100644
2961 +--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
2962 ++++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
2963 +@@ -52,7 +52,7 @@
2964 +
2965 + #define MSG_NOT_RESP 0xFFFF
2966 +
2967 +-#define MGMT_MSG_TIMEOUT 1000
2968 ++#define MGMT_MSG_TIMEOUT 5000
2969 +
2970 + #define mgmt_to_pfhwdev(pf_mgmt) \
2971 + container_of(pf_mgmt, struct hinic_pfhwdev, pf_to_mgmt)
2972 +@@ -276,7 +276,8 @@ static int msg_to_mgmt_sync(struct hinic_pf_to_mgmt *pf_to_mgmt,
2973 + goto unlock_sync_msg;
2974 + }
2975 +
2976 +- if (!wait_for_completion_timeout(recv_done, MGMT_MSG_TIMEOUT)) {
2977 ++ if (!wait_for_completion_timeout(recv_done,
2978 ++ msecs_to_jiffies(MGMT_MSG_TIMEOUT))) {
2979 + dev_err(&pdev->dev, "MGMT timeout, MSG id = %d\n", msg_id);
2980 + err = -ETIMEDOUT;
2981 + goto unlock_sync_msg;
2982 +diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.h b/drivers/net/ethernet/neterion/vxge/vxge-config.h
2983 +index cfa970417f81..fe4a4315d20d 100644
2984 +--- a/drivers/net/ethernet/neterion/vxge/vxge-config.h
2985 ++++ b/drivers/net/ethernet/neterion/vxge/vxge-config.h
2986 +@@ -2065,7 +2065,7 @@ vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);
2987 + if ((level >= VXGE_ERR && VXGE_COMPONENT_LL & VXGE_DEBUG_ERR_MASK) || \
2988 + (level >= VXGE_TRACE && VXGE_COMPONENT_LL & VXGE_DEBUG_TRACE_MASK))\
2989 + if ((mask & VXGE_DEBUG_MASK) == mask) \
2990 +- printk(fmt "\n", __VA_ARGS__); \
2991 ++ printk(fmt "\n", ##__VA_ARGS__); \
2992 + } while (0)
2993 + #else
2994 + #define vxge_debug_ll(level, mask, fmt, ...)
2995 +diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.h b/drivers/net/ethernet/neterion/vxge/vxge-main.h
2996 +index 3a79d93b8445..5b535aa10d23 100644
2997 +--- a/drivers/net/ethernet/neterion/vxge/vxge-main.h
2998 ++++ b/drivers/net/ethernet/neterion/vxge/vxge-main.h
2999 +@@ -454,49 +454,49 @@ int vxge_fw_upgrade(struct vxgedev *vdev, char *fw_name, int override);
3000 +
3001 + #if (VXGE_DEBUG_LL_CONFIG & VXGE_DEBUG_MASK)
3002 + #define vxge_debug_ll_config(level, fmt, ...) \
3003 +- vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, __VA_ARGS__)
3004 ++ vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, ##__VA_ARGS__)
3005 + #else
3006 + #define vxge_debug_ll_config(level, fmt, ...)
3007 + #endif
3008 +
3009 + #if (VXGE_DEBUG_INIT & VXGE_DEBUG_MASK)
3010 + #define vxge_debug_init(level, fmt, ...) \
3011 +- vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, __VA_ARGS__)
3012 ++ vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, ##__VA_ARGS__)
3013 + #else
3014 + #define vxge_debug_init(level, fmt, ...)
3015 + #endif
3016 +
3017 + #if (VXGE_DEBUG_TX & VXGE_DEBUG_MASK)
3018 + #define vxge_debug_tx(level, fmt, ...) \
3019 +- vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, __VA_ARGS__)
3020 ++ vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, ##__VA_ARGS__)
3021 + #else
3022 + #define vxge_debug_tx(level, fmt, ...)
3023 + #endif
3024 +
3025 + #if (VXGE_DEBUG_RX & VXGE_DEBUG_MASK)
3026 + #define vxge_debug_rx(level, fmt, ...) \
3027 +- vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, __VA_ARGS__)
3028 ++ vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, ##__VA_ARGS__)
3029 + #else
3030 + #define vxge_debug_rx(level, fmt, ...)
3031 + #endif
3032 +
3033 + #if (VXGE_DEBUG_MEM & VXGE_DEBUG_MASK)
3034 + #define vxge_debug_mem(level, fmt, ...) \
3035 +- vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, __VA_ARGS__)
3036 ++ vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, ##__VA_ARGS__)
3037 + #else
3038 + #define vxge_debug_mem(level, fmt, ...)
3039 + #endif
3040 +
3041 + #if (VXGE_DEBUG_ENTRYEXIT & VXGE_DEBUG_MASK)
3042 + #define vxge_debug_entryexit(level, fmt, ...) \
3043 +- vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, __VA_ARGS__)
3044 ++ vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, ##__VA_ARGS__)
3045 + #else
3046 + #define vxge_debug_entryexit(level, fmt, ...)
3047 + #endif
3048 +
3049 + #if (VXGE_DEBUG_INTR & VXGE_DEBUG_MASK)
3050 + #define vxge_debug_intr(level, fmt, ...) \
3051 +- vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, __VA_ARGS__)
3052 ++ vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, ##__VA_ARGS__)
3053 + #else
3054 + #define vxge_debug_intr(level, fmt, ...)
3055 + #endif
3056 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
3057 +index 07f9067affc6..cda5b0a9e948 100644
3058 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
3059 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
3060 +@@ -1720,7 +1720,7 @@ static int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *p_d
3061 +
3062 + ahw->reset.seq_error = 0;
3063 + ahw->reset.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL);
3064 +- if (p_dev->ahw->reset.buff == NULL)
3065 ++ if (ahw->reset.buff == NULL)
3066 + return -ENOMEM;
3067 +
3068 + p_buff = p_dev->ahw->reset.buff;
3069 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
3070 +index fc1fa0f9f338..57694eada995 100644
3071 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
3072 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
3073 +@@ -155,6 +155,8 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
3074 + plat_dat->init = sun7i_gmac_init;
3075 + plat_dat->exit = sun7i_gmac_exit;
3076 + plat_dat->fix_mac_speed = sun7i_fix_speed;
3077 ++ plat_dat->tx_fifo_size = 4096;
3078 ++ plat_dat->rx_fifo_size = 16384;
3079 +
3080 + ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv);
3081 + if (ret)
3082 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
3083 +index 72ad84fde5c1..8e084670c3c2 100644
3084 +--- a/drivers/net/wireless/ath/ath9k/main.c
3085 ++++ b/drivers/net/wireless/ath/ath9k/main.c
3086 +@@ -1456,6 +1456,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
3087 + ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
3088 + }
3089 +
3090 ++ if (changed & IEEE80211_CONF_CHANGE_POWER)
3091 ++ ath9k_set_txpower(sc, NULL);
3092 ++
3093 + mutex_unlock(&sc->mutex);
3094 + ath9k_ps_restore(sc);
3095 +
3096 +diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c
3097 +index c374ed311520..58784e77e215 100644
3098 +--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
3099 ++++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
3100 +@@ -1735,9 +1735,12 @@ static int wil_cfg80211_suspend(struct wiphy *wiphy,
3101 +
3102 + wil_dbg_pm(wil, "suspending\n");
3103 +
3104 +- wil_p2p_stop_discovery(wil);
3105 +-
3106 ++ mutex_lock(&wil->mutex);
3107 ++ mutex_lock(&wil->p2p_wdev_mutex);
3108 ++ wil_p2p_stop_radio_operations(wil);
3109 + wil_abort_scan(wil, true);
3110 ++ mutex_unlock(&wil->p2p_wdev_mutex);
3111 ++ mutex_unlock(&wil->mutex);
3112 +
3113 + out:
3114 + return rc;
3115 +diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
3116 +index 6db00c167d2e..3a98f75c5d7e 100644
3117 +--- a/drivers/net/wireless/ath/wil6210/debugfs.c
3118 ++++ b/drivers/net/wireless/ath/wil6210/debugfs.c
3119 +@@ -1093,7 +1093,7 @@ static const struct file_operations fops_ssid = {
3120 + };
3121 +
3122 + /*---------temp------------*/
3123 +-static void print_temp(struct seq_file *s, const char *prefix, u32 t)
3124 ++static void print_temp(struct seq_file *s, const char *prefix, s32 t)
3125 + {
3126 + switch (t) {
3127 + case 0:
3128 +@@ -1101,7 +1101,8 @@ static void print_temp(struct seq_file *s, const char *prefix, u32 t)
3129 + seq_printf(s, "%s N/A\n", prefix);
3130 + break;
3131 + default:
3132 +- seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
3133 ++ seq_printf(s, "%s %s%d.%03d\n", prefix, (t < 0 ? "-" : ""),
3134 ++ abs(t / 1000), abs(t % 1000));
3135 + break;
3136 + }
3137 + }
3138 +@@ -1109,7 +1110,7 @@ static void print_temp(struct seq_file *s, const char *prefix, u32 t)
3139 + static int wil_temp_debugfs_show(struct seq_file *s, void *data)
3140 + {
3141 + struct wil6210_priv *wil = s->private;
3142 +- u32 t_m, t_r;
3143 ++ s32 t_m, t_r;
3144 + int rc = wmi_get_temperature(wil, &t_m, &t_r);
3145 +
3146 + if (rc) {
3147 +diff --git a/drivers/net/wireless/ath/wil6210/fw_inc.c b/drivers/net/wireless/ath/wil6210/fw_inc.c
3148 +index e01acac88825..7d090150187c 100644
3149 +--- a/drivers/net/wireless/ath/wil6210/fw_inc.c
3150 ++++ b/drivers/net/wireless/ath/wil6210/fw_inc.c
3151 +@@ -26,14 +26,17 @@
3152 + prefix_type, rowsize, \
3153 + groupsize, buf, len, ascii)
3154 +
3155 +-#define FW_ADDR_CHECK(ioaddr, val, msg) do { \
3156 +- ioaddr = wmi_buffer(wil, val); \
3157 +- if (!ioaddr) { \
3158 +- wil_err_fw(wil, "bad " msg ": 0x%08x\n", \
3159 +- le32_to_cpu(val)); \
3160 +- return -EINVAL; \
3161 +- } \
3162 +- } while (0)
3163 ++static bool wil_fw_addr_check(struct wil6210_priv *wil,
3164 ++ void __iomem **ioaddr, __le32 val,
3165 ++ u32 size, const char *msg)
3166 ++{
3167 ++ *ioaddr = wmi_buffer_block(wil, val, size);
3168 ++ if (!(*ioaddr)) {
3169 ++ wil_err_fw(wil, "bad %s: 0x%08x\n", msg, le32_to_cpu(val));
3170 ++ return false;
3171 ++ }
3172 ++ return true;
3173 ++}
3174 +
3175 + /**
3176 + * wil_fw_verify - verify firmware file validity
3177 +@@ -165,7 +168,8 @@ static int fw_handle_data(struct wil6210_priv *wil, const void *data,
3178 + return -EINVAL;
3179 + }
3180 +
3181 +- FW_ADDR_CHECK(dst, d->addr, "address");
3182 ++ if (!wil_fw_addr_check(wil, &dst, d->addr, s, "address"))
3183 ++ return -EINVAL;
3184 + wil_dbg_fw(wil, "write [0x%08x] <== %zu bytes\n", le32_to_cpu(d->addr),
3185 + s);
3186 + wil_memcpy_toio_32(dst, d->data, s);
3187 +@@ -197,7 +201,8 @@ static int fw_handle_fill(struct wil6210_priv *wil, const void *data,
3188 + return -EINVAL;
3189 + }
3190 +
3191 +- FW_ADDR_CHECK(dst, d->addr, "address");
3192 ++ if (!wil_fw_addr_check(wil, &dst, d->addr, s, "address"))
3193 ++ return -EINVAL;
3194 +
3195 + v = le32_to_cpu(d->value);
3196 + wil_dbg_fw(wil, "fill [0x%08x] <== 0x%08x, %zu bytes\n",
3197 +@@ -253,7 +258,8 @@ static int fw_handle_direct_write(struct wil6210_priv *wil, const void *data,
3198 + u32 v = le32_to_cpu(block[i].value);
3199 + u32 x, y;
3200 +
3201 +- FW_ADDR_CHECK(dst, block[i].addr, "address");
3202 ++ if (!wil_fw_addr_check(wil, &dst, block[i].addr, 0, "address"))
3203 ++ return -EINVAL;
3204 +
3205 + x = readl(dst);
3206 + y = (x & m) | (v & ~m);
3207 +@@ -319,10 +325,15 @@ static int fw_handle_gateway_data(struct wil6210_priv *wil, const void *data,
3208 + wil_dbg_fw(wil, "gw write record [%3d] blocks, cmd 0x%08x\n",
3209 + n, gw_cmd);
3210 +
3211 +- FW_ADDR_CHECK(gwa_addr, d->gateway_addr_addr, "gateway_addr_addr");
3212 +- FW_ADDR_CHECK(gwa_val, d->gateway_value_addr, "gateway_value_addr");
3213 +- FW_ADDR_CHECK(gwa_cmd, d->gateway_cmd_addr, "gateway_cmd_addr");
3214 +- FW_ADDR_CHECK(gwa_ctl, d->gateway_ctrl_address, "gateway_ctrl_address");
3215 ++ if (!wil_fw_addr_check(wil, &gwa_addr, d->gateway_addr_addr, 0,
3216 ++ "gateway_addr_addr") ||
3217 ++ !wil_fw_addr_check(wil, &gwa_val, d->gateway_value_addr, 0,
3218 ++ "gateway_value_addr") ||
3219 ++ !wil_fw_addr_check(wil, &gwa_cmd, d->gateway_cmd_addr, 0,
3220 ++ "gateway_cmd_addr") ||
3221 ++ !wil_fw_addr_check(wil, &gwa_ctl, d->gateway_ctrl_address, 0,
3222 ++ "gateway_ctrl_address"))
3223 ++ return -EINVAL;
3224 +
3225 + wil_dbg_fw(wil, "gw addresses: addr 0x%08x val 0x%08x"
3226 + " cmd 0x%08x ctl 0x%08x\n",
3227 +@@ -378,12 +389,19 @@ static int fw_handle_gateway_data4(struct wil6210_priv *wil, const void *data,
3228 + wil_dbg_fw(wil, "gw4 write record [%3d] blocks, cmd 0x%08x\n",
3229 + n, gw_cmd);
3230 +
3231 +- FW_ADDR_CHECK(gwa_addr, d->gateway_addr_addr, "gateway_addr_addr");
3232 ++ if (!wil_fw_addr_check(wil, &gwa_addr, d->gateway_addr_addr, 0,
3233 ++ "gateway_addr_addr"))
3234 ++ return -EINVAL;
3235 + for (k = 0; k < ARRAY_SIZE(block->value); k++)
3236 +- FW_ADDR_CHECK(gwa_val[k], d->gateway_value_addr[k],
3237 +- "gateway_value_addr");
3238 +- FW_ADDR_CHECK(gwa_cmd, d->gateway_cmd_addr, "gateway_cmd_addr");
3239 +- FW_ADDR_CHECK(gwa_ctl, d->gateway_ctrl_address, "gateway_ctrl_address");
3240 ++ if (!wil_fw_addr_check(wil, &gwa_val[k],
3241 ++ d->gateway_value_addr[k],
3242 ++ 0, "gateway_value_addr"))
3243 ++ return -EINVAL;
3244 ++ if (!wil_fw_addr_check(wil, &gwa_cmd, d->gateway_cmd_addr, 0,
3245 ++ "gateway_cmd_addr") ||
3246 ++ !wil_fw_addr_check(wil, &gwa_ctl, d->gateway_ctrl_address, 0,
3247 ++ "gateway_ctrl_address"))
3248 ++ return -EINVAL;
3249 +
3250 + wil_dbg_fw(wil, "gw4 addresses: addr 0x%08x cmd 0x%08x ctl 0x%08x\n",
3251 + le32_to_cpu(d->gateway_addr_addr),
3252 +diff --git a/drivers/net/wireless/ath/wil6210/interrupt.c b/drivers/net/wireless/ath/wil6210/interrupt.c
3253 +index 59def4f3fcf3..5cf341702dc1 100644
3254 +--- a/drivers/net/wireless/ath/wil6210/interrupt.c
3255 ++++ b/drivers/net/wireless/ath/wil6210/interrupt.c
3256 +@@ -358,6 +358,25 @@ static void wil_cache_mbox_regs(struct wil6210_priv *wil)
3257 + wil_mbox_ring_le2cpus(&wil->mbox_ctl.tx);
3258 + }
3259 +
3260 ++static bool wil_validate_mbox_regs(struct wil6210_priv *wil)
3261 ++{
3262 ++ size_t min_size = sizeof(struct wil6210_mbox_hdr) +
3263 ++ sizeof(struct wmi_cmd_hdr);
3264 ++
3265 ++ if (wil->mbox_ctl.rx.entry_size < min_size) {
3266 ++ wil_err(wil, "rx mbox entry too small (%d)\n",
3267 ++ wil->mbox_ctl.rx.entry_size);
3268 ++ return false;
3269 ++ }
3270 ++ if (wil->mbox_ctl.tx.entry_size < min_size) {
3271 ++ wil_err(wil, "tx mbox entry too small (%d)\n",
3272 ++ wil->mbox_ctl.tx.entry_size);
3273 ++ return false;
3274 ++ }
3275 ++
3276 ++ return true;
3277 ++}
3278 ++
3279 + static irqreturn_t wil6210_irq_misc(int irq, void *cookie)
3280 + {
3281 + struct wil6210_priv *wil = cookie;
3282 +@@ -393,7 +412,8 @@ static irqreturn_t wil6210_irq_misc(int irq, void *cookie)
3283 + if (isr & ISR_MISC_FW_READY) {
3284 + wil_dbg_irq(wil, "IRQ: FW ready\n");
3285 + wil_cache_mbox_regs(wil);
3286 +- set_bit(wil_status_mbox_ready, wil->status);
3287 ++ if (wil_validate_mbox_regs(wil))
3288 ++ set_bit(wil_status_mbox_ready, wil->status);
3289 + /**
3290 + * Actual FW ready indicated by the
3291 + * WMI_FW_READY_EVENTID
3292 +diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
3293 +index bac829aa950d..a3dc42841526 100644
3294 +--- a/drivers/net/wireless/ath/wil6210/main.c
3295 ++++ b/drivers/net/wireless/ath/wil6210/main.c
3296 +@@ -871,7 +871,7 @@ static void wil_bl_crash_info(struct wil6210_priv *wil, bool is_err)
3297 +
3298 + static int wil_wait_for_fw_ready(struct wil6210_priv *wil)
3299 + {
3300 +- ulong to = msecs_to_jiffies(1000);
3301 ++ ulong to = msecs_to_jiffies(2000);
3302 + ulong left = wait_for_completion_timeout(&wil->wmi_ready, to);
3303 +
3304 + if (0 == left) {
3305 +diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c b/drivers/net/wireless/ath/wil6210/pcie_bus.c
3306 +index 6a3ab4bf916d..b2c3cf6db881 100644
3307 +--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
3308 ++++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
3309 +@@ -393,6 +393,9 @@ static int wil6210_suspend(struct device *dev, bool is_runtime)
3310 + int rc = 0;
3311 + struct pci_dev *pdev = to_pci_dev(dev);
3312 + struct wil6210_priv *wil = pci_get_drvdata(pdev);
3313 ++ struct net_device *ndev = wil_to_ndev(wil);
3314 ++ bool keep_radio_on = ndev->flags & IFF_UP &&
3315 ++ wil->keep_radio_on_during_sleep;
3316 +
3317 + wil_dbg_pm(wil, "suspend: %s\n", is_runtime ? "runtime" : "system");
3318 +
3319 +@@ -400,14 +403,14 @@ static int wil6210_suspend(struct device *dev, bool is_runtime)
3320 + if (rc)
3321 + goto out;
3322 +
3323 +- rc = wil_suspend(wil, is_runtime);
3324 ++ rc = wil_suspend(wil, is_runtime, keep_radio_on);
3325 + if (!rc) {
3326 + wil->suspend_stats.successful_suspends++;
3327 +
3328 +- /* If platform device supports keep_radio_on_during_sleep
3329 +- * it will control PCIe master
3330 ++ /* In case radio stays on, platform device will control
3331 ++ * PCIe master
3332 + */
3333 +- if (!wil->keep_radio_on_during_sleep)
3334 ++ if (!keep_radio_on)
3335 + /* disable bus mastering */
3336 + pci_clear_master(pdev);
3337 + }
3338 +@@ -420,20 +423,23 @@ static int wil6210_resume(struct device *dev, bool is_runtime)
3339 + int rc = 0;
3340 + struct pci_dev *pdev = to_pci_dev(dev);
3341 + struct wil6210_priv *wil = pci_get_drvdata(pdev);
3342 ++ struct net_device *ndev = wil_to_ndev(wil);
3343 ++ bool keep_radio_on = ndev->flags & IFF_UP &&
3344 ++ wil->keep_radio_on_during_sleep;
3345 +
3346 + wil_dbg_pm(wil, "resume: %s\n", is_runtime ? "runtime" : "system");
3347 +
3348 +- /* If platform device supports keep_radio_on_during_sleep it will
3349 +- * control PCIe master
3350 ++ /* In case radio stays on, platform device will control
3351 ++ * PCIe master
3352 + */
3353 +- if (!wil->keep_radio_on_during_sleep)
3354 ++ if (!keep_radio_on)
3355 + /* allow master */
3356 + pci_set_master(pdev);
3357 +- rc = wil_resume(wil, is_runtime);
3358 ++ rc = wil_resume(wil, is_runtime, keep_radio_on);
3359 + if (rc) {
3360 + wil_err(wil, "device failed to resume (%d)\n", rc);
3361 + wil->suspend_stats.failed_resumes++;
3362 +- if (!wil->keep_radio_on_during_sleep)
3363 ++ if (!keep_radio_on)
3364 + pci_clear_master(pdev);
3365 + } else {
3366 + wil->suspend_stats.successful_resumes++;
3367 +diff --git a/drivers/net/wireless/ath/wil6210/pm.c b/drivers/net/wireless/ath/wil6210/pm.c
3368 +index 8f5d1b447aaa..8378742ecd49 100644
3369 +--- a/drivers/net/wireless/ath/wil6210/pm.c
3370 ++++ b/drivers/net/wireless/ath/wil6210/pm.c
3371 +@@ -279,12 +279,9 @@ static int wil_resume_radio_off(struct wil6210_priv *wil)
3372 + return rc;
3373 + }
3374 +
3375 +-int wil_suspend(struct wil6210_priv *wil, bool is_runtime)
3376 ++int wil_suspend(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on)
3377 + {
3378 + int rc = 0;
3379 +- struct net_device *ndev = wil_to_ndev(wil);
3380 +- bool keep_radio_on = ndev->flags & IFF_UP &&
3381 +- wil->keep_radio_on_during_sleep;
3382 +
3383 + wil_dbg_pm(wil, "suspend: %s\n", is_runtime ? "runtime" : "system");
3384 +
3385 +@@ -307,12 +304,9 @@ int wil_suspend(struct wil6210_priv *wil, bool is_runtime)
3386 + return rc;
3387 + }
3388 +
3389 +-int wil_resume(struct wil6210_priv *wil, bool is_runtime)
3390 ++int wil_resume(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on)
3391 + {
3392 + int rc = 0;
3393 +- struct net_device *ndev = wil_to_ndev(wil);
3394 +- bool keep_radio_on = ndev->flags & IFF_UP &&
3395 +- wil->keep_radio_on_during_sleep;
3396 + unsigned long long suspend_time_usec = 0;
3397 +
3398 + wil_dbg_pm(wil, "resume: %s\n", is_runtime ? "runtime" : "system");
3399 +diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
3400 +index 16750056b8b5..b483c4266097 100644
3401 +--- a/drivers/net/wireless/ath/wil6210/txrx.c
3402 ++++ b/drivers/net/wireless/ath/wil6210/txrx.c
3403 +@@ -636,8 +636,8 @@ static int wil_rx_refill(struct wil6210_priv *wil, int count)
3404 + v->swtail = next_tail) {
3405 + rc = wil_vring_alloc_skb(wil, v, v->swtail, headroom);
3406 + if (unlikely(rc)) {
3407 +- wil_err(wil, "Error %d in wil_rx_refill[%d]\n",
3408 +- rc, v->swtail);
3409 ++ wil_err_ratelimited(wil, "Error %d in rx refill[%d]\n",
3410 ++ rc, v->swtail);
3411 + break;
3412 + }
3413 + }
3414 +diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
3415 +index 315ec8b59662..0bfd51adcc81 100644
3416 +--- a/drivers/net/wireless/ath/wil6210/wil6210.h
3417 ++++ b/drivers/net/wireless/ath/wil6210/wil6210.h
3418 +@@ -865,6 +865,7 @@ void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
3419 + int wil_find_cid(struct wil6210_priv *wil, const u8 *mac);
3420 + void wil_set_ethtoolops(struct net_device *ndev);
3421 +
3422 ++void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr, u32 size);
3423 + void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr);
3424 + void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr);
3425 + int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,
3426 +@@ -1000,8 +1001,8 @@ int wil_request_firmware(struct wil6210_priv *wil, const char *name,
3427 + bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);
3428 +
3429 + int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
3430 +-int wil_suspend(struct wil6210_priv *wil, bool is_runtime);
3431 +-int wil_resume(struct wil6210_priv *wil, bool is_runtime);
3432 ++int wil_suspend(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
3433 ++int wil_resume(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
3434 + bool wil_is_wmi_idle(struct wil6210_priv *wil);
3435 + int wmi_resume(struct wil6210_priv *wil);
3436 + int wmi_suspend(struct wil6210_priv *wil);
3437 +diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c
3438 +index 798516f42f2f..22bfa10ea827 100644
3439 +--- a/drivers/net/wireless/ath/wil6210/wmi.c
3440 ++++ b/drivers/net/wireless/ath/wil6210/wmi.c
3441 +@@ -140,13 +140,15 @@ static u32 wmi_addr_remap(u32 x)
3442 + /**
3443 + * Check address validity for WMI buffer; remap if needed
3444 + * @ptr - internal (linker) fw/ucode address
3445 ++ * @size - if non zero, validate the block does not
3446 ++ * exceed the device memory (bar)
3447 + *
3448 + * Valid buffer should be DWORD aligned
3449 + *
3450 + * return address for accessing buffer from the host;
3451 + * if buffer is not valid, return NULL.
3452 + */
3453 +-void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
3454 ++void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr_, u32 size)
3455 + {
3456 + u32 off;
3457 + u32 ptr = le32_to_cpu(ptr_);
3458 +@@ -161,10 +163,17 @@ void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
3459 + off = HOSTADDR(ptr);
3460 + if (off > wil->bar_size - 4)
3461 + return NULL;
3462 ++ if (size && ((off + size > wil->bar_size) || (off + size < off)))
3463 ++ return NULL;
3464 +
3465 + return wil->csr + off;
3466 + }
3467 +
3468 ++void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
3469 ++{
3470 ++ return wmi_buffer_block(wil, ptr_, 0);
3471 ++}
3472 ++
3473 + /**
3474 + * Check address validity
3475 + */
3476 +@@ -222,7 +231,7 @@ static int __wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len)
3477 + uint retry;
3478 + int rc = 0;
3479 +
3480 +- if (sizeof(cmd) + len > r->entry_size) {
3481 ++ if (len > r->entry_size - sizeof(cmd)) {
3482 + wil_err(wil, "WMI size too large: %d bytes, max is %d\n",
3483 + (int)(sizeof(cmd) + len), r->entry_size);
3484 + return -ERANGE;
3485 +diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
3486 +index 27224dc26413..a8ec5b2c5abb 100644
3487 +--- a/drivers/net/wireless/mac80211_hwsim.c
3488 ++++ b/drivers/net/wireless/mac80211_hwsim.c
3489 +@@ -3134,9 +3134,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
3490 + param.no_vif = true;
3491 +
3492 + if (info->attrs[HWSIM_ATTR_RADIO_NAME]) {
3493 +- hwname = kasprintf(GFP_KERNEL, "%.*s",
3494 +- nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3495 +- (char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]));
3496 ++ hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3497 ++ nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3498 ++ GFP_KERNEL);
3499 + if (!hwname)
3500 + return -ENOMEM;
3501 + param.hwname = hwname;
3502 +@@ -3175,9 +3175,9 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
3503 + if (info->attrs[HWSIM_ATTR_RADIO_ID]) {
3504 + idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
3505 + } else if (info->attrs[HWSIM_ATTR_RADIO_NAME]) {
3506 +- hwname = kasprintf(GFP_KERNEL, "%.*s",
3507 +- nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3508 +- (char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]));
3509 ++ hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3510 ++ nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]),
3511 ++ GFP_KERNEL);
3512 + if (!hwname)
3513 + return -ENOMEM;
3514 + } else
3515 +diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
3516 +index 2f1b54fab399..83e18b367944 100644
3517 +--- a/drivers/nvdimm/bus.c
3518 ++++ b/drivers/nvdimm/bus.c
3519 +@@ -951,8 +951,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
3520 + return -EFAULT;
3521 + }
3522 +
3523 +- if (!desc || (desc->out_num + desc->in_num == 0) ||
3524 +- !test_bit(cmd, &cmd_mask))
3525 ++ if (!desc ||
3526 ++ (desc->out_num + desc->in_num == 0) ||
3527 ++ cmd > ND_CMD_CALL ||
3528 ++ !test_bit(cmd, &cmd_mask))
3529 + return -ENOTTY;
3530 +
3531 + /* fail write commands (when read-only) */
3532 +diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
3533 +index 9e4d2ecf736d..058d542647dd 100644
3534 +--- a/drivers/nvme/host/fc.c
3535 ++++ b/drivers/nvme/host/fc.c
3536 +@@ -337,8 +337,7 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
3537 + !template->ls_req || !template->fcp_io ||
3538 + !template->ls_abort || !template->fcp_abort ||
3539 + !template->max_hw_queues || !template->max_sgl_segments ||
3540 +- !template->max_dif_sgl_segments || !template->dma_boundary ||
3541 +- !template->module) {
3542 ++ !template->max_dif_sgl_segments || !template->dma_boundary) {
3543 + ret = -EINVAL;
3544 + goto out_reghost_failed;
3545 + }
3546 +@@ -1763,7 +1762,6 @@ nvme_fc_ctrl_free(struct kref *ref)
3547 + {
3548 + struct nvme_fc_ctrl *ctrl =
3549 + container_of(ref, struct nvme_fc_ctrl, ref);
3550 +- struct nvme_fc_lport *lport = ctrl->lport;
3551 + unsigned long flags;
3552 +
3553 + if (ctrl->ctrl.tagset) {
3554 +@@ -1789,7 +1787,6 @@ nvme_fc_ctrl_free(struct kref *ref)
3555 + if (ctrl->ctrl.opts)
3556 + nvmf_free_options(ctrl->ctrl.opts);
3557 + kfree(ctrl);
3558 +- module_put(lport->ops->module);
3559 + }
3560 +
3561 + static void
3562 +@@ -2768,15 +2765,10 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
3563 + goto out_fail;
3564 + }
3565 +
3566 +- if (!try_module_get(lport->ops->module)) {
3567 +- ret = -EUNATCH;
3568 +- goto out_free_ctrl;
3569 +- }
3570 +-
3571 + idx = ida_simple_get(&nvme_fc_ctrl_cnt, 0, 0, GFP_KERNEL);
3572 + if (idx < 0) {
3573 + ret = -ENOSPC;
3574 +- goto out_mod_put;
3575 ++ goto out_free_ctrl;
3576 + }
3577 +
3578 + ctrl->ctrl.opts = opts;
3579 +@@ -2923,8 +2915,6 @@ out_free_queues:
3580 + out_free_ida:
3581 + put_device(ctrl->dev);
3582 + ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
3583 +-out_mod_put:
3584 +- module_put(lport->ops->module);
3585 + out_free_ctrl:
3586 + kfree(ctrl);
3587 + out_fail:
3588 +diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
3589 +index b8fe8702065b..096523d8dd42 100644
3590 +--- a/drivers/nvme/target/fcloop.c
3591 ++++ b/drivers/nvme/target/fcloop.c
3592 +@@ -693,7 +693,6 @@ fcloop_targetport_delete(struct nvmet_fc_target_port *targetport)
3593 + #define FCLOOP_DMABOUND_4G 0xFFFFFFFF
3594 +
3595 + static struct nvme_fc_port_template fctemplate = {
3596 +- .module = THIS_MODULE,
3597 + .localport_delete = fcloop_localport_delete,
3598 + .remoteport_delete = fcloop_remoteport_delete,
3599 + .create_queue = fcloop_create_queue,
3600 +diff --git a/drivers/of/base.c b/drivers/of/base.c
3601 +index 41b254be0295..c0281be8e061 100644
3602 +--- a/drivers/of/base.c
3603 ++++ b/drivers/of/base.c
3604 +@@ -169,9 +169,6 @@ int __of_attach_node_sysfs(struct device_node *np)
3605 + struct property *pp;
3606 + int rc;
3607 +
3608 +- if (!IS_ENABLED(CONFIG_SYSFS))
3609 +- return 0;
3610 +-
3611 + if (!of_kset)
3612 + return 0;
3613 +
3614 +diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
3615 +index 4bf6a9db6ac0..55c98f119df2 100644
3616 +--- a/drivers/of/unittest.c
3617 ++++ b/drivers/of/unittest.c
3618 +@@ -887,10 +887,13 @@ static void __init of_unittest_platform_populate(void)
3619 +
3620 + of_platform_populate(np, match, NULL, &test_bus->dev);
3621 + for_each_child_of_node(np, child) {
3622 +- for_each_child_of_node(child, grandchild)
3623 +- unittest(of_find_device_by_node(grandchild),
3624 ++ for_each_child_of_node(child, grandchild) {
3625 ++ pdev = of_find_device_by_node(grandchild);
3626 ++ unittest(pdev,
3627 + "Could not create device for node '%s'\n",
3628 + grandchild->name);
3629 ++ of_dev_put(pdev);
3630 ++ }
3631 + }
3632 +
3633 + of_platform_depopulate(&test_bus->dev);
3634 +diff --git a/drivers/pci/endpoint/pci-epc-mem.c b/drivers/pci/endpoint/pci-epc-mem.c
3635 +index 83b7d5d3fc3e..60fbfe92e0ef 100644
3636 +--- a/drivers/pci/endpoint/pci-epc-mem.c
3637 ++++ b/drivers/pci/endpoint/pci-epc-mem.c
3638 +@@ -90,6 +90,7 @@ int __pci_epc_mem_init(struct pci_epc *epc, phys_addr_t phys_base, size_t size,
3639 + mem->page_size = page_size;
3640 + mem->pages = pages;
3641 + mem->size = size;
3642 ++ mutex_init(&mem->lock);
3643 +
3644 + epc->mem = mem;
3645 +
3646 +@@ -133,7 +134,7 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
3647 + phys_addr_t *phys_addr, size_t size)
3648 + {
3649 + int pageno;
3650 +- void __iomem *virt_addr;
3651 ++ void __iomem *virt_addr = NULL;
3652 + struct pci_epc_mem *mem = epc->mem;
3653 + unsigned int page_shift = ilog2(mem->page_size);
3654 + int order;
3655 +@@ -141,15 +142,18 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
3656 + size = ALIGN(size, mem->page_size);
3657 + order = pci_epc_mem_get_order(mem, size);
3658 +
3659 ++ mutex_lock(&mem->lock);
3660 + pageno = bitmap_find_free_region(mem->bitmap, mem->pages, order);
3661 + if (pageno < 0)
3662 +- return NULL;
3663 ++ goto ret;
3664 +
3665 + *phys_addr = mem->phys_base + (pageno << page_shift);
3666 + virt_addr = ioremap(*phys_addr, size);
3667 + if (!virt_addr)
3668 + bitmap_release_region(mem->bitmap, pageno, order);
3669 +
3670 ++ret:
3671 ++ mutex_unlock(&mem->lock);
3672 + return virt_addr;
3673 + }
3674 + EXPORT_SYMBOL_GPL(pci_epc_mem_alloc_addr);
3675 +@@ -175,7 +179,9 @@ void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr,
3676 + pageno = (phys_addr - mem->phys_base) >> page_shift;
3677 + size = ALIGN(size, mem->page_size);
3678 + order = pci_epc_mem_get_order(mem, size);
3679 ++ mutex_lock(&mem->lock);
3680 + bitmap_release_region(mem->bitmap, pageno, order);
3681 ++ mutex_unlock(&mem->lock);
3682 + }
3683 + EXPORT_SYMBOL_GPL(pci_epc_mem_free_addr);
3684 +
3685 +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
3686 +index 6b4e82a4b64e..6f58767b5190 100644
3687 +--- a/drivers/pci/pcie/aspm.c
3688 ++++ b/drivers/pci/pcie/aspm.c
3689 +@@ -693,9 +693,9 @@ static void pcie_config_aspm_l1ss(struct pcie_link_state *link, u32 state)
3690 +
3691 + /* Enable what we need to enable */
3692 + pci_clear_and_set_dword(parent, up_cap_ptr + PCI_L1SS_CTL1,
3693 +- PCI_L1SS_CAP_L1_PM_SS, val);
3694 ++ PCI_L1SS_CTL1_L1SS_MASK, val);
3695 + pci_clear_and_set_dword(child, dw_cap_ptr + PCI_L1SS_CTL1,
3696 +- PCI_L1SS_CAP_L1_PM_SS, val);
3697 ++ PCI_L1SS_CTL1_L1SS_MASK, val);
3698 + }
3699 +
3700 + static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
3701 +diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
3702 +index bf229b442e72..6ef0d4b756f0 100644
3703 +--- a/drivers/pci/switch/switchtec.c
3704 ++++ b/drivers/pci/switch/switchtec.c
3705 +@@ -412,7 +412,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)
3706 + kref_get(&stuser->kref);
3707 + stuser->read_len = sizeof(stuser->data);
3708 + stuser_set_state(stuser, MRPC_QUEUED);
3709 +- init_completion(&stuser->comp);
3710 ++ reinit_completion(&stuser->comp);
3711 + list_add_tail(&stuser->list, &stdev->mrpc_queue);
3712 +
3713 + mrpc_cmd_submit(stdev);
3714 +diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
3715 +index 51f0961ecf3e..a7d8cadf172c 100644
3716 +--- a/drivers/power/supply/bq27xxx_battery.c
3717 ++++ b/drivers/power/supply/bq27xxx_battery.c
3718 +@@ -1842,7 +1842,10 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
3719 +
3720 + di->bat = power_supply_register_no_ws(di->dev, psy_desc, &psy_cfg);
3721 + if (IS_ERR(di->bat)) {
3722 +- dev_err(di->dev, "failed to register battery\n");
3723 ++ if (PTR_ERR(di->bat) == -EPROBE_DEFER)
3724 ++ dev_dbg(di->dev, "failed to register battery, deferring probe\n");
3725 ++ else
3726 ++ dev_err(di->dev, "failed to register battery\n");
3727 + return PTR_ERR(di->bat);
3728 + }
3729 +
3730 +diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c
3731 +index e1e5dfcb16f3..259fd58812ae 100644
3732 +--- a/drivers/pwm/pwm-pca9685.c
3733 ++++ b/drivers/pwm/pwm-pca9685.c
3734 +@@ -31,6 +31,7 @@
3735 + #include <linux/slab.h>
3736 + #include <linux/delay.h>
3737 + #include <linux/pm_runtime.h>
3738 ++#include <linux/bitmap.h>
3739 +
3740 + /*
3741 + * Because the PCA9685 has only one prescaler per chip, changing the period of
3742 +@@ -85,6 +86,7 @@ struct pca9685 {
3743 + #if IS_ENABLED(CONFIG_GPIOLIB)
3744 + struct mutex lock;
3745 + struct gpio_chip gpio;
3746 ++ DECLARE_BITMAP(pwms_inuse, PCA9685_MAXCHAN + 1);
3747 + #endif
3748 + };
3749 +
3750 +@@ -94,51 +96,51 @@ static inline struct pca9685 *to_pca(struct pwm_chip *chip)
3751 + }
3752 +
3753 + #if IS_ENABLED(CONFIG_GPIOLIB)
3754 +-static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
3755 ++static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx)
3756 + {
3757 +- struct pca9685 *pca = gpiochip_get_data(gpio);
3758 +- struct pwm_device *pwm;
3759 ++ bool is_inuse;
3760 +
3761 + mutex_lock(&pca->lock);
3762 +-
3763 +- pwm = &pca->chip.pwms[offset];
3764 +-
3765 +- if (pwm->flags & (PWMF_REQUESTED | PWMF_EXPORTED)) {
3766 +- mutex_unlock(&pca->lock);
3767 +- return -EBUSY;
3768 ++ if (pwm_idx >= PCA9685_MAXCHAN) {
3769 ++ /*
3770 ++ * "all LEDs" channel:
3771 ++ * pretend already in use if any of the PWMs are requested
3772 ++ */
3773 ++ if (!bitmap_empty(pca->pwms_inuse, PCA9685_MAXCHAN)) {
3774 ++ is_inuse = true;
3775 ++ goto out;
3776 ++ }
3777 ++ } else {
3778 ++ /*
3779 ++ * regular channel:
3780 ++ * pretend already in use if the "all LEDs" channel is requested
3781 ++ */
3782 ++ if (test_bit(PCA9685_MAXCHAN, pca->pwms_inuse)) {
3783 ++ is_inuse = true;
3784 ++ goto out;
3785 ++ }
3786 + }
3787 +-
3788 +- pwm_set_chip_data(pwm, (void *)1);
3789 +-
3790 ++ is_inuse = test_and_set_bit(pwm_idx, pca->pwms_inuse);
3791 ++out:
3792 + mutex_unlock(&pca->lock);
3793 +- pm_runtime_get_sync(pca->chip.dev);
3794 +- return 0;
3795 ++ return is_inuse;
3796 + }
3797 +
3798 +-static bool pca9685_pwm_is_gpio(struct pca9685 *pca, struct pwm_device *pwm)
3799 ++static void pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
3800 + {
3801 +- bool is_gpio = false;
3802 +-
3803 + mutex_lock(&pca->lock);
3804 ++ clear_bit(pwm_idx, pca->pwms_inuse);
3805 ++ mutex_unlock(&pca->lock);
3806 ++}
3807 +
3808 +- if (pwm->hwpwm >= PCA9685_MAXCHAN) {
3809 +- unsigned int i;
3810 +-
3811 +- /*
3812 +- * Check if any of the GPIOs are requested and in that case
3813 +- * prevent using the "all LEDs" channel.
3814 +- */
3815 +- for (i = 0; i < pca->gpio.ngpio; i++)
3816 +- if (gpiochip_is_requested(&pca->gpio, i)) {
3817 +- is_gpio = true;
3818 +- break;
3819 +- }
3820 +- } else if (pwm_get_chip_data(pwm)) {
3821 +- is_gpio = true;
3822 +- }
3823 ++static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
3824 ++{
3825 ++ struct pca9685 *pca = gpiochip_get_data(gpio);
3826 +
3827 +- mutex_unlock(&pca->lock);
3828 +- return is_gpio;
3829 ++ if (pca9685_pwm_test_and_set_inuse(pca, offset))
3830 ++ return -EBUSY;
3831 ++ pm_runtime_get_sync(pca->chip.dev);
3832 ++ return 0;
3833 + }
3834 +
3835 + static int pca9685_pwm_gpio_get(struct gpio_chip *gpio, unsigned int offset)
3836 +@@ -173,6 +175,7 @@ static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
3837 +
3838 + pca9685_pwm_gpio_set(gpio, offset, 0);
3839 + pm_runtime_put(pca->chip.dev);
3840 ++ pca9685_pwm_clear_inuse(pca, offset);
3841 + }
3842 +
3843 + static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
3844 +@@ -224,12 +227,17 @@ static int pca9685_pwm_gpio_probe(struct pca9685 *pca)
3845 + return devm_gpiochip_add_data(dev, &pca->gpio, pca);
3846 + }
3847 + #else
3848 +-static inline bool pca9685_pwm_is_gpio(struct pca9685 *pca,
3849 +- struct pwm_device *pwm)
3850 ++static inline bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca,
3851 ++ int pwm_idx)
3852 + {
3853 + return false;
3854 + }
3855 +
3856 ++static inline void
3857 ++pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
3858 ++{
3859 ++}
3860 ++
3861 + static inline int pca9685_pwm_gpio_probe(struct pca9685 *pca)
3862 + {
3863 + return 0;
3864 +@@ -413,7 +421,7 @@ static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
3865 + {
3866 + struct pca9685 *pca = to_pca(chip);
3867 +
3868 +- if (pca9685_pwm_is_gpio(pca, pwm))
3869 ++ if (pca9685_pwm_test_and_set_inuse(pca, pwm->hwpwm))
3870 + return -EBUSY;
3871 + pm_runtime_get_sync(chip->dev);
3872 +
3873 +@@ -422,8 +430,11 @@ static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
3874 +
3875 + static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
3876 + {
3877 ++ struct pca9685 *pca = to_pca(chip);
3878 ++
3879 + pca9685_pwm_disable(chip, pwm);
3880 + pm_runtime_put(chip->dev);
3881 ++ pca9685_pwm_clear_inuse(pca, pwm->hwpwm);
3882 + }
3883 +
3884 + static const struct pwm_ops pca9685_pwm_ops = {
3885 +diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
3886 +index 114481c9fba1..7802663efe33 100644
3887 +--- a/drivers/rpmsg/qcom_glink_native.c
3888 ++++ b/drivers/rpmsg/qcom_glink_native.c
3889 +@@ -221,6 +221,7 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink,
3890 + /* Setup glink internal glink_channel data */
3891 + spin_lock_init(&channel->recv_lock);
3892 + spin_lock_init(&channel->intent_lock);
3893 ++ mutex_init(&channel->intent_req_lock);
3894 +
3895 + channel->glink = glink;
3896 + channel->name = kstrdup(name, GFP_KERNEL);
3897 +diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c
3898 +index 2b54e71886d9..ed616b0bc563 100644
3899 +--- a/drivers/rpmsg/qcom_glink_smem.c
3900 ++++ b/drivers/rpmsg/qcom_glink_smem.c
3901 +@@ -181,6 +181,9 @@ static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe,
3902 + if (head >= pipe->native.length)
3903 + head -= pipe->native.length;
3904 +
3905 ++ /* Ensure ordering of fifo and head update */
3906 ++ wmb();
3907 ++
3908 + *pipe->head = cpu_to_le32(head);
3909 + }
3910 +
3911 +@@ -212,6 +215,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
3912 + ret = device_register(dev);
3913 + if (ret) {
3914 + pr_err("failed to register glink edge\n");
3915 ++ put_device(dev);
3916 + return ERR_PTR(ret);
3917 + }
3918 +
3919 +@@ -294,7 +298,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
3920 + return glink;
3921 +
3922 + err_put_dev:
3923 +- put_device(dev);
3924 ++ device_unregister(dev);
3925 +
3926 + return ERR_PTR(ret);
3927 + }
3928 +diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
3929 +index 7d3e5168fcef..efbbde7379f1 100644
3930 +--- a/drivers/rtc/rtc-88pm860x.c
3931 ++++ b/drivers/rtc/rtc-88pm860x.c
3932 +@@ -341,6 +341,10 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
3933 + info->dev = &pdev->dev;
3934 + dev_set_drvdata(&pdev->dev, info);
3935 +
3936 ++ info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
3937 ++ if (IS_ERR(info->rtc_dev))
3938 ++ return PTR_ERR(info->rtc_dev);
3939 ++
3940 + ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
3941 + rtc_update_handler, IRQF_ONESHOT, "rtc",
3942 + info);
3943 +@@ -382,13 +386,11 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
3944 + }
3945 + }
3946 +
3947 +- info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm860x-rtc",
3948 +- &pm860x_rtc_ops, THIS_MODULE);
3949 +- ret = PTR_ERR(info->rtc_dev);
3950 +- if (IS_ERR(info->rtc_dev)) {
3951 +- dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
3952 ++ info->rtc_dev->ops = &pm860x_rtc_ops;
3953 ++
3954 ++ ret = rtc_register_device(info->rtc_dev);
3955 ++ if (ret)
3956 + return ret;
3957 +- }
3958 +
3959 + /*
3960 + * enable internal XO instead of internal 3.25MHz clock since it can
3961 +diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
3962 +index ae6506a8b4f5..b25a2ba5ac48 100644
3963 +--- a/drivers/rtc/rtc-omap.c
3964 ++++ b/drivers/rtc/rtc-omap.c
3965 +@@ -559,9 +559,7 @@ static const struct pinctrl_ops rtc_pinctrl_ops = {
3966 + .dt_free_map = pinconf_generic_dt_free_map,
3967 + };
3968 +
3969 +-enum rtc_pin_config_param {
3970 +- PIN_CONFIG_ACTIVE_HIGH = PIN_CONFIG_END + 1,
3971 +-};
3972 ++#define PIN_CONFIG_ACTIVE_HIGH (PIN_CONFIG_END + 1)
3973 +
3974 + static const struct pinconf_generic_params rtc_params[] = {
3975 + {"ti,active-high", PIN_CONFIG_ACTIVE_HIGH, 0},
3976 +diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
3977 +index a1b4b0ed1f19..3b619b7b2c53 100644
3978 +--- a/drivers/rtc/rtc-pm8xxx.c
3979 ++++ b/drivers/rtc/rtc-pm8xxx.c
3980 +@@ -74,16 +74,18 @@ struct pm8xxx_rtc {
3981 + /*
3982 + * Steps to write the RTC registers.
3983 + * 1. Disable alarm if enabled.
3984 +- * 2. Write 0x00 to LSB.
3985 +- * 3. Write Byte[1], Byte[2], Byte[3] then Byte[0].
3986 +- * 4. Enable alarm if disabled in step 1.
3987 ++ * 2. Disable rtc if enabled.
3988 ++ * 3. Write 0x00 to LSB.
3989 ++ * 4. Write Byte[1], Byte[2], Byte[3] then Byte[0].
3990 ++ * 5. Enable rtc if disabled in step 2.
3991 ++ * 6. Enable alarm if disabled in step 1.
3992 + */
3993 + static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
3994 + {
3995 + int rc, i;
3996 + unsigned long secs, irq_flags;
3997 +- u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
3998 +- unsigned int ctrl_reg;
3999 ++ u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, rtc_disabled = 0;
4000 ++ unsigned int ctrl_reg, rtc_ctrl_reg;
4001 + struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
4002 + const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
4003 +
4004 +@@ -92,23 +94,38 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
4005 +
4006 + rtc_tm_to_time(tm, &secs);
4007 +
4008 ++ dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
4009 ++
4010 + for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
4011 + value[i] = secs & 0xFF;
4012 + secs >>= 8;
4013 + }
4014 +
4015 +- dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
4016 +-
4017 + spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
4018 +
4019 +- rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg);
4020 ++ rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
4021 + if (rc)
4022 + goto rtc_rw_fail;
4023 +
4024 + if (ctrl_reg & regs->alarm_en) {
4025 + alarm_enabled = 1;
4026 + ctrl_reg &= ~regs->alarm_en;
4027 +- rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
4028 ++ rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
4029 ++ if (rc) {
4030 ++ dev_err(dev, "Write to RTC Alarm control register failed\n");
4031 ++ goto rtc_rw_fail;
4032 ++ }
4033 ++ }
4034 ++
4035 ++ /* Disable RTC H/w before writing on RTC register */
4036 ++ rc = regmap_read(rtc_dd->regmap, regs->ctrl, &rtc_ctrl_reg);
4037 ++ if (rc)
4038 ++ goto rtc_rw_fail;
4039 ++
4040 ++ if (rtc_ctrl_reg & PM8xxx_RTC_ENABLE) {
4041 ++ rtc_disabled = 1;
4042 ++ rtc_ctrl_reg &= ~PM8xxx_RTC_ENABLE;
4043 ++ rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg);
4044 + if (rc) {
4045 + dev_err(dev, "Write to RTC control register failed\n");
4046 + goto rtc_rw_fail;
4047 +@@ -137,11 +154,21 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
4048 + goto rtc_rw_fail;
4049 + }
4050 +
4051 ++ /* Enable RTC H/w after writing on RTC register */
4052 ++ if (rtc_disabled) {
4053 ++ rtc_ctrl_reg |= PM8xxx_RTC_ENABLE;
4054 ++ rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg);
4055 ++ if (rc) {
4056 ++ dev_err(dev, "Write to RTC control register failed\n");
4057 ++ goto rtc_rw_fail;
4058 ++ }
4059 ++ }
4060 ++
4061 + if (alarm_enabled) {
4062 + ctrl_reg |= regs->alarm_en;
4063 +- rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
4064 ++ rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
4065 + if (rc) {
4066 +- dev_err(dev, "Write to RTC control register failed\n");
4067 ++ dev_err(dev, "Write to RTC Alarm control register failed\n");
4068 + goto rtc_rw_fail;
4069 + }
4070 + }
4071 +diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
4072 +index 8f90e4cea254..168f7c84edba 100644
4073 +--- a/drivers/s390/scsi/zfcp_erp.c
4074 ++++ b/drivers/s390/scsi/zfcp_erp.c
4075 +@@ -747,7 +747,7 @@ static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter)
4076 + adapter->peer_d_id);
4077 + if (IS_ERR(port)) /* error or port already attached */
4078 + return;
4079 +- _zfcp_erp_port_reopen(port, 0, "ereptp1");
4080 ++ zfcp_erp_port_reopen(port, 0, "ereptp1");
4081 + }
4082 +
4083 + static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action)
4084 +diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
4085 +index af937b91765e..fcf4b4175d77 100644
4086 +--- a/drivers/scsi/lpfc/lpfc_nvme.c
4087 ++++ b/drivers/scsi/lpfc/lpfc_nvme.c
4088 +@@ -1591,8 +1591,6 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport,
4089 +
4090 + /* Declare and initialization an instance of the FC NVME template. */
4091 + static struct nvme_fc_port_template lpfc_nvme_template = {
4092 +- .module = THIS_MODULE,
4093 +-
4094 + /* initiator-based functions */
4095 + .localport_delete = lpfc_nvme_localport_delete,
4096 + .remoteport_delete = lpfc_nvme_remoteport_delete,
4097 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4098 +index 9ef0c6265cd2..400c055167b0 100644
4099 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4100 ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4101 +@@ -8280,8 +8280,8 @@ static void scsih_remove(struct pci_dev *pdev)
4102 +
4103 + ioc->remove_host = 1;
4104 +
4105 +- mpt3sas_wait_for_commands_to_complete(ioc);
4106 +- _scsih_flush_running_cmds(ioc);
4107 ++ if (!pci_device_is_present(pdev))
4108 ++ _scsih_flush_running_cmds(ioc);
4109 +
4110 + _scsih_fw_event_cleanup_queue(ioc);
4111 +
4112 +@@ -8354,8 +8354,8 @@ scsih_shutdown(struct pci_dev *pdev)
4113 +
4114 + ioc->remove_host = 1;
4115 +
4116 +- mpt3sas_wait_for_commands_to_complete(ioc);
4117 +- _scsih_flush_running_cmds(ioc);
4118 ++ if (!pci_device_is_present(pdev))
4119 ++ _scsih_flush_running_cmds(ioc);
4120 +
4121 + _scsih_fw_event_cleanup_queue(ioc);
4122 +
4123 +diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
4124 +index 7dceed021236..6b33a1f24f56 100644
4125 +--- a/drivers/scsi/qla2xxx/qla_nvme.c
4126 ++++ b/drivers/scsi/qla2xxx/qla_nvme.c
4127 +@@ -578,7 +578,6 @@ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
4128 + }
4129 +
4130 + static struct nvme_fc_port_template qla_nvme_fc_transport = {
4131 +- .module = THIS_MODULE,
4132 + .localport_delete = qla_nvme_localport_delete,
4133 + .remoteport_delete = qla_nvme_remoteport_delete,
4134 + .create_queue = qla_nvme_alloc_queue,
4135 +diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
4136 +index 3a406b40f150..b5f589b7b43d 100644
4137 +--- a/drivers/scsi/sg.c
4138 ++++ b/drivers/scsi/sg.c
4139 +@@ -809,8 +809,10 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
4140 + "sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n",
4141 + (int) cmnd[0], (int) hp->cmd_len));
4142 +
4143 +- if (hp->dxfer_len >= SZ_256M)
4144 ++ if (hp->dxfer_len >= SZ_256M) {
4145 ++ sg_remove_request(sfp, srp);
4146 + return -EINVAL;
4147 ++ }
4148 +
4149 + k = sg_start_req(srp, cmnd);
4150 + if (k) {
4151 +diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
4152 +index c87d770b519a..f2b8de195d8a 100644
4153 +--- a/drivers/scsi/ufs/ufs-qcom.c
4154 ++++ b/drivers/scsi/ufs/ufs-qcom.c
4155 +@@ -1094,7 +1094,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
4156 + hba->quirks |= UFSHCD_QUIRK_BROKEN_LCC;
4157 + }
4158 +
4159 +- if (host->hw_ver.major >= 0x2) {
4160 ++ if (host->hw_ver.major == 0x2) {
4161 + hba->quirks |= UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION;
4162 +
4163 + if (!ufs_qcom_cap_qunipro(host))
4164 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
4165 +index c35045324695..78d9c2c48236 100644
4166 +--- a/drivers/scsi/ufs/ufshcd.c
4167 ++++ b/drivers/scsi/ufs/ufshcd.c
4168 +@@ -1448,6 +1448,11 @@ start:
4169 + */
4170 + if (ufshcd_can_hibern8_during_gating(hba) &&
4171 + ufshcd_is_link_hibern8(hba)) {
4172 ++ if (async) {
4173 ++ rc = -EAGAIN;
4174 ++ hba->clk_gating.active_reqs--;
4175 ++ break;
4176 ++ }
4177 + spin_unlock_irqrestore(hba->host->host_lock, flags);
4178 + flush_work(&hba->clk_gating.ungate_work);
4179 + spin_lock_irqsave(hba->host->host_lock, flags);
4180 +@@ -5366,19 +5371,30 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
4181 + u32 intr_status, enabled_intr_status;
4182 + irqreturn_t retval = IRQ_NONE;
4183 + struct ufs_hba *hba = __hba;
4184 ++ int retries = hba->nutrs;
4185 +
4186 + spin_lock(hba->host->host_lock);
4187 + intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
4188 +- enabled_intr_status =
4189 +- intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
4190 +
4191 +- if (intr_status)
4192 +- ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS);
4193 ++ /*
4194 ++ * There could be max of hba->nutrs reqs in flight and in worst case
4195 ++ * if the reqs get finished 1 by 1 after the interrupt status is
4196 ++ * read, make sure we handle them by checking the interrupt status
4197 ++ * again in a loop until we process all of the reqs before returning.
4198 ++ */
4199 ++ do {
4200 ++ enabled_intr_status =
4201 ++ intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
4202 ++ if (intr_status)
4203 ++ ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS);
4204 ++ if (enabled_intr_status) {
4205 ++ ufshcd_sl_intr(hba, enabled_intr_status);
4206 ++ retval = IRQ_HANDLED;
4207 ++ }
4208 ++
4209 ++ intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
4210 ++ } while (intr_status && --retries);
4211 +
4212 +- if (enabled_intr_status) {
4213 +- ufshcd_sl_intr(hba, enabled_intr_status);
4214 +- retval = IRQ_HANDLED;
4215 +- }
4216 + spin_unlock(hba->host->host_lock);
4217 + return retval;
4218 + }
4219 +diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c
4220 +index 3a12123de466..0e083fe8b893 100644
4221 +--- a/drivers/soc/imx/gpc.c
4222 ++++ b/drivers/soc/imx/gpc.c
4223 +@@ -97,8 +97,8 @@ static int imx6_pm_domain_power_off(struct generic_pm_domain *genpd)
4224 + static int imx6_pm_domain_power_on(struct generic_pm_domain *genpd)
4225 + {
4226 + struct imx_pm_domain *pd = to_imx_pm_domain(genpd);
4227 +- int i, ret, sw, sw2iso;
4228 +- u32 val;
4229 ++ int i, ret;
4230 ++ u32 val, req;
4231 +
4232 + if (pd->supply) {
4233 + ret = regulator_enable(pd->supply);
4234 +@@ -117,17 +117,18 @@ static int imx6_pm_domain_power_on(struct generic_pm_domain *genpd)
4235 + regmap_update_bits(pd->regmap, pd->reg_offs + GPC_PGC_CTRL_OFFS,
4236 + 0x1, 0x1);
4237 +
4238 +- /* Read ISO and ISO2SW power up delays */
4239 +- regmap_read(pd->regmap, pd->reg_offs + GPC_PGC_PUPSCR_OFFS, &val);
4240 +- sw = val & 0x3f;
4241 +- sw2iso = (val >> 8) & 0x3f;
4242 +-
4243 + /* Request GPC to power up domain */
4244 +- val = BIT(pd->cntr_pdn_bit + 1);
4245 +- regmap_update_bits(pd->regmap, GPC_CNTR, val, val);
4246 ++ req = BIT(pd->cntr_pdn_bit + 1);
4247 ++ regmap_update_bits(pd->regmap, GPC_CNTR, req, req);
4248 +
4249 +- /* Wait ISO + ISO2SW IPG clock cycles */
4250 +- udelay(DIV_ROUND_UP(sw + sw2iso, pd->ipg_rate_mhz));
4251 ++ /* Wait for the PGC to handle the request */
4252 ++ ret = regmap_read_poll_timeout(pd->regmap, GPC_CNTR, val, !(val & req),
4253 ++ 1, 50);
4254 ++ if (ret)
4255 ++ pr_err("powerup request on domain %s timed out\n", genpd->name);
4256 ++
4257 ++ /* Wait for reset to propagate through peripherals */
4258 ++ usleep_range(5, 10);
4259 +
4260 + /* Disable reset clocks for all devices in the domain */
4261 + for (i = 0; i < pd->num_clks; i++)
4262 +@@ -329,6 +330,7 @@ static const struct regmap_config imx_gpc_regmap_config = {
4263 + .rd_table = &access_table,
4264 + .wr_table = &access_table,
4265 + .max_register = 0x2ac,
4266 ++ .fast_io = true,
4267 + };
4268 +
4269 + static struct generic_pm_domain *imx_gpc_onecell_domains[] = {
4270 +diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
4271 +index 18ec52f2078a..89dd50fa404f 100644
4272 +--- a/drivers/soc/qcom/smem.c
4273 ++++ b/drivers/soc/qcom/smem.c
4274 +@@ -646,7 +646,7 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,
4275 + return -EINVAL;
4276 + }
4277 +
4278 +- if (header->size != entry->size) {
4279 ++ if (le32_to_cpu(header->size) != le32_to_cpu(entry->size)) {
4280 + dev_err(smem->dev,
4281 + "Partition %d has invalid size\n", i);
4282 + return -EINVAL;
4283 +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
4284 +index fb7bd422e2e1..ee49b227dc12 100644
4285 +--- a/drivers/target/iscsi/iscsi_target.c
4286 ++++ b/drivers/target/iscsi/iscsi_target.c
4287 +@@ -4314,30 +4314,37 @@ int iscsit_close_connection(
4288 + if (!atomic_read(&sess->session_reinstatement) &&
4289 + atomic_read(&sess->session_fall_back_to_erl0)) {
4290 + spin_unlock_bh(&sess->conn_lock);
4291 ++ complete_all(&sess->session_wait_comp);
4292 + iscsit_close_session(sess);
4293 +
4294 + return 0;
4295 + } else if (atomic_read(&sess->session_logout)) {
4296 + pr_debug("Moving to TARG_SESS_STATE_FREE.\n");
4297 + sess->session_state = TARG_SESS_STATE_FREE;
4298 +- spin_unlock_bh(&sess->conn_lock);
4299 +
4300 +- if (atomic_read(&sess->sleep_on_sess_wait_comp))
4301 +- complete(&sess->session_wait_comp);
4302 ++ if (atomic_read(&sess->session_close)) {
4303 ++ spin_unlock_bh(&sess->conn_lock);
4304 ++ complete_all(&sess->session_wait_comp);
4305 ++ iscsit_close_session(sess);
4306 ++ } else {
4307 ++ spin_unlock_bh(&sess->conn_lock);
4308 ++ }
4309 +
4310 + return 0;
4311 + } else {
4312 + pr_debug("Moving to TARG_SESS_STATE_FAILED.\n");
4313 + sess->session_state = TARG_SESS_STATE_FAILED;
4314 +
4315 +- if (!atomic_read(&sess->session_continuation)) {
4316 +- spin_unlock_bh(&sess->conn_lock);
4317 ++ if (!atomic_read(&sess->session_continuation))
4318 + iscsit_start_time2retain_handler(sess);
4319 +- } else
4320 +- spin_unlock_bh(&sess->conn_lock);
4321 +
4322 +- if (atomic_read(&sess->sleep_on_sess_wait_comp))
4323 +- complete(&sess->session_wait_comp);
4324 ++ if (atomic_read(&sess->session_close)) {
4325 ++ spin_unlock_bh(&sess->conn_lock);
4326 ++ complete_all(&sess->session_wait_comp);
4327 ++ iscsit_close_session(sess);
4328 ++ } else {
4329 ++ spin_unlock_bh(&sess->conn_lock);
4330 ++ }
4331 +
4332 + return 0;
4333 + }
4334 +@@ -4446,9 +4453,9 @@ static void iscsit_logout_post_handler_closesession(
4335 + complete(&conn->conn_logout_comp);
4336 +
4337 + iscsit_dec_conn_usage_count(conn);
4338 ++ atomic_set(&sess->session_close, 1);
4339 + iscsit_stop_session(sess, sleep, sleep);
4340 + iscsit_dec_session_usage_count(sess);
4341 +- iscsit_close_session(sess);
4342 + }
4343 +
4344 + static void iscsit_logout_post_handler_samecid(
4345 +@@ -4583,49 +4590,6 @@ void iscsit_fail_session(struct iscsi_session *sess)
4346 + sess->session_state = TARG_SESS_STATE_FAILED;
4347 + }
4348 +
4349 +-int iscsit_free_session(struct iscsi_session *sess)
4350 +-{
4351 +- u16 conn_count = atomic_read(&sess->nconn);
4352 +- struct iscsi_conn *conn, *conn_tmp = NULL;
4353 +- int is_last;
4354 +-
4355 +- spin_lock_bh(&sess->conn_lock);
4356 +- atomic_set(&sess->sleep_on_sess_wait_comp, 1);
4357 +-
4358 +- list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list,
4359 +- conn_list) {
4360 +- if (conn_count == 0)
4361 +- break;
4362 +-
4363 +- if (list_is_last(&conn->conn_list, &sess->sess_conn_list)) {
4364 +- is_last = 1;
4365 +- } else {
4366 +- iscsit_inc_conn_usage_count(conn_tmp);
4367 +- is_last = 0;
4368 +- }
4369 +- iscsit_inc_conn_usage_count(conn);
4370 +-
4371 +- spin_unlock_bh(&sess->conn_lock);
4372 +- iscsit_cause_connection_reinstatement(conn, 1);
4373 +- spin_lock_bh(&sess->conn_lock);
4374 +-
4375 +- iscsit_dec_conn_usage_count(conn);
4376 +- if (is_last == 0)
4377 +- iscsit_dec_conn_usage_count(conn_tmp);
4378 +-
4379 +- conn_count--;
4380 +- }
4381 +-
4382 +- if (atomic_read(&sess->nconn)) {
4383 +- spin_unlock_bh(&sess->conn_lock);
4384 +- wait_for_completion(&sess->session_wait_comp);
4385 +- } else
4386 +- spin_unlock_bh(&sess->conn_lock);
4387 +-
4388 +- iscsit_close_session(sess);
4389 +- return 0;
4390 +-}
4391 +-
4392 + void iscsit_stop_session(
4393 + struct iscsi_session *sess,
4394 + int session_sleep,
4395 +@@ -4636,8 +4600,6 @@ void iscsit_stop_session(
4396 + int is_last;
4397 +
4398 + spin_lock_bh(&sess->conn_lock);
4399 +- if (session_sleep)
4400 +- atomic_set(&sess->sleep_on_sess_wait_comp, 1);
4401 +
4402 + if (connection_sleep) {
4403 + list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list,
4404 +@@ -4695,12 +4657,15 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)
4405 + spin_lock(&sess->conn_lock);
4406 + if (atomic_read(&sess->session_fall_back_to_erl0) ||
4407 + atomic_read(&sess->session_logout) ||
4408 ++ atomic_read(&sess->session_close) ||
4409 + (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
4410 + spin_unlock(&sess->conn_lock);
4411 + continue;
4412 + }
4413 ++ iscsit_inc_session_usage_count(sess);
4414 + atomic_set(&sess->session_reinstatement, 1);
4415 + atomic_set(&sess->session_fall_back_to_erl0, 1);
4416 ++ atomic_set(&sess->session_close, 1);
4417 + spin_unlock(&sess->conn_lock);
4418 +
4419 + list_move_tail(&se_sess->sess_list, &free_list);
4420 +@@ -4710,7 +4675,9 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)
4421 + list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {
4422 + sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;
4423 +
4424 +- iscsit_free_session(sess);
4425 ++ list_del_init(&se_sess->sess_list);
4426 ++ iscsit_stop_session(sess, 1, 1);
4427 ++ iscsit_dec_session_usage_count(sess);
4428 + session_count++;
4429 + }
4430 +
4431 +diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h
4432 +index 42de1843aa40..f0d2cbf594c9 100644
4433 +--- a/drivers/target/iscsi/iscsi_target.h
4434 ++++ b/drivers/target/iscsi/iscsi_target.h
4435 +@@ -43,7 +43,6 @@ extern int iscsi_target_rx_thread(void *);
4436 + extern int iscsit_close_connection(struct iscsi_conn *);
4437 + extern int iscsit_close_session(struct iscsi_session *);
4438 + extern void iscsit_fail_session(struct iscsi_session *);
4439 +-extern int iscsit_free_session(struct iscsi_session *);
4440 + extern void iscsit_stop_session(struct iscsi_session *, int, int);
4441 + extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);
4442 +
4443 +diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
4444 +index 0ebc4818e132..4191e4a8a9ed 100644
4445 +--- a/drivers/target/iscsi/iscsi_target_configfs.c
4446 ++++ b/drivers/target/iscsi/iscsi_target_configfs.c
4447 +@@ -1503,20 +1503,23 @@ static void lio_tpg_close_session(struct se_session *se_sess)
4448 + spin_lock(&sess->conn_lock);
4449 + if (atomic_read(&sess->session_fall_back_to_erl0) ||
4450 + atomic_read(&sess->session_logout) ||
4451 ++ atomic_read(&sess->session_close) ||
4452 + (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
4453 + spin_unlock(&sess->conn_lock);
4454 + spin_unlock_bh(&se_tpg->session_lock);
4455 + return;
4456 + }
4457 ++ iscsit_inc_session_usage_count(sess);
4458 + atomic_set(&sess->session_reinstatement, 1);
4459 + atomic_set(&sess->session_fall_back_to_erl0, 1);
4460 ++ atomic_set(&sess->session_close, 1);
4461 + spin_unlock(&sess->conn_lock);
4462 +
4463 + iscsit_stop_time2retain_timer(sess);
4464 + spin_unlock_bh(&se_tpg->session_lock);
4465 +
4466 + iscsit_stop_session(sess, 1, 1);
4467 +- iscsit_close_session(sess);
4468 ++ iscsit_dec_session_usage_count(sess);
4469 + }
4470 +
4471 + static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
4472 +diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
4473 +index 27893d90c4ef..55df6f99e669 100644
4474 +--- a/drivers/target/iscsi/iscsi_target_login.c
4475 ++++ b/drivers/target/iscsi/iscsi_target_login.c
4476 +@@ -199,6 +199,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
4477 + spin_lock(&sess_p->conn_lock);
4478 + if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
4479 + atomic_read(&sess_p->session_logout) ||
4480 ++ atomic_read(&sess_p->session_close) ||
4481 + (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
4482 + spin_unlock(&sess_p->conn_lock);
4483 + continue;
4484 +@@ -209,6 +210,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
4485 + (sess_p->sess_ops->SessionType == sessiontype))) {
4486 + atomic_set(&sess_p->session_reinstatement, 1);
4487 + atomic_set(&sess_p->session_fall_back_to_erl0, 1);
4488 ++ atomic_set(&sess_p->session_close, 1);
4489 + spin_unlock(&sess_p->conn_lock);
4490 + iscsit_inc_session_usage_count(sess_p);
4491 + iscsit_stop_time2retain_timer(sess_p);
4492 +@@ -233,7 +235,6 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
4493 + if (sess->session_state == TARG_SESS_STATE_FAILED) {
4494 + spin_unlock_bh(&sess->conn_lock);
4495 + iscsit_dec_session_usage_count(sess);
4496 +- iscsit_close_session(sess);
4497 + return 0;
4498 + }
4499 + spin_unlock_bh(&sess->conn_lock);
4500 +@@ -241,7 +242,6 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
4501 + iscsit_stop_session(sess, 1, 1);
4502 + iscsit_dec_session_usage_count(sess);
4503 +
4504 +- iscsit_close_session(sess);
4505 + return 0;
4506 + }
4507 +
4508 +@@ -534,6 +534,7 @@ static int iscsi_login_non_zero_tsih_s2(
4509 + sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr;
4510 + if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
4511 + atomic_read(&sess_p->session_logout) ||
4512 ++ atomic_read(&sess_p->session_close) ||
4513 + (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED))
4514 + continue;
4515 + if (!memcmp(sess_p->isid, pdu->isid, 6) &&
4516 +diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
4517 +index a1c7125cb968..5a348efb91ad 100644
4518 +--- a/drivers/tty/ehv_bytechan.c
4519 ++++ b/drivers/tty/ehv_bytechan.c
4520 +@@ -139,6 +139,21 @@ static int find_console_handle(void)
4521 + return 1;
4522 + }
4523 +
4524 ++static unsigned int local_ev_byte_channel_send(unsigned int handle,
4525 ++ unsigned int *count,
4526 ++ const char *p)
4527 ++{
4528 ++ char buffer[EV_BYTE_CHANNEL_MAX_BYTES];
4529 ++ unsigned int c = *count;
4530 ++
4531 ++ if (c < sizeof(buffer)) {
4532 ++ memcpy(buffer, p, c);
4533 ++ memset(&buffer[c], 0, sizeof(buffer) - c);
4534 ++ p = buffer;
4535 ++ }
4536 ++ return ev_byte_channel_send(handle, count, p);
4537 ++}
4538 ++
4539 + /*************************** EARLY CONSOLE DRIVER ***************************/
4540 +
4541 + #ifdef CONFIG_PPC_EARLY_DEBUG_EHV_BC
4542 +@@ -157,7 +172,7 @@ static void byte_channel_spin_send(const char data)
4543 +
4544 + do {
4545 + count = 1;
4546 +- ret = ev_byte_channel_send(CONFIG_PPC_EARLY_DEBUG_EHV_BC_HANDLE,
4547 ++ ret = local_ev_byte_channel_send(CONFIG_PPC_EARLY_DEBUG_EHV_BC_HANDLE,
4548 + &count, &data);
4549 + } while (ret == EV_EAGAIN);
4550 + }
4551 +@@ -224,7 +239,7 @@ static int ehv_bc_console_byte_channel_send(unsigned int handle, const char *s,
4552 + while (count) {
4553 + len = min_t(unsigned int, count, EV_BYTE_CHANNEL_MAX_BYTES);
4554 + do {
4555 +- ret = ev_byte_channel_send(handle, &len, s);
4556 ++ ret = local_ev_byte_channel_send(handle, &len, s);
4557 + } while (ret == EV_EAGAIN);
4558 + count -= len;
4559 + s += len;
4560 +@@ -404,7 +419,7 @@ static void ehv_bc_tx_dequeue(struct ehv_bc_data *bc)
4561 + CIRC_CNT_TO_END(bc->head, bc->tail, BUF_SIZE),
4562 + EV_BYTE_CHANNEL_MAX_BYTES);
4563 +
4564 +- ret = ev_byte_channel_send(bc->handle, &len, bc->buf + bc->tail);
4565 ++ ret = local_ev_byte_channel_send(bc->handle, &len, bc->buf + bc->tail);
4566 +
4567 + /* 'len' is valid only if the return code is 0 or EV_EAGAIN */
4568 + if (!ret || (ret == EV_EAGAIN))
4569 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
4570 +index 021899c58028..010201dbd029 100644
4571 +--- a/drivers/usb/dwc3/core.c
4572 ++++ b/drivers/usb/dwc3/core.c
4573 +@@ -867,6 +867,9 @@ static int dwc3_core_init(struct dwc3 *dwc)
4574 + if (dwc->dis_tx_ipgap_linecheck_quirk)
4575 + reg |= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS;
4576 +
4577 ++ if (dwc->parkmode_disable_ss_quirk)
4578 ++ reg |= DWC3_GUCTL1_PARKMODE_DISABLE_SS;
4579 ++
4580 + dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
4581 + }
4582 +
4583 +@@ -1107,6 +1110,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
4584 + "snps,dis-del-phy-power-chg-quirk");
4585 + dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev,
4586 + "snps,dis-tx-ipgap-linecheck-quirk");
4587 ++ dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev,
4588 ++ "snps,parkmode-disable-ss-quirk");
4589 +
4590 + dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
4591 + "snps,tx_de_emphasis_quirk");
4592 +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
4593 +index 40bf0e0768d9..8747f9f02229 100644
4594 +--- a/drivers/usb/dwc3/core.h
4595 ++++ b/drivers/usb/dwc3/core.h
4596 +@@ -206,6 +206,7 @@
4597 + #define DWC3_GCTL_DSBLCLKGTNG BIT(0)
4598 +
4599 + /* Global User Control 1 Register */
4600 ++#define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17)
4601 + #define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28)
4602 + #define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24)
4603 +
4604 +@@ -863,6 +864,8 @@ struct dwc3_scratchpad_array {
4605 + * change quirk.
4606 + * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate
4607 + * check during HS transmit.
4608 ++ * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed
4609 ++ * instances in park mode.
4610 + * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
4611 + * @tx_de_emphasis: Tx de-emphasis value
4612 + * 0 - -6dB de-emphasis
4613 +@@ -1022,6 +1025,7 @@ struct dwc3 {
4614 + unsigned dis_u2_freeclk_exists_quirk:1;
4615 + unsigned dis_del_phy_power_chg_quirk:1;
4616 + unsigned dis_tx_ipgap_linecheck_quirk:1;
4617 ++ unsigned parkmode_disable_ss_quirk:1;
4618 +
4619 + unsigned tx_de_emphasis_quirk:1;
4620 + unsigned tx_de_emphasis:2;
4621 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
4622 +index 5a4cf779b269..c1f037af9702 100644
4623 +--- a/drivers/usb/gadget/composite.c
4624 ++++ b/drivers/usb/gadget/composite.c
4625 +@@ -850,6 +850,11 @@ static int set_config(struct usb_composite_dev *cdev,
4626 + else
4627 + power = min(power, 900U);
4628 + done:
4629 ++ if (power <= USB_SELF_POWER_VBUS_MAX_DRAW)
4630 ++ usb_gadget_set_selfpowered(gadget);
4631 ++ else
4632 ++ usb_gadget_clear_selfpowered(gadget);
4633 ++
4634 + usb_gadget_vbus_draw(gadget, power);
4635 + if (result >= 0 && cdev->delayed_status)
4636 + result = USB_GADGET_DELAYED_STATUS;
4637 +@@ -2281,6 +2286,7 @@ void composite_suspend(struct usb_gadget *gadget)
4638 +
4639 + cdev->suspended = 1;
4640 +
4641 ++ usb_gadget_set_selfpowered(gadget);
4642 + usb_gadget_vbus_draw(gadget, 2);
4643 + }
4644 +
4645 +@@ -2309,6 +2315,9 @@ void composite_resume(struct usb_gadget *gadget)
4646 + else
4647 + maxpower = min(maxpower, 900U);
4648 +
4649 ++ if (maxpower > USB_SELF_POWER_VBUS_MAX_DRAW)
4650 ++ usb_gadget_clear_selfpowered(gadget);
4651 ++
4652 + usb_gadget_vbus_draw(gadget, maxpower);
4653 + }
4654 +
4655 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
4656 +index 282396e8eec6..819fd77a2da4 100644
4657 +--- a/drivers/usb/gadget/function/f_fs.c
4658 ++++ b/drivers/usb/gadget/function/f_fs.c
4659 +@@ -1037,6 +1037,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
4660 +
4661 + ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
4662 + if (unlikely(ret)) {
4663 ++ io_data->req = NULL;
4664 + usb_ep_free_request(ep->ep, req);
4665 + goto error_lock;
4666 + }
4667 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
4668 +index 83961a22bef1..07dcf687a52b 100644
4669 +--- a/drivers/video/fbdev/core/fbmem.c
4670 ++++ b/drivers/video/fbdev/core/fbmem.c
4671 +@@ -1134,7 +1134,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
4672 + case FBIOGET_FSCREENINFO:
4673 + if (!lock_fb_info(info))
4674 + return -ENODEV;
4675 +- fix = info->fix;
4676 ++ memcpy(&fix, &info->fix, sizeof(fix));
4677 + unlock_fb_info(info);
4678 +
4679 + ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0;
4680 +diff --git a/drivers/video/fbdev/sis/init301.c b/drivers/video/fbdev/sis/init301.c
4681 +index 1ec9c3e0e1d8..f23a381442d3 100644
4682 +--- a/drivers/video/fbdev/sis/init301.c
4683 ++++ b/drivers/video/fbdev/sis/init301.c
4684 +@@ -522,9 +522,7 @@ SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime)
4685 + SiS_DDC2Delay(SiS_Pr, 0x4000);
4686 + }
4687 +
4688 +- } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* ||
4689 +- (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
4690 +- (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */
4691 ++ } else if (SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 315 series, LVDS; Special */
4692 +
4693 + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4694 + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
4695 +diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
4696 +index 72d7589072f5..92615badc173 100644
4697 +--- a/fs/btrfs/async-thread.c
4698 ++++ b/fs/btrfs/async-thread.c
4699 +@@ -447,3 +447,11 @@ void btrfs_set_work_high_priority(struct btrfs_work *work)
4700 + {
4701 + set_bit(WORK_HIGH_PRIO_BIT, &work->flags);
4702 + }
4703 ++
4704 ++void btrfs_flush_workqueue(struct btrfs_workqueue *wq)
4705 ++{
4706 ++ if (wq->high)
4707 ++ flush_workqueue(wq->high->normal_wq);
4708 ++
4709 ++ flush_workqueue(wq->normal->normal_wq);
4710 ++}
4711 +diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
4712 +index fc957e00cef1..2a25aef6ef2a 100644
4713 +--- a/fs/btrfs/async-thread.h
4714 ++++ b/fs/btrfs/async-thread.h
4715 +@@ -85,4 +85,6 @@ void btrfs_set_work_high_priority(struct btrfs_work *work);
4716 + struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work);
4717 + struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq);
4718 + bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
4719 ++void btrfs_flush_workqueue(struct btrfs_workqueue *wq);
4720 ++
4721 + #endif
4722 +diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
4723 +index 87414fc9e268..416fb50a5378 100644
4724 +--- a/fs/btrfs/delayed-inode.c
4725 ++++ b/fs/btrfs/delayed-inode.c
4726 +@@ -18,6 +18,7 @@
4727 + */
4728 +
4729 + #include <linux/slab.h>
4730 ++#include <linux/sched/mm.h>
4731 + #include "delayed-inode.h"
4732 + #include "disk-io.h"
4733 + #include "transaction.h"
4734 +@@ -833,11 +834,14 @@ static int btrfs_insert_delayed_item(struct btrfs_trans_handle *trans,
4735 + {
4736 + struct btrfs_fs_info *fs_info = root->fs_info;
4737 + struct extent_buffer *leaf;
4738 ++ unsigned int nofs_flag;
4739 + char *ptr;
4740 + int ret;
4741 +
4742 ++ nofs_flag = memalloc_nofs_save();
4743 + ret = btrfs_insert_empty_item(trans, root, path, &delayed_item->key,
4744 + delayed_item->data_len);
4745 ++ memalloc_nofs_restore(nofs_flag);
4746 + if (ret < 0 && ret != -EEXIST)
4747 + return ret;
4748 +
4749 +@@ -966,6 +970,7 @@ static int btrfs_delete_delayed_items(struct btrfs_trans_handle *trans,
4750 + struct btrfs_delayed_node *node)
4751 + {
4752 + struct btrfs_delayed_item *curr, *prev;
4753 ++ unsigned int nofs_flag;
4754 + int ret = 0;
4755 +
4756 + do_again:
4757 +@@ -974,7 +979,9 @@ do_again:
4758 + if (!curr)
4759 + goto delete_fail;
4760 +
4761 ++ nofs_flag = memalloc_nofs_save();
4762 + ret = btrfs_search_slot(trans, root, &curr->key, path, -1, 1);
4763 ++ memalloc_nofs_restore(nofs_flag);
4764 + if (ret < 0)
4765 + goto delete_fail;
4766 + else if (ret > 0) {
4767 +@@ -1041,6 +1048,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
4768 + struct btrfs_key key;
4769 + struct btrfs_inode_item *inode_item;
4770 + struct extent_buffer *leaf;
4771 ++ unsigned int nofs_flag;
4772 + int mod;
4773 + int ret;
4774 +
4775 +@@ -1053,7 +1061,9 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
4776 + else
4777 + mod = 1;
4778 +
4779 ++ nofs_flag = memalloc_nofs_save();
4780 + ret = btrfs_lookup_inode(trans, root, path, &key, mod);
4781 ++ memalloc_nofs_restore(nofs_flag);
4782 + if (ret > 0) {
4783 + btrfs_release_path(path);
4784 + return -ENOENT;
4785 +@@ -1104,7 +1114,10 @@ search:
4786 +
4787 + key.type = BTRFS_INODE_EXTREF_KEY;
4788 + key.offset = -1;
4789 ++
4790 ++ nofs_flag = memalloc_nofs_save();
4791 + ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
4792 ++ memalloc_nofs_restore(nofs_flag);
4793 + if (ret < 0)
4794 + goto err_out;
4795 + ASSERT(ret);
4796 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
4797 +index 6b4fee5c79f9..096c015b22a4 100644
4798 +--- a/fs/btrfs/disk-io.c
4799 ++++ b/fs/btrfs/disk-io.c
4800 +@@ -3725,6 +3725,19 @@ void close_ctree(struct btrfs_fs_info *fs_info)
4801 + */
4802 + btrfs_delete_unused_bgs(fs_info);
4803 +
4804 ++ /*
4805 ++ * There might be existing delayed inode workers still running
4806 ++ * and holding an empty delayed inode item. We must wait for
4807 ++ * them to complete first because they can create a transaction.
4808 ++ * This happens when someone calls btrfs_balance_delayed_items()
4809 ++ * and then a transaction commit runs the same delayed nodes
4810 ++ * before any delayed worker has done something with the nodes.
4811 ++ * We must wait for any worker here and not at transaction
4812 ++ * commit time since that could cause a deadlock.
4813 ++ * This is a very rare case.
4814 ++ */
4815 ++ btrfs_flush_workqueue(fs_info->delayed_workers);
4816 ++
4817 + ret = btrfs_commit_super(fs_info);
4818 + if (ret)
4819 + btrfs_err(fs_info, "commit super ret %d", ret);
4820 +diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
4821 +index d4c00edd16d2..f4397dd19583 100644
4822 +--- a/fs/btrfs/relocation.c
4823 ++++ b/fs/btrfs/relocation.c
4824 +@@ -538,8 +538,8 @@ static int should_ignore_root(struct btrfs_root *root)
4825 + if (!reloc_root)
4826 + return 0;
4827 +
4828 +- if (btrfs_root_last_snapshot(&reloc_root->root_item) ==
4829 +- root->fs_info->running_transaction->transid - 1)
4830 ++ if (btrfs_header_generation(reloc_root->commit_root) ==
4831 ++ root->fs_info->running_transaction->transid)
4832 + return 0;
4833 + /*
4834 + * if there is reloc tree and it was created in previous
4835 +@@ -1194,7 +1194,7 @@ out:
4836 + free_backref_node(cache, lower);
4837 + }
4838 +
4839 +- free_backref_node(cache, node);
4840 ++ remove_backref_node(cache, node);
4841 + return ERR_PTR(err);
4842 + }
4843 + ASSERT(!node || !node->detached);
4844 +@@ -1306,7 +1306,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
4845 + if (!node)
4846 + return -ENOMEM;
4847 +
4848 +- node->bytenr = root->node->start;
4849 ++ node->bytenr = root->commit_root->start;
4850 + node->data = root;
4851 +
4852 + spin_lock(&rc->reloc_root_tree.lock);
4853 +@@ -1337,10 +1337,11 @@ static void __del_reloc_root(struct btrfs_root *root)
4854 + if (rc && root->node) {
4855 + spin_lock(&rc->reloc_root_tree.lock);
4856 + rb_node = tree_search(&rc->reloc_root_tree.rb_root,
4857 +- root->node->start);
4858 ++ root->commit_root->start);
4859 + if (rb_node) {
4860 + node = rb_entry(rb_node, struct mapping_node, rb_node);
4861 + rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root);
4862 ++ RB_CLEAR_NODE(&node->rb_node);
4863 + }
4864 + spin_unlock(&rc->reloc_root_tree.lock);
4865 + if (!node)
4866 +@@ -1358,7 +1359,7 @@ static void __del_reloc_root(struct btrfs_root *root)
4867 + * helper to update the 'address of tree root -> reloc tree'
4868 + * mapping
4869 + */
4870 +-static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)
4871 ++static int __update_reloc_root(struct btrfs_root *root)
4872 + {
4873 + struct btrfs_fs_info *fs_info = root->fs_info;
4874 + struct rb_node *rb_node;
4875 +@@ -1367,7 +1368,7 @@ static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)
4876 +
4877 + spin_lock(&rc->reloc_root_tree.lock);
4878 + rb_node = tree_search(&rc->reloc_root_tree.rb_root,
4879 +- root->node->start);
4880 ++ root->commit_root->start);
4881 + if (rb_node) {
4882 + node = rb_entry(rb_node, struct mapping_node, rb_node);
4883 + rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root);
4884 +@@ -1379,7 +1380,7 @@ static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)
4885 + BUG_ON((struct btrfs_root *)node->data != root);
4886 +
4887 + spin_lock(&rc->reloc_root_tree.lock);
4888 +- node->bytenr = new_bytenr;
4889 ++ node->bytenr = root->node->start;
4890 + rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
4891 + node->bytenr, &node->rb_node);
4892 + spin_unlock(&rc->reloc_root_tree.lock);
4893 +@@ -1524,6 +1525,7 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
4894 + }
4895 +
4896 + if (reloc_root->commit_root != reloc_root->node) {
4897 ++ __update_reloc_root(reloc_root);
4898 + btrfs_set_root_node(root_item, reloc_root->node);
4899 + free_extent_buffer(reloc_root->commit_root);
4900 + reloc_root->commit_root = btrfs_root_node(reloc_root);
4901 +@@ -2480,7 +2482,21 @@ out:
4902 + free_reloc_roots(&reloc_roots);
4903 + }
4904 +
4905 +- BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root));
4906 ++ /*
4907 ++ * We used to have
4908 ++ *
4909 ++ * BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root));
4910 ++ *
4911 ++ * here, but it's wrong. If we fail to start the transaction in
4912 ++ * prepare_to_merge() we will have only 0 ref reloc roots, none of which
4913 ++ * have actually been removed from the reloc_root_tree rb tree. This is
4914 ++ * fine because we're bailing here, and we hold a reference on the root
4915 ++ * for the list that holds it, so these roots will be cleaned up when we
4916 ++ * do the reloc_dirty_list afterwards. Meanwhile the root->reloc_root
4917 ++ * will be cleaned up on unmount.
4918 ++ *
4919 ++ * The remaining nodes will be cleaned up by free_reloc_control.
4920 ++ */
4921 + }
4922 +
4923 + static void free_block_list(struct rb_root *blocks)
4924 +@@ -4698,11 +4714,6 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
4925 + BUG_ON(rc->stage == UPDATE_DATA_PTRS &&
4926 + root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID);
4927 +
4928 +- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
4929 +- if (buf == root->node)
4930 +- __update_reloc_root(root, cow->start);
4931 +- }
4932 +-
4933 + level = btrfs_header_level(buf);
4934 + if (btrfs_header_generation(buf) <=
4935 + btrfs_root_last_snapshot(&root->root_item))
4936 +diff --git a/fs/buffer.c b/fs/buffer.c
4937 +index bdca7b10e239..cae7f24a0410 100644
4938 +--- a/fs/buffer.c
4939 ++++ b/fs/buffer.c
4940 +@@ -1398,6 +1398,17 @@ void __breadahead(struct block_device *bdev, sector_t block, unsigned size)
4941 + }
4942 + EXPORT_SYMBOL(__breadahead);
4943 +
4944 ++void __breadahead_gfp(struct block_device *bdev, sector_t block, unsigned size,
4945 ++ gfp_t gfp)
4946 ++{
4947 ++ struct buffer_head *bh = __getblk_gfp(bdev, block, size, gfp);
4948 ++ if (likely(bh)) {
4949 ++ ll_rw_block(REQ_OP_READ, REQ_RAHEAD, 1, &bh);
4950 ++ brelse(bh);
4951 ++ }
4952 ++}
4953 ++EXPORT_SYMBOL(__breadahead_gfp);
4954 ++
4955 + /**
4956 + * __bread_gfp() - reads a specified block and returns the bh
4957 + * @bdev: the block_device to read from
4958 +diff --git a/fs/cifs/file.c b/fs/cifs/file.c
4959 +index 5e75c5f77f4c..662977b8d6ae 100644
4960 +--- a/fs/cifs/file.c
4961 ++++ b/fs/cifs/file.c
4962 +@@ -3303,7 +3303,7 @@ again:
4963 + if (rc == -ENODATA)
4964 + rc = 0;
4965 +
4966 +- ctx->rc = (rc == 0) ? ctx->total_len : rc;
4967 ++ ctx->rc = (rc == 0) ? (ssize_t)ctx->total_len : rc;
4968 +
4969 + mutex_unlock(&ctx->aio_mutex);
4970 +
4971 +diff --git a/fs/exec.c b/fs/exec.c
4972 +index 7def97f6aac2..f687e7d59beb 100644
4973 +--- a/fs/exec.c
4974 ++++ b/fs/exec.c
4975 +@@ -1373,7 +1373,7 @@ void setup_new_exec(struct linux_binprm * bprm)
4976 +
4977 + /* An exec changes our domain. We are no longer part of the thread
4978 + group */
4979 +- current->self_exec_id++;
4980 ++ WRITE_ONCE(current->self_exec_id, current->self_exec_id + 1);
4981 + flush_signal_handlers(current, 0);
4982 + }
4983 + EXPORT_SYMBOL(setup_new_exec);
4984 +diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
4985 +index dd8f10db82e9..bd1d68ff3a9f 100644
4986 +--- a/fs/ext2/xattr.c
4987 ++++ b/fs/ext2/xattr.c
4988 +@@ -56,6 +56,7 @@
4989 +
4990 + #include <linux/buffer_head.h>
4991 + #include <linux/init.h>
4992 ++#include <linux/printk.h>
4993 + #include <linux/slab.h>
4994 + #include <linux/mbcache.h>
4995 + #include <linux/quotaops.h>
4996 +@@ -84,8 +85,8 @@
4997 + printk("\n"); \
4998 + } while (0)
4999 + #else
5000 +-# define ea_idebug(f...)
5001 +-# define ea_bdebug(f...)
5002 ++# define ea_idebug(inode, f...) no_printk(f)
5003 ++# define ea_bdebug(bh, f...) no_printk(f)
5004 + #endif
5005 +
5006 + static int ext2_xattr_set2(struct inode *, struct buffer_head *,
5007 +@@ -838,8 +839,7 @@ ext2_xattr_cache_insert(struct mb_cache *cache, struct buffer_head *bh)
5008 + error = mb_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr, 1);
5009 + if (error) {
5010 + if (error == -EBUSY) {
5011 +- ea_bdebug(bh, "already in cache (%d cache entries)",
5012 +- atomic_read(&ext2_xattr_cache->c_entry_count));
5013 ++ ea_bdebug(bh, "already in cache");
5014 + error = 0;
5015 + }
5016 + } else
5017 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
5018 +index 20d68554680f..fa6ae9014e8f 100644
5019 +--- a/fs/ext4/extents.c
5020 ++++ b/fs/ext4/extents.c
5021 +@@ -3446,8 +3446,8 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
5022 + (unsigned long long)map->m_lblk, map_len);
5023 +
5024 + sbi = EXT4_SB(inode->i_sb);
5025 +- eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
5026 +- inode->i_sb->s_blocksize_bits;
5027 ++ eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1)
5028 ++ >> inode->i_sb->s_blocksize_bits;
5029 + if (eof_block < map->m_lblk + map_len)
5030 + eof_block = map->m_lblk + map_len;
5031 +
5032 +@@ -3702,8 +3702,8 @@ static int ext4_split_convert_extents(handle_t *handle,
5033 + __func__, inode->i_ino,
5034 + (unsigned long long)map->m_lblk, map->m_len);
5035 +
5036 +- eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
5037 +- inode->i_sb->s_blocksize_bits;
5038 ++ eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1)
5039 ++ >> inode->i_sb->s_blocksize_bits;
5040 + if (eof_block < map->m_lblk + map->m_len)
5041 + eof_block = map->m_lblk + map->m_len;
5042 + /*
5043 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
5044 +index 1e2edebd0929..5b0d5ca2c2b2 100644
5045 +--- a/fs/ext4/inode.c
5046 ++++ b/fs/ext4/inode.c
5047 +@@ -4593,7 +4593,7 @@ make_io:
5048 + if (end > table)
5049 + end = table;
5050 + while (b <= end)
5051 +- sb_breadahead(sb, b++);
5052 ++ sb_breadahead_unmovable(sb, b++);
5053 + }
5054 +
5055 + /*
5056 +@@ -4981,7 +4981,7 @@ static int ext4_inode_blocks_set(handle_t *handle,
5057 + struct ext4_inode_info *ei)
5058 + {
5059 + struct inode *inode = &(ei->vfs_inode);
5060 +- u64 i_blocks = inode->i_blocks;
5061 ++ u64 i_blocks = READ_ONCE(inode->i_blocks);
5062 + struct super_block *sb = inode->i_sb;
5063 +
5064 + if (i_blocks <= ~0U) {
5065 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
5066 +index f5646bcad770..0ced133a36ec 100644
5067 +--- a/fs/ext4/super.c
5068 ++++ b/fs/ext4/super.c
5069 +@@ -369,7 +369,8 @@ static void save_error_info(struct super_block *sb, const char *func,
5070 + unsigned int line)
5071 + {
5072 + __save_error_info(sb, func, line);
5073 +- ext4_commit_super(sb, 1);
5074 ++ if (!bdev_read_only(sb->s_bdev))
5075 ++ ext4_commit_super(sb, 1);
5076 + }
5077 +
5078 + /*
5079 +@@ -3969,7 +3970,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
5080 + if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
5081 + sbi->s_inodes_per_group > blocksize * 8) {
5082 + ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n",
5083 +- sbi->s_blocks_per_group);
5084 ++ sbi->s_inodes_per_group);
5085 + goto failed_mount;
5086 + }
5087 + sbi->s_itb_per_group = sbi->s_inodes_per_group /
5088 +@@ -4100,9 +4101,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
5089 + EXT4_BLOCKS_PER_GROUP(sb) - 1);
5090 + do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb));
5091 + if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) {
5092 +- ext4_msg(sb, KERN_WARNING, "groups count too large: %u "
5093 ++ ext4_msg(sb, KERN_WARNING, "groups count too large: %llu "
5094 + "(block count %llu, first data block %u, "
5095 +- "blocks per group %lu)", sbi->s_groups_count,
5096 ++ "blocks per group %lu)", blocks_count,
5097 + ext4_blocks_count(es),
5098 + le32_to_cpu(es->s_first_data_block),
5099 + EXT4_BLOCKS_PER_GROUP(sb));
5100 +@@ -4145,7 +4146,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
5101 + /* Pre-read the descriptors into the buffer cache */
5102 + for (i = 0; i < db_count; i++) {
5103 + block = descriptor_loc(sb, logical_sb_block, i);
5104 +- sb_breadahead(sb, block);
5105 ++ sb_breadahead_unmovable(sb, block);
5106 + }
5107 +
5108 + for (i = 0; i < db_count; i++) {
5109 +diff --git a/fs/filesystems.c b/fs/filesystems.c
5110 +index f2728a4a03a1..8fb7cda40997 100644
5111 +--- a/fs/filesystems.c
5112 ++++ b/fs/filesystems.c
5113 +@@ -279,7 +279,9 @@ struct file_system_type *get_fs_type(const char *name)
5114 + fs = __get_fs_type(name, len);
5115 + if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
5116 + fs = __get_fs_type(name, len);
5117 +- WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
5118 ++ if (!fs)
5119 ++ pr_warn_once("request_module fs-%.*s succeeded, but still no fs?\n",
5120 ++ len, name);
5121 + }
5122 +
5123 + if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
5124 +diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
5125 +index aea1ed0aebd0..1e2ff4b32c79 100644
5126 +--- a/fs/gfs2/glock.c
5127 ++++ b/fs/gfs2/glock.c
5128 +@@ -636,6 +636,9 @@ __acquires(&gl->gl_lockref.lock)
5129 + goto out_unlock;
5130 + if (nonblock)
5131 + goto out_sched;
5132 ++ smp_mb();
5133 ++ if (atomic_read(&gl->gl_revokes) != 0)
5134 ++ goto out_sched;
5135 + set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
5136 + GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
5137 + gl->gl_target = gl->gl_demote_state;
5138 +diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
5139 +index e6d554476db4..eeebe80c6be4 100644
5140 +--- a/fs/hfsplus/attributes.c
5141 ++++ b/fs/hfsplus/attributes.c
5142 +@@ -292,6 +292,10 @@ static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
5143 + return -ENOENT;
5144 + }
5145 +
5146 ++ /* Avoid btree corruption */
5147 ++ hfs_bnode_read(fd->bnode, fd->search_key,
5148 ++ fd->keyoffset, fd->keylength);
5149 ++
5150 + err = hfs_brec_remove(fd);
5151 + if (err)
5152 + return err;
5153 +diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
5154 +index 1a4bd8d9636e..6870103a0f59 100644
5155 +--- a/fs/jbd2/commit.c
5156 ++++ b/fs/jbd2/commit.c
5157 +@@ -994,9 +994,10 @@ restart_loop:
5158 + * journalled data) we need to unmap buffer and clear
5159 + * more bits. We also need to be careful about the check
5160 + * because the data page mapping can get cleared under
5161 +- * out hands, which alse need not to clear more bits
5162 +- * because the page and buffers will be freed and can
5163 +- * never be reused once we are done with them.
5164 ++ * our hands. Note that if mapping == NULL, we don't
5165 ++ * need to make buffer unmapped because the page is
5166 ++ * already detached from the mapping and buffers cannot
5167 ++ * get reused.
5168 + */
5169 + mapping = READ_ONCE(bh->b_page->mapping);
5170 + if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) {
5171 +diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
5172 +index b8d55da2f04d..440ff8e7082b 100644
5173 +--- a/fs/nfs/callback_proc.c
5174 ++++ b/fs/nfs/callback_proc.c
5175 +@@ -127,6 +127,8 @@ static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
5176 + restart:
5177 + list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
5178 + list_for_each_entry(lo, &server->layouts, plh_layouts) {
5179 ++ if (!pnfs_layout_is_valid(lo))
5180 ++ continue;
5181 + if (stateid != NULL &&
5182 + !nfs4_stateid_match_other(stateid, &lo->plh_stateid))
5183 + continue;
5184 +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
5185 +index 9d07b53e1647..e6ea4511c41c 100644
5186 +--- a/fs/nfs/direct.c
5187 ++++ b/fs/nfs/direct.c
5188 +@@ -600,6 +600,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter)
5189 + l_ctx = nfs_get_lock_context(dreq->ctx);
5190 + if (IS_ERR(l_ctx)) {
5191 + result = PTR_ERR(l_ctx);
5192 ++ nfs_direct_req_release(dreq);
5193 + goto out_release;
5194 + }
5195 + dreq->l_ctx = l_ctx;
5196 +@@ -1023,6 +1024,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
5197 + l_ctx = nfs_get_lock_context(dreq->ctx);
5198 + if (IS_ERR(l_ctx)) {
5199 + result = PTR_ERR(l_ctx);
5200 ++ nfs_direct_req_release(dreq);
5201 + goto out_release;
5202 + }
5203 + dreq->l_ctx = l_ctx;
5204 +diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
5205 +index ceb6892d9bbd..7c01936be7c7 100644
5206 +--- a/fs/nfs/pagelist.c
5207 ++++ b/fs/nfs/pagelist.c
5208 +@@ -864,15 +864,6 @@ static void nfs_pageio_setup_mirroring(struct nfs_pageio_descriptor *pgio,
5209 + pgio->pg_mirror_count = mirror_count;
5210 + }
5211 +
5212 +-/*
5213 +- * nfs_pageio_stop_mirroring - stop using mirroring (set mirror count to 1)
5214 +- */
5215 +-void nfs_pageio_stop_mirroring(struct nfs_pageio_descriptor *pgio)
5216 +-{
5217 +- pgio->pg_mirror_count = 1;
5218 +- pgio->pg_mirror_idx = 0;
5219 +-}
5220 +-
5221 + static void nfs_pageio_cleanup_mirroring(struct nfs_pageio_descriptor *pgio)
5222 + {
5223 + pgio->pg_mirror_count = 1;
5224 +@@ -1301,6 +1292,14 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index)
5225 + }
5226 + }
5227 +
5228 ++/*
5229 ++ * nfs_pageio_stop_mirroring - stop using mirroring (set mirror count to 1)
5230 ++ */
5231 ++void nfs_pageio_stop_mirroring(struct nfs_pageio_descriptor *pgio)
5232 ++{
5233 ++ nfs_pageio_complete(pgio);
5234 ++}
5235 ++
5236 + int __init nfs_init_nfspagecache(void)
5237 + {
5238 + nfs_page_cachep = kmem_cache_create("nfs_page",
5239 +diff --git a/fs/nfs/write.c b/fs/nfs/write.c
5240 +index 89f36040adf6..7b6bda68aa86 100644
5241 +--- a/fs/nfs/write.c
5242 ++++ b/fs/nfs/write.c
5243 +@@ -422,6 +422,7 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list,
5244 + }
5245 +
5246 + subreq->wb_head = subreq;
5247 ++ nfs_release_request(old_head);
5248 +
5249 + if (test_and_clear_bit(PG_INODE_REF, &subreq->wb_flags)) {
5250 + nfs_release_request(subreq);
5251 +diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
5252 +index addd7c5f2d3e..bed54e8adcf9 100644
5253 +--- a/fs/ocfs2/alloc.c
5254 ++++ b/fs/ocfs2/alloc.c
5255 +@@ -7240,6 +7240,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
5256 + struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
5257 + struct ocfs2_inline_data *idata = &di->id2.i_data;
5258 +
5259 ++ /* No need to punch hole beyond i_size. */
5260 ++ if (start >= i_size_read(inode))
5261 ++ return 0;
5262 ++
5263 + if (end > i_size_read(inode))
5264 + end = i_size_read(inode);
5265 +
5266 +diff --git a/include/acpi/processor.h b/include/acpi/processor.h
5267 +index d591bb77f592..f4bff2313547 100644
5268 +--- a/include/acpi/processor.h
5269 ++++ b/include/acpi/processor.h
5270 +@@ -291,6 +291,14 @@ static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
5271 + }
5272 + #endif
5273 +
5274 ++static inline int call_on_cpu(int cpu, long (*fn)(void *), void *arg,
5275 ++ bool direct)
5276 ++{
5277 ++ if (direct || (is_percpu_thread() && cpu == smp_processor_id()))
5278 ++ return fn(arg);
5279 ++ return work_on_cpu(cpu, fn, arg);
5280 ++}
5281 ++
5282 + /* in processor_perflib.c */
5283 +
5284 + #ifdef CONFIG_CPU_FREQ
5285 +diff --git a/include/keys/big_key-type.h b/include/keys/big_key-type.h
5286 +index e0970a578188..a7207a965466 100644
5287 +--- a/include/keys/big_key-type.h
5288 ++++ b/include/keys/big_key-type.h
5289 +@@ -21,6 +21,6 @@ extern void big_key_free_preparse(struct key_preparsed_payload *prep);
5290 + extern void big_key_revoke(struct key *key);
5291 + extern void big_key_destroy(struct key *key);
5292 + extern void big_key_describe(const struct key *big_key, struct seq_file *m);
5293 +-extern long big_key_read(const struct key *key, char __user *buffer, size_t buflen);
5294 ++extern long big_key_read(const struct key *key, char *buffer, size_t buflen);
5295 +
5296 + #endif /* _KEYS_BIG_KEY_TYPE_H */
5297 +diff --git a/include/keys/user-type.h b/include/keys/user-type.h
5298 +index 12babe991594..0d8f3cd3056f 100644
5299 +--- a/include/keys/user-type.h
5300 ++++ b/include/keys/user-type.h
5301 +@@ -45,8 +45,7 @@ extern int user_update(struct key *key, struct key_preparsed_payload *prep);
5302 + extern void user_revoke(struct key *key);
5303 + extern void user_destroy(struct key *key);
5304 + extern void user_describe(const struct key *user, struct seq_file *m);
5305 +-extern long user_read(const struct key *key,
5306 +- char __user *buffer, size_t buflen);
5307 ++extern long user_read(const struct key *key, char *buffer, size_t buflen);
5308 +
5309 + static inline const struct user_key_payload *user_key_payload_rcu(const struct key *key)
5310 + {
5311 +diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
5312 +index afa37f807f12..2e1077ea77db 100644
5313 +--- a/include/linux/buffer_head.h
5314 ++++ b/include/linux/buffer_head.h
5315 +@@ -187,6 +187,8 @@ struct buffer_head *__getblk_gfp(struct block_device *bdev, sector_t block,
5316 + void __brelse(struct buffer_head *);
5317 + void __bforget(struct buffer_head *);
5318 + void __breadahead(struct block_device *, sector_t block, unsigned int size);
5319 ++void __breadahead_gfp(struct block_device *, sector_t block, unsigned int size,
5320 ++ gfp_t gfp);
5321 + struct buffer_head *__bread_gfp(struct block_device *,
5322 + sector_t block, unsigned size, gfp_t gfp);
5323 + void invalidate_bh_lrus(void);
5324 +@@ -319,6 +321,12 @@ sb_breadahead(struct super_block *sb, sector_t block)
5325 + __breadahead(sb->s_bdev, block, sb->s_blocksize);
5326 + }
5327 +
5328 ++static inline void
5329 ++sb_breadahead_unmovable(struct super_block *sb, sector_t block)
5330 ++{
5331 ++ __breadahead_gfp(sb->s_bdev, block, sb->s_blocksize, 0);
5332 ++}
5333 ++
5334 + static inline struct buffer_head *
5335 + sb_getblk(struct super_block *sb, sector_t block)
5336 + {
5337 +diff --git a/include/linux/compiler.h b/include/linux/compiler.h
5338 +index f84d332085c3..3ffe3f3f7903 100644
5339 +--- a/include/linux/compiler.h
5340 ++++ b/include/linux/compiler.h
5341 +@@ -331,7 +331,7 @@ unsigned long read_word_at_a_time(const void *addr)
5342 + * compiler has support to do so.
5343 + */
5344 + #define compiletime_assert(condition, msg) \
5345 +- _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
5346 ++ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
5347 +
5348 + #define compiletime_assert_atomic_type(t) \
5349 + compiletime_assert(__native_word(t), \
5350 +diff --git a/include/linux/devfreq_cooling.h b/include/linux/devfreq_cooling.h
5351 +index 4635f95000a4..79a6e37a1d6f 100644
5352 +--- a/include/linux/devfreq_cooling.h
5353 ++++ b/include/linux/devfreq_cooling.h
5354 +@@ -75,7 +75,7 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
5355 +
5356 + #else /* !CONFIG_DEVFREQ_THERMAL */
5357 +
5358 +-struct thermal_cooling_device *
5359 ++static inline struct thermal_cooling_device *
5360 + of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
5361 + struct devfreq_cooling_power *dfc_power)
5362 + {
5363 +diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
5364 +index dba15ca8e60b..1dcd9198beb7 100644
5365 +--- a/include/linux/iocontext.h
5366 ++++ b/include/linux/iocontext.h
5367 +@@ -8,6 +8,7 @@
5368 +
5369 + enum {
5370 + ICQ_EXITED = 1 << 2,
5371 ++ ICQ_DESTROYED = 1 << 3,
5372 + };
5373 +
5374 + /*
5375 +diff --git a/include/linux/key-type.h b/include/linux/key-type.h
5376 +index dfb3ba782d2c..535b310a4c3b 100644
5377 +--- a/include/linux/key-type.h
5378 ++++ b/include/linux/key-type.h
5379 +@@ -125,7 +125,7 @@ struct key_type {
5380 + * much is copied into the buffer
5381 + * - shouldn't do the copy if the buffer is NULL
5382 + */
5383 +- long (*read)(const struct key *key, char __user *buffer, size_t buflen);
5384 ++ long (*read)(const struct key *key, char *buffer, size_t buflen);
5385 +
5386 + /* handle request_key() for this type instead of invoking
5387 + * /sbin/request-key (optional)
5388 +diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h
5389 +index e9c3b98df3e2..a726f96010d5 100644
5390 +--- a/include/linux/nvme-fc-driver.h
5391 ++++ b/include/linux/nvme-fc-driver.h
5392 +@@ -279,8 +279,6 @@ struct nvme_fc_remote_port {
5393 + *
5394 + * Host/Initiator Transport Entrypoints/Parameters:
5395 + *
5396 +- * @module: The LLDD module using the interface
5397 +- *
5398 + * @localport_delete: The LLDD initiates deletion of a localport via
5399 + * nvme_fc_deregister_localport(). However, the teardown is
5400 + * asynchronous. This routine is called upon the completion of the
5401 +@@ -394,8 +392,6 @@ struct nvme_fc_remote_port {
5402 + * Value is Mandatory. Allowed to be zero.
5403 + */
5404 + struct nvme_fc_port_template {
5405 +- struct module *module;
5406 +-
5407 + /* initiator-based functions */
5408 + void (*localport_delete)(struct nvme_fc_local_port *);
5409 + void (*remoteport_delete)(struct nvme_fc_remote_port *);
5410 +diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
5411 +index f7a04e1af112..abbc74621f38 100644
5412 +--- a/include/linux/pci-epc.h
5413 ++++ b/include/linux/pci-epc.h
5414 +@@ -63,6 +63,7 @@ struct pci_epc_ops {
5415 + * @bitmap: bitmap to manage the PCI address space
5416 + * @pages: number of bits representing the address region
5417 + * @page_size: size of each page
5418 ++ * @lock: mutex to protect bitmap
5419 + */
5420 + struct pci_epc_mem {
5421 + phys_addr_t phys_base;
5422 +@@ -70,6 +71,8 @@ struct pci_epc_mem {
5423 + unsigned long *bitmap;
5424 + size_t page_size;
5425 + int pages;
5426 ++ /* mutex to protect against concurrent access for memory allocation*/
5427 ++ struct mutex lock;
5428 + };
5429 +
5430 + /**
5431 +diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
5432 +index 73a7bf30fe9a..3f3cece31148 100644
5433 +--- a/include/linux/percpu_counter.h
5434 ++++ b/include/linux/percpu_counter.h
5435 +@@ -78,9 +78,9 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc)
5436 + */
5437 + static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
5438 + {
5439 +- s64 ret = fbc->count;
5440 ++ /* Prevent reloads of fbc->count */
5441 ++ s64 ret = READ_ONCE(fbc->count);
5442 +
5443 +- barrier(); /* Prevent reloads of fbc->count */
5444 + if (ret >= 0)
5445 + return ret;
5446 + return 0;
5447 +diff --git a/include/linux/sched.h b/include/linux/sched.h
5448 +index b06577652643..99650f05c271 100644
5449 +--- a/include/linux/sched.h
5450 ++++ b/include/linux/sched.h
5451 +@@ -839,8 +839,8 @@ struct task_struct {
5452 + struct seccomp seccomp;
5453 +
5454 + /* Thread group tracking: */
5455 +- u32 parent_exec_id;
5456 +- u32 self_exec_id;
5457 ++ u64 parent_exec_id;
5458 ++ u64 self_exec_id;
5459 +
5460 + /* Protection against (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, mempolicy: */
5461 + spinlock_t alloc_lock;
5462 +diff --git a/include/linux/swab.h b/include/linux/swab.h
5463 +index e466fd159c85..bcff5149861a 100644
5464 +--- a/include/linux/swab.h
5465 ++++ b/include/linux/swab.h
5466 +@@ -7,6 +7,7 @@
5467 + # define swab16 __swab16
5468 + # define swab32 __swab32
5469 + # define swab64 __swab64
5470 ++# define swab __swab
5471 + # define swahw32 __swahw32
5472 + # define swahb32 __swahb32
5473 + # define swab16p __swab16p
5474 +diff --git a/include/linux/swapops.h b/include/linux/swapops.h
5475 +index 1d3877c39a00..0b8c86096752 100644
5476 +--- a/include/linux/swapops.h
5477 ++++ b/include/linux/swapops.h
5478 +@@ -377,7 +377,8 @@ static inline void num_poisoned_pages_inc(void)
5479 + }
5480 + #endif
5481 +
5482 +-#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION)
5483 ++#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) || \
5484 ++ defined(CONFIG_DEVICE_PRIVATE)
5485 + static inline int non_swap_entry(swp_entry_t entry)
5486 + {
5487 + return swp_type(entry) >= MAX_SWAPFILES;
5488 +diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
5489 +index bee528135cf1..9f7f81117434 100644
5490 +--- a/include/net/ip6_route.h
5491 ++++ b/include/net/ip6_route.h
5492 +@@ -207,6 +207,7 @@ static inline bool ipv6_anycast_destination(const struct dst_entry *dst,
5493 +
5494 + return rt->rt6i_flags & RTF_ANYCAST ||
5495 + (rt->rt6i_dst.plen < 127 &&
5496 ++ !(rt->rt6i_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) &&
5497 + ipv6_addr_equal(&rt->rt6i_dst.addr, daddr));
5498 + }
5499 +
5500 +diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h
5501 +index cf5f3fff1f1a..fd7e4d1df9a1 100644
5502 +--- a/include/target/iscsi/iscsi_target_core.h
5503 ++++ b/include/target/iscsi/iscsi_target_core.h
5504 +@@ -673,7 +673,7 @@ struct iscsi_session {
5505 + atomic_t session_logout;
5506 + atomic_t session_reinstatement;
5507 + atomic_t session_stop_active;
5508 +- atomic_t sleep_on_sess_wait_comp;
5509 ++ atomic_t session_close;
5510 + /* connection list */
5511 + struct list_head sess_conn_list;
5512 + struct list_head cr_active_list;
5513 +diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
5514 +index 23cd84868cc3..fa7f97da5b76 100644
5515 +--- a/include/uapi/linux/swab.h
5516 ++++ b/include/uapi/linux/swab.h
5517 +@@ -4,6 +4,7 @@
5518 +
5519 + #include <linux/types.h>
5520 + #include <linux/compiler.h>
5521 ++#include <asm/bitsperlong.h>
5522 + #include <asm/swab.h>
5523 +
5524 + /*
5525 +@@ -132,6 +133,15 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)
5526 + __fswab64(x))
5527 + #endif
5528 +
5529 ++static __always_inline unsigned long __swab(const unsigned long y)
5530 ++{
5531 ++#if BITS_PER_LONG == 64
5532 ++ return __swab64(y);
5533 ++#else /* BITS_PER_LONG == 32 */
5534 ++ return __swab32(y);
5535 ++#endif
5536 ++}
5537 ++
5538 + /**
5539 + * __swahw32 - return a word-swapped 32-bit value
5540 + * @x: value to wordswap
5541 +diff --git a/kernel/cpu.c b/kernel/cpu.c
5542 +index 96c0a868232e..d8c77bfb6e7e 100644
5543 +--- a/kernel/cpu.c
5544 ++++ b/kernel/cpu.c
5545 +@@ -2089,10 +2089,8 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
5546 + */
5547 + cpuhp_offline_cpu_device(cpu);
5548 + }
5549 +- if (!ret) {
5550 ++ if (!ret)
5551 + cpu_smt_control = ctrlval;
5552 +- arch_smt_update();
5553 +- }
5554 + cpu_maps_update_done();
5555 + return ret;
5556 + }
5557 +@@ -2103,7 +2101,6 @@ int cpuhp_smt_enable(void)
5558 +
5559 + cpu_maps_update_begin();
5560 + cpu_smt_control = CPU_SMT_ENABLED;
5561 +- arch_smt_update();
5562 + for_each_present_cpu(cpu) {
5563 + /* Skip online CPUs and CPUs on offline nodes */
5564 + if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
5565 +diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
5566 +index b269ae16b10c..0d54f8256b9f 100644
5567 +--- a/kernel/irq/irqdomain.c
5568 ++++ b/kernel/irq/irqdomain.c
5569 +@@ -1372,6 +1372,11 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
5570 + unsigned int irq_base,
5571 + unsigned int nr_irqs, void *arg)
5572 + {
5573 ++ if (!domain->ops->alloc) {
5574 ++ pr_debug("domain->ops->alloc() is NULL\n");
5575 ++ return -ENOSYS;
5576 ++ }
5577 ++
5578 + return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
5579 + }
5580 +
5581 +@@ -1409,11 +1414,6 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
5582 + return -EINVAL;
5583 + }
5584 +
5585 +- if (!domain->ops->alloc) {
5586 +- pr_debug("domain->ops->alloc() is NULL\n");
5587 +- return -ENOSYS;
5588 +- }
5589 +-
5590 + if (realloc && irq_base >= 0) {
5591 + virq = irq_base;
5592 + } else {
5593 +diff --git a/kernel/kmod.c b/kernel/kmod.c
5594 +index bc6addd9152b..a2de58de6ab6 100644
5595 +--- a/kernel/kmod.c
5596 ++++ b/kernel/kmod.c
5597 +@@ -120,7 +120,7 @@ out:
5598 + * invoke it.
5599 + *
5600 + * If module auto-loading support is disabled then this function
5601 +- * becomes a no-operation.
5602 ++ * simply returns -ENOENT.
5603 + */
5604 + int __request_module(bool wait, const char *fmt, ...)
5605 + {
5606 +@@ -137,7 +137,7 @@ int __request_module(bool wait, const char *fmt, ...)
5607 + WARN_ON_ONCE(wait && current_is_async());
5608 +
5609 + if (!modprobe_path[0])
5610 +- return 0;
5611 ++ return -ENOENT;
5612 +
5613 + va_start(args, fmt);
5614 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
5615 +diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
5616 +index 90a3469a7a88..03e3ab61a2ed 100644
5617 +--- a/kernel/locking/lockdep.c
5618 ++++ b/kernel/locking/lockdep.c
5619 +@@ -1297,9 +1297,11 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
5620 + this.class = class;
5621 +
5622 + raw_local_irq_save(flags);
5623 ++ current->lockdep_recursion = 1;
5624 + arch_spin_lock(&lockdep_lock);
5625 + ret = __lockdep_count_forward_deps(&this);
5626 + arch_spin_unlock(&lockdep_lock);
5627 ++ current->lockdep_recursion = 0;
5628 + raw_local_irq_restore(flags);
5629 +
5630 + return ret;
5631 +@@ -1324,9 +1326,11 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
5632 + this.class = class;
5633 +
5634 + raw_local_irq_save(flags);
5635 ++ current->lockdep_recursion = 1;
5636 + arch_spin_lock(&lockdep_lock);
5637 + ret = __lockdep_count_backward_deps(&this);
5638 + arch_spin_unlock(&lockdep_lock);
5639 ++ current->lockdep_recursion = 0;
5640 + raw_local_irq_restore(flags);
5641 +
5642 + return ret;
5643 +diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
5644 +index 6dca260eeccf..032868be3259 100644
5645 +--- a/kernel/locking/locktorture.c
5646 ++++ b/kernel/locking/locktorture.c
5647 +@@ -723,10 +723,10 @@ static void __torture_print_stats(char *page,
5648 + if (statp[i].n_lock_fail)
5649 + fail = true;
5650 + sum += statp[i].n_lock_acquired;
5651 +- if (max < statp[i].n_lock_fail)
5652 +- max = statp[i].n_lock_fail;
5653 +- if (min > statp[i].n_lock_fail)
5654 +- min = statp[i].n_lock_fail;
5655 ++ if (max < statp[i].n_lock_acquired)
5656 ++ max = statp[i].n_lock_acquired;
5657 ++ if (min > statp[i].n_lock_acquired)
5658 ++ min = statp[i].n_lock_acquired;
5659 + }
5660 + page += sprintf(page,
5661 + "%s: Total: %lld Max/Min: %ld/%ld %s Fail: %d %s\n",
5662 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
5663 +index 268f560ec998..391d73a12ad7 100644
5664 +--- a/kernel/sched/sched.h
5665 ++++ b/kernel/sched/sched.h
5666 +@@ -89,7 +89,13 @@ static inline void cpu_load_update_active(struct rq *this_rq) { }
5667 + #ifdef CONFIG_64BIT
5668 + # define NICE_0_LOAD_SHIFT (SCHED_FIXEDPOINT_SHIFT + SCHED_FIXEDPOINT_SHIFT)
5669 + # define scale_load(w) ((w) << SCHED_FIXEDPOINT_SHIFT)
5670 +-# define scale_load_down(w) ((w) >> SCHED_FIXEDPOINT_SHIFT)
5671 ++# define scale_load_down(w) \
5672 ++({ \
5673 ++ unsigned long __w = (w); \
5674 ++ if (__w) \
5675 ++ __w = max(2UL, __w >> SCHED_FIXEDPOINT_SHIFT); \
5676 ++ __w; \
5677 ++})
5678 + #else
5679 + # define NICE_0_LOAD_SHIFT (SCHED_FIXEDPOINT_SHIFT)
5680 + # define scale_load(w) (w)
5681 +diff --git a/kernel/signal.c b/kernel/signal.c
5682 +index c066168f8854..deb36b35c30b 100644
5683 +--- a/kernel/signal.c
5684 ++++ b/kernel/signal.c
5685 +@@ -1675,7 +1675,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
5686 + * This is only possible if parent == real_parent.
5687 + * Check if it has changed security domain.
5688 + */
5689 +- if (tsk->parent_exec_id != tsk->parent->self_exec_id)
5690 ++ if (tsk->parent_exec_id != READ_ONCE(tsk->parent->self_exec_id))
5691 + sig = SIGCHLD;
5692 + }
5693 +
5694 +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
5695 +index 31e91efe243e..6fb5eb7b57dc 100644
5696 +--- a/kernel/trace/trace_events_trigger.c
5697 ++++ b/kernel/trace/trace_events_trigger.c
5698 +@@ -1075,14 +1075,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
5699 + struct event_trigger_data *data,
5700 + struct trace_event_file *file)
5701 + {
5702 +- int ret = register_trigger(glob, ops, data, file);
5703 +-
5704 +- if (ret > 0 && tracing_alloc_snapshot_instance(file->tr) != 0) {
5705 +- unregister_trigger(glob, ops, data, file);
5706 +- ret = 0;
5707 +- }
5708 ++ if (tracing_alloc_snapshot_instance(file->tr) != 0)
5709 ++ return 0;
5710 +
5711 +- return ret;
5712 ++ return register_trigger(glob, ops, data, file);
5713 + }
5714 +
5715 + static int
5716 +diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
5717 +index ea20274a105a..d66aed6e9c75 100644
5718 +--- a/kernel/trace/trace_kprobe.c
5719 ++++ b/kernel/trace/trace_kprobe.c
5720 +@@ -877,6 +877,8 @@ static int probes_seq_show(struct seq_file *m, void *v)
5721 + int i;
5722 +
5723 + seq_putc(m, trace_kprobe_is_return(tk) ? 'r' : 'p');
5724 ++ if (trace_kprobe_is_return(tk) && tk->rp.maxactive)
5725 ++ seq_printf(m, "%d", tk->rp.maxactive);
5726 + seq_printf(m, ":%s/%s", tk->tp.call.class->system,
5727 + trace_event_name(&tk->tp.call));
5728 +
5729 +diff --git a/lib/find_bit.c b/lib/find_bit.c
5730 +index 6ed74f78380c..883ef3755a1c 100644
5731 +--- a/lib/find_bit.c
5732 ++++ b/lib/find_bit.c
5733 +@@ -133,18 +133,6 @@ EXPORT_SYMBOL(find_last_bit);
5734 +
5735 + #ifdef __BIG_ENDIAN
5736 +
5737 +-/* include/linux/byteorder does not support "unsigned long" type */
5738 +-static inline unsigned long ext2_swab(const unsigned long y)
5739 +-{
5740 +-#if BITS_PER_LONG == 64
5741 +- return (unsigned long) __swab64((u64) y);
5742 +-#elif BITS_PER_LONG == 32
5743 +- return (unsigned long) __swab32((u32) y);
5744 +-#else
5745 +-#error BITS_PER_LONG not defined
5746 +-#endif
5747 +-}
5748 +-
5749 + #if !defined(find_next_bit_le) || !defined(find_next_zero_bit_le)
5750 + static unsigned long _find_next_bit_le(const unsigned long *addr,
5751 + unsigned long nbits, unsigned long start, unsigned long invert)
5752 +@@ -157,7 +145,7 @@ static unsigned long _find_next_bit_le(const unsigned long *addr,
5753 + tmp = addr[start / BITS_PER_LONG] ^ invert;
5754 +
5755 + /* Handle 1st word. */
5756 +- tmp &= ext2_swab(BITMAP_FIRST_WORD_MASK(start));
5757 ++ tmp &= swab(BITMAP_FIRST_WORD_MASK(start));
5758 + start = round_down(start, BITS_PER_LONG);
5759 +
5760 + while (!tmp) {
5761 +@@ -168,7 +156,7 @@ static unsigned long _find_next_bit_le(const unsigned long *addr,
5762 + tmp = addr[start / BITS_PER_LONG] ^ invert;
5763 + }
5764 +
5765 +- return min(start + __ffs(ext2_swab(tmp)), nbits);
5766 ++ return min(start + __ffs(swab(tmp)), nbits);
5767 + }
5768 + #endif
5769 +
5770 +diff --git a/lib/raid6/neon.uc b/lib/raid6/neon.uc
5771 +index d5242f544551..b7c68030da4f 100644
5772 +--- a/lib/raid6/neon.uc
5773 ++++ b/lib/raid6/neon.uc
5774 +@@ -28,7 +28,6 @@
5775 +
5776 + typedef uint8x16_t unative_t;
5777 +
5778 +-#define NBYTES(x) ((unative_t){x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x})
5779 + #define NSIZE sizeof(unative_t)
5780 +
5781 + /*
5782 +@@ -61,7 +60,7 @@ void raid6_neon$#_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
5783 + int d, z, z0;
5784 +
5785 + register unative_t wd$$, wq$$, wp$$, w1$$, w2$$;
5786 +- const unative_t x1d = NBYTES(0x1d);
5787 ++ const unative_t x1d = vdupq_n_u8(0x1d);
5788 +
5789 + z0 = disks - 3; /* Highest data disk */
5790 + p = dptr[z0+1]; /* XOR parity */
5791 +@@ -92,7 +91,7 @@ void raid6_neon$#_xor_syndrome_real(int disks, int start, int stop,
5792 + int d, z, z0;
5793 +
5794 + register unative_t wd$$, wq$$, wp$$, w1$$, w2$$;
5795 +- const unative_t x1d = NBYTES(0x1d);
5796 ++ const unative_t x1d = vdupq_n_u8(0x1d);
5797 +
5798 + z0 = stop; /* P/Q right side optimization */
5799 + p = dptr[disks-2]; /* XOR parity */
5800 +diff --git a/lib/raid6/recov_neon_inner.c b/lib/raid6/recov_neon_inner.c
5801 +index 8cd20c9f834a..7d00c31a6547 100644
5802 +--- a/lib/raid6/recov_neon_inner.c
5803 ++++ b/lib/raid6/recov_neon_inner.c
5804 +@@ -10,11 +10,6 @@
5805 +
5806 + #include <arm_neon.h>
5807 +
5808 +-static const uint8x16_t x0f = {
5809 +- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
5810 +- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
5811 +-};
5812 +-
5813 + #ifdef CONFIG_ARM
5814 + /*
5815 + * AArch32 does not provide this intrinsic natively because it does not
5816 +@@ -41,6 +36,7 @@ void __raid6_2data_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dp,
5817 + uint8x16_t pm1 = vld1q_u8(pbmul + 16);
5818 + uint8x16_t qm0 = vld1q_u8(qmul);
5819 + uint8x16_t qm1 = vld1q_u8(qmul + 16);
5820 ++ uint8x16_t x0f = vdupq_n_u8(0x0f);
5821 +
5822 + /*
5823 + * while ( bytes-- ) {
5824 +@@ -87,6 +83,7 @@ void __raid6_datap_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dq,
5825 + {
5826 + uint8x16_t qm0 = vld1q_u8(qmul);
5827 + uint8x16_t qm1 = vld1q_u8(qmul + 16);
5828 ++ uint8x16_t x0f = vdupq_n_u8(0x0f);
5829 +
5830 + /*
5831 + * while (bytes--) {
5832 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
5833 +index 6f71518a4558..08af4e3de6fb 100644
5834 +--- a/mm/page_alloc.c
5835 ++++ b/mm/page_alloc.c
5836 +@@ -4325,11 +4325,11 @@ refill:
5837 + /* Even if we own the page, we do not use atomic_set().
5838 + * This would break get_page_unless_zero() users.
5839 + */
5840 +- page_ref_add(page, size);
5841 ++ page_ref_add(page, PAGE_FRAG_CACHE_MAX_SIZE);
5842 +
5843 + /* reset page count bias and offset to start of new frag */
5844 + nc->pfmemalloc = page_is_pfmemalloc(page);
5845 +- nc->pagecnt_bias = size + 1;
5846 ++ nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1;
5847 + nc->offset = size;
5848 + }
5849 +
5850 +@@ -4345,10 +4345,10 @@ refill:
5851 + size = nc->size;
5852 + #endif
5853 + /* OK, page count is 0, we can safely set it */
5854 +- set_page_count(page, size + 1);
5855 ++ set_page_count(page, PAGE_FRAG_CACHE_MAX_SIZE + 1);
5856 +
5857 + /* reset page count bias and offset to start of new frag */
5858 +- nc->pagecnt_bias = size + 1;
5859 ++ nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1;
5860 + offset = size - fragsz;
5861 + }
5862 +
5863 +diff --git a/mm/slub.c b/mm/slub.c
5864 +index 958a8f7a3c25..3c1a16f03b2b 100644
5865 +--- a/mm/slub.c
5866 ++++ b/mm/slub.c
5867 +@@ -248,7 +248,7 @@ static inline void *freelist_ptr(const struct kmem_cache *s, void *ptr,
5868 + unsigned long ptr_addr)
5869 + {
5870 + #ifdef CONFIG_SLAB_FREELIST_HARDENED
5871 +- return (void *)((unsigned long)ptr ^ s->random ^ ptr_addr);
5872 ++ return (void *)((unsigned long)ptr ^ s->random ^ swab(ptr_addr));
5873 + #else
5874 + return ptr;
5875 + #endif
5876 +diff --git a/mm/vmalloc.c b/mm/vmalloc.c
5877 +index d00961ba0c42..88091fd704f4 100644
5878 +--- a/mm/vmalloc.c
5879 ++++ b/mm/vmalloc.c
5880 +@@ -1682,7 +1682,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
5881 + nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
5882 + array_size = (nr_pages * sizeof(struct page *));
5883 +
5884 +- area->nr_pages = nr_pages;
5885 + /* Please note that the recursion is strictly bounded. */
5886 + if (array_size > PAGE_SIZE) {
5887 + pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
5888 +@@ -1690,13 +1689,16 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
5889 + } else {
5890 + pages = kmalloc_node(array_size, nested_gfp, node);
5891 + }
5892 +- area->pages = pages;
5893 +- if (!area->pages) {
5894 ++
5895 ++ if (!pages) {
5896 + remove_vm_area(area->addr);
5897 + kfree(area);
5898 + return NULL;
5899 + }
5900 +
5901 ++ area->pages = pages;
5902 ++ area->nr_pages = nr_pages;
5903 ++
5904 + for (i = 0; i < area->nr_pages; i++) {
5905 + struct page *page;
5906 +
5907 +diff --git a/net/core/dev.c b/net/core/dev.c
5908 +index 36d926d2d5f0..4f32a3251b64 100644
5909 +--- a/net/core/dev.c
5910 ++++ b/net/core/dev.c
5911 +@@ -3575,7 +3575,8 @@ EXPORT_SYMBOL(netdev_max_backlog);
5912 +
5913 + int netdev_tstamp_prequeue __read_mostly = 1;
5914 + int netdev_budget __read_mostly = 300;
5915 +-unsigned int __read_mostly netdev_budget_usecs = 2000;
5916 ++/* Must be at least 2 jiffes to guarantee 1 jiffy timeout */
5917 ++unsigned int __read_mostly netdev_budget_usecs = 2 * USEC_PER_SEC / HZ;
5918 + int weight_p __read_mostly = 64; /* old backlog weight */
5919 + int dev_weight_rx_bias __read_mostly = 1; /* bias for backlog weight */
5920 + int dev_weight_tx_bias __read_mostly = 1; /* bias for output_queue quota */
5921 +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
5922 +index 7c479c1ffd77..cb15338cfda4 100644
5923 +--- a/net/core/rtnetlink.c
5924 ++++ b/net/core/rtnetlink.c
5925 +@@ -2424,7 +2424,7 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
5926 + }
5927 +
5928 + if (dev->rtnl_link_state == RTNL_LINK_INITIALIZED) {
5929 +- __dev_notify_flags(dev, old_flags, 0U);
5930 ++ __dev_notify_flags(dev, old_flags, (old_flags ^ dev->flags));
5931 + } else {
5932 + dev->rtnl_link_state = RTNL_LINK_INITIALIZED;
5933 + __dev_notify_flags(dev, old_flags, ~0U);
5934 +diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
5935 +index 5f5d9eafccf5..ea133857f19e 100644
5936 +--- a/net/dns_resolver/dns_key.c
5937 ++++ b/net/dns_resolver/dns_key.c
5938 +@@ -242,7 +242,7 @@ static void dns_resolver_describe(const struct key *key, struct seq_file *m)
5939 + * - the key's semaphore is read-locked
5940 + */
5941 + static long dns_resolver_read(const struct key *key,
5942 +- char __user *buffer, size_t buflen)
5943 ++ char *buffer, size_t buflen)
5944 + {
5945 + int err = PTR_ERR(key->payload.data[dns_key_error]);
5946 +
5947 +diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
5948 +index 37708dabebd1..606bc7fe5cc7 100644
5949 +--- a/net/hsr/hsr_netlink.c
5950 ++++ b/net/hsr/hsr_netlink.c
5951 +@@ -64,10 +64,16 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
5952 + else
5953 + multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]);
5954 +
5955 +- if (!data[IFLA_HSR_VERSION])
5956 ++ if (!data[IFLA_HSR_VERSION]) {
5957 + hsr_version = 0;
5958 +- else
5959 ++ } else {
5960 + hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]);
5961 ++ if (hsr_version > 1) {
5962 ++ NL_SET_ERR_MSG_MOD(extack,
5963 ++ "Only versions 0..1 are supported");
5964 ++ return -EINVAL;
5965 ++ }
5966 ++ }
5967 +
5968 + return hsr_dev_finalize(dev, link, multicast_spec, hsr_version);
5969 + }
5970 +diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
5971 +index 5f020c051af9..096a28f9720d 100644
5972 +--- a/net/ipv4/devinet.c
5973 ++++ b/net/ipv4/devinet.c
5974 +@@ -579,12 +579,15 @@ struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
5975 + return NULL;
5976 + }
5977 +
5978 +-static int ip_mc_config(struct sock *sk, bool join, const struct in_ifaddr *ifa)
5979 ++static int ip_mc_autojoin_config(struct net *net, bool join,
5980 ++ const struct in_ifaddr *ifa)
5981 + {
5982 ++#if defined(CONFIG_IP_MULTICAST)
5983 + struct ip_mreqn mreq = {
5984 + .imr_multiaddr.s_addr = ifa->ifa_address,
5985 + .imr_ifindex = ifa->ifa_dev->dev->ifindex,
5986 + };
5987 ++ struct sock *sk = net->ipv4.mc_autojoin_sk;
5988 + int ret;
5989 +
5990 + ASSERT_RTNL();
5991 +@@ -597,6 +600,9 @@ static int ip_mc_config(struct sock *sk, bool join, const struct in_ifaddr *ifa)
5992 + release_sock(sk);
5993 +
5994 + return ret;
5995 ++#else
5996 ++ return -EOPNOTSUPP;
5997 ++#endif
5998 + }
5999 +
6000 + static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
6001 +@@ -638,7 +644,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
6002 + continue;
6003 +
6004 + if (ipv4_is_multicast(ifa->ifa_address))
6005 +- ip_mc_config(net->ipv4.mc_autojoin_sk, false, ifa);
6006 ++ ip_mc_autojoin_config(net, false, ifa);
6007 + __inet_del_ifa(in_dev, ifap, 1, nlh, NETLINK_CB(skb).portid);
6008 + return 0;
6009 + }
6010 +@@ -896,8 +902,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
6011 + */
6012 + set_ifa_lifetime(ifa, valid_lft, prefered_lft);
6013 + if (ifa->ifa_flags & IFA_F_MCAUTOJOIN) {
6014 +- int ret = ip_mc_config(net->ipv4.mc_autojoin_sk,
6015 +- true, ifa);
6016 ++ int ret = ip_mc_autojoin_config(net, true, ifa);
6017 +
6018 + if (ret < 0) {
6019 + inet_free_ifa(ifa);
6020 +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
6021 +index 91490446ebb4..5b8d5bfeb7ac 100644
6022 +--- a/net/netfilter/nf_tables_api.c
6023 ++++ b/net/netfilter/nf_tables_api.c
6024 +@@ -3129,7 +3129,7 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
6025 + NFT_SET_INTERVAL | NFT_SET_TIMEOUT |
6026 + NFT_SET_MAP | NFT_SET_EVAL |
6027 + NFT_SET_OBJECT))
6028 +- return -EINVAL;
6029 ++ return -EOPNOTSUPP;
6030 + /* Only one of these operations is supported */
6031 + if ((flags & (NFT_SET_MAP | NFT_SET_OBJECT)) ==
6032 + (NFT_SET_MAP | NFT_SET_OBJECT))
6033 +@@ -3167,7 +3167,7 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
6034 + objtype = ntohl(nla_get_be32(nla[NFTA_SET_OBJ_TYPE]));
6035 + if (objtype == NFT_OBJECT_UNSPEC ||
6036 + objtype > NFT_OBJECT_MAX)
6037 +- return -EINVAL;
6038 ++ return -EOPNOTSUPP;
6039 + } else if (flags & NFT_SET_OBJECT)
6040 + return -EINVAL;
6041 + else
6042 +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
6043 +index 8d9a244f4534..944ce686bfe5 100644
6044 +--- a/net/qrtr/qrtr.c
6045 ++++ b/net/qrtr/qrtr.c
6046 +@@ -710,20 +710,21 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6047 +
6048 + node = NULL;
6049 + if (addr->sq_node == QRTR_NODE_BCAST) {
6050 +- enqueue_fn = qrtr_bcast_enqueue;
6051 +- if (addr->sq_port != QRTR_PORT_CTRL) {
6052 ++ if (addr->sq_port != QRTR_PORT_CTRL &&
6053 ++ qrtr_local_nid != QRTR_NODE_BCAST) {
6054 + release_sock(sk);
6055 + return -ENOTCONN;
6056 + }
6057 ++ enqueue_fn = qrtr_bcast_enqueue;
6058 + } else if (addr->sq_node == ipc->us.sq_node) {
6059 + enqueue_fn = qrtr_local_enqueue;
6060 + } else {
6061 +- enqueue_fn = qrtr_node_enqueue;
6062 + node = qrtr_node_lookup(addr->sq_node);
6063 + if (!node) {
6064 + release_sock(sk);
6065 + return -ECONNRESET;
6066 + }
6067 ++ enqueue_fn = qrtr_node_enqueue;
6068 + }
6069 +
6070 + plen = (len + 3) & ~3;
6071 +diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
6072 +index e7f6b8823eb6..ad9d1b21cb0b 100644
6073 +--- a/net/rxrpc/key.c
6074 ++++ b/net/rxrpc/key.c
6075 +@@ -35,7 +35,7 @@ static void rxrpc_free_preparse_s(struct key_preparsed_payload *);
6076 + static void rxrpc_destroy(struct key *);
6077 + static void rxrpc_destroy_s(struct key *);
6078 + static void rxrpc_describe(const struct key *, struct seq_file *);
6079 +-static long rxrpc_read(const struct key *, char __user *, size_t);
6080 ++static long rxrpc_read(const struct key *, char *, size_t);
6081 +
6082 + /*
6083 + * rxrpc defined keys take an arbitrary string as the description and an
6084 +@@ -1044,12 +1044,12 @@ EXPORT_SYMBOL(rxrpc_get_null_key);
6085 + * - this returns the result in XDR form
6086 + */
6087 + static long rxrpc_read(const struct key *key,
6088 +- char __user *buffer, size_t buflen)
6089 ++ char *buffer, size_t buflen)
6090 + {
6091 + const struct rxrpc_key_token *token;
6092 + const struct krb5_principal *princ;
6093 + size_t size;
6094 +- __be32 __user *xdr, *oldxdr;
6095 ++ __be32 *xdr, *oldxdr;
6096 + u32 cnlen, toksize, ntoks, tok, zero;
6097 + u16 toksizes[AFSTOKEN_MAX];
6098 + int loop;
6099 +@@ -1126,30 +1126,25 @@ static long rxrpc_read(const struct key *key,
6100 + if (!buffer || buflen < size)
6101 + return size;
6102 +
6103 +- xdr = (__be32 __user *) buffer;
6104 ++ xdr = (__be32 *)buffer;
6105 + zero = 0;
6106 + #define ENCODE(x) \
6107 + do { \
6108 +- __be32 y = htonl(x); \
6109 +- if (put_user(y, xdr++) < 0) \
6110 +- goto fault; \
6111 ++ *xdr++ = htonl(x); \
6112 + } while(0)
6113 + #define ENCODE_DATA(l, s) \
6114 + do { \
6115 + u32 _l = (l); \
6116 + ENCODE(l); \
6117 +- if (copy_to_user(xdr, (s), _l) != 0) \
6118 +- goto fault; \
6119 +- if (_l & 3 && \
6120 +- copy_to_user((u8 __user *)xdr + _l, &zero, 4 - (_l & 3)) != 0) \
6121 +- goto fault; \
6122 ++ memcpy(xdr, (s), _l); \
6123 ++ if (_l & 3) \
6124 ++ memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \
6125 + xdr += (_l + 3) >> 2; \
6126 + } while(0)
6127 + #define ENCODE64(x) \
6128 + do { \
6129 + __be64 y = cpu_to_be64(x); \
6130 +- if (copy_to_user(xdr, &y, 8) != 0) \
6131 +- goto fault; \
6132 ++ memcpy(xdr, &y, 8); \
6133 + xdr += 8 >> 2; \
6134 + } while(0)
6135 + #define ENCODE_STR(s) \
6136 +@@ -1240,8 +1235,4 @@ static long rxrpc_read(const struct key *key,
6137 + ASSERTCMP((char __user *) xdr - buffer, ==, size);
6138 + _leave(" = %zu", size);
6139 + return size;
6140 +-
6141 +-fault:
6142 +- _leave(" = -EFAULT");
6143 +- return -EFAULT;
6144 + }
6145 +diff --git a/security/keys/big_key.c b/security/keys/big_key.c
6146 +index 929e14978c42..1957275ad2af 100644
6147 +--- a/security/keys/big_key.c
6148 ++++ b/security/keys/big_key.c
6149 +@@ -22,6 +22,13 @@
6150 + #include <keys/big_key-type.h>
6151 + #include <crypto/aead.h>
6152 +
6153 ++struct big_key_buf {
6154 ++ unsigned int nr_pages;
6155 ++ void *virt;
6156 ++ struct scatterlist *sg;
6157 ++ struct page *pages[];
6158 ++};
6159 ++
6160 + /*
6161 + * Layout of key payload words.
6162 + */
6163 +@@ -91,10 +98,9 @@ static DEFINE_MUTEX(big_key_aead_lock);
6164 + /*
6165 + * Encrypt/decrypt big_key data
6166 + */
6167 +-static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key)
6168 ++static int big_key_crypt(enum big_key_op op, struct big_key_buf *buf, size_t datalen, u8 *key)
6169 + {
6170 + int ret;
6171 +- struct scatterlist sgio;
6172 + struct aead_request *aead_req;
6173 + /* We always use a zero nonce. The reason we can get away with this is
6174 + * because we're using a different randomly generated key for every
6175 +@@ -109,8 +115,7 @@ static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key)
6176 + return -ENOMEM;
6177 +
6178 + memset(zero_nonce, 0, sizeof(zero_nonce));
6179 +- sg_init_one(&sgio, data, datalen + (op == BIG_KEY_ENC ? ENC_AUTHTAG_SIZE : 0));
6180 +- aead_request_set_crypt(aead_req, &sgio, &sgio, datalen, zero_nonce);
6181 ++ aead_request_set_crypt(aead_req, buf->sg, buf->sg, datalen, zero_nonce);
6182 + aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);
6183 + aead_request_set_ad(aead_req, 0);
6184 +
6185 +@@ -129,22 +134,82 @@ error:
6186 + return ret;
6187 + }
6188 +
6189 ++/*
6190 ++ * Free up the buffer.
6191 ++ */
6192 ++static void big_key_free_buffer(struct big_key_buf *buf)
6193 ++{
6194 ++ unsigned int i;
6195 ++
6196 ++ if (buf->virt) {
6197 ++ memset(buf->virt, 0, buf->nr_pages * PAGE_SIZE);
6198 ++ vunmap(buf->virt);
6199 ++ }
6200 ++
6201 ++ for (i = 0; i < buf->nr_pages; i++)
6202 ++ if (buf->pages[i])
6203 ++ __free_page(buf->pages[i]);
6204 ++
6205 ++ kfree(buf);
6206 ++}
6207 ++
6208 ++/*
6209 ++ * Allocate a buffer consisting of a set of pages with a virtual mapping
6210 ++ * applied over them.
6211 ++ */
6212 ++static void *big_key_alloc_buffer(size_t len)
6213 ++{
6214 ++ struct big_key_buf *buf;
6215 ++ unsigned int npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
6216 ++ unsigned int i, l;
6217 ++
6218 ++ buf = kzalloc(sizeof(struct big_key_buf) +
6219 ++ sizeof(struct page) * npg +
6220 ++ sizeof(struct scatterlist) * npg,
6221 ++ GFP_KERNEL);
6222 ++ if (!buf)
6223 ++ return NULL;
6224 ++
6225 ++ buf->nr_pages = npg;
6226 ++ buf->sg = (void *)(buf->pages + npg);
6227 ++ sg_init_table(buf->sg, npg);
6228 ++
6229 ++ for (i = 0; i < buf->nr_pages; i++) {
6230 ++ buf->pages[i] = alloc_page(GFP_KERNEL);
6231 ++ if (!buf->pages[i])
6232 ++ goto nomem;
6233 ++
6234 ++ l = min_t(size_t, len, PAGE_SIZE);
6235 ++ sg_set_page(&buf->sg[i], buf->pages[i], l, 0);
6236 ++ len -= l;
6237 ++ }
6238 ++
6239 ++ buf->virt = vmap(buf->pages, buf->nr_pages, VM_MAP, PAGE_KERNEL);
6240 ++ if (!buf->virt)
6241 ++ goto nomem;
6242 ++
6243 ++ return buf;
6244 ++
6245 ++nomem:
6246 ++ big_key_free_buffer(buf);
6247 ++ return NULL;
6248 ++}
6249 ++
6250 + /*
6251 + * Preparse a big key
6252 + */
6253 + int big_key_preparse(struct key_preparsed_payload *prep)
6254 + {
6255 ++ struct big_key_buf *buf;
6256 + struct path *path = (struct path *)&prep->payload.data[big_key_path];
6257 + struct file *file;
6258 + u8 *enckey;
6259 +- u8 *data = NULL;
6260 + ssize_t written;
6261 +- size_t datalen = prep->datalen;
6262 ++ size_t datalen = prep->datalen, enclen = datalen + ENC_AUTHTAG_SIZE;
6263 + int ret;
6264 +
6265 +- ret = -EINVAL;
6266 + if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data)
6267 +- goto error;
6268 ++ return -EINVAL;
6269 +
6270 + /* Set an arbitrary quota */
6271 + prep->quotalen = 16;
6272 +@@ -157,13 +222,12 @@ int big_key_preparse(struct key_preparsed_payload *prep)
6273 + *
6274 + * File content is stored encrypted with randomly generated key.
6275 + */
6276 +- size_t enclen = datalen + ENC_AUTHTAG_SIZE;
6277 + loff_t pos = 0;
6278 +
6279 +- data = kmalloc(enclen, GFP_KERNEL);
6280 +- if (!data)
6281 ++ buf = big_key_alloc_buffer(enclen);
6282 ++ if (!buf)
6283 + return -ENOMEM;
6284 +- memcpy(data, prep->data, datalen);
6285 ++ memcpy(buf->virt, prep->data, datalen);
6286 +
6287 + /* generate random key */
6288 + enckey = kmalloc(ENC_KEY_SIZE, GFP_KERNEL);
6289 +@@ -176,7 +240,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
6290 + goto err_enckey;
6291 +
6292 + /* encrypt aligned data */
6293 +- ret = big_key_crypt(BIG_KEY_ENC, data, datalen, enckey);
6294 ++ ret = big_key_crypt(BIG_KEY_ENC, buf, datalen, enckey);
6295 + if (ret)
6296 + goto err_enckey;
6297 +
6298 +@@ -187,7 +251,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
6299 + goto err_enckey;
6300 + }
6301 +
6302 +- written = kernel_write(file, data, enclen, &pos);
6303 ++ written = kernel_write(file, buf->virt, enclen, &pos);
6304 + if (written != enclen) {
6305 + ret = written;
6306 + if (written >= 0)
6307 +@@ -202,7 +266,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
6308 + *path = file->f_path;
6309 + path_get(path);
6310 + fput(file);
6311 +- kzfree(data);
6312 ++ big_key_free_buffer(buf);
6313 + } else {
6314 + /* Just store the data in a buffer */
6315 + void *data = kmalloc(datalen, GFP_KERNEL);
6316 +@@ -220,7 +284,7 @@ err_fput:
6317 + err_enckey:
6318 + kzfree(enckey);
6319 + error:
6320 +- kzfree(data);
6321 ++ big_key_free_buffer(buf);
6322 + return ret;
6323 + }
6324 +
6325 +@@ -289,7 +353,7 @@ void big_key_describe(const struct key *key, struct seq_file *m)
6326 + * read the key data
6327 + * - the key's semaphore is read-locked
6328 + */
6329 +-long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
6330 ++long big_key_read(const struct key *key, char *buffer, size_t buflen)
6331 + {
6332 + size_t datalen = (size_t)key->payload.data[big_key_len];
6333 + long ret;
6334 +@@ -298,15 +362,15 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
6335 + return datalen;
6336 +
6337 + if (datalen > BIG_KEY_FILE_THRESHOLD) {
6338 ++ struct big_key_buf *buf;
6339 + struct path *path = (struct path *)&key->payload.data[big_key_path];
6340 + struct file *file;
6341 +- u8 *data;
6342 + u8 *enckey = (u8 *)key->payload.data[big_key_data];
6343 + size_t enclen = datalen + ENC_AUTHTAG_SIZE;
6344 + loff_t pos = 0;
6345 +
6346 +- data = kmalloc(enclen, GFP_KERNEL);
6347 +- if (!data)
6348 ++ buf = big_key_alloc_buffer(enclen);
6349 ++ if (!buf)
6350 + return -ENOMEM;
6351 +
6352 + file = dentry_open(path, O_RDONLY, current_cred());
6353 +@@ -316,31 +380,28 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
6354 + }
6355 +
6356 + /* read file to kernel and decrypt */
6357 +- ret = kernel_read(file, data, enclen, &pos);
6358 ++ ret = kernel_read(file, buf->virt, enclen, &pos);
6359 + if (ret >= 0 && ret != enclen) {
6360 + ret = -EIO;
6361 + goto err_fput;
6362 + }
6363 +
6364 +- ret = big_key_crypt(BIG_KEY_DEC, data, enclen, enckey);
6365 ++ ret = big_key_crypt(BIG_KEY_DEC, buf, enclen, enckey);
6366 + if (ret)
6367 + goto err_fput;
6368 +
6369 + ret = datalen;
6370 +
6371 +- /* copy decrypted data to user */
6372 +- if (copy_to_user(buffer, data, datalen) != 0)
6373 +- ret = -EFAULT;
6374 ++ /* copy out decrypted data */
6375 ++ memcpy(buffer, buf->virt, datalen);
6376 +
6377 + err_fput:
6378 + fput(file);
6379 + error:
6380 +- kzfree(data);
6381 ++ big_key_free_buffer(buf);
6382 + } else {
6383 + ret = datalen;
6384 +- if (copy_to_user(buffer, key->payload.data[big_key_data],
6385 +- datalen) != 0)
6386 +- ret = -EFAULT;
6387 ++ memcpy(buffer, key->payload.data[big_key_data], datalen);
6388 + }
6389 +
6390 + return ret;
6391 +diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
6392 +index d92cbf9687c3..571f6d486838 100644
6393 +--- a/security/keys/encrypted-keys/encrypted.c
6394 ++++ b/security/keys/encrypted-keys/encrypted.c
6395 +@@ -895,14 +895,14 @@ out:
6396 + }
6397 +
6398 + /*
6399 +- * encrypted_read - format and copy the encrypted data to userspace
6400 ++ * encrypted_read - format and copy out the encrypted data
6401 + *
6402 + * The resulting datablob format is:
6403 + * <master-key name> <decrypted data length> <encrypted iv> <encrypted data>
6404 + *
6405 + * On success, return to userspace the encrypted key datablob size.
6406 + */
6407 +-static long encrypted_read(const struct key *key, char __user *buffer,
6408 ++static long encrypted_read(const struct key *key, char *buffer,
6409 + size_t buflen)
6410 + {
6411 + struct encrypted_key_payload *epayload;
6412 +@@ -950,8 +950,7 @@ static long encrypted_read(const struct key *key, char __user *buffer,
6413 + key_put(mkey);
6414 + memzero_explicit(derived_key, sizeof(derived_key));
6415 +
6416 +- if (copy_to_user(buffer, ascii_buf, asciiblob_len) != 0)
6417 +- ret = -EFAULT;
6418 ++ memcpy(buffer, ascii_buf, asciiblob_len);
6419 + kzfree(ascii_buf);
6420 +
6421 + return asciiblob_len;
6422 +diff --git a/security/keys/key.c b/security/keys/key.c
6423 +index 17244f5f54c6..5f4cb271464a 100644
6424 +--- a/security/keys/key.c
6425 ++++ b/security/keys/key.c
6426 +@@ -383,7 +383,7 @@ int key_payload_reserve(struct key *key, size_t datalen)
6427 + spin_lock(&key->user->lock);
6428 +
6429 + if (delta > 0 &&
6430 +- (key->user->qnbytes + delta >= maxbytes ||
6431 ++ (key->user->qnbytes + delta > maxbytes ||
6432 + key->user->qnbytes + delta < key->user->qnbytes)) {
6433 + ret = -EDQUOT;
6434 + }
6435 +diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
6436 +index ca31af186abd..4b6a084e323b 100644
6437 +--- a/security/keys/keyctl.c
6438 ++++ b/security/keys/keyctl.c
6439 +@@ -742,6 +742,21 @@ error:
6440 + return ret;
6441 + }
6442 +
6443 ++/*
6444 ++ * Call the read method
6445 ++ */
6446 ++static long __keyctl_read_key(struct key *key, char *buffer, size_t buflen)
6447 ++{
6448 ++ long ret;
6449 ++
6450 ++ down_read(&key->sem);
6451 ++ ret = key_validate(key);
6452 ++ if (ret == 0)
6453 ++ ret = key->type->read(key, buffer, buflen);
6454 ++ up_read(&key->sem);
6455 ++ return ret;
6456 ++}
6457 ++
6458 + /*
6459 + * Read a key's payload.
6460 + *
6461 +@@ -757,26 +772,27 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
6462 + struct key *key;
6463 + key_ref_t key_ref;
6464 + long ret;
6465 ++ char *key_data;
6466 +
6467 + /* find the key first */
6468 + key_ref = lookup_user_key(keyid, 0, 0);
6469 + if (IS_ERR(key_ref)) {
6470 + ret = -ENOKEY;
6471 +- goto error;
6472 ++ goto out;
6473 + }
6474 +
6475 + key = key_ref_to_ptr(key_ref);
6476 +
6477 + ret = key_read_state(key);
6478 + if (ret < 0)
6479 +- goto error2; /* Negatively instantiated */
6480 ++ goto key_put_out; /* Negatively instantiated */
6481 +
6482 + /* see if we can read it directly */
6483 + ret = key_permission(key_ref, KEY_NEED_READ);
6484 + if (ret == 0)
6485 + goto can_read_key;
6486 + if (ret != -EACCES)
6487 +- goto error2;
6488 ++ goto key_put_out;
6489 +
6490 + /* we can't; see if it's searchable from this process's keyrings
6491 + * - we automatically take account of the fact that it may be
6492 +@@ -784,26 +800,51 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
6493 + */
6494 + if (!is_key_possessed(key_ref)) {
6495 + ret = -EACCES;
6496 +- goto error2;
6497 ++ goto key_put_out;
6498 + }
6499 +
6500 + /* the key is probably readable - now try to read it */
6501 + can_read_key:
6502 +- ret = -EOPNOTSUPP;
6503 +- if (key->type->read) {
6504 +- /* Read the data with the semaphore held (since we might sleep)
6505 +- * to protect against the key being updated or revoked.
6506 +- */
6507 +- down_read(&key->sem);
6508 +- ret = key_validate(key);
6509 +- if (ret == 0)
6510 +- ret = key->type->read(key, buffer, buflen);
6511 +- up_read(&key->sem);
6512 ++ if (!key->type->read) {
6513 ++ ret = -EOPNOTSUPP;
6514 ++ goto key_put_out;
6515 + }
6516 +
6517 +-error2:
6518 ++ if (!buffer || !buflen) {
6519 ++ /* Get the key length from the read method */
6520 ++ ret = __keyctl_read_key(key, NULL, 0);
6521 ++ goto key_put_out;
6522 ++ }
6523 ++
6524 ++ /*
6525 ++ * Read the data with the semaphore held (since we might sleep)
6526 ++ * to protect against the key being updated or revoked.
6527 ++ *
6528 ++ * Allocating a temporary buffer to hold the keys before
6529 ++ * transferring them to user buffer to avoid potential
6530 ++ * deadlock involving page fault and mmap_sem.
6531 ++ */
6532 ++ key_data = kmalloc(buflen, GFP_KERNEL);
6533 ++
6534 ++ if (!key_data) {
6535 ++ ret = -ENOMEM;
6536 ++ goto key_put_out;
6537 ++ }
6538 ++ ret = __keyctl_read_key(key, key_data, buflen);
6539 ++
6540 ++ /*
6541 ++ * Read methods will just return the required length without
6542 ++ * any copying if the provided length isn't large enough.
6543 ++ */
6544 ++ if (ret > 0 && ret <= buflen) {
6545 ++ if (copy_to_user(buffer, key_data, ret))
6546 ++ ret = -EFAULT;
6547 ++ }
6548 ++ kzfree(key_data);
6549 ++
6550 ++key_put_out:
6551 + key_put(key);
6552 +-error:
6553 ++out:
6554 + return ret;
6555 + }
6556 +
6557 +@@ -882,8 +923,8 @@ long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group)
6558 + key_quota_root_maxbytes : key_quota_maxbytes;
6559 +
6560 + spin_lock(&newowner->lock);
6561 +- if (newowner->qnkeys + 1 >= maxkeys ||
6562 +- newowner->qnbytes + key->quotalen >= maxbytes ||
6563 ++ if (newowner->qnkeys + 1 > maxkeys ||
6564 ++ newowner->qnbytes + key->quotalen > maxbytes ||
6565 + newowner->qnbytes + key->quotalen <
6566 + newowner->qnbytes)
6567 + goto quota_overrun;
6568 +diff --git a/security/keys/keyring.c b/security/keys/keyring.c
6569 +index 359b9cba3d0d..f7cf371bcd2a 100644
6570 +--- a/security/keys/keyring.c
6571 ++++ b/security/keys/keyring.c
6572 +@@ -432,7 +432,6 @@ static int keyring_read_iterator(const void *object, void *data)
6573 + {
6574 + struct keyring_read_iterator_context *ctx = data;
6575 + const struct key *key = keyring_ptr_to_key(object);
6576 +- int ret;
6577 +
6578 + kenter("{%s,%d},,{%zu/%zu}",
6579 + key->type->name, key->serial, ctx->count, ctx->buflen);
6580 +@@ -440,10 +439,7 @@ static int keyring_read_iterator(const void *object, void *data)
6581 + if (ctx->count >= ctx->buflen)
6582 + return 1;
6583 +
6584 +- ret = put_user(key->serial, ctx->buffer);
6585 +- if (ret < 0)
6586 +- return ret;
6587 +- ctx->buffer++;
6588 ++ *ctx->buffer++ = key->serial;
6589 + ctx->count += sizeof(key->serial);
6590 + return 0;
6591 + }
6592 +diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
6593 +index 1d34b2a5f485..13ac3b1e57da 100644
6594 +--- a/security/keys/request_key_auth.c
6595 ++++ b/security/keys/request_key_auth.c
6596 +@@ -27,7 +27,7 @@ static int request_key_auth_instantiate(struct key *,
6597 + static void request_key_auth_describe(const struct key *, struct seq_file *);
6598 + static void request_key_auth_revoke(struct key *);
6599 + static void request_key_auth_destroy(struct key *);
6600 +-static long request_key_auth_read(const struct key *, char __user *, size_t);
6601 ++static long request_key_auth_read(const struct key *, char *, size_t);
6602 +
6603 + /*
6604 + * The request-key authorisation key type definition.
6605 +@@ -85,7 +85,7 @@ static void request_key_auth_describe(const struct key *key,
6606 + * - the key's semaphore is read-locked
6607 + */
6608 + static long request_key_auth_read(const struct key *key,
6609 +- char __user *buffer, size_t buflen)
6610 ++ char *buffer, size_t buflen)
6611 + {
6612 + struct request_key_auth *rka = get_request_key_auth(key);
6613 + size_t datalen;
6614 +@@ -102,8 +102,7 @@ static long request_key_auth_read(const struct key *key,
6615 + if (buflen > datalen)
6616 + buflen = datalen;
6617 +
6618 +- if (copy_to_user(buffer, rka->callout_info, buflen) != 0)
6619 +- ret = -EFAULT;
6620 ++ memcpy(buffer, rka->callout_info, buflen);
6621 + }
6622 +
6623 + return ret;
6624 +diff --git a/security/keys/trusted.c b/security/keys/trusted.c
6625 +index 98aa89ff7bfd..01e8544f79a5 100644
6626 +--- a/security/keys/trusted.c
6627 ++++ b/security/keys/trusted.c
6628 +@@ -1136,11 +1136,10 @@ out:
6629 + * trusted_read - copy the sealed blob data to userspace in hex.
6630 + * On success, return to userspace the trusted key datablob size.
6631 + */
6632 +-static long trusted_read(const struct key *key, char __user *buffer,
6633 ++static long trusted_read(const struct key *key, char *buffer,
6634 + size_t buflen)
6635 + {
6636 + const struct trusted_key_payload *p;
6637 +- char *ascii_buf;
6638 + char *bufp;
6639 + int i;
6640 +
6641 +@@ -1149,18 +1148,9 @@ static long trusted_read(const struct key *key, char __user *buffer,
6642 + return -EINVAL;
6643 +
6644 + if (buffer && buflen >= 2 * p->blob_len) {
6645 +- ascii_buf = kmalloc(2 * p->blob_len, GFP_KERNEL);
6646 +- if (!ascii_buf)
6647 +- return -ENOMEM;
6648 +-
6649 +- bufp = ascii_buf;
6650 ++ bufp = buffer;
6651 + for (i = 0; i < p->blob_len; i++)
6652 + bufp = hex_byte_pack(bufp, p->blob[i]);
6653 +- if (copy_to_user(buffer, ascii_buf, 2 * p->blob_len) != 0) {
6654 +- kzfree(ascii_buf);
6655 +- return -EFAULT;
6656 +- }
6657 +- kzfree(ascii_buf);
6658 + }
6659 + return 2 * p->blob_len;
6660 + }
6661 +diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c
6662 +index 9f558bedba23..0e723b676aef 100644
6663 +--- a/security/keys/user_defined.c
6664 ++++ b/security/keys/user_defined.c
6665 +@@ -172,7 +172,7 @@ EXPORT_SYMBOL_GPL(user_describe);
6666 + * read the key data
6667 + * - the key's semaphore is read-locked
6668 + */
6669 +-long user_read(const struct key *key, char __user *buffer, size_t buflen)
6670 ++long user_read(const struct key *key, char *buffer, size_t buflen)
6671 + {
6672 + const struct user_key_payload *upayload;
6673 + long ret;
6674 +@@ -185,8 +185,7 @@ long user_read(const struct key *key, char __user *buffer, size_t buflen)
6675 + if (buflen > upayload->datalen)
6676 + buflen = upayload->datalen;
6677 +
6678 +- if (copy_to_user(buffer, upayload->data, buflen) != 0)
6679 +- ret = -EFAULT;
6680 ++ memcpy(buffer, upayload->data, buflen);
6681 + }
6682 +
6683 + return ret;
6684 +diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
6685 +index 40d2d39151bf..3ecc070738e8 100644
6686 +--- a/sound/core/oss/pcm_plugin.c
6687 ++++ b/sound/core/oss/pcm_plugin.c
6688 +@@ -196,7 +196,9 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
6689 + return 0;
6690 + }
6691 +
6692 +-snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames)
6693 ++static snd_pcm_sframes_t plug_client_size(struct snd_pcm_substream *plug,
6694 ++ snd_pcm_uframes_t drv_frames,
6695 ++ bool check_size)
6696 + {
6697 + struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
6698 + int stream;
6699 +@@ -209,7 +211,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
6700 + if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
6701 + plugin = snd_pcm_plug_last(plug);
6702 + while (plugin && drv_frames > 0) {
6703 +- if (drv_frames > plugin->buf_frames)
6704 ++ if (check_size && drv_frames > plugin->buf_frames)
6705 + drv_frames = plugin->buf_frames;
6706 + plugin_prev = plugin->prev;
6707 + if (plugin->src_frames)
6708 +@@ -222,7 +224,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
6709 + plugin_next = plugin->next;
6710 + if (plugin->dst_frames)
6711 + drv_frames = plugin->dst_frames(plugin, drv_frames);
6712 +- if (drv_frames > plugin->buf_frames)
6713 ++ if (check_size && drv_frames > plugin->buf_frames)
6714 + drv_frames = plugin->buf_frames;
6715 + plugin = plugin_next;
6716 + }
6717 +@@ -231,7 +233,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
6718 + return drv_frames;
6719 + }
6720 +
6721 +-snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t clt_frames)
6722 ++static snd_pcm_sframes_t plug_slave_size(struct snd_pcm_substream *plug,
6723 ++ snd_pcm_uframes_t clt_frames,
6724 ++ bool check_size)
6725 + {
6726 + struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
6727 + snd_pcm_sframes_t frames;
6728 +@@ -252,14 +256,14 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
6729 + if (frames < 0)
6730 + return frames;
6731 + }
6732 +- if (frames > plugin->buf_frames)
6733 ++ if (check_size && frames > plugin->buf_frames)
6734 + frames = plugin->buf_frames;
6735 + plugin = plugin_next;
6736 + }
6737 + } else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
6738 + plugin = snd_pcm_plug_last(plug);
6739 + while (plugin) {
6740 +- if (frames > plugin->buf_frames)
6741 ++ if (check_size && frames > plugin->buf_frames)
6742 + frames = plugin->buf_frames;
6743 + plugin_prev = plugin->prev;
6744 + if (plugin->src_frames) {
6745 +@@ -274,6 +278,18 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
6746 + return frames;
6747 + }
6748 +
6749 ++snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug,
6750 ++ snd_pcm_uframes_t drv_frames)
6751 ++{
6752 ++ return plug_client_size(plug, drv_frames, false);
6753 ++}
6754 ++
6755 ++snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug,
6756 ++ snd_pcm_uframes_t clt_frames)
6757 ++{
6758 ++ return plug_slave_size(plug, clt_frames, false);
6759 ++}
6760 ++
6761 + static int snd_pcm_plug_formats(const struct snd_mask *mask,
6762 + snd_pcm_format_t format)
6763 + {
6764 +@@ -629,7 +645,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
6765 + src_channels = dst_channels;
6766 + plugin = next;
6767 + }
6768 +- return snd_pcm_plug_client_size(plug, frames);
6769 ++ return plug_client_size(plug, frames, true);
6770 + }
6771 +
6772 + snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, struct snd_pcm_plugin_channel *dst_channels_final, snd_pcm_uframes_t size)
6773 +@@ -639,7 +655,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str
6774 + snd_pcm_sframes_t frames = size;
6775 + int err;
6776 +
6777 +- frames = snd_pcm_plug_slave_size(plug, frames);
6778 ++ frames = plug_slave_size(plug, frames, true);
6779 + if (frames < 0)
6780 + return frames;
6781 +
6782 +diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
6783 +index c397e7da0eac..7ccfb09535e1 100644
6784 +--- a/sound/pci/hda/hda_beep.c
6785 ++++ b/sound/pci/hda/hda_beep.c
6786 +@@ -310,8 +310,12 @@ int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
6787 + {
6788 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6789 + struct hda_beep *beep = codec->beep;
6790 ++ int chs = get_amp_channels(kcontrol);
6791 ++
6792 + if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) {
6793 +- ucontrol->value.integer.value[0] =
6794 ++ if (chs & 1)
6795 ++ ucontrol->value.integer.value[0] = beep->enabled;
6796 ++ if (chs & 2)
6797 + ucontrol->value.integer.value[1] = beep->enabled;
6798 + return 0;
6799 + }
6800 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
6801 +index a6f7561e7bb9..7d65fe31c825 100644
6802 +--- a/sound/pci/hda/hda_codec.c
6803 ++++ b/sound/pci/hda/hda_codec.c
6804 +@@ -942,6 +942,7 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
6805 +
6806 + /* power-up all before initialization */
6807 + hda_set_power_state(codec, AC_PWRST_D0);
6808 ++ codec->core.dev.power.power_state = PMSG_ON;
6809 +
6810 + snd_hda_codec_proc_new(codec);
6811 +
6812 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
6813 +index 890793ad85ca..d392c1ec0b28 100644
6814 +--- a/sound/pci/hda/hda_intel.c
6815 ++++ b/sound/pci/hda/hda_intel.c
6816 +@@ -2034,24 +2034,15 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
6817 + {
6818 + struct snd_card *card = context;
6819 + struct azx *chip = card->private_data;
6820 +- struct pci_dev *pci = chip->pci;
6821 +-
6822 +- if (!fw) {
6823 +- dev_err(card->dev, "Cannot load firmware, aborting\n");
6824 +- goto error;
6825 +- }
6826 +
6827 +- chip->fw = fw;
6828 ++ if (fw)
6829 ++ chip->fw = fw;
6830 ++ else
6831 ++ dev_err(card->dev, "Cannot load firmware, continue without patching\n");
6832 + if (!chip->disabled) {
6833 + /* continue probing */
6834 +- if (azx_probe_continue(chip))
6835 +- goto error;
6836 ++ azx_probe_continue(chip);
6837 + }
6838 +- return; /* OK */
6839 +-
6840 +- error:
6841 +- snd_card_free(card);
6842 +- pci_set_drvdata(pci, NULL);
6843 + }
6844 + #endif
6845 +
6846 +@@ -2177,6 +2168,17 @@ static const struct hdac_io_ops pci_hda_io_ops = {
6847 + .dma_free_pages = dma_free_pages,
6848 + };
6849 +
6850 ++/* Blacklist for skipping the whole probe:
6851 ++ * some HD-audio PCI entries are exposed without any codecs, and such devices
6852 ++ * should be ignored from the beginning.
6853 ++ */
6854 ++static const struct snd_pci_quirk driver_blacklist[] = {
6855 ++ SND_PCI_QUIRK(0x1043, 0x874f, "ASUS ROG Zenith II / Strix", 0),
6856 ++ SND_PCI_QUIRK(0x1462, 0xcb59, "MSI TRX40 Creator", 0),
6857 ++ SND_PCI_QUIRK(0x1462, 0xcb60, "MSI TRX40", 0),
6858 ++ {}
6859 ++};
6860 ++
6861 + static const struct hda_controller_ops pci_hda_ops = {
6862 + .disable_msi_reset_irq = disable_msi_reset_irq,
6863 + .substream_alloc_pages = substream_alloc_pages,
6864 +@@ -2196,6 +2198,11 @@ static int azx_probe(struct pci_dev *pci,
6865 + bool schedule_probe;
6866 + int err;
6867 +
6868 ++ if (snd_pci_quirk_lookup(pci, driver_blacklist)) {
6869 ++ dev_info(&pci->dev, "Skipping the blacklisted device\n");
6870 ++ return -ENODEV;
6871 ++ }
6872 ++
6873 + if (dev >= SNDRV_CARDS)
6874 + return -ENODEV;
6875 + if (!enable[dev]) {
6876 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
6877 +index b500dad33ea9..3fded87817c6 100644
6878 +--- a/sound/pci/hda/patch_realtek.c
6879 ++++ b/sound/pci/hda/patch_realtek.c
6880 +@@ -333,7 +333,9 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
6881 + case 0x10ec0215:
6882 + case 0x10ec0233:
6883 + case 0x10ec0235:
6884 ++ case 0x10ec0236:
6885 + case 0x10ec0255:
6886 ++ case 0x10ec0256:
6887 + case 0x10ec0257:
6888 + case 0x10ec0282:
6889 + case 0x10ec0283:
6890 +@@ -345,11 +347,6 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
6891 + case 0x10ec0300:
6892 + alc_update_coef_idx(codec, 0x10, 1<<9, 0);
6893 + break;
6894 +- case 0x10ec0236:
6895 +- case 0x10ec0256:
6896 +- alc_write_coef_idx(codec, 0x36, 0x5757);
6897 +- alc_update_coef_idx(codec, 0x10, 1<<9, 0);
6898 +- break;
6899 + case 0x10ec0275:
6900 + alc_update_coef_idx(codec, 0xe, 0, 1<<0);
6901 + break;
6902 +@@ -3122,7 +3119,13 @@ static void alc256_init(struct hda_codec *codec)
6903 + alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
6904 + alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
6905 + alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
6906 +- alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
6907 ++ /*
6908 ++ * Expose headphone mic (or possibly Line In on some machines) instead
6909 ++ * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
6910 ++ * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
6911 ++ * this register.
6912 ++ */
6913 ++ alc_write_coef_idx(codec, 0x36, 0x5757);
6914 + }
6915 +
6916 + static void alc256_shutup(struct hda_codec *codec)
6917 +diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c
6918 +index 2697402b5195..41f6450a2539 100644
6919 +--- a/sound/pci/ice1712/prodigy_hifi.c
6920 ++++ b/sound/pci/ice1712/prodigy_hifi.c
6921 +@@ -569,7 +569,7 @@ static int wm_adc_mux_enum_get(struct snd_kcontrol *kcontrol,
6922 + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
6923 +
6924 + mutex_lock(&ice->gpio_mutex);
6925 +- ucontrol->value.integer.value[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
6926 ++ ucontrol->value.enumerated.item[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
6927 + mutex_unlock(&ice->gpio_mutex);
6928 + return 0;
6929 + }
6930 +@@ -583,7 +583,7 @@ static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol,
6931 +
6932 + mutex_lock(&ice->gpio_mutex);
6933 + oval = wm_get(ice, WM_ADC_MUX);
6934 +- nval = (oval & 0xe0) | ucontrol->value.integer.value[0];
6935 ++ nval = (oval & 0xe0) | ucontrol->value.enumerated.item[0];
6936 + if (nval != oval) {
6937 + wm_put(ice, WM_ADC_MUX, nval);
6938 + change = 1;
6939 +diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
6940 +index 0f3604b55942..6044b3bbb121 100644
6941 +--- a/sound/soc/intel/atom/sst-atom-controls.c
6942 ++++ b/sound/soc/intel/atom/sst-atom-controls.c
6943 +@@ -1341,7 +1341,7 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
6944 + dai->capture_widget->name);
6945 + w = dai->capture_widget;
6946 + snd_soc_dapm_widget_for_each_source_path(w, p) {
6947 +- if (p->connected && !p->connected(w, p->sink))
6948 ++ if (p->connected && !p->connected(w, p->source))
6949 + continue;
6950 +
6951 + if (p->connect && p->source->power &&
6952 +diff --git a/sound/soc/intel/atom/sst/sst_pci.c b/sound/soc/intel/atom/sst/sst_pci.c
6953 +index 6906ee624cf6..438c7bcd8c4c 100644
6954 +--- a/sound/soc/intel/atom/sst/sst_pci.c
6955 ++++ b/sound/soc/intel/atom/sst/sst_pci.c
6956 +@@ -107,7 +107,7 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
6957 + dev_dbg(ctx->dev, "DRAM Ptr %p\n", ctx->dram);
6958 + do_release_regions:
6959 + pci_release_regions(pci);
6960 +- return 0;
6961 ++ return ret;
6962 + }
6963 +
6964 + /*
6965 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
6966 +index fb2fef166672..7861cf7a4488 100644
6967 +--- a/sound/soc/soc-dapm.c
6968 ++++ b/sound/soc/soc-dapm.c
6969 +@@ -799,7 +799,13 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
6970 + val = max - val;
6971 + p->connect = !!val;
6972 + } else {
6973 +- p->connect = 0;
6974 ++ /* since a virtual mixer has no backing registers to
6975 ++ * decide which path to connect, it will try to match
6976 ++ * with initial state. This is to ensure
6977 ++ * that the default mixer choice will be
6978 ++ * correctly powered up during initialization.
6979 ++ */
6980 ++ p->connect = invert;
6981 + }
6982 + }
6983 +
6984 +diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
6985 +index 500f98c730b9..d5ef627e93be 100644
6986 +--- a/sound/soc/soc-ops.c
6987 ++++ b/sound/soc/soc-ops.c
6988 +@@ -837,7 +837,7 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
6989 + unsigned int regbase = mc->regbase;
6990 + unsigned int regcount = mc->regcount;
6991 + unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
6992 +- unsigned int regwmask = (1<<regwshift)-1;
6993 ++ unsigned int regwmask = (1UL<<regwshift)-1;
6994 + unsigned int invert = mc->invert;
6995 + unsigned long mask = (1UL<<mc->nbits)-1;
6996 + long min = mc->min;
6997 +@@ -886,7 +886,7 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
6998 + unsigned int regbase = mc->regbase;
6999 + unsigned int regcount = mc->regcount;
7000 + unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
7001 +- unsigned int regwmask = (1<<regwshift)-1;
7002 ++ unsigned int regwmask = (1UL<<regwshift)-1;
7003 + unsigned int invert = mc->invert;
7004 + unsigned long mask = (1UL<<mc->nbits)-1;
7005 + long max = mc->max;
7006 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
7007 +index e75822dd9930..fd4b71729eed 100644
7008 +--- a/sound/soc/soc-pcm.c
7009 ++++ b/sound/soc/soc-pcm.c
7010 +@@ -2048,7 +2048,8 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
7011 + switch (cmd) {
7012 + case SNDRV_PCM_TRIGGER_START:
7013 + if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) &&
7014 +- (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
7015 ++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
7016 ++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
7017 + continue;
7018 +
7019 + ret = dpcm_do_trigger(dpcm, be_substream, cmd);
7020 +@@ -2078,7 +2079,8 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
7021 + be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
7022 + break;
7023 + case SNDRV_PCM_TRIGGER_STOP:
7024 +- if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
7025 ++ if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) &&
7026 ++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
7027 + continue;
7028 +
7029 + if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
7030 +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
7031 +index 1a912f72bddd..a215b9ad148c 100644
7032 +--- a/sound/soc/soc-topology.c
7033 ++++ b/sound/soc/soc-topology.c
7034 +@@ -421,7 +421,7 @@ static int soc_tplg_add_kcontrol(struct soc_tplg *tplg,
7035 + struct snd_soc_component *comp = tplg->comp;
7036 +
7037 + return soc_tplg_add_dcontrol(comp->card->snd_card,
7038 +- comp->dev, k, NULL, comp, kcontrol);
7039 ++ comp->dev, k, comp->name_prefix, comp, kcontrol);
7040 + }
7041 +
7042 + /* remove a mixer kcontrol */
7043 +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
7044 +index e6e4c3b9d9d3..7b75208d5cea 100644
7045 +--- a/sound/usb/mixer.c
7046 ++++ b/sound/usb/mixer.c
7047 +@@ -2342,7 +2342,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
7048 + if (map->id == state.chip->usb_id) {
7049 + state.map = map->map;
7050 + state.selector_map = map->selector_map;
7051 +- mixer->ignore_ctl_error = map->ignore_ctl_error;
7052 ++ mixer->ignore_ctl_error |= map->ignore_ctl_error;
7053 + break;
7054 + }
7055 + }
7056 +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
7057 +index eaa03acd4686..26ce6838e842 100644
7058 +--- a/sound/usb/mixer_maps.c
7059 ++++ b/sound/usb/mixer_maps.c
7060 +@@ -363,6 +363,14 @@ static const struct usbmix_name_map dell_alc4020_map[] = {
7061 + { 0 }
7062 + };
7063 +
7064 ++/* Some mobos shipped with a dummy HD-audio show the invalid GET_MIN/GET_MAX
7065 ++ * response for Input Gain Pad (id=19, control=12). Skip it.
7066 ++ */
7067 ++static const struct usbmix_name_map asus_rog_map[] = {
7068 ++ { 19, NULL, 12 }, /* FU, Input Gain Pad */
7069 ++ {}
7070 ++};
7071 ++
7072 + /*
7073 + * Control map entries
7074 + */
7075 +@@ -482,6 +490,26 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
7076 + .id = USB_ID(0x05a7, 0x1020),
7077 + .map = bose_companion5_map,
7078 + },
7079 ++ { /* Gigabyte TRX40 Aorus Pro WiFi */
7080 ++ .id = USB_ID(0x0414, 0xa002),
7081 ++ .map = asus_rog_map,
7082 ++ },
7083 ++ { /* ASUS ROG Zenith II */
7084 ++ .id = USB_ID(0x0b05, 0x1916),
7085 ++ .map = asus_rog_map,
7086 ++ },
7087 ++ { /* ASUS ROG Strix */
7088 ++ .id = USB_ID(0x0b05, 0x1917),
7089 ++ .map = asus_rog_map,
7090 ++ },
7091 ++ { /* MSI TRX40 Creator */
7092 ++ .id = USB_ID(0x0db0, 0x0d64),
7093 ++ .map = asus_rog_map,
7094 ++ },
7095 ++ { /* MSI TRX40 */
7096 ++ .id = USB_ID(0x0db0, 0x543d),
7097 ++ .map = asus_rog_map,
7098 ++ },
7099 + { 0 } /* terminator */
7100 + };
7101 +
7102 +diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile
7103 +index 6a73c06e069c..3dbf7e8b07a5 100644
7104 +--- a/tools/gpio/Makefile
7105 ++++ b/tools/gpio/Makefile
7106 +@@ -35,7 +35,7 @@ $(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
7107 +
7108 + prepare: $(OUTPUT)include/linux/gpio.h
7109 +
7110 +-GPIO_UTILS_IN := $(output)gpio-utils-in.o
7111 ++GPIO_UTILS_IN := $(OUTPUT)gpio-utils-in.o
7112 + $(GPIO_UTILS_IN): prepare FORCE
7113 + $(Q)$(MAKE) $(build)=gpio-utils
7114 +
7115 +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
7116 +index 5422543faff8..ccd5319d1284 100644
7117 +--- a/tools/objtool/check.c
7118 ++++ b/tools/objtool/check.c
7119 +@@ -915,10 +915,7 @@ static struct rela *find_switch_table(struct objtool_file *file,
7120 + * it.
7121 + */
7122 + for (;
7123 +- &insn->list != &file->insn_list &&
7124 +- insn->sec == func->sec &&
7125 +- insn->offset >= func->offset;
7126 +-
7127 ++ &insn->list != &file->insn_list && insn->func && insn->func->pfunc == func;
7128 + insn = insn->first_jump_src ?: list_prev_entry(insn, list)) {
7129 +
7130 + if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC)
7131 +diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
7132 +index b97e31498ff7..8baaf9797101 100644
7133 +--- a/tools/perf/Makefile.config
7134 ++++ b/tools/perf/Makefile.config
7135 +@@ -179,8 +179,17 @@ strip-libs = $(filter-out -l%,$(1))
7136 +
7137 + PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
7138 +
7139 ++# Python 3.8 changed the output of `python-config --ldflags` to not include the
7140 ++# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
7141 ++# libpython fails if that flag is not included in LDFLAGS
7142 ++ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
7143 ++ PYTHON_CONFIG_LDFLAGS := --ldflags --embed
7144 ++else
7145 ++ PYTHON_CONFIG_LDFLAGS := --ldflags
7146 ++endif
7147 ++
7148 + ifdef PYTHON_CONFIG
7149 +- PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
7150 ++ PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
7151 + PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
7152 + PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
7153 + PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
7154 +diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c
7155 +index 6f22238f3217..12aaa063196e 100644
7156 +--- a/tools/testing/selftests/x86/ptrace_syscall.c
7157 ++++ b/tools/testing/selftests/x86/ptrace_syscall.c
7158 +@@ -414,8 +414,12 @@ int main()
7159 +
7160 + #if defined(__i386__) && (!defined(__GLIBC__) || __GLIBC__ > 2 || __GLIBC_MINOR__ >= 16)
7161 + vsyscall32 = (void *)getauxval(AT_SYSINFO);
7162 +- printf("[RUN]\tCheck AT_SYSINFO return regs\n");
7163 +- test_sys32_regs(do_full_vsyscall32);
7164 ++ if (vsyscall32) {
7165 ++ printf("[RUN]\tCheck AT_SYSINFO return regs\n");
7166 ++ test_sys32_regs(do_full_vsyscall32);
7167 ++ } else {
7168 ++ printf("[SKIP]\tAT_SYSINFO is not available\n");
7169 ++ }
7170 + #endif
7171 +
7172 + test_ptrace_syscall_restart();