Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.9/0330-4.9.231-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3605 - (hide annotations) (download)
Thu Aug 13 10:21:44 2020 UTC (3 years, 10 months ago) by niro
File size: 85706 byte(s)
linux-231
1 niro 3605 diff --git a/Makefile b/Makefile
2     index e426d0c90188..1b1342a8785a 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 9
8     -SUBLEVEL = 230
9     +SUBLEVEL = 231
10     EXTRAVERSION =
11     NAME = Roaring Lionus
12    
13     diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
14     index aa2d6da9d187..12c74e826530 100644
15     --- a/arch/arc/include/asm/elf.h
16     +++ b/arch/arc/include/asm/elf.h
17     @@ -26,7 +26,7 @@
18     #define R_ARC_32_PCREL 0x31
19    
20     /*to set parameters in the core dumps */
21     -#define ELF_ARCH EM_ARCOMPACT
22     +#define ELF_ARCH EM_ARC_INUSE
23     #define ELF_CLASS ELFCLASS32
24    
25     #ifdef CONFIG_CPU_BIG_ENDIAN
26     diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
27     index 85d9ea4a0acc..705a68208423 100644
28     --- a/arch/arc/kernel/entry.S
29     +++ b/arch/arc/kernel/entry.S
30     @@ -156,7 +156,6 @@ END(EV_Extension)
31     tracesys:
32     ; save EFA in case tracer wants the PC of traced task
33     ; using ERET won't work since next-PC has already committed
34     - lr r12, [efa]
35     GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11
36     st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address
37    
38     @@ -199,15 +198,9 @@ tracesys_exit:
39     ; Breakpoint TRAP
40     ; ---------------------------------------------
41     trap_with_param:
42     -
43     - ; stop_pc info by gdb needs this info
44     - lr r0, [efa]
45     + mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc
46     mov r1, sp
47    
48     - ; Now that we have read EFA, it is safe to do "fake" rtie
49     - ; and get out of CPU exception mode
50     - FAKE_RET_FROM_EXCPN
51     -
52     ; Save callee regs in case gdb wants to have a look
53     ; SP will grow up by size of CALLEE Reg-File
54     ; NOTE: clobbers r12
55     @@ -234,6 +227,10 @@ ENTRY(EV_Trap)
56    
57     EXCEPTION_PROLOGUE
58    
59     + lr r12, [efa]
60     +
61     + FAKE_RET_FROM_EXCPN
62     +
63     ;============ TRAP 1 :breakpoints
64     ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR)
65     bmsk.f 0, r9, 7
66     @@ -241,9 +238,6 @@ ENTRY(EV_Trap)
67    
68     ;============ TRAP (no param): syscall top level
69    
70     - ; First return from Exception to pure K mode (Exception/IRQs renabled)
71     - FAKE_RET_FROM_EXCPN
72     -
73     ; If syscall tracing ongoing, invoke pre-post-hooks
74     GET_CURR_THR_INFO_FLAGS r10
75     btst r10, TIF_SYSCALL_TRACE
76     diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
77     index f0702d8063d9..9a2db3df5ede 100644
78     --- a/arch/arm/boot/dts/socfpga.dtsi
79     +++ b/arch/arm/boot/dts/socfpga.dtsi
80     @@ -676,7 +676,7 @@
81     };
82     };
83    
84     - L2: l2-cache@fffef000 {
85     + L2: cache-controller@fffef000 {
86     compatible = "arm,pl310-cache";
87     reg = <0xfffef000 0x1000>;
88     interrupts = <0 38 0x04>;
89     diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi b/arch/arm/boot/dts/socfpga_arria10.dtsi
90     index f520cbff5e1c..4d496479e135 100644
91     --- a/arch/arm/boot/dts/socfpga_arria10.dtsi
92     +++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
93     @@ -567,7 +567,7 @@
94     reg = <0xffcfb100 0x80>;
95     };
96    
97     - L2: l2-cache@fffff000 {
98     + L2: cache-controller@fffff000 {
99     compatible = "arm,pl310-cache";
100     reg = <0xfffff000 0x1000>;
101     interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>;
102     diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
103     index dd9eb3f14f45..6da26692f2fd 100644
104     --- a/arch/arm/mach-imx/pm-imx6.c
105     +++ b/arch/arm/mach-imx/pm-imx6.c
106     @@ -481,14 +481,14 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
107     if (!ocram_pool) {
108     pr_warn("%s: ocram pool unavailable!\n", __func__);
109     ret = -ENODEV;
110     - goto put_node;
111     + goto put_device;
112     }
113    
114     ocram_base = gen_pool_alloc(ocram_pool, MX6Q_SUSPEND_OCRAM_SIZE);
115     if (!ocram_base) {
116     pr_warn("%s: unable to alloc ocram!\n", __func__);
117     ret = -ENOMEM;
118     - goto put_node;
119     + goto put_device;
120     }
121    
122     ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base);
123     @@ -511,7 +511,7 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
124     ret = imx6_pm_get_base(&pm_info->mmdc_base, socdata->mmdc_compat);
125     if (ret) {
126     pr_warn("%s: failed to get mmdc base %d!\n", __func__, ret);
127     - goto put_node;
128     + goto put_device;
129     }
130    
131     ret = imx6_pm_get_base(&pm_info->src_base, socdata->src_compat);
132     @@ -558,7 +558,7 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
133     &imx6_suspend,
134     MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));
135    
136     - goto put_node;
137     + goto put_device;
138    
139     pl310_cache_map_failed:
140     iounmap(pm_info->gpc_base.vbase);
141     @@ -568,6 +568,8 @@ iomuxc_map_failed:
142     iounmap(pm_info->src_base.vbase);
143     src_map_failed:
144     iounmap(pm_info->mmdc_base.vbase);
145     +put_device:
146     + put_device(&pdev->dev);
147     put_node:
148     of_node_put(node);
149    
150     diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h
151     index b71420a12f26..12e2f82341b9 100644
152     --- a/arch/arm64/include/asm/debug-monitors.h
153     +++ b/arch/arm64/include/asm/debug-monitors.h
154     @@ -116,6 +116,8 @@ void disable_debug_monitors(enum dbg_active_el el);
155    
156     void user_rewind_single_step(struct task_struct *task);
157     void user_fastforward_single_step(struct task_struct *task);
158     +void user_regs_reset_single_step(struct user_pt_regs *regs,
159     + struct task_struct *task);
160    
161     void kernel_enable_single_step(struct pt_regs *regs);
162     void kernel_disable_single_step(void);
163     diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
164     index 5bc3de78306a..94f30e6c327c 100644
165     --- a/arch/arm64/include/asm/pgtable-prot.h
166     +++ b/arch/arm64/include/asm/pgtable-prot.h
167     @@ -65,7 +65,7 @@
168     #define PAGE_HYP __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_HYP_XN)
169     #define PAGE_HYP_EXEC __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY)
170     #define PAGE_HYP_RO __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY | PTE_HYP_XN)
171     -#define PAGE_HYP_DEVICE __pgprot(PROT_DEVICE_nGnRE | PTE_HYP)
172     +#define PAGE_HYP_DEVICE __pgprot(_PROT_DEFAULT | PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_HYP | PTE_HYP_XN)
173    
174     #define PAGE_S2 __pgprot(_PROT_DEFAULT | PTE_S2_MEMATTR(MT_S2_NORMAL) | PTE_S2_RDONLY)
175     #define PAGE_S2_DEVICE __pgprot(_PROT_DEFAULT | PTE_S2_MEMATTR(MT_S2_DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_UXN)
176     diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
177     index 9f1adca3c346..a5236a3e5297 100644
178     --- a/arch/arm64/kernel/debug-monitors.c
179     +++ b/arch/arm64/kernel/debug-monitors.c
180     @@ -149,17 +149,20 @@ postcore_initcall(debug_monitors_init);
181     /*
182     * Single step API and exception handling.
183     */
184     -static void set_regs_spsr_ss(struct pt_regs *regs)
185     +static void set_user_regs_spsr_ss(struct user_pt_regs *regs)
186     {
187     regs->pstate |= DBG_SPSR_SS;
188     }
189     -NOKPROBE_SYMBOL(set_regs_spsr_ss);
190     +NOKPROBE_SYMBOL(set_user_regs_spsr_ss);
191    
192     -static void clear_regs_spsr_ss(struct pt_regs *regs)
193     +static void clear_user_regs_spsr_ss(struct user_pt_regs *regs)
194     {
195     regs->pstate &= ~DBG_SPSR_SS;
196     }
197     -NOKPROBE_SYMBOL(clear_regs_spsr_ss);
198     +NOKPROBE_SYMBOL(clear_user_regs_spsr_ss);
199     +
200     +#define set_regs_spsr_ss(r) set_user_regs_spsr_ss(&(r)->user_regs)
201     +#define clear_regs_spsr_ss(r) clear_user_regs_spsr_ss(&(r)->user_regs)
202    
203     /* EL1 Single Step Handler hooks */
204     static LIST_HEAD(step_hook);
205     @@ -388,6 +391,15 @@ void user_fastforward_single_step(struct task_struct *task)
206     clear_regs_spsr_ss(task_pt_regs(task));
207     }
208    
209     +void user_regs_reset_single_step(struct user_pt_regs *regs,
210     + struct task_struct *task)
211     +{
212     + if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
213     + set_user_regs_spsr_ss(regs);
214     + else
215     + clear_user_regs_spsr_ss(regs);
216     +}
217     +
218     /* Kernel API */
219     void kernel_enable_single_step(struct pt_regs *regs)
220     {
221     diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
222     index 72a660a74ff9..44d757308e47 100644
223     --- a/arch/arm64/kernel/kgdb.c
224     +++ b/arch/arm64/kernel/kgdb.c
225     @@ -256,7 +256,7 @@ static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
226     if (user_mode(regs))
227     return DBG_HOOK_ERROR;
228    
229     - kgdb_handle_exception(1, SIGTRAP, 0, regs);
230     + kgdb_handle_exception(0, SIGTRAP, 0, regs);
231     return DBG_HOOK_HANDLED;
232     }
233     NOKPROBE_SYMBOL(kgdb_step_brk_fn);
234     diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
235     index 8eedeef375d6..68af3f849fdd 100644
236     --- a/arch/arm64/kernel/ptrace.c
237     +++ b/arch/arm64/kernel/ptrace.c
238     @@ -1447,8 +1447,8 @@ static int valid_native_regs(struct user_pt_regs *regs)
239     */
240     int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task)
241     {
242     - if (!test_tsk_thread_flag(task, TIF_SINGLESTEP))
243     - regs->pstate &= ~DBG_SPSR_SS;
244     + /* https://lore.kernel.org/lkml/20191118131525.GA4180@willie-the-truck */
245     + user_regs_reset_single_step(regs, task);
246    
247     if (is_compat_thread(task_thread_info(task)))
248     return valid_compat_regs(regs);
249     diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
250     index b7f7e08e1ce4..b15ee1258668 100644
251     --- a/arch/mips/kernel/time.c
252     +++ b/arch/mips/kernel/time.c
253     @@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq;
254     static int cpufreq_callback(struct notifier_block *nb,
255     unsigned long val, void *data)
256     {
257     - struct cpufreq_freqs *freq = data;
258     - struct cpumask *cpus = freq->policy->cpus;
259     - unsigned long lpj;
260     int cpu;
261     + struct cpufreq_freqs *freq = data;
262    
263     /*
264     * Skip lpj numbers adjustment if the CPU-freq transition is safe for
265     @@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb,
266     }
267     }
268    
269     + cpu = freq->cpu;
270     /*
271     * Adjust global lpj variable and per-CPU udelay_val number in
272     * accordance with the new CPU frequency.
273     @@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb,
274     glb_lpj_ref_freq,
275     freq->new);
276    
277     - for_each_cpu(cpu, cpus) {
278     - lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
279     - per_cpu(pcp_lpj_ref_freq, cpu),
280     - freq->new);
281     - cpu_data[cpu].udelay_val = (unsigned int)lpj;
282     - }
283     + cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
284     + per_cpu(pcp_lpj_ref_freq, cpu), freq->new);
285     }
286    
287     return NOTIFY_OK;
288     diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
289     index 5792590d0e7c..0b3c26e6930d 100644
290     --- a/arch/s390/include/asm/kvm_host.h
291     +++ b/arch/s390/include/asm/kvm_host.h
292     @@ -32,12 +32,12 @@
293     #define KVM_USER_MEM_SLOTS 32
294    
295     /*
296     - * These seem to be used for allocating ->chip in the routing table,
297     - * which we don't use. 4096 is an out-of-thin-air value. If we need
298     - * to look at ->chip later on, we'll need to revisit this.
299     + * These seem to be used for allocating ->chip in the routing table, which we
300     + * don't use. 1 is as small as we can get to reduce the needed memory. If we
301     + * need to look at ->chip later on, we'll need to revisit this.
302     */
303     #define KVM_NR_IRQCHIPS 1
304     -#define KVM_IRQCHIP_NUM_PINS 4096
305     +#define KVM_IRQCHIP_NUM_PINS 1
306     #define KVM_HALT_POLL_NS_DEFAULT 80000
307    
308     /* s390-specific vcpu->requests bit members */
309     diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
310     index a651c2bc94ef..f862cc27fe98 100644
311     --- a/arch/s390/kernel/early.c
312     +++ b/arch/s390/kernel/early.c
313     @@ -288,6 +288,8 @@ static noinline __init void setup_lowcore_early(void)
314     psw_t psw;
315    
316     psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA;
317     + if (IS_ENABLED(CONFIG_KASAN))
318     + psw.mask |= PSW_MASK_DAT;
319     psw.addr = (unsigned long) s390_base_ext_handler;
320     S390_lowcore.external_new_psw = psw;
321     psw.addr = (unsigned long) s390_base_pgm_handler;
322     diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
323     index 4a0c5bce3552..8a22def411c5 100644
324     --- a/arch/s390/mm/hugetlbpage.c
325     +++ b/arch/s390/mm/hugetlbpage.c
326     @@ -111,7 +111,7 @@ static inline pte_t __rste_to_pte(unsigned long rste)
327     _PAGE_YOUNG);
328     #ifdef CONFIG_MEM_SOFT_DIRTY
329     pte_val(pte) |= move_set_bit(rste, _SEGMENT_ENTRY_SOFT_DIRTY,
330     - _PAGE_DIRTY);
331     + _PAGE_SOFT_DIRTY);
332     #endif
333     } else
334     pte_val(pte) = _PAGE_INVALID;
335     diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
336     index b16b6176738b..ff3253b9a879 100644
337     --- a/arch/x86/kernel/cpu/common.c
338     +++ b/arch/x86/kernel/cpu/common.c
339     @@ -849,6 +849,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
340     else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))
341     c->x86_phys_bits = 36;
342     #endif
343     + c->x86_cache_bits = c->x86_phys_bits;
344    
345     if (c->extended_cpuid_level >= 0x8000000a)
346     c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
347     @@ -888,7 +889,6 @@ static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
348     }
349     }
350     #endif
351     - c->x86_cache_bits = c->x86_phys_bits;
352     }
353    
354     #define NO_SPECULATION BIT(0)
355     diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
356     index 3a281a2decde..73055b8e411f 100644
357     --- a/arch/x86/kvm/mmu.c
358     +++ b/arch/x86/kvm/mmu.c
359     @@ -3849,7 +3849,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
360     nonleaf_bit8_rsvd | rsvd_bits(7, 7) |
361     rsvd_bits(maxphyaddr, 51);
362     rsvd_check->rsvd_bits_mask[0][2] = exb_bit_rsvd |
363     - nonleaf_bit8_rsvd | gbpages_bit_rsvd |
364     + gbpages_bit_rsvd |
365     rsvd_bits(maxphyaddr, 51);
366     rsvd_check->rsvd_bits_mask[0][1] = exb_bit_rsvd |
367     rsvd_bits(maxphyaddr, 51);
368     diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
369     index 34548d3b4d13..4ec08c7a7b65 100644
370     --- a/drivers/char/virtio_console.c
371     +++ b/drivers/char/virtio_console.c
372     @@ -2161,6 +2161,7 @@ static struct virtio_device_id id_table[] = {
373     { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID },
374     { 0 },
375     };
376     +MODULE_DEVICE_TABLE(virtio, id_table);
377    
378     static unsigned int features[] = {
379     VIRTIO_CONSOLE_F_SIZE,
380     @@ -2173,6 +2174,7 @@ static struct virtio_device_id rproc_serial_id_table[] = {
381     #endif
382     { 0 },
383     };
384     +MODULE_DEVICE_TABLE(virtio, rproc_serial_id_table);
385    
386     static unsigned int rproc_serial_features[] = {
387     };
388     @@ -2325,6 +2327,5 @@ static void __exit fini(void)
389     module_init(init);
390     module_exit(fini);
391    
392     -MODULE_DEVICE_TABLE(virtio, id_table);
393     MODULE_DESCRIPTION("Virtio console driver");
394     MODULE_LICENSE("GPL");
395     diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
396     index c7568869284e..0d2c6e13a01f 100644
397     --- a/drivers/dma/fsl-edma.c
398     +++ b/drivers/dma/fsl-edma.c
399     @@ -682,6 +682,13 @@ static irqreturn_t fsl_edma_tx_handler(int irq, void *dev_id)
400     fsl_chan = &fsl_edma->chans[ch];
401    
402     spin_lock(&fsl_chan->vchan.lock);
403     +
404     + if (!fsl_chan->edesc) {
405     + /* terminate_all called before */
406     + spin_unlock(&fsl_chan->vchan.lock);
407     + continue;
408     + }
409     +
410     if (!fsl_chan->edesc->iscyclic) {
411     list_del(&fsl_chan->edesc->vdesc.node);
412     vchan_cookie_complete(&fsl_chan->edesc->vdesc);
413     diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
414     index 24810492d2c1..be43582811df 100644
415     --- a/drivers/gpu/drm/radeon/ci_dpm.c
416     +++ b/drivers/gpu/drm/radeon/ci_dpm.c
417     @@ -5557,6 +5557,7 @@ static int ci_parse_power_table(struct radeon_device *rdev)
418     if (!rdev->pm.dpm.ps)
419     return -ENOMEM;
420     power_state_offset = (u8 *)state_array->states;
421     + rdev->pm.dpm.num_ps = 0;
422     for (i = 0; i < state_array->ucNumEntries; i++) {
423     u8 *idx;
424     power_state = (union pplib_power_state *)power_state_offset;
425     @@ -5566,10 +5567,8 @@ static int ci_parse_power_table(struct radeon_device *rdev)
426     if (!rdev->pm.power_state[i].clock_info)
427     return -EINVAL;
428     ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL);
429     - if (ps == NULL) {
430     - kfree(rdev->pm.dpm.ps);
431     + if (ps == NULL)
432     return -ENOMEM;
433     - }
434     rdev->pm.dpm.ps[i].ps_priv = ps;
435     ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i],
436     non_clock_info,
437     @@ -5591,8 +5590,8 @@ static int ci_parse_power_table(struct radeon_device *rdev)
438     k++;
439     }
440     power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
441     + rdev->pm.dpm.num_ps = i + 1;
442     }
443     - rdev->pm.dpm.num_ps = state_array->ucNumEntries;
444    
445     /* fill in the vce power states */
446     for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) {
447     diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
448     index c27858ae0552..6ef89e8a515a 100644
449     --- a/drivers/gpu/host1x/bus.c
450     +++ b/drivers/gpu/host1x/bus.c
451     @@ -542,8 +542,17 @@ EXPORT_SYMBOL(host1x_driver_register_full);
452    
453     void host1x_driver_unregister(struct host1x_driver *driver)
454     {
455     + struct host1x *host1x;
456     +
457     driver_unregister(&driver->driver);
458    
459     + mutex_lock(&devices_lock);
460     +
461     + list_for_each_entry(host1x, &devices, list)
462     + host1x_detach_driver(host1x, driver);
463     +
464     + mutex_unlock(&devices_lock);
465     +
466     mutex_lock(&drivers_lock);
467     list_del_init(&driver->list);
468     mutex_unlock(&drivers_lock);
469     diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
470     index 20b40ad26325..8c993f95e3ba 100644
471     --- a/drivers/hid/hid-magicmouse.c
472     +++ b/drivers/hid/hid-magicmouse.c
473     @@ -451,6 +451,12 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
474     __set_bit(MSC_RAW, input->mscbit);
475     }
476    
477     + /*
478     + * hid-input may mark device as using autorepeat, but neither
479     + * the trackpad, nor the mouse actually want it.
480     + */
481     + __clear_bit(EV_REP, input->evbit);
482     +
483     return 0;
484     }
485    
486     diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
487     index 24e395c5907d..7204ebf32351 100644
488     --- a/drivers/hwmon/emc2103.c
489     +++ b/drivers/hwmon/emc2103.c
490     @@ -452,7 +452,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da,
491     }
492    
493     result = read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg);
494     - if (result) {
495     + if (result < 0) {
496     count = result;
497     goto err;
498     }
499     diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
500     index 5ce71ce7b6c4..39f05e784566 100644
501     --- a/drivers/i2c/busses/i2c-eg20t.c
502     +++ b/drivers/i2c/busses/i2c-eg20t.c
503     @@ -189,6 +189,7 @@ static const struct pci_device_id pch_pcidev_id[] = {
504     { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_I2C), 1, },
505     {0,}
506     };
507     +MODULE_DEVICE_TABLE(pci, pch_pcidev_id);
508    
509     static irqreturn_t pch_i2c_handler(int irq, void *pData);
510    
511     diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
512     index d41e1b588e68..08cb814c36da 100644
513     --- a/drivers/iio/accel/mma8452.c
514     +++ b/drivers/iio/accel/mma8452.c
515     @@ -1576,10 +1576,13 @@ static int mma8452_probe(struct i2c_client *client,
516    
517     ret = mma8452_set_freefall_mode(data, false);
518     if (ret < 0)
519     - goto buffer_cleanup;
520     + goto unregister_device;
521    
522     return 0;
523    
524     +unregister_device:
525     + iio_device_unregister(indio_dev);
526     +
527     buffer_cleanup:
528     iio_triggered_buffer_cleanup(indio_dev);
529    
530     diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
531     index 6bb23a49e81e..2f07c4d1398c 100644
532     --- a/drivers/iio/health/afe4403.c
533     +++ b/drivers/iio/health/afe4403.c
534     @@ -71,6 +71,7 @@ static const struct reg_field afe4403_reg_fields[] = {
535     * @regulator: Pointer to the regulator for the IC
536     * @trig: IIO trigger for this device
537     * @irq: ADC_RDY line interrupt number
538     + * @buffer: Used to construct data layout to push into IIO buffer.
539     */
540     struct afe4403_data {
541     struct device *dev;
542     @@ -80,6 +81,8 @@ struct afe4403_data {
543     struct regulator *regulator;
544     struct iio_trigger *trig;
545     int irq;
546     + /* Ensure suitable alignment for timestamp */
547     + s32 buffer[8] __aligned(8);
548     };
549    
550     enum afe4403_chan_id {
551     @@ -318,7 +321,6 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
552     struct iio_dev *indio_dev = pf->indio_dev;
553     struct afe4403_data *afe = iio_priv(indio_dev);
554     int ret, bit, i = 0;
555     - s32 buffer[8];
556     u8 tx[4] = {AFE440X_CONTROL0, 0x0, 0x0, AFE440X_CONTROL0_READ};
557     u8 rx[3];
558    
559     @@ -335,9 +337,9 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
560     if (ret)
561     goto err;
562    
563     - buffer[i++] = (rx[0] << 16) |
564     - (rx[1] << 8) |
565     - (rx[2]);
566     + afe->buffer[i++] = (rx[0] << 16) |
567     + (rx[1] << 8) |
568     + (rx[2]);
569     }
570    
571     /* Disable reading from the device */
572     @@ -346,7 +348,8 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
573     if (ret)
574     goto err;
575    
576     - iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
577     + iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
578     + pf->timestamp);
579     err:
580     iio_trigger_notify_done(indio_dev->trig);
581    
582     diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
583     index 964f5231a831..5e256b11ac87 100644
584     --- a/drivers/iio/health/afe4404.c
585     +++ b/drivers/iio/health/afe4404.c
586     @@ -91,6 +91,7 @@ static const struct reg_field afe4404_reg_fields[] = {
587     * @regulator: Pointer to the regulator for the IC
588     * @trig: IIO trigger for this device
589     * @irq: ADC_RDY line interrupt number
590     + * @buffer: Used to construct a scan to push to the iio buffer.
591     */
592     struct afe4404_data {
593     struct device *dev;
594     @@ -99,6 +100,7 @@ struct afe4404_data {
595     struct regulator *regulator;
596     struct iio_trigger *trig;
597     int irq;
598     + s32 buffer[10] __aligned(8);
599     };
600    
601     enum afe4404_chan_id {
602     @@ -337,17 +339,17 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private)
603     struct iio_dev *indio_dev = pf->indio_dev;
604     struct afe4404_data *afe = iio_priv(indio_dev);
605     int ret, bit, i = 0;
606     - s32 buffer[10];
607    
608     for_each_set_bit(bit, indio_dev->active_scan_mask,
609     indio_dev->masklength) {
610     ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
611     - &buffer[i++]);
612     + &afe->buffer[i++]);
613     if (ret)
614     goto err;
615     }
616    
617     - iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
618     + iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
619     + pf->timestamp);
620     err:
621     iio_trigger_notify_done(indio_dev->trig);
622    
623     diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
624     index 752237f0889e..374b1fdd1e42 100644
625     --- a/drivers/iio/magnetometer/ak8974.c
626     +++ b/drivers/iio/magnetometer/ak8974.c
627     @@ -153,6 +153,11 @@ struct ak8974 {
628     bool drdy_irq;
629     struct completion drdy_complete;
630     bool drdy_active_low;
631     + /* Ensure timestamp is naturally aligned */
632     + struct {
633     + __le16 channels[3];
634     + s64 ts __aligned(8);
635     + } scan;
636     };
637    
638     static const char ak8974_reg_avdd[] = "avdd";
639     @@ -494,7 +499,6 @@ static void ak8974_fill_buffer(struct iio_dev *indio_dev)
640     {
641     struct ak8974 *ak8974 = iio_priv(indio_dev);
642     int ret;
643     - s16 hw_values[8]; /* Three axes + 64bit padding */
644    
645     pm_runtime_get_sync(&ak8974->i2c->dev);
646     mutex_lock(&ak8974->lock);
647     @@ -504,13 +508,13 @@ static void ak8974_fill_buffer(struct iio_dev *indio_dev)
648     dev_err(&ak8974->i2c->dev, "error triggering measure\n");
649     goto out_unlock;
650     }
651     - ret = ak8974_getresult(ak8974, hw_values);
652     + ret = ak8974_getresult(ak8974, ak8974->scan.channels);
653     if (ret) {
654     dev_err(&ak8974->i2c->dev, "error getting measures\n");
655     goto out_unlock;
656     }
657    
658     - iio_push_to_buffers_with_timestamp(indio_dev, hw_values,
659     + iio_push_to_buffers_with_timestamp(indio_dev, &ak8974->scan,
660     iio_get_time_ns(indio_dev));
661    
662     out_unlock:
663     @@ -671,19 +675,21 @@ static int ak8974_probe(struct i2c_client *i2c,
664     ak8974->map = devm_regmap_init_i2c(i2c, &ak8974_regmap_config);
665     if (IS_ERR(ak8974->map)) {
666     dev_err(&i2c->dev, "failed to allocate register map\n");
667     + pm_runtime_put_noidle(&i2c->dev);
668     + pm_runtime_disable(&i2c->dev);
669     return PTR_ERR(ak8974->map);
670     }
671    
672     ret = ak8974_set_power(ak8974, AK8974_PWR_ON);
673     if (ret) {
674     dev_err(&i2c->dev, "could not power on\n");
675     - goto power_off;
676     + goto disable_pm;
677     }
678    
679     ret = ak8974_detect(ak8974);
680     if (ret) {
681     dev_err(&i2c->dev, "neither AK8974 nor AMI305 found\n");
682     - goto power_off;
683     + goto disable_pm;
684     }
685    
686     ret = ak8974_selftest(ak8974);
687     @@ -693,14 +699,9 @@ static int ak8974_probe(struct i2c_client *i2c,
688     ret = ak8974_reset(ak8974);
689     if (ret) {
690     dev_err(&i2c->dev, "AK8974 reset failed\n");
691     - goto power_off;
692     + goto disable_pm;
693     }
694    
695     - pm_runtime_set_autosuspend_delay(&i2c->dev,
696     - AK8974_AUTOSUSPEND_DELAY);
697     - pm_runtime_use_autosuspend(&i2c->dev);
698     - pm_runtime_put(&i2c->dev);
699     -
700     indio_dev->dev.parent = &i2c->dev;
701     indio_dev->channels = ak8974_channels;
702     indio_dev->num_channels = ARRAY_SIZE(ak8974_channels);
703     @@ -753,6 +754,11 @@ no_irq:
704     goto cleanup_buffer;
705     }
706    
707     + pm_runtime_set_autosuspend_delay(&i2c->dev,
708     + AK8974_AUTOSUSPEND_DELAY);
709     + pm_runtime_use_autosuspend(&i2c->dev);
710     + pm_runtime_put(&i2c->dev);
711     +
712     return 0;
713    
714     cleanup_buffer:
715     @@ -761,7 +767,6 @@ disable_pm:
716     pm_runtime_put_noidle(&i2c->dev);
717     pm_runtime_disable(&i2c->dev);
718     ak8974_set_power(ak8974, AK8974_PWR_OFF);
719     -power_off:
720     regulator_bulk_disable(ARRAY_SIZE(ak8974->regs), ak8974->regs);
721    
722     return ret;
723     diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
724     index 8cc7156b5ace..17844e20de7d 100644
725     --- a/drivers/iio/pressure/ms5611_core.c
726     +++ b/drivers/iio/pressure/ms5611_core.c
727     @@ -215,16 +215,21 @@ static irqreturn_t ms5611_trigger_handler(int irq, void *p)
728     struct iio_poll_func *pf = p;
729     struct iio_dev *indio_dev = pf->indio_dev;
730     struct ms5611_state *st = iio_priv(indio_dev);
731     - s32 buf[4]; /* s32 (pressure) + s32 (temp) + 2 * s32 (timestamp) */
732     + /* Ensure buffer elements are naturally aligned */
733     + struct {
734     + s32 channels[2];
735     + s64 ts __aligned(8);
736     + } scan;
737     int ret;
738    
739     mutex_lock(&st->lock);
740     - ret = ms5611_read_temp_and_pressure(indio_dev, &buf[1], &buf[0]);
741     + ret = ms5611_read_temp_and_pressure(indio_dev, &scan.channels[1],
742     + &scan.channels[0]);
743     mutex_unlock(&st->lock);
744     if (ret < 0)
745     goto err;
746    
747     - iio_push_to_buffers_with_timestamp(indio_dev, buf,
748     + iio_push_to_buffers_with_timestamp(indio_dev, &scan,
749     iio_get_time_ns(indio_dev));
750    
751     err:
752     diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
753     index cc002b958f7e..401e230ab72e 100644
754     --- a/drivers/iio/pressure/zpa2326.c
755     +++ b/drivers/iio/pressure/zpa2326.c
756     @@ -676,8 +676,10 @@ static int zpa2326_resume(const struct iio_dev *indio_dev)
757     int err;
758    
759     err = pm_runtime_get_sync(indio_dev->dev.parent);
760     - if (err < 0)
761     + if (err < 0) {
762     + pm_runtime_put(indio_dev->dev.parent);
763     return err;
764     + }
765    
766     if (err > 0) {
767     /*
768     diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
769     index fd1e79013cf8..bdc42923523e 100644
770     --- a/drivers/input/serio/i8042-x86ia64io.h
771     +++ b/drivers/input/serio/i8042-x86ia64io.h
772     @@ -429,6 +429,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
773     DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
774     },
775     },
776     + {
777     + /* Lenovo XiaoXin Air 12 */
778     + .matches = {
779     + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
780     + DMI_MATCH(DMI_PRODUCT_NAME, "80UN"),
781     + },
782     + },
783     {
784     .matches = {
785     DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
786     diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
787     index d6c404b3584d..006b17593c12 100644
788     --- a/drivers/irqchip/irq-gic.c
789     +++ b/drivers/irqchip/irq-gic.c
790     @@ -324,10 +324,8 @@ static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu)
791     static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
792     bool force)
793     {
794     - void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3);
795     - unsigned int cpu, shift = (gic_irq(d) % 4) * 8;
796     - u32 val, mask, bit;
797     - unsigned long flags;
798     + void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d);
799     + unsigned int cpu;
800    
801     if (!force)
802     cpu = cpumask_any_and(mask_val, cpu_online_mask);
803     @@ -337,12 +335,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
804     if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids)
805     return -EINVAL;
806    
807     - gic_lock_irqsave(flags);
808     - mask = 0xff << shift;
809     - bit = gic_cpu_map[cpu] << shift;
810     - val = readl_relaxed(reg) & ~mask;
811     - writel_relaxed(val | bit, reg);
812     - gic_unlock_irqrestore(flags);
813     + writeb_relaxed(gic_cpu_map[cpu], reg);
814    
815     return IRQ_SET_MASK_OK_DONE;
816     }
817     diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
818     index 6c9fc11efb87..e77185e143ab 100644
819     --- a/drivers/message/fusion/mptscsih.c
820     +++ b/drivers/message/fusion/mptscsih.c
821     @@ -118,8 +118,6 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
822     int mptscsih_resume(struct pci_dev *pdev);
823     #endif
824    
825     -#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE
826     -
827    
828     /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
829     /*
830     @@ -2427,7 +2425,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
831     /* Copy the sense received into the scsi command block. */
832     req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
833     sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC));
834     - memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc));
835     + memcpy(sc->sense_buffer, sense_data, MPT_SENSE_BUFFER_ALLOC);
836    
837     /* Log SMART data (asc = 0x5D, non-IM case only) if required.
838     */
839     diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
840     index 3a6e4ec21c87..8c9a444d61d3 100644
841     --- a/drivers/misc/atmel-ssc.c
842     +++ b/drivers/misc/atmel-ssc.c
843     @@ -13,7 +13,7 @@
844     #include <linux/clk.h>
845     #include <linux/err.h>
846     #include <linux/io.h>
847     -#include <linux/spinlock.h>
848     +#include <linux/mutex.h>
849     #include <linux/atmel-ssc.h>
850     #include <linux/slab.h>
851     #include <linux/module.h>
852     @@ -21,7 +21,7 @@
853     #include <linux/of.h>
854    
855     /* Serialize access to ssc_list and user count */
856     -static DEFINE_SPINLOCK(user_lock);
857     +static DEFINE_MUTEX(user_lock);
858     static LIST_HEAD(ssc_list);
859    
860     struct ssc_device *ssc_request(unsigned int ssc_num)
861     @@ -29,7 +29,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
862     int ssc_valid = 0;
863     struct ssc_device *ssc;
864    
865     - spin_lock(&user_lock);
866     + mutex_lock(&user_lock);
867     list_for_each_entry(ssc, &ssc_list, list) {
868     if (ssc->pdev->dev.of_node) {
869     if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
870     @@ -45,18 +45,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
871     }
872    
873     if (!ssc_valid) {
874     - spin_unlock(&user_lock);
875     + mutex_unlock(&user_lock);
876     pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
877     return ERR_PTR(-ENODEV);
878     }
879    
880     if (ssc->user) {
881     - spin_unlock(&user_lock);
882     + mutex_unlock(&user_lock);
883     dev_dbg(&ssc->pdev->dev, "module busy\n");
884     return ERR_PTR(-EBUSY);
885     }
886     ssc->user++;
887     - spin_unlock(&user_lock);
888     + mutex_unlock(&user_lock);
889    
890     clk_prepare(ssc->clk);
891    
892     @@ -68,14 +68,14 @@ void ssc_free(struct ssc_device *ssc)
893     {
894     bool disable_clk = true;
895    
896     - spin_lock(&user_lock);
897     + mutex_lock(&user_lock);
898     if (ssc->user)
899     ssc->user--;
900     else {
901     disable_clk = false;
902     dev_dbg(&ssc->pdev->dev, "device already free\n");
903     }
904     - spin_unlock(&user_lock);
905     + mutex_unlock(&user_lock);
906    
907     if (disable_clk)
908     clk_unprepare(ssc->clk);
909     @@ -195,9 +195,9 @@ static int ssc_probe(struct platform_device *pdev)
910     return -ENXIO;
911     }
912    
913     - spin_lock(&user_lock);
914     + mutex_lock(&user_lock);
915     list_add_tail(&ssc->list, &ssc_list);
916     - spin_unlock(&user_lock);
917     + mutex_unlock(&user_lock);
918    
919     platform_set_drvdata(pdev, ssc);
920    
921     @@ -211,9 +211,9 @@ static int ssc_remove(struct platform_device *pdev)
922     {
923     struct ssc_device *ssc = platform_get_drvdata(pdev);
924    
925     - spin_lock(&user_lock);
926     + mutex_lock(&user_lock);
927     list_del(&ssc->list);
928     - spin_unlock(&user_lock);
929     + mutex_unlock(&user_lock);
930    
931     return 0;
932     }
933     diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
934     index 582b24d2c479..610e87bdb5dc 100644
935     --- a/drivers/misc/mei/bus.c
936     +++ b/drivers/misc/mei/bus.c
937     @@ -639,9 +639,8 @@ static int mei_cl_device_remove(struct device *dev)
938     ret = cldrv->remove(cldev);
939    
940     module_put(THIS_MODULE);
941     - dev->driver = NULL;
942     - return ret;
943    
944     + return ret;
945     }
946    
947     static ssize_t name_show(struct device *dev, struct device_attribute *a,
948     diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
949     index fbee81909d38..40fdc9d267b9 100644
950     --- a/drivers/mtd/nand/brcmnand/brcmnand.c
951     +++ b/drivers/mtd/nand/brcmnand/brcmnand.c
952     @@ -491,8 +491,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
953     } else {
954     ctrl->cs_offsets = brcmnand_cs_offsets;
955    
956     - /* v5.0 and earlier has a different CS0 offset layout */
957     - if (ctrl->nand_version <= 0x0500)
958     + /* v3.3-5.0 have a different CS0 offset layout */
959     + if (ctrl->nand_version >= 0x0303 &&
960     + ctrl->nand_version <= 0x0500)
961     ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
962     }
963    
964     diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
965     index 796571fccba7..84def5819d2e 100644
966     --- a/drivers/net/dsa/bcm_sf2.c
967     +++ b/drivers/net/dsa/bcm_sf2.c
968     @@ -1039,6 +1039,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
969     spin_lock_init(&priv->indir_lock);
970     mutex_init(&priv->stats_mutex);
971    
972     + /* Balance of_node_put() done by of_find_node_by_name() */
973     + of_node_get(dn);
974     ports = of_find_node_by_name(dn, "ports");
975     if (ports) {
976     bcm_sf2_identify_ports(priv, ports);
977     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
978     index 393cce3bf2fc..1d6cb5f0ffeb 100644
979     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
980     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
981     @@ -342,6 +342,7 @@ static void bnxt_free_vf_resources(struct bnxt *bp)
982     }
983     }
984    
985     + bp->pf.active_vfs = 0;
986     kfree(bp->pf.vf);
987     bp->pf.vf = NULL;
988     }
989     @@ -590,7 +591,6 @@ void bnxt_sriov_disable(struct bnxt *bp)
990    
991     bnxt_free_vf_resources(bp);
992    
993     - bp->pf.active_vfs = 0;
994     /* Reclaim all resources for the PF. */
995     bnxt_hwrm_func_qcaps(bp);
996     }
997     diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
998     index 30e93041bf83..f20718b730e5 100644
999     --- a/drivers/net/ethernet/cadence/macb.c
1000     +++ b/drivers/net/ethernet/cadence/macb.c
1001     @@ -3024,7 +3024,7 @@ static int macb_probe(struct platform_device *pdev)
1002     bp->wol = 0;
1003     if (of_get_property(np, "magic-packet", NULL))
1004     bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
1005     - device_init_wakeup(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
1006     + device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
1007    
1008     #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
1009     if (GEM_BFEXT(DBWDEF, gem_readl(bp, DCFG1)) > GEM_DBW32)
1010     diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1011     index 62bc2af9cde7..9a2edc4d4fe8 100644
1012     --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1013     +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1014     @@ -3152,7 +3152,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
1015     drv_fw = &fw_info->fw_hdr;
1016    
1017     /* Read the header of the firmware on the card */
1018     - ret = -t4_read_flash(adap, FLASH_FW_START,
1019     + ret = t4_read_flash(adap, FLASH_FW_START,
1020     sizeof(*card_fw) / sizeof(uint32_t),
1021     (uint32_t *)card_fw, 1);
1022     if (ret == 0) {
1023     @@ -3181,8 +3181,8 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
1024     should_install_fs_fw(adap, card_fw_usable,
1025     be32_to_cpu(fs_fw->fw_ver),
1026     be32_to_cpu(card_fw->fw_ver))) {
1027     - ret = -t4_fw_upgrade(adap, adap->mbox, fw_data,
1028     - fw_size, 0);
1029     + ret = t4_fw_upgrade(adap, adap->mbox, fw_data,
1030     + fw_size, 0);
1031     if (ret != 0) {
1032     dev_err(adap->pdev_dev,
1033     "failed to install firmware: %d\n", ret);
1034     @@ -3213,7 +3213,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
1035     FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c),
1036     FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k),
1037     FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k));
1038     - ret = EINVAL;
1039     + ret = -EINVAL;
1040     goto bye;
1041     }
1042    
1043     diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
1044     index 9a873616dd27..254a27295f41 100644
1045     --- a/drivers/net/usb/qmi_wwan.c
1046     +++ b/drivers/net/usb/qmi_wwan.c
1047     @@ -962,6 +962,7 @@ static const struct usb_device_id products[] = {
1048     {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
1049     {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */
1050     {QMI_QUIRK_SET_DTR(0x2c7c, 0x0191, 4)}, /* Quectel EG91 */
1051     + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0195, 4)}, /* Quectel EG95 */
1052     {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */
1053     {QMI_QUIRK_SET_DTR(0x2c7c, 0x0306, 4)}, /* Quectel EP06 Mini PCIe */
1054    
1055     diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
1056     index 6852ebafd4d3..3e6bf6bd0a68 100644
1057     --- a/drivers/net/usb/smsc95xx.c
1058     +++ b/drivers/net/usb/smsc95xx.c
1059     @@ -1292,11 +1292,14 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
1060    
1061     /* Init all registers */
1062     ret = smsc95xx_reset(dev);
1063     + if (ret)
1064     + goto free_pdata;
1065    
1066     /* detect device revision as different features may be available */
1067     ret = smsc95xx_read_reg(dev, ID_REV, &val);
1068     if (ret < 0)
1069     - return ret;
1070     + goto free_pdata;
1071     +
1072     val >>= 16;
1073     pdata->chip_id = val;
1074     pdata->mdix_ctrl = get_mdix_status(dev->net);
1075     @@ -1320,6 +1323,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
1076     schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY);
1077    
1078     return 0;
1079     +
1080     +free_pdata:
1081     + kfree(pdata);
1082     + return ret;
1083     }
1084    
1085     static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
1086     diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
1087     index e27acccc3678..84b5f8a144ff 100644
1088     --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
1089     +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
1090     @@ -641,9 +641,9 @@ err:
1091    
1092     static void ath9k_hif_usb_rx_cb(struct urb *urb)
1093     {
1094     - struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
1095     - struct hif_device_usb *hif_dev = rx_buf->hif_dev;
1096     - struct sk_buff *skb = rx_buf->skb;
1097     + struct sk_buff *skb = (struct sk_buff *) urb->context;
1098     + struct hif_device_usb *hif_dev =
1099     + usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
1100     int ret;
1101    
1102     if (!skb)
1103     @@ -683,15 +683,14 @@ resubmit:
1104     return;
1105     free:
1106     kfree_skb(skb);
1107     - kfree(rx_buf);
1108     }
1109    
1110     static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
1111     {
1112     - struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
1113     - struct hif_device_usb *hif_dev = rx_buf->hif_dev;
1114     - struct sk_buff *skb = rx_buf->skb;
1115     + struct sk_buff *skb = (struct sk_buff *) urb->context;
1116     struct sk_buff *nskb;
1117     + struct hif_device_usb *hif_dev =
1118     + usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
1119     int ret;
1120    
1121     if (!skb)
1122     @@ -749,7 +748,6 @@ resubmit:
1123     return;
1124     free:
1125     kfree_skb(skb);
1126     - kfree(rx_buf);
1127     urb->context = NULL;
1128     }
1129    
1130     @@ -795,7 +793,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
1131     init_usb_anchor(&hif_dev->mgmt_submitted);
1132    
1133     for (i = 0; i < MAX_TX_URB_NUM; i++) {
1134     - tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL);
1135     + tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
1136     if (!tx_buf)
1137     goto err;
1138    
1139     @@ -832,9 +830,8 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
1140    
1141     static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
1142     {
1143     - struct rx_buf *rx_buf = NULL;
1144     - struct sk_buff *skb = NULL;
1145     struct urb *urb = NULL;
1146     + struct sk_buff *skb = NULL;
1147     int i, ret;
1148    
1149     init_usb_anchor(&hif_dev->rx_submitted);
1150     @@ -842,12 +839,6 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
1151    
1152     for (i = 0; i < MAX_RX_URB_NUM; i++) {
1153    
1154     - rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
1155     - if (!rx_buf) {
1156     - ret = -ENOMEM;
1157     - goto err_rxb;
1158     - }
1159     -
1160     /* Allocate URB */
1161     urb = usb_alloc_urb(0, GFP_KERNEL);
1162     if (urb == NULL) {
1163     @@ -862,14 +853,11 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
1164     goto err_skb;
1165     }
1166    
1167     - rx_buf->hif_dev = hif_dev;
1168     - rx_buf->skb = skb;
1169     -
1170     usb_fill_bulk_urb(urb, hif_dev->udev,
1171     usb_rcvbulkpipe(hif_dev->udev,
1172     USB_WLAN_RX_PIPE),
1173     skb->data, MAX_RX_BUF_SIZE,
1174     - ath9k_hif_usb_rx_cb, rx_buf);
1175     + ath9k_hif_usb_rx_cb, skb);
1176    
1177     /* Anchor URB */
1178     usb_anchor_urb(urb, &hif_dev->rx_submitted);
1179     @@ -895,8 +883,6 @@ err_submit:
1180     err_skb:
1181     usb_free_urb(urb);
1182     err_urb:
1183     - kfree(rx_buf);
1184     -err_rxb:
1185     ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
1186     return ret;
1187     }
1188     @@ -908,21 +894,14 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev)
1189    
1190     static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
1191     {
1192     - struct rx_buf *rx_buf = NULL;
1193     - struct sk_buff *skb = NULL;
1194     struct urb *urb = NULL;
1195     + struct sk_buff *skb = NULL;
1196     int i, ret;
1197    
1198     init_usb_anchor(&hif_dev->reg_in_submitted);
1199    
1200     for (i = 0; i < MAX_REG_IN_URB_NUM; i++) {
1201    
1202     - rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
1203     - if (!rx_buf) {
1204     - ret = -ENOMEM;
1205     - goto err_rxb;
1206     - }
1207     -
1208     /* Allocate URB */
1209     urb = usb_alloc_urb(0, GFP_KERNEL);
1210     if (urb == NULL) {
1211     @@ -937,14 +916,11 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
1212     goto err_skb;
1213     }
1214    
1215     - rx_buf->hif_dev = hif_dev;
1216     - rx_buf->skb = skb;
1217     -
1218     usb_fill_int_urb(urb, hif_dev->udev,
1219     usb_rcvintpipe(hif_dev->udev,
1220     USB_REG_IN_PIPE),
1221     skb->data, MAX_REG_IN_BUF_SIZE,
1222     - ath9k_hif_usb_reg_in_cb, rx_buf, 1);
1223     + ath9k_hif_usb_reg_in_cb, skb, 1);
1224    
1225     /* Anchor URB */
1226     usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
1227     @@ -970,8 +946,6 @@ err_submit:
1228     err_skb:
1229     usb_free_urb(urb);
1230     err_urb:
1231     - kfree(rx_buf);
1232     -err_rxb:
1233     ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
1234     return ret;
1235     }
1236     diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
1237     index 835264c36595..a95cdf562611 100644
1238     --- a/drivers/net/wireless/ath/ath9k/hif_usb.h
1239     +++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
1240     @@ -84,11 +84,6 @@ struct tx_buf {
1241     struct list_head list;
1242     };
1243    
1244     -struct rx_buf {
1245     - struct sk_buff *skb;
1246     - struct hif_device_usb *hif_dev;
1247     -};
1248     -
1249     #define HIF_USB_TX_STOP BIT(0)
1250     #define HIF_USB_TX_FLUSH BIT(1)
1251    
1252     diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
1253     index db3b6e9151a8..672152b49d95 100644
1254     --- a/drivers/spi/spi-fsl-dspi.c
1255     +++ b/drivers/spi/spi-fsl-dspi.c
1256     @@ -70,7 +70,7 @@
1257     #define SPI_SR 0x2c
1258     #define SPI_SR_EOQF 0x10000000
1259     #define SPI_SR_TCFQF 0x80000000
1260     -#define SPI_SR_CLEAR 0xdaad0000
1261     +#define SPI_SR_CLEAR 0x9aaf0000
1262    
1263     #define SPI_RSER 0x30
1264     #define SPI_RSER_EOQFE 0x10000000
1265     diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
1266     index 7e7da97982aa..17068e62e792 100644
1267     --- a/drivers/spi/spi-sun6i.c
1268     +++ b/drivers/spi/spi-sun6i.c
1269     @@ -163,7 +163,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
1270     struct spi_transfer *tfr)
1271     {
1272     struct sun6i_spi *sspi = spi_master_get_devdata(master);
1273     - unsigned int mclk_rate, div, timeout;
1274     + unsigned int mclk_rate, div, div_cdr1, div_cdr2, timeout;
1275     unsigned int start, end, tx_time;
1276     unsigned int tx_len = 0;
1277     int ret = 0;
1278     @@ -241,14 +241,12 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
1279     * First try CDR2, and if we can't reach the expected
1280     * frequency, fall back to CDR1.
1281     */
1282     - div = mclk_rate / (2 * tfr->speed_hz);
1283     - if (div <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
1284     - if (div > 0)
1285     - div--;
1286     -
1287     - reg = SUN6I_CLK_CTL_CDR2(div) | SUN6I_CLK_CTL_DRS;
1288     + div_cdr1 = DIV_ROUND_UP(mclk_rate, tfr->speed_hz);
1289     + div_cdr2 = DIV_ROUND_UP(div_cdr1, 2);
1290     + if (div_cdr2 <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
1291     + reg = SUN6I_CLK_CTL_CDR2(div_cdr2 - 1) | SUN6I_CLK_CTL_DRS;
1292     } else {
1293     - div = ilog2(mclk_rate) - ilog2(tfr->speed_hz);
1294     + div = min(SUN6I_CLK_CTL_CDR1_MASK, order_base_2(div_cdr1));
1295     reg = SUN6I_CLK_CTL_CDR1(div);
1296     }
1297    
1298     diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
1299     index a685c6114a8d..c364d9ce6d4b 100644
1300     --- a/drivers/spi/spidev.c
1301     +++ b/drivers/spi/spidev.c
1302     @@ -636,15 +636,20 @@ err_find_dev:
1303     static int spidev_release(struct inode *inode, struct file *filp)
1304     {
1305     struct spidev_data *spidev;
1306     + int dofree;
1307    
1308     mutex_lock(&device_list_lock);
1309     spidev = filp->private_data;
1310     filp->private_data = NULL;
1311    
1312     + spin_lock_irq(&spidev->spi_lock);
1313     + /* ... after we unbound from the underlying device? */
1314     + dofree = (spidev->spi == NULL);
1315     + spin_unlock_irq(&spidev->spi_lock);
1316     +
1317     /* last close? */
1318     spidev->users--;
1319     if (!spidev->users) {
1320     - int dofree;
1321    
1322     kfree(spidev->tx_buffer);
1323     spidev->tx_buffer = NULL;
1324     @@ -652,19 +657,14 @@ static int spidev_release(struct inode *inode, struct file *filp)
1325     kfree(spidev->rx_buffer);
1326     spidev->rx_buffer = NULL;
1327    
1328     - spin_lock_irq(&spidev->spi_lock);
1329     - if (spidev->spi)
1330     - spidev->speed_hz = spidev->spi->max_speed_hz;
1331     -
1332     - /* ... after we unbound from the underlying device? */
1333     - dofree = (spidev->spi == NULL);
1334     - spin_unlock_irq(&spidev->spi_lock);
1335     -
1336     if (dofree)
1337     kfree(spidev);
1338     + else
1339     + spidev->speed_hz = spidev->spi->max_speed_hz;
1340     }
1341     #ifdef CONFIG_SPI_SLAVE
1342     - spi_slave_abort(spidev->spi);
1343     + if (!dofree)
1344     + spi_slave_abort(spidev->spi);
1345     #endif
1346     mutex_unlock(&device_list_lock);
1347    
1348     @@ -809,13 +809,13 @@ static int spidev_remove(struct spi_device *spi)
1349     {
1350     struct spidev_data *spidev = spi_get_drvdata(spi);
1351    
1352     + /* prevent new opens */
1353     + mutex_lock(&device_list_lock);
1354     /* make sure ops on existing fds can abort cleanly */
1355     spin_lock_irq(&spidev->spi_lock);
1356     spidev->spi = NULL;
1357     spin_unlock_irq(&spidev->spi_lock);
1358    
1359     - /* prevent new opens */
1360     - mutex_lock(&device_list_lock);
1361     list_del(&spidev->device_entry);
1362     device_destroy(spidev_class, spidev->devt);
1363     clear_bit(MINOR(spidev->devt), minors);
1364     diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
1365     index 63991c49ff23..79a8799b1262 100644
1366     --- a/drivers/staging/comedi/drivers/addi_apci_1500.c
1367     +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
1368     @@ -465,9 +465,9 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
1369     unsigned int lo_mask = data[5] << shift;
1370     unsigned int chan_mask = hi_mask | lo_mask;
1371     unsigned int old_mask = (1 << shift) - 1;
1372     - unsigned int pm = devpriv->pm[trig] & old_mask;
1373     - unsigned int pt = devpriv->pt[trig] & old_mask;
1374     - unsigned int pp = devpriv->pp[trig] & old_mask;
1375     + unsigned int pm;
1376     + unsigned int pt;
1377     + unsigned int pp;
1378    
1379     if (trig > 1) {
1380     dev_dbg(dev->class_dev,
1381     @@ -480,6 +480,10 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
1382     return -EINVAL;
1383     }
1384    
1385     + pm = devpriv->pm[trig] & old_mask;
1386     + pt = devpriv->pt[trig] & old_mask;
1387     + pp = devpriv->pp[trig] & old_mask;
1388     +
1389     switch (data[2]) {
1390     case COMEDI_DIGITAL_TRIG_DISABLE:
1391     /* clear trigger configuration */
1392     diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
1393     index ea9558679634..34169c32d495 100644
1394     --- a/drivers/thermal/mtk_thermal.c
1395     +++ b/drivers/thermal/mtk_thermal.c
1396     @@ -348,8 +348,7 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
1397     u32 raw;
1398    
1399     for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) {
1400     - raw = readl(mt->thermal_base +
1401     - conf->msr[conf->bank_data[bank->id].sensors[i]]);
1402     + raw = readl(mt->thermal_base + conf->msr[i]);
1403    
1404     temp = raw_to_mcelsius(mt,
1405     conf->bank_data[bank->id].sensors[i],
1406     @@ -486,8 +485,7 @@ static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num,
1407    
1408     for (i = 0; i < conf->bank_data[num].num_sensors; i++)
1409     writel(conf->sensor_mux_values[conf->bank_data[num].sensors[i]],
1410     - mt->thermal_base +
1411     - conf->adcpnp[conf->bank_data[num].sensors[i]]);
1412     + mt->thermal_base + conf->adcpnp[i]);
1413    
1414     writel((1 << conf->bank_data[num].num_sensors) - 1,
1415     mt->thermal_base + TEMP_MONCTL0);
1416     diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
1417     index f598ecddc8a7..b58a504240c4 100644
1418     --- a/drivers/uio/uio_pdrv_genirq.c
1419     +++ b/drivers/uio/uio_pdrv_genirq.c
1420     @@ -148,7 +148,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
1421     if (!uioinfo->irq) {
1422     ret = platform_get_irq(pdev, 0);
1423     uioinfo->irq = ret;
1424     - if (ret == -ENXIO && pdev->dev.of_node)
1425     + if (ret == -ENXIO)
1426     uioinfo->irq = UIO_IRQ_NONE;
1427     else if (ret < 0) {
1428     dev_err(&pdev->dev, "failed to get IRQ\n");
1429     diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c
1430     index 7311ed61e99a..029c8bc54b7a 100644
1431     --- a/drivers/usb/c67x00/c67x00-sched.c
1432     +++ b/drivers/usb/c67x00/c67x00-sched.c
1433     @@ -500,7 +500,7 @@ c67x00_giveback_urb(struct c67x00_hcd *c67x00, struct urb *urb, int status)
1434     c67x00_release_urb(c67x00, urb);
1435     usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00), urb);
1436     spin_unlock(&c67x00->lock);
1437     - usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status);
1438     + usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, status);
1439     spin_lock(&c67x00->lock);
1440     }
1441    
1442     diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
1443     index e96e3a5808b3..6062a5d816a6 100644
1444     --- a/drivers/usb/chipidea/core.c
1445     +++ b/drivers/usb/chipidea/core.c
1446     @@ -1110,6 +1110,29 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
1447     enable_irq(ci->irq);
1448     }
1449    
1450     +/*
1451     + * Handle the wakeup interrupt triggered by extcon connector
1452     + * We need to call ci_irq again for extcon since the first
1453     + * interrupt (wakeup int) only let the controller be out of
1454     + * low power mode, but not handle any interrupts.
1455     + */
1456     +static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
1457     +{
1458     + struct ci_hdrc_cable *cable_id, *cable_vbus;
1459     + u32 otgsc = hw_read_otgsc(ci, ~0);
1460     +
1461     + cable_id = &ci->platdata->id_extcon;
1462     + cable_vbus = &ci->platdata->vbus_extcon;
1463     +
1464     + if (!IS_ERR(cable_id->edev) && ci->is_otg &&
1465     + (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
1466     + ci_irq(ci->irq, ci);
1467     +
1468     + if (!IS_ERR(cable_vbus->edev) && ci->is_otg &&
1469     + (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
1470     + ci_irq(ci->irq, ci);
1471     +}
1472     +
1473     static int ci_controller_resume(struct device *dev)
1474     {
1475     struct ci_hdrc *ci = dev_get_drvdata(dev);
1476     @@ -1136,6 +1159,7 @@ static int ci_controller_resume(struct device *dev)
1477     enable_irq(ci->irq);
1478     if (ci_otg_is_fsm_mode(ci))
1479     ci_otg_fsm_wakeup_by_srp(ci);
1480     + ci_extcon_wakeup_int(ci);
1481     }
1482    
1483     return 0;
1484     diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
1485     index 7b81bcfa19cb..56dcc0820898 100644
1486     --- a/drivers/usb/core/urb.c
1487     +++ b/drivers/usb/core/urb.c
1488     @@ -183,6 +183,31 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
1489    
1490     /*-------------------------------------------------------------------*/
1491    
1492     +static const int pipetypes[4] = {
1493     + PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
1494     +};
1495     +
1496     +/**
1497     + * usb_urb_ep_type_check - sanity check of endpoint in the given urb
1498     + * @urb: urb to be checked
1499     + *
1500     + * This performs a light-weight sanity check for the endpoint in the
1501     + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise
1502     + * a negative error code.
1503     + */
1504     +int usb_urb_ep_type_check(const struct urb *urb)
1505     +{
1506     + const struct usb_host_endpoint *ep;
1507     +
1508     + ep = usb_pipe_endpoint(urb->dev, urb->pipe);
1509     + if (!ep)
1510     + return -EINVAL;
1511     + if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)])
1512     + return -EINVAL;
1513     + return 0;
1514     +}
1515     +EXPORT_SYMBOL_GPL(usb_urb_ep_type_check);
1516     +
1517     /**
1518     * usb_submit_urb - issue an asynchronous transfer request for an endpoint
1519     * @urb: pointer to the urb describing the request
1520     @@ -322,9 +347,6 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
1521     */
1522     int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
1523     {
1524     - static int pipetypes[4] = {
1525     - PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
1526     - };
1527     int xfertype, max;
1528     struct usb_device *dev;
1529     struct usb_host_endpoint *ep;
1530     @@ -443,7 +465,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
1531     */
1532    
1533     /* Check that the pipe's type matches the endpoint's type */
1534     - if (usb_pipetype(urb->pipe) != pipetypes[xfertype])
1535     + if (usb_urb_ep_type_check(urb))
1536     dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
1537     usb_pipetype(urb->pipe), pipetypes[xfertype]);
1538    
1539     diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
1540     index 63178ed7f650..38926495c751 100644
1541     --- a/drivers/usb/dwc2/platform.c
1542     +++ b/drivers/usb/dwc2/platform.c
1543     @@ -507,7 +507,8 @@ static void dwc2_driver_shutdown(struct platform_device *dev)
1544     {
1545     struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
1546    
1547     - disable_irq(hsotg->irq);
1548     + dwc2_disable_global_interrupts(hsotg);
1549     + synchronize_irq(hsotg->irq);
1550     }
1551    
1552     static const struct of_device_id dwc2_of_match_table[] = {
1553     diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
1554     index f2ac0cbc29a4..be9616964a17 100644
1555     --- a/drivers/usb/gadget/function/f_uac1.c
1556     +++ b/drivers/usb/gadget/function/f_uac1.c
1557     @@ -336,7 +336,9 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
1558    
1559     /* Copy buffer is full, add it to the play_queue */
1560     if (audio_buf_size - copy_buf->actual < req->actual) {
1561     + spin_lock_irq(&audio->lock);
1562     list_add_tail(&copy_buf->list, &audio->play_queue);
1563     + spin_unlock_irq(&audio->lock);
1564     schedule_work(&audio->playback_work);
1565     copy_buf = f_audio_buffer_alloc(audio_buf_size);
1566     if (IS_ERR(copy_buf))
1567     diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
1568     index 57dd3bad9539..ccf1e9fe5ebd 100644
1569     --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
1570     +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
1571     @@ -843,7 +843,7 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1572     u32 status;
1573    
1574     DBG(DBG_GADGET | DBG_QUEUE, "ep_dequeue: %s, req %p\n",
1575     - ep->ep.name, req);
1576     + ep->ep.name, _req);
1577    
1578     spin_lock_irqsave(&udc->lock, flags);
1579    
1580     diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
1581     index 1b141e9299f9..a268d9e8d6cf 100644
1582     --- a/drivers/usb/host/ehci-platform.c
1583     +++ b/drivers/usb/host/ehci-platform.c
1584     @@ -378,11 +378,6 @@ static int ehci_platform_resume(struct device *dev)
1585     }
1586    
1587     ehci_resume(hcd, priv->reset_on_resume);
1588     -
1589     - pm_runtime_disable(dev);
1590     - pm_runtime_set_active(dev);
1591     - pm_runtime_enable(dev);
1592     -
1593     return 0;
1594     }
1595     #endif /* CONFIG_PM_SLEEP */
1596     diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
1597     index 9e3fdb1421f7..898b74086c12 100644
1598     --- a/drivers/usb/host/ohci-platform.c
1599     +++ b/drivers/usb/host/ohci-platform.c
1600     @@ -340,11 +340,6 @@ static int ohci_platform_resume(struct device *dev)
1601     }
1602    
1603     ohci_resume(hcd, false);
1604     -
1605     - pm_runtime_disable(dev);
1606     - pm_runtime_set_active(dev);
1607     - pm_runtime_enable(dev);
1608     -
1609     return 0;
1610     }
1611     #endif /* CONFIG_PM_SLEEP */
1612     diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
1613     index 169d7b2feb1f..781283a5138e 100644
1614     --- a/drivers/usb/host/xhci-plat.c
1615     +++ b/drivers/usb/host/xhci-plat.c
1616     @@ -313,17 +313,8 @@ static int xhci_plat_resume(struct device *dev)
1617     {
1618     struct usb_hcd *hcd = dev_get_drvdata(dev);
1619     struct xhci_hcd *xhci = hcd_to_xhci(hcd);
1620     - int ret;
1621     -
1622     - ret = xhci_resume(xhci, 0);
1623     - if (ret)
1624     - return ret;
1625     -
1626     - pm_runtime_disable(dev);
1627     - pm_runtime_set_active(dev);
1628     - pm_runtime_enable(dev);
1629    
1630     - return 0;
1631     + return xhci_resume(xhci, 0);
1632     }
1633    
1634     static const struct dev_pm_ops xhci_plat_pm_ops = {
1635     diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
1636     index 0291dc7cd284..cfa02d712362 100644
1637     --- a/drivers/usb/serial/ch341.c
1638     +++ b/drivers/usb/serial/ch341.c
1639     @@ -71,6 +71,7 @@
1640    
1641     static const struct usb_device_id id_table[] = {
1642     { USB_DEVICE(0x4348, 0x5523) },
1643     + { USB_DEVICE(0x1a86, 0x7522) },
1644     { USB_DEVICE(0x1a86, 0x7523) },
1645     { USB_DEVICE(0x1a86, 0x5523) },
1646     { },
1647     diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
1648     index 2c915be1db4c..5cdd6ad4d290 100644
1649     --- a/drivers/usb/serial/cypress_m8.c
1650     +++ b/drivers/usb/serial/cypress_m8.c
1651     @@ -63,6 +63,7 @@ static const struct usb_device_id id_table_earthmate[] = {
1652    
1653     static const struct usb_device_id id_table_cyphidcomrs232[] = {
1654     { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
1655     + { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) },
1656     { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
1657     { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) },
1658     { } /* Terminating entry */
1659     @@ -77,6 +78,7 @@ static const struct usb_device_id id_table_combined[] = {
1660     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
1661     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
1662     { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
1663     + { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) },
1664     { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
1665     { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) },
1666     { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
1667     diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
1668     index 119d2e17077b..6d9820bffc20 100644
1669     --- a/drivers/usb/serial/cypress_m8.h
1670     +++ b/drivers/usb/serial/cypress_m8.h
1671     @@ -24,6 +24,9 @@
1672     #define VENDOR_ID_CYPRESS 0x04b4
1673     #define PRODUCT_ID_CYPHIDCOM 0x5500
1674    
1675     +/* Simply Automated HID->COM UPB PIM (using Cypress PID 0x5500) */
1676     +#define VENDOR_ID_SAI 0x17dd
1677     +
1678     /* FRWD Dongle - a GPS sports watch */
1679     #define VENDOR_ID_FRWD 0x6737
1680     #define PRODUCT_ID_CYPHIDCOM_FRWD 0x0001
1681     diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
1682     index d57fb5199218..d6ac1f472b77 100644
1683     --- a/drivers/usb/serial/iuu_phoenix.c
1684     +++ b/drivers/usb/serial/iuu_phoenix.c
1685     @@ -717,14 +717,16 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
1686     struct iuu_private *priv = usb_get_serial_port_data(port);
1687     unsigned long flags;
1688    
1689     - if (count > 256)
1690     - return -ENOMEM;
1691     -
1692     spin_lock_irqsave(&priv->lock, flags);
1693    
1694     + count = min(count, 256 - priv->writelen);
1695     + if (count == 0)
1696     + goto out;
1697     +
1698     /* fill the buffer */
1699     memcpy(priv->writebuf + priv->writelen, buf, count);
1700     priv->writelen += count;
1701     +out:
1702     spin_unlock_irqrestore(&priv->lock, flags);
1703    
1704     return count;
1705     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1706     index 326e7109b8f8..52b1092ed57e 100644
1707     --- a/drivers/usb/serial/option.c
1708     +++ b/drivers/usb/serial/option.c
1709     @@ -248,6 +248,7 @@ static void option_instat_callback(struct urb *urb);
1710     /* These Quectel products use Quectel's vendor ID */
1711     #define QUECTEL_PRODUCT_EC21 0x0121
1712     #define QUECTEL_PRODUCT_EC25 0x0125
1713     +#define QUECTEL_PRODUCT_EG95 0x0195
1714     #define QUECTEL_PRODUCT_BG96 0x0296
1715     #define QUECTEL_PRODUCT_EP06 0x0306
1716    
1717     @@ -1095,6 +1096,8 @@ static const struct usb_device_id option_ids[] = {
1718     .driver_info = RSVD(4) },
1719     { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
1720     .driver_info = RSVD(4) },
1721     + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95),
1722     + .driver_info = RSVD(4) },
1723     { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
1724     .driver_info = RSVD(4) },
1725     { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06),
1726     @@ -2019,6 +2022,9 @@ static const struct usb_device_id option_ids[] = {
1727     .driver_info = RSVD(4) | RSVD(5) },
1728     { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */
1729     .driver_info = RSVD(6) },
1730     + { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */
1731     + { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */
1732     + { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */
1733     { } /* Terminating entry */
1734     };
1735     MODULE_DEVICE_TABLE(usb, option_ids);
1736     diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
1737     index 1372d3e5d90b..8c0ff985c191 100644
1738     --- a/fs/btrfs/extent_io.c
1739     +++ b/fs/btrfs/extent_io.c
1740     @@ -4907,25 +4907,28 @@ struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
1741     static void check_buffer_tree_ref(struct extent_buffer *eb)
1742     {
1743     int refs;
1744     - /* the ref bit is tricky. We have to make sure it is set
1745     - * if we have the buffer dirty. Otherwise the
1746     - * code to free a buffer can end up dropping a dirty
1747     - * page
1748     + /*
1749     + * The TREE_REF bit is first set when the extent_buffer is added
1750     + * to the radix tree. It is also reset, if unset, when a new reference
1751     + * is created by find_extent_buffer.
1752     *
1753     - * Once the ref bit is set, it won't go away while the
1754     - * buffer is dirty or in writeback, and it also won't
1755     - * go away while we have the reference count on the
1756     - * eb bumped.
1757     + * It is only cleared in two cases: freeing the last non-tree
1758     + * reference to the extent_buffer when its STALE bit is set or
1759     + * calling releasepage when the tree reference is the only reference.
1760     *
1761     - * We can't just set the ref bit without bumping the
1762     - * ref on the eb because free_extent_buffer might
1763     - * see the ref bit and try to clear it. If this happens
1764     - * free_extent_buffer might end up dropping our original
1765     - * ref by mistake and freeing the page before we are able
1766     - * to add one more ref.
1767     + * In both cases, care is taken to ensure that the extent_buffer's
1768     + * pages are not under io. However, releasepage can be concurrently
1769     + * called with creating new references, which is prone to race
1770     + * conditions between the calls to check_buffer_tree_ref in those
1771     + * codepaths and clearing TREE_REF in try_release_extent_buffer.
1772     *
1773     - * So bump the ref count first, then set the bit. If someone
1774     - * beat us to it, drop the ref we added.
1775     + * The actual lifetime of the extent_buffer in the radix tree is
1776     + * adequately protected by the refcount, but the TREE_REF bit and
1777     + * its corresponding reference are not. To protect against this
1778     + * class of races, we call check_buffer_tree_ref from the codepaths
1779     + * which trigger io after they set eb->io_pages. Note that once io is
1780     + * initiated, TREE_REF can no longer be cleared, so that is the
1781     + * moment at which any such race is best fixed.
1782     */
1783     refs = atomic_read(&eb->refs);
1784     if (refs >= 2 && test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags))
1785     @@ -5389,6 +5392,11 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
1786     clear_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags);
1787     eb->read_mirror = 0;
1788     atomic_set(&eb->io_pages, num_reads);
1789     + /*
1790     + * It is possible for releasepage to clear the TREE_REF bit before we
1791     + * set io_pages. See check_buffer_tree_ref for a more detailed comment.
1792     + */
1793     + check_buffer_tree_ref(eb);
1794     for (i = 0; i < num_pages; i++) {
1795     page = eb->pages[i];
1796    
1797     diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
1798     index 3dad943da956..acd8e0dccab4 100644
1799     --- a/fs/cifs/inode.c
1800     +++ b/fs/cifs/inode.c
1801     @@ -2194,6 +2194,15 @@ set_size_out:
1802     if (rc == 0) {
1803     cifsInode->server_eof = attrs->ia_size;
1804     cifs_setsize(inode, attrs->ia_size);
1805     +
1806     + /*
1807     + * The man page of truncate says if the size changed,
1808     + * then the st_ctime and st_mtime fields for the file
1809     + * are updated.
1810     + */
1811     + attrs->ia_ctime = attrs->ia_mtime = current_time(inode);
1812     + attrs->ia_valid |= ATTR_CTIME | ATTR_MTIME;
1813     +
1814     cifs_truncate_page(inode->i_mapping, inode->i_size);
1815     }
1816    
1817     diff --git a/fs/fuse/file.c b/fs/fuse/file.c
1818     index 92f905ea20b0..cea2317e0138 100644
1819     --- a/fs/fuse/file.c
1820     +++ b/fs/fuse/file.c
1821     @@ -17,6 +17,7 @@
1822     #include <linux/swap.h>
1823     #include <linux/falloc.h>
1824     #include <linux/uio.h>
1825     +#include <linux/fs.h>
1826    
1827     static const struct file_operations fuse_direct_io_file_operations;
1828    
1829     @@ -2520,7 +2521,16 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
1830     struct iovec *iov = iov_page;
1831    
1832     iov->iov_base = (void __user *)arg;
1833     - iov->iov_len = _IOC_SIZE(cmd);
1834     +
1835     + switch (cmd) {
1836     + case FS_IOC_GETFLAGS:
1837     + case FS_IOC_SETFLAGS:
1838     + iov->iov_len = sizeof(int);
1839     + break;
1840     + default:
1841     + iov->iov_len = _IOC_SIZE(cmd);
1842     + break;
1843     + }
1844    
1845     if (_IOC_DIR(cmd) & _IOC_WRITE) {
1846     in_iov = iov;
1847     diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
1848     index 1619a3213af5..b3e7da0bf50f 100644
1849     --- a/include/linux/cgroup-defs.h
1850     +++ b/include/linux/cgroup-defs.h
1851     @@ -587,7 +587,9 @@ struct sock_cgroup_data {
1852     union {
1853     #ifdef __LITTLE_ENDIAN
1854     struct {
1855     - u8 is_data;
1856     + u8 is_data : 1;
1857     + u8 no_refcnt : 1;
1858     + u8 unused : 6;
1859     u8 padding;
1860     u16 prioidx;
1861     u32 classid;
1862     @@ -597,7 +599,9 @@ struct sock_cgroup_data {
1863     u32 classid;
1864     u16 prioidx;
1865     u8 padding;
1866     - u8 is_data;
1867     + u8 unused : 6;
1868     + u8 no_refcnt : 1;
1869     + u8 is_data : 1;
1870     } __packed;
1871     #endif
1872     u64 val;
1873     diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
1874     index 8be03520995c..75fbf932db50 100644
1875     --- a/include/linux/cgroup.h
1876     +++ b/include/linux/cgroup.h
1877     @@ -657,6 +657,7 @@ extern spinlock_t cgroup_sk_update_lock;
1878    
1879     void cgroup_sk_alloc_disable(void);
1880     void cgroup_sk_alloc(struct sock_cgroup_data *skcd);
1881     +void cgroup_sk_clone(struct sock_cgroup_data *skcd);
1882     void cgroup_sk_free(struct sock_cgroup_data *skcd);
1883    
1884     static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
1885     @@ -670,7 +671,7 @@ static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
1886     */
1887     v = READ_ONCE(skcd->val);
1888    
1889     - if (v & 1)
1890     + if (v & 3)
1891     return &cgrp_dfl_root.cgrp;
1892    
1893     return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;
1894     @@ -682,6 +683,7 @@ static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
1895     #else /* CONFIG_CGROUP_DATA */
1896    
1897     static inline void cgroup_sk_alloc(struct sock_cgroup_data *skcd) {}
1898     +static inline void cgroup_sk_clone(struct sock_cgroup_data *skcd) {}
1899     static inline void cgroup_sk_free(struct sock_cgroup_data *skcd) {}
1900    
1901     #endif /* CONFIG_CGROUP_DATA */
1902     diff --git a/include/linux/usb.h b/include/linux/usb.h
1903     index 9b5ca59271d9..ddbd9c8d3df6 100644
1904     --- a/include/linux/usb.h
1905     +++ b/include/linux/usb.h
1906     @@ -1655,6 +1655,8 @@ static inline int usb_urb_dir_out(struct urb *urb)
1907     return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1908     }
1909    
1910     +int usb_urb_ep_type_check(const struct urb *urb);
1911     +
1912     void *usb_alloc_coherent(struct usb_device *dev, size_t size,
1913     gfp_t mem_flags, dma_addr_t *dma);
1914     void usb_free_coherent(struct usb_device *dev, size_t size,
1915     diff --git a/include/net/dst.h b/include/net/dst.h
1916     index e57e8fb9a43d..12247c034206 100644
1917     --- a/include/net/dst.h
1918     +++ b/include/net/dst.h
1919     @@ -479,7 +479,15 @@ static inline struct neighbour *dst_neigh_lookup(const struct dst_entry *dst, co
1920     static inline struct neighbour *dst_neigh_lookup_skb(const struct dst_entry *dst,
1921     struct sk_buff *skb)
1922     {
1923     - struct neighbour *n = dst->ops->neigh_lookup(dst, skb, NULL);
1924     + struct neighbour *n = NULL;
1925     +
1926     + /* The packets from tunnel devices (eg bareudp) may have only
1927     + * metadata in the dst pointer of skb. Hence a pointer check of
1928     + * neigh_lookup is needed.
1929     + */
1930     + if (dst->ops->neigh_lookup)
1931     + n = dst->ops->neigh_lookup(dst, skb, NULL);
1932     +
1933     return IS_ERR(n) ? NULL : n;
1934     }
1935    
1936     diff --git a/include/net/genetlink.h b/include/net/genetlink.h
1937     index 8d4608ce8716..facf9851ede6 100644
1938     --- a/include/net/genetlink.h
1939     +++ b/include/net/genetlink.h
1940     @@ -33,12 +33,6 @@ struct genl_info;
1941     * do additional, common, filtering and return an error
1942     * @post_doit: called after an operation's doit callback, it may
1943     * undo operations done by pre_doit, for example release locks
1944     - * @mcast_bind: a socket bound to the given multicast group (which
1945     - * is given as the offset into the groups array)
1946     - * @mcast_unbind: a socket was unbound from the given multicast group.
1947     - * Note that unbind() will not be called symmetrically if the
1948     - * generic netlink family is removed while there are still open
1949     - * sockets.
1950     * @attrbuf: buffer to store parsed attributes
1951     * @family_list: family list
1952     * @mcgrps: multicast groups used by this family (private)
1953     @@ -61,8 +55,6 @@ struct genl_family {
1954     void (*post_doit)(const struct genl_ops *ops,
1955     struct sk_buff *skb,
1956     struct genl_info *info);
1957     - int (*mcast_bind)(struct net *net, int group);
1958     - void (*mcast_unbind)(struct net *net, int group);
1959     struct nlattr ** attrbuf; /* private */
1960     const struct genl_ops * ops; /* private */
1961     const struct genl_multicast_group *mcgrps; /* private */
1962     diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
1963     index 49482080311a..b3b06478cf2b 100644
1964     --- a/include/sound/compress_driver.h
1965     +++ b/include/sound/compress_driver.h
1966     @@ -72,6 +72,7 @@ struct snd_compr_runtime {
1967     * @direction: stream direction, playback/recording
1968     * @metadata_set: metadata set flag, true when set
1969     * @next_track: has userspace signal next track transition, true when set
1970     + * @partial_drain: undergoing partial_drain for stream, true when set
1971     * @private_data: pointer to DSP private data
1972     */
1973     struct snd_compr_stream {
1974     @@ -83,6 +84,7 @@ struct snd_compr_stream {
1975     enum snd_compr_direction direction;
1976     bool metadata_set;
1977     bool next_track;
1978     + bool partial_drain;
1979     void *private_data;
1980     };
1981    
1982     @@ -185,7 +187,13 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
1983     if (snd_BUG_ON(!stream))
1984     return;
1985    
1986     - stream->runtime->state = SNDRV_PCM_STATE_SETUP;
1987     + /* for partial_drain case we are back to running state on success */
1988     + if (stream->partial_drain) {
1989     + stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
1990     + stream->partial_drain = false; /* clear this flag as well */
1991     + } else {
1992     + stream->runtime->state = SNDRV_PCM_STATE_SETUP;
1993     + }
1994    
1995     wake_up(&stream->runtime->sleep);
1996     }
1997     diff --git a/kernel/cgroup.c b/kernel/cgroup.c
1998     index 2d7a4fc42a88..f047c73189f3 100644
1999     --- a/kernel/cgroup.c
2000     +++ b/kernel/cgroup.c
2001     @@ -6326,12 +6326,8 @@ void cgroup_sk_alloc_disable(void)
2002    
2003     void cgroup_sk_alloc(struct sock_cgroup_data *skcd)
2004     {
2005     - if (cgroup_sk_alloc_disabled)
2006     - return;
2007     -
2008     - /* Socket clone path */
2009     - if (skcd->val) {
2010     - cgroup_get(sock_cgroup_ptr(skcd));
2011     + if (cgroup_sk_alloc_disabled) {
2012     + skcd->no_refcnt = 1;
2013     return;
2014     }
2015    
2016     @@ -6355,8 +6351,24 @@ void cgroup_sk_alloc(struct sock_cgroup_data *skcd)
2017     rcu_read_unlock();
2018     }
2019    
2020     +void cgroup_sk_clone(struct sock_cgroup_data *skcd)
2021     +{
2022     + /* Socket clone path */
2023     + if (skcd->val) {
2024     + /*
2025     + * We might be cloning a socket which is left in an empty
2026     + * cgroup and the cgroup might have already been rmdir'd.
2027     + * Don't use cgroup_get_live().
2028     + */
2029     + cgroup_get(sock_cgroup_ptr(skcd));
2030     + }
2031     +}
2032     +
2033     void cgroup_sk_free(struct sock_cgroup_data *skcd)
2034     {
2035     + if (skcd->no_refcnt)
2036     + return;
2037     +
2038     cgroup_put(sock_cgroup_ptr(skcd));
2039     }
2040    
2041     diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
2042     index 8233032a2f01..5a349fcb634e 100644
2043     --- a/kernel/sched/fair.c
2044     +++ b/kernel/sched/fair.c
2045     @@ -6561,7 +6561,15 @@ static int detach_tasks(struct lb_env *env)
2046     if (!can_migrate_task(p, env))
2047     goto next;
2048    
2049     - load = task_h_load(p);
2050     + /*
2051     + * Depending of the number of CPUs and tasks and the
2052     + * cgroup hierarchy, task_h_load() can return a null
2053     + * value. Make sure that env->imbalance decreases
2054     + * otherwise detach_tasks() will stop only after
2055     + * detaching up to loop_max tasks.
2056     + */
2057     + load = max_t(unsigned long, task_h_load(p), 1);
2058     +
2059    
2060     if (sched_feat(LB_MIN) && load < 16 && !env->sd->nr_balance_failed)
2061     goto next;
2062     diff --git a/kernel/time/timer.c b/kernel/time/timer.c
2063     index b5603248d841..88c2c597f61c 100644
2064     --- a/kernel/time/timer.c
2065     +++ b/kernel/time/timer.c
2066     @@ -500,8 +500,8 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk)
2067     * Force expire obscene large timeouts to expire at the
2068     * capacity limit of the wheel.
2069     */
2070     - if (expires >= WHEEL_TIMEOUT_CUTOFF)
2071     - expires = WHEEL_TIMEOUT_MAX;
2072     + if (delta >= WHEEL_TIMEOUT_CUTOFF)
2073     + expires = clk + WHEEL_TIMEOUT_MAX;
2074    
2075     idx = calc_index(expires, LVL_DEPTH - 1);
2076     }
2077     diff --git a/net/core/sock.c b/net/core/sock.c
2078     index dac9365151df..3be209f74965 100644
2079     --- a/net/core/sock.c
2080     +++ b/net/core/sock.c
2081     @@ -1533,7 +1533,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
2082     newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;
2083    
2084     sock_reset_flag(newsk, SOCK_DONE);
2085     - cgroup_sk_alloc(&newsk->sk_cgrp_data);
2086     + cgroup_sk_clone(&newsk->sk_cgrp_data);
2087     skb_queue_head_init(&newsk->sk_error_queue);
2088    
2089     filter = rcu_dereference_protected(newsk->sk_filter, 1);
2090     diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
2091     index 9adcd4b1b3fd..4fda9abf38ee 100644
2092     --- a/net/ipv4/ping.c
2093     +++ b/net/ipv4/ping.c
2094     @@ -800,6 +800,9 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
2095     RT_SCOPE_UNIVERSE, sk->sk_protocol,
2096     inet_sk_flowi_flags(sk), faddr, saddr, 0, 0);
2097    
2098     + fl4.fl4_icmp_type = user_icmph.type;
2099     + fl4.fl4_icmp_code = user_icmph.code;
2100     +
2101     security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
2102     rt = ip_route_output_flow(net, &fl4, sk);
2103     if (IS_ERR(rt)) {
2104     diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
2105     index 02918e0d635e..aeda018e4c49 100644
2106     --- a/net/ipv4/tcp.c
2107     +++ b/net/ipv4/tcp.c
2108     @@ -2299,6 +2299,9 @@ int tcp_disconnect(struct sock *sk, int flags)
2109     tp->snd_cwnd_cnt = 0;
2110     tp->window_clamp = 0;
2111     tp->delivered = 0;
2112     + if (icsk->icsk_ca_ops->release)
2113     + icsk->icsk_ca_ops->release(sk);
2114     + memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
2115     tcp_set_ca_state(sk, TCP_CA_Open);
2116     tp->is_sack_reneg = 0;
2117     tcp_clear_retrans(tp);
2118     @@ -2669,10 +2672,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2119    
2120     #ifdef CONFIG_TCP_MD5SIG
2121     case TCP_MD5SIG:
2122     - if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))
2123     - err = tp->af_specific->md5_parse(sk, optval, optlen);
2124     - else
2125     - err = -EINVAL;
2126     + err = tp->af_specific->md5_parse(sk, optval, optlen);
2127     break;
2128     #endif
2129     case TCP_USER_TIMEOUT:
2130     @@ -3207,10 +3207,13 @@ EXPORT_SYMBOL(tcp_md5_hash_skb_data);
2131    
2132     int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key)
2133     {
2134     + u8 keylen = READ_ONCE(key->keylen); /* paired with WRITE_ONCE() in tcp_md5_do_add */
2135     struct scatterlist sg;
2136    
2137     - sg_init_one(&sg, key->key, key->keylen);
2138     - ahash_request_set_crypt(hp->md5_req, &sg, NULL, key->keylen);
2139     + sg_init_one(&sg, key->key, keylen);
2140     + ahash_request_set_crypt(hp->md5_req, &sg, NULL, keylen);
2141     +
2142     + /* tcp_md5_do_add() might change key->key under us */
2143     return crypto_ahash_update(hp->md5_req);
2144     }
2145     EXPORT_SYMBOL(tcp_md5_hash_key);
2146     diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
2147     index 0cdbea9b9288..05643dd7b15d 100644
2148     --- a/net/ipv4/tcp_cong.c
2149     +++ b/net/ipv4/tcp_cong.c
2150     @@ -198,7 +198,7 @@ static void tcp_reinit_congestion_control(struct sock *sk,
2151     icsk->icsk_ca_setsockopt = 1;
2152     memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
2153    
2154     - if (sk->sk_state != TCP_CLOSE)
2155     + if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
2156     tcp_init_congestion_control(sk);
2157     }
2158    
2159     diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
2160     index e1cf810140b0..10c4a5fce215 100644
2161     --- a/net/ipv4/tcp_ipv4.c
2162     +++ b/net/ipv4/tcp_ipv4.c
2163     @@ -936,9 +936,18 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
2164    
2165     key = tcp_md5_do_lookup(sk, addr, family);
2166     if (key) {
2167     - /* Pre-existing entry - just update that one. */
2168     + /* Pre-existing entry - just update that one.
2169     + * Note that the key might be used concurrently.
2170     + */
2171     memcpy(key->key, newkey, newkeylen);
2172     - key->keylen = newkeylen;
2173     +
2174     + /* Pairs with READ_ONCE() in tcp_md5_hash_key().
2175     + * Also note that a reader could catch new key->keylen value
2176     + * but old key->key[], this is the reason we use __GFP_ZERO
2177     + * at sock_kmalloc() time below these lines.
2178     + */
2179     + WRITE_ONCE(key->keylen, newkeylen);
2180     +
2181     return 0;
2182     }
2183    
2184     @@ -954,7 +963,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
2185     rcu_assign_pointer(tp->md5sig_info, md5sig);
2186     }
2187    
2188     - key = sock_kmalloc(sk, sizeof(*key), gfp);
2189     + key = sock_kmalloc(sk, sizeof(*key), gfp | __GFP_ZERO);
2190     if (!key)
2191     return -ENOMEM;
2192     if (!tcp_alloc_md5sig_pool()) {
2193     diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
2194     index ea7e9308c555..84d74c431f83 100644
2195     --- a/net/ipv4/tcp_output.c
2196     +++ b/net/ipv4/tcp_output.c
2197     @@ -615,7 +615,8 @@ static unsigned int tcp_synack_options(struct request_sock *req,
2198     unsigned int mss, struct sk_buff *skb,
2199     struct tcp_out_options *opts,
2200     const struct tcp_md5sig_key *md5,
2201     - struct tcp_fastopen_cookie *foc)
2202     + struct tcp_fastopen_cookie *foc,
2203     + enum tcp_synack_type synack_type)
2204     {
2205     struct inet_request_sock *ireq = inet_rsk(req);
2206     unsigned int remaining = MAX_TCP_OPTION_SPACE;
2207     @@ -630,7 +631,8 @@ static unsigned int tcp_synack_options(struct request_sock *req,
2208     * rather than TS in order to fit in better with old,
2209     * buggy kernels, but that was deemed to be unnecessary.
2210     */
2211     - ireq->tstamp_ok &= !ireq->sack_ok;
2212     + if (synack_type != TCP_SYNACK_COOKIE)
2213     + ireq->tstamp_ok &= !ireq->sack_ok;
2214     }
2215     #endif
2216    
2217     @@ -3165,8 +3167,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
2218     md5 = tcp_rsk(req)->af_specific->req_md5_lookup(sk, req_to_sk(req));
2219     #endif
2220     skb_set_hash(skb, tcp_rsk(req)->txhash, PKT_HASH_TYPE_L4);
2221     - tcp_header_size = tcp_synack_options(req, mss, skb, &opts, md5, foc) +
2222     - sizeof(*th);
2223     + tcp_header_size = tcp_synack_options(req, mss, skb, &opts, md5,
2224     + foc, synack_type) + sizeof(*th);
2225    
2226     skb_push(skb, tcp_header_size);
2227     skb_reset_transport_header(skb);
2228     diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
2229     index c191ea65a6c7..a8f575bf9b7c 100644
2230     --- a/net/l2tp/l2tp_core.c
2231     +++ b/net/l2tp/l2tp_core.c
2232     @@ -1134,6 +1134,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
2233    
2234     /* Queue the packet to IP for output */
2235     skb->ignore_df = 1;
2236     + skb_dst_drop(skb);
2237     #if IS_ENABLED(CONFIG_IPV6)
2238     if (tunnel->sock->sk_family == PF_INET6 && !tunnel->v4mapped)
2239     error = inet6_csk_xmit(tunnel->sock, skb, NULL);
2240     @@ -1198,10 +1199,6 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
2241     goto out_unlock;
2242     }
2243    
2244     - /* Get routing info from the tunnel socket */
2245     - skb_dst_drop(skb);
2246     - skb_dst_set(skb, sk_dst_check(sk, 0));
2247     -
2248     inet = inet_sk(sk);
2249     fl = &inet->cork.fl;
2250     switch (tunnel->encap) {
2251     diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
2252     index 2a859f967c8a..1a77d0687d74 100644
2253     --- a/net/llc/af_llc.c
2254     +++ b/net/llc/af_llc.c
2255     @@ -271,6 +271,10 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
2256    
2257     if (!sock_flag(sk, SOCK_ZAPPED))
2258     goto out;
2259     + if (!addr->sllc_arphrd)
2260     + addr->sllc_arphrd = ARPHRD_ETHER;
2261     + if (addr->sllc_arphrd != ARPHRD_ETHER)
2262     + goto out;
2263     rc = -ENODEV;
2264     if (sk->sk_bound_dev_if) {
2265     llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
2266     @@ -328,15 +332,15 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
2267     if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
2268     goto out;
2269     rc = -EAFNOSUPPORT;
2270     - if (unlikely(addr->sllc_family != AF_LLC))
2271     + if (!addr->sllc_arphrd)
2272     + addr->sllc_arphrd = ARPHRD_ETHER;
2273     + if (unlikely(addr->sllc_family != AF_LLC || addr->sllc_arphrd != ARPHRD_ETHER))
2274     goto out;
2275     rc = -ENODEV;
2276     rcu_read_lock();
2277     if (sk->sk_bound_dev_if) {
2278     llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if);
2279     if (llc->dev) {
2280     - if (!addr->sllc_arphrd)
2281     - addr->sllc_arphrd = llc->dev->type;
2282     if (is_zero_ether_addr(addr->sllc_mac))
2283     memcpy(addr->sllc_mac, llc->dev->dev_addr,
2284     IFHWADDRLEN);
2285     diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
2286     index 9192a6143523..9eb20dbcb411 100644
2287     --- a/net/netlink/genetlink.c
2288     +++ b/net/netlink/genetlink.c
2289     @@ -992,63 +992,11 @@ static const struct genl_multicast_group genl_ctrl_groups[] = {
2290     { .name = "notify", },
2291     };
2292    
2293     -static int genl_bind(struct net *net, int group)
2294     -{
2295     - int i, err = -ENOENT;
2296     -
2297     - down_read(&cb_lock);
2298     - for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
2299     - struct genl_family *f;
2300     -
2301     - list_for_each_entry(f, genl_family_chain(i), family_list) {
2302     - if (group >= f->mcgrp_offset &&
2303     - group < f->mcgrp_offset + f->n_mcgrps) {
2304     - int fam_grp = group - f->mcgrp_offset;
2305     -
2306     - if (!f->netnsok && net != &init_net)
2307     - err = -ENOENT;
2308     - else if (f->mcast_bind)
2309     - err = f->mcast_bind(net, fam_grp);
2310     - else
2311     - err = 0;
2312     - break;
2313     - }
2314     - }
2315     - }
2316     - up_read(&cb_lock);
2317     -
2318     - return err;
2319     -}
2320     -
2321     -static void genl_unbind(struct net *net, int group)
2322     -{
2323     - int i;
2324     -
2325     - down_read(&cb_lock);
2326     - for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
2327     - struct genl_family *f;
2328     -
2329     - list_for_each_entry(f, genl_family_chain(i), family_list) {
2330     - if (group >= f->mcgrp_offset &&
2331     - group < f->mcgrp_offset + f->n_mcgrps) {
2332     - int fam_grp = group - f->mcgrp_offset;
2333     -
2334     - if (f->mcast_unbind)
2335     - f->mcast_unbind(net, fam_grp);
2336     - break;
2337     - }
2338     - }
2339     - }
2340     - up_read(&cb_lock);
2341     -}
2342     -
2343     static int __net_init genl_pernet_init(struct net *net)
2344     {
2345     struct netlink_kernel_cfg cfg = {
2346     .input = genl_rcv,
2347     .flags = NL_CFG_F_NONROOT_RECV,
2348     - .bind = genl_bind,
2349     - .unbind = genl_unbind,
2350     };
2351    
2352     /* we'll bump the group number right afterwards */
2353     diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
2354     index 7ae8e24dc1e6..81624f6e3f33 100644
2355     --- a/sound/core/compress_offload.c
2356     +++ b/sound/core/compress_offload.c
2357     @@ -723,6 +723,9 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
2358    
2359     retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
2360     if (!retval) {
2361     + /* clear flags and stop any drain wait */
2362     + stream->partial_drain = false;
2363     + stream->metadata_set = false;
2364     snd_compr_drain_notify(stream);
2365     stream->runtime->total_bytes_available = 0;
2366     stream->runtime->total_bytes_transferred = 0;
2367     @@ -880,6 +883,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
2368     if (stream->next_track == false)
2369     return -EPERM;
2370    
2371     + stream->partial_drain = true;
2372     retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN);
2373     if (retval) {
2374     pr_debug("Partial drain returned failure\n");
2375     diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
2376     index 42920a243328..3f94746d587a 100644
2377     --- a/sound/drivers/opl3/opl3_synth.c
2378     +++ b/sound/drivers/opl3/opl3_synth.c
2379     @@ -104,6 +104,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
2380     {
2381     struct snd_dm_fm_info info;
2382    
2383     + memset(&info, 0, sizeof(info));
2384     +
2385     info.fm_mode = opl3->fm_mode;
2386     info.rhythm = opl3->rhythm;
2387     if (copy_to_user(argp, &info, sizeof(struct snd_dm_fm_info)))
2388     diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
2389     index 12d87204e373..7ac92d188f4f 100644
2390     --- a/sound/pci/hda/hda_auto_parser.c
2391     +++ b/sound/pci/hda/hda_auto_parser.c
2392     @@ -76,6 +76,12 @@ static int compare_input_type(const void *ap, const void *bp)
2393     if (a->type != b->type)
2394     return (int)(a->type - b->type);
2395    
2396     + /* If has both hs_mic and hp_mic, pick the hs_mic ahead of hp_mic. */
2397     + if (a->is_headset_mic && b->is_headphone_mic)
2398     + return -1; /* don't swap */
2399     + else if (a->is_headphone_mic && b->is_headset_mic)
2400     + return 1; /* swap */
2401     +
2402     /* In case one has boost and the other one has not,
2403     pick the one with boost first. */
2404     return (int)(b->has_boost_on_pin - a->has_boost_on_pin);
2405     diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c
2406     index 7c812565f90d..a65a82d5791d 100644
2407     --- a/sound/usb/line6/capture.c
2408     +++ b/sound/usb/line6/capture.c
2409     @@ -291,6 +291,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
2410     urb->interval = LINE6_ISO_INTERVAL;
2411     urb->error_count = 0;
2412     urb->complete = audio_in_callback;
2413     + if (usb_urb_ep_type_check(urb))
2414     + return -EINVAL;
2415     }
2416    
2417     return 0;
2418     diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c
2419     index 812d18191e01..1736eb3ee98e 100644
2420     --- a/sound/usb/line6/playback.c
2421     +++ b/sound/usb/line6/playback.c
2422     @@ -436,6 +436,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
2423     urb->interval = LINE6_ISO_INTERVAL;
2424     urb->error_count = 0;
2425     urb->complete = audio_out_callback;
2426     + if (usb_urb_ep_type_check(urb))
2427     + return -EINVAL;
2428     }
2429    
2430     return 0;
2431     diff --git a/sound/usb/midi.c b/sound/usb/midi.c
2432     index 7ba92921bf28..0676e7d485de 100644
2433     --- a/sound/usb/midi.c
2434     +++ b/sound/usb/midi.c
2435     @@ -1477,6 +1477,8 @@ void snd_usbmidi_disconnect(struct list_head *p)
2436     spin_unlock_irq(&umidi->disc_lock);
2437     up_write(&umidi->disc_rwsem);
2438    
2439     + del_timer_sync(&umidi->error_timer);
2440     +
2441     for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
2442     struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
2443     if (ep->out)
2444     @@ -1503,7 +1505,6 @@ void snd_usbmidi_disconnect(struct list_head *p)
2445     ep->in = NULL;
2446     }
2447     }
2448     - del_timer_sync(&umidi->error_timer);
2449     }
2450     EXPORT_SYMBOL(snd_usbmidi_disconnect);
2451    
2452     @@ -2260,16 +2261,22 @@ void snd_usbmidi_input_stop(struct list_head *p)
2453     }
2454     EXPORT_SYMBOL(snd_usbmidi_input_stop);
2455    
2456     -static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint *ep)
2457     +static void snd_usbmidi_input_start_ep(struct snd_usb_midi *umidi,
2458     + struct snd_usb_midi_in_endpoint *ep)
2459     {
2460     unsigned int i;
2461     + unsigned long flags;
2462    
2463     if (!ep)
2464     return;
2465     for (i = 0; i < INPUT_URBS; ++i) {
2466     struct urb *urb = ep->urbs[i];
2467     - urb->dev = ep->umidi->dev;
2468     - snd_usbmidi_submit_urb(urb, GFP_KERNEL);
2469     + spin_lock_irqsave(&umidi->disc_lock, flags);
2470     + if (!atomic_read(&urb->use_count)) {
2471     + urb->dev = ep->umidi->dev;
2472     + snd_usbmidi_submit_urb(urb, GFP_ATOMIC);
2473     + }
2474     + spin_unlock_irqrestore(&umidi->disc_lock, flags);
2475     }
2476     }
2477    
2478     @@ -2285,7 +2292,7 @@ void snd_usbmidi_input_start(struct list_head *p)
2479     if (umidi->input_running || !umidi->opened[1])
2480     return;
2481     for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
2482     - snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
2483     + snd_usbmidi_input_start_ep(umidi, umidi->endpoints[i].in);
2484     umidi->input_running = 1;
2485     }
2486     EXPORT_SYMBOL(snd_usbmidi_input_start);
2487     diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
2488     index c892b4d1e733..ec56ce382061 100644
2489     --- a/sound/usb/quirks-table.h
2490     +++ b/sound/usb/quirks-table.h
2491     @@ -3323,4 +3323,56 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
2492     }
2493     },
2494    
2495     +/*
2496     + * MacroSilicon MS2109 based HDMI capture cards
2497     + *
2498     + * These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch.
2499     + * They also need QUIRK_AUDIO_ALIGN_TRANSFER, which makes one wonder if
2500     + * they pretend to be 96kHz mono as a workaround for stereo being broken
2501     + * by that...
2502     + *
2503     + * They also have swapped L-R channels, but that's for userspace to deal
2504     + * with.
2505     + */
2506     +{
2507     + USB_DEVICE(0x534d, 0x2109),
2508     + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2509     + .vendor_name = "MacroSilicon",
2510     + .product_name = "MS2109",
2511     + .ifnum = QUIRK_ANY_INTERFACE,
2512     + .type = QUIRK_COMPOSITE,
2513     + .data = &(const struct snd_usb_audio_quirk[]) {
2514     + {
2515     + .ifnum = 2,
2516     + .type = QUIRK_AUDIO_ALIGN_TRANSFER,
2517     + },
2518     + {
2519     + .ifnum = 2,
2520     + .type = QUIRK_AUDIO_STANDARD_MIXER,
2521     + },
2522     + {
2523     + .ifnum = 3,
2524     + .type = QUIRK_AUDIO_FIXED_ENDPOINT,
2525     + .data = &(const struct audioformat) {
2526     + .formats = SNDRV_PCM_FMTBIT_S16_LE,
2527     + .channels = 2,
2528     + .iface = 3,
2529     + .altsetting = 1,
2530     + .altset_idx = 1,
2531     + .attributes = 0,
2532     + .endpoint = 0x82,
2533     + .ep_attr = USB_ENDPOINT_XFER_ISOC |
2534     + USB_ENDPOINT_SYNC_ASYNC,
2535     + .rates = SNDRV_PCM_RATE_CONTINUOUS,
2536     + .rate_min = 48000,
2537     + .rate_max = 48000,
2538     + }
2539     + },
2540     + {
2541     + .ifnum = -1
2542     + }
2543     + }
2544     + }
2545     +},
2546     +
2547     #undef USB_DEVICE_VENDOR_SPEC
2548     diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
2549     index d4f872f1750e..8a178b36981a 100644
2550     --- a/tools/perf/util/stat.c
2551     +++ b/tools/perf/util/stat.c
2552     @@ -341,8 +341,10 @@ int perf_stat_process_counter(struct perf_stat_config *config,
2553     * interval mode, otherwise overall avg running
2554     * averages will be shown for each interval.
2555     */
2556     - if (config->interval)
2557     - init_stats(ps->res_stats);
2558     + if (config->interval) {
2559     + for (i = 0; i < 3; i++)
2560     + init_stats(&ps->res_stats[i]);
2561     + }
2562    
2563     if (counter->per_pkg)
2564     zero_per_pkg(counter);