Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2150 - genpatches-2.6/trunk/3.2
Date: Wed, 06 Jun 2012 00:47:05
Message-Id: 20120606004635.C75DF2004B@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2012-06-06 00:46:35 +0000 (Wed, 06 Jun 2012)
3 New Revision: 2150
4
5 Added:
6 genpatches-2.6/trunk/3.2/1016_linux-3.2.17.patch
7 genpatches-2.6/trunk/3.2/1017_linux-3.2.18.patch
8 genpatches-2.6/trunk/3.2/1018_linux-3.2.19.patch
9 Modified:
10 genpatches-2.6/trunk/3.2/0000_README
11 Log:
12 Linux patches 3.2.17, 3.2.18 and 3.2.19
13
14 Modified: genpatches-2.6/trunk/3.2/0000_README
15 ===================================================================
16 --- genpatches-2.6/trunk/3.2/0000_README 2012-06-06 00:39:15 UTC (rev 2149)
17 +++ genpatches-2.6/trunk/3.2/0000_README 2012-06-06 00:46:35 UTC (rev 2150)
18 @@ -104,6 +104,18 @@
19 From: http://www.kernel.org
20 Desc: Linux 3.2.16
21
22 +Patch: 1016_linux-3.2.17.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 3.2.17
25 +
26 +Patch: 1017_linux-3.2.18.patch
27 +From: http://www.kernel.org
28 +Desc: Linux 3.2.18
29 +
30 +Patch: 1018_linux-3.2.19.patch
31 +From: http://www.kernel.org
32 +Desc: Linux 3.2.19
33 +
34 Patch: 2300_per-pci-device-msi-irq-listing.patch
35 From: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=da8d1c8ba4dcb16d60be54b233deca9a7cac98dc
36 Desc: Add a per-pci-device subdirectory in sysfs
37
38 Added: genpatches-2.6/trunk/3.2/1016_linux-3.2.17.patch
39 ===================================================================
40 --- genpatches-2.6/trunk/3.2/1016_linux-3.2.17.patch (rev 0)
41 +++ genpatches-2.6/trunk/3.2/1016_linux-3.2.17.patch 2012-06-06 00:46:35 UTC (rev 2150)
42 @@ -0,0 +1,5695 @@
43 +diff --git a/Makefile b/Makefile
44 +index 3da29cb..4c4efa3 100644
45 +--- a/Makefile
46 ++++ b/Makefile
47 +@@ -1,6 +1,6 @@
48 + VERSION = 3
49 + PATCHLEVEL = 2
50 +-SUBLEVEL = 16
51 ++SUBLEVEL = 17
52 + EXTRAVERSION =
53 + NAME = Saber-toothed Squirrel
54 +
55 +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
56 +index ab3740e..ef642a0 100644
57 +--- a/arch/arm/Kconfig
58 ++++ b/arch/arm/Kconfig
59 +@@ -1155,6 +1155,15 @@ if !MMU
60 + source "arch/arm/Kconfig-nommu"
61 + endif
62 +
63 ++config ARM_ERRATA_326103
64 ++ bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory"
65 ++ depends on CPU_V6
66 ++ help
67 ++ Executing a SWP instruction to read-only memory does not set bit 11
68 ++ of the FSR on the ARM 1136 prior to r1p0. This causes the kernel to
69 ++ treat the access as a read, preventing a COW from occurring and
70 ++ causing the faulting task to livelock.
71 ++
72 + config ARM_ERRATA_411920
73 + bool "ARM errata: Invalidation of the Instruction Cache operation can fail"
74 + depends on CPU_V6 || CPU_V6K
75 +diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h
76 +index 60843eb..73409e6 100644
77 +--- a/arch/arm/include/asm/tls.h
78 ++++ b/arch/arm/include/asm/tls.h
79 +@@ -7,6 +7,8 @@
80 +
81 + .macro set_tls_v6k, tp, tmp1, tmp2
82 + mcr p15, 0, \tp, c13, c0, 3 @ set TLS register
83 ++ mov \tmp1, #0
84 ++ mcr p15, 0, \tmp1, c13, c0, 2 @ clear user r/w TLS register
85 + .endm
86 +
87 + .macro set_tls_v6, tp, tmp1, tmp2
88 +@@ -15,6 +17,8 @@
89 + mov \tmp2, #0xffff0fff
90 + tst \tmp1, #HWCAP_TLS @ hardware TLS available?
91 + mcrne p15, 0, \tp, c13, c0, 3 @ yes, set TLS register
92 ++ movne \tmp1, #0
93 ++ mcrne p15, 0, \tmp1, c13, c0, 2 @ clear user r/w TLS register
94 + streq \tp, [\tmp2, #-15] @ set TLS value at 0xffff0ff0
95 + .endm
96 +
97 +diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
98 +index 3efd82c..87c8be5 100644
99 +--- a/arch/arm/kernel/irq.c
100 ++++ b/arch/arm/kernel/irq.c
101 +@@ -156,10 +156,10 @@ static bool migrate_one_irq(struct irq_desc *desc)
102 + }
103 +
104 + c = irq_data_get_irq_chip(d);
105 +- if (c->irq_set_affinity)
106 +- c->irq_set_affinity(d, affinity, true);
107 +- else
108 ++ if (!c->irq_set_affinity)
109 + pr_debug("IRQ%u: unable to set affinity\n", d->irq);
110 ++ else if (c->irq_set_affinity(d, affinity, true) == IRQ_SET_MASK_OK && ret)
111 ++ cpumask_copy(d->affinity, affinity);
112 +
113 + return ret;
114 + }
115 +diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
116 +index ef5640b..e10e59a 100644
117 +--- a/arch/arm/kernel/smp.c
118 ++++ b/arch/arm/kernel/smp.c
119 +@@ -297,8 +297,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
120 + struct mm_struct *mm = &init_mm;
121 + unsigned int cpu = smp_processor_id();
122 +
123 +- printk("CPU%u: Booted secondary processor\n", cpu);
124 +-
125 + /*
126 + * All kernel threads share the same mm context; grab a
127 + * reference and switch to it.
128 +@@ -310,6 +308,8 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
129 + enter_lazy_tlb(mm, current);
130 + local_flush_tlb_all();
131 +
132 ++ printk("CPU%u: Booted secondary processor\n", cpu);
133 ++
134 + cpu_init();
135 + preempt_disable();
136 + trace_hardirqs_off();
137 +diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
138 +index d2b1779..76cbb05 100644
139 +--- a/arch/arm/kernel/sys_arm.c
140 ++++ b/arch/arm/kernel/sys_arm.c
141 +@@ -115,7 +115,7 @@ int kernel_execve(const char *filename,
142 + "Ir" (THREAD_START_SP - sizeof(regs)),
143 + "r" (&regs),
144 + "Ir" (sizeof(regs))
145 +- : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
146 ++ : "r0", "r1", "r2", "r3", "r8", "r9", "ip", "lr", "memory");
147 +
148 + out:
149 + return ret;
150 +diff --git a/arch/arm/mach-omap1/timer.c b/arch/arm/mach-omap1/timer.c
151 +index 6e90665..fb202af 100644
152 +--- a/arch/arm/mach-omap1/timer.c
153 ++++ b/arch/arm/mach-omap1/timer.c
154 +@@ -47,9 +47,9 @@ static int omap1_dm_timer_set_src(struct platform_device *pdev,
155 + int n = (pdev->id - 1) << 1;
156 + u32 l;
157 +
158 +- l = __raw_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
159 ++ l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
160 + l |= source << n;
161 +- __raw_writel(l, MOD_CONF_CTRL_1);
162 ++ omap_writel(l, MOD_CONF_CTRL_1);
163 +
164 + return 0;
165 + }
166 +diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
167 +index ff1f7cc..8074199 100644
168 +--- a/arch/arm/mm/abort-ev6.S
169 ++++ b/arch/arm/mm/abort-ev6.S
170 +@@ -26,18 +26,23 @@ ENTRY(v6_early_abort)
171 + mrc p15, 0, r1, c5, c0, 0 @ get FSR
172 + mrc p15, 0, r0, c6, c0, 0 @ get FAR
173 + /*
174 +- * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR (erratum 326103).
175 +- * The test below covers all the write situations, including Java bytecodes
176 ++ * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR.
177 + */
178 +- bic r1, r1, #1 << 11 @ clear bit 11 of FSR
179 ++#ifdef CONFIG_ARM_ERRATA_326103
180 ++ ldr ip, =0x4107b36
181 ++ mrc p15, 0, r3, c0, c0, 0 @ get processor id
182 ++ teq ip, r3, lsr #4 @ r0 ARM1136?
183 ++ bne do_DataAbort
184 + tst r5, #PSR_J_BIT @ Java?
185 ++ tsteq r5, #PSR_T_BIT @ Thumb?
186 + bne do_DataAbort
187 +- do_thumb_abort fsr=r1, pc=r4, psr=r5, tmp=r3
188 +- ldreq r3, [r4] @ read aborted ARM instruction
189 ++ bic r1, r1, #1 << 11 @ clear bit 11 of FSR
190 ++ ldr r3, [r4] @ read aborted ARM instruction
191 + #ifdef CONFIG_CPU_ENDIAN_BE8
192 +- reveq r3, r3
193 ++ rev r3, r3
194 + #endif
195 + do_ldrd_abort tmp=ip, insn=r3
196 + tst r3, #1 << 20 @ L = 0 -> write
197 + orreq r1, r1, #1 << 11 @ yes.
198 ++#endif
199 + b do_DataAbort
200 +diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
201 +index b1e192b..db7bcc0 100644
202 +--- a/arch/arm/mm/cache-l2x0.c
203 ++++ b/arch/arm/mm/cache-l2x0.c
204 +@@ -32,6 +32,7 @@ static void __iomem *l2x0_base;
205 + static DEFINE_RAW_SPINLOCK(l2x0_lock);
206 + static uint32_t l2x0_way_mask; /* Bitmask of active ways */
207 + static uint32_t l2x0_size;
208 ++static unsigned long sync_reg_offset = L2X0_CACHE_SYNC;
209 +
210 + struct l2x0_regs l2x0_saved_regs;
211 +
212 +@@ -61,12 +62,7 @@ static inline void cache_sync(void)
213 + {
214 + void __iomem *base = l2x0_base;
215 +
216 +-#ifdef CONFIG_PL310_ERRATA_753970
217 +- /* write to an unmmapped register */
218 +- writel_relaxed(0, base + L2X0_DUMMY_REG);
219 +-#else
220 +- writel_relaxed(0, base + L2X0_CACHE_SYNC);
221 +-#endif
222 ++ writel_relaxed(0, base + sync_reg_offset);
223 + cache_wait(base + L2X0_CACHE_SYNC, 1);
224 + }
225 +
226 +@@ -85,10 +81,13 @@ static inline void l2x0_inv_line(unsigned long addr)
227 + }
228 +
229 + #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915)
230 ++static inline void debug_writel(unsigned long val)
231 ++{
232 ++ if (outer_cache.set_debug)
233 ++ outer_cache.set_debug(val);
234 ++}
235 +
236 +-#define debug_writel(val) outer_cache.set_debug(val)
237 +-
238 +-static void l2x0_set_debug(unsigned long val)
239 ++static void pl310_set_debug(unsigned long val)
240 + {
241 + writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL);
242 + }
243 +@@ -98,7 +97,7 @@ static inline void debug_writel(unsigned long val)
244 + {
245 + }
246 +
247 +-#define l2x0_set_debug NULL
248 ++#define pl310_set_debug NULL
249 + #endif
250 +
251 + #ifdef CONFIG_PL310_ERRATA_588369
252 +@@ -331,6 +330,11 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
253 + else
254 + ways = 8;
255 + type = "L310";
256 ++#ifdef CONFIG_PL310_ERRATA_753970
257 ++ /* Unmapped register. */
258 ++ sync_reg_offset = L2X0_DUMMY_REG;
259 ++#endif
260 ++ outer_cache.set_debug = pl310_set_debug;
261 + break;
262 + case L2X0_CACHE_ID_PART_L210:
263 + ways = (aux >> 13) & 0xf;
264 +@@ -379,7 +383,6 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
265 + outer_cache.flush_all = l2x0_flush_all;
266 + outer_cache.inv_all = l2x0_inv_all;
267 + outer_cache.disable = l2x0_disable;
268 +- outer_cache.set_debug = l2x0_set_debug;
269 +
270 + printk(KERN_INFO "%s cache controller enabled\n", type);
271 + printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",
272 +diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
273 +index 89bbf4e..e77f4e4 100644
274 +--- a/arch/x86/boot/compressed/relocs.c
275 ++++ b/arch/x86/boot/compressed/relocs.c
276 +@@ -402,13 +402,11 @@ static void print_absolute_symbols(void)
277 + for (i = 0; i < ehdr.e_shnum; i++) {
278 + struct section *sec = &secs[i];
279 + char *sym_strtab;
280 +- Elf32_Sym *sh_symtab;
281 + int j;
282 +
283 + if (sec->shdr.sh_type != SHT_SYMTAB) {
284 + continue;
285 + }
286 +- sh_symtab = sec->symtab;
287 + sym_strtab = sec->link->strtab;
288 + for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
289 + Elf32_Sym *sym;
290 +diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
291 +index f98d84c..c4e3581 100644
292 +--- a/arch/x86/kernel/apic/apic.c
293 ++++ b/arch/x86/kernel/apic/apic.c
294 +@@ -1577,9 +1577,11 @@ static int __init apic_verify(void)
295 + mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
296 +
297 + /* The BIOS may have set up the APIC at some other address */
298 +- rdmsr(MSR_IA32_APICBASE, l, h);
299 +- if (l & MSR_IA32_APICBASE_ENABLE)
300 +- mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
301 ++ if (boot_cpu_data.x86 >= 6) {
302 ++ rdmsr(MSR_IA32_APICBASE, l, h);
303 ++ if (l & MSR_IA32_APICBASE_ENABLE)
304 ++ mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
305 ++ }
306 +
307 + pr_info("Found and enabled local APIC!\n");
308 + return 0;
309 +@@ -1597,13 +1599,15 @@ int __init apic_force_enable(unsigned long addr)
310 + * MSR. This can only be done in software for Intel P6 or later
311 + * and AMD K7 (Model > 1) or later.
312 + */
313 +- rdmsr(MSR_IA32_APICBASE, l, h);
314 +- if (!(l & MSR_IA32_APICBASE_ENABLE)) {
315 +- pr_info("Local APIC disabled by BIOS -- reenabling.\n");
316 +- l &= ~MSR_IA32_APICBASE_BASE;
317 +- l |= MSR_IA32_APICBASE_ENABLE | addr;
318 +- wrmsr(MSR_IA32_APICBASE, l, h);
319 +- enabled_via_apicbase = 1;
320 ++ if (boot_cpu_data.x86 >= 6) {
321 ++ rdmsr(MSR_IA32_APICBASE, l, h);
322 ++ if (!(l & MSR_IA32_APICBASE_ENABLE)) {
323 ++ pr_info("Local APIC disabled by BIOS -- reenabling.\n");
324 ++ l &= ~MSR_IA32_APICBASE_BASE;
325 ++ l |= MSR_IA32_APICBASE_ENABLE | addr;
326 ++ wrmsr(MSR_IA32_APICBASE, l, h);
327 ++ enabled_via_apicbase = 1;
328 ++ }
329 + }
330 + return apic_verify();
331 + }
332 +@@ -2149,10 +2153,12 @@ static void lapic_resume(void)
333 + * FIXME! This will be wrong if we ever support suspend on
334 + * SMP! We'll need to do this as part of the CPU restore!
335 + */
336 +- rdmsr(MSR_IA32_APICBASE, l, h);
337 +- l &= ~MSR_IA32_APICBASE_BASE;
338 +- l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
339 +- wrmsr(MSR_IA32_APICBASE, l, h);
340 ++ if (boot_cpu_data.x86 >= 6) {
341 ++ rdmsr(MSR_IA32_APICBASE, l, h);
342 ++ l &= ~MSR_IA32_APICBASE_BASE;
343 ++ l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
344 ++ wrmsr(MSR_IA32_APICBASE, l, h);
345 ++ }
346 + }
347 +
348 + maxlvt = lapic_get_maxlvt();
349 +diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
350 +index 9d46f5e..563a09d 100644
351 +--- a/arch/x86/kernel/microcode_core.c
352 ++++ b/arch/x86/kernel/microcode_core.c
353 +@@ -418,10 +418,8 @@ static int mc_sysdev_add(struct sys_device *sys_dev)
354 + if (err)
355 + return err;
356 +
357 +- if (microcode_init_cpu(cpu) == UCODE_ERROR) {
358 +- sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
359 ++ if (microcode_init_cpu(cpu) == UCODE_ERROR)
360 + return -EINVAL;
361 +- }
362 +
363 + return err;
364 + }
365 +diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
366 +index 71f4727..5a98aa2 100644
367 +--- a/arch/x86/kernel/setup_percpu.c
368 ++++ b/arch/x86/kernel/setup_percpu.c
369 +@@ -185,10 +185,22 @@ void __init setup_per_cpu_areas(void)
370 + #endif
371 + rc = -EINVAL;
372 + if (pcpu_chosen_fc != PCPU_FC_PAGE) {
373 +- const size_t atom_size = cpu_has_pse ? PMD_SIZE : PAGE_SIZE;
374 + const size_t dyn_size = PERCPU_MODULE_RESERVE +
375 + PERCPU_DYNAMIC_RESERVE - PERCPU_FIRST_CHUNK_RESERVE;
376 ++ size_t atom_size;
377 +
378 ++ /*
379 ++ * On 64bit, use PMD_SIZE for atom_size so that embedded
380 ++ * percpu areas are aligned to PMD. This, in the future,
381 ++ * can also allow using PMD mappings in vmalloc area. Use
382 ++ * PAGE_SIZE on 32bit as vmalloc space is highly contended
383 ++ * and large vmalloc area allocs can easily fail.
384 ++ */
385 ++#ifdef CONFIG_X86_64
386 ++ atom_size = PMD_SIZE;
387 ++#else
388 ++ atom_size = PAGE_SIZE;
389 ++#endif
390 + rc = pcpu_embed_first_chunk(PERCPU_FIRST_CHUNK_RESERVE,
391 + dyn_size, atom_size,
392 + pcpu_cpu_distance,
393 +diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
394 +index 1f92865..e7c920b 100644
395 +--- a/arch/x86/xen/enlighten.c
396 ++++ b/arch/x86/xen/enlighten.c
397 +@@ -62,6 +62,7 @@
398 + #include <asm/reboot.h>
399 + #include <asm/stackprotector.h>
400 + #include <asm/hypervisor.h>
401 ++#include <asm/pci_x86.h>
402 +
403 + #include "xen-ops.h"
404 + #include "mmu.h"
405 +@@ -1278,8 +1279,10 @@ asmlinkage void __init xen_start_kernel(void)
406 + /* Make sure ACS will be enabled */
407 + pci_request_acs();
408 + }
409 +-
410 +-
411 ++#ifdef CONFIG_PCI
412 ++ /* PCI BIOS service won't work from a PV guest. */
413 ++ pci_probe &= ~PCI_PROBE_BIOS;
414 ++#endif
415 + xen_raw_console_write("about to get started...\n");
416 +
417 + xen_setup_runstate_info(0);
418 +diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
419 +index 87f6673..ec3d603 100644
420 +--- a/arch/x86/xen/mmu.c
421 ++++ b/arch/x86/xen/mmu.c
422 +@@ -353,8 +353,13 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
423 + {
424 + if (val & _PAGE_PRESENT) {
425 + unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
426 ++ unsigned long pfn = mfn_to_pfn(mfn);
427 ++
428 + pteval_t flags = val & PTE_FLAGS_MASK;
429 +- val = ((pteval_t)mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
430 ++ if (unlikely(pfn == ~0))
431 ++ val = flags & ~_PAGE_PRESENT;
432 ++ else
433 ++ val = ((pteval_t)pfn << PAGE_SHIFT) | flags;
434 + }
435 +
436 + return val;
437 +diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
438 +index 041d4fe..9a23fff 100644
439 +--- a/arch/x86/xen/smp.c
440 ++++ b/arch/x86/xen/smp.c
441 +@@ -172,6 +172,7 @@ static void __init xen_fill_possible_map(void)
442 + static void __init xen_filter_cpu_maps(void)
443 + {
444 + int i, rc;
445 ++ unsigned int subtract = 0;
446 +
447 + if (!xen_initial_domain())
448 + return;
449 +@@ -186,8 +187,22 @@ static void __init xen_filter_cpu_maps(void)
450 + } else {
451 + set_cpu_possible(i, false);
452 + set_cpu_present(i, false);
453 ++ subtract++;
454 + }
455 + }
456 ++#ifdef CONFIG_HOTPLUG_CPU
457 ++ /* This is akin to using 'nr_cpus' on the Linux command line.
458 ++ * Which is OK as when we use 'dom0_max_vcpus=X' we can only
459 ++ * have up to X, while nr_cpu_ids is greater than X. This
460 ++ * normally is not a problem, except when CPU hotplugging
461 ++ * is involved and then there might be more than X CPUs
462 ++ * in the guest - which will not work as there is no
463 ++ * hypercall to expand the max number of VCPUs an already
464 ++ * running guest has. So cap it up to X. */
465 ++ if (subtract)
466 ++ nr_cpu_ids = nr_cpu_ids - subtract;
467 ++#endif
468 ++
469 + }
470 +
471 + static void __init xen_smp_prepare_boot_cpu(void)
472 +diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
473 +index 79d7362..3e45aa0 100644
474 +--- a/arch/x86/xen/xen-asm.S
475 ++++ b/arch/x86/xen/xen-asm.S
476 +@@ -96,7 +96,7 @@ ENTRY(xen_restore_fl_direct)
477 +
478 + /* check for unmasked and pending */
479 + cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
480 +- jz 1f
481 ++ jnz 1f
482 + 2: call check_events
483 + 1:
484 + ENDPATCH(xen_restore_fl_direct)
485 +diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
486 +index 107f6f7..dd30f40 100644
487 +--- a/crypto/sha512_generic.c
488 ++++ b/crypto/sha512_generic.c
489 +@@ -174,7 +174,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len)
490 + index = sctx->count[0] & 0x7f;
491 +
492 + /* Update number of bytes */
493 +- if (!(sctx->count[0] += len))
494 ++ if ((sctx->count[0] += len) < len)
495 + sctx->count[1]++;
496 +
497 + part_len = 128 - index;
498 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
499 +index a9b2820..58db834 100644
500 +--- a/drivers/ata/libata-eh.c
501 ++++ b/drivers/ata/libata-eh.c
502 +@@ -3500,7 +3500,8 @@ static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg
503 + u64 now = get_jiffies_64();
504 + int *trials = void_arg;
505 +
506 +- if (ent->timestamp < now - min(now, interval))
507 ++ if ((ent->eflags & ATA_EFLAG_OLD_ER) ||
508 ++ (ent->timestamp < now - min(now, interval)))
509 + return -1;
510 +
511 + (*trials)++;
512 +diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
513 +index 003cd8d..99fefbd 100644
514 +--- a/drivers/bluetooth/ath3k.c
515 ++++ b/drivers/bluetooth/ath3k.c
516 +@@ -73,6 +73,7 @@ static struct usb_device_id ath3k_table[] = {
517 + { USB_DEVICE(0x0CF3, 0x3004) },
518 + { USB_DEVICE(0x0CF3, 0x311D) },
519 + { USB_DEVICE(0x13d3, 0x3375) },
520 ++ { USB_DEVICE(0x04CA, 0x3005) },
521 +
522 + /* Atheros AR5BBU12 with sflash firmware */
523 + { USB_DEVICE(0x0489, 0xE02C) },
524 +@@ -91,6 +92,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
525 + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
526 + { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
527 + { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
528 ++ { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
529 +
530 + { } /* Terminating entry */
531 + };
532 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
533 +index db44ad5..e56da6a 100644
534 +--- a/drivers/bluetooth/btusb.c
535 ++++ b/drivers/bluetooth/btusb.c
536 +@@ -129,6 +129,7 @@ static struct usb_device_id blacklist_table[] = {
537 + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
538 + { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
539 + { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
540 ++ { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
541 +
542 + /* Atheros AR5BBU12 with sflash firmware */
543 + { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
544 +diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
545 +index a60adbf..79dcf6e 100644
546 +--- a/drivers/dma/at_hdmac.c
547 ++++ b/drivers/dma/at_hdmac.c
548 +@@ -239,10 +239,6 @@ static void atc_dostart(struct at_dma_chan *atchan, struct at_desc *first)
549 +
550 + vdbg_dump_regs(atchan);
551 +
552 +- /* clear any pending interrupt */
553 +- while (dma_readl(atdma, EBCISR))
554 +- cpu_relax();
555 +-
556 + channel_writel(atchan, SADDR, 0);
557 + channel_writel(atchan, DADDR, 0);
558 + channel_writel(atchan, CTRLA, 0);
559 +diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
560 +index b0a8117..0535c21 100644
561 +--- a/drivers/firmware/efivars.c
562 ++++ b/drivers/firmware/efivars.c
563 +@@ -191,6 +191,190 @@ utf16_strncmp(const efi_char16_t *a, const efi_char16_t *b, size_t len)
564 + }
565 + }
566 +
567 ++static bool
568 ++validate_device_path(struct efi_variable *var, int match, u8 *buffer,
569 ++ unsigned long len)
570 ++{
571 ++ struct efi_generic_dev_path *node;
572 ++ int offset = 0;
573 ++
574 ++ node = (struct efi_generic_dev_path *)buffer;
575 ++
576 ++ if (len < sizeof(*node))
577 ++ return false;
578 ++
579 ++ while (offset <= len - sizeof(*node) &&
580 ++ node->length >= sizeof(*node) &&
581 ++ node->length <= len - offset) {
582 ++ offset += node->length;
583 ++
584 ++ if ((node->type == EFI_DEV_END_PATH ||
585 ++ node->type == EFI_DEV_END_PATH2) &&
586 ++ node->sub_type == EFI_DEV_END_ENTIRE)
587 ++ return true;
588 ++
589 ++ node = (struct efi_generic_dev_path *)(buffer + offset);
590 ++ }
591 ++
592 ++ /*
593 ++ * If we're here then either node->length pointed past the end
594 ++ * of the buffer or we reached the end of the buffer without
595 ++ * finding a device path end node.
596 ++ */
597 ++ return false;
598 ++}
599 ++
600 ++static bool
601 ++validate_boot_order(struct efi_variable *var, int match, u8 *buffer,
602 ++ unsigned long len)
603 ++{
604 ++ /* An array of 16-bit integers */
605 ++ if ((len % 2) != 0)
606 ++ return false;
607 ++
608 ++ return true;
609 ++}
610 ++
611 ++static bool
612 ++validate_load_option(struct efi_variable *var, int match, u8 *buffer,
613 ++ unsigned long len)
614 ++{
615 ++ u16 filepathlength;
616 ++ int i, desclength = 0, namelen;
617 ++
618 ++ namelen = utf16_strnlen(var->VariableName, sizeof(var->VariableName));
619 ++
620 ++ /* Either "Boot" or "Driver" followed by four digits of hex */
621 ++ for (i = match; i < match+4; i++) {
622 ++ if (var->VariableName[i] > 127 ||
623 ++ hex_to_bin(var->VariableName[i] & 0xff) < 0)
624 ++ return true;
625 ++ }
626 ++
627 ++ /* Reject it if there's 4 digits of hex and then further content */
628 ++ if (namelen > match + 4)
629 ++ return false;
630 ++
631 ++ /* A valid entry must be at least 8 bytes */
632 ++ if (len < 8)
633 ++ return false;
634 ++
635 ++ filepathlength = buffer[4] | buffer[5] << 8;
636 ++
637 ++ /*
638 ++ * There's no stored length for the description, so it has to be
639 ++ * found by hand
640 ++ */
641 ++ desclength = utf16_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2;
642 ++
643 ++ /* Each boot entry must have a descriptor */
644 ++ if (!desclength)
645 ++ return false;
646 ++
647 ++ /*
648 ++ * If the sum of the length of the description, the claimed filepath
649 ++ * length and the original header are greater than the length of the
650 ++ * variable, it's malformed
651 ++ */
652 ++ if ((desclength + filepathlength + 6) > len)
653 ++ return false;
654 ++
655 ++ /*
656 ++ * And, finally, check the filepath
657 ++ */
658 ++ return validate_device_path(var, match, buffer + desclength + 6,
659 ++ filepathlength);
660 ++}
661 ++
662 ++static bool
663 ++validate_uint16(struct efi_variable *var, int match, u8 *buffer,
664 ++ unsigned long len)
665 ++{
666 ++ /* A single 16-bit integer */
667 ++ if (len != 2)
668 ++ return false;
669 ++
670 ++ return true;
671 ++}
672 ++
673 ++static bool
674 ++validate_ascii_string(struct efi_variable *var, int match, u8 *buffer,
675 ++ unsigned long len)
676 ++{
677 ++ int i;
678 ++
679 ++ for (i = 0; i < len; i++) {
680 ++ if (buffer[i] > 127)
681 ++ return false;
682 ++
683 ++ if (buffer[i] == 0)
684 ++ return true;
685 ++ }
686 ++
687 ++ return false;
688 ++}
689 ++
690 ++struct variable_validate {
691 ++ char *name;
692 ++ bool (*validate)(struct efi_variable *var, int match, u8 *data,
693 ++ unsigned long len);
694 ++};
695 ++
696 ++static const struct variable_validate variable_validate[] = {
697 ++ { "BootNext", validate_uint16 },
698 ++ { "BootOrder", validate_boot_order },
699 ++ { "DriverOrder", validate_boot_order },
700 ++ { "Boot*", validate_load_option },
701 ++ { "Driver*", validate_load_option },
702 ++ { "ConIn", validate_device_path },
703 ++ { "ConInDev", validate_device_path },
704 ++ { "ConOut", validate_device_path },
705 ++ { "ConOutDev", validate_device_path },
706 ++ { "ErrOut", validate_device_path },
707 ++ { "ErrOutDev", validate_device_path },
708 ++ { "Timeout", validate_uint16 },
709 ++ { "Lang", validate_ascii_string },
710 ++ { "PlatformLang", validate_ascii_string },
711 ++ { "", NULL },
712 ++};
713 ++
714 ++static bool
715 ++validate_var(struct efi_variable *var, u8 *data, unsigned long len)
716 ++{
717 ++ int i;
718 ++ u16 *unicode_name = var->VariableName;
719 ++
720 ++ for (i = 0; variable_validate[i].validate != NULL; i++) {
721 ++ const char *name = variable_validate[i].name;
722 ++ int match;
723 ++
724 ++ for (match = 0; ; match++) {
725 ++ char c = name[match];
726 ++ u16 u = unicode_name[match];
727 ++
728 ++ /* All special variables are plain ascii */
729 ++ if (u > 127)
730 ++ return true;
731 ++
732 ++ /* Wildcard in the matching name means we've matched */
733 ++ if (c == '*')
734 ++ return variable_validate[i].validate(var,
735 ++ match, data, len);
736 ++
737 ++ /* Case sensitive match */
738 ++ if (c != u)
739 ++ break;
740 ++
741 ++ /* Reached the end of the string while matching */
742 ++ if (!c)
743 ++ return variable_validate[i].validate(var,
744 ++ match, data, len);
745 ++ }
746 ++ }
747 ++
748 ++ return true;
749 ++}
750 ++
751 + static efi_status_t
752 + get_var_data_locked(struct efivars *efivars, struct efi_variable *var)
753 + {
754 +@@ -324,6 +508,12 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count)
755 + return -EINVAL;
756 + }
757 +
758 ++ if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 ||
759 ++ validate_var(new_var, new_var->Data, new_var->DataSize) == false) {
760 ++ printk(KERN_ERR "efivars: Malformed variable content\n");
761 ++ return -EINVAL;
762 ++ }
763 ++
764 + spin_lock(&efivars->lock);
765 + status = efivars->ops->set_variable(new_var->VariableName,
766 + &new_var->VendorGuid,
767 +@@ -624,6 +814,12 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
768 + if (!capable(CAP_SYS_ADMIN))
769 + return -EACCES;
770 +
771 ++ if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 ||
772 ++ validate_var(new_var, new_var->Data, new_var->DataSize) == false) {
773 ++ printk(KERN_ERR "efivars: Malformed variable content\n");
774 ++ return -EINVAL;
775 ++ }
776 ++
777 + spin_lock(&efivars->lock);
778 +
779 + /*
780 +diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
781 +index b9da890..a6c2f7a 100644
782 +--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
783 ++++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
784 +@@ -984,6 +984,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
785 + struct intel_ring_buffer *ring;
786 + u32 exec_start, exec_len;
787 + u32 seqno;
788 ++ u32 mask;
789 + int ret, mode, i;
790 +
791 + if (!i915_gem_check_execbuffer(args)) {
792 +@@ -1021,6 +1022,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
793 + }
794 +
795 + mode = args->flags & I915_EXEC_CONSTANTS_MASK;
796 ++ mask = I915_EXEC_CONSTANTS_MASK;
797 + switch (mode) {
798 + case I915_EXEC_CONSTANTS_REL_GENERAL:
799 + case I915_EXEC_CONSTANTS_ABSOLUTE:
800 +@@ -1034,18 +1036,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
801 + mode == I915_EXEC_CONSTANTS_REL_SURFACE)
802 + return -EINVAL;
803 +
804 +- ret = intel_ring_begin(ring, 4);
805 +- if (ret)
806 +- return ret;
807 +-
808 +- intel_ring_emit(ring, MI_NOOP);
809 +- intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
810 +- intel_ring_emit(ring, INSTPM);
811 +- intel_ring_emit(ring,
812 +- I915_EXEC_CONSTANTS_MASK << 16 | mode);
813 +- intel_ring_advance(ring);
814 +-
815 +- dev_priv->relative_constants_mode = mode;
816 ++ /* The HW changed the meaning on this bit on gen6 */
817 ++ if (INTEL_INFO(dev)->gen >= 6)
818 ++ mask &= ~I915_EXEC_CONSTANTS_REL_SURFACE;
819 + }
820 + break;
821 + default:
822 +@@ -1064,6 +1057,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
823 + return -EINVAL;
824 + }
825 +
826 ++ if (args->num_cliprects > UINT_MAX / sizeof(*cliprects)) {
827 ++ DRM_DEBUG("execbuf with %u cliprects\n",
828 ++ args->num_cliprects);
829 ++ return -EINVAL;
830 ++ }
831 + cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects),
832 + GFP_KERNEL);
833 + if (cliprects == NULL) {
834 +@@ -1176,6 +1174,21 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
835 + }
836 + }
837 +
838 ++ if (ring == &dev_priv->ring[RCS] &&
839 ++ mode != dev_priv->relative_constants_mode) {
840 ++ ret = intel_ring_begin(ring, 4);
841 ++ if (ret)
842 ++ goto err;
843 ++
844 ++ intel_ring_emit(ring, MI_NOOP);
845 ++ intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
846 ++ intel_ring_emit(ring, INSTPM);
847 ++ intel_ring_emit(ring, mask << 16 | mode);
848 ++ intel_ring_advance(ring);
849 ++
850 ++ dev_priv->relative_constants_mode = mode;
851 ++ }
852 ++
853 + trace_i915_gem_ring_dispatch(ring, seqno);
854 +
855 + exec_start = batch_obj->gtt_offset + args->batch_start_offset;
856 +@@ -1314,7 +1327,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
857 + struct drm_i915_gem_exec_object2 *exec2_list = NULL;
858 + int ret;
859 +
860 +- if (args->buffer_count < 1) {
861 ++ if (args->buffer_count < 1 ||
862 ++ args->buffer_count > UINT_MAX / sizeof(*exec2_list)) {
863 + DRM_ERROR("execbuf2 with %d buffers\n", args->buffer_count);
864 + return -EINVAL;
865 + }
866 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
867 +index 2f99fd4..cbe5a88 100644
868 +--- a/drivers/gpu/drm/i915/i915_reg.h
869 ++++ b/drivers/gpu/drm/i915/i915_reg.h
870 +@@ -442,6 +442,7 @@
871 + #define INSTPM_AGPBUSY_DIS (1<<11) /* gen3: when disabled, pending interrupts
872 + will not assert AGPBUSY# and will only
873 + be delivered when out of C3. */
874 ++#define INSTPM_FORCE_ORDERING (1<<7) /* GEN6+ */
875 + #define ACTHD 0x020c8
876 + #define FW_BLC 0x020d8
877 + #define FW_BLC2 0x020dc
878 +@@ -522,6 +523,7 @@
879 + #define CM0_MASK_SHIFT 16
880 + #define CM0_IZ_OPT_DISABLE (1<<6)
881 + #define CM0_ZR_OPT_DISABLE (1<<5)
882 ++#define CM0_STC_EVICT_DISABLE_LRA_SNB (1<<5)
883 + #define CM0_DEPTH_EVICT_DISABLE (1<<4)
884 + #define CM0_COLOR_EVICT_DISABLE (1<<3)
885 + #define CM0_DEPTH_WRITE_DISABLE (1<<1)
886 +diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
887 +index 64541f7..9cd81ba 100644
888 +--- a/drivers/gpu/drm/i915/intel_hdmi.c
889 ++++ b/drivers/gpu/drm/i915/intel_hdmi.c
890 +@@ -136,7 +136,7 @@ static void i9xx_write_infoframe(struct drm_encoder *encoder,
891 +
892 + val &= ~VIDEO_DIP_SELECT_MASK;
893 +
894 +- I915_WRITE(VIDEO_DIP_CTL, val | port | flags);
895 ++ I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | val | port | flags);
896 +
897 + for (i = 0; i < len; i += 4) {
898 + I915_WRITE(VIDEO_DIP_DATA, *data);
899 +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
900 +index 8673581..62f9ac5 100644
901 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
902 ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
903 +@@ -414,6 +414,22 @@ static int init_render_ring(struct intel_ring_buffer *ring)
904 + return ret;
905 + }
906 +
907 ++
908 ++ if (IS_GEN6(dev)) {
909 ++ /* From the Sandybridge PRM, volume 1 part 3, page 24:
910 ++ * "If this bit is set, STCunit will have LRA as replacement
911 ++ * policy. [...] This bit must be reset. LRA replacement
912 ++ * policy is not supported."
913 ++ */
914 ++ I915_WRITE(CACHE_MODE_0,
915 ++ CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT);
916 ++ }
917 ++
918 ++ if (INTEL_INFO(dev)->gen >= 6) {
919 ++ I915_WRITE(INSTPM,
920 ++ INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING);
921 ++ }
922 ++
923 + return ret;
924 + }
925 +
926 +diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
927 +index e334ec3..8eddcca 100644
928 +--- a/drivers/gpu/drm/i915/intel_sdvo.c
929 ++++ b/drivers/gpu/drm/i915/intel_sdvo.c
930 +@@ -731,6 +731,7 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
931 + uint16_t width, height;
932 + uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
933 + uint16_t h_sync_offset, v_sync_offset;
934 ++ int mode_clock;
935 +
936 + width = mode->crtc_hdisplay;
937 + height = mode->crtc_vdisplay;
938 +@@ -745,7 +746,11 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
939 + h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
940 + v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
941 +
942 +- dtd->part1.clock = mode->clock / 10;
943 ++ mode_clock = mode->clock;
944 ++ mode_clock /= intel_mode_get_pixel_multiplier(mode) ?: 1;
945 ++ mode_clock /= 10;
946 ++ dtd->part1.clock = mode_clock;
947 ++
948 + dtd->part1.h_active = width & 0xff;
949 + dtd->part1.h_blank = h_blank_len & 0xff;
950 + dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
951 +@@ -997,7 +1002,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
952 + struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder);
953 + u32 sdvox;
954 + struct intel_sdvo_in_out_map in_out;
955 +- struct intel_sdvo_dtd input_dtd;
956 ++ struct intel_sdvo_dtd input_dtd, output_dtd;
957 + int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode);
958 + int rate;
959 +
960 +@@ -1022,20 +1027,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
961 + intel_sdvo->attached_output))
962 + return;
963 +
964 +- /* We have tried to get input timing in mode_fixup, and filled into
965 +- * adjusted_mode.
966 +- */
967 +- if (intel_sdvo->is_tv || intel_sdvo->is_lvds) {
968 +- input_dtd = intel_sdvo->input_dtd;
969 +- } else {
970 +- /* Set the output timing to the screen */
971 +- if (!intel_sdvo_set_target_output(intel_sdvo,
972 +- intel_sdvo->attached_output))
973 +- return;
974 +-
975 +- intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
976 +- (void) intel_sdvo_set_output_timing(intel_sdvo, &input_dtd);
977 +- }
978 ++ /* lvds has a special fixed output timing. */
979 ++ if (intel_sdvo->is_lvds)
980 ++ intel_sdvo_get_dtd_from_mode(&output_dtd,
981 ++ intel_sdvo->sdvo_lvds_fixed_mode);
982 ++ else
983 ++ intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
984 ++ (void) intel_sdvo_set_output_timing(intel_sdvo, &output_dtd);
985 +
986 + /* Set the input timing to the screen. Assume always input 0. */
987 + if (!intel_sdvo_set_target_input(intel_sdvo))
988 +@@ -1053,6 +1051,10 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
989 + !intel_sdvo_set_tv_format(intel_sdvo))
990 + return;
991 +
992 ++ /* We have tried to get input timing in mode_fixup, and filled into
993 ++ * adjusted_mode.
994 ++ */
995 ++ intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
996 + (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd);
997 +
998 + switch (pixel_multiplier) {
999 +@@ -1219,8 +1221,14 @@ static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in
1000 +
1001 + static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo)
1002 + {
1003 ++ struct drm_device *dev = intel_sdvo->base.base.dev;
1004 + u8 response[2];
1005 +
1006 ++ /* HW Erratum: SDVO Hotplug is broken on all i945G chips, there's noise
1007 ++ * on the line. */
1008 ++ if (IS_I945G(dev) || IS_I945GM(dev))
1009 ++ return false;
1010 ++
1011 + return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
1012 + &response, 2) && response[0];
1013 + }
1014 +diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
1015 +index 525744d..3df56c7 100644
1016 +--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
1017 ++++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
1018 +@@ -245,7 +245,7 @@ static bool nouveau_dsm_detect(void)
1019 + struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
1020 + struct pci_dev *pdev = NULL;
1021 + int has_dsm = 0;
1022 +- int has_optimus;
1023 ++ int has_optimus = 0;
1024 + int vga_count = 0;
1025 + bool guid_valid;
1026 + int retval;
1027 +diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
1028 +index b30081f..757c549 100644
1029 +--- a/drivers/gpu/drm/radeon/atombios_crtc.c
1030 ++++ b/drivers/gpu/drm/radeon/atombios_crtc.c
1031 +@@ -917,8 +917,8 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
1032 + break;
1033 + }
1034 +
1035 +- if (radeon_encoder->active_device &
1036 +- (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) {
1037 ++ if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
1038 ++ (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
1039 + struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1040 + struct drm_connector *connector =
1041 + radeon_get_connector_for_encoder(encoder);
1042 +diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
1043 +index 104b376..427468f 100644
1044 +--- a/drivers/hwmon/coretemp.c
1045 ++++ b/drivers/hwmon/coretemp.c
1046 +@@ -51,7 +51,7 @@ module_param_named(tjmax, force_tjmax, int, 0444);
1047 + MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
1048 +
1049 + #define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */
1050 +-#define NUM_REAL_CORES 16 /* Number of Real cores per cpu */
1051 ++#define NUM_REAL_CORES 32 /* Number of Real cores per cpu */
1052 + #define CORETEMP_NAME_LENGTH 17 /* String Length of attrs */
1053 + #define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */
1054 + #define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
1055 +@@ -705,6 +705,10 @@ static void __cpuinit put_core_offline(unsigned int cpu)
1056 +
1057 + indx = TO_ATTR_NO(cpu);
1058 +
1059 ++ /* The core id is too big, just return */
1060 ++ if (indx > MAX_CORE_DATA - 1)
1061 ++ return;
1062 ++
1063 + if (pdata->core_data[indx] && pdata->core_data[indx]->cpu == cpu)
1064 + coretemp_remove_core(pdata, &pdev->dev, indx);
1065 +
1066 +diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
1067 +index 930370d..9a4c3ab 100644
1068 +--- a/drivers/hwmon/fam15h_power.c
1069 ++++ b/drivers/hwmon/fam15h_power.c
1070 +@@ -122,6 +122,41 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
1071 + return true;
1072 + }
1073 +
1074 ++/*
1075 ++ * Newer BKDG versions have an updated recommendation on how to properly
1076 ++ * initialize the running average range (was: 0xE, now: 0x9). This avoids
1077 ++ * counter saturations resulting in bogus power readings.
1078 ++ * We correct this value ourselves to cope with older BIOSes.
1079 ++ */
1080 ++static DEFINE_PCI_DEVICE_TABLE(affected_device) = {
1081 ++ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
1082 ++ { 0 }
1083 ++};
1084 ++
1085 ++static void __devinit tweak_runavg_range(struct pci_dev *pdev)
1086 ++{
1087 ++ u32 val;
1088 ++
1089 ++ /*
1090 ++ * let this quirk apply only to the current version of the
1091 ++ * northbridge, since future versions may change the behavior
1092 ++ */
1093 ++ if (!pci_match_id(affected_device, pdev))
1094 ++ return;
1095 ++
1096 ++ pci_bus_read_config_dword(pdev->bus,
1097 ++ PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
1098 ++ REG_TDP_RUNNING_AVERAGE, &val);
1099 ++ if ((val & 0xf) != 0xe)
1100 ++ return;
1101 ++
1102 ++ val &= ~0xf;
1103 ++ val |= 0x9;
1104 ++ pci_bus_write_config_dword(pdev->bus,
1105 ++ PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
1106 ++ REG_TDP_RUNNING_AVERAGE, val);
1107 ++}
1108 ++
1109 + static void __devinit fam15h_power_init_data(struct pci_dev *f4,
1110 + struct fam15h_power_data *data)
1111 + {
1112 +@@ -155,6 +190,13 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
1113 + struct device *dev;
1114 + int err;
1115 +
1116 ++ /*
1117 ++ * though we ignore every other northbridge, we still have to
1118 ++ * do the tweaking on _each_ node in MCM processors as the counters
1119 ++ * are working hand-in-hand
1120 ++ */
1121 ++ tweak_runavg_range(pdev);
1122 ++
1123 + if (!fam15h_power_is_internal_node0(pdev)) {
1124 + err = -ENODEV;
1125 + goto exit;
1126 +diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
1127 +index 04be9f8..eb8ad53 100644
1128 +--- a/drivers/i2c/busses/i2c-pnx.c
1129 ++++ b/drivers/i2c/busses/i2c-pnx.c
1130 +@@ -546,8 +546,7 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
1131 + {
1132 + struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
1133 +
1134 +- /* FIXME: shouldn't this be clk_disable? */
1135 +- clk_enable(alg_data->clk);
1136 ++ clk_disable(alg_data->clk);
1137 +
1138 + return 0;
1139 + }
1140 +diff --git a/drivers/md/md.c b/drivers/md/md.c
1141 +index 6f37aa4..065ab4f 100644
1142 +--- a/drivers/md/md.c
1143 ++++ b/drivers/md/md.c
1144 +@@ -8100,7 +8100,8 @@ static int md_notify_reboot(struct notifier_block *this,
1145 +
1146 + for_each_mddev(mddev, tmp) {
1147 + if (mddev_trylock(mddev)) {
1148 +- __md_stop_writes(mddev);
1149 ++ if (mddev->pers)
1150 ++ __md_stop_writes(mddev);
1151 + mddev->safemode = 2;
1152 + mddev_unlock(mddev);
1153 + }
1154 +diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
1155 +index f6431ef..a1f5e3d 100644
1156 +--- a/drivers/media/dvb/frontends/drxk_hard.c
1157 ++++ b/drivers/media/dvb/frontends/drxk_hard.c
1158 +@@ -1523,8 +1523,10 @@ static int scu_command(struct drxk_state *state,
1159 + dprintk(1, "\n");
1160 +
1161 + if ((cmd == 0) || ((parameterLen > 0) && (parameter == NULL)) ||
1162 +- ((resultLen > 0) && (result == NULL)))
1163 +- goto error;
1164 ++ ((resultLen > 0) && (result == NULL))) {
1165 ++ printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__);
1166 ++ return status;
1167 ++ }
1168 +
1169 + mutex_lock(&state->mutex);
1170 +
1171 +diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
1172 +index 13f54b5..a7e7d6f 100644
1173 +--- a/drivers/media/rc/winbond-cir.c
1174 ++++ b/drivers/media/rc/winbond-cir.c
1175 +@@ -1046,6 +1046,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1176 + goto exit_unregister_led;
1177 + }
1178 +
1179 ++ data->dev->driver_type = RC_DRIVER_IR_RAW;
1180 + data->dev->driver_name = WBCIR_NAME;
1181 + data->dev->input_name = WBCIR_NAME;
1182 + data->dev->input_phys = "wbcir/cir0";
1183 +diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
1184 +index e15e47d..34416d4 100644
1185 +--- a/drivers/mmc/card/block.c
1186 ++++ b/drivers/mmc/card/block.c
1187 +@@ -799,7 +799,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
1188 + {
1189 + struct mmc_blk_data *md = mq->data;
1190 + struct mmc_card *card = md->queue.card;
1191 +- unsigned int from, nr, arg;
1192 ++ unsigned int from, nr, arg, trim_arg, erase_arg;
1193 + int err = 0, type = MMC_BLK_SECDISCARD;
1194 +
1195 + if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
1196 +@@ -807,20 +807,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
1197 + goto out;
1198 + }
1199 +
1200 ++ from = blk_rq_pos(req);
1201 ++ nr = blk_rq_sectors(req);
1202 ++
1203 + /* The sanitize operation is supported at v4.5 only */
1204 + if (mmc_can_sanitize(card)) {
1205 +- err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1206 +- EXT_CSD_SANITIZE_START, 1, 0);
1207 +- goto out;
1208 ++ erase_arg = MMC_ERASE_ARG;
1209 ++ trim_arg = MMC_TRIM_ARG;
1210 ++ } else {
1211 ++ erase_arg = MMC_SECURE_ERASE_ARG;
1212 ++ trim_arg = MMC_SECURE_TRIM1_ARG;
1213 + }
1214 +
1215 +- from = blk_rq_pos(req);
1216 +- nr = blk_rq_sectors(req);
1217 +-
1218 +- if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
1219 +- arg = MMC_SECURE_TRIM1_ARG;
1220 +- else
1221 +- arg = MMC_SECURE_ERASE_ARG;
1222 ++ if (mmc_erase_group_aligned(card, from, nr))
1223 ++ arg = erase_arg;
1224 ++ else if (mmc_can_trim(card))
1225 ++ arg = trim_arg;
1226 ++ else {
1227 ++ err = -EINVAL;
1228 ++ goto out;
1229 ++ }
1230 + retry:
1231 + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
1232 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1233 +@@ -830,25 +836,41 @@ retry:
1234 + INAND_CMD38_ARG_SECERASE,
1235 + 0);
1236 + if (err)
1237 +- goto out;
1238 ++ goto out_retry;
1239 + }
1240 ++
1241 + err = mmc_erase(card, from, nr, arg);
1242 +- if (!err && arg == MMC_SECURE_TRIM1_ARG) {
1243 ++ if (err == -EIO)
1244 ++ goto out_retry;
1245 ++ if (err)
1246 ++ goto out;
1247 ++
1248 ++ if (arg == MMC_SECURE_TRIM1_ARG) {
1249 + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
1250 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1251 + INAND_CMD38_ARG_EXT_CSD,
1252 + INAND_CMD38_ARG_SECTRIM2,
1253 + 0);
1254 + if (err)
1255 +- goto out;
1256 ++ goto out_retry;
1257 + }
1258 ++
1259 + err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
1260 ++ if (err == -EIO)
1261 ++ goto out_retry;
1262 ++ if (err)
1263 ++ goto out;
1264 + }
1265 +-out:
1266 +- if (err == -EIO && !mmc_blk_reset(md, card->host, type))
1267 ++
1268 ++ if (mmc_can_sanitize(card))
1269 ++ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1270 ++ EXT_CSD_SANITIZE_START, 1, 0);
1271 ++out_retry:
1272 ++ if (err && !mmc_blk_reset(md, card->host, type))
1273 + goto retry;
1274 + if (!err)
1275 + mmc_blk_reset_success(md, type);
1276 ++out:
1277 + spin_lock_irq(&md->lock);
1278 + __blk_end_request(req, err, blk_rq_bytes(req));
1279 + spin_unlock_irq(&md->lock);
1280 +diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
1281 +index dcad59c..78690f2 100644
1282 +--- a/drivers/mmc/card/queue.c
1283 ++++ b/drivers/mmc/card/queue.c
1284 +@@ -134,7 +134,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
1285 +
1286 + queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
1287 + q->limits.max_discard_sectors = max_discard;
1288 +- if (card->erased_byte == 0)
1289 ++ if (card->erased_byte == 0 && !mmc_can_discard(card))
1290 + q->limits.discard_zeroes_data = 1;
1291 + q->limits.discard_granularity = card->pref_erase << 9;
1292 + /* granularity must not be greater than max. discard */
1293 +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1294 +index 950b97d..411a994 100644
1295 +--- a/drivers/mmc/core/core.c
1296 ++++ b/drivers/mmc/core/core.c
1297 +@@ -1516,7 +1516,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
1298 + {
1299 + unsigned int erase_timeout;
1300 +
1301 +- if (card->ext_csd.erase_group_def & 1) {
1302 ++ if (arg == MMC_DISCARD_ARG ||
1303 ++ (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
1304 ++ erase_timeout = card->ext_csd.trim_timeout;
1305 ++ } else if (card->ext_csd.erase_group_def & 1) {
1306 + /* High Capacity Erase Group Size uses HC timeouts */
1307 + if (arg == MMC_TRIM_ARG)
1308 + erase_timeout = card->ext_csd.trim_timeout;
1309 +@@ -1788,8 +1791,6 @@ int mmc_can_trim(struct mmc_card *card)
1310 + {
1311 + if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
1312 + return 1;
1313 +- if (mmc_can_discard(card))
1314 +- return 1;
1315 + return 0;
1316 + }
1317 + EXPORT_SYMBOL(mmc_can_trim);
1318 +@@ -1808,6 +1809,8 @@ EXPORT_SYMBOL(mmc_can_discard);
1319 +
1320 + int mmc_can_sanitize(struct mmc_card *card)
1321 + {
1322 ++ if (!mmc_can_trim(card) && !mmc_can_erase(card))
1323 ++ return 0;
1324 + if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
1325 + return 1;
1326 + return 0;
1327 +diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
1328 +index 4540e37..1b47937 100644
1329 +--- a/drivers/mmc/host/sdhci-esdhc-imx.c
1330 ++++ b/drivers/mmc/host/sdhci-esdhc-imx.c
1331 +@@ -467,8 +467,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
1332 + clk_enable(clk);
1333 + pltfm_host->clk = clk;
1334 +
1335 +- if (!is_imx25_esdhc(imx_data))
1336 +- host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
1337 ++ host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
1338 +
1339 + if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
1340 + /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
1341 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
1342 +index e58aa2b..f65e0b9 100644
1343 +--- a/drivers/net/bonding/bond_main.c
1344 ++++ b/drivers/net/bonding/bond_main.c
1345 +@@ -2982,7 +2982,11 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
1346 + trans_start + delta_in_ticks)) ||
1347 + bond->curr_active_slave != slave) {
1348 + slave->link = BOND_LINK_UP;
1349 +- bond->current_arp_slave = NULL;
1350 ++ if (bond->current_arp_slave) {
1351 ++ bond_set_slave_inactive_flags(
1352 ++ bond->current_arp_slave);
1353 ++ bond->current_arp_slave = NULL;
1354 ++ }
1355 +
1356 + pr_info("%s: link status definitely up for interface %s.\n",
1357 + bond->dev->name, slave->dev->name);
1358 +diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
1359 +index a7c5e88..eeac9ca 100644
1360 +--- a/drivers/net/dummy.c
1361 ++++ b/drivers/net/dummy.c
1362 +@@ -106,14 +106,14 @@ static int dummy_dev_init(struct net_device *dev)
1363 + return 0;
1364 + }
1365 +
1366 +-static void dummy_dev_free(struct net_device *dev)
1367 ++static void dummy_dev_uninit(struct net_device *dev)
1368 + {
1369 + free_percpu(dev->dstats);
1370 +- free_netdev(dev);
1371 + }
1372 +
1373 + static const struct net_device_ops dummy_netdev_ops = {
1374 + .ndo_init = dummy_dev_init,
1375 ++ .ndo_uninit = dummy_dev_uninit,
1376 + .ndo_start_xmit = dummy_xmit,
1377 + .ndo_validate_addr = eth_validate_addr,
1378 + .ndo_set_rx_mode = set_multicast_list,
1379 +@@ -127,7 +127,7 @@ static void dummy_setup(struct net_device *dev)
1380 +
1381 + /* Initialize the device structure. */
1382 + dev->netdev_ops = &dummy_netdev_ops;
1383 +- dev->destructor = dummy_dev_free;
1384 ++ dev->destructor = free_netdev;
1385 +
1386 + /* Fill in device structure with ethernet-generic values. */
1387 + dev->tx_queue_len = 0;
1388 +diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
1389 +index 33a4e35..ee532e1 100644
1390 +--- a/drivers/net/ethernet/atheros/atlx/atl1.c
1391 ++++ b/drivers/net/ethernet/atheros/atlx/atl1.c
1392 +@@ -2473,7 +2473,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
1393 + "pcie phy link down %x\n", status);
1394 + if (netif_running(adapter->netdev)) { /* reset MAC */
1395 + iowrite32(0, adapter->hw.hw_addr + REG_IMR);
1396 +- schedule_work(&adapter->pcie_dma_to_rst_task);
1397 ++ schedule_work(&adapter->reset_dev_task);
1398 + return IRQ_HANDLED;
1399 + }
1400 + }
1401 +@@ -2485,7 +2485,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
1402 + "pcie DMA r/w error (status = 0x%x)\n",
1403 + status);
1404 + iowrite32(0, adapter->hw.hw_addr + REG_IMR);
1405 +- schedule_work(&adapter->pcie_dma_to_rst_task);
1406 ++ schedule_work(&adapter->reset_dev_task);
1407 + return IRQ_HANDLED;
1408 + }
1409 +
1410 +@@ -2630,10 +2630,10 @@ static void atl1_down(struct atl1_adapter *adapter)
1411 + atl1_clean_rx_ring(adapter);
1412 + }
1413 +
1414 +-static void atl1_tx_timeout_task(struct work_struct *work)
1415 ++static void atl1_reset_dev_task(struct work_struct *work)
1416 + {
1417 + struct atl1_adapter *adapter =
1418 +- container_of(work, struct atl1_adapter, tx_timeout_task);
1419 ++ container_of(work, struct atl1_adapter, reset_dev_task);
1420 + struct net_device *netdev = adapter->netdev;
1421 +
1422 + netif_device_detach(netdev);
1423 +@@ -3032,12 +3032,10 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
1424 + (unsigned long)adapter);
1425 + adapter->phy_timer_pending = false;
1426 +
1427 +- INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task);
1428 ++ INIT_WORK(&adapter->reset_dev_task, atl1_reset_dev_task);
1429 +
1430 + INIT_WORK(&adapter->link_chg_task, atlx_link_chg_task);
1431 +
1432 +- INIT_WORK(&adapter->pcie_dma_to_rst_task, atl1_tx_timeout_task);
1433 +-
1434 + err = register_netdev(netdev);
1435 + if (err)
1436 + goto err_common;
1437 +diff --git a/drivers/net/ethernet/atheros/atlx/atl1.h b/drivers/net/ethernet/atheros/atlx/atl1.h
1438 +index 109d6da..e04bf4d 100644
1439 +--- a/drivers/net/ethernet/atheros/atlx/atl1.h
1440 ++++ b/drivers/net/ethernet/atheros/atlx/atl1.h
1441 +@@ -758,9 +758,8 @@ struct atl1_adapter {
1442 + u16 link_speed;
1443 + u16 link_duplex;
1444 + spinlock_t lock;
1445 +- struct work_struct tx_timeout_task;
1446 ++ struct work_struct reset_dev_task;
1447 + struct work_struct link_chg_task;
1448 +- struct work_struct pcie_dma_to_rst_task;
1449 +
1450 + struct timer_list phy_config_timer;
1451 + bool phy_timer_pending;
1452 +diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c
1453 +index aabcf4b..41c6d83 100644
1454 +--- a/drivers/net/ethernet/atheros/atlx/atlx.c
1455 ++++ b/drivers/net/ethernet/atheros/atlx/atlx.c
1456 +@@ -193,7 +193,7 @@ static void atlx_tx_timeout(struct net_device *netdev)
1457 + {
1458 + struct atlx_adapter *adapter = netdev_priv(netdev);
1459 + /* Do the reset outside of interrupt context */
1460 +- schedule_work(&adapter->tx_timeout_task);
1461 ++ schedule_work(&adapter->reset_dev_task);
1462 + }
1463 +
1464 + /*
1465 +diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
1466 +index d19c849..77241b6 100644
1467 +--- a/drivers/net/ethernet/micrel/ks8851_mll.c
1468 ++++ b/drivers/net/ethernet/micrel/ks8851_mll.c
1469 +@@ -40,7 +40,7 @@
1470 + #define DRV_NAME "ks8851_mll"
1471 +
1472 + static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
1473 +-#define MAX_RECV_FRAMES 32
1474 ++#define MAX_RECV_FRAMES 255
1475 + #define MAX_BUF_SIZE 2048
1476 + #define TX_BUF_SIZE 2000
1477 + #define RX_BUF_SIZE 2000
1478 +diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
1479 +index 7ece990..4b9f4bd 100644
1480 +--- a/drivers/net/ethernet/micrel/ksz884x.c
1481 ++++ b/drivers/net/ethernet/micrel/ksz884x.c
1482 +@@ -5679,7 +5679,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr)
1483 + memcpy(hw->override_addr, mac->sa_data, MAC_ADDR_LEN);
1484 + }
1485 +
1486 +- memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN);
1487 ++ memcpy(dev->dev_addr, mac->sa_data, ETH_ALEN);
1488 +
1489 + interrupt = hw_block_intr(hw);
1490 +
1491 +diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
1492 +index aba4f67..8f47907 100644
1493 +--- a/drivers/net/ethernet/realtek/8139cp.c
1494 ++++ b/drivers/net/ethernet/realtek/8139cp.c
1495 +@@ -961,6 +961,11 @@ static inline void cp_start_hw (struct cp_private *cp)
1496 + cpw8(Cmd, RxOn | TxOn);
1497 + }
1498 +
1499 ++static void cp_enable_irq(struct cp_private *cp)
1500 ++{
1501 ++ cpw16_f(IntrMask, cp_intr_mask);
1502 ++}
1503 ++
1504 + static void cp_init_hw (struct cp_private *cp)
1505 + {
1506 + struct net_device *dev = cp->dev;
1507 +@@ -1000,8 +1005,6 @@ static void cp_init_hw (struct cp_private *cp)
1508 +
1509 + cpw16(MultiIntr, 0);
1510 +
1511 +- cpw16_f(IntrMask, cp_intr_mask);
1512 +-
1513 + cpw8_f(Cfg9346, Cfg9346_Lock);
1514 + }
1515 +
1516 +@@ -1133,6 +1136,8 @@ static int cp_open (struct net_device *dev)
1517 + if (rc)
1518 + goto err_out_hw;
1519 +
1520 ++ cp_enable_irq(cp);
1521 ++
1522 + netif_carrier_off(dev);
1523 + mii_check_media(&cp->mii_if, netif_msg_link(cp), true);
1524 + netif_start_queue(dev);
1525 +@@ -2034,6 +2039,7 @@ static int cp_resume (struct pci_dev *pdev)
1526 + /* FIXME: sh*t may happen if the Rx ring buffer is depleted */
1527 + cp_init_rings_index (cp);
1528 + cp_init_hw (cp);
1529 ++ cp_enable_irq(cp);
1530 + netif_start_queue (dev);
1531 +
1532 + spin_lock_irqsave (&cp->lock, flags);
1533 +diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
1534 +index 8843071..8c7dd21 100644
1535 +--- a/drivers/net/ethernet/smsc/smsc911x.c
1536 ++++ b/drivers/net/ethernet/smsc/smsc911x.c
1537 +@@ -1089,10 +1089,8 @@ smsc911x_rx_counterrors(struct net_device *dev, unsigned int rxstat)
1538 +
1539 + /* Quickly dumps bad packets */
1540 + static void
1541 +-smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktbytes)
1542 ++smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktwords)
1543 + {
1544 +- unsigned int pktwords = (pktbytes + NET_IP_ALIGN + 3) >> 2;
1545 +-
1546 + if (likely(pktwords >= 4)) {
1547 + unsigned int timeout = 500;
1548 + unsigned int val;
1549 +@@ -1156,7 +1154,7 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
1550 + continue;
1551 + }
1552 +
1553 +- skb = netdev_alloc_skb(dev, pktlength + NET_IP_ALIGN);
1554 ++ skb = netdev_alloc_skb(dev, pktwords << 2);
1555 + if (unlikely(!skb)) {
1556 + SMSC_WARN(pdata, rx_err,
1557 + "Unable to allocate skb for rx packet");
1558 +@@ -1166,14 +1164,12 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
1559 + break;
1560 + }
1561 +
1562 +- skb->data = skb->head;
1563 +- skb_reset_tail_pointer(skb);
1564 ++ pdata->ops->rx_readfifo(pdata,
1565 ++ (unsigned int *)skb->data, pktwords);
1566 +
1567 + /* Align IP on 16B boundary */
1568 + skb_reserve(skb, NET_IP_ALIGN);
1569 + skb_put(skb, pktlength - 4);
1570 +- pdata->ops->rx_readfifo(pdata,
1571 +- (unsigned int *)skb->head, pktwords);
1572 + skb->protocol = eth_type_trans(skb, dev);
1573 + skb_checksum_none_assert(skb);
1574 + netif_receive_skb(skb);
1575 +@@ -1396,7 +1392,7 @@ static int smsc911x_open(struct net_device *dev)
1576 + smsc911x_reg_write(pdata, FIFO_INT, temp);
1577 +
1578 + /* set RX Data offset to 2 bytes for alignment */
1579 +- smsc911x_reg_write(pdata, RX_CFG, (2 << 8));
1580 ++ smsc911x_reg_write(pdata, RX_CFG, (NET_IP_ALIGN << 8));
1581 +
1582 + /* enable NAPI polling before enabling RX interrupts */
1583 + napi_enable(&pdata->napi);
1584 +diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
1585 +index 7615040..f470ab6 100644
1586 +--- a/drivers/net/ethernet/ti/davinci_mdio.c
1587 ++++ b/drivers/net/ethernet/ti/davinci_mdio.c
1588 +@@ -181,6 +181,11 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
1589 + __davinci_mdio_reset(data);
1590 + return -EAGAIN;
1591 + }
1592 ++
1593 ++ reg = __raw_readl(&regs->user[0].access);
1594 ++ if ((reg & USERACCESS_GO) == 0)
1595 ++ return 0;
1596 ++
1597 + dev_err(data->dev, "timed out waiting for user access\n");
1598 + return -ETIMEDOUT;
1599 + }
1600 +diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
1601 +index 486b404..3ed983c 100644
1602 +--- a/drivers/net/ppp/ppp_generic.c
1603 ++++ b/drivers/net/ppp/ppp_generic.c
1604 +@@ -968,7 +968,6 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
1605 + proto = npindex_to_proto[npi];
1606 + put_unaligned_be16(proto, pp);
1607 +
1608 +- netif_stop_queue(dev);
1609 + skb_queue_tail(&ppp->file.xq, skb);
1610 + ppp_xmit_process(ppp);
1611 + return NETDEV_TX_OK;
1612 +@@ -1063,6 +1062,8 @@ ppp_xmit_process(struct ppp *ppp)
1613 + code that we can accept some more. */
1614 + if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
1615 + netif_wake_queue(ppp->dev);
1616 ++ else
1617 ++ netif_stop_queue(ppp->dev);
1618 + }
1619 + ppp_xmit_unlock(ppp);
1620 + }
1621 +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
1622 +index a5b9b12..7bd219b 100644
1623 +--- a/drivers/net/usb/smsc75xx.c
1624 ++++ b/drivers/net/usb/smsc75xx.c
1625 +@@ -1050,6 +1050,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
1626 + dev->net->ethtool_ops = &smsc75xx_ethtool_ops;
1627 + dev->net->flags |= IFF_MULTICAST;
1628 + dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD;
1629 ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
1630 + return 0;
1631 + }
1632 +
1633 +diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
1634 +index eff6767..55b3218 100644
1635 +--- a/drivers/net/usb/smsc95xx.c
1636 ++++ b/drivers/net/usb/smsc95xx.c
1637 +@@ -1190,7 +1190,7 @@ static const struct driver_info smsc95xx_info = {
1638 + .rx_fixup = smsc95xx_rx_fixup,
1639 + .tx_fixup = smsc95xx_tx_fixup,
1640 + .status = smsc95xx_status,
1641 +- .flags = FLAG_ETHER | FLAG_SEND_ZLP,
1642 ++ .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
1643 + };
1644 +
1645 + static const struct usb_device_id products[] = {
1646 +diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
1647 +index 64a1106..4697cf3 100644
1648 +--- a/drivers/net/wimax/i2400m/netdev.c
1649 ++++ b/drivers/net/wimax/i2400m/netdev.c
1650 +@@ -607,7 +607,8 @@ static void i2400m_get_drvinfo(struct net_device *net_dev,
1651 + struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
1652 +
1653 + strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1);
1654 +- strncpy(info->fw_version, i2400m->fw_name, sizeof(info->fw_version) - 1);
1655 ++ strncpy(info->fw_version,
1656 ++ i2400m->fw_name ? : "", sizeof(info->fw_version) - 1);
1657 + if (net_dev->dev.parent)
1658 + strncpy(info->bus_info, dev_name(net_dev->dev.parent),
1659 + sizeof(info->bus_info) - 1);
1660 +diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
1661 +index 5634d9a..680709c 100644
1662 +--- a/drivers/net/wireless/b43/main.c
1663 ++++ b/drivers/net/wireless/b43/main.c
1664 +@@ -4820,8 +4820,14 @@ static int b43_op_start(struct ieee80211_hw *hw)
1665 + out_mutex_unlock:
1666 + mutex_unlock(&wl->mutex);
1667 +
1668 +- /* reload configuration */
1669 +- b43_op_config(hw, ~0);
1670 ++ /*
1671 ++ * Configuration may have been overwritten during initialization.
1672 ++ * Reload the configuration, but only if initialization was
1673 ++ * successful. Reloading the configuration after a failed init
1674 ++ * may hang the system.
1675 ++ */
1676 ++ if (!err)
1677 ++ b43_op_config(hw, ~0);
1678 +
1679 + return err;
1680 + }
1681 +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
1682 +index 453f58e..f98becc 100644
1683 +--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
1684 ++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
1685 +@@ -7865,6 +7865,7 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
1686 + {
1687 + int len_mpdu;
1688 + struct ieee80211_rx_status rx_status;
1689 ++ struct ieee80211_hdr *hdr;
1690 +
1691 + memset(&rx_status, 0, sizeof(rx_status));
1692 + prep_mac80211_status(wlc, rxh, p, &rx_status);
1693 +@@ -7874,6 +7875,13 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
1694 + skb_pull(p, D11_PHY_HDR_LEN);
1695 + __skb_trim(p, len_mpdu);
1696 +
1697 ++ /* unmute transmit */
1698 ++ if (wlc->hw->suspended_fifos) {
1699 ++ hdr = (struct ieee80211_hdr *)p->data;
1700 ++ if (ieee80211_is_beacon(hdr->frame_control))
1701 ++ brcms_b_mute(wlc->hw, false);
1702 ++ }
1703 ++
1704 + memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
1705 + ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);
1706 + }
1707 +diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
1708 +index 99a710d..827889b 100644
1709 +--- a/drivers/net/wireless/ipw2x00/ipw2200.c
1710 ++++ b/drivers/net/wireless/ipw2x00/ipw2200.c
1711 +@@ -2183,6 +2183,7 @@ static int __ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1712 + {
1713 + int rc = 0;
1714 + unsigned long flags;
1715 ++ unsigned long now, end;
1716 +
1717 + spin_lock_irqsave(&priv->lock, flags);
1718 + if (priv->status & STATUS_HCMD_ACTIVE) {
1719 +@@ -2224,10 +2225,20 @@ static int __ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1720 + }
1721 + spin_unlock_irqrestore(&priv->lock, flags);
1722 +
1723 ++ now = jiffies;
1724 ++ end = now + HOST_COMPLETE_TIMEOUT;
1725 ++again:
1726 + rc = wait_event_interruptible_timeout(priv->wait_command_queue,
1727 + !(priv->
1728 + status & STATUS_HCMD_ACTIVE),
1729 +- HOST_COMPLETE_TIMEOUT);
1730 ++ end - now);
1731 ++ if (rc < 0) {
1732 ++ now = jiffies;
1733 ++ if (time_before(now, end))
1734 ++ goto again;
1735 ++ rc = 0;
1736 ++ }
1737 ++
1738 + if (rc == 0) {
1739 + spin_lock_irqsave(&priv->lock, flags);
1740 + if (priv->status & STATUS_HCMD_ACTIVE) {
1741 +diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
1742 +index dd008b0..1e6c8cc 100644
1743 +--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
1744 ++++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
1745 +@@ -45,8 +45,8 @@
1746 + #include "iwl-cfg.h"
1747 +
1748 + /* Highest firmware API version supported */
1749 +-#define IWL1000_UCODE_API_MAX 6
1750 +-#define IWL100_UCODE_API_MAX 6
1751 ++#define IWL1000_UCODE_API_MAX 5
1752 ++#define IWL100_UCODE_API_MAX 5
1753 +
1754 + /* Oldest version we won't warn about */
1755 + #define IWL1000_UCODE_API_OK 5
1756 +@@ -244,5 +244,5 @@ struct iwl_cfg iwl100_bg_cfg = {
1757 + IWL_DEVICE_100,
1758 + };
1759 +
1760 +-MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
1761 +-MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_MAX));
1762 ++MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_OK));
1763 ++MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_OK));
1764 +diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
1765 +index 7943197..9823e41 100644
1766 +--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
1767 ++++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
1768 +@@ -51,10 +51,10 @@
1769 + #define IWL135_UCODE_API_MAX 6
1770 +
1771 + /* Oldest version we won't warn about */
1772 +-#define IWL2030_UCODE_API_OK 5
1773 +-#define IWL2000_UCODE_API_OK 5
1774 +-#define IWL105_UCODE_API_OK 5
1775 +-#define IWL135_UCODE_API_OK 5
1776 ++#define IWL2030_UCODE_API_OK 6
1777 ++#define IWL2000_UCODE_API_OK 6
1778 ++#define IWL105_UCODE_API_OK 6
1779 ++#define IWL135_UCODE_API_OK 6
1780 +
1781 + /* Lowest firmware API version supported */
1782 + #define IWL2030_UCODE_API_MIN 5
1783 +@@ -372,7 +372,7 @@ struct iwl_cfg iwl135_bgn_cfg = {
1784 + .ht_params = &iwl2000_ht_params,
1785 + };
1786 +
1787 +-MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
1788 +-MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
1789 +-MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
1790 +-MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));
1791 ++MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_OK));
1792 ++MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_OK));
1793 ++MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_OK));
1794 ++MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_OK));
1795 +diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
1796 +index f55fb2d..606213f 100644
1797 +--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
1798 ++++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
1799 +@@ -50,6 +50,10 @@
1800 + #define IWL5000_UCODE_API_MAX 5
1801 + #define IWL5150_UCODE_API_MAX 2
1802 +
1803 ++/* Oldest version we won't warn about */
1804 ++#define IWL5000_UCODE_API_OK 5
1805 ++#define IWL5150_UCODE_API_OK 2
1806 ++
1807 + /* Lowest firmware API version supported */
1808 + #define IWL5000_UCODE_API_MIN 1
1809 + #define IWL5150_UCODE_API_MIN 1
1810 +@@ -373,6 +377,7 @@ static struct iwl_ht_params iwl5000_ht_params = {
1811 + #define IWL_DEVICE_5000 \
1812 + .fw_name_pre = IWL5000_FW_PRE, \
1813 + .ucode_api_max = IWL5000_UCODE_API_MAX, \
1814 ++ .ucode_api_ok = IWL5000_UCODE_API_OK, \
1815 + .ucode_api_min = IWL5000_UCODE_API_MIN, \
1816 + .eeprom_ver = EEPROM_5000_EEPROM_VERSION, \
1817 + .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, \
1818 +@@ -416,6 +421,7 @@ struct iwl_cfg iwl5350_agn_cfg = {
1819 + .name = "Intel(R) WiMAX/WiFi Link 5350 AGN",
1820 + .fw_name_pre = IWL5000_FW_PRE,
1821 + .ucode_api_max = IWL5000_UCODE_API_MAX,
1822 ++ .ucode_api_ok = IWL5000_UCODE_API_OK,
1823 + .ucode_api_min = IWL5000_UCODE_API_MIN,
1824 + .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1825 + .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
1826 +@@ -429,6 +435,7 @@ struct iwl_cfg iwl5350_agn_cfg = {
1827 + #define IWL_DEVICE_5150 \
1828 + .fw_name_pre = IWL5150_FW_PRE, \
1829 + .ucode_api_max = IWL5150_UCODE_API_MAX, \
1830 ++ .ucode_api_ok = IWL5150_UCODE_API_OK, \
1831 + .ucode_api_min = IWL5150_UCODE_API_MIN, \
1832 + .eeprom_ver = EEPROM_5050_EEPROM_VERSION, \
1833 + .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, \
1834 +@@ -450,5 +457,5 @@ struct iwl_cfg iwl5150_abg_cfg = {
1835 + IWL_DEVICE_5150,
1836 + };
1837 +
1838 +-MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
1839 +-MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
1840 ++MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_OK));
1841 ++MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_OK));
1842 +diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
1843 +index c840c78..b4f809c 100644
1844 +--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
1845 ++++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
1846 +@@ -46,12 +46,15 @@
1847 + #include "iwl-cfg.h"
1848 +
1849 + /* Highest firmware API version supported */
1850 +-#define IWL6000_UCODE_API_MAX 4
1851 ++#define IWL6000_UCODE_API_MAX 6
1852 + #define IWL6050_UCODE_API_MAX 5
1853 + #define IWL6000G2_UCODE_API_MAX 6
1854 +
1855 + /* Oldest version we won't warn about */
1856 ++#define IWL6000_UCODE_API_OK 4
1857 + #define IWL6000G2_UCODE_API_OK 5
1858 ++#define IWL6050_UCODE_API_OK 5
1859 ++#define IWL6000G2B_UCODE_API_OK 6
1860 +
1861 + /* Lowest firmware API version supported */
1862 + #define IWL6000_UCODE_API_MIN 4
1863 +@@ -399,7 +402,7 @@ struct iwl_cfg iwl6005_2agn_d_cfg = {
1864 + #define IWL_DEVICE_6030 \
1865 + .fw_name_pre = IWL6030_FW_PRE, \
1866 + .ucode_api_max = IWL6000G2_UCODE_API_MAX, \
1867 +- .ucode_api_ok = IWL6000G2_UCODE_API_OK, \
1868 ++ .ucode_api_ok = IWL6000G2B_UCODE_API_OK, \
1869 + .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
1870 + .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \
1871 + .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \
1872 +@@ -479,6 +482,7 @@ struct iwl_cfg iwl130_bg_cfg = {
1873 + #define IWL_DEVICE_6000i \
1874 + .fw_name_pre = IWL6000_FW_PRE, \
1875 + .ucode_api_max = IWL6000_UCODE_API_MAX, \
1876 ++ .ucode_api_ok = IWL6000_UCODE_API_OK, \
1877 + .ucode_api_min = IWL6000_UCODE_API_MIN, \
1878 + .valid_tx_ant = ANT_BC, /* .cfg overwrite */ \
1879 + .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \
1880 +@@ -559,6 +563,7 @@ struct iwl_cfg iwl6000_3agn_cfg = {
1881 + .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
1882 + .fw_name_pre = IWL6000_FW_PRE,
1883 + .ucode_api_max = IWL6000_UCODE_API_MAX,
1884 ++ .ucode_api_ok = IWL6000_UCODE_API_OK,
1885 + .ucode_api_min = IWL6000_UCODE_API_MIN,
1886 + .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
1887 + .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION,
1888 +@@ -569,7 +574,7 @@ struct iwl_cfg iwl6000_3agn_cfg = {
1889 + .led_mode = IWL_LED_BLINK,
1890 + };
1891 +
1892 +-MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
1893 +-MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));
1894 +-MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
1895 +-MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
1896 ++MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK));
1897 ++MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_OK));
1898 ++MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_OK));
1899 ++MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2B_UCODE_API_OK));
1900 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
1901 +index e0e9a3d..d7d2512 100644
1902 +--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
1903 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
1904 +@@ -1504,7 +1504,6 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
1905 +
1906 + static void iwlagn_prepare_restart(struct iwl_priv *priv)
1907 + {
1908 +- struct iwl_rxon_context *ctx;
1909 + bool bt_full_concurrent;
1910 + u8 bt_ci_compliance;
1911 + u8 bt_load;
1912 +@@ -1513,8 +1512,6 @@ static void iwlagn_prepare_restart(struct iwl_priv *priv)
1913 +
1914 + lockdep_assert_held(&priv->shrd->mutex);
1915 +
1916 +- for_each_context(priv, ctx)
1917 +- ctx->vif = NULL;
1918 + priv->is_open = 0;
1919 +
1920 + /*
1921 +diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
1922 +index 3d75d4c..832ec4d 100644
1923 +--- a/drivers/net/wireless/iwlwifi/iwl-core.c
1924 ++++ b/drivers/net/wireless/iwlwifi/iwl-core.c
1925 +@@ -1228,6 +1228,7 @@ int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1926 + struct iwl_rxon_context *tmp, *ctx = NULL;
1927 + int err;
1928 + enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif);
1929 ++ bool reset = false;
1930 +
1931 + IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n",
1932 + viftype, vif->addr);
1933 +@@ -1249,6 +1250,13 @@ int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1934 + tmp->interface_modes | tmp->exclusive_interface_modes;
1935 +
1936 + if (tmp->vif) {
1937 ++ /* On reset we need to add the same interface again */
1938 ++ if (tmp->vif == vif) {
1939 ++ reset = true;
1940 ++ ctx = tmp;
1941 ++ break;
1942 ++ }
1943 ++
1944 + /* check if this busy context is exclusive */
1945 + if (tmp->exclusive_interface_modes &
1946 + BIT(tmp->vif->type)) {
1947 +@@ -1275,7 +1283,7 @@ int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1948 + ctx->vif = vif;
1949 +
1950 + err = iwl_setup_interface(priv, ctx);
1951 +- if (!err)
1952 ++ if (!err || reset)
1953 + goto out;
1954 +
1955 + ctx->vif = NULL;
1956 +diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
1957 +index 5bede9d..aae992a 100644
1958 +--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
1959 ++++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
1960 +@@ -104,15 +104,29 @@
1961 + * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04
1962 + * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
1963 + * aligned (address bits 0-7 must be 0).
1964 ++ * Later devices have 20 (5000 series) or 30 (higher) queues, but the registers
1965 ++ * for them are in different places.
1966 + *
1967 + * Bit fields in each pointer register:
1968 + * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
1969 + */
1970 +-#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
1971 +-#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
1972 +-
1973 +-/* Find TFD CB base pointer for given queue (range 0-15). */
1974 +-#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
1975 ++#define FH_MEM_CBBC_0_15_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
1976 ++#define FH_MEM_CBBC_0_15_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
1977 ++#define FH_MEM_CBBC_16_19_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBF0)
1978 ++#define FH_MEM_CBBC_16_19_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
1979 ++#define FH_MEM_CBBC_20_31_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xB20)
1980 ++#define FH_MEM_CBBC_20_31_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xB80)
1981 ++
1982 ++/* Find TFD CB base pointer for given queue */
1983 ++static inline unsigned int FH_MEM_CBBC_QUEUE(unsigned int chnl)
1984 ++{
1985 ++ if (chnl < 16)
1986 ++ return FH_MEM_CBBC_0_15_LOWER_BOUND + 4 * chnl;
1987 ++ if (chnl < 20)
1988 ++ return FH_MEM_CBBC_16_19_LOWER_BOUND + 4 * (chnl - 16);
1989 ++ WARN_ON_ONCE(chnl >= 32);
1990 ++ return FH_MEM_CBBC_20_31_LOWER_BOUND + 4 * (chnl - 20);
1991 ++}
1992 +
1993 +
1994 + /**
1995 +diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
1996 +index bebdd82..d9b089e 100644
1997 +--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
1998 ++++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
1999 +@@ -227,12 +227,33 @@
2000 + #define SCD_AIT (SCD_BASE + 0x0c)
2001 + #define SCD_TXFACT (SCD_BASE + 0x10)
2002 + #define SCD_ACTIVE (SCD_BASE + 0x14)
2003 +-#define SCD_QUEUE_WRPTR(x) (SCD_BASE + 0x18 + (x) * 4)
2004 +-#define SCD_QUEUE_RDPTR(x) (SCD_BASE + 0x68 + (x) * 4)
2005 + #define SCD_QUEUECHAIN_SEL (SCD_BASE + 0xe8)
2006 + #define SCD_AGGR_SEL (SCD_BASE + 0x248)
2007 + #define SCD_INTERRUPT_MASK (SCD_BASE + 0x108)
2008 +-#define SCD_QUEUE_STATUS_BITS(x) (SCD_BASE + 0x10c + (x) * 4)
2009 ++
2010 ++static inline unsigned int SCD_QUEUE_WRPTR(unsigned int chnl)
2011 ++{
2012 ++ if (chnl < 20)
2013 ++ return SCD_BASE + 0x18 + chnl * 4;
2014 ++ WARN_ON_ONCE(chnl >= 32);
2015 ++ return SCD_BASE + 0x284 + (chnl - 20) * 4;
2016 ++}
2017 ++
2018 ++static inline unsigned int SCD_QUEUE_RDPTR(unsigned int chnl)
2019 ++{
2020 ++ if (chnl < 20)
2021 ++ return SCD_BASE + 0x68 + chnl * 4;
2022 ++ WARN_ON_ONCE(chnl >= 32);
2023 ++ return SCD_BASE + 0x2B4 + (chnl - 20) * 4;
2024 ++}
2025 ++
2026 ++static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl)
2027 ++{
2028 ++ if (chnl < 20)
2029 ++ return SCD_BASE + 0x10c + chnl * 4;
2030 ++ WARN_ON_ONCE(chnl >= 32);
2031 ++ return SCD_BASE + 0x384 + (chnl - 20) * 4;
2032 ++}
2033 +
2034 + /*********************** END TX SCHEDULER *************************************/
2035 +
2036 +diff --git a/drivers/net/wireless/mwifiex/pcie.h b/drivers/net/wireless/mwifiex/pcie.h
2037 +index 445ff21..2f218f9 100644
2038 +--- a/drivers/net/wireless/mwifiex/pcie.h
2039 ++++ b/drivers/net/wireless/mwifiex/pcie.h
2040 +@@ -48,15 +48,15 @@
2041 + #define PCIE_HOST_INT_STATUS_MASK 0xC3C
2042 + #define PCIE_SCRATCH_2_REG 0xC40
2043 + #define PCIE_SCRATCH_3_REG 0xC44
2044 +-#define PCIE_SCRATCH_4_REG 0xCC0
2045 +-#define PCIE_SCRATCH_5_REG 0xCC4
2046 +-#define PCIE_SCRATCH_6_REG 0xCC8
2047 +-#define PCIE_SCRATCH_7_REG 0xCCC
2048 +-#define PCIE_SCRATCH_8_REG 0xCD0
2049 +-#define PCIE_SCRATCH_9_REG 0xCD4
2050 +-#define PCIE_SCRATCH_10_REG 0xCD8
2051 +-#define PCIE_SCRATCH_11_REG 0xCDC
2052 +-#define PCIE_SCRATCH_12_REG 0xCE0
2053 ++#define PCIE_SCRATCH_4_REG 0xCD0
2054 ++#define PCIE_SCRATCH_5_REG 0xCD4
2055 ++#define PCIE_SCRATCH_6_REG 0xCD8
2056 ++#define PCIE_SCRATCH_7_REG 0xCDC
2057 ++#define PCIE_SCRATCH_8_REG 0xCE0
2058 ++#define PCIE_SCRATCH_9_REG 0xCE4
2059 ++#define PCIE_SCRATCH_10_REG 0xCE8
2060 ++#define PCIE_SCRATCH_11_REG 0xCEC
2061 ++#define PCIE_SCRATCH_12_REG 0xCF0
2062 +
2063 + #define CPU_INTR_DNLD_RDY BIT(0)
2064 + #define CPU_INTR_DOOR_BELL BIT(1)
2065 +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
2066 +index cb71e88..0ffa111 100644
2067 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c
2068 ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c
2069 +@@ -914,12 +914,14 @@ static struct usb_device_id rt2800usb_device_table[] = {
2070 + { USB_DEVICE(0x050d, 0x8053) },
2071 + { USB_DEVICE(0x050d, 0x805c) },
2072 + { USB_DEVICE(0x050d, 0x815c) },
2073 ++ { USB_DEVICE(0x050d, 0x825a) },
2074 + { USB_DEVICE(0x050d, 0x825b) },
2075 + { USB_DEVICE(0x050d, 0x935a) },
2076 + { USB_DEVICE(0x050d, 0x935b) },
2077 + /* Buffalo */
2078 + { USB_DEVICE(0x0411, 0x00e8) },
2079 + { USB_DEVICE(0x0411, 0x0158) },
2080 ++ { USB_DEVICE(0x0411, 0x015d) },
2081 + { USB_DEVICE(0x0411, 0x016f) },
2082 + { USB_DEVICE(0x0411, 0x01a2) },
2083 + /* Corega */
2084 +@@ -934,6 +936,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
2085 + { USB_DEVICE(0x07d1, 0x3c0e) },
2086 + { USB_DEVICE(0x07d1, 0x3c0f) },
2087 + { USB_DEVICE(0x07d1, 0x3c11) },
2088 ++ { USB_DEVICE(0x07d1, 0x3c13) },
2089 ++ { USB_DEVICE(0x07d1, 0x3c15) },
2090 + { USB_DEVICE(0x07d1, 0x3c16) },
2091 + { USB_DEVICE(0x2001, 0x3c1b) },
2092 + /* Draytek */
2093 +@@ -944,6 +948,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
2094 + { USB_DEVICE(0x7392, 0x7711) },
2095 + { USB_DEVICE(0x7392, 0x7717) },
2096 + { USB_DEVICE(0x7392, 0x7718) },
2097 ++ { USB_DEVICE(0x7392, 0x7722) },
2098 + /* Encore */
2099 + { USB_DEVICE(0x203d, 0x1480) },
2100 + { USB_DEVICE(0x203d, 0x14a9) },
2101 +@@ -978,6 +983,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
2102 + { USB_DEVICE(0x1737, 0x0070) },
2103 + { USB_DEVICE(0x1737, 0x0071) },
2104 + { USB_DEVICE(0x1737, 0x0077) },
2105 ++ { USB_DEVICE(0x1737, 0x0078) },
2106 + /* Logitec */
2107 + { USB_DEVICE(0x0789, 0x0162) },
2108 + { USB_DEVICE(0x0789, 0x0163) },
2109 +@@ -1001,9 +1007,13 @@ static struct usb_device_id rt2800usb_device_table[] = {
2110 + { USB_DEVICE(0x0db0, 0x871b) },
2111 + { USB_DEVICE(0x0db0, 0x871c) },
2112 + { USB_DEVICE(0x0db0, 0x899a) },
2113 ++ /* Ovislink */
2114 ++ { USB_DEVICE(0x1b75, 0x3071) },
2115 ++ { USB_DEVICE(0x1b75, 0x3072) },
2116 + /* Para */
2117 + { USB_DEVICE(0x20b8, 0x8888) },
2118 + /* Pegatron */
2119 ++ { USB_DEVICE(0x1d4d, 0x0002) },
2120 + { USB_DEVICE(0x1d4d, 0x000c) },
2121 + { USB_DEVICE(0x1d4d, 0x000e) },
2122 + { USB_DEVICE(0x1d4d, 0x0011) },
2123 +@@ -1056,7 +1066,9 @@ static struct usb_device_id rt2800usb_device_table[] = {
2124 + /* Sparklan */
2125 + { USB_DEVICE(0x15a9, 0x0006) },
2126 + /* Sweex */
2127 ++ { USB_DEVICE(0x177f, 0x0153) },
2128 + { USB_DEVICE(0x177f, 0x0302) },
2129 ++ { USB_DEVICE(0x177f, 0x0313) },
2130 + /* U-Media */
2131 + { USB_DEVICE(0x157e, 0x300e) },
2132 + { USB_DEVICE(0x157e, 0x3013) },
2133 +@@ -1140,27 +1152,24 @@ static struct usb_device_id rt2800usb_device_table[] = {
2134 + { USB_DEVICE(0x13d3, 0x3322) },
2135 + /* Belkin */
2136 + { USB_DEVICE(0x050d, 0x1003) },
2137 +- { USB_DEVICE(0x050d, 0x825a) },
2138 + /* Buffalo */
2139 + { USB_DEVICE(0x0411, 0x012e) },
2140 + { USB_DEVICE(0x0411, 0x0148) },
2141 + { USB_DEVICE(0x0411, 0x0150) },
2142 +- { USB_DEVICE(0x0411, 0x015d) },
2143 + /* Corega */
2144 + { USB_DEVICE(0x07aa, 0x0041) },
2145 + { USB_DEVICE(0x07aa, 0x0042) },
2146 + { USB_DEVICE(0x18c5, 0x0008) },
2147 + /* D-Link */
2148 + { USB_DEVICE(0x07d1, 0x3c0b) },
2149 +- { USB_DEVICE(0x07d1, 0x3c13) },
2150 +- { USB_DEVICE(0x07d1, 0x3c15) },
2151 + { USB_DEVICE(0x07d1, 0x3c17) },
2152 + { USB_DEVICE(0x2001, 0x3c17) },
2153 + /* Edimax */
2154 + { USB_DEVICE(0x7392, 0x4085) },
2155 +- { USB_DEVICE(0x7392, 0x7722) },
2156 + /* Encore */
2157 + { USB_DEVICE(0x203d, 0x14a1) },
2158 ++ /* Fujitsu Stylistic 550 */
2159 ++ { USB_DEVICE(0x1690, 0x0761) },
2160 + /* Gemtek */
2161 + { USB_DEVICE(0x15a9, 0x0010) },
2162 + /* Gigabyte */
2163 +@@ -1172,19 +1181,13 @@ static struct usb_device_id rt2800usb_device_table[] = {
2164 + /* LevelOne */
2165 + { USB_DEVICE(0x1740, 0x0605) },
2166 + { USB_DEVICE(0x1740, 0x0615) },
2167 +- /* Linksys */
2168 +- { USB_DEVICE(0x1737, 0x0078) },
2169 + /* Logitec */
2170 + { USB_DEVICE(0x0789, 0x0168) },
2171 + { USB_DEVICE(0x0789, 0x0169) },
2172 + /* Motorola */
2173 + { USB_DEVICE(0x100d, 0x9032) },
2174 +- /* Ovislink */
2175 +- { USB_DEVICE(0x1b75, 0x3071) },
2176 +- { USB_DEVICE(0x1b75, 0x3072) },
2177 + /* Pegatron */
2178 + { USB_DEVICE(0x05a6, 0x0101) },
2179 +- { USB_DEVICE(0x1d4d, 0x0002) },
2180 + { USB_DEVICE(0x1d4d, 0x0010) },
2181 + /* Planex */
2182 + { USB_DEVICE(0x2019, 0x5201) },
2183 +@@ -1203,9 +1206,6 @@ static struct usb_device_id rt2800usb_device_table[] = {
2184 + { USB_DEVICE(0x083a, 0xc522) },
2185 + { USB_DEVICE(0x083a, 0xd522) },
2186 + { USB_DEVICE(0x083a, 0xf511) },
2187 +- /* Sweex */
2188 +- { USB_DEVICE(0x177f, 0x0153) },
2189 +- { USB_DEVICE(0x177f, 0x0313) },
2190 + /* Zyxel */
2191 + { USB_DEVICE(0x0586, 0x341a) },
2192 + #endif
2193 +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
2194 +index d44d398..47ba0f7 100644
2195 +--- a/drivers/net/wireless/rtlwifi/pci.c
2196 ++++ b/drivers/net/wireless/rtlwifi/pci.c
2197 +@@ -1961,6 +1961,7 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
2198 + rtl_deinit_deferred_work(hw);
2199 + rtlpriv->intf_ops->adapter_stop(hw);
2200 + }
2201 ++ rtlpriv->cfg->ops->disable_interrupt(hw);
2202 +
2203 + /*deinit rfkill */
2204 + rtl_deinit_rfkill(hw);
2205 +diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c
2206 +index ba3268e..40c1574 100644
2207 +--- a/drivers/net/wireless/wl1251/main.c
2208 ++++ b/drivers/net/wireless/wl1251/main.c
2209 +@@ -479,6 +479,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw)
2210 + cancel_work_sync(&wl->irq_work);
2211 + cancel_work_sync(&wl->tx_work);
2212 + cancel_work_sync(&wl->filter_work);
2213 ++ cancel_delayed_work_sync(&wl->elp_work);
2214 +
2215 + mutex_lock(&wl->mutex);
2216 +
2217 +diff --git a/drivers/net/wireless/wl1251/sdio.c b/drivers/net/wireless/wl1251/sdio.c
2218 +index f786942..1b851f6 100644
2219 +--- a/drivers/net/wireless/wl1251/sdio.c
2220 ++++ b/drivers/net/wireless/wl1251/sdio.c
2221 +@@ -315,8 +315,8 @@ static void __devexit wl1251_sdio_remove(struct sdio_func *func)
2222 +
2223 + if (wl->irq)
2224 + free_irq(wl->irq, wl);
2225 +- kfree(wl_sdio);
2226 + wl1251_free_hw(wl);
2227 ++ kfree(wl_sdio);
2228 +
2229 + sdio_claim_host(func);
2230 + sdio_release_irq(func);
2231 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2232 +index 6476547..78fda9c 100644
2233 +--- a/drivers/pci/quirks.c
2234 ++++ b/drivers/pci/quirks.c
2235 +@@ -2906,6 +2906,40 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f8, quirk_intel_mc_errata);
2236 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
2237 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
2238 +
2239 ++/*
2240 ++ * Some BIOS implementations leave the Intel GPU interrupts enabled,
2241 ++ * even though no one is handling them (f.e. i915 driver is never loaded).
2242 ++ * Additionally the interrupt destination is not set up properly
2243 ++ * and the interrupt ends up -somewhere-.
2244 ++ *
2245 ++ * These spurious interrupts are "sticky" and the kernel disables
2246 ++ * the (shared) interrupt line after 100.000+ generated interrupts.
2247 ++ *
2248 ++ * Fix it by disabling the still enabled interrupts.
2249 ++ * This resolves crashes often seen on monitor unplug.
2250 ++ */
2251 ++#define I915_DEIER_REG 0x4400c
2252 ++static void __devinit disable_igfx_irq(struct pci_dev *dev)
2253 ++{
2254 ++ void __iomem *regs = pci_iomap(dev, 0, 0);
2255 ++ if (regs == NULL) {
2256 ++ dev_warn(&dev->dev, "igfx quirk: Can't iomap PCI device\n");
2257 ++ return;
2258 ++ }
2259 ++
2260 ++ /* Check if any interrupt line is still enabled */
2261 ++ if (readl(regs + I915_DEIER_REG) != 0) {
2262 ++ dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; "
2263 ++ "disabling\n");
2264 ++
2265 ++ writel(0, regs + I915_DEIER_REG);
2266 ++ }
2267 ++
2268 ++ pci_iounmap(dev, regs);
2269 ++}
2270 ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
2271 ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
2272 ++
2273 + static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
2274 + struct pci_fixup *end)
2275 + {
2276 +diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
2277 +index d93e962..1d3bcce 100644
2278 +--- a/drivers/platform/x86/dell-laptop.c
2279 ++++ b/drivers/platform/x86/dell-laptop.c
2280 +@@ -184,6 +184,34 @@ static struct dmi_system_id __devinitdata dell_quirks[] = {
2281 + },
2282 + .driver_data = &quirk_dell_vostro_v130,
2283 + },
2284 ++ {
2285 ++ .callback = dmi_matched,
2286 ++ .ident = "Dell Vostro 3555",
2287 ++ .matches = {
2288 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
2289 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3555"),
2290 ++ },
2291 ++ .driver_data = &quirk_dell_vostro_v130,
2292 ++ },
2293 ++ {
2294 ++ .callback = dmi_matched,
2295 ++ .ident = "Dell Inspiron N311z",
2296 ++ .matches = {
2297 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
2298 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N311z"),
2299 ++ },
2300 ++ .driver_data = &quirk_dell_vostro_v130,
2301 ++ },
2302 ++ {
2303 ++ .callback = dmi_matched,
2304 ++ .ident = "Dell Inspiron M5110",
2305 ++ .matches = {
2306 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
2307 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron M5110"),
2308 ++ },
2309 ++ .driver_data = &quirk_dell_vostro_v130,
2310 ++ },
2311 ++ { }
2312 + };
2313 +
2314 + static struct calling_interface_buffer *buffer;
2315 +@@ -615,6 +643,7 @@ static void touchpad_led_set(struct led_classdev *led_cdev,
2316 + static struct led_classdev touchpad_led = {
2317 + .name = "dell-laptop::touchpad",
2318 + .brightness_set = touchpad_led_set,
2319 ++ .flags = LED_CORE_SUSPENDRESUME,
2320 + };
2321 +
2322 + static int __devinit touchpad_led_init(struct device *dev)
2323 +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
2324 +index 1b831c5..e48ba4b 100644
2325 +--- a/drivers/scsi/libsas/sas_expander.c
2326 ++++ b/drivers/scsi/libsas/sas_expander.c
2327 +@@ -192,7 +192,14 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,
2328 + phy->attached_sata_ps = dr->attached_sata_ps;
2329 + phy->attached_iproto = dr->iproto << 1;
2330 + phy->attached_tproto = dr->tproto << 1;
2331 +- memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
2332 ++ /* help some expanders that fail to zero sas_address in the 'no
2333 ++ * device' case
2334 ++ */
2335 ++ if (phy->attached_dev_type == NO_DEVICE ||
2336 ++ phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
2337 ++ memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
2338 ++ else
2339 ++ memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
2340 + phy->attached_phy_id = dr->attached_phy_id;
2341 + phy->phy_change_count = dr->change_count;
2342 + phy->routing_attr = dr->routing_attr;
2343 +@@ -1643,9 +1650,17 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
2344 + int phy_change_count = 0;
2345 +
2346 + res = sas_get_phy_change_count(dev, i, &phy_change_count);
2347 +- if (res)
2348 +- goto out;
2349 +- else if (phy_change_count != ex->ex_phy[i].phy_change_count) {
2350 ++ switch (res) {
2351 ++ case SMP_RESP_PHY_VACANT:
2352 ++ case SMP_RESP_NO_PHY:
2353 ++ continue;
2354 ++ case SMP_RESP_FUNC_ACC:
2355 ++ break;
2356 ++ default:
2357 ++ return res;
2358 ++ }
2359 ++
2360 ++ if (phy_change_count != ex->ex_phy[i].phy_change_count) {
2361 + if (update)
2362 + ex->ex_phy[i].phy_change_count =
2363 + phy_change_count;
2364 +@@ -1653,8 +1668,7 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
2365 + return 0;
2366 + }
2367 + }
2368 +-out:
2369 +- return res;
2370 ++ return 0;
2371 + }
2372 +
2373 + static int sas_get_ex_change_count(struct domain_device *dev, int *ecc)
2374 +diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
2375 +index 24cacff..5f748c0 100644
2376 +--- a/drivers/spi/spi-fsl-spi.c
2377 ++++ b/drivers/spi/spi-fsl-spi.c
2378 +@@ -139,10 +139,12 @@ static void fsl_spi_change_mode(struct spi_device *spi)
2379 + static void fsl_spi_chipselect(struct spi_device *spi, int value)
2380 + {
2381 + struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
2382 +- struct fsl_spi_platform_data *pdata = spi->dev.parent->platform_data;
2383 ++ struct fsl_spi_platform_data *pdata;
2384 + bool pol = spi->mode & SPI_CS_HIGH;
2385 + struct spi_mpc8xxx_cs *cs = spi->controller_state;
2386 +
2387 ++ pdata = spi->dev.parent->parent->platform_data;
2388 ++
2389 + if (value == BITBANG_CS_INACTIVE) {
2390 + if (pdata->cs_control)
2391 + pdata->cs_control(spi, !pol);
2392 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
2393 +index 77eae99..b2ccdea 100644
2394 +--- a/drivers/spi/spi.c
2395 ++++ b/drivers/spi/spi.c
2396 +@@ -319,7 +319,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master)
2397 + }
2398 +
2399 + spi->master = master;
2400 +- spi->dev.parent = dev;
2401 ++ spi->dev.parent = &master->dev;
2402 + spi->dev.bus = &spi_bus_type;
2403 + spi->dev.release = spidev_release;
2404 + device_initialize(&spi->dev);
2405 +diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
2406 +index fb11743..4bb2797 100644
2407 +--- a/drivers/staging/rtl8712/os_intfs.c
2408 ++++ b/drivers/staging/rtl8712/os_intfs.c
2409 +@@ -476,9 +476,6 @@ static int netdev_close(struct net_device *pnetdev)
2410 + r8712_free_assoc_resources(padapter);
2411 + /*s2-4.*/
2412 + r8712_free_network_queue(padapter);
2413 +- release_firmware(padapter->fw);
2414 +- /* never exit with a firmware callback pending */
2415 +- wait_for_completion(&padapter->rtl8712_fw_ready);
2416 + return 0;
2417 + }
2418 +
2419 +diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
2420 +index 9bade18..ec41d38 100644
2421 +--- a/drivers/staging/rtl8712/usb_intf.c
2422 ++++ b/drivers/staging/rtl8712/usb_intf.c
2423 +@@ -30,6 +30,7 @@
2424 +
2425 + #include <linux/usb.h>
2426 + #include <linux/module.h>
2427 ++#include <linux/firmware.h>
2428 +
2429 + #include "osdep_service.h"
2430 + #include "drv_types.h"
2431 +@@ -621,6 +622,10 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
2432 + struct _adapter *padapter = netdev_priv(pnetdev);
2433 + struct usb_device *udev = interface_to_usbdev(pusb_intf);
2434 +
2435 ++ if (padapter->fw_found)
2436 ++ release_firmware(padapter->fw);
2437 ++ /* never exit with a firmware callback pending */
2438 ++ wait_for_completion(&padapter->rtl8712_fw_ready);
2439 + usb_set_intfdata(pusb_intf, NULL);
2440 + if (padapter) {
2441 + if (drvpriv.drv_registered == true)
2442 +diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
2443 +index b84c834..8daf073 100644
2444 +--- a/drivers/tty/amiserial.c
2445 ++++ b/drivers/tty/amiserial.c
2446 +@@ -1113,8 +1113,10 @@ static int set_serial_info(struct async_struct * info,
2447 + (new_serial.close_delay != state->close_delay) ||
2448 + (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
2449 + ((new_serial.flags & ~ASYNC_USR_MASK) !=
2450 +- (state->flags & ~ASYNC_USR_MASK)))
2451 ++ (state->flags & ~ASYNC_USR_MASK))) {
2452 ++ tty_unlock();
2453 + return -EPERM;
2454 ++ }
2455 + state->flags = ((state->flags & ~ASYNC_USR_MASK) |
2456 + (new_serial.flags & ASYNC_USR_MASK));
2457 + info->flags = ((info->flags & ~ASYNC_USR_MASK) |
2458 +diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
2459 +index e6c3dbd..836fe273 100644
2460 +--- a/drivers/tty/serial/clps711x.c
2461 ++++ b/drivers/tty/serial/clps711x.c
2462 +@@ -154,10 +154,9 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id)
2463 + port->x_char = 0;
2464 + return IRQ_HANDLED;
2465 + }
2466 +- if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
2467 +- clps711xuart_stop_tx(port);
2468 +- return IRQ_HANDLED;
2469 +- }
2470 ++
2471 ++ if (uart_circ_empty(xmit) || uart_tx_stopped(port))
2472 ++ goto disable_tx_irq;
2473 +
2474 + count = port->fifosize >> 1;
2475 + do {
2476 +@@ -171,8 +170,11 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id)
2477 + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
2478 + uart_write_wakeup(port);
2479 +
2480 +- if (uart_circ_empty(xmit))
2481 +- clps711xuart_stop_tx(port);
2482 ++ if (uart_circ_empty(xmit)) {
2483 ++ disable_tx_irq:
2484 ++ disable_irq_nosync(TX_IRQ(port));
2485 ++ tx_enabled(port) = 0;
2486 ++ }
2487 +
2488 + return IRQ_HANDLED;
2489 + }
2490 +diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
2491 +index da776a0..a4b192d 100644
2492 +--- a/drivers/tty/serial/pch_uart.c
2493 ++++ b/drivers/tty/serial/pch_uart.c
2494 +@@ -1356,9 +1356,11 @@ static int pch_uart_verify_port(struct uart_port *port,
2495 + __func__);
2496 + return -EOPNOTSUPP;
2497 + #endif
2498 +- priv->use_dma = 1;
2499 + priv->use_dma_flag = 1;
2500 + dev_info(priv->port.dev, "PCH UART : Use DMA Mode\n");
2501 ++ if (!priv->use_dma)
2502 ++ pch_request_dma(port);
2503 ++ priv->use_dma = 1;
2504 + }
2505 +
2506 + return 0;
2507 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
2508 +index 9eb71d8..2db0327 100644
2509 +--- a/drivers/usb/class/cdc-wdm.c
2510 ++++ b/drivers/usb/class/cdc-wdm.c
2511 +@@ -108,8 +108,9 @@ static void wdm_out_callback(struct urb *urb)
2512 + spin_lock(&desc->iuspin);
2513 + desc->werr = urb->status;
2514 + spin_unlock(&desc->iuspin);
2515 +- clear_bit(WDM_IN_USE, &desc->flags);
2516 + kfree(desc->outbuf);
2517 ++ desc->outbuf = NULL;
2518 ++ clear_bit(WDM_IN_USE, &desc->flags);
2519 + wake_up(&desc->wait);
2520 + }
2521 +
2522 +@@ -312,7 +313,7 @@ static ssize_t wdm_write
2523 + if (we < 0)
2524 + return -EIO;
2525 +
2526 +- desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
2527 ++ buf = kmalloc(count, GFP_KERNEL);
2528 + if (!buf) {
2529 + rv = -ENOMEM;
2530 + goto outnl;
2531 +@@ -376,10 +377,12 @@ static ssize_t wdm_write
2532 + req->wIndex = desc->inum;
2533 + req->wLength = cpu_to_le16(count);
2534 + set_bit(WDM_IN_USE, &desc->flags);
2535 ++ desc->outbuf = buf;
2536 +
2537 + rv = usb_submit_urb(desc->command, GFP_KERNEL);
2538 + if (rv < 0) {
2539 + kfree(buf);
2540 ++ desc->outbuf = NULL;
2541 + clear_bit(WDM_IN_USE, &desc->flags);
2542 + dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
2543 + } else {
2544 +diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
2545 +index 61d08dd..5f1404a 100644
2546 +--- a/drivers/usb/core/hcd-pci.c
2547 ++++ b/drivers/usb/core/hcd-pci.c
2548 +@@ -495,6 +495,15 @@ static int hcd_pci_suspend_noirq(struct device *dev)
2549 +
2550 + pci_save_state(pci_dev);
2551 +
2552 ++ /*
2553 ++ * Some systems crash if an EHCI controller is in D3 during
2554 ++ * a sleep transition. We have to leave such controllers in D0.
2555 ++ */
2556 ++ if (hcd->broken_pci_sleep) {
2557 ++ dev_dbg(dev, "Staying in PCI D0\n");
2558 ++ return retval;
2559 ++ }
2560 ++
2561 + /* If the root hub is dead rather than suspended, disallow remote
2562 + * wakeup. usb_hc_died() should ensure that both hosts are marked as
2563 + * dying, so we only need to check the primary roothub.
2564 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2565 +index e238b3b..2b0a341 100644
2566 +--- a/drivers/usb/core/hub.c
2567 ++++ b/drivers/usb/core/hub.c
2568 +@@ -1644,7 +1644,6 @@ void usb_disconnect(struct usb_device **pdev)
2569 + {
2570 + struct usb_device *udev = *pdev;
2571 + int i;
2572 +- struct usb_hcd *hcd = bus_to_hcd(udev->bus);
2573 +
2574 + /* mark the device as inactive, so any further urb submissions for
2575 + * this device (and any of its children) will fail immediately.
2576 +@@ -1667,9 +1666,7 @@ void usb_disconnect(struct usb_device **pdev)
2577 + * so that the hardware is now fully quiesced.
2578 + */
2579 + dev_dbg (&udev->dev, "unregistering device\n");
2580 +- mutex_lock(hcd->bandwidth_mutex);
2581 + usb_disable_device(udev, 0);
2582 +- mutex_unlock(hcd->bandwidth_mutex);
2583 + usb_hcd_synchronize_unlinks(udev);
2584 +
2585 + usb_remove_ep_devs(&udev->ep0);
2586 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
2587 +index aed3e07..ca717da 100644
2588 +--- a/drivers/usb/core/message.c
2589 ++++ b/drivers/usb/core/message.c
2590 +@@ -1136,8 +1136,6 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
2591 + * Deallocates hcd/hardware state for the endpoints (nuking all or most
2592 + * pending urbs) and usbcore state for the interfaces, so that usbcore
2593 + * must usb_set_configuration() before any interfaces could be used.
2594 +- *
2595 +- * Must be called with hcd->bandwidth_mutex held.
2596 + */
2597 + void usb_disable_device(struct usb_device *dev, int skip_ep0)
2598 + {
2599 +@@ -1190,7 +1188,9 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
2600 + usb_disable_endpoint(dev, i + USB_DIR_IN, false);
2601 + }
2602 + /* Remove endpoints from the host controller internal state */
2603 ++ mutex_lock(hcd->bandwidth_mutex);
2604 + usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
2605 ++ mutex_unlock(hcd->bandwidth_mutex);
2606 + /* Second pass: remove endpoint pointers */
2607 + }
2608 + for (i = skip_ep0; i < 16; ++i) {
2609 +@@ -1750,7 +1750,6 @@ free_interfaces:
2610 + /* if it's already configured, clear out old state first.
2611 + * getting rid of old interfaces means unbinding their drivers.
2612 + */
2613 +- mutex_lock(hcd->bandwidth_mutex);
2614 + if (dev->state != USB_STATE_ADDRESS)
2615 + usb_disable_device(dev, 1); /* Skip ep0 */
2616 +
2617 +@@ -1763,6 +1762,7 @@ free_interfaces:
2618 + * host controller will not allow submissions to dropped endpoints. If
2619 + * this call fails, the device state is unchanged.
2620 + */
2621 ++ mutex_lock(hcd->bandwidth_mutex);
2622 + ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
2623 + if (ret < 0) {
2624 + mutex_unlock(hcd->bandwidth_mutex);
2625 +diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
2626 +index 27bd50a..c0dcf69 100644
2627 +--- a/drivers/usb/dwc3/ep0.c
2628 ++++ b/drivers/usb/dwc3/ep0.c
2629 +@@ -572,9 +572,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
2630 + dwc->ep0_bounced = false;
2631 + } else {
2632 + transferred = ur->length - trb.length;
2633 +- ur->actual += transferred;
2634 + }
2635 +
2636 ++ ur->actual += transferred;
2637 ++
2638 + if ((epnum & 1) && ur->actual < ur->length) {
2639 + /* for some reason we did not get everything out */
2640 +
2641 +diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
2642 +index ab8f1b4..527736e 100644
2643 +--- a/drivers/usb/gadget/dummy_hcd.c
2644 ++++ b/drivers/usb/gadget/dummy_hcd.c
2645 +@@ -925,7 +925,6 @@ static int dummy_udc_stop(struct usb_gadget *g,
2646 +
2647 + dum->driver = NULL;
2648 +
2649 +- dummy_pullup(&dum->gadget, 0);
2650 + return 0;
2651 + }
2652 +
2653 +diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
2654 +index acb3800..0e641a1 100644
2655 +--- a/drivers/usb/gadget/f_fs.c
2656 ++++ b/drivers/usb/gadget/f_fs.c
2657 +@@ -712,7 +712,7 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
2658 + if (code == FUNCTIONFS_INTERFACE_REVMAP) {
2659 + struct ffs_function *func = ffs->func;
2660 + ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV;
2661 +- } else if (gadget->ops->ioctl) {
2662 ++ } else if (gadget && gadget->ops->ioctl) {
2663 + ret = gadget->ops->ioctl(gadget, code, value);
2664 + } else {
2665 + ret = -ENOTTY;
2666 +diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
2667 +index 1a6f415..a5570b6 100644
2668 +--- a/drivers/usb/gadget/f_mass_storage.c
2669 ++++ b/drivers/usb/gadget/f_mass_storage.c
2670 +@@ -2182,7 +2182,7 @@ unknown_cmnd:
2671 + common->data_size_from_cmnd = 0;
2672 + sprintf(unknown, "Unknown x%02x", common->cmnd[0]);
2673 + reply = check_command(common, common->cmnd_size,
2674 +- DATA_DIR_UNKNOWN, 0xff, 0, unknown);
2675 ++ DATA_DIR_UNKNOWN, ~0, 0, unknown);
2676 + if (reply == 0) {
2677 + common->curlun->sense_data = SS_INVALID_COMMAND;
2678 + reply = -EINVAL;
2679 +diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
2680 +index 11b5196..db2d607 100644
2681 +--- a/drivers/usb/gadget/file_storage.c
2682 ++++ b/drivers/usb/gadget/file_storage.c
2683 +@@ -2569,7 +2569,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2684 + fsg->data_size_from_cmnd = 0;
2685 + sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
2686 + if ((reply = check_command(fsg, fsg->cmnd_size,
2687 +- DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) {
2688 ++ DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
2689 + fsg->curlun->sense_data = SS_INVALID_COMMAND;
2690 + reply = -EINVAL;
2691 + }
2692 +diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
2693 +index 6939e17..901924a 100644
2694 +--- a/drivers/usb/gadget/udc-core.c
2695 ++++ b/drivers/usb/gadget/udc-core.c
2696 +@@ -211,9 +211,9 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
2697 +
2698 + if (udc_is_newstyle(udc)) {
2699 + udc->driver->disconnect(udc->gadget);
2700 ++ usb_gadget_disconnect(udc->gadget);
2701 + udc->driver->unbind(udc->gadget);
2702 + usb_gadget_udc_stop(udc->gadget, udc->driver);
2703 +- usb_gadget_disconnect(udc->gadget);
2704 + } else {
2705 + usb_gadget_stop(udc->gadget, udc->driver);
2706 + }
2707 +@@ -359,9 +359,13 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
2708 + struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
2709 +
2710 + if (sysfs_streq(buf, "connect")) {
2711 ++ if (udc_is_newstyle(udc))
2712 ++ usb_gadget_udc_start(udc->gadget, udc->driver);
2713 + usb_gadget_connect(udc->gadget);
2714 + } else if (sysfs_streq(buf, "disconnect")) {
2715 + usb_gadget_disconnect(udc->gadget);
2716 ++ if (udc_is_newstyle(udc))
2717 ++ usb_gadget_udc_stop(udc->gadget, udc->driver);
2718 + } else {
2719 + dev_err(dev, "unsupported command '%s'\n", buf);
2720 + return -EINVAL;
2721 +diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h
2722 +index bc78c60..ca4e03a 100644
2723 +--- a/drivers/usb/gadget/uvc.h
2724 ++++ b/drivers/usb/gadget/uvc.h
2725 +@@ -28,7 +28,7 @@
2726 +
2727 + struct uvc_request_data
2728 + {
2729 +- unsigned int length;
2730 ++ __s32 length;
2731 + __u8 data[60];
2732 + };
2733 +
2734 +diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
2735 +index f6e083b..54d7ca5 100644
2736 +--- a/drivers/usb/gadget/uvc_v4l2.c
2737 ++++ b/drivers/usb/gadget/uvc_v4l2.c
2738 +@@ -39,7 +39,7 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data)
2739 + if (data->length < 0)
2740 + return usb_ep_set_halt(cdev->gadget->ep0);
2741 +
2742 +- req->length = min(uvc->event_length, data->length);
2743 ++ req->length = min_t(unsigned int, uvc->event_length, data->length);
2744 + req->zero = data->length < uvc->event_length;
2745 + req->dma = DMA_ADDR_INVALID;
2746 +
2747 +diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
2748 +index 3ff9f82..da2f711 100644
2749 +--- a/drivers/usb/host/ehci-hcd.c
2750 ++++ b/drivers/usb/host/ehci-hcd.c
2751 +@@ -815,8 +815,13 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
2752 + goto dead;
2753 + }
2754 +
2755 ++ /*
2756 ++ * We don't use STS_FLR, but some controllers don't like it to
2757 ++ * remain on, so mask it out along with the other status bits.
2758 ++ */
2759 ++ masked_status = status & (INTR_MASK | STS_FLR);
2760 ++
2761 + /* Shared IRQ? */
2762 +- masked_status = status & INTR_MASK;
2763 + if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
2764 + spin_unlock(&ehci->lock);
2765 + return IRQ_NONE;
2766 +@@ -867,7 +872,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
2767 + pcd_status = status;
2768 +
2769 + /* resume root hub? */
2770 +- if (!(cmd & CMD_RUN))
2771 ++ if (ehci->rh_state == EHCI_RH_SUSPENDED)
2772 + usb_hcd_resume_root_hub(hcd);
2773 +
2774 + /* get per-port change detect bits */
2775 +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
2776 +index f4b627d..971d312 100644
2777 +--- a/drivers/usb/host/ehci-pci.c
2778 ++++ b/drivers/usb/host/ehci-pci.c
2779 +@@ -144,6 +144,14 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
2780 + hcd->has_tt = 1;
2781 + tdi_reset(ehci);
2782 + }
2783 ++ if (pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK) {
2784 ++ /* EHCI #1 or #2 on 6 Series/C200 Series chipset */
2785 ++ if (pdev->device == 0x1c26 || pdev->device == 0x1c2d) {
2786 ++ ehci_info(ehci, "broken D3 during system sleep on ASUS\n");
2787 ++ hcd->broken_pci_sleep = 1;
2788 ++ device_set_wakeup_capable(&pdev->dev, false);
2789 ++ }
2790 ++ }
2791 + break;
2792 + case PCI_VENDOR_ID_TDI:
2793 + if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
2794 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
2795 +index ac5bfd6..2504694 100644
2796 +--- a/drivers/usb/misc/yurex.c
2797 ++++ b/drivers/usb/misc/yurex.c
2798 +@@ -99,9 +99,7 @@ static void yurex_delete(struct kref *kref)
2799 + usb_put_dev(dev->udev);
2800 + if (dev->cntl_urb) {
2801 + usb_kill_urb(dev->cntl_urb);
2802 +- if (dev->cntl_req)
2803 +- usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
2804 +- dev->cntl_req, dev->cntl_urb->setup_dma);
2805 ++ kfree(dev->cntl_req);
2806 + if (dev->cntl_buffer)
2807 + usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
2808 + dev->cntl_buffer, dev->cntl_urb->transfer_dma);
2809 +@@ -234,9 +232,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
2810 + }
2811 +
2812 + /* allocate buffer for control req */
2813 +- dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
2814 +- GFP_KERNEL,
2815 +- &dev->cntl_urb->setup_dma);
2816 ++ dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
2817 + if (!dev->cntl_req) {
2818 + err("Could not allocate cntl_req");
2819 + goto error;
2820 +@@ -286,7 +282,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
2821 + usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
2822 + dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
2823 + dev, 1);
2824 +- dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2825 ++ dev->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2826 + if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
2827 + retval = -EIO;
2828 + err("Could not submitting URB");
2829 +diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
2830 +index ba85f27..a8f0c09 100644
2831 +--- a/drivers/usb/musb/omap2430.c
2832 ++++ b/drivers/usb/musb/omap2430.c
2833 +@@ -282,7 +282,8 @@ static int musb_otg_notifications(struct notifier_block *nb,
2834 +
2835 + static int omap2430_musb_init(struct musb *musb)
2836 + {
2837 +- u32 l, status = 0;
2838 ++ u32 l;
2839 ++ int status = 0;
2840 + struct device *dev = musb->controller;
2841 + struct musb_hdrc_platform_data *plat = dev->platform_data;
2842 + struct omap_musb_board_data *data = plat->board_data;
2843 +@@ -299,7 +300,7 @@ static int omap2430_musb_init(struct musb *musb)
2844 +
2845 + status = pm_runtime_get_sync(dev);
2846 + if (status < 0) {
2847 +- dev_err(dev, "pm_runtime_get_sync FAILED");
2848 ++ dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
2849 + goto err1;
2850 + }
2851 +
2852 +@@ -451,14 +452,14 @@ static int __init omap2430_probe(struct platform_device *pdev)
2853 + goto err2;
2854 + }
2855 +
2856 ++ pm_runtime_enable(&pdev->dev);
2857 ++
2858 + ret = platform_device_add(musb);
2859 + if (ret) {
2860 + dev_err(&pdev->dev, "failed to register musb device\n");
2861 + goto err2;
2862 + }
2863 +
2864 +- pm_runtime_enable(&pdev->dev);
2865 +-
2866 + return 0;
2867 +
2868 + err2:
2869 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
2870 +index 4c12404..f2c57e0 100644
2871 +--- a/drivers/usb/serial/cp210x.c
2872 ++++ b/drivers/usb/serial/cp210x.c
2873 +@@ -285,7 +285,8 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
2874 + /* Issue the request, attempting to read 'size' bytes */
2875 + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
2876 + request, REQTYPE_DEVICE_TO_HOST, 0x0000,
2877 +- port_priv->bInterfaceNumber, buf, size, 300);
2878 ++ port_priv->bInterfaceNumber, buf, size,
2879 ++ USB_CTRL_GET_TIMEOUT);
2880 +
2881 + /* Convert data into an array of integers */
2882 + for (i = 0; i < length; i++)
2883 +@@ -335,12 +336,14 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
2884 + result = usb_control_msg(serial->dev,
2885 + usb_sndctrlpipe(serial->dev, 0),
2886 + request, REQTYPE_HOST_TO_DEVICE, 0x0000,
2887 +- port_priv->bInterfaceNumber, buf, size, 300);
2888 ++ port_priv->bInterfaceNumber, buf, size,
2889 ++ USB_CTRL_SET_TIMEOUT);
2890 + } else {
2891 + result = usb_control_msg(serial->dev,
2892 + usb_sndctrlpipe(serial->dev, 0),
2893 + request, REQTYPE_HOST_TO_DEVICE, data[0],
2894 +- port_priv->bInterfaceNumber, NULL, 0, 300);
2895 ++ port_priv->bInterfaceNumber, NULL, 0,
2896 ++ USB_CTRL_SET_TIMEOUT);
2897 + }
2898 +
2899 + kfree(buf);
2900 +diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
2901 +index 7c3ec9e..e093585 100644
2902 +--- a/drivers/usb/serial/sierra.c
2903 ++++ b/drivers/usb/serial/sierra.c
2904 +@@ -221,7 +221,7 @@ static const struct sierra_iface_info typeB_interface_list = {
2905 + };
2906 +
2907 + /* 'blacklist' of interfaces not served by this driver */
2908 +-static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11 };
2909 ++static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 };
2910 + static const struct sierra_iface_info direct_ip_interface_blacklist = {
2911 + .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces),
2912 + .ifaceinfo = direct_ip_non_serial_ifaces,
2913 +@@ -289,7 +289,6 @@ static const struct usb_device_id id_table[] = {
2914 + { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
2915 + { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */
2916 + { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
2917 +- { USB_DEVICE(0x1199, 0x68A2) }, /* Sierra Wireless MC7710 */
2918 + /* Sierra Wireless C885 */
2919 + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)},
2920 + /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */
2921 +@@ -299,6 +298,9 @@ static const struct usb_device_id id_table[] = {
2922 + /* Sierra Wireless HSPA Non-Composite Device */
2923 + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
2924 + { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
2925 ++ { USB_DEVICE(0x1199, 0x68A2), /* Sierra Wireless MC77xx in QMI mode */
2926 ++ .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
2927 ++ },
2928 + { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */
2929 + .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
2930 + },
2931 +diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
2932 +index 2babcd4..86685e9 100644
2933 +--- a/drivers/uwb/hwa-rc.c
2934 ++++ b/drivers/uwb/hwa-rc.c
2935 +@@ -645,7 +645,8 @@ void hwarc_neep_cb(struct urb *urb)
2936 + dev_err(dev, "NEEP: URB error %d\n", urb->status);
2937 + }
2938 + result = usb_submit_urb(urb, GFP_ATOMIC);
2939 +- if (result < 0) {
2940 ++ if (result < 0 && result != -ENODEV && result != -EPERM) {
2941 ++ /* ignoring unrecoverable errors */
2942 + dev_err(dev, "NEEP: Can't resubmit URB (%d) resetting device\n",
2943 + result);
2944 + goto error;
2945 +diff --git a/drivers/uwb/neh.c b/drivers/uwb/neh.c
2946 +index a269937..8cb71bb 100644
2947 +--- a/drivers/uwb/neh.c
2948 ++++ b/drivers/uwb/neh.c
2949 +@@ -107,6 +107,7 @@ struct uwb_rc_neh {
2950 + u8 evt_type;
2951 + __le16 evt;
2952 + u8 context;
2953 ++ u8 completed;
2954 + uwb_rc_cmd_cb_f cb;
2955 + void *arg;
2956 +
2957 +@@ -409,6 +410,7 @@ static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size
2958 + struct device *dev = &rc->uwb_dev.dev;
2959 + struct uwb_rc_neh *neh;
2960 + struct uwb_rceb *notif;
2961 ++ unsigned long flags;
2962 +
2963 + if (rceb->bEventContext == 0) {
2964 + notif = kmalloc(size, GFP_ATOMIC);
2965 +@@ -422,7 +424,11 @@ static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size
2966 + } else {
2967 + neh = uwb_rc_neh_lookup(rc, rceb);
2968 + if (neh) {
2969 +- del_timer_sync(&neh->timer);
2970 ++ spin_lock_irqsave(&rc->neh_lock, flags);
2971 ++ /* to guard against a timeout */
2972 ++ neh->completed = 1;
2973 ++ del_timer(&neh->timer);
2974 ++ spin_unlock_irqrestore(&rc->neh_lock, flags);
2975 + uwb_rc_neh_cb(neh, rceb, size);
2976 + } else
2977 + dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n",
2978 +@@ -568,6 +574,10 @@ static void uwb_rc_neh_timer(unsigned long arg)
2979 + unsigned long flags;
2980 +
2981 + spin_lock_irqsave(&rc->neh_lock, flags);
2982 ++ if (neh->completed) {
2983 ++ spin_unlock_irqrestore(&rc->neh_lock, flags);
2984 ++ return;
2985 ++ }
2986 + if (neh->context)
2987 + __uwb_rc_neh_rm(rc, neh);
2988 + else
2989 +diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
2990 +index afca14d..625890c 100644
2991 +--- a/drivers/xen/gntdev.c
2992 ++++ b/drivers/xen/gntdev.c
2993 +@@ -692,7 +692,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
2994 + vma->vm_flags |= VM_RESERVED|VM_DONTEXPAND;
2995 +
2996 + if (use_ptemod)
2997 +- vma->vm_flags |= VM_DONTCOPY|VM_PFNMAP;
2998 ++ vma->vm_flags |= VM_DONTCOPY;
2999 +
3000 + vma->vm_private_data = map;
3001 +
3002 +diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
3003 +index 2f73195..2ce95c0 100644
3004 +--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
3005 ++++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
3006 +@@ -129,7 +129,7 @@ static int read_backend_details(struct xenbus_device *xendev)
3007 + return xenbus_read_otherend_details(xendev, "backend-id", "backend");
3008 + }
3009 +
3010 +-static int is_device_connecting(struct device *dev, void *data)
3011 ++static int is_device_connecting(struct device *dev, void *data, bool ignore_nonessential)
3012 + {
3013 + struct xenbus_device *xendev = to_xenbus_device(dev);
3014 + struct device_driver *drv = data;
3015 +@@ -146,16 +146,41 @@ static int is_device_connecting(struct device *dev, void *data)
3016 + if (drv && (dev->driver != drv))
3017 + return 0;
3018 +
3019 ++ if (ignore_nonessential) {
3020 ++ /* With older QEMU, for PVonHVM guests the guest config files
3021 ++ * could contain: vfb = [ 'vnc=1, vnclisten=0.0.0.0']
3022 ++ * which is nonsensical as there is no PV FB (there can be
3023 ++ * a PVKB) running as HVM guest. */
3024 ++
3025 ++ if ((strncmp(xendev->nodename, "device/vkbd", 11) == 0))
3026 ++ return 0;
3027 ++
3028 ++ if ((strncmp(xendev->nodename, "device/vfb", 10) == 0))
3029 ++ return 0;
3030 ++ }
3031 + xendrv = to_xenbus_driver(dev->driver);
3032 + return (xendev->state < XenbusStateConnected ||
3033 + (xendev->state == XenbusStateConnected &&
3034 + xendrv->is_ready && !xendrv->is_ready(xendev)));
3035 + }
3036 ++static int essential_device_connecting(struct device *dev, void *data)
3037 ++{
3038 ++ return is_device_connecting(dev, data, true /* ignore PV[KBB+FB] */);
3039 ++}
3040 ++static int non_essential_device_connecting(struct device *dev, void *data)
3041 ++{
3042 ++ return is_device_connecting(dev, data, false);
3043 ++}
3044 +
3045 +-static int exists_connecting_device(struct device_driver *drv)
3046 ++static int exists_essential_connecting_device(struct device_driver *drv)
3047 + {
3048 + return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
3049 +- is_device_connecting);
3050 ++ essential_device_connecting);
3051 ++}
3052 ++static int exists_non_essential_connecting_device(struct device_driver *drv)
3053 ++{
3054 ++ return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
3055 ++ non_essential_device_connecting);
3056 + }
3057 +
3058 + static int print_device_status(struct device *dev, void *data)
3059 +@@ -186,6 +211,23 @@ static int print_device_status(struct device *dev, void *data)
3060 + /* We only wait for device setup after most initcalls have run. */
3061 + static int ready_to_wait_for_devices;
3062 +
3063 ++static bool wait_loop(unsigned long start, unsigned int max_delay,
3064 ++ unsigned int *seconds_waited)
3065 ++{
3066 ++ if (time_after(jiffies, start + (*seconds_waited+5)*HZ)) {
3067 ++ if (!*seconds_waited)
3068 ++ printk(KERN_WARNING "XENBUS: Waiting for "
3069 ++ "devices to initialise: ");
3070 ++ *seconds_waited += 5;
3071 ++ printk("%us...", max_delay - *seconds_waited);
3072 ++ if (*seconds_waited == max_delay)
3073 ++ return true;
3074 ++ }
3075 ++
3076 ++ schedule_timeout_interruptible(HZ/10);
3077 ++
3078 ++ return false;
3079 ++}
3080 + /*
3081 + * On a 5-minute timeout, wait for all devices currently configured. We need
3082 + * to do this to guarantee that the filesystems and / or network devices
3083 +@@ -209,19 +251,14 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
3084 + if (!ready_to_wait_for_devices || !xen_domain())
3085 + return;
3086 +
3087 +- while (exists_connecting_device(drv)) {
3088 +- if (time_after(jiffies, start + (seconds_waited+5)*HZ)) {
3089 +- if (!seconds_waited)
3090 +- printk(KERN_WARNING "XENBUS: Waiting for "
3091 +- "devices to initialise: ");
3092 +- seconds_waited += 5;
3093 +- printk("%us...", 300 - seconds_waited);
3094 +- if (seconds_waited == 300)
3095 +- break;
3096 +- }
3097 +-
3098 +- schedule_timeout_interruptible(HZ/10);
3099 +- }
3100 ++ while (exists_non_essential_connecting_device(drv))
3101 ++ if (wait_loop(start, 30, &seconds_waited))
3102 ++ break;
3103 ++
3104 ++ /* Skips PVKB and PVFB check.*/
3105 ++ while (exists_essential_connecting_device(drv))
3106 ++ if (wait_loop(start, 270, &seconds_waited))
3107 ++ break;
3108 +
3109 + if (seconds_waited)
3110 + printk("\n");
3111 +diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
3112 +index 308a98b..650d520 100644
3113 +--- a/fs/autofs4/autofs_i.h
3114 ++++ b/fs/autofs4/autofs_i.h
3115 +@@ -110,7 +110,6 @@ struct autofs_sb_info {
3116 + int sub_version;
3117 + int min_proto;
3118 + int max_proto;
3119 +- int compat_daemon;
3120 + unsigned long exp_timeout;
3121 + unsigned int type;
3122 + int reghost_enabled;
3123 +@@ -269,6 +268,17 @@ int autofs4_fill_super(struct super_block *, void *, int);
3124 + struct autofs_info *autofs4_new_ino(struct autofs_sb_info *);
3125 + void autofs4_clean_ino(struct autofs_info *);
3126 +
3127 ++static inline int autofs_prepare_pipe(struct file *pipe)
3128 ++{
3129 ++ if (!pipe->f_op || !pipe->f_op->write)
3130 ++ return -EINVAL;
3131 ++ if (!S_ISFIFO(pipe->f_dentry->d_inode->i_mode))
3132 ++ return -EINVAL;
3133 ++ /* We want a packet pipe */
3134 ++ pipe->f_flags |= O_DIRECT;
3135 ++ return 0;
3136 ++}
3137 ++
3138 + /* Queue management functions */
3139 +
3140 + int autofs4_wait(struct autofs_sb_info *,struct dentry *, enum autofs_notify);
3141 +diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
3142 +index 56bac70..de54271 100644
3143 +--- a/fs/autofs4/dev-ioctl.c
3144 ++++ b/fs/autofs4/dev-ioctl.c
3145 +@@ -376,7 +376,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
3146 + err = -EBADF;
3147 + goto out;
3148 + }
3149 +- if (!pipe->f_op || !pipe->f_op->write) {
3150 ++ if (autofs_prepare_pipe(pipe) < 0) {
3151 + err = -EPIPE;
3152 + fput(pipe);
3153 + goto out;
3154 +@@ -385,7 +385,6 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
3155 + sbi->pipefd = pipefd;
3156 + sbi->pipe = pipe;
3157 + sbi->catatonic = 0;
3158 +- sbi->compat_daemon = is_compat_task();
3159 + }
3160 + out:
3161 + mutex_unlock(&sbi->wq_mutex);
3162 +diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
3163 +index 98a5695..7b5293e 100644
3164 +--- a/fs/autofs4/inode.c
3165 ++++ b/fs/autofs4/inode.c
3166 +@@ -19,7 +19,6 @@
3167 + #include <linux/parser.h>
3168 + #include <linux/bitops.h>
3169 + #include <linux/magic.h>
3170 +-#include <linux/compat.h>
3171 + #include "autofs_i.h"
3172 + #include <linux/module.h>
3173 +
3174 +@@ -225,7 +224,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
3175 + set_autofs_type_indirect(&sbi->type);
3176 + sbi->min_proto = 0;
3177 + sbi->max_proto = 0;
3178 +- sbi->compat_daemon = is_compat_task();
3179 + mutex_init(&sbi->wq_mutex);
3180 + spin_lock_init(&sbi->fs_lock);
3181 + sbi->queues = NULL;
3182 +@@ -294,7 +292,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
3183 + printk("autofs: could not open pipe file descriptor\n");
3184 + goto fail_dput;
3185 + }
3186 +- if (!pipe->f_op || !pipe->f_op->write)
3187 ++ if (autofs_prepare_pipe(pipe) < 0)
3188 + goto fail_fput;
3189 + sbi->pipe = pipe;
3190 + sbi->pipefd = pipefd;
3191 +diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
3192 +index 6861f61..e1fbdee 100644
3193 +--- a/fs/autofs4/waitq.c
3194 ++++ b/fs/autofs4/waitq.c
3195 +@@ -90,24 +90,7 @@ static int autofs4_write(struct file *file, const void *addr, int bytes)
3196 +
3197 + return (bytes > 0);
3198 + }
3199 +-
3200 +-/*
3201 +- * The autofs_v5 packet was misdesigned.
3202 +- *
3203 +- * The packets are identical on x86-32 and x86-64, but have different
3204 +- * alignment. Which means that 'sizeof()' will give different results.
3205 +- * Fix it up for the case of running 32-bit user mode on a 64-bit kernel.
3206 +- */
3207 +-static noinline size_t autofs_v5_packet_size(struct autofs_sb_info *sbi)
3208 +-{
3209 +- size_t pktsz = sizeof(struct autofs_v5_packet);
3210 +-#if defined(CONFIG_X86_64) && defined(CONFIG_COMPAT)
3211 +- if (sbi->compat_daemon > 0)
3212 +- pktsz -= 4;
3213 +-#endif
3214 +- return pktsz;
3215 +-}
3216 +-
3217 ++
3218 + static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
3219 + struct autofs_wait_queue *wq,
3220 + int type)
3221 +@@ -164,7 +147,8 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
3222 + {
3223 + struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet;
3224 +
3225 +- pktsz = autofs_v5_packet_size(sbi);
3226 ++ pktsz = sizeof(*packet);
3227 ++
3228 + packet->wait_queue_token = wq->wait_queue_token;
3229 + packet->len = wq->name.len;
3230 + memcpy(packet->name, wq->name.name, wq->name.len);
3231 +diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
3232 +index 6738503..83a871f 100644
3233 +--- a/fs/btrfs/ctree.h
3234 ++++ b/fs/btrfs/ctree.h
3235 +@@ -2025,7 +2025,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
3236 +
3237 + static inline bool btrfs_root_readonly(struct btrfs_root *root)
3238 + {
3239 +- return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY;
3240 ++ return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0;
3241 + }
3242 +
3243 + /* struct btrfs_root_backup */
3244 +diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
3245 +index 0e6adac..e89803b 100644
3246 +--- a/fs/cifs/cifssmb.c
3247 ++++ b/fs/cifs/cifssmb.c
3248 +@@ -4826,8 +4826,12 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3249 + max_len = data_end - temp;
3250 + node->node_name = cifs_strndup_from_ucs(temp, max_len,
3251 + is_unicode, nls_codepage);
3252 +- if (!node->node_name)
3253 ++ if (!node->node_name) {
3254 + rc = -ENOMEM;
3255 ++ goto parse_DFS_referrals_exit;
3256 ++ }
3257 ++
3258 ++ ref++;
3259 + }
3260 +
3261 + parse_DFS_referrals_exit:
3262 +diff --git a/fs/eventpoll.c b/fs/eventpoll.c
3263 +index ea54cde..4d9d3a4 100644
3264 +--- a/fs/eventpoll.c
3265 ++++ b/fs/eventpoll.c
3266 +@@ -988,6 +988,10 @@ static int path_count[PATH_ARR_SIZE];
3267 +
3268 + static int path_count_inc(int nests)
3269 + {
3270 ++ /* Allow an arbitrary number of depth 1 paths */
3271 ++ if (nests == 0)
3272 ++ return 0;
3273 ++
3274 + if (++path_count[nests] > path_limits[nests])
3275 + return -1;
3276 + return 0;
3277 +diff --git a/fs/exec.c b/fs/exec.c
3278 +index 3625464..160cd2f 100644
3279 +--- a/fs/exec.c
3280 ++++ b/fs/exec.c
3281 +@@ -973,6 +973,9 @@ static int de_thread(struct task_struct *tsk)
3282 + sig->notify_count = 0;
3283 +
3284 + no_thread_group:
3285 ++ /* we have changed execution domain */
3286 ++ tsk->exit_signal = SIGCHLD;
3287 ++
3288 + if (current->mm)
3289 + setmax_mm_hiwater_rss(&sig->maxrss, current->mm);
3290 +
3291 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
3292 +index c2a2012..54f2bdc 100644
3293 +--- a/fs/ext4/extents.c
3294 ++++ b/fs/ext4/extents.c
3295 +@@ -2812,7 +2812,7 @@ static int ext4_split_extent_at(handle_t *handle,
3296 + if (err)
3297 + goto fix_extent_len;
3298 + /* update the extent length and mark as initialized */
3299 +- ex->ee_len = cpu_to_le32(ee_len);
3300 ++ ex->ee_len = cpu_to_le16(ee_len);
3301 + ext4_ext_try_to_merge(inode, path, ex);
3302 + err = ext4_ext_dirty(handle, inode, path + depth);
3303 + goto out;
3304 +diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
3305 +index 4dfbfec..ec2a9c2 100644
3306 +--- a/fs/hfsplus/catalog.c
3307 ++++ b/fs/hfsplus/catalog.c
3308 +@@ -366,6 +366,10 @@ int hfsplus_rename_cat(u32 cnid,
3309 + err = hfs_brec_find(&src_fd);
3310 + if (err)
3311 + goto out;
3312 ++ if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
3313 ++ err = -EIO;
3314 ++ goto out;
3315 ++ }
3316 +
3317 + hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
3318 + src_fd.entrylength);
3319 +diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
3320 +index 4536cd3..5adb740 100644
3321 +--- a/fs/hfsplus/dir.c
3322 ++++ b/fs/hfsplus/dir.c
3323 +@@ -150,6 +150,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
3324 + filp->f_pos++;
3325 + /* fall through */
3326 + case 1:
3327 ++ if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
3328 ++ err = -EIO;
3329 ++ goto out;
3330 ++ }
3331 ++
3332 + hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
3333 + fd.entrylength);
3334 + if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
3335 +@@ -181,6 +186,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
3336 + err = -EIO;
3337 + goto out;
3338 + }
3339 ++
3340 ++ if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
3341 ++ err = -EIO;
3342 ++ goto out;
3343 ++ }
3344 ++
3345 + hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
3346 + fd.entrylength);
3347 + type = be16_to_cpu(entry.type);
3348 +diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
3349 +index 68d704d..d751f04 100644
3350 +--- a/fs/jbd2/commit.c
3351 ++++ b/fs/jbd2/commit.c
3352 +@@ -683,7 +683,7 @@ start_journal_io:
3353 + if (commit_transaction->t_need_data_flush &&
3354 + (journal->j_fs_dev != journal->j_dev) &&
3355 + (journal->j_flags & JBD2_BARRIER))
3356 +- blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
3357 ++ blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL);
3358 +
3359 + /* Done it all: now write the commit record asynchronously. */
3360 + if (JBD2_HAS_INCOMPAT_FEATURE(journal,
3361 +@@ -819,7 +819,7 @@ wait_for_iobuf:
3362 + if (JBD2_HAS_INCOMPAT_FEATURE(journal,
3363 + JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) &&
3364 + journal->j_flags & JBD2_BARRIER) {
3365 +- blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL);
3366 ++ blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL);
3367 + }
3368 +
3369 + if (err)
3370 +diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c
3371 +index f848b52..046bb77 100644
3372 +--- a/fs/lockd/clnt4xdr.c
3373 ++++ b/fs/lockd/clnt4xdr.c
3374 +@@ -241,7 +241,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat)
3375 + p = xdr_inline_decode(xdr, 4);
3376 + if (unlikely(p == NULL))
3377 + goto out_overflow;
3378 +- if (unlikely(*p > nlm4_failed))
3379 ++ if (unlikely(ntohl(*p) > ntohl(nlm4_failed)))
3380 + goto out_bad_xdr;
3381 + *stat = *p;
3382 + return 0;
3383 +diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c
3384 +index 180ac34..36057ce 100644
3385 +--- a/fs/lockd/clntxdr.c
3386 ++++ b/fs/lockd/clntxdr.c
3387 +@@ -236,7 +236,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr,
3388 + p = xdr_inline_decode(xdr, 4);
3389 + if (unlikely(p == NULL))
3390 + goto out_overflow;
3391 +- if (unlikely(*p > nlm_lck_denied_grace_period))
3392 ++ if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period)))
3393 + goto out_enum;
3394 + *stat = *p;
3395 + return 0;
3396 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
3397 +index 757293b..51f6a40 100644
3398 +--- a/fs/nfs/nfs4proc.c
3399 ++++ b/fs/nfs/nfs4proc.c
3400 +@@ -4453,7 +4453,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3401 + static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
3402 + {
3403 + struct nfs_server *server = NFS_SERVER(state->inode);
3404 +- struct nfs4_exception exception = { };
3405 ++ struct nfs4_exception exception = {
3406 ++ .inode = state->inode,
3407 ++ };
3408 + int err;
3409 +
3410 + do {
3411 +@@ -4471,7 +4473,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
3412 + static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
3413 + {
3414 + struct nfs_server *server = NFS_SERVER(state->inode);
3415 +- struct nfs4_exception exception = { };
3416 ++ struct nfs4_exception exception = {
3417 ++ .inode = state->inode,
3418 ++ };
3419 + int err;
3420 +
3421 + err = nfs4_set_lock_state(state, request);
3422 +@@ -4551,6 +4555,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
3423 + {
3424 + struct nfs4_exception exception = {
3425 + .state = state,
3426 ++ .inode = state->inode,
3427 + };
3428 + int err;
3429 +
3430 +@@ -4596,6 +4601,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
3431 +
3432 + if (state == NULL)
3433 + return -ENOLCK;
3434 ++ /*
3435 ++ * Don't rely on the VFS having checked the file open mode,
3436 ++ * since it won't do this for flock() locks.
3437 ++ */
3438 ++ switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) {
3439 ++ case F_RDLCK:
3440 ++ if (!(filp->f_mode & FMODE_READ))
3441 ++ return -EBADF;
3442 ++ break;
3443 ++ case F_WRLCK:
3444 ++ if (!(filp->f_mode & FMODE_WRITE))
3445 ++ return -EBADF;
3446 ++ }
3447 ++
3448 + do {
3449 + status = nfs4_proc_setlk(state, cmd, request);
3450 + if ((status != -EAGAIN) || IS_SETLK(cmd))
3451 +diff --git a/fs/nfs/read.c b/fs/nfs/read.c
3452 +index cfa175c..41bae32 100644
3453 +--- a/fs/nfs/read.c
3454 ++++ b/fs/nfs/read.c
3455 +@@ -324,7 +324,7 @@ out_bad:
3456 + while (!list_empty(res)) {
3457 + data = list_entry(res->next, struct nfs_read_data, list);
3458 + list_del(&data->list);
3459 +- nfs_readdata_free(data);
3460 ++ nfs_readdata_release(data);
3461 + }
3462 + nfs_readpage_release(req);
3463 + return -ENOMEM;
3464 +diff --git a/fs/nfs/super.c b/fs/nfs/super.c
3465 +index 3ada13c..376cd65 100644
3466 +--- a/fs/nfs/super.c
3467 ++++ b/fs/nfs/super.c
3468 +@@ -2708,11 +2708,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
3469 + char *root_devname;
3470 + size_t len;
3471 +
3472 +- len = strlen(hostname) + 3;
3473 ++ len = strlen(hostname) + 5;
3474 + root_devname = kmalloc(len, GFP_KERNEL);
3475 + if (root_devname == NULL)
3476 + return ERR_PTR(-ENOMEM);
3477 +- snprintf(root_devname, len, "%s:/", hostname);
3478 ++ /* Does hostname needs to be enclosed in brackets? */
3479 ++ if (strchr(hostname, ':'))
3480 ++ snprintf(root_devname, len, "[%s]:/", hostname);
3481 ++ else
3482 ++ snprintf(root_devname, len, "%s:/", hostname);
3483 + root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
3484 + kfree(root_devname);
3485 + return root_mnt;
3486 +diff --git a/fs/nfs/write.c b/fs/nfs/write.c
3487 +index 1dda78d..4efd421 100644
3488 +--- a/fs/nfs/write.c
3489 ++++ b/fs/nfs/write.c
3490 +@@ -974,7 +974,7 @@ out_bad:
3491 + while (!list_empty(res)) {
3492 + data = list_entry(res->next, struct nfs_write_data, list);
3493 + list_del(&data->list);
3494 +- nfs_writedata_free(data);
3495 ++ nfs_writedata_release(data);
3496 + }
3497 + nfs_redirty_request(req);
3498 + return -ENOMEM;
3499 +diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
3500 +index 08c6e36..43f46cd 100644
3501 +--- a/fs/nfsd/nfs3xdr.c
3502 ++++ b/fs/nfsd/nfs3xdr.c
3503 +@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
3504 + return p;
3505 + }
3506 +
3507 +-static int
3508 ++static __be32
3509 + compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
3510 + const char *name, int namlen)
3511 + {
3512 + struct svc_export *exp;
3513 + struct dentry *dparent, *dchild;
3514 +- int rv = 0;
3515 ++ __be32 rv = nfserr_noent;
3516 +
3517 + dparent = cd->fh.fh_dentry;
3518 + exp = cd->fh.fh_export;
3519 +@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
3520 + if (isdotent(name, namlen)) {
3521 + if (namlen == 2) {
3522 + dchild = dget_parent(dparent);
3523 +- if (dchild == dparent) {
3524 +- /* filesystem root - cannot return filehandle for ".." */
3525 +- dput(dchild);
3526 +- return -ENOENT;
3527 +- }
3528 ++ /* filesystem root - cannot return filehandle for ".." */
3529 ++ if (dchild == dparent)
3530 ++ goto out;
3531 + } else
3532 + dchild = dget(dparent);
3533 + } else
3534 + dchild = lookup_one_len(name, dparent, namlen);
3535 + if (IS_ERR(dchild))
3536 +- return -ENOENT;
3537 +- rv = -ENOENT;
3538 ++ return rv;
3539 + if (d_mountpoint(dchild))
3540 + goto out;
3541 +- rv = fh_compose(fhp, exp, dchild, &cd->fh);
3542 +- if (rv)
3543 +- goto out;
3544 + if (!dchild->d_inode)
3545 + goto out;
3546 +- rv = 0;
3547 ++ rv = fh_compose(fhp, exp, dchild, &cd->fh);
3548 + out:
3549 + dput(dchild);
3550 + return rv;
3551 +@@ -845,7 +839,7 @@ out:
3552 + static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
3553 + {
3554 + struct svc_fh fh;
3555 +- int err;
3556 ++ __be32 err;
3557 +
3558 + fh_init(&fh, NFS3_FHSIZE);
3559 + err = compose_entry_fh(cd, &fh, name, namlen);
3560 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
3561 +index fa38336..b8c5538 100644
3562 +--- a/fs/nfsd/nfs4proc.c
3563 ++++ b/fs/nfsd/nfs4proc.c
3564 +@@ -231,17 +231,17 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
3565 + */
3566 + if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0)
3567 + open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS |
3568 +- FATTR4_WORD1_TIME_MODIFY);
3569 ++ FATTR4_WORD1_TIME_MODIFY);
3570 + } else {
3571 + status = nfsd_lookup(rqstp, current_fh,
3572 + open->op_fname.data, open->op_fname.len, &resfh);
3573 + fh_unlock(current_fh);
3574 +- if (status)
3575 +- goto out;
3576 +- status = nfsd_check_obj_isreg(&resfh);
3577 + }
3578 + if (status)
3579 + goto out;
3580 ++ status = nfsd_check_obj_isreg(&resfh);
3581 ++ if (status)
3582 ++ goto out;
3583 +
3584 + if (is_create_with_attrs(open) && open->op_acl != NULL)
3585 + do_set_nfs4_acl(rqstp, &resfh, open->op_acl, open->op_bmval);
3586 +@@ -827,6 +827,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3587 + struct nfsd4_setattr *setattr)
3588 + {
3589 + __be32 status = nfs_ok;
3590 ++ int err;
3591 +
3592 + if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
3593 + nfs4_lock_state();
3594 +@@ -838,9 +839,9 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3595 + return status;
3596 + }
3597 + }
3598 +- status = mnt_want_write(cstate->current_fh.fh_export->ex_path.mnt);
3599 +- if (status)
3600 +- return status;
3601 ++ err = mnt_want_write(cstate->current_fh.fh_export->ex_path.mnt);
3602 ++ if (err)
3603 ++ return nfserrno(err);
3604 + status = nfs_ok;
3605 +
3606 + status = check_attr_support(rqstp, cstate, setattr->sa_bmval,
3607 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
3608 +index 5abced7..4cfe260 100644
3609 +--- a/fs/nfsd/nfs4state.c
3610 ++++ b/fs/nfsd/nfs4state.c
3611 +@@ -4080,16 +4080,14 @@ out:
3612 + * vfs_test_lock. (Arguably perhaps test_lock should be done with an
3613 + * inode operation.)
3614 + */
3615 +-static int nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
3616 ++static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
3617 + {
3618 + struct file *file;
3619 +- int err;
3620 +-
3621 +- err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
3622 +- if (err)
3623 +- return err;
3624 +- err = vfs_test_lock(file, lock);
3625 +- nfsd_close(file);
3626 ++ __be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
3627 ++ if (!err) {
3628 ++ err = nfserrno(vfs_test_lock(file, lock));
3629 ++ nfsd_close(file);
3630 ++ }
3631 + return err;
3632 + }
3633 +
3634 +@@ -4103,7 +4101,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3635 + struct inode *inode;
3636 + struct file_lock file_lock;
3637 + struct nfs4_lockowner *lo;
3638 +- int error;
3639 + __be32 status;
3640 +
3641 + if (locks_in_grace())
3642 +@@ -4149,12 +4146,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3643 +
3644 + nfs4_transform_lock_offset(&file_lock);
3645 +
3646 +- status = nfs_ok;
3647 +- error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
3648 +- if (error) {
3649 +- status = nfserrno(error);
3650 ++ status = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
3651 ++ if (status)
3652 + goto out;
3653 +- }
3654 ++
3655 + if (file_lock.fl_type != F_UNLCK) {
3656 + status = nfserr_denied;
3657 + nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);
3658 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
3659 +index b6fa792..9cfa60a 100644
3660 +--- a/fs/nfsd/nfs4xdr.c
3661 ++++ b/fs/nfsd/nfs4xdr.c
3662 +@@ -3411,7 +3411,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr,
3663 + nfsd4_decode_stateid(argp, &si);
3664 + valid = nfs4_validate_stateid(cl, &si);
3665 + RESERVE_SPACE(4);
3666 +- *p++ = htonl(valid);
3667 ++ *p++ = valid;
3668 + resp->p = p;
3669 + }
3670 + nfs4_unlock_state();
3671 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
3672 +index 7a2e442..5c3cd82 100644
3673 +--- a/fs/nfsd/vfs.c
3674 ++++ b/fs/nfsd/vfs.c
3675 +@@ -1439,7 +1439,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
3676 + switch (createmode) {
3677 + case NFS3_CREATE_UNCHECKED:
3678 + if (! S_ISREG(dchild->d_inode->i_mode))
3679 +- err = nfserr_exist;
3680 ++ goto out;
3681 + else if (truncp) {
3682 + /* in nfsv4, we need to treat this case a little
3683 + * differently. we don't want to truncate the
3684 +diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
3685 +index 3165aeb..31b9463 100644
3686 +--- a/fs/ocfs2/alloc.c
3687 ++++ b/fs/ocfs2/alloc.c
3688 +@@ -1134,7 +1134,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle,
3689 + }
3690 +
3691 + el = path_leaf_el(path);
3692 +- rec = &el->l_recs[le32_to_cpu(el->l_next_free_rec) - 1];
3693 ++ rec = &el->l_recs[le16_to_cpu(el->l_next_free_rec) - 1];
3694 +
3695 + ocfs2_adjust_rightmost_records(handle, et, path, rec);
3696 +
3697 +diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
3698 +index cf78233..9f32d7c 100644
3699 +--- a/fs/ocfs2/refcounttree.c
3700 ++++ b/fs/ocfs2/refcounttree.c
3701 +@@ -1036,14 +1036,14 @@ static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci,
3702 +
3703 + tmp_el = left_path->p_node[subtree_root].el;
3704 + blkno = left_path->p_node[subtree_root+1].bh->b_blocknr;
3705 +- for (i = 0; i < le32_to_cpu(tmp_el->l_next_free_rec); i++) {
3706 ++ for (i = 0; i < le16_to_cpu(tmp_el->l_next_free_rec); i++) {
3707 + if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) {
3708 + *cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
3709 + break;
3710 + }
3711 + }
3712 +
3713 +- BUG_ON(i == le32_to_cpu(tmp_el->l_next_free_rec));
3714 ++ BUG_ON(i == le16_to_cpu(tmp_el->l_next_free_rec));
3715 +
3716 + out:
3717 + ocfs2_free_path(left_path);
3718 +@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh,
3719 +
3720 + trace_ocfs2_divide_leaf_refcount_block(
3721 + (unsigned long long)ref_leaf_bh->b_blocknr,
3722 +- le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used));
3723 ++ le16_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
3724 +
3725 + /*
3726 + * XXX: Improvement later.
3727 +@@ -2411,7 +2411,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
3728 + rb = (struct ocfs2_refcount_block *)
3729 + prev_bh->b_data;
3730 +
3731 +- if (le64_to_cpu(rb->rf_records.rl_used) +
3732 ++ if (le16_to_cpu(rb->rf_records.rl_used) +
3733 + recs_add >
3734 + le16_to_cpu(rb->rf_records.rl_count))
3735 + ref_blocks++;
3736 +@@ -2476,7 +2476,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
3737 + if (prev_bh) {
3738 + rb = (struct ocfs2_refcount_block *)prev_bh->b_data;
3739 +
3740 +- if (le64_to_cpu(rb->rf_records.rl_used) + recs_add >
3741 ++ if (le16_to_cpu(rb->rf_records.rl_used) + recs_add >
3742 + le16_to_cpu(rb->rf_records.rl_count))
3743 + ref_blocks++;
3744 +
3745 +@@ -3629,7 +3629,7 @@ int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
3746 + * one will split a refcount rec, so totally we need
3747 + * clusters * 2 new refcount rec.
3748 + */
3749 +- if (le64_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
3750 ++ if (le16_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
3751 + le16_to_cpu(rb->rf_records.rl_count))
3752 + ref_blocks++;
3753 +
3754 +diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
3755 +index ba5d97e..f169da4 100644
3756 +--- a/fs/ocfs2/suballoc.c
3757 ++++ b/fs/ocfs2/suballoc.c
3758 +@@ -600,7 +600,7 @@ static void ocfs2_bg_alloc_cleanup(handle_t *handle,
3759 + ret = ocfs2_free_clusters(handle, cluster_ac->ac_inode,
3760 + cluster_ac->ac_bh,
3761 + le64_to_cpu(rec->e_blkno),
3762 +- le32_to_cpu(rec->e_leaf_clusters));
3763 ++ le16_to_cpu(rec->e_leaf_clusters));
3764 + if (ret)
3765 + mlog_errno(ret);
3766 + /* Try all the clusters to free */
3767 +@@ -1628,7 +1628,7 @@ static int ocfs2_bg_discontig_fix_by_rec(struct ocfs2_suballoc_result *res,
3768 + {
3769 + unsigned int bpc = le16_to_cpu(cl->cl_bpc);
3770 + unsigned int bitoff = le32_to_cpu(rec->e_cpos) * bpc;
3771 +- unsigned int bitcount = le32_to_cpu(rec->e_leaf_clusters) * bpc;
3772 ++ unsigned int bitcount = le16_to_cpu(rec->e_leaf_clusters) * bpc;
3773 +
3774 + if (res->sr_bit_offset < bitoff)
3775 + return 0;
3776 +diff --git a/fs/pipe.c b/fs/pipe.c
3777 +index 4065f07..05ed5ca 100644
3778 +--- a/fs/pipe.c
3779 ++++ b/fs/pipe.c
3780 +@@ -345,6 +345,16 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
3781 + .get = generic_pipe_buf_get,
3782 + };
3783 +
3784 ++static const struct pipe_buf_operations packet_pipe_buf_ops = {
3785 ++ .can_merge = 0,
3786 ++ .map = generic_pipe_buf_map,
3787 ++ .unmap = generic_pipe_buf_unmap,
3788 ++ .confirm = generic_pipe_buf_confirm,
3789 ++ .release = anon_pipe_buf_release,
3790 ++ .steal = generic_pipe_buf_steal,
3791 ++ .get = generic_pipe_buf_get,
3792 ++};
3793 ++
3794 + static ssize_t
3795 + pipe_read(struct kiocb *iocb, const struct iovec *_iov,
3796 + unsigned long nr_segs, loff_t pos)
3797 +@@ -406,6 +416,13 @@ redo:
3798 + ret += chars;
3799 + buf->offset += chars;
3800 + buf->len -= chars;
3801 ++
3802 ++ /* Was it a packet buffer? Clean up and exit */
3803 ++ if (buf->flags & PIPE_BUF_FLAG_PACKET) {
3804 ++ total_len = chars;
3805 ++ buf->len = 0;
3806 ++ }
3807 ++
3808 + if (!buf->len) {
3809 + buf->ops = NULL;
3810 + ops->release(pipe, buf);
3811 +@@ -458,6 +475,11 @@ redo:
3812 + return ret;
3813 + }
3814 +
3815 ++static inline int is_packetized(struct file *file)
3816 ++{
3817 ++ return (file->f_flags & O_DIRECT) != 0;
3818 ++}
3819 ++
3820 + static ssize_t
3821 + pipe_write(struct kiocb *iocb, const struct iovec *_iov,
3822 + unsigned long nr_segs, loff_t ppos)
3823 +@@ -592,6 +614,11 @@ redo2:
3824 + buf->ops = &anon_pipe_buf_ops;
3825 + buf->offset = 0;
3826 + buf->len = chars;
3827 ++ buf->flags = 0;
3828 ++ if (is_packetized(filp)) {
3829 ++ buf->ops = &packet_pipe_buf_ops;
3830 ++ buf->flags = PIPE_BUF_FLAG_PACKET;
3831 ++ }
3832 + pipe->nrbufs = ++bufs;
3833 + pipe->tmp_page = NULL;
3834 +
3835 +@@ -1012,7 +1039,7 @@ struct file *create_write_pipe(int flags)
3836 + goto err_dentry;
3837 + f->f_mapping = inode->i_mapping;
3838 +
3839 +- f->f_flags = O_WRONLY | (flags & O_NONBLOCK);
3840 ++ f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
3841 + f->f_version = 0;
3842 +
3843 + return f;
3844 +@@ -1056,7 +1083,7 @@ int do_pipe_flags(int *fd, int flags)
3845 + int error;
3846 + int fdw, fdr;
3847 +
3848 +- if (flags & ~(O_CLOEXEC | O_NONBLOCK))
3849 ++ if (flags & ~(O_CLOEXEC | O_NONBLOCK | O_DIRECT))
3850 + return -EINVAL;
3851 +
3852 + fw = create_write_pipe(flags);
3853 +diff --git a/fs/splice.c b/fs/splice.c
3854 +index fa2defa..6d0dfb8 100644
3855 +--- a/fs/splice.c
3856 ++++ b/fs/splice.c
3857 +@@ -31,6 +31,7 @@
3858 + #include <linux/uio.h>
3859 + #include <linux/security.h>
3860 + #include <linux/gfp.h>
3861 ++#include <linux/socket.h>
3862 +
3863 + /*
3864 + * Attempt to steal a page from a pipe buffer. This should perhaps go into
3865 +@@ -691,7 +692,9 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe,
3866 + if (!likely(file->f_op && file->f_op->sendpage))
3867 + return -EINVAL;
3868 +
3869 +- more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
3870 ++ more = (sd->flags & SPLICE_F_MORE) ? MSG_MORE : 0;
3871 ++ if (sd->len < sd->total_len)
3872 ++ more |= MSG_SENDPAGE_NOTLAST;
3873 + return file->f_op->sendpage(file, buf->page, buf->offset,
3874 + sd->len, &pos, more);
3875 + }
3876 +diff --git a/include/asm-generic/statfs.h b/include/asm-generic/statfs.h
3877 +index 0fd28e0..c749af9 100644
3878 +--- a/include/asm-generic/statfs.h
3879 ++++ b/include/asm-generic/statfs.h
3880 +@@ -15,7 +15,7 @@ typedef __kernel_fsid_t fsid_t;
3881 + * with a 10' pole.
3882 + */
3883 + #ifndef __statfs_word
3884 +-#if BITS_PER_LONG == 64
3885 ++#if __BITS_PER_LONG == 64
3886 + #define __statfs_word long
3887 + #else
3888 + #define __statfs_word __u32
3889 +diff --git a/include/linux/efi.h b/include/linux/efi.h
3890 +index 2362a0b..1328d8c 100644
3891 +--- a/include/linux/efi.h
3892 ++++ b/include/linux/efi.h
3893 +@@ -383,7 +383,18 @@ extern int __init efi_setup_pcdp_console(char *);
3894 + #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
3895 + #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
3896 + #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
3897 +-
3898 ++#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
3899 ++#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
3900 ++#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
3901 ++#define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040
3902 ++
3903 ++#define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \
3904 ++ EFI_VARIABLE_BOOTSERVICE_ACCESS | \
3905 ++ EFI_VARIABLE_RUNTIME_ACCESS | \
3906 ++ EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
3907 ++ EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
3908 ++ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
3909 ++ EFI_VARIABLE_APPEND_WRITE)
3910 + /*
3911 + * EFI Device Path information
3912 + */
3913 +diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
3914 +index d526231..35410ef 100644
3915 +--- a/include/linux/kvm_host.h
3916 ++++ b/include/linux/kvm_host.h
3917 +@@ -562,6 +562,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
3918 +
3919 + #ifdef CONFIG_IOMMU_API
3920 + int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
3921 ++void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
3922 + int kvm_iommu_map_guest(struct kvm *kvm);
3923 + int kvm_iommu_unmap_guest(struct kvm *kvm);
3924 + int kvm_assign_device(struct kvm *kvm,
3925 +@@ -575,6 +576,11 @@ static inline int kvm_iommu_map_pages(struct kvm *kvm,
3926 + return 0;
3927 + }
3928 +
3929 ++static inline void kvm_iommu_unmap_pages(struct kvm *kvm,
3930 ++ struct kvm_memory_slot *slot)
3931 ++{
3932 ++}
3933 ++
3934 + static inline int kvm_iommu_map_guest(struct kvm *kvm)
3935 + {
3936 + return -ENODEV;
3937 +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
3938 +index a82ad4d..cbeb586 100644
3939 +--- a/include/linux/netdevice.h
3940 ++++ b/include/linux/netdevice.h
3941 +@@ -2536,8 +2536,6 @@ extern void net_disable_timestamp(void);
3942 + extern void *dev_seq_start(struct seq_file *seq, loff_t *pos);
3943 + extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
3944 + extern void dev_seq_stop(struct seq_file *seq, void *v);
3945 +-extern int dev_seq_open_ops(struct inode *inode, struct file *file,
3946 +- const struct seq_operations *ops);
3947 + #endif
3948 +
3949 + extern int netdev_class_create_file(struct class_attribute *class_attr);
3950 +diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
3951 +index 77257c9..0072a53 100644
3952 +--- a/include/linux/pipe_fs_i.h
3953 ++++ b/include/linux/pipe_fs_i.h
3954 +@@ -8,6 +8,7 @@
3955 + #define PIPE_BUF_FLAG_LRU 0x01 /* page is on the LRU */
3956 + #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */
3957 + #define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */
3958 ++#define PIPE_BUF_FLAG_PACKET 0x08 /* read() as a packet */
3959 +
3960 + /**
3961 + * struct pipe_buffer - a linux kernel pipe buffer
3962 +diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
3963 +index c6db9fb..bb1fac5 100644
3964 +--- a/include/linux/seqlock.h
3965 ++++ b/include/linux/seqlock.h
3966 +@@ -141,7 +141,7 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
3967 + unsigned ret;
3968 +
3969 + repeat:
3970 +- ret = s->sequence;
3971 ++ ret = ACCESS_ONCE(s->sequence);
3972 + if (unlikely(ret & 1)) {
3973 + cpu_relax();
3974 + goto repeat;
3975 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
3976 +index 6cf8b53..e689b47 100644
3977 +--- a/include/linux/skbuff.h
3978 ++++ b/include/linux/skbuff.h
3979 +@@ -458,6 +458,7 @@ struct sk_buff {
3980 + union {
3981 + __u32 mark;
3982 + __u32 dropcount;
3983 ++ __u32 avail_size;
3984 + };
3985 +
3986 + __u16 vlan_tci;
3987 +@@ -1326,6 +1327,18 @@ static inline int skb_tailroom(const struct sk_buff *skb)
3988 + }
3989 +
3990 + /**
3991 ++ * skb_availroom - bytes at buffer end
3992 ++ * @skb: buffer to check
3993 ++ *
3994 ++ * Return the number of bytes of free space at the tail of an sk_buff
3995 ++ * allocated by sk_stream_alloc()
3996 ++ */
3997 ++static inline int skb_availroom(const struct sk_buff *skb)
3998 ++{
3999 ++ return skb_is_nonlinear(skb) ? 0 : skb->avail_size - skb->len;
4000 ++}
4001 ++
4002 ++/**
4003 + * skb_reserve - adjust headroom
4004 + * @skb: buffer to alter
4005 + * @len: bytes to move
4006 +diff --git a/include/linux/socket.h b/include/linux/socket.h
4007 +index d0e77f6..ad919e0 100644
4008 +--- a/include/linux/socket.h
4009 ++++ b/include/linux/socket.h
4010 +@@ -265,7 +265,7 @@ struct ucred {
4011 + #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
4012 + #define MSG_MORE 0x8000 /* Sender will send more */
4013 + #define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
4014 +-
4015 ++#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
4016 + #define MSG_EOF MSG_FIN
4017 +
4018 + #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file
4019 +diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
4020 +index 03354d5..64cec8d 100644
4021 +--- a/include/linux/usb/hcd.h
4022 ++++ b/include/linux/usb/hcd.h
4023 +@@ -128,6 +128,8 @@ struct usb_hcd {
4024 + unsigned wireless:1; /* Wireless USB HCD */
4025 + unsigned authorized_default:1;
4026 + unsigned has_tt:1; /* Integrated TT in root hub */
4027 ++ unsigned broken_pci_sleep:1; /* Don't put the
4028 ++ controller in PCI-D3 for system sleep */
4029 +
4030 + int irq; /* irq allocated */
4031 + void __iomem *regs; /* device memory/io */
4032 +diff --git a/kernel/exit.c b/kernel/exit.c
4033 +index e6e01b9..5a8a66e 100644
4034 +--- a/kernel/exit.c
4035 ++++ b/kernel/exit.c
4036 +@@ -819,25 +819,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
4037 + if (group_dead)
4038 + kill_orphaned_pgrp(tsk->group_leader, NULL);
4039 +
4040 +- /* Let father know we died
4041 +- *
4042 +- * Thread signals are configurable, but you aren't going to use
4043 +- * that to send signals to arbitrary processes.
4044 +- * That stops right now.
4045 +- *
4046 +- * If the parent exec id doesn't match the exec id we saved
4047 +- * when we started then we know the parent has changed security
4048 +- * domain.
4049 +- *
4050 +- * If our self_exec id doesn't match our parent_exec_id then
4051 +- * we have changed execution domain as these two values started
4052 +- * the same after a fork.
4053 +- */
4054 +- if (thread_group_leader(tsk) && tsk->exit_signal != SIGCHLD &&
4055 +- (tsk->parent_exec_id != tsk->real_parent->self_exec_id ||
4056 +- tsk->self_exec_id != tsk->parent_exec_id))
4057 +- tsk->exit_signal = SIGCHLD;
4058 +-
4059 + if (unlikely(tsk->ptrace)) {
4060 + int sig = thread_group_leader(tsk) &&
4061 + thread_group_empty(tsk) &&
4062 +diff --git a/kernel/power/swap.c b/kernel/power/swap.c
4063 +index 11a594c..b313086 100644
4064 +--- a/kernel/power/swap.c
4065 ++++ b/kernel/power/swap.c
4066 +@@ -52,6 +52,23 @@
4067 +
4068 + #define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)
4069 +
4070 ++/*
4071 ++ * Number of free pages that are not high.
4072 ++ */
4073 ++static inline unsigned long low_free_pages(void)
4074 ++{
4075 ++ return nr_free_pages() - nr_free_highpages();
4076 ++}
4077 ++
4078 ++/*
4079 ++ * Number of pages required to be kept free while writing the image. Always
4080 ++ * half of all available low pages before the writing starts.
4081 ++ */
4082 ++static inline unsigned long reqd_free_pages(void)
4083 ++{
4084 ++ return low_free_pages() / 2;
4085 ++}
4086 ++
4087 + struct swap_map_page {
4088 + sector_t entries[MAP_PAGE_ENTRIES];
4089 + sector_t next_swap;
4090 +@@ -73,7 +90,7 @@ struct swap_map_handle {
4091 + sector_t cur_swap;
4092 + sector_t first_sector;
4093 + unsigned int k;
4094 +- unsigned long nr_free_pages, written;
4095 ++ unsigned long reqd_free_pages;
4096 + u32 crc32;
4097 + };
4098 +
4099 +@@ -317,8 +334,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
4100 + goto err_rel;
4101 + }
4102 + handle->k = 0;
4103 +- handle->nr_free_pages = nr_free_pages() >> 1;
4104 +- handle->written = 0;
4105 ++ handle->reqd_free_pages = reqd_free_pages();
4106 + handle->first_sector = handle->cur_swap;
4107 + return 0;
4108 + err_rel:
4109 +@@ -353,11 +369,11 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
4110 + handle->cur_swap = offset;
4111 + handle->k = 0;
4112 + }
4113 +- if (bio_chain && ++handle->written > handle->nr_free_pages) {
4114 ++ if (bio_chain && low_free_pages() <= handle->reqd_free_pages) {
4115 + error = hib_wait_on_bio_chain(bio_chain);
4116 + if (error)
4117 + goto out;
4118 +- handle->written = 0;
4119 ++ handle->reqd_free_pages = reqd_free_pages();
4120 + }
4121 + out:
4122 + return error;
4123 +@@ -619,7 +635,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
4124 + * Adjust number of free pages after all allocations have been done.
4125 + * We don't want to run out of pages when writing.
4126 + */
4127 +- handle->nr_free_pages = nr_free_pages() >> 1;
4128 ++ handle->reqd_free_pages = reqd_free_pages();
4129 +
4130 + /*
4131 + * Start the CRC32 thread.
4132 +diff --git a/kernel/sched.c b/kernel/sched.c
4133 +index d6b149c..299f55c 100644
4134 +--- a/kernel/sched.c
4135 ++++ b/kernel/sched.c
4136 +@@ -3538,13 +3538,10 @@ calc_load_n(unsigned long load, unsigned long exp,
4137 + * Once we've updated the global active value, we need to apply the exponential
4138 + * weights adjusted to the number of cycles missed.
4139 + */
4140 +-static void calc_global_nohz(unsigned long ticks)
4141 ++static void calc_global_nohz(void)
4142 + {
4143 + long delta, active, n;
4144 +
4145 +- if (time_before(jiffies, calc_load_update))
4146 +- return;
4147 +-
4148 + /*
4149 + * If we crossed a calc_load_update boundary, make sure to fold
4150 + * any pending idle changes, the respective CPUs might have
4151 +@@ -3556,31 +3553,25 @@ static void calc_global_nohz(unsigned long ticks)
4152 + atomic_long_add(delta, &calc_load_tasks);
4153 +
4154 + /*
4155 +- * If we were idle for multiple load cycles, apply them.
4156 ++ * It could be the one fold was all it took, we done!
4157 + */
4158 +- if (ticks >= LOAD_FREQ) {
4159 +- n = ticks / LOAD_FREQ;
4160 ++ if (time_before(jiffies, calc_load_update + 10))
4161 ++ return;
4162 +
4163 +- active = atomic_long_read(&calc_load_tasks);
4164 +- active = active > 0 ? active * FIXED_1 : 0;
4165 ++ /*
4166 ++ * Catch-up, fold however many we are behind still
4167 ++ */
4168 ++ delta = jiffies - calc_load_update - 10;
4169 ++ n = 1 + (delta / LOAD_FREQ);
4170 +
4171 +- avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
4172 +- avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
4173 +- avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
4174 ++ active = atomic_long_read(&calc_load_tasks);
4175 ++ active = active > 0 ? active * FIXED_1 : 0;
4176 +
4177 +- calc_load_update += n * LOAD_FREQ;
4178 +- }
4179 ++ avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
4180 ++ avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
4181 ++ avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
4182 +
4183 +- /*
4184 +- * Its possible the remainder of the above division also crosses
4185 +- * a LOAD_FREQ period, the regular check in calc_global_load()
4186 +- * which comes after this will take care of that.
4187 +- *
4188 +- * Consider us being 11 ticks before a cycle completion, and us
4189 +- * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
4190 +- * age us 4 cycles, and the test in calc_global_load() will
4191 +- * pick up the final one.
4192 +- */
4193 ++ calc_load_update += n * LOAD_FREQ;
4194 + }
4195 + #else
4196 + static void calc_load_account_idle(struct rq *this_rq)
4197 +@@ -3592,7 +3583,7 @@ static inline long calc_load_fold_idle(void)
4198 + return 0;
4199 + }
4200 +
4201 +-static void calc_global_nohz(unsigned long ticks)
4202 ++static void calc_global_nohz(void)
4203 + {
4204 + }
4205 + #endif
4206 +@@ -3620,8 +3611,6 @@ void calc_global_load(unsigned long ticks)
4207 + {
4208 + long active;
4209 +
4210 +- calc_global_nohz(ticks);
4211 +-
4212 + if (time_before(jiffies, calc_load_update + 10))
4213 + return;
4214 +
4215 +@@ -3633,6 +3622,16 @@ void calc_global_load(unsigned long ticks)
4216 + avenrun[2] = calc_load(avenrun[2], EXP_15, active);
4217 +
4218 + calc_load_update += LOAD_FREQ;
4219 ++
4220 ++ /*
4221 ++ * Account one period with whatever state we found before
4222 ++ * folding in the nohz state and ageing the entire idle period.
4223 ++ *
4224 ++ * This avoids loosing a sample when we go idle between
4225 ++ * calc_load_account_active() (10 ticks ago) and now and thus
4226 ++ * under-accounting.
4227 ++ */
4228 ++ calc_global_nohz();
4229 + }
4230 +
4231 + /*
4232 +@@ -7605,16 +7604,26 @@ static void __sdt_free(const struct cpumask *cpu_map)
4233 + struct sd_data *sdd = &tl->data;
4234 +
4235 + for_each_cpu(j, cpu_map) {
4236 +- struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
4237 +- if (sd && (sd->flags & SD_OVERLAP))
4238 +- free_sched_groups(sd->groups, 0);
4239 +- kfree(*per_cpu_ptr(sdd->sd, j));
4240 +- kfree(*per_cpu_ptr(sdd->sg, j));
4241 +- kfree(*per_cpu_ptr(sdd->sgp, j));
4242 ++ struct sched_domain *sd;
4243 ++
4244 ++ if (sdd->sd) {
4245 ++ sd = *per_cpu_ptr(sdd->sd, j);
4246 ++ if (sd && (sd->flags & SD_OVERLAP))
4247 ++ free_sched_groups(sd->groups, 0);
4248 ++ kfree(*per_cpu_ptr(sdd->sd, j));
4249 ++ }
4250 ++
4251 ++ if (sdd->sg)
4252 ++ kfree(*per_cpu_ptr(sdd->sg, j));
4253 ++ if (sdd->sgp)
4254 ++ kfree(*per_cpu_ptr(sdd->sgp, j));
4255 + }
4256 + free_percpu(sdd->sd);
4257 ++ sdd->sd = NULL;
4258 + free_percpu(sdd->sg);
4259 ++ sdd->sg = NULL;
4260 + free_percpu(sdd->sgp);
4261 ++ sdd->sgp = NULL;
4262 + }
4263 + }
4264 +
4265 +diff --git a/kernel/signal.c b/kernel/signal.c
4266 +index 2065515..08e0b97 100644
4267 +--- a/kernel/signal.c
4268 ++++ b/kernel/signal.c
4269 +@@ -1610,6 +1610,15 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
4270 + BUG_ON(!tsk->ptrace &&
4271 + (tsk->group_leader != tsk || !thread_group_empty(tsk)));
4272 +
4273 ++ if (sig != SIGCHLD) {
4274 ++ /*
4275 ++ * This is only possible if parent == real_parent.
4276 ++ * Check if it has changed security domain.
4277 ++ */
4278 ++ if (tsk->parent_exec_id != tsk->parent->self_exec_id)
4279 ++ sig = SIGCHLD;
4280 ++ }
4281 ++
4282 + info.si_signo = sig;
4283 + info.si_errno = 0;
4284 + /*
4285 +diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
4286 +index 5199930..1dcf253 100644
4287 +--- a/kernel/trace/trace_output.c
4288 ++++ b/kernel/trace/trace_output.c
4289 +@@ -638,6 +638,8 @@ int trace_print_lat_context(struct trace_iterator *iter)
4290 + {
4291 + u64 next_ts;
4292 + int ret;
4293 ++ /* trace_find_next_entry will reset ent_size */
4294 ++ int ent_size = iter->ent_size;
4295 + struct trace_seq *s = &iter->seq;
4296 + struct trace_entry *entry = iter->ent,
4297 + *next_entry = trace_find_next_entry(iter, NULL,
4298 +@@ -646,6 +648,9 @@ int trace_print_lat_context(struct trace_iterator *iter)
4299 + unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
4300 + unsigned long rel_usecs;
4301 +
4302 ++ /* Restore the original ent_size */
4303 ++ iter->ent_size = ent_size;
4304 ++
4305 + if (!next_entry)
4306 + next_ts = iter->ts;
4307 + rel_usecs = ns2usecs(next_ts - iter->ts);
4308 +diff --git a/mm/swap_state.c b/mm/swap_state.c
4309 +index 78cc4d1..7704d9c 100644
4310 +--- a/mm/swap_state.c
4311 ++++ b/mm/swap_state.c
4312 +@@ -27,7 +27,7 @@
4313 + */
4314 + static const struct address_space_operations swap_aops = {
4315 + .writepage = swap_writepage,
4316 +- .set_page_dirty = __set_page_dirty_nobuffers,
4317 ++ .set_page_dirty = __set_page_dirty_no_writeback,
4318 + .migratepage = migrate_page,
4319 + };
4320 +
4321 +diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
4322 +index e7c69f4..b04a6ef 100644
4323 +--- a/net/ax25/af_ax25.c
4324 ++++ b/net/ax25/af_ax25.c
4325 +@@ -2006,16 +2006,17 @@ static void __exit ax25_exit(void)
4326 + proc_net_remove(&init_net, "ax25_route");
4327 + proc_net_remove(&init_net, "ax25");
4328 + proc_net_remove(&init_net, "ax25_calls");
4329 +- ax25_rt_free();
4330 +- ax25_uid_free();
4331 +- ax25_dev_free();
4332 +
4333 +- ax25_unregister_sysctl();
4334 + unregister_netdevice_notifier(&ax25_dev_notifier);
4335 ++ ax25_unregister_sysctl();
4336 +
4337 + dev_remove_pack(&ax25_packet_type);
4338 +
4339 + sock_unregister(PF_AX25);
4340 + proto_unregister(&ax25_proto);
4341 ++
4342 ++ ax25_rt_free();
4343 ++ ax25_uid_free();
4344 ++ ax25_dev_free();
4345 + }
4346 + module_exit(ax25_exit);
4347 +diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
4348 +index 8eb6b15..5ac1811 100644
4349 +--- a/net/bridge/br_multicast.c
4350 ++++ b/net/bridge/br_multicast.c
4351 +@@ -241,7 +241,6 @@ static void br_multicast_group_expired(unsigned long data)
4352 + hlist_del_rcu(&mp->hlist[mdb->ver]);
4353 + mdb->size--;
4354 +
4355 +- del_timer(&mp->query_timer);
4356 + call_rcu_bh(&mp->rcu, br_multicast_free_group);
4357 +
4358 + out:
4359 +@@ -271,7 +270,6 @@ static void br_multicast_del_pg(struct net_bridge *br,
4360 + rcu_assign_pointer(*pp, p->next);
4361 + hlist_del_init(&p->mglist);
4362 + del_timer(&p->timer);
4363 +- del_timer(&p->query_timer);
4364 + call_rcu_bh(&p->rcu, br_multicast_free_pg);
4365 +
4366 + if (!mp->ports && !mp->mglist &&
4367 +@@ -507,74 +505,6 @@ static struct sk_buff *br_multicast_alloc_query(struct net_bridge *br,
4368 + return NULL;
4369 + }
4370 +
4371 +-static void br_multicast_send_group_query(struct net_bridge_mdb_entry *mp)
4372 +-{
4373 +- struct net_bridge *br = mp->br;
4374 +- struct sk_buff *skb;
4375 +-
4376 +- skb = br_multicast_alloc_query(br, &mp->addr);
4377 +- if (!skb)
4378 +- goto timer;
4379 +-
4380 +- netif_rx(skb);
4381 +-
4382 +-timer:
4383 +- if (++mp->queries_sent < br->multicast_last_member_count)
4384 +- mod_timer(&mp->query_timer,
4385 +- jiffies + br->multicast_last_member_interval);
4386 +-}
4387 +-
4388 +-static void br_multicast_group_query_expired(unsigned long data)
4389 +-{
4390 +- struct net_bridge_mdb_entry *mp = (void *)data;
4391 +- struct net_bridge *br = mp->br;
4392 +-
4393 +- spin_lock(&br->multicast_lock);
4394 +- if (!netif_running(br->dev) || !mp->mglist ||
4395 +- mp->queries_sent >= br->multicast_last_member_count)
4396 +- goto out;
4397 +-
4398 +- br_multicast_send_group_query(mp);
4399 +-
4400 +-out:
4401 +- spin_unlock(&br->multicast_lock);
4402 +-}
4403 +-
4404 +-static void br_multicast_send_port_group_query(struct net_bridge_port_group *pg)
4405 +-{
4406 +- struct net_bridge_port *port = pg->port;
4407 +- struct net_bridge *br = port->br;
4408 +- struct sk_buff *skb;
4409 +-
4410 +- skb = br_multicast_alloc_query(br, &pg->addr);
4411 +- if (!skb)
4412 +- goto timer;
4413 +-
4414 +- br_deliver(port, skb);
4415 +-
4416 +-timer:
4417 +- if (++pg->queries_sent < br->multicast_last_member_count)
4418 +- mod_timer(&pg->query_timer,
4419 +- jiffies + br->multicast_last_member_interval);
4420 +-}
4421 +-
4422 +-static void br_multicast_port_group_query_expired(unsigned long data)
4423 +-{
4424 +- struct net_bridge_port_group *pg = (void *)data;
4425 +- struct net_bridge_port *port = pg->port;
4426 +- struct net_bridge *br = port->br;
4427 +-
4428 +- spin_lock(&br->multicast_lock);
4429 +- if (!netif_running(br->dev) || hlist_unhashed(&pg->mglist) ||
4430 +- pg->queries_sent >= br->multicast_last_member_count)
4431 +- goto out;
4432 +-
4433 +- br_multicast_send_port_group_query(pg);
4434 +-
4435 +-out:
4436 +- spin_unlock(&br->multicast_lock);
4437 +-}
4438 +-
4439 + static struct net_bridge_mdb_entry *br_multicast_get_group(
4440 + struct net_bridge *br, struct net_bridge_port *port,
4441 + struct br_ip *group, int hash)
4442 +@@ -690,8 +620,6 @@ rehash:
4443 + mp->addr = *group;
4444 + setup_timer(&mp->timer, br_multicast_group_expired,
4445 + (unsigned long)mp);
4446 +- setup_timer(&mp->query_timer, br_multicast_group_query_expired,
4447 +- (unsigned long)mp);
4448 +
4449 + hlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]);
4450 + mdb->size++;
4451 +@@ -746,8 +674,6 @@ static int br_multicast_add_group(struct net_bridge *br,
4452 + hlist_add_head(&p->mglist, &port->mglist);
4453 + setup_timer(&p->timer, br_multicast_port_group_expired,
4454 + (unsigned long)p);
4455 +- setup_timer(&p->query_timer, br_multicast_port_group_query_expired,
4456 +- (unsigned long)p);
4457 +
4458 + rcu_assign_pointer(*pp, p);
4459 +
4460 +@@ -1291,9 +1217,6 @@ static void br_multicast_leave_group(struct net_bridge *br,
4461 + time_after(mp->timer.expires, time) :
4462 + try_to_del_timer_sync(&mp->timer) >= 0)) {
4463 + mod_timer(&mp->timer, time);
4464 +-
4465 +- mp->queries_sent = 0;
4466 +- mod_timer(&mp->query_timer, now);
4467 + }
4468 +
4469 + goto out;
4470 +@@ -1310,9 +1233,6 @@ static void br_multicast_leave_group(struct net_bridge *br,
4471 + time_after(p->timer.expires, time) :
4472 + try_to_del_timer_sync(&p->timer) >= 0)) {
4473 + mod_timer(&p->timer, time);
4474 +-
4475 +- p->queries_sent = 0;
4476 +- mod_timer(&p->query_timer, now);
4477 + }
4478 +
4479 + break;
4480 +@@ -1680,7 +1600,6 @@ void br_multicast_stop(struct net_bridge *br)
4481 + hlist_for_each_entry_safe(mp, p, n, &mdb->mhash[i],
4482 + hlist[ver]) {
4483 + del_timer(&mp->timer);
4484 +- del_timer(&mp->query_timer);
4485 + call_rcu_bh(&mp->rcu, br_multicast_free_group);
4486 + }
4487 + }
4488 +diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
4489 +index d7d6fb0..93264df 100644
4490 +--- a/net/bridge/br_private.h
4491 ++++ b/net/bridge/br_private.h
4492 +@@ -82,9 +82,7 @@ struct net_bridge_port_group {
4493 + struct hlist_node mglist;
4494 + struct rcu_head rcu;
4495 + struct timer_list timer;
4496 +- struct timer_list query_timer;
4497 + struct br_ip addr;
4498 +- u32 queries_sent;
4499 + };
4500 +
4501 + struct net_bridge_mdb_entry
4502 +@@ -94,10 +92,8 @@ struct net_bridge_mdb_entry
4503 + struct net_bridge_port_group __rcu *ports;
4504 + struct rcu_head rcu;
4505 + struct timer_list timer;
4506 +- struct timer_list query_timer;
4507 + struct br_ip addr;
4508 + bool mglist;
4509 +- u32 queries_sent;
4510 + };
4511 +
4512 + struct net_bridge_mdb_htable
4513 +diff --git a/net/core/dev.c b/net/core/dev.c
4514 +index 55cd370..cd5050e 100644
4515 +--- a/net/core/dev.c
4516 ++++ b/net/core/dev.c
4517 +@@ -4102,54 +4102,41 @@ static int dev_ifconf(struct net *net, char __user *arg)
4518 +
4519 + #ifdef CONFIG_PROC_FS
4520 +
4521 +-#define BUCKET_SPACE (32 - NETDEV_HASHBITS)
4522 +-
4523 +-struct dev_iter_state {
4524 +- struct seq_net_private p;
4525 +- unsigned int pos; /* bucket << BUCKET_SPACE + offset */
4526 +-};
4527 ++#define BUCKET_SPACE (32 - NETDEV_HASHBITS - 1)
4528 +
4529 + #define get_bucket(x) ((x) >> BUCKET_SPACE)
4530 + #define get_offset(x) ((x) & ((1 << BUCKET_SPACE) - 1))
4531 + #define set_bucket_offset(b, o) ((b) << BUCKET_SPACE | (o))
4532 +
4533 +-static inline struct net_device *dev_from_same_bucket(struct seq_file *seq)
4534 ++static inline struct net_device *dev_from_same_bucket(struct seq_file *seq, loff_t *pos)
4535 + {
4536 +- struct dev_iter_state *state = seq->private;
4537 + struct net *net = seq_file_net(seq);
4538 + struct net_device *dev;
4539 + struct hlist_node *p;
4540 + struct hlist_head *h;
4541 +- unsigned int count, bucket, offset;
4542 ++ unsigned int count = 0, offset = get_offset(*pos);
4543 +
4544 +- bucket = get_bucket(state->pos);
4545 +- offset = get_offset(state->pos);
4546 +- h = &net->dev_name_head[bucket];
4547 +- count = 0;
4548 ++ h = &net->dev_name_head[get_bucket(*pos)];
4549 + hlist_for_each_entry_rcu(dev, p, h, name_hlist) {
4550 +- if (count++ == offset) {
4551 +- state->pos = set_bucket_offset(bucket, count);
4552 ++ if (++count == offset)
4553 + return dev;
4554 +- }
4555 + }
4556 +
4557 + return NULL;
4558 + }
4559 +
4560 +-static inline struct net_device *dev_from_new_bucket(struct seq_file *seq)
4561 ++static inline struct net_device *dev_from_bucket(struct seq_file *seq, loff_t *pos)
4562 + {
4563 +- struct dev_iter_state *state = seq->private;
4564 + struct net_device *dev;
4565 + unsigned int bucket;
4566 +
4567 +- bucket = get_bucket(state->pos);
4568 + do {
4569 +- dev = dev_from_same_bucket(seq);
4570 ++ dev = dev_from_same_bucket(seq, pos);
4571 + if (dev)
4572 + return dev;
4573 +
4574 +- bucket++;
4575 +- state->pos = set_bucket_offset(bucket, 0);
4576 ++ bucket = get_bucket(*pos) + 1;
4577 ++ *pos = set_bucket_offset(bucket, 1);
4578 + } while (bucket < NETDEV_HASHENTRIES);
4579 +
4580 + return NULL;
4581 +@@ -4162,33 +4149,20 @@ static inline struct net_device *dev_from_new_bucket(struct seq_file *seq)
4582 + void *dev_seq_start(struct seq_file *seq, loff_t *pos)
4583 + __acquires(RCU)
4584 + {
4585 +- struct dev_iter_state *state = seq->private;
4586 +-
4587 + rcu_read_lock();
4588 + if (!*pos)
4589 + return SEQ_START_TOKEN;
4590 +
4591 +- /* check for end of the hash */
4592 +- if (state->pos == 0 && *pos > 1)
4593 ++ if (get_bucket(*pos) >= NETDEV_HASHENTRIES)
4594 + return NULL;
4595 +
4596 +- return dev_from_new_bucket(seq);
4597 ++ return dev_from_bucket(seq, pos);
4598 + }
4599 +
4600 + void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
4601 + {
4602 +- struct net_device *dev;
4603 +-
4604 + ++*pos;
4605 +-
4606 +- if (v == SEQ_START_TOKEN)
4607 +- return dev_from_new_bucket(seq);
4608 +-
4609 +- dev = dev_from_same_bucket(seq);
4610 +- if (dev)
4611 +- return dev;
4612 +-
4613 +- return dev_from_new_bucket(seq);
4614 ++ return dev_from_bucket(seq, pos);
4615 + }
4616 +
4617 + void dev_seq_stop(struct seq_file *seq, void *v)
4618 +@@ -4287,13 +4261,7 @@ static const struct seq_operations dev_seq_ops = {
4619 + static int dev_seq_open(struct inode *inode, struct file *file)
4620 + {
4621 + return seq_open_net(inode, file, &dev_seq_ops,
4622 +- sizeof(struct dev_iter_state));
4623 +-}
4624 +-
4625 +-int dev_seq_open_ops(struct inode *inode, struct file *file,
4626 +- const struct seq_operations *ops)
4627 +-{
4628 +- return seq_open_net(inode, file, ops, sizeof(struct dev_iter_state));
4629 ++ sizeof(struct seq_net_private));
4630 + }
4631 +
4632 + static const struct file_operations dev_seq_fops = {
4633 +diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
4634 +index febba51..277faef 100644
4635 +--- a/net/core/dev_addr_lists.c
4636 ++++ b/net/core/dev_addr_lists.c
4637 +@@ -696,7 +696,8 @@ static const struct seq_operations dev_mc_seq_ops = {
4638 +
4639 + static int dev_mc_seq_open(struct inode *inode, struct file *file)
4640 + {
4641 +- return dev_seq_open_ops(inode, file, &dev_mc_seq_ops);
4642 ++ return seq_open_net(inode, file, &dev_mc_seq_ops,
4643 ++ sizeof(struct seq_net_private));
4644 + }
4645 +
4646 + static const struct file_operations dev_mc_seq_fops = {
4647 +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
4648 +index 0e950fd..31a5ae5 100644
4649 +--- a/net/core/net_namespace.c
4650 ++++ b/net/core/net_namespace.c
4651 +@@ -83,21 +83,29 @@ assign:
4652 +
4653 + static int ops_init(const struct pernet_operations *ops, struct net *net)
4654 + {
4655 +- int err;
4656 ++ int err = -ENOMEM;
4657 ++ void *data = NULL;
4658 ++
4659 + if (ops->id && ops->size) {
4660 +- void *data = kzalloc(ops->size, GFP_KERNEL);
4661 ++ data = kzalloc(ops->size, GFP_KERNEL);
4662 + if (!data)
4663 +- return -ENOMEM;
4664 ++ goto out;
4665 +
4666 + err = net_assign_generic(net, *ops->id, data);
4667 +- if (err) {
4668 +- kfree(data);
4669 +- return err;
4670 +- }
4671 ++ if (err)
4672 ++ goto cleanup;
4673 + }
4674 ++ err = 0;
4675 + if (ops->init)
4676 +- return ops->init(net);
4677 +- return 0;
4678 ++ err = ops->init(net);
4679 ++ if (!err)
4680 ++ return 0;
4681 ++
4682 ++cleanup:
4683 ++ kfree(data);
4684 ++
4685 ++out:
4686 ++ return err;
4687 + }
4688 +
4689 + static void ops_free(const struct pernet_operations *ops, struct net *net)
4690 +@@ -448,12 +456,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
4691 + static int __register_pernet_operations(struct list_head *list,
4692 + struct pernet_operations *ops)
4693 + {
4694 +- int err = 0;
4695 +- err = ops_init(ops, &init_net);
4696 +- if (err)
4697 +- ops_free(ops, &init_net);
4698 +- return err;
4699 +-
4700 ++ return ops_init(ops, &init_net);
4701 + }
4702 +
4703 + static void __unregister_pernet_operations(struct pernet_operations *ops)
4704 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
4705 +index 3c30ee4..2ec200de 100644
4706 +--- a/net/core/skbuff.c
4707 ++++ b/net/core/skbuff.c
4708 +@@ -903,9 +903,11 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
4709 + goto adjust_others;
4710 + }
4711 +
4712 +- data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
4713 ++ data = kmalloc(size + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
4714 ++ gfp_mask);
4715 + if (!data)
4716 + goto nodata;
4717 ++ size = SKB_WITH_OVERHEAD(ksize(data));
4718 +
4719 + /* Copy only real data... and, alas, header. This should be
4720 + * optimized for the cases when header is void.
4721 +@@ -3111,6 +3113,8 @@ static void sock_rmem_free(struct sk_buff *skb)
4722 + */
4723 + int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
4724 + {
4725 ++ int len = skb->len;
4726 ++
4727 + if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
4728 + (unsigned)sk->sk_rcvbuf)
4729 + return -ENOMEM;
4730 +@@ -3125,7 +3129,7 @@ int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
4731 +
4732 + skb_queue_tail(&sk->sk_error_queue, skb);
4733 + if (!sock_flag(sk, SOCK_DEAD))
4734 +- sk->sk_data_ready(sk, skb->len);
4735 ++ sk->sk_data_ready(sk, len);
4736 + return 0;
4737 + }
4738 + EXPORT_SYMBOL(sock_queue_err_skb);
4739 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
4740 +index 34f5db1..7904db4 100644
4741 +--- a/net/ipv4/tcp.c
4742 ++++ b/net/ipv4/tcp.c
4743 +@@ -701,11 +701,12 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp)
4744 + skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);
4745 + if (skb) {
4746 + if (sk_wmem_schedule(sk, skb->truesize)) {
4747 ++ skb_reserve(skb, sk->sk_prot->max_header);
4748 + /*
4749 + * Make sure that we have exactly size bytes
4750 + * available to the caller, no more, no less.
4751 + */
4752 +- skb_reserve(skb, skb_tailroom(skb) - size);
4753 ++ skb->avail_size = size;
4754 + return skb;
4755 + }
4756 + __kfree_skb(skb);
4757 +@@ -860,7 +861,7 @@ wait_for_memory:
4758 + }
4759 +
4760 + out:
4761 +- if (copied)
4762 ++ if (copied && !(flags & MSG_SENDPAGE_NOTLAST))
4763 + tcp_push(sk, flags, mss_now, tp->nonagle);
4764 + return copied;
4765 +
4766 +@@ -995,10 +996,9 @@ new_segment:
4767 + copy = seglen;
4768 +
4769 + /* Where to copy to? */
4770 +- if (skb_tailroom(skb) > 0) {
4771 ++ if (skb_availroom(skb) > 0) {
4772 + /* We have some space in skb head. Superb! */
4773 +- if (copy > skb_tailroom(skb))
4774 +- copy = skb_tailroom(skb);
4775 ++ copy = min_t(int, copy, skb_availroom(skb));
4776 + err = skb_add_data_nocache(sk, skb, from, copy);
4777 + if (err)
4778 + goto do_fault;
4779 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
4780 +index e4d1e4a..daedc07 100644
4781 +--- a/net/ipv4/tcp_input.c
4782 ++++ b/net/ipv4/tcp_input.c
4783 +@@ -334,6 +334,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)
4784 + incr = __tcp_grow_window(sk, skb);
4785 +
4786 + if (incr) {
4787 ++ incr = max_t(int, incr, 2 * skb->len);
4788 + tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr,
4789 + tp->window_clamp);
4790 + inet_csk(sk)->icsk_ack.quick |= 1;
4791 +@@ -473,8 +474,11 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
4792 + if (!win_dep) {
4793 + m -= (new_sample >> 3);
4794 + new_sample += m;
4795 +- } else if (m < new_sample)
4796 +- new_sample = m << 3;
4797 ++ } else {
4798 ++ m <<= 3;
4799 ++ if (m < new_sample)
4800 ++ new_sample = m;
4801 ++ }
4802 + } else {
4803 + /* No previous measure. */
4804 + new_sample = m << 3;
4805 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
4806 +index 097e0c7..c51dd5b 100644
4807 +--- a/net/ipv4/tcp_output.c
4808 ++++ b/net/ipv4/tcp_output.c
4809 +@@ -1093,6 +1093,14 @@ static void __pskb_trim_head(struct sk_buff *skb, int len)
4810 + {
4811 + int i, k, eat;
4812 +
4813 ++ eat = min_t(int, len, skb_headlen(skb));
4814 ++ if (eat) {
4815 ++ __skb_pull(skb, eat);
4816 ++ skb->avail_size -= eat;
4817 ++ len -= eat;
4818 ++ if (!len)
4819 ++ return;
4820 ++ }
4821 + eat = len;
4822 + k = 0;
4823 + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
4824 +@@ -1124,11 +1132,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
4825 + if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
4826 + return -ENOMEM;
4827 +
4828 +- /* If len == headlen, we avoid __skb_pull to preserve alignment. */
4829 +- if (unlikely(len < skb_headlen(skb)))
4830 +- __skb_pull(skb, len);
4831 +- else
4832 +- __pskb_trim_head(skb, len - skb_headlen(skb));
4833 ++ __pskb_trim_head(skb, len);
4834 +
4835 + TCP_SKB_CB(skb)->seq += len;
4836 + skb->ip_summed = CHECKSUM_PARTIAL;
4837 +@@ -2057,7 +2061,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
4838 + /* Punt if not enough space exists in the first SKB for
4839 + * the data in the second
4840 + */
4841 +- if (skb->len > skb_tailroom(to))
4842 ++ if (skb->len > skb_availroom(to))
4843 + break;
4844 +
4845 + if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp)))
4846 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
4847 +index 2257366..f2d74ea 100644
4848 +--- a/net/ipv6/mcast.c
4849 ++++ b/net/ipv6/mcast.c
4850 +@@ -2054,7 +2054,7 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,
4851 + if (!delta)
4852 + pmc->mca_sfcount[sfmode]--;
4853 + for (j=0; j<i; j++)
4854 +- (void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
4855 ++ ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
4856 + } else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) {
4857 + struct ip6_sf_list *psf;
4858 +
4859 +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
4860 +index b859e4a..4a56574 100644
4861 +--- a/net/ipv6/tcp_ipv6.c
4862 ++++ b/net/ipv6/tcp_ipv6.c
4863 +@@ -1494,6 +1494,10 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
4864 + tcp_mtup_init(newsk);
4865 + tcp_sync_mss(newsk, dst_mtu(dst));
4866 + newtp->advmss = dst_metric_advmss(dst);
4867 ++ if (tcp_sk(sk)->rx_opt.user_mss &&
4868 ++ tcp_sk(sk)->rx_opt.user_mss < newtp->advmss)
4869 ++ newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
4870 ++
4871 + tcp_initialize_rcv_mss(newsk);
4872 + if (tcp_rsk(req)->snt_synack)
4873 + tcp_valid_rtt_meas(newsk,
4874 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
4875 +index eff1f4e..4ff35bf 100644
4876 +--- a/net/mac80211/tx.c
4877 ++++ b/net/mac80211/tx.c
4878 +@@ -1121,7 +1121,8 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
4879 + tx->sta = rcu_dereference(sdata->u.vlan.sta);
4880 + if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
4881 + return TX_DROP;
4882 +- } else if (info->flags & IEEE80211_TX_CTL_INJECTED) {
4883 ++ } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
4884 ++ tx->sdata->control_port_protocol == tx->skb->protocol) {
4885 + tx->sta = sta_info_get_bss(sdata, hdr->addr1);
4886 + }
4887 + if (!tx->sta)
4888 +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
4889 +index 1201b6d..a99fb41 100644
4890 +--- a/net/netlink/af_netlink.c
4891 ++++ b/net/netlink/af_netlink.c
4892 +@@ -830,12 +830,19 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
4893 + return 0;
4894 + }
4895 +
4896 +-int netlink_sendskb(struct sock *sk, struct sk_buff *skb)
4897 ++static int __netlink_sendskb(struct sock *sk, struct sk_buff *skb)
4898 + {
4899 + int len = skb->len;
4900 +
4901 + skb_queue_tail(&sk->sk_receive_queue, skb);
4902 + sk->sk_data_ready(sk, len);
4903 ++ return len;
4904 ++}
4905 ++
4906 ++int netlink_sendskb(struct sock *sk, struct sk_buff *skb)
4907 ++{
4908 ++ int len = __netlink_sendskb(sk, skb);
4909 ++
4910 + sock_put(sk);
4911 + return len;
4912 + }
4913 +@@ -960,8 +967,7 @@ static inline int netlink_broadcast_deliver(struct sock *sk,
4914 + if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
4915 + !test_bit(0, &nlk->state)) {
4916 + skb_set_owner_r(skb, sk);
4917 +- skb_queue_tail(&sk->sk_receive_queue, skb);
4918 +- sk->sk_data_ready(sk, skb->len);
4919 ++ __netlink_sendskb(sk, skb);
4920 + return atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf;
4921 + }
4922 + return -1;
4923 +@@ -1684,10 +1690,8 @@ static int netlink_dump(struct sock *sk)
4924 +
4925 + if (sk_filter(sk, skb))
4926 + kfree_skb(skb);
4927 +- else {
4928 +- skb_queue_tail(&sk->sk_receive_queue, skb);
4929 +- sk->sk_data_ready(sk, skb->len);
4930 +- }
4931 ++ else
4932 ++ __netlink_sendskb(sk, skb);
4933 + return 0;
4934 + }
4935 +
4936 +@@ -1701,10 +1705,8 @@ static int netlink_dump(struct sock *sk)
4937 +
4938 + if (sk_filter(sk, skb))
4939 + kfree_skb(skb);
4940 +- else {
4941 +- skb_queue_tail(&sk->sk_receive_queue, skb);
4942 +- sk->sk_data_ready(sk, skb->len);
4943 +- }
4944 ++ else
4945 ++ __netlink_sendskb(sk, skb);
4946 +
4947 + if (cb->done)
4948 + cb->done(cb);
4949 +diff --git a/net/phonet/pep.c b/net/phonet/pep.c
4950 +index 2ba6e9f..007546d 100644
4951 +--- a/net/phonet/pep.c
4952 ++++ b/net/phonet/pep.c
4953 +@@ -1046,6 +1046,9 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk,
4954 + int flags = msg->msg_flags;
4955 + int err, done;
4956 +
4957 ++ if (len > USHRT_MAX)
4958 ++ return -EMSGSIZE;
4959 ++
4960 + if ((msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL|
4961 + MSG_CMSG_COMPAT)) ||
4962 + !(msg->msg_flags & MSG_EOR))
4963 +diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
4964 +index 6cd8ddf..e1afe0c 100644
4965 +--- a/net/sched/sch_gred.c
4966 ++++ b/net/sched/sch_gred.c
4967 +@@ -544,11 +544,8 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
4968 + opt.packets = q->packetsin;
4969 + opt.bytesin = q->bytesin;
4970 +
4971 +- if (gred_wred_mode(table)) {
4972 +- q->parms.qidlestart =
4973 +- table->tab[table->def]->parms.qidlestart;
4974 +- q->parms.qavg = table->tab[table->def]->parms.qavg;
4975 +- }
4976 ++ if (gred_wred_mode(table))
4977 ++ gred_load_wred_set(table, q);
4978 +
4979 + opt.qave = red_calc_qavg(&q->parms, q->parms.qavg);
4980 +
4981 +diff --git a/net/sctp/socket.c b/net/sctp/socket.c
4982 +index 54a7cd2..0075554 100644
4983 +--- a/net/sctp/socket.c
4984 ++++ b/net/sctp/socket.c
4985 +@@ -4133,9 +4133,10 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
4986 + static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
4987 + int __user *optlen)
4988 + {
4989 +- if (len < sizeof(struct sctp_event_subscribe))
4990 ++ if (len <= 0)
4991 + return -EINVAL;
4992 +- len = sizeof(struct sctp_event_subscribe);
4993 ++ if (len > sizeof(struct sctp_event_subscribe))
4994 ++ len = sizeof(struct sctp_event_subscribe);
4995 + if (put_user(len, optlen))
4996 + return -EFAULT;
4997 + if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
4998 +diff --git a/net/socket.c b/net/socket.c
4999 +index 2dce67a..273cbce 100644
5000 +--- a/net/socket.c
5001 ++++ b/net/socket.c
5002 +@@ -791,9 +791,9 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
5003 +
5004 + sock = file->private_data;
5005 +
5006 +- flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT;
5007 +- if (more)
5008 +- flags |= MSG_MORE;
5009 ++ flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0;
5010 ++ /* more is a combination of MSG_MORE and MSG_SENDPAGE_NOTLAST */
5011 ++ flags |= more;
5012 +
5013 + return kernel_sendpage(sock, page, offset, size, flags);
5014 + }
5015 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
5016 +index ffafda5..c06c365 100644
5017 +--- a/net/wireless/nl80211.c
5018 ++++ b/net/wireless/nl80211.c
5019 +@@ -1258,6 +1258,11 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
5020 + goto bad_res;
5021 + }
5022 +
5023 ++ if (!netif_running(netdev)) {
5024 ++ result = -ENETDOWN;
5025 ++ goto bad_res;
5026 ++ }
5027 ++
5028 + nla_for_each_nested(nl_txq_params,
5029 + info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
5030 + rem_txq_params) {
5031 +@@ -5944,7 +5949,7 @@ static struct genl_ops nl80211_ops[] = {
5032 + .doit = nl80211_get_key,
5033 + .policy = nl80211_policy,
5034 + .flags = GENL_ADMIN_PERM,
5035 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5036 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5037 + NL80211_FLAG_NEED_RTNL,
5038 + },
5039 + {
5040 +@@ -5976,7 +5981,7 @@ static struct genl_ops nl80211_ops[] = {
5041 + .policy = nl80211_policy,
5042 + .flags = GENL_ADMIN_PERM,
5043 + .doit = nl80211_addset_beacon,
5044 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5045 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5046 + NL80211_FLAG_NEED_RTNL,
5047 + },
5048 + {
5049 +@@ -5984,7 +5989,7 @@ static struct genl_ops nl80211_ops[] = {
5050 + .policy = nl80211_policy,
5051 + .flags = GENL_ADMIN_PERM,
5052 + .doit = nl80211_addset_beacon,
5053 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5054 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5055 + NL80211_FLAG_NEED_RTNL,
5056 + },
5057 + {
5058 +@@ -6008,7 +6013,7 @@ static struct genl_ops nl80211_ops[] = {
5059 + .doit = nl80211_set_station,
5060 + .policy = nl80211_policy,
5061 + .flags = GENL_ADMIN_PERM,
5062 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5063 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5064 + NL80211_FLAG_NEED_RTNL,
5065 + },
5066 + {
5067 +@@ -6024,7 +6029,7 @@ static struct genl_ops nl80211_ops[] = {
5068 + .doit = nl80211_del_station,
5069 + .policy = nl80211_policy,
5070 + .flags = GENL_ADMIN_PERM,
5071 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5072 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5073 + NL80211_FLAG_NEED_RTNL,
5074 + },
5075 + {
5076 +@@ -6057,7 +6062,7 @@ static struct genl_ops nl80211_ops[] = {
5077 + .doit = nl80211_del_mpath,
5078 + .policy = nl80211_policy,
5079 + .flags = GENL_ADMIN_PERM,
5080 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5081 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5082 + NL80211_FLAG_NEED_RTNL,
5083 + },
5084 + {
5085 +@@ -6065,7 +6070,7 @@ static struct genl_ops nl80211_ops[] = {
5086 + .doit = nl80211_set_bss,
5087 + .policy = nl80211_policy,
5088 + .flags = GENL_ADMIN_PERM,
5089 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5090 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5091 + NL80211_FLAG_NEED_RTNL,
5092 + },
5093 + {
5094 +@@ -6091,7 +6096,7 @@ static struct genl_ops nl80211_ops[] = {
5095 + .doit = nl80211_get_mesh_config,
5096 + .policy = nl80211_policy,
5097 + /* can be retrieved by unprivileged users */
5098 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5099 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5100 + NL80211_FLAG_NEED_RTNL,
5101 + },
5102 + {
5103 +@@ -6224,7 +6229,7 @@ static struct genl_ops nl80211_ops[] = {
5104 + .doit = nl80211_setdel_pmksa,
5105 + .policy = nl80211_policy,
5106 + .flags = GENL_ADMIN_PERM,
5107 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5108 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5109 + NL80211_FLAG_NEED_RTNL,
5110 + },
5111 + {
5112 +@@ -6232,7 +6237,7 @@ static struct genl_ops nl80211_ops[] = {
5113 + .doit = nl80211_setdel_pmksa,
5114 + .policy = nl80211_policy,
5115 + .flags = GENL_ADMIN_PERM,
5116 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5117 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5118 + NL80211_FLAG_NEED_RTNL,
5119 + },
5120 + {
5121 +@@ -6240,7 +6245,7 @@ static struct genl_ops nl80211_ops[] = {
5122 + .doit = nl80211_flush_pmksa,
5123 + .policy = nl80211_policy,
5124 + .flags = GENL_ADMIN_PERM,
5125 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5126 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5127 + NL80211_FLAG_NEED_RTNL,
5128 + },
5129 + {
5130 +@@ -6328,7 +6333,7 @@ static struct genl_ops nl80211_ops[] = {
5131 + .doit = nl80211_set_wds_peer,
5132 + .policy = nl80211_policy,
5133 + .flags = GENL_ADMIN_PERM,
5134 +- .internal_flags = NL80211_FLAG_NEED_NETDEV |
5135 ++ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
5136 + NL80211_FLAG_NEED_RTNL,
5137 + },
5138 + {
5139 +diff --git a/net/wireless/util.c b/net/wireless/util.c
5140 +index 4dde429..8bf8902 100644
5141 +--- a/net/wireless/util.c
5142 ++++ b/net/wireless/util.c
5143 +@@ -996,7 +996,7 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
5144 + if (rdev->wiphy.software_iftypes & BIT(iftype))
5145 + continue;
5146 + for (j = 0; j < c->n_limits; j++) {
5147 +- if (!(limits[j].types & iftype))
5148 ++ if (!(limits[j].types & BIT(iftype)))
5149 + continue;
5150 + if (limits[j].max < num[iftype])
5151 + goto cont;
5152 +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
5153 +index f936d1f..d1d0ae8 100644
5154 +--- a/scripts/mod/file2alias.c
5155 ++++ b/scripts/mod/file2alias.c
5156 +@@ -926,6 +926,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
5157 + if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)
5158 + return;
5159 +
5160 ++ /* We're looking for an object */
5161 ++ if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
5162 ++ return;
5163 ++
5164 + /* Handle all-NULL symbols allocated into .bss */
5165 + if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) {
5166 + zeros = calloc(1, sym->st_size);
5167 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
5168 +index ae94929..51a1afc 100644
5169 +--- a/sound/pci/hda/patch_conexant.c
5170 ++++ b/sound/pci/hda/patch_conexant.c
5171 +@@ -4003,9 +4003,14 @@ static void cx_auto_init_output(struct hda_codec *codec)
5172 + int i;
5173 +
5174 + mute_outputs(codec, spec->multiout.num_dacs, spec->multiout.dac_nids);
5175 +- for (i = 0; i < cfg->hp_outs; i++)
5176 ++ for (i = 0; i < cfg->hp_outs; i++) {
5177 ++ unsigned int val = PIN_OUT;
5178 ++ if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) &
5179 ++ AC_PINCAP_HP_DRV)
5180 ++ val |= AC_PINCTL_HP_EN;
5181 + snd_hda_codec_write(codec, cfg->hp_pins[i], 0,
5182 +- AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5183 ++ AC_VERB_SET_PIN_WIDGET_CONTROL, val);
5184 ++ }
5185 + mute_outputs(codec, cfg->hp_outs, cfg->hp_pins);
5186 + mute_outputs(codec, cfg->line_outs, cfg->line_out_pins);
5187 + mute_outputs(codec, cfg->speaker_outs, cfg->speaker_pins);
5188 +@@ -4408,8 +4413,10 @@ static void apply_pin_fixup(struct hda_codec *codec,
5189 +
5190 + enum {
5191 + CXT_PINCFG_LENOVO_X200,
5192 ++ CXT_PINCFG_LENOVO_TP410,
5193 + };
5194 +
5195 ++/* ThinkPad X200 & co with cxt5051 */
5196 + static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = {
5197 + { 0x16, 0x042140ff }, /* HP (seq# overridden) */
5198 + { 0x17, 0x21a11000 }, /* dock-mic */
5199 +@@ -4417,15 +4424,33 @@ static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = {
5200 + {}
5201 + };
5202 +
5203 ++/* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
5204 ++static const struct cxt_pincfg cxt_pincfg_lenovo_tp410[] = {
5205 ++ { 0x19, 0x042110ff }, /* HP (seq# overridden) */
5206 ++ { 0x1a, 0x21a190f0 }, /* dock-mic */
5207 ++ { 0x1c, 0x212140ff }, /* dock-HP */
5208 ++ {}
5209 ++};
5210 ++
5211 + static const struct cxt_pincfg *cxt_pincfg_tbl[] = {
5212 + [CXT_PINCFG_LENOVO_X200] = cxt_pincfg_lenovo_x200,
5213 ++ [CXT_PINCFG_LENOVO_TP410] = cxt_pincfg_lenovo_tp410,
5214 + };
5215 +
5216 +-static const struct snd_pci_quirk cxt_fixups[] = {
5217 ++static const struct snd_pci_quirk cxt5051_fixups[] = {
5218 + SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
5219 + {}
5220 + };
5221 +
5222 ++static const struct snd_pci_quirk cxt5066_fixups[] = {
5223 ++ SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
5224 ++ SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
5225 ++ SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
5226 ++ SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
5227 ++ SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
5228 ++ {}
5229 ++};
5230 ++
5231 + /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
5232 + * can be created (bko#42825)
5233 + */
5234 +@@ -4462,11 +4487,13 @@ static int patch_conexant_auto(struct hda_codec *codec)
5235 + break;
5236 + case 0x14f15051:
5237 + add_cx5051_fake_mutes(codec);
5238 ++ apply_pin_fixup(codec, cxt5051_fixups, cxt_pincfg_tbl);
5239 ++ break;
5240 ++ default:
5241 ++ apply_pin_fixup(codec, cxt5066_fixups, cxt_pincfg_tbl);
5242 + break;
5243 + }
5244 +
5245 +- apply_pin_fixup(codec, cxt_fixups, cxt_pincfg_tbl);
5246 +-
5247 + err = cx_auto_search_adcs(codec);
5248 + if (err < 0)
5249 + return err;
5250 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5251 +index dc8a6fc..0bc5a46 100644
5252 +--- a/sound/pci/hda/patch_realtek.c
5253 ++++ b/sound/pci/hda/patch_realtek.c
5254 +@@ -5032,6 +5032,7 @@ static const struct alc_fixup alc269_fixups[] = {
5255 + };
5256 +
5257 + static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5258 ++ SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
5259 + SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
5260 + SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
5261 + SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
5262 +diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
5263 +index 336de8f..0e7e26e 100644
5264 +--- a/sound/soc/codecs/tlv320aic23.c
5265 ++++ b/sound/soc/codecs/tlv320aic23.c
5266 +@@ -473,7 +473,7 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai,
5267 + static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
5268 + enum snd_soc_bias_level level)
5269 + {
5270 +- u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0xff7f;
5271 ++ u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0x17f;
5272 +
5273 + switch (level) {
5274 + case SND_SOC_BIAS_ON:
5275 +@@ -492,7 +492,7 @@ static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
5276 + case SND_SOC_BIAS_OFF:
5277 + /* everything off, dac mute, inactive */
5278 + snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0);
5279 +- snd_soc_write(codec, TLV320AIC23_PWR, 0xffff);
5280 ++ snd_soc_write(codec, TLV320AIC23_PWR, 0x1ff);
5281 + break;
5282 + }
5283 + codec->dapm.bias_level = level;
5284 +diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
5285 +index 2f1f5f8..7806301 100644
5286 +--- a/sound/soc/codecs/wm8994.c
5287 ++++ b/sound/soc/codecs/wm8994.c
5288 +@@ -883,61 +883,170 @@ static void wm8994_update_class_w(struct snd_soc_codec *codec)
5289 + }
5290 + }
5291 +
5292 +-static int late_enable_ev(struct snd_soc_dapm_widget *w,
5293 +- struct snd_kcontrol *kcontrol, int event)
5294 ++static int aif1clk_ev(struct snd_soc_dapm_widget *w,
5295 ++ struct snd_kcontrol *kcontrol, int event)
5296 + {
5297 + struct snd_soc_codec *codec = w->codec;
5298 +- struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5299 ++ struct wm8994 *control = codec->control_data;
5300 ++ int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
5301 ++ int dac;
5302 ++ int adc;
5303 ++ int val;
5304 ++
5305 ++ switch (control->type) {
5306 ++ case WM8994:
5307 ++ case WM8958:
5308 ++ mask |= WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA;
5309 ++ break;
5310 ++ default:
5311 ++ break;
5312 ++ }
5313 +
5314 + switch (event) {
5315 + case SND_SOC_DAPM_PRE_PMU:
5316 +- if (wm8994->aif1clk_enable) {
5317 +- snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
5318 +- WM8994_AIF1CLK_ENA_MASK,
5319 +- WM8994_AIF1CLK_ENA);
5320 +- wm8994->aif1clk_enable = 0;
5321 +- }
5322 +- if (wm8994->aif2clk_enable) {
5323 +- snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
5324 +- WM8994_AIF2CLK_ENA_MASK,
5325 +- WM8994_AIF2CLK_ENA);
5326 +- wm8994->aif2clk_enable = 0;
5327 +- }
5328 ++ val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1);
5329 ++ if ((val & WM8994_AIF1ADCL_SRC) &&
5330 ++ (val & WM8994_AIF1ADCR_SRC))
5331 ++ adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA;
5332 ++ else if (!(val & WM8994_AIF1ADCL_SRC) &&
5333 ++ !(val & WM8994_AIF1ADCR_SRC))
5334 ++ adc = WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA;
5335 ++ else
5336 ++ adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA |
5337 ++ WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA;
5338 ++
5339 ++ val = snd_soc_read(codec, WM8994_AIF1_CONTROL_2);
5340 ++ if ((val & WM8994_AIF1DACL_SRC) &&
5341 ++ (val & WM8994_AIF1DACR_SRC))
5342 ++ dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA;
5343 ++ else if (!(val & WM8994_AIF1DACL_SRC) &&
5344 ++ !(val & WM8994_AIF1DACR_SRC))
5345 ++ dac = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA;
5346 ++ else
5347 ++ dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA |
5348 ++ WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA;
5349 ++
5350 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
5351 ++ mask, adc);
5352 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5353 ++ mask, dac);
5354 ++ snd_soc_update_bits(codec, WM8994_CLOCKING_1,
5355 ++ WM8994_AIF1DSPCLK_ENA |
5356 ++ WM8994_SYSDSPCLK_ENA,
5357 ++ WM8994_AIF1DSPCLK_ENA |
5358 ++ WM8994_SYSDSPCLK_ENA);
5359 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, mask,
5360 ++ WM8994_AIF1ADC1R_ENA |
5361 ++ WM8994_AIF1ADC1L_ENA |
5362 ++ WM8994_AIF1ADC2R_ENA |
5363 ++ WM8994_AIF1ADC2L_ENA);
5364 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, mask,
5365 ++ WM8994_AIF1DAC1R_ENA |
5366 ++ WM8994_AIF1DAC1L_ENA |
5367 ++ WM8994_AIF1DAC2R_ENA |
5368 ++ WM8994_AIF1DAC2L_ENA);
5369 ++ break;
5370 ++
5371 ++ case SND_SOC_DAPM_PRE_PMD:
5372 ++ case SND_SOC_DAPM_POST_PMD:
5373 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5374 ++ mask, 0);
5375 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
5376 ++ mask, 0);
5377 ++
5378 ++ val = snd_soc_read(codec, WM8994_CLOCKING_1);
5379 ++ if (val & WM8994_AIF2DSPCLK_ENA)
5380 ++ val = WM8994_SYSDSPCLK_ENA;
5381 ++ else
5382 ++ val = 0;
5383 ++ snd_soc_update_bits(codec, WM8994_CLOCKING_1,
5384 ++ WM8994_SYSDSPCLK_ENA |
5385 ++ WM8994_AIF1DSPCLK_ENA, val);
5386 + break;
5387 + }
5388 +
5389 +- /* We may also have postponed startup of DSP, handle that. */
5390 +- wm8958_aif_ev(w, kcontrol, event);
5391 +-
5392 + return 0;
5393 + }
5394 +
5395 +-static int late_disable_ev(struct snd_soc_dapm_widget *w,
5396 +- struct snd_kcontrol *kcontrol, int event)
5397 ++static int aif2clk_ev(struct snd_soc_dapm_widget *w,
5398 ++ struct snd_kcontrol *kcontrol, int event)
5399 + {
5400 + struct snd_soc_codec *codec = w->codec;
5401 +- struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5402 ++ int dac;
5403 ++ int adc;
5404 ++ int val;
5405 +
5406 + switch (event) {
5407 ++ case SND_SOC_DAPM_PRE_PMU:
5408 ++ val = snd_soc_read(codec, WM8994_AIF2_CONTROL_1);
5409 ++ if ((val & WM8994_AIF2ADCL_SRC) &&
5410 ++ (val & WM8994_AIF2ADCR_SRC))
5411 ++ adc = WM8994_AIF2ADCR_ENA;
5412 ++ else if (!(val & WM8994_AIF2ADCL_SRC) &&
5413 ++ !(val & WM8994_AIF2ADCR_SRC))
5414 ++ adc = WM8994_AIF2ADCL_ENA;
5415 ++ else
5416 ++ adc = WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA;
5417 ++
5418 ++
5419 ++ val = snd_soc_read(codec, WM8994_AIF2_CONTROL_2);
5420 ++ if ((val & WM8994_AIF2DACL_SRC) &&
5421 ++ (val & WM8994_AIF2DACR_SRC))
5422 ++ dac = WM8994_AIF2DACR_ENA;
5423 ++ else if (!(val & WM8994_AIF2DACL_SRC) &&
5424 ++ !(val & WM8994_AIF2DACR_SRC))
5425 ++ dac = WM8994_AIF2DACL_ENA;
5426 ++ else
5427 ++ dac = WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA;
5428 ++
5429 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
5430 ++ WM8994_AIF2ADCL_ENA |
5431 ++ WM8994_AIF2ADCR_ENA, adc);
5432 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5433 ++ WM8994_AIF2DACL_ENA |
5434 ++ WM8994_AIF2DACR_ENA, dac);
5435 ++ snd_soc_update_bits(codec, WM8994_CLOCKING_1,
5436 ++ WM8994_AIF2DSPCLK_ENA |
5437 ++ WM8994_SYSDSPCLK_ENA,
5438 ++ WM8994_AIF2DSPCLK_ENA |
5439 ++ WM8994_SYSDSPCLK_ENA);
5440 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
5441 ++ WM8994_AIF2ADCL_ENA |
5442 ++ WM8994_AIF2ADCR_ENA,
5443 ++ WM8994_AIF2ADCL_ENA |
5444 ++ WM8994_AIF2ADCR_ENA);
5445 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5446 ++ WM8994_AIF2DACL_ENA |
5447 ++ WM8994_AIF2DACR_ENA,
5448 ++ WM8994_AIF2DACL_ENA |
5449 ++ WM8994_AIF2DACR_ENA);
5450 ++ break;
5451 ++
5452 ++ case SND_SOC_DAPM_PRE_PMD:
5453 + case SND_SOC_DAPM_POST_PMD:
5454 +- if (wm8994->aif1clk_disable) {
5455 +- snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
5456 +- WM8994_AIF1CLK_ENA_MASK, 0);
5457 +- wm8994->aif1clk_disable = 0;
5458 +- }
5459 +- if (wm8994->aif2clk_disable) {
5460 +- snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
5461 +- WM8994_AIF2CLK_ENA_MASK, 0);
5462 +- wm8994->aif2clk_disable = 0;
5463 +- }
5464 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5465 ++ WM8994_AIF2DACL_ENA |
5466 ++ WM8994_AIF2DACR_ENA, 0);
5467 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
5468 ++ WM8994_AIF2ADCL_ENA |
5469 ++ WM8994_AIF2ADCR_ENA, 0);
5470 ++
5471 ++ val = snd_soc_read(codec, WM8994_CLOCKING_1);
5472 ++ if (val & WM8994_AIF1DSPCLK_ENA)
5473 ++ val = WM8994_SYSDSPCLK_ENA;
5474 ++ else
5475 ++ val = 0;
5476 ++ snd_soc_update_bits(codec, WM8994_CLOCKING_1,
5477 ++ WM8994_SYSDSPCLK_ENA |
5478 ++ WM8994_AIF2DSPCLK_ENA, val);
5479 + break;
5480 + }
5481 +
5482 + return 0;
5483 + }
5484 +
5485 +-static int aif1clk_ev(struct snd_soc_dapm_widget *w,
5486 +- struct snd_kcontrol *kcontrol, int event)
5487 ++static int aif1clk_late_ev(struct snd_soc_dapm_widget *w,
5488 ++ struct snd_kcontrol *kcontrol, int event)
5489 + {
5490 + struct snd_soc_codec *codec = w->codec;
5491 + struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5492 +@@ -954,8 +1063,8 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
5493 + return 0;
5494 + }
5495 +
5496 +-static int aif2clk_ev(struct snd_soc_dapm_widget *w,
5497 +- struct snd_kcontrol *kcontrol, int event)
5498 ++static int aif2clk_late_ev(struct snd_soc_dapm_widget *w,
5499 ++ struct snd_kcontrol *kcontrol, int event)
5500 + {
5501 + struct snd_soc_codec *codec = w->codec;
5502 + struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5503 +@@ -972,6 +1081,63 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
5504 + return 0;
5505 + }
5506 +
5507 ++static int late_enable_ev(struct snd_soc_dapm_widget *w,
5508 ++ struct snd_kcontrol *kcontrol, int event)
5509 ++{
5510 ++ struct snd_soc_codec *codec = w->codec;
5511 ++ struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5512 ++
5513 ++ switch (event) {
5514 ++ case SND_SOC_DAPM_PRE_PMU:
5515 ++ if (wm8994->aif1clk_enable) {
5516 ++ aif1clk_ev(w, kcontrol, event);
5517 ++ snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
5518 ++ WM8994_AIF1CLK_ENA_MASK,
5519 ++ WM8994_AIF1CLK_ENA);
5520 ++ wm8994->aif1clk_enable = 0;
5521 ++ }
5522 ++ if (wm8994->aif2clk_enable) {
5523 ++ aif2clk_ev(w, kcontrol, event);
5524 ++ snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
5525 ++ WM8994_AIF2CLK_ENA_MASK,
5526 ++ WM8994_AIF2CLK_ENA);
5527 ++ wm8994->aif2clk_enable = 0;
5528 ++ }
5529 ++ break;
5530 ++ }
5531 ++
5532 ++ /* We may also have postponed startup of DSP, handle that. */
5533 ++ wm8958_aif_ev(w, kcontrol, event);
5534 ++
5535 ++ return 0;
5536 ++}
5537 ++
5538 ++static int late_disable_ev(struct snd_soc_dapm_widget *w,
5539 ++ struct snd_kcontrol *kcontrol, int event)
5540 ++{
5541 ++ struct snd_soc_codec *codec = w->codec;
5542 ++ struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
5543 ++
5544 ++ switch (event) {
5545 ++ case SND_SOC_DAPM_POST_PMD:
5546 ++ if (wm8994->aif1clk_disable) {
5547 ++ snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
5548 ++ WM8994_AIF1CLK_ENA_MASK, 0);
5549 ++ aif1clk_ev(w, kcontrol, event);
5550 ++ wm8994->aif1clk_disable = 0;
5551 ++ }
5552 ++ if (wm8994->aif2clk_disable) {
5553 ++ snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
5554 ++ WM8994_AIF2CLK_ENA_MASK, 0);
5555 ++ aif2clk_ev(w, kcontrol, event);
5556 ++ wm8994->aif2clk_disable = 0;
5557 ++ }
5558 ++ break;
5559 ++ }
5560 ++
5561 ++ return 0;
5562 ++}
5563 ++
5564 + static int adc_mux_ev(struct snd_soc_dapm_widget *w,
5565 + struct snd_kcontrol *kcontrol, int event)
5566 + {
5567 +@@ -1268,9 +1434,9 @@ static const struct snd_kcontrol_new aif2dacr_src_mux =
5568 + SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum);
5569 +
5570 + static const struct snd_soc_dapm_widget wm8994_lateclk_revd_widgets[] = {
5571 +-SND_SOC_DAPM_SUPPLY("AIF1CLK", SND_SOC_NOPM, 0, 0, aif1clk_ev,
5572 ++SND_SOC_DAPM_SUPPLY("AIF1CLK", SND_SOC_NOPM, 0, 0, aif1clk_late_ev,
5573 + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
5574 +-SND_SOC_DAPM_SUPPLY("AIF2CLK", SND_SOC_NOPM, 0, 0, aif2clk_ev,
5575 ++SND_SOC_DAPM_SUPPLY("AIF2CLK", SND_SOC_NOPM, 0, 0, aif2clk_late_ev,
5576 + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
5577 +
5578 + SND_SOC_DAPM_PGA_E("Late DAC1L Enable PGA", SND_SOC_NOPM, 0, 0, NULL, 0,
5579 +@@ -1299,8 +1465,10 @@ SND_SOC_DAPM_POST("Late Disable PGA", late_disable_ev)
5580 + };
5581 +
5582 + static const struct snd_soc_dapm_widget wm8994_lateclk_widgets[] = {
5583 +-SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, NULL, 0),
5584 +-SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, NULL, 0),
5585 ++SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, aif1clk_ev,
5586 ++ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
5587 ++SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, aif2clk_ev,
5588 ++ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
5589 + SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
5590 + SND_SOC_DAPM_MIXER("SPKL", WM8994_POWER_MANAGEMENT_3, 8, 0,
5591 + left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)),
5592 +@@ -1353,30 +1521,30 @@ SND_SOC_DAPM_SUPPLY("VMID", SND_SOC_NOPM, 0, 0, vmid_event,
5593 + SND_SOC_DAPM_SUPPLY("CLK_SYS", SND_SOC_NOPM, 0, 0, clk_sys_event,
5594 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
5595 +
5596 +-SND_SOC_DAPM_SUPPLY("DSP1CLK", WM8994_CLOCKING_1, 3, 0, NULL, 0),
5597 +-SND_SOC_DAPM_SUPPLY("DSP2CLK", WM8994_CLOCKING_1, 2, 0, NULL, 0),
5598 +-SND_SOC_DAPM_SUPPLY("DSPINTCLK", WM8994_CLOCKING_1, 1, 0, NULL, 0),
5599 ++SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM, 3, 0, NULL, 0),
5600 ++SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM, 2, 0, NULL, 0),
5601 ++SND_SOC_DAPM_SUPPLY("DSPINTCLK", SND_SOC_NOPM, 1, 0, NULL, 0),
5602 +
5603 + SND_SOC_DAPM_AIF_OUT("AIF1ADC1L", NULL,
5604 +- 0, WM8994_POWER_MANAGEMENT_4, 9, 0),
5605 ++ 0, SND_SOC_NOPM, 9, 0),
5606 + SND_SOC_DAPM_AIF_OUT("AIF1ADC1R", NULL,
5607 +- 0, WM8994_POWER_MANAGEMENT_4, 8, 0),
5608 ++ 0, SND_SOC_NOPM, 8, 0),
5609 + SND_SOC_DAPM_AIF_IN_E("AIF1DAC1L", NULL, 0,
5610 +- WM8994_POWER_MANAGEMENT_5, 9, 0, wm8958_aif_ev,
5611 ++ SND_SOC_NOPM, 9, 0, wm8958_aif_ev,
5612 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
5613 + SND_SOC_DAPM_AIF_IN_E("AIF1DAC1R", NULL, 0,
5614 +- WM8994_POWER_MANAGEMENT_5, 8, 0, wm8958_aif_ev,
5615 ++ SND_SOC_NOPM, 8, 0, wm8958_aif_ev,
5616 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
5617 +
5618 + SND_SOC_DAPM_AIF_OUT("AIF1ADC2L", NULL,
5619 +- 0, WM8994_POWER_MANAGEMENT_4, 11, 0),
5620 ++ 0, SND_SOC_NOPM, 11, 0),
5621 + SND_SOC_DAPM_AIF_OUT("AIF1ADC2R", NULL,
5622 +- 0, WM8994_POWER_MANAGEMENT_4, 10, 0),
5623 ++ 0, SND_SOC_NOPM, 10, 0),
5624 + SND_SOC_DAPM_AIF_IN_E("AIF1DAC2L", NULL, 0,
5625 +- WM8994_POWER_MANAGEMENT_5, 11, 0, wm8958_aif_ev,
5626 ++ SND_SOC_NOPM, 11, 0, wm8958_aif_ev,
5627 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
5628 + SND_SOC_DAPM_AIF_IN_E("AIF1DAC2R", NULL, 0,
5629 +- WM8994_POWER_MANAGEMENT_5, 10, 0, wm8958_aif_ev,
5630 ++ SND_SOC_NOPM, 10, 0, wm8958_aif_ev,
5631 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
5632 +
5633 + SND_SOC_DAPM_MIXER("AIF1ADC1L Mixer", SND_SOC_NOPM, 0, 0,
5634 +@@ -1403,14 +1571,14 @@ SND_SOC_DAPM_MIXER("DAC1R Mixer", SND_SOC_NOPM, 0, 0,
5635 + dac1r_mix, ARRAY_SIZE(dac1r_mix)),
5636 +
5637 + SND_SOC_DAPM_AIF_OUT("AIF2ADCL", NULL, 0,
5638 +- WM8994_POWER_MANAGEMENT_4, 13, 0),
5639 ++ SND_SOC_NOPM, 13, 0),
5640 + SND_SOC_DAPM_AIF_OUT("AIF2ADCR", NULL, 0,
5641 +- WM8994_POWER_MANAGEMENT_4, 12, 0),
5642 ++ SND_SOC_NOPM, 12, 0),
5643 + SND_SOC_DAPM_AIF_IN_E("AIF2DACL", NULL, 0,
5644 +- WM8994_POWER_MANAGEMENT_5, 13, 0, wm8958_aif_ev,
5645 ++ SND_SOC_NOPM, 13, 0, wm8958_aif_ev,
5646 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
5647 + SND_SOC_DAPM_AIF_IN_E("AIF2DACR", NULL, 0,
5648 +- WM8994_POWER_MANAGEMENT_5, 12, 0, wm8958_aif_ev,
5649 ++ SND_SOC_NOPM, 12, 0, wm8958_aif_ev,
5650 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
5651 +
5652 + SND_SOC_DAPM_AIF_IN("AIF1DACDAT", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
5653 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
5654 +index ea909c5..90e93bf 100644
5655 +--- a/sound/soc/soc-dapm.c
5656 ++++ b/sound/soc/soc-dapm.c
5657 +@@ -69,6 +69,7 @@ static int dapm_up_seq[] = {
5658 + [snd_soc_dapm_out_drv] = 10,
5659 + [snd_soc_dapm_hp] = 10,
5660 + [snd_soc_dapm_spk] = 10,
5661 ++ [snd_soc_dapm_line] = 10,
5662 + [snd_soc_dapm_post] = 11,
5663 + };
5664 +
5665 +@@ -77,6 +78,7 @@ static int dapm_down_seq[] = {
5666 + [snd_soc_dapm_adc] = 1,
5667 + [snd_soc_dapm_hp] = 2,
5668 + [snd_soc_dapm_spk] = 2,
5669 ++ [snd_soc_dapm_line] = 2,
5670 + [snd_soc_dapm_out_drv] = 2,
5671 + [snd_soc_dapm_pga] = 4,
5672 + [snd_soc_dapm_mixer_named_ctl] = 5,
5673 +diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
5674 +index adb372d..e0a0970 100644
5675 +--- a/tools/perf/util/hist.c
5676 ++++ b/tools/perf/util/hist.c
5677 +@@ -237,8 +237,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
5678 + * mis-adjust symbol addresses when computing
5679 + * the history counter to increment.
5680 + */
5681 +- if (he->ms.map != entry->ms.map) {
5682 +- he->ms.map = entry->ms.map;
5683 ++ if (he->ms.map != entry.ms.map) {
5684 ++ he->ms.map = entry.ms.map;
5685 + if (he->ms.map)
5686 + he->ms.map->referenced = true;
5687 + }
5688 +diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
5689 +index a195c07..fd817a2 100644
5690 +--- a/virt/kvm/iommu.c
5691 ++++ b/virt/kvm/iommu.c
5692 +@@ -309,6 +309,11 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
5693 + }
5694 + }
5695 +
5696 ++void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
5697 ++{
5698 ++ kvm_iommu_put_pages(kvm, slot->base_gfn, slot->npages);
5699 ++}
5700 ++
5701 + static int kvm_iommu_unmap_memslots(struct kvm *kvm)
5702 + {
5703 + int i, idx;
5704 +@@ -317,10 +322,9 @@ static int kvm_iommu_unmap_memslots(struct kvm *kvm)
5705 + idx = srcu_read_lock(&kvm->srcu);
5706 + slots = kvm_memslots(kvm);
5707 +
5708 +- for (i = 0; i < slots->nmemslots; i++) {
5709 +- kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn,
5710 +- slots->memslots[i].npages);
5711 +- }
5712 ++ for (i = 0; i < slots->nmemslots; i++)
5713 ++ kvm_iommu_unmap_pages(kvm, &slots->memslots[i]);
5714 ++
5715 + srcu_read_unlock(&kvm->srcu, idx);
5716 +
5717 + return 0;
5718 +diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
5719 +index d9cfb78..e401c1b 100644
5720 +--- a/virt/kvm/kvm_main.c
5721 ++++ b/virt/kvm/kvm_main.c
5722 +@@ -802,12 +802,13 @@ skip_lpage:
5723 + if (r)
5724 + goto out_free;
5725 +
5726 +- /* map the pages in iommu page table */
5727 ++ /* map/unmap the pages in iommu page table */
5728 + if (npages) {
5729 + r = kvm_iommu_map_pages(kvm, &new);
5730 + if (r)
5731 + goto out_free;
5732 +- }
5733 ++ } else
5734 ++ kvm_iommu_unmap_pages(kvm, &old);
5735 +
5736 + r = -ENOMEM;
5737 + slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
5738
5739 Added: genpatches-2.6/trunk/3.2/1017_linux-3.2.18.patch
5740 ===================================================================
5741 --- genpatches-2.6/trunk/3.2/1017_linux-3.2.18.patch (rev 0)
5742 +++ genpatches-2.6/trunk/3.2/1017_linux-3.2.18.patch 2012-06-06 00:46:35 UTC (rev 2150)
5743 @@ -0,0 +1,1791 @@
5744 +diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
5745 +index 589f2da..a4399f5 100644
5746 +--- a/Documentation/networking/ip-sysctl.txt
5747 ++++ b/Documentation/networking/ip-sysctl.txt
5748 +@@ -137,7 +137,7 @@ tcp_adv_win_scale - INTEGER
5749 + (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale),
5750 + if it is <= 0.
5751 + Possible values are [-31, 31], inclusive.
5752 +- Default: 2
5753 ++ Default: 1
5754 +
5755 + tcp_allowed_congestion_control - STRING
5756 + Show/set the congestion control choices available to non-privileged
5757 +@@ -397,7 +397,7 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max
5758 + net.core.rmem_max. Calling setsockopt() with SO_RCVBUF disables
5759 + automatic tuning of that socket's receive buffer size, in which
5760 + case this value is ignored.
5761 +- Default: between 87380B and 4MB, depending on RAM size.
5762 ++ Default: between 87380B and 6MB, depending on RAM size.
5763 +
5764 + tcp_sack - BOOLEAN
5765 + Enable select acknowledgments (SACKS).
5766 +diff --git a/Makefile b/Makefile
5767 +index 4c4efa3..add68f1 100644
5768 +--- a/Makefile
5769 ++++ b/Makefile
5770 +@@ -1,6 +1,6 @@
5771 + VERSION = 3
5772 + PATCHLEVEL = 2
5773 +-SUBLEVEL = 17
5774 ++SUBLEVEL = 18
5775 + EXTRAVERSION =
5776 + NAME = Saber-toothed Squirrel
5777 +
5778 +diff --git a/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h
5779 +index 1e2d332..c88420d 100644
5780 +--- a/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h
5781 ++++ b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h
5782 +@@ -941,10 +941,10 @@
5783 + #define OMAP4_DSI2_LANEENABLE_MASK (0x7 << 29)
5784 + #define OMAP4_DSI1_LANEENABLE_SHIFT 24
5785 + #define OMAP4_DSI1_LANEENABLE_MASK (0x1f << 24)
5786 +-#define OMAP4_DSI2_PIPD_SHIFT 19
5787 +-#define OMAP4_DSI2_PIPD_MASK (0x1f << 19)
5788 +-#define OMAP4_DSI1_PIPD_SHIFT 14
5789 +-#define OMAP4_DSI1_PIPD_MASK (0x1f << 14)
5790 ++#define OMAP4_DSI1_PIPD_SHIFT 19
5791 ++#define OMAP4_DSI1_PIPD_MASK (0x1f << 19)
5792 ++#define OMAP4_DSI2_PIPD_SHIFT 14
5793 ++#define OMAP4_DSI2_PIPD_MASK (0x1f << 14)
5794 +
5795 + /* CONTROL_MCBSPLP */
5796 + #define OMAP4_ALBCTRLRX_FSX_SHIFT 31
5797 +diff --git a/arch/arm/mach-orion5x/mpp.h b/arch/arm/mach-orion5x/mpp.h
5798 +index eac6897..db70e79 100644
5799 +--- a/arch/arm/mach-orion5x/mpp.h
5800 ++++ b/arch/arm/mach-orion5x/mpp.h
5801 +@@ -65,8 +65,8 @@
5802 + #define MPP8_GIGE MPP(8, 0x1, 0, 0, 1, 1, 1)
5803 +
5804 + #define MPP9_UNUSED MPP(9, 0x0, 0, 0, 1, 1, 1)
5805 +-#define MPP9_GPIO MPP(9, 0x0, 0, 0, 1, 1, 1)
5806 +-#define MPP9_GIGE MPP(9, 0x1, 1, 1, 1, 1, 1)
5807 ++#define MPP9_GPIO MPP(9, 0x0, 1, 1, 1, 1, 1)
5808 ++#define MPP9_GIGE MPP(9, 0x1, 0, 0, 1, 1, 1)
5809 +
5810 + #define MPP10_UNUSED MPP(10, 0x0, 0, 0, 1, 1, 1)
5811 + #define MPP10_GPIO MPP(10, 0x0, 1, 1, 1, 1, 1)
5812 +diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
5813 +index aa33949..4b0bc37 100644
5814 +--- a/arch/arm/mm/fault.c
5815 ++++ b/arch/arm/mm/fault.c
5816 +@@ -267,7 +267,9 @@ good_area:
5817 + return fault;
5818 +
5819 + check_stack:
5820 +- if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
5821 ++ /* Don't allow expansion below FIRST_USER_ADDRESS */
5822 ++ if (vma->vm_flags & VM_GROWSDOWN &&
5823 ++ addr >= FIRST_USER_ADDRESS && !expand_stack(vma, addr))
5824 + goto good_area;
5825 + out:
5826 + return fault;
5827 +diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
5828 +index 8f3ccdd..8ea07e4 100644
5829 +--- a/arch/arm/vfp/vfpmodule.c
5830 ++++ b/arch/arm/vfp/vfpmodule.c
5831 +@@ -11,6 +11,7 @@
5832 + #include <linux/types.h>
5833 + #include <linux/cpu.h>
5834 + #include <linux/cpu_pm.h>
5835 ++#include <linux/hardirq.h>
5836 + #include <linux/kernel.h>
5837 + #include <linux/notifier.h>
5838 + #include <linux/signal.h>
5839 +@@ -428,7 +429,10 @@ void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
5840 +
5841 + static void vfp_enable(void *unused)
5842 + {
5843 +- u32 access = get_copro_access();
5844 ++ u32 access;
5845 ++
5846 ++ BUG_ON(preemptible());
5847 ++ access = get_copro_access();
5848 +
5849 + /*
5850 + * Enable full access to VFP (cp10 and cp11)
5851 +@@ -556,7 +560,7 @@ static int __init vfp_init(void)
5852 + unsigned int cpu_arch = cpu_architecture();
5853 +
5854 + if (cpu_arch >= CPU_ARCH_ARMv6)
5855 +- vfp_enable(NULL);
5856 ++ on_each_cpu(vfp_enable, NULL, 1);
5857 +
5858 + /*
5859 + * First check that there is a VFP that we can use.
5860 +@@ -577,8 +581,6 @@ static int __init vfp_init(void)
5861 + } else {
5862 + hotcpu_notifier(vfp_hotplug, 0);
5863 +
5864 +- smp_call_function(vfp_enable, NULL, 1);
5865 +-
5866 + VFP_arch = (vfpsid & FPSID_ARCH_MASK) >> FPSID_ARCH_BIT; /* Extract the architecture version */
5867 + printk("implementor %02x architecture %d part %02x variant %x rev %x\n",
5868 + (vfpsid & FPSID_IMPLEMENTER_MASK) >> FPSID_IMPLEMENTER_BIT,
5869 +diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h
5870 +index 7617248..7a3bd25 100644
5871 +--- a/arch/ia64/include/asm/unistd.h
5872 ++++ b/arch/ia64/include/asm/unistd.h
5873 +@@ -323,11 +323,12 @@
5874 + #define __NR_sendmmsg 1331
5875 + #define __NR_process_vm_readv 1332
5876 + #define __NR_process_vm_writev 1333
5877 ++#define __NR_accept4 1334
5878 +
5879 + #ifdef __KERNEL__
5880 +
5881 +
5882 +-#define NR_syscalls 310 /* length of syscall table */
5883 ++#define NR_syscalls 311 /* length of syscall table */
5884 +
5885 + /*
5886 + * The following defines stop scripts/checksyscalls.sh from complaining about
5887 +diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
5888 +index 5b31d46..1ccbe12 100644
5889 +--- a/arch/ia64/kernel/entry.S
5890 ++++ b/arch/ia64/kernel/entry.S
5891 +@@ -1779,6 +1779,7 @@ sys_call_table:
5892 + data8 sys_sendmmsg
5893 + data8 sys_process_vm_readv
5894 + data8 sys_process_vm_writev
5895 ++ data8 sys_accept4
5896 +
5897 + .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls
5898 + #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
5899 +diff --git a/arch/sparc/kernel/central.c b/arch/sparc/kernel/central.c
5900 +index 38d48a5..9708851 100644
5901 +--- a/arch/sparc/kernel/central.c
5902 ++++ b/arch/sparc/kernel/central.c
5903 +@@ -269,4 +269,4 @@ static int __init sunfire_init(void)
5904 + return 0;
5905 + }
5906 +
5907 +-subsys_initcall(sunfire_init);
5908 ++fs_initcall(sunfire_init);
5909 +diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
5910 +index b57a594..874162a 100644
5911 +--- a/arch/sparc/mm/ultra.S
5912 ++++ b/arch/sparc/mm/ultra.S
5913 +@@ -495,11 +495,11 @@ xcall_fetch_glob_regs:
5914 + stx %o7, [%g1 + GR_SNAP_O7]
5915 + stx %i7, [%g1 + GR_SNAP_I7]
5916 + /* Don't try this at home kids... */
5917 +- rdpr %cwp, %g2
5918 +- sub %g2, 1, %g7
5919 ++ rdpr %cwp, %g3
5920 ++ sub %g3, 1, %g7
5921 + wrpr %g7, %cwp
5922 + mov %i7, %g7
5923 +- wrpr %g2, %cwp
5924 ++ wrpr %g3, %cwp
5925 + stx %g7, [%g1 + GR_SNAP_RPC]
5926 + sethi %hi(trap_block), %g7
5927 + or %g7, %lo(trap_block), %g7
5928 +diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
5929 +index a7869ad..41459d8 100644
5930 +--- a/arch/tile/kernel/compat_signal.c
5931 ++++ b/arch/tile/kernel/compat_signal.c
5932 +@@ -406,19 +406,17 @@ int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
5933 + * Set up registers for signal handler.
5934 + * Registers that we don't modify keep the value they had from
5935 + * user-space at the time we took the signal.
5936 ++ * We always pass siginfo and mcontext, regardless of SA_SIGINFO,
5937 ++ * since some things rely on this (e.g. glibc's debug/segfault.c).
5938 + */
5939 + regs->pc = ptr_to_compat_reg(ka->sa.sa_handler);
5940 + regs->ex1 = PL_ICS_EX1(USER_PL, 1); /* set crit sec in handler */
5941 + regs->sp = ptr_to_compat_reg(frame);
5942 + regs->lr = restorer;
5943 + regs->regs[0] = (unsigned long) usig;
5944 +-
5945 +- if (ka->sa.sa_flags & SA_SIGINFO) {
5946 +- /* Need extra arguments, so mark to restore caller-saves. */
5947 +- regs->regs[1] = ptr_to_compat_reg(&frame->info);
5948 +- regs->regs[2] = ptr_to_compat_reg(&frame->uc);
5949 +- regs->flags |= PT_FLAGS_CALLER_SAVES;
5950 +- }
5951 ++ regs->regs[1] = ptr_to_compat_reg(&frame->info);
5952 ++ regs->regs[2] = ptr_to_compat_reg(&frame->uc);
5953 ++ regs->flags |= PT_FLAGS_CALLER_SAVES;
5954 +
5955 + /*
5956 + * Notify any tracer that was single-stepping it.
5957 +diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
5958 +index 6d16b4b..7e3002b 100644
5959 +--- a/drivers/crypto/Kconfig
5960 ++++ b/drivers/crypto/Kconfig
5961 +@@ -173,6 +173,7 @@ config CRYPTO_DEV_MV_CESA
5962 + select CRYPTO_ALGAPI
5963 + select CRYPTO_AES
5964 + select CRYPTO_BLKCIPHER2
5965 ++ select CRYPTO_HASH
5966 + help
5967 + This driver allows you to utilize the Cryptographic Engines and
5968 + Security Accelerator (CESA) which can be found on the Marvell Orion
5969 +diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
5970 +index 461958f..271fd49 100644
5971 +--- a/drivers/gpio/gpio-ml-ioh.c
5972 ++++ b/drivers/gpio/gpio-ml-ioh.c
5973 +@@ -448,6 +448,7 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
5974 + chip->reg = chip->base;
5975 + chip->ch = i;
5976 + mutex_init(&chip->lock);
5977 ++ spin_lock_init(&chip->spinlock);
5978 + ioh_gpio_setup(chip, num_ports[i]);
5979 + ret = gpiochip_add(&chip->gpio);
5980 + if (ret) {
5981 +diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
5982 +index 801d92d..a417f94 100644
5983 +--- a/drivers/md/dm-mpath.c
5984 ++++ b/drivers/md/dm-mpath.c
5985 +@@ -698,8 +698,8 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
5986 + return 0;
5987 +
5988 + m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);
5989 +- request_module("scsi_dh_%s", m->hw_handler_name);
5990 +- if (scsi_dh_handler_exist(m->hw_handler_name) == 0) {
5991 ++ if (!try_then_request_module(scsi_dh_handler_exist(m->hw_handler_name),
5992 ++ "scsi_dh_%s", m->hw_handler_name)) {
5993 + ti->error = "unknown hardware handler type";
5994 + ret = -EINVAL;
5995 + goto fail;
5996 +diff --git a/drivers/md/md.c b/drivers/md/md.c
5997 +index 065ab4f..adcd850 100644
5998 +--- a/drivers/md/md.c
5999 ++++ b/drivers/md/md.c
6000 +@@ -392,6 +392,8 @@ void mddev_suspend(struct mddev *mddev)
6001 + synchronize_rcu();
6002 + wait_event(mddev->sb_wait, atomic_read(&mddev->active_io) == 0);
6003 + mddev->pers->quiesce(mddev, 1);
6004 ++
6005 ++ del_timer_sync(&mddev->safemode_timer);
6006 + }
6007 + EXPORT_SYMBOL_GPL(mddev_suspend);
6008 +
6009 +diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
6010 +index cf10ecf..ed77c6d 100644
6011 +--- a/drivers/media/rc/ene_ir.c
6012 ++++ b/drivers/media/rc/ene_ir.c
6013 +@@ -1018,22 +1018,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
6014 +
6015 + spin_lock_init(&dev->hw_lock);
6016 +
6017 +- /* claim the resources */
6018 +- error = -EBUSY;
6019 +- dev->hw_io = pnp_port_start(pnp_dev, 0);
6020 +- if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
6021 +- dev->hw_io = -1;
6022 +- dev->irq = -1;
6023 +- goto error;
6024 +- }
6025 +-
6026 +- dev->irq = pnp_irq(pnp_dev, 0);
6027 +- if (request_irq(dev->irq, ene_isr,
6028 +- IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
6029 +- dev->irq = -1;
6030 +- goto error;
6031 +- }
6032 +-
6033 + pnp_set_drvdata(pnp_dev, dev);
6034 + dev->pnp_dev = pnp_dev;
6035 +
6036 +@@ -1086,6 +1070,22 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
6037 + device_set_wakeup_capable(&pnp_dev->dev, true);
6038 + device_set_wakeup_enable(&pnp_dev->dev, true);
6039 +
6040 ++ /* claim the resources */
6041 ++ error = -EBUSY;
6042 ++ dev->hw_io = pnp_port_start(pnp_dev, 0);
6043 ++ if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
6044 ++ dev->hw_io = -1;
6045 ++ dev->irq = -1;
6046 ++ goto error;
6047 ++ }
6048 ++
6049 ++ dev->irq = pnp_irq(pnp_dev, 0);
6050 ++ if (request_irq(dev->irq, ene_isr,
6051 ++ IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
6052 ++ dev->irq = -1;
6053 ++ goto error;
6054 ++ }
6055 ++
6056 + error = rc_register_device(rdev);
6057 + if (error < 0)
6058 + goto error;
6059 +diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
6060 +index 7f7079b..4218f73 100644
6061 +--- a/drivers/media/rc/fintek-cir.c
6062 ++++ b/drivers/media/rc/fintek-cir.c
6063 +@@ -504,16 +504,6 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
6064 +
6065 + spin_lock_init(&fintek->fintek_lock);
6066 +
6067 +- ret = -EBUSY;
6068 +- /* now claim resources */
6069 +- if (!request_region(fintek->cir_addr,
6070 +- fintek->cir_port_len, FINTEK_DRIVER_NAME))
6071 +- goto failure;
6072 +-
6073 +- if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED,
6074 +- FINTEK_DRIVER_NAME, (void *)fintek))
6075 +- goto failure;
6076 +-
6077 + pnp_set_drvdata(pdev, fintek);
6078 + fintek->pdev = pdev;
6079 +
6080 +@@ -548,6 +538,16 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
6081 + /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
6082 + rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);
6083 +
6084 ++ ret = -EBUSY;
6085 ++ /* now claim resources */
6086 ++ if (!request_region(fintek->cir_addr,
6087 ++ fintek->cir_port_len, FINTEK_DRIVER_NAME))
6088 ++ goto failure;
6089 ++
6090 ++ if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED,
6091 ++ FINTEK_DRIVER_NAME, (void *)fintek))
6092 ++ goto failure;
6093 ++
6094 + ret = rc_register_device(rdev);
6095 + if (ret)
6096 + goto failure;
6097 +diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
6098 +index 682009d..0e49c99 100644
6099 +--- a/drivers/media/rc/ite-cir.c
6100 ++++ b/drivers/media/rc/ite-cir.c
6101 +@@ -1515,16 +1515,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
6102 + /* initialize raw event */
6103 + init_ir_raw_event(&itdev->rawir);
6104 +
6105 +- ret = -EBUSY;
6106 +- /* now claim resources */
6107 +- if (!request_region(itdev->cir_addr,
6108 +- dev_desc->io_region_size, ITE_DRIVER_NAME))
6109 +- goto failure;
6110 +-
6111 +- if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED,
6112 +- ITE_DRIVER_NAME, (void *)itdev))
6113 +- goto failure;
6114 +-
6115 + /* set driver data into the pnp device */
6116 + pnp_set_drvdata(pdev, itdev);
6117 + itdev->pdev = pdev;
6118 +@@ -1600,6 +1590,16 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
6119 + rdev->driver_name = ITE_DRIVER_NAME;
6120 + rdev->map_name = RC_MAP_RC6_MCE;
6121 +
6122 ++ ret = -EBUSY;
6123 ++ /* now claim resources */
6124 ++ if (!request_region(itdev->cir_addr,
6125 ++ dev_desc->io_region_size, ITE_DRIVER_NAME))
6126 ++ goto failure;
6127 ++
6128 ++ if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED,
6129 ++ ITE_DRIVER_NAME, (void *)itdev))
6130 ++ goto failure;
6131 ++
6132 + ret = rc_register_device(rdev);
6133 + if (ret)
6134 + goto failure;
6135 +diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
6136 +index 144f3f5..8b2c071 100644
6137 +--- a/drivers/media/rc/nuvoton-cir.c
6138 ++++ b/drivers/media/rc/nuvoton-cir.c
6139 +@@ -1021,24 +1021,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
6140 + spin_lock_init(&nvt->nvt_lock);
6141 + spin_lock_init(&nvt->tx.lock);
6142 +
6143 +- ret = -EBUSY;
6144 +- /* now claim resources */
6145 +- if (!request_region(nvt->cir_addr,
6146 +- CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
6147 +- goto failure;
6148 +-
6149 +- if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED,
6150 +- NVT_DRIVER_NAME, (void *)nvt))
6151 +- goto failure;
6152 +-
6153 +- if (!request_region(nvt->cir_wake_addr,
6154 +- CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
6155 +- goto failure;
6156 +-
6157 +- if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED,
6158 +- NVT_DRIVER_NAME, (void *)nvt))
6159 +- goto failure;
6160 +-
6161 + pnp_set_drvdata(pdev, nvt);
6162 + nvt->pdev = pdev;
6163 +
6164 +@@ -1085,6 +1067,24 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
6165 + rdev->tx_resolution = XYZ;
6166 + #endif
6167 +
6168 ++ ret = -EBUSY;
6169 ++ /* now claim resources */
6170 ++ if (!request_region(nvt->cir_addr,
6171 ++ CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
6172 ++ goto failure;
6173 ++
6174 ++ if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED,
6175 ++ NVT_DRIVER_NAME, (void *)nvt))
6176 ++ goto failure;
6177 ++
6178 ++ if (!request_region(nvt->cir_wake_addr,
6179 ++ CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
6180 ++ goto failure;
6181 ++
6182 ++ if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED,
6183 ++ NVT_DRIVER_NAME, (void *)nvt))
6184 ++ goto failure;
6185 ++
6186 + ret = rc_register_device(rdev);
6187 + if (ret)
6188 + goto failure;
6189 +diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
6190 +index a7e7d6f..4591770 100644
6191 +--- a/drivers/media/rc/winbond-cir.c
6192 ++++ b/drivers/media/rc/winbond-cir.c
6193 +@@ -991,39 +991,10 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
6194 + "(w: 0x%lX, e: 0x%lX, s: 0x%lX, i: %u)\n",
6195 + data->wbase, data->ebase, data->sbase, data->irq);
6196 +
6197 +- if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
6198 +- dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6199 +- data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1);
6200 +- err = -EBUSY;
6201 +- goto exit_free_data;
6202 +- }
6203 +-
6204 +- if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) {
6205 +- dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6206 +- data->ebase, data->ebase + EHFUNC_IOMEM_LEN - 1);
6207 +- err = -EBUSY;
6208 +- goto exit_release_wbase;
6209 +- }
6210 +-
6211 +- if (!request_region(data->sbase, SP_IOMEM_LEN, DRVNAME)) {
6212 +- dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6213 +- data->sbase, data->sbase + SP_IOMEM_LEN - 1);
6214 +- err = -EBUSY;
6215 +- goto exit_release_ebase;
6216 +- }
6217 +-
6218 +- err = request_irq(data->irq, wbcir_irq_handler,
6219 +- IRQF_DISABLED, DRVNAME, device);
6220 +- if (err) {
6221 +- dev_err(dev, "Failed to claim IRQ %u\n", data->irq);
6222 +- err = -EBUSY;
6223 +- goto exit_release_sbase;
6224 +- }
6225 +-
6226 + led_trigger_register_simple("cir-tx", &data->txtrigger);
6227 + if (!data->txtrigger) {
6228 + err = -ENOMEM;
6229 +- goto exit_free_irq;
6230 ++ goto exit_free_data;
6231 + }
6232 +
6233 + led_trigger_register_simple("cir-rx", &data->rxtrigger);
6234 +@@ -1062,9 +1033,38 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
6235 + data->dev->priv = data;
6236 + data->dev->dev.parent = &device->dev;
6237 +
6238 ++ if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
6239 ++ dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6240 ++ data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1);
6241 ++ err = -EBUSY;
6242 ++ goto exit_free_rc;
6243 ++ }
6244 ++
6245 ++ if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) {
6246 ++ dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6247 ++ data->ebase, data->ebase + EHFUNC_IOMEM_LEN - 1);
6248 ++ err = -EBUSY;
6249 ++ goto exit_release_wbase;
6250 ++ }
6251 ++
6252 ++ if (!request_region(data->sbase, SP_IOMEM_LEN, DRVNAME)) {
6253 ++ dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
6254 ++ data->sbase, data->sbase + SP_IOMEM_LEN - 1);
6255 ++ err = -EBUSY;
6256 ++ goto exit_release_ebase;
6257 ++ }
6258 ++
6259 ++ err = request_irq(data->irq, wbcir_irq_handler,
6260 ++ IRQF_DISABLED, DRVNAME, device);
6261 ++ if (err) {
6262 ++ dev_err(dev, "Failed to claim IRQ %u\n", data->irq);
6263 ++ err = -EBUSY;
6264 ++ goto exit_release_sbase;
6265 ++ }
6266 ++
6267 + err = rc_register_device(data->dev);
6268 + if (err)
6269 +- goto exit_free_rc;
6270 ++ goto exit_free_irq;
6271 +
6272 + device_init_wakeup(&device->dev, 1);
6273 +
6274 +@@ -1072,14 +1072,6 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
6275 +
6276 + return 0;
6277 +
6278 +-exit_free_rc:
6279 +- rc_free_device(data->dev);
6280 +-exit_unregister_led:
6281 +- led_classdev_unregister(&data->led);
6282 +-exit_unregister_rxtrigger:
6283 +- led_trigger_unregister_simple(data->rxtrigger);
6284 +-exit_unregister_txtrigger:
6285 +- led_trigger_unregister_simple(data->txtrigger);
6286 + exit_free_irq:
6287 + free_irq(data->irq, device);
6288 + exit_release_sbase:
6289 +@@ -1088,6 +1080,14 @@ exit_release_ebase:
6290 + release_region(data->ebase, EHFUNC_IOMEM_LEN);
6291 + exit_release_wbase:
6292 + release_region(data->wbase, WAKEUP_IOMEM_LEN);
6293 ++exit_free_rc:
6294 ++ rc_free_device(data->dev);
6295 ++exit_unregister_led:
6296 ++ led_classdev_unregister(&data->led);
6297 ++exit_unregister_rxtrigger:
6298 ++ led_trigger_unregister_simple(data->rxtrigger);
6299 ++exit_unregister_txtrigger:
6300 ++ led_trigger_unregister_simple(data->txtrigger);
6301 + exit_free_data:
6302 + kfree(data);
6303 + pnp_set_drvdata(device, NULL);
6304 +diff --git a/drivers/media/video/marvell-ccic/mmp-driver.c b/drivers/media/video/marvell-ccic/mmp-driver.c
6305 +index fb0b124..a6b7657 100644
6306 +--- a/drivers/media/video/marvell-ccic/mmp-driver.c
6307 ++++ b/drivers/media/video/marvell-ccic/mmp-driver.c
6308 +@@ -175,7 +175,6 @@ static int mmpcam_probe(struct platform_device *pdev)
6309 + INIT_LIST_HEAD(&cam->devlist);
6310 +
6311 + mcam = &cam->mcam;
6312 +- mcam->platform = MHP_Armada610;
6313 + mcam->plat_power_up = mmpcam_power_up;
6314 + mcam->plat_power_down = mmpcam_power_down;
6315 + mcam->dev = &pdev->dev;
6316 +diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
6317 +index 2cc3b91..327a81f 100644
6318 +--- a/drivers/media/video/s5p-fimc/fimc-capture.c
6319 ++++ b/drivers/media/video/s5p-fimc/fimc-capture.c
6320 +@@ -1304,7 +1304,7 @@ static int fimc_subdev_set_crop(struct v4l2_subdev *sd,
6321 + fimc_capture_try_crop(ctx, r, crop->pad);
6322 +
6323 + if (crop->which == V4L2_SUBDEV_FORMAT_TRY) {
6324 +- mutex_lock(&fimc->lock);
6325 ++ mutex_unlock(&fimc->lock);
6326 + *v4l2_subdev_get_try_crop(fh, crop->pad) = *r;
6327 + return 0;
6328 + }
6329 +diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
6330 +index 3d55883..2dcac28 100644
6331 +--- a/drivers/net/ethernet/broadcom/tg3.c
6332 ++++ b/drivers/net/ethernet/broadcom/tg3.c
6333 +@@ -879,8 +879,13 @@ static inline unsigned int tg3_has_work(struct tg3_napi *tnapi)
6334 + if (sblk->status & SD_STATUS_LINK_CHG)
6335 + work_exists = 1;
6336 + }
6337 +- /* check for RX/TX work to do */
6338 +- if (sblk->idx[0].tx_consumer != tnapi->tx_cons ||
6339 ++
6340 ++ /* check for TX work to do */
6341 ++ if (sblk->idx[0].tx_consumer != tnapi->tx_cons)
6342 ++ work_exists = 1;
6343 ++
6344 ++ /* check for RX work to do */
6345 ++ if (tnapi->rx_rcb_prod_idx &&
6346 + *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr)
6347 + work_exists = 1;
6348 +
6349 +@@ -5895,6 +5900,9 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
6350 + return work_done;
6351 + }
6352 +
6353 ++ if (!tnapi->rx_rcb_prod_idx)
6354 ++ return work_done;
6355 ++
6356 + /* run RX thread, within the bounds set by NAPI.
6357 + * All RX "locking" is done by ensuring outside
6358 + * code synchronizes with tg3->napi.poll()
6359 +@@ -7448,6 +7456,12 @@ static int tg3_alloc_consistent(struct tg3 *tp)
6360 + */
6361 + switch (i) {
6362 + default:
6363 ++ if (tg3_flag(tp, ENABLE_RSS)) {
6364 ++ tnapi->rx_rcb_prod_idx = NULL;
6365 ++ break;
6366 ++ }
6367 ++ /* Fall through */
6368 ++ case 1:
6369 + tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer;
6370 + break;
6371 + case 2:
6372 +diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
6373 +index cf480b5..de00805 100644
6374 +--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
6375 ++++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
6376 +@@ -494,7 +494,11 @@ out:
6377 + static void e1000_down_and_stop(struct e1000_adapter *adapter)
6378 + {
6379 + set_bit(__E1000_DOWN, &adapter->flags);
6380 +- cancel_work_sync(&adapter->reset_task);
6381 ++
6382 ++ /* Only kill reset task if adapter is not resetting */
6383 ++ if (!test_bit(__E1000_RESETTING, &adapter->flags))
6384 ++ cancel_work_sync(&adapter->reset_task);
6385 ++
6386 + cancel_delayed_work_sync(&adapter->watchdog_task);
6387 + cancel_delayed_work_sync(&adapter->phy_info_task);
6388 + cancel_delayed_work_sync(&adapter->fifo_stall_task);
6389 +diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
6390 +index 7eb8a00..65c51ff 100644
6391 +--- a/drivers/net/ethernet/marvell/sky2.c
6392 ++++ b/drivers/net/ethernet/marvell/sky2.c
6393 +@@ -2475,8 +2475,13 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
6394 + skb_copy_from_linear_data(re->skb, skb->data, length);
6395 + skb->ip_summed = re->skb->ip_summed;
6396 + skb->csum = re->skb->csum;
6397 ++ skb->rxhash = re->skb->rxhash;
6398 ++ skb->vlan_tci = re->skb->vlan_tci;
6399 ++
6400 + pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
6401 + length, PCI_DMA_FROMDEVICE);
6402 ++ re->skb->vlan_tci = 0;
6403 ++ re->skb->rxhash = 0;
6404 + re->skb->ip_summed = CHECKSUM_NONE;
6405 + skb_put(skb, length);
6406 + }
6407 +@@ -2561,9 +2566,6 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
6408 + struct sk_buff *skb = NULL;
6409 + u16 count = (status & GMR_FS_LEN) >> 16;
6410 +
6411 +- if (status & GMR_FS_VLAN)
6412 +- count -= VLAN_HLEN; /* Account for vlan tag */
6413 +-
6414 + netif_printk(sky2, rx_status, KERN_DEBUG, dev,
6415 + "rx slot %u status 0x%x len %d\n",
6416 + sky2->rx_next, status, length);
6417 +@@ -2571,6 +2573,9 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
6418 + sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending;
6419 + prefetch(sky2->rx_ring + sky2->rx_next);
6420 +
6421 ++ if (vlan_tx_tag_present(re->skb))
6422 ++ count -= VLAN_HLEN; /* Account for vlan tag */
6423 ++
6424 + /* This chip has hardware problems that generates bogus status.
6425 + * So do only marginal checking and expect higher level protocols
6426 + * to handle crap frames.
6427 +@@ -2628,11 +2633,8 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
6428 + }
6429 +
6430 + static inline void sky2_skb_rx(const struct sky2_port *sky2,
6431 +- u32 status, struct sk_buff *skb)
6432 ++ struct sk_buff *skb)
6433 + {
6434 +- if (status & GMR_FS_VLAN)
6435 +- __vlan_hwaccel_put_tag(skb, be16_to_cpu(sky2->rx_tag));
6436 +-
6437 + if (skb->ip_summed == CHECKSUM_NONE)
6438 + netif_receive_skb(skb);
6439 + else
6440 +@@ -2686,6 +2688,14 @@ static void sky2_rx_checksum(struct sky2_port *sky2, u32 status)
6441 + }
6442 + }
6443 +
6444 ++static void sky2_rx_tag(struct sky2_port *sky2, u16 length)
6445 ++{
6446 ++ struct sk_buff *skb;
6447 ++
6448 ++ skb = sky2->rx_ring[sky2->rx_next].skb;
6449 ++ __vlan_hwaccel_put_tag(skb, be16_to_cpu(length));
6450 ++}
6451 ++
6452 + static void sky2_rx_hash(struct sky2_port *sky2, u32 status)
6453 + {
6454 + struct sk_buff *skb;
6455 +@@ -2744,8 +2754,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
6456 + }
6457 +
6458 + skb->protocol = eth_type_trans(skb, dev);
6459 +-
6460 +- sky2_skb_rx(sky2, status, skb);
6461 ++ sky2_skb_rx(sky2, skb);
6462 +
6463 + /* Stop after net poll weight */
6464 + if (++work_done >= to_do)
6465 +@@ -2753,11 +2762,11 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
6466 + break;
6467 +
6468 + case OP_RXVLAN:
6469 +- sky2->rx_tag = length;
6470 ++ sky2_rx_tag(sky2, length);
6471 + break;
6472 +
6473 + case OP_RXCHKSVLAN:
6474 +- sky2->rx_tag = length;
6475 ++ sky2_rx_tag(sky2, length);
6476 + /* fall through */
6477 + case OP_RXCHKS:
6478 + if (likely(dev->features & NETIF_F_RXCSUM))
6479 +diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h
6480 +index ff6f58b..3c896ce 100644
6481 +--- a/drivers/net/ethernet/marvell/sky2.h
6482 ++++ b/drivers/net/ethernet/marvell/sky2.h
6483 +@@ -2241,7 +2241,6 @@ struct sky2_port {
6484 + u16 rx_pending;
6485 + u16 rx_data_size;
6486 + u16 rx_nfrags;
6487 +- u16 rx_tag;
6488 +
6489 + struct {
6490 + unsigned long last;
6491 +diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
6492 +index 41e6b33..c07cfe9 100644
6493 +--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
6494 ++++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
6495 +@@ -22,6 +22,7 @@
6496 + Author: Giuseppe Cavallaro <peppe.cavallaro@××.com>
6497 + *******************************************************************************/
6498 +
6499 ++#include <linux/kernel.h>
6500 + #include <linux/io.h>
6501 + #include "mmc.h"
6502 +
6503 +diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
6504 +index ceab215..c508d6a 100644
6505 +--- a/drivers/net/ethernet/sun/sungem.c
6506 ++++ b/drivers/net/ethernet/sun/sungem.c
6507 +@@ -2340,7 +2340,7 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
6508 + netif_device_detach(dev);
6509 +
6510 + /* Switch off chip, remember WOL setting */
6511 +- gp->asleep_wol = gp->wake_on_lan;
6512 ++ gp->asleep_wol = !!gp->wake_on_lan;
6513 + gem_do_stop(dev, gp->asleep_wol);
6514 +
6515 + /* Unlock the network stack */
6516 +diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
6517 +index c81f136..b142300 100644
6518 +--- a/drivers/net/phy/icplus.c
6519 ++++ b/drivers/net/phy/icplus.c
6520 +@@ -150,7 +150,8 @@ static int ip101a_config_init(struct phy_device *phydev)
6521 + /* Enable Auto Power Saving mode */
6522 + c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
6523 + c |= IP101A_APS_ON;
6524 +- return c;
6525 ++
6526 ++ return phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
6527 + }
6528 +
6529 + static int ip175c_read_status(struct phy_device *phydev)
6530 +diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
6531 +index fda4be2..a9abee8 100644
6532 +--- a/drivers/net/usb/asix.c
6533 ++++ b/drivers/net/usb/asix.c
6534 +@@ -403,7 +403,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
6535 + u32 packet_len;
6536 + u32 padbytes = 0xffff0000;
6537 +
6538 +- padlen = ((skb->len + 4) % 512) ? 0 : 4;
6539 ++ padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4;
6540 +
6541 + if ((!skb_cloned(skb)) &&
6542 + ((headroom + tailroom) >= (4 + padlen))) {
6543 +@@ -425,7 +425,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
6544 + cpu_to_le32s(&packet_len);
6545 + skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
6546 +
6547 +- if ((skb->len % 512) == 0) {
6548 ++ if (padlen) {
6549 + cpu_to_le32s(&padbytes);
6550 + memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
6551 + skb_put(skb, sizeof(padbytes));
6552 +diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
6553 +index 4fd4144..2ba40cf 100644
6554 +--- a/drivers/net/usb/cdc_ether.c
6555 ++++ b/drivers/net/usb/cdc_ether.c
6556 +@@ -83,6 +83,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
6557 + struct cdc_state *info = (void *) &dev->data;
6558 + int status;
6559 + int rndis;
6560 ++ bool android_rndis_quirk = false;
6561 + struct usb_driver *driver = driver_of(intf);
6562 + struct usb_cdc_mdlm_desc *desc = NULL;
6563 + struct usb_cdc_mdlm_detail_desc *detail = NULL;
6564 +@@ -195,6 +196,11 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
6565 + info->control,
6566 + info->u->bSlaveInterface0,
6567 + info->data);
6568 ++ /* fall back to hard-wiring for RNDIS */
6569 ++ if (rndis) {
6570 ++ android_rndis_quirk = true;
6571 ++ goto next_desc;
6572 ++ }
6573 + goto bad_desc;
6574 + }
6575 + if (info->control != intf) {
6576 +@@ -271,11 +277,15 @@ next_desc:
6577 + /* Microsoft ActiveSync based and some regular RNDIS devices lack the
6578 + * CDC descriptors, so we'll hard-wire the interfaces and not check
6579 + * for descriptors.
6580 ++ *
6581 ++ * Some Android RNDIS devices have a CDC Union descriptor pointing
6582 ++ * to non-existing interfaces. Ignore that and attempt the same
6583 ++ * hard-wired 0 and 1 interfaces.
6584 + */
6585 +- if (rndis && !info->u) {
6586 ++ if (rndis && (!info->u || android_rndis_quirk)) {
6587 + info->control = usb_ifnum_to_if(dev->udev, 0);
6588 + info->data = usb_ifnum_to_if(dev->udev, 1);
6589 +- if (!info->control || !info->data) {
6590 ++ if (!info->control || !info->data || info->control != intf) {
6591 + dev_dbg(&intf->dev,
6592 + "rndis: master #0/%p slave #1/%p\n",
6593 + info->control,
6594 +@@ -472,6 +482,7 @@ static const struct driver_info wwan_info = {
6595 + /*-------------------------------------------------------------------------*/
6596 +
6597 + #define HUAWEI_VENDOR_ID 0x12D1
6598 ++#define NOVATEL_VENDOR_ID 0x1410
6599 +
6600 + static const struct usb_device_id products [] = {
6601 + /*
6602 +@@ -589,6 +600,21 @@ static const struct usb_device_id products [] = {
6603 + * because of bugs/quirks in a given product (like Zaurus, above).
6604 + */
6605 + {
6606 ++ /* Novatel USB551L */
6607 ++ /* This match must come *before* the generic CDC-ETHER match so that
6608 ++ * we get FLAG_WWAN set on the device, since it's descriptors are
6609 ++ * generic CDC-ETHER.
6610 ++ */
6611 ++ .match_flags = USB_DEVICE_ID_MATCH_VENDOR
6612 ++ | USB_DEVICE_ID_MATCH_PRODUCT
6613 ++ | USB_DEVICE_ID_MATCH_INT_INFO,
6614 ++ .idVendor = NOVATEL_VENDOR_ID,
6615 ++ .idProduct = 0xB001,
6616 ++ .bInterfaceClass = USB_CLASS_COMM,
6617 ++ .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
6618 ++ .bInterfaceProtocol = USB_CDC_PROTO_NONE,
6619 ++ .driver_info = (unsigned long)&wwan_info,
6620 ++}, {
6621 + USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
6622 + USB_CDC_PROTO_NONE),
6623 + .driver_info = (unsigned long) &cdc_info,
6624 +diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
6625 +index 750e330..b873b5d 100644
6626 +--- a/drivers/net/usb/usbnet.c
6627 ++++ b/drivers/net/usb/usbnet.c
6628 +@@ -281,17 +281,32 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)
6629 + }
6630 + EXPORT_SYMBOL_GPL(usbnet_change_mtu);
6631 +
6632 ++/* The caller must hold list->lock */
6633 ++static void __usbnet_queue_skb(struct sk_buff_head *list,
6634 ++ struct sk_buff *newsk, enum skb_state state)
6635 ++{
6636 ++ struct skb_data *entry = (struct skb_data *) newsk->cb;
6637 ++
6638 ++ __skb_queue_tail(list, newsk);
6639 ++ entry->state = state;
6640 ++}
6641 ++
6642 + /*-------------------------------------------------------------------------*/
6643 +
6644 + /* some LK 2.4 HCDs oopsed if we freed or resubmitted urbs from
6645 + * completion callbacks. 2.5 should have fixed those bugs...
6646 + */
6647 +
6648 +-static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
6649 ++static enum skb_state defer_bh(struct usbnet *dev, struct sk_buff *skb,
6650 ++ struct sk_buff_head *list, enum skb_state state)
6651 + {
6652 + unsigned long flags;
6653 ++ enum skb_state old_state;
6654 ++ struct skb_data *entry = (struct skb_data *) skb->cb;
6655 +
6656 + spin_lock_irqsave(&list->lock, flags);
6657 ++ old_state = entry->state;
6658 ++ entry->state = state;
6659 + __skb_unlink(skb, list);
6660 + spin_unlock(&list->lock);
6661 + spin_lock(&dev->done.lock);
6662 +@@ -299,6 +314,7 @@ static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_hea
6663 + if (dev->done.qlen == 1)
6664 + tasklet_schedule(&dev->bh);
6665 + spin_unlock_irqrestore(&dev->done.lock, flags);
6666 ++ return old_state;
6667 + }
6668 +
6669 + /* some work can't be done in tasklets, so we use keventd
6670 +@@ -339,7 +355,6 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
6671 + entry = (struct skb_data *) skb->cb;
6672 + entry->urb = urb;
6673 + entry->dev = dev;
6674 +- entry->state = rx_start;
6675 + entry->length = 0;
6676 +
6677 + usb_fill_bulk_urb (urb, dev->udev, dev->in,
6678 +@@ -371,7 +386,7 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
6679 + tasklet_schedule (&dev->bh);
6680 + break;
6681 + case 0:
6682 +- __skb_queue_tail (&dev->rxq, skb);
6683 ++ __usbnet_queue_skb(&dev->rxq, skb, rx_start);
6684 + }
6685 + } else {
6686 + netif_dbg(dev, ifdown, dev->net, "rx: stopped\n");
6687 +@@ -422,16 +437,17 @@ static void rx_complete (struct urb *urb)
6688 + struct skb_data *entry = (struct skb_data *) skb->cb;
6689 + struct usbnet *dev = entry->dev;
6690 + int urb_status = urb->status;
6691 ++ enum skb_state state;
6692 +
6693 + skb_put (skb, urb->actual_length);
6694 +- entry->state = rx_done;
6695 ++ state = rx_done;
6696 + entry->urb = NULL;
6697 +
6698 + switch (urb_status) {
6699 + /* success */
6700 + case 0:
6701 + if (skb->len < dev->net->hard_header_len) {
6702 +- entry->state = rx_cleanup;
6703 ++ state = rx_cleanup;
6704 + dev->net->stats.rx_errors++;
6705 + dev->net->stats.rx_length_errors++;
6706 + netif_dbg(dev, rx_err, dev->net,
6707 +@@ -470,7 +486,7 @@ static void rx_complete (struct urb *urb)
6708 + "rx throttle %d\n", urb_status);
6709 + }
6710 + block:
6711 +- entry->state = rx_cleanup;
6712 ++ state = rx_cleanup;
6713 + entry->urb = urb;
6714 + urb = NULL;
6715 + break;
6716 +@@ -481,17 +497,18 @@ block:
6717 + // FALLTHROUGH
6718 +
6719 + default:
6720 +- entry->state = rx_cleanup;
6721 ++ state = rx_cleanup;
6722 + dev->net->stats.rx_errors++;
6723 + netif_dbg(dev, rx_err, dev->net, "rx status %d\n", urb_status);
6724 + break;
6725 + }
6726 +
6727 +- defer_bh(dev, skb, &dev->rxq);
6728 ++ state = defer_bh(dev, skb, &dev->rxq, state);
6729 +
6730 + if (urb) {
6731 + if (netif_running (dev->net) &&
6732 +- !test_bit (EVENT_RX_HALT, &dev->flags)) {
6733 ++ !test_bit (EVENT_RX_HALT, &dev->flags) &&
6734 ++ state != unlink_start) {
6735 + rx_submit (dev, urb, GFP_ATOMIC);
6736 + return;
6737 + }
6738 +@@ -577,16 +594,23 @@ EXPORT_SYMBOL_GPL(usbnet_purge_paused_rxq);
6739 + static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
6740 + {
6741 + unsigned long flags;
6742 +- struct sk_buff *skb, *skbnext;
6743 ++ struct sk_buff *skb;
6744 + int count = 0;
6745 +
6746 + spin_lock_irqsave (&q->lock, flags);
6747 +- skb_queue_walk_safe(q, skb, skbnext) {
6748 ++ while (!skb_queue_empty(q)) {
6749 + struct skb_data *entry;
6750 + struct urb *urb;
6751 + int retval;
6752 +
6753 +- entry = (struct skb_data *) skb->cb;
6754 ++ skb_queue_walk(q, skb) {
6755 ++ entry = (struct skb_data *) skb->cb;
6756 ++ if (entry->state != unlink_start)
6757 ++ goto found;
6758 ++ }
6759 ++ break;
6760 ++found:
6761 ++ entry->state = unlink_start;
6762 + urb = entry->urb;
6763 +
6764 + /*
6765 +@@ -1037,8 +1061,7 @@ static void tx_complete (struct urb *urb)
6766 + }
6767 +
6768 + usb_autopm_put_interface_async(dev->intf);
6769 +- entry->state = tx_done;
6770 +- defer_bh(dev, skb, &dev->txq);
6771 ++ (void) defer_bh(dev, skb, &dev->txq, tx_done);
6772 + }
6773 +
6774 + /*-------------------------------------------------------------------------*/
6775 +@@ -1094,7 +1117,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
6776 + entry = (struct skb_data *) skb->cb;
6777 + entry->urb = urb;
6778 + entry->dev = dev;
6779 +- entry->state = tx_start;
6780 + entry->length = length;
6781 +
6782 + usb_fill_bulk_urb (urb, dev->udev, dev->out,
6783 +@@ -1153,7 +1175,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
6784 + break;
6785 + case 0:
6786 + net->trans_start = jiffies;
6787 +- __skb_queue_tail (&dev->txq, skb);
6788 ++ __usbnet_queue_skb(&dev->txq, skb, tx_start);
6789 + if (dev->txq.qlen >= TX_QLEN (dev))
6790 + netif_stop_queue (net);
6791 + }
6792 +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
6793 +index 7f27dbd..0515862 100644
6794 +--- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
6795 ++++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
6796 +@@ -1053,17 +1053,13 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
6797 + }
6798 + /* either retransmit or send bar if ack not recd */
6799 + if (!ack_recd) {
6800 +- struct ieee80211_tx_rate *txrate =
6801 +- tx_info->status.rates;
6802 +- if (retry && (txrate[0].count < (int)retry_limit)) {
6803 ++ if (retry && (ini->txretry[index] < (int)retry_limit)) {
6804 + ini->txretry[index]++;
6805 + ini->tx_in_transit--;
6806 + /*
6807 + * Use high prededence for retransmit to
6808 + * give some punch
6809 + */
6810 +- /* brcms_c_txq_enq(wlc, scb, p,
6811 +- * BRCMS_PRIO_TO_PREC(tid)); */
6812 + brcms_c_txq_enq(wlc, scb, p,
6813 + BRCMS_PRIO_TO_HI_PREC(tid));
6814 + } else {
6815 +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
6816 +index f98becc..833cbef 100644
6817 +--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
6818 ++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
6819 +@@ -7879,7 +7879,7 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
6820 + if (wlc->hw->suspended_fifos) {
6821 + hdr = (struct ieee80211_hdr *)p->data;
6822 + if (ieee80211_is_beacon(hdr->frame_control))
6823 +- brcms_b_mute(wlc->hw, false);
6824 ++ brcms_b_mute(wlc->hw, false, 0);
6825 + }
6826 +
6827 + memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
6828 +diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
6829 +index 6176129..8cba82d 100644
6830 +--- a/drivers/regulator/max8997.c
6831 ++++ b/drivers/regulator/max8997.c
6832 +@@ -689,7 +689,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
6833 + }
6834 +
6835 + new_val++;
6836 +- } while (desc->min + desc->step + new_val <= desc->max);
6837 ++ } while (desc->min + desc->step * new_val <= desc->max);
6838 +
6839 + new_idx = tmp_idx;
6840 + new_val = tmp_val;
6841 +diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
6842 +index 54b9d2e..1590dbd 100644
6843 +--- a/drivers/spi/spi-topcliff-pch.c
6844 ++++ b/drivers/spi/spi-topcliff-pch.c
6845 +@@ -196,6 +196,7 @@ struct pch_spi_data {
6846 + struct pch_spi_dma_ctrl dma;
6847 + int use_dma;
6848 + u8 irq_reg_sts;
6849 ++ int save_total_len;
6850 + };
6851 +
6852 + /**
6853 +@@ -823,11 +824,13 @@ static void pch_spi_copy_rx_data_for_dma(struct pch_spi_data *data, int bpw)
6854 + rx_dma_buf = data->dma.rx_buf_virt;
6855 + for (j = 0; j < data->bpw_len; j++)
6856 + *rx_buf++ = *rx_dma_buf++ & 0xFF;
6857 ++ data->cur_trans->rx_buf = rx_buf;
6858 + } else {
6859 + rx_sbuf = data->cur_trans->rx_buf;
6860 + rx_dma_sbuf = data->dma.rx_buf_virt;
6861 + for (j = 0; j < data->bpw_len; j++)
6862 + *rx_sbuf++ = *rx_dma_sbuf++;
6863 ++ data->cur_trans->rx_buf = rx_sbuf;
6864 + }
6865 + }
6866 +
6867 +@@ -853,6 +856,9 @@ static int pch_spi_start_transfer(struct pch_spi_data *data)
6868 + rtn = wait_event_interruptible_timeout(data->wait,
6869 + data->transfer_complete,
6870 + msecs_to_jiffies(2 * HZ));
6871 ++ if (!rtn)
6872 ++ dev_err(&data->master->dev,
6873 ++ "%s wait-event timeout\n", __func__);
6874 +
6875 + dma_sync_sg_for_cpu(&data->master->dev, dma->sg_rx_p, dma->nent,
6876 + DMA_FROM_DEVICE);
6877 +@@ -924,7 +930,8 @@ static void pch_spi_request_dma(struct pch_spi_data *data, int bpw)
6878 + dma_cap_set(DMA_SLAVE, mask);
6879 +
6880 + /* Get DMA's dev information */
6881 +- dma_dev = pci_get_bus_and_slot(2, PCI_DEVFN(12, 0));
6882 ++ dma_dev = pci_get_bus_and_slot(data->board_dat->pdev->bus->number,
6883 ++ PCI_DEVFN(12, 0));
6884 +
6885 + /* Set Tx DMA */
6886 + param = &dma->param_tx;
6887 +@@ -988,6 +995,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
6888 + int i;
6889 + int size;
6890 + int rem;
6891 ++ int head;
6892 + unsigned long flags;
6893 + struct pch_spi_dma_ctrl *dma;
6894 +
6895 +@@ -1016,6 +1024,11 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
6896 + }
6897 + data->bpw_len = data->cur_trans->len / (*bpw / 8);
6898 +
6899 ++ if (data->bpw_len > PCH_BUF_SIZE) {
6900 ++ data->bpw_len = PCH_BUF_SIZE;
6901 ++ data->cur_trans->len -= PCH_BUF_SIZE;
6902 ++ }
6903 ++
6904 + /* copy Tx Data */
6905 + if (data->cur_trans->tx_buf != NULL) {
6906 + if (*bpw == 8) {
6907 +@@ -1030,10 +1043,17 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
6908 + *tx_dma_sbuf++ = *tx_sbuf++;
6909 + }
6910 + }
6911 ++
6912 ++ /* Calculate Rx parameter for DMA transmitting */
6913 + if (data->bpw_len > PCH_DMA_TRANS_SIZE) {
6914 +- num = data->bpw_len / PCH_DMA_TRANS_SIZE + 1;
6915 ++ if (data->bpw_len % PCH_DMA_TRANS_SIZE) {
6916 ++ num = data->bpw_len / PCH_DMA_TRANS_SIZE + 1;
6917 ++ rem = data->bpw_len % PCH_DMA_TRANS_SIZE;
6918 ++ } else {
6919 ++ num = data->bpw_len / PCH_DMA_TRANS_SIZE;
6920 ++ rem = PCH_DMA_TRANS_SIZE;
6921 ++ }
6922 + size = PCH_DMA_TRANS_SIZE;
6923 +- rem = data->bpw_len % PCH_DMA_TRANS_SIZE;
6924 + } else {
6925 + num = 1;
6926 + size = data->bpw_len;
6927 +@@ -1093,15 +1113,23 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
6928 + dma->nent = num;
6929 + dma->desc_rx = desc_rx;
6930 +
6931 +- /* TX */
6932 +- if (data->bpw_len > PCH_DMA_TRANS_SIZE) {
6933 +- num = data->bpw_len / PCH_DMA_TRANS_SIZE;
6934 ++ /* Calculate Tx parameter for DMA transmitting */
6935 ++ if (data->bpw_len > PCH_MAX_FIFO_DEPTH) {
6936 ++ head = PCH_MAX_FIFO_DEPTH - PCH_DMA_TRANS_SIZE;
6937 ++ if (data->bpw_len % PCH_DMA_TRANS_SIZE > 4) {
6938 ++ num = data->bpw_len / PCH_DMA_TRANS_SIZE + 1;
6939 ++ rem = data->bpw_len % PCH_DMA_TRANS_SIZE - head;
6940 ++ } else {
6941 ++ num = data->bpw_len / PCH_DMA_TRANS_SIZE;
6942 ++ rem = data->bpw_len % PCH_DMA_TRANS_SIZE +
6943 ++ PCH_DMA_TRANS_SIZE - head;
6944 ++ }
6945 + size = PCH_DMA_TRANS_SIZE;
6946 +- rem = 16;
6947 + } else {
6948 + num = 1;
6949 + size = data->bpw_len;
6950 + rem = data->bpw_len;
6951 ++ head = 0;
6952 + }
6953 +
6954 + dma->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
6955 +@@ -1111,11 +1139,17 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
6956 + for (i = 0; i < num; i++, sg++) {
6957 + if (i == 0) {
6958 + sg->offset = 0;
6959 ++ sg_set_page(sg, virt_to_page(dma->tx_buf_virt), size + head,
6960 ++ sg->offset);
6961 ++ sg_dma_len(sg) = size + head;
6962 ++ } else if (i == (num - 1)) {
6963 ++ sg->offset = head + size * i;
6964 ++ sg->offset = sg->offset * (*bpw / 8);
6965 + sg_set_page(sg, virt_to_page(dma->tx_buf_virt), rem,
6966 + sg->offset);
6967 + sg_dma_len(sg) = rem;
6968 + } else {
6969 +- sg->offset = rem + size * (i - 1);
6970 ++ sg->offset = head + size * i;
6971 + sg->offset = sg->offset * (*bpw / 8);
6972 + sg_set_page(sg, virt_to_page(dma->tx_buf_virt), size,
6973 + sg->offset);
6974 +@@ -1203,6 +1237,7 @@ static void pch_spi_process_messages(struct work_struct *pwork)
6975 + data->current_msg->spi->bits_per_word);
6976 + pch_spi_writereg(data->master, PCH_SSNXCR, SSN_NO_CONTROL);
6977 + do {
6978 ++ int cnt;
6979 + /* If we are already processing a message get the next
6980 + transfer structure from the message otherwise retrieve
6981 + the 1st transfer request from the message. */
6982 +@@ -1222,11 +1257,28 @@ static void pch_spi_process_messages(struct work_struct *pwork)
6983 + }
6984 + spin_unlock(&data->lock);
6985 +
6986 ++ if (!data->cur_trans->len)
6987 ++ goto out;
6988 ++ cnt = (data->cur_trans->len - 1) / PCH_BUF_SIZE + 1;
6989 ++ data->save_total_len = data->cur_trans->len;
6990 + if (data->use_dma) {
6991 +- pch_spi_handle_dma(data, &bpw);
6992 +- if (!pch_spi_start_transfer(data))
6993 +- goto out;
6994 +- pch_spi_copy_rx_data_for_dma(data, bpw);
6995 ++ int i;
6996 ++ char *save_rx_buf = data->cur_trans->rx_buf;
6997 ++ for (i = 0; i < cnt; i ++) {
6998 ++ pch_spi_handle_dma(data, &bpw);
6999 ++ if (!pch_spi_start_transfer(data)) {
7000 ++ data->transfer_complete = true;
7001 ++ data->current_msg->status = -EIO;
7002 ++ data->current_msg->complete
7003 ++ (data->current_msg->context);
7004 ++ data->bcurrent_msg_processing = false;
7005 ++ data->current_msg = NULL;
7006 ++ data->cur_trans = NULL;
7007 ++ goto out;
7008 ++ }
7009 ++ pch_spi_copy_rx_data_for_dma(data, bpw);
7010 ++ }
7011 ++ data->cur_trans->rx_buf = save_rx_buf;
7012 + } else {
7013 + pch_spi_set_tx(data, &bpw);
7014 + pch_spi_set_ir(data);
7015 +@@ -1237,6 +1289,7 @@ static void pch_spi_process_messages(struct work_struct *pwork)
7016 + data->pkt_tx_buff = NULL;
7017 + }
7018 + /* increment message count */
7019 ++ data->cur_trans->len = data->save_total_len;
7020 + data->current_msg->actual_length += data->cur_trans->len;
7021 +
7022 + dev_dbg(&data->master->dev,
7023 +@@ -1389,6 +1442,7 @@ static int __devinit pch_spi_pd_probe(struct platform_device *plat_dev)
7024 + master->num_chipselect = PCH_MAX_CS;
7025 + master->setup = pch_spi_setup;
7026 + master->transfer = pch_spi_transfer;
7027 ++ master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
7028 +
7029 + data->board_dat = board_dat;
7030 + data->plat_dev = plat_dev;
7031 +diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
7032 +index b4864fb..cad8b92 100644
7033 +--- a/drivers/target/target_core_file.c
7034 ++++ b/drivers/target/target_core_file.c
7035 +@@ -170,6 +170,7 @@ static struct se_device *fd_create_virtdevice(
7036 + inode = file->f_mapping->host;
7037 + if (S_ISBLK(inode->i_mode)) {
7038 + struct request_queue *q;
7039 ++ unsigned long long dev_size;
7040 + /*
7041 + * Setup the local scope queue_limits from struct request_queue->limits
7042 + * to pass into transport_add_device_to_core_hba() as struct se_dev_limits.
7043 +@@ -184,13 +185,12 @@ static struct se_device *fd_create_virtdevice(
7044 + * one (1) logical sector from underlying struct block_device
7045 + */
7046 + fd_dev->fd_block_size = bdev_logical_block_size(inode->i_bdev);
7047 +- fd_dev->fd_dev_size = (i_size_read(file->f_mapping->host) -
7048 ++ dev_size = (i_size_read(file->f_mapping->host) -
7049 + fd_dev->fd_block_size);
7050 +
7051 + pr_debug("FILEIO: Using size: %llu bytes from struct"
7052 + " block_device blocks: %llu logical_block_size: %d\n",
7053 +- fd_dev->fd_dev_size,
7054 +- div_u64(fd_dev->fd_dev_size, fd_dev->fd_block_size),
7055 ++ dev_size, div_u64(dev_size, fd_dev->fd_block_size),
7056 + fd_dev->fd_block_size);
7057 + } else {
7058 + if (!(fd_dev->fbd_flags & FBDF_HAS_SIZE)) {
7059 +@@ -606,10 +606,20 @@ static u32 fd_get_device_type(struct se_device *dev)
7060 + static sector_t fd_get_blocks(struct se_device *dev)
7061 + {
7062 + struct fd_dev *fd_dev = dev->dev_ptr;
7063 +- unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size,
7064 +- dev->se_sub_dev->se_dev_attrib.block_size);
7065 ++ struct file *f = fd_dev->fd_file;
7066 ++ struct inode *i = f->f_mapping->host;
7067 ++ unsigned long long dev_size;
7068 ++ /*
7069 ++ * When using a file that references an underlying struct block_device,
7070 ++ * ensure dev_size is always based on the current inode size in order
7071 ++ * to handle underlying block_device resize operations.
7072 ++ */
7073 ++ if (S_ISBLK(i->i_mode))
7074 ++ dev_size = (i_size_read(i) - fd_dev->fd_block_size);
7075 ++ else
7076 ++ dev_size = fd_dev->fd_dev_size;
7077 +
7078 +- return blocks_long;
7079 ++ return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size);
7080 + }
7081 +
7082 + static struct se_subsystem_api fileio_template = {
7083 +diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
7084 +index 6cf6ff4..b75bc92 100644
7085 +--- a/drivers/target/target_core_pr.c
7086 ++++ b/drivers/target/target_core_pr.c
7087 +@@ -223,6 +223,9 @@ int target_scsi2_reservation_release(struct se_task *task)
7088 + if (dev->dev_reserved_node_acl != sess->se_node_acl)
7089 + goto out_unlock;
7090 +
7091 ++ if (dev->dev_res_bin_isid != sess->sess_bin_isid)
7092 ++ goto out_unlock;
7093 ++
7094 + dev->dev_reserved_node_acl = NULL;
7095 + dev->dev_flags &= ~DF_SPC2_RESERVATIONS;
7096 + if (dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID) {
7097 +diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
7098 +index 8ddd133..d91fe44 100644
7099 +--- a/drivers/target/target_core_tpg.c
7100 ++++ b/drivers/target/target_core_tpg.c
7101 +@@ -63,7 +63,6 @@ static void core_clear_initiator_node_from_tpg(
7102 + int i;
7103 + struct se_dev_entry *deve;
7104 + struct se_lun *lun;
7105 +- struct se_lun_acl *acl, *acl_tmp;
7106 +
7107 + spin_lock_irq(&nacl->device_list_lock);
7108 + for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
7109 +@@ -84,28 +83,7 @@ static void core_clear_initiator_node_from_tpg(
7110 + core_update_device_list_for_node(lun, NULL, deve->mapped_lun,
7111 + TRANSPORT_LUNFLAGS_NO_ACCESS, nacl, tpg, 0);
7112 +
7113 +- spin_lock(&lun->lun_acl_lock);
7114 +- list_for_each_entry_safe(acl, acl_tmp,
7115 +- &lun->lun_acl_list, lacl_list) {
7116 +- if (!strcmp(acl->initiatorname, nacl->initiatorname) &&
7117 +- (acl->mapped_lun == deve->mapped_lun))
7118 +- break;
7119 +- }
7120 +-
7121 +- if (!acl) {
7122 +- pr_err("Unable to locate struct se_lun_acl for %s,"
7123 +- " mapped_lun: %u\n", nacl->initiatorname,
7124 +- deve->mapped_lun);
7125 +- spin_unlock(&lun->lun_acl_lock);
7126 +- spin_lock_irq(&nacl->device_list_lock);
7127 +- continue;
7128 +- }
7129 +-
7130 +- list_del(&acl->lacl_list);
7131 +- spin_unlock(&lun->lun_acl_lock);
7132 +-
7133 + spin_lock_irq(&nacl->device_list_lock);
7134 +- kfree(acl);
7135 + }
7136 + spin_unlock_irq(&nacl->device_list_lock);
7137 + }
7138 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
7139 +index 93a00d8..4410ae7 100644
7140 +--- a/fs/ext4/xattr.c
7141 ++++ b/fs/ext4/xattr.c
7142 +@@ -487,18 +487,19 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
7143 + ext4_free_blocks(handle, inode, bh, 0, 1,
7144 + EXT4_FREE_BLOCKS_METADATA |
7145 + EXT4_FREE_BLOCKS_FORGET);
7146 ++ unlock_buffer(bh);
7147 + } else {
7148 + le32_add_cpu(&BHDR(bh)->h_refcount, -1);
7149 ++ if (ce)
7150 ++ mb_cache_entry_release(ce);
7151 ++ unlock_buffer(bh);
7152 + error = ext4_handle_dirty_metadata(handle, inode, bh);
7153 + if (IS_SYNC(inode))
7154 + ext4_handle_sync(handle);
7155 + dquot_free_block(inode, 1);
7156 + ea_bdebug(bh, "refcount now=%d; releasing",
7157 + le32_to_cpu(BHDR(bh)->h_refcount));
7158 +- if (ce)
7159 +- mb_cache_entry_release(ce);
7160 + }
7161 +- unlock_buffer(bh);
7162 + out:
7163 + ext4_std_error(inode->i_sb, error);
7164 + return;
7165 +diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
7166 +index 31dce61..4bbd521 100644
7167 +--- a/fs/jffs2/gc.c
7168 ++++ b/fs/jffs2/gc.c
7169 +@@ -225,8 +225,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
7170 + return 0;
7171 +
7172 + D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n"));
7173 +- spin_lock(&c->erase_completion_lock);
7174 + mutex_lock(&c->alloc_sem);
7175 ++ spin_lock(&c->erase_completion_lock);
7176 + }
7177 +
7178 + /* First, work out which block we're garbage-collecting */
7179 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
7180 +index 51f6a40..bab7c58 100644
7181 +--- a/fs/nfs/nfs4proc.c
7182 ++++ b/fs/nfs/nfs4proc.c
7183 +@@ -1802,6 +1802,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, fmode_t fmode
7184 + nfs_setattr_update_inode(state->inode, sattr);
7185 + nfs_post_op_update_inode(state->inode, opendata->o_res.f_attr);
7186 + }
7187 ++ nfs_revalidate_inode(server, state->inode);
7188 + nfs4_opendata_put(opendata);
7189 + nfs4_put_state_owner(sp);
7190 + *res = state;
7191 +diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
7192 +index a9e6ba4..daad4e6 100644
7193 +--- a/include/linux/mtd/map.h
7194 ++++ b/include/linux/mtd/map.h
7195 +@@ -26,7 +26,7 @@
7196 + #include <linux/list.h>
7197 + #include <linux/string.h>
7198 + #include <linux/bug.h>
7199 +-
7200 ++#include <linux/kernel.h>
7201 +
7202 + #include <asm/unaligned.h>
7203 + #include <asm/system.h>
7204 +diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
7205 +index 605b0aa..76f4396 100644
7206 +--- a/include/linux/usb/usbnet.h
7207 ++++ b/include/linux/usb/usbnet.h
7208 +@@ -191,7 +191,8 @@ extern void usbnet_cdc_status(struct usbnet *, struct urb *);
7209 + enum skb_state {
7210 + illegal = 0,
7211 + tx_start, tx_done,
7212 +- rx_start, rx_done, rx_cleanup
7213 ++ rx_start, rx_done, rx_cleanup,
7214 ++ unlink_start
7215 + };
7216 +
7217 + struct skb_data { /* skb->cb is one of these */
7218 +diff --git a/kernel/fork.c b/kernel/fork.c
7219 +index 0acf42c0..26f1ab0 100644
7220 +--- a/kernel/fork.c
7221 ++++ b/kernel/fork.c
7222 +@@ -47,6 +47,7 @@
7223 + #include <linux/audit.h>
7224 + #include <linux/memcontrol.h>
7225 + #include <linux/ftrace.h>
7226 ++#include <linux/proc_fs.h>
7227 + #include <linux/profile.h>
7228 + #include <linux/rmap.h>
7229 + #include <linux/ksm.h>
7230 +@@ -1387,6 +1388,8 @@ bad_fork_cleanup_io:
7231 + if (p->io_context)
7232 + exit_io_context(p);
7233 + bad_fork_cleanup_namespaces:
7234 ++ if (unlikely(clone_flags & CLONE_NEWPID))
7235 ++ pid_ns_release_proc(p->nsproxy->pid_ns);
7236 + exit_task_namespaces(p);
7237 + bad_fork_cleanup_mm:
7238 + if (p->mm)
7239 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
7240 +index bd936ed..7120c2e 100644
7241 +--- a/mm/hugetlb.c
7242 ++++ b/mm/hugetlb.c
7243 +@@ -2405,7 +2405,6 @@ retry_avoidcopy:
7244 + if (outside_reserve) {
7245 + BUG_ON(huge_pte_none(pte));
7246 + if (unmap_ref_private(mm, vma, old_page, address)) {
7247 +- BUG_ON(page_count(old_page) != 1);
7248 + BUG_ON(huge_pte_none(pte));
7249 + spin_lock(&mm->page_table_lock);
7250 + goto retry_avoidcopy;
7251 +diff --git a/mm/nobootmem.c b/mm/nobootmem.c
7252 +index 7fa41b4..07c08c4 100644
7253 +--- a/mm/nobootmem.c
7254 ++++ b/mm/nobootmem.c
7255 +@@ -83,8 +83,7 @@ void __init free_bootmem_late(unsigned long addr, unsigned long size)
7256 +
7257 + static void __init __free_pages_memory(unsigned long start, unsigned long end)
7258 + {
7259 +- int i;
7260 +- unsigned long start_aligned, end_aligned;
7261 ++ unsigned long i, start_aligned, end_aligned;
7262 + int order = ilog2(BITS_PER_LONG);
7263 +
7264 + start_aligned = (start + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 1);
7265 +diff --git a/mm/percpu.c b/mm/percpu.c
7266 +index 716eb4a..5c29750 100644
7267 +--- a/mm/percpu.c
7268 ++++ b/mm/percpu.c
7269 +@@ -1642,6 +1642,16 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
7270 + areas[group] = ptr;
7271 +
7272 + base = min(ptr, base);
7273 ++ }
7274 ++
7275 ++ /*
7276 ++ * Copy data and free unused parts. This should happen after all
7277 ++ * allocations are complete; otherwise, we may end up with
7278 ++ * overlapping groups.
7279 ++ */
7280 ++ for (group = 0; group < ai->nr_groups; group++) {
7281 ++ struct pcpu_group_info *gi = &ai->groups[group];
7282 ++ void *ptr = areas[group];
7283 +
7284 + for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) {
7285 + if (gi->cpu_map[i] == NR_CPUS) {
7286 +diff --git a/net/core/dev.c b/net/core/dev.c
7287 +index cd5050e..61a7baa 100644
7288 +--- a/net/core/dev.c
7289 ++++ b/net/core/dev.c
7290 +@@ -1421,14 +1421,34 @@ EXPORT_SYMBOL(register_netdevice_notifier);
7291 + * register_netdevice_notifier(). The notifier is unlinked into the
7292 + * kernel structures and may then be reused. A negative errno code
7293 + * is returned on a failure.
7294 ++ *
7295 ++ * After unregistering unregister and down device events are synthesized
7296 ++ * for all devices on the device list to the removed notifier to remove
7297 ++ * the need for special case cleanup code.
7298 + */
7299 +
7300 + int unregister_netdevice_notifier(struct notifier_block *nb)
7301 + {
7302 ++ struct net_device *dev;
7303 ++ struct net *net;
7304 + int err;
7305 +
7306 + rtnl_lock();
7307 + err = raw_notifier_chain_unregister(&netdev_chain, nb);
7308 ++ if (err)
7309 ++ goto unlock;
7310 ++
7311 ++ for_each_net(net) {
7312 ++ for_each_netdev(net, dev) {
7313 ++ if (dev->flags & IFF_UP) {
7314 ++ nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
7315 ++ nb->notifier_call(nb, NETDEV_DOWN, dev);
7316 ++ }
7317 ++ nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
7318 ++ nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
7319 ++ }
7320 ++ }
7321 ++unlock:
7322 + rtnl_unlock();
7323 + return err;
7324 + }
7325 +diff --git a/net/core/pktgen.c b/net/core/pktgen.c
7326 +index 0001c24..df878de 100644
7327 +--- a/net/core/pktgen.c
7328 ++++ b/net/core/pktgen.c
7329 +@@ -1932,7 +1932,7 @@ static int pktgen_device_event(struct notifier_block *unused,
7330 + {
7331 + struct net_device *dev = ptr;
7332 +
7333 +- if (!net_eq(dev_net(dev), &init_net))
7334 ++ if (!net_eq(dev_net(dev), &init_net) || pktgen_exiting)
7335 + return NOTIFY_DONE;
7336 +
7337 + /* It is OK that we do not hold the group lock right now,
7338 +@@ -3758,12 +3758,18 @@ static void __exit pg_cleanup(void)
7339 + {
7340 + struct pktgen_thread *t;
7341 + struct list_head *q, *n;
7342 ++ LIST_HEAD(list);
7343 +
7344 + /* Stop all interfaces & threads */
7345 + pktgen_exiting = true;
7346 +
7347 +- list_for_each_safe(q, n, &pktgen_threads) {
7348 ++ mutex_lock(&pktgen_thread_lock);
7349 ++ list_splice_init(&pktgen_threads, &list);
7350 ++ mutex_unlock(&pktgen_thread_lock);
7351 ++
7352 ++ list_for_each_safe(q, n, &list) {
7353 + t = list_entry(q, struct pktgen_thread, th_list);
7354 ++ list_del(&t->th_list);
7355 + kthread_stop(t->tsk);
7356 + kfree(t);
7357 + }
7358 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
7359 +index 7904db4..11ba922 100644
7360 +--- a/net/ipv4/tcp.c
7361 ++++ b/net/ipv4/tcp.c
7362 +@@ -851,8 +851,7 @@ new_segment:
7363 + wait_for_sndbuf:
7364 + set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
7365 + wait_for_memory:
7366 +- if (copied)
7367 +- tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
7368 ++ tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
7369 +
7370 + if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
7371 + goto do_error;
7372 +@@ -3216,7 +3215,7 @@ void __init tcp_init(void)
7373 + {
7374 + struct sk_buff *skb = NULL;
7375 + unsigned long limit;
7376 +- int i, max_share, cnt;
7377 ++ int i, max_rshare, max_wshare, cnt;
7378 + unsigned long jiffy = jiffies;
7379 +
7380 + BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));
7381 +@@ -3280,15 +3279,16 @@ void __init tcp_init(void)
7382 +
7383 + /* Set per-socket limits to no more than 1/128 the pressure threshold */
7384 + limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
7385 +- max_share = min(4UL*1024*1024, limit);
7386 ++ max_wshare = min(4UL*1024*1024, limit);
7387 ++ max_rshare = min(6UL*1024*1024, limit);
7388 +
7389 + sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
7390 + sysctl_tcp_wmem[1] = 16*1024;
7391 +- sysctl_tcp_wmem[2] = max(64*1024, max_share);
7392 ++ sysctl_tcp_wmem[2] = max(64*1024, max_wshare);
7393 +
7394 + sysctl_tcp_rmem[0] = SK_MEM_QUANTUM;
7395 + sysctl_tcp_rmem[1] = 87380;
7396 +- sysctl_tcp_rmem[2] = max(87380, max_share);
7397 ++ sysctl_tcp_rmem[2] = max(87380, max_rshare);
7398 +
7399 + printk(KERN_INFO "TCP: Hash tables configured "
7400 + "(established %u bind %u)\n",
7401 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
7402 +index daedc07..9726927 100644
7403 +--- a/net/ipv4/tcp_input.c
7404 ++++ b/net/ipv4/tcp_input.c
7405 +@@ -83,7 +83,7 @@ int sysctl_tcp_ecn __read_mostly = 2;
7406 + EXPORT_SYMBOL(sysctl_tcp_ecn);
7407 + int sysctl_tcp_dsack __read_mostly = 1;
7408 + int sysctl_tcp_app_win __read_mostly = 31;
7409 +-int sysctl_tcp_adv_win_scale __read_mostly = 2;
7410 ++int sysctl_tcp_adv_win_scale __read_mostly = 1;
7411 + EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);
7412 +
7413 + int sysctl_tcp_stdurg __read_mostly;
7414 +@@ -2868,11 +2868,14 @@ static inline void tcp_complete_cwr(struct sock *sk)
7415 +
7416 + /* Do not moderate cwnd if it's already undone in cwr or recovery. */
7417 + if (tp->undo_marker) {
7418 +- if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR)
7419 ++ if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR) {
7420 + tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh);
7421 +- else /* PRR */
7422 ++ tp->snd_cwnd_stamp = tcp_time_stamp;
7423 ++ } else if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH) {
7424 ++ /* PRR algorithm. */
7425 + tp->snd_cwnd = tp->snd_ssthresh;
7426 +- tp->snd_cwnd_stamp = tcp_time_stamp;
7427 ++ tp->snd_cwnd_stamp = tcp_time_stamp;
7428 ++ }
7429 + }
7430 + tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR);
7431 + }
7432 +diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
7433 +index 55670ec..2a2a3e7 100644
7434 +--- a/net/l2tp/l2tp_ip.c
7435 ++++ b/net/l2tp/l2tp_ip.c
7436 +@@ -441,8 +441,9 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
7437 +
7438 + daddr = lip->l2tp_addr.s_addr;
7439 + } else {
7440 ++ rc = -EDESTADDRREQ;
7441 + if (sk->sk_state != TCP_ESTABLISHED)
7442 +- return -EDESTADDRREQ;
7443 ++ goto out;
7444 +
7445 + daddr = inet->inet_daddr;
7446 + connected = 1;
7447 +diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
7448 +index 7801b15..a489d8b 100644
7449 +--- a/net/sched/sch_netem.c
7450 ++++ b/net/sched/sch_netem.c
7451 +@@ -351,10 +351,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
7452 + if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
7453 + if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
7454 + (skb->ip_summed == CHECKSUM_PARTIAL &&
7455 +- skb_checksum_help(skb))) {
7456 +- sch->qstats.drops++;
7457 +- return NET_XMIT_DROP;
7458 +- }
7459 ++ skb_checksum_help(skb)))
7460 ++ return qdisc_drop(skb, sch);
7461 +
7462 + skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
7463 + }
7464 +diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
7465 +index 64417a7..d8c670c 100644
7466 +--- a/sound/pci/echoaudio/echoaudio_dsp.c
7467 ++++ b/sound/pci/echoaudio/echoaudio_dsp.c
7468 +@@ -475,7 +475,7 @@ static int load_firmware(struct echoaudio *chip)
7469 + const struct firmware *fw;
7470 + int box_type, err;
7471 +
7472 +- if (snd_BUG_ON(!chip->dsp_code_to_load || !chip->comm_page))
7473 ++ if (snd_BUG_ON(!chip->comm_page))
7474 + return -EPERM;
7475 +
7476 + /* See if the ASIC is present and working - only if the DSP is already loaded */
7477 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
7478 +index 192e6c0..53345bc 100644
7479 +--- a/sound/pci/hda/hda_intel.c
7480 ++++ b/sound/pci/hda/hda_intel.c
7481 +@@ -769,11 +769,13 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
7482 + {
7483 + struct azx *chip = bus->private_data;
7484 + unsigned long timeout;
7485 ++ unsigned long loopcounter;
7486 + int do_poll = 0;
7487 +
7488 + again:
7489 + timeout = jiffies + msecs_to_jiffies(1000);
7490 +- for (;;) {
7491 ++
7492 ++ for (loopcounter = 0;; loopcounter++) {
7493 + if (chip->polling_mode || do_poll) {
7494 + spin_lock_irq(&chip->reg_lock);
7495 + azx_update_rirb(chip);
7496 +@@ -789,7 +791,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
7497 + }
7498 + if (time_after(jiffies, timeout))
7499 + break;
7500 +- if (bus->needs_damn_long_delay)
7501 ++ if (bus->needs_damn_long_delay || loopcounter > 3000)
7502 + msleep(2); /* temporary workaround */
7503 + else {
7504 + udelay(10);
7505 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
7506 +index ed67698..7b7a516 100644
7507 +--- a/sound/pci/hda/patch_sigmatel.c
7508 ++++ b/sound/pci/hda/patch_sigmatel.c
7509 +@@ -4484,9 +4484,9 @@ static int stac92xx_init(struct hda_codec *codec)
7510 + def_conf = get_defcfg_connect(def_conf);
7511 + /* skip any ports that don't have jacks since presence
7512 + * detection is useless */
7513 +- if (def_conf != AC_JACK_PORT_COMPLEX) {
7514 +- if (def_conf != AC_JACK_PORT_NONE)
7515 +- stac_toggle_power_map(codec, nid, 1);
7516 ++ if (def_conf != AC_JACK_PORT_NONE &&
7517 ++ !is_jack_detectable(codec, nid)) {
7518 ++ stac_toggle_power_map(codec, nid, 1);
7519 + continue;
7520 + }
7521 + if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
7522 +diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
7523 +index 7806301..3e7aa22 100644
7524 +--- a/sound/soc/codecs/wm8994.c
7525 ++++ b/sound/soc/codecs/wm8994.c
7526 +@@ -1027,7 +1027,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
7527 + snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
7528 + WM8994_AIF2DACL_ENA |
7529 + WM8994_AIF2DACR_ENA, 0);
7530 +- snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
7531 ++ snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
7532 + WM8994_AIF2ADCL_ENA |
7533 + WM8994_AIF2ADCR_ENA, 0);
7534 +
7535
7536 Added: genpatches-2.6/trunk/3.2/1018_linux-3.2.19.patch
7537 ===================================================================
7538 --- genpatches-2.6/trunk/3.2/1018_linux-3.2.19.patch (rev 0)
7539 +++ genpatches-2.6/trunk/3.2/1018_linux-3.2.19.patch 2012-06-06 00:46:35 UTC (rev 2150)
7540 @@ -0,0 +1,4857 @@
7541 +diff --git a/Documentation/HOWTO b/Documentation/HOWTO
7542 +index f7ade3b..59c080f 100644
7543 +--- a/Documentation/HOWTO
7544 ++++ b/Documentation/HOWTO
7545 +@@ -218,16 +218,16 @@ The development process
7546 + Linux kernel development process currently consists of a few different
7547 + main kernel "branches" and lots of different subsystem-specific kernel
7548 + branches. These different branches are:
7549 +- - main 2.6.x kernel tree
7550 +- - 2.6.x.y -stable kernel tree
7551 +- - 2.6.x -git kernel patches
7552 ++ - main 3.x kernel tree
7553 ++ - 3.x.y -stable kernel tree
7554 ++ - 3.x -git kernel patches
7555 + - subsystem specific kernel trees and patches
7556 +- - the 2.6.x -next kernel tree for integration tests
7557 ++ - the 3.x -next kernel tree for integration tests
7558 +
7559 +-2.6.x kernel tree
7560 ++3.x kernel tree
7561 + -----------------
7562 +-2.6.x kernels are maintained by Linus Torvalds, and can be found on
7563 +-kernel.org in the pub/linux/kernel/v2.6/ directory. Its development
7564 ++3.x kernels are maintained by Linus Torvalds, and can be found on
7565 ++kernel.org in the pub/linux/kernel/v3.x/ directory. Its development
7566 + process is as follows:
7567 + - As soon as a new kernel is released a two weeks window is open,
7568 + during this period of time maintainers can submit big diffs to
7569 +@@ -262,20 +262,20 @@ mailing list about kernel releases:
7570 + released according to perceived bug status, not according to a
7571 + preconceived timeline."
7572 +
7573 +-2.6.x.y -stable kernel tree
7574 ++3.x.y -stable kernel tree
7575 + ---------------------------
7576 +-Kernels with 4-part versions are -stable kernels. They contain
7577 ++Kernels with 3-part versions are -stable kernels. They contain
7578 + relatively small and critical fixes for security problems or significant
7579 +-regressions discovered in a given 2.6.x kernel.
7580 ++regressions discovered in a given 3.x kernel.
7581 +
7582 + This is the recommended branch for users who want the most recent stable
7583 + kernel and are not interested in helping test development/experimental
7584 + versions.
7585 +
7586 +-If no 2.6.x.y kernel is available, then the highest numbered 2.6.x
7587 ++If no 3.x.y kernel is available, then the highest numbered 3.x
7588 + kernel is the current stable kernel.
7589 +
7590 +-2.6.x.y are maintained by the "stable" team <stable@×××××××××××.org>, and
7591 ++3.x.y are maintained by the "stable" team <stable@×××××××××××.org>, and
7592 + are released as needs dictate. The normal release period is approximately
7593 + two weeks, but it can be longer if there are no pressing problems. A
7594 + security-related problem, instead, can cause a release to happen almost
7595 +@@ -285,7 +285,7 @@ The file Documentation/stable_kernel_rules.txt in the kernel tree
7596 + documents what kinds of changes are acceptable for the -stable tree, and
7597 + how the release process works.
7598 +
7599 +-2.6.x -git patches
7600 ++3.x -git patches
7601 + ------------------
7602 + These are daily snapshots of Linus' kernel tree which are managed in a
7603 + git repository (hence the name.) These patches are usually released
7604 +@@ -317,13 +317,13 @@ revisions to it, and maintainers can mark patches as under review,
7605 + accepted, or rejected. Most of these patchwork sites are listed at
7606 + http://patchwork.kernel.org/.
7607 +
7608 +-2.6.x -next kernel tree for integration tests
7609 ++3.x -next kernel tree for integration tests
7610 + ---------------------------------------------
7611 +-Before updates from subsystem trees are merged into the mainline 2.6.x
7612 ++Before updates from subsystem trees are merged into the mainline 3.x
7613 + tree, they need to be integration-tested. For this purpose, a special
7614 + testing repository exists into which virtually all subsystem trees are
7615 + pulled on an almost daily basis:
7616 +- http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git
7617 ++ http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
7618 + http://linux.f-seidel.de/linux-next/pmwiki/
7619 +
7620 + This way, the -next kernel gives a summary outlook onto what will be
7621 +diff --git a/Makefile b/Makefile
7622 +index add68f1..c291184 100644
7623 +--- a/Makefile
7624 ++++ b/Makefile
7625 +@@ -1,6 +1,6 @@
7626 + VERSION = 3
7627 + PATCHLEVEL = 2
7628 +-SUBLEVEL = 18
7629 ++SUBLEVEL = 19
7630 + EXTRAVERSION =
7631 + NAME = Saber-toothed Squirrel
7632 +
7633 +@@ -442,7 +442,7 @@ asm-generic:
7634 +
7635 + no-dot-config-targets := clean mrproper distclean \
7636 + cscope gtags TAGS tags help %docs check% coccicheck \
7637 +- include/linux/version.h headers_% \
7638 ++ include/linux/version.h headers_% archscripts \
7639 + kernelversion %src-pkg
7640 +
7641 + config-targets := 0
7642 +@@ -979,7 +979,7 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
7643 + include/config/auto.conf
7644 + $(cmd_crmodverdir)
7645 +
7646 +-archprepare: prepare1 scripts_basic
7647 ++archprepare: archscripts prepare1 scripts_basic
7648 +
7649 + prepare0: archprepare FORCE
7650 + $(Q)$(MAKE) $(build)=.
7651 +@@ -1046,8 +1046,11 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
7652 + # If we do an all arch process set dst to asm-$(hdr-arch)
7653 + hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
7654 +
7655 ++PHONY += archscripts
7656 ++archscripts:
7657 ++
7658 + PHONY += __headers
7659 +-__headers: include/linux/version.h scripts_basic asm-generic FORCE
7660 ++__headers: include/linux/version.h scripts_basic asm-generic archscripts FORCE
7661 + $(Q)$(MAKE) $(build)=scripts build_unifdef
7662 +
7663 + PHONY += headers_install_all
7664 +diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
7665 +index d5d8d5c..1252a26 100644
7666 +--- a/arch/arm/include/asm/cacheflush.h
7667 ++++ b/arch/arm/include/asm/cacheflush.h
7668 +@@ -249,7 +249,7 @@ extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr
7669 + * Harvard caches are synchronised for the user space address range.
7670 + * This is used for the ARM private sys_cacheflush system call.
7671 + */
7672 +-#define flush_cache_user_range(vma,start,end) \
7673 ++#define flush_cache_user_range(start,end) \
7674 + __cpuc_coherent_user_range((start) & PAGE_MASK, PAGE_ALIGN(end))
7675 +
7676 + /*
7677 +diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
7678 +index 99a5727..160cb16 100644
7679 +--- a/arch/arm/kernel/traps.c
7680 ++++ b/arch/arm/kernel/traps.c
7681 +@@ -488,7 +488,9 @@ do_cache_op(unsigned long start, unsigned long end, int flags)
7682 + if (end > vma->vm_end)
7683 + end = vma->vm_end;
7684 +
7685 +- flush_cache_user_range(vma, start, end);
7686 ++ up_read(&mm->mmap_sem);
7687 ++ flush_cache_user_range(start, end);
7688 ++ return;
7689 + }
7690 + up_read(&mm->mmap_sem);
7691 + }
7692 +diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
7693 +index 43f4c92..7073185 100644
7694 +--- a/arch/ia64/kvm/kvm-ia64.c
7695 ++++ b/arch/ia64/kvm/kvm-ia64.c
7696 +@@ -1169,6 +1169,11 @@ out:
7697 +
7698 + #define PALE_RESET_ENTRY 0x80000000ffffffb0UL
7699 +
7700 ++bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
7701 ++{
7702 ++ return irqchip_in_kernel(vcpu->kcm) == (vcpu->arch.apic != NULL);
7703 ++}
7704 ++
7705 + int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
7706 + {
7707 + struct kvm_vcpu *v;
7708 +diff --git a/arch/parisc/include/asm/prefetch.h b/arch/parisc/include/asm/prefetch.h
7709 +index c5edc60..1ee7c82 100644
7710 +--- a/arch/parisc/include/asm/prefetch.h
7711 ++++ b/arch/parisc/include/asm/prefetch.h
7712 +@@ -21,7 +21,12 @@
7713 + #define ARCH_HAS_PREFETCH
7714 + static inline void prefetch(const void *addr)
7715 + {
7716 +- __asm__("ldw 0(%0), %%r0" : : "r" (addr));
7717 ++ __asm__(
7718 ++#ifndef CONFIG_PA20
7719 ++ /* Need to avoid prefetch of NULL on PA7300LC */
7720 ++ " extrw,u,= %0,31,32,%%r0\n"
7721 ++#endif
7722 ++ " ldw 0(%0), %%r0" : : "r" (addr));
7723 + }
7724 +
7725 + /* LDD is a PA2.0 addition. */
7726 +diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
7727 +index 6f05944..5350342 100644
7728 +--- a/arch/parisc/kernel/entry.S
7729 ++++ b/arch/parisc/kernel/entry.S
7730 +@@ -581,7 +581,11 @@
7731 + */
7732 + cmpiclr,= 0x01,\tmp,%r0
7733 + ldi (_PAGE_DIRTY|_PAGE_READ|_PAGE_WRITE),\prot
7734 ++#ifdef CONFIG_64BIT
7735 + depd,z \prot,8,7,\prot
7736 ++#else
7737 ++ depw,z \prot,8,7,\prot
7738 ++#endif
7739 + /*
7740 + * OK, it is in the temp alias region, check whether "from" or "to".
7741 + * Check "subtle" note in pacache.S re: r23/r26.
7742 +diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
7743 +index 93ff3d9..5d7218a 100644
7744 +--- a/arch/parisc/kernel/pacache.S
7745 ++++ b/arch/parisc/kernel/pacache.S
7746 +@@ -692,7 +692,7 @@ ENTRY(flush_icache_page_asm)
7747 +
7748 + /* Purge any old translation */
7749 +
7750 +- pitlb (%sr0,%r28)
7751 ++ pitlb (%sr4,%r28)
7752 +
7753 + ldil L%icache_stride, %r1
7754 + ldw R%icache_stride(%r1), %r1
7755 +@@ -706,27 +706,29 @@ ENTRY(flush_icache_page_asm)
7756 + sub %r25, %r1, %r25
7757 +
7758 +
7759 +-1: fic,m %r1(%r28)
7760 +- fic,m %r1(%r28)
7761 +- fic,m %r1(%r28)
7762 +- fic,m %r1(%r28)
7763 +- fic,m %r1(%r28)
7764 +- fic,m %r1(%r28)
7765 +- fic,m %r1(%r28)
7766 +- fic,m %r1(%r28)
7767 +- fic,m %r1(%r28)
7768 +- fic,m %r1(%r28)
7769 +- fic,m %r1(%r28)
7770 +- fic,m %r1(%r28)
7771 +- fic,m %r1(%r28)
7772 +- fic,m %r1(%r28)
7773 +- fic,m %r1(%r28)
7774 ++ /* fic only has the type 26 form on PA1.1, requiring an
7775 ++ * explicit space specification, so use %sr4 */
7776 ++1: fic,m %r1(%sr4,%r28)
7777 ++ fic,m %r1(%sr4,%r28)
7778 ++ fic,m %r1(%sr4,%r28)
7779 ++ fic,m %r1(%sr4,%r28)
7780 ++ fic,m %r1(%sr4,%r28)
7781 ++ fic,m %r1(%sr4,%r28)
7782 ++ fic,m %r1(%sr4,%r28)
7783 ++ fic,m %r1(%sr4,%r28)
7784 ++ fic,m %r1(%sr4,%r28)
7785 ++ fic,m %r1(%sr4,%r28)
7786 ++ fic,m %r1(%sr4,%r28)
7787 ++ fic,m %r1(%sr4,%r28)
7788 ++ fic,m %r1(%sr4,%r28)
7789 ++ fic,m %r1(%sr4,%r28)
7790 ++ fic,m %r1(%sr4,%r28)
7791 + cmpb,COND(<<) %r28, %r25,1b
7792 +- fic,m %r1(%r28)
7793 ++ fic,m %r1(%sr4,%r28)
7794 +
7795 + sync
7796 + bv %r0(%r2)
7797 +- pitlb (%sr0,%r25)
7798 ++ pitlb (%sr4,%r25)
7799 + .exit
7800 +
7801 + .procend
7802 +diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
7803 +index 0243454..a5f6eff 100644
7804 +--- a/arch/s390/kvm/intercept.c
7805 ++++ b/arch/s390/kvm/intercept.c
7806 +@@ -133,13 +133,6 @@ static int handle_stop(struct kvm_vcpu *vcpu)
7807 +
7808 + vcpu->stat.exit_stop_request++;
7809 + spin_lock_bh(&vcpu->arch.local_int.lock);
7810 +- if (vcpu->arch.local_int.action_bits & ACTION_STORE_ON_STOP) {
7811 +- vcpu->arch.local_int.action_bits &= ~ACTION_STORE_ON_STOP;
7812 +- rc = kvm_s390_vcpu_store_status(vcpu,
7813 +- KVM_S390_STORE_STATUS_NOADDR);
7814 +- if (rc >= 0)
7815 +- rc = -EOPNOTSUPP;
7816 +- }
7817 +
7818 + if (vcpu->arch.local_int.action_bits & ACTION_RELOADVCPU_ON_STOP) {
7819 + vcpu->arch.local_int.action_bits &= ~ACTION_RELOADVCPU_ON_STOP;
7820 +@@ -155,7 +148,18 @@ static int handle_stop(struct kvm_vcpu *vcpu)
7821 + rc = -EOPNOTSUPP;
7822 + }
7823 +
7824 +- spin_unlock_bh(&vcpu->arch.local_int.lock);
7825 ++ if (vcpu->arch.local_int.action_bits & ACTION_STORE_ON_STOP) {
7826 ++ vcpu->arch.local_int.action_bits &= ~ACTION_STORE_ON_STOP;
7827 ++ /* store status must be called unlocked. Since local_int.lock
7828 ++ * only protects local_int.* and not guest memory we can give
7829 ++ * up the lock here */
7830 ++ spin_unlock_bh(&vcpu->arch.local_int.lock);
7831 ++ rc = kvm_s390_vcpu_store_status(vcpu,
7832 ++ KVM_S390_STORE_STATUS_NOADDR);
7833 ++ if (rc >= 0)
7834 ++ rc = -EOPNOTSUPP;
7835 ++ } else
7836 ++ spin_unlock_bh(&vcpu->arch.local_int.lock);
7837 + return rc;
7838 + }
7839 +
7840 +diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
7841 +index d1c44573..d3cb86c 100644
7842 +--- a/arch/s390/kvm/kvm-s390.c
7843 ++++ b/arch/s390/kvm/kvm-s390.c
7844 +@@ -418,7 +418,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
7845 + int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
7846 + {
7847 + memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs));
7848 +- vcpu->arch.guest_fpregs.fpc = fpu->fpc;
7849 ++ vcpu->arch.guest_fpregs.fpc = fpu->fpc & FPC_VALID_MASK;
7850 + restore_fp_regs(&vcpu->arch.guest_fpregs);
7851 + return 0;
7852 + }
7853 +diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
7854 +index c7f0fbc..b28aaa4 100644
7855 +--- a/arch/s390/mm/fault.c
7856 ++++ b/arch/s390/mm/fault.c
7857 +@@ -583,6 +583,7 @@ static void pfault_interrupt(unsigned int ext_int_code,
7858 + tsk->thread.pfault_wait = 0;
7859 + list_del(&tsk->thread.list);
7860 + wake_up_process(tsk);
7861 ++ put_task_struct(tsk);
7862 + } else {
7863 + /* Completion interrupt was faster than initial
7864 + * interrupt. Set pfault_wait to -1 so the initial
7865 +@@ -597,14 +598,22 @@ static void pfault_interrupt(unsigned int ext_int_code,
7866 + put_task_struct(tsk);
7867 + } else {
7868 + /* signal bit not set -> a real page is missing. */
7869 +- if (tsk->thread.pfault_wait == -1) {
7870 ++ if (tsk->thread.pfault_wait == 1) {
7871 ++ /* Already on the list with a reference: put to sleep */
7872 ++ set_task_state(tsk, TASK_UNINTERRUPTIBLE);
7873 ++ set_tsk_need_resched(tsk);
7874 ++ } else if (tsk->thread.pfault_wait == -1) {
7875 + /* Completion interrupt was faster than the initial
7876 + * interrupt (pfault_wait == -1). Set pfault_wait
7877 + * back to zero and exit. */
7878 + tsk->thread.pfault_wait = 0;
7879 + } else {
7880 + /* Initial interrupt arrived before completion
7881 +- * interrupt. Let the task sleep. */
7882 ++ * interrupt. Let the task sleep.
7883 ++ * An extra task reference is needed since a different
7884 ++ * cpu may set the task state to TASK_RUNNING again
7885 ++ * before the scheduler is reached. */
7886 ++ get_task_struct(tsk);
7887 + tsk->thread.pfault_wait = 1;
7888 + list_add(&tsk->thread.list, &pfault_list);
7889 + set_task_state(tsk, TASK_UNINTERRUPTIBLE);
7890 +@@ -629,6 +638,7 @@ static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
7891 + list_del(&thread->list);
7892 + tsk = container_of(thread, struct task_struct, thread);
7893 + wake_up_process(tsk);
7894 ++ put_task_struct(tsk);
7895 + }
7896 + spin_unlock_irq(&pfault_lock);
7897 + break;
7898 +diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
7899 +index f92602e..f210d51 100644
7900 +--- a/arch/sparc/Kconfig
7901 ++++ b/arch/sparc/Kconfig
7902 +@@ -583,6 +583,9 @@ config SYSVIPC_COMPAT
7903 + depends on COMPAT && SYSVIPC
7904 + default y
7905 +
7906 ++config KEYS_COMPAT
7907 ++ def_bool y if COMPAT && KEYS
7908 ++
7909 + endmenu
7910 +
7911 + source "net/Kconfig"
7912 +diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
7913 +index db86b1a..3a58e0d 100644
7914 +--- a/arch/sparc/kernel/systbls_64.S
7915 ++++ b/arch/sparc/kernel/systbls_64.S
7916 +@@ -74,7 +74,7 @@ sys_call_table32:
7917 + .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
7918 + /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
7919 + .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
7920 +-/*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
7921 ++/*280*/ .word sys32_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
7922 + .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64
7923 + /*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
7924 + .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare
7925 +diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
7926 +index 70a0de4..6cb8319 100644
7927 +--- a/arch/tile/Kconfig
7928 ++++ b/arch/tile/Kconfig
7929 +@@ -11,8 +11,9 @@ config TILE
7930 + select GENERIC_IRQ_PROBE
7931 + select GENERIC_PENDING_IRQ if SMP
7932 + select GENERIC_IRQ_SHOW
7933 ++ select HAVE_SYSCALL_WRAPPERS if TILEGX
7934 + select SYS_HYPERVISOR
7935 +- select ARCH_HAVE_NMI_SAFE_CMPXCHG if !M386
7936 ++ select ARCH_HAVE_NMI_SAFE_CMPXCHG
7937 +
7938 + # FIXME: investigate whether we need/want these options.
7939 + # select HAVE_IOREMAP_PROT
7940 +diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
7941 +index 16f1fa5..bd186c4 100644
7942 +--- a/arch/tile/include/asm/bitops.h
7943 ++++ b/arch/tile/include/asm/bitops.h
7944 +@@ -77,6 +77,11 @@ static inline int ffs(int x)
7945 + return __builtin_ffs(x);
7946 + }
7947 +
7948 ++static inline int fls64(__u64 w)
7949 ++{
7950 ++ return (sizeof(__u64) * 8) - __builtin_clzll(w);
7951 ++}
7952 ++
7953 + /**
7954 + * fls - find last set bit in word
7955 + * @x: the word to search
7956 +@@ -90,12 +95,7 @@ static inline int ffs(int x)
7957 + */
7958 + static inline int fls(int x)
7959 + {
7960 +- return (sizeof(int) * 8) - __builtin_clz(x);
7961 +-}
7962 +-
7963 +-static inline int fls64(__u64 w)
7964 +-{
7965 +- return (sizeof(__u64) * 8) - __builtin_clzll(w);
7966 ++ return fls64((unsigned int) x);
7967 + }
7968 +
7969 + static inline unsigned int __arch_hweight32(unsigned int w)
7970 +diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
7971 +index 41474fb..aa365c5 100644
7972 +--- a/arch/um/include/asm/pgtable.h
7973 ++++ b/arch/um/include/asm/pgtable.h
7974 +@@ -271,6 +271,12 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
7975 + }
7976 + #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
7977 +
7978 ++#define __HAVE_ARCH_PTE_SAME
7979 ++static inline int pte_same(pte_t pte_a, pte_t pte_b)
7980 ++{
7981 ++ return !((pte_val(pte_a) ^ pte_val(pte_b)) & ~_PAGE_NEWPAGE);
7982 ++}
7983 ++
7984 + /*
7985 + * Conversion functions: convert a page and protection to a page entry,
7986 + * and a page entry and page directory to the page they refer to.
7987 +@@ -346,11 +352,11 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
7988 + #define update_mmu_cache(vma,address,ptep) do ; while (0)
7989 +
7990 + /* Encode and de-code a swap entry */
7991 +-#define __swp_type(x) (((x).val >> 4) & 0x3f)
7992 ++#define __swp_type(x) (((x).val >> 5) & 0x1f)
7993 + #define __swp_offset(x) ((x).val >> 11)
7994 +
7995 + #define __swp_entry(type, offset) \
7996 +- ((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
7997 ++ ((swp_entry_t) { ((type) << 5) | ((offset) << 11) })
7998 + #define __pte_to_swp_entry(pte) \
7999 + ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
8000 + #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
8001 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
8002 +index b02e509..03dbc7f5b 100644
8003 +--- a/arch/x86/Makefile
8004 ++++ b/arch/x86/Makefile
8005 +@@ -117,6 +117,9 @@ KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
8006 + KBUILD_CFLAGS += $(mflags-y)
8007 + KBUILD_AFLAGS += $(mflags-y)
8008 +
8009 ++archscripts:
8010 ++ $(Q)$(MAKE) $(build)=arch/x86/tools relocs
8011 ++
8012 + ###
8013 + # Kernel objects
8014 +
8015 +@@ -180,6 +183,7 @@ archclean:
8016 + $(Q)rm -rf $(objtree)/arch/i386
8017 + $(Q)rm -rf $(objtree)/arch/x86_64
8018 + $(Q)$(MAKE) $(clean)=$(boot)
8019 ++ $(Q)$(MAKE) $(clean)=arch/x86/tools
8020 +
8021 + define archhelp
8022 + echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
8023 +diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
8024 +index 09664ef..77453c6 100644
8025 +--- a/arch/x86/boot/compressed/Makefile
8026 ++++ b/arch/x86/boot/compressed/Makefile
8027 +@@ -31,13 +31,12 @@ OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
8028 + $(obj)/vmlinux.bin: vmlinux FORCE
8029 + $(call if_changed,objcopy)
8030 +
8031 ++targets += vmlinux.bin.all vmlinux.relocs
8032 +
8033 +-targets += vmlinux.bin.all vmlinux.relocs relocs
8034 +-hostprogs-$(CONFIG_X86_NEED_RELOCS) += relocs
8035 +-
8036 ++CMD_RELOCS = arch/x86/tools/relocs
8037 + quiet_cmd_relocs = RELOCS $@
8038 +- cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
8039 +-$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
8040 ++ cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
8041 ++$(obj)/vmlinux.relocs: vmlinux FORCE
8042 + $(call if_changed,relocs)
8043 +
8044 + vmlinux.bin.all-y := $(obj)/vmlinux.bin
8045 +diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
8046 +deleted file mode 100644
8047 +index e77f4e4..0000000
8048 +--- a/arch/x86/boot/compressed/relocs.c
8049 ++++ /dev/null
8050 +@@ -1,680 +0,0 @@
8051 +-#include <stdio.h>
8052 +-#include <stdarg.h>
8053 +-#include <stdlib.h>
8054 +-#include <stdint.h>
8055 +-#include <string.h>
8056 +-#include <errno.h>
8057 +-#include <unistd.h>
8058 +-#include <elf.h>
8059 +-#include <byteswap.h>
8060 +-#define USE_BSD
8061 +-#include <endian.h>
8062 +-#include <regex.h>
8063 +-
8064 +-static void die(char *fmt, ...);
8065 +-
8066 +-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
8067 +-static Elf32_Ehdr ehdr;
8068 +-static unsigned long reloc_count, reloc_idx;
8069 +-static unsigned long *relocs;
8070 +-
8071 +-struct section {
8072 +- Elf32_Shdr shdr;
8073 +- struct section *link;
8074 +- Elf32_Sym *symtab;
8075 +- Elf32_Rel *reltab;
8076 +- char *strtab;
8077 +-};
8078 +-static struct section *secs;
8079 +-
8080 +-/*
8081 +- * Following symbols have been audited. There values are constant and do
8082 +- * not change if bzImage is loaded at a different physical address than
8083 +- * the address for which it has been compiled. Don't warn user about
8084 +- * absolute relocations present w.r.t these symbols.
8085 +- */
8086 +-static const char abs_sym_regex[] =
8087 +- "^(xen_irq_disable_direct_reloc$|"
8088 +- "xen_save_fl_direct_reloc$|"
8089 +- "VDSO|"
8090 +- "__crc_)";
8091 +-static regex_t abs_sym_regex_c;
8092 +-static int is_abs_reloc(const char *sym_name)
8093 +-{
8094 +- return !regexec(&abs_sym_regex_c, sym_name, 0, NULL, 0);
8095 +-}
8096 +-
8097 +-/*
8098 +- * These symbols are known to be relative, even if the linker marks them
8099 +- * as absolute (typically defined outside any section in the linker script.)
8100 +- */
8101 +-static const char rel_sym_regex[] =
8102 +- "^_end$";
8103 +-static regex_t rel_sym_regex_c;
8104 +-static int is_rel_reloc(const char *sym_name)
8105 +-{
8106 +- return !regexec(&rel_sym_regex_c, sym_name, 0, NULL, 0);
8107 +-}
8108 +-
8109 +-static void regex_init(void)
8110 +-{
8111 +- char errbuf[128];
8112 +- int err;
8113 +-
8114 +- err = regcomp(&abs_sym_regex_c, abs_sym_regex,
8115 +- REG_EXTENDED|REG_NOSUB);
8116 +- if (err) {
8117 +- regerror(err, &abs_sym_regex_c, errbuf, sizeof errbuf);
8118 +- die("%s", errbuf);
8119 +- }
8120 +-
8121 +- err = regcomp(&rel_sym_regex_c, rel_sym_regex,
8122 +- REG_EXTENDED|REG_NOSUB);
8123 +- if (err) {
8124 +- regerror(err, &rel_sym_regex_c, errbuf, sizeof errbuf);
8125 +- die("%s", errbuf);
8126 +- }
8127 +-}
8128 +-
8129 +-static void die(char *fmt, ...)
8130 +-{
8131 +- va_list ap;
8132 +- va_start(ap, fmt);
8133 +- vfprintf(stderr, fmt, ap);
8134 +- va_end(ap);
8135 +- exit(1);
8136 +-}
8137 +-
8138 +-static const char *sym_type(unsigned type)
8139 +-{
8140 +- static const char *type_name[] = {
8141 +-#define SYM_TYPE(X) [X] = #X
8142 +- SYM_TYPE(STT_NOTYPE),
8143 +- SYM_TYPE(STT_OBJECT),
8144 +- SYM_TYPE(STT_FUNC),
8145 +- SYM_TYPE(STT_SECTION),
8146 +- SYM_TYPE(STT_FILE),
8147 +- SYM_TYPE(STT_COMMON),
8148 +- SYM_TYPE(STT_TLS),
8149 +-#undef SYM_TYPE
8150 +- };
8151 +- const char *name = "unknown sym type name";
8152 +- if (type < ARRAY_SIZE(type_name)) {
8153 +- name = type_name[type];
8154 +- }
8155 +- return name;
8156 +-}
8157 +-
8158 +-static const char *sym_bind(unsigned bind)
8159 +-{
8160 +- static const char *bind_name[] = {
8161 +-#define SYM_BIND(X) [X] = #X
8162 +- SYM_BIND(STB_LOCAL),
8163 +- SYM_BIND(STB_GLOBAL),
8164 +- SYM_BIND(STB_WEAK),
8165 +-#undef SYM_BIND
8166 +- };
8167 +- const char *name = "unknown sym bind name";
8168 +- if (bind < ARRAY_SIZE(bind_name)) {
8169 +- name = bind_name[bind];
8170 +- }
8171 +- return name;
8172 +-}
8173 +-
8174 +-static const char *sym_visibility(unsigned visibility)
8175 +-{
8176 +- static const char *visibility_name[] = {
8177 +-#define SYM_VISIBILITY(X) [X] = #X
8178 +- SYM_VISIBILITY(STV_DEFAULT),
8179 +- SYM_VISIBILITY(STV_INTERNAL),
8180 +- SYM_VISIBILITY(STV_HIDDEN),
8181 +- SYM_VISIBILITY(STV_PROTECTED),
8182 +-#undef SYM_VISIBILITY
8183 +- };
8184 +- const char *name = "unknown sym visibility name";
8185 +- if (visibility < ARRAY_SIZE(visibility_name)) {
8186 +- name = visibility_name[visibility];
8187 +- }
8188 +- return name;
8189 +-}
8190 +-
8191 +-static const char *rel_type(unsigned type)
8192 +-{
8193 +- static const char *type_name[] = {
8194 +-#define REL_TYPE(X) [X] = #X
8195 +- REL_TYPE(R_386_NONE),
8196 +- REL_TYPE(R_386_32),
8197 +- REL_TYPE(R_386_PC32),
8198 +- REL_TYPE(R_386_GOT32),
8199 +- REL_TYPE(R_386_PLT32),
8200 +- REL_TYPE(R_386_COPY),
8201 +- REL_TYPE(R_386_GLOB_DAT),
8202 +- REL_TYPE(R_386_JMP_SLOT),
8203 +- REL_TYPE(R_386_RELATIVE),
8204 +- REL_TYPE(R_386_GOTOFF),
8205 +- REL_TYPE(R_386_GOTPC),
8206 +-#undef REL_TYPE
8207 +- };
8208 +- const char *name = "unknown type rel type name";
8209 +- if (type < ARRAY_SIZE(type_name) && type_name[type]) {
8210 +- name = type_name[type];
8211 +- }
8212 +- return name;
8213 +-}
8214 +-
8215 +-static const char *sec_name(unsigned shndx)
8216 +-{
8217 +- const char *sec_strtab;
8218 +- const char *name;
8219 +- sec_strtab = secs[ehdr.e_shstrndx].strtab;
8220 +- name = "<noname>";
8221 +- if (shndx < ehdr.e_shnum) {
8222 +- name = sec_strtab + secs[shndx].shdr.sh_name;
8223 +- }
8224 +- else if (shndx == SHN_ABS) {
8225 +- name = "ABSOLUTE";
8226 +- }
8227 +- else if (shndx == SHN_COMMON) {
8228 +- name = "COMMON";
8229 +- }
8230 +- return name;
8231 +-}
8232 +-
8233 +-static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
8234 +-{
8235 +- const char *name;
8236 +- name = "<noname>";
8237 +- if (sym->st_name) {
8238 +- name = sym_strtab + sym->st_name;
8239 +- }
8240 +- else {
8241 +- name = sec_name(secs[sym->st_shndx].shdr.sh_name);
8242 +- }
8243 +- return name;
8244 +-}
8245 +-
8246 +-
8247 +-
8248 +-#if BYTE_ORDER == LITTLE_ENDIAN
8249 +-#define le16_to_cpu(val) (val)
8250 +-#define le32_to_cpu(val) (val)
8251 +-#endif
8252 +-#if BYTE_ORDER == BIG_ENDIAN
8253 +-#define le16_to_cpu(val) bswap_16(val)
8254 +-#define le32_to_cpu(val) bswap_32(val)
8255 +-#endif
8256 +-
8257 +-static uint16_t elf16_to_cpu(uint16_t val)
8258 +-{
8259 +- return le16_to_cpu(val);
8260 +-}
8261 +-
8262 +-static uint32_t elf32_to_cpu(uint32_t val)
8263 +-{
8264 +- return le32_to_cpu(val);
8265 +-}
8266 +-
8267 +-static void read_ehdr(FILE *fp)
8268 +-{
8269 +- if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
8270 +- die("Cannot read ELF header: %s\n",
8271 +- strerror(errno));
8272 +- }
8273 +- if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
8274 +- die("No ELF magic\n");
8275 +- }
8276 +- if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
8277 +- die("Not a 32 bit executable\n");
8278 +- }
8279 +- if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
8280 +- die("Not a LSB ELF executable\n");
8281 +- }
8282 +- if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
8283 +- die("Unknown ELF version\n");
8284 +- }
8285 +- /* Convert the fields to native endian */
8286 +- ehdr.e_type = elf16_to_cpu(ehdr.e_type);
8287 +- ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
8288 +- ehdr.e_version = elf32_to_cpu(ehdr.e_version);
8289 +- ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
8290 +- ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
8291 +- ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
8292 +- ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
8293 +- ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
8294 +- ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
8295 +- ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
8296 +- ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
8297 +- ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
8298 +- ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
8299 +-
8300 +- if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
8301 +- die("Unsupported ELF header type\n");
8302 +- }
8303 +- if (ehdr.e_machine != EM_386) {
8304 +- die("Not for x86\n");
8305 +- }
8306 +- if (ehdr.e_version != EV_CURRENT) {
8307 +- die("Unknown ELF version\n");
8308 +- }
8309 +- if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
8310 +- die("Bad Elf header size\n");
8311 +- }
8312 +- if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
8313 +- die("Bad program header entry\n");
8314 +- }
8315 +- if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
8316 +- die("Bad section header entry\n");
8317 +- }
8318 +- if (ehdr.e_shstrndx >= ehdr.e_shnum) {
8319 +- die("String table index out of bounds\n");
8320 +- }
8321 +-}
8322 +-
8323 +-static void read_shdrs(FILE *fp)
8324 +-{
8325 +- int i;
8326 +- Elf32_Shdr shdr;
8327 +-
8328 +- secs = calloc(ehdr.e_shnum, sizeof(struct section));
8329 +- if (!secs) {
8330 +- die("Unable to allocate %d section headers\n",
8331 +- ehdr.e_shnum);
8332 +- }
8333 +- if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
8334 +- die("Seek to %d failed: %s\n",
8335 +- ehdr.e_shoff, strerror(errno));
8336 +- }
8337 +- for (i = 0; i < ehdr.e_shnum; i++) {
8338 +- struct section *sec = &secs[i];
8339 +- if (fread(&shdr, sizeof shdr, 1, fp) != 1)
8340 +- die("Cannot read ELF section headers %d/%d: %s\n",
8341 +- i, ehdr.e_shnum, strerror(errno));
8342 +- sec->shdr.sh_name = elf32_to_cpu(shdr.sh_name);
8343 +- sec->shdr.sh_type = elf32_to_cpu(shdr.sh_type);
8344 +- sec->shdr.sh_flags = elf32_to_cpu(shdr.sh_flags);
8345 +- sec->shdr.sh_addr = elf32_to_cpu(shdr.sh_addr);
8346 +- sec->shdr.sh_offset = elf32_to_cpu(shdr.sh_offset);
8347 +- sec->shdr.sh_size = elf32_to_cpu(shdr.sh_size);
8348 +- sec->shdr.sh_link = elf32_to_cpu(shdr.sh_link);
8349 +- sec->shdr.sh_info = elf32_to_cpu(shdr.sh_info);
8350 +- sec->shdr.sh_addralign = elf32_to_cpu(shdr.sh_addralign);
8351 +- sec->shdr.sh_entsize = elf32_to_cpu(shdr.sh_entsize);
8352 +- if (sec->shdr.sh_link < ehdr.e_shnum)
8353 +- sec->link = &secs[sec->shdr.sh_link];
8354 +- }
8355 +-
8356 +-}
8357 +-
8358 +-static void read_strtabs(FILE *fp)
8359 +-{
8360 +- int i;
8361 +- for (i = 0; i < ehdr.e_shnum; i++) {
8362 +- struct section *sec = &secs[i];
8363 +- if (sec->shdr.sh_type != SHT_STRTAB) {
8364 +- continue;
8365 +- }
8366 +- sec->strtab = malloc(sec->shdr.sh_size);
8367 +- if (!sec->strtab) {
8368 +- die("malloc of %d bytes for strtab failed\n",
8369 +- sec->shdr.sh_size);
8370 +- }
8371 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
8372 +- die("Seek to %d failed: %s\n",
8373 +- sec->shdr.sh_offset, strerror(errno));
8374 +- }
8375 +- if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
8376 +- != sec->shdr.sh_size) {
8377 +- die("Cannot read symbol table: %s\n",
8378 +- strerror(errno));
8379 +- }
8380 +- }
8381 +-}
8382 +-
8383 +-static void read_symtabs(FILE *fp)
8384 +-{
8385 +- int i,j;
8386 +- for (i = 0; i < ehdr.e_shnum; i++) {
8387 +- struct section *sec = &secs[i];
8388 +- if (sec->shdr.sh_type != SHT_SYMTAB) {
8389 +- continue;
8390 +- }
8391 +- sec->symtab = malloc(sec->shdr.sh_size);
8392 +- if (!sec->symtab) {
8393 +- die("malloc of %d bytes for symtab failed\n",
8394 +- sec->shdr.sh_size);
8395 +- }
8396 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
8397 +- die("Seek to %d failed: %s\n",
8398 +- sec->shdr.sh_offset, strerror(errno));
8399 +- }
8400 +- if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
8401 +- != sec->shdr.sh_size) {
8402 +- die("Cannot read symbol table: %s\n",
8403 +- strerror(errno));
8404 +- }
8405 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
8406 +- Elf32_Sym *sym = &sec->symtab[j];
8407 +- sym->st_name = elf32_to_cpu(sym->st_name);
8408 +- sym->st_value = elf32_to_cpu(sym->st_value);
8409 +- sym->st_size = elf32_to_cpu(sym->st_size);
8410 +- sym->st_shndx = elf16_to_cpu(sym->st_shndx);
8411 +- }
8412 +- }
8413 +-}
8414 +-
8415 +-
8416 +-static void read_relocs(FILE *fp)
8417 +-{
8418 +- int i,j;
8419 +- for (i = 0; i < ehdr.e_shnum; i++) {
8420 +- struct section *sec = &secs[i];
8421 +- if (sec->shdr.sh_type != SHT_REL) {
8422 +- continue;
8423 +- }
8424 +- sec->reltab = malloc(sec->shdr.sh_size);
8425 +- if (!sec->reltab) {
8426 +- die("malloc of %d bytes for relocs failed\n",
8427 +- sec->shdr.sh_size);
8428 +- }
8429 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
8430 +- die("Seek to %d failed: %s\n",
8431 +- sec->shdr.sh_offset, strerror(errno));
8432 +- }
8433 +- if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
8434 +- != sec->shdr.sh_size) {
8435 +- die("Cannot read symbol table: %s\n",
8436 +- strerror(errno));
8437 +- }
8438 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
8439 +- Elf32_Rel *rel = &sec->reltab[j];
8440 +- rel->r_offset = elf32_to_cpu(rel->r_offset);
8441 +- rel->r_info = elf32_to_cpu(rel->r_info);
8442 +- }
8443 +- }
8444 +-}
8445 +-
8446 +-
8447 +-static void print_absolute_symbols(void)
8448 +-{
8449 +- int i;
8450 +- printf("Absolute symbols\n");
8451 +- printf(" Num: Value Size Type Bind Visibility Name\n");
8452 +- for (i = 0; i < ehdr.e_shnum; i++) {
8453 +- struct section *sec = &secs[i];
8454 +- char *sym_strtab;
8455 +- int j;
8456 +-
8457 +- if (sec->shdr.sh_type != SHT_SYMTAB) {
8458 +- continue;
8459 +- }
8460 +- sym_strtab = sec->link->strtab;
8461 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
8462 +- Elf32_Sym *sym;
8463 +- const char *name;
8464 +- sym = &sec->symtab[j];
8465 +- name = sym_name(sym_strtab, sym);
8466 +- if (sym->st_shndx != SHN_ABS) {
8467 +- continue;
8468 +- }
8469 +- printf("%5d %08x %5d %10s %10s %12s %s\n",
8470 +- j, sym->st_value, sym->st_size,
8471 +- sym_type(ELF32_ST_TYPE(sym->st_info)),
8472 +- sym_bind(ELF32_ST_BIND(sym->st_info)),
8473 +- sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
8474 +- name);
8475 +- }
8476 +- }
8477 +- printf("\n");
8478 +-}
8479 +-
8480 +-static void print_absolute_relocs(void)
8481 +-{
8482 +- int i, printed = 0;
8483 +-
8484 +- for (i = 0; i < ehdr.e_shnum; i++) {
8485 +- struct section *sec = &secs[i];
8486 +- struct section *sec_applies, *sec_symtab;
8487 +- char *sym_strtab;
8488 +- Elf32_Sym *sh_symtab;
8489 +- int j;
8490 +- if (sec->shdr.sh_type != SHT_REL) {
8491 +- continue;
8492 +- }
8493 +- sec_symtab = sec->link;
8494 +- sec_applies = &secs[sec->shdr.sh_info];
8495 +- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
8496 +- continue;
8497 +- }
8498 +- sh_symtab = sec_symtab->symtab;
8499 +- sym_strtab = sec_symtab->link->strtab;
8500 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
8501 +- Elf32_Rel *rel;
8502 +- Elf32_Sym *sym;
8503 +- const char *name;
8504 +- rel = &sec->reltab[j];
8505 +- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
8506 +- name = sym_name(sym_strtab, sym);
8507 +- if (sym->st_shndx != SHN_ABS) {
8508 +- continue;
8509 +- }
8510 +-
8511 +- /* Absolute symbols are not relocated if bzImage is
8512 +- * loaded at a non-compiled address. Display a warning
8513 +- * to user at compile time about the absolute
8514 +- * relocations present.
8515 +- *
8516 +- * User need to audit the code to make sure
8517 +- * some symbols which should have been section
8518 +- * relative have not become absolute because of some
8519 +- * linker optimization or wrong programming usage.
8520 +- *
8521 +- * Before warning check if this absolute symbol
8522 +- * relocation is harmless.
8523 +- */
8524 +- if (is_abs_reloc(name) || is_rel_reloc(name))
8525 +- continue;
8526 +-
8527 +- if (!printed) {
8528 +- printf("WARNING: Absolute relocations"
8529 +- " present\n");
8530 +- printf("Offset Info Type Sym.Value "
8531 +- "Sym.Name\n");
8532 +- printed = 1;
8533 +- }
8534 +-
8535 +- printf("%08x %08x %10s %08x %s\n",
8536 +- rel->r_offset,
8537 +- rel->r_info,
8538 +- rel_type(ELF32_R_TYPE(rel->r_info)),
8539 +- sym->st_value,
8540 +- name);
8541 +- }
8542 +- }
8543 +-
8544 +- if (printed)
8545 +- printf("\n");
8546 +-}
8547 +-
8548 +-static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
8549 +-{
8550 +- int i;
8551 +- /* Walk through the relocations */
8552 +- for (i = 0; i < ehdr.e_shnum; i++) {
8553 +- char *sym_strtab;
8554 +- Elf32_Sym *sh_symtab;
8555 +- struct section *sec_applies, *sec_symtab;
8556 +- int j;
8557 +- struct section *sec = &secs[i];
8558 +-
8559 +- if (sec->shdr.sh_type != SHT_REL) {
8560 +- continue;
8561 +- }
8562 +- sec_symtab = sec->link;
8563 +- sec_applies = &secs[sec->shdr.sh_info];
8564 +- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
8565 +- continue;
8566 +- }
8567 +- sh_symtab = sec_symtab->symtab;
8568 +- sym_strtab = sec_symtab->link->strtab;
8569 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
8570 +- Elf32_Rel *rel;
8571 +- Elf32_Sym *sym;
8572 +- unsigned r_type;
8573 +- rel = &sec->reltab[j];
8574 +- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
8575 +- r_type = ELF32_R_TYPE(rel->r_info);
8576 +- /* Don't visit relocations to absolute symbols */
8577 +- if (sym->st_shndx == SHN_ABS &&
8578 +- !is_rel_reloc(sym_name(sym_strtab, sym))) {
8579 +- continue;
8580 +- }
8581 +- switch (r_type) {
8582 +- case R_386_NONE:
8583 +- case R_386_PC32:
8584 +- /*
8585 +- * NONE can be ignored and and PC relative
8586 +- * relocations don't need to be adjusted.
8587 +- */
8588 +- break;
8589 +- case R_386_32:
8590 +- /* Visit relocations that need to be adjusted */
8591 +- visit(rel, sym);
8592 +- break;
8593 +- default:
8594 +- die("Unsupported relocation type: %s (%d)\n",
8595 +- rel_type(r_type), r_type);
8596 +- break;
8597 +- }
8598 +- }
8599 +- }
8600 +-}
8601 +-
8602 +-static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
8603 +-{
8604 +- reloc_count += 1;
8605 +-}
8606 +-
8607 +-static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
8608 +-{
8609 +- /* Remember the address that needs to be adjusted. */
8610 +- relocs[reloc_idx++] = rel->r_offset;
8611 +-}
8612 +-
8613 +-static int cmp_relocs(const void *va, const void *vb)
8614 +-{
8615 +- const unsigned long *a, *b;
8616 +- a = va; b = vb;
8617 +- return (*a == *b)? 0 : (*a > *b)? 1 : -1;
8618 +-}
8619 +-
8620 +-static void emit_relocs(int as_text)
8621 +-{
8622 +- int i;
8623 +- /* Count how many relocations I have and allocate space for them. */
8624 +- reloc_count = 0;
8625 +- walk_relocs(count_reloc);
8626 +- relocs = malloc(reloc_count * sizeof(relocs[0]));
8627 +- if (!relocs) {
8628 +- die("malloc of %d entries for relocs failed\n",
8629 +- reloc_count);
8630 +- }
8631 +- /* Collect up the relocations */
8632 +- reloc_idx = 0;
8633 +- walk_relocs(collect_reloc);
8634 +-
8635 +- /* Order the relocations for more efficient processing */
8636 +- qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
8637 +-
8638 +- /* Print the relocations */
8639 +- if (as_text) {
8640 +- /* Print the relocations in a form suitable that
8641 +- * gas will like.
8642 +- */
8643 +- printf(".section \".data.reloc\",\"a\"\n");
8644 +- printf(".balign 4\n");
8645 +- for (i = 0; i < reloc_count; i++) {
8646 +- printf("\t .long 0x%08lx\n", relocs[i]);
8647 +- }
8648 +- printf("\n");
8649 +- }
8650 +- else {
8651 +- unsigned char buf[4];
8652 +- /* Print a stop */
8653 +- fwrite("\0\0\0\0", 4, 1, stdout);
8654 +- /* Now print each relocation */
8655 +- for (i = 0; i < reloc_count; i++) {
8656 +- buf[0] = (relocs[i] >> 0) & 0xff;
8657 +- buf[1] = (relocs[i] >> 8) & 0xff;
8658 +- buf[2] = (relocs[i] >> 16) & 0xff;
8659 +- buf[3] = (relocs[i] >> 24) & 0xff;
8660 +- fwrite(buf, 4, 1, stdout);
8661 +- }
8662 +- }
8663 +-}
8664 +-
8665 +-static void usage(void)
8666 +-{
8667 +- die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
8668 +-}
8669 +-
8670 +-int main(int argc, char **argv)
8671 +-{
8672 +- int show_absolute_syms, show_absolute_relocs;
8673 +- int as_text;
8674 +- const char *fname;
8675 +- FILE *fp;
8676 +- int i;
8677 +-
8678 +- regex_init();
8679 +-
8680 +- show_absolute_syms = 0;
8681 +- show_absolute_relocs = 0;
8682 +- as_text = 0;
8683 +- fname = NULL;
8684 +- for (i = 1; i < argc; i++) {
8685 +- char *arg = argv[i];
8686 +- if (*arg == '-') {
8687 +- if (strcmp(argv[1], "--abs-syms") == 0) {
8688 +- show_absolute_syms = 1;
8689 +- continue;
8690 +- }
8691 +-
8692 +- if (strcmp(argv[1], "--abs-relocs") == 0) {
8693 +- show_absolute_relocs = 1;
8694 +- continue;
8695 +- }
8696 +- else if (strcmp(argv[1], "--text") == 0) {
8697 +- as_text = 1;
8698 +- continue;
8699 +- }
8700 +- }
8701 +- else if (!fname) {
8702 +- fname = arg;
8703 +- continue;
8704 +- }
8705 +- usage();
8706 +- }
8707 +- if (!fname) {
8708 +- usage();
8709 +- }
8710 +- fp = fopen(fname, "r");
8711 +- if (!fp) {
8712 +- die("Cannot open %s: %s\n",
8713 +- fname, strerror(errno));
8714 +- }
8715 +- read_ehdr(fp);
8716 +- read_shdrs(fp);
8717 +- read_strtabs(fp);
8718 +- read_symtabs(fp);
8719 +- read_relocs(fp);
8720 +- if (show_absolute_syms) {
8721 +- print_absolute_symbols();
8722 +- return 0;
8723 +- }
8724 +- if (show_absolute_relocs) {
8725 +- print_absolute_relocs();
8726 +- return 0;
8727 +- }
8728 +- emit_relocs(as_text);
8729 +- return 0;
8730 +-}
8731 +diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
8732 +index 7395d5f..c9c9cfe 100644
8733 +--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
8734 ++++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
8735 +@@ -145,15 +145,19 @@ static struct severity {
8736 + };
8737 +
8738 + /*
8739 +- * If the EIPV bit is set, it means the saved IP is the
8740 +- * instruction which caused the MCE.
8741 ++ * If mcgstatus indicated that ip/cs on the stack were
8742 ++ * no good, then "m->cs" will be zero and we will have
8743 ++ * to assume the worst case (IN_KERNEL) as we actually
8744 ++ * have no idea what we were executing when the machine
8745 ++ * check hit.
8746 ++ * If we do have a good "m->cs" (or a faked one in the
8747 ++ * case we were executing in VM86 mode) we can use it to
8748 ++ * distinguish an exception taken in user from from one
8749 ++ * taken in the kernel.
8750 + */
8751 + static int error_context(struct mce *m)
8752 + {
8753 +- if (m->mcgstatus & MCG_STATUS_EIPV)
8754 +- return (m->ip && (m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
8755 +- /* Unknown, assume kernel */
8756 +- return IN_KERNEL;
8757 ++ return ((m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
8758 + }
8759 +
8760 + int mce_severity(struct mce *m, int tolerant, char **msg)
8761 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
8762 +index 2af127d..b0f1271 100644
8763 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
8764 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
8765 +@@ -389,6 +389,14 @@ static inline void mce_gather_info(struct mce *m, struct pt_regs *regs)
8766 + if (m->mcgstatus & (MCG_STATUS_RIPV|MCG_STATUS_EIPV)) {
8767 + m->ip = regs->ip;
8768 + m->cs = regs->cs;
8769 ++
8770 ++ /*
8771 ++ * When in VM86 mode make the cs look like ring 3
8772 ++ * always. This is a lie, but it's better than passing
8773 ++ * the additional vm86 bit around everywhere.
8774 ++ */
8775 ++ if (v8086_mode(regs))
8776 ++ m->cs |= 3;
8777 + }
8778 + /* Use accurate RIP reporting if available. */
8779 + if (rip_msr)
8780 +diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
8781 +index f64a039..3dbfb00 100644
8782 +--- a/arch/x86/kernel/cpu/perf_event_amd.c
8783 ++++ b/arch/x86/kernel/cpu/perf_event_amd.c
8784 +@@ -473,6 +473,7 @@ static __initconst const struct x86_pmu amd_pmu = {
8785 + * 0x023 DE PERF_CTL[2:0]
8786 + * 0x02D LS PERF_CTL[3]
8787 + * 0x02E LS PERF_CTL[3,0]
8788 ++ * 0x031 LS PERF_CTL[2:0] (**)
8789 + * 0x043 CU PERF_CTL[2:0]
8790 + * 0x045 CU PERF_CTL[2:0]
8791 + * 0x046 CU PERF_CTL[2:0]
8792 +@@ -486,10 +487,12 @@ static __initconst const struct x86_pmu amd_pmu = {
8793 + * 0x0DD LS PERF_CTL[5:0]
8794 + * 0x0DE LS PERF_CTL[5:0]
8795 + * 0x0DF LS PERF_CTL[5:0]
8796 ++ * 0x1C0 EX PERF_CTL[5:3]
8797 + * 0x1D6 EX PERF_CTL[5:0]
8798 + * 0x1D8 EX PERF_CTL[5:0]
8799 + *
8800 +- * (*) depending on the umask all FPU counters may be used
8801 ++ * (*) depending on the umask all FPU counters may be used
8802 ++ * (**) only one unitmask enabled at a time
8803 + */
8804 +
8805 + static struct event_constraint amd_f15_PMC0 = EVENT_CONSTRAINT(0, 0x01, 0);
8806 +@@ -539,6 +542,12 @@ amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *ev
8807 + return &amd_f15_PMC3;
8808 + case 0x02E:
8809 + return &amd_f15_PMC30;
8810 ++ case 0x031:
8811 ++ if (hweight_long(hwc->config & ARCH_PERFMON_EVENTSEL_UMASK) <= 1)
8812 ++ return &amd_f15_PMC20;
8813 ++ return &emptyconstraint;
8814 ++ case 0x1C0:
8815 ++ return &amd_f15_PMC53;
8816 + default:
8817 + return &amd_f15_PMC50;
8818 + }
8819 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
8820 +index 4ea7678..7315488 100644
8821 +--- a/arch/x86/kvm/vmx.c
8822 ++++ b/arch/x86/kvm/vmx.c
8823 +@@ -1677,7 +1677,7 @@ static int nested_pf_handled(struct kvm_vcpu *vcpu)
8824 + struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
8825 +
8826 + /* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */
8827 +- if (!(vmcs12->exception_bitmap & PF_VECTOR))
8828 ++ if (!(vmcs12->exception_bitmap & (1u << PF_VECTOR)))
8829 + return 0;
8830 +
8831 + nested_vmx_vmexit(vcpu);
8832 +@@ -3915,7 +3915,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
8833 + vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
8834 +
8835 + vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
8836 ++ vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
8837 + vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */
8838 ++ srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
8839 + vmx_set_cr4(&vmx->vcpu, 0);
8840 + vmx_set_efer(&vmx->vcpu, 0);
8841 + vmx_fpu_activate(&vmx->vcpu);
8842 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
8843 +index e04cae1..4fc5323 100644
8844 +--- a/arch/x86/kvm/x86.c
8845 ++++ b/arch/x86/kvm/x86.c
8846 +@@ -3579,6 +3579,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
8847 + r = -EEXIST;
8848 + if (kvm->arch.vpic)
8849 + goto create_irqchip_unlock;
8850 ++ r = -EINVAL;
8851 ++ if (atomic_read(&kvm->online_vcpus))
8852 ++ goto create_irqchip_unlock;
8853 + r = -ENOMEM;
8854 + vpic = kvm_create_pic(kvm);
8855 + if (vpic) {
8856 +@@ -6486,6 +6489,11 @@ void kvm_arch_check_processor_compat(void *rtn)
8857 + kvm_x86_ops->check_processor_compatibility(rtn);
8858 + }
8859 +
8860 ++bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
8861 ++{
8862 ++ return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL);
8863 ++}
8864 ++
8865 + int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
8866 + {
8867 + struct page *page;
8868 +diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
8869 +index d99346e..4c262f6 100644
8870 +--- a/arch/x86/pci/xen.c
8871 ++++ b/arch/x86/pci/xen.c
8872 +@@ -64,6 +64,10 @@ static int xen_register_pirq(u32 gsi, int gsi_override, int triggering,
8873 + int shareable = 0;
8874 + char *name;
8875 +
8876 ++ irq = xen_irq_from_gsi(gsi);
8877 ++ if (irq > 0)
8878 ++ return irq;
8879 ++
8880 + if (set_pirq)
8881 + pirq = gsi;
8882 +
8883 +diff --git a/arch/x86/tools/.gitignore b/arch/x86/tools/.gitignore
8884 +new file mode 100644
8885 +index 0000000..be0ed06
8886 +--- /dev/null
8887 ++++ b/arch/x86/tools/.gitignore
8888 +@@ -0,0 +1 @@
8889 ++relocs
8890 +diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
8891 +index f820826..162a34a 100644
8892 +--- a/arch/x86/tools/Makefile
8893 ++++ b/arch/x86/tools/Makefile
8894 +@@ -29,3 +29,6 @@ HOSTCFLAGS_test_get_len.o := -Wall -I$(objtree)/arch/x86/lib/ -I$(srctree)/arch/
8895 + # Dependencies are also needed.
8896 + $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
8897 +
8898 ++HOST_EXTRACFLAGS += -I$(srctree)/tools/include
8899 ++hostprogs-y += relocs
8900 ++relocs: $(obj)/relocs
8901 +diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
8902 +new file mode 100644
8903 +index 0000000..e529730
8904 +--- /dev/null
8905 ++++ b/arch/x86/tools/relocs.c
8906 +@@ -0,0 +1,820 @@
8907 ++#include <stdio.h>
8908 ++#include <stdarg.h>
8909 ++#include <stdlib.h>
8910 ++#include <stdint.h>
8911 ++#include <string.h>
8912 ++#include <errno.h>
8913 ++#include <unistd.h>
8914 ++#include <elf.h>
8915 ++#include <byteswap.h>
8916 ++#define USE_BSD
8917 ++#include <endian.h>
8918 ++#include <regex.h>
8919 ++
8920 ++static void die(char *fmt, ...);
8921 ++
8922 ++#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
8923 ++static Elf32_Ehdr ehdr;
8924 ++static unsigned long reloc_count, reloc_idx;
8925 ++static unsigned long *relocs;
8926 ++static unsigned long reloc16_count, reloc16_idx;
8927 ++static unsigned long *relocs16;
8928 ++
8929 ++struct section {
8930 ++ Elf32_Shdr shdr;
8931 ++ struct section *link;
8932 ++ Elf32_Sym *symtab;
8933 ++ Elf32_Rel *reltab;
8934 ++ char *strtab;
8935 ++};
8936 ++static struct section *secs;
8937 ++
8938 ++enum symtype {
8939 ++ S_ABS,
8940 ++ S_REL,
8941 ++ S_SEG,
8942 ++ S_LIN,
8943 ++ S_NSYMTYPES
8944 ++};
8945 ++
8946 ++static const char * const sym_regex_kernel[S_NSYMTYPES] = {
8947 ++/*
8948 ++ * Following symbols have been audited. There values are constant and do
8949 ++ * not change if bzImage is loaded at a different physical address than
8950 ++ * the address for which it has been compiled. Don't warn user about
8951 ++ * absolute relocations present w.r.t these symbols.
8952 ++ */
8953 ++ [S_ABS] =
8954 ++ "^(xen_irq_disable_direct_reloc$|"
8955 ++ "xen_save_fl_direct_reloc$|"
8956 ++ "VDSO|"
8957 ++ "__crc_)",
8958 ++
8959 ++/*
8960 ++ * These symbols are known to be relative, even if the linker marks them
8961 ++ * as absolute (typically defined outside any section in the linker script.)
8962 ++ */
8963 ++ [S_REL] =
8964 ++ "^(__init_(begin|end)|"
8965 ++ "__x86_cpu_dev_(start|end)|"
8966 ++ "(__parainstructions|__alt_instructions)(|_end)|"
8967 ++ "(__iommu_table|__apicdrivers|__smp_locks)(|_end)|"
8968 ++ "__(start|end)_pci_.*|"
8969 ++ "__(start|end)_builtin_fw|"
8970 ++ "__(start|stop)___ksymtab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
8971 ++ "__(start|stop)___kcrctab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
8972 ++ "__(start|stop)___param|"
8973 ++ "__(start|stop)___modver|"
8974 ++ "__(start|stop)___bug_table|"
8975 ++ "__tracedata_(start|end)|"
8976 ++ "__(start|stop)_notes|"
8977 ++ "__end_rodata|"
8978 ++ "__initramfs_start|"
8979 ++ "(jiffies|jiffies_64)|"
8980 ++ "_end)$"
8981 ++};
8982 ++
8983 ++
8984 ++static const char * const sym_regex_realmode[S_NSYMTYPES] = {
8985 ++/*
8986 ++ * These are 16-bit segment symbols when compiling 16-bit code.
8987 ++ */
8988 ++ [S_SEG] =
8989 ++ "^real_mode_seg$",
8990 ++
8991 ++/*
8992 ++ * These are offsets belonging to segments, as opposed to linear addresses,
8993 ++ * when compiling 16-bit code.
8994 ++ */
8995 ++ [S_LIN] =
8996 ++ "^pa_",
8997 ++};
8998 ++
8999 ++static const char * const *sym_regex;
9000 ++
9001 ++static regex_t sym_regex_c[S_NSYMTYPES];
9002 ++static int is_reloc(enum symtype type, const char *sym_name)
9003 ++{
9004 ++ return sym_regex[type] &&
9005 ++ !regexec(&sym_regex_c[type], sym_name, 0, NULL, 0);
9006 ++}
9007 ++
9008 ++static void regex_init(int use_real_mode)
9009 ++{
9010 ++ char errbuf[128];
9011 ++ int err;
9012 ++ int i;
9013 ++
9014 ++ if (use_real_mode)
9015 ++ sym_regex = sym_regex_realmode;
9016 ++ else
9017 ++ sym_regex = sym_regex_kernel;
9018 ++
9019 ++ for (i = 0; i < S_NSYMTYPES; i++) {
9020 ++ if (!sym_regex[i])
9021 ++ continue;
9022 ++
9023 ++ err = regcomp(&sym_regex_c[i], sym_regex[i],
9024 ++ REG_EXTENDED|REG_NOSUB);
9025 ++
9026 ++ if (err) {
9027 ++ regerror(err, &sym_regex_c[i], errbuf, sizeof errbuf);
9028 ++ die("%s", errbuf);
9029 ++ }
9030 ++ }
9031 ++}
9032 ++
9033 ++static void die(char *fmt, ...)
9034 ++{
9035 ++ va_list ap;
9036 ++ va_start(ap, fmt);
9037 ++ vfprintf(stderr, fmt, ap);
9038 ++ va_end(ap);
9039 ++ exit(1);
9040 ++}
9041 ++
9042 ++static const char *sym_type(unsigned type)
9043 ++{
9044 ++ static const char *type_name[] = {
9045 ++#define SYM_TYPE(X) [X] = #X
9046 ++ SYM_TYPE(STT_NOTYPE),
9047 ++ SYM_TYPE(STT_OBJECT),
9048 ++ SYM_TYPE(STT_FUNC),
9049 ++ SYM_TYPE(STT_SECTION),
9050 ++ SYM_TYPE(STT_FILE),
9051 ++ SYM_TYPE(STT_COMMON),
9052 ++ SYM_TYPE(STT_TLS),
9053 ++#undef SYM_TYPE
9054 ++ };
9055 ++ const char *name = "unknown sym type name";
9056 ++ if (type < ARRAY_SIZE(type_name)) {
9057 ++ name = type_name[type];
9058 ++ }
9059 ++ return name;
9060 ++}
9061 ++
9062 ++static const char *sym_bind(unsigned bind)
9063 ++{
9064 ++ static const char *bind_name[] = {
9065 ++#define SYM_BIND(X) [X] = #X
9066 ++ SYM_BIND(STB_LOCAL),
9067 ++ SYM_BIND(STB_GLOBAL),
9068 ++ SYM_BIND(STB_WEAK),
9069 ++#undef SYM_BIND
9070 ++ };
9071 ++ const char *name = "unknown sym bind name";
9072 ++ if (bind < ARRAY_SIZE(bind_name)) {
9073 ++ name = bind_name[bind];
9074 ++ }
9075 ++ return name;
9076 ++}
9077 ++
9078 ++static const char *sym_visibility(unsigned visibility)
9079 ++{
9080 ++ static const char *visibility_name[] = {
9081 ++#define SYM_VISIBILITY(X) [X] = #X
9082 ++ SYM_VISIBILITY(STV_DEFAULT),
9083 ++ SYM_VISIBILITY(STV_INTERNAL),
9084 ++ SYM_VISIBILITY(STV_HIDDEN),
9085 ++ SYM_VISIBILITY(STV_PROTECTED),
9086 ++#undef SYM_VISIBILITY
9087 ++ };
9088 ++ const char *name = "unknown sym visibility name";
9089 ++ if (visibility < ARRAY_SIZE(visibility_name)) {
9090 ++ name = visibility_name[visibility];
9091 ++ }
9092 ++ return name;
9093 ++}
9094 ++
9095 ++static const char *rel_type(unsigned type)
9096 ++{
9097 ++ static const char *type_name[] = {
9098 ++#define REL_TYPE(X) [X] = #X
9099 ++ REL_TYPE(R_386_NONE),
9100 ++ REL_TYPE(R_386_32),
9101 ++ REL_TYPE(R_386_PC32),
9102 ++ REL_TYPE(R_386_GOT32),
9103 ++ REL_TYPE(R_386_PLT32),
9104 ++ REL_TYPE(R_386_COPY),
9105 ++ REL_TYPE(R_386_GLOB_DAT),
9106 ++ REL_TYPE(R_386_JMP_SLOT),
9107 ++ REL_TYPE(R_386_RELATIVE),
9108 ++ REL_TYPE(R_386_GOTOFF),
9109 ++ REL_TYPE(R_386_GOTPC),
9110 ++ REL_TYPE(R_386_8),
9111 ++ REL_TYPE(R_386_PC8),
9112 ++ REL_TYPE(R_386_16),
9113 ++ REL_TYPE(R_386_PC16),
9114 ++#undef REL_TYPE
9115 ++ };
9116 ++ const char *name = "unknown type rel type name";
9117 ++ if (type < ARRAY_SIZE(type_name) && type_name[type]) {
9118 ++ name = type_name[type];
9119 ++ }
9120 ++ return name;
9121 ++}
9122 ++
9123 ++static const char *sec_name(unsigned shndx)
9124 ++{
9125 ++ const char *sec_strtab;
9126 ++ const char *name;
9127 ++ sec_strtab = secs[ehdr.e_shstrndx].strtab;
9128 ++ name = "<noname>";
9129 ++ if (shndx < ehdr.e_shnum) {
9130 ++ name = sec_strtab + secs[shndx].shdr.sh_name;
9131 ++ }
9132 ++ else if (shndx == SHN_ABS) {
9133 ++ name = "ABSOLUTE";
9134 ++ }
9135 ++ else if (shndx == SHN_COMMON) {
9136 ++ name = "COMMON";
9137 ++ }
9138 ++ return name;
9139 ++}
9140 ++
9141 ++static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
9142 ++{
9143 ++ const char *name;
9144 ++ name = "<noname>";
9145 ++ if (sym->st_name) {
9146 ++ name = sym_strtab + sym->st_name;
9147 ++ }
9148 ++ else {
9149 ++ name = sec_name(sym->st_shndx);
9150 ++ }
9151 ++ return name;
9152 ++}
9153 ++
9154 ++
9155 ++
9156 ++#if BYTE_ORDER == LITTLE_ENDIAN
9157 ++#define le16_to_cpu(val) (val)
9158 ++#define le32_to_cpu(val) (val)
9159 ++#endif
9160 ++#if BYTE_ORDER == BIG_ENDIAN
9161 ++#define le16_to_cpu(val) bswap_16(val)
9162 ++#define le32_to_cpu(val) bswap_32(val)
9163 ++#endif
9164 ++
9165 ++static uint16_t elf16_to_cpu(uint16_t val)
9166 ++{
9167 ++ return le16_to_cpu(val);
9168 ++}
9169 ++
9170 ++static uint32_t elf32_to_cpu(uint32_t val)
9171 ++{
9172 ++ return le32_to_cpu(val);
9173 ++}
9174 ++
9175 ++static void read_ehdr(FILE *fp)
9176 ++{
9177 ++ if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
9178 ++ die("Cannot read ELF header: %s\n",
9179 ++ strerror(errno));
9180 ++ }
9181 ++ if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
9182 ++ die("No ELF magic\n");
9183 ++ }
9184 ++ if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
9185 ++ die("Not a 32 bit executable\n");
9186 ++ }
9187 ++ if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
9188 ++ die("Not a LSB ELF executable\n");
9189 ++ }
9190 ++ if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
9191 ++ die("Unknown ELF version\n");
9192 ++ }
9193 ++ /* Convert the fields to native endian */
9194 ++ ehdr.e_type = elf16_to_cpu(ehdr.e_type);
9195 ++ ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
9196 ++ ehdr.e_version = elf32_to_cpu(ehdr.e_version);
9197 ++ ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
9198 ++ ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
9199 ++ ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
9200 ++ ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
9201 ++ ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
9202 ++ ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
9203 ++ ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
9204 ++ ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
9205 ++ ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
9206 ++ ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
9207 ++
9208 ++ if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
9209 ++ die("Unsupported ELF header type\n");
9210 ++ }
9211 ++ if (ehdr.e_machine != EM_386) {
9212 ++ die("Not for x86\n");
9213 ++ }
9214 ++ if (ehdr.e_version != EV_CURRENT) {
9215 ++ die("Unknown ELF version\n");
9216 ++ }
9217 ++ if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
9218 ++ die("Bad Elf header size\n");
9219 ++ }
9220 ++ if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
9221 ++ die("Bad program header entry\n");
9222 ++ }
9223 ++ if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
9224 ++ die("Bad section header entry\n");
9225 ++ }
9226 ++ if (ehdr.e_shstrndx >= ehdr.e_shnum) {
9227 ++ die("String table index out of bounds\n");
9228 ++ }
9229 ++}
9230 ++
9231 ++static void read_shdrs(FILE *fp)
9232 ++{
9233 ++ int i;
9234 ++ Elf32_Shdr shdr;
9235 ++
9236 ++ secs = calloc(ehdr.e_shnum, sizeof(struct section));
9237 ++ if (!secs) {
9238 ++ die("Unable to allocate %d section headers\n",
9239 ++ ehdr.e_shnum);
9240 ++ }
9241 ++ if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
9242 ++ die("Seek to %d failed: %s\n",
9243 ++ ehdr.e_shoff, strerror(errno));
9244 ++ }
9245 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9246 ++ struct section *sec = &secs[i];
9247 ++ if (fread(&shdr, sizeof shdr, 1, fp) != 1)
9248 ++ die("Cannot read ELF section headers %d/%d: %s\n",
9249 ++ i, ehdr.e_shnum, strerror(errno));
9250 ++ sec->shdr.sh_name = elf32_to_cpu(shdr.sh_name);
9251 ++ sec->shdr.sh_type = elf32_to_cpu(shdr.sh_type);
9252 ++ sec->shdr.sh_flags = elf32_to_cpu(shdr.sh_flags);
9253 ++ sec->shdr.sh_addr = elf32_to_cpu(shdr.sh_addr);
9254 ++ sec->shdr.sh_offset = elf32_to_cpu(shdr.sh_offset);
9255 ++ sec->shdr.sh_size = elf32_to_cpu(shdr.sh_size);
9256 ++ sec->shdr.sh_link = elf32_to_cpu(shdr.sh_link);
9257 ++ sec->shdr.sh_info = elf32_to_cpu(shdr.sh_info);
9258 ++ sec->shdr.sh_addralign = elf32_to_cpu(shdr.sh_addralign);
9259 ++ sec->shdr.sh_entsize = elf32_to_cpu(shdr.sh_entsize);
9260 ++ if (sec->shdr.sh_link < ehdr.e_shnum)
9261 ++ sec->link = &secs[sec->shdr.sh_link];
9262 ++ }
9263 ++
9264 ++}
9265 ++
9266 ++static void read_strtabs(FILE *fp)
9267 ++{
9268 ++ int i;
9269 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9270 ++ struct section *sec = &secs[i];
9271 ++ if (sec->shdr.sh_type != SHT_STRTAB) {
9272 ++ continue;
9273 ++ }
9274 ++ sec->strtab = malloc(sec->shdr.sh_size);
9275 ++ if (!sec->strtab) {
9276 ++ die("malloc of %d bytes for strtab failed\n",
9277 ++ sec->shdr.sh_size);
9278 ++ }
9279 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
9280 ++ die("Seek to %d failed: %s\n",
9281 ++ sec->shdr.sh_offset, strerror(errno));
9282 ++ }
9283 ++ if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
9284 ++ != sec->shdr.sh_size) {
9285 ++ die("Cannot read symbol table: %s\n",
9286 ++ strerror(errno));
9287 ++ }
9288 ++ }
9289 ++}
9290 ++
9291 ++static void read_symtabs(FILE *fp)
9292 ++{
9293 ++ int i,j;
9294 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9295 ++ struct section *sec = &secs[i];
9296 ++ if (sec->shdr.sh_type != SHT_SYMTAB) {
9297 ++ continue;
9298 ++ }
9299 ++ sec->symtab = malloc(sec->shdr.sh_size);
9300 ++ if (!sec->symtab) {
9301 ++ die("malloc of %d bytes for symtab failed\n",
9302 ++ sec->shdr.sh_size);
9303 ++ }
9304 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
9305 ++ die("Seek to %d failed: %s\n",
9306 ++ sec->shdr.sh_offset, strerror(errno));
9307 ++ }
9308 ++ if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
9309 ++ != sec->shdr.sh_size) {
9310 ++ die("Cannot read symbol table: %s\n",
9311 ++ strerror(errno));
9312 ++ }
9313 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
9314 ++ Elf32_Sym *sym = &sec->symtab[j];
9315 ++ sym->st_name = elf32_to_cpu(sym->st_name);
9316 ++ sym->st_value = elf32_to_cpu(sym->st_value);
9317 ++ sym->st_size = elf32_to_cpu(sym->st_size);
9318 ++ sym->st_shndx = elf16_to_cpu(sym->st_shndx);
9319 ++ }
9320 ++ }
9321 ++}
9322 ++
9323 ++
9324 ++static void read_relocs(FILE *fp)
9325 ++{
9326 ++ int i,j;
9327 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9328 ++ struct section *sec = &secs[i];
9329 ++ if (sec->shdr.sh_type != SHT_REL) {
9330 ++ continue;
9331 ++ }
9332 ++ sec->reltab = malloc(sec->shdr.sh_size);
9333 ++ if (!sec->reltab) {
9334 ++ die("malloc of %d bytes for relocs failed\n",
9335 ++ sec->shdr.sh_size);
9336 ++ }
9337 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
9338 ++ die("Seek to %d failed: %s\n",
9339 ++ sec->shdr.sh_offset, strerror(errno));
9340 ++ }
9341 ++ if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
9342 ++ != sec->shdr.sh_size) {
9343 ++ die("Cannot read symbol table: %s\n",
9344 ++ strerror(errno));
9345 ++ }
9346 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
9347 ++ Elf32_Rel *rel = &sec->reltab[j];
9348 ++ rel->r_offset = elf32_to_cpu(rel->r_offset);
9349 ++ rel->r_info = elf32_to_cpu(rel->r_info);
9350 ++ }
9351 ++ }
9352 ++}
9353 ++
9354 ++
9355 ++static void print_absolute_symbols(void)
9356 ++{
9357 ++ int i;
9358 ++ printf("Absolute symbols\n");
9359 ++ printf(" Num: Value Size Type Bind Visibility Name\n");
9360 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9361 ++ struct section *sec = &secs[i];
9362 ++ char *sym_strtab;
9363 ++ int j;
9364 ++
9365 ++ if (sec->shdr.sh_type != SHT_SYMTAB) {
9366 ++ continue;
9367 ++ }
9368 ++ sym_strtab = sec->link->strtab;
9369 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
9370 ++ Elf32_Sym *sym;
9371 ++ const char *name;
9372 ++ sym = &sec->symtab[j];
9373 ++ name = sym_name(sym_strtab, sym);
9374 ++ if (sym->st_shndx != SHN_ABS) {
9375 ++ continue;
9376 ++ }
9377 ++ printf("%5d %08x %5d %10s %10s %12s %s\n",
9378 ++ j, sym->st_value, sym->st_size,
9379 ++ sym_type(ELF32_ST_TYPE(sym->st_info)),
9380 ++ sym_bind(ELF32_ST_BIND(sym->st_info)),
9381 ++ sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
9382 ++ name);
9383 ++ }
9384 ++ }
9385 ++ printf("\n");
9386 ++}
9387 ++
9388 ++static void print_absolute_relocs(void)
9389 ++{
9390 ++ int i, printed = 0;
9391 ++
9392 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9393 ++ struct section *sec = &secs[i];
9394 ++ struct section *sec_applies, *sec_symtab;
9395 ++ char *sym_strtab;
9396 ++ Elf32_Sym *sh_symtab;
9397 ++ int j;
9398 ++ if (sec->shdr.sh_type != SHT_REL) {
9399 ++ continue;
9400 ++ }
9401 ++ sec_symtab = sec->link;
9402 ++ sec_applies = &secs[sec->shdr.sh_info];
9403 ++ if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
9404 ++ continue;
9405 ++ }
9406 ++ sh_symtab = sec_symtab->symtab;
9407 ++ sym_strtab = sec_symtab->link->strtab;
9408 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
9409 ++ Elf32_Rel *rel;
9410 ++ Elf32_Sym *sym;
9411 ++ const char *name;
9412 ++ rel = &sec->reltab[j];
9413 ++ sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
9414 ++ name = sym_name(sym_strtab, sym);
9415 ++ if (sym->st_shndx != SHN_ABS) {
9416 ++ continue;
9417 ++ }
9418 ++
9419 ++ /* Absolute symbols are not relocated if bzImage is
9420 ++ * loaded at a non-compiled address. Display a warning
9421 ++ * to user at compile time about the absolute
9422 ++ * relocations present.
9423 ++ *
9424 ++ * User need to audit the code to make sure
9425 ++ * some symbols which should have been section
9426 ++ * relative have not become absolute because of some
9427 ++ * linker optimization or wrong programming usage.
9428 ++ *
9429 ++ * Before warning check if this absolute symbol
9430 ++ * relocation is harmless.
9431 ++ */
9432 ++ if (is_reloc(S_ABS, name) || is_reloc(S_REL, name))
9433 ++ continue;
9434 ++
9435 ++ if (!printed) {
9436 ++ printf("WARNING: Absolute relocations"
9437 ++ " present\n");
9438 ++ printf("Offset Info Type Sym.Value "
9439 ++ "Sym.Name\n");
9440 ++ printed = 1;
9441 ++ }
9442 ++
9443 ++ printf("%08x %08x %10s %08x %s\n",
9444 ++ rel->r_offset,
9445 ++ rel->r_info,
9446 ++ rel_type(ELF32_R_TYPE(rel->r_info)),
9447 ++ sym->st_value,
9448 ++ name);
9449 ++ }
9450 ++ }
9451 ++
9452 ++ if (printed)
9453 ++ printf("\n");
9454 ++}
9455 ++
9456 ++static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
9457 ++ int use_real_mode)
9458 ++{
9459 ++ int i;
9460 ++ /* Walk through the relocations */
9461 ++ for (i = 0; i < ehdr.e_shnum; i++) {
9462 ++ char *sym_strtab;
9463 ++ Elf32_Sym *sh_symtab;
9464 ++ struct section *sec_applies, *sec_symtab;
9465 ++ int j;
9466 ++ struct section *sec = &secs[i];
9467 ++
9468 ++ if (sec->shdr.sh_type != SHT_REL) {
9469 ++ continue;
9470 ++ }
9471 ++ sec_symtab = sec->link;
9472 ++ sec_applies = &secs[sec->shdr.sh_info];
9473 ++ if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
9474 ++ continue;
9475 ++ }
9476 ++ sh_symtab = sec_symtab->symtab;
9477 ++ sym_strtab = sec_symtab->link->strtab;
9478 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
9479 ++ Elf32_Rel *rel;
9480 ++ Elf32_Sym *sym;
9481 ++ unsigned r_type;
9482 ++ const char *symname;
9483 ++ int shn_abs;
9484 ++
9485 ++ rel = &sec->reltab[j];
9486 ++ sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
9487 ++ r_type = ELF32_R_TYPE(rel->r_info);
9488 ++
9489 ++ shn_abs = sym->st_shndx == SHN_ABS;
9490 ++
9491 ++ switch (r_type) {
9492 ++ case R_386_NONE:
9493 ++ case R_386_PC32:
9494 ++ case R_386_PC16:
9495 ++ case R_386_PC8:
9496 ++ /*
9497 ++ * NONE can be ignored and and PC relative
9498 ++ * relocations don't need to be adjusted.
9499 ++ */
9500 ++ break;
9501 ++
9502 ++ case R_386_16:
9503 ++ symname = sym_name(sym_strtab, sym);
9504 ++ if (!use_real_mode)
9505 ++ goto bad;
9506 ++ if (shn_abs) {
9507 ++ if (is_reloc(S_ABS, symname))
9508 ++ break;
9509 ++ else if (!is_reloc(S_SEG, symname))
9510 ++ goto bad;
9511 ++ } else {
9512 ++ if (is_reloc(S_LIN, symname))
9513 ++ goto bad;
9514 ++ else
9515 ++ break;
9516 ++ }
9517 ++ visit(rel, sym);
9518 ++ break;
9519 ++
9520 ++ case R_386_32:
9521 ++ symname = sym_name(sym_strtab, sym);
9522 ++ if (shn_abs) {
9523 ++ if (is_reloc(S_ABS, symname))
9524 ++ break;
9525 ++ else if (!is_reloc(S_REL, symname))
9526 ++ goto bad;
9527 ++ } else {
9528 ++ if (use_real_mode &&
9529 ++ !is_reloc(S_LIN, symname))
9530 ++ break;
9531 ++ }
9532 ++ visit(rel, sym);
9533 ++ break;
9534 ++ default:
9535 ++ die("Unsupported relocation type: %s (%d)\n",
9536 ++ rel_type(r_type), r_type);
9537 ++ break;
9538 ++ bad:
9539 ++ symname = sym_name(sym_strtab, sym);
9540 ++ die("Invalid %s %s relocation: %s\n",
9541 ++ shn_abs ? "absolute" : "relative",
9542 ++ rel_type(r_type), symname);
9543 ++ }
9544 ++ }
9545 ++ }
9546 ++}
9547 ++
9548 ++static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
9549 ++{
9550 ++ if (ELF32_R_TYPE(rel->r_info) == R_386_16)
9551 ++ reloc16_count++;
9552 ++ else
9553 ++ reloc_count++;
9554 ++}
9555 ++
9556 ++static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
9557 ++{
9558 ++ /* Remember the address that needs to be adjusted. */
9559 ++ if (ELF32_R_TYPE(rel->r_info) == R_386_16)
9560 ++ relocs16[reloc16_idx++] = rel->r_offset;
9561 ++ else
9562 ++ relocs[reloc_idx++] = rel->r_offset;
9563 ++}
9564 ++
9565 ++static int cmp_relocs(const void *va, const void *vb)
9566 ++{
9567 ++ const unsigned long *a, *b;
9568 ++ a = va; b = vb;
9569 ++ return (*a == *b)? 0 : (*a > *b)? 1 : -1;
9570 ++}
9571 ++
9572 ++static int write32(unsigned int v, FILE *f)
9573 ++{
9574 ++ unsigned char buf[4];
9575 ++
9576 ++ buf[0] = (v >> 0) & 0xff;
9577 ++ buf[1] = (v >> 8) & 0xff;
9578 ++ buf[2] = (v >> 16) & 0xff;
9579 ++ buf[3] = (v >> 24) & 0xff;
9580 ++ return fwrite(buf, 1, 4, f) == 4 ? 0 : -1;
9581 ++}
9582 ++
9583 ++static void emit_relocs(int as_text, int use_real_mode)
9584 ++{
9585 ++ int i;
9586 ++ /* Count how many relocations I have and allocate space for them. */
9587 ++ reloc_count = 0;
9588 ++ walk_relocs(count_reloc, use_real_mode);
9589 ++ relocs = malloc(reloc_count * sizeof(relocs[0]));
9590 ++ if (!relocs) {
9591 ++ die("malloc of %d entries for relocs failed\n",
9592 ++ reloc_count);
9593 ++ }
9594 ++
9595 ++ relocs16 = malloc(reloc16_count * sizeof(relocs[0]));
9596 ++ if (!relocs16) {
9597 ++ die("malloc of %d entries for relocs16 failed\n",
9598 ++ reloc16_count);
9599 ++ }
9600 ++ /* Collect up the relocations */
9601 ++ reloc_idx = 0;
9602 ++ walk_relocs(collect_reloc, use_real_mode);
9603 ++
9604 ++ if (reloc16_count && !use_real_mode)
9605 ++ die("Segment relocations found but --realmode not specified\n");
9606 ++
9607 ++ /* Order the relocations for more efficient processing */
9608 ++ qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
9609 ++ qsort(relocs16, reloc16_count, sizeof(relocs16[0]), cmp_relocs);
9610 ++
9611 ++ /* Print the relocations */
9612 ++ if (as_text) {
9613 ++ /* Print the relocations in a form suitable that
9614 ++ * gas will like.
9615 ++ */
9616 ++ printf(".section \".data.reloc\",\"a\"\n");
9617 ++ printf(".balign 4\n");
9618 ++ if (use_real_mode) {
9619 ++ printf("\t.long %lu\n", reloc16_count);
9620 ++ for (i = 0; i < reloc16_count; i++)
9621 ++ printf("\t.long 0x%08lx\n", relocs16[i]);
9622 ++ printf("\t.long %lu\n", reloc_count);
9623 ++ for (i = 0; i < reloc_count; i++) {
9624 ++ printf("\t.long 0x%08lx\n", relocs[i]);
9625 ++ }
9626 ++ } else {
9627 ++ /* Print a stop */
9628 ++ printf("\t.long 0x%08lx\n", (unsigned long)0);
9629 ++ for (i = 0; i < reloc_count; i++) {
9630 ++ printf("\t.long 0x%08lx\n", relocs[i]);
9631 ++ }
9632 ++ }
9633 ++
9634 ++ printf("\n");
9635 ++ }
9636 ++ else {
9637 ++ if (use_real_mode) {
9638 ++ write32(reloc16_count, stdout);
9639 ++ for (i = 0; i < reloc16_count; i++)
9640 ++ write32(relocs16[i], stdout);
9641 ++ write32(reloc_count, stdout);
9642 ++
9643 ++ /* Now print each relocation */
9644 ++ for (i = 0; i < reloc_count; i++)
9645 ++ write32(relocs[i], stdout);
9646 ++ } else {
9647 ++ /* Print a stop */
9648 ++ write32(0, stdout);
9649 ++
9650 ++ /* Now print each relocation */
9651 ++ for (i = 0; i < reloc_count; i++) {
9652 ++ write32(relocs[i], stdout);
9653 ++ }
9654 ++ }
9655 ++ }
9656 ++}
9657 ++
9658 ++static void usage(void)
9659 ++{
9660 ++ die("relocs [--abs-syms|--abs-relocs|--text|--realmode] vmlinux\n");
9661 ++}
9662 ++
9663 ++int main(int argc, char **argv)
9664 ++{
9665 ++ int show_absolute_syms, show_absolute_relocs;
9666 ++ int as_text, use_real_mode;
9667 ++ const char *fname;
9668 ++ FILE *fp;
9669 ++ int i;
9670 ++
9671 ++ show_absolute_syms = 0;
9672 ++ show_absolute_relocs = 0;
9673 ++ as_text = 0;
9674 ++ use_real_mode = 0;
9675 ++ fname = NULL;
9676 ++ for (i = 1; i < argc; i++) {
9677 ++ char *arg = argv[i];
9678 ++ if (*arg == '-') {
9679 ++ if (strcmp(arg, "--abs-syms") == 0) {
9680 ++ show_absolute_syms = 1;
9681 ++ continue;
9682 ++ }
9683 ++ if (strcmp(arg, "--abs-relocs") == 0) {
9684 ++ show_absolute_relocs = 1;
9685 ++ continue;
9686 ++ }
9687 ++ if (strcmp(arg, "--text") == 0) {
9688 ++ as_text = 1;
9689 ++ continue;
9690 ++ }
9691 ++ if (strcmp(arg, "--realmode") == 0) {
9692 ++ use_real_mode = 1;
9693 ++ continue;
9694 ++ }
9695 ++ }
9696 ++ else if (!fname) {
9697 ++ fname = arg;
9698 ++ continue;
9699 ++ }
9700 ++ usage();
9701 ++ }
9702 ++ if (!fname) {
9703 ++ usage();
9704 ++ }
9705 ++ regex_init(use_real_mode);
9706 ++ fp = fopen(fname, "r");
9707 ++ if (!fp) {
9708 ++ die("Cannot open %s: %s\n",
9709 ++ fname, strerror(errno));
9710 ++ }
9711 ++ read_ehdr(fp);
9712 ++ read_shdrs(fp);
9713 ++ read_strtabs(fp);
9714 ++ read_symtabs(fp);
9715 ++ read_relocs(fp);
9716 ++ if (show_absolute_syms) {
9717 ++ print_absolute_symbols();
9718 ++ return 0;
9719 ++ }
9720 ++ if (show_absolute_relocs) {
9721 ++ print_absolute_relocs();
9722 ++ return 0;
9723 ++ }
9724 ++ emit_relocs(as_text, use_real_mode);
9725 ++ return 0;
9726 ++}
9727 +diff --git a/block/genhd.c b/block/genhd.c
9728 +index 997afd6..4927476 100644
9729 +--- a/block/genhd.c
9730 ++++ b/block/genhd.c
9731 +@@ -744,7 +744,7 @@ void __init printk_all_partitions(void)
9732 + struct hd_struct *part;
9733 + char name_buf[BDEVNAME_SIZE];
9734 + char devt_buf[BDEVT_SIZE];
9735 +- u8 uuid[PARTITION_META_INFO_UUIDLTH * 2 + 1];
9736 ++ char uuid_buf[PARTITION_META_INFO_UUIDLTH * 2 + 5];
9737 +
9738 + /*
9739 + * Don't show empty devices or things that have been
9740 +@@ -763,14 +763,16 @@ void __init printk_all_partitions(void)
9741 + while ((part = disk_part_iter_next(&piter))) {
9742 + bool is_part0 = part == &disk->part0;
9743 +
9744 +- uuid[0] = 0;
9745 ++ uuid_buf[0] = '\0';
9746 + if (part->info)
9747 +- part_unpack_uuid(part->info->uuid, uuid);
9748 ++ snprintf(uuid_buf, sizeof(uuid_buf), "%pU",
9749 ++ part->info->uuid);
9750 +
9751 + printk("%s%s %10llu %s %s", is_part0 ? "" : " ",
9752 + bdevt_str(part_devt(part), devt_buf),
9753 + (unsigned long long)part->nr_sects >> 1,
9754 +- disk_name(disk, part->partno, name_buf), uuid);
9755 ++ disk_name(disk, part->partno, name_buf),
9756 ++ uuid_buf);
9757 + if (is_part0) {
9758 + if (disk->driverfs_dev != NULL &&
9759 + disk->driverfs_dev->driver != NULL)
9760 +diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
9761 +index 0a7ed69..ca191ff 100644
9762 +--- a/drivers/acpi/sleep.c
9763 ++++ b/drivers/acpi/sleep.c
9764 +@@ -438,6 +438,14 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
9765 + },
9766 + {
9767 + .callback = init_nvs_nosave,
9768 ++ .ident = "Sony Vaio VPCCW29FX",
9769 ++ .matches = {
9770 ++ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
9771 ++ DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
9772 ++ },
9773 ++ },
9774 ++ {
9775 ++ .callback = init_nvs_nosave,
9776 + .ident = "Averatec AV1020-ED2",
9777 + .matches = {
9778 + DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
9779 +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
9780 +index cf26222..fb65915 100644
9781 +--- a/drivers/ata/ahci.c
9782 ++++ b/drivers/ata/ahci.c
9783 +@@ -384,6 +384,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
9784 + .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
9785 + { PCI_DEVICE(0x1b4b, 0x9125),
9786 + .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
9787 ++ { PCI_DEVICE(0x1b4b, 0x917a),
9788 ++ .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
9789 + { PCI_DEVICE(0x1b4b, 0x91a3),
9790 + .driver_data = board_ahci_yes_fbs },
9791 +
9792 +diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
9793 +index 5cd04b6..edcffd6 100644
9794 +--- a/drivers/gpio/gpio-mpc8xxx.c
9795 ++++ b/drivers/gpio/gpio-mpc8xxx.c
9796 +@@ -163,7 +163,8 @@ static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc)
9797 + if (mask)
9798 + generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
9799 + 32 - ffs(mask)));
9800 +- chip->irq_eoi(&desc->irq_data);
9801 ++ if (chip->irq_eoi)
9802 ++ chip->irq_eoi(&desc->irq_data);
9803 + }
9804 +
9805 + static void mpc8xxx_irq_unmask(struct irq_data *d)
9806 +diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
9807 +index d47a53b..d3820c2 100644
9808 +--- a/drivers/gpu/drm/i915/i915_irq.c
9809 ++++ b/drivers/gpu/drm/i915/i915_irq.c
9810 +@@ -424,14 +424,11 @@ static void gen6_pm_rps_work(struct work_struct *work)
9811 + mutex_unlock(&dev_priv->dev->struct_mutex);
9812 + }
9813 +
9814 +-static void pch_irq_handler(struct drm_device *dev)
9815 ++static void pch_irq_handler(struct drm_device *dev, u32 pch_iir)
9816 + {
9817 + drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
9818 +- u32 pch_iir;
9819 + int pipe;
9820 +
9821 +- pch_iir = I915_READ(SDEIIR);
9822 +-
9823 + if (pch_iir & SDE_AUDIO_POWER_MASK)
9824 + DRM_DEBUG_DRIVER("PCH audio power change on port %d\n",
9825 + (pch_iir & SDE_AUDIO_POWER_MASK) >>
9826 +@@ -529,7 +526,7 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
9827 + if (de_iir & DE_PCH_EVENT_IVB) {
9828 + if (pch_iir & SDE_HOTPLUG_MASK_CPT)
9829 + queue_work(dev_priv->wq, &dev_priv->hotplug_work);
9830 +- pch_irq_handler(dev);
9831 ++ pch_irq_handler(dev, pch_iir);
9832 + }
9833 +
9834 + if (pm_iir & GEN6_PM_DEFERRED_EVENTS) {
9835 +@@ -629,7 +626,7 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
9836 + if (de_iir & DE_PCH_EVENT) {
9837 + if (pch_iir & hotplug_mask)
9838 + queue_work(dev_priv->wq, &dev_priv->hotplug_work);
9839 +- pch_irq_handler(dev);
9840 ++ pch_irq_handler(dev, pch_iir);
9841 + }
9842 +
9843 + if (de_iir & DE_PCU_EVENT) {
9844 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
9845 +index cbe5a88..a1d53b6 100644
9846 +--- a/drivers/gpu/drm/i915/i915_reg.h
9847 ++++ b/drivers/gpu/drm/i915/i915_reg.h
9848 +@@ -570,6 +570,21 @@
9849 +
9850 + #define GEN6_BSD_RNCID 0x12198
9851 +
9852 ++#define GEN7_FF_THREAD_MODE 0x20a0
9853 ++#define GEN7_FF_SCHED_MASK 0x0077070
9854 ++#define GEN7_FF_TS_SCHED_HS1 (0x5<<16)
9855 ++#define GEN7_FF_TS_SCHED_HS0 (0x3<<16)
9856 ++#define GEN7_FF_TS_SCHED_LOAD_BALANCE (0x1<<16)
9857 ++#define GEN7_FF_TS_SCHED_HW (0x0<<16) /* Default */
9858 ++#define GEN7_FF_VS_SCHED_HS1 (0x5<<12)
9859 ++#define GEN7_FF_VS_SCHED_HS0 (0x3<<12)
9860 ++#define GEN7_FF_VS_SCHED_LOAD_BALANCE (0x1<<12) /* Default */
9861 ++#define GEN7_FF_VS_SCHED_HW (0x0<<12)
9862 ++#define GEN7_FF_DS_SCHED_HS1 (0x5<<4)
9863 ++#define GEN7_FF_DS_SCHED_HS0 (0x3<<4)
9864 ++#define GEN7_FF_DS_SCHED_LOAD_BALANCE (0x1<<4) /* Default */
9865 ++#define GEN7_FF_DS_SCHED_HW (0x0<<4)
9866 ++
9867 + /*
9868 + * Framebuffer compression (915+ only)
9869 + */
9870 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
9871 +index 390768f..3ff980d 100644
9872 +--- a/drivers/gpu/drm/i915/intel_display.c
9873 ++++ b/drivers/gpu/drm/i915/intel_display.c
9874 +@@ -7280,10 +7280,11 @@ static void intel_sanitize_modesetting(struct drm_device *dev,
9875 + {
9876 + struct drm_i915_private *dev_priv = dev->dev_private;
9877 + u32 reg, val;
9878 ++ int i;
9879 +
9880 + /* Clear any frame start delays used for debugging left by the BIOS */
9881 +- for_each_pipe(pipe) {
9882 +- reg = PIPECONF(pipe);
9883 ++ for_each_pipe(i) {
9884 ++ reg = PIPECONF(i);
9885 + I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK);
9886 + }
9887 +
9888 +@@ -8245,6 +8246,18 @@ static void gen6_init_clock_gating(struct drm_device *dev)
9889 + }
9890 + }
9891 +
9892 ++static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
9893 ++{
9894 ++ uint32_t reg = I915_READ(GEN7_FF_THREAD_MODE);
9895 ++
9896 ++ reg &= ~GEN7_FF_SCHED_MASK;
9897 ++ reg |= GEN7_FF_TS_SCHED_HW;
9898 ++ reg |= GEN7_FF_VS_SCHED_HW;
9899 ++ reg |= GEN7_FF_DS_SCHED_HW;
9900 ++
9901 ++ I915_WRITE(GEN7_FF_THREAD_MODE, reg);
9902 ++}
9903 ++
9904 + static void ivybridge_init_clock_gating(struct drm_device *dev)
9905 + {
9906 + struct drm_i915_private *dev_priv = dev->dev_private;
9907 +@@ -8285,6 +8298,8 @@ static void ivybridge_init_clock_gating(struct drm_device *dev)
9908 + DISPPLANE_TRICKLE_FEED_DISABLE);
9909 + intel_flush_display_plane(dev_priv, pipe);
9910 + }
9911 ++
9912 ++ gen7_setup_fixed_func_scheduler(dev_priv);
9913 + }
9914 +
9915 + static void g4x_init_clock_gating(struct drm_device *dev)
9916 +diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
9917 +index 7cc37e6..d5af089 100644
9918 +--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
9919 ++++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
9920 +@@ -1024,7 +1024,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
9921 +
9922 + nvbo->placement.fpfn = 0;
9923 + nvbo->placement.lpfn = dev_priv->fb_mappable_pages;
9924 +- nouveau_bo_placement_set(nvbo, TTM_PL_VRAM, 0);
9925 ++ nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0);
9926 + return nouveau_bo_validate(nvbo, false, true, false);
9927 + }
9928 +
9929 +diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
9930 +index 38b12e4..2eac8c5 100644
9931 +--- a/drivers/hid/hid-logitech-dj.c
9932 ++++ b/drivers/hid/hid-logitech-dj.c
9933 +@@ -26,6 +26,7 @@
9934 + #include <linux/hid.h>
9935 + #include <linux/module.h>
9936 + #include <linux/usb.h>
9937 ++#include <asm/unaligned.h>
9938 + #include "usbhid/usbhid.h"
9939 + #include "hid-ids.h"
9940 + #include "hid-logitech-dj.h"
9941 +@@ -265,8 +266,8 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
9942 + goto dj_device_allocate_fail;
9943 + }
9944 +
9945 +- dj_dev->reports_supported = le32_to_cpu(
9946 +- dj_report->report_params[DEVICE_PAIRED_RF_REPORT_TYPE]);
9947 ++ dj_dev->reports_supported = get_unaligned_le32(
9948 ++ dj_report->report_params + DEVICE_PAIRED_RF_REPORT_TYPE);
9949 + dj_dev->hdev = dj_hiddev;
9950 + dj_dev->dj_receiver_dev = djrcv_dev;
9951 + dj_dev->device_index = dj_report->device_index;
9952 +diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
9953 +index 76739c0..bfa9a27 100644
9954 +--- a/drivers/hid/hid-wiimote.c
9955 ++++ b/drivers/hid/hid-wiimote.c
9956 +@@ -829,7 +829,7 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
9957 +
9958 + /*
9959 + * Basic IR data is encoded into 3 bytes. The first two bytes are the
9960 +- * upper 8 bit of the X/Y data, the 3rd byte contains the lower 2 bits
9961 ++ * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits
9962 + * of both.
9963 + * If data is packed, then the 3rd byte is put first and slightly
9964 + * reordered. This allows to interleave packed and non-packed data to
9965 +@@ -838,17 +838,11 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
9966 + */
9967 +
9968 + if (packed) {
9969 +- x = ir[1] << 2;
9970 +- y = ir[2] << 2;
9971 +-
9972 +- x |= ir[0] & 0x3;
9973 +- y |= (ir[0] >> 2) & 0x3;
9974 ++ x = ir[1] | ((ir[0] & 0x03) << 8);
9975 ++ y = ir[2] | ((ir[0] & 0x0c) << 6);
9976 + } else {
9977 +- x = ir[0] << 2;
9978 +- y = ir[1] << 2;
9979 +-
9980 +- x |= (ir[2] >> 4) & 0x3;
9981 +- y |= (ir[2] >> 6) & 0x3;
9982 ++ x = ir[0] | ((ir[2] & 0x30) << 4);
9983 ++ y = ir[1] | ((ir[2] & 0xc0) << 2);
9984 + }
9985 +
9986 + input_report_abs(wdata->ir, xid, x);
9987 +diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
9988 +index a76d85f..79b4bcb 100644
9989 +--- a/drivers/i2c/busses/i2c-davinci.c
9990 ++++ b/drivers/i2c/busses/i2c-davinci.c
9991 +@@ -755,7 +755,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
9992 + dev->clk = NULL;
9993 +
9994 + davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
9995 +- free_irq(IRQ_I2C, dev);
9996 ++ free_irq(dev->irq, dev);
9997 + iounmap(dev->base);
9998 + kfree(dev);
9999 +
10000 +diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
10001 +index 730215e..2cda65bf 100644
10002 +--- a/drivers/i2c/busses/i2c-eg20t.c
10003 ++++ b/drivers/i2c/busses/i2c-eg20t.c
10004 +@@ -315,7 +315,7 @@ static s32 pch_i2c_wait_for_xfer_complete(struct i2c_algo_pch_data *adap)
10005 + {
10006 + long ret;
10007 + ret = wait_event_timeout(pch_event,
10008 +- (adap->pch_event_flag != 0), msecs_to_jiffies(50));
10009 ++ (adap->pch_event_flag != 0), msecs_to_jiffies(1000));
10010 +
10011 + if (ret == 0) {
10012 + pch_err(adap, "timeout: %x\n", adap->pch_event_flag);
10013 +diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
10014 +index 46b6500..3d7885a 100644
10015 +--- a/drivers/i2c/busses/i2c-tegra.c
10016 ++++ b/drivers/i2c/busses/i2c-tegra.c
10017 +@@ -401,8 +401,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
10018 + disable_irq_nosync(i2c_dev->irq);
10019 + i2c_dev->irq_disabled = 1;
10020 + }
10021 +-
10022 +- complete(&i2c_dev->msg_complete);
10023 + goto err;
10024 + }
10025 +
10026 +@@ -411,7 +409,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
10027 + i2c_dev->msg_err |= I2C_ERR_NO_ACK;
10028 + if (status & I2C_INT_ARBITRATION_LOST)
10029 + i2c_dev->msg_err |= I2C_ERR_ARBITRATION_LOST;
10030 +- complete(&i2c_dev->msg_complete);
10031 + goto err;
10032 + }
10033 +
10034 +@@ -429,14 +426,14 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
10035 + tegra_i2c_mask_irq(i2c_dev, I2C_INT_TX_FIFO_DATA_REQ);
10036 + }
10037 +
10038 ++ i2c_writel(i2c_dev, status, I2C_INT_STATUS);
10039 ++ if (i2c_dev->is_dvc)
10040 ++ dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
10041 ++
10042 + if (status & I2C_INT_PACKET_XFER_COMPLETE) {
10043 + BUG_ON(i2c_dev->msg_buf_remaining);
10044 + complete(&i2c_dev->msg_complete);
10045 + }
10046 +-
10047 +- i2c_writel(i2c_dev, status, I2C_INT_STATUS);
10048 +- if (i2c_dev->is_dvc)
10049 +- dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
10050 + return IRQ_HANDLED;
10051 + err:
10052 + /* An error occurred, mask all interrupts */
10053 +@@ -446,6 +443,8 @@ err:
10054 + i2c_writel(i2c_dev, status, I2C_INT_STATUS);
10055 + if (i2c_dev->is_dvc)
10056 + dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
10057 ++
10058 ++ complete(&i2c_dev->msg_complete);
10059 + return IRQ_HANDLED;
10060 + }
10061 +
10062 +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
10063 +index 71f0c0f..a841123 100644
10064 +--- a/drivers/infiniband/core/umem.c
10065 ++++ b/drivers/infiniband/core/umem.c
10066 +@@ -269,7 +269,7 @@ void ib_umem_release(struct ib_umem *umem)
10067 + } else
10068 + down_write(&mm->mmap_sem);
10069 +
10070 +- current->mm->locked_vm -= diff;
10071 ++ current->mm->pinned_vm -= diff;
10072 + up_write(&mm->mmap_sem);
10073 + mmput(mm);
10074 + kfree(umem);
10075 +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
10076 +index 0747004..2e6a538 100644
10077 +--- a/drivers/infiniband/hw/cxgb4/cm.c
10078 ++++ b/drivers/infiniband/hw/cxgb4/cm.c
10079 +@@ -2714,6 +2714,12 @@ static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
10080 + unsigned int tid = GET_TID(req);
10081 +
10082 + ep = lookup_tid(t, tid);
10083 ++ if (!ep) {
10084 ++ printk(KERN_WARNING MOD
10085 ++ "Abort on non-existent endpoint, tid %d\n", tid);
10086 ++ kfree_skb(skb);
10087 ++ return 0;
10088 ++ }
10089 + if (is_neg_adv_abort(req->status)) {
10090 + PDBG("%s neg_adv_abort ep %p tid %u\n", __func__, ep,
10091 + ep->hwtid);
10092 +@@ -2725,11 +2731,8 @@ static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
10093 +
10094 + /*
10095 + * Wake up any threads in rdma_init() or rdma_fini().
10096 +- * However, this is not needed if com state is just
10097 +- * MPA_REQ_SENT
10098 + */
10099 +- if (ep->com.state != MPA_REQ_SENT)
10100 +- c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
10101 ++ c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
10102 + sched(dev, skb);
10103 + return 0;
10104 + }
10105 +diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
10106 +index 2ee47d0..f00c70e 100644
10107 +--- a/drivers/input/tablet/wacom_wac.c
10108 ++++ b/drivers/input/tablet/wacom_wac.c
10109 +@@ -843,12 +843,7 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
10110 + unsigned char *data = wacom->data;
10111 + int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
10112 +
10113 +- /*
10114 +- * Similar to Graphire protocol, data[1] & 0x20 is proximity and
10115 +- * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore
10116 +- * 2 unused tool ID's.
10117 +- */
10118 +- prox = (data[1] & 0x30) == 0x30;
10119 ++ prox = (data[1] & 0x20) == 0x20;
10120 +
10121 + /*
10122 + * All reports shared between PEN and RUBBER tool must be
10123 +diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
10124 +index 35c1e17..97b2e21 100644
10125 +--- a/drivers/iommu/dmar.c
10126 ++++ b/drivers/iommu/dmar.c
10127 +@@ -1056,8 +1056,8 @@ static const char *intr_remap_fault_reasons[] =
10128 +
10129 + const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type)
10130 + {
10131 +- if (fault_reason >= 0x20 && (fault_reason <= 0x20 +
10132 +- ARRAY_SIZE(intr_remap_fault_reasons))) {
10133 ++ if (fault_reason >= 0x20 && (fault_reason - 0x20 <
10134 ++ ARRAY_SIZE(intr_remap_fault_reasons))) {
10135 + *fault_type = INTR_REMAP;
10136 + return intr_remap_fault_reasons[fault_reason - 0x20];
10137 + } else if (fault_reason < ARRAY_SIZE(dma_remap_fault_reasons)) {
10138 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
10139 +index bdc447f..ccf347f 100644
10140 +--- a/drivers/iommu/intel-iommu.c
10141 ++++ b/drivers/iommu/intel-iommu.c
10142 +@@ -2267,12 +2267,6 @@ static int domain_add_dev_info(struct dmar_domain *domain,
10143 + if (!info)
10144 + return -ENOMEM;
10145 +
10146 +- ret = domain_context_mapping(domain, pdev, translation);
10147 +- if (ret) {
10148 +- free_devinfo_mem(info);
10149 +- return ret;
10150 +- }
10151 +-
10152 + info->segment = pci_domain_nr(pdev->bus);
10153 + info->bus = pdev->bus->number;
10154 + info->devfn = pdev->devfn;
10155 +@@ -2285,6 +2279,17 @@ static int domain_add_dev_info(struct dmar_domain *domain,
10156 + pdev->dev.archdata.iommu = info;
10157 + spin_unlock_irqrestore(&device_domain_lock, flags);
10158 +
10159 ++ ret = domain_context_mapping(domain, pdev, translation);
10160 ++ if (ret) {
10161 ++ spin_lock_irqsave(&device_domain_lock, flags);
10162 ++ list_del(&info->link);
10163 ++ list_del(&info->global);
10164 ++ pdev->dev.archdata.iommu = NULL;
10165 ++ spin_unlock_irqrestore(&device_domain_lock, flags);
10166 ++ free_devinfo_mem(info);
10167 ++ return ret;
10168 ++ }
10169 ++
10170 + return 0;
10171 + }
10172 +
10173 +diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
10174 +index 6d5ceee..fd17bb3 100644
10175 +--- a/drivers/isdn/gigaset/capi.c
10176 ++++ b/drivers/isdn/gigaset/capi.c
10177 +@@ -14,6 +14,7 @@
10178 + #include "gigaset.h"
10179 + #include <linux/proc_fs.h>
10180 + #include <linux/seq_file.h>
10181 ++#include <linux/ratelimit.h>
10182 + #include <linux/isdn/capilli.h>
10183 + #include <linux/isdn/capicmd.h>
10184 + #include <linux/isdn/capiutil.h>
10185 +@@ -223,10 +224,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)
10186 + static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p)
10187 + {
10188 + #ifdef CONFIG_GIGASET_DEBUG
10189 ++ /* dump at most 20 messages in 20 secs */
10190 ++ static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);
10191 + _cdebbuf *cdb;
10192 +
10193 + if (!(gigaset_debuglevel & level))
10194 + return;
10195 ++ if (!___ratelimit(&msg_dump_ratelimit, tag))
10196 ++ return;
10197 +
10198 + cdb = capi_cmsg2str(p);
10199 + if (cdb) {
10200 +@@ -1882,6 +1887,9 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
10201 +
10202 + /* check for active logical connection */
10203 + if (bcs->apconnstate >= APCONN_ACTIVE) {
10204 ++ /* clear it */
10205 ++ bcs->apconnstate = APCONN_SETUP;
10206 ++
10207 + /*
10208 + * emit DISCONNECT_B3_IND with cause 0x3301
10209 + * use separate cmsg structure, as the content of iif->acmsg
10210 +@@ -1906,6 +1914,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
10211 + }
10212 + capi_cmsg2message(b3cmsg,
10213 + __skb_put(b3skb, CAPI_DISCONNECT_B3_IND_BASELEN));
10214 ++ dump_cmsg(DEBUG_CMD, __func__, b3cmsg);
10215 + kfree(b3cmsg);
10216 + capi_ctr_handle_message(&iif->ctr, ap->id, b3skb);
10217 + }
10218 +@@ -2059,12 +2068,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif,
10219 + }
10220 +
10221 + /*
10222 +- * dump unsupported/ignored messages at most twice per minute,
10223 +- * some apps send those very frequently
10224 +- */
10225 +-static unsigned long ignored_msg_dump_time;
10226 +-
10227 +-/*
10228 + * unsupported CAPI message handler
10229 + */
10230 + static void do_unsupported(struct gigaset_capi_ctr *iif,
10231 +@@ -2073,8 +2076,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif,
10232 + {
10233 + /* decode message */
10234 + capi_message2cmsg(&iif->acmsg, skb->data);
10235 +- if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000))
10236 +- dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
10237 ++ dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
10238 + send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
10239 + }
10240 +
10241 +@@ -2085,11 +2087,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,
10242 + struct gigaset_capi_appl *ap,
10243 + struct sk_buff *skb)
10244 + {
10245 +- if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) {
10246 +- /* decode message */
10247 +- capi_message2cmsg(&iif->acmsg, skb->data);
10248 +- dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
10249 +- }
10250 ++ /* decode message */
10251 ++ capi_message2cmsg(&iif->acmsg, skb->data);
10252 ++ dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
10253 + dev_kfree_skb_any(skb);
10254 + }
10255 +
10256 +diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
10257 +index 6d12623..e95fac0 100644
10258 +--- a/drivers/isdn/gigaset/ev-layer.c
10259 ++++ b/drivers/isdn/gigaset/ev-layer.c
10260 +@@ -190,6 +190,7 @@ struct reply_t gigaset_tab_nocid[] =
10261 + ACT_INIT} },
10262 + {RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER,
10263 + ACT_INIT} },
10264 ++{RSP_NONE, 121, 121, -1, 120, 0, {ACT_GETSTRING} },
10265 +
10266 + /* leave dle mode */
10267 + {RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"},
10268 +@@ -1314,8 +1315,9 @@ static void do_action(int action, struct cardstate *cs,
10269 + s = ev->ptr;
10270 +
10271 + if (!strcmp(s, "OK")) {
10272 ++ /* OK without version string: assume old response */
10273 + *p_genresp = 1;
10274 +- *p_resp_code = RSP_ERROR;
10275 ++ *p_resp_code = RSP_NONE;
10276 + break;
10277 + }
10278 +
10279 +diff --git a/drivers/md/md.c b/drivers/md/md.c
10280 +index adcd850..700ecae 100644
10281 +--- a/drivers/md/md.c
10282 ++++ b/drivers/md/md.c
10283 +@@ -453,7 +453,7 @@ static void submit_flushes(struct work_struct *ws)
10284 + atomic_inc(&rdev->nr_pending);
10285 + atomic_inc(&rdev->nr_pending);
10286 + rcu_read_unlock();
10287 +- bi = bio_alloc_mddev(GFP_KERNEL, 0, mddev);
10288 ++ bi = bio_alloc_mddev(GFP_NOIO, 0, mddev);
10289 + bi->bi_end_io = md_end_flush;
10290 + bi->bi_private = rdev;
10291 + bi->bi_bdev = rdev->bdev;
10292 +diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
10293 +index 51c7121..b7d1e3e 100644
10294 +--- a/drivers/media/dvb/siano/smsusb.c
10295 ++++ b/drivers/media/dvb/siano/smsusb.c
10296 +@@ -542,6 +542,8 @@ static const struct usb_device_id smsusb_id_table[] __devinitconst = {
10297 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
10298 + { USB_DEVICE(0x2040, 0xc090),
10299 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
10300 ++ { USB_DEVICE(0x2040, 0xc0a0),
10301 ++ .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
10302 + { } /* Terminating entry */
10303 + };
10304 +
10305 +diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
10306 +index cf7788f..1030479 100644
10307 +--- a/drivers/media/video/uvc/uvc_v4l2.c
10308 ++++ b/drivers/media/video/uvc/uvc_v4l2.c
10309 +@@ -689,7 +689,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
10310 + break;
10311 + }
10312 + pin = iterm->id;
10313 +- } else if (pin < selector->bNrInPins) {
10314 ++ } else if (index < selector->bNrInPins) {
10315 + pin = selector->baSourceID[index];
10316 + list_for_each_entry(iterm, &chain->entities, chain) {
10317 + if (!UVC_ENTITY_IS_ITERM(iterm))
10318 +diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
10319 +index 3ab565e..558a495 100644
10320 +--- a/drivers/mmc/core/sdio.c
10321 ++++ b/drivers/mmc/core/sdio.c
10322 +@@ -663,7 +663,7 @@ static int mmc_sdio_resume(struct mmc_host *host)
10323 + }
10324 +
10325 + if (!err && host->sdio_irqs)
10326 +- mmc_signal_sdio_irq(host);
10327 ++ wake_up_process(host->sdio_irq_thread);
10328 + mmc_release_host(host);
10329 +
10330 + /*
10331 +diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
10332 +index 68f81b9..9dd0462 100644
10333 +--- a/drivers/mmc/core/sdio_irq.c
10334 ++++ b/drivers/mmc/core/sdio_irq.c
10335 +@@ -28,18 +28,20 @@
10336 +
10337 + #include "sdio_ops.h"
10338 +
10339 +-static int process_sdio_pending_irqs(struct mmc_card *card)
10340 ++static int process_sdio_pending_irqs(struct mmc_host *host)
10341 + {
10342 ++ struct mmc_card *card = host->card;
10343 + int i, ret, count;
10344 + unsigned char pending;
10345 + struct sdio_func *func;
10346 +
10347 + /*
10348 + * Optimization, if there is only 1 function interrupt registered
10349 +- * call irq handler directly
10350 ++ * and we know an IRQ was signaled then call irq handler directly.
10351 ++ * Otherwise do the full probe.
10352 + */
10353 + func = card->sdio_single_irq;
10354 +- if (func) {
10355 ++ if (func && host->sdio_irq_pending) {
10356 + func->irq_handler(func);
10357 + return 1;
10358 + }
10359 +@@ -116,7 +118,8 @@ static int sdio_irq_thread(void *_host)
10360 + ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort);
10361 + if (ret)
10362 + break;
10363 +- ret = process_sdio_pending_irqs(host->card);
10364 ++ ret = process_sdio_pending_irqs(host);
10365 ++ host->sdio_irq_pending = false;
10366 + mmc_release_host(host);
10367 +
10368 + /*
10369 +diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
10370 +index fddb714..a9ff89ff 100644
10371 +--- a/drivers/mtd/sm_ftl.c
10372 ++++ b/drivers/mtd/sm_ftl.c
10373 +@@ -1256,7 +1256,7 @@ static void sm_remove_dev(struct mtd_blktrans_dev *dev)
10374 +
10375 + static struct mtd_blktrans_ops sm_ftl_ops = {
10376 + .name = "smblk",
10377 +- .major = -1,
10378 ++ .major = 0,
10379 + .part_bits = SM_FTL_PARTN_BITS,
10380 + .blksize = SM_SECTOR_SIZE,
10381 + .getgeo = sm_getgeo,
10382 +diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
10383 +index b2dc2c8..2e09edb 100644
10384 +--- a/drivers/net/ethernet/dlink/dl2k.c
10385 ++++ b/drivers/net/ethernet/dlink/dl2k.c
10386 +@@ -1259,55 +1259,21 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
10387 + {
10388 + int phy_addr;
10389 + struct netdev_private *np = netdev_priv(dev);
10390 +- struct mii_data *miidata = (struct mii_data *) &rq->ifr_ifru;
10391 +-
10392 +- struct netdev_desc *desc;
10393 +- int i;
10394 ++ struct mii_ioctl_data *miidata = if_mii(rq);
10395 +
10396 + phy_addr = np->phy_addr;
10397 + switch (cmd) {
10398 +- case SIOCDEVPRIVATE:
10399 +- break;
10400 +-
10401 +- case SIOCDEVPRIVATE + 1:
10402 +- miidata->out_value = mii_read (dev, phy_addr, miidata->reg_num);
10403 ++ case SIOCGMIIPHY:
10404 ++ miidata->phy_id = phy_addr;
10405 + break;
10406 +- case SIOCDEVPRIVATE + 2:
10407 +- mii_write (dev, phy_addr, miidata->reg_num, miidata->in_value);
10408 ++ case SIOCGMIIREG:
10409 ++ miidata->val_out = mii_read (dev, phy_addr, miidata->reg_num);
10410 + break;
10411 +- case SIOCDEVPRIVATE + 3:
10412 +- break;
10413 +- case SIOCDEVPRIVATE + 4:
10414 +- break;
10415 +- case SIOCDEVPRIVATE + 5:
10416 +- netif_stop_queue (dev);
10417 ++ case SIOCSMIIREG:
10418 ++ if (!capable(CAP_NET_ADMIN))
10419 ++ return -EPERM;
10420 ++ mii_write (dev, phy_addr, miidata->reg_num, miidata->val_in);
10421 + break;
10422 +- case SIOCDEVPRIVATE + 6:
10423 +- netif_wake_queue (dev);
10424 +- break;
10425 +- case SIOCDEVPRIVATE + 7:
10426 +- printk
10427 +- ("tx_full=%x cur_tx=%lx old_tx=%lx cur_rx=%lx old_rx=%lx\n",
10428 +- netif_queue_stopped(dev), np->cur_tx, np->old_tx, np->cur_rx,
10429 +- np->old_rx);
10430 +- break;
10431 +- case SIOCDEVPRIVATE + 8:
10432 +- printk("TX ring:\n");
10433 +- for (i = 0; i < TX_RING_SIZE; i++) {
10434 +- desc = &np->tx_ring[i];
10435 +- printk
10436 +- ("%02x:cur:%08x next:%08x status:%08x frag1:%08x frag0:%08x",
10437 +- i,
10438 +- (u32) (np->tx_ring_dma + i * sizeof (*desc)),
10439 +- (u32)le64_to_cpu(desc->next_desc),
10440 +- (u32)le64_to_cpu(desc->status),
10441 +- (u32)(le64_to_cpu(desc->fraginfo) >> 32),
10442 +- (u32)le64_to_cpu(desc->fraginfo));
10443 +- printk ("\n");
10444 +- }
10445 +- printk ("\n");
10446 +- break;
10447 +-
10448 + default:
10449 + return -EOPNOTSUPP;
10450 + }
10451 +diff --git a/drivers/net/ethernet/dlink/dl2k.h b/drivers/net/ethernet/dlink/dl2k.h
10452 +index ba0adca..30c2da3 100644
10453 +--- a/drivers/net/ethernet/dlink/dl2k.h
10454 ++++ b/drivers/net/ethernet/dlink/dl2k.h
10455 +@@ -365,13 +365,6 @@ struct ioctl_data {
10456 + char *data;
10457 + };
10458 +
10459 +-struct mii_data {
10460 +- __u16 reserved;
10461 +- __u16 reg_num;
10462 +- __u16 in_value;
10463 +- __u16 out_value;
10464 +-};
10465 +-
10466 + /* The Rx and Tx buffer descriptors. */
10467 + struct netdev_desc {
10468 + __le64 next_desc;
10469 +diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
10470 +index bf8153e..7570c1a 100644
10471 +--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
10472 ++++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
10473 +@@ -649,12 +649,8 @@ static int
10474 + be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
10475 + {
10476 + struct be_adapter *adapter = netdev_priv(netdev);
10477 +- char file_name[ETHTOOL_FLASH_MAX_FILENAME];
10478 +
10479 +- file_name[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0;
10480 +- strcpy(file_name, efl->data);
10481 +-
10482 +- return be_load_fw(adapter, file_name);
10483 ++ return be_load_fw(adapter, efl->data);
10484 + }
10485 +
10486 + static int
10487 +diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
10488 +index 20f0243..c5ce163 100644
10489 +--- a/drivers/net/wireless/b43legacy/main.c
10490 ++++ b/drivers/net/wireless/b43legacy/main.c
10491 +@@ -1564,8 +1564,6 @@ static int b43legacy_request_firmware(struct b43legacy_wldev *dev)
10492 + const char *filename;
10493 + int err;
10494 +
10495 +- /* do dummy read */
10496 +- ssb_read32(dev->dev, SSB_TMSHIGH);
10497 + if (!fw->ucode) {
10498 + if (rev == 2)
10499 + filename = "ucode2";
10500 +diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
10501 +index 2b7bcc8..db34db6 100644
10502 +--- a/drivers/net/wireless/rtlwifi/usb.c
10503 ++++ b/drivers/net/wireless/rtlwifi/usb.c
10504 +@@ -113,46 +113,38 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
10505 + return status;
10506 + }
10507 +
10508 +-static u32 _usb_read_sync(struct usb_device *udev, u32 addr, u16 len)
10509 ++static u32 _usb_read_sync(struct rtl_priv *rtlpriv, u32 addr, u16 len)
10510 + {
10511 ++ struct device *dev = rtlpriv->io.dev;
10512 ++ struct usb_device *udev = to_usb_device(dev);
10513 + u8 request;
10514 + u16 wvalue;
10515 + u16 index;
10516 +- u32 *data;
10517 +- u32 ret;
10518 ++ __le32 *data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
10519 +
10520 +- data = kmalloc(sizeof(u32), GFP_KERNEL);
10521 +- if (!data)
10522 +- return -ENOMEM;
10523 + request = REALTEK_USB_VENQT_CMD_REQ;
10524 + index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
10525 +
10526 + wvalue = (u16)addr;
10527 + _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len);
10528 +- ret = *data;
10529 +- kfree(data);
10530 +- return ret;
10531 ++ if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
10532 ++ rtlpriv->usb_data_index = 0;
10533 ++ return le32_to_cpu(*data);
10534 + }
10535 +
10536 + static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
10537 + {
10538 +- struct device *dev = rtlpriv->io.dev;
10539 +-
10540 +- return (u8)_usb_read_sync(to_usb_device(dev), addr, 1);
10541 ++ return (u8)_usb_read_sync(rtlpriv, addr, 1);
10542 + }
10543 +
10544 + static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
10545 + {
10546 +- struct device *dev = rtlpriv->io.dev;
10547 +-
10548 +- return (u16)_usb_read_sync(to_usb_device(dev), addr, 2);
10549 ++ return (u16)_usb_read_sync(rtlpriv, addr, 2);
10550 + }
10551 +
10552 + static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
10553 + {
10554 +- struct device *dev = rtlpriv->io.dev;
10555 +-
10556 +- return _usb_read_sync(to_usb_device(dev), addr, 4);
10557 ++ return _usb_read_sync(rtlpriv, addr, 4);
10558 + }
10559 +
10560 + static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val,
10561 +@@ -913,6 +905,11 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
10562 + return -ENOMEM;
10563 + }
10564 + rtlpriv = hw->priv;
10565 ++ rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
10566 ++ GFP_KERNEL);
10567 ++ if (!rtlpriv->usb_data)
10568 ++ return -ENOMEM;
10569 ++ rtlpriv->usb_data_index = 0;
10570 + SET_IEEE80211_DEV(hw, &intf->dev);
10571 + udev = interface_to_usbdev(intf);
10572 + usb_get_dev(udev);
10573 +@@ -990,6 +987,7 @@ void rtl_usb_disconnect(struct usb_interface *intf)
10574 + /* rtl_deinit_rfkill(hw); */
10575 + rtl_usb_deinit(hw);
10576 + rtl_deinit_core(hw);
10577 ++ kfree(rtlpriv->usb_data);
10578 + rtlpriv->cfg->ops->deinit_sw_leds(hw);
10579 + rtlpriv->cfg->ops->deinit_sw_vars(hw);
10580 + _rtl_usb_io_handler_release(hw);
10581 +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
10582 +index 713c7dd..b1e9deb 100644
10583 +--- a/drivers/net/wireless/rtlwifi/wifi.h
10584 ++++ b/drivers/net/wireless/rtlwifi/wifi.h
10585 +@@ -63,7 +63,7 @@
10586 + #define AC_MAX 4
10587 + #define QOS_QUEUE_NUM 4
10588 + #define RTL_MAC80211_NUM_QUEUE 5
10589 +-
10590 ++#define RTL_USB_MAX_RX_COUNT 100
10591 + #define QBSS_LOAD_SIZE 5
10592 + #define MAX_WMMELE_LENGTH 64
10593 +
10594 +@@ -1621,6 +1621,10 @@ struct rtl_priv {
10595 + interface or hardware */
10596 + unsigned long status;
10597 +
10598 ++ /* data buffer pointer for USB reads */
10599 ++ __le32 *usb_data;
10600 ++ int usb_data_index;
10601 ++
10602 + /*This must be the last item so
10603 + that it points to the data allocated
10604 + beyond this structure like:
10605 +diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
10606 +index c006dee..40c4705 100644
10607 +--- a/drivers/platform/x86/sony-laptop.c
10608 ++++ b/drivers/platform/x86/sony-laptop.c
10609 +@@ -127,7 +127,7 @@ MODULE_PARM_DESC(minor,
10610 + "default is -1 (automatic)");
10611 + #endif
10612 +
10613 +-static int kbd_backlight; /* = 1 */
10614 ++static int kbd_backlight = 1;
10615 + module_param(kbd_backlight, int, 0444);
10616 + MODULE_PARM_DESC(kbd_backlight,
10617 + "set this to 0 to disable keyboard backlight, "
10618 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
10619 +index 938398f..6ec610c 100644
10620 +--- a/drivers/regulator/core.c
10621 ++++ b/drivers/regulator/core.c
10622 +@@ -2765,6 +2765,8 @@ unset_supplies:
10623 + unset_regulator_supplies(rdev);
10624 +
10625 + scrub:
10626 ++ if (rdev->supply)
10627 ++ regulator_put(rdev->supply);
10628 + kfree(rdev->constraints);
10629 + device_unregister(&rdev->dev);
10630 + /* device core frees rdev */
10631 +diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
10632 +index e86edfc..1e80a48 100644
10633 +--- a/drivers/rtc/rtc-pl031.c
10634 ++++ b/drivers/rtc/rtc-pl031.c
10635 +@@ -312,6 +312,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
10636 + int ret;
10637 + struct pl031_local *ldata;
10638 + struct rtc_class_ops *ops = id->data;
10639 ++ unsigned long time;
10640 +
10641 + ret = amba_request_regions(adev, NULL);
10642 + if (ret)
10643 +@@ -343,6 +344,23 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
10644 + writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
10645 + ldata->base + RTC_CR);
10646 +
10647 ++ /*
10648 ++ * On ST PL031 variants, the RTC reset value does not provide correct
10649 ++ * weekday for 2000-01-01. Correct the erroneous sunday to saturday.
10650 ++ */
10651 ++ if (ldata->hw_designer == AMBA_VENDOR_ST) {
10652 ++ if (readl(ldata->base + RTC_YDR) == 0x2000) {
10653 ++ time = readl(ldata->base + RTC_DR);
10654 ++ if ((time &
10655 ++ (RTC_MON_MASK | RTC_MDAY_MASK | RTC_WDAY_MASK))
10656 ++ == 0x02120000) {
10657 ++ time = time | (0x7 << RTC_WDAY_SHIFT);
10658 ++ writel(0x2000, ldata->base + RTC_YLR);
10659 ++ writel(time, ldata->base + RTC_LR);
10660 ++ }
10661 ++ }
10662 ++ }
10663 ++
10664 + ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
10665 + THIS_MODULE);
10666 + if (IS_ERR(ldata->rtc)) {
10667 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
10668 +index 865d452..b4d2c86 100644
10669 +--- a/drivers/scsi/hpsa.c
10670 ++++ b/drivers/scsi/hpsa.c
10671 +@@ -1674,30 +1674,26 @@ static void figure_bus_target_lun(struct ctlr_info *h,
10672 +
10673 + if (is_logical_dev_addr_mode(lunaddrbytes)) {
10674 + /* logical device */
10675 +- if (unlikely(is_scsi_rev_5(h))) {
10676 +- /* p1210m, logical drives lun assignments
10677 +- * match SCSI REPORT LUNS data.
10678 ++ lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
10679 ++ if (is_msa2xxx(h, device)) {
10680 ++ /* msa2xxx way, put logicals on bus 1
10681 ++ * and match target/lun numbers box
10682 ++ * reports.
10683 + */
10684 +- lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
10685 +- *bus = 0;
10686 +- *target = 0;
10687 +- *lun = (lunid & 0x3fff) + 1;
10688 ++ *bus = 1;
10689 ++ *target = (lunid >> 16) & 0x3fff;
10690 ++ *lun = lunid & 0x00ff;
10691 + } else {
10692 +- /* not p1210m... */
10693 +- lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
10694 +- if (is_msa2xxx(h, device)) {
10695 +- /* msa2xxx way, put logicals on bus 1
10696 +- * and match target/lun numbers box
10697 +- * reports.
10698 +- */
10699 +- *bus = 1;
10700 +- *target = (lunid >> 16) & 0x3fff;
10701 +- *lun = lunid & 0x00ff;
10702 ++ if (likely(is_scsi_rev_5(h))) {
10703 ++ /* All current smart arrays (circa 2011) */
10704 ++ *bus = 0;
10705 ++ *target = 0;
10706 ++ *lun = (lunid & 0x3fff) + 1;
10707 + } else {
10708 +- /* Traditional smart array way. */
10709 ++ /* Traditional old smart array way. */
10710 + *bus = 0;
10711 +- *lun = 0;
10712 + *target = lunid & 0x3fff;
10713 ++ *lun = 0;
10714 + }
10715 + }
10716 + } else {
10717 +@@ -4072,10 +4068,10 @@ static int hpsa_request_irq(struct ctlr_info *h,
10718 +
10719 + if (h->msix_vector || h->msi_vector)
10720 + rc = request_irq(h->intr[h->intr_mode], msixhandler,
10721 +- IRQF_DISABLED, h->devname, h);
10722 ++ 0, h->devname, h);
10723 + else
10724 + rc = request_irq(h->intr[h->intr_mode], intxhandler,
10725 +- IRQF_DISABLED, h->devname, h);
10726 ++ IRQF_SHARED, h->devname, h);
10727 + if (rc) {
10728 + dev_err(&h->pdev->dev, "unable to get irq %d for %s\n",
10729 + h->intr[h->intr_mode], h->devname);
10730 +diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
10731 +index a97edab..83d08b6 100644
10732 +--- a/drivers/scsi/isci/init.c
10733 ++++ b/drivers/scsi/isci/init.c
10734 +@@ -465,7 +465,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
10735 + if (!orom)
10736 + orom = isci_request_oprom(pdev);
10737 +
10738 +- for (i = 0; orom && i < ARRAY_SIZE(orom->ctrl); i++) {
10739 ++ for (i = 0; orom && i < num_controllers(pdev); i++) {
10740 + if (sci_oem_parameters_validate(&orom->ctrl[i])) {
10741 + dev_warn(&pdev->dev,
10742 + "[%d]: invalid oem parameters detected, falling back to firmware\n", i);
10743 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
10744 +index b1ddfef..ac336e1 100644
10745 +--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
10746 ++++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
10747 +@@ -3274,7 +3274,7 @@ _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
10748 + }
10749 +
10750 + pfacts = &ioc->pfacts[port];
10751 +- memset(pfacts, 0, sizeof(Mpi2PortFactsReply_t));
10752 ++ memset(pfacts, 0, sizeof(struct mpt2sas_port_facts));
10753 + pfacts->PortNumber = mpi_reply.PortNumber;
10754 + pfacts->VP_ID = mpi_reply.VP_ID;
10755 + pfacts->VF_ID = mpi_reply.VF_ID;
10756 +@@ -3316,7 +3316,7 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
10757 + }
10758 +
10759 + facts = &ioc->facts;
10760 +- memset(facts, 0, sizeof(Mpi2IOCFactsReply_t));
10761 ++ memset(facts, 0, sizeof(struct mpt2sas_facts));
10762 + facts->MsgVersion = le16_to_cpu(mpi_reply.MsgVersion);
10763 + facts->HeaderVersion = le16_to_cpu(mpi_reply.HeaderVersion);
10764 + facts->VP_ID = mpi_reply.VP_ID;
10765 +@@ -4193,7 +4193,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
10766 + goto out_free_resources;
10767 +
10768 + ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
10769 +- sizeof(Mpi2PortFactsReply_t), GFP_KERNEL);
10770 ++ sizeof(struct mpt2sas_port_facts), GFP_KERNEL);
10771 + if (!ioc->pfacts) {
10772 + r = -ENOMEM;
10773 + goto out_free_resources;
10774 +diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
10775 +index 5f748c0..6a62934 100644
10776 +--- a/drivers/spi/spi-fsl-spi.c
10777 ++++ b/drivers/spi/spi-fsl-spi.c
10778 +@@ -933,7 +933,7 @@ err:
10779 +
10780 + static void fsl_spi_cs_control(struct spi_device *spi, bool on)
10781 + {
10782 +- struct device *dev = spi->dev.parent;
10783 ++ struct device *dev = spi->dev.parent->parent;
10784 + struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
10785 + u16 cs = spi->chip_select;
10786 + int gpio = pinfo->gpios[cs];
10787 +diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
10788 +index 5e78c77..4ad2c0e 100644
10789 +--- a/drivers/staging/comedi/comedi_fops.c
10790 ++++ b/drivers/staging/comedi/comedi_fops.c
10791 +@@ -280,7 +280,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
10792 + if (ret == 0) {
10793 + if (!try_module_get(dev->driver->module)) {
10794 + comedi_device_detach(dev);
10795 +- return -ENOSYS;
10796 ++ ret = -ENOSYS;
10797 + }
10798 + }
10799 +
10800 +diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
10801 +index eeadf1b..70585b6 100644
10802 +--- a/drivers/tty/serial/8250.c
10803 ++++ b/drivers/tty/serial/8250.c
10804 +@@ -2327,10 +2327,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
10805 + quot++;
10806 +
10807 + if (up->capabilities & UART_CAP_FIFO && up->port.fifosize > 1) {
10808 +- if (baud < 2400)
10809 +- fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
10810 +- else
10811 +- fcr = uart_config[up->port.type].fcr;
10812 ++ fcr = uart_config[up->port.type].fcr;
10813 ++ if (baud < 2400) {
10814 ++ fcr &= ~UART_FCR_TRIGGER_MASK;
10815 ++ fcr |= UART_FCR_TRIGGER_1;
10816 ++ }
10817 + }
10818 +
10819 + /*
10820 +diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
10821 +index 825937a..482d51e 100644
10822 +--- a/drivers/tty/serial/8250_pci.c
10823 ++++ b/drivers/tty/serial/8250_pci.c
10824 +@@ -1590,54 +1590,72 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
10825 + {
10826 + .vendor = PCI_VENDOR_ID_INTEL,
10827 + .device = 0x8811,
10828 ++ .subvendor = PCI_ANY_ID,
10829 ++ .subdevice = PCI_ANY_ID,
10830 + .init = pci_eg20t_init,
10831 + .setup = pci_default_setup,
10832 + },
10833 + {
10834 + .vendor = PCI_VENDOR_ID_INTEL,
10835 + .device = 0x8812,
10836 ++ .subvendor = PCI_ANY_ID,
10837 ++ .subdevice = PCI_ANY_ID,
10838 + .init = pci_eg20t_init,
10839 + .setup = pci_default_setup,
10840 + },
10841 + {
10842 + .vendor = PCI_VENDOR_ID_INTEL,
10843 + .device = 0x8813,
10844 ++ .subvendor = PCI_ANY_ID,
10845 ++ .subdevice = PCI_ANY_ID,
10846 + .init = pci_eg20t_init,
10847 + .setup = pci_default_setup,
10848 + },
10849 + {
10850 + .vendor = PCI_VENDOR_ID_INTEL,
10851 + .device = 0x8814,
10852 ++ .subvendor = PCI_ANY_ID,
10853 ++ .subdevice = PCI_ANY_ID,
10854 + .init = pci_eg20t_init,
10855 + .setup = pci_default_setup,
10856 + },
10857 + {
10858 + .vendor = 0x10DB,
10859 + .device = 0x8027,
10860 ++ .subvendor = PCI_ANY_ID,
10861 ++ .subdevice = PCI_ANY_ID,
10862 + .init = pci_eg20t_init,
10863 + .setup = pci_default_setup,
10864 + },
10865 + {
10866 + .vendor = 0x10DB,
10867 + .device = 0x8028,
10868 ++ .subvendor = PCI_ANY_ID,
10869 ++ .subdevice = PCI_ANY_ID,
10870 + .init = pci_eg20t_init,
10871 + .setup = pci_default_setup,
10872 + },
10873 + {
10874 + .vendor = 0x10DB,
10875 + .device = 0x8029,
10876 ++ .subvendor = PCI_ANY_ID,
10877 ++ .subdevice = PCI_ANY_ID,
10878 + .init = pci_eg20t_init,
10879 + .setup = pci_default_setup,
10880 + },
10881 + {
10882 + .vendor = 0x10DB,
10883 + .device = 0x800C,
10884 ++ .subvendor = PCI_ANY_ID,
10885 ++ .subdevice = PCI_ANY_ID,
10886 + .init = pci_eg20t_init,
10887 + .setup = pci_default_setup,
10888 + },
10889 + {
10890 + .vendor = 0x10DB,
10891 + .device = 0x800D,
10892 ++ .subvendor = PCI_ANY_ID,
10893 ++ .subdevice = PCI_ANY_ID,
10894 + .init = pci_eg20t_init,
10895 + .setup = pci_default_setup,
10896 + },
10897 +diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
10898 +index 7e02c9c..5b3d063 100644
10899 +--- a/drivers/tty/serial/mxs-auart.c
10900 ++++ b/drivers/tty/serial/mxs-auart.c
10901 +@@ -368,6 +368,8 @@ static void mxs_auart_settermios(struct uart_port *u,
10902 +
10903 + writel(ctrl, u->membase + AUART_LINECTRL);
10904 + writel(ctrl2, u->membase + AUART_CTRL2);
10905 ++
10906 ++ uart_update_timeout(u, termios->c_cflag, baud);
10907 + }
10908 +
10909 + static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
10910 +diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
10911 +index 0406d7f..af5ffb9 100644
10912 +--- a/drivers/tty/serial/serial_core.c
10913 ++++ b/drivers/tty/serial/serial_core.c
10914 +@@ -2305,6 +2305,7 @@ void uart_unregister_driver(struct uart_driver *drv)
10915 + tty_unregister_driver(p);
10916 + put_tty_driver(p);
10917 + kfree(drv->state);
10918 ++ drv->state = NULL;
10919 + drv->tty_driver = NULL;
10920 + }
10921 +
10922 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
10923 +index 2db0327..554ac90 100644
10924 +--- a/drivers/usb/class/cdc-wdm.c
10925 ++++ b/drivers/usb/class/cdc-wdm.c
10926 +@@ -496,11 +496,13 @@ static int wdm_flush(struct file *file, fl_owner_t id)
10927 + struct wdm_device *desc = file->private_data;
10928 +
10929 + wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
10930 +- if (desc->werr < 0)
10931 ++
10932 ++ /* cannot dereference desc->intf if WDM_DISCONNECTING */
10933 ++ if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
10934 + dev_err(&desc->intf->dev, "Error in flush path: %d\n",
10935 + desc->werr);
10936 +
10937 +- return desc->werr;
10938 ++ return usb_translate_errors(desc->werr);
10939 + }
10940 +
10941 + static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
10942 +@@ -511,7 +513,7 @@ static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
10943 +
10944 + spin_lock_irqsave(&desc->iuspin, flags);
10945 + if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
10946 +- mask = POLLERR;
10947 ++ mask = POLLHUP | POLLERR;
10948 + spin_unlock_irqrestore(&desc->iuspin, flags);
10949 + goto desc_out;
10950 + }
10951 +@@ -586,10 +588,15 @@ static int wdm_release(struct inode *inode, struct file *file)
10952 + mutex_unlock(&desc->wlock);
10953 +
10954 + if (!desc->count) {
10955 +- dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
10956 +- kill_urbs(desc);
10957 +- if (!test_bit(WDM_DISCONNECTING, &desc->flags))
10958 ++ if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
10959 ++ dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
10960 ++ kill_urbs(desc);
10961 + desc->intf->needs_remote_wakeup = 0;
10962 ++ } else {
10963 ++ /* must avoid dev_printk here as desc->intf is invalid */
10964 ++ pr_debug(KBUILD_MODNAME " %s: device gone - cleaning up\n", __func__);
10965 ++ cleanup(desc);
10966 ++ }
10967 + }
10968 + mutex_unlock(&wdm_mutex);
10969 + return 0;
10970 +@@ -805,6 +812,8 @@ static void wdm_disconnect(struct usb_interface *intf)
10971 + mutex_unlock(&desc->rlock);
10972 + if (!desc->count)
10973 + cleanup(desc);
10974 ++ else
10975 ++ dev_dbg(&intf->dev, "%s: %d open files - postponing cleanup\n", __func__, desc->count);
10976 + mutex_unlock(&wdm_mutex);
10977 + }
10978 +
10979 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
10980 +index 7abf060..f6ff837 100644
10981 +--- a/drivers/usb/core/devio.c
10982 ++++ b/drivers/usb/core/devio.c
10983 +@@ -295,17 +295,14 @@ static struct async *async_getcompleted(struct dev_state *ps)
10984 + static struct async *async_getpending(struct dev_state *ps,
10985 + void __user *userurb)
10986 + {
10987 +- unsigned long flags;
10988 + struct async *as;
10989 +
10990 +- spin_lock_irqsave(&ps->lock, flags);
10991 + list_for_each_entry(as, &ps->async_pending, asynclist)
10992 + if (as->userurb == userurb) {
10993 + list_del_init(&as->asynclist);
10994 +- spin_unlock_irqrestore(&ps->lock, flags);
10995 + return as;
10996 + }
10997 +- spin_unlock_irqrestore(&ps->lock, flags);
10998 ++
10999 + return NULL;
11000 + }
11001 +
11002 +@@ -360,6 +357,7 @@ static void cancel_bulk_urbs(struct dev_state *ps, unsigned bulk_addr)
11003 + __releases(ps->lock)
11004 + __acquires(ps->lock)
11005 + {
11006 ++ struct urb *urb;
11007 + struct async *as;
11008 +
11009 + /* Mark all the pending URBs that match bulk_addr, up to but not
11010 +@@ -382,8 +380,11 @@ __acquires(ps->lock)
11011 + list_for_each_entry(as, &ps->async_pending, asynclist) {
11012 + if (as->bulk_status == AS_UNLINK) {
11013 + as->bulk_status = 0; /* Only once */
11014 ++ urb = as->urb;
11015 ++ usb_get_urb(urb);
11016 + spin_unlock(&ps->lock); /* Allow completions */
11017 +- usb_unlink_urb(as->urb);
11018 ++ usb_unlink_urb(urb);
11019 ++ usb_put_urb(urb);
11020 + spin_lock(&ps->lock);
11021 + goto rescan;
11022 + }
11023 +@@ -434,6 +435,7 @@ static void async_completed(struct urb *urb)
11024 +
11025 + static void destroy_async(struct dev_state *ps, struct list_head *list)
11026 + {
11027 ++ struct urb *urb;
11028 + struct async *as;
11029 + unsigned long flags;
11030 +
11031 +@@ -441,10 +443,13 @@ static void destroy_async(struct dev_state *ps, struct list_head *list)
11032 + while (!list_empty(list)) {
11033 + as = list_entry(list->next, struct async, asynclist);
11034 + list_del_init(&as->asynclist);
11035 ++ urb = as->urb;
11036 ++ usb_get_urb(urb);
11037 +
11038 + /* drop the spinlock so the completion handler can run */
11039 + spin_unlock_irqrestore(&ps->lock, flags);
11040 +- usb_kill_urb(as->urb);
11041 ++ usb_kill_urb(urb);
11042 ++ usb_put_urb(urb);
11043 + spin_lock_irqsave(&ps->lock, flags);
11044 + }
11045 + spin_unlock_irqrestore(&ps->lock, flags);
11046 +@@ -1350,12 +1355,24 @@ static int proc_submiturb(struct dev_state *ps, void __user *arg)
11047 +
11048 + static int proc_unlinkurb(struct dev_state *ps, void __user *arg)
11049 + {
11050 ++ struct urb *urb;
11051 + struct async *as;
11052 ++ unsigned long flags;
11053 +
11054 ++ spin_lock_irqsave(&ps->lock, flags);
11055 + as = async_getpending(ps, arg);
11056 +- if (!as)
11057 ++ if (!as) {
11058 ++ spin_unlock_irqrestore(&ps->lock, flags);
11059 + return -EINVAL;
11060 +- usb_kill_urb(as->urb);
11061 ++ }
11062 ++
11063 ++ urb = as->urb;
11064 ++ usb_get_urb(urb);
11065 ++ spin_unlock_irqrestore(&ps->lock, flags);
11066 ++
11067 ++ usb_kill_urb(urb);
11068 ++ usb_put_urb(urb);
11069 ++
11070 + return 0;
11071 + }
11072 +
11073 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
11074 +index 2b0a341..52d27ed 100644
11075 +--- a/drivers/usb/core/hub.c
11076 ++++ b/drivers/usb/core/hub.c
11077 +@@ -2420,6 +2420,10 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
11078 + NULL, 0,
11079 + USB_CTRL_SET_TIMEOUT);
11080 +
11081 ++ /* Try to enable USB2 hardware LPM again */
11082 ++ if (udev->usb2_hw_lpm_capable == 1)
11083 ++ usb_set_usb2_hardware_lpm(udev, 1);
11084 ++
11085 + /* System sleep transitions should never fail */
11086 + if (!PMSG_IS_AUTO(msg))
11087 + status = 0;
11088 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
11089 +index 4c65eb6..32d3adc 100644
11090 +--- a/drivers/usb/core/quirks.c
11091 ++++ b/drivers/usb/core/quirks.c
11092 +@@ -123,6 +123,9 @@ static const struct usb_device_id usb_quirk_list[] = {
11093 + /* Guillemot Webcam Hercules Dualpix Exchange*/
11094 + { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
11095 +
11096 ++ /* Midiman M-Audio Keystation 88es */
11097 ++ { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
11098 ++
11099 + /* M-Systems Flash Disk Pioneers */
11100 + { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
11101 +
11102 +diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
11103 +index 3888778..45e8479 100644
11104 +--- a/drivers/usb/core/usb.h
11105 ++++ b/drivers/usb/core/usb.h
11106 +@@ -132,20 +132,6 @@ static inline int is_usb_device_driver(struct device_driver *drv)
11107 + for_devices;
11108 + }
11109 +
11110 +-/* translate USB error codes to codes user space understands */
11111 +-static inline int usb_translate_errors(int error_code)
11112 +-{
11113 +- switch (error_code) {
11114 +- case 0:
11115 +- case -ENOMEM:
11116 +- case -ENODEV:
11117 +- return error_code;
11118 +- default:
11119 +- return -EIO;
11120 +- }
11121 +-}
11122 +-
11123 +-
11124 + /* for labeling diagnostics */
11125 + extern const char *usbcore_name;
11126 +
11127 +diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
11128 +index 8e3e509..01de16e 100644
11129 +--- a/drivers/usb/gadget/fsl_udc_core.c
11130 ++++ b/drivers/usb/gadget/fsl_udc_core.c
11131 +@@ -736,6 +736,8 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req)
11132 + lastreq = list_entry(ep->queue.prev, struct fsl_req, queue);
11133 + lastreq->tail->next_td_ptr =
11134 + cpu_to_hc32(req->head->td_dma & DTD_ADDR_MASK);
11135 ++ /* Ensure dTD's next dtd pointer to be updated */
11136 ++ wmb();
11137 + /* Read prime bit, if 1 goto done */
11138 + if (fsl_readl(&dr_regs->endpointprime) & bitmask)
11139 + return;
11140 +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
11141 +index 971d312..ee85e81 100644
11142 +--- a/drivers/usb/host/ehci-pci.c
11143 ++++ b/drivers/usb/host/ehci-pci.c
11144 +@@ -365,7 +365,9 @@ static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
11145 + {
11146 + return pdev->class == PCI_CLASS_SERIAL_USB_EHCI &&
11147 + pdev->vendor == PCI_VENDOR_ID_INTEL &&
11148 +- pdev->device == 0x1E26;
11149 ++ (pdev->device == 0x1E26 ||
11150 ++ pdev->device == 0x8C2D ||
11151 ++ pdev->device == 0x8C26);
11152 + }
11153 +
11154 + static void ehci_enable_xhci_companion(void)
11155 +diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
11156 +index 95a9fec..a60c7aa 100644
11157 +--- a/drivers/usb/host/ohci-at91.c
11158 ++++ b/drivers/usb/host/ohci-at91.c
11159 +@@ -199,7 +199,7 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
11160 + /*-------------------------------------------------------------------------*/
11161 +
11162 + static int __devinit
11163 +-ohci_at91_start (struct usb_hcd *hcd)
11164 ++ohci_at91_reset (struct usb_hcd *hcd)
11165 + {
11166 + struct at91_usbh_data *board = hcd->self.controller->platform_data;
11167 + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
11168 +@@ -209,6 +209,14 @@ ohci_at91_start (struct usb_hcd *hcd)
11169 + return ret;
11170 +
11171 + ohci->num_ports = board->ports;
11172 ++ return 0;
11173 ++}
11174 ++
11175 ++static int __devinit
11176 ++ohci_at91_start (struct usb_hcd *hcd)
11177 ++{
11178 ++ struct ohci_hcd *ohci = hcd_to_ohci (hcd);
11179 ++ int ret;
11180 +
11181 + if ((ret = ohci_run(ohci)) < 0) {
11182 + err("can't start %s", hcd->self.bus_name);
11183 +@@ -390,6 +398,7 @@ static const struct hc_driver ohci_at91_hc_driver = {
11184 + /*
11185 + * basic lifecycle operations
11186 + */
11187 ++ .reset = ohci_at91_reset,
11188 + .start = ohci_at91_start,
11189 + .stop = ohci_stop,
11190 + .shutdown = ohci_shutdown,
11191 +diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
11192 +index 2afff88..833b3c6 100644
11193 +--- a/drivers/usb/host/pci-quirks.c
11194 ++++ b/drivers/usb/host/pci-quirks.c
11195 +@@ -9,6 +9,7 @@
11196 + */
11197 +
11198 + #include <linux/types.h>
11199 ++#include <linux/kconfig.h>
11200 + #include <linux/kernel.h>
11201 + #include <linux/pci.h>
11202 + #include <linux/init.h>
11203 +@@ -712,12 +713,28 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done,
11204 + return -ETIMEDOUT;
11205 + }
11206 +
11207 +-bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
11208 ++#define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
11209 ++
11210 ++bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev)
11211 + {
11212 + return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
11213 + pdev->vendor == PCI_VENDOR_ID_INTEL &&
11214 + pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI;
11215 + }
11216 ++
11217 ++/* The Intel Lynx Point chipset also has switchable ports. */
11218 ++bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev)
11219 ++{
11220 ++ return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
11221 ++ pdev->vendor == PCI_VENDOR_ID_INTEL &&
11222 ++ pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI;
11223 ++}
11224 ++
11225 ++bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
11226 ++{
11227 ++ return usb_is_intel_ppt_switchable_xhci(pdev) ||
11228 ++ usb_is_intel_lpt_switchable_xhci(pdev);
11229 ++}
11230 + EXPORT_SYMBOL_GPL(usb_is_intel_switchable_xhci);
11231 +
11232 + /*
11233 +@@ -742,6 +759,19 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
11234 + {
11235 + u32 ports_available;
11236 +
11237 ++ /* Don't switchover the ports if the user hasn't compiled the xHCI
11238 ++ * driver. Otherwise they will see "dead" USB ports that don't power
11239 ++ * the devices.
11240 ++ */
11241 ++ if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
11242 ++ dev_warn(&xhci_pdev->dev,
11243 ++ "CONFIG_USB_XHCI_HCD is turned off, "
11244 ++ "defaulting to EHCI.\n");
11245 ++ dev_warn(&xhci_pdev->dev,
11246 ++ "USB 3.0 devices will work at USB 2.0 speeds.\n");
11247 ++ return;
11248 ++ }
11249 ++
11250 + ports_available = 0xffffffff;
11251 + /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable
11252 + * Register, to turn on SuperSpeed terminations for all
11253 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
11254 +index 01c3800..4232e868 100644
11255 +--- a/drivers/usb/host/xhci-mem.c
11256 ++++ b/drivers/usb/host/xhci-mem.c
11257 +@@ -1699,6 +1699,14 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
11258 + {
11259 + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
11260 + struct dev_info *dev_info, *next;
11261 ++ struct list_head *tt_list_head;
11262 ++ struct list_head *tt;
11263 ++ struct list_head *endpoints;
11264 ++ struct list_head *ep, *q;
11265 ++ struct xhci_tt_bw_info *tt_info;
11266 ++ struct xhci_interval_bw_table *bwt;
11267 ++ struct xhci_virt_ep *virt_ep;
11268 ++
11269 + unsigned long flags;
11270 + int size;
11271 + int i;
11272 +@@ -1715,6 +1723,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
11273 + xhci->event_ring = NULL;
11274 + xhci_dbg(xhci, "Freed event ring\n");
11275 +
11276 ++ xhci->cmd_ring_reserved_trbs = 0;
11277 + if (xhci->cmd_ring)
11278 + xhci_ring_free(xhci, xhci->cmd_ring);
11279 + xhci->cmd_ring = NULL;
11280 +@@ -1757,8 +1766,26 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
11281 + }
11282 + spin_unlock_irqrestore(&xhci->lock, flags);
11283 +
11284 ++ bwt = &xhci->rh_bw->bw_table;
11285 ++ for (i = 0; i < XHCI_MAX_INTERVAL; i++) {
11286 ++ endpoints = &bwt->interval_bw[i].endpoints;
11287 ++ list_for_each_safe(ep, q, endpoints) {
11288 ++ virt_ep = list_entry(ep, struct xhci_virt_ep, bw_endpoint_list);
11289 ++ list_del(&virt_ep->bw_endpoint_list);
11290 ++ kfree(virt_ep);
11291 ++ }
11292 ++ }
11293 ++
11294 ++ tt_list_head = &xhci->rh_bw->tts;
11295 ++ list_for_each_safe(tt, q, tt_list_head) {
11296 ++ tt_info = list_entry(tt, struct xhci_tt_bw_info, tt_list);
11297 ++ list_del(tt);
11298 ++ kfree(tt_info);
11299 ++ }
11300 ++
11301 + xhci->num_usb2_ports = 0;
11302 + xhci->num_usb3_ports = 0;
11303 ++ xhci->num_active_eps = 0;
11304 + kfree(xhci->usb2_ports);
11305 + kfree(xhci->usb3_ports);
11306 + kfree(xhci->port_array);
11307 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
11308 +index 211296a..daf5754 100644
11309 +--- a/drivers/usb/host/xhci-pci.c
11310 ++++ b/drivers/usb/host/xhci-pci.c
11311 +@@ -72,6 +72,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
11312 + xhci_dbg(xhci, "QUIRK: Fresco Logic revision %u "
11313 + "has broken MSI implementation\n",
11314 + pdev->revision);
11315 ++ xhci->quirks |= XHCI_TRUST_TX_LENGTH;
11316 + }
11317 +
11318 + if (pdev->vendor == PCI_VENDOR_ID_NEC)
11319 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
11320 +index 43b3447..fb0981e 100644
11321 +--- a/drivers/usb/host/xhci-ring.c
11322 ++++ b/drivers/usb/host/xhci-ring.c
11323 +@@ -1735,8 +1735,12 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
11324 + /* handle completion code */
11325 + switch (trb_comp_code) {
11326 + case COMP_SUCCESS:
11327 +- frame->status = 0;
11328 +- break;
11329 ++ if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) {
11330 ++ frame->status = 0;
11331 ++ break;
11332 ++ }
11333 ++ if ((xhci->quirks & XHCI_TRUST_TX_LENGTH))
11334 ++ trb_comp_code = COMP_SHORT_TX;
11335 + case COMP_SHORT_TX:
11336 + frame->status = td->urb->transfer_flags & URB_SHORT_NOT_OK ?
11337 + -EREMOTEIO : 0;
11338 +@@ -1752,6 +1756,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
11339 + break;
11340 + case COMP_DEV_ERR:
11341 + case COMP_STALL:
11342 ++ case COMP_TX_ERR:
11343 + frame->status = -EPROTO;
11344 + skip_td = true;
11345 + break;
11346 +@@ -1832,13 +1837,16 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
11347 + switch (trb_comp_code) {
11348 + case COMP_SUCCESS:
11349 + /* Double check that the HW transferred everything. */
11350 +- if (event_trb != td->last_trb) {
11351 ++ if (event_trb != td->last_trb ||
11352 ++ TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) {
11353 + xhci_warn(xhci, "WARN Successful completion "
11354 + "on short TX\n");
11355 + if (td->urb->transfer_flags & URB_SHORT_NOT_OK)
11356 + *status = -EREMOTEIO;
11357 + else
11358 + *status = 0;
11359 ++ if ((xhci->quirks & XHCI_TRUST_TX_LENGTH))
11360 ++ trb_comp_code = COMP_SHORT_TX;
11361 + } else {
11362 + *status = 0;
11363 + }
11364 +@@ -1977,6 +1985,13 @@ static int handle_tx_event(struct xhci_hcd *xhci,
11365 + * transfer type
11366 + */
11367 + case COMP_SUCCESS:
11368 ++ if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0)
11369 ++ break;
11370 ++ if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
11371 ++ trb_comp_code = COMP_SHORT_TX;
11372 ++ else
11373 ++ xhci_warn(xhci, "WARN Successful completion on short TX: "
11374 ++ "needs XHCI_TRUST_TX_LENGTH quirk?\n");
11375 + case COMP_SHORT_TX:
11376 + break;
11377 + case COMP_STOP:
11378 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
11379 +index 4850c4d..363b141 100644
11380 +--- a/drivers/usb/host/xhci.h
11381 ++++ b/drivers/usb/host/xhci.h
11382 +@@ -1466,6 +1466,7 @@ struct xhci_hcd {
11383 + #define XHCI_RESET_ON_RESUME (1 << 7)
11384 + #define XHCI_SW_BW_CHECKING (1 << 8)
11385 + #define XHCI_AMD_0x96_HOST (1 << 9)
11386 ++#define XHCI_TRUST_TX_LENGTH (1 << 10)
11387 + unsigned int num_active_eps;
11388 + unsigned int limit_active_eps;
11389 + /* There are two roothubs to keep track of bus suspend info for */
11390 +diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
11391 +index bd6d008..b9ac9a3 100644
11392 +--- a/drivers/usb/misc/usbtest.c
11393 ++++ b/drivers/usb/misc/usbtest.c
11394 +@@ -1025,7 +1025,10 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
11395 + case 13: /* short read, resembling case 10 */
11396 + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
11397 + /* last data packet "should" be DATA1, not DATA0 */
11398 +- len = 1024 - udev->descriptor.bMaxPacketSize0;
11399 ++ if (udev->speed == USB_SPEED_SUPER)
11400 ++ len = 1024 - 512;
11401 ++ else
11402 ++ len = 1024 - udev->descriptor.bMaxPacketSize0;
11403 + expected = -EREMOTEIO;
11404 + break;
11405 + case 14: /* short read; try to fill the last packet */
11406 +@@ -1384,11 +1387,15 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
11407 +
11408 + static int halt_simple(struct usbtest_dev *dev)
11409 + {
11410 +- int ep;
11411 +- int retval = 0;
11412 +- struct urb *urb;
11413 ++ int ep;
11414 ++ int retval = 0;
11415 ++ struct urb *urb;
11416 ++ struct usb_device *udev = testdev_to_usbdev(dev);
11417 +
11418 +- urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512);
11419 ++ if (udev->speed == USB_SPEED_SUPER)
11420 ++ urb = simple_alloc_urb(udev, 0, 1024);
11421 ++ else
11422 ++ urb = simple_alloc_urb(udev, 0, 512);
11423 + if (urb == NULL)
11424 + return -ENOMEM;
11425 +
11426 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
11427 +index c4cf3f3..450bdfe 100644
11428 +--- a/drivers/usb/serial/ftdi_sio.c
11429 ++++ b/drivers/usb/serial/ftdi_sio.c
11430 +@@ -809,6 +809,7 @@ static struct usb_device_id id_table_combined [] = {
11431 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
11432 + { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
11433 + { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
11434 ++ { USB_DEVICE(PI_VID, PI_E861_PID) },
11435 + { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
11436 + { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
11437 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
11438 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
11439 +index c6dd18e..219b199 100644
11440 +--- a/drivers/usb/serial/ftdi_sio_ids.h
11441 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
11442 +@@ -785,6 +785,14 @@
11443 + #define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */
11444 + #define RTSYSTEMS_CT29B_PID 0x9e54 /* CT29B Radio Cable */
11445 +
11446 ++
11447 ++/*
11448 ++ * Physik Instrumente
11449 ++ * http://www.physikinstrumente.com/en/products/
11450 ++ */
11451 ++#define PI_VID 0x1a72 /* Vendor ID */
11452 ++#define PI_E861_PID 0x1008 /* E-861 piezo controller USB connection */
11453 ++
11454 + /*
11455 + * Bayer Ascensia Contour blood glucose meter USB-converter cable.
11456 + * http://winglucofacts.com/cables/
11457 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
11458 +index 21c82b0..2856474 100644
11459 +--- a/drivers/usb/serial/ti_usb_3410_5052.c
11460 ++++ b/drivers/usb/serial/ti_usb_3410_5052.c
11461 +@@ -165,7 +165,7 @@ static unsigned int product_5052_count;
11462 + /* the array dimension is the number of default entries plus */
11463 + /* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
11464 + /* null entry */
11465 +-static struct usb_device_id ti_id_table_3410[14+TI_EXTRA_VID_PID_COUNT+1] = {
11466 ++static struct usb_device_id ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
11467 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
11468 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
11469 + { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
11470 +@@ -180,6 +180,7 @@ static struct usb_device_id ti_id_table_3410[14+TI_EXTRA_VID_PID_COUNT+1] = {
11471 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
11472 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
11473 + { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
11474 ++ { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
11475 + };
11476 +
11477 + static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
11478 +@@ -189,7 +190,7 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
11479 + { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
11480 + };
11481 +
11482 +-static struct usb_device_id ti_id_table_combined[18+2*TI_EXTRA_VID_PID_COUNT+1] = {
11483 ++static struct usb_device_id ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1] = {
11484 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
11485 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
11486 + { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
11487 +@@ -208,6 +209,7 @@ static struct usb_device_id ti_id_table_combined[18+2*TI_EXTRA_VID_PID_COUNT+1]
11488 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
11489 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
11490 + { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
11491 ++ { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
11492 + { }
11493 + };
11494 +
11495 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
11496 +index f140f1b..b353e7e 100644
11497 +--- a/drivers/usb/serial/ti_usb_3410_5052.h
11498 ++++ b/drivers/usb/serial/ti_usb_3410_5052.h
11499 +@@ -37,6 +37,7 @@
11500 + #define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
11501 + #define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
11502 + #define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */
11503 ++#define FRI2_PRODUCT_ID 0x5053 /* Fish River Island II */
11504 +
11505 + /* Multi-Tech vendor and product ids */
11506 + #define MTS_VENDOR_ID 0x06E0
11507 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
11508 +index 24caba7..591f57f 100644
11509 +--- a/drivers/usb/storage/unusual_devs.h
11510 ++++ b/drivers/usb/storage/unusual_devs.h
11511 +@@ -1885,6 +1885,13 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
11512 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
11513 + US_FL_IGNORE_RESIDUE ),
11514 +
11515 ++/* Reported by Jesse Feddema <jdfeddema@×××××.com> */
11516 ++UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000,
11517 ++ "Yarvik",
11518 ++ "PMP400",
11519 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
11520 ++ US_FL_BULK_IGNORE_TAG | US_FL_MAX_SECTORS_64 ),
11521 ++
11522 + /* Reported by Hans de Goede <hdegoede@××××××.com>
11523 + * These Appotech controllers are found in Picture Frames, they provide a
11524 + * (buggy) emulation of a cdrom drive which contains the windows software
11525 +diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
11526 +index 7533458..7152b53 100644
11527 +--- a/drivers/video/omap2/dss/venc.c
11528 ++++ b/drivers/video/omap2/dss/venc.c
11529 +@@ -679,6 +679,11 @@ void venc_dump_regs(struct seq_file *s)
11530 + {
11531 + #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
11532 +
11533 ++ if (cpu_is_omap44xx()) {
11534 ++ seq_printf(s, "VENC currently disabled on OMAP44xx\n");
11535 ++ return;
11536 ++ }
11537 ++
11538 + if (venc_runtime_get())
11539 + return;
11540 +
11541 +diff --git a/drivers/xen/events.c b/drivers/xen/events.c
11542 +index 6e075cd..fec1204 100644
11543 +--- a/drivers/xen/events.c
11544 ++++ b/drivers/xen/events.c
11545 +@@ -600,7 +600,7 @@ static void disable_pirq(struct irq_data *data)
11546 + disable_dynirq(data);
11547 + }
11548 +
11549 +-static int find_irq_by_gsi(unsigned gsi)
11550 ++int xen_irq_from_gsi(unsigned gsi)
11551 + {
11552 + struct irq_info *info;
11553 +
11554 +@@ -614,6 +614,7 @@ static int find_irq_by_gsi(unsigned gsi)
11555 +
11556 + return -1;
11557 + }
11558 ++EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
11559 +
11560 + /*
11561 + * Do not make any assumptions regarding the relationship between the
11562 +@@ -633,7 +634,7 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi,
11563 +
11564 + mutex_lock(&irq_mapping_update_lock);
11565 +
11566 +- irq = find_irq_by_gsi(gsi);
11567 ++ irq = xen_irq_from_gsi(gsi);
11568 + if (irq != -1) {
11569 + printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n",
11570 + irq, gsi);
11571 +diff --git a/fs/aio.c b/fs/aio.c
11572 +index b9d64d8..3b65ee7 100644
11573 +--- a/fs/aio.c
11574 ++++ b/fs/aio.c
11575 +@@ -1477,6 +1477,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
11576 + if (ret < 0)
11577 + goto out;
11578 +
11579 ++ ret = rw_verify_area(type, kiocb->ki_filp, &kiocb->ki_pos, ret);
11580 ++ if (ret < 0)
11581 ++ goto out;
11582 ++
11583 + kiocb->ki_nr_segs = kiocb->ki_nbytes;
11584 + kiocb->ki_cur_seg = 0;
11585 + /* ki_nbytes/left now reflect bytes instead of segs */
11586 +@@ -1488,11 +1492,17 @@ out:
11587 + return ret;
11588 + }
11589 +
11590 +-static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
11591 ++static ssize_t aio_setup_single_vector(int type, struct file * file, struct kiocb *kiocb)
11592 + {
11593 ++ int bytes;
11594 ++
11595 ++ bytes = rw_verify_area(type, file, &kiocb->ki_pos, kiocb->ki_left);
11596 ++ if (bytes < 0)
11597 ++ return bytes;
11598 ++
11599 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
11600 + kiocb->ki_iovec->iov_base = kiocb->ki_buf;
11601 +- kiocb->ki_iovec->iov_len = kiocb->ki_left;
11602 ++ kiocb->ki_iovec->iov_len = bytes;
11603 + kiocb->ki_nr_segs = 1;
11604 + kiocb->ki_cur_seg = 0;
11605 + return 0;
11606 +@@ -1517,10 +1527,7 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
11607 + if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,
11608 + kiocb->ki_left)))
11609 + break;
11610 +- ret = security_file_permission(file, MAY_READ);
11611 +- if (unlikely(ret))
11612 +- break;
11613 +- ret = aio_setup_single_vector(kiocb);
11614 ++ ret = aio_setup_single_vector(READ, file, kiocb);
11615 + if (ret)
11616 + break;
11617 + ret = -EINVAL;
11618 +@@ -1535,10 +1542,7 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
11619 + if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,
11620 + kiocb->ki_left)))
11621 + break;
11622 +- ret = security_file_permission(file, MAY_WRITE);
11623 +- if (unlikely(ret))
11624 +- break;
11625 +- ret = aio_setup_single_vector(kiocb);
11626 ++ ret = aio_setup_single_vector(WRITE, file, kiocb);
11627 + if (ret)
11628 + break;
11629 + ret = -EINVAL;
11630 +@@ -1549,9 +1553,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
11631 + ret = -EBADF;
11632 + if (unlikely(!(file->f_mode & FMODE_READ)))
11633 + break;
11634 +- ret = security_file_permission(file, MAY_READ);
11635 +- if (unlikely(ret))
11636 +- break;
11637 + ret = aio_setup_vectored_rw(READ, kiocb, compat);
11638 + if (ret)
11639 + break;
11640 +@@ -1563,9 +1564,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
11641 + ret = -EBADF;
11642 + if (unlikely(!(file->f_mode & FMODE_WRITE)))
11643 + break;
11644 +- ret = security_file_permission(file, MAY_WRITE);
11645 +- if (unlikely(ret))
11646 +- break;
11647 + ret = aio_setup_vectored_rw(WRITE, kiocb, compat);
11648 + if (ret)
11649 + break;
11650 +diff --git a/fs/bio.c b/fs/bio.c
11651 +index b1fe82c..4fc4dbb 100644
11652 +--- a/fs/bio.c
11653 ++++ b/fs/bio.c
11654 +@@ -507,11 +507,12 @@ int bio_get_nr_vecs(struct block_device *bdev)
11655 + struct request_queue *q = bdev_get_queue(bdev);
11656 + int nr_pages;
11657 +
11658 +- nr_pages = ((queue_max_sectors(q) << 9) + PAGE_SIZE - 1) >> PAGE_SHIFT;
11659 +- if (nr_pages > queue_max_segments(q))
11660 +- nr_pages = queue_max_segments(q);
11661 ++ nr_pages = min_t(unsigned,
11662 ++ queue_max_segments(q),
11663 ++ queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1);
11664 ++
11665 ++ return min_t(unsigned, nr_pages, BIO_MAX_PAGES);
11666 +
11667 +- return nr_pages;
11668 + }
11669 + EXPORT_SYMBOL(bio_get_nr_vecs);
11670 +
11671 +diff --git a/fs/block_dev.c b/fs/block_dev.c
11672 +index abe9b48..9b98987 100644
11673 +--- a/fs/block_dev.c
11674 ++++ b/fs/block_dev.c
11675 +@@ -68,7 +68,7 @@ static void bdev_inode_switch_bdi(struct inode *inode,
11676 + spin_unlock(&dst->wb.list_lock);
11677 + }
11678 +
11679 +-static sector_t max_block(struct block_device *bdev)
11680 ++sector_t blkdev_max_block(struct block_device *bdev)
11681 + {
11682 + sector_t retval = ~((sector_t)0);
11683 + loff_t sz = i_size_read(bdev->bd_inode);
11684 +@@ -139,7 +139,7 @@ static int
11685 + blkdev_get_block(struct inode *inode, sector_t iblock,
11686 + struct buffer_head *bh, int create)
11687 + {
11688 +- if (iblock >= max_block(I_BDEV(inode))) {
11689 ++ if (iblock >= blkdev_max_block(I_BDEV(inode))) {
11690 + if (create)
11691 + return -EIO;
11692 +
11693 +@@ -161,7 +161,7 @@ static int
11694 + blkdev_get_blocks(struct inode *inode, sector_t iblock,
11695 + struct buffer_head *bh, int create)
11696 + {
11697 +- sector_t end_block = max_block(I_BDEV(inode));
11698 ++ sector_t end_block = blkdev_max_block(I_BDEV(inode));
11699 + unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
11700 +
11701 + if ((iblock + max_blocks) > end_block) {
11702 +diff --git a/fs/buffer.c b/fs/buffer.c
11703 +index 19d8eb7..c807931 100644
11704 +--- a/fs/buffer.c
11705 ++++ b/fs/buffer.c
11706 +@@ -971,6 +971,7 @@ init_page_buffers(struct page *page, struct block_device *bdev,
11707 + struct buffer_head *head = page_buffers(page);
11708 + struct buffer_head *bh = head;
11709 + int uptodate = PageUptodate(page);
11710 ++ sector_t end_block = blkdev_max_block(I_BDEV(bdev->bd_inode));
11711 +
11712 + do {
11713 + if (!buffer_mapped(bh)) {
11714 +@@ -979,7 +980,8 @@ init_page_buffers(struct page *page, struct block_device *bdev,
11715 + bh->b_blocknr = block;
11716 + if (uptodate)
11717 + set_buffer_uptodate(bh);
11718 +- set_buffer_mapped(bh);
11719 ++ if (block < end_block)
11720 ++ set_buffer_mapped(bh);
11721 + }
11722 + block++;
11723 + bh = bh->b_this_page;
11724 +diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
11725 +index b4c2c99..b1451af 100644
11726 +--- a/fs/cifs/cifsfs.c
11727 ++++ b/fs/cifs/cifsfs.c
11728 +@@ -703,7 +703,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
11729 + * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
11730 + * the cached file length
11731 + */
11732 +- if (origin != SEEK_SET || origin != SEEK_CUR) {
11733 ++ if (origin != SEEK_SET && origin != SEEK_CUR) {
11734 + int rc;
11735 + struct inode *inode = file->f_path.dentry->d_inode;
11736 +
11737 +diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
11738 +index 5c866e0..adae962 100644
11739 +--- a/fs/ext3/ialloc.c
11740 ++++ b/fs/ext3/ialloc.c
11741 +@@ -525,8 +525,12 @@ got:
11742 + if (IS_DIRSYNC(inode))
11743 + handle->h_sync = 1;
11744 + if (insert_inode_locked(inode) < 0) {
11745 +- err = -EINVAL;
11746 +- goto fail_drop;
11747 ++ /*
11748 ++ * Likely a bitmap corruption causing inode to be allocated
11749 ++ * twice.
11750 ++ */
11751 ++ err = -EIO;
11752 ++ goto fail;
11753 + }
11754 + spin_lock(&sbi->s_next_gen_lock);
11755 + inode->i_generation = sbi->s_next_generation++;
11756 +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
11757 +index 00beb4f..8fb6844 100644
11758 +--- a/fs/ext4/ialloc.c
11759 ++++ b/fs/ext4/ialloc.c
11760 +@@ -885,8 +885,12 @@ got:
11761 + if (IS_DIRSYNC(inode))
11762 + ext4_handle_sync(handle);
11763 + if (insert_inode_locked(inode) < 0) {
11764 +- err = -EINVAL;
11765 +- goto fail_drop;
11766 ++ /*
11767 ++ * Likely a bitmap corruption causing inode to be allocated
11768 ++ * twice.
11769 ++ */
11770 ++ err = -EIO;
11771 ++ goto fail;
11772 + }
11773 + spin_lock(&sbi->s_next_gen_lock);
11774 + inode->i_generation = sbi->s_next_generation++;
11775 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
11776 +index bab7c58..03d9b90 100644
11777 +--- a/fs/nfs/nfs4proc.c
11778 ++++ b/fs/nfs/nfs4proc.c
11779 +@@ -3526,16 +3526,16 @@ out:
11780 + return ret;
11781 + }
11782 +
11783 +-static void nfs4_write_cached_acl(struct inode *inode, const char *buf, size_t acl_len)
11784 ++static void nfs4_write_cached_acl(struct inode *inode, struct page **pages, size_t pgbase, size_t acl_len)
11785 + {
11786 + struct nfs4_cached_acl *acl;
11787 +
11788 +- if (buf && acl_len <= PAGE_SIZE) {
11789 ++ if (pages && acl_len <= PAGE_SIZE) {
11790 + acl = kmalloc(sizeof(*acl) + acl_len, GFP_KERNEL);
11791 + if (acl == NULL)
11792 + goto out;
11793 + acl->cached = 1;
11794 +- memcpy(acl->data, buf, acl_len);
11795 ++ _copy_from_pages(acl->data, pages, pgbase, acl_len);
11796 + } else {
11797 + acl = kmalloc(sizeof(*acl), GFP_KERNEL);
11798 + if (acl == NULL)
11799 +@@ -3568,7 +3568,6 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
11800 + struct nfs_getaclres res = {
11801 + .acl_len = buflen,
11802 + };
11803 +- void *resp_buf;
11804 + struct rpc_message msg = {
11805 + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETACL],
11806 + .rpc_argp = &args,
11807 +@@ -3582,26 +3581,29 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
11808 + if (npages == 0)
11809 + npages = 1;
11810 +
11811 ++ /* Add an extra page to handle the bitmap returned */
11812 ++ npages++;
11813 ++
11814 + for (i = 0; i < npages; i++) {
11815 + pages[i] = alloc_page(GFP_KERNEL);
11816 + if (!pages[i])
11817 + goto out_free;
11818 + }
11819 +- if (npages > 1) {
11820 +- /* for decoding across pages */
11821 +- res.acl_scratch = alloc_page(GFP_KERNEL);
11822 +- if (!res.acl_scratch)
11823 +- goto out_free;
11824 +- }
11825 ++
11826 ++ /* for decoding across pages */
11827 ++ res.acl_scratch = alloc_page(GFP_KERNEL);
11828 ++ if (!res.acl_scratch)
11829 ++ goto out_free;
11830 ++
11831 + args.acl_len = npages * PAGE_SIZE;
11832 + args.acl_pgbase = 0;
11833 ++
11834 + /* Let decode_getfacl know not to fail if the ACL data is larger than
11835 + * the page we send as a guess */
11836 + if (buf == NULL)
11837 + res.acl_flags |= NFS4_ACL_LEN_REQUEST;
11838 +- resp_buf = page_address(pages[0]);
11839 +
11840 +- dprintk("%s buf %p buflen %ld npages %d args.acl_len %ld\n",
11841 ++ dprintk("%s buf %p buflen %zu npages %d args.acl_len %zu\n",
11842 + __func__, buf, buflen, npages, args.acl_len);
11843 + ret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode),
11844 + &msg, &args.seq_args, &res.seq_res, 0);
11845 +@@ -3610,9 +3612,9 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
11846 +
11847 + acl_len = res.acl_len - res.acl_data_offset;
11848 + if (acl_len > args.acl_len)
11849 +- nfs4_write_cached_acl(inode, NULL, acl_len);
11850 ++ nfs4_write_cached_acl(inode, NULL, 0, acl_len);
11851 + else
11852 +- nfs4_write_cached_acl(inode, resp_buf + res.acl_data_offset,
11853 ++ nfs4_write_cached_acl(inode, pages, res.acl_data_offset,
11854 + acl_len);
11855 + if (buf) {
11856 + ret = -ERANGE;
11857 +diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
11858 +index 68adab4..bdd5bdc 100644
11859 +--- a/fs/nfs/nfs4xdr.c
11860 ++++ b/fs/nfs/nfs4xdr.c
11861 +@@ -4965,11 +4965,19 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
11862 + bitmap[3] = {0};
11863 + struct kvec *iov = req->rq_rcv_buf.head;
11864 + int status;
11865 ++ size_t page_len = xdr->buf->page_len;
11866 +
11867 + res->acl_len = 0;
11868 + if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
11869 + goto out;
11870 ++
11871 + bm_p = xdr->p;
11872 ++ res->acl_data_offset = be32_to_cpup(bm_p) + 2;
11873 ++ res->acl_data_offset <<= 2;
11874 ++ /* Check if the acl data starts beyond the allocated buffer */
11875 ++ if (res->acl_data_offset > page_len)
11876 ++ return -ERANGE;
11877 ++
11878 + if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
11879 + goto out;
11880 + if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
11881 +@@ -4979,28 +4987,24 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
11882 + return -EIO;
11883 + if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
11884 + size_t hdrlen;
11885 +- u32 recvd;
11886 +
11887 + /* The bitmap (xdr len + bitmaps) and the attr xdr len words
11888 + * are stored with the acl data to handle the problem of
11889 + * variable length bitmaps.*/
11890 + xdr->p = bm_p;
11891 +- res->acl_data_offset = be32_to_cpup(bm_p) + 2;
11892 +- res->acl_data_offset <<= 2;
11893 +
11894 + /* We ignore &savep and don't do consistency checks on
11895 + * the attr length. Let userspace figure it out.... */
11896 + hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
11897 + attrlen += res->acl_data_offset;
11898 +- recvd = req->rq_rcv_buf.len - hdrlen;
11899 +- if (attrlen > recvd) {
11900 ++ if (attrlen > page_len) {
11901 + if (res->acl_flags & NFS4_ACL_LEN_REQUEST) {
11902 + /* getxattr interface called with a NULL buf */
11903 + res->acl_len = attrlen;
11904 + goto out;
11905 + }
11906 +- dprintk("NFS: acl reply: attrlen %u > recvd %u\n",
11907 +- attrlen, recvd);
11908 ++ dprintk("NFS: acl reply: attrlen %u > page_len %zu\n",
11909 ++ attrlen, page_len);
11910 + return -EINVAL;
11911 + }
11912 + xdr_read_pages(xdr, attrlen);
11913 +diff --git a/fs/super.c b/fs/super.c
11914 +index afd0f1a..2a698f6 100644
11915 +--- a/fs/super.c
11916 ++++ b/fs/super.c
11917 +@@ -1166,6 +1166,8 @@ int freeze_super(struct super_block *sb)
11918 + printk(KERN_ERR
11919 + "VFS:Filesystem freeze failed\n");
11920 + sb->s_frozen = SB_UNFROZEN;
11921 ++ smp_wmb();
11922 ++ wake_up(&sb->s_wait_unfrozen);
11923 + deactivate_locked_super(sb);
11924 + return ret;
11925 + }
11926 +diff --git a/include/linux/fs.h b/include/linux/fs.h
11927 +index 11f1951..43d36b7 100644
11928 +--- a/include/linux/fs.h
11929 ++++ b/include/linux/fs.h
11930 +@@ -2094,6 +2094,7 @@ extern void unregister_blkdev(unsigned int, const char *);
11931 + extern struct block_device *bdget(dev_t);
11932 + extern struct block_device *bdgrab(struct block_device *bdev);
11933 + extern void bd_set_size(struct block_device *, loff_t size);
11934 ++extern sector_t blkdev_max_block(struct block_device *bdev);
11935 + extern void bd_forget(struct inode *inode);
11936 + extern void bdput(struct block_device *);
11937 + extern void invalidate_bdev(struct block_device *);
11938 +diff --git a/include/linux/genhd.h b/include/linux/genhd.h
11939 +index c6f7f6a..4eec461 100644
11940 +--- a/include/linux/genhd.h
11941 ++++ b/include/linux/genhd.h
11942 +@@ -222,12 +222,6 @@ static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
11943 + }
11944 + }
11945 +
11946 +-static inline char *part_unpack_uuid(const u8 *uuid, char *out)
11947 +-{
11948 +- sprintf(out, "%pU", uuid);
11949 +- return out;
11950 +-}
11951 +-
11952 + static inline int disk_max_parts(struct gendisk *disk)
11953 + {
11954 + if (disk->flags & GENHD_FL_EXT_DEVT)
11955 +diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
11956 +index 35410ef..6136821 100644
11957 +--- a/include/linux/kvm_host.h
11958 ++++ b/include/linux/kvm_host.h
11959 +@@ -744,6 +744,13 @@ static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
11960 + {
11961 + return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
11962 + }
11963 ++
11964 ++bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
11965 ++
11966 ++#else
11967 ++
11968 ++static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; }
11969 ++
11970 + #endif
11971 +
11972 + #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT
11973 +diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
11974 +index a3ac9c4..deb6282 100644
11975 +--- a/include/linux/mmc/host.h
11976 ++++ b/include/linux/mmc/host.h
11977 +@@ -303,6 +303,7 @@ struct mmc_host {
11978 +
11979 + unsigned int sdio_irqs;
11980 + struct task_struct *sdio_irq_thread;
11981 ++ bool sdio_irq_pending;
11982 + atomic_t sdio_irq_thread_abort;
11983 +
11984 + mmc_pm_flag_t pm_flags; /* requested pm features */
11985 +@@ -356,6 +357,7 @@ extern int mmc_cache_ctrl(struct mmc_host *, u8);
11986 + static inline void mmc_signal_sdio_irq(struct mmc_host *host)
11987 + {
11988 + host->ops->enable_sdio_irq(host, 0);
11989 ++ host->sdio_irq_pending = true;
11990 + wake_up_process(host->sdio_irq_thread);
11991 + }
11992 +
11993 +diff --git a/include/linux/usb.h b/include/linux/usb.h
11994 +index 7503352..4269c3f 100644
11995 +--- a/include/linux/usb.h
11996 ++++ b/include/linux/usb.h
11997 +@@ -1599,6 +1599,19 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
11998 +
11999 + /* ----------------------------------------------------------------------- */
12000 +
12001 ++/* translate USB error codes to codes user space understands */
12002 ++static inline int usb_translate_errors(int error_code)
12003 ++{
12004 ++ switch (error_code) {
12005 ++ case 0:
12006 ++ case -ENOMEM:
12007 ++ case -ENODEV:
12008 ++ return error_code;
12009 ++ default:
12010 ++ return -EIO;
12011 ++ }
12012 ++}
12013 ++
12014 + /* Events from the usb core */
12015 + #define USB_DEVICE_ADD 0x0001
12016 + #define USB_DEVICE_REMOVE 0x0002
12017 +diff --git a/include/xen/events.h b/include/xen/events.h
12018 +index d287997..8f3d622 100644
12019 +--- a/include/xen/events.h
12020 ++++ b/include/xen/events.h
12021 +@@ -96,6 +96,9 @@ int xen_irq_from_pirq(unsigned pirq);
12022 + /* Return the pirq allocated to the irq. */
12023 + int xen_pirq_from_irq(unsigned irq);
12024 +
12025 ++/* Return the irq allocated to the gsi */
12026 ++int xen_irq_from_gsi(unsigned gsi);
12027 ++
12028 + /* Determine whether to ignore this IRQ if it is passed to a guest. */
12029 + int xen_test_irq_shared(int irq);
12030 +
12031 +diff --git a/init/do_mounts.c b/init/do_mounts.c
12032 +index db6e5ee..d6c229f 100644
12033 +--- a/init/do_mounts.c
12034 ++++ b/init/do_mounts.c
12035 +@@ -470,7 +470,7 @@ void __init change_floppy(char *fmt, ...)
12036 + void __init mount_root(void)
12037 + {
12038 + #ifdef CONFIG_ROOT_NFS
12039 +- if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) {
12040 ++ if (ROOT_DEV == Root_NFS) {
12041 + if (mount_nfs_root())
12042 + return;
12043 +
12044 +diff --git a/init/main.c b/init/main.c
12045 +index 217ed23..cb08fea2 100644
12046 +--- a/init/main.c
12047 ++++ b/init/main.c
12048 +@@ -563,9 +563,6 @@ asmlinkage void __init start_kernel(void)
12049 + early_boot_irqs_disabled = false;
12050 + local_irq_enable();
12051 +
12052 +- /* Interrupts are enabled now so all GFP allocations are safe. */
12053 +- gfp_allowed_mask = __GFP_BITS_MASK;
12054 +-
12055 + kmem_cache_init_late();
12056 +
12057 + /*
12058 +@@ -798,6 +795,10 @@ static int __init kernel_init(void * unused)
12059 + * Wait until kthreadd is all set-up.
12060 + */
12061 + wait_for_completion(&kthreadd_done);
12062 ++
12063 ++ /* Now the scheduler is fully set up and can do blocking allocations */
12064 ++ gfp_allowed_mask = __GFP_BITS_MASK;
12065 ++
12066 + /*
12067 + * init can allocate pages on any node
12068 + */
12069 +diff --git a/kernel/compat.c b/kernel/compat.c
12070 +index f346ced..a6d0649 100644
12071 +--- a/kernel/compat.c
12072 ++++ b/kernel/compat.c
12073 +@@ -320,25 +320,54 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
12074 +
12075 + #ifdef __ARCH_WANT_SYS_SIGPROCMASK
12076 +
12077 +-asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,
12078 +- compat_old_sigset_t __user *oset)
12079 ++/*
12080 ++ * sys_sigprocmask SIG_SETMASK sets the first (compat) word of the
12081 ++ * blocked set of signals to the supplied signal set
12082 ++ */
12083 ++static inline void compat_sig_setmask(sigset_t *blocked, compat_sigset_word set)
12084 + {
12085 +- old_sigset_t s;
12086 +- long ret;
12087 +- mm_segment_t old_fs;
12088 ++ memcpy(blocked->sig, &set, sizeof(set));
12089 ++}
12090 +
12091 +- if (set && get_user(s, set))
12092 +- return -EFAULT;
12093 +- old_fs = get_fs();
12094 +- set_fs(KERNEL_DS);
12095 +- ret = sys_sigprocmask(how,
12096 +- set ? (old_sigset_t __user *) &s : NULL,
12097 +- oset ? (old_sigset_t __user *) &s : NULL);
12098 +- set_fs(old_fs);
12099 +- if (ret == 0)
12100 +- if (oset)
12101 +- ret = put_user(s, oset);
12102 +- return ret;
12103 ++asmlinkage long compat_sys_sigprocmask(int how,
12104 ++ compat_old_sigset_t __user *nset,
12105 ++ compat_old_sigset_t __user *oset)
12106 ++{
12107 ++ old_sigset_t old_set, new_set;
12108 ++ sigset_t new_blocked;
12109 ++
12110 ++ old_set = current->blocked.sig[0];
12111 ++
12112 ++ if (nset) {
12113 ++ if (get_user(new_set, nset))
12114 ++ return -EFAULT;
12115 ++ new_set &= ~(sigmask(SIGKILL) | sigmask(SIGSTOP));
12116 ++
12117 ++ new_blocked = current->blocked;
12118 ++
12119 ++ switch (how) {
12120 ++ case SIG_BLOCK:
12121 ++ sigaddsetmask(&new_blocked, new_set);
12122 ++ break;
12123 ++ case SIG_UNBLOCK:
12124 ++ sigdelsetmask(&new_blocked, new_set);
12125 ++ break;
12126 ++ case SIG_SETMASK:
12127 ++ compat_sig_setmask(&new_blocked, new_set);
12128 ++ break;
12129 ++ default:
12130 ++ return -EINVAL;
12131 ++ }
12132 ++
12133 ++ set_current_blocked(&new_blocked);
12134 ++ }
12135 ++
12136 ++ if (oset) {
12137 ++ if (put_user(old_set, oset))
12138 ++ return -EFAULT;
12139 ++ }
12140 ++
12141 ++ return 0;
12142 + }
12143 +
12144 + #endif
12145 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
12146 +index bb425b1..7947e16 100644
12147 +--- a/kernel/workqueue.c
12148 ++++ b/kernel/workqueue.c
12149 +@@ -1215,8 +1215,13 @@ static void worker_enter_idle(struct worker *worker)
12150 + } else
12151 + wake_up_all(&gcwq->trustee_wait);
12152 +
12153 +- /* sanity check nr_running */
12154 +- WARN_ON_ONCE(gcwq->nr_workers == gcwq->nr_idle &&
12155 ++ /*
12156 ++ * Sanity check nr_running. Because trustee releases gcwq->lock
12157 ++ * between setting %WORKER_ROGUE and zapping nr_running, the
12158 ++ * warning may trigger spuriously. Check iff trustee is idle.
12159 ++ */
12160 ++ WARN_ON_ONCE(gcwq->trustee_state == TRUSTEE_DONE &&
12161 ++ gcwq->nr_workers == gcwq->nr_idle &&
12162 + atomic_read(get_gcwq_nr_running(gcwq->cpu)));
12163 + }
12164 +
12165 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
12166 +index 778554f..c8425b1 100644
12167 +--- a/mm/memcontrol.c
12168 ++++ b/mm/memcontrol.c
12169 +@@ -4549,6 +4549,12 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
12170 + swap_buffers:
12171 + /* Swap primary and spare array */
12172 + thresholds->spare = thresholds->primary;
12173 ++ /* If all events are unregistered, free the spare array */
12174 ++ if (!new) {
12175 ++ kfree(thresholds->spare);
12176 ++ thresholds->spare = NULL;
12177 ++ }
12178 ++
12179 + rcu_assign_pointer(thresholds->primary, new);
12180 +
12181 + /* To be sure that nobody uses thresholds */
12182 +diff --git a/mm/swapfile.c b/mm/swapfile.c
12183 +index 2015a1e..d3955f2 100644
12184 +--- a/mm/swapfile.c
12185 ++++ b/mm/swapfile.c
12186 +@@ -2102,7 +2102,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
12187 + p->flags |= SWP_SOLIDSTATE;
12188 + p->cluster_next = 1 + (random32() % p->highest_bit);
12189 + }
12190 +- if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
12191 ++ if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0)
12192 + p->flags |= SWP_DISCARDABLE;
12193 + }
12194 +
12195 +diff --git a/net/core/ethtool.c b/net/core/ethtool.c
12196 +index f444817..2b587ec 100644
12197 +--- a/net/core/ethtool.c
12198 ++++ b/net/core/ethtool.c
12199 +@@ -1549,6 +1549,8 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
12200 + if (!dev->ethtool_ops->flash_device)
12201 + return -EOPNOTSUPP;
12202 +
12203 ++ efl.data[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0;
12204 ++
12205 + return dev->ethtool_ops->flash_device(dev, &efl);
12206 + }
12207 +
12208 +diff --git a/net/wireless/reg.c b/net/wireless/reg.c
12209 +index 3302c56..c1c99dd 100644
12210 +--- a/net/wireless/reg.c
12211 ++++ b/net/wireless/reg.c
12212 +@@ -379,7 +379,15 @@ static void reg_regdb_query(const char *alpha2)
12213 +
12214 + schedule_work(&reg_regdb_work);
12215 + }
12216 ++
12217 ++/* Feel free to add any other sanity checks here */
12218 ++static void reg_regdb_size_check(void)
12219 ++{
12220 ++ /* We should ideally BUILD_BUG_ON() but then random builds would fail */
12221 ++ WARN_ONCE(!reg_regdb_size, "db.txt is empty, you should update it...");
12222 ++}
12223 + #else
12224 ++static inline void reg_regdb_size_check(void) {}
12225 + static inline void reg_regdb_query(const char *alpha2) {}
12226 + #endif /* CONFIG_CFG80211_INTERNAL_REGDB */
12227 +
12228 +@@ -2236,6 +2244,8 @@ int __init regulatory_init(void)
12229 + spin_lock_init(&reg_requests_lock);
12230 + spin_lock_init(&reg_pending_beacons_lock);
12231 +
12232 ++ reg_regdb_size_check();
12233 ++
12234 + cfg80211_regdomain = cfg80211_world_regdom;
12235 +
12236 + user_alpha2[0] = '9';
12237 +diff --git a/scripts/Makefile b/scripts/Makefile
12238 +index df7678f..3626666 100644
12239 +--- a/scripts/Makefile
12240 ++++ b/scripts/Makefile
12241 +@@ -8,6 +8,8 @@
12242 + # conmakehash: Create arrays for initializing the kernel console tables
12243 + # docproc: Used in Documentation/DocBook
12244 +
12245 ++HOST_EXTRACFLAGS += -I$(srctree)/tools/include
12246 ++
12247 + hostprogs-$(CONFIG_KALLSYMS) += kallsyms
12248 + hostprogs-$(CONFIG_LOGO) += pnmtologo
12249 + hostprogs-$(CONFIG_VT) += conmakehash
12250 +diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
12251 +index f466587..b4f802d 100644
12252 +--- a/security/selinux/selinuxfs.c
12253 ++++ b/security/selinux/selinuxfs.c
12254 +@@ -1238,6 +1238,7 @@ static int sel_make_bools(void)
12255 + kfree(bool_pending_names[i]);
12256 + kfree(bool_pending_names);
12257 + kfree(bool_pending_values);
12258 ++ bool_num = 0;
12259 + bool_pending_names = NULL;
12260 + bool_pending_values = NULL;
12261 +
12262 +diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
12263 +index b9c7986..f17dfee 100644
12264 +--- a/tools/usb/ffs-test.c
12265 ++++ b/tools/usb/ffs-test.c
12266 +@@ -324,7 +324,7 @@ static void *start_thread_helper(void *arg)
12267 +
12268 + ret = t->in(t, t->buf, t->buf_size);
12269 + if (ret > 0) {
12270 +- ret = t->out(t, t->buf, t->buf_size);
12271 ++ ret = t->out(t, t->buf, ret);
12272 + name = out_name;
12273 + op = "write";
12274 + } else {
12275 +diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
12276 +index fd817a2..533db33 100644
12277 +--- a/virt/kvm/iommu.c
12278 ++++ b/virt/kvm/iommu.c
12279 +@@ -239,9 +239,13 @@ int kvm_iommu_map_guest(struct kvm *kvm)
12280 + return -ENODEV;
12281 + }
12282 +
12283 ++ mutex_lock(&kvm->slots_lock);
12284 ++
12285 + kvm->arch.iommu_domain = iommu_domain_alloc(&pci_bus_type);
12286 +- if (!kvm->arch.iommu_domain)
12287 +- return -ENOMEM;
12288 ++ if (!kvm->arch.iommu_domain) {
12289 ++ r = -ENOMEM;
12290 ++ goto out_unlock;
12291 ++ }
12292 +
12293 + if (!allow_unsafe_assigned_interrupts &&
12294 + !iommu_domain_has_cap(kvm->arch.iommu_domain,
12295 +@@ -252,17 +256,16 @@ int kvm_iommu_map_guest(struct kvm *kvm)
12296 + " module option.\n", __func__);
12297 + iommu_domain_free(kvm->arch.iommu_domain);
12298 + kvm->arch.iommu_domain = NULL;
12299 +- return -EPERM;
12300 ++ r = -EPERM;
12301 ++ goto out_unlock;
12302 + }
12303 +
12304 + r = kvm_iommu_map_memslots(kvm);
12305 + if (r)
12306 +- goto out_unmap;
12307 +-
12308 +- return 0;
12309 ++ kvm_iommu_unmap_memslots(kvm);
12310 +
12311 +-out_unmap:
12312 +- kvm_iommu_unmap_memslots(kvm);
12313 ++out_unlock:
12314 ++ mutex_unlock(&kvm->slots_lock);
12315 + return r;
12316 + }
12317 +
12318 +@@ -338,7 +341,11 @@ int kvm_iommu_unmap_guest(struct kvm *kvm)
12319 + if (!domain)
12320 + return 0;
12321 +
12322 ++ mutex_lock(&kvm->slots_lock);
12323 + kvm_iommu_unmap_memslots(kvm);
12324 ++ kvm->arch.iommu_domain = NULL;
12325 ++ mutex_unlock(&kvm->slots_lock);
12326 ++
12327 + iommu_domain_free(domain);
12328 + return 0;
12329 + }
12330 +diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
12331 +index e401c1b..ec747dc 100644
12332 +--- a/virt/kvm/kvm_main.c
12333 ++++ b/virt/kvm/kvm_main.c
12334 +@@ -289,15 +289,15 @@ static void kvm_mmu_notifier_invalidate_page(struct mmu_notifier *mn,
12335 + */
12336 + idx = srcu_read_lock(&kvm->srcu);
12337 + spin_lock(&kvm->mmu_lock);
12338 ++
12339 + kvm->mmu_notifier_seq++;
12340 + need_tlb_flush = kvm_unmap_hva(kvm, address) | kvm->tlbs_dirty;
12341 +- spin_unlock(&kvm->mmu_lock);
12342 +- srcu_read_unlock(&kvm->srcu, idx);
12343 +-
12344 + /* we've to flush the tlb before the pages can be freed */
12345 + if (need_tlb_flush)
12346 + kvm_flush_remote_tlbs(kvm);
12347 +
12348 ++ spin_unlock(&kvm->mmu_lock);
12349 ++ srcu_read_unlock(&kvm->srcu, idx);
12350 + }
12351 +
12352 + static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
12353 +@@ -335,12 +335,12 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
12354 + for (; start < end; start += PAGE_SIZE)
12355 + need_tlb_flush |= kvm_unmap_hva(kvm, start);
12356 + need_tlb_flush |= kvm->tlbs_dirty;
12357 +- spin_unlock(&kvm->mmu_lock);
12358 +- srcu_read_unlock(&kvm->srcu, idx);
12359 +-
12360 + /* we've to flush the tlb before the pages can be freed */
12361 + if (need_tlb_flush)
12362 + kvm_flush_remote_tlbs(kvm);
12363 ++
12364 ++ spin_unlock(&kvm->mmu_lock);
12365 ++ srcu_read_unlock(&kvm->srcu, idx);
12366 + }
12367 +
12368 + static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
12369 +@@ -378,13 +378,14 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn,
12370 +
12371 + idx = srcu_read_lock(&kvm->srcu);
12372 + spin_lock(&kvm->mmu_lock);
12373 +- young = kvm_age_hva(kvm, address);
12374 +- spin_unlock(&kvm->mmu_lock);
12375 +- srcu_read_unlock(&kvm->srcu, idx);
12376 +
12377 ++ young = kvm_age_hva(kvm, address);
12378 + if (young)
12379 + kvm_flush_remote_tlbs(kvm);
12380 +
12381 ++ spin_unlock(&kvm->mmu_lock);
12382 ++ srcu_read_unlock(&kvm->srcu, idx);
12383 ++
12384 + return young;
12385 + }
12386 +
12387 +@@ -1666,6 +1667,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
12388 + goto vcpu_destroy;
12389 +
12390 + mutex_lock(&kvm->lock);
12391 ++ if (!kvm_vcpu_compatible(vcpu)) {
12392 ++ r = -EINVAL;
12393 ++ goto unlock_vcpu_destroy;
12394 ++ }
12395 + if (atomic_read(&kvm->online_vcpus) == KVM_MAX_VCPUS) {
12396 + r = -EINVAL;
12397 + goto unlock_vcpu_destroy;