Magellan Linux

Annotation of /trunk/kernel-magellan/patches-3.4/0110-3.4.11-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1897 - (hide annotations) (download)
Sat Sep 22 14:51:23 2012 UTC (11 years, 7 months ago) by niro
File size: 83653 byte(s)
-added linux patches up to 3.4.11
1 niro 1897 diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
2     index 71f55bb..99d4e44 100644
3     --- a/Documentation/i2c/busses/i2c-i801
4     +++ b/Documentation/i2c/busses/i2c-i801
5     @@ -21,6 +21,7 @@ Supported adapters:
6     * Intel DH89xxCC (PCH)
7     * Intel Panther Point (PCH)
8     * Intel Lynx Point (PCH)
9     + * Intel Lynx Point-LP (PCH)
10     Datasheets: Publicly available at the Intel website
11    
12     On Intel Patsburg and later chipsets, both the normal host SMBus controller
13     diff --git a/arch/alpha/include/asm/fpu.h b/arch/alpha/include/asm/fpu.h
14     index db00f78..e477bcd 100644
15     --- a/arch/alpha/include/asm/fpu.h
16     +++ b/arch/alpha/include/asm/fpu.h
17     @@ -1,7 +1,9 @@
18     #ifndef __ASM_ALPHA_FPU_H
19     #define __ASM_ALPHA_FPU_H
20    
21     +#ifdef __KERNEL__
22     #include <asm/special_insns.h>
23     +#endif
24    
25     /*
26     * Alpha floating-point control register defines:
27     diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h
28     index dcb221a..7d2f75b 100644
29     --- a/arch/alpha/include/asm/socket.h
30     +++ b/arch/alpha/include/asm/socket.h
31     @@ -76,9 +76,11 @@
32     /* Instruct lower device to use last 4-bytes of skb data as FCS */
33     #define SO_NOFCS 43
34    
35     +#ifdef __KERNEL__
36     /* O_NONBLOCK clashes with the bits used for socket types. Therefore we
37     * have to define SOCK_NONBLOCK to a different value here.
38     */
39     #define SOCK_NONBLOCK 0x40000000
40     +#endif /* __KERNEL__ */
41    
42     #endif /* _ASM_SOCKET_H */
43     diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
44     index 7a8660a..352322a 100644
45     --- a/arch/arm/Kconfig
46     +++ b/arch/arm/Kconfig
47     @@ -2113,6 +2113,7 @@ source "drivers/cpufreq/Kconfig"
48     config CPU_FREQ_IMX
49     tristate "CPUfreq driver for i.MX CPUs"
50     depends on ARCH_MXC && CPU_FREQ
51     + select CPU_FREQ_TABLE
52     help
53     This enables the CPUfreq driver for i.MX CPUs.
54    
55     diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
56     index f66626d..41dc31f 100644
57     --- a/arch/arm/include/asm/pgtable.h
58     +++ b/arch/arm/include/asm/pgtable.h
59     @@ -195,6 +195,18 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
60    
61     #define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0)
62    
63     +#define pte_none(pte) (!pte_val(pte))
64     +#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT)
65     +#define pte_write(pte) (!(pte_val(pte) & L_PTE_RDONLY))
66     +#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
67     +#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
68     +#define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN))
69     +#define pte_special(pte) (0)
70     +
71     +#define pte_present_user(pte) \
72     + ((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
73     + (L_PTE_PRESENT | L_PTE_USER))
74     +
75     #if __LINUX_ARM_ARCH__ < 6
76     static inline void __sync_icache_dcache(pte_t pteval)
77     {
78     @@ -206,25 +218,15 @@ extern void __sync_icache_dcache(pte_t pteval);
79     static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
80     pte_t *ptep, pte_t pteval)
81     {
82     - if (addr >= TASK_SIZE)
83     - set_pte_ext(ptep, pteval, 0);
84     - else {
85     + unsigned long ext = 0;
86     +
87     + if (addr < TASK_SIZE && pte_present_user(pteval)) {
88     __sync_icache_dcache(pteval);
89     - set_pte_ext(ptep, pteval, PTE_EXT_NG);
90     + ext |= PTE_EXT_NG;
91     }
92     -}
93    
94     -#define pte_none(pte) (!pte_val(pte))
95     -#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT)
96     -#define pte_write(pte) (!(pte_val(pte) & L_PTE_RDONLY))
97     -#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
98     -#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
99     -#define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN))
100     -#define pte_special(pte) (0)
101     -
102     -#define pte_present_user(pte) \
103     - ((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
104     - (L_PTE_PRESENT | L_PTE_USER))
105     + set_pte_ext(ptep, pteval, ext);
106     +}
107    
108     #define PTE_BIT_FUNC(fn,op) \
109     static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
110     @@ -251,13 +253,13 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
111     *
112     * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
113     * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
114     - * <--------------- offset --------------------> <- type --> 0 0 0
115     + * <--------------- offset ----------------------> < type -> 0 0 0
116     *
117     - * This gives us up to 63 swap files and 32GB per swap file. Note that
118     + * This gives us up to 31 swap files and 64GB per swap file. Note that
119     * the offset field is always non-zero.
120     */
121     #define __SWP_TYPE_SHIFT 3
122     -#define __SWP_TYPE_BITS 6
123     +#define __SWP_TYPE_BITS 5
124     #define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1)
125     #define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)
126    
127     diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c
128     index 20ed2d5..f8f7437 100644
129     --- a/arch/arm/mach-imx/hotplug.c
130     +++ b/arch/arm/mach-imx/hotplug.c
131     @@ -42,22 +42,6 @@ static inline void cpu_enter_lowpower(void)
132     : "cc");
133     }
134    
135     -static inline void cpu_leave_lowpower(void)
136     -{
137     - unsigned int v;
138     -
139     - asm volatile(
140     - "mrc p15, 0, %0, c1, c0, 0\n"
141     - " orr %0, %0, %1\n"
142     - " mcr p15, 0, %0, c1, c0, 0\n"
143     - " mrc p15, 0, %0, c1, c0, 1\n"
144     - " orr %0, %0, %2\n"
145     - " mcr p15, 0, %0, c1, c0, 1\n"
146     - : "=&r" (v)
147     - : "Ir" (CR_C), "Ir" (0x40)
148     - : "cc");
149     -}
150     -
151     /*
152     * platform-specific code to shutdown a CPU
153     *
154     @@ -67,11 +51,10 @@ void platform_cpu_die(unsigned int cpu)
155     {
156     cpu_enter_lowpower();
157     imx_enable_cpu(cpu, false);
158     - cpu_do_idle();
159     - cpu_leave_lowpower();
160    
161     - /* We should never return from idle */
162     - panic("cpu %d unexpectedly exit from shutdown\n", cpu);
163     + /* spin here until hardware takes it down */
164     + while (1)
165     + ;
166     }
167    
168     int platform_cpu_disable(unsigned int cpu)
169     diff --git a/arch/arm/mach-s3c24xx/include/mach/dma.h b/arch/arm/mach-s3c24xx/include/mach/dma.h
170     index acbdfec..ccaaafc 100644
171     --- a/arch/arm/mach-s3c24xx/include/mach/dma.h
172     +++ b/arch/arm/mach-s3c24xx/include/mach/dma.h
173     @@ -24,7 +24,8 @@
174     */
175    
176     enum dma_ch {
177     - DMACH_XD0,
178     + DMACH_DT_PROP = -1, /* not yet supported, do not use */
179     + DMACH_XD0 = 0,
180     DMACH_XD1,
181     DMACH_SDI,
182     DMACH_SPI0,
183     diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
184     index 7745854..40ca11e 100644
185     --- a/arch/arm/mm/flush.c
186     +++ b/arch/arm/mm/flush.c
187     @@ -231,8 +231,6 @@ void __sync_icache_dcache(pte_t pteval)
188     struct page *page;
189     struct address_space *mapping;
190    
191     - if (!pte_present_user(pteval))
192     - return;
193     if (cache_is_vipt_nonaliasing() && !pte_exec(pteval))
194     /* only flush non-aliasing VIPT caches for exec mappings */
195     return;
196     diff --git a/arch/arm/mm/tlb-v7.S b/arch/arm/mm/tlb-v7.S
197     index c202113..ea94765 100644
198     --- a/arch/arm/mm/tlb-v7.S
199     +++ b/arch/arm/mm/tlb-v7.S
200     @@ -38,10 +38,10 @@ ENTRY(v7wbi_flush_user_tlb_range)
201     dsb
202     mov r0, r0, lsr #PAGE_SHIFT @ align address
203     mov r1, r1, lsr #PAGE_SHIFT
204     -#ifdef CONFIG_ARM_ERRATA_720789
205     - mov r3, #0
206     -#else
207     asid r3, r3 @ mask ASID
208     +#ifdef CONFIG_ARM_ERRATA_720789
209     + ALT_SMP(W(mov) r3, #0 )
210     + ALT_UP(W(nop) )
211     #endif
212     orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA
213     mov r1, r1, lsl #PAGE_SHIFT
214     diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
215     index 652139c..7ac301e 100644
216     --- a/arch/arm/plat-omap/dmtimer.c
217     +++ b/arch/arm/plat-omap/dmtimer.c
218     @@ -238,7 +238,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
219    
220     void omap_dm_timer_disable(struct omap_dm_timer *timer)
221     {
222     - pm_runtime_put(&timer->pdev->dev);
223     + pm_runtime_put_sync(&timer->pdev->dev);
224     }
225     EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
226    
227     diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
228     index 28f898f..db98e70 100644
229     --- a/arch/arm/plat-s3c24xx/dma.c
230     +++ b/arch/arm/plat-s3c24xx/dma.c
231     @@ -430,7 +430,7 @@ s3c2410_dma_canload(struct s3c2410_dma_chan *chan)
232     * when necessary.
233     */
234    
235     -int s3c2410_dma_enqueue(unsigned int channel, void *id,
236     +int s3c2410_dma_enqueue(enum dma_ch channel, void *id,
237     dma_addr_t data, int size)
238     {
239     struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
240     diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
241     index 1ef803a..1f8241d 100644
242     --- a/arch/arm/vfp/vfpmodule.c
243     +++ b/arch/arm/vfp/vfpmodule.c
244     @@ -719,8 +719,10 @@ static int __init vfp_init(void)
245     if ((fmrx(MVFR1) & 0x000fff00) == 0x00011100)
246     elf_hwcap |= HWCAP_NEON;
247     #endif
248     +#ifdef CONFIG_VFPv3
249     if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000)
250     elf_hwcap |= HWCAP_VFPv4;
251     +#endif
252     }
253     }
254     return 0;
255     diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
256     index 6c6defc..af9cf30 100644
257     --- a/arch/parisc/include/asm/atomic.h
258     +++ b/arch/parisc/include/asm/atomic.h
259     @@ -141,7 +141,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
260    
261     #define atomic_sub_and_test(i,v) (atomic_sub_return((i),(v)) == 0)
262    
263     -#define ATOMIC_INIT(i) ((atomic_t) { (i) })
264     +#define ATOMIC_INIT(i) { (i) }
265    
266     #define smp_mb__before_atomic_dec() smp_mb()
267     #define smp_mb__after_atomic_dec() smp_mb()
268     @@ -150,7 +150,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
269    
270     #ifdef CONFIG_64BIT
271    
272     -#define ATOMIC64_INIT(i) ((atomic64_t) { (i) })
273     +#define ATOMIC64_INIT(i) { (i) }
274    
275     static __inline__ s64
276     __atomic64_add_return(s64 i, atomic64_t *v)
277     diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
278     index 34b8afe9..ec0b529 100644
279     --- a/arch/powerpc/kernel/asm-offsets.c
280     +++ b/arch/powerpc/kernel/asm-offsets.c
281     @@ -76,6 +76,7 @@ int main(void)
282     DEFINE(SIGSEGV, SIGSEGV);
283     DEFINE(NMI_MASK, NMI_MASK);
284     DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr));
285     + DEFINE(THREAD_DSCR_INHERIT, offsetof(struct thread_struct, dscr_inherit));
286     #else
287     DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));
288     #endif /* CONFIG_PPC64 */
289     diff --git a/arch/powerpc/kernel/dbell.c b/arch/powerpc/kernel/dbell.c
290     index 5b25c80..a892680 100644
291     --- a/arch/powerpc/kernel/dbell.c
292     +++ b/arch/powerpc/kernel/dbell.c
293     @@ -28,6 +28,8 @@ void doorbell_setup_this_cpu(void)
294    
295     void doorbell_cause_ipi(int cpu, unsigned long data)
296     {
297     + /* Order previous accesses vs. msgsnd, which is treated as a store */
298     + mb();
299     ppc_msgsnd(PPC_DBELL, 0, data);
300     }
301    
302     diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
303     index ef2074c..e500969 100644
304     --- a/arch/powerpc/kernel/entry_64.S
305     +++ b/arch/powerpc/kernel/entry_64.S
306     @@ -373,6 +373,12 @@ _GLOBAL(ret_from_fork)
307     li r3,0
308     b syscall_exit
309    
310     + .section ".toc","aw"
311     +DSCR_DEFAULT:
312     + .tc dscr_default[TC],dscr_default
313     +
314     + .section ".text"
315     +
316     /*
317     * This routine switches between two different tasks. The process
318     * state of one is saved on its kernel stack. Then the state
319     @@ -512,9 +518,6 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
320     mr r1,r8 /* start using new stack pointer */
321     std r7,PACAKSAVE(r13)
322    
323     - ld r6,_CCR(r1)
324     - mtcrf 0xFF,r6
325     -
326     #ifdef CONFIG_ALTIVEC
327     BEGIN_FTR_SECTION
328     ld r0,THREAD_VRSAVE(r4)
329     @@ -523,14 +526,22 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
330     #endif /* CONFIG_ALTIVEC */
331     #ifdef CONFIG_PPC64
332     BEGIN_FTR_SECTION
333     + lwz r6,THREAD_DSCR_INHERIT(r4)
334     + ld r7,DSCR_DEFAULT@toc(2)
335     ld r0,THREAD_DSCR(r4)
336     - cmpd r0,r25
337     - beq 1f
338     + cmpwi r6,0
339     + bne 1f
340     + ld r0,0(r7)
341     +1: cmpd r0,r25
342     + beq 2f
343     mtspr SPRN_DSCR,r0
344     -1:
345     +2:
346     END_FTR_SECTION_IFSET(CPU_FTR_DSCR)
347     #endif
348    
349     + ld r6,_CCR(r1)
350     + mtcrf 0xFF,r6
351     +
352     /* r3-r13 are destroyed -- Cort */
353     REST_8GPRS(14, r1)
354     REST_10GPRS(22, r1)
355     diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
356     index 4937c96..94178e5 100644
357     --- a/arch/powerpc/kernel/process.c
358     +++ b/arch/powerpc/kernel/process.c
359     @@ -799,16 +799,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
360     #endif /* CONFIG_PPC_STD_MMU_64 */
361     #ifdef CONFIG_PPC64
362     if (cpu_has_feature(CPU_FTR_DSCR)) {
363     - if (current->thread.dscr_inherit) {
364     - p->thread.dscr_inherit = 1;
365     - p->thread.dscr = current->thread.dscr;
366     - } else if (0 != dscr_default) {
367     - p->thread.dscr_inherit = 1;
368     - p->thread.dscr = dscr_default;
369     - } else {
370     - p->thread.dscr_inherit = 0;
371     - p->thread.dscr = 0;
372     - }
373     + p->thread.dscr_inherit = current->thread.dscr_inherit;
374     + p->thread.dscr = current->thread.dscr;
375     }
376     #endif
377    
378     diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
379     index d9f9441..ab24aee 100644
380     --- a/arch/powerpc/kernel/smp.c
381     +++ b/arch/powerpc/kernel/smp.c
382     @@ -215,8 +215,15 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
383     struct cpu_messages *info = &per_cpu(ipi_message, cpu);
384     char *message = (char *)&info->messages;
385    
386     + /*
387     + * Order previous accesses before accesses in the IPI handler.
388     + */
389     + smp_mb();
390     message[msg] = 1;
391     - mb();
392     + /*
393     + * cause_ipi functions are required to include a full barrier
394     + * before doing whatever causes the IPI.
395     + */
396     smp_ops->cause_ipi(cpu, info->data);
397     }
398    
399     @@ -228,7 +235,7 @@ irqreturn_t smp_ipi_demux(void)
400     mb(); /* order any irq clear */
401    
402     do {
403     - all = xchg_local(&info->messages, 0);
404     + all = xchg(&info->messages, 0);
405    
406     #ifdef __BIG_ENDIAN
407     if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
408     diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
409     index 3529446..8302af6 100644
410     --- a/arch/powerpc/kernel/sysfs.c
411     +++ b/arch/powerpc/kernel/sysfs.c
412     @@ -194,6 +194,14 @@ static ssize_t show_dscr_default(struct device *dev,
413     return sprintf(buf, "%lx\n", dscr_default);
414     }
415    
416     +static void update_dscr(void *dummy)
417     +{
418     + if (!current->thread.dscr_inherit) {
419     + current->thread.dscr = dscr_default;
420     + mtspr(SPRN_DSCR, dscr_default);
421     + }
422     +}
423     +
424     static ssize_t __used store_dscr_default(struct device *dev,
425     struct device_attribute *attr, const char *buf,
426     size_t count)
427     @@ -206,6 +214,8 @@ static ssize_t __used store_dscr_default(struct device *dev,
428     return -EINVAL;
429     dscr_default = val;
430    
431     + on_each_cpu(update_dscr, NULL, 1);
432     +
433     return count;
434     }
435    
436     diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
437     index 1589723..ae0843f 100644
438     --- a/arch/powerpc/kernel/traps.c
439     +++ b/arch/powerpc/kernel/traps.c
440     @@ -972,8 +972,9 @@ static int emulate_instruction(struct pt_regs *regs)
441     cpu_has_feature(CPU_FTR_DSCR)) {
442     PPC_WARN_EMULATED(mtdscr, regs);
443     rd = (instword >> 21) & 0x1f;
444     - mtspr(SPRN_DSCR, regs->gpr[rd]);
445     + current->thread.dscr = regs->gpr[rd];
446     current->thread.dscr_inherit = 1;
447     + mtspr(SPRN_DSCR, current->thread.dscr);
448     return 0;
449     }
450     #endif
451     diff --git a/arch/powerpc/sysdev/xics/icp-hv.c b/arch/powerpc/sysdev/xics/icp-hv.c
452     index 253dce9..762c5ca 100644
453     --- a/arch/powerpc/sysdev/xics/icp-hv.c
454     +++ b/arch/powerpc/sysdev/xics/icp-hv.c
455     @@ -65,7 +65,11 @@ static inline void icp_hv_set_xirr(unsigned int value)
456     static inline void icp_hv_set_qirr(int n_cpu , u8 value)
457     {
458     int hw_cpu = get_hard_smp_processor_id(n_cpu);
459     - long rc = plpar_hcall_norets(H_IPI, hw_cpu, value);
460     + long rc;
461     +
462     + /* Make sure all previous accesses are ordered before IPI sending */
463     + mb();
464     + rc = plpar_hcall_norets(H_IPI, hw_cpu, value);
465     if (rc != H_SUCCESS) {
466     pr_err("%s: bad return code qirr cpu=%d hw_cpu=%d mfrr=0x%x "
467     "returned %ld\n", __func__, n_cpu, hw_cpu, value, rc);
468     diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
469     index 8a2ce8f..82746f9 100644
470     --- a/arch/x86/kernel/microcode_amd.c
471     +++ b/arch/x86/kernel/microcode_amd.c
472     @@ -143,11 +143,12 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr,
473     unsigned int *current_size)
474     {
475     struct microcode_header_amd *mc_hdr;
476     - unsigned int actual_size;
477     + unsigned int actual_size, patch_size;
478     u16 equiv_cpu_id;
479    
480     /* size of the current patch we're staring at */
481     - *current_size = *(u32 *)(ucode_ptr + 4) + SECTION_HDR_SIZE;
482     + patch_size = *(u32 *)(ucode_ptr + 4);
483     + *current_size = patch_size + SECTION_HDR_SIZE;
484    
485     equiv_cpu_id = find_equiv_id();
486     if (!equiv_cpu_id)
487     @@ -174,7 +175,7 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr,
488     /*
489     * now that the header looks sane, verify its size
490     */
491     - actual_size = verify_ucode_size(cpu, *current_size, leftover_size);
492     + actual_size = verify_ucode_size(cpu, patch_size, leftover_size);
493     if (!actual_size)
494     return 0;
495    
496     diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
497     index f6679a7..b91e485 100644
498     --- a/arch/x86/mm/hugetlbpage.c
499     +++ b/arch/x86/mm/hugetlbpage.c
500     @@ -56,9 +56,16 @@ static int vma_shareable(struct vm_area_struct *vma, unsigned long addr)
501     }
502    
503     /*
504     - * search for a shareable pmd page for hugetlb.
505     + * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
506     + * and returns the corresponding pte. While this is not necessary for the
507     + * !shared pmd case because we can allocate the pmd later as well, it makes the
508     + * code much cleaner. pmd allocation is essential for the shared case because
509     + * pud has to be populated inside the same i_mmap_mutex section - otherwise
510     + * racing tasks could either miss the sharing (see huge_pte_offset) or select a
511     + * bad pmd for sharing.
512     */
513     -static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
514     +static pte_t *
515     +huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
516     {
517     struct vm_area_struct *vma = find_vma(mm, addr);
518     struct address_space *mapping = vma->vm_file->f_mapping;
519     @@ -68,9 +75,10 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
520     struct vm_area_struct *svma;
521     unsigned long saddr;
522     pte_t *spte = NULL;
523     + pte_t *pte;
524    
525     if (!vma_shareable(vma, addr))
526     - return;
527     + return (pte_t *)pmd_alloc(mm, pud, addr);
528    
529     mutex_lock(&mapping->i_mmap_mutex);
530     vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
531     @@ -97,7 +105,9 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
532     put_page(virt_to_page(spte));
533     spin_unlock(&mm->page_table_lock);
534     out:
535     + pte = (pte_t *)pmd_alloc(mm, pud, addr);
536     mutex_unlock(&mapping->i_mmap_mutex);
537     + return pte;
538     }
539    
540     /*
541     @@ -142,8 +152,9 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
542     } else {
543     BUG_ON(sz != PMD_SIZE);
544     if (pud_none(*pud))
545     - huge_pmd_share(mm, addr, pud);
546     - pte = (pte_t *) pmd_alloc(mm, pud, addr);
547     + pte = huge_pmd_share(mm, addr, pud);
548     + else
549     + pte = (pte_t *)pmd_alloc(mm, pud, addr);
550     }
551     }
552     BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
553     diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
554     index dd29a9e..fd1f103 100644
555     --- a/arch/x86/syscalls/syscall_64.tbl
556     +++ b/arch/x86/syscalls/syscall_64.tbl
557     @@ -60,8 +60,8 @@
558     51 common getsockname sys_getsockname
559     52 common getpeername sys_getpeername
560     53 common socketpair sys_socketpair
561     -54 common setsockopt sys_setsockopt
562     -55 common getsockopt sys_getsockopt
563     +54 64 setsockopt sys_setsockopt
564     +55 64 getsockopt sys_getsockopt
565     56 common clone stub_clone
566     57 common fork stub_fork
567     58 common vfork stub_vfork
568     @@ -351,3 +351,5 @@
569     538 x32 sendmmsg compat_sys_sendmmsg
570     539 x32 process_vm_readv compat_sys_process_vm_readv
571     540 x32 process_vm_writev compat_sys_process_vm_writev
572     +541 x32 setsockopt compat_sys_setsockopt
573     +542 x32 getsockopt compat_sys_getsockopt
574     diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
575     index 1ba8dff..99de967 100644
576     --- a/arch/x86/xen/setup.c
577     +++ b/arch/x86/xen/setup.c
578     @@ -79,9 +79,16 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
579     memblock_reserve(start, size);
580    
581     xen_max_p2m_pfn = PFN_DOWN(start + size);
582     + for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) {
583     + unsigned long mfn = pfn_to_mfn(pfn);
584     +
585     + if (WARN(mfn == pfn, "Trying to over-write 1-1 mapping (pfn: %lx)\n", pfn))
586     + continue;
587     + WARN(mfn != INVALID_P2M_ENTRY, "Trying to remove %lx which has %lx mfn!\n",
588     + pfn, mfn);
589    
590     - for (pfn = PFN_DOWN(start); pfn <= xen_max_p2m_pfn; pfn++)
591     __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
592     + }
593     }
594    
595     static unsigned long __init xen_release_chunk(unsigned long start,
596     diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
597     index abcc641..33214d7 100644
598     --- a/drivers/acpi/acpica/tbxface.c
599     +++ b/drivers/acpi/acpica/tbxface.c
600     @@ -436,6 +436,7 @@ acpi_get_table_with_size(char *signature,
601    
602     return (AE_NOT_FOUND);
603     }
604     +ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
605    
606     acpi_status
607     acpi_get_table(char *signature,
608     diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
609     index acda773..38aa6dd 100644
610     --- a/drivers/block/cciss_scsi.c
611     +++ b/drivers/block/cciss_scsi.c
612     @@ -763,16 +763,7 @@ static void complete_scsi_command(CommandList_struct *c, int timeout,
613     {
614     case CMD_TARGET_STATUS:
615     /* Pass it up to the upper layers... */
616     - if( ei->ScsiStatus)
617     - {
618     -#if 0
619     - printk(KERN_WARNING "cciss: cmd %p "
620     - "has SCSI Status = %x\n",
621     - c, ei->ScsiStatus);
622     -#endif
623     - cmd->result |= (ei->ScsiStatus << 1);
624     - }
625     - else { /* scsi status is zero??? How??? */
626     + if (!ei->ScsiStatus) {
627    
628     /* Ordinarily, this case should never happen, but there is a bug
629     in some released firmware revisions that allows it to happen
630     diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
631     index 2ca8d3f..bb787d8 100644
632     --- a/drivers/dma/imx-dma.c
633     +++ b/drivers/dma/imx-dma.c
634     @@ -172,8 +172,7 @@ struct imxdma_engine {
635     struct device_dma_parameters dma_parms;
636     struct dma_device dma_device;
637     void __iomem *base;
638     - struct clk *dma_ahb;
639     - struct clk *dma_ipg;
640     + struct clk *dma_clk;
641     spinlock_t lock;
642     struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS];
643     struct imxdma_channel channel[IMX_DMA_CHANNELS];
644     @@ -977,20 +976,10 @@ static int __init imxdma_probe(struct platform_device *pdev)
645     return 0;
646     }
647    
648     - imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg");
649     - if (IS_ERR(imxdma->dma_ipg)) {
650     - ret = PTR_ERR(imxdma->dma_ipg);
651     - goto err_clk;
652     - }
653     -
654     - imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb");
655     - if (IS_ERR(imxdma->dma_ahb)) {
656     - ret = PTR_ERR(imxdma->dma_ahb);
657     - goto err_clk;
658     - }
659     -
660     - clk_prepare_enable(imxdma->dma_ipg);
661     - clk_prepare_enable(imxdma->dma_ahb);
662     + imxdma->dma_clk = clk_get(NULL, "dma");
663     + if (IS_ERR(imxdma->dma_clk))
664     + return PTR_ERR(imxdma->dma_clk);
665     + clk_enable(imxdma->dma_clk);
666    
667     /* reset DMA module */
668     imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR);
669     @@ -999,14 +988,16 @@ static int __init imxdma_probe(struct platform_device *pdev)
670     ret = request_irq(MX1_DMA_INT, dma_irq_handler, 0, "DMA", imxdma);
671     if (ret) {
672     dev_warn(imxdma->dev, "Can't register IRQ for DMA\n");
673     - goto err_enable;
674     + kfree(imxdma);
675     + return ret;
676     }
677    
678     ret = request_irq(MX1_DMA_ERR, imxdma_err_handler, 0, "DMA", imxdma);
679     if (ret) {
680     dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n");
681     free_irq(MX1_DMA_INT, NULL);
682     - goto err_enable;
683     + kfree(imxdma);
684     + return ret;
685     }
686     }
687    
688     @@ -1103,10 +1094,7 @@ err_init:
689     free_irq(MX1_DMA_INT, NULL);
690     free_irq(MX1_DMA_ERR, NULL);
691     }
692     -err_enable:
693     - clk_disable_unprepare(imxdma->dma_ipg);
694     - clk_disable_unprepare(imxdma->dma_ahb);
695     -err_clk:
696     +
697     kfree(imxdma);
698     return ret;
699     }
700     @@ -1126,9 +1114,7 @@ static int __exit imxdma_remove(struct platform_device *pdev)
701     free_irq(MX1_DMA_ERR, NULL);
702     }
703    
704     - clk_disable_unprepare(imxdma->dma_ipg);
705     - clk_disable_unprepare(imxdma->dma_ahb);
706     - kfree(imxdma);
707     + kfree(imxdma);
708    
709     return 0;
710     }
711     diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
712     index 80c6e8b..df6a4db 100644
713     --- a/drivers/gpu/drm/radeon/radeon_object.c
714     +++ b/drivers/gpu/drm/radeon/radeon_object.c
715     @@ -136,6 +136,7 @@ int radeon_bo_create(struct radeon_device *rdev,
716     acc_size = ttm_bo_dma_acc_size(&rdev->mman.bdev, size,
717     sizeof(struct radeon_bo));
718    
719     +retry:
720     bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
721     if (bo == NULL)
722     return -ENOMEM;
723     @@ -149,8 +150,6 @@ int radeon_bo_create(struct radeon_device *rdev,
724     bo->surface_reg = -1;
725     INIT_LIST_HEAD(&bo->list);
726     INIT_LIST_HEAD(&bo->va);
727     -
728     -retry:
729     radeon_ttm_placement_from_domain(bo, domain);
730     /* Kernel allocation are uninterruptible */
731     mutex_lock(&rdev->vram_mutex);
732     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
733     index ee24d21..7279b3e 100644
734     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
735     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
736     @@ -182,6 +182,7 @@ static struct pci_device_id vmw_pci_id_list[] = {
737     {0x15ad, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VMWGFX_CHIP_SVGAII},
738     {0, 0, 0}
739     };
740     +MODULE_DEVICE_TABLE(pci, vmw_pci_id_list);
741    
742     static int enable_fbdev;
743    
744     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
745     index 2286d47..00fb5aa 100644
746     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
747     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
748     @@ -1688,15 +1688,19 @@ int vmw_du_page_flip(struct drm_crtc *crtc,
749     struct vmw_private *dev_priv = vmw_priv(crtc->dev);
750     struct drm_framebuffer *old_fb = crtc->fb;
751     struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(fb);
752     - struct drm_file *file_priv = event->base.file_priv;
753     + struct drm_file *file_priv ;
754     struct vmw_fence_obj *fence = NULL;
755     struct drm_clip_rect clips;
756     int ret;
757    
758     + if (event == NULL)
759     + return -EINVAL;
760     +
761     /* require ScreenObject support for page flipping */
762     if (!dev_priv->sou_priv)
763     return -ENOSYS;
764    
765     + file_priv = event->base.file_priv;
766     if (!vmw_kms_screen_object_flippable(dev_priv, crtc))
767     return -EINVAL;
768    
769     diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
770     index 82f61ee..dc9697c 100644
771     --- a/drivers/hid/usbhid/hid-quirks.c
772     +++ b/drivers/hid/usbhid/hid-quirks.c
773     @@ -70,6 +70,7 @@ static const struct hid_blacklist {
774     { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
775     { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
776     { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
777     + { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
778     { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS },
779     { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS },
780     { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS },
781     diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
782     index 351d1f4..4ee5789 100644
783     --- a/drivers/hwmon/asus_atk0110.c
784     +++ b/drivers/hwmon/asus_atk0110.c
785     @@ -34,6 +34,12 @@ static const struct dmi_system_id __initconst atk_force_new_if[] = {
786     .matches = {
787     DMI_MATCH(DMI_BOARD_NAME, "SABERTOOTH X58")
788     }
789     + }, {
790     + /* Old interface reads the same sensor for fan0 and fan1 */
791     + .ident = "Asus M5A78L",
792     + .matches = {
793     + DMI_MATCH(DMI_BOARD_NAME, "M5A78L")
794     + }
795     },
796     { }
797     };
798     diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
799     index d2c5095..ea8736b 100644
800     --- a/drivers/i2c/busses/Kconfig
801     +++ b/drivers/i2c/busses/Kconfig
802     @@ -104,6 +104,7 @@ config I2C_I801
803     DH89xxCC (PCH)
804     Panther Point (PCH)
805     Lynx Point (PCH)
806     + Lynx Point-LP (PCH)
807    
808     This driver can also be built as a module. If so, the module
809     will be called i2c-i801.
810     @@ -350,9 +351,13 @@ config I2C_DAVINCI
811     devices such as DaVinci NIC.
812     For details please see http://www.ti.com/davinci
813    
814     +config I2C_DESIGNWARE_CORE
815     + tristate
816     +
817     config I2C_DESIGNWARE_PLATFORM
818     tristate "Synopsys DesignWare Platfrom"
819     depends on HAVE_CLK
820     + select I2C_DESIGNWARE_CORE
821     help
822     If you say yes to this option, support will be included for the
823     Synopsys DesignWare I2C adapter. Only master mode is supported.
824     @@ -363,6 +368,7 @@ config I2C_DESIGNWARE_PLATFORM
825     config I2C_DESIGNWARE_PCI
826     tristate "Synopsys DesignWare PCI"
827     depends on PCI
828     + select I2C_DESIGNWARE_CORE
829     help
830     If you say yes to this option, support will be included for the
831     Synopsys DesignWare I2C adapter. Only master mode is supported.
832     diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
833     index 569567b..2f05d7b 100644
834     --- a/drivers/i2c/busses/Makefile
835     +++ b/drivers/i2c/busses/Makefile
836     @@ -33,10 +33,11 @@ obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
837     obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
838     obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
839     obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
840     +obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o
841     obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
842     -i2c-designware-platform-objs := i2c-designware-platdrv.o i2c-designware-core.o
843     +i2c-designware-platform-objs := i2c-designware-platdrv.o
844     obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
845     -i2c-designware-pci-objs := i2c-designware-pcidrv.o i2c-designware-core.o
846     +i2c-designware-pci-objs := i2c-designware-pcidrv.o
847     obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
848     obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
849     obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
850     diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
851     index df87992..6193349 100644
852     --- a/drivers/i2c/busses/i2c-designware-core.c
853     +++ b/drivers/i2c/busses/i2c-designware-core.c
854     @@ -25,6 +25,7 @@
855     * ----------------------------------------------------------------------------
856     *
857     */
858     +#include <linux/export.h>
859     #include <linux/clk.h>
860     #include <linux/errno.h>
861     #include <linux/err.h>
862     @@ -305,6 +306,7 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
863     dw_writel(dev, dev->master_cfg , DW_IC_CON);
864     return 0;
865     }
866     +EXPORT_SYMBOL_GPL(i2c_dw_init);
867    
868     /*
869     * Waiting for bus not busy
870     @@ -557,12 +559,14 @@ done:
871    
872     return ret;
873     }
874     +EXPORT_SYMBOL_GPL(i2c_dw_xfer);
875    
876     u32 i2c_dw_func(struct i2c_adapter *adap)
877     {
878     struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
879     return dev->functionality;
880     }
881     +EXPORT_SYMBOL_GPL(i2c_dw_func);
882    
883     static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
884     {
885     @@ -667,17 +671,20 @@ tx_aborted:
886    
887     return IRQ_HANDLED;
888     }
889     +EXPORT_SYMBOL_GPL(i2c_dw_isr);
890    
891     void i2c_dw_enable(struct dw_i2c_dev *dev)
892     {
893     /* Enable the adapter */
894     dw_writel(dev, 1, DW_IC_ENABLE);
895     }
896     +EXPORT_SYMBOL_GPL(i2c_dw_enable);
897    
898     u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev)
899     {
900     return dw_readl(dev, DW_IC_ENABLE);
901     }
902     +EXPORT_SYMBOL_GPL(i2c_dw_is_enabled);
903    
904     void i2c_dw_disable(struct dw_i2c_dev *dev)
905     {
906     @@ -688,18 +695,22 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
907     dw_writel(dev, 0, DW_IC_INTR_MASK);
908     dw_readl(dev, DW_IC_CLR_INTR);
909     }
910     +EXPORT_SYMBOL_GPL(i2c_dw_disable);
911    
912     void i2c_dw_clear_int(struct dw_i2c_dev *dev)
913     {
914     dw_readl(dev, DW_IC_CLR_INTR);
915     }
916     +EXPORT_SYMBOL_GPL(i2c_dw_clear_int);
917    
918     void i2c_dw_disable_int(struct dw_i2c_dev *dev)
919     {
920     dw_writel(dev, 0, DW_IC_INTR_MASK);
921     }
922     +EXPORT_SYMBOL_GPL(i2c_dw_disable_int);
923    
924     u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
925     {
926     return dw_readl(dev, DW_IC_COMP_PARAM_1);
927     }
928     +EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
929     diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
930     index ae2945a..d88ec81 100644
931     --- a/drivers/i2c/busses/i2c-i801.c
932     +++ b/drivers/i2c/busses/i2c-i801.c
933     @@ -52,6 +52,7 @@
934     DH89xxCC (PCH) 0x2330 32 hard yes yes yes
935     Panther Point (PCH) 0x1e22 32 hard yes yes yes
936     Lynx Point (PCH) 0x8c22 32 hard yes yes yes
937     + Lynx Point-LP (PCH) 0x9c22 32 hard yes yes yes
938    
939     Features supported by this driver:
940     Software PEC no
941     @@ -147,6 +148,7 @@
942     #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330
943     #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30
944     #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22
945     +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22
946    
947     struct i801_priv {
948     struct i2c_adapter adapter;
949     @@ -636,6 +638,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
950     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) },
951     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) },
952     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) },
953     + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS) },
954     { 0, }
955     };
956    
957     diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
958     index 5ec774d..6918773 100644
959     --- a/drivers/input/serio/i8042-x86ia64io.h
960     +++ b/drivers/input/serio/i8042-x86ia64io.h
961     @@ -177,6 +177,20 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
962     },
963     },
964     {
965     + /* Gigabyte T1005 - defines wrong chassis type ("Other") */
966     + .matches = {
967     + DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
968     + DMI_MATCH(DMI_PRODUCT_NAME, "T1005"),
969     + },
970     + },
971     + {
972     + /* Gigabyte T1005M/P - defines wrong chassis type ("Other") */
973     + .matches = {
974     + DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
975     + DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"),
976     + },
977     + },
978     + {
979     .matches = {
980     DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
981     DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
982     diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
983     index 664e460..aac6222 100644
984     --- a/drivers/media/dvb/siano/smsusb.c
985     +++ b/drivers/media/dvb/siano/smsusb.c
986     @@ -481,7 +481,7 @@ static int smsusb_resume(struct usb_interface *intf)
987     return 0;
988     }
989    
990     -static const struct usb_device_id smsusb_id_table[] __devinitconst = {
991     +static const struct usb_device_id smsusb_id_table[] = {
992     { USB_DEVICE(0x187f, 0x0010),
993     .driver_info = SMS1XXX_BOARD_SIANO_STELLAR },
994     { USB_DEVICE(0x187f, 0x0100),
995     diff --git a/drivers/media/video/gspca/jl2005bcd.c b/drivers/media/video/gspca/jl2005bcd.c
996     index 53f58ef..3264d87 100644
997     --- a/drivers/media/video/gspca/jl2005bcd.c
998     +++ b/drivers/media/video/gspca/jl2005bcd.c
999     @@ -510,7 +510,7 @@ static const struct sd_desc sd_desc = {
1000     };
1001    
1002     /* -- module initialisation -- */
1003     -static const __devinitdata struct usb_device_id device_table[] = {
1004     +static const struct usb_device_id device_table[] = {
1005     {USB_DEVICE(0x0979, 0x0227)},
1006     {}
1007     };
1008     diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
1009     index 54eed87..21e6a37 100644
1010     --- a/drivers/media/video/gspca/spca506.c
1011     +++ b/drivers/media/video/gspca/spca506.c
1012     @@ -685,7 +685,7 @@ static const struct sd_desc sd_desc = {
1013     };
1014    
1015     /* -- module initialisation -- */
1016     -static const struct usb_device_id device_table[] __devinitconst = {
1017     +static const struct usb_device_id device_table[] = {
1018     {USB_DEVICE(0x06e1, 0xa190)},
1019     /*fixme: may be IntelPCCameraPro BRIDGE_SPCA505
1020     {USB_DEVICE(0x0733, 0x0430)}, */
1021     diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
1022     index 8f54e24..4261bf2 100644
1023     --- a/drivers/media/video/uvc/uvc_queue.c
1024     +++ b/drivers/media/video/uvc/uvc_queue.c
1025     @@ -355,6 +355,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
1026     if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) {
1027     buf->error = 0;
1028     buf->state = UVC_BUF_STATE_QUEUED;
1029     + buf->bytesused = 0;
1030     vb2_set_plane_payload(&buf->buf, 0, 0);
1031     return buf;
1032     }
1033     diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
1034     index a2f7ae8..90b8527 100644
1035     --- a/drivers/net/wireless/ath/ath9k/recv.c
1036     +++ b/drivers/net/wireless/ath/ath9k/recv.c
1037     @@ -1774,7 +1774,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1038     struct ieee80211_hw *hw = sc->hw;
1039     struct ieee80211_hdr *hdr;
1040     int retval;
1041     - bool decrypt_error = false;
1042     struct ath_rx_status rs;
1043     enum ath9k_rx_qtype qtype;
1044     bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1045     @@ -1796,6 +1795,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1046     tsf_lower = tsf & 0xffffffff;
1047    
1048     do {
1049     + bool decrypt_error = false;
1050     /* If handling rx interrupt and flush is in progress => exit */
1051     if ((sc->sc_flags & SC_OP_RXFLUSH) && (flush == 0))
1052     break;
1053     diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
1054     index f4d28c3..a337a50 100644
1055     --- a/drivers/net/wireless/p54/p54usb.c
1056     +++ b/drivers/net/wireless/p54/p54usb.c
1057     @@ -42,7 +42,7 @@ MODULE_FIRMWARE("isl3887usb");
1058     * whenever you add a new device.
1059     */
1060    
1061     -static struct usb_device_id p54u_table[] __devinitdata = {
1062     +static struct usb_device_id p54u_table[] = {
1063     /* Version 1 devices (pci chip + net2280) */
1064     {USB_DEVICE(0x0411, 0x0050)}, /* Buffalo WLI2-USB2-G54 */
1065     {USB_DEVICE(0x045e, 0x00c2)}, /* Microsoft MN-710 */
1066     diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c
1067     index cf53ac9..86467a2 100644
1068     --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
1069     +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
1070     @@ -44,7 +44,7 @@ MODULE_AUTHOR("Larry Finger <Larry.Finger@lwfinger.net>");
1071     MODULE_DESCRIPTION("RTL8187/RTL8187B USB wireless driver");
1072     MODULE_LICENSE("GPL");
1073    
1074     -static struct usb_device_id rtl8187_table[] __devinitdata = {
1075     +static struct usb_device_id rtl8187_table[] = {
1076     /* Asus */
1077     {USB_DEVICE(0x0b05, 0x171d), .driver_info = DEVICE_RTL8187},
1078     /* Belkin */
1079     diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
1080     index 3cd3f45..54fc988 100644
1081     --- a/drivers/pci/pci-driver.c
1082     +++ b/drivers/pci/pci-driver.c
1083     @@ -952,6 +952,13 @@ static int pci_pm_poweroff_noirq(struct device *dev)
1084     if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
1085     pci_prepare_to_sleep(pci_dev);
1086    
1087     + /*
1088     + * The reason for doing this here is the same as for the analogous code
1089     + * in pci_pm_suspend_noirq().
1090     + */
1091     + if (pci_dev->class == PCI_CLASS_SERIAL_USB_EHCI)
1092     + pci_write_config_word(pci_dev, PCI_COMMAND, 0);
1093     +
1094     return 0;
1095     }
1096    
1097     diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
1098     index 30d2072..33471e1 100644
1099     --- a/drivers/rapidio/devices/tsi721.c
1100     +++ b/drivers/rapidio/devices/tsi721.c
1101     @@ -439,6 +439,9 @@ static void tsi721_db_dpc(struct work_struct *work)
1102     " info %4.4x\n", DBELL_SID(idb.bytes),
1103     DBELL_TID(idb.bytes), DBELL_INF(idb.bytes));
1104     }
1105     +
1106     + wr_ptr = ioread32(priv->regs +
1107     + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE;
1108     }
1109    
1110     iowrite32(rd_ptr & (IDB_QSIZE - 1),
1111     @@ -449,6 +452,10 @@ static void tsi721_db_dpc(struct work_struct *work)
1112     regval |= TSI721_SR_CHINT_IDBQRCV;
1113     iowrite32(regval,
1114     priv->regs + TSI721_SR_CHINTE(IDB_QUEUE));
1115     +
1116     + wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE;
1117     + if (wr_ptr != rd_ptr)
1118     + schedule_work(&priv->idb_work);
1119     }
1120    
1121     /**
1122     @@ -2155,7 +2162,7 @@ static int __devinit tsi721_probe(struct pci_dev *pdev,
1123     const struct pci_device_id *id)
1124     {
1125     struct tsi721_device *priv;
1126     - int i, cap;
1127     + int cap;
1128     int err;
1129     u32 regval;
1130    
1131     @@ -2175,12 +2182,15 @@ static int __devinit tsi721_probe(struct pci_dev *pdev,
1132     priv->pdev = pdev;
1133    
1134     #ifdef DEBUG
1135     + {
1136     + int i;
1137     for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
1138     dev_dbg(&pdev->dev, "res[%d] @ 0x%llx (0x%lx, 0x%lx)\n",
1139     i, (unsigned long long)pci_resource_start(pdev, i),
1140     (unsigned long)pci_resource_len(pdev, i),
1141     pci_resource_flags(pdev, i));
1142     }
1143     + }
1144     #endif
1145     /*
1146     * Verify BAR configuration
1147     diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
1148     index 9cdfc38..1eb7a15 100644
1149     --- a/drivers/regulator/twl-regulator.c
1150     +++ b/drivers/regulator/twl-regulator.c
1151     @@ -1085,7 +1085,7 @@ TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1152     TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1153     TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1154     TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1155     -TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1156     +TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08);
1157     TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1158     TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1159     TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1160     @@ -1166,7 +1166,7 @@ static const struct of_device_id twl_of_match[] __devinitconst = {
1161     TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1162     TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1163     TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1164     - TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1165     + TWLFIXED_OF_MATCH("ti,twl4030-vintana1", VINTANA1),
1166     TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1167     TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1168     TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1169     diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
1170     index 8b300be..6308a8d 100644
1171     --- a/drivers/scsi/megaraid/megaraid_sas_base.c
1172     +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
1173     @@ -4066,7 +4066,6 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1174     spin_lock_init(&instance->cmd_pool_lock);
1175     spin_lock_init(&instance->hba_lock);
1176     spin_lock_init(&instance->completion_lock);
1177     - spin_lock_init(&poll_aen_lock);
1178    
1179     mutex_init(&instance->aen_mutex);
1180     mutex_init(&instance->reset_mutex);
1181     @@ -5392,6 +5391,8 @@ static int __init megasas_init(void)
1182     printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION,
1183     MEGASAS_EXT_VERSION);
1184    
1185     + spin_lock_init(&poll_aen_lock);
1186     +
1187     support_poll_for_event = 2;
1188     support_device_change = 1;
1189    
1190     diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
1191     index 3f03342..c4cef56 100644
1192     --- a/drivers/scsi/mpt2sas/mpt2sas_base.c
1193     +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
1194     @@ -2417,10 +2417,13 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1195     }
1196    
1197     /* command line tunables for max controller queue depth */
1198     - if (max_queue_depth != -1)
1199     - max_request_credit = (max_queue_depth < facts->RequestCredit)
1200     - ? max_queue_depth : facts->RequestCredit;
1201     - else
1202     + if (max_queue_depth != -1 && max_queue_depth != 0) {
1203     + max_request_credit = min_t(u16, max_queue_depth +
1204     + ioc->hi_priority_depth + ioc->internal_depth,
1205     + facts->RequestCredit);
1206     + if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
1207     + max_request_credit = MAX_HBA_QUEUE_DEPTH;
1208     + } else
1209     max_request_credit = min_t(u16, facts->RequestCredit,
1210     MAX_HBA_QUEUE_DEPTH);
1211    
1212     @@ -2495,7 +2498,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1213     /* set the scsi host can_queue depth
1214     * with some internal commands that could be outstanding
1215     */
1216     - ioc->shost->can_queue = ioc->scsiio_depth - (2);
1217     + ioc->shost->can_queue = ioc->scsiio_depth;
1218     dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
1219     "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
1220    
1221     diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
1222     index cc8dc8c..b3f0b0f 100644
1223     --- a/drivers/scsi/scsi_error.c
1224     +++ b/drivers/scsi/scsi_error.c
1225     @@ -42,6 +42,8 @@
1226    
1227     #include <trace/events/scsi.h>
1228    
1229     +static void scsi_eh_done(struct scsi_cmnd *scmd);
1230     +
1231     #define SENSE_TIMEOUT (10*HZ)
1232    
1233     /*
1234     @@ -241,6 +243,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
1235     if (! scsi_command_normalize_sense(scmd, &sshdr))
1236     return FAILED; /* no valid sense data */
1237    
1238     + if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
1239     + /*
1240     + * nasty: for mid-layer issued TURs, we need to return the
1241     + * actual sense data without any recovery attempt. For eh
1242     + * issued ones, we need to try to recover and interpret
1243     + */
1244     + return SUCCESS;
1245     +
1246     if (scsi_sense_is_deferred(&sshdr))
1247     return NEEDS_RETRY;
1248    
1249     diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
1250     index 1929146..2bc0362 100644
1251     --- a/drivers/scsi/scsi_lib.c
1252     +++ b/drivers/scsi/scsi_lib.c
1253     @@ -760,7 +760,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1254     }
1255    
1256     if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */
1257     - req->errors = result;
1258     if (result) {
1259     if (sense_valid && req->sense) {
1260     /*
1261     @@ -776,6 +775,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1262     if (!sense_deferred)
1263     error = __scsi_error_from_host_byte(cmd, result);
1264     }
1265     + /*
1266     + * __scsi_error_from_host_byte may have reset the host_byte
1267     + */
1268     + req->errors = cmd->result;
1269    
1270     req->resid_len = scsi_get_resid(cmd);
1271    
1272     diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
1273     index 8906557..348840e 100644
1274     --- a/drivers/scsi/scsi_scan.c
1275     +++ b/drivers/scsi/scsi_scan.c
1276     @@ -776,6 +776,16 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
1277     sdev->model = (char *) (sdev->inquiry + 16);
1278     sdev->rev = (char *) (sdev->inquiry + 32);
1279    
1280     + if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
1281     + /*
1282     + * sata emulation layer device. This is a hack to work around
1283     + * the SATL power management specifications which state that
1284     + * when the SATL detects the device has gone into standby
1285     + * mode, it shall respond with NOT READY.
1286     + */
1287     + sdev->allow_restart = 1;
1288     + }
1289     +
1290     if (*bflags & BLIST_ISROM) {
1291     sdev->type = TYPE_ROM;
1292     sdev->removable = 1;
1293     diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
1294     index 763e028..8739454 100644
1295     --- a/drivers/staging/vt6656/main_usb.c
1296     +++ b/drivers/staging/vt6656/main_usb.c
1297     @@ -222,7 +222,7 @@ DEVICE_PARAM(b80211hEnable, "802.11h mode");
1298     // Static vars definitions
1299     //
1300    
1301     -static struct usb_device_id vt6656_table[] __devinitdata = {
1302     +static struct usb_device_id vt6656_table[] = {
1303     {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
1304     {}
1305     };
1306     diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
1307     index c3751a7..9160049 100644
1308     --- a/drivers/staging/winbond/wbusb.c
1309     +++ b/drivers/staging/winbond/wbusb.c
1310     @@ -25,7 +25,7 @@ MODULE_DESCRIPTION("IS89C35 802.11bg WLAN USB Driver");
1311     MODULE_LICENSE("GPL");
1312     MODULE_VERSION("0.1");
1313    
1314     -static const struct usb_device_id wb35_table[] __devinitconst = {
1315     +static const struct usb_device_id wb35_table[] = {
1316     { USB_DEVICE(0x0416, 0x0035) },
1317     { USB_DEVICE(0x18E8, 0x6201) },
1318     { USB_DEVICE(0x18E8, 0x6206) },
1319     diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
1320     index 0686d61..222f1c5 100644
1321     --- a/drivers/target/target_core_transport.c
1322     +++ b/drivers/target/target_core_transport.c
1323     @@ -3675,9 +3675,9 @@ transport_generic_get_mem(struct se_cmd *cmd)
1324     return 0;
1325    
1326     out:
1327     - while (i >= 0) {
1328     - __free_page(sg_page(&cmd->t_data_sg[i]));
1329     + while (i > 0) {
1330     i--;
1331     + __free_page(sg_page(&cmd->t_data_sg[i]));
1332     }
1333     kfree(cmd->t_data_sg);
1334     cmd->t_data_sg = NULL;
1335     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1336     index 640cf79..1b632cb 100644
1337     --- a/drivers/usb/class/cdc-acm.c
1338     +++ b/drivers/usb/class/cdc-acm.c
1339     @@ -1104,7 +1104,8 @@ skip_normal_probe:
1340     }
1341    
1342    
1343     - if (data_interface->cur_altsetting->desc.bNumEndpoints < 2)
1344     + if (data_interface->cur_altsetting->desc.bNumEndpoints < 2 ||
1345     + control_interface->cur_altsetting->desc.bNumEndpoints == 0)
1346     return -EINVAL;
1347    
1348     epctrl = &control_interface->cur_altsetting->endpoint[0].desc;
1349     diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
1350     index 4e0f167..8be96de 100644
1351     --- a/drivers/usb/misc/emi62.c
1352     +++ b/drivers/usb/misc/emi62.c
1353     @@ -256,7 +256,7 @@ wraperr:
1354     return err;
1355     }
1356    
1357     -static const struct usb_device_id id_table[] __devinitconst = {
1358     +static const struct usb_device_id id_table[] = {
1359     { USB_DEVICE(EMI62_VENDOR_ID, EMI62_PRODUCT_ID) },
1360     { } /* Terminating entry */
1361     };
1362     diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
1363     index 1afb4fb..4d51948 100644
1364     --- a/drivers/xen/swiotlb-xen.c
1365     +++ b/drivers/xen/swiotlb-xen.c
1366     @@ -232,7 +232,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
1367     return ret;
1368    
1369     if (hwdev && hwdev->coherent_dma_mask)
1370     - dma_mask = hwdev->coherent_dma_mask;
1371     + dma_mask = dma_alloc_coherent_mask(hwdev, flags);
1372    
1373     phys = virt_to_phys(ret);
1374     dev_addr = xen_phys_to_bus(phys);
1375     diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
1376     index 097e536..0334272 100644
1377     --- a/drivers/xen/xen-pciback/pci_stub.c
1378     +++ b/drivers/xen/xen-pciback/pci_stub.c
1379     @@ -353,16 +353,16 @@ static int __devinit pcistub_init_device(struct pci_dev *dev)
1380     if (err)
1381     goto config_release;
1382    
1383     - dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");
1384     - __pci_reset_function_locked(dev);
1385     -
1386     /* We need the device active to save the state. */
1387     dev_dbg(&dev->dev, "save state of device\n");
1388     pci_save_state(dev);
1389     dev_data->pci_saved_state = pci_store_saved_state(dev);
1390     if (!dev_data->pci_saved_state)
1391     dev_err(&dev->dev, "Could not store PCI conf saved state!\n");
1392     -
1393     + else {
1394     + dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");
1395     + __pci_reset_function_locked(dev);
1396     + }
1397     /* Now disable the device (this also ensures some private device
1398     * data is setup before we export)
1399     */
1400     diff --git a/fs/buffer.c b/fs/buffer.c
1401     index 0bc1bed..18669e9 100644
1402     --- a/fs/buffer.c
1403     +++ b/fs/buffer.c
1404     @@ -914,7 +914,7 @@ link_dev_buffers(struct page *page, struct buffer_head *head)
1405     /*
1406     * Initialise the state of a blockdev page's buffers.
1407     */
1408     -static void
1409     +static sector_t
1410     init_page_buffers(struct page *page, struct block_device *bdev,
1411     sector_t block, int size)
1412     {
1413     @@ -936,33 +936,41 @@ init_page_buffers(struct page *page, struct block_device *bdev,
1414     block++;
1415     bh = bh->b_this_page;
1416     } while (bh != head);
1417     +
1418     + /*
1419     + * Caller needs to validate requested block against end of device.
1420     + */
1421     + return end_block;
1422     }
1423    
1424     /*
1425     * Create the page-cache page that contains the requested block.
1426     *
1427     - * This is user purely for blockdev mappings.
1428     + * This is used purely for blockdev mappings.
1429     */
1430     -static struct page *
1431     +static int
1432     grow_dev_page(struct block_device *bdev, sector_t block,
1433     - pgoff_t index, int size)
1434     + pgoff_t index, int size, int sizebits)
1435     {
1436     struct inode *inode = bdev->bd_inode;
1437     struct page *page;
1438     struct buffer_head *bh;
1439     + sector_t end_block;
1440     + int ret = 0; /* Will call free_more_memory() */
1441    
1442     page = find_or_create_page(inode->i_mapping, index,
1443     (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
1444     if (!page)
1445     - return NULL;
1446     + return ret;
1447    
1448     BUG_ON(!PageLocked(page));
1449    
1450     if (page_has_buffers(page)) {
1451     bh = page_buffers(page);
1452     if (bh->b_size == size) {
1453     - init_page_buffers(page, bdev, block, size);
1454     - return page;
1455     + end_block = init_page_buffers(page, bdev,
1456     + index << sizebits, size);
1457     + goto done;
1458     }
1459     if (!try_to_free_buffers(page))
1460     goto failed;
1461     @@ -982,14 +990,14 @@ grow_dev_page(struct block_device *bdev, sector_t block,
1462     */
1463     spin_lock(&inode->i_mapping->private_lock);
1464     link_dev_buffers(page, bh);
1465     - init_page_buffers(page, bdev, block, size);
1466     + end_block = init_page_buffers(page, bdev, index << sizebits, size);
1467     spin_unlock(&inode->i_mapping->private_lock);
1468     - return page;
1469     -
1470     +done:
1471     + ret = (block < end_block) ? 1 : -ENXIO;
1472     failed:
1473     unlock_page(page);
1474     page_cache_release(page);
1475     - return NULL;
1476     + return ret;
1477     }
1478    
1479     /*
1480     @@ -999,7 +1007,6 @@ failed:
1481     static int
1482     grow_buffers(struct block_device *bdev, sector_t block, int size)
1483     {
1484     - struct page *page;
1485     pgoff_t index;
1486     int sizebits;
1487    
1488     @@ -1023,22 +1030,14 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
1489     bdevname(bdev, b));
1490     return -EIO;
1491     }
1492     - block = index << sizebits;
1493     +
1494     /* Create a page with the proper size buffers.. */
1495     - page = grow_dev_page(bdev, block, index, size);
1496     - if (!page)
1497     - return 0;
1498     - unlock_page(page);
1499     - page_cache_release(page);
1500     - return 1;
1501     + return grow_dev_page(bdev, block, index, size, sizebits);
1502     }
1503    
1504     static struct buffer_head *
1505     __getblk_slow(struct block_device *bdev, sector_t block, int size)
1506     {
1507     - int ret;
1508     - struct buffer_head *bh;
1509     -
1510     /* Size must be multiple of hard sectorsize */
1511     if (unlikely(size & (bdev_logical_block_size(bdev)-1) ||
1512     (size < 512 || size > PAGE_SIZE))) {
1513     @@ -1051,21 +1050,20 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
1514     return NULL;
1515     }
1516    
1517     -retry:
1518     - bh = __find_get_block(bdev, block, size);
1519     - if (bh)
1520     - return bh;
1521     + for (;;) {
1522     + struct buffer_head *bh;
1523     + int ret;
1524    
1525     - ret = grow_buffers(bdev, block, size);
1526     - if (ret == 0) {
1527     - free_more_memory();
1528     - goto retry;
1529     - } else if (ret > 0) {
1530     bh = __find_get_block(bdev, block, size);
1531     if (bh)
1532     return bh;
1533     +
1534     + ret = grow_buffers(bdev, block, size);
1535     + if (ret < 0)
1536     + return NULL;
1537     + if (ret == 0)
1538     + free_more_memory();
1539     }
1540     - return NULL;
1541     }
1542    
1543     /*
1544     @@ -1321,10 +1319,6 @@ EXPORT_SYMBOL(__find_get_block);
1545     * which corresponds to the passed block_device, block and size. The
1546     * returned buffer has its reference count incremented.
1547     *
1548     - * __getblk() cannot fail - it just keeps trying. If you pass it an
1549     - * illegal block number, __getblk() will happily return a buffer_head
1550     - * which represents the non-existent block. Very weird.
1551     - *
1552     * __getblk() will lock up the machine if grow_dev_page's try_to_free_buffers()
1553     * attempt is failing. FIXME, perhaps?
1554     */
1555     diff --git a/fs/compat.c b/fs/compat.c
1556     index f2944ac..2b371b3 100644
1557     --- a/fs/compat.c
1558     +++ b/fs/compat.c
1559     @@ -1160,11 +1160,14 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
1560     struct file *file;
1561     int fput_needed;
1562     ssize_t ret;
1563     + loff_t pos;
1564    
1565     file = fget_light(fd, &fput_needed);
1566     if (!file)
1567     return -EBADF;
1568     - ret = compat_readv(file, vec, vlen, &file->f_pos);
1569     + pos = file->f_pos;
1570     + ret = compat_readv(file, vec, vlen, &pos);
1571     + file->f_pos = pos;
1572     fput_light(file, fput_needed);
1573     return ret;
1574     }
1575     @@ -1226,11 +1229,14 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
1576     struct file *file;
1577     int fput_needed;
1578     ssize_t ret;
1579     + loff_t pos;
1580    
1581     file = fget_light(fd, &fput_needed);
1582     if (!file)
1583     return -EBADF;
1584     - ret = compat_writev(file, vec, vlen, &file->f_pos);
1585     + pos = file->f_pos;
1586     + ret = compat_writev(file, vec, vlen, &pos);
1587     + file->f_pos = pos;
1588     fput_light(file, fput_needed);
1589     return ret;
1590     }
1591     diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
1592     index 10d7812..0752817 100644
1593     --- a/fs/ext3/inode.c
1594     +++ b/fs/ext3/inode.c
1595     @@ -3068,6 +3068,8 @@ static int ext3_do_update_inode(handle_t *handle,
1596     struct ext3_inode_info *ei = EXT3_I(inode);
1597     struct buffer_head *bh = iloc->bh;
1598     int err = 0, rc, block;
1599     + int need_datasync = 0;
1600     + __le32 disksize;
1601    
1602     again:
1603     /* we can't allow multiple procs in here at once, its a bit racey */
1604     @@ -3105,7 +3107,11 @@ again:
1605     raw_inode->i_gid_high = 0;
1606     }
1607     raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
1608     - raw_inode->i_size = cpu_to_le32(ei->i_disksize);
1609     + disksize = cpu_to_le32(ei->i_disksize);
1610     + if (disksize != raw_inode->i_size) {
1611     + need_datasync = 1;
1612     + raw_inode->i_size = disksize;
1613     + }
1614     raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
1615     raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
1616     raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
1617     @@ -3121,8 +3127,11 @@ again:
1618     if (!S_ISREG(inode->i_mode)) {
1619     raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
1620     } else {
1621     - raw_inode->i_size_high =
1622     - cpu_to_le32(ei->i_disksize >> 32);
1623     + disksize = cpu_to_le32(ei->i_disksize >> 32);
1624     + if (disksize != raw_inode->i_size_high) {
1625     + raw_inode->i_size_high = disksize;
1626     + need_datasync = 1;
1627     + }
1628     if (ei->i_disksize > 0x7fffffffULL) {
1629     struct super_block *sb = inode->i_sb;
1630     if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
1631     @@ -3175,6 +3184,8 @@ again:
1632     ext3_clear_inode_state(inode, EXT3_STATE_NEW);
1633    
1634     atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid);
1635     + if (need_datasync)
1636     + atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);
1637     out_brelse:
1638     brelse (bh);
1639     ext3_std_error(inode->i_sb, err);
1640     diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
1641     index 7df2b5e..f4246cf 100644
1642     --- a/fs/fuse/dev.c
1643     +++ b/fs/fuse/dev.c
1644     @@ -1576,6 +1576,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
1645     req->pages[req->num_pages] = page;
1646     req->num_pages++;
1647    
1648     + offset = 0;
1649     num -= this_num;
1650     total_len += this_num;
1651     index++;
1652     diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
1653     index 929ba01..9131b17 100644
1654     --- a/fs/nfs/idmap.c
1655     +++ b/fs/nfs/idmap.c
1656     @@ -63,6 +63,12 @@ struct idmap {
1657     struct mutex idmap_mutex;
1658     };
1659    
1660     +struct idmap_legacy_upcalldata {
1661     + struct rpc_pipe_msg pipe_msg;
1662     + struct idmap_msg idmap_msg;
1663     + struct idmap *idmap;
1664     +};
1665     +
1666     /**
1667     * nfs_fattr_init_names - initialise the nfs_fattr owner_name/group_name fields
1668     * @fattr: fully initialised struct nfs_fattr
1669     @@ -326,6 +332,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen,
1670     ret = nfs_idmap_request_key(&key_type_id_resolver_legacy,
1671     name, namelen, type, data,
1672     data_size, idmap);
1673     + idmap->idmap_key_cons = NULL;
1674     mutex_unlock(&idmap->idmap_mutex);
1675     }
1676     return ret;
1677     @@ -383,11 +390,13 @@ static const match_table_t nfs_idmap_tokens = {
1678     static int nfs_idmap_legacy_upcall(struct key_construction *, const char *, void *);
1679     static ssize_t idmap_pipe_downcall(struct file *, const char __user *,
1680     size_t);
1681     +static void idmap_release_pipe(struct inode *);
1682     static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
1683    
1684     static const struct rpc_pipe_ops idmap_upcall_ops = {
1685     .upcall = rpc_pipe_generic_upcall,
1686     .downcall = idmap_pipe_downcall,
1687     + .release_pipe = idmap_release_pipe,
1688     .destroy_msg = idmap_pipe_destroy_msg,
1689     };
1690    
1691     @@ -603,7 +612,8 @@ void nfs_idmap_quit(void)
1692     nfs_idmap_quit_keyring();
1693     }
1694    
1695     -static int nfs_idmap_prepare_message(char *desc, struct idmap_msg *im,
1696     +static int nfs_idmap_prepare_message(char *desc, struct idmap *idmap,
1697     + struct idmap_msg *im,
1698     struct rpc_pipe_msg *msg)
1699     {
1700     substring_t substr;
1701     @@ -646,6 +656,7 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
1702     const char *op,
1703     void *aux)
1704     {
1705     + struct idmap_legacy_upcalldata *data;
1706     struct rpc_pipe_msg *msg;
1707     struct idmap_msg *im;
1708     struct idmap *idmap = (struct idmap *)aux;
1709     @@ -653,15 +664,15 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
1710     int ret = -ENOMEM;
1711    
1712     /* msg and im are freed in idmap_pipe_destroy_msg */
1713     - msg = kmalloc(sizeof(*msg), GFP_KERNEL);
1714     - if (!msg)
1715     - goto out0;
1716     -
1717     - im = kmalloc(sizeof(*im), GFP_KERNEL);
1718     - if (!im)
1719     + data = kmalloc(sizeof(*data), GFP_KERNEL);
1720     + if (!data)
1721     goto out1;
1722    
1723     - ret = nfs_idmap_prepare_message(key->description, im, msg);
1724     + msg = &data->pipe_msg;
1725     + im = &data->idmap_msg;
1726     + data->idmap = idmap;
1727     +
1728     + ret = nfs_idmap_prepare_message(key->description, idmap, im, msg);
1729     if (ret < 0)
1730     goto out2;
1731    
1732     @@ -670,15 +681,15 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
1733    
1734     ret = rpc_queue_upcall(idmap->idmap_pipe, msg);
1735     if (ret < 0)
1736     - goto out2;
1737     + goto out3;
1738    
1739     return ret;
1740    
1741     +out3:
1742     + idmap->idmap_key_cons = NULL;
1743     out2:
1744     - kfree(im);
1745     + kfree(data);
1746     out1:
1747     - kfree(msg);
1748     -out0:
1749     complete_request_key(cons, ret);
1750     return ret;
1751     }
1752     @@ -736,9 +747,8 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
1753     }
1754    
1755     if (!(im.im_status & IDMAP_STATUS_SUCCESS)) {
1756     - ret = mlen;
1757     - complete_request_key(cons, -ENOKEY);
1758     - goto out_incomplete;
1759     + ret = -ENOKEY;
1760     + goto out;
1761     }
1762    
1763     namelen_in = strnlen(im.im_name, IDMAP_NAMESZ);
1764     @@ -755,16 +765,32 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
1765    
1766     out:
1767     complete_request_key(cons, ret);
1768     -out_incomplete:
1769     return ret;
1770     }
1771    
1772     static void
1773     idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
1774     {
1775     + struct idmap_legacy_upcalldata *data = container_of(msg,
1776     + struct idmap_legacy_upcalldata,
1777     + pipe_msg);
1778     + struct idmap *idmap = data->idmap;
1779     + struct key_construction *cons;
1780     + if (msg->errno) {
1781     + cons = ACCESS_ONCE(idmap->idmap_key_cons);
1782     + idmap->idmap_key_cons = NULL;
1783     + complete_request_key(cons, msg->errno);
1784     + }
1785     /* Free memory allocated in nfs_idmap_legacy_upcall() */
1786     - kfree(msg->data);
1787     - kfree(msg);
1788     + kfree(data);
1789     +}
1790     +
1791     +static void
1792     +idmap_release_pipe(struct inode *inode)
1793     +{
1794     + struct rpc_inode *rpci = RPC_I(inode);
1795     + struct idmap *idmap = (struct idmap *)rpci->private;
1796     + idmap->idmap_key_cons = NULL;
1797     }
1798    
1799     int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
1800     diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
1801     index 5242eae..a1e416b 100644
1802     --- a/fs/nfs/nfs3proc.c
1803     +++ b/fs/nfs/nfs3proc.c
1804     @@ -69,7 +69,7 @@ do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
1805     nfs_fattr_init(info->fattr);
1806     status = rpc_call_sync(client, &msg, 0);
1807     dprintk("%s: reply fsinfo: %d\n", __func__, status);
1808     - if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
1809     + if (status == 0 && !(info->fattr->valid & NFS_ATTR_FATTR)) {
1810     msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
1811     msg.rpc_resp = info->fattr;
1812     status = rpc_call_sync(client, &msg, 0);
1813     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
1814     index d60c2d8..dc57324 100644
1815     --- a/fs/nfs/nfs4proc.c
1816     +++ b/fs/nfs/nfs4proc.c
1817     @@ -5966,11 +5966,58 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)
1818     dprintk("<-- %s\n", __func__);
1819     }
1820    
1821     +static size_t max_response_pages(struct nfs_server *server)
1822     +{
1823     + u32 max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
1824     + return nfs_page_array_len(0, max_resp_sz);
1825     +}
1826     +
1827     +static void nfs4_free_pages(struct page **pages, size_t size)
1828     +{
1829     + int i;
1830     +
1831     + if (!pages)
1832     + return;
1833     +
1834     + for (i = 0; i < size; i++) {
1835     + if (!pages[i])
1836     + break;
1837     + __free_page(pages[i]);
1838     + }
1839     + kfree(pages);
1840     +}
1841     +
1842     +static struct page **nfs4_alloc_pages(size_t size, gfp_t gfp_flags)
1843     +{
1844     + struct page **pages;
1845     + int i;
1846     +
1847     + pages = kcalloc(size, sizeof(struct page *), gfp_flags);
1848     + if (!pages) {
1849     + dprintk("%s: can't alloc array of %zu pages\n", __func__, size);
1850     + return NULL;
1851     + }
1852     +
1853     + for (i = 0; i < size; i++) {
1854     + pages[i] = alloc_page(gfp_flags);
1855     + if (!pages[i]) {
1856     + dprintk("%s: failed to allocate page\n", __func__);
1857     + nfs4_free_pages(pages, size);
1858     + return NULL;
1859     + }
1860     + }
1861     +
1862     + return pages;
1863     +}
1864     +
1865     static void nfs4_layoutget_release(void *calldata)
1866     {
1867     struct nfs4_layoutget *lgp = calldata;
1868     + struct nfs_server *server = NFS_SERVER(lgp->args.inode);
1869     + size_t max_pages = max_response_pages(server);
1870    
1871     dprintk("--> %s\n", __func__);
1872     + nfs4_free_pages(lgp->args.layout.pages, max_pages);
1873     put_nfs_open_context(lgp->args.ctx);
1874     kfree(calldata);
1875     dprintk("<-- %s\n", __func__);
1876     @@ -5982,9 +6029,10 @@ static const struct rpc_call_ops nfs4_layoutget_call_ops = {
1877     .rpc_release = nfs4_layoutget_release,
1878     };
1879    
1880     -int nfs4_proc_layoutget(struct nfs4_layoutget *lgp)
1881     +int nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags)
1882     {
1883     struct nfs_server *server = NFS_SERVER(lgp->args.inode);
1884     + size_t max_pages = max_response_pages(server);
1885     struct rpc_task *task;
1886     struct rpc_message msg = {
1887     .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LAYOUTGET],
1888     @@ -6002,6 +6050,13 @@ int nfs4_proc_layoutget(struct nfs4_layoutget *lgp)
1889    
1890     dprintk("--> %s\n", __func__);
1891    
1892     + lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
1893     + if (!lgp->args.layout.pages) {
1894     + nfs4_layoutget_release(lgp);
1895     + return -ENOMEM;
1896     + }
1897     + lgp->args.layout.pglen = max_pages * PAGE_SIZE;
1898     +
1899     lgp->res.layoutp = &lgp->args.layout;
1900     lgp->res.seq_res.sr_slot = NULL;
1901     nfs41_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0);
1902     @@ -6047,12 +6102,8 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
1903     return;
1904     }
1905     spin_lock(&lo->plh_inode->i_lock);
1906     - if (task->tk_status == 0) {
1907     - if (lrp->res.lrs_present) {
1908     - pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
1909     - } else
1910     - BUG_ON(!list_empty(&lo->plh_segs));
1911     - }
1912     + if (task->tk_status == 0 && lrp->res.lrs_present)
1913     + pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
1914     lo->plh_block_lgets--;
1915     spin_unlock(&lo->plh_inode->i_lock);
1916     dprintk("<-- %s\n", __func__);
1917     diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
1918     index 38512bc..059e2c3 100644
1919     --- a/fs/nfs/pnfs.c
1920     +++ b/fs/nfs/pnfs.c
1921     @@ -574,9 +574,6 @@ send_layoutget(struct pnfs_layout_hdr *lo,
1922     struct nfs_server *server = NFS_SERVER(ino);
1923     struct nfs4_layoutget *lgp;
1924     struct pnfs_layout_segment *lseg = NULL;
1925     - struct page **pages = NULL;
1926     - int i;
1927     - u32 max_resp_sz, max_pages;
1928    
1929     dprintk("--> %s\n", __func__);
1930    
1931     @@ -585,20 +582,6 @@ send_layoutget(struct pnfs_layout_hdr *lo,
1932     if (lgp == NULL)
1933     return NULL;
1934    
1935     - /* allocate pages for xdr post processing */
1936     - max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
1937     - max_pages = nfs_page_array_len(0, max_resp_sz);
1938     -
1939     - pages = kcalloc(max_pages, sizeof(struct page *), gfp_flags);
1940     - if (!pages)
1941     - goto out_err_free;
1942     -
1943     - for (i = 0; i < max_pages; i++) {
1944     - pages[i] = alloc_page(gfp_flags);
1945     - if (!pages[i])
1946     - goto out_err_free;
1947     - }
1948     -
1949     lgp->args.minlength = PAGE_CACHE_SIZE;
1950     if (lgp->args.minlength > range->length)
1951     lgp->args.minlength = range->length;
1952     @@ -607,39 +590,19 @@ send_layoutget(struct pnfs_layout_hdr *lo,
1953     lgp->args.type = server->pnfs_curr_ld->id;
1954     lgp->args.inode = ino;
1955     lgp->args.ctx = get_nfs_open_context(ctx);
1956     - lgp->args.layout.pages = pages;
1957     - lgp->args.layout.pglen = max_pages * PAGE_SIZE;
1958     lgp->lsegpp = &lseg;
1959     lgp->gfp_flags = gfp_flags;
1960    
1961     /* Synchronously retrieve layout information from server and
1962     * store in lseg.
1963     */
1964     - nfs4_proc_layoutget(lgp);
1965     + nfs4_proc_layoutget(lgp, gfp_flags);
1966     if (!lseg) {
1967     /* remember that LAYOUTGET failed and suspend trying */
1968     set_bit(lo_fail_bit(range->iomode), &lo->plh_flags);
1969     }
1970    
1971     - /* free xdr pages */
1972     - for (i = 0; i < max_pages; i++)
1973     - __free_page(pages[i]);
1974     - kfree(pages);
1975     -
1976     return lseg;
1977     -
1978     -out_err_free:
1979     - /* free any allocated xdr pages, lgp as it's not used */
1980     - if (pages) {
1981     - for (i = 0; i < max_pages; i++) {
1982     - if (!pages[i])
1983     - break;
1984     - __free_page(pages[i]);
1985     - }
1986     - kfree(pages);
1987     - }
1988     - kfree(lgp);
1989     - return NULL;
1990     }
1991    
1992     /* Initiates a LAYOUTRETURN(FILE) */
1993     diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
1994     index 442ebf6..8d95818 100644
1995     --- a/fs/nfs/pnfs.h
1996     +++ b/fs/nfs/pnfs.h
1997     @@ -161,7 +161,7 @@ extern int nfs4_proc_getdevicelist(struct nfs_server *server,
1998     struct pnfs_devicelist *devlist);
1999     extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
2000     struct pnfs_device *dev);
2001     -extern int nfs4_proc_layoutget(struct nfs4_layoutget *lgp);
2002     +extern int nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags);
2003     extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
2004    
2005     /* pnfs.c */
2006     diff --git a/fs/nfs/super.c b/fs/nfs/super.c
2007     index 4ac7fca..7b55f51 100644
2008     --- a/fs/nfs/super.c
2009     +++ b/fs/nfs/super.c
2010     @@ -3146,4 +3146,6 @@ static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type,
2011     return res;
2012     }
2013    
2014     +MODULE_ALIAS("nfs4");
2015     +
2016     #endif /* CONFIG_NFS_V4 */
2017     diff --git a/fs/open.c b/fs/open.c
2018     index 3f1108b..cf1d34f 100644
2019     --- a/fs/open.c
2020     +++ b/fs/open.c
2021     @@ -882,9 +882,10 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
2022     int lookup_flags = 0;
2023     int acc_mode;
2024    
2025     - if (!(flags & O_CREAT))
2026     - mode = 0;
2027     - op->mode = mode;
2028     + if (flags & O_CREAT)
2029     + op->mode = (mode & S_IALLUGO) | S_IFREG;
2030     + else
2031     + op->mode = 0;
2032    
2033     /* Must never be set by userspace */
2034     flags &= ~FMODE_NONOTIFY;
2035     diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
2036     index 9f71765..28e3de1 100644
2037     --- a/fs/ubifs/debug.h
2038     +++ b/fs/ubifs/debug.h
2039     @@ -170,7 +170,7 @@ struct ubifs_global_debug_info {
2040     #define ubifs_dbg_msg(type, fmt, ...) \
2041     pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)
2042    
2043     -#define DBG_KEY_BUF_LEN 32
2044     +#define DBG_KEY_BUF_LEN 48
2045     #define ubifs_dbg_msg_key(type, key, fmt, ...) do { \
2046     char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
2047     pr_debug("UBIFS DBG " type ": " fmt "%s\n", ##__VA_ARGS__, \
2048     diff --git a/fs/udf/file.c b/fs/udf/file.c
2049     index 7f3f7ba..d1c6093 100644
2050     --- a/fs/udf/file.c
2051     +++ b/fs/udf/file.c
2052     @@ -39,20 +39,24 @@
2053     #include "udf_i.h"
2054     #include "udf_sb.h"
2055    
2056     -static int udf_adinicb_readpage(struct file *file, struct page *page)
2057     +static void __udf_adinicb_readpage(struct page *page)
2058     {
2059     struct inode *inode = page->mapping->host;
2060     char *kaddr;
2061     struct udf_inode_info *iinfo = UDF_I(inode);
2062    
2063     - BUG_ON(!PageLocked(page));
2064     -
2065     kaddr = kmap(page);
2066     - memset(kaddr, 0, PAGE_CACHE_SIZE);
2067     memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
2068     + memset(kaddr + inode->i_size, 0, PAGE_CACHE_SIZE - inode->i_size);
2069     flush_dcache_page(page);
2070     SetPageUptodate(page);
2071     kunmap(page);
2072     +}
2073     +
2074     +static int udf_adinicb_readpage(struct file *file, struct page *page)
2075     +{
2076     + BUG_ON(!PageLocked(page));
2077     + __udf_adinicb_readpage(page);
2078     unlock_page(page);
2079    
2080     return 0;
2081     @@ -77,6 +81,25 @@ static int udf_adinicb_writepage(struct page *page,
2082     return 0;
2083     }
2084    
2085     +static int udf_adinicb_write_begin(struct file *file,
2086     + struct address_space *mapping, loff_t pos,
2087     + unsigned len, unsigned flags, struct page **pagep,
2088     + void **fsdata)
2089     +{
2090     + struct page *page;
2091     +
2092     + if (WARN_ON_ONCE(pos >= PAGE_CACHE_SIZE))
2093     + return -EIO;
2094     + page = grab_cache_page_write_begin(mapping, 0, flags);
2095     + if (!page)
2096     + return -ENOMEM;
2097     + *pagep = page;
2098     +
2099     + if (!PageUptodate(page) && len != PAGE_CACHE_SIZE)
2100     + __udf_adinicb_readpage(page);
2101     + return 0;
2102     +}
2103     +
2104     static int udf_adinicb_write_end(struct file *file,
2105     struct address_space *mapping,
2106     loff_t pos, unsigned len, unsigned copied,
2107     @@ -98,8 +121,8 @@ static int udf_adinicb_write_end(struct file *file,
2108     const struct address_space_operations udf_adinicb_aops = {
2109     .readpage = udf_adinicb_readpage,
2110     .writepage = udf_adinicb_writepage,
2111     - .write_begin = simple_write_begin,
2112     - .write_end = udf_adinicb_write_end,
2113     + .write_begin = udf_adinicb_write_begin,
2114     + .write_end = udf_adinicb_write_end,
2115     };
2116    
2117     static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2118     diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
2119     index 5bf0790..31fdc48 100644
2120     --- a/kernel/audit_tree.c
2121     +++ b/kernel/audit_tree.c
2122     @@ -250,7 +250,6 @@ static void untag_chunk(struct node *p)
2123     spin_unlock(&hash_lock);
2124     spin_unlock(&entry->lock);
2125     fsnotify_destroy_mark(entry);
2126     - fsnotify_put_mark(entry);
2127     goto out;
2128     }
2129    
2130     @@ -259,7 +258,7 @@ static void untag_chunk(struct node *p)
2131    
2132     fsnotify_duplicate_mark(&new->mark, entry);
2133     if (fsnotify_add_mark(&new->mark, new->mark.group, new->mark.i.inode, NULL, 1)) {
2134     - free_chunk(new);
2135     + fsnotify_put_mark(&new->mark);
2136     goto Fallback;
2137     }
2138    
2139     @@ -293,7 +292,6 @@ static void untag_chunk(struct node *p)
2140     spin_unlock(&hash_lock);
2141     spin_unlock(&entry->lock);
2142     fsnotify_destroy_mark(entry);
2143     - fsnotify_put_mark(entry);
2144     goto out;
2145    
2146     Fallback:
2147     @@ -322,7 +320,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
2148    
2149     entry = &chunk->mark;
2150     if (fsnotify_add_mark(entry, audit_tree_group, inode, NULL, 0)) {
2151     - free_chunk(chunk);
2152     + fsnotify_put_mark(entry);
2153     return -ENOSPC;
2154     }
2155    
2156     @@ -332,6 +330,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
2157     spin_unlock(&hash_lock);
2158     chunk->dead = 1;
2159     spin_unlock(&entry->lock);
2160     + fsnotify_get_mark(entry);
2161     fsnotify_destroy_mark(entry);
2162     fsnotify_put_mark(entry);
2163     return 0;
2164     @@ -396,7 +395,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
2165     fsnotify_duplicate_mark(chunk_entry, old_entry);
2166     if (fsnotify_add_mark(chunk_entry, chunk_entry->group, chunk_entry->i.inode, NULL, 1)) {
2167     spin_unlock(&old_entry->lock);
2168     - free_chunk(chunk);
2169     + fsnotify_put_mark(chunk_entry);
2170     fsnotify_put_mark(old_entry);
2171     return -ENOSPC;
2172     }
2173     @@ -412,6 +411,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
2174     spin_unlock(&chunk_entry->lock);
2175     spin_unlock(&old_entry->lock);
2176    
2177     + fsnotify_get_mark(chunk_entry);
2178     fsnotify_destroy_mark(chunk_entry);
2179    
2180     fsnotify_put_mark(chunk_entry);
2181     @@ -445,7 +445,6 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
2182     spin_unlock(&old_entry->lock);
2183     fsnotify_destroy_mark(old_entry);
2184     fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */
2185     - fsnotify_put_mark(old_entry); /* and kill it */
2186     return 0;
2187     }
2188    
2189     diff --git a/kernel/sched/core.c b/kernel/sched/core.c
2190     index 817bf70..ef6a8f2 100644
2191     --- a/kernel/sched/core.c
2192     +++ b/kernel/sched/core.c
2193     @@ -3084,6 +3084,20 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
2194     # define nsecs_to_cputime(__nsecs) nsecs_to_jiffies(__nsecs)
2195     #endif
2196    
2197     +static cputime_t scale_utime(cputime_t utime, cputime_t rtime, cputime_t total)
2198     +{
2199     + u64 temp = (__force u64) rtime;
2200     +
2201     + temp *= (__force u64) utime;
2202     +
2203     + if (sizeof(cputime_t) == 4)
2204     + temp = div_u64(temp, (__force u32) total);
2205     + else
2206     + temp = div64_u64(temp, (__force u64) total);
2207     +
2208     + return (__force cputime_t) temp;
2209     +}
2210     +
2211     void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
2212     {
2213     cputime_t rtime, utime = p->utime, total = utime + p->stime;
2214     @@ -3093,13 +3107,9 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
2215     */
2216     rtime = nsecs_to_cputime(p->se.sum_exec_runtime);
2217    
2218     - if (total) {
2219     - u64 temp = (__force u64) rtime;
2220     -
2221     - temp *= (__force u64) utime;
2222     - do_div(temp, (__force u32) total);
2223     - utime = (__force cputime_t) temp;
2224     - } else
2225     + if (total)
2226     + utime = scale_utime(utime, rtime, total);
2227     + else
2228     utime = rtime;
2229    
2230     /*
2231     @@ -3126,13 +3136,9 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
2232     total = cputime.utime + cputime.stime;
2233     rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
2234    
2235     - if (total) {
2236     - u64 temp = (__force u64) rtime;
2237     -
2238     - temp *= (__force u64) cputime.utime;
2239     - do_div(temp, (__force u32) total);
2240     - utime = (__force cputime_t) temp;
2241     - } else
2242     + if (total)
2243     + utime = scale_utime(cputime.utime, rtime, total);
2244     + else
2245     utime = rtime;
2246    
2247     sig->prev_utime = max(sig->prev_utime, utime);
2248     @@ -7011,6 +7017,7 @@ int in_sched_functions(unsigned long addr)
2249    
2250     #ifdef CONFIG_CGROUP_SCHED
2251     struct task_group root_task_group;
2252     +LIST_HEAD(task_groups);
2253     #endif
2254    
2255     DECLARE_PER_CPU(cpumask_var_t, load_balance_tmpmask);
2256     diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
2257     index 116ced0..d9637f4 100644
2258     --- a/kernel/sched/sched.h
2259     +++ b/kernel/sched/sched.h
2260     @@ -80,7 +80,7 @@ extern struct mutex sched_domains_mutex;
2261     struct cfs_rq;
2262     struct rt_rq;
2263    
2264     -static LIST_HEAD(task_groups);
2265     +extern struct list_head task_groups;
2266    
2267     struct cfs_bandwidth {
2268     #ifdef CONFIG_CFS_BANDWIDTH
2269     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
2270     index bf5b485..9afcbad 100644
2271     --- a/mm/mempolicy.c
2272     +++ b/mm/mempolicy.c
2273     @@ -2536,7 +2536,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
2274     break;
2275    
2276     default:
2277     - BUG();
2278     + return -EINVAL;
2279     }
2280    
2281     l = strlen(policy_modes[mode]);
2282     diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
2283     index 1266f78..25edda0 100644
2284     --- a/net/bluetooth/hci_event.c
2285     +++ b/net/bluetooth/hci_event.c
2286     @@ -1357,6 +1357,9 @@ static bool hci_resolve_next_name(struct hci_dev *hdev)
2287     return false;
2288    
2289     e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
2290     + if (!e)
2291     + return false;
2292     +
2293     if (hci_resolve_name(hdev, e) == 0) {
2294     e->name_state = NAME_PENDING;
2295     return true;
2296     @@ -1385,12 +1388,20 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
2297     return;
2298    
2299     e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING);
2300     - if (e) {
2301     + /* If the device was not found in a list of found devices names of which
2302     + * are pending. there is no need to continue resolving a next name as it
2303     + * will be done upon receiving another Remote Name Request Complete
2304     + * Event */
2305     + if (!e)
2306     + return;
2307     +
2308     + list_del(&e->list);
2309     + if (name) {
2310     e->name_state = NAME_KNOWN;
2311     - list_del(&e->list);
2312     - if (name)
2313     - mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00,
2314     - e->data.rssi, name, name_len);
2315     + mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00,
2316     + e->data.rssi, name, name_len);
2317     + } else {
2318     + e->name_state = NAME_NOT_KNOWN;
2319     }
2320    
2321     if (hci_resolve_next_name(hdev))
2322     @@ -1749,7 +1760,12 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
2323     if (conn->type == ACL_LINK) {
2324     conn->state = BT_CONFIG;
2325     hci_conn_hold(conn);
2326     - conn->disc_timeout = HCI_DISCONN_TIMEOUT;
2327     +
2328     + if (!conn->out && !hci_conn_ssp_enabled(conn) &&
2329     + !hci_find_link_key(hdev, &ev->bdaddr))
2330     + conn->disc_timeout = HCI_PAIRING_TIMEOUT;
2331     + else
2332     + conn->disc_timeout = HCI_DISCONN_TIMEOUT;
2333     } else
2334     conn->state = BT_CONNECTED;
2335    
2336     diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
2337     index 6f9c25b..9a86759 100644
2338     --- a/net/bluetooth/l2cap_core.c
2339     +++ b/net/bluetooth/l2cap_core.c
2340     @@ -893,6 +893,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
2341     sk = chan->sk;
2342    
2343     hci_conn_hold(conn->hcon);
2344     + conn->hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
2345    
2346     bacpy(&bt_sk(sk)->src, conn->src);
2347     bacpy(&bt_sk(sk)->dst, conn->dst);
2348     diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
2349     index 75c3582..fb85d37 100644
2350     --- a/net/dccp/ccid.h
2351     +++ b/net/dccp/ccid.h
2352     @@ -246,7 +246,7 @@ static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
2353     u32 __user *optval, int __user *optlen)
2354     {
2355     int rc = -ENOPROTOOPT;
2356     - if (ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
2357     + if (ccid != NULL && ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
2358     rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
2359     optval, optlen);
2360     return rc;
2361     @@ -257,7 +257,7 @@ static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
2362     u32 __user *optval, int __user *optlen)
2363     {
2364     int rc = -ENOPROTOOPT;
2365     - if (ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
2366     + if (ccid != NULL && ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
2367     rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
2368     optval, optlen);
2369     return rc;
2370     diff --git a/net/socket.c b/net/socket.c
2371     index 573b261..06ffa0f 100644
2372     --- a/net/socket.c
2373     +++ b/net/socket.c
2374     @@ -2605,7 +2605,7 @@ static int do_siocgstamp(struct net *net, struct socket *sock,
2375     err = sock_do_ioctl(net, sock, cmd, (unsigned long)&ktv);
2376     set_fs(old_fs);
2377     if (!err)
2378     - err = compat_put_timeval(up, &ktv);
2379     + err = compat_put_timeval(&ktv, up);
2380    
2381     return err;
2382     }
2383     @@ -2621,7 +2621,7 @@ static int do_siocgstampns(struct net *net, struct socket *sock,
2384     err = sock_do_ioctl(net, sock, cmd, (unsigned long)&kts);
2385     set_fs(old_fs);
2386     if (!err)
2387     - err = compat_put_timespec(up, &kts);
2388     + err = compat_put_timespec(&kts, up);
2389    
2390     return err;
2391     }
2392     diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
2393     index 4bda09d..fd9b288 100644
2394     --- a/net/sunrpc/svc_xprt.c
2395     +++ b/net/sunrpc/svc_xprt.c
2396     @@ -316,7 +316,6 @@ static bool svc_xprt_has_something_to_do(struct svc_xprt *xprt)
2397     */
2398     void svc_xprt_enqueue(struct svc_xprt *xprt)
2399     {
2400     - struct svc_serv *serv = xprt->xpt_server;
2401     struct svc_pool *pool;
2402     struct svc_rqst *rqstp;
2403     int cpu;
2404     @@ -362,8 +361,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
2405     rqstp, rqstp->rq_xprt);
2406     rqstp->rq_xprt = xprt;
2407     svc_xprt_get(xprt);
2408     - rqstp->rq_reserved = serv->sv_max_mesg;
2409     - atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
2410     pool->sp_stats.threads_woken++;
2411     wake_up(&rqstp->rq_wait);
2412     } else {
2413     @@ -643,8 +640,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
2414     if (xprt) {
2415     rqstp->rq_xprt = xprt;
2416     svc_xprt_get(xprt);
2417     - rqstp->rq_reserved = serv->sv_max_mesg;
2418     - atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
2419    
2420     /* As there is a shortage of threads and this request
2421     * had to be queued, don't allow the thread to wait so
2422     @@ -741,6 +736,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
2423     else
2424     len = xprt->xpt_ops->xpo_recvfrom(rqstp);
2425     dprintk("svc: got len=%d\n", len);
2426     + rqstp->rq_reserved = serv->sv_max_mesg;
2427     + atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
2428     }
2429     svc_xprt_received(xprt);
2430    
2431     @@ -797,7 +794,8 @@ int svc_send(struct svc_rqst *rqstp)
2432    
2433     /* Grab mutex to serialize outgoing data. */
2434     mutex_lock(&xprt->xpt_mutex);
2435     - if (test_bit(XPT_DEAD, &xprt->xpt_flags))
2436     + if (test_bit(XPT_DEAD, &xprt->xpt_flags)
2437     + || test_bit(XPT_CLOSE, &xprt->xpt_flags))
2438     len = -ENOTCONN;
2439     else
2440     len = xprt->xpt_ops->xpo_sendto(rqstp);
2441     diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
2442     index 824d32f..f190ea9 100644
2443     --- a/net/sunrpc/svcsock.c
2444     +++ b/net/sunrpc/svcsock.c
2445     @@ -1137,9 +1137,9 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
2446     if (len >= 0)
2447     svsk->sk_tcplen += len;
2448     if (len != want) {
2449     + svc_tcp_save_pages(svsk, rqstp);
2450     if (len < 0 && len != -EAGAIN)
2451     goto err_other;
2452     - svc_tcp_save_pages(svsk, rqstp);
2453     dprintk("svc: incomplete TCP record (%d of %d)\n",
2454     svsk->sk_tcplen, svsk->sk_reclen);
2455     goto err_noclose;
2456     diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
2457     index e59e2f0..0074aee 100644
2458     --- a/sound/pci/hda/hda_proc.c
2459     +++ b/sound/pci/hda/hda_proc.c
2460     @@ -412,7 +412,7 @@ static void print_digital_conv(struct snd_info_buffer *buffer,
2461     if (digi1 & AC_DIG1_EMPHASIS)
2462     snd_iprintf(buffer, " Preemphasis");
2463     if (digi1 & AC_DIG1_COPYRIGHT)
2464     - snd_iprintf(buffer, " Copyright");
2465     + snd_iprintf(buffer, " Non-Copyright");
2466     if (digi1 & AC_DIG1_NONAUDIO)
2467     snd_iprintf(buffer, " Non-Audio");
2468     if (digi1 & AC_DIG1_PROFESSIONAL)
2469     diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
2470     index 21d91d5..70b4f02 100644
2471     --- a/sound/pci/hda/patch_ca0132.c
2472     +++ b/sound/pci/hda/patch_ca0132.c
2473     @@ -276,6 +276,10 @@ static int _add_switch(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
2474     int type = dir ? HDA_INPUT : HDA_OUTPUT;
2475     struct snd_kcontrol_new knew =
2476     HDA_CODEC_MUTE_MONO(namestr, nid, chan, 0, type);
2477     + if ((query_amp_caps(codec, nid, type) & AC_AMPCAP_MUTE) == 0) {
2478     + snd_printdd("Skipping '%s %s Switch' (no mute on node 0x%x)\n", pfx, dirstr[dir], nid);
2479     + return 0;
2480     + }
2481     sprintf(namestr, "%s %s Switch", pfx, dirstr[dir]);
2482     return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
2483     }
2484     @@ -287,6 +291,10 @@ static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
2485     int type = dir ? HDA_INPUT : HDA_OUTPUT;
2486     struct snd_kcontrol_new knew =
2487     HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type);
2488     + if ((query_amp_caps(codec, nid, type) & AC_AMPCAP_NUM_STEPS) == 0) {
2489     + snd_printdd("Skipping '%s %s Volume' (no amp on node 0x%x)\n", pfx, dirstr[dir], nid);
2490     + return 0;
2491     + }
2492     sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]);
2493     return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
2494     }
2495     diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
2496     index b342ae5..b9567bc 100644
2497     --- a/sound/soc/codecs/wm9712.c
2498     +++ b/sound/soc/codecs/wm9712.c
2499     @@ -272,7 +272,7 @@ SOC_DAPM_ENUM("Route", wm9712_enum[9]);
2500    
2501     /* Mic select */
2502     static const struct snd_kcontrol_new wm9712_mic_src_controls =
2503     -SOC_DAPM_ENUM("Route", wm9712_enum[7]);
2504     +SOC_DAPM_ENUM("Mic Source Select", wm9712_enum[7]);
2505    
2506     /* diff select */
2507     static const struct snd_kcontrol_new wm9712_diff_sel_controls =
2508     @@ -291,7 +291,9 @@ SND_SOC_DAPM_MUX("Left Capture Select", SND_SOC_NOPM, 0, 0,
2509     &wm9712_capture_selectl_controls),
2510     SND_SOC_DAPM_MUX("Right Capture Select", SND_SOC_NOPM, 0, 0,
2511     &wm9712_capture_selectr_controls),
2512     -SND_SOC_DAPM_MUX("Mic Select Source", SND_SOC_NOPM, 0, 0,
2513     +SND_SOC_DAPM_MUX("Left Mic Select Source", SND_SOC_NOPM, 0, 0,
2514     + &wm9712_mic_src_controls),
2515     +SND_SOC_DAPM_MUX("Right Mic Select Source", SND_SOC_NOPM, 0, 0,
2516     &wm9712_mic_src_controls),
2517     SND_SOC_DAPM_MUX("Differential Source", SND_SOC_NOPM, 0, 0,
2518     &wm9712_diff_sel_controls),
2519     @@ -319,6 +321,7 @@ SND_SOC_DAPM_PGA("Out 3 PGA", AC97_INT_PAGING, 5, 1, NULL, 0),
2520     SND_SOC_DAPM_PGA("Line PGA", AC97_INT_PAGING, 2, 1, NULL, 0),
2521     SND_SOC_DAPM_PGA("Phone PGA", AC97_INT_PAGING, 1, 1, NULL, 0),
2522     SND_SOC_DAPM_PGA("Mic PGA", AC97_INT_PAGING, 0, 1, NULL, 0),
2523     +SND_SOC_DAPM_PGA("Differential Mic", SND_SOC_NOPM, 0, 0, NULL, 0),
2524     SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_INT_PAGING, 10, 1),
2525     SND_SOC_DAPM_OUTPUT("MONOOUT"),
2526     SND_SOC_DAPM_OUTPUT("HPOUTL"),
2527     @@ -379,6 +382,18 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {
2528     {"Mic PGA", NULL, "MIC1"},
2529     {"Mic PGA", NULL, "MIC2"},
2530    
2531     + /* microphones */
2532     + {"Differential Mic", NULL, "MIC1"},
2533     + {"Differential Mic", NULL, "MIC2"},
2534     + {"Left Mic Select Source", "Mic 1", "MIC1"},
2535     + {"Left Mic Select Source", "Mic 2", "MIC2"},
2536     + {"Left Mic Select Source", "Stereo", "MIC1"},
2537     + {"Left Mic Select Source", "Differential", "Differential Mic"},
2538     + {"Right Mic Select Source", "Mic 1", "MIC1"},
2539     + {"Right Mic Select Source", "Mic 2", "MIC2"},
2540     + {"Right Mic Select Source", "Stereo", "MIC2"},
2541     + {"Right Mic Select Source", "Differential", "Differential Mic"},
2542     +
2543     /* left capture selector */
2544     {"Left Capture Select", "Mic", "MIC1"},
2545     {"Left Capture Select", "Speaker Mixer", "Speaker Mixer"},
2546     diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
2547     index e5f4444..fb67772 100644
2548     --- a/sound/soc/omap/mcbsp.c
2549     +++ b/sound/soc/omap/mcbsp.c
2550     @@ -691,7 +691,7 @@ int omap_mcbsp_6pin_src_mux(struct omap_mcbsp *mcbsp, u8 mux)
2551     {
2552     const char *signal, *src;
2553    
2554     - if (mcbsp->pdata->mux_signal)
2555     + if (!mcbsp->pdata->mux_signal)
2556     return -EINVAL;
2557    
2558     switch (mux) {