Magellan Linux

Annotation of /trunk/kernel-magellan/patches-4.5/0105-4.5.6-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


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