Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Sun, 10 Dec 2017 13:02:38
Message-Id: 1512910940.b8a9123d2e639a06e18b9a738f628c907dfdb686.alicef@gentoo
1 commit: b8a9123d2e639a06e18b9a738f628c907dfdb686
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 10 13:02:20 2017 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 10 13:02:20 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=b8a9123d
7
8 linux kernel 4.14.5
9
10 0000_README | 4 +
11 1004_linux-4.14.5.patch | 2342 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 2346 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 6749ad6..797ac0c 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -59,6 +59,10 @@ Patch: 1003_linux-4.14.4.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.14.4
21
22 +Patch: 1004_linux-4.14.5.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.14.5
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1004_linux-4.14.5.patch b/1004_linux-4.14.5.patch
31 new file mode 100644
32 index 0000000..e762dc5
33 --- /dev/null
34 +++ b/1004_linux-4.14.5.patch
35 @@ -0,0 +1,2342 @@
36 +diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
37 +index 6ca6b9e582a0..d740989eb569 100644
38 +--- a/Documentation/devicetree/bindings/timer/renesas,cmt.txt
39 ++++ b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
40 +@@ -20,16 +20,16 @@ Required Properties:
41 + (CMT1 on sh73a0 and r8a7740)
42 + This is a fallback for the above renesas,cmt-48-* entries.
43 +
44 +- - "renesas,cmt0-r8a73a4" for the 32-bit CMT0 device included in r8a73a4.
45 +- - "renesas,cmt1-r8a73a4" for the 48-bit CMT1 device included in r8a73a4.
46 +- - "renesas,cmt0-r8a7790" for the 32-bit CMT0 device included in r8a7790.
47 +- - "renesas,cmt1-r8a7790" for the 48-bit CMT1 device included in r8a7790.
48 +- - "renesas,cmt0-r8a7791" for the 32-bit CMT0 device included in r8a7791.
49 +- - "renesas,cmt1-r8a7791" for the 48-bit CMT1 device included in r8a7791.
50 +- - "renesas,cmt0-r8a7793" for the 32-bit CMT0 device included in r8a7793.
51 +- - "renesas,cmt1-r8a7793" for the 48-bit CMT1 device included in r8a7793.
52 +- - "renesas,cmt0-r8a7794" for the 32-bit CMT0 device included in r8a7794.
53 +- - "renesas,cmt1-r8a7794" for the 48-bit CMT1 device included in r8a7794.
54 ++ - "renesas,r8a73a4-cmt0" for the 32-bit CMT0 device included in r8a73a4.
55 ++ - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4.
56 ++ - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790.
57 ++ - "renesas,r8a7790-cmt1" for the 48-bit CMT1 device included in r8a7790.
58 ++ - "renesas,r8a7791-cmt0" for the 32-bit CMT0 device included in r8a7791.
59 ++ - "renesas,r8a7791-cmt1" for the 48-bit CMT1 device included in r8a7791.
60 ++ - "renesas,r8a7793-cmt0" for the 32-bit CMT0 device included in r8a7793.
61 ++ - "renesas,r8a7793-cmt1" for the 48-bit CMT1 device included in r8a7793.
62 ++ - "renesas,r8a7794-cmt0" for the 32-bit CMT0 device included in r8a7794.
63 ++ - "renesas,r8a7794-cmt1" for the 48-bit CMT1 device included in r8a7794.
64 +
65 + - "renesas,rcar-gen2-cmt0" for 32-bit CMT0 devices included in R-Car Gen2.
66 + - "renesas,rcar-gen2-cmt1" for 48-bit CMT1 devices included in R-Car Gen2.
67 +@@ -46,7 +46,7 @@ Required Properties:
68 + Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
69 +
70 + cmt0: timer@ffca0000 {
71 +- compatible = "renesas,cmt0-r8a7790", "renesas,rcar-gen2-cmt0";
72 ++ compatible = "renesas,r8a7790-cmt0", "renesas,rcar-gen2-cmt0";
73 + reg = <0 0xffca0000 0 0x1004>;
74 + interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
75 + <0 142 IRQ_TYPE_LEVEL_HIGH>;
76 +@@ -55,7 +55,7 @@ Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
77 + };
78 +
79 + cmt1: timer@e6130000 {
80 +- compatible = "renesas,cmt1-r8a7790", "renesas,rcar-gen2-cmt1";
81 ++ compatible = "renesas,r8a7790-cmt1", "renesas,rcar-gen2-cmt1";
82 + reg = <0 0xe6130000 0 0x1004>;
83 + interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
84 + <0 121 IRQ_TYPE_LEVEL_HIGH>,
85 +diff --git a/Makefile b/Makefile
86 +index ba1648c093fe..43ac7bdb10ad 100644
87 +--- a/Makefile
88 ++++ b/Makefile
89 +@@ -1,7 +1,7 @@
90 + # SPDX-License-Identifier: GPL-2.0
91 + VERSION = 4
92 + PATCHLEVEL = 14
93 +-SUBLEVEL = 4
94 ++SUBLEVEL = 5
95 + EXTRAVERSION =
96 + NAME = Petit Gorille
97 +
98 +diff --git a/arch/Kconfig b/arch/Kconfig
99 +index 057370a0ac4e..400b9e1b2f27 100644
100 +--- a/arch/Kconfig
101 ++++ b/arch/Kconfig
102 +@@ -91,7 +91,7 @@ config STATIC_KEYS_SELFTEST
103 + config OPTPROBES
104 + def_bool y
105 + depends on KPROBES && HAVE_OPTPROBES
106 +- depends on !PREEMPT
107 ++ select TASKS_RCU if PREEMPT
108 +
109 + config KPROBES_ON_FTRACE
110 + def_bool y
111 +diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
112 +index 8d1408583cf4..b523a604cb87 100644
113 +--- a/arch/m68k/mm/mcfmmu.c
114 ++++ b/arch/m68k/mm/mcfmmu.c
115 +@@ -170,7 +170,7 @@ void __init cf_bootmem_alloc(void)
116 + max_pfn = max_low_pfn = PFN_DOWN(_ramend);
117 + high_memory = (void *)_ramend;
118 +
119 +- m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
120 ++ m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
121 + module_fixup(NULL, __start_fixup, __stop_fixup);
122 +
123 + /* setup bootmem data */
124 +diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild
125 +index 7c8aab23bce8..b1f66699677d 100644
126 +--- a/arch/mips/include/asm/Kbuild
127 ++++ b/arch/mips/include/asm/Kbuild
128 +@@ -16,7 +16,6 @@ generic-y += qrwlock.h
129 + generic-y += qspinlock.h
130 + generic-y += sections.h
131 + generic-y += segment.h
132 +-generic-y += serial.h
133 + generic-y += trace_clock.h
134 + generic-y += unaligned.h
135 + generic-y += user.h
136 +diff --git a/arch/mips/include/asm/serial.h b/arch/mips/include/asm/serial.h
137 +new file mode 100644
138 +index 000000000000..1d830c6666c2
139 +--- /dev/null
140 ++++ b/arch/mips/include/asm/serial.h
141 +@@ -0,0 +1,22 @@
142 ++/*
143 ++ * Copyright (C) 2017 MIPS Tech, LLC
144 ++ *
145 ++ * This program is free software; you can redistribute it and/or modify it
146 ++ * under the terms of the GNU General Public License as published by the
147 ++ * Free Software Foundation; either version 2 of the License, or (at your
148 ++ * option) any later version.
149 ++ */
150 ++#ifndef __ASM__SERIAL_H
151 ++#define __ASM__SERIAL_H
152 ++
153 ++#ifdef CONFIG_MIPS_GENERIC
154 ++/*
155 ++ * Generic kernels cannot know a correct value for all platforms at
156 ++ * compile time. Set it to 0 to prevent 8250_early using it
157 ++ */
158 ++#define BASE_BAUD 0
159 ++#else
160 ++#include <asm-generic/serial.h>
161 ++#endif
162 ++
163 ++#endif /* __ASM__SERIAL_H */
164 +diff --git a/arch/powerpc/kernel/kprobes-ftrace.c b/arch/powerpc/kernel/kprobes-ftrace.c
165 +index 6c089d9757c9..2d81404f818c 100644
166 +--- a/arch/powerpc/kernel/kprobes-ftrace.c
167 ++++ b/arch/powerpc/kernel/kprobes-ftrace.c
168 +@@ -65,6 +65,7 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
169 + /* Disable irq for emulating a breakpoint and avoiding preempt */
170 + local_irq_save(flags);
171 + hard_irq_disable();
172 ++ preempt_disable();
173 +
174 + p = get_kprobe((kprobe_opcode_t *)nip);
175 + if (unlikely(!p) || kprobe_disabled(p))
176 +@@ -86,12 +87,18 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
177 + kcb->kprobe_status = KPROBE_HIT_ACTIVE;
178 + if (!p->pre_handler || !p->pre_handler(p, regs))
179 + __skip_singlestep(p, regs, kcb, orig_nip);
180 +- /*
181 +- * If pre_handler returns !0, it sets regs->nip and
182 +- * resets current kprobe.
183 +- */
184 ++ else {
185 ++ /*
186 ++ * If pre_handler returns !0, it sets regs->nip and
187 ++ * resets current kprobe. In this case, we still need
188 ++ * to restore irq, but not preemption.
189 ++ */
190 ++ local_irq_restore(flags);
191 ++ return;
192 ++ }
193 + }
194 + end:
195 ++ preempt_enable_no_resched();
196 + local_irq_restore(flags);
197 + }
198 + NOKPROBE_SYMBOL(kprobe_ftrace_handler);
199 +diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
200 +index 91e037ab20a1..60ba7f1370a8 100644
201 +--- a/arch/powerpc/kernel/optprobes.c
202 ++++ b/arch/powerpc/kernel/optprobes.c
203 +@@ -115,7 +115,6 @@ static unsigned long can_optimize(struct kprobe *p)
204 + static void optimized_callback(struct optimized_kprobe *op,
205 + struct pt_regs *regs)
206 + {
207 +- struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
208 + unsigned long flags;
209 +
210 + /* This is possible if op is under delayed unoptimizing */
211 +@@ -124,13 +123,14 @@ static void optimized_callback(struct optimized_kprobe *op,
212 +
213 + local_irq_save(flags);
214 + hard_irq_disable();
215 ++ preempt_disable();
216 +
217 + if (kprobe_running()) {
218 + kprobes_inc_nmissed_count(&op->kp);
219 + } else {
220 + __this_cpu_write(current_kprobe, &op->kp);
221 + regs->nip = (unsigned long)op->kp.addr;
222 +- kcb->kprobe_status = KPROBE_HIT_ACTIVE;
223 ++ get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
224 + opt_pre_handler(&op->kp, regs);
225 + __this_cpu_write(current_kprobe, NULL);
226 + }
227 +@@ -140,6 +140,7 @@ static void optimized_callback(struct optimized_kprobe *op,
228 + * local_irq_restore() will re-enable interrupts,
229 + * if they were hard disabled.
230 + */
231 ++ preempt_enable_no_resched();
232 + local_irq_restore(flags);
233 + }
234 + NOKPROBE_SYMBOL(optimized_callback);
235 +diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h
236 +index 419e83fa4721..ba22a6ea51a1 100644
237 +--- a/arch/s390/include/asm/pci_insn.h
238 ++++ b/arch/s390/include/asm/pci_insn.h
239 +@@ -82,6 +82,6 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range);
240 + int zpci_load(u64 *data, u64 req, u64 offset);
241 + int zpci_store(u64 data, u64 req, u64 offset);
242 + int zpci_store_block(const u64 *data, u64 req, u64 offset);
243 +-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
244 ++int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
245 +
246 + #endif
247 +diff --git a/arch/s390/include/asm/runtime_instr.h b/arch/s390/include/asm/runtime_instr.h
248 +index ea8896ba5afc..2502d05403ef 100644
249 +--- a/arch/s390/include/asm/runtime_instr.h
250 ++++ b/arch/s390/include/asm/runtime_instr.h
251 +@@ -86,6 +86,8 @@ static inline void restore_ri_cb(struct runtime_instr_cb *cb_next,
252 + load_runtime_instr_cb(&runtime_instr_empty_cb);
253 + }
254 +
255 +-void exit_thread_runtime_instr(void);
256 ++struct task_struct;
257 ++
258 ++void runtime_instr_release(struct task_struct *tsk);
259 +
260 + #endif /* _RUNTIME_INSTR_H */
261 +diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
262 +index 203b7cd7c348..7d4c5500c6c2 100644
263 +--- a/arch/s390/kernel/process.c
264 ++++ b/arch/s390/kernel/process.c
265 +@@ -49,10 +49,8 @@ extern void kernel_thread_starter(void);
266 + */
267 + void exit_thread(struct task_struct *tsk)
268 + {
269 +- if (tsk == current) {
270 +- exit_thread_runtime_instr();
271 ++ if (tsk == current)
272 + exit_thread_gs();
273 +- }
274 + }
275 +
276 + void flush_thread(void)
277 +@@ -65,6 +63,7 @@ void release_thread(struct task_struct *dead_task)
278 +
279 + void arch_release_task_struct(struct task_struct *tsk)
280 + {
281 ++ runtime_instr_release(tsk);
282 + }
283 +
284 + int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
285 +diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
286 +index 1427d60ce628..56e0190d6e65 100644
287 +--- a/arch/s390/kernel/ptrace.c
288 ++++ b/arch/s390/kernel/ptrace.c
289 +@@ -1172,26 +1172,37 @@ static int s390_gs_cb_set(struct task_struct *target,
290 + unsigned int pos, unsigned int count,
291 + const void *kbuf, const void __user *ubuf)
292 + {
293 +- struct gs_cb *data = target->thread.gs_cb;
294 ++ struct gs_cb gs_cb = { }, *data = NULL;
295 + int rc;
296 +
297 + if (!MACHINE_HAS_GS)
298 + return -ENODEV;
299 +- if (!data) {
300 ++ if (!target->thread.gs_cb) {
301 + data = kzalloc(sizeof(*data), GFP_KERNEL);
302 + if (!data)
303 + return -ENOMEM;
304 +- data->gsd = 25;
305 +- target->thread.gs_cb = data;
306 +- if (target == current)
307 +- __ctl_set_bit(2, 4);
308 +- } else if (target == current) {
309 +- save_gs_cb(data);
310 + }
311 ++ if (!target->thread.gs_cb)
312 ++ gs_cb.gsd = 25;
313 ++ else if (target == current)
314 ++ save_gs_cb(&gs_cb);
315 ++ else
316 ++ gs_cb = *target->thread.gs_cb;
317 + rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
318 +- data, 0, sizeof(struct gs_cb));
319 +- if (target == current)
320 +- restore_gs_cb(data);
321 ++ &gs_cb, 0, sizeof(gs_cb));
322 ++ if (rc) {
323 ++ kfree(data);
324 ++ return -EFAULT;
325 ++ }
326 ++ preempt_disable();
327 ++ if (!target->thread.gs_cb)
328 ++ target->thread.gs_cb = data;
329 ++ *target->thread.gs_cb = gs_cb;
330 ++ if (target == current) {
331 ++ __ctl_set_bit(2, 4);
332 ++ restore_gs_cb(target->thread.gs_cb);
333 ++ }
334 ++ preempt_enable();
335 + return rc;
336 + }
337 +
338 +diff --git a/arch/s390/kernel/runtime_instr.c b/arch/s390/kernel/runtime_instr.c
339 +index d85c64821a6b..94c9ba72cf83 100644
340 +--- a/arch/s390/kernel/runtime_instr.c
341 ++++ b/arch/s390/kernel/runtime_instr.c
342 +@@ -21,11 +21,24 @@
343 + /* empty control block to disable RI by loading it */
344 + struct runtime_instr_cb runtime_instr_empty_cb;
345 +
346 ++void runtime_instr_release(struct task_struct *tsk)
347 ++{
348 ++ kfree(tsk->thread.ri_cb);
349 ++}
350 ++
351 + static void disable_runtime_instr(void)
352 + {
353 +- struct pt_regs *regs = task_pt_regs(current);
354 ++ struct task_struct *task = current;
355 ++ struct pt_regs *regs;
356 +
357 ++ if (!task->thread.ri_cb)
358 ++ return;
359 ++ regs = task_pt_regs(task);
360 ++ preempt_disable();
361 + load_runtime_instr_cb(&runtime_instr_empty_cb);
362 ++ kfree(task->thread.ri_cb);
363 ++ task->thread.ri_cb = NULL;
364 ++ preempt_enable();
365 +
366 + /*
367 + * Make sure the RI bit is deleted from the PSW. If the user did not
368 +@@ -46,19 +59,6 @@ static void init_runtime_instr_cb(struct runtime_instr_cb *cb)
369 + cb->valid = 1;
370 + }
371 +
372 +-void exit_thread_runtime_instr(void)
373 +-{
374 +- struct task_struct *task = current;
375 +-
376 +- preempt_disable();
377 +- if (!task->thread.ri_cb)
378 +- return;
379 +- disable_runtime_instr();
380 +- kfree(task->thread.ri_cb);
381 +- task->thread.ri_cb = NULL;
382 +- preempt_enable();
383 +-}
384 +-
385 + SYSCALL_DEFINE1(s390_runtime_instr, int, command)
386 + {
387 + struct runtime_instr_cb *cb;
388 +@@ -67,7 +67,7 @@ SYSCALL_DEFINE1(s390_runtime_instr, int, command)
389 + return -EOPNOTSUPP;
390 +
391 + if (command == S390_RUNTIME_INSTR_STOP) {
392 +- exit_thread_runtime_instr();
393 ++ disable_runtime_instr();
394 + return 0;
395 + }
396 +
397 +diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
398 +index a25d95a6612d..0fe649c0d542 100644
399 +--- a/arch/s390/pci/pci.c
400 ++++ b/arch/s390/pci/pci.c
401 +@@ -368,7 +368,8 @@ static void zpci_irq_handler(struct airq_struct *airq)
402 + /* End of second scan with interrupts on. */
403 + break;
404 + /* First scan complete, reenable interrupts. */
405 +- zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
406 ++ if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC))
407 ++ break;
408 + si = 0;
409 + continue;
410 + }
411 +@@ -956,7 +957,7 @@ static int __init pci_base_init(void)
412 + if (!s390_pci_probe)
413 + return 0;
414 +
415 +- if (!test_facility(69) || !test_facility(71) || !test_facility(72))
416 ++ if (!test_facility(69) || !test_facility(71))
417 + return 0;
418 +
419 + rc = zpci_debug_init();
420 +diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c
421 +index ea34086c8674..81b840bc6e4e 100644
422 +--- a/arch/s390/pci/pci_insn.c
423 ++++ b/arch/s390/pci/pci_insn.c
424 +@@ -7,6 +7,7 @@
425 + #include <linux/export.h>
426 + #include <linux/errno.h>
427 + #include <linux/delay.h>
428 ++#include <asm/facility.h>
429 + #include <asm/pci_insn.h>
430 + #include <asm/pci_debug.h>
431 + #include <asm/processor.h>
432 +@@ -91,11 +92,14 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range)
433 + }
434 +
435 + /* Set Interruption Controls */
436 +-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
437 ++int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
438 + {
439 ++ if (!test_facility(72))
440 ++ return -EIO;
441 + asm volatile (
442 + " .insn rsy,0xeb00000000d1,%[ctl],%[isc],%[u]\n"
443 + : : [ctl] "d" (ctl), [isc] "d" (isc << 27), [u] "Q" (*unused));
444 ++ return 0;
445 + }
446 +
447 + /* PCI Load */
448 +diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
449 +index 2fdb23313dd5..9bceea6a5852 100644
450 +--- a/arch/x86/Kconfig
451 ++++ b/arch/x86/Kconfig
452 +@@ -56,7 +56,7 @@ config X86
453 + select ARCH_HAS_KCOV if X86_64
454 + select ARCH_HAS_PMEM_API if X86_64
455 + # Causing hangs/crashes, see the commit that added this change for details.
456 +- select ARCH_HAS_REFCOUNT if BROKEN
457 ++ select ARCH_HAS_REFCOUNT
458 + select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64
459 + select ARCH_HAS_SET_MEMORY
460 + select ARCH_HAS_SG_CHAIN
461 +diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h
462 +index ff871210b9f2..4e44250e7d0d 100644
463 +--- a/arch/x86/include/asm/refcount.h
464 ++++ b/arch/x86/include/asm/refcount.h
465 +@@ -15,7 +15,7 @@
466 + * back to the regular execution flow in .text.
467 + */
468 + #define _REFCOUNT_EXCEPTION \
469 +- ".pushsection .text.unlikely\n" \
470 ++ ".pushsection .text..refcount\n" \
471 + "111:\tlea %[counter], %%" _ASM_CX "\n" \
472 + "112:\t" ASM_UD0 "\n" \
473 + ASM_UNREACHABLE \
474 +diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h
475 +index 91dfcafe27a6..bad25bb80679 100644
476 +--- a/arch/x86/include/asm/syscalls.h
477 ++++ b/arch/x86/include/asm/syscalls.h
478 +@@ -21,7 +21,7 @@ asmlinkage long sys_ioperm(unsigned long, unsigned long, int);
479 + asmlinkage long sys_iopl(unsigned int);
480 +
481 + /* kernel/ldt.c */
482 +-asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);
483 ++asmlinkage long sys_modify_ldt(int, void __user *, unsigned long);
484 +
485 + /* kernel/signal.c */
486 + asmlinkage long sys_rt_sigreturn(void);
487 +diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
488 +index cd5fc61ba450..88dcf8479013 100644
489 +--- a/arch/x86/kernel/cpu/intel_rdt.c
490 ++++ b/arch/x86/kernel/cpu/intel_rdt.c
491 +@@ -267,6 +267,7 @@ static void rdt_get_cdp_l3_config(int type)
492 + r->num_closid = r_l3->num_closid / 2;
493 + r->cache.cbm_len = r_l3->cache.cbm_len;
494 + r->default_ctrl = r_l3->default_ctrl;
495 ++ r->cache.shareable_bits = r_l3->cache.shareable_bits;
496 + r->data_width = (r->cache.cbm_len + 3) / 4;
497 + r->alloc_capable = true;
498 + /*
499 +diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
500 +index a869d4a073c5..3d433af856a5 100644
501 +--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
502 ++++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
503 +@@ -1081,6 +1081,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
504 + struct dentry *dentry;
505 + int ret;
506 +
507 ++ cpus_read_lock();
508 + mutex_lock(&rdtgroup_mutex);
509 + /*
510 + * resctrl file system can only be mounted once.
511 +@@ -1130,12 +1131,12 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
512 + goto out_mondata;
513 +
514 + if (rdt_alloc_capable)
515 +- static_branch_enable(&rdt_alloc_enable_key);
516 ++ static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
517 + if (rdt_mon_capable)
518 +- static_branch_enable(&rdt_mon_enable_key);
519 ++ static_branch_enable_cpuslocked(&rdt_mon_enable_key);
520 +
521 + if (rdt_alloc_capable || rdt_mon_capable)
522 +- static_branch_enable(&rdt_enable_key);
523 ++ static_branch_enable_cpuslocked(&rdt_enable_key);
524 +
525 + if (is_mbm_enabled()) {
526 + r = &rdt_resources_all[RDT_RESOURCE_L3];
527 +@@ -1157,6 +1158,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
528 + cdp_disable();
529 + out:
530 + mutex_unlock(&rdtgroup_mutex);
531 ++ cpus_read_unlock();
532 +
533 + return dentry;
534 + }
535 +diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c
536 +index 041f7b6dfa0f..bcfee4f69b0e 100644
537 +--- a/arch/x86/kernel/kprobes/ftrace.c
538 ++++ b/arch/x86/kernel/kprobes/ftrace.c
539 +@@ -26,7 +26,7 @@
540 + #include "common.h"
541 +
542 + static nokprobe_inline
543 +-int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
544 ++void __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
545 + struct kprobe_ctlblk *kcb, unsigned long orig_ip)
546 + {
547 + /*
548 +@@ -41,20 +41,21 @@ int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
549 + __this_cpu_write(current_kprobe, NULL);
550 + if (orig_ip)
551 + regs->ip = orig_ip;
552 +- return 1;
553 + }
554 +
555 + int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
556 + struct kprobe_ctlblk *kcb)
557 + {
558 +- if (kprobe_ftrace(p))
559 +- return __skip_singlestep(p, regs, kcb, 0);
560 +- else
561 +- return 0;
562 ++ if (kprobe_ftrace(p)) {
563 ++ __skip_singlestep(p, regs, kcb, 0);
564 ++ preempt_enable_no_resched();
565 ++ return 1;
566 ++ }
567 ++ return 0;
568 + }
569 + NOKPROBE_SYMBOL(skip_singlestep);
570 +
571 +-/* Ftrace callback handler for kprobes */
572 ++/* Ftrace callback handler for kprobes -- called under preepmt disabed */
573 + void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
574 + struct ftrace_ops *ops, struct pt_regs *regs)
575 + {
576 +@@ -77,13 +78,17 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
577 + /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */
578 + regs->ip = ip + sizeof(kprobe_opcode_t);
579 +
580 ++ /* To emulate trap based kprobes, preempt_disable here */
581 ++ preempt_disable();
582 + __this_cpu_write(current_kprobe, p);
583 + kcb->kprobe_status = KPROBE_HIT_ACTIVE;
584 +- if (!p->pre_handler || !p->pre_handler(p, regs))
585 ++ if (!p->pre_handler || !p->pre_handler(p, regs)) {
586 + __skip_singlestep(p, regs, kcb, orig_ip);
587 ++ preempt_enable_no_resched();
588 ++ }
589 + /*
590 + * If pre_handler returns !0, it sets regs->ip and
591 +- * resets current kprobe.
592 ++ * resets current kprobe, and keep preempt count +1.
593 + */
594 + }
595 + end:
596 +diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
597 +index 4d17bacf4030..ae5615b03def 100644
598 +--- a/arch/x86/kernel/ldt.c
599 ++++ b/arch/x86/kernel/ldt.c
600 +@@ -13,6 +13,7 @@
601 + #include <linux/string.h>
602 + #include <linux/mm.h>
603 + #include <linux/smp.h>
604 ++#include <linux/syscalls.h>
605 + #include <linux/slab.h>
606 + #include <linux/vmalloc.h>
607 + #include <linux/uaccess.h>
608 +@@ -295,8 +296,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
609 + return error;
610 + }
611 +
612 +-asmlinkage int sys_modify_ldt(int func, void __user *ptr,
613 +- unsigned long bytecount)
614 ++SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
615 ++ unsigned long , bytecount)
616 + {
617 + int ret = -ENOSYS;
618 +
619 +@@ -314,5 +315,14 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
620 + ret = write_ldt(ptr, bytecount, 0);
621 + break;
622 + }
623 +- return ret;
624 ++ /*
625 ++ * The SYSCALL_DEFINE() macros give us an 'unsigned long'
626 ++ * return type, but tht ABI for sys_modify_ldt() expects
627 ++ * 'int'. This cast gives us an int-sized value in %rax
628 ++ * for the return code. The 'unsigned' is necessary so
629 ++ * the compiler does not try to sign-extend the negative
630 ++ * return codes into the high half of the register when
631 ++ * taking the value from int->long.
632 ++ */
633 ++ return (unsigned int)ret;
634 + }
635 +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
636 +index c3521e2be396..30bc4812ceb8 100644
637 +--- a/arch/x86/mm/extable.c
638 ++++ b/arch/x86/mm/extable.c
639 +@@ -67,17 +67,22 @@ bool ex_handler_refcount(const struct exception_table_entry *fixup,
640 + * wrapped around) will be set. Additionally, seeing the refcount
641 + * reach 0 will set ZF (Zero Flag: result was zero). In each of
642 + * these cases we want a report, since it's a boundary condition.
643 +- *
644 ++ * The SF case is not reported since it indicates post-boundary
645 ++ * manipulations below zero or above INT_MAX. And if none of the
646 ++ * flags are set, something has gone very wrong, so report it.
647 + */
648 + if (regs->flags & (X86_EFLAGS_OF | X86_EFLAGS_ZF)) {
649 + bool zero = regs->flags & X86_EFLAGS_ZF;
650 +
651 + refcount_error_report(regs, zero ? "hit zero" : "overflow");
652 ++ } else if ((regs->flags & X86_EFLAGS_SF) == 0) {
653 ++ /* Report if none of OF, ZF, nor SF are set. */
654 ++ refcount_error_report(regs, "unexpected saturation");
655 + }
656 +
657 + return true;
658 + }
659 +-EXPORT_SYMBOL_GPL(ex_handler_refcount);
660 ++EXPORT_SYMBOL(ex_handler_refcount);
661 +
662 + /*
663 + * Handler for when we fail to restore a task's FPU state. We should never get
664 +diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c
665 +index 836a1eb5df43..3ee234b6234d 100644
666 +--- a/arch/x86/um/ldt.c
667 ++++ b/arch/x86/um/ldt.c
668 +@@ -6,6 +6,7 @@
669 + #include <linux/mm.h>
670 + #include <linux/sched.h>
671 + #include <linux/slab.h>
672 ++#include <linux/syscalls.h>
673 + #include <linux/uaccess.h>
674 + #include <asm/unistd.h>
675 + #include <os.h>
676 +@@ -369,7 +370,9 @@ void free_ldt(struct mm_context *mm)
677 + mm->arch.ldt.entry_count = 0;
678 + }
679 +
680 +-int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
681 ++SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
682 ++ unsigned long , bytecount)
683 + {
684 +- return do_modify_ldt_skas(func, ptr, bytecount);
685 ++ /* See non-um modify_ldt() for why we do this cast */
686 ++ return (unsigned int)do_modify_ldt_skas(func, ptr, bytecount);
687 + }
688 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
689 +index fddf76ef5bd6..88b4bbe58100 100644
690 +--- a/drivers/android/binder.c
691 ++++ b/drivers/android/binder.c
692 +@@ -1947,6 +1947,26 @@ static void binder_send_failed_reply(struct binder_transaction *t,
693 + }
694 + }
695 +
696 ++/**
697 ++ * binder_cleanup_transaction() - cleans up undelivered transaction
698 ++ * @t: transaction that needs to be cleaned up
699 ++ * @reason: reason the transaction wasn't delivered
700 ++ * @error_code: error to return to caller (if synchronous call)
701 ++ */
702 ++static void binder_cleanup_transaction(struct binder_transaction *t,
703 ++ const char *reason,
704 ++ uint32_t error_code)
705 ++{
706 ++ if (t->buffer->target_node && !(t->flags & TF_ONE_WAY)) {
707 ++ binder_send_failed_reply(t, error_code);
708 ++ } else {
709 ++ binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
710 ++ "undelivered transaction %d, %s\n",
711 ++ t->debug_id, reason);
712 ++ binder_free_transaction(t);
713 ++ }
714 ++}
715 ++
716 + /**
717 + * binder_validate_object() - checks for a valid metadata object in a buffer.
718 + * @buffer: binder_buffer that we're parsing.
719 +@@ -4015,12 +4035,20 @@ static int binder_thread_read(struct binder_proc *proc,
720 + if (put_user(cmd, (uint32_t __user *)ptr)) {
721 + if (t_from)
722 + binder_thread_dec_tmpref(t_from);
723 ++
724 ++ binder_cleanup_transaction(t, "put_user failed",
725 ++ BR_FAILED_REPLY);
726 ++
727 + return -EFAULT;
728 + }
729 + ptr += sizeof(uint32_t);
730 + if (copy_to_user(ptr, &tr, sizeof(tr))) {
731 + if (t_from)
732 + binder_thread_dec_tmpref(t_from);
733 ++
734 ++ binder_cleanup_transaction(t, "copy_to_user failed",
735 ++ BR_FAILED_REPLY);
736 ++
737 + return -EFAULT;
738 + }
739 + ptr += sizeof(tr);
740 +@@ -4090,15 +4118,9 @@ static void binder_release_work(struct binder_proc *proc,
741 + struct binder_transaction *t;
742 +
743 + t = container_of(w, struct binder_transaction, work);
744 +- if (t->buffer->target_node &&
745 +- !(t->flags & TF_ONE_WAY)) {
746 +- binder_send_failed_reply(t, BR_DEAD_REPLY);
747 +- } else {
748 +- binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
749 +- "undelivered transaction %d\n",
750 +- t->debug_id);
751 +- binder_free_transaction(t);
752 +- }
753 ++
754 ++ binder_cleanup_transaction(t, "process died.",
755 ++ BR_DEAD_REPLY);
756 + } break;
757 + case BINDER_WORK_RETURN_ERROR: {
758 + struct binder_error *e = container_of(
759 +diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
760 +index e8ca5e2cf1e5..70f8904f46a3 100644
761 +--- a/drivers/base/power/domain.c
762 ++++ b/drivers/base/power/domain.c
763 +@@ -921,7 +921,7 @@ static int pm_genpd_prepare(struct device *dev)
764 + genpd_unlock(genpd);
765 +
766 + ret = pm_generic_prepare(dev);
767 +- if (ret) {
768 ++ if (ret < 0) {
769 + genpd_lock(genpd);
770 +
771 + genpd->prepared_count--;
772 +@@ -929,7 +929,8 @@ static int pm_genpd_prepare(struct device *dev)
773 + genpd_unlock(genpd);
774 + }
775 +
776 +- return ret;
777 ++ /* Never return 1, as genpd don't cope with the direct_complete path. */
778 ++ return ret >= 0 ? 0 : ret;
779 + }
780 +
781 + /**
782 +diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
783 +index fd4b7f684bd0..14e2419063e9 100644
784 +--- a/drivers/clocksource/arm_arch_timer.c
785 ++++ b/drivers/clocksource/arm_arch_timer.c
786 +@@ -1268,10 +1268,6 @@ arch_timer_mem_find_best_frame(struct arch_timer_mem *timer_mem)
787 +
788 + iounmap(cntctlbase);
789 +
790 +- if (!best_frame)
791 +- pr_err("Unable to find a suitable frame in timer @ %pa\n",
792 +- &timer_mem->cntctlbase);
793 +-
794 + return best_frame;
795 + }
796 +
797 +@@ -1372,6 +1368,8 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
798 +
799 + frame = arch_timer_mem_find_best_frame(timer_mem);
800 + if (!frame) {
801 ++ pr_err("Unable to find a suitable frame in timer @ %pa\n",
802 ++ &timer_mem->cntctlbase);
803 + ret = -EINVAL;
804 + goto out;
805 + }
806 +@@ -1420,7 +1418,7 @@ arch_timer_mem_verify_cntfrq(struct arch_timer_mem *timer_mem)
807 + static int __init arch_timer_mem_acpi_init(int platform_timer_count)
808 + {
809 + struct arch_timer_mem *timers, *timer;
810 +- struct arch_timer_mem_frame *frame;
811 ++ struct arch_timer_mem_frame *frame, *best_frame = NULL;
812 + int timer_count, i, ret = 0;
813 +
814 + timers = kcalloc(platform_timer_count, sizeof(*timers),
815 +@@ -1432,14 +1430,6 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
816 + if (ret || !timer_count)
817 + goto out;
818 +
819 +- for (i = 0; i < timer_count; i++) {
820 +- ret = arch_timer_mem_verify_cntfrq(&timers[i]);
821 +- if (ret) {
822 +- pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n");
823 +- goto out;
824 +- }
825 +- }
826 +-
827 + /*
828 + * While unlikely, it's theoretically possible that none of the frames
829 + * in a timer expose the combination of feature we want.
830 +@@ -1448,12 +1438,26 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
831 + timer = &timers[i];
832 +
833 + frame = arch_timer_mem_find_best_frame(timer);
834 +- if (frame)
835 +- break;
836 ++ if (!best_frame)
837 ++ best_frame = frame;
838 ++
839 ++ ret = arch_timer_mem_verify_cntfrq(timer);
840 ++ if (ret) {
841 ++ pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n");
842 ++ goto out;
843 ++ }
844 ++
845 ++ if (!best_frame) /* implies !frame */
846 ++ /*
847 ++ * Only complain about missing suitable frames if we
848 ++ * haven't already found one in a previous iteration.
849 ++ */
850 ++ pr_err("Unable to find a suitable frame in timer @ %pa\n",
851 ++ &timer->cntctlbase);
852 + }
853 +
854 +- if (frame)
855 +- ret = arch_timer_mem_frame_register(frame);
856 ++ if (best_frame)
857 ++ ret = arch_timer_mem_frame_register(best_frame);
858 + out:
859 + kfree(timers);
860 + return ret;
861 +diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
862 +index 52a75053ee03..f47c54546752 100644
863 +--- a/drivers/cpuidle/cpuidle-arm.c
864 ++++ b/drivers/cpuidle/cpuidle-arm.c
865 +@@ -104,13 +104,13 @@ static int __init arm_idle_init(void)
866 + ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
867 + if (ret <= 0) {
868 + ret = ret ? : -ENODEV;
869 +- goto init_fail;
870 ++ goto out_kfree_drv;
871 + }
872 +
873 + ret = cpuidle_register_driver(drv);
874 + if (ret) {
875 + pr_err("Failed to register cpuidle driver\n");
876 +- goto init_fail;
877 ++ goto out_kfree_drv;
878 + }
879 +
880 + /*
881 +@@ -128,14 +128,14 @@ static int __init arm_idle_init(void)
882 +
883 + if (ret) {
884 + pr_err("CPU %d failed to init idle CPU ops\n", cpu);
885 +- goto out_fail;
886 ++ goto out_unregister_drv;
887 + }
888 +
889 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
890 + if (!dev) {
891 + pr_err("Failed to allocate cpuidle device\n");
892 + ret = -ENOMEM;
893 +- goto out_fail;
894 ++ goto out_unregister_drv;
895 + }
896 + dev->cpu = cpu;
897 +
898 +@@ -143,21 +143,25 @@ static int __init arm_idle_init(void)
899 + if (ret) {
900 + pr_err("Failed to register cpuidle device for CPU %d\n",
901 + cpu);
902 +- kfree(dev);
903 +- goto out_fail;
904 ++ goto out_kfree_dev;
905 + }
906 + }
907 +
908 + return 0;
909 +-init_fail:
910 ++
911 ++out_kfree_dev:
912 ++ kfree(dev);
913 ++out_unregister_drv:
914 ++ cpuidle_unregister_driver(drv);
915 ++out_kfree_drv:
916 + kfree(drv);
917 + out_fail:
918 + while (--cpu >= 0) {
919 + dev = per_cpu(cpuidle_devices, cpu);
920 ++ drv = cpuidle_get_cpu_driver(dev);
921 + cpuidle_unregister_device(dev);
922 +- kfree(dev);
923 +- drv = cpuidle_get_driver();
924 + cpuidle_unregister_driver(drv);
925 ++ kfree(dev);
926 + kfree(drv);
927 + }
928 +
929 +diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
930 +index 38cc7389a6c1..24f83f9eeaed 100644
931 +--- a/drivers/dma-buf/sw_sync.c
932 ++++ b/drivers/dma-buf/sw_sync.c
933 +@@ -321,8 +321,16 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
934 + static int sw_sync_debugfs_release(struct inode *inode, struct file *file)
935 + {
936 + struct sync_timeline *obj = file->private_data;
937 ++ struct sync_pt *pt, *next;
938 ++
939 ++ spin_lock_irq(&obj->lock);
940 ++
941 ++ list_for_each_entry_safe(pt, next, &obj->pt_list, link) {
942 ++ dma_fence_set_error(&pt->base, -ENOENT);
943 ++ dma_fence_signal_locked(&pt->base);
944 ++ }
945 +
946 +- smp_wmb();
947 ++ spin_unlock_irq(&obj->lock);
948 +
949 + sync_timeline_put(obj);
950 + return 0;
951 +diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
952 +index 6241fa787d66..cd9d6ba03579 100644
953 +--- a/drivers/edac/sb_edac.c
954 ++++ b/drivers/edac/sb_edac.c
955 +@@ -2498,6 +2498,7 @@ static int ibridge_mci_bind_devs(struct mem_ctl_info *mci,
956 + case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA:
957 + case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TA:
958 + pvt->pci_ta = pdev;
959 ++ break;
960 + case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS:
961 + case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_RAS:
962 + pvt->pci_ras = pdev;
963 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
964 +index 87801faaf264..712ad8c2bdc5 100644
965 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
966 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
967 +@@ -697,7 +697,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
968 + struct amdgpu_queue_mgr *mgr);
969 + int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
970 + struct amdgpu_queue_mgr *mgr,
971 +- int hw_ip, int instance, int ring,
972 ++ u32 hw_ip, u32 instance, u32 ring,
973 + struct amdgpu_ring **out_ring);
974 +
975 + /*
976 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c
977 +index befc09b68543..b293380bd46c 100644
978 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c
979 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c
980 +@@ -63,7 +63,7 @@ static int amdgpu_update_cached_map(struct amdgpu_queue_mapper *mapper,
981 +
982 + static int amdgpu_identity_map(struct amdgpu_device *adev,
983 + struct amdgpu_queue_mapper *mapper,
984 +- int ring,
985 ++ u32 ring,
986 + struct amdgpu_ring **out_ring)
987 + {
988 + switch (mapper->hw_ip) {
989 +@@ -121,7 +121,7 @@ static enum amdgpu_ring_type amdgpu_hw_ip_to_ring_type(int hw_ip)
990 +
991 + static int amdgpu_lru_map(struct amdgpu_device *adev,
992 + struct amdgpu_queue_mapper *mapper,
993 +- int user_ring,
994 ++ u32 user_ring,
995 + struct amdgpu_ring **out_ring)
996 + {
997 + int r, i, j;
998 +@@ -208,7 +208,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
999 + */
1000 + int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
1001 + struct amdgpu_queue_mgr *mgr,
1002 +- int hw_ip, int instance, int ring,
1003 ++ u32 hw_ip, u32 instance, u32 ring,
1004 + struct amdgpu_ring **out_ring)
1005 + {
1006 + int r, ip_num_rings;
1007 +diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1008 +index 58e9e0601a61..faf17b83b910 100644
1009 +--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1010 ++++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1011 +@@ -210,7 +210,6 @@ static int fsl_dcu_drm_pm_suspend(struct device *dev)
1012 + return PTR_ERR(fsl_dev->state);
1013 + }
1014 +
1015 +- clk_disable_unprepare(fsl_dev->pix_clk);
1016 + clk_disable_unprepare(fsl_dev->clk);
1017 +
1018 + return 0;
1019 +@@ -233,6 +232,7 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
1020 + if (fsl_dev->tcon)
1021 + fsl_tcon_bypass_enable(fsl_dev->tcon);
1022 + fsl_dcu_drm_init_planes(fsl_dev->drm);
1023 ++ enable_irq(fsl_dev->irq);
1024 + drm_atomic_helper_resume(fsl_dev->drm, fsl_dev->state);
1025 +
1026 + console_lock();
1027 +@@ -240,7 +240,6 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
1028 + console_unlock();
1029 +
1030 + drm_kms_helper_poll_enable(fsl_dev->drm);
1031 +- enable_irq(fsl_dev->irq);
1032 +
1033 + return 0;
1034 + }
1035 +diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
1036 +index 4efa2bd4f6d8..fa613bd209e3 100644
1037 +--- a/drivers/hwmon/pmbus/pmbus.h
1038 ++++ b/drivers/hwmon/pmbus/pmbus.h
1039 +@@ -404,9 +404,9 @@ extern const struct regulator_ops pmbus_regulator_ops;
1040 + /* Function declarations */
1041 +
1042 + void pmbus_clear_cache(struct i2c_client *client);
1043 +-int pmbus_set_page(struct i2c_client *client, u8 page);
1044 +-int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg);
1045 +-int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word);
1046 ++int pmbus_set_page(struct i2c_client *client, int page);
1047 ++int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg);
1048 ++int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word);
1049 + int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
1050 + int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
1051 + int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
1052 +diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
1053 +index 302f0aef59de..52a58b8b6e1b 100644
1054 +--- a/drivers/hwmon/pmbus/pmbus_core.c
1055 ++++ b/drivers/hwmon/pmbus/pmbus_core.c
1056 +@@ -136,13 +136,13 @@ void pmbus_clear_cache(struct i2c_client *client)
1057 + }
1058 + EXPORT_SYMBOL_GPL(pmbus_clear_cache);
1059 +
1060 +-int pmbus_set_page(struct i2c_client *client, u8 page)
1061 ++int pmbus_set_page(struct i2c_client *client, int page)
1062 + {
1063 + struct pmbus_data *data = i2c_get_clientdata(client);
1064 + int rv = 0;
1065 + int newpage;
1066 +
1067 +- if (page != data->currpage) {
1068 ++ if (page >= 0 && page != data->currpage) {
1069 + rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
1070 + newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
1071 + if (newpage != page)
1072 +@@ -158,11 +158,9 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
1073 + {
1074 + int rv;
1075 +
1076 +- if (page >= 0) {
1077 +- rv = pmbus_set_page(client, page);
1078 +- if (rv < 0)
1079 +- return rv;
1080 +- }
1081 ++ rv = pmbus_set_page(client, page);
1082 ++ if (rv < 0)
1083 ++ return rv;
1084 +
1085 + return i2c_smbus_write_byte(client, value);
1086 + }
1087 +@@ -186,7 +184,8 @@ static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value)
1088 + return pmbus_write_byte(client, page, value);
1089 + }
1090 +
1091 +-int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word)
1092 ++int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
1093 ++ u16 word)
1094 + {
1095 + int rv;
1096 +
1097 +@@ -219,7 +218,7 @@ static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg,
1098 + return pmbus_write_word_data(client, page, reg, word);
1099 + }
1100 +
1101 +-int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg)
1102 ++int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg)
1103 + {
1104 + int rv;
1105 +
1106 +@@ -255,11 +254,9 @@ int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
1107 + {
1108 + int rv;
1109 +
1110 +- if (page >= 0) {
1111 +- rv = pmbus_set_page(client, page);
1112 +- if (rv < 0)
1113 +- return rv;
1114 +- }
1115 ++ rv = pmbus_set_page(client, page);
1116 ++ if (rv < 0)
1117 ++ return rv;
1118 +
1119 + return i2c_smbus_read_byte_data(client, reg);
1120 + }
1121 +diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
1122 +index e0dc20488335..9ac2fb032df6 100644
1123 +--- a/drivers/iio/adc/ti-ads1015.c
1124 ++++ b/drivers/iio/adc/ti-ads1015.c
1125 +@@ -369,6 +369,7 @@ int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
1126 +
1127 + conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]);
1128 + conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]);
1129 ++ conv_time += conv_time / 10; /* 10% internal clock inaccuracy */
1130 + usleep_range(conv_time, conv_time + 1);
1131 + data->conv_invalid = false;
1132 + }
1133 +diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
1134 +index 37ba007f8dca..74831fcd0313 100644
1135 +--- a/drivers/iio/multiplexer/iio-mux.c
1136 ++++ b/drivers/iio/multiplexer/iio-mux.c
1137 +@@ -285,6 +285,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
1138 + child->ext_info_cache = devm_kzalloc(dev,
1139 + sizeof(*child->ext_info_cache) *
1140 + num_ext_info, GFP_KERNEL);
1141 ++ if (!child->ext_info_cache)
1142 ++ return -ENOMEM;
1143 ++
1144 + for (i = 0; i < num_ext_info; ++i) {
1145 + child->ext_info_cache[i].size = -1;
1146 +
1147 +@@ -309,6 +312,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
1148 +
1149 + child->ext_info_cache[i].data = devm_kmemdup(dev, page, ret + 1,
1150 + GFP_KERNEL);
1151 ++ if (!child->ext_info_cache[i].data)
1152 ++ return -ENOMEM;
1153 ++
1154 + child->ext_info_cache[i].data[ret] = 0;
1155 + child->ext_info_cache[i].size = ret;
1156 + }
1157 +diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
1158 +index fc73e56eb1e2..92c483ec6cb2 100644
1159 +--- a/drivers/mmc/host/sdhci-msm.c
1160 ++++ b/drivers/mmc/host/sdhci-msm.c
1161 +@@ -1251,6 +1251,21 @@ static int sdhci_msm_probe(struct platform_device *pdev)
1162 + CORE_VENDOR_SPEC_CAPABILITIES0);
1163 + }
1164 +
1165 ++ /*
1166 ++ * Power on reset state may trigger power irq if previous status of
1167 ++ * PWRCTL was either BUS_ON or IO_HIGH_V. So before enabling pwr irq
1168 ++ * interrupt in GIC, any pending power irq interrupt should be
1169 ++ * acknowledged. Otherwise power irq interrupt handler would be
1170 ++ * fired prematurely.
1171 ++ */
1172 ++ sdhci_msm_voltage_switch(host);
1173 ++
1174 ++ /*
1175 ++ * Ensure that above writes are propogated before interrupt enablement
1176 ++ * in GIC.
1177 ++ */
1178 ++ mb();
1179 ++
1180 + /* Setup IRQ for handling power/voltage tasks with PMIC */
1181 + msm_host->pwr_irq = platform_get_irq_byname(pdev, "pwr_irq");
1182 + if (msm_host->pwr_irq < 0) {
1183 +@@ -1260,6 +1275,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
1184 + goto clk_disable;
1185 + }
1186 +
1187 ++ /* Enable pwr irq interrupts */
1188 ++ writel_relaxed(INT_MASK, msm_host->core_mem + CORE_PWRCTL_MASK);
1189 ++
1190 + ret = devm_request_threaded_irq(&pdev->dev, msm_host->pwr_irq, NULL,
1191 + sdhci_msm_pwr_irq, IRQF_ONESHOT,
1192 + dev_name(&pdev->dev), host);
1193 +diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
1194 +index 9c4e6199b854..3a6d49f07e22 100644
1195 +--- a/drivers/mmc/host/tmio_mmc_core.c
1196 ++++ b/drivers/mmc/host/tmio_mmc_core.c
1197 +@@ -1113,8 +1113,11 @@ static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
1198 + {
1199 + struct tmio_mmc_data *pdata = host->pdata;
1200 + struct mmc_host *mmc = host->mmc;
1201 ++ int err;
1202 +
1203 +- mmc_regulator_get_supply(mmc);
1204 ++ err = mmc_regulator_get_supply(mmc);
1205 ++ if (err)
1206 ++ return err;
1207 +
1208 + /* use ocr_mask if no regulator */
1209 + if (!mmc->ocr_avail)
1210 +diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
1211 +index 34427a6a15af..362607f727ee 100644
1212 +--- a/drivers/pci/dwc/pci-dra7xx.c
1213 ++++ b/drivers/pci/dwc/pci-dra7xx.c
1214 +@@ -11,6 +11,7 @@
1215 + */
1216 +
1217 + #include <linux/delay.h>
1218 ++#include <linux/device.h>
1219 + #include <linux/err.h>
1220 + #include <linux/interrupt.h>
1221 + #include <linux/irq.h>
1222 +@@ -594,6 +595,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
1223 + int i;
1224 + int phy_count;
1225 + struct phy **phy;
1226 ++ struct device_link **link;
1227 + void __iomem *base;
1228 + struct resource *res;
1229 + struct dw_pcie *pci;
1230 +@@ -649,11 +651,21 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
1231 + if (!phy)
1232 + return -ENOMEM;
1233 +
1234 ++ link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
1235 ++ if (!link)
1236 ++ return -ENOMEM;
1237 ++
1238 + for (i = 0; i < phy_count; i++) {
1239 + snprintf(name, sizeof(name), "pcie-phy%d", i);
1240 + phy[i] = devm_phy_get(dev, name);
1241 + if (IS_ERR(phy[i]))
1242 + return PTR_ERR(phy[i]);
1243 ++
1244 ++ link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
1245 ++ if (!link[i]) {
1246 ++ ret = -EINVAL;
1247 ++ goto err_link;
1248 ++ }
1249 + }
1250 +
1251 + dra7xx->base = base;
1252 +@@ -732,6 +744,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
1253 + pm_runtime_disable(dev);
1254 + dra7xx_pcie_disable_phy(dra7xx);
1255 +
1256 ++err_link:
1257 ++ while (--i >= 0)
1258 ++ device_link_del(link[i]);
1259 ++
1260 + return ret;
1261 + }
1262 +
1263 +diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
1264 +index f20b4d66c75f..4a39b54732d0 100644
1265 +--- a/drivers/s390/cio/vfio_ccw_cp.c
1266 ++++ b/drivers/s390/cio/vfio_ccw_cp.c
1267 +@@ -330,6 +330,8 @@ static void ccwchain_cda_free(struct ccwchain *chain, int idx)
1268 + {
1269 + struct ccw1 *ccw = chain->ch_ccw + idx;
1270 +
1271 ++ if (ccw_is_test(ccw) || ccw_is_noop(ccw) || ccw_is_tic(ccw))
1272 ++ return;
1273 + if (!ccw->count)
1274 + return;
1275 +
1276 +diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
1277 +index 6ab4c7700228..68cfc351b47f 100644
1278 +--- a/drivers/spi/spi-axi-spi-engine.c
1279 ++++ b/drivers/spi/spi-axi-spi-engine.c
1280 +@@ -553,7 +553,7 @@ static int spi_engine_probe(struct platform_device *pdev)
1281 +
1282 + static int spi_engine_remove(struct platform_device *pdev)
1283 + {
1284 +- struct spi_master *master = platform_get_drvdata(pdev);
1285 ++ struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
1286 + struct spi_engine *spi_engine = spi_master_get_devdata(master);
1287 + int irq = platform_get_irq(pdev, 0);
1288 +
1289 +@@ -561,6 +561,8 @@ static int spi_engine_remove(struct platform_device *pdev)
1290 +
1291 + free_irq(irq, master);
1292 +
1293 ++ spi_master_put(master);
1294 ++
1295 + writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
1296 + writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
1297 + writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
1298 +diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
1299 +index 0eb1e9583485..837bb95eea62 100644
1300 +--- a/drivers/spi/spi-sh-msiof.c
1301 ++++ b/drivers/spi/spi-sh-msiof.c
1302 +@@ -900,7 +900,7 @@ static int sh_msiof_transfer_one(struct spi_master *master,
1303 + break;
1304 + copy32 = copy_bswap32;
1305 + } else if (bits <= 16) {
1306 +- if (l & 1)
1307 ++ if (l & 3)
1308 + break;
1309 + copy32 = copy_wswap32;
1310 + } else {
1311 +diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
1312 +index 13291aeaf350..f72ca485c86f 100644
1313 +--- a/drivers/staging/ccree/ssi_hash.c
1314 ++++ b/drivers/staging/ccree/ssi_hash.c
1315 +@@ -1790,9 +1790,12 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in)
1316 + }
1317 + in += sizeof(u32);
1318 +
1319 +- rc = ssi_hash_init(state, ctx);
1320 +- if (rc)
1321 +- goto out;
1322 ++ /* call init() to allocate bufs if the user hasn't */
1323 ++ if (!state->digest_buff) {
1324 ++ rc = ssi_hash_init(state, ctx);
1325 ++ if (rc)
1326 ++ goto out;
1327 ++ }
1328 +
1329 + dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr,
1330 + ctx->inter_digestsize, DMA_BIDIRECTIONAL);
1331 +diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
1332 +index 26017fe9df93..8e84b2e7f5bd 100644
1333 +--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
1334 ++++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
1335 +@@ -131,6 +131,8 @@ static struct sk_buff *build_linear_skb(struct dpaa2_eth_priv *priv,
1336 + u16 fd_offset = dpaa2_fd_get_offset(fd);
1337 + u32 fd_length = dpaa2_fd_get_len(fd);
1338 +
1339 ++ ch->buf_count--;
1340 ++
1341 + skb = build_skb(fd_vaddr, DPAA2_ETH_RX_BUF_SIZE +
1342 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
1343 + if (unlikely(!skb))
1344 +@@ -139,8 +141,6 @@ static struct sk_buff *build_linear_skb(struct dpaa2_eth_priv *priv,
1345 + skb_reserve(skb, fd_offset);
1346 + skb_put(skb, fd_length);
1347 +
1348 +- ch->buf_count--;
1349 +-
1350 + return skb;
1351 + }
1352 +
1353 +@@ -178,8 +178,15 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv *priv,
1354 + /* We build the skb around the first data buffer */
1355 + skb = build_skb(sg_vaddr, DPAA2_ETH_RX_BUF_SIZE +
1356 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
1357 +- if (unlikely(!skb))
1358 +- return NULL;
1359 ++ if (unlikely(!skb)) {
1360 ++ /* We still need to subtract the buffers used
1361 ++ * by this FD from our software counter
1362 ++ */
1363 ++ while (!dpaa2_sg_is_final(&sgt[i]) &&
1364 ++ i < DPAA2_ETH_MAX_SG_ENTRIES)
1365 ++ i++;
1366 ++ break;
1367 ++ }
1368 +
1369 + sg_offset = dpaa2_sg_get_offset(sge);
1370 + skb_reserve(skb, sg_offset);
1371 +diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
1372 +index f8096828f5b7..a609ec82daf3 100644
1373 +--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
1374 ++++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
1375 +@@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
1376 + if (d)
1377 + return d;
1378 +
1379 +- if (unlikely(cpu >= num_possible_cpus()))
1380 ++ if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus())
1381 + return NULL;
1382 +
1383 + /*
1384 +@@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
1385 + return NULL;
1386 +
1387 + /* check if CPU is out of range (-1 means any cpu) */
1388 +- if (desc->cpu >= num_possible_cpus()) {
1389 ++ if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) {
1390 + kfree(obj);
1391 + return NULL;
1392 + }
1393 +diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/drivers/staging/fsl-mc/include/dpaa2-io.h
1394 +index c5646096c5d4..afc2d060d077 100644
1395 +--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
1396 ++++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
1397 +@@ -54,6 +54,8 @@ struct device;
1398 + * for dequeue.
1399 + */
1400 +
1401 ++#define DPAA2_IO_ANY_CPU -1
1402 ++
1403 + /**
1404 + * struct dpaa2_io_desc - The DPIO descriptor
1405 + * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
1406 +@@ -91,8 +93,8 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
1407 + * @cb: The callback to be invoked when the notification arrives
1408 + * @is_cdan: Zero for FQDAN, non-zero for CDAN
1409 + * @id: FQID or channel ID, needed for rearm
1410 +- * @desired_cpu: The cpu on which the notifications will show up. -1 means
1411 +- * any CPU.
1412 ++ * @desired_cpu: The cpu on which the notifications will show up. Use
1413 ++ * DPAA2_IO_ANY_CPU if don't care
1414 + * @dpio_id: The dpio index
1415 + * @qman64: The 64-bit context value shows up in the FQDAN/CDAN.
1416 + * @node: The list node
1417 +diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
1418 +index 08e255884206..93e86798ec1c 100644
1419 +--- a/drivers/staging/greybus/loopback.c
1420 ++++ b/drivers/staging/greybus/loopback.c
1421 +@@ -1042,8 +1042,10 @@ static int gb_loopback_fn(void *data)
1422 + else if (type == GB_LOOPBACK_TYPE_SINK)
1423 + error = gb_loopback_async_sink(gb, size);
1424 +
1425 +- if (error)
1426 ++ if (error) {
1427 + gb->error++;
1428 ++ gb->iteration_count++;
1429 ++ }
1430 + } else {
1431 + /* We are effectively single threaded here */
1432 + if (type == GB_LOOPBACK_TYPE_PING)
1433 +diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
1434 +index f663e6c41f8a..f6d71587b803 100644
1435 +--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
1436 ++++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
1437 +@@ -106,10 +106,10 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
1438 +
1439 + void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
1440 + {
1441 +- rtw_free_mlme_priv_ie_data(pmlmepriv);
1442 +-
1443 +- if (pmlmepriv)
1444 ++ if (pmlmepriv) {
1445 ++ rtw_free_mlme_priv_ie_data(pmlmepriv);
1446 + vfree(pmlmepriv->free_bss_buf);
1447 ++ }
1448 + }
1449 +
1450 + struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)
1451 +diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.c b/drivers/staging/rtlwifi/phydm/phydm_dig.c
1452 +index 31a4f3fcad19..c88b9788363a 100644
1453 +--- a/drivers/staging/rtlwifi/phydm/phydm_dig.c
1454 ++++ b/drivers/staging/rtlwifi/phydm/phydm_dig.c
1455 +@@ -490,6 +490,8 @@ void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,
1456 + break;
1457 + }
1458 +
1459 ++ /* pin max_level to be >= 0 */
1460 ++ max_level = max_t(s8, 0, max_level);
1461 + /* write IGI of lower level */
1462 + odm_write_dig(dm, dig_tab->pause_dig_value[max_level]);
1463 + ODM_RT_TRACE(dm, ODM_COMP_DIG,
1464 +diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c
1465 +index 8e24da16752c..a2cc54866e79 100644
1466 +--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
1467 ++++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
1468 +@@ -419,7 +419,7 @@ static bool _rtl8822be_send_bcn_or_cmd_packet(struct ieee80211_hw *hw,
1469 + dma_addr = rtlpriv->cfg->ops->get_desc(
1470 + hw, (u8 *)pbd_desc, true, HW_DESC_TXBUFF_ADDR);
1471 +
1472 +- pci_unmap_single(rtlpci->pdev, dma_addr, skb->len,
1473 ++ pci_unmap_single(rtlpci->pdev, dma_addr, pskb->len,
1474 + PCI_DMA_TODEVICE);
1475 + kfree_skb(pskb);
1476 +
1477 +diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
1478 +index af72ec32e404..f135c1846477 100644
1479 +--- a/drivers/tty/serial/8250/8250_early.c
1480 ++++ b/drivers/tty/serial/8250/8250_early.c
1481 +@@ -125,12 +125,14 @@ static void __init init_port(struct earlycon_device *device)
1482 + serial8250_early_out(port, UART_FCR, 0); /* no fifo */
1483 + serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */
1484 +
1485 +- divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
1486 +- c = serial8250_early_in(port, UART_LCR);
1487 +- serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
1488 +- serial8250_early_out(port, UART_DLL, divisor & 0xff);
1489 +- serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff);
1490 +- serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB);
1491 ++ if (port->uartclk && device->baud) {
1492 ++ divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
1493 ++ c = serial8250_early_in(port, UART_LCR);
1494 ++ serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
1495 ++ serial8250_early_out(port, UART_DLL, divisor & 0xff);
1496 ++ serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff);
1497 ++ serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB);
1498 ++ }
1499 + }
1500 +
1501 + int __init early_serial8250_setup(struct earlycon_device *device,
1502 +diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
1503 +index 4bd376c08b59..ba4af5434b91 100644
1504 +--- a/drivers/tty/serial/8250/8250_fintek.c
1505 ++++ b/drivers/tty/serial/8250/8250_fintek.c
1506 +@@ -211,7 +211,7 @@ static int fintek_8250_rs485_config(struct uart_port *port,
1507 +
1508 + if ((!!(rs485->flags & SER_RS485_RTS_ON_SEND)) ==
1509 + (!!(rs485->flags & SER_RS485_RTS_AFTER_SEND)))
1510 +- rs485->flags &= SER_RS485_ENABLED;
1511 ++ rs485->flags &= ~SER_RS485_ENABLED;
1512 + else
1513 + config |= RS485_URA;
1514 +
1515 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
1516 +index 0c101a7470b0..d4e7be88e0da 100644
1517 +--- a/drivers/tty/serial/8250/8250_pci.c
1518 ++++ b/drivers/tty/serial/8250/8250_pci.c
1519 +@@ -5137,6 +5137,9 @@ static const struct pci_device_id serial_pci_tbl[] = {
1520 + { PCI_DEVICE(0x1601, 0x0800), .driver_data = pbn_b0_4_1250000 },
1521 + { PCI_DEVICE(0x1601, 0xa801), .driver_data = pbn_b0_4_1250000 },
1522 +
1523 ++ /* Amazon PCI serial device */
1524 ++ { PCI_DEVICE(0x1d0f, 0x8250), .driver_data = pbn_b0_1_115200 },
1525 ++
1526 + /*
1527 + * These entries match devices with class COMMUNICATION_SERIAL,
1528 + * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
1529 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
1530 +index f0cc04f62b67..8dcfd4978a03 100644
1531 +--- a/drivers/tty/serial/8250/8250_port.c
1532 ++++ b/drivers/tty/serial/8250/8250_port.c
1533 +@@ -2586,8 +2586,11 @@ static void serial8250_set_divisor(struct uart_port *port, unsigned int baud,
1534 + serial_dl_write(up, quot);
1535 +
1536 + /* XR17V35x UARTs have an extra fractional divisor register (DLD) */
1537 +- if (up->port.type == PORT_XR17V35X)
1538 ++ if (up->port.type == PORT_XR17V35X) {
1539 ++ /* Preserve bits not related to baudrate; DLD[7:4]. */
1540 ++ quot_frac |= serial_port_in(port, 0x2) & 0xf0;
1541 + serial_port_out(port, 0x2, quot_frac);
1542 ++ }
1543 + }
1544 +
1545 + static unsigned int serial8250_get_baud_rate(struct uart_port *port,
1546 +diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
1547 +index dfeff3951f93..3657d745e90f 100644
1548 +--- a/drivers/tty/serial/imx.c
1549 ++++ b/drivers/tty/serial/imx.c
1550 +@@ -334,7 +334,8 @@ static void imx_port_rts_active(struct imx_port *sport, unsigned long *ucr2)
1551 + {
1552 + *ucr2 &= ~(UCR2_CTSC | UCR2_CTS);
1553 +
1554 +- mctrl_gpio_set(sport->gpios, sport->port.mctrl | TIOCM_RTS);
1555 ++ sport->port.mctrl |= TIOCM_RTS;
1556 ++ mctrl_gpio_set(sport->gpios, sport->port.mctrl);
1557 + }
1558 +
1559 + static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
1560 +@@ -342,7 +343,8 @@ static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
1561 + *ucr2 &= ~UCR2_CTSC;
1562 + *ucr2 |= UCR2_CTS;
1563 +
1564 +- mctrl_gpio_set(sport->gpios, sport->port.mctrl & ~TIOCM_RTS);
1565 ++ sport->port.mctrl &= ~TIOCM_RTS;
1566 ++ mctrl_gpio_set(sport->gpios, sport->port.mctrl);
1567 + }
1568 +
1569 + static void imx_port_rts_auto(struct imx_port *sport, unsigned long *ucr2)
1570 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
1571 +index 784dd42002ea..761b9f5f1491 100644
1572 +--- a/drivers/tty/serial/sh-sci.c
1573 ++++ b/drivers/tty/serial/sh-sci.c
1574 +@@ -1491,6 +1491,14 @@ static void sci_request_dma(struct uart_port *port)
1575 + return;
1576 +
1577 + s->cookie_tx = -EINVAL;
1578 ++
1579 ++ /*
1580 ++ * Don't request a dma channel if no channel was specified
1581 ++ * in the device tree.
1582 ++ */
1583 ++ if (!of_find_property(port->dev->of_node, "dmas", NULL))
1584 ++ return;
1585 ++
1586 + chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV);
1587 + dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan);
1588 + if (chan) {
1589 +diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
1590 +index d008f5a75197..377b3592384e 100644
1591 +--- a/drivers/tty/sysrq.c
1592 ++++ b/drivers/tty/sysrq.c
1593 +@@ -246,8 +246,10 @@ static void sysrq_handle_showallcpus(int key)
1594 + * architecture has no support for it:
1595 + */
1596 + if (!trigger_all_cpu_backtrace()) {
1597 +- struct pt_regs *regs = get_irq_regs();
1598 ++ struct pt_regs *regs = NULL;
1599 +
1600 ++ if (in_irq())
1601 ++ regs = get_irq_regs();
1602 + if (regs) {
1603 + pr_info("CPU%d:\n", smp_processor_id());
1604 + show_regs(regs);
1605 +@@ -266,7 +268,10 @@ static struct sysrq_key_op sysrq_showallcpus_op = {
1606 +
1607 + static void sysrq_handle_showregs(int key)
1608 + {
1609 +- struct pt_regs *regs = get_irq_regs();
1610 ++ struct pt_regs *regs = NULL;
1611 ++
1612 ++ if (in_irq())
1613 ++ regs = get_irq_regs();
1614 + if (regs)
1615 + show_regs(regs);
1616 + perf_event_print_debug();
1617 +diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
1618 +index 4aa5195db8ea..e02acfb1ca95 100644
1619 +--- a/drivers/usb/common/ulpi.c
1620 ++++ b/drivers/usb/common/ulpi.c
1621 +@@ -183,9 +183,9 @@ static int ulpi_of_register(struct ulpi *ulpi)
1622 + /* Find a ulpi bus underneath the parent or the grandparent */
1623 + parent = ulpi->dev.parent;
1624 + if (parent->of_node)
1625 +- np = of_find_node_by_name(parent->of_node, "ulpi");
1626 ++ np = of_get_child_by_name(parent->of_node, "ulpi");
1627 + else if (parent->parent && parent->parent->of_node)
1628 +- np = of_find_node_by_name(parent->parent->of_node, "ulpi");
1629 ++ np = of_get_child_by_name(parent->parent->of_node, "ulpi");
1630 + if (!np)
1631 + return 0;
1632 +
1633 +diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
1634 +index 883549ee946c..c42a3e63eb07 100644
1635 +--- a/drivers/usb/core/config.c
1636 ++++ b/drivers/usb/core/config.c
1637 +@@ -905,14 +905,25 @@ void usb_release_bos_descriptor(struct usb_device *dev)
1638 + }
1639 + }
1640 +
1641 ++static const __u8 bos_desc_len[256] = {
1642 ++ [USB_CAP_TYPE_WIRELESS_USB] = USB_DT_USB_WIRELESS_CAP_SIZE,
1643 ++ [USB_CAP_TYPE_EXT] = USB_DT_USB_EXT_CAP_SIZE,
1644 ++ [USB_SS_CAP_TYPE] = USB_DT_USB_SS_CAP_SIZE,
1645 ++ [USB_SSP_CAP_TYPE] = USB_DT_USB_SSP_CAP_SIZE(1),
1646 ++ [CONTAINER_ID_TYPE] = USB_DT_USB_SS_CONTN_ID_SIZE,
1647 ++ [USB_PTM_CAP_TYPE] = USB_DT_USB_PTM_ID_SIZE,
1648 ++};
1649 ++
1650 + /* Get BOS descriptor set */
1651 + int usb_get_bos_descriptor(struct usb_device *dev)
1652 + {
1653 + struct device *ddev = &dev->dev;
1654 + struct usb_bos_descriptor *bos;
1655 + struct usb_dev_cap_header *cap;
1656 ++ struct usb_ssp_cap_descriptor *ssp_cap;
1657 + unsigned char *buffer;
1658 +- int length, total_len, num, i;
1659 ++ int length, total_len, num, i, ssac;
1660 ++ __u8 cap_type;
1661 + int ret;
1662 +
1663 + bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);
1664 +@@ -965,7 +976,13 @@ int usb_get_bos_descriptor(struct usb_device *dev)
1665 + dev->bos->desc->bNumDeviceCaps = i;
1666 + break;
1667 + }
1668 ++ cap_type = cap->bDevCapabilityType;
1669 + length = cap->bLength;
1670 ++ if (bos_desc_len[cap_type] && length < bos_desc_len[cap_type]) {
1671 ++ dev->bos->desc->bNumDeviceCaps = i;
1672 ++ break;
1673 ++ }
1674 ++
1675 + total_len -= length;
1676 +
1677 + if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
1678 +@@ -973,7 +990,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
1679 + continue;
1680 + }
1681 +
1682 +- switch (cap->bDevCapabilityType) {
1683 ++ switch (cap_type) {
1684 + case USB_CAP_TYPE_WIRELESS_USB:
1685 + /* Wireless USB cap descriptor is handled by wusb */
1686 + break;
1687 +@@ -986,8 +1003,11 @@ int usb_get_bos_descriptor(struct usb_device *dev)
1688 + (struct usb_ss_cap_descriptor *)buffer;
1689 + break;
1690 + case USB_SSP_CAP_TYPE:
1691 +- dev->bos->ssp_cap =
1692 +- (struct usb_ssp_cap_descriptor *)buffer;
1693 ++ ssp_cap = (struct usb_ssp_cap_descriptor *)buffer;
1694 ++ ssac = (le32_to_cpu(ssp_cap->bmAttributes) &
1695 ++ USB_SSP_SUBLINK_SPEED_ATTRIBS) + 1;
1696 ++ if (length >= USB_DT_USB_SSP_CAP_SIZE(ssac))
1697 ++ dev->bos->ssp_cap = ssp_cap;
1698 + break;
1699 + case CONTAINER_ID_TYPE:
1700 + dev->bos->ss_id =
1701 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1702 +index 98c666ef9a57..ab245352f102 100644
1703 +--- a/drivers/usb/core/devio.c
1704 ++++ b/drivers/usb/core/devio.c
1705 +@@ -1455,14 +1455,18 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1706 + int number_of_packets = 0;
1707 + unsigned int stream_id = 0;
1708 + void *buf;
1709 +-
1710 +- if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
1711 +- USBDEVFS_URB_SHORT_NOT_OK |
1712 ++ unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK |
1713 + USBDEVFS_URB_BULK_CONTINUATION |
1714 + USBDEVFS_URB_NO_FSBR |
1715 + USBDEVFS_URB_ZERO_PACKET |
1716 +- USBDEVFS_URB_NO_INTERRUPT))
1717 +- return -EINVAL;
1718 ++ USBDEVFS_URB_NO_INTERRUPT;
1719 ++ /* USBDEVFS_URB_ISO_ASAP is a special case */
1720 ++ if (uurb->type == USBDEVFS_URB_TYPE_ISO)
1721 ++ mask |= USBDEVFS_URB_ISO_ASAP;
1722 ++
1723 ++ if (uurb->flags & ~mask)
1724 ++ return -EINVAL;
1725 ++
1726 + if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
1727 + return -EINVAL;
1728 + if (uurb->buffer_length > 0 && !uurb->buffer)
1729 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
1730 +index e9ce6bb0b22d..8f7d94239ee3 100644
1731 +--- a/drivers/usb/core/hub.c
1732 ++++ b/drivers/usb/core/hub.c
1733 +@@ -4935,6 +4935,15 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
1734 + usb_put_dev(udev);
1735 + if ((status == -ENOTCONN) || (status == -ENOTSUPP))
1736 + break;
1737 ++
1738 ++ /* When halfway through our retry count, power-cycle the port */
1739 ++ if (i == (SET_CONFIG_TRIES / 2) - 1) {
1740 ++ dev_info(&port_dev->dev, "attempt power cycle\n");
1741 ++ usb_hub_set_port_power(hdev, hub, port1, false);
1742 ++ msleep(2 * hub_power_on_good_delay(hub));
1743 ++ usb_hub_set_port_power(hdev, hub, port1, true);
1744 ++ msleep(hub_power_on_good_delay(hub));
1745 ++ }
1746 + }
1747 + if (hub->hdev->parent ||
1748 + !hcd->driver->port_handed_over ||
1749 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1750 +index 37c418e581fb..50010282c010 100644
1751 +--- a/drivers/usb/core/quirks.c
1752 ++++ b/drivers/usb/core/quirks.c
1753 +@@ -151,6 +151,9 @@ static const struct usb_device_id usb_quirk_list[] = {
1754 + /* appletouch */
1755 + { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
1756 +
1757 ++ /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
1758 ++ { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
1759 ++
1760 + /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
1761 + { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
1762 +
1763 +diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
1764 +index cbb9b8e12c3c..8c5a6fee4dfd 100644
1765 +--- a/drivers/usb/host/ehci-dbg.c
1766 ++++ b/drivers/usb/host/ehci-dbg.c
1767 +@@ -837,7 +837,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
1768 + default: /* unknown */
1769 + break;
1770 + }
1771 +- temp = (cap >> 8) & 0xff;
1772 ++ offset = (cap >> 8) & 0xff;
1773 + }
1774 + }
1775 + #endif
1776 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
1777 +index 2a82c927ded2..97f30eb7dac0 100644
1778 +--- a/drivers/usb/host/xhci-mem.c
1779 ++++ b/drivers/usb/host/xhci-mem.c
1780 +@@ -947,6 +947,12 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
1781 + if (!vdev)
1782 + return;
1783 +
1784 ++ if (vdev->real_port == 0 ||
1785 ++ vdev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) {
1786 ++ xhci_dbg(xhci, "Bad vdev->real_port.\n");
1787 ++ goto out;
1788 ++ }
1789 ++
1790 + tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
1791 + list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
1792 + /* is this a hub device that added a tt_info to the tts list */
1793 +@@ -960,6 +966,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
1794 + }
1795 + }
1796 + }
1797 ++out:
1798 + /* we are now at a leaf device */
1799 + xhci_free_virt_device(xhci, slot_id);
1800 + }
1801 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
1802 +index 82c746e2d85c..353520005c13 100644
1803 +--- a/drivers/usb/host/xhci-ring.c
1804 ++++ b/drivers/usb/host/xhci-ring.c
1805 +@@ -2486,12 +2486,16 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1806 + */
1807 + if (list_empty(&ep_ring->td_list)) {
1808 + /*
1809 +- * A stopped endpoint may generate an extra completion
1810 +- * event if the device was suspended. Don't print
1811 +- * warnings.
1812 ++ * Don't print wanings if it's due to a stopped endpoint
1813 ++ * generating an extra completion event if the device
1814 ++ * was suspended. Or, a event for the last TRB of a
1815 ++ * short TD we already got a short event for.
1816 ++ * The short TD is already removed from the TD list.
1817 + */
1818 ++
1819 + if (!(trb_comp_code == COMP_STOPPED ||
1820 +- trb_comp_code == COMP_STOPPED_LENGTH_INVALID)) {
1821 ++ trb_comp_code == COMP_STOPPED_LENGTH_INVALID ||
1822 ++ ep_ring->last_td_was_short)) {
1823 + xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n",
1824 + TRB_TO_SLOT_ID(le32_to_cpu(event->flags)),
1825 + ep_index);
1826 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
1827 +index 51535ba2bcd4..e5677700dea4 100644
1828 +--- a/drivers/usb/host/xhci.c
1829 ++++ b/drivers/usb/host/xhci.c
1830 +@@ -3583,10 +3583,9 @@ int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command,
1831 + state = readl(&xhci->op_regs->status);
1832 + if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
1833 + (xhci->xhc_state & XHCI_STATE_HALTED)) {
1834 +- xhci_free_virt_device(xhci, slot_id);
1835 + spin_unlock_irqrestore(&xhci->lock, flags);
1836 + kfree(command);
1837 +- return ret;
1838 ++ return -ENODEV;
1839 + }
1840 +
1841 + ret = xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT,
1842 +diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
1843 +index 99c65b0788ff..947579842ad7 100644
1844 +--- a/drivers/usb/mtu3/mtu3_core.c
1845 ++++ b/drivers/usb/mtu3/mtu3_core.c
1846 +@@ -774,9 +774,9 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
1847 + return -ENOMEM;
1848 +
1849 + mtu->irq = platform_get_irq(pdev, 0);
1850 +- if (mtu->irq <= 0) {
1851 ++ if (mtu->irq < 0) {
1852 + dev_err(dev, "fail to get irq number\n");
1853 +- return -ENODEV;
1854 ++ return mtu->irq;
1855 + }
1856 + dev_info(dev, "irq %d\n", mtu->irq);
1857 +
1858 +diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
1859 +index 8babd318c0ed..1ec00eae339a 100644
1860 +--- a/drivers/usb/phy/phy-tahvo.c
1861 ++++ b/drivers/usb/phy/phy-tahvo.c
1862 +@@ -368,7 +368,8 @@ static int tahvo_usb_probe(struct platform_device *pdev)
1863 + tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable);
1864 + if (IS_ERR(tu->extcon)) {
1865 + dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
1866 +- return -ENOMEM;
1867 ++ ret = PTR_ERR(tu->extcon);
1868 ++ goto err_disable_clk;
1869 + }
1870 +
1871 + ret = devm_extcon_dev_register(&pdev->dev, tu->extcon);
1872 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1873 +index ba672cf4e888..54e316b1892d 100644
1874 +--- a/drivers/usb/serial/option.c
1875 ++++ b/drivers/usb/serial/option.c
1876 +@@ -241,6 +241,7 @@ static void option_instat_callback(struct urb *urb);
1877 + /* These Quectel products use Quectel's vendor ID */
1878 + #define QUECTEL_PRODUCT_EC21 0x0121
1879 + #define QUECTEL_PRODUCT_EC25 0x0125
1880 ++#define QUECTEL_PRODUCT_BG96 0x0296
1881 +
1882 + #define CMOTECH_VENDOR_ID 0x16d8
1883 + #define CMOTECH_PRODUCT_6001 0x6001
1884 +@@ -1185,6 +1186,8 @@ static const struct usb_device_id option_ids[] = {
1885 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1886 + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
1887 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1888 ++ { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
1889 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1890 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
1891 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
1892 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
1893 +diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
1894 +index 48f285a1ad00..c593ca8800e5 100644
1895 +--- a/drivers/usb/serial/usb_debug.c
1896 ++++ b/drivers/usb/serial/usb_debug.c
1897 +@@ -34,12 +34,14 @@ static const struct usb_device_id id_table[] = {
1898 + };
1899 +
1900 + static const struct usb_device_id dbc_id_table[] = {
1901 ++ { USB_DEVICE(0x1d6b, 0x0010) },
1902 + { USB_DEVICE(0x1d6b, 0x0011) },
1903 + { },
1904 + };
1905 +
1906 + static const struct usb_device_id id_table_combined[] = {
1907 + { USB_DEVICE(0x0525, 0x127a) },
1908 ++ { USB_DEVICE(0x1d6b, 0x0010) },
1909 + { USB_DEVICE(0x1d6b, 0x0011) },
1910 + { },
1911 + };
1912 +diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
1913 +index 1fcd758a961f..3734a25e09e5 100644
1914 +--- a/drivers/usb/storage/uas-detect.h
1915 ++++ b/drivers/usb/storage/uas-detect.h
1916 +@@ -112,6 +112,10 @@ static int uas_use_uas_driver(struct usb_interface *intf,
1917 + }
1918 + }
1919 +
1920 ++ /* All Seagate disk enclosures have broken ATA pass-through support */
1921 ++ if (le16_to_cpu(udev->descriptor.idVendor) == 0x0bc2)
1922 ++ flags |= US_FL_NO_ATA_1X;
1923 ++
1924 + usb_stor_adjust_quirks(udev, &flags);
1925 +
1926 + if (flags & US_FL_IGNORE_UAS) {
1927 +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
1928 +index 11b9a22799cc..1f0cf81cc145 100644
1929 +--- a/drivers/usb/usbip/vhci_hcd.c
1930 ++++ b/drivers/usb/usbip/vhci_hcd.c
1931 +@@ -1112,7 +1112,6 @@ static int hcd_name_to_id(const char *name)
1932 + static int vhci_setup(struct usb_hcd *hcd)
1933 + {
1934 + struct vhci *vhci = *((void **)dev_get_platdata(hcd->self.controller));
1935 +- hcd->self.sg_tablesize = ~0;
1936 + if (usb_hcd_is_primary_hcd(hcd)) {
1937 + vhci->vhci_hcd_hs = hcd_to_vhci_hcd(hcd);
1938 + vhci->vhci_hcd_hs->vhci = vhci;
1939 +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
1940 +index 8acfc1e099e1..e549bff87c5b 100644
1941 +--- a/include/asm-generic/vmlinux.lds.h
1942 ++++ b/include/asm-generic/vmlinux.lds.h
1943 +@@ -459,6 +459,7 @@
1944 + #define TEXT_TEXT \
1945 + ALIGN_FUNCTION(); \
1946 + *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \
1947 ++ *(.text..refcount) \
1948 + *(.ref.text) \
1949 + MEM_KEEP(init.text) \
1950 + MEM_KEEP(exit.text) \
1951 +diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
1952 +index cec06625f407..8512777889b0 100644
1953 +--- a/include/uapi/linux/usb/ch9.h
1954 ++++ b/include/uapi/linux/usb/ch9.h
1955 +@@ -876,6 +876,8 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
1956 + __u8 bReserved;
1957 + } __attribute__((packed));
1958 +
1959 ++#define USB_DT_USB_WIRELESS_CAP_SIZE 11
1960 ++
1961 + /* USB 2.0 Extension descriptor */
1962 + #define USB_CAP_TYPE_EXT 2
1963 +
1964 +@@ -1068,6 +1070,7 @@ struct usb_ptm_cap_descriptor {
1965 + __u8 bDevCapabilityType;
1966 + } __attribute__((packed));
1967 +
1968 ++#define USB_DT_USB_PTM_ID_SIZE 3
1969 + /*
1970 + * The size of the descriptor for the Sublink Speed Attribute Count
1971 + * (SSAC) specified in bmAttributes[4:0].
1972 +diff --git a/kernel/events/core.c b/kernel/events/core.c
1973 +index 10cdb9c26b5d..4f1d4bfc607a 100644
1974 +--- a/kernel/events/core.c
1975 ++++ b/kernel/events/core.c
1976 +@@ -4433,6 +4433,8 @@ static int __perf_read_group_add(struct perf_event *leader,
1977 + if (ret)
1978 + return ret;
1979 +
1980 ++ raw_spin_lock_irqsave(&ctx->lock, flags);
1981 ++
1982 + /*
1983 + * Since we co-schedule groups, {enabled,running} times of siblings
1984 + * will be identical to those of the leader, so we only publish one
1985 +@@ -4455,8 +4457,6 @@ static int __perf_read_group_add(struct perf_event *leader,
1986 + if (read_format & PERF_FORMAT_ID)
1987 + values[n++] = primary_event_id(leader);
1988 +
1989 +- raw_spin_lock_irqsave(&ctx->lock, flags);
1990 +-
1991 + list_for_each_entry(sub, &leader->sibling_list, group_entry) {
1992 + values[n++] += perf_event_count(sub);
1993 + if (read_format & PERF_FORMAT_ID)
1994 +diff --git a/kernel/kprobes.c b/kernel/kprobes.c
1995 +index a1606a4224e1..a66e838640ea 100644
1996 +--- a/kernel/kprobes.c
1997 ++++ b/kernel/kprobes.c
1998 +@@ -573,13 +573,15 @@ static void kprobe_optimizer(struct work_struct *work)
1999 + do_unoptimize_kprobes();
2000 +
2001 + /*
2002 +- * Step 2: Wait for quiesence period to ensure all running interrupts
2003 +- * are done. Because optprobe may modify multiple instructions
2004 +- * there is a chance that Nth instruction is interrupted. In that
2005 +- * case, running interrupt can return to 2nd-Nth byte of jump
2006 +- * instruction. This wait is for avoiding it.
2007 ++ * Step 2: Wait for quiesence period to ensure all potentially
2008 ++ * preempted tasks to have normally scheduled. Because optprobe
2009 ++ * may modify multiple instructions, there is a chance that Nth
2010 ++ * instruction is preempted. In that case, such tasks can return
2011 ++ * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
2012 ++ * Note that on non-preemptive kernel, this is transparently converted
2013 ++ * to synchronoze_sched() to wait for all interrupts to have completed.
2014 + */
2015 +- synchronize_sched();
2016 ++ synchronize_rcu_tasks();
2017 +
2018 + /* Step 3: Optimize kprobes after quiesence period */
2019 + do_optimize_kprobes();
2020 +diff --git a/mm/gup.c b/mm/gup.c
2021 +index 165ba2174c75..e0d82b6706d7 100644
2022 +--- a/mm/gup.c
2023 ++++ b/mm/gup.c
2024 +@@ -1707,6 +1707,47 @@ static int gup_p4d_range(pgd_t pgd, unsigned long addr, unsigned long end,
2025 + return 1;
2026 + }
2027 +
2028 ++static void gup_pgd_range(unsigned long addr, unsigned long end,
2029 ++ int write, struct page **pages, int *nr)
2030 ++{
2031 ++ unsigned long next;
2032 ++ pgd_t *pgdp;
2033 ++
2034 ++ pgdp = pgd_offset(current->mm, addr);
2035 ++ do {
2036 ++ pgd_t pgd = READ_ONCE(*pgdp);
2037 ++
2038 ++ next = pgd_addr_end(addr, end);
2039 ++ if (pgd_none(pgd))
2040 ++ return;
2041 ++ if (unlikely(pgd_huge(pgd))) {
2042 ++ if (!gup_huge_pgd(pgd, pgdp, addr, next, write,
2043 ++ pages, nr))
2044 ++ return;
2045 ++ } else if (unlikely(is_hugepd(__hugepd(pgd_val(pgd))))) {
2046 ++ if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr,
2047 ++ PGDIR_SHIFT, next, write, pages, nr))
2048 ++ return;
2049 ++ } else if (!gup_p4d_range(pgd, addr, next, write, pages, nr))
2050 ++ return;
2051 ++ } while (pgdp++, addr = next, addr != end);
2052 ++}
2053 ++
2054 ++#ifndef gup_fast_permitted
2055 ++/*
2056 ++ * Check if it's allowed to use __get_user_pages_fast() for the range, or
2057 ++ * we need to fall back to the slow version:
2058 ++ */
2059 ++bool gup_fast_permitted(unsigned long start, int nr_pages, int write)
2060 ++{
2061 ++ unsigned long len, end;
2062 ++
2063 ++ len = (unsigned long) nr_pages << PAGE_SHIFT;
2064 ++ end = start + len;
2065 ++ return end >= start;
2066 ++}
2067 ++#endif
2068 ++
2069 + /*
2070 + * Like get_user_pages_fast() except it's IRQ-safe in that it won't fall back to
2071 + * the regular GUP. It will only return non-negative values.
2072 +@@ -1714,10 +1755,8 @@ static int gup_p4d_range(pgd_t pgd, unsigned long addr, unsigned long end,
2073 + int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
2074 + struct page **pages)
2075 + {
2076 +- struct mm_struct *mm = current->mm;
2077 + unsigned long addr, len, end;
2078 +- unsigned long next, flags;
2079 +- pgd_t *pgdp;
2080 ++ unsigned long flags;
2081 + int nr = 0;
2082 +
2083 + start &= PAGE_MASK;
2084 +@@ -1741,45 +1780,15 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
2085 + * block IPIs that come from THPs splitting.
2086 + */
2087 +
2088 +- local_irq_save(flags);
2089 +- pgdp = pgd_offset(mm, addr);
2090 +- do {
2091 +- pgd_t pgd = READ_ONCE(*pgdp);
2092 +-
2093 +- next = pgd_addr_end(addr, end);
2094 +- if (pgd_none(pgd))
2095 +- break;
2096 +- if (unlikely(pgd_huge(pgd))) {
2097 +- if (!gup_huge_pgd(pgd, pgdp, addr, next, write,
2098 +- pages, &nr))
2099 +- break;
2100 +- } else if (unlikely(is_hugepd(__hugepd(pgd_val(pgd))))) {
2101 +- if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr,
2102 +- PGDIR_SHIFT, next, write, pages, &nr))
2103 +- break;
2104 +- } else if (!gup_p4d_range(pgd, addr, next, write, pages, &nr))
2105 +- break;
2106 +- } while (pgdp++, addr = next, addr != end);
2107 +- local_irq_restore(flags);
2108 ++ if (gup_fast_permitted(start, nr_pages, write)) {
2109 ++ local_irq_save(flags);
2110 ++ gup_pgd_range(addr, end, write, pages, &nr);
2111 ++ local_irq_restore(flags);
2112 ++ }
2113 +
2114 + return nr;
2115 + }
2116 +
2117 +-#ifndef gup_fast_permitted
2118 +-/*
2119 +- * Check if it's allowed to use __get_user_pages_fast() for the range, or
2120 +- * we need to fall back to the slow version:
2121 +- */
2122 +-bool gup_fast_permitted(unsigned long start, int nr_pages, int write)
2123 +-{
2124 +- unsigned long len, end;
2125 +-
2126 +- len = (unsigned long) nr_pages << PAGE_SHIFT;
2127 +- end = start + len;
2128 +- return end >= start;
2129 +-}
2130 +-#endif
2131 +-
2132 + /**
2133 + * get_user_pages_fast() - pin user pages in memory
2134 + * @start: starting user address
2135 +@@ -1799,12 +1808,22 @@ bool gup_fast_permitted(unsigned long start, int nr_pages, int write)
2136 + int get_user_pages_fast(unsigned long start, int nr_pages, int write,
2137 + struct page **pages)
2138 + {
2139 ++ unsigned long addr, len, end;
2140 + int nr = 0, ret = 0;
2141 +
2142 + start &= PAGE_MASK;
2143 ++ addr = start;
2144 ++ len = (unsigned long) nr_pages << PAGE_SHIFT;
2145 ++ end = start + len;
2146 ++
2147 ++ if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
2148 ++ (void __user *)start, len)))
2149 ++ return 0;
2150 +
2151 + if (gup_fast_permitted(start, nr_pages, write)) {
2152 +- nr = __get_user_pages_fast(start, nr_pages, write, pages);
2153 ++ local_irq_disable();
2154 ++ gup_pgd_range(addr, end, write, pages, &nr);
2155 ++ local_irq_enable();
2156 + ret = nr;
2157 + }
2158 +
2159 +diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
2160 +index 2aebb7984437..ab70a395f490 100644
2161 +--- a/security/integrity/ima/ima_main.c
2162 ++++ b/security/integrity/ima/ima_main.c
2163 +@@ -51,6 +51,8 @@ static int __init hash_setup(char *str)
2164 + ima_hash_algo = HASH_ALGO_SHA1;
2165 + else if (strncmp(str, "md5", 3) == 0)
2166 + ima_hash_algo = HASH_ALGO_MD5;
2167 ++ else
2168 ++ return 1;
2169 + goto out;
2170 + }
2171 +
2172 +@@ -60,6 +62,8 @@ static int __init hash_setup(char *str)
2173 + break;
2174 + }
2175 + }
2176 ++ if (i == HASH_ALGO__LAST)
2177 ++ return 1;
2178 + out:
2179 + hash_setup_done = 1;
2180 + return 1;
2181 +diff --git a/tools/include/linux/poison.h b/tools/include/linux/poison.h
2182 +index 4bf6777a8a03..9fdcd3eaac3b 100644
2183 +--- a/tools/include/linux/poison.h
2184 ++++ b/tools/include/linux/poison.h
2185 +@@ -15,6 +15,10 @@
2186 + # define POISON_POINTER_DELTA 0
2187 + #endif
2188 +
2189 ++#ifdef __cplusplus
2190 ++#define LIST_POISON1 NULL
2191 ++#define LIST_POISON2 NULL
2192 ++#else
2193 + /*
2194 + * These are non-NULL pointers that will result in page faults
2195 + * under normal circumstances, used to verify that nobody uses
2196 +@@ -22,6 +26,7 @@
2197 + */
2198 + #define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA)
2199 + #define LIST_POISON2 ((void *) 0x200 + POISON_POINTER_DELTA)
2200 ++#endif
2201 +
2202 + /********** include/linux/timer.h **********/
2203 + /*
2204 +diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
2205 +index fd32ad08c6d4..d00aac51130d 100644
2206 +--- a/tools/perf/builtin-c2c.c
2207 ++++ b/tools/perf/builtin-c2c.c
2208 +@@ -2733,6 +2733,7 @@ static int perf_c2c__record(int argc, const char **argv)
2209 + if (!perf_mem_events[j].supported) {
2210 + pr_err("failed: event '%s' not supported\n",
2211 + perf_mem_events[j].name);
2212 ++ free(rec_argv);
2213 + return -1;
2214 + }
2215 +
2216 +diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
2217 +index 4db960085273..e15efba605f6 100644
2218 +--- a/tools/perf/builtin-mem.c
2219 ++++ b/tools/perf/builtin-mem.c
2220 +@@ -113,6 +113,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
2221 + if (!perf_mem_events[j].supported) {
2222 + pr_err("failed: event '%s' not supported\n",
2223 + perf_mem_events__name(j));
2224 ++ free(rec_argv);
2225 + return -1;
2226 + }
2227 +
2228 +diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
2229 +index 4e2e61695986..01de01ca14f2 100644
2230 +--- a/tools/perf/builtin-timechart.c
2231 ++++ b/tools/perf/builtin-timechart.c
2232 +@@ -1732,8 +1732,10 @@ static int timechart__io_record(int argc, const char **argv)
2233 + if (rec_argv == NULL)
2234 + return -ENOMEM;
2235 +
2236 +- if (asprintf(&filter, "common_pid != %d", getpid()) < 0)
2237 ++ if (asprintf(&filter, "common_pid != %d", getpid()) < 0) {
2238 ++ free(rec_argv);
2239 + return -ENOMEM;
2240 ++ }
2241 +
2242 + p = rec_argv;
2243 + for (i = 0; i < common_args_nr; i++)
2244 +diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
2245 +index d5d7fff1c211..8e3c4ec00017 100644
2246 +--- a/tools/perf/builtin-trace.c
2247 ++++ b/tools/perf/builtin-trace.c
2248 +@@ -2086,6 +2086,7 @@ static int trace__record(struct trace *trace, int argc, const char **argv)
2249 + rec_argv[j++] = "syscalls:sys_enter,syscalls:sys_exit";
2250 + else {
2251 + pr_err("Neither raw_syscalls nor syscalls events exist.\n");
2252 ++ free(rec_argv);
2253 + return -1;
2254 + }
2255 + }
2256 +diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
2257 +index c180bbcdbef6..0e1367f90af5 100644
2258 +--- a/tools/perf/tests/attr.c
2259 ++++ b/tools/perf/tests/attr.c
2260 +@@ -167,7 +167,7 @@ static int run_dir(const char *d, const char *perf)
2261 + snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
2262 + d, d, perf, vcnt, v);
2263 +
2264 +- return system(cmd);
2265 ++ return system(cmd) ? TEST_FAIL : TEST_OK;
2266 + }
2267 +
2268 + int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
2269 +diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
2270 +index 907b1b2f56ad..ff9b60b99f52 100644
2271 +--- a/tools/perf/tests/attr.py
2272 ++++ b/tools/perf/tests/attr.py
2273 +@@ -238,6 +238,7 @@ class Test(object):
2274 + # events in result. Fail if there's not any.
2275 + for exp_name, exp_event in expect.items():
2276 + exp_list = []
2277 ++ res_event = {}
2278 + log.debug(" matching [%s]" % exp_name)
2279 + for res_name, res_event in result.items():
2280 + log.debug(" to [%s]" % res_name)
2281 +@@ -254,7 +255,10 @@ class Test(object):
2282 + if exp_event.optional():
2283 + log.debug(" %s does not match, but is optional" % exp_name)
2284 + else:
2285 +- exp_event.diff(res_event)
2286 ++ if not res_event:
2287 ++ log.debug(" res_event is empty");
2288 ++ else:
2289 ++ exp_event.diff(res_event)
2290 + raise Fail(self, 'match failure');
2291 +
2292 + match[exp_name] = exp_list
2293 +diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
2294 +index 961e3ee26c27..2afc41a3730f 100644
2295 +--- a/tools/testing/selftests/x86/ldt_gdt.c
2296 ++++ b/tools/testing/selftests/x86/ldt_gdt.c
2297 +@@ -115,7 +115,15 @@ static void check_valid_segment(uint16_t index, int ldt,
2298 + return;
2299 + }
2300 +
2301 +- if (ar != expected_ar) {
2302 ++ /* The SDM says "bits 19:16 are undefined". Thanks. */
2303 ++ ar &= ~0xF0000;
2304 ++
2305 ++ /*
2306 ++ * NB: Different Linux versions do different things with the
2307 ++ * accessed bit in set_thread_area().
2308 ++ */
2309 ++ if (ar != expected_ar &&
2310 ++ (ldt || ar != (expected_ar | AR_ACCESSED))) {
2311 + printf("[FAIL]\t%s entry %hu has AR 0x%08X but expected 0x%08X\n",
2312 + (ldt ? "LDT" : "GDT"), index, ar, expected_ar);
2313 + nerrs++;
2314 +@@ -367,9 +375,24 @@ static void do_simple_tests(void)
2315 + install_invalid(&desc, false);
2316 +
2317 + desc.seg_not_present = 0;
2318 +- desc.read_exec_only = 0;
2319 + desc.seg_32bit = 1;
2320 ++ desc.read_exec_only = 0;
2321 ++ desc.limit = 0xfffff;
2322 ++
2323 + install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB);
2324 ++
2325 ++ desc.limit_in_pages = 1;
2326 ++
2327 ++ install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB | AR_G);
2328 ++ desc.read_exec_only = 1;
2329 ++ install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA | AR_S | AR_P | AR_DB | AR_G);
2330 ++ desc.contents = 1;
2331 ++ desc.read_exec_only = 0;
2332 ++ install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
2333 ++ desc.read_exec_only = 1;
2334 ++ install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
2335 ++
2336 ++ desc.limit = 0;
2337 + install_invalid(&desc, true);
2338 + }
2339 +
2340 +diff --git a/tools/usb/usbip/Makefile.am b/tools/usb/usbip/Makefile.am
2341 +index da3a430849a8..5961e9c18812 100644
2342 +--- a/tools/usb/usbip/Makefile.am
2343 ++++ b/tools/usb/usbip/Makefile.am
2344 +@@ -2,6 +2,7 @@
2345 + SUBDIRS := libsrc src
2346 + includedir = @includedir@/usbip
2347 + include_HEADERS := $(addprefix libsrc/, \
2348 +- usbip_common.h vhci_driver.h usbip_host_driver.h)
2349 ++ usbip_common.h vhci_driver.h usbip_host_driver.h \
2350 ++ list.h sysfs_utils.h usbip_host_common.h)
2351 +
2352 + dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8)
2353 +diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
2354 +index 5727dfb15a83..8a1cd1616de4 100644
2355 +--- a/tools/usb/usbip/libsrc/vhci_driver.c
2356 ++++ b/tools/usb/usbip/libsrc/vhci_driver.c
2357 +@@ -329,9 +329,17 @@ int usbip_vhci_refresh_device_list(void)
2358 + int usbip_vhci_get_free_port(uint32_t speed)
2359 + {
2360 + for (int i = 0; i < vhci_driver->nports; i++) {
2361 +- if (speed == USB_SPEED_SUPER &&
2362 +- vhci_driver->idev[i].hub != HUB_SPEED_SUPER)
2363 +- continue;
2364 ++
2365 ++ switch (speed) {
2366 ++ case USB_SPEED_SUPER:
2367 ++ if (vhci_driver->idev[i].hub != HUB_SPEED_SUPER)
2368 ++ continue;
2369 ++ break;
2370 ++ default:
2371 ++ if (vhci_driver->idev[i].hub != HUB_SPEED_HIGH)
2372 ++ continue;
2373 ++ break;
2374 ++ }
2375 +
2376 + if (vhci_driver->idev[i].status == VDEV_ST_NULL)
2377 + return vhci_driver->idev[i].port;