Gentoo Archives: gentoo-commits

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