Gentoo Archives: gentoo-commits

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