Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.4/0111-4.4.12-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2810 - (hide annotations) (download)
Fri Jun 17 10:51:01 2016 UTC (8 years ago) by niro
File size: 139652 byte(s)
-linux-4.4.12
1 niro 2810 diff --git a/Documentation/serial/tty.txt b/Documentation/serial/tty.txt
2     index bc3842dc323a..e2dea3dc4307 100644
3     --- a/Documentation/serial/tty.txt
4     +++ b/Documentation/serial/tty.txt
5     @@ -213,9 +213,6 @@ TTY_IO_ERROR If set, causes all subsequent userspace read/write
6    
7     TTY_OTHER_CLOSED Device is a pty and the other side has closed.
8    
9     -TTY_OTHER_DONE Device is a pty and the other side has closed and
10     - all pending input processing has been completed.
11     -
12     TTY_NO_WRITE_SPLIT Prevent driver from splitting up writes into
13     smaller chunks.
14    
15     diff --git a/Makefile b/Makefile
16     index aad86274b61b..a1fbd691a36e 100644
17     --- a/Makefile
18     +++ b/Makefile
19     @@ -1,6 +1,6 @@
20     VERSION = 4
21     PATCHLEVEL = 4
22     -SUBLEVEL = 11
23     +SUBLEVEL = 12
24     EXTRAVERSION =
25     NAME = Blurry Fish Butt
26    
27     @@ -682,9 +682,10 @@ KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
28     KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
29     else
30    
31     -# This warning generated too much noise in a regular build.
32     -# Use make W=1 to enable this warning (see scripts/Makefile.build)
33     +# These warnings generated too much noise in a regular build.
34     +# Use make W=1 to enable them (see scripts/Makefile.build)
35     KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
36     +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
37     endif
38    
39     ifdef CONFIG_FRAME_POINTER
40     diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
41     index 61d96a645ff3..12d727fae0a7 100644
42     --- a/arch/arm/kvm/mmu.c
43     +++ b/arch/arm/kvm/mmu.c
44     @@ -886,11 +886,14 @@ static int stage2_set_pmd_huge(struct kvm *kvm, struct kvm_mmu_memory_cache
45     VM_BUG_ON(pmd_present(*pmd) && pmd_pfn(*pmd) != pmd_pfn(*new_pmd));
46    
47     old_pmd = *pmd;
48     - kvm_set_pmd(pmd, *new_pmd);
49     - if (pmd_present(old_pmd))
50     + if (pmd_present(old_pmd)) {
51     + pmd_clear(pmd);
52     kvm_tlb_flush_vmid_ipa(kvm, addr);
53     - else
54     + } else {
55     get_page(virt_to_page(pmd));
56     + }
57     +
58     + kvm_set_pmd(pmd, *new_pmd);
59     return 0;
60     }
61    
62     @@ -939,12 +942,14 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
63    
64     /* Create 2nd stage page table mapping - Level 3 */
65     old_pte = *pte;
66     - kvm_set_pte(pte, *new_pte);
67     - if (pte_present(old_pte))
68     + if (pte_present(old_pte)) {
69     + kvm_set_pte(pte, __pte(0));
70     kvm_tlb_flush_vmid_ipa(kvm, addr);
71     - else
72     + } else {
73     get_page(virt_to_page(pte));
74     + }
75    
76     + kvm_set_pte(pte, *new_pte);
77     return 0;
78     }
79    
80     diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
81     index d6739e836f7b..b9da9545b442 100644
82     --- a/arch/arm64/include/asm/pgtable-hwdef.h
83     +++ b/arch/arm64/include/asm/pgtable-hwdef.h
84     @@ -117,7 +117,6 @@
85     * Section
86     */
87     #define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0)
88     -#define PMD_SECT_PROT_NONE (_AT(pmdval_t, 1) << 58)
89     #define PMD_SECT_USER (_AT(pmdval_t, 1) << 6) /* AP[1] */
90     #define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7) /* AP[2] */
91     #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
92     diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
93     index c63868ae9a4a..67c2ad6d33b7 100644
94     --- a/arch/arm64/include/asm/pgtable.h
95     +++ b/arch/arm64/include/asm/pgtable.h
96     @@ -347,6 +347,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address,
97     #endif /* CONFIG_HAVE_RCU_TABLE_FREE */
98     #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
99    
100     +#define pmd_present(pmd) pte_present(pmd_pte(pmd))
101     #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd))
102     #define pmd_young(pmd) pte_young(pmd_pte(pmd))
103     #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
104     @@ -355,7 +356,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address,
105     #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
106     #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
107     #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
108     -#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) & ~PMD_TYPE_MASK))
109     +#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) & ~PMD_SECT_VALID))
110    
111     #define __HAVE_ARCH_PMD_WRITE
112     #define pmd_write(pmd) pte_write(pmd_pte(pmd))
113     @@ -394,7 +395,6 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
114     unsigned long size, pgprot_t vma_prot);
115    
116     #define pmd_none(pmd) (!pmd_val(pmd))
117     -#define pmd_present(pmd) (pmd_val(pmd))
118    
119     #define pmd_bad(pmd) (!(pmd_val(pmd) & 2))
120    
121     @@ -538,6 +538,21 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
122     }
123    
124     #ifdef CONFIG_ARM64_HW_AFDBM
125     +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
126     +extern int ptep_set_access_flags(struct vm_area_struct *vma,
127     + unsigned long address, pte_t *ptep,
128     + pte_t entry, int dirty);
129     +
130     +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
131     +#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
132     +static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
133     + unsigned long address, pmd_t *pmdp,
134     + pmd_t entry, int dirty)
135     +{
136     + return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty);
137     +}
138     +#endif
139     +
140     /*
141     * Atomic pte/pmd modifications.
142     */
143     @@ -590,9 +605,9 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
144     }
145    
146     #ifdef CONFIG_TRANSPARENT_HUGEPAGE
147     -#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
148     -static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
149     - unsigned long address, pmd_t *pmdp)
150     +#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
151     +static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
152     + unsigned long address, pmd_t *pmdp)
153     {
154     return pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp));
155     }
156     diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
157     index 212ae6361d8b..a5f234039616 100644
158     --- a/arch/arm64/kernel/cpuinfo.c
159     +++ b/arch/arm64/kernel/cpuinfo.c
160     @@ -85,7 +85,8 @@ static const char *const compat_hwcap_str[] = {
161     "idivt",
162     "vfpd32",
163     "lpae",
164     - "evtstrm"
165     + "evtstrm",
166     + NULL
167     };
168    
169     static const char *const compat_hwcap2_str[] = {
170     diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c
171     index 648112e90ed5..3972e65fbd5a 100644
172     --- a/arch/arm64/kvm/inject_fault.c
173     +++ b/arch/arm64/kvm/inject_fault.c
174     @@ -130,7 +130,7 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr
175     esr |= (ESR_ELx_EC_IABT_CUR << ESR_ELx_EC_SHIFT);
176    
177     if (!is_iabt)
178     - esr |= ESR_ELx_EC_DABT_LOW;
179     + esr |= ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT;
180    
181     vcpu_sys_reg(vcpu, ESR_EL1) = esr | ESR_ELx_FSC_EXTABT;
182     }
183     diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
184     index 92ddac1e8ca2..40f5522245a2 100644
185     --- a/arch/arm64/mm/fault.c
186     +++ b/arch/arm64/mm/fault.c
187     @@ -81,6 +81,56 @@ void show_pte(struct mm_struct *mm, unsigned long addr)
188     printk("\n");
189     }
190    
191     +#ifdef CONFIG_ARM64_HW_AFDBM
192     +/*
193     + * This function sets the access flags (dirty, accessed), as well as write
194     + * permission, and only to a more permissive setting.
195     + *
196     + * It needs to cope with hardware update of the accessed/dirty state by other
197     + * agents in the system and can safely skip the __sync_icache_dcache() call as,
198     + * like set_pte_at(), the PTE is never changed from no-exec to exec here.
199     + *
200     + * Returns whether or not the PTE actually changed.
201     + */
202     +int ptep_set_access_flags(struct vm_area_struct *vma,
203     + unsigned long address, pte_t *ptep,
204     + pte_t entry, int dirty)
205     +{
206     + pteval_t old_pteval;
207     + unsigned int tmp;
208     +
209     + if (pte_same(*ptep, entry))
210     + return 0;
211     +
212     + /* only preserve the access flags and write permission */
213     + pte_val(entry) &= PTE_AF | PTE_WRITE | PTE_DIRTY;
214     +
215     + /*
216     + * PTE_RDONLY is cleared by default in the asm below, so set it in
217     + * back if necessary (read-only or clean PTE).
218     + */
219     + if (!pte_write(entry) || !dirty)
220     + pte_val(entry) |= PTE_RDONLY;
221     +
222     + /*
223     + * Setting the flags must be done atomically to avoid racing with the
224     + * hardware update of the access/dirty state.
225     + */
226     + asm volatile("// ptep_set_access_flags\n"
227     + " prfm pstl1strm, %2\n"
228     + "1: ldxr %0, %2\n"
229     + " and %0, %0, %3 // clear PTE_RDONLY\n"
230     + " orr %0, %0, %4 // set flags\n"
231     + " stxr %w1, %0, %2\n"
232     + " cbnz %w1, 1b\n"
233     + : "=&r" (old_pteval), "=&r" (tmp), "+Q" (pte_val(*ptep))
234     + : "L" (~PTE_RDONLY), "r" (pte_val(entry)));
235     +
236     + flush_tlb_fix_spurious_fault(vma, address);
237     + return 1;
238     +}
239     +#endif
240     +
241     /*
242     * The kernel tried to access some page that wasn't present.
243     */
244     diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
245     index 6ded8d347af9..4e956b3e16f5 100644
246     --- a/arch/mips/include/asm/kvm_host.h
247     +++ b/arch/mips/include/asm/kvm_host.h
248     @@ -784,7 +784,7 @@ extern enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu,
249    
250     uint32_t kvm_mips_read_count(struct kvm_vcpu *vcpu);
251     void kvm_mips_write_count(struct kvm_vcpu *vcpu, uint32_t count);
252     -void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare);
253     +void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare, bool ack);
254     void kvm_mips_init_count(struct kvm_vcpu *vcpu);
255     int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl);
256     int kvm_mips_set_count_resume(struct kvm_vcpu *vcpu, s64 count_resume);
257     diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
258     index 41b1b090f56f..dc10c77b7500 100644
259     --- a/arch/mips/kvm/emulate.c
260     +++ b/arch/mips/kvm/emulate.c
261     @@ -302,12 +302,31 @@ static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu)
262     */
263     static uint32_t kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
264     {
265     - ktime_t expires;
266     + struct mips_coproc *cop0 = vcpu->arch.cop0;
267     + ktime_t expires, threshold;
268     + uint32_t count, compare;
269     int running;
270    
271     - /* Is the hrtimer pending? */
272     + /* Calculate the biased and scaled guest CP0_Count */
273     + count = vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now);
274     + compare = kvm_read_c0_guest_compare(cop0);
275     +
276     + /*
277     + * Find whether CP0_Count has reached the closest timer interrupt. If
278     + * not, we shouldn't inject it.
279     + */
280     + if ((int32_t)(count - compare) < 0)
281     + return count;
282     +
283     + /*
284     + * The CP0_Count we're going to return has already reached the closest
285     + * timer interrupt. Quickly check if it really is a new interrupt by
286     + * looking at whether the interval until the hrtimer expiry time is
287     + * less than 1/4 of the timer period.
288     + */
289     expires = hrtimer_get_expires(&vcpu->arch.comparecount_timer);
290     - if (ktime_compare(now, expires) >= 0) {
291     + threshold = ktime_add_ns(now, vcpu->arch.count_period / 4);
292     + if (ktime_before(expires, threshold)) {
293     /*
294     * Cancel it while we handle it so there's no chance of
295     * interference with the timeout handler.
296     @@ -329,8 +348,7 @@ static uint32_t kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
297     }
298     }
299    
300     - /* Return the biased and scaled guest CP0_Count */
301     - return vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now);
302     + return count;
303     }
304    
305     /**
306     @@ -420,32 +438,6 @@ static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu,
307     }
308    
309     /**
310     - * kvm_mips_update_hrtimer() - Update next expiry time of hrtimer.
311     - * @vcpu: Virtual CPU.
312     - *
313     - * Recalculates and updates the expiry time of the hrtimer. This can be used
314     - * after timer parameters have been altered which do not depend on the time that
315     - * the change occurs (in those cases kvm_mips_freeze_hrtimer() and
316     - * kvm_mips_resume_hrtimer() are used directly).
317     - *
318     - * It is guaranteed that no timer interrupts will be lost in the process.
319     - *
320     - * Assumes !kvm_mips_count_disabled(@vcpu) (guest CP0_Count timer is running).
321     - */
322     -static void kvm_mips_update_hrtimer(struct kvm_vcpu *vcpu)
323     -{
324     - ktime_t now;
325     - uint32_t count;
326     -
327     - /*
328     - * freeze_hrtimer takes care of a timer interrupts <= count, and
329     - * resume_hrtimer the hrtimer takes care of a timer interrupts > count.
330     - */
331     - now = kvm_mips_freeze_hrtimer(vcpu, &count);
332     - kvm_mips_resume_hrtimer(vcpu, now, count);
333     -}
334     -
335     -/**
336     * kvm_mips_write_count() - Modify the count and update timer.
337     * @vcpu: Virtual CPU.
338     * @count: Guest CP0_Count value to set.
339     @@ -540,23 +532,42 @@ int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
340     * kvm_mips_write_compare() - Modify compare and update timer.
341     * @vcpu: Virtual CPU.
342     * @compare: New CP0_Compare value.
343     + * @ack: Whether to acknowledge timer interrupt.
344     *
345     * Update CP0_Compare to a new value and update the timeout.
346     + * If @ack, atomically acknowledge any pending timer interrupt, otherwise ensure
347     + * any pending timer interrupt is preserved.
348     */
349     -void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare)
350     +void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare, bool ack)
351     {
352     struct mips_coproc *cop0 = vcpu->arch.cop0;
353     + int dc;
354     + u32 old_compare = kvm_read_c0_guest_compare(cop0);
355     + ktime_t now;
356     + uint32_t count;
357    
358     /* if unchanged, must just be an ack */
359     - if (kvm_read_c0_guest_compare(cop0) == compare)
360     + if (old_compare == compare) {
361     + if (!ack)
362     + return;
363     + kvm_mips_callbacks->dequeue_timer_int(vcpu);
364     + kvm_write_c0_guest_compare(cop0, compare);
365     return;
366     + }
367     +
368     + /* freeze_hrtimer() takes care of timer interrupts <= count */
369     + dc = kvm_mips_count_disabled(vcpu);
370     + if (!dc)
371     + now = kvm_mips_freeze_hrtimer(vcpu, &count);
372     +
373     + if (ack)
374     + kvm_mips_callbacks->dequeue_timer_int(vcpu);
375    
376     - /* Update compare */
377     kvm_write_c0_guest_compare(cop0, compare);
378    
379     - /* Update timeout if count enabled */
380     - if (!kvm_mips_count_disabled(vcpu))
381     - kvm_mips_update_hrtimer(vcpu);
382     + /* resume_hrtimer() takes care of timer interrupts > count */
383     + if (!dc)
384     + kvm_mips_resume_hrtimer(vcpu, now, count);
385     }
386    
387     /**
388     @@ -1095,9 +1106,9 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc,
389    
390     /* If we are writing to COMPARE */
391     /* Clear pending timer interrupt, if any */
392     - kvm_mips_callbacks->dequeue_timer_int(vcpu);
393     kvm_mips_write_compare(vcpu,
394     - vcpu->arch.gprs[rt]);
395     + vcpu->arch.gprs[rt],
396     + true);
397     } else if ((rd == MIPS_CP0_STATUS) && (sel == 0)) {
398     unsigned int old_val, val, change;
399    
400     diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
401     index d836ed5b0bc7..307cc4c98bdd 100644
402     --- a/arch/mips/kvm/trap_emul.c
403     +++ b/arch/mips/kvm/trap_emul.c
404     @@ -547,7 +547,7 @@ static int kvm_trap_emul_set_one_reg(struct kvm_vcpu *vcpu,
405     kvm_mips_write_count(vcpu, v);
406     break;
407     case KVM_REG_MIPS_CP0_COMPARE:
408     - kvm_mips_write_compare(vcpu, v);
409     + kvm_mips_write_compare(vcpu, v, false);
410     break;
411     case KVM_REG_MIPS_CP0_CAUSE:
412     /*
413     diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
414     index 868e1194337f..49e35d003b74 100644
415     --- a/arch/x86/kernel/cpu/perf_event_intel_pt.c
416     +++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
417     @@ -694,6 +694,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
418    
419     /* clear STOP and INT from current entry */
420     buf->topa_index[buf->stop_pos]->stop = 0;
421     + buf->topa_index[buf->stop_pos]->intr = 0;
422     buf->topa_index[buf->intr_pos]->intr = 0;
423    
424     /* how many pages till the STOP marker */
425     @@ -718,6 +719,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
426     buf->intr_pos = idx;
427    
428     buf->topa_index[buf->stop_pos]->stop = 1;
429     + buf->topa_index[buf->stop_pos]->intr = 1;
430     buf->topa_index[buf->intr_pos]->intr = 1;
431    
432     return 0;
433     diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
434     index 6525e926f566..2e1fd586b895 100644
435     --- a/arch/x86/kvm/cpuid.c
436     +++ b/arch/x86/kvm/cpuid.c
437     @@ -509,6 +509,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
438     do_cpuid_1_ent(&entry[i], function, idx);
439     if (idx == 1) {
440     entry[i].eax &= kvm_supported_word10_x86_features;
441     + cpuid_mask(&entry[i].eax, 10);
442     entry[i].ebx = 0;
443     if (entry[i].eax & (F(XSAVES)|F(XSAVEC)))
444     entry[i].ebx =
445     diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c
446     index 3f8c732117ec..c146f3c262c3 100644
447     --- a/arch/x86/kvm/mtrr.c
448     +++ b/arch/x86/kvm/mtrr.c
449     @@ -44,8 +44,6 @@ static bool msr_mtrr_valid(unsigned msr)
450     case MSR_MTRRdefType:
451     case MSR_IA32_CR_PAT:
452     return true;
453     - case 0x2f8:
454     - return true;
455     }
456     return false;
457     }
458     diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
459     index f34ab71dfd57..f314e9b9660b 100644
460     --- a/arch/x86/kvm/vmx.c
461     +++ b/arch/x86/kvm/vmx.c
462     @@ -4954,8 +4954,8 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
463     vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
464    
465     cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
466     - vmx_set_cr0(vcpu, cr0); /* enter rmode */
467     vmx->vcpu.arch.cr0 = cr0;
468     + vmx_set_cr0(vcpu, cr0); /* enter rmode */
469     vmx_set_cr4(vcpu, 0);
470     vmx_set_efer(vcpu, 0);
471     vmx_fpu_activate(vcpu);
472     diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
473     index ff31ab464213..c6d6efed392a 100644
474     --- a/arch/x86/pci/xen.c
475     +++ b/arch/x86/pci/xen.c
476     @@ -488,8 +488,11 @@ int __init pci_xen_initial_domain(void)
477     #endif
478     __acpi_register_gsi = acpi_register_gsi_xen;
479     __acpi_unregister_gsi = NULL;
480     - /* Pre-allocate legacy irqs */
481     - for (irq = 0; irq < nr_legacy_irqs(); irq++) {
482     + /*
483     + * Pre-allocate the legacy IRQs. Use NR_LEGACY_IRQS here
484     + * because we don't have a PIC and thus nr_legacy_irqs() is zero.
485     + */
486     + for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
487     int trigger, polarity;
488    
489     if (acpi_get_override_irq(irq, &trigger, &polarity) == -1)
490     diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
491     index 32d684af0ec7..a000ecb995e6 100644
492     --- a/drivers/acpi/osl.c
493     +++ b/drivers/acpi/osl.c
494     @@ -135,7 +135,7 @@ static struct osi_linux {
495     unsigned int enable:1;
496     unsigned int dmi:1;
497     unsigned int cmdline:1;
498     - unsigned int default_disabling:1;
499     + u8 default_disabling;
500     } osi_linux = {0, 0, 0, 0};
501    
502     static u32 acpi_osi_handler(acpi_string interface, u32 supported)
503     @@ -1444,10 +1444,13 @@ void __init acpi_osi_setup(char *str)
504     if (*str == '!') {
505     str++;
506     if (*str == '\0') {
507     - osi_linux.default_disabling = 1;
508     + /* Do not override acpi_osi=!* */
509     + if (!osi_linux.default_disabling)
510     + osi_linux.default_disabling =
511     + ACPI_DISABLE_ALL_VENDOR_STRINGS;
512     return;
513     } else if (*str == '*') {
514     - acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
515     + osi_linux.default_disabling = ACPI_DISABLE_ALL_STRINGS;
516     for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
517     osi = &osi_setup_entries[i];
518     osi->enable = false;
519     @@ -1520,10 +1523,13 @@ static void __init acpi_osi_setup_late(void)
520     acpi_status status;
521    
522     if (osi_linux.default_disabling) {
523     - status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
524     + status = acpi_update_interfaces(osi_linux.default_disabling);
525    
526     if (ACPI_SUCCESS(status))
527     - printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
528     + printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n",
529     + osi_linux.default_disabling ==
530     + ACPI_DISABLE_ALL_STRINGS ?
531     + " and feature groups" : "");
532     }
533    
534     for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
535     diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
536     index ed888e302bc3..597b2d16b775 100644
537     --- a/drivers/bluetooth/hci_vhci.c
538     +++ b/drivers/bluetooth/hci_vhci.c
539     @@ -50,6 +50,7 @@ struct vhci_data {
540     wait_queue_head_t read_wait;
541     struct sk_buff_head readq;
542    
543     + struct mutex open_mutex;
544     struct delayed_work open_timeout;
545     };
546    
547     @@ -87,12 +88,15 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
548     return 0;
549     }
550    
551     -static int vhci_create_device(struct vhci_data *data, __u8 opcode)
552     +static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
553     {
554     struct hci_dev *hdev;
555     struct sk_buff *skb;
556     __u8 dev_type;
557    
558     + if (data->hdev)
559     + return -EBADFD;
560     +
561     /* bits 0-1 are dev_type (BR/EDR or AMP) */
562     dev_type = opcode & 0x03;
563    
564     @@ -151,6 +155,17 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
565     return 0;
566     }
567    
568     +static int vhci_create_device(struct vhci_data *data, __u8 opcode)
569     +{
570     + int err;
571     +
572     + mutex_lock(&data->open_mutex);
573     + err = __vhci_create_device(data, opcode);
574     + mutex_unlock(&data->open_mutex);
575     +
576     + return err;
577     +}
578     +
579     static inline ssize_t vhci_get_user(struct vhci_data *data,
580     struct iov_iter *from)
581     {
582     @@ -189,11 +204,6 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
583     break;
584    
585     case HCI_VENDOR_PKT:
586     - if (data->hdev) {
587     - kfree_skb(skb);
588     - return -EBADFD;
589     - }
590     -
591     cancel_delayed_work_sync(&data->open_timeout);
592    
593     opcode = *((__u8 *) skb->data);
594     @@ -320,6 +330,7 @@ static int vhci_open(struct inode *inode, struct file *file)
595     skb_queue_head_init(&data->readq);
596     init_waitqueue_head(&data->read_wait);
597    
598     + mutex_init(&data->open_mutex);
599     INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
600    
601     file->private_data = data;
602     @@ -333,15 +344,18 @@ static int vhci_open(struct inode *inode, struct file *file)
603     static int vhci_release(struct inode *inode, struct file *file)
604     {
605     struct vhci_data *data = file->private_data;
606     - struct hci_dev *hdev = data->hdev;
607     + struct hci_dev *hdev;
608    
609     cancel_delayed_work_sync(&data->open_timeout);
610    
611     + hdev = data->hdev;
612     +
613     if (hdev) {
614     hci_unregister_dev(hdev);
615     hci_free_dev(hdev);
616     }
617    
618     + skb_queue_purge(&data->readq);
619     file->private_data = NULL;
620     kfree(data);
621    
622     diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
623     index 4f9830c1b121..185a4d859638 100644
624     --- a/drivers/clk/bcm/clk-bcm2835.c
625     +++ b/drivers/clk/bcm/clk-bcm2835.c
626     @@ -1068,10 +1068,12 @@ static void bcm2835_pll_divider_off(struct clk_hw *hw)
627     struct bcm2835_cprman *cprman = divider->cprman;
628     const struct bcm2835_pll_divider_data *data = divider->data;
629    
630     + spin_lock(&cprman->regs_lock);
631     cprman_write(cprman, data->cm_reg,
632     (cprman_read(cprman, data->cm_reg) &
633     ~data->load_mask) | data->hold_mask);
634     cprman_write(cprman, data->a2w_reg, A2W_PLL_CHANNEL_DISABLE);
635     + spin_unlock(&cprman->regs_lock);
636     }
637    
638     static int bcm2835_pll_divider_on(struct clk_hw *hw)
639     @@ -1080,12 +1082,14 @@ static int bcm2835_pll_divider_on(struct clk_hw *hw)
640     struct bcm2835_cprman *cprman = divider->cprman;
641     const struct bcm2835_pll_divider_data *data = divider->data;
642    
643     + spin_lock(&cprman->regs_lock);
644     cprman_write(cprman, data->a2w_reg,
645     cprman_read(cprman, data->a2w_reg) &
646     ~A2W_PLL_CHANNEL_DISABLE);
647    
648     cprman_write(cprman, data->cm_reg,
649     cprman_read(cprman, data->cm_reg) & ~data->hold_mask);
650     + spin_unlock(&cprman->regs_lock);
651    
652     return 0;
653     }
654     diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c
655     index d0a0313d6bef..2e7f03d50f4e 100644
656     --- a/drivers/clk/qcom/gcc-msm8916.c
657     +++ b/drivers/clk/qcom/gcc-msm8916.c
658     @@ -2346,6 +2346,7 @@ static struct clk_branch gcc_crypto_ahb_clk = {
659     "pcnoc_bfdcd_clk_src",
660     },
661     .num_parents = 1,
662     + .flags = CLK_SET_RATE_PARENT,
663     .ops = &clk_branch2_ops,
664     },
665     },
666     @@ -2381,6 +2382,7 @@ static struct clk_branch gcc_crypto_clk = {
667     "crypto_clk_src",
668     },
669     .num_parents = 1,
670     + .flags = CLK_SET_RATE_PARENT,
671     .ops = &clk_branch2_ops,
672     },
673     },
674     diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
675     index f7e0d8d4c3da..8f50a02ff68d 100644
676     --- a/drivers/crypto/caam/jr.c
677     +++ b/drivers/crypto/caam/jr.c
678     @@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg)
679     struct device *caam_jr_alloc(void)
680     {
681     struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL;
682     - struct device *dev = NULL;
683     + struct device *dev = ERR_PTR(-ENODEV);
684     int min_tfm_cnt = INT_MAX;
685     int tfm_cnt;
686    
687     diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
688     index a19ee127edca..e72fea737a0d 100644
689     --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
690     +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
691     @@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
692     unsigned int todo;
693     struct sg_mapping_iter mi, mo;
694     unsigned int oi, oo; /* offset for in and out */
695     + unsigned long flags;
696    
697     if (areq->nbytes == 0)
698     return 0;
699     @@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
700     return -EINVAL;
701     }
702    
703     - spin_lock_bh(&ss->slock);
704     + spin_lock_irqsave(&ss->slock, flags);
705    
706     for (i = 0; i < op->keylen; i += 4)
707     writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
708     @@ -117,7 +118,7 @@ release_ss:
709     sg_miter_stop(&mi);
710     sg_miter_stop(&mo);
711     writel(0, ss->base + SS_CTL);
712     - spin_unlock_bh(&ss->slock);
713     + spin_unlock_irqrestore(&ss->slock, flags);
714     return err;
715     }
716    
717     @@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
718     unsigned int ob = 0; /* offset in buf */
719     unsigned int obo = 0; /* offset in bufo*/
720     unsigned int obl = 0; /* length of data in bufo */
721     + unsigned long flags;
722    
723     if (areq->nbytes == 0)
724     return 0;
725     @@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
726     if (no_chunk == 1)
727     return sun4i_ss_opti_poll(areq);
728    
729     - spin_lock_bh(&ss->slock);
730     + spin_lock_irqsave(&ss->slock, flags);
731    
732     for (i = 0; i < op->keylen; i += 4)
733     writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
734     @@ -308,7 +310,7 @@ release_ss:
735     sg_miter_stop(&mi);
736     sg_miter_stop(&mo);
737     writel(0, ss->base + SS_CTL);
738     - spin_unlock_bh(&ss->slock);
739     + spin_unlock_irqrestore(&ss->slock, flags);
740    
741     return err;
742     }
743     diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
744     index a04fea4d0063..9a8a18aafd5c 100644
745     --- a/drivers/crypto/talitos.c
746     +++ b/drivers/crypto/talitos.c
747     @@ -835,6 +835,16 @@ struct talitos_ahash_req_ctx {
748     struct scatterlist *psrc;
749     };
750    
751     +struct talitos_export_state {
752     + u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
753     + u8 buf[HASH_MAX_BLOCK_SIZE];
754     + unsigned int swinit;
755     + unsigned int first;
756     + unsigned int last;
757     + unsigned int to_hash_later;
758     + unsigned int nbuf;
759     +};
760     +
761     static int aead_setkey(struct crypto_aead *authenc,
762     const u8 *key, unsigned int keylen)
763     {
764     @@ -1954,6 +1964,46 @@ static int ahash_digest(struct ahash_request *areq)
765     return ahash_process_req(areq, areq->nbytes);
766     }
767    
768     +static int ahash_export(struct ahash_request *areq, void *out)
769     +{
770     + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
771     + struct talitos_export_state *export = out;
772     +
773     + memcpy(export->hw_context, req_ctx->hw_context,
774     + req_ctx->hw_context_size);
775     + memcpy(export->buf, req_ctx->buf, req_ctx->nbuf);
776     + export->swinit = req_ctx->swinit;
777     + export->first = req_ctx->first;
778     + export->last = req_ctx->last;
779     + export->to_hash_later = req_ctx->to_hash_later;
780     + export->nbuf = req_ctx->nbuf;
781     +
782     + return 0;
783     +}
784     +
785     +static int ahash_import(struct ahash_request *areq, const void *in)
786     +{
787     + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
788     + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
789     + const struct talitos_export_state *export = in;
790     +
791     + memset(req_ctx, 0, sizeof(*req_ctx));
792     + req_ctx->hw_context_size =
793     + (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE)
794     + ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256
795     + : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512;
796     + memcpy(req_ctx->hw_context, export->hw_context,
797     + req_ctx->hw_context_size);
798     + memcpy(req_ctx->buf, export->buf, export->nbuf);
799     + req_ctx->swinit = export->swinit;
800     + req_ctx->first = export->first;
801     + req_ctx->last = export->last;
802     + req_ctx->to_hash_later = export->to_hash_later;
803     + req_ctx->nbuf = export->nbuf;
804     +
805     + return 0;
806     +}
807     +
808     struct keyhash_result {
809     struct completion completion;
810     int err;
811     @@ -2348,6 +2398,7 @@ static struct talitos_alg_template driver_algs[] = {
812     { .type = CRYPTO_ALG_TYPE_AHASH,
813     .alg.hash = {
814     .halg.digestsize = MD5_DIGEST_SIZE,
815     + .halg.statesize = sizeof(struct talitos_export_state),
816     .halg.base = {
817     .cra_name = "md5",
818     .cra_driver_name = "md5-talitos",
819     @@ -2363,6 +2414,7 @@ static struct talitos_alg_template driver_algs[] = {
820     { .type = CRYPTO_ALG_TYPE_AHASH,
821     .alg.hash = {
822     .halg.digestsize = SHA1_DIGEST_SIZE,
823     + .halg.statesize = sizeof(struct talitos_export_state),
824     .halg.base = {
825     .cra_name = "sha1",
826     .cra_driver_name = "sha1-talitos",
827     @@ -2378,6 +2430,7 @@ static struct talitos_alg_template driver_algs[] = {
828     { .type = CRYPTO_ALG_TYPE_AHASH,
829     .alg.hash = {
830     .halg.digestsize = SHA224_DIGEST_SIZE,
831     + .halg.statesize = sizeof(struct talitos_export_state),
832     .halg.base = {
833     .cra_name = "sha224",
834     .cra_driver_name = "sha224-talitos",
835     @@ -2393,6 +2446,7 @@ static struct talitos_alg_template driver_algs[] = {
836     { .type = CRYPTO_ALG_TYPE_AHASH,
837     .alg.hash = {
838     .halg.digestsize = SHA256_DIGEST_SIZE,
839     + .halg.statesize = sizeof(struct talitos_export_state),
840     .halg.base = {
841     .cra_name = "sha256",
842     .cra_driver_name = "sha256-talitos",
843     @@ -2408,6 +2462,7 @@ static struct talitos_alg_template driver_algs[] = {
844     { .type = CRYPTO_ALG_TYPE_AHASH,
845     .alg.hash = {
846     .halg.digestsize = SHA384_DIGEST_SIZE,
847     + .halg.statesize = sizeof(struct talitos_export_state),
848     .halg.base = {
849     .cra_name = "sha384",
850     .cra_driver_name = "sha384-talitos",
851     @@ -2423,6 +2478,7 @@ static struct talitos_alg_template driver_algs[] = {
852     { .type = CRYPTO_ALG_TYPE_AHASH,
853     .alg.hash = {
854     .halg.digestsize = SHA512_DIGEST_SIZE,
855     + .halg.statesize = sizeof(struct talitos_export_state),
856     .halg.base = {
857     .cra_name = "sha512",
858     .cra_driver_name = "sha512-talitos",
859     @@ -2438,6 +2494,7 @@ static struct talitos_alg_template driver_algs[] = {
860     { .type = CRYPTO_ALG_TYPE_AHASH,
861     .alg.hash = {
862     .halg.digestsize = MD5_DIGEST_SIZE,
863     + .halg.statesize = sizeof(struct talitos_export_state),
864     .halg.base = {
865     .cra_name = "hmac(md5)",
866     .cra_driver_name = "hmac-md5-talitos",
867     @@ -2453,6 +2510,7 @@ static struct talitos_alg_template driver_algs[] = {
868     { .type = CRYPTO_ALG_TYPE_AHASH,
869     .alg.hash = {
870     .halg.digestsize = SHA1_DIGEST_SIZE,
871     + .halg.statesize = sizeof(struct talitos_export_state),
872     .halg.base = {
873     .cra_name = "hmac(sha1)",
874     .cra_driver_name = "hmac-sha1-talitos",
875     @@ -2468,6 +2526,7 @@ static struct talitos_alg_template driver_algs[] = {
876     { .type = CRYPTO_ALG_TYPE_AHASH,
877     .alg.hash = {
878     .halg.digestsize = SHA224_DIGEST_SIZE,
879     + .halg.statesize = sizeof(struct talitos_export_state),
880     .halg.base = {
881     .cra_name = "hmac(sha224)",
882     .cra_driver_name = "hmac-sha224-talitos",
883     @@ -2483,6 +2542,7 @@ static struct talitos_alg_template driver_algs[] = {
884     { .type = CRYPTO_ALG_TYPE_AHASH,
885     .alg.hash = {
886     .halg.digestsize = SHA256_DIGEST_SIZE,
887     + .halg.statesize = sizeof(struct talitos_export_state),
888     .halg.base = {
889     .cra_name = "hmac(sha256)",
890     .cra_driver_name = "hmac-sha256-talitos",
891     @@ -2498,6 +2558,7 @@ static struct talitos_alg_template driver_algs[] = {
892     { .type = CRYPTO_ALG_TYPE_AHASH,
893     .alg.hash = {
894     .halg.digestsize = SHA384_DIGEST_SIZE,
895     + .halg.statesize = sizeof(struct talitos_export_state),
896     .halg.base = {
897     .cra_name = "hmac(sha384)",
898     .cra_driver_name = "hmac-sha384-talitos",
899     @@ -2513,6 +2574,7 @@ static struct talitos_alg_template driver_algs[] = {
900     { .type = CRYPTO_ALG_TYPE_AHASH,
901     .alg.hash = {
902     .halg.digestsize = SHA512_DIGEST_SIZE,
903     + .halg.statesize = sizeof(struct talitos_export_state),
904     .halg.base = {
905     .cra_name = "hmac(sha512)",
906     .cra_driver_name = "hmac-sha512-talitos",
907     @@ -2704,6 +2766,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
908     t_alg->algt.alg.hash.finup = ahash_finup;
909     t_alg->algt.alg.hash.digest = ahash_digest;
910     t_alg->algt.alg.hash.setkey = ahash_setkey;
911     + t_alg->algt.alg.hash.import = ahash_import;
912     + t_alg->algt.alg.hash.export = ahash_export;
913    
914     if (!(priv->features & TALITOS_FTR_HMAC_OK) &&
915     !strncmp(alg->cra_name, "hmac", 4)) {
916     diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
917     index 3db9a659719b..5f0f4fc58f43 100644
918     --- a/drivers/infiniband/ulp/srp/ib_srp.c
919     +++ b/drivers/infiniband/ulp/srp/ib_srp.c
920     @@ -1519,7 +1519,7 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
921    
922     if (dev->use_fast_reg) {
923     state.sg = idb_sg;
924     - sg_set_buf(idb_sg, req->indirect_desc, idb_len);
925     + sg_init_one(idb_sg, req->indirect_desc, idb_len);
926     idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
927     #ifdef CONFIG_NEED_SG_DMA_LENGTH
928     idb_sg->dma_length = idb_sg->length; /* hack^2 */
929     diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
930     index f2261ab54701..18663d4edae5 100644
931     --- a/drivers/input/misc/pwm-beeper.c
932     +++ b/drivers/input/misc/pwm-beeper.c
933     @@ -20,21 +20,40 @@
934     #include <linux/platform_device.h>
935     #include <linux/pwm.h>
936     #include <linux/slab.h>
937     +#include <linux/workqueue.h>
938    
939     struct pwm_beeper {
940     struct input_dev *input;
941     struct pwm_device *pwm;
942     + struct work_struct work;
943     unsigned long period;
944     };
945    
946     #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x))
947    
948     +static void __pwm_beeper_set(struct pwm_beeper *beeper)
949     +{
950     + unsigned long period = beeper->period;
951     +
952     + if (period) {
953     + pwm_config(beeper->pwm, period / 2, period);
954     + pwm_enable(beeper->pwm);
955     + } else
956     + pwm_disable(beeper->pwm);
957     +}
958     +
959     +static void pwm_beeper_work(struct work_struct *work)
960     +{
961     + struct pwm_beeper *beeper =
962     + container_of(work, struct pwm_beeper, work);
963     +
964     + __pwm_beeper_set(beeper);
965     +}
966     +
967     static int pwm_beeper_event(struct input_dev *input,
968     unsigned int type, unsigned int code, int value)
969     {
970     - int ret = 0;
971     struct pwm_beeper *beeper = input_get_drvdata(input);
972     - unsigned long period;
973    
974     if (type != EV_SND || value < 0)
975     return -EINVAL;
976     @@ -49,22 +68,31 @@ static int pwm_beeper_event(struct input_dev *input,
977     return -EINVAL;
978     }
979    
980     - if (value == 0) {
981     - pwm_disable(beeper->pwm);
982     - } else {
983     - period = HZ_TO_NANOSECONDS(value);
984     - ret = pwm_config(beeper->pwm, period / 2, period);
985     - if (ret)
986     - return ret;
987     - ret = pwm_enable(beeper->pwm);
988     - if (ret)
989     - return ret;
990     - beeper->period = period;
991     - }
992     + if (value == 0)
993     + beeper->period = 0;
994     + else
995     + beeper->period = HZ_TO_NANOSECONDS(value);
996     +
997     + schedule_work(&beeper->work);
998    
999     return 0;
1000     }
1001    
1002     +static void pwm_beeper_stop(struct pwm_beeper *beeper)
1003     +{
1004     + cancel_work_sync(&beeper->work);
1005     +
1006     + if (beeper->period)
1007     + pwm_disable(beeper->pwm);
1008     +}
1009     +
1010     +static void pwm_beeper_close(struct input_dev *input)
1011     +{
1012     + struct pwm_beeper *beeper = input_get_drvdata(input);
1013     +
1014     + pwm_beeper_stop(beeper);
1015     +}
1016     +
1017     static int pwm_beeper_probe(struct platform_device *pdev)
1018     {
1019     unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev);
1020     @@ -87,6 +115,8 @@ static int pwm_beeper_probe(struct platform_device *pdev)
1021     goto err_free;
1022     }
1023    
1024     + INIT_WORK(&beeper->work, pwm_beeper_work);
1025     +
1026     beeper->input = input_allocate_device();
1027     if (!beeper->input) {
1028     dev_err(&pdev->dev, "Failed to allocate input device\n");
1029     @@ -106,6 +136,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
1030     beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL);
1031    
1032     beeper->input->event = pwm_beeper_event;
1033     + beeper->input->close = pwm_beeper_close;
1034    
1035     input_set_drvdata(beeper->input, beeper);
1036    
1037     @@ -135,7 +166,6 @@ static int pwm_beeper_remove(struct platform_device *pdev)
1038    
1039     input_unregister_device(beeper->input);
1040    
1041     - pwm_disable(beeper->pwm);
1042     pwm_free(beeper->pwm);
1043    
1044     kfree(beeper);
1045     @@ -147,8 +177,7 @@ static int __maybe_unused pwm_beeper_suspend(struct device *dev)
1046     {
1047     struct pwm_beeper *beeper = dev_get_drvdata(dev);
1048    
1049     - if (beeper->period)
1050     - pwm_disable(beeper->pwm);
1051     + pwm_beeper_stop(beeper);
1052    
1053     return 0;
1054     }
1055     @@ -157,10 +186,8 @@ static int __maybe_unused pwm_beeper_resume(struct device *dev)
1056     {
1057     struct pwm_beeper *beeper = dev_get_drvdata(dev);
1058    
1059     - if (beeper->period) {
1060     - pwm_config(beeper->pwm, beeper->period / 2, beeper->period);
1061     - pwm_enable(beeper->pwm);
1062     - }
1063     + if (beeper->period)
1064     + __pwm_beeper_set(beeper);
1065    
1066     return 0;
1067     }
1068     diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
1069     index d7be6ddc34f6..2fc499a2207e 100644
1070     --- a/drivers/irqchip/irq-gic-v3.c
1071     +++ b/drivers/irqchip/irq-gic-v3.c
1072     @@ -361,6 +361,13 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
1073     if (static_key_true(&supports_deactivate))
1074     gic_write_dir(irqnr);
1075     #ifdef CONFIG_SMP
1076     + /*
1077     + * Unlike GICv2, we don't need an smp_rmb() here.
1078     + * The control dependency from gic_read_iar to
1079     + * the ISB in gic_write_eoir is enough to ensure
1080     + * that any shared data read by handle_IPI will
1081     + * be read after the ACK.
1082     + */
1083     handle_IPI(irqnr, regs);
1084     #else
1085     WARN_ONCE(true, "Unexpected SGI received!\n");
1086     @@ -380,6 +387,15 @@ static void __init gic_dist_init(void)
1087     writel_relaxed(0, base + GICD_CTLR);
1088     gic_dist_wait_for_rwp();
1089    
1090     + /*
1091     + * Configure SPIs as non-secure Group-1. This will only matter
1092     + * if the GIC only has a single security state. This will not
1093     + * do the right thing if the kernel is running in secure mode,
1094     + * but that's not the intended use case anyway.
1095     + */
1096     + for (i = 32; i < gic_data.irq_nr; i += 32)
1097     + writel_relaxed(~0, base + GICD_IGROUPR + i / 8);
1098     +
1099     gic_dist_config(base, gic_data.irq_nr, gic_dist_wait_for_rwp);
1100    
1101     /* Enable distributor with ARE, Group1 */
1102     @@ -494,6 +510,9 @@ static void gic_cpu_init(void)
1103    
1104     rbase = gic_data_rdist_sgi_base();
1105    
1106     + /* Configure SGIs/PPIs as non-secure Group-1 */
1107     + writel_relaxed(~0, rbase + GICR_IGROUPR0);
1108     +
1109     gic_cpu_config(rbase, gic_redist_wait_for_rwp);
1110    
1111     /* Give LPIs a spin */
1112     diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
1113     index abf2ffaed392..cebd8efe651a 100644
1114     --- a/drivers/irqchip/irq-gic.c
1115     +++ b/drivers/irqchip/irq-gic.c
1116     @@ -347,6 +347,14 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
1117     if (static_key_true(&supports_deactivate))
1118     writel_relaxed(irqstat, cpu_base + GIC_CPU_DEACTIVATE);
1119     #ifdef CONFIG_SMP
1120     + /*
1121     + * Ensure any shared data written by the CPU sending
1122     + * the IPI is read after we've read the ACK register
1123     + * on the GIC.
1124     + *
1125     + * Pairs with the write barrier in gic_raise_softirq
1126     + */
1127     + smp_rmb();
1128     handle_IPI(irqnr, regs);
1129     #endif
1130     continue;
1131     diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
1132     index 004926955263..b0155b05cddb 100644
1133     --- a/drivers/mcb/mcb-parse.c
1134     +++ b/drivers/mcb/mcb-parse.c
1135     @@ -57,7 +57,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
1136     mdev->id = GDD_DEV(reg1);
1137     mdev->rev = GDD_REV(reg1);
1138     mdev->var = GDD_VAR(reg1);
1139     - mdev->bar = GDD_BAR(reg1);
1140     + mdev->bar = GDD_BAR(reg2);
1141     mdev->group = GDD_GRP(reg2);
1142     mdev->inst = GDD_INS(reg2);
1143    
1144     diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
1145     index b7b3e8ee64f2..c30290f33430 100644
1146     --- a/drivers/mfd/omap-usb-tll.c
1147     +++ b/drivers/mfd/omap-usb-tll.c
1148     @@ -269,6 +269,8 @@ static int usbtll_omap_probe(struct platform_device *pdev)
1149    
1150     if (IS_ERR(tll->ch_clk[i]))
1151     dev_dbg(dev, "can't get clock : %s\n", clkname);
1152     + else
1153     + clk_prepare(tll->ch_clk[i]);
1154     }
1155    
1156     pm_runtime_put_sync(dev);
1157     @@ -301,9 +303,12 @@ static int usbtll_omap_remove(struct platform_device *pdev)
1158     tll_dev = NULL;
1159     spin_unlock(&tll_lock);
1160    
1161     - for (i = 0; i < tll->nch; i++)
1162     - if (!IS_ERR(tll->ch_clk[i]))
1163     + for (i = 0; i < tll->nch; i++) {
1164     + if (!IS_ERR(tll->ch_clk[i])) {
1165     + clk_unprepare(tll->ch_clk[i]);
1166     clk_put(tll->ch_clk[i]);
1167     + }
1168     + }
1169    
1170     pm_runtime_disable(&pdev->dev);
1171     return 0;
1172     @@ -420,7 +425,7 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
1173     if (IS_ERR(tll->ch_clk[i]))
1174     continue;
1175    
1176     - r = clk_prepare_enable(tll->ch_clk[i]);
1177     + r = clk_enable(tll->ch_clk[i]);
1178     if (r) {
1179     dev_err(tll_dev,
1180     "Error enabling ch %d clock: %d\n", i, r);
1181     @@ -448,7 +453,7 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata)
1182     for (i = 0; i < tll->nch; i++) {
1183     if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
1184     if (!IS_ERR(tll->ch_clk[i]))
1185     - clk_disable_unprepare(tll->ch_clk[i]);
1186     + clk_disable(tll->ch_clk[i]);
1187     }
1188     }
1189    
1190     diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
1191     index cd0403f09267..e79c0371ee6f 100644
1192     --- a/drivers/misc/mei/amthif.c
1193     +++ b/drivers/misc/mei/amthif.c
1194     @@ -417,8 +417,10 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
1195    
1196     dev = cl->dev;
1197    
1198     - if (dev->iamthif_state != MEI_IAMTHIF_READING)
1199     + if (dev->iamthif_state != MEI_IAMTHIF_READING) {
1200     + mei_irq_discard_msg(dev, mei_hdr);
1201     return 0;
1202     + }
1203    
1204     ret = mei_cl_irq_read_msg(cl, mei_hdr, cmpl_list);
1205     if (ret)
1206     diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
1207     index 1a173d0af694..a77643954523 100644
1208     --- a/drivers/misc/mei/bus.c
1209     +++ b/drivers/misc/mei/bus.c
1210     @@ -222,17 +222,23 @@ EXPORT_SYMBOL_GPL(mei_cldev_recv);
1211     static void mei_cl_bus_event_work(struct work_struct *work)
1212     {
1213     struct mei_cl_device *cldev;
1214     + struct mei_device *bus;
1215    
1216     cldev = container_of(work, struct mei_cl_device, event_work);
1217    
1218     + bus = cldev->bus;
1219     +
1220     if (cldev->event_cb)
1221     cldev->event_cb(cldev, cldev->events, cldev->event_context);
1222    
1223     cldev->events = 0;
1224    
1225     /* Prepare for the next read */
1226     - if (cldev->events_mask & BIT(MEI_CL_EVENT_RX))
1227     + if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
1228     + mutex_lock(&bus->device_lock);
1229     mei_cl_read_start(cldev->cl, 0, NULL);
1230     + mutex_unlock(&bus->device_lock);
1231     + }
1232     }
1233    
1234     /**
1235     @@ -296,6 +302,7 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
1236     unsigned long events_mask,
1237     mei_cldev_event_cb_t event_cb, void *context)
1238     {
1239     + struct mei_device *bus = cldev->bus;
1240     int ret;
1241    
1242     if (cldev->event_cb)
1243     @@ -308,15 +315,17 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
1244     INIT_WORK(&cldev->event_work, mei_cl_bus_event_work);
1245    
1246     if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
1247     + mutex_lock(&bus->device_lock);
1248     ret = mei_cl_read_start(cldev->cl, 0, NULL);
1249     + mutex_unlock(&bus->device_lock);
1250     if (ret && ret != -EBUSY)
1251     return ret;
1252     }
1253    
1254     if (cldev->events_mask & BIT(MEI_CL_EVENT_NOTIF)) {
1255     - mutex_lock(&cldev->cl->dev->device_lock);
1256     + mutex_lock(&bus->device_lock);
1257     ret = mei_cl_notify_request(cldev->cl, NULL, event_cb ? 1 : 0);
1258     - mutex_unlock(&cldev->cl->dev->device_lock);
1259     + mutex_unlock(&bus->device_lock);
1260     if (ret)
1261     return ret;
1262     }
1263     diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
1264     index a6c87c713193..958af84884b5 100644
1265     --- a/drivers/misc/mei/client.c
1266     +++ b/drivers/misc/mei/client.c
1267     @@ -1735,6 +1735,10 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
1268     wake_up(&cl->wait);
1269    
1270     break;
1271     + case MEI_FOP_DISCONNECT_RSP:
1272     + mei_io_cb_free(cb);
1273     + mei_cl_set_disconnected(cl);
1274     + break;
1275     default:
1276     BUG_ON(0);
1277     }
1278     diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
1279     index e7b7aad0999b..fd8a9f057ea6 100644
1280     --- a/drivers/misc/mei/hbm.c
1281     +++ b/drivers/misc/mei/hbm.c
1282     @@ -873,8 +873,7 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
1283     cb = mei_io_cb_init(cl, MEI_FOP_DISCONNECT_RSP, NULL);
1284     if (!cb)
1285     return -ENOMEM;
1286     - cl_dbg(dev, cl, "add disconnect response as first\n");
1287     - list_add(&cb->list, &dev->ctrl_wr_list.list);
1288     + list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
1289     }
1290     return 0;
1291     }
1292     diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
1293     index 64b568a0268d..d1df797c7568 100644
1294     --- a/drivers/misc/mei/interrupt.c
1295     +++ b/drivers/misc/mei/interrupt.c
1296     @@ -76,7 +76,6 @@ static inline int mei_cl_hbm_equal(struct mei_cl *cl,
1297     * @dev: mei device
1298     * @hdr: message header
1299     */
1300     -static inline
1301     void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr)
1302     {
1303     /*
1304     @@ -184,10 +183,7 @@ static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
1305     return -EMSGSIZE;
1306    
1307     ret = mei_hbm_cl_disconnect_rsp(dev, cl);
1308     - mei_cl_set_disconnected(cl);
1309     - mei_io_cb_free(cb);
1310     - mei_me_cl_put(cl->me_cl);
1311     - cl->me_cl = NULL;
1312     + list_move_tail(&cb->list, &cmpl_list->list);
1313    
1314     return ret;
1315     }
1316     diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
1317     index 4250555d5e72..1b06e2fd6858 100644
1318     --- a/drivers/misc/mei/mei_dev.h
1319     +++ b/drivers/misc/mei/mei_dev.h
1320     @@ -782,6 +782,8 @@ bool mei_hbuf_acquire(struct mei_device *dev);
1321    
1322     bool mei_write_is_idle(struct mei_device *dev);
1323    
1324     +void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr);
1325     +
1326     #if IS_ENABLED(CONFIG_DEBUG_FS)
1327     int mei_dbgfs_register(struct mei_device *dev, const char *name);
1328     void mei_dbgfs_deregister(struct mei_device *dev);
1329     diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
1330     index 553113eb1bdb..c641c202fe7e 100644
1331     --- a/drivers/mmc/card/block.c
1332     +++ b/drivers/mmc/card/block.c
1333     @@ -2514,11 +2514,12 @@ static const struct mmc_fixup blk_fixups[] =
1334     MMC_QUIRK_BLK_NO_CMD23),
1335    
1336     /*
1337     - * Some Micron MMC cards needs longer data read timeout than
1338     - * indicated in CSD.
1339     + * Some MMC cards need longer data read timeout than indicated in CSD.
1340     */
1341     MMC_FIXUP(CID_NAME_ANY, CID_MANFID_MICRON, 0x200, add_quirk_mmc,
1342     MMC_QUIRK_LONG_READ_TIME),
1343     + MMC_FIXUP("008GE0", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
1344     + MMC_QUIRK_LONG_READ_TIME),
1345    
1346     /*
1347     * On these Samsung MoviNAND parts, performing secure erase or
1348     diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1349     index 5ae89e48fd85..5f7d10ba498a 100644
1350     --- a/drivers/mmc/core/core.c
1351     +++ b/drivers/mmc/core/core.c
1352     @@ -874,11 +874,11 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
1353     /*
1354     * Some cards require longer data read timeout than indicated in CSD.
1355     * Address this by setting the read timeout to a "reasonably high"
1356     - * value. For the cards tested, 300ms has proven enough. If necessary,
1357     + * value. For the cards tested, 600ms has proven enough. If necessary,
1358     * this value can be increased if other problematic cards require this.
1359     */
1360     if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
1361     - data->timeout_ns = 300000000;
1362     + data->timeout_ns = 600000000;
1363     data->timeout_clks = 0;
1364     }
1365    
1366     diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1367     index 3d5087b03999..78187699467a 100644
1368     --- a/drivers/mmc/core/mmc.c
1369     +++ b/drivers/mmc/core/mmc.c
1370     @@ -333,6 +333,9 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
1371     }
1372     }
1373    
1374     +/* Minimum partition switch timeout in milliseconds */
1375     +#define MMC_MIN_PART_SWITCH_TIME 300
1376     +
1377     /*
1378     * Decode extended CSD.
1379     */
1380     @@ -397,6 +400,10 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
1381    
1382     /* EXT_CSD value is in units of 10ms, but we store in ms */
1383     card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
1384     + /* Some eMMC set the value too low so set a minimum */
1385     + if (card->ext_csd.part_time &&
1386     + card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
1387     + card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
1388    
1389     /* Sleep / awake timeout in 100ns units */
1390     if (sa_shift > 0 && sa_shift <= 0x17)
1391     diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
1392     index a5cda926d38e..8aea3fa6938b 100644
1393     --- a/drivers/mmc/host/sdhci-acpi.c
1394     +++ b/drivers/mmc/host/sdhci-acpi.c
1395     @@ -233,7 +233,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
1396     .chip = &sdhci_acpi_chip_int,
1397     .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
1398     MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
1399     - MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1400     + MMC_CAP_WAIT_WHILE_BUSY,
1401     .caps2 = MMC_CAP2_HC_ERASE_SZ,
1402     .flags = SDHCI_ACPI_RUNTIME_PM,
1403     .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1404     @@ -248,7 +248,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
1405     SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1406     .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
1407     .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD |
1408     - MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1409     + MMC_CAP_WAIT_WHILE_BUSY,
1410     .flags = SDHCI_ACPI_RUNTIME_PM,
1411     .pm_caps = MMC_PM_KEEP_POWER,
1412     .probe_slot = sdhci_acpi_sdio_probe_slot,
1413     @@ -260,7 +260,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
1414     .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1415     .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
1416     SDHCI_QUIRK2_STOP_WITH_TC,
1417     - .caps = MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1418     + .caps = MMC_CAP_WAIT_WHILE_BUSY,
1419     .probe_slot = sdhci_acpi_sd_probe_slot,
1420     };
1421    
1422     diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
1423     index 610154836d79..5ebe6eb6b89e 100644
1424     --- a/drivers/mmc/host/sdhci-pci-core.c
1425     +++ b/drivers/mmc/host/sdhci-pci-core.c
1426     @@ -361,7 +361,6 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
1427     {
1428     slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
1429     MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
1430     - MMC_CAP_BUS_WIDTH_TEST |
1431     MMC_CAP_WAIT_WHILE_BUSY;
1432     slot->host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ;
1433     slot->hw_reset = sdhci_pci_int_hw_reset;
1434     @@ -377,15 +376,13 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
1435     static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
1436     {
1437     slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE |
1438     - MMC_CAP_BUS_WIDTH_TEST |
1439     MMC_CAP_WAIT_WHILE_BUSY;
1440     return 0;
1441     }
1442    
1443     static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
1444     {
1445     - slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST |
1446     - MMC_CAP_WAIT_WHILE_BUSY;
1447     + slot->host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
1448     slot->cd_con_id = NULL;
1449     slot->cd_idx = 0;
1450     slot->cd_override_level = true;
1451     diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
1452     index 5b9834cf2820..96fddb016bf1 100644
1453     --- a/drivers/mtd/ubi/eba.c
1454     +++ b/drivers/mtd/ubi/eba.c
1455     @@ -426,8 +426,25 @@ retry:
1456     pnum, vol_id, lnum);
1457     err = -EBADMSG;
1458     } else {
1459     - err = -EINVAL;
1460     - ubi_ro_mode(ubi);
1461     + /*
1462     + * Ending up here in the non-Fastmap case
1463     + * is a clear bug as the VID header had to
1464     + * be present at scan time to have it referenced.
1465     + * With fastmap the story is more complicated.
1466     + * Fastmap has the mapping info without the need
1467     + * of a full scan. So the LEB could have been
1468     + * unmapped, Fastmap cannot know this and keeps
1469     + * the LEB referenced.
1470     + * This is valid and works as the layer above UBI
1471     + * has to do bookkeeping about used/referenced
1472     + * LEBs in any case.
1473     + */
1474     + if (ubi->fast_attach) {
1475     + err = -EBADMSG;
1476     + } else {
1477     + err = -EINVAL;
1478     + ubi_ro_mode(ubi);
1479     + }
1480     }
1481     }
1482     goto out_free;
1483     diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
1484     index 263b439e21a8..990898b9dc72 100644
1485     --- a/drivers/mtd/ubi/fastmap.c
1486     +++ b/drivers/mtd/ubi/fastmap.c
1487     @@ -1058,6 +1058,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
1488     ubi_msg(ubi, "fastmap WL pool size: %d",
1489     ubi->fm_wl_pool.max_size);
1490     ubi->fm_disabled = 0;
1491     + ubi->fast_attach = 1;
1492    
1493     ubi_free_vid_hdr(ubi, vh);
1494     kfree(ech);
1495     diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
1496     index 2974b67f6c6c..de1ea2e4c37d 100644
1497     --- a/drivers/mtd/ubi/ubi.h
1498     +++ b/drivers/mtd/ubi/ubi.h
1499     @@ -462,6 +462,7 @@ struct ubi_debug_info {
1500     * @fm_eba_sem: allows ubi_update_fastmap() to block EBA table changes
1501     * @fm_work: fastmap work queue
1502     * @fm_work_scheduled: non-zero if fastmap work was scheduled
1503     + * @fast_attach: non-zero if UBI was attached by fastmap
1504     *
1505     * @used: RB-tree of used physical eraseblocks
1506     * @erroneous: RB-tree of erroneous used physical eraseblocks
1507     @@ -570,6 +571,7 @@ struct ubi_device {
1508     size_t fm_size;
1509     struct work_struct fm_work;
1510     int fm_work_scheduled;
1511     + int fast_attach;
1512    
1513     /* Wear-leveling sub-system's stuff */
1514     struct rb_root used;
1515     diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
1516     index 141c2a42d7ed..910c12e2638e 100644
1517     --- a/drivers/net/can/dev.c
1518     +++ b/drivers/net/can/dev.c
1519     @@ -696,11 +696,17 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
1520     /* allow change of MTU according to the CANFD ability of the device */
1521     switch (new_mtu) {
1522     case CAN_MTU:
1523     + /* 'CANFD-only' controllers can not switch to CAN_MTU */
1524     + if (priv->ctrlmode_static & CAN_CTRLMODE_FD)
1525     + return -EINVAL;
1526     +
1527     priv->ctrlmode &= ~CAN_CTRLMODE_FD;
1528     break;
1529    
1530     case CANFD_MTU:
1531     - if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD))
1532     + /* check for potential CANFD ability */
1533     + if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) &&
1534     + !(priv->ctrlmode_static & CAN_CTRLMODE_FD))
1535     return -EINVAL;
1536    
1537     priv->ctrlmode |= CAN_CTRLMODE_FD;
1538     @@ -782,6 +788,35 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
1539     = { .len = sizeof(struct can_bittiming_const) },
1540     };
1541    
1542     +static int can_validate(struct nlattr *tb[], struct nlattr *data[])
1543     +{
1544     + bool is_can_fd = false;
1545     +
1546     + /* Make sure that valid CAN FD configurations always consist of
1547     + * - nominal/arbitration bittiming
1548     + * - data bittiming
1549     + * - control mode with CAN_CTRLMODE_FD set
1550     + */
1551     +
1552     + if (data[IFLA_CAN_CTRLMODE]) {
1553     + struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]);
1554     +
1555     + is_can_fd = cm->flags & cm->mask & CAN_CTRLMODE_FD;
1556     + }
1557     +
1558     + if (is_can_fd) {
1559     + if (!data[IFLA_CAN_BITTIMING] || !data[IFLA_CAN_DATA_BITTIMING])
1560     + return -EOPNOTSUPP;
1561     + }
1562     +
1563     + if (data[IFLA_CAN_DATA_BITTIMING]) {
1564     + if (!is_can_fd || !data[IFLA_CAN_BITTIMING])
1565     + return -EOPNOTSUPP;
1566     + }
1567     +
1568     + return 0;
1569     +}
1570     +
1571     static int can_changelink(struct net_device *dev,
1572     struct nlattr *tb[], struct nlattr *data[])
1573     {
1574     @@ -813,19 +848,31 @@ static int can_changelink(struct net_device *dev,
1575    
1576     if (data[IFLA_CAN_CTRLMODE]) {
1577     struct can_ctrlmode *cm;
1578     + u32 ctrlstatic;
1579     + u32 maskedflags;
1580    
1581     /* Do not allow changing controller mode while running */
1582     if (dev->flags & IFF_UP)
1583     return -EBUSY;
1584     cm = nla_data(data[IFLA_CAN_CTRLMODE]);
1585     + ctrlstatic = priv->ctrlmode_static;
1586     + maskedflags = cm->flags & cm->mask;
1587     +
1588     + /* check whether provided bits are allowed to be passed */
1589     + if (cm->mask & ~(priv->ctrlmode_supported | ctrlstatic))
1590     + return -EOPNOTSUPP;
1591     +
1592     + /* do not check for static fd-non-iso if 'fd' is disabled */
1593     + if (!(maskedflags & CAN_CTRLMODE_FD))
1594     + ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
1595    
1596     - /* check whether changed bits are allowed to be modified */
1597     - if (cm->mask & ~priv->ctrlmode_supported)
1598     + /* make sure static options are provided by configuration */
1599     + if ((maskedflags & ctrlstatic) != ctrlstatic)
1600     return -EOPNOTSUPP;
1601    
1602     /* clear bits to be modified and copy the flag values */
1603     priv->ctrlmode &= ~cm->mask;
1604     - priv->ctrlmode |= (cm->flags & cm->mask);
1605     + priv->ctrlmode |= maskedflags;
1606    
1607     /* CAN_CTRLMODE_FD can only be set when driver supports FD */
1608     if (priv->ctrlmode & CAN_CTRLMODE_FD)
1609     @@ -966,6 +1013,7 @@ static struct rtnl_link_ops can_link_ops __read_mostly = {
1610     .maxtype = IFLA_CAN_MAX,
1611     .policy = can_policy,
1612     .setup = can_setup,
1613     + .validate = can_validate,
1614     .newlink = can_newlink,
1615     .changelink = can_changelink,
1616     .get_size = can_get_size,
1617     diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
1618     index 39cf911f7a1e..195f15edb32e 100644
1619     --- a/drivers/net/can/m_can/m_can.c
1620     +++ b/drivers/net/can/m_can/m_can.c
1621     @@ -955,7 +955,7 @@ static struct net_device *alloc_m_can_dev(void)
1622     priv->can.do_get_berr_counter = m_can_get_berr_counter;
1623    
1624     /* CAN_CTRLMODE_FD_NON_ISO is fixed with M_CAN IP v3.0.1 */
1625     - priv->can.ctrlmode = CAN_CTRLMODE_FD_NON_ISO;
1626     + can_set_static_ctrlmode(dev, CAN_CTRLMODE_FD_NON_ISO);
1627    
1628     /* CAN_CTRLMODE_FD_NON_ISO can not be changed with M_CAN IP v3.0.1 */
1629     priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
1630     diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
1631     index bd9acff1eb7b..7fbd8f044207 100644
1632     --- a/drivers/net/usb/asix_common.c
1633     +++ b/drivers/net/usb/asix_common.c
1634     @@ -66,7 +66,7 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
1635     * buffer.
1636     */
1637     if (rx->remaining && (rx->remaining + sizeof(u32) <= skb->len)) {
1638     - offset = ((rx->remaining + 1) & 0xfffe) + sizeof(u32);
1639     + offset = ((rx->remaining + 1) & 0xfffe);
1640     rx->header = get_unaligned_le32(skb->data + offset);
1641     offset = 0;
1642    
1643     diff --git a/drivers/platform/x86/dell-rbtn.c b/drivers/platform/x86/dell-rbtn.c
1644     index cd410e392550..d33e9ad3218f 100644
1645     --- a/drivers/platform/x86/dell-rbtn.c
1646     +++ b/drivers/platform/x86/dell-rbtn.c
1647     @@ -28,6 +28,7 @@ struct rbtn_data {
1648     enum rbtn_type type;
1649     struct rfkill *rfkill;
1650     struct input_dev *input_dev;
1651     + bool suspended;
1652     };
1653    
1654    
1655     @@ -220,9 +221,55 @@ static const struct acpi_device_id rbtn_ids[] = {
1656     { "", 0 },
1657     };
1658    
1659     +#ifdef CONFIG_PM_SLEEP
1660     +static void ACPI_SYSTEM_XFACE rbtn_clear_suspended_flag(void *context)
1661     +{
1662     + struct rbtn_data *rbtn_data = context;
1663     +
1664     + rbtn_data->suspended = false;
1665     +}
1666     +
1667     +static int rbtn_suspend(struct device *dev)
1668     +{
1669     + struct acpi_device *device = to_acpi_device(dev);
1670     + struct rbtn_data *rbtn_data = acpi_driver_data(device);
1671     +
1672     + rbtn_data->suspended = true;
1673     +
1674     + return 0;
1675     +}
1676     +
1677     +static int rbtn_resume(struct device *dev)
1678     +{
1679     + struct acpi_device *device = to_acpi_device(dev);
1680     + struct rbtn_data *rbtn_data = acpi_driver_data(device);
1681     + acpi_status status;
1682     +
1683     + /*
1684     + * Upon resume, some BIOSes send an ACPI notification thet triggers
1685     + * an unwanted input event. In order to ignore it, we use a flag
1686     + * that we set at suspend and clear once we have received the extra
1687     + * ACPI notification. Since ACPI notifications are delivered
1688     + * asynchronously to drivers, we clear the flag from the workqueue
1689     + * used to deliver the notifications. This should be enough
1690     + * to have the flag cleared only after we received the extra
1691     + * notification, if any.
1692     + */
1693     + status = acpi_os_execute(OSL_NOTIFY_HANDLER,
1694     + rbtn_clear_suspended_flag, rbtn_data);
1695     + if (ACPI_FAILURE(status))
1696     + rbtn_clear_suspended_flag(rbtn_data);
1697     +
1698     + return 0;
1699     +}
1700     +#endif
1701     +
1702     +static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume);
1703     +
1704     static struct acpi_driver rbtn_driver = {
1705     .name = "dell-rbtn",
1706     .ids = rbtn_ids,
1707     + .drv.pm = &rbtn_pm_ops,
1708     .ops = {
1709     .add = rbtn_add,
1710     .remove = rbtn_remove,
1711     @@ -384,6 +431,15 @@ static void rbtn_notify(struct acpi_device *device, u32 event)
1712     {
1713     struct rbtn_data *rbtn_data = device->driver_data;
1714    
1715     + /*
1716     + * Some BIOSes send a notification at resume.
1717     + * Ignore it to prevent unwanted input events.
1718     + */
1719     + if (rbtn_data->suspended) {
1720     + dev_dbg(&device->dev, "ACPI notification ignored\n");
1721     + return;
1722     + }
1723     +
1724     if (event != 0x80) {
1725     dev_info(&device->dev, "Received unknown event (0x%x)\n",
1726     event);
1727     diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
1728     index 054923e3393c..f0cfaacbfabd 100644
1729     --- a/drivers/scsi/scsi_scan.c
1730     +++ b/drivers/scsi/scsi_scan.c
1731     @@ -314,6 +314,7 @@ static void scsi_target_destroy(struct scsi_target *starget)
1732     struct Scsi_Host *shost = dev_to_shost(dev->parent);
1733     unsigned long flags;
1734    
1735     + BUG_ON(starget->state == STARGET_DEL);
1736     starget->state = STARGET_DEL;
1737     transport_destroy_device(dev);
1738     spin_lock_irqsave(shost->host_lock, flags);
1739     diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
1740     index c8115b4fe474..f7ae898833dd 100644
1741     --- a/drivers/scsi/scsi_sysfs.c
1742     +++ b/drivers/scsi/scsi_sysfs.c
1743     @@ -1192,18 +1192,18 @@ static void __scsi_remove_target(struct scsi_target *starget)
1744     void scsi_remove_target(struct device *dev)
1745     {
1746     struct Scsi_Host *shost = dev_to_shost(dev->parent);
1747     - struct scsi_target *starget, *last_target = NULL;
1748     + struct scsi_target *starget;
1749     unsigned long flags;
1750    
1751     restart:
1752     spin_lock_irqsave(shost->host_lock, flags);
1753     list_for_each_entry(starget, &shost->__targets, siblings) {
1754     if (starget->state == STARGET_DEL ||
1755     - starget == last_target)
1756     + starget->state == STARGET_REMOVE)
1757     continue;
1758     if (starget->dev.parent == dev || &starget->dev == dev) {
1759     kref_get(&starget->reap_ref);
1760     - last_target = starget;
1761     + starget->state = STARGET_REMOVE;
1762     spin_unlock_irqrestore(shost->host_lock, flags);
1763     __scsi_remove_target(starget);
1764     scsi_target_reap(starget);
1765     diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
1766     index 940781183fac..3be10963f98b 100644
1767     --- a/drivers/staging/comedi/drivers/das1800.c
1768     +++ b/drivers/staging/comedi/drivers/das1800.c
1769     @@ -567,14 +567,17 @@ static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
1770     struct comedi_isadma_desc *desc;
1771     int i;
1772    
1773     - outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
1774     - outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
1775     - outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */
1776     -
1777     - for (i = 0; i < 2; i++) {
1778     - desc = &dma->desc[i];
1779     - if (desc->chan)
1780     - comedi_isadma_disable(desc->chan);
1781     + /* disable and stop conversions */
1782     + outb(0x0, dev->iobase + DAS1800_STATUS);
1783     + outb(0x0, dev->iobase + DAS1800_CONTROL_B);
1784     + outb(0x0, dev->iobase + DAS1800_CONTROL_A);
1785     +
1786     + if (dma) {
1787     + for (i = 0; i < 2; i++) {
1788     + desc = &dma->desc[i];
1789     + if (desc->chan)
1790     + comedi_isadma_disable(desc->chan);
1791     + }
1792     }
1793    
1794     return 0;
1795     @@ -934,13 +937,14 @@ static void das1800_ai_setup_dma(struct comedi_device *dev,
1796     {
1797     struct das1800_private *devpriv = dev->private;
1798     struct comedi_isadma *dma = devpriv->dma;
1799     - struct comedi_isadma_desc *desc = &dma->desc[0];
1800     + struct comedi_isadma_desc *desc;
1801     unsigned int bytes;
1802    
1803     if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0)
1804     return;
1805    
1806     dma->cur_dma = 0;
1807     + desc = &dma->desc[0];
1808    
1809     /* determine a dma transfer size to fill buffer in 0.3 sec */
1810     bytes = das1800_ai_transfer_size(dev, s, desc->maxsize, 300000000);
1811     diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c
1812     index 0dde34e3a7c5..545c60c826a1 100644
1813     --- a/drivers/thunderbolt/eeprom.c
1814     +++ b/drivers/thunderbolt/eeprom.c
1815     @@ -444,6 +444,7 @@ int tb_drom_read(struct tb_switch *sw)
1816     return tb_drom_parse_entries(sw);
1817     err:
1818     kfree(sw->drom);
1819     + sw->drom = NULL;
1820     return -EIO;
1821    
1822     }
1823     diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
1824     index c3fe026d3168..9aff37186246 100644
1825     --- a/drivers/tty/n_gsm.c
1826     +++ b/drivers/tty/n_gsm.c
1827     @@ -2045,7 +2045,9 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
1828     }
1829     }
1830     spin_unlock(&gsm_mux_lock);
1831     - WARN_ON(i == MAX_MUX);
1832     + /* open failed before registering => nothing to do */
1833     + if (i == MAX_MUX)
1834     + return;
1835    
1836     /* In theory disconnecting DLCI 0 is sufficient but for some
1837     modems this is apparently not the case. */
1838     diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
1839     index bbc4ce66c2c1..644ddb841d9f 100644
1840     --- a/drivers/tty/n_hdlc.c
1841     +++ b/drivers/tty/n_hdlc.c
1842     @@ -600,7 +600,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
1843     add_wait_queue(&tty->read_wait, &wait);
1844    
1845     for (;;) {
1846     - if (test_bit(TTY_OTHER_DONE, &tty->flags)) {
1847     + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
1848     ret = -EIO;
1849     break;
1850     }
1851     @@ -828,7 +828,7 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
1852     /* set bits for operations that won't block */
1853     if (n_hdlc->rx_buf_list.head)
1854     mask |= POLLIN | POLLRDNORM; /* readable */
1855     - if (test_bit(TTY_OTHER_DONE, &tty->flags))
1856     + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
1857     mask |= POLLHUP;
1858     if (tty_hung_up_p(filp))
1859     mask |= POLLHUP;
1860     diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
1861     index cf000b331eed..84e71bd19082 100644
1862     --- a/drivers/tty/n_tty.c
1863     +++ b/drivers/tty/n_tty.c
1864     @@ -1955,18 +1955,6 @@ static inline int input_available_p(struct tty_struct *tty, int poll)
1865     return ldata->commit_head - ldata->read_tail >= amt;
1866     }
1867    
1868     -static inline int check_other_done(struct tty_struct *tty)
1869     -{
1870     - int done = test_bit(TTY_OTHER_DONE, &tty->flags);
1871     - if (done) {
1872     - /* paired with cmpxchg() in check_other_closed(); ensures
1873     - * read buffer head index is not stale
1874     - */
1875     - smp_mb__after_atomic();
1876     - }
1877     - return done;
1878     -}
1879     -
1880     /**
1881     * copy_from_read_buf - copy read data directly
1882     * @tty: terminal device
1883     @@ -2171,7 +2159,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
1884     struct n_tty_data *ldata = tty->disc_data;
1885     unsigned char __user *b = buf;
1886     DEFINE_WAIT_FUNC(wait, woken_wake_function);
1887     - int c, done;
1888     + int c;
1889     int minimum, time;
1890     ssize_t retval = 0;
1891     long timeout;
1892     @@ -2239,32 +2227,35 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
1893     ((minimum - (b - buf)) >= 1))
1894     ldata->minimum_to_wake = (minimum - (b - buf));
1895    
1896     - done = check_other_done(tty);
1897     -
1898     if (!input_available_p(tty, 0)) {
1899     - if (done) {
1900     - retval = -EIO;
1901     - break;
1902     - }
1903     - if (tty_hung_up_p(file))
1904     - break;
1905     - if (!timeout)
1906     - break;
1907     - if (file->f_flags & O_NONBLOCK) {
1908     - retval = -EAGAIN;
1909     - break;
1910     - }
1911     - if (signal_pending(current)) {
1912     - retval = -ERESTARTSYS;
1913     - break;
1914     - }
1915     up_read(&tty->termios_rwsem);
1916     + tty_buffer_flush_work(tty->port);
1917     + down_read(&tty->termios_rwsem);
1918     + if (!input_available_p(tty, 0)) {
1919     + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
1920     + retval = -EIO;
1921     + break;
1922     + }
1923     + if (tty_hung_up_p(file))
1924     + break;
1925     + if (!timeout)
1926     + break;
1927     + if (file->f_flags & O_NONBLOCK) {
1928     + retval = -EAGAIN;
1929     + break;
1930     + }
1931     + if (signal_pending(current)) {
1932     + retval = -ERESTARTSYS;
1933     + break;
1934     + }
1935     + up_read(&tty->termios_rwsem);
1936    
1937     - timeout = wait_woken(&wait, TASK_INTERRUPTIBLE,
1938     - timeout);
1939     + timeout = wait_woken(&wait, TASK_INTERRUPTIBLE,
1940     + timeout);
1941    
1942     - down_read(&tty->termios_rwsem);
1943     - continue;
1944     + down_read(&tty->termios_rwsem);
1945     + continue;
1946     + }
1947     }
1948    
1949     if (ldata->icanon && !L_EXTPROC(tty)) {
1950     @@ -2446,12 +2437,17 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
1951    
1952     poll_wait(file, &tty->read_wait, wait);
1953     poll_wait(file, &tty->write_wait, wait);
1954     - if (check_other_done(tty))
1955     - mask |= POLLHUP;
1956     if (input_available_p(tty, 1))
1957     mask |= POLLIN | POLLRDNORM;
1958     + else {
1959     + tty_buffer_flush_work(tty->port);
1960     + if (input_available_p(tty, 1))
1961     + mask |= POLLIN | POLLRDNORM;
1962     + }
1963     if (tty->packet && tty->link->ctrl_status)
1964     mask |= POLLPRI | POLLIN | POLLRDNORM;
1965     + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
1966     + mask |= POLLHUP;
1967     if (tty_hung_up_p(file))
1968     mask |= POLLHUP;
1969     if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
1970     diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
1971     index 78e983677339..7865228f664f 100644
1972     --- a/drivers/tty/pty.c
1973     +++ b/drivers/tty/pty.c
1974     @@ -59,7 +59,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
1975     if (!tty->link)
1976     return;
1977     set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
1978     - tty_flip_buffer_push(tty->link->port);
1979     + wake_up_interruptible(&tty->link->read_wait);
1980     wake_up_interruptible(&tty->link->write_wait);
1981     if (tty->driver->subtype == PTY_TYPE_MASTER) {
1982     set_bit(TTY_OTHER_CLOSED, &tty->flags);
1983     @@ -247,9 +247,7 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
1984     goto out;
1985    
1986     clear_bit(TTY_IO_ERROR, &tty->flags);
1987     - /* TTY_OTHER_CLOSED must be cleared before TTY_OTHER_DONE */
1988     clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
1989     - clear_bit(TTY_OTHER_DONE, &tty->link->flags);
1990     set_bit(TTY_THROTTLED, &tty->flags);
1991     return 0;
1992    
1993     diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
1994     index 88531a36b69c..ed489880e62b 100644
1995     --- a/drivers/tty/serial/8250/8250_mid.c
1996     +++ b/drivers/tty/serial/8250/8250_mid.c
1997     @@ -14,6 +14,7 @@
1998     #include <linux/pci.h>
1999    
2000     #include <linux/dma/hsu.h>
2001     +#include <linux/8250_pci.h>
2002    
2003     #include "8250.h"
2004    
2005     @@ -24,6 +25,7 @@
2006     #define PCI_DEVICE_ID_INTEL_DNV_UART 0x19d8
2007    
2008     /* Intel MID Specific registers */
2009     +#define INTEL_MID_UART_DNV_FISR 0x08
2010     #define INTEL_MID_UART_PS 0x30
2011     #define INTEL_MID_UART_MUL 0x34
2012     #define INTEL_MID_UART_DIV 0x38
2013     @@ -31,6 +33,7 @@
2014     struct mid8250;
2015    
2016     struct mid8250_board {
2017     + unsigned int flags;
2018     unsigned long freq;
2019     unsigned int base_baud;
2020     int (*setup)(struct mid8250 *, struct uart_port *p);
2021     @@ -88,16 +91,16 @@ static int tng_setup(struct mid8250 *mid, struct uart_port *p)
2022     static int dnv_handle_irq(struct uart_port *p)
2023     {
2024     struct mid8250 *mid = p->private_data;
2025     - int ret;
2026     -
2027     - ret = hsu_dma_irq(&mid->dma_chip, 0);
2028     - ret |= hsu_dma_irq(&mid->dma_chip, 1);
2029     -
2030     - /* For now, letting the HW generate separate interrupt for the UART */
2031     - if (ret)
2032     - return ret;
2033     -
2034     - return serial8250_handle_irq(p, serial_port_in(p, UART_IIR));
2035     + unsigned int fisr = serial_port_in(p, INTEL_MID_UART_DNV_FISR);
2036     + int ret = IRQ_NONE;
2037     +
2038     + if (fisr & BIT(2))
2039     + ret |= hsu_dma_irq(&mid->dma_chip, 1);
2040     + if (fisr & BIT(1))
2041     + ret |= hsu_dma_irq(&mid->dma_chip, 0);
2042     + if (fisr & BIT(0))
2043     + ret |= serial8250_handle_irq(p, serial_port_in(p, UART_IIR));
2044     + return ret;
2045     }
2046    
2047     #define DNV_DMA_CHAN_OFFSET 0x80
2048     @@ -106,12 +109,13 @@ static int dnv_setup(struct mid8250 *mid, struct uart_port *p)
2049     {
2050     struct hsu_dma_chip *chip = &mid->dma_chip;
2051     struct pci_dev *pdev = to_pci_dev(p->dev);
2052     + unsigned int bar = FL_GET_BASE(mid->board->flags);
2053     int ret;
2054    
2055     chip->dev = &pdev->dev;
2056     chip->irq = pdev->irq;
2057     chip->regs = p->membase;
2058     - chip->length = pci_resource_len(pdev, 0);
2059     + chip->length = pci_resource_len(pdev, bar);
2060     chip->offset = DNV_DMA_CHAN_OFFSET;
2061    
2062     /* Falling back to PIO mode if DMA probing fails */
2063     @@ -217,6 +221,7 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2064     {
2065     struct uart_8250_port uart;
2066     struct mid8250 *mid;
2067     + unsigned int bar;
2068     int ret;
2069    
2070     ret = pcim_enable_device(pdev);
2071     @@ -230,6 +235,7 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2072     return -ENOMEM;
2073    
2074     mid->board = (struct mid8250_board *)id->driver_data;
2075     + bar = FL_GET_BASE(mid->board->flags);
2076    
2077     memset(&uart, 0, sizeof(struct uart_8250_port));
2078    
2079     @@ -242,8 +248,8 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2080     uart.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE;
2081     uart.port.set_termios = mid8250_set_termios;
2082    
2083     - uart.port.mapbase = pci_resource_start(pdev, 0);
2084     - uart.port.membase = pcim_iomap(pdev, 0, 0);
2085     + uart.port.mapbase = pci_resource_start(pdev, bar);
2086     + uart.port.membase = pcim_iomap(pdev, bar, 0);
2087     if (!uart.port.membase)
2088     return -ENOMEM;
2089    
2090     @@ -282,18 +288,21 @@ static void mid8250_remove(struct pci_dev *pdev)
2091     }
2092    
2093     static const struct mid8250_board pnw_board = {
2094     + .flags = FL_BASE0,
2095     .freq = 50000000,
2096     .base_baud = 115200,
2097     .setup = pnw_setup,
2098     };
2099    
2100     static const struct mid8250_board tng_board = {
2101     + .flags = FL_BASE0,
2102     .freq = 38400000,
2103     .base_baud = 1843200,
2104     .setup = tng_setup,
2105     };
2106    
2107     static const struct mid8250_board dnv_board = {
2108     + .flags = FL_BASE1,
2109     .freq = 133333333,
2110     .base_baud = 115200,
2111     .setup = dnv_setup,
2112     diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2113     index 7cd6f9a90542..c1d4a8fa9be8 100644
2114     --- a/drivers/tty/serial/8250/8250_pci.c
2115     +++ b/drivers/tty/serial/8250/8250_pci.c
2116     @@ -1401,6 +1401,9 @@ byt_set_termios(struct uart_port *p, struct ktermios *termios,
2117     unsigned long m, n;
2118     u32 reg;
2119    
2120     + /* Gracefully handle the B0 case: fall back to B9600 */
2121     + fuart = fuart ? fuart : 9600 * 16;
2122     +
2123     /* Get Fuart closer to Fref */
2124     fuart *= rounddown_pow_of_two(fref / fuart);
2125    
2126     diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
2127     index 94294558943c..7bbadd176c74 100644
2128     --- a/drivers/tty/serial/atmel_serial.c
2129     +++ b/drivers/tty/serial/atmel_serial.c
2130     @@ -277,6 +277,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
2131     return atmel_port->use_dma_rx;
2132     }
2133    
2134     +static bool atmel_use_fifo(struct uart_port *port)
2135     +{
2136     + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2137     +
2138     + return atmel_port->fifo_size;
2139     +}
2140     +
2141     static unsigned int atmel_get_lines_status(struct uart_port *port)
2142     {
2143     struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2144     @@ -2169,7 +2176,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2145     mode |= ATMEL_US_USMODE_RS485;
2146     } else if (termios->c_cflag & CRTSCTS) {
2147     /* RS232 with hardware handshake (RTS/CTS) */
2148     - mode |= ATMEL_US_USMODE_HWHS;
2149     + if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
2150     + dev_info(port->dev, "not enabling hardware flow control because DMA is used");
2151     + termios->c_cflag &= ~CRTSCTS;
2152     + } else {
2153     + mode |= ATMEL_US_USMODE_HWHS;
2154     + }
2155     } else {
2156     /* RS232 without hadware handshake */
2157     mode |= ATMEL_US_USMODE_NORMAL;
2158     diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
2159     index d72cd736bdc6..8320173af846 100644
2160     --- a/drivers/tty/serial/samsung.c
2161     +++ b/drivers/tty/serial/samsung.c
2162     @@ -1263,6 +1263,8 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
2163     /* check to see if we need to change clock source */
2164    
2165     if (ourport->baudclk != clk) {
2166     + clk_prepare_enable(clk);
2167     +
2168     s3c24xx_serial_setsource(port, clk_sel);
2169    
2170     if (!IS_ERR(ourport->baudclk)) {
2171     @@ -1270,8 +1272,6 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
2172     ourport->baudclk = ERR_PTR(-EINVAL);
2173     }
2174    
2175     - clk_prepare_enable(clk);
2176     -
2177     ourport->baudclk = clk;
2178     ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
2179     }
2180     diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
2181     index 3cd31e0d4bd9..fb31eecb708d 100644
2182     --- a/drivers/tty/tty_buffer.c
2183     +++ b/drivers/tty/tty_buffer.c
2184     @@ -37,29 +37,6 @@
2185    
2186     #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
2187    
2188     -/*
2189     - * If all tty flip buffers have been processed by flush_to_ldisc() or
2190     - * dropped by tty_buffer_flush(), check if the linked pty has been closed.
2191     - * If so, wake the reader/poll to process
2192     - */
2193     -static inline void check_other_closed(struct tty_struct *tty)
2194     -{
2195     - unsigned long flags, old;
2196     -
2197     - /* transition from TTY_OTHER_CLOSED => TTY_OTHER_DONE must be atomic */
2198     - for (flags = ACCESS_ONCE(tty->flags);
2199     - test_bit(TTY_OTHER_CLOSED, &flags);
2200     - ) {
2201     - old = flags;
2202     - __set_bit(TTY_OTHER_DONE, &flags);
2203     - flags = cmpxchg(&tty->flags, old, flags);
2204     - if (old == flags) {
2205     - wake_up_interruptible(&tty->read_wait);
2206     - break;
2207     - }
2208     - }
2209     -}
2210     -
2211     /**
2212     * tty_buffer_lock_exclusive - gain exclusive access to buffer
2213     * tty_buffer_unlock_exclusive - release exclusive access
2214     @@ -254,8 +231,6 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
2215     if (ld && ld->ops->flush_buffer)
2216     ld->ops->flush_buffer(tty);
2217    
2218     - check_other_closed(tty);
2219     -
2220     atomic_dec(&buf->priority);
2221     mutex_unlock(&buf->lock);
2222     }
2223     @@ -505,10 +480,8 @@ static void flush_to_ldisc(struct work_struct *work)
2224     */
2225     count = smp_load_acquire(&head->commit) - head->read;
2226     if (!count) {
2227     - if (next == NULL) {
2228     - check_other_closed(tty);
2229     + if (next == NULL)
2230     break;
2231     - }
2232     buf->head = next;
2233     tty_buffer_free(port, head);
2234     continue;
2235     @@ -597,3 +570,8 @@ bool tty_buffer_cancel_work(struct tty_port *port)
2236     {
2237     return cancel_work_sync(&port->buf.work);
2238     }
2239     +
2240     +void tty_buffer_flush_work(struct tty_port *port)
2241     +{
2242     + flush_work(&port->buf.work);
2243     +}
2244     diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
2245     index 4462d167900c..cf20282f79f0 100644
2246     --- a/drivers/tty/vt/vt.c
2247     +++ b/drivers/tty/vt/vt.c
2248     @@ -3583,9 +3583,10 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
2249     goto err;
2250    
2251     desc = csw->con_startup();
2252     -
2253     - if (!desc)
2254     + if (!desc) {
2255     + retval = -ENODEV;
2256     goto err;
2257     + }
2258    
2259     retval = -EINVAL;
2260    
2261     diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
2262     index 2057d91d8336..dadd1e8dfe09 100644
2263     --- a/drivers/usb/core/driver.c
2264     +++ b/drivers/usb/core/driver.c
2265     @@ -284,7 +284,7 @@ static int usb_probe_interface(struct device *dev)
2266     struct usb_device *udev = interface_to_usbdev(intf);
2267     const struct usb_device_id *id;
2268     int error = -ENODEV;
2269     - int lpm_disable_error;
2270     + int lpm_disable_error = -ENODEV;
2271    
2272     dev_dbg(dev, "%s\n", __func__);
2273    
2274     @@ -336,12 +336,14 @@ static int usb_probe_interface(struct device *dev)
2275     * setting during probe, that should also be fine. usb_set_interface()
2276     * will attempt to disable LPM, and fail if it can't disable it.
2277     */
2278     - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2279     - if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
2280     - dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.",
2281     - __func__, driver->name);
2282     - error = lpm_disable_error;
2283     - goto err;
2284     + if (driver->disable_hub_initiated_lpm) {
2285     + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2286     + if (lpm_disable_error) {
2287     + dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.",
2288     + __func__, driver->name);
2289     + error = lpm_disable_error;
2290     + goto err;
2291     + }
2292     }
2293    
2294     /* Carry out a deferred switch to altsetting 0 */
2295     @@ -391,7 +393,8 @@ static int usb_unbind_interface(struct device *dev)
2296     struct usb_interface *intf = to_usb_interface(dev);
2297     struct usb_host_endpoint *ep, **eps = NULL;
2298     struct usb_device *udev;
2299     - int i, j, error, r, lpm_disable_error;
2300     + int i, j, error, r;
2301     + int lpm_disable_error = -ENODEV;
2302    
2303     intf->condition = USB_INTERFACE_UNBINDING;
2304    
2305     @@ -399,12 +402,13 @@ static int usb_unbind_interface(struct device *dev)
2306     udev = interface_to_usbdev(intf);
2307     error = usb_autoresume_device(udev);
2308    
2309     - /* Hub-initiated LPM policy may change, so attempt to disable LPM until
2310     + /* If hub-initiated LPM policy may change, attempt to disable LPM until
2311     * the driver is unbound. If LPM isn't disabled, that's fine because it
2312     * wouldn't be enabled unless all the bound interfaces supported
2313     * hub-initiated LPM.
2314     */
2315     - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2316     + if (driver->disable_hub_initiated_lpm)
2317     + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2318    
2319     /*
2320     * Terminate all URBs for this interface unless the driver
2321     @@ -505,7 +509,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2322     struct device *dev;
2323     struct usb_device *udev;
2324     int retval = 0;
2325     - int lpm_disable_error;
2326     + int lpm_disable_error = -ENODEV;
2327    
2328     if (!iface)
2329     return -ENODEV;
2330     @@ -526,12 +530,14 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2331    
2332     iface->condition = USB_INTERFACE_BOUND;
2333    
2334     - /* Disable LPM until this driver is bound. */
2335     - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2336     - if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
2337     - dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
2338     - __func__, driver->name);
2339     - return -ENOMEM;
2340     + /* See the comment about disabling LPM in usb_probe_interface(). */
2341     + if (driver->disable_hub_initiated_lpm) {
2342     + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2343     + if (lpm_disable_error) {
2344     + dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
2345     + __func__, driver->name);
2346     + return -ENOMEM;
2347     + }
2348     }
2349    
2350     /* Claimed interfaces are initially inactive (suspended) and
2351     diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
2352     index 79d895c2dd71..97ef75af9632 100644
2353     --- a/drivers/usb/gadget/function/f_fs.c
2354     +++ b/drivers/usb/gadget/function/f_fs.c
2355     @@ -651,7 +651,7 @@ static void ffs_user_copy_worker(struct work_struct *work)
2356     if (io_data->read && ret > 0) {
2357     use_mm(io_data->mm);
2358     ret = copy_to_iter(io_data->buf, ret, &io_data->data);
2359     - if (iov_iter_count(&io_data->data))
2360     + if (ret != io_data->req->actual && iov_iter_count(&io_data->data))
2361     ret = -EFAULT;
2362     unuse_mm(io_data->mm);
2363     }
2364     diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
2365     index 223ccf89d226..a4f664062e0c 100644
2366     --- a/drivers/usb/gadget/function/f_mass_storage.c
2367     +++ b/drivers/usb/gadget/function/f_mass_storage.c
2368     @@ -2977,25 +2977,6 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2369     }
2370     EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string);
2371    
2372     -int fsg_common_run_thread(struct fsg_common *common)
2373     -{
2374     - common->state = FSG_STATE_IDLE;
2375     - /* Tell the thread to start working */
2376     - common->thread_task =
2377     - kthread_create(fsg_main_thread, common, "file-storage");
2378     - if (IS_ERR(common->thread_task)) {
2379     - common->state = FSG_STATE_TERMINATED;
2380     - return PTR_ERR(common->thread_task);
2381     - }
2382     -
2383     - DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
2384     -
2385     - wake_up_process(common->thread_task);
2386     -
2387     - return 0;
2388     -}
2389     -EXPORT_SYMBOL_GPL(fsg_common_run_thread);
2390     -
2391     static void fsg_common_release(struct kref *ref)
2392     {
2393     struct fsg_common *common = container_of(ref, struct fsg_common, ref);
2394     @@ -3005,6 +2986,7 @@ static void fsg_common_release(struct kref *ref)
2395     if (common->state != FSG_STATE_TERMINATED) {
2396     raise_exception(common, FSG_STATE_EXIT);
2397     wait_for_completion(&common->thread_notifier);
2398     + common->thread_task = NULL;
2399     }
2400    
2401     for (i = 0; i < ARRAY_SIZE(common->luns); ++i) {
2402     @@ -3050,9 +3032,21 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2403     if (ret)
2404     return ret;
2405     fsg_common_set_inquiry_string(fsg->common, NULL, NULL);
2406     - ret = fsg_common_run_thread(fsg->common);
2407     - if (ret)
2408     + }
2409     +
2410     + if (!common->thread_task) {
2411     + common->state = FSG_STATE_IDLE;
2412     + common->thread_task =
2413     + kthread_create(fsg_main_thread, common, "file-storage");
2414     + if (IS_ERR(common->thread_task)) {
2415     + int ret = PTR_ERR(common->thread_task);
2416     + common->thread_task = NULL;
2417     + common->state = FSG_STATE_TERMINATED;
2418     return ret;
2419     + }
2420     + DBG(common, "I/O thread pid: %d\n",
2421     + task_pid_nr(common->thread_task));
2422     + wake_up_process(common->thread_task);
2423     }
2424    
2425     fsg->gadget = gadget;
2426     diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h
2427     index 445df6775609..b6a9918eaefb 100644
2428     --- a/drivers/usb/gadget/function/f_mass_storage.h
2429     +++ b/drivers/usb/gadget/function/f_mass_storage.h
2430     @@ -153,8 +153,6 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
2431     void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2432     const char *pn);
2433    
2434     -int fsg_common_run_thread(struct fsg_common *common);
2435     -
2436     void fsg_config_from_params(struct fsg_config *cfg,
2437     const struct fsg_module_parameters *params,
2438     unsigned int fsg_num_buffers);
2439     diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c
2440     index 4b158e2d1e57..64b2cbb0bc6b 100644
2441     --- a/drivers/usb/gadget/legacy/acm_ms.c
2442     +++ b/drivers/usb/gadget/legacy/acm_ms.c
2443     @@ -133,10 +133,6 @@ static int acm_ms_do_config(struct usb_configuration *c)
2444     if (status < 0)
2445     goto put_msg;
2446    
2447     - status = fsg_common_run_thread(opts->common);
2448     - if (status)
2449     - goto remove_acm;
2450     -
2451     status = usb_add_function(c, f_msg);
2452     if (status)
2453     goto remove_acm;
2454     diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c
2455     index bda3c519110f..99aa22c81770 100644
2456     --- a/drivers/usb/gadget/legacy/mass_storage.c
2457     +++ b/drivers/usb/gadget/legacy/mass_storage.c
2458     @@ -132,10 +132,6 @@ static int msg_do_config(struct usb_configuration *c)
2459     if (IS_ERR(f_msg))
2460     return PTR_ERR(f_msg);
2461    
2462     - ret = fsg_common_run_thread(opts->common);
2463     - if (ret)
2464     - goto put_func;
2465     -
2466     ret = usb_add_function(c, f_msg);
2467     if (ret)
2468     goto put_func;
2469     diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c
2470     index 4fe794ddcd49..09c7c28f32f7 100644
2471     --- a/drivers/usb/gadget/legacy/multi.c
2472     +++ b/drivers/usb/gadget/legacy/multi.c
2473     @@ -137,7 +137,6 @@ static struct usb_function *f_msg_rndis;
2474    
2475     static int rndis_do_config(struct usb_configuration *c)
2476     {
2477     - struct fsg_opts *fsg_opts;
2478     int ret;
2479    
2480     if (gadget_is_otg(c->cdev->gadget)) {
2481     @@ -169,11 +168,6 @@ static int rndis_do_config(struct usb_configuration *c)
2482     goto err_fsg;
2483     }
2484    
2485     - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2486     - ret = fsg_common_run_thread(fsg_opts->common);
2487     - if (ret)
2488     - goto err_run;
2489     -
2490     ret = usb_add_function(c, f_msg_rndis);
2491     if (ret)
2492     goto err_run;
2493     @@ -225,7 +219,6 @@ static struct usb_function *f_msg_multi;
2494    
2495     static int cdc_do_config(struct usb_configuration *c)
2496     {
2497     - struct fsg_opts *fsg_opts;
2498     int ret;
2499    
2500     if (gadget_is_otg(c->cdev->gadget)) {
2501     @@ -258,11 +251,6 @@ static int cdc_do_config(struct usb_configuration *c)
2502     goto err_fsg;
2503     }
2504    
2505     - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2506     - ret = fsg_common_run_thread(fsg_opts->common);
2507     - if (ret)
2508     - goto err_run;
2509     -
2510     ret = usb_add_function(c, f_msg_multi);
2511     if (ret)
2512     goto err_run;
2513     diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
2514     index 8b3f6fb1825d..05d3f79e768d 100644
2515     --- a/drivers/usb/gadget/legacy/nokia.c
2516     +++ b/drivers/usb/gadget/legacy/nokia.c
2517     @@ -152,7 +152,6 @@ static int nokia_bind_config(struct usb_configuration *c)
2518     struct usb_function *f_ecm;
2519     struct usb_function *f_obex2 = NULL;
2520     struct usb_function *f_msg;
2521     - struct fsg_opts *fsg_opts;
2522     int status = 0;
2523     int obex1_stat = -1;
2524     int obex2_stat = -1;
2525     @@ -222,12 +221,6 @@ static int nokia_bind_config(struct usb_configuration *c)
2526     goto err_ecm;
2527     }
2528    
2529     - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2530     -
2531     - status = fsg_common_run_thread(fsg_opts->common);
2532     - if (status)
2533     - goto err_msg;
2534     -
2535     status = usb_add_function(c, f_msg);
2536     if (status)
2537     goto err_msg;
2538     diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
2539     index f660afba715d..89f7cd66f5e6 100644
2540     --- a/drivers/usb/gadget/udc/udc-core.c
2541     +++ b/drivers/usb/gadget/udc/udc-core.c
2542     @@ -71,7 +71,7 @@ int usb_gadget_map_request(struct usb_gadget *gadget,
2543     mapped = dma_map_sg(dev, req->sg, req->num_sgs,
2544     is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
2545     if (mapped == 0) {
2546     - dev_err(&gadget->dev, "failed to map SGs\n");
2547     + dev_err(dev, "failed to map SGs\n");
2548     return -EFAULT;
2549     }
2550    
2551     diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
2552     index 637f3f7cfce8..1a812eafe670 100644
2553     --- a/drivers/usb/misc/usbtest.c
2554     +++ b/drivers/usb/misc/usbtest.c
2555     @@ -505,6 +505,7 @@ static struct scatterlist *
2556     alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
2557     {
2558     struct scatterlist *sg;
2559     + unsigned int n_size = 0;
2560     unsigned i;
2561     unsigned size = max;
2562     unsigned maxpacket =
2563     @@ -537,7 +538,8 @@ alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
2564     break;
2565     case 1:
2566     for (j = 0; j < size; j++)
2567     - *buf++ = (u8) ((j % maxpacket) % 63);
2568     + *buf++ = (u8) (((j + n_size) % maxpacket) % 63);
2569     + n_size += size;
2570     break;
2571     }
2572    
2573     diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
2574     index c0866971db2b..1947ea0e0988 100644
2575     --- a/drivers/usb/serial/io_edgeport.c
2576     +++ b/drivers/usb/serial/io_edgeport.c
2577     @@ -2856,14 +2856,16 @@ static int edge_startup(struct usb_serial *serial)
2578     /* not set up yet, so do it now */
2579     edge_serial->interrupt_read_urb =
2580     usb_alloc_urb(0, GFP_KERNEL);
2581     - if (!edge_serial->interrupt_read_urb)
2582     - return -ENOMEM;
2583     + if (!edge_serial->interrupt_read_urb) {
2584     + response = -ENOMEM;
2585     + break;
2586     + }
2587    
2588     edge_serial->interrupt_in_buffer =
2589     kmalloc(buffer_size, GFP_KERNEL);
2590     if (!edge_serial->interrupt_in_buffer) {
2591     - usb_free_urb(edge_serial->interrupt_read_urb);
2592     - return -ENOMEM;
2593     + response = -ENOMEM;
2594     + break;
2595     }
2596     edge_serial->interrupt_in_endpoint =
2597     endpoint->bEndpointAddress;
2598     @@ -2891,14 +2893,16 @@ static int edge_startup(struct usb_serial *serial)
2599     /* not set up yet, so do it now */
2600     edge_serial->read_urb =
2601     usb_alloc_urb(0, GFP_KERNEL);
2602     - if (!edge_serial->read_urb)
2603     - return -ENOMEM;
2604     + if (!edge_serial->read_urb) {
2605     + response = -ENOMEM;
2606     + break;
2607     + }
2608    
2609     edge_serial->bulk_in_buffer =
2610     kmalloc(buffer_size, GFP_KERNEL);
2611     if (!edge_serial->bulk_in_buffer) {
2612     - usb_free_urb(edge_serial->read_urb);
2613     - return -ENOMEM;
2614     + response = -ENOMEM;
2615     + break;
2616     }
2617     edge_serial->bulk_in_endpoint =
2618     endpoint->bEndpointAddress;
2619     @@ -2924,9 +2928,22 @@ static int edge_startup(struct usb_serial *serial)
2620     }
2621     }
2622    
2623     - if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
2624     - dev_err(ddev, "Error - the proper endpoints were not found!\n");
2625     - return -ENODEV;
2626     + if (response || !interrupt_in_found || !bulk_in_found ||
2627     + !bulk_out_found) {
2628     + if (!response) {
2629     + dev_err(ddev, "expected endpoints not found\n");
2630     + response = -ENODEV;
2631     + }
2632     +
2633     + usb_free_urb(edge_serial->interrupt_read_urb);
2634     + kfree(edge_serial->interrupt_in_buffer);
2635     +
2636     + usb_free_urb(edge_serial->read_urb);
2637     + kfree(edge_serial->bulk_in_buffer);
2638     +
2639     + kfree(edge_serial);
2640     +
2641     + return response;
2642     }
2643    
2644     /* start interrupt read for this edgeport this interrupt will
2645     @@ -2949,16 +2966,9 @@ static void edge_disconnect(struct usb_serial *serial)
2646     {
2647     struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2648    
2649     - /* stop reads and writes on all ports */
2650     - /* free up our endpoint stuff */
2651     if (edge_serial->is_epic) {
2652     usb_kill_urb(edge_serial->interrupt_read_urb);
2653     - usb_free_urb(edge_serial->interrupt_read_urb);
2654     - kfree(edge_serial->interrupt_in_buffer);
2655     -
2656     usb_kill_urb(edge_serial->read_urb);
2657     - usb_free_urb(edge_serial->read_urb);
2658     - kfree(edge_serial->bulk_in_buffer);
2659     }
2660     }
2661    
2662     @@ -2971,6 +2981,16 @@ static void edge_release(struct usb_serial *serial)
2663     {
2664     struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2665    
2666     + if (edge_serial->is_epic) {
2667     + usb_kill_urb(edge_serial->interrupt_read_urb);
2668     + usb_free_urb(edge_serial->interrupt_read_urb);
2669     + kfree(edge_serial->interrupt_in_buffer);
2670     +
2671     + usb_kill_urb(edge_serial->read_urb);
2672     + usb_free_urb(edge_serial->read_urb);
2673     + kfree(edge_serial->bulk_in_buffer);
2674     + }
2675     +
2676     kfree(edge_serial);
2677     }
2678    
2679     diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
2680     index e07b15ed5814..7faa901ee47f 100644
2681     --- a/drivers/usb/serial/keyspan.c
2682     +++ b/drivers/usb/serial/keyspan.c
2683     @@ -2376,6 +2376,10 @@ static void keyspan_release(struct usb_serial *serial)
2684    
2685     s_priv = usb_get_serial_data(serial);
2686    
2687     + /* Make sure to unlink the URBs submitted in attach. */
2688     + usb_kill_urb(s_priv->instat_urb);
2689     + usb_kill_urb(s_priv->indat_urb);
2690     +
2691     usb_free_urb(s_priv->instat_urb);
2692     usb_free_urb(s_priv->indat_urb);
2693     usb_free_urb(s_priv->glocont_urb);
2694     diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
2695     index 31a8b47f1ac6..c6596cbcc4b6 100644
2696     --- a/drivers/usb/serial/mxuport.c
2697     +++ b/drivers/usb/serial/mxuport.c
2698     @@ -1259,6 +1259,15 @@ static int mxuport_attach(struct usb_serial *serial)
2699     return 0;
2700     }
2701    
2702     +static void mxuport_release(struct usb_serial *serial)
2703     +{
2704     + struct usb_serial_port *port0 = serial->port[0];
2705     + struct usb_serial_port *port1 = serial->port[1];
2706     +
2707     + usb_serial_generic_close(port1);
2708     + usb_serial_generic_close(port0);
2709     +}
2710     +
2711     static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port)
2712     {
2713     struct mxuport_port *mxport = usb_get_serial_port_data(port);
2714     @@ -1361,6 +1370,7 @@ static struct usb_serial_driver mxuport_device = {
2715     .probe = mxuport_probe,
2716     .port_probe = mxuport_port_probe,
2717     .attach = mxuport_attach,
2718     + .release = mxuport_release,
2719     .calc_num_ports = mxuport_calc_num_ports,
2720     .open = mxuport_open,
2721     .close = mxuport_close,
2722     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2723     index c6f497f16526..d96d423d00e6 100644
2724     --- a/drivers/usb/serial/option.c
2725     +++ b/drivers/usb/serial/option.c
2726     @@ -375,18 +375,22 @@ static void option_instat_callback(struct urb *urb);
2727     #define HAIER_PRODUCT_CE81B 0x10f8
2728     #define HAIER_PRODUCT_CE100 0x2009
2729    
2730     -/* Cinterion (formerly Siemens) products */
2731     -#define SIEMENS_VENDOR_ID 0x0681
2732     -#define CINTERION_VENDOR_ID 0x1e2d
2733     +/* Gemalto's Cinterion products (formerly Siemens) */
2734     +#define SIEMENS_VENDOR_ID 0x0681
2735     +#define CINTERION_VENDOR_ID 0x1e2d
2736     +#define CINTERION_PRODUCT_HC25_MDMNET 0x0040
2737     #define CINTERION_PRODUCT_HC25_MDM 0x0047
2738     -#define CINTERION_PRODUCT_HC25_MDMNET 0x0040
2739     +#define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
2740     #define CINTERION_PRODUCT_HC28_MDM 0x004C
2741     -#define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
2742     #define CINTERION_PRODUCT_EU3_E 0x0051
2743     #define CINTERION_PRODUCT_EU3_P 0x0052
2744     #define CINTERION_PRODUCT_PH8 0x0053
2745     #define CINTERION_PRODUCT_AHXX 0x0055
2746     #define CINTERION_PRODUCT_PLXX 0x0060
2747     +#define CINTERION_PRODUCT_PH8_2RMNET 0x0082
2748     +#define CINTERION_PRODUCT_PH8_AUDIO 0x0083
2749     +#define CINTERION_PRODUCT_AHXX_2RMNET 0x0084
2750     +#define CINTERION_PRODUCT_AHXX_AUDIO 0x0085
2751    
2752     /* Olivetti products */
2753     #define OLIVETTI_VENDOR_ID 0x0b3c
2754     @@ -633,6 +637,10 @@ static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = {
2755     .reserved = BIT(1) | BIT(2) | BIT(3),
2756     };
2757    
2758     +static const struct option_blacklist_info cinterion_rmnet2_blacklist = {
2759     + .reserved = BIT(4) | BIT(5),
2760     +};
2761     +
2762     static const struct usb_device_id option_ids[] = {
2763     { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
2764     { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
2765     @@ -1602,7 +1610,79 @@ static const struct usb_device_id option_ids[] = {
2766     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
2767     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
2768     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
2769     - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
2770     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff42, 0xff, 0xff, 0xff) },
2771     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff43, 0xff, 0xff, 0xff) },
2772     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff44, 0xff, 0xff, 0xff) },
2773     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff45, 0xff, 0xff, 0xff) },
2774     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff46, 0xff, 0xff, 0xff) },
2775     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff47, 0xff, 0xff, 0xff) },
2776     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff48, 0xff, 0xff, 0xff) },
2777     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff49, 0xff, 0xff, 0xff) },
2778     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4a, 0xff, 0xff, 0xff) },
2779     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4b, 0xff, 0xff, 0xff) },
2780     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4c, 0xff, 0xff, 0xff) },
2781     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4d, 0xff, 0xff, 0xff) },
2782     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4e, 0xff, 0xff, 0xff) },
2783     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4f, 0xff, 0xff, 0xff) },
2784     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff50, 0xff, 0xff, 0xff) },
2785     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff51, 0xff, 0xff, 0xff) },
2786     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff52, 0xff, 0xff, 0xff) },
2787     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff53, 0xff, 0xff, 0xff) },
2788     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff54, 0xff, 0xff, 0xff) },
2789     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff55, 0xff, 0xff, 0xff) },
2790     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff56, 0xff, 0xff, 0xff) },
2791     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff57, 0xff, 0xff, 0xff) },
2792     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff58, 0xff, 0xff, 0xff) },
2793     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff59, 0xff, 0xff, 0xff) },
2794     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5a, 0xff, 0xff, 0xff) },
2795     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5b, 0xff, 0xff, 0xff) },
2796     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5c, 0xff, 0xff, 0xff) },
2797     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5d, 0xff, 0xff, 0xff) },
2798     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5e, 0xff, 0xff, 0xff) },
2799     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5f, 0xff, 0xff, 0xff) },
2800     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff60, 0xff, 0xff, 0xff) },
2801     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff61, 0xff, 0xff, 0xff) },
2802     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff62, 0xff, 0xff, 0xff) },
2803     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff63, 0xff, 0xff, 0xff) },
2804     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff64, 0xff, 0xff, 0xff) },
2805     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff65, 0xff, 0xff, 0xff) },
2806     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff66, 0xff, 0xff, 0xff) },
2807     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff67, 0xff, 0xff, 0xff) },
2808     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff68, 0xff, 0xff, 0xff) },
2809     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff69, 0xff, 0xff, 0xff) },
2810     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6a, 0xff, 0xff, 0xff) },
2811     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6b, 0xff, 0xff, 0xff) },
2812     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6c, 0xff, 0xff, 0xff) },
2813     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6d, 0xff, 0xff, 0xff) },
2814     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6e, 0xff, 0xff, 0xff) },
2815     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6f, 0xff, 0xff, 0xff) },
2816     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff70, 0xff, 0xff, 0xff) },
2817     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff71, 0xff, 0xff, 0xff) },
2818     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff72, 0xff, 0xff, 0xff) },
2819     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff73, 0xff, 0xff, 0xff) },
2820     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff74, 0xff, 0xff, 0xff) },
2821     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff75, 0xff, 0xff, 0xff) },
2822     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff76, 0xff, 0xff, 0xff) },
2823     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff77, 0xff, 0xff, 0xff) },
2824     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff78, 0xff, 0xff, 0xff) },
2825     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff79, 0xff, 0xff, 0xff) },
2826     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7a, 0xff, 0xff, 0xff) },
2827     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7b, 0xff, 0xff, 0xff) },
2828     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7c, 0xff, 0xff, 0xff) },
2829     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7d, 0xff, 0xff, 0xff) },
2830     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7e, 0xff, 0xff, 0xff) },
2831     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7f, 0xff, 0xff, 0xff) },
2832     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff80, 0xff, 0xff, 0xff) },
2833     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff81, 0xff, 0xff, 0xff) },
2834     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff82, 0xff, 0xff, 0xff) },
2835     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff83, 0xff, 0xff, 0xff) },
2836     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff84, 0xff, 0xff, 0xff) },
2837     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff85, 0xff, 0xff, 0xff) },
2838     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff86, 0xff, 0xff, 0xff) },
2839     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff87, 0xff, 0xff, 0xff) },
2840     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff88, 0xff, 0xff, 0xff) },
2841     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff89, 0xff, 0xff, 0xff) },
2842     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8a, 0xff, 0xff, 0xff) },
2843     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) },
2844     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) },
2845     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
2846     @@ -1613,6 +1693,61 @@ static const struct usb_device_id option_ids[] = {
2847     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) },
2848     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
2849     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
2850     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff9f, 0xff, 0xff, 0xff) },
2851     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa0, 0xff, 0xff, 0xff) },
2852     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa1, 0xff, 0xff, 0xff) },
2853     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa2, 0xff, 0xff, 0xff) },
2854     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa3, 0xff, 0xff, 0xff) },
2855     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa4, 0xff, 0xff, 0xff) },
2856     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa5, 0xff, 0xff, 0xff) },
2857     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa6, 0xff, 0xff, 0xff) },
2858     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa7, 0xff, 0xff, 0xff) },
2859     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa8, 0xff, 0xff, 0xff) },
2860     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa9, 0xff, 0xff, 0xff) },
2861     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaa, 0xff, 0xff, 0xff) },
2862     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffab, 0xff, 0xff, 0xff) },
2863     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffac, 0xff, 0xff, 0xff) },
2864     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffae, 0xff, 0xff, 0xff) },
2865     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaf, 0xff, 0xff, 0xff) },
2866     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb0, 0xff, 0xff, 0xff) },
2867     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb1, 0xff, 0xff, 0xff) },
2868     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb2, 0xff, 0xff, 0xff) },
2869     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb3, 0xff, 0xff, 0xff) },
2870     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb4, 0xff, 0xff, 0xff) },
2871     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb5, 0xff, 0xff, 0xff) },
2872     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb6, 0xff, 0xff, 0xff) },
2873     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb7, 0xff, 0xff, 0xff) },
2874     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb8, 0xff, 0xff, 0xff) },
2875     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb9, 0xff, 0xff, 0xff) },
2876     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffba, 0xff, 0xff, 0xff) },
2877     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbb, 0xff, 0xff, 0xff) },
2878     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbc, 0xff, 0xff, 0xff) },
2879     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbd, 0xff, 0xff, 0xff) },
2880     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbe, 0xff, 0xff, 0xff) },
2881     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbf, 0xff, 0xff, 0xff) },
2882     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc0, 0xff, 0xff, 0xff) },
2883     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc1, 0xff, 0xff, 0xff) },
2884     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc2, 0xff, 0xff, 0xff) },
2885     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc3, 0xff, 0xff, 0xff) },
2886     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc4, 0xff, 0xff, 0xff) },
2887     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc5, 0xff, 0xff, 0xff) },
2888     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc6, 0xff, 0xff, 0xff) },
2889     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc7, 0xff, 0xff, 0xff) },
2890     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc8, 0xff, 0xff, 0xff) },
2891     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc9, 0xff, 0xff, 0xff) },
2892     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffca, 0xff, 0xff, 0xff) },
2893     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcb, 0xff, 0xff, 0xff) },
2894     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcc, 0xff, 0xff, 0xff) },
2895     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcd, 0xff, 0xff, 0xff) },
2896     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffce, 0xff, 0xff, 0xff) },
2897     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcf, 0xff, 0xff, 0xff) },
2898     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd0, 0xff, 0xff, 0xff) },
2899     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd1, 0xff, 0xff, 0xff) },
2900     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd2, 0xff, 0xff, 0xff) },
2901     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd3, 0xff, 0xff, 0xff) },
2902     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd4, 0xff, 0xff, 0xff) },
2903     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd5, 0xff, 0xff, 0xff) },
2904     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
2905     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffec, 0xff, 0xff, 0xff) },
2906     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffee, 0xff, 0xff, 0xff) },
2907     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff6, 0xff, 0xff, 0xff) },
2908     @@ -1712,7 +1847,13 @@ static const struct usb_device_id option_ids[] = {
2909     { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) },
2910     { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
2911     .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2912     - { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
2913     + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_2RMNET, 0xff),
2914     + .driver_info = (kernel_ulong_t)&cinterion_rmnet2_blacklist },
2915     + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_AUDIO, 0xff),
2916     + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2917     + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },
2918     + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) },
2919     + { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
2920     { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
2921     { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
2922     { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
2923     diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
2924     index 504f5bff79c0..b18974cbd995 100644
2925     --- a/drivers/usb/serial/quatech2.c
2926     +++ b/drivers/usb/serial/quatech2.c
2927     @@ -141,6 +141,7 @@ static void qt2_release(struct usb_serial *serial)
2928    
2929     serial_priv = usb_get_serial_data(serial);
2930    
2931     + usb_kill_urb(serial_priv->read_urb);
2932     usb_free_urb(serial_priv->read_urb);
2933     kfree(serial_priv->read_buffer);
2934     kfree(serial_priv);
2935     diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
2936     index f07d01bc4875..bfcd87ee8ff5 100644
2937     --- a/fs/btrfs/ioctl.c
2938     +++ b/fs/btrfs/ioctl.c
2939     @@ -1648,7 +1648,7 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
2940    
2941     src_inode = file_inode(src.file);
2942     if (src_inode->i_sb != file_inode(file)->i_sb) {
2943     - btrfs_info(BTRFS_I(src_inode)->root->fs_info,
2944     + btrfs_info(BTRFS_I(file_inode(file))->root->fs_info,
2945     "Snapshot src from another FS");
2946     ret = -EXDEV;
2947     } else if (!inode_owner_or_capable(src_inode)) {
2948     diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
2949     index 59727e32ed0f..af0ec2d5ad0e 100644
2950     --- a/fs/cifs/sess.c
2951     +++ b/fs/cifs/sess.c
2952     @@ -400,19 +400,27 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
2953     sec_blob->LmChallengeResponse.MaximumLength = 0;
2954    
2955     sec_blob->NtChallengeResponse.BufferOffset = cpu_to_le32(tmp - pbuffer);
2956     - rc = setup_ntlmv2_rsp(ses, nls_cp);
2957     - if (rc) {
2958     - cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
2959     - goto setup_ntlmv2_ret;
2960     + if (ses->user_name != NULL) {
2961     + rc = setup_ntlmv2_rsp(ses, nls_cp);
2962     + if (rc) {
2963     + cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
2964     + goto setup_ntlmv2_ret;
2965     + }
2966     + memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
2967     + ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2968     + tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
2969     +
2970     + sec_blob->NtChallengeResponse.Length =
2971     + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2972     + sec_blob->NtChallengeResponse.MaximumLength =
2973     + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2974     + } else {
2975     + /*
2976     + * don't send an NT Response for anonymous access
2977     + */
2978     + sec_blob->NtChallengeResponse.Length = 0;
2979     + sec_blob->NtChallengeResponse.MaximumLength = 0;
2980     }
2981     - memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
2982     - ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2983     - tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
2984     -
2985     - sec_blob->NtChallengeResponse.Length =
2986     - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2987     - sec_blob->NtChallengeResponse.MaximumLength =
2988     - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
2989    
2990     if (ses->domainName == NULL) {
2991     sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
2992     @@ -670,20 +678,24 @@ sess_auth_lanman(struct sess_data *sess_data)
2993    
2994     pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
2995    
2996     - /* no capabilities flags in old lanman negotiation */
2997     - pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
2998     -
2999     - /* Calculate hash with password and copy into bcc_ptr.
3000     - * Encryption Key (stored as in cryptkey) gets used if the
3001     - * security mode bit in Negottiate Protocol response states
3002     - * to use challenge/response method (i.e. Password bit is 1).
3003     - */
3004     - rc = calc_lanman_hash(ses->password, ses->server->cryptkey,
3005     - ses->server->sec_mode & SECMODE_PW_ENCRYPT ?
3006     - true : false, lnm_session_key);
3007     -
3008     - memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
3009     - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3010     + if (ses->user_name != NULL) {
3011     + /* no capabilities flags in old lanman negotiation */
3012     + pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3013     +
3014     + /* Calculate hash with password and copy into bcc_ptr.
3015     + * Encryption Key (stored as in cryptkey) gets used if the
3016     + * security mode bit in Negottiate Protocol response states
3017     + * to use challenge/response method (i.e. Password bit is 1).
3018     + */
3019     + rc = calc_lanman_hash(ses->password, ses->server->cryptkey,
3020     + ses->server->sec_mode & SECMODE_PW_ENCRYPT ?
3021     + true : false, lnm_session_key);
3022     +
3023     + memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
3024     + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3025     + } else {
3026     + pSMB->old_req.PasswordLength = 0;
3027     + }
3028    
3029     /*
3030     * can not sign if LANMAN negotiated so no need
3031     @@ -769,26 +781,31 @@ sess_auth_ntlm(struct sess_data *sess_data)
3032     capabilities = cifs_ssetup_hdr(ses, pSMB);
3033    
3034     pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
3035     - pSMB->req_no_secext.CaseInsensitivePasswordLength =
3036     - cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3037     - pSMB->req_no_secext.CaseSensitivePasswordLength =
3038     - cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3039     -
3040     - /* calculate ntlm response and session key */
3041     - rc = setup_ntlm_response(ses, sess_data->nls_cp);
3042     - if (rc) {
3043     - cifs_dbg(VFS, "Error %d during NTLM authentication\n",
3044     - rc);
3045     - goto out;
3046     - }
3047     + if (ses->user_name != NULL) {
3048     + pSMB->req_no_secext.CaseInsensitivePasswordLength =
3049     + cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3050     + pSMB->req_no_secext.CaseSensitivePasswordLength =
3051     + cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3052     +
3053     + /* calculate ntlm response and session key */
3054     + rc = setup_ntlm_response(ses, sess_data->nls_cp);
3055     + if (rc) {
3056     + cifs_dbg(VFS, "Error %d during NTLM authentication\n",
3057     + rc);
3058     + goto out;
3059     + }
3060    
3061     - /* copy ntlm response */
3062     - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3063     - CIFS_AUTH_RESP_SIZE);
3064     - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3065     - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3066     - CIFS_AUTH_RESP_SIZE);
3067     - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3068     + /* copy ntlm response */
3069     + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3070     + CIFS_AUTH_RESP_SIZE);
3071     + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3072     + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3073     + CIFS_AUTH_RESP_SIZE);
3074     + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3075     + } else {
3076     + pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
3077     + pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
3078     + }
3079    
3080     if (ses->capabilities & CAP_UNICODE) {
3081     /* unicode strings must be word aligned */
3082     @@ -878,22 +895,26 @@ sess_auth_ntlmv2(struct sess_data *sess_data)
3083     /* LM2 password would be here if we supported it */
3084     pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
3085    
3086     - /* calculate nlmv2 response and session key */
3087     - rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
3088     - if (rc) {
3089     - cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
3090     - goto out;
3091     - }
3092     + if (ses->user_name != NULL) {
3093     + /* calculate nlmv2 response and session key */
3094     + rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
3095     + if (rc) {
3096     + cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
3097     + goto out;
3098     + }
3099    
3100     - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3101     - ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3102     - bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3103     + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3104     + ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3105     + bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3106    
3107     - /* set case sensitive password length after tilen may get
3108     - * assigned, tilen is 0 otherwise.
3109     - */
3110     - pSMB->req_no_secext.CaseSensitivePasswordLength =
3111     - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3112     + /* set case sensitive password length after tilen may get
3113     + * assigned, tilen is 0 otherwise.
3114     + */
3115     + pSMB->req_no_secext.CaseSensitivePasswordLength =
3116     + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3117     + } else {
3118     + pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
3119     + }
3120    
3121     if (ses->capabilities & CAP_UNICODE) {
3122     if (sess_data->iov[0].iov_len % 2) {
3123     diff --git a/fs/cifs/smb2glob.h b/fs/cifs/smb2glob.h
3124     index bc0bb9c34f72..0ffa18094335 100644
3125     --- a/fs/cifs/smb2glob.h
3126     +++ b/fs/cifs/smb2glob.h
3127     @@ -44,6 +44,7 @@
3128     #define SMB2_OP_DELETE 7
3129     #define SMB2_OP_HARDLINK 8
3130     #define SMB2_OP_SET_EOF 9
3131     +#define SMB2_OP_RMDIR 10
3132    
3133     /* Used when constructing chained read requests. */
3134     #define CHAINED_REQUEST 1
3135     diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
3136     index 899bbc86f73e..4f0231e685a9 100644
3137     --- a/fs/cifs/smb2inode.c
3138     +++ b/fs/cifs/smb2inode.c
3139     @@ -80,6 +80,10 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
3140     * SMB2_open() call.
3141     */
3142     break;
3143     + case SMB2_OP_RMDIR:
3144     + tmprc = SMB2_rmdir(xid, tcon, fid.persistent_fid,
3145     + fid.volatile_fid);
3146     + break;
3147     case SMB2_OP_RENAME:
3148     tmprc = SMB2_rename(xid, tcon, fid.persistent_fid,
3149     fid.volatile_fid, (__le16 *)data);
3150     @@ -191,8 +195,8 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
3151     struct cifs_sb_info *cifs_sb)
3152     {
3153     return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
3154     - CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE,
3155     - NULL, SMB2_OP_DELETE);
3156     + CREATE_NOT_FILE,
3157     + NULL, SMB2_OP_RMDIR);
3158     }
3159    
3160     int
3161     diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
3162     index 373b5cd1c913..82c5f57382b2 100644
3163     --- a/fs/cifs/smb2pdu.c
3164     +++ b/fs/cifs/smb2pdu.c
3165     @@ -2577,6 +2577,22 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
3166     }
3167    
3168     int
3169     +SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
3170     + u64 persistent_fid, u64 volatile_fid)
3171     +{
3172     + __u8 delete_pending = 1;
3173     + void *data;
3174     + unsigned int size;
3175     +
3176     + data = &delete_pending;
3177     + size = 1; /* sizeof __u8 */
3178     +
3179     + return send_set_info(xid, tcon, persistent_fid, volatile_fid,
3180     + current->tgid, FILE_DISPOSITION_INFORMATION, 1, &data,
3181     + &size);
3182     +}
3183     +
3184     +int
3185     SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
3186     u64 persistent_fid, u64 volatile_fid, __le16 *target_file)
3187     {
3188     diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
3189     index 79dc650c18b2..9bc59f9c12fb 100644
3190     --- a/fs/cifs/smb2proto.h
3191     +++ b/fs/cifs/smb2proto.h
3192     @@ -140,6 +140,8 @@ extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
3193     extern int SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
3194     u64 persistent_fid, u64 volatile_fid,
3195     __le16 *target_file);
3196     +extern int SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
3197     + u64 persistent_fid, u64 volatile_fid);
3198     extern int SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
3199     u64 persistent_fid, u64 volatile_fid,
3200     __le16 *target_file);
3201     diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
3202     index 9bdbf98240a0..796ff0eafd3c 100644
3203     --- a/fs/ext4/move_extent.c
3204     +++ b/fs/ext4/move_extent.c
3205     @@ -390,6 +390,7 @@ data_copy:
3206     *err = ext4_get_block(orig_inode, orig_blk_offset + i, bh, 0);
3207     if (*err < 0)
3208     break;
3209     + bh = bh->b_this_page;
3210     }
3211     if (!*err)
3212     *err = block_commit_write(pagep[0], from, from + replaced_size);
3213     diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
3214     index a561591896bd..3713fd52b44b 100644
3215     --- a/fs/hpfs/super.c
3216     +++ b/fs/hpfs/super.c
3217     @@ -15,6 +15,7 @@
3218     #include <linux/sched.h>
3219     #include <linux/bitmap.h>
3220     #include <linux/slab.h>
3221     +#include <linux/seq_file.h>
3222    
3223     /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
3224    
3225     @@ -453,10 +454,6 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
3226     int lowercase, eas, chk, errs, chkdsk, timeshift;
3227     int o;
3228     struct hpfs_sb_info *sbi = hpfs_sb(s);
3229     - char *new_opts = kstrdup(data, GFP_KERNEL);
3230     -
3231     - if (!new_opts)
3232     - return -ENOMEM;
3233    
3234     sync_filesystem(s);
3235    
3236     @@ -493,17 +490,44 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
3237    
3238     if (!(*flags & MS_RDONLY)) mark_dirty(s, 1);
3239    
3240     - replace_mount_options(s, new_opts);
3241     -
3242     hpfs_unlock(s);
3243     return 0;
3244    
3245     out_err:
3246     hpfs_unlock(s);
3247     - kfree(new_opts);
3248     return -EINVAL;
3249     }
3250    
3251     +static int hpfs_show_options(struct seq_file *seq, struct dentry *root)
3252     +{
3253     + struct hpfs_sb_info *sbi = hpfs_sb(root->d_sb);
3254     +
3255     + seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, sbi->sb_uid));
3256     + seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, sbi->sb_gid));
3257     + seq_printf(seq, ",umask=%03o", (~sbi->sb_mode & 0777));
3258     + if (sbi->sb_lowercase)
3259     + seq_printf(seq, ",case=lower");
3260     + if (!sbi->sb_chk)
3261     + seq_printf(seq, ",check=none");
3262     + if (sbi->sb_chk == 2)
3263     + seq_printf(seq, ",check=strict");
3264     + if (!sbi->sb_err)
3265     + seq_printf(seq, ",errors=continue");
3266     + if (sbi->sb_err == 2)
3267     + seq_printf(seq, ",errors=panic");
3268     + if (!sbi->sb_chkdsk)
3269     + seq_printf(seq, ",chkdsk=no");
3270     + if (sbi->sb_chkdsk == 2)
3271     + seq_printf(seq, ",chkdsk=always");
3272     + if (!sbi->sb_eas)
3273     + seq_printf(seq, ",eas=no");
3274     + if (sbi->sb_eas == 1)
3275     + seq_printf(seq, ",eas=ro");
3276     + if (sbi->sb_timeshift)
3277     + seq_printf(seq, ",timeshift=%d", sbi->sb_timeshift);
3278     + return 0;
3279     +}
3280     +
3281     /* Super operations */
3282    
3283     static const struct super_operations hpfs_sops =
3284     @@ -514,7 +538,7 @@ static const struct super_operations hpfs_sops =
3285     .put_super = hpfs_put_super,
3286     .statfs = hpfs_statfs,
3287     .remount_fs = hpfs_remount_fs,
3288     - .show_options = generic_show_options,
3289     + .show_options = hpfs_show_options,
3290     };
3291    
3292     static int hpfs_fill_super(struct super_block *s, void *options, int silent)
3293     @@ -537,8 +561,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
3294    
3295     int o;
3296    
3297     - save_mount_options(s, options);
3298     -
3299     sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
3300     if (!sbi) {
3301     return -ENOMEM;
3302     diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
3303     index e2aadbc7151f..7d633f19e38a 100644
3304     --- a/include/asm-generic/qspinlock.h
3305     +++ b/include/asm-generic/qspinlock.h
3306     @@ -27,7 +27,30 @@
3307     */
3308     static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
3309     {
3310     - return atomic_read(&lock->val);
3311     + /*
3312     + * queued_spin_lock_slowpath() can ACQUIRE the lock before
3313     + * issuing the unordered store that sets _Q_LOCKED_VAL.
3314     + *
3315     + * See both smp_cond_acquire() sites for more detail.
3316     + *
3317     + * This however means that in code like:
3318     + *
3319     + * spin_lock(A) spin_lock(B)
3320     + * spin_unlock_wait(B) spin_is_locked(A)
3321     + * do_something() do_something()
3322     + *
3323     + * Both CPUs can end up running do_something() because the store
3324     + * setting _Q_LOCKED_VAL will pass through the loads in
3325     + * spin_unlock_wait() and/or spin_is_locked().
3326     + *
3327     + * Avoid this by issuing a full memory barrier between the spin_lock()
3328     + * and the loads in spin_unlock_wait() and spin_is_locked().
3329     + *
3330     + * Note that regular mutual exclusion doesn't care about this
3331     + * delayed store.
3332     + */
3333     + smp_mb();
3334     + return atomic_read(&lock->val) & _Q_LOCKED_MASK;
3335     }
3336    
3337     /**
3338     @@ -107,6 +130,8 @@ static __always_inline void queued_spin_unlock(struct qspinlock *lock)
3339     */
3340     static inline void queued_spin_unlock_wait(struct qspinlock *lock)
3341     {
3342     + /* See queued_spin_is_locked() */
3343     + smp_mb();
3344     while (atomic_read(&lock->val) & _Q_LOCKED_MASK)
3345     cpu_relax();
3346     }
3347     diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h
3348     index 3d1a3af5cf59..a2508a8f9a9c 100644
3349     --- a/include/asm-generic/siginfo.h
3350     +++ b/include/asm-generic/siginfo.h
3351     @@ -17,21 +17,6 @@
3352     struct siginfo;
3353     void do_schedule_next_timer(struct siginfo *info);
3354    
3355     -#ifndef HAVE_ARCH_COPY_SIGINFO
3356     -
3357     -#include <linux/string.h>
3358     -
3359     -static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
3360     -{
3361     - if (from->si_code < 0)
3362     - memcpy(to, from, sizeof(*to));
3363     - else
3364     - /* _sigchld is currently the largest know union member */
3365     - memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
3366     -}
3367     -
3368     -#endif
3369     -
3370     extern int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
3371    
3372     #endif
3373     diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
3374     index 735f9f8c4e43..5261751f6bd4 100644
3375     --- a/include/linux/can/dev.h
3376     +++ b/include/linux/can/dev.h
3377     @@ -40,8 +40,11 @@ struct can_priv {
3378     struct can_clock clock;
3379    
3380     enum can_state state;
3381     - u32 ctrlmode;
3382     - u32 ctrlmode_supported;
3383     +
3384     + /* CAN controller features - see include/uapi/linux/can/netlink.h */
3385     + u32 ctrlmode; /* current options setting */
3386     + u32 ctrlmode_supported; /* options that can be modified by netlink */
3387     + u32 ctrlmode_static; /* static enabled options for driver/hardware */
3388    
3389     int restart_ms;
3390     struct timer_list restart_timer;
3391     @@ -108,6 +111,21 @@ static inline bool can_is_canfd_skb(const struct sk_buff *skb)
3392     return skb->len == CANFD_MTU;
3393     }
3394    
3395     +/* helper to define static CAN controller features at device creation time */
3396     +static inline void can_set_static_ctrlmode(struct net_device *dev,
3397     + u32 static_mode)
3398     +{
3399     + struct can_priv *priv = netdev_priv(dev);
3400     +
3401     + /* alloc_candev() succeeded => netdev_priv() is valid at this point */
3402     + priv->ctrlmode = static_mode;
3403     + priv->ctrlmode_static = static_mode;
3404     +
3405     + /* override MTU which was set by default in can_setup()? */
3406     + if (static_mode & CAN_CTRLMODE_FD)
3407     + dev->mtu = CANFD_MTU;
3408     +}
3409     +
3410     /* get data length from can_dlc with sanitized can_dlc */
3411     u8 can_dlc2len(u8 can_dlc);
3412    
3413     diff --git a/include/linux/signal.h b/include/linux/signal.h
3414     index 92557bbce7e7..d80259afb9e5 100644
3415     --- a/include/linux/signal.h
3416     +++ b/include/linux/signal.h
3417     @@ -28,6 +28,21 @@ struct sigpending {
3418     sigset_t signal;
3419     };
3420    
3421     +#ifndef HAVE_ARCH_COPY_SIGINFO
3422     +
3423     +#include <linux/string.h>
3424     +
3425     +static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
3426     +{
3427     + if (from->si_code < 0)
3428     + memcpy(to, from, sizeof(*to));
3429     + else
3430     + /* _sigchld is currently the largest know union member */
3431     + memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
3432     +}
3433     +
3434     +#endif
3435     +
3436     /*
3437     * Define some primitives to manipulate sigset_t.
3438     */
3439     diff --git a/include/linux/tty.h b/include/linux/tty.h
3440     index 3bf03b6b52e9..83b264c52898 100644
3441     --- a/include/linux/tty.h
3442     +++ b/include/linux/tty.h
3443     @@ -338,7 +338,6 @@ struct tty_file_private {
3444     #define TTY_EXCLUSIVE 3 /* Exclusive open mode */
3445     #define TTY_DEBUG 4 /* Debugging */
3446     #define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */
3447     -#define TTY_OTHER_DONE 6 /* Closed pty has completed input processing */
3448     #define TTY_LDISC_OPEN 11 /* Line discipline is open */
3449     #define TTY_PTY_LOCK 16 /* pty private */
3450     #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */
3451     @@ -469,6 +468,7 @@ extern void tty_buffer_init(struct tty_port *port);
3452     extern void tty_buffer_set_lock_subclass(struct tty_port *port);
3453     extern bool tty_buffer_restart_work(struct tty_port *port);
3454     extern bool tty_buffer_cancel_work(struct tty_port *port);
3455     +extern void tty_buffer_flush_work(struct tty_port *port);
3456     extern speed_t tty_termios_baud_rate(struct ktermios *termios);
3457     extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
3458     extern void tty_termios_encode_baud_rate(struct ktermios *termios,
3459     diff --git a/include/linux/usb.h b/include/linux/usb.h
3460     index b79925dd2b41..12891ffd4bf0 100644
3461     --- a/include/linux/usb.h
3462     +++ b/include/linux/usb.h
3463     @@ -1068,7 +1068,7 @@ struct usbdrv_wrap {
3464     * for interfaces bound to this driver.
3465     * @soft_unbind: if set to 1, the USB core will not kill URBs and disable
3466     * endpoints before calling the driver's disconnect method.
3467     - * @disable_hub_initiated_lpm: if set to 0, the USB core will not allow hubs
3468     + * @disable_hub_initiated_lpm: if set to 1, the USB core will not allow hubs
3469     * to initiate lower power link state transitions when an idle timeout
3470     * occurs. Device-initiated USB 3.0 link PM will still be allowed.
3471     *
3472     diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
3473     index fe89d7cd67b9..4f6ba34cdee6 100644
3474     --- a/include/scsi/scsi_device.h
3475     +++ b/include/scsi/scsi_device.h
3476     @@ -239,6 +239,7 @@ scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...);
3477     enum scsi_target_state {
3478     STARGET_CREATED = 1,
3479     STARGET_RUNNING,
3480     + STARGET_REMOVE,
3481     STARGET_DEL,
3482     };
3483    
3484     diff --git a/kernel/events/core.c b/kernel/events/core.c
3485     index 1e889a078dbc..95e47d2f2c67 100644
3486     --- a/kernel/events/core.c
3487     +++ b/kernel/events/core.c
3488     @@ -946,6 +946,7 @@ static void put_ctx(struct perf_event_context *ctx)
3489     * function.
3490     *
3491     * Lock order:
3492     + * cred_guard_mutex
3493     * task_struct::perf_event_mutex
3494     * perf_event_context::mutex
3495     * perf_event_context::lock
3496     @@ -3418,7 +3419,6 @@ static struct task_struct *
3497     find_lively_task_by_vpid(pid_t vpid)
3498     {
3499     struct task_struct *task;
3500     - int err;
3501    
3502     rcu_read_lock();
3503     if (!vpid)
3504     @@ -3432,16 +3432,7 @@ find_lively_task_by_vpid(pid_t vpid)
3505     if (!task)
3506     return ERR_PTR(-ESRCH);
3507    
3508     - /* Reuse ptrace permission checks for now. */
3509     - err = -EACCES;
3510     - if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS))
3511     - goto errout;
3512     -
3513     return task;
3514     -errout:
3515     - put_task_struct(task);
3516     - return ERR_PTR(err);
3517     -
3518     }
3519    
3520     /*
3521     @@ -8328,6 +8319,24 @@ SYSCALL_DEFINE5(perf_event_open,
3522    
3523     get_online_cpus();
3524    
3525     + if (task) {
3526     + err = mutex_lock_interruptible(&task->signal->cred_guard_mutex);
3527     + if (err)
3528     + goto err_cpus;
3529     +
3530     + /*
3531     + * Reuse ptrace permission checks for now.
3532     + *
3533     + * We must hold cred_guard_mutex across this and any potential
3534     + * perf_install_in_context() call for this new event to
3535     + * serialize against exec() altering our credentials (and the
3536     + * perf_event_exit_task() that could imply).
3537     + */
3538     + err = -EACCES;
3539     + if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS))
3540     + goto err_cred;
3541     + }
3542     +
3543     if (flags & PERF_FLAG_PID_CGROUP)
3544     cgroup_fd = pid;
3545    
3546     @@ -8335,7 +8344,7 @@ SYSCALL_DEFINE5(perf_event_open,
3547     NULL, NULL, cgroup_fd);
3548     if (IS_ERR(event)) {
3549     err = PTR_ERR(event);
3550     - goto err_cpus;
3551     + goto err_cred;
3552     }
3553    
3554     if (is_sampling_event(event)) {
3555     @@ -8394,11 +8403,6 @@ SYSCALL_DEFINE5(perf_event_open,
3556     goto err_context;
3557     }
3558    
3559     - if (task) {
3560     - put_task_struct(task);
3561     - task = NULL;
3562     - }
3563     -
3564     /*
3565     * Look up the group leader (we will attach this event to it):
3566     */
3567     @@ -8486,6 +8490,11 @@ SYSCALL_DEFINE5(perf_event_open,
3568    
3569     WARN_ON_ONCE(ctx->parent_ctx);
3570    
3571     + /*
3572     + * This is the point on no return; we cannot fail hereafter. This is
3573     + * where we start modifying current state.
3574     + */
3575     +
3576     if (move_group) {
3577     /*
3578     * See perf_event_ctx_lock() for comments on the details
3579     @@ -8555,6 +8564,11 @@ SYSCALL_DEFINE5(perf_event_open,
3580     mutex_unlock(&gctx->mutex);
3581     mutex_unlock(&ctx->mutex);
3582    
3583     + if (task) {
3584     + mutex_unlock(&task->signal->cred_guard_mutex);
3585     + put_task_struct(task);
3586     + }
3587     +
3588     put_online_cpus();
3589    
3590     event->owner = current;
3591     @@ -8589,6 +8603,9 @@ err_alloc:
3592     */
3593     if (!event_file)
3594     free_event(event);
3595     +err_cred:
3596     + if (task)
3597     + mutex_unlock(&task->signal->cred_guard_mutex);
3598     err_cpus:
3599     put_online_cpus();
3600     err_task:
3601     @@ -8868,6 +8885,9 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
3602    
3603     /*
3604     * When a child task exits, feed back event values to parent events.
3605     + *
3606     + * Can be called with cred_guard_mutex held when called from
3607     + * install_exec_creds().
3608     */
3609     void perf_event_exit_task(struct task_struct *child)
3610     {
3611     diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c
3612     index ef7159012cf3..b0b93fd33af9 100644
3613     --- a/kernel/sched/loadavg.c
3614     +++ b/kernel/sched/loadavg.c
3615     @@ -99,10 +99,13 @@ long calc_load_fold_active(struct rq *this_rq)
3616     static unsigned long
3617     calc_load(unsigned long load, unsigned long exp, unsigned long active)
3618     {
3619     - load *= exp;
3620     - load += active * (FIXED_1 - exp);
3621     - load += 1UL << (FSHIFT - 1);
3622     - return load >> FSHIFT;
3623     + unsigned long newload;
3624     +
3625     + newload = load * exp + active * (FIXED_1 - exp);
3626     + if (active >= load)
3627     + newload += FIXED_1-1;
3628     +
3629     + return newload / FIXED_1;
3630     }
3631    
3632     #ifdef CONFIG_NO_HZ_COMMON
3633     diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
3634     index 9c6045a27ba3..acbb0e73d3a2 100644
3635     --- a/kernel/trace/ring_buffer.c
3636     +++ b/kernel/trace/ring_buffer.c
3637     @@ -437,7 +437,7 @@ struct ring_buffer_per_cpu {
3638     raw_spinlock_t reader_lock; /* serialize readers */
3639     arch_spinlock_t lock;
3640     struct lock_class_key lock_key;
3641     - unsigned int nr_pages;
3642     + unsigned long nr_pages;
3643     unsigned int current_context;
3644     struct list_head *pages;
3645     struct buffer_page *head_page; /* read from head */
3646     @@ -458,7 +458,7 @@ struct ring_buffer_per_cpu {
3647     u64 write_stamp;
3648     u64 read_stamp;
3649     /* ring buffer pages to update, > 0 to add, < 0 to remove */
3650     - int nr_pages_to_update;
3651     + long nr_pages_to_update;
3652     struct list_head new_pages; /* new pages to add */
3653     struct work_struct update_pages_work;
3654     struct completion update_done;
3655     @@ -1137,10 +1137,10 @@ static int rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
3656     return 0;
3657     }
3658    
3659     -static int __rb_allocate_pages(int nr_pages, struct list_head *pages, int cpu)
3660     +static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu)
3661     {
3662     - int i;
3663     struct buffer_page *bpage, *tmp;
3664     + long i;
3665    
3666     for (i = 0; i < nr_pages; i++) {
3667     struct page *page;
3668     @@ -1177,7 +1177,7 @@ free_pages:
3669     }
3670    
3671     static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
3672     - unsigned nr_pages)
3673     + unsigned long nr_pages)
3674     {
3675     LIST_HEAD(pages);
3676    
3677     @@ -1202,7 +1202,7 @@ static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
3678     }
3679    
3680     static struct ring_buffer_per_cpu *
3681     -rb_allocate_cpu_buffer(struct ring_buffer *buffer, int nr_pages, int cpu)
3682     +rb_allocate_cpu_buffer(struct ring_buffer *buffer, long nr_pages, int cpu)
3683     {
3684     struct ring_buffer_per_cpu *cpu_buffer;
3685     struct buffer_page *bpage;
3686     @@ -1302,8 +1302,9 @@ struct ring_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags,
3687     struct lock_class_key *key)
3688     {
3689     struct ring_buffer *buffer;
3690     + long nr_pages;
3691     int bsize;
3692     - int cpu, nr_pages;
3693     + int cpu;
3694    
3695     /* keep it in its own cache line */
3696     buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()),
3697     @@ -1429,12 +1430,12 @@ static inline unsigned long rb_page_write(struct buffer_page *bpage)
3698     }
3699    
3700     static int
3701     -rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
3702     +rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)
3703     {
3704     struct list_head *tail_page, *to_remove, *next_page;
3705     struct buffer_page *to_remove_page, *tmp_iter_page;
3706     struct buffer_page *last_page, *first_page;
3707     - unsigned int nr_removed;
3708     + unsigned long nr_removed;
3709     unsigned long head_bit;
3710     int page_entries;
3711    
3712     @@ -1651,7 +1652,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
3713     int cpu_id)
3714     {
3715     struct ring_buffer_per_cpu *cpu_buffer;
3716     - unsigned nr_pages;
3717     + unsigned long nr_pages;
3718     int cpu, err = 0;
3719    
3720     /*
3721     @@ -1665,14 +1666,13 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
3722     !cpumask_test_cpu(cpu_id, buffer->cpumask))
3723     return size;
3724    
3725     - size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
3726     - size *= BUF_PAGE_SIZE;
3727     + nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
3728    
3729     /* we need a minimum of two pages */
3730     - if (size < BUF_PAGE_SIZE * 2)
3731     - size = BUF_PAGE_SIZE * 2;
3732     + if (nr_pages < 2)
3733     + nr_pages = 2;
3734    
3735     - nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
3736     + size = nr_pages * BUF_PAGE_SIZE;
3737    
3738     /*
3739     * Don't succeed if resizing is disabled, as a reader might be
3740     @@ -4645,8 +4645,9 @@ static int rb_cpu_notify(struct notifier_block *self,
3741     struct ring_buffer *buffer =
3742     container_of(self, struct ring_buffer, cpu_notify);
3743     long cpu = (long)hcpu;
3744     - int cpu_i, nr_pages_same;
3745     - unsigned int nr_pages;
3746     + long nr_pages_same;
3747     + int cpu_i;
3748     + unsigned long nr_pages;
3749    
3750     switch (action) {
3751     case CPU_UP_PREPARE:
3752     diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
3753     index 4efedcbe4165..da3386a9d244 100644
3754     --- a/scripts/Makefile.extrawarn
3755     +++ b/scripts/Makefile.extrawarn
3756     @@ -24,6 +24,7 @@ warning-1 += $(call cc-option, -Wmissing-prototypes)
3757     warning-1 += -Wold-style-definition
3758     warning-1 += $(call cc-option, -Wmissing-include-dirs)
3759     warning-1 += $(call cc-option, -Wunused-but-set-variable)
3760     +warning-1 += $(call cc-option, -Wunused-const-variable)
3761     warning-1 += $(call cc-disable-warning, missing-field-initializers)
3762    
3763     warning-2 := -Waggregate-return
3764     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3765     index 4918ffa5ba68..d53c25e7a1c1 100644
3766     --- a/sound/pci/hda/patch_realtek.c
3767     +++ b/sound/pci/hda/patch_realtek.c
3768     @@ -335,6 +335,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
3769     case 0x10ec0283:
3770     case 0x10ec0286:
3771     case 0x10ec0288:
3772     + case 0x10ec0295:
3773     case 0x10ec0298:
3774     alc_update_coef_idx(codec, 0x10, 1<<9, 0);
3775     break;
3776     @@ -342,6 +343,11 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
3777     case 0x10ec0293:
3778     alc_update_coef_idx(codec, 0xa, 1<<13, 0);
3779     break;
3780     + case 0x10ec0234:
3781     + case 0x10ec0274:
3782     + case 0x10ec0294:
3783     + alc_update_coef_idx(codec, 0x10, 1<<15, 0);
3784     + break;
3785     case 0x10ec0662:
3786     if ((coef & 0x00f0) == 0x0030)
3787     alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
3788     @@ -902,6 +908,7 @@ static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
3789     { 0x10ec0298, 0x1028, 0, "ALC3266" },
3790     { 0x10ec0256, 0x1028, 0, "ALC3246" },
3791     { 0x10ec0225, 0x1028, 0, "ALC3253" },
3792     + { 0x10ec0295, 0x1028, 0, "ALC3254" },
3793     { 0x10ec0670, 0x1025, 0, "ALC669X" },
3794     { 0x10ec0676, 0x1025, 0, "ALC679X" },
3795     { 0x10ec0282, 0x1043, 0, "ALC3229" },
3796     @@ -2647,6 +2654,7 @@ enum {
3797     ALC269_TYPE_ALC255,
3798     ALC269_TYPE_ALC256,
3799     ALC269_TYPE_ALC225,
3800     + ALC269_TYPE_ALC294,
3801     };
3802    
3803     /*
3804     @@ -2677,6 +2685,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
3805     case ALC269_TYPE_ALC255:
3806     case ALC269_TYPE_ALC256:
3807     case ALC269_TYPE_ALC225:
3808     + case ALC269_TYPE_ALC294:
3809     ssids = alc269_ssids;
3810     break;
3811     default:
3812     @@ -3690,6 +3699,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
3813     alc_process_coef_fw(codec, coef0668);
3814     break;
3815     case 0x10ec0225:
3816     + case 0x10ec0295:
3817     alc_process_coef_fw(codec, coef0225);
3818     break;
3819     }
3820     @@ -3790,6 +3800,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3821     snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3822     break;
3823     case 0x10ec0225:
3824     + case 0x10ec0295:
3825     alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
3826     snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3827     alc_process_coef_fw(codec, coef0225);
3828     @@ -3847,6 +3858,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
3829    
3830     switch (codec->core.vendor_id) {
3831     case 0x10ec0225:
3832     + case 0x10ec0295:
3833     alc_process_coef_fw(codec, coef0225);
3834     break;
3835     case 0x10ec0255:
3836     @@ -3950,6 +3962,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
3837     alc_process_coef_fw(codec, coef0688);
3838     break;
3839     case 0x10ec0225:
3840     + case 0x10ec0295:
3841     alc_process_coef_fw(codec, coef0225);
3842     break;
3843     }
3844     @@ -4031,6 +4044,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
3845     alc_process_coef_fw(codec, coef0688);
3846     break;
3847     case 0x10ec0225:
3848     + case 0x10ec0295:
3849     alc_process_coef_fw(codec, coef0225);
3850     break;
3851     }
3852     @@ -4114,6 +4128,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
3853     is_ctia = (val & 0x1c02) == 0x1c02;
3854     break;
3855     case 0x10ec0225:
3856     + case 0x10ec0295:
3857     alc_process_coef_fw(codec, coef0225);
3858     msleep(800);
3859     val = alc_read_coef_idx(codec, 0x46);
3860     @@ -5459,8 +5474,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3861     SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
3862     SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
3863     SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
3864     - SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
3865     + SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
3866     SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
3867     + SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
3868     SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
3869     SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
3870     SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
3871     @@ -5704,6 +5720,9 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
3872     {0x14, 0x90170110},
3873     {0x21, 0x02211020}),
3874     SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
3875     + {0x14, 0x90170130},
3876     + {0x21, 0x02211040}),
3877     + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
3878     {0x12, 0x90a60140},
3879     {0x14, 0x90170110},
3880     {0x21, 0x02211020}),
3881     @@ -6026,8 +6045,14 @@ static int patch_alc269(struct hda_codec *codec)
3882     alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
3883     break;
3884     case 0x10ec0225:
3885     + case 0x10ec0295:
3886     spec->codec_variant = ALC269_TYPE_ALC225;
3887     break;
3888     + case 0x10ec0234:
3889     + case 0x10ec0274:
3890     + case 0x10ec0294:
3891     + spec->codec_variant = ALC269_TYPE_ALC294;
3892     + break;
3893     }
3894    
3895     if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
3896     @@ -6942,6 +6967,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
3897     HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
3898     HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
3899     HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
3900     + HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
3901     HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
3902     HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
3903     HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
3904     @@ -6952,6 +6978,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
3905     HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
3906     HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
3907     HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
3908     + HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
3909     HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
3910     HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
3911     HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
3912     @@ -6964,6 +6991,8 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
3913     HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
3914     HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
3915     HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
3916     + HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
3917     + HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
3918     HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
3919     HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
3920     HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
3921     diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
3922     index ec16f7812c8b..6ebfdee3e2c6 100644
3923     --- a/tools/perf/tests/bpf.c
3924     +++ b/tools/perf/tests/bpf.c
3925     @@ -146,7 +146,7 @@ prepare_bpf(void *obj_buf, size_t obj_buf_sz, const char *name)
3926     return obj;
3927     }
3928    
3929     -static int __test__bpf(int index)
3930     +static int __test__bpf(int idx)
3931     {
3932     int ret;
3933     void *obj_buf;
3934     @@ -154,27 +154,27 @@ static int __test__bpf(int index)
3935     struct bpf_object *obj;
3936    
3937     ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
3938     - bpf_testcase_table[index].prog_id,
3939     + bpf_testcase_table[idx].prog_id,
3940     true);
3941     if (ret != TEST_OK || !obj_buf || !obj_buf_sz) {
3942     pr_debug("Unable to get BPF object, %s\n",
3943     - bpf_testcase_table[index].msg_compile_fail);
3944     - if (index == 0)
3945     + bpf_testcase_table[idx].msg_compile_fail);
3946     + if (idx == 0)
3947     return TEST_SKIP;
3948     else
3949     return TEST_FAIL;
3950     }
3951    
3952     obj = prepare_bpf(obj_buf, obj_buf_sz,
3953     - bpf_testcase_table[index].name);
3954     + bpf_testcase_table[idx].name);
3955     if (!obj) {
3956     ret = TEST_FAIL;
3957     goto out;
3958     }
3959    
3960     ret = do_test(obj,
3961     - bpf_testcase_table[index].target_func,
3962     - bpf_testcase_table[index].expect_result);
3963     + bpf_testcase_table[idx].target_func,
3964     + bpf_testcase_table[idx].expect_result);
3965     out:
3966     bpf__clear();
3967     return ret;
3968     diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
3969     index bc4cf507cde5..366e38ba8b49 100644
3970     --- a/tools/perf/tests/llvm.c
3971     +++ b/tools/perf/tests/llvm.c
3972     @@ -50,7 +50,7 @@ static struct {
3973     int
3974     test_llvm__fetch_bpf_obj(void **p_obj_buf,
3975     size_t *p_obj_buf_sz,
3976     - enum test_llvm__testcase index,
3977     + enum test_llvm__testcase idx,
3978     bool force)
3979     {
3980     const char *source;
3981     @@ -59,11 +59,11 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
3982     char *tmpl_new = NULL, *clang_opt_new = NULL;
3983     int err, old_verbose, ret = TEST_FAIL;
3984    
3985     - if (index >= __LLVM_TESTCASE_MAX)
3986     + if (idx >= __LLVM_TESTCASE_MAX)
3987     return TEST_FAIL;
3988    
3989     - source = bpf_source_table[index].source;
3990     - desc = bpf_source_table[index].desc;
3991     + source = bpf_source_table[idx].source;
3992     + desc = bpf_source_table[idx].desc;
3993    
3994     perf_config(perf_config_cb, NULL);
3995