Magellan Linux

Annotation of /trunk/kernel26-magellan/patches-2.6.35-r4/0104-2.6.35.5-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1138 - (hide annotations) (download)
Tue Sep 21 13:53:34 2010 UTC (13 years, 9 months ago) by niro
File size: 171638 byte(s)
-2.6.35-magellan-r4: updated to linux-2.6.35.5, removed CVE-2010-3301 hotfix, as it is provided by 2.6.35.5
1 niro 1138 diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
2     index 1d38b0d..dc25bb8 100644
3     --- a/Documentation/sound/alsa/HD-Audio-Models.txt
4     +++ b/Documentation/sound/alsa/HD-Audio-Models.txt
5     @@ -288,6 +288,7 @@ Conexant 5051
6     Conexant 5066
7     =============
8     laptop Basic Laptop config (default)
9     + hp-laptop HP laptops, e g G60
10     dell-laptop Dell laptops
11     olpc-xo-1_5 OLPC XO 1.5
12     ideapad Lenovo IdeaPad U150
13     diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
14     index 2c1db77..a6c66f5 100644
15     --- a/arch/arm/kernel/entry-common.S
16     +++ b/arch/arm/kernel/entry-common.S
17     @@ -382,11 +382,13 @@ ENDPROC(sys_clone_wrapper)
18    
19     sys_sigreturn_wrapper:
20     add r0, sp, #S_OFF
21     + mov why, #0 @ prevent syscall restart handling
22     b sys_sigreturn
23     ENDPROC(sys_sigreturn_wrapper)
24    
25     sys_rt_sigreturn_wrapper:
26     add r0, sp, #S_OFF
27     + mov why, #0 @ prevent syscall restart handling
28     b sys_rt_sigreturn
29     ENDPROC(sys_rt_sigreturn_wrapper)
30    
31     diff --git a/arch/ia64/include/asm/compat.h b/arch/ia64/include/asm/compat.h
32     index f90edc8..9301a28 100644
33     --- a/arch/ia64/include/asm/compat.h
34     +++ b/arch/ia64/include/asm/compat.h
35     @@ -199,7 +199,7 @@ ptr_to_compat(void __user *uptr)
36     }
37    
38     static __inline__ void __user *
39     -compat_alloc_user_space (long len)
40     +arch_compat_alloc_user_space (long len)
41     {
42     struct pt_regs *regs = task_pt_regs(current);
43     return (void __user *) (((regs->r12 & 0xffffffff) & -16) - len);
44     diff --git a/arch/ia64/kernel/msi_ia64.c b/arch/ia64/kernel/msi_ia64.c
45     index 6c89228..4a746ea 100644
46     --- a/arch/ia64/kernel/msi_ia64.c
47     +++ b/arch/ia64/kernel/msi_ia64.c
48     @@ -25,7 +25,7 @@ static int ia64_set_msi_irq_affinity(unsigned int irq,
49     if (irq_prepare_move(irq, cpu))
50     return -1;
51    
52     - read_msi_msg(irq, &msg);
53     + get_cached_msi_msg(irq, &msg);
54    
55     addr = msg.address_lo;
56     addr &= MSI_ADDR_DEST_ID_MASK;
57     diff --git a/arch/ia64/sn/kernel/msi_sn.c b/arch/ia64/sn/kernel/msi_sn.c
58     index ebfdd6a..0c72dd4 100644
59     --- a/arch/ia64/sn/kernel/msi_sn.c
60     +++ b/arch/ia64/sn/kernel/msi_sn.c
61     @@ -175,7 +175,7 @@ static int sn_set_msi_irq_affinity(unsigned int irq,
62     * Release XIO resources for the old MSI PCI address
63     */
64    
65     - read_msi_msg(irq, &msg);
66     + get_cached_msi_msg(irq, &msg);
67     sn_pdev = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
68     pdev = sn_pdev->pdi_linux_pcidev;
69     provider = SN_PCIDEV_BUSPROVIDER(pdev);
70     diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
71     index 613f691..dbc5106 100644
72     --- a/arch/mips/include/asm/compat.h
73     +++ b/arch/mips/include/asm/compat.h
74     @@ -145,7 +145,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
75     return (u32)(unsigned long)uptr;
76     }
77    
78     -static inline void __user *compat_alloc_user_space(long len)
79     +static inline void __user *arch_compat_alloc_user_space(long len)
80     {
81     struct pt_regs *regs = (struct pt_regs *)
82     ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
83     diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h
84     index 02b77ba..efa0b60 100644
85     --- a/arch/parisc/include/asm/compat.h
86     +++ b/arch/parisc/include/asm/compat.h
87     @@ -147,7 +147,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
88     return (u32)(unsigned long)uptr;
89     }
90    
91     -static __inline__ void __user *compat_alloc_user_space(long len)
92     +static __inline__ void __user *arch_compat_alloc_user_space(long len)
93     {
94     struct pt_regs *regs = &current->thread.regs;
95     return (void __user *)regs->gr[30];
96     diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
97     index 396d21a..a11d4ea 100644
98     --- a/arch/powerpc/include/asm/compat.h
99     +++ b/arch/powerpc/include/asm/compat.h
100     @@ -134,7 +134,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
101     return (u32)(unsigned long)uptr;
102     }
103    
104     -static inline void __user *compat_alloc_user_space(long len)
105     +static inline void __user *arch_compat_alloc_user_space(long len)
106     {
107     struct pt_regs *regs = current->thread.regs;
108     unsigned long usp = regs->gpr[1];
109     diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
110     index 0441bbd..b119497 100644
111     --- a/arch/powerpc/kernel/time.c
112     +++ b/arch/powerpc/kernel/time.c
113     @@ -616,20 +616,11 @@ void timer_interrupt(struct pt_regs * regs)
114     * some CPUs will continuue to take decrementer exceptions */
115     set_dec(DECREMENTER_MAX);
116    
117     -#ifdef CONFIG_PPC32
118     +#if defined(CONFIG_PPC32) && defined(CONFIG_PMAC)
119     if (atomic_read(&ppc_n_lost_interrupts) != 0)
120     do_IRQ(regs);
121     #endif
122    
123     - now = get_tb_or_rtc();
124     - if (now < decrementer->next_tb) {
125     - /* not time for this event yet */
126     - now = decrementer->next_tb - now;
127     - if (now <= DECREMENTER_MAX)
128     - set_dec((int)now);
129     - trace_timer_interrupt_exit(regs);
130     - return;
131     - }
132     old_regs = set_irq_regs(regs);
133     irq_enter();
134    
135     @@ -645,8 +636,16 @@ void timer_interrupt(struct pt_regs * regs)
136     get_lppaca()->int_dword.fields.decr_int = 0;
137     #endif
138    
139     - if (evt->event_handler)
140     - evt->event_handler(evt);
141     + now = get_tb_or_rtc();
142     + if (now >= decrementer->next_tb) {
143     + decrementer->next_tb = ~(u64)0;
144     + if (evt->event_handler)
145     + evt->event_handler(evt);
146     + } else {
147     + now = decrementer->next_tb - now;
148     + if (now <= DECREMENTER_MAX)
149     + set_dec((int)now);
150     + }
151    
152     #ifdef CONFIG_PPC_ISERIES
153     if (firmware_has_feature(FW_FEATURE_ISERIES) && hvlpevent_is_pending())
154     diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
155     index 104f200..a875c2f 100644
156     --- a/arch/s390/include/asm/compat.h
157     +++ b/arch/s390/include/asm/compat.h
158     @@ -181,7 +181,7 @@ static inline int is_compat_task(void)
159    
160     #endif
161    
162     -static inline void __user *compat_alloc_user_space(long len)
163     +static inline void __user *arch_compat_alloc_user_space(long len)
164     {
165     unsigned long stack;
166    
167     diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h
168     index 5016f76..6f57325 100644
169     --- a/arch/sparc/include/asm/compat.h
170     +++ b/arch/sparc/include/asm/compat.h
171     @@ -167,7 +167,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
172     return (u32)(unsigned long)uptr;
173     }
174    
175     -static inline void __user *compat_alloc_user_space(long len)
176     +static inline void __user *arch_compat_alloc_user_space(long len)
177     {
178     struct pt_regs *regs = current_thread_info()->kregs;
179     unsigned long usp = regs->u_regs[UREG_I6];
180     diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
181     index e790bc1..4f5f71e 100644
182     --- a/arch/x86/ia32/ia32entry.S
183     +++ b/arch/x86/ia32/ia32entry.S
184     @@ -50,7 +50,12 @@
185     /*
186     * Reload arg registers from stack in case ptrace changed them.
187     * We don't reload %eax because syscall_trace_enter() returned
188     - * the value it wants us to use in the table lookup.
189     + * the %rax value we should see. Instead, we just truncate that
190     + * value to 32 bits again as we did on entry from user mode.
191     + * If it's a new value set by user_regset during entry tracing,
192     + * this matches the normal truncation of the user-mode value.
193     + * If it's -1 to make us punt the syscall, then (u32)-1 is still
194     + * an appropriately invalid value.
195     */
196     .macro LOAD_ARGS32 offset, _r9=0
197     .if \_r9
198     @@ -60,6 +65,7 @@
199     movl \offset+48(%rsp),%edx
200     movl \offset+56(%rsp),%esi
201     movl \offset+64(%rsp),%edi
202     + movl %eax,%eax /* zero extension */
203     .endm
204    
205     .macro CFI_STARTPROC32 simple
206     @@ -153,7 +159,7 @@ ENTRY(ia32_sysenter_target)
207     testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
208     CFI_REMEMBER_STATE
209     jnz sysenter_tracesys
210     - cmpl $(IA32_NR_syscalls-1),%eax
211     + cmpq $(IA32_NR_syscalls-1),%rax
212     ja ia32_badsys
213     sysenter_do_call:
214     IA32_ARG_FIXUP
215     @@ -195,7 +201,7 @@ sysexit_from_sys_call:
216     movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
217     call audit_syscall_entry
218     movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
219     - cmpl $(IA32_NR_syscalls-1),%eax
220     + cmpq $(IA32_NR_syscalls-1),%rax
221     ja ia32_badsys
222     movl %ebx,%edi /* reload 1st syscall arg */
223     movl RCX-ARGOFFSET(%rsp),%esi /* reload 2nd syscall arg */
224     @@ -248,7 +254,7 @@ sysenter_tracesys:
225     call syscall_trace_enter
226     LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
227     RESTORE_REST
228     - cmpl $(IA32_NR_syscalls-1),%eax
229     + cmpq $(IA32_NR_syscalls-1),%rax
230     ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
231     jmp sysenter_do_call
232     CFI_ENDPROC
233     @@ -314,7 +320,7 @@ ENTRY(ia32_cstar_target)
234     testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
235     CFI_REMEMBER_STATE
236     jnz cstar_tracesys
237     - cmpl $IA32_NR_syscalls-1,%eax
238     + cmpq $IA32_NR_syscalls-1,%rax
239     ja ia32_badsys
240     cstar_do_call:
241     IA32_ARG_FIXUP 1
242     @@ -367,7 +373,7 @@ cstar_tracesys:
243     LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
244     RESTORE_REST
245     xchgl %ebp,%r9d
246     - cmpl $(IA32_NR_syscalls-1),%eax
247     + cmpq $(IA32_NR_syscalls-1),%rax
248     ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
249     jmp cstar_do_call
250     END(ia32_cstar_target)
251     @@ -425,7 +431,7 @@ ENTRY(ia32_syscall)
252     orl $TS_COMPAT,TI_status(%r10)
253     testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
254     jnz ia32_tracesys
255     - cmpl $(IA32_NR_syscalls-1),%eax
256     + cmpq $(IA32_NR_syscalls-1),%rax
257     ja ia32_badsys
258     ia32_do_call:
259     IA32_ARG_FIXUP
260     @@ -444,7 +450,7 @@ ia32_tracesys:
261     call syscall_trace_enter
262     LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
263     RESTORE_REST
264     - cmpl $(IA32_NR_syscalls-1),%eax
265     + cmpq $(IA32_NR_syscalls-1),%rax
266     ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
267     jmp ia32_do_call
268     END(ia32_syscall)
269     diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
270     index 306160e..1d9cd27 100644
271     --- a/arch/x86/include/asm/compat.h
272     +++ b/arch/x86/include/asm/compat.h
273     @@ -205,7 +205,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
274     return (u32)(unsigned long)uptr;
275     }
276    
277     -static inline void __user *compat_alloc_user_space(long len)
278     +static inline void __user *arch_compat_alloc_user_space(long len)
279     {
280     struct pt_regs *regs = task_pt_regs(current);
281     return (void __user *)regs->sp - len;
282     diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
283     index 004e6e2..1d5c08a 100644
284     --- a/arch/x86/include/asm/hpet.h
285     +++ b/arch/x86/include/asm/hpet.h
286     @@ -68,7 +68,6 @@ extern unsigned long force_hpet_address;
287     extern u8 hpet_blockid;
288     extern int hpet_force_user;
289     extern u8 hpet_msi_disable;
290     -extern u8 hpet_readback_cmp;
291     extern int is_hpet_enabled(void);
292     extern int hpet_enable(void);
293     extern void hpet_disable(void);
294     diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
295     index c042729..1ca132f 100644
296     --- a/arch/x86/include/asm/tsc.h
297     +++ b/arch/x86/include/asm/tsc.h
298     @@ -59,5 +59,7 @@ extern void check_tsc_sync_source(int cpu);
299     extern void check_tsc_sync_target(void);
300    
301     extern int notsc_setup(char *);
302     +extern void save_sched_clock_state(void);
303     +extern void restore_sched_clock_state(void);
304    
305     #endif /* _ASM_X86_TSC_H */
306     diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
307     index 2b18af1..f1efeba 100644
308     --- a/arch/x86/kernel/apic/io_apic.c
309     +++ b/arch/x86/kernel/apic/io_apic.c
310     @@ -3399,7 +3399,7 @@ static int set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask)
311    
312     cfg = desc->chip_data;
313    
314     - read_msi_msg_desc(desc, &msg);
315     + get_cached_msi_msg_desc(desc, &msg);
316    
317     msg.data &= ~MSI_DATA_VECTOR_MASK;
318     msg.data |= MSI_DATA_VECTOR(cfg->vector);
319     diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
320     index 0ffe19e..a187365 100644
321     --- a/arch/x86/kernel/cpu/perf_event_p4.c
322     +++ b/arch/x86/kernel/cpu/perf_event_p4.c
323     @@ -457,6 +457,8 @@ static int p4_hw_config(struct perf_event *event)
324     event->hw.config |= event->attr.config &
325     (p4_config_pack_escr(P4_ESCR_MASK_HT) |
326     p4_config_pack_cccr(P4_CCCR_MASK_HT));
327     +
328     + event->hw.config &= ~P4_CCCR_FORCE_OVF;
329     }
330    
331     rc = x86_setup_perfctr(event);
332     diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
333     index e5cc7e8..ebdb85c 100644
334     --- a/arch/x86/kernel/early-quirks.c
335     +++ b/arch/x86/kernel/early-quirks.c
336     @@ -18,7 +18,6 @@
337     #include <asm/apic.h>
338     #include <asm/iommu.h>
339     #include <asm/gart.h>
340     -#include <asm/hpet.h>
341    
342     static void __init fix_hypertransport_config(int num, int slot, int func)
343     {
344     @@ -192,21 +191,6 @@ static void __init ati_bugs_contd(int num, int slot, int func)
345     }
346     #endif
347    
348     -/*
349     - * Force the read back of the CMP register in hpet_next_event()
350     - * to work around the problem that the CMP register write seems to be
351     - * delayed. See hpet_next_event() for details.
352     - *
353     - * We do this on all SMBUS incarnations for now until we have more
354     - * information about the affected chipsets.
355     - */
356     -static void __init ati_hpet_bugs(int num, int slot, int func)
357     -{
358     -#ifdef CONFIG_HPET_TIMER
359     - hpet_readback_cmp = 1;
360     -#endif
361     -}
362     -
363     #define QFLAG_APPLY_ONCE 0x1
364     #define QFLAG_APPLIED 0x2
365     #define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
366     @@ -236,8 +220,6 @@ static struct chipset early_qrk[] __initdata = {
367     PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
368     { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
369     PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
370     - { PCI_VENDOR_ID_ATI, PCI_ANY_ID,
371     - PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_hpet_bugs },
372     {}
373     };
374    
375     diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
376     index ba390d7..7cd1886 100644
377     --- a/arch/x86/kernel/hpet.c
378     +++ b/arch/x86/kernel/hpet.c
379     @@ -36,7 +36,6 @@
380     unsigned long hpet_address;
381     u8 hpet_blockid; /* OS timer block num */
382     u8 hpet_msi_disable;
383     -u8 hpet_readback_cmp;
384    
385     #ifdef CONFIG_PCI_MSI
386     static unsigned long hpet_num_timers;
387     @@ -396,23 +395,27 @@ static int hpet_next_event(unsigned long delta,
388     * at that point and we would wait for the next hpet interrupt
389     * forever. We found out that reading the CMP register back
390     * forces the transfer so we can rely on the comparison with
391     - * the counter register below.
392     + * the counter register below. If the read back from the
393     + * compare register does not match the value we programmed
394     + * then we might have a real hardware problem. We can not do
395     + * much about it here, but at least alert the user/admin with
396     + * a prominent warning.
397     *
398     - * That works fine on those ATI chipsets, but on newer Intel
399     - * chipsets (ICH9...) this triggers due to an erratum: Reading
400     - * the comparator immediately following a write is returning
401     - * the old value.
402     + * An erratum on some chipsets (ICH9,..), results in
403     + * comparator read immediately following a write returning old
404     + * value. Workaround for this is to read this value second
405     + * time, when first read returns old value.
406     *
407     - * We restrict the read back to the affected ATI chipsets (set
408     - * by quirks) and also run it with hpet=verbose for debugging
409     - * purposes.
410     + * In fact the write to the comparator register is delayed up
411     + * to two HPET cycles so the workaround we tried to restrict
412     + * the readback to those known to be borked ATI chipsets
413     + * failed miserably. So we give up on optimizations forever
414     + * and penalize all HPET incarnations unconditionally.
415     */
416     - if (hpet_readback_cmp || hpet_verbose) {
417     - u32 cmp = hpet_readl(HPET_Tn_CMP(timer));
418     -
419     - if (cmp != cnt)
420     + if (unlikely((u32)hpet_readl(HPET_Tn_CMP(timer)) != cnt)) {
421     + if (hpet_readl(HPET_Tn_CMP(timer)) != cnt)
422     printk_once(KERN_WARNING
423     - "hpet: compare register read back failed.\n");
424     + "hpet: compare register read back failed.\n");
425     }
426    
427     return (s32)(hpet_readl(HPET_COUNTER) - cnt) >= 0 ? -ETIME : 0;
428     diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
429     index 9faf91a..4094ae0 100644
430     --- a/arch/x86/kernel/tsc.c
431     +++ b/arch/x86/kernel/tsc.c
432     @@ -626,6 +626,44 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
433     local_irq_restore(flags);
434     }
435    
436     +static unsigned long long cyc2ns_suspend;
437     +
438     +void save_sched_clock_state(void)
439     +{
440     + if (!sched_clock_stable)
441     + return;
442     +
443     + cyc2ns_suspend = sched_clock();
444     +}
445     +
446     +/*
447     + * Even on processors with invariant TSC, TSC gets reset in some the
448     + * ACPI system sleep states. And in some systems BIOS seem to reinit TSC to
449     + * arbitrary value (still sync'd across cpu's) during resume from such sleep
450     + * states. To cope up with this, recompute the cyc2ns_offset for each cpu so
451     + * that sched_clock() continues from the point where it was left off during
452     + * suspend.
453     + */
454     +void restore_sched_clock_state(void)
455     +{
456     + unsigned long long offset;
457     + unsigned long flags;
458     + int cpu;
459     +
460     + if (!sched_clock_stable)
461     + return;
462     +
463     + local_irq_save(flags);
464     +
465     + __get_cpu_var(cyc2ns_offset) = 0;
466     + offset = cyc2ns_suspend - sched_clock();
467     +
468     + for_each_possible_cpu(cpu)
469     + per_cpu(cyc2ns_offset, cpu) = offset;
470     +
471     + local_irq_restore(flags);
472     +}
473     +
474     #ifdef CONFIG_CPU_FREQ
475    
476     /* Frequency scaling support. Adjust the TSC based timer when the cpu frequency
477     diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
478     index f6b48f6..cfe4faa 100644
479     --- a/arch/x86/oprofile/nmi_int.c
480     +++ b/arch/x86/oprofile/nmi_int.c
481     @@ -568,8 +568,13 @@ static int __init init_sysfs(void)
482     int error;
483    
484     error = sysdev_class_register(&oprofile_sysclass);
485     - if (!error)
486     - error = sysdev_register(&device_oprofile);
487     + if (error)
488     + return error;
489     +
490     + error = sysdev_register(&device_oprofile);
491     + if (error)
492     + sysdev_class_unregister(&oprofile_sysclass);
493     +
494     return error;
495     }
496    
497     @@ -580,8 +585,10 @@ static void exit_sysfs(void)
498     }
499    
500     #else
501     -#define init_sysfs() do { } while (0)
502     -#define exit_sysfs() do { } while (0)
503     +
504     +static inline int init_sysfs(void) { return 0; }
505     +static inline void exit_sysfs(void) { }
506     +
507     #endif /* CONFIG_PM */
508    
509     static int __init p4_init(char **cpu_type)
510     @@ -695,6 +702,8 @@ int __init op_nmi_init(struct oprofile_operations *ops)
511     char *cpu_type = NULL;
512     int ret = 0;
513    
514     + using_nmi = 0;
515     +
516     if (!cpu_has_apic)
517     return -ENODEV;
518    
519     @@ -774,7 +783,10 @@ int __init op_nmi_init(struct oprofile_operations *ops)
520    
521     mux_init(ops);
522    
523     - init_sysfs();
524     + ret = init_sysfs();
525     + if (ret)
526     + return ret;
527     +
528     using_nmi = 1;
529     printk(KERN_INFO "oprofile: using NMI interrupt.\n");
530     return 0;
531     diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
532     index 1290ba5..9c57cb1 100644
533     --- a/arch/x86/power/cpu.c
534     +++ b/arch/x86/power/cpu.c
535     @@ -113,6 +113,7 @@ static void __save_processor_state(struct saved_context *ctxt)
536     void save_processor_state(void)
537     {
538     __save_processor_state(&saved_context);
539     + save_sched_clock_state();
540     }
541     #ifdef CONFIG_X86_32
542     EXPORT_SYMBOL(save_processor_state);
543     @@ -229,6 +230,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
544     void restore_processor_state(void)
545     {
546     __restore_processor_state(&saved_context);
547     + restore_sched_clock_state();
548     }
549     #ifdef CONFIG_X86_32
550     EXPORT_SYMBOL(restore_processor_state);
551     diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
552     index 81e772a..98c80e1 100644
553     --- a/drivers/ata/libahci.c
554     +++ b/drivers/ata/libahci.c
555     @@ -1320,7 +1320,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
556     /* issue the first D2H Register FIS */
557     msecs = 0;
558     now = jiffies;
559     - if (time_after(now, deadline))
560     + if (time_after(deadline, now))
561     msecs = jiffies_to_msecs(deadline - now);
562    
563     tf.ctl |= ATA_SRST;
564     diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
565     index ddf8e48..1f24267 100644
566     --- a/drivers/ata/libata-core.c
567     +++ b/drivers/ata/libata-core.c
568     @@ -5434,6 +5434,7 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
569     */
570     int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
571     {
572     + unsigned int ehi_flags = ATA_EHI_QUIET;
573     int rc;
574    
575     /*
576     @@ -5442,7 +5443,18 @@ int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
577     */
578     ata_lpm_enable(host);
579    
580     - rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
581     + /*
582     + * On some hardware, device fails to respond after spun down
583     + * for suspend. As the device won't be used before being
584     + * resumed, we don't need to touch the device. Ask EH to skip
585     + * the usual stuff and proceed directly to suspend.
586     + *
587     + * http://thread.gmane.org/gmane.linux.ide/46764
588     + */
589     + if (mesg.event == PM_EVENT_SUSPEND)
590     + ehi_flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_NO_RECOVERY;
591     +
592     + rc = ata_host_request_pm(host, mesg, 0, ehi_flags, 1);
593     if (rc == 0)
594     host->dev->power.power_state = mesg;
595     return rc;
596     diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
597     index f77a673..da5a55b 100644
598     --- a/drivers/ata/libata-eh.c
599     +++ b/drivers/ata/libata-eh.c
600     @@ -3234,6 +3234,10 @@ static int ata_eh_skip_recovery(struct ata_link *link)
601     if (link->flags & ATA_LFLAG_DISABLED)
602     return 1;
603    
604     + /* skip if explicitly requested */
605     + if (ehc->i.flags & ATA_EHI_NO_RECOVERY)
606     + return 1;
607     +
608     /* thaw frozen port and recover failed devices */
609     if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link))
610     return 0;
611     diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
612     index efa4a18..cde20ff 100644
613     --- a/drivers/ata/libata-sff.c
614     +++ b/drivers/ata/libata-sff.c
615     @@ -418,6 +418,7 @@ void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
616     if (ioaddr->ctl_addr)
617     iowrite8(tf->ctl, ioaddr->ctl_addr);
618     ap->last_ctl = tf->ctl;
619     + ata_wait_idle(ap);
620     }
621    
622     if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
623     @@ -453,6 +454,8 @@ void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
624     iowrite8(tf->device, ioaddr->device_addr);
625     VPRINTK("device 0x%X\n", tf->device);
626     }
627     +
628     + ata_wait_idle(ap);
629     }
630     EXPORT_SYMBOL_GPL(ata_sff_tf_load);
631    
632     @@ -2735,10 +2738,6 @@ unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc)
633     {
634     struct ata_port *ap = qc->ap;
635    
636     - /* see ata_dma_blacklisted() */
637     - BUG_ON((ap->flags & ATA_FLAG_PIO_POLLING) &&
638     - qc->tf.protocol == ATAPI_PROT_DMA);
639     -
640     /* defer PIO handling to sff_qc_issue */
641     if (!ata_is_dma(qc->tf.protocol))
642     return ata_sff_qc_issue(qc);
643     diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
644     index 9f5da1c..905ff76 100644
645     --- a/drivers/ata/pata_cmd64x.c
646     +++ b/drivers/ata/pata_cmd64x.c
647     @@ -121,14 +121,8 @@ static void cmd64x_set_timing(struct ata_port *ap, struct ata_device *adev, u8 m
648    
649     if (pair) {
650     struct ata_timing tp;
651     -
652     ata_timing_compute(pair, pair->pio_mode, &tp, T, 0);
653     ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP);
654     - if (pair->dma_mode) {
655     - ata_timing_compute(pair, pair->dma_mode,
656     - &tp, T, 0);
657     - ata_timing_merge(&tp, &t, &t, ATA_TIMING_SETUP);
658     - }
659     }
660     }
661    
662     diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
663     index 5e65988..ac8d7d9 100644
664     --- a/drivers/ata/pata_via.c
665     +++ b/drivers/ata/pata_via.c
666     @@ -417,6 +417,8 @@ static void via_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
667     tf->lbam,
668     tf->lbah);
669     }
670     +
671     + ata_wait_idle(ap);
672     }
673    
674     static int via_port_start(struct ata_port *ap)
675     diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
676     index a476cd9..d57f6eb 100644
677     --- a/drivers/ata/sata_mv.c
678     +++ b/drivers/ata/sata_mv.c
679     @@ -1898,19 +1898,25 @@ static void mv_bmdma_start(struct ata_queued_cmd *qc)
680     * LOCKING:
681     * Inherited from caller.
682     */
683     -static void mv_bmdma_stop(struct ata_queued_cmd *qc)
684     +static void mv_bmdma_stop_ap(struct ata_port *ap)
685     {
686     - struct ata_port *ap = qc->ap;
687     void __iomem *port_mmio = mv_ap_base(ap);
688     u32 cmd;
689    
690     /* clear start/stop bit */
691     cmd = readl(port_mmio + BMDMA_CMD);
692     - cmd &= ~ATA_DMA_START;
693     - writelfl(cmd, port_mmio + BMDMA_CMD);
694     + if (cmd & ATA_DMA_START) {
695     + cmd &= ~ATA_DMA_START;
696     + writelfl(cmd, port_mmio + BMDMA_CMD);
697     +
698     + /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
699     + ata_sff_dma_pause(ap);
700     + }
701     +}
702    
703     - /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
704     - ata_sff_dma_pause(ap);
705     +static void mv_bmdma_stop(struct ata_queued_cmd *qc)
706     +{
707     + mv_bmdma_stop_ap(qc->ap);
708     }
709    
710     /**
711     @@ -1934,8 +1940,21 @@ static u8 mv_bmdma_status(struct ata_port *ap)
712     reg = readl(port_mmio + BMDMA_STATUS);
713     if (reg & ATA_DMA_ACTIVE)
714     status = ATA_DMA_ACTIVE;
715     - else
716     + else if (reg & ATA_DMA_ERR)
717     status = (reg & ATA_DMA_ERR) | ATA_DMA_INTR;
718     + else {
719     + /*
720     + * Just because DMA_ACTIVE is 0 (DMA completed),
721     + * this does _not_ mean the device is "done".
722     + * So we should not yet be signalling ATA_DMA_INTR
723     + * in some cases. Eg. DSM/TRIM, and perhaps others.
724     + */
725     + mv_bmdma_stop_ap(ap);
726     + if (ioread8(ap->ioaddr.altstatus_addr) & ATA_BUSY)
727     + status = 0;
728     + else
729     + status = ATA_DMA_INTR;
730     + }
731     return status;
732     }
733    
734     @@ -1995,6 +2014,9 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
735    
736     switch (tf->protocol) {
737     case ATA_PROT_DMA:
738     + if (tf->command == ATA_CMD_DSM)
739     + return;
740     + /* fall-thru */
741     case ATA_PROT_NCQ:
742     break; /* continue below */
743     case ATA_PROT_PIO:
744     @@ -2094,6 +2116,8 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
745     if ((tf->protocol != ATA_PROT_DMA) &&
746     (tf->protocol != ATA_PROT_NCQ))
747     return;
748     + if (tf->command == ATA_CMD_DSM)
749     + return; /* use bmdma for this */
750    
751     /* Fill in Gen IIE command request block */
752     if (!(tf->flags & ATA_TFLAG_WRITE))
753     @@ -2289,6 +2313,12 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
754    
755     switch (qc->tf.protocol) {
756     case ATA_PROT_DMA:
757     + if (qc->tf.command == ATA_CMD_DSM) {
758     + if (!ap->ops->bmdma_setup) /* no bmdma on GEN_I */
759     + return AC_ERR_OTHER;
760     + break; /* use bmdma for this */
761     + }
762     + /* fall thru */
763     case ATA_PROT_NCQ:
764     mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
765     pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
766     diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
767     index d84af6c..ea6997e 100644
768     --- a/drivers/char/agp/intel-gtt.c
769     +++ b/drivers/char/agp/intel-gtt.c
770     @@ -1061,11 +1061,11 @@ static void intel_i9xx_setup_flush(void)
771     intel_i915_setup_chipset_flush();
772     }
773    
774     - if (intel_private.ifp_resource.start) {
775     + if (intel_private.ifp_resource.start)
776     intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
777     - if (!intel_private.i9xx_flush_page)
778     - dev_info(&intel_private.pcidev->dev, "can't ioremap flush page - no chipset flushing");
779     - }
780     + if (!intel_private.i9xx_flush_page)
781     + dev_err(&intel_private.pcidev->dev,
782     + "can't ioremap flush page - no chipset flushing\n");
783     }
784    
785     static int intel_i9xx_configure(void)
786     diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
787     index 9b2a541..25d70d6 100644
788     --- a/drivers/gpu/drm/drm_crtc_helper.c
789     +++ b/drivers/gpu/drm/drm_crtc_helper.c
790     @@ -610,13 +610,13 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
791     mode_changed = true;
792    
793     if (mode_changed) {
794     - old_fb = set->crtc->fb;
795     - set->crtc->fb = set->fb;
796     set->crtc->enabled = (set->mode != NULL);
797     if (set->mode != NULL) {
798     DRM_DEBUG_KMS("attempting to set mode from"
799     " userspace\n");
800     drm_mode_debug_printmodeline(set->mode);
801     + old_fb = set->crtc->fb;
802     + set->crtc->fb = set->fb;
803     if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
804     set->x, set->y,
805     old_fb)) {
806     diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
807     index 013a0ae..ce8ff0e 100644
808     --- a/drivers/gpu/drm/i915/i915_dma.c
809     +++ b/drivers/gpu/drm/i915/i915_dma.c
810     @@ -612,8 +612,10 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
811     ret = copy_from_user(cliprects, batch->cliprects,
812     batch->num_cliprects *
813     sizeof(struct drm_clip_rect));
814     - if (ret != 0)
815     + if (ret != 0) {
816     + ret = -EFAULT;
817     goto fail_free;
818     + }
819     }
820    
821     mutex_lock(&dev->struct_mutex);
822     @@ -654,8 +656,10 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
823     return -ENOMEM;
824    
825     ret = copy_from_user(batch_data, cmdbuf->buf, cmdbuf->sz);
826     - if (ret != 0)
827     + if (ret != 0) {
828     + ret = -EFAULT;
829     goto fail_batch_free;
830     + }
831    
832     if (cmdbuf->num_cliprects) {
833     cliprects = kcalloc(cmdbuf->num_cliprects,
834     @@ -668,8 +672,10 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
835     ret = copy_from_user(cliprects, cmdbuf->cliprects,
836     cmdbuf->num_cliprects *
837     sizeof(struct drm_clip_rect));
838     - if (ret != 0)
839     + if (ret != 0) {
840     + ret = -EFAULT;
841     goto fail_clip_free;
842     + }
843     }
844    
845     mutex_lock(&dev->struct_mutex);
846     @@ -877,7 +883,7 @@ intel_alloc_mchbar_resource(struct drm_device *dev)
847     int reg = IS_I965G(dev) ? MCHBAR_I965 : MCHBAR_I915;
848     u32 temp_lo, temp_hi = 0;
849     u64 mchbar_addr;
850     - int ret = 0;
851     + int ret;
852    
853     if (IS_I965G(dev))
854     pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi);
855     @@ -887,22 +893,23 @@ intel_alloc_mchbar_resource(struct drm_device *dev)
856     /* If ACPI doesn't have it, assume we need to allocate it ourselves */
857     #ifdef CONFIG_PNP
858     if (mchbar_addr &&
859     - pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE)) {
860     - ret = 0;
861     - goto out;
862     - }
863     + pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE))
864     + return 0;
865     #endif
866    
867     /* Get some space for it */
868     - ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus, &dev_priv->mch_res,
869     + dev_priv->mch_res.name = "i915 MCHBAR";
870     + dev_priv->mch_res.flags = IORESOURCE_MEM;
871     + ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus,
872     + &dev_priv->mch_res,
873     MCHBAR_SIZE, MCHBAR_SIZE,
874     PCIBIOS_MIN_MEM,
875     - 0, pcibios_align_resource,
876     + 0, pcibios_align_resource,
877     dev_priv->bridge_dev);
878     if (ret) {
879     DRM_DEBUG_DRIVER("failed bus alloc: %d\n", ret);
880     dev_priv->mch_res.start = 0;
881     - goto out;
882     + return ret;
883     }
884    
885     if (IS_I965G(dev))
886     @@ -911,8 +918,7 @@ intel_alloc_mchbar_resource(struct drm_device *dev)
887    
888     pci_write_config_dword(dev_priv->bridge_dev, reg,
889     lower_32_bits(dev_priv->mch_res.start));
890     -out:
891     - return ret;
892     + return 0;
893     }
894    
895     /* Setup MCHBAR if possible, return true if we should disable it again */
896     @@ -2073,6 +2079,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
897     goto free_priv;
898     }
899    
900     + /* overlay on gen2 is broken and can't address above 1G */
901     + if (IS_GEN2(dev))
902     + dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(30));
903     +
904     dev_priv->regs = ioremap(base, size);
905     if (!dev_priv->regs) {
906     DRM_ERROR("failed to map registers\n");
907     diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
908     index 5aa747f..06f8238 100644
909     --- a/drivers/gpu/drm/i915/i915_gem.c
910     +++ b/drivers/gpu/drm/i915/i915_gem.c
911     @@ -3709,6 +3709,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
912     if (ret != 0) {
913     DRM_ERROR("copy %d cliprects failed: %d\n",
914     args->num_cliprects, ret);
915     + ret = -EFAULT;
916     goto pre_mutex_err;
917     }
918     }
919     diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
920     index cf41c67..bed6a5e 100644
921     --- a/drivers/gpu/drm/i915/i915_reg.h
922     +++ b/drivers/gpu/drm/i915/i915_reg.h
923     @@ -312,6 +312,7 @@
924    
925     #define MI_MODE 0x0209c
926     # define VS_TIMER_DISPATCH (1 << 6)
927     +# define MI_FLUSH_ENABLE (1 << 11)
928    
929     #define SCPD0 0x0209c /* 915+ only */
930     #define IER 0x020a0
931     @@ -2199,9 +2200,17 @@
932     #define WM1_LP_SR_EN (1<<31)
933     #define WM1_LP_LATENCY_SHIFT 24
934     #define WM1_LP_LATENCY_MASK (0x7f<<24)
935     +#define WM1_LP_FBC_LP1_MASK (0xf<<20)
936     +#define WM1_LP_FBC_LP1_SHIFT 20
937     #define WM1_LP_SR_MASK (0x1ff<<8)
938     #define WM1_LP_SR_SHIFT 8
939     #define WM1_LP_CURSOR_MASK (0x3f)
940     +#define WM2_LP_ILK 0x4510c
941     +#define WM2_LP_EN (1<<31)
942     +#define WM3_LP_ILK 0x45110
943     +#define WM3_LP_EN (1<<31)
944     +#define WM1S_LP_ILK 0x45120
945     +#define WM1S_LP_EN (1<<31)
946    
947     /* Memory latency timer register */
948     #define MLTR_ILK 0x11222
949     diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
950     index e9a4b12..ac38e46 100644
951     --- a/drivers/gpu/drm/i915/intel_display.c
952     +++ b/drivers/gpu/drm/i915/intel_display.c
953     @@ -2314,6 +2314,9 @@ static void intel_crtc_dpms(struct drm_crtc *crtc, int mode)
954     int pipe = intel_crtc->pipe;
955     bool enabled;
956    
957     + if (intel_crtc->dpms_mode == mode)
958     + return;
959     +
960     dev_priv->display.dpms(crtc, mode);
961    
962     intel_crtc->dpms_mode = mode;
963     @@ -3203,8 +3206,7 @@ static void ironlake_update_wm(struct drm_device *dev, int planea_clock,
964     reg_value = I915_READ(WM1_LP_ILK);
965     reg_value &= ~(WM1_LP_LATENCY_MASK | WM1_LP_SR_MASK |
966     WM1_LP_CURSOR_MASK);
967     - reg_value |= WM1_LP_SR_EN |
968     - (ilk_sr_latency << WM1_LP_LATENCY_SHIFT) |
969     + reg_value |= (ilk_sr_latency << WM1_LP_LATENCY_SHIFT) |
970     (sr_wm << WM1_LP_SR_SHIFT) | cursor_wm;
971    
972     I915_WRITE(WM1_LP_ILK, reg_value);
973     @@ -4915,7 +4917,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
974     dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
975    
976     intel_crtc->cursor_addr = 0;
977     - intel_crtc->dpms_mode = DRM_MODE_DPMS_OFF;
978     + intel_crtc->dpms_mode = -1;
979     drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
980    
981     intel_crtc->busy = false;
982     @@ -5422,6 +5424,9 @@ void intel_init_clock_gating(struct drm_device *dev)
983     I915_WRITE(DISP_ARB_CTL,
984     (I915_READ(DISP_ARB_CTL) |
985     DISP_FBC_WM_DIS));
986     + I915_WRITE(WM3_LP_ILK, 0);
987     + I915_WRITE(WM2_LP_ILK, 0);
988     + I915_WRITE(WM1_LP_ILK, 0);
989     }
990     return;
991     } else if (IS_G4X(dev)) {
992     diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
993     index 5dde80f..d9de8f1 100644
994     --- a/drivers/gpu/drm/i915/intel_dp.c
995     +++ b/drivers/gpu/drm/i915/intel_dp.c
996     @@ -229,7 +229,6 @@ intel_dp_aux_ch(struct intel_encoder *intel_encoder,
997     uint32_t ch_data = ch_ctl + 4;
998     int i;
999     int recv_bytes;
1000     - uint32_t ctl;
1001     uint32_t status;
1002     uint32_t aux_clock_divider;
1003     int try, precharge;
1004     @@ -253,41 +252,43 @@ intel_dp_aux_ch(struct intel_encoder *intel_encoder,
1005     else
1006     precharge = 5;
1007    
1008     + if (I915_READ(ch_ctl) & DP_AUX_CH_CTL_SEND_BUSY) {
1009     + DRM_ERROR("dp_aux_ch not started status 0x%08x\n",
1010     + I915_READ(ch_ctl));
1011     + return -EBUSY;
1012     + }
1013     +
1014     /* Must try at least 3 times according to DP spec */
1015     for (try = 0; try < 5; try++) {
1016     /* Load the send data into the aux channel data registers */
1017     - for (i = 0; i < send_bytes; i += 4) {
1018     - uint32_t d = pack_aux(send + i, send_bytes - i);
1019     -
1020     - I915_WRITE(ch_data + i, d);
1021     - }
1022     -
1023     - ctl = (DP_AUX_CH_CTL_SEND_BUSY |
1024     - DP_AUX_CH_CTL_TIME_OUT_400us |
1025     - (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
1026     - (precharge << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) |
1027     - (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT) |
1028     - DP_AUX_CH_CTL_DONE |
1029     - DP_AUX_CH_CTL_TIME_OUT_ERROR |
1030     - DP_AUX_CH_CTL_RECEIVE_ERROR);
1031     + for (i = 0; i < send_bytes; i += 4)
1032     + I915_WRITE(ch_data + i,
1033     + pack_aux(send + i, send_bytes - i));
1034    
1035     /* Send the command and wait for it to complete */
1036     - I915_WRITE(ch_ctl, ctl);
1037     - (void) I915_READ(ch_ctl);
1038     + I915_WRITE(ch_ctl,
1039     + DP_AUX_CH_CTL_SEND_BUSY |
1040     + DP_AUX_CH_CTL_TIME_OUT_400us |
1041     + (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
1042     + (precharge << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) |
1043     + (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT) |
1044     + DP_AUX_CH_CTL_DONE |
1045     + DP_AUX_CH_CTL_TIME_OUT_ERROR |
1046     + DP_AUX_CH_CTL_RECEIVE_ERROR);
1047     for (;;) {
1048     - udelay(100);
1049     status = I915_READ(ch_ctl);
1050     if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0)
1051     break;
1052     + udelay(100);
1053     }
1054    
1055     /* Clear done status and any errors */
1056     - I915_WRITE(ch_ctl, (status |
1057     - DP_AUX_CH_CTL_DONE |
1058     - DP_AUX_CH_CTL_TIME_OUT_ERROR |
1059     - DP_AUX_CH_CTL_RECEIVE_ERROR));
1060     - (void) I915_READ(ch_ctl);
1061     - if ((status & DP_AUX_CH_CTL_TIME_OUT_ERROR) == 0)
1062     + I915_WRITE(ch_ctl,
1063     + status |
1064     + DP_AUX_CH_CTL_DONE |
1065     + DP_AUX_CH_CTL_TIME_OUT_ERROR |
1066     + DP_AUX_CH_CTL_RECEIVE_ERROR);
1067     + if (status & DP_AUX_CH_CTL_DONE)
1068     break;
1069     }
1070    
1071     @@ -314,15 +315,12 @@ intel_dp_aux_ch(struct intel_encoder *intel_encoder,
1072     /* Unload any bytes sent back from the other side */
1073     recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >>
1074     DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT);
1075     -
1076     if (recv_bytes > recv_size)
1077     recv_bytes = recv_size;
1078    
1079     - for (i = 0; i < recv_bytes; i += 4) {
1080     - uint32_t d = I915_READ(ch_data + i);
1081     -
1082     - unpack_aux(d, recv + i, recv_bytes - i);
1083     - }
1084     + for (i = 0; i < recv_bytes; i += 4)
1085     + unpack_aux(I915_READ(ch_data + i),
1086     + recv + i, recv_bytes - i);
1087    
1088     return recv_bytes;
1089     }
1090     diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
1091     index 0eab8df..7d42ff1 100644
1092     --- a/drivers/gpu/drm/i915/intel_lvds.c
1093     +++ b/drivers/gpu/drm/i915/intel_lvds.c
1094     @@ -988,8 +988,6 @@ void intel_lvds_init(struct drm_device *dev)
1095    
1096     intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
1097     intel_encoder->crtc_mask = (1 << 1);
1098     - if (IS_I965G(dev))
1099     - intel_encoder->crtc_mask |= (1 << 0);
1100     drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs);
1101     drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
1102     connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1103     diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
1104     index 26362f8..4d9c5ce 100644
1105     --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
1106     +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
1107     @@ -203,9 +203,13 @@ static int init_render_ring(struct drm_device *dev,
1108     {
1109     drm_i915_private_t *dev_priv = dev->dev_private;
1110     int ret = init_ring_common(dev, ring);
1111     + int mode;
1112     +
1113     if (IS_I9XX(dev) && !IS_GEN3(dev)) {
1114     - I915_WRITE(MI_MODE,
1115     - (VS_TIMER_DISPATCH) << 16 | VS_TIMER_DISPATCH);
1116     + mode = VS_TIMER_DISPATCH << 16 | VS_TIMER_DISPATCH;
1117     + if (IS_GEN6(dev))
1118     + mode |= MI_FLUSH_ENABLE << 16 | MI_FLUSH_ENABLE;
1119     + I915_WRITE(MI_MODE, mode);
1120     }
1121     return ret;
1122     }
1123     diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
1124     index 8c2d647..1d67f4d 100644
1125     --- a/drivers/gpu/drm/radeon/atombios_crtc.c
1126     +++ b/drivers/gpu/drm/radeon/atombios_crtc.c
1127     @@ -527,6 +527,21 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
1128     pll->algo = PLL_ALGO_LEGACY;
1129     pll->flags |= RADEON_PLL_PREFER_CLOSEST_LOWER;
1130     }
1131     + /* There is some evidence (often anecdotal) that RV515/RV620 LVDS
1132     + * (on some boards at least) prefers the legacy algo. I'm not
1133     + * sure whether this should handled generically or on a
1134     + * case-by-case quirk basis. Both algos should work fine in the
1135     + * majority of cases.
1136     + */
1137     + if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) &&
1138     + ((rdev->family == CHIP_RV515) ||
1139     + (rdev->family == CHIP_RV620))) {
1140     + /* allow the user to overrride just in case */
1141     + if (radeon_new_pll == 1)
1142     + pll->algo = PLL_ALGO_NEW;
1143     + else
1144     + pll->algo = PLL_ALGO_LEGACY;
1145     + }
1146     } else {
1147     if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
1148     pll->flags |= RADEON_PLL_NO_ODD_POST_DIV;
1149     @@ -992,11 +1007,11 @@ static int avivo_crtc_set_base(struct drm_crtc *crtc, int x, int y,
1150    
1151     if (rdev->family >= CHIP_RV770) {
1152     if (radeon_crtc->crtc_id) {
1153     - WREG32(R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0);
1154     - WREG32(R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0);
1155     + WREG32(R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location));
1156     + WREG32(R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location));
1157     } else {
1158     - WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0);
1159     - WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0);
1160     + WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location));
1161     + WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location));
1162     }
1163     }
1164     WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset,
1165     diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
1166     index 1caf625..d448c25 100644
1167     --- a/drivers/gpu/drm/radeon/evergreen.c
1168     +++ b/drivers/gpu/drm/radeon/evergreen.c
1169     @@ -658,6 +658,43 @@ static int evergreen_cp_load_microcode(struct radeon_device *rdev)
1170     return 0;
1171     }
1172    
1173     +static int evergreen_cp_start(struct radeon_device *rdev)
1174     +{
1175     + int r;
1176     + uint32_t cp_me;
1177     +
1178     + r = radeon_ring_lock(rdev, 7);
1179     + if (r) {
1180     + DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r);
1181     + return r;
1182     + }
1183     + radeon_ring_write(rdev, PACKET3(PACKET3_ME_INITIALIZE, 5));
1184     + radeon_ring_write(rdev, 0x1);
1185     + radeon_ring_write(rdev, 0x0);
1186     + radeon_ring_write(rdev, rdev->config.evergreen.max_hw_contexts - 1);
1187     + radeon_ring_write(rdev, PACKET3_ME_INITIALIZE_DEVICE_ID(1));
1188     + radeon_ring_write(rdev, 0);
1189     + radeon_ring_write(rdev, 0);
1190     + radeon_ring_unlock_commit(rdev);
1191     +
1192     + cp_me = 0xff;
1193     + WREG32(CP_ME_CNTL, cp_me);
1194     +
1195     + r = radeon_ring_lock(rdev, 4);
1196     + if (r) {
1197     + DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r);
1198     + return r;
1199     + }
1200     + /* init some VGT regs */
1201     + radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONTEXT_REG, 2));
1202     + radeon_ring_write(rdev, (VGT_VERTEX_REUSE_BLOCK_CNTL - PACKET3_SET_CONTEXT_REG_START) >> 2);
1203     + radeon_ring_write(rdev, 0xe);
1204     + radeon_ring_write(rdev, 0x10);
1205     + radeon_ring_unlock_commit(rdev);
1206     +
1207     + return 0;
1208     +}
1209     +
1210     int evergreen_cp_resume(struct radeon_device *rdev)
1211     {
1212     u32 tmp;
1213     @@ -702,7 +739,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)
1214     rdev->cp.rptr = RREG32(CP_RB_RPTR);
1215     rdev->cp.wptr = RREG32(CP_RB_WPTR);
1216    
1217     - r600_cp_start(rdev);
1218     + evergreen_cp_start(rdev);
1219     rdev->cp.ready = true;
1220     r = radeon_ring_test(rdev);
1221     if (r) {
1222     @@ -1106,14 +1143,25 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1223     EVERGREEN_MAX_BACKENDS_MASK));
1224     break;
1225     }
1226     - } else
1227     - gb_backend_map =
1228     - evergreen_get_tile_pipe_to_backend_map(rdev,
1229     - rdev->config.evergreen.max_tile_pipes,
1230     - rdev->config.evergreen.max_backends,
1231     - ((EVERGREEN_MAX_BACKENDS_MASK <<
1232     - rdev->config.evergreen.max_backends) &
1233     - EVERGREEN_MAX_BACKENDS_MASK));
1234     + } else {
1235     + switch (rdev->family) {
1236     + case CHIP_CYPRESS:
1237     + case CHIP_HEMLOCK:
1238     + gb_backend_map = 0x66442200;
1239     + break;
1240     + case CHIP_JUNIPER:
1241     + gb_backend_map = 0x00006420;
1242     + break;
1243     + default:
1244     + gb_backend_map =
1245     + evergreen_get_tile_pipe_to_backend_map(rdev,
1246     + rdev->config.evergreen.max_tile_pipes,
1247     + rdev->config.evergreen.max_backends,
1248     + ((EVERGREEN_MAX_BACKENDS_MASK <<
1249     + rdev->config.evergreen.max_backends) &
1250     + EVERGREEN_MAX_BACKENDS_MASK));
1251     + }
1252     + }
1253    
1254     WREG32(GB_BACKEND_MAP, gb_backend_map);
1255     WREG32(GB_ADDR_CONFIG, gb_addr_config);
1256     diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1257     index bb3de01..952cc78 100644
1258     --- a/drivers/gpu/drm/radeon/r600.c
1259     +++ b/drivers/gpu/drm/radeon/r600.c
1260     @@ -2104,10 +2104,7 @@ int r600_cp_start(struct radeon_device *rdev)
1261     }
1262     radeon_ring_write(rdev, PACKET3(PACKET3_ME_INITIALIZE, 5));
1263     radeon_ring_write(rdev, 0x1);
1264     - if (rdev->family >= CHIP_CEDAR) {
1265     - radeon_ring_write(rdev, 0x0);
1266     - radeon_ring_write(rdev, rdev->config.evergreen.max_hw_contexts - 1);
1267     - } else if (rdev->family >= CHIP_RV770) {
1268     + if (rdev->family >= CHIP_RV770) {
1269     radeon_ring_write(rdev, 0x0);
1270     radeon_ring_write(rdev, rdev->config.rv770.max_hw_contexts - 1);
1271     } else {
1272     @@ -3526,7 +3523,7 @@ void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo)
1273     * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL
1274     */
1275     if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740)) {
1276     - void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
1277     + void __iomem *ptr = (void *)rdev->vram_scratch.ptr;
1278     u32 tmp;
1279    
1280     WREG32(HDP_DEBUG1, 0);
1281     diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
1282     index 2f94dc6..e0865c7 100644
1283     --- a/drivers/gpu/drm/radeon/radeon.h
1284     +++ b/drivers/gpu/drm/radeon/radeon.h
1285     @@ -997,6 +997,11 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
1286     int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
1287     struct drm_file *filp);
1288    
1289     +/* VRAM scratch page for HDP bug */
1290     +struct r700_vram_scratch {
1291     + struct radeon_bo *robj;
1292     + volatile uint32_t *ptr;
1293     +};
1294    
1295     /*
1296     * Core structure, functions and helpers.
1297     @@ -1060,6 +1065,7 @@ struct radeon_device {
1298     const struct firmware *pfp_fw; /* r6/700 PFP firmware */
1299     const struct firmware *rlc_fw; /* r6/700 RLC firmware */
1300     struct r600_blit r600_blit;
1301     + struct r700_vram_scratch vram_scratch;
1302     int msi_enabled; /* msi enabled */
1303     struct r600_ih ih; /* r6/700 interrupt ring */
1304     struct workqueue_struct *wq;
1305     diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
1306     index 1d6fb79..67e8073 100644
1307     --- a/drivers/gpu/drm/radeon/rv770.c
1308     +++ b/drivers/gpu/drm/radeon/rv770.c
1309     @@ -889,6 +889,54 @@ static void rv770_gpu_init(struct radeon_device *rdev)
1310    
1311     }
1312    
1313     +static int rv770_vram_scratch_init(struct radeon_device *rdev)
1314     +{
1315     + int r;
1316     + u64 gpu_addr;
1317     +
1318     + if (rdev->vram_scratch.robj == NULL) {
1319     + r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE,
1320     + true, RADEON_GEM_DOMAIN_VRAM,
1321     + &rdev->vram_scratch.robj);
1322     + if (r) {
1323     + return r;
1324     + }
1325     + }
1326     +
1327     + r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
1328     + if (unlikely(r != 0))
1329     + return r;
1330     + r = radeon_bo_pin(rdev->vram_scratch.robj,
1331     + RADEON_GEM_DOMAIN_VRAM, &gpu_addr);
1332     + if (r) {
1333     + radeon_bo_unreserve(rdev->vram_scratch.robj);
1334     + return r;
1335     + }
1336     + r = radeon_bo_kmap(rdev->vram_scratch.robj,
1337     + (void **)&rdev->vram_scratch.ptr);
1338     + if (r)
1339     + radeon_bo_unpin(rdev->vram_scratch.robj);
1340     + radeon_bo_unreserve(rdev->vram_scratch.robj);
1341     +
1342     + return r;
1343     +}
1344     +
1345     +static void rv770_vram_scratch_fini(struct radeon_device *rdev)
1346     +{
1347     + int r;
1348     +
1349     + if (rdev->vram_scratch.robj == NULL) {
1350     + return;
1351     + }
1352     + r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
1353     + if (likely(r == 0)) {
1354     + radeon_bo_kunmap(rdev->vram_scratch.robj);
1355     + radeon_bo_unpin(rdev->vram_scratch.robj);
1356     + radeon_bo_unreserve(rdev->vram_scratch.robj);
1357     + }
1358     + radeon_bo_unref(&rdev->vram_scratch.robj);
1359     +}
1360     +
1361     int rv770_mc_init(struct radeon_device *rdev)
1362     {
1363     u32 tmp;
1364     @@ -954,6 +1002,9 @@ static int rv770_startup(struct radeon_device *rdev)
1365     if (r)
1366     return r;
1367     }
1368     + r = rv770_vram_scratch_init(rdev);
1369     + if (r)
1370     + return r;
1371     rv770_gpu_init(rdev);
1372     r = r600_blit_init(rdev);
1373     if (r) {
1374     @@ -1179,6 +1230,7 @@ void rv770_fini(struct radeon_device *rdev)
1375     r600_irq_fini(rdev);
1376     radeon_irq_kms_fini(rdev);
1377     rv770_pcie_gart_fini(rdev);
1378     + rv770_vram_scratch_fini(rdev);
1379     radeon_gem_fini(rdev);
1380     radeon_fence_driver_fini(rdev);
1381     radeon_clocks_fini(rdev);
1382     diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
1383     index b729c02..ffd6899 100644
1384     --- a/drivers/hid/usbhid/hid-core.c
1385     +++ b/drivers/hid/usbhid/hid-core.c
1386     @@ -828,6 +828,7 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
1387     }
1388     } else {
1389     int skipped_report_id = 0;
1390     + int report_id = buf[0];
1391     if (buf[0] == 0x0) {
1392     /* Don't send the Report ID */
1393     buf++;
1394     @@ -837,7 +838,7 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
1395     ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1396     HID_REQ_SET_REPORT,
1397     USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1398     - ((report_type + 1) << 8) | *buf,
1399     + ((report_type + 1) << 8) | report_id,
1400     interface->desc.bInterfaceNumber, buf, count,
1401     USB_CTRL_SET_TIMEOUT);
1402     /* count also the report id, if this was a numbered report. */
1403     diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
1404     index b300a20..5231934 100644
1405     --- a/drivers/hwmon/ads7871.c
1406     +++ b/drivers/hwmon/ads7871.c
1407     @@ -160,30 +160,12 @@ static const struct attribute_group ads7871_group = {
1408    
1409     static int __devinit ads7871_probe(struct spi_device *spi)
1410     {
1411     - int status, ret, err = 0;
1412     + int ret, err;
1413     uint8_t val;
1414     struct ads7871_data *pdata;
1415    
1416     dev_dbg(&spi->dev, "probe\n");
1417    
1418     - pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
1419     - if (!pdata) {
1420     - err = -ENOMEM;
1421     - goto exit;
1422     - }
1423     -
1424     - status = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
1425     - if (status < 0)
1426     - goto error_free;
1427     -
1428     - pdata->hwmon_dev = hwmon_device_register(&spi->dev);
1429     - if (IS_ERR(pdata->hwmon_dev)) {
1430     - err = PTR_ERR(pdata->hwmon_dev);
1431     - goto error_remove;
1432     - }
1433     -
1434     - spi_set_drvdata(spi, pdata);
1435     -
1436     /* Configure the SPI bus */
1437     spi->mode = (SPI_MODE_0);
1438     spi->bits_per_word = 8;
1439     @@ -201,6 +183,24 @@ static int __devinit ads7871_probe(struct spi_device *spi)
1440     we need to make sure we really have a chip*/
1441     if (val != ret) {
1442     err = -ENODEV;
1443     + goto exit;
1444     + }
1445     +
1446     + pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
1447     + if (!pdata) {
1448     + err = -ENOMEM;
1449     + goto exit;
1450     + }
1451     +
1452     + err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
1453     + if (err < 0)
1454     + goto error_free;
1455     +
1456     + spi_set_drvdata(spi, pdata);
1457     +
1458     + pdata->hwmon_dev = hwmon_device_register(&spi->dev);
1459     + if (IS_ERR(pdata->hwmon_dev)) {
1460     + err = PTR_ERR(pdata->hwmon_dev);
1461     goto error_remove;
1462     }
1463    
1464     diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
1465     index 0e4b564..3f5a00e 100644
1466     --- a/drivers/hwmon/emc1403.c
1467     +++ b/drivers/hwmon/emc1403.c
1468     @@ -275,7 +275,6 @@ static int emc1403_probe(struct i2c_client *client,
1469     res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr);
1470     if (res) {
1471     dev_warn(&client->dev, "create group failed\n");
1472     - hwmon_device_unregister(data->hwmon_dev);
1473     goto thermal_error1;
1474     }
1475     data->hwmon_dev = hwmon_device_register(&client->dev);
1476     diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
1477     index 0f58ecc..9638d58 100644
1478     --- a/drivers/hwmon/f75375s.c
1479     +++ b/drivers/hwmon/f75375s.c
1480     @@ -79,7 +79,7 @@ enum chips { f75373, f75375 };
1481     #define F75375_REG_PWM2_DROP_DUTY 0x6C
1482    
1483     #define FAN_CTRL_LINEAR(nr) (4 + nr)
1484     -#define FAN_CTRL_MODE(nr) (5 + ((nr) * 2))
1485     +#define FAN_CTRL_MODE(nr) (4 + ((nr) * 2))
1486    
1487     /*
1488     * Data structures and manipulation thereof
1489     @@ -298,7 +298,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
1490     return -EINVAL;
1491    
1492     fanmode = f75375_read8(client, F75375_REG_FAN_TIMER);
1493     - fanmode = ~(3 << FAN_CTRL_MODE(nr));
1494     + fanmode &= ~(3 << FAN_CTRL_MODE(nr));
1495    
1496     switch (val) {
1497     case 0: /* Full speed */
1498     @@ -350,7 +350,7 @@ static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr,
1499    
1500     mutex_lock(&data->update_lock);
1501     conf = f75375_read8(client, F75375_REG_CONFIG1);
1502     - conf = ~(1 << FAN_CTRL_LINEAR(nr));
1503     + conf &= ~(1 << FAN_CTRL_LINEAR(nr));
1504    
1505     if (val == 0)
1506     conf |= (1 << FAN_CTRL_LINEAR(nr)) ;
1507     diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
1508     index 7580f55..36e9575 100644
1509     --- a/drivers/hwmon/hp_accel.c
1510     +++ b/drivers/hwmon/hp_accel.c
1511     @@ -221,6 +221,8 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
1512     AXIS_DMI_MATCH("HPB442x", "HP ProBook 442", xy_rotated_left),
1513     AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted),
1514     AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap),
1515     + AXIS_DMI_MATCH("HPB532x", "HP ProBook 532", y_inverted),
1516     + AXIS_DMI_MATCH("Mini5102", "HP Mini 5102", xy_rotated_left_usd),
1517     { NULL, }
1518     /* Laptop models without axis info (yet):
1519     * "NC6910" "HP Compaq 6910"
1520     diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
1521     index 8bdf80d..8364932 100644
1522     --- a/drivers/hwmon/k8temp.c
1523     +++ b/drivers/hwmon/k8temp.c
1524     @@ -143,6 +143,37 @@ static const struct pci_device_id k8temp_ids[] = {
1525    
1526     MODULE_DEVICE_TABLE(pci, k8temp_ids);
1527    
1528     +static int __devinit is_rev_g_desktop(u8 model)
1529     +{
1530     + u32 brandidx;
1531     +
1532     + if (model < 0x69)
1533     + return 0;
1534     +
1535     + if (model == 0xc1 || model == 0x6c || model == 0x7c)
1536     + return 0;
1537     +
1538     + /*
1539     + * Differentiate between AM2 and ASB1.
1540     + * See "Constructing the processor Name String" in "Revision
1541     + * Guide for AMD NPT Family 0Fh Processors" (33610).
1542     + */
1543     + brandidx = cpuid_ebx(0x80000001);
1544     + brandidx = (brandidx >> 9) & 0x1f;
1545     +
1546     + /* Single core */
1547     + if ((model == 0x6f || model == 0x7f) &&
1548     + (brandidx == 0x7 || brandidx == 0x9 || brandidx == 0xc))
1549     + return 0;
1550     +
1551     + /* Dual core */
1552     + if (model == 0x6b &&
1553     + (brandidx == 0xb || brandidx == 0xc))
1554     + return 0;
1555     +
1556     + return 1;
1557     +}
1558     +
1559     static int __devinit k8temp_probe(struct pci_dev *pdev,
1560     const struct pci_device_id *id)
1561     {
1562     @@ -179,9 +210,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
1563     "wrong - check erratum #141\n");
1564     }
1565    
1566     - if ((model >= 0x69) &&
1567     - !(model == 0xc1 || model == 0x6c || model == 0x7c ||
1568     - model == 0x6b || model == 0x6f || model == 0x7f)) {
1569     + if (is_rev_g_desktop(model)) {
1570     /*
1571     * RevG desktop CPUs (i.e. no socket S1G1 or
1572     * ASB1 parts) need additional offset,
1573     diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h
1574     index 8f0caf7..78fbe9f 100644
1575     --- a/drivers/infiniband/hw/cxgb3/cxio_hal.h
1576     +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h
1577     @@ -53,7 +53,7 @@
1578     #define T3_MAX_PBL_SIZE 256
1579     #define T3_MAX_RQ_SIZE 1024
1580     #define T3_MAX_QP_DEPTH (T3_MAX_RQ_SIZE-1)
1581     -#define T3_MAX_CQ_DEPTH 262144
1582     +#define T3_MAX_CQ_DEPTH 65536
1583     #define T3_MAX_NUM_STAG (1<<15)
1584     #define T3_MAX_MR_SIZE 0x100000000ULL
1585     #define T3_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */
1586     diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
1587     index 05edd75..a9cf768 100644
1588     --- a/drivers/input/mouse/appletouch.c
1589     +++ b/drivers/input/mouse/appletouch.c
1590     @@ -205,8 +205,8 @@ struct atp {
1591     bool overflow_warned;
1592     int x_old; /* last reported x/y, */
1593     int y_old; /* used for smoothing */
1594     - u8 xy_cur[ATP_XSENSORS + ATP_YSENSORS];
1595     - u8 xy_old[ATP_XSENSORS + ATP_YSENSORS];
1596     + signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS];
1597     + signed char xy_old[ATP_XSENSORS + ATP_YSENSORS];
1598     int xy_acc[ATP_XSENSORS + ATP_YSENSORS];
1599     int idlecount; /* number of empty packets */
1600     struct work_struct work;
1601     @@ -531,7 +531,7 @@ static void atp_complete_geyser_1_2(struct urb *urb)
1602    
1603     for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
1604     /* accumulate the change */
1605     - int change = dev->xy_old[i] - dev->xy_cur[i];
1606     + signed char change = dev->xy_old[i] - dev->xy_cur[i];
1607     dev->xy_acc[i] -= change;
1608    
1609     /* prevent down drifting */
1610     diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
1611     index 6440a8f..5d42358 100644
1612     --- a/drivers/input/serio/i8042.c
1613     +++ b/drivers/input/serio/i8042.c
1614     @@ -861,9 +861,6 @@ static int i8042_controller_selftest(void)
1615     unsigned char param;
1616     int i = 0;
1617    
1618     - if (!i8042_reset)
1619     - return 0;
1620     -
1621     /*
1622     * We try this 5 times; on some really fragile systems this does not
1623     * take the first time...
1624     @@ -1020,7 +1017,8 @@ static void i8042_controller_reset(void)
1625     * Reset the controller if requested.
1626     */
1627    
1628     - i8042_controller_selftest();
1629     + if (i8042_reset)
1630     + i8042_controller_selftest();
1631    
1632     /*
1633     * Restore the original control register setting.
1634     @@ -1094,23 +1092,11 @@ static void i8042_dritek_enable(void)
1635     #ifdef CONFIG_PM
1636    
1637     /*
1638     - * Here we try to restore the original BIOS settings to avoid
1639     - * upsetting it.
1640     - */
1641     -
1642     -static int i8042_pm_reset(struct device *dev)
1643     -{
1644     - i8042_controller_reset();
1645     -
1646     - return 0;
1647     -}
1648     -
1649     -/*
1650     * Here we try to reset everything back to a state we had
1651     * before suspending.
1652     */
1653    
1654     -static int i8042_pm_restore(struct device *dev)
1655     +static int i8042_controller_resume(bool force_reset)
1656     {
1657     int error;
1658    
1659     @@ -1118,9 +1104,11 @@ static int i8042_pm_restore(struct device *dev)
1660     if (error)
1661     return error;
1662    
1663     - error = i8042_controller_selftest();
1664     - if (error)
1665     - return error;
1666     + if (i8042_reset || force_reset) {
1667     + error = i8042_controller_selftest();
1668     + if (error)
1669     + return error;
1670     + }
1671    
1672     /*
1673     * Restore original CTR value and disable all ports
1674     @@ -1162,6 +1150,28 @@ static int i8042_pm_restore(struct device *dev)
1675     return 0;
1676     }
1677    
1678     +/*
1679     + * Here we try to restore the original BIOS settings to avoid
1680     + * upsetting it.
1681     + */
1682     +
1683     +static int i8042_pm_reset(struct device *dev)
1684     +{
1685     + i8042_controller_reset();
1686     +
1687     + return 0;
1688     +}
1689     +
1690     +static int i8042_pm_resume(struct device *dev)
1691     +{
1692     + /*
1693     + * On resume from S2R we always try to reset the controller
1694     + * to bring it in a sane state. (In case of S2D we expect
1695     + * BIOS to reset the controller for us.)
1696     + */
1697     + return i8042_controller_resume(true);
1698     +}
1699     +
1700     static int i8042_pm_thaw(struct device *dev)
1701     {
1702     i8042_interrupt(0, NULL);
1703     @@ -1169,9 +1179,14 @@ static int i8042_pm_thaw(struct device *dev)
1704     return 0;
1705     }
1706    
1707     +static int i8042_pm_restore(struct device *dev)
1708     +{
1709     + return i8042_controller_resume(false);
1710     +}
1711     +
1712     static const struct dev_pm_ops i8042_pm_ops = {
1713     .suspend = i8042_pm_reset,
1714     - .resume = i8042_pm_restore,
1715     + .resume = i8042_pm_resume,
1716     .thaw = i8042_pm_thaw,
1717     .poweroff = i8042_pm_reset,
1718     .restore = i8042_pm_restore,
1719     @@ -1389,9 +1404,11 @@ static int __init i8042_probe(struct platform_device *dev)
1720    
1721     i8042_platform_device = dev;
1722    
1723     - error = i8042_controller_selftest();
1724     - if (error)
1725     - return error;
1726     + if (i8042_reset) {
1727     + error = i8042_controller_selftest();
1728     + if (error)
1729     + return error;
1730     + }
1731    
1732     error = i8042_controller_init();
1733     if (error)
1734     @@ -1483,8 +1500,8 @@ static int __init i8042_init(void)
1735    
1736     static void __exit i8042_exit(void)
1737     {
1738     - platform_driver_unregister(&i8042_driver);
1739     platform_device_unregister(i8042_platform_device);
1740     + platform_driver_unregister(&i8042_driver);
1741     i8042_platform_exit();
1742    
1743     panic_blink = NULL;
1744     diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1745     index 569e94d..83e7543 100644
1746     --- a/drivers/mmc/core/core.c
1747     +++ b/drivers/mmc/core/core.c
1748     @@ -1057,6 +1057,17 @@ void mmc_rescan(struct work_struct *work)
1749     container_of(work, struct mmc_host, detect.work);
1750     u32 ocr;
1751     int err;
1752     + unsigned long flags;
1753     +
1754     + spin_lock_irqsave(&host->lock, flags);
1755     +
1756     + if (host->rescan_disable) {
1757     + spin_unlock_irqrestore(&host->lock, flags);
1758     + return;
1759     + }
1760     +
1761     + spin_unlock_irqrestore(&host->lock, flags);
1762     +
1763    
1764     mmc_bus_get(host);
1765    
1766     @@ -1266,19 +1277,6 @@ int mmc_suspend_host(struct mmc_host *host)
1767     if (host->bus_ops && !host->bus_dead) {
1768     if (host->bus_ops->suspend)
1769     err = host->bus_ops->suspend(host);
1770     - if (err == -ENOSYS || !host->bus_ops->resume) {
1771     - /*
1772     - * We simply "remove" the card in this case.
1773     - * It will be redetected on resume.
1774     - */
1775     - if (host->bus_ops->remove)
1776     - host->bus_ops->remove(host);
1777     - mmc_claim_host(host);
1778     - mmc_detach_bus(host);
1779     - mmc_release_host(host);
1780     - host->pm_flags = 0;
1781     - err = 0;
1782     - }
1783     }
1784     mmc_bus_put(host);
1785    
1786     @@ -1310,28 +1308,61 @@ int mmc_resume_host(struct mmc_host *host)
1787     printk(KERN_WARNING "%s: error %d during resume "
1788     "(card was removed?)\n",
1789     mmc_hostname(host), err);
1790     - if (host->bus_ops->remove)
1791     - host->bus_ops->remove(host);
1792     - mmc_claim_host(host);
1793     - mmc_detach_bus(host);
1794     - mmc_release_host(host);
1795     - /* no need to bother upper layers */
1796     err = 0;
1797     }
1798     }
1799     mmc_bus_put(host);
1800    
1801     - /*
1802     - * We add a slight delay here so that resume can progress
1803     - * in parallel.
1804     - */
1805     - mmc_detect_change(host, 1);
1806     -
1807     return err;
1808     }
1809     -
1810     EXPORT_SYMBOL(mmc_resume_host);
1811    
1812     +/* Do the card removal on suspend if card is assumed removeable
1813     + * Do that in pm notifier while userspace isn't yet frozen, so we will be able
1814     + to sync the card.
1815     +*/
1816     +int mmc_pm_notify(struct notifier_block *notify_block,
1817     + unsigned long mode, void *unused)
1818     +{
1819     + struct mmc_host *host = container_of(
1820     + notify_block, struct mmc_host, pm_notify);
1821     + unsigned long flags;
1822     +
1823     +
1824     + switch (mode) {
1825     + case PM_HIBERNATION_PREPARE:
1826     + case PM_SUSPEND_PREPARE:
1827     +
1828     + spin_lock_irqsave(&host->lock, flags);
1829     + host->rescan_disable = 1;
1830     + spin_unlock_irqrestore(&host->lock, flags);
1831     + cancel_delayed_work_sync(&host->detect);
1832     +
1833     + if (!host->bus_ops || host->bus_ops->suspend)
1834     + break;
1835     +
1836     + mmc_claim_host(host);
1837     +
1838     + if (host->bus_ops->remove)
1839     + host->bus_ops->remove(host);
1840     +
1841     + mmc_detach_bus(host);
1842     + mmc_release_host(host);
1843     + host->pm_flags = 0;
1844     + break;
1845     +
1846     + case PM_POST_SUSPEND:
1847     + case PM_POST_HIBERNATION:
1848     +
1849     + spin_lock_irqsave(&host->lock, flags);
1850     + host->rescan_disable = 0;
1851     + spin_unlock_irqrestore(&host->lock, flags);
1852     + mmc_detect_change(host, 0);
1853     +
1854     + }
1855     +
1856     + return 0;
1857     +}
1858     #endif
1859    
1860     static int __init mmc_init(void)
1861     diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
1862     index 4735390..d80cfdc 100644
1863     --- a/drivers/mmc/core/host.c
1864     +++ b/drivers/mmc/core/host.c
1865     @@ -17,6 +17,7 @@
1866     #include <linux/pagemap.h>
1867     #include <linux/leds.h>
1868     #include <linux/slab.h>
1869     +#include <linux/suspend.h>
1870    
1871     #include <linux/mmc/host.h>
1872    
1873     @@ -85,6 +86,9 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1874     init_waitqueue_head(&host->wq);
1875     INIT_DELAYED_WORK(&host->detect, mmc_rescan);
1876     INIT_DELAYED_WORK_DEFERRABLE(&host->disable, mmc_host_deeper_disable);
1877     +#ifdef CONFIG_PM
1878     + host->pm_notify.notifier_call = mmc_pm_notify;
1879     +#endif
1880    
1881     /*
1882     * By default, hosts do not support SGIO or large requests.
1883     @@ -133,6 +137,7 @@ int mmc_add_host(struct mmc_host *host)
1884     #endif
1885    
1886     mmc_start_host(host);
1887     + register_pm_notifier(&host->pm_notify);
1888    
1889     return 0;
1890     }
1891     @@ -149,6 +154,7 @@ EXPORT_SYMBOL(mmc_add_host);
1892     */
1893     void mmc_remove_host(struct mmc_host *host)
1894     {
1895     + unregister_pm_notifier(&host->pm_notify);
1896     mmc_stop_host(host);
1897    
1898     #ifdef CONFIG_DEBUG_FS
1899     diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
1900     index ee7d0a5..69d98e3 100644
1901     --- a/drivers/mmc/host/tmio_mmc.c
1902     +++ b/drivers/mmc/host/tmio_mmc.c
1903     @@ -164,6 +164,7 @@ tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command *cmd)
1904     static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
1905     {
1906     struct mmc_data *data = host->data;
1907     + void *sg_virt;
1908     unsigned short *buf;
1909     unsigned int count;
1910     unsigned long flags;
1911     @@ -173,8 +174,8 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
1912     return;
1913     }
1914    
1915     - buf = (unsigned short *)(tmio_mmc_kmap_atomic(host, &flags) +
1916     - host->sg_off);
1917     + sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags);
1918     + buf = (unsigned short *)(sg_virt + host->sg_off);
1919    
1920     count = host->sg_ptr->length - host->sg_off;
1921     if (count > data->blksz)
1922     @@ -191,7 +192,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
1923    
1924     host->sg_off += count;
1925    
1926     - tmio_mmc_kunmap_atomic(host, &flags);
1927     + tmio_mmc_kunmap_atomic(sg_virt, &flags);
1928    
1929     if (host->sg_off == host->sg_ptr->length)
1930     tmio_mmc_next_sg(host);
1931     diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
1932     index 64f7d5d..0fedc78 100644
1933     --- a/drivers/mmc/host/tmio_mmc.h
1934     +++ b/drivers/mmc/host/tmio_mmc.h
1935     @@ -82,10 +82,7 @@
1936    
1937     #define ack_mmc_irqs(host, i) \
1938     do { \
1939     - u32 mask;\
1940     - mask = sd_ctrl_read32((host), CTL_STATUS); \
1941     - mask &= ~((i) & TMIO_MASK_IRQ); \
1942     - sd_ctrl_write32((host), CTL_STATUS, mask); \
1943     + sd_ctrl_write32((host), CTL_STATUS, ~(i)); \
1944     } while (0)
1945    
1946    
1947     @@ -177,19 +174,17 @@ static inline int tmio_mmc_next_sg(struct tmio_mmc_host *host)
1948     return --host->sg_len;
1949     }
1950    
1951     -static inline char *tmio_mmc_kmap_atomic(struct tmio_mmc_host *host,
1952     +static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg,
1953     unsigned long *flags)
1954     {
1955     - struct scatterlist *sg = host->sg_ptr;
1956     -
1957     local_irq_save(*flags);
1958     return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
1959     }
1960    
1961     -static inline void tmio_mmc_kunmap_atomic(struct tmio_mmc_host *host,
1962     +static inline void tmio_mmc_kunmap_atomic(void *virt,
1963     unsigned long *flags)
1964     {
1965     - kunmap_atomic(sg_page(host->sg_ptr), KM_BIO_SRC_IRQ);
1966     + kunmap_atomic(virt, KM_BIO_SRC_IRQ);
1967     local_irq_restore(*flags);
1968     }
1969    
1970     diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
1971     index ab9fe22..f1e3469 100644
1972     --- a/drivers/net/wireless/ath/ath5k/base.c
1973     +++ b/drivers/net/wireless/ath/ath5k/base.c
1974     @@ -1318,6 +1318,10 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
1975     PCI_DMA_TODEVICE);
1976    
1977     rate = ieee80211_get_tx_rate(sc->hw, info);
1978     + if (!rate) {
1979     + ret = -EINVAL;
1980     + goto err_unmap;
1981     + }
1982    
1983     if (info->flags & IEEE80211_TX_CTL_NO_ACK)
1984     flags |= AR5K_TXDESC_NOACK;
1985     diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1986     index cb4e7da..5543465 100644
1987     --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1988     +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1989     @@ -768,7 +768,7 @@ static bool ar9300_uncompress_block(struct ath_hw *ah,
1990     length = block[it+1];
1991     length &= 0xff;
1992    
1993     - if (length > 0 && spot >= 0 && spot+length < mdataSize) {
1994     + if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
1995     ath_print(common, ATH_DBG_EEPROM,
1996     "Restore at %d: spot=%d "
1997     "offset=%d length=%d\n",
1998     diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
1999     index 5f01a0f..0e8489d 100644
2000     --- a/drivers/net/wireless/ath/ath9k/eeprom.h
2001     +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
2002     @@ -62,7 +62,7 @@
2003    
2004     #define SD_NO_CTL 0xE0
2005     #define NO_CTL 0xff
2006     -#define CTL_MODE_M 7
2007     +#define CTL_MODE_M 0xf
2008     #define CTL_11A 0
2009     #define CTL_11B 1
2010     #define CTL_11G 2
2011     diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2012     index 9d371c1..5f3c47d 100644
2013     --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2014     +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2015     @@ -370,7 +370,8 @@ static int ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
2016     priv->tgt_rate.rates.ht_rates.rs_nrates = j;
2017    
2018     caps = WLAN_RC_HT_FLAG;
2019     - if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
2020     + if ((sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
2021     + (conf_is_ht40(&priv->hw->conf)))
2022     caps |= WLAN_RC_40_FLAG;
2023     if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
2024     caps |= WLAN_RC_SGI_FLAG;
2025     diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
2026     index a1c3952..345dd97 100644
2027     --- a/drivers/net/wireless/ath/regd.h
2028     +++ b/drivers/net/wireless/ath/regd.h
2029     @@ -31,7 +31,6 @@ enum ctl_group {
2030     #define NO_CTL 0xff
2031     #define SD_NO_CTL 0xE0
2032     #define NO_CTL 0xff
2033     -#define CTL_MODE_M 7
2034     #define CTL_11A 0
2035     #define CTL_11B 1
2036     #define CTL_11G 2
2037     diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
2038     index 4e68910..ccb2dd1 100644
2039     --- a/drivers/net/wireless/p54/txrx.c
2040     +++ b/drivers/net/wireless/p54/txrx.c
2041     @@ -444,7 +444,7 @@ static void p54_rx_frame_sent(struct p54_common *priv, struct sk_buff *skb)
2042     }
2043    
2044     if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
2045     - (!payload->status))
2046     + !(payload->status & P54_TX_FAILED))
2047     info->flags |= IEEE80211_TX_STAT_ACK;
2048     if (payload->status & P54_TX_PSM_CANCELLED)
2049     info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
2050     diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
2051     index a9352b2..b7e755f 100644
2052     --- a/drivers/oprofile/buffer_sync.c
2053     +++ b/drivers/oprofile/buffer_sync.c
2054     @@ -141,16 +141,6 @@ static struct notifier_block module_load_nb = {
2055     .notifier_call = module_load_notify,
2056     };
2057    
2058     -
2059     -static void end_sync(void)
2060     -{
2061     - end_cpu_work();
2062     - /* make sure we don't leak task structs */
2063     - process_task_mortuary();
2064     - process_task_mortuary();
2065     -}
2066     -
2067     -
2068     int sync_start(void)
2069     {
2070     int err;
2071     @@ -158,7 +148,7 @@ int sync_start(void)
2072     if (!zalloc_cpumask_var(&marked_cpus, GFP_KERNEL))
2073     return -ENOMEM;
2074    
2075     - start_cpu_work();
2076     + mutex_lock(&buffer_mutex);
2077    
2078     err = task_handoff_register(&task_free_nb);
2079     if (err)
2080     @@ -173,7 +163,10 @@ int sync_start(void)
2081     if (err)
2082     goto out4;
2083    
2084     + start_cpu_work();
2085     +
2086     out:
2087     + mutex_unlock(&buffer_mutex);
2088     return err;
2089     out4:
2090     profile_event_unregister(PROFILE_MUNMAP, &munmap_nb);
2091     @@ -182,7 +175,6 @@ out3:
2092     out2:
2093     task_handoff_unregister(&task_free_nb);
2094     out1:
2095     - end_sync();
2096     free_cpumask_var(marked_cpus);
2097     goto out;
2098     }
2099     @@ -190,11 +182,20 @@ out1:
2100    
2101     void sync_stop(void)
2102     {
2103     + /* flush buffers */
2104     + mutex_lock(&buffer_mutex);
2105     + end_cpu_work();
2106     unregister_module_notifier(&module_load_nb);
2107     profile_event_unregister(PROFILE_MUNMAP, &munmap_nb);
2108     profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);
2109     task_handoff_unregister(&task_free_nb);
2110     - end_sync();
2111     + mutex_unlock(&buffer_mutex);
2112     + flush_scheduled_work();
2113     +
2114     + /* make sure we don't leak task structs */
2115     + process_task_mortuary();
2116     + process_task_mortuary();
2117     +
2118     free_cpumask_var(marked_cpus);
2119     }
2120    
2121     diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
2122     index 219f79e..f179ac2 100644
2123     --- a/drivers/oprofile/cpu_buffer.c
2124     +++ b/drivers/oprofile/cpu_buffer.c
2125     @@ -120,8 +120,6 @@ void end_cpu_work(void)
2126    
2127     cancel_delayed_work(&b->work);
2128     }
2129     -
2130     - flush_scheduled_work();
2131     }
2132    
2133     /*
2134     diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
2135     index 77b68ea..cd22d69 100644
2136     --- a/drivers/pci/msi.c
2137     +++ b/drivers/pci/msi.c
2138     @@ -196,6 +196,9 @@ void unmask_msi_irq(unsigned int irq)
2139     void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
2140     {
2141     struct msi_desc *entry = get_irq_desc_msi(desc);
2142     +
2143     + BUG_ON(entry->dev->current_state != PCI_D0);
2144     +
2145     if (entry->msi_attrib.is_msix) {
2146     void __iomem *base = entry->mask_base +
2147     entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
2148     @@ -229,10 +232,32 @@ void read_msi_msg(unsigned int irq, struct msi_msg *msg)
2149     read_msi_msg_desc(desc, msg);
2150     }
2151    
2152     +void get_cached_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
2153     +{
2154     + struct msi_desc *entry = get_irq_desc_msi(desc);
2155     +
2156     + /* Assert that the cache is valid, assuming that
2157     + * valid messages are not all-zeroes. */
2158     + BUG_ON(!(entry->msg.address_hi | entry->msg.address_lo |
2159     + entry->msg.data));
2160     +
2161     + *msg = entry->msg;
2162     +}
2163     +
2164     +void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg)
2165     +{
2166     + struct irq_desc *desc = irq_to_desc(irq);
2167     +
2168     + get_cached_msi_msg_desc(desc, msg);
2169     +}
2170     +
2171     void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
2172     {
2173     struct msi_desc *entry = get_irq_desc_msi(desc);
2174     - if (entry->msi_attrib.is_msix) {
2175     +
2176     + if (entry->dev->current_state != PCI_D0) {
2177     + /* Don't touch the hardware now */
2178     + } else if (entry->msi_attrib.is_msix) {
2179     void __iomem *base;
2180     base = entry->mask_base +
2181     entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
2182     diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c
2183     index 936bae5..dc628cb 100644
2184     --- a/drivers/power/apm_power.c
2185     +++ b/drivers/power/apm_power.c
2186     @@ -233,6 +233,7 @@ static int calculate_capacity(enum apm_source source)
2187     empty_design_prop = POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN;
2188     now_prop = POWER_SUPPLY_PROP_ENERGY_NOW;
2189     avg_prop = POWER_SUPPLY_PROP_ENERGY_AVG;
2190     + break;
2191     case SOURCE_VOLTAGE:
2192     full_prop = POWER_SUPPLY_PROP_VOLTAGE_MAX;
2193     empty_prop = POWER_SUPPLY_PROP_VOLTAGE_MIN;
2194     diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/serial/bfin_sport_uart.c
2195     index e57fb3d..5318dd3 100644
2196     --- a/drivers/serial/bfin_sport_uart.c
2197     +++ b/drivers/serial/bfin_sport_uart.c
2198     @@ -121,7 +121,7 @@ static int sport_uart_setup(struct sport_uart_port *up, int size, int baud_rate)
2199     unsigned int sclk = get_sclk();
2200    
2201     /* Set TCR1 and TCR2, TFSR is not enabled for uart */
2202     - SPORT_PUT_TCR1(up, (ITFS | TLSBIT | ITCLK));
2203     + SPORT_PUT_TCR1(up, (LATFS | ITFS | TFSR | TLSBIT | ITCLK));
2204     SPORT_PUT_TCR2(up, size + 1);
2205     pr_debug("%s TCR1:%x, TCR2:%x\n", __func__, SPORT_GET_TCR1(up), SPORT_GET_TCR2(up));
2206    
2207     diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
2208     index 55b9932..69cc8f7 100644
2209     --- a/drivers/staging/hv/netvsc_drv.c
2210     +++ b/drivers/staging/hv/netvsc_drv.c
2211     @@ -348,6 +348,9 @@ static const struct net_device_ops device_ops = {
2212     .ndo_stop = netvsc_close,
2213     .ndo_start_xmit = netvsc_start_xmit,
2214     .ndo_set_multicast_list = netvsc_set_multicast_list,
2215     + .ndo_change_mtu = eth_change_mtu,
2216     + .ndo_validate_addr = eth_validate_addr,
2217     + .ndo_set_mac_address = eth_mac_addr,
2218     };
2219    
2220     static int netvsc_probe(struct device *device)
2221     diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
2222     index ae2a10e..c5a3870 100644
2223     --- a/drivers/staging/hv/ring_buffer.c
2224     +++ b/drivers/staging/hv/ring_buffer.c
2225     @@ -192,8 +192,7 @@ Description:
2226     static inline u64
2227     GetRingBufferIndices(RING_BUFFER_INFO *RingInfo)
2228     {
2229     - return ((u64)RingInfo->RingBuffer->WriteIndex << 32)
2230     - || RingInfo->RingBuffer->ReadIndex;
2231     + return (u64)RingInfo->RingBuffer->WriteIndex << 32;
2232     }
2233    
2234    
2235     diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h
2236     index 0063bde..8505a1c 100644
2237     --- a/drivers/staging/hv/storvsc_api.h
2238     +++ b/drivers/staging/hv/storvsc_api.h
2239     @@ -28,10 +28,10 @@
2240     #include "vmbus_api.h"
2241    
2242     /* Defines */
2243     -#define STORVSC_RING_BUFFER_SIZE (10*PAGE_SIZE)
2244     +#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
2245     #define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
2246    
2247     -#define STORVSC_MAX_IO_REQUESTS 64
2248     +#define STORVSC_MAX_IO_REQUESTS 128
2249    
2250     /*
2251     * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
2252     diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
2253     index d22e35f..c1ba458 100644
2254     --- a/drivers/staging/hv/storvsc_drv.c
2255     +++ b/drivers/staging/hv/storvsc_drv.c
2256     @@ -526,7 +526,7 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
2257    
2258     /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
2259    
2260     - if (j == 0)
2261     + if (bounce_addr == 0)
2262     bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
2263    
2264     while (srclen) {
2265     @@ -587,7 +587,7 @@ static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
2266     destlen = orig_sgl[i].length;
2267     /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
2268    
2269     - if (j == 0)
2270     + if (bounce_addr == 0)
2271     bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
2272    
2273     while (destlen) {
2274     @@ -646,6 +646,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
2275     unsigned int request_size = 0;
2276     int i;
2277     struct scatterlist *sgl;
2278     + unsigned int sg_count = 0;
2279    
2280     DPRINT_ENTER(STORVSC_DRV);
2281    
2282     @@ -730,6 +731,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
2283     request->DataBuffer.Length = scsi_bufflen(scmnd);
2284     if (scsi_sg_count(scmnd)) {
2285     sgl = (struct scatterlist *)scsi_sglist(scmnd);
2286     + sg_count = scsi_sg_count(scmnd);
2287    
2288     /* check if we need to bounce the sgl */
2289     if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
2290     @@ -764,15 +766,16 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
2291     scsi_sg_count(scmnd));
2292    
2293     sgl = cmd_request->bounce_sgl;
2294     + sg_count = cmd_request->bounce_sgl_count;
2295     }
2296    
2297     request->DataBuffer.Offset = sgl[0].offset;
2298    
2299     - for (i = 0; i < scsi_sg_count(scmnd); i++) {
2300     + for (i = 0; i < sg_count; i++) {
2301     DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n",
2302     i, sgl[i].length, sgl[i].offset);
2303     request->DataBuffer.PfnArray[i] =
2304     - page_to_pfn(sg_page((&sgl[i])));
2305     + page_to_pfn(sg_page((&sgl[i])));
2306     }
2307     } else if (scsi_sglist(scmnd)) {
2308     /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
2309     diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
2310     index c48e85d..1252392 100644
2311     --- a/drivers/staging/rt2860/usb_main_dev.c
2312     +++ b/drivers/staging/rt2860/usb_main_dev.c
2313     @@ -44,6 +44,7 @@ struct usb_device_id rtusb_usb_id[] = {
2314     {USB_DEVICE(0x07B8, 0x2870)}, /* AboCom */
2315     {USB_DEVICE(0x07B8, 0x2770)}, /* AboCom */
2316     {USB_DEVICE(0x0DF6, 0x0039)}, /* Sitecom 2770 */
2317     + {USB_DEVICE(0x0DF6, 0x003F)}, /* Sitecom 2770 */
2318     {USB_DEVICE(0x083A, 0x7512)}, /* Arcadyan 2770 */
2319     {USB_DEVICE(0x0789, 0x0162)}, /* Logitec 2870 */
2320     {USB_DEVICE(0x0789, 0x0163)}, /* Logitec 2870 */
2321     @@ -95,7 +96,8 @@ struct usb_device_id rtusb_usb_id[] = {
2322     {USB_DEVICE(0x050d, 0x815c)},
2323     {USB_DEVICE(0x1482, 0x3C09)}, /* Abocom */
2324     {USB_DEVICE(0x14B2, 0x3C09)}, /* Alpha */
2325     - {USB_DEVICE(0x04E8, 0x2018)}, /* samsung */
2326     + {USB_DEVICE(0x04E8, 0x2018)}, /* samsung linkstick2 */
2327     + {USB_DEVICE(0x1690, 0x0740)}, /* Askey */
2328     {USB_DEVICE(0x5A57, 0x0280)}, /* Zinwell */
2329     {USB_DEVICE(0x5A57, 0x0282)}, /* Zinwell */
2330     {USB_DEVICE(0x7392, 0x7718)},
2331     @@ -105,21 +107,34 @@ struct usb_device_id rtusb_usb_id[] = {
2332     {USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */
2333     {USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */
2334     {USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */
2335     + {USB_DEVICE(0x100D, 0x9031)}, /* Motorola 2770 */
2336     #endif /* RT2870 // */
2337     #ifdef RT3070
2338     {USB_DEVICE(0x148F, 0x3070)}, /* Ralink 3070 */
2339     {USB_DEVICE(0x148F, 0x3071)}, /* Ralink 3071 */
2340     {USB_DEVICE(0x148F, 0x3072)}, /* Ralink 3072 */
2341     {USB_DEVICE(0x0DB0, 0x3820)}, /* Ralink 3070 */
2342     + {USB_DEVICE(0x0DB0, 0x871C)}, /* Ralink 3070 */
2343     + {USB_DEVICE(0x0DB0, 0x822C)}, /* Ralink 3070 */
2344     + {USB_DEVICE(0x0DB0, 0x871B)}, /* Ralink 3070 */
2345     + {USB_DEVICE(0x0DB0, 0x822B)}, /* Ralink 3070 */
2346     {USB_DEVICE(0x0DF6, 0x003E)}, /* Sitecom 3070 */
2347     {USB_DEVICE(0x0DF6, 0x0042)}, /* Sitecom 3072 */
2348     + {USB_DEVICE(0x0DF6, 0x0048)}, /* Sitecom 3070 */
2349     + {USB_DEVICE(0x0DF6, 0x0047)}, /* Sitecom 3071 */
2350     {USB_DEVICE(0x14B2, 0x3C12)}, /* AL 3070 */
2351     {USB_DEVICE(0x18C5, 0x0012)}, /* Corega 3070 */
2352     {USB_DEVICE(0x083A, 0x7511)}, /* Arcadyan 3070 */
2353     + {USB_DEVICE(0x083A, 0xA701)}, /* SMC 3070 */
2354     + {USB_DEVICE(0x083A, 0xA702)}, /* SMC 3072 */
2355     {USB_DEVICE(0x1740, 0x9703)}, /* EnGenius 3070 */
2356     {USB_DEVICE(0x1740, 0x9705)}, /* EnGenius 3071 */
2357     {USB_DEVICE(0x1740, 0x9706)}, /* EnGenius 3072 */
2358     + {USB_DEVICE(0x1740, 0x9707)}, /* EnGenius 3070 */
2359     + {USB_DEVICE(0x1740, 0x9708)}, /* EnGenius 3071 */
2360     + {USB_DEVICE(0x1740, 0x9709)}, /* EnGenius 3072 */
2361     {USB_DEVICE(0x13D3, 0x3273)}, /* AzureWave 3070 */
2362     + {USB_DEVICE(0x13D3, 0x3305)}, /* AzureWave 3070*/
2363     {USB_DEVICE(0x1044, 0x800D)}, /* Gigabyte GN-WB32L 3070 */
2364     {USB_DEVICE(0x2019, 0xAB25)}, /* Planex Communications, Inc. RT3070 */
2365     {USB_DEVICE(0x07B8, 0x3070)}, /* AboCom 3070 */
2366     @@ -132,14 +147,36 @@ struct usb_device_id rtusb_usb_id[] = {
2367     {USB_DEVICE(0x07D1, 0x3C0D)}, /* D-Link 3070 */
2368     {USB_DEVICE(0x07D1, 0x3C0E)}, /* D-Link 3070 */
2369     {USB_DEVICE(0x07D1, 0x3C0F)}, /* D-Link 3070 */
2370     + {USB_DEVICE(0x07D1, 0x3C16)}, /* D-Link 3070 */
2371     + {USB_DEVICE(0x07D1, 0x3C17)}, /* D-Link 8070 */
2372     {USB_DEVICE(0x1D4D, 0x000C)}, /* Pegatron Corporation 3070 */
2373     {USB_DEVICE(0x1D4D, 0x000E)}, /* Pegatron Corporation 3070 */
2374     {USB_DEVICE(0x5A57, 0x5257)}, /* Zinwell 3070 */
2375     {USB_DEVICE(0x5A57, 0x0283)}, /* Zinwell 3072 */
2376     {USB_DEVICE(0x04BB, 0x0945)}, /* I-O DATA 3072 */
2377     + {USB_DEVICE(0x04BB, 0x0947)}, /* I-O DATA 3070 */
2378     + {USB_DEVICE(0x04BB, 0x0948)}, /* I-O DATA 3072 */
2379     {USB_DEVICE(0x203D, 0x1480)}, /* Encore 3070 */
2380     + {USB_DEVICE(0x20B8, 0x8888)}, /* PARA INDUSTRIAL 3070 */
2381     + {USB_DEVICE(0x0B05, 0x1784)}, /* Asus 3072 */
2382     + {USB_DEVICE(0x203D, 0x14A9)}, /* Encore 3070*/
2383     + {USB_DEVICE(0x0DB0, 0x899A)}, /* MSI 3070*/
2384     + {USB_DEVICE(0x0DB0, 0x3870)}, /* MSI 3070*/
2385     + {USB_DEVICE(0x0DB0, 0x870A)}, /* MSI 3070*/
2386     + {USB_DEVICE(0x0DB0, 0x6899)}, /* MSI 3070 */
2387     + {USB_DEVICE(0x0DB0, 0x3822)}, /* MSI 3070 */
2388     + {USB_DEVICE(0x0DB0, 0x3871)}, /* MSI 3070 */
2389     + {USB_DEVICE(0x0DB0, 0x871A)}, /* MSI 3070 */
2390     + {USB_DEVICE(0x0DB0, 0x822A)}, /* MSI 3070 */
2391     + {USB_DEVICE(0x0DB0, 0x3821)}, /* Ralink 3070 */
2392     + {USB_DEVICE(0x0DB0, 0x821A)}, /* Ralink 3070 */
2393     + {USB_DEVICE(0x083A, 0xA703)}, /* IO-MAGIC */
2394     + {USB_DEVICE(0x13D3, 0x3307)}, /* Azurewave */
2395     + {USB_DEVICE(0x13D3, 0x3321)}, /* Azurewave */
2396     + {USB_DEVICE(0x07FA, 0x7712)}, /* Edimax */
2397     + {USB_DEVICE(0x0789, 0x0166)}, /* Edimax */
2398     + {USB_DEVICE(0x148F, 0x2070)}, /* Edimax */
2399     #endif /* RT3070 // */
2400     - {USB_DEVICE(0x0DF6, 0x003F)}, /* Sitecom WL-608 */
2401     {USB_DEVICE(0x1737, 0x0077)}, /* Linksys WUSB54GC-EU v3 */
2402     {USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */
2403     {USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */
2404     diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
2405     index c89990f..b24025d 100644
2406     --- a/drivers/usb/atm/cxacru.c
2407     +++ b/drivers/usb/atm/cxacru.c
2408     @@ -1128,6 +1128,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
2409     {
2410     struct cxacru_data *instance;
2411     struct usb_device *usb_dev = interface_to_usbdev(intf);
2412     + struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
2413     int ret;
2414    
2415     /* instance init */
2416     @@ -1172,15 +1173,34 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
2417     goto fail;
2418     }
2419    
2420     - usb_fill_int_urb(instance->rcv_urb,
2421     + if (!cmd_ep) {
2422     + dbg("cxacru_bind: no command endpoint");
2423     + ret = -ENODEV;
2424     + goto fail;
2425     + }
2426     +
2427     + if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
2428     + == USB_ENDPOINT_XFER_INT) {
2429     + usb_fill_int_urb(instance->rcv_urb,
2430     usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
2431     instance->rcv_buf, PAGE_SIZE,
2432     cxacru_blocking_completion, &instance->rcv_done, 1);
2433    
2434     - usb_fill_int_urb(instance->snd_urb,
2435     + usb_fill_int_urb(instance->snd_urb,
2436     usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD),
2437     instance->snd_buf, PAGE_SIZE,
2438     cxacru_blocking_completion, &instance->snd_done, 4);
2439     + } else {
2440     + usb_fill_bulk_urb(instance->rcv_urb,
2441     + usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD),
2442     + instance->rcv_buf, PAGE_SIZE,
2443     + cxacru_blocking_completion, &instance->rcv_done);
2444     +
2445     + usb_fill_bulk_urb(instance->snd_urb,
2446     + usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
2447     + instance->snd_buf, PAGE_SIZE,
2448     + cxacru_blocking_completion, &instance->snd_done);
2449     + }
2450    
2451     mutex_init(&instance->cm_serialize);
2452    
2453     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
2454     index 162c95a..a1aacb0 100644
2455     --- a/drivers/usb/class/cdc-acm.c
2456     +++ b/drivers/usb/class/cdc-acm.c
2457     @@ -971,7 +971,8 @@ static int acm_probe(struct usb_interface *intf,
2458     }
2459    
2460     if (!buflen) {
2461     - if (intf->cur_altsetting->endpoint->extralen &&
2462     + if (intf->cur_altsetting->endpoint &&
2463     + intf->cur_altsetting->endpoint->extralen &&
2464     intf->cur_altsetting->endpoint->extra) {
2465     dev_dbg(&intf->dev,
2466     "Seeking extra descriptors on endpoint\n");
2467     @@ -1487,6 +1488,11 @@ static int acm_reset_resume(struct usb_interface *intf)
2468     USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
2469     USB_CDC_ACM_PROTO_VENDOR)
2470    
2471     +#define SAMSUNG_PCSUITE_ACM_INFO(x) \
2472     + USB_DEVICE_AND_INTERFACE_INFO(0x04e7, x, \
2473     + USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
2474     + USB_CDC_ACM_PROTO_VENDOR)
2475     +
2476     /*
2477     * USB driver structure.
2478     */
2479     @@ -1597,6 +1603,17 @@ static const struct usb_device_id acm_ids[] = {
2480     { NOKIA_PCSUITE_ACM_INFO(0x0108), }, /* Nokia 5320 XpressMusic 2G */
2481     { NOKIA_PCSUITE_ACM_INFO(0x01f5), }, /* Nokia N97, RM-505 */
2482     { NOKIA_PCSUITE_ACM_INFO(0x02e3), }, /* Nokia 5230, RM-588 */
2483     + { NOKIA_PCSUITE_ACM_INFO(0x0178), }, /* Nokia E63 */
2484     + { NOKIA_PCSUITE_ACM_INFO(0x010e), }, /* Nokia E75 */
2485     + { NOKIA_PCSUITE_ACM_INFO(0x02d9), }, /* Nokia 6760 Slide */
2486     + { NOKIA_PCSUITE_ACM_INFO(0x01d0), }, /* Nokia E52 */
2487     + { NOKIA_PCSUITE_ACM_INFO(0x0223), }, /* Nokia E72 */
2488     + { NOKIA_PCSUITE_ACM_INFO(0x0275), }, /* Nokia X6 */
2489     + { NOKIA_PCSUITE_ACM_INFO(0x026c), }, /* Nokia N97 Mini */
2490     + { NOKIA_PCSUITE_ACM_INFO(0x0154), }, /* Nokia 5800 XpressMusic */
2491     + { NOKIA_PCSUITE_ACM_INFO(0x04ce), }, /* Nokia E90 */
2492     + { NOKIA_PCSUITE_ACM_INFO(0x01d4), }, /* Nokia E55 */
2493     + { SAMSUNG_PCSUITE_ACM_INFO(0x6651), }, /* Samsung GTi8510 (INNOV8) */
2494    
2495     /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */
2496    
2497     @@ -1605,6 +1622,10 @@ static const struct usb_device_id acm_ids[] = {
2498     .driver_info = NOT_A_MODEM,
2499     },
2500    
2501     + /* control interfaces without any protocol set */
2502     + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
2503     + USB_CDC_PROTO_NONE) },
2504     +
2505     /* control interfaces with various AT-command sets */
2506     { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
2507     USB_CDC_ACM_PROTO_AT_V25TER) },
2508     diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
2509     index fd4c36e..844683e 100644
2510     --- a/drivers/usb/core/message.c
2511     +++ b/drivers/usb/core/message.c
2512     @@ -1724,6 +1724,15 @@ free_interfaces:
2513     if (ret)
2514     goto free_interfaces;
2515    
2516     + /* if it's already configured, clear out old state first.
2517     + * getting rid of old interfaces means unbinding their drivers.
2518     + */
2519     + if (dev->state != USB_STATE_ADDRESS)
2520     + usb_disable_device(dev, 1); /* Skip ep0 */
2521     +
2522     + /* Get rid of pending async Set-Config requests for this device */
2523     + cancel_async_set_config(dev);
2524     +
2525     /* Make sure we have bandwidth (and available HCD resources) for this
2526     * configuration. Remove endpoints from the schedule if we're dropping
2527     * this configuration to set configuration 0. After this point, the
2528     @@ -1733,20 +1742,11 @@ free_interfaces:
2529     mutex_lock(&hcd->bandwidth_mutex);
2530     ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
2531     if (ret < 0) {
2532     - usb_autosuspend_device(dev);
2533     mutex_unlock(&hcd->bandwidth_mutex);
2534     + usb_autosuspend_device(dev);
2535     goto free_interfaces;
2536     }
2537    
2538     - /* if it's already configured, clear out old state first.
2539     - * getting rid of old interfaces means unbinding their drivers.
2540     - */
2541     - if (dev->state != USB_STATE_ADDRESS)
2542     - usb_disable_device(dev, 1); /* Skip ep0 */
2543     -
2544     - /* Get rid of pending async Set-Config requests for this device */
2545     - cancel_async_set_config(dev);
2546     -
2547     ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2548     USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
2549     NULL, 0, USB_CTRL_SET_TIMEOUT);
2550     @@ -1761,8 +1761,8 @@ free_interfaces:
2551     if (!cp) {
2552     usb_set_device_state(dev, USB_STATE_ADDRESS);
2553     usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
2554     - usb_autosuspend_device(dev);
2555     mutex_unlock(&hcd->bandwidth_mutex);
2556     + usb_autosuspend_device(dev);
2557     goto free_interfaces;
2558     }
2559     mutex_unlock(&hcd->bandwidth_mutex);
2560     diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
2561     index 5c0d06c..1043da1 100644
2562     --- a/drivers/usb/gadget/rndis.c
2563     +++ b/drivers/usb/gadget/rndis.c
2564     @@ -292,9 +292,13 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
2565     /* mandatory */
2566     case OID_GEN_VENDOR_DESCRIPTION:
2567     pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
2568     - length = strlen (rndis_per_dev_params [configNr].vendorDescr);
2569     - memcpy (outbuf,
2570     - rndis_per_dev_params [configNr].vendorDescr, length);
2571     + if ( rndis_per_dev_params [configNr].vendorDescr ) {
2572     + length = strlen (rndis_per_dev_params [configNr].vendorDescr);
2573     + memcpy (outbuf,
2574     + rndis_per_dev_params [configNr].vendorDescr, length);
2575     + } else {
2576     + outbuf[0] = 0;
2577     + }
2578     retval = 0;
2579     break;
2580    
2581     diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
2582     index 5aec928..a07cfd6 100644
2583     --- a/drivers/usb/host/ehci-ppc-of.c
2584     +++ b/drivers/usb/host/ehci-ppc-of.c
2585     @@ -192,17 +192,19 @@ ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match)
2586     }
2587    
2588     rv = usb_add_hcd(hcd, irq, 0);
2589     - if (rv == 0)
2590     - return 0;
2591     + if (rv)
2592     + goto err_ehci;
2593     +
2594     + return 0;
2595    
2596     +err_ehci:
2597     + if (ehci->has_amcc_usb23)
2598     + iounmap(ehci->ohci_hcctrl_reg);
2599     iounmap(hcd->regs);
2600     err_ioremap:
2601     irq_dispose_mapping(irq);
2602     err_irq:
2603     release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
2604     -
2605     - if (ehci->has_amcc_usb23)
2606     - iounmap(ehci->ohci_hcctrl_reg);
2607     err_rmr:
2608     usb_put_hcd(hcd);
2609    
2610     diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
2611     index 80bf833..8ed6ff6 100644
2612     --- a/drivers/usb/serial/cp210x.c
2613     +++ b/drivers/usb/serial/cp210x.c
2614     @@ -88,6 +88,7 @@ static const struct usb_device_id id_table[] = {
2615     { USB_DEVICE(0x10C4, 0x8149) }, /* West Mountain Radio Computerized Battery Analyzer */
2616     { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
2617     { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
2618     + { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */
2619     { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
2620     { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */
2621     { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */
2622     @@ -109,6 +110,7 @@ static const struct usb_device_id id_table[] = {
2623     { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
2624     { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
2625     { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
2626     + { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
2627     { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
2628     { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
2629     { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
2630     @@ -122,14 +124,14 @@ static const struct usb_device_id id_table[] = {
2631     { USB_DEVICE(0x1555, 0x0004) }, /* Owen AC4 USB-RS485 Converter */
2632     { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */
2633     { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
2634     - { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
2635     - { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
2636     - { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
2637     - { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
2638     { USB_DEVICE(0x16DC, 0x0010) }, /* W-IE-NE-R Plein & Baus GmbH PL512 Power Supply */
2639     { USB_DEVICE(0x16DC, 0x0011) }, /* W-IE-NE-R Plein & Baus GmbH RCM Remote Control for MARATON Power Supply */
2640     { USB_DEVICE(0x16DC, 0x0012) }, /* W-IE-NE-R Plein & Baus GmbH MPOD Multi Channel Power Supply */
2641     { USB_DEVICE(0x16DC, 0x0015) }, /* W-IE-NE-R Plein & Baus GmbH CML Control, Monitoring and Data Logger */
2642     + { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
2643     + { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
2644     + { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
2645     + { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
2646     { } /* Terminating Entry */
2647     };
2648    
2649     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2650     index 63ddb2f..0edf4b3 100644
2651     --- a/drivers/usb/serial/ftdi_sio.c
2652     +++ b/drivers/usb/serial/ftdi_sio.c
2653     @@ -753,6 +753,14 @@ static struct usb_device_id id_table_combined [] = {
2654     { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) },
2655     { USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID),
2656     .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2657     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) },
2658     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_PC_WING_PID) },
2659     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_USB_DMX_PID) },
2660     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MIDI_TIMECODE_PID) },
2661     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MINI_WING_PID) },
2662     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) },
2663     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) },
2664     + { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) },
2665     { }, /* Optional parameter entry */
2666     { } /* Terminating entry */
2667     };
2668     diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
2669     index 2e95857..15a4583 100644
2670     --- a/drivers/usb/serial/ftdi_sio_ids.h
2671     +++ b/drivers/usb/serial/ftdi_sio_ids.h
2672     @@ -135,6 +135,18 @@
2673     #define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */
2674    
2675     /*
2676     + * ChamSys Limited (www.chamsys.co.uk) USB wing/interface product IDs
2677     + */
2678     +#define FTDI_CHAMSYS_24_MASTER_WING_PID 0xDAF8
2679     +#define FTDI_CHAMSYS_PC_WING_PID 0xDAF9
2680     +#define FTDI_CHAMSYS_USB_DMX_PID 0xDAFA
2681     +#define FTDI_CHAMSYS_MIDI_TIMECODE_PID 0xDAFB
2682     +#define FTDI_CHAMSYS_MINI_WING_PID 0xDAFC
2683     +#define FTDI_CHAMSYS_MAXI_WING_PID 0xDAFD
2684     +#define FTDI_CHAMSYS_MEDIA_WING_PID 0xDAFE
2685     +#define FTDI_CHAMSYS_WING_PID 0xDAFF
2686     +
2687     +/*
2688     * Westrex International devices submitted by Cory Lee
2689     */
2690     #define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */
2691     diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
2692     index 585b7e6..1c9b6e9 100644
2693     --- a/drivers/usb/serial/mos7840.c
2694     +++ b/drivers/usb/serial/mos7840.c
2695     @@ -119,16 +119,20 @@
2696     * by making a change here, in moschip_port_id_table, and in
2697     * moschip_id_table_combined
2698     */
2699     -#define USB_VENDOR_ID_BANDB 0x0856
2700     -#define BANDB_DEVICE_ID_USO9ML2_2 0xAC22
2701     -#define BANDB_DEVICE_ID_USO9ML2_4 0xAC24
2702     -#define BANDB_DEVICE_ID_US9ML2_2 0xAC29
2703     -#define BANDB_DEVICE_ID_US9ML2_4 0xAC30
2704     -#define BANDB_DEVICE_ID_USPTL4_2 0xAC31
2705     -#define BANDB_DEVICE_ID_USPTL4_4 0xAC32
2706     -#define BANDB_DEVICE_ID_USOPTL4_2 0xAC42
2707     -#define BANDB_DEVICE_ID_USOPTL4_4 0xAC44
2708     -#define BANDB_DEVICE_ID_USOPTL2_4 0xAC24
2709     +#define USB_VENDOR_ID_BANDB 0x0856
2710     +#define BANDB_DEVICE_ID_USO9ML2_2 0xAC22
2711     +#define BANDB_DEVICE_ID_USO9ML2_2P 0xBC00
2712     +#define BANDB_DEVICE_ID_USO9ML2_4 0xAC24
2713     +#define BANDB_DEVICE_ID_USO9ML2_4P 0xBC01
2714     +#define BANDB_DEVICE_ID_US9ML2_2 0xAC29
2715     +#define BANDB_DEVICE_ID_US9ML2_4 0xAC30
2716     +#define BANDB_DEVICE_ID_USPTL4_2 0xAC31
2717     +#define BANDB_DEVICE_ID_USPTL4_4 0xAC32
2718     +#define BANDB_DEVICE_ID_USOPTL4_2 0xAC42
2719     +#define BANDB_DEVICE_ID_USOPTL4_2P 0xBC02
2720     +#define BANDB_DEVICE_ID_USOPTL4_4 0xAC44
2721     +#define BANDB_DEVICE_ID_USOPTL4_4P 0xBC03
2722     +#define BANDB_DEVICE_ID_USOPTL2_4 0xAC24
2723    
2724     /* This driver also supports
2725     * ATEN UC2324 device using Moschip MCS7840
2726     @@ -184,13 +188,17 @@ static const struct usb_device_id moschip_port_id_table[] = {
2727     {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
2728     {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
2729     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
2730     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2P)},
2731     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4)},
2732     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4P)},
2733     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2)},
2734     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4)},
2735     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2)},
2736     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
2737     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
2738     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2P)},
2739     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
2740     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4P)},
2741     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
2742     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
2743     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
2744     @@ -201,13 +209,17 @@ static const struct usb_device_id moschip_id_table_combined[] __devinitconst = {
2745     {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
2746     {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
2747     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
2748     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2P)},
2749     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4)},
2750     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4P)},
2751     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2)},
2752     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4)},
2753     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2)},
2754     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
2755     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
2756     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2P)},
2757     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
2758     + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4P)},
2759     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
2760     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
2761     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
2762     diff --git a/drivers/xen/events.c b/drivers/xen/events.c
2763     index 28f133a..14ed358 100644
2764     --- a/drivers/xen/events.c
2765     +++ b/drivers/xen/events.c
2766     @@ -107,6 +107,7 @@ static inline unsigned long *cpu_evtchn_mask(int cpu)
2767     #define VALID_EVTCHN(chn) ((chn) != 0)
2768    
2769     static struct irq_chip xen_dynamic_chip;
2770     +static struct irq_chip xen_percpu_chip;
2771    
2772     /* Constructor for packed IRQ information. */
2773     static struct irq_info mk_unbound_info(void)
2774     @@ -363,7 +364,7 @@ int bind_evtchn_to_irq(unsigned int evtchn)
2775     irq = find_unbound_irq();
2776    
2777     set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
2778     - handle_level_irq, "event");
2779     + handle_edge_irq, "event");
2780    
2781     evtchn_to_irq[evtchn] = irq;
2782     irq_info[irq] = mk_evtchn_info(evtchn);
2783     @@ -389,8 +390,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
2784     if (irq < 0)
2785     goto out;
2786    
2787     - set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
2788     - handle_level_irq, "ipi");
2789     + set_irq_chip_and_handler_name(irq, &xen_percpu_chip,
2790     + handle_percpu_irq, "ipi");
2791    
2792     bind_ipi.vcpu = cpu;
2793     if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
2794     @@ -430,8 +431,8 @@ static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
2795    
2796     irq = find_unbound_irq();
2797    
2798     - set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
2799     - handle_level_irq, "virq");
2800     + set_irq_chip_and_handler_name(irq, &xen_percpu_chip,
2801     + handle_percpu_irq, "virq");
2802    
2803     evtchn_to_irq[evtchn] = irq;
2804     irq_info[irq] = mk_virq_info(evtchn, virq);
2805     @@ -934,6 +935,16 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
2806     .retrigger = retrigger_dynirq,
2807     };
2808    
2809     +static struct irq_chip en_percpu_chip __read_mostly = {
2810     + .name = "xen-percpu",
2811     +
2812     + .disable = disable_dynirq,
2813     + .mask = disable_dynirq,
2814     + .unmask = enable_dynirq,
2815     +
2816     + .ack = ack_dynirq,
2817     +};
2818     +
2819     void __init xen_init_IRQ(void)
2820     {
2821     int i;
2822     diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
2823     index c4e8353..42b60b0 100644
2824     --- a/fs/binfmt_misc.c
2825     +++ b/fs/binfmt_misc.c
2826     @@ -723,7 +723,7 @@ static int __init init_misc_binfmt(void)
2827     {
2828     int err = register_filesystem(&bm_fs_type);
2829     if (!err) {
2830     - err = register_binfmt(&misc_format);
2831     + err = insert_binfmt(&misc_format);
2832     if (err)
2833     unregister_filesystem(&bm_fs_type);
2834     }
2835     diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
2836     index 2208f06..fa1039a 100644
2837     --- a/fs/cifs/connect.c
2838     +++ b/fs/cifs/connect.c
2839     @@ -1647,9 +1647,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
2840     if (ses) {
2841     cFYI(1, "Existing smb sess found (status=%d)", ses->status);
2842    
2843     - /* existing SMB ses has a server reference already */
2844     - cifs_put_tcp_session(server);
2845     -
2846     mutex_lock(&ses->session_mutex);
2847     rc = cifs_negotiate_protocol(xid, ses);
2848     if (rc) {
2849     @@ -1672,6 +1669,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
2850     }
2851     }
2852     mutex_unlock(&ses->session_mutex);
2853     +
2854     + /* existing SMB ses has a server reference already */
2855     + cifs_put_tcp_session(server);
2856     FreeXid(xid);
2857     return ses;
2858     }
2859     diff --git a/fs/direct-io.c b/fs/direct-io.c
2860     index 7600aac..458fdd3 100644
2861     --- a/fs/direct-io.c
2862     +++ b/fs/direct-io.c
2863     @@ -218,7 +218,7 @@ static struct page *dio_get_page(struct dio *dio)
2864     * filesystems can use it to hold additional state between get_block calls and
2865     * dio_complete.
2866     */
2867     -static int dio_complete(struct dio *dio, loff_t offset, int ret)
2868     +static int dio_complete(struct dio *dio, loff_t offset, int ret, bool is_async)
2869     {
2870     ssize_t transferred = 0;
2871    
2872     @@ -239,14 +239,6 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
2873     transferred = dio->i_size - offset;
2874     }
2875    
2876     - if (dio->end_io && dio->result)
2877     - dio->end_io(dio->iocb, offset, transferred,
2878     - dio->map_bh.b_private);
2879     -
2880     - if (dio->flags & DIO_LOCKING)
2881     - /* lockdep: non-owner release */
2882     - up_read_non_owner(&dio->inode->i_alloc_sem);
2883     -
2884     if (ret == 0)
2885     ret = dio->page_errors;
2886     if (ret == 0)
2887     @@ -254,6 +246,17 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
2888     if (ret == 0)
2889     ret = transferred;
2890    
2891     + if (dio->end_io && dio->result) {
2892     + dio->end_io(dio->iocb, offset, transferred,
2893     + dio->map_bh.b_private, ret, is_async);
2894     + } else if (is_async) {
2895     + aio_complete(dio->iocb, ret, 0);
2896     + }
2897     +
2898     + if (dio->flags & DIO_LOCKING)
2899     + /* lockdep: non-owner release */
2900     + up_read_non_owner(&dio->inode->i_alloc_sem);
2901     +
2902     return ret;
2903     }
2904    
2905     @@ -277,8 +280,7 @@ static void dio_bio_end_aio(struct bio *bio, int error)
2906     spin_unlock_irqrestore(&dio->bio_lock, flags);
2907    
2908     if (remaining == 0) {
2909     - int ret = dio_complete(dio, dio->iocb->ki_pos, 0);
2910     - aio_complete(dio->iocb, ret, 0);
2911     + dio_complete(dio, dio->iocb->ki_pos, 0, true);
2912     kfree(dio);
2913     }
2914     }
2915     @@ -632,7 +634,7 @@ static int dio_send_cur_page(struct dio *dio)
2916     int ret = 0;
2917    
2918     if (dio->bio) {
2919     - loff_t cur_offset = dio->block_in_file << dio->blkbits;
2920     + loff_t cur_offset = dio->cur_page_fs_offset;
2921     loff_t bio_next_offset = dio->logical_offset_in_bio +
2922     dio->bio->bi_size;
2923    
2924     @@ -657,7 +659,7 @@ static int dio_send_cur_page(struct dio *dio)
2925     * Submit now if the underlying fs is about to perform a
2926     * metadata read
2927     */
2928     - if (dio->boundary)
2929     + else if (dio->boundary)
2930     dio_bio_submit(dio);
2931     }
2932    
2933     @@ -1126,7 +1128,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
2934     spin_unlock_irqrestore(&dio->bio_lock, flags);
2935    
2936     if (ret2 == 0) {
2937     - ret = dio_complete(dio, offset, ret);
2938     + ret = dio_complete(dio, offset, ret, false);
2939     kfree(dio);
2940     } else
2941     BUG_ON(ret != -EIOCBQUEUED);
2942     diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2943     index 19a4de5..4c9f05d 100644
2944     --- a/fs/ext4/ext4.h
2945     +++ b/fs/ext4/ext4.h
2946     @@ -167,13 +167,15 @@ struct mpage_da_data {
2947     };
2948     #define EXT4_IO_UNWRITTEN 0x1
2949     typedef struct ext4_io_end {
2950     - struct list_head list; /* per-file finished AIO list */
2951     + struct list_head list; /* per-file finished IO list */
2952     struct inode *inode; /* file being written to */
2953     unsigned int flag; /* unwritten or not */
2954     struct page *page; /* page struct for buffer write */
2955     loff_t offset; /* offset in the file */
2956     ssize_t size; /* size of the extent */
2957     struct work_struct work; /* data work queue */
2958     + struct kiocb *iocb; /* iocb struct for AIO */
2959     + int result; /* error value for AIO */
2960     } ext4_io_end_t;
2961    
2962     /*
2963     diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2964     index 42272d6..3fb64b9 100644
2965     --- a/fs/ext4/inode.c
2966     +++ b/fs/ext4/inode.c
2967     @@ -3668,6 +3668,8 @@ static int ext4_end_io_nolock(ext4_io_end_t *io)
2968     return ret;
2969     }
2970    
2971     + if (io->iocb)
2972     + aio_complete(io->iocb, io->result, 0);
2973     /* clear the DIO AIO unwritten flag */
2974     io->flag = 0;
2975     return ret;
2976     @@ -3767,6 +3769,8 @@ static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags)
2977     io->offset = 0;
2978     io->size = 0;
2979     io->page = NULL;
2980     + io->iocb = NULL;
2981     + io->result = 0;
2982     INIT_WORK(&io->work, ext4_end_io_work);
2983     INIT_LIST_HEAD(&io->list);
2984     }
2985     @@ -3775,7 +3779,8 @@ static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags)
2986     }
2987    
2988     static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
2989     - ssize_t size, void *private)
2990     + ssize_t size, void *private, int ret,
2991     + bool is_async)
2992     {
2993     ext4_io_end_t *io_end = iocb->private;
2994     struct workqueue_struct *wq;
2995     @@ -3784,7 +3789,7 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
2996    
2997     /* if not async direct IO or dio with 0 bytes write, just return */
2998     if (!io_end || !size)
2999     - return;
3000     + goto out;
3001    
3002     ext_debug("ext4_end_io_dio(): io_end 0x%p"
3003     "for inode %lu, iocb 0x%p, offset %llu, size %llu\n",
3004     @@ -3795,12 +3800,18 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3005     if (io_end->flag != EXT4_IO_UNWRITTEN){
3006     ext4_free_io_end(io_end);
3007     iocb->private = NULL;
3008     +out:
3009     + if (is_async)
3010     + aio_complete(iocb, ret, 0);
3011     return;
3012     }
3013    
3014     io_end->offset = offset;
3015     io_end->size = size;
3016     - io_end->flag = EXT4_IO_UNWRITTEN;
3017     + if (is_async) {
3018     + io_end->iocb = iocb;
3019     + io_end->result = ret;
3020     + }
3021     wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq;
3022    
3023     /* queue the work to convert unwritten extents to written */
3024     diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
3025     index 9424796..e5cdabf 100644
3026     --- a/fs/fuse/dev.c
3027     +++ b/fs/fuse/dev.c
3028     @@ -1552,6 +1552,14 @@ __acquires(&fc->lock)
3029     }
3030     }
3031    
3032     +static void end_queued_requests(struct fuse_conn *fc)
3033     +{
3034     + fc->max_background = UINT_MAX;
3035     + flush_bg_queue(fc);
3036     + end_requests(fc, &fc->pending);
3037     + end_requests(fc, &fc->processing);
3038     +}
3039     +
3040     /*
3041     * Abort all requests.
3042     *
3043     @@ -1578,8 +1586,7 @@ void fuse_abort_conn(struct fuse_conn *fc)
3044     fc->connected = 0;
3045     fc->blocked = 0;
3046     end_io_requests(fc);
3047     - end_requests(fc, &fc->pending);
3048     - end_requests(fc, &fc->processing);
3049     + end_queued_requests(fc);
3050     wake_up_all(&fc->waitq);
3051     wake_up_all(&fc->blocked_waitq);
3052     kill_fasync(&fc->fasync, SIGIO, POLL_IN);
3053     @@ -1594,8 +1601,9 @@ int fuse_dev_release(struct inode *inode, struct file *file)
3054     if (fc) {
3055     spin_lock(&fc->lock);
3056     fc->connected = 0;
3057     - end_requests(fc, &fc->pending);
3058     - end_requests(fc, &fc->processing);
3059     + fc->blocked = 0;
3060     + end_queued_requests(fc);
3061     + wake_up_all(&fc->blocked_waitq);
3062     spin_unlock(&fc->lock);
3063     fuse_conn_put(fc);
3064     }
3065     diff --git a/fs/minix/namei.c b/fs/minix/namei.c
3066     index e20ee85..f3f3578 100644
3067     --- a/fs/minix/namei.c
3068     +++ b/fs/minix/namei.c
3069     @@ -115,7 +115,7 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
3070    
3071     inode_inc_link_count(dir);
3072    
3073     - inode = minix_new_inode(dir, mode, &err);
3074     + inode = minix_new_inode(dir, S_IFDIR | mode, &err);
3075     if (!inode)
3076     goto out_dir;
3077    
3078     diff --git a/fs/nfs/client.c b/fs/nfs/client.c
3079     index d25b525..e006770 100644
3080     --- a/fs/nfs/client.c
3081     +++ b/fs/nfs/client.c
3082     @@ -274,7 +274,7 @@ static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
3083     sin1->sin6_scope_id != sin2->sin6_scope_id)
3084     return 0;
3085    
3086     - return ipv6_addr_equal(&sin1->sin6_addr, &sin1->sin6_addr);
3087     + return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
3088     }
3089     #else /* !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) */
3090     static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
3091     diff --git a/fs/nfs/super.c b/fs/nfs/super.c
3092     index 6bf11d7..381d929 100644
3093     --- a/fs/nfs/super.c
3094     +++ b/fs/nfs/super.c
3095     @@ -431,7 +431,15 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3096     goto out_err;
3097    
3098     error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
3099     + if (unlikely(error == -ESTALE)) {
3100     + struct dentry *pd_dentry;
3101    
3102     + pd_dentry = dget_parent(dentry);
3103     + if (pd_dentry != NULL) {
3104     + nfs_zap_caches(pd_dentry->d_inode);
3105     + dput(pd_dentry);
3106     + }
3107     + }
3108     nfs_free_fattr(res.fattr);
3109     if (error < 0)
3110     goto out_err;
3111     diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
3112     index 356e976..96337a4 100644
3113     --- a/fs/ocfs2/aops.c
3114     +++ b/fs/ocfs2/aops.c
3115     @@ -578,7 +578,9 @@ bail:
3116     static void ocfs2_dio_end_io(struct kiocb *iocb,
3117     loff_t offset,
3118     ssize_t bytes,
3119     - void *private)
3120     + void *private,
3121     + int ret,
3122     + bool is_async)
3123     {
3124     struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
3125     int level;
3126     @@ -592,6 +594,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
3127     if (!level)
3128     up_read(&inode->i_alloc_sem);
3129     ocfs2_rw_unlock(inode, level);
3130     +
3131     + if (is_async)
3132     + aio_complete(iocb, ret, 0);
3133     }
3134    
3135     /*
3136     diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
3137     index abb0a95..201e7bc 100644
3138     --- a/fs/ocfs2/inode.c
3139     +++ b/fs/ocfs2/inode.c
3140     @@ -488,7 +488,11 @@ static int ocfs2_read_locked_inode(struct inode *inode,
3141     OCFS2_BH_IGNORE_CACHE);
3142     } else {
3143     status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh);
3144     - if (!status)
3145     + /*
3146     + * If buffer is in jbd, then its checksum may not have been
3147     + * computed as yet.
3148     + */
3149     + if (!status && !buffer_jbd(bh))
3150     status = ocfs2_validate_inode_block(osb->sb, bh);
3151     }
3152     if (status < 0) {
3153     diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
3154     index 1beaa73..cd79684 100644
3155     --- a/fs/sysfs/file.c
3156     +++ b/fs/sysfs/file.c
3157     @@ -340,7 +340,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
3158     char *p;
3159    
3160     p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
3161     - if (p)
3162     + if (!IS_ERR(p))
3163     memmove(last_sysfs_file, p, strlen(p) + 1);
3164    
3165     /* need attr_sd for attr and ops, its parent for kobj */
3166     diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
3167     index 34640d6..f9f5567 100644
3168     --- a/fs/xfs/linux-2.6/xfs_aops.c
3169     +++ b/fs/xfs/linux-2.6/xfs_aops.c
3170     @@ -275,8 +275,11 @@ xfs_end_io(
3171     xfs_finish_ioend(ioend, 0);
3172     /* ensure we don't spin on blocked ioends */
3173     delay(1);
3174     - } else
3175     + } else {
3176     + if (ioend->io_iocb)
3177     + aio_complete(ioend->io_iocb, ioend->io_result, 0);
3178     xfs_destroy_ioend(ioend);
3179     + }
3180     }
3181    
3182     /*
3183     @@ -309,6 +312,8 @@ xfs_alloc_ioend(
3184     atomic_inc(&XFS_I(ioend->io_inode)->i_iocount);
3185     ioend->io_offset = 0;
3186     ioend->io_size = 0;
3187     + ioend->io_iocb = NULL;
3188     + ioend->io_result = 0;
3189    
3190     INIT_WORK(&ioend->io_work, xfs_end_io);
3191     return ioend;
3192     @@ -1599,9 +1604,12 @@ xfs_end_io_direct(
3193     struct kiocb *iocb,
3194     loff_t offset,
3195     ssize_t size,
3196     - void *private)
3197     + void *private,
3198     + int ret,
3199     + bool is_async)
3200     {
3201     xfs_ioend_t *ioend = iocb->private;
3202     + bool complete_aio = is_async;
3203    
3204     /*
3205     * Non-NULL private data means we need to issue a transaction to
3206     @@ -1627,7 +1635,14 @@ xfs_end_io_direct(
3207     if (ioend->io_type == IO_READ) {
3208     xfs_finish_ioend(ioend, 0);
3209     } else if (private && size > 0) {
3210     - xfs_finish_ioend(ioend, is_sync_kiocb(iocb));
3211     + if (is_async) {
3212     + ioend->io_iocb = iocb;
3213     + ioend->io_result = ret;
3214     + complete_aio = false;
3215     + xfs_finish_ioend(ioend, 0);
3216     + } else {
3217     + xfs_finish_ioend(ioend, 1);
3218     + }
3219     } else {
3220     /*
3221     * A direct I/O write ioend starts it's life in unwritten
3222     @@ -1645,6 +1660,9 @@ xfs_end_io_direct(
3223     * against double-freeing.
3224     */
3225     iocb->private = NULL;
3226     +
3227     + if (complete_aio)
3228     + aio_complete(iocb, ret, 0);
3229     }
3230    
3231     STATIC ssize_t
3232     diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
3233     index 4cfc6ea..9f566d9 100644
3234     --- a/fs/xfs/linux-2.6/xfs_aops.h
3235     +++ b/fs/xfs/linux-2.6/xfs_aops.h
3236     @@ -37,6 +37,8 @@ typedef struct xfs_ioend {
3237     size_t io_size; /* size of the extent */
3238     xfs_off_t io_offset; /* offset in the file */
3239     struct work_struct io_work; /* xfsdatad work queue */
3240     + struct kiocb *io_iocb;
3241     + int io_result;
3242     } xfs_ioend_t;
3243    
3244     extern const struct address_space_operations xfs_address_space_operations;
3245     diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
3246     index c7142a0..eb779af 100644
3247     --- a/fs/xfs/xfs_ialloc.c
3248     +++ b/fs/xfs/xfs_ialloc.c
3249     @@ -1217,7 +1217,6 @@ xfs_imap_lookup(
3250     struct xfs_inobt_rec_incore rec;
3251     struct xfs_btree_cur *cur;
3252     struct xfs_buf *agbp;
3253     - xfs_agino_t startino;
3254     int error;
3255     int i;
3256    
3257     @@ -1231,13 +1230,13 @@ xfs_imap_lookup(
3258     }
3259    
3260     /*
3261     - * derive and lookup the exact inode record for the given agino. If the
3262     - * record cannot be found, then it's an invalid inode number and we
3263     - * should abort.
3264     + * Lookup the inode record for the given agino. If the record cannot be
3265     + * found, then it's an invalid inode number and we should abort. Once
3266     + * we have a record, we need to ensure it contains the inode number
3267     + * we are looking up.
3268     */
3269     cur = xfs_inobt_init_cursor(mp, tp, agbp, agno);
3270     - startino = agino & ~(XFS_IALLOC_INODES(mp) - 1);
3271     - error = xfs_inobt_lookup(cur, startino, XFS_LOOKUP_EQ, &i);
3272     + error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i);
3273     if (!error) {
3274     if (i)
3275     error = xfs_inobt_get_rec(cur, &rec, &i);
3276     @@ -1250,6 +1249,11 @@ xfs_imap_lookup(
3277     if (error)
3278     return error;
3279    
3280     + /* check that the returned record contains the required inode */
3281     + if (rec.ir_startino > agino ||
3282     + rec.ir_startino + XFS_IALLOC_INODES(mp) <= agino)
3283     + return EINVAL;
3284     +
3285     /* for untrusted inodes check it is allocated first */
3286     if ((flags & XFS_IGET_UNTRUSTED) &&
3287     (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
3288     diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
3289     index b76a829..f702218 100644
3290     --- a/fs/xfs/xfs_inode.c
3291     +++ b/fs/xfs/xfs_inode.c
3292     @@ -1927,6 +1927,11 @@ xfs_iunlink_remove(
3293     return 0;
3294     }
3295    
3296     +/*
3297     + * A big issue when freeing the inode cluster is is that we _cannot_ skip any
3298     + * inodes that are in memory - they all must be marked stale and attached to
3299     + * the cluster buffer.
3300     + */
3301     STATIC void
3302     xfs_ifree_cluster(
3303     xfs_inode_t *free_ip,
3304     @@ -1958,8 +1963,6 @@ xfs_ifree_cluster(
3305     }
3306    
3307     for (j = 0; j < nbufs; j++, inum += ninodes) {
3308     - int found = 0;
3309     -
3310     blkno = XFS_AGB_TO_DADDR(mp, XFS_INO_TO_AGNO(mp, inum),
3311     XFS_INO_TO_AGBNO(mp, inum));
3312    
3313     @@ -1978,7 +1981,9 @@ xfs_ifree_cluster(
3314     /*
3315     * Walk the inodes already attached to the buffer and mark them
3316     * stale. These will all have the flush locks held, so an
3317     - * in-memory inode walk can't lock them.
3318     + * in-memory inode walk can't lock them. By marking them all
3319     + * stale first, we will not attempt to lock them in the loop
3320     + * below as the XFS_ISTALE flag will be set.
3321     */
3322     lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
3323     while (lip) {
3324     @@ -1990,11 +1995,11 @@ xfs_ifree_cluster(
3325     &iip->ili_flush_lsn,
3326     &iip->ili_item.li_lsn);
3327     xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
3328     - found++;
3329     }
3330     lip = lip->li_bio_list;
3331     }
3332    
3333     +
3334     /*
3335     * For each inode in memory attempt to add it to the inode
3336     * buffer and set it up for being staled on buffer IO
3337     @@ -2006,6 +2011,7 @@ xfs_ifree_cluster(
3338     * even trying to lock them.
3339     */
3340     for (i = 0; i < ninodes; i++) {
3341     +retry:
3342     read_lock(&pag->pag_ici_lock);
3343     ip = radix_tree_lookup(&pag->pag_ici_root,
3344     XFS_INO_TO_AGINO(mp, (inum + i)));
3345     @@ -2016,38 +2022,36 @@ xfs_ifree_cluster(
3346     continue;
3347     }
3348    
3349     - /* don't try to lock/unlock the current inode */
3350     + /*
3351     + * Don't try to lock/unlock the current inode, but we
3352     + * _cannot_ skip the other inodes that we did not find
3353     + * in the list attached to the buffer and are not
3354     + * already marked stale. If we can't lock it, back off
3355     + * and retry.
3356     + */
3357     if (ip != free_ip &&
3358     !xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
3359     read_unlock(&pag->pag_ici_lock);
3360     - continue;
3361     + delay(1);
3362     + goto retry;
3363     }
3364     read_unlock(&pag->pag_ici_lock);
3365    
3366     - if (!xfs_iflock_nowait(ip)) {
3367     - if (ip != free_ip)
3368     - xfs_iunlock(ip, XFS_ILOCK_EXCL);
3369     - continue;
3370     - }
3371     -
3372     + xfs_iflock(ip);
3373     xfs_iflags_set(ip, XFS_ISTALE);
3374     - if (xfs_inode_clean(ip)) {
3375     - ASSERT(ip != free_ip);
3376     - xfs_ifunlock(ip);
3377     - xfs_iunlock(ip, XFS_ILOCK_EXCL);
3378     - continue;
3379     - }
3380    
3381     + /*
3382     + * we don't need to attach clean inodes or those only
3383     + * with unlogged changes (which we throw away, anyway).
3384     + */
3385     iip = ip->i_itemp;
3386     - if (!iip) {
3387     - /* inode with unlogged changes only */
3388     + if (!iip || xfs_inode_clean(ip)) {
3389     ASSERT(ip != free_ip);
3390     ip->i_update_core = 0;
3391     xfs_ifunlock(ip);
3392     xfs_iunlock(ip, XFS_ILOCK_EXCL);
3393     continue;
3394     }
3395     - found++;
3396    
3397     iip->ili_last_fields = iip->ili_format.ilf_fields;
3398     iip->ili_format.ilf_fields = 0;
3399     @@ -2063,8 +2067,7 @@ xfs_ifree_cluster(
3400     xfs_iunlock(ip, XFS_ILOCK_EXCL);
3401     }
3402    
3403     - if (found)
3404     - xfs_trans_stale_inode_buf(tp, bp);
3405     + xfs_trans_stale_inode_buf(tp, bp);
3406     xfs_trans_binval(tp, bp);
3407     }
3408    
3409     diff --git a/include/linux/compat.h b/include/linux/compat.h
3410     index 168f7da..c766441 100644
3411     --- a/include/linux/compat.h
3412     +++ b/include/linux/compat.h
3413     @@ -360,5 +360,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
3414     const struct compat_iovec __user *uvector, unsigned long nr_segs,
3415     unsigned long fast_segs, struct iovec *fast_pointer,
3416     struct iovec **ret_pointer);
3417     +
3418     +extern void __user *compat_alloc_user_space(unsigned long len);
3419     +
3420     #endif /* CONFIG_COMPAT */
3421     #endif /* _LINUX_COMPAT_H */
3422     diff --git a/include/linux/fs.h b/include/linux/fs.h
3423     index f0f447a..509ca14 100644
3424     --- a/include/linux/fs.h
3425     +++ b/include/linux/fs.h
3426     @@ -416,7 +416,8 @@ struct buffer_head;
3427     typedef int (get_block_t)(struct inode *inode, sector_t iblock,
3428     struct buffer_head *bh_result, int create);
3429     typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
3430     - ssize_t bytes, void *private);
3431     + ssize_t bytes, void *private, int ret,
3432     + bool is_async);
3433    
3434     /*
3435     * Attribute flags. These should be or-ed together to figure out what
3436     diff --git a/include/linux/libata.h b/include/linux/libata.h
3437     index b85f3ff..8a9b4cf 100644
3438     --- a/include/linux/libata.h
3439     +++ b/include/linux/libata.h
3440     @@ -335,6 +335,7 @@ enum {
3441     ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
3442     ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
3443     ATA_EHI_QUIET = (1 << 3), /* be quiet */
3444     + ATA_EHI_NO_RECOVERY = (1 << 4), /* no recovery */
3445    
3446     ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */
3447     ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
3448     diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
3449     index f65913c..513ff03 100644
3450     --- a/include/linux/mmc/host.h
3451     +++ b/include/linux/mmc/host.h
3452     @@ -124,6 +124,7 @@ struct mmc_host {
3453     unsigned int f_min;
3454     unsigned int f_max;
3455     u32 ocr_avail;
3456     + struct notifier_block pm_notify;
3457    
3458     #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
3459     #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
3460     @@ -183,6 +184,7 @@ struct mmc_host {
3461    
3462     /* Only used with MMC_CAP_DISABLE */
3463     int enabled; /* host is enabled */
3464     + int rescan_disable; /* disable card detection */
3465     int nesting_cnt; /* "enable" nesting count */
3466     int en_dis_recurs; /* detect recursion */
3467     unsigned int disable_delay; /* disable delay in msecs */
3468     @@ -257,6 +259,7 @@ int mmc_card_can_sleep(struct mmc_host *host);
3469     int mmc_host_enable(struct mmc_host *host);
3470     int mmc_host_disable(struct mmc_host *host);
3471     int mmc_host_lazy_disable(struct mmc_host *host);
3472     +int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *);
3473    
3474     static inline void mmc_set_disable_delay(struct mmc_host *host,
3475     unsigned int disable_delay)
3476     diff --git a/include/linux/msi.h b/include/linux/msi.h
3477     index 6991ab5..91b05c1 100644
3478     --- a/include/linux/msi.h
3479     +++ b/include/linux/msi.h
3480     @@ -14,8 +14,10 @@ struct irq_desc;
3481     extern void mask_msi_irq(unsigned int irq);
3482     extern void unmask_msi_irq(unsigned int irq);
3483     extern void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg);
3484     +extern void get_cached_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg);
3485     extern void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg);
3486     extern void read_msi_msg(unsigned int irq, struct msi_msg *msg);
3487     +extern void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
3488     extern void write_msi_msg(unsigned int irq, struct msi_msg *msg);
3489    
3490     struct msi_desc {
3491     diff --git a/include/linux/swap.h b/include/linux/swap.h
3492     index ff4acea..11c1e47 100644
3493     --- a/include/linux/swap.h
3494     +++ b/include/linux/swap.h
3495     @@ -19,6 +19,7 @@ struct bio;
3496     #define SWAP_FLAG_PREFER 0x8000 /* set if swap priority specified */
3497     #define SWAP_FLAG_PRIO_MASK 0x7fff
3498     #define SWAP_FLAG_PRIO_SHIFT 0
3499     +#define SWAP_FLAG_DISCARD 0x10000 /* discard swap cluster after use */
3500    
3501     static inline int current_is_kswapd(void)
3502     {
3503     @@ -142,7 +143,7 @@ struct swap_extent {
3504     enum {
3505     SWP_USED = (1 << 0), /* is slot in swap_info[] used? */
3506     SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */
3507     - SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */
3508     + SWP_DISCARDABLE = (1 << 2), /* swapon+blkdev support discard */
3509     SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */
3510     SWP_SOLIDSTATE = (1 << 4), /* blkdev seeks are cheap */
3511     SWP_CONTINUED = (1 << 5), /* swap_map has count continuation */
3512     diff --git a/kernel/compat.c b/kernel/compat.c
3513     index 5adab05..91b33fb 100644
3514     --- a/kernel/compat.c
3515     +++ b/kernel/compat.c
3516     @@ -1137,3 +1137,24 @@ compat_sys_sysinfo(struct compat_sysinfo __user *info)
3517    
3518     return 0;
3519     }
3520     +
3521     +/*
3522     + * Allocate user-space memory for the duration of a single system call,
3523     + * in order to marshall parameters inside a compat thunk.
3524     + */
3525     +void __user *compat_alloc_user_space(unsigned long len)
3526     +{
3527     + void __user *ptr;
3528     +
3529     + /* If len would occupy more than half of the entire compat space... */
3530     + if (unlikely(len > (((compat_uptr_t)~0) >> 1)))
3531     + return NULL;
3532     +
3533     + ptr = arch_compat_alloc_user_space(len);
3534     +
3535     + if (unlikely(!access_ok(VERIFY_WRITE, ptr, len)))
3536     + return NULL;
3537     +
3538     + return ptr;
3539     +}
3540     +EXPORT_SYMBOL_GPL(compat_alloc_user_space);
3541     diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
3542     index ef3c3f8..f83972b 100644
3543     --- a/kernel/gcov/fs.c
3544     +++ b/kernel/gcov/fs.c
3545     @@ -33,10 +33,11 @@
3546     * @children: child nodes
3547     * @all: list head for list of all nodes
3548     * @parent: parent node
3549     - * @info: associated profiling data structure if not a directory
3550     - * @ghost: when an object file containing profiling data is unloaded we keep a
3551     - * copy of the profiling data here to allow collecting coverage data
3552     - * for cleanup code. Such a node is called a "ghost".
3553     + * @loaded_info: array of pointers to profiling data sets for loaded object
3554     + * files.
3555     + * @num_loaded: number of profiling data sets for loaded object files.
3556     + * @unloaded_info: accumulated copy of profiling data sets for unloaded
3557     + * object files. Used only when gcov_persist=1.
3558     * @dentry: main debugfs entry, either a directory or data file
3559     * @links: associated symbolic links
3560     * @name: data file basename
3561     @@ -51,10 +52,11 @@ struct gcov_node {
3562     struct list_head children;
3563     struct list_head all;
3564     struct gcov_node *parent;
3565     - struct gcov_info *info;
3566     - struct gcov_info *ghost;
3567     + struct gcov_info **loaded_info;
3568     + struct gcov_info *unloaded_info;
3569     struct dentry *dentry;
3570     struct dentry **links;
3571     + int num_loaded;
3572     char name[0];
3573     };
3574    
3575     @@ -136,16 +138,37 @@ static const struct seq_operations gcov_seq_ops = {
3576     };
3577    
3578     /*
3579     - * Return the profiling data set for a given node. This can either be the
3580     - * original profiling data structure or a duplicate (also called "ghost")
3581     - * in case the associated object file has been unloaded.
3582     + * Return a profiling data set associated with the given node. This is
3583     + * either a data set for a loaded object file or a data set copy in case
3584     + * all associated object files have been unloaded.
3585     */
3586     static struct gcov_info *get_node_info(struct gcov_node *node)
3587     {
3588     - if (node->info)
3589     - return node->info;
3590     + if (node->num_loaded > 0)
3591     + return node->loaded_info[0];
3592    
3593     - return node->ghost;
3594     + return node->unloaded_info;
3595     +}
3596     +
3597     +/*
3598     + * Return a newly allocated profiling data set which contains the sum of
3599     + * all profiling data associated with the given node.
3600     + */
3601     +static struct gcov_info *get_accumulated_info(struct gcov_node *node)
3602     +{
3603     + struct gcov_info *info;
3604     + int i = 0;
3605     +
3606     + if (node->unloaded_info)
3607     + info = gcov_info_dup(node->unloaded_info);
3608     + else
3609     + info = gcov_info_dup(node->loaded_info[i++]);
3610     + if (!info)
3611     + return NULL;
3612     + for (; i < node->num_loaded; i++)
3613     + gcov_info_add(info, node->loaded_info[i]);
3614     +
3615     + return info;
3616     }
3617    
3618     /*
3619     @@ -163,9 +186,10 @@ static int gcov_seq_open(struct inode *inode, struct file *file)
3620     mutex_lock(&node_lock);
3621     /*
3622     * Read from a profiling data copy to minimize reference tracking
3623     - * complexity and concurrent access.
3624     + * complexity and concurrent access and to keep accumulating multiple
3625     + * profiling data sets associated with one node simple.
3626     */
3627     - info = gcov_info_dup(get_node_info(node));
3628     + info = get_accumulated_info(node);
3629     if (!info)
3630     goto out_unlock;
3631     iter = gcov_iter_new(info);
3632     @@ -225,12 +249,25 @@ static struct gcov_node *get_node_by_name(const char *name)
3633     return NULL;
3634     }
3635    
3636     +/*
3637     + * Reset all profiling data associated with the specified node.
3638     + */
3639     +static void reset_node(struct gcov_node *node)
3640     +{
3641     + int i;
3642     +
3643     + if (node->unloaded_info)
3644     + gcov_info_reset(node->unloaded_info);
3645     + for (i = 0; i < node->num_loaded; i++)
3646     + gcov_info_reset(node->loaded_info[i]);
3647     +}
3648     +
3649     static void remove_node(struct gcov_node *node);
3650    
3651     /*
3652     * write() implementation for gcov data files. Reset profiling data for the
3653     - * associated file. If the object file has been unloaded (i.e. this is
3654     - * a "ghost" node), remove the debug fs node as well.
3655     + * corresponding file. If all associated object files have been unloaded,
3656     + * remove the debug fs node as well.
3657     */
3658     static ssize_t gcov_seq_write(struct file *file, const char __user *addr,
3659     size_t len, loff_t *pos)
3660     @@ -245,10 +282,10 @@ static ssize_t gcov_seq_write(struct file *file, const char __user *addr,
3661     node = get_node_by_name(info->filename);
3662     if (node) {
3663     /* Reset counts or remove node for unloaded modules. */
3664     - if (node->ghost)
3665     + if (node->num_loaded == 0)
3666     remove_node(node);
3667     else
3668     - gcov_info_reset(node->info);
3669     + reset_node(node);
3670     }
3671     /* Reset counts for open file. */
3672     gcov_info_reset(info);
3673     @@ -378,7 +415,10 @@ static void init_node(struct gcov_node *node, struct gcov_info *info,
3674     INIT_LIST_HEAD(&node->list);
3675     INIT_LIST_HEAD(&node->children);
3676     INIT_LIST_HEAD(&node->all);
3677     - node->info = info;
3678     + if (node->loaded_info) {
3679     + node->loaded_info[0] = info;
3680     + node->num_loaded = 1;
3681     + }
3682     node->parent = parent;
3683     if (name)
3684     strcpy(node->name, name);
3685     @@ -394,9 +434,13 @@ static struct gcov_node *new_node(struct gcov_node *parent,
3686     struct gcov_node *node;
3687    
3688     node = kzalloc(sizeof(struct gcov_node) + strlen(name) + 1, GFP_KERNEL);
3689     - if (!node) {
3690     - pr_warning("out of memory\n");
3691     - return NULL;
3692     + if (!node)
3693     + goto err_nomem;
3694     + if (info) {
3695     + node->loaded_info = kcalloc(1, sizeof(struct gcov_info *),
3696     + GFP_KERNEL);
3697     + if (!node->loaded_info)
3698     + goto err_nomem;
3699     }
3700     init_node(node, info, name, parent);
3701     /* Differentiate between gcov data file nodes and directory nodes. */
3702     @@ -416,6 +460,11 @@ static struct gcov_node *new_node(struct gcov_node *parent,
3703     list_add(&node->all, &all_head);
3704    
3705     return node;
3706     +
3707     +err_nomem:
3708     + kfree(node);
3709     + pr_warning("out of memory\n");
3710     + return NULL;
3711     }
3712    
3713     /* Remove symbolic links associated with node. */
3714     @@ -441,8 +490,9 @@ static void release_node(struct gcov_node *node)
3715     list_del(&node->all);
3716     debugfs_remove(node->dentry);
3717     remove_links(node);
3718     - if (node->ghost)
3719     - gcov_info_free(node->ghost);
3720     + kfree(node->loaded_info);
3721     + if (node->unloaded_info)
3722     + gcov_info_free(node->unloaded_info);
3723     kfree(node);
3724     }
3725    
3726     @@ -477,7 +527,7 @@ static struct gcov_node *get_child_by_name(struct gcov_node *parent,
3727    
3728     /*
3729     * write() implementation for reset file. Reset all profiling data to zero
3730     - * and remove ghost nodes.
3731     + * and remove nodes for which all associated object files are unloaded.
3732     */
3733     static ssize_t reset_write(struct file *file, const char __user *addr,
3734     size_t len, loff_t *pos)
3735     @@ -487,8 +537,8 @@ static ssize_t reset_write(struct file *file, const char __user *addr,
3736     mutex_lock(&node_lock);
3737     restart:
3738     list_for_each_entry(node, &all_head, all) {
3739     - if (node->info)
3740     - gcov_info_reset(node->info);
3741     + if (node->num_loaded > 0)
3742     + reset_node(node);
3743     else if (list_empty(&node->children)) {
3744     remove_node(node);
3745     /* Several nodes may have gone - restart loop. */
3746     @@ -564,37 +614,115 @@ err_remove:
3747     }
3748    
3749     /*
3750     - * The profiling data set associated with this node is being unloaded. Store a
3751     - * copy of the profiling data and turn this node into a "ghost".
3752     + * Associate a profiling data set with an existing node. Needs to be called
3753     + * with node_lock held.
3754     */
3755     -static int ghost_node(struct gcov_node *node)
3756     +static void add_info(struct gcov_node *node, struct gcov_info *info)
3757     {
3758     - node->ghost = gcov_info_dup(node->info);
3759     - if (!node->ghost) {
3760     - pr_warning("could not save data for '%s' (out of memory)\n",
3761     - node->info->filename);
3762     - return -ENOMEM;
3763     + struct gcov_info **loaded_info;
3764     + int num = node->num_loaded;
3765     +
3766     + /*
3767     + * Prepare new array. This is done first to simplify cleanup in
3768     + * case the new data set is incompatible, the node only contains
3769     + * unloaded data sets and there's not enough memory for the array.
3770     + */
3771     + loaded_info = kcalloc(num + 1, sizeof(struct gcov_info *), GFP_KERNEL);
3772     + if (!loaded_info) {
3773     + pr_warning("could not add '%s' (out of memory)\n",
3774     + info->filename);
3775     + return;
3776     + }
3777     + memcpy(loaded_info, node->loaded_info,
3778     + num * sizeof(struct gcov_info *));
3779     + loaded_info[num] = info;
3780     + /* Check if the new data set is compatible. */
3781     + if (num == 0) {
3782     + /*
3783     + * A module was unloaded, modified and reloaded. The new
3784     + * data set replaces the copy of the last one.
3785     + */
3786     + if (!gcov_info_is_compatible(node->unloaded_info, info)) {
3787     + pr_warning("discarding saved data for %s "
3788     + "(incompatible version)\n", info->filename);
3789     + gcov_info_free(node->unloaded_info);
3790     + node->unloaded_info = NULL;
3791     + }
3792     + } else {
3793     + /*
3794     + * Two different versions of the same object file are loaded.
3795     + * The initial one takes precedence.
3796     + */
3797     + if (!gcov_info_is_compatible(node->loaded_info[0], info)) {
3798     + pr_warning("could not add '%s' (incompatible "
3799     + "version)\n", info->filename);
3800     + kfree(loaded_info);
3801     + return;
3802     + }
3803     }
3804     - node->info = NULL;
3805     + /* Overwrite previous array. */
3806     + kfree(node->loaded_info);
3807     + node->loaded_info = loaded_info;
3808     + node->num_loaded = num + 1;
3809     +}
3810    
3811     - return 0;
3812     +/*
3813     + * Return the index of a profiling data set associated with a node.
3814     + */
3815     +static int get_info_index(struct gcov_node *node, struct gcov_info *info)
3816     +{
3817     + int i;
3818     +
3819     + for (i = 0; i < node->num_loaded; i++) {
3820     + if (node->loaded_info[i] == info)
3821     + return i;
3822     + }
3823     + return -ENOENT;
3824     }
3825    
3826     /*
3827     - * Profiling data for this node has been loaded again. Add profiling data
3828     - * from previous instantiation and turn this node into a regular node.
3829     + * Save the data of a profiling data set which is being unloaded.
3830     */
3831     -static void revive_node(struct gcov_node *node, struct gcov_info *info)
3832     +static void save_info(struct gcov_node *node, struct gcov_info *info)
3833     {
3834     - if (gcov_info_is_compatible(node->ghost, info))
3835     - gcov_info_add(info, node->ghost);
3836     + if (node->unloaded_info)
3837     + gcov_info_add(node->unloaded_info, info);
3838     else {
3839     - pr_warning("discarding saved data for '%s' (version changed)\n",
3840     + node->unloaded_info = gcov_info_dup(info);
3841     + if (!node->unloaded_info) {
3842     + pr_warning("could not save data for '%s' "
3843     + "(out of memory)\n", info->filename);
3844     + }
3845     + }
3846     +}
3847     +
3848     +/*
3849     + * Disassociate a profiling data set from a node. Needs to be called with
3850     + * node_lock held.
3851     + */
3852     +static void remove_info(struct gcov_node *node, struct gcov_info *info)
3853     +{
3854     + int i;
3855     +
3856     + i = get_info_index(node, info);
3857     + if (i < 0) {
3858     + pr_warning("could not remove '%s' (not found)\n",
3859     info->filename);
3860     + return;
3861     }
3862     - gcov_info_free(node->ghost);
3863     - node->ghost = NULL;
3864     - node->info = info;
3865     + if (gcov_persist)
3866     + save_info(node, info);
3867     + /* Shrink array. */
3868     + node->loaded_info[i] = node->loaded_info[node->num_loaded - 1];
3869     + node->num_loaded--;
3870     + if (node->num_loaded > 0)
3871     + return;
3872     + /* Last loaded data set was removed. */
3873     + kfree(node->loaded_info);
3874     + node->loaded_info = NULL;
3875     + node->num_loaded = 0;
3876     + if (!node->unloaded_info)
3877     + remove_node(node);
3878     }
3879    
3880     /*
3881     @@ -609,30 +737,18 @@ void gcov_event(enum gcov_action action, struct gcov_info *info)
3882     node = get_node_by_name(info->filename);
3883     switch (action) {
3884     case GCOV_ADD:
3885     - /* Add new node or revive ghost. */
3886     - if (!node) {
3887     + if (node)
3888     + add_info(node, info);
3889     + else
3890     add_node(info);
3891     - break;
3892     - }
3893     - if (gcov_persist)
3894     - revive_node(node, info);
3895     - else {
3896     - pr_warning("could not add '%s' (already exists)\n",
3897     - info->filename);
3898     - }
3899     break;
3900     case GCOV_REMOVE:
3901     - /* Remove node or turn into ghost. */
3902     - if (!node) {
3903     + if (node)
3904     + remove_info(node, info);
3905     + else {
3906     pr_warning("could not remove '%s' (not found)\n",
3907     info->filename);
3908     - break;
3909     }
3910     - if (gcov_persist) {
3911     - if (!ghost_node(node))
3912     - break;
3913     - }
3914     - remove_node(node);
3915     break;
3916     }
3917     mutex_unlock(&node_lock);
3918     diff --git a/kernel/groups.c b/kernel/groups.c
3919     index 53b1916..253dc0f 100644
3920     --- a/kernel/groups.c
3921     +++ b/kernel/groups.c
3922     @@ -143,10 +143,9 @@ int groups_search(const struct group_info *group_info, gid_t grp)
3923     right = group_info->ngroups;
3924     while (left < right) {
3925     unsigned int mid = (left+right)/2;
3926     - int cmp = grp - GROUP_AT(group_info, mid);
3927     - if (cmp > 0)
3928     + if (grp > GROUP_AT(group_info, mid))
3929     left = mid + 1;
3930     - else if (cmp < 0)
3931     + else if (grp < GROUP_AT(group_info, mid))
3932     right = mid;
3933     else
3934     return 1;
3935     diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
3936     index 6d2cb14..6b316b3 100644
3937     --- a/kernel/trace/ftrace.c
3938     +++ b/kernel/trace/ftrace.c
3939     @@ -381,12 +381,19 @@ static int function_stat_show(struct seq_file *m, void *v)
3940     {
3941     struct ftrace_profile *rec = v;
3942     char str[KSYM_SYMBOL_LEN];
3943     + int ret = 0;
3944     #ifdef CONFIG_FUNCTION_GRAPH_TRACER
3945     - static DEFINE_MUTEX(mutex);
3946     static struct trace_seq s;
3947     unsigned long long avg;
3948     unsigned long long stddev;
3949     #endif
3950     + mutex_lock(&ftrace_profile_lock);
3951     +
3952     + /* we raced with function_profile_reset() */
3953     + if (unlikely(rec->counter == 0)) {
3954     + ret = -EBUSY;
3955     + goto out;
3956     + }
3957    
3958     kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
3959     seq_printf(m, " %-30.30s %10lu", str, rec->counter);
3960     @@ -408,7 +415,6 @@ static int function_stat_show(struct seq_file *m, void *v)
3961     do_div(stddev, (rec->counter - 1) * 1000);
3962     }
3963    
3964     - mutex_lock(&mutex);
3965     trace_seq_init(&s);
3966     trace_print_graph_duration(rec->time, &s);
3967     trace_seq_puts(&s, " ");
3968     @@ -416,11 +422,12 @@ static int function_stat_show(struct seq_file *m, void *v)
3969     trace_seq_puts(&s, " ");
3970     trace_print_graph_duration(stddev, &s);
3971     trace_print_seq(m, &s);
3972     - mutex_unlock(&mutex);
3973     #endif
3974     seq_putc(m, '\n');
3975     +out:
3976     + mutex_unlock(&ftrace_profile_lock);
3977    
3978     - return 0;
3979     + return ret;
3980     }
3981    
3982     static void ftrace_profile_reset(struct ftrace_profile_stat *stat)
3983     @@ -1503,6 +1510,8 @@ static void *t_start(struct seq_file *m, loff_t *pos)
3984     if (*pos > 0)
3985     return t_hash_start(m, pos);
3986     iter->flags |= FTRACE_ITER_PRINTALL;
3987     + /* reset in case of seek/pread */
3988     + iter->flags &= ~FTRACE_ITER_HASH;
3989     return iter;
3990     }
3991    
3992     @@ -2410,7 +2419,7 @@ static const struct file_operations ftrace_filter_fops = {
3993     .open = ftrace_filter_open,
3994     .read = seq_read,
3995     .write = ftrace_filter_write,
3996     - .llseek = ftrace_regex_lseek,
3997     + .llseek = no_llseek,
3998     .release = ftrace_filter_release,
3999     };
4000    
4001     diff --git a/mm/bounce.c b/mm/bounce.c
4002     index 13b6dad..1481de6 100644
4003     --- a/mm/bounce.c
4004     +++ b/mm/bounce.c
4005     @@ -116,8 +116,8 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
4006     */
4007     vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
4008    
4009     - flush_dcache_page(tovec->bv_page);
4010     bounce_copy_vec(tovec, vfrom);
4011     + flush_dcache_page(tovec->bv_page);
4012     }
4013     }
4014    
4015     diff --git a/mm/compaction.c b/mm/compaction.c
4016     index 94cce51..4d709ee 100644
4017     --- a/mm/compaction.c
4018     +++ b/mm/compaction.c
4019     @@ -214,15 +214,16 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc)
4020     /* Similar to reclaim, but different enough that they don't share logic */
4021     static bool too_many_isolated(struct zone *zone)
4022     {
4023     -
4024     - unsigned long inactive, isolated;
4025     + unsigned long active, inactive, isolated;
4026    
4027     inactive = zone_page_state(zone, NR_INACTIVE_FILE) +
4028     zone_page_state(zone, NR_INACTIVE_ANON);
4029     + active = zone_page_state(zone, NR_ACTIVE_FILE) +
4030     + zone_page_state(zone, NR_ACTIVE_ANON);
4031     isolated = zone_page_state(zone, NR_ISOLATED_FILE) +
4032     zone_page_state(zone, NR_ISOLATED_ANON);
4033    
4034     - return isolated > inactive;
4035     + return isolated > (inactive + active) / 2;
4036     }
4037    
4038     /*
4039     diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
4040     index a4cfcdc..dd186c1 100644
4041     --- a/mm/memory_hotplug.c
4042     +++ b/mm/memory_hotplug.c
4043     @@ -584,19 +584,19 @@ static inline int pageblock_free(struct page *page)
4044     /* Return the start of the next active pageblock after a given page */
4045     static struct page *next_active_pageblock(struct page *page)
4046     {
4047     - int pageblocks_stride;
4048     -
4049     /* Ensure the starting page is pageblock-aligned */
4050     BUG_ON(page_to_pfn(page) & (pageblock_nr_pages - 1));
4051    
4052     - /* Move forward by at least 1 * pageblock_nr_pages */
4053     - pageblocks_stride = 1;
4054     -
4055     /* If the entire pageblock is free, move to the end of free page */
4056     - if (pageblock_free(page))
4057     - pageblocks_stride += page_order(page) - pageblock_order;
4058     + if (pageblock_free(page)) {
4059     + int order;
4060     + /* be careful. we don't have locks, page_order can be changed.*/
4061     + order = page_order(page);
4062     + if ((order < MAX_ORDER) && (order >= pageblock_order))
4063     + return page + (1 << order);
4064     + }
4065    
4066     - return page + (pageblocks_stride * pageblock_nr_pages);
4067     + return page + pageblock_nr_pages;
4068     }
4069    
4070     /* Checks if this range of memory is likely to be hot-removable. */
4071     diff --git a/mm/page-writeback.c b/mm/page-writeback.c
4072     index 37498ef..582cba1 100644
4073     --- a/mm/page-writeback.c
4074     +++ b/mm/page-writeback.c
4075     @@ -949,22 +949,16 @@ continue_unlock:
4076     }
4077     }
4078    
4079     - if (wbc->nr_to_write > 0) {
4080     - if (--wbc->nr_to_write == 0 &&
4081     - wbc->sync_mode == WB_SYNC_NONE) {
4082     - /*
4083     - * We stop writing back only if we are
4084     - * not doing integrity sync. In case of
4085     - * integrity sync we have to keep going
4086     - * because someone may be concurrently
4087     - * dirtying pages, and we might have
4088     - * synced a lot of newly appeared dirty
4089     - * pages, but have not synced all of the
4090     - * old dirty pages.
4091     - */
4092     - done = 1;
4093     - break;
4094     - }
4095     + /*
4096     + * We stop writing back only if we are not doing
4097     + * integrity sync. In case of integrity sync we have to
4098     + * keep going until we have written all the pages
4099     + * we tagged for writeback prior to entering this loop.
4100     + */
4101     + if (--wbc->nr_to_write <= 0 &&
4102     + wbc->sync_mode == WB_SYNC_NONE) {
4103     + done = 1;
4104     + break;
4105     }
4106     }
4107     pagevec_release(&pvec);
4108     diff --git a/mm/swapfile.c b/mm/swapfile.c
4109     index f08d165..7c703ff 100644
4110     --- a/mm/swapfile.c
4111     +++ b/mm/swapfile.c
4112     @@ -139,8 +139,7 @@ static int discard_swap(struct swap_info_struct *si)
4113     nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9);
4114     if (nr_blocks) {
4115     err = blkdev_issue_discard(si->bdev, start_block,
4116     - nr_blocks, GFP_KERNEL,
4117     - BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
4118     + nr_blocks, GFP_KERNEL, BLKDEV_IFL_WAIT);
4119     if (err)
4120     return err;
4121     cond_resched();
4122     @@ -151,8 +150,7 @@ static int discard_swap(struct swap_info_struct *si)
4123     nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9);
4124    
4125     err = blkdev_issue_discard(si->bdev, start_block,
4126     - nr_blocks, GFP_KERNEL,
4127     - BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
4128     + nr_blocks, GFP_KERNEL, BLKDEV_IFL_WAIT);
4129     if (err)
4130     break;
4131    
4132     @@ -191,8 +189,7 @@ static void discard_swap_cluster(struct swap_info_struct *si,
4133     start_block <<= PAGE_SHIFT - 9;
4134     nr_blocks <<= PAGE_SHIFT - 9;
4135     if (blkdev_issue_discard(si->bdev, start_block,
4136     - nr_blocks, GFP_NOIO, BLKDEV_IFL_WAIT |
4137     - BLKDEV_IFL_BARRIER))
4138     + nr_blocks, GFP_NOIO, BLKDEV_IFL_WAIT))
4139     break;
4140     }
4141    
4142     @@ -318,10 +315,8 @@ checks:
4143     if (offset > si->highest_bit)
4144     scan_base = offset = si->lowest_bit;
4145    
4146     - /* reuse swap entry of cache-only swap if not hibernation. */
4147     - if (vm_swap_full()
4148     - && usage == SWAP_HAS_CACHE
4149     - && si->swap_map[offset] == SWAP_HAS_CACHE) {
4150     + /* reuse swap entry of cache-only swap if not busy. */
4151     + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
4152     int swap_was_freed;
4153     spin_unlock(&swap_lock);
4154     swap_was_freed = __try_to_reclaim_swap(si, offset);
4155     @@ -688,6 +683,24 @@ int try_to_free_swap(struct page *page)
4156     if (page_swapcount(page))
4157     return 0;
4158    
4159     + /*
4160     + * Once hibernation has begun to create its image of memory,
4161     + * there's a danger that one of the calls to try_to_free_swap()
4162     + * - most probably a call from __try_to_reclaim_swap() while
4163     + * hibernation is allocating its own swap pages for the image,
4164     + * but conceivably even a call from memory reclaim - will free
4165     + * the swap from a page which has already been recorded in the
4166     + * image as a clean swapcache page, and then reuse its swap for
4167     + * another page of the image. On waking from hibernation, the
4168     + * original page might be freed under memory pressure, then
4169     + * later read back in from swap, now with the wrong data.
4170     + *
4171     + * Hibernation clears bits from gfp_allowed_mask to prevent
4172     + * memory reclaim from writing to disk, so check that here.
4173     + */
4174     + if (!(gfp_allowed_mask & __GFP_IO))
4175     + return 0;
4176     +
4177     delete_from_swap_cache(page);
4178     SetPageDirty(page);
4179     return 1;
4180     @@ -2034,7 +2047,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
4181     p->flags |= SWP_SOLIDSTATE;
4182     p->cluster_next = 1 + (random32() % p->highest_bit);
4183     }
4184     - if (discard_swap(p) == 0)
4185     + if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
4186     p->flags |= SWP_DISCARDABLE;
4187     }
4188    
4189     diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
4190     index 1ac01b1..aaab5aa 100644
4191     --- a/net/ipv4/netfilter/arp_tables.c
4192     +++ b/net/ipv4/netfilter/arp_tables.c
4193     @@ -1420,6 +1420,9 @@ static int translate_compat_table(const char *name,
4194     if (ret != 0)
4195     break;
4196     ++i;
4197     + if (strcmp(arpt_get_target(iter1)->u.user.name,
4198     + XT_ERROR_TARGET) == 0)
4199     + ++newinfo->stacksize;
4200     }
4201     if (ret) {
4202     /*
4203     diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
4204     index 4b6c5ca..402ce75 100644
4205     --- a/net/ipv4/netfilter/ip_tables.c
4206     +++ b/net/ipv4/netfilter/ip_tables.c
4207     @@ -1747,6 +1747,9 @@ translate_compat_table(struct net *net,
4208     if (ret != 0)
4209     break;
4210     ++i;
4211     + if (strcmp(ipt_get_target(iter1)->u.user.name,
4212     + XT_ERROR_TARGET) == 0)
4213     + ++newinfo->stacksize;
4214     }
4215     if (ret) {
4216     /*
4217     diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
4218     index 9d2d68f..2112298 100644
4219     --- a/net/ipv6/netfilter/ip6_tables.c
4220     +++ b/net/ipv6/netfilter/ip6_tables.c
4221     @@ -1765,6 +1765,9 @@ translate_compat_table(struct net *net,
4222     if (ret != 0)
4223     break;
4224     ++i;
4225     + if (strcmp(ip6t_get_target(iter1)->u.user.name,
4226     + XT_ERROR_TARGET) == 0)
4227     + ++newinfo->stacksize;
4228     }
4229     if (ret) {
4230     /*
4231     diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
4232     index a788f9e..6130f9d 100644
4233     --- a/net/irda/irlan/irlan_common.c
4234     +++ b/net/irda/irlan/irlan_common.c
4235     @@ -1102,7 +1102,7 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
4236     memcpy(&val_len, buf+n, 2); /* To avoid alignment problems */
4237     le16_to_cpus(&val_len); n+=2;
4238    
4239     - if (val_len > 1016) {
4240     + if (val_len >= 1016) {
4241     IRDA_DEBUG(2, "%s(), parameter length to long\n", __func__ );
4242     return -RSP_INVALID_COMMAND_FORMAT;
4243     }
4244     diff --git a/net/mac80211/main.c b/net/mac80211/main.c
4245     index 22a384d..52f15fe 100644
4246     --- a/net/mac80211/main.c
4247     +++ b/net/mac80211/main.c
4248     @@ -659,6 +659,12 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
4249    
4250     rtnl_unlock();
4251    
4252     + /*
4253     + * Now all work items will be gone, but the
4254     + * timer might still be armed, so delete it
4255     + */
4256     + del_timer_sync(&local->work_timer);
4257     +
4258     cancel_work_sync(&local->reconfig_filter);
4259    
4260     ieee80211_clear_tx_pending(local);
4261     diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
4262     index 8da2a0e..5359f36 100644
4263     --- a/net/sunrpc/auth_gss/auth_gss.c
4264     +++ b/net/sunrpc/auth_gss/auth_gss.c
4265     @@ -745,17 +745,18 @@ gss_pipe_release(struct inode *inode)
4266     struct rpc_inode *rpci = RPC_I(inode);
4267     struct gss_upcall_msg *gss_msg;
4268    
4269     +restart:
4270     spin_lock(&inode->i_lock);
4271     - while (!list_empty(&rpci->in_downcall)) {
4272     + list_for_each_entry(gss_msg, &rpci->in_downcall, list) {
4273    
4274     - gss_msg = list_entry(rpci->in_downcall.next,
4275     - struct gss_upcall_msg, list);
4276     + if (!list_empty(&gss_msg->msg.list))
4277     + continue;
4278     gss_msg->msg.errno = -EPIPE;
4279     atomic_inc(&gss_msg->count);
4280     __gss_unhash_msg(gss_msg);
4281     spin_unlock(&inode->i_lock);
4282     gss_release_msg(gss_msg);
4283     - spin_lock(&inode->i_lock);
4284     + goto restart;
4285     }
4286     spin_unlock(&inode->i_lock);
4287    
4288     diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
4289     index 95ccbcf..41a762f 100644
4290     --- a/net/sunrpc/rpc_pipe.c
4291     +++ b/net/sunrpc/rpc_pipe.c
4292     @@ -48,7 +48,7 @@ static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head,
4293     return;
4294     do {
4295     msg = list_entry(head->next, struct rpc_pipe_msg, list);
4296     - list_del(&msg->list);
4297     + list_del_init(&msg->list);
4298     msg->errno = err;
4299     destroy_msg(msg);
4300     } while (!list_empty(head));
4301     @@ -208,7 +208,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
4302     if (msg != NULL) {
4303     spin_lock(&inode->i_lock);
4304     msg->errno = -EAGAIN;
4305     - list_del(&msg->list);
4306     + list_del_init(&msg->list);
4307     spin_unlock(&inode->i_lock);
4308     rpci->ops->destroy_msg(msg);
4309     }
4310     @@ -268,7 +268,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
4311     if (res < 0 || msg->len == msg->copied) {
4312     filp->private_data = NULL;
4313     spin_lock(&inode->i_lock);
4314     - list_del(&msg->list);
4315     + list_del_init(&msg->list);
4316     spin_unlock(&inode->i_lock);
4317     rpci->ops->destroy_msg(msg);
4318     }
4319     diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
4320     index 9634299..37c7d5b 100644
4321     --- a/net/wireless/wext-compat.c
4322     +++ b/net/wireless/wext-compat.c
4323     @@ -1420,6 +1420,9 @@ int cfg80211_wext_giwessid(struct net_device *dev,
4324     {
4325     struct wireless_dev *wdev = dev->ieee80211_ptr;
4326    
4327     + data->flags = 0;
4328     + data->length = 0;
4329     +
4330     switch (wdev->iftype) {
4331     case NL80211_IFTYPE_ADHOC:
4332     return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
4333     diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
4334     index 0ef17bc..8f5116f 100644
4335     --- a/net/wireless/wext-core.c
4336     +++ b/net/wireless/wext-core.c
4337     @@ -782,6 +782,22 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
4338     }
4339     }
4340    
4341     + if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
4342     + /*
4343     + * If this is a GET, but not NOMAX, it means that the extra
4344     + * data is not bounded by userspace, but by max_tokens. Thus
4345     + * set the length to max_tokens. This matches the extra data
4346     + * allocation.
4347     + * The driver should fill it with the number of tokens it
4348     + * provided, and it may check iwp->length rather than having
4349     + * knowledge of max_tokens. If the driver doesn't change the
4350     + * iwp->length, this ioctl just copies back max_token tokens
4351     + * filled with zeroes. Hopefully the driver isn't claiming
4352     + * them to be valid data.
4353     + */
4354     + iwp->length = descr->max_tokens;
4355     + }
4356     +
4357     err = handler(dev, info, (union iwreq_data *) iwp, extra);
4358    
4359     iwp->length += essid_compat;
4360     diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
4361     index 16d100d..3fbcd1d 100644
4362     --- a/security/integrity/ima/ima.h
4363     +++ b/security/integrity/ima/ima.h
4364     @@ -35,6 +35,7 @@ enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8 };
4365     #define IMA_MEASURE_HTABLE_SIZE (1 << IMA_HASH_BITS)
4366    
4367     /* set during initialization */
4368     +extern int iint_initialized;
4369     extern int ima_initialized;
4370     extern int ima_used_chip;
4371     extern char *ima_hash;
4372     diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c
4373     index 7625b85..afba4ae 100644
4374     --- a/security/integrity/ima/ima_iint.c
4375     +++ b/security/integrity/ima/ima_iint.c
4376     @@ -22,9 +22,10 @@
4377    
4378     RADIX_TREE(ima_iint_store, GFP_ATOMIC);
4379     DEFINE_SPINLOCK(ima_iint_lock);
4380     -
4381     static struct kmem_cache *iint_cache __read_mostly;
4382    
4383     +int iint_initialized = 0;
4384     +
4385     /* ima_iint_find_get - return the iint associated with an inode
4386     *
4387     * ima_iint_find_get gets a reference to the iint. Caller must
4388     @@ -141,6 +142,7 @@ static int __init ima_iintcache_init(void)
4389     iint_cache =
4390     kmem_cache_create("iint_cache", sizeof(struct ima_iint_cache), 0,
4391     SLAB_PANIC, init_once);
4392     + iint_initialized = 1;
4393     return 0;
4394     }
4395     security_initcall(ima_iintcache_init);
4396     diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
4397     index f936413..e662b89 100644
4398     --- a/security/integrity/ima/ima_main.c
4399     +++ b/security/integrity/ima/ima_main.c
4400     @@ -148,12 +148,14 @@ void ima_counts_get(struct file *file)
4401     struct ima_iint_cache *iint;
4402     int rc;
4403    
4404     - if (!ima_initialized || !S_ISREG(inode->i_mode))
4405     + if (!iint_initialized || !S_ISREG(inode->i_mode))
4406     return;
4407     iint = ima_iint_find_get(inode);
4408     if (!iint)
4409     return;
4410     mutex_lock(&iint->mutex);
4411     + if (!ima_initialized)
4412     + goto out;
4413     rc = ima_must_measure(iint, inode, MAY_READ, FILE_CHECK);
4414     if (rc < 0)
4415     goto out;
4416     @@ -213,7 +215,7 @@ void ima_file_free(struct file *file)
4417     struct inode *inode = file->f_dentry->d_inode;
4418     struct ima_iint_cache *iint;
4419    
4420     - if (!ima_initialized || !S_ISREG(inode->i_mode))
4421     + if (!iint_initialized || !S_ISREG(inode->i_mode))
4422     return;
4423     iint = ima_iint_find_get(inode);
4424     if (!iint)
4425     @@ -230,7 +232,7 @@ static int process_measurement(struct file *file, const unsigned char *filename,
4426     {
4427     struct inode *inode = file->f_dentry->d_inode;
4428     struct ima_iint_cache *iint;
4429     - int rc;
4430     + int rc = 0;
4431    
4432     if (!ima_initialized || !S_ISREG(inode->i_mode))
4433     return 0;
4434     diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
4435     index 6857122..69cd7b3 100644
4436     --- a/sound/core/seq/oss/seq_oss_init.c
4437     +++ b/sound/core/seq/oss/seq_oss_init.c
4438     @@ -281,13 +281,10 @@ snd_seq_oss_open(struct file *file, int level)
4439     return 0;
4440    
4441     _error:
4442     - snd_seq_oss_writeq_delete(dp->writeq);
4443     - snd_seq_oss_readq_delete(dp->readq);
4444     snd_seq_oss_synth_cleanup(dp);
4445     snd_seq_oss_midi_cleanup(dp);
4446     - delete_port(dp);
4447     delete_seq_queue(dp->queue);
4448     - kfree(dp);
4449     + delete_port(dp);
4450    
4451     return rc;
4452     }
4453     @@ -350,8 +347,10 @@ create_port(struct seq_oss_devinfo *dp)
4454     static int
4455     delete_port(struct seq_oss_devinfo *dp)
4456     {
4457     - if (dp->port < 0)
4458     + if (dp->port < 0) {
4459     + kfree(dp);
4460     return 0;
4461     + }
4462    
4463     debug_printk(("delete_port %i\n", dp->port));
4464     return snd_seq_event_port_detach(dp->cseq, dp->port);
4465     diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
4466     index ba2098d..00515c7 100644
4467     --- a/sound/pci/hda/hda_codec.c
4468     +++ b/sound/pci/hda/hda_codec.c
4469     @@ -4360,7 +4360,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4470     cfg->hp_outs--;
4471     memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1,
4472     sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i));
4473     - memmove(sequences_hp + i - 1, sequences_hp + i,
4474     + memmove(sequences_hp + i, sequences_hp + i + 1,
4475     sizeof(sequences_hp[0]) * (cfg->hp_outs - i));
4476     }
4477     }
4478     diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
4479     index 350ee8a..059565f 100644
4480     --- a/sound/pci/hda/patch_cirrus.c
4481     +++ b/sound/pci/hda/patch_cirrus.c
4482     @@ -972,6 +972,53 @@ static struct hda_verb cs_coef_init_verbs[] = {
4483     {} /* terminator */
4484     };
4485    
4486     +/* Errata: CS4207 rev C0/C1/C2 Silicon
4487     + *
4488     + * http://www.cirrus.com/en/pubs/errata/ER880C3.pdf
4489     + *
4490     + * 6. At high temperature (TA > +85°C), the digital supply current (IVD)
4491     + * may be excessive (up to an additional 200 μA), which is most easily
4492     + * observed while the part is being held in reset (RESET# active low).
4493     + *
4494     + * Root Cause: At initial powerup of the device, the logic that drives
4495     + * the clock and write enable to the S/PDIF SRC RAMs is not properly
4496     + * initialized.
4497     + * Certain random patterns will cause a steady leakage current in those
4498     + * RAM cells. The issue will resolve once the SRCs are used (turned on).
4499     + *
4500     + * Workaround: The following verb sequence briefly turns on the S/PDIF SRC
4501     + * blocks, which will alleviate the issue.
4502     + */
4503     +
4504     +static struct hda_verb cs_errata_init_verbs[] = {
4505     + {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
4506     + {0x11, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
4507     +
4508     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
4509     + {0x11, AC_VERB_SET_PROC_COEF, 0x9999},
4510     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
4511     + {0x11, AC_VERB_SET_PROC_COEF, 0xa412},
4512     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
4513     + {0x11, AC_VERB_SET_PROC_COEF, 0x0009},
4514     +
4515     + {0x07, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Rx: D0 */
4516     + {0x08, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Tx: D0 */
4517     +
4518     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
4519     + {0x11, AC_VERB_SET_PROC_COEF, 0x2412},
4520     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
4521     + {0x11, AC_VERB_SET_PROC_COEF, 0x0000},
4522     + {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
4523     + {0x11, AC_VERB_SET_PROC_COEF, 0x0008},
4524     + {0x11, AC_VERB_SET_PROC_STATE, 0x00},
4525     +
4526     + {0x07, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Rx: D3 */
4527     + {0x08, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Tx: D3 */
4528     + /*{0x01, AC_VERB_SET_POWER_STATE, 0x03},*/ /* AFG: D3 This is already handled */
4529     +
4530     + {} /* terminator */
4531     +};
4532     +
4533     /* SPDIF setup */
4534     static void init_digital(struct hda_codec *codec)
4535     {
4536     @@ -991,6 +1038,9 @@ static int cs_init(struct hda_codec *codec)
4537     {
4538     struct cs_spec *spec = codec->spec;
4539    
4540     + /* init_verb sequence for C0/C1/C2 errata*/
4541     + snd_hda_sequence_write(codec, cs_errata_init_verbs);
4542     +
4543     snd_hda_sequence_write(codec, cs_coef_init_verbs);
4544    
4545     if (spec->gpio_mask) {
4546     diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
4547     index baadda4..4eee494 100644
4548     --- a/sound/pci/hda/patch_conexant.c
4549     +++ b/sound/pci/hda/patch_conexant.c
4550     @@ -116,6 +116,7 @@ struct conexant_spec {
4551     unsigned int dell_vostro:1;
4552     unsigned int ideapad:1;
4553     unsigned int thinkpad:1;
4554     + unsigned int hp_laptop:1;
4555    
4556     unsigned int ext_mic_present;
4557     unsigned int recording;
4558     @@ -2219,6 +2220,18 @@ static void cxt5066_ideapad_automic(struct hda_codec *codec)
4559     }
4560     }
4561    
4562     +/* toggle input of built-in digital mic and mic jack appropriately */
4563     +static void cxt5066_hp_laptop_automic(struct hda_codec *codec)
4564     +{
4565     + unsigned int present;
4566     +
4567     + present = snd_hda_jack_detect(codec, 0x1b);
4568     + snd_printdd("CXT5066: external microphone present=%d\n", present);
4569     + snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
4570     + present ? 1 : 3);
4571     +}
4572     +
4573     +
4574     /* toggle input of built-in digital mic and mic jack appropriately
4575     order is: external mic -> dock mic -> interal mic */
4576     static void cxt5066_thinkpad_automic(struct hda_codec *codec)
4577     @@ -2328,6 +2341,20 @@ static void cxt5066_ideapad_event(struct hda_codec *codec, unsigned int res)
4578     }
4579    
4580     /* unsolicited event for jack sensing */
4581     +static void cxt5066_hp_laptop_event(struct hda_codec *codec, unsigned int res)
4582     +{
4583     + snd_printdd("CXT5066_hp_laptop: unsol event %x (%x)\n", res, res >> 26);
4584     + switch (res >> 26) {
4585     + case CONEXANT_HP_EVENT:
4586     + cxt5066_hp_automute(codec);
4587     + break;
4588     + case CONEXANT_MIC_EVENT:
4589     + cxt5066_hp_laptop_automic(codec);
4590     + break;
4591     + }
4592     +}
4593     +
4594     +/* unsolicited event for jack sensing */
4595     static void cxt5066_thinkpad_event(struct hda_codec *codec, unsigned int res)
4596     {
4597     snd_printdd("CXT5066_thinkpad: unsol event %x (%x)\n", res, res >> 26);
4598     @@ -2910,6 +2937,14 @@ static struct hda_verb cxt5066_init_verbs_portd_lo[] = {
4599     { } /* end */
4600     };
4601    
4602     +
4603     +static struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
4604     + {0x14, AC_VERB_SET_CONNECT_SEL, 0x0},
4605     + {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
4606     + {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
4607     + { } /* end */
4608     +};
4609     +
4610     /* initialize jack-sensing, too */
4611     static int cxt5066_init(struct hda_codec *codec)
4612     {
4613     @@ -2925,6 +2960,8 @@ static int cxt5066_init(struct hda_codec *codec)
4614     cxt5066_ideapad_automic(codec);
4615     else if (spec->thinkpad)
4616     cxt5066_thinkpad_automic(codec);
4617     + else if (spec->hp_laptop)
4618     + cxt5066_hp_laptop_automic(codec);
4619     }
4620     cxt5066_set_mic_boost(codec);
4621     return 0;
4622     @@ -2952,6 +2989,7 @@ enum {
4623     CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */
4624     CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */
4625     CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */
4626     + CXT5066_HP_LAPTOP, /* HP Laptop */
4627     CXT5066_MODELS
4628     };
4629    
4630     @@ -2962,6 +3000,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = {
4631     [CXT5066_DELL_VOSTO] = "dell-vostro",
4632     [CXT5066_IDEAPAD] = "ideapad",
4633     [CXT5066_THINKPAD] = "thinkpad",
4634     + [CXT5066_HP_LAPTOP] = "hp-laptop",
4635     };
4636    
4637     static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
4638     @@ -2973,8 +3012,10 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
4639     SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTO),
4640     SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO),
4641     SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD),
4642     + SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP),
4643     SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
4644     SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5),
4645     + SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD),
4646     SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD),
4647     SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD),
4648     SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD),
4649     @@ -3032,6 +3073,23 @@ static int patch_cxt5066(struct hda_codec *codec)
4650     spec->num_init_verbs++;
4651     spec->dell_automute = 1;
4652     break;
4653     + case CXT5066_HP_LAPTOP:
4654     + codec->patch_ops.init = cxt5066_init;
4655     + codec->patch_ops.unsol_event = cxt5066_hp_laptop_event;
4656     + spec->init_verbs[spec->num_init_verbs] =
4657     + cxt5066_init_verbs_hp_laptop;
4658     + spec->num_init_verbs++;
4659     + spec->hp_laptop = 1;
4660     + spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
4661     + spec->mixers[spec->num_mixers++] = cxt5066_mixers;
4662     + /* no S/PDIF out */
4663     + spec->multiout.dig_out_nid = 0;
4664     + /* input source automatically selected */
4665     + spec->input_mux = NULL;
4666     + spec->port_d_mode = 0;
4667     + spec->mic_boost = 3; /* default 30dB gain */
4668     + break;
4669     +
4670     case CXT5066_OLPC_XO_1_5:
4671     codec->patch_ops.init = cxt5066_olpc_init;
4672     codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
4673     diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
4674     index b0652ac..88ae0f2 100644
4675     --- a/sound/pci/hda/patch_nvhdmi.c
4676     +++ b/sound/pci/hda/patch_nvhdmi.c
4677     @@ -541,26 +541,32 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec)
4678     * patch entries
4679     */
4680     static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
4681     - { .id = 0x10de0002, .name = "MCP77/78 HDMI",
4682     - .patch = patch_nvhdmi_8ch_7x },
4683     - { .id = 0x10de0003, .name = "MCP77/78 HDMI",
4684     - .patch = patch_nvhdmi_8ch_7x },
4685     - { .id = 0x10de0005, .name = "MCP77/78 HDMI",
4686     - .patch = patch_nvhdmi_8ch_7x },
4687     - { .id = 0x10de0006, .name = "MCP77/78 HDMI",
4688     - .patch = patch_nvhdmi_8ch_7x },
4689     - { .id = 0x10de0007, .name = "MCP79/7A HDMI",
4690     - .patch = patch_nvhdmi_8ch_7x },
4691     - { .id = 0x10de000a, .name = "GT220 HDMI",
4692     - .patch = patch_nvhdmi_8ch_89 },
4693     - { .id = 0x10de000b, .name = "GT21x HDMI",
4694     - .patch = patch_nvhdmi_8ch_89 },
4695     - { .id = 0x10de000c, .name = "MCP89 HDMI",
4696     - .patch = patch_nvhdmi_8ch_89 },
4697     - { .id = 0x10de000d, .name = "GT240 HDMI",
4698     - .patch = patch_nvhdmi_8ch_89 },
4699     - { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
4700     - { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
4701     + { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
4702     + { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
4703     + { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
4704     + { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
4705     + { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
4706     + { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4707     + { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4708     + { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 },
4709     + { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4710     + { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4711     + { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4712     + { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4713     + { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4714     + { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4715     + { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4716     + { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4717     + { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4718     + { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4719     + { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4720     + { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4721     + { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4722     + { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4723     + { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4724     + { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
4725     + { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
4726     + { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
4727     {} /* terminator */
4728     };
4729    
4730     @@ -573,6 +579,21 @@ MODULE_ALIAS("snd-hda-codec-id:10de000a");
4731     MODULE_ALIAS("snd-hda-codec-id:10de000b");
4732     MODULE_ALIAS("snd-hda-codec-id:10de000c");
4733     MODULE_ALIAS("snd-hda-codec-id:10de000d");
4734     +MODULE_ALIAS("snd-hda-codec-id:10de0010");
4735     +MODULE_ALIAS("snd-hda-codec-id:10de0011");
4736     +MODULE_ALIAS("snd-hda-codec-id:10de0012");
4737     +MODULE_ALIAS("snd-hda-codec-id:10de0013");
4738     +MODULE_ALIAS("snd-hda-codec-id:10de0014");
4739     +MODULE_ALIAS("snd-hda-codec-id:10de0018");
4740     +MODULE_ALIAS("snd-hda-codec-id:10de0019");
4741     +MODULE_ALIAS("snd-hda-codec-id:10de001a");
4742     +MODULE_ALIAS("snd-hda-codec-id:10de001b");
4743     +MODULE_ALIAS("snd-hda-codec-id:10de001c");
4744     +MODULE_ALIAS("snd-hda-codec-id:10de0040");
4745     +MODULE_ALIAS("snd-hda-codec-id:10de0041");
4746     +MODULE_ALIAS("snd-hda-codec-id:10de0042");
4747     +MODULE_ALIAS("snd-hda-codec-id:10de0043");
4748     +MODULE_ALIAS("snd-hda-codec-id:10de0044");
4749     MODULE_ALIAS("snd-hda-codec-id:10de0067");
4750     MODULE_ALIAS("snd-hda-codec-id:10de8001");
4751    
4752     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4753     index 6d9a542..76c4968 100644
4754     --- a/sound/pci/hda/patch_realtek.c
4755     +++ b/sound/pci/hda/patch_realtek.c
4756     @@ -7005,7 +7005,7 @@ static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
4757     .num_items = 4,
4758     .items = {
4759     { "Mic", 0x0 },
4760     - { "iMic", 0x1 },
4761     + { "Int Mic", 0x1 },
4762     { "Line", 0x2 },
4763     { "CD", 0x4 },
4764     },
4765     @@ -8575,8 +8575,8 @@ static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
4766     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4767     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4768     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4769     - HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4770     - HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4771     + HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4772     + HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4773     { } /* end */
4774     };
4775    
4776     @@ -13026,6 +13026,8 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
4777     dac = 0x02;
4778     break;
4779     case 0x15:
4780     + case 0x1a: /* ALC259/269 only */
4781     + case 0x1b: /* ALC259/269 only */
4782     case 0x21: /* ALC269vb has this pin, too */
4783     dac = 0x03;
4784     break;
4785     @@ -13305,7 +13307,6 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
4786     SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
4787     SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
4788     SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
4789     - SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
4790     {}
4791     };
4792    
4793     @@ -14229,6 +14230,7 @@ static void alc269_auto_init(struct hda_codec *codec)
4794    
4795     enum {
4796     ALC269_FIXUP_SONY_VAIO,
4797     + ALC269_FIXUP_DELL_M101Z,
4798     };
4799    
4800     static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
4801     @@ -14240,10 +14242,20 @@ static const struct alc_fixup alc269_fixups[] = {
4802     [ALC269_FIXUP_SONY_VAIO] = {
4803     .verbs = alc269_sony_vaio_fixup_verbs
4804     },
4805     + [ALC269_FIXUP_DELL_M101Z] = {
4806     + .verbs = (const struct hda_verb[]) {
4807     + /* Enables internal speaker */
4808     + {0x20, AC_VERB_SET_COEF_INDEX, 13},
4809     + {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4810     + {}
4811     + }
4812     + },
4813     };
4814    
4815     static struct snd_pci_quirk alc269_fixup_tbl[] = {
4816     SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
4817     + SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
4818     + SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
4819     {}
4820     };
4821    
4822     diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
4823     index 6147216..a3409ed 100644
4824     --- a/sound/pci/oxygen/oxygen.h
4825     +++ b/sound/pci/oxygen/oxygen.h
4826     @@ -155,6 +155,7 @@ void oxygen_pci_remove(struct pci_dev *pci);
4827     int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state);
4828     int oxygen_pci_resume(struct pci_dev *pci);
4829     #endif
4830     +void oxygen_pci_shutdown(struct pci_dev *pci);
4831    
4832     /* oxygen_mixer.c */
4833    
4834     diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
4835     index fad03d6..7e93cf8 100644
4836     --- a/sound/pci/oxygen/oxygen_lib.c
4837     +++ b/sound/pci/oxygen/oxygen_lib.c
4838     @@ -519,16 +519,21 @@ static void oxygen_init(struct oxygen *chip)
4839     }
4840     }
4841    
4842     -static void oxygen_card_free(struct snd_card *card)
4843     +static void oxygen_shutdown(struct oxygen *chip)
4844     {
4845     - struct oxygen *chip = card->private_data;
4846     -
4847     spin_lock_irq(&chip->reg_lock);
4848     chip->interrupt_mask = 0;
4849     chip->pcm_running = 0;
4850     oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
4851     oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
4852     spin_unlock_irq(&chip->reg_lock);
4853     +}
4854     +
4855     +static void oxygen_card_free(struct snd_card *card)
4856     +{
4857     + struct oxygen *chip = card->private_data;
4858     +
4859     + oxygen_shutdown(chip);
4860     if (chip->irq >= 0)
4861     free_irq(chip->irq, chip);
4862     flush_scheduled_work();
4863     @@ -778,3 +783,13 @@ int oxygen_pci_resume(struct pci_dev *pci)
4864     }
4865     EXPORT_SYMBOL(oxygen_pci_resume);
4866     #endif /* CONFIG_PM */
4867     +
4868     +void oxygen_pci_shutdown(struct pci_dev *pci)
4869     +{
4870     + struct snd_card *card = pci_get_drvdata(pci);
4871     + struct oxygen *chip = card->private_data;
4872     +
4873     + oxygen_shutdown(chip);
4874     + chip->model.cleanup(chip);
4875     +}
4876     +EXPORT_SYMBOL(oxygen_pci_shutdown);
4877     diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
4878     index f03a2f2..06c863e 100644
4879     --- a/sound/pci/oxygen/virtuoso.c
4880     +++ b/sound/pci/oxygen/virtuoso.c
4881     @@ -95,6 +95,7 @@ static struct pci_driver xonar_driver = {
4882     .suspend = oxygen_pci_suspend,
4883     .resume = oxygen_pci_resume,
4884     #endif
4885     + .shutdown = oxygen_pci_shutdown,
4886     };
4887    
4888     static int __init alsa_card_xonar_init(void)
4889     diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c
4890     index dbc4b89..b82c1cf 100644
4891     --- a/sound/pci/oxygen/xonar_wm87x6.c
4892     +++ b/sound/pci/oxygen/xonar_wm87x6.c
4893     @@ -53,6 +53,8 @@ struct xonar_wm87x6 {
4894     struct xonar_generic generic;
4895     u16 wm8776_regs[0x17];
4896     u16 wm8766_regs[0x10];
4897     + struct snd_kcontrol *line_adcmux_control;
4898     + struct snd_kcontrol *mic_adcmux_control;
4899     struct snd_kcontrol *lc_controls[13];
4900     };
4901    
4902     @@ -193,6 +195,7 @@ static void xonar_ds_init(struct oxygen *chip)
4903     static void xonar_ds_cleanup(struct oxygen *chip)
4904     {
4905     xonar_disable_output(chip);
4906     + wm8776_write(chip, WM8776_RESET, 0);
4907     }
4908    
4909     static void xonar_ds_suspend(struct oxygen *chip)
4910     @@ -603,6 +606,7 @@ static int wm8776_input_mux_put(struct snd_kcontrol *ctl,
4911     {
4912     struct oxygen *chip = ctl->private_data;
4913     struct xonar_wm87x6 *data = chip->model_data;
4914     + struct snd_kcontrol *other_ctl;
4915     unsigned int mux_bit = ctl->private_value;
4916     u16 reg;
4917     int changed;
4918     @@ -610,8 +614,18 @@ static int wm8776_input_mux_put(struct snd_kcontrol *ctl,
4919     mutex_lock(&chip->mutex);
4920     reg = data->wm8776_regs[WM8776_ADCMUX];
4921     if (value->value.integer.value[0]) {
4922     - reg &= ~0x003;
4923     reg |= mux_bit;
4924     + /* line-in and mic-in are exclusive */
4925     + mux_bit ^= 3;
4926     + if (reg & mux_bit) {
4927     + reg &= ~mux_bit;
4928     + if (mux_bit == 1)
4929     + other_ctl = data->line_adcmux_control;
4930     + else
4931     + other_ctl = data->mic_adcmux_control;
4932     + snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
4933     + &other_ctl->id);
4934     + }
4935     } else
4936     reg &= ~mux_bit;
4937     changed = reg != data->wm8776_regs[WM8776_ADCMUX];
4938     @@ -963,7 +977,13 @@ static int xonar_ds_mixer_init(struct oxygen *chip)
4939     err = snd_ctl_add(chip->card, ctl);
4940     if (err < 0)
4941     return err;
4942     + if (!strcmp(ctl->id.name, "Line Capture Switch"))
4943     + data->line_adcmux_control = ctl;
4944     + else if (!strcmp(ctl->id.name, "Mic Capture Switch"))
4945     + data->mic_adcmux_control = ctl;
4946     }
4947     + if (!data->line_adcmux_control || !data->mic_adcmux_control)
4948     + return -ENXIO;
4949     BUILD_BUG_ON(ARRAY_SIZE(lc_controls) != ARRAY_SIZE(data->lc_controls));
4950     for (i = 0; i < ARRAY_SIZE(lc_controls); ++i) {
4951     ctl = snd_ctl_new1(&lc_controls[i], chip);
4952     diff --git a/sound/usb/card.c b/sound/usb/card.c
4953     index 7a8ac1d..ceeba89 100644
4954     --- a/sound/usb/card.c
4955     +++ b/sound/usb/card.c
4956     @@ -126,7 +126,7 @@ static void snd_usb_stream_disconnect(struct list_head *head)
4957     for (idx = 0; idx < 2; idx++) {
4958     subs = &as->substream[idx];
4959     if (!subs->num_formats)
4960     - return;
4961     + continue;
4962     snd_usb_release_substream_urbs(subs, 1);
4963     subs->interface = -1;
4964     }
4965     @@ -216,6 +216,11 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
4966     }
4967    
4968     switch (protocol) {
4969     + default:
4970     + snd_printdd(KERN_WARNING "unknown interface protocol %#02x, assuming v1\n",
4971     + protocol);
4972     + /* fall through */
4973     +
4974     case UAC_VERSION_1: {
4975     struct uac_ac_header_descriptor_v1 *h1 = control_header;
4976    
4977     @@ -253,10 +258,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
4978    
4979     break;
4980     }
4981     -
4982     - default:
4983     - snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol);
4984     - return -EINVAL;
4985     }
4986    
4987     return 0;
4988     @@ -465,7 +466,13 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
4989     goto __error;
4990     }
4991    
4992     - chip->ctrl_intf = alts;
4993     + /*
4994     + * For devices with more than one control interface, we assume the
4995     + * first contains the audio controls. We might need a more specific
4996     + * check here in the future.
4997     + */
4998     + if (!chip->ctrl_intf)
4999     + chip->ctrl_intf = alts;
5000    
5001     if (err > 0) {
5002     /* create normal USB audio interfaces */
5003     diff --git a/sound/usb/clock.c b/sound/usb/clock.c
5004     index b585511..aeda4c7 100644
5005     --- a/sound/usb/clock.c
5006     +++ b/sound/usb/clock.c
5007     @@ -304,12 +304,11 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
5008    
5009     switch (altsd->bInterfaceProtocol) {
5010     case UAC_VERSION_1:
5011     + default:
5012     return set_sample_rate_v1(chip, iface, alts, fmt, rate);
5013    
5014     case UAC_VERSION_2:
5015     return set_sample_rate_v2(chip, iface, alts, fmt, rate);
5016     }
5017     -
5018     - return -EINVAL;
5019     }
5020    
5021     diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
5022     index 6f6596c..0aac628 100644
5023     --- a/sound/usb/endpoint.c
5024     +++ b/sound/usb/endpoint.c
5025     @@ -274,6 +274,12 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
5026    
5027     /* get audio formats */
5028     switch (protocol) {
5029     + default:
5030     + snd_printdd(KERN_WARNING "%d:%u:%d: unknown interface protocol %#02x, assuming v1\n",
5031     + dev->devnum, iface_no, altno, protocol);
5032     + protocol = UAC_VERSION_1;
5033     + /* fall through */
5034     +
5035     case UAC_VERSION_1: {
5036     struct uac_as_header_descriptor_v1 *as =
5037     snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
5038     @@ -335,11 +341,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
5039     dev->devnum, iface_no, altno, as->bTerminalLink);
5040     continue;
5041     }
5042     -
5043     - default:
5044     - snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n",
5045     - dev->devnum, iface_no, altno, protocol);
5046     - continue;
5047     }
5048    
5049     /* get format type */
5050     diff --git a/sound/usb/format.c b/sound/usb/format.c
5051     index 30364ab..440d7c3 100644
5052     --- a/sound/usb/format.c
5053     +++ b/sound/usb/format.c
5054     @@ -49,7 +49,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
5055     u64 pcm_formats;
5056    
5057     switch (protocol) {
5058     - case UAC_VERSION_1: {
5059     + case UAC_VERSION_1:
5060     + default: {
5061     struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
5062     sample_width = fmt->bBitResolution;
5063     sample_bytes = fmt->bSubframeSize;
5064     @@ -64,9 +65,6 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
5065     format <<= 1;
5066     break;
5067     }
5068     -
5069     - default:
5070     - return -EINVAL;
5071     }
5072    
5073     pcm_formats = 0;
5074     @@ -385,6 +383,10 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
5075     * audio class v2 uses class specific EP0 range requests for that.
5076     */
5077     switch (protocol) {
5078     + default:
5079     + snd_printdd(KERN_WARNING "%d:%u:%d : invalid protocol version %d, assuming v1\n",
5080     + chip->dev->devnum, fp->iface, fp->altsetting, protocol);
5081     + /* fall through */
5082     case UAC_VERSION_1:
5083     fp->channels = fmt->bNrChannels;
5084     ret = parse_audio_format_rates_v1(chip, fp, (unsigned char *) fmt, 7);
5085     @@ -435,6 +437,10 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
5086     fp->channels = 1;
5087    
5088     switch (protocol) {
5089     + default:
5090     + snd_printdd(KERN_WARNING "%d:%u:%d : invalid protocol version %d, assuming v1\n",
5091     + chip->dev->devnum, fp->iface, fp->altsetting, protocol);
5092     + /* fall through */
5093     case UAC_VERSION_1: {
5094     struct uac_format_type_ii_discrete_descriptor *fmt = _fmt;
5095     brate = le16_to_cpu(fmt->wMaxBitRate);
5096     diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
5097     index 736d134..2a4377f 100644
5098     --- a/sound/usb/mixer.c
5099     +++ b/sound/usb/mixer.c
5100     @@ -2168,7 +2168,15 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
5101     }
5102    
5103     host_iface = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
5104     - mixer->protocol = get_iface_desc(host_iface)->bInterfaceProtocol;
5105     + switch (get_iface_desc(host_iface)->bInterfaceProtocol) {
5106     + case UAC_VERSION_1:
5107     + default:
5108     + mixer->protocol = UAC_VERSION_1;
5109     + break;
5110     + case UAC_VERSION_2:
5111     + mixer->protocol = UAC_VERSION_2;
5112     + break;
5113     + }
5114    
5115     if ((err = snd_usb_mixer_controls(mixer)) < 0 ||
5116     (err = snd_usb_mixer_status_create(mixer)) < 0)
5117     diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
5118     index 4568298..b40a248 100644
5119     --- a/sound/usb/pcm.c
5120     +++ b/sound/usb/pcm.c
5121     @@ -173,13 +173,12 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
5122    
5123     switch (altsd->bInterfaceProtocol) {
5124     case UAC_VERSION_1:
5125     + default:
5126     return init_pitch_v1(chip, iface, alts, fmt);
5127    
5128     case UAC_VERSION_2:
5129     return init_pitch_v2(chip, iface, alts, fmt);
5130     }
5131     -
5132     - return -EINVAL;
5133     }
5134    
5135     /*
5136     diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
5137     index f2e9ee1..ecb9732 100644
5138     --- a/tools/perf/util/callchain.h
5139     +++ b/tools/perf/util/callchain.h
5140     @@ -50,6 +50,7 @@ static inline void callchain_init(struct callchain_node *node)
5141     INIT_LIST_HEAD(&node->children);
5142     INIT_LIST_HEAD(&node->val);
5143    
5144     + node->children_hit = 0;
5145     node->parent = NULL;
5146     node->hit = 0;
5147     }