Magellan Linux

Annotation of /trunk/kernel26-alx/patches-3.10/0128-3.10.29-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2672 - (hide annotations) (download)
Tue Jul 21 16:46:35 2015 UTC (9 years, 2 months ago) by niro
File size: 138657 byte(s)
-3.10.84-alx-r1
1 niro 2672 diff --git a/Documentation/devicetree/bindings/ata/marvell.txt b/Documentation/devicetree/bindings/ata/marvell.txt
2     index b5cdd20cde9c..1c8351604d38 100644
3     --- a/Documentation/devicetree/bindings/ata/marvell.txt
4     +++ b/Documentation/devicetree/bindings/ata/marvell.txt
5     @@ -1,7 +1,7 @@
6     * Marvell Orion SATA
7    
8     Required Properties:
9     -- compatibility : "marvell,orion-sata"
10     +- compatibility : "marvell,orion-sata" or "marvell,armada-370-sata"
11     - reg : Address range of controller
12     - interrupts : Interrupt controller is using
13     - nr-ports : Number of SATA ports in use.
14     diff --git a/Makefile b/Makefile
15     index addf1b007fe3..db7691ddd67c 100644
16     --- a/Makefile
17     +++ b/Makefile
18     @@ -1,6 +1,6 @@
19     VERSION = 3
20     PATCHLEVEL = 10
21     -SUBLEVEL = 28
22     +SUBLEVEL = 29
23     EXTRAVERSION =
24     NAME = TOSSUG Baby Fish
25    
26     diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c
27     index 99a0a1d2b7dc..b26156bf15db 100644
28     --- a/arch/arm/mach-at91/sam9_smc.c
29     +++ b/arch/arm/mach-at91/sam9_smc.c
30     @@ -101,7 +101,7 @@ static void sam9_smc_cs_read(void __iomem *base,
31     /* Pulse register */
32     val = __raw_readl(base + AT91_SMC_PULSE);
33    
34     - config->nwe_setup = val & AT91_SMC_NWEPULSE;
35     + config->nwe_pulse = val & AT91_SMC_NWEPULSE;
36     config->ncs_write_pulse = (val & AT91_SMC_NCS_WRPULSE) >> 8;
37     config->nrd_pulse = (val & AT91_SMC_NRDPULSE) >> 16;
38     config->ncs_read_pulse = (val & AT91_SMC_NCS_RDPULSE) >> 24;
39     diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
40     index 1a643ee8e082..6de423dbd385 100644
41     --- a/arch/arm/net/bpf_jit_32.c
42     +++ b/arch/arm/net/bpf_jit_32.c
43     @@ -637,10 +637,10 @@ load_ind:
44     emit(ARM_MUL(r_A, r_A, r_X), ctx);
45     break;
46     case BPF_S_ALU_DIV_K:
47     - /* current k == reciprocal_value(userspace k) */
48     + if (k == 1)
49     + break;
50     emit_mov_i(r_scratch, k, ctx);
51     - /* A = top 32 bits of the product */
52     - emit(ARM_UMULL(r_scratch, r_A, r_A, r_scratch), ctx);
53     + emit_udiv(r_A, r_A, r_scratch, ctx);
54     break;
55     case BPF_S_ALU_DIV_X:
56     update_on_xread(ctx);
57     diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h
58     index 2f9b751878ba..de65f66ea64e 100644
59     --- a/arch/parisc/include/asm/cacheflush.h
60     +++ b/arch/parisc/include/asm/cacheflush.h
61     @@ -132,7 +132,6 @@ void mark_rodata_ro(void);
62     static inline void *kmap(struct page *page)
63     {
64     might_sleep();
65     - flush_dcache_page(page);
66     return page_address(page);
67     }
68    
69     @@ -144,7 +143,6 @@ static inline void kunmap(struct page *page)
70     static inline void *kmap_atomic(struct page *page)
71     {
72     pagefault_disable();
73     - flush_dcache_page(page);
74     return page_address(page);
75     }
76    
77     diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
78     index c53fc63149e8..637fe031aa84 100644
79     --- a/arch/parisc/include/asm/page.h
80     +++ b/arch/parisc/include/asm/page.h
81     @@ -29,7 +29,8 @@ struct page;
82     void clear_page_asm(void *page);
83     void copy_page_asm(void *to, void *from);
84     #define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
85     -#define copy_user_page(vto, vfrom, vaddr, page) copy_page_asm(vto, vfrom)
86     +void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
87     + struct page *pg);
88    
89     /* #define CONFIG_PARISC_TMPALIAS */
90    
91     diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
92     index a72545554a31..ac87a40502e6 100644
93     --- a/arch/parisc/kernel/cache.c
94     +++ b/arch/parisc/kernel/cache.c
95     @@ -388,6 +388,20 @@ void flush_kernel_dcache_page_addr(void *addr)
96     }
97     EXPORT_SYMBOL(flush_kernel_dcache_page_addr);
98    
99     +void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
100     + struct page *pg)
101     +{
102     + /* Copy using kernel mapping. No coherency is needed (all in
103     + kunmap) for the `to' page. However, the `from' page needs to
104     + be flushed through a mapping equivalent to the user mapping
105     + before it can be accessed through the kernel mapping. */
106     + preempt_disable();
107     + flush_dcache_page_asm(__pa(vfrom), vaddr);
108     + preempt_enable();
109     + copy_page_asm(vto, vfrom);
110     +}
111     +EXPORT_SYMBOL(copy_user_page);
112     +
113     void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
114     {
115     unsigned long flags;
116     diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
117     index 161ab662843b..884b001bafcb 100644
118     --- a/arch/powerpc/include/asm/topology.h
119     +++ b/arch/powerpc/include/asm/topology.h
120     @@ -22,7 +22,15 @@ struct device_node;
121    
122     static inline int cpu_to_node(int cpu)
123     {
124     - return numa_cpu_lookup_table[cpu];
125     + int nid;
126     +
127     + nid = numa_cpu_lookup_table[cpu];
128     +
129     + /*
130     + * During early boot, the numa-cpu lookup table might not have been
131     + * setup for all CPUs yet. In such cases, default to node 0.
132     + */
133     + return (nid < 0) ? 0 : nid;
134     }
135    
136     #define parent_node(node) (node)
137     diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
138     index 92c6b008dd2b..b4437e8a7a8f 100644
139     --- a/arch/powerpc/kernel/cacheinfo.c
140     +++ b/arch/powerpc/kernel/cacheinfo.c
141     @@ -788,6 +788,9 @@ static void remove_cache_dir(struct cache_dir *cache_dir)
142     {
143     remove_index_dirs(cache_dir);
144    
145     + /* Remove cache dir from sysfs */
146     + kobject_del(cache_dir->kobj);
147     +
148     kobject_put(cache_dir->kobj);
149    
150     kfree(cache_dir);
151     diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
152     index 550f5928b394..102ad8a255f3 100644
153     --- a/arch/powerpc/kvm/book3s_hv.c
154     +++ b/arch/powerpc/kvm/book3s_hv.c
155     @@ -82,10 +82,13 @@ void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu)
156    
157     /* CPU points to the first thread of the core */
158     if (cpu != me && cpu >= 0 && cpu < nr_cpu_ids) {
159     +#ifdef CONFIG_KVM_XICS
160     int real_cpu = cpu + vcpu->arch.ptid;
161     if (paca[real_cpu].kvm_hstate.xics_phys)
162     xics_wake_cpu(real_cpu);
163     - else if (cpu_online(cpu))
164     + else
165     +#endif
166     + if (cpu_online(cpu))
167     smp_send_reschedule(cpu);
168     }
169     put_cpu();
170     @@ -1090,7 +1093,9 @@ static void kvmppc_start_thread(struct kvm_vcpu *vcpu)
171     smp_wmb();
172     #if defined(CONFIG_PPC_ICP_NATIVE) && defined(CONFIG_SMP)
173     if (vcpu->arch.ptid) {
174     +#ifdef CONFIG_KVM_XICS
175     xics_wake_cpu(cpu);
176     +#endif
177     ++vc->n_woken;
178     }
179     #endif
180     diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
181     index 6d6f153b6c1d..c17600de7d59 100644
182     --- a/arch/powerpc/kvm/e500_mmu.c
183     +++ b/arch/powerpc/kvm/e500_mmu.c
184     @@ -127,7 +127,7 @@ static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500,
185     }
186    
187     static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu,
188     - unsigned int eaddr, int as)
189     + gva_t eaddr, int as)
190     {
191     struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
192     unsigned int victim, tsized;
193     diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
194     index cafad4017765..b7293bba0062 100644
195     --- a/arch/powerpc/mm/numa.c
196     +++ b/arch/powerpc/mm/numa.c
197     @@ -31,6 +31,8 @@
198     #include <asm/sparsemem.h>
199     #include <asm/prom.h>
200     #include <asm/smp.h>
201     +#include <asm/cputhreads.h>
202     +#include <asm/topology.h>
203     #include <asm/firmware.h>
204     #include <asm/paca.h>
205     #include <asm/hvcall.h>
206     @@ -152,9 +154,22 @@ static void __init get_node_active_region(unsigned long pfn,
207     }
208     }
209    
210     -static void map_cpu_to_node(int cpu, int node)
211     +static void reset_numa_cpu_lookup_table(void)
212     +{
213     + unsigned int cpu;
214     +
215     + for_each_possible_cpu(cpu)
216     + numa_cpu_lookup_table[cpu] = -1;
217     +}
218     +
219     +static void update_numa_cpu_lookup_table(unsigned int cpu, int node)
220     {
221     numa_cpu_lookup_table[cpu] = node;
222     +}
223     +
224     +static void map_cpu_to_node(int cpu, int node)
225     +{
226     + update_numa_cpu_lookup_table(cpu, node);
227    
228     dbg("adding cpu %d to node %d\n", cpu, node);
229    
230     @@ -519,11 +534,24 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
231     */
232     static int __cpuinit numa_setup_cpu(unsigned long lcpu)
233     {
234     - int nid = 0;
235     - struct device_node *cpu = of_get_cpu_node(lcpu, NULL);
236     + int nid;
237     + struct device_node *cpu;
238     +
239     + /*
240     + * If a valid cpu-to-node mapping is already available, use it
241     + * directly instead of querying the firmware, since it represents
242     + * the most recent mapping notified to us by the platform (eg: VPHN).
243     + */
244     + if ((nid = numa_cpu_lookup_table[lcpu]) >= 0) {
245     + map_cpu_to_node(lcpu, nid);
246     + return nid;
247     + }
248     +
249     + cpu = of_get_cpu_node(lcpu, NULL);
250    
251     if (!cpu) {
252     WARN_ON(1);
253     + nid = 0;
254     goto out;
255     }
256    
257     @@ -1066,6 +1094,7 @@ void __init do_init_bootmem(void)
258     */
259     setup_node_to_cpumask_map();
260    
261     + reset_numa_cpu_lookup_table();
262     register_cpu_notifier(&ppc64_numa_nb);
263     cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
264     (void *)(unsigned long)boot_cpuid);
265     @@ -1443,6 +1472,33 @@ static int update_cpu_topology(void *data)
266     return 0;
267     }
268    
269     +static int update_lookup_table(void *data)
270     +{
271     + struct topology_update_data *update;
272     +
273     + if (!data)
274     + return -EINVAL;
275     +
276     + /*
277     + * Upon topology update, the numa-cpu lookup table needs to be updated
278     + * for all threads in the core, including offline CPUs, to ensure that
279     + * future hotplug operations respect the cpu-to-node associativity
280     + * properly.
281     + */
282     + for (update = data; update; update = update->next) {
283     + int nid, base, j;
284     +
285     + nid = update->new_nid;
286     + base = cpu_first_thread_sibling(update->cpu);
287     +
288     + for (j = 0; j < threads_per_core; j++) {
289     + update_numa_cpu_lookup_table(base + j, nid);
290     + }
291     + }
292     +
293     + return 0;
294     +}
295     +
296     /*
297     * Update the node maps and sysfs entries for each cpu whose home node
298     * has changed. Returns 1 when the topology has changed, and 0 otherwise.
299     @@ -1511,6 +1567,14 @@ int arch_update_cpu_topology(void)
300    
301     stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
302    
303     + /*
304     + * Update the numa-cpu lookup table with the new mappings, even for
305     + * offline CPUs. It is best to perform this update from the stop-
306     + * machine context.
307     + */
308     + stop_machine(update_lookup_table, &updates[0],
309     + cpumask_of(raw_smp_processor_id()));
310     +
311     for (ud = &updates[0]; ud; ud = ud->next) {
312     unregister_cpu_under_node(ud->cpu, ud->old_nid);
313     register_cpu_under_node(ud->cpu, ud->new_nid);
314     diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
315     index c427ae36374a..a012a9747cdd 100644
316     --- a/arch/powerpc/net/bpf_jit_comp.c
317     +++ b/arch/powerpc/net/bpf_jit_comp.c
318     @@ -209,10 +209,11 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
319     }
320     PPC_DIVWU(r_A, r_A, r_X);
321     break;
322     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
323     + case BPF_S_ALU_DIV_K: /* A /= K */
324     + if (K == 1)
325     + break;
326     PPC_LI32(r_scratch1, K);
327     - /* Top 32 bits of 64bit result -> A */
328     - PPC_MULHWU(r_A, r_A, r_scratch1);
329     + PPC_DIVWU(r_A, r_A, r_scratch1);
330     break;
331     case BPF_S_ALU_AND_X:
332     ctx->seen |= SEEN_XREG;
333     diff --git a/arch/s390/include/uapi/asm/statfs.h b/arch/s390/include/uapi/asm/statfs.h
334     index a61d538756f2..471eb09184d4 100644
335     --- a/arch/s390/include/uapi/asm/statfs.h
336     +++ b/arch/s390/include/uapi/asm/statfs.h
337     @@ -35,11 +35,11 @@ struct statfs {
338     struct statfs64 {
339     unsigned int f_type;
340     unsigned int f_bsize;
341     - unsigned long f_blocks;
342     - unsigned long f_bfree;
343     - unsigned long f_bavail;
344     - unsigned long f_files;
345     - unsigned long f_ffree;
346     + unsigned long long f_blocks;
347     + unsigned long long f_bfree;
348     + unsigned long long f_bavail;
349     + unsigned long long f_files;
350     + unsigned long long f_ffree;
351     __kernel_fsid_t f_fsid;
352     unsigned int f_namelen;
353     unsigned int f_frsize;
354     diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
355     index 1c01a9912989..6acb24d606fd 100644
356     --- a/arch/s390/kvm/diag.c
357     +++ b/arch/s390/kvm/diag.c
358     @@ -130,7 +130,7 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
359    
360     int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
361     {
362     - int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16;
363     + int code = kvm_s390_get_base_disp_rs(vcpu) & 0xffff;
364    
365     trace_kvm_s390_handle_diag(vcpu, code);
366     switch (code) {
367     diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
368     index 82f165f8078c..1919db6c0607 100644
369     --- a/arch/s390/net/bpf_jit_comp.c
370     +++ b/arch/s390/net/bpf_jit_comp.c
371     @@ -335,14 +335,16 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
372     EMIT4_PCREL(0xa7840000, (jit->ret0_ip - jit->prg));
373     /* lhi %r4,0 */
374     EMIT4(0xa7480000);
375     - /* dr %r4,%r12 */
376     - EMIT2(0x1d4c);
377     + /* dlr %r4,%r12 */
378     + EMIT4(0xb997004c);
379     break;
380     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K) */
381     - /* m %r4,<d(K)>(%r13) */
382     - EMIT4_DISP(0x5c40d000, EMIT_CONST(K));
383     - /* lr %r5,%r4 */
384     - EMIT2(0x1854);
385     + case BPF_S_ALU_DIV_K: /* A /= K */
386     + if (K == 1)
387     + break;
388     + /* lhi %r4,0 */
389     + EMIT4(0xa7480000);
390     + /* dl %r4,<d(K)>(%r13) */
391     + EMIT6_DISP(0xe340d000, 0x0097, EMIT_CONST(K));
392     break;
393     case BPF_S_ALU_MOD_X: /* A %= X */
394     jit->seen |= SEEN_XREG | SEEN_RET0;
395     @@ -352,16 +354,21 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
396     EMIT4_PCREL(0xa7840000, (jit->ret0_ip - jit->prg));
397     /* lhi %r4,0 */
398     EMIT4(0xa7480000);
399     - /* dr %r4,%r12 */
400     - EMIT2(0x1d4c);
401     + /* dlr %r4,%r12 */
402     + EMIT4(0xb997004c);
403     /* lr %r5,%r4 */
404     EMIT2(0x1854);
405     break;
406     case BPF_S_ALU_MOD_K: /* A %= K */
407     + if (K == 1) {
408     + /* lhi %r5,0 */
409     + EMIT4(0xa7580000);
410     + break;
411     + }
412     /* lhi %r4,0 */
413     EMIT4(0xa7480000);
414     - /* d %r4,<d(K)>(%r13) */
415     - EMIT4_DISP(0x5d40d000, EMIT_CONST(K));
416     + /* dl %r4,<d(K)>(%r13) */
417     + EMIT6_DISP(0xe340d000, 0x0097, EMIT_CONST(K));
418     /* lr %r5,%r4 */
419     EMIT2(0x1854);
420     break;
421     diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
422     index d36a85ebb5e0..fd95862c65aa 100644
423     --- a/arch/sparc/net/bpf_jit_comp.c
424     +++ b/arch/sparc/net/bpf_jit_comp.c
425     @@ -497,9 +497,20 @@ void bpf_jit_compile(struct sk_filter *fp)
426     case BPF_S_ALU_MUL_K: /* A *= K */
427     emit_alu_K(MUL, K);
428     break;
429     - case BPF_S_ALU_DIV_K: /* A /= K */
430     - emit_alu_K(MUL, K);
431     - emit_read_y(r_A);
432     + case BPF_S_ALU_DIV_K: /* A /= K with K != 0*/
433     + if (K == 1)
434     + break;
435     + emit_write_y(G0);
436     +#ifdef CONFIG_SPARC32
437     + /* The Sparc v8 architecture requires
438     + * three instructions between a %y
439     + * register write and the first use.
440     + */
441     + emit_nop();
442     + emit_nop();
443     + emit_nop();
444     +#endif
445     + emit_alu_K(DIV, K);
446     break;
447     case BPF_S_ALU_DIV_X: /* A /= X; */
448     emit_cmpi(r_X, 0);
449     diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h
450     index 2af848dfa754..d3fd447ecbee 100644
451     --- a/arch/x86/include/uapi/asm/msr-index.h
452     +++ b/arch/x86/include/uapi/asm/msr-index.h
453     @@ -179,6 +179,7 @@
454     #define MSR_AMD64_PATCH_LOADER 0xc0010020
455     #define MSR_AMD64_OSVW_ID_LENGTH 0xc0010140
456     #define MSR_AMD64_OSVW_STATUS 0xc0010141
457     +#define MSR_AMD64_LS_CFG 0xc0011020
458     #define MSR_AMD64_DC_CFG 0xc0011022
459     #define MSR_AMD64_BU_CFG2 0xc001102a
460     #define MSR_AMD64_IBSFETCHCTL 0xc0011030
461     diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
462     index 5013a48d1aff..ae177a014180 100644
463     --- a/arch/x86/kernel/cpu/amd.c
464     +++ b/arch/x86/kernel/cpu/amd.c
465     @@ -508,6 +508,16 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
466     set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
467     }
468     #endif
469     +
470     + /* F16h erratum 793, CVE-2013-6885 */
471     + if (c->x86 == 0x16 && c->x86_model <= 0xf) {
472     + u64 val;
473     +
474     + rdmsrl(MSR_AMD64_LS_CFG, val);
475     + if (!(val & BIT(15)))
476     + wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
477     + }
478     +
479     }
480    
481     static const int amd_erratum_383[];
482     diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
483     index 412a5aa0ef94..518d86471b76 100644
484     --- a/arch/x86/kvm/i8254.c
485     +++ b/arch/x86/kvm/i8254.c
486     @@ -37,6 +37,7 @@
487    
488     #include "irq.h"
489     #include "i8254.h"
490     +#include "x86.h"
491    
492     #ifndef CONFIG_X86_64
493     #define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
494     @@ -349,6 +350,23 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
495     atomic_set(&ps->pending, 0);
496     ps->irq_ack = 1;
497    
498     + /*
499     + * Do not allow the guest to program periodic timers with small
500     + * interval, since the hrtimers are not throttled by the host
501     + * scheduler.
502     + */
503     + if (ps->is_periodic) {
504     + s64 min_period = min_timer_period_us * 1000LL;
505     +
506     + if (ps->period < min_period) {
507     + pr_info_ratelimited(
508     + "kvm: requested %lld ns "
509     + "i8254 timer period limited to %lld ns\n",
510     + ps->period, min_period);
511     + ps->period = min_period;
512     + }
513     + }
514     +
515     hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval),
516     HRTIMER_MODE_ABS);
517     }
518     diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
519     index d0a97e808828..61d9fed5eb31 100644
520     --- a/arch/x86/kvm/lapic.c
521     +++ b/arch/x86/kvm/lapic.c
522     @@ -71,9 +71,6 @@
523     #define VEC_POS(v) ((v) & (32 - 1))
524     #define REG_POS(v) (((v) >> 5) << 4)
525    
526     -static unsigned int min_timer_period_us = 500;
527     -module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR);
528     -
529     static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val)
530     {
531     *((u32 *) (apic->regs + reg_off)) = val;
532     @@ -1369,7 +1366,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
533     vcpu->arch.apic_base = value;
534    
535     /* update jump label if enable bit changes */
536     - if ((vcpu->arch.apic_base ^ value) & MSR_IA32_APICBASE_ENABLE) {
537     + if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE) {
538     if (value & MSR_IA32_APICBASE_ENABLE)
539     static_key_slow_dec_deferred(&apic_hw_disabled);
540     else
541     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
542     index ad6a01605aaa..1bd6ea07d7d3 100644
543     --- a/arch/x86/kvm/x86.c
544     +++ b/arch/x86/kvm/x86.c
545     @@ -94,6 +94,9 @@ EXPORT_SYMBOL_GPL(kvm_x86_ops);
546     static bool ignore_msrs = 0;
547     module_param(ignore_msrs, bool, S_IRUGO | S_IWUSR);
548    
549     +unsigned int min_timer_period_us = 500;
550     +module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR);
551     +
552     bool kvm_has_tsc_control;
553     EXPORT_SYMBOL_GPL(kvm_has_tsc_control);
554     u32 kvm_max_guest_tsc_khz;
555     diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
556     index e224f7a671b6..3186542f2fa3 100644
557     --- a/arch/x86/kvm/x86.h
558     +++ b/arch/x86/kvm/x86.h
559     @@ -124,5 +124,7 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
560    
561     extern u64 host_xcr0;
562    
563     +extern unsigned int min_timer_period_us;
564     +
565     extern struct static_key kvm_no_apic_vcpu;
566     #endif
567     diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
568     index f66b54086ce5..0c966fecfb8c 100644
569     --- a/arch/x86/net/bpf_jit_comp.c
570     +++ b/arch/x86/net/bpf_jit_comp.c
571     @@ -324,15 +324,21 @@ void bpf_jit_compile(struct sk_filter *fp)
572     EMIT2(0x89, 0xd0); /* mov %edx,%eax */
573     break;
574     case BPF_S_ALU_MOD_K: /* A %= K; */
575     + if (K == 1) {
576     + CLEAR_A();
577     + break;
578     + }
579     EMIT2(0x31, 0xd2); /* xor %edx,%edx */
580     EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
581     EMIT2(0xf7, 0xf1); /* div %ecx */
582     EMIT2(0x89, 0xd0); /* mov %edx,%eax */
583     break;
584     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
585     - EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
586     - EMIT(K, 4);
587     - EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
588     + case BPF_S_ALU_DIV_K: /* A /= K */
589     + if (K == 1)
590     + break;
591     + EMIT2(0x31, 0xd2); /* xor %edx,%edx */
592     + EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
593     + EMIT2(0xf7, 0xf1); /* div %ecx */
594     break;
595     case BPF_S_ALU_AND_X:
596     seen |= SEEN_XREG;
597     diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
598     index 3474a2ccd8b1..6033be9ff81a 100644
599     --- a/arch/x86/platform/efi/efi.c
600     +++ b/arch/x86/platform/efi/efi.c
601     @@ -438,7 +438,7 @@ void __init efi_reserve_boot_services(void)
602     * - Not within any part of the kernel
603     * - Not the bios reserved area
604     */
605     - if ((start+size >= __pa_symbol(_text)
606     + if ((start + size > __pa_symbol(_text)
607     && start <= __pa_symbol(_end)) ||
608     !e820_all_mapped(start, start+size, E820_RAM) ||
609     memblock_is_region_reserved(start, size)) {
610     diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
611     index 8cacd1693f03..15518fda2d2a 100644
612     --- a/drivers/ata/libata-core.c
613     +++ b/drivers/ata/libata-core.c
614     @@ -2199,6 +2199,16 @@ int ata_dev_configure(struct ata_device *dev)
615     if (rc)
616     return rc;
617    
618     + /* some WD SATA-1 drives have issues with LPM, turn on NOLPM for them */
619     + if ((dev->horkage & ATA_HORKAGE_WD_BROKEN_LPM) &&
620     + (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
621     + dev->horkage |= ATA_HORKAGE_NOLPM;
622     +
623     + if (dev->horkage & ATA_HORKAGE_NOLPM) {
624     + ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
625     + dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER;
626     + }
627     +
628     /* let ACPI work its magic */
629     rc = ata_acpi_on_devcfg(dev);
630     if (rc)
631     @@ -4189,6 +4199,23 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
632     { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER },
633     { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },
634    
635     + /*
636     + * Some WD SATA-I drives spin up and down erratically when the link
637     + * is put into the slumber mode. We don't have full list of the
638     + * affected devices. Disable LPM if the device matches one of the
639     + * known prefixes and is SATA-1. As a side effect LPM partial is
640     + * lost too.
641     + *
642     + * https://bugzilla.kernel.org/show_bug.cgi?id=57211
643     + */
644     + { "WDC WD800JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
645     + { "WDC WD1200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
646     + { "WDC WD1600JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
647     + { "WDC WD2000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
648     + { "WDC WD2500JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
649     + { "WDC WD3000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
650     + { "WDC WD3200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
651     +
652     /* End Marker */
653     { }
654     };
655     diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
656     index 81a353590b8a..9933b4db7caf 100644
657     --- a/drivers/ata/libata-scsi.c
658     +++ b/drivers/ata/libata-scsi.c
659     @@ -112,12 +112,14 @@ static const char *ata_lpm_policy_names[] = {
660     [ATA_LPM_MIN_POWER] = "min_power",
661     };
662    
663     -static ssize_t ata_scsi_lpm_store(struct device *dev,
664     +static ssize_t ata_scsi_lpm_store(struct device *device,
665     struct device_attribute *attr,
666     const char *buf, size_t count)
667     {
668     - struct Scsi_Host *shost = class_to_shost(dev);
669     + struct Scsi_Host *shost = class_to_shost(device);
670     struct ata_port *ap = ata_shost_to_port(shost);
671     + struct ata_link *link;
672     + struct ata_device *dev;
673     enum ata_lpm_policy policy;
674     unsigned long flags;
675    
676     @@ -133,10 +135,20 @@ static ssize_t ata_scsi_lpm_store(struct device *dev,
677     return -EINVAL;
678    
679     spin_lock_irqsave(ap->lock, flags);
680     +
681     + ata_for_each_link(link, ap, EDGE) {
682     + ata_for_each_dev(dev, &ap->link, ENABLED) {
683     + if (dev->horkage & ATA_HORKAGE_NOLPM) {
684     + count = -EOPNOTSUPP;
685     + goto out_unlock;
686     + }
687     + }
688     + }
689     +
690     ap->target_lpm_policy = policy;
691     ata_port_schedule_eh(ap);
692     +out_unlock:
693     spin_unlock_irqrestore(ap->lock, flags);
694     -
695     return count;
696     }
697    
698     diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
699     index 35c6b6d09c27..b256ff5b6579 100644
700     --- a/drivers/ata/sata_mv.c
701     +++ b/drivers/ata/sata_mv.c
702     @@ -304,6 +304,7 @@ enum {
703     MV5_LTMODE = 0x30,
704     MV5_PHY_CTL = 0x0C,
705     SATA_IFCFG = 0x050,
706     + LP_PHY_CTL = 0x058,
707    
708     MV_M2_PREAMP_MASK = 0x7e0,
709    
710     @@ -431,6 +432,7 @@ enum {
711     MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */
712     MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */
713     MV_HP_QUIRK_LED_BLINK_EN = (1 << 12), /* is led blinking enabled? */
714     + MV_HP_FIX_LP_PHY_CTL = (1 << 13), /* fix speed in LP_PHY_CTL ? */
715    
716     /* Port private flags (pp_flags) */
717     MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */
718     @@ -1353,6 +1355,7 @@ static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
719    
720     if (ofs != 0xffffffffU) {
721     void __iomem *addr = mv_ap_base(link->ap) + ofs;
722     + struct mv_host_priv *hpriv = link->ap->host->private_data;
723     if (sc_reg_in == SCR_CONTROL) {
724     /*
725     * Workaround for 88SX60x1 FEr SATA#26:
726     @@ -1369,6 +1372,18 @@ static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
727     */
728     if ((val & 0xf) == 1 || (readl(addr) & 0xf) == 1)
729     val |= 0xf000;
730     +
731     + if (hpriv->hp_flags & MV_HP_FIX_LP_PHY_CTL) {
732     + void __iomem *lp_phy_addr =
733     + mv_ap_base(link->ap) + LP_PHY_CTL;
734     + /*
735     + * Set PHY speed according to SControl speed.
736     + */
737     + if ((val & 0xf0) == 0x10)
738     + writelfl(0x7, lp_phy_addr);
739     + else
740     + writelfl(0x227, lp_phy_addr);
741     + }
742     }
743     writelfl(val, addr);
744     return 0;
745     @@ -4111,6 +4126,15 @@ static int mv_platform_probe(struct platform_device *pdev)
746     if (rc)
747     goto err;
748    
749     + /*
750     + * To allow disk hotplug on Armada 370/XP SoCs, the PHY speed must be
751     + * updated in the LP_PHY_CTL register.
752     + */
753     + if (pdev->dev.of_node &&
754     + of_device_is_compatible(pdev->dev.of_node,
755     + "marvell,armada-370-sata"))
756     + hpriv->hp_flags |= MV_HP_FIX_LP_PHY_CTL;
757     +
758     /* initialize adapter */
759     rc = mv_init_host(host);
760     if (rc)
761     @@ -4216,6 +4240,7 @@ static int mv_platform_resume(struct platform_device *pdev)
762    
763     #ifdef CONFIG_OF
764     static struct of_device_id mv_sata_dt_ids[] = {
765     + { .compatible = "marvell,armada-370-sata", },
766     { .compatible = "marvell,orion-sata", },
767     {},
768     };
769     diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
770     index 5bb8e2ddd3b3..156bd3c72770 100644
771     --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
772     +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
773     @@ -410,6 +410,8 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
774     &chip->vendor.read_queue)
775     == 0) {
776     burstcnt = get_burstcount(chip);
777     + if (burstcnt < 0)
778     + return burstcnt;
779     len = min_t(int, burstcnt, count - size);
780     I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
781     size += len;
782     @@ -451,7 +453,8 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
783     static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf,
784     size_t len)
785     {
786     - u32 status, burstcnt = 0, i, size;
787     + u32 status, i, size;
788     + int burstcnt = 0;
789     int ret;
790     u8 data;
791     struct i2c_client *client;
792     @@ -482,6 +485,8 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf,
793    
794     for (i = 0; i < len - 1;) {
795     burstcnt = get_burstcount(chip);
796     + if (burstcnt < 0)
797     + return burstcnt;
798     size = min_t(int, len - i - 1, burstcnt);
799     ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf, size);
800     if (ret < 0)
801     diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
802     index 57a818b2b5f2..811ad1e4d802 100644
803     --- a/drivers/char/tpm/tpm_ppi.c
804     +++ b/drivers/char/tpm/tpm_ppi.c
805     @@ -172,7 +172,7 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
806     * is updated with function index from SUBREQ to SUBREQ2 since PPI
807     * version 1.1
808     */
809     - if (strcmp(version, "1.1") == -1)
810     + if (strcmp(version, "1.1") < 0)
811     params[2].integer.value = TPM_PPI_FN_SUBREQ;
812     else
813     params[2].integer.value = TPM_PPI_FN_SUBREQ2;
814     @@ -182,7 +182,7 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
815     * string/package type. For PPI version 1.0 and 1.1, use buffer type
816     * for compatibility, and use package type since 1.2 according to spec.
817     */
818     - if (strcmp(version, "1.2") == -1) {
819     + if (strcmp(version, "1.2") < 0) {
820     params[3].type = ACPI_TYPE_BUFFER;
821     params[3].buffer.length = sizeof(req);
822     sscanf(buf, "%d", &req);
823     @@ -248,7 +248,7 @@ static ssize_t tpm_show_ppi_transition_action(struct device *dev,
824     * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for
825     * compatibility, define params[3].type as buffer, if PPI version < 1.2
826     */
827     - if (strcmp(version, "1.2") == -1) {
828     + if (strcmp(version, "1.2") < 0) {
829     params[3].type = ACPI_TYPE_BUFFER;
830     params[3].buffer.length = 0;
831     params[3].buffer.pointer = NULL;
832     @@ -390,7 +390,7 @@ static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
833     kfree(output.pointer);
834     output.length = ACPI_ALLOCATE_BUFFER;
835     output.pointer = NULL;
836     - if (strcmp(version, "1.2") == -1)
837     + if (strcmp(version, "1.2") < 0)
838     return -EPERM;
839    
840     params[2].integer.value = TPM_PPI_FN_GETOPR;
841     diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
842     index 644fec54681f..f1e9d7bd131f 100644
843     --- a/drivers/edac/e752x_edac.c
844     +++ b/drivers/edac/e752x_edac.c
845     @@ -1182,9 +1182,11 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
846     pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
847     pvt->dev_info->err_dev, pvt->bridge_ck);
848    
849     - if (pvt->bridge_ck == NULL)
850     + if (pvt->bridge_ck == NULL) {
851     pvt->bridge_ck = pci_scan_single_device(pdev->bus,
852     PCI_DEVFN(0, 1));
853     + pci_dev_get(pvt->bridge_ck);
854     + }
855    
856     if (pvt->bridge_ck == NULL) {
857     e752x_printk(KERN_ERR, "error reporting device not found:"
858     diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
859     index 3044b07230db..c7bf974ed4a6 100644
860     --- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
861     +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
862     @@ -366,13 +366,13 @@ static u16
863     init_script(struct nouveau_bios *bios, int index)
864     {
865     struct nvbios_init init = { .bios = bios };
866     - u16 data;
867     + u16 bmp_ver = bmp_version(bios), data;
868    
869     - if (bmp_version(bios) && bmp_version(bios) < 0x0510) {
870     - if (index > 1)
871     + if (bmp_ver && bmp_ver < 0x0510) {
872     + if (index > 1 || bmp_ver < 0x0100)
873     return 0x0000;
874    
875     - data = bios->bmp_offset + (bios->version.major < 2 ? 14 : 18);
876     + data = bios->bmp_offset + (bmp_ver < 0x0200 ? 14 : 18);
877     return nv_ro16(bios, data + (index * 2));
878     }
879    
880     diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
881     index e633856370cf..9bcf175c4921 100644
882     --- a/drivers/hwmon/k10temp.c
883     +++ b/drivers/hwmon/k10temp.c
884     @@ -211,6 +211,7 @@ static DEFINE_PCI_DEVICE_TABLE(k10temp_id_table) = {
885     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
886     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
887     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
888     + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) },
889     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
890     {}
891     };
892     diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
893     index 14032e8c7731..1b27cbd822e1 100644
894     --- a/drivers/md/bcache/bset.c
895     +++ b/drivers/md/bcache/bset.c
896     @@ -927,7 +927,7 @@ static void sort_key_next(struct btree_iter *iter,
897     *i = iter->data[--iter->used];
898     }
899    
900     -static void btree_sort_fixup(struct btree_iter *iter)
901     +static struct bkey *btree_sort_fixup(struct btree_iter *iter, struct bkey *tmp)
902     {
903     while (iter->used > 1) {
904     struct btree_iter_set *top = iter->data, *i = top + 1;
905     @@ -955,9 +955,22 @@ static void btree_sort_fixup(struct btree_iter *iter)
906     } else {
907     /* can't happen because of comparison func */
908     BUG_ON(!bkey_cmp(&START_KEY(top->k), &START_KEY(i->k)));
909     - bch_cut_back(&START_KEY(i->k), top->k);
910     +
911     + if (bkey_cmp(i->k, top->k) < 0) {
912     + bkey_copy(tmp, top->k);
913     +
914     + bch_cut_back(&START_KEY(i->k), tmp);
915     + bch_cut_front(i->k, top->k);
916     + heap_sift(iter, 0, btree_iter_cmp);
917     +
918     + return tmp;
919     + } else {
920     + bch_cut_back(&START_KEY(i->k), top->k);
921     + }
922     }
923     }
924     +
925     + return NULL;
926     }
927    
928     static void btree_mergesort(struct btree *b, struct bset *out,
929     @@ -965,15 +978,20 @@ static void btree_mergesort(struct btree *b, struct bset *out,
930     bool fixup, bool remove_stale)
931     {
932     struct bkey *k, *last = NULL;
933     + BKEY_PADDED(k) tmp;
934     bool (*bad)(struct btree *, const struct bkey *) = remove_stale
935     ? bch_ptr_bad
936     : bch_ptr_invalid;
937    
938     while (!btree_iter_end(iter)) {
939     if (fixup && !b->level)
940     - btree_sort_fixup(iter);
941     + k = btree_sort_fixup(iter, &tmp.k);
942     + else
943     + k = NULL;
944     +
945     + if (!k)
946     + k = bch_btree_iter_next(iter);
947    
948     - k = bch_btree_iter_next(iter);
949     if (bad(b, k))
950     continue;
951    
952     diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
953     index 51422999fd08..740e3f42bef8 100644
954     --- a/drivers/md/raid5.c
955     +++ b/drivers/md/raid5.c
956     @@ -1893,6 +1893,7 @@ static void raid5_end_write_request(struct bio *bi, int error)
957     set_bit(R5_MadeGoodRepl, &sh->dev[i].flags);
958     } else {
959     if (!uptodate) {
960     + set_bit(STRIPE_DEGRADED, &sh->state);
961     set_bit(WriteErrorSeen, &rdev->flags);
962     set_bit(R5_WriteError, &sh->dev[i].flags);
963     if (!test_and_set_bit(WantReplacement, &rdev->flags))
964     diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
965     index 1cbb17609c8b..8290c2382395 100644
966     --- a/drivers/mfd/max77686.c
967     +++ b/drivers/mfd/max77686.c
968     @@ -102,7 +102,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
969     max77686->irq_gpio = pdata->irq_gpio;
970     max77686->irq = i2c->irq;
971    
972     - max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
973     + max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config);
974     if (IS_ERR(max77686->regmap)) {
975     ret = PTR_ERR(max77686->regmap);
976     dev_err(max77686->dev, "Failed to allocate register map: %d\n",
977     diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
978     index 8c4babc0efbd..70be100feeb4 100644
979     --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
980     +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
981     @@ -153,6 +153,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
982     struct sk_buff *skb = tx_buf->skb;
983     u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons;
984     int nbd;
985     + u16 split_bd_len = 0;
986    
987     /* prefetch skb end pointer to speedup dev_kfree_skb() */
988     prefetch(&skb->end);
989     @@ -160,10 +161,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
990     DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n",
991     txdata->txq_index, idx, tx_buf, skb);
992    
993     - /* unmap first bd */
994     tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd;
995     - dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
996     - BD_UNMAP_LEN(tx_start_bd), DMA_TO_DEVICE);
997    
998    
999     nbd = le16_to_cpu(tx_start_bd->nbd) - 1;
1000     @@ -182,12 +180,19 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
1001     --nbd;
1002     bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
1003    
1004     - /* ...and the TSO split header bd since they have no mapping */
1005     + /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
1006     if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
1007     + tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
1008     + split_bd_len = BD_UNMAP_LEN(tx_data_bd);
1009     --nbd;
1010     bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
1011     }
1012    
1013     + /* unmap first bd */
1014     + dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
1015     + BD_UNMAP_LEN(tx_start_bd) + split_bd_len,
1016     + DMA_TO_DEVICE);
1017     +
1018     /* now free frags */
1019     while (nbd > 0) {
1020    
1021     diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
1022     index 59c76a6815a0..be4d7c1e3c14 100644
1023     --- a/drivers/net/ethernet/intel/e1000e/phy.c
1024     +++ b/drivers/net/ethernet/intel/e1000e/phy.c
1025     @@ -1757,19 +1757,23 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
1026     * it across the board.
1027     */
1028     ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
1029     - if (ret_val)
1030     + if (ret_val) {
1031     /* If the first read fails, another entity may have
1032     * ownership of the resources, wait and try again to
1033     * see if they have relinquished the resources yet.
1034     */
1035     - udelay(usec_interval);
1036     + if (usec_interval >= 1000)
1037     + msleep(usec_interval / 1000);
1038     + else
1039     + udelay(usec_interval);
1040     + }
1041     ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
1042     if (ret_val)
1043     break;
1044     if (phy_status & BMSR_LSTATUS)
1045     break;
1046     if (usec_interval >= 1000)
1047     - mdelay(usec_interval / 1000);
1048     + msleep(usec_interval / 1000);
1049     else
1050     udelay(usec_interval);
1051     }
1052     diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
1053     index 75b82b6e8c54..c879969e82fb 100644
1054     --- a/drivers/net/ethernet/via/via-rhine.c
1055     +++ b/drivers/net/ethernet/via/via-rhine.c
1056     @@ -1611,6 +1611,7 @@ static void rhine_reset_task(struct work_struct *work)
1057     goto out_unlock;
1058    
1059     napi_disable(&rp->napi);
1060     + netif_tx_disable(dev);
1061     spin_lock_bh(&rp->lock);
1062    
1063     /* clear all descriptors */
1064     diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
1065     index 7f3d461f7e8d..54376fddfaf9 100644
1066     --- a/drivers/net/wireless/b43/b43.h
1067     +++ b/drivers/net/wireless/b43/b43.h
1068     @@ -731,8 +731,6 @@ enum b43_firmware_file_type {
1069     struct b43_request_fw_context {
1070     /* The device we are requesting the fw for. */
1071     struct b43_wldev *dev;
1072     - /* a completion event structure needed if this call is asynchronous */
1073     - struct completion fw_load_complete;
1074     /* a pointer to the firmware object */
1075     const struct firmware *blob;
1076     /* The type of firmware to request. */
1077     @@ -809,6 +807,8 @@ enum {
1078     struct b43_wldev {
1079     struct b43_bus_dev *dev;
1080     struct b43_wl *wl;
1081     + /* a completion event structure needed if this call is asynchronous */
1082     + struct completion fw_load_complete;
1083    
1084     /* The device initialization status.
1085     * Use b43_status() to query. */
1086     diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
1087     index a95b77ab360e..0b7edd36cfa2 100644
1088     --- a/drivers/net/wireless/b43/main.c
1089     +++ b/drivers/net/wireless/b43/main.c
1090     @@ -2068,6 +2068,7 @@ void b43_do_release_fw(struct b43_firmware_file *fw)
1091    
1092     static void b43_release_firmware(struct b43_wldev *dev)
1093     {
1094     + complete(&dev->fw_load_complete);
1095     b43_do_release_fw(&dev->fw.ucode);
1096     b43_do_release_fw(&dev->fw.pcm);
1097     b43_do_release_fw(&dev->fw.initvals);
1098     @@ -2093,7 +2094,7 @@ static void b43_fw_cb(const struct firmware *firmware, void *context)
1099     struct b43_request_fw_context *ctx = context;
1100    
1101     ctx->blob = firmware;
1102     - complete(&ctx->fw_load_complete);
1103     + complete(&ctx->dev->fw_load_complete);
1104     }
1105    
1106     int b43_do_request_fw(struct b43_request_fw_context *ctx,
1107     @@ -2140,7 +2141,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
1108     }
1109     if (async) {
1110     /* do this part asynchronously */
1111     - init_completion(&ctx->fw_load_complete);
1112     + init_completion(&ctx->dev->fw_load_complete);
1113     err = request_firmware_nowait(THIS_MODULE, 1, ctx->fwname,
1114     ctx->dev->dev->dev, GFP_KERNEL,
1115     ctx, b43_fw_cb);
1116     @@ -2148,12 +2149,11 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
1117     pr_err("Unable to load firmware\n");
1118     return err;
1119     }
1120     - /* stall here until fw ready */
1121     - wait_for_completion(&ctx->fw_load_complete);
1122     + wait_for_completion(&ctx->dev->fw_load_complete);
1123     if (ctx->blob)
1124     goto fw_ready;
1125     /* On some ARM systems, the async request will fail, but the next sync
1126     - * request works. For this reason, we dall through here
1127     + * request works. For this reason, we fall through here
1128     */
1129     }
1130     err = request_firmware(&ctx->blob, ctx->fwname,
1131     @@ -2422,6 +2422,7 @@ error:
1132    
1133     static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl);
1134     static void b43_one_core_detach(struct b43_bus_dev *dev);
1135     +static int b43_rng_init(struct b43_wl *wl);
1136    
1137     static void b43_request_firmware(struct work_struct *work)
1138     {
1139     @@ -2473,6 +2474,10 @@ start_ieee80211:
1140     goto err_one_core_detach;
1141     wl->hw_registred = true;
1142     b43_leds_register(wl->current_dev);
1143     +
1144     + /* Register HW RNG driver */
1145     + b43_rng_init(wl);
1146     +
1147     goto out;
1148    
1149     err_one_core_detach:
1150     @@ -4634,9 +4639,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
1151     if (!dev || b43_status(dev) != B43_STAT_INITIALIZED)
1152     return;
1153    
1154     - /* Unregister HW RNG driver */
1155     - b43_rng_exit(dev->wl);
1156     -
1157     b43_set_status(dev, B43_STAT_UNINIT);
1158    
1159     /* Stop the microcode PSM. */
1160     @@ -4779,9 +4781,6 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
1161    
1162     b43_set_status(dev, B43_STAT_INITIALIZED);
1163    
1164     - /* Register HW RNG driver */
1165     - b43_rng_init(dev->wl);
1166     -
1167     out:
1168     return err;
1169    
1170     @@ -5442,6 +5441,9 @@ static void b43_bcma_remove(struct bcma_device *core)
1171    
1172     b43_one_core_detach(wldev->dev);
1173    
1174     + /* Unregister HW RNG driver */
1175     + b43_rng_exit(wl);
1176     +
1177     b43_leds_unregister(wl);
1178    
1179     ieee80211_free_hw(wl->hw);
1180     @@ -5519,6 +5521,9 @@ static void b43_ssb_remove(struct ssb_device *sdev)
1181    
1182     b43_one_core_detach(dev);
1183    
1184     + /* Unregister HW RNG driver */
1185     + b43_rng_exit(wl);
1186     +
1187     if (list_empty(&wl->devlist)) {
1188     b43_leds_unregister(wl);
1189     /* Last core on the chip unregistered.
1190     diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
1191     index 8cb206a89083..e85d34b76039 100644
1192     --- a/drivers/net/wireless/b43/xmit.c
1193     +++ b/drivers/net/wireless/b43/xmit.c
1194     @@ -821,10 +821,10 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
1195     * channel number in b43. */
1196     if (chanstat & B43_RX_CHAN_5GHZ) {
1197     status.band = IEEE80211_BAND_5GHZ;
1198     - status.freq = b43_freq_to_channel_5ghz(chanid);
1199     + status.freq = b43_channel_to_freq_5ghz(chanid);
1200     } else {
1201     status.band = IEEE80211_BAND_2GHZ;
1202     - status.freq = b43_freq_to_channel_2ghz(chanid);
1203     + status.freq = b43_channel_to_freq_2ghz(chanid);
1204     }
1205     break;
1206     default:
1207     diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
1208     index 572668821862..349c77605231 100644
1209     --- a/drivers/net/wireless/b43legacy/main.c
1210     +++ b/drivers/net/wireless/b43legacy/main.c
1211     @@ -3919,6 +3919,7 @@ static void b43legacy_remove(struct ssb_device *dev)
1212     * as the ieee80211 unreg will destroy the workqueue. */
1213     cancel_work_sync(&wldev->restart_work);
1214     cancel_work_sync(&wl->firmware_load);
1215     + complete(&wldev->fw_load_complete);
1216    
1217     B43legacy_WARN_ON(!wl);
1218     if (!wldev->fw.ucode)
1219     diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c
1220     index 822443c5a3b5..9fd01dc5146b 100644
1221     --- a/drivers/net/wireless/iwlwifi/iwl-7000.c
1222     +++ b/drivers/net/wireless/iwlwifi/iwl-7000.c
1223     @@ -131,6 +131,7 @@ const struct iwl_cfg iwl7260_2ac_cfg = {
1224     .ht_params = &iwl7000_ht_params,
1225     .nvm_ver = IWL7260_NVM_VERSION,
1226     .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
1227     + .host_interrupt_operation_mode = true,
1228     };
1229    
1230     const struct iwl_cfg iwl7260_2n_cfg = {
1231     @@ -140,6 +141,7 @@ const struct iwl_cfg iwl7260_2n_cfg = {
1232     .ht_params = &iwl7000_ht_params,
1233     .nvm_ver = IWL7260_NVM_VERSION,
1234     .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
1235     + .host_interrupt_operation_mode = true,
1236     };
1237    
1238     const struct iwl_cfg iwl7260_n_cfg = {
1239     @@ -149,6 +151,7 @@ const struct iwl_cfg iwl7260_n_cfg = {
1240     .ht_params = &iwl7000_ht_params,
1241     .nvm_ver = IWL7260_NVM_VERSION,
1242     .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
1243     + .host_interrupt_operation_mode = true,
1244     };
1245    
1246     const struct iwl_cfg iwl3160_2ac_cfg = {
1247     @@ -158,6 +161,7 @@ const struct iwl_cfg iwl3160_2ac_cfg = {
1248     .ht_params = &iwl7000_ht_params,
1249     .nvm_ver = IWL3160_NVM_VERSION,
1250     .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
1251     + .host_interrupt_operation_mode = true,
1252     };
1253    
1254     const struct iwl_cfg iwl3160_2n_cfg = {
1255     @@ -167,6 +171,7 @@ const struct iwl_cfg iwl3160_2n_cfg = {
1256     .ht_params = &iwl7000_ht_params,
1257     .nvm_ver = IWL3160_NVM_VERSION,
1258     .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
1259     + .host_interrupt_operation_mode = true,
1260     };
1261    
1262     const struct iwl_cfg iwl3160_n_cfg = {
1263     @@ -176,6 +181,7 @@ const struct iwl_cfg iwl3160_n_cfg = {
1264     .ht_params = &iwl7000_ht_params,
1265     .nvm_ver = IWL3160_NVM_VERSION,
1266     .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
1267     + .host_interrupt_operation_mode = true,
1268     };
1269    
1270     MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
1271     diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h
1272     index 44e3370ce343..8ca006b12a32 100644
1273     --- a/drivers/net/wireless/iwlwifi/iwl-config.h
1274     +++ b/drivers/net/wireless/iwlwifi/iwl-config.h
1275     @@ -241,6 +241,8 @@ struct iwl_eeprom_params {
1276     * @rx_with_siso_diversity: 1x1 device with rx antenna diversity
1277     * @internal_wimax_coex: internal wifi/wimax combo device
1278     * @temp_offset_v2: support v2 of temperature offset calibration
1279     + * @host_interrupt_operation_mode: device needs host interrupt operation
1280     + * mode set
1281     *
1282     * We enable the driver to be backward compatible wrt. hardware features.
1283     * API differences in uCode shouldn't be handled here but through TLVs
1284     @@ -273,6 +275,7 @@ struct iwl_cfg {
1285     const bool rx_with_siso_diversity;
1286     const bool internal_wimax_coex;
1287     const bool temp_offset_v2;
1288     + const bool host_interrupt_operation_mode;
1289     };
1290    
1291     /*
1292     diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
1293     index 20e845d4da04..bba1af4d406c 100644
1294     --- a/drivers/net/wireless/iwlwifi/iwl-csr.h
1295     +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
1296     @@ -463,13 +463,10 @@
1297     * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
1298     *
1299     * default interrupt coalescing timer is 64 x 32 = 2048 usecs
1300     - * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
1301     */
1302     #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
1303     #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
1304     #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
1305     -#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
1306     -#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
1307     -#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
1308     +#define IWL_HOST_INT_OPER_MODE BIT(31)
1309    
1310     #endif /* !__iwl_csr_h__ */
1311     diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
1312     index 386f2a7c87cb..c26a6dc21eef 100644
1313     --- a/drivers/net/wireless/iwlwifi/iwl-prph.h
1314     +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
1315     @@ -260,4 +260,8 @@ static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl)
1316    
1317     /*********************** END TX SCHEDULER *************************************/
1318    
1319     +/* Oscillator clock */
1320     +#define OSC_CLK (0xa04068)
1321     +#define OSC_CLK_FORCE_CONTROL (0x8)
1322     +
1323     #endif /* __iwl_prph_h__ */
1324     diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
1325     index b29c31a41594..388c8a914960 100644
1326     --- a/drivers/net/wireless/iwlwifi/mvm/ops.c
1327     +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
1328     @@ -424,6 +424,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
1329    
1330     out_unregister:
1331     ieee80211_unregister_hw(mvm->hw);
1332     + iwl_mvm_leds_exit(mvm);
1333     out_free:
1334     iwl_phy_db_free(mvm->phy_db);
1335     kfree(mvm->scan_cmd);
1336     diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
1337     index 567e67ad1f61..296026b08a0c 100644
1338     --- a/drivers/net/wireless/iwlwifi/pcie/rx.c
1339     +++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
1340     @@ -489,6 +489,10 @@ static void iwl_pcie_rx_hw_init(struct iwl_trans *trans, struct iwl_rxq *rxq)
1341    
1342     /* Set interrupt coalescing timer to default (2048 usecs) */
1343     iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
1344     +
1345     + /* W/A for interrupt coalescing bug in 7260 and 3160 */
1346     + if (trans->cfg->host_interrupt_operation_mode)
1347     + iwl_set_bit(trans, CSR_INT_COALESCING, IWL_HOST_INT_OPER_MODE);
1348     }
1349    
1350     int iwl_pcie_rx_init(struct iwl_trans *trans)
1351     diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
1352     index aeb70e13137a..4088dd5e9244 100644
1353     --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
1354     +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
1355     @@ -207,6 +207,22 @@ static int iwl_pcie_apm_init(struct iwl_trans *trans)
1356     }
1357    
1358     /*
1359     + * Enable the oscillator to count wake up time for L1 exit. This
1360     + * consumes slightly more power (100uA) - but allows to be sure
1361     + * that we wake up from L1 on time.
1362     + *
1363     + * This looks weird: read twice the same register, discard the
1364     + * value, set a bit, and yet again, read that same register
1365     + * just to discard the value. But that's the way the hardware
1366     + * seems to like it.
1367     + */
1368     + iwl_read_prph(trans, OSC_CLK);
1369     + iwl_read_prph(trans, OSC_CLK);
1370     + iwl_set_bits_prph(trans, OSC_CLK, OSC_CLK_FORCE_CONTROL);
1371     + iwl_read_prph(trans, OSC_CLK);
1372     + iwl_read_prph(trans, OSC_CLK);
1373     +
1374     + /*
1375     * Enable DMA clock and wait for it to stabilize.
1376     *
1377     * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits
1378     @@ -276,9 +292,6 @@ static int iwl_pcie_nic_init(struct iwl_trans *trans)
1379     spin_lock_irqsave(&trans_pcie->irq_lock, flags);
1380     iwl_pcie_apm_init(trans);
1381    
1382     - /* Set interrupt coalescing calibration timer to default (512 usecs) */
1383     - iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
1384     -
1385     spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
1386    
1387     iwl_pcie_set_pwr(trans, false);
1388     diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
1389     index 1f7578d553ec..5400a1e58d79 100644
1390     --- a/drivers/net/wireless/mwifiex/fw.h
1391     +++ b/drivers/net/wireless/mwifiex/fw.h
1392     @@ -228,7 +228,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
1393    
1394     /* HW_SPEC fw_cap_info */
1395    
1396     -#define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(13)|BIT(14)))
1397     +#define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(12)|BIT(13)))
1398    
1399     #define GET_VHTCAP_CHWDSET(vht_cap_info) ((vht_cap_info >> 2) & 0x3)
1400     #define GET_VHTNSSMCS(mcs_mapset, nss) ((mcs_mapset >> (2 * (nss - 1))) & 0x3)
1401     diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
1402     index 9cf5d8f07df8..50b2fe53219d 100644
1403     --- a/drivers/net/wireless/mwifiex/scan.c
1404     +++ b/drivers/net/wireless/mwifiex/scan.c
1405     @@ -1622,7 +1622,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
1406     const u8 *ie_buf;
1407     size_t ie_len;
1408     u16 channel = 0;
1409     - u64 fw_tsf = 0;
1410     + __le64 fw_tsf = 0;
1411     u16 beacon_size = 0;
1412     u32 curr_bcn_bytes;
1413     u32 freq;
1414     @@ -1749,7 +1749,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
1415     ie_buf, ie_len, rssi, GFP_KERNEL);
1416     bss_priv = (struct mwifiex_bss_priv *)bss->priv;
1417     bss_priv->band = band;
1418     - bss_priv->fw_tsf = fw_tsf;
1419     + bss_priv->fw_tsf = le64_to_cpu(fw_tsf);
1420     if (priv->media_connected &&
1421     !memcmp(bssid,
1422     priv->curr_bss_params.bss_descriptor
1423     diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
1424     index 3698028c910d..6fc0853fd7f9 100644
1425     --- a/drivers/net/wireless/rtlwifi/base.c
1426     +++ b/drivers/net/wireless/rtlwifi/base.c
1427     @@ -1427,7 +1427,8 @@ void rtl_watchdog_wq_callback(void *data)
1428     /* if we can't recv beacon for 6s, we should
1429     * reconnect this AP
1430     */
1431     - if (rtlpriv->link_info.roam_times >= 3) {
1432     + if ((rtlpriv->link_info.roam_times >= 3) &&
1433     + !is_zero_ether_addr(rtlpriv->mac80211.bssid)) {
1434     RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1435     "AP off, try to reconnect now\n");
1436     rtlpriv->link_info.roam_times = 0;
1437     diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
1438     index ee84844be008..e2301970c85e 100644
1439     --- a/drivers/net/wireless/rtlwifi/core.c
1440     +++ b/drivers/net/wireless/rtlwifi/core.c
1441     @@ -46,10 +46,20 @@ void rtl_fw_cb(const struct firmware *firmware, void *context)
1442     "Firmware callback routine entered!\n");
1443     complete(&rtlpriv->firmware_loading_complete);
1444     if (!firmware) {
1445     + if (rtlpriv->cfg->alt_fw_name) {
1446     + err = request_firmware(&firmware,
1447     + rtlpriv->cfg->alt_fw_name,
1448     + rtlpriv->io.dev);
1449     + pr_info("Loading alternative firmware %s\n",
1450     + rtlpriv->cfg->alt_fw_name);
1451     + if (!err)
1452     + goto found_alt;
1453     + }
1454     pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
1455     rtlpriv->max_fw_size = 0;
1456     return;
1457     }
1458     +found_alt:
1459     if (firmware->size > rtlpriv->max_fw_size) {
1460     RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1461     "Firmware is too big!\n");
1462     @@ -184,6 +194,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
1463     rtlpriv->cfg->maps
1464     [RTL_IBSS_INT_MASKS]);
1465     }
1466     + mac->link_state = MAC80211_LINKED;
1467     break;
1468     case NL80211_IFTYPE_ADHOC:
1469     RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
1470     diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
1471     index 21a5cf060677..a6184b6e1d57 100644
1472     --- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
1473     +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
1474     @@ -1078,7 +1078,7 @@ static void rtl88e_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
1475     rtldm->swing_flag_ofdm = true;
1476     }
1477    
1478     - if (rtldm->swing_idx_cck != rtldm->swing_idx_cck) {
1479     + if (rtldm->swing_idx_cck_cur != rtldm->swing_idx_cck) {
1480     rtldm->swing_idx_cck_cur = rtldm->swing_idx_cck;
1481     rtldm->swing_flag_cck = true;
1482     }
1483     diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1484     index d2d57a27a7c1..06cb94cf5085 100644
1485     --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1486     +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1487     @@ -158,6 +158,42 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
1488     {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
1489     };
1490    
1491     +static u32 power_index_reg[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
1492     +
1493     +void dm_restorepowerindex(struct ieee80211_hw *hw)
1494     +{
1495     + struct rtl_priv *rtlpriv = rtl_priv(hw);
1496     + u8 index;
1497     +
1498     + for (index = 0; index < 6; index++)
1499     + rtl_write_byte(rtlpriv, power_index_reg[index],
1500     + rtlpriv->dm.powerindex_backup[index]);
1501     +}
1502     +EXPORT_SYMBOL_GPL(dm_restorepowerindex);
1503     +
1504     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value)
1505     +{
1506     + struct rtl_priv *rtlpriv = rtl_priv(hw);
1507     + u8 index;
1508     +
1509     + for (index = 0; index < 6; index++)
1510     + rtl_write_byte(rtlpriv, power_index_reg[index], value);
1511     +}
1512     +EXPORT_SYMBOL_GPL(dm_writepowerindex);
1513     +
1514     +void dm_savepowerindex(struct ieee80211_hw *hw)
1515     +{
1516     + struct rtl_priv *rtlpriv = rtl_priv(hw);
1517     + u8 index;
1518     + u8 tmp;
1519     +
1520     + for (index = 0; index < 6; index++) {
1521     + tmp = rtl_read_byte(rtlpriv, power_index_reg[index]);
1522     + rtlpriv->dm.powerindex_backup[index] = tmp;
1523     + }
1524     +}
1525     +EXPORT_SYMBOL_GPL(dm_savepowerindex);
1526     +
1527     static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
1528     {
1529     struct rtl_priv *rtlpriv = rtl_priv(hw);
1530     diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
1531     index 518e208c0180..4f232a063636 100644
1532     --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
1533     +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
1534     @@ -91,6 +91,17 @@
1535     #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74
1536     #define TX_POWER_NEAR_FIELD_THRESH_LVL1 67
1537    
1538     +#define DYNAMIC_FUNC_DISABLE 0x0
1539     +#define DYNAMIC_FUNC_DIG BIT(0)
1540     +#define DYNAMIC_FUNC_HP BIT(1)
1541     +#define DYNAMIC_FUNC_SS BIT(2) /*Tx Power Tracking*/
1542     +#define DYNAMIC_FUNC_BT BIT(3)
1543     +#define DYNAMIC_FUNC_ANT_DIV BIT(4)
1544     +
1545     +#define RSSI_CCK 0
1546     +#define RSSI_OFDM 1
1547     +#define RSSI_DEFAULT 2
1548     +
1549     struct swat_t {
1550     u8 failure_cnt;
1551     u8 try_flag;
1552     @@ -167,5 +178,8 @@ void rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw);
1553     void rtl92c_phy_iq_calibrate(struct ieee80211_hw *hw, bool recovery);
1554     void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw);
1555     void rtl92c_dm_bt_coexist(struct ieee80211_hw *hw);
1556     +void dm_savepowerindex(struct ieee80211_hw *hw);
1557     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value);
1558     +void dm_restorepowerindex(struct ieee80211_hw *hw);
1559    
1560     #endif
1561     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
1562     index 16a0b9e59acf..c16209a336ea 100644
1563     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
1564     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
1565     @@ -101,6 +101,15 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw)
1566     "PHY_SetTxPowerLevel8192S() Channel = %d\n",
1567     rtlphy->current_channel);
1568     rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel);
1569     + if (rtlpriv->dm.dynamic_txhighpower_lvl ==
1570     + TXHIGHPWRLEVEL_NORMAL)
1571     + dm_restorepowerindex(hw);
1572     + else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
1573     + TXHIGHPWRLEVEL_LEVEL1)
1574     + dm_writepowerindex(hw, 0x14);
1575     + else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
1576     + TXHIGHPWRLEVEL_LEVEL2)
1577     + dm_writepowerindex(hw, 0x10);
1578     }
1579    
1580     rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl;
1581     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
1582     index d947e7d350bb..fafa6bac2a3f 100644
1583     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
1584     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
1585     @@ -30,3 +30,6 @@
1586     #include "../rtl8192ce/dm.h"
1587    
1588     void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw);
1589     +void dm_savepowerindex(struct ieee80211_hw *hw);
1590     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value);
1591     +void dm_restorepowerindex(struct ieee80211_hw *hw);
1592     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
1593     index 2119313a737b..b878d56d2f4d 100644
1594     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
1595     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
1596     @@ -85,17 +85,15 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
1597     if (mac->act_scanning) {
1598     tx_agc[RF90_PATH_A] = 0x3f3f3f3f;
1599     tx_agc[RF90_PATH_B] = 0x3f3f3f3f;
1600     - if (turbo_scanoff) {
1601     - for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
1602     - tx_agc[idx1] = ppowerlevel[idx1] |
1603     - (ppowerlevel[idx1] << 8) |
1604     - (ppowerlevel[idx1] << 16) |
1605     - (ppowerlevel[idx1] << 24);
1606     - if (rtlhal->interface == INTF_USB) {
1607     - if (tx_agc[idx1] > 0x20 &&
1608     - rtlefuse->external_pa)
1609     - tx_agc[idx1] = 0x20;
1610     - }
1611     + for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
1612     + tx_agc[idx1] = ppowerlevel[idx1] |
1613     + (ppowerlevel[idx1] << 8) |
1614     + (ppowerlevel[idx1] << 16) |
1615     + (ppowerlevel[idx1] << 24);
1616     + if (rtlhal->interface == INTF_USB) {
1617     + if (tx_agc[idx1] > 0x20 &&
1618     + rtlefuse->external_pa)
1619     + tx_agc[idx1] = 0x20;
1620     }
1621     }
1622     } else {
1623     @@ -107,7 +105,7 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
1624     TXHIGHPWRLEVEL_LEVEL2) {
1625     tx_agc[RF90_PATH_A] = 0x00000000;
1626     tx_agc[RF90_PATH_B] = 0x00000000;
1627     - } else{
1628     + } else {
1629     for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
1630     tx_agc[idx1] = ppowerlevel[idx1] |
1631     (ppowerlevel[idx1] << 8) |
1632     @@ -373,7 +371,12 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw,
1633     regoffset == RTXAGC_B_MCS07_MCS04)
1634     regoffset = 0xc98;
1635     for (i = 0; i < 3; i++) {
1636     - writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
1637     + if (i != 2)
1638     + writeVal = (writeVal > 8) ?
1639     + (writeVal - 8) : 0;
1640     + else
1641     + writeVal = (writeVal > 6) ?
1642     + (writeVal - 6) : 0;
1643     rtl_write_byte(rtlpriv, (u32)(regoffset + i),
1644     (u8)writeVal);
1645     }
1646     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
1647     index 2bd598526217..8188dcb512f0 100644
1648     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
1649     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
1650     @@ -49,6 +49,9 @@ MODULE_AUTHOR("Larry Finger <Larry.Finger@lwfinger.net>");
1651     MODULE_LICENSE("GPL");
1652     MODULE_DESCRIPTION("Realtek 8192C/8188C 802.11n USB wireless");
1653     MODULE_FIRMWARE("rtlwifi/rtl8192cufw.bin");
1654     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_A.bin");
1655     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_B.bin");
1656     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_TMSC.bin");
1657    
1658     static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
1659     {
1660     @@ -68,14 +71,21 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
1661     "Can't alloc buffer for fw\n");
1662     return 1;
1663     }
1664     -
1665     + if (IS_VENDOR_UMC_A_CUT(rtlpriv->rtlhal.version) &&
1666     + !IS_92C_SERIAL(rtlpriv->rtlhal.version)) {
1667     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_A.bin";
1668     + } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlpriv->rtlhal.version)) {
1669     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_B.bin";
1670     + } else {
1671     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_TMSC.bin";
1672     + }
1673     + /* provide name of alternative file */
1674     + rtlpriv->cfg->alt_fw_name = "rtlwifi/rtl8192cufw.bin";
1675     pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name);
1676     rtlpriv->max_fw_size = 0x4000;
1677     err = request_firmware_nowait(THIS_MODULE, 1,
1678     rtlpriv->cfg->fw_name, rtlpriv->io.dev,
1679     GFP_KERNEL, hw, rtl_fw_cb);
1680     -
1681     -
1682     return err;
1683     }
1684    
1685     @@ -306,6 +316,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = {
1686     {RTL_USB_DEVICE(0x0bda, 0x5088, rtl92cu_hal_cfg)}, /*Thinkware-CC&C*/
1687     {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
1688     {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
1689     + {RTL_USB_DEVICE(0x0df6, 0x0077, rtl92cu_hal_cfg)}, /*Sitecom-WLA2100V2*/
1690     {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/
1691     {RTL_USB_DEVICE(0x4856, 0x0091, rtl92cu_hal_cfg)}, /*NetweeN - Feixun*/
1692     /* HP - Lite-On ,8188CUS Slim Combo */
1693     diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
1694     index 8ed31744a054..4f083fc1d360 100644
1695     --- a/drivers/net/wireless/rtlwifi/stats.c
1696     +++ b/drivers/net/wireless/rtlwifi/stats.c
1697     @@ -176,6 +176,7 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
1698     struct rtl_sta_info *drv_priv = NULL;
1699     struct ieee80211_sta *sta = NULL;
1700     long undec_sm_pwdb;
1701     + long undec_sm_cck;
1702    
1703     rcu_read_lock();
1704     if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
1705     @@ -185,12 +186,16 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
1706     if (sta) {
1707     drv_priv = (struct rtl_sta_info *) sta->drv_priv;
1708     undec_sm_pwdb = drv_priv->rssi_stat.undec_sm_pwdb;
1709     + undec_sm_cck = drv_priv->rssi_stat.undec_sm_cck;
1710     } else {
1711     undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
1712     + undec_sm_cck = rtlpriv->dm.undec_sm_cck;
1713     }
1714    
1715     if (undec_sm_pwdb < 0)
1716     undec_sm_pwdb = pstatus->rx_pwdb_all;
1717     + if (undec_sm_cck < 0)
1718     + undec_sm_cck = pstatus->rx_pwdb_all;
1719     if (pstatus->rx_pwdb_all > (u32) undec_sm_pwdb) {
1720     undec_sm_pwdb = (((undec_sm_pwdb) *
1721     (RX_SMOOTH_FACTOR - 1)) +
1722     @@ -200,6 +205,15 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
1723     undec_sm_pwdb = (((undec_sm_pwdb) * (RX_SMOOTH_FACTOR - 1)) +
1724     (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
1725     }
1726     + if (pstatus->rx_pwdb_all > (u32) undec_sm_cck) {
1727     + undec_sm_cck = (((undec_sm_pwdb) *
1728     + (RX_SMOOTH_FACTOR - 1)) +
1729     + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
1730     + undec_sm_cck = undec_sm_cck + 1;
1731     + } else {
1732     + undec_sm_pwdb = (((undec_sm_cck) * (RX_SMOOTH_FACTOR - 1)) +
1733     + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
1734     + }
1735    
1736     if (sta) {
1737     drv_priv->rssi_stat.undec_sm_pwdb = undec_sm_pwdb;
1738     diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
1739     index 1feebdc92f41..57b12a5883a0 100644
1740     --- a/drivers/net/wireless/rtlwifi/usb.c
1741     +++ b/drivers/net/wireless/rtlwifi/usb.c
1742     @@ -477,6 +477,8 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
1743     if (unicast)
1744     rtlpriv->link_info.num_rx_inperiod++;
1745     }
1746     + /* static bcn for roaming */
1747     + rtl_beacon_statistic(hw, skb);
1748     }
1749     }
1750    
1751     @@ -548,7 +550,7 @@ static void _rtl_rx_pre_process(struct ieee80211_hw *hw, struct sk_buff *skb)
1752     }
1753     }
1754    
1755     -#define __RX_SKB_MAX_QUEUED 32
1756     +#define __RX_SKB_MAX_QUEUED 64
1757    
1758     static void _rtl_rx_work(unsigned long param)
1759     {
1760     diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
1761     index ad9c37a42709..e576a927fde7 100644
1762     --- a/drivers/net/wireless/rtlwifi/wifi.h
1763     +++ b/drivers/net/wireless/rtlwifi/wifi.h
1764     @@ -1035,6 +1035,7 @@ struct rtl_ht_agg {
1765    
1766     struct rssi_sta {
1767     long undec_sm_pwdb;
1768     + long undec_sm_cck;
1769     };
1770    
1771     struct rtl_tid_data {
1772     @@ -1325,8 +1326,10 @@ struct fast_ant_training {
1773     struct rtl_dm {
1774     /*PHY status for Dynamic Management */
1775     long entry_min_undec_sm_pwdb;
1776     + long undec_sm_cck;
1777     long undec_sm_pwdb; /*out dm */
1778     long entry_max_undec_sm_pwdb;
1779     + s32 ofdm_pkt_cnt;
1780     bool dm_initialgain_enable;
1781     bool dynamic_txpower_enable;
1782     bool current_turbo_edca;
1783     @@ -1341,6 +1344,7 @@ struct rtl_dm {
1784     bool inform_fw_driverctrldm;
1785     bool current_mrc_switch;
1786     u8 txpowercount;
1787     + u8 powerindex_backup[6];
1788    
1789     u8 thermalvalue_rxgain;
1790     u8 thermalvalue_iqk;
1791     @@ -1352,7 +1356,9 @@ struct rtl_dm {
1792     bool done_txpower;
1793     u8 dynamic_txhighpower_lvl; /*Tx high power level */
1794     u8 dm_flag; /*Indicate each dynamic mechanism's status. */
1795     + u8 dm_flag_tmp;
1796     u8 dm_type;
1797     + u8 dm_rssi_sel;
1798     u8 txpower_track_control;
1799     bool interrupt_migration;
1800     bool disable_tx_int;
1801     @@ -1806,6 +1812,7 @@ struct rtl_hal_cfg {
1802     bool write_readback;
1803     char *name;
1804     char *fw_name;
1805     + char *alt_fw_name;
1806     struct rtl_hal_ops *ops;
1807     struct rtl_mod_params *mod_params;
1808     struct rtl_hal_usbint_cfg *usb_interface_cfg;
1809     @@ -1950,6 +1957,7 @@ struct dig_t {
1810     u8 pre_ccastate;
1811     u8 cur_ccasate;
1812     u8 large_fa_hit;
1813     + u8 dig_dynamic_min;
1814     u8 forbidden_igi;
1815     u8 dig_state;
1816     u8 dig_highpwrstate;
1817     @@ -2030,22 +2038,15 @@ struct rtl_priv {
1818     struct dig_t dm_digtable;
1819     struct ps_t dm_pstable;
1820    
1821     - /* section shared by individual drivers */
1822     - union {
1823     - struct { /* data buffer pointer for USB reads */
1824     - __le32 *usb_data;
1825     - int usb_data_index;
1826     - bool initialized;
1827     - };
1828     - struct { /* section for 8723ae */
1829     - bool reg_init; /* true if regs saved */
1830     - u32 reg_874;
1831     - u32 reg_c70;
1832     - u32 reg_85c;
1833     - u32 reg_a74;
1834     - bool bt_operation_on;
1835     - };
1836     - };
1837     + u32 reg_874;
1838     + u32 reg_c70;
1839     + u32 reg_85c;
1840     + u32 reg_a74;
1841     + bool reg_init; /* true if regs saved */
1842     + bool bt_operation_on;
1843     + __le32 *usb_data;
1844     + int usb_data_index;
1845     + bool initialized;
1846     bool enter_ps; /* true when entering PS */
1847     u8 rate_mask[5];
1848    
1849     diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
1850     index 0c01b8e33fe1..82e0f1fd2254 100644
1851     --- a/drivers/net/xen-netfront.c
1852     +++ b/drivers/net/xen-netfront.c
1853     @@ -107,6 +107,7 @@ struct netfront_info {
1854     } tx_skbs[NET_TX_RING_SIZE];
1855     grant_ref_t gref_tx_head;
1856     grant_ref_t grant_tx_ref[NET_TX_RING_SIZE];
1857     + struct page *grant_tx_page[NET_TX_RING_SIZE];
1858     unsigned tx_skb_freelist;
1859    
1860     spinlock_t rx_lock ____cacheline_aligned_in_smp;
1861     @@ -386,6 +387,7 @@ static void xennet_tx_buf_gc(struct net_device *dev)
1862     gnttab_release_grant_reference(
1863     &np->gref_tx_head, np->grant_tx_ref[id]);
1864     np->grant_tx_ref[id] = GRANT_INVALID_REF;
1865     + np->grant_tx_page[id] = NULL;
1866     add_id_to_freelist(&np->tx_skb_freelist, np->tx_skbs, id);
1867     dev_kfree_skb_irq(skb);
1868     }
1869     @@ -442,6 +444,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
1870     gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
1871     mfn, GNTMAP_readonly);
1872    
1873     + np->grant_tx_page[id] = virt_to_page(data);
1874     tx->gref = np->grant_tx_ref[id] = ref;
1875     tx->offset = offset;
1876     tx->size = len;
1877     @@ -487,6 +490,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
1878     np->xbdev->otherend_id,
1879     mfn, GNTMAP_readonly);
1880    
1881     + np->grant_tx_page[id] = page;
1882     tx->gref = np->grant_tx_ref[id] = ref;
1883     tx->offset = offset;
1884     tx->size = bytes;
1885     @@ -586,6 +590,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
1886     mfn = virt_to_mfn(data);
1887     gnttab_grant_foreign_access_ref(
1888     ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
1889     + np->grant_tx_page[id] = virt_to_page(data);
1890     tx->gref = np->grant_tx_ref[id] = ref;
1891     tx->offset = offset;
1892     tx->size = len;
1893     @@ -1115,10 +1120,11 @@ static void xennet_release_tx_bufs(struct netfront_info *np)
1894     continue;
1895    
1896     skb = np->tx_skbs[i].skb;
1897     - gnttab_end_foreign_access_ref(np->grant_tx_ref[i],
1898     - GNTMAP_readonly);
1899     - gnttab_release_grant_reference(&np->gref_tx_head,
1900     - np->grant_tx_ref[i]);
1901     + get_page(np->grant_tx_page[i]);
1902     + gnttab_end_foreign_access(np->grant_tx_ref[i],
1903     + GNTMAP_readonly,
1904     + (unsigned long)page_address(np->grant_tx_page[i]));
1905     + np->grant_tx_page[i] = NULL;
1906     np->grant_tx_ref[i] = GRANT_INVALID_REF;
1907     add_id_to_freelist(&np->tx_skb_freelist, np->tx_skbs, i);
1908     dev_kfree_skb_irq(skb);
1909     @@ -1127,78 +1133,35 @@ static void xennet_release_tx_bufs(struct netfront_info *np)
1910    
1911     static void xennet_release_rx_bufs(struct netfront_info *np)
1912     {
1913     - struct mmu_update *mmu = np->rx_mmu;
1914     - struct multicall_entry *mcl = np->rx_mcl;
1915     - struct sk_buff_head free_list;
1916     - struct sk_buff *skb;
1917     - unsigned long mfn;
1918     - int xfer = 0, noxfer = 0, unused = 0;
1919     int id, ref;
1920    
1921     - dev_warn(&np->netdev->dev, "%s: fix me for copying receiver.\n",
1922     - __func__);
1923     - return;
1924     -
1925     - skb_queue_head_init(&free_list);
1926     -
1927     spin_lock_bh(&np->rx_lock);
1928    
1929     for (id = 0; id < NET_RX_RING_SIZE; id++) {
1930     - ref = np->grant_rx_ref[id];
1931     - if (ref == GRANT_INVALID_REF) {
1932     - unused++;
1933     - continue;
1934     - }
1935     + struct sk_buff *skb;
1936     + struct page *page;
1937    
1938     skb = np->rx_skbs[id];
1939     - mfn = gnttab_end_foreign_transfer_ref(ref);
1940     - gnttab_release_grant_reference(&np->gref_rx_head, ref);
1941     - np->grant_rx_ref[id] = GRANT_INVALID_REF;
1942     -
1943     - if (0 == mfn) {
1944     - skb_shinfo(skb)->nr_frags = 0;
1945     - dev_kfree_skb(skb);
1946     - noxfer++;
1947     + if (!skb)
1948     continue;
1949     - }
1950    
1951     - if (!xen_feature(XENFEAT_auto_translated_physmap)) {
1952     - /* Remap the page. */
1953     - const struct page *page =
1954     - skb_frag_page(&skb_shinfo(skb)->frags[0]);
1955     - unsigned long pfn = page_to_pfn(page);
1956     - void *vaddr = page_address(page);
1957     + ref = np->grant_rx_ref[id];
1958     + if (ref == GRANT_INVALID_REF)
1959     + continue;
1960    
1961     - MULTI_update_va_mapping(mcl, (unsigned long)vaddr,
1962     - mfn_pte(mfn, PAGE_KERNEL),
1963     - 0);
1964     - mcl++;
1965     - mmu->ptr = ((u64)mfn << PAGE_SHIFT)
1966     - | MMU_MACHPHYS_UPDATE;
1967     - mmu->val = pfn;
1968     - mmu++;
1969     + page = skb_frag_page(&skb_shinfo(skb)->frags[0]);
1970    
1971     - set_phys_to_machine(pfn, mfn);
1972     - }
1973     - __skb_queue_tail(&free_list, skb);
1974     - xfer++;
1975     - }
1976     -
1977     - dev_info(&np->netdev->dev, "%s: %d xfer, %d noxfer, %d unused\n",
1978     - __func__, xfer, noxfer, unused);
1979     + /* gnttab_end_foreign_access() needs a page ref until
1980     + * foreign access is ended (which may be deferred).
1981     + */
1982     + get_page(page);
1983     + gnttab_end_foreign_access(ref, 0,
1984     + (unsigned long)page_address(page));
1985     + np->grant_rx_ref[id] = GRANT_INVALID_REF;
1986    
1987     - if (xfer) {
1988     - if (!xen_feature(XENFEAT_auto_translated_physmap)) {
1989     - /* Do all the remapping work and M2P updates. */
1990     - MULTI_mmu_update(mcl, np->rx_mmu, mmu - np->rx_mmu,
1991     - NULL, DOMID_SELF);
1992     - mcl++;
1993     - HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
1994     - }
1995     + kfree_skb(skb);
1996     }
1997    
1998     - __skb_queue_purge(&free_list);
1999     -
2000     spin_unlock_bh(&np->rx_lock);
2001     }
2002    
2003     @@ -1333,6 +1296,7 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
2004     for (i = 0; i < NET_RX_RING_SIZE; i++) {
2005     np->rx_skbs[i] = NULL;
2006     np->grant_rx_ref[i] = GRANT_INVALID_REF;
2007     + np->grant_tx_page[i] = NULL;
2008     }
2009    
2010     /* A grant for every tx ring slot */
2011     diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
2012     index 903e1285fda0..b0a0d5389f41 100644
2013     --- a/drivers/parport/parport_pc.c
2014     +++ b/drivers/parport/parport_pc.c
2015     @@ -2596,8 +2596,6 @@ enum parport_pc_pci_cards {
2016     syba_2p_epp,
2017     syba_1p_ecp,
2018     titan_010l,
2019     - titan_1284p1,
2020     - titan_1284p2,
2021     avlab_1p,
2022     avlab_2p,
2023     oxsemi_952,
2024     @@ -2656,8 +2654,6 @@ static struct parport_pc_pci {
2025     /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } },
2026     /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } },
2027     /* titan_010l */ { 1, { { 3, -1 }, } },
2028     - /* titan_1284p1 */ { 1, { { 0, 1 }, } },
2029     - /* titan_1284p2 */ { 2, { { 0, 1 }, { 2, 3 }, } },
2030     /* avlab_1p */ { 1, { { 0, 1}, } },
2031     /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} },
2032     /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
2033     @@ -2673,8 +2669,8 @@ static struct parport_pc_pci {
2034     /* netmos_9705 */ { 1, { { 0, -1 }, } },
2035     /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} },
2036     /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} },
2037     - /* netmos_9805 */ { 1, { { 0, -1 }, } },
2038     - /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } },
2039     + /* netmos_9805 */ { 1, { { 0, 1 }, } },
2040     + /* netmos_9815 */ { 2, { { 0, 1 }, { 2, 3 }, } },
2041     /* netmos_9901 */ { 1, { { 0, -1 }, } },
2042     /* netmos_9865 */ { 1, { { 0, -1 }, } },
2043     /* quatech_sppxp100 */ { 1, { { 0, 1 }, } },
2044     @@ -2718,8 +2714,6 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2045     PCI_ANY_ID, PCI_ANY_ID, 0, 0, syba_1p_ecp },
2046     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_010L,
2047     PCI_ANY_ID, PCI_ANY_ID, 0, 0, titan_010l },
2048     - { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 },
2049     - { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 },
2050     /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2051     /* AFAVLAB_TK9902 */
2052     { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p},
2053     diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
2054     index b7d8c890514c..876d7cc4d8a7 100644
2055     --- a/drivers/pinctrl/pinctrl-sunxi.c
2056     +++ b/drivers/pinctrl/pinctrl-sunxi.c
2057     @@ -1754,12 +1754,6 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
2058     return val;
2059     }
2060    
2061     -static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
2062     - unsigned offset, int value)
2063     -{
2064     - return pinctrl_gpio_direction_output(chip->base + offset);
2065     -}
2066     -
2067     static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
2068     unsigned offset, int value)
2069     {
2070     @@ -1770,6 +1764,13 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
2071     writel((value & DATA_PINS_MASK) << index, pctl->membase + reg);
2072     }
2073    
2074     +static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
2075     + unsigned offset, int value)
2076     +{
2077     + sunxi_pinctrl_gpio_set(chip, offset, value);
2078     + return pinctrl_gpio_direction_output(chip->base + offset);
2079     +}
2080     +
2081     static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
2082     const struct of_phandle_args *gpiospec,
2083     u32 *flags)
2084     diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
2085     index a8e43cf70fac..0ed96df20162 100644
2086     --- a/drivers/platform/x86/hp_accel.c
2087     +++ b/drivers/platform/x86/hp_accel.c
2088     @@ -77,6 +77,7 @@ static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
2089     static struct acpi_device_id lis3lv02d_device_ids[] = {
2090     {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
2091     {"HPQ6000", 0}, /* HP Mobile Data Protection System PNP */
2092     + {"HPQ6007", 0}, /* HP Mobile Data Protection System PNP */
2093     {"", 0},
2094     };
2095     MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
2096     diff --git a/drivers/rtc/rtc-max8907.c b/drivers/rtc/rtc-max8907.c
2097     index 86afb797125d..5d0ce597ba83 100644
2098     --- a/drivers/rtc/rtc-max8907.c
2099     +++ b/drivers/rtc/rtc-max8907.c
2100     @@ -51,7 +51,7 @@ static irqreturn_t max8907_irq_handler(int irq, void *data)
2101     {
2102     struct max8907_rtc *rtc = data;
2103    
2104     - regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
2105     + regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
2106    
2107     rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);
2108    
2109     @@ -64,7 +64,7 @@ static void regs_to_tm(u8 *regs, struct rtc_time *tm)
2110     bcd2bin(regs[RTC_YEAR1]) - 1900;
2111     tm->tm_mon = bcd2bin(regs[RTC_MONTH] & 0x1f) - 1;
2112     tm->tm_mday = bcd2bin(regs[RTC_DATE] & 0x3f);
2113     - tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07) - 1;
2114     + tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07);
2115     if (regs[RTC_HOUR] & HOUR_12) {
2116     tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x01f);
2117     if (tm->tm_hour == 12)
2118     @@ -88,7 +88,7 @@ static void tm_to_regs(struct rtc_time *tm, u8 *regs)
2119     regs[RTC_YEAR1] = bin2bcd(low);
2120     regs[RTC_MONTH] = bin2bcd(tm->tm_mon + 1);
2121     regs[RTC_DATE] = bin2bcd(tm->tm_mday);
2122     - regs[RTC_WEEKDAY] = tm->tm_wday + 1;
2123     + regs[RTC_WEEKDAY] = tm->tm_wday;
2124     regs[RTC_HOUR] = bin2bcd(tm->tm_hour);
2125     regs[RTC_MIN] = bin2bcd(tm->tm_min);
2126     regs[RTC_SEC] = bin2bcd(tm->tm_sec);
2127     @@ -153,7 +153,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
2128     tm_to_regs(&alrm->time, regs);
2129    
2130     /* Disable alarm while we update the target time */
2131     - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
2132     + ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
2133     if (ret < 0)
2134     return ret;
2135    
2136     @@ -163,8 +163,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
2137     return ret;
2138    
2139     if (alrm->enabled)
2140     - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL,
2141     - 0x7f, 0x7f);
2142     + ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x77);
2143    
2144     return ret;
2145     }
2146     diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
2147     index a5f7690e819e..ae2564d3123b 100644
2148     --- a/drivers/scsi/bfa/bfad.c
2149     +++ b/drivers/scsi/bfa/bfad.c
2150     @@ -1824,7 +1824,7 @@ out:
2151     static u32 *
2152     bfad_load_fwimg(struct pci_dev *pdev)
2153     {
2154     - if (pdev->device == BFA_PCI_DEVICE_ID_CT2) {
2155     + if (bfa_asic_id_ct2(pdev->device)) {
2156     if (bfi_image_ct2_size == 0)
2157     bfad_read_firmware(pdev, &bfi_image_ct2,
2158     &bfi_image_ct2_size, BFAD_FW_FILE_CT2);
2159     @@ -1834,12 +1834,14 @@ bfad_load_fwimg(struct pci_dev *pdev)
2160     bfad_read_firmware(pdev, &bfi_image_ct,
2161     &bfi_image_ct_size, BFAD_FW_FILE_CT);
2162     return bfi_image_ct;
2163     - } else {
2164     + } else if (bfa_asic_id_cb(pdev->device)) {
2165     if (bfi_image_cb_size == 0)
2166     bfad_read_firmware(pdev, &bfi_image_cb,
2167     &bfi_image_cb_size, BFAD_FW_FILE_CB);
2168     return bfi_image_cb;
2169     }
2170     +
2171     + return NULL;
2172     }
2173    
2174     static void
2175     diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
2176     index 74b88efde6ad..b26f1a5cc0ec 100644
2177     --- a/drivers/scsi/virtio_scsi.c
2178     +++ b/drivers/scsi/virtio_scsi.c
2179     @@ -957,6 +957,10 @@ static void virtscsi_remove(struct virtio_device *vdev)
2180     #ifdef CONFIG_PM
2181     static int virtscsi_freeze(struct virtio_device *vdev)
2182     {
2183     + struct Scsi_Host *sh = virtio_scsi_host(vdev);
2184     + struct virtio_scsi *vscsi = shost_priv(sh);
2185     +
2186     + unregister_hotcpu_notifier(&vscsi->nb);
2187     virtscsi_remove_vqs(vdev);
2188     return 0;
2189     }
2190     @@ -965,8 +969,17 @@ static int virtscsi_restore(struct virtio_device *vdev)
2191     {
2192     struct Scsi_Host *sh = virtio_scsi_host(vdev);
2193     struct virtio_scsi *vscsi = shost_priv(sh);
2194     + int err;
2195     +
2196     + err = virtscsi_init(vdev, vscsi);
2197     + if (err)
2198     + return err;
2199     +
2200     + err = register_hotcpu_notifier(&vscsi->nb);
2201     + if (err)
2202     + vdev->config->del_vqs(vdev);
2203    
2204     - return virtscsi_init(vdev, vscsi);
2205     + return err;
2206     }
2207     #endif
2208    
2209     diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
2210     index c812d6c7dc31..e3a005da776b 100644
2211     --- a/drivers/staging/rtl8712/usb_intf.c
2212     +++ b/drivers/staging/rtl8712/usb_intf.c
2213     @@ -358,6 +358,10 @@ static u8 key_2char2num(u8 hch, u8 lch)
2214     return (hex_to_bin(hch) << 4) | hex_to_bin(lch);
2215     }
2216    
2217     +static const struct device_type wlan_type = {
2218     + .name = "wlan",
2219     +};
2220     +
2221     /*
2222     * drv_init() - a device potentially for us
2223     *
2224     @@ -393,6 +397,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
2225     padapter->pusb_intf = pusb_intf;
2226     usb_set_intfdata(pusb_intf, pnetdev);
2227     SET_NETDEV_DEV(pnetdev, &pusb_intf->dev);
2228     + pnetdev->dev.type = &wlan_type;
2229     /* step 2. */
2230     padapter->dvobj_init = &r8712_usb_dvobj_init;
2231     padapter->dvobj_deinit = &r8712_usb_dvobj_deinit;
2232     diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
2233     index 3ff1126c9a53..55185336afe2 100644
2234     --- a/drivers/staging/vt6656/baseband.c
2235     +++ b/drivers/staging/vt6656/baseband.c
2236     @@ -1466,7 +1466,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2237    
2238     if( bScanning )
2239     { // need Max sensitivity //RSSI -69, -70,....
2240     - if(pDevice->byBBPreEDIndex == 0) break;
2241     pDevice->byBBPreEDIndex = 0;
2242     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2243     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
2244     @@ -1609,7 +1608,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2245    
2246     if( bScanning )
2247     { // need Max sensitivity //RSSI -69, -70, ...
2248     - if(pDevice->byBBPreEDIndex == 0) break;
2249     pDevice->byBBPreEDIndex = 0;
2250     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2251     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
2252     @@ -1761,7 +1759,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2253     case RF_VT3342A0: //RobertYu:20060627, testing table
2254     if( bScanning )
2255     { // need Max sensitivity //RSSI -67, -68, ...
2256     - if(pDevice->byBBPreEDIndex == 0) break;
2257     pDevice->byBBPreEDIndex = 0;
2258     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2259     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
2260     diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
2261     index 24291aee58b5..0beb246af4ad 100644
2262     --- a/drivers/staging/vt6656/card.c
2263     +++ b/drivers/staging/vt6656/card.c
2264     @@ -761,7 +761,7 @@ u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval)
2265    
2266     uBeaconInterval = wBeaconInterval * 1024;
2267     // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2268     - uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
2269     + uLowNextTBTT = ((qwTSF & 0xffffffffULL) >> 10) << 10;
2270     uLowRemain = (uLowNextTBTT) % uBeaconInterval;
2271     uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
2272     % uBeaconInterval;
2273     diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
2274     index b71a69750607..5b07fd156bd7 100644
2275     --- a/drivers/target/iscsi/iscsi_target.c
2276     +++ b/drivers/target/iscsi/iscsi_target.c
2277     @@ -54,7 +54,7 @@
2278     static LIST_HEAD(g_tiqn_list);
2279     static LIST_HEAD(g_np_list);
2280     static DEFINE_SPINLOCK(tiqn_lock);
2281     -static DEFINE_SPINLOCK(np_lock);
2282     +static DEFINE_MUTEX(np_lock);
2283    
2284     static struct idr tiqn_idr;
2285     struct idr sess_idr;
2286     @@ -303,6 +303,9 @@ bool iscsit_check_np_match(
2287     return false;
2288     }
2289    
2290     +/*
2291     + * Called with mutex np_lock held
2292     + */
2293     static struct iscsi_np *iscsit_get_np(
2294     struct __kernel_sockaddr_storage *sockaddr,
2295     int network_transport)
2296     @@ -310,11 +313,10 @@ static struct iscsi_np *iscsit_get_np(
2297     struct iscsi_np *np;
2298     bool match;
2299    
2300     - spin_lock_bh(&np_lock);
2301     list_for_each_entry(np, &g_np_list, np_list) {
2302     - spin_lock(&np->np_thread_lock);
2303     + spin_lock_bh(&np->np_thread_lock);
2304     if (np->np_thread_state != ISCSI_NP_THREAD_ACTIVE) {
2305     - spin_unlock(&np->np_thread_lock);
2306     + spin_unlock_bh(&np->np_thread_lock);
2307     continue;
2308     }
2309    
2310     @@ -326,13 +328,11 @@ static struct iscsi_np *iscsit_get_np(
2311     * while iscsi_tpg_add_network_portal() is called.
2312     */
2313     np->np_exports++;
2314     - spin_unlock(&np->np_thread_lock);
2315     - spin_unlock_bh(&np_lock);
2316     + spin_unlock_bh(&np->np_thread_lock);
2317     return np;
2318     }
2319     - spin_unlock(&np->np_thread_lock);
2320     + spin_unlock_bh(&np->np_thread_lock);
2321     }
2322     - spin_unlock_bh(&np_lock);
2323    
2324     return NULL;
2325     }
2326     @@ -346,16 +346,22 @@ struct iscsi_np *iscsit_add_np(
2327     struct sockaddr_in6 *sock_in6;
2328     struct iscsi_np *np;
2329     int ret;
2330     +
2331     + mutex_lock(&np_lock);
2332     +
2333     /*
2334     * Locate the existing struct iscsi_np if already active..
2335     */
2336     np = iscsit_get_np(sockaddr, network_transport);
2337     - if (np)
2338     + if (np) {
2339     + mutex_unlock(&np_lock);
2340     return np;
2341     + }
2342    
2343     np = kzalloc(sizeof(struct iscsi_np), GFP_KERNEL);
2344     if (!np) {
2345     pr_err("Unable to allocate memory for struct iscsi_np\n");
2346     + mutex_unlock(&np_lock);
2347     return ERR_PTR(-ENOMEM);
2348     }
2349    
2350     @@ -378,6 +384,7 @@ struct iscsi_np *iscsit_add_np(
2351     ret = iscsi_target_setup_login_socket(np, sockaddr);
2352     if (ret != 0) {
2353     kfree(np);
2354     + mutex_unlock(&np_lock);
2355     return ERR_PTR(ret);
2356     }
2357    
2358     @@ -386,6 +393,7 @@ struct iscsi_np *iscsit_add_np(
2359     pr_err("Unable to create kthread: iscsi_np\n");
2360     ret = PTR_ERR(np->np_thread);
2361     kfree(np);
2362     + mutex_unlock(&np_lock);
2363     return ERR_PTR(ret);
2364     }
2365     /*
2366     @@ -396,10 +404,10 @@ struct iscsi_np *iscsit_add_np(
2367     * point because iscsi_np has not been added to g_np_list yet.
2368     */
2369     np->np_exports = 1;
2370     + np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
2371    
2372     - spin_lock_bh(&np_lock);
2373     list_add_tail(&np->np_list, &g_np_list);
2374     - spin_unlock_bh(&np_lock);
2375     + mutex_unlock(&np_lock);
2376    
2377     pr_debug("CORE[0] - Added Network Portal: %s:%hu on %s\n",
2378     np->np_ip, np->np_port, np->np_transport->name);
2379     @@ -469,9 +477,9 @@ int iscsit_del_np(struct iscsi_np *np)
2380    
2381     np->np_transport->iscsit_free_np(np);
2382    
2383     - spin_lock_bh(&np_lock);
2384     + mutex_lock(&np_lock);
2385     list_del(&np->np_list);
2386     - spin_unlock_bh(&np_lock);
2387     + mutex_unlock(&np_lock);
2388    
2389     pr_debug("CORE[0] - Removed Network Portal: %s:%hu on %s\n",
2390     np->np_ip, np->np_port, np->np_transport->name);
2391     diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
2392     index 86c00b1c5583..d28d7afc128a 100644
2393     --- a/drivers/tty/serial/8250/8250_core.c
2394     +++ b/drivers/tty/serial/8250/8250_core.c
2395     @@ -2670,6 +2670,10 @@ static void serial8250_config_port(struct uart_port *port, int flags)
2396     if (port->type == PORT_16550A && port->iotype == UPIO_AU)
2397     up->bugs |= UART_BUG_NOMSR;
2398    
2399     + /* HW bugs may trigger IRQ while IIR == NO_INT */
2400     + if (port->type == PORT_TEGRA)
2401     + up->bugs |= UART_BUG_NOMSR;
2402     +
2403     if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
2404     autoconfig_irq(up);
2405    
2406     diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2407     index c52948b368d8..8d3c0b5e2878 100644
2408     --- a/drivers/tty/serial/8250/8250_pci.c
2409     +++ b/drivers/tty/serial/8250/8250_pci.c
2410     @@ -1260,10 +1260,10 @@ static int pci_quatech_init(struct pci_dev *dev)
2411     unsigned long base = pci_resource_start(dev, 0);
2412     if (base) {
2413     u32 tmp;
2414     - outl(inl(base + 0x38), base + 0x38);
2415     + outl(inl(base + 0x38) | 0x00002000, base + 0x38);
2416     tmp = inl(base + 0x3c);
2417     outl(tmp | 0x01000000, base + 0x3c);
2418     - outl(tmp, base + 0x3c);
2419     + outl(tmp &= ~0x01000000, base + 0x3c);
2420     }
2421     }
2422     return 0;
2423     @@ -1545,6 +1545,7 @@ pci_wch_ch353_setup(struct serial_private *priv,
2424     #define PCI_DEVICE_ID_TITAN_800E 0xA014
2425     #define PCI_DEVICE_ID_TITAN_200EI 0xA016
2426     #define PCI_DEVICE_ID_TITAN_200EISI 0xA017
2427     +#define PCI_DEVICE_ID_TITAN_200V3 0xA306
2428     #define PCI_DEVICE_ID_TITAN_400V3 0xA310
2429     #define PCI_DEVICE_ID_TITAN_410V3 0xA312
2430     #define PCI_DEVICE_ID_TITAN_800V3 0xA314
2431     @@ -4139,6 +4140,9 @@ static struct pci_device_id serial_pci_tbl[] = {
2432     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EISI,
2433     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2434     pbn_oxsemi_2_4000000 },
2435     + { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200V3,
2436     + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2437     + pbn_b0_bt_2_921600 },
2438     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400V3,
2439     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2440     pbn_b0_4_921600 },
2441     diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
2442     index 3467462869ce..82127ac26d6f 100644
2443     --- a/drivers/tty/serial/atmel_serial.c
2444     +++ b/drivers/tty/serial/atmel_serial.c
2445     @@ -1022,12 +1022,24 @@ static int atmel_startup(struct uart_port *port)
2446     static void atmel_shutdown(struct uart_port *port)
2447     {
2448     struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2449     +
2450     /*
2451     - * Ensure everything is stopped.
2452     + * Clear out any scheduled tasklets before
2453     + * we destroy the buffers
2454     + */
2455     + tasklet_kill(&atmel_port->tasklet);
2456     +
2457     + /*
2458     + * Ensure everything is stopped and
2459     + * disable all interrupts, port and break condition.
2460     */
2461     atmel_stop_rx(port);
2462     atmel_stop_tx(port);
2463    
2464     + UART_PUT_CR(port, ATMEL_US_RSTSTA);
2465     + UART_PUT_IDR(port, -1);
2466     +
2467     +
2468     /*
2469     * Shut-down the DMA.
2470     */
2471     @@ -1054,12 +1066,6 @@ static void atmel_shutdown(struct uart_port *port)
2472     }
2473    
2474     /*
2475     - * Disable all interrupts, port and break condition.
2476     - */
2477     - UART_PUT_CR(port, ATMEL_US_RSTSTA);
2478     - UART_PUT_IDR(port, -1);
2479     -
2480     - /*
2481     * Free the interrupt
2482     */
2483     free_irq(port->irq, port);
2484     diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
2485     index a6b2cabe7930..548d1996590f 100644
2486     --- a/drivers/usb/core/config.c
2487     +++ b/drivers/usb/core/config.c
2488     @@ -651,10 +651,6 @@ void usb_destroy_configuration(struct usb_device *dev)
2489     *
2490     * hub-only!! ... and only in reset path, or usb_new_device()
2491     * (used by real hubs and virtual root hubs)
2492     - *
2493     - * NOTE: if this is a WUSB device and is not authorized, we skip the
2494     - * whole thing. A non-authorized USB device has no
2495     - * configurations.
2496     */
2497     int usb_get_configuration(struct usb_device *dev)
2498     {
2499     @@ -666,8 +662,6 @@ int usb_get_configuration(struct usb_device *dev)
2500     struct usb_config_descriptor *desc;
2501    
2502     cfgno = 0;
2503     - if (dev->authorized == 0) /* Not really an error */
2504     - goto out_not_authorized;
2505     result = -ENOMEM;
2506     if (ncfg > USB_MAXCONFIG) {
2507     dev_warn(ddev, "too many configurations: %d, "
2508     @@ -751,7 +745,6 @@ int usb_get_configuration(struct usb_device *dev)
2509    
2510     err:
2511     kfree(desc);
2512     -out_not_authorized:
2513     dev->descriptor.bNumConfigurations = cfgno;
2514     err2:
2515     if (result == -ENOMEM)
2516     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2517     index 4d25bff2dac1..e604645a1290 100644
2518     --- a/drivers/usb/core/hub.c
2519     +++ b/drivers/usb/core/hub.c
2520     @@ -1605,7 +1605,7 @@ static void hub_disconnect(struct usb_interface *intf)
2521     {
2522     struct usb_hub *hub = usb_get_intfdata(intf);
2523     struct usb_device *hdev = interface_to_usbdev(intf);
2524     - int i;
2525     + int port1;
2526    
2527     /* Take the hub off the event list and don't let it be added again */
2528     spin_lock_irq(&hub_event_lock);
2529     @@ -1620,11 +1620,15 @@ static void hub_disconnect(struct usb_interface *intf)
2530     hub->error = 0;
2531     hub_quiesce(hub, HUB_DISCONNECT);
2532    
2533     - usb_set_intfdata (intf, NULL);
2534     + /* Avoid races with recursively_mark_NOTATTACHED() */
2535     + spin_lock_irq(&device_state_lock);
2536     + port1 = hdev->maxchild;
2537     + hdev->maxchild = 0;
2538     + usb_set_intfdata(intf, NULL);
2539     + spin_unlock_irq(&device_state_lock);
2540    
2541     - for (i = 0; i < hdev->maxchild; i++)
2542     - usb_hub_remove_port_device(hub, i + 1);
2543     - hub->hdev->maxchild = 0;
2544     + for (; port1 > 0; --port1)
2545     + usb_hub_remove_port_device(hub, port1);
2546    
2547     if (hub->hdev->speed == USB_SPEED_HIGH)
2548     highspeed_hubs--;
2549     @@ -2227,18 +2231,13 @@ static int usb_enumerate_device(struct usb_device *udev)
2550     return err;
2551     }
2552     }
2553     - if (udev->wusb == 1 && udev->authorized == 0) {
2554     - udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2555     - udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2556     - udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2557     - }
2558     - else {
2559     - /* read the standard strings and cache them if present */
2560     - udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2561     - udev->manufacturer = usb_cache_string(udev,
2562     - udev->descriptor.iManufacturer);
2563     - udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2564     - }
2565     +
2566     + /* read the standard strings and cache them if present */
2567     + udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2568     + udev->manufacturer = usb_cache_string(udev,
2569     + udev->descriptor.iManufacturer);
2570     + udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2571     +
2572     err = usb_enumerate_device_otg(udev);
2573     if (err < 0)
2574     return err;
2575     @@ -2417,16 +2416,6 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
2576     usb_dev->authorized = 0;
2577     usb_set_configuration(usb_dev, -1);
2578    
2579     - kfree(usb_dev->product);
2580     - usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2581     - kfree(usb_dev->manufacturer);
2582     - usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2583     - kfree(usb_dev->serial);
2584     - usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2585     -
2586     - usb_destroy_configuration(usb_dev);
2587     - usb_dev->descriptor.bNumConfigurations = 0;
2588     -
2589     out_unauthorized:
2590     usb_unlock_device(usb_dev);
2591     return 0;
2592     @@ -2454,17 +2443,7 @@ int usb_authorize_device(struct usb_device *usb_dev)
2593     goto error_device_descriptor;
2594     }
2595    
2596     - kfree(usb_dev->product);
2597     - usb_dev->product = NULL;
2598     - kfree(usb_dev->manufacturer);
2599     - usb_dev->manufacturer = NULL;
2600     - kfree(usb_dev->serial);
2601     - usb_dev->serial = NULL;
2602     -
2603     usb_dev->authorized = 1;
2604     - result = usb_enumerate_device(usb_dev);
2605     - if (result < 0)
2606     - goto error_enumerate;
2607     /* Choose and set the configuration. This registers the interfaces
2608     * with the driver core and lets interface drivers bind to them.
2609     */
2610     @@ -2480,7 +2459,6 @@ int usb_authorize_device(struct usb_device *usb_dev)
2611     }
2612     dev_info(&usb_dev->dev, "authorized to connect\n");
2613    
2614     -error_enumerate:
2615     error_device_descriptor:
2616     usb_autosuspend_device(usb_dev);
2617     error_autoresume:
2618     diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
2619     index 7c978b23520d..03322d9c70dc 100644
2620     --- a/drivers/usb/host/ehci.h
2621     +++ b/drivers/usb/host/ehci.h
2622     @@ -200,6 +200,7 @@ struct ehci_hcd { /* one per controller */
2623     unsigned has_synopsys_hc_bug:1; /* Synopsys HC */
2624     unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
2625     unsigned need_oc_pp_cycle:1; /* MPC834X port power */
2626     + unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
2627    
2628     /* required for usb32 quirk */
2629     #define OHCI_CTRL_HCFS (3 << 6)
2630     @@ -675,6 +676,18 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
2631     #endif
2632     }
2633    
2634     +#ifdef CONFIG_SOC_IMX28
2635     +static inline void imx28_ehci_writel(const unsigned int val,
2636     + volatile __u32 __iomem *addr)
2637     +{
2638     + __asm__ ("swp %0, %0, [%1]" : : "r"(val), "r"(addr));
2639     +}
2640     +#else
2641     +static inline void imx28_ehci_writel(const unsigned int val,
2642     + volatile __u32 __iomem *addr)
2643     +{
2644     +}
2645     +#endif
2646     static inline void ehci_writel(const struct ehci_hcd *ehci,
2647     const unsigned int val, __u32 __iomem *regs)
2648     {
2649     @@ -683,7 +696,10 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,
2650     writel_be(val, regs) :
2651     writel(val, regs);
2652     #else
2653     - writel(val, regs);
2654     + if (ehci->imx28_write_fix)
2655     + imx28_ehci_writel(val, regs);
2656     + else
2657     + writel(val, regs);
2658     #endif
2659     }
2660    
2661     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2662     index 4a5251f3614c..a90819b83224 100644
2663     --- a/drivers/usb/host/xhci.c
2664     +++ b/drivers/usb/host/xhci.c
2665     @@ -315,6 +315,9 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
2666     struct usb_hcd *hcd = xhci_to_hcd(xhci);
2667     struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
2668    
2669     + if (xhci->quirks & XHCI_PLAT)
2670     + return;
2671     +
2672     xhci_free_irq(xhci);
2673    
2674     if (xhci->msix_entries) {
2675     diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
2676     index b461311a2ae7..ce13e61b7d55 100644
2677     --- a/drivers/usb/serial/cypress_m8.h
2678     +++ b/drivers/usb/serial/cypress_m8.h
2679     @@ -63,7 +63,7 @@
2680     #define UART_DSR 0x20 /* data set ready - flow control - device to host */
2681     #define CONTROL_RTS 0x10 /* request to send - flow control - host to device */
2682     #define UART_CTS 0x10 /* clear to send - flow control - device to host */
2683     -#define UART_RI 0x10 /* ring indicator - modem - device to host */
2684     +#define UART_RI 0x80 /* ring indicator - modem - device to host */
2685     #define UART_CD 0x40 /* carrier detect - modem - device to host */
2686     #define CYP_ERROR 0x08 /* received from input report - device to host */
2687     /* Note - the below has nothing to do with the "feature report" reset */
2688     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2689     index 92549cc4665f..089248c1d597 100644
2690     --- a/drivers/usb/serial/ftdi_sio.c
2691     +++ b/drivers/usb/serial/ftdi_sio.c
2692     @@ -2132,10 +2132,20 @@ static void ftdi_set_termios(struct tty_struct *tty,
2693     }
2694    
2695     /*
2696     - * All FTDI UART chips are limited to CS7/8. We won't pretend to
2697     + * All FTDI UART chips are limited to CS7/8. We shouldn't pretend to
2698     * support CS5/6 and revert the CSIZE setting instead.
2699     + *
2700     + * CS5 however is used to control some smartcard readers which abuse
2701     + * this limitation to switch modes. Original FTDI chips fall back to
2702     + * eight data bits.
2703     + *
2704     + * TODO: Implement a quirk to only allow this with mentioned
2705     + * readers. One I know of (Argolis Smartreader V1)
2706     + * returns "USB smartcard server" as iInterface string.
2707     + * The vendor didn't bother with a custom VID/PID of
2708     + * course.
2709     */
2710     - if ((C_CSIZE(tty) != CS8) && (C_CSIZE(tty) != CS7)) {
2711     + if (C_CSIZE(tty) == CS6) {
2712     dev_warn(ddev, "requested CSIZE setting not supported\n");
2713    
2714     termios->c_cflag &= ~CSIZE;
2715     @@ -2182,6 +2192,9 @@ no_skip:
2716     urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
2717     }
2718     switch (cflag & CSIZE) {
2719     + case CS5:
2720     + dev_dbg(ddev, "Setting CS5 quirk\n");
2721     + break;
2722     case CS7:
2723     urb_value |= 7;
2724     dev_dbg(ddev, "Setting CS7\n");
2725     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2726     index cc7a24154490..5c86f57e4afa 100644
2727     --- a/drivers/usb/serial/option.c
2728     +++ b/drivers/usb/serial/option.c
2729     @@ -320,6 +320,9 @@ static void option_instat_callback(struct urb *urb);
2730     * It seems to contain a Qualcomm QSC6240/6290 chipset */
2731     #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603
2732    
2733     +/* iBall 3.5G connect wireless modem */
2734     +#define IBALL_3_5G_CONNECT 0x9605
2735     +
2736     /* Zoom */
2737     #define ZOOM_PRODUCT_4597 0x9607
2738    
2739     @@ -1447,6 +1450,17 @@ static const struct usb_device_id option_ids[] = {
2740     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
2741     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
2742     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
2743     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
2744     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) },
2745     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) },
2746     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
2747     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8e, 0xff, 0xff, 0xff) },
2748     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8f, 0xff, 0xff, 0xff) },
2749     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff90, 0xff, 0xff, 0xff) },
2750     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff91, 0xff, 0xff, 0xff) },
2751     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) },
2752     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
2753     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
2754    
2755     /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */
2756     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
2757     @@ -1489,6 +1503,7 @@ static const struct usb_device_id option_ids[] = {
2758     .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
2759     },
2760     { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
2761     + { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
2762     { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
2763     /* Pirelli */
2764     { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
2765     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
2766     index 5e39f5c4941b..4471f464ca26 100644
2767     --- a/drivers/usb/serial/pl2303.c
2768     +++ b/drivers/usb/serial/pl2303.c
2769     @@ -141,6 +141,8 @@ struct pl2303_private {
2770     spinlock_t lock;
2771     u8 line_control;
2772     u8 line_status;
2773     +
2774     + u8 line_settings[7];
2775     };
2776    
2777     static int pl2303_vendor_read(__u16 value, __u16 index,
2778     @@ -280,10 +282,6 @@ static void pl2303_set_termios(struct tty_struct *tty,
2779     int baud_floor, baud_ceil;
2780     int k;
2781    
2782     - /* The PL2303 is reported to lose bytes if you change
2783     - serial settings even to the same values as before. Thus
2784     - we actually need to filter in this specific case */
2785     -
2786     if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
2787     return;
2788    
2789     @@ -422,10 +420,29 @@ static void pl2303_set_termios(struct tty_struct *tty,
2790     dev_dbg(&port->dev, "parity = none\n");
2791     }
2792    
2793     - i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2794     - SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
2795     - 0, 0, buf, 7, 100);
2796     - dev_dbg(&port->dev, "0x21:0x20:0:0 %d\n", i);
2797     + /*
2798     + * Some PL2303 are known to lose bytes if you change serial settings
2799     + * even to the same values as before. Thus we actually need to filter
2800     + * in this specific case.
2801     + *
2802     + * Note that the tty_termios_hw_change check above is not sufficient
2803     + * as a previously requested baud rate may differ from the one
2804     + * actually used (and stored in old_termios).
2805     + *
2806     + * NOTE: No additional locking needed for line_settings as it is
2807     + * only used in set_termios, which is serialised against itself.
2808     + */
2809     + if (!old_termios || memcmp(buf, priv->line_settings, 7)) {
2810     + i = usb_control_msg(serial->dev,
2811     + usb_sndctrlpipe(serial->dev, 0),
2812     + SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
2813     + 0, 0, buf, 7, 100);
2814     +
2815     + dev_dbg(&port->dev, "0x21:0x20:0:0 %d\n", i);
2816     +
2817     + if (i == 7)
2818     + memcpy(priv->line_settings, buf, 7);
2819     + }
2820    
2821     /* change control lines if we are switching to or from B0 */
2822     spin_lock_irqsave(&priv->lock, flags);
2823     diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
2824     index de32cfa5bfa6..ad06255c2ade 100644
2825     --- a/drivers/usb/storage/unusual_devs.h
2826     +++ b/drivers/usb/storage/unusual_devs.h
2827     @@ -234,6 +234,13 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
2828     USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2829     US_FL_MAX_SECTORS_64 ),
2830    
2831     +/* Patch submitted by Mikhail Zolotaryov <lebon@lebon.org.ua> */
2832     +UNUSUAL_DEV( 0x0421, 0x06aa, 0x1110, 0x1110,
2833     + "Nokia",
2834     + "502",
2835     + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2836     + US_FL_MAX_SECTORS_64 ),
2837     +
2838     #ifdef NO_SDDR09
2839     UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
2840     "Microtech",
2841     diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
2842     index 3b6d20bc2388..bbafa05519da 100644
2843     --- a/fs/btrfs/extent-tree.c
2844     +++ b/fs/btrfs/extent-tree.c
2845     @@ -7491,7 +7491,7 @@ out:
2846     */
2847     if (root_dropped == false)
2848     btrfs_add_dead_root(root);
2849     - if (err)
2850     + if (err && err != -EAGAIN)
2851     btrfs_std_error(root->fs_info, err);
2852     return err;
2853     }
2854     diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
2855     index 145b2c75ab83..783906c687b5 100644
2856     --- a/fs/btrfs/ioctl.c
2857     +++ b/fs/btrfs/ioctl.c
2858     @@ -1528,6 +1528,12 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
2859     printk(KERN_INFO "btrfs: Snapshot src from "
2860     "another FS\n");
2861     ret = -EINVAL;
2862     + } else if (!inode_owner_or_capable(src_inode)) {
2863     + /*
2864     + * Subvolume creation is not restricted, but snapshots
2865     + * are limited to own subvolumes only
2866     + */
2867     + ret = -EPERM;
2868     } else {
2869     ret = btrfs_mksubvol(&file->f_path, name, namelen,
2870     BTRFS_I(src_inode)->root,
2871     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
2872     index 33331b4c2178..e350be6c7ac6 100644
2873     --- a/fs/ext4/inline.c
2874     +++ b/fs/ext4/inline.c
2875     @@ -1957,9 +1957,11 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
2876     }
2877    
2878     /* Clear the content within i_blocks. */
2879     - if (i_size < EXT4_MIN_INLINE_DATA_SIZE)
2880     - memset(ext4_raw_inode(&is.iloc)->i_block + i_size, 0,
2881     - EXT4_MIN_INLINE_DATA_SIZE - i_size);
2882     + if (i_size < EXT4_MIN_INLINE_DATA_SIZE) {
2883     + void *p = (void *) ext4_raw_inode(&is.iloc)->i_block;
2884     + memset(p + i_size, 0,
2885     + EXT4_MIN_INLINE_DATA_SIZE - i_size);
2886     + }
2887    
2888     EXT4_I(inode)->i_inline_size = i_size <
2889     EXT4_MIN_INLINE_DATA_SIZE ?
2890     diff --git a/fs/mount.h b/fs/mount.h
2891     index 64a858143ff9..68d80bdcd081 100644
2892     --- a/fs/mount.h
2893     +++ b/fs/mount.h
2894     @@ -73,7 +73,7 @@ static inline int mnt_has_parent(struct mount *mnt)
2895     static inline int is_mounted(struct vfsmount *mnt)
2896     {
2897     /* neither detached nor internal? */
2898     - return !IS_ERR_OR_NULL(real_mount(mnt));
2899     + return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
2900     }
2901    
2902     extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
2903     diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
2904     index feaf0c7fb7d8..c8958f563116 100644
2905     --- a/include/linux/hugetlb.h
2906     +++ b/include/linux/hugetlb.h
2907     @@ -31,6 +31,7 @@ struct hugepage_subpool *hugepage_new_subpool(long nr_blocks);
2908     void hugepage_put_subpool(struct hugepage_subpool *spool);
2909    
2910     int PageHuge(struct page *page);
2911     +int PageHeadHuge(struct page *page_head);
2912    
2913     void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
2914     int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
2915     @@ -98,6 +99,11 @@ static inline int PageHuge(struct page *page)
2916     return 0;
2917     }
2918    
2919     +static inline int PageHeadHuge(struct page *page_head)
2920     +{
2921     + return 0;
2922     +}
2923     +
2924     static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
2925     {
2926     }
2927     diff --git a/include/linux/libata.h b/include/linux/libata.h
2928     index 9a4c194ebc8a..f33619d8ac52 100644
2929     --- a/include/linux/libata.h
2930     +++ b/include/linux/libata.h
2931     @@ -400,6 +400,8 @@ enum {
2932     ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */
2933     ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */
2934     ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */
2935     + ATA_HORKAGE_NOLPM = (1 << 20), /* don't use LPM */
2936     + ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21), /* some WDs have broken LPM */
2937    
2938     /* DMA mask for user DMA control: User visible values; DO NOT
2939     renumber */
2940     diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
2941     index 19ff89e34eec..d619b28c456f 100644
2942     --- a/lib/decompress_inflate.c
2943     +++ b/lib/decompress_inflate.c
2944     @@ -48,7 +48,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
2945     out_len = 0x8000; /* 32 K */
2946     out_buf = malloc(out_len);
2947     } else {
2948     - out_len = 0x7fffffff; /* no limit */
2949     + out_len = ((size_t)~0) - (size_t)out_buf; /* no limit */
2950     }
2951     if (!out_buf) {
2952     error("Out of memory while allocating output buffer");
2953     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2954     index 7c5eb85ec645..40ad2c6e0ca9 100644
2955     --- a/mm/hugetlb.c
2956     +++ b/mm/hugetlb.c
2957     @@ -690,6 +690,23 @@ int PageHuge(struct page *page)
2958     }
2959     EXPORT_SYMBOL_GPL(PageHuge);
2960    
2961     +/*
2962     + * PageHeadHuge() only returns true for hugetlbfs head page, but not for
2963     + * normal or transparent huge pages.
2964     + */
2965     +int PageHeadHuge(struct page *page_head)
2966     +{
2967     + compound_page_dtor *dtor;
2968     +
2969     + if (!PageHead(page_head))
2970     + return 0;
2971     +
2972     + dtor = get_compound_page_dtor(page_head);
2973     +
2974     + return dtor == free_huge_page;
2975     +}
2976     +EXPORT_SYMBOL_GPL(PageHeadHuge);
2977     +
2978     pgoff_t __basepage_index(struct page *page)
2979     {
2980     struct page *page_head = compound_head(page);
2981     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
2982     index 4baf12e534d1..6c2dace665aa 100644
2983     --- a/mm/mempolicy.c
2984     +++ b/mm/mempolicy.c
2985     @@ -2801,7 +2801,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
2986     */
2987     VM_BUG_ON(maxlen < strlen("interleave") + strlen("relative") + 16);
2988    
2989     - if (!pol || pol == &default_policy)
2990     + if (!pol || pol == &default_policy || (pol->flags & MPOL_F_MORON))
2991     mode = MPOL_DEFAULT;
2992     else
2993     mode = pol->mode;
2994     diff --git a/mm/swap.c b/mm/swap.c
2995     index 9f2225f2b5b0..ea58dbde788e 100644
2996     --- a/mm/swap.c
2997     +++ b/mm/swap.c
2998     @@ -79,19 +79,6 @@ static void __put_compound_page(struct page *page)
2999    
3000     static void put_compound_page(struct page *page)
3001     {
3002     - /*
3003     - * hugetlbfs pages cannot be split from under us. If this is a
3004     - * hugetlbfs page, check refcount on head page and release the page if
3005     - * the refcount becomes zero.
3006     - */
3007     - if (PageHuge(page)) {
3008     - page = compound_head(page);
3009     - if (put_page_testzero(page))
3010     - __put_compound_page(page);
3011     -
3012     - return;
3013     - }
3014     -
3015     if (unlikely(PageTail(page))) {
3016     /* __split_huge_page_refcount can run under us */
3017     struct page *page_head = compound_trans_head(page);
3018     @@ -108,14 +95,31 @@ static void put_compound_page(struct page *page)
3019     * still hot on arches that do not support
3020     * this_cpu_cmpxchg_double().
3021     */
3022     - if (PageSlab(page_head)) {
3023     - if (PageTail(page)) {
3024     + if (PageSlab(page_head) || PageHeadHuge(page_head)) {
3025     + if (likely(PageTail(page))) {
3026     + /*
3027     + * __split_huge_page_refcount
3028     + * cannot race here.
3029     + */
3030     + VM_BUG_ON(!PageHead(page_head));
3031     + atomic_dec(&page->_mapcount);
3032     if (put_page_testzero(page_head))
3033     VM_BUG_ON(1);
3034     -
3035     - atomic_dec(&page->_mapcount);
3036     - goto skip_lock_tail;
3037     + if (put_page_testzero(page_head))
3038     + __put_compound_page(page_head);
3039     + return;
3040     } else
3041     + /*
3042     + * __split_huge_page_refcount
3043     + * run before us, "page" was a
3044     + * THP tail. The split
3045     + * page_head has been freed
3046     + * and reallocated as slab or
3047     + * hugetlbfs page of smaller
3048     + * order (only possible if
3049     + * reallocated as slab on
3050     + * x86).
3051     + */
3052     goto skip_lock;
3053     }
3054     /*
3055     @@ -129,8 +133,27 @@ static void put_compound_page(struct page *page)
3056     /* __split_huge_page_refcount run before us */
3057     compound_unlock_irqrestore(page_head, flags);
3058     skip_lock:
3059     - if (put_page_testzero(page_head))
3060     - __put_single_page(page_head);
3061     + if (put_page_testzero(page_head)) {
3062     + /*
3063     + * The head page may have been
3064     + * freed and reallocated as a
3065     + * compound page of smaller
3066     + * order and then freed again.
3067     + * All we know is that it
3068     + * cannot have become: a THP
3069     + * page, a compound page of
3070     + * higher order, a tail page.
3071     + * That is because we still
3072     + * hold the refcount of the
3073     + * split THP tail and
3074     + * page_head was the THP head
3075     + * before the split.
3076     + */
3077     + if (PageHead(page_head))
3078     + __put_compound_page(page_head);
3079     + else
3080     + __put_single_page(page_head);
3081     + }
3082     out_put_single:
3083     if (put_page_testzero(page))
3084     __put_single_page(page);
3085     @@ -152,7 +175,6 @@ out_put_single:
3086     VM_BUG_ON(atomic_read(&page->_count) != 0);
3087     compound_unlock_irqrestore(page_head, flags);
3088    
3089     -skip_lock_tail:
3090     if (put_page_testzero(page_head)) {
3091     if (PageHead(page_head))
3092     __put_compound_page(page_head);
3093     @@ -195,51 +217,52 @@ bool __get_page_tail(struct page *page)
3094     * proper PT lock that already serializes against
3095     * split_huge_page().
3096     */
3097     + unsigned long flags;
3098     bool got = false;
3099     - struct page *page_head;
3100     -
3101     - /*
3102     - * If this is a hugetlbfs page it cannot be split under us. Simply
3103     - * increment refcount for the head page.
3104     - */
3105     - if (PageHuge(page)) {
3106     - page_head = compound_head(page);
3107     - atomic_inc(&page_head->_count);
3108     - got = true;
3109     - } else {
3110     - unsigned long flags;
3111     + struct page *page_head = compound_trans_head(page);
3112    
3113     - page_head = compound_trans_head(page);
3114     - if (likely(page != page_head &&
3115     - get_page_unless_zero(page_head))) {
3116     -
3117     - /* Ref to put_compound_page() comment. */
3118     - if (PageSlab(page_head)) {
3119     - if (likely(PageTail(page))) {
3120     - __get_page_tail_foll(page, false);
3121     - return true;
3122     - } else {
3123     - put_page(page_head);
3124     - return false;
3125     - }
3126     - }
3127     -
3128     - /*
3129     - * page_head wasn't a dangling pointer but it
3130     - * may not be a head page anymore by the time
3131     - * we obtain the lock. That is ok as long as it
3132     - * can't be freed from under us.
3133     - */
3134     - flags = compound_lock_irqsave(page_head);
3135     - /* here __split_huge_page_refcount won't run anymore */
3136     + if (likely(page != page_head && get_page_unless_zero(page_head))) {
3137     + /* Ref to put_compound_page() comment. */
3138     + if (PageSlab(page_head) || PageHeadHuge(page_head)) {
3139     if (likely(PageTail(page))) {
3140     + /*
3141     + * This is a hugetlbfs page or a slab
3142     + * page. __split_huge_page_refcount
3143     + * cannot race here.
3144     + */
3145     + VM_BUG_ON(!PageHead(page_head));
3146     __get_page_tail_foll(page, false);
3147     - got = true;
3148     - }
3149     - compound_unlock_irqrestore(page_head, flags);
3150     - if (unlikely(!got))
3151     + return true;
3152     + } else {
3153     + /*
3154     + * __split_huge_page_refcount run
3155     + * before us, "page" was a THP
3156     + * tail. The split page_head has been
3157     + * freed and reallocated as slab or
3158     + * hugetlbfs page of smaller order
3159     + * (only possible if reallocated as
3160     + * slab on x86).
3161     + */
3162     put_page(page_head);
3163     + return false;
3164     + }
3165     + }
3166     +
3167     + /*
3168     + * page_head wasn't a dangling pointer but it
3169     + * may not be a head page anymore by the time
3170     + * we obtain the lock. That is ok as long as it
3171     + * can't be freed from under us.
3172     + */
3173     + flags = compound_lock_irqsave(page_head);
3174     + /* here __split_huge_page_refcount won't run anymore */
3175     + if (likely(PageTail(page))) {
3176     + __get_page_tail_foll(page, false);
3177     + got = true;
3178     }
3179     + compound_unlock_irqrestore(page_head, flags);
3180     + if (unlikely(!got))
3181     + put_page(page_head);
3182     }
3183     return got;
3184     }
3185     diff --git a/net/compat.c b/net/compat.c
3186     index dd32e34c1e2c..f50161fb812e 100644
3187     --- a/net/compat.c
3188     +++ b/net/compat.c
3189     @@ -780,21 +780,16 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
3190     if (flags & MSG_CMSG_COMPAT)
3191     return -EINVAL;
3192    
3193     - if (COMPAT_USE_64BIT_TIME)
3194     - return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
3195     - flags | MSG_CMSG_COMPAT,
3196     - (struct timespec *) timeout);
3197     -
3198     if (timeout == NULL)
3199     return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
3200     flags | MSG_CMSG_COMPAT, NULL);
3201    
3202     - if (get_compat_timespec(&ktspec, timeout))
3203     + if (compat_get_timespec(&ktspec, timeout))
3204     return -EFAULT;
3205    
3206     datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
3207     flags | MSG_CMSG_COMPAT, &ktspec);
3208     - if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
3209     + if (datagrams > 0 && compat_put_timespec(&ktspec, timeout))
3210     datagrams = -EFAULT;
3211    
3212     return datagrams;
3213     diff --git a/net/core/filter.c b/net/core/filter.c
3214     index 6438f29ff266..52f01229ee01 100644
3215     --- a/net/core/filter.c
3216     +++ b/net/core/filter.c
3217     @@ -36,7 +36,6 @@
3218     #include <asm/uaccess.h>
3219     #include <asm/unaligned.h>
3220     #include <linux/filter.h>
3221     -#include <linux/reciprocal_div.h>
3222     #include <linux/ratelimit.h>
3223     #include <linux/seccomp.h>
3224     #include <linux/if_vlan.h>
3225     @@ -166,7 +165,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
3226     A /= X;
3227     continue;
3228     case BPF_S_ALU_DIV_K:
3229     - A = reciprocal_divide(A, K);
3230     + A /= K;
3231     continue;
3232     case BPF_S_ALU_MOD_X:
3233     if (X == 0)
3234     @@ -553,11 +552,6 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
3235     /* Some instructions need special checks */
3236     switch (code) {
3237     case BPF_S_ALU_DIV_K:
3238     - /* check for division by zero */
3239     - if (ftest->k == 0)
3240     - return -EINVAL;
3241     - ftest->k = reciprocal_value(ftest->k);
3242     - break;
3243     case BPF_S_ALU_MOD_K:
3244     /* check for division by zero */
3245     if (ftest->k == 0)
3246     @@ -853,27 +847,7 @@ void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
3247     to->code = decodes[code];
3248     to->jt = filt->jt;
3249     to->jf = filt->jf;
3250     -
3251     - if (code == BPF_S_ALU_DIV_K) {
3252     - /*
3253     - * When loaded this rule user gave us X, which was
3254     - * translated into R = r(X). Now we calculate the
3255     - * RR = r(R) and report it back. If next time this
3256     - * value is loaded and RRR = r(RR) is calculated
3257     - * then the R == RRR will be true.
3258     - *
3259     - * One exception. X == 1 translates into R == 0 and
3260     - * we can't calculate RR out of it with r().
3261     - */
3262     -
3263     - if (filt->k == 0)
3264     - to->k = 1;
3265     - else
3266     - to->k = reciprocal_value(filt->k);
3267     -
3268     - BUG_ON(reciprocal_value(to->k) != filt->k);
3269     - } else
3270     - to->k = filt->k;
3271     + to->k = filt->k;
3272     }
3273    
3274     int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, unsigned int len)
3275     diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
3276     index 22b1a7058fd3..4efd2375d7e1 100644
3277     --- a/net/ieee802154/nl-phy.c
3278     +++ b/net/ieee802154/nl-phy.c
3279     @@ -224,8 +224,10 @@ static int ieee802154_add_iface(struct sk_buff *skb,
3280    
3281     if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
3282     type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
3283     - if (type >= __IEEE802154_DEV_MAX)
3284     - return -EINVAL;
3285     + if (type >= __IEEE802154_DEV_MAX) {
3286     + rc = -EINVAL;
3287     + goto nla_put_failure;
3288     + }
3289     }
3290    
3291     dev = phy->add_iface(phy, devname, type);
3292     diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
3293     index c7629a209f9d..4556cd25acde 100644
3294     --- a/net/ipv4/fib_frontend.c
3295     +++ b/net/ipv4/fib_frontend.c
3296     @@ -1049,6 +1049,8 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
3297     }
3298    
3299     in_dev = __in_dev_get_rtnl(dev);
3300     + if (!in_dev)
3301     + return NOTIFY_DONE;
3302    
3303     switch (event) {
3304     case NETDEV_UP:
3305     diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
3306     index 31cf54d18221..45dbdab915e2 100644
3307     --- a/net/ipv4/inet_diag.c
3308     +++ b/net/ipv4/inet_diag.c
3309     @@ -961,7 +961,7 @@ next_normal:
3310     ++num;
3311     }
3312    
3313     - if (r->idiag_states & TCPF_TIME_WAIT) {
3314     + if (r->idiag_states & (TCPF_TIME_WAIT | TCPF_FIN_WAIT2)) {
3315     struct inet_timewait_sock *tw;
3316    
3317     inet_twsk_for_each(tw, node,
3318     @@ -971,6 +971,8 @@ next_normal:
3319    
3320     if (num < s_num)
3321     goto next_dying;
3322     + if (!(r->idiag_states & (1 << tw->tw_substate)))
3323     + goto next_dying;
3324     if (r->sdiag_family != AF_UNSPEC &&
3325     tw->tw_family != r->sdiag_family)
3326     goto next_dying;
3327     diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
3328     index 15e3e683adec..0a22bb0ce1a8 100644
3329     --- a/net/ipv4/ip_input.c
3330     +++ b/net/ipv4/ip_input.c
3331     @@ -313,7 +313,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
3332     const struct iphdr *iph = ip_hdr(skb);
3333     struct rtable *rt;
3334    
3335     - if (sysctl_ip_early_demux && !skb_dst(skb)) {
3336     + if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
3337     const struct net_protocol *ipprot;
3338     int protocol = iph->protocol;
3339    
3340     diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
3341     index 46dcf32c012e..fa6573264c8a 100644
3342     --- a/net/ipv4/ip_tunnel.c
3343     +++ b/net/ipv4/ip_tunnel.c
3344     @@ -636,6 +636,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
3345     tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
3346     tunnel->err_count--;
3347    
3348     + memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
3349     dst_link_failure(skb);
3350     } else
3351     tunnel->err_count = 0;
3352     diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
3353     index 2c581da1fcab..7dbad6835843 100644
3354     --- a/net/ipv4/ipmr.c
3355     +++ b/net/ipv4/ipmr.c
3356     @@ -157,9 +157,12 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)
3357     static int ipmr_fib_lookup(struct net *net, struct flowi4 *flp4,
3358     struct mr_table **mrt)
3359     {
3360     - struct ipmr_result res;
3361     - struct fib_lookup_arg arg = { .result = &res, };
3362     int err;
3363     + struct ipmr_result res;
3364     + struct fib_lookup_arg arg = {
3365     + .result = &res,
3366     + .flags = FIB_LOOKUP_NOREF,
3367     + };
3368    
3369     err = fib_rules_lookup(net->ipv4.mr_rules_ops,
3370     flowi4_to_flowi(flp4), 0, &arg);
3371     diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
3372     index 306dbd9a9441..b500d2ddc476 100644
3373     --- a/net/ipv4/tcp_metrics.c
3374     +++ b/net/ipv4/tcp_metrics.c
3375     @@ -22,6 +22,9 @@
3376    
3377     int sysctl_tcp_nometrics_save __read_mostly;
3378    
3379     +static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *addr,
3380     + struct net *net, unsigned int hash);
3381     +
3382     struct tcp_fastopen_metrics {
3383     u16 mss;
3384     u16 syn_loss:10; /* Recurring Fast Open SYN losses */
3385     @@ -130,16 +133,41 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst,
3386     }
3387     }
3388    
3389     +#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
3390     +
3391     +static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
3392     +{
3393     + if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
3394     + tcpm_suck_dst(tm, dst, false);
3395     +}
3396     +
3397     +#define TCP_METRICS_RECLAIM_DEPTH 5
3398     +#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
3399     +
3400     static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
3401     struct inetpeer_addr *addr,
3402     - unsigned int hash,
3403     - bool reclaim)
3404     + unsigned int hash)
3405     {
3406     struct tcp_metrics_block *tm;
3407     struct net *net;
3408     + bool reclaim = false;
3409    
3410     spin_lock_bh(&tcp_metrics_lock);
3411     net = dev_net(dst->dev);
3412     +
3413     + /* While waiting for the spin-lock the cache might have been populated
3414     + * with this entry and so we have to check again.
3415     + */
3416     + tm = __tcp_get_metrics(addr, net, hash);
3417     + if (tm == TCP_METRICS_RECLAIM_PTR) {
3418     + reclaim = true;
3419     + tm = NULL;
3420     + }
3421     + if (tm) {
3422     + tcpm_check_stamp(tm, dst);
3423     + goto out_unlock;
3424     + }
3425     +
3426     if (unlikely(reclaim)) {
3427     struct tcp_metrics_block *oldest;
3428    
3429     @@ -169,17 +197,6 @@ out_unlock:
3430     return tm;
3431     }
3432    
3433     -#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
3434     -
3435     -static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
3436     -{
3437     - if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
3438     - tcpm_suck_dst(tm, dst, false);
3439     -}
3440     -
3441     -#define TCP_METRICS_RECLAIM_DEPTH 5
3442     -#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
3443     -
3444     static struct tcp_metrics_block *tcp_get_encode(struct tcp_metrics_block *tm, int depth)
3445     {
3446     if (tm)
3447     @@ -280,7 +297,6 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
3448     struct inetpeer_addr addr;
3449     unsigned int hash;
3450     struct net *net;
3451     - bool reclaim;
3452    
3453     addr.family = sk->sk_family;
3454     switch (addr.family) {
3455     @@ -300,13 +316,10 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
3456     hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
3457    
3458     tm = __tcp_get_metrics(&addr, net, hash);
3459     - reclaim = false;
3460     - if (tm == TCP_METRICS_RECLAIM_PTR) {
3461     - reclaim = true;
3462     + if (tm == TCP_METRICS_RECLAIM_PTR)
3463     tm = NULL;
3464     - }
3465     if (!tm && create)
3466     - tm = tcpm_new(dst, &addr, hash, reclaim);
3467     + tm = tcpm_new(dst, &addr, hash);
3468     else
3469     tcpm_check_stamp(tm, dst);
3470    
3471     diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
3472     index 2bab2aa59745..774b09cb2920 100644
3473     --- a/net/ipv6/ip6_input.c
3474     +++ b/net/ipv6/ip6_input.c
3475     @@ -49,7 +49,7 @@
3476    
3477     int ip6_rcv_finish(struct sk_buff *skb)
3478     {
3479     - if (sysctl_ip_early_demux && !skb_dst(skb)) {
3480     + if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
3481     const struct inet6_protocol *ipprot;
3482    
3483     ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
3484     diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
3485     index 209bb4d6e188..f21cf476b00c 100644
3486     --- a/net/ipv6/ip6_tunnel.c
3487     +++ b/net/ipv6/ip6_tunnel.c
3488     @@ -1617,6 +1617,15 @@ static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[],
3489     return ip6_tnl_update(t, &p);
3490     }
3491    
3492     +static void ip6_tnl_dellink(struct net_device *dev, struct list_head *head)
3493     +{
3494     + struct net *net = dev_net(dev);
3495     + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
3496     +
3497     + if (dev != ip6n->fb_tnl_dev)
3498     + unregister_netdevice_queue(dev, head);
3499     +}
3500     +
3501     static size_t ip6_tnl_get_size(const struct net_device *dev)
3502     {
3503     return
3504     @@ -1681,6 +1690,7 @@ static struct rtnl_link_ops ip6_link_ops __read_mostly = {
3505     .validate = ip6_tnl_validate,
3506     .newlink = ip6_tnl_newlink,
3507     .changelink = ip6_tnl_changelink,
3508     + .dellink = ip6_tnl_dellink,
3509     .get_size = ip6_tnl_get_size,
3510     .fill_info = ip6_tnl_fill_info,
3511     };
3512     @@ -1711,6 +1721,8 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
3513     }
3514     }
3515    
3516     + t = rtnl_dereference(ip6n->tnls_wc[0]);
3517     + unregister_netdevice_queue(t->dev, &list);
3518     unregister_netdevice_many(&list);
3519     }
3520    
3521     diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
3522     index 4b421249532f..9f44ebc17759 100644
3523     --- a/net/ipv6/ip6mr.c
3524     +++ b/net/ipv6/ip6mr.c
3525     @@ -141,9 +141,12 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
3526     static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
3527     struct mr6_table **mrt)
3528     {
3529     - struct ip6mr_result res;
3530     - struct fib_lookup_arg arg = { .result = &res, };
3531     int err;
3532     + struct ip6mr_result res;
3533     + struct fib_lookup_arg arg = {
3534     + .result = &res,
3535     + .flags = FIB_LOOKUP_NOREF,
3536     + };
3537    
3538     err = fib_rules_lookup(net->ipv6.mr6_rules_ops,
3539     flowi6_to_flowi(flp6), 0, &arg);
3540     diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
3541     index 0491264b8bfc..620d326e8fdd 100644
3542     --- a/net/ipv6/sit.c
3543     +++ b/net/ipv6/sit.c
3544     @@ -1507,6 +1507,15 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
3545     #endif
3546     };
3547    
3548     +static void ipip6_dellink(struct net_device *dev, struct list_head *head)
3549     +{
3550     + struct net *net = dev_net(dev);
3551     + struct sit_net *sitn = net_generic(net, sit_net_id);
3552     +
3553     + if (dev != sitn->fb_tunnel_dev)
3554     + unregister_netdevice_queue(dev, head);
3555     +}
3556     +
3557     static struct rtnl_link_ops sit_link_ops __read_mostly = {
3558     .kind = "sit",
3559     .maxtype = IFLA_IPTUN_MAX,
3560     @@ -1517,6 +1526,7 @@ static struct rtnl_link_ops sit_link_ops __read_mostly = {
3561     .changelink = ipip6_changelink,
3562     .get_size = ipip6_get_size,
3563     .fill_info = ipip6_fill_info,
3564     + .dellink = ipip6_dellink,
3565     };
3566    
3567     static struct xfrm_tunnel sit_handler __read_mostly = {
3568     diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
3569     index 8eb9501e3d60..b7ebe23cdedf 100644
3570     --- a/net/rds/ib_recv.c
3571     +++ b/net/rds/ib_recv.c
3572     @@ -421,8 +421,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
3573     struct rds_ib_refill_cache *cache)
3574     {
3575     unsigned long flags;
3576     - struct list_head *old;
3577     - struct list_head __percpu *chpfirst;
3578     + struct list_head *old, *chpfirst;
3579    
3580     local_irq_save(flags);
3581    
3582     @@ -432,7 +431,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
3583     else /* put on front */
3584     list_add_tail(new_item, chpfirst);
3585    
3586     - __this_cpu_write(chpfirst, new_item);
3587     + __this_cpu_write(cache->percpu->first, new_item);
3588     __this_cpu_inc(cache->percpu->count);
3589    
3590     if (__this_cpu_read(cache->percpu->count) < RDS_IB_RECYCLE_BATCH_COUNT)
3591     @@ -452,7 +451,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
3592     } while (old);
3593    
3594    
3595     - __this_cpu_write(chpfirst, NULL);
3596     + __this_cpu_write(cache->percpu->first, NULL);
3597     __this_cpu_write(cache->percpu->count, 0);
3598     end:
3599     local_irq_restore(flags);
3600     diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
3601     index fe6fa93a6262..daac7c7ebe9e 100644
3602     --- a/sound/pci/Kconfig
3603     +++ b/sound/pci/Kconfig
3604     @@ -30,6 +30,7 @@ config SND_ALS300
3605     select SND_PCM
3606     select SND_AC97_CODEC
3607     select SND_OPL3_LIB
3608     + select ZONE_DMA
3609     help
3610     Say 'Y' or 'M' to include support for Avance Logic ALS300/ALS300+
3611    
3612     @@ -54,6 +55,7 @@ config SND_ALI5451
3613     tristate "ALi M5451 PCI Audio Controller"
3614     select SND_MPU401_UART
3615     select SND_AC97_CODEC
3616     + select ZONE_DMA
3617     help
3618     Say Y here to include support for the integrated AC97 sound
3619     device on motherboards using the ALi M5451 Audio Controller
3620     @@ -158,6 +160,7 @@ config SND_AZT3328
3621     select SND_PCM
3622     select SND_RAWMIDI
3623     select SND_AC97_CODEC
3624     + select ZONE_DMA
3625     help
3626     Say Y here to include support for Aztech AZF3328 (PCI168)
3627     soundcards.
3628     @@ -463,6 +466,7 @@ config SND_EMU10K1
3629     select SND_HWDEP
3630     select SND_RAWMIDI
3631     select SND_AC97_CODEC
3632     + select ZONE_DMA
3633     help
3634     Say Y to include support for Sound Blaster PCI 512, Live!,
3635     Audigy and E-mu APS (partially supported) soundcards.
3636     @@ -478,6 +482,7 @@ config SND_EMU10K1X
3637     tristate "Emu10k1X (Dell OEM Version)"
3638     select SND_AC97_CODEC
3639     select SND_RAWMIDI
3640     + select ZONE_DMA
3641     help
3642     Say Y here to include support for the Dell OEM version of the
3643     Sound Blaster Live!.
3644     @@ -511,6 +516,7 @@ config SND_ES1938
3645     select SND_OPL3_LIB
3646     select SND_MPU401_UART
3647     select SND_AC97_CODEC
3648     + select ZONE_DMA
3649     help
3650     Say Y here to include support for soundcards based on ESS Solo-1
3651     (ES1938, ES1946, ES1969) chips.
3652     @@ -522,6 +528,7 @@ config SND_ES1968
3653     tristate "ESS ES1968/1978 (Maestro-1/2/2E)"
3654     select SND_MPU401_UART
3655     select SND_AC97_CODEC
3656     + select ZONE_DMA
3657     help
3658     Say Y here to include support for soundcards based on ESS Maestro
3659     1/2/2E chips.
3660     @@ -603,6 +610,7 @@ config SND_ICE1712
3661     select SND_MPU401_UART
3662     select SND_AC97_CODEC
3663     select BITREVERSE
3664     + select ZONE_DMA
3665     help
3666     Say Y here to include support for soundcards based on the
3667     ICE1712 (Envy24) chip.
3668     @@ -690,6 +698,7 @@ config SND_LX6464ES
3669     config SND_MAESTRO3
3670     tristate "ESS Allegro/Maestro3"
3671     select SND_AC97_CODEC
3672     + select ZONE_DMA
3673     help
3674     Say Y here to include support for soundcards based on ESS Maestro 3
3675     (Allegro) chips.
3676     @@ -786,6 +795,7 @@ config SND_SIS7019
3677     tristate "SiS 7019 Audio Accelerator"
3678     depends on X86 && !X86_64
3679     select SND_AC97_CODEC
3680     + select ZONE_DMA
3681     help
3682     Say Y here to include support for the SiS 7019 Audio Accelerator.
3683    
3684     @@ -797,6 +807,7 @@ config SND_SONICVIBES
3685     select SND_OPL3_LIB
3686     select SND_MPU401_UART
3687     select SND_AC97_CODEC
3688     + select ZONE_DMA
3689     help
3690     Say Y here to include support for soundcards based on the S3
3691     SonicVibes chip.
3692     @@ -808,6 +819,7 @@ config SND_TRIDENT
3693     tristate "Trident 4D-Wave DX/NX; SiS 7018"
3694     select SND_MPU401_UART
3695     select SND_AC97_CODEC
3696     + select ZONE_DMA
3697     help
3698     Say Y here to include support for soundcards based on Trident
3699     4D-Wave DX/NX or SiS 7018 chips.
3700     diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
3701     index 8536266e4004..cb4d3700f330 100644
3702     --- a/sound/pci/hda/hda_generic.c
3703     +++ b/sound/pci/hda/hda_generic.c
3704     @@ -2796,9 +2796,11 @@ static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid,
3705     if (num_conns < idx)
3706     return false;
3707     nid = list[idx];
3708     - if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT))
3709     + if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT) &&
3710     + !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_VOL_CTL))
3711     *mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3712     - if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT))
3713     + if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT) &&
3714     + !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_MUTE_CTL))
3715     *mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3716    
3717     return *mix_val || *mute_val;
3718     diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
3719     index 8c1d1cf0c0cd..ba442d24257a 100644
3720     --- a/sound/pci/hda/patch_hdmi.c
3721     +++ b/sound/pci/hda/patch_hdmi.c
3722     @@ -86,6 +86,9 @@ struct hdmi_spec {
3723     unsigned int channels_max; /* max over all cvts */
3724    
3725     struct hdmi_eld temp_eld;
3726     +
3727     + bool dyn_pin_out;
3728     +
3729     /*
3730     * Non-generic ATI/NVIDIA specific
3731     */
3732     @@ -450,15 +453,25 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
3733    
3734     static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
3735     {
3736     + struct hdmi_spec *spec = codec->spec;
3737     + int pin_out;
3738     +
3739     /* Unmute */
3740     if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
3741     snd_hda_codec_write(codec, pin_nid, 0,
3742     AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3743     - /* Enable pin out: some machines with GM965 gets broken output when
3744     - * the pin is disabled or changed while using with HDMI
3745     - */
3746     +
3747     + if (spec->dyn_pin_out)
3748     + /* Disable pin out until stream is active */
3749     + pin_out = 0;
3750     + else
3751     + /* Enable pin out: some machines with GM965 gets broken output
3752     + * when the pin is disabled or changed while using with HDMI
3753     + */
3754     + pin_out = PIN_OUT;
3755     +
3756     snd_hda_codec_write(codec, pin_nid, 0,
3757     - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3758     + AC_VERB_SET_PIN_WIDGET_CONTROL, pin_out);
3759     }
3760    
3761     static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid)
3762     @@ -1473,6 +1486,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3763     struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
3764     hda_nid_t pin_nid = per_pin->pin_nid;
3765     bool non_pcm;
3766     + int pinctl;
3767    
3768     non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
3769     per_pin->channels = substream->runtime->channels;
3770     @@ -1482,6 +1496,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3771    
3772     hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
3773    
3774     + if (spec->dyn_pin_out) {
3775     + pinctl = snd_hda_codec_read(codec, pin_nid, 0,
3776     + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3777     + snd_hda_codec_write(codec, pin_nid, 0,
3778     + AC_VERB_SET_PIN_WIDGET_CONTROL,
3779     + pinctl | PIN_OUT);
3780     + }
3781     +
3782     return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
3783     }
3784    
3785     @@ -1501,6 +1523,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
3786     int cvt_idx, pin_idx;
3787     struct hdmi_spec_per_cvt *per_cvt;
3788     struct hdmi_spec_per_pin *per_pin;
3789     + int pinctl;
3790    
3791     if (hinfo->nid) {
3792     cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid);
3793     @@ -1517,6 +1540,14 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
3794     return -EINVAL;
3795     per_pin = get_pin(spec, pin_idx);
3796    
3797     + if (spec->dyn_pin_out) {
3798     + pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
3799     + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3800     + snd_hda_codec_write(codec, per_pin->pin_nid, 0,
3801     + AC_VERB_SET_PIN_WIDGET_CONTROL,
3802     + pinctl & ~PIN_OUT);
3803     + }
3804     +
3805     snd_hda_spdif_ctls_unassign(codec, pin_idx);
3806     per_pin->chmap_set = false;
3807     memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
3808     @@ -2476,6 +2507,21 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
3809     return 0;
3810     }
3811    
3812     +static int patch_nvhdmi(struct hda_codec *codec)
3813     +{
3814     + struct hdmi_spec *spec;
3815     + int err;
3816     +
3817     + err = patch_generic_hdmi(codec);
3818     + if (err)
3819     + return err;
3820     +
3821     + spec = codec->spec;
3822     + spec->dyn_pin_out = true;
3823     +
3824     + return 0;
3825     +}
3826     +
3827     /*
3828     * ATI-specific implementations
3829     *
3830     @@ -2548,30 +2594,30 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
3831     { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
3832     { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
3833     { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
3834     -{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_generic_hdmi },
3835     -{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_generic_hdmi },
3836     -{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_generic_hdmi },
3837     -{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_generic_hdmi },
3838     -{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_generic_hdmi },
3839     -{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_generic_hdmi },
3840     -{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_generic_hdmi },
3841     -{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_generic_hdmi },
3842     -{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_generic_hdmi },
3843     -{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_generic_hdmi },
3844     -{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_generic_hdmi },
3845     +{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi },
3846     +{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi },
3847     +{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi },
3848     +{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi },
3849     +{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi },
3850     +{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi },
3851     +{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi },
3852     +{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi },
3853     +{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi },
3854     +{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_nvhdmi },
3855     +{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_nvhdmi },
3856     /* 17 is known to be absent */
3857     -{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_generic_hdmi },
3858     -{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_generic_hdmi },
3859     -{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_generic_hdmi },
3860     -{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_generic_hdmi },
3861     -{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_generic_hdmi },
3862     -{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_generic_hdmi },
3863     -{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_generic_hdmi },
3864     -{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_generic_hdmi },
3865     -{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi },
3866     -{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi },
3867     -{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi },
3868     -{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi },
3869     +{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi },
3870     +{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi },
3871     +{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi },
3872     +{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi },
3873     +{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi },
3874     +{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi },
3875     +{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi },
3876     +{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi },
3877     +{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi },
3878     +{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi },
3879     +{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi },
3880     +{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi },
3881     { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
3882     { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
3883     { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
3884     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3885     index 937079a5265a..4b06e0a64392 100644
3886     --- a/sound/pci/hda/patch_realtek.c
3887     +++ b/sound/pci/hda/patch_realtek.c
3888     @@ -1763,6 +1763,7 @@ enum {
3889     ALC889_FIXUP_DAC_ROUTE,
3890     ALC889_FIXUP_MBP_VREF,
3891     ALC889_FIXUP_IMAC91_VREF,
3892     + ALC889_FIXUP_MBA11_VREF,
3893     ALC889_FIXUP_MBA21_VREF,
3894     ALC882_FIXUP_INV_DMIC,
3895     ALC882_FIXUP_NO_PRIMARY_HP,
3896     @@ -1892,6 +1893,16 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec,
3897     alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
3898     }
3899    
3900     +/* Set VREF on speaker pins on mba11 */
3901     +static void alc889_fixup_mba11_vref(struct hda_codec *codec,
3902     + const struct hda_fixup *fix, int action)
3903     +{
3904     + static hda_nid_t nids[1] = { 0x18 };
3905     +
3906     + if (action == HDA_FIXUP_ACT_INIT)
3907     + alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
3908     +}
3909     +
3910     /* Set VREF on speaker pins on mba21 */
3911     static void alc889_fixup_mba21_vref(struct hda_codec *codec,
3912     const struct hda_fixup *fix, int action)
3913     @@ -2096,6 +2107,12 @@ static const struct hda_fixup alc882_fixups[] = {
3914     .chained = true,
3915     .chain_id = ALC882_FIXUP_GPIO1,
3916     },
3917     + [ALC889_FIXUP_MBA11_VREF] = {
3918     + .type = HDA_FIXUP_FUNC,
3919     + .v.func = alc889_fixup_mba11_vref,
3920     + .chained = true,
3921     + .chain_id = ALC889_FIXUP_MBP_VREF,
3922     + },
3923     [ALC889_FIXUP_MBA21_VREF] = {
3924     .type = HDA_FIXUP_FUNC,
3925     .v.func = alc889_fixup_mba21_vref,
3926     @@ -2165,7 +2182,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
3927     SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
3928     SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
3929     SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
3930     - SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
3931     + SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
3932     SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
3933     SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
3934     SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
3935     diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
3936     index 773a67fff4cd..431bf6897dd6 100644
3937     --- a/sound/pci/rme9652/rme9652.c
3938     +++ b/sound/pci/rme9652/rme9652.c
3939     @@ -285,7 +285,7 @@ static char channel_map_9636_ds[26] = {
3940     /* ADAT channels are remapped */
3941     1, 3, 5, 7, 9, 11, 13, 15,
3942     /* channels 8 and 9 are S/PDIF */
3943     - 24, 25
3944     + 24, 25,
3945     /* others don't exist */
3946     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
3947     };
3948     diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
3949     index dafdbe87edeb..0c499c638692 100644
3950     --- a/sound/soc/codecs/adau1701.c
3951     +++ b/sound/soc/codecs/adau1701.c
3952     @@ -64,7 +64,7 @@
3953    
3954     #define ADAU1701_SEROCTL_WORD_LEN_24 0x0000
3955     #define ADAU1701_SEROCTL_WORD_LEN_20 0x0001
3956     -#define ADAU1701_SEROCTL_WORD_LEN_16 0x0010
3957     +#define ADAU1701_SEROCTL_WORD_LEN_16 0x0002
3958     #define ADAU1701_SEROCTL_WORD_LEN_MASK 0x0003
3959    
3960     #define ADAU1701_AUXNPOW_VBPD 0x40
3961     diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
3962     index 866b9c657e15..3775394c9c8b 100644
3963     --- a/sound/soc/codecs/wm5110.c
3964     +++ b/sound/soc/codecs/wm5110.c
3965     @@ -43,6 +43,54 @@ static const struct reg_default wm5110_sysclk_revd_patch[] = {
3966     { 0x3133, 0x1201 },
3967     { 0x3183, 0x1501 },
3968     { 0x31D3, 0x1401 },
3969     + { 0x0049, 0x01ea },
3970     + { 0x004a, 0x01f2 },
3971     + { 0x0057, 0x01e7 },
3972     + { 0x0058, 0x01fb },
3973     + { 0x33ce, 0xc4f5 },
3974     + { 0x33cf, 0x1361 },
3975     + { 0x33d0, 0x0402 },
3976     + { 0x33d1, 0x4700 },
3977     + { 0x33d2, 0x026d },
3978     + { 0x33d3, 0xff00 },
3979     + { 0x33d4, 0x026d },
3980     + { 0x33d5, 0x0101 },
3981     + { 0x33d6, 0xc4f5 },
3982     + { 0x33d7, 0x0361 },
3983     + { 0x33d8, 0x0402 },
3984     + { 0x33d9, 0x6701 },
3985     + { 0x33da, 0xc4f5 },
3986     + { 0x33db, 0x136f },
3987     + { 0x33dc, 0xc4f5 },
3988     + { 0x33dd, 0x134f },
3989     + { 0x33de, 0xc4f5 },
3990     + { 0x33df, 0x131f },
3991     + { 0x33e0, 0x026d },
3992     + { 0x33e1, 0x4f01 },
3993     + { 0x33e2, 0x026d },
3994     + { 0x33e3, 0xf100 },
3995     + { 0x33e4, 0x026d },
3996     + { 0x33e5, 0x0001 },
3997     + { 0x33e6, 0xc4f5 },
3998     + { 0x33e7, 0x0361 },
3999     + { 0x33e8, 0x0402 },
4000     + { 0x33e9, 0x6601 },
4001     + { 0x33ea, 0xc4f5 },
4002     + { 0x33eb, 0x136f },
4003     + { 0x33ec, 0xc4f5 },
4004     + { 0x33ed, 0x134f },
4005     + { 0x33ee, 0xc4f5 },
4006     + { 0x33ef, 0x131f },
4007     + { 0x33f0, 0x026d },
4008     + { 0x33f1, 0x4e01 },
4009     + { 0x33f2, 0x026d },
4010     + { 0x33f3, 0xf000 },
4011     + { 0x33f6, 0xc4f5 },
4012     + { 0x33f7, 0x1361 },
4013     + { 0x33f8, 0x0402 },
4014     + { 0x33f9, 0x4600 },
4015     + { 0x33fa, 0x026d },
4016     + { 0x33fb, 0xfe00 },
4017     };
4018    
4019     static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
4020     diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
4021     index cf1fe01b7e89..e392202b96bc 100644
4022     --- a/tools/perf/util/session.c
4023     +++ b/tools/perf/util/session.c
4024     @@ -811,6 +811,7 @@ static struct machine *
4025     union perf_event *event)
4026     {
4027     const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
4028     + struct machine *machine;
4029    
4030     if (perf_guest &&
4031     ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
4032     @@ -822,7 +823,11 @@ static struct machine *
4033     else
4034     pid = event->ip.pid;
4035    
4036     - return perf_session__findnew_machine(session, pid);
4037     + machine = perf_session__find_machine(session, pid);
4038     + if (!machine)
4039     + machine = perf_session__findnew_machine(session,
4040     + DEFAULT_GUEST_KERNEL_ID);
4041     + return machine;
4042     }
4043    
4044     return &session->machines.host;