Magellan Linux

Contents of /trunk/kernel-magellan/patches-4.6/0100-4.6.1-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2815 - (show annotations) (download)
Thu Aug 4 13:24:19 2016 UTC (7 years, 9 months ago) by niro
File size: 160519 byte(s)
-linux-4.6.1
1 diff --git a/Documentation/serial/tty.txt b/Documentation/serial/tty.txt
2 index 798cba82c762..b48780977a68 100644
3 --- a/Documentation/serial/tty.txt
4 +++ b/Documentation/serial/tty.txt
5 @@ -210,9 +210,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 0f9cb36d45c2..2fcc41ea99a3 100644
17 --- a/Makefile
18 +++ b/Makefile
19 @@ -1,6 +1,6 @@
20 VERSION = 4
21 PATCHLEVEL = 6
22 -SUBLEVEL = 0
23 +SUBLEVEL = 1
24 EXTRAVERSION =
25 NAME = Charred Weasel
26
27 @@ -697,9 +697,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 d6d4191e68f2..dea1452a8419 100644
42 --- a/arch/arm/kvm/mmu.c
43 +++ b/arch/arm/kvm/mmu.c
44 @@ -893,11 +893,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 @@ -946,12 +949,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 989fef16d461..44430ce5819e 100644
94 --- a/arch/arm64/include/asm/pgtable.h
95 +++ b/arch/arm64/include/asm/pgtable.h
96 @@ -280,6 +280,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 @@ -288,7 +289,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 @@ -327,7 +328,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 @@ -526,6 +526,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 @@ -578,9 +593,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 84c8684431c7..f0c3fb7ec8cf 100644
158 --- a/arch/arm64/kernel/cpuinfo.c
159 +++ b/arch/arm64/kernel/cpuinfo.c
160 @@ -87,7 +87,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 95df28bc875f..3ae4a28c4aed 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 c4038d2a724c..caa5ea1038a0 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/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
414 index 84fb4fcfaa41..93243554cae9 100644
415 --- a/arch/powerpc/kvm/book3s_hv.c
416 +++ b/arch/powerpc/kvm/book3s_hv.c
417 @@ -27,6 +27,7 @@
418 #include <linux/export.h>
419 #include <linux/fs.h>
420 #include <linux/anon_inodes.h>
421 +#include <linux/cpu.h>
422 #include <linux/cpumask.h>
423 #include <linux/spinlock.h>
424 #include <linux/page-flags.h>
425 diff --git a/arch/x86/crypto/sha-mb/sha1_x8_avx2.S b/arch/x86/crypto/sha-mb/sha1_x8_avx2.S
426 index 8e1b47792b31..c9dae1cd2919 100644
427 --- a/arch/x86/crypto/sha-mb/sha1_x8_avx2.S
428 +++ b/arch/x86/crypto/sha-mb/sha1_x8_avx2.S
429 @@ -296,7 +296,11 @@ W14 = TMP_
430 #
431 ENTRY(sha1_x8_avx2)
432
433 - push RSP_SAVE
434 + # save callee-saved clobbered registers to comply with C function ABI
435 + push %r12
436 + push %r13
437 + push %r14
438 + push %r15
439
440 #save rsp
441 mov %rsp, RSP_SAVE
442 @@ -446,7 +450,12 @@ lloop:
443 ## Postamble
444
445 mov RSP_SAVE, %rsp
446 - pop RSP_SAVE
447 +
448 + # restore callee-saved clobbered registers
449 + pop %r15
450 + pop %r14
451 + pop %r13
452 + pop %r12
453
454 ret
455 ENDPROC(sha1_x8_avx2)
456 diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
457 index 7012d18bb293..f921a1ed43f7 100644
458 --- a/arch/x86/events/intel/uncore.c
459 +++ b/arch/x86/events/intel/uncore.c
460 @@ -888,7 +888,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
461 return -ENODEV;
462
463 pkg = topology_phys_to_logical_pkg(phys_id);
464 - if (WARN_ON_ONCE(pkg < 0))
465 + if (pkg < 0)
466 return -EINVAL;
467
468 if (UNCORE_PCI_DEV_TYPE(id->driver_data) == UNCORE_EXTRA_PCI_DEV) {
469 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
470 index 3636ec06c887..aeab47932933 100644
471 --- a/arch/x86/include/asm/cpufeature.h
472 +++ b/arch/x86/include/asm/cpufeature.h
473 @@ -63,9 +63,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
474 (((bit)>>5)==11 && (1UL<<((bit)&31) & REQUIRED_MASK11)) || \
475 (((bit)>>5)==12 && (1UL<<((bit)&31) & REQUIRED_MASK12)) || \
476 (((bit)>>5)==13 && (1UL<<((bit)&31) & REQUIRED_MASK13)) || \
477 - (((bit)>>5)==13 && (1UL<<((bit)&31) & REQUIRED_MASK14)) || \
478 - (((bit)>>5)==13 && (1UL<<((bit)&31) & REQUIRED_MASK15)) || \
479 - (((bit)>>5)==14 && (1UL<<((bit)&31) & REQUIRED_MASK16)) )
480 + (((bit)>>5)==14 && (1UL<<((bit)&31) & REQUIRED_MASK14)) || \
481 + (((bit)>>5)==15 && (1UL<<((bit)&31) & REQUIRED_MASK15)) || \
482 + (((bit)>>5)==16 && (1UL<<((bit)&31) & REQUIRED_MASK16)) )
483
484 #define DISABLED_MASK_BIT_SET(bit) \
485 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & DISABLED_MASK0 )) || \
486 @@ -82,9 +82,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
487 (((bit)>>5)==11 && (1UL<<((bit)&31) & DISABLED_MASK11)) || \
488 (((bit)>>5)==12 && (1UL<<((bit)&31) & DISABLED_MASK12)) || \
489 (((bit)>>5)==13 && (1UL<<((bit)&31) & DISABLED_MASK13)) || \
490 - (((bit)>>5)==13 && (1UL<<((bit)&31) & DISABLED_MASK14)) || \
491 - (((bit)>>5)==13 && (1UL<<((bit)&31) & DISABLED_MASK15)) || \
492 - (((bit)>>5)==14 && (1UL<<((bit)&31) & DISABLED_MASK16)) )
493 + (((bit)>>5)==14 && (1UL<<((bit)&31) & DISABLED_MASK14)) || \
494 + (((bit)>>5)==15 && (1UL<<((bit)&31) & DISABLED_MASK15)) || \
495 + (((bit)>>5)==16 && (1UL<<((bit)&31) & DISABLED_MASK16)) )
496
497 #define cpu_has(c, bit) \
498 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
499 diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h
500 index 39343be7d4f4..911e9358ceb1 100644
501 --- a/arch/x86/include/asm/disabled-features.h
502 +++ b/arch/x86/include/asm/disabled-features.h
503 @@ -29,11 +29,11 @@
504 #endif /* CONFIG_X86_64 */
505
506 #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
507 -# define DISABLE_PKU (1<<(X86_FEATURE_PKU))
508 -# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE))
509 -#else
510 # define DISABLE_PKU 0
511 # define DISABLE_OSPKE 0
512 +#else
513 +# define DISABLE_PKU (1<<(X86_FEATURE_PKU & 31))
514 +# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE & 31))
515 #endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
516
517 /*
518 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
519 index 8394b3d1f94f..f45a4b9d28c8 100644
520 --- a/arch/x86/kernel/cpu/common.c
521 +++ b/arch/x86/kernel/cpu/common.c
522 @@ -310,6 +310,10 @@ static bool pku_disabled;
523
524 static __always_inline void setup_pku(struct cpuinfo_x86 *c)
525 {
526 + /* check the boot processor, plus compile options for PKU: */
527 + if (!cpu_feature_enabled(X86_FEATURE_PKU))
528 + return;
529 + /* checks the actual processor's cpuid bits: */
530 if (!cpu_has(c, X86_FEATURE_PKU))
531 return;
532 if (pku_disabled)
533 diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c
534 index 3f8c732117ec..c146f3c262c3 100644
535 --- a/arch/x86/kvm/mtrr.c
536 +++ b/arch/x86/kvm/mtrr.c
537 @@ -44,8 +44,6 @@ static bool msr_mtrr_valid(unsigned msr)
538 case MSR_MTRRdefType:
539 case MSR_IA32_CR_PAT:
540 return true;
541 - case 0x2f8:
542 - return true;
543 }
544 return false;
545 }
546 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
547 index 133679d520af..faf52bac1416 100644
548 --- a/arch/x86/kvm/vmx.c
549 +++ b/arch/x86/kvm/vmx.c
550 @@ -5050,8 +5050,8 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
551 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
552
553 cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
554 - vmx_set_cr0(vcpu, cr0); /* enter rmode */
555 vmx->vcpu.arch.cr0 = cr0;
556 + vmx_set_cr0(vcpu, cr0); /* enter rmode */
557 vmx_set_cr4(vcpu, 0);
558 vmx_set_efer(vcpu, 0);
559 vmx_fpu_activate(vcpu);
560 diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
561 index beac4dfdade6..349b8ce92bf2 100644
562 --- a/arch/x86/pci/xen.c
563 +++ b/arch/x86/pci/xen.c
564 @@ -491,8 +491,11 @@ int __init pci_xen_initial_domain(void)
565 #endif
566 __acpi_register_gsi = acpi_register_gsi_xen;
567 __acpi_unregister_gsi = NULL;
568 - /* Pre-allocate legacy irqs */
569 - for (irq = 0; irq < nr_legacy_irqs(); irq++) {
570 + /*
571 + * Pre-allocate the legacy IRQs. Use NR_LEGACY_IRQS here
572 + * because we don't have a PIC and thus nr_legacy_irqs() is zero.
573 + */
574 + for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
575 int trigger, polarity;
576
577 if (acpi_get_override_irq(irq, &trigger, &polarity) == -1)
578 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
579 index cd2c3d6d40e0..993fd31394c8 100644
580 --- a/drivers/acpi/device_pm.c
581 +++ b/drivers/acpi/device_pm.c
582 @@ -319,6 +319,7 @@ int acpi_device_fix_up_power(struct acpi_device *device)
583
584 return ret;
585 }
586 +EXPORT_SYMBOL_GPL(acpi_device_fix_up_power);
587
588 int acpi_device_update_power(struct acpi_device *device, int *state_p)
589 {
590 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
591 index 814d5f83b75e..f03677588b9d 100644
592 --- a/drivers/acpi/osl.c
593 +++ b/drivers/acpi/osl.c
594 @@ -135,7 +135,7 @@ static struct osi_linux {
595 unsigned int enable:1;
596 unsigned int dmi:1;
597 unsigned int cmdline:1;
598 - unsigned int default_disabling:1;
599 + u8 default_disabling;
600 } osi_linux = {0, 0, 0, 0};
601
602 static u32 acpi_osi_handler(acpi_string interface, u32 supported)
603 @@ -1751,10 +1751,13 @@ void __init acpi_osi_setup(char *str)
604 if (*str == '!') {
605 str++;
606 if (*str == '\0') {
607 - osi_linux.default_disabling = 1;
608 + /* Do not override acpi_osi=!* */
609 + if (!osi_linux.default_disabling)
610 + osi_linux.default_disabling =
611 + ACPI_DISABLE_ALL_VENDOR_STRINGS;
612 return;
613 } else if (*str == '*') {
614 - acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
615 + osi_linux.default_disabling = ACPI_DISABLE_ALL_STRINGS;
616 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
617 osi = &osi_setup_entries[i];
618 osi->enable = false;
619 @@ -1827,10 +1830,13 @@ static void __init acpi_osi_setup_late(void)
620 acpi_status status;
621
622 if (osi_linux.default_disabling) {
623 - status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
624 + status = acpi_update_interfaces(osi_linux.default_disabling);
625
626 if (ACPI_SUCCESS(status))
627 - printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
628 + printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n",
629 + osi_linux.default_disabling ==
630 + ACPI_DISABLE_ALL_STRINGS ?
631 + " and feature groups" : "");
632 }
633
634 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
635 diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
636 index 80783dcb7f57..aba31210c802 100644
637 --- a/drivers/bluetooth/hci_vhci.c
638 +++ b/drivers/bluetooth/hci_vhci.c
639 @@ -50,6 +50,7 @@ struct vhci_data {
640 wait_queue_head_t read_wait;
641 struct sk_buff_head readq;
642
643 + struct mutex open_mutex;
644 struct delayed_work open_timeout;
645 };
646
647 @@ -87,12 +88,15 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
648 return 0;
649 }
650
651 -static int vhci_create_device(struct vhci_data *data, __u8 opcode)
652 +static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
653 {
654 struct hci_dev *hdev;
655 struct sk_buff *skb;
656 __u8 dev_type;
657
658 + if (data->hdev)
659 + return -EBADFD;
660 +
661 /* bits 0-1 are dev_type (BR/EDR or AMP) */
662 dev_type = opcode & 0x03;
663
664 @@ -151,6 +155,17 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
665 return 0;
666 }
667
668 +static int vhci_create_device(struct vhci_data *data, __u8 opcode)
669 +{
670 + int err;
671 +
672 + mutex_lock(&data->open_mutex);
673 + err = __vhci_create_device(data, opcode);
674 + mutex_unlock(&data->open_mutex);
675 +
676 + return err;
677 +}
678 +
679 static inline ssize_t vhci_get_user(struct vhci_data *data,
680 struct iov_iter *from)
681 {
682 @@ -189,11 +204,6 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
683 break;
684
685 case HCI_VENDOR_PKT:
686 - if (data->hdev) {
687 - kfree_skb(skb);
688 - return -EBADFD;
689 - }
690 -
691 cancel_delayed_work_sync(&data->open_timeout);
692
693 opcode = *((__u8 *) skb->data);
694 @@ -320,6 +330,7 @@ static int vhci_open(struct inode *inode, struct file *file)
695 skb_queue_head_init(&data->readq);
696 init_waitqueue_head(&data->read_wait);
697
698 + mutex_init(&data->open_mutex);
699 INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
700
701 file->private_data = data;
702 @@ -333,15 +344,18 @@ static int vhci_open(struct inode *inode, struct file *file)
703 static int vhci_release(struct inode *inode, struct file *file)
704 {
705 struct vhci_data *data = file->private_data;
706 - struct hci_dev *hdev = data->hdev;
707 + struct hci_dev *hdev;
708
709 cancel_delayed_work_sync(&data->open_timeout);
710
711 + hdev = data->hdev;
712 +
713 if (hdev) {
714 hci_unregister_dev(hdev);
715 hci_free_dev(hdev);
716 }
717
718 + skb_queue_purge(&data->readq);
719 file->private_data = NULL;
720 kfree(data);
721
722 diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
723 index c74ed3fd496d..90338c38e38a 100644
724 --- a/drivers/clk/bcm/clk-bcm2835.c
725 +++ b/drivers/clk/bcm/clk-bcm2835.c
726 @@ -1079,10 +1079,12 @@ static void bcm2835_pll_divider_off(struct clk_hw *hw)
727 struct bcm2835_cprman *cprman = divider->cprman;
728 const struct bcm2835_pll_divider_data *data = divider->data;
729
730 + spin_lock(&cprman->regs_lock);
731 cprman_write(cprman, data->cm_reg,
732 (cprman_read(cprman, data->cm_reg) &
733 ~data->load_mask) | data->hold_mask);
734 cprman_write(cprman, data->a2w_reg, A2W_PLL_CHANNEL_DISABLE);
735 + spin_unlock(&cprman->regs_lock);
736 }
737
738 static int bcm2835_pll_divider_on(struct clk_hw *hw)
739 @@ -1091,12 +1093,14 @@ static int bcm2835_pll_divider_on(struct clk_hw *hw)
740 struct bcm2835_cprman *cprman = divider->cprman;
741 const struct bcm2835_pll_divider_data *data = divider->data;
742
743 + spin_lock(&cprman->regs_lock);
744 cprman_write(cprman, data->a2w_reg,
745 cprman_read(cprman, data->a2w_reg) &
746 ~A2W_PLL_CHANNEL_DISABLE);
747
748 cprman_write(cprman, data->cm_reg,
749 cprman_read(cprman, data->cm_reg) & ~data->hold_mask);
750 + spin_unlock(&cprman->regs_lock);
751
752 return 0;
753 }
754 diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c
755 index 9c29080a84d8..5c4e193164d4 100644
756 --- a/drivers/clk/qcom/gcc-msm8916.c
757 +++ b/drivers/clk/qcom/gcc-msm8916.c
758 @@ -2346,6 +2346,7 @@ static struct clk_branch gcc_crypto_ahb_clk = {
759 "pcnoc_bfdcd_clk_src",
760 },
761 .num_parents = 1,
762 + .flags = CLK_SET_RATE_PARENT,
763 .ops = &clk_branch2_ops,
764 },
765 },
766 @@ -2381,6 +2382,7 @@ static struct clk_branch gcc_crypto_clk = {
767 "crypto_clk_src",
768 },
769 .num_parents = 1,
770 + .flags = CLK_SET_RATE_PARENT,
771 .ops = &clk_branch2_ops,
772 },
773 },
774 diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
775 index 6fd63a600614..5ef4be22eb80 100644
776 --- a/drivers/crypto/caam/jr.c
777 +++ b/drivers/crypto/caam/jr.c
778 @@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg)
779 struct device *caam_jr_alloc(void)
780 {
781 struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL;
782 - struct device *dev = NULL;
783 + struct device *dev = ERR_PTR(-ENODEV);
784 int min_tfm_cnt = INT_MAX;
785 int tfm_cnt;
786
787 diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
788 index 7be3fbcd8d78..3830d7c4e138 100644
789 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
790 +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
791 @@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
792 unsigned int todo;
793 struct sg_mapping_iter mi, mo;
794 unsigned int oi, oo; /* offset for in and out */
795 + unsigned long flags;
796
797 if (areq->nbytes == 0)
798 return 0;
799 @@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
800 return -EINVAL;
801 }
802
803 - spin_lock_bh(&ss->slock);
804 + spin_lock_irqsave(&ss->slock, flags);
805
806 for (i = 0; i < op->keylen; i += 4)
807 writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
808 @@ -117,7 +118,7 @@ release_ss:
809 sg_miter_stop(&mi);
810 sg_miter_stop(&mo);
811 writel(0, ss->base + SS_CTL);
812 - spin_unlock_bh(&ss->slock);
813 + spin_unlock_irqrestore(&ss->slock, flags);
814 return err;
815 }
816
817 @@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
818 unsigned int ob = 0; /* offset in buf */
819 unsigned int obo = 0; /* offset in bufo*/
820 unsigned int obl = 0; /* length of data in bufo */
821 + unsigned long flags;
822
823 if (areq->nbytes == 0)
824 return 0;
825 @@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
826 if (no_chunk == 1)
827 return sun4i_ss_opti_poll(areq);
828
829 - spin_lock_bh(&ss->slock);
830 + spin_lock_irqsave(&ss->slock, flags);
831
832 for (i = 0; i < op->keylen; i += 4)
833 writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
834 @@ -307,7 +309,7 @@ release_ss:
835 sg_miter_stop(&mi);
836 sg_miter_stop(&mo);
837 writel(0, ss->base + SS_CTL);
838 - spin_unlock_bh(&ss->slock);
839 + spin_unlock_irqrestore(&ss->slock, flags);
840
841 return err;
842 }
843 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
844 index aae05547b924..b7ee8d30147d 100644
845 --- a/drivers/crypto/talitos.c
846 +++ b/drivers/crypto/talitos.c
847 @@ -835,6 +835,16 @@ struct talitos_ahash_req_ctx {
848 struct scatterlist *psrc;
849 };
850
851 +struct talitos_export_state {
852 + u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
853 + u8 buf[HASH_MAX_BLOCK_SIZE];
854 + unsigned int swinit;
855 + unsigned int first;
856 + unsigned int last;
857 + unsigned int to_hash_later;
858 + unsigned int nbuf;
859 +};
860 +
861 static int aead_setkey(struct crypto_aead *authenc,
862 const u8 *key, unsigned int keylen)
863 {
864 @@ -1981,6 +1991,46 @@ static int ahash_digest(struct ahash_request *areq)
865 return ahash_process_req(areq, areq->nbytes);
866 }
867
868 +static int ahash_export(struct ahash_request *areq, void *out)
869 +{
870 + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
871 + struct talitos_export_state *export = out;
872 +
873 + memcpy(export->hw_context, req_ctx->hw_context,
874 + req_ctx->hw_context_size);
875 + memcpy(export->buf, req_ctx->buf, req_ctx->nbuf);
876 + export->swinit = req_ctx->swinit;
877 + export->first = req_ctx->first;
878 + export->last = req_ctx->last;
879 + export->to_hash_later = req_ctx->to_hash_later;
880 + export->nbuf = req_ctx->nbuf;
881 +
882 + return 0;
883 +}
884 +
885 +static int ahash_import(struct ahash_request *areq, const void *in)
886 +{
887 + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
888 + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
889 + const struct talitos_export_state *export = in;
890 +
891 + memset(req_ctx, 0, sizeof(*req_ctx));
892 + req_ctx->hw_context_size =
893 + (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE)
894 + ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256
895 + : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512;
896 + memcpy(req_ctx->hw_context, export->hw_context,
897 + req_ctx->hw_context_size);
898 + memcpy(req_ctx->buf, export->buf, export->nbuf);
899 + req_ctx->swinit = export->swinit;
900 + req_ctx->first = export->first;
901 + req_ctx->last = export->last;
902 + req_ctx->to_hash_later = export->to_hash_later;
903 + req_ctx->nbuf = export->nbuf;
904 +
905 + return 0;
906 +}
907 +
908 struct keyhash_result {
909 struct completion completion;
910 int err;
911 @@ -2458,6 +2508,7 @@ static struct talitos_alg_template driver_algs[] = {
912 { .type = CRYPTO_ALG_TYPE_AHASH,
913 .alg.hash = {
914 .halg.digestsize = MD5_DIGEST_SIZE,
915 + .halg.statesize = sizeof(struct talitos_export_state),
916 .halg.base = {
917 .cra_name = "md5",
918 .cra_driver_name = "md5-talitos",
919 @@ -2473,6 +2524,7 @@ static struct talitos_alg_template driver_algs[] = {
920 { .type = CRYPTO_ALG_TYPE_AHASH,
921 .alg.hash = {
922 .halg.digestsize = SHA1_DIGEST_SIZE,
923 + .halg.statesize = sizeof(struct talitos_export_state),
924 .halg.base = {
925 .cra_name = "sha1",
926 .cra_driver_name = "sha1-talitos",
927 @@ -2488,6 +2540,7 @@ static struct talitos_alg_template driver_algs[] = {
928 { .type = CRYPTO_ALG_TYPE_AHASH,
929 .alg.hash = {
930 .halg.digestsize = SHA224_DIGEST_SIZE,
931 + .halg.statesize = sizeof(struct talitos_export_state),
932 .halg.base = {
933 .cra_name = "sha224",
934 .cra_driver_name = "sha224-talitos",
935 @@ -2503,6 +2556,7 @@ static struct talitos_alg_template driver_algs[] = {
936 { .type = CRYPTO_ALG_TYPE_AHASH,
937 .alg.hash = {
938 .halg.digestsize = SHA256_DIGEST_SIZE,
939 + .halg.statesize = sizeof(struct talitos_export_state),
940 .halg.base = {
941 .cra_name = "sha256",
942 .cra_driver_name = "sha256-talitos",
943 @@ -2518,6 +2572,7 @@ static struct talitos_alg_template driver_algs[] = {
944 { .type = CRYPTO_ALG_TYPE_AHASH,
945 .alg.hash = {
946 .halg.digestsize = SHA384_DIGEST_SIZE,
947 + .halg.statesize = sizeof(struct talitos_export_state),
948 .halg.base = {
949 .cra_name = "sha384",
950 .cra_driver_name = "sha384-talitos",
951 @@ -2533,6 +2588,7 @@ static struct talitos_alg_template driver_algs[] = {
952 { .type = CRYPTO_ALG_TYPE_AHASH,
953 .alg.hash = {
954 .halg.digestsize = SHA512_DIGEST_SIZE,
955 + .halg.statesize = sizeof(struct talitos_export_state),
956 .halg.base = {
957 .cra_name = "sha512",
958 .cra_driver_name = "sha512-talitos",
959 @@ -2548,6 +2604,7 @@ static struct talitos_alg_template driver_algs[] = {
960 { .type = CRYPTO_ALG_TYPE_AHASH,
961 .alg.hash = {
962 .halg.digestsize = MD5_DIGEST_SIZE,
963 + .halg.statesize = sizeof(struct talitos_export_state),
964 .halg.base = {
965 .cra_name = "hmac(md5)",
966 .cra_driver_name = "hmac-md5-talitos",
967 @@ -2563,6 +2620,7 @@ static struct talitos_alg_template driver_algs[] = {
968 { .type = CRYPTO_ALG_TYPE_AHASH,
969 .alg.hash = {
970 .halg.digestsize = SHA1_DIGEST_SIZE,
971 + .halg.statesize = sizeof(struct talitos_export_state),
972 .halg.base = {
973 .cra_name = "hmac(sha1)",
974 .cra_driver_name = "hmac-sha1-talitos",
975 @@ -2578,6 +2636,7 @@ static struct talitos_alg_template driver_algs[] = {
976 { .type = CRYPTO_ALG_TYPE_AHASH,
977 .alg.hash = {
978 .halg.digestsize = SHA224_DIGEST_SIZE,
979 + .halg.statesize = sizeof(struct talitos_export_state),
980 .halg.base = {
981 .cra_name = "hmac(sha224)",
982 .cra_driver_name = "hmac-sha224-talitos",
983 @@ -2593,6 +2652,7 @@ static struct talitos_alg_template driver_algs[] = {
984 { .type = CRYPTO_ALG_TYPE_AHASH,
985 .alg.hash = {
986 .halg.digestsize = SHA256_DIGEST_SIZE,
987 + .halg.statesize = sizeof(struct talitos_export_state),
988 .halg.base = {
989 .cra_name = "hmac(sha256)",
990 .cra_driver_name = "hmac-sha256-talitos",
991 @@ -2608,6 +2668,7 @@ static struct talitos_alg_template driver_algs[] = {
992 { .type = CRYPTO_ALG_TYPE_AHASH,
993 .alg.hash = {
994 .halg.digestsize = SHA384_DIGEST_SIZE,
995 + .halg.statesize = sizeof(struct talitos_export_state),
996 .halg.base = {
997 .cra_name = "hmac(sha384)",
998 .cra_driver_name = "hmac-sha384-talitos",
999 @@ -2623,6 +2684,7 @@ static struct talitos_alg_template driver_algs[] = {
1000 { .type = CRYPTO_ALG_TYPE_AHASH,
1001 .alg.hash = {
1002 .halg.digestsize = SHA512_DIGEST_SIZE,
1003 + .halg.statesize = sizeof(struct talitos_export_state),
1004 .halg.base = {
1005 .cra_name = "hmac(sha512)",
1006 .cra_driver_name = "hmac-sha512-talitos",
1007 @@ -2814,6 +2876,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
1008 t_alg->algt.alg.hash.finup = ahash_finup;
1009 t_alg->algt.alg.hash.digest = ahash_digest;
1010 t_alg->algt.alg.hash.setkey = ahash_setkey;
1011 + t_alg->algt.alg.hash.import = ahash_import;
1012 + t_alg->algt.alg.hash.export = ahash_export;
1013
1014 if (!(priv->features & TALITOS_FTR_HMAC_OK) &&
1015 !strncmp(alg->cra_name, "hmac", 4)) {
1016 diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
1017 index b6bf20496021..845ce90c2885 100644
1018 --- a/drivers/infiniband/ulp/srp/ib_srp.c
1019 +++ b/drivers/infiniband/ulp/srp/ib_srp.c
1020 @@ -448,16 +448,16 @@ static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target)
1021
1022 /**
1023 * srp_destroy_qp() - destroy an RDMA queue pair
1024 - * @ch: SRP RDMA channel.
1025 + * @qp: RDMA queue pair.
1026 *
1027 * Drain the qp before destroying it. This avoids that the receive
1028 * completion handler can access the queue pair while it is
1029 * being destroyed.
1030 */
1031 -static void srp_destroy_qp(struct srp_rdma_ch *ch)
1032 +static void srp_destroy_qp(struct ib_qp *qp)
1033 {
1034 - ib_drain_rq(ch->qp);
1035 - ib_destroy_qp(ch->qp);
1036 + ib_drain_rq(qp);
1037 + ib_destroy_qp(qp);
1038 }
1039
1040 static int srp_create_ch_ib(struct srp_rdma_ch *ch)
1041 @@ -530,7 +530,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
1042 }
1043
1044 if (ch->qp)
1045 - srp_destroy_qp(ch);
1046 + srp_destroy_qp(ch->qp);
1047 if (ch->recv_cq)
1048 ib_free_cq(ch->recv_cq);
1049 if (ch->send_cq)
1050 @@ -554,7 +554,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
1051 return 0;
1052
1053 err_qp:
1054 - srp_destroy_qp(ch);
1055 + srp_destroy_qp(qp);
1056
1057 err_send_cq:
1058 ib_free_cq(send_cq);
1059 @@ -597,7 +597,7 @@ static void srp_free_ch_ib(struct srp_target_port *target,
1060 ib_destroy_fmr_pool(ch->fmr_pool);
1061 }
1062
1063 - srp_destroy_qp(ch);
1064 + srp_destroy_qp(ch->qp);
1065 ib_free_cq(ch->send_cq);
1066 ib_free_cq(ch->recv_cq);
1067
1068 @@ -1509,7 +1509,7 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
1069
1070 if (dev->use_fast_reg) {
1071 state.sg = idb_sg;
1072 - sg_set_buf(idb_sg, req->indirect_desc, idb_len);
1073 + sg_init_one(idb_sg, req->indirect_desc, idb_len);
1074 idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
1075 #ifdef CONFIG_NEED_SG_DMA_LENGTH
1076 idb_sg->dma_length = idb_sg->length; /* hack^2 */
1077 diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
1078 index f2261ab54701..18663d4edae5 100644
1079 --- a/drivers/input/misc/pwm-beeper.c
1080 +++ b/drivers/input/misc/pwm-beeper.c
1081 @@ -20,21 +20,40 @@
1082 #include <linux/platform_device.h>
1083 #include <linux/pwm.h>
1084 #include <linux/slab.h>
1085 +#include <linux/workqueue.h>
1086
1087 struct pwm_beeper {
1088 struct input_dev *input;
1089 struct pwm_device *pwm;
1090 + struct work_struct work;
1091 unsigned long period;
1092 };
1093
1094 #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x))
1095
1096 +static void __pwm_beeper_set(struct pwm_beeper *beeper)
1097 +{
1098 + unsigned long period = beeper->period;
1099 +
1100 + if (period) {
1101 + pwm_config(beeper->pwm, period / 2, period);
1102 + pwm_enable(beeper->pwm);
1103 + } else
1104 + pwm_disable(beeper->pwm);
1105 +}
1106 +
1107 +static void pwm_beeper_work(struct work_struct *work)
1108 +{
1109 + struct pwm_beeper *beeper =
1110 + container_of(work, struct pwm_beeper, work);
1111 +
1112 + __pwm_beeper_set(beeper);
1113 +}
1114 +
1115 static int pwm_beeper_event(struct input_dev *input,
1116 unsigned int type, unsigned int code, int value)
1117 {
1118 - int ret = 0;
1119 struct pwm_beeper *beeper = input_get_drvdata(input);
1120 - unsigned long period;
1121
1122 if (type != EV_SND || value < 0)
1123 return -EINVAL;
1124 @@ -49,22 +68,31 @@ static int pwm_beeper_event(struct input_dev *input,
1125 return -EINVAL;
1126 }
1127
1128 - if (value == 0) {
1129 - pwm_disable(beeper->pwm);
1130 - } else {
1131 - period = HZ_TO_NANOSECONDS(value);
1132 - ret = pwm_config(beeper->pwm, period / 2, period);
1133 - if (ret)
1134 - return ret;
1135 - ret = pwm_enable(beeper->pwm);
1136 - if (ret)
1137 - return ret;
1138 - beeper->period = period;
1139 - }
1140 + if (value == 0)
1141 + beeper->period = 0;
1142 + else
1143 + beeper->period = HZ_TO_NANOSECONDS(value);
1144 +
1145 + schedule_work(&beeper->work);
1146
1147 return 0;
1148 }
1149
1150 +static void pwm_beeper_stop(struct pwm_beeper *beeper)
1151 +{
1152 + cancel_work_sync(&beeper->work);
1153 +
1154 + if (beeper->period)
1155 + pwm_disable(beeper->pwm);
1156 +}
1157 +
1158 +static void pwm_beeper_close(struct input_dev *input)
1159 +{
1160 + struct pwm_beeper *beeper = input_get_drvdata(input);
1161 +
1162 + pwm_beeper_stop(beeper);
1163 +}
1164 +
1165 static int pwm_beeper_probe(struct platform_device *pdev)
1166 {
1167 unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev);
1168 @@ -87,6 +115,8 @@ static int pwm_beeper_probe(struct platform_device *pdev)
1169 goto err_free;
1170 }
1171
1172 + INIT_WORK(&beeper->work, pwm_beeper_work);
1173 +
1174 beeper->input = input_allocate_device();
1175 if (!beeper->input) {
1176 dev_err(&pdev->dev, "Failed to allocate input device\n");
1177 @@ -106,6 +136,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
1178 beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL);
1179
1180 beeper->input->event = pwm_beeper_event;
1181 + beeper->input->close = pwm_beeper_close;
1182
1183 input_set_drvdata(beeper->input, beeper);
1184
1185 @@ -135,7 +166,6 @@ static int pwm_beeper_remove(struct platform_device *pdev)
1186
1187 input_unregister_device(beeper->input);
1188
1189 - pwm_disable(beeper->pwm);
1190 pwm_free(beeper->pwm);
1191
1192 kfree(beeper);
1193 @@ -147,8 +177,7 @@ static int __maybe_unused pwm_beeper_suspend(struct device *dev)
1194 {
1195 struct pwm_beeper *beeper = dev_get_drvdata(dev);
1196
1197 - if (beeper->period)
1198 - pwm_disable(beeper->pwm);
1199 + pwm_beeper_stop(beeper);
1200
1201 return 0;
1202 }
1203 @@ -157,10 +186,8 @@ static int __maybe_unused pwm_beeper_resume(struct device *dev)
1204 {
1205 struct pwm_beeper *beeper = dev_get_drvdata(dev);
1206
1207 - if (beeper->period) {
1208 - pwm_config(beeper->pwm, beeper->period / 2, beeper->period);
1209 - pwm_enable(beeper->pwm);
1210 - }
1211 + if (beeper->period)
1212 + __pwm_beeper_set(beeper);
1213
1214 return 0;
1215 }
1216 diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
1217 index 5b7d3c2129d8..390e0ece26dc 100644
1218 --- a/drivers/irqchip/irq-gic-v3.c
1219 +++ b/drivers/irqchip/irq-gic-v3.c
1220 @@ -364,6 +364,13 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
1221 if (static_key_true(&supports_deactivate))
1222 gic_write_dir(irqnr);
1223 #ifdef CONFIG_SMP
1224 + /*
1225 + * Unlike GICv2, we don't need an smp_rmb() here.
1226 + * The control dependency from gic_read_iar to
1227 + * the ISB in gic_write_eoir is enough to ensure
1228 + * that any shared data read by handle_IPI will
1229 + * be read after the ACK.
1230 + */
1231 handle_IPI(irqnr, regs);
1232 #else
1233 WARN_ONCE(true, "Unexpected SGI received!\n");
1234 @@ -383,6 +390,15 @@ static void __init gic_dist_init(void)
1235 writel_relaxed(0, base + GICD_CTLR);
1236 gic_dist_wait_for_rwp();
1237
1238 + /*
1239 + * Configure SPIs as non-secure Group-1. This will only matter
1240 + * if the GIC only has a single security state. This will not
1241 + * do the right thing if the kernel is running in secure mode,
1242 + * but that's not the intended use case anyway.
1243 + */
1244 + for (i = 32; i < gic_data.irq_nr; i += 32)
1245 + writel_relaxed(~0, base + GICD_IGROUPR + i / 8);
1246 +
1247 gic_dist_config(base, gic_data.irq_nr, gic_dist_wait_for_rwp);
1248
1249 /* Enable distributor with ARE, Group1 */
1250 @@ -500,6 +516,9 @@ static void gic_cpu_init(void)
1251
1252 rbase = gic_data_rdist_sgi_base();
1253
1254 + /* Configure SGIs/PPIs as non-secure Group-1 */
1255 + writel_relaxed(~0, rbase + GICR_IGROUPR0);
1256 +
1257 gic_cpu_config(rbase, gic_redist_wait_for_rwp);
1258
1259 /* Give LPIs a spin */
1260 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
1261 index 282344b95ec2..5c4da5808b15 100644
1262 --- a/drivers/irqchip/irq-gic.c
1263 +++ b/drivers/irqchip/irq-gic.c
1264 @@ -344,6 +344,14 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
1265 if (static_key_true(&supports_deactivate))
1266 writel_relaxed(irqstat, cpu_base + GIC_CPU_DEACTIVATE);
1267 #ifdef CONFIG_SMP
1268 + /*
1269 + * Ensure any shared data written by the CPU sending
1270 + * the IPI is read after we've read the ACK register
1271 + * on the GIC.
1272 + *
1273 + * Pairs with the write barrier in gic_raise_softirq
1274 + */
1275 + smp_rmb();
1276 handle_IPI(irqnr, regs);
1277 #endif
1278 continue;
1279 diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
1280 index 004926955263..b0155b05cddb 100644
1281 --- a/drivers/mcb/mcb-parse.c
1282 +++ b/drivers/mcb/mcb-parse.c
1283 @@ -57,7 +57,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
1284 mdev->id = GDD_DEV(reg1);
1285 mdev->rev = GDD_REV(reg1);
1286 mdev->var = GDD_VAR(reg1);
1287 - mdev->bar = GDD_BAR(reg1);
1288 + mdev->bar = GDD_BAR(reg2);
1289 mdev->group = GDD_GRP(reg2);
1290 mdev->inst = GDD_INS(reg2);
1291
1292 diff --git a/drivers/md/md.c b/drivers/md/md.c
1293 index 14d3b37944df..85b16aadd459 100644
1294 --- a/drivers/md/md.c
1295 +++ b/drivers/md/md.c
1296 @@ -307,7 +307,7 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
1297 */
1298 void mddev_suspend(struct mddev *mddev)
1299 {
1300 - WARN_ON_ONCE(current == mddev->thread->tsk);
1301 + WARN_ON_ONCE(mddev->thread && current == mddev->thread->tsk);
1302 if (mddev->suspended++)
1303 return;
1304 synchronize_rcu();
1305 diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
1306 index b7b3e8ee64f2..c30290f33430 100644
1307 --- a/drivers/mfd/omap-usb-tll.c
1308 +++ b/drivers/mfd/omap-usb-tll.c
1309 @@ -269,6 +269,8 @@ static int usbtll_omap_probe(struct platform_device *pdev)
1310
1311 if (IS_ERR(tll->ch_clk[i]))
1312 dev_dbg(dev, "can't get clock : %s\n", clkname);
1313 + else
1314 + clk_prepare(tll->ch_clk[i]);
1315 }
1316
1317 pm_runtime_put_sync(dev);
1318 @@ -301,9 +303,12 @@ static int usbtll_omap_remove(struct platform_device *pdev)
1319 tll_dev = NULL;
1320 spin_unlock(&tll_lock);
1321
1322 - for (i = 0; i < tll->nch; i++)
1323 - if (!IS_ERR(tll->ch_clk[i]))
1324 + for (i = 0; i < tll->nch; i++) {
1325 + if (!IS_ERR(tll->ch_clk[i])) {
1326 + clk_unprepare(tll->ch_clk[i]);
1327 clk_put(tll->ch_clk[i]);
1328 + }
1329 + }
1330
1331 pm_runtime_disable(&pdev->dev);
1332 return 0;
1333 @@ -420,7 +425,7 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
1334 if (IS_ERR(tll->ch_clk[i]))
1335 continue;
1336
1337 - r = clk_prepare_enable(tll->ch_clk[i]);
1338 + r = clk_enable(tll->ch_clk[i]);
1339 if (r) {
1340 dev_err(tll_dev,
1341 "Error enabling ch %d clock: %d\n", i, r);
1342 @@ -448,7 +453,7 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata)
1343 for (i = 0; i < tll->nch; i++) {
1344 if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
1345 if (!IS_ERR(tll->ch_clk[i]))
1346 - clk_disable_unprepare(tll->ch_clk[i]);
1347 + clk_disable(tll->ch_clk[i]);
1348 }
1349 }
1350
1351 diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
1352 index 194360a5f782..a039a5df6f21 100644
1353 --- a/drivers/misc/mei/amthif.c
1354 +++ b/drivers/misc/mei/amthif.c
1355 @@ -380,8 +380,10 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
1356
1357 dev = cl->dev;
1358
1359 - if (dev->iamthif_state != MEI_IAMTHIF_READING)
1360 + if (dev->iamthif_state != MEI_IAMTHIF_READING) {
1361 + mei_irq_discard_msg(dev, mei_hdr);
1362 return 0;
1363 + }
1364
1365 ret = mei_cl_irq_read_msg(cl, mei_hdr, cmpl_list);
1366 if (ret)
1367 diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
1368 index 5d5996e39a67..038b6dd24fb4 100644
1369 --- a/drivers/misc/mei/bus.c
1370 +++ b/drivers/misc/mei/bus.c
1371 @@ -220,17 +220,23 @@ EXPORT_SYMBOL_GPL(mei_cldev_recv);
1372 static void mei_cl_bus_event_work(struct work_struct *work)
1373 {
1374 struct mei_cl_device *cldev;
1375 + struct mei_device *bus;
1376
1377 cldev = container_of(work, struct mei_cl_device, event_work);
1378
1379 + bus = cldev->bus;
1380 +
1381 if (cldev->event_cb)
1382 cldev->event_cb(cldev, cldev->events, cldev->event_context);
1383
1384 cldev->events = 0;
1385
1386 /* Prepare for the next read */
1387 - if (cldev->events_mask & BIT(MEI_CL_EVENT_RX))
1388 + if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
1389 + mutex_lock(&bus->device_lock);
1390 mei_cl_read_start(cldev->cl, 0, NULL);
1391 + mutex_unlock(&bus->device_lock);
1392 + }
1393 }
1394
1395 /**
1396 @@ -304,6 +310,7 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
1397 unsigned long events_mask,
1398 mei_cldev_event_cb_t event_cb, void *context)
1399 {
1400 + struct mei_device *bus = cldev->bus;
1401 int ret;
1402
1403 if (cldev->event_cb)
1404 @@ -316,15 +323,17 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
1405 INIT_WORK(&cldev->event_work, mei_cl_bus_event_work);
1406
1407 if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
1408 + mutex_lock(&bus->device_lock);
1409 ret = mei_cl_read_start(cldev->cl, 0, NULL);
1410 + mutex_unlock(&bus->device_lock);
1411 if (ret && ret != -EBUSY)
1412 return ret;
1413 }
1414
1415 if (cldev->events_mask & BIT(MEI_CL_EVENT_NOTIF)) {
1416 - mutex_lock(&cldev->cl->dev->device_lock);
1417 + mutex_lock(&bus->device_lock);
1418 ret = mei_cl_notify_request(cldev->cl, NULL, event_cb ? 1 : 0);
1419 - mutex_unlock(&cldev->cl->dev->device_lock);
1420 + mutex_unlock(&bus->device_lock);
1421 if (ret)
1422 return ret;
1423 }
1424 diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
1425 index bab17e4197b6..09f5280fa021 100644
1426 --- a/drivers/misc/mei/client.c
1427 +++ b/drivers/misc/mei/client.c
1428 @@ -1767,6 +1767,10 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
1429 wake_up(&cl->wait);
1430
1431 break;
1432 + case MEI_FOP_DISCONNECT_RSP:
1433 + mei_io_cb_free(cb);
1434 + mei_cl_set_disconnected(cl);
1435 + break;
1436 default:
1437 BUG_ON(0);
1438 }
1439 diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
1440 index 5e305d2605f3..8fe1ef8215c1 100644
1441 --- a/drivers/misc/mei/hbm.c
1442 +++ b/drivers/misc/mei/hbm.c
1443 @@ -882,8 +882,7 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
1444 cb = mei_io_cb_init(cl, MEI_FOP_DISCONNECT_RSP, NULL);
1445 if (!cb)
1446 return -ENOMEM;
1447 - cl_dbg(dev, cl, "add disconnect response as first\n");
1448 - list_add(&cb->list, &dev->ctrl_wr_list.list);
1449 + list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
1450 }
1451 return 0;
1452 }
1453 diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
1454 index 1e5cb1f704f8..3831a7ba2531 100644
1455 --- a/drivers/misc/mei/interrupt.c
1456 +++ b/drivers/misc/mei/interrupt.c
1457 @@ -76,7 +76,6 @@ static inline int mei_cl_hbm_equal(struct mei_cl *cl,
1458 * @dev: mei device
1459 * @hdr: message header
1460 */
1461 -static inline
1462 void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr)
1463 {
1464 /*
1465 @@ -194,10 +193,7 @@ static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
1466 return -EMSGSIZE;
1467
1468 ret = mei_hbm_cl_disconnect_rsp(dev, cl);
1469 - mei_cl_set_disconnected(cl);
1470 - mei_io_cb_free(cb);
1471 - mei_me_cl_put(cl->me_cl);
1472 - cl->me_cl = NULL;
1473 + list_move_tail(&cb->list, &cmpl_list->list);
1474
1475 return ret;
1476 }
1477 diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
1478 index db78e6d99456..859bdac22352 100644
1479 --- a/drivers/misc/mei/mei_dev.h
1480 +++ b/drivers/misc/mei/mei_dev.h
1481 @@ -704,6 +704,8 @@ bool mei_hbuf_acquire(struct mei_device *dev);
1482
1483 bool mei_write_is_idle(struct mei_device *dev);
1484
1485 +void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr);
1486 +
1487 #if IS_ENABLED(CONFIG_DEBUG_FS)
1488 int mei_dbgfs_register(struct mei_device *dev, const char *name);
1489 void mei_dbgfs_deregister(struct mei_device *dev);
1490 diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
1491 index 88e45234d527..af57d2caac75 100644
1492 --- a/drivers/misc/mic/vop/vop_vringh.c
1493 +++ b/drivers/misc/mic/vop/vop_vringh.c
1494 @@ -950,6 +950,11 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
1495 ret = -EINVAL;
1496 goto free_ret;
1497 }
1498 + /* Ensure desc has not changed between the two reads */
1499 + if (memcmp(&dd, dd_config, sizeof(dd))) {
1500 + ret = -EINVAL;
1501 + goto free_ret;
1502 + }
1503 mutex_lock(&vdev->vdev_mutex);
1504 mutex_lock(&vi->vop_mutex);
1505 ret = vop_virtio_add_device(vdev, dd_config);
1506 diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
1507 index 8a0147dfed27..b0a27413cb13 100644
1508 --- a/drivers/mmc/card/block.c
1509 +++ b/drivers/mmc/card/block.c
1510 @@ -2494,11 +2494,12 @@ static const struct mmc_fixup blk_fixups[] =
1511 MMC_QUIRK_BLK_NO_CMD23),
1512
1513 /*
1514 - * Some Micron MMC cards needs longer data read timeout than
1515 - * indicated in CSD.
1516 + * Some MMC cards need longer data read timeout than indicated in CSD.
1517 */
1518 MMC_FIXUP(CID_NAME_ANY, CID_MANFID_MICRON, 0x200, add_quirk_mmc,
1519 MMC_QUIRK_LONG_READ_TIME),
1520 + MMC_FIXUP("008GE0", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
1521 + MMC_QUIRK_LONG_READ_TIME),
1522
1523 /*
1524 * On these Samsung MoviNAND parts, performing secure erase or
1525 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1526 index 41b1e761965f..9eba56c68ca1 100644
1527 --- a/drivers/mmc/core/core.c
1528 +++ b/drivers/mmc/core/core.c
1529 @@ -868,11 +868,11 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
1530 /*
1531 * Some cards require longer data read timeout than indicated in CSD.
1532 * Address this by setting the read timeout to a "reasonably high"
1533 - * value. For the cards tested, 300ms has proven enough. If necessary,
1534 + * value. For the cards tested, 600ms has proven enough. If necessary,
1535 * this value can be increased if other problematic cards require this.
1536 */
1537 if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
1538 - data->timeout_ns = 300000000;
1539 + data->timeout_ns = 600000000;
1540 data->timeout_clks = 0;
1541 }
1542
1543 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1544 index 4dbe3df8024b..80169643d59f 100644
1545 --- a/drivers/mmc/core/mmc.c
1546 +++ b/drivers/mmc/core/mmc.c
1547 @@ -333,6 +333,9 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
1548 }
1549 }
1550
1551 +/* Minimum partition switch timeout in milliseconds */
1552 +#define MMC_MIN_PART_SWITCH_TIME 300
1553 +
1554 /*
1555 * Decode extended CSD.
1556 */
1557 @@ -397,6 +400,10 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
1558
1559 /* EXT_CSD value is in units of 10ms, but we store in ms */
1560 card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
1561 + /* Some eMMC set the value too low so set a minimum */
1562 + if (card->ext_csd.part_time &&
1563 + card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
1564 + card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
1565
1566 /* Sleep / awake timeout in 100ns units */
1567 if (sa_shift > 0 && sa_shift <= 0x17)
1568 diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
1569 index bed6a494f52c..c0e206d72153 100644
1570 --- a/drivers/mmc/host/sdhci-acpi.c
1571 +++ b/drivers/mmc/host/sdhci-acpi.c
1572 @@ -277,7 +277,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
1573 .chip = &sdhci_acpi_chip_int,
1574 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
1575 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
1576 - MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1577 + MMC_CAP_WAIT_WHILE_BUSY,
1578 .caps2 = MMC_CAP2_HC_ERASE_SZ,
1579 .flags = SDHCI_ACPI_RUNTIME_PM,
1580 .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1581 @@ -292,7 +292,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
1582 SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1583 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
1584 .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD |
1585 - MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1586 + MMC_CAP_WAIT_WHILE_BUSY,
1587 .flags = SDHCI_ACPI_RUNTIME_PM,
1588 .pm_caps = MMC_PM_KEEP_POWER,
1589 .probe_slot = sdhci_acpi_sdio_probe_slot,
1590 @@ -304,7 +304,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
1591 .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1592 .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
1593 SDHCI_QUIRK2_STOP_WITH_TC,
1594 - .caps = MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_WAIT_WHILE_BUSY,
1595 + .caps = MMC_CAP_WAIT_WHILE_BUSY,
1596 .probe_slot = sdhci_acpi_sd_probe_slot,
1597 };
1598
1599 @@ -381,7 +381,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
1600 {
1601 struct device *dev = &pdev->dev;
1602 acpi_handle handle = ACPI_HANDLE(dev);
1603 - struct acpi_device *device;
1604 + struct acpi_device *device, *child;
1605 struct sdhci_acpi_host *c;
1606 struct sdhci_host *host;
1607 struct resource *iomem;
1608 @@ -393,6 +393,11 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
1609 if (acpi_bus_get_device(handle, &device))
1610 return -ENODEV;
1611
1612 + /* Power on the SDHCI controller and its children */
1613 + acpi_device_fix_up_power(device);
1614 + list_for_each_entry(child, &device->children, node)
1615 + acpi_device_fix_up_power(child);
1616 +
1617 if (acpi_bus_get_status(device) || !device->status.present)
1618 return -ENODEV;
1619
1620 diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
1621 index 79e19017343e..b42dd6a1b639 100644
1622 --- a/drivers/mmc/host/sdhci-pci-core.c
1623 +++ b/drivers/mmc/host/sdhci-pci-core.c
1624 @@ -361,7 +361,6 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
1625 {
1626 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
1627 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
1628 - MMC_CAP_BUS_WIDTH_TEST |
1629 MMC_CAP_WAIT_WHILE_BUSY;
1630 slot->host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ;
1631 slot->hw_reset = sdhci_pci_int_hw_reset;
1632 @@ -377,15 +376,13 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
1633 static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
1634 {
1635 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE |
1636 - MMC_CAP_BUS_WIDTH_TEST |
1637 MMC_CAP_WAIT_WHILE_BUSY;
1638 return 0;
1639 }
1640
1641 static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
1642 {
1643 - slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST |
1644 - MMC_CAP_WAIT_WHILE_BUSY;
1645 + slot->host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
1646 slot->cd_con_id = NULL;
1647 slot->cd_idx = 0;
1648 slot->cd_override_level = true;
1649 diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
1650 index 5b9834cf2820..96fddb016bf1 100644
1651 --- a/drivers/mtd/ubi/eba.c
1652 +++ b/drivers/mtd/ubi/eba.c
1653 @@ -426,8 +426,25 @@ retry:
1654 pnum, vol_id, lnum);
1655 err = -EBADMSG;
1656 } else {
1657 - err = -EINVAL;
1658 - ubi_ro_mode(ubi);
1659 + /*
1660 + * Ending up here in the non-Fastmap case
1661 + * is a clear bug as the VID header had to
1662 + * be present at scan time to have it referenced.
1663 + * With fastmap the story is more complicated.
1664 + * Fastmap has the mapping info without the need
1665 + * of a full scan. So the LEB could have been
1666 + * unmapped, Fastmap cannot know this and keeps
1667 + * the LEB referenced.
1668 + * This is valid and works as the layer above UBI
1669 + * has to do bookkeeping about used/referenced
1670 + * LEBs in any case.
1671 + */
1672 + if (ubi->fast_attach) {
1673 + err = -EBADMSG;
1674 + } else {
1675 + err = -EINVAL;
1676 + ubi_ro_mode(ubi);
1677 + }
1678 }
1679 }
1680 goto out_free;
1681 diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
1682 index 263b439e21a8..990898b9dc72 100644
1683 --- a/drivers/mtd/ubi/fastmap.c
1684 +++ b/drivers/mtd/ubi/fastmap.c
1685 @@ -1058,6 +1058,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
1686 ubi_msg(ubi, "fastmap WL pool size: %d",
1687 ubi->fm_wl_pool.max_size);
1688 ubi->fm_disabled = 0;
1689 + ubi->fast_attach = 1;
1690
1691 ubi_free_vid_hdr(ubi, vh);
1692 kfree(ech);
1693 diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
1694 index dadc6a9d5755..61d4e99755a4 100644
1695 --- a/drivers/mtd/ubi/ubi.h
1696 +++ b/drivers/mtd/ubi/ubi.h
1697 @@ -466,6 +466,7 @@ struct ubi_debug_info {
1698 * @fm_eba_sem: allows ubi_update_fastmap() to block EBA table changes
1699 * @fm_work: fastmap work queue
1700 * @fm_work_scheduled: non-zero if fastmap work was scheduled
1701 + * @fast_attach: non-zero if UBI was attached by fastmap
1702 *
1703 * @used: RB-tree of used physical eraseblocks
1704 * @erroneous: RB-tree of erroneous used physical eraseblocks
1705 @@ -574,6 +575,7 @@ struct ubi_device {
1706 size_t fm_size;
1707 struct work_struct fm_work;
1708 int fm_work_scheduled;
1709 + int fast_attach;
1710
1711 /* Wear-leveling sub-system's stuff */
1712 struct rb_root used;
1713 diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
1714 index 141c2a42d7ed..910c12e2638e 100644
1715 --- a/drivers/net/can/dev.c
1716 +++ b/drivers/net/can/dev.c
1717 @@ -696,11 +696,17 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
1718 /* allow change of MTU according to the CANFD ability of the device */
1719 switch (new_mtu) {
1720 case CAN_MTU:
1721 + /* 'CANFD-only' controllers can not switch to CAN_MTU */
1722 + if (priv->ctrlmode_static & CAN_CTRLMODE_FD)
1723 + return -EINVAL;
1724 +
1725 priv->ctrlmode &= ~CAN_CTRLMODE_FD;
1726 break;
1727
1728 case CANFD_MTU:
1729 - if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD))
1730 + /* check for potential CANFD ability */
1731 + if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) &&
1732 + !(priv->ctrlmode_static & CAN_CTRLMODE_FD))
1733 return -EINVAL;
1734
1735 priv->ctrlmode |= CAN_CTRLMODE_FD;
1736 @@ -782,6 +788,35 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
1737 = { .len = sizeof(struct can_bittiming_const) },
1738 };
1739
1740 +static int can_validate(struct nlattr *tb[], struct nlattr *data[])
1741 +{
1742 + bool is_can_fd = false;
1743 +
1744 + /* Make sure that valid CAN FD configurations always consist of
1745 + * - nominal/arbitration bittiming
1746 + * - data bittiming
1747 + * - control mode with CAN_CTRLMODE_FD set
1748 + */
1749 +
1750 + if (data[IFLA_CAN_CTRLMODE]) {
1751 + struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]);
1752 +
1753 + is_can_fd = cm->flags & cm->mask & CAN_CTRLMODE_FD;
1754 + }
1755 +
1756 + if (is_can_fd) {
1757 + if (!data[IFLA_CAN_BITTIMING] || !data[IFLA_CAN_DATA_BITTIMING])
1758 + return -EOPNOTSUPP;
1759 + }
1760 +
1761 + if (data[IFLA_CAN_DATA_BITTIMING]) {
1762 + if (!is_can_fd || !data[IFLA_CAN_BITTIMING])
1763 + return -EOPNOTSUPP;
1764 + }
1765 +
1766 + return 0;
1767 +}
1768 +
1769 static int can_changelink(struct net_device *dev,
1770 struct nlattr *tb[], struct nlattr *data[])
1771 {
1772 @@ -813,19 +848,31 @@ static int can_changelink(struct net_device *dev,
1773
1774 if (data[IFLA_CAN_CTRLMODE]) {
1775 struct can_ctrlmode *cm;
1776 + u32 ctrlstatic;
1777 + u32 maskedflags;
1778
1779 /* Do not allow changing controller mode while running */
1780 if (dev->flags & IFF_UP)
1781 return -EBUSY;
1782 cm = nla_data(data[IFLA_CAN_CTRLMODE]);
1783 + ctrlstatic = priv->ctrlmode_static;
1784 + maskedflags = cm->flags & cm->mask;
1785 +
1786 + /* check whether provided bits are allowed to be passed */
1787 + if (cm->mask & ~(priv->ctrlmode_supported | ctrlstatic))
1788 + return -EOPNOTSUPP;
1789 +
1790 + /* do not check for static fd-non-iso if 'fd' is disabled */
1791 + if (!(maskedflags & CAN_CTRLMODE_FD))
1792 + ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
1793
1794 - /* check whether changed bits are allowed to be modified */
1795 - if (cm->mask & ~priv->ctrlmode_supported)
1796 + /* make sure static options are provided by configuration */
1797 + if ((maskedflags & ctrlstatic) != ctrlstatic)
1798 return -EOPNOTSUPP;
1799
1800 /* clear bits to be modified and copy the flag values */
1801 priv->ctrlmode &= ~cm->mask;
1802 - priv->ctrlmode |= (cm->flags & cm->mask);
1803 + priv->ctrlmode |= maskedflags;
1804
1805 /* CAN_CTRLMODE_FD can only be set when driver supports FD */
1806 if (priv->ctrlmode & CAN_CTRLMODE_FD)
1807 @@ -966,6 +1013,7 @@ static struct rtnl_link_ops can_link_ops __read_mostly = {
1808 .maxtype = IFLA_CAN_MAX,
1809 .policy = can_policy,
1810 .setup = can_setup,
1811 + .validate = can_validate,
1812 .newlink = can_newlink,
1813 .changelink = can_changelink,
1814 .get_size = can_get_size,
1815 diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
1816 index 39cf911f7a1e..195f15edb32e 100644
1817 --- a/drivers/net/can/m_can/m_can.c
1818 +++ b/drivers/net/can/m_can/m_can.c
1819 @@ -955,7 +955,7 @@ static struct net_device *alloc_m_can_dev(void)
1820 priv->can.do_get_berr_counter = m_can_get_berr_counter;
1821
1822 /* CAN_CTRLMODE_FD_NON_ISO is fixed with M_CAN IP v3.0.1 */
1823 - priv->can.ctrlmode = CAN_CTRLMODE_FD_NON_ISO;
1824 + can_set_static_ctrlmode(dev, CAN_CTRLMODE_FD_NON_ISO);
1825
1826 /* CAN_CTRLMODE_FD_NON_ISO can not be changed with M_CAN IP v3.0.1 */
1827 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
1828 diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
1829 index 0c5c22b84da8..7de5ab589e4e 100644
1830 --- a/drivers/net/usb/asix_common.c
1831 +++ b/drivers/net/usb/asix_common.c
1832 @@ -66,7 +66,7 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
1833 * buffer.
1834 */
1835 if (rx->remaining && (rx->remaining + sizeof(u32) <= skb->len)) {
1836 - offset = ((rx->remaining + 1) & 0xfffe) + sizeof(u32);
1837 + offset = ((rx->remaining + 1) & 0xfffe);
1838 rx->header = get_unaligned_le32(skb->data + offset);
1839 offset = 0;
1840
1841 diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
1842 index 1f44a151d206..d5a099b022e4 100644
1843 --- a/drivers/nfc/st21nfca/i2c.c
1844 +++ b/drivers/nfc/st21nfca/i2c.c
1845 @@ -524,8 +524,10 @@ static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
1846 /* Get EN GPIO from ACPI */
1847 gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1,
1848 GPIOD_OUT_LOW);
1849 - if (!IS_ERR(gpiod_ena))
1850 - phy->gpio_ena = desc_to_gpio(gpiod_ena);
1851 + if (!IS_ERR(gpiod_ena)) {
1852 + nfc_err(dev, "Unable to get ENABLE GPIO\n");
1853 + return -ENODEV;
1854 + }
1855
1856 phy->gpio_ena = desc_to_gpio(gpiod_ena);
1857
1858 diff --git a/drivers/platform/x86/dell-rbtn.c b/drivers/platform/x86/dell-rbtn.c
1859 index b51a2008d782..dcd9f40a4b18 100644
1860 --- a/drivers/platform/x86/dell-rbtn.c
1861 +++ b/drivers/platform/x86/dell-rbtn.c
1862 @@ -28,6 +28,7 @@ struct rbtn_data {
1863 enum rbtn_type type;
1864 struct rfkill *rfkill;
1865 struct input_dev *input_dev;
1866 + bool suspended;
1867 };
1868
1869
1870 @@ -235,9 +236,55 @@ static const struct acpi_device_id rbtn_ids[] = {
1871 { "", 0 },
1872 };
1873
1874 +#ifdef CONFIG_PM_SLEEP
1875 +static void ACPI_SYSTEM_XFACE rbtn_clear_suspended_flag(void *context)
1876 +{
1877 + struct rbtn_data *rbtn_data = context;
1878 +
1879 + rbtn_data->suspended = false;
1880 +}
1881 +
1882 +static int rbtn_suspend(struct device *dev)
1883 +{
1884 + struct acpi_device *device = to_acpi_device(dev);
1885 + struct rbtn_data *rbtn_data = acpi_driver_data(device);
1886 +
1887 + rbtn_data->suspended = true;
1888 +
1889 + return 0;
1890 +}
1891 +
1892 +static int rbtn_resume(struct device *dev)
1893 +{
1894 + struct acpi_device *device = to_acpi_device(dev);
1895 + struct rbtn_data *rbtn_data = acpi_driver_data(device);
1896 + acpi_status status;
1897 +
1898 + /*
1899 + * Upon resume, some BIOSes send an ACPI notification thet triggers
1900 + * an unwanted input event. In order to ignore it, we use a flag
1901 + * that we set at suspend and clear once we have received the extra
1902 + * ACPI notification. Since ACPI notifications are delivered
1903 + * asynchronously to drivers, we clear the flag from the workqueue
1904 + * used to deliver the notifications. This should be enough
1905 + * to have the flag cleared only after we received the extra
1906 + * notification, if any.
1907 + */
1908 + status = acpi_os_execute(OSL_NOTIFY_HANDLER,
1909 + rbtn_clear_suspended_flag, rbtn_data);
1910 + if (ACPI_FAILURE(status))
1911 + rbtn_clear_suspended_flag(rbtn_data);
1912 +
1913 + return 0;
1914 +}
1915 +#endif
1916 +
1917 +static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume);
1918 +
1919 static struct acpi_driver rbtn_driver = {
1920 .name = "dell-rbtn",
1921 .ids = rbtn_ids,
1922 + .drv.pm = &rbtn_pm_ops,
1923 .ops = {
1924 .add = rbtn_add,
1925 .remove = rbtn_remove,
1926 @@ -399,6 +446,15 @@ static void rbtn_notify(struct acpi_device *device, u32 event)
1927 {
1928 struct rbtn_data *rbtn_data = device->driver_data;
1929
1930 + /*
1931 + * Some BIOSes send a notification at resume.
1932 + * Ignore it to prevent unwanted input events.
1933 + */
1934 + if (rbtn_data->suspended) {
1935 + dev_dbg(&device->dev, "ACPI notification ignored\n");
1936 + return;
1937 + }
1938 +
1939 if (event != 0x80) {
1940 dev_info(&device->dev, "Received unknown event (0x%x)\n",
1941 event);
1942 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
1943 index 97074c91e328..6b5811de6519 100644
1944 --- a/drivers/scsi/scsi_scan.c
1945 +++ b/drivers/scsi/scsi_scan.c
1946 @@ -316,6 +316,7 @@ static void scsi_target_destroy(struct scsi_target *starget)
1947 struct Scsi_Host *shost = dev_to_shost(dev->parent);
1948 unsigned long flags;
1949
1950 + BUG_ON(starget->state == STARGET_DEL);
1951 starget->state = STARGET_DEL;
1952 transport_destroy_device(dev);
1953 spin_lock_irqsave(shost->host_lock, flags);
1954 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
1955 index 2b642b145be1..c7e4b5e0bae3 100644
1956 --- a/drivers/scsi/scsi_sysfs.c
1957 +++ b/drivers/scsi/scsi_sysfs.c
1958 @@ -1366,18 +1366,18 @@ static void __scsi_remove_target(struct scsi_target *starget)
1959 void scsi_remove_target(struct device *dev)
1960 {
1961 struct Scsi_Host *shost = dev_to_shost(dev->parent);
1962 - struct scsi_target *starget, *last_target = NULL;
1963 + struct scsi_target *starget;
1964 unsigned long flags;
1965
1966 restart:
1967 spin_lock_irqsave(shost->host_lock, flags);
1968 list_for_each_entry(starget, &shost->__targets, siblings) {
1969 if (starget->state == STARGET_DEL ||
1970 - starget == last_target)
1971 + starget->state == STARGET_REMOVE)
1972 continue;
1973 if (starget->dev.parent == dev || &starget->dev == dev) {
1974 kref_get(&starget->reap_ref);
1975 - last_target = starget;
1976 + starget->state = STARGET_REMOVE;
1977 spin_unlock_irqrestore(shost->host_lock, flags);
1978 __scsi_remove_target(starget);
1979 scsi_target_reap(starget);
1980 diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
1981 index 940781183fac..3be10963f98b 100644
1982 --- a/drivers/staging/comedi/drivers/das1800.c
1983 +++ b/drivers/staging/comedi/drivers/das1800.c
1984 @@ -567,14 +567,17 @@ static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
1985 struct comedi_isadma_desc *desc;
1986 int i;
1987
1988 - outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
1989 - outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
1990 - outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */
1991 -
1992 - for (i = 0; i < 2; i++) {
1993 - desc = &dma->desc[i];
1994 - if (desc->chan)
1995 - comedi_isadma_disable(desc->chan);
1996 + /* disable and stop conversions */
1997 + outb(0x0, dev->iobase + DAS1800_STATUS);
1998 + outb(0x0, dev->iobase + DAS1800_CONTROL_B);
1999 + outb(0x0, dev->iobase + DAS1800_CONTROL_A);
2000 +
2001 + if (dma) {
2002 + for (i = 0; i < 2; i++) {
2003 + desc = &dma->desc[i];
2004 + if (desc->chan)
2005 + comedi_isadma_disable(desc->chan);
2006 + }
2007 }
2008
2009 return 0;
2010 @@ -934,13 +937,14 @@ static void das1800_ai_setup_dma(struct comedi_device *dev,
2011 {
2012 struct das1800_private *devpriv = dev->private;
2013 struct comedi_isadma *dma = devpriv->dma;
2014 - struct comedi_isadma_desc *desc = &dma->desc[0];
2015 + struct comedi_isadma_desc *desc;
2016 unsigned int bytes;
2017
2018 if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0)
2019 return;
2020
2021 dma->cur_dma = 0;
2022 + desc = &dma->desc[0];
2023
2024 /* determine a dma transfer size to fill buffer in 0.3 sec */
2025 bytes = das1800_ai_transfer_size(dev, s, desc->maxsize, 300000000);
2026 diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c
2027 index 0dde34e3a7c5..545c60c826a1 100644
2028 --- a/drivers/thunderbolt/eeprom.c
2029 +++ b/drivers/thunderbolt/eeprom.c
2030 @@ -444,6 +444,7 @@ int tb_drom_read(struct tb_switch *sw)
2031 return tb_drom_parse_entries(sw);
2032 err:
2033 kfree(sw->drom);
2034 + sw->drom = NULL;
2035 return -EIO;
2036
2037 }
2038 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
2039 index c01620780f5b..365dfd8bc42b 100644
2040 --- a/drivers/tty/n_gsm.c
2041 +++ b/drivers/tty/n_gsm.c
2042 @@ -2045,7 +2045,9 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
2043 }
2044 }
2045 spin_unlock(&gsm_mux_lock);
2046 - WARN_ON(i == MAX_MUX);
2047 + /* open failed before registering => nothing to do */
2048 + if (i == MAX_MUX)
2049 + return;
2050
2051 /* In theory disconnecting DLCI 0 is sufficient but for some
2052 modems this is apparently not the case. */
2053 diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
2054 index bcaba17688f6..a7fa016f31eb 100644
2055 --- a/drivers/tty/n_hdlc.c
2056 +++ b/drivers/tty/n_hdlc.c
2057 @@ -599,7 +599,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
2058 add_wait_queue(&tty->read_wait, &wait);
2059
2060 for (;;) {
2061 - if (test_bit(TTY_OTHER_DONE, &tty->flags)) {
2062 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
2063 ret = -EIO;
2064 break;
2065 }
2066 @@ -827,7 +827,7 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
2067 /* set bits for operations that won't block */
2068 if (n_hdlc->rx_buf_list.head)
2069 mask |= POLLIN | POLLRDNORM; /* readable */
2070 - if (test_bit(TTY_OTHER_DONE, &tty->flags))
2071 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2072 mask |= POLLHUP;
2073 if (tty_hung_up_p(filp))
2074 mask |= POLLHUP;
2075 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
2076 index fb76a7d80e7e..bdf0e6e89991 100644
2077 --- a/drivers/tty/n_tty.c
2078 +++ b/drivers/tty/n_tty.c
2079 @@ -1917,18 +1917,6 @@ static inline int input_available_p(struct tty_struct *tty, int poll)
2080 return ldata->commit_head - ldata->read_tail >= amt;
2081 }
2082
2083 -static inline int check_other_done(struct tty_struct *tty)
2084 -{
2085 - int done = test_bit(TTY_OTHER_DONE, &tty->flags);
2086 - if (done) {
2087 - /* paired with cmpxchg() in check_other_closed(); ensures
2088 - * read buffer head index is not stale
2089 - */
2090 - smp_mb__after_atomic();
2091 - }
2092 - return done;
2093 -}
2094 -
2095 /**
2096 * copy_from_read_buf - copy read data directly
2097 * @tty: terminal device
2098 @@ -2124,7 +2112,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
2099 struct n_tty_data *ldata = tty->disc_data;
2100 unsigned char __user *b = buf;
2101 DEFINE_WAIT_FUNC(wait, woken_wake_function);
2102 - int c, done;
2103 + int c;
2104 int minimum, time;
2105 ssize_t retval = 0;
2106 long timeout;
2107 @@ -2183,32 +2171,35 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
2108 break;
2109 }
2110
2111 - done = check_other_done(tty);
2112 -
2113 if (!input_available_p(tty, 0)) {
2114 - if (done) {
2115 - retval = -EIO;
2116 - break;
2117 - }
2118 - if (tty_hung_up_p(file))
2119 - break;
2120 - if (!timeout)
2121 - break;
2122 - if (file->f_flags & O_NONBLOCK) {
2123 - retval = -EAGAIN;
2124 - break;
2125 - }
2126 - if (signal_pending(current)) {
2127 - retval = -ERESTARTSYS;
2128 - break;
2129 - }
2130 up_read(&tty->termios_rwsem);
2131 + tty_buffer_flush_work(tty->port);
2132 + down_read(&tty->termios_rwsem);
2133 + if (!input_available_p(tty, 0)) {
2134 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
2135 + retval = -EIO;
2136 + break;
2137 + }
2138 + if (tty_hung_up_p(file))
2139 + break;
2140 + if (!timeout)
2141 + break;
2142 + if (file->f_flags & O_NONBLOCK) {
2143 + retval = -EAGAIN;
2144 + break;
2145 + }
2146 + if (signal_pending(current)) {
2147 + retval = -ERESTARTSYS;
2148 + break;
2149 + }
2150 + up_read(&tty->termios_rwsem);
2151
2152 - timeout = wait_woken(&wait, TASK_INTERRUPTIBLE,
2153 - timeout);
2154 + timeout = wait_woken(&wait, TASK_INTERRUPTIBLE,
2155 + timeout);
2156
2157 - down_read(&tty->termios_rwsem);
2158 - continue;
2159 + down_read(&tty->termios_rwsem);
2160 + continue;
2161 + }
2162 }
2163
2164 if (ldata->icanon && !L_EXTPROC(tty)) {
2165 @@ -2386,12 +2377,17 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
2166
2167 poll_wait(file, &tty->read_wait, wait);
2168 poll_wait(file, &tty->write_wait, wait);
2169 - if (check_other_done(tty))
2170 - mask |= POLLHUP;
2171 if (input_available_p(tty, 1))
2172 mask |= POLLIN | POLLRDNORM;
2173 + else {
2174 + tty_buffer_flush_work(tty->port);
2175 + if (input_available_p(tty, 1))
2176 + mask |= POLLIN | POLLRDNORM;
2177 + }
2178 if (tty->packet && tty->link->ctrl_status)
2179 mask |= POLLPRI | POLLIN | POLLRDNORM;
2180 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2181 + mask |= POLLHUP;
2182 if (tty_hung_up_p(file))
2183 mask |= POLLHUP;
2184 if (tty->ops->write && !tty_is_writelocked(tty) &&
2185 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
2186 index cf0dc51a2690..e198996c5b83 100644
2187 --- a/drivers/tty/pty.c
2188 +++ b/drivers/tty/pty.c
2189 @@ -59,7 +59,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
2190 if (!tty->link)
2191 return;
2192 set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
2193 - tty_flip_buffer_push(tty->link->port);
2194 + wake_up_interruptible(&tty->link->read_wait);
2195 wake_up_interruptible(&tty->link->write_wait);
2196 if (tty->driver->subtype == PTY_TYPE_MASTER) {
2197 set_bit(TTY_OTHER_CLOSED, &tty->flags);
2198 @@ -247,9 +247,7 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
2199 goto out;
2200
2201 clear_bit(TTY_IO_ERROR, &tty->flags);
2202 - /* TTY_OTHER_CLOSED must be cleared before TTY_OTHER_DONE */
2203 clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
2204 - clear_bit(TTY_OTHER_DONE, &tty->link->flags);
2205 set_bit(TTY_THROTTLED, &tty->flags);
2206 return 0;
2207
2208 diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
2209 index 88531a36b69c..ed489880e62b 100644
2210 --- a/drivers/tty/serial/8250/8250_mid.c
2211 +++ b/drivers/tty/serial/8250/8250_mid.c
2212 @@ -14,6 +14,7 @@
2213 #include <linux/pci.h>
2214
2215 #include <linux/dma/hsu.h>
2216 +#include <linux/8250_pci.h>
2217
2218 #include "8250.h"
2219
2220 @@ -24,6 +25,7 @@
2221 #define PCI_DEVICE_ID_INTEL_DNV_UART 0x19d8
2222
2223 /* Intel MID Specific registers */
2224 +#define INTEL_MID_UART_DNV_FISR 0x08
2225 #define INTEL_MID_UART_PS 0x30
2226 #define INTEL_MID_UART_MUL 0x34
2227 #define INTEL_MID_UART_DIV 0x38
2228 @@ -31,6 +33,7 @@
2229 struct mid8250;
2230
2231 struct mid8250_board {
2232 + unsigned int flags;
2233 unsigned long freq;
2234 unsigned int base_baud;
2235 int (*setup)(struct mid8250 *, struct uart_port *p);
2236 @@ -88,16 +91,16 @@ static int tng_setup(struct mid8250 *mid, struct uart_port *p)
2237 static int dnv_handle_irq(struct uart_port *p)
2238 {
2239 struct mid8250 *mid = p->private_data;
2240 - int ret;
2241 -
2242 - ret = hsu_dma_irq(&mid->dma_chip, 0);
2243 - ret |= hsu_dma_irq(&mid->dma_chip, 1);
2244 -
2245 - /* For now, letting the HW generate separate interrupt for the UART */
2246 - if (ret)
2247 - return ret;
2248 -
2249 - return serial8250_handle_irq(p, serial_port_in(p, UART_IIR));
2250 + unsigned int fisr = serial_port_in(p, INTEL_MID_UART_DNV_FISR);
2251 + int ret = IRQ_NONE;
2252 +
2253 + if (fisr & BIT(2))
2254 + ret |= hsu_dma_irq(&mid->dma_chip, 1);
2255 + if (fisr & BIT(1))
2256 + ret |= hsu_dma_irq(&mid->dma_chip, 0);
2257 + if (fisr & BIT(0))
2258 + ret |= serial8250_handle_irq(p, serial_port_in(p, UART_IIR));
2259 + return ret;
2260 }
2261
2262 #define DNV_DMA_CHAN_OFFSET 0x80
2263 @@ -106,12 +109,13 @@ static int dnv_setup(struct mid8250 *mid, struct uart_port *p)
2264 {
2265 struct hsu_dma_chip *chip = &mid->dma_chip;
2266 struct pci_dev *pdev = to_pci_dev(p->dev);
2267 + unsigned int bar = FL_GET_BASE(mid->board->flags);
2268 int ret;
2269
2270 chip->dev = &pdev->dev;
2271 chip->irq = pdev->irq;
2272 chip->regs = p->membase;
2273 - chip->length = pci_resource_len(pdev, 0);
2274 + chip->length = pci_resource_len(pdev, bar);
2275 chip->offset = DNV_DMA_CHAN_OFFSET;
2276
2277 /* Falling back to PIO mode if DMA probing fails */
2278 @@ -217,6 +221,7 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2279 {
2280 struct uart_8250_port uart;
2281 struct mid8250 *mid;
2282 + unsigned int bar;
2283 int ret;
2284
2285 ret = pcim_enable_device(pdev);
2286 @@ -230,6 +235,7 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2287 return -ENOMEM;
2288
2289 mid->board = (struct mid8250_board *)id->driver_data;
2290 + bar = FL_GET_BASE(mid->board->flags);
2291
2292 memset(&uart, 0, sizeof(struct uart_8250_port));
2293
2294 @@ -242,8 +248,8 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2295 uart.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE;
2296 uart.port.set_termios = mid8250_set_termios;
2297
2298 - uart.port.mapbase = pci_resource_start(pdev, 0);
2299 - uart.port.membase = pcim_iomap(pdev, 0, 0);
2300 + uart.port.mapbase = pci_resource_start(pdev, bar);
2301 + uart.port.membase = pcim_iomap(pdev, bar, 0);
2302 if (!uart.port.membase)
2303 return -ENOMEM;
2304
2305 @@ -282,18 +288,21 @@ static void mid8250_remove(struct pci_dev *pdev)
2306 }
2307
2308 static const struct mid8250_board pnw_board = {
2309 + .flags = FL_BASE0,
2310 .freq = 50000000,
2311 .base_baud = 115200,
2312 .setup = pnw_setup,
2313 };
2314
2315 static const struct mid8250_board tng_board = {
2316 + .flags = FL_BASE0,
2317 .freq = 38400000,
2318 .base_baud = 1843200,
2319 .setup = tng_setup,
2320 };
2321
2322 static const struct mid8250_board dnv_board = {
2323 + .flags = FL_BASE1,
2324 .freq = 133333333,
2325 .base_baud = 115200,
2326 .setup = dnv_setup,
2327 diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2328 index 98862aa5bb58..4eedd1da32e6 100644
2329 --- a/drivers/tty/serial/8250/8250_pci.c
2330 +++ b/drivers/tty/serial/8250/8250_pci.c
2331 @@ -1377,6 +1377,9 @@ byt_set_termios(struct uart_port *p, struct ktermios *termios,
2332 unsigned long m, n;
2333 u32 reg;
2334
2335 + /* Gracefully handle the B0 case: fall back to B9600 */
2336 + fuart = fuart ? fuart : 9600 * 16;
2337 +
2338 /* Get Fuart closer to Fref */
2339 fuart *= rounddown_pow_of_two(fref / fuart);
2340
2341 diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
2342 index d9439e6ab719..954941dd8124 100644
2343 --- a/drivers/tty/serial/atmel_serial.c
2344 +++ b/drivers/tty/serial/atmel_serial.c
2345 @@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
2346 return atmel_port->use_dma_rx;
2347 }
2348
2349 +static bool atmel_use_fifo(struct uart_port *port)
2350 +{
2351 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2352 +
2353 + return atmel_port->fifo_size;
2354 +}
2355 +
2356 static unsigned int atmel_get_lines_status(struct uart_port *port)
2357 {
2358 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2359 @@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2360 mode |= ATMEL_US_USMODE_RS485;
2361 } else if (termios->c_cflag & CRTSCTS) {
2362 /* RS232 with hardware handshake (RTS/CTS) */
2363 - mode |= ATMEL_US_USMODE_HWHS;
2364 + if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
2365 + dev_info(port->dev, "not enabling hardware flow control because DMA is used");
2366 + termios->c_cflag &= ~CRTSCTS;
2367 + } else {
2368 + mode |= ATMEL_US_USMODE_HWHS;
2369 + }
2370 } else {
2371 /* RS232 without hadware handshake */
2372 mode |= ATMEL_US_USMODE_NORMAL;
2373 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
2374 index ac7f8df54406..99bb23161dd6 100644
2375 --- a/drivers/tty/serial/samsung.c
2376 +++ b/drivers/tty/serial/samsung.c
2377 @@ -1271,6 +1271,8 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
2378 /* check to see if we need to change clock source */
2379
2380 if (ourport->baudclk != clk) {
2381 + clk_prepare_enable(clk);
2382 +
2383 s3c24xx_serial_setsource(port, clk_sel);
2384
2385 if (!IS_ERR(ourport->baudclk)) {
2386 @@ -1278,8 +1280,6 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
2387 ourport->baudclk = ERR_PTR(-EINVAL);
2388 }
2389
2390 - clk_prepare_enable(clk);
2391 -
2392 ourport->baudclk = clk;
2393 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
2394 }
2395 diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
2396 index a946e49a2626..aa80dc94ddc2 100644
2397 --- a/drivers/tty/tty_buffer.c
2398 +++ b/drivers/tty/tty_buffer.c
2399 @@ -37,29 +37,6 @@
2400
2401 #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
2402
2403 -/*
2404 - * If all tty flip buffers have been processed by flush_to_ldisc() or
2405 - * dropped by tty_buffer_flush(), check if the linked pty has been closed.
2406 - * If so, wake the reader/poll to process
2407 - */
2408 -static inline void check_other_closed(struct tty_struct *tty)
2409 -{
2410 - unsigned long flags, old;
2411 -
2412 - /* transition from TTY_OTHER_CLOSED => TTY_OTHER_DONE must be atomic */
2413 - for (flags = ACCESS_ONCE(tty->flags);
2414 - test_bit(TTY_OTHER_CLOSED, &flags);
2415 - ) {
2416 - old = flags;
2417 - __set_bit(TTY_OTHER_DONE, &flags);
2418 - flags = cmpxchg(&tty->flags, old, flags);
2419 - if (old == flags) {
2420 - wake_up_interruptible(&tty->read_wait);
2421 - break;
2422 - }
2423 - }
2424 -}
2425 -
2426 /**
2427 * tty_buffer_lock_exclusive - gain exclusive access to buffer
2428 * tty_buffer_unlock_exclusive - release exclusive access
2429 @@ -254,8 +231,6 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
2430 if (ld && ld->ops->flush_buffer)
2431 ld->ops->flush_buffer(tty);
2432
2433 - check_other_closed(tty);
2434 -
2435 atomic_dec(&buf->priority);
2436 mutex_unlock(&buf->lock);
2437 }
2438 @@ -522,10 +497,8 @@ static void flush_to_ldisc(struct work_struct *work)
2439 */
2440 count = smp_load_acquire(&head->commit) - head->read;
2441 if (!count) {
2442 - if (next == NULL) {
2443 - check_other_closed(tty);
2444 + if (next == NULL)
2445 break;
2446 - }
2447 buf->head = next;
2448 tty_buffer_free(port, head);
2449 continue;
2450 @@ -614,3 +587,8 @@ bool tty_buffer_cancel_work(struct tty_port *port)
2451 {
2452 return cancel_work_sync(&port->buf.work);
2453 }
2454 +
2455 +void tty_buffer_flush_work(struct tty_port *port)
2456 +{
2457 + flush_work(&port->buf.work);
2458 +}
2459 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
2460 index 3e3c7575e92d..bd523adb9643 100644
2461 --- a/drivers/tty/vt/vt.c
2462 +++ b/drivers/tty/vt/vt.c
2463 @@ -3583,9 +3583,10 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
2464 goto err;
2465
2466 desc = csw->con_startup();
2467 -
2468 - if (!desc)
2469 + if (!desc) {
2470 + retval = -ENODEV;
2471 goto err;
2472 + }
2473
2474 retval = -EINVAL;
2475
2476 diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
2477 index 2057d91d8336..dadd1e8dfe09 100644
2478 --- a/drivers/usb/core/driver.c
2479 +++ b/drivers/usb/core/driver.c
2480 @@ -284,7 +284,7 @@ static int usb_probe_interface(struct device *dev)
2481 struct usb_device *udev = interface_to_usbdev(intf);
2482 const struct usb_device_id *id;
2483 int error = -ENODEV;
2484 - int lpm_disable_error;
2485 + int lpm_disable_error = -ENODEV;
2486
2487 dev_dbg(dev, "%s\n", __func__);
2488
2489 @@ -336,12 +336,14 @@ static int usb_probe_interface(struct device *dev)
2490 * setting during probe, that should also be fine. usb_set_interface()
2491 * will attempt to disable LPM, and fail if it can't disable it.
2492 */
2493 - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2494 - if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
2495 - dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.",
2496 - __func__, driver->name);
2497 - error = lpm_disable_error;
2498 - goto err;
2499 + if (driver->disable_hub_initiated_lpm) {
2500 + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2501 + if (lpm_disable_error) {
2502 + dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.",
2503 + __func__, driver->name);
2504 + error = lpm_disable_error;
2505 + goto err;
2506 + }
2507 }
2508
2509 /* Carry out a deferred switch to altsetting 0 */
2510 @@ -391,7 +393,8 @@ static int usb_unbind_interface(struct device *dev)
2511 struct usb_interface *intf = to_usb_interface(dev);
2512 struct usb_host_endpoint *ep, **eps = NULL;
2513 struct usb_device *udev;
2514 - int i, j, error, r, lpm_disable_error;
2515 + int i, j, error, r;
2516 + int lpm_disable_error = -ENODEV;
2517
2518 intf->condition = USB_INTERFACE_UNBINDING;
2519
2520 @@ -399,12 +402,13 @@ static int usb_unbind_interface(struct device *dev)
2521 udev = interface_to_usbdev(intf);
2522 error = usb_autoresume_device(udev);
2523
2524 - /* Hub-initiated LPM policy may change, so attempt to disable LPM until
2525 + /* If hub-initiated LPM policy may change, attempt to disable LPM until
2526 * the driver is unbound. If LPM isn't disabled, that's fine because it
2527 * wouldn't be enabled unless all the bound interfaces supported
2528 * hub-initiated LPM.
2529 */
2530 - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2531 + if (driver->disable_hub_initiated_lpm)
2532 + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2533
2534 /*
2535 * Terminate all URBs for this interface unless the driver
2536 @@ -505,7 +509,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2537 struct device *dev;
2538 struct usb_device *udev;
2539 int retval = 0;
2540 - int lpm_disable_error;
2541 + int lpm_disable_error = -ENODEV;
2542
2543 if (!iface)
2544 return -ENODEV;
2545 @@ -526,12 +530,14 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2546
2547 iface->condition = USB_INTERFACE_BOUND;
2548
2549 - /* Disable LPM until this driver is bound. */
2550 - lpm_disable_error = usb_unlocked_disable_lpm(udev);
2551 - if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
2552 - dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
2553 - __func__, driver->name);
2554 - return -ENOMEM;
2555 + /* See the comment about disabling LPM in usb_probe_interface(). */
2556 + if (driver->disable_hub_initiated_lpm) {
2557 + lpm_disable_error = usb_unlocked_disable_lpm(udev);
2558 + if (lpm_disable_error) {
2559 + dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
2560 + __func__, driver->name);
2561 + return -ENOMEM;
2562 + }
2563 }
2564
2565 /* Claimed interfaces are initially inactive (suspended) and
2566 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
2567 index 2ca2cef7f681..980fc5774151 100644
2568 --- a/drivers/usb/core/hcd.c
2569 +++ b/drivers/usb/core/hcd.c
2570 @@ -994,7 +994,7 @@ static void usb_bus_init (struct usb_bus *bus)
2571 bus->bandwidth_allocated = 0;
2572 bus->bandwidth_int_reqs = 0;
2573 bus->bandwidth_isoc_reqs = 0;
2574 - mutex_init(&bus->usb_address0_mutex);
2575 + mutex_init(&bus->devnum_next_mutex);
2576 }
2577
2578 /*-------------------------------------------------------------------------*/
2579 @@ -2521,6 +2521,14 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
2580 return NULL;
2581 }
2582 if (primary_hcd == NULL) {
2583 + hcd->address0_mutex = kmalloc(sizeof(*hcd->address0_mutex),
2584 + GFP_KERNEL);
2585 + if (!hcd->address0_mutex) {
2586 + kfree(hcd);
2587 + dev_dbg(dev, "hcd address0 mutex alloc failed\n");
2588 + return NULL;
2589 + }
2590 + mutex_init(hcd->address0_mutex);
2591 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
2592 GFP_KERNEL);
2593 if (!hcd->bandwidth_mutex) {
2594 @@ -2532,6 +2540,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
2595 dev_set_drvdata(dev, hcd);
2596 } else {
2597 mutex_lock(&usb_port_peer_mutex);
2598 + hcd->address0_mutex = primary_hcd->address0_mutex;
2599 hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex;
2600 hcd->primary_hcd = primary_hcd;
2601 primary_hcd->primary_hcd = primary_hcd;
2602 @@ -2598,8 +2607,10 @@ static void hcd_release(struct kref *kref)
2603 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
2604
2605 mutex_lock(&usb_port_peer_mutex);
2606 - if (usb_hcd_is_primary_hcd(hcd))
2607 + if (usb_hcd_is_primary_hcd(hcd)) {
2608 + kfree(hcd->address0_mutex);
2609 kfree(hcd->bandwidth_mutex);
2610 + }
2611 if (hcd->shared_hcd) {
2612 struct usb_hcd *peer = hcd->shared_hcd;
2613
2614 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2615 index 38cc4bae0a82..1ab42bfbecaf 100644
2616 --- a/drivers/usb/core/hub.c
2617 +++ b/drivers/usb/core/hub.c
2618 @@ -2080,7 +2080,7 @@ static void choose_devnum(struct usb_device *udev)
2619 struct usb_bus *bus = udev->bus;
2620
2621 /* be safe when more hub events are proceed in parallel */
2622 - mutex_lock(&bus->usb_address0_mutex);
2623 + mutex_lock(&bus->devnum_next_mutex);
2624 if (udev->wusb) {
2625 devnum = udev->portnum + 1;
2626 BUG_ON(test_bit(devnum, bus->devmap.devicemap));
2627 @@ -2098,7 +2098,7 @@ static void choose_devnum(struct usb_device *udev)
2628 set_bit(devnum, bus->devmap.devicemap);
2629 udev->devnum = devnum;
2630 }
2631 - mutex_unlock(&bus->usb_address0_mutex);
2632 + mutex_unlock(&bus->devnum_next_mutex);
2633 }
2634
2635 static void release_devnum(struct usb_device *udev)
2636 @@ -4364,7 +4364,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2637 if (oldspeed == USB_SPEED_LOW)
2638 delay = HUB_LONG_RESET_TIME;
2639
2640 - mutex_lock(&hdev->bus->usb_address0_mutex);
2641 + mutex_lock(hcd->address0_mutex);
2642
2643 /* Reset the device; full speed may morph to high speed */
2644 /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */
2645 @@ -4650,7 +4650,7 @@ fail:
2646 hub_port_disable(hub, port1, 0);
2647 update_devnum(udev, devnum); /* for disconnect processing */
2648 }
2649 - mutex_unlock(&hdev->bus->usb_address0_mutex);
2650 + mutex_unlock(hcd->address0_mutex);
2651 return retval;
2652 }
2653
2654 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
2655 index 15b648cbc75c..73515d54e1cc 100644
2656 --- a/drivers/usb/gadget/function/f_fs.c
2657 +++ b/drivers/usb/gadget/function/f_fs.c
2658 @@ -651,7 +651,7 @@ static void ffs_user_copy_worker(struct work_struct *work)
2659 if (io_data->read && ret > 0) {
2660 use_mm(io_data->mm);
2661 ret = copy_to_iter(io_data->buf, ret, &io_data->data);
2662 - if (iov_iter_count(&io_data->data))
2663 + if (ret != io_data->req->actual && iov_iter_count(&io_data->data))
2664 ret = -EFAULT;
2665 unuse_mm(io_data->mm);
2666 }
2667 diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
2668 index acf210f16328..5c6d4d7ca605 100644
2669 --- a/drivers/usb/gadget/function/f_mass_storage.c
2670 +++ b/drivers/usb/gadget/function/f_mass_storage.c
2671 @@ -2977,25 +2977,6 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2672 }
2673 EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string);
2674
2675 -int fsg_common_run_thread(struct fsg_common *common)
2676 -{
2677 - common->state = FSG_STATE_IDLE;
2678 - /* Tell the thread to start working */
2679 - common->thread_task =
2680 - kthread_create(fsg_main_thread, common, "file-storage");
2681 - if (IS_ERR(common->thread_task)) {
2682 - common->state = FSG_STATE_TERMINATED;
2683 - return PTR_ERR(common->thread_task);
2684 - }
2685 -
2686 - DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
2687 -
2688 - wake_up_process(common->thread_task);
2689 -
2690 - return 0;
2691 -}
2692 -EXPORT_SYMBOL_GPL(fsg_common_run_thread);
2693 -
2694 static void fsg_common_release(struct kref *ref)
2695 {
2696 struct fsg_common *common = container_of(ref, struct fsg_common, ref);
2697 @@ -3005,6 +2986,7 @@ static void fsg_common_release(struct kref *ref)
2698 if (common->state != FSG_STATE_TERMINATED) {
2699 raise_exception(common, FSG_STATE_EXIT);
2700 wait_for_completion(&common->thread_notifier);
2701 + common->thread_task = NULL;
2702 }
2703
2704 for (i = 0; i < ARRAY_SIZE(common->luns); ++i) {
2705 @@ -3050,9 +3032,21 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2706 if (ret)
2707 return ret;
2708 fsg_common_set_inquiry_string(fsg->common, NULL, NULL);
2709 - ret = fsg_common_run_thread(fsg->common);
2710 - if (ret)
2711 + }
2712 +
2713 + if (!common->thread_task) {
2714 + common->state = FSG_STATE_IDLE;
2715 + common->thread_task =
2716 + kthread_create(fsg_main_thread, common, "file-storage");
2717 + if (IS_ERR(common->thread_task)) {
2718 + int ret = PTR_ERR(common->thread_task);
2719 + common->thread_task = NULL;
2720 + common->state = FSG_STATE_TERMINATED;
2721 return ret;
2722 + }
2723 + DBG(common, "I/O thread pid: %d\n",
2724 + task_pid_nr(common->thread_task));
2725 + wake_up_process(common->thread_task);
2726 }
2727
2728 fsg->gadget = gadget;
2729 diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h
2730 index 445df6775609..b6a9918eaefb 100644
2731 --- a/drivers/usb/gadget/function/f_mass_storage.h
2732 +++ b/drivers/usb/gadget/function/f_mass_storage.h
2733 @@ -153,8 +153,6 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
2734 void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2735 const char *pn);
2736
2737 -int fsg_common_run_thread(struct fsg_common *common);
2738 -
2739 void fsg_config_from_params(struct fsg_config *cfg,
2740 const struct fsg_module_parameters *params,
2741 unsigned int fsg_num_buffers);
2742 diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c
2743 index c16089efc322..c39de65a448b 100644
2744 --- a/drivers/usb/gadget/legacy/acm_ms.c
2745 +++ b/drivers/usb/gadget/legacy/acm_ms.c
2746 @@ -133,10 +133,6 @@ static int acm_ms_do_config(struct usb_configuration *c)
2747 if (status < 0)
2748 goto put_msg;
2749
2750 - status = fsg_common_run_thread(opts->common);
2751 - if (status)
2752 - goto remove_acm;
2753 -
2754 status = usb_add_function(c, f_msg);
2755 if (status)
2756 goto remove_acm;
2757 diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c
2758 index e61af53c7d2b..125974f32f50 100644
2759 --- a/drivers/usb/gadget/legacy/mass_storage.c
2760 +++ b/drivers/usb/gadget/legacy/mass_storage.c
2761 @@ -132,10 +132,6 @@ static int msg_do_config(struct usb_configuration *c)
2762 if (IS_ERR(f_msg))
2763 return PTR_ERR(f_msg);
2764
2765 - ret = fsg_common_run_thread(opts->common);
2766 - if (ret)
2767 - goto put_func;
2768 -
2769 ret = usb_add_function(c, f_msg);
2770 if (ret)
2771 goto put_func;
2772 diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c
2773 index 229d704a620b..a70a406580ea 100644
2774 --- a/drivers/usb/gadget/legacy/multi.c
2775 +++ b/drivers/usb/gadget/legacy/multi.c
2776 @@ -137,7 +137,6 @@ static struct usb_function *f_msg_rndis;
2777
2778 static int rndis_do_config(struct usb_configuration *c)
2779 {
2780 - struct fsg_opts *fsg_opts;
2781 int ret;
2782
2783 if (gadget_is_otg(c->cdev->gadget)) {
2784 @@ -169,11 +168,6 @@ static int rndis_do_config(struct usb_configuration *c)
2785 goto err_fsg;
2786 }
2787
2788 - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2789 - ret = fsg_common_run_thread(fsg_opts->common);
2790 - if (ret)
2791 - goto err_run;
2792 -
2793 ret = usb_add_function(c, f_msg_rndis);
2794 if (ret)
2795 goto err_run;
2796 @@ -225,7 +219,6 @@ static struct usb_function *f_msg_multi;
2797
2798 static int cdc_do_config(struct usb_configuration *c)
2799 {
2800 - struct fsg_opts *fsg_opts;
2801 int ret;
2802
2803 if (gadget_is_otg(c->cdev->gadget)) {
2804 @@ -258,11 +251,6 @@ static int cdc_do_config(struct usb_configuration *c)
2805 goto err_fsg;
2806 }
2807
2808 - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2809 - ret = fsg_common_run_thread(fsg_opts->common);
2810 - if (ret)
2811 - goto err_run;
2812 -
2813 ret = usb_add_function(c, f_msg_multi);
2814 if (ret)
2815 goto err_run;
2816 diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
2817 index 09975046c694..b1e535f4022e 100644
2818 --- a/drivers/usb/gadget/legacy/nokia.c
2819 +++ b/drivers/usb/gadget/legacy/nokia.c
2820 @@ -152,7 +152,6 @@ static int nokia_bind_config(struct usb_configuration *c)
2821 struct usb_function *f_ecm;
2822 struct usb_function *f_obex2 = NULL;
2823 struct usb_function *f_msg;
2824 - struct fsg_opts *fsg_opts;
2825 int status = 0;
2826 int obex1_stat = -1;
2827 int obex2_stat = -1;
2828 @@ -222,12 +221,6 @@ static int nokia_bind_config(struct usb_configuration *c)
2829 goto err_ecm;
2830 }
2831
2832 - fsg_opts = fsg_opts_from_func_inst(fi_msg);
2833 -
2834 - status = fsg_common_run_thread(fsg_opts->common);
2835 - if (status)
2836 - goto err_msg;
2837 -
2838 status = usb_add_function(c, f_msg);
2839 if (status)
2840 goto err_msg;
2841 diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
2842 index e4e70e11d0f6..c6e76465065a 100644
2843 --- a/drivers/usb/gadget/udc/udc-core.c
2844 +++ b/drivers/usb/gadget/udc/udc-core.c
2845 @@ -75,7 +75,7 @@ int usb_gadget_map_request(struct usb_gadget *gadget,
2846 mapped = dma_map_sg(dev, req->sg, req->num_sgs,
2847 is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
2848 if (mapped == 0) {
2849 - dev_err(&gadget->dev, "failed to map SGs\n");
2850 + dev_err(dev, "failed to map SGs\n");
2851 return -EFAULT;
2852 }
2853
2854 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
2855 index 3050b18b2447..e9d4dde3e9b3 100644
2856 --- a/drivers/usb/host/Kconfig
2857 +++ b/drivers/usb/host/Kconfig
2858 @@ -35,6 +35,7 @@ config USB_XHCI_PCI
2859
2860 config USB_XHCI_PLATFORM
2861 tristate "Generic xHCI driver for a platform device"
2862 + select USB_XHCI_RCAR if ARCH_RENESAS
2863 ---help---
2864 Adds an xHCI host driver for a generic platform device, which
2865 provides a memory space and an irq.
2866 @@ -63,7 +64,7 @@ config USB_XHCI_MVEBU
2867
2868 config USB_XHCI_RCAR
2869 tristate "xHCI support for Renesas R-Car SoCs"
2870 - select USB_XHCI_PLATFORM
2871 + depends on USB_XHCI_PLATFORM
2872 depends on ARCH_RENESAS || COMPILE_TEST
2873 ---help---
2874 Say 'Y' to enable the support for the xHCI host controller
2875 diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
2876 index 92fdb6e9faff..c78ff95a43be 100644
2877 --- a/drivers/usb/misc/usbtest.c
2878 +++ b/drivers/usb/misc/usbtest.c
2879 @@ -529,6 +529,7 @@ static struct scatterlist *
2880 alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
2881 {
2882 struct scatterlist *sg;
2883 + unsigned int n_size = 0;
2884 unsigned i;
2885 unsigned size = max;
2886 unsigned maxpacket =
2887 @@ -561,7 +562,8 @@ alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
2888 break;
2889 case 1:
2890 for (j = 0; j < size; j++)
2891 - *buf++ = (u8) ((j % maxpacket) % 63);
2892 + *buf++ = (u8) (((j + n_size) % maxpacket) % 63);
2893 + n_size += size;
2894 break;
2895 }
2896
2897 diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
2898 index 7c9f25e9c422..a7c8d26a322b 100644
2899 --- a/drivers/usb/serial/cp210x.c
2900 +++ b/drivers/usb/serial/cp210x.c
2901 @@ -971,8 +971,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
2902 } else {
2903 modem_ctl[0] &= ~0x7B;
2904 modem_ctl[0] |= 0x01;
2905 - /* FIXME - OR here instead of assignment looks wrong */
2906 - modem_ctl[4] |= 0x40;
2907 + modem_ctl[4] = 0x40;
2908 dev_dbg(dev, "%s - flow control = NONE\n", __func__);
2909 }
2910
2911 diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
2912 index f3007ecdd1b4..11c05ce2f35f 100644
2913 --- a/drivers/usb/serial/io_edgeport.c
2914 +++ b/drivers/usb/serial/io_edgeport.c
2915 @@ -2849,14 +2849,16 @@ static int edge_startup(struct usb_serial *serial)
2916 /* not set up yet, so do it now */
2917 edge_serial->interrupt_read_urb =
2918 usb_alloc_urb(0, GFP_KERNEL);
2919 - if (!edge_serial->interrupt_read_urb)
2920 - return -ENOMEM;
2921 + if (!edge_serial->interrupt_read_urb) {
2922 + response = -ENOMEM;
2923 + break;
2924 + }
2925
2926 edge_serial->interrupt_in_buffer =
2927 kmalloc(buffer_size, GFP_KERNEL);
2928 if (!edge_serial->interrupt_in_buffer) {
2929 - usb_free_urb(edge_serial->interrupt_read_urb);
2930 - return -ENOMEM;
2931 + response = -ENOMEM;
2932 + break;
2933 }
2934 edge_serial->interrupt_in_endpoint =
2935 endpoint->bEndpointAddress;
2936 @@ -2884,14 +2886,16 @@ static int edge_startup(struct usb_serial *serial)
2937 /* not set up yet, so do it now */
2938 edge_serial->read_urb =
2939 usb_alloc_urb(0, GFP_KERNEL);
2940 - if (!edge_serial->read_urb)
2941 - return -ENOMEM;
2942 + if (!edge_serial->read_urb) {
2943 + response = -ENOMEM;
2944 + break;
2945 + }
2946
2947 edge_serial->bulk_in_buffer =
2948 kmalloc(buffer_size, GFP_KERNEL);
2949 if (!edge_serial->bulk_in_buffer) {
2950 - usb_free_urb(edge_serial->read_urb);
2951 - return -ENOMEM;
2952 + response = -ENOMEM;
2953 + break;
2954 }
2955 edge_serial->bulk_in_endpoint =
2956 endpoint->bEndpointAddress;
2957 @@ -2917,9 +2921,22 @@ static int edge_startup(struct usb_serial *serial)
2958 }
2959 }
2960
2961 - if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
2962 - dev_err(ddev, "Error - the proper endpoints were not found!\n");
2963 - return -ENODEV;
2964 + if (response || !interrupt_in_found || !bulk_in_found ||
2965 + !bulk_out_found) {
2966 + if (!response) {
2967 + dev_err(ddev, "expected endpoints not found\n");
2968 + response = -ENODEV;
2969 + }
2970 +
2971 + usb_free_urb(edge_serial->interrupt_read_urb);
2972 + kfree(edge_serial->interrupt_in_buffer);
2973 +
2974 + usb_free_urb(edge_serial->read_urb);
2975 + kfree(edge_serial->bulk_in_buffer);
2976 +
2977 + kfree(edge_serial);
2978 +
2979 + return response;
2980 }
2981
2982 /* start interrupt read for this edgeport this interrupt will
2983 @@ -2942,16 +2959,9 @@ static void edge_disconnect(struct usb_serial *serial)
2984 {
2985 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2986
2987 - /* stop reads and writes on all ports */
2988 - /* free up our endpoint stuff */
2989 if (edge_serial->is_epic) {
2990 usb_kill_urb(edge_serial->interrupt_read_urb);
2991 - usb_free_urb(edge_serial->interrupt_read_urb);
2992 - kfree(edge_serial->interrupt_in_buffer);
2993 -
2994 usb_kill_urb(edge_serial->read_urb);
2995 - usb_free_urb(edge_serial->read_urb);
2996 - kfree(edge_serial->bulk_in_buffer);
2997 }
2998 }
2999
3000 @@ -2964,6 +2974,16 @@ static void edge_release(struct usb_serial *serial)
3001 {
3002 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
3003
3004 + if (edge_serial->is_epic) {
3005 + usb_kill_urb(edge_serial->interrupt_read_urb);
3006 + usb_free_urb(edge_serial->interrupt_read_urb);
3007 + kfree(edge_serial->interrupt_in_buffer);
3008 +
3009 + usb_kill_urb(edge_serial->read_urb);
3010 + usb_free_urb(edge_serial->read_urb);
3011 + kfree(edge_serial->bulk_in_buffer);
3012 + }
3013 +
3014 kfree(edge_serial);
3015 }
3016
3017 diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
3018 index b6bd8e4a6486..1cf05883f48c 100644
3019 --- a/drivers/usb/serial/keyspan.c
3020 +++ b/drivers/usb/serial/keyspan.c
3021 @@ -2376,6 +2376,10 @@ static void keyspan_release(struct usb_serial *serial)
3022
3023 s_priv = usb_get_serial_data(serial);
3024
3025 + /* Make sure to unlink the URBs submitted in attach. */
3026 + usb_kill_urb(s_priv->instat_urb);
3027 + usb_kill_urb(s_priv->indat_urb);
3028 +
3029 usb_free_urb(s_priv->instat_urb);
3030 usb_free_urb(s_priv->indat_urb);
3031 usb_free_urb(s_priv->glocont_urb);
3032 diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
3033 index 31a8b47f1ac6..c6596cbcc4b6 100644
3034 --- a/drivers/usb/serial/mxuport.c
3035 +++ b/drivers/usb/serial/mxuport.c
3036 @@ -1259,6 +1259,15 @@ static int mxuport_attach(struct usb_serial *serial)
3037 return 0;
3038 }
3039
3040 +static void mxuport_release(struct usb_serial *serial)
3041 +{
3042 + struct usb_serial_port *port0 = serial->port[0];
3043 + struct usb_serial_port *port1 = serial->port[1];
3044 +
3045 + usb_serial_generic_close(port1);
3046 + usb_serial_generic_close(port0);
3047 +}
3048 +
3049 static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port)
3050 {
3051 struct mxuport_port *mxport = usb_get_serial_port_data(port);
3052 @@ -1361,6 +1370,7 @@ static struct usb_serial_driver mxuport_device = {
3053 .probe = mxuport_probe,
3054 .port_probe = mxuport_port_probe,
3055 .attach = mxuport_attach,
3056 + .release = mxuport_release,
3057 .calc_num_ports = mxuport_calc_num_ports,
3058 .open = mxuport_open,
3059 .close = mxuport_close,
3060 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
3061 index c6f497f16526..d96d423d00e6 100644
3062 --- a/drivers/usb/serial/option.c
3063 +++ b/drivers/usb/serial/option.c
3064 @@ -375,18 +375,22 @@ static void option_instat_callback(struct urb *urb);
3065 #define HAIER_PRODUCT_CE81B 0x10f8
3066 #define HAIER_PRODUCT_CE100 0x2009
3067
3068 -/* Cinterion (formerly Siemens) products */
3069 -#define SIEMENS_VENDOR_ID 0x0681
3070 -#define CINTERION_VENDOR_ID 0x1e2d
3071 +/* Gemalto's Cinterion products (formerly Siemens) */
3072 +#define SIEMENS_VENDOR_ID 0x0681
3073 +#define CINTERION_VENDOR_ID 0x1e2d
3074 +#define CINTERION_PRODUCT_HC25_MDMNET 0x0040
3075 #define CINTERION_PRODUCT_HC25_MDM 0x0047
3076 -#define CINTERION_PRODUCT_HC25_MDMNET 0x0040
3077 +#define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
3078 #define CINTERION_PRODUCT_HC28_MDM 0x004C
3079 -#define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
3080 #define CINTERION_PRODUCT_EU3_E 0x0051
3081 #define CINTERION_PRODUCT_EU3_P 0x0052
3082 #define CINTERION_PRODUCT_PH8 0x0053
3083 #define CINTERION_PRODUCT_AHXX 0x0055
3084 #define CINTERION_PRODUCT_PLXX 0x0060
3085 +#define CINTERION_PRODUCT_PH8_2RMNET 0x0082
3086 +#define CINTERION_PRODUCT_PH8_AUDIO 0x0083
3087 +#define CINTERION_PRODUCT_AHXX_2RMNET 0x0084
3088 +#define CINTERION_PRODUCT_AHXX_AUDIO 0x0085
3089
3090 /* Olivetti products */
3091 #define OLIVETTI_VENDOR_ID 0x0b3c
3092 @@ -633,6 +637,10 @@ static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = {
3093 .reserved = BIT(1) | BIT(2) | BIT(3),
3094 };
3095
3096 +static const struct option_blacklist_info cinterion_rmnet2_blacklist = {
3097 + .reserved = BIT(4) | BIT(5),
3098 +};
3099 +
3100 static const struct usb_device_id option_ids[] = {
3101 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
3102 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
3103 @@ -1602,7 +1610,79 @@ static const struct usb_device_id option_ids[] = {
3104 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
3105 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
3106 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
3107 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
3108 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff42, 0xff, 0xff, 0xff) },
3109 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff43, 0xff, 0xff, 0xff) },
3110 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff44, 0xff, 0xff, 0xff) },
3111 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff45, 0xff, 0xff, 0xff) },
3112 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff46, 0xff, 0xff, 0xff) },
3113 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff47, 0xff, 0xff, 0xff) },
3114 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff48, 0xff, 0xff, 0xff) },
3115 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff49, 0xff, 0xff, 0xff) },
3116 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4a, 0xff, 0xff, 0xff) },
3117 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4b, 0xff, 0xff, 0xff) },
3118 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4c, 0xff, 0xff, 0xff) },
3119 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4d, 0xff, 0xff, 0xff) },
3120 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4e, 0xff, 0xff, 0xff) },
3121 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4f, 0xff, 0xff, 0xff) },
3122 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff50, 0xff, 0xff, 0xff) },
3123 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff51, 0xff, 0xff, 0xff) },
3124 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff52, 0xff, 0xff, 0xff) },
3125 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff53, 0xff, 0xff, 0xff) },
3126 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff54, 0xff, 0xff, 0xff) },
3127 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff55, 0xff, 0xff, 0xff) },
3128 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff56, 0xff, 0xff, 0xff) },
3129 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff57, 0xff, 0xff, 0xff) },
3130 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff58, 0xff, 0xff, 0xff) },
3131 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff59, 0xff, 0xff, 0xff) },
3132 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5a, 0xff, 0xff, 0xff) },
3133 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5b, 0xff, 0xff, 0xff) },
3134 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5c, 0xff, 0xff, 0xff) },
3135 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5d, 0xff, 0xff, 0xff) },
3136 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5e, 0xff, 0xff, 0xff) },
3137 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5f, 0xff, 0xff, 0xff) },
3138 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff60, 0xff, 0xff, 0xff) },
3139 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff61, 0xff, 0xff, 0xff) },
3140 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff62, 0xff, 0xff, 0xff) },
3141 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff63, 0xff, 0xff, 0xff) },
3142 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff64, 0xff, 0xff, 0xff) },
3143 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff65, 0xff, 0xff, 0xff) },
3144 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff66, 0xff, 0xff, 0xff) },
3145 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff67, 0xff, 0xff, 0xff) },
3146 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff68, 0xff, 0xff, 0xff) },
3147 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff69, 0xff, 0xff, 0xff) },
3148 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6a, 0xff, 0xff, 0xff) },
3149 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6b, 0xff, 0xff, 0xff) },
3150 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6c, 0xff, 0xff, 0xff) },
3151 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6d, 0xff, 0xff, 0xff) },
3152 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6e, 0xff, 0xff, 0xff) },
3153 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6f, 0xff, 0xff, 0xff) },
3154 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff70, 0xff, 0xff, 0xff) },
3155 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff71, 0xff, 0xff, 0xff) },
3156 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff72, 0xff, 0xff, 0xff) },
3157 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff73, 0xff, 0xff, 0xff) },
3158 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff74, 0xff, 0xff, 0xff) },
3159 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff75, 0xff, 0xff, 0xff) },
3160 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff76, 0xff, 0xff, 0xff) },
3161 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff77, 0xff, 0xff, 0xff) },
3162 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff78, 0xff, 0xff, 0xff) },
3163 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff79, 0xff, 0xff, 0xff) },
3164 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7a, 0xff, 0xff, 0xff) },
3165 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7b, 0xff, 0xff, 0xff) },
3166 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7c, 0xff, 0xff, 0xff) },
3167 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7d, 0xff, 0xff, 0xff) },
3168 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7e, 0xff, 0xff, 0xff) },
3169 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7f, 0xff, 0xff, 0xff) },
3170 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff80, 0xff, 0xff, 0xff) },
3171 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff81, 0xff, 0xff, 0xff) },
3172 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff82, 0xff, 0xff, 0xff) },
3173 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff83, 0xff, 0xff, 0xff) },
3174 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff84, 0xff, 0xff, 0xff) },
3175 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff85, 0xff, 0xff, 0xff) },
3176 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff86, 0xff, 0xff, 0xff) },
3177 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff87, 0xff, 0xff, 0xff) },
3178 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff88, 0xff, 0xff, 0xff) },
3179 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff89, 0xff, 0xff, 0xff) },
3180 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8a, 0xff, 0xff, 0xff) },
3181 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) },
3182 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) },
3183 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
3184 @@ -1613,6 +1693,61 @@ static const struct usb_device_id option_ids[] = {
3185 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) },
3186 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
3187 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
3188 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff9f, 0xff, 0xff, 0xff) },
3189 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa0, 0xff, 0xff, 0xff) },
3190 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa1, 0xff, 0xff, 0xff) },
3191 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa2, 0xff, 0xff, 0xff) },
3192 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa3, 0xff, 0xff, 0xff) },
3193 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa4, 0xff, 0xff, 0xff) },
3194 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa5, 0xff, 0xff, 0xff) },
3195 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa6, 0xff, 0xff, 0xff) },
3196 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa7, 0xff, 0xff, 0xff) },
3197 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa8, 0xff, 0xff, 0xff) },
3198 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa9, 0xff, 0xff, 0xff) },
3199 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaa, 0xff, 0xff, 0xff) },
3200 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffab, 0xff, 0xff, 0xff) },
3201 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffac, 0xff, 0xff, 0xff) },
3202 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffae, 0xff, 0xff, 0xff) },
3203 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaf, 0xff, 0xff, 0xff) },
3204 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb0, 0xff, 0xff, 0xff) },
3205 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb1, 0xff, 0xff, 0xff) },
3206 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb2, 0xff, 0xff, 0xff) },
3207 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb3, 0xff, 0xff, 0xff) },
3208 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb4, 0xff, 0xff, 0xff) },
3209 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb5, 0xff, 0xff, 0xff) },
3210 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb6, 0xff, 0xff, 0xff) },
3211 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb7, 0xff, 0xff, 0xff) },
3212 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb8, 0xff, 0xff, 0xff) },
3213 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb9, 0xff, 0xff, 0xff) },
3214 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffba, 0xff, 0xff, 0xff) },
3215 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbb, 0xff, 0xff, 0xff) },
3216 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbc, 0xff, 0xff, 0xff) },
3217 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbd, 0xff, 0xff, 0xff) },
3218 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbe, 0xff, 0xff, 0xff) },
3219 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbf, 0xff, 0xff, 0xff) },
3220 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc0, 0xff, 0xff, 0xff) },
3221 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc1, 0xff, 0xff, 0xff) },
3222 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc2, 0xff, 0xff, 0xff) },
3223 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc3, 0xff, 0xff, 0xff) },
3224 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc4, 0xff, 0xff, 0xff) },
3225 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc5, 0xff, 0xff, 0xff) },
3226 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc6, 0xff, 0xff, 0xff) },
3227 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc7, 0xff, 0xff, 0xff) },
3228 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc8, 0xff, 0xff, 0xff) },
3229 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc9, 0xff, 0xff, 0xff) },
3230 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffca, 0xff, 0xff, 0xff) },
3231 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcb, 0xff, 0xff, 0xff) },
3232 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcc, 0xff, 0xff, 0xff) },
3233 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcd, 0xff, 0xff, 0xff) },
3234 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffce, 0xff, 0xff, 0xff) },
3235 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcf, 0xff, 0xff, 0xff) },
3236 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd0, 0xff, 0xff, 0xff) },
3237 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd1, 0xff, 0xff, 0xff) },
3238 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd2, 0xff, 0xff, 0xff) },
3239 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd3, 0xff, 0xff, 0xff) },
3240 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd4, 0xff, 0xff, 0xff) },
3241 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd5, 0xff, 0xff, 0xff) },
3242 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
3243 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffec, 0xff, 0xff, 0xff) },
3244 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffee, 0xff, 0xff, 0xff) },
3245 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff6, 0xff, 0xff, 0xff) },
3246 @@ -1712,7 +1847,13 @@ static const struct usb_device_id option_ids[] = {
3247 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) },
3248 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
3249 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
3250 - { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
3251 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_2RMNET, 0xff),
3252 + .driver_info = (kernel_ulong_t)&cinterion_rmnet2_blacklist },
3253 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_AUDIO, 0xff),
3254 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
3255 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },
3256 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) },
3257 + { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
3258 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
3259 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
3260 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
3261 diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
3262 index 2df8ad5ede89..85acb50a7ee2 100644
3263 --- a/drivers/usb/serial/quatech2.c
3264 +++ b/drivers/usb/serial/quatech2.c
3265 @@ -141,6 +141,7 @@ static void qt2_release(struct usb_serial *serial)
3266
3267 serial_priv = usb_get_serial_data(serial);
3268
3269 + usb_kill_urb(serial_priv->read_urb);
3270 usb_free_urb(serial_priv->read_urb);
3271 kfree(serial_priv->read_buffer);
3272 kfree(serial_priv);
3273 diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
3274 index 6467b91f2245..028618c5eeba 100644
3275 --- a/drivers/watchdog/sp5100_tco.c
3276 +++ b/drivers/watchdog/sp5100_tco.c
3277 @@ -73,6 +73,13 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started."
3278 /*
3279 * Some TCO specific functions
3280 */
3281 +
3282 +static bool tco_has_sp5100_reg_layout(struct pci_dev *dev)
3283 +{
3284 + return dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
3285 + dev->revision < 0x40;
3286 +}
3287 +
3288 static void tco_timer_start(void)
3289 {
3290 u32 val;
3291 @@ -129,7 +136,7 @@ static void tco_timer_enable(void)
3292 {
3293 int val;
3294
3295 - if (sp5100_tco_pci->revision >= 0x40) {
3296 + if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
3297 /* For SB800 or later */
3298 /* Set the Watchdog timer resolution to 1 sec */
3299 outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG);
3300 @@ -342,8 +349,7 @@ static unsigned char sp5100_tco_setupdevice(void)
3301 /*
3302 * Determine type of southbridge chipset.
3303 */
3304 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
3305 - sp5100_tco_pci->revision < 0x40) {
3306 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
3307 dev_name = SP5100_DEVNAME;
3308 index_reg = SP5100_IO_PM_INDEX_REG;
3309 data_reg = SP5100_IO_PM_DATA_REG;
3310 @@ -388,8 +394,7 @@ static unsigned char sp5100_tco_setupdevice(void)
3311 * Secondly, Find the watchdog timer MMIO address
3312 * from SBResource_MMIO register.
3313 */
3314 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
3315 - sp5100_tco_pci->revision < 0x40) {
3316 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
3317 /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */
3318 pci_read_config_dword(sp5100_tco_pci,
3319 SP5100_SB_RESOURCE_MMIO_BASE, &val);
3320 diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
3321 index e2c5abbb45ff..3595cffa24ea 100644
3322 --- a/drivers/watchdog/watchdog_dev.c
3323 +++ b/drivers/watchdog/watchdog_dev.c
3324 @@ -736,7 +736,6 @@ static int watchdog_release(struct inode *inode, struct file *file)
3325 watchdog_ping(wdd);
3326 }
3327
3328 - cancel_delayed_work_sync(&wd_data->work);
3329 watchdog_update_worker(wdd);
3330
3331 /* make sure that /dev/watchdog can be re-opened */
3332 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
3333 index 84a6a5b3384a..208d19938fdf 100644
3334 --- a/fs/btrfs/ctree.h
3335 +++ b/fs/btrfs/ctree.h
3336 @@ -4122,6 +4122,7 @@ void btrfs_test_inode_set_ops(struct inode *inode);
3337
3338 /* ioctl.c */
3339 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3340 +long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3341 int btrfs_ioctl_get_supported_features(void __user *arg);
3342 void btrfs_update_iflags(struct inode *inode);
3343 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3344 diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
3345 index 8d7b5a45c005..af5c7fa22e0e 100644
3346 --- a/fs/btrfs/file.c
3347 +++ b/fs/btrfs/file.c
3348 @@ -1596,6 +1596,13 @@ again:
3349
3350 copied = btrfs_copy_from_user(pos, write_bytes, pages, i);
3351
3352 + num_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
3353 + reserve_bytes);
3354 + dirty_sectors = round_up(copied + sector_offset,
3355 + root->sectorsize);
3356 + dirty_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
3357 + dirty_sectors);
3358 +
3359 /*
3360 * if we have trouble faulting in the pages, fall
3361 * back to one page at a time
3362 @@ -1605,6 +1612,7 @@ again:
3363
3364 if (copied == 0) {
3365 force_page_uptodate = true;
3366 + dirty_sectors = 0;
3367 dirty_pages = 0;
3368 } else {
3369 force_page_uptodate = false;
3370 @@ -1615,20 +1623,19 @@ again:
3371 /*
3372 * If we had a short copy we need to release the excess delaloc
3373 * bytes we reserved. We need to increment outstanding_extents
3374 - * because btrfs_delalloc_release_space will decrement it, but
3375 + * because btrfs_delalloc_release_space and
3376 + * btrfs_delalloc_release_metadata will decrement it, but
3377 * we still have an outstanding extent for the chunk we actually
3378 * managed to copy.
3379 */
3380 - num_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
3381 - reserve_bytes);
3382 - dirty_sectors = round_up(copied + sector_offset,
3383 - root->sectorsize);
3384 - dirty_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
3385 - dirty_sectors);
3386 -
3387 if (num_sectors > dirty_sectors) {
3388 - release_bytes = (write_bytes - copied)
3389 - & ~((u64)root->sectorsize - 1);
3390 + /*
3391 + * we round down because we don't want to count
3392 + * any partial blocks actually sent through the
3393 + * IO machines
3394 + */
3395 + release_bytes = round_down(release_bytes - copied,
3396 + root->sectorsize);
3397 if (copied > 0) {
3398 spin_lock(&BTRFS_I(inode)->lock);
3399 BTRFS_I(inode)->outstanding_extents++;
3400 @@ -2956,7 +2963,7 @@ const struct file_operations btrfs_file_operations = {
3401 .fallocate = btrfs_fallocate,
3402 .unlocked_ioctl = btrfs_ioctl,
3403 #ifdef CONFIG_COMPAT
3404 - .compat_ioctl = btrfs_ioctl,
3405 + .compat_ioctl = btrfs_compat_ioctl,
3406 #endif
3407 .copy_file_range = btrfs_copy_file_range,
3408 .clone_file_range = btrfs_clone_file_range,
3409 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
3410 index 2aaba58b4856..167fc3d49450 100644
3411 --- a/fs/btrfs/inode.c
3412 +++ b/fs/btrfs/inode.c
3413 @@ -10184,7 +10184,7 @@ static const struct file_operations btrfs_dir_file_operations = {
3414 .iterate = btrfs_real_readdir,
3415 .unlocked_ioctl = btrfs_ioctl,
3416 #ifdef CONFIG_COMPAT
3417 - .compat_ioctl = btrfs_ioctl,
3418 + .compat_ioctl = btrfs_compat_ioctl,
3419 #endif
3420 .release = btrfs_release_file,
3421 .fsync = btrfs_sync_file,
3422 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
3423 index 5a23806ae418..f545f81f642d 100644
3424 --- a/fs/btrfs/ioctl.c
3425 +++ b/fs/btrfs/ioctl.c
3426 @@ -5552,3 +5552,24 @@ long btrfs_ioctl(struct file *file, unsigned int
3427
3428 return -ENOTTY;
3429 }
3430 +
3431 +#ifdef CONFIG_COMPAT
3432 +long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3433 +{
3434 + switch (cmd) {
3435 + case FS_IOC32_GETFLAGS:
3436 + cmd = FS_IOC_GETFLAGS;
3437 + break;
3438 + case FS_IOC32_SETFLAGS:
3439 + cmd = FS_IOC_SETFLAGS;
3440 + break;
3441 + case FS_IOC32_GETVERSION:
3442 + cmd = FS_IOC_GETVERSION;
3443 + break;
3444 + default:
3445 + return -ENOIOCTLCMD;
3446 + }
3447 +
3448 + return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
3449 +}
3450 +#endif
3451 diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
3452 index 59727e32ed0f..af0ec2d5ad0e 100644
3453 --- a/fs/cifs/sess.c
3454 +++ b/fs/cifs/sess.c
3455 @@ -400,19 +400,27 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
3456 sec_blob->LmChallengeResponse.MaximumLength = 0;
3457
3458 sec_blob->NtChallengeResponse.BufferOffset = cpu_to_le32(tmp - pbuffer);
3459 - rc = setup_ntlmv2_rsp(ses, nls_cp);
3460 - if (rc) {
3461 - cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
3462 - goto setup_ntlmv2_ret;
3463 + if (ses->user_name != NULL) {
3464 + rc = setup_ntlmv2_rsp(ses, nls_cp);
3465 + if (rc) {
3466 + cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
3467 + goto setup_ntlmv2_ret;
3468 + }
3469 + memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3470 + ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3471 + tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3472 +
3473 + sec_blob->NtChallengeResponse.Length =
3474 + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3475 + sec_blob->NtChallengeResponse.MaximumLength =
3476 + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3477 + } else {
3478 + /*
3479 + * don't send an NT Response for anonymous access
3480 + */
3481 + sec_blob->NtChallengeResponse.Length = 0;
3482 + sec_blob->NtChallengeResponse.MaximumLength = 0;
3483 }
3484 - memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3485 - ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3486 - tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3487 -
3488 - sec_blob->NtChallengeResponse.Length =
3489 - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3490 - sec_blob->NtChallengeResponse.MaximumLength =
3491 - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3492
3493 if (ses->domainName == NULL) {
3494 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
3495 @@ -670,20 +678,24 @@ sess_auth_lanman(struct sess_data *sess_data)
3496
3497 pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
3498
3499 - /* no capabilities flags in old lanman negotiation */
3500 - pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3501 -
3502 - /* Calculate hash with password and copy into bcc_ptr.
3503 - * Encryption Key (stored as in cryptkey) gets used if the
3504 - * security mode bit in Negottiate Protocol response states
3505 - * to use challenge/response method (i.e. Password bit is 1).
3506 - */
3507 - rc = calc_lanman_hash(ses->password, ses->server->cryptkey,
3508 - ses->server->sec_mode & SECMODE_PW_ENCRYPT ?
3509 - true : false, lnm_session_key);
3510 -
3511 - memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
3512 - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3513 + if (ses->user_name != NULL) {
3514 + /* no capabilities flags in old lanman negotiation */
3515 + pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3516 +
3517 + /* Calculate hash with password and copy into bcc_ptr.
3518 + * Encryption Key (stored as in cryptkey) gets used if the
3519 + * security mode bit in Negottiate Protocol response states
3520 + * to use challenge/response method (i.e. Password bit is 1).
3521 + */
3522 + rc = calc_lanman_hash(ses->password, ses->server->cryptkey,
3523 + ses->server->sec_mode & SECMODE_PW_ENCRYPT ?
3524 + true : false, lnm_session_key);
3525 +
3526 + memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
3527 + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3528 + } else {
3529 + pSMB->old_req.PasswordLength = 0;
3530 + }
3531
3532 /*
3533 * can not sign if LANMAN negotiated so no need
3534 @@ -769,26 +781,31 @@ sess_auth_ntlm(struct sess_data *sess_data)
3535 capabilities = cifs_ssetup_hdr(ses, pSMB);
3536
3537 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
3538 - pSMB->req_no_secext.CaseInsensitivePasswordLength =
3539 - cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3540 - pSMB->req_no_secext.CaseSensitivePasswordLength =
3541 - cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3542 -
3543 - /* calculate ntlm response and session key */
3544 - rc = setup_ntlm_response(ses, sess_data->nls_cp);
3545 - if (rc) {
3546 - cifs_dbg(VFS, "Error %d during NTLM authentication\n",
3547 - rc);
3548 - goto out;
3549 - }
3550 + if (ses->user_name != NULL) {
3551 + pSMB->req_no_secext.CaseInsensitivePasswordLength =
3552 + cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3553 + pSMB->req_no_secext.CaseSensitivePasswordLength =
3554 + cpu_to_le16(CIFS_AUTH_RESP_SIZE);
3555 +
3556 + /* calculate ntlm response and session key */
3557 + rc = setup_ntlm_response(ses, sess_data->nls_cp);
3558 + if (rc) {
3559 + cifs_dbg(VFS, "Error %d during NTLM authentication\n",
3560 + rc);
3561 + goto out;
3562 + }
3563
3564 - /* copy ntlm response */
3565 - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3566 - CIFS_AUTH_RESP_SIZE);
3567 - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3568 - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3569 - CIFS_AUTH_RESP_SIZE);
3570 - bcc_ptr += CIFS_AUTH_RESP_SIZE;
3571 + /* copy ntlm response */
3572 + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3573 + CIFS_AUTH_RESP_SIZE);
3574 + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3575 + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3576 + CIFS_AUTH_RESP_SIZE);
3577 + bcc_ptr += CIFS_AUTH_RESP_SIZE;
3578 + } else {
3579 + pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
3580 + pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
3581 + }
3582
3583 if (ses->capabilities & CAP_UNICODE) {
3584 /* unicode strings must be word aligned */
3585 @@ -878,22 +895,26 @@ sess_auth_ntlmv2(struct sess_data *sess_data)
3586 /* LM2 password would be here if we supported it */
3587 pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
3588
3589 - /* calculate nlmv2 response and session key */
3590 - rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
3591 - if (rc) {
3592 - cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
3593 - goto out;
3594 - }
3595 + if (ses->user_name != NULL) {
3596 + /* calculate nlmv2 response and session key */
3597 + rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
3598 + if (rc) {
3599 + cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
3600 + goto out;
3601 + }
3602
3603 - memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3604 - ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3605 - bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3606 + memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
3607 + ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3608 + bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
3609
3610 - /* set case sensitive password length after tilen may get
3611 - * assigned, tilen is 0 otherwise.
3612 - */
3613 - pSMB->req_no_secext.CaseSensitivePasswordLength =
3614 - cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3615 + /* set case sensitive password length after tilen may get
3616 + * assigned, tilen is 0 otherwise.
3617 + */
3618 + pSMB->req_no_secext.CaseSensitivePasswordLength =
3619 + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
3620 + } else {
3621 + pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
3622 + }
3623
3624 if (ses->capabilities & CAP_UNICODE) {
3625 if (sess_data->iov[0].iov_len % 2) {
3626 diff --git a/fs/cifs/smb2glob.h b/fs/cifs/smb2glob.h
3627 index bc0bb9c34f72..0ffa18094335 100644
3628 --- a/fs/cifs/smb2glob.h
3629 +++ b/fs/cifs/smb2glob.h
3630 @@ -44,6 +44,7 @@
3631 #define SMB2_OP_DELETE 7
3632 #define SMB2_OP_HARDLINK 8
3633 #define SMB2_OP_SET_EOF 9
3634 +#define SMB2_OP_RMDIR 10
3635
3636 /* Used when constructing chained read requests. */
3637 #define CHAINED_REQUEST 1
3638 diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
3639 index 899bbc86f73e..4f0231e685a9 100644
3640 --- a/fs/cifs/smb2inode.c
3641 +++ b/fs/cifs/smb2inode.c
3642 @@ -80,6 +80,10 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
3643 * SMB2_open() call.
3644 */
3645 break;
3646 + case SMB2_OP_RMDIR:
3647 + tmprc = SMB2_rmdir(xid, tcon, fid.persistent_fid,
3648 + fid.volatile_fid);
3649 + break;
3650 case SMB2_OP_RENAME:
3651 tmprc = SMB2_rename(xid, tcon, fid.persistent_fid,
3652 fid.volatile_fid, (__le16 *)data);
3653 @@ -191,8 +195,8 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
3654 struct cifs_sb_info *cifs_sb)
3655 {
3656 return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
3657 - CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE,
3658 - NULL, SMB2_OP_DELETE);
3659 + CREATE_NOT_FILE,
3660 + NULL, SMB2_OP_RMDIR);
3661 }
3662
3663 int
3664 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
3665 index 42e1f440eb1e..8f38e33d365b 100644
3666 --- a/fs/cifs/smb2pdu.c
3667 +++ b/fs/cifs/smb2pdu.c
3668 @@ -2575,6 +2575,22 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
3669 }
3670
3671 int
3672 +SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
3673 + u64 persistent_fid, u64 volatile_fid)
3674 +{
3675 + __u8 delete_pending = 1;
3676 + void *data;
3677 + unsigned int size;
3678 +
3679 + data = &delete_pending;
3680 + size = 1; /* sizeof __u8 */
3681 +
3682 + return send_set_info(xid, tcon, persistent_fid, volatile_fid,
3683 + current->tgid, FILE_DISPOSITION_INFORMATION, 1, &data,
3684 + &size);
3685 +}
3686 +
3687 +int
3688 SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
3689 u64 persistent_fid, u64 volatile_fid, __le16 *target_file)
3690 {
3691 diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
3692 index 4f07dc93608d..eb2cde2f64ba 100644
3693 --- a/fs/cifs/smb2proto.h
3694 +++ b/fs/cifs/smb2proto.h
3695 @@ -141,6 +141,8 @@ extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
3696 extern int SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
3697 u64 persistent_fid, u64 volatile_fid,
3698 __le16 *target_file);
3699 +extern int SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
3700 + u64 persistent_fid, u64 volatile_fid);
3701 extern int SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
3702 u64 persistent_fid, u64 volatile_fid,
3703 __le16 *target_file);
3704 diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
3705 index 06f5aa478bf2..1ac263eddc4e 100644
3706 --- a/fs/crypto/keyinfo.c
3707 +++ b/fs/crypto/keyinfo.c
3708 @@ -78,6 +78,67 @@ out:
3709 return res;
3710 }
3711
3712 +static int validate_user_key(struct fscrypt_info *crypt_info,
3713 + struct fscrypt_context *ctx, u8 *raw_key,
3714 + u8 *prefix, int prefix_size)
3715 +{
3716 + u8 *full_key_descriptor;
3717 + struct key *keyring_key;
3718 + struct fscrypt_key *master_key;
3719 + const struct user_key_payload *ukp;
3720 + int full_key_len = prefix_size + (FS_KEY_DESCRIPTOR_SIZE * 2) + 1;
3721 + int res;
3722 +
3723 + full_key_descriptor = kmalloc(full_key_len, GFP_NOFS);
3724 + if (!full_key_descriptor)
3725 + return -ENOMEM;
3726 +
3727 + memcpy(full_key_descriptor, prefix, prefix_size);
3728 + sprintf(full_key_descriptor + prefix_size,
3729 + "%*phN", FS_KEY_DESCRIPTOR_SIZE,
3730 + ctx->master_key_descriptor);
3731 + full_key_descriptor[full_key_len - 1] = '\0';
3732 + keyring_key = request_key(&key_type_logon, full_key_descriptor, NULL);
3733 + kfree(full_key_descriptor);
3734 + if (IS_ERR(keyring_key))
3735 + return PTR_ERR(keyring_key);
3736 +
3737 + if (keyring_key->type != &key_type_logon) {
3738 + printk_once(KERN_WARNING
3739 + "%s: key type must be logon\n", __func__);
3740 + res = -ENOKEY;
3741 + goto out;
3742 + }
3743 + down_read(&keyring_key->sem);
3744 + ukp = user_key_payload(keyring_key);
3745 + if (ukp->datalen != sizeof(struct fscrypt_key)) {
3746 + res = -EINVAL;
3747 + up_read(&keyring_key->sem);
3748 + goto out;
3749 + }
3750 + master_key = (struct fscrypt_key *)ukp->data;
3751 + BUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);
3752 +
3753 + if (master_key->size != FS_AES_256_XTS_KEY_SIZE) {
3754 + printk_once(KERN_WARNING
3755 + "%s: key size incorrect: %d\n",
3756 + __func__, master_key->size);
3757 + res = -ENOKEY;
3758 + up_read(&keyring_key->sem);
3759 + goto out;
3760 + }
3761 + res = derive_key_aes(ctx->nonce, master_key->raw, raw_key);
3762 + up_read(&keyring_key->sem);
3763 + if (res)
3764 + goto out;
3765 +
3766 + crypt_info->ci_keyring_key = keyring_key;
3767 + return 0;
3768 +out:
3769 + key_put(keyring_key);
3770 + return res;
3771 +}
3772 +
3773 static void put_crypt_info(struct fscrypt_info *ci)
3774 {
3775 if (!ci)
3776 @@ -91,12 +152,7 @@ static void put_crypt_info(struct fscrypt_info *ci)
3777 int get_crypt_info(struct inode *inode)
3778 {
3779 struct fscrypt_info *crypt_info;
3780 - u8 full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE +
3781 - (FS_KEY_DESCRIPTOR_SIZE * 2) + 1];
3782 - struct key *keyring_key = NULL;
3783 - struct fscrypt_key *master_key;
3784 struct fscrypt_context ctx;
3785 - const struct user_key_payload *ukp;
3786 struct crypto_skcipher *ctfm;
3787 const char *cipher_str;
3788 u8 raw_key[FS_MAX_KEY_SIZE];
3789 @@ -167,48 +223,24 @@ retry:
3790 memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE);
3791 goto got_key;
3792 }
3793 - memcpy(full_key_descriptor, FS_KEY_DESC_PREFIX,
3794 - FS_KEY_DESC_PREFIX_SIZE);
3795 - sprintf(full_key_descriptor + FS_KEY_DESC_PREFIX_SIZE,
3796 - "%*phN", FS_KEY_DESCRIPTOR_SIZE,
3797 - ctx.master_key_descriptor);
3798 - full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE +
3799 - (2 * FS_KEY_DESCRIPTOR_SIZE)] = '\0';
3800 - keyring_key = request_key(&key_type_logon, full_key_descriptor, NULL);
3801 - if (IS_ERR(keyring_key)) {
3802 - res = PTR_ERR(keyring_key);
3803 - keyring_key = NULL;
3804 - goto out;
3805 - }
3806 - crypt_info->ci_keyring_key = keyring_key;
3807 - if (keyring_key->type != &key_type_logon) {
3808 - printk_once(KERN_WARNING
3809 - "%s: key type must be logon\n", __func__);
3810 - res = -ENOKEY;
3811 - goto out;
3812 - }
3813 - down_read(&keyring_key->sem);
3814 - ukp = user_key_payload(keyring_key);
3815 - if (ukp->datalen != sizeof(struct fscrypt_key)) {
3816 - res = -EINVAL;
3817 - up_read(&keyring_key->sem);
3818 - goto out;
3819 - }
3820 - master_key = (struct fscrypt_key *)ukp->data;
3821 - BUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);
3822
3823 - if (master_key->size != FS_AES_256_XTS_KEY_SIZE) {
3824 - printk_once(KERN_WARNING
3825 - "%s: key size incorrect: %d\n",
3826 - __func__, master_key->size);
3827 - res = -ENOKEY;
3828 - up_read(&keyring_key->sem);
3829 + res = validate_user_key(crypt_info, &ctx, raw_key,
3830 + FS_KEY_DESC_PREFIX, FS_KEY_DESC_PREFIX_SIZE);
3831 + if (res && inode->i_sb->s_cop->key_prefix) {
3832 + u8 *prefix = NULL;
3833 + int prefix_size, res2;
3834 +
3835 + prefix_size = inode->i_sb->s_cop->key_prefix(inode, &prefix);
3836 + res2 = validate_user_key(crypt_info, &ctx, raw_key,
3837 + prefix, prefix_size);
3838 + if (res2) {
3839 + if (res2 == -ENOKEY)
3840 + res = -ENOKEY;
3841 + goto out;
3842 + }
3843 + } else if (res) {
3844 goto out;
3845 }
3846 - res = derive_key_aes(ctx.nonce, master_key->raw, raw_key);
3847 - up_read(&keyring_key->sem);
3848 - if (res)
3849 - goto out;
3850 got_key:
3851 ctfm = crypto_alloc_skcipher(cipher_str, 0, 0);
3852 if (!ctfm || IS_ERR(ctfm)) {
3853 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
3854 index 7a4558d17f36..2effb79b5f3e 100644
3855 --- a/fs/f2fs/f2fs.h
3856 +++ b/fs/f2fs/f2fs.h
3857 @@ -680,6 +680,10 @@ enum {
3858 MAX_TIME,
3859 };
3860
3861 +#ifdef CONFIG_F2FS_FS_ENCRYPTION
3862 +#define F2FS_KEY_DESC_PREFIX "f2fs:"
3863 +#define F2FS_KEY_DESC_PREFIX_SIZE 5
3864 +#endif
3865 struct f2fs_sb_info {
3866 struct super_block *sb; /* pointer to VFS super block */
3867 struct proc_dir_entry *s_proc; /* proc entry */
3868 @@ -687,6 +691,10 @@ struct f2fs_sb_info {
3869 int valid_super_block; /* valid super block no */
3870 int s_flag; /* flags for sbi */
3871
3872 +#ifdef CONFIG_F2FS_FS_ENCRYPTION
3873 + u8 key_prefix[F2FS_KEY_DESC_PREFIX_SIZE];
3874 + u8 key_prefix_size;
3875 +#endif
3876 /* for node-related operations */
3877 struct f2fs_nm_info *nm_info; /* node manager */
3878 struct inode *node_inode; /* cache node blocks */
3879 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
3880 index 006f87d69921..e11385bbd4c6 100644
3881 --- a/fs/f2fs/super.c
3882 +++ b/fs/f2fs/super.c
3883 @@ -893,6 +893,12 @@ static int f2fs_get_context(struct inode *inode, void *ctx, size_t len)
3884 ctx, len, NULL);
3885 }
3886
3887 +static int f2fs_key_prefix(struct inode *inode, u8 **key)
3888 +{
3889 + *key = F2FS_I_SB(inode)->key_prefix;
3890 + return F2FS_I_SB(inode)->key_prefix_size;
3891 +}
3892 +
3893 static int f2fs_set_context(struct inode *inode, const void *ctx, size_t len,
3894 void *fs_data)
3895 {
3896 @@ -909,6 +915,7 @@ static unsigned f2fs_max_namelen(struct inode *inode)
3897
3898 static struct fscrypt_operations f2fs_cryptops = {
3899 .get_context = f2fs_get_context,
3900 + .key_prefix = f2fs_key_prefix,
3901 .set_context = f2fs_set_context,
3902 .is_encrypted = f2fs_encrypted_inode,
3903 .empty_dir = f2fs_empty_dir,
3904 @@ -1231,6 +1238,12 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
3905
3906 INIT_LIST_HEAD(&sbi->s_list);
3907 mutex_init(&sbi->umount_mutex);
3908 +
3909 +#ifdef CONFIG_F2FS_FS_ENCRYPTION
3910 + memcpy(sbi->key_prefix, F2FS_KEY_DESC_PREFIX,
3911 + F2FS_KEY_DESC_PREFIX_SIZE);
3912 + sbi->key_prefix_size = F2FS_KEY_DESC_PREFIX_SIZE;
3913 +#endif
3914 }
3915
3916 /*
3917 diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
3918 index 458cf463047b..82067ca22f2b 100644
3919 --- a/fs/hpfs/super.c
3920 +++ b/fs/hpfs/super.c
3921 @@ -15,6 +15,7 @@
3922 #include <linux/sched.h>
3923 #include <linux/bitmap.h>
3924 #include <linux/slab.h>
3925 +#include <linux/seq_file.h>
3926
3927 /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
3928
3929 @@ -453,10 +454,6 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
3930 int lowercase, eas, chk, errs, chkdsk, timeshift;
3931 int o;
3932 struct hpfs_sb_info *sbi = hpfs_sb(s);
3933 - char *new_opts = kstrdup(data, GFP_KERNEL);
3934 -
3935 - if (!new_opts)
3936 - return -ENOMEM;
3937
3938 sync_filesystem(s);
3939
3940 @@ -493,17 +490,44 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
3941
3942 if (!(*flags & MS_RDONLY)) mark_dirty(s, 1);
3943
3944 - replace_mount_options(s, new_opts);
3945 -
3946 hpfs_unlock(s);
3947 return 0;
3948
3949 out_err:
3950 hpfs_unlock(s);
3951 - kfree(new_opts);
3952 return -EINVAL;
3953 }
3954
3955 +static int hpfs_show_options(struct seq_file *seq, struct dentry *root)
3956 +{
3957 + struct hpfs_sb_info *sbi = hpfs_sb(root->d_sb);
3958 +
3959 + seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, sbi->sb_uid));
3960 + seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, sbi->sb_gid));
3961 + seq_printf(seq, ",umask=%03o", (~sbi->sb_mode & 0777));
3962 + if (sbi->sb_lowercase)
3963 + seq_printf(seq, ",case=lower");
3964 + if (!sbi->sb_chk)
3965 + seq_printf(seq, ",check=none");
3966 + if (sbi->sb_chk == 2)
3967 + seq_printf(seq, ",check=strict");
3968 + if (!sbi->sb_err)
3969 + seq_printf(seq, ",errors=continue");
3970 + if (sbi->sb_err == 2)
3971 + seq_printf(seq, ",errors=panic");
3972 + if (!sbi->sb_chkdsk)
3973 + seq_printf(seq, ",chkdsk=no");
3974 + if (sbi->sb_chkdsk == 2)
3975 + seq_printf(seq, ",chkdsk=always");
3976 + if (!sbi->sb_eas)
3977 + seq_printf(seq, ",eas=no");
3978 + if (sbi->sb_eas == 1)
3979 + seq_printf(seq, ",eas=ro");
3980 + if (sbi->sb_timeshift)
3981 + seq_printf(seq, ",timeshift=%d", sbi->sb_timeshift);
3982 + return 0;
3983 +}
3984 +
3985 /* Super operations */
3986
3987 static const struct super_operations hpfs_sops =
3988 @@ -514,7 +538,7 @@ static const struct super_operations hpfs_sops =
3989 .put_super = hpfs_put_super,
3990 .statfs = hpfs_statfs,
3991 .remount_fs = hpfs_remount_fs,
3992 - .show_options = generic_show_options,
3993 + .show_options = hpfs_show_options,
3994 };
3995
3996 static int hpfs_fill_super(struct super_block *s, void *options, int silent)
3997 @@ -537,8 +561,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
3998
3999 int o;
4000
4001 - save_mount_options(s, options);
4002 -
4003 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
4004 if (!sbi) {
4005 return -ENOMEM;
4006 diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
4007 index 618ced381a14..7c9fbf504f07 100644
4008 --- a/fs/nfs/callback_proc.c
4009 +++ b/fs/nfs/callback_proc.c
4010 @@ -500,8 +500,10 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
4011 cps->slot = slot;
4012
4013 /* The ca_maxresponsesize_cached is 0 with no DRC */
4014 - if (args->csa_cachethis != 0)
4015 - return htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE);
4016 + if (args->csa_cachethis != 0) {
4017 + status = htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE);
4018 + goto out_unlock;
4019 + }
4020
4021 /*
4022 * Check for pending referring calls. If a match is found, a
4023 diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
4024 index 35a52a880b2f..6bd05700d8c9 100644
4025 --- a/include/asm-generic/qspinlock.h
4026 +++ b/include/asm-generic/qspinlock.h
4027 @@ -28,7 +28,30 @@
4028 */
4029 static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
4030 {
4031 - return atomic_read(&lock->val);
4032 + /*
4033 + * queued_spin_lock_slowpath() can ACQUIRE the lock before
4034 + * issuing the unordered store that sets _Q_LOCKED_VAL.
4035 + *
4036 + * See both smp_cond_acquire() sites for more detail.
4037 + *
4038 + * This however means that in code like:
4039 + *
4040 + * spin_lock(A) spin_lock(B)
4041 + * spin_unlock_wait(B) spin_is_locked(A)
4042 + * do_something() do_something()
4043 + *
4044 + * Both CPUs can end up running do_something() because the store
4045 + * setting _Q_LOCKED_VAL will pass through the loads in
4046 + * spin_unlock_wait() and/or spin_is_locked().
4047 + *
4048 + * Avoid this by issuing a full memory barrier between the spin_lock()
4049 + * and the loads in spin_unlock_wait() and spin_is_locked().
4050 + *
4051 + * Note that regular mutual exclusion doesn't care about this
4052 + * delayed store.
4053 + */
4054 + smp_mb();
4055 + return atomic_read(&lock->val) & _Q_LOCKED_MASK;
4056 }
4057
4058 /**
4059 @@ -108,6 +131,8 @@ static __always_inline void queued_spin_unlock(struct qspinlock *lock)
4060 */
4061 static inline void queued_spin_unlock_wait(struct qspinlock *lock)
4062 {
4063 + /* See queued_spin_is_locked() */
4064 + smp_mb();
4065 while (atomic_read(&lock->val) & _Q_LOCKED_MASK)
4066 cpu_relax();
4067 }
4068 diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h
4069 index 3d1a3af5cf59..a2508a8f9a9c 100644
4070 --- a/include/asm-generic/siginfo.h
4071 +++ b/include/asm-generic/siginfo.h
4072 @@ -17,21 +17,6 @@
4073 struct siginfo;
4074 void do_schedule_next_timer(struct siginfo *info);
4075
4076 -#ifndef HAVE_ARCH_COPY_SIGINFO
4077 -
4078 -#include <linux/string.h>
4079 -
4080 -static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
4081 -{
4082 - if (from->si_code < 0)
4083 - memcpy(to, from, sizeof(*to));
4084 - else
4085 - /* _sigchld is currently the largest know union member */
4086 - memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
4087 -}
4088 -
4089 -#endif
4090 -
4091 extern int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
4092
4093 #endif
4094 diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
4095 index 735f9f8c4e43..5261751f6bd4 100644
4096 --- a/include/linux/can/dev.h
4097 +++ b/include/linux/can/dev.h
4098 @@ -40,8 +40,11 @@ struct can_priv {
4099 struct can_clock clock;
4100
4101 enum can_state state;
4102 - u32 ctrlmode;
4103 - u32 ctrlmode_supported;
4104 +
4105 + /* CAN controller features - see include/uapi/linux/can/netlink.h */
4106 + u32 ctrlmode; /* current options setting */
4107 + u32 ctrlmode_supported; /* options that can be modified by netlink */
4108 + u32 ctrlmode_static; /* static enabled options for driver/hardware */
4109
4110 int restart_ms;
4111 struct timer_list restart_timer;
4112 @@ -108,6 +111,21 @@ static inline bool can_is_canfd_skb(const struct sk_buff *skb)
4113 return skb->len == CANFD_MTU;
4114 }
4115
4116 +/* helper to define static CAN controller features at device creation time */
4117 +static inline void can_set_static_ctrlmode(struct net_device *dev,
4118 + u32 static_mode)
4119 +{
4120 + struct can_priv *priv = netdev_priv(dev);
4121 +
4122 + /* alloc_candev() succeeded => netdev_priv() is valid at this point */
4123 + priv->ctrlmode = static_mode;
4124 + priv->ctrlmode_static = static_mode;
4125 +
4126 + /* override MTU which was set by default in can_setup()? */
4127 + if (static_mode & CAN_CTRLMODE_FD)
4128 + dev->mtu = CANFD_MTU;
4129 +}
4130 +
4131 /* get data length from can_dlc with sanitized can_dlc */
4132 u8 can_dlc2len(u8 can_dlc);
4133
4134 diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h
4135 index 6027f6bbb061..cfa6cde25f8e 100644
4136 --- a/include/linux/fscrypto.h
4137 +++ b/include/linux/fscrypto.h
4138 @@ -175,6 +175,7 @@ struct fscrypt_name {
4139 */
4140 struct fscrypt_operations {
4141 int (*get_context)(struct inode *, void *, size_t);
4142 + int (*key_prefix)(struct inode *, u8 **);
4143 int (*prepare_context)(struct inode *);
4144 int (*set_context)(struct inode *, const void *, size_t, void *);
4145 int (*dummy_context)(struct inode *);
4146 diff --git a/include/linux/signal.h b/include/linux/signal.h
4147 index 92557bbce7e7..d80259afb9e5 100644
4148 --- a/include/linux/signal.h
4149 +++ b/include/linux/signal.h
4150 @@ -28,6 +28,21 @@ struct sigpending {
4151 sigset_t signal;
4152 };
4153
4154 +#ifndef HAVE_ARCH_COPY_SIGINFO
4155 +
4156 +#include <linux/string.h>
4157 +
4158 +static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
4159 +{
4160 + if (from->si_code < 0)
4161 + memcpy(to, from, sizeof(*to));
4162 + else
4163 + /* _sigchld is currently the largest know union member */
4164 + memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
4165 +}
4166 +
4167 +#endif
4168 +
4169 /*
4170 * Define some primitives to manipulate sigset_t.
4171 */
4172 diff --git a/include/linux/tty.h b/include/linux/tty.h
4173 index 3b09f235db66..a34442031aae 100644
4174 --- a/include/linux/tty.h
4175 +++ b/include/linux/tty.h
4176 @@ -338,7 +338,6 @@ struct tty_file_private {
4177 #define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */
4178 #define TTY_EXCLUSIVE 3 /* Exclusive open mode */
4179 #define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */
4180 -#define TTY_OTHER_DONE 6 /* Closed pty has completed input processing */
4181 #define TTY_LDISC_OPEN 11 /* Line discipline is open */
4182 #define TTY_PTY_LOCK 16 /* pty private */
4183 #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */
4184 @@ -457,6 +456,7 @@ extern void tty_buffer_init(struct tty_port *port);
4185 extern void tty_buffer_set_lock_subclass(struct tty_port *port);
4186 extern bool tty_buffer_restart_work(struct tty_port *port);
4187 extern bool tty_buffer_cancel_work(struct tty_port *port);
4188 +extern void tty_buffer_flush_work(struct tty_port *port);
4189 extern speed_t tty_termios_baud_rate(struct ktermios *termios);
4190 extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
4191 extern void tty_termios_encode_baud_rate(struct ktermios *termios,
4192 diff --git a/include/linux/usb.h b/include/linux/usb.h
4193 index 6a9a0c28415d..818bf7087996 100644
4194 --- a/include/linux/usb.h
4195 +++ b/include/linux/usb.h
4196 @@ -374,13 +374,12 @@ struct usb_bus {
4197
4198 int devnum_next; /* Next open device number in
4199 * round-robin allocation */
4200 + struct mutex devnum_next_mutex; /* devnum_next mutex */
4201
4202 struct usb_devmap devmap; /* device address allocation map */
4203 struct usb_device *root_hub; /* Root hub */
4204 struct usb_bus *hs_companion; /* Companion EHCI bus, if any */
4205
4206 - struct mutex usb_address0_mutex; /* unaddressed device mutex */
4207 -
4208 int bandwidth_allocated; /* on this bus: how much of the time
4209 * reserved for periodic (intr/iso)
4210 * requests is used, on average?
4211 @@ -1069,7 +1068,7 @@ struct usbdrv_wrap {
4212 * for interfaces bound to this driver.
4213 * @soft_unbind: if set to 1, the USB core will not kill URBs and disable
4214 * endpoints before calling the driver's disconnect method.
4215 - * @disable_hub_initiated_lpm: if set to 0, the USB core will not allow hubs
4216 + * @disable_hub_initiated_lpm: if set to 1, the USB core will not allow hubs
4217 * to initiate lower power link state transitions when an idle timeout
4218 * occurs. Device-initiated USB 3.0 link PM will still be allowed.
4219 *
4220 diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
4221 index b98f831dcda3..66fc13705ab7 100644
4222 --- a/include/linux/usb/hcd.h
4223 +++ b/include/linux/usb/hcd.h
4224 @@ -181,6 +181,7 @@ struct usb_hcd {
4225 * bandwidth_mutex should be dropped after a successful control message
4226 * to the device, or resetting the bandwidth after a failed attempt.
4227 */
4228 + struct mutex *address0_mutex;
4229 struct mutex *bandwidth_mutex;
4230 struct usb_hcd *shared_hcd;
4231 struct usb_hcd *primary_hcd;
4232 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
4233 index 74d79bde7075..a505079dcf88 100644
4234 --- a/include/scsi/scsi_device.h
4235 +++ b/include/scsi/scsi_device.h
4236 @@ -242,6 +242,7 @@ scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...);
4237 enum scsi_target_state {
4238 STARGET_CREATED = 1,
4239 STARGET_RUNNING,
4240 + STARGET_REMOVE,
4241 STARGET_DEL,
4242 };
4243
4244 diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c
4245 index ef7159012cf3..b0b93fd33af9 100644
4246 --- a/kernel/sched/loadavg.c
4247 +++ b/kernel/sched/loadavg.c
4248 @@ -99,10 +99,13 @@ long calc_load_fold_active(struct rq *this_rq)
4249 static unsigned long
4250 calc_load(unsigned long load, unsigned long exp, unsigned long active)
4251 {
4252 - load *= exp;
4253 - load += active * (FIXED_1 - exp);
4254 - load += 1UL << (FSHIFT - 1);
4255 - return load >> FSHIFT;
4256 + unsigned long newload;
4257 +
4258 + newload = load * exp + active * (FIXED_1 - exp);
4259 + if (active >= load)
4260 + newload += FIXED_1-1;
4261 +
4262 + return newload / FIXED_1;
4263 }
4264
4265 #ifdef CONFIG_NO_HZ_COMMON
4266 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
4267 index 95181e36891a..9c143739b8d7 100644
4268 --- a/kernel/trace/ring_buffer.c
4269 +++ b/kernel/trace/ring_buffer.c
4270 @@ -437,7 +437,7 @@ struct ring_buffer_per_cpu {
4271 raw_spinlock_t reader_lock; /* serialize readers */
4272 arch_spinlock_t lock;
4273 struct lock_class_key lock_key;
4274 - unsigned int nr_pages;
4275 + unsigned long nr_pages;
4276 unsigned int current_context;
4277 struct list_head *pages;
4278 struct buffer_page *head_page; /* read from head */
4279 @@ -458,7 +458,7 @@ struct ring_buffer_per_cpu {
4280 u64 write_stamp;
4281 u64 read_stamp;
4282 /* ring buffer pages to update, > 0 to add, < 0 to remove */
4283 - int nr_pages_to_update;
4284 + long nr_pages_to_update;
4285 struct list_head new_pages; /* new pages to add */
4286 struct work_struct update_pages_work;
4287 struct completion update_done;
4288 @@ -1128,10 +1128,10 @@ static int rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
4289 return 0;
4290 }
4291
4292 -static int __rb_allocate_pages(int nr_pages, struct list_head *pages, int cpu)
4293 +static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu)
4294 {
4295 - int i;
4296 struct buffer_page *bpage, *tmp;
4297 + long i;
4298
4299 for (i = 0; i < nr_pages; i++) {
4300 struct page *page;
4301 @@ -1168,7 +1168,7 @@ free_pages:
4302 }
4303
4304 static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
4305 - unsigned nr_pages)
4306 + unsigned long nr_pages)
4307 {
4308 LIST_HEAD(pages);
4309
4310 @@ -1193,7 +1193,7 @@ static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
4311 }
4312
4313 static struct ring_buffer_per_cpu *
4314 -rb_allocate_cpu_buffer(struct ring_buffer *buffer, int nr_pages, int cpu)
4315 +rb_allocate_cpu_buffer(struct ring_buffer *buffer, long nr_pages, int cpu)
4316 {
4317 struct ring_buffer_per_cpu *cpu_buffer;
4318 struct buffer_page *bpage;
4319 @@ -1293,8 +1293,9 @@ struct ring_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags,
4320 struct lock_class_key *key)
4321 {
4322 struct ring_buffer *buffer;
4323 + long nr_pages;
4324 int bsize;
4325 - int cpu, nr_pages;
4326 + int cpu;
4327
4328 /* keep it in its own cache line */
4329 buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()),
4330 @@ -1420,12 +1421,12 @@ static inline unsigned long rb_page_write(struct buffer_page *bpage)
4331 }
4332
4333 static int
4334 -rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
4335 +rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)
4336 {
4337 struct list_head *tail_page, *to_remove, *next_page;
4338 struct buffer_page *to_remove_page, *tmp_iter_page;
4339 struct buffer_page *last_page, *first_page;
4340 - unsigned int nr_removed;
4341 + unsigned long nr_removed;
4342 unsigned long head_bit;
4343 int page_entries;
4344
4345 @@ -1642,7 +1643,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
4346 int cpu_id)
4347 {
4348 struct ring_buffer_per_cpu *cpu_buffer;
4349 - unsigned nr_pages;
4350 + unsigned long nr_pages;
4351 int cpu, err = 0;
4352
4353 /*
4354 @@ -1656,14 +1657,13 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
4355 !cpumask_test_cpu(cpu_id, buffer->cpumask))
4356 return size;
4357
4358 - size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
4359 - size *= BUF_PAGE_SIZE;
4360 + nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
4361
4362 /* we need a minimum of two pages */
4363 - if (size < BUF_PAGE_SIZE * 2)
4364 - size = BUF_PAGE_SIZE * 2;
4365 + if (nr_pages < 2)
4366 + nr_pages = 2;
4367
4368 - nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
4369 + size = nr_pages * BUF_PAGE_SIZE;
4370
4371 /*
4372 * Don't succeed if resizing is disabled, as a reader might be
4373 @@ -4640,8 +4640,9 @@ static int rb_cpu_notify(struct notifier_block *self,
4374 struct ring_buffer *buffer =
4375 container_of(self, struct ring_buffer, cpu_notify);
4376 long cpu = (long)hcpu;
4377 - int cpu_i, nr_pages_same;
4378 - unsigned int nr_pages;
4379 + long nr_pages_same;
4380 + int cpu_i;
4381 + unsigned long nr_pages;
4382
4383 switch (action) {
4384 case CPU_UP_PREPARE:
4385 diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
4386 index f9e47a70509c..53449a6ff6aa 100644
4387 --- a/scripts/Makefile.extrawarn
4388 +++ b/scripts/Makefile.extrawarn
4389 @@ -24,6 +24,7 @@ warning-1 += $(call cc-option, -Wmissing-prototypes)
4390 warning-1 += -Wold-style-definition
4391 warning-1 += $(call cc-option, -Wmissing-include-dirs)
4392 warning-1 += $(call cc-option, -Wunused-but-set-variable)
4393 +warning-1 += $(call cc-option, -Wunused-const-variable)
4394 warning-1 += $(call cc-disable-warning, missing-field-initializers)
4395 warning-1 += $(call cc-disable-warning, sign-compare)
4396
4397 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4398 index 4918ffa5ba68..d53c25e7a1c1 100644
4399 --- a/sound/pci/hda/patch_realtek.c
4400 +++ b/sound/pci/hda/patch_realtek.c
4401 @@ -335,6 +335,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
4402 case 0x10ec0283:
4403 case 0x10ec0286:
4404 case 0x10ec0288:
4405 + case 0x10ec0295:
4406 case 0x10ec0298:
4407 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
4408 break;
4409 @@ -342,6 +343,11 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
4410 case 0x10ec0293:
4411 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
4412 break;
4413 + case 0x10ec0234:
4414 + case 0x10ec0274:
4415 + case 0x10ec0294:
4416 + alc_update_coef_idx(codec, 0x10, 1<<15, 0);
4417 + break;
4418 case 0x10ec0662:
4419 if ((coef & 0x00f0) == 0x0030)
4420 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
4421 @@ -902,6 +908,7 @@ static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
4422 { 0x10ec0298, 0x1028, 0, "ALC3266" },
4423 { 0x10ec0256, 0x1028, 0, "ALC3246" },
4424 { 0x10ec0225, 0x1028, 0, "ALC3253" },
4425 + { 0x10ec0295, 0x1028, 0, "ALC3254" },
4426 { 0x10ec0670, 0x1025, 0, "ALC669X" },
4427 { 0x10ec0676, 0x1025, 0, "ALC679X" },
4428 { 0x10ec0282, 0x1043, 0, "ALC3229" },
4429 @@ -2647,6 +2654,7 @@ enum {
4430 ALC269_TYPE_ALC255,
4431 ALC269_TYPE_ALC256,
4432 ALC269_TYPE_ALC225,
4433 + ALC269_TYPE_ALC294,
4434 };
4435
4436 /*
4437 @@ -2677,6 +2685,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
4438 case ALC269_TYPE_ALC255:
4439 case ALC269_TYPE_ALC256:
4440 case ALC269_TYPE_ALC225:
4441 + case ALC269_TYPE_ALC294:
4442 ssids = alc269_ssids;
4443 break;
4444 default:
4445 @@ -3690,6 +3699,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
4446 alc_process_coef_fw(codec, coef0668);
4447 break;
4448 case 0x10ec0225:
4449 + case 0x10ec0295:
4450 alc_process_coef_fw(codec, coef0225);
4451 break;
4452 }
4453 @@ -3790,6 +3800,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4454 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4455 break;
4456 case 0x10ec0225:
4457 + case 0x10ec0295:
4458 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4459 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4460 alc_process_coef_fw(codec, coef0225);
4461 @@ -3847,6 +3858,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
4462
4463 switch (codec->core.vendor_id) {
4464 case 0x10ec0225:
4465 + case 0x10ec0295:
4466 alc_process_coef_fw(codec, coef0225);
4467 break;
4468 case 0x10ec0255:
4469 @@ -3950,6 +3962,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
4470 alc_process_coef_fw(codec, coef0688);
4471 break;
4472 case 0x10ec0225:
4473 + case 0x10ec0295:
4474 alc_process_coef_fw(codec, coef0225);
4475 break;
4476 }
4477 @@ -4031,6 +4044,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
4478 alc_process_coef_fw(codec, coef0688);
4479 break;
4480 case 0x10ec0225:
4481 + case 0x10ec0295:
4482 alc_process_coef_fw(codec, coef0225);
4483 break;
4484 }
4485 @@ -4114,6 +4128,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
4486 is_ctia = (val & 0x1c02) == 0x1c02;
4487 break;
4488 case 0x10ec0225:
4489 + case 0x10ec0295:
4490 alc_process_coef_fw(codec, coef0225);
4491 msleep(800);
4492 val = alc_read_coef_idx(codec, 0x46);
4493 @@ -5459,8 +5474,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4494 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
4495 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
4496 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
4497 - SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
4498 + SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
4499 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
4500 + SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
4501 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4502 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4503 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
4504 @@ -5704,6 +5720,9 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
4505 {0x14, 0x90170110},
4506 {0x21, 0x02211020}),
4507 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
4508 + {0x14, 0x90170130},
4509 + {0x21, 0x02211040}),
4510 + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
4511 {0x12, 0x90a60140},
4512 {0x14, 0x90170110},
4513 {0x21, 0x02211020}),
4514 @@ -6026,8 +6045,14 @@ static int patch_alc269(struct hda_codec *codec)
4515 alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
4516 break;
4517 case 0x10ec0225:
4518 + case 0x10ec0295:
4519 spec->codec_variant = ALC269_TYPE_ALC225;
4520 break;
4521 + case 0x10ec0234:
4522 + case 0x10ec0274:
4523 + case 0x10ec0294:
4524 + spec->codec_variant = ALC269_TYPE_ALC294;
4525 + break;
4526 }
4527
4528 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
4529 @@ -6942,6 +6967,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
4530 HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
4531 HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
4532 HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
4533 + HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
4534 HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
4535 HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
4536 HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
4537 @@ -6952,6 +6978,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
4538 HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
4539 HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
4540 HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
4541 + HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
4542 HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
4543 HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
4544 HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
4545 @@ -6964,6 +6991,8 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
4546 HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
4547 HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
4548 HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
4549 + HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
4550 + HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
4551 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
4552 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
4553 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
4554 diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
4555 index 6765c7e949f3..f094f3c4ed84 100644
4556 --- a/tools/objtool/Makefile
4557 +++ b/tools/objtool/Makefile
4558 @@ -30,6 +30,10 @@ INCLUDES := -I$(srctree)/tools/include
4559 CFLAGS += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
4560 LDFLAGS += -lelf $(LIBSUBCMD)
4561
4562 +# Allow old libelf to be used:
4563 +elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
4564 +CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
4565 +
4566 AWK = awk
4567 export srctree OUTPUT CFLAGS ARCH AWK
4568 include $(srctree)/tools/build/Makefile.include
4569 diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
4570 index 7f3e00a2f907..aa1ff6596684 100644
4571 --- a/tools/objtool/elf.h
4572 +++ b/tools/objtool/elf.h
4573 @@ -23,6 +23,11 @@
4574 #include <linux/list.h>
4575 #include <linux/hashtable.h>
4576
4577 +#ifdef LIBELF_USE_DEPRECATED
4578 +# define elf_getshdrnum elf_getshnum
4579 +# define elf_getshdrstrndx elf_getshstrndx
4580 +#endif
4581 +
4582 struct section {
4583 struct list_head list;
4584 GElf_Shdr sh;