Magellan Linux

Annotation of /trunk/kernel-alx/patches-3.12/0109-3.12.10-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2423 - (hide annotations) (download)
Tue Mar 25 12:29:50 2014 UTC (10 years, 2 months ago) by niro
File size: 181364 byte(s)
-added 3.12 branch
1 niro 2423 diff --git a/Documentation/devicetree/bindings/ata/marvell.txt b/Documentation/devicetree/bindings/ata/marvell.txt
2     index b5cdd20cde9c..1c8351604d38 100644
3     --- a/Documentation/devicetree/bindings/ata/marvell.txt
4     +++ b/Documentation/devicetree/bindings/ata/marvell.txt
5     @@ -1,7 +1,7 @@
6     * Marvell Orion SATA
7    
8     Required Properties:
9     -- compatibility : "marvell,orion-sata"
10     +- compatibility : "marvell,orion-sata" or "marvell,armada-370-sata"
11     - reg : Address range of controller
12     - interrupts : Interrupt controller is using
13     - nr-ports : Number of SATA ports in use.
14     diff --git a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
15     index 82e8f6f17179..582b4652a82a 100644
16     --- a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
17     +++ b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
18     @@ -5,7 +5,11 @@ Required properties :
19    
20     - reg : Offset and length of the register set for the device
21     - compatible : Should be "marvell,mv64xxx-i2c" or "allwinner,sun4i-i2c"
22     - or "marvell,mv78230-i2c"
23     + or "marvell,mv78230-i2c" or "marvell,mv78230-a0-i2c"
24     + Note: Only use "marvell,mv78230-a0-i2c" for a very rare,
25     + initial version of the SoC which had broken offload
26     + support. Linux auto-detects this and sets it
27     + appropriately.
28     - interrupts : The interrupt number
29    
30     Optional properties :
31     diff --git a/Documentation/i2c/busses/i2c-piix4 b/Documentation/i2c/busses/i2c-piix4
32     index c097e0f020fe..aa959fd22450 100644
33     --- a/Documentation/i2c/busses/i2c-piix4
34     +++ b/Documentation/i2c/busses/i2c-piix4
35     @@ -13,7 +13,7 @@ Supported adapters:
36     * AMD SP5100 (SB700 derivative found on some server mainboards)
37     Datasheet: Publicly available at the AMD website
38     http://support.amd.com/us/Embedded_TechDocs/44413.pdf
39     - * AMD Hudson-2, CZ
40     + * AMD Hudson-2, ML, CZ
41     Datasheet: Not publicly available
42     * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
43     Datasheet: Publicly available at the SMSC website http://www.smsc.com
44     diff --git a/Makefile b/Makefile
45     index 4ee77eaa7b1f..49b64402f947 100644
46     --- a/Makefile
47     +++ b/Makefile
48     @@ -1,6 +1,6 @@
49     VERSION = 3
50     PATCHLEVEL = 12
51     -SUBLEVEL = 9
52     +SUBLEVEL = 10
53     EXTRAVERSION =
54     NAME = One Giant Leap for Frogkind
55    
56     diff --git a/arch/alpha/lib/csum_partial_copy.c b/arch/alpha/lib/csum_partial_copy.c
57     index ffb19b7da999..9df43dfe511e 100644
58     --- a/arch/alpha/lib/csum_partial_copy.c
59     +++ b/arch/alpha/lib/csum_partial_copy.c
60     @@ -378,6 +378,11 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
61     __wsum
62     csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
63     {
64     - return csum_partial_copy_from_user((__force const void __user *)src,
65     - dst, len, sum, NULL);
66     + __wsum checksum;
67     + mm_segment_t oldfs = get_fs();
68     + set_fs(KERNEL_DS);
69     + checksum = csum_partial_copy_from_user((__force const void __user *)src,
70     + dst, len, sum, NULL);
71     + set_fs(oldfs);
72     + return checksum;
73     }
74     diff --git a/arch/arm/boot/dts/armada-370-xp.dtsi b/arch/arm/boot/dts/armada-370-xp.dtsi
75     index b97ab017d4a2..364a63dce6c5 100644
76     --- a/arch/arm/boot/dts/armada-370-xp.dtsi
77     +++ b/arch/arm/boot/dts/armada-370-xp.dtsi
78     @@ -143,7 +143,7 @@
79     };
80    
81     sata@a0000 {
82     - compatible = "marvell,orion-sata";
83     + compatible = "marvell,armada-370-sata";
84     reg = <0xa0000 0x5000>;
85     interrupts = <55>;
86     clocks = <&gateclk 15>, <&gateclk 30>;
87     diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
88     index c3e514837074..cf7de80377f1 100644
89     --- a/arch/arm/boot/dts/at91sam9g45.dtsi
90     +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
91     @@ -618,6 +618,7 @@
92     compatible = "atmel,hsmci";
93     reg = <0xfff80000 0x600>;
94     interrupts = <11 IRQ_TYPE_LEVEL_HIGH 0>;
95     + pinctrl-names = "default";
96     dmas = <&dma 1 AT91_DMA_CFG_PER_ID(0)>;
97     dma-names = "rxtx";
98     #address-cells = <1>;
99     @@ -629,6 +630,7 @@
100     compatible = "atmel,hsmci";
101     reg = <0xfffd0000 0x600>;
102     interrupts = <29 IRQ_TYPE_LEVEL_HIGH 0>;
103     + pinctrl-names = "default";
104     dmas = <&dma 1 AT91_DMA_CFG_PER_ID(13)>;
105     dma-names = "rxtx";
106     #address-cells = <1>;
107     diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c
108     index 99a0a1d2b7dc..b26156bf15db 100644
109     --- a/arch/arm/mach-at91/sam9_smc.c
110     +++ b/arch/arm/mach-at91/sam9_smc.c
111     @@ -101,7 +101,7 @@ static void sam9_smc_cs_read(void __iomem *base,
112     /* Pulse register */
113     val = __raw_readl(base + AT91_SMC_PULSE);
114    
115     - config->nwe_setup = val & AT91_SMC_NWEPULSE;
116     + config->nwe_pulse = val & AT91_SMC_NWEPULSE;
117     config->ncs_write_pulse = (val & AT91_SMC_NCS_WRPULSE) >> 8;
118     config->nrd_pulse = (val & AT91_SMC_NRDPULSE) >> 16;
119     config->ncs_read_pulse = (val & AT91_SMC_NCS_RDPULSE) >> 24;
120     diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
121     index 2d04f0e21870..878aebe98dcc 100644
122     --- a/arch/arm/mach-mvebu/Makefile
123     +++ b/arch/arm/mach-mvebu/Makefile
124     @@ -3,7 +3,7 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \
125    
126     AFLAGS_coherency_ll.o := -Wa,-march=armv7-a
127    
128     -obj-y += system-controller.o
129     +obj-y += system-controller.o mvebu-soc-id.o
130     obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o
131     obj-$(CONFIG_ARCH_MVEBU) += coherency.o coherency_ll.o pmsu.o
132     obj-$(CONFIG_SMP) += platsmp.o headsmp.o
133     diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
134     index e2acff98e750..f6c9d1d85c14 100644
135     --- a/arch/arm/mach-mvebu/armada-370-xp.c
136     +++ b/arch/arm/mach-mvebu/armada-370-xp.c
137     @@ -21,6 +21,7 @@
138     #include <linux/clocksource.h>
139     #include <linux/dma-mapping.h>
140     #include <linux/mbus.h>
141     +#include <linux/slab.h>
142     #include <asm/hardware/cache-l2x0.h>
143     #include <asm/mach/arch.h>
144     #include <asm/mach/map.h>
145     @@ -28,6 +29,7 @@
146     #include "armada-370-xp.h"
147     #include "common.h"
148     #include "coherency.h"
149     +#include "mvebu-soc-id.h"
150    
151     static void __init armada_370_xp_map_io(void)
152     {
153     @@ -45,8 +47,38 @@ static void __init armada_370_xp_timer_and_clk_init(void)
154     #endif
155     }
156    
157     +static void __init i2c_quirk(void)
158     +{
159     + struct device_node *np;
160     + u32 dev, rev;
161     +
162     + /*
163     + * Only revisons more recent than A0 support the offload
164     + * mechanism. We can exit only if we are sure that we can
165     + * get the SoC revision and it is more recent than A0.
166     + */
167     + if (mvebu_get_soc_id(&rev, &dev) == 0 && dev > MV78XX0_A0_REV)
168     + return;
169     +
170     + for_each_compatible_node(np, NULL, "marvell,mv78230-i2c") {
171     + struct property *new_compat;
172     +
173     + new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
174     +
175     + new_compat->name = kstrdup("compatible", GFP_KERNEL);
176     + new_compat->length = sizeof("marvell,mv78230-a0-i2c");
177     + new_compat->value = kstrdup("marvell,mv78230-a0-i2c",
178     + GFP_KERNEL);
179     +
180     + of_update_property(np, new_compat);
181     + }
182     + return;
183     +}
184     +
185     static void __init armada_370_xp_dt_init(void)
186     {
187     + if (of_machine_is_compatible("plathome,openblocks-ax3-4"))
188     + i2c_quirk();
189     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
190     }
191    
192     diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.c b/arch/arm/mach-mvebu/mvebu-soc-id.c
193     new file mode 100644
194     index 000000000000..fe4fc1cbdfaf
195     --- /dev/null
196     +++ b/arch/arm/mach-mvebu/mvebu-soc-id.c
197     @@ -0,0 +1,119 @@
198     +/*
199     + * ID and revision information for mvebu SoCs
200     + *
201     + * Copyright (C) 2014 Marvell
202     + *
203     + * Gregory CLEMENT <gregory.clement@free-electrons.com>
204     + *
205     + * This file is licensed under the terms of the GNU General Public
206     + * License version 2. This program is licensed "as is" without any
207     + * warranty of any kind, whether express or implied.
208     + *
209     + * All the mvebu SoCs have information related to their variant and
210     + * revision that can be read from the PCI control register. This is
211     + * done before the PCI initialization to avoid any conflict. Once the
212     + * ID and revision are retrieved, the mapping is freed.
213     + */
214     +
215     +#define pr_fmt(fmt) "mvebu-soc-id: " fmt
216     +
217     +#include <linux/clk.h>
218     +#include <linux/init.h>
219     +#include <linux/io.h>
220     +#include <linux/kernel.h>
221     +#include <linux/of.h>
222     +#include <linux/of_address.h>
223     +#include "mvebu-soc-id.h"
224     +
225     +#define PCIE_DEV_ID_OFF 0x0
226     +#define PCIE_DEV_REV_OFF 0x8
227     +
228     +#define SOC_ID_MASK 0xFFFF0000
229     +#define SOC_REV_MASK 0xFF
230     +
231     +static u32 soc_dev_id;
232     +static u32 soc_rev;
233     +static bool is_id_valid;
234     +
235     +static const struct of_device_id mvebu_pcie_of_match_table[] = {
236     + { .compatible = "marvell,armada-xp-pcie", },
237     + { .compatible = "marvell,armada-370-pcie", },
238     + {},
239     +};
240     +
241     +int mvebu_get_soc_id(u32 *dev, u32 *rev)
242     +{
243     + if (is_id_valid) {
244     + *dev = soc_dev_id;
245     + *rev = soc_rev;
246     + return 0;
247     + } else
248     + return -1;
249     +}
250     +
251     +static int __init mvebu_soc_id_init(void)
252     +{
253     + struct device_node *np;
254     + int ret = 0;
255     + void __iomem *pci_base;
256     + struct clk *clk;
257     + struct device_node *child;
258     +
259     + np = of_find_matching_node(NULL, mvebu_pcie_of_match_table);
260     + if (!np)
261     + return ret;
262     +
263     + /*
264     + * ID and revision are available from any port, so we
265     + * just pick the first one
266     + */
267     + child = of_get_next_child(np, NULL);
268     + if (child == NULL) {
269     + pr_err("cannot get pci node\n");
270     + ret = -ENOMEM;
271     + goto clk_err;
272     + }
273     +
274     + clk = of_clk_get_by_name(child, NULL);
275     + if (IS_ERR(clk)) {
276     + pr_err("cannot get clock\n");
277     + ret = -ENOMEM;
278     + goto clk_err;
279     + }
280     +
281     + ret = clk_prepare_enable(clk);
282     + if (ret) {
283     + pr_err("cannot enable clock\n");
284     + goto clk_err;
285     + }
286     +
287     + pci_base = of_iomap(child, 0);
288     + if (IS_ERR(pci_base)) {
289     + pr_err("cannot map registers\n");
290     + ret = -ENOMEM;
291     + goto res_ioremap;
292     + }
293     +
294     + /* SoC ID */
295     + soc_dev_id = readl(pci_base + PCIE_DEV_ID_OFF) >> 16;
296     +
297     + /* SoC revision */
298     + soc_rev = readl(pci_base + PCIE_DEV_REV_OFF) & SOC_REV_MASK;
299     +
300     + is_id_valid = true;
301     +
302     + pr_info("MVEBU SoC ID=0x%X, Rev=0x%X\n", soc_dev_id, soc_rev);
303     +
304     + iounmap(pci_base);
305     +
306     +res_ioremap:
307     + clk_disable_unprepare(clk);
308     +
309     +clk_err:
310     + of_node_put(child);
311     + of_node_put(np);
312     +
313     + return ret;
314     +}
315     +core_initcall(mvebu_soc_id_init);
316     +
317     diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.h b/arch/arm/mach-mvebu/mvebu-soc-id.h
318     new file mode 100644
319     index 000000000000..31654252fe35
320     --- /dev/null
321     +++ b/arch/arm/mach-mvebu/mvebu-soc-id.h
322     @@ -0,0 +1,32 @@
323     +/*
324     + * Marvell EBU SoC ID and revision definitions.
325     + *
326     + * Copyright (C) 2014 Marvell Semiconductor
327     + *
328     + * This file is licensed under the terms of the GNU General Public
329     + * License version 2. This program is licensed "as is" without any
330     + * warranty of any kind, whether express or implied.
331     + */
332     +
333     +#ifndef __LINUX_MVEBU_SOC_ID_H
334     +#define __LINUX_MVEBU_SOC_ID_H
335     +
336     +/* Armada XP ID */
337     +#define MV78230_DEV_ID 0x7823
338     +#define MV78260_DEV_ID 0x7826
339     +#define MV78460_DEV_ID 0x7846
340     +
341     +/* Armada XP Revision */
342     +#define MV78XX0_A0_REV 0x1
343     +#define MV78XX0_B0_REV 0x2
344     +
345     +#ifdef CONFIG_ARCH_MVEBU
346     +int mvebu_get_soc_id(u32 *dev, u32 *rev);
347     +#else
348     +static inline int mvebu_get_soc_id(u32 *dev, u32 *rev)
349     +{
350     + return -1;
351     +}
352     +#endif
353     +
354     +#endif /* __LINUX_MVEBU_SOC_ID_H */
355     diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
356     index 99b44e0e8d86..8c9106fd8163 100644
357     --- a/arch/arm/net/bpf_jit_32.c
358     +++ b/arch/arm/net/bpf_jit_32.c
359     @@ -637,10 +637,10 @@ load_ind:
360     emit(ARM_MUL(r_A, r_A, r_X), ctx);
361     break;
362     case BPF_S_ALU_DIV_K:
363     - /* current k == reciprocal_value(userspace k) */
364     + if (k == 1)
365     + break;
366     emit_mov_i(r_scratch, k, ctx);
367     - /* A = top 32 bits of the product */
368     - emit(ARM_UMULL(r_scratch, r_A, r_A, r_scratch), ctx);
369     + emit_udiv(r_A, r_A, r_scratch, ctx);
370     break;
371     case BPF_S_ALU_DIV_X:
372     update_on_xread(ctx);
373     diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h
374     index 2f9b751878ba..de65f66ea64e 100644
375     --- a/arch/parisc/include/asm/cacheflush.h
376     +++ b/arch/parisc/include/asm/cacheflush.h
377     @@ -132,7 +132,6 @@ void mark_rodata_ro(void);
378     static inline void *kmap(struct page *page)
379     {
380     might_sleep();
381     - flush_dcache_page(page);
382     return page_address(page);
383     }
384    
385     @@ -144,7 +143,6 @@ static inline void kunmap(struct page *page)
386     static inline void *kmap_atomic(struct page *page)
387     {
388     pagefault_disable();
389     - flush_dcache_page(page);
390     return page_address(page);
391     }
392    
393     diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
394     index c53fc63149e8..637fe031aa84 100644
395     --- a/arch/parisc/include/asm/page.h
396     +++ b/arch/parisc/include/asm/page.h
397     @@ -29,7 +29,8 @@ struct page;
398     void clear_page_asm(void *page);
399     void copy_page_asm(void *to, void *from);
400     #define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
401     -#define copy_user_page(vto, vfrom, vaddr, page) copy_page_asm(vto, vfrom)
402     +void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
403     + struct page *pg);
404    
405     /* #define CONFIG_PARISC_TMPALIAS */
406    
407     diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
408     index a72545554a31..ac87a40502e6 100644
409     --- a/arch/parisc/kernel/cache.c
410     +++ b/arch/parisc/kernel/cache.c
411     @@ -388,6 +388,20 @@ void flush_kernel_dcache_page_addr(void *addr)
412     }
413     EXPORT_SYMBOL(flush_kernel_dcache_page_addr);
414    
415     +void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
416     + struct page *pg)
417     +{
418     + /* Copy using kernel mapping. No coherency is needed (all in
419     + kunmap) for the `to' page. However, the `from' page needs to
420     + be flushed through a mapping equivalent to the user mapping
421     + before it can be accessed through the kernel mapping. */
422     + preempt_disable();
423     + flush_dcache_page_asm(__pa(vfrom), vaddr);
424     + preempt_enable();
425     + copy_page_asm(vto, vfrom);
426     +}
427     +EXPORT_SYMBOL(copy_user_page);
428     +
429     void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
430     {
431     unsigned long flags;
432     diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
433     index 89e3ef2496ac..d0b5fca6b077 100644
434     --- a/arch/powerpc/include/asm/topology.h
435     +++ b/arch/powerpc/include/asm/topology.h
436     @@ -22,7 +22,15 @@ struct device_node;
437    
438     static inline int cpu_to_node(int cpu)
439     {
440     - return numa_cpu_lookup_table[cpu];
441     + int nid;
442     +
443     + nid = numa_cpu_lookup_table[cpu];
444     +
445     + /*
446     + * During early boot, the numa-cpu lookup table might not have been
447     + * setup for all CPUs yet. In such cases, default to node 0.
448     + */
449     + return (nid < 0) ? 0 : nid;
450     }
451    
452     #define parent_node(node) (node)
453     diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
454     index 654932727873..bfb82365bc7a 100644
455     --- a/arch/powerpc/kernel/cacheinfo.c
456     +++ b/arch/powerpc/kernel/cacheinfo.c
457     @@ -794,6 +794,9 @@ static void remove_cache_dir(struct cache_dir *cache_dir)
458     {
459     remove_index_dirs(cache_dir);
460    
461     + /* Remove cache dir from sysfs */
462     + kobject_del(cache_dir->kobj);
463     +
464     kobject_put(cache_dir->kobj);
465    
466     kfree(cache_dir);
467     diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
468     index 62a2b5ab08ed..e1ab62e0d548 100644
469     --- a/arch/powerpc/kvm/book3s_hv.c
470     +++ b/arch/powerpc/kvm/book3s_hv.c
471     @@ -82,10 +82,13 @@ void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu)
472    
473     /* CPU points to the first thread of the core */
474     if (cpu != me && cpu >= 0 && cpu < nr_cpu_ids) {
475     +#ifdef CONFIG_KVM_XICS
476     int real_cpu = cpu + vcpu->arch.ptid;
477     if (paca[real_cpu].kvm_hstate.xics_phys)
478     xics_wake_cpu(real_cpu);
479     - else if (cpu_online(cpu))
480     + else
481     +#endif
482     + if (cpu_online(cpu))
483     smp_send_reschedule(cpu);
484     }
485     put_cpu();
486     @@ -1089,7 +1092,9 @@ static void kvmppc_start_thread(struct kvm_vcpu *vcpu)
487     smp_wmb();
488     #if defined(CONFIG_PPC_ICP_NATIVE) && defined(CONFIG_SMP)
489     if (vcpu->arch.ptid) {
490     +#ifdef CONFIG_KVM_XICS
491     xics_wake_cpu(cpu);
492     +#endif
493     ++vc->n_woken;
494     }
495     #endif
496     diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
497     index 6d6f153b6c1d..c17600de7d59 100644
498     --- a/arch/powerpc/kvm/e500_mmu.c
499     +++ b/arch/powerpc/kvm/e500_mmu.c
500     @@ -127,7 +127,7 @@ static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500,
501     }
502    
503     static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu,
504     - unsigned int eaddr, int as)
505     + gva_t eaddr, int as)
506     {
507     struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
508     unsigned int victim, tsized;
509     diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
510     index c916127f10c3..4788ea2b343a 100644
511     --- a/arch/powerpc/mm/numa.c
512     +++ b/arch/powerpc/mm/numa.c
513     @@ -31,6 +31,8 @@
514     #include <asm/sparsemem.h>
515     #include <asm/prom.h>
516     #include <asm/smp.h>
517     +#include <asm/cputhreads.h>
518     +#include <asm/topology.h>
519     #include <asm/firmware.h>
520     #include <asm/paca.h>
521     #include <asm/hvcall.h>
522     @@ -152,9 +154,22 @@ static void __init get_node_active_region(unsigned long pfn,
523     }
524     }
525    
526     -static void map_cpu_to_node(int cpu, int node)
527     +static void reset_numa_cpu_lookup_table(void)
528     +{
529     + unsigned int cpu;
530     +
531     + for_each_possible_cpu(cpu)
532     + numa_cpu_lookup_table[cpu] = -1;
533     +}
534     +
535     +static void update_numa_cpu_lookup_table(unsigned int cpu, int node)
536     {
537     numa_cpu_lookup_table[cpu] = node;
538     +}
539     +
540     +static void map_cpu_to_node(int cpu, int node)
541     +{
542     + update_numa_cpu_lookup_table(cpu, node);
543    
544     dbg("adding cpu %d to node %d\n", cpu, node);
545    
546     @@ -522,11 +537,24 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
547     */
548     static int numa_setup_cpu(unsigned long lcpu)
549     {
550     - int nid = 0;
551     - struct device_node *cpu = of_get_cpu_node(lcpu, NULL);
552     + int nid;
553     + struct device_node *cpu;
554     +
555     + /*
556     + * If a valid cpu-to-node mapping is already available, use it
557     + * directly instead of querying the firmware, since it represents
558     + * the most recent mapping notified to us by the platform (eg: VPHN).
559     + */
560     + if ((nid = numa_cpu_lookup_table[lcpu]) >= 0) {
561     + map_cpu_to_node(lcpu, nid);
562     + return nid;
563     + }
564     +
565     + cpu = of_get_cpu_node(lcpu, NULL);
566    
567     if (!cpu) {
568     WARN_ON(1);
569     + nid = 0;
570     goto out;
571     }
572    
573     @@ -1068,6 +1096,7 @@ void __init do_init_bootmem(void)
574     */
575     setup_node_to_cpumask_map();
576    
577     + reset_numa_cpu_lookup_table();
578     register_cpu_notifier(&ppc64_numa_nb);
579     cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
580     (void *)(unsigned long)boot_cpuid);
581     @@ -1446,6 +1475,33 @@ static int update_cpu_topology(void *data)
582     return 0;
583     }
584    
585     +static int update_lookup_table(void *data)
586     +{
587     + struct topology_update_data *update;
588     +
589     + if (!data)
590     + return -EINVAL;
591     +
592     + /*
593     + * Upon topology update, the numa-cpu lookup table needs to be updated
594     + * for all threads in the core, including offline CPUs, to ensure that
595     + * future hotplug operations respect the cpu-to-node associativity
596     + * properly.
597     + */
598     + for (update = data; update; update = update->next) {
599     + int nid, base, j;
600     +
601     + nid = update->new_nid;
602     + base = cpu_first_thread_sibling(update->cpu);
603     +
604     + for (j = 0; j < threads_per_core; j++) {
605     + update_numa_cpu_lookup_table(base + j, nid);
606     + }
607     + }
608     +
609     + return 0;
610     +}
611     +
612     /*
613     * Update the node maps and sysfs entries for each cpu whose home node
614     * has changed. Returns 1 when the topology has changed, and 0 otherwise.
615     @@ -1514,6 +1570,14 @@ int arch_update_cpu_topology(void)
616    
617     stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
618    
619     + /*
620     + * Update the numa-cpu lookup table with the new mappings, even for
621     + * offline CPUs. It is best to perform this update from the stop-
622     + * machine context.
623     + */
624     + stop_machine(update_lookup_table, &updates[0],
625     + cpumask_of(raw_smp_processor_id()));
626     +
627     for (ud = &updates[0]; ud; ud = ud->next) {
628     unregister_cpu_under_node(ud->cpu, ud->old_nid);
629     register_cpu_under_node(ud->cpu, ud->new_nid);
630     diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
631     index 2345bdb4d917..ebbb2f1408ff 100644
632     --- a/arch/powerpc/net/bpf_jit_comp.c
633     +++ b/arch/powerpc/net/bpf_jit_comp.c
634     @@ -209,10 +209,11 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
635     }
636     PPC_DIVWU(r_A, r_A, r_X);
637     break;
638     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
639     + case BPF_S_ALU_DIV_K: /* A /= K */
640     + if (K == 1)
641     + break;
642     PPC_LI32(r_scratch1, K);
643     - /* Top 32 bits of 64bit result -> A */
644     - PPC_MULHWU(r_A, r_A, r_scratch1);
645     + PPC_DIVWU(r_A, r_A, r_scratch1);
646     break;
647     case BPF_S_ALU_AND_X:
648     ctx->seen |= SEEN_XREG;
649     diff --git a/arch/s390/include/uapi/asm/statfs.h b/arch/s390/include/uapi/asm/statfs.h
650     index a61d538756f2..471eb09184d4 100644
651     --- a/arch/s390/include/uapi/asm/statfs.h
652     +++ b/arch/s390/include/uapi/asm/statfs.h
653     @@ -35,11 +35,11 @@ struct statfs {
654     struct statfs64 {
655     unsigned int f_type;
656     unsigned int f_bsize;
657     - unsigned long f_blocks;
658     - unsigned long f_bfree;
659     - unsigned long f_bavail;
660     - unsigned long f_files;
661     - unsigned long f_ffree;
662     + unsigned long long f_blocks;
663     + unsigned long long f_bfree;
664     + unsigned long long f_bavail;
665     + unsigned long long f_files;
666     + unsigned long long f_ffree;
667     __kernel_fsid_t f_fsid;
668     unsigned int f_namelen;
669     unsigned int f_frsize;
670     diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
671     index 3a74d8af0d69..d88e846a58f1 100644
672     --- a/arch/s390/kvm/diag.c
673     +++ b/arch/s390/kvm/diag.c
674     @@ -122,7 +122,7 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
675     * - gpr 4 contains the index on the bus (optionally)
676     */
677     ret = kvm_io_bus_write_cookie(vcpu->kvm, KVM_VIRTIO_CCW_NOTIFY_BUS,
678     - vcpu->run->s.regs.gprs[2],
679     + vcpu->run->s.regs.gprs[2] & 0xffffffff,
680     8, &vcpu->run->s.regs.gprs[3],
681     vcpu->run->s.regs.gprs[4]);
682     srcu_read_unlock(&vcpu->kvm->srcu, idx);
683     @@ -139,7 +139,7 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
684    
685     int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
686     {
687     - int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16;
688     + int code = kvm_s390_get_base_disp_rs(vcpu) & 0xffff;
689    
690     if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
691     return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
692     diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
693     index a5df511e27a2..96a4b150f958 100644
694     --- a/arch/s390/net/bpf_jit_comp.c
695     +++ b/arch/s390/net/bpf_jit_comp.c
696     @@ -368,14 +368,16 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
697     EMIT4_PCREL(0xa7840000, (jit->ret0_ip - jit->prg));
698     /* lhi %r4,0 */
699     EMIT4(0xa7480000);
700     - /* dr %r4,%r12 */
701     - EMIT2(0x1d4c);
702     + /* dlr %r4,%r12 */
703     + EMIT4(0xb997004c);
704     break;
705     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K) */
706     - /* m %r4,<d(K)>(%r13) */
707     - EMIT4_DISP(0x5c40d000, EMIT_CONST(K));
708     - /* lr %r5,%r4 */
709     - EMIT2(0x1854);
710     + case BPF_S_ALU_DIV_K: /* A /= K */
711     + if (K == 1)
712     + break;
713     + /* lhi %r4,0 */
714     + EMIT4(0xa7480000);
715     + /* dl %r4,<d(K)>(%r13) */
716     + EMIT6_DISP(0xe340d000, 0x0097, EMIT_CONST(K));
717     break;
718     case BPF_S_ALU_MOD_X: /* A %= X */
719     jit->seen |= SEEN_XREG | SEEN_RET0;
720     @@ -385,16 +387,21 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
721     EMIT4_PCREL(0xa7840000, (jit->ret0_ip - jit->prg));
722     /* lhi %r4,0 */
723     EMIT4(0xa7480000);
724     - /* dr %r4,%r12 */
725     - EMIT2(0x1d4c);
726     + /* dlr %r4,%r12 */
727     + EMIT4(0xb997004c);
728     /* lr %r5,%r4 */
729     EMIT2(0x1854);
730     break;
731     case BPF_S_ALU_MOD_K: /* A %= K */
732     + if (K == 1) {
733     + /* lhi %r5,0 */
734     + EMIT4(0xa7580000);
735     + break;
736     + }
737     /* lhi %r4,0 */
738     EMIT4(0xa7480000);
739     - /* d %r4,<d(K)>(%r13) */
740     - EMIT4_DISP(0x5d40d000, EMIT_CONST(K));
741     + /* dl %r4,<d(K)>(%r13) */
742     + EMIT6_DISP(0xe340d000, 0x0097, EMIT_CONST(K));
743     /* lr %r5,%r4 */
744     EMIT2(0x1854);
745     break;
746     diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
747     index 218b6b23c378..01fe9946d388 100644
748     --- a/arch/sparc/net/bpf_jit_comp.c
749     +++ b/arch/sparc/net/bpf_jit_comp.c
750     @@ -497,9 +497,20 @@ void bpf_jit_compile(struct sk_filter *fp)
751     case BPF_S_ALU_MUL_K: /* A *= K */
752     emit_alu_K(MUL, K);
753     break;
754     - case BPF_S_ALU_DIV_K: /* A /= K */
755     - emit_alu_K(MUL, K);
756     - emit_read_y(r_A);
757     + case BPF_S_ALU_DIV_K: /* A /= K with K != 0*/
758     + if (K == 1)
759     + break;
760     + emit_write_y(G0);
761     +#ifdef CONFIG_SPARC32
762     + /* The Sparc v8 architecture requires
763     + * three instructions between a %y
764     + * register write and the first use.
765     + */
766     + emit_nop();
767     + emit_nop();
768     + emit_nop();
769     +#endif
770     + emit_alu_K(DIV, K);
771     break;
772     case BPF_S_ALU_DIV_X: /* A /= X; */
773     emit_cmpi(r_X, 0);
774     diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
775     index 1df115909758..c7678e43465b 100644
776     --- a/arch/x86/include/asm/kvm_para.h
777     +++ b/arch/x86/include/asm/kvm_para.h
778     @@ -85,28 +85,9 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
779     return ret;
780     }
781    
782     -static inline uint32_t kvm_cpuid_base(void)
783     -{
784     - if (boot_cpu_data.cpuid_level < 0)
785     - return 0; /* So we don't blow up on old processors */
786     -
787     - if (cpu_has_hypervisor)
788     - return hypervisor_cpuid_base("KVMKVMKVM\0\0\0", 0);
789     -
790     - return 0;
791     -}
792     -
793     -static inline bool kvm_para_available(void)
794     -{
795     - return kvm_cpuid_base() != 0;
796     -}
797     -
798     -static inline unsigned int kvm_arch_para_features(void)
799     -{
800     - return cpuid_eax(KVM_CPUID_FEATURES);
801     -}
802     -
803     #ifdef CONFIG_KVM_GUEST
804     +bool kvm_para_available(void);
805     +unsigned int kvm_arch_para_features(void);
806     void __init kvm_guest_init(void);
807     void kvm_async_pf_task_wait(u32 token);
808     void kvm_async_pf_task_wake(u32 token);
809     @@ -126,6 +107,16 @@ static inline void kvm_spinlock_init(void)
810     #define kvm_async_pf_task_wait(T) do {} while(0)
811     #define kvm_async_pf_task_wake(T) do {} while(0)
812    
813     +static inline bool kvm_para_available(void)
814     +{
815     + return 0;
816     +}
817     +
818     +static inline unsigned int kvm_arch_para_features(void)
819     +{
820     + return 0;
821     +}
822     +
823     static inline u32 kvm_read_and_reset_pf_reason(void)
824     {
825     return 0;
826     diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h
827     index bb0465090ae5..228d95f6592a 100644
828     --- a/arch/x86/include/uapi/asm/msr-index.h
829     +++ b/arch/x86/include/uapi/asm/msr-index.h
830     @@ -182,6 +182,7 @@
831     #define MSR_AMD64_PATCH_LOADER 0xc0010020
832     #define MSR_AMD64_OSVW_ID_LENGTH 0xc0010140
833     #define MSR_AMD64_OSVW_STATUS 0xc0010141
834     +#define MSR_AMD64_LS_CFG 0xc0011020
835     #define MSR_AMD64_DC_CFG 0xc0011022
836     #define MSR_AMD64_BU_CFG2 0xc001102a
837     #define MSR_AMD64_IBSFETCHCTL 0xc0011030
838     diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
839     index 903a264af981..28233b9e45cc 100644
840     --- a/arch/x86/kernel/cpu/amd.c
841     +++ b/arch/x86/kernel/cpu/amd.c
842     @@ -508,6 +508,16 @@ static void early_init_amd(struct cpuinfo_x86 *c)
843     set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
844     }
845     #endif
846     +
847     + /* F16h erratum 793, CVE-2013-6885 */
848     + if (c->x86 == 0x16 && c->x86_model <= 0xf) {
849     + u64 val;
850     +
851     + rdmsrl(MSR_AMD64_LS_CFG, val);
852     + if (!(val & BIT(15)))
853     + wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
854     + }
855     +
856     }
857    
858     static const int amd_erratum_383[];
859     diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
860     index b2046e4d0b59..f022c54a79a4 100644
861     --- a/arch/x86/kernel/kvm.c
862     +++ b/arch/x86/kernel/kvm.c
863     @@ -500,6 +500,38 @@ void __init kvm_guest_init(void)
864     #endif
865     }
866    
867     +static noinline uint32_t __kvm_cpuid_base(void)
868     +{
869     + if (boot_cpu_data.cpuid_level < 0)
870     + return 0; /* So we don't blow up on old processors */
871     +
872     + if (cpu_has_hypervisor)
873     + return hypervisor_cpuid_base("KVMKVMKVM\0\0\0", 0);
874     +
875     + return 0;
876     +}
877     +
878     +static inline uint32_t kvm_cpuid_base(void)
879     +{
880     + static int kvm_cpuid_base = -1;
881     +
882     + if (kvm_cpuid_base == -1)
883     + kvm_cpuid_base = __kvm_cpuid_base();
884     +
885     + return kvm_cpuid_base;
886     +}
887     +
888     +bool kvm_para_available(void)
889     +{
890     + return kvm_cpuid_base() != 0;
891     +}
892     +EXPORT_SYMBOL_GPL(kvm_para_available);
893     +
894     +unsigned int kvm_arch_para_features(void)
895     +{
896     + return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES);
897     +}
898     +
899     static uint32_t __init kvm_detect(void)
900     {
901     return kvm_cpuid_base();
902     diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
903     index 412a5aa0ef94..518d86471b76 100644
904     --- a/arch/x86/kvm/i8254.c
905     +++ b/arch/x86/kvm/i8254.c
906     @@ -37,6 +37,7 @@
907    
908     #include "irq.h"
909     #include "i8254.h"
910     +#include "x86.h"
911    
912     #ifndef CONFIG_X86_64
913     #define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
914     @@ -349,6 +350,23 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
915     atomic_set(&ps->pending, 0);
916     ps->irq_ack = 1;
917    
918     + /*
919     + * Do not allow the guest to program periodic timers with small
920     + * interval, since the hrtimers are not throttled by the host
921     + * scheduler.
922     + */
923     + if (ps->is_periodic) {
924     + s64 min_period = min_timer_period_us * 1000LL;
925     +
926     + if (ps->period < min_period) {
927     + pr_info_ratelimited(
928     + "kvm: requested %lld ns "
929     + "i8254 timer period limited to %lld ns\n",
930     + ps->period, min_period);
931     + ps->period = min_period;
932     + }
933     + }
934     +
935     hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval),
936     HRTIMER_MODE_ABS);
937     }
938     diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
939     index 1673940cf9c3..d86ff15fc89f 100644
940     --- a/arch/x86/kvm/lapic.c
941     +++ b/arch/x86/kvm/lapic.c
942     @@ -71,9 +71,6 @@
943     #define VEC_POS(v) ((v) & (32 - 1))
944     #define REG_POS(v) (((v) >> 5) << 4)
945    
946     -static unsigned int min_timer_period_us = 500;
947     -module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR);
948     -
949     static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val)
950     {
951     *((u32 *) (apic->regs + reg_off)) = val;
952     @@ -1355,7 +1352,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
953     vcpu->arch.apic_base = value;
954    
955     /* update jump label if enable bit changes */
956     - if ((vcpu->arch.apic_base ^ value) & MSR_IA32_APICBASE_ENABLE) {
957     + if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE) {
958     if (value & MSR_IA32_APICBASE_ENABLE)
959     static_key_slow_dec_deferred(&apic_hw_disabled);
960     else
961     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
962     index eb9b9c9fc3d9..16dc55a39fa3 100644
963     --- a/arch/x86/kvm/x86.c
964     +++ b/arch/x86/kvm/x86.c
965     @@ -94,6 +94,9 @@ EXPORT_SYMBOL_GPL(kvm_x86_ops);
966     static bool ignore_msrs = 0;
967     module_param(ignore_msrs, bool, S_IRUGO | S_IWUSR);
968    
969     +unsigned int min_timer_period_us = 500;
970     +module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR);
971     +
972     bool kvm_has_tsc_control;
973     EXPORT_SYMBOL_GPL(kvm_has_tsc_control);
974     u32 kvm_max_guest_tsc_khz;
975     diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
976     index e224f7a671b6..3186542f2fa3 100644
977     --- a/arch/x86/kvm/x86.h
978     +++ b/arch/x86/kvm/x86.h
979     @@ -124,5 +124,7 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
980    
981     extern u64 host_xcr0;
982    
983     +extern unsigned int min_timer_period_us;
984     +
985     extern struct static_key kvm_no_apic_vcpu;
986     #endif
987     diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
988     index 26328e800869..4ed75dd81d05 100644
989     --- a/arch/x86/net/bpf_jit_comp.c
990     +++ b/arch/x86/net/bpf_jit_comp.c
991     @@ -359,15 +359,21 @@ void bpf_jit_compile(struct sk_filter *fp)
992     EMIT2(0x89, 0xd0); /* mov %edx,%eax */
993     break;
994     case BPF_S_ALU_MOD_K: /* A %= K; */
995     + if (K == 1) {
996     + CLEAR_A();
997     + break;
998     + }
999     EMIT2(0x31, 0xd2); /* xor %edx,%edx */
1000     EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
1001     EMIT2(0xf7, 0xf1); /* div %ecx */
1002     EMIT2(0x89, 0xd0); /* mov %edx,%eax */
1003     break;
1004     - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
1005     - EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
1006     - EMIT(K, 4);
1007     - EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
1008     + case BPF_S_ALU_DIV_K: /* A /= K */
1009     + if (K == 1)
1010     + break;
1011     + EMIT2(0x31, 0xd2); /* xor %edx,%edx */
1012     + EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
1013     + EMIT2(0xf7, 0xf1); /* div %ecx */
1014     break;
1015     case BPF_S_ALU_AND_X:
1016     seen |= SEEN_XREG;
1017     diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
1018     index 220fa52b9bd0..f19284d87dfe 100644
1019     --- a/arch/x86/platform/efi/efi.c
1020     +++ b/arch/x86/platform/efi/efi.c
1021     @@ -440,7 +440,7 @@ void __init efi_reserve_boot_services(void)
1022     * - Not within any part of the kernel
1023     * - Not the bios reserved area
1024     */
1025     - if ((start+size >= __pa_symbol(_text)
1026     + if ((start + size > __pa_symbol(_text)
1027     && start <= __pa_symbol(_end)) ||
1028     !e820_all_mapped(start, start+size, E820_RAM) ||
1029     memblock_is_region_reserved(start, size)) {
1030     diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1031     index 2c2780a19609..f3c361b5c5e5 100644
1032     --- a/drivers/ata/libata-core.c
1033     +++ b/drivers/ata/libata-core.c
1034     @@ -2222,6 +2222,16 @@ int ata_dev_configure(struct ata_device *dev)
1035     if (rc)
1036     return rc;
1037    
1038     + /* some WD SATA-1 drives have issues with LPM, turn on NOLPM for them */
1039     + if ((dev->horkage & ATA_HORKAGE_WD_BROKEN_LPM) &&
1040     + (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
1041     + dev->horkage |= ATA_HORKAGE_NOLPM;
1042     +
1043     + if (dev->horkage & ATA_HORKAGE_NOLPM) {
1044     + ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
1045     + dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER;
1046     + }
1047     +
1048     /* let ACPI work its magic */
1049     rc = ata_acpi_on_devcfg(dev);
1050     if (rc)
1051     @@ -4216,6 +4226,23 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
1052     { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
1053     { "Crucial_CT???M500SSD1", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
1054    
1055     + /*
1056     + * Some WD SATA-I drives spin up and down erratically when the link
1057     + * is put into the slumber mode. We don't have full list of the
1058     + * affected devices. Disable LPM if the device matches one of the
1059     + * known prefixes and is SATA-1. As a side effect LPM partial is
1060     + * lost too.
1061     + *
1062     + * https://bugzilla.kernel.org/show_bug.cgi?id=57211
1063     + */
1064     + { "WDC WD800JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1065     + { "WDC WD1200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1066     + { "WDC WD1600JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1067     + { "WDC WD2000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1068     + { "WDC WD2500JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1069     + { "WDC WD3000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1070     + { "WDC WD3200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },
1071     +
1072     /* End Marker */
1073     { }
1074     };
1075     diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
1076     index 377eb889f555..ef8567de6a75 100644
1077     --- a/drivers/ata/libata-scsi.c
1078     +++ b/drivers/ata/libata-scsi.c
1079     @@ -111,12 +111,14 @@ static const char *ata_lpm_policy_names[] = {
1080     [ATA_LPM_MIN_POWER] = "min_power",
1081     };
1082    
1083     -static ssize_t ata_scsi_lpm_store(struct device *dev,
1084     +static ssize_t ata_scsi_lpm_store(struct device *device,
1085     struct device_attribute *attr,
1086     const char *buf, size_t count)
1087     {
1088     - struct Scsi_Host *shost = class_to_shost(dev);
1089     + struct Scsi_Host *shost = class_to_shost(device);
1090     struct ata_port *ap = ata_shost_to_port(shost);
1091     + struct ata_link *link;
1092     + struct ata_device *dev;
1093     enum ata_lpm_policy policy;
1094     unsigned long flags;
1095    
1096     @@ -132,10 +134,20 @@ static ssize_t ata_scsi_lpm_store(struct device *dev,
1097     return -EINVAL;
1098    
1099     spin_lock_irqsave(ap->lock, flags);
1100     +
1101     + ata_for_each_link(link, ap, EDGE) {
1102     + ata_for_each_dev(dev, &ap->link, ENABLED) {
1103     + if (dev->horkage & ATA_HORKAGE_NOLPM) {
1104     + count = -EOPNOTSUPP;
1105     + goto out_unlock;
1106     + }
1107     + }
1108     + }
1109     +
1110     ap->target_lpm_policy = policy;
1111     ata_port_schedule_eh(ap);
1112     +out_unlock:
1113     spin_unlock_irqrestore(ap->lock, flags);
1114     -
1115     return count;
1116     }
1117    
1118     diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
1119     index 56be31819897..dc9d4b1ea4ec 100644
1120     --- a/drivers/ata/sata_mv.c
1121     +++ b/drivers/ata/sata_mv.c
1122     @@ -304,6 +304,7 @@ enum {
1123     MV5_LTMODE = 0x30,
1124     MV5_PHY_CTL = 0x0C,
1125     SATA_IFCFG = 0x050,
1126     + LP_PHY_CTL = 0x058,
1127    
1128     MV_M2_PREAMP_MASK = 0x7e0,
1129    
1130     @@ -431,6 +432,7 @@ enum {
1131     MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */
1132     MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */
1133     MV_HP_QUIRK_LED_BLINK_EN = (1 << 12), /* is led blinking enabled? */
1134     + MV_HP_FIX_LP_PHY_CTL = (1 << 13), /* fix speed in LP_PHY_CTL ? */
1135    
1136     /* Port private flags (pp_flags) */
1137     MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */
1138     @@ -1358,6 +1360,7 @@ static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
1139    
1140     if (ofs != 0xffffffffU) {
1141     void __iomem *addr = mv_ap_base(link->ap) + ofs;
1142     + struct mv_host_priv *hpriv = link->ap->host->private_data;
1143     if (sc_reg_in == SCR_CONTROL) {
1144     /*
1145     * Workaround for 88SX60x1 FEr SATA#26:
1146     @@ -1374,6 +1377,18 @@ static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
1147     */
1148     if ((val & 0xf) == 1 || (readl(addr) & 0xf) == 1)
1149     val |= 0xf000;
1150     +
1151     + if (hpriv->hp_flags & MV_HP_FIX_LP_PHY_CTL) {
1152     + void __iomem *lp_phy_addr =
1153     + mv_ap_base(link->ap) + LP_PHY_CTL;
1154     + /*
1155     + * Set PHY speed according to SControl speed.
1156     + */
1157     + if ((val & 0xf0) == 0x10)
1158     + writelfl(0x7, lp_phy_addr);
1159     + else
1160     + writelfl(0x227, lp_phy_addr);
1161     + }
1162     }
1163     writelfl(val, addr);
1164     return 0;
1165     @@ -4110,6 +4125,15 @@ static int mv_platform_probe(struct platform_device *pdev)
1166     if (rc)
1167     goto err;
1168    
1169     + /*
1170     + * To allow disk hotplug on Armada 370/XP SoCs, the PHY speed must be
1171     + * updated in the LP_PHY_CTL register.
1172     + */
1173     + if (pdev->dev.of_node &&
1174     + of_device_is_compatible(pdev->dev.of_node,
1175     + "marvell,armada-370-sata"))
1176     + hpriv->hp_flags |= MV_HP_FIX_LP_PHY_CTL;
1177     +
1178     /* initialize adapter */
1179     rc = mv_init_host(host);
1180     if (rc)
1181     @@ -4209,6 +4233,7 @@ static int mv_platform_resume(struct platform_device *pdev)
1182    
1183     #ifdef CONFIG_OF
1184     static struct of_device_id mv_sata_dt_ids[] = {
1185     + { .compatible = "marvell,armada-370-sata", },
1186     { .compatible = "marvell,orion-sata", },
1187     {},
1188     };
1189     diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
1190     index 5bb8e2ddd3b3..156bd3c72770 100644
1191     --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
1192     +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
1193     @@ -410,6 +410,8 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
1194     &chip->vendor.read_queue)
1195     == 0) {
1196     burstcnt = get_burstcount(chip);
1197     + if (burstcnt < 0)
1198     + return burstcnt;
1199     len = min_t(int, burstcnt, count - size);
1200     I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
1201     size += len;
1202     @@ -451,7 +453,8 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
1203     static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf,
1204     size_t len)
1205     {
1206     - u32 status, burstcnt = 0, i, size;
1207     + u32 status, i, size;
1208     + int burstcnt = 0;
1209     int ret;
1210     u8 data;
1211     struct i2c_client *client;
1212     @@ -482,6 +485,8 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf,
1213    
1214     for (i = 0; i < len - 1;) {
1215     burstcnt = get_burstcount(chip);
1216     + if (burstcnt < 0)
1217     + return burstcnt;
1218     size = min_t(int, len - i - 1, burstcnt);
1219     ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf, size);
1220     if (ret < 0)
1221     diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
1222     index 57a818b2b5f2..811ad1e4d802 100644
1223     --- a/drivers/char/tpm/tpm_ppi.c
1224     +++ b/drivers/char/tpm/tpm_ppi.c
1225     @@ -172,7 +172,7 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
1226     * is updated with function index from SUBREQ to SUBREQ2 since PPI
1227     * version 1.1
1228     */
1229     - if (strcmp(version, "1.1") == -1)
1230     + if (strcmp(version, "1.1") < 0)
1231     params[2].integer.value = TPM_PPI_FN_SUBREQ;
1232     else
1233     params[2].integer.value = TPM_PPI_FN_SUBREQ2;
1234     @@ -182,7 +182,7 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
1235     * string/package type. For PPI version 1.0 and 1.1, use buffer type
1236     * for compatibility, and use package type since 1.2 according to spec.
1237     */
1238     - if (strcmp(version, "1.2") == -1) {
1239     + if (strcmp(version, "1.2") < 0) {
1240     params[3].type = ACPI_TYPE_BUFFER;
1241     params[3].buffer.length = sizeof(req);
1242     sscanf(buf, "%d", &req);
1243     @@ -248,7 +248,7 @@ static ssize_t tpm_show_ppi_transition_action(struct device *dev,
1244     * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for
1245     * compatibility, define params[3].type as buffer, if PPI version < 1.2
1246     */
1247     - if (strcmp(version, "1.2") == -1) {
1248     + if (strcmp(version, "1.2") < 0) {
1249     params[3].type = ACPI_TYPE_BUFFER;
1250     params[3].buffer.length = 0;
1251     params[3].buffer.pointer = NULL;
1252     @@ -390,7 +390,7 @@ static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
1253     kfree(output.pointer);
1254     output.length = ACPI_ALLOCATE_BUFFER;
1255     output.pointer = NULL;
1256     - if (strcmp(version, "1.2") == -1)
1257     + if (strcmp(version, "1.2") < 0)
1258     return -EPERM;
1259    
1260     params[2].integer.value = TPM_PPI_FN_GETOPR;
1261     diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
1262     index 644fec54681f..f1e9d7bd131f 100644
1263     --- a/drivers/edac/e752x_edac.c
1264     +++ b/drivers/edac/e752x_edac.c
1265     @@ -1182,9 +1182,11 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
1266     pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
1267     pvt->dev_info->err_dev, pvt->bridge_ck);
1268    
1269     - if (pvt->bridge_ck == NULL)
1270     + if (pvt->bridge_ck == NULL) {
1271     pvt->bridge_ck = pci_scan_single_device(pdev->bus,
1272     PCI_DEVFN(0, 1));
1273     + pci_dev_get(pvt->bridge_ck);
1274     + }
1275    
1276     if (pvt->bridge_ck == NULL) {
1277     e752x_printk(KERN_ERR, "error reporting device not found:"
1278     diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1279     index 3dc7a997b795..a36f9c1d265c 100644
1280     --- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1281     +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1282     @@ -365,13 +365,13 @@ static u16
1283     init_script(struct nouveau_bios *bios, int index)
1284     {
1285     struct nvbios_init init = { .bios = bios };
1286     - u16 data;
1287     + u16 bmp_ver = bmp_version(bios), data;
1288    
1289     - if (bmp_version(bios) && bmp_version(bios) < 0x0510) {
1290     - if (index > 1)
1291     + if (bmp_ver && bmp_ver < 0x0510) {
1292     + if (index > 1 || bmp_ver < 0x0100)
1293     return 0x0000;
1294    
1295     - data = bios->bmp_offset + (bios->version.major < 2 ? 14 : 18);
1296     + data = bios->bmp_offset + (bmp_ver < 0x0200 ? 14 : 18);
1297     return nv_ro16(bios, data + (index * 2));
1298     }
1299    
1300     diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
1301     index d65f3fd895dd..758774f4454c 100644
1302     --- a/drivers/hwmon/k10temp.c
1303     +++ b/drivers/hwmon/k10temp.c
1304     @@ -210,6 +210,7 @@ static DEFINE_PCI_DEVICE_TABLE(k10temp_id_table) = {
1305     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
1306     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
1307     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
1308     + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) },
1309     { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
1310     {}
1311     };
1312     diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
1313     index cdcbd8368ed3..ff758eded96f 100644
1314     --- a/drivers/i2c/busses/Kconfig
1315     +++ b/drivers/i2c/busses/Kconfig
1316     @@ -151,6 +151,7 @@ config I2C_PIIX4
1317     ATI SB700/SP5100
1318     ATI SB800
1319     AMD Hudson-2
1320     + AMD ML
1321     AMD CZ
1322     Serverworks OSB4
1323     Serverworks CSB5
1324     diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
1325     index d3e9cc3153a9..6f02eb883e5e 100644
1326     --- a/drivers/i2c/busses/i2c-mv64xxx.c
1327     +++ b/drivers/i2c/busses/i2c-mv64xxx.c
1328     @@ -692,6 +692,7 @@ static const struct of_device_id mv64xxx_i2c_of_match_table[] = {
1329     { .compatible = "allwinner,sun4i-i2c", .data = &mv64xxx_i2c_regs_sun4i},
1330     { .compatible = "marvell,mv64xxx-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
1331     { .compatible = "marvell,mv78230-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
1332     + { .compatible = "marvell,mv78230-a0-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
1333     {}
1334     };
1335     MODULE_DEVICE_TABLE(of, mv64xxx_i2c_of_match_table);
1336     @@ -783,6 +784,10 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
1337     drv_data->errata_delay = true;
1338     }
1339    
1340     + if (of_device_is_compatible(np, "marvell,mv78230-a0-i2c")) {
1341     + drv_data->offload_enabled = false;
1342     + drv_data->errata_delay = true;
1343     + }
1344     out:
1345     return rc;
1346     #endif
1347     diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
1348     index a028617b8f13..f71b4d381c00 100644
1349     --- a/drivers/i2c/busses/i2c-piix4.c
1350     +++ b/drivers/i2c/busses/i2c-piix4.c
1351     @@ -22,7 +22,7 @@
1352     Intel PIIX4, 440MX
1353     Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
1354     ATI IXP200, IXP300, IXP400, SB600, SB700/SP5100, SB800
1355     - AMD Hudson-2, CZ
1356     + AMD Hudson-2, ML, CZ
1357     SMSC Victory66
1358    
1359     Note: we assume there can only be one device, with one or more
1360     @@ -235,7 +235,8 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
1361     {
1362     unsigned short piix4_smba;
1363     unsigned short smba_idx = 0xcd6;
1364     - u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en;
1365     + u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status;
1366     + u8 i2ccfg, i2ccfg_offset = 0x10;
1367    
1368     /* SB800 and later SMBus does not support forcing address */
1369     if (force || force_addr) {
1370     @@ -245,7 +246,15 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
1371     }
1372    
1373     /* Determine the address of the SMBus areas */
1374     - smb_en = (aux) ? 0x28 : 0x2c;
1375     + if ((PIIX4_dev->vendor == PCI_VENDOR_ID_AMD &&
1376     + PIIX4_dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS &&
1377     + PIIX4_dev->revision >= 0x41) ||
1378     + (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD &&
1379     + PIIX4_dev->device == 0x790b &&
1380     + PIIX4_dev->revision >= 0x49))
1381     + smb_en = 0x00;
1382     + else
1383     + smb_en = (aux) ? 0x28 : 0x2c;
1384    
1385     if (!request_region(smba_idx, 2, "smba_idx")) {
1386     dev_err(&PIIX4_dev->dev, "SMBus base address index region "
1387     @@ -258,13 +267,22 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
1388     smba_en_hi = inb_p(smba_idx + 1);
1389     release_region(smba_idx, 2);
1390    
1391     - if ((smba_en_lo & 1) == 0) {
1392     + if (!smb_en) {
1393     + smb_en_status = smba_en_lo & 0x10;
1394     + piix4_smba = smba_en_hi << 8;
1395     + if (aux)
1396     + piix4_smba |= 0x20;
1397     + } else {
1398     + smb_en_status = smba_en_lo & 0x01;
1399     + piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0;
1400     + }
1401     +
1402     + if (!smb_en_status) {
1403     dev_err(&PIIX4_dev->dev,
1404     "Host SMBus controller not enabled!\n");
1405     return -ENODEV;
1406     }
1407    
1408     - piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0;
1409     if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
1410     return -ENODEV;
1411    
1412     diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
1413     index 22d1ae72c282..26fdcac56ad1 100644
1414     --- a/drivers/md/bcache/bset.c
1415     +++ b/drivers/md/bcache/bset.c
1416     @@ -935,7 +935,7 @@ static void sort_key_next(struct btree_iter *iter,
1417     *i = iter->data[--iter->used];
1418     }
1419    
1420     -static void btree_sort_fixup(struct btree_iter *iter)
1421     +static struct bkey *btree_sort_fixup(struct btree_iter *iter, struct bkey *tmp)
1422     {
1423     while (iter->used > 1) {
1424     struct btree_iter_set *top = iter->data, *i = top + 1;
1425     @@ -963,9 +963,22 @@ static void btree_sort_fixup(struct btree_iter *iter)
1426     } else {
1427     /* can't happen because of comparison func */
1428     BUG_ON(!bkey_cmp(&START_KEY(top->k), &START_KEY(i->k)));
1429     - bch_cut_back(&START_KEY(i->k), top->k);
1430     +
1431     + if (bkey_cmp(i->k, top->k) < 0) {
1432     + bkey_copy(tmp, top->k);
1433     +
1434     + bch_cut_back(&START_KEY(i->k), tmp);
1435     + bch_cut_front(i->k, top->k);
1436     + heap_sift(iter, 0, btree_iter_cmp);
1437     +
1438     + return tmp;
1439     + } else {
1440     + bch_cut_back(&START_KEY(i->k), top->k);
1441     + }
1442     }
1443     }
1444     +
1445     + return NULL;
1446     }
1447    
1448     static void btree_mergesort(struct btree *b, struct bset *out,
1449     @@ -973,15 +986,20 @@ static void btree_mergesort(struct btree *b, struct bset *out,
1450     bool fixup, bool remove_stale)
1451     {
1452     struct bkey *k, *last = NULL;
1453     + BKEY_PADDED(k) tmp;
1454     bool (*bad)(struct btree *, const struct bkey *) = remove_stale
1455     ? bch_ptr_bad
1456     : bch_ptr_invalid;
1457    
1458     while (!btree_iter_end(iter)) {
1459     if (fixup && !b->level)
1460     - btree_sort_fixup(iter);
1461     + k = btree_sort_fixup(iter, &tmp.k);
1462     + else
1463     + k = NULL;
1464     +
1465     + if (!k)
1466     + k = bch_btree_iter_next(iter);
1467    
1468     - k = bch_btree_iter_next(iter);
1469     if (bad(b, k))
1470     continue;
1471    
1472     diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
1473     index 93174c6ab37c..10e9e46108fd 100644
1474     --- a/drivers/md/raid5.c
1475     +++ b/drivers/md/raid5.c
1476     @@ -2004,6 +2004,7 @@ static void raid5_end_write_request(struct bio *bi, int error)
1477     set_bit(R5_MadeGoodRepl, &sh->dev[i].flags);
1478     } else {
1479     if (!uptodate) {
1480     + set_bit(STRIPE_DEGRADED, &sh->state);
1481     set_bit(WriteErrorSeen, &rdev->flags);
1482     set_bit(R5_WriteError, &sh->dev[i].flags);
1483     if (!test_and_set_bit(WantReplacement, &rdev->flags))
1484     diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
1485     index 522be67b2e68..108453b75ccc 100644
1486     --- a/drivers/mfd/max77686.c
1487     +++ b/drivers/mfd/max77686.c
1488     @@ -103,7 +103,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
1489     max77686->irq_gpio = pdata->irq_gpio;
1490     max77686->irq = i2c->irq;
1491    
1492     - max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
1493     + max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config);
1494     if (IS_ERR(max77686->regmap)) {
1495     ret = PTR_ERR(max77686->regmap);
1496     dev_err(max77686->dev, "Failed to allocate register map: %d\n",
1497     diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
1498     index 0a0448326e9d..98f95614b5b1 100644
1499     --- a/drivers/misc/mei/hbm.c
1500     +++ b/drivers/misc/mei/hbm.c
1501     @@ -128,6 +128,17 @@ static bool is_treat_specially_client(struct mei_cl *cl,
1502     return false;
1503     }
1504    
1505     +/**
1506     + * mei_hbm_idle - set hbm to idle state
1507     + *
1508     + * @dev: the device structure
1509     + */
1510     +void mei_hbm_idle(struct mei_device *dev)
1511     +{
1512     + dev->init_clients_timer = 0;
1513     + dev->hbm_state = MEI_HBM_IDLE;
1514     +}
1515     +
1516     int mei_hbm_start_wait(struct mei_device *dev)
1517     {
1518     int ret;
1519     @@ -577,6 +588,14 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
1520     mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
1521     mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
1522    
1523     + /* ignore spurious message and prevent reset nesting
1524     + * hbm is put to idle during system reset
1525     + */
1526     + if (dev->hbm_state == MEI_HBM_IDLE) {
1527     + dev_dbg(&dev->pdev->dev, "hbm: state is idle ignore spurious messages\n");
1528     + return 0;
1529     + }
1530     +
1531     switch (mei_msg->hbm_cmd) {
1532     case HOST_START_RES_CMD:
1533     version_res = (struct hbm_host_version_response *)mei_msg;
1534     diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h
1535     index 4ae2e56e404f..210757701207 100644
1536     --- a/drivers/misc/mei/hbm.h
1537     +++ b/drivers/misc/mei/hbm.h
1538     @@ -49,6 +49,7 @@ static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
1539     hdr->reserved = 0;
1540     }
1541    
1542     +void mei_hbm_idle(struct mei_device *dev);
1543     int mei_hbm_start_req(struct mei_device *dev);
1544     int mei_hbm_start_wait(struct mei_device *dev);
1545     int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl);
1546     diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
1547     index 6197018e2f16..3fd43b0e69d1 100644
1548     --- a/drivers/misc/mei/init.c
1549     +++ b/drivers/misc/mei/init.c
1550     @@ -139,14 +139,19 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
1551     dev->dev_state != MEI_DEV_POWER_DOWN &&
1552     dev->dev_state != MEI_DEV_POWER_UP);
1553    
1554     + /* we're already in reset, cancel the init timer
1555     + * if the reset was called due the hbm protocol error
1556     + * we need to call it before hw start
1557     + * so the hbm watchdog won't kick in
1558     + */
1559     + mei_hbm_idle(dev);
1560     +
1561     ret = mei_hw_reset(dev, interrupts_enabled);
1562     if (ret) {
1563     dev_err(&dev->pdev->dev, "hw reset failed disabling the device\n");
1564     interrupts_enabled = false;
1565     - dev->dev_state = MEI_DEV_DISABLED;
1566     }
1567    
1568     - dev->hbm_state = MEI_HBM_IDLE;
1569    
1570     if (dev->dev_state != MEI_DEV_INITIALIZING &&
1571     dev->dev_state != MEI_DEV_POWER_UP) {
1572     @@ -175,8 +180,6 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
1573     memset(&dev->wr_ext_msg, 0, sizeof(dev->wr_ext_msg));
1574     }
1575    
1576     - /* we're already in reset, cancel the init timer */
1577     - dev->init_clients_timer = 0;
1578    
1579     dev->me_clients_num = 0;
1580     dev->rd_msg_hdr = 0;
1581     @@ -188,6 +191,7 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
1582    
1583     if (!interrupts_enabled) {
1584     dev_dbg(&dev->pdev->dev, "intr not enabled end of reset\n");
1585     + dev->dev_state = MEI_DEV_DISABLED;
1586     return;
1587     }
1588    
1589     diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
1590     index 4b59cb742dee..1b922e971d3e 100644
1591     --- a/drivers/misc/mei/interrupt.c
1592     +++ b/drivers/misc/mei/interrupt.c
1593     @@ -536,7 +536,6 @@ EXPORT_SYMBOL_GPL(mei_irq_write_handler);
1594     *
1595     * @work: pointer to the work_struct structure
1596     *
1597     - * NOTE: This function is called by timer interrupt work
1598     */
1599     void mei_timer(struct work_struct *work)
1600     {
1601     @@ -551,18 +550,24 @@ void mei_timer(struct work_struct *work)
1602    
1603    
1604     mutex_lock(&dev->device_lock);
1605     - if (dev->dev_state != MEI_DEV_ENABLED) {
1606     - if (dev->dev_state == MEI_DEV_INIT_CLIENTS) {
1607     - if (dev->init_clients_timer) {
1608     - if (--dev->init_clients_timer == 0) {
1609     - dev_err(&dev->pdev->dev, "reset: init clients timeout hbm_state = %d.\n",
1610     - dev->hbm_state);
1611     - mei_reset(dev, 1);
1612     - }
1613     +
1614     + /* Catch interrupt stalls during HBM init handshake */
1615     + if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
1616     + dev->hbm_state != MEI_HBM_IDLE) {
1617     +
1618     + if (dev->init_clients_timer) {
1619     + if (--dev->init_clients_timer == 0) {
1620     + dev_err(&dev->pdev->dev, "timer: init clients timeout hbm_state = %d.\n",
1621     + dev->hbm_state);
1622     + mei_reset(dev, 1);
1623     + goto out;
1624     }
1625     }
1626     - goto out;
1627     }
1628     +
1629     + if (dev->dev_state != MEI_DEV_ENABLED)
1630     + goto out;
1631     +
1632     /*** connect/disconnect timeouts ***/
1633     list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
1634     if (cl_pos->timer_count) {
1635     diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1636     index 4ab4c89c60cd..0399458e6d44 100644
1637     --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1638     +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1639     @@ -160,6 +160,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
1640     struct sk_buff *skb = tx_buf->skb;
1641     u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons;
1642     int nbd;
1643     + u16 split_bd_len = 0;
1644    
1645     /* prefetch skb end pointer to speedup dev_kfree_skb() */
1646     prefetch(&skb->end);
1647     @@ -167,10 +168,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
1648     DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n",
1649     txdata->txq_index, idx, tx_buf, skb);
1650    
1651     - /* unmap first bd */
1652     tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd;
1653     - dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
1654     - BD_UNMAP_LEN(tx_start_bd), DMA_TO_DEVICE);
1655    
1656     nbd = le16_to_cpu(tx_start_bd->nbd) - 1;
1657     #ifdef BNX2X_STOP_ON_ERROR
1658     @@ -188,12 +186,19 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
1659     --nbd;
1660     bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
1661    
1662     - /* ...and the TSO split header bd since they have no mapping */
1663     + /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
1664     if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
1665     + tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
1666     + split_bd_len = BD_UNMAP_LEN(tx_data_bd);
1667     --nbd;
1668     bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
1669     }
1670    
1671     + /* unmap first bd */
1672     + dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
1673     + BD_UNMAP_LEN(tx_start_bd) + split_bd_len,
1674     + DMA_TO_DEVICE);
1675     +
1676     /* now free frags */
1677     while (nbd > 0) {
1678    
1679     diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
1680     index da2be59505c0..20e71f4ca426 100644
1681     --- a/drivers/net/ethernet/intel/e1000e/phy.c
1682     +++ b/drivers/net/ethernet/intel/e1000e/phy.c
1683     @@ -1757,19 +1757,23 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
1684     * it across the board.
1685     */
1686     ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
1687     - if (ret_val)
1688     + if (ret_val) {
1689     /* If the first read fails, another entity may have
1690     * ownership of the resources, wait and try again to
1691     * see if they have relinquished the resources yet.
1692     */
1693     - udelay(usec_interval);
1694     + if (usec_interval >= 1000)
1695     + msleep(usec_interval / 1000);
1696     + else
1697     + udelay(usec_interval);
1698     + }
1699     ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
1700     if (ret_val)
1701     break;
1702     if (phy_status & BMSR_LSTATUS)
1703     break;
1704     if (usec_interval >= 1000)
1705     - mdelay(usec_interval / 1000);
1706     + msleep(usec_interval / 1000);
1707     else
1708     udelay(usec_interval);
1709     }
1710     diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
1711     index bdf697b184ae..f3ae9d94fe71 100644
1712     --- a/drivers/net/ethernet/via/via-rhine.c
1713     +++ b/drivers/net/ethernet/via/via-rhine.c
1714     @@ -1615,6 +1615,7 @@ static void rhine_reset_task(struct work_struct *work)
1715     goto out_unlock;
1716    
1717     napi_disable(&rp->napi);
1718     + netif_tx_disable(dev);
1719     spin_lock_bh(&rp->lock);
1720    
1721     /* clear all descriptors */
1722     diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
1723     index 8494bb53ebdc..aba04f561760 100644
1724     --- a/drivers/net/usb/usbnet.c
1725     +++ b/drivers/net/usb/usbnet.c
1726     @@ -1245,7 +1245,7 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
1727     return -ENOMEM;
1728    
1729     urb->num_sgs = num_sgs;
1730     - sg_init_table(urb->sg, urb->num_sgs);
1731     + sg_init_table(urb->sg, urb->num_sgs + 1);
1732    
1733     sg_set_buf(&urb->sg[s++], skb->data, skb_headlen(skb));
1734     total_len += skb_headlen(skb);
1735     diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
1736     index 146236891889..32c45c3d820d 100644
1737     --- a/drivers/net/vxlan.c
1738     +++ b/drivers/net/vxlan.c
1739     @@ -1051,6 +1051,15 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
1740     if (!vs)
1741     goto drop;
1742    
1743     + /* If the NIC driver gave us an encapsulated packet
1744     + * with the encapsulation mark, the device checksummed it
1745     + * for us. Otherwise force the upper layers to verify it.
1746     + */
1747     + if (skb->ip_summed != CHECKSUM_UNNECESSARY || !skb->encapsulation)
1748     + skb->ip_summed = CHECKSUM_NONE;
1749     +
1750     + skb->encapsulation = 0;
1751     +
1752     vs->rcv(vs, skb, vxh->vx_vni);
1753     return 0;
1754    
1755     @@ -1109,17 +1118,6 @@ static void vxlan_rcv(struct vxlan_sock *vs,
1756    
1757     skb_reset_network_header(skb);
1758    
1759     - /* If the NIC driver gave us an encapsulated packet with
1760     - * CHECKSUM_UNNECESSARY and Rx checksum feature is enabled,
1761     - * leave the CHECKSUM_UNNECESSARY, the device checksummed it
1762     - * for us. Otherwise force the upper layers to verify it.
1763     - */
1764     - if (skb->ip_summed != CHECKSUM_UNNECESSARY || !skb->encapsulation ||
1765     - !(vxlan->dev->features & NETIF_F_RXCSUM))
1766     - skb->ip_summed = CHECKSUM_NONE;
1767     -
1768     - skb->encapsulation = 0;
1769     -
1770     if (oip6)
1771     err = IP6_ECN_decapsulate(oip6, skb);
1772     if (oip)
1773     diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
1774     index ecc6ec4a1edb..4e0a9429e192 100644
1775     --- a/drivers/net/wireless/ath/ath9k/hw.c
1776     +++ b/drivers/net/wireless/ath/ath9k/hw.c
1777     @@ -2608,13 +2608,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
1778     ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
1779     pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
1780    
1781     - /*
1782     - * Fast channel change across bands is available
1783     - * only for AR9462 and AR9565.
1784     - */
1785     - if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
1786     - pCap->hw_caps |= ATH9K_HW_CAP_FCC_BAND_SWITCH;
1787     -
1788     return 0;
1789     }
1790    
1791     diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
1792     index ab9e3a8410bc..a1ab4ff46818 100644
1793     --- a/drivers/net/wireless/ath/ath9k/recv.c
1794     +++ b/drivers/net/wireless/ath/ath9k/recv.c
1795     @@ -848,20 +848,15 @@ static int ath9k_process_rate(struct ath_common *common,
1796     enum ieee80211_band band;
1797     unsigned int i = 0;
1798     struct ath_softc __maybe_unused *sc = common->priv;
1799     + struct ath_hw *ah = sc->sc_ah;
1800    
1801     - band = hw->conf.chandef.chan->band;
1802     + band = ah->curchan->chan->band;
1803     sband = hw->wiphy->bands[band];
1804    
1805     - switch (hw->conf.chandef.width) {
1806     - case NL80211_CHAN_WIDTH_5:
1807     + if (IS_CHAN_QUARTER_RATE(ah->curchan))
1808     rxs->flag |= RX_FLAG_5MHZ;
1809     - break;
1810     - case NL80211_CHAN_WIDTH_10:
1811     + else if (IS_CHAN_HALF_RATE(ah->curchan))
1812     rxs->flag |= RX_FLAG_10MHZ;
1813     - break;
1814     - default:
1815     - break;
1816     - }
1817    
1818     if (rx_stats->rs_rate & 0x80) {
1819     /* HT rate */
1820     @@ -1175,6 +1170,14 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
1821     ath_start_rx_poll(sc, 3);
1822     }
1823    
1824     + /*
1825     + * This shouldn't happen, but have a safety check anyway.
1826     + */
1827     + if (WARN_ON(!ah->curchan)) {
1828     + ret = -EINVAL;
1829     + goto exit;
1830     + }
1831     +
1832     if (ath9k_process_rate(common, hw, rx_stats, rx_status)) {
1833     ret =-EINVAL;
1834     goto exit;
1835     @@ -1182,8 +1185,8 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
1836    
1837     ath9k_process_rssi(common, hw, rx_stats, rx_status);
1838    
1839     - rx_status->band = hw->conf.chandef.chan->band;
1840     - rx_status->freq = hw->conf.chandef.chan->center_freq;
1841     + rx_status->band = ah->curchan->chan->band;
1842     + rx_status->freq = ah->curchan->chan->center_freq;
1843     rx_status->antenna = rx_stats->rs_antenna;
1844     rx_status->flag |= RX_FLAG_MACTIME_END;
1845    
1846     diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
1847     index 7f3d461f7e8d..54376fddfaf9 100644
1848     --- a/drivers/net/wireless/b43/b43.h
1849     +++ b/drivers/net/wireless/b43/b43.h
1850     @@ -731,8 +731,6 @@ enum b43_firmware_file_type {
1851     struct b43_request_fw_context {
1852     /* The device we are requesting the fw for. */
1853     struct b43_wldev *dev;
1854     - /* a completion event structure needed if this call is asynchronous */
1855     - struct completion fw_load_complete;
1856     /* a pointer to the firmware object */
1857     const struct firmware *blob;
1858     /* The type of firmware to request. */
1859     @@ -809,6 +807,8 @@ enum {
1860     struct b43_wldev {
1861     struct b43_bus_dev *dev;
1862     struct b43_wl *wl;
1863     + /* a completion event structure needed if this call is asynchronous */
1864     + struct completion fw_load_complete;
1865    
1866     /* The device initialization status.
1867     * Use b43_status() to query. */
1868     diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
1869     index ccd24f0acb8d..c75237eb55a1 100644
1870     --- a/drivers/net/wireless/b43/main.c
1871     +++ b/drivers/net/wireless/b43/main.c
1872     @@ -2070,6 +2070,7 @@ void b43_do_release_fw(struct b43_firmware_file *fw)
1873    
1874     static void b43_release_firmware(struct b43_wldev *dev)
1875     {
1876     + complete(&dev->fw_load_complete);
1877     b43_do_release_fw(&dev->fw.ucode);
1878     b43_do_release_fw(&dev->fw.pcm);
1879     b43_do_release_fw(&dev->fw.initvals);
1880     @@ -2095,7 +2096,7 @@ static void b43_fw_cb(const struct firmware *firmware, void *context)
1881     struct b43_request_fw_context *ctx = context;
1882    
1883     ctx->blob = firmware;
1884     - complete(&ctx->fw_load_complete);
1885     + complete(&ctx->dev->fw_load_complete);
1886     }
1887    
1888     int b43_do_request_fw(struct b43_request_fw_context *ctx,
1889     @@ -2142,7 +2143,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
1890     }
1891     if (async) {
1892     /* do this part asynchronously */
1893     - init_completion(&ctx->fw_load_complete);
1894     + init_completion(&ctx->dev->fw_load_complete);
1895     err = request_firmware_nowait(THIS_MODULE, 1, ctx->fwname,
1896     ctx->dev->dev->dev, GFP_KERNEL,
1897     ctx, b43_fw_cb);
1898     @@ -2150,12 +2151,11 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
1899     pr_err("Unable to load firmware\n");
1900     return err;
1901     }
1902     - /* stall here until fw ready */
1903     - wait_for_completion(&ctx->fw_load_complete);
1904     + wait_for_completion(&ctx->dev->fw_load_complete);
1905     if (ctx->blob)
1906     goto fw_ready;
1907     /* On some ARM systems, the async request will fail, but the next sync
1908     - * request works. For this reason, we dall through here
1909     + * request works. For this reason, we fall through here
1910     */
1911     }
1912     err = request_firmware(&ctx->blob, ctx->fwname,
1913     @@ -2424,6 +2424,7 @@ error:
1914    
1915     static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl);
1916     static void b43_one_core_detach(struct b43_bus_dev *dev);
1917     +static int b43_rng_init(struct b43_wl *wl);
1918    
1919     static void b43_request_firmware(struct work_struct *work)
1920     {
1921     @@ -2475,6 +2476,10 @@ start_ieee80211:
1922     goto err_one_core_detach;
1923     wl->hw_registred = true;
1924     b43_leds_register(wl->current_dev);
1925     +
1926     + /* Register HW RNG driver */
1927     + b43_rng_init(wl);
1928     +
1929     goto out;
1930    
1931     err_one_core_detach:
1932     @@ -4636,9 +4641,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
1933     if (!dev || b43_status(dev) != B43_STAT_INITIALIZED)
1934     return;
1935    
1936     - /* Unregister HW RNG driver */
1937     - b43_rng_exit(dev->wl);
1938     -
1939     b43_set_status(dev, B43_STAT_UNINIT);
1940    
1941     /* Stop the microcode PSM. */
1942     @@ -4795,9 +4797,6 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
1943    
1944     b43_set_status(dev, B43_STAT_INITIALIZED);
1945    
1946     - /* Register HW RNG driver */
1947     - b43_rng_init(dev->wl);
1948     -
1949     out:
1950     return err;
1951    
1952     @@ -5464,6 +5463,9 @@ static void b43_bcma_remove(struct bcma_device *core)
1953    
1954     b43_one_core_detach(wldev->dev);
1955    
1956     + /* Unregister HW RNG driver */
1957     + b43_rng_exit(wl);
1958     +
1959     b43_leds_unregister(wl);
1960    
1961     ieee80211_free_hw(wl->hw);
1962     @@ -5541,6 +5543,9 @@ static void b43_ssb_remove(struct ssb_device *sdev)
1963    
1964     b43_one_core_detach(dev);
1965    
1966     + /* Unregister HW RNG driver */
1967     + b43_rng_exit(wl);
1968     +
1969     if (list_empty(&wl->devlist)) {
1970     b43_leds_unregister(wl);
1971     /* Last core on the chip unregistered.
1972     diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
1973     index 8cb206a89083..e85d34b76039 100644
1974     --- a/drivers/net/wireless/b43/xmit.c
1975     +++ b/drivers/net/wireless/b43/xmit.c
1976     @@ -821,10 +821,10 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
1977     * channel number in b43. */
1978     if (chanstat & B43_RX_CHAN_5GHZ) {
1979     status.band = IEEE80211_BAND_5GHZ;
1980     - status.freq = b43_freq_to_channel_5ghz(chanid);
1981     + status.freq = b43_channel_to_freq_5ghz(chanid);
1982     } else {
1983     status.band = IEEE80211_BAND_2GHZ;
1984     - status.freq = b43_freq_to_channel_2ghz(chanid);
1985     + status.freq = b43_channel_to_freq_2ghz(chanid);
1986     }
1987     break;
1988     default:
1989     diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
1990     index 572668821862..349c77605231 100644
1991     --- a/drivers/net/wireless/b43legacy/main.c
1992     +++ b/drivers/net/wireless/b43legacy/main.c
1993     @@ -3919,6 +3919,7 @@ static void b43legacy_remove(struct ssb_device *dev)
1994     * as the ieee80211 unreg will destroy the workqueue. */
1995     cancel_work_sync(&wldev->restart_work);
1996     cancel_work_sync(&wl->firmware_load);
1997     + complete(&wldev->fw_load_complete);
1998    
1999     B43legacy_WARN_ON(!wl);
2000     if (!wldev->fw.ucode)
2001     diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
2002     index ff8cc75c189d..4e6dfbafc2a1 100644
2003     --- a/drivers/net/wireless/iwlwifi/iwl-prph.h
2004     +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
2005     @@ -272,4 +272,8 @@ static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl)
2006    
2007     /*********************** END TX SCHEDULER *************************************/
2008    
2009     +/* Oscillator clock */
2010     +#define OSC_CLK (0xa04068)
2011     +#define OSC_CLK_FORCE_CONTROL (0x8)
2012     +
2013     #endif /* __iwl_prph_h__ */
2014     diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
2015     index 2fcc8ef88a68..1fd08baa0d32 100644
2016     --- a/drivers/net/wireless/iwlwifi/mvm/ops.c
2017     +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
2018     @@ -446,6 +446,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
2019    
2020     out_unregister:
2021     ieee80211_unregister_hw(mvm->hw);
2022     + iwl_mvm_leds_exit(mvm);
2023     out_free:
2024     iwl_phy_db_free(mvm->phy_db);
2025     kfree(mvm->scan_cmd);
2026     diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
2027     index 6bc31003a32c..7bdaf06b8f5a 100644
2028     --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
2029     +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
2030     @@ -206,6 +206,28 @@ static int iwl_pcie_apm_init(struct iwl_trans *trans)
2031     goto out;
2032     }
2033    
2034     + if (trans->cfg->host_interrupt_operation_mode) {
2035     + /*
2036     + * This is a bit of an abuse - This is needed for 7260 / 3160
2037     + * only check host_interrupt_operation_mode even if this is
2038     + * not related to host_interrupt_operation_mode.
2039     + *
2040     + * Enable the oscillator to count wake up time for L1 exit. This
2041     + * consumes slightly more power (100uA) - but allows to be sure
2042     + * that we wake up from L1 on time.
2043     + *
2044     + * This looks weird: read twice the same register, discard the
2045     + * value, set a bit, and yet again, read that same register
2046     + * just to discard the value. But that's the way the hardware
2047     + * seems to like it.
2048     + */
2049     + iwl_read_prph(trans, OSC_CLK);
2050     + iwl_read_prph(trans, OSC_CLK);
2051     + iwl_set_bits_prph(trans, OSC_CLK, OSC_CLK_FORCE_CONTROL);
2052     + iwl_read_prph(trans, OSC_CLK);
2053     + iwl_read_prph(trans, OSC_CLK);
2054     + }
2055     +
2056     /*
2057     * Enable DMA clock and wait for it to stabilize.
2058     *
2059     diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
2060     index f80f30b6160e..14f63c9f6220 100644
2061     --- a/drivers/net/wireless/mwifiex/fw.h
2062     +++ b/drivers/net/wireless/mwifiex/fw.h
2063     @@ -226,7 +226,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
2064    
2065     /* HW_SPEC fw_cap_info */
2066    
2067     -#define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(13)|BIT(14)))
2068     +#define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(12)|BIT(13)))
2069    
2070     #define GET_VHTCAP_CHWDSET(vht_cap_info) ((vht_cap_info >> 2) & 0x3)
2071     #define GET_VHTNSSMCS(mcs_mapset, nss) ((mcs_mapset >> (2 * (nss - 1))) & 0x3)
2072     diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
2073     index 8cf7d50a7603..ba48e64673d9 100644
2074     --- a/drivers/net/wireless/mwifiex/scan.c
2075     +++ b/drivers/net/wireless/mwifiex/scan.c
2076     @@ -1681,7 +1681,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2077     const u8 *ie_buf;
2078     size_t ie_len;
2079     u16 channel = 0;
2080     - u64 fw_tsf = 0;
2081     + __le64 fw_tsf = 0;
2082     u16 beacon_size = 0;
2083     u32 curr_bcn_bytes;
2084     u32 freq;
2085     @@ -1815,7 +1815,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2086     ie_buf, ie_len, rssi, GFP_KERNEL);
2087     bss_priv = (struct mwifiex_bss_priv *)bss->priv;
2088     bss_priv->band = band;
2089     - bss_priv->fw_tsf = fw_tsf;
2090     + bss_priv->fw_tsf = le64_to_cpu(fw_tsf);
2091     if (priv->media_connected &&
2092     !memcmp(bssid,
2093     priv->curr_bss_params.bss_descriptor
2094     diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
2095     index 9fa90a252b96..e99d8b1aa3bd 100644
2096     --- a/drivers/net/wireless/rtlwifi/base.c
2097     +++ b/drivers/net/wireless/rtlwifi/base.c
2098     @@ -1437,7 +1437,8 @@ void rtl_watchdog_wq_callback(void *data)
2099     /* if we can't recv beacon for 6s, we should
2100     * reconnect this AP
2101     */
2102     - if (rtlpriv->link_info.roam_times >= 3) {
2103     + if ((rtlpriv->link_info.roam_times >= 3) &&
2104     + !is_zero_ether_addr(rtlpriv->mac80211.bssid)) {
2105     RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2106     "AP off, try to reconnect now\n");
2107     rtlpriv->link_info.roam_times = 0;
2108     diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
2109     index 733b7ce7f0e2..3550e8ae34eb 100644
2110     --- a/drivers/net/wireless/rtlwifi/core.c
2111     +++ b/drivers/net/wireless/rtlwifi/core.c
2112     @@ -46,10 +46,20 @@ void rtl_fw_cb(const struct firmware *firmware, void *context)
2113     "Firmware callback routine entered!\n");
2114     complete(&rtlpriv->firmware_loading_complete);
2115     if (!firmware) {
2116     + if (rtlpriv->cfg->alt_fw_name) {
2117     + err = request_firmware(&firmware,
2118     + rtlpriv->cfg->alt_fw_name,
2119     + rtlpriv->io.dev);
2120     + pr_info("Loading alternative firmware %s\n",
2121     + rtlpriv->cfg->alt_fw_name);
2122     + if (!err)
2123     + goto found_alt;
2124     + }
2125     pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
2126     rtlpriv->max_fw_size = 0;
2127     return;
2128     }
2129     +found_alt:
2130     if (firmware->size > rtlpriv->max_fw_size) {
2131     RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2132     "Firmware is too big!\n");
2133     @@ -184,6 +194,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
2134     rtlpriv->cfg->maps
2135     [RTL_IBSS_INT_MASKS]);
2136     }
2137     + mac->link_state = MAC80211_LINKED;
2138     break;
2139     case NL80211_IFTYPE_ADHOC:
2140     RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
2141     diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
2142     index 21a5cf060677..a6184b6e1d57 100644
2143     --- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
2144     +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
2145     @@ -1078,7 +1078,7 @@ static void rtl88e_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
2146     rtldm->swing_flag_ofdm = true;
2147     }
2148    
2149     - if (rtldm->swing_idx_cck != rtldm->swing_idx_cck) {
2150     + if (rtldm->swing_idx_cck_cur != rtldm->swing_idx_cck) {
2151     rtldm->swing_idx_cck_cur = rtldm->swing_idx_cck;
2152     rtldm->swing_flag_cck = true;
2153     }
2154     diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
2155     index d2d57a27a7c1..06cb94cf5085 100644
2156     --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
2157     +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
2158     @@ -158,6 +158,42 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
2159     {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
2160     };
2161    
2162     +static u32 power_index_reg[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
2163     +
2164     +void dm_restorepowerindex(struct ieee80211_hw *hw)
2165     +{
2166     + struct rtl_priv *rtlpriv = rtl_priv(hw);
2167     + u8 index;
2168     +
2169     + for (index = 0; index < 6; index++)
2170     + rtl_write_byte(rtlpriv, power_index_reg[index],
2171     + rtlpriv->dm.powerindex_backup[index]);
2172     +}
2173     +EXPORT_SYMBOL_GPL(dm_restorepowerindex);
2174     +
2175     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value)
2176     +{
2177     + struct rtl_priv *rtlpriv = rtl_priv(hw);
2178     + u8 index;
2179     +
2180     + for (index = 0; index < 6; index++)
2181     + rtl_write_byte(rtlpriv, power_index_reg[index], value);
2182     +}
2183     +EXPORT_SYMBOL_GPL(dm_writepowerindex);
2184     +
2185     +void dm_savepowerindex(struct ieee80211_hw *hw)
2186     +{
2187     + struct rtl_priv *rtlpriv = rtl_priv(hw);
2188     + u8 index;
2189     + u8 tmp;
2190     +
2191     + for (index = 0; index < 6; index++) {
2192     + tmp = rtl_read_byte(rtlpriv, power_index_reg[index]);
2193     + rtlpriv->dm.powerindex_backup[index] = tmp;
2194     + }
2195     +}
2196     +EXPORT_SYMBOL_GPL(dm_savepowerindex);
2197     +
2198     static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
2199     {
2200     struct rtl_priv *rtlpriv = rtl_priv(hw);
2201     diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
2202     index 518e208c0180..4f232a063636 100644
2203     --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
2204     +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
2205     @@ -91,6 +91,17 @@
2206     #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74
2207     #define TX_POWER_NEAR_FIELD_THRESH_LVL1 67
2208    
2209     +#define DYNAMIC_FUNC_DISABLE 0x0
2210     +#define DYNAMIC_FUNC_DIG BIT(0)
2211     +#define DYNAMIC_FUNC_HP BIT(1)
2212     +#define DYNAMIC_FUNC_SS BIT(2) /*Tx Power Tracking*/
2213     +#define DYNAMIC_FUNC_BT BIT(3)
2214     +#define DYNAMIC_FUNC_ANT_DIV BIT(4)
2215     +
2216     +#define RSSI_CCK 0
2217     +#define RSSI_OFDM 1
2218     +#define RSSI_DEFAULT 2
2219     +
2220     struct swat_t {
2221     u8 failure_cnt;
2222     u8 try_flag;
2223     @@ -167,5 +178,8 @@ void rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw);
2224     void rtl92c_phy_iq_calibrate(struct ieee80211_hw *hw, bool recovery);
2225     void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw);
2226     void rtl92c_dm_bt_coexist(struct ieee80211_hw *hw);
2227     +void dm_savepowerindex(struct ieee80211_hw *hw);
2228     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value);
2229     +void dm_restorepowerindex(struct ieee80211_hw *hw);
2230    
2231     #endif
2232     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
2233     index 16a0b9e59acf..c16209a336ea 100644
2234     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
2235     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
2236     @@ -101,6 +101,15 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw)
2237     "PHY_SetTxPowerLevel8192S() Channel = %d\n",
2238     rtlphy->current_channel);
2239     rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel);
2240     + if (rtlpriv->dm.dynamic_txhighpower_lvl ==
2241     + TXHIGHPWRLEVEL_NORMAL)
2242     + dm_restorepowerindex(hw);
2243     + else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
2244     + TXHIGHPWRLEVEL_LEVEL1)
2245     + dm_writepowerindex(hw, 0x14);
2246     + else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
2247     + TXHIGHPWRLEVEL_LEVEL2)
2248     + dm_writepowerindex(hw, 0x10);
2249     }
2250    
2251     rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl;
2252     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
2253     index d947e7d350bb..fafa6bac2a3f 100644
2254     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
2255     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
2256     @@ -30,3 +30,6 @@
2257     #include "../rtl8192ce/dm.h"
2258    
2259     void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw);
2260     +void dm_savepowerindex(struct ieee80211_hw *hw);
2261     +void dm_writepowerindex(struct ieee80211_hw *hw, u8 value);
2262     +void dm_restorepowerindex(struct ieee80211_hw *hw);
2263     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
2264     index 2119313a737b..b878d56d2f4d 100644
2265     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
2266     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
2267     @@ -85,17 +85,15 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
2268     if (mac->act_scanning) {
2269     tx_agc[RF90_PATH_A] = 0x3f3f3f3f;
2270     tx_agc[RF90_PATH_B] = 0x3f3f3f3f;
2271     - if (turbo_scanoff) {
2272     - for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
2273     - tx_agc[idx1] = ppowerlevel[idx1] |
2274     - (ppowerlevel[idx1] << 8) |
2275     - (ppowerlevel[idx1] << 16) |
2276     - (ppowerlevel[idx1] << 24);
2277     - if (rtlhal->interface == INTF_USB) {
2278     - if (tx_agc[idx1] > 0x20 &&
2279     - rtlefuse->external_pa)
2280     - tx_agc[idx1] = 0x20;
2281     - }
2282     + for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
2283     + tx_agc[idx1] = ppowerlevel[idx1] |
2284     + (ppowerlevel[idx1] << 8) |
2285     + (ppowerlevel[idx1] << 16) |
2286     + (ppowerlevel[idx1] << 24);
2287     + if (rtlhal->interface == INTF_USB) {
2288     + if (tx_agc[idx1] > 0x20 &&
2289     + rtlefuse->external_pa)
2290     + tx_agc[idx1] = 0x20;
2291     }
2292     }
2293     } else {
2294     @@ -107,7 +105,7 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
2295     TXHIGHPWRLEVEL_LEVEL2) {
2296     tx_agc[RF90_PATH_A] = 0x00000000;
2297     tx_agc[RF90_PATH_B] = 0x00000000;
2298     - } else{
2299     + } else {
2300     for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) {
2301     tx_agc[idx1] = ppowerlevel[idx1] |
2302     (ppowerlevel[idx1] << 8) |
2303     @@ -373,7 +371,12 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw,
2304     regoffset == RTXAGC_B_MCS07_MCS04)
2305     regoffset = 0xc98;
2306     for (i = 0; i < 3; i++) {
2307     - writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
2308     + if (i != 2)
2309     + writeVal = (writeVal > 8) ?
2310     + (writeVal - 8) : 0;
2311     + else
2312     + writeVal = (writeVal > 6) ?
2313     + (writeVal - 6) : 0;
2314     rtl_write_byte(rtlpriv, (u32)(regoffset + i),
2315     (u8)writeVal);
2316     }
2317     diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
2318     index 2bd598526217..8188dcb512f0 100644
2319     --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
2320     +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
2321     @@ -49,6 +49,9 @@ MODULE_AUTHOR("Larry Finger <Larry.Finger@lwfinger.net>");
2322     MODULE_LICENSE("GPL");
2323     MODULE_DESCRIPTION("Realtek 8192C/8188C 802.11n USB wireless");
2324     MODULE_FIRMWARE("rtlwifi/rtl8192cufw.bin");
2325     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_A.bin");
2326     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_B.bin");
2327     +MODULE_FIRMWARE("rtlwifi/rtl8192cufw_TMSC.bin");
2328    
2329     static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
2330     {
2331     @@ -68,14 +71,21 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
2332     "Can't alloc buffer for fw\n");
2333     return 1;
2334     }
2335     -
2336     + if (IS_VENDOR_UMC_A_CUT(rtlpriv->rtlhal.version) &&
2337     + !IS_92C_SERIAL(rtlpriv->rtlhal.version)) {
2338     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_A.bin";
2339     + } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlpriv->rtlhal.version)) {
2340     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_B.bin";
2341     + } else {
2342     + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_TMSC.bin";
2343     + }
2344     + /* provide name of alternative file */
2345     + rtlpriv->cfg->alt_fw_name = "rtlwifi/rtl8192cufw.bin";
2346     pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name);
2347     rtlpriv->max_fw_size = 0x4000;
2348     err = request_firmware_nowait(THIS_MODULE, 1,
2349     rtlpriv->cfg->fw_name, rtlpriv->io.dev,
2350     GFP_KERNEL, hw, rtl_fw_cb);
2351     -
2352     -
2353     return err;
2354     }
2355    
2356     @@ -306,6 +316,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = {
2357     {RTL_USB_DEVICE(0x0bda, 0x5088, rtl92cu_hal_cfg)}, /*Thinkware-CC&C*/
2358     {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
2359     {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
2360     + {RTL_USB_DEVICE(0x0df6, 0x0077, rtl92cu_hal_cfg)}, /*Sitecom-WLA2100V2*/
2361     {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/
2362     {RTL_USB_DEVICE(0x4856, 0x0091, rtl92cu_hal_cfg)}, /*NetweeN - Feixun*/
2363     /* HP - Lite-On ,8188CUS Slim Combo */
2364     diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
2365     index 8ed31744a054..4f083fc1d360 100644
2366     --- a/drivers/net/wireless/rtlwifi/stats.c
2367     +++ b/drivers/net/wireless/rtlwifi/stats.c
2368     @@ -176,6 +176,7 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
2369     struct rtl_sta_info *drv_priv = NULL;
2370     struct ieee80211_sta *sta = NULL;
2371     long undec_sm_pwdb;
2372     + long undec_sm_cck;
2373    
2374     rcu_read_lock();
2375     if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
2376     @@ -185,12 +186,16 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
2377     if (sta) {
2378     drv_priv = (struct rtl_sta_info *) sta->drv_priv;
2379     undec_sm_pwdb = drv_priv->rssi_stat.undec_sm_pwdb;
2380     + undec_sm_cck = drv_priv->rssi_stat.undec_sm_cck;
2381     } else {
2382     undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
2383     + undec_sm_cck = rtlpriv->dm.undec_sm_cck;
2384     }
2385    
2386     if (undec_sm_pwdb < 0)
2387     undec_sm_pwdb = pstatus->rx_pwdb_all;
2388     + if (undec_sm_cck < 0)
2389     + undec_sm_cck = pstatus->rx_pwdb_all;
2390     if (pstatus->rx_pwdb_all > (u32) undec_sm_pwdb) {
2391     undec_sm_pwdb = (((undec_sm_pwdb) *
2392     (RX_SMOOTH_FACTOR - 1)) +
2393     @@ -200,6 +205,15 @@ static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
2394     undec_sm_pwdb = (((undec_sm_pwdb) * (RX_SMOOTH_FACTOR - 1)) +
2395     (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
2396     }
2397     + if (pstatus->rx_pwdb_all > (u32) undec_sm_cck) {
2398     + undec_sm_cck = (((undec_sm_pwdb) *
2399     + (RX_SMOOTH_FACTOR - 1)) +
2400     + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
2401     + undec_sm_cck = undec_sm_cck + 1;
2402     + } else {
2403     + undec_sm_pwdb = (((undec_sm_cck) * (RX_SMOOTH_FACTOR - 1)) +
2404     + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
2405     + }
2406    
2407     if (sta) {
2408     drv_priv->rssi_stat.undec_sm_pwdb = undec_sm_pwdb;
2409     diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
2410     index e56778cac9bf..97924743ecf6 100644
2411     --- a/drivers/net/wireless/rtlwifi/usb.c
2412     +++ b/drivers/net/wireless/rtlwifi/usb.c
2413     @@ -484,6 +484,8 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
2414     if (unicast)
2415     rtlpriv->link_info.num_rx_inperiod++;
2416     }
2417     + /* static bcn for roaming */
2418     + rtl_beacon_statistic(hw, skb);
2419     }
2420     }
2421    
2422     @@ -555,7 +557,7 @@ static void _rtl_rx_pre_process(struct ieee80211_hw *hw, struct sk_buff *skb)
2423     }
2424     }
2425    
2426     -#define __RX_SKB_MAX_QUEUED 32
2427     +#define __RX_SKB_MAX_QUEUED 64
2428    
2429     static void _rtl_rx_work(unsigned long param)
2430     {
2431     diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
2432     index ad9c37a42709..e576a927fde7 100644
2433     --- a/drivers/net/wireless/rtlwifi/wifi.h
2434     +++ b/drivers/net/wireless/rtlwifi/wifi.h
2435     @@ -1035,6 +1035,7 @@ struct rtl_ht_agg {
2436    
2437     struct rssi_sta {
2438     long undec_sm_pwdb;
2439     + long undec_sm_cck;
2440     };
2441    
2442     struct rtl_tid_data {
2443     @@ -1325,8 +1326,10 @@ struct fast_ant_training {
2444     struct rtl_dm {
2445     /*PHY status for Dynamic Management */
2446     long entry_min_undec_sm_pwdb;
2447     + long undec_sm_cck;
2448     long undec_sm_pwdb; /*out dm */
2449     long entry_max_undec_sm_pwdb;
2450     + s32 ofdm_pkt_cnt;
2451     bool dm_initialgain_enable;
2452     bool dynamic_txpower_enable;
2453     bool current_turbo_edca;
2454     @@ -1341,6 +1344,7 @@ struct rtl_dm {
2455     bool inform_fw_driverctrldm;
2456     bool current_mrc_switch;
2457     u8 txpowercount;
2458     + u8 powerindex_backup[6];
2459    
2460     u8 thermalvalue_rxgain;
2461     u8 thermalvalue_iqk;
2462     @@ -1352,7 +1356,9 @@ struct rtl_dm {
2463     bool done_txpower;
2464     u8 dynamic_txhighpower_lvl; /*Tx high power level */
2465     u8 dm_flag; /*Indicate each dynamic mechanism's status. */
2466     + u8 dm_flag_tmp;
2467     u8 dm_type;
2468     + u8 dm_rssi_sel;
2469     u8 txpower_track_control;
2470     bool interrupt_migration;
2471     bool disable_tx_int;
2472     @@ -1806,6 +1812,7 @@ struct rtl_hal_cfg {
2473     bool write_readback;
2474     char *name;
2475     char *fw_name;
2476     + char *alt_fw_name;
2477     struct rtl_hal_ops *ops;
2478     struct rtl_mod_params *mod_params;
2479     struct rtl_hal_usbint_cfg *usb_interface_cfg;
2480     @@ -1950,6 +1957,7 @@ struct dig_t {
2481     u8 pre_ccastate;
2482     u8 cur_ccasate;
2483     u8 large_fa_hit;
2484     + u8 dig_dynamic_min;
2485     u8 forbidden_igi;
2486     u8 dig_state;
2487     u8 dig_highpwrstate;
2488     @@ -2030,22 +2038,15 @@ struct rtl_priv {
2489     struct dig_t dm_digtable;
2490     struct ps_t dm_pstable;
2491    
2492     - /* section shared by individual drivers */
2493     - union {
2494     - struct { /* data buffer pointer for USB reads */
2495     - __le32 *usb_data;
2496     - int usb_data_index;
2497     - bool initialized;
2498     - };
2499     - struct { /* section for 8723ae */
2500     - bool reg_init; /* true if regs saved */
2501     - u32 reg_874;
2502     - u32 reg_c70;
2503     - u32 reg_85c;
2504     - u32 reg_a74;
2505     - bool bt_operation_on;
2506     - };
2507     - };
2508     + u32 reg_874;
2509     + u32 reg_c70;
2510     + u32 reg_85c;
2511     + u32 reg_a74;
2512     + bool reg_init; /* true if regs saved */
2513     + bool bt_operation_on;
2514     + __le32 *usb_data;
2515     + int usb_data_index;
2516     + bool initialized;
2517     bool enter_ps; /* true when entering PS */
2518     u8 rate_mask[5];
2519    
2520     diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
2521     index 36808bf25677..3f0f20081979 100644
2522     --- a/drivers/net/xen-netfront.c
2523     +++ b/drivers/net/xen-netfront.c
2524     @@ -117,6 +117,7 @@ struct netfront_info {
2525     } tx_skbs[NET_TX_RING_SIZE];
2526     grant_ref_t gref_tx_head;
2527     grant_ref_t grant_tx_ref[NET_TX_RING_SIZE];
2528     + struct page *grant_tx_page[NET_TX_RING_SIZE];
2529     unsigned tx_skb_freelist;
2530    
2531     spinlock_t rx_lock ____cacheline_aligned_in_smp;
2532     @@ -395,6 +396,7 @@ static void xennet_tx_buf_gc(struct net_device *dev)
2533     gnttab_release_grant_reference(
2534     &np->gref_tx_head, np->grant_tx_ref[id]);
2535     np->grant_tx_ref[id] = GRANT_INVALID_REF;
2536     + np->grant_tx_page[id] = NULL;
2537     add_id_to_freelist(&np->tx_skb_freelist, np->tx_skbs, id);
2538     dev_kfree_skb_irq(skb);
2539     }
2540     @@ -451,6 +453,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
2541     gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
2542     mfn, GNTMAP_readonly);
2543    
2544     + np->grant_tx_page[id] = virt_to_page(data);
2545     tx->gref = np->grant_tx_ref[id] = ref;
2546     tx->offset = offset;
2547     tx->size = len;
2548     @@ -496,6 +499,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
2549     np->xbdev->otherend_id,
2550     mfn, GNTMAP_readonly);
2551    
2552     + np->grant_tx_page[id] = page;
2553     tx->gref = np->grant_tx_ref[id] = ref;
2554     tx->offset = offset;
2555     tx->size = bytes;
2556     @@ -595,6 +599,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
2557     mfn = virt_to_mfn(data);
2558     gnttab_grant_foreign_access_ref(
2559     ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
2560     + np->grant_tx_page[id] = virt_to_page(data);
2561     tx->gref = np->grant_tx_ref[id] = ref;
2562     tx->offset = offset;
2563     tx->size = len;
2564     @@ -1119,10 +1124,11 @@ static void xennet_release_tx_bufs(struct netfront_info *np)
2565     continue;
2566    
2567     skb = np->tx_skbs[i].skb;
2568     - gnttab_end_foreign_access_ref(np->grant_tx_ref[i],
2569     - GNTMAP_readonly);
2570     - gnttab_release_grant_reference(&np->gref_tx_head,
2571     - np->grant_tx_ref[i]);
2572     + get_page(np->grant_tx_page[i]);
2573     + gnttab_end_foreign_access(np->grant_tx_ref[i],
2574     + GNTMAP_readonly,
2575     + (unsigned long)page_address(np->grant_tx_page[i]));
2576     + np->grant_tx_page[i] = NULL;
2577     np->grant_tx_ref[i] = GRANT_INVALID_REF;
2578     add_id_to_freelist(&np->tx_skb_freelist, np->tx_skbs, i);
2579     dev_kfree_skb_irq(skb);
2580     @@ -1131,78 +1137,35 @@ static void xennet_release_tx_bufs(struct netfront_info *np)
2581    
2582     static void xennet_release_rx_bufs(struct netfront_info *np)
2583     {
2584     - struct mmu_update *mmu = np->rx_mmu;
2585     - struct multicall_entry *mcl = np->rx_mcl;
2586     - struct sk_buff_head free_list;
2587     - struct sk_buff *skb;
2588     - unsigned long mfn;
2589     - int xfer = 0, noxfer = 0, unused = 0;
2590     int id, ref;
2591    
2592     - dev_warn(&np->netdev->dev, "%s: fix me for copying receiver.\n",
2593     - __func__);
2594     - return;
2595     -
2596     - skb_queue_head_init(&free_list);
2597     -
2598     spin_lock_bh(&np->rx_lock);
2599    
2600     for (id = 0; id < NET_RX_RING_SIZE; id++) {
2601     - ref = np->grant_rx_ref[id];
2602     - if (ref == GRANT_INVALID_REF) {
2603     - unused++;
2604     - continue;
2605     - }
2606     + struct sk_buff *skb;
2607     + struct page *page;
2608    
2609     skb = np->rx_skbs[id];
2610     - mfn = gnttab_end_foreign_transfer_ref(ref);
2611     - gnttab_release_grant_reference(&np->gref_rx_head, ref);
2612     - np->grant_rx_ref[id] = GRANT_INVALID_REF;
2613     -
2614     - if (0 == mfn) {
2615     - skb_shinfo(skb)->nr_frags = 0;
2616     - dev_kfree_skb(skb);
2617     - noxfer++;
2618     + if (!skb)
2619     continue;
2620     - }
2621    
2622     - if (!xen_feature(XENFEAT_auto_translated_physmap)) {
2623     - /* Remap the page. */
2624     - const struct page *page =
2625     - skb_frag_page(&skb_shinfo(skb)->frags[0]);
2626     - unsigned long pfn = page_to_pfn(page);
2627     - void *vaddr = page_address(page);
2628     + ref = np->grant_rx_ref[id];
2629     + if (ref == GRANT_INVALID_REF)
2630     + continue;
2631    
2632     - MULTI_update_va_mapping(mcl, (unsigned long)vaddr,
2633     - mfn_pte(mfn, PAGE_KERNEL),
2634     - 0);
2635     - mcl++;
2636     - mmu->ptr = ((u64)mfn << PAGE_SHIFT)
2637     - | MMU_MACHPHYS_UPDATE;
2638     - mmu->val = pfn;
2639     - mmu++;
2640     + page = skb_frag_page(&skb_shinfo(skb)->frags[0]);
2641    
2642     - set_phys_to_machine(pfn, mfn);
2643     - }
2644     - __skb_queue_tail(&free_list, skb);
2645     - xfer++;
2646     - }
2647     -
2648     - dev_info(&np->netdev->dev, "%s: %d xfer, %d noxfer, %d unused\n",
2649     - __func__, xfer, noxfer, unused);
2650     + /* gnttab_end_foreign_access() needs a page ref until
2651     + * foreign access is ended (which may be deferred).
2652     + */
2653     + get_page(page);
2654     + gnttab_end_foreign_access(ref, 0,
2655     + (unsigned long)page_address(page));
2656     + np->grant_rx_ref[id] = GRANT_INVALID_REF;
2657    
2658     - if (xfer) {
2659     - if (!xen_feature(XENFEAT_auto_translated_physmap)) {
2660     - /* Do all the remapping work and M2P updates. */
2661     - MULTI_mmu_update(mcl, np->rx_mmu, mmu - np->rx_mmu,
2662     - NULL, DOMID_SELF);
2663     - mcl++;
2664     - HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
2665     - }
2666     + kfree_skb(skb);
2667     }
2668    
2669     - __skb_queue_purge(&free_list);
2670     -
2671     spin_unlock_bh(&np->rx_lock);
2672     }
2673    
2674     @@ -1349,6 +1312,7 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
2675     for (i = 0; i < NET_RX_RING_SIZE; i++) {
2676     np->rx_skbs[i] = NULL;
2677     np->grant_rx_ref[i] = GRANT_INVALID_REF;
2678     + np->grant_tx_page[i] = NULL;
2679     }
2680    
2681     /* A grant for every tx ring slot */
2682     diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
2683     index 903e1285fda0..b0a0d5389f41 100644
2684     --- a/drivers/parport/parport_pc.c
2685     +++ b/drivers/parport/parport_pc.c
2686     @@ -2596,8 +2596,6 @@ enum parport_pc_pci_cards {
2687     syba_2p_epp,
2688     syba_1p_ecp,
2689     titan_010l,
2690     - titan_1284p1,
2691     - titan_1284p2,
2692     avlab_1p,
2693     avlab_2p,
2694     oxsemi_952,
2695     @@ -2656,8 +2654,6 @@ static struct parport_pc_pci {
2696     /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } },
2697     /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } },
2698     /* titan_010l */ { 1, { { 3, -1 }, } },
2699     - /* titan_1284p1 */ { 1, { { 0, 1 }, } },
2700     - /* titan_1284p2 */ { 2, { { 0, 1 }, { 2, 3 }, } },
2701     /* avlab_1p */ { 1, { { 0, 1}, } },
2702     /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} },
2703     /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
2704     @@ -2673,8 +2669,8 @@ static struct parport_pc_pci {
2705     /* netmos_9705 */ { 1, { { 0, -1 }, } },
2706     /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} },
2707     /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} },
2708     - /* netmos_9805 */ { 1, { { 0, -1 }, } },
2709     - /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } },
2710     + /* netmos_9805 */ { 1, { { 0, 1 }, } },
2711     + /* netmos_9815 */ { 2, { { 0, 1 }, { 2, 3 }, } },
2712     /* netmos_9901 */ { 1, { { 0, -1 }, } },
2713     /* netmos_9865 */ { 1, { { 0, -1 }, } },
2714     /* quatech_sppxp100 */ { 1, { { 0, 1 }, } },
2715     @@ -2718,8 +2714,6 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2716     PCI_ANY_ID, PCI_ANY_ID, 0, 0, syba_1p_ecp },
2717     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_010L,
2718     PCI_ANY_ID, PCI_ANY_ID, 0, 0, titan_010l },
2719     - { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 },
2720     - { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 },
2721     /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2722     /* AFAVLAB_TK9902 */
2723     { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p},
2724     diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
2725     index 119d2ddedfe7..6ebf3067bde4 100644
2726     --- a/drivers/pinctrl/pinctrl-sunxi.c
2727     +++ b/drivers/pinctrl/pinctrl-sunxi.c
2728     @@ -469,12 +469,6 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
2729     return val;
2730     }
2731    
2732     -static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
2733     - unsigned offset, int value)
2734     -{
2735     - return pinctrl_gpio_direction_output(chip->base + offset);
2736     -}
2737     -
2738     static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
2739     unsigned offset, int value)
2740     {
2741     @@ -498,6 +492,13 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
2742     spin_unlock_irqrestore(&pctl->lock, flags);
2743     }
2744    
2745     +static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
2746     + unsigned offset, int value)
2747     +{
2748     + sunxi_pinctrl_gpio_set(chip, offset, value);
2749     + return pinctrl_gpio_direction_output(chip->base + offset);
2750     +}
2751     +
2752     static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
2753     const struct of_phandle_args *gpiospec,
2754     u32 *flags)
2755     diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
2756     index a8e43cf70fac..0ed96df20162 100644
2757     --- a/drivers/platform/x86/hp_accel.c
2758     +++ b/drivers/platform/x86/hp_accel.c
2759     @@ -77,6 +77,7 @@ static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
2760     static struct acpi_device_id lis3lv02d_device_ids[] = {
2761     {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
2762     {"HPQ6000", 0}, /* HP Mobile Data Protection System PNP */
2763     + {"HPQ6007", 0}, /* HP Mobile Data Protection System PNP */
2764     {"", 0},
2765     };
2766     MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
2767     diff --git a/drivers/rtc/rtc-max8907.c b/drivers/rtc/rtc-max8907.c
2768     index 8e45b3c4aa2f..3032178bd9e6 100644
2769     --- a/drivers/rtc/rtc-max8907.c
2770     +++ b/drivers/rtc/rtc-max8907.c
2771     @@ -51,7 +51,7 @@ static irqreturn_t max8907_irq_handler(int irq, void *data)
2772     {
2773     struct max8907_rtc *rtc = data;
2774    
2775     - regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
2776     + regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
2777    
2778     rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);
2779    
2780     @@ -64,7 +64,7 @@ static void regs_to_tm(u8 *regs, struct rtc_time *tm)
2781     bcd2bin(regs[RTC_YEAR1]) - 1900;
2782     tm->tm_mon = bcd2bin(regs[RTC_MONTH] & 0x1f) - 1;
2783     tm->tm_mday = bcd2bin(regs[RTC_DATE] & 0x3f);
2784     - tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07) - 1;
2785     + tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07);
2786     if (regs[RTC_HOUR] & HOUR_12) {
2787     tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x01f);
2788     if (tm->tm_hour == 12)
2789     @@ -88,7 +88,7 @@ static void tm_to_regs(struct rtc_time *tm, u8 *regs)
2790     regs[RTC_YEAR1] = bin2bcd(low);
2791     regs[RTC_MONTH] = bin2bcd(tm->tm_mon + 1);
2792     regs[RTC_DATE] = bin2bcd(tm->tm_mday);
2793     - regs[RTC_WEEKDAY] = tm->tm_wday + 1;
2794     + regs[RTC_WEEKDAY] = tm->tm_wday;
2795     regs[RTC_HOUR] = bin2bcd(tm->tm_hour);
2796     regs[RTC_MIN] = bin2bcd(tm->tm_min);
2797     regs[RTC_SEC] = bin2bcd(tm->tm_sec);
2798     @@ -153,7 +153,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
2799     tm_to_regs(&alrm->time, regs);
2800    
2801     /* Disable alarm while we update the target time */
2802     - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
2803     + ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
2804     if (ret < 0)
2805     return ret;
2806    
2807     @@ -163,8 +163,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
2808     return ret;
2809    
2810     if (alrm->enabled)
2811     - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL,
2812     - 0x7f, 0x7f);
2813     + ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x77);
2814    
2815     return ret;
2816     }
2817     diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
2818     index f8ca7becacca..8ebab9c64be4 100644
2819     --- a/drivers/scsi/bfa/bfad.c
2820     +++ b/drivers/scsi/bfa/bfad.c
2821     @@ -1832,7 +1832,7 @@ out:
2822     static u32 *
2823     bfad_load_fwimg(struct pci_dev *pdev)
2824     {
2825     - if (pdev->device == BFA_PCI_DEVICE_ID_CT2) {
2826     + if (bfa_asic_id_ct2(pdev->device)) {
2827     if (bfi_image_ct2_size == 0)
2828     bfad_read_firmware(pdev, &bfi_image_ct2,
2829     &bfi_image_ct2_size, BFAD_FW_FILE_CT2);
2830     @@ -1842,12 +1842,14 @@ bfad_load_fwimg(struct pci_dev *pdev)
2831     bfad_read_firmware(pdev, &bfi_image_ct,
2832     &bfi_image_ct_size, BFAD_FW_FILE_CT);
2833     return bfi_image_ct;
2834     - } else {
2835     + } else if (bfa_asic_id_cb(pdev->device)) {
2836     if (bfi_image_cb_size == 0)
2837     bfad_read_firmware(pdev, &bfi_image_cb,
2838     &bfi_image_cb_size, BFAD_FW_FILE_CB);
2839     return bfi_image_cb;
2840     }
2841     +
2842     + return NULL;
2843     }
2844    
2845     static void
2846     diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
2847     index 74b88efde6ad..b26f1a5cc0ec 100644
2848     --- a/drivers/scsi/virtio_scsi.c
2849     +++ b/drivers/scsi/virtio_scsi.c
2850     @@ -957,6 +957,10 @@ static void virtscsi_remove(struct virtio_device *vdev)
2851     #ifdef CONFIG_PM
2852     static int virtscsi_freeze(struct virtio_device *vdev)
2853     {
2854     + struct Scsi_Host *sh = virtio_scsi_host(vdev);
2855     + struct virtio_scsi *vscsi = shost_priv(sh);
2856     +
2857     + unregister_hotcpu_notifier(&vscsi->nb);
2858     virtscsi_remove_vqs(vdev);
2859     return 0;
2860     }
2861     @@ -965,8 +969,17 @@ static int virtscsi_restore(struct virtio_device *vdev)
2862     {
2863     struct Scsi_Host *sh = virtio_scsi_host(vdev);
2864     struct virtio_scsi *vscsi = shost_priv(sh);
2865     + int err;
2866     +
2867     + err = virtscsi_init(vdev, vscsi);
2868     + if (err)
2869     + return err;
2870     +
2871     + err = register_hotcpu_notifier(&vscsi->nb);
2872     + if (err)
2873     + vdev->config->del_vqs(vdev);
2874    
2875     - return virtscsi_init(vdev, vscsi);
2876     + return err;
2877     }
2878     #endif
2879    
2880     diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
2881     index a0e009717a5a..d6047b9535ae 100644
2882     --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
2883     +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
2884     @@ -179,7 +179,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
2885     LNET_UNLINK, LNET_INS_AFTER, &me_h);
2886     if (rc != 0) {
2887     CERROR("%s: LNetMEAttach failed x"LPU64"/%d: rc = %d\n",
2888     - desc->bd_export->exp_obd->obd_name, xid,
2889     + desc->bd_import->imp_obd->obd_name, xid,
2890     posted_md, rc);
2891     break;
2892     }
2893     @@ -189,7 +189,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
2894     &desc->bd_mds[posted_md]);
2895     if (rc != 0) {
2896     CERROR("%s: LNetMDAttach failed x"LPU64"/%d: rc = %d\n",
2897     - desc->bd_export->exp_obd->obd_name, xid,
2898     + desc->bd_import->imp_obd->obd_name, xid,
2899     posted_md, rc);
2900     rc2 = LNetMEUnlink(me_h);
2901     LASSERT(rc2 == 0);
2902     @@ -219,7 +219,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
2903     /* Holler if peer manages to touch buffers before he knows the xid */
2904     if (desc->bd_md_count != total_md)
2905     CWARN("%s: Peer %s touched %d buffers while I registered\n",
2906     - desc->bd_export->exp_obd->obd_name, libcfs_id2str(peer),
2907     + desc->bd_import->imp_obd->obd_name, libcfs_id2str(peer),
2908     total_md - desc->bd_md_count);
2909     spin_unlock(&desc->bd_lock);
2910    
2911     diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
2912     index c812d6c7dc31..e3a005da776b 100644
2913     --- a/drivers/staging/rtl8712/usb_intf.c
2914     +++ b/drivers/staging/rtl8712/usb_intf.c
2915     @@ -358,6 +358,10 @@ static u8 key_2char2num(u8 hch, u8 lch)
2916     return (hex_to_bin(hch) << 4) | hex_to_bin(lch);
2917     }
2918    
2919     +static const struct device_type wlan_type = {
2920     + .name = "wlan",
2921     +};
2922     +
2923     /*
2924     * drv_init() - a device potentially for us
2925     *
2926     @@ -393,6 +397,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
2927     padapter->pusb_intf = pusb_intf;
2928     usb_set_intfdata(pusb_intf, pnetdev);
2929     SET_NETDEV_DEV(pnetdev, &pusb_intf->dev);
2930     + pnetdev->dev.type = &wlan_type;
2931     /* step 2. */
2932     padapter->dvobj_init = &r8712_usb_dvobj_init;
2933     padapter->dvobj_deinit = &r8712_usb_dvobj_deinit;
2934     diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
2935     index 4aa5ef54b683..22e117440f94 100644
2936     --- a/drivers/staging/vt6656/baseband.c
2937     +++ b/drivers/staging/vt6656/baseband.c
2938     @@ -1464,7 +1464,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2939    
2940     if( bScanning )
2941     { // need Max sensitivity //RSSI -69, -70,....
2942     - if(pDevice->byBBPreEDIndex == 0) break;
2943     pDevice->byBBPreEDIndex = 0;
2944     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2945     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
2946     @@ -1607,7 +1606,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2947    
2948     if( bScanning )
2949     { // need Max sensitivity //RSSI -69, -70, ...
2950     - if(pDevice->byBBPreEDIndex == 0) break;
2951     pDevice->byBBPreEDIndex = 0;
2952     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2953     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
2954     @@ -1759,7 +1757,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
2955     case RF_VT3342A0: //RobertYu:20060627, testing table
2956     if( bScanning )
2957     { // need Max sensitivity //RSSI -67, -68, ...
2958     - if(pDevice->byBBPreEDIndex == 0) break;
2959     pDevice->byBBPreEDIndex = 0;
2960     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2961     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
2962     diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
2963     index 19d3cf451b88..34a24b78c1a7 100644
2964     --- a/drivers/staging/vt6656/card.c
2965     +++ b/drivers/staging/vt6656/card.c
2966     @@ -731,7 +731,7 @@ u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval)
2967    
2968     uBeaconInterval = wBeaconInterval * 1024;
2969     // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2970     - uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
2971     + uLowNextTBTT = ((qwTSF & 0xffffffffULL) >> 10) << 10;
2972     uLowRemain = (uLowNextTBTT) % uBeaconInterval;
2973     uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
2974     % uBeaconInterval;
2975     diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
2976     index e06ec4393803..d7ac040e0dc1 100644
2977     --- a/drivers/staging/zram/zram_drv.c
2978     +++ b/drivers/staging/zram/zram_drv.c
2979     @@ -552,14 +552,14 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
2980     size_t index;
2981     struct zram_meta *meta;
2982    
2983     - flush_work(&zram->free_work);
2984     -
2985     down_write(&zram->init_lock);
2986     if (!zram->init_done) {
2987     up_write(&zram->init_lock);
2988     return;
2989     }
2990    
2991     + flush_work(&zram->free_work);
2992     +
2993     meta = zram->meta;
2994     zram->init_done = 0;
2995    
2996     diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
2997     index d5c724b317aa..e12f2aab3c87 100644
2998     --- a/drivers/target/iscsi/iscsi_target.c
2999     +++ b/drivers/target/iscsi/iscsi_target.c
3000     @@ -52,7 +52,7 @@
3001     static LIST_HEAD(g_tiqn_list);
3002     static LIST_HEAD(g_np_list);
3003     static DEFINE_SPINLOCK(tiqn_lock);
3004     -static DEFINE_SPINLOCK(np_lock);
3005     +static DEFINE_MUTEX(np_lock);
3006    
3007     static struct idr tiqn_idr;
3008     struct idr sess_idr;
3009     @@ -307,6 +307,9 @@ bool iscsit_check_np_match(
3010     return false;
3011     }
3012    
3013     +/*
3014     + * Called with mutex np_lock held
3015     + */
3016     static struct iscsi_np *iscsit_get_np(
3017     struct __kernel_sockaddr_storage *sockaddr,
3018     int network_transport)
3019     @@ -314,11 +317,10 @@ static struct iscsi_np *iscsit_get_np(
3020     struct iscsi_np *np;
3021     bool match;
3022    
3023     - spin_lock_bh(&np_lock);
3024     list_for_each_entry(np, &g_np_list, np_list) {
3025     - spin_lock(&np->np_thread_lock);
3026     + spin_lock_bh(&np->np_thread_lock);
3027     if (np->np_thread_state != ISCSI_NP_THREAD_ACTIVE) {
3028     - spin_unlock(&np->np_thread_lock);
3029     + spin_unlock_bh(&np->np_thread_lock);
3030     continue;
3031     }
3032    
3033     @@ -330,13 +332,11 @@ static struct iscsi_np *iscsit_get_np(
3034     * while iscsi_tpg_add_network_portal() is called.
3035     */
3036     np->np_exports++;
3037     - spin_unlock(&np->np_thread_lock);
3038     - spin_unlock_bh(&np_lock);
3039     + spin_unlock_bh(&np->np_thread_lock);
3040     return np;
3041     }
3042     - spin_unlock(&np->np_thread_lock);
3043     + spin_unlock_bh(&np->np_thread_lock);
3044     }
3045     - spin_unlock_bh(&np_lock);
3046    
3047     return NULL;
3048     }
3049     @@ -350,16 +350,22 @@ struct iscsi_np *iscsit_add_np(
3050     struct sockaddr_in6 *sock_in6;
3051     struct iscsi_np *np;
3052     int ret;
3053     +
3054     + mutex_lock(&np_lock);
3055     +
3056     /*
3057     * Locate the existing struct iscsi_np if already active..
3058     */
3059     np = iscsit_get_np(sockaddr, network_transport);
3060     - if (np)
3061     + if (np) {
3062     + mutex_unlock(&np_lock);
3063     return np;
3064     + }
3065    
3066     np = kzalloc(sizeof(struct iscsi_np), GFP_KERNEL);
3067     if (!np) {
3068     pr_err("Unable to allocate memory for struct iscsi_np\n");
3069     + mutex_unlock(&np_lock);
3070     return ERR_PTR(-ENOMEM);
3071     }
3072    
3073     @@ -382,6 +388,7 @@ struct iscsi_np *iscsit_add_np(
3074     ret = iscsi_target_setup_login_socket(np, sockaddr);
3075     if (ret != 0) {
3076     kfree(np);
3077     + mutex_unlock(&np_lock);
3078     return ERR_PTR(ret);
3079     }
3080    
3081     @@ -390,6 +397,7 @@ struct iscsi_np *iscsit_add_np(
3082     pr_err("Unable to create kthread: iscsi_np\n");
3083     ret = PTR_ERR(np->np_thread);
3084     kfree(np);
3085     + mutex_unlock(&np_lock);
3086     return ERR_PTR(ret);
3087     }
3088     /*
3089     @@ -400,10 +408,10 @@ struct iscsi_np *iscsit_add_np(
3090     * point because iscsi_np has not been added to g_np_list yet.
3091     */
3092     np->np_exports = 1;
3093     + np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
3094    
3095     - spin_lock_bh(&np_lock);
3096     list_add_tail(&np->np_list, &g_np_list);
3097     - spin_unlock_bh(&np_lock);
3098     + mutex_unlock(&np_lock);
3099    
3100     pr_debug("CORE[0] - Added Network Portal: %s:%hu on %s\n",
3101     np->np_ip, np->np_port, np->np_transport->name);
3102     @@ -470,9 +478,9 @@ int iscsit_del_np(struct iscsi_np *np)
3103    
3104     np->np_transport->iscsit_free_np(np);
3105    
3106     - spin_lock_bh(&np_lock);
3107     + mutex_lock(&np_lock);
3108     list_del(&np->np_list);
3109     - spin_unlock_bh(&np_lock);
3110     + mutex_unlock(&np_lock);
3111    
3112     pr_debug("CORE[0] - Removed Network Portal: %s:%hu on %s\n",
3113     np->np_ip, np->np_port, np->np_transport->name);
3114     diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
3115     index a972145dbaaa..76dc32fc5e1b 100644
3116     --- a/drivers/target/iscsi/iscsi_target_nego.c
3117     +++ b/drivers/target/iscsi/iscsi_target_nego.c
3118     @@ -1192,7 +1192,7 @@ get_target:
3119     */
3120     alloc_tags:
3121     tag_num = max_t(u32, ISCSIT_MIN_TAGS, queue_depth);
3122     - tag_num += (tag_num / 2) + ISCSIT_EXTRA_TAGS;
3123     + tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
3124     tag_size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size;
3125    
3126     ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size);
3127     diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
3128     index 570df9d2a5d2..4f6e01cf67f7 100644
3129     --- a/drivers/tty/serial/8250/8250_core.c
3130     +++ b/drivers/tty/serial/8250/8250_core.c
3131     @@ -2670,6 +2670,10 @@ static void serial8250_config_port(struct uart_port *port, int flags)
3132     if (port->type == PORT_16550A && port->iotype == UPIO_AU)
3133     up->bugs |= UART_BUG_NOMSR;
3134    
3135     + /* HW bugs may trigger IRQ while IIR == NO_INT */
3136     + if (port->type == PORT_TEGRA)
3137     + up->bugs |= UART_BUG_NOMSR;
3138     +
3139     if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
3140     autoconfig_irq(up);
3141    
3142     diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
3143     index c810da7c7a88..f5df8b7067ad 100644
3144     --- a/drivers/tty/serial/8250/8250_pci.c
3145     +++ b/drivers/tty/serial/8250/8250_pci.c
3146     @@ -1260,10 +1260,10 @@ static int pci_quatech_init(struct pci_dev *dev)
3147     unsigned long base = pci_resource_start(dev, 0);
3148     if (base) {
3149     u32 tmp;
3150     - outl(inl(base + 0x38), base + 0x38);
3151     + outl(inl(base + 0x38) | 0x00002000, base + 0x38);
3152     tmp = inl(base + 0x3c);
3153     outl(tmp | 0x01000000, base + 0x3c);
3154     - outl(tmp, base + 0x3c);
3155     + outl(tmp &= ~0x01000000, base + 0x3c);
3156     }
3157     }
3158     return 0;
3159     @@ -1545,6 +1545,7 @@ pci_wch_ch353_setup(struct serial_private *priv,
3160     #define PCI_DEVICE_ID_TITAN_800E 0xA014
3161     #define PCI_DEVICE_ID_TITAN_200EI 0xA016
3162     #define PCI_DEVICE_ID_TITAN_200EISI 0xA017
3163     +#define PCI_DEVICE_ID_TITAN_200V3 0xA306
3164     #define PCI_DEVICE_ID_TITAN_400V3 0xA310
3165     #define PCI_DEVICE_ID_TITAN_410V3 0xA312
3166     #define PCI_DEVICE_ID_TITAN_800V3 0xA314
3167     @@ -4140,6 +4141,9 @@ static struct pci_device_id serial_pci_tbl[] = {
3168     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EISI,
3169     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3170     pbn_oxsemi_2_4000000 },
3171     + { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200V3,
3172     + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3173     + pbn_b0_bt_2_921600 },
3174     { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400V3,
3175     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3176     pbn_b0_4_921600 },
3177     diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
3178     index 6b0f75eac8a2..41bb8387e80d 100644
3179     --- a/drivers/tty/serial/atmel_serial.c
3180     +++ b/drivers/tty/serial/atmel_serial.c
3181     @@ -824,9 +824,6 @@ static void atmel_release_rx_dma(struct uart_port *port)
3182     atmel_port->desc_rx = NULL;
3183     atmel_port->chan_rx = NULL;
3184     atmel_port->cookie_rx = -EINVAL;
3185     -
3186     - if (!atmel_port->is_usart)
3187     - del_timer_sync(&atmel_port->uart_timer);
3188     }
3189    
3190     static void atmel_rx_from_dma(struct uart_port *port)
3191     @@ -1228,9 +1225,6 @@ static void atmel_release_rx_pdc(struct uart_port *port)
3192     DMA_FROM_DEVICE);
3193     kfree(pdc->buf);
3194     }
3195     -
3196     - if (!atmel_port->is_usart)
3197     - del_timer_sync(&atmel_port->uart_timer);
3198     }
3199    
3200     static void atmel_rx_from_pdc(struct uart_port *port)
3201     @@ -1587,12 +1581,13 @@ static int atmel_startup(struct uart_port *port)
3202     /* enable xmit & rcvr */
3203     UART_PUT_CR(port, ATMEL_US_TXEN | ATMEL_US_RXEN);
3204    
3205     + setup_timer(&atmel_port->uart_timer,
3206     + atmel_uart_timer_callback,
3207     + (unsigned long)port);
3208     +
3209     if (atmel_use_pdc_rx(port)) {
3210     /* set UART timeout */
3211     if (!atmel_port->is_usart) {
3212     - setup_timer(&atmel_port->uart_timer,
3213     - atmel_uart_timer_callback,
3214     - (unsigned long)port);
3215     mod_timer(&atmel_port->uart_timer,
3216     jiffies + uart_poll_timeout(port));
3217     /* set USART timeout */
3218     @@ -1607,9 +1602,6 @@ static int atmel_startup(struct uart_port *port)
3219     } else if (atmel_use_dma_rx(port)) {
3220     /* set UART timeout */
3221     if (!atmel_port->is_usart) {
3222     - setup_timer(&atmel_port->uart_timer,
3223     - atmel_uart_timer_callback,
3224     - (unsigned long)port);
3225     mod_timer(&atmel_port->uart_timer,
3226     jiffies + uart_poll_timeout(port));
3227     /* set USART timeout */
3228     @@ -1633,12 +1625,30 @@ static int atmel_startup(struct uart_port *port)
3229     static void atmel_shutdown(struct uart_port *port)
3230     {
3231     struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
3232     +
3233     /*
3234     - * Ensure everything is stopped.
3235     + * Prevent any tasklets being scheduled during
3236     + * cleanup
3237     + */
3238     + del_timer_sync(&atmel_port->uart_timer);
3239     +
3240     + /*
3241     + * Clear out any scheduled tasklets before
3242     + * we destroy the buffers
3243     + */
3244     + tasklet_kill(&atmel_port->tasklet);
3245     +
3246     + /*
3247     + * Ensure everything is stopped and
3248     + * disable all interrupts, port and break condition.
3249     */
3250     atmel_stop_rx(port);
3251     atmel_stop_tx(port);
3252    
3253     + UART_PUT_CR(port, ATMEL_US_RSTSTA);
3254     + UART_PUT_IDR(port, -1);
3255     +
3256     +
3257     /*
3258     * Shut-down the DMA.
3259     */
3260     @@ -1648,10 +1658,10 @@ static void atmel_shutdown(struct uart_port *port)
3261     atmel_port->release_tx(port);
3262    
3263     /*
3264     - * Disable all interrupts, port and break condition.
3265     + * Reset ring buffer pointers
3266     */
3267     - UART_PUT_CR(port, ATMEL_US_RSTSTA);
3268     - UART_PUT_IDR(port, -1);
3269     + atmel_port->rx_ring.head = 0;
3270     + atmel_port->rx_ring.tail = 0;
3271    
3272     /*
3273     * Free the interrupt
3274     @@ -2424,11 +2434,12 @@ static int atmel_serial_remove(struct platform_device *pdev)
3275     struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
3276     int ret = 0;
3277    
3278     + tasklet_kill(&atmel_port->tasklet);
3279     +
3280     device_init_wakeup(&pdev->dev, 0);
3281    
3282     ret = uart_remove_one_port(&atmel_uart, port);
3283    
3284     - tasklet_kill(&atmel_port->tasklet);
3285     kfree(atmel_port->rx_ring.buf);
3286    
3287     /* "port" is allocated statically, so we shouldn't free it */
3288     diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
3289     index 1c94fc5257f4..5ad448d0fb7d 100644
3290     --- a/drivers/usb/chipidea/ci.h
3291     +++ b/drivers/usb/chipidea/ci.h
3292     @@ -135,6 +135,7 @@ struct hw_bank {
3293     * @id_event: indicates there is an id event, and handled at ci_otg_work
3294     * @b_sess_valid_event: indicates there is a vbus event, and handled
3295     * at ci_otg_work
3296     + * @imx28_write_fix: Freescale imx28 needs swp instruction for writing
3297     */
3298     struct ci_hdrc {
3299     struct device *dev;
3300     @@ -173,6 +174,7 @@ struct ci_hdrc {
3301     struct dentry *debugfs;
3302     bool id_event;
3303     bool b_sess_valid_event;
3304     + bool imx28_write_fix;
3305     };
3306    
3307     static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
3308     @@ -253,6 +255,26 @@ static inline u32 hw_read(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask)
3309     return ioread32(ci->hw_bank.regmap[reg]) & mask;
3310     }
3311    
3312     +#ifdef CONFIG_SOC_IMX28
3313     +static inline void imx28_ci_writel(u32 val, volatile void __iomem *addr)
3314     +{
3315     + __asm__ ("swp %0, %0, [%1]" : : "r"(val), "r"(addr));
3316     +}
3317     +#else
3318     +static inline void imx28_ci_writel(u32 val, volatile void __iomem *addr)
3319     +{
3320     +}
3321     +#endif
3322     +
3323     +static inline void __hw_write(struct ci_hdrc *ci, u32 val,
3324     + void __iomem *addr)
3325     +{
3326     + if (ci->imx28_write_fix)
3327     + imx28_ci_writel(val, addr);
3328     + else
3329     + iowrite32(val, addr);
3330     +}
3331     +
3332     /**
3333     * hw_write: writes to a hw register
3334     * @reg: register index
3335     @@ -266,7 +288,7 @@ static inline void hw_write(struct ci_hdrc *ci, enum ci_hw_regs reg,
3336     data = (ioread32(ci->hw_bank.regmap[reg]) & ~mask)
3337     | (data & mask);
3338    
3339     - iowrite32(data, ci->hw_bank.regmap[reg]);
3340     + __hw_write(ci, data, ci->hw_bank.regmap[reg]);
3341     }
3342    
3343     /**
3344     @@ -281,7 +303,7 @@ static inline u32 hw_test_and_clear(struct ci_hdrc *ci, enum ci_hw_regs reg,
3345     {
3346     u32 val = ioread32(ci->hw_bank.regmap[reg]) & mask;
3347    
3348     - iowrite32(val, ci->hw_bank.regmap[reg]);
3349     + __hw_write(ci, val, ci->hw_bank.regmap[reg]);
3350     return val;
3351     }
3352    
3353     diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
3354     index be822a2c1776..76a67fb6ea32 100644
3355     --- a/drivers/usb/chipidea/ci_hdrc_imx.c
3356     +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
3357     @@ -23,6 +23,26 @@
3358     #include "ci.h"
3359     #include "ci_hdrc_imx.h"
3360    
3361     +#define CI_HDRC_IMX_IMX28_WRITE_FIX BIT(0)
3362     +
3363     +struct ci_hdrc_imx_platform_flag {
3364     + unsigned int flags;
3365     +};
3366     +
3367     +static const struct ci_hdrc_imx_platform_flag imx27_usb_data = {
3368     +};
3369     +
3370     +static const struct ci_hdrc_imx_platform_flag imx28_usb_data = {
3371     + .flags = CI_HDRC_IMX_IMX28_WRITE_FIX,
3372     +};
3373     +
3374     +static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
3375     + { .compatible = "fsl,imx28-usb", .data = &imx28_usb_data},
3376     + { .compatible = "fsl,imx27-usb", .data = &imx27_usb_data},
3377     + { /* sentinel */ }
3378     +};
3379     +MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids);
3380     +
3381     struct ci_hdrc_imx_data {
3382     struct usb_phy *phy;
3383     struct platform_device *ci_pdev;
3384     @@ -82,6 +102,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
3385     CI_HDRC_DISABLE_STREAMING,
3386     };
3387     int ret;
3388     + const struct of_device_id *of_id =
3389     + of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev);
3390     + const struct ci_hdrc_imx_platform_flag *imx_platform_flag = of_id->data;
3391    
3392     data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
3393     if (!data) {
3394     @@ -121,6 +144,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
3395    
3396     pdata.phy = data->phy;
3397    
3398     + if (imx_platform_flag->flags & CI_HDRC_IMX_IMX28_WRITE_FIX)
3399     + pdata.flags |= CI_HDRC_IMX28_WRITE_FIX;
3400     +
3401     if (!pdev->dev.dma_mask)
3402     pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
3403     if (!pdev->dev.coherent_dma_mask)
3404     @@ -187,12 +213,6 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
3405     return 0;
3406     }
3407    
3408     -static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
3409     - { .compatible = "fsl,imx27-usb", },
3410     - { /* sentinel */ }
3411     -};
3412     -MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids);
3413     -
3414     static struct platform_driver ci_hdrc_imx_driver = {
3415     .probe = ci_hdrc_imx_probe,
3416     .remove = ci_hdrc_imx_remove,
3417     diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
3418     index d6a50b7bb4ca..7e8dceb4c634 100644
3419     --- a/drivers/usb/chipidea/core.c
3420     +++ b/drivers/usb/chipidea/core.c
3421     @@ -497,6 +497,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
3422     ci->transceiver = ci->platdata->phy;
3423     else
3424     ci->global_phy = true;
3425     + ci->imx28_write_fix = !!(ci->platdata->flags &
3426     + CI_HDRC_IMX28_WRITE_FIX);
3427    
3428     ret = hw_device_init(ci, base);
3429     if (ret < 0) {
3430     diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
3431     index 5d874d5cf500..e3b9f98dfcd6 100644
3432     --- a/drivers/usb/chipidea/host.c
3433     +++ b/drivers/usb/chipidea/host.c
3434     @@ -65,6 +65,7 @@ static int host_start(struct ci_hdrc *ci)
3435     ehci->caps = ci->hw_bank.cap;
3436     ehci->has_hostpc = ci->hw_bank.lpm;
3437     ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
3438     + ehci->imx28_write_fix = ci->imx28_write_fix;
3439    
3440     if (ci->platdata->reg_vbus) {
3441     ret = regulator_enable(ci->platdata->reg_vbus);
3442     diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
3443     index 2d9f090733bc..449bee07f4fe 100644
3444     --- a/drivers/usb/chipidea/otg.h
3445     +++ b/drivers/usb/chipidea/otg.h
3446     @@ -1,5 +1,5 @@
3447     /*
3448     - * Copyright (C) 2013 Freescale Semiconductor, Inc.
3449     + * Copyright (C) 2013-2014 Freescale Semiconductor, Inc.
3450     *
3451     * Author: Peter Chen
3452     *
3453     @@ -19,12 +19,12 @@ static inline void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits)
3454    
3455     static inline void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
3456     {
3457     - hw_write(ci, OP_OTGSC, bits, bits);
3458     + hw_write(ci, OP_OTGSC, bits | OTGSC_INT_STATUS_BITS, bits);
3459     }
3460    
3461     static inline void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
3462     {
3463     - hw_write(ci, OP_OTGSC, bits, 0);
3464     + hw_write(ci, OP_OTGSC, bits | OTGSC_INT_STATUS_BITS, 0);
3465     }
3466    
3467     int ci_hdrc_otg_init(struct ci_hdrc *ci);
3468     diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
3469     index d98fa254eaaf..94c26acfd5a4 100644
3470     --- a/drivers/usb/chipidea/udc.c
3471     +++ b/drivers/usb/chipidea/udc.c
3472     @@ -394,6 +394,14 @@ static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
3473     node->ptr->token = cpu_to_le32(length << __ffs(TD_TOTAL_BYTES));
3474     node->ptr->token &= cpu_to_le32(TD_TOTAL_BYTES);
3475     node->ptr->token |= cpu_to_le32(TD_STATUS_ACTIVE);
3476     + if (hwep->type == USB_ENDPOINT_XFER_ISOC && hwep->dir == TX) {
3477     + u32 mul = hwreq->req.length / hwep->ep.maxpacket;
3478     +
3479     + if (hwreq->req.length == 0
3480     + || hwreq->req.length % hwep->ep.maxpacket)
3481     + mul++;
3482     + node->ptr->token |= mul << __ffs(TD_MULTO);
3483     + }
3484    
3485     temp = (u32) (hwreq->req.dma + hwreq->req.actual);
3486     if (length) {
3487     @@ -516,10 +524,11 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
3488     hwep->qh.ptr->td.token &=
3489     cpu_to_le32(~(TD_STATUS_HALTED|TD_STATUS_ACTIVE));
3490    
3491     - if (hwep->type == USB_ENDPOINT_XFER_ISOC) {
3492     + if (hwep->type == USB_ENDPOINT_XFER_ISOC && hwep->dir == RX) {
3493     u32 mul = hwreq->req.length / hwep->ep.maxpacket;
3494    
3495     - if (hwreq->req.length % hwep->ep.maxpacket)
3496     + if (hwreq->req.length == 0
3497     + || hwreq->req.length % hwep->ep.maxpacket)
3498     mul++;
3499     hwep->qh.ptr->cap |= mul << __ffs(QH_MULT);
3500     }
3501     @@ -1172,6 +1181,12 @@ static int ep_enable(struct usb_ep *ep,
3502     if (hwep->num)
3503     cap |= QH_ZLT;
3504     cap |= (hwep->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT;
3505     + /*
3506     + * For ISO-TX, we set mult at QH as the largest value, and use
3507     + * MultO at TD as real mult value.
3508     + */
3509     + if (hwep->type == USB_ENDPOINT_XFER_ISOC && hwep->dir == TX)
3510     + cap |= 3 << __ffs(QH_MULT);
3511    
3512     hwep->qh.ptr->cap = cpu_to_le32(cap);
3513    
3514     diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
3515     index a6b2cabe7930..548d1996590f 100644
3516     --- a/drivers/usb/core/config.c
3517     +++ b/drivers/usb/core/config.c
3518     @@ -651,10 +651,6 @@ void usb_destroy_configuration(struct usb_device *dev)
3519     *
3520     * hub-only!! ... and only in reset path, or usb_new_device()
3521     * (used by real hubs and virtual root hubs)
3522     - *
3523     - * NOTE: if this is a WUSB device and is not authorized, we skip the
3524     - * whole thing. A non-authorized USB device has no
3525     - * configurations.
3526     */
3527     int usb_get_configuration(struct usb_device *dev)
3528     {
3529     @@ -666,8 +662,6 @@ int usb_get_configuration(struct usb_device *dev)
3530     struct usb_config_descriptor *desc;
3531    
3532     cfgno = 0;
3533     - if (dev->authorized == 0) /* Not really an error */
3534     - goto out_not_authorized;
3535     result = -ENOMEM;
3536     if (ncfg > USB_MAXCONFIG) {
3537     dev_warn(ddev, "too many configurations: %d, "
3538     @@ -751,7 +745,6 @@ int usb_get_configuration(struct usb_device *dev)
3539    
3540     err:
3541     kfree(desc);
3542     -out_not_authorized:
3543     dev->descriptor.bNumConfigurations = cfgno;
3544     err2:
3545     if (result == -ENOMEM)
3546     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3547     index c5c366790e6a..e3f7e41818f8 100644
3548     --- a/drivers/usb/core/hub.c
3549     +++ b/drivers/usb/core/hub.c
3550     @@ -1610,7 +1610,7 @@ static void hub_disconnect(struct usb_interface *intf)
3551     {
3552     struct usb_hub *hub = usb_get_intfdata(intf);
3553     struct usb_device *hdev = interface_to_usbdev(intf);
3554     - int i;
3555     + int port1;
3556    
3557     /* Take the hub off the event list and don't let it be added again */
3558     spin_lock_irq(&hub_event_lock);
3559     @@ -1625,11 +1625,15 @@ static void hub_disconnect(struct usb_interface *intf)
3560     hub->error = 0;
3561     hub_quiesce(hub, HUB_DISCONNECT);
3562    
3563     - usb_set_intfdata (intf, NULL);
3564     + /* Avoid races with recursively_mark_NOTATTACHED() */
3565     + spin_lock_irq(&device_state_lock);
3566     + port1 = hdev->maxchild;
3567     + hdev->maxchild = 0;
3568     + usb_set_intfdata(intf, NULL);
3569     + spin_unlock_irq(&device_state_lock);
3570    
3571     - for (i = 0; i < hdev->maxchild; i++)
3572     - usb_hub_remove_port_device(hub, i + 1);
3573     - hub->hdev->maxchild = 0;
3574     + for (; port1 > 0; --port1)
3575     + usb_hub_remove_port_device(hub, port1);
3576    
3577     if (hub->hdev->speed == USB_SPEED_HIGH)
3578     highspeed_hubs--;
3579     @@ -2238,18 +2242,13 @@ static int usb_enumerate_device(struct usb_device *udev)
3580     return err;
3581     }
3582     }
3583     - if (udev->wusb == 1 && udev->authorized == 0) {
3584     - udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3585     - udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3586     - udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3587     - }
3588     - else {
3589     - /* read the standard strings and cache them if present */
3590     - udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
3591     - udev->manufacturer = usb_cache_string(udev,
3592     - udev->descriptor.iManufacturer);
3593     - udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
3594     - }
3595     +
3596     + /* read the standard strings and cache them if present */
3597     + udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
3598     + udev->manufacturer = usb_cache_string(udev,
3599     + udev->descriptor.iManufacturer);
3600     + udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
3601     +
3602     err = usb_enumerate_device_otg(udev);
3603     if (err < 0)
3604     return err;
3605     @@ -2431,16 +2430,6 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
3606     usb_dev->authorized = 0;
3607     usb_set_configuration(usb_dev, -1);
3608    
3609     - kfree(usb_dev->product);
3610     - usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3611     - kfree(usb_dev->manufacturer);
3612     - usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3613     - kfree(usb_dev->serial);
3614     - usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
3615     -
3616     - usb_destroy_configuration(usb_dev);
3617     - usb_dev->descriptor.bNumConfigurations = 0;
3618     -
3619     out_unauthorized:
3620     usb_unlock_device(usb_dev);
3621     return 0;
3622     @@ -2468,17 +2457,7 @@ int usb_authorize_device(struct usb_device *usb_dev)
3623     goto error_device_descriptor;
3624     }
3625    
3626     - kfree(usb_dev->product);
3627     - usb_dev->product = NULL;
3628     - kfree(usb_dev->manufacturer);
3629     - usb_dev->manufacturer = NULL;
3630     - kfree(usb_dev->serial);
3631     - usb_dev->serial = NULL;
3632     -
3633     usb_dev->authorized = 1;
3634     - result = usb_enumerate_device(usb_dev);
3635     - if (result < 0)
3636     - goto error_enumerate;
3637     /* Choose and set the configuration. This registers the interfaces
3638     * with the driver core and lets interface drivers bind to them.
3639     */
3640     @@ -2494,7 +2473,6 @@ int usb_authorize_device(struct usb_device *usb_dev)
3641     }
3642     dev_info(&usb_dev->dev, "authorized to connect\n");
3643    
3644     -error_enumerate:
3645     error_device_descriptor:
3646     usb_autosuspend_device(usb_dev);
3647     error_autoresume:
3648     diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
3649     index 291db7d09f22..2a1f38d209f0 100644
3650     --- a/drivers/usb/host/ehci.h
3651     +++ b/drivers/usb/host/ehci.h
3652     @@ -203,6 +203,7 @@ struct ehci_hcd { /* one per controller */
3653     unsigned has_synopsys_hc_bug:1; /* Synopsys HC */
3654     unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
3655     unsigned need_oc_pp_cycle:1; /* MPC834X port power */
3656     + unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
3657    
3658     /* required for usb32 quirk */
3659     #define OHCI_CTRL_HCFS (3 << 6)
3660     @@ -679,6 +680,18 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
3661     #endif
3662     }
3663    
3664     +#ifdef CONFIG_SOC_IMX28
3665     +static inline void imx28_ehci_writel(const unsigned int val,
3666     + volatile __u32 __iomem *addr)
3667     +{
3668     + __asm__ ("swp %0, %0, [%1]" : : "r"(val), "r"(addr));
3669     +}
3670     +#else
3671     +static inline void imx28_ehci_writel(const unsigned int val,
3672     + volatile __u32 __iomem *addr)
3673     +{
3674     +}
3675     +#endif
3676     static inline void ehci_writel(const struct ehci_hcd *ehci,
3677     const unsigned int val, __u32 __iomem *regs)
3678     {
3679     @@ -687,7 +700,10 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,
3680     writel_be(val, regs) :
3681     writel(val, regs);
3682     #else
3683     - writel(val, regs);
3684     + if (ehci->imx28_write_fix)
3685     + imx28_ehci_writel(val, regs);
3686     + else
3687     + writel(val, regs);
3688     #endif
3689     }
3690    
3691     diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
3692     index 55fc0c39b7e1..fec3c8654ccd 100644
3693     --- a/drivers/usb/host/xhci-ring.c
3694     +++ b/drivers/usb/host/xhci-ring.c
3695     @@ -2964,7 +2964,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
3696     if (num_trbs >= TRBS_PER_SEGMENT) {
3697     xhci_err(xhci, "Too many fragments %d, max %d\n",
3698     num_trbs, TRBS_PER_SEGMENT - 1);
3699     - return -ENOMEM;
3700     + return -EINVAL;
3701     }
3702    
3703     nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
3704     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
3705     index ed6c186a5393..1dceec25223e 100644
3706     --- a/drivers/usb/host/xhci.c
3707     +++ b/drivers/usb/host/xhci.c
3708     @@ -321,6 +321,9 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
3709     struct usb_hcd *hcd = xhci_to_hcd(xhci);
3710     struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
3711    
3712     + if (xhci->quirks & XHCI_PLAT)
3713     + return;
3714     +
3715     xhci_free_irq(xhci);
3716    
3717     if (xhci->msix_entries) {
3718     @@ -4724,8 +4727,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
3719     struct device *dev = hcd->self.controller;
3720     int retval;
3721    
3722     - /* Accept arbitrarily long scatter-gather lists */
3723     - hcd->self.sg_tablesize = ~0;
3724     + /* Limit the block layer scatter-gather lists to half a segment. */
3725     + hcd->self.sg_tablesize = TRBS_PER_SEGMENT / 2;
3726    
3727     /* support to build packet from discontinuous buffers */
3728     hcd->self.no_sg_constraint = 1;
3729     diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
3730     index ed3a425de8ce..6b3164c75c98 100644
3731     --- a/drivers/usb/host/xhci.h
3732     +++ b/drivers/usb/host/xhci.h
3733     @@ -1262,7 +1262,7 @@ union xhci_trb {
3734     * since the command ring is 64-byte aligned.
3735     * It must also be greater than 16.
3736     */
3737     -#define TRBS_PER_SEGMENT 64
3738     +#define TRBS_PER_SEGMENT 256
3739     /* Allow two commands + a link TRB, along with any reserved command TRBs */
3740     #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3)
3741     #define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
3742     diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
3743     index b461311a2ae7..ce13e61b7d55 100644
3744     --- a/drivers/usb/serial/cypress_m8.h
3745     +++ b/drivers/usb/serial/cypress_m8.h
3746     @@ -63,7 +63,7 @@
3747     #define UART_DSR 0x20 /* data set ready - flow control - device to host */
3748     #define CONTROL_RTS 0x10 /* request to send - flow control - host to device */
3749     #define UART_CTS 0x10 /* clear to send - flow control - device to host */
3750     -#define UART_RI 0x10 /* ring indicator - modem - device to host */
3751     +#define UART_RI 0x80 /* ring indicator - modem - device to host */
3752     #define UART_CD 0x40 /* carrier detect - modem - device to host */
3753     #define CYP_ERROR 0x08 /* received from input report - device to host */
3754     /* Note - the below has nothing to do with the "feature report" reset */
3755     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
3756     index dccb4db98ea1..6f1cbbf51ae8 100644
3757     --- a/drivers/usb/serial/ftdi_sio.c
3758     +++ b/drivers/usb/serial/ftdi_sio.c
3759     @@ -2116,10 +2116,20 @@ static void ftdi_set_termios(struct tty_struct *tty,
3760     }
3761    
3762     /*
3763     - * All FTDI UART chips are limited to CS7/8. We won't pretend to
3764     + * All FTDI UART chips are limited to CS7/8. We shouldn't pretend to
3765     * support CS5/6 and revert the CSIZE setting instead.
3766     + *
3767     + * CS5 however is used to control some smartcard readers which abuse
3768     + * this limitation to switch modes. Original FTDI chips fall back to
3769     + * eight data bits.
3770     + *
3771     + * TODO: Implement a quirk to only allow this with mentioned
3772     + * readers. One I know of (Argolis Smartreader V1)
3773     + * returns "USB smartcard server" as iInterface string.
3774     + * The vendor didn't bother with a custom VID/PID of
3775     + * course.
3776     */
3777     - if ((C_CSIZE(tty) != CS8) && (C_CSIZE(tty) != CS7)) {
3778     + if (C_CSIZE(tty) == CS6) {
3779     dev_warn(ddev, "requested CSIZE setting not supported\n");
3780    
3781     termios->c_cflag &= ~CSIZE;
3782     @@ -2166,6 +2176,9 @@ no_skip:
3783     urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
3784     }
3785     switch (cflag & CSIZE) {
3786     + case CS5:
3787     + dev_dbg(ddev, "Setting CS5 quirk\n");
3788     + break;
3789     case CS7:
3790     urb_value |= 7;
3791     dev_dbg(ddev, "Setting CS7\n");
3792     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
3793     index cc7a24154490..5c86f57e4afa 100644
3794     --- a/drivers/usb/serial/option.c
3795     +++ b/drivers/usb/serial/option.c
3796     @@ -320,6 +320,9 @@ static void option_instat_callback(struct urb *urb);
3797     * It seems to contain a Qualcomm QSC6240/6290 chipset */
3798     #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603
3799    
3800     +/* iBall 3.5G connect wireless modem */
3801     +#define IBALL_3_5G_CONNECT 0x9605
3802     +
3803     /* Zoom */
3804     #define ZOOM_PRODUCT_4597 0x9607
3805    
3806     @@ -1447,6 +1450,17 @@ static const struct usb_device_id option_ids[] = {
3807     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
3808     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
3809     .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
3810     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
3811     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) },
3812     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) },
3813     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
3814     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8e, 0xff, 0xff, 0xff) },
3815     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8f, 0xff, 0xff, 0xff) },
3816     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff90, 0xff, 0xff, 0xff) },
3817     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff91, 0xff, 0xff, 0xff) },
3818     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) },
3819     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
3820     + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
3821    
3822     /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */
3823     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
3824     @@ -1489,6 +1503,7 @@ static const struct usb_device_id option_ids[] = {
3825     .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
3826     },
3827     { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
3828     + { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
3829     { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
3830     /* Pirelli */
3831     { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
3832     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
3833     index 1e3318dfa1cb..beb8edce4ef2 100644
3834     --- a/drivers/usb/serial/pl2303.c
3835     +++ b/drivers/usb/serial/pl2303.c
3836     @@ -142,6 +142,8 @@ struct pl2303_private {
3837     spinlock_t lock;
3838     u8 line_control;
3839     u8 line_status;
3840     +
3841     + u8 line_settings[7];
3842     };
3843    
3844     static int pl2303_vendor_read(__u16 value, __u16 index,
3845     @@ -339,11 +341,6 @@ static void pl2303_set_termios(struct tty_struct *tty,
3846     int i;
3847     u8 control;
3848    
3849     - /*
3850     - * The PL2303 is reported to lose bytes if you change serial settings
3851     - * even to the same values as before. Thus we actually need to filter
3852     - * in this specific case.
3853     - */
3854     if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
3855     return;
3856    
3857     @@ -428,10 +425,29 @@ static void pl2303_set_termios(struct tty_struct *tty,
3858     dev_dbg(&port->dev, "parity = none\n");
3859     }
3860    
3861     - i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
3862     - SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
3863     - 0, 0, buf, 7, 100);
3864     - dev_dbg(&port->dev, "0x21:0x20:0:0 %d\n", i);
3865     + /*
3866     + * Some PL2303 are known to lose bytes if you change serial settings
3867     + * even to the same values as before. Thus we actually need to filter
3868     + * in this specific case.
3869     + *
3870     + * Note that the tty_termios_hw_change check above is not sufficient
3871     + * as a previously requested baud rate may differ from the one
3872     + * actually used (and stored in old_termios).
3873     + *
3874     + * NOTE: No additional locking needed for line_settings as it is
3875     + * only used in set_termios, which is serialised against itself.
3876     + */
3877     + if (!old_termios || memcmp(buf, priv->line_settings, 7)) {
3878     + i = usb_control_msg(serial->dev,
3879     + usb_sndctrlpipe(serial->dev, 0),
3880     + SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
3881     + 0, 0, buf, 7, 100);
3882     +
3883     + dev_dbg(&port->dev, "0x21:0x20:0:0 %d\n", i);
3884     +
3885     + if (i == 7)
3886     + memcpy(priv->line_settings, buf, 7);
3887     + }
3888    
3889     /* change control lines if we are switching to or from B0 */
3890     spin_lock_irqsave(&priv->lock, flags);
3891     diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
3892     index de32cfa5bfa6..ad06255c2ade 100644
3893     --- a/drivers/usb/storage/unusual_devs.h
3894     +++ b/drivers/usb/storage/unusual_devs.h
3895     @@ -234,6 +234,13 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
3896     USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3897     US_FL_MAX_SECTORS_64 ),
3898    
3899     +/* Patch submitted by Mikhail Zolotaryov <lebon@lebon.org.ua> */
3900     +UNUSUAL_DEV( 0x0421, 0x06aa, 0x1110, 0x1110,
3901     + "Nokia",
3902     + "502",
3903     + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3904     + US_FL_MAX_SECTORS_64 ),
3905     +
3906     #ifdef NO_SDDR09
3907     UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
3908     "Microtech",
3909     diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
3910     index d58bef130a41..b256ddc1cb53 100644
3911     --- a/fs/btrfs/extent-tree.c
3912     +++ b/fs/btrfs/extent-tree.c
3913     @@ -7718,7 +7718,7 @@ out:
3914     */
3915     if (!for_reloc && root_dropped == false)
3916     btrfs_add_dead_root(root);
3917     - if (err)
3918     + if (err && err != -EAGAIN)
3919     btrfs_std_error(root->fs_info, err);
3920     return err;
3921     }
3922     diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
3923     index 8747feb77ec9..669eb53273c0 100644
3924     --- a/fs/btrfs/ioctl.c
3925     +++ b/fs/btrfs/ioctl.c
3926     @@ -1548,6 +1548,12 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
3927     printk(KERN_INFO "btrfs: Snapshot src from "
3928     "another FS\n");
3929     ret = -EINVAL;
3930     + } else if (!inode_owner_or_capable(src_inode)) {
3931     + /*
3932     + * Subvolume creation is not restricted, but snapshots
3933     + * are limited to own subvolumes only
3934     + */
3935     + ret = -EPERM;
3936     } else {
3937     ret = btrfs_mksubvol(&file->f_path, name, namelen,
3938     BTRFS_I(src_inode)->root,
3939     diff --git a/fs/dcache.c b/fs/dcache.c
3940     index f27c1d12a1fa..4021e0172602 100644
3941     --- a/fs/dcache.c
3942     +++ b/fs/dcache.c
3943     @@ -3140,7 +3140,6 @@ restart:
3944     read_seqbegin_or_lock(&rename_lock, &seq);
3945     while (!IS_ROOT(dentry)) {
3946     struct dentry *parent = dentry->d_parent;
3947     - int error;
3948    
3949     prefetch(parent);
3950     error = prepend_name(&end, &len, &dentry->d_name);
3951     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
3952     index d9ecbf1113a7..46b366897553 100644
3953     --- a/fs/ext4/inline.c
3954     +++ b/fs/ext4/inline.c
3955     @@ -1925,9 +1925,11 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
3956     }
3957    
3958     /* Clear the content within i_blocks. */
3959     - if (i_size < EXT4_MIN_INLINE_DATA_SIZE)
3960     - memset(ext4_raw_inode(&is.iloc)->i_block + i_size, 0,
3961     - EXT4_MIN_INLINE_DATA_SIZE - i_size);
3962     + if (i_size < EXT4_MIN_INLINE_DATA_SIZE) {
3963     + void *p = (void *) ext4_raw_inode(&is.iloc)->i_block;
3964     + memset(p + i_size, 0,
3965     + EXT4_MIN_INLINE_DATA_SIZE - i_size);
3966     + }
3967    
3968     EXT4_I(inode)->i_inline_size = i_size <
3969     EXT4_MIN_INLINE_DATA_SIZE ?
3970     diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c
3971     index cdb84a838068..58b5106186d0 100644
3972     --- a/fs/hpfs/alloc.c
3973     +++ b/fs/hpfs/alloc.c
3974     @@ -8,6 +8,58 @@
3975    
3976     #include "hpfs_fn.h"
3977    
3978     +static void hpfs_claim_alloc(struct super_block *s, secno sec)
3979     +{
3980     + struct hpfs_sb_info *sbi = hpfs_sb(s);
3981     + if (sbi->sb_n_free != (unsigned)-1) {
3982     + if (unlikely(!sbi->sb_n_free)) {
3983     + hpfs_error(s, "free count underflow, allocating sector %08x", sec);
3984     + sbi->sb_n_free = -1;
3985     + return;
3986     + }
3987     + sbi->sb_n_free--;
3988     + }
3989     +}
3990     +
3991     +static void hpfs_claim_free(struct super_block *s, secno sec)
3992     +{
3993     + struct hpfs_sb_info *sbi = hpfs_sb(s);
3994     + if (sbi->sb_n_free != (unsigned)-1) {
3995     + if (unlikely(sbi->sb_n_free >= sbi->sb_fs_size)) {
3996     + hpfs_error(s, "free count overflow, freeing sector %08x", sec);
3997     + sbi->sb_n_free = -1;
3998     + return;
3999     + }
4000     + sbi->sb_n_free++;
4001     + }
4002     +}
4003     +
4004     +static void hpfs_claim_dirband_alloc(struct super_block *s, secno sec)
4005     +{
4006     + struct hpfs_sb_info *sbi = hpfs_sb(s);
4007     + if (sbi->sb_n_free_dnodes != (unsigned)-1) {
4008     + if (unlikely(!sbi->sb_n_free_dnodes)) {
4009     + hpfs_error(s, "dirband free count underflow, allocating sector %08x", sec);
4010     + sbi->sb_n_free_dnodes = -1;
4011     + return;
4012     + }
4013     + sbi->sb_n_free_dnodes--;
4014     + }
4015     +}
4016     +
4017     +static void hpfs_claim_dirband_free(struct super_block *s, secno sec)
4018     +{
4019     + struct hpfs_sb_info *sbi = hpfs_sb(s);
4020     + if (sbi->sb_n_free_dnodes != (unsigned)-1) {
4021     + if (unlikely(sbi->sb_n_free_dnodes >= sbi->sb_dirband_size / 4)) {
4022     + hpfs_error(s, "dirband free count overflow, freeing sector %08x", sec);
4023     + sbi->sb_n_free_dnodes = -1;
4024     + return;
4025     + }
4026     + sbi->sb_n_free_dnodes++;
4027     + }
4028     +}
4029     +
4030     /*
4031     * Check if a sector is allocated in bitmap
4032     * This is really slow. Turned on only if chk==2
4033     @@ -203,9 +255,15 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa
4034     }
4035     sec = 0;
4036     ret:
4037     + if (sec) {
4038     + i = 0;
4039     + do
4040     + hpfs_claim_alloc(s, sec + i);
4041     + while (unlikely(++i < n));
4042     + }
4043     if (sec && f_p) {
4044     for (i = 0; i < forward; i++) {
4045     - if (!hpfs_alloc_if_possible(s, sec + i + 1)) {
4046     + if (!hpfs_alloc_if_possible(s, sec + n + i)) {
4047     hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i);
4048     sec = 0;
4049     break;
4050     @@ -228,6 +286,7 @@ static secno alloc_in_dirband(struct super_block *s, secno near)
4051     nr >>= 2;
4052     sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0);
4053     if (!sec) return 0;
4054     + hpfs_claim_dirband_alloc(s, sec);
4055     return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start;
4056     }
4057    
4058     @@ -242,6 +301,7 @@ int hpfs_alloc_if_possible(struct super_block *s, secno sec)
4059     bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f)));
4060     hpfs_mark_4buffers_dirty(&qbh);
4061     hpfs_brelse4(&qbh);
4062     + hpfs_claim_alloc(s, sec);
4063     return 1;
4064     }
4065     hpfs_brelse4(&qbh);
4066     @@ -275,6 +335,7 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n)
4067     return;
4068     }
4069     bmp[(sec & 0x3fff) >> 5] |= cpu_to_le32(1 << (sec & 0x1f));
4070     + hpfs_claim_free(s, sec);
4071     if (!--n) {
4072     hpfs_mark_4buffers_dirty(&qbh);
4073     hpfs_brelse4(&qbh);
4074     @@ -359,6 +420,7 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno)
4075     bmp[ssec >> 5] |= cpu_to_le32(1 << (ssec & 0x1f));
4076     hpfs_mark_4buffers_dirty(&qbh);
4077     hpfs_brelse4(&qbh);
4078     + hpfs_claim_dirband_free(s, dno);
4079     }
4080     }
4081    
4082     @@ -366,7 +428,7 @@ struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near,
4083     dnode_secno *dno, struct quad_buffer_head *qbh)
4084     {
4085     struct dnode *d;
4086     - if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) {
4087     + if (hpfs_get_free_dnodes(s) > FREE_DNODES_ADD) {
4088     if (!(*dno = alloc_in_dirband(s, near)))
4089     if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL;
4090     } else {
4091     diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
4092     index 1b398636e990..c65f0bf326a1 100644
4093     --- a/fs/hpfs/hpfs_fn.h
4094     +++ b/fs/hpfs/hpfs_fn.h
4095     @@ -311,7 +311,7 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
4096     __printf(2, 3)
4097     void hpfs_error(struct super_block *, const char *, ...);
4098     int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
4099     -unsigned hpfs_count_one_bitmap(struct super_block *, secno);
4100     +unsigned hpfs_get_free_dnodes(struct super_block *);
4101    
4102     /*
4103     * local time (HPFS) to GMT (Unix)
4104     diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
4105     index 4334cda8dba1..3d6f8972d06e 100644
4106     --- a/fs/hpfs/super.c
4107     +++ b/fs/hpfs/super.c
4108     @@ -115,7 +115,7 @@ static void hpfs_put_super(struct super_block *s)
4109     kfree(sbi);
4110     }
4111    
4112     -unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
4113     +static unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
4114     {
4115     struct quad_buffer_head qbh;
4116     unsigned long *bits;
4117     @@ -123,7 +123,7 @@ unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
4118    
4119     bits = hpfs_map_4sectors(s, secno, &qbh, 0);
4120     if (!bits)
4121     - return 0;
4122     + return (unsigned)-1;
4123     count = bitmap_weight(bits, 2048 * BITS_PER_BYTE);
4124     hpfs_brelse4(&qbh);
4125     return count;
4126     @@ -138,30 +138,45 @@ static unsigned count_bitmaps(struct super_block *s)
4127     hpfs_prefetch_bitmap(s, n);
4128     }
4129     for (n = 0; n < n_bands; n++) {
4130     + unsigned c;
4131     hpfs_prefetch_bitmap(s, n + COUNT_RD_AHEAD);
4132     - count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n]));
4133     + c = hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n]));
4134     + if (c != (unsigned)-1)
4135     + count += c;
4136     }
4137     return count;
4138     }
4139    
4140     +unsigned hpfs_get_free_dnodes(struct super_block *s)
4141     +{
4142     + struct hpfs_sb_info *sbi = hpfs_sb(s);
4143     + if (sbi->sb_n_free_dnodes == (unsigned)-1) {
4144     + unsigned c = hpfs_count_one_bitmap(s, sbi->sb_dmap);
4145     + if (c == (unsigned)-1)
4146     + return 0;
4147     + sbi->sb_n_free_dnodes = c;
4148     + }
4149     + return sbi->sb_n_free_dnodes;
4150     +}
4151     +
4152     static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
4153     {
4154     struct super_block *s = dentry->d_sb;
4155     struct hpfs_sb_info *sbi = hpfs_sb(s);
4156     u64 id = huge_encode_dev(s->s_bdev->bd_dev);
4157     +
4158     hpfs_lock(s);
4159    
4160     - /*if (sbi->sb_n_free == -1) {*/
4161     + if (sbi->sb_n_free == (unsigned)-1)
4162     sbi->sb_n_free = count_bitmaps(s);
4163     - sbi->sb_n_free_dnodes = hpfs_count_one_bitmap(s, sbi->sb_dmap);
4164     - /*}*/
4165     +
4166     buf->f_type = s->s_magic;
4167     buf->f_bsize = 512;
4168     buf->f_blocks = sbi->sb_fs_size;
4169     buf->f_bfree = sbi->sb_n_free;
4170     buf->f_bavail = sbi->sb_n_free;
4171     buf->f_files = sbi->sb_dirband_size / 4;
4172     - buf->f_ffree = sbi->sb_n_free_dnodes;
4173     + buf->f_ffree = hpfs_get_free_dnodes(s);
4174     buf->f_fsid.val[0] = (u32)id;
4175     buf->f_fsid.val[1] = (u32)(id >> 32);
4176     buf->f_namelen = 254;
4177     diff --git a/fs/mount.h b/fs/mount.h
4178     index 64a858143ff9..68d80bdcd081 100644
4179     --- a/fs/mount.h
4180     +++ b/fs/mount.h
4181     @@ -73,7 +73,7 @@ static inline int mnt_has_parent(struct mount *mnt)
4182     static inline int is_mounted(struct vfsmount *mnt)
4183     {
4184     /* neither detached nor internal? */
4185     - return !IS_ERR_OR_NULL(real_mount(mnt));
4186     + return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
4187     }
4188    
4189     extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
4190     diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
4191     index 0393270466c3..6125579b5207 100644
4192     --- a/include/linux/hugetlb.h
4193     +++ b/include/linux/hugetlb.h
4194     @@ -31,6 +31,7 @@ struct hugepage_subpool *hugepage_new_subpool(long nr_blocks);
4195     void hugepage_put_subpool(struct hugepage_subpool *spool);
4196    
4197     int PageHuge(struct page *page);
4198     +int PageHeadHuge(struct page *page_head);
4199    
4200     void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
4201     int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
4202     @@ -104,6 +105,11 @@ static inline int PageHuge(struct page *page)
4203     return 0;
4204     }
4205    
4206     +static inline int PageHeadHuge(struct page *page_head)
4207     +{
4208     + return 0;
4209     +}
4210     +
4211     static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
4212     {
4213     }
4214     diff --git a/include/linux/libata.h b/include/linux/libata.h
4215     index 9b503376738f..bec6dbe939a0 100644
4216     --- a/include/linux/libata.h
4217     +++ b/include/linux/libata.h
4218     @@ -419,6 +419,8 @@ enum {
4219     ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */
4220     ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */
4221     ATA_HORKAGE_NO_NCQ_TRIM = (1 << 19), /* don't use queued TRIM */
4222     + ATA_HORKAGE_NOLPM = (1 << 20), /* don't use LPM */
4223     + ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21), /* some WDs have broken LPM */
4224    
4225     /* DMA mask for user DMA control: User visible values; DO NOT
4226     renumber */
4227     diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
4228     index 7d399671a566..708bd119627f 100644
4229     --- a/include/linux/usb/chipidea.h
4230     +++ b/include/linux/usb/chipidea.h
4231     @@ -24,6 +24,7 @@ struct ci_hdrc_platform_data {
4232     * but otg is not supported (no register otgsc).
4233     */
4234     #define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4)
4235     +#define CI_HDRC_IMX28_WRITE_FIX BIT(5)
4236     enum usb_dr_mode dr_mode;
4237     #define CI_HDRC_CONTROLLER_RESET_EVENT 0
4238     #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
4239     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
4240     index 0b7656e804d1..f0a4ca4cc219 100644
4241     --- a/mm/hugetlb.c
4242     +++ b/mm/hugetlb.c
4243     @@ -736,6 +736,23 @@ int PageHuge(struct page *page)
4244     }
4245     EXPORT_SYMBOL_GPL(PageHuge);
4246    
4247     +/*
4248     + * PageHeadHuge() only returns true for hugetlbfs head page, but not for
4249     + * normal or transparent huge pages.
4250     + */
4251     +int PageHeadHuge(struct page *page_head)
4252     +{
4253     + compound_page_dtor *dtor;
4254     +
4255     + if (!PageHead(page_head))
4256     + return 0;
4257     +
4258     + dtor = get_compound_page_dtor(page_head);
4259     +
4260     + return dtor == free_huge_page;
4261     +}
4262     +EXPORT_SYMBOL_GPL(PageHeadHuge);
4263     +
4264     pgoff_t __basepage_index(struct page *page)
4265     {
4266     struct page *page_head = compound_head(page);
4267     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
4268     index 6b22d8f9bfb8..927a69cf354a 100644
4269     --- a/mm/mempolicy.c
4270     +++ b/mm/mempolicy.c
4271     @@ -2857,7 +2857,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
4272     */
4273     VM_BUG_ON(maxlen < strlen("interleave") + strlen("relative") + 16);
4274    
4275     - if (!pol || pol == &default_policy)
4276     + if (!pol || pol == &default_policy || (pol->flags & MPOL_F_MORON))
4277     mode = MPOL_DEFAULT;
4278     else
4279     mode = pol->mode;
4280     diff --git a/mm/swap.c b/mm/swap.c
4281     index 759c3caf44bd..0c8f7a471925 100644
4282     --- a/mm/swap.c
4283     +++ b/mm/swap.c
4284     @@ -82,19 +82,6 @@ static void __put_compound_page(struct page *page)
4285    
4286     static void put_compound_page(struct page *page)
4287     {
4288     - /*
4289     - * hugetlbfs pages cannot be split from under us. If this is a
4290     - * hugetlbfs page, check refcount on head page and release the page if
4291     - * the refcount becomes zero.
4292     - */
4293     - if (PageHuge(page)) {
4294     - page = compound_head(page);
4295     - if (put_page_testzero(page))
4296     - __put_compound_page(page);
4297     -
4298     - return;
4299     - }
4300     -
4301     if (unlikely(PageTail(page))) {
4302     /* __split_huge_page_refcount can run under us */
4303     struct page *page_head = compound_trans_head(page);
4304     @@ -111,14 +98,31 @@ static void put_compound_page(struct page *page)
4305     * still hot on arches that do not support
4306     * this_cpu_cmpxchg_double().
4307     */
4308     - if (PageSlab(page_head)) {
4309     - if (PageTail(page)) {
4310     + if (PageSlab(page_head) || PageHeadHuge(page_head)) {
4311     + if (likely(PageTail(page))) {
4312     + /*
4313     + * __split_huge_page_refcount
4314     + * cannot race here.
4315     + */
4316     + VM_BUG_ON(!PageHead(page_head));
4317     + atomic_dec(&page->_mapcount);
4318     if (put_page_testzero(page_head))
4319     VM_BUG_ON(1);
4320     -
4321     - atomic_dec(&page->_mapcount);
4322     - goto skip_lock_tail;
4323     + if (put_page_testzero(page_head))
4324     + __put_compound_page(page_head);
4325     + return;
4326     } else
4327     + /*
4328     + * __split_huge_page_refcount
4329     + * run before us, "page" was a
4330     + * THP tail. The split
4331     + * page_head has been freed
4332     + * and reallocated as slab or
4333     + * hugetlbfs page of smaller
4334     + * order (only possible if
4335     + * reallocated as slab on
4336     + * x86).
4337     + */
4338     goto skip_lock;
4339     }
4340     /*
4341     @@ -132,8 +136,27 @@ static void put_compound_page(struct page *page)
4342     /* __split_huge_page_refcount run before us */
4343     compound_unlock_irqrestore(page_head, flags);
4344     skip_lock:
4345     - if (put_page_testzero(page_head))
4346     - __put_single_page(page_head);
4347     + if (put_page_testzero(page_head)) {
4348     + /*
4349     + * The head page may have been
4350     + * freed and reallocated as a
4351     + * compound page of smaller
4352     + * order and then freed again.
4353     + * All we know is that it
4354     + * cannot have become: a THP
4355     + * page, a compound page of
4356     + * higher order, a tail page.
4357     + * That is because we still
4358     + * hold the refcount of the
4359     + * split THP tail and
4360     + * page_head was the THP head
4361     + * before the split.
4362     + */
4363     + if (PageHead(page_head))
4364     + __put_compound_page(page_head);
4365     + else
4366     + __put_single_page(page_head);
4367     + }
4368     out_put_single:
4369     if (put_page_testzero(page))
4370     __put_single_page(page);
4371     @@ -155,7 +178,6 @@ out_put_single:
4372     VM_BUG_ON(atomic_read(&page->_count) != 0);
4373     compound_unlock_irqrestore(page_head, flags);
4374    
4375     -skip_lock_tail:
4376     if (put_page_testzero(page_head)) {
4377     if (PageHead(page_head))
4378     __put_compound_page(page_head);
4379     @@ -198,51 +220,52 @@ bool __get_page_tail(struct page *page)
4380     * proper PT lock that already serializes against
4381     * split_huge_page().
4382     */
4383     + unsigned long flags;
4384     bool got = false;
4385     - struct page *page_head;
4386     -
4387     - /*
4388     - * If this is a hugetlbfs page it cannot be split under us. Simply
4389     - * increment refcount for the head page.
4390     - */
4391     - if (PageHuge(page)) {
4392     - page_head = compound_head(page);
4393     - atomic_inc(&page_head->_count);
4394     - got = true;
4395     - } else {
4396     - unsigned long flags;
4397     + struct page *page_head = compound_trans_head(page);
4398    
4399     - page_head = compound_trans_head(page);
4400     - if (likely(page != page_head &&
4401     - get_page_unless_zero(page_head))) {
4402     -
4403     - /* Ref to put_compound_page() comment. */
4404     - if (PageSlab(page_head)) {
4405     - if (likely(PageTail(page))) {
4406     - __get_page_tail_foll(page, false);
4407     - return true;
4408     - } else {
4409     - put_page(page_head);
4410     - return false;
4411     - }
4412     - }
4413     -
4414     - /*
4415     - * page_head wasn't a dangling pointer but it
4416     - * may not be a head page anymore by the time
4417     - * we obtain the lock. That is ok as long as it
4418     - * can't be freed from under us.
4419     - */
4420     - flags = compound_lock_irqsave(page_head);
4421     - /* here __split_huge_page_refcount won't run anymore */
4422     + if (likely(page != page_head && get_page_unless_zero(page_head))) {
4423     + /* Ref to put_compound_page() comment. */
4424     + if (PageSlab(page_head) || PageHeadHuge(page_head)) {
4425     if (likely(PageTail(page))) {
4426     + /*
4427     + * This is a hugetlbfs page or a slab
4428     + * page. __split_huge_page_refcount
4429     + * cannot race here.
4430     + */
4431     + VM_BUG_ON(!PageHead(page_head));
4432     __get_page_tail_foll(page, false);
4433     - got = true;
4434     - }
4435     - compound_unlock_irqrestore(page_head, flags);
4436     - if (unlikely(!got))
4437     + return true;
4438     + } else {
4439     + /*
4440     + * __split_huge_page_refcount run
4441     + * before us, "page" was a THP
4442     + * tail. The split page_head has been
4443     + * freed and reallocated as slab or
4444     + * hugetlbfs page of smaller order
4445     + * (only possible if reallocated as
4446     + * slab on x86).
4447     + */
4448     put_page(page_head);
4449     + return false;
4450     + }
4451     + }
4452     +
4453     + /*
4454     + * page_head wasn't a dangling pointer but it
4455     + * may not be a head page anymore by the time
4456     + * we obtain the lock. That is ok as long as it
4457     + * can't be freed from under us.
4458     + */
4459     + flags = compound_lock_irqsave(page_head);
4460     + /* here __split_huge_page_refcount won't run anymore */
4461     + if (likely(PageTail(page))) {
4462     + __get_page_tail_foll(page, false);
4463     + got = true;
4464     }
4465     + compound_unlock_irqrestore(page_head, flags);
4466     + if (unlikely(!got))
4467     + put_page(page_head);
4468     }
4469     return got;
4470     }
4471     diff --git a/net/compat.c b/net/compat.c
4472     index dd32e34c1e2c..f50161fb812e 100644
4473     --- a/net/compat.c
4474     +++ b/net/compat.c
4475     @@ -780,21 +780,16 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
4476     if (flags & MSG_CMSG_COMPAT)
4477     return -EINVAL;
4478    
4479     - if (COMPAT_USE_64BIT_TIME)
4480     - return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
4481     - flags | MSG_CMSG_COMPAT,
4482     - (struct timespec *) timeout);
4483     -
4484     if (timeout == NULL)
4485     return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
4486     flags | MSG_CMSG_COMPAT, NULL);
4487    
4488     - if (get_compat_timespec(&ktspec, timeout))
4489     + if (compat_get_timespec(&ktspec, timeout))
4490     return -EFAULT;
4491    
4492     datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
4493     flags | MSG_CMSG_COMPAT, &ktspec);
4494     - if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
4495     + if (datagrams > 0 && compat_put_timespec(&ktspec, timeout))
4496     datagrams = -EFAULT;
4497    
4498     return datagrams;
4499     diff --git a/net/core/filter.c b/net/core/filter.c
4500     index 01b780856db2..ad30d626a5bd 100644
4501     --- a/net/core/filter.c
4502     +++ b/net/core/filter.c
4503     @@ -36,7 +36,6 @@
4504     #include <asm/uaccess.h>
4505     #include <asm/unaligned.h>
4506     #include <linux/filter.h>
4507     -#include <linux/reciprocal_div.h>
4508     #include <linux/ratelimit.h>
4509     #include <linux/seccomp.h>
4510     #include <linux/if_vlan.h>
4511     @@ -166,7 +165,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
4512     A /= X;
4513     continue;
4514     case BPF_S_ALU_DIV_K:
4515     - A = reciprocal_divide(A, K);
4516     + A /= K;
4517     continue;
4518     case BPF_S_ALU_MOD_X:
4519     if (X == 0)
4520     @@ -553,11 +552,6 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
4521     /* Some instructions need special checks */
4522     switch (code) {
4523     case BPF_S_ALU_DIV_K:
4524     - /* check for division by zero */
4525     - if (ftest->k == 0)
4526     - return -EINVAL;
4527     - ftest->k = reciprocal_value(ftest->k);
4528     - break;
4529     case BPF_S_ALU_MOD_K:
4530     /* check for division by zero */
4531     if (ftest->k == 0)
4532     @@ -853,27 +847,7 @@ void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
4533     to->code = decodes[code];
4534     to->jt = filt->jt;
4535     to->jf = filt->jf;
4536     -
4537     - if (code == BPF_S_ALU_DIV_K) {
4538     - /*
4539     - * When loaded this rule user gave us X, which was
4540     - * translated into R = r(X). Now we calculate the
4541     - * RR = r(R) and report it back. If next time this
4542     - * value is loaded and RRR = r(RR) is calculated
4543     - * then the R == RRR will be true.
4544     - *
4545     - * One exception. X == 1 translates into R == 0 and
4546     - * we can't calculate RR out of it with r().
4547     - */
4548     -
4549     - if (filt->k == 0)
4550     - to->k = 1;
4551     - else
4552     - to->k = reciprocal_value(filt->k);
4553     -
4554     - BUG_ON(reciprocal_value(to->k) != filt->k);
4555     - } else
4556     - to->k = filt->k;
4557     + to->k = filt->k;
4558     }
4559    
4560     int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, unsigned int len)
4561     diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
4562     index 22b1a7058fd3..4efd2375d7e1 100644
4563     --- a/net/ieee802154/nl-phy.c
4564     +++ b/net/ieee802154/nl-phy.c
4565     @@ -224,8 +224,10 @@ static int ieee802154_add_iface(struct sk_buff *skb,
4566    
4567     if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
4568     type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
4569     - if (type >= __IEEE802154_DEV_MAX)
4570     - return -EINVAL;
4571     + if (type >= __IEEE802154_DEV_MAX) {
4572     + rc = -EINVAL;
4573     + goto nla_put_failure;
4574     + }
4575     }
4576    
4577     dev = phy->add_iface(phy, devname, type);
4578     diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
4579     index b3f627ac4ed8..f7f8cff67344 100644
4580     --- a/net/ipv4/fib_frontend.c
4581     +++ b/net/ipv4/fib_frontend.c
4582     @@ -1049,6 +1049,8 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
4583     }
4584    
4585     in_dev = __in_dev_get_rtnl(dev);
4586     + if (!in_dev)
4587     + return NOTIFY_DONE;
4588    
4589     switch (event) {
4590     case NETDEV_UP:
4591     diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
4592     index 31cf54d18221..45dbdab915e2 100644
4593     --- a/net/ipv4/inet_diag.c
4594     +++ b/net/ipv4/inet_diag.c
4595     @@ -961,7 +961,7 @@ next_normal:
4596     ++num;
4597     }
4598    
4599     - if (r->idiag_states & TCPF_TIME_WAIT) {
4600     + if (r->idiag_states & (TCPF_TIME_WAIT | TCPF_FIN_WAIT2)) {
4601     struct inet_timewait_sock *tw;
4602    
4603     inet_twsk_for_each(tw, node,
4604     @@ -971,6 +971,8 @@ next_normal:
4605    
4606     if (num < s_num)
4607     goto next_dying;
4608     + if (!(r->idiag_states & (1 << tw->tw_substate)))
4609     + goto next_dying;
4610     if (r->sdiag_family != AF_UNSPEC &&
4611     tw->tw_family != r->sdiag_family)
4612     goto next_dying;
4613     diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
4614     index e560ef34cf4b..d30636080a11 100644
4615     --- a/net/ipv4/ip_gre.c
4616     +++ b/net/ipv4/ip_gre.c
4617     @@ -178,7 +178,7 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
4618     else
4619     itn = net_generic(net, ipgre_net_id);
4620    
4621     - iph = (const struct iphdr *)skb->data;
4622     + iph = (const struct iphdr *)(icmp_hdr(skb) + 1);
4623     t = ip_tunnel_lookup(itn, skb->dev->ifindex, tpi->flags,
4624     iph->daddr, iph->saddr, tpi->key);
4625    
4626     diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
4627     index 054a3e97d822..3d4da2c16b6a 100644
4628     --- a/net/ipv4/ip_input.c
4629     +++ b/net/ipv4/ip_input.c
4630     @@ -314,7 +314,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
4631     const struct iphdr *iph = ip_hdr(skb);
4632     struct rtable *rt;
4633    
4634     - if (sysctl_ip_early_demux && !skb_dst(skb)) {
4635     + if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
4636     const struct net_protocol *ipprot;
4637     int protocol = iph->protocol;
4638    
4639     diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
4640     index 254f11c24aa5..995a0bb33a65 100644
4641     --- a/net/ipv4/ip_tunnel.c
4642     +++ b/net/ipv4/ip_tunnel.c
4643     @@ -618,6 +618,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
4644     tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
4645     tunnel->err_count--;
4646    
4647     + memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
4648     dst_link_failure(skb);
4649     } else
4650     tunnel->err_count = 0;
4651     diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
4652     index 62212c772a4b..1672409f5ba5 100644
4653     --- a/net/ipv4/ipmr.c
4654     +++ b/net/ipv4/ipmr.c
4655     @@ -157,9 +157,12 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)
4656     static int ipmr_fib_lookup(struct net *net, struct flowi4 *flp4,
4657     struct mr_table **mrt)
4658     {
4659     - struct ipmr_result res;
4660     - struct fib_lookup_arg arg = { .result = &res, };
4661     int err;
4662     + struct ipmr_result res;
4663     + struct fib_lookup_arg arg = {
4664     + .result = &res,
4665     + .flags = FIB_LOOKUP_NOREF,
4666     + };
4667    
4668     err = fib_rules_lookup(net->ipv4.mr_rules_ops,
4669     flowi4_to_flowi(flp4), 0, &arg);
4670     diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
4671     index 310711433358..75c7f5391fb1 100644
4672     --- a/net/ipv4/tcp_metrics.c
4673     +++ b/net/ipv4/tcp_metrics.c
4674     @@ -22,6 +22,9 @@
4675    
4676     int sysctl_tcp_nometrics_save __read_mostly;
4677    
4678     +static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *addr,
4679     + struct net *net, unsigned int hash);
4680     +
4681     struct tcp_fastopen_metrics {
4682     u16 mss;
4683     u16 syn_loss:10; /* Recurring Fast Open SYN losses */
4684     @@ -130,16 +133,41 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst,
4685     }
4686     }
4687    
4688     +#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
4689     +
4690     +static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
4691     +{
4692     + if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
4693     + tcpm_suck_dst(tm, dst, false);
4694     +}
4695     +
4696     +#define TCP_METRICS_RECLAIM_DEPTH 5
4697     +#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
4698     +
4699     static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
4700     struct inetpeer_addr *addr,
4701     - unsigned int hash,
4702     - bool reclaim)
4703     + unsigned int hash)
4704     {
4705     struct tcp_metrics_block *tm;
4706     struct net *net;
4707     + bool reclaim = false;
4708    
4709     spin_lock_bh(&tcp_metrics_lock);
4710     net = dev_net(dst->dev);
4711     +
4712     + /* While waiting for the spin-lock the cache might have been populated
4713     + * with this entry and so we have to check again.
4714     + */
4715     + tm = __tcp_get_metrics(addr, net, hash);
4716     + if (tm == TCP_METRICS_RECLAIM_PTR) {
4717     + reclaim = true;
4718     + tm = NULL;
4719     + }
4720     + if (tm) {
4721     + tcpm_check_stamp(tm, dst);
4722     + goto out_unlock;
4723     + }
4724     +
4725     if (unlikely(reclaim)) {
4726     struct tcp_metrics_block *oldest;
4727    
4728     @@ -169,17 +197,6 @@ out_unlock:
4729     return tm;
4730     }
4731    
4732     -#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
4733     -
4734     -static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
4735     -{
4736     - if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
4737     - tcpm_suck_dst(tm, dst, false);
4738     -}
4739     -
4740     -#define TCP_METRICS_RECLAIM_DEPTH 5
4741     -#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
4742     -
4743     static struct tcp_metrics_block *tcp_get_encode(struct tcp_metrics_block *tm, int depth)
4744     {
4745     if (tm)
4746     @@ -280,7 +297,6 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
4747     struct inetpeer_addr addr;
4748     unsigned int hash;
4749     struct net *net;
4750     - bool reclaim;
4751    
4752     addr.family = sk->sk_family;
4753     switch (addr.family) {
4754     @@ -300,13 +316,10 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
4755     hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
4756    
4757     tm = __tcp_get_metrics(&addr, net, hash);
4758     - reclaim = false;
4759     - if (tm == TCP_METRICS_RECLAIM_PTR) {
4760     - reclaim = true;
4761     + if (tm == TCP_METRICS_RECLAIM_PTR)
4762     tm = NULL;
4763     - }
4764     if (!tm && create)
4765     - tm = tcpm_new(dst, &addr, hash, reclaim);
4766     + tm = tcpm_new(dst, &addr, hash);
4767     else
4768     tcpm_check_stamp(tm, dst);
4769    
4770     diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
4771     index 302d6fb1ff2b..51d54dc376f3 100644
4772     --- a/net/ipv6/ip6_input.c
4773     +++ b/net/ipv6/ip6_input.c
4774     @@ -49,7 +49,7 @@
4775    
4776     int ip6_rcv_finish(struct sk_buff *skb)
4777     {
4778     - if (sysctl_ip_early_demux && !skb_dst(skb)) {
4779     + if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
4780     const struct inet6_protocol *ipprot;
4781    
4782     ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
4783     diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
4784     index f365310bfcca..0eb4038a4d63 100644
4785     --- a/net/ipv6/ip6mr.c
4786     +++ b/net/ipv6/ip6mr.c
4787     @@ -141,9 +141,12 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
4788     static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
4789     struct mr6_table **mrt)
4790     {
4791     - struct ip6mr_result res;
4792     - struct fib_lookup_arg arg = { .result = &res, };
4793     int err;
4794     + struct ip6mr_result res;
4795     + struct fib_lookup_arg arg = {
4796     + .result = &res,
4797     + .flags = FIB_LOOKUP_NOREF,
4798     + };
4799    
4800     err = fib_rules_lookup(net->ipv6.mr6_rules_ops,
4801     flowi6_to_flowi(flp6), 0, &arg);
4802     diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
4803     index 8eb9501e3d60..b7ebe23cdedf 100644
4804     --- a/net/rds/ib_recv.c
4805     +++ b/net/rds/ib_recv.c
4806     @@ -421,8 +421,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
4807     struct rds_ib_refill_cache *cache)
4808     {
4809     unsigned long flags;
4810     - struct list_head *old;
4811     - struct list_head __percpu *chpfirst;
4812     + struct list_head *old, *chpfirst;
4813    
4814     local_irq_save(flags);
4815    
4816     @@ -432,7 +431,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
4817     else /* put on front */
4818     list_add_tail(new_item, chpfirst);
4819    
4820     - __this_cpu_write(chpfirst, new_item);
4821     + __this_cpu_write(cache->percpu->first, new_item);
4822     __this_cpu_inc(cache->percpu->count);
4823    
4824     if (__this_cpu_read(cache->percpu->count) < RDS_IB_RECYCLE_BATCH_COUNT)
4825     @@ -452,7 +451,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
4826     } while (old);
4827    
4828    
4829     - __this_cpu_write(chpfirst, NULL);
4830     + __this_cpu_write(cache->percpu->first, NULL);
4831     __this_cpu_write(cache->percpu->count, 0);
4832     end:
4833     local_irq_restore(flags);
4834     diff --git a/sound/core/init.c b/sound/core/init.c
4835     index 6b9087115da2..d04785144601 100644
4836     --- a/sound/core/init.c
4837     +++ b/sound/core/init.c
4838     @@ -170,7 +170,7 @@ int snd_card_create(int idx, const char *xid,
4839     if (idx < 0) {
4840     for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) {
4841     /* idx == -1 == 0xffff means: take any free slot */
4842     - if (idx2 < sizeof(int) && !(idx & (1U << idx2)))
4843     + if (idx2 < 32 && !(idx & (1U << idx2)))
4844     continue;
4845     if (!test_bit(idx2, snd_cards_lock)) {
4846     if (module_slot_match(module, idx2)) {
4847     @@ -183,7 +183,7 @@ int snd_card_create(int idx, const char *xid,
4848     if (idx < 0) {
4849     for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) {
4850     /* idx == -1 == 0xffff means: take any free slot */
4851     - if (idx2 < sizeof(int) && !(idx & (1U << idx2)))
4852     + if (idx2 < 32 && !(idx & (1U << idx2)))
4853     continue;
4854     if (!test_bit(idx2, snd_cards_lock)) {
4855     if (!slots[idx2] || !*slots[idx2]) {
4856     diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
4857     index 46ed9e8ae0fd..cc9fd67a50df 100644
4858     --- a/sound/pci/Kconfig
4859     +++ b/sound/pci/Kconfig
4860     @@ -25,6 +25,7 @@ config SND_ALS300
4861     select SND_PCM
4862     select SND_AC97_CODEC
4863     select SND_OPL3_LIB
4864     + select ZONE_DMA
4865     help
4866     Say 'Y' or 'M' to include support for Avance Logic ALS300/ALS300+
4867    
4868     @@ -49,6 +50,7 @@ config SND_ALI5451
4869     tristate "ALi M5451 PCI Audio Controller"
4870     select SND_MPU401_UART
4871     select SND_AC97_CODEC
4872     + select ZONE_DMA
4873     help
4874     Say Y here to include support for the integrated AC97 sound
4875     device on motherboards using the ALi M5451 Audio Controller
4876     @@ -153,6 +155,7 @@ config SND_AZT3328
4877     select SND_PCM
4878     select SND_RAWMIDI
4879     select SND_AC97_CODEC
4880     + select ZONE_DMA
4881     help
4882     Say Y here to include support for Aztech AZF3328 (PCI168)
4883     soundcards.
4884     @@ -458,6 +461,7 @@ config SND_EMU10K1
4885     select SND_HWDEP
4886     select SND_RAWMIDI
4887     select SND_AC97_CODEC
4888     + select ZONE_DMA
4889     help
4890     Say Y to include support for Sound Blaster PCI 512, Live!,
4891     Audigy and E-mu APS (partially supported) soundcards.
4892     @@ -473,6 +477,7 @@ config SND_EMU10K1X
4893     tristate "Emu10k1X (Dell OEM Version)"
4894     select SND_AC97_CODEC
4895     select SND_RAWMIDI
4896     + select ZONE_DMA
4897     help
4898     Say Y here to include support for the Dell OEM version of the
4899     Sound Blaster Live!.
4900     @@ -506,6 +511,7 @@ config SND_ES1938
4901     select SND_OPL3_LIB
4902     select SND_MPU401_UART
4903     select SND_AC97_CODEC
4904     + select ZONE_DMA
4905     help
4906     Say Y here to include support for soundcards based on ESS Solo-1
4907     (ES1938, ES1946, ES1969) chips.
4908     @@ -517,6 +523,7 @@ config SND_ES1968
4909     tristate "ESS ES1968/1978 (Maestro-1/2/2E)"
4910     select SND_MPU401_UART
4911     select SND_AC97_CODEC
4912     + select ZONE_DMA
4913     help
4914     Say Y here to include support for soundcards based on ESS Maestro
4915     1/2/2E chips.
4916     @@ -605,6 +612,7 @@ config SND_ICE1712
4917     select SND_MPU401_UART
4918     select SND_AC97_CODEC
4919     select BITREVERSE
4920     + select ZONE_DMA
4921     help
4922     Say Y here to include support for soundcards based on the
4923     ICE1712 (Envy24) chip.
4924     @@ -692,6 +700,7 @@ config SND_LX6464ES
4925     config SND_MAESTRO3
4926     tristate "ESS Allegro/Maestro3"
4927     select SND_AC97_CODEC
4928     + select ZONE_DMA
4929     help
4930     Say Y here to include support for soundcards based on ESS Maestro 3
4931     (Allegro) chips.
4932     @@ -788,6 +797,7 @@ config SND_SIS7019
4933     tristate "SiS 7019 Audio Accelerator"
4934     depends on X86 && !X86_64
4935     select SND_AC97_CODEC
4936     + select ZONE_DMA
4937     help
4938     Say Y here to include support for the SiS 7019 Audio Accelerator.
4939    
4940     @@ -799,6 +809,7 @@ config SND_SONICVIBES
4941     select SND_OPL3_LIB
4942     select SND_MPU401_UART
4943     select SND_AC97_CODEC
4944     + select ZONE_DMA
4945     help
4946     Say Y here to include support for soundcards based on the S3
4947     SonicVibes chip.
4948     @@ -810,6 +821,7 @@ config SND_TRIDENT
4949     tristate "Trident 4D-Wave DX/NX; SiS 7018"
4950     select SND_MPU401_UART
4951     select SND_AC97_CODEC
4952     + select ZONE_DMA
4953     help
4954     Say Y here to include support for soundcards based on Trident
4955     4D-Wave DX/NX or SiS 7018 chips.
4956     diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
4957     index c7f6d1cab606..7d4ccfa48008 100644
4958     --- a/sound/pci/hda/hda_generic.c
4959     +++ b/sound/pci/hda/hda_generic.c
4960     @@ -2857,9 +2857,11 @@ static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid,
4961     if (num_conns < idx)
4962     return false;
4963     nid = list[idx];
4964     - if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT))
4965     + if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT) &&
4966     + !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_VOL_CTL))
4967     *mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4968     - if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT))
4969     + if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT) &&
4970     + !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_MUTE_CTL))
4971     *mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4972    
4973     return *mix_val || *mute_val;
4974     diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
4975     index 38aa080681a3..31230c68b603 100644
4976     --- a/sound/pci/hda/patch_analog.c
4977     +++ b/sound/pci/hda/patch_analog.c
4978     @@ -171,7 +171,7 @@ static const struct hda_codec_ops ad198x_auto_patch_ops = {
4979     };
4980    
4981    
4982     -static int ad198x_parse_auto_config(struct hda_codec *codec)
4983     +static int ad198x_parse_auto_config(struct hda_codec *codec, bool indep_hp)
4984     {
4985     struct ad198x_spec *spec = codec->spec;
4986     struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4987     @@ -181,7 +181,7 @@ static int ad198x_parse_auto_config(struct hda_codec *codec)
4988     codec->no_trigger_sense = 1;
4989     codec->no_sticky_stream = 1;
4990    
4991     - spec->gen.indep_hp = 1;
4992     + spec->gen.indep_hp = indep_hp;
4993    
4994     err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
4995     if (err < 0)
4996     @@ -264,11 +264,11 @@ static const struct hda_fixup ad1986a_fixups[] = {
4997     .v.pins = (const struct hda_pintbl[]) {
4998     { 0x1a, 0x02214021 }, /* headphone */
4999     { 0x1b, 0x01014011 }, /* front */
5000     - { 0x1c, 0x01013012 }, /* surround */
5001     - { 0x1d, 0x01019015 }, /* clfe */
5002     + { 0x1c, 0x01813030 }, /* line-in */
5003     + { 0x1d, 0x01a19020 }, /* rear mic */
5004     { 0x1e, 0x411111f0 }, /* N/A */
5005     { 0x1f, 0x02a190f0 }, /* mic */
5006     - { 0x20, 0x018130f0 }, /* line-in */
5007     + { 0x20, 0x411111f0 }, /* N/A */
5008     {}
5009     },
5010     },
5011     @@ -362,7 +362,7 @@ static int patch_ad1986a(struct hda_codec *codec)
5012     ad1986a_fixups);
5013     snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5014    
5015     - err = ad198x_parse_auto_config(codec);
5016     + err = ad198x_parse_auto_config(codec, false);
5017     if (err < 0) {
5018     snd_hda_gen_free(codec);
5019     return err;
5020     @@ -464,7 +464,7 @@ static int patch_ad1983(struct hda_codec *codec)
5021    
5022     spec->gen.beep_nid = 0x10;
5023     set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
5024     - err = ad198x_parse_auto_config(codec);
5025     + err = ad198x_parse_auto_config(codec, false);
5026     if (err < 0)
5027     goto error;
5028     err = ad1983_add_spdif_mux_ctl(codec);
5029     @@ -564,7 +564,7 @@ static int patch_ad1981(struct hda_codec *codec)
5030     snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
5031     snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5032    
5033     - err = ad198x_parse_auto_config(codec);
5034     + err = ad198x_parse_auto_config(codec, false);
5035     if (err < 0)
5036     goto error;
5037     err = ad1983_add_spdif_mux_ctl(codec);
5038     @@ -890,7 +890,7 @@ static int patch_ad1988(struct hda_codec *codec)
5039     snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
5040     snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5041    
5042     - err = ad198x_parse_auto_config(codec);
5043     + err = ad198x_parse_auto_config(codec, true);
5044     if (err < 0)
5045     goto error;
5046     err = ad1988_add_spdif_mux_ctl(codec);
5047     @@ -1064,7 +1064,7 @@ static int patch_ad1884(struct hda_codec *codec)
5048     snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
5049     snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5050    
5051     - err = ad198x_parse_auto_config(codec);
5052     + err = ad198x_parse_auto_config(codec, true);
5053     if (err < 0)
5054     goto error;
5055     err = ad1983_add_spdif_mux_ctl(codec);
5056     @@ -1106,7 +1106,7 @@ static int patch_ad1882(struct hda_codec *codec)
5057     spec->gen.mixer_merge_nid = 0x21;
5058     spec->gen.beep_nid = 0x10;
5059     set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
5060     - err = ad198x_parse_auto_config(codec);
5061     + err = ad198x_parse_auto_config(codec, true);
5062     if (err < 0)
5063     goto error;
5064     err = ad1988_add_spdif_mux_ctl(codec);
5065     diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
5066     index f26c42c92db7..417e0fc2d119 100644
5067     --- a/sound/pci/hda/patch_hdmi.c
5068     +++ b/sound/pci/hda/patch_hdmi.c
5069     @@ -88,6 +88,9 @@ struct hdmi_spec {
5070     unsigned int channels_max; /* max over all cvts */
5071    
5072     struct hdmi_eld temp_eld;
5073     +
5074     + bool dyn_pin_out;
5075     +
5076     /*
5077     * Non-generic ATI/NVIDIA specific
5078     */
5079     @@ -452,15 +455,25 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
5080    
5081     static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
5082     {
5083     + struct hdmi_spec *spec = codec->spec;
5084     + int pin_out;
5085     +
5086     /* Unmute */
5087     if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
5088     snd_hda_codec_write(codec, pin_nid, 0,
5089     AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5090     - /* Enable pin out: some machines with GM965 gets broken output when
5091     - * the pin is disabled or changed while using with HDMI
5092     - */
5093     +
5094     + if (spec->dyn_pin_out)
5095     + /* Disable pin out until stream is active */
5096     + pin_out = 0;
5097     + else
5098     + /* Enable pin out: some machines with GM965 gets broken output
5099     + * when the pin is disabled or changed while using with HDMI
5100     + */
5101     + pin_out = PIN_OUT;
5102     +
5103     snd_hda_codec_write(codec, pin_nid, 0,
5104     - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5105     + AC_VERB_SET_PIN_WIDGET_CONTROL, pin_out);
5106     }
5107    
5108     static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid)
5109     @@ -1535,6 +1548,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
5110     struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
5111     hda_nid_t pin_nid = per_pin->pin_nid;
5112     bool non_pcm;
5113     + int pinctl;
5114    
5115     non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
5116     per_pin->channels = substream->runtime->channels;
5117     @@ -1544,6 +1558,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
5118    
5119     hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
5120    
5121     + if (spec->dyn_pin_out) {
5122     + pinctl = snd_hda_codec_read(codec, pin_nid, 0,
5123     + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5124     + snd_hda_codec_write(codec, pin_nid, 0,
5125     + AC_VERB_SET_PIN_WIDGET_CONTROL,
5126     + pinctl | PIN_OUT);
5127     + }
5128     +
5129     return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
5130     }
5131    
5132     @@ -1563,6 +1585,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
5133     int cvt_idx, pin_idx;
5134     struct hdmi_spec_per_cvt *per_cvt;
5135     struct hdmi_spec_per_pin *per_pin;
5136     + int pinctl;
5137    
5138     if (hinfo->nid) {
5139     cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid);
5140     @@ -1579,6 +1602,14 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
5141     return -EINVAL;
5142     per_pin = get_pin(spec, pin_idx);
5143    
5144     + if (spec->dyn_pin_out) {
5145     + pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
5146     + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5147     + snd_hda_codec_write(codec, per_pin->pin_nid, 0,
5148     + AC_VERB_SET_PIN_WIDGET_CONTROL,
5149     + pinctl & ~PIN_OUT);
5150     + }
5151     +
5152     snd_hda_spdif_ctls_unassign(codec, pin_idx);
5153     per_pin->chmap_set = false;
5154     memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
5155     @@ -2560,6 +2591,21 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
5156     return 0;
5157     }
5158    
5159     +static int patch_nvhdmi(struct hda_codec *codec)
5160     +{
5161     + struct hdmi_spec *spec;
5162     + int err;
5163     +
5164     + err = patch_generic_hdmi(codec);
5165     + if (err)
5166     + return err;
5167     +
5168     + spec = codec->spec;
5169     + spec->dyn_pin_out = true;
5170     +
5171     + return 0;
5172     +}
5173     +
5174     /*
5175     * ATI-specific implementations
5176     *
5177     @@ -2632,30 +2678,30 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
5178     { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
5179     { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
5180     { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
5181     -{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_generic_hdmi },
5182     -{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_generic_hdmi },
5183     -{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_generic_hdmi },
5184     -{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_generic_hdmi },
5185     -{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_generic_hdmi },
5186     -{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_generic_hdmi },
5187     -{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_generic_hdmi },
5188     -{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_generic_hdmi },
5189     -{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_generic_hdmi },
5190     -{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_generic_hdmi },
5191     -{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_generic_hdmi },
5192     +{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi },
5193     +{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi },
5194     +{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi },
5195     +{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi },
5196     +{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi },
5197     +{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi },
5198     +{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi },
5199     +{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi },
5200     +{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi },
5201     +{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_nvhdmi },
5202     +{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_nvhdmi },
5203     /* 17 is known to be absent */
5204     -{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_generic_hdmi },
5205     -{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_generic_hdmi },
5206     -{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_generic_hdmi },
5207     -{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_generic_hdmi },
5208     -{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_generic_hdmi },
5209     -{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_generic_hdmi },
5210     -{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_generic_hdmi },
5211     -{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_generic_hdmi },
5212     -{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi },
5213     -{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi },
5214     -{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi },
5215     -{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi },
5216     +{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi },
5217     +{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi },
5218     +{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi },
5219     +{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi },
5220     +{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi },
5221     +{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi },
5222     +{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi },
5223     +{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi },
5224     +{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi },
5225     +{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi },
5226     +{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi },
5227     +{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi },
5228     { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
5229     { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
5230     { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
5231     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5232     index dce47c414ea7..56b62555eef4 100644
5233     --- a/sound/pci/hda/patch_realtek.c
5234     +++ b/sound/pci/hda/patch_realtek.c
5235     @@ -1769,6 +1769,7 @@ enum {
5236     ALC889_FIXUP_DAC_ROUTE,
5237     ALC889_FIXUP_MBP_VREF,
5238     ALC889_FIXUP_IMAC91_VREF,
5239     + ALC889_FIXUP_MBA11_VREF,
5240     ALC889_FIXUP_MBA21_VREF,
5241     ALC882_FIXUP_INV_DMIC,
5242     ALC882_FIXUP_NO_PRIMARY_HP,
5243     @@ -1898,6 +1899,16 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec,
5244     alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
5245     }
5246    
5247     +/* Set VREF on speaker pins on mba11 */
5248     +static void alc889_fixup_mba11_vref(struct hda_codec *codec,
5249     + const struct hda_fixup *fix, int action)
5250     +{
5251     + static hda_nid_t nids[1] = { 0x18 };
5252     +
5253     + if (action == HDA_FIXUP_ACT_INIT)
5254     + alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
5255     +}
5256     +
5257     /* Set VREF on speaker pins on mba21 */
5258     static void alc889_fixup_mba21_vref(struct hda_codec *codec,
5259     const struct hda_fixup *fix, int action)
5260     @@ -2104,6 +2115,12 @@ static const struct hda_fixup alc882_fixups[] = {
5261     .chained = true,
5262     .chain_id = ALC882_FIXUP_GPIO1,
5263     },
5264     + [ALC889_FIXUP_MBA11_VREF] = {
5265     + .type = HDA_FIXUP_FUNC,
5266     + .v.func = alc889_fixup_mba11_vref,
5267     + .chained = true,
5268     + .chain_id = ALC889_FIXUP_MBP_VREF,
5269     + },
5270     [ALC889_FIXUP_MBA21_VREF] = {
5271     .type = HDA_FIXUP_FUNC,
5272     .v.func = alc889_fixup_mba21_vref,
5273     @@ -2173,7 +2190,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5274     SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
5275     SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
5276     SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
5277     - SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
5278     + SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
5279     SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
5280     SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
5281     SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5282     diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
5283     index b96d9e1adf6d..3717f2dd30be 100644
5284     --- a/sound/pci/rme9652/rme9652.c
5285     +++ b/sound/pci/rme9652/rme9652.c
5286     @@ -285,7 +285,7 @@ static char channel_map_9636_ds[26] = {
5287     /* ADAT channels are remapped */
5288     1, 3, 5, 7, 9, 11, 13, 15,
5289     /* channels 8 and 9 are S/PDIF */
5290     - 24, 25
5291     + 24, 25,
5292     /* others don't exist */
5293     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
5294     };
5295     diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
5296     index ebff1128be59..adee866f463f 100644
5297     --- a/sound/soc/codecs/adau1701.c
5298     +++ b/sound/soc/codecs/adau1701.c
5299     @@ -71,7 +71,7 @@
5300    
5301     #define ADAU1701_SEROCTL_WORD_LEN_24 0x0000
5302     #define ADAU1701_SEROCTL_WORD_LEN_20 0x0001
5303     -#define ADAU1701_SEROCTL_WORD_LEN_16 0x0010
5304     +#define ADAU1701_SEROCTL_WORD_LEN_16 0x0002
5305     #define ADAU1701_SEROCTL_WORD_LEN_MASK 0x0003
5306    
5307     #define ADAU1701_AUXNPOW_VBPD 0x40
5308     diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
5309     index 831a34d7cc72..c09a5305d601 100644
5310     --- a/sound/soc/codecs/wm5110.c
5311     +++ b/sound/soc/codecs/wm5110.c
5312     @@ -43,6 +43,54 @@ static const struct reg_default wm5110_sysclk_revd_patch[] = {
5313     { 0x3133, 0x1201 },
5314     { 0x3183, 0x1501 },
5315     { 0x31D3, 0x1401 },
5316     + { 0x0049, 0x01ea },
5317     + { 0x004a, 0x01f2 },
5318     + { 0x0057, 0x01e7 },
5319     + { 0x0058, 0x01fb },
5320     + { 0x33ce, 0xc4f5 },
5321     + { 0x33cf, 0x1361 },
5322     + { 0x33d0, 0x0402 },
5323     + { 0x33d1, 0x4700 },
5324     + { 0x33d2, 0x026d },
5325     + { 0x33d3, 0xff00 },
5326     + { 0x33d4, 0x026d },
5327     + { 0x33d5, 0x0101 },
5328     + { 0x33d6, 0xc4f5 },
5329     + { 0x33d7, 0x0361 },
5330     + { 0x33d8, 0x0402 },
5331     + { 0x33d9, 0x6701 },
5332     + { 0x33da, 0xc4f5 },
5333     + { 0x33db, 0x136f },
5334     + { 0x33dc, 0xc4f5 },
5335     + { 0x33dd, 0x134f },
5336     + { 0x33de, 0xc4f5 },
5337     + { 0x33df, 0x131f },
5338     + { 0x33e0, 0x026d },
5339     + { 0x33e1, 0x4f01 },
5340     + { 0x33e2, 0x026d },
5341     + { 0x33e3, 0xf100 },
5342     + { 0x33e4, 0x026d },
5343     + { 0x33e5, 0x0001 },
5344     + { 0x33e6, 0xc4f5 },
5345     + { 0x33e7, 0x0361 },
5346     + { 0x33e8, 0x0402 },
5347     + { 0x33e9, 0x6601 },
5348     + { 0x33ea, 0xc4f5 },
5349     + { 0x33eb, 0x136f },
5350     + { 0x33ec, 0xc4f5 },
5351     + { 0x33ed, 0x134f },
5352     + { 0x33ee, 0xc4f5 },
5353     + { 0x33ef, 0x131f },
5354     + { 0x33f0, 0x026d },
5355     + { 0x33f1, 0x4e01 },
5356     + { 0x33f2, 0x026d },
5357     + { 0x33f3, 0xf000 },
5358     + { 0x33f6, 0xc4f5 },
5359     + { 0x33f7, 0x1361 },
5360     + { 0x33f8, 0x0402 },
5361     + { 0x33f9, 0x4600 },
5362     + { 0x33fa, 0x026d },
5363     + { 0x33fb, 0xfe00 },
5364     };
5365    
5366     static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
5367     diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
5368     index 568b750c01f6..9d78c70be71e 100644
5369     --- a/tools/perf/util/session.c
5370     +++ b/tools/perf/util/session.c
5371     @@ -870,6 +870,7 @@ static struct machine *
5372     struct perf_sample *sample)
5373     {
5374     const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
5375     + struct machine *machine;
5376    
5377     if (perf_guest &&
5378     ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
5379     @@ -882,7 +883,11 @@ static struct machine *
5380     else
5381     pid = sample->pid;
5382    
5383     - return perf_session__findnew_machine(session, pid);
5384     + machine = perf_session__find_machine(session, pid);
5385     + if (!machine)
5386     + machine = perf_session__findnew_machine(session,
5387     + DEFAULT_GUEST_KERNEL_ID);
5388     + return machine;
5389     }
5390    
5391     return &session->machines.host;