Magellan Linux

Annotation of /trunk/kernel-magellan/patches-4.14/0104-4.14.5-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


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