Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.4/0119-4.4.20-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2828 - (hide annotations) (download)
Tue Sep 13 07:18:33 2016 UTC (7 years, 8 months ago) by niro
File size: 125438 byte(s)
-linux-4.4.20
1 niro 2828 diff --git a/Makefile b/Makefile
2     index 695c64ec160c..b74d60081a16 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 4
8     -SUBLEVEL = 19
9     +SUBLEVEL = 20
10     EXTRAVERSION =
11     NAME = Blurry Fish Butt
12    
13     diff --git a/arch/arc/Makefile b/arch/arc/Makefile
14     index 209d8451e23d..c05ea2b54276 100644
15     --- a/arch/arc/Makefile
16     +++ b/arch/arc/Makefile
17     @@ -18,6 +18,20 @@ cflags-y += -fno-common -pipe -fno-builtin -D__linux__
18     cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
19     cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
20    
21     +is_700 = $(shell $(CC) -dM -E - < /dev/null | grep -q "ARC700" && echo 1 || echo 0)
22     +
23     +ifdef CONFIG_ISA_ARCOMPACT
24     +ifeq ($(is_700), 0)
25     + $(error Toolchain not configured for ARCompact builds)
26     +endif
27     +endif
28     +
29     +ifdef CONFIG_ISA_ARCV2
30     +ifeq ($(is_700), 1)
31     + $(error Toolchain not configured for ARCv2 builds)
32     +endif
33     +endif
34     +
35     ifdef CONFIG_ARC_CURR_IN_REG
36     # For a global register defintion, make sure it gets passed to every file
37     # We had a customer reported bug where some code built in kernel was NOT using
38     diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
39     index 7fac7d85ed6a..2c30a016cf15 100644
40     --- a/arch/arc/include/asm/arcregs.h
41     +++ b/arch/arc/include/asm/arcregs.h
42     @@ -374,12 +374,6 @@ static inline int is_isa_arcompact(void)
43     return IS_ENABLED(CONFIG_ISA_ARCOMPACT);
44     }
45    
46     -#if defined(CONFIG_ISA_ARCOMPACT) && !defined(_CPU_DEFAULT_A7)
47     -#error "Toolchain not configured for ARCompact builds"
48     -#elif defined(CONFIG_ISA_ARCV2) && !defined(_CPU_DEFAULT_HS)
49     -#error "Toolchain not configured for ARCv2 builds"
50     -#endif
51     -
52     #endif /* __ASEMBLY__ */
53    
54     #endif /* _ASM_ARC_ARCREGS_H */
55     diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
56     index ad7860c5ce15..51597f344a62 100644
57     --- a/arch/arc/include/asm/entry.h
58     +++ b/arch/arc/include/asm/entry.h
59     @@ -142,7 +142,7 @@
60    
61     #ifdef CONFIG_ARC_CURR_IN_REG
62     ; Retrieve orig r25 and save it with rest of callee_regs
63     - ld.as r12, [r12, PT_user_r25]
64     + ld r12, [r12, PT_user_r25]
65     PUSH r12
66     #else
67     PUSH r25
68     @@ -198,7 +198,7 @@
69    
70     ; SP is back to start of pt_regs
71     #ifdef CONFIG_ARC_CURR_IN_REG
72     - st.as r12, [sp, PT_user_r25]
73     + st r12, [sp, PT_user_r25]
74     #endif
75     .endm
76    
77     diff --git a/arch/arc/include/asm/irqflags-compact.h b/arch/arc/include/asm/irqflags-compact.h
78     index c1d36458bfb7..4c6eed80cd8b 100644
79     --- a/arch/arc/include/asm/irqflags-compact.h
80     +++ b/arch/arc/include/asm/irqflags-compact.h
81     @@ -188,10 +188,10 @@ static inline int arch_irqs_disabled(void)
82     .endm
83    
84     .macro IRQ_ENABLE scratch
85     + TRACE_ASM_IRQ_ENABLE
86     lr \scratch, [status32]
87     or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
88     flag \scratch
89     - TRACE_ASM_IRQ_ENABLE
90     .endm
91    
92     #endif /* __ASSEMBLY__ */
93     diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
94     index ff7ff6cbb811..aaf1e2d1d900 100644
95     --- a/arch/arc/mm/cache.c
96     +++ b/arch/arc/mm/cache.c
97     @@ -914,6 +914,15 @@ void arc_cache_init(void)
98    
99     printk(arc_cache_mumbojumbo(0, str, sizeof(str)));
100    
101     + /*
102     + * Only master CPU needs to execute rest of function:
103     + * - Assume SMP so all cores will have same cache config so
104     + * any geomtry checks will be same for all
105     + * - IOC setup / dma callbacks only need to be setup once
106     + */
107     + if (cpu)
108     + return;
109     +
110     if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) {
111     struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache;
112    
113     diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
114     index 8fe39e1b680e..e0ee2b00d573 100644
115     --- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
116     +++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
117     @@ -262,6 +262,8 @@
118     #io-channel-cells = <1>;
119     clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
120     clock-names = "saradc", "apb_pclk";
121     + resets = <&cru SRST_SARADC>;
122     + reset-names = "saradc-apb";
123     status = "disabled";
124     };
125    
126     diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
127     index bc6492b9a924..44dd892a4bbe 100644
128     --- a/arch/arm64/include/asm/elf.h
129     +++ b/arch/arm64/include/asm/elf.h
130     @@ -136,6 +136,7 @@ typedef struct user_fpsimd_state elf_fpregset_t;
131    
132     #define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT);
133    
134     +/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
135     #define ARCH_DLINFO \
136     do { \
137     NEW_AUX_ENT(AT_SYSINFO_EHDR, \
138     diff --git a/arch/arm64/include/uapi/asm/auxvec.h b/arch/arm64/include/uapi/asm/auxvec.h
139     index 22d6d8885854..4cf0c17787a8 100644
140     --- a/arch/arm64/include/uapi/asm/auxvec.h
141     +++ b/arch/arm64/include/uapi/asm/auxvec.h
142     @@ -19,4 +19,6 @@
143     /* vDSO location */
144     #define AT_SYSINFO_EHDR 33
145    
146     +#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */
147     +
148     #endif
149     diff --git a/arch/parisc/include/uapi/asm/errno.h b/arch/parisc/include/uapi/asm/errno.h
150     index c0ae62520d15..274d5bc6ecce 100644
151     --- a/arch/parisc/include/uapi/asm/errno.h
152     +++ b/arch/parisc/include/uapi/asm/errno.h
153     @@ -97,10 +97,10 @@
154     #define ENOTCONN 235 /* Transport endpoint is not connected */
155     #define ESHUTDOWN 236 /* Cannot send after transport endpoint shutdown */
156     #define ETOOMANYREFS 237 /* Too many references: cannot splice */
157     -#define EREFUSED ECONNREFUSED /* for HP's NFS apparently */
158     #define ETIMEDOUT 238 /* Connection timed out */
159     #define ECONNREFUSED 239 /* Connection refused */
160     -#define EREMOTERELEASE 240 /* Remote peer released connection */
161     +#define EREFUSED ECONNREFUSED /* for HP's NFS apparently */
162     +#define EREMOTERELEASE 240 /* Remote peer released connection */
163     #define EHOSTDOWN 241 /* Host is down */
164     #define EHOSTUNREACH 242 /* No route to host */
165    
166     diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
167     index b34e8a54f7db..98949b0df00a 100644
168     --- a/arch/powerpc/kernel/eeh.c
169     +++ b/arch/powerpc/kernel/eeh.c
170     @@ -677,7 +677,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)
171     /* Check if the request is finished successfully */
172     if (active_flag) {
173     rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC);
174     - if (rc <= 0)
175     + if (rc < 0)
176     return rc;
177    
178     if (rc & active_flag)
179     diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
180     index 1dd5bd8a8c59..133055311dce 100644
181     --- a/arch/um/include/asm/common.lds.S
182     +++ b/arch/um/include/asm/common.lds.S
183     @@ -81,7 +81,7 @@
184     .altinstr_replacement : { *(.altinstr_replacement) }
185     /* .exit.text is discard at runtime, not link time, to deal with references
186     from .altinstructions and .eh_frame */
187     - .exit.text : { *(.exit.text) }
188     + .exit.text : { EXIT_TEXT }
189     .exit.data : { *(.exit.data) }
190    
191     .preinit_array : {
192     diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
193     index 6df2029405a3..3142218e546f 100644
194     --- a/arch/x86/include/asm/tlbflush.h
195     +++ b/arch/x86/include/asm/tlbflush.h
196     @@ -86,7 +86,14 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
197    
198     static inline void __native_flush_tlb(void)
199     {
200     + /*
201     + * If current->mm == NULL then we borrow a mm which may change during a
202     + * task switch and therefore we must not be preempted while we write CR3
203     + * back:
204     + */
205     + preempt_disable();
206     native_write_cr3(native_read_cr3());
207     + preempt_enable();
208     }
209    
210     static inline void __native_flush_tlb_global_irq_disabled(void)
211     diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
212     index bf4db6eaec8f..c6aace2bbe08 100644
213     --- a/arch/x86/kernel/uprobes.c
214     +++ b/arch/x86/kernel/uprobes.c
215     @@ -357,20 +357,22 @@ static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn)
216     *cursor &= 0xfe;
217     }
218     /*
219     - * Similar treatment for VEX3 prefix.
220     - * TODO: add XOP/EVEX treatment when insn decoder supports them
221     + * Similar treatment for VEX3/EVEX prefix.
222     + * TODO: add XOP treatment when insn decoder supports them
223     */
224     - if (insn->vex_prefix.nbytes == 3) {
225     + if (insn->vex_prefix.nbytes >= 3) {
226     /*
227     * vex2: c5 rvvvvLpp (has no b bit)
228     * vex3/xop: c4/8f rxbmmmmm wvvvvLpp
229     * evex: 62 rxbR00mm wvvvv1pp zllBVaaa
230     - * (evex will need setting of both b and x since
231     - * in non-sib encoding evex.x is 4th bit of MODRM.rm)
232     - * Setting VEX3.b (setting because it has inverted meaning):
233     + * Setting VEX3.b (setting because it has inverted meaning).
234     + * Setting EVEX.x since (in non-SIB encoding) EVEX.x
235     + * is the 4th bit of MODRM.rm, and needs the same treatment.
236     + * For VEX3-encoded insns, VEX3.x value has no effect in
237     + * non-SIB encoding, the change is superfluous but harmless.
238     */
239     cursor = auprobe->insn + insn_offset_vex_prefix(insn) + 1;
240     - *cursor |= 0x20;
241     + *cursor |= 0x60;
242     }
243    
244     /*
245     @@ -415,12 +417,10 @@ static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn)
246    
247     reg = MODRM_REG(insn); /* Fetch modrm.reg */
248     reg2 = 0xff; /* Fetch vex.vvvv */
249     - if (insn->vex_prefix.nbytes == 2)
250     - reg2 = insn->vex_prefix.bytes[1];
251     - else if (insn->vex_prefix.nbytes == 3)
252     + if (insn->vex_prefix.nbytes)
253     reg2 = insn->vex_prefix.bytes[2];
254     /*
255     - * TODO: add XOP, EXEV vvvv reading.
256     + * TODO: add XOP vvvv reading.
257     *
258     * vex.vvvv field is in bits 6-3, bits are inverted.
259     * But in 32-bit mode, high-order bit may be ignored.
260     diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
261     index 6730f965b379..0afd1981e350 100644
262     --- a/drivers/acpi/cppc_acpi.c
263     +++ b/drivers/acpi/cppc_acpi.c
264     @@ -216,8 +216,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data)
265     continue;
266    
267     cpc_ptr = per_cpu(cpc_desc_ptr, i);
268     - if (!cpc_ptr)
269     - continue;
270     + if (!cpc_ptr) {
271     + retval = -EFAULT;
272     + goto err_ret;
273     + }
274    
275     pdomain = &(cpc_ptr->domain_info);
276     cpumask_set_cpu(i, pr->shared_cpu_map);
277     @@ -239,8 +241,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data)
278     continue;
279    
280     match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
281     - if (!match_cpc_ptr)
282     - continue;
283     + if (!match_cpc_ptr) {
284     + retval = -EFAULT;
285     + goto err_ret;
286     + }
287    
288     match_pdomain = &(match_cpc_ptr->domain_info);
289     if (match_pdomain->domain != pdomain->domain)
290     @@ -270,8 +274,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data)
291     continue;
292    
293     match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
294     - if (!match_cpc_ptr)
295     - continue;
296     + if (!match_cpc_ptr) {
297     + retval = -EFAULT;
298     + goto err_ret;
299     + }
300    
301     match_pdomain = &(match_cpc_ptr->domain_info);
302     if (match_pdomain->domain != pdomain->domain)
303     @@ -502,9 +508,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
304     /* Store CPU Logical ID */
305     cpc_ptr->cpu_id = pr->id;
306    
307     - /* Plug it into this CPUs CPC descriptor. */
308     - per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr;
309     -
310     /* Parse PSD data for this CPU */
311     ret = acpi_get_psd(cpc_ptr, handle);
312     if (ret)
313     @@ -517,6 +520,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
314     goto out_free;
315     }
316    
317     + /* Plug PSD data into this CPUs CPC descriptor. */
318     + per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr;
319     +
320     /* Everything looks okay */
321     pr_debug("Parsed CPC struct for CPU: %d\n", pr->id);
322    
323     diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
324     index 11d8209e6e5d..5230e8449d30 100644
325     --- a/drivers/acpi/nfit.c
326     +++ b/drivers/acpi/nfit.c
327     @@ -1072,11 +1072,12 @@ static u32 read_blk_stat(struct nfit_blk *nfit_blk, unsigned int bw)
328     {
329     struct nfit_blk_mmio *mmio = &nfit_blk->mmio[DCR];
330     u64 offset = nfit_blk->stat_offset + mmio->size * bw;
331     + const u32 STATUS_MASK = 0x80000037;
332    
333     if (mmio->num_lines)
334     offset = to_interleave_offset(offset, mmio);
335    
336     - return readl(mmio->addr.base + offset);
337     + return readl(mmio->addr.base + offset) & STATUS_MASK;
338     }
339    
340     static void write_blk_ctl(struct nfit_blk *nfit_blk, unsigned int bw,
341     diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
342     index 72b6e9ef0ae9..d176e0ece470 100644
343     --- a/drivers/acpi/numa.c
344     +++ b/drivers/acpi/numa.c
345     @@ -327,10 +327,18 @@ int __init acpi_numa_init(void)
346    
347     /* SRAT: Static Resource Affinity Table */
348     if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
349     - acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY,
350     - acpi_parse_x2apic_affinity, 0);
351     - acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
352     - acpi_parse_processor_affinity, 0);
353     + struct acpi_subtable_proc srat_proc[2];
354     +
355     + memset(srat_proc, 0, sizeof(srat_proc));
356     + srat_proc[0].id = ACPI_SRAT_TYPE_CPU_AFFINITY;
357     + srat_proc[0].handler = acpi_parse_processor_affinity;
358     + srat_proc[1].id = ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY;
359     + srat_proc[1].handler = acpi_parse_x2apic_affinity;
360     +
361     + acpi_table_parse_entries_array(ACPI_SIG_SRAT,
362     + sizeof(struct acpi_table_srat),
363     + srat_proc, ARRAY_SIZE(srat_proc), 0);
364     +
365     cnt = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
366     acpi_parse_memory_affinity,
367     NR_NODE_MEMBLKS);
368     diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
369     index 78d5f02a073b..dcb3d6245ca5 100644
370     --- a/drivers/acpi/scan.c
371     +++ b/drivers/acpi/scan.c
372     @@ -1958,7 +1958,7 @@ int __init acpi_scan_init(void)
373    
374     static struct acpi_probe_entry *ape;
375     static int acpi_probe_count;
376     -static DEFINE_SPINLOCK(acpi_probe_lock);
377     +static DEFINE_MUTEX(acpi_probe_mutex);
378    
379     static int __init acpi_match_madt(struct acpi_subtable_header *header,
380     const unsigned long end)
381     @@ -1977,7 +1977,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
382     if (acpi_disabled)
383     return 0;
384    
385     - spin_lock(&acpi_probe_lock);
386     + mutex_lock(&acpi_probe_mutex);
387     for (ape = ap_head; nr; ape++, nr--) {
388     if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
389     acpi_probe_count = 0;
390     @@ -1990,7 +1990,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
391     count++;
392     }
393     }
394     - spin_unlock(&acpi_probe_lock);
395     + mutex_unlock(&acpi_probe_mutex);
396    
397     return count;
398     }
399     diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
400     index 0243d375c6fd..4b3a9e27f1b6 100644
401     --- a/drivers/acpi/sysfs.c
402     +++ b/drivers/acpi/sysfs.c
403     @@ -555,23 +555,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
404     static int get_status(u32 index, acpi_event_status *status,
405     acpi_handle *handle)
406     {
407     - int result = 0;
408     + int result;
409    
410     if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
411     - goto end;
412     + return -EINVAL;
413    
414     if (index < num_gpes) {
415     result = acpi_get_gpe_device(index, handle);
416     if (result) {
417     ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
418     "Invalid GPE 0x%x", index));
419     - goto end;
420     + return result;
421     }
422     result = acpi_get_gpe_status(*handle, index, status);
423     } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
424     result = acpi_get_event_status(index - num_gpes, status);
425    
426     -end:
427     return result;
428     }
429    
430     diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
431     index ea8189f4b021..6dc597126b79 100644
432     --- a/drivers/crypto/caam/caamalg.c
433     +++ b/drivers/crypto/caam/caamalg.c
434     @@ -441,6 +441,9 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
435     OP_ALG_AAI_CTR_MOD128);
436     const bool is_rfc3686 = alg->caam.rfc3686;
437    
438     + if (!ctx->authsize)
439     + return 0;
440     +
441     /* NULL encryption / decryption */
442     if (!ctx->enckeylen)
443     return aead_null_set_sh_desc(aead);
444     @@ -614,7 +617,7 @@ skip_enc:
445     keys_fit_inline = true;
446    
447     /* aead_givencrypt shared descriptor */
448     - desc = ctx->sh_desc_givenc;
449     + desc = ctx->sh_desc_enc;
450    
451     /* Note: Context registers are saved. */
452     init_sh_desc_key_aead(desc, ctx, keys_fit_inline, is_rfc3686);
453     @@ -645,13 +648,13 @@ copy_iv:
454     append_operation(desc, ctx->class2_alg_type |
455     OP_ALG_AS_INITFINAL | OP_ALG_ENCRYPT);
456    
457     - /* ivsize + cryptlen = seqoutlen - authsize */
458     - append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize);
459     -
460     /* Read and write assoclen bytes */
461     append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ);
462     append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ);
463    
464     + /* ivsize + cryptlen = seqoutlen - authsize */
465     + append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize);
466     +
467     /* Skip assoc data */
468     append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF);
469    
470     @@ -697,7 +700,7 @@ copy_iv:
471     ctx->sh_desc_enc_dma = dma_map_single(jrdev, desc,
472     desc_bytes(desc),
473     DMA_TO_DEVICE);
474     - if (dma_mapping_error(jrdev, ctx->sh_desc_givenc_dma)) {
475     + if (dma_mapping_error(jrdev, ctx->sh_desc_enc_dma)) {
476     dev_err(jrdev, "unable to map shared descriptor\n");
477     return -ENOMEM;
478     }
479     diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
480     index 49106ea42887..99d5e11db194 100644
481     --- a/drivers/crypto/caam/caamhash.c
482     +++ b/drivers/crypto/caam/caamhash.c
483     @@ -1873,6 +1873,7 @@ caam_hash_alloc(struct caam_hash_template *template,
484     template->name);
485     snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
486     template->driver_name);
487     + t_alg->ahash_alg.setkey = NULL;
488     }
489     alg->cra_module = THIS_MODULE;
490     alg->cra_init = caam_hash_cra_init;
491     diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
492     index 0794f1cc0018..42f0f229f7f7 100644
493     --- a/drivers/crypto/nx/nx.c
494     +++ b/drivers/crypto/nx/nx.c
495     @@ -392,7 +392,7 @@ static void nx_of_update_msc(struct device *dev,
496     ((bytes_so_far + sizeof(struct msc_triplet)) <= lenp) &&
497     i < msc->triplets;
498     i++) {
499     - if (msc->fc > NX_MAX_FC || msc->mode > NX_MAX_MODE) {
500     + if (msc->fc >= NX_MAX_FC || msc->mode >= NX_MAX_MODE) {
501     dev_err(dev, "unknown function code/mode "
502     "combo: %d/%d (ignored)\n", msc->fc,
503     msc->mode);
504     diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
505     index 59e4c3af15ed..367b6661ee04 100644
506     --- a/drivers/crypto/qat/qat_common/qat_algs.c
507     +++ b/drivers/crypto/qat/qat_common/qat_algs.c
508     @@ -1262,8 +1262,8 @@ static struct crypto_alg qat_algs[] = { {
509     .setkey = qat_alg_ablkcipher_xts_setkey,
510     .decrypt = qat_alg_ablkcipher_decrypt,
511     .encrypt = qat_alg_ablkcipher_encrypt,
512     - .min_keysize = AES_MIN_KEY_SIZE,
513     - .max_keysize = AES_MAX_KEY_SIZE,
514     + .min_keysize = 2 * AES_MIN_KEY_SIZE,
515     + .max_keysize = 2 * AES_MAX_KEY_SIZE,
516     .ivsize = AES_BLOCK_SIZE,
517     },
518     },
519     diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
520     index f1bcc2a163b3..b1bc945f008f 100644
521     --- a/drivers/dma/sh/usb-dmac.c
522     +++ b/drivers/dma/sh/usb-dmac.c
523     @@ -600,27 +600,30 @@ static irqreturn_t usb_dmac_isr_channel(int irq, void *dev)
524     {
525     struct usb_dmac_chan *chan = dev;
526     irqreturn_t ret = IRQ_NONE;
527     - u32 mask = USB_DMACHCR_TE;
528     - u32 check_bits = USB_DMACHCR_TE | USB_DMACHCR_SP;
529     + u32 mask = 0;
530     u32 chcr;
531     + bool xfer_end = false;
532    
533     spin_lock(&chan->vc.lock);
534    
535     chcr = usb_dmac_chan_read(chan, USB_DMACHCR);
536     - if (chcr & check_bits)
537     - mask |= USB_DMACHCR_DE | check_bits;
538     + if (chcr & (USB_DMACHCR_TE | USB_DMACHCR_SP)) {
539     + mask |= USB_DMACHCR_DE | USB_DMACHCR_TE | USB_DMACHCR_SP;
540     + if (chcr & USB_DMACHCR_DE)
541     + xfer_end = true;
542     + ret |= IRQ_HANDLED;
543     + }
544     if (chcr & USB_DMACHCR_NULL) {
545     /* An interruption of TE will happen after we set FTE */
546     mask |= USB_DMACHCR_NULL;
547     chcr |= USB_DMACHCR_FTE;
548     ret |= IRQ_HANDLED;
549     }
550     - usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask);
551     + if (mask)
552     + usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask);
553    
554     - if (chcr & check_bits) {
555     + if (xfer_end)
556     usb_dmac_isr_transfer_end(chan);
557     - ret |= IRQ_HANDLED;
558     - }
559    
560     spin_unlock(&chan->vc.lock);
561    
562     diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
563     index 1b2c2187b347..dc68394da682 100644
564     --- a/drivers/edac/edac_mc.c
565     +++ b/drivers/edac/edac_mc.c
566     @@ -966,7 +966,7 @@ static void edac_inc_ue_error(struct mem_ctl_info *mci,
567     mci->ue_mc += count;
568    
569     if (!enable_per_layer_report) {
570     - mci->ce_noinfo_count += count;
571     + mci->ue_noinfo_count += count;
572     return;
573     }
574    
575     diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
576     index b18bea08ff25..469dc378adeb 100644
577     --- a/drivers/gpio/Kconfig
578     +++ b/drivers/gpio/Kconfig
579     @@ -50,6 +50,7 @@ config GPIO_DEVRES
580     config OF_GPIO
581     def_bool y
582     depends on OF
583     + depends on HAS_IOMEM
584    
585     config GPIO_ACPI
586     def_bool y
587     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
588     index 053fc2f465df..ff5566c69f7d 100644
589     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
590     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
591     @@ -710,9 +710,9 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
592     void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
593     int amdgpu_gart_init(struct amdgpu_device *adev);
594     void amdgpu_gart_fini(struct amdgpu_device *adev);
595     -void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,
596     +void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
597     int pages);
598     -int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset,
599     +int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
600     int pages, struct page **pagelist,
601     dma_addr_t *dma_addr, uint32_t flags);
602    
603     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
604     index 0aaa457a1710..51a9942cdb40 100644
605     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
606     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
607     @@ -331,6 +331,19 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *
608     (le16_to_cpu(path->usConnObjectId) &
609     OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
610    
611     + /* Skip TV/CV support */
612     + if ((le16_to_cpu(path->usDeviceTag) ==
613     + ATOM_DEVICE_TV1_SUPPORT) ||
614     + (le16_to_cpu(path->usDeviceTag) ==
615     + ATOM_DEVICE_CV_SUPPORT))
616     + continue;
617     +
618     + if (con_obj_id >= ARRAY_SIZE(object_connector_convert)) {
619     + DRM_ERROR("invalid con_obj_id %d for device tag 0x%04x\n",
620     + con_obj_id, le16_to_cpu(path->usDeviceTag));
621     + continue;
622     + }
623     +
624     connector_type =
625     object_connector_convert[con_obj_id];
626     connector_object_id = con_obj_id;
627     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
628     index 7312d729d300..22a613a95bf0 100644
629     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
630     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
631     @@ -221,7 +221,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
632     * Unbinds the requested pages from the gart page table and
633     * replaces them with the dummy page (all asics).
634     */
635     -void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,
636     +void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
637     int pages)
638     {
639     unsigned t;
640     @@ -269,7 +269,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,
641     * (all asics).
642     * Returns 0 for success, -EINVAL for failure.
643     */
644     -int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset,
645     +int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
646     int pages, struct page **pagelist, dma_addr_t *dma_addr,
647     uint32_t flags)
648     {
649     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
650     index 9e25edafa721..c77a1ebfc632 100644
651     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
652     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
653     @@ -288,7 +288,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev)
654     int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
655     {
656     unsigned i;
657     - int r;
658     + int r, ret = 0;
659    
660     for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
661     struct amdgpu_ring *ring = adev->rings[i];
662     @@ -309,10 +309,11 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
663     } else {
664     /* still not good, but we can live with it */
665     DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r);
666     + ret = r;
667     }
668     }
669     }
670     - return 0;
671     + return ret;
672     }
673    
674     /*
675     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
676     index 1cbb16e15307..475c38fe9245 100644
677     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
678     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
679     @@ -233,8 +233,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
680    
681     adev = amdgpu_get_adev(bo->bdev);
682     ring = adev->mman.buffer_funcs_ring;
683     - old_start = old_mem->start << PAGE_SHIFT;
684     - new_start = new_mem->start << PAGE_SHIFT;
685     + old_start = (u64)old_mem->start << PAGE_SHIFT;
686     + new_start = (u64)new_mem->start << PAGE_SHIFT;
687    
688     switch (old_mem->mem_type) {
689     case TTM_PL_VRAM:
690     diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
691     index 5f712ceddf08..c568293cb6c1 100644
692     --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
693     +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
694     @@ -52,6 +52,7 @@ static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev);
695     static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev);
696     static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev);
697     static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev);
698     +static int cik_sdma_soft_reset(void *handle);
699    
700     MODULE_FIRMWARE("radeon/bonaire_sdma.bin");
701     MODULE_FIRMWARE("radeon/bonaire_sdma1.bin");
702     @@ -1030,6 +1031,8 @@ static int cik_sdma_resume(void *handle)
703     {
704     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
705    
706     + cik_sdma_soft_reset(handle);
707     +
708     return cik_sdma_hw_init(adev);
709     }
710    
711     diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
712     index 86c7500454b4..b37fe0df743e 100644
713     --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
714     +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
715     @@ -2747,6 +2747,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev)
716     struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
717    
718     ppgtt->base.cleanup(&ppgtt->base);
719     + kfree(ppgtt);
720     }
721    
722     if (drm_mm_initialized(&vm->mm)) {
723     diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
724     index 17ae2eb26ce2..d5c06f2764f4 100644
725     --- a/drivers/hwmon/iio_hwmon.c
726     +++ b/drivers/hwmon/iio_hwmon.c
727     @@ -109,24 +109,24 @@ static int iio_hwmon_probe(struct platform_device *pdev)
728    
729     switch (type) {
730     case IIO_VOLTAGE:
731     - a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
732     - "in%d_input",
733     - in_i++);
734     + a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
735     + "in%d_input",
736     + in_i++);
737     break;
738     case IIO_TEMP:
739     - a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
740     - "temp%d_input",
741     - temp_i++);
742     + a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
743     + "temp%d_input",
744     + temp_i++);
745     break;
746     case IIO_CURRENT:
747     - a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
748     - "curr%d_input",
749     - curr_i++);
750     + a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
751     + "curr%d_input",
752     + curr_i++);
753     break;
754     case IIO_HUMIDITYRELATIVE:
755     - a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
756     - "humidity%d_input",
757     - humidity_i++);
758     + a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
759     + "humidity%d_input",
760     + humidity_i++);
761     break;
762     default:
763     ret = -EINVAL;
764     diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
765     index a0d95ff682ae..2d5ff86398d0 100644
766     --- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
767     +++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
768     @@ -215,7 +215,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
769     msg->outsize = request_len;
770     msg->insize = response_len;
771    
772     - result = cros_ec_cmd_xfer(bus->ec, msg);
773     + result = cros_ec_cmd_xfer_status(bus->ec, msg);
774     if (result < 0) {
775     dev_err(dev, "Error transferring EC i2c message %d\n", result);
776     goto exit;
777     diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
778     index 0f6f63b20263..7afd226a3321 100644
779     --- a/drivers/iio/industrialio-buffer.c
780     +++ b/drivers/iio/industrialio-buffer.c
781     @@ -107,6 +107,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
782     {
783     struct iio_dev *indio_dev = filp->private_data;
784     struct iio_buffer *rb = indio_dev->buffer;
785     + DEFINE_WAIT_FUNC(wait, woken_wake_function);
786     size_t datum_size;
787     size_t to_wait;
788     int ret;
789     @@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
790     else
791     to_wait = min_t(size_t, n / datum_size, rb->watermark);
792    
793     + add_wait_queue(&rb->pollq, &wait);
794     do {
795     - ret = wait_event_interruptible(rb->pollq,
796     - iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size));
797     - if (ret)
798     - return ret;
799     + if (!indio_dev->info) {
800     + ret = -ENODEV;
801     + break;
802     + }
803    
804     - if (!indio_dev->info)
805     - return -ENODEV;
806     + if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) {
807     + if (signal_pending(current)) {
808     + ret = -ERESTARTSYS;
809     + break;
810     + }
811     +
812     + wait_woken(&wait, TASK_INTERRUPTIBLE,
813     + MAX_SCHEDULE_TIMEOUT);
814     + continue;
815     + }
816    
817     ret = rb->access->read_first_n(rb, n, buf);
818     if (ret == 0 && (filp->f_flags & O_NONBLOCK))
819     ret = -EAGAIN;
820     } while (ret == 0);
821     + remove_wait_queue(&rb->pollq, &wait);
822    
823     return ret;
824     }
825     diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
826     index acc5394afb03..29485bc4221c 100644
827     --- a/drivers/input/keyboard/tegra-kbc.c
828     +++ b/drivers/input/keyboard/tegra-kbc.c
829     @@ -376,7 +376,7 @@ static int tegra_kbc_start(struct tegra_kbc *kbc)
830     /* Reset the KBC controller to clear all previous status.*/
831     reset_control_assert(kbc->rst);
832     udelay(100);
833     - reset_control_assert(kbc->rst);
834     + reset_control_deassert(kbc->rst);
835     udelay(100);
836    
837     tegra_kbc_config_pins(kbc);
838     diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
839     index 454195709a82..405252a884dd 100644
840     --- a/drivers/input/serio/i8042.c
841     +++ b/drivers/input/serio/i8042.c
842     @@ -1277,6 +1277,7 @@ static int __init i8042_create_kbd_port(void)
843     serio->start = i8042_start;
844     serio->stop = i8042_stop;
845     serio->close = i8042_port_close;
846     + serio->ps2_cmd_mutex = &i8042_mutex;
847     serio->port_data = port;
848     serio->dev.parent = &i8042_platform_device->dev;
849     strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name));
850     @@ -1304,6 +1305,7 @@ static int __init i8042_create_aux_port(int idx)
851     serio->write = i8042_aux_write;
852     serio->start = i8042_start;
853     serio->stop = i8042_stop;
854     + serio->ps2_cmd_mutex = &i8042_mutex;
855     serio->port_data = port;
856     serio->dev.parent = &i8042_platform_device->dev;
857     if (idx < 0) {
858     @@ -1373,21 +1375,6 @@ static void i8042_unregister_ports(void)
859     }
860     }
861    
862     -/*
863     - * Checks whether port belongs to i8042 controller.
864     - */
865     -bool i8042_check_port_owner(const struct serio *port)
866     -{
867     - int i;
868     -
869     - for (i = 0; i < I8042_NUM_PORTS; i++)
870     - if (i8042_ports[i].serio == port)
871     - return true;
872     -
873     - return false;
874     -}
875     -EXPORT_SYMBOL(i8042_check_port_owner);
876     -
877     static void i8042_free_irqs(void)
878     {
879     if (i8042_aux_irq_registered)
880     diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
881     index 316f2c897101..83e9c663aa67 100644
882     --- a/drivers/input/serio/libps2.c
883     +++ b/drivers/input/serio/libps2.c
884     @@ -56,19 +56,17 @@ EXPORT_SYMBOL(ps2_sendbyte);
885    
886     void ps2_begin_command(struct ps2dev *ps2dev)
887     {
888     - mutex_lock(&ps2dev->cmd_mutex);
889     + struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
890    
891     - if (i8042_check_port_owner(ps2dev->serio))
892     - i8042_lock_chip();
893     + mutex_lock(m);
894     }
895     EXPORT_SYMBOL(ps2_begin_command);
896    
897     void ps2_end_command(struct ps2dev *ps2dev)
898     {
899     - if (i8042_check_port_owner(ps2dev->serio))
900     - i8042_unlock_chip();
901     + struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
902    
903     - mutex_unlock(&ps2dev->cmd_mutex);
904     + mutex_unlock(m);
905     }
906     EXPORT_SYMBOL(ps2_end_command);
907    
908     diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
909     index 8487987458a1..00df3832faab 100644
910     --- a/drivers/iommu/arm-smmu-v3.c
911     +++ b/drivers/iommu/arm-smmu-v3.c
912     @@ -870,7 +870,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu)
913     * We may have concurrent producers, so we need to be careful
914     * not to touch any of the shadow cmdq state.
915     */
916     - queue_read(cmd, Q_ENT(q, idx), q->ent_dwords);
917     + queue_read(cmd, Q_ENT(q, cons), q->ent_dwords);
918     dev_err(smmu->dev, "skipping command in error state:\n");
919     for (i = 0; i < ARRAY_SIZE(cmd); ++i)
920     dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]);
921     @@ -881,7 +881,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu)
922     return;
923     }
924    
925     - queue_write(cmd, Q_ENT(q, idx), q->ent_dwords);
926     + queue_write(Q_ENT(q, cons), cmd, q->ent_dwords);
927     }
928    
929     static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu,
930     @@ -1025,6 +1025,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid,
931     case STRTAB_STE_0_CFG_S2_TRANS:
932     ste_live = true;
933     break;
934     + case STRTAB_STE_0_CFG_ABORT:
935     + if (disable_bypass)
936     + break;
937     default:
938     BUG(); /* STE corruption */
939     }
940     diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
941     index 58f2fe687a24..347a3c17f73a 100644
942     --- a/drivers/iommu/dma-iommu.c
943     +++ b/drivers/iommu/dma-iommu.c
944     @@ -68,7 +68,8 @@ void iommu_put_dma_cookie(struct iommu_domain *domain)
945     if (!iovad)
946     return;
947    
948     - put_iova_domain(iovad);
949     + if (iovad->granule)
950     + put_iova_domain(iovad);
951     kfree(iovad);
952     domain->iova_cookie = NULL;
953     }
954     diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
955     index 1dee533634c9..2e6d2fff1096 100644
956     --- a/drivers/mmc/host/Kconfig
957     +++ b/drivers/mmc/host/Kconfig
958     @@ -97,6 +97,7 @@ config MMC_RICOH_MMC
959     config MMC_SDHCI_ACPI
960     tristate "SDHCI support for ACPI enumerated SDHCI controllers"
961     depends on MMC_SDHCI && ACPI
962     + select IOSF_MBI if X86
963     help
964     This selects support for ACPI enumerated SDHCI controllers,
965     identified by ACPI Compatibility ID PNP0D40 or specific
966     diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
967     index 8aea3fa6938b..5a05bf400ca8 100644
968     --- a/drivers/mmc/host/sdhci-acpi.c
969     +++ b/drivers/mmc/host/sdhci-acpi.c
970     @@ -41,6 +41,11 @@
971     #include <linux/mmc/pm.h>
972     #include <linux/mmc/slot-gpio.h>
973    
974     +#ifdef CONFIG_X86
975     +#include <asm/cpu_device_id.h>
976     +#include <asm/iosf_mbi.h>
977     +#endif
978     +
979     #include "sdhci.h"
980    
981     enum {
982     @@ -146,6 +151,75 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
983     .ops = &sdhci_acpi_ops_int,
984     };
985    
986     +#ifdef CONFIG_X86
987     +
988     +static bool sdhci_acpi_byt(void)
989     +{
990     + static const struct x86_cpu_id byt[] = {
991     + { X86_VENDOR_INTEL, 6, 0x37 },
992     + {}
993     + };
994     +
995     + return x86_match_cpu(byt);
996     +}
997     +
998     +#define BYT_IOSF_SCCEP 0x63
999     +#define BYT_IOSF_OCP_NETCTRL0 0x1078
1000     +#define BYT_IOSF_OCP_TIMEOUT_BASE GENMASK(10, 8)
1001     +
1002     +static void sdhci_acpi_byt_setting(struct device *dev)
1003     +{
1004     + u32 val = 0;
1005     +
1006     + if (!sdhci_acpi_byt())
1007     + return;
1008     +
1009     + if (iosf_mbi_read(BYT_IOSF_SCCEP, 0x06, BYT_IOSF_OCP_NETCTRL0,
1010     + &val)) {
1011     + dev_err(dev, "%s read error\n", __func__);
1012     + return;
1013     + }
1014     +
1015     + if (!(val & BYT_IOSF_OCP_TIMEOUT_BASE))
1016     + return;
1017     +
1018     + val &= ~BYT_IOSF_OCP_TIMEOUT_BASE;
1019     +
1020     + if (iosf_mbi_write(BYT_IOSF_SCCEP, 0x07, BYT_IOSF_OCP_NETCTRL0,
1021     + val)) {
1022     + dev_err(dev, "%s write error\n", __func__);
1023     + return;
1024     + }
1025     +
1026     + dev_dbg(dev, "%s completed\n", __func__);
1027     +}
1028     +
1029     +static bool sdhci_acpi_byt_defer(struct device *dev)
1030     +{
1031     + if (!sdhci_acpi_byt())
1032     + return false;
1033     +
1034     + if (!iosf_mbi_available())
1035     + return true;
1036     +
1037     + sdhci_acpi_byt_setting(dev);
1038     +
1039     + return false;
1040     +}
1041     +
1042     +#else
1043     +
1044     +static inline void sdhci_acpi_byt_setting(struct device *dev)
1045     +{
1046     +}
1047     +
1048     +static inline bool sdhci_acpi_byt_defer(struct device *dev)
1049     +{
1050     + return false;
1051     +}
1052     +
1053     +#endif
1054     +
1055     static int bxt_get_cd(struct mmc_host *mmc)
1056     {
1057     int gpio_cd = mmc_gpio_get_cd(mmc);
1058     @@ -337,6 +411,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
1059     if (acpi_bus_get_status(device) || !device->status.present)
1060     return -ENODEV;
1061    
1062     + if (sdhci_acpi_byt_defer(dev))
1063     + return -EPROBE_DEFER;
1064     +
1065     hid = acpi_device_hid(device);
1066     uid = device->pnp.unique_id;
1067    
1068     @@ -460,6 +537,8 @@ static int sdhci_acpi_resume(struct device *dev)
1069     {
1070     struct sdhci_acpi_host *c = dev_get_drvdata(dev);
1071    
1072     + sdhci_acpi_byt_setting(&c->pdev->dev);
1073     +
1074     return sdhci_resume_host(c->host);
1075     }
1076    
1077     @@ -483,6 +562,8 @@ static int sdhci_acpi_runtime_resume(struct device *dev)
1078     {
1079     struct sdhci_acpi_host *c = dev_get_drvdata(dev);
1080    
1081     + sdhci_acpi_byt_setting(&c->pdev->dev);
1082     +
1083     return sdhci_runtime_resume_host(c->host);
1084     }
1085    
1086     diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
1087     index 0c67b57be83c..289a5df0d44a 100644
1088     --- a/drivers/nvme/host/pci.c
1089     +++ b/drivers/nvme/host/pci.c
1090     @@ -2672,10 +2672,10 @@ static int nvme_dev_add(struct nvme_dev *dev)
1091     return 0;
1092     }
1093    
1094     -static int nvme_dev_map(struct nvme_dev *dev)
1095     +static int nvme_pci_enable(struct nvme_dev *dev)
1096     {
1097     u64 cap;
1098     - int bars, result = -ENOMEM;
1099     + int result = -ENOMEM;
1100     struct pci_dev *pdev = to_pci_dev(dev->dev);
1101    
1102     if (pci_enable_device_mem(pdev))
1103     @@ -2683,24 +2683,14 @@ static int nvme_dev_map(struct nvme_dev *dev)
1104    
1105     dev->entry[0].vector = pdev->irq;
1106     pci_set_master(pdev);
1107     - bars = pci_select_bars(pdev, IORESOURCE_MEM);
1108     - if (!bars)
1109     - goto disable_pci;
1110     -
1111     - if (pci_request_selected_regions(pdev, bars, "nvme"))
1112     - goto disable_pci;
1113    
1114     if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
1115     dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32)))
1116     goto disable;
1117    
1118     - dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
1119     - if (!dev->bar)
1120     - goto disable;
1121     -
1122     if (readl(&dev->bar->csts) == -1) {
1123     result = -ENODEV;
1124     - goto unmap;
1125     + goto disable;
1126     }
1127    
1128     /*
1129     @@ -2710,7 +2700,7 @@ static int nvme_dev_map(struct nvme_dev *dev)
1130     if (!pdev->irq) {
1131     result = pci_enable_msix(pdev, dev->entry, 1);
1132     if (result < 0)
1133     - goto unmap;
1134     + goto disable;
1135     }
1136    
1137     cap = lo_hi_readq(&dev->bar->cap);
1138     @@ -2734,18 +2724,21 @@ static int nvme_dev_map(struct nvme_dev *dev)
1139    
1140     return 0;
1141    
1142     - unmap:
1143     - iounmap(dev->bar);
1144     - dev->bar = NULL;
1145     disable:
1146     pci_release_regions(pdev);
1147     - disable_pci:
1148     - pci_disable_device(pdev);
1149     +
1150     return result;
1151     }
1152    
1153     static void nvme_dev_unmap(struct nvme_dev *dev)
1154     {
1155     + if (dev->bar)
1156     + iounmap(dev->bar);
1157     + pci_release_regions(to_pci_dev(dev->dev));
1158     +}
1159     +
1160     +static void nvme_pci_disable(struct nvme_dev *dev)
1161     +{
1162     struct pci_dev *pdev = to_pci_dev(dev->dev);
1163    
1164     if (pdev->msi_enabled)
1165     @@ -2753,12 +2746,6 @@ static void nvme_dev_unmap(struct nvme_dev *dev)
1166     else if (pdev->msix_enabled)
1167     pci_disable_msix(pdev);
1168    
1169     - if (dev->bar) {
1170     - iounmap(dev->bar);
1171     - dev->bar = NULL;
1172     - pci_release_regions(pdev);
1173     - }
1174     -
1175     if (pci_is_enabled(pdev))
1176     pci_disable_device(pdev);
1177     }
1178     @@ -2962,7 +2949,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev)
1179    
1180     nvme_dev_list_remove(dev);
1181    
1182     - if (dev->bar) {
1183     + if (pci_is_enabled(to_pci_dev(dev->dev))) {
1184     nvme_freeze_queues(dev);
1185     csts = readl(&dev->bar->csts);
1186     }
1187     @@ -2976,7 +2963,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev)
1188     nvme_shutdown_ctrl(dev);
1189     nvme_disable_queue(dev, 0);
1190     }
1191     - nvme_dev_unmap(dev);
1192     + nvme_pci_disable(dev);
1193    
1194     for (i = dev->queue_count - 1; i >= 0; i--)
1195     nvme_clear_queue(dev->queues[i]);
1196     @@ -3136,7 +3123,7 @@ static void nvme_probe_work(struct work_struct *work)
1197     bool start_thread = false;
1198     int result;
1199    
1200     - result = nvme_dev_map(dev);
1201     + result = nvme_pci_enable(dev);
1202     if (result)
1203     goto out;
1204    
1205     @@ -3292,6 +3279,27 @@ static ssize_t nvme_sysfs_reset(struct device *dev,
1206     }
1207     static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
1208    
1209     +static int nvme_dev_map(struct nvme_dev *dev)
1210     +{
1211     + int bars;
1212     + struct pci_dev *pdev = to_pci_dev(dev->dev);
1213     +
1214     + bars = pci_select_bars(pdev, IORESOURCE_MEM);
1215     + if (!bars)
1216     + return -ENODEV;
1217     + if (pci_request_selected_regions(pdev, bars, "nvme"))
1218     + return -ENODEV;
1219     +
1220     + dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
1221     + if (!dev->bar)
1222     + goto release;
1223     +
1224     + return 0;
1225     +release:
1226     + pci_release_regions(pdev);
1227     + return -ENODEV;
1228     +}
1229     +
1230     static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1231     {
1232     int node, result = -ENOMEM;
1233     @@ -3317,6 +3325,11 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1234     INIT_WORK(&dev->reset_work, nvme_reset_work);
1235     dev->dev = get_device(&pdev->dev);
1236     pci_set_drvdata(pdev, dev);
1237     +
1238     + result = nvme_dev_map(dev);
1239     + if (result)
1240     + goto free;
1241     +
1242     result = nvme_set_instance(dev);
1243     if (result)
1244     goto put_pci;
1245     @@ -3355,6 +3368,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1246     nvme_release_instance(dev);
1247     put_pci:
1248     put_device(dev->dev);
1249     + nvme_dev_unmap(dev);
1250     free:
1251     kfree(dev->queues);
1252     kfree(dev->entry);
1253     @@ -3398,6 +3412,7 @@ static void nvme_remove(struct pci_dev *pdev)
1254     nvme_free_queues(dev, 0);
1255     nvme_release_cmb(dev);
1256     nvme_release_prp_pools(dev);
1257     + nvme_dev_unmap(dev);
1258     kref_put(&dev->kref, nvme_free_dev);
1259     }
1260    
1261     diff --git a/drivers/of/base.c b/drivers/of/base.c
1262     index 942461f36616..31341290cd91 100644
1263     --- a/drivers/of/base.c
1264     +++ b/drivers/of/base.c
1265     @@ -2253,20 +2253,13 @@ struct device_node *of_graph_get_endpoint_by_regs(
1266     const struct device_node *parent, int port_reg, int reg)
1267     {
1268     struct of_endpoint endpoint;
1269     - struct device_node *node, *prev_node = NULL;
1270     -
1271     - while (1) {
1272     - node = of_graph_get_next_endpoint(parent, prev_node);
1273     - of_node_put(prev_node);
1274     - if (!node)
1275     - break;
1276     + struct device_node *node = NULL;
1277    
1278     + for_each_endpoint_of_node(parent, node) {
1279     of_graph_parse_endpoint(node, &endpoint);
1280     if (((port_reg == -1) || (endpoint.port == port_reg)) &&
1281     ((reg == -1) || (endpoint.id == reg)))
1282     return node;
1283     -
1284     - prev_node = node;
1285     }
1286    
1287     return NULL;
1288     diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
1289     index 7eaa4c87fec7..10a6a8e5db88 100644
1290     --- a/drivers/pci/msi.c
1291     +++ b/drivers/pci/msi.c
1292     @@ -1278,6 +1278,8 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
1293     if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
1294     pci_msi_domain_update_chip_ops(info);
1295    
1296     + info->flags |= MSI_FLAG_ACTIVATE_EARLY;
1297     +
1298     domain = msi_create_irq_domain(fwnode, info, parent);
1299     if (!domain)
1300     return NULL;
1301     diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
1302     index eead54cd01b2..d7508704c992 100644
1303     --- a/drivers/pci/pci-sysfs.c
1304     +++ b/drivers/pci/pci-sysfs.c
1305     @@ -1372,10 +1372,10 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
1306     if (!sysfs_initialized)
1307     return -EACCES;
1308    
1309     - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
1310     - retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
1311     - else
1312     + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
1313     retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
1314     + else
1315     + retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
1316     if (retval)
1317     goto err;
1318    
1319     @@ -1427,10 +1427,10 @@ err_rom_file:
1320     err_resource_files:
1321     pci_remove_resource_files(pdev);
1322     err_config_file:
1323     - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
1324     - sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
1325     - else
1326     + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
1327     sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
1328     + else
1329     + sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
1330     err:
1331     return retval;
1332     }
1333     @@ -1464,10 +1464,10 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
1334    
1335     pci_remove_capabilities_sysfs(pdev);
1336    
1337     - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
1338     - sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
1339     - else
1340     + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
1341     sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
1342     + else
1343     + sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
1344    
1345     pci_remove_resource_files(pdev);
1346    
1347     diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
1348     index 3c4752a288e2..42774bc39786 100644
1349     --- a/drivers/pci/quirks.c
1350     +++ b/drivers/pci/quirks.c
1351     @@ -287,6 +287,18 @@ static void quirk_citrine(struct pci_dev *dev)
1352     }
1353     DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine);
1354    
1355     +/*
1356     + * This chip can cause bus lockups if config addresses above 0x600
1357     + * are read or written.
1358     + */
1359     +static void quirk_nfp6000(struct pci_dev *dev)
1360     +{
1361     + dev->cfg_size = 0x600;
1362     +}
1363     +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP4000, quirk_nfp6000);
1364     +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000, quirk_nfp6000);
1365     +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000_VF, quirk_nfp6000);
1366     +
1367     /* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */
1368     static void quirk_extend_bar_to_page(struct pci_dev *dev)
1369     {
1370     diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
1371     index 3318f1d6193c..7340ff78839a 100644
1372     --- a/drivers/pinctrl/pinctrl-amd.c
1373     +++ b/drivers/pinctrl/pinctrl-amd.c
1374     @@ -48,17 +48,6 @@ static int amd_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
1375    
1376     spin_lock_irqsave(&gpio_dev->lock, flags);
1377     pin_reg = readl(gpio_dev->base + offset * 4);
1378     - /*
1379     - * Suppose BIOS or Bootloader sets specific debounce for the
1380     - * GPIO. if not, set debounce to be 2.75ms and remove glitch.
1381     - */
1382     - if ((pin_reg & DB_TMR_OUT_MASK) == 0) {
1383     - pin_reg |= 0xf;
1384     - pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF);
1385     - pin_reg |= DB_TYPE_REMOVE_GLITCH << DB_CNTRL_OFF;
1386     - pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
1387     - }
1388     -
1389     pin_reg &= ~BIT(OUTPUT_ENABLE_OFF);
1390     writel(pin_reg, gpio_dev->base + offset * 4);
1391     spin_unlock_irqrestore(&gpio_dev->lock, flags);
1392     @@ -331,15 +320,6 @@ static void amd_gpio_irq_enable(struct irq_data *d)
1393    
1394     spin_lock_irqsave(&gpio_dev->lock, flags);
1395     pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
1396     - /*
1397     - Suppose BIOS or Bootloader sets specific debounce for the
1398     - GPIO. if not, set debounce to be 2.75ms.
1399     - */
1400     - if ((pin_reg & DB_TMR_OUT_MASK) == 0) {
1401     - pin_reg |= 0xf;
1402     - pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF);
1403     - pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
1404     - }
1405     pin_reg |= BIT(INTERRUPT_ENABLE_OFF);
1406     pin_reg |= BIT(INTERRUPT_MASK_OFF);
1407     writel(pin_reg, gpio_dev->base + (d->hwirq)*4);
1408     diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
1409     index 990308ca384f..92430f781eb7 100644
1410     --- a/drivers/platform/chrome/cros_ec_proto.c
1411     +++ b/drivers/platform/chrome/cros_ec_proto.c
1412     @@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
1413     return ret;
1414     }
1415     EXPORT_SYMBOL(cros_ec_cmd_xfer);
1416     +
1417     +int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
1418     + struct cros_ec_command *msg)
1419     +{
1420     + int ret;
1421     +
1422     + ret = cros_ec_cmd_xfer(ec_dev, msg);
1423     + if (ret < 0) {
1424     + dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
1425     + } else if (msg->result != EC_RES_SUCCESS) {
1426     + dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
1427     + return -EPROTO;
1428     + }
1429     +
1430     + return ret;
1431     +}
1432     +EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
1433     diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
1434     index 4abfbdb285ec..84c13dffa3a8 100644
1435     --- a/drivers/s390/block/dasd.c
1436     +++ b/drivers/s390/block/dasd.c
1437     @@ -1584,9 +1584,18 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
1438     unsigned long long now;
1439     int expires;
1440    
1441     + cqr = (struct dasd_ccw_req *) intparm;
1442     if (IS_ERR(irb)) {
1443     switch (PTR_ERR(irb)) {
1444     case -EIO:
1445     + if (cqr && cqr->status == DASD_CQR_CLEAR_PENDING) {
1446     + device = (struct dasd_device *) cqr->startdev;
1447     + cqr->status = DASD_CQR_CLEARED;
1448     + dasd_device_clear_timer(device);
1449     + wake_up(&dasd_flush_wq);
1450     + dasd_schedule_device_bh(device);
1451     + return;
1452     + }
1453     break;
1454     case -ETIMEDOUT:
1455     DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: "
1456     @@ -1602,7 +1611,6 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
1457     }
1458    
1459     now = get_tod_clock();
1460     - cqr = (struct dasd_ccw_req *) intparm;
1461     /* check for conditions that should be handled immediately */
1462     if (!cqr ||
1463     !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
1464     diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
1465     index 54195a117f72..f78cc943d230 100644
1466     --- a/drivers/scsi/aacraid/commctrl.c
1467     +++ b/drivers/scsi/aacraid/commctrl.c
1468     @@ -63,7 +63,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
1469     struct fib *fibptr;
1470     struct hw_fib * hw_fib = (struct hw_fib *)0;
1471     dma_addr_t hw_fib_pa = (dma_addr_t)0LL;
1472     - unsigned size;
1473     + unsigned int size, osize;
1474     int retval;
1475    
1476     if (dev->in_reset) {
1477     @@ -87,7 +87,8 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
1478     * will not overrun the buffer when we copy the memory. Return
1479     * an error if we would.
1480     */
1481     - size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr);
1482     + osize = size = le16_to_cpu(kfib->header.Size) +
1483     + sizeof(struct aac_fibhdr);
1484     if (size < le16_to_cpu(kfib->header.SenderSize))
1485     size = le16_to_cpu(kfib->header.SenderSize);
1486     if (size > dev->max_fib_size) {
1487     @@ -118,6 +119,14 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
1488     goto cleanup;
1489     }
1490    
1491     + /* Sanity check the second copy */
1492     + if ((osize != le16_to_cpu(kfib->header.Size) +
1493     + sizeof(struct aac_fibhdr))
1494     + || (size < le16_to_cpu(kfib->header.SenderSize))) {
1495     + retval = -EINVAL;
1496     + goto cleanup;
1497     + }
1498     +
1499     if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
1500     aac_adapter_interrupt(dev);
1501     /*
1502     diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
1503     index 00ce3e269a43..e994ff944091 100644
1504     --- a/drivers/scsi/megaraid/megaraid_sas_base.c
1505     +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
1506     @@ -4669,7 +4669,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
1507     /* Find first memory bar */
1508     bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
1509     instance->bar = find_first_bit(&bar_list, sizeof(unsigned long));
1510     - if (pci_request_selected_regions(instance->pdev, instance->bar,
1511     + if (pci_request_selected_regions(instance->pdev, 1<<instance->bar,
1512     "megasas: LSI")) {
1513     dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n");
1514     return -EBUSY;
1515     @@ -4960,7 +4960,7 @@ fail_ready_state:
1516     iounmap(instance->reg_set);
1517    
1518     fail_ioremap:
1519     - pci_release_selected_regions(instance->pdev, instance->bar);
1520     + pci_release_selected_regions(instance->pdev, 1<<instance->bar);
1521    
1522     return -EINVAL;
1523     }
1524     @@ -4981,7 +4981,7 @@ static void megasas_release_mfi(struct megasas_instance *instance)
1525    
1526     iounmap(instance->reg_set);
1527    
1528     - pci_release_selected_regions(instance->pdev, instance->bar);
1529     + pci_release_selected_regions(instance->pdev, 1<<instance->bar);
1530     }
1531    
1532     /**
1533     diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
1534     index 8d630a552b07..4f391e747be2 100644
1535     --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
1536     +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
1537     @@ -2437,7 +2437,7 @@ megasas_release_fusion(struct megasas_instance *instance)
1538    
1539     iounmap(instance->reg_set);
1540    
1541     - pci_release_selected_regions(instance->pdev, instance->bar);
1542     + pci_release_selected_regions(instance->pdev, 1<<instance->bar);
1543     }
1544    
1545     /**
1546     diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
1547     index 11393ebf1a68..356233f86064 100644
1548     --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
1549     +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
1550     @@ -2155,6 +2155,17 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
1551     } else
1552     ioc->msix96_vector = 0;
1553    
1554     + if (ioc->is_warpdrive) {
1555     + ioc->reply_post_host_index[0] = (resource_size_t __iomem *)
1556     + &ioc->chip->ReplyPostHostIndex;
1557     +
1558     + for (i = 1; i < ioc->cpu_msix_table_sz; i++)
1559     + ioc->reply_post_host_index[i] =
1560     + (resource_size_t __iomem *)
1561     + ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1)
1562     + * 4)));
1563     + }
1564     +
1565     list_for_each_entry(reply_q, &ioc->reply_queue_list, list)
1566     pr_info(MPT3SAS_FMT "%s: IRQ %d\n",
1567     reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" :
1568     @@ -5201,17 +5212,6 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
1569     if (r)
1570     goto out_free_resources;
1571    
1572     - if (ioc->is_warpdrive) {
1573     - ioc->reply_post_host_index[0] = (resource_size_t __iomem *)
1574     - &ioc->chip->ReplyPostHostIndex;
1575     -
1576     - for (i = 1; i < ioc->cpu_msix_table_sz; i++)
1577     - ioc->reply_post_host_index[i] =
1578     - (resource_size_t __iomem *)
1579     - ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1)
1580     - * 4)));
1581     - }
1582     -
1583     pci_set_drvdata(ioc->pdev, ioc->shost);
1584     r = _base_get_ioc_facts(ioc, CAN_SLEEP);
1585     if (r)
1586     diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
1587     index 4ab186669f0c..ec5b9a23494d 100644
1588     --- a/drivers/staging/comedi/drivers/comedi_test.c
1589     +++ b/drivers/staging/comedi/drivers/comedi_test.c
1590     @@ -56,11 +56,6 @@
1591    
1592     #define N_CHANS 8
1593    
1594     -enum waveform_state_bits {
1595     - WAVEFORM_AI_RUNNING,
1596     - WAVEFORM_AO_RUNNING
1597     -};
1598     -
1599     /* Data unique to this driver */
1600     struct waveform_private {
1601     struct timer_list ai_timer; /* timer for AI commands */
1602     @@ -68,7 +63,6 @@ struct waveform_private {
1603     unsigned int wf_amplitude; /* waveform amplitude in microvolts */
1604     unsigned int wf_period; /* waveform period in microseconds */
1605     unsigned int wf_current; /* current time in waveform period */
1606     - unsigned long state_bits;
1607     unsigned int ai_scan_period; /* AI scan period in usec */
1608     unsigned int ai_convert_period; /* AI conversion period in usec */
1609     struct timer_list ao_timer; /* timer for AO commands */
1610     @@ -191,10 +185,6 @@ static void waveform_ai_timer(unsigned long arg)
1611     unsigned int nsamples;
1612     unsigned int time_increment;
1613    
1614     - /* check command is still active */
1615     - if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
1616     - return;
1617     -
1618     now = ktime_to_us(ktime_get());
1619     nsamples = comedi_nsamples_left(s, UINT_MAX);
1620    
1621     @@ -386,11 +376,6 @@ static int waveform_ai_cmd(struct comedi_device *dev,
1622     */
1623     devpriv->ai_timer.expires =
1624     jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1;
1625     -
1626     - /* mark command as active */
1627     - smp_mb__before_atomic();
1628     - set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
1629     - smp_mb__after_atomic();
1630     add_timer(&devpriv->ai_timer);
1631     return 0;
1632     }
1633     @@ -400,11 +385,12 @@ static int waveform_ai_cancel(struct comedi_device *dev,
1634     {
1635     struct waveform_private *devpriv = dev->private;
1636    
1637     - /* mark command as no longer active */
1638     - clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
1639     - smp_mb__after_atomic();
1640     - /* cannot call del_timer_sync() as may be called from timer routine */
1641     - del_timer(&devpriv->ai_timer);
1642     + if (in_softirq()) {
1643     + /* Assume we were called from the timer routine itself. */
1644     + del_timer(&devpriv->ai_timer);
1645     + } else {
1646     + del_timer_sync(&devpriv->ai_timer);
1647     + }
1648     return 0;
1649     }
1650    
1651     @@ -436,10 +422,6 @@ static void waveform_ao_timer(unsigned long arg)
1652     u64 scans_since;
1653     unsigned int scans_avail = 0;
1654    
1655     - /* check command is still active */
1656     - if (!test_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits))
1657     - return;
1658     -
1659     /* determine number of scan periods since last time */
1660     now = ktime_to_us(ktime_get());
1661     scans_since = now - devpriv->ao_last_scan_time;
1662     @@ -518,11 +500,6 @@ static int waveform_ao_inttrig_start(struct comedi_device *dev,
1663     devpriv->ao_last_scan_time = ktime_to_us(ktime_get());
1664     devpriv->ao_timer.expires =
1665     jiffies + usecs_to_jiffies(devpriv->ao_scan_period);
1666     -
1667     - /* mark command as active */
1668     - smp_mb__before_atomic();
1669     - set_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits);
1670     - smp_mb__after_atomic();
1671     add_timer(&devpriv->ao_timer);
1672    
1673     return 1;
1674     @@ -608,11 +585,12 @@ static int waveform_ao_cancel(struct comedi_device *dev,
1675     struct waveform_private *devpriv = dev->private;
1676    
1677     s->async->inttrig = NULL;
1678     - /* mark command as no longer active */
1679     - clear_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits);
1680     - smp_mb__after_atomic();
1681     - /* cannot call del_timer_sync() as may be called from timer routine */
1682     - del_timer(&devpriv->ao_timer);
1683     + if (in_softirq()) {
1684     + /* Assume we were called from the timer routine itself. */
1685     + del_timer(&devpriv->ao_timer);
1686     + } else {
1687     + del_timer_sync(&devpriv->ao_timer);
1688     + }
1689     return 0;
1690     }
1691    
1692     diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
1693     index 57ab6680e3ae..e5fee6e0fb47 100644
1694     --- a/drivers/staging/comedi/drivers/daqboard2000.c
1695     +++ b/drivers/staging/comedi/drivers/daqboard2000.c
1696     @@ -636,7 +636,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev,
1697     const struct daq200_boardtype *board;
1698     int i;
1699    
1700     - if (pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH)
1701     + if (pcidev->subsystem_vendor != PCI_VENDOR_ID_IOTECH)
1702     return NULL;
1703    
1704     for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
1705     diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
1706     index 27fbf1a81097..35ab4a9ef95d 100644
1707     --- a/drivers/staging/comedi/drivers/ni_mio_common.c
1708     +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
1709     @@ -2823,7 +2823,15 @@ static int ni_ao_inttrig(struct comedi_device *dev,
1710     int i;
1711     static const int timeout = 1000;
1712    
1713     - if (trig_num != cmd->start_arg)
1714     + /*
1715     + * Require trig_num == cmd->start_arg when cmd->start_src == TRIG_INT.
1716     + * For backwards compatibility, also allow trig_num == 0 when
1717     + * cmd->start_src != TRIG_INT (i.e. when cmd->start_src == TRIG_EXT);
1718     + * in that case, the internal trigger is being used as a pre-trigger
1719     + * before the external trigger.
1720     + */
1721     + if (!(trig_num == cmd->start_arg ||
1722     + (trig_num == 0 && cmd->start_src != TRIG_INT)))
1723     return -EINVAL;
1724    
1725     /* Null trig at beginning prevent ao start trigger from executing more than
1726     @@ -5346,7 +5354,7 @@ static int ni_E_init(struct comedi_device *dev,
1727     s->maxdata = (devpriv->is_m_series) ? 0xffffffff
1728     : 0x00ffffff;
1729     s->insn_read = ni_tio_insn_read;
1730     - s->insn_write = ni_tio_insn_read;
1731     + s->insn_write = ni_tio_insn_write;
1732     s->insn_config = ni_tio_insn_config;
1733     #ifdef PCIDMA
1734     if (dev->irq && devpriv->mite) {
1735     diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
1736     index 391a1225b0ba..ca367b05e440 100644
1737     --- a/drivers/usb/chipidea/udc.c
1738     +++ b/drivers/usb/chipidea/udc.c
1739     @@ -1585,8 +1585,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
1740     {
1741     struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
1742    
1743     - /* Data+ pullup controlled by OTG state machine in OTG fsm mode */
1744     - if (ci_otg_is_fsm_mode(ci))
1745     + /*
1746     + * Data+ pullup controlled by OTG state machine in OTG fsm mode;
1747     + * and don't touch Data+ in host mode for dual role config.
1748     + */
1749     + if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST)
1750     return 0;
1751    
1752     pm_runtime_get_sync(&ci->gadget.dev);
1753     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1754     index d37fdcc3143c..7f374369e539 100644
1755     --- a/drivers/usb/class/cdc-acm.c
1756     +++ b/drivers/usb/class/cdc-acm.c
1757     @@ -1336,7 +1336,6 @@ made_compressed_probe:
1758     spin_lock_init(&acm->write_lock);
1759     spin_lock_init(&acm->read_lock);
1760     mutex_init(&acm->mutex);
1761     - acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
1762     acm->is_int_ep = usb_endpoint_xfer_int(epread);
1763     if (acm->is_int_ep)
1764     acm->bInterval = epread->bInterval;
1765     @@ -1376,14 +1375,14 @@ made_compressed_probe:
1766     urb->transfer_dma = rb->dma;
1767     if (acm->is_int_ep) {
1768     usb_fill_int_urb(urb, acm->dev,
1769     - acm->rx_endpoint,
1770     + usb_rcvintpipe(usb_dev, epread->bEndpointAddress),
1771     rb->base,
1772     acm->readsize,
1773     acm_read_bulk_callback, rb,
1774     acm->bInterval);
1775     } else {
1776     usb_fill_bulk_urb(urb, acm->dev,
1777     - acm->rx_endpoint,
1778     + usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress),
1779     rb->base,
1780     acm->readsize,
1781     acm_read_bulk_callback, rb);
1782     diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
1783     index ccfaba9ab4e4..b30ac5fcde68 100644
1784     --- a/drivers/usb/class/cdc-acm.h
1785     +++ b/drivers/usb/class/cdc-acm.h
1786     @@ -95,7 +95,6 @@ struct acm {
1787     struct urb *read_urbs[ACM_NR];
1788     struct acm_rb read_buffers[ACM_NR];
1789     int rx_buflimit;
1790     - int rx_endpoint;
1791     spinlock_t read_lock;
1792     int write_used; /* number of non-empty write buffers */
1793     int transmitting;
1794     diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
1795     index 673d53038ed2..a00bfb93acc3 100644
1796     --- a/drivers/usb/common/common.c
1797     +++ b/drivers/usb/common/common.c
1798     @@ -50,6 +50,7 @@ static const char *const speed_names[] = {
1799     [USB_SPEED_HIGH] = "high-speed",
1800     [USB_SPEED_WIRELESS] = "wireless",
1801     [USB_SPEED_SUPER] = "super-speed",
1802     + [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
1803     };
1804    
1805     const char *usb_speed_string(enum usb_device_speed speed)
1806     diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
1807     index 5050760f5e17..80c8d90d8b75 100644
1808     --- a/drivers/usb/core/config.c
1809     +++ b/drivers/usb/core/config.c
1810     @@ -142,6 +142,31 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
1811     }
1812     }
1813    
1814     +static const unsigned short low_speed_maxpacket_maxes[4] = {
1815     + [USB_ENDPOINT_XFER_CONTROL] = 8,
1816     + [USB_ENDPOINT_XFER_ISOC] = 0,
1817     + [USB_ENDPOINT_XFER_BULK] = 0,
1818     + [USB_ENDPOINT_XFER_INT] = 8,
1819     +};
1820     +static const unsigned short full_speed_maxpacket_maxes[4] = {
1821     + [USB_ENDPOINT_XFER_CONTROL] = 64,
1822     + [USB_ENDPOINT_XFER_ISOC] = 1023,
1823     + [USB_ENDPOINT_XFER_BULK] = 64,
1824     + [USB_ENDPOINT_XFER_INT] = 64,
1825     +};
1826     +static const unsigned short high_speed_maxpacket_maxes[4] = {
1827     + [USB_ENDPOINT_XFER_CONTROL] = 64,
1828     + [USB_ENDPOINT_XFER_ISOC] = 1024,
1829     + [USB_ENDPOINT_XFER_BULK] = 512,
1830     + [USB_ENDPOINT_XFER_INT] = 1024,
1831     +};
1832     +static const unsigned short super_speed_maxpacket_maxes[4] = {
1833     + [USB_ENDPOINT_XFER_CONTROL] = 512,
1834     + [USB_ENDPOINT_XFER_ISOC] = 1024,
1835     + [USB_ENDPOINT_XFER_BULK] = 1024,
1836     + [USB_ENDPOINT_XFER_INT] = 1024,
1837     +};
1838     +
1839     static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1840     int asnum, struct usb_host_interface *ifp, int num_ep,
1841     unsigned char *buffer, int size)
1842     @@ -150,6 +175,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1843     struct usb_endpoint_descriptor *d;
1844     struct usb_host_endpoint *endpoint;
1845     int n, i, j, retval;
1846     + unsigned int maxp;
1847     + const unsigned short *maxpacket_maxes;
1848    
1849     d = (struct usb_endpoint_descriptor *) buffer;
1850     buffer += d->bLength;
1851     @@ -191,6 +218,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1852     if (usb_endpoint_xfer_int(d)) {
1853     i = 1;
1854     switch (to_usb_device(ddev)->speed) {
1855     + case USB_SPEED_SUPER_PLUS:
1856     case USB_SPEED_SUPER:
1857     case USB_SPEED_HIGH:
1858     /* Many device manufacturers are using full-speed
1859     @@ -256,6 +284,42 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1860     endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
1861     }
1862    
1863     + /* Validate the wMaxPacketSize field */
1864     + maxp = usb_endpoint_maxp(&endpoint->desc);
1865     +
1866     + /* Find the highest legal maxpacket size for this endpoint */
1867     + i = 0; /* additional transactions per microframe */
1868     + switch (to_usb_device(ddev)->speed) {
1869     + case USB_SPEED_LOW:
1870     + maxpacket_maxes = low_speed_maxpacket_maxes;
1871     + break;
1872     + case USB_SPEED_FULL:
1873     + maxpacket_maxes = full_speed_maxpacket_maxes;
1874     + break;
1875     + case USB_SPEED_HIGH:
1876     + /* Bits 12..11 are allowed only for HS periodic endpoints */
1877     + if (usb_endpoint_xfer_int(d) || usb_endpoint_xfer_isoc(d)) {
1878     + i = maxp & (BIT(12) | BIT(11));
1879     + maxp &= ~i;
1880     + }
1881     + /* fallthrough */
1882     + default:
1883     + maxpacket_maxes = high_speed_maxpacket_maxes;
1884     + break;
1885     + case USB_SPEED_SUPER:
1886     + case USB_SPEED_SUPER_PLUS:
1887     + maxpacket_maxes = super_speed_maxpacket_maxes;
1888     + break;
1889     + }
1890     + j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)];
1891     +
1892     + if (maxp > j) {
1893     + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n",
1894     + cfgno, inum, asnum, d->bEndpointAddress, maxp, j);
1895     + maxp = j;
1896     + endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp);
1897     + }
1898     +
1899     /*
1900     * Some buggy high speed devices have bulk endpoints using
1901     * maxpacket sizes other than 512. High speed HCDs may not
1902     @@ -263,9 +327,6 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1903     */
1904     if (to_usb_device(ddev)->speed == USB_SPEED_HIGH
1905     && usb_endpoint_xfer_bulk(d)) {
1906     - unsigned maxp;
1907     -
1908     - maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff;
1909     if (maxp != 512)
1910     dev_warn(ddev, "config %d interface %d altsetting %d "
1911     "bulk endpoint 0x%X has invalid maxpacket %d\n",
1912     @@ -274,7 +335,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
1913     }
1914    
1915     /* Parse a possible SuperSpeed endpoint companion descriptor */
1916     - if (to_usb_device(ddev)->speed == USB_SPEED_SUPER)
1917     + if (to_usb_device(ddev)->speed >= USB_SPEED_SUPER)
1918     usb_parse_ss_endpoint_companion(ddev, cfgno,
1919     inum, asnum, endpoint, buffer, size);
1920    
1921     diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
1922     index 2a3bbdf7eb94..332ed277a06c 100644
1923     --- a/drivers/usb/core/devices.c
1924     +++ b/drivers/usb/core/devices.c
1925     @@ -221,7 +221,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
1926     break;
1927     case USB_ENDPOINT_XFER_INT:
1928     type = "Int.";
1929     - if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER)
1930     + if (speed == USB_SPEED_HIGH || speed >= USB_SPEED_SUPER)
1931     interval = 1 << (desc->bInterval - 1);
1932     else
1933     interval = desc->bInterval;
1934     @@ -230,7 +230,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
1935     return start;
1936     }
1937     interval *= (speed == USB_SPEED_HIGH ||
1938     - speed == USB_SPEED_SUPER) ? 125 : 1000;
1939     + speed >= USB_SPEED_SUPER) ? 125 : 1000;
1940     if (interval % 1000)
1941     unit = 'u';
1942     else {
1943     @@ -322,7 +322,7 @@ static char *usb_dump_config_descriptor(char *start, char *end,
1944    
1945     if (start > end)
1946     return start;
1947     - if (speed == USB_SPEED_SUPER)
1948     + if (speed >= USB_SPEED_SUPER)
1949     mul = 8;
1950     else
1951     mul = 2;
1952     @@ -534,6 +534,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
1953     speed = "480"; break;
1954     case USB_SPEED_SUPER:
1955     speed = "5000"; break;
1956     + case USB_SPEED_SUPER_PLUS:
1957     + speed = "10000"; break;
1958     default:
1959     speed = "??";
1960     }
1961     @@ -553,7 +555,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
1962    
1963     /* super/high speed reserves 80%, full/low reserves 90% */
1964     if (usbdev->speed == USB_SPEED_HIGH ||
1965     - usbdev->speed == USB_SPEED_SUPER)
1966     + usbdev->speed >= USB_SPEED_SUPER)
1967     max = 800;
1968     else
1969     max = FRAME_TIME_MAX_USECS_ALLOC;
1970     diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1971     index 3ffb01ff6549..f5c92d904ded 100644
1972     --- a/drivers/usb/core/devio.c
1973     +++ b/drivers/usb/core/devio.c
1974     @@ -1530,11 +1530,17 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1975     as->urb->start_frame = uurb->start_frame;
1976     as->urb->number_of_packets = number_of_packets;
1977     as->urb->stream_id = stream_id;
1978     - if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
1979     - ps->dev->speed == USB_SPEED_HIGH)
1980     - as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);
1981     - else
1982     - as->urb->interval = ep->desc.bInterval;
1983     +
1984     + if (ep->desc.bInterval) {
1985     + if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
1986     + ps->dev->speed == USB_SPEED_HIGH ||
1987     + ps->dev->speed >= USB_SPEED_SUPER)
1988     + as->urb->interval = 1 <<
1989     + min(15, ep->desc.bInterval - 1);
1990     + else
1991     + as->urb->interval = ep->desc.bInterval;
1992     + }
1993     +
1994     as->urb->context = as;
1995     as->urb->complete = async_completed;
1996     for (totlen = u = 0; u < number_of_packets; u++) {
1997     diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
1998     index b8b580e5ae6e..40378487e023 100644
1999     --- a/drivers/usb/core/hcd-pci.c
2000     +++ b/drivers/usb/core/hcd-pci.c
2001     @@ -206,7 +206,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
2002     * The xHCI driver has its own irq management
2003     * make sure irq setup is not touched for xhci in generic hcd code
2004     */
2005     - if ((driver->flags & HCD_MASK) != HCD_USB3) {
2006     + if ((driver->flags & HCD_MASK) < HCD_USB3) {
2007     if (!dev->irq) {
2008     dev_err(&dev->dev,
2009     "Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
2010     diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
2011     index 1c102d60cd9f..f44ce09367bc 100644
2012     --- a/drivers/usb/core/hcd.c
2013     +++ b/drivers/usb/core/hcd.c
2014     @@ -1078,7 +1078,7 @@ static int register_root_hub(struct usb_hcd *hcd)
2015     retval = usb_get_bos_descriptor(usb_dev);
2016     if (!retval) {
2017     usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev);
2018     - } else if (usb_dev->speed == USB_SPEED_SUPER) {
2019     + } else if (usb_dev->speed >= USB_SPEED_SUPER) {
2020     mutex_unlock(&usb_bus_list_lock);
2021     dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",
2022     dev_name(&usb_dev->dev), retval);
2023     @@ -2112,7 +2112,7 @@ int usb_alloc_streams(struct usb_interface *interface,
2024     hcd = bus_to_hcd(dev->bus);
2025     if (!hcd->driver->alloc_streams || !hcd->driver->free_streams)
2026     return -EINVAL;
2027     - if (dev->speed != USB_SPEED_SUPER)
2028     + if (dev->speed < USB_SPEED_SUPER)
2029     return -EINVAL;
2030     if (dev->state < USB_STATE_CONFIGURED)
2031     return -ENODEV;
2032     @@ -2160,7 +2160,7 @@ int usb_free_streams(struct usb_interface *interface,
2033    
2034     dev = interface_to_usbdev(interface);
2035     hcd = bus_to_hcd(dev->bus);
2036     - if (dev->speed != USB_SPEED_SUPER)
2037     + if (dev->speed < USB_SPEED_SUPER)
2038     return -EINVAL;
2039    
2040     /* Double-free is not allowed */
2041     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2042     index 84df093639ac..bcc1e1b729ad 100644
2043     --- a/drivers/usb/core/hub.c
2044     +++ b/drivers/usb/core/hub.c
2045     @@ -298,7 +298,7 @@ static void usb_set_lpm_parameters(struct usb_device *udev)
2046     unsigned int hub_u1_del;
2047     unsigned int hub_u2_del;
2048    
2049     - if (!udev->lpm_capable || udev->speed != USB_SPEED_SUPER)
2050     + if (!udev->lpm_capable || udev->speed < USB_SPEED_SUPER)
2051     return;
2052    
2053     hub = usb_hub_to_struct_hub(udev->parent);
2054     @@ -1036,14 +1036,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
2055    
2056     /* Continue a partial initialization */
2057     if (type == HUB_INIT2 || type == HUB_INIT3) {
2058     - device_lock(hub->intfdev);
2059     + device_lock(&hdev->dev);
2060    
2061     /* Was the hub disconnected while we were waiting? */
2062     - if (hub->disconnected) {
2063     - device_unlock(hub->intfdev);
2064     - kref_put(&hub->kref, hub_release);
2065     - return;
2066     - }
2067     + if (hub->disconnected)
2068     + goto disconnected;
2069     if (type == HUB_INIT2)
2070     goto init2;
2071     goto init3;
2072     @@ -1246,7 +1243,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
2073     queue_delayed_work(system_power_efficient_wq,
2074     &hub->init_work,
2075     msecs_to_jiffies(delay));
2076     - device_unlock(hub->intfdev);
2077     + device_unlock(&hdev->dev);
2078     return; /* Continues at init3: below */
2079     } else {
2080     msleep(delay);
2081     @@ -1265,12 +1262,12 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
2082     /* Scan all ports that need attention */
2083     kick_hub_wq(hub);
2084    
2085     - /* Allow autosuspend if it was suppressed */
2086     - if (type <= HUB_INIT3)
2087     + if (type == HUB_INIT2 || type == HUB_INIT3) {
2088     + /* Allow autosuspend if it was suppressed */
2089     + disconnected:
2090     usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
2091     -
2092     - if (type == HUB_INIT2 || type == HUB_INIT3)
2093     - device_unlock(hub->intfdev);
2094     + device_unlock(&hdev->dev);
2095     + }
2096    
2097     kref_put(&hub->kref, hub_release);
2098     }
2099     @@ -1299,8 +1296,6 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
2100     struct usb_device *hdev = hub->hdev;
2101     int i;
2102    
2103     - cancel_delayed_work_sync(&hub->init_work);
2104     -
2105     /* hub_wq and related activity won't re-trigger */
2106     hub->quiescing = 1;
2107    
2108     @@ -2645,7 +2640,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
2109     */
2110     static bool use_new_scheme(struct usb_device *udev, int retry)
2111     {
2112     - if (udev->speed == USB_SPEED_SUPER)
2113     + if (udev->speed >= USB_SPEED_SUPER)
2114     return false;
2115    
2116     return USE_NEW_SCHEME(retry);
2117     @@ -3985,7 +3980,7 @@ int usb_disable_lpm(struct usb_device *udev)
2118     struct usb_hcd *hcd;
2119    
2120     if (!udev || !udev->parent ||
2121     - udev->speed != USB_SPEED_SUPER ||
2122     + udev->speed < USB_SPEED_SUPER ||
2123     !udev->lpm_capable ||
2124     udev->state < USB_STATE_DEFAULT)
2125     return 0;
2126     @@ -4042,7 +4037,7 @@ void usb_enable_lpm(struct usb_device *udev)
2127     struct usb_hcd *hcd;
2128    
2129     if (!udev || !udev->parent ||
2130     - udev->speed != USB_SPEED_SUPER ||
2131     + udev->speed < USB_SPEED_SUPER ||
2132     !udev->lpm_capable ||
2133     udev->state < USB_STATE_DEFAULT)
2134     return;
2135     @@ -4308,7 +4303,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2136    
2137     retval = -ENODEV;
2138    
2139     - if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) {
2140     + /* Don't allow speed changes at reset, except usb 3.0 to faster */
2141     + if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed &&
2142     + !(oldspeed == USB_SPEED_SUPER && udev->speed > oldspeed)) {
2143     dev_dbg(&udev->dev, "device reset changed speed!\n");
2144     goto fail;
2145     }
2146     @@ -4320,6 +4317,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2147     * reported as 0xff in the device descriptor). WUSB1.0[4.8.1].
2148     */
2149     switch (udev->speed) {
2150     + case USB_SPEED_SUPER_PLUS:
2151     case USB_SPEED_SUPER:
2152     case USB_SPEED_WIRELESS: /* fixed at 512 */
2153     udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
2154     @@ -4346,7 +4344,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2155     else
2156     speed = usb_speed_string(udev->speed);
2157    
2158     - if (udev->speed != USB_SPEED_SUPER)
2159     + if (udev->speed < USB_SPEED_SUPER)
2160     dev_info(&udev->dev,
2161     "%s %s USB device number %d using %s\n",
2162     (udev->config) ? "reset" : "new", speed,
2163     @@ -4476,11 +4474,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2164     devnum, retval);
2165     goto fail;
2166     }
2167     - if (udev->speed == USB_SPEED_SUPER) {
2168     + if (udev->speed >= USB_SPEED_SUPER) {
2169     devnum = udev->devnum;
2170     dev_info(&udev->dev,
2171     - "%s SuperSpeed USB device number %d using %s\n",
2172     + "%s SuperSpeed%s USB device number %d using %s\n",
2173     (udev->config) ? "reset" : "new",
2174     + (udev->speed == USB_SPEED_SUPER_PLUS) ? "Plus" : "",
2175     devnum, udev->bus->controller->driver->name);
2176     }
2177    
2178     @@ -4519,7 +4518,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2179     * got from those devices show they aren't superspeed devices. Warm
2180     * reset the port attached by the devices can fix them.
2181     */
2182     - if ((udev->speed == USB_SPEED_SUPER) &&
2183     + if ((udev->speed >= USB_SPEED_SUPER) &&
2184     (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) {
2185     dev_err(&udev->dev, "got a wrong device descriptor, "
2186     "warm reset device\n");
2187     @@ -4530,7 +4529,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
2188     }
2189    
2190     if (udev->descriptor.bMaxPacketSize0 == 0xff ||
2191     - udev->speed == USB_SPEED_SUPER)
2192     + udev->speed >= USB_SPEED_SUPER)
2193     i = 512;
2194     else
2195     i = udev->descriptor.bMaxPacketSize0;
2196     @@ -4740,7 +4739,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
2197     udev->level = hdev->level + 1;
2198     udev->wusb = hub_is_wusb(hub);
2199    
2200     - /* Only USB 3.0 devices are connected to SuperSpeed hubs. */
2201     + /* Devices connected to SuperSpeed hubs are USB 3.0 or later */
2202     if (hub_is_superspeed(hub->hdev))
2203     udev->speed = USB_SPEED_SUPER;
2204     else
2205     diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
2206     index 3d274778caaf..c601e25b609f 100644
2207     --- a/drivers/usb/core/urb.c
2208     +++ b/drivers/usb/core/urb.c
2209     @@ -401,7 +401,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
2210     /* SuperSpeed isoc endpoints have up to 16 bursts of up to
2211     * 3 packets each
2212     */
2213     - if (dev->speed == USB_SPEED_SUPER) {
2214     + if (dev->speed >= USB_SPEED_SUPER) {
2215     int burst = 1 + ep->ss_ep_comp.bMaxBurst;
2216     int mult = USB_SS_MULT(ep->ss_ep_comp.bmAttributes);
2217     max *= burst;
2218     @@ -499,6 +499,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
2219     }
2220     /* too big? */
2221     switch (dev->speed) {
2222     + case USB_SPEED_SUPER_PLUS:
2223     case USB_SPEED_SUPER: /* units are 125us */
2224     /* Handle up to 2^(16-1) microframes */
2225     if (urb->interval > (1 << 15))
2226     diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
2227     index 05b5e17abf92..53318126ed91 100644
2228     --- a/drivers/usb/core/usb.h
2229     +++ b/drivers/usb/core/usb.h
2230     @@ -45,7 +45,7 @@ static inline unsigned usb_get_max_power(struct usb_device *udev,
2231     struct usb_host_config *c)
2232     {
2233     /* SuperSpeed power is in 8 mA units; others are in 2 mA units */
2234     - unsigned mul = (udev->speed == USB_SPEED_SUPER ? 8 : 2);
2235     + unsigned mul = (udev->speed >= USB_SPEED_SUPER ? 8 : 2);
2236    
2237     return c->desc.bMaxPower * mul;
2238     }
2239     diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
2240     index 009d83048c8c..3d731d1b5c60 100644
2241     --- a/drivers/usb/dwc3/dwc3-pci.c
2242     +++ b/drivers/usb/dwc3/dwc3-pci.c
2243     @@ -36,6 +36,7 @@
2244     #define PCI_DEVICE_ID_INTEL_SPTH 0xa130
2245     #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
2246     #define PCI_DEVICE_ID_INTEL_APL 0x5aaa
2247     +#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
2248    
2249     static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
2250     static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
2251     @@ -214,6 +215,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
2252     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTH), },
2253     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
2254     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
2255     + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
2256     { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
2257     { } /* Terminating Entry */
2258     };
2259     diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
2260     index 70900e6ca9bc..fb79dca9484b 100644
2261     --- a/drivers/usb/dwc3/gadget.c
2262     +++ b/drivers/usb/dwc3/gadget.c
2263     @@ -1892,14 +1892,6 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
2264     s_pkt = 1;
2265     }
2266    
2267     - /*
2268     - * We assume here we will always receive the entire data block
2269     - * which we should receive. Meaning, if we program RX to
2270     - * receive 4K but we receive only 2K, we assume that's all we
2271     - * should receive and we simply bounce the request back to the
2272     - * gadget driver for further processing.
2273     - */
2274     - req->request.actual += req->request.length - count;
2275     if (s_pkt)
2276     return 1;
2277     if ((event->status & DEPEVT_STATUS_LST) &&
2278     @@ -1919,6 +1911,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
2279     struct dwc3_trb *trb;
2280     unsigned int slot;
2281     unsigned int i;
2282     + int count = 0;
2283     int ret;
2284    
2285     do {
2286     @@ -1935,6 +1928,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
2287     slot++;
2288     slot %= DWC3_TRB_NUM;
2289     trb = &dep->trb_pool[slot];
2290     + count += trb->size & DWC3_TRB_SIZE_MASK;
2291     +
2292    
2293     ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
2294     event, status);
2295     @@ -1942,6 +1937,14 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
2296     break;
2297     } while (++i < req->request.num_mapped_sgs);
2298    
2299     + /*
2300     + * We assume here we will always receive the entire data block
2301     + * which we should receive. Meaning, if we program RX to
2302     + * receive 4K but we receive only 2K, we assume that's all we
2303     + * should receive and we simply bounce the request back to the
2304     + * gadget driver for further processing.
2305     + */
2306     + req->request.actual += req->request.length - count;
2307     dwc3_gadget_giveback(dep, req, status);
2308    
2309     if (ret)
2310     diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
2311     index 55386619a0f1..e57f48f9528f 100644
2312     --- a/drivers/usb/gadget/legacy/inode.c
2313     +++ b/drivers/usb/gadget/legacy/inode.c
2314     @@ -541,7 +541,7 @@ static ssize_t ep_aio(struct kiocb *iocb,
2315     */
2316     spin_lock_irq(&epdata->dev->lock);
2317     value = -ENODEV;
2318     - if (unlikely(epdata->ep))
2319     + if (unlikely(epdata->ep == NULL))
2320     goto fail;
2321    
2322     req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
2323     diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
2324     index 5fb6f8b4f0b4..c73689b72f95 100644
2325     --- a/drivers/usb/gadget/udc/fsl_qe_udc.c
2326     +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
2327     @@ -2053,7 +2053,7 @@ static void setup_received_handle(struct qe_udc *udc,
2328     struct qe_ep *ep;
2329    
2330     if (wValue != 0 || wLength != 0
2331     - || pipe > USB_MAX_ENDPOINTS)
2332     + || pipe >= USB_MAX_ENDPOINTS)
2333     break;
2334     ep = &udc->eps[pipe];
2335    
2336     diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
2337     index 48c92bf78bd0..f7661d9750fd 100644
2338     --- a/drivers/usb/host/ehci-hcd.c
2339     +++ b/drivers/usb/host/ehci-hcd.c
2340     @@ -332,11 +332,11 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci)
2341     int port = HCS_N_PORTS(ehci->hcs_params);
2342    
2343     while (port--) {
2344     - ehci_writel(ehci, PORT_RWC_BITS,
2345     - &ehci->regs->port_status[port]);
2346     spin_unlock_irq(&ehci->lock);
2347     ehci_port_power(ehci, port, false);
2348     spin_lock_irq(&ehci->lock);
2349     + ehci_writel(ehci, PORT_RWC_BITS,
2350     + &ehci->regs->port_status[port]);
2351     }
2352     }
2353    
2354     diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
2355     index f980c239eded..1da876605e4d 100644
2356     --- a/drivers/usb/host/xhci-hub.c
2357     +++ b/drivers/usb/host/xhci-hub.c
2358     @@ -377,6 +377,9 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
2359    
2360     ret = 0;
2361     virt_dev = xhci->devs[slot_id];
2362     + if (!virt_dev)
2363     + return -ENODEV;
2364     +
2365     cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
2366     if (!cmd) {
2367     xhci_dbg(xhci, "Couldn't allocate command structure.\n");
2368     diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
2369     index d8dbd7e5194b..8ea2c05beca2 100644
2370     --- a/drivers/usb/host/xhci-mem.c
2371     +++ b/drivers/usb/host/xhci-mem.c
2372     @@ -1072,7 +1072,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
2373     struct usb_device *top_dev;
2374     struct usb_hcd *hcd;
2375    
2376     - if (udev->speed == USB_SPEED_SUPER)
2377     + if (udev->speed >= USB_SPEED_SUPER)
2378     hcd = xhci->shared_hcd;
2379     else
2380     hcd = xhci->main_hcd;
2381     @@ -1107,6 +1107,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
2382     /* 3) Only the control endpoint is valid - one endpoint context */
2383     slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route);
2384     switch (udev->speed) {
2385     + case USB_SPEED_SUPER_PLUS:
2386     case USB_SPEED_SUPER:
2387     slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS);
2388     max_packets = MAX_PACKET(512);
2389     @@ -1294,6 +1295,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
2390     }
2391     /* Fall through - SS and HS isoc/int have same decoding */
2392    
2393     + case USB_SPEED_SUPER_PLUS:
2394     case USB_SPEED_SUPER:
2395     if (usb_endpoint_xfer_int(&ep->desc) ||
2396     usb_endpoint_xfer_isoc(&ep->desc)) {
2397     @@ -1334,7 +1336,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
2398     static u32 xhci_get_endpoint_mult(struct usb_device *udev,
2399     struct usb_host_endpoint *ep)
2400     {
2401     - if (udev->speed != USB_SPEED_SUPER ||
2402     + if (udev->speed < USB_SPEED_SUPER ||
2403     !usb_endpoint_xfer_isoc(&ep->desc))
2404     return 0;
2405     return ep->ss_ep_comp.bmAttributes;
2406     @@ -1384,7 +1386,7 @@ static u32 xhci_get_max_esit_payload(struct usb_device *udev,
2407     usb_endpoint_xfer_bulk(&ep->desc))
2408     return 0;
2409    
2410     - if (udev->speed == USB_SPEED_SUPER)
2411     + if (udev->speed >= USB_SPEED_SUPER)
2412     return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
2413    
2414     max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
2415     @@ -1455,6 +1457,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
2416     max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
2417     max_burst = 0;
2418     switch (udev->speed) {
2419     + case USB_SPEED_SUPER_PLUS:
2420     case USB_SPEED_SUPER:
2421     /* dig out max burst from ep companion desc */
2422     max_burst = ep->ss_ep_comp.bMaxBurst;
2423     diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
2424     index de644e56aa3b..963867c2c1d5 100644
2425     --- a/drivers/usb/host/xhci-pci.c
2426     +++ b/drivers/usb/host/xhci-pci.c
2427     @@ -311,11 +311,12 @@ static void xhci_pci_remove(struct pci_dev *dev)
2428     usb_remove_hcd(xhci->shared_hcd);
2429     usb_put_hcd(xhci->shared_hcd);
2430     }
2431     - usb_hcd_pci_remove(dev);
2432    
2433     /* Workaround for spurious wakeups at shutdown with HSW */
2434     if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
2435     pci_set_power_state(dev, PCI_D3hot);
2436     +
2437     + usb_hcd_pci_remove(dev);
2438     }
2439    
2440     #ifdef CONFIG_PM
2441     diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
2442     index 34cd23724bed..1f37b89e7267 100644
2443     --- a/drivers/usb/host/xhci-ring.c
2444     +++ b/drivers/usb/host/xhci-ring.c
2445     @@ -1331,12 +1331,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
2446    
2447     cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
2448    
2449     - if (cmd->command_trb != xhci->cmd_ring->dequeue) {
2450     - xhci_err(xhci,
2451     - "Command completion event does not match command\n");
2452     - return;
2453     - }
2454     -
2455     del_timer(&xhci->cmd_timer);
2456    
2457     trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
2458     @@ -1348,6 +1342,13 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
2459     xhci_handle_stopped_cmd_ring(xhci, cmd);
2460     return;
2461     }
2462     +
2463     + if (cmd->command_trb != xhci->cmd_ring->dequeue) {
2464     + xhci_err(xhci,
2465     + "Command completion event does not match command\n");
2466     + return;
2467     + }
2468     +
2469     /*
2470     * Host aborted the command ring, check if the current command was
2471     * supposed to be aborted, otherwise continue normally.
2472     @@ -3575,7 +3576,7 @@ static unsigned int xhci_get_burst_count(struct xhci_hcd *xhci,
2473     {
2474     unsigned int max_burst;
2475    
2476     - if (xhci->hci_version < 0x100 || udev->speed != USB_SPEED_SUPER)
2477     + if (xhci->hci_version < 0x100 || udev->speed < USB_SPEED_SUPER)
2478     return 0;
2479    
2480     max_burst = urb->ep->ss_ep_comp.bMaxBurst;
2481     @@ -3601,6 +3602,7 @@ static unsigned int xhci_get_last_burst_packet_count(struct xhci_hcd *xhci,
2482     return 0;
2483    
2484     switch (udev->speed) {
2485     + case USB_SPEED_SUPER_PLUS:
2486     case USB_SPEED_SUPER:
2487     /* bMaxBurst is zero based: 0 means 1 packet per burst */
2488     max_burst = urb->ep->ss_ep_comp.bMaxBurst;
2489     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2490     index 6fe0174da226..adc169d2fd76 100644
2491     --- a/drivers/usb/host/xhci.c
2492     +++ b/drivers/usb/host/xhci.c
2493     @@ -2073,6 +2073,7 @@ static unsigned int xhci_get_block_size(struct usb_device *udev)
2494     case USB_SPEED_HIGH:
2495     return HS_BLOCK;
2496     case USB_SPEED_SUPER:
2497     + case USB_SPEED_SUPER_PLUS:
2498     return SS_BLOCK;
2499     case USB_SPEED_UNKNOWN:
2500     case USB_SPEED_WIRELESS:
2501     @@ -2198,7 +2199,7 @@ static int xhci_check_bw_table(struct xhci_hcd *xhci,
2502     unsigned int packets_remaining = 0;
2503     unsigned int i;
2504    
2505     - if (virt_dev->udev->speed == USB_SPEED_SUPER)
2506     + if (virt_dev->udev->speed >= USB_SPEED_SUPER)
2507     return xhci_check_ss_bw(xhci, virt_dev);
2508    
2509     if (virt_dev->udev->speed == USB_SPEED_HIGH) {
2510     @@ -2399,7 +2400,7 @@ void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci,
2511     if (xhci_is_async_ep(ep_bw->type))
2512     return;
2513    
2514     - if (udev->speed == USB_SPEED_SUPER) {
2515     + if (udev->speed >= USB_SPEED_SUPER) {
2516     if (xhci_is_sync_in_ep(ep_bw->type))
2517     xhci->devs[udev->slot_id]->bw_table->ss_bw_in -=
2518     xhci_get_ss_bw_consumed(ep_bw);
2519     @@ -2437,6 +2438,7 @@ void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci,
2520     interval_bw->overhead[HS_OVERHEAD_TYPE] -= 1;
2521     break;
2522     case USB_SPEED_SUPER:
2523     + case USB_SPEED_SUPER_PLUS:
2524     case USB_SPEED_UNKNOWN:
2525     case USB_SPEED_WIRELESS:
2526     /* Should never happen because only LS/FS/HS endpoints will get
2527     @@ -2496,6 +2498,7 @@ static void xhci_add_ep_to_interval_table(struct xhci_hcd *xhci,
2528     interval_bw->overhead[HS_OVERHEAD_TYPE] += 1;
2529     break;
2530     case USB_SPEED_SUPER:
2531     + case USB_SPEED_SUPER_PLUS:
2532     case USB_SPEED_UNKNOWN:
2533     case USB_SPEED_WIRELESS:
2534     /* Should never happen because only LS/FS/HS endpoints will get
2535     diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
2536     index 1a812eafe670..1624b09d9748 100644
2537     --- a/drivers/usb/misc/usbtest.c
2538     +++ b/drivers/usb/misc/usbtest.c
2539     @@ -558,7 +558,6 @@ static void sg_timeout(unsigned long _req)
2540     {
2541     struct usb_sg_request *req = (struct usb_sg_request *) _req;
2542    
2543     - req->status = -ETIMEDOUT;
2544     usb_sg_cancel(req);
2545     }
2546    
2547     @@ -589,8 +588,10 @@ static int perform_sglist(
2548     mod_timer(&sg_timer, jiffies +
2549     msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
2550     usb_sg_wait(req);
2551     - del_timer_sync(&sg_timer);
2552     - retval = req->status;
2553     + if (!del_timer_sync(&sg_timer))
2554     + retval = -ETIMEDOUT;
2555     + else
2556     + retval = req->status;
2557    
2558     /* FIXME check resulting data pattern */
2559    
2560     diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
2561     index db565f620f82..36e5b5c530bd 100644
2562     --- a/drivers/usb/renesas_usbhs/fifo.c
2563     +++ b/drivers/usb/renesas_usbhs/fifo.c
2564     @@ -869,7 +869,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
2565    
2566     /* use PIO if packet is less than pio_dma_border or pipe is DCP */
2567     if ((len < usbhs_get_dparam(priv, pio_dma_border)) ||
2568     - usbhs_pipe_is_dcp(pipe))
2569     + usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
2570     goto usbhsf_pio_prepare_push;
2571    
2572     /* check data length if this driver don't use USB-DMAC */
2573     @@ -974,7 +974,7 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,
2574    
2575     /* use PIO if packet is less than pio_dma_border or pipe is DCP */
2576     if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) ||
2577     - usbhs_pipe_is_dcp(pipe))
2578     + usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
2579     goto usbhsf_pio_prepare_pop;
2580    
2581     fifo = usbhsf_get_dma_fifo(priv, pkt);
2582     diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
2583     index 5a3abf56d56b..efc4fae123a4 100644
2584     --- a/drivers/usb/renesas_usbhs/mod_gadget.c
2585     +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
2586     @@ -618,10 +618,13 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
2587     * use dmaengine if possible.
2588     * It will use pio handler if impossible.
2589     */
2590     - if (usb_endpoint_dir_in(desc))
2591     + if (usb_endpoint_dir_in(desc)) {
2592     pipe->handler = &usbhs_fifo_dma_push_handler;
2593     - else
2594     + } else {
2595     pipe->handler = &usbhs_fifo_dma_pop_handler;
2596     + usbhs_xxxsts_clear(priv, BRDYSTS,
2597     + usbhs_pipe_number(pipe));
2598     + }
2599    
2600     ret = 0;
2601     }
2602     @@ -1072,7 +1075,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
2603    
2604     gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
2605     dev_info(dev, "%stransceiver found\n",
2606     - gpriv->transceiver ? "" : "no ");
2607     + !IS_ERR(gpriv->transceiver) ? "" : "no ");
2608    
2609     /*
2610     * CAUTION
2611     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2612     index b61f12160d37..8c48c9d83d48 100644
2613     --- a/drivers/usb/serial/ftdi_sio.c
2614     +++ b/drivers/usb/serial/ftdi_sio.c
2615     @@ -648,6 +648,8 @@ static const struct usb_device_id id_table_combined[] = {
2616     { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) },
2617     { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) },
2618     { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) },
2619     + { USB_DEVICE(FTDI_VID, FTDI_PALMSENS_PID) },
2620     + { USB_DEVICE(FTDI_VID, FTDI_IVIUM_XSTAT_PID) },
2621     { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
2622     { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
2623     { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
2624     @@ -1008,6 +1010,7 @@ static const struct usb_device_id id_table_combined[] = {
2625     { USB_DEVICE(ICPDAS_VID, ICPDAS_I7560U_PID) },
2626     { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) },
2627     { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) },
2628     + { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
2629     { } /* Terminating entry */
2630     };
2631    
2632     diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
2633     index c5d6c1e73e8e..f87a938cf005 100644
2634     --- a/drivers/usb/serial/ftdi_sio_ids.h
2635     +++ b/drivers/usb/serial/ftdi_sio_ids.h
2636     @@ -406,6 +406,12 @@
2637     #define FTDI_4N_GALAXY_DE_3_PID 0xF3C2
2638    
2639     /*
2640     + * Ivium Technologies product IDs
2641     + */
2642     +#define FTDI_PALMSENS_PID 0xf440
2643     +#define FTDI_IVIUM_XSTAT_PID 0xf441
2644     +
2645     +/*
2646     * Linx Technologies product ids
2647     */
2648     #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */
2649     @@ -673,6 +679,12 @@
2650     #define INTREPID_NEOVI_PID 0x0701
2651    
2652     /*
2653     + * WICED USB UART
2654     + */
2655     +#define WICED_VID 0x0A5C
2656     +#define WICED_USB20706V2_PID 0x6422
2657     +
2658     +/*
2659     * Definitions for ID TECH (www.idt-net.com) devices
2660     */
2661     #define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */
2662     diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
2663     index 06c7dbc1c802..63db004af21f 100644
2664     --- a/drivers/usb/serial/mos7720.c
2665     +++ b/drivers/usb/serial/mos7720.c
2666     @@ -1252,7 +1252,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
2667    
2668     if (urb->transfer_buffer == NULL) {
2669     urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
2670     - GFP_KERNEL);
2671     + GFP_ATOMIC);
2672     if (!urb->transfer_buffer)
2673     goto exit;
2674     }
2675     diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
2676     index 8ac9b55f05af..7f3ddd7ba2ce 100644
2677     --- a/drivers/usb/serial/mos7840.c
2678     +++ b/drivers/usb/serial/mos7840.c
2679     @@ -1340,8 +1340,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
2680     }
2681    
2682     if (urb->transfer_buffer == NULL) {
2683     - urb->transfer_buffer =
2684     - kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
2685     + urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
2686     + GFP_ATOMIC);
2687     if (!urb->transfer_buffer)
2688     goto exit;
2689     }
2690     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2691     index 8e07536c233a..9894e341c6ac 100644
2692     --- a/drivers/usb/serial/option.c
2693     +++ b/drivers/usb/serial/option.c
2694     @@ -274,6 +274,12 @@ static void option_instat_callback(struct urb *urb);
2695     #define TELIT_PRODUCT_LE920 0x1200
2696     #define TELIT_PRODUCT_LE910 0x1201
2697     #define TELIT_PRODUCT_LE910_USBCFG4 0x1206
2698     +#define TELIT_PRODUCT_LE920A4_1207 0x1207
2699     +#define TELIT_PRODUCT_LE920A4_1208 0x1208
2700     +#define TELIT_PRODUCT_LE920A4_1211 0x1211
2701     +#define TELIT_PRODUCT_LE920A4_1212 0x1212
2702     +#define TELIT_PRODUCT_LE920A4_1213 0x1213
2703     +#define TELIT_PRODUCT_LE920A4_1214 0x1214
2704    
2705     /* ZTE PRODUCTS */
2706     #define ZTE_VENDOR_ID 0x19d2
2707     @@ -519,6 +525,12 @@ static void option_instat_callback(struct urb *urb);
2708     #define VIATELECOM_VENDOR_ID 0x15eb
2709     #define VIATELECOM_PRODUCT_CDS7 0x0001
2710    
2711     +/* WeTelecom products */
2712     +#define WETELECOM_VENDOR_ID 0x22de
2713     +#define WETELECOM_PRODUCT_WMD200 0x6801
2714     +#define WETELECOM_PRODUCT_6802 0x6802
2715     +#define WETELECOM_PRODUCT_WMD300 0x6803
2716     +
2717     struct option_blacklist_info {
2718     /* bitmask of interface numbers blacklisted for send_setup */
2719     const unsigned long sendsetup;
2720     @@ -628,6 +640,11 @@ static const struct option_blacklist_info telit_le920_blacklist = {
2721     .reserved = BIT(1) | BIT(5),
2722     };
2723    
2724     +static const struct option_blacklist_info telit_le920a4_blacklist_1 = {
2725     + .sendsetup = BIT(0),
2726     + .reserved = BIT(1),
2727     +};
2728     +
2729     static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = {
2730     .sendsetup = BIT(2),
2731     .reserved = BIT(0) | BIT(1) | BIT(3),
2732     @@ -1203,6 +1220,16 @@ static const struct usb_device_id option_ids[] = {
2733     .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
2734     { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
2735     .driver_info = (kernel_ulong_t)&telit_le920_blacklist },
2736     + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1207) },
2737     + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1208),
2738     + .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 },
2739     + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1211),
2740     + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
2741     + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1212),
2742     + .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 },
2743     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) },
2744     + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214),
2745     + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
2746     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
2747     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff),
2748     .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
2749     @@ -1966,9 +1993,13 @@ static const struct usb_device_id option_ids[] = {
2750     .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2751     { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
2752     { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
2753     + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
2754     { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
2755     { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
2756     { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
2757     + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) },
2758     + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) },
2759     + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) },
2760     { } /* Terminating entry */
2761     };
2762     MODULE_DEVICE_TABLE(usb, option_ids);
2763     diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
2764     index 46f1f13b41f1..a0ca291bc07f 100644
2765     --- a/drivers/usb/serial/usb-serial.c
2766     +++ b/drivers/usb/serial/usb-serial.c
2767     @@ -1432,7 +1432,7 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[]
2768    
2769     rc = usb_register(udriver);
2770     if (rc)
2771     - return rc;
2772     + goto failed_usb_register;
2773    
2774     for (sd = serial_drivers; *sd; ++sd) {
2775     (*sd)->usb_driver = udriver;
2776     @@ -1450,6 +1450,8 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[]
2777     while (sd-- > serial_drivers)
2778     usb_serial_deregister(*sd);
2779     usb_deregister(udriver);
2780     +failed_usb_register:
2781     + kfree(udriver);
2782     return rc;
2783     }
2784     EXPORT_SYMBOL_GPL(usb_serial_register_drivers);
2785     diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
2786     index 3b3ba15558b7..20e9a86d2dcf 100644
2787     --- a/drivers/vfio/pci/vfio_pci_intrs.c
2788     +++ b/drivers/vfio/pci/vfio_pci_intrs.c
2789     @@ -563,67 +563,80 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_device *vdev,
2790     }
2791    
2792     static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx,
2793     - uint32_t flags, void *data)
2794     + unsigned int count, uint32_t flags,
2795     + void *data)
2796     {
2797     - int32_t fd = *(int32_t *)data;
2798     -
2799     - if (!(flags & VFIO_IRQ_SET_DATA_TYPE_MASK))
2800     - return -EINVAL;
2801     -
2802     /* DATA_NONE/DATA_BOOL enables loopback testing */
2803     if (flags & VFIO_IRQ_SET_DATA_NONE) {
2804     - if (*ctx)
2805     - eventfd_signal(*ctx, 1);
2806     - return 0;
2807     + if (*ctx) {
2808     + if (count) {
2809     + eventfd_signal(*ctx, 1);
2810     + } else {
2811     + eventfd_ctx_put(*ctx);
2812     + *ctx = NULL;
2813     + }
2814     + return 0;
2815     + }
2816     } else if (flags & VFIO_IRQ_SET_DATA_BOOL) {
2817     - uint8_t trigger = *(uint8_t *)data;
2818     + uint8_t trigger;
2819     +
2820     + if (!count)
2821     + return -EINVAL;
2822     +
2823     + trigger = *(uint8_t *)data;
2824     if (trigger && *ctx)
2825     eventfd_signal(*ctx, 1);
2826     - return 0;
2827     - }
2828    
2829     - /* Handle SET_DATA_EVENTFD */
2830     - if (fd == -1) {
2831     - if (*ctx)
2832     - eventfd_ctx_put(*ctx);
2833     - *ctx = NULL;
2834     return 0;
2835     - } else if (fd >= 0) {
2836     - struct eventfd_ctx *efdctx;
2837     - efdctx = eventfd_ctx_fdget(fd);
2838     - if (IS_ERR(efdctx))
2839     - return PTR_ERR(efdctx);
2840     - if (*ctx)
2841     - eventfd_ctx_put(*ctx);
2842     - *ctx = efdctx;
2843     + } else if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
2844     + int32_t fd;
2845     +
2846     + if (!count)
2847     + return -EINVAL;
2848     +
2849     + fd = *(int32_t *)data;
2850     + if (fd == -1) {
2851     + if (*ctx)
2852     + eventfd_ctx_put(*ctx);
2853     + *ctx = NULL;
2854     + } else if (fd >= 0) {
2855     + struct eventfd_ctx *efdctx;
2856     +
2857     + efdctx = eventfd_ctx_fdget(fd);
2858     + if (IS_ERR(efdctx))
2859     + return PTR_ERR(efdctx);
2860     +
2861     + if (*ctx)
2862     + eventfd_ctx_put(*ctx);
2863     +
2864     + *ctx = efdctx;
2865     + }
2866     return 0;
2867     - } else
2868     - return -EINVAL;
2869     + }
2870     +
2871     + return -EINVAL;
2872     }
2873    
2874     static int vfio_pci_set_err_trigger(struct vfio_pci_device *vdev,
2875     unsigned index, unsigned start,
2876     unsigned count, uint32_t flags, void *data)
2877     {
2878     - if (index != VFIO_PCI_ERR_IRQ_INDEX)
2879     + if (index != VFIO_PCI_ERR_IRQ_INDEX || start != 0 || count > 1)
2880     return -EINVAL;
2881    
2882     - /*
2883     - * We should sanitize start & count, but that wasn't caught
2884     - * originally, so this IRQ index must forever ignore them :-(
2885     - */
2886     -
2887     - return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, flags, data);
2888     + return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger,
2889     + count, flags, data);
2890     }
2891    
2892     static int vfio_pci_set_req_trigger(struct vfio_pci_device *vdev,
2893     unsigned index, unsigned start,
2894     unsigned count, uint32_t flags, void *data)
2895     {
2896     - if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count != 1)
2897     + if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count > 1)
2898     return -EINVAL;
2899    
2900     - return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, flags, data);
2901     + return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger,
2902     + count, flags, data);
2903     }
2904    
2905     int vfio_pci_set_irqs_ioctl(struct vfio_pci_device *vdev, uint32_t flags,
2906     diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
2907     index ee663c458b20..dc2b94142f53 100644
2908     --- a/drivers/virtio/virtio_ring.c
2909     +++ b/drivers/virtio/virtio_ring.c
2910     @@ -202,6 +202,8 @@ static inline int virtqueue_add(struct virtqueue *_vq,
2911     * host should service the ring ASAP. */
2912     if (out_sgs)
2913     vq->notify(&vq->vq);
2914     + if (indirect)
2915     + kfree(desc);
2916     END_USE(vq);
2917     return -ENOSPC;
2918     }
2919     diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
2920     index 385b449fd7ed..1391f72c28c3 100644
2921     --- a/fs/btrfs/ctree.h
2922     +++ b/fs/btrfs/ctree.h
2923     @@ -1770,6 +1770,7 @@ struct btrfs_fs_info {
2924     struct btrfs_workqueue *qgroup_rescan_workers;
2925     struct completion qgroup_rescan_completion;
2926     struct btrfs_work qgroup_rescan_work;
2927     + bool qgroup_rescan_running; /* protected by qgroup_rescan_lock */
2928    
2929     /* filesystem state */
2930     unsigned long fs_state;
2931     diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2932     index 41fb43183406..85b207d19aa5 100644
2933     --- a/fs/btrfs/disk-io.c
2934     +++ b/fs/btrfs/disk-io.c
2935     @@ -2276,6 +2276,7 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info)
2936     fs_info->quota_enabled = 0;
2937     fs_info->pending_quota_state = 0;
2938     fs_info->qgroup_ulist = NULL;
2939     + fs_info->qgroup_rescan_running = false;
2940     mutex_init(&fs_info->qgroup_rescan_lock);
2941     }
2942    
2943     @@ -3811,7 +3812,7 @@ void close_ctree(struct btrfs_root *root)
2944     smp_mb();
2945    
2946     /* wait for the qgroup rescan worker to stop */
2947     - btrfs_qgroup_wait_for_completion(fs_info);
2948     + btrfs_qgroup_wait_for_completion(fs_info, false);
2949    
2950     /* wait for the uuid_scan task to finish */
2951     down(&fs_info->uuid_tree_rescan_sem);
2952     diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
2953     index bfcd87ee8ff5..65f30b3b04f9 100644
2954     --- a/fs/btrfs/ioctl.c
2955     +++ b/fs/btrfs/ioctl.c
2956     @@ -5121,7 +5121,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg)
2957     if (!capable(CAP_SYS_ADMIN))
2958     return -EPERM;
2959    
2960     - return btrfs_qgroup_wait_for_completion(root->fs_info);
2961     + return btrfs_qgroup_wait_for_completion(root->fs_info, true);
2962     }
2963    
2964     static long _btrfs_ioctl_set_received_subvol(struct file *file,
2965     diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
2966     index 5279fdae7142..bcc965ed5fa1 100644
2967     --- a/fs/btrfs/qgroup.c
2968     +++ b/fs/btrfs/qgroup.c
2969     @@ -995,7 +995,7 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans,
2970     goto out;
2971     fs_info->quota_enabled = 0;
2972     fs_info->pending_quota_state = 0;
2973     - btrfs_qgroup_wait_for_completion(fs_info);
2974     + btrfs_qgroup_wait_for_completion(fs_info, false);
2975     spin_lock(&fs_info->qgroup_lock);
2976     quota_root = fs_info->quota_root;
2977     fs_info->quota_root = NULL;
2978     @@ -2283,6 +2283,10 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
2979     int err = -ENOMEM;
2980     int ret = 0;
2981    
2982     + mutex_lock(&fs_info->qgroup_rescan_lock);
2983     + fs_info->qgroup_rescan_running = true;
2984     + mutex_unlock(&fs_info->qgroup_rescan_lock);
2985     +
2986     path = btrfs_alloc_path();
2987     if (!path)
2988     goto out;
2989     @@ -2349,6 +2353,9 @@ out:
2990     }
2991    
2992     done:
2993     + mutex_lock(&fs_info->qgroup_rescan_lock);
2994     + fs_info->qgroup_rescan_running = false;
2995     + mutex_unlock(&fs_info->qgroup_rescan_lock);
2996     complete_all(&fs_info->qgroup_rescan_completion);
2997     }
2998    
2999     @@ -2467,20 +2474,26 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info)
3000     return 0;
3001     }
3002    
3003     -int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info)
3004     +int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,
3005     + bool interruptible)
3006     {
3007     int running;
3008     int ret = 0;
3009    
3010     mutex_lock(&fs_info->qgroup_rescan_lock);
3011     spin_lock(&fs_info->qgroup_lock);
3012     - running = fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN;
3013     + running = fs_info->qgroup_rescan_running;
3014     spin_unlock(&fs_info->qgroup_lock);
3015     mutex_unlock(&fs_info->qgroup_rescan_lock);
3016    
3017     - if (running)
3018     + if (!running)
3019     + return 0;
3020     +
3021     + if (interruptible)
3022     ret = wait_for_completion_interruptible(
3023     &fs_info->qgroup_rescan_completion);
3024     + else
3025     + wait_for_completion(&fs_info->qgroup_rescan_completion);
3026    
3027     return ret;
3028     }
3029     diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
3030     index ecb2c143ef75..3d73e4c9c7df 100644
3031     --- a/fs/btrfs/qgroup.h
3032     +++ b/fs/btrfs/qgroup.h
3033     @@ -46,7 +46,8 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans,
3034     struct btrfs_fs_info *fs_info);
3035     int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info);
3036     void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info);
3037     -int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info);
3038     +int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,
3039     + bool interruptible);
3040     int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans,
3041     struct btrfs_fs_info *fs_info, u64 src, u64 dst);
3042     int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans,
3043     diff --git a/fs/seq_file.c b/fs/seq_file.c
3044     index e85664b7c7d9..d672e2fec459 100644
3045     --- a/fs/seq_file.c
3046     +++ b/fs/seq_file.c
3047     @@ -222,8 +222,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
3048     size -= n;
3049     buf += n;
3050     copied += n;
3051     - if (!m->count)
3052     + if (!m->count) {
3053     + m->from = 0;
3054     m->index++;
3055     + }
3056     if (!size)
3057     goto Done;
3058     }
3059     diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
3060     index f35523d4fa3a..b803213d1307 100644
3061     --- a/fs/sysfs/file.c
3062     +++ b/fs/sysfs/file.c
3063     @@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,
3064     * If buf != of->prealloc_buf, we don't know how
3065     * large it is, so cannot safely pass it to ->show
3066     */
3067     - if (pos || WARN_ON_ONCE(buf != of->prealloc_buf))
3068     + if (WARN_ON_ONCE(buf != of->prealloc_buf))
3069     return 0;
3070     len = ops->show(kobj, of->kn->priv, buf);
3071     + if (pos) {
3072     + if (len <= pos)
3073     + return 0;
3074     + len -= pos;
3075     + memmove(buf, buf + pos, len);
3076     + }
3077     return min(count, len);
3078     }
3079    
3080     diff --git a/include/linux/acpi.h b/include/linux/acpi.h
3081     index 1991aea2ec4c..3672893b275e 100644
3082     --- a/include/linux/acpi.h
3083     +++ b/include/linux/acpi.h
3084     @@ -920,7 +920,7 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
3085     return NULL;
3086     }
3087    
3088     -#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \
3089     +#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
3090     static const void * __acpi_table_##name[] \
3091     __attribute__((unused)) \
3092     = { (void *) table_id, \
3093     diff --git a/include/linux/i8042.h b/include/linux/i8042.h
3094     index 0f9bafa17a02..d98780ca9604 100644
3095     --- a/include/linux/i8042.h
3096     +++ b/include/linux/i8042.h
3097     @@ -62,7 +62,6 @@ struct serio;
3098     void i8042_lock_chip(void);
3099     void i8042_unlock_chip(void);
3100     int i8042_command(unsigned char *param, int command);
3101     -bool i8042_check_port_owner(const struct serio *);
3102     int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
3103     struct serio *serio));
3104     int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
3105     @@ -83,11 +82,6 @@ static inline int i8042_command(unsigned char *param, int command)
3106     return -ENODEV;
3107     }
3108    
3109     -static inline bool i8042_check_port_owner(const struct serio *serio)
3110     -{
3111     - return false;
3112     -}
3113     -
3114     static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
3115     struct serio *serio))
3116     {
3117     diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
3118     index 494682ce4bf3..3ab3cede28ea 100644
3119     --- a/include/linux/mfd/cros_ec.h
3120     +++ b/include/linux/mfd/cros_ec.h
3121     @@ -224,6 +224,21 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
3122     struct cros_ec_command *msg);
3123    
3124     /**
3125     + * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC
3126     + *
3127     + * This function is identical to cros_ec_cmd_xfer, except it returns success
3128     + * status only if both the command was transmitted successfully and the EC
3129     + * replied with success status. It's not necessary to check msg->result when
3130     + * using this function.
3131     + *
3132     + * @ec_dev: EC device
3133     + * @msg: Message to write
3134     + * @return: Num. of bytes transferred on success, <0 on failure
3135     + */
3136     +int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
3137     + struct cros_ec_command *msg);
3138     +
3139     +/**
3140     * cros_ec_remove - Remove a ChromeOS EC
3141     *
3142     * Call this to deregister a ChromeOS EC, then clean up any private data.
3143     diff --git a/include/linux/msi.h b/include/linux/msi.h
3144     index f71a25e5fd25..f0f43ec45ee7 100644
3145     --- a/include/linux/msi.h
3146     +++ b/include/linux/msi.h
3147     @@ -254,12 +254,12 @@ enum {
3148     * callbacks.
3149     */
3150     MSI_FLAG_USE_DEF_CHIP_OPS = (1 << 1),
3151     - /* Build identity map between hwirq and irq */
3152     - MSI_FLAG_IDENTITY_MAP = (1 << 2),
3153     /* Support multiple PCI MSI interrupts */
3154     - MSI_FLAG_MULTI_PCI_MSI = (1 << 3),
3155     + MSI_FLAG_MULTI_PCI_MSI = (1 << 2),
3156     /* Support PCI MSIX interrupts */
3157     - MSI_FLAG_PCI_MSIX = (1 << 4),
3158     + MSI_FLAG_PCI_MSIX = (1 << 3),
3159     + /* Needs early activate, required for PCI */
3160     + MSI_FLAG_ACTIVATE_EARLY = (1 << 4),
3161     };
3162    
3163     int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
3164     diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
3165     index d9ba49cedc5d..37f05cb1dfd6 100644
3166     --- a/include/linux/pci_ids.h
3167     +++ b/include/linux/pci_ids.h
3168     @@ -2495,6 +2495,13 @@
3169     #define PCI_DEVICE_ID_KORENIX_JETCARDF2 0x1700
3170     #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff
3171    
3172     +#define PCI_VENDOR_ID_NETRONOME 0x19ee
3173     +#define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200
3174     +#define PCI_DEVICE_ID_NETRONOME_NFP3240 0x3240
3175     +#define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000
3176     +#define PCI_DEVICE_ID_NETRONOME_NFP6000 0x6000
3177     +#define PCI_DEVICE_ID_NETRONOME_NFP6000_VF 0x6003
3178     +
3179     #define PCI_VENDOR_ID_QMI 0x1a32
3180    
3181     #define PCI_VENDOR_ID_AZWAVE 0x1a3b
3182     diff --git a/include/linux/serio.h b/include/linux/serio.h
3183     index df4ab5de1586..c733cff44e18 100644
3184     --- a/include/linux/serio.h
3185     +++ b/include/linux/serio.h
3186     @@ -31,7 +31,8 @@ struct serio {
3187    
3188     struct serio_device_id id;
3189    
3190     - spinlock_t lock; /* protects critical sections from port's interrupt handler */
3191     + /* Protects critical sections from port's interrupt handler */
3192     + spinlock_t lock;
3193    
3194     int (*write)(struct serio *, unsigned char);
3195     int (*open)(struct serio *);
3196     @@ -40,16 +41,29 @@ struct serio {
3197     void (*stop)(struct serio *);
3198    
3199     struct serio *parent;
3200     - struct list_head child_node; /* Entry in parent->children list */
3201     + /* Entry in parent->children list */
3202     + struct list_head child_node;
3203     struct list_head children;
3204     - unsigned int depth; /* level of nesting in serio hierarchy */
3205     + /* Level of nesting in serio hierarchy */
3206     + unsigned int depth;
3207    
3208     - struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
3209     - struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
3210     + /*
3211     + * serio->drv is accessed from interrupt handlers; when modifying
3212     + * caller should acquire serio->drv_mutex and serio->lock.
3213     + */
3214     + struct serio_driver *drv;
3215     + /* Protects serio->drv so attributes can pin current driver */
3216     + struct mutex drv_mutex;
3217    
3218     struct device dev;
3219    
3220     struct list_head node;
3221     +
3222     + /*
3223     + * For use by PS/2 layer when several ports share hardware and
3224     + * may get indigestion when exposed to concurrent access (i8042).
3225     + */
3226     + struct mutex *ps2_cmd_mutex;
3227     };
3228     #define to_serio_port(d) container_of(d, struct serio, dev)
3229    
3230     diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
3231     index 4338eb7b09b3..779a62aafafe 100644
3232     --- a/include/uapi/linux/usb/ch9.h
3233     +++ b/include/uapi/linux/usb/ch9.h
3234     @@ -954,6 +954,7 @@ enum usb_device_speed {
3235     USB_SPEED_HIGH, /* usb 2.0 */
3236     USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
3237     USB_SPEED_SUPER, /* usb 3.0 */
3238     + USB_SPEED_SUPER_PLUS, /* usb 3.1 */
3239     };
3240    
3241    
3242     diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
3243     index 6b0c0b74a2a1..4b21779d5163 100644
3244     --- a/kernel/irq/msi.c
3245     +++ b/kernel/irq/msi.c
3246     @@ -268,7 +268,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
3247     struct msi_domain_ops *ops = info->ops;
3248     msi_alloc_info_t arg;
3249     struct msi_desc *desc;
3250     - int i, ret, virq = -1;
3251     + int i, ret, virq;
3252    
3253     ret = ops->msi_check(domain, info, dev);
3254     if (ret == 0)
3255     @@ -278,12 +278,8 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
3256    
3257     for_each_msi_entry(desc, dev) {
3258     ops->set_desc(&arg, desc);
3259     - if (info->flags & MSI_FLAG_IDENTITY_MAP)
3260     - virq = (int)ops->get_hwirq(info, &arg);
3261     - else
3262     - virq = -1;
3263    
3264     - virq = __irq_domain_alloc_irqs(domain, virq, desc->nvec_used,
3265     + virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used,
3266     dev_to_node(dev), &arg, false);
3267     if (virq < 0) {
3268     ret = -ENOSPC;
3269     @@ -307,6 +303,17 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
3270     else
3271     dev_dbg(dev, "irq [%d-%d] for MSI\n",
3272     virq, virq + desc->nvec_used - 1);
3273     + /*
3274     + * This flag is set by the PCI layer as we need to activate
3275     + * the MSI entries before the PCI layer enables MSI in the
3276     + * card. Otherwise the card latches a random msi message.
3277     + */
3278     + if (info->flags & MSI_FLAG_ACTIVATE_EARLY) {
3279     + struct irq_data *irq_data;
3280     +
3281     + irq_data = irq_domain_get_irq_data(domain, desc->irq);
3282     + irq_domain_activate_irq(irq_data);
3283     + }
3284     }
3285    
3286     return 0;
3287     diff --git a/kernel/sched/core.c b/kernel/sched/core.c
3288     index 67d1e1597d9c..ea863bc22caf 100644
3289     --- a/kernel/sched/core.c
3290     +++ b/kernel/sched/core.c
3291     @@ -627,7 +627,10 @@ int get_nohz_timer_target(void)
3292     rcu_read_lock();
3293     for_each_domain(cpu, sd) {
3294     for_each_cpu(i, sched_domain_span(sd)) {
3295     - if (!idle_cpu(i) && is_housekeeping_cpu(cpu)) {
3296     + if (cpu == i)
3297     + continue;
3298     +
3299     + if (!idle_cpu(i) && is_housekeeping_cpu(i)) {
3300     cpu = i;
3301     goto unlock;
3302     }
3303     diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
3304     index f74ea89e77a8..a1aecbedf5b1 100644
3305     --- a/kernel/sched/cputime.c
3306     +++ b/kernel/sched/cputime.c
3307     @@ -600,19 +600,25 @@ static void cputime_adjust(struct task_cputime *curr,
3308     stime = curr->stime;
3309     utime = curr->utime;
3310    
3311     - if (utime == 0) {
3312     - stime = rtime;
3313     + /*
3314     + * If either stime or both stime and utime are 0, assume all runtime is
3315     + * userspace. Once a task gets some ticks, the monotonicy code at
3316     + * 'update' will ensure things converge to the observed ratio.
3317     + */
3318     + if (stime == 0) {
3319     + utime = rtime;
3320     goto update;
3321     }
3322    
3323     - if (stime == 0) {
3324     - utime = rtime;
3325     + if (utime == 0) {
3326     + stime = rtime;
3327     goto update;
3328     }
3329    
3330     stime = scale_stime((__force u64)stime, (__force u64)rtime,
3331     (__force u64)(stime + utime));
3332    
3333     +update:
3334     /*
3335     * Make sure stime doesn't go backwards; this preserves monotonicity
3336     * for utime because rtime is monotonic.
3337     @@ -635,7 +641,6 @@ static void cputime_adjust(struct task_cputime *curr,
3338     stime = rtime - utime;
3339     }
3340    
3341     -update:
3342     prev->stime = stime;
3343     prev->utime = utime;
3344     out:
3345     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3346     index 0c31f184daf8..125c7dd55322 100644
3347     --- a/mm/hugetlb.c
3348     +++ b/mm/hugetlb.c
3349     @@ -4213,7 +4213,6 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
3350     if (saddr) {
3351     spte = huge_pte_offset(svma->vm_mm, saddr);
3352     if (spte) {
3353     - mm_inc_nr_pmds(mm);
3354     get_page(virt_to_page(spte));
3355     break;
3356     }
3357     @@ -4228,9 +4227,9 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
3358     if (pud_none(*pud)) {
3359     pud_populate(mm, pud,
3360     (pmd_t *)((unsigned long)spte & PAGE_MASK));
3361     + mm_inc_nr_pmds(mm);
3362     } else {
3363     put_page(virt_to_page(spte));
3364     - mm_inc_nr_pmds(mm);
3365     }
3366     spin_unlock(ptl);
3367     out:
3368     diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
3369     index c12f348138ac..19322c047386 100644
3370     --- a/net/mac80211/cfg.c
3371     +++ b/net/mac80211/cfg.c
3372     @@ -865,7 +865,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3373    
3374     /* free all potentially still buffered bcast frames */
3375     local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
3376     - skb_queue_purge(&sdata->u.ap.ps.bc_buf);
3377     + ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
3378    
3379     mutex_lock(&local->mtx);
3380     ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
3381     diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
3382     index bdc224d5053a..e1225b395415 100644
3383     --- a/net/mac80211/tx.c
3384     +++ b/net/mac80211/tx.c
3385     @@ -365,7 +365,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
3386     skb = skb_dequeue(&ps->bc_buf);
3387     if (skb) {
3388     purged++;
3389     - dev_kfree_skb(skb);
3390     + ieee80211_free_txskb(&local->hw, skb);
3391     }
3392     total += skb_queue_len(&ps->bc_buf);
3393     }
3394     @@ -448,7 +448,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
3395     if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) {
3396     ps_dbg(tx->sdata,
3397     "BC TX buffer full - dropping the oldest frame\n");
3398     - dev_kfree_skb(skb_dequeue(&ps->bc_buf));
3399     + ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf));
3400     } else
3401     tx->local->total_ps_buffered++;
3402    
3403     @@ -3781,7 +3781,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
3404     sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
3405     if (!ieee80211_tx_prepare(sdata, &tx, NULL, skb))
3406     break;
3407     - dev_kfree_skb_any(skb);
3408     + ieee80211_free_txskb(hw, skb);
3409     }
3410    
3411     info = IEEE80211_SKB_CB(skb);
3412     diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
3413     index 799e65b944b9..06095cc8815e 100644
3414     --- a/net/sunrpc/auth_gss/auth_gss.c
3415     +++ b/net/sunrpc/auth_gss/auth_gss.c
3416     @@ -340,12 +340,14 @@ gss_release_msg(struct gss_upcall_msg *gss_msg)
3417     }
3418    
3419     static struct gss_upcall_msg *
3420     -__gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid)
3421     +__gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid, const struct gss_auth *auth)
3422     {
3423     struct gss_upcall_msg *pos;
3424     list_for_each_entry(pos, &pipe->in_downcall, list) {
3425     if (!uid_eq(pos->uid, uid))
3426     continue;
3427     + if (auth && pos->auth->service != auth->service)
3428     + continue;
3429     atomic_inc(&pos->count);
3430     dprintk("RPC: %s found msg %p\n", __func__, pos);
3431     return pos;
3432     @@ -365,7 +367,7 @@ gss_add_msg(struct gss_upcall_msg *gss_msg)
3433     struct gss_upcall_msg *old;
3434    
3435     spin_lock(&pipe->lock);
3436     - old = __gss_find_upcall(pipe, gss_msg->uid);
3437     + old = __gss_find_upcall(pipe, gss_msg->uid, gss_msg->auth);
3438     if (old == NULL) {
3439     atomic_inc(&gss_msg->count);
3440     list_add(&gss_msg->list, &pipe->in_downcall);
3441     @@ -714,7 +716,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
3442     err = -ENOENT;
3443     /* Find a matching upcall */
3444     spin_lock(&pipe->lock);
3445     - gss_msg = __gss_find_upcall(pipe, uid);
3446     + gss_msg = __gss_find_upcall(pipe, uid, NULL);
3447     if (gss_msg == NULL) {
3448     spin_unlock(&pipe->lock);
3449     goto err_put_ctx;
3450     diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
3451     index 027c9ef8a263..1ba417207465 100644
3452     --- a/net/sunrpc/xprtsock.c
3453     +++ b/net/sunrpc/xprtsock.c
3454     @@ -2286,6 +2286,10 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
3455     /* SYN_SENT! */
3456     if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO)
3457     xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
3458     + break;
3459     + case -EADDRNOTAVAIL:
3460     + /* Source port number is unavailable. Try a new one! */
3461     + transport->srcport = 0;
3462     }
3463     out:
3464     return ret;
3465     diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
3466     index e769e5764cba..12f7f6fdae4d 100644
3467     --- a/sound/pci/hda/hda_intel.c
3468     +++ b/sound/pci/hda/hda_intel.c
3469     @@ -944,20 +944,23 @@ static int azx_resume(struct device *dev)
3470     struct snd_card *card = dev_get_drvdata(dev);
3471     struct azx *chip;
3472     struct hda_intel *hda;
3473     + struct hdac_bus *bus;
3474    
3475     if (!card)
3476     return 0;
3477    
3478     chip = card->private_data;
3479     hda = container_of(chip, struct hda_intel, chip);
3480     + bus = azx_bus(chip);
3481     if (chip->disabled || hda->init_failed || !chip->running)
3482     return 0;
3483    
3484     - if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL
3485     - && hda->need_i915_power) {
3486     - snd_hdac_display_power(azx_bus(chip), true);
3487     - haswell_set_bclk(hda);
3488     + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
3489     + snd_hdac_display_power(bus, true);
3490     + if (hda->need_i915_power)
3491     + haswell_set_bclk(hda);
3492     }
3493     +
3494     if (chip->msi)
3495     if (pci_enable_msi(pci) < 0)
3496     chip->msi = 0;
3497     @@ -967,6 +970,11 @@ static int azx_resume(struct device *dev)
3498    
3499     hda_intel_init_chip(chip, true);
3500    
3501     + /* power down again for link-controlled chips */
3502     + if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) &&
3503     + !hda->need_i915_power)
3504     + snd_hdac_display_power(bus, false);
3505     +
3506     snd_power_change_state(card, SNDRV_CTL_POWER_D0);
3507    
3508     trace_azx_resume(chip);
3509     @@ -1046,6 +1054,7 @@ static int azx_runtime_resume(struct device *dev)
3510    
3511     chip = card->private_data;
3512     hda = container_of(chip, struct hda_intel, chip);
3513     + bus = azx_bus(chip);
3514     if (chip->disabled || hda->init_failed)
3515     return 0;
3516    
3517     @@ -1053,15 +1062,9 @@ static int azx_runtime_resume(struct device *dev)
3518     return 0;
3519    
3520     if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
3521     - bus = azx_bus(chip);
3522     - if (hda->need_i915_power) {
3523     - snd_hdac_display_power(bus, true);
3524     + snd_hdac_display_power(bus, true);
3525     + if (hda->need_i915_power)
3526     haswell_set_bclk(hda);
3527     - } else {
3528     - /* toggle codec wakeup bit for STATESTS read */
3529     - snd_hdac_set_codec_wakeup(bus, true);
3530     - snd_hdac_set_codec_wakeup(bus, false);
3531     - }
3532     }
3533    
3534     /* Read STATESTS before controller reset */
3535     @@ -1081,6 +1084,11 @@ static int azx_runtime_resume(struct device *dev)
3536     azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
3537     ~STATESTS_INT_MASK);
3538    
3539     + /* power down again for link-controlled chips */
3540     + if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) &&
3541     + !hda->need_i915_power)
3542     + snd_hdac_display_power(bus, false);
3543     +
3544     trace_azx_runtime_resume(chip);
3545     return 0;
3546     }
3547     diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
3548     index 204cc074adb9..41aa3355e920 100644
3549     --- a/sound/usb/line6/pcm.c
3550     +++ b/sound/usb/line6/pcm.c
3551     @@ -55,7 +55,6 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol,
3552     err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE);
3553     if (err < 0) {
3554     line6pcm->impulse_volume = 0;
3555     - line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE);
3556     return err;
3557     }
3558     } else {
3559     @@ -211,7 +210,9 @@ static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction,
3560     spin_lock_irqsave(&pstr->lock, flags);
3561     clear_bit(type, &pstr->running);
3562     if (!pstr->running) {
3563     + spin_unlock_irqrestore(&pstr->lock, flags);
3564     line6_unlink_audio_urbs(line6pcm, pstr);
3565     + spin_lock_irqsave(&pstr->lock, flags);
3566     if (direction == SNDRV_PCM_STREAM_CAPTURE) {
3567     line6pcm->prev_fbuf = NULL;
3568     line6pcm->prev_fsize = 0;
3569     diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c
3570     index daf81d169a42..45dd34874f43 100644
3571     --- a/sound/usb/line6/pod.c
3572     +++ b/sound/usb/line6/pod.c
3573     @@ -244,8 +244,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value,
3574     static ssize_t serial_number_show(struct device *dev,
3575     struct device_attribute *attr, char *buf)
3576     {
3577     - struct usb_interface *interface = to_usb_interface(dev);
3578     - struct usb_line6_pod *pod = usb_get_intfdata(interface);
3579     + struct snd_card *card = dev_to_snd_card(dev);
3580     + struct usb_line6_pod *pod = card->private_data;
3581    
3582     return sprintf(buf, "%u\n", pod->serial_number);
3583     }
3584     @@ -256,8 +256,8 @@ static ssize_t serial_number_show(struct device *dev,
3585     static ssize_t firmware_version_show(struct device *dev,
3586     struct device_attribute *attr, char *buf)
3587     {
3588     - struct usb_interface *interface = to_usb_interface(dev);
3589     - struct usb_line6_pod *pod = usb_get_intfdata(interface);
3590     + struct snd_card *card = dev_to_snd_card(dev);
3591     + struct usb_line6_pod *pod = card->private_data;
3592    
3593     return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100,
3594     pod->firmware_version % 100);
3595     @@ -269,8 +269,8 @@ static ssize_t firmware_version_show(struct device *dev,
3596     static ssize_t device_id_show(struct device *dev,
3597     struct device_attribute *attr, char *buf)
3598     {
3599     - struct usb_interface *interface = to_usb_interface(dev);
3600     - struct usb_line6_pod *pod = usb_get_intfdata(interface);
3601     + struct snd_card *card = dev_to_snd_card(dev);
3602     + struct usb_line6_pod *pod = card->private_data;
3603    
3604     return sprintf(buf, "%d\n", pod->device_id);
3605     }
3606     diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
3607     index db11ecf0b74d..a3e1252ce242 100644
3608     --- a/sound/usb/quirks.c
3609     +++ b/sound/usb/quirks.c
3610     @@ -1129,6 +1129,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
3611     {
3612     /* devices which do not support reading the sample rate. */
3613     switch (chip->usb_id) {
3614     + case USB_ID(0x041E, 0x4080): /* Creative Live Cam VF0610 */
3615     case USB_ID(0x045E, 0x075D): /* MS Lifecam Cinema */
3616     case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */
3617     case USB_ID(0x045E, 0x076E): /* MS Lifecam HD-5001 */
3618     @@ -1139,6 +1140,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
3619     case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
3620     case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
3621     case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
3622     + case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
3623     case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
3624     case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
3625     case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
3626     diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
3627     index b02af064f0f9..c53f78767568 100644
3628     --- a/tools/perf/arch/x86/util/intel-pt.c
3629     +++ b/tools/perf/arch/x86/util/intel-pt.c
3630     @@ -499,7 +499,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
3631     struct intel_pt_recording *ptr =
3632     container_of(itr, struct intel_pt_recording, itr);
3633     struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
3634     - bool have_timing_info;
3635     + bool have_timing_info, need_immediate = false;
3636     struct perf_evsel *evsel, *intel_pt_evsel = NULL;
3637     const struct cpu_map *cpus = evlist->cpus;
3638     bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
3639     @@ -653,6 +653,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
3640     ptr->have_sched_switch = 3;
3641     } else {
3642     opts->record_switch_events = true;
3643     + need_immediate = true;
3644     if (cpu_wide)
3645     ptr->have_sched_switch = 3;
3646     else
3647     @@ -698,6 +699,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
3648     tracking_evsel->attr.freq = 0;
3649     tracking_evsel->attr.sample_period = 1;
3650    
3651     + if (need_immediate)
3652     + tracking_evsel->immediate = true;
3653     +
3654     /* In per-cpu case, always need the time of mmap events etc */
3655     if (!cpu_map__empty(cpus)) {
3656     perf_evsel__set_sample_bit(tracking_evsel, TIME);
3657     diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
3658     index 51cf8256c6cd..f0d1c8ff8e8a 100644
3659     --- a/tools/testing/nvdimm/test/nfit.c
3660     +++ b/tools/testing/nvdimm/test/nfit.c
3661     @@ -13,6 +13,7 @@
3662     #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3663     #include <linux/platform_device.h>
3664     #include <linux/dma-mapping.h>
3665     +#include <linux/workqueue.h>
3666     #include <linux/libnvdimm.h>
3667     #include <linux/vmalloc.h>
3668     #include <linux/device.h>
3669     @@ -1246,6 +1247,7 @@ static int nfit_test_probe(struct platform_device *pdev)
3670     if (nfit_test->setup != nfit_test0_setup)
3671     return 0;
3672    
3673     + flush_work(&acpi_desc->work);
3674     nfit_test->setup_hotplug = 1;
3675     nfit_test->setup(nfit_test);
3676