Magellan Linux

Contents of /trunk/kernel-magellan/patches-3.7/0105-3.7.6-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2064 - (show annotations) (download)
Wed Feb 6 10:48:49 2013 UTC (11 years, 3 months ago) by niro
File size: 110462 byte(s)
- linux-3.7.6
1 diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt
2 index 728c38c..56fb62b 100644
3 --- a/Documentation/device-mapper/dm-raid.txt
4 +++ b/Documentation/device-mapper/dm-raid.txt
5 @@ -141,3 +141,4 @@ Version History
6 1.2.0 Handle creation of arrays that contain failed devices.
7 1.3.0 Added support for RAID 10
8 1.3.1 Allow device replacement/rebuild for RAID 10
9 +1.3.2 Fix/improve redundancy checking for RAID10
10 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
11 index 4eee351..486a15a 100644
12 --- a/arch/arm/kernel/head.S
13 +++ b/arch/arm/kernel/head.S
14 @@ -246,6 +246,7 @@ __create_page_tables:
15
16 /*
17 * Then map boot params address in r2 if specified.
18 + * We map 2 sections in case the ATAGs/DTB crosses a section boundary.
19 */
20 mov r0, r2, lsr #SECTION_SHIFT
21 movs r0, r0, lsl #SECTION_SHIFT
22 @@ -253,6 +254,8 @@ __create_page_tables:
23 addne r3, r3, #PAGE_OFFSET
24 addne r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER)
25 orrne r6, r7, r0
26 + strne r6, [r3], #1 << PMD_ORDER
27 + addne r6, r6, #1 << SECTION_SHIFT
28 strne r6, [r3]
29
30 #ifdef CONFIG_DEBUG_LL
31 @@ -331,7 +334,7 @@ ENTRY(secondary_startup)
32 * as it has already been validated by the primary processor.
33 */
34 #ifdef CONFIG_ARM_VIRT_EXT
35 - bl __hyp_stub_install
36 + bl __hyp_stub_install_secondary
37 #endif
38 safe_svcmode_maskall r9
39
40 diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
41 index 65b2417..1315c4c 100644
42 --- a/arch/arm/kernel/hyp-stub.S
43 +++ b/arch/arm/kernel/hyp-stub.S
44 @@ -99,7 +99,7 @@ ENTRY(__hyp_stub_install_secondary)
45 * immediately.
46 */
47 compare_cpu_mode_with_primary r4, r5, r6, r7
48 - bxne lr
49 + movne pc, lr
50
51 /*
52 * Once we have given up on one CPU, we do not try to install the
53 @@ -111,7 +111,7 @@ ENTRY(__hyp_stub_install_secondary)
54 */
55
56 cmp r4, #HYP_MODE
57 - bxne lr @ give up if the CPU is not in HYP mode
58 + movne pc, lr @ give up if the CPU is not in HYP mode
59
60 /*
61 * Configure HSCTLR to set correct exception endianness/instruction set
62 @@ -120,7 +120,8 @@ ENTRY(__hyp_stub_install_secondary)
63 * Eventually, CPU-specific code might be needed -- assume not for now
64 *
65 * This code relies on the "eret" instruction to synchronize the
66 - * various coprocessor accesses.
67 + * various coprocessor accesses. This is done when we switch to SVC
68 + * (see safe_svcmode_maskall).
69 */
70 @ Now install the hypervisor stub:
71 adr r7, __hyp_stub_vectors
72 @@ -155,14 +156,7 @@ THUMB( orr r7, #(1 << 30) ) @ HSCTLR.TE
73 1:
74 #endif
75
76 - bic r7, r4, #MODE_MASK
77 - orr r7, r7, #SVC_MODE
78 -THUMB( orr r7, r7, #PSR_T_BIT )
79 - msr spsr_cxsf, r7 @ This is SPSR_hyp.
80 -
81 - __MSR_ELR_HYP(14) @ msr elr_hyp, lr
82 - __ERET @ return, switching to SVC mode
83 - @ The boot CPU mode is left in r4.
84 + bx lr @ The boot CPU mode is left in r4.
85 ENDPROC(__hyp_stub_install_secondary)
86
87 __hyp_stub_do_trap:
88 @@ -200,7 +194,7 @@ ENDPROC(__hyp_get_vectors)
89 @ fall through
90 ENTRY(__hyp_set_vectors)
91 __HVC(0)
92 - bx lr
93 + mov pc, lr
94 ENDPROC(__hyp_set_vectors)
95
96 #ifndef ZIMAGE
97 diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
98 index 0b32c81..dee51da 100644
99 --- a/arch/arm/mach-at91/setup.c
100 +++ b/arch/arm/mach-at91/setup.c
101 @@ -104,6 +104,8 @@ static void __init soc_detect(u32 dbgu_base)
102 switch (socid) {
103 case ARCH_ID_AT91RM9200:
104 at91_soc_initdata.type = AT91_SOC_RM9200;
105 + if (at91_soc_initdata.subtype == AT91_SOC_SUBTYPE_NONE)
106 + at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
107 at91_boot_soc = at91rm9200_soc;
108 break;
109
110 diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
111 index bfcd397..92bb6b4 100644
112 --- a/arch/arm/mach-omap2/board-omap4panda.c
113 +++ b/arch/arm/mach-omap2/board-omap4panda.c
114 @@ -402,6 +402,12 @@ static struct omap_board_mux board_mux[] __initdata = {
115 OMAP_PULL_ENA),
116 OMAP4_MUX(ABE_MCBSP1_FSX, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
117
118 + /* UART2 - BT/FM/GPS shared transport */
119 + OMAP4_MUX(UART2_CTS, OMAP_PIN_INPUT | OMAP_MUX_MODE0),
120 + OMAP4_MUX(UART2_RTS, OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
121 + OMAP4_MUX(UART2_RX, OMAP_PIN_INPUT | OMAP_MUX_MODE0),
122 + OMAP4_MUX(UART2_TX, OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
123 +
124 { .reg_offset = OMAP_MUX_TERMINATOR },
125 };
126
127 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
128 index 4e3fe57..cbc1b7b 100644
129 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
130 +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
131 @@ -39,7 +39,7 @@ static struct spi_board_info wm1253_devs[] = {
132 .bus_num = 0,
133 .chip_select = 0,
134 .mode = SPI_MODE_0,
135 - .irq = S3C_EINT(5),
136 + .irq = S3C_EINT(4),
137 .controller_data = &wm0010_spi_csinfo,
138 },
139 };
140 diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
141 index 58bc3e4..9cb586f 100644
142 --- a/arch/arm/mm/dma-mapping.c
143 +++ b/arch/arm/mm/dma-mapping.c
144 @@ -776,25 +776,27 @@ static void dma_cache_maint_page(struct page *page, unsigned long offset,
145 size_t size, enum dma_data_direction dir,
146 void (*op)(const void *, size_t, int))
147 {
148 + unsigned long pfn;
149 + size_t left = size;
150 +
151 + pfn = page_to_pfn(page) + offset / PAGE_SIZE;
152 + offset %= PAGE_SIZE;
153 +
154 /*
155 * A single sg entry may refer to multiple physically contiguous
156 * pages. But we still need to process highmem pages individually.
157 * If highmem is not configured then the bulk of this loop gets
158 * optimized out.
159 */
160 - size_t left = size;
161 do {
162 size_t len = left;
163 void *vaddr;
164
165 + page = pfn_to_page(pfn);
166 +
167 if (PageHighMem(page)) {
168 - if (len + offset > PAGE_SIZE) {
169 - if (offset >= PAGE_SIZE) {
170 - page += offset / PAGE_SIZE;
171 - offset %= PAGE_SIZE;
172 - }
173 + if (len + offset > PAGE_SIZE)
174 len = PAGE_SIZE - offset;
175 - }
176 vaddr = kmap_high_get(page);
177 if (vaddr) {
178 vaddr += offset;
179 @@ -811,7 +813,7 @@ static void dma_cache_maint_page(struct page *page, unsigned long offset,
180 op(vaddr, len, dir);
181 }
182 offset = 0;
183 - page++;
184 + pfn++;
185 left -= len;
186 } while (left);
187 }
188 diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
189 index cc926c9..323ce1a 100644
190 --- a/arch/arm/vfp/entry.S
191 +++ b/arch/arm/vfp/entry.S
192 @@ -22,7 +22,7 @@
193 @ IRQs disabled.
194 @
195 ENTRY(do_vfp)
196 -#ifdef CONFIG_PREEMPT
197 +#ifdef CONFIG_PREEMPT_COUNT
198 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
199 add r11, r4, #1 @ increment it
200 str r11, [r10, #TI_PREEMPT]
201 @@ -35,7 +35,7 @@ ENTRY(do_vfp)
202 ENDPROC(do_vfp)
203
204 ENTRY(vfp_null_entry)
205 -#ifdef CONFIG_PREEMPT
206 +#ifdef CONFIG_PREEMPT_COUNT
207 get_thread_info r10
208 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
209 sub r11, r4, #1 @ decrement it
210 @@ -53,7 +53,7 @@ ENDPROC(vfp_null_entry)
211
212 __INIT
213 ENTRY(vfp_testing_entry)
214 -#ifdef CONFIG_PREEMPT
215 +#ifdef CONFIG_PREEMPT_COUNT
216 get_thread_info r10
217 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
218 sub r11, r4, #1 @ decrement it
219 diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
220 index ea0349f..dd5e56f 100644
221 --- a/arch/arm/vfp/vfphw.S
222 +++ b/arch/arm/vfp/vfphw.S
223 @@ -168,7 +168,7 @@ vfp_hw_state_valid:
224 @ else it's one 32-bit instruction, so
225 @ always subtract 4 from the following
226 @ instruction address.
227 -#ifdef CONFIG_PREEMPT
228 +#ifdef CONFIG_PREEMPT_COUNT
229 get_thread_info r10
230 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
231 sub r11, r4, #1 @ decrement it
232 @@ -192,7 +192,7 @@ look_for_VFP_exceptions:
233 @ not recognised by VFP
234
235 DBGSTR "not VFP"
236 -#ifdef CONFIG_PREEMPT
237 +#ifdef CONFIG_PREEMPT_COUNT
238 get_thread_info r10
239 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
240 sub r11, r4, #1 @ decrement it
241 diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
242 index 56e0ff0..4262aac 100644
243 --- a/arch/powerpc/kernel/entry_64.S
244 +++ b/arch/powerpc/kernel/entry_64.S
245 @@ -668,6 +668,19 @@ resume_kernel:
246 ld r4,TI_FLAGS(r9)
247 andi. r0,r4,_TIF_NEED_RESCHED
248 bne 1b
249 +
250 + /*
251 + * arch_local_irq_restore() from preempt_schedule_irq above may
252 + * enable hard interrupt but we really should disable interrupts
253 + * when we return from the interrupt, and so that we don't get
254 + * interrupted after loading SRR0/1.
255 + */
256 +#ifdef CONFIG_PPC_BOOK3E
257 + wrteei 0
258 +#else
259 + ld r10,PACAKMSR(r13) /* Get kernel MSR without EE */
260 + mtmsrd r10,1 /* Update machine state */
261 +#endif /* CONFIG_PPC_BOOK3E */
262 #endif /* CONFIG_PREEMPT */
263
264 .globl fast_exc_return_irq
265 diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
266 index ee04aba..f6ba56f 100644
267 --- a/arch/powerpc/kvm/emulate.c
268 +++ b/arch/powerpc/kvm/emulate.c
269 @@ -39,6 +39,7 @@
270 #define OP_31_XOP_TRAP 4
271 #define OP_31_XOP_LWZX 23
272 #define OP_31_XOP_TRAP_64 68
273 +#define OP_31_XOP_DCBF 86
274 #define OP_31_XOP_LBZX 87
275 #define OP_31_XOP_STWX 151
276 #define OP_31_XOP_STBX 215
277 @@ -353,6 +354,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
278 kvmppc_set_exit_type(vcpu, EMULATED_MTSPR_EXITS);
279 break;
280
281 + case OP_31_XOP_DCBF:
282 case OP_31_XOP_DCBI:
283 /* Do nothing. The guest is performing dcbi because
284 * hardware DMA is not snooped by the dcache, but
285 diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
286 index 2d3b7cb..80d44ff 100644
287 --- a/arch/s390/include/asm/pgtable.h
288 +++ b/arch/s390/include/asm/pgtable.h
289 @@ -1365,6 +1365,18 @@ static inline void pmdp_invalidate(struct vm_area_struct *vma,
290 __pmd_idte(address, pmdp);
291 }
292
293 +#define __HAVE_ARCH_PMDP_SET_WRPROTECT
294 +static inline void pmdp_set_wrprotect(struct mm_struct *mm,
295 + unsigned long address, pmd_t *pmdp)
296 +{
297 + pmd_t pmd = *pmdp;
298 +
299 + if (pmd_write(pmd)) {
300 + __pmd_idte(address, pmdp);
301 + set_pmd_at(mm, address, pmdp, pmd_wrprotect(pmd));
302 + }
303 +}
304 +
305 static inline pmd_t mk_pmd_phys(unsigned long physpage, pgprot_t pgprot)
306 {
307 pmd_t __pmd;
308 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
309 index e87b0ca..ccae7e2 100644
310 --- a/arch/x86/boot/compressed/eboot.c
311 +++ b/arch/x86/boot/compressed/eboot.c
312 @@ -316,10 +316,9 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
313 * Once we've found a GOP supporting ConOut,
314 * don't bother looking any further.
315 */
316 + first_gop = gop;
317 if (conout_found)
318 break;
319 -
320 - first_gop = gop;
321 }
322 }
323
324 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
325 index aa4aaf1..ccb2f4a 100644
326 --- a/arch/x86/boot/compressed/head_32.S
327 +++ b/arch/x86/boot/compressed/head_32.S
328 @@ -50,8 +50,10 @@ ENTRY(startup_32)
329 pushl %eax
330 pushl %esi
331 pushl %ecx
332 + sub $0x4, %esp
333
334 .org 0x30,0x90
335 + add $0x4, %esp
336 call efi_main
337 cmpl $0, %eax
338 movl %eax, %esi
339 diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
340 index 6e8fdf5..28677c5 100644
341 --- a/arch/x86/include/asm/efi.h
342 +++ b/arch/x86/include/asm/efi.h
343 @@ -94,6 +94,7 @@ extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
344 #endif /* CONFIG_X86_32 */
345
346 extern int add_efi_memmap;
347 +extern unsigned long x86_efi_facility;
348 extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
349 extern int efi_memblock_x86_reserve_range(void);
350 extern void efi_call_phys_prelog(void);
351 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
352 index a7c5661..4929502 100644
353 --- a/arch/x86/kernel/msr.c
354 +++ b/arch/x86/kernel/msr.c
355 @@ -174,6 +174,9 @@ static int msr_open(struct inode *inode, struct file *file)
356 unsigned int cpu;
357 struct cpuinfo_x86 *c;
358
359 + if (!capable(CAP_SYS_RAWIO))
360 + return -EPERM;
361 +
362 cpu = iminor(file->f_path.dentry->d_inode);
363 if (cpu >= nr_cpu_ids || !cpu_online(cpu))
364 return -ENXIO; /* No such CPU */
365 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
366 index 4e8ba39..76fa1e9 100644
367 --- a/arch/x86/kernel/reboot.c
368 +++ b/arch/x86/kernel/reboot.c
369 @@ -584,7 +584,7 @@ static void native_machine_emergency_restart(void)
370 break;
371
372 case BOOT_EFI:
373 - if (efi_enabled)
374 + if (efi_enabled(EFI_RUNTIME_SERVICES))
375 efi.reset_system(reboot_mode ?
376 EFI_RESET_WARM :
377 EFI_RESET_COLD,
378 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
379 index 86c524c..aeacb0e 100644
380 --- a/arch/x86/kernel/setup.c
381 +++ b/arch/x86/kernel/setup.c
382 @@ -616,6 +616,7 @@ static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
383
384 static bool __init snb_gfx_workaround_needed(void)
385 {
386 +#ifdef CONFIG_PCI
387 int i;
388 u16 vendor, devid;
389 static const u16 snb_ids[] = {
390 @@ -640,6 +641,7 @@ static bool __init snb_gfx_workaround_needed(void)
391 for (i = 0; i < ARRAY_SIZE(snb_ids); i++)
392 if (devid == snb_ids[i])
393 return true;
394 +#endif
395
396 return false;
397 }
398 @@ -809,15 +811,15 @@ void __init setup_arch(char **cmdline_p)
399 #ifdef CONFIG_EFI
400 if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
401 "EL32", 4)) {
402 - efi_enabled = 1;
403 - efi_64bit = false;
404 + set_bit(EFI_BOOT, &x86_efi_facility);
405 } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
406 "EL64", 4)) {
407 - efi_enabled = 1;
408 - efi_64bit = true;
409 + set_bit(EFI_BOOT, &x86_efi_facility);
410 + set_bit(EFI_64BIT, &x86_efi_facility);
411 }
412 - if (efi_enabled && efi_memblock_x86_reserve_range())
413 - efi_enabled = 0;
414 +
415 + if (efi_enabled(EFI_BOOT))
416 + efi_memblock_x86_reserve_range();
417 #endif
418
419 x86_init.oem.arch_setup();
420 @@ -890,7 +892,7 @@ void __init setup_arch(char **cmdline_p)
421
422 finish_e820_parsing();
423
424 - if (efi_enabled)
425 + if (efi_enabled(EFI_BOOT))
426 efi_init();
427
428 dmi_scan_machine();
429 @@ -973,7 +975,7 @@ void __init setup_arch(char **cmdline_p)
430 * The EFI specification says that boot service code won't be called
431 * after ExitBootServices(). This is, in fact, a lie.
432 */
433 - if (efi_enabled)
434 + if (efi_enabled(EFI_MEMMAP))
435 efi_reserve_boot_services();
436
437 /* preallocate 4k for mptable mpc */
438 @@ -1112,7 +1114,7 @@ void __init setup_arch(char **cmdline_p)
439
440 #ifdef CONFIG_VT
441 #if defined(CONFIG_VGA_CONSOLE)
442 - if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
443 + if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
444 conswitchp = &vga_con;
445 #elif defined(CONFIG_DUMMY_CONSOLE)
446 conswitchp = &dummy_con;
447 @@ -1129,14 +1131,14 @@ void __init setup_arch(char **cmdline_p)
448 register_refined_jiffies(CLOCK_TICK_RATE);
449
450 #ifdef CONFIG_EFI
451 - /* Once setup is done above, disable efi_enabled on mismatched
452 - * firmware/kernel archtectures since there is no support for
453 - * runtime services.
454 + /* Once setup is done above, unmap the EFI memory map on
455 + * mismatched firmware/kernel archtectures since there is no
456 + * support for runtime services.
457 */
458 - if (efi_enabled && IS_ENABLED(CONFIG_X86_64) != efi_64bit) {
459 + if (efi_enabled(EFI_BOOT) &&
460 + IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)) {
461 pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
462 efi_unmap_memmap();
463 - efi_enabled = 0;
464 }
465 #endif
466 }
467 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
468 index ad44391..77cf009 100644
469 --- a/arch/x86/platform/efi/efi.c
470 +++ b/arch/x86/platform/efi/efi.c
471 @@ -51,9 +51,6 @@
472
473 #define EFI_DEBUG 1
474
475 -int efi_enabled;
476 -EXPORT_SYMBOL(efi_enabled);
477 -
478 struct efi __read_mostly efi = {
479 .mps = EFI_INVALID_TABLE_ADDR,
480 .acpi = EFI_INVALID_TABLE_ADDR,
481 @@ -69,19 +66,28 @@ EXPORT_SYMBOL(efi);
482
483 struct efi_memory_map memmap;
484
485 -bool efi_64bit;
486 -
487 static struct efi efi_phys __initdata;
488 static efi_system_table_t efi_systab __initdata;
489
490 static inline bool efi_is_native(void)
491 {
492 - return IS_ENABLED(CONFIG_X86_64) == efi_64bit;
493 + return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
494 +}
495 +
496 +unsigned long x86_efi_facility;
497 +
498 +/*
499 + * Returns 1 if 'facility' is enabled, 0 otherwise.
500 + */
501 +int efi_enabled(int facility)
502 +{
503 + return test_bit(facility, &x86_efi_facility) != 0;
504 }
505 +EXPORT_SYMBOL(efi_enabled);
506
507 static int __init setup_noefi(char *arg)
508 {
509 - efi_enabled = 0;
510 + clear_bit(EFI_BOOT, &x86_efi_facility);
511 return 0;
512 }
513 early_param("noefi", setup_noefi);
514 @@ -426,6 +432,7 @@ void __init efi_reserve_boot_services(void)
515
516 void __init efi_unmap_memmap(void)
517 {
518 + clear_bit(EFI_MEMMAP, &x86_efi_facility);
519 if (memmap.map) {
520 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
521 memmap.map = NULL;
522 @@ -460,7 +467,7 @@ void __init efi_free_boot_services(void)
523
524 static int __init efi_systab_init(void *phys)
525 {
526 - if (efi_64bit) {
527 + if (efi_enabled(EFI_64BIT)) {
528 efi_system_table_64_t *systab64;
529 u64 tmp = 0;
530
531 @@ -552,7 +559,7 @@ static int __init efi_config_init(u64 tables, int nr_tables)
532 void *config_tables, *tablep;
533 int i, sz;
534
535 - if (efi_64bit)
536 + if (efi_enabled(EFI_64BIT))
537 sz = sizeof(efi_config_table_64_t);
538 else
539 sz = sizeof(efi_config_table_32_t);
540 @@ -572,7 +579,7 @@ static int __init efi_config_init(u64 tables, int nr_tables)
541 efi_guid_t guid;
542 unsigned long table;
543
544 - if (efi_64bit) {
545 + if (efi_enabled(EFI_64BIT)) {
546 u64 table64;
547 guid = ((efi_config_table_64_t *)tablep)->guid;
548 table64 = ((efi_config_table_64_t *)tablep)->table;
549 @@ -684,7 +691,6 @@ void __init efi_init(void)
550 if (boot_params.efi_info.efi_systab_hi ||
551 boot_params.efi_info.efi_memmap_hi) {
552 pr_info("Table located above 4GB, disabling EFI.\n");
553 - efi_enabled = 0;
554 return;
555 }
556 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
557 @@ -694,10 +700,10 @@ void __init efi_init(void)
558 ((__u64)boot_params.efi_info.efi_systab_hi<<32));
559 #endif
560
561 - if (efi_systab_init(efi_phys.systab)) {
562 - efi_enabled = 0;
563 + if (efi_systab_init(efi_phys.systab))
564 return;
565 - }
566 +
567 + set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility);
568
569 /*
570 * Show what we know for posterity
571 @@ -715,10 +721,10 @@ void __init efi_init(void)
572 efi.systab->hdr.revision >> 16,
573 efi.systab->hdr.revision & 0xffff, vendor);
574
575 - if (efi_config_init(efi.systab->tables, efi.systab->nr_tables)) {
576 - efi_enabled = 0;
577 + if (efi_config_init(efi.systab->tables, efi.systab->nr_tables))
578 return;
579 - }
580 +
581 + set_bit(EFI_CONFIG_TABLES, &x86_efi_facility);
582
583 /*
584 * Note: We currently don't support runtime services on an EFI
585 @@ -727,15 +733,17 @@ void __init efi_init(void)
586
587 if (!efi_is_native())
588 pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n");
589 - else if (efi_runtime_init()) {
590 - efi_enabled = 0;
591 - return;
592 + else {
593 + if (efi_runtime_init())
594 + return;
595 + set_bit(EFI_RUNTIME_SERVICES, &x86_efi_facility);
596 }
597
598 - if (efi_memmap_init()) {
599 - efi_enabled = 0;
600 + if (efi_memmap_init())
601 return;
602 - }
603 +
604 + set_bit(EFI_MEMMAP, &x86_efi_facility);
605 +
606 #ifdef CONFIG_X86_32
607 if (efi_is_native()) {
608 x86_platform.get_wallclock = efi_get_time;
609 @@ -941,7 +949,7 @@ void __init efi_enter_virtual_mode(void)
610 *
611 * Call EFI services through wrapper functions.
612 */
613 - efi.runtime_version = efi_systab.fw_revision;
614 + efi.runtime_version = efi_systab.hdr.revision;
615 efi.get_time = virt_efi_get_time;
616 efi.set_time = virt_efi_set_time;
617 efi.get_wakeup_time = virt_efi_get_wakeup_time;
618 @@ -969,6 +977,9 @@ u32 efi_mem_type(unsigned long phys_addr)
619 efi_memory_desc_t *md;
620 void *p;
621
622 + if (!efi_enabled(EFI_MEMMAP))
623 + return 0;
624 +
625 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
626 md = p;
627 if ((md->phys_addr <= phys_addr) &&
628 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
629 index 95fd505..2b20038 100644
630 --- a/arch/x86/platform/efi/efi_64.c
631 +++ b/arch/x86/platform/efi/efi_64.c
632 @@ -38,7 +38,7 @@
633 #include <asm/cacheflush.h>
634 #include <asm/fixmap.h>
635
636 -static pgd_t save_pgd __initdata;
637 +static pgd_t *save_pgd __initdata;
638 static unsigned long efi_flags __initdata;
639
640 static void __init early_code_mapping_set_exec(int executable)
641 @@ -61,12 +61,20 @@ static void __init early_code_mapping_set_exec(int executable)
642 void __init efi_call_phys_prelog(void)
643 {
644 unsigned long vaddress;
645 + int pgd;
646 + int n_pgds;
647
648 early_code_mapping_set_exec(1);
649 local_irq_save(efi_flags);
650 - vaddress = (unsigned long)__va(0x0UL);
651 - save_pgd = *pgd_offset_k(0x0UL);
652 - set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress));
653 +
654 + n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
655 + save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL);
656 +
657 + for (pgd = 0; pgd < n_pgds; pgd++) {
658 + save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
659 + vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
660 + set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
661 + }
662 __flush_tlb_all();
663 }
664
665 @@ -75,7 +83,11 @@ void __init efi_call_phys_epilog(void)
666 /*
667 * After the lock is released, the original page table is restored.
668 */
669 - set_pgd(pgd_offset_k(0x0UL), save_pgd);
670 + int pgd;
671 + int n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
672 + for (pgd = 0; pgd < n_pgds; pgd++)
673 + set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
674 + kfree(save_pgd);
675 __flush_tlb_all();
676 local_irq_restore(efi_flags);
677 early_code_mapping_set_exec(0);
678 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
679 index 9eaf708..251435a 100644
680 --- a/drivers/acpi/osl.c
681 +++ b/drivers/acpi/osl.c
682 @@ -250,7 +250,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
683 return acpi_rsdp;
684 #endif
685
686 - if (efi_enabled) {
687 + if (efi_enabled(EFI_CONFIG_TABLES)) {
688 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
689 return efi.acpi20;
690 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
691 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
692 index e164c55..1bfb207 100644
693 --- a/drivers/edac/edac_pci_sysfs.c
694 +++ b/drivers/edac/edac_pci_sysfs.c
695 @@ -256,7 +256,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
696 struct edac_pci_dev_attribute *edac_pci_dev;
697 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
698
699 - if (edac_pci_dev->show)
700 + if (edac_pci_dev->store)
701 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
702 return -EIO;
703 }
704 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
705 index fd3ae62..982f1f5 100644
706 --- a/drivers/firmware/dmi_scan.c
707 +++ b/drivers/firmware/dmi_scan.c
708 @@ -471,7 +471,7 @@ void __init dmi_scan_machine(void)
709 char __iomem *p, *q;
710 int rc;
711
712 - if (efi_enabled) {
713 + if (efi_enabled(EFI_CONFIG_TABLES)) {
714 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
715 goto error;
716
717 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
718 index d10c987..bfd8f43 100644
719 --- a/drivers/firmware/efivars.c
720 +++ b/drivers/firmware/efivars.c
721 @@ -1224,7 +1224,7 @@ efivars_init(void)
722 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
723 EFIVARS_DATE);
724
725 - if (!efi_enabled)
726 + if (!efi_enabled(EFI_RUNTIME_SERVICES))
727 return 0;
728
729 /* For now we'll register the efi directory at /sys/firmware/efi */
730 @@ -1262,7 +1262,7 @@ err_put:
731 static void __exit
732 efivars_exit(void)
733 {
734 - if (efi_enabled) {
735 + if (efi_enabled(EFI_RUNTIME_SERVICES)) {
736 unregister_efivars(&__efivars);
737 kobject_put(efi_kobj);
738 }
739 diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
740 index 4da4eb9..2224f1d 100644
741 --- a/drivers/firmware/iscsi_ibft_find.c
742 +++ b/drivers/firmware/iscsi_ibft_find.c
743 @@ -99,7 +99,7 @@ unsigned long __init find_ibft_region(unsigned long *sizep)
744 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
745 * only use ACPI for this */
746
747 - if (!efi_enabled)
748 + if (!efi_enabled(EFI_BOOT))
749 find_ibft_in_mem();
750
751 if (ibft_addr) {
752 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
753 index da21b11..3a1a495 100644
754 --- a/drivers/gpu/drm/i915/i915_debugfs.c
755 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
756 @@ -30,6 +30,7 @@
757 #include <linux/debugfs.h>
758 #include <linux/slab.h>
759 #include <linux/export.h>
760 +#include <generated/utsrelease.h>
761 #include <drm/drmP.h>
762 #include "intel_drv.h"
763 #include "intel_ringbuffer.h"
764 @@ -687,6 +688,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
765
766 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
767 error->time.tv_usec);
768 + seq_printf(m, "Kernel: " UTS_RELEASE);
769 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
770 seq_printf(m, "EIR: 0x%08x\n", error->eir);
771 seq_printf(m, "IER: 0x%08x\n", error->ier);
772 diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
773 index ecec134..3a43405 100644
774 --- a/drivers/gpu/drm/i915/i915_reg.h
775 +++ b/drivers/gpu/drm/i915/i915_reg.h
776 @@ -527,6 +527,7 @@
777 #define MI_MODE 0x0209c
778 # define VS_TIMER_DISPATCH (1 << 6)
779 # define MI_FLUSH_ENABLE (1 << 12)
780 +# define ASYNC_FLIP_PERF_DISABLE (1 << 14)
781
782 #define GEN6_GT_MODE 0x20d0
783 #define GEN6_GT_MODE_HI (1 << 9)
784 diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
785 index e87fa47..4e6a2b2 100644
786 --- a/drivers/gpu/drm/i915/intel_pm.c
787 +++ b/drivers/gpu/drm/i915/intel_pm.c
788 @@ -4018,7 +4018,8 @@ static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
789 DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
790
791 I915_WRITE_NOTRACE(FORCEWAKE, 1);
792 - POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
793 + /* something from same cacheline, but !FORCEWAKE */
794 + POSTING_READ(ECOBUS);
795
796 if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1),
797 FORCEWAKE_ACK_TIMEOUT_MS))
798 @@ -4041,7 +4042,8 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)
799 DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
800
801 I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_ENABLE(1));
802 - POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
803 + /* something from same cacheline, but !FORCEWAKE */
804 + POSTING_READ(ECOBUS);
805
806 if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1),
807 FORCEWAKE_ACK_TIMEOUT_MS))
808 @@ -4078,14 +4080,16 @@ void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv)
809 static void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
810 {
811 I915_WRITE_NOTRACE(FORCEWAKE, 0);
812 - /* gen6_gt_check_fifodbg doubles as the POSTING_READ */
813 + /* something from same cacheline, but !FORCEWAKE */
814 + POSTING_READ(ECOBUS);
815 gen6_gt_check_fifodbg(dev_priv);
816 }
817
818 static void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv)
819 {
820 I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(1));
821 - /* gen6_gt_check_fifodbg doubles as the POSTING_READ */
822 + /* something from same cacheline, but !FORCEWAKE_MT */
823 + POSTING_READ(ECOBUS);
824 gen6_gt_check_fifodbg(dev_priv);
825 }
826
827 @@ -4140,7 +4144,8 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
828 static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
829 {
830 I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(1));
831 - /* The below doubles as a POSTING_READ */
832 + /* something from same cacheline, but !FORCEWAKE_VLV */
833 + POSTING_READ(FORCEWAKE_ACK_VLV);
834 gen6_gt_check_fifodbg(dev_priv);
835 }
836
837 diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
838 index ecbc5c5..4b33f2d 100644
839 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
840 +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
841 @@ -505,13 +505,25 @@ static int init_render_ring(struct intel_ring_buffer *ring)
842 struct drm_i915_private *dev_priv = dev->dev_private;
843 int ret = init_ring_common(ring);
844
845 - if (INTEL_INFO(dev)->gen > 3) {
846 + if (INTEL_INFO(dev)->gen > 3)
847 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH));
848 - if (IS_GEN7(dev))
849 - I915_WRITE(GFX_MODE_GEN7,
850 - _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) |
851 - _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
852 - }
853 +
854 + /* We need to disable the AsyncFlip performance optimisations in order
855 + * to use MI_WAIT_FOR_EVENT within the CS. It should already be
856 + * programmed to '1' on all products.
857 + */
858 + if (INTEL_INFO(dev)->gen >= 6)
859 + I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(ASYNC_FLIP_PERF_DISABLE));
860 +
861 + /* Required for the hardware to program scanline values for waiting */
862 + if (INTEL_INFO(dev)->gen == 6)
863 + I915_WRITE(GFX_MODE,
864 + _MASKED_BIT_ENABLE(GFX_TLB_INVALIDATE_ALWAYS));
865 +
866 + if (IS_GEN7(dev))
867 + I915_WRITE(GFX_MODE_GEN7,
868 + _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) |
869 + _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
870
871 if (INTEL_INFO(dev)->gen >= 5) {
872 ret = init_pipe_control(ring);
873 diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
874 index dc8d15a..e797080 100644
875 --- a/drivers/gpu/drm/radeon/radeon_cs.c
876 +++ b/drivers/gpu/drm/radeon/radeon_cs.c
877 @@ -271,8 +271,10 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
878 p->chunks[p->chunk_ib_idx].kpage[1] = kmalloc(PAGE_SIZE, GFP_KERNEL);
879 if (p->chunks[p->chunk_ib_idx].kpage[0] == NULL ||
880 p->chunks[p->chunk_ib_idx].kpage[1] == NULL) {
881 - kfree(p->chunks[i].kpage[0]);
882 - kfree(p->chunks[i].kpage[1]);
883 + kfree(p->chunks[p->chunk_ib_idx].kpage[0]);
884 + kfree(p->chunks[p->chunk_ib_idx].kpage[1]);
885 + p->chunks[p->chunk_ib_idx].kpage[0] = NULL;
886 + p->chunks[p->chunk_ib_idx].kpage[1] = NULL;
887 return -ENOMEM;
888 }
889 }
890 diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
891 index 0fe56c9..cd1f151 100644
892 --- a/drivers/gpu/drm/radeon/radeon_cursor.c
893 +++ b/drivers/gpu/drm/radeon/radeon_cursor.c
894 @@ -240,7 +240,8 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
895 y = 0;
896 }
897
898 - if (ASIC_IS_AVIVO(rdev)) {
899 + /* fixed on DCE6 and newer */
900 + if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
901 int i = 0;
902 struct drm_crtc *crtc_p;
903
904 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
905 index ad4c973..008d645 100644
906 --- a/drivers/gpu/drm/radeon/radeon_device.c
907 +++ b/drivers/gpu/drm/radeon/radeon_device.c
908 @@ -429,7 +429,8 @@ bool radeon_card_posted(struct radeon_device *rdev)
909 {
910 uint32_t reg;
911
912 - if (efi_enabled && rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
913 + if (efi_enabled(EFI_BOOT) &&
914 + rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
915 return false;
916
917 /* first check CRTCs */
918 diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
919 index 2bddddd..6477849 100644
920 --- a/drivers/gpu/drm/radeon/radeon_display.c
921 +++ b/drivers/gpu/drm/radeon/radeon_display.c
922 @@ -1118,7 +1118,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
923 if (ret) {
924 kfree(radeon_fb);
925 drm_gem_object_unreference_unlocked(obj);
926 - return NULL;
927 + return ERR_PTR(ret);
928 }
929
930 return &radeon_fb->base;
931 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
932 index 1ef9a9e..7a845c0 100644
933 --- a/drivers/hid/hid-ids.h
934 +++ b/drivers/hid/hid-ids.h
935 @@ -305,6 +305,9 @@
936 #define USB_VENDOR_ID_EZKEY 0x0518
937 #define USB_DEVICE_ID_BTC_8193 0x0002
938
939 +#define USB_VENDOR_ID_FORMOSA 0x147a
940 +#define USB_DEVICE_ID_FORMOSA_IR_RECEIVER 0xe03e
941 +
942 #define USB_VENDOR_ID_FREESCALE 0x15A2
943 #define USB_DEVICE_ID_FREESCALE_MX28 0x004F
944
945 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
946 index 0a1429f..29736e9 100644
947 --- a/drivers/hid/usbhid/hid-quirks.c
948 +++ b/drivers/hid/usbhid/hid-quirks.c
949 @@ -70,6 +70,7 @@ static const struct hid_blacklist {
950 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
951 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
952 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
953 + { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
954 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
955 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
956 { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS },
957 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
958 index 81837b0..faf10ba 100644
959 --- a/drivers/iommu/amd_iommu_init.c
960 +++ b/drivers/iommu/amd_iommu_init.c
961 @@ -975,6 +975,38 @@ static void __init free_iommu_all(void)
962 }
963
964 /*
965 + * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)
966 + * Workaround:
967 + * BIOS should disable L2B micellaneous clock gating by setting
968 + * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) = 1b
969 + */
970 +static void __init amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
971 +{
972 + u32 value;
973 +
974 + if ((boot_cpu_data.x86 != 0x15) ||
975 + (boot_cpu_data.x86_model < 0x10) ||
976 + (boot_cpu_data.x86_model > 0x1f))
977 + return;
978 +
979 + pci_write_config_dword(iommu->dev, 0xf0, 0x90);
980 + pci_read_config_dword(iommu->dev, 0xf4, &value);
981 +
982 + if (value & BIT(2))
983 + return;
984 +
985 + /* Select NB indirect register 0x90 and enable writing */
986 + pci_write_config_dword(iommu->dev, 0xf0, 0x90 | (1 << 8));
987 +
988 + pci_write_config_dword(iommu->dev, 0xf4, value | 0x4);
989 + pr_info("AMD-Vi: Applying erratum 746 workaround for IOMMU at %s\n",
990 + dev_name(&iommu->dev->dev));
991 +
992 + /* Clear the enable writing bit */
993 + pci_write_config_dword(iommu->dev, 0xf0, 0x90);
994 +}
995 +
996 +/*
997 * This function clues the initialization function for one IOMMU
998 * together and also allocates the command buffer and programs the
999 * hardware. It does NOT enable the IOMMU. This is done afterwards.
1000 @@ -1172,6 +1204,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1001 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
1002 }
1003
1004 + amd_iommu_erratum_746_workaround(iommu);
1005 +
1006 return pci_enable_device(iommu->dev);
1007 }
1008
1009 diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1010 index c2c07a4..be3d7dd 100644
1011 --- a/drivers/iommu/intel-iommu.c
1012 +++ b/drivers/iommu/intel-iommu.c
1013 @@ -4234,6 +4234,21 @@ static struct iommu_ops intel_iommu_ops = {
1014 .pgsize_bitmap = INTEL_IOMMU_PGSIZES,
1015 };
1016
1017 +static void __devinit quirk_iommu_g4x_gfx(struct pci_dev *dev)
1018 +{
1019 + /* G4x/GM45 integrated gfx dmar support is totally busted. */
1020 + printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
1021 + dmar_map_gfx = 0;
1022 +}
1023 +
1024 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_g4x_gfx);
1025 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_g4x_gfx);
1026 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e10, quirk_iommu_g4x_gfx);
1027 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e20, quirk_iommu_g4x_gfx);
1028 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_g4x_gfx);
1029 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_g4x_gfx);
1030 +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_g4x_gfx);
1031 +
1032 static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
1033 {
1034 /*
1035 @@ -4242,12 +4257,6 @@ static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
1036 */
1037 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
1038 rwbf_quirk = 1;
1039 -
1040 - /* https://bugzilla.redhat.com/show_bug.cgi?id=538163 */
1041 - if (dev->revision == 0x07) {
1042 - printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
1043 - dmar_map_gfx = 0;
1044 - }
1045 }
1046
1047 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
1048 diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
1049 index 45d94a7..3235723 100644
1050 --- a/drivers/md/dm-raid.c
1051 +++ b/drivers/md/dm-raid.c
1052 @@ -338,24 +338,22 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
1053 }
1054
1055 /*
1056 - * validate_rebuild_devices
1057 + * validate_raid_redundancy
1058 * @rs
1059 *
1060 - * Determine if the devices specified for rebuild can result in a valid
1061 - * usable array that is capable of rebuilding the given devices.
1062 + * Determine if there are enough devices in the array that haven't
1063 + * failed (or are being rebuilt) to form a usable array.
1064 *
1065 * Returns: 0 on success, -EINVAL on failure.
1066 */
1067 -static int validate_rebuild_devices(struct raid_set *rs)
1068 +static int validate_raid_redundancy(struct raid_set *rs)
1069 {
1070 unsigned i, rebuild_cnt = 0;
1071 unsigned rebuilds_per_group, copies, d;
1072
1073 - if (!(rs->print_flags & DMPF_REBUILD))
1074 - return 0;
1075 -
1076 for (i = 0; i < rs->md.raid_disks; i++)
1077 - if (!test_bit(In_sync, &rs->dev[i].rdev.flags))
1078 + if (!test_bit(In_sync, &rs->dev[i].rdev.flags) ||
1079 + !rs->dev[i].rdev.sb_page)
1080 rebuild_cnt++;
1081
1082 switch (rs->raid_type->level) {
1083 @@ -391,27 +389,24 @@ static int validate_rebuild_devices(struct raid_set *rs)
1084 * A A B B C
1085 * C D D E E
1086 */
1087 - rebuilds_per_group = 0;
1088 for (i = 0; i < rs->md.raid_disks * copies; i++) {
1089 + if (!(i % copies))
1090 + rebuilds_per_group = 0;
1091 d = i % rs->md.raid_disks;
1092 - if (!test_bit(In_sync, &rs->dev[d].rdev.flags) &&
1093 + if ((!rs->dev[d].rdev.sb_page ||
1094 + !test_bit(In_sync, &rs->dev[d].rdev.flags)) &&
1095 (++rebuilds_per_group >= copies))
1096 goto too_many;
1097 - if (!((i + 1) % copies))
1098 - rebuilds_per_group = 0;
1099 }
1100 break;
1101 default:
1102 - DMERR("The rebuild parameter is not supported for %s",
1103 - rs->raid_type->name);
1104 - rs->ti->error = "Rebuild not supported for this RAID type";
1105 - return -EINVAL;
1106 + if (rebuild_cnt)
1107 + return -EINVAL;
1108 }
1109
1110 return 0;
1111
1112 too_many:
1113 - rs->ti->error = "Too many rebuild devices specified";
1114 return -EINVAL;
1115 }
1116
1117 @@ -662,9 +657,6 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
1118 }
1119 rs->md.dev_sectors = sectors_per_dev;
1120
1121 - if (validate_rebuild_devices(rs))
1122 - return -EINVAL;
1123 -
1124 /* Assume there are no metadata devices until the drives are parsed */
1125 rs->md.persistent = 0;
1126 rs->md.external = 1;
1127 @@ -993,28 +985,10 @@ static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
1128 static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
1129 {
1130 int ret;
1131 - unsigned redundancy = 0;
1132 struct raid_dev *dev;
1133 struct md_rdev *rdev, *tmp, *freshest;
1134 struct mddev *mddev = &rs->md;
1135
1136 - switch (rs->raid_type->level) {
1137 - case 1:
1138 - redundancy = rs->md.raid_disks - 1;
1139 - break;
1140 - case 4:
1141 - case 5:
1142 - case 6:
1143 - redundancy = rs->raid_type->parity_devs;
1144 - break;
1145 - case 10:
1146 - redundancy = raid10_md_layout_to_copies(mddev->layout) - 1;
1147 - break;
1148 - default:
1149 - ti->error = "Unknown RAID type";
1150 - return -EINVAL;
1151 - }
1152 -
1153 freshest = NULL;
1154 rdev_for_each_safe(rdev, tmp, mddev) {
1155 /*
1156 @@ -1043,44 +1017,43 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
1157 break;
1158 default:
1159 dev = container_of(rdev, struct raid_dev, rdev);
1160 - if (redundancy--) {
1161 - if (dev->meta_dev)
1162 - dm_put_device(ti, dev->meta_dev);
1163 -
1164 - dev->meta_dev = NULL;
1165 - rdev->meta_bdev = NULL;
1166 + if (dev->meta_dev)
1167 + dm_put_device(ti, dev->meta_dev);
1168
1169 - if (rdev->sb_page)
1170 - put_page(rdev->sb_page);
1171 + dev->meta_dev = NULL;
1172 + rdev->meta_bdev = NULL;
1173
1174 - rdev->sb_page = NULL;
1175 + if (rdev->sb_page)
1176 + put_page(rdev->sb_page);
1177
1178 - rdev->sb_loaded = 0;
1179 + rdev->sb_page = NULL;
1180
1181 - /*
1182 - * We might be able to salvage the data device
1183 - * even though the meta device has failed. For
1184 - * now, we behave as though '- -' had been
1185 - * set for this device in the table.
1186 - */
1187 - if (dev->data_dev)
1188 - dm_put_device(ti, dev->data_dev);
1189 + rdev->sb_loaded = 0;
1190
1191 - dev->data_dev = NULL;
1192 - rdev->bdev = NULL;
1193 + /*
1194 + * We might be able to salvage the data device
1195 + * even though the meta device has failed. For
1196 + * now, we behave as though '- -' had been
1197 + * set for this device in the table.
1198 + */
1199 + if (dev->data_dev)
1200 + dm_put_device(ti, dev->data_dev);
1201
1202 - list_del(&rdev->same_set);
1203 + dev->data_dev = NULL;
1204 + rdev->bdev = NULL;
1205
1206 - continue;
1207 - }
1208 - ti->error = "Failed to load superblock";
1209 - return ret;
1210 + list_del(&rdev->same_set);
1211 }
1212 }
1213
1214 if (!freshest)
1215 return 0;
1216
1217 + if (validate_raid_redundancy(rs)) {
1218 + rs->ti->error = "Insufficient redundancy to activate array";
1219 + return -EINVAL;
1220 + }
1221 +
1222 /*
1223 * Validation of the freshest device provides the source of
1224 * validation for the remaining devices.
1225 @@ -1430,7 +1403,7 @@ static void raid_resume(struct dm_target *ti)
1226
1227 static struct target_type raid_target = {
1228 .name = "raid",
1229 - .version = {1, 3, 1},
1230 + .version = {1, 3, 2},
1231 .module = THIS_MODULE,
1232 .ctr = raid_ctr,
1233 .dtr = raid_dtr,
1234 diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
1235 index 8f4c853..4678156 100644
1236 --- a/drivers/mfd/tc3589x.c
1237 +++ b/drivers/mfd/tc3589x.c
1238 @@ -219,25 +219,18 @@ static void tc3589x_irq_unmap(struct irq_domain *d, unsigned int virq)
1239 }
1240
1241 static struct irq_domain_ops tc3589x_irq_ops = {
1242 - .map = tc3589x_irq_map,
1243 + .map = tc3589x_irq_map,
1244 .unmap = tc3589x_irq_unmap,
1245 - .xlate = irq_domain_xlate_twocell,
1246 + .xlate = irq_domain_xlate_twocell,
1247 };
1248
1249 static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np)
1250 {
1251 int base = tc3589x->irq_base;
1252
1253 - if (base) {
1254 - tc3589x->domain = irq_domain_add_legacy(
1255 - NULL, TC3589x_NR_INTERNAL_IRQS, base,
1256 - 0, &tc3589x_irq_ops, tc3589x);
1257 - }
1258 - else {
1259 - tc3589x->domain = irq_domain_add_linear(
1260 - np, TC3589x_NR_INTERNAL_IRQS,
1261 - &tc3589x_irq_ops, tc3589x);
1262 - }
1263 + tc3589x->domain = irq_domain_add_simple(
1264 + np, TC3589x_NR_INTERNAL_IRQS, base,
1265 + &tc3589x_irq_ops, tc3589x);
1266
1267 if (!tc3589x->domain) {
1268 dev_err(tc3589x->dev, "Failed to create irqdomain\n");
1269 diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
1270 index e5180df..3391bdd 100644
1271 --- a/drivers/net/can/c_can/c_can.c
1272 +++ b/drivers/net/can/c_can/c_can.c
1273 @@ -954,7 +954,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
1274 break;
1275 case LEC_ACK_ERROR:
1276 netdev_dbg(dev, "ack error\n");
1277 - cf->data[2] |= (CAN_ERR_PROT_LOC_ACK |
1278 + cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
1279 CAN_ERR_PROT_LOC_ACK_DEL);
1280 break;
1281 case LEC_BIT1_ERROR:
1282 @@ -967,7 +967,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
1283 break;
1284 case LEC_CRC_ERROR:
1285 netdev_dbg(dev, "CRC error\n");
1286 - cf->data[2] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
1287 + cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
1288 CAN_ERR_PROT_LOC_CRC_DEL);
1289 break;
1290 default:
1291 diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
1292 index 48b3d62..7a43d4d 100644
1293 --- a/drivers/net/can/pch_can.c
1294 +++ b/drivers/net/can/pch_can.c
1295 @@ -560,7 +560,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
1296 stats->rx_errors++;
1297 break;
1298 case PCH_CRC_ERR:
1299 - cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
1300 + cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
1301 CAN_ERR_PROT_LOC_CRC_DEL;
1302 priv->can.can_stats.bus_error++;
1303 stats->rx_errors++;
1304 diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
1305 index 9ded21e..44996a9 100644
1306 --- a/drivers/net/can/ti_hecc.c
1307 +++ b/drivers/net/can/ti_hecc.c
1308 @@ -746,12 +746,12 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
1309 }
1310 if (err_status & HECC_CANES_CRCE) {
1311 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
1312 - cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
1313 + cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
1314 CAN_ERR_PROT_LOC_CRC_DEL;
1315 }
1316 if (err_status & HECC_CANES_ACKE) {
1317 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
1318 - cf->data[2] |= CAN_ERR_PROT_LOC_ACK |
1319 + cf->data[3] |= CAN_ERR_PROT_LOC_ACK |
1320 CAN_ERR_PROT_LOC_ACK_DEL;
1321 }
1322 }
1323 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1324 index 759f5f5..8a38ff2 100644
1325 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1326 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1327 @@ -588,30 +588,17 @@ static void ar9003_hw_init_bb(struct ath_hw *ah,
1328
1329 static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
1330 {
1331 - switch (rx) {
1332 - case 0x5:
1333 + if (ah->caps.tx_chainmask == 5 || ah->caps.rx_chainmask == 5)
1334 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
1335 AR_PHY_SWAP_ALT_CHAIN);
1336 - case 0x3:
1337 - case 0x1:
1338 - case 0x2:
1339 - case 0x7:
1340 - REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
1341 - REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
1342 - break;
1343 - default:
1344 - break;
1345 - }
1346 +
1347 + REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
1348 + REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
1349
1350 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && (tx == 0x7))
1351 - REG_WRITE(ah, AR_SELFGEN_MASK, 0x3);
1352 - else
1353 - REG_WRITE(ah, AR_SELFGEN_MASK, tx);
1354 + tx = 3;
1355
1356 - if (tx == 0x5) {
1357 - REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
1358 - AR_PHY_SWAP_ALT_CHAIN);
1359 - }
1360 + REG_WRITE(ah, AR_SELFGEN_MASK, tx);
1361 }
1362
1363 /*
1364 diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
1365 index dfe6a47..d7897dcf 100644
1366 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1367 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1368 @@ -315,7 +315,6 @@ struct ath_rx {
1369 u32 *rxlink;
1370 u32 num_pkts;
1371 unsigned int rxfilter;
1372 - spinlock_t rxbuflock;
1373 struct list_head rxbuf;
1374 struct ath_descdma rxdma;
1375 struct ath_buf *rx_bufptr;
1376 @@ -326,7 +325,6 @@ struct ath_rx {
1377
1378 int ath_startrecv(struct ath_softc *sc);
1379 bool ath_stoprecv(struct ath_softc *sc);
1380 -void ath_flushrecv(struct ath_softc *sc);
1381 u32 ath_calcrxfilter(struct ath_softc *sc);
1382 int ath_rx_init(struct ath_softc *sc, int nbufs);
1383 void ath_rx_cleanup(struct ath_softc *sc);
1384 @@ -630,7 +628,6 @@ void ath_ant_comb_update(struct ath_softc *sc);
1385 enum sc_op_flags {
1386 SC_OP_INVALID,
1387 SC_OP_BEACONS,
1388 - SC_OP_RXFLUSH,
1389 SC_OP_ANI_RUN,
1390 SC_OP_PRIM_STA_VIF,
1391 SC_OP_HW_RESET,
1392 diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
1393 index 1b48414..4b2dabf 100644
1394 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1395 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1396 @@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
1397 skb->len, DMA_TO_DEVICE);
1398 dev_kfree_skb_any(skb);
1399 bf->bf_buf_addr = 0;
1400 + bf->bf_mpdu = NULL;
1401 }
1402
1403 skb = ieee80211_beacon_get(hw, vif);
1404 @@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long data)
1405 return;
1406
1407 bf = ath9k_beacon_generate(sc->hw, vif);
1408 - WARN_ON(!bf);
1409
1410 if (sc->beacon.bmisscnt != 0) {
1411 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
1412 diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
1413 index 6727b56..774e95b 100644
1414 --- a/drivers/net/wireless/ath/ath9k/debug.c
1415 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1416 @@ -973,7 +973,6 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
1417 RXS_ERR("RX-LENGTH-ERR", rx_len_err);
1418 RXS_ERR("RX-OOM-ERR", rx_oom_err);
1419 RXS_ERR("RX-RATE-ERR", rx_rate_err);
1420 - RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
1421 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
1422
1423 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
1424 diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
1425 index 2ed9785..b9d95c7 100644
1426 --- a/drivers/net/wireless/ath/ath9k/debug.h
1427 +++ b/drivers/net/wireless/ath/ath9k/debug.h
1428 @@ -200,7 +200,6 @@ struct ath_tx_stats {
1429 * @rx_oom_err: No. of frames dropped due to OOM issues.
1430 * @rx_rate_err: No. of frames dropped due to rate errors.
1431 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received.
1432 - * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
1433 * @rx_beacons: No. of beacons received.
1434 * @rx_frags: No. of rx-fragements received.
1435 */
1436 @@ -219,7 +218,6 @@ struct ath_rx_stats {
1437 u32 rx_oom_err;
1438 u32 rx_rate_err;
1439 u32 rx_too_many_frags_err;
1440 - u32 rx_drop_rxflush;
1441 u32 rx_beacons;
1442 u32 rx_frags;
1443 };
1444 diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
1445 index 4a9570d..aac4a40 100644
1446 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c
1447 +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
1448 @@ -344,6 +344,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
1449 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv,
1450 skb, htc_hdr->endpoint_id,
1451 txok);
1452 + } else {
1453 + kfree_skb(skb);
1454 }
1455 }
1456
1457 diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
1458 index dd45edf..6962c8a 100644
1459 --- a/drivers/net/wireless/ath/ath9k/main.c
1460 +++ b/drivers/net/wireless/ath/ath9k/main.c
1461 @@ -181,7 +181,7 @@ static void ath_restart_work(struct ath_softc *sc)
1462 ath_start_ani(sc);
1463 }
1464
1465 -static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
1466 +static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
1467 {
1468 struct ath_hw *ah = sc->sc_ah;
1469 bool ret = true;
1470 @@ -201,14 +201,6 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
1471 if (!ath_drain_all_txq(sc, retry_tx))
1472 ret = false;
1473
1474 - if (!flush) {
1475 - if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1476 - ath_rx_tasklet(sc, 1, true);
1477 - ath_rx_tasklet(sc, 1, false);
1478 - } else {
1479 - ath_flushrecv(sc);
1480 - }
1481 -
1482 return ret;
1483 }
1484
1485 @@ -261,11 +253,11 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
1486 struct ath_common *common = ath9k_hw_common(ah);
1487 struct ath9k_hw_cal_data *caldata = NULL;
1488 bool fastcc = true;
1489 - bool flush = false;
1490 int r;
1491
1492 __ath_cancel_work(sc);
1493
1494 + tasklet_disable(&sc->intr_tq);
1495 spin_lock_bh(&sc->sc_pcu_lock);
1496
1497 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
1498 @@ -275,11 +267,10 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
1499
1500 if (!hchan) {
1501 fastcc = false;
1502 - flush = true;
1503 hchan = ah->curchan;
1504 }
1505
1506 - if (!ath_prepare_reset(sc, retry_tx, flush))
1507 + if (!ath_prepare_reset(sc, retry_tx))
1508 fastcc = false;
1509
1510 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
1511 @@ -297,6 +288,8 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
1512
1513 out:
1514 spin_unlock_bh(&sc->sc_pcu_lock);
1515 + tasklet_enable(&sc->intr_tq);
1516 +
1517 return r;
1518 }
1519
1520 @@ -816,7 +809,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1521 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
1522 }
1523
1524 - ath_prepare_reset(sc, false, true);
1525 + ath_prepare_reset(sc, false);
1526
1527 if (sc->rx.frag) {
1528 dev_kfree_skb_any(sc->rx.frag);
1529 @@ -1837,6 +1830,9 @@ static u32 fill_chainmask(u32 cap, u32 new)
1530
1531 static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
1532 {
1533 + if (AR_SREV_9300_20_OR_LATER(ah))
1534 + return true;
1535 +
1536 switch (val & 0x7) {
1537 case 0x1:
1538 case 0x3:
1539 diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
1540 index 83d16e7..4919d68 100644
1541 --- a/drivers/net/wireless/ath/ath9k/recv.c
1542 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1543 @@ -254,8 +254,6 @@ rx_init_fail:
1544
1545 static void ath_edma_start_recv(struct ath_softc *sc)
1546 {
1547 - spin_lock_bh(&sc->rx.rxbuflock);
1548 -
1549 ath9k_hw_rxena(sc->sc_ah);
1550
1551 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP,
1552 @@ -267,8 +265,6 @@ static void ath_edma_start_recv(struct ath_softc *sc)
1553 ath_opmode_init(sc);
1554
1555 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
1556 -
1557 - spin_unlock_bh(&sc->rx.rxbuflock);
1558 }
1559
1560 static void ath_edma_stop_recv(struct ath_softc *sc)
1561 @@ -285,8 +281,6 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
1562 int error = 0;
1563
1564 spin_lock_init(&sc->sc_pcu_lock);
1565 - spin_lock_init(&sc->rx.rxbuflock);
1566 - clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
1567
1568 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
1569 sc->sc_ah->caps.rx_status_len;
1570 @@ -447,7 +441,6 @@ int ath_startrecv(struct ath_softc *sc)
1571 return 0;
1572 }
1573
1574 - spin_lock_bh(&sc->rx.rxbuflock);
1575 if (list_empty(&sc->rx.rxbuf))
1576 goto start_recv;
1577
1578 @@ -468,26 +461,31 @@ start_recv:
1579 ath_opmode_init(sc);
1580 ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
1581
1582 - spin_unlock_bh(&sc->rx.rxbuflock);
1583 -
1584 return 0;
1585 }
1586
1587 +static void ath_flushrecv(struct ath_softc *sc)
1588 +{
1589 + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1590 + ath_rx_tasklet(sc, 1, true);
1591 + ath_rx_tasklet(sc, 1, false);
1592 +}
1593 +
1594 bool ath_stoprecv(struct ath_softc *sc)
1595 {
1596 struct ath_hw *ah = sc->sc_ah;
1597 bool stopped, reset = false;
1598
1599 - spin_lock_bh(&sc->rx.rxbuflock);
1600 ath9k_hw_abortpcurecv(ah);
1601 ath9k_hw_setrxfilter(ah, 0);
1602 stopped = ath9k_hw_stopdmarecv(ah, &reset);
1603
1604 + ath_flushrecv(sc);
1605 +
1606 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1607 ath_edma_stop_recv(sc);
1608 else
1609 sc->rx.rxlink = NULL;
1610 - spin_unlock_bh(&sc->rx.rxbuflock);
1611
1612 if (!(ah->ah_flags & AH_UNPLUGGED) &&
1613 unlikely(!stopped)) {
1614 @@ -499,15 +497,6 @@ bool ath_stoprecv(struct ath_softc *sc)
1615 return stopped && !reset;
1616 }
1617
1618 -void ath_flushrecv(struct ath_softc *sc)
1619 -{
1620 - set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
1621 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1622 - ath_rx_tasklet(sc, 1, true);
1623 - ath_rx_tasklet(sc, 1, false);
1624 - clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
1625 -}
1626 -
1627 static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
1628 {
1629 /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
1630 @@ -744,6 +733,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
1631 return NULL;
1632 }
1633
1634 + list_del(&bf->list);
1635 if (!bf->bf_mpdu)
1636 return bf;
1637
1638 @@ -1059,16 +1049,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1639 dma_type = DMA_FROM_DEVICE;
1640
1641 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
1642 - spin_lock_bh(&sc->rx.rxbuflock);
1643
1644 tsf = ath9k_hw_gettsf64(ah);
1645 tsf_lower = tsf & 0xffffffff;
1646
1647 do {
1648 bool decrypt_error = false;
1649 - /* If handling rx interrupt and flush is in progress => exit */
1650 - if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
1651 - break;
1652
1653 memset(&rs, 0, sizeof(rs));
1654 if (edma)
1655 @@ -1108,15 +1094,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1656 sc->rx.num_pkts++;
1657 ath_debug_stat_rx(sc, &rs);
1658
1659 - /*
1660 - * If we're asked to flush receive queue, directly
1661 - * chain it back at the queue without processing it.
1662 - */
1663 - if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
1664 - RX_STAT_INC(rx_drop_rxflush);
1665 - goto requeue_drop_frag;
1666 - }
1667 -
1668 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1669
1670 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1671 @@ -1251,19 +1228,18 @@ requeue_drop_frag:
1672 sc->rx.frag = NULL;
1673 }
1674 requeue:
1675 + list_add_tail(&bf->list, &sc->rx.rxbuf);
1676 + if (flush)
1677 + continue;
1678 +
1679 if (edma) {
1680 - list_add_tail(&bf->list, &sc->rx.rxbuf);
1681 ath_rx_edma_buf_link(sc, qtype);
1682 } else {
1683 - list_move_tail(&bf->list, &sc->rx.rxbuf);
1684 ath_rx_buf_link(sc, bf);
1685 - if (!flush)
1686 - ath9k_hw_rxena(ah);
1687 + ath9k_hw_rxena(ah);
1688 }
1689 } while (1);
1690
1691 - spin_unlock_bh(&sc->rx.rxbuflock);
1692 -
1693 if (!(ah->imask & ATH9K_INT_RXEOL)) {
1694 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
1695 ath9k_hw_set_interrupts(ah);
1696 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1697 index a744ea5..36014bf 100644
1698 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1699 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1700 @@ -280,8 +280,8 @@ static void brcms_ops_tx(struct ieee80211_hw *hw,
1701 kfree_skb(skb);
1702 goto done;
1703 }
1704 - brcms_c_sendpkt_mac80211(wl->wlc, skb, hw);
1705 - tx_info->rate_driver_data[0] = control->sta;
1706 + if (brcms_c_sendpkt_mac80211(wl->wlc, skb, hw))
1707 + tx_info->rate_driver_data[0] = control->sta;
1708 done:
1709 spin_unlock_bh(&wl->lock);
1710 }
1711 @@ -1401,9 +1401,10 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
1712 #endif
1713 t->ms = ms;
1714 t->periodic = (bool) periodic;
1715 - t->set = true;
1716 -
1717 - atomic_inc(&t->wl->callbacks);
1718 + if (!t->set) {
1719 + t->set = true;
1720 + atomic_inc(&t->wl->callbacks);
1721 + }
1722
1723 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
1724 }
1725 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
1726 index 75086b3..9fb0a4c9 100644
1727 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
1728 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
1729 @@ -6095,7 +6095,7 @@ static bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q,
1730 return brcms_c_prec_enq_head(wlc, q, pkt, prec, false);
1731 }
1732
1733 -void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
1734 +bool brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
1735 struct sk_buff *sdu, uint prec)
1736 {
1737 struct brcms_txq_info *qi = wlc->pkt_queue; /* Check me */
1738 @@ -6110,7 +6110,9 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
1739 * packet flooding from mac80211 stack
1740 */
1741 brcmu_pkt_buf_free_skb(sdu);
1742 + return false;
1743 }
1744 + return true;
1745 }
1746
1747 /*
1748 @@ -7273,7 +7275,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
1749 return 0;
1750 }
1751
1752 -void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
1753 +bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
1754 struct ieee80211_hw *hw)
1755 {
1756 u8 prio;
1757 @@ -7288,10 +7290,12 @@ void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
1758 prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority :
1759 MAXPRIO;
1760 fifo = prio2fifo[prio];
1761 - if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0))
1762 - return;
1763 - brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio));
1764 + brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0);
1765 + if (!brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)))
1766 + return false;
1767 brcms_c_send_q(wlc);
1768 +
1769 + return true;
1770 }
1771
1772 void brcms_c_send_q(struct brcms_c_info *wlc)
1773 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h
1774 index 8debc74..b44725c 100644
1775 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
1776 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
1777 @@ -642,7 +642,7 @@ extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo,
1778 bool commit, s8 txpktpend);
1779 extern void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo,
1780 s8 txpktpend);
1781 -extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
1782 +extern bool brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
1783 struct sk_buff *sdu, uint prec);
1784 extern void brcms_c_print_txstatus(struct tx_status *txs);
1785 extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
1786 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
1787 index 5855f4f..bfa2630 100644
1788 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
1789 +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
1790 @@ -321,7 +321,7 @@ extern void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
1791 extern bool brcms_c_intrsupd(struct brcms_c_info *wlc);
1792 extern bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc);
1793 extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
1794 -extern void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc,
1795 +extern bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc,
1796 struct sk_buff *sdu,
1797 struct ieee80211_hw *hw);
1798 extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
1799 diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
1800 index 318ed3c..617aeb9 100644
1801 --- a/drivers/net/wireless/iwlegacy/common.c
1802 +++ b/drivers/net/wireless/iwlegacy/common.c
1803 @@ -3957,17 +3957,21 @@ il_connection_init_rx_config(struct il_priv *il)
1804
1805 memset(&il->staging, 0, sizeof(il->staging));
1806
1807 - if (!il->vif) {
1808 + switch (il->iw_mode) {
1809 + case NL80211_IFTYPE_UNSPECIFIED:
1810 il->staging.dev_type = RXON_DEV_TYPE_ESS;
1811 - } else if (il->vif->type == NL80211_IFTYPE_STATION) {
1812 + break;
1813 + case NL80211_IFTYPE_STATION:
1814 il->staging.dev_type = RXON_DEV_TYPE_ESS;
1815 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
1816 - } else if (il->vif->type == NL80211_IFTYPE_ADHOC) {
1817 + break;
1818 + case NL80211_IFTYPE_ADHOC:
1819 il->staging.dev_type = RXON_DEV_TYPE_IBSS;
1820 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
1821 il->staging.filter_flags =
1822 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
1823 - } else {
1824 + break;
1825 + default:
1826 IL_ERR("Unsupported interface type %d\n", il->vif->type);
1827 return;
1828 }
1829 @@ -4550,8 +4554,7 @@ out:
1830 EXPORT_SYMBOL(il_mac_add_interface);
1831
1832 static void
1833 -il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
1834 - bool mode_change)
1835 +il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif)
1836 {
1837 lockdep_assert_held(&il->mutex);
1838
1839 @@ -4560,9 +4563,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
1840 il_force_scan_end(il);
1841 }
1842
1843 - if (!mode_change)
1844 - il_set_mode(il);
1845 -
1846 + il_set_mode(il);
1847 }
1848
1849 void
1850 @@ -4575,8 +4576,8 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1851
1852 WARN_ON(il->vif != vif);
1853 il->vif = NULL;
1854 -
1855 - il_teardown_interface(il, vif, false);
1856 + il->iw_mode = NL80211_IFTYPE_UNSPECIFIED;
1857 + il_teardown_interface(il, vif);
1858 memset(il->bssid, 0, ETH_ALEN);
1859
1860 D_MAC80211("leave\n");
1861 @@ -4685,18 +4686,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1862 }
1863
1864 /* success */
1865 - il_teardown_interface(il, vif, true);
1866 vif->type = newtype;
1867 vif->p2p = false;
1868 - err = il_set_mode(il);
1869 - WARN_ON(err);
1870 - /*
1871 - * We've switched internally, but submitting to the
1872 - * device may have failed for some reason. Mask this
1873 - * error, because otherwise mac80211 will not switch
1874 - * (and set the interface type back) and we'll be
1875 - * out of sync with it.
1876 - */
1877 + il->iw_mode = newtype;
1878 + il_teardown_interface(il, vif);
1879 err = 0;
1880
1881 out:
1882 diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
1883 index 780d3e1..f7e91f2 100644
1884 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1885 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1886 @@ -1462,7 +1462,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1887 struct cfg80211_ssid req_ssid;
1888 int ret, auth_type = 0;
1889 struct cfg80211_bss *bss = NULL;
1890 - u8 is_scanning_required = 0, config_bands = 0;
1891 + u8 is_scanning_required = 0;
1892
1893 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid));
1894
1895 @@ -1481,19 +1481,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1896 /* disconnect before try to associate */
1897 mwifiex_deauthenticate(priv, NULL);
1898
1899 - if (channel) {
1900 - if (mode == NL80211_IFTYPE_STATION) {
1901 - if (channel->band == IEEE80211_BAND_2GHZ)
1902 - config_bands = BAND_B | BAND_G | BAND_GN;
1903 - else
1904 - config_bands = BAND_A | BAND_AN;
1905 -
1906 - if (!((config_bands | priv->adapter->fw_bands) &
1907 - ~priv->adapter->fw_bands))
1908 - priv->adapter->config_bands = config_bands;
1909 - }
1910 - }
1911 -
1912 /* As this is new association, clear locally stored
1913 * keys and security related flags */
1914 priv->sec_info.wpa_enabled = false;
1915 diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
1916 index 13fbc4e..b879e13 100644
1917 --- a/drivers/net/wireless/mwifiex/pcie.c
1918 +++ b/drivers/net/wireless/mwifiex/pcie.c
1919 @@ -161,7 +161,7 @@ static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state)
1920
1921 if (pdev) {
1922 card = (struct pcie_service_card *) pci_get_drvdata(pdev);
1923 - if (!card || card->adapter) {
1924 + if (!card || !card->adapter) {
1925 pr_err("Card or adapter structure is not valid\n");
1926 return 0;
1927 }
1928 diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
1929 index 786bc11..f3211d8 100644
1930 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c
1931 +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
1932 @@ -265,6 +265,20 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1933 if (ret)
1934 goto done;
1935
1936 + if (bss_desc) {
1937 + u8 config_bands = 0;
1938 +
1939 + if (mwifiex_band_to_radio_type((u8) bss_desc->bss_band)
1940 + == HostCmd_SCAN_RADIO_TYPE_BG)
1941 + config_bands = BAND_B | BAND_G | BAND_GN;
1942 + else
1943 + config_bands = BAND_A | BAND_AN;
1944 +
1945 + if (!((config_bands | adapter->fw_bands) &
1946 + ~adapter->fw_bands))
1947 + adapter->config_bands = config_bands;
1948 + }
1949 +
1950 ret = mwifiex_check_network_compatibility(priv, bss_desc);
1951 if (ret)
1952 goto done;
1953 diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
1954 index 7481146..97c2be1 100644
1955 --- a/drivers/platform/x86/ibm_rtl.c
1956 +++ b/drivers/platform/x86/ibm_rtl.c
1957 @@ -244,7 +244,7 @@ static int __init ibm_rtl_init(void) {
1958 if (force)
1959 pr_warn("module loaded by force\n");
1960 /* first ensure that we are running on IBM HW */
1961 - else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table))
1962 + else if (efi_enabled(EFI_BOOT) || !dmi_check_system(ibm_rtl_dmi_table))
1963 return -ENODEV;
1964
1965 /* Get the address for the Extended BIOS Data Area */
1966 diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
1967 index 71623a2..d1f0300 100644
1968 --- a/drivers/platform/x86/samsung-laptop.c
1969 +++ b/drivers/platform/x86/samsung-laptop.c
1970 @@ -26,6 +26,7 @@
1971 #include <linux/seq_file.h>
1972 #include <linux/debugfs.h>
1973 #include <linux/ctype.h>
1974 +#include <linux/efi.h>
1975 #include <acpi/video.h>
1976
1977 /*
1978 @@ -1544,6 +1545,9 @@ static int __init samsung_init(void)
1979 struct samsung_laptop *samsung;
1980 int ret;
1981
1982 + if (efi_enabled(EFI_BOOT))
1983 + return -ENODEV;
1984 +
1985 quirks = &samsung_unknown;
1986 if (!force && !dmi_check_system(samsung_dmi_table))
1987 return -ENODEV;
1988 diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
1989 index b74050b..9ac1e9d 100644
1990 --- a/drivers/scsi/isci/init.c
1991 +++ b/drivers/scsi/isci/init.c
1992 @@ -633,7 +633,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
1993 return -ENOMEM;
1994 pci_set_drvdata(pdev, pci_info);
1995
1996 - if (efi_enabled)
1997 + if (efi_enabled(EFI_RUNTIME_SERVICES))
1998 orom = isci_get_efi_var(pdev);
1999
2000 if (!orom)
2001 diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
2002 index a55f91a..9430cd2 100644
2003 --- a/drivers/target/target_core_fabric_configfs.c
2004 +++ b/drivers/target/target_core_fabric_configfs.c
2005 @@ -751,12 +751,6 @@ static int target_fabric_port_link(
2006 struct target_fabric_configfs *tf;
2007 int ret;
2008
2009 - if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
2010 - pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
2011 - " %p to struct se_device: %p\n", se_dev_ci, dev);
2012 - return -EFAULT;
2013 - }
2014 -
2015 tpg_ci = &lun_ci->ci_parent->ci_group->cg_item;
2016 se_tpg = container_of(to_config_group(tpg_ci),
2017 struct se_portal_group, tpg_group);
2018 @@ -774,6 +768,11 @@ static int target_fabric_port_link(
2019 ret = -ENODEV;
2020 goto out;
2021 }
2022 + if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
2023 + pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
2024 + " %p to struct se_device: %p\n", se_dev_ci, dev);
2025 + return -EFAULT;
2026 + }
2027
2028 lun_p = core_dev_add_lun(se_tpg, dev, lun->unpacked_lun);
2029 if (IS_ERR(lun_p)) {
2030 diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
2031 index ce5cbd7..210fce2 100644
2032 --- a/fs/cifs/cifs_dfs_ref.c
2033 +++ b/fs/cifs/cifs_dfs_ref.c
2034 @@ -226,6 +226,8 @@ compose_mount_options_out:
2035 compose_mount_options_err:
2036 kfree(mountdata);
2037 mountdata = ERR_PTR(rc);
2038 + kfree(*devname);
2039 + *devname = NULL;
2040 goto compose_mount_options_out;
2041 }
2042
2043 diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
2044 index dd057bc..fc8dc20 100644
2045 --- a/fs/nfs/namespace.c
2046 +++ b/fs/nfs/namespace.c
2047 @@ -177,11 +177,31 @@ out_nofree:
2048 return mnt;
2049 }
2050
2051 +static int
2052 +nfs_namespace_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
2053 +{
2054 + if (NFS_FH(dentry->d_inode)->size != 0)
2055 + return nfs_getattr(mnt, dentry, stat);
2056 + generic_fillattr(dentry->d_inode, stat);
2057 + return 0;
2058 +}
2059 +
2060 +static int
2061 +nfs_namespace_setattr(struct dentry *dentry, struct iattr *attr)
2062 +{
2063 + if (NFS_FH(dentry->d_inode)->size != 0)
2064 + return nfs_setattr(dentry, attr);
2065 + return -EACCES;
2066 +}
2067 +
2068 const struct inode_operations nfs_mountpoint_inode_operations = {
2069 .getattr = nfs_getattr,
2070 + .setattr = nfs_setattr,
2071 };
2072
2073 const struct inode_operations nfs_referral_inode_operations = {
2074 + .getattr = nfs_namespace_getattr,
2075 + .setattr = nfs_namespace_setattr,
2076 };
2077
2078 static void nfs_expire_automounts(struct work_struct *work)
2079 diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
2080 index 6bacfde..1f55131 100644
2081 --- a/fs/nfs/nfs4client.c
2082 +++ b/fs/nfs/nfs4client.c
2083 @@ -235,11 +235,10 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
2084 error = nfs4_discover_server_trunking(clp, &old);
2085 if (error < 0)
2086 goto error;
2087 + nfs_put_client(clp);
2088 if (clp != old) {
2089 clp->cl_preserve_clid = true;
2090 - nfs_put_client(clp);
2091 clp = old;
2092 - atomic_inc(&clp->cl_count);
2093 }
2094
2095 return clp;
2096 @@ -305,7 +304,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
2097 .clientid = new->cl_clientid,
2098 .confirm = new->cl_confirm,
2099 };
2100 - int status;
2101 + int status = -NFS4ERR_STALE_CLIENTID;
2102
2103 spin_lock(&nn->nfs_client_lock);
2104 list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
2105 @@ -331,40 +330,33 @@ int nfs40_walk_client_list(struct nfs_client *new,
2106
2107 if (prev)
2108 nfs_put_client(prev);
2109 + prev = pos;
2110
2111 status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
2112 - if (status == 0) {
2113 + switch (status) {
2114 + case -NFS4ERR_STALE_CLIENTID:
2115 + break;
2116 + case 0:
2117 nfs4_swap_callback_idents(pos, new);
2118
2119 - nfs_put_client(pos);
2120 + prev = NULL;
2121 *result = pos;
2122 dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n",
2123 __func__, pos, atomic_read(&pos->cl_count));
2124 - return 0;
2125 - }
2126 - if (status != -NFS4ERR_STALE_CLIENTID) {
2127 - nfs_put_client(pos);
2128 - dprintk("NFS: <-- %s status = %d, no result\n",
2129 - __func__, status);
2130 - return status;
2131 + default:
2132 + goto out;
2133 }
2134
2135 spin_lock(&nn->nfs_client_lock);
2136 - prev = pos;
2137 }
2138 + spin_unlock(&nn->nfs_client_lock);
2139
2140 - /*
2141 - * No matching nfs_client found. This should be impossible,
2142 - * because the new nfs_client has already been added to
2143 - * nfs_client_list by nfs_get_client().
2144 - *
2145 - * Don't BUG(), since the caller is holding a mutex.
2146 - */
2147 + /* No match found. The server lost our clientid */
2148 +out:
2149 if (prev)
2150 nfs_put_client(prev);
2151 - spin_unlock(&nn->nfs_client_lock);
2152 - pr_err("NFS: %s Error: no matching nfs_client found\n", __func__);
2153 - return -NFS4ERR_STALE_CLIENTID;
2154 + dprintk("NFS: <-- %s status = %d\n", __func__, status);
2155 + return status;
2156 }
2157
2158 #ifdef CONFIG_NFS_V4_1
2159 @@ -431,7 +423,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
2160 {
2161 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
2162 struct nfs_client *pos, *n, *prev = NULL;
2163 - int error;
2164 + int status = -NFS4ERR_STALE_CLIENTID;
2165
2166 spin_lock(&nn->nfs_client_lock);
2167 list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
2168 @@ -447,14 +439,17 @@ int nfs41_walk_client_list(struct nfs_client *new,
2169 nfs_put_client(prev);
2170 prev = pos;
2171
2172 - error = nfs_wait_client_init_complete(pos);
2173 - if (error < 0) {
2174 + nfs4_schedule_lease_recovery(pos);
2175 + status = nfs_wait_client_init_complete(pos);
2176 + if (status < 0) {
2177 nfs_put_client(pos);
2178 spin_lock(&nn->nfs_client_lock);
2179 continue;
2180 }
2181 -
2182 + status = pos->cl_cons_state;
2183 spin_lock(&nn->nfs_client_lock);
2184 + if (status < 0)
2185 + continue;
2186 }
2187
2188 if (pos->rpc_ops != new->rpc_ops)
2189 @@ -472,6 +467,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
2190 if (!nfs4_match_serverowners(pos, new))
2191 continue;
2192
2193 + atomic_inc(&pos->cl_count);
2194 spin_unlock(&nn->nfs_client_lock);
2195 dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n",
2196 __func__, pos, atomic_read(&pos->cl_count));
2197 @@ -480,16 +476,10 @@ int nfs41_walk_client_list(struct nfs_client *new,
2198 return 0;
2199 }
2200
2201 - /*
2202 - * No matching nfs_client found. This should be impossible,
2203 - * because the new nfs_client has already been added to
2204 - * nfs_client_list by nfs_get_client().
2205 - *
2206 - * Don't BUG(), since the caller is holding a mutex.
2207 - */
2208 + /* No matching nfs_client found. */
2209 spin_unlock(&nn->nfs_client_lock);
2210 - pr_err("NFS: %s Error: no matching nfs_client found\n", __func__);
2211 - return -NFS4ERR_STALE_CLIENTID;
2212 + dprintk("NFS: <-- %s status = %d\n", __func__, status);
2213 + return status;
2214 }
2215 #endif /* CONFIG_NFS_V4_1 */
2216
2217 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
2218 index c351e6b..b1c96e7 100644
2219 --- a/fs/nfs/nfs4state.c
2220 +++ b/fs/nfs/nfs4state.c
2221 @@ -136,16 +136,11 @@ int nfs40_discover_server_trunking(struct nfs_client *clp,
2222 clp->cl_confirm = clid.confirm;
2223
2224 status = nfs40_walk_client_list(clp, result, cred);
2225 - switch (status) {
2226 - case -NFS4ERR_STALE_CLIENTID:
2227 - set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
2228 - case 0:
2229 + if (status == 0) {
2230 /* Sustain the lease, even if it's empty. If the clientid4
2231 * goes stale it's of no use for trunking discovery. */
2232 nfs4_schedule_state_renewal(*result);
2233 - break;
2234 }
2235 -
2236 out:
2237 return status;
2238 }
2239 @@ -1850,6 +1845,7 @@ again:
2240 case -ETIMEDOUT:
2241 case -EAGAIN:
2242 ssleep(1);
2243 + case -NFS4ERR_STALE_CLIENTID:
2244 dprintk("NFS: %s after status %d, retrying\n",
2245 __func__, status);
2246 goto again;
2247 @@ -2001,8 +1997,18 @@ static int nfs4_reset_session(struct nfs_client *clp)
2248 nfs4_begin_drain_session(clp);
2249 cred = nfs4_get_exchange_id_cred(clp);
2250 status = nfs4_proc_destroy_session(clp->cl_session, cred);
2251 - if (status && status != -NFS4ERR_BADSESSION &&
2252 - status != -NFS4ERR_DEADSESSION) {
2253 + switch (status) {
2254 + case 0:
2255 + case -NFS4ERR_BADSESSION:
2256 + case -NFS4ERR_DEADSESSION:
2257 + break;
2258 + case -NFS4ERR_BACK_CHAN_BUSY:
2259 + case -NFS4ERR_DELAY:
2260 + set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
2261 + status = 0;
2262 + ssleep(1);
2263 + goto out;
2264 + default:
2265 status = nfs4_recovery_handle_error(clp, status);
2266 goto out;
2267 }
2268 diff --git a/fs/nfs/super.c b/fs/nfs/super.c
2269 index 00be08f..49f3f90 100644
2270 --- a/fs/nfs/super.c
2271 +++ b/fs/nfs/super.c
2272 @@ -2576,27 +2576,23 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
2273 struct nfs_server *server;
2274 struct dentry *mntroot = ERR_PTR(-ENOMEM);
2275 struct nfs_subversion *nfs_mod = NFS_SB(data->sb)->nfs_client->cl_nfs_mod;
2276 - int error;
2277
2278 - dprintk("--> nfs_xdev_mount_common()\n");
2279 + dprintk("--> nfs_xdev_mount()\n");
2280
2281 mount_info.mntfh = mount_info.cloned->fh;
2282
2283 /* create a new volume representation */
2284 server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
2285 - if (IS_ERR(server)) {
2286 - error = PTR_ERR(server);
2287 - goto out_err;
2288 - }
2289
2290 - mntroot = nfs_fs_mount_common(server, flags, dev_name, &mount_info, nfs_mod);
2291 - dprintk("<-- nfs_xdev_mount_common() = 0\n");
2292 -out:
2293 - return mntroot;
2294 + if (IS_ERR(server))
2295 + mntroot = ERR_CAST(server);
2296 + else
2297 + mntroot = nfs_fs_mount_common(server, flags,
2298 + dev_name, &mount_info, nfs_mod);
2299
2300 -out_err:
2301 - dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error);
2302 - goto out;
2303 + dprintk("<-- nfs_xdev_mount() = %ld\n",
2304 + IS_ERR(mntroot) ? PTR_ERR(mntroot) : 0L);
2305 + return mntroot;
2306 }
2307
2308 #if IS_ENABLED(CONFIG_NFS_V4)
2309 diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
2310 index e0e9ee0..dfbcfd0 100644
2311 --- a/fs/xfs/xfs_aops.c
2312 +++ b/fs/xfs/xfs_aops.c
2313 @@ -86,11 +86,11 @@ xfs_destroy_ioend(
2314 }
2315
2316 if (ioend->io_iocb) {
2317 + inode_dio_done(ioend->io_inode);
2318 if (ioend->io_isasync) {
2319 aio_complete(ioend->io_iocb, ioend->io_error ?
2320 ioend->io_error : ioend->io_result, 0);
2321 }
2322 - inode_dio_done(ioend->io_inode);
2323 }
2324
2325 mempool_free(ioend, xfs_ioend_pool);
2326 diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
2327 index 4b0b8dd..58a1f41 100644
2328 --- a/fs/xfs/xfs_buf.c
2329 +++ b/fs/xfs/xfs_buf.c
2330 @@ -487,6 +487,7 @@ _xfs_buf_find(
2331 struct rb_node *parent;
2332 xfs_buf_t *bp;
2333 xfs_daddr_t blkno = map[0].bm_bn;
2334 + xfs_daddr_t eofs;
2335 int numblks = 0;
2336 int i;
2337
2338 @@ -498,6 +499,23 @@ _xfs_buf_find(
2339 ASSERT(!(numbytes < (1 << btp->bt_sshift)));
2340 ASSERT(!(BBTOB(blkno) & (xfs_off_t)btp->bt_smask));
2341
2342 + /*
2343 + * Corrupted block numbers can get through to here, unfortunately, so we
2344 + * have to check that the buffer falls within the filesystem bounds.
2345 + */
2346 + eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
2347 + if (blkno >= eofs) {
2348 + /*
2349 + * XXX (dgc): we should really be returning EFSCORRUPTED here,
2350 + * but none of the higher level infrastructure supports
2351 + * returning a specific error on buffer lookup failures.
2352 + */
2353 + xfs_alert(btp->bt_mount,
2354 + "%s: Block out of range: block 0x%llx, EOFS 0x%llx ",
2355 + __func__, blkno, eofs);
2356 + return NULL;
2357 + }
2358 +
2359 /* get tree root */
2360 pag = xfs_perag_get(btp->bt_mount,
2361 xfs_daddr_to_agno(btp->bt_mount, blkno));
2362 diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
2363 index 9500caf..7bf85e8 100644
2364 --- a/fs/xfs/xfs_sync.c
2365 +++ b/fs/xfs/xfs_sync.c
2366 @@ -400,7 +400,7 @@ xfs_sync_worker(
2367 * cancel_delayed_work_sync on this work queue before tearing down
2368 * the ail and the log in xfs_log_unmount.
2369 */
2370 - if (!(mp->m_super->s_flags & MS_ACTIVE) &&
2371 + if ((mp->m_super->s_flags & MS_ACTIVE) &&
2372 !(mp->m_flags & XFS_MOUNT_RDONLY)) {
2373 /* dgc: errors ignored here */
2374 if (mp->m_super->s_writers.frozen == SB_UNFROZEN &&
2375 diff --git a/include/linux/efi.h b/include/linux/efi.h
2376 index 8670eb1..b424f64 100644
2377 --- a/include/linux/efi.h
2378 +++ b/include/linux/efi.h
2379 @@ -542,18 +542,30 @@ extern int __init efi_setup_pcdp_console(char *);
2380 #endif
2381
2382 /*
2383 - * We play games with efi_enabled so that the compiler will, if possible, remove
2384 - * EFI-related code altogether.
2385 + * We play games with efi_enabled so that the compiler will, if
2386 + * possible, remove EFI-related code altogether.
2387 */
2388 +#define EFI_BOOT 0 /* Were we booted from EFI? */
2389 +#define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */
2390 +#define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */
2391 +#define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */
2392 +#define EFI_MEMMAP 4 /* Can we use EFI memory map? */
2393 +#define EFI_64BIT 5 /* Is the firmware 64-bit? */
2394 +
2395 #ifdef CONFIG_EFI
2396 # ifdef CONFIG_X86
2397 - extern int efi_enabled;
2398 - extern bool efi_64bit;
2399 +extern int efi_enabled(int facility);
2400 # else
2401 -# define efi_enabled 1
2402 +static inline int efi_enabled(int facility)
2403 +{
2404 + return 1;
2405 +}
2406 # endif
2407 #else
2408 -# define efi_enabled 0
2409 +static inline int efi_enabled(int facility)
2410 +{
2411 + return 0;
2412 +}
2413 #endif
2414
2415 /*
2416 diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
2417 index d8f5b9f..e98aeb3 100644
2418 --- a/include/net/netfilter/nf_conntrack_core.h
2419 +++ b/include/net/netfilter/nf_conntrack_core.h
2420 @@ -31,6 +31,8 @@ extern void nf_conntrack_cleanup(struct net *net);
2421 extern int nf_conntrack_proto_init(struct net *net);
2422 extern void nf_conntrack_proto_fini(struct net *net);
2423
2424 +extern void nf_conntrack_cleanup_end(void);
2425 +
2426 extern bool
2427 nf_ct_get_tuple(const struct sk_buff *skb,
2428 unsigned int nhoff,
2429 diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
2430 index 591db7d..c24060e 100644
2431 --- a/include/net/netns/x_tables.h
2432 +++ b/include/net/netns/x_tables.h
2433 @@ -8,6 +8,7 @@ struct ebt_table;
2434
2435 struct netns_xt {
2436 struct list_head tables[NFPROTO_NUMPROTO];
2437 + bool notrack_deprecated_warning;
2438 #if defined(CONFIG_BRIDGE_NF_EBTABLES) || \
2439 defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE)
2440 struct ebt_table *broute_table;
2441 diff --git a/init/main.c b/init/main.c
2442 index cd147a9..857166f 100644
2443 --- a/init/main.c
2444 +++ b/init/main.c
2445 @@ -604,7 +604,7 @@ asmlinkage void __init start_kernel(void)
2446 pidmap_init();
2447 anon_vma_init();
2448 #ifdef CONFIG_X86
2449 - if (efi_enabled)
2450 + if (efi_enabled(EFI_RUNTIME_SERVICES))
2451 efi_enter_virtual_mode();
2452 #endif
2453 thread_info_cache_init();
2454 @@ -632,7 +632,7 @@ asmlinkage void __init start_kernel(void)
2455 acpi_early_init(); /* before LAPIC and SMP init */
2456 sfi_init_late();
2457
2458 - if (efi_enabled) {
2459 + if (efi_enabled(EFI_RUNTIME_SERVICES)) {
2460 efi_late_init();
2461 efi_free_boot_services();
2462 }
2463 diff --git a/kernel/smp.c b/kernel/smp.c
2464 index 29dd40a..69f38bd 100644
2465 --- a/kernel/smp.c
2466 +++ b/kernel/smp.c
2467 @@ -33,6 +33,7 @@ struct call_function_data {
2468 struct call_single_data csd;
2469 atomic_t refs;
2470 cpumask_var_t cpumask;
2471 + cpumask_var_t cpumask_ipi;
2472 };
2473
2474 static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_function_data, cfd_data);
2475 @@ -56,6 +57,9 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
2476 if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
2477 cpu_to_node(cpu)))
2478 return notifier_from_errno(-ENOMEM);
2479 + if (!zalloc_cpumask_var_node(&cfd->cpumask_ipi, GFP_KERNEL,
2480 + cpu_to_node(cpu)))
2481 + return notifier_from_errno(-ENOMEM);
2482 break;
2483
2484 #ifdef CONFIG_HOTPLUG_CPU
2485 @@ -65,6 +69,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
2486 case CPU_DEAD:
2487 case CPU_DEAD_FROZEN:
2488 free_cpumask_var(cfd->cpumask);
2489 + free_cpumask_var(cfd->cpumask_ipi);
2490 break;
2491 #endif
2492 };
2493 @@ -526,6 +531,12 @@ void smp_call_function_many(const struct cpumask *mask,
2494 return;
2495 }
2496
2497 + /*
2498 + * After we put an entry into the list, data->cpumask
2499 + * may be cleared again when another CPU sends another IPI for
2500 + * a SMP function call, so data->cpumask will be zero.
2501 + */
2502 + cpumask_copy(data->cpumask_ipi, data->cpumask);
2503 raw_spin_lock_irqsave(&call_function.lock, flags);
2504 /*
2505 * Place entry at the _HEAD_ of the list, so that any cpu still
2506 @@ -549,7 +560,7 @@ void smp_call_function_many(const struct cpumask *mask,
2507 smp_mb();
2508
2509 /* Send a message to all CPUs in the map */
2510 - arch_send_call_function_ipi_mask(data->cpumask);
2511 + arch_send_call_function_ipi_mask(data->cpumask_ipi);
2512
2513 /* Optionally wait for the CPUs to complete */
2514 if (wait)
2515 diff --git a/mm/slub.c b/mm/slub.c
2516 index a0d6984..321afab 100644
2517 --- a/mm/slub.c
2518 +++ b/mm/slub.c
2519 @@ -3279,6 +3279,7 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name,
2520 if (kmem_cache_open(s, flags))
2521 goto panic;
2522
2523 + s->refcount = 1;
2524 list_add(&s->list, &slab_caches);
2525 return s;
2526
2527 diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
2528 index 2022b43..7c40d1e 100644
2529 --- a/net/bluetooth/hci_event.c
2530 +++ b/net/bluetooth/hci_event.c
2531 @@ -2394,7 +2394,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
2532 if (ev->opcode != HCI_OP_NOP)
2533 del_timer(&hdev->cmd_timer);
2534
2535 - if (ev->ncmd) {
2536 + if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
2537 atomic_set(&hdev->cmd_cnt, 1);
2538 if (!skb_queue_empty(&hdev->cmd_q))
2539 queue_work(hdev->workqueue, &hdev->cmd_work);
2540 diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
2541 index ccd985d..03652f3 100644
2542 --- a/net/bluetooth/hidp/core.c
2543 +++ b/net/bluetooth/hidp/core.c
2544 @@ -931,7 +931,7 @@ static int hidp_setup_hid(struct hidp_session *session,
2545 hid->version = req->version;
2546 hid->country = req->country;
2547
2548 - strncpy(hid->name, req->name, 128);
2549 + strncpy(hid->name, req->name, sizeof(req->name) - 1);
2550 strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
2551 strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);
2552
2553 diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
2554 index 51f13f8..04b18c1 100644
2555 --- a/net/ipv4/netfilter/ipt_REJECT.c
2556 +++ b/net/ipv4/netfilter/ipt_REJECT.c
2557 @@ -81,6 +81,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
2558 niph->saddr = oiph->daddr;
2559 niph->daddr = oiph->saddr;
2560
2561 + skb_reset_transport_header(nskb);
2562 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
2563 memset(tcph, 0, sizeof(*tcph));
2564 tcph->source = oth->dest;
2565 diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
2566 index fd4fb34..029623d 100644
2567 --- a/net/ipv6/netfilter/ip6t_REJECT.c
2568 +++ b/net/ipv6/netfilter/ip6t_REJECT.c
2569 @@ -132,6 +132,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
2570 ip6h->saddr = oip6h->daddr;
2571 ip6h->daddr = oip6h->saddr;
2572
2573 + skb_reset_transport_header(nskb);
2574 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
2575 /* Truncate to length (no data) */
2576 tcph->doff = sizeof(struct tcphdr)/4;
2577 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
2578 index 22c8ea9..3dacecc 100644
2579 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
2580 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
2581 @@ -311,7 +311,10 @@ found:
2582 else
2583 fq->q.fragments = skb;
2584
2585 - skb->dev = NULL;
2586 + if (skb->dev) {
2587 + fq->iif = skb->dev->ifindex;
2588 + skb->dev = NULL;
2589 + }
2590 fq->q.stamp = skb->tstamp;
2591 fq->q.meat += skb->len;
2592 if (payload_len > fq->q.max_size)
2593 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
2594 index 7371f67..494da7f 100644
2595 --- a/net/mac80211/cfg.c
2596 +++ b/net/mac80211/cfg.c
2597 @@ -164,7 +164,17 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
2598 sta = sta_info_get(sdata, mac_addr);
2599 else
2600 sta = sta_info_get_bss(sdata, mac_addr);
2601 - if (!sta) {
2602 + /*
2603 + * The ASSOC test makes sure the driver is ready to
2604 + * receive the key. When wpa_supplicant has roamed
2605 + * using FT, it attempts to set the key before
2606 + * association has completed, this rejects that attempt
2607 + * so it will set the key again after assocation.
2608 + *
2609 + * TODO: accept the key if we have a station entry and
2610 + * add it to the device after the station.
2611 + */
2612 + if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
2613 ieee80211_key_free(sdata->local, key);
2614 err = -ENOENT;
2615 goto out_unlock;
2616 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
2617 index 3da215c..493e2e8 100644
2618 --- a/net/mac80211/ieee80211_i.h
2619 +++ b/net/mac80211/ieee80211_i.h
2620 @@ -1279,10 +1279,8 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
2621 void ieee80211_sched_scan_stopped_work(struct work_struct *work);
2622
2623 /* off-channel helpers */
2624 -void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
2625 - bool offchannel_ps_enable);
2626 -void ieee80211_offchannel_return(struct ieee80211_local *local,
2627 - bool offchannel_ps_disable);
2628 +void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
2629 +void ieee80211_offchannel_return(struct ieee80211_local *local);
2630 void ieee80211_roc_setup(struct ieee80211_local *local);
2631 void ieee80211_start_next_roc(struct ieee80211_local *local);
2632 void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata);
2633 diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
2634 index 2c84185..b88152f 100644
2635 --- a/net/mac80211/offchannel.c
2636 +++ b/net/mac80211/offchannel.c
2637 @@ -102,8 +102,7 @@ static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata)
2638 ieee80211_sta_reset_conn_monitor(sdata);
2639 }
2640
2641 -void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
2642 - bool offchannel_ps_enable)
2643 +void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
2644 {
2645 struct ieee80211_sub_if_data *sdata;
2646
2647 @@ -131,8 +130,7 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
2648
2649 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) {
2650 netif_tx_stop_all_queues(sdata->dev);
2651 - if (offchannel_ps_enable &&
2652 - (sdata->vif.type == NL80211_IFTYPE_STATION) &&
2653 + if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2654 sdata->u.mgd.associated)
2655 ieee80211_offchannel_ps_enable(sdata);
2656 }
2657 @@ -140,8 +138,7 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
2658 mutex_unlock(&local->iflist_mtx);
2659 }
2660
2661 -void ieee80211_offchannel_return(struct ieee80211_local *local,
2662 - bool offchannel_ps_disable)
2663 +void ieee80211_offchannel_return(struct ieee80211_local *local)
2664 {
2665 struct ieee80211_sub_if_data *sdata;
2666
2667 @@ -157,11 +154,9 @@ void ieee80211_offchannel_return(struct ieee80211_local *local,
2668 continue;
2669
2670 /* Tell AP we're back */
2671 - if (offchannel_ps_disable &&
2672 - sdata->vif.type == NL80211_IFTYPE_STATION) {
2673 - if (sdata->u.mgd.associated)
2674 - ieee80211_offchannel_ps_disable(sdata);
2675 - }
2676 + if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2677 + sdata->u.mgd.associated)
2678 + ieee80211_offchannel_ps_disable(sdata);
2679
2680 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) {
2681 /*
2682 @@ -381,7 +376,7 @@ void ieee80211_sw_roc_work(struct work_struct *work)
2683 local->tmp_channel = NULL;
2684 ieee80211_hw_config(local, 0);
2685
2686 - ieee80211_offchannel_return(local, true);
2687 + ieee80211_offchannel_return(local);
2688 }
2689
2690 ieee80211_recalc_idle(local);
2691 diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
2692 index fab706f..f41b1bd 100644
2693 --- a/net/mac80211/scan.c
2694 +++ b/net/mac80211/scan.c
2695 @@ -310,7 +310,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
2696 if (!was_hw_scan) {
2697 ieee80211_configure_filter(local);
2698 drv_sw_scan_complete(local);
2699 - ieee80211_offchannel_return(local, true);
2700 + ieee80211_offchannel_return(local);
2701 }
2702
2703 ieee80211_recalc_idle(local);
2704 @@ -355,7 +355,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
2705 local->next_scan_state = SCAN_DECISION;
2706 local->scan_channel_idx = 0;
2707
2708 - ieee80211_offchannel_stop_vifs(local, true);
2709 + ieee80211_offchannel_stop_vifs(local);
2710
2711 ieee80211_configure_filter(local);
2712
2713 @@ -680,12 +680,8 @@ static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
2714 local->scan_channel = NULL;
2715 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
2716
2717 - /*
2718 - * Re-enable vifs and beaconing. Leave PS
2719 - * in off-channel state..will put that back
2720 - * on-channel at the end of scanning.
2721 - */
2722 - ieee80211_offchannel_return(local, false);
2723 + /* disable PS */
2724 + ieee80211_offchannel_return(local);
2725
2726 *next_delay = HZ / 5;
2727 /* afterwards, resume scan & go to next channel */
2728 @@ -695,8 +691,7 @@ static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
2729 static void ieee80211_scan_state_resume(struct ieee80211_local *local,
2730 unsigned long *next_delay)
2731 {
2732 - /* PS already is in off-channel mode */
2733 - ieee80211_offchannel_stop_vifs(local, false);
2734 + ieee80211_offchannel_stop_vifs(local);
2735
2736 if (local->ops->flush) {
2737 drv_flush(local, false);
2738 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
2739 index fefa514..49e96df 100644
2740 --- a/net/netfilter/Kconfig
2741 +++ b/net/netfilter/Kconfig
2742 @@ -680,6 +680,13 @@ config NETFILTER_XT_TARGET_NFQUEUE
2743
2744 To compile it as a module, choose M here. If unsure, say N.
2745
2746 +config NETFILTER_XT_TARGET_NOTRACK
2747 + tristate '"NOTRACK" target support (DEPRECATED)'
2748 + depends on NF_CONNTRACK
2749 + depends on IP_NF_RAW || IP6_NF_RAW
2750 + depends on NETFILTER_ADVANCED
2751 + select NETFILTER_XT_TARGET_CT
2752 +
2753 config NETFILTER_XT_TARGET_RATEEST
2754 tristate '"RATEEST" target support'
2755 depends on NETFILTER_ADVANCED
2756 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
2757 index 0f241be..ec02168 100644
2758 --- a/net/netfilter/nf_conntrack_core.c
2759 +++ b/net/netfilter/nf_conntrack_core.c
2760 @@ -1383,11 +1383,12 @@ void nf_conntrack_cleanup(struct net *net)
2761 synchronize_net();
2762 nf_conntrack_proto_fini(net);
2763 nf_conntrack_cleanup_net(net);
2764 +}
2765
2766 - if (net_eq(net, &init_net)) {
2767 - RCU_INIT_POINTER(nf_ct_destroy, NULL);
2768 - nf_conntrack_cleanup_init_net();
2769 - }
2770 +void nf_conntrack_cleanup_end(void)
2771 +{
2772 + RCU_INIT_POINTER(nf_ct_destroy, NULL);
2773 + nf_conntrack_cleanup_init_net();
2774 }
2775
2776 void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls)
2777 diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
2778 index 7bbfb3d..ef9e86e 100644
2779 --- a/net/netfilter/nf_conntrack_netlink.c
2780 +++ b/net/netfilter/nf_conntrack_netlink.c
2781 @@ -2514,7 +2514,7 @@ ctnetlink_create_expect(struct net *net, u16 zone,
2782 if (!help) {
2783 if (!cda[CTA_EXPECT_TIMEOUT]) {
2784 err = -EINVAL;
2785 - goto out;
2786 + goto err_out;
2787 }
2788 exp->timeout.expires =
2789 jiffies + ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;
2790 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
2791 index 9b39432..df8aa3a 100644
2792 --- a/net/netfilter/nf_conntrack_standalone.c
2793 +++ b/net/netfilter/nf_conntrack_standalone.c
2794 @@ -571,6 +571,7 @@ static int __init nf_conntrack_standalone_init(void)
2795 static void __exit nf_conntrack_standalone_fini(void)
2796 {
2797 unregister_pernet_subsys(&nf_conntrack_net_ops);
2798 + nf_conntrack_cleanup_end();
2799 }
2800
2801 module_init(nf_conntrack_standalone_init);
2802 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
2803 index 9f199f2..92fd8ec 100644
2804 --- a/net/netfilter/nfnetlink_log.c
2805 +++ b/net/netfilter/nfnetlink_log.c
2806 @@ -13,6 +13,7 @@
2807 */
2808 #include <linux/module.h>
2809 #include <linux/skbuff.h>
2810 +#include <linux/if_arp.h>
2811 #include <linux/init.h>
2812 #include <linux/ip.h>
2813 #include <linux/ipv6.h>
2814 @@ -384,6 +385,7 @@ __build_packet_message(struct nfulnl_instance *inst,
2815 struct nfgenmsg *nfmsg;
2816 sk_buff_data_t old_tail = inst->skb->tail;
2817 struct sock *sk;
2818 + const unsigned char *hwhdrp;
2819
2820 nlh = nlmsg_put(inst->skb, 0, 0,
2821 NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET,
2822 @@ -485,9 +487,17 @@ __build_packet_message(struct nfulnl_instance *inst,
2823 if (indev && skb_mac_header_was_set(skb)) {
2824 if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) ||
2825 nla_put_be16(inst->skb, NFULA_HWLEN,
2826 - htons(skb->dev->hard_header_len)) ||
2827 - nla_put(inst->skb, NFULA_HWHEADER, skb->dev->hard_header_len,
2828 - skb_mac_header(skb)))
2829 + htons(skb->dev->hard_header_len)))
2830 + goto nla_put_failure;
2831 +
2832 + hwhdrp = skb_mac_header(skb);
2833 +
2834 + if (skb->dev->type == ARPHRD_SIT)
2835 + hwhdrp -= ETH_HLEN;
2836 +
2837 + if (hwhdrp >= skb->head &&
2838 + nla_put(inst->skb, NFULA_HWHEADER,
2839 + skb->dev->hard_header_len, hwhdrp))
2840 goto nla_put_failure;
2841 }
2842
2843 diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
2844 index 8d987c3..7b3a9e5 100644
2845 --- a/net/netfilter/x_tables.c
2846 +++ b/net/netfilter/x_tables.c
2847 @@ -345,19 +345,27 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target,
2848 }
2849 EXPORT_SYMBOL_GPL(xt_find_revision);
2850
2851 -static char *textify_hooks(char *buf, size_t size, unsigned int mask)
2852 +static char *
2853 +textify_hooks(char *buf, size_t size, unsigned int mask, uint8_t nfproto)
2854 {
2855 - static const char *const names[] = {
2856 + static const char *const inetbr_names[] = {
2857 "PREROUTING", "INPUT", "FORWARD",
2858 "OUTPUT", "POSTROUTING", "BROUTING",
2859 };
2860 - unsigned int i;
2861 + static const char *const arp_names[] = {
2862 + "INPUT", "FORWARD", "OUTPUT",
2863 + };
2864 + const char *const *names;
2865 + unsigned int i, max;
2866 char *p = buf;
2867 bool np = false;
2868 int res;
2869
2870 + names = (nfproto == NFPROTO_ARP) ? arp_names : inetbr_names;
2871 + max = (nfproto == NFPROTO_ARP) ? ARRAY_SIZE(arp_names) :
2872 + ARRAY_SIZE(inetbr_names);
2873 *p = '\0';
2874 - for (i = 0; i < ARRAY_SIZE(names); ++i) {
2875 + for (i = 0; i < max; ++i) {
2876 if (!(mask & (1 << i)))
2877 continue;
2878 res = snprintf(p, size, "%s%s", np ? "/" : "", names[i]);
2879 @@ -402,8 +410,10 @@ int xt_check_match(struct xt_mtchk_param *par,
2880 pr_err("%s_tables: %s match: used from hooks %s, but only "
2881 "valid from %s\n",
2882 xt_prefix[par->family], par->match->name,
2883 - textify_hooks(used, sizeof(used), par->hook_mask),
2884 - textify_hooks(allow, sizeof(allow), par->match->hooks));
2885 + textify_hooks(used, sizeof(used), par->hook_mask,
2886 + par->family),
2887 + textify_hooks(allow, sizeof(allow), par->match->hooks,
2888 + par->family));
2889 return -EINVAL;
2890 }
2891 if (par->match->proto && (par->match->proto != proto || inv_proto)) {
2892 @@ -575,8 +585,10 @@ int xt_check_target(struct xt_tgchk_param *par,
2893 pr_err("%s_tables: %s target: used from hooks %s, but only "
2894 "usable from %s\n",
2895 xt_prefix[par->family], par->target->name,
2896 - textify_hooks(used, sizeof(used), par->hook_mask),
2897 - textify_hooks(allow, sizeof(allow), par->target->hooks));
2898 + textify_hooks(used, sizeof(used), par->hook_mask,
2899 + par->family),
2900 + textify_hooks(allow, sizeof(allow), par->target->hooks,
2901 + par->family));
2902 return -EINVAL;
2903 }
2904 if (par->target->proto && (par->target->proto != proto || inv_proto)) {
2905 diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
2906 index ae7f5da..8461605 100644
2907 --- a/net/netfilter/xt_CT.c
2908 +++ b/net/netfilter/xt_CT.c
2909 @@ -109,7 +109,7 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)
2910 struct xt_ct_target_info *info = par->targinfo;
2911 struct nf_conntrack_tuple t;
2912 struct nf_conn *ct;
2913 - int ret;
2914 + int ret = -EOPNOTSUPP;
2915
2916 if (info->flags & ~XT_CT_NOTRACK)
2917 return -EINVAL;
2918 @@ -243,7 +243,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)
2919 struct xt_ct_target_info_v1 *info = par->targinfo;
2920 struct nf_conntrack_tuple t;
2921 struct nf_conn *ct;
2922 - int ret;
2923 + int ret = -EOPNOTSUPP;
2924
2925 if (info->flags & ~XT_CT_NOTRACK)
2926 return -EINVAL;
2927 @@ -377,14 +377,60 @@ static struct xt_target xt_ct_tg_reg[] __read_mostly = {
2928 },
2929 };
2930
2931 +static unsigned int
2932 +notrack_tg(struct sk_buff *skb, const struct xt_action_param *par)
2933 +{
2934 + /* Previously seen (loopback)? Ignore. */
2935 + if (skb->nfct != NULL)
2936 + return XT_CONTINUE;
2937 +
2938 + skb->nfct = &nf_ct_untracked_get()->ct_general;
2939 + skb->nfctinfo = IP_CT_NEW;
2940 + nf_conntrack_get(skb->nfct);
2941 +
2942 + return XT_CONTINUE;
2943 +}
2944 +
2945 +static int notrack_chk(const struct xt_tgchk_param *par)
2946 +{
2947 + if (!par->net->xt.notrack_deprecated_warning) {
2948 + pr_info("netfilter: NOTRACK target is deprecated, "
2949 + "use CT instead or upgrade iptables\n");
2950 + par->net->xt.notrack_deprecated_warning = true;
2951 + }
2952 + return 0;
2953 +}
2954 +
2955 +static struct xt_target notrack_tg_reg __read_mostly = {
2956 + .name = "NOTRACK",
2957 + .revision = 0,
2958 + .family = NFPROTO_UNSPEC,
2959 + .checkentry = notrack_chk,
2960 + .target = notrack_tg,
2961 + .table = "raw",
2962 + .me = THIS_MODULE,
2963 +};
2964 +
2965 static int __init xt_ct_tg_init(void)
2966 {
2967 - return xt_register_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg));
2968 + int ret;
2969 +
2970 + ret = xt_register_target(&notrack_tg_reg);
2971 + if (ret < 0)
2972 + return ret;
2973 +
2974 + ret = xt_register_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg));
2975 + if (ret < 0) {
2976 + xt_unregister_target(&notrack_tg_reg);
2977 + return ret;
2978 + }
2979 + return 0;
2980 }
2981
2982 static void __exit xt_ct_tg_exit(void)
2983 {
2984 xt_unregister_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg));
2985 + xt_unregister_target(&notrack_tg_reg);
2986 }
2987
2988 module_init(xt_ct_tg_init);
2989 @@ -394,3 +440,5 @@ MODULE_LICENSE("GPL");
2990 MODULE_DESCRIPTION("Xtables: connection tracking target");
2991 MODULE_ALIAS("ipt_CT");
2992 MODULE_ALIAS("ip6t_CT");
2993 +MODULE_ALIAS("ipt_NOTRACK");
2994 +MODULE_ALIAS("ip6t_NOTRACK");
2995 diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
2996 index 26a668a..a9d7af9 100644
2997 --- a/net/netfilter/xt_hashlimit.c
2998 +++ b/net/netfilter/xt_hashlimit.c
2999 @@ -157,11 +157,22 @@ dsthash_find(const struct xt_hashlimit_htable *ht,
3000 /* allocate dsthash_ent, initialize dst, put in htable and lock it */
3001 static struct dsthash_ent *
3002 dsthash_alloc_init(struct xt_hashlimit_htable *ht,
3003 - const struct dsthash_dst *dst)
3004 + const struct dsthash_dst *dst, bool *race)
3005 {
3006 struct dsthash_ent *ent;
3007
3008 spin_lock(&ht->lock);
3009 +
3010 + /* Two or more packets may race to create the same entry in the
3011 + * hashtable, double check if this packet lost race.
3012 + */
3013 + ent = dsthash_find(ht, dst);
3014 + if (ent != NULL) {
3015 + spin_unlock(&ht->lock);
3016 + *race = true;
3017 + return ent;
3018 + }
3019 +
3020 /* initialize hash with random val at the time we allocate
3021 * the first hashtable entry */
3022 if (unlikely(!ht->rnd_initialized)) {
3023 @@ -318,7 +329,10 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
3024 parent = hashlimit_net->ipt_hashlimit;
3025 else
3026 parent = hashlimit_net->ip6t_hashlimit;
3027 - remove_proc_entry(hinfo->pde->name, parent);
3028 +
3029 + if(parent != NULL)
3030 + remove_proc_entry(hinfo->pde->name, parent);
3031 +
3032 htable_selective_cleanup(hinfo, select_all);
3033 vfree(hinfo);
3034 }
3035 @@ -585,6 +599,7 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
3036 unsigned long now = jiffies;
3037 struct dsthash_ent *dh;
3038 struct dsthash_dst dst;
3039 + bool race = false;
3040 u32 cost;
3041
3042 if (hashlimit_init_dst(hinfo, &dst, skb, par->thoff) < 0)
3043 @@ -593,13 +608,18 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
3044 rcu_read_lock_bh();
3045 dh = dsthash_find(hinfo, &dst);
3046 if (dh == NULL) {
3047 - dh = dsthash_alloc_init(hinfo, &dst);
3048 + dh = dsthash_alloc_init(hinfo, &dst, &race);
3049 if (dh == NULL) {
3050 rcu_read_unlock_bh();
3051 goto hotdrop;
3052 + } else if (race) {
3053 + /* Already got an entry, update expiration timeout */
3054 + dh->expires = now + msecs_to_jiffies(hinfo->cfg.expire);
3055 + rateinfo_recalc(dh, now, hinfo->cfg.mode);
3056 + } else {
3057 + dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire);
3058 + rateinfo_init(dh, hinfo);
3059 }
3060 - dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire);
3061 - rateinfo_init(dh, hinfo);
3062 } else {
3063 /* update expiration timeout */
3064 dh->expires = now + msecs_to_jiffies(hinfo->cfg.expire);
3065 @@ -856,6 +876,27 @@ static int __net_init hashlimit_proc_net_init(struct net *net)
3066
3067 static void __net_exit hashlimit_proc_net_exit(struct net *net)
3068 {
3069 + struct xt_hashlimit_htable *hinfo;
3070 + struct hlist_node *pos;
3071 + struct proc_dir_entry *pde;
3072 + struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
3073 +
3074 + /* recent_net_exit() is called before recent_mt_destroy(). Make sure
3075 + * that the parent xt_recent proc entry is is empty before trying to
3076 + * remove it.
3077 + */
3078 + mutex_lock(&hashlimit_mutex);
3079 + pde = hashlimit_net->ipt_hashlimit;
3080 + if (pde == NULL)
3081 + pde = hashlimit_net->ip6t_hashlimit;
3082 +
3083 + hlist_for_each_entry(hinfo, pos, &hashlimit_net->htables, node)
3084 + remove_proc_entry(hinfo->pde->name, pde);
3085 +
3086 + hashlimit_net->ipt_hashlimit = NULL;
3087 + hashlimit_net->ip6t_hashlimit = NULL;
3088 + mutex_unlock(&hashlimit_mutex);
3089 +
3090 proc_net_remove(net, "ipt_hashlimit");
3091 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
3092 proc_net_remove(net, "ip6t_hashlimit");
3093 @@ -872,9 +913,6 @@ static int __net_init hashlimit_net_init(struct net *net)
3094
3095 static void __net_exit hashlimit_net_exit(struct net *net)
3096 {
3097 - struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
3098 -
3099 - BUG_ON(!hlist_empty(&hashlimit_net->htables));
3100 hashlimit_proc_net_exit(net);
3101 }
3102
3103 diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
3104 index 4635c9b..978efc9 100644
3105 --- a/net/netfilter/xt_recent.c
3106 +++ b/net/netfilter/xt_recent.c
3107 @@ -29,6 +29,7 @@
3108 #include <linux/skbuff.h>
3109 #include <linux/inet.h>
3110 #include <linux/slab.h>
3111 +#include <linux/vmalloc.h>
3112 #include <net/net_namespace.h>
3113 #include <net/netns/generic.h>
3114
3115 @@ -310,6 +311,14 @@ out:
3116 return ret;
3117 }
3118
3119 +static void recent_table_free(void *addr)
3120 +{
3121 + if (is_vmalloc_addr(addr))
3122 + vfree(addr);
3123 + else
3124 + kfree(addr);
3125 +}
3126 +
3127 static int recent_mt_check(const struct xt_mtchk_param *par,
3128 const struct xt_recent_mtinfo_v1 *info)
3129 {
3130 @@ -322,6 +331,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
3131 #endif
3132 unsigned int i;
3133 int ret = -EINVAL;
3134 + size_t sz;
3135
3136 if (unlikely(!hash_rnd_inited)) {
3137 get_random_bytes(&hash_rnd, sizeof(hash_rnd));
3138 @@ -360,8 +370,11 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
3139 goto out;
3140 }
3141
3142 - t = kzalloc(sizeof(*t) + sizeof(t->iphash[0]) * ip_list_hash_size,
3143 - GFP_KERNEL);
3144 + sz = sizeof(*t) + sizeof(t->iphash[0]) * ip_list_hash_size;
3145 + if (sz <= PAGE_SIZE)
3146 + t = kzalloc(sz, GFP_KERNEL);
3147 + else
3148 + t = vzalloc(sz);
3149 if (t == NULL) {
3150 ret = -ENOMEM;
3151 goto out;
3152 @@ -377,14 +390,14 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
3153 uid = make_kuid(&init_user_ns, ip_list_uid);
3154 gid = make_kgid(&init_user_ns, ip_list_gid);
3155 if (!uid_valid(uid) || !gid_valid(gid)) {
3156 - kfree(t);
3157 + recent_table_free(t);
3158 ret = -EINVAL;
3159 goto out;
3160 }
3161 pde = proc_create_data(t->name, ip_list_perms, recent_net->xt_recent,
3162 &recent_mt_fops, t);
3163 if (pde == NULL) {
3164 - kfree(t);
3165 + recent_table_free(t);
3166 ret = -ENOMEM;
3167 goto out;
3168 }
3169 @@ -431,10 +444,11 @@ static void recent_mt_destroy(const struct xt_mtdtor_param *par)
3170 list_del(&t->list);
3171 spin_unlock_bh(&recent_lock);
3172 #ifdef CONFIG_PROC_FS
3173 - remove_proc_entry(t->name, recent_net->xt_recent);
3174 + if (recent_net->xt_recent != NULL)
3175 + remove_proc_entry(t->name, recent_net->xt_recent);
3176 #endif
3177 recent_table_flush(t);
3178 - kfree(t);
3179 + recent_table_free(t);
3180 }
3181 mutex_unlock(&recent_mutex);
3182 }
3183 @@ -615,6 +629,20 @@ static int __net_init recent_proc_net_init(struct net *net)
3184
3185 static void __net_exit recent_proc_net_exit(struct net *net)
3186 {
3187 + struct recent_net *recent_net = recent_pernet(net);
3188 + struct recent_table *t;
3189 +
3190 + /* recent_net_exit() is called before recent_mt_destroy(). Make sure
3191 + * that the parent xt_recent proc entry is is empty before trying to
3192 + * remove it.
3193 + */
3194 + spin_lock_bh(&recent_lock);
3195 + list_for_each_entry(t, &recent_net->tables, list)
3196 + remove_proc_entry(t->name, recent_net->xt_recent);
3197 +
3198 + recent_net->xt_recent = NULL;
3199 + spin_unlock_bh(&recent_lock);
3200 +
3201 proc_net_remove(net, "xt_recent");
3202 }
3203 #else
3204 @@ -638,9 +666,6 @@ static int __net_init recent_net_init(struct net *net)
3205
3206 static void __net_exit recent_net_exit(struct net *net)
3207 {
3208 - struct recent_net *recent_net = recent_pernet(net);
3209 -
3210 - BUG_ON(!list_empty(&recent_net->tables));
3211 recent_proc_net_exit(net);
3212 }
3213
3214 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
3215 index f419f0a9..078fb30 100644
3216 --- a/sound/pci/hda/hda_intel.c
3217 +++ b/sound/pci/hda/hda_intel.c
3218 @@ -650,29 +650,43 @@ static char *driver_short_names[] DELAYED_INITDATA_MARK = {
3219 #define get_azx_dev(substream) (substream->runtime->private_data)
3220
3221 #ifdef CONFIG_X86
3222 -static void __mark_pages_wc(struct azx *chip, void *addr, size_t size, bool on)
3223 +static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on)
3224 {
3225 + int pages;
3226 +
3227 if (azx_snoop(chip))
3228 return;
3229 - if (addr && size) {
3230 - int pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
3231 + if (!dmab || !dmab->area || !dmab->bytes)
3232 + return;
3233 +
3234 +#ifdef CONFIG_SND_DMA_SGBUF
3235 + if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) {
3236 + struct snd_sg_buf *sgbuf = dmab->private_data;
3237 if (on)
3238 - set_memory_wc((unsigned long)addr, pages);
3239 + set_pages_array_wc(sgbuf->page_table, sgbuf->pages);
3240 else
3241 - set_memory_wb((unsigned long)addr, pages);
3242 + set_pages_array_wb(sgbuf->page_table, sgbuf->pages);
3243 + return;
3244 }
3245 +#endif
3246 +
3247 + pages = (dmab->bytes + PAGE_SIZE - 1) >> PAGE_SHIFT;
3248 + if (on)
3249 + set_memory_wc((unsigned long)dmab->area, pages);
3250 + else
3251 + set_memory_wb((unsigned long)dmab->area, pages);
3252 }
3253
3254 static inline void mark_pages_wc(struct azx *chip, struct snd_dma_buffer *buf,
3255 bool on)
3256 {
3257 - __mark_pages_wc(chip, buf->area, buf->bytes, on);
3258 + __mark_pages_wc(chip, buf, on);
3259 }
3260 static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
3261 - struct snd_pcm_runtime *runtime, bool on)
3262 + struct snd_pcm_substream *substream, bool on)
3263 {
3264 if (azx_dev->wc_marked != on) {
3265 - __mark_pages_wc(chip, runtime->dma_area, runtime->dma_bytes, on);
3266 + __mark_pages_wc(chip, snd_pcm_get_dma_buf(substream), on);
3267 azx_dev->wc_marked = on;
3268 }
3269 }
3270 @@ -683,7 +697,7 @@ static inline void mark_pages_wc(struct azx *chip, struct snd_dma_buffer *buf,
3271 {
3272 }
3273 static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
3274 - struct snd_pcm_runtime *runtime, bool on)
3275 + struct snd_pcm_substream *substream, bool on)
3276 {
3277 }
3278 #endif
3279 @@ -1860,11 +1874,10 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
3280 {
3281 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
3282 struct azx *chip = apcm->chip;
3283 - struct snd_pcm_runtime *runtime = substream->runtime;
3284 struct azx_dev *azx_dev = get_azx_dev(substream);
3285 int ret;
3286
3287 - mark_runtime_wc(chip, azx_dev, runtime, false);
3288 + mark_runtime_wc(chip, azx_dev, substream, false);
3289 azx_dev->bufsize = 0;
3290 azx_dev->period_bytes = 0;
3291 azx_dev->format_val = 0;
3292 @@ -1872,7 +1885,7 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
3293 params_buffer_bytes(hw_params));
3294 if (ret < 0)
3295 return ret;
3296 - mark_runtime_wc(chip, azx_dev, runtime, true);
3297 + mark_runtime_wc(chip, azx_dev, substream, true);
3298 return ret;
3299 }
3300
3301 @@ -1881,7 +1894,6 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
3302 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
3303 struct azx_dev *azx_dev = get_azx_dev(substream);
3304 struct azx *chip = apcm->chip;
3305 - struct snd_pcm_runtime *runtime = substream->runtime;
3306 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
3307
3308 /* reset BDL address */
3309 @@ -1894,7 +1906,7 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
3310
3311 snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
3312
3313 - mark_runtime_wc(chip, azx_dev, runtime, false);
3314 + mark_runtime_wc(chip, azx_dev, substream, false);
3315 return snd_pcm_lib_free_pages(substream);
3316 }
3317
3318 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3319 index bbaf67c..c98cb89 100644
3320 --- a/sound/pci/hda/patch_realtek.c
3321 +++ b/sound/pci/hda/patch_realtek.c
3322 @@ -4688,6 +4688,7 @@ static const struct snd_pci_quirk alc880_fixup_tbl[] = {
3323 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
3324 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
3325 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
3326 + SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST),
3327 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
3328 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
3329 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
3330 @@ -5702,6 +5703,7 @@ static const struct alc_model_fixup alc268_fixup_models[] = {
3331 };
3332
3333 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
3334 + SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
3335 /* below is codec SSID since multiple Toshiba laptops have the
3336 * same PCI SSID 1179:ff00
3337 */
3338 diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
3339 index 08ae3cb..f9d9f68 100644
3340 --- a/sound/soc/codecs/arizona.c
3341 +++ b/sound/soc/codecs/arizona.c
3342 @@ -648,7 +648,7 @@ static int arizona_hw_params(struct snd_pcm_substream *substream,
3343 }
3344 sr_val = i;
3345
3346 - lrclk = snd_soc_params_to_bclk(params) / params_rate(params);
3347 + lrclk = rates[bclk] / params_rate(params);
3348
3349 arizona_aif_dbg(dai, "BCLK %dHz LRCLK %dHz\n",
3350 rates[bclk], rates[bclk] / lrclk);
3351 diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
3352 index 7ef4e96..0f2bb25 100644
3353 --- a/sound/soc/codecs/wm2200.c
3354 +++ b/sound/soc/codecs/wm2200.c
3355 @@ -897,8 +897,6 @@ static const char *wm2200_mixer_texts[] = {
3356 "EQR",
3357 "LHPF1",
3358 "LHPF2",
3359 - "LHPF3",
3360 - "LHPF4",
3361 "DSP1.1",
3362 "DSP1.2",
3363 "DSP1.3",
3364 @@ -931,7 +929,6 @@ static int wm2200_mixer_values[] = {
3365 0x25,
3366 0x50, /* EQ */
3367 0x51,
3368 - 0x52,
3369 0x60, /* LHPF1 */
3370 0x61, /* LHPF2 */
3371 0x68, /* DSP1 */
3372 diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
3373 index 298070e..41e8bfb 100644
3374 --- a/sound/usb/mixer.c
3375 +++ b/sound/usb/mixer.c
3376 @@ -1259,16 +1259,23 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
3377 }
3378 channels = (hdr->bLength - 7) / csize - 1;
3379 bmaControls = hdr->bmaControls;
3380 + if (hdr->bLength < 7 + csize) {
3381 + snd_printk(KERN_ERR "usbaudio: unit %u: "
3382 + "invalid UAC_FEATURE_UNIT descriptor\n",
3383 + unitid);
3384 + return -EINVAL;
3385 + }
3386 } else {
3387 struct uac2_feature_unit_descriptor *ftr = _ftr;
3388 csize = 4;
3389 channels = (hdr->bLength - 6) / 4 - 1;
3390 bmaControls = ftr->bmaControls;
3391 - }
3392 -
3393 - if (hdr->bLength < 7 || !csize || hdr->bLength < 7 + csize) {
3394 - snd_printk(KERN_ERR "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", unitid);
3395 - return -EINVAL;
3396 + if (hdr->bLength < 6 + csize) {
3397 + snd_printk(KERN_ERR "usbaudio: unit %u: "
3398 + "invalid UAC_FEATURE_UNIT descriptor\n",
3399 + unitid);
3400 + return -EINVAL;
3401 + }
3402 }
3403
3404 /* parse the source unit */
3405 diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
3406 index 9718e98..62e7bd6 100644
3407 --- a/virt/kvm/eventfd.c
3408 +++ b/virt/kvm/eventfd.c
3409 @@ -332,7 +332,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
3410 mutex_lock(&kvm->irqfds.resampler_lock);
3411
3412 list_for_each_entry(resampler,
3413 - &kvm->irqfds.resampler_list, list) {
3414 + &kvm->irqfds.resampler_list, link) {
3415 if (resampler->notifier.gsi == irqfd->gsi) {
3416 irqfd->resampler = resampler;
3417 break;