/[linux-patches]/genpatches-2.6/tags/3.4-10/1007_linux-3.4.8.patch
Gentoo

Contents of /genpatches-2.6/tags/3.4-10/1007_linux-3.4.8.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2192 - (show annotations) (download)
Fri Aug 17 23:46:53 2012 UTC (6 years, 3 months ago) by mpagano
File size: 152301 byte(s)
3.4-10 release
1 diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
2 index 03f7897..286ec04 100644
3 --- a/Documentation/sound/alsa/HD-Audio-Models.txt
4 +++ b/Documentation/sound/alsa/HD-Audio-Models.txt
5 @@ -21,10 +21,11 @@ ALC267/268
6 ==========
7 N/A
8
9 -ALC269
10 +ALC269/270/275/276/280/282
11 ======
12 laptop-amic Laptops with analog-mic input
13 laptop-dmic Laptops with digital-mic input
14 + lenovo-dock Enables docking station I/O for some Lenovos
15
16 ALC662/663/272
17 ==============
18 diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
19 index 4a7b54b..b0714d8 100644
20 --- a/Documentation/stable_kernel_rules.txt
21 +++ b/Documentation/stable_kernel_rules.txt
22 @@ -1,4 +1,4 @@
23 -Everything you ever wanted to know about Linux 2.6 -stable releases.
24 +Everything you ever wanted to know about Linux -stable releases.
25
26 Rules on what kind of patches are accepted, and which ones are not, into the
27 "-stable" tree:
28 @@ -42,10 +42,10 @@ Procedure for submitting patches to the -stable tree:
29 cherry-picked than this can be specified in the following format in
30 the sign-off area:
31
32 - Cc: <stable@vger.kernel.org> # .32.x: a1f84a3: sched: Check for idle
33 - Cc: <stable@vger.kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
34 - Cc: <stable@vger.kernel.org> # .32.x: fd21073: sched: Fix affinity logic
35 - Cc: <stable@vger.kernel.org> # .32.x
36 + Cc: <stable@vger.kernel.org> # 3.3.x: a1f84a3: sched: Check for idle
37 + Cc: <stable@vger.kernel.org> # 3.3.x: 1b9508f: sched: Rate-limit newidle
38 + Cc: <stable@vger.kernel.org> # 3.3.x: fd21073: sched: Fix affinity logic
39 + Cc: <stable@vger.kernel.org> # 3.3.x
40 Signed-off-by: Ingo Molnar <mingo@elte.hu>
41
42 The tag sequence has the meaning of:
43 @@ -79,6 +79,15 @@ Review cycle:
44 security kernel team, and not go through the normal review cycle.
45 Contact the kernel security team for more details on this procedure.
46
47 +Trees:
48 +
49 + - The queues of patches, for both completed versions and in progress
50 + versions can be found at:
51 + http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
52 + - The finalized and tagged releases of all stable kernels can be found
53 + in separate branches per version at:
54 + http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git
55 +
56
57 Review committee:
58
59 diff --git a/Makefile b/Makefile
60 index e17a98c..a3c0c43 100644
61 --- a/Makefile
62 +++ b/Makefile
63 @@ -1,6 +1,6 @@
64 VERSION = 3
65 PATCHLEVEL = 4
66 -SUBLEVEL = 7
67 +SUBLEVEL = 8
68 EXTRAVERSION =
69 NAME = Saber-toothed Squirrel
70
71 diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c
72 index de6d464..d8f6dbf 100644
73 --- a/arch/arm/mach-omap2/opp.c
74 +++ b/arch/arm/mach-omap2/opp.c
75 @@ -53,7 +53,7 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
76 omap_table_init = 1;
77
78 /* Lets now register with OPP library */
79 - for (i = 0; i < opp_def_size; i++) {
80 + for (i = 0; i < opp_def_size; i++, opp_def++) {
81 struct omap_hwmod *oh;
82 struct device *dev;
83
84 @@ -86,7 +86,6 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
85 __func__, opp_def->freq,
86 opp_def->hwmod_name, i, r);
87 }
88 - opp_def++;
89 }
90
91 return 0;
92 diff --git a/arch/m68k/include/asm/entry.h b/arch/m68k/include/asm/entry.h
93 index 622138d..34c2520 100644
94 --- a/arch/m68k/include/asm/entry.h
95 +++ b/arch/m68k/include/asm/entry.h
96 @@ -33,8 +33,8 @@
97
98 /* the following macro is used when enabling interrupts */
99 #if defined(MACH_ATARI_ONLY)
100 - /* block out HSYNC on the atari */
101 -#define ALLOWINT (~0x400)
102 + /* block out HSYNC = ipl 2 on the atari */
103 +#define ALLOWINT (~0x500)
104 #define MAX_NOINT_IPL 3
105 #else
106 /* portable version */
107 diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
108 index 8623f8d..9a5932e 100644
109 --- a/arch/m68k/kernel/sys_m68k.c
110 +++ b/arch/m68k/kernel/sys_m68k.c
111 @@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
112 goto bad_access;
113 }
114
115 - mem_value = *mem;
116 + /*
117 + * No need to check for EFAULT; we know that the page is
118 + * present and writable.
119 + */
120 + __get_user(mem_value, mem);
121 if (mem_value == oldval)
122 - *mem = newval;
123 + __put_user(newval, mem);
124
125 pte_unmap_unlock(pte, ptl);
126 up_read(&mm->mmap_sem);
127 diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
128 index 84d0639..b77f56b 100644
129 --- a/arch/mips/kernel/kspd.c
130 +++ b/arch/mips/kernel/kspd.c
131 @@ -323,7 +323,7 @@ static void sp_cleanup(void)
132 fdt = files_fdtable(files);
133 for (;;) {
134 unsigned long set;
135 - i = j * __NFDBITS;
136 + i = j * BITS_PER_LONG;
137 if (i >= fdt->max_fds)
138 break;
139 set = fdt->open_fds[j++];
140 diff --git a/arch/powerpc/boot/dts/p1022ds.dtsi b/arch/powerpc/boot/dts/p1022ds.dtsi
141 index 7cdb505..1b0673e 100644
142 --- a/arch/powerpc/boot/dts/p1022ds.dtsi
143 +++ b/arch/powerpc/boot/dts/p1022ds.dtsi
144 @@ -33,22 +33,6 @@
145 */
146
147 &board_lbc {
148 - /*
149 - * This node is used to access the pixis via "indirect" mode,
150 - * which is done by writing the pixis register index to chip
151 - * select 0 and the value to/from chip select 1. Indirect
152 - * mode is the only way to access the pixis when DIU video
153 - * is enabled. Note that this assumes that the first column
154 - * of the 'ranges' property above is the chip select number.
155 - */
156 - board-control@0,0 {
157 - compatible = "fsl,p1022ds-indirect-pixis";
158 - reg = <0x0 0x0 1 /* CS0 */
159 - 0x1 0x0 1>; /* CS1 */
160 - interrupt-parent = <&mpic>;
161 - interrupts = <8 0 0 0>;
162 - };
163 -
164 nor@0,0 {
165 #address-cells = <1>;
166 #size-cells = <1>;
167 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
168 index 9d7f0fb..cae0ed7 100644
169 --- a/arch/powerpc/include/asm/reg.h
170 +++ b/arch/powerpc/include/asm/reg.h
171 @@ -1022,7 +1022,8 @@
172 /* Macros for setting and retrieving special purpose registers */
173 #ifndef __ASSEMBLY__
174 #define mfmsr() ({unsigned long rval; \
175 - asm volatile("mfmsr %0" : "=r" (rval)); rval;})
176 + asm volatile("mfmsr %0" : "=r" (rval) : \
177 + : "memory"); rval;})
178 #ifdef CONFIG_PPC_BOOK3S_64
179 #define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
180 : : "r" (v) : "memory")
181 diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
182 index bf99cfa..6324008 100644
183 --- a/arch/powerpc/kernel/ftrace.c
184 +++ b/arch/powerpc/kernel/ftrace.c
185 @@ -245,9 +245,9 @@ __ftrace_make_nop(struct module *mod,
186
187 /*
188 * On PPC32 the trampoline looks like:
189 - * 0x3d, 0x60, 0x00, 0x00 lis r11,sym@ha
190 - * 0x39, 0x6b, 0x00, 0x00 addi r11,r11,sym@l
191 - * 0x7d, 0x69, 0x03, 0xa6 mtctr r11
192 + * 0x3d, 0x80, 0x00, 0x00 lis r12,sym@ha
193 + * 0x39, 0x8c, 0x00, 0x00 addi r12,r12,sym@l
194 + * 0x7d, 0x89, 0x03, 0xa6 mtctr r12
195 * 0x4e, 0x80, 0x04, 0x20 bctr
196 */
197
198 @@ -262,9 +262,9 @@ __ftrace_make_nop(struct module *mod,
199 pr_devel(" %08x %08x ", jmp[0], jmp[1]);
200
201 /* verify that this is what we expect it to be */
202 - if (((jmp[0] & 0xffff0000) != 0x3d600000) ||
203 - ((jmp[1] & 0xffff0000) != 0x396b0000) ||
204 - (jmp[2] != 0x7d6903a6) ||
205 + if (((jmp[0] & 0xffff0000) != 0x3d800000) ||
206 + ((jmp[1] & 0xffff0000) != 0x398c0000) ||
207 + (jmp[2] != 0x7d8903a6) ||
208 (jmp[3] != 0x4e800420)) {
209 printk(KERN_ERR "Not a trampoline\n");
210 return -EINVAL;
211 diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
212 index f700c81..978330c 100644
213 --- a/arch/powerpc/platforms/85xx/p1022_ds.c
214 +++ b/arch/powerpc/platforms/85xx/p1022_ds.c
215 @@ -27,6 +27,7 @@
216 #include <sysdev/fsl_pci.h>
217 #include <asm/udbg.h>
218 #include <asm/fsl_guts.h>
219 +#include <asm/fsl_lbc.h>
220 #include "smp.h"
221
222 #include "mpc85xx.h"
223 @@ -142,17 +143,73 @@ static void p1022ds_set_gamma_table(enum fsl_diu_monitor_port port,
224 {
225 }
226
227 +struct fsl_law {
228 + u32 lawbar;
229 + u32 reserved1;
230 + u32 lawar;
231 + u32 reserved[5];
232 +};
233 +
234 +#define LAWBAR_MASK 0x00F00000
235 +#define LAWBAR_SHIFT 12
236 +
237 +#define LAWAR_EN 0x80000000
238 +#define LAWAR_TGT_MASK 0x01F00000
239 +#define LAW_TRGT_IF_LBC (0x04 << 20)
240 +
241 +#define LAWAR_MASK (LAWAR_EN | LAWAR_TGT_MASK)
242 +#define LAWAR_MATCH (LAWAR_EN | LAW_TRGT_IF_LBC)
243 +
244 +#define BR_BA 0xFFFF8000
245 +
246 +/*
247 + * Map a BRx value to a physical address
248 + *
249 + * The localbus BRx registers only store the lower 32 bits of the address. To
250 + * obtain the upper four bits, we need to scan the LAW table. The entry which
251 + * maps to the localbus will contain the upper four bits.
252 + */
253 +static phys_addr_t lbc_br_to_phys(const void *ecm, unsigned int count, u32 br)
254 +{
255 +#ifndef CONFIG_PHYS_64BIT
256 + /*
257 + * If we only have 32-bit addressing, then the BRx address *is* the
258 + * physical address.
259 + */
260 + return br & BR_BA;
261 +#else
262 + const struct fsl_law *law = ecm + 0xc08;
263 + unsigned int i;
264 +
265 + for (i = 0; i < count; i++) {
266 + u64 lawbar = in_be32(&law[i].lawbar);
267 + u32 lawar = in_be32(&law[i].lawar);
268 +
269 + if ((lawar & LAWAR_MASK) == LAWAR_MATCH)
270 + /* Extract the upper four bits */
271 + return (br & BR_BA) | ((lawbar & LAWBAR_MASK) << 12);
272 + }
273 +
274 + return 0;
275 +#endif
276 +}
277 +
278 /**
279 * p1022ds_set_monitor_port: switch the output to a different monitor port
280 - *
281 */
282 static void p1022ds_set_monitor_port(enum fsl_diu_monitor_port port)
283 {
284 struct device_node *guts_node;
285 - struct device_node *indirect_node = NULL;
286 + struct device_node *lbc_node = NULL;
287 + struct device_node *law_node = NULL;
288 struct ccsr_guts __iomem *guts;
289 + struct fsl_lbc_regs *lbc = NULL;
290 + void *ecm = NULL;
291 u8 __iomem *lbc_lcs0_ba = NULL;
292 u8 __iomem *lbc_lcs1_ba = NULL;
293 + phys_addr_t cs0_addr, cs1_addr;
294 + const __be32 *iprop;
295 + unsigned int num_laws;
296 u8 b;
297
298 /* Map the global utilities registers. */
299 @@ -168,25 +225,43 @@ static void p1022ds_set_monitor_port(enum fsl_diu_monitor_port port)
300 goto exit;
301 }
302
303 - indirect_node = of_find_compatible_node(NULL, NULL,
304 - "fsl,p1022ds-indirect-pixis");
305 - if (!indirect_node) {
306 - pr_err("p1022ds: missing pixis indirect mode node\n");
307 + lbc_node = of_find_compatible_node(NULL, NULL, "fsl,p1022-elbc");
308 + if (!lbc_node) {
309 + pr_err("p1022ds: missing localbus node\n");
310 goto exit;
311 }
312
313 - lbc_lcs0_ba = of_iomap(indirect_node, 0);
314 - if (!lbc_lcs0_ba) {
315 - pr_err("p1022ds: could not map localbus chip select 0\n");
316 + lbc = of_iomap(lbc_node, 0);
317 + if (!lbc) {
318 + pr_err("p1022ds: could not map localbus node\n");
319 goto exit;
320 }
321
322 - lbc_lcs1_ba = of_iomap(indirect_node, 1);
323 - if (!lbc_lcs1_ba) {
324 - pr_err("p1022ds: could not map localbus chip select 1\n");
325 + law_node = of_find_compatible_node(NULL, NULL, "fsl,ecm-law");
326 + if (!law_node) {
327 + pr_err("p1022ds: missing local access window node\n");
328 goto exit;
329 }
330
331 + ecm = of_iomap(law_node, 0);
332 + if (!ecm) {
333 + pr_err("p1022ds: could not map local access window node\n");
334 + goto exit;
335 + }
336 +
337 + iprop = of_get_property(law_node, "fsl,num-laws", 0);
338 + if (!iprop) {
339 + pr_err("p1022ds: LAW node is missing fsl,num-laws property\n");
340 + goto exit;
341 + }
342 + num_laws = be32_to_cpup(iprop);
343 +
344 + cs0_addr = lbc_br_to_phys(ecm, num_laws, in_be32(&lbc->bank[0].br));
345 + cs1_addr = lbc_br_to_phys(ecm, num_laws, in_be32(&lbc->bank[1].br));
346 +
347 + lbc_lcs0_ba = ioremap(cs0_addr, 1);
348 + lbc_lcs1_ba = ioremap(cs1_addr, 1);
349 +
350 /* Make sure we're in indirect mode first. */
351 if ((in_be32(&guts->pmuxcr) & PMUXCR_ELBCDIU_MASK) !=
352 PMUXCR_ELBCDIU_DIU) {
353 @@ -254,10 +329,15 @@ exit:
354 iounmap(lbc_lcs1_ba);
355 if (lbc_lcs0_ba)
356 iounmap(lbc_lcs0_ba);
357 + if (lbc)
358 + iounmap(lbc);
359 + if (ecm)
360 + iounmap(ecm);
361 if (guts)
362 iounmap(guts);
363
364 - of_node_put(indirect_node);
365 + of_node_put(law_node);
366 + of_node_put(lbc_node);
367 of_node_put(guts_node);
368 }
369
370 diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
371 index 4cb375c..fb50631 100644
372 --- a/arch/powerpc/platforms/pseries/eeh_event.c
373 +++ b/arch/powerpc/platforms/pseries/eeh_event.c
374 @@ -85,8 +85,10 @@ static int eeh_event_handler(void * dummy)
375 set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */
376 edev = handle_eeh_events(event);
377
378 - eeh_clear_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING);
379 - pci_dev_put(edev->pdev);
380 + if (edev) {
381 + eeh_clear_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING);
382 + pci_dev_put(edev->pdev);
383 + }
384
385 kfree(event);
386 mutex_unlock(&eeh_event_mutex);
387 diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
388 index 5d09e40..5d211f7 100644
389 --- a/arch/s390/include/asm/mmu_context.h
390 +++ b/arch/s390/include/asm/mmu_context.h
391 @@ -13,7 +13,6 @@
392 #include <asm/uaccess.h>
393 #include <asm/tlbflush.h>
394 #include <asm/ctl_reg.h>
395 -#include <asm-generic/mm_hooks.h>
396
397 static inline int init_new_context(struct task_struct *tsk,
398 struct mm_struct *mm)
399 @@ -93,4 +92,17 @@ static inline void activate_mm(struct mm_struct *prev,
400 switch_mm(prev, next, current);
401 }
402
403 +static inline void arch_dup_mmap(struct mm_struct *oldmm,
404 + struct mm_struct *mm)
405 +{
406 +#ifdef CONFIG_64BIT
407 + if (oldmm->context.asce_limit < mm->context.asce_limit)
408 + crst_table_downgrade(mm, oldmm->context.asce_limit);
409 +#endif
410 +}
411 +
412 +static inline void arch_exit_mmap(struct mm_struct *mm)
413 +{
414 +}
415 +
416 #endif /* __S390_MMU_CONTEXT_H */
417 diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
418 index d499b30..8b6f62e 100644
419 --- a/arch/s390/include/asm/processor.h
420 +++ b/arch/s390/include/asm/processor.h
421 @@ -129,7 +129,9 @@ struct stack_frame {
422 regs->psw.mask = psw_user_bits | PSW_MASK_BA; \
423 regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
424 regs->gprs[15] = new_stackp; \
425 + __tlb_flush_mm(current->mm); \
426 crst_table_downgrade(current->mm, 1UL << 31); \
427 + update_mm(current->mm, current); \
428 } while (0)
429
430 /* Forward declaration, a strange C thing */
431 diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
432 index 6e0073e..07c7bf4 100644
433 --- a/arch/s390/kernel/processor.c
434 +++ b/arch/s390/kernel/processor.c
435 @@ -26,12 +26,14 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id);
436 void __cpuinit cpu_init(void)
437 {
438 struct cpuid *id = &per_cpu(cpu_id, smp_processor_id());
439 + struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
440
441 get_cpu_id(id);
442 atomic_inc(&init_mm.mm_count);
443 current->active_mm = &init_mm;
444 BUG_ON(current->mm);
445 enter_lazy_tlb(&init_mm, current);
446 + memset(idle, 0, sizeof(*idle));
447 }
448
449 /*
450 diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
451 index 1f77227..c7b8822 100644
452 --- a/arch/s390/kernel/smp.c
453 +++ b/arch/s390/kernel/smp.c
454 @@ -1034,14 +1034,11 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
455 unsigned int cpu = (unsigned int)(long)hcpu;
456 struct cpu *c = &pcpu_devices[cpu].cpu;
457 struct device *s = &c->dev;
458 - struct s390_idle_data *idle;
459 int err = 0;
460
461 switch (action) {
462 case CPU_ONLINE:
463 case CPU_ONLINE_FROZEN:
464 - idle = &per_cpu(s390_idle, cpu);
465 - memset(idle, 0, sizeof(struct s390_idle_data));
466 err = sysfs_create_group(&s->kobj, &cpu_online_attr_group);
467 break;
468 case CPU_DEAD:
469 diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
470 index 4e66860..f2b11ee 100644
471 --- a/arch/s390/mm/fault.c
472 +++ b/arch/s390/mm/fault.c
473 @@ -443,6 +443,7 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
474 struct pt_regs regs;
475 int access, fault;
476
477 + /* Emulate a uaccess fault from kernel mode. */
478 regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
479 if (!irqs_disabled())
480 regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT;
481 @@ -452,12 +453,12 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
482 regs.int_parm_long = (uaddr & PAGE_MASK) | 2;
483 access = write ? VM_WRITE : VM_READ;
484 fault = do_exception(&regs, access);
485 - if (unlikely(fault)) {
486 - if (fault & VM_FAULT_OOM)
487 - return -EFAULT;
488 - else if (fault & VM_FAULT_SIGBUS)
489 - do_sigbus(&regs);
490 - }
491 + /*
492 + * Since the fault happened in kernel mode while performing a uaccess
493 + * all we need to do now is emulating a fixup in case "fault" is not
494 + * zero.
495 + * For the calling uaccess functions this results always in -EFAULT.
496 + */
497 return fault ? -EFAULT : 0;
498 }
499
500 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
501 index 2857c48..a64fe53 100644
502 --- a/arch/s390/mm/mmap.c
503 +++ b/arch/s390/mm/mmap.c
504 @@ -105,9 +105,15 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
505
506 int s390_mmap_check(unsigned long addr, unsigned long len)
507 {
508 + int rc;
509 +
510 if (!is_compat_task() &&
511 - len >= TASK_SIZE && TASK_SIZE < (1UL << 53))
512 - return crst_table_upgrade(current->mm, 1UL << 53);
513 + len >= TASK_SIZE && TASK_SIZE < (1UL << 53)) {
514 + rc = crst_table_upgrade(current->mm, 1UL << 53);
515 + if (rc)
516 + return rc;
517 + update_mm(current->mm, current);
518 + }
519 return 0;
520 }
521
522 @@ -127,6 +133,7 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr,
523 rc = crst_table_upgrade(mm, 1UL << 53);
524 if (rc)
525 return (unsigned long) rc;
526 + update_mm(mm, current);
527 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
528 }
529 return area;
530 @@ -149,6 +156,7 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr,
531 rc = crst_table_upgrade(mm, 1UL << 53);
532 if (rc)
533 return (unsigned long) rc;
534 + update_mm(mm, current);
535 area = arch_get_unmapped_area_topdown(filp, addr, len,
536 pgoff, flags);
537 }
538 diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
539 index 6e765bf..87f0efd 100644
540 --- a/arch/s390/mm/pgtable.c
541 +++ b/arch/s390/mm/pgtable.c
542 @@ -85,7 +85,6 @@ repeat:
543 crst_table_free(mm, table);
544 if (mm->context.asce_limit < limit)
545 goto repeat;
546 - update_mm(mm, current);
547 return 0;
548 }
549
550 @@ -93,9 +92,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit)
551 {
552 pgd_t *pgd;
553
554 - if (mm->context.asce_limit <= limit)
555 - return;
556 - __tlb_flush_mm(mm);
557 while (mm->context.asce_limit > limit) {
558 pgd = mm->pgd;
559 switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) {
560 @@ -118,7 +114,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit)
561 mm->task_size = mm->context.asce_limit;
562 crst_table_free(mm, (unsigned long *) pgd);
563 }
564 - update_mm(mm, current);
565 }
566 #endif
567
568 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
569 index 61604ae..0d2db0e 100644
570 --- a/arch/x86/kernel/cpu/mcheck/mce.c
571 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
572 @@ -1180,6 +1180,7 @@ void mce_notify_process(void)
573 {
574 unsigned long pfn;
575 struct mce_info *mi = mce_find_info();
576 + int flags = MF_ACTION_REQUIRED;
577
578 if (!mi)
579 mce_panic("Lost physical address for unconsumed uncorrectable error", NULL, NULL);
580 @@ -1194,8 +1195,9 @@ void mce_notify_process(void)
581 * doomed. We still need to mark the page as poisoned and alert any
582 * other users of the page.
583 */
584 - if (memory_failure(pfn, MCE_VECTOR, MF_ACTION_REQUIRED) < 0 ||
585 - mi->restartable == 0) {
586 + if (!mi->restartable)
587 + flags |= MF_MUST_KILL;
588 + if (memory_failure(pfn, MCE_VECTOR, flags) < 0) {
589 pr_err("Memory error not recovered");
590 force_sig(SIGBUS, current);
591 }
592 diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
593 index 6512b20..d1fcbc0 100644
594 --- a/drivers/acpi/ac.c
595 +++ b/drivers/acpi/ac.c
596 @@ -292,7 +292,9 @@ static int acpi_ac_add(struct acpi_device *device)
597 ac->charger.properties = ac_props;
598 ac->charger.num_properties = ARRAY_SIZE(ac_props);
599 ac->charger.get_property = get_ac_property;
600 - power_supply_register(&ac->device->dev, &ac->charger);
601 + result = power_supply_register(&ac->device->dev, &ac->charger);
602 + if (result)
603 + goto end;
604
605 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
606 acpi_device_name(device), acpi_device_bid(device),
607 diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
608 index 6686b1e..00a7836 100644
609 --- a/drivers/acpi/apei/apei-base.c
610 +++ b/drivers/acpi/apei/apei-base.c
611 @@ -586,6 +586,11 @@ static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr,
612 }
613 *access_bit_width = 1UL << (access_size_code + 2);
614
615 + /* Fixup common BIOS bug */
616 + if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
617 + *access_bit_width < 32)
618 + *access_bit_width = 32;
619 +
620 if ((bit_width + bit_offset) > *access_bit_width) {
621 pr_warning(FW_BUG APEI_PFX
622 "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
623 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
624 index 3085f9b..f7eff25 100644
625 --- a/drivers/base/power/main.c
626 +++ b/drivers/base/power/main.c
627 @@ -979,8 +979,16 @@ static int dpm_suspend_late(pm_message_t state)
628 int dpm_suspend_end(pm_message_t state)
629 {
630 int error = dpm_suspend_late(state);
631 + if (error)
632 + return error;
633
634 - return error ? : dpm_suspend_noirq(state);
635 + error = dpm_suspend_noirq(state);
636 + if (error) {
637 + dpm_resume_early(state);
638 + return error;
639 + }
640 +
641 + return 0;
642 }
643 EXPORT_SYMBOL_GPL(dpm_suspend_end);
644
645 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
646 index ad7c732..08427ab 100644
647 --- a/drivers/char/tpm/tpm.c
648 +++ b/drivers/char/tpm/tpm.c
649 @@ -827,10 +827,10 @@ EXPORT_SYMBOL_GPL(tpm_pcr_extend);
650 int tpm_do_selftest(struct tpm_chip *chip)
651 {
652 int rc;
653 - u8 digest[TPM_DIGEST_SIZE];
654 unsigned int loops;
655 unsigned int delay_msec = 1000;
656 unsigned long duration;
657 + struct tpm_cmd_t cmd;
658
659 duration = tpm_calc_ordinal_duration(chip,
660 TPM_ORD_CONTINUE_SELFTEST);
661 @@ -845,7 +845,15 @@ int tpm_do_selftest(struct tpm_chip *chip)
662 return rc;
663
664 do {
665 - rc = __tpm_pcr_read(chip, 0, digest);
666 + /* Attempt to read a PCR value */
667 + cmd.header.in = pcrread_header;
668 + cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0);
669 + rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE);
670 +
671 + if (rc < TPM_HEADER_SIZE)
672 + return -EFAULT;
673 +
674 + rc = be32_to_cpu(cmd.header.out.return_code);
675 if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
676 dev_info(chip->dev,
677 "TPM is disabled/deactivated (0x%X)\n", rc);
678 diff --git a/drivers/gpu/drm/nouveau/nva3_copy.fuc b/drivers/gpu/drm/nouveau/nva3_copy.fuc
679 index abc3662..219850d 100644
680 --- a/drivers/gpu/drm/nouveau/nva3_copy.fuc
681 +++ b/drivers/gpu/drm/nouveau/nva3_copy.fuc
682 @@ -119,9 +119,9 @@ dispatch_dma:
683 // mthd 0x030c-0x0340, various stuff
684 .b16 0xc3 14
685 .b32 #ctx_src_address_high ~0x000000ff
686 -.b32 #ctx_src_address_low ~0xfffffff0
687 +.b32 #ctx_src_address_low ~0xffffffff
688 .b32 #ctx_dst_address_high ~0x000000ff
689 -.b32 #ctx_dst_address_low ~0xfffffff0
690 +.b32 #ctx_dst_address_low ~0xffffffff
691 .b32 #ctx_src_pitch ~0x0007ffff
692 .b32 #ctx_dst_pitch ~0x0007ffff
693 .b32 #ctx_xcnt ~0x0000ffff
694 diff --git a/drivers/gpu/drm/nouveau/nva3_copy.fuc.h b/drivers/gpu/drm/nouveau/nva3_copy.fuc.h
695 index 1f33fbd..37d6de3 100644
696 --- a/drivers/gpu/drm/nouveau/nva3_copy.fuc.h
697 +++ b/drivers/gpu/drm/nouveau/nva3_copy.fuc.h
698 @@ -1,37 +1,72 @@
699 -uint32_t nva3_pcopy_data[] = {
700 +u32 nva3_pcopy_data[] = {
701 +/* 0x0000: ctx_object */
702 0x00000000,
703 +/* 0x0004: ctx_dma */
704 +/* 0x0004: ctx_dma_query */
705 0x00000000,
706 +/* 0x0008: ctx_dma_src */
707 0x00000000,
708 +/* 0x000c: ctx_dma_dst */
709 0x00000000,
710 +/* 0x0010: ctx_query_address_high */
711 0x00000000,
712 +/* 0x0014: ctx_query_address_low */
713 0x00000000,
714 +/* 0x0018: ctx_query_counter */
715 0x00000000,
716 +/* 0x001c: ctx_src_address_high */
717 0x00000000,
718 +/* 0x0020: ctx_src_address_low */
719 0x00000000,
720 +/* 0x0024: ctx_src_pitch */
721 0x00000000,
722 +/* 0x0028: ctx_src_tile_mode */
723 0x00000000,
724 +/* 0x002c: ctx_src_xsize */
725 0x00000000,
726 +/* 0x0030: ctx_src_ysize */
727 0x00000000,
728 +/* 0x0034: ctx_src_zsize */
729 0x00000000,
730 +/* 0x0038: ctx_src_zoff */
731 0x00000000,
732 +/* 0x003c: ctx_src_xoff */
733 0x00000000,
734 +/* 0x0040: ctx_src_yoff */
735 0x00000000,
736 +/* 0x0044: ctx_src_cpp */
737 0x00000000,
738 +/* 0x0048: ctx_dst_address_high */
739 0x00000000,
740 +/* 0x004c: ctx_dst_address_low */
741 0x00000000,
742 +/* 0x0050: ctx_dst_pitch */
743 0x00000000,
744 +/* 0x0054: ctx_dst_tile_mode */
745 0x00000000,
746 +/* 0x0058: ctx_dst_xsize */
747 0x00000000,
748 +/* 0x005c: ctx_dst_ysize */
749 0x00000000,
750 +/* 0x0060: ctx_dst_zsize */
751 0x00000000,
752 +/* 0x0064: ctx_dst_zoff */
753 0x00000000,
754 +/* 0x0068: ctx_dst_xoff */
755 0x00000000,
756 +/* 0x006c: ctx_dst_yoff */
757 0x00000000,
758 +/* 0x0070: ctx_dst_cpp */
759 0x00000000,
760 +/* 0x0074: ctx_format */
761 0x00000000,
762 +/* 0x0078: ctx_swz_const0 */
763 0x00000000,
764 +/* 0x007c: ctx_swz_const1 */
765 0x00000000,
766 +/* 0x0080: ctx_xcnt */
767 0x00000000,
768 +/* 0x0084: ctx_ycnt */
769 0x00000000,
770 0x00000000,
771 0x00000000,
772 @@ -63,6 +98,7 @@ uint32_t nva3_pcopy_data[] = {
773 0x00000000,
774 0x00000000,
775 0x00000000,
776 +/* 0x0100: dispatch_table */
777 0x00010000,
778 0x00000000,
779 0x00000000,
780 @@ -73,6 +109,7 @@ uint32_t nva3_pcopy_data[] = {
781 0x00010162,
782 0x00000000,
783 0x00030060,
784 +/* 0x0128: dispatch_dma */
785 0x00010170,
786 0x00000000,
787 0x00010170,
788 @@ -118,11 +155,11 @@ uint32_t nva3_pcopy_data[] = {
789 0x0000001c,
790 0xffffff00,
791 0x00000020,
792 - 0x0000000f,
793 + 0x00000000,
794 0x00000048,
795 0xffffff00,
796 0x0000004c,
797 - 0x0000000f,
798 + 0x00000000,
799 0x00000024,
800 0xfff80000,
801 0x00000050,
802 @@ -146,7 +183,8 @@ uint32_t nva3_pcopy_data[] = {
803 0x00000800,
804 };
805
806 -uint32_t nva3_pcopy_code[] = {
807 +u32 nva3_pcopy_code[] = {
808 +/* 0x0000: main */
809 0x04fe04bd,
810 0x3517f000,
811 0xf10010fe,
812 @@ -158,23 +196,31 @@ uint32_t nva3_pcopy_code[] = {
813 0x17f11031,
814 0x27f01200,
815 0x0012d003,
816 +/* 0x002f: spin */
817 0xf40031f4,
818 0x0ef40028,
819 +/* 0x0035: ih */
820 0x8001cffd,
821 0xf40812c4,
822 0x21f4060b,
823 +/* 0x0041: ih_no_chsw */
824 0x0412c472,
825 0xf4060bf4,
826 +/* 0x004a: ih_no_cmd */
827 0x11c4c321,
828 0x4001d00c,
829 +/* 0x0052: swctx */
830 0x47f101f8,
831 0x4bfe7700,
832 0x0007fe00,
833 0xf00204b9,
834 0x01f40643,
835 0x0604fa09,
836 +/* 0x006b: swctx_load */
837 0xfa060ef4,
838 +/* 0x006e: swctx_done */
839 0x03f80504,
840 +/* 0x0072: chsw */
841 0x27f100f8,
842 0x23cf1400,
843 0x1e3fc800,
844 @@ -183,18 +229,22 @@ uint32_t nva3_pcopy_code[] = {
845 0x1e3af052,
846 0xf00023d0,
847 0x24d00147,
848 +/* 0x0093: chsw_no_unload */
849 0xcf00f880,
850 0x3dc84023,
851 0x220bf41e,
852 0xf40131f4,
853 0x57f05221,
854 0x0367f004,
855 +/* 0x00a8: chsw_load_ctx_dma */
856 0xa07856bc,
857 0xb6018068,
858 0x87d00884,
859 0x0162b600,
860 +/* 0x00bb: chsw_finish_load */
861 0xf0f018f4,
862 0x23d00237,
863 +/* 0x00c3: dispatch */
864 0xf100f880,
865 0xcf190037,
866 0x33cf4032,
867 @@ -202,6 +252,7 @@ uint32_t nva3_pcopy_code[] = {
868 0x1024b607,
869 0x010057f1,
870 0x74bd64bd,
871 +/* 0x00dc: dispatch_loop */
872 0x58005658,
873 0x50b60157,
874 0x0446b804,
875 @@ -211,6 +262,7 @@ uint32_t nva3_pcopy_code[] = {
876 0xb60276bb,
877 0x57bb0374,
878 0xdf0ef400,
879 +/* 0x0100: dispatch_valid_mthd */
880 0xb60246bb,
881 0x45bb0344,
882 0x01459800,
883 @@ -220,31 +272,41 @@ uint32_t nva3_pcopy_code[] = {
884 0xb0014658,
885 0x1bf40064,
886 0x00538009,
887 +/* 0x0127: dispatch_cmd */
888 0xf4300ef4,
889 0x55f90132,
890 0xf40c01f4,
891 +/* 0x0132: dispatch_invalid_bitfield */
892 0x25f0250e,
893 +/* 0x0135: dispatch_illegal_mthd */
894 0x0125f002,
895 +/* 0x0138: dispatch_error */
896 0x100047f1,
897 0xd00042d0,
898 0x27f04043,
899 0x0002d040,
900 +/* 0x0148: hostirq_wait */
901 0xf08002cf,
902 0x24b04024,
903 0xf71bf400,
904 +/* 0x0154: dispatch_done */
905 0x1d0027f1,
906 0xd00137f0,
907 0x00f80023,
908 +/* 0x0160: cmd_nop */
909 +/* 0x0162: cmd_pm_trigger */
910 0x27f100f8,
911 0x34bd2200,
912 0xd00233f0,
913 0x00f80023,
914 +/* 0x0170: cmd_dma */
915 0x012842b7,
916 0xf00145b6,
917 0x43801e39,
918 0x0040b701,
919 0x0644b606,
920 0xf80043d0,
921 +/* 0x0189: cmd_exec_set_format */
922 0xf030f400,
923 0xb00001b0,
924 0x01b00101,
925 @@ -256,20 +318,26 @@ uint32_t nva3_pcopy_code[] = {
926 0x70b63847,
927 0x0232f401,
928 0x94bd84bd,
929 +/* 0x01b4: ncomp_loop */
930 0xb60f4ac4,
931 0xb4bd0445,
932 +/* 0x01bc: bpc_loop */
933 0xf404a430,
934 0xa5ff0f18,
935 0x00cbbbc0,
936 0xf40231f4,
937 +/* 0x01ce: cmp_c0 */
938 0x1bf4220e,
939 0x10c7f00c,
940 0xf400cbbb,
941 +/* 0x01da: cmp_c1 */
942 0xa430160e,
943 0x0c18f406,
944 0xbb14c7f0,
945 0x0ef400cb,
946 +/* 0x01e9: cmp_zero */
947 0x80c7f107,
948 +/* 0x01ed: bpc_next */
949 0x01c83800,
950 0xb60180b6,
951 0xb5b801b0,
952 @@ -280,6 +348,7 @@ uint32_t nva3_pcopy_code[] = {
953 0x98110680,
954 0x68fd2008,
955 0x0502f400,
956 +/* 0x0216: dst_xcnt */
957 0x75fd64bd,
958 0x1c078000,
959 0xf10078fd,
960 @@ -304,6 +373,7 @@ uint32_t nva3_pcopy_code[] = {
961 0x980056d0,
962 0x56d01f06,
963 0x1030f440,
964 +/* 0x0276: cmd_exec_set_surface_tiled */
965 0x579800f8,
966 0x6879c70a,
967 0xb66478c7,
968 @@ -311,9 +381,11 @@ uint32_t nva3_pcopy_code[] = {
969 0x0e76b060,
970 0xf0091bf4,
971 0x0ef40477,
972 +/* 0x0291: xtile64 */
973 0x027cf00f,
974 0xfd1170b6,
975 0x77f00947,
976 +/* 0x029d: xtileok */
977 0x0f5a9806,
978 0xfd115b98,
979 0xb7f000ab,
980 @@ -371,6 +443,7 @@ uint32_t nva3_pcopy_code[] = {
981 0x67d00600,
982 0x0060b700,
983 0x0068d004,
984 +/* 0x0382: cmd_exec_set_surface_linear */
985 0x6cf000f8,
986 0x0260b702,
987 0x0864b602,
988 @@ -381,13 +454,16 @@ uint32_t nva3_pcopy_code[] = {
989 0xb70067d0,
990 0x98040060,
991 0x67d00957,
992 +/* 0x03ab: cmd_exec_wait */
993 0xf900f800,
994 0xf110f900,
995 0xb6080007,
996 +/* 0x03b6: loop */
997 0x01cf0604,
998 0x0114f000,
999 0xfcfa1bf4,
1000 0xf800fc10,
1001 +/* 0x03c5: cmd_exec_query */
1002 0x0d34c800,
1003 0xf5701bf4,
1004 0xf103ab21,
1005 @@ -417,6 +493,7 @@ uint32_t nva3_pcopy_code[] = {
1006 0x47f10153,
1007 0x44b60800,
1008 0x0045d006,
1009 +/* 0x0438: query_counter */
1010 0x03ab21f5,
1011 0x080c47f1,
1012 0x980644b6,
1013 @@ -439,11 +516,13 @@ uint32_t nva3_pcopy_code[] = {
1014 0x47f10153,
1015 0x44b60800,
1016 0x0045d006,
1017 +/* 0x0492: cmd_exec */
1018 0x21f500f8,
1019 0x3fc803ab,
1020 0x0e0bf400,
1021 0x018921f5,
1022 0x020047f1,
1023 +/* 0x04a7: cmd_exec_no_format */
1024 0xf11e0ef4,
1025 0xb6081067,
1026 0x77f00664,
1027 @@ -451,19 +530,24 @@ uint32_t nva3_pcopy_code[] = {
1028 0x981c0780,
1029 0x67d02007,
1030 0x4067d000,
1031 +/* 0x04c2: cmd_exec_init_src_surface */
1032 0x32f444bd,
1033 0xc854bd02,
1034 0x0bf4043f,
1035 0x8221f50a,
1036 0x0a0ef403,
1037 +/* 0x04d4: src_tiled */
1038 0x027621f5,
1039 +/* 0x04db: cmd_exec_init_dst_surface */
1040 0xf40749f0,
1041 0x57f00231,
1042 0x083fc82c,
1043 0xf50a0bf4,
1044 0xf4038221,
1045 +/* 0x04ee: dst_tiled */
1046 0x21f50a0e,
1047 0x49f00276,
1048 +/* 0x04f5: cmd_exec_kick */
1049 0x0057f108,
1050 0x0654b608,
1051 0xd0210698,
1052 @@ -473,6 +557,8 @@ uint32_t nva3_pcopy_code[] = {
1053 0xc80054d0,
1054 0x0bf40c3f,
1055 0xc521f507,
1056 +/* 0x0519: cmd_exec_done */
1057 +/* 0x051b: cmd_wrcache_flush */
1058 0xf100f803,
1059 0xbd220027,
1060 0x0133f034,
1061 diff --git a/drivers/gpu/drm/nouveau/nvc0_copy.fuc.h b/drivers/gpu/drm/nouveau/nvc0_copy.fuc.h
1062 index a8d1745..cd879f3 100644
1063 --- a/drivers/gpu/drm/nouveau/nvc0_copy.fuc.h
1064 +++ b/drivers/gpu/drm/nouveau/nvc0_copy.fuc.h
1065 @@ -1,34 +1,65 @@
1066 -uint32_t nvc0_pcopy_data[] = {
1067 +u32 nvc0_pcopy_data[] = {
1068 +/* 0x0000: ctx_object */
1069 0x00000000,
1070 +/* 0x0004: ctx_query_address_high */
1071 0x00000000,
1072 +/* 0x0008: ctx_query_address_low */
1073 0x00000000,
1074 +/* 0x000c: ctx_query_counter */
1075 0x00000000,
1076 +/* 0x0010: ctx_src_address_high */
1077 0x00000000,
1078 +/* 0x0014: ctx_src_address_low */
1079 0x00000000,
1080 +/* 0x0018: ctx_src_pitch */
1081 0x00000000,
1082 +/* 0x001c: ctx_src_tile_mode */
1083 0x00000000,
1084 +/* 0x0020: ctx_src_xsize */
1085 0x00000000,
1086 +/* 0x0024: ctx_src_ysize */
1087 0x00000000,
1088 +/* 0x0028: ctx_src_zsize */
1089 0x00000000,
1090 +/* 0x002c: ctx_src_zoff */
1091 0x00000000,
1092 +/* 0x0030: ctx_src_xoff */
1093 0x00000000,
1094 +/* 0x0034: ctx_src_yoff */
1095 0x00000000,
1096 +/* 0x0038: ctx_src_cpp */
1097 0x00000000,
1098 +/* 0x003c: ctx_dst_address_high */
1099 0x00000000,
1100 +/* 0x0040: ctx_dst_address_low */
1101 0x00000000,
1102 +/* 0x0044: ctx_dst_pitch */
1103 0x00000000,
1104 +/* 0x0048: ctx_dst_tile_mode */
1105 0x00000000,
1106 +/* 0x004c: ctx_dst_xsize */
1107 0x00000000,
1108 +/* 0x0050: ctx_dst_ysize */
1109 0x00000000,
1110 +/* 0x0054: ctx_dst_zsize */
1111 0x00000000,
1112 +/* 0x0058: ctx_dst_zoff */
1113 0x00000000,
1114 +/* 0x005c: ctx_dst_xoff */
1115 0x00000000,
1116 +/* 0x0060: ctx_dst_yoff */
1117 0x00000000,
1118 +/* 0x0064: ctx_dst_cpp */
1119 0x00000000,
1120 +/* 0x0068: ctx_format */
1121 0x00000000,
1122 +/* 0x006c: ctx_swz_const0 */
1123 0x00000000,
1124 +/* 0x0070: ctx_swz_const1 */
1125 0x00000000,
1126 +/* 0x0074: ctx_xcnt */
1127 0x00000000,
1128 +/* 0x0078: ctx_ycnt */
1129 0x00000000,
1130 0x00000000,
1131 0x00000000,
1132 @@ -63,6 +94,7 @@ uint32_t nvc0_pcopy_data[] = {
1133 0x00000000,
1134 0x00000000,
1135 0x00000000,
1136 +/* 0x0100: dispatch_table */
1137 0x00010000,
1138 0x00000000,
1139 0x00000000,
1140 @@ -111,11 +143,11 @@ uint32_t nvc0_pcopy_data[] = {
1141 0x00000010,
1142 0xffffff00,
1143 0x00000014,
1144 - 0x0000000f,
1145 + 0x00000000,
1146 0x0000003c,
1147 0xffffff00,
1148 0x00000040,
1149 - 0x0000000f,
1150 + 0x00000000,
1151 0x00000018,
1152 0xfff80000,
1153 0x00000044,
1154 @@ -139,7 +171,8 @@ uint32_t nvc0_pcopy_data[] = {
1155 0x00000800,
1156 };
1157
1158 -uint32_t nvc0_pcopy_code[] = {
1159 +u32 nvc0_pcopy_code[] = {
1160 +/* 0x0000: main */
1161 0x04fe04bd,
1162 0x3517f000,
1163 0xf10010fe,
1164 @@ -151,15 +184,20 @@ uint32_t nvc0_pcopy_code[] = {
1165 0x17f11031,
1166 0x27f01200,
1167 0x0012d003,
1168 +/* 0x002f: spin */
1169 0xf40031f4,
1170 0x0ef40028,
1171 +/* 0x0035: ih */
1172 0x8001cffd,
1173 0xf40812c4,
1174 0x21f4060b,
1175 +/* 0x0041: ih_no_chsw */
1176 0x0412c4ca,
1177 0xf5070bf4,
1178 +/* 0x004b: ih_no_cmd */
1179 0xc4010221,
1180 0x01d00c11,
1181 +/* 0x0053: swctx */
1182 0xf101f840,
1183 0xfe770047,
1184 0x47f1004b,
1185 @@ -188,8 +226,11 @@ uint32_t nvc0_pcopy_code[] = {
1186 0xf00204b9,
1187 0x01f40643,
1188 0x0604fa09,
1189 +/* 0x00c3: swctx_load */
1190 0xfa060ef4,
1191 +/* 0x00c6: swctx_done */
1192 0x03f80504,
1193 +/* 0x00ca: chsw */
1194 0x27f100f8,
1195 0x23cf1400,
1196 0x1e3fc800,
1197 @@ -198,18 +239,22 @@ uint32_t nvc0_pcopy_code[] = {
1198 0x1e3af053,
1199 0xf00023d0,
1200 0x24d00147,
1201 +/* 0x00eb: chsw_no_unload */
1202 0xcf00f880,
1203 0x3dc84023,
1204 0x090bf41e,
1205 0xf40131f4,
1206 +/* 0x00fa: chsw_finish_load */
1207 0x37f05321,
1208 0x8023d002,
1209 +/* 0x0102: dispatch */
1210 0x37f100f8,
1211 0x32cf1900,
1212 0x0033cf40,
1213 0x07ff24e4,
1214 0xf11024b6,
1215 0xbd010057,
1216 +/* 0x011b: dispatch_loop */
1217 0x5874bd64,
1218 0x57580056,
1219 0x0450b601,
1220 @@ -219,6 +264,7 @@ uint32_t nvc0_pcopy_code[] = {
1221 0xbb0f08f4,
1222 0x74b60276,
1223 0x0057bb03,
1224 +/* 0x013f: dispatch_valid_mthd */
1225 0xbbdf0ef4,
1226 0x44b60246,
1227 0x0045bb03,
1228 @@ -229,24 +275,33 @@ uint32_t nvc0_pcopy_code[] = {
1229 0x64b00146,
1230 0x091bf400,
1231 0xf4005380,
1232 +/* 0x0166: dispatch_cmd */
1233 0x32f4300e,
1234 0xf455f901,
1235 0x0ef40c01,
1236 +/* 0x0171: dispatch_invalid_bitfield */
1237 0x0225f025,
1238 +/* 0x0174: dispatch_illegal_mthd */
1239 +/* 0x0177: dispatch_error */
1240 0xf10125f0,
1241 0xd0100047,
1242 0x43d00042,
1243 0x4027f040,
1244 +/* 0x0187: hostirq_wait */
1245 0xcf0002d0,
1246 0x24f08002,
1247 0x0024b040,
1248 +/* 0x0193: dispatch_done */
1249 0xf1f71bf4,
1250 0xf01d0027,
1251 0x23d00137,
1252 +/* 0x019f: cmd_nop */
1253 0xf800f800,
1254 +/* 0x01a1: cmd_pm_trigger */
1255 0x0027f100,
1256 0xf034bd22,
1257 0x23d00233,
1258 +/* 0x01af: cmd_exec_set_format */
1259 0xf400f800,
1260 0x01b0f030,
1261 0x0101b000,
1262 @@ -258,20 +313,26 @@ uint32_t nvc0_pcopy_code[] = {
1263 0x3847c701,
1264 0xf40170b6,
1265 0x84bd0232,
1266 +/* 0x01da: ncomp_loop */
1267 0x4ac494bd,
1268 0x0445b60f,
1269 +/* 0x01e2: bpc_loop */
1270 0xa430b4bd,
1271 0x0f18f404,
1272 0xbbc0a5ff,
1273 0x31f400cb,
1274 0x220ef402,
1275 +/* 0x01f4: cmp_c0 */
1276 0xf00c1bf4,
1277 0xcbbb10c7,
1278 0x160ef400,
1279 +/* 0x0200: cmp_c1 */
1280 0xf406a430,
1281 0xc7f00c18,
1282 0x00cbbb14,
1283 +/* 0x020f: cmp_zero */
1284 0xf1070ef4,
1285 +/* 0x0213: bpc_next */
1286 0x380080c7,
1287 0x80b601c8,
1288 0x01b0b601,
1289 @@ -283,6 +344,7 @@ uint32_t nvc0_pcopy_code[] = {
1290 0x1d08980e,
1291 0xf40068fd,
1292 0x64bd0502,
1293 +/* 0x023c: dst_xcnt */
1294 0x800075fd,
1295 0x78fd1907,
1296 0x1057f100,
1297 @@ -307,15 +369,18 @@ uint32_t nvc0_pcopy_code[] = {
1298 0x1c069800,
1299 0xf44056d0,
1300 0x00f81030,
1301 +/* 0x029c: cmd_exec_set_surface_tiled */
1302 0xc7075798,
1303 0x78c76879,
1304 0x0380b664,
1305 0xb06077c7,
1306 0x1bf40e76,
1307 0x0477f009,
1308 +/* 0x02b7: xtile64 */
1309 0xf00f0ef4,
1310 0x70b6027c,
1311 0x0947fd11,
1312 +/* 0x02c3: xtileok */
1313 0x980677f0,
1314 0x5b980c5a,
1315 0x00abfd0e,
1316 @@ -374,6 +439,7 @@ uint32_t nvc0_pcopy_code[] = {
1317 0xb70067d0,
1318 0xd0040060,
1319 0x00f80068,
1320 +/* 0x03a8: cmd_exec_set_surface_linear */
1321 0xb7026cf0,
1322 0xb6020260,
1323 0x57980864,
1324 @@ -384,12 +450,15 @@ uint32_t nvc0_pcopy_code[] = {
1325 0x0060b700,
1326 0x06579804,
1327 0xf80067d0,
1328 +/* 0x03d1: cmd_exec_wait */
1329 0xf900f900,
1330 0x0007f110,
1331 0x0604b608,
1332 +/* 0x03dc: loop */
1333 0xf00001cf,
1334 0x1bf40114,
1335 0xfc10fcfa,
1336 +/* 0x03eb: cmd_exec_query */
1337 0xc800f800,
1338 0x1bf40d34,
1339 0xd121f570,
1340 @@ -419,6 +488,7 @@ uint32_t nvc0_pcopy_code[] = {
1341 0x0153f026,
1342 0x080047f1,
1343 0xd00644b6,
1344 +/* 0x045e: query_counter */
1345 0x21f50045,
1346 0x47f103d1,
1347 0x44b6080c,
1348 @@ -442,11 +512,13 @@ uint32_t nvc0_pcopy_code[] = {
1349 0x080047f1,
1350 0xd00644b6,
1351 0x00f80045,
1352 +/* 0x04b8: cmd_exec */
1353 0x03d121f5,
1354 0xf4003fc8,
1355 0x21f50e0b,
1356 0x47f101af,
1357 0x0ef40200,
1358 +/* 0x04cd: cmd_exec_no_format */
1359 0x1067f11e,
1360 0x0664b608,
1361 0x800177f0,
1362 @@ -454,18 +526,23 @@ uint32_t nvc0_pcopy_code[] = {
1363 0x1d079819,
1364 0xd00067d0,
1365 0x44bd4067,
1366 +/* 0x04e8: cmd_exec_init_src_surface */
1367 0xbd0232f4,
1368 0x043fc854,
1369 0xf50a0bf4,
1370 0xf403a821,
1371 +/* 0x04fa: src_tiled */
1372 0x21f50a0e,
1373 0x49f0029c,
1374 +/* 0x0501: cmd_exec_init_dst_surface */
1375 0x0231f407,
1376 0xc82c57f0,
1377 0x0bf4083f,
1378 0xa821f50a,
1379 0x0a0ef403,
1380 +/* 0x0514: dst_tiled */
1381 0x029c21f5,
1382 +/* 0x051b: cmd_exec_kick */
1383 0xf10849f0,
1384 0xb6080057,
1385 0x06980654,
1386 @@ -475,7 +552,9 @@ uint32_t nvc0_pcopy_code[] = {
1387 0x54d00546,
1388 0x0c3fc800,
1389 0xf5070bf4,
1390 +/* 0x053f: cmd_exec_done */
1391 0xf803eb21,
1392 +/* 0x0541: cmd_wrcache_flush */
1393 0x0027f100,
1394 0xf034bd22,
1395 0x23d00133,
1396 diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
1397 index c57d856..886b41f 100644
1398 --- a/drivers/gpu/drm/radeon/atombios_dp.c
1399 +++ b/drivers/gpu/drm/radeon/atombios_dp.c
1400 @@ -22,6 +22,7 @@
1401 *
1402 * Authors: Dave Airlie
1403 * Alex Deucher
1404 + * Jerome Glisse
1405 */
1406 #include "drmP.h"
1407 #include "radeon_drm.h"
1408 @@ -637,7 +638,6 @@ static bool radeon_dp_get_link_status(struct radeon_connector *radeon_connector,
1409 ret = radeon_dp_aux_native_read(radeon_connector, DP_LANE0_1_STATUS,
1410 link_status, DP_LINK_STATUS_SIZE, 100);
1411 if (ret <= 0) {
1412 - DRM_ERROR("displayport link status failed\n");
1413 return false;
1414 }
1415
1416 @@ -816,8 +816,10 @@ static int radeon_dp_link_train_cr(struct radeon_dp_link_train_info *dp_info)
1417 else
1418 mdelay(dp_info->rd_interval * 4);
1419
1420 - if (!radeon_dp_get_link_status(dp_info->radeon_connector, dp_info->link_status))
1421 + if (!radeon_dp_get_link_status(dp_info->radeon_connector, dp_info->link_status)) {
1422 + DRM_ERROR("displayport link status failed\n");
1423 break;
1424 + }
1425
1426 if (dp_clock_recovery_ok(dp_info->link_status, dp_info->dp_lane_count)) {
1427 clock_recovery = true;
1428 @@ -879,8 +881,10 @@ static int radeon_dp_link_train_ce(struct radeon_dp_link_train_info *dp_info)
1429 else
1430 mdelay(dp_info->rd_interval * 4);
1431
1432 - if (!radeon_dp_get_link_status(dp_info->radeon_connector, dp_info->link_status))
1433 + if (!radeon_dp_get_link_status(dp_info->radeon_connector, dp_info->link_status)) {
1434 + DRM_ERROR("displayport link status failed\n");
1435 break;
1436 + }
1437
1438 if (dp_channel_eq_ok(dp_info->link_status, dp_info->dp_lane_count)) {
1439 channel_eq = true;
1440 diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
1441 index 2d39f99..a3ae788 100644
1442 --- a/drivers/gpu/drm/radeon/atombios_encoders.c
1443 +++ b/drivers/gpu/drm/radeon/atombios_encoders.c
1444 @@ -1392,10 +1392,18 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1445 case DRM_MODE_DPMS_ON:
1446 /* some early dce3.2 boards have a bug in their transmitter control table */
1447 if ((rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV730) ||
1448 - ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev))
1449 + ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) {
1450 + if (ASIC_IS_DCE6(rdev)) {
1451 + /* It seems we need to call ATOM_ENCODER_CMD_SETUP again
1452 + * before reenabling encoder on DPMS ON, otherwise we never
1453 + * get picture
1454 + */
1455 + atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_SETUP, 0);
1456 + }
1457 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1458 - else
1459 + } else {
1460 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1461 + }
1462 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
1463 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1464 atombios_set_edp_panel_power(connector,
1465 diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1466 index 3c2e7a0..3fb7ca9 100644
1467 --- a/drivers/gpu/drm/radeon/radeon_connectors.c
1468 +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1469 @@ -64,14 +64,33 @@ void radeon_connector_hotplug(struct drm_connector *connector)
1470
1471 /* just deal with DP (not eDP) here. */
1472 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
1473 - int saved_dpms = connector->dpms;
1474 -
1475 - /* Only turn off the display it it's physically disconnected */
1476 - if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
1477 - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
1478 - else if (radeon_dp_needs_link_train(radeon_connector))
1479 - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
1480 - connector->dpms = saved_dpms;
1481 + struct radeon_connector_atom_dig *dig_connector =
1482 + radeon_connector->con_priv;
1483 +
1484 + /* if existing sink type was not DP no need to retrain */
1485 + if (dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT)
1486 + return;
1487 +
1488 + /* first get sink type as it may be reset after (un)plug */
1489 + dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
1490 + /* don't do anything if sink is not display port, i.e.,
1491 + * passive dp->(dvi|hdmi) adaptor
1492 + */
1493 + if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
1494 + int saved_dpms = connector->dpms;
1495 + /* Only turn off the display if it's physically disconnected */
1496 + if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
1497 + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
1498 + } else if (radeon_dp_needs_link_train(radeon_connector)) {
1499 + /* set it to OFF so that drm_helper_connector_dpms()
1500 + * won't return immediately since the current state
1501 + * is ON at this point.
1502 + */
1503 + connector->dpms = DRM_MODE_DPMS_OFF;
1504 + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
1505 + }
1506 + connector->dpms = saved_dpms;
1507 + }
1508 }
1509 }
1510
1511 diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
1512 index 2418cf6..cf723c4 100644
1513 --- a/drivers/gpu/drm/radeon/radeon_cs.c
1514 +++ b/drivers/gpu/drm/radeon/radeon_cs.c
1515 @@ -377,7 +377,7 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
1516 if (r) {
1517 DRM_ERROR("Failed to schedule IB !\n");
1518 }
1519 - return 0;
1520 + return r;
1521 }
1522
1523 static int radeon_bo_vm_update_pte(struct radeon_cs_parser *parser,
1524 diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
1525 index 42acc64..711e95a 100644
1526 --- a/drivers/gpu/drm/radeon/radeon_cursor.c
1527 +++ b/drivers/gpu/drm/radeon/radeon_cursor.c
1528 @@ -262,8 +262,14 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
1529 if (!(cursor_end & 0x7f))
1530 w--;
1531 }
1532 - if (w <= 0)
1533 + if (w <= 0) {
1534 w = 1;
1535 + cursor_end = x - xorigin + w;
1536 + if (!(cursor_end & 0x7f)) {
1537 + x--;
1538 + WARN_ON_ONCE(x < 0);
1539 + }
1540 + }
1541 }
1542 }
1543
1544 diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
1545 index df6a4db..80c6e8b 100644
1546 --- a/drivers/gpu/drm/radeon/radeon_object.c
1547 +++ b/drivers/gpu/drm/radeon/radeon_object.c
1548 @@ -136,7 +136,6 @@ int radeon_bo_create(struct radeon_device *rdev,
1549 acc_size = ttm_bo_dma_acc_size(&rdev->mman.bdev, size,
1550 sizeof(struct radeon_bo));
1551
1552 -retry:
1553 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
1554 if (bo == NULL)
1555 return -ENOMEM;
1556 @@ -150,6 +149,8 @@ retry:
1557 bo->surface_reg = -1;
1558 INIT_LIST_HEAD(&bo->list);
1559 INIT_LIST_HEAD(&bo->va);
1560 +
1561 +retry:
1562 radeon_ttm_placement_from_domain(bo, domain);
1563 /* Kernel allocation are uninterruptible */
1564 mutex_lock(&rdev->vram_mutex);
1565 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
1566 index dfe7d37..57ed244 100644
1567 --- a/drivers/iommu/amd_iommu.c
1568 +++ b/drivers/iommu/amd_iommu.c
1569 @@ -2254,6 +2254,18 @@ static int device_change_notifier(struct notifier_block *nb,
1570
1571 iommu_init_device(dev);
1572
1573 + /*
1574 + * dev_data is still NULL and
1575 + * got initialized in iommu_init_device
1576 + */
1577 + dev_data = get_dev_data(dev);
1578 +
1579 + if (iommu_pass_through || dev_data->iommu_v2) {
1580 + dev_data->passthrough = true;
1581 + attach_device(dev, pt_domain);
1582 + break;
1583 + }
1584 +
1585 domain = domain_for_device(dev);
1586
1587 /* allocate a protection domain if a device is added */
1588 @@ -2271,10 +2283,7 @@ static int device_change_notifier(struct notifier_block *nb,
1589
1590 dev_data = get_dev_data(dev);
1591
1592 - if (!dev_data->passthrough)
1593 - dev->archdata.dma_ops = &amd_iommu_dma_ops;
1594 - else
1595 - dev->archdata.dma_ops = &nommu_dma_ops;
1596 + dev->archdata.dma_ops = &amd_iommu_dma_ops;
1597
1598 break;
1599 case BUS_NOTIFY_DEL_DEVICE:
1600 diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
1601 index 036fe9b..a1f1bc8 100644
1602 --- a/drivers/iommu/amd_iommu_v2.c
1603 +++ b/drivers/iommu/amd_iommu_v2.c
1604 @@ -681,6 +681,8 @@ int amd_iommu_bind_pasid(struct pci_dev *pdev, int pasid,
1605
1606 atomic_set(&pasid_state->count, 1);
1607 init_waitqueue_head(&pasid_state->wq);
1608 + spin_lock_init(&pasid_state->lock);
1609 +
1610 pasid_state->task = task;
1611 pasid_state->mm = get_task_mm(task);
1612 pasid_state->device_state = dev_state;
1613 diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
1614 index e0a0ebe..1555f0b 100644
1615 --- a/drivers/md/dm-thin.c
1616 +++ b/drivers/md/dm-thin.c
1617 @@ -19,7 +19,7 @@
1618 /*
1619 * Tunable constants
1620 */
1621 -#define ENDIO_HOOK_POOL_SIZE 10240
1622 +#define ENDIO_HOOK_POOL_SIZE 1024
1623 #define DEFERRED_SET_SIZE 64
1624 #define MAPPING_POOL_SIZE 1024
1625 #define PRISON_CELLS 1024
1626 @@ -855,7 +855,7 @@ static void process_prepared_mapping(struct new_mapping *m)
1627
1628 if (m->err) {
1629 cell_error(m->cell);
1630 - return;
1631 + goto out;
1632 }
1633
1634 /*
1635 @@ -867,7 +867,7 @@ static void process_prepared_mapping(struct new_mapping *m)
1636 if (r) {
1637 DMERR("dm_thin_insert_block() failed");
1638 cell_error(m->cell);
1639 - return;
1640 + goto out;
1641 }
1642
1643 /*
1644 @@ -882,6 +882,7 @@ static void process_prepared_mapping(struct new_mapping *m)
1645 } else
1646 cell_defer(tc, m->cell, m->data_block);
1647
1648 +out:
1649 list_del(&m->list);
1650 mempool_free(m, tc->pool->mapping_pool);
1651 }
1652 diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
1653 index 69ef0be..504da71 100644
1654 --- a/drivers/mmc/host/sdhci-pci.c
1655 +++ b/drivers/mmc/host/sdhci-pci.c
1656 @@ -157,6 +157,7 @@ static const struct sdhci_pci_fixes sdhci_ene_714 = {
1657 static const struct sdhci_pci_fixes sdhci_cafe = {
1658 .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
1659 SDHCI_QUIRK_NO_BUSY_IRQ |
1660 + SDHCI_QUIRK_BROKEN_CARD_DETECTION |
1661 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
1662 };
1663
1664 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
1665 index ccefdeb..3c403aa 100644
1666 --- a/drivers/mmc/host/sdhci.c
1667 +++ b/drivers/mmc/host/sdhci.c
1668 @@ -27,6 +27,7 @@
1669
1670 #include <linux/mmc/mmc.h>
1671 #include <linux/mmc/host.h>
1672 +#include <linux/mmc/card.h>
1673
1674 #include "sdhci.h"
1675
1676 @@ -1245,6 +1246,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1677 struct sdhci_host *host;
1678 bool present;
1679 unsigned long flags;
1680 + u32 tuning_opcode;
1681
1682 host = mmc_priv(mmc);
1683
1684 @@ -1292,8 +1294,12 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1685 */
1686 if ((host->flags & SDHCI_NEEDS_RETUNING) &&
1687 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
1688 + /* eMMC uses cmd21 while sd and sdio use cmd19 */
1689 + tuning_opcode = mmc->card->type == MMC_TYPE_MMC ?
1690 + MMC_SEND_TUNING_BLOCK_HS200 :
1691 + MMC_SEND_TUNING_BLOCK;
1692 spin_unlock_irqrestore(&host->lock, flags);
1693 - sdhci_execute_tuning(mmc, mrq->cmd->opcode);
1694 + sdhci_execute_tuning(mmc, tuning_opcode);
1695 spin_lock_irqsave(&host->lock, flags);
1696
1697 /* Restore original mmc_request structure */
1698 diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
1699 index 8a3054b..5de74e7 100644
1700 --- a/drivers/net/caif/caif_serial.c
1701 +++ b/drivers/net/caif/caif_serial.c
1702 @@ -325,6 +325,9 @@ static int ldisc_open(struct tty_struct *tty)
1703
1704 sprintf(name, "cf%s", tty->name);
1705 dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
1706 + if (!dev)
1707 + return -ENOMEM;
1708 +
1709 ser = netdev_priv(dev);
1710 ser->tty = tty_kref_get(tty);
1711 ser->dev = dev;
1712 diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
1713 index 1ef0c92..65fe632 100644
1714 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
1715 +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
1716 @@ -267,7 +267,6 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
1717 dev_warn(&pdev->dev, "stop mac failed\n");
1718 atl1c_set_aspm(hw, false);
1719 netif_carrier_off(netdev);
1720 - netif_stop_queue(netdev);
1721 atl1c_phy_reset(hw);
1722 atl1c_phy_init(&adapter->hw);
1723 } else {
1724 diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
1725 index 8297e28..b8ade57 100644
1726 --- a/drivers/net/ethernet/broadcom/bnx2.c
1727 +++ b/drivers/net/ethernet/broadcom/bnx2.c
1728 @@ -5372,7 +5372,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
1729 int k, last;
1730
1731 if (skb == NULL) {
1732 - j++;
1733 + j = NEXT_TX_BD(j);
1734 continue;
1735 }
1736
1737 @@ -5384,8 +5384,8 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
1738 tx_buf->skb = NULL;
1739
1740 last = tx_buf->nr_frags;
1741 - j++;
1742 - for (k = 0; k < last; k++, j++) {
1743 + j = NEXT_TX_BD(j);
1744 + for (k = 0; k < last; k++, j = NEXT_TX_BD(j)) {
1745 tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)];
1746 dma_unmap_page(&bp->pdev->dev,
1747 dma_unmap_addr(tx_buf, mapping),
1748 diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
1749 index 1a1b29f..689d2a1 100644
1750 --- a/drivers/net/ethernet/broadcom/tg3.c
1751 +++ b/drivers/net/ethernet/broadcom/tg3.c
1752 @@ -298,6 +298,7 @@ static DEFINE_PCI_DEVICE_TABLE(tg3_pci_tbl) = {
1753 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_57795)},
1754 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_5719)},
1755 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_5720)},
1756 + {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_57762)},
1757 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX)},
1758 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX)},
1759 {PCI_DEVICE(PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1000)},
1760 @@ -8948,8 +8949,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
1761 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 ||
1762 tg3_flag(tp, 57765_PLUS)) {
1763 val = tr32(TG3_RDMA_RSRVCTRL_REG);
1764 - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
1765 - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) {
1766 + if (tp->pci_chip_rev_id == CHIPREV_ID_5719_A0) {
1767 val &= ~(TG3_RDMA_RSRVCTRL_TXMRGN_MASK |
1768 TG3_RDMA_RSRVCTRL_FIFO_LWM_MASK |
1769 TG3_RDMA_RSRVCTRL_FIFO_HWM_MASK);
1770 @@ -12255,10 +12255,12 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
1771 {
1772 struct tg3 *tp = netdev_priv(dev);
1773
1774 - if (!tp->hw_stats)
1775 + spin_lock_bh(&tp->lock);
1776 + if (!tp->hw_stats) {
1777 + spin_unlock_bh(&tp->lock);
1778 return &tp->net_stats_prev;
1779 + }
1780
1781 - spin_lock_bh(&tp->lock);
1782 tg3_get_nstats(tp, stats);
1783 spin_unlock_bh(&tp->lock);
1784
1785 diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
1786 index e7bed53..24381e1 100644
1787 --- a/drivers/net/ethernet/freescale/gianfar.c
1788 +++ b/drivers/net/ethernet/freescale/gianfar.c
1789 @@ -2065,10 +2065,9 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1790 return NETDEV_TX_OK;
1791 }
1792
1793 - /* Steal sock reference for processing TX time stamps */
1794 - swap(skb_new->sk, skb->sk);
1795 - swap(skb_new->destructor, skb->destructor);
1796 - kfree_skb(skb);
1797 + if (skb->sk)
1798 + skb_set_owner_w(skb_new, skb->sk);
1799 + consume_skb(skb);
1800 skb = skb_new;
1801 }
1802
1803 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
1804 index 161e045..a73bbe7 100644
1805 --- a/drivers/net/ethernet/realtek/r8169.c
1806 +++ b/drivers/net/ethernet/realtek/r8169.c
1807 @@ -5000,7 +5000,6 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)
1808 {
1809 rtl8169_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC);
1810 tp->cur_tx = tp->dirty_tx = 0;
1811 - netdev_reset_queue(tp->dev);
1812 }
1813
1814 static void rtl_reset_work(struct rtl8169_private *tp)
1815 @@ -5155,8 +5154,6 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
1816
1817 txd->opts2 = cpu_to_le32(opts[1]);
1818
1819 - netdev_sent_queue(dev, skb->len);
1820 -
1821 skb_tx_timestamp(skb);
1822
1823 wmb();
1824 @@ -5253,16 +5250,9 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
1825 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
1826 }
1827
1828 -struct rtl_txc {
1829 - int packets;
1830 - int bytes;
1831 -};
1832 -
1833 static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
1834 {
1835 - struct rtl8169_stats *tx_stats = &tp->tx_stats;
1836 unsigned int dirty_tx, tx_left;
1837 - struct rtl_txc txc = { 0, 0 };
1838
1839 dirty_tx = tp->dirty_tx;
1840 smp_rmb();
1841 @@ -5281,24 +5271,17 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
1842 rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
1843 tp->TxDescArray + entry);
1844 if (status & LastFrag) {
1845 - struct sk_buff *skb = tx_skb->skb;
1846 -
1847 - txc.packets++;
1848 - txc.bytes += skb->len;
1849 - dev_kfree_skb(skb);
1850 + u64_stats_update_begin(&tp->tx_stats.syncp);
1851 + tp->tx_stats.packets++;
1852 + tp->tx_stats.bytes += tx_skb->skb->len;
1853 + u64_stats_update_end(&tp->tx_stats.syncp);
1854 + dev_kfree_skb(tx_skb->skb);
1855 tx_skb->skb = NULL;
1856 }
1857 dirty_tx++;
1858 tx_left--;
1859 }
1860
1861 - u64_stats_update_begin(&tx_stats->syncp);
1862 - tx_stats->packets += txc.packets;
1863 - tx_stats->bytes += txc.bytes;
1864 - u64_stats_update_end(&tx_stats->syncp);
1865 -
1866 - netdev_completed_queue(dev, txc.packets, txc.bytes);
1867 -
1868 if (tp->dirty_tx != dirty_tx) {
1869 tp->dirty_tx = dirty_tx;
1870 /* Sync with rtl8169_start_xmit:
1871 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
1872 index bb8c72c..8f13420 100644
1873 --- a/drivers/net/tun.c
1874 +++ b/drivers/net/tun.c
1875 @@ -358,6 +358,8 @@ static void tun_free_netdev(struct net_device *dev)
1876 {
1877 struct tun_struct *tun = netdev_priv(dev);
1878
1879 + BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags));
1880 +
1881 sk_release_kernel(tun->socket.sk);
1882 }
1883
1884 @@ -1115,6 +1117,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1885 tun->flags = flags;
1886 tun->txflt.count = 0;
1887 tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
1888 + set_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags);
1889
1890 err = -ENOMEM;
1891 sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto);
1892 @@ -1252,10 +1255,12 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
1893 int vnet_hdr_sz;
1894 int ret;
1895
1896 - if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)
1897 + if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) {
1898 if (copy_from_user(&ifr, argp, ifreq_len))
1899 return -EFAULT;
1900 -
1901 + } else {
1902 + memset(&ifr, 0, sizeof(ifr));
1903 + }
1904 if (cmd == TUNGETFEATURES) {
1905 /* Currently this just means: "what IFF flags are valid?".
1906 * This is needed because we never checked for invalid flags on
1907 diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
1908 index df2a2cf..7a6ccd6 100644
1909 --- a/drivers/net/usb/kaweth.c
1910 +++ b/drivers/net/usb/kaweth.c
1911 @@ -1302,7 +1302,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
1912 int retv;
1913 int length = 0; /* shut up GCC */
1914
1915 - urb = usb_alloc_urb(0, GFP_NOIO);
1916 + urb = usb_alloc_urb(0, GFP_ATOMIC);
1917 if (!urb)
1918 return -ENOMEM;
1919
1920 diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
1921 index bef3f24..8be535f 100644
1922 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
1923 +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
1924 @@ -191,6 +191,7 @@ static void iwl_sta_calc_ht_flags(struct iwl_priv *priv,
1925 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
1926
1927 IWL_DEBUG_INFO(priv, "STA %pM SM PS mode: %s\n",
1928 + sta->addr,
1929 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
1930 "static" :
1931 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
1932 diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
1933 index baf6919..03560a8 100644
1934 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1935 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1936 @@ -544,9 +544,9 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
1937
1938 /*
1939 * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid
1940 - * MCS index values for us are 0 to 7.
1941 + * MCS index values for us are 0 to 15.
1942 */
1943 - if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 8)) {
1944 + if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) {
1945 sinfo->txrate.mcs = priv->tx_rate;
1946 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
1947 /* 40MHz rate */
1948 diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
1949 index 5601302..f388b65 100644
1950 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
1951 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
1952 @@ -1137,6 +1137,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
1953 #ifdef CONFIG_RT2800USB_RT33XX
1954 /* Belkin */
1955 { USB_DEVICE(0x050d, 0x945b) },
1956 + /* D-Link */
1957 + { USB_DEVICE(0x2001, 0x3c17) },
1958 /* Panasonic */
1959 { USB_DEVICE(0x083a, 0xb511) },
1960 /* Philips */
1961 @@ -1237,7 +1239,6 @@ static struct usb_device_id rt2800usb_device_table[] = {
1962 /* D-Link */
1963 { USB_DEVICE(0x07d1, 0x3c0b) },
1964 { USB_DEVICE(0x07d1, 0x3c17) },
1965 - { USB_DEVICE(0x2001, 0x3c17) },
1966 /* Encore */
1967 { USB_DEVICE(0x203d, 0x14a1) },
1968 /* Gemtek */
1969 diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
1970 index 28fc5fb..46f7917 100644
1971 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
1972 +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
1973 @@ -3344,21 +3344,21 @@ void rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw)
1974 switch (rtlhal->macphymode) {
1975 case DUALMAC_SINGLEPHY:
1976 rtlphy->rf_type = RF_2T2R;
1977 - rtlhal->version |= CHIP_92D_SINGLEPHY;
1978 + rtlhal->version |= RF_TYPE_2T2R;
1979 rtlhal->bandset = BAND_ON_BOTH;
1980 rtlhal->current_bandtype = BAND_ON_2_4G;
1981 break;
1982
1983 case SINGLEMAC_SINGLEPHY:
1984 rtlphy->rf_type = RF_2T2R;
1985 - rtlhal->version |= CHIP_92D_SINGLEPHY;
1986 + rtlhal->version |= RF_TYPE_2T2R;
1987 rtlhal->bandset = BAND_ON_BOTH;
1988 rtlhal->current_bandtype = BAND_ON_2_4G;
1989 break;
1990
1991 case DUALMAC_DUALPHY:
1992 rtlphy->rf_type = RF_1T1R;
1993 - rtlhal->version &= (~CHIP_92D_SINGLEPHY);
1994 + rtlhal->version &= RF_TYPE_1T1R;
1995 /* Now we let MAC0 run on 5G band. */
1996 if (rtlhal->interfaceindex == 0) {
1997 rtlhal->bandset = BAND_ON_5G;
1998 diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
1999 index a6049d7..aa970fc 100644
2000 --- a/drivers/net/wireless/rtlwifi/usb.c
2001 +++ b/drivers/net/wireless/rtlwifi/usb.c
2002 @@ -131,15 +131,19 @@ static u32 _usb_read_sync(struct rtl_priv *rtlpriv, u32 addr, u16 len)
2003 u8 request;
2004 u16 wvalue;
2005 u16 index;
2006 - __le32 *data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
2007 + __le32 *data;
2008 + unsigned long flags;
2009
2010 + spin_lock_irqsave(&rtlpriv->locks.usb_lock, flags);
2011 + if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
2012 + rtlpriv->usb_data_index = 0;
2013 + data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
2014 + spin_unlock_irqrestore(&rtlpriv->locks.usb_lock, flags);
2015 request = REALTEK_USB_VENQT_CMD_REQ;
2016 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
2017
2018 wvalue = (u16)addr;
2019 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len);
2020 - if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
2021 - rtlpriv->usb_data_index = 0;
2022 return le32_to_cpu(*data);
2023 }
2024
2025 @@ -951,6 +955,10 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
2026 GFP_KERNEL);
2027 if (!rtlpriv->usb_data)
2028 return -ENOMEM;
2029 +
2030 + /* this spin lock must be initialized early */
2031 + spin_lock_init(&rtlpriv->locks.usb_lock);
2032 +
2033 rtlpriv->usb_data_index = 0;
2034 init_completion(&rtlpriv->firmware_loading_complete);
2035 SET_IEEE80211_DEV(hw, &intf->dev);
2036 diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
2037 index 28ebc69..717d3ba 100644
2038 --- a/drivers/net/wireless/rtlwifi/wifi.h
2039 +++ b/drivers/net/wireless/rtlwifi/wifi.h
2040 @@ -1555,6 +1555,7 @@ struct rtl_locks {
2041 spinlock_t rf_ps_lock;
2042 spinlock_t rf_lock;
2043 spinlock_t waitq_lock;
2044 + spinlock_t usb_lock;
2045
2046 /*Dual mac*/
2047 spinlock_t cck_and_rw_pagea_lock;
2048 diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
2049 index f859216..951b6cf 100644
2050 --- a/drivers/s390/net/qeth_l3_main.c
2051 +++ b/drivers/s390/net/qeth_l3_main.c
2052 @@ -1818,6 +1818,8 @@ static void qeth_l3_free_vlan_addresses4(struct qeth_card *card,
2053 QETH_CARD_TEXT(card, 4, "frvaddr4");
2054
2055 netdev = __vlan_find_dev_deep(card->dev, vid);
2056 + if (!netdev)
2057 + return;
2058 in_dev = in_dev_get(netdev);
2059 if (!in_dev)
2060 return;
2061 @@ -1846,6 +1848,8 @@ static void qeth_l3_free_vlan_addresses6(struct qeth_card *card,
2062 QETH_CARD_TEXT(card, 4, "frvaddr6");
2063
2064 netdev = __vlan_find_dev_deep(card->dev, vid);
2065 + if (!netdev)
2066 + return;
2067 in6_dev = in6_dev_get(netdev);
2068 if (!in6_dev)
2069 return;
2070 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
2071 index a3a056a..b48c24f 100644
2072 --- a/drivers/scsi/hosts.c
2073 +++ b/drivers/scsi/hosts.c
2074 @@ -290,6 +290,7 @@ static void scsi_host_dev_release(struct device *dev)
2075 struct Scsi_Host *shost = dev_to_shost(dev);
2076 struct device *parent = dev->parent;
2077 struct request_queue *q;
2078 + void *queuedata;
2079
2080 scsi_proc_hostdir_rm(shost->hostt);
2081
2082 @@ -299,9 +300,9 @@ static void scsi_host_dev_release(struct device *dev)
2083 destroy_workqueue(shost->work_q);
2084 q = shost->uspace_req_q;
2085 if (q) {
2086 - kfree(q->queuedata);
2087 - q->queuedata = NULL;
2088 - scsi_free_queue(q);
2089 + queuedata = q->queuedata;
2090 + blk_cleanup_queue(q);
2091 + kfree(queuedata);
2092 }
2093
2094 scsi_destroy_command_freelist(shost);
2095 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
2096 index caa0525..101b28e 100644
2097 --- a/drivers/scsi/libsas/sas_expander.c
2098 +++ b/drivers/scsi/libsas/sas_expander.c
2099 @@ -868,7 +868,7 @@ static struct domain_device *sas_ex_discover_end_dev(
2100 }
2101
2102 /* See if this phy is part of a wide port */
2103 -static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
2104 +static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
2105 {
2106 struct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id];
2107 int i;
2108 @@ -884,11 +884,11 @@ static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
2109 sas_port_add_phy(ephy->port, phy->phy);
2110 phy->port = ephy->port;
2111 phy->phy_state = PHY_DEVICE_DISCOVERED;
2112 - return 0;
2113 + return true;
2114 }
2115 }
2116
2117 - return -ENODEV;
2118 + return false;
2119 }
2120
2121 static struct domain_device *sas_ex_discover_expander(
2122 @@ -1030,8 +1030,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
2123 return res;
2124 }
2125
2126 - res = sas_ex_join_wide_port(dev, phy_id);
2127 - if (!res) {
2128 + if (sas_ex_join_wide_port(dev, phy_id)) {
2129 SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
2130 phy_id, SAS_ADDR(ex_phy->attached_sas_addr));
2131 return res;
2132 @@ -1077,8 +1076,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
2133 if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) ==
2134 SAS_ADDR(child->sas_addr)) {
2135 ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED;
2136 - res = sas_ex_join_wide_port(dev, i);
2137 - if (!res)
2138 + if (sas_ex_join_wide_port(dev, i))
2139 SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
2140 i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
2141
2142 @@ -1943,32 +1941,20 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)
2143 {
2144 struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id];
2145 struct domain_device *child;
2146 - bool found = false;
2147 - int res, i;
2148 + int res;
2149
2150 SAS_DPRINTK("ex %016llx phy%d new device attached\n",
2151 SAS_ADDR(dev->sas_addr), phy_id);
2152 res = sas_ex_phy_discover(dev, phy_id);
2153 if (res)
2154 - goto out;
2155 - /* to support the wide port inserted */
2156 - for (i = 0; i < dev->ex_dev.num_phys; i++) {
2157 - struct ex_phy *ex_phy_temp = &dev->ex_dev.ex_phy[i];
2158 - if (i == phy_id)
2159 - continue;
2160 - if (SAS_ADDR(ex_phy_temp->attached_sas_addr) ==
2161 - SAS_ADDR(ex_phy->attached_sas_addr)) {
2162 - found = true;
2163 - break;
2164 - }
2165 - }
2166 - if (found) {
2167 - sas_ex_join_wide_port(dev, phy_id);
2168 + return res;
2169 +
2170 + if (sas_ex_join_wide_port(dev, phy_id))
2171 return 0;
2172 - }
2173 +
2174 res = sas_ex_discover_devices(dev, phy_id);
2175 - if (!res)
2176 - goto out;
2177 + if (res)
2178 + return res;
2179 list_for_each_entry(child, &dev->ex_dev.children, siblings) {
2180 if (SAS_ADDR(child->sas_addr) ==
2181 SAS_ADDR(ex_phy->attached_sas_addr)) {
2182 @@ -1978,7 +1964,6 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)
2183 break;
2184 }
2185 }
2186 -out:
2187 return res;
2188 }
2189
2190 @@ -2109,9 +2094,7 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)
2191 struct domain_device *dev = NULL;
2192
2193 res = sas_find_bcast_dev(port_dev, &dev);
2194 - if (res)
2195 - goto out;
2196 - if (dev) {
2197 + while (res == 0 && dev) {
2198 struct expander_device *ex = &dev->ex_dev;
2199 int i = 0, phy_id;
2200
2201 @@ -2123,8 +2106,10 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)
2202 res = sas_rediscover(dev, phy_id);
2203 i = phy_id + 1;
2204 } while (i < ex->num_phys);
2205 +
2206 + dev = NULL;
2207 + res = sas_find_bcast_dev(port_dev, &dev);
2208 }
2209 -out:
2210 return res;
2211 }
2212
2213 diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
2214 index 386f0c5..cc8dc8c 100644
2215 --- a/drivers/scsi/scsi_error.c
2216 +++ b/drivers/scsi/scsi_error.c
2217 @@ -1687,6 +1687,20 @@ static void scsi_restart_operations(struct Scsi_Host *shost)
2218 * requests are started.
2219 */
2220 scsi_run_host_queues(shost);
2221 +
2222 + /*
2223 + * if eh is active and host_eh_scheduled is pending we need to re-run
2224 + * recovery. we do this check after scsi_run_host_queues() to allow
2225 + * everything pent up since the last eh run a chance to make forward
2226 + * progress before we sync again. Either we'll immediately re-run
2227 + * recovery or scsi_device_unbusy() will wake us again when these
2228 + * pending commands complete.
2229 + */
2230 + spin_lock_irqsave(shost->host_lock, flags);
2231 + if (shost->host_eh_scheduled)
2232 + if (scsi_host_set_state(shost, SHOST_RECOVERY))
2233 + WARN_ON(scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY));
2234 + spin_unlock_irqrestore(shost->host_lock, flags);
2235 }
2236
2237 /**
2238 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
2239 index 4037fd5..1929146 100644
2240 --- a/drivers/scsi/scsi_lib.c
2241 +++ b/drivers/scsi/scsi_lib.c
2242 @@ -406,10 +406,6 @@ static void scsi_run_queue(struct request_queue *q)
2243 LIST_HEAD(starved_list);
2244 unsigned long flags;
2245
2246 - /* if the device is dead, sdev will be NULL, so no queue to run */
2247 - if (!sdev)
2248 - return;
2249 -
2250 shost = sdev->host;
2251 if (scsi_target(sdev)->single_lun)
2252 scsi_single_lun_run(sdev);
2253 @@ -483,15 +479,26 @@ void scsi_requeue_run_queue(struct work_struct *work)
2254 */
2255 static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
2256 {
2257 + struct scsi_device *sdev = cmd->device;
2258 struct request *req = cmd->request;
2259 unsigned long flags;
2260
2261 + /*
2262 + * We need to hold a reference on the device to avoid the queue being
2263 + * killed after the unlock and before scsi_run_queue is invoked which
2264 + * may happen because scsi_unprep_request() puts the command which
2265 + * releases its reference on the device.
2266 + */
2267 + get_device(&sdev->sdev_gendev);
2268 +
2269 spin_lock_irqsave(q->queue_lock, flags);
2270 scsi_unprep_request(req);
2271 blk_requeue_request(q, req);
2272 spin_unlock_irqrestore(q->queue_lock, flags);
2273
2274 scsi_run_queue(q);
2275 +
2276 + put_device(&sdev->sdev_gendev);
2277 }
2278
2279 void scsi_next_command(struct scsi_cmnd *cmd)
2280 @@ -1370,16 +1377,16 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
2281 * may be changed after request stacking drivers call the function,
2282 * regardless of taking lock or not.
2283 *
2284 - * When scsi can't dispatch I/Os anymore and needs to kill I/Os
2285 - * (e.g. !sdev), scsi needs to return 'not busy'.
2286 - * Otherwise, request stacking drivers may hold requests forever.
2287 + * When scsi can't dispatch I/Os anymore and needs to kill I/Os scsi
2288 + * needs to return 'not busy'. Otherwise, request stacking drivers
2289 + * may hold requests forever.
2290 */
2291 static int scsi_lld_busy(struct request_queue *q)
2292 {
2293 struct scsi_device *sdev = q->queuedata;
2294 struct Scsi_Host *shost;
2295
2296 - if (!sdev)
2297 + if (blk_queue_dead(q))
2298 return 0;
2299
2300 shost = sdev->host;
2301 @@ -1490,12 +1497,6 @@ static void scsi_request_fn(struct request_queue *q)
2302 struct scsi_cmnd *cmd;
2303 struct request *req;
2304
2305 - if (!sdev) {
2306 - while ((req = blk_peek_request(q)) != NULL)
2307 - scsi_kill_request(req, q);
2308 - return;
2309 - }
2310 -
2311 if(!get_device(&sdev->sdev_gendev))
2312 /* We must be tearing the block queue down already */
2313 return;
2314 @@ -1697,20 +1698,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
2315 return q;
2316 }
2317
2318 -void scsi_free_queue(struct request_queue *q)
2319 -{
2320 - unsigned long flags;
2321 -
2322 - WARN_ON(q->queuedata);
2323 -
2324 - /* cause scsi_request_fn() to kill all non-finished requests */
2325 - spin_lock_irqsave(q->queue_lock, flags);
2326 - q->request_fn(q);
2327 - spin_unlock_irqrestore(q->queue_lock, flags);
2328 -
2329 - blk_cleanup_queue(q);
2330 -}
2331 -
2332 /*
2333 * Function: scsi_block_requests()
2334 *
2335 diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
2336 index be4fa6d..fd9f57f 100644
2337 --- a/drivers/scsi/scsi_priv.h
2338 +++ b/drivers/scsi/scsi_priv.h
2339 @@ -84,7 +84,6 @@ extern void scsi_next_command(struct scsi_cmnd *cmd);
2340 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
2341 extern void scsi_run_host_queues(struct Scsi_Host *shost);
2342 extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
2343 -extern void scsi_free_queue(struct request_queue *q);
2344 extern int scsi_init_queue(void);
2345 extern void scsi_exit_queue(void);
2346 struct request_queue;
2347 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
2348 index 01b0374..8906557 100644
2349 --- a/drivers/scsi/scsi_scan.c
2350 +++ b/drivers/scsi/scsi_scan.c
2351 @@ -1714,6 +1714,9 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
2352 {
2353 struct scsi_device *sdev;
2354 shost_for_each_device(sdev, shost) {
2355 + /* target removed before the device could be added */
2356 + if (sdev->sdev_state == SDEV_DEL)
2357 + continue;
2358 if (!scsi_host_scan_allowed(shost) ||
2359 scsi_sysfs_add_sdev(sdev) != 0)
2360 __scsi_remove_device(sdev);
2361 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
2362 index 04c2a27..bb7c482 100644
2363 --- a/drivers/scsi/scsi_sysfs.c
2364 +++ b/drivers/scsi/scsi_sysfs.c
2365 @@ -971,11 +971,8 @@ void __scsi_remove_device(struct scsi_device *sdev)
2366 sdev->host->hostt->slave_destroy(sdev);
2367 transport_destroy_device(dev);
2368
2369 - /* cause the request function to reject all I/O requests */
2370 - sdev->request_queue->queuedata = NULL;
2371 -
2372 /* Freeing the queue signals to block that we're done */
2373 - scsi_free_queue(sdev->request_queue);
2374 + blk_cleanup_queue(sdev->request_queue);
2375 put_device(dev);
2376 }
2377
2378 @@ -1000,7 +997,6 @@ static void __scsi_remove_target(struct scsi_target *starget)
2379 struct scsi_device *sdev;
2380
2381 spin_lock_irqsave(shost->host_lock, flags);
2382 - starget->reap_ref++;
2383 restart:
2384 list_for_each_entry(sdev, &shost->__devices, siblings) {
2385 if (sdev->channel != starget->channel ||
2386 @@ -1014,14 +1010,6 @@ static void __scsi_remove_target(struct scsi_target *starget)
2387 goto restart;
2388 }
2389 spin_unlock_irqrestore(shost->host_lock, flags);
2390 - scsi_target_reap(starget);
2391 -}
2392 -
2393 -static int __remove_child (struct device * dev, void * data)
2394 -{
2395 - if (scsi_is_target_device(dev))
2396 - __scsi_remove_target(to_scsi_target(dev));
2397 - return 0;
2398 }
2399
2400 /**
2401 @@ -1034,14 +1022,34 @@ static int __remove_child (struct device * dev, void * data)
2402 */
2403 void scsi_remove_target(struct device *dev)
2404 {
2405 - if (scsi_is_target_device(dev)) {
2406 - __scsi_remove_target(to_scsi_target(dev));
2407 - return;
2408 + struct Scsi_Host *shost = dev_to_shost(dev->parent);
2409 + struct scsi_target *starget, *found;
2410 + unsigned long flags;
2411 +
2412 + restart:
2413 + found = NULL;
2414 + spin_lock_irqsave(shost->host_lock, flags);
2415 + list_for_each_entry(starget, &shost->__targets, siblings) {
2416 + if (starget->state == STARGET_DEL)
2417 + continue;
2418 + if (starget->dev.parent == dev || &starget->dev == dev) {
2419 + found = starget;
2420 + found->reap_ref++;
2421 + break;
2422 + }
2423 }
2424 + spin_unlock_irqrestore(shost->host_lock, flags);
2425
2426 - get_device(dev);
2427 - device_for_each_child(dev, NULL, __remove_child);
2428 - put_device(dev);
2429 + if (found) {
2430 + __scsi_remove_target(found);
2431 + scsi_target_reap(found);
2432 + /* in the case where @dev has multiple starget children,
2433 + * continue removing.
2434 + *
2435 + * FIXME: does such a case exist?
2436 + */
2437 + goto restart;
2438 + }
2439 }
2440 EXPORT_SYMBOL(scsi_remove_target);
2441
2442 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
2443 index 400ae21..469eb28 100644
2444 --- a/drivers/spi/spi-pl022.c
2445 +++ b/drivers/spi/spi-pl022.c
2446 @@ -489,6 +489,11 @@ static void giveback(struct pl022 *pl022)
2447 pl022->cur_transfer = NULL;
2448 pl022->cur_chip = NULL;
2449 spi_finalize_current_message(pl022->master);
2450 +
2451 + /* disable the SPI/SSP operation */
2452 + writew((readw(SSP_CR1(pl022->virtbase)) &
2453 + (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
2454 +
2455 }
2456
2457 /**
2458 diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
2459 index 917461c..175b3c9 100644
2460 --- a/drivers/staging/zsmalloc/zsmalloc-main.c
2461 +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
2462 @@ -426,12 +426,6 @@ static struct page *find_get_zspage(struct size_class *class)
2463 }
2464
2465
2466 -/*
2467 - * If this becomes a separate module, register zs_init() with
2468 - * module_init(), zs_exit with module_exit(), and remove zs_initialized
2469 -*/
2470 -static int zs_initialized;
2471 -
2472 static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action,
2473 void *pcpu)
2474 {
2475 @@ -490,7 +484,7 @@ fail:
2476
2477 struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
2478 {
2479 - int i, error, ovhd_size;
2480 + int i, ovhd_size;
2481 struct zs_pool *pool;
2482
2483 if (!name)
2484 @@ -517,28 +511,9 @@ struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
2485
2486 }
2487
2488 - /*
2489 - * If this becomes a separate module, register zs_init with
2490 - * module_init, and remove this block
2491 - */
2492 - if (!zs_initialized) {
2493 - error = zs_init();
2494 - if (error)
2495 - goto cleanup;
2496 - zs_initialized = 1;
2497 - }
2498 -
2499 pool->flags = flags;
2500 pool->name = name;
2501
2502 - error = 0; /* Success */
2503 -
2504 -cleanup:
2505 - if (error) {
2506 - zs_destroy_pool(pool);
2507 - pool = NULL;
2508 - }
2509 -
2510 return pool;
2511 }
2512 EXPORT_SYMBOL_GPL(zs_create_pool);
2513 @@ -749,3 +724,9 @@ u64 zs_get_total_size_bytes(struct zs_pool *pool)
2514 return npages << PAGE_SHIFT;
2515 }
2516 EXPORT_SYMBOL_GPL(zs_get_total_size_bytes);
2517 +
2518 +module_init(zs_init);
2519 +module_exit(zs_exit);
2520 +
2521 +MODULE_LICENSE("Dual BSD/GPL");
2522 +MODULE_AUTHOR("Nitin Gupta <ngupta@vflare.org>");
2523 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
2524 index 8b1d5e6..e326d17 100644
2525 --- a/drivers/target/iscsi/iscsi_target.c
2526 +++ b/drivers/target/iscsi/iscsi_target.c
2527 @@ -427,19 +427,8 @@ int iscsit_reset_np_thread(
2528
2529 int iscsit_del_np_comm(struct iscsi_np *np)
2530 {
2531 - if (!np->np_socket)
2532 - return 0;
2533 -
2534 - /*
2535 - * Some network transports allocate their own struct sock->file,
2536 - * see if we need to free any additional allocated resources.
2537 - */
2538 - if (np->np_flags & NPF_SCTP_STRUCT_FILE) {
2539 - kfree(np->np_socket->file);
2540 - np->np_socket->file = NULL;
2541 - }
2542 -
2543 - sock_release(np->np_socket);
2544 + if (np->np_socket)
2545 + sock_release(np->np_socket);
2546 return 0;
2547 }
2548
2549 @@ -4094,13 +4083,8 @@ int iscsit_close_connection(
2550 kfree(conn->conn_ops);
2551 conn->conn_ops = NULL;
2552
2553 - if (conn->sock) {
2554 - if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) {
2555 - kfree(conn->sock->file);
2556 - conn->sock->file = NULL;
2557 - }
2558 + if (conn->sock)
2559 sock_release(conn->sock);
2560 - }
2561 conn->thread_set = NULL;
2562
2563 pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
2564 diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
2565 index 2aaee7e..d1c4bc2 100644
2566 --- a/drivers/target/iscsi/iscsi_target_core.h
2567 +++ b/drivers/target/iscsi/iscsi_target_core.h
2568 @@ -224,7 +224,6 @@ enum iscsi_timer_flags_table {
2569 /* Used for struct iscsi_np->np_flags */
2570 enum np_flags_table {
2571 NPF_IP_NETWORK = 0x00,
2572 - NPF_SCTP_STRUCT_FILE = 0x01 /* Bugfix */
2573 };
2574
2575 /* Used for struct iscsi_np->np_thread_state */
2576 @@ -511,7 +510,6 @@ struct iscsi_conn {
2577 u16 local_port;
2578 int net_size;
2579 u32 auth_id;
2580 -#define CONNFLAG_SCTP_STRUCT_FILE 0x01
2581 u32 conn_flags;
2582 /* Used for iscsi_tx_login_rsp() */
2583 u32 login_itt;
2584 diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
2585 index a3656c9..ae30424 100644
2586 --- a/drivers/target/iscsi/iscsi_target_login.c
2587 +++ b/drivers/target/iscsi/iscsi_target_login.c
2588 @@ -795,22 +795,6 @@ int iscsi_target_setup_login_socket(
2589 }
2590 np->np_socket = sock;
2591 /*
2592 - * The SCTP stack needs struct socket->file.
2593 - */
2594 - if ((np->np_network_transport == ISCSI_SCTP_TCP) ||
2595 - (np->np_network_transport == ISCSI_SCTP_UDP)) {
2596 - if (!sock->file) {
2597 - sock->file = kzalloc(sizeof(struct file), GFP_KERNEL);
2598 - if (!sock->file) {
2599 - pr_err("Unable to allocate struct"
2600 - " file for SCTP\n");
2601 - ret = -ENOMEM;
2602 - goto fail;
2603 - }
2604 - np->np_flags |= NPF_SCTP_STRUCT_FILE;
2605 - }
2606 - }
2607 - /*
2608 * Setup the np->np_sockaddr from the passed sockaddr setup
2609 * in iscsi_target_configfs.c code..
2610 */
2611 @@ -869,21 +853,15 @@ int iscsi_target_setup_login_socket(
2612
2613 fail:
2614 np->np_socket = NULL;
2615 - if (sock) {
2616 - if (np->np_flags & NPF_SCTP_STRUCT_FILE) {
2617 - kfree(sock->file);
2618 - sock->file = NULL;
2619 - }
2620 -
2621 + if (sock)
2622 sock_release(sock);
2623 - }
2624 return ret;
2625 }
2626
2627 static int __iscsi_target_login_thread(struct iscsi_np *np)
2628 {
2629 u8 buffer[ISCSI_HDR_LEN], iscsi_opcode, zero_tsih = 0;
2630 - int err, ret = 0, set_sctp_conn_flag, stop;
2631 + int err, ret = 0, stop;
2632 struct iscsi_conn *conn = NULL;
2633 struct iscsi_login *login;
2634 struct iscsi_portal_group *tpg = NULL;
2635 @@ -894,7 +872,6 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
2636 struct sockaddr_in6 sock_in6;
2637
2638 flush_signals(current);
2639 - set_sctp_conn_flag = 0;
2640 sock = np->np_socket;
2641
2642 spin_lock_bh(&np->np_thread_lock);
2643 @@ -917,35 +894,12 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
2644 spin_unlock_bh(&np->np_thread_lock);
2645 goto out;
2646 }
2647 - /*
2648 - * The SCTP stack needs struct socket->file.
2649 - */
2650 - if ((np->np_network_transport == ISCSI_SCTP_TCP) ||
2651 - (np->np_network_transport == ISCSI_SCTP_UDP)) {
2652 - if (!new_sock->file) {
2653 - new_sock->file = kzalloc(
2654 - sizeof(struct file), GFP_KERNEL);
2655 - if (!new_sock->file) {
2656 - pr_err("Unable to allocate struct"
2657 - " file for SCTP\n");
2658 - sock_release(new_sock);
2659 - /* Get another socket */
2660 - return 1;
2661 - }
2662 - set_sctp_conn_flag = 1;
2663 - }
2664 - }
2665 -
2666 iscsi_start_login_thread_timer(np);
2667
2668 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL);
2669 if (!conn) {
2670 pr_err("Could not allocate memory for"
2671 " new connection\n");
2672 - if (set_sctp_conn_flag) {
2673 - kfree(new_sock->file);
2674 - new_sock->file = NULL;
2675 - }
2676 sock_release(new_sock);
2677 /* Get another socket */
2678 return 1;
2679 @@ -955,9 +909,6 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
2680 conn->conn_state = TARG_CONN_STATE_FREE;
2681 conn->sock = new_sock;
2682
2683 - if (set_sctp_conn_flag)
2684 - conn->conn_flags |= CONNFLAG_SCTP_STRUCT_FILE;
2685 -
2686 pr_debug("Moving to TARG_CONN_STATE_XPT_UP.\n");
2687 conn->conn_state = TARG_CONN_STATE_XPT_UP;
2688
2689 @@ -1205,13 +1156,8 @@ old_sess_out:
2690 iscsi_release_param_list(conn->param_list);
2691 conn->param_list = NULL;
2692 }
2693 - if (conn->sock) {
2694 - if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) {
2695 - kfree(conn->sock->file);
2696 - conn->sock->file = NULL;
2697 - }
2698 + if (conn->sock)
2699 sock_release(conn->sock);
2700 - }
2701 kfree(conn);
2702
2703 if (tpg) {
2704 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
2705 index 443704f..0686d61 100644
2706 --- a/drivers/target/target_core_transport.c
2707 +++ b/drivers/target/target_core_transport.c
2708 @@ -1976,6 +1976,7 @@ void transport_generic_request_failure(struct se_cmd *cmd)
2709 case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE:
2710 case TCM_UNKNOWN_MODE_PAGE:
2711 case TCM_WRITE_PROTECTED:
2712 + case TCM_ADDRESS_OUT_OF_RANGE:
2713 case TCM_CHECK_CONDITION_ABORT_CMD:
2714 case TCM_CHECK_CONDITION_UNIT_ATTENTION:
2715 case TCM_CHECK_CONDITION_NOT_READY:
2716 @@ -4656,6 +4657,15 @@ int transport_send_check_condition_and_sense(
2717 /* WRITE PROTECTED */
2718 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x27;
2719 break;
2720 + case TCM_ADDRESS_OUT_OF_RANGE:
2721 + /* CURRENT ERROR */
2722 + buffer[offset] = 0x70;
2723 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
2724 + /* ILLEGAL REQUEST */
2725 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
2726 + /* LOGICAL BLOCK ADDRESS OUT OF RANGE */
2727 + buffer[offset+SPC_ASC_KEY_OFFSET] = 0x21;
2728 + break;
2729 case TCM_CHECK_CONDITION_UNIT_ATTENTION:
2730 /* CURRENT ERROR */
2731 buffer[offset] = 0x70;
2732 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
2733 index 4e57772..404413b 100644
2734 --- a/drivers/usb/core/devio.c
2735 +++ b/drivers/usb/core/devio.c
2736 @@ -1615,10 +1615,14 @@ static int processcompl_compat(struct async *as, void __user * __user *arg)
2737 void __user *addr = as->userurb;
2738 unsigned int i;
2739
2740 - if (as->userbuffer && urb->actual_length)
2741 - if (copy_to_user(as->userbuffer, urb->transfer_buffer,
2742 - urb->actual_length))
2743 + if (as->userbuffer && urb->actual_length) {
2744 + if (urb->number_of_packets > 0) /* Isochronous */
2745 + i = urb->transfer_buffer_length;
2746 + else /* Non-Isoc */
2747 + i = urb->actual_length;
2748 + if (copy_to_user(as->userbuffer, urb->transfer_buffer, i))
2749 return -EFAULT;
2750 + }
2751 if (put_user(as->status, &userurb->status))
2752 return -EFAULT;
2753 if (put_user(urb->actual_length, &userurb->actual_length))
2754 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
2755 index 1fc8f12..347bb05 100644
2756 --- a/drivers/usb/early/ehci-dbgp.c
2757 +++ b/drivers/usb/early/ehci-dbgp.c
2758 @@ -450,7 +450,7 @@ static int dbgp_ehci_startup(void)
2759 writel(FLAG_CF, &ehci_regs->configured_flag);
2760
2761 /* Wait until the controller is no longer halted */
2762 - loop = 10;
2763 + loop = 1000;
2764 do {
2765 status = readl(&ehci_regs->status);
2766 if (!(status & STS_HALT))
2767 diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
2768 index 29c854b..4e1f0aa 100644
2769 --- a/drivers/usb/gadget/u_ether.c
2770 +++ b/drivers/usb/gadget/u_ether.c
2771 @@ -796,12 +796,6 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
2772
2773 SET_ETHTOOL_OPS(net, &ops);
2774
2775 - /* two kinds of host-initiated state changes:
2776 - * - iff DATA transfer is active, carrier is "on"
2777 - * - tx queueing enabled if open *and* carrier is "on"
2778 - */
2779 - netif_carrier_off(net);
2780 -
2781 dev->gadget = g;
2782 SET_NETDEV_DEV(net, &g->dev);
2783 SET_NETDEV_DEVTYPE(net, &gadget_type);
2784 @@ -815,6 +809,12 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
2785 INFO(dev, "HOST MAC %pM\n", dev->host_mac);
2786
2787 the_dev = dev;
2788 +
2789 + /* two kinds of host-initiated state changes:
2790 + * - iff DATA transfer is active, carrier is "on"
2791 + * - tx queueing enabled if open *and* carrier is "on"
2792 + */
2793 + netif_carrier_off(net);
2794 }
2795
2796 return status;
2797 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2798 index 49484b3..ae1a4b8 100644
2799 --- a/drivers/usb/serial/option.c
2800 +++ b/drivers/usb/serial/option.c
2801 @@ -936,6 +936,8 @@ static const struct usb_device_id option_ids[] = {
2802 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
2803 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
2804 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2805 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
2806 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2807 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
2808 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2809 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
2810 diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
2811 index 8ec8a6e..f98ba40 100644
2812 --- a/drivers/usb/storage/uas.c
2813 +++ b/drivers/usb/storage/uas.c
2814 @@ -58,9 +58,6 @@ enum {
2815 SUBMIT_DATA_OUT_URB = (1 << 5),
2816 ALLOC_CMD_URB = (1 << 6),
2817 SUBMIT_CMD_URB = (1 << 7),
2818 - COMPLETED_DATA_IN = (1 << 8),
2819 - COMPLETED_DATA_OUT = (1 << 9),
2820 - DATA_COMPLETES_CMD = (1 << 10),
2821 };
2822
2823 /* Overrides scsi_pointer */
2824 @@ -114,7 +111,6 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
2825 {
2826 struct sense_iu *sense_iu = urb->transfer_buffer;
2827 struct scsi_device *sdev = cmnd->device;
2828 - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
2829
2830 if (urb->actual_length > 16) {
2831 unsigned len = be16_to_cpup(&sense_iu->len);
2832 @@ -132,15 +128,13 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
2833 }
2834
2835 cmnd->result = sense_iu->status;
2836 - if (!(cmdinfo->state & DATA_COMPLETES_CMD))
2837 - cmnd->scsi_done(cmnd);
2838 + cmnd->scsi_done(cmnd);
2839 }
2840
2841 static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
2842 {
2843 struct sense_iu_old *sense_iu = urb->transfer_buffer;
2844 struct scsi_device *sdev = cmnd->device;
2845 - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
2846
2847 if (urb->actual_length > 8) {
2848 unsigned len = be16_to_cpup(&sense_iu->len) - 2;
2849 @@ -158,8 +152,7 @@ static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
2850 }
2851
2852 cmnd->result = sense_iu->status;
2853 - if (!(cmdinfo->state & DATA_COMPLETES_CMD))
2854 - cmnd->scsi_done(cmnd);
2855 + cmnd->scsi_done(cmnd);
2856 }
2857
2858 static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
2859 @@ -184,7 +177,6 @@ static void uas_stat_cmplt(struct urb *urb)
2860 struct Scsi_Host *shost = urb->context;
2861 struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
2862 struct scsi_cmnd *cmnd;
2863 - struct uas_cmd_info *cmdinfo;
2864 u16 tag;
2865 int ret;
2866
2867 @@ -210,32 +202,12 @@ static void uas_stat_cmplt(struct urb *urb)
2868 dev_err(&urb->dev->dev, "failed submit status urb\n");
2869 return;
2870 }
2871 - cmdinfo = (void *)&cmnd->SCp;
2872
2873 switch (iu->iu_id) {
2874 case IU_ID_STATUS:
2875 if (devinfo->cmnd == cmnd)
2876 devinfo->cmnd = NULL;
2877
2878 - if (!(cmdinfo->state & COMPLETED_DATA_IN) &&
2879 - cmdinfo->data_in_urb) {
2880 - if (devinfo->use_streams) {
2881 - cmdinfo->state |= DATA_COMPLETES_CMD;
2882 - usb_unlink_urb(cmdinfo->data_in_urb);
2883 - } else {
2884 - usb_free_urb(cmdinfo->data_in_urb);
2885 - }
2886 - }
2887 - if (!(cmdinfo->state & COMPLETED_DATA_OUT) &&
2888 - cmdinfo->data_out_urb) {
2889 - if (devinfo->use_streams) {
2890 - cmdinfo->state |= DATA_COMPLETES_CMD;
2891 - usb_unlink_urb(cmdinfo->data_in_urb);
2892 - } else {
2893 - usb_free_urb(cmdinfo->data_out_urb);
2894 - }
2895 - }
2896 -
2897 if (urb->actual_length < 16)
2898 devinfo->uas_sense_old = 1;
2899 if (devinfo->uas_sense_old)
2900 @@ -264,59 +236,27 @@ static void uas_stat_cmplt(struct urb *urb)
2901 dev_err(&urb->dev->dev, "failed submit status urb\n");
2902 }
2903
2904 -static void uas_data_out_cmplt(struct urb *urb)
2905 -{
2906 - struct scsi_cmnd *cmnd = urb->context;
2907 - struct scsi_data_buffer *sdb = scsi_out(cmnd);
2908 - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
2909 -
2910 - cmdinfo->state |= COMPLETED_DATA_OUT;
2911 -
2912 - sdb->resid = sdb->length - urb->actual_length;
2913 - usb_free_urb(urb);
2914 -
2915 - if (cmdinfo->state & DATA_COMPLETES_CMD)
2916 - cmnd->scsi_done(cmnd);
2917 -}
2918 -
2919 -static void uas_data_in_cmplt(struct urb *urb)
2920 +static void uas_data_cmplt(struct urb *urb)
2921 {
2922 - struct scsi_cmnd *cmnd = urb->context;
2923 - struct scsi_data_buffer *sdb = scsi_in(cmnd);
2924 - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
2925 -
2926 - cmdinfo->state |= COMPLETED_DATA_IN;
2927 -
2928 + struct scsi_data_buffer *sdb = urb->context;
2929 sdb->resid = sdb->length - urb->actual_length;
2930 usb_free_urb(urb);
2931 -
2932 - if (cmdinfo->state & DATA_COMPLETES_CMD)
2933 - cmnd->scsi_done(cmnd);
2934 }
2935
2936 static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
2937 - unsigned int pipe, struct scsi_cmnd *cmnd,
2938 - enum dma_data_direction dir)
2939 + unsigned int pipe, u16 stream_id,
2940 + struct scsi_data_buffer *sdb,
2941 + enum dma_data_direction dir)
2942 {
2943 - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
2944 struct usb_device *udev = devinfo->udev;
2945 struct urb *urb = usb_alloc_urb(0, gfp);
2946 - struct scsi_data_buffer *sdb;
2947 - usb_complete_t complete_fn;
2948 - u16 stream_id = cmdinfo->stream;
2949
2950 if (!urb)
2951 goto out;
2952 - if (dir == DMA_FROM_DEVICE) {
2953 - sdb = scsi_in(cmnd);
2954 - complete_fn = uas_data_in_cmplt;
2955 - } else {
2956 - sdb = scsi_out(cmnd);
2957 - complete_fn = uas_data_out_cmplt;
2958 - }
2959 - usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
2960 - complete_fn, cmnd);
2961 - urb->stream_id = stream_id;
2962 + usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, uas_data_cmplt,
2963 + sdb);
2964 + if (devinfo->use_streams)
2965 + urb->stream_id = stream_id;
2966 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
2967 urb->sg = sdb->table.sgl;
2968 out:
2969 @@ -418,8 +358,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
2970
2971 if (cmdinfo->state & ALLOC_DATA_IN_URB) {
2972 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
2973 - devinfo->data_in_pipe, cmnd,
2974 - DMA_FROM_DEVICE);
2975 + devinfo->data_in_pipe, cmdinfo->stream,
2976 + scsi_in(cmnd), DMA_FROM_DEVICE);
2977 if (!cmdinfo->data_in_urb)
2978 return SCSI_MLQUEUE_DEVICE_BUSY;
2979 cmdinfo->state &= ~ALLOC_DATA_IN_URB;
2980 @@ -436,8 +376,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
2981
2982 if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
2983 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
2984 - devinfo->data_out_pipe, cmnd,
2985 - DMA_TO_DEVICE);
2986 + devinfo->data_out_pipe, cmdinfo->stream,
2987 + scsi_out(cmnd), DMA_TO_DEVICE);
2988 if (!cmdinfo->data_out_urb)
2989 return SCSI_MLQUEUE_DEVICE_BUSY;
2990 cmdinfo->state &= ~ALLOC_DATA_OUT_URB;
2991 diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
2992 index 4270414..58b7d14 100644
2993 --- a/fs/btrfs/async-thread.c
2994 +++ b/fs/btrfs/async-thread.c
2995 @@ -206,10 +206,17 @@ static noinline void run_ordered_completions(struct btrfs_workers *workers,
2996
2997 work->ordered_func(work);
2998
2999 - /* now take the lock again and call the freeing code */
3000 + /* now take the lock again and drop our item from the list */
3001 spin_lock(&workers->order_lock);
3002 list_del(&work->order_list);
3003 + spin_unlock(&workers->order_lock);
3004 +
3005 + /*
3006 + * we don't want to call the ordered free functions
3007 + * with the lock held though
3008 + */
3009 work->ordered_free(work);
3010 + spin_lock(&workers->order_lock);
3011 }
3012
3013 spin_unlock(&workers->order_lock);
3014 diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
3015 index 87ce8af..65a78e9 100644
3016 --- a/fs/cifs/connect.c
3017 +++ b/fs/cifs/connect.c
3018 @@ -238,8 +238,8 @@ static const match_table_t cifs_mount_option_tokens = {
3019 enum {
3020 Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p,
3021 Opt_sec_ntlmsspi, Opt_sec_ntlmssp,
3022 - Opt_ntlm, Opt_sec_ntlmi, Opt_sec_ntlmv2i,
3023 - Opt_sec_nontlm, Opt_sec_lanman,
3024 + Opt_ntlm, Opt_sec_ntlmi, Opt_sec_ntlmv2,
3025 + Opt_sec_ntlmv2i, Opt_sec_lanman,
3026 Opt_sec_none,
3027
3028 Opt_sec_err
3029 @@ -253,8 +253,9 @@ static const match_table_t cifs_secflavor_tokens = {
3030 { Opt_sec_ntlmssp, "ntlmssp" },
3031 { Opt_ntlm, "ntlm" },
3032 { Opt_sec_ntlmi, "ntlmi" },
3033 + { Opt_sec_ntlmv2, "nontlm" },
3034 + { Opt_sec_ntlmv2, "ntlmv2" },
3035 { Opt_sec_ntlmv2i, "ntlmv2i" },
3036 - { Opt_sec_nontlm, "nontlm" },
3037 { Opt_sec_lanman, "lanman" },
3038 { Opt_sec_none, "none" },
3039
3040 @@ -1163,7 +1164,7 @@ static int cifs_parse_security_flavors(char *value,
3041 case Opt_sec_ntlmi:
3042 vol->secFlg |= CIFSSEC_MAY_NTLM | CIFSSEC_MUST_SIGN;
3043 break;
3044 - case Opt_sec_nontlm:
3045 + case Opt_sec_ntlmv2:
3046 vol->secFlg |= CIFSSEC_MAY_NTLMV2;
3047 break;
3048 case Opt_sec_ntlmv2i:
3049 diff --git a/fs/exec.c b/fs/exec.c
3050 index 29e5f84..126e01c 100644
3051 --- a/fs/exec.c
3052 +++ b/fs/exec.c
3053 @@ -1024,7 +1024,7 @@ static void flush_old_files(struct files_struct * files)
3054 unsigned long set, i;
3055
3056 j++;
3057 - i = j * __NFDBITS;
3058 + i = j * BITS_PER_LONG;
3059 fdt = files_fdtable(files);
3060 if (i >= fdt->max_fds)
3061 break;
3062 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
3063 index 8da837b..df76291 100644
3064 --- a/fs/ext4/balloc.c
3065 +++ b/fs/ext4/balloc.c
3066 @@ -584,7 +584,8 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb)
3067 if (bitmap_bh == NULL)
3068 continue;
3069
3070 - x = ext4_count_free(bitmap_bh, sb->s_blocksize);
3071 + x = ext4_count_free(bitmap_bh->b_data,
3072 + EXT4_BLOCKS_PER_GROUP(sb) / 8);
3073 printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n",
3074 i, ext4_free_group_clusters(sb, gdp), x);
3075 bitmap_count += x;
3076 diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
3077 index fa3af81..bbde5d5 100644
3078 --- a/fs/ext4/bitmap.c
3079 +++ b/fs/ext4/bitmap.c
3080 @@ -11,21 +11,15 @@
3081 #include <linux/jbd2.h>
3082 #include "ext4.h"
3083
3084 -#ifdef EXT4FS_DEBUG
3085 -
3086 static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
3087
3088 -unsigned int ext4_count_free(struct buffer_head *map, unsigned int numchars)
3089 +unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
3090 {
3091 unsigned int i, sum = 0;
3092
3093 - if (!map)
3094 - return 0;
3095 for (i = 0; i < numchars; i++)
3096 - sum += nibblemap[map->b_data[i] & 0xf] +
3097 - nibblemap[(map->b_data[i] >> 4) & 0xf];
3098 + sum += nibblemap[bitmap[i] & 0xf] +
3099 + nibblemap[(bitmap[i] >> 4) & 0xf];
3100 return sum;
3101 }
3102
3103 -#endif /* EXT4FS_DEBUG */
3104 -
3105 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
3106 index 0e01e90..47d1c8c 100644
3107 --- a/fs/ext4/ext4.h
3108 +++ b/fs/ext4/ext4.h
3109 @@ -1140,8 +1140,7 @@ struct ext4_sb_info {
3110 unsigned long s_desc_per_block; /* Number of group descriptors per block */
3111 ext4_group_t s_groups_count; /* Number of groups in the fs */
3112 ext4_group_t s_blockfile_groups;/* Groups acceptable for non-extent files */
3113 - unsigned long s_overhead_last; /* Last calculated overhead */
3114 - unsigned long s_blocks_last; /* Last seen block count */
3115 + unsigned long s_overhead; /* # of fs overhead clusters */
3116 unsigned int s_cluster_ratio; /* Number of blocks per cluster */
3117 unsigned int s_cluster_bits; /* log2 of s_cluster_ratio */
3118 loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
3119 @@ -1783,7 +1782,7 @@ struct mmpd_data {
3120 # define NORET_AND noreturn,
3121
3122 /* bitmap.c */
3123 -extern unsigned int ext4_count_free(struct buffer_head *, unsigned);
3124 +extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
3125
3126 /* balloc.c */
3127 extern unsigned int ext4_block_group(struct super_block *sb,
3128 @@ -1950,6 +1949,7 @@ extern int ext4_group_extend(struct super_block *sb,
3129 extern int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count);
3130
3131 /* super.c */
3132 +extern int ext4_calculate_overhead(struct super_block *sb);
3133 extern void *ext4_kvmalloc(size_t size, gfp_t flags);
3134 extern void *ext4_kvzalloc(size_t size, gfp_t flags);
3135 extern void ext4_kvfree(void *ptr);
3136 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
3137 index abcdeab..6b7daa4 100644
3138 --- a/fs/ext4/extents.c
3139 +++ b/fs/ext4/extents.c
3140 @@ -2503,10 +2503,10 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
3141 {
3142 struct super_block *sb = inode->i_sb;
3143 int depth = ext_depth(inode);
3144 - struct ext4_ext_path *path;
3145 + struct ext4_ext_path *path = NULL;
3146 ext4_fsblk_t partial_cluster = 0;
3147 handle_t *handle;
3148 - int i, err;
3149 + int i = 0, err;
3150
3151 ext_debug("truncate since %u to %u\n", start, end);
3152
3153 @@ -2539,8 +2539,12 @@ again:
3154 }
3155 depth = ext_depth(inode);
3156 ex = path[depth].p_ext;
3157 - if (!ex)
3158 + if (!ex) {
3159 + ext4_ext_drop_refs(path);
3160 + kfree(path);
3161 + path = NULL;
3162 goto cont;
3163 + }
3164
3165 ee_block = le32_to_cpu(ex->ee_block);
3166
3167 @@ -2570,8 +2574,6 @@ again:
3168 if (err < 0)
3169 goto out;
3170 }
3171 - ext4_ext_drop_refs(path);
3172 - kfree(path);
3173 }
3174 cont:
3175
3176 @@ -2580,19 +2582,27 @@ cont:
3177 * after i_size and walking into the tree depth-wise.
3178 */
3179 depth = ext_depth(inode);
3180 - path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
3181 - if (path == NULL) {
3182 - ext4_journal_stop(handle);
3183 - return -ENOMEM;
3184 - }
3185 - path[0].p_depth = depth;
3186 - path[0].p_hdr = ext_inode_hdr(inode);
3187 + if (path) {
3188 + int k = i = depth;
3189 + while (--k > 0)
3190 + path[k].p_block =
3191 + le16_to_cpu(path[k].p_hdr->eh_entries)+1;
3192 + } else {
3193 + path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
3194 + GFP_NOFS);
3195 + if (path == NULL) {
3196 + ext4_journal_stop(handle);
3197 + return -ENOMEM;
3198 + }
3199 + path[0].p_depth = depth;
3200 + path[0].p_hdr = ext_inode_hdr(inode);
3201
3202 - if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
3203 - err = -EIO;
3204 - goto out;
3205 + if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
3206 + err = -EIO;
3207 + goto out;
3208 + }
3209 }
3210 - i = err = 0;
3211 + err = 0;
3212
3213 while (i >= 0 && err == 0) {
3214 if (i == depth) {
3215 @@ -2706,8 +2716,10 @@ cont:
3216 out:
3217 ext4_ext_drop_refs(path);
3218 kfree(path);
3219 - if (err == -EAGAIN)
3220 + if (err == -EAGAIN) {
3221 + path = NULL;
3222 goto again;
3223 + }
3224 ext4_journal_stop(handle);
3225
3226 return err;
3227 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
3228 index 8900f8b..0ee374d 100644
3229 --- a/fs/ext4/ialloc.c
3230 +++ b/fs/ext4/ialloc.c
3231 @@ -1013,7 +1013,8 @@ unsigned long ext4_count_free_inodes(struct super_block *sb)
3232 if (!bitmap_bh)
3233 continue;
3234
3235 - x = ext4_count_free(bitmap_bh, EXT4_INODES_PER_GROUP(sb) / 8);
3236 + x = ext4_count_free(bitmap_bh->b_data,
3237 + EXT4_INODES_PER_GROUP(sb) / 8);
3238 printk(KERN_DEBUG "group %lu: stored = %d, counted = %lu\n",
3239 (unsigned long) i, ext4_free_inodes_count(sb, gdp), x);
3240 bitmap_count += x;
3241 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
3242 index c77b0bd..55a654d 100644
3243 --- a/fs/ext4/inode.c
3244 +++ b/fs/ext4/inode.c
3245 @@ -279,6 +279,15 @@ void ext4_da_update_reserve_space(struct inode *inode,
3246 used = ei->i_reserved_data_blocks;
3247 }
3248
3249 + if (unlikely(ei->i_allocated_meta_blocks > ei->i_reserved_meta_blocks)) {
3250 + ext4_msg(inode->i_sb, KERN_NOTICE, "%s: ino %lu, allocated %d "
3251 + "with only %d reserved metadata blocks\n", __func__,
3252 + inode->i_ino, ei->i_allocated_meta_blocks,
3253 + ei->i_reserved_meta_blocks);
3254 + WARN_ON(1);
3255 + ei->i_allocated_meta_blocks = ei->i_reserved_meta_blocks;
3256 + }
3257 +
3258 /* Update per-inode reservations */
3259 ei->i_reserved_data_blocks -= used;
3260 ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks;
3261 @@ -1104,6 +1113,17 @@ static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock)
3262 struct ext4_inode_info *ei = EXT4_I(inode);
3263 unsigned int md_needed;
3264 int ret;
3265 + ext4_lblk_t save_last_lblock;
3266 + int save_len;
3267 +
3268 + /*
3269 + * We will charge metadata quota at writeout time; this saves
3270 + * us from metadata over-estimation, though we may go over by
3271 + * a small amount in the end. Here we just reserve for data.
3272 + */
3273 + ret = dquot_reserve_block(inode, EXT4_C2B(sbi, 1));
3274 + if (ret)
3275 + return ret;
3276
3277 /*
3278 * recalculate the amount of metadata blocks to reserve
3279 @@ -1112,32 +1132,31 @@ static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock)
3280 */
3281 repeat:
3282 spin_lock(&ei->i_block_reservation_lock);
3283 + /*
3284 + * ext4_calc_metadata_amount() has side effects, which we have
3285 + * to be prepared undo if we fail to claim space.
3286 + */
3287 + save_len = ei->i_da_metadata_calc_len;
3288 + save_last_lblock = ei->i_da_metadata_calc_last_lblock;
3289 md_needed = EXT4_NUM_B2C(sbi,
3290 ext4_calc_metadata_amount(inode, lblock));
3291 trace_ext4_da_reserve_space(inode, md_needed);
3292 - spin_unlock(&ei->i_block_reservation_lock);
3293
3294 /*
3295 - * We will charge metadata quota at writeout time; this saves
3296 - * us from metadata over-estimation, though we may go over by
3297 - * a small amount in the end. Here we just reserve for data.
3298 - */
3299 - ret = dquot_reserve_block(inode, EXT4_C2B(sbi, 1));
3300 - if (ret)
3301 - return ret;
3302 - /*
3303 * We do still charge estimated metadata to the sb though;
3304 * we cannot afford to run out of free blocks.
3305 */
3306 if (ext4_claim_free_clusters(sbi, md_needed + 1, 0)) {
3307 - dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
3308 + ei->i_da_metadata_calc_len = save_len;
3309 + ei->i_da_metadata_calc_last_lblock = save_last_lblock;
3310 + spin_unlock(&ei->i_block_reservation_lock);
3311 if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
3312 yield();
3313 goto repeat;
3314 }
3315 + dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
3316 return -ENOSPC;
3317 }
3318 - spin_lock(&ei->i_block_reservation_lock);
3319 ei->i_reserved_data_blocks++;
3320 ei->i_reserved_meta_blocks += md_needed;
3321 spin_unlock(&ei->i_block_reservation_lock);
3322 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
3323 index 53589ff..3407a62 100644
3324 --- a/fs/ext4/resize.c
3325 +++ b/fs/ext4/resize.c
3326 @@ -1141,7 +1141,7 @@ static void ext4_update_super(struct super_block *sb,
3327 struct ext4_new_group_data *group_data = flex_gd->groups;
3328 struct ext4_sb_info *sbi = EXT4_SB(sb);
3329 struct ext4_super_block *es = sbi->s_es;
3330 - int i;
3331 + int i, ret;
3332
3333 BUG_ON(flex_gd->count == 0 || group_data == NULL);
3334 /*
3335 @@ -1216,6 +1216,11 @@ static void ext4_update_super(struct super_block *sb,
3336 &sbi->s_flex_groups[flex_group].free_inodes);
3337 }
3338
3339 + /*
3340 + * Update the fs overhead information
3341 + */
3342 + ext4_calculate_overhead(sb);
3343 +
3344 if (test_opt(sb, DEBUG))
3345 printk(KERN_DEBUG "EXT4-fs: added group %u:"
3346 "%llu blocks(%llu free %llu reserved)\n", flex_gd->count,
3347 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
3348 index a68703a..7fe3869 100644
3349 --- a/fs/ext4/super.c
3350 +++ b/fs/ext4/super.c
3351 @@ -2944,6 +2944,114 @@ static void ext4_destroy_lazyinit_thread(void)
3352 kthread_stop(ext4_lazyinit_task);
3353 }
3354
3355 +/*
3356 + * Note: calculating the overhead so we can be compatible with
3357 + * historical BSD practice is quite difficult in the face of
3358 + * clusters/bigalloc. This is because multiple metadata blocks from
3359 + * different block group can end up in the same allocation cluster.
3360 + * Calculating the exact overhead in the face of clustered allocation
3361 + * requires either O(all block bitmaps) in memory or O(number of block
3362 + * groups**2) in time. We will still calculate the superblock for
3363 + * older file systems --- and if we come across with a bigalloc file
3364 + * system with zero in s_overhead_clusters the estimate will be close to
3365 + * correct especially for very large cluster sizes --- but for newer
3366 + * file systems, it's better to calculate this figure once at mkfs
3367 + * time, and store it in the superblock. If the superblock value is
3368 + * present (even for non-bigalloc file systems), we will use it.
3369 + */
3370 +static int count_overhead(struct super_block *sb, ext4_group_t grp,
3371 + char *buf)
3372 +{
3373 + struct ext4_sb_info *sbi = EXT4_SB(sb);
3374 + struct ext4_group_desc *gdp;
3375 + ext4_fsblk_t first_block, last_block, b;
3376 + ext4_group_t i, ngroups = ext4_get_groups_count(sb);
3377 + int s, j, count = 0;
3378 +
3379 + first_block = le32_to_cpu(sbi->s_es->s_first_data_block) +
3380 + (grp * EXT4_BLOCKS_PER_GROUP(sb));
3381 + last_block = first_block + EXT4_BLOCKS_PER_GROUP(sb) - 1;
3382 + for (i = 0; i < ngroups; i++) {
3383 + gdp = ext4_get_group_desc(sb, i, NULL);
3384 + b = ext4_block_bitmap(sb, gdp);
3385 + if (b >= first_block && b <= last_block) {
3386 + ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
3387 + count++;
3388 + }
3389 + b = ext4_inode_bitmap(sb, gdp);
3390 + if (b >= first_block && b <= last_block) {
3391 + ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
3392 + count++;
3393 + }
3394 + b = ext4_inode_table(sb, gdp);
3395 + if (b >= first_block && b + sbi->s_itb_per_group <= last_block)
3396 + for (j = 0; j < sbi->s_itb_per_group; j++, b++) {
3397 + int c = EXT4_B2C(sbi, b - first_block);
3398 + ext4_set_bit(c, buf);
3399 + count++;
3400 + }
3401 + if (i != grp)
3402 + continue;
3403 + s = 0;
3404 + if (ext4_bg_has_super(sb, grp)) {
3405 + ext4_set_bit(s++, buf);
3406 + count++;
3407 + }
3408 + for (j = ext4_bg_num_gdb(sb, grp); j > 0; j--) {
3409 + ext4_set_bit(EXT4_B2C(sbi, s++), buf);
3410 + count++;
3411 + }
3412 + }
3413 + if (!count)
3414 + return 0;
3415 + return EXT4_CLUSTERS_PER_GROUP(sb) -
3416 + ext4_count_free(buf, EXT4_CLUSTERS_PER_GROUP(sb) / 8);
3417 +}
3418 +
3419 +/*
3420 + * Compute the overhead and stash it in sbi->s_overhead
3421 + */
3422 +int ext4_calculate_overhead(struct super_block *sb)
3423 +{
3424 + struct ext4_sb_info *sbi = EXT4_SB(sb);
3425 + struct ext4_super_block *es = sbi->s_es;
3426 + ext4_group_t i, ngroups = ext4_get_groups_count(sb);
3427 + ext4_fsblk_t overhead = 0;
3428 + char *buf = (char *) get_zeroed_page(GFP_KERNEL);
3429 +
3430 + memset(buf, 0, PAGE_SIZE);
3431 + if (!buf)
3432 + return -ENOMEM;
3433 +
3434 + /*
3435 + * Compute the overhead (FS structures). This is constant
3436 + * for a given filesystem unless the number of block groups
3437 + * changes so we cache the previous value until it does.
3438 + */
3439 +
3440 + /*
3441 + * All of the blocks before first_data_block are overhead
3442 + */
3443 + overhead = EXT4_B2C(sbi, le32_to_cpu(es->s_first_data_block));
3444 +
3445 + /*
3446 + * Add the overhead found in each block group
3447 + */
3448 + for (i = 0; i < ngroups; i++) {
3449 + int blks;
3450 +
3451 + blks = count_overhead(sb, i, buf);
3452 + overhead += blks;
3453 + if (blks)
3454 + memset(buf, 0, PAGE_SIZE);
3455 + cond_resched();
3456 + }
3457 + sbi->s_overhead = overhead;
3458 + smp_wmb();
3459 + free_page((unsigned long) buf);
3460 + return 0;
3461 +}
3462 +
3463 static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3464 {
3465 char *orig_data = kstrdup(data, GFP_KERNEL);
3466 @@ -3559,6 +3667,18 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3467
3468 no_journal:
3469 /*
3470 + * Get the # of file system overhead blocks from the
3471 + * superblock if present.
3472 + */
3473 + if (es->s_overhead_clusters)
3474 + sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
3475 + else {
3476 + ret = ext4_calculate_overhead(sb);
3477 + if (ret)
3478 + goto failed_mount_wq;
3479 + }
3480 +
3481 + /*
3482 * The maximum number of concurrent works can be high and
3483 * concurrency isn't really necessary. Limit it to 1.
3484 */
3485 @@ -4421,67 +4541,21 @@ restore_opts:
3486 return err;
3487 }
3488
3489 -/*
3490 - * Note: calculating the overhead so we can be compatible with
3491 - * historical BSD practice is quite difficult in the face of
3492 - * clusters/bigalloc. This is because multiple metadata blocks from
3493 - * different block group can end up in the same allocation cluster.
3494 - * Calculating the exact overhead in the face of clustered allocation
3495 - * requires either O(all block bitmaps) in memory or O(number of block
3496 - * groups**2) in time. We will still calculate the superblock for
3497 - * older file systems --- and if we come across with a bigalloc file
3498 - * system with zero in s_overhead_clusters the estimate will be close to
3499 - * correct especially for very large cluster sizes --- but for newer
3500 - * file systems, it's better to calculate this figure once at mkfs
3501 - * time, and store it in the superblock. If the superblock value is
3502 - * present (even for non-bigalloc file systems), we will use it.
3503 - */
3504 static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
3505 {
3506 struct super_block *sb = dentry->d_sb;
3507 struct ext4_sb_info *sbi = EXT4_SB(sb);
3508 struct ext4_super_block *es = sbi->s_es;
3509 - struct ext4_group_desc *gdp;
3510 + ext4_fsblk_t overhead = 0;
3511 u64 fsid;
3512 s64 bfree;
3513
3514 - if (test_opt(sb, MINIX_DF)) {
3515 - sbi->s_overhead_last = 0;
3516 - } else if (es->s_overhead_clusters) {
3517 - sbi->s_overhead_last = le32_to_cpu(es->s_overhead_clusters);
3518 - } else if (sbi->s_blocks_last != ext4_blocks_count(es)) {
3519 - ext4_group_t i, ngroups = ext4_get_groups_count(sb);
3520 - ext4_fsblk_t overhead = 0;
3521 -
3522 - /*
3523 - * Compute the overhead (FS structures). This is constant
3524 - * for a given filesystem unless the number of block groups
3525 - * changes so we cache the previous value until it does.
3526 - */
3527 -
3528 - /*
3529 - * All of the blocks before first_data_block are
3530 - * overhead
3531 - */
3532 - overhead = EXT4_B2C(sbi, le32_to_cpu(es->s_first_data_block));
3533 -
3534 - /*
3535 - * Add the overhead found in each block group
3536 - */
3537 - for (i = 0; i < ngroups; i++) {
3538 - gdp = ext4_get_group_desc(sb, i, NULL);
3539 - overhead += ext4_num_overhead_clusters(sb, i, gdp);
3540 - cond_resched();
3541 - }
3542 - sbi->s_overhead_last = overhead;
3543 - smp_wmb();
3544 - sbi->s_blocks_last = ext4_blocks_count(es);
3545 - }
3546 + if (!test_opt(sb, MINIX_DF))
3547 + overhead = sbi->s_overhead;
3548
3549 buf->f_type = EXT4_SUPER_MAGIC;
3550 buf->f_bsize = sb->s_blocksize;
3551 - buf->f_blocks = (ext4_blocks_count(es) -
3552 - EXT4_C2B(sbi, sbi->s_overhead_last));
3553 + buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, sbi->s_overhead);
3554 bfree = percpu_counter_sum_positive(&sbi->s_freeclusters_counter) -
3555 percpu_counter_sum_positive(&sbi->s_dirtyclusters_counter);
3556 /* prevent underflow in case that few free space is available */
3557 diff --git a/fs/locks.c b/fs/locks.c
3558 index 6a64f15..fcc50ab 100644
3559 --- a/fs/locks.c
3560 +++ b/fs/locks.c
3561 @@ -308,7 +308,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
3562 return 0;
3563 }
3564
3565 -static int assign_type(struct file_lock *fl, int type)
3566 +static int assign_type(struct file_lock *fl, long type)
3567 {
3568 switch (type) {
3569 case F_RDLCK:
3570 @@ -445,7 +445,7 @@ static const struct lock_manager_operations lease_manager_ops = {
3571 /*
3572 * Initialize a lease, use the default lock manager operations
3573 */
3574 -static int lease_init(struct file *filp, int type, struct file_lock *fl)
3575 +static int lease_init(struct file *filp, long type, struct file_lock *fl)
3576 {
3577 if (assign_type(fl, type) != 0)
3578 return -EINVAL;
3579 @@ -463,7 +463,7 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
3580 }
3581
3582 /* Allocate a file_lock initialised to this type of lease */
3583 -static struct file_lock *lease_alloc(struct file *filp, int type)
3584 +static struct file_lock *lease_alloc(struct file *filp, long type)
3585 {
3586 struct file_lock *fl = locks_alloc_lock();
3587 int error = -ENOMEM;
3588 diff --git a/fs/nfs/file.c b/fs/nfs/file.c
3589 index aa9b709..f0f439d 100644
3590 --- a/fs/nfs/file.c
3591 +++ b/fs/nfs/file.c
3592 @@ -451,8 +451,11 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
3593
3594 dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page);
3595
3596 - /* Only do I/O if gfp is a superset of GFP_KERNEL */
3597 - if (mapping && (gfp & GFP_KERNEL) == GFP_KERNEL) {
3598 + /* Only do I/O if gfp is a superset of GFP_KERNEL, and we're not
3599 + * doing this memory reclaim for a fs-related allocation.
3600 + */
3601 + if (mapping && (gfp & GFP_KERNEL) == GFP_KERNEL &&
3602 + !(current->flags & PF_FSTRANS)) {
3603 int how = FLUSH_SYNC;
3604
3605 /* Don't let kswapd deadlock waiting for OOM RPC calls */
3606 diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
3607 index 93aa3a4..929ba01 100644
3608 --- a/fs/nfs/idmap.c
3609 +++ b/fs/nfs/idmap.c
3610 @@ -205,12 +205,18 @@ static int nfs_idmap_init_keyring(void)
3611 if (ret < 0)
3612 goto failed_put_key;
3613
3614 + ret = register_key_type(&key_type_id_resolver_legacy);
3615 + if (ret < 0)
3616 + goto failed_reg_legacy;
3617 +
3618 set_bit(KEY_FLAG_ROOT_CAN_CLEAR, &keyring->flags);
3619 cred->thread_keyring = keyring;
3620 cred->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING;
3621 id_resolver_cache = cred;
3622 return 0;
3623
3624 +failed_reg_legacy:
3625 + unregister_key_type(&key_type_id_resolver);
3626 failed_put_key:
3627 key_put(keyring);
3628 failed_put_cred:
3629 @@ -222,6 +228,7 @@ static void nfs_idmap_quit_keyring(void)
3630 {
3631 key_revoke(id_resolver_cache->thread_keyring);
3632 unregister_key_type(&key_type_id_resolver);
3633 + unregister_key_type(&key_type_id_resolver_legacy);
3634 put_cred(id_resolver_cache);
3635 }
3636
3637 @@ -385,7 +392,7 @@ static const struct rpc_pipe_ops idmap_upcall_ops = {
3638 };
3639
3640 static struct key_type key_type_id_resolver_legacy = {
3641 - .name = "id_resolver",
3642 + .name = "id_legacy",
3643 .instantiate = user_instantiate,
3644 .match = user_match,
3645 .revoke = user_revoke,
3646 @@ -658,6 +665,7 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
3647 if (ret < 0)
3648 goto out2;
3649
3650 + BUG_ON(idmap->idmap_key_cons != NULL);
3651 idmap->idmap_key_cons = cons;
3652
3653 ret = rpc_queue_upcall(idmap->idmap_pipe, msg);
3654 @@ -671,8 +679,7 @@ out2:
3655 out1:
3656 kfree(msg);
3657 out0:
3658 - key_revoke(cons->key);
3659 - key_revoke(cons->authkey);
3660 + complete_request_key(cons, ret);
3661 return ret;
3662 }
3663
3664 @@ -706,11 +713,18 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
3665 {
3666 struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
3667 struct idmap *idmap = (struct idmap *)rpci->private;
3668 - struct key_construction *cons = idmap->idmap_key_cons;
3669 + struct key_construction *cons;
3670 struct idmap_msg im;
3671 size_t namelen_in;
3672 int ret;
3673
3674 + /* If instantiation is successful, anyone waiting for key construction
3675 + * will have been woken up and someone else may now have used
3676 + * idmap_key_cons - so after this point we may no longer touch it.
3677 + */
3678 + cons = ACCESS_ONCE(idmap->idmap_key_cons);
3679 + idmap->idmap_key_cons = NULL;
3680 +
3681 if (mlen != sizeof(im)) {
3682 ret = -ENOSPC;
3683 goto out;
3684 @@ -723,7 +737,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
3685
3686 if (!(im.im_status & IDMAP_STATUS_SUCCESS)) {
3687 ret = mlen;
3688 - complete_request_key(idmap->idmap_key_cons, -ENOKEY);
3689 + complete_request_key(cons, -ENOKEY);
3690 goto out_incomplete;
3691 }
3692
3693 @@ -740,7 +754,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
3694 }
3695
3696 out:
3697 - complete_request_key(idmap->idmap_key_cons, ret);
3698 + complete_request_key(cons, ret);
3699 out_incomplete:
3700 return ret;
3701 }
3702 diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
3703 index 42ac1bf..1afe74c 100644
3704 --- a/fs/nfs/objlayout/objio_osd.c
3705 +++ b/fs/nfs/objlayout/objio_osd.c
3706 @@ -487,8 +487,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
3707 struct objio_state *objios = priv;
3708 struct nfs_write_data *wdata = objios->oir.rpcdata;
3709 pgoff_t index = offset / PAGE_SIZE;
3710 - struct page *page = find_get_page(wdata->inode->i_mapping, index);
3711 + struct page *page;
3712 + loff_t i_size = i_size_read(wdata->inode);
3713
3714 + if (offset >= i_size) {
3715 + *uptodate = true;
3716 + dprintk("%s: g_zero_page index=0x%lx\n", __func__, index);
3717 + return ZERO_PAGE(0);
3718 + }
3719 +
3720 + page = find_get_page(wdata->inode->i_mapping, index);
3721 if (!page) {
3722 page = find_or_create_page(wdata->inode->i_mapping,
3723 index, GFP_NOFS);
3724 @@ -509,8 +517,10 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
3725
3726 static void __r4w_put_page(void *priv, struct page *page)
3727 {
3728 - dprintk("%s: index=0x%lx\n", __func__, page->index);
3729 - page_cache_release(page);
3730 + dprintk("%s: index=0x%lx\n", __func__,
3731 + (page == ZERO_PAGE(0)) ? -1UL : page->index);
3732 + if (ZERO_PAGE(0) != page)
3733 + page_cache_release(page);
3734 return;
3735 }
3736
3737 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
3738 index 74c00bc..283d15e 100644
3739 --- a/fs/nfsd/nfs4xdr.c
3740 +++ b/fs/nfsd/nfs4xdr.c
3741 @@ -2233,7 +2233,7 @@ out_acl:
3742 if (bmval0 & FATTR4_WORD0_CASE_INSENSITIVE) {
3743 if ((buflen -= 4) < 0)
3744 goto out_resource;
3745 - WRITE32(1);
3746 + WRITE32(0);
3747 }
3748 if (bmval0 & FATTR4_WORD0_CASE_PRESERVING) {
3749 if ((buflen -= 4) < 0)
3750 diff --git a/fs/select.c b/fs/select.c
3751 index 17d33d0..0baa0a3 100644
3752 --- a/fs/select.c
3753 +++ b/fs/select.c
3754 @@ -345,8 +345,8 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds)
3755 struct fdtable *fdt;
3756
3757 /* handle last in-complete long-word first */
3758 - set = ~(~0UL << (n & (__NFDBITS-1)));
3759 - n /= __NFDBITS;
3760 + set = ~(~0UL << (n & (BITS_PER_LONG-1)));
3761 + n /= BITS_PER_LONG;
3762 fdt = files_fdtable(current->files);
3763 open_fds = fdt->open_fds + n;
3764 max = 0;
3765 @@ -373,7 +373,7 @@ get_max:
3766 max++;
3767 set >>= 1;
3768 } while (set);
3769 - max += n * __NFDBITS;
3770 + max += n * BITS_PER_LONG;
3771 }
3772
3773 return max;
3774 @@ -435,11 +435,11 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
3775 in = *inp++; out = *outp++; ex = *exp++;
3776 all_bits = in | out | ex;
3777 if (all_bits == 0) {
3778 - i += __NFDBITS;
3779 + i += BITS_PER_LONG;
3780 continue;
3781 }
3782
3783 - for (j = 0; j < __NFDBITS; ++j, ++i, bit <<= 1) {
3784 + for (j = 0; j < BITS_PER_LONG; ++j, ++i, bit <<= 1) {
3785 int fput_needed;
3786 if (i >= n)
3787 break;
3788 diff --git a/fs/udf/super.c b/fs/udf/super.c
3789 index 8d86a87..e660ffd 100644
3790 --- a/fs/udf/super.c
3791 +++ b/fs/udf/super.c
3792 @@ -1283,7 +1283,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
3793 BUG_ON(ident != TAG_IDENT_LVD);
3794 lvd = (struct logicalVolDesc *)bh->b_data;
3795 table_len = le32_to_cpu(lvd->mapTableLength);
3796 - if (sizeof(*lvd) + table_len > sb->s_blocksize) {
3797 + if (table_len > sb->s_blocksize - sizeof(*lvd)) {
3798 udf_err(sb, "error loading logical volume descriptor: "
3799 "Partition table too long (%u > %lu)\n", table_len,
3800 sb->s_blocksize - sizeof(*lvd));
3801 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
3802 index ee28844..78ed62f 100644
3803 --- a/include/linux/cpu.h
3804 +++ b/include/linux/cpu.h
3805 @@ -75,8 +75,9 @@ enum {
3806 /* migration should happen before other stuff but after perf */
3807 CPU_PRI_PERF = 20,
3808 CPU_PRI_MIGRATION = 10,
3809 - /* prepare workqueues for other notifiers */
3810 - CPU_PRI_WORKQUEUE = 5,
3811 + /* bring up workqueues before normal notifiers and down after */
3812 + CPU_PRI_WORKQUEUE_UP = 5,
3813 + CPU_PRI_WORKQUEUE_DOWN = -5,
3814 };
3815
3816 #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
3817 diff --git a/include/linux/mm.h b/include/linux/mm.h
3818 index 74aa71b..441a564 100644
3819 --- a/include/linux/mm.h
3820 +++ b/include/linux/mm.h
3821 @@ -1595,6 +1595,7 @@ void vmemmap_populate_print_last(void);
3822 enum mf_flags {
3823 MF_COUNT_INCREASED = 1 << 0,
3824 MF_ACTION_REQUIRED = 1 << 1,
3825 + MF_MUST_KILL = 1 << 2,
3826 };
3827 extern int memory_failure(unsigned long pfn, int trapno, int flags);
3828 extern void memory_failure_queue(unsigned long pfn, int trapno, int flags);
3829 diff --git a/include/linux/net.h b/include/linux/net.h
3830 index be60c7f..95fea14 100644
3831 --- a/include/linux/net.h
3832 +++ b/include/linux/net.h
3833 @@ -72,6 +72,7 @@ struct net;
3834 #define SOCK_NOSPACE 2
3835 #define SOCK_PASSCRED 3
3836 #define SOCK_PASSSEC 4
3837 +#define SOCK_EXTERNALLY_ALLOCATED 5
3838
3839 #ifndef ARCH_HAS_SOCKET_TYPES
3840 /**
3841 diff --git a/include/linux/posix_types.h b/include/linux/posix_types.h
3842 index f04c98c..988f76e 100644
3843 --- a/include/linux/posix_types.h
3844 +++ b/include/linux/posix_types.h
3845 @@ -15,26 +15,14 @@
3846 */
3847
3848 /*
3849 - * Those macros may have been defined in <gnu/types.h>. But we always
3850 - * use the ones here.
3851 + * This macro may have been defined in <gnu/types.h>. But we always
3852 + * use the one here.
3853 */
3854 -#undef __NFDBITS
3855 -#define __NFDBITS (8 * sizeof(unsigned long))
3856 -
3857 #undef __FD_SETSIZE
3858 #define __FD_SETSIZE 1024
3859
3860 -#undef __FDSET_LONGS
3861 -#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
3862 -
3863 -#undef __FDELT
3864 -#define __FDELT(d) ((d) / __NFDBITS)
3865 -
3866 -#undef __FDMASK
3867 -#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
3868 -
3869 typedef struct {
3870 - unsigned long fds_bits [__FDSET_LONGS];
3871 + unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))];
3872 } __kernel_fd_set;
3873
3874 /* Type of a signal handler. */
3875 diff --git a/include/linux/time.h b/include/linux/time.h
3876 index 33a92ea..8da5129 100644
3877 --- a/include/linux/time.h
3878 +++ b/include/linux/time.h
3879 @@ -258,14 +258,6 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
3880
3881 #endif /* __KERNEL__ */
3882
3883 -#define NFDBITS __NFDBITS
3884 -
3885 -#define FD_SETSIZE __FD_SETSIZE
3886 -#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp)
3887 -#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp)
3888 -#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp)
3889 -#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp)
3890 -
3891 /*
3892 * Names of the interval timers, and structure
3893 * defining a timer setting:
3894 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
3895 index aaccc5f..3ad5b33 100644
3896 --- a/include/target/target_core_base.h
3897 +++ b/include/target/target_core_base.h
3898 @@ -229,6 +229,7 @@ enum tcm_sense_reason_table {
3899 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e,
3900 TCM_CHECK_CONDITION_NOT_READY = 0x0f,
3901 TCM_RESERVATION_CONFLICT = 0x10,
3902 + TCM_ADDRESS_OUT_OF_RANGE = 0x11,
3903 };
3904
3905 enum target_sc_flags_table {
3906 diff --git a/kernel/exit.c b/kernel/exit.c
3907 index 9d81012..bfbd856 100644
3908 --- a/kernel/exit.c
3909 +++ b/kernel/exit.c
3910 @@ -471,7 +471,7 @@ static void close_files(struct files_struct * files)
3911 rcu_read_unlock();
3912 for (;;) {
3913 unsigned long set;
3914 - i = j * __NFDBITS;
3915 + i = j * BITS_PER_LONG;
3916 if (i >= fdt->max_fds)
3917 break;
3918 set = fdt->open_fds[j++];
3919 diff --git a/kernel/futex.c b/kernel/futex.c
3920 index e2b0fb9..3717e7b 100644
3921 --- a/kernel/futex.c
3922 +++ b/kernel/futex.c
3923 @@ -2231,11 +2231,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
3924 * @uaddr2: the pi futex we will take prior to returning to user-space
3925 *
3926 * The caller will wait on uaddr and will be requeued by futex_requeue() to
3927 - * uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and
3928 - * complete the acquisition of the rt_mutex prior to returning to userspace.
3929 - * This ensures the rt_mutex maintains an owner when it has waiters; without
3930 - * one, the pi logic wouldn't know which task to boost/deboost, if there was a
3931 - * need to.
3932 + * uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake
3933 + * on uaddr2 and complete the acquisition of the rt_mutex prior to returning to
3934 + * userspace. This ensures the rt_mutex maintains an owner when it has waiters;
3935 + * without one, the pi logic would not know which task to boost/deboost, if
3936 + * there was a need to.
3937 *
3938 * We call schedule in futex_wait_queue_me() when we enqueue and return there
3939 * via the following:
3940 @@ -2272,6 +2272,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
3941 struct futex_q q = futex_q_init;
3942 int res, ret;
3943
3944 + if (uaddr == uaddr2)
3945 + return -EINVAL;
3946 +
3947 if (!bitset)
3948 return -EINVAL;
3949
3950 @@ -2343,7 +2346,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
3951 * signal. futex_unlock_pi() will not destroy the lock_ptr nor
3952 * the pi_state.
3953 */
3954 - WARN_ON(!&q.pi_state);
3955 + WARN_ON(!q.pi_state);
3956 pi_mutex = &q.pi_state->pi_mutex;
3957 ret = rt_mutex_finish_proxy_lock(pi_mutex, to, &rt_waiter, 1);
3958 debug_rt_mutex_free_waiter(&rt_waiter);
3959 @@ -2370,7 +2373,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
3960 * fault, unlock the rt_mutex and return the fault to userspace.
3961 */
3962 if (ret == -EFAULT) {
3963 - if (rt_mutex_owner(pi_mutex) == current)
3964 + if (pi_mutex && rt_mutex_owner(pi_mutex) == current)
3965 rt_mutex_unlock(pi_mutex);
3966 } else if (ret == -EINTR) {
3967 /*
3968 diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
3969 index e09dfbf..52a1817 100644
3970 --- a/kernel/power/hibernate.c
3971 +++ b/kernel/power/hibernate.c
3972 @@ -352,6 +352,7 @@ int hibernation_snapshot(int platform_mode)
3973 }
3974
3975 suspend_console();
3976 + ftrace_stop();
3977 pm_restrict_gfp_mask();
3978
3979 error = dpm_suspend(PMSG_FREEZE);
3980 @@ -377,6 +378,7 @@ int hibernation_snapshot(int platform_mode)
3981 if (error || !in_suspend)
3982 pm_restore_gfp_mask();
3983
3984 + ftrace_start();
3985 resume_console();
3986 dpm_complete(msg);
3987
3988 @@ -479,6 +481,7 @@ int hibernation_restore(int platform_mode)
3989
3990 pm_prepare_console();
3991 suspend_console();
3992 + ftrace_stop();
3993 pm_restrict_gfp_mask();
3994 error = dpm_suspend_start(PMSG_QUIESCE);
3995 if (!error) {
3996 @@ -486,6 +489,7 @@ int hibernation_restore(int platform_mode)
3997 dpm_resume_end(PMSG_RECOVER);
3998 }
3999 pm_restore_gfp_mask();
4000 + ftrace_start();
4001 resume_console();
4002 pm_restore_console();
4003 return error;
4004 @@ -512,6 +516,7 @@ int hibernation_platform_enter(void)
4005
4006 entering_platform_hibernation = true;
4007 suspend_console();
4008 + ftrace_stop();
4009 error = dpm_suspend_start(PMSG_HIBERNATE);
4010 if (error) {
4011 if (hibernation_ops->recover)
4012 @@ -555,6 +560,7 @@ int hibernation_platform_enter(void)
4013 Resume_devices:
4014 entering_platform_hibernation = false;
4015 dpm_resume_end(PMSG_RESTORE);
4016 + ftrace_start();
4017 resume_console();
4018
4019 Close:
4020 diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
4021 index 396d262..c8b7446 100644
4022 --- a/kernel/power/suspend.c
4023 +++ b/kernel/power/suspend.c
4024 @@ -24,6 +24,7 @@
4025 #include <linux/export.h>
4026 #include <linux/suspend.h>
4027 #include <linux/syscore_ops.h>
4028 +#include <linux/ftrace.h>
4029 #include <trace/events/power.h>
4030
4031 #include "power.h"
4032 @@ -212,6 +213,7 @@ int suspend_devices_and_enter(suspend_state_t state)
4033 goto Close;
4034 }
4035 suspend_console();
4036 + ftrace_stop();
4037 suspend_test_start();
4038 error = dpm_suspend_start(PMSG_SUSPEND);
4039 if (error) {
4040 @@ -231,6 +233,7 @@ int suspend_devices_and_enter(suspend_state_t state)
4041 suspend_test_start();
4042 dpm_resume_end(PMSG_RESUME);
4043 suspend_test_finish("resume devices");
4044 + ftrace_start();
4045 resume_console();
4046 Close:
4047 if (suspend_ops->end)
4048 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
4049 index 7da267c..bfe3f8a 100644
4050 --- a/kernel/workqueue.c
4051 +++ b/kernel/workqueue.c
4052 @@ -3582,6 +3582,41 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
4053 return notifier_from_errno(0);
4054 }
4055
4056 +/*
4057 + * Workqueues should be brought up before normal priority CPU notifiers.
4058 + * This will be registered high priority CPU notifier.
4059 + */
4060 +static int __devinit workqueue_cpu_up_callback(struct notifier_block *nfb,
4061 + unsigned long action,
4062 + void *hcpu)
4063 +{
4064 + switch (action & ~CPU_TASKS_FROZEN) {
4065 + case CPU_UP_PREPARE:
4066 + case CPU_UP_CANCELED:
4067 + case CPU_DOWN_FAILED:
4068 + case CPU_ONLINE:
4069 + return workqueue_cpu_callback(nfb, action, hcpu);
4070 + }
4071 + return NOTIFY_OK;
4072 +}
4073 +
4074 +/*
4075 + * Workqueues should be brought down after normal priority CPU notifiers.
4076 + * This will be registered as low priority CPU notifier.
4077 + */
4078 +static int __devinit workqueue_cpu_down_callback(struct notifier_block *nfb,
4079 + unsigned long action,
4080 + void *hcpu)
4081 +{
4082 + switch (action & ~CPU_TASKS_FROZEN) {
4083 + case CPU_DOWN_PREPARE:
4084 + case CPU_DYING:
4085 + case CPU_POST_DEAD:
4086 + return workqueue_cpu_callback(nfb, action, hcpu);
4087 + }
4088 + return NOTIFY_OK;
4089 +}
4090 +
4091 #ifdef CONFIG_SMP
4092
4093 struct work_for_cpu {
4094 @@ -3775,7 +3810,8 @@ static int __init init_workqueues(void)
4095 unsigned int cpu;
4096 int i;
4097
4098 - cpu_notifier(workqueue_cpu_callback, CPU_PRI_WORKQUEUE);
4099 + cpu_notifier(workqueue_cpu_up_callback, CPU_PRI_WORKQUEUE_UP);
4100 + cpu_notifier(workqueue_cpu_down_callback, CPU_PRI_WORKQUEUE_DOWN);
4101
4102 /* initialize gcwqs */
4103 for_each_gcwq_cpu(cpu) {
4104 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
4105 index 97cc273..0de20d7 100644
4106 --- a/mm/memory-failure.c
4107 +++ b/mm/memory-failure.c
4108 @@ -345,14 +345,14 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
4109 * Also when FAIL is set do a force kill because something went
4110 * wrong earlier.
4111 */
4112 -static void kill_procs(struct list_head *to_kill, int doit, int trapno,
4113 +static void kill_procs(struct list_head *to_kill, int forcekill, int trapno,
4114 int fail, struct page *page, unsigned long pfn,
4115 int flags)
4116 {
4117 struct to_kill *tk, *next;
4118
4119 list_for_each_entry_safe (tk, next, to_kill, nd) {
4120 - if (doit) {
4121 + if (forcekill) {
4122 /*
4123 * In case something went wrong with munmapping
4124 * make sure the process doesn't catch the
4125 @@ -858,7 +858,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
4126 struct address_space *mapping;
4127 LIST_HEAD(tokill);
4128 int ret;
4129 - int kill = 1;
4130 + int kill = 1, forcekill;
4131 struct page *hpage = compound_head(p);
4132 struct page *ppage;
4133
4134 @@ -888,7 +888,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
4135 * be called inside page lock (it's recommended but not enforced).
4136 */
4137 mapping = page_mapping(hpage);
4138 - if (!PageDirty(hpage) && mapping &&
4139 + if (!(flags & MF_MUST_KILL) && !PageDirty(hpage) && mapping &&
4140 mapping_cap_writeback_dirty(mapping)) {
4141 if (page_mkclean(hpage)) {
4142 SetPageDirty(hpage);
4143 @@ -965,12 +965,14 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
4144 * Now that the dirty bit has been propagated to the
4145 * struct page and all unmaps done we can decide if
4146 * killing is needed or not. Only kill when the page
4147 - * was dirty, otherwise the tokill list is merely
4148 + * was dirty or the process is not restartable,
4149 + * otherwise the tokill list is merely
4150 * freed. When there was a problem unmapping earlier
4151 * use a more force-full uncatchable kill to prevent
4152 * any accesses to the poisoned memory.
4153 */
4154 - kill_procs(&tokill, !!PageDirty(ppage), trapno,
4155 + forcekill = PageDirty(ppage) || (flags & MF_MUST_KILL);
4156 + kill_procs(&tokill, forcekill, trapno,
4157 ret != SWAP_SUCCESS, p, pfn, flags);
4158
4159 return ret;
4160 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
4161 index efea35b..cf4a49c 100644
4162 --- a/net/8021q/vlan.c
4163 +++ b/net/8021q/vlan.c
4164 @@ -403,6 +403,9 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
4165 break;
4166
4167 case NETDEV_DOWN:
4168 + if (dev->features & NETIF_F_HW_VLAN_FILTER)
4169 + vlan_vid_del(dev, 0);
4170 +
4171 /* Put all VLANs for this dev in the down state too. */
4172 for (i = 0; i < VLAN_N_VID; i++) {
4173 vlandev = vlan_group_get_device(grp, i);
4174 diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
4175 index aa6f716..7bf4c21 100644
4176 --- a/net/caif/caif_dev.c
4177 +++ b/net/caif/caif_dev.c
4178 @@ -562,9 +562,9 @@ static int __init caif_device_init(void)
4179
4180 static void __exit caif_device_exit(void)
4181 {
4182 - unregister_pernet_subsys(&caif_net_ops);
4183 unregister_netdevice_notifier(&caif_device_notifier);
4184 dev_remove_pack(&caif_packet_type);
4185 + unregister_pernet_subsys(&caif_net_ops);
4186 }
4187
4188 module_init(caif_device_init);
4189 diff --git a/net/compat.c b/net/compat.c
4190 index e055708..ae6d67a 100644
4191 --- a/net/compat.c
4192 +++ b/net/compat.c
4193 @@ -221,6 +221,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
4194 {
4195 struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
4196 struct compat_cmsghdr cmhdr;
4197 + struct compat_timeval ctv;
4198 + struct compat_timespec cts[3];
4199 int cmlen;
4200
4201 if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {
4202 @@ -229,8 +231,6 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
4203 }
4204
4205 if (!COMPAT_USE_64BIT_TIME) {
4206 - struct compat_timeval ctv;
4207 - struct compat_timespec cts[3];
4208 if (level == SOL_SOCKET && type == SCM_TIMESTAMP) {
4209 struct timeval *tv = (struct timeval *)data;
4210 ctv.tv_sec = tv->tv_sec;
4211 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
4212 index 90430b7..b8052ba 100644
4213 --- a/net/core/rtnetlink.c
4214 +++ b/net/core/rtnetlink.c
4215 @@ -671,6 +671,12 @@ static void set_operstate(struct net_device *dev, unsigned char transition)
4216 }
4217 }
4218
4219 +static unsigned int rtnl_dev_get_flags(const struct net_device *dev)
4220 +{
4221 + return (dev->flags & ~(IFF_PROMISC | IFF_ALLMULTI)) |
4222 + (dev->gflags & (IFF_PROMISC | IFF_ALLMULTI));
4223 +}
4224 +
4225 static unsigned int rtnl_dev_combine_flags(const struct net_device *dev,
4226 const struct ifinfomsg *ifm)
4227 {
4228 @@ -679,7 +685,7 @@ static unsigned int rtnl_dev_combine_flags(const struct net_device *dev,
4229 /* bugwards compatibility: ifi_change == 0 is treated as ~0 */
4230 if (ifm->ifi_change)
4231 flags = (flags & ifm->ifi_change) |
4232 - (dev->flags & ~ifm->ifi_change);
4233 + (rtnl_dev_get_flags(dev) & ~ifm->ifi_change);
4234
4235 return flags;
4236 }
4237 diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
4238 index c48adc5..667c1d4 100644
4239 --- a/net/ipv4/cipso_ipv4.c
4240 +++ b/net/ipv4/cipso_ipv4.c
4241 @@ -1725,8 +1725,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
4242 case CIPSO_V4_TAG_LOCAL:
4243 /* This is a non-standard tag that we only allow for
4244 * local connections, so if the incoming interface is
4245 - * not the loopback device drop the packet. */
4246 - if (!(skb->dev->flags & IFF_LOOPBACK)) {
4247 + * not the loopback device drop the packet. Further,
4248 + * there is no legitimate reason for setting this from
4249 + * userspace so reject it if skb is NULL. */
4250 + if (skb == NULL || !(skb->dev->flags & IFF_LOOPBACK)) {
4251 err_offset = opt_iter;
4252 goto validate_return_locked;
4253 }
4254 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
4255 index 6589e11..d6feb1e 100644
4256 --- a/net/ipv4/tcp.c
4257 +++ b/net/ipv4/tcp.c
4258 @@ -2408,7 +2408,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
4259 /* Cap the max timeout in ms TCP will retry/retrans
4260 * before giving up and aborting (ETIMEDOUT) a connection.
4261 */
4262 - icsk->icsk_user_timeout = msecs_to_jiffies(val);
4263 + if (val < 0)
4264 + err = -EINVAL;
4265 + else
4266 + icsk->icsk_user_timeout = msecs_to_jiffies(val);
4267 break;
4268 default:
4269 err = -ENOPROTOOPT;
4270 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
4271 index 257b617..56a9c8d 100644
4272 --- a/net/ipv4/tcp_input.c
4273 +++ b/net/ipv4/tcp_input.c
4274 @@ -5441,7 +5441,9 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
4275 if (tp->copied_seq == tp->rcv_nxt &&
4276 len - tcp_header_len <= tp->ucopy.len) {
4277 #ifdef CONFIG_NET_DMA
4278 - if (tcp_dma_try_early_copy(sk, skb, tcp_header_len)) {
4279 + if (tp->ucopy.task == current &&
4280 + sock_owned_by_user(sk) &&
4281 + tcp_dma_try_early_copy(sk, skb, tcp_header_len)) {
4282 copied_early = 1;
4283 eaten = 1;
4284 }
4285 diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
4286 index d132b98..25be683 100644
4287 --- a/net/mac80211/mlme.c
4288 +++ b/net/mac80211/mlme.c
4289 @@ -1813,7 +1813,8 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
4290 if (status_code != WLAN_STATUS_SUCCESS) {
4291 printk(KERN_DEBUG "%s: %pM denied authentication (status %d)\n",
4292 sdata->name, mgmt->sa, status_code);
4293 - goto out;
4294 + ieee80211_destroy_auth_data(sdata, false);
4295 + return RX_MGMT_CFG80211_RX_AUTH;
4296 }
4297
4298 switch (ifmgd->auth_data->algorithm) {
4299 @@ -1835,7 +1836,6 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
4300 }
4301
4302 printk(KERN_DEBUG "%s: authenticated\n", sdata->name);
4303 - out:
4304 ifmgd->auth_data->done = true;
4305 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
4306 run_again(ifmgd, ifmgd->auth_data->timeout);
4307 diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
4308 index ebd2296..992acaa 100644
4309 --- a/net/sched/sch_netem.c
4310 +++ b/net/sched/sch_netem.c
4311 @@ -329,29 +329,22 @@ static psched_time_t packet_len_2_sched_time(unsigned int len, struct netem_sche
4312 return PSCHED_NS2TICKS(ticks);
4313 }
4314
4315 -static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
4316 +static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
4317 {
4318 struct sk_buff_head *list = &sch->q;
4319 psched_time_t tnext = netem_skb_cb(nskb)->time_to_send;
4320 - struct sk_buff *skb;
4321 -
4322 - if (likely(skb_queue_len(list) < sch->limit)) {
4323 - skb = skb_peek_tail(list);
4324 - /* Optimize for add at tail */
4325 - if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send))
4326 - return qdisc_enqueue_tail(nskb, sch);
4327 + struct sk_buff *skb = skb_peek_tail(list);
4328
4329 - skb_queue_reverse_walk(list, skb) {
4330 - if (tnext >= netem_skb_cb(skb)->time_to_send)
4331 - break;
4332 - }
4333 + /* Optimize for add at tail */
4334 + if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send))
4335 + return __skb_queue_tail(list, nskb);
4336
4337 - __skb_queue_after(list, skb, nskb);
4338 - sch->qstats.backlog += qdisc_pkt_len(nskb);
4339 - return NET_XMIT_SUCCESS;
4340 + skb_queue_reverse_walk(list, skb) {
4341 + if (tnext >= netem_skb_cb(skb)->time_to_send)
4342 + break;
4343 }
4344
4345 - return qdisc_reshape_fail(nskb, sch);
4346 + __skb_queue_after(list, skb, nskb);
4347 }
4348
4349 /*
4350 @@ -366,7 +359,6 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
4351 /* We don't fill cb now as skb_unshare() may invalidate it */
4352 struct netem_skb_cb *cb;
4353 struct sk_buff *skb2;
4354 - int ret;
4355 int count = 1;
4356
4357 /* Random duplication */
4358 @@ -414,6 +406,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
4359 skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
4360 }
4361
4362 + if (unlikely(skb_queue_len(&sch->q) >= sch->limit))
4363 + return qdisc_reshape_fail(skb, sch);
4364 +
4365 + sch->qstats.backlog += qdisc_pkt_len(skb);
4366 +
4367 cb = netem_skb_cb(skb);
4368 if (q->gap == 0 || /* not doing reordering */
4369 q->counter < q->gap - 1 || /* inside last reordering gap */
4370 @@ -445,7 +442,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
4371
4372 cb->time_to_send = now + delay;
4373 ++q->counter;
4374 - ret = tfifo_enqueue(skb, sch);
4375 + tfifo_enqueue(skb, sch);
4376 } else {
4377 /*
4378 * Do re-ordering by putting one out of N packets at the front
4379 @@ -455,16 +452,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
4380 q->counter = 0;
4381
4382 __skb_queue_head(&sch->q, skb);
4383 - sch->qstats.backlog += qdisc_pkt_len(skb);
4384 sch->qstats.requeues++;
4385 - ret = NET_XMIT_SUCCESS;
4386 - }
4387 -
4388 - if (ret != NET_XMIT_SUCCESS) {
4389 - if (net_xmit_drop_count(ret)) {
4390 - sch->qstats.drops++;
4391 - return ret;
4392 - }
4393 }
4394
4395 return NET_XMIT_SUCCESS;
4396 diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
4397 index d7eea99..c6a5867 100644
4398 --- a/net/sched/sch_sfb.c
4399 +++ b/net/sched/sch_sfb.c
4400 @@ -570,6 +570,8 @@ static int sfb_dump(struct Qdisc *sch, struct sk_buff *skb)
4401
4402 sch->qstats.backlog = q->qdisc->qstats.backlog;
4403 opts = nla_nest_start(skb, TCA_OPTIONS);
4404 + if (opts == NULL)
4405 + goto nla_put_failure;
4406 NLA_PUT(skb, TCA_SFB_PARMS, sizeof(opt), &opt);
4407 return nla_nest_end(skb, opts);
4408
4409 diff --git a/net/sctp/input.c b/net/sctp/input.c
4410 index 80f71af..be772c0 100644
4411 --- a/net/sctp/input.c
4412 +++ b/net/sctp/input.c
4413 @@ -736,15 +736,12 @@ static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
4414
4415 epb = &ep->base;
4416
4417 - if (hlist_unhashed(&epb->node))
4418 - return;
4419 -
4420 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
4421
4422 head = &sctp_ep_hashtable[epb->hashent];
4423
4424 sctp_write_lock(&head->lock);
4425 - __hlist_del(&epb->node);
4426 + hlist_del_init(&epb->node);
4427 sctp_write_unlock(&head->lock);
4428 }
4429
4430 @@ -825,7 +822,7 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
4431 head = &sctp_assoc_hashtable[epb->hashent];
4432
4433 sctp_write_lock(&head->lock);
4434 - __hlist_del(&epb->node);
4435 + hlist_del_init(&epb->node);
4436 sctp_write_unlock(&head->lock);
4437 }
4438
4439 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
4440 index 92ba71d..dba20d6 100644
4441 --- a/net/sctp/socket.c
4442 +++ b/net/sctp/socket.c
4443 @@ -1231,8 +1231,14 @@ out_free:
4444 SCTP_DEBUG_PRINTK("About to exit __sctp_connect() free asoc: %p"
4445 " kaddrs: %p err: %d\n",
4446 asoc, kaddrs, err);
4447 - if (asoc)
4448 + if (asoc) {
4449 + /* sctp_primitive_ASSOCIATE may have added this association
4450 + * To the hash table, try to unhash it, just in case, its a noop
4451 + * if it wasn't hashed so we're safe
4452 + */
4453 + sctp_unhash_established(asoc);
4454 sctp_association_free(asoc);
4455 + }
4456 return err;
4457 }
4458
4459 @@ -1942,8 +1948,10 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
4460 goto out_unlock;
4461
4462 out_free:
4463 - if (new_asoc)
4464 + if (new_asoc) {
4465 + sctp_unhash_established(asoc);
4466 sctp_association_free(asoc);
4467 + }
4468 out_unlock:
4469 sctp_release_sock(sk);
4470
4471 diff --git a/net/socket.c b/net/socket.c
4472 index 851edcd..573b261 100644
4473 --- a/net/socket.c
4474 +++ b/net/socket.c
4475 @@ -522,6 +522,9 @@ void sock_release(struct socket *sock)
4476 if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
4477 printk(KERN_ERR "sock_release: fasync list not empty!\n");
4478
4479 + if (test_bit(SOCK_EXTERNALLY_ALLOCATED, &sock->flags))
4480 + return;
4481 +
4482 percpu_sub(sockets_in_use, 1);
4483 if (!sock->file) {
4484 iput(SOCK_INODE(sock));
4485 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
4486 index 994cfea..eda32ae 100644
4487 --- a/net/sunrpc/sched.c
4488 +++ b/net/sunrpc/sched.c
4489 @@ -790,7 +790,9 @@ void rpc_execute(struct rpc_task *task)
4490
4491 static void rpc_async_schedule(struct work_struct *work)
4492 {
4493 + current->flags |= PF_FSTRANS;
4494 __rpc_execute(container_of(work, struct rpc_task, u.tk_work));
4495 + current->flags &= ~PF_FSTRANS;
4496 }
4497
4498 /**
4499 diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
4500 index b446e10..06cdbff 100644
4501 --- a/net/sunrpc/xprtrdma/transport.c
4502 +++ b/net/sunrpc/xprtrdma/transport.c
4503 @@ -200,6 +200,7 @@ xprt_rdma_connect_worker(struct work_struct *work)
4504 int rc = 0;
4505
4506 if (!xprt->shutdown) {
4507 + current->flags |= PF_FSTRANS;
4508 xprt_clear_connected(xprt);
4509
4510 dprintk("RPC: %s: %sconnect\n", __func__,
4511 @@ -212,10 +213,10 @@ xprt_rdma_connect_worker(struct work_struct *work)
4512
4513 out:
4514 xprt_wake_pending_tasks(xprt, rc);
4515 -
4516 out_clear:
4517 dprintk("RPC: %s: exit\n", __func__);
4518 xprt_clear_connecting(xprt);
4519 + current->flags &= ~PF_FSTRANS;
4520 }
4521
4522 /*
4523 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
4524 index 890b03f..b88c6bf 100644
4525 --- a/net/sunrpc/xprtsock.c
4526 +++ b/net/sunrpc/xprtsock.c
4527 @@ -1895,6 +1895,8 @@ static void xs_local_setup_socket(struct work_struct *work)
4528 if (xprt->shutdown)
4529 goto out;
4530
4531 + current->flags |= PF_FSTRANS;
4532 +
4533 clear_bit(XPRT_CONNECTION_ABORT, &xprt->state);
4534 status = __sock_create(xprt->xprt_net, AF_LOCAL,
4535 SOCK_STREAM, 0, &sock, 1);
4536 @@ -1928,6 +1930,7 @@ static void xs_local_setup_socket(struct work_struct *work)
4537 out:
4538 xprt_clear_connecting(xprt);
4539 xprt_wake_pending_tasks(xprt, status);
4540 + current->flags &= ~PF_FSTRANS;
4541 }
4542
4543 static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
4544 @@ -1970,6 +1973,8 @@ static void xs_udp_setup_socket(struct work_struct *work)
4545 if (xprt->shutdown)
4546 goto out;
4547
4548 + current->flags |= PF_FSTRANS;
4549 +
4550 /* Start by resetting any existing state */
4551 xs_reset_transport(transport);
4552 sock = xs_create_sock(xprt, transport,
4553 @@ -1988,6 +1993,7 @@ static void xs_udp_setup_socket(struct work_struct *work)
4554 out:
4555 xprt_clear_connecting(xprt);
4556 xprt_wake_pending_tasks(xprt, status);
4557 + current->flags &= ~PF_FSTRANS;
4558 }
4559
4560 /*
4561 @@ -2113,6 +2119,8 @@ static void xs_tcp_setup_socket(struct work_struct *work)
4562 if (xprt->shutdown)
4563 goto out;
4564
4565 + current->flags |= PF_FSTRANS;
4566 +
4567 if (!sock) {
4568 clear_bit(XPRT_CONNECTION_ABORT, &xprt->state);
4569 sock = xs_create_sock(xprt, transport,
4570 @@ -2162,6 +2170,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)
4571 case -EINPROGRESS:
4572 case -EALREADY:
4573 xprt_clear_connecting(xprt);
4574 + current->flags &= ~PF_FSTRANS;
4575 return;
4576 case -EINVAL:
4577 /* Happens, for instance, if the user specified a link
4578 @@ -2174,6 +2183,7 @@ out_eagain:
4579 out:
4580 xprt_clear_connecting(xprt);
4581 xprt_wake_pending_tasks(xprt, status);
4582 + current->flags &= ~PF_FSTRANS;
4583 }
4584
4585 /**
4586 diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
4587 index 788a12c..2ab7850 100644
4588 --- a/net/wanrouter/wanmain.c
4589 +++ b/net/wanrouter/wanmain.c
4590 @@ -602,36 +602,31 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
4591 * successfully, add it to the interface list.
4592 */
4593
4594 - if (dev->name == NULL) {
4595 - err = -EINVAL;
4596 - } else {
4597 +#ifdef WANDEBUG
4598 + printk(KERN_INFO "%s: registering interface %s...\n",
4599 + wanrouter_modname, dev->name);
4600 +#endif
4601
4602 - #ifdef WANDEBUG
4603 - printk(KERN_INFO "%s: registering interface %s...\n",
4604 - wanrouter_modname, dev->name);
4605 - #endif
4606 -
4607 - err = register_netdev(dev);
4608 - if (!err) {
4609 - struct net_device *slave = NULL;
4610 - unsigned long smp_flags=0;
4611 -
4612 - lock_adapter_irq(&wandev->lock, &smp_flags);
4613 -
4614 - if (wandev->dev == NULL) {
4615 - wandev->dev = dev;
4616 - } else {
4617 - for (slave=wandev->dev;
4618 - DEV_TO_SLAVE(slave);
4619 - slave = DEV_TO_SLAVE(slave))
4620 - DEV_TO_SLAVE(slave) = dev;
4621 - }
4622 - ++wandev->ndev;
4623 -
4624 - unlock_adapter_irq(&wandev->lock, &smp_flags);
4625 - err = 0; /* done !!! */
4626 - goto out;
4627 + err = register_netdev(dev);
4628 + if (!err) {
4629 + struct net_device *slave = NULL;
4630 + unsigned long smp_flags=0;
4631 +
4632 + lock_adapter_irq(&wandev->lock, &smp_flags);
4633 +
4634 + if (wandev->dev == NULL) {
4635 + wandev->dev = dev;
4636 + } else {
4637 + for (slave=wandev->dev;
4638 + DEV_TO_SLAVE(slave);
4639 + slave = DEV_TO_SLAVE(slave))
4640 + DEV_TO_SLAVE(slave) = dev;
4641 }
4642 + ++wandev->ndev;
4643 +
4644 + unlock_adapter_irq(&wandev->lock, &smp_flags);
4645 + err = 0; /* done !!! */
4646 + goto out;
4647 }
4648 if (wandev->del_if)
4649 wandev->del_if(wandev, dev);
4650 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
4651 index d85b793..5626222 100644
4652 --- a/security/selinux/hooks.c
4653 +++ b/security/selinux/hooks.c
4654 @@ -2162,7 +2162,7 @@ static inline void flush_unauthorized_files(const struct cred *cred,
4655 int fd;
4656
4657 j++;
4658 - i = j * __NFDBITS;
4659 + i = j * BITS_PER_LONG;
4660 fdt = files_fdtable(files);
4661 if (i >= fdt->max_fds)
4662 break;
4663 diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
4664 index 1cff331..4608c2c 100644
4665 --- a/sound/drivers/mpu401/mpu401_uart.c
4666 +++ b/sound/drivers/mpu401/mpu401_uart.c
4667 @@ -554,6 +554,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
4668 spin_lock_init(&mpu->output_lock);
4669 spin_lock_init(&mpu->timer_lock);
4670 mpu->hardware = hardware;
4671 + mpu->irq = -1;
4672 if (! (info_flags & MPU401_INFO_INTEGRATED)) {
4673 int res_size = hardware == MPU401_HW_PC98II ? 4 : 2;
4674 mpu->res = request_region(port, res_size, "MPU401 UART");
4675 diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
4676 index 83f345f..d1b805a 100644
4677 --- a/sound/pci/hda/patch_hdmi.c
4678 +++ b/sound/pci/hda/patch_hdmi.c
4679 @@ -876,7 +876,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
4680 struct hdmi_spec_per_pin *per_pin;
4681 struct hdmi_eld *eld;
4682 struct hdmi_spec_per_cvt *per_cvt = NULL;
4683 - int pinctl;
4684
4685 /* Validate hinfo */
4686 pin_idx = hinfo_to_pin_index(spec, hinfo);
4687 @@ -912,11 +911,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
4688 snd_hda_codec_write(codec, per_pin->pin_nid, 0,
4689 AC_VERB_SET_CONNECT_SEL,
4690 mux_idx);
4691 - pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
4692 - AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4693 - snd_hda_codec_write(codec, per_pin->pin_nid, 0,
4694 - AC_VERB_SET_PIN_WIDGET_CONTROL,
4695 - pinctl | PIN_OUT);
4696 snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid);
4697
4698 /* Initially set the converter's capabilities */
4699 @@ -1153,11 +1147,17 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4700 struct hdmi_spec *spec = codec->spec;
4701 int pin_idx = hinfo_to_pin_index(spec, hinfo);
4702 hda_nid_t pin_nid = spec->pins[pin_idx].pin_nid;
4703 + int pinctl;
4704
4705 hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
4706
4707 hdmi_setup_audio_infoframe(codec, pin_idx, substream);
4708
4709 + pinctl = snd_hda_codec_read(codec, pin_nid, 0,
4710 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4711 + snd_hda_codec_write(codec, pin_nid, 0,
4712 + AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl | PIN_OUT);
4713 +
4714 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
4715 }
4716
4717 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4718 index c43264f..62e1627 100644
4719 --- a/sound/pci/hda/patch_realtek.c
4720 +++ b/sound/pci/hda/patch_realtek.c
4721 @@ -5858,6 +5858,15 @@ static int alc269_resume(struct hda_codec *codec)
4722 }
4723 #endif /* CONFIG_PM */
4724
4725 +static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4726 + const struct alc_fixup *fix, int action)
4727 +{
4728 + struct alc_spec *spec = codec->spec;
4729 +
4730 + if (action == ALC_FIXUP_ACT_PRE_PROBE)
4731 + spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4732 +}
4733 +
4734 static void alc269_fixup_hweq(struct hda_codec *codec,
4735 const struct alc_fixup *fix, int action)
4736 {
4737 @@ -5984,6 +5993,8 @@ enum {
4738 ALC269VB_FIXUP_AMIC,
4739 ALC269VB_FIXUP_DMIC,
4740 ALC269_FIXUP_MIC2_MUTE_LED,
4741 + ALC269_FIXUP_LENOVO_DOCK,
4742 + ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
4743 };
4744
4745 static const struct alc_fixup alc269_fixups[] = {
4746 @@ -6108,6 +6119,20 @@ static const struct alc_fixup alc269_fixups[] = {
4747 .type = ALC_FIXUP_FUNC,
4748 .v.func = alc269_fixup_mic2_mute,
4749 },
4750 + [ALC269_FIXUP_LENOVO_DOCK] = {
4751 + .type = ALC_FIXUP_PINS,
4752 + .v.pins = (const struct alc_pincfg[]) {
4753 + { 0x19, 0x23a11040 }, /* dock mic */
4754 + { 0x1b, 0x2121103f }, /* dock headphone */
4755 + { }
4756 + },
4757 + .chained = true,
4758 + .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4759 + },
4760 + [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
4761 + .type = ALC_FIXUP_FUNC,
4762 + .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
4763 + },
4764 };
4765
4766 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4767 @@ -6131,6 +6156,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4768 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4769 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4770 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
4771 + SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
4772 + SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
4773 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
4774 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
4775 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
4776 @@ -6189,6 +6216,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4777 static const struct alc_model_fixup alc269_fixup_models[] = {
4778 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
4779 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
4780 + {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
4781 {}
4782 };
4783
4784 @@ -6977,6 +7005,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
4785 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
4786 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
4787 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
4788 + { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
4789 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
4790 .patch = patch_alc861 },
4791 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
4792 diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
4793 index 7494fbc..fd53312 100644
4794 --- a/sound/pci/hda/patch_sigmatel.c
4795 +++ b/sound/pci/hda/patch_sigmatel.c
4796 @@ -100,6 +100,8 @@ enum {
4797 STAC_92HD83XXX_HP_cNB11_INTQUAD,
4798 STAC_HP_DV7_4000,
4799 STAC_HP_ZEPHYR,
4800 + STAC_92HD83XXX_HP_LED,
4801 + STAC_92HD83XXX_HP_INV_LED,
4802 STAC_92HD83XXX_MODELS
4803 };
4804
4805 @@ -1672,6 +1674,8 @@ static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
4806 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
4807 [STAC_HP_DV7_4000] = "hp-dv7-4000",
4808 [STAC_HP_ZEPHYR] = "hp-zephyr",
4809 + [STAC_92HD83XXX_HP_LED] = "hp-led",
4810 + [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led",
4811 };
4812
4813 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
4814 @@ -1726,6 +1730,8 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
4815 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
4816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
4817 "HP", STAC_HP_ZEPHYR),
4818 + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
4819 + "HP Mini", STAC_92HD83XXX_HP_LED),
4820 {} /* terminator */
4821 };
4822
4823 @@ -4431,7 +4437,13 @@ static int stac92xx_init(struct hda_codec *codec)
4824 snd_hda_jack_report_sync(codec);
4825
4826 /* sync mute LED */
4827 - snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
4828 + if (spec->gpio_led) {
4829 + if (spec->vmaster_mute.hook)
4830 + snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
4831 + else /* the very first init call doesn't have vmaster yet */
4832 + stac92xx_update_led_status(codec, false);
4833 + }
4834 +
4835 if (spec->dac_list)
4836 stac92xx_power_down(codec);
4837 return 0;
4838 @@ -5528,6 +5540,7 @@ static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
4839 static int patch_stac92hd83xxx(struct hda_codec *codec)
4840 {
4841 struct sigmatel_spec *spec;
4842 + int default_polarity = -1; /* no default cfg */
4843 int err;
4844
4845 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4846 @@ -5576,9 +5589,15 @@ again:
4847 case STAC_HP_ZEPHYR:
4848 spec->init = stac92hd83xxx_hp_zephyr_init;
4849 break;
4850 + case STAC_92HD83XXX_HP_LED:
4851 + default_polarity = 0;
4852 + break;
4853 + case STAC_92HD83XXX_HP_INV_LED:
4854 + default_polarity = 1;
4855 + break;
4856 }
4857
4858 - if (find_mute_led_cfg(codec, -1/*no default cfg*/))
4859 + if (find_mute_led_cfg(codec, default_polarity))
4860 snd_printd("mute LED gpio %d polarity %d\n",
4861 spec->gpio_led,
4862 spec->gpio_led_polarity);
4863 diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
4864 index 06214fd..3998d09b 100644
4865 --- a/sound/pci/hda/patch_via.c
4866 +++ b/sound/pci/hda/patch_via.c
4867 @@ -3233,7 +3233,7 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec)
4868 {
4869 struct via_spec *spec = codec->spec;
4870 int imux_is_smixer;
4871 - unsigned int parm;
4872 + unsigned int parm, parm2;
4873 /* MUX6 (1eh) = stereo mixer */
4874 imux_is_smixer =
4875 snd_hda_codec_read(codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5;
4876 @@ -3256,7 +3256,7 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec)
4877 parm = AC_PWRST_D3;
4878 set_pin_power_state(codec, 0x27, &parm);
4879 update_power_state(codec, 0x1a, parm);
4880 - update_power_state(codec, 0xb, parm);
4881 + parm2 = parm; /* for pin 0x0b */
4882
4883 /* PW2 (26h), AOW2 (ah) */
4884 parm = AC_PWRST_D3;
4885 @@ -3271,6 +3271,9 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec)
4886 if (!spec->hp_independent_mode) /* check for redirected HP */
4887 set_pin_power_state(codec, 0x28, &parm);
4888 update_power_state(codec, 0x8, parm);
4889 + if (!spec->hp_independent_mode && parm2 != AC_PWRST_D3)
4890 + parm = parm2;
4891 + update_power_state(codec, 0xb, parm);
4892 /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */
4893 update_power_state(codec, 0x21, imux_is_smixer ? AC_PWRST_D0 : parm);
4894
4895 diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
4896 index 15d467f..96f6f9f 100644
4897 --- a/sound/soc/codecs/wm8962.c
4898 +++ b/sound/soc/codecs/wm8962.c
4899 @@ -2488,6 +2488,9 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
4900 /* VMID 2*250k */
4901 snd_soc_update_bits(codec, WM8962_PWR_MGMT_1,
4902 WM8962_VMID_SEL_MASK, 0x100);
4903 +
4904 + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
4905 + msleep(100);
4906 break;
4907
4908 case SND_SOC_BIAS_OFF:
4909 @@ -3710,6 +3713,9 @@ static int wm8962_runtime_resume(struct device *dev)
4910 }
4911
4912 regcache_cache_only(wm8962->regmap, false);
4913 +
4914 + wm8962_reset(wm8962);
4915 +
4916 regcache_sync(wm8962->regmap);
4917
4918 regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
4919 diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
4920 index f351b93..4c471a5 100644
4921 --- a/sound/soc/codecs/wm8994.c
4922 +++ b/sound/soc/codecs/wm8994.c
4923 @@ -2695,7 +2695,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
4924 return -EINVAL;
4925 }
4926
4927 - bclk_rate = params_rate(params) * 2;
4928 + bclk_rate = params_rate(params) * 4;
4929 switch (params_format(params)) {
4930 case SNDRV_PCM_FORMAT_S16_LE:
4931 bclk_rate *= 16;
4932 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
4933 index 1bb6d4a..c41efe0 100644
4934 --- a/sound/soc/soc-dapm.c
4935 +++ b/sound/soc/soc-dapm.c
4936 @@ -1442,7 +1442,15 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
4937 }
4938
4939 list_for_each_entry(w, &card->widgets, list) {
4940 - list_del_init(&w->dirty);
4941 + switch (w->id) {
4942 + case snd_soc_dapm_pre:
4943 + case snd_soc_dapm_post:
4944 + /* These widgets always need to be powered */
4945 + break;
4946 + default:
4947 + list_del_init(&w->dirty);
4948 + break;
4949 + }
4950
4951 if (w->power) {
4952 d = w->dapm;
4953 diff --git a/sound/usb/clock.c b/sound/usb/clock.c
4954 index 379baad..5e634a2 100644
4955 --- a/sound/usb/clock.c
4956 +++ b/sound/usb/clock.c
4957 @@ -111,7 +111,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
4958 return 0;
4959
4960 /* If a clock source can't tell us whether it's valid, we assume it is */
4961 - if (!uac2_control_is_readable(cs_desc->bmControls, UAC2_CS_CONTROL_CLOCK_VALID))
4962 + if (!uac2_control_is_readable(cs_desc->bmControls,
4963 + UAC2_CS_CONTROL_CLOCK_VALID - 1))
4964 return 1;
4965
4966 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,

  ViewVC Help
Powered by ViewVC 1.1.20