Magellan Linux

Annotation of /trunk/kernel-magellan/patches-3.6/0101-3.6.2-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1921 - (hide annotations) (download)
Fri Oct 26 08:33:00 2012 UTC (11 years, 7 months ago) by niro
File size: 145571 byte(s)
-3.6.3-magellan-r1
1 niro 1921 diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
2     index d6fde98..848ef4a 100644
3     --- a/arch/alpha/kernel/process.c
4     +++ b/arch/alpha/kernel/process.c
5     @@ -28,6 +28,7 @@
6     #include <linux/tty.h>
7     #include <linux/console.h>
8     #include <linux/slab.h>
9     +#include <linux/rcupdate.h>
10    
11     #include <asm/reg.h>
12     #include <asm/uaccess.h>
13     @@ -54,8 +55,10 @@ cpu_idle(void)
14     /* FIXME -- EV6 and LCA45 know how to power down
15     the CPU. */
16    
17     + rcu_idle_enter();
18     while (!need_resched())
19     cpu_relax();
20     + rcu_idle_exit();
21     schedule();
22     }
23     }
24     diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
25     index c334a23..fce38a6 100644
26     --- a/arch/arm/include/asm/syscall.h
27     +++ b/arch/arm/include/asm/syscall.h
28     @@ -8,6 +8,7 @@
29     #define _ASM_ARM_SYSCALL_H
30    
31     #include <linux/err.h>
32     +#include <linux/sched.h>
33    
34     extern const unsigned long sys_call_table[];
35    
36     diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
37     index 66fd017..7f65be6 100644
38     --- a/arch/cris/kernel/process.c
39     +++ b/arch/cris/kernel/process.c
40     @@ -25,6 +25,7 @@
41     #include <linux/elfcore.h>
42     #include <linux/mqueue.h>
43     #include <linux/reboot.h>
44     +#include <linux/rcupdate.h>
45    
46     //#define DEBUG
47    
48     @@ -74,6 +75,7 @@ void cpu_idle (void)
49     {
50     /* endless idle loop with no priority at all */
51     while (1) {
52     + rcu_idle_enter();
53     while (!need_resched()) {
54     void (*idle)(void);
55     /*
56     @@ -86,6 +88,7 @@ void cpu_idle (void)
57     idle = default_idle;
58     idle();
59     }
60     + rcu_idle_exit();
61     schedule_preempt_disabled();
62     }
63     }
64     diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
65     index ff95f50..2eb7fa5 100644
66     --- a/arch/frv/kernel/process.c
67     +++ b/arch/frv/kernel/process.c
68     @@ -25,6 +25,7 @@
69     #include <linux/reboot.h>
70     #include <linux/interrupt.h>
71     #include <linux/pagemap.h>
72     +#include <linux/rcupdate.h>
73    
74     #include <asm/asm-offsets.h>
75     #include <asm/uaccess.h>
76     @@ -69,12 +70,14 @@ void cpu_idle(void)
77     {
78     /* endless idle loop with no priority at all */
79     while (1) {
80     + rcu_idle_enter();
81     while (!need_resched()) {
82     check_pgt_cache();
83    
84     if (!frv_dma_inprogress && idle)
85     idle();
86     }
87     + rcu_idle_exit();
88    
89     schedule_preempt_disabled();
90     }
91     diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
92     index 0e9c315..f153ed1 100644
93     --- a/arch/h8300/kernel/process.c
94     +++ b/arch/h8300/kernel/process.c
95     @@ -36,6 +36,7 @@
96     #include <linux/reboot.h>
97     #include <linux/fs.h>
98     #include <linux/slab.h>
99     +#include <linux/rcupdate.h>
100    
101     #include <asm/uaccess.h>
102     #include <asm/traps.h>
103     @@ -78,8 +79,10 @@ void (*idle)(void) = default_idle;
104     void cpu_idle(void)
105     {
106     while (1) {
107     + rcu_idle_enter();
108     while (!need_resched())
109     idle();
110     + rcu_idle_exit();
111     schedule_preempt_disabled();
112     }
113     }
114     diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
115     index dd6fc14..3e316ec 100644
116     --- a/arch/ia64/kernel/process.c
117     +++ b/arch/ia64/kernel/process.c
118     @@ -29,6 +29,7 @@
119     #include <linux/kdebug.h>
120     #include <linux/utsname.h>
121     #include <linux/tracehook.h>
122     +#include <linux/rcupdate.h>
123    
124     #include <asm/cpu.h>
125     #include <asm/delay.h>
126     @@ -279,6 +280,7 @@ cpu_idle (void)
127    
128     /* endless idle loop with no priority at all */
129     while (1) {
130     + rcu_idle_enter();
131     if (can_do_pal_halt) {
132     current_thread_info()->status &= ~TS_POLLING;
133     /*
134     @@ -309,6 +311,7 @@ cpu_idle (void)
135     normal_xtp();
136     #endif
137     }
138     + rcu_idle_exit();
139     schedule_preempt_disabled();
140     check_pgt_cache();
141     if (cpu_is_offline(cpu))
142     diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
143     index 3a4a32b..384e63f 100644
144     --- a/arch/m32r/kernel/process.c
145     +++ b/arch/m32r/kernel/process.c
146     @@ -26,6 +26,7 @@
147     #include <linux/ptrace.h>
148     #include <linux/unistd.h>
149     #include <linux/hardirq.h>
150     +#include <linux/rcupdate.h>
151    
152     #include <asm/io.h>
153     #include <asm/uaccess.h>
154     @@ -82,6 +83,7 @@ void cpu_idle (void)
155     {
156     /* endless idle loop with no priority at all */
157     while (1) {
158     + rcu_idle_enter();
159     while (!need_resched()) {
160     void (*idle)(void) = pm_idle;
161    
162     @@ -90,6 +92,7 @@ void cpu_idle (void)
163    
164     idle();
165     }
166     + rcu_idle_exit();
167     schedule_preempt_disabled();
168     }
169     }
170     diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
171     index c488e3c..ac2892e 100644
172     --- a/arch/m68k/kernel/process.c
173     +++ b/arch/m68k/kernel/process.c
174     @@ -25,6 +25,7 @@
175     #include <linux/reboot.h>
176     #include <linux/init_task.h>
177     #include <linux/mqueue.h>
178     +#include <linux/rcupdate.h>
179    
180     #include <asm/uaccess.h>
181     #include <asm/traps.h>
182     @@ -75,8 +76,10 @@ void cpu_idle(void)
183     {
184     /* endless idle loop with no priority at all */
185     while (1) {
186     + rcu_idle_enter();
187     while (!need_resched())
188     idle();
189     + rcu_idle_exit();
190     schedule_preempt_disabled();
191     }
192     }
193     diff --git a/arch/mips/Makefile b/arch/mips/Makefile
194     index 764e37a..654b1ad 100644
195     --- a/arch/mips/Makefile
196     +++ b/arch/mips/Makefile
197     @@ -225,7 +225,7 @@ KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
198     LDFLAGS += -m $(ld-emul)
199    
200     ifdef CONFIG_MIPS
201     -CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -xc /dev/null | \
202     +CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
203     egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
204     sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/")
205     ifdef CONFIG_64BIT
206     diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c
207     index b91ad3e..d272857 100644
208     --- a/arch/mips/ath79/clock.c
209     +++ b/arch/mips/ath79/clock.c
210     @@ -189,7 +189,7 @@ static void __init ar934x_clocks_init(void)
211     AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
212    
213     cpu_pll = nint * ath79_ref_clk.rate / ref_div;
214     - cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 6));
215     + cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 6));
216     cpu_pll /= (1 << out_div);
217    
218     pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
219     @@ -203,7 +203,7 @@ static void __init ar934x_clocks_init(void)
220     AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
221    
222     ddr_pll = nint * ath79_ref_clk.rate / ref_div;
223     - ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 10));
224     + ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 10));
225     ddr_pll /= (1 << out_div);
226    
227     clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
228     diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
229     index fdaf65e..c6136cb 100644
230     --- a/arch/mips/kernel/Makefile
231     +++ b/arch/mips/kernel/Makefile
232     @@ -104,7 +104,7 @@ obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
233    
234     obj-$(CONFIG_OF) += prom.o
235    
236     -CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
237     +CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -x c /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
238    
239     obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
240    
241     diff --git a/arch/mn10300/Makefile b/arch/mn10300/Makefile
242     index 33188b6..a3d0fef 100644
243     --- a/arch/mn10300/Makefile
244     +++ b/arch/mn10300/Makefile
245     @@ -26,7 +26,7 @@ CHECKFLAGS +=
246     PROCESSOR := unset
247     UNIT := unset
248    
249     -KBUILD_CFLAGS += -mam33 -mmem-funcs -DCPU=AM33
250     +KBUILD_CFLAGS += -mam33 -DCPU=AM33 $(call cc-option,-mmem-funcs,)
251     KBUILD_AFLAGS += -mam33 -DCPU=AM33
252    
253     ifeq ($(CONFIG_MN10300_CURRENT_IN_E2),y)
254     diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
255     index 7dab0cd..e9cceba 100644
256     --- a/arch/mn10300/kernel/process.c
257     +++ b/arch/mn10300/kernel/process.c
258     @@ -25,6 +25,7 @@
259     #include <linux/err.h>
260     #include <linux/fs.h>
261     #include <linux/slab.h>
262     +#include <linux/rcupdate.h>
263     #include <asm/uaccess.h>
264     #include <asm/pgtable.h>
265     #include <asm/io.h>
266     @@ -107,6 +108,7 @@ void cpu_idle(void)
267     {
268     /* endless idle loop with no priority at all */
269     for (;;) {
270     + rcu_idle_enter();
271     while (!need_resched()) {
272     void (*idle)(void);
273    
274     @@ -121,6 +123,7 @@ void cpu_idle(void)
275     }
276     idle();
277     }
278     + rcu_idle_exit();
279    
280     schedule_preempt_disabled();
281     }
282     diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
283     index 2c05a92..8c6b6b6 100644
284     --- a/arch/parisc/kernel/process.c
285     +++ b/arch/parisc/kernel/process.c
286     @@ -48,6 +48,7 @@
287     #include <linux/unistd.h>
288     #include <linux/kallsyms.h>
289     #include <linux/uaccess.h>
290     +#include <linux/rcupdate.h>
291    
292     #include <asm/io.h>
293     #include <asm/asm-offsets.h>
294     @@ -69,8 +70,10 @@ void cpu_idle(void)
295    
296     /* endless idle loop with no priority at all */
297     while (1) {
298     + rcu_idle_enter();
299     while (!need_resched())
300     barrier();
301     + rcu_idle_exit();
302     schedule_preempt_disabled();
303     check_pgt_cache();
304     }
305     diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
306     index 8cccbee..78326de 100644
307     --- a/arch/powerpc/include/asm/pci-bridge.h
308     +++ b/arch/powerpc/include/asm/pci-bridge.h
309     @@ -182,6 +182,14 @@ static inline int pci_device_from_OF_node(struct device_node *np,
310     #if defined(CONFIG_EEH)
311     static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
312     {
313     + /*
314     + * For those OF nodes whose parent isn't PCI bridge, they
315     + * don't have PCI_DN actually. So we have to skip them for
316     + * any EEH operations.
317     + */
318     + if (!dn || !PCI_DN(dn))
319     + return NULL;
320     +
321     return PCI_DN(dn)->edev;
322     }
323     #endif
324     diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
325     index ff5a6ce..8226c6c 100644
326     --- a/arch/powerpc/kernel/iommu.c
327     +++ b/arch/powerpc/kernel/iommu.c
328     @@ -215,7 +215,8 @@ static unsigned long iommu_range_alloc(struct device *dev,
329     spin_lock_irqsave(&(pool->lock), flags);
330    
331     again:
332     - if ((pass == 0) && handle && *handle)
333     + if ((pass == 0) && handle && *handle &&
334     + (*handle >= pool->start) && (*handle < pool->end))
335     start = *handle;
336     else
337     start = pool->hint;
338     @@ -236,7 +237,9 @@ again:
339     * but on second pass, start at 0 in pool 0.
340     */
341     if ((start & mask) >= limit || pass > 0) {
342     + spin_unlock(&(pool->lock));
343     pool = &(tbl->pools[0]);
344     + spin_lock(&(pool->lock));
345     start = pool->start;
346     } else {
347     start &= mask;
348     diff --git a/arch/powerpc/lib/memcpy_power7.S b/arch/powerpc/lib/memcpy_power7.S
349     index 7ba6c96..0663630 100644
350     --- a/arch/powerpc/lib/memcpy_power7.S
351     +++ b/arch/powerpc/lib/memcpy_power7.S
352     @@ -239,8 +239,8 @@ _GLOBAL(memcpy_power7)
353     ori r9,r9,1 /* stream=1 */
354    
355     srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */
356     - cmpldi cr1,r7,0x3FF
357     - ble cr1,1f
358     + cmpldi r7,0x3FF
359     + ble 1f
360     li r7,0x3FF
361     1: lis r0,0x0E00 /* depth=7 */
362     sldi r7,r7,7
363     diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
364     index ecd394c..9a0b5f5 100644
365     --- a/arch/powerpc/platforms/pseries/eeh.c
366     +++ b/arch/powerpc/platforms/pseries/eeh.c
367     @@ -1029,7 +1029,7 @@ static void eeh_add_device_early(struct device_node *dn)
368     {
369     struct pci_controller *phb;
370    
371     - if (!dn || !of_node_to_eeh_dev(dn))
372     + if (!of_node_to_eeh_dev(dn))
373     return;
374     phb = of_node_to_eeh_dev(dn)->phb;
375    
376     diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
377     index 4f2680f..b68b0db 100644
378     --- a/arch/powerpc/sysdev/dart_iommu.c
379     +++ b/arch/powerpc/sysdev/dart_iommu.c
380     @@ -74,11 +74,16 @@ static int dart_is_u4;
381    
382     #define DBG(...)
383    
384     +static DEFINE_SPINLOCK(invalidate_lock);
385     +
386     static inline void dart_tlb_invalidate_all(void)
387     {
388     unsigned long l = 0;
389     unsigned int reg, inv_bit;
390     unsigned long limit;
391     + unsigned long flags;
392     +
393     + spin_lock_irqsave(&invalidate_lock, flags);
394    
395     DBG("dart: flush\n");
396    
397     @@ -111,12 +116,17 @@ retry:
398     panic("DART: TLB did not flush after waiting a long "
399     "time. Buggy U3 ?");
400     }
401     +
402     + spin_unlock_irqrestore(&invalidate_lock, flags);
403     }
404    
405     static inline void dart_tlb_invalidate_one(unsigned long bus_rpn)
406     {
407     unsigned int reg;
408     unsigned int l, limit;
409     + unsigned long flags;
410     +
411     + spin_lock_irqsave(&invalidate_lock, flags);
412    
413     reg = DART_CNTL_U4_ENABLE | DART_CNTL_U4_IONE |
414     (bus_rpn & DART_CNTL_U4_IONE_MASK);
415     @@ -138,6 +148,8 @@ wait_more:
416     panic("DART: TLB did not flush after waiting a long "
417     "time. Buggy U4 ?");
418     }
419     +
420     + spin_unlock_irqrestore(&invalidate_lock, flags);
421     }
422    
423     static void dart_flush(struct iommu_table *tbl)
424     diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
425     index 2707023..637970c 100644
426     --- a/arch/score/kernel/process.c
427     +++ b/arch/score/kernel/process.c
428     @@ -27,6 +27,7 @@
429     #include <linux/reboot.h>
430     #include <linux/elfcore.h>
431     #include <linux/pm.h>
432     +#include <linux/rcupdate.h>
433    
434     void (*pm_power_off)(void);
435     EXPORT_SYMBOL(pm_power_off);
436     @@ -50,9 +51,10 @@ void __noreturn cpu_idle(void)
437     {
438     /* endless idle loop with no priority at all */
439     while (1) {
440     + rcu_idle_enter();
441     while (!need_resched())
442     barrier();
443     -
444     + rcu_idle_exit();
445     schedule_preempt_disabled();
446     }
447     }
448     diff --git a/arch/x86/Makefile b/arch/x86/Makefile
449     index 474ca35..58790bd 100644
450     --- a/arch/x86/Makefile
451     +++ b/arch/x86/Makefile
452     @@ -92,7 +92,7 @@ endif
453     ifdef CONFIG_X86_X32
454     x32_ld_ok := $(call try-run,\
455     /bin/echo -e '1: .quad 1b' | \
456     - $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" - && \
457     + $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
458     $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
459     $(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
460     ifeq ($(x32_ld_ok),y)
461     @@ -142,7 +142,7 @@ KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
462     KBUILD_CFLAGS += $(mflags-y)
463     KBUILD_AFLAGS += $(mflags-y)
464    
465     -archscripts: scripts_basic
466     +archscripts:
467     $(Q)$(MAKE) $(build)=arch/x86/tools relocs
468    
469     ###
470     diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
471     index e398bb5..8a84501 100644
472     --- a/arch/x86/boot/compressed/Makefile
473     +++ b/arch/x86/boot/compressed/Makefile
474     @@ -28,6 +28,9 @@ VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
475     $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \
476     $(obj)/piggy.o
477    
478     +$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
479     +$(obj)/efi_stub_$(BITS).o: KBUILD_CLFAGS += -fshort-wchar -mno-red-zone
480     +
481     ifeq ($(CONFIG_EFI_STUB), y)
482     VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
483     endif
484     diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
485     index 49afb3f..c3520d7 100644
486     --- a/arch/x86/include/asm/pgtable.h
487     +++ b/arch/x86/include/asm/pgtable.h
488     @@ -146,8 +146,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
489    
490     static inline int pmd_large(pmd_t pte)
491     {
492     - return (pmd_flags(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==
493     - (_PAGE_PSE | _PAGE_PRESENT);
494     + return pmd_flags(pte) & _PAGE_PSE;
495     }
496    
497     #ifdef CONFIG_TRANSPARENT_HUGEPAGE
498     @@ -415,7 +414,13 @@ static inline int pte_hidden(pte_t pte)
499    
500     static inline int pmd_present(pmd_t pmd)
501     {
502     - return pmd_flags(pmd) & _PAGE_PRESENT;
503     + /*
504     + * Checking for _PAGE_PSE is needed too because
505     + * split_huge_page will temporarily clear the present bit (but
506     + * the _PAGE_PSE flag will remain set at all times while the
507     + * _PAGE_PRESENT bit is clear).
508     + */
509     + return pmd_flags(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE);
510     }
511    
512     static inline int pmd_none(pmd_t pmd)
513     diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
514     index 92660eda..f55a4ce 100644
515     --- a/arch/x86/platform/efi/efi.c
516     +++ b/arch/x86/platform/efi/efi.c
517     @@ -890,6 +890,7 @@ void __init efi_enter_virtual_mode(void)
518     *
519     * Call EFI services through wrapper functions.
520     */
521     + efi.runtime_version = efi_systab.fw_revision;
522     efi.get_time = virt_efi_get_time;
523     efi.set_time = virt_efi_set_time;
524     efi.get_wakeup_time = virt_efi_get_wakeup_time;
525     diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
526     index 2c8d6a3..bc44311 100644
527     --- a/arch/xtensa/kernel/process.c
528     +++ b/arch/xtensa/kernel/process.c
529     @@ -31,6 +31,7 @@
530     #include <linux/mqueue.h>
531     #include <linux/fs.h>
532     #include <linux/slab.h>
533     +#include <linux/rcupdate.h>
534    
535     #include <asm/pgtable.h>
536     #include <asm/uaccess.h>
537     @@ -110,8 +111,10 @@ void cpu_idle(void)
538    
539     /* endless idle loop with no priority at all */
540     while (1) {
541     + rcu_idle_enter();
542     while (!need_resched())
543     platform_idle();
544     + rcu_idle_exit();
545     schedule_preempt_disabled();
546     }
547     }
548     diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
549     index e059695..d59175e 100644
550     --- a/drivers/acpi/bus.c
551     +++ b/drivers/acpi/bus.c
552     @@ -994,8 +994,6 @@ static int __init acpi_bus_init(void)
553     status = acpi_ec_ecdt_probe();
554     /* Ignore result. Not having an ECDT is not fatal. */
555    
556     - acpi_bus_osc_support();
557     -
558     status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
559     if (ACPI_FAILURE(status)) {
560     printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
561     @@ -1003,6 +1001,12 @@ static int __init acpi_bus_init(void)
562     }
563    
564     /*
565     + * _OSC method may exist in module level code,
566     + * so it must be run after ACPI_FULL_INITIALIZATION
567     + */
568     + acpi_bus_osc_support();
569     +
570     + /*
571     * _PDC control method may load dynamic SSDT tables,
572     * and we need to install the table handler before that.
573     */
574     diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
575     index 0113adc..2700f2e 100644
576     --- a/drivers/base/power/main.c
577     +++ b/drivers/base/power/main.c
578     @@ -996,7 +996,7 @@ int dpm_suspend_end(pm_message_t state)
579    
580     error = dpm_suspend_noirq(state);
581     if (error) {
582     - dpm_resume_early(state);
583     + dpm_resume_early(resume_event(state));
584     return error;
585     }
586    
587     diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
588     index 3491654..a815d44 100644
589     --- a/drivers/dma/dmaengine.c
590     +++ b/drivers/dma/dmaengine.c
591     @@ -582,7 +582,7 @@ void dmaengine_get(void)
592     list_del_rcu(&device->global_node);
593     break;
594     } else if (err)
595     - pr_err("%s: failed to get %s: (%d)\n",
596     + pr_debug("%s: failed to get %s: (%d)\n",
597     __func__, dma_chan_name(chan), err);
598     }
599     }
600     diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
601     index 6fbfc24..af81f77 100644
602     --- a/drivers/gpu/drm/drm_crtc.c
603     +++ b/drivers/gpu/drm/drm_crtc.c
604     @@ -1034,15 +1034,15 @@ void drm_mode_config_cleanup(struct drm_device *dev)
605     fb->funcs->destroy(fb);
606     }
607    
608     - list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
609     - crtc->funcs->destroy(crtc);
610     - }
611     -
612     list_for_each_entry_safe(plane, plt, &dev->mode_config.plane_list,
613     head) {
614     plane->funcs->destroy(plane);
615     }
616    
617     + list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
618     + crtc->funcs->destroy(crtc);
619     + }
620     +
621     idr_remove_all(&dev->mode_config.crtc_idr);
622     idr_destroy(&dev->mode_config.crtc_idr);
623     }
624     diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
625     index 5249640..73fa3e1 100644
626     --- a/drivers/gpu/drm/i915/i915_irq.c
627     +++ b/drivers/gpu/drm/i915/i915_irq.c
628     @@ -680,12 +680,12 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
629     intel_opregion_gse_intr(dev);
630    
631     for (i = 0; i < 3; i++) {
632     + if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i)))
633     + drm_handle_vblank(dev, i);
634     if (de_iir & (DE_PLANEA_FLIP_DONE_IVB << (5 * i))) {
635     intel_prepare_page_flip(dev, i);
636     intel_finish_page_flip_plane(dev, i);
637     }
638     - if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i)))
639     - drm_handle_vblank(dev, i);
640     }
641    
642     /* check event from PCH */
643     @@ -767,6 +767,12 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
644     if (de_iir & DE_GSE)
645     intel_opregion_gse_intr(dev);
646    
647     + if (de_iir & DE_PIPEA_VBLANK)
648     + drm_handle_vblank(dev, 0);
649     +
650     + if (de_iir & DE_PIPEB_VBLANK)
651     + drm_handle_vblank(dev, 1);
652     +
653     if (de_iir & DE_PLANEA_FLIP_DONE) {
654     intel_prepare_page_flip(dev, 0);
655     intel_finish_page_flip_plane(dev, 0);
656     @@ -777,12 +783,6 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
657     intel_finish_page_flip_plane(dev, 1);
658     }
659    
660     - if (de_iir & DE_PIPEA_VBLANK)
661     - drm_handle_vblank(dev, 0);
662     -
663     - if (de_iir & DE_PIPEB_VBLANK)
664     - drm_handle_vblank(dev, 1);
665     -
666     /* check event from PCH */
667     if (de_iir & DE_PCH_EVENT) {
668     if (pch_iir & hotplug_mask)
669     diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
670     index 28725ce..a3e53c5 100644
671     --- a/drivers/gpu/drm/i915/i915_reg.h
672     +++ b/drivers/gpu/drm/i915/i915_reg.h
673     @@ -519,6 +519,9 @@
674     # define VS_TIMER_DISPATCH (1 << 6)
675     # define MI_FLUSH_ENABLE (1 << 12)
676    
677     +#define GEN6_GT_MODE 0x20d0
678     +#define GEN6_GT_MODE_HI (1 << 9)
679     +
680     #define GFX_MODE 0x02520
681     #define GFX_MODE_GEN7 0x0229c
682     #define RING_MODE_GEN7(ring) ((ring)->mmio_base+0x29c)
683     @@ -1753,6 +1756,10 @@
684    
685     /* Video Data Island Packet control */
686     #define VIDEO_DIP_DATA 0x61178
687     +/* Read the description of VIDEO_DIP_DATA (before Haswel) or VIDEO_DIP_ECC
688     + * (Haswell and newer) to see which VIDEO_DIP_DATA byte corresponds to each byte
689     + * of the infoframe structure specified by CEA-861. */
690     +#define VIDEO_DIP_DATA_SIZE 32
691     #define VIDEO_DIP_CTL 0x61170
692     /* Pre HSW: */
693     #define VIDEO_DIP_ENABLE (1 << 31)
694     diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
695     index c040aee..0c7f4aa 100644
696     --- a/drivers/gpu/drm/i915/intel_display.c
697     +++ b/drivers/gpu/drm/i915/intel_display.c
698     @@ -2823,13 +2823,34 @@ static void ironlake_fdi_disable(struct drm_crtc *crtc)
699     udelay(100);
700     }
701    
702     +static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
703     +{
704     + struct drm_device *dev = crtc->dev;
705     + struct drm_i915_private *dev_priv = dev->dev_private;
706     + unsigned long flags;
707     + bool pending;
708     +
709     + if (atomic_read(&dev_priv->mm.wedged))
710     + return false;
711     +
712     + spin_lock_irqsave(&dev->event_lock, flags);
713     + pending = to_intel_crtc(crtc)->unpin_work != NULL;
714     + spin_unlock_irqrestore(&dev->event_lock, flags);
715     +
716     + return pending;
717     +}
718     +
719     static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
720     {
721     struct drm_device *dev = crtc->dev;
722     + struct drm_i915_private *dev_priv = dev->dev_private;
723    
724     if (crtc->fb == NULL)
725     return;
726    
727     + wait_event(dev_priv->pending_flip_queue,
728     + !intel_crtc_has_pending_flip(crtc));
729     +
730     mutex_lock(&dev->struct_mutex);
731     intel_finish_fb(crtc->fb);
732     mutex_unlock(&dev->struct_mutex);
733     @@ -6149,9 +6170,8 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
734    
735     atomic_clear_mask(1 << intel_crtc->plane,
736     &obj->pending_flip.counter);
737     - if (atomic_read(&obj->pending_flip) == 0)
738     - wake_up(&dev_priv->pending_flip_queue);
739    
740     + wake_up(&dev_priv->pending_flip_queue);
741     schedule_work(&work->work);
742    
743     trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);
744     @@ -6394,7 +6414,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
745     default:
746     WARN_ONCE(1, "unknown plane in flip command\n");
747     ret = -ENODEV;
748     - goto err;
749     + goto err_unpin;
750     }
751    
752     ret = intel_ring_begin(ring, 4);
753     diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
754     index 12dc330..34b6724 100644
755     --- a/drivers/gpu/drm/i915/intel_hdmi.c
756     +++ b/drivers/gpu/drm/i915/intel_hdmi.c
757     @@ -151,6 +151,9 @@ static void g4x_write_infoframe(struct drm_encoder *encoder,
758     I915_WRITE(VIDEO_DIP_DATA, *data);
759     data++;
760     }
761     + /* Write every possible data byte to force correct ECC calculation. */
762     + for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
763     + I915_WRITE(VIDEO_DIP_DATA, 0);
764     mmiowb();
765    
766     val |= g4x_infoframe_enable(frame);
767     @@ -186,6 +189,9 @@ static void ibx_write_infoframe(struct drm_encoder *encoder,
768     I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
769     data++;
770     }
771     + /* Write every possible data byte to force correct ECC calculation. */
772     + for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
773     + I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
774     mmiowb();
775    
776     val |= g4x_infoframe_enable(frame);
777     @@ -224,6 +230,9 @@ static void cpt_write_infoframe(struct drm_encoder *encoder,
778     I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
779     data++;
780     }
781     + /* Write every possible data byte to force correct ECC calculation. */
782     + for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
783     + I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
784     mmiowb();
785    
786     val |= g4x_infoframe_enable(frame);
787     @@ -259,6 +268,9 @@ static void vlv_write_infoframe(struct drm_encoder *encoder,
788     I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
789     data++;
790     }
791     + /* Write every possible data byte to force correct ECC calculation. */
792     + for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
793     + I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
794     mmiowb();
795    
796     val |= g4x_infoframe_enable(frame);
797     @@ -292,6 +304,9 @@ static void hsw_write_infoframe(struct drm_encoder *encoder,
798     I915_WRITE(data_reg + i, *data);
799     data++;
800     }
801     + /* Write every possible data byte to force correct ECC calculation. */
802     + for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
803     + I915_WRITE(data_reg + i, 0);
804     mmiowb();
805    
806     val |= hsw_infoframe_enable(frame);
807     diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
808     index ba8a27b..8c73fae 100644
809     --- a/drivers/gpu/drm/i915/intel_pm.c
810     +++ b/drivers/gpu/drm/i915/intel_pm.c
811     @@ -3387,6 +3387,11 @@ static void gen6_init_clock_gating(struct drm_device *dev)
812     DISPPLANE_TRICKLE_FEED_DISABLE);
813     intel_flush_display_plane(dev_priv, pipe);
814     }
815     +
816     + /* The default value should be 0x200 according to docs, but the two
817     + * platforms I checked have a 0 for this. (Maybe BIOS overrides?) */
818     + I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_DISABLE(0xffff));
819     + I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_ENABLE(GEN6_GT_MODE_HI));
820     }
821    
822     static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
823     diff --git a/drivers/gpu/drm/nouveau/nvc0_fence.c b/drivers/gpu/drm/nouveau/nvc0_fence.c
824     index 47ab388..8e5a2f4 100644
825     --- a/drivers/gpu/drm/nouveau/nvc0_fence.c
826     +++ b/drivers/gpu/drm/nouveau/nvc0_fence.c
827     @@ -32,6 +32,7 @@
828     struct nvc0_fence_priv {
829     struct nouveau_fence_priv base;
830     struct nouveau_bo *bo;
831     + u32 *suspend;
832     };
833    
834     struct nvc0_fence_chan {
835     @@ -125,12 +126,36 @@ nvc0_fence_context_new(struct nouveau_channel *chan, int engine)
836     static int
837     nvc0_fence_fini(struct drm_device *dev, int engine, bool suspend)
838     {
839     + struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
840     + struct nvc0_fence_priv *priv = nv_engine(dev, engine);
841     + int i;
842     +
843     + if (suspend) {
844     + priv->suspend = vmalloc(pfifo->channels * sizeof(u32));
845     + if (!priv->suspend)
846     + return -ENOMEM;
847     +
848     + for (i = 0; i < pfifo->channels; i++)
849     + priv->suspend[i] = nouveau_bo_rd32(priv->bo, i);
850     + }
851     +
852     return 0;
853     }
854    
855     static int
856     nvc0_fence_init(struct drm_device *dev, int engine)
857     {
858     + struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
859     + struct nvc0_fence_priv *priv = nv_engine(dev, engine);
860     + int i;
861     +
862     + if (priv->suspend) {
863     + for (i = 0; i < pfifo->channels; i++)
864     + nouveau_bo_wr32(priv->bo, i, priv->suspend[i]);
865     + vfree(priv->suspend);
866     + priv->suspend = NULL;
867     + }
868     +
869     return 0;
870     }
871    
872     diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
873     index e44a62a..d883b20 100644
874     --- a/drivers/gpu/drm/radeon/evergreen_cs.c
875     +++ b/drivers/gpu/drm/radeon/evergreen_cs.c
876     @@ -846,6 +846,16 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p,
877     return -EINVAL;
878     }
879    
880     + if (!mipmap) {
881     + if (llevel) {
882     + dev_warn(p->dev, "%s:%i got NULL MIP_ADDRESS relocation\n",
883     + __func__, __LINE__);
884     + return -EINVAL;
885     + } else {
886     + return 0; /* everything's ok */
887     + }
888     + }
889     +
890     /* check mipmap size */
891     for (i = 1; i <= llevel; i++) {
892     unsigned w, h, d;
893     @@ -1081,6 +1091,27 @@ static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p,
894     }
895    
896     /**
897     + * evergreen_cs_packet_next_is_pkt3_nop() - test if the next packet is NOP
898     + * @p: structure holding the parser context.
899     + *
900     + * Check if the next packet is a relocation packet3.
901     + **/
902     +static bool evergreen_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p)
903     +{
904     + struct radeon_cs_packet p3reloc;
905     + int r;
906     +
907     + r = evergreen_cs_packet_parse(p, &p3reloc, p->idx);
908     + if (r) {
909     + return false;
910     + }
911     + if (p3reloc.type != PACKET_TYPE3 || p3reloc.opcode != PACKET3_NOP) {
912     + return false;
913     + }
914     + return true;
915     +}
916     +
917     +/**
918     * evergreen_cs_packet_next_vline() - parse userspace VLINE packet
919     * @parser: parser structure holding parsing context.
920     *
921     @@ -2330,7 +2361,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p,
922     for (i = 0; i < (pkt->count / 8); i++) {
923     struct radeon_bo *texture, *mipmap;
924     u32 toffset, moffset;
925     - u32 size, offset;
926     + u32 size, offset, mip_address, tex_dim;
927    
928     switch (G__SQ_CONSTANT_TYPE(radeon_get_ib_value(p, idx+1+(i*8)+7))) {
929     case SQ_TEX_VTX_VALID_TEXTURE:
930     @@ -2359,14 +2390,28 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p,
931     }
932     texture = reloc->robj;
933     toffset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
934     +
935     /* tex mip base */
936     - r = evergreen_cs_packet_next_reloc(p, &reloc);
937     - if (r) {
938     - DRM_ERROR("bad SET_RESOURCE (tex)\n");
939     - return -EINVAL;
940     + tex_dim = ib[idx+1+(i*8)+0] & 0x7;
941     + mip_address = ib[idx+1+(i*8)+3];
942     +
943     + if ((tex_dim == SQ_TEX_DIM_2D_MSAA || tex_dim == SQ_TEX_DIM_2D_ARRAY_MSAA) &&
944     + !mip_address &&
945     + !evergreen_cs_packet_next_is_pkt3_nop(p)) {
946     + /* MIP_ADDRESS should point to FMASK for an MSAA texture.
947     + * It should be 0 if FMASK is disabled. */
948     + moffset = 0;
949     + mipmap = NULL;
950     + } else {
951     + r = evergreen_cs_packet_next_reloc(p, &reloc);
952     + if (r) {
953     + DRM_ERROR("bad SET_RESOURCE (tex)\n");
954     + return -EINVAL;
955     + }
956     + moffset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
957     + mipmap = reloc->robj;
958     }
959     - moffset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
960     - mipmap = reloc->robj;
961     +
962     r = evergreen_cs_track_validate_texture(p, texture, mipmap, idx+1+(i*8));
963     if (r)
964     return r;
965     diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
966     index f37676d..dfa2448 100644
967     --- a/drivers/gpu/drm/radeon/r600_cs.c
968     +++ b/drivers/gpu/drm/radeon/r600_cs.c
969     @@ -2180,7 +2180,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
970     }
971     break;
972     case PACKET3_STRMOUT_BASE_UPDATE:
973     - if (p->family < CHIP_RV770) {
974     + /* RS780 and RS880 also need this */
975     + if (p->family < CHIP_RS780) {
976     DRM_ERROR("STRMOUT_BASE_UPDATE only supported on 7xx\n");
977     return -EINVAL;
978     }
979     diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
980     index 8c593ea..27ece75 100644
981     --- a/drivers/gpu/drm/radeon/radeon_drv.c
982     +++ b/drivers/gpu/drm/radeon/radeon_drv.c
983     @@ -64,9 +64,11 @@
984     * 2.20.0 - r600-si: RADEON_INFO_TIMESTAMP query
985     * 2.21.0 - r600-r700: FMASK and CMASK
986     * 2.22.0 - r600 only: RESOLVE_BOX allowed
987     + * 2.23.0 - allow STRMOUT_BASE_UPDATE on RS780 and RS880
988     + * 2.24.0 - eg only: allow MIP_ADDRESS=0 for MSAA textures
989     */
990     #define KMS_DRIVER_MAJOR 2
991     -#define KMS_DRIVER_MINOR 22
992     +#define KMS_DRIVER_MINOR 24
993     #define KMS_DRIVER_PATCHLEVEL 0
994     int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
995     int radeon_driver_unload_kms(struct drm_device *dev);
996     diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
997     index afaa172..443bd49 100644
998     --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
999     +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
1000     @@ -204,6 +204,16 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
1001     (rdev->pdev->subsystem_device == 0x01fd))
1002     return true;
1003    
1004     + /* Gateway RS690 only seems to work with MSIs. */
1005     + if ((rdev->pdev->device == 0x791f) &&
1006     + (rdev->pdev->subsystem_vendor == 0x107b) &&
1007     + (rdev->pdev->subsystem_device == 0x0185))
1008     + return true;
1009     +
1010     + /* try and enable MSIs by default on all RS690s */
1011     + if (rdev->family == CHIP_RS690)
1012     + return true;
1013     +
1014     /* RV515 seems to have MSI issues where it loses
1015     * MSI rearms occasionally. This leads to lockups and freezes.
1016     * disable it by default.
1017     diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
1018     index 7ae6066..395d7e0 100644
1019     --- a/drivers/gpu/drm/radeon/radeon_pm.c
1020     +++ b/drivers/gpu/drm/radeon/radeon_pm.c
1021     @@ -547,7 +547,9 @@ void radeon_pm_suspend(struct radeon_device *rdev)
1022     void radeon_pm_resume(struct radeon_device *rdev)
1023     {
1024     /* set up the default clocks if the MC ucode is loaded */
1025     - if (ASIC_IS_DCE5(rdev) && rdev->mc_fw) {
1026     + if ((rdev->family >= CHIP_BARTS) &&
1027     + (rdev->family <= CHIP_CAYMAN) &&
1028     + rdev->mc_fw) {
1029     if (rdev->pm.default_vddc)
1030     radeon_atom_set_voltage(rdev, rdev->pm.default_vddc,
1031     SET_VOLTAGE_TYPE_ASIC_VDDC);
1032     @@ -602,7 +604,9 @@ int radeon_pm_init(struct radeon_device *rdev)
1033     radeon_pm_print_states(rdev);
1034     radeon_pm_init_profile(rdev);
1035     /* set up the default clocks if the MC ucode is loaded */
1036     - if (ASIC_IS_DCE5(rdev) && rdev->mc_fw) {
1037     + if ((rdev->family >= CHIP_BARTS) &&
1038     + (rdev->family <= CHIP_CAYMAN) &&
1039     + rdev->mc_fw) {
1040     if (rdev->pm.default_vddc)
1041     radeon_atom_set_voltage(rdev, rdev->pm.default_vddc,
1042     SET_VOLTAGE_TYPE_ASIC_VDDC);
1043     diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
1044     index 1efbb90..c89aef4 100644
1045     --- a/drivers/gpu/drm/savage/savage_bci.c
1046     +++ b/drivers/gpu/drm/savage/savage_bci.c
1047     @@ -547,6 +547,8 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset)
1048    
1049     dev_priv->chipset = (enum savage_family)chipset;
1050    
1051     + pci_set_master(dev->pdev);
1052     +
1053     return 0;
1054     }
1055    
1056     diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
1057     index 3b6f7bf..c46c5f1 100644
1058     --- a/drivers/hid/hidraw.c
1059     +++ b/drivers/hid/hidraw.c
1060     @@ -42,6 +42,7 @@ static struct cdev hidraw_cdev;
1061     static struct class *hidraw_class;
1062     static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES];
1063     static DEFINE_MUTEX(minors_lock);
1064     +static void drop_ref(struct hidraw *hid, int exists_bit);
1065    
1066     static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
1067     {
1068     @@ -113,7 +114,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
1069     __u8 *buf;
1070     int ret = 0;
1071    
1072     - if (!hidraw_table[minor]) {
1073     + if (!hidraw_table[minor] || !hidraw_table[minor]->exist) {
1074     ret = -ENODEV;
1075     goto out;
1076     }
1077     @@ -261,7 +262,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
1078     }
1079    
1080     mutex_lock(&minors_lock);
1081     - if (!hidraw_table[minor]) {
1082     + if (!hidraw_table[minor] || !hidraw_table[minor]->exist) {
1083     err = -ENODEV;
1084     goto out_unlock;
1085     }
1086     @@ -298,36 +299,12 @@ out:
1087     static int hidraw_release(struct inode * inode, struct file * file)
1088     {
1089     unsigned int minor = iminor(inode);
1090     - struct hidraw *dev;
1091     struct hidraw_list *list = file->private_data;
1092     - int ret;
1093     - int i;
1094     -
1095     - mutex_lock(&minors_lock);
1096     - if (!hidraw_table[minor]) {
1097     - ret = -ENODEV;
1098     - goto unlock;
1099     - }
1100    
1101     + drop_ref(hidraw_table[minor], 0);
1102     list_del(&list->node);
1103     - dev = hidraw_table[minor];
1104     - if (!--dev->open) {
1105     - if (list->hidraw->exist) {
1106     - hid_hw_power(dev->hid, PM_HINT_NORMAL);
1107     - hid_hw_close(dev->hid);
1108     - } else {
1109     - kfree(list->hidraw);
1110     - }
1111     - }
1112     -
1113     - for (i = 0; i < HIDRAW_BUFFER_SIZE; ++i)
1114     - kfree(list->buffer[i].value);
1115     kfree(list);
1116     - ret = 0;
1117     -unlock:
1118     - mutex_unlock(&minors_lock);
1119     -
1120     - return ret;
1121     + return 0;
1122     }
1123    
1124     static long hidraw_ioctl(struct file *file, unsigned int cmd,
1125     @@ -529,21 +506,7 @@ EXPORT_SYMBOL_GPL(hidraw_connect);
1126     void hidraw_disconnect(struct hid_device *hid)
1127     {
1128     struct hidraw *hidraw = hid->hidraw;
1129     -
1130     - mutex_lock(&minors_lock);
1131     - hidraw->exist = 0;
1132     -
1133     - device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
1134     -
1135     - hidraw_table[hidraw->minor] = NULL;
1136     -
1137     - if (hidraw->open) {
1138     - hid_hw_close(hid);
1139     - wake_up_interruptible(&hidraw->wait);
1140     - } else {
1141     - kfree(hidraw);
1142     - }
1143     - mutex_unlock(&minors_lock);
1144     + drop_ref(hidraw, 1);
1145     }
1146     EXPORT_SYMBOL_GPL(hidraw_disconnect);
1147    
1148     @@ -585,3 +548,23 @@ void hidraw_exit(void)
1149     unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES);
1150    
1151     }
1152     +
1153     +static void drop_ref(struct hidraw *hidraw, int exists_bit)
1154     +{
1155     + mutex_lock(&minors_lock);
1156     + if (exists_bit) {
1157     + hid_hw_close(hidraw->hid);
1158     + hidraw->exist = 0;
1159     + if (hidraw->open)
1160     + wake_up_interruptible(&hidraw->wait);
1161     + } else {
1162     + --hidraw->open;
1163     + }
1164     +
1165     + if (!hidraw->open && !hidraw->exist) {
1166     + device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
1167     + hidraw_table[hidraw->minor] = NULL;
1168     + kfree(hidraw);
1169     + }
1170     + mutex_unlock(&minors_lock);
1171     +}
1172     diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
1173     index ef511df..8bbd6ec 100644
1174     --- a/drivers/i2c/busses/i2c-piix4.c
1175     +++ b/drivers/i2c/busses/i2c-piix4.c
1176     @@ -37,6 +37,7 @@
1177     #include <linux/stddef.h>
1178     #include <linux/ioport.h>
1179     #include <linux/i2c.h>
1180     +#include <linux/slab.h>
1181     #include <linux/init.h>
1182     #include <linux/dmi.h>
1183     #include <linux/acpi.h>
1184     diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1185     index 2297ec1..cb9e114 100644
1186     --- a/drivers/iommu/intel-iommu.c
1187     +++ b/drivers/iommu/intel-iommu.c
1188     @@ -589,7 +589,9 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain)
1189     {
1190     int i;
1191    
1192     - domain->iommu_coherency = 1;
1193     + i = find_first_bit(domain->iommu_bmp, g_num_of_iommus);
1194     +
1195     + domain->iommu_coherency = i < g_num_of_iommus ? 1 : 0;
1196    
1197     for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) {
1198     if (!ecap_coherent(g_iommus[i]->ecap)) {
1199     diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h
1200     index d615d7d..94fecfb 100644
1201     --- a/drivers/media/dvb/frontends/drxk.h
1202     +++ b/drivers/media/dvb/frontends/drxk.h
1203     @@ -28,6 +28,7 @@
1204     * A value of 0 (default) or lower indicates that
1205     * the correct number of parameters will be
1206     * automatically detected.
1207     + * @load_firmware_sync: Force the firmware load to be synchronous.
1208     *
1209     * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
1210     * UIO-3.
1211     @@ -39,6 +40,7 @@ struct drxk_config {
1212     bool parallel_ts;
1213     bool dynamic_clk;
1214     bool enable_merr_cfg;
1215     + bool load_firmware_sync;
1216    
1217     bool antenna_dvbt;
1218     u16 antenna_gpio;
1219     diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
1220     index 1ab8154..8b4c6d5 100644
1221     --- a/drivers/media/dvb/frontends/drxk_hard.c
1222     +++ b/drivers/media/dvb/frontends/drxk_hard.c
1223     @@ -6609,15 +6609,25 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
1224    
1225     /* Load firmware and initialize DRX-K */
1226     if (state->microcode_name) {
1227     - status = request_firmware_nowait(THIS_MODULE, 1,
1228     + if (config->load_firmware_sync) {
1229     + const struct firmware *fw = NULL;
1230     +
1231     + status = request_firmware(&fw, state->microcode_name,
1232     + state->i2c->dev.parent);
1233     + if (status < 0)
1234     + fw = NULL;
1235     + load_firmware_cb(fw, state);
1236     + } else {
1237     + status = request_firmware_nowait(THIS_MODULE, 1,
1238     state->microcode_name,
1239     state->i2c->dev.parent,
1240     GFP_KERNEL,
1241     state, load_firmware_cb);
1242     - if (status < 0) {
1243     - printk(KERN_ERR
1244     - "drxk: failed to request a firmware\n");
1245     - return NULL;
1246     + if (status < 0) {
1247     + printk(KERN_ERR
1248     + "drxk: failed to request a firmware\n");
1249     + return NULL;
1250     + }
1251     }
1252     } else if (init_drxk(state) < 0)
1253     goto error;
1254     diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
1255     index 36fe5a3..24c77a4 100644
1256     --- a/drivers/media/rc/ite-cir.c
1257     +++ b/drivers/media/rc/ite-cir.c
1258     @@ -1473,6 +1473,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1259     rdev = rc_allocate_device();
1260     if (!rdev)
1261     goto failure;
1262     + itdev->rdev = rdev;
1263    
1264     ret = -ENODEV;
1265    
1266     @@ -1604,7 +1605,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1267     if (ret)
1268     goto failure3;
1269    
1270     - itdev->rdev = rdev;
1271     ite_pr(KERN_NOTICE, "driver has been successfully loaded\n");
1272    
1273     return 0;
1274     diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
1275     index ca62b99..ab98d08 100644
1276     --- a/drivers/media/video/em28xx/em28xx-cards.c
1277     +++ b/drivers/media/video/em28xx/em28xx-cards.c
1278     @@ -2875,12 +2875,20 @@ static void em28xx_card_setup(struct em28xx *dev)
1279     }
1280    
1281    
1282     -#if defined(CONFIG_MODULES) && defined(MODULE)
1283     static void request_module_async(struct work_struct *work)
1284     {
1285     struct em28xx *dev = container_of(work,
1286     struct em28xx, request_module_wk);
1287    
1288     + /*
1289     + * The em28xx extensions can be modules or builtin. If the
1290     + * modules are already loaded or are built in, those extensions
1291     + * can be initialised right now. Otherwise, the module init
1292     + * code will do it.
1293     + */
1294     + em28xx_init_extension(dev);
1295     +
1296     +#if defined(CONFIG_MODULES) && defined(MODULE)
1297     if (dev->has_audio_class)
1298     request_module("snd-usb-audio");
1299     else if (dev->has_alsa_audio)
1300     @@ -2890,6 +2898,7 @@ static void request_module_async(struct work_struct *work)
1301     request_module("em28xx-dvb");
1302     if (dev->board.ir_codes && !disable_ir)
1303     request_module("em28xx-rc");
1304     +#endif /* CONFIG_MODULES */
1305     }
1306    
1307     static void request_modules(struct em28xx *dev)
1308     @@ -2902,10 +2911,6 @@ static void flush_request_modules(struct em28xx *dev)
1309     {
1310     flush_work_sync(&dev->request_module_wk);
1311     }
1312     -#else
1313     -#define request_modules(dev)
1314     -#define flush_request_modules(dev)
1315     -#endif /* CONFIG_MODULES */
1316    
1317     /*
1318     * em28xx_release_resources()
1319     @@ -3324,13 +3329,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
1320     */
1321     mutex_unlock(&dev->lock);
1322    
1323     - /*
1324     - * These extensions can be modules. If the modules are already
1325     - * loaded then we can initialise the device now, otherwise we
1326     - * will initialise it when the modules load instead.
1327     - */
1328     - em28xx_init_extension(dev);
1329     -
1330     return 0;
1331    
1332     unlock_and_free:
1333     diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
1334     index a16531f..7353143 100644
1335     --- a/drivers/media/video/em28xx/em28xx-dvb.c
1336     +++ b/drivers/media/video/em28xx/em28xx-dvb.c
1337     @@ -316,6 +316,7 @@ static struct drxk_config terratec_h5_drxk = {
1338     .no_i2c_bridge = 1,
1339     .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
1340     .qam_demod_parameter_count = 2,
1341     + .load_firmware_sync = true,
1342     };
1343    
1344     static struct drxk_config hauppauge_930c_drxk = {
1345     @@ -325,6 +326,7 @@ static struct drxk_config hauppauge_930c_drxk = {
1346     .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw",
1347     .chunk_size = 56,
1348     .qam_demod_parameter_count = 2,
1349     + .load_firmware_sync = true,
1350     };
1351    
1352     struct drxk_config terratec_htc_stick_drxk = {
1353     @@ -338,12 +340,14 @@ struct drxk_config terratec_htc_stick_drxk = {
1354     .antenna_dvbt = true,
1355     /* The windows driver uses the same. This will disable LNA. */
1356     .antenna_gpio = 0x6,
1357     + .load_firmware_sync = true,
1358     };
1359    
1360     static struct drxk_config maxmedia_ub425_tc_drxk = {
1361     .adr = 0x29,
1362     .single_master = 1,
1363     .no_i2c_bridge = 1,
1364     + .load_firmware_sync = true,
1365     };
1366    
1367     static struct drxk_config pctv_520e_drxk = {
1368     @@ -354,6 +358,7 @@ static struct drxk_config pctv_520e_drxk = {
1369     .chunk_size = 58,
1370     .antenna_dvbt = true, /* disable LNA */
1371     .antenna_gpio = (1 << 2), /* disable LNA */
1372     + .load_firmware_sync = true,
1373     };
1374    
1375     static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
1376     diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c
1377     index 4877f7a..eb3c90e4 100644
1378     --- a/drivers/media/video/gspca/pac7302.c
1379     +++ b/drivers/media/video/gspca/pac7302.c
1380     @@ -616,7 +616,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
1381     sd->red_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1382     V4L2_CID_RED_BALANCE, 0, 3, 1, 1);
1383     sd->blue_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1384     - V4L2_CID_RED_BALANCE, 0, 3, 1, 1);
1385     + V4L2_CID_BLUE_BALANCE, 0, 3, 1, 1);
1386    
1387     gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1388     V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
1389     @@ -905,6 +905,7 @@ static const struct usb_device_id device_table[] = {
1390     {USB_DEVICE(0x093a, 0x262a)},
1391     {USB_DEVICE(0x093a, 0x262c)},
1392     {USB_DEVICE(0x145f, 0x013c)},
1393     + {USB_DEVICE(0x1ae7, 0x2001)}, /* SpeedLink Snappy Mic SL-6825-SBK */
1394     {}
1395     };
1396     MODULE_DEVICE_TABLE(usb, device_table);
1397     diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
1398     index b73f033..81ba655 100644
1399     --- a/drivers/mfd/88pm860x-core.c
1400     +++ b/drivers/mfd/88pm860x-core.c
1401     @@ -21,40 +21,73 @@
1402    
1403     #define INT_STATUS_NUM 3
1404    
1405     +static struct resource io_parent = {
1406     + .start = 0,
1407     + .end = 0xffffffff,
1408     + .flags = IORESOURCE_IO,
1409     +};
1410     +
1411     static struct resource bk_resources[] __devinitdata = {
1412     - {PM8606_BACKLIGHT1, PM8606_BACKLIGHT1, "backlight-0", IORESOURCE_IO,},
1413     - {PM8606_BACKLIGHT2, PM8606_BACKLIGHT2, "backlight-1", IORESOURCE_IO,},
1414     - {PM8606_BACKLIGHT3, PM8606_BACKLIGHT3, "backlight-2", IORESOURCE_IO,},
1415     + {PM8606_BACKLIGHT1, PM8606_BACKLIGHT1, "backlight-0", IORESOURCE_IO,
1416     + &io_parent,},
1417     + {PM8606_BACKLIGHT2, PM8606_BACKLIGHT2, "backlight-1", IORESOURCE_IO,
1418     + &io_parent,},
1419     + {PM8606_BACKLIGHT3, PM8606_BACKLIGHT3, "backlight-2", IORESOURCE_IO,
1420     + &io_parent,},
1421     };
1422    
1423     static struct resource led_resources[] __devinitdata = {
1424     - {PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_IO,},
1425     - {PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_IO,},
1426     - {PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_IO,},
1427     - {PM8606_LED2_RED, PM8606_LED2_RED, "led1-red", IORESOURCE_IO,},
1428     - {PM8606_LED2_GREEN, PM8606_LED2_GREEN, "led1-green", IORESOURCE_IO,},
1429     - {PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_IO,},
1430     + {PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_IO,
1431     + &io_parent,},
1432     + {PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_IO,
1433     + &io_parent,},
1434     + {PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_IO,
1435     + &io_parent,},
1436     + {PM8606_LED2_RED, PM8606_LED2_RED, "led1-red", IORESOURCE_IO,
1437     + &io_parent,},
1438     + {PM8606_LED2_GREEN, PM8606_LED2_GREEN, "led1-green", IORESOURCE_IO,
1439     + &io_parent,},
1440     + {PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_IO,
1441     + &io_parent,},
1442     };
1443    
1444     static struct resource regulator_resources[] __devinitdata = {
1445     - {PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_IO,},
1446     - {PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_IO,},
1447     - {PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_IO,},
1448     - {PM8607_ID_LDO1, PM8607_ID_LDO1, "ldo-01", IORESOURCE_IO,},
1449     - {PM8607_ID_LDO2, PM8607_ID_LDO2, "ldo-02", IORESOURCE_IO,},
1450     - {PM8607_ID_LDO3, PM8607_ID_LDO3, "ldo-03", IORESOURCE_IO,},
1451     - {PM8607_ID_LDO4, PM8607_ID_LDO4, "ldo-04", IORESOURCE_IO,},
1452     - {PM8607_ID_LDO5, PM8607_ID_LDO5, "ldo-05", IORESOURCE_IO,},
1453     - {PM8607_ID_LDO6, PM8607_ID_LDO6, "ldo-06", IORESOURCE_IO,},
1454     - {PM8607_ID_LDO7, PM8607_ID_LDO7, "ldo-07", IORESOURCE_IO,},
1455     - {PM8607_ID_LDO8, PM8607_ID_LDO8, "ldo-08", IORESOURCE_IO,},
1456     - {PM8607_ID_LDO9, PM8607_ID_LDO9, "ldo-09", IORESOURCE_IO,},
1457     - {PM8607_ID_LDO10, PM8607_ID_LDO10, "ldo-10", IORESOURCE_IO,},
1458     - {PM8607_ID_LDO11, PM8607_ID_LDO11, "ldo-11", IORESOURCE_IO,},
1459     - {PM8607_ID_LDO12, PM8607_ID_LDO12, "ldo-12", IORESOURCE_IO,},
1460     - {PM8607_ID_LDO13, PM8607_ID_LDO13, "ldo-13", IORESOURCE_IO,},
1461     - {PM8607_ID_LDO14, PM8607_ID_LDO14, "ldo-14", IORESOURCE_IO,},
1462     - {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,},
1463     + {PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_IO,
1464     + &io_parent,},
1465     + {PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_IO,
1466     + &io_parent,},
1467     + {PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_IO,
1468     + &io_parent,},
1469     + {PM8607_ID_LDO1, PM8607_ID_LDO1, "ldo-01", IORESOURCE_IO,
1470     + &io_parent,},
1471     + {PM8607_ID_LDO2, PM8607_ID_LDO2, "ldo-02", IORESOURCE_IO,
1472     + &io_parent,},
1473     + {PM8607_ID_LDO3, PM8607_ID_LDO3, "ldo-03", IORESOURCE_IO,
1474     + &io_parent,},
1475     + {PM8607_ID_LDO4, PM8607_ID_LDO4, "ldo-04", IORESOURCE_IO,
1476     + &io_parent,},
1477     + {PM8607_ID_LDO5, PM8607_ID_LDO5, "ldo-05", IORESOURCE_IO,
1478     + &io_parent,},
1479     + {PM8607_ID_LDO6, PM8607_ID_LDO6, "ldo-06", IORESOURCE_IO,
1480     + &io_parent,},
1481     + {PM8607_ID_LDO7, PM8607_ID_LDO7, "ldo-07", IORESOURCE_IO,
1482     + &io_parent,},
1483     + {PM8607_ID_LDO8, PM8607_ID_LDO8, "ldo-08", IORESOURCE_IO,
1484     + &io_parent,},
1485     + {PM8607_ID_LDO9, PM8607_ID_LDO9, "ldo-09", IORESOURCE_IO,
1486     + &io_parent,},
1487     + {PM8607_ID_LDO10, PM8607_ID_LDO10, "ldo-10", IORESOURCE_IO,
1488     + &io_parent,},
1489     + {PM8607_ID_LDO11, PM8607_ID_LDO11, "ldo-11", IORESOURCE_IO,
1490     + &io_parent,},
1491     + {PM8607_ID_LDO12, PM8607_ID_LDO12, "ldo-12", IORESOURCE_IO,
1492     + &io_parent,},
1493     + {PM8607_ID_LDO13, PM8607_ID_LDO13, "ldo-13", IORESOURCE_IO,
1494     + &io_parent,},
1495     + {PM8607_ID_LDO14, PM8607_ID_LDO14, "ldo-14", IORESOURCE_IO,
1496     + &io_parent,},
1497     + {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,
1498     + &io_parent,},
1499     };
1500    
1501     static struct resource touch_resources[] __devinitdata = {
1502     @@ -91,11 +124,12 @@ static struct resource charger_resources[] __devinitdata = {
1503     };
1504    
1505     static struct resource preg_resources[] __devinitdata = {
1506     - {PM8606_ID_PREG, PM8606_ID_PREG, "preg", IORESOURCE_IO,},
1507     + {PM8606_ID_PREG, PM8606_ID_PREG, "preg", IORESOURCE_IO,
1508     + &io_parent,},
1509     };
1510    
1511     static struct resource rtc_resources[] __devinitdata = {
1512     - {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
1513     + {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ, &io_parent,},
1514     };
1515    
1516     static struct mfd_cell bk_devs[] = {
1517     diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
1518     index ee53757..66d08a7 100644
1519     --- a/drivers/mfd/max8925-core.c
1520     +++ b/drivers/mfd/max8925-core.c
1521     @@ -18,12 +18,19 @@
1522     #include <linux/mfd/core.h>
1523     #include <linux/mfd/max8925.h>
1524    
1525     +static struct resource io_parent = {
1526     + .start = 0,
1527     + .end = 0xffffffff,
1528     + .flags = IORESOURCE_IO,
1529     +};
1530     +
1531     static struct resource backlight_resources[] = {
1532     {
1533     .name = "max8925-backlight",
1534     .start = MAX8925_WLED_MODE_CNTL,
1535     .end = MAX8925_WLED_CNTL,
1536     .flags = IORESOURCE_IO,
1537     + .parent = &io_parent,
1538     },
1539     };
1540    
1541     @@ -42,6 +49,7 @@ static struct resource touch_resources[] = {
1542     .start = MAX8925_TSC_IRQ,
1543     .end = MAX8925_ADC_RES_END,
1544     .flags = IORESOURCE_IO,
1545     + .parent = &io_parent,
1546     },
1547     };
1548    
1549     @@ -60,6 +68,7 @@ static struct resource power_supply_resources[] = {
1550     .start = MAX8925_CHG_IRQ1,
1551     .end = MAX8925_CHG_IRQ1_MASK,
1552     .flags = IORESOURCE_IO,
1553     + .parent = &io_parent,
1554     },
1555     };
1556    
1557     @@ -118,6 +127,7 @@ static struct mfd_cell onkey_devs[] = {
1558     .start = MAX8925_##_start, \
1559     .end = MAX8925_##_end, \
1560     .flags = IORESOURCE_IO, \
1561     + .parent = &io_parent, \
1562     }
1563    
1564     static struct resource regulator_resources[] = {
1565     diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
1566     index 0582429..08c6b3d 100644
1567     --- a/drivers/mmc/core/slot-gpio.c
1568     +++ b/drivers/mmc/core/slot-gpio.c
1569     @@ -100,7 +100,13 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
1570    
1571     ctx = host->slot.handler_priv;
1572    
1573     - return gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
1574     + ret = gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
1575     + if (ret < 0)
1576     + return ret;
1577     +
1578     + ctx->ro_gpio = gpio;
1579     +
1580     + return 0;
1581     }
1582     EXPORT_SYMBOL(mmc_gpio_request_ro);
1583    
1584     diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
1585     index 3a09f93..ed4945c 100644
1586     --- a/drivers/mmc/host/omap_hsmmc.c
1587     +++ b/drivers/mmc/host/omap_hsmmc.c
1588     @@ -2106,8 +2106,7 @@ static int omap_hsmmc_suspend(struct device *dev)
1589     if (ret) {
1590     host->suspended = 0;
1591     if (host->pdata->resume) {
1592     - ret = host->pdata->resume(dev, host->slot_id);
1593     - if (ret)
1594     + if (host->pdata->resume(dev, host->slot_id))
1595     dev_dbg(dev, "Unmask interrupt failed\n");
1596     }
1597     goto err;
1598     diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
1599     index 5d81427..ba0e493 100644
1600     --- a/drivers/mmc/host/sh_mmcif.c
1601     +++ b/drivers/mmc/host/sh_mmcif.c
1602     @@ -1229,6 +1229,10 @@ static irqreturn_t sh_mmcif_intr(int irq, void *dev_id)
1603     host->sd_error = true;
1604     dev_dbg(&host->pd->dev, "int err state = %08x\n", state);
1605     }
1606     + if (host->state == STATE_IDLE) {
1607     + dev_info(&host->pd->dev, "Spurious IRQ status 0x%x", state);
1608     + return IRQ_HANDLED;
1609     + }
1610     if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) {
1611     if (!host->dma_active)
1612     return IRQ_WAKE_THREAD;
1613     diff --git a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c
1614     index e5bfd0e..0598d52 100644
1615     --- a/drivers/mtd/maps/autcpu12-nvram.c
1616     +++ b/drivers/mtd/maps/autcpu12-nvram.c
1617     @@ -43,7 +43,8 @@ struct map_info autcpu12_sram_map = {
1618    
1619     static int __init init_autcpu12_sram (void)
1620     {
1621     - int err, save0, save1;
1622     + map_word tmp, save0, save1;
1623     + int err;
1624    
1625     autcpu12_sram_map.virt = ioremap(0x12000000, SZ_128K);
1626     if (!autcpu12_sram_map.virt) {
1627     @@ -51,7 +52,7 @@ static int __init init_autcpu12_sram (void)
1628     err = -EIO;
1629     goto out;
1630     }
1631     - simple_map_init(&autcpu_sram_map);
1632     + simple_map_init(&autcpu12_sram_map);
1633    
1634     /*
1635     * Check for 32K/128K
1636     @@ -61,20 +62,22 @@ static int __init init_autcpu12_sram (void)
1637     * Read and check result on ofs 0x0
1638     * Restore contents
1639     */
1640     - save0 = map_read32(&autcpu12_sram_map,0);
1641     - save1 = map_read32(&autcpu12_sram_map,0x10000);
1642     - map_write32(&autcpu12_sram_map,~save0,0x10000);
1643     + save0 = map_read(&autcpu12_sram_map, 0);
1644     + save1 = map_read(&autcpu12_sram_map, 0x10000);
1645     + tmp.x[0] = ~save0.x[0];
1646     + map_write(&autcpu12_sram_map, tmp, 0x10000);
1647     /* if we find this pattern on 0x0, we have 32K size
1648     * restore contents and exit
1649     */
1650     - if ( map_read32(&autcpu12_sram_map,0) != save0) {
1651     - map_write32(&autcpu12_sram_map,save0,0x0);
1652     + tmp = map_read(&autcpu12_sram_map, 0);
1653     + if (!map_word_equal(&autcpu12_sram_map, tmp, save0)) {
1654     + map_write(&autcpu12_sram_map, save0, 0x0);
1655     goto map;
1656     }
1657     /* We have a 128K found, restore 0x10000 and set size
1658     * to 128K
1659     */
1660     - map_write32(&autcpu12_sram_map,save1,0x10000);
1661     + map_write(&autcpu12_sram_map, save1, 0x10000);
1662     autcpu12_sram_map.size = SZ_128K;
1663    
1664     map:
1665     diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
1666     index d518e4d..f8c08ec 100644
1667     --- a/drivers/mtd/mtdpart.c
1668     +++ b/drivers/mtd/mtdpart.c
1669     @@ -711,6 +711,8 @@ static const char *default_mtd_part_types[] = {
1670     * partition parsers, specified in @types. However, if @types is %NULL, then
1671     * the default list of parsers is used. The default list contains only the
1672     * "cmdlinepart" and "ofpart" parsers ATM.
1673     + * Note: If there are more then one parser in @types, the kernel only takes the
1674     + * partitions parsed out by the first parser.
1675     *
1676     * This function may return:
1677     * o a negative error code in case of failure
1678     @@ -735,11 +737,12 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
1679     if (!parser)
1680     continue;
1681     ret = (*parser->parse_fn)(master, pparts, data);
1682     + put_partition_parser(parser);
1683     if (ret > 0) {
1684     printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
1685     ret, parser->name, master->name);
1686     + break;
1687     }
1688     - put_partition_parser(parser);
1689     }
1690     return ret;
1691     }
1692     diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
1693     index 30d1319..c126469 100644
1694     --- a/drivers/mtd/nand/nand_bbt.c
1695     +++ b/drivers/mtd/nand/nand_bbt.c
1696     @@ -390,7 +390,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
1697     /* Read the mirror version, if available */
1698     if (md && (md->options & NAND_BBT_VERSION)) {
1699     scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift,
1700     - mtd->writesize, td);
1701     + mtd->writesize, md);
1702     md->version[0] = buf[bbt_get_ver_offs(mtd, md)];
1703     pr_info("Bad block table at page %d, version 0x%02X\n",
1704     md->pages[0], md->version[0]);
1705     diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
1706     index cf0cd31..5d881180 100644
1707     --- a/drivers/mtd/nand/nandsim.c
1708     +++ b/drivers/mtd/nand/nandsim.c
1709     @@ -2333,6 +2333,7 @@ static int __init ns_init_module(void)
1710     uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize;
1711     if (new_size >> overridesize != nsmtd->erasesize) {
1712     NS_ERR("overridesize is too big\n");
1713     + retval = -EINVAL;
1714     goto err_exit;
1715     }
1716     /* N.B. This relies on nand_scan not doing anything with the size before we change it */
1717     diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
1718     index ac4fd75..48f1d4e 100644
1719     --- a/drivers/mtd/nand/omap2.c
1720     +++ b/drivers/mtd/nand/omap2.c
1721     @@ -1387,7 +1387,8 @@ static int omap_nand_remove(struct platform_device *pdev)
1722     /* Release NAND device, its internal structures and partitions */
1723     nand_release(&info->mtd);
1724     iounmap(info->nand.IO_ADDR_R);
1725     - kfree(&info->mtd);
1726     + release_mem_region(info->phys_base, NAND_IO_SIZE);
1727     + kfree(info);
1728     return 0;
1729     }
1730    
1731     diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
1732     index 4104ea25..56b20d1 100644
1733     --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
1734     +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
1735     @@ -2690,10 +2690,7 @@ static int ixgbe_get_ts_info(struct net_device *dev,
1736     (1 << HWTSTAMP_FILTER_NONE) |
1737     (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
1738     (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
1739     - (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
1740     - (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
1741     - (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
1742     - (1 << HWTSTAMP_FILTER_SOME);
1743     + (1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
1744     break;
1745     #endif /* CONFIG_IXGBE_PTP */
1746     default:
1747     diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
1748     index d15c888..4995673 100644
1749     --- a/drivers/net/ethernet/ti/davinci_cpdma.c
1750     +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
1751     @@ -863,6 +863,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
1752    
1753     next_dma = desc_read(desc, hw_next);
1754     chan->head = desc_from_phys(pool, next_dma);
1755     + chan->count--;
1756     chan->stats.teardown_dequeue++;
1757    
1758     /* issue callback without locks held */
1759     diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
1760     index 91d2588..1470d3e 100644
1761     --- a/drivers/net/rionet.c
1762     +++ b/drivers/net/rionet.c
1763     @@ -79,6 +79,7 @@ static int rionet_capable = 1;
1764     * on system trade-offs.
1765     */
1766     static struct rio_dev **rionet_active;
1767     +static int nact; /* total number of active rionet peers */
1768    
1769     #define is_rionet_capable(src_ops, dst_ops) \
1770     ((src_ops & RIO_SRC_OPS_DATA_MSG) && \
1771     @@ -175,6 +176,7 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1772     struct ethhdr *eth = (struct ethhdr *)skb->data;
1773     u16 destid;
1774     unsigned long flags;
1775     + int add_num = 1;
1776    
1777     local_irq_save(flags);
1778     if (!spin_trylock(&rnet->tx_lock)) {
1779     @@ -182,7 +184,10 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1780     return NETDEV_TX_LOCKED;
1781     }
1782    
1783     - if ((rnet->tx_cnt + 1) > RIONET_TX_RING_SIZE) {
1784     + if (is_multicast_ether_addr(eth->h_dest))
1785     + add_num = nact;
1786     +
1787     + if ((rnet->tx_cnt + add_num) > RIONET_TX_RING_SIZE) {
1788     netif_stop_queue(ndev);
1789     spin_unlock_irqrestore(&rnet->tx_lock, flags);
1790     printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n",
1791     @@ -191,11 +196,16 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1792     }
1793    
1794     if (is_multicast_ether_addr(eth->h_dest)) {
1795     + int count = 0;
1796     for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
1797     i++)
1798     - if (rionet_active[i])
1799     + if (rionet_active[i]) {
1800     rionet_queue_tx_msg(skb, ndev,
1801     rionet_active[i]);
1802     + if (count)
1803     + atomic_inc(&skb->users);
1804     + count++;
1805     + }
1806     } else if (RIONET_MAC_MATCH(eth->h_dest)) {
1807     destid = RIONET_GET_DESTID(eth->h_dest);
1808     if (rionet_active[destid])
1809     @@ -220,14 +230,17 @@ static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u
1810     if (info == RIONET_DOORBELL_JOIN) {
1811     if (!rionet_active[sid]) {
1812     list_for_each_entry(peer, &rionet_peers, node) {
1813     - if (peer->rdev->destid == sid)
1814     + if (peer->rdev->destid == sid) {
1815     rionet_active[sid] = peer->rdev;
1816     + nact++;
1817     + }
1818     }
1819     rio_mport_send_doorbell(mport, sid,
1820     RIONET_DOORBELL_JOIN);
1821     }
1822     } else if (info == RIONET_DOORBELL_LEAVE) {
1823     rionet_active[sid] = NULL;
1824     + nact--;
1825     } else {
1826     if (netif_msg_intr(rnet))
1827     printk(KERN_WARNING "%s: unhandled doorbell\n",
1828     @@ -523,6 +536,7 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
1829    
1830     rc = rionet_setup_netdev(rdev->net->hport, ndev);
1831     rionet_check = 1;
1832     + nact = 0;
1833     }
1834    
1835     /*
1836     diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
1837     index 32e31c5..f778aa0 100644
1838     --- a/drivers/net/usb/asix_devices.c
1839     +++ b/drivers/net/usb/asix_devices.c
1840     @@ -930,6 +930,10 @@ static const struct usb_device_id products [] = {
1841     USB_DEVICE (0x04f1, 0x3008),
1842     .driver_info = (unsigned long) &ax8817x_info,
1843     }, {
1844     + // Lenovo U2L100P 10/100
1845     + USB_DEVICE (0x17ef, 0x7203),
1846     + .driver_info = (unsigned long) &ax88772_info,
1847     +}, {
1848     // ASIX AX88772B 10/100
1849     USB_DEVICE (0x0b95, 0x772b),
1850     .driver_info = (unsigned long) &ax88772_info,
1851     diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
1852     index 9f8a6b7..61859d0 100644
1853     --- a/drivers/pci/probe.c
1854     +++ b/drivers/pci/probe.c
1855     @@ -729,8 +729,10 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
1856    
1857     /* Check if setup is sensible at all */
1858     if (!pass &&
1859     - (primary != bus->number || secondary <= bus->number)) {
1860     - dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
1861     + (primary != bus->number || secondary <= bus->number ||
1862     + secondary > subordinate)) {
1863     + dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n",
1864     + secondary, subordinate);
1865     broken = 1;
1866     }
1867    
1868     diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
1869     index aff8621..f6adde4 100644
1870     --- a/drivers/s390/scsi/zfcp_aux.c
1871     +++ b/drivers/s390/scsi/zfcp_aux.c
1872     @@ -519,6 +519,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
1873    
1874     rwlock_init(&port->unit_list_lock);
1875     INIT_LIST_HEAD(&port->unit_list);
1876     + atomic_set(&port->units, 0);
1877    
1878     INIT_WORK(&port->gid_pn_work, zfcp_fc_port_did_lookup);
1879     INIT_WORK(&port->test_link_work, zfcp_fc_link_test_work);
1880     diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
1881     index e37f045..9646766 100644
1882     --- a/drivers/s390/scsi/zfcp_ccw.c
1883     +++ b/drivers/s390/scsi/zfcp_ccw.c
1884     @@ -39,17 +39,23 @@ void zfcp_ccw_adapter_put(struct zfcp_adapter *adapter)
1885     spin_unlock_irqrestore(&zfcp_ccw_adapter_ref_lock, flags);
1886     }
1887    
1888     -static int zfcp_ccw_activate(struct ccw_device *cdev)
1889     -
1890     +/**
1891     + * zfcp_ccw_activate - activate adapter and wait for it to finish
1892     + * @cdev: pointer to belonging ccw device
1893     + * @clear: Status flags to clear.
1894     + * @tag: s390dbf trace record tag
1895     + */
1896     +static int zfcp_ccw_activate(struct ccw_device *cdev, int clear, char *tag)
1897     {
1898     struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
1899    
1900     if (!adapter)
1901     return 0;
1902    
1903     + zfcp_erp_clear_adapter_status(adapter, clear);
1904     zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING);
1905     zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
1906     - "ccresu2");
1907     + tag);
1908     zfcp_erp_wait(adapter);
1909     flush_work(&adapter->scan_work);
1910    
1911     @@ -164,26 +170,29 @@ static int zfcp_ccw_set_online(struct ccw_device *cdev)
1912     BUG_ON(!zfcp_reqlist_isempty(adapter->req_list));
1913     adapter->req_no = 0;
1914    
1915     - zfcp_ccw_activate(cdev);
1916     + zfcp_ccw_activate(cdev, 0, "ccsonl1");
1917     zfcp_ccw_adapter_put(adapter);
1918     return 0;
1919     }
1920    
1921     /**
1922     - * zfcp_ccw_set_offline - set_offline function of zfcp driver
1923     + * zfcp_ccw_offline_sync - shut down adapter and wait for it to finish
1924     * @cdev: pointer to belonging ccw device
1925     + * @set: Status flags to set.
1926     + * @tag: s390dbf trace record tag
1927     *
1928     * This function gets called by the common i/o layer and sets an adapter
1929     * into state offline.
1930     */
1931     -static int zfcp_ccw_set_offline(struct ccw_device *cdev)
1932     +static int zfcp_ccw_offline_sync(struct ccw_device *cdev, int set, char *tag)
1933     {
1934     struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
1935    
1936     if (!adapter)
1937     return 0;
1938    
1939     - zfcp_erp_adapter_shutdown(adapter, 0, "ccsoff1");
1940     + zfcp_erp_set_adapter_status(adapter, set);
1941     + zfcp_erp_adapter_shutdown(adapter, 0, tag);
1942     zfcp_erp_wait(adapter);
1943    
1944     zfcp_ccw_adapter_put(adapter);
1945     @@ -191,6 +200,18 @@ static int zfcp_ccw_set_offline(struct ccw_device *cdev)
1946     }
1947    
1948     /**
1949     + * zfcp_ccw_set_offline - set_offline function of zfcp driver
1950     + * @cdev: pointer to belonging ccw device
1951     + *
1952     + * This function gets called by the common i/o layer and sets an adapter
1953     + * into state offline.
1954     + */
1955     +static int zfcp_ccw_set_offline(struct ccw_device *cdev)
1956     +{
1957     + return zfcp_ccw_offline_sync(cdev, 0, "ccsoff1");
1958     +}
1959     +
1960     +/**
1961     * zfcp_ccw_notify - ccw notify function
1962     * @cdev: pointer to belonging ccw device
1963     * @event: indicates if adapter was detached or attached
1964     @@ -207,6 +228,11 @@ static int zfcp_ccw_notify(struct ccw_device *cdev, int event)
1965    
1966     switch (event) {
1967     case CIO_GONE:
1968     + if (atomic_read(&adapter->status) &
1969     + ZFCP_STATUS_ADAPTER_SUSPENDED) { /* notification ignore */
1970     + zfcp_dbf_hba_basic("ccnigo1", adapter);
1971     + break;
1972     + }
1973     dev_warn(&cdev->dev, "The FCP device has been detached\n");
1974     zfcp_erp_adapter_shutdown(adapter, 0, "ccnoti1");
1975     break;
1976     @@ -216,6 +242,11 @@ static int zfcp_ccw_notify(struct ccw_device *cdev, int event)
1977     zfcp_erp_adapter_shutdown(adapter, 0, "ccnoti2");
1978     break;
1979     case CIO_OPER:
1980     + if (atomic_read(&adapter->status) &
1981     + ZFCP_STATUS_ADAPTER_SUSPENDED) { /* notification ignore */
1982     + zfcp_dbf_hba_basic("ccniop1", adapter);
1983     + break;
1984     + }
1985     dev_info(&cdev->dev, "The FCP device is operational again\n");
1986     zfcp_erp_set_adapter_status(adapter,
1987     ZFCP_STATUS_COMMON_RUNNING);
1988     @@ -251,6 +282,28 @@ static void zfcp_ccw_shutdown(struct ccw_device *cdev)
1989     zfcp_ccw_adapter_put(adapter);
1990     }
1991    
1992     +static int zfcp_ccw_suspend(struct ccw_device *cdev)
1993     +{
1994     + zfcp_ccw_offline_sync(cdev, ZFCP_STATUS_ADAPTER_SUSPENDED, "ccsusp1");
1995     + return 0;
1996     +}
1997     +
1998     +static int zfcp_ccw_thaw(struct ccw_device *cdev)
1999     +{
2000     + /* trace records for thaw and final shutdown during suspend
2001     + can only be found in system dump until the end of suspend
2002     + but not after resume because it's based on the memory image
2003     + right after the very first suspend (freeze) callback */
2004     + zfcp_ccw_activate(cdev, 0, "ccthaw1");
2005     + return 0;
2006     +}
2007     +
2008     +static int zfcp_ccw_resume(struct ccw_device *cdev)
2009     +{
2010     + zfcp_ccw_activate(cdev, ZFCP_STATUS_ADAPTER_SUSPENDED, "ccresu1");
2011     + return 0;
2012     +}
2013     +
2014     struct ccw_driver zfcp_ccw_driver = {
2015     .driver = {
2016     .owner = THIS_MODULE,
2017     @@ -263,7 +316,7 @@ struct ccw_driver zfcp_ccw_driver = {
2018     .set_offline = zfcp_ccw_set_offline,
2019     .notify = zfcp_ccw_notify,
2020     .shutdown = zfcp_ccw_shutdown,
2021     - .freeze = zfcp_ccw_set_offline,
2022     - .thaw = zfcp_ccw_activate,
2023     - .restore = zfcp_ccw_activate,
2024     + .freeze = zfcp_ccw_suspend,
2025     + .thaw = zfcp_ccw_thaw,
2026     + .restore = zfcp_ccw_resume,
2027     };
2028     diff --git a/drivers/s390/scsi/zfcp_cfdc.c b/drivers/s390/scsi/zfcp_cfdc.c
2029     index fbd8b4d..49b82e4 100644
2030     --- a/drivers/s390/scsi/zfcp_cfdc.c
2031     +++ b/drivers/s390/scsi/zfcp_cfdc.c
2032     @@ -293,7 +293,7 @@ void zfcp_cfdc_adapter_access_changed(struct zfcp_adapter *adapter)
2033     }
2034     read_unlock_irqrestore(&adapter->port_list_lock, flags);
2035    
2036     - shost_for_each_device(sdev, port->adapter->scsi_host) {
2037     + shost_for_each_device(sdev, adapter->scsi_host) {
2038     zfcp_sdev = sdev_to_zfcp(sdev);
2039     status = atomic_read(&zfcp_sdev->status);
2040     if ((status & ZFCP_STATUS_COMMON_ACCESS_DENIED) ||
2041     diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
2042     index 3c1d220..e1a8cc2 100644
2043     --- a/drivers/s390/scsi/zfcp_dbf.c
2044     +++ b/drivers/s390/scsi/zfcp_dbf.c
2045     @@ -191,7 +191,7 @@ void zfcp_dbf_hba_def_err(struct zfcp_adapter *adapter, u64 req_id, u16 scount,
2046     length = min((u16)sizeof(struct qdio_buffer),
2047     (u16)ZFCP_DBF_PAY_MAX_REC);
2048    
2049     - while ((char *)pl[payload->counter] && payload->counter < scount) {
2050     + while (payload->counter < scount && (char *)pl[payload->counter]) {
2051     memcpy(payload->data, (char *)pl[payload->counter], length);
2052     debug_event(dbf->pay, 1, payload, zfcp_dbf_plen(length));
2053     payload->counter++;
2054     @@ -200,6 +200,26 @@ void zfcp_dbf_hba_def_err(struct zfcp_adapter *adapter, u64 req_id, u16 scount,
2055     spin_unlock_irqrestore(&dbf->pay_lock, flags);
2056     }
2057    
2058     +/**
2059     + * zfcp_dbf_hba_basic - trace event for basic adapter events
2060     + * @adapter: pointer to struct zfcp_adapter
2061     + */
2062     +void zfcp_dbf_hba_basic(char *tag, struct zfcp_adapter *adapter)
2063     +{
2064     + struct zfcp_dbf *dbf = adapter->dbf;
2065     + struct zfcp_dbf_hba *rec = &dbf->hba_buf;
2066     + unsigned long flags;
2067     +
2068     + spin_lock_irqsave(&dbf->hba_lock, flags);
2069     + memset(rec, 0, sizeof(*rec));
2070     +
2071     + memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
2072     + rec->id = ZFCP_DBF_HBA_BASIC;
2073     +
2074     + debug_event(dbf->hba, 1, rec, sizeof(*rec));
2075     + spin_unlock_irqrestore(&dbf->hba_lock, flags);
2076     +}
2077     +
2078     static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec,
2079     struct zfcp_adapter *adapter,
2080     struct zfcp_port *port,
2081     diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h
2082     index 714f087..3ac7a4b 100644
2083     --- a/drivers/s390/scsi/zfcp_dbf.h
2084     +++ b/drivers/s390/scsi/zfcp_dbf.h
2085     @@ -154,6 +154,7 @@ enum zfcp_dbf_hba_id {
2086     ZFCP_DBF_HBA_RES = 1,
2087     ZFCP_DBF_HBA_USS = 2,
2088     ZFCP_DBF_HBA_BIT = 3,
2089     + ZFCP_DBF_HBA_BASIC = 4,
2090     };
2091    
2092     /**
2093     diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
2094     index 2955e1a..1305955 100644
2095     --- a/drivers/s390/scsi/zfcp_def.h
2096     +++ b/drivers/s390/scsi/zfcp_def.h
2097     @@ -77,6 +77,7 @@ struct zfcp_reqlist;
2098     #define ZFCP_STATUS_ADAPTER_SIOSL_ISSUED 0x00000004
2099     #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
2100     #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
2101     +#define ZFCP_STATUS_ADAPTER_SUSPENDED 0x00000040
2102     #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
2103     #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
2104     #define ZFCP_STATUS_ADAPTER_DATA_DIV_ENABLED 0x00000400
2105     @@ -204,6 +205,7 @@ struct zfcp_port {
2106     struct zfcp_adapter *adapter; /* adapter used to access port */
2107     struct list_head unit_list; /* head of logical unit list */
2108     rwlock_t unit_list_lock; /* unit list lock */
2109     + atomic_t units; /* zfcp_unit count */
2110     atomic_t status; /* status of this remote port */
2111     u64 wwnn; /* WWNN if known */
2112     u64 wwpn; /* WWPN */
2113     diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
2114     index 36f4227..03441a7f 100644
2115     --- a/drivers/s390/scsi/zfcp_ext.h
2116     +++ b/drivers/s390/scsi/zfcp_ext.h
2117     @@ -54,6 +54,7 @@ extern void zfcp_dbf_hba_fsf_res(char *, struct zfcp_fsf_req *);
2118     extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *);
2119     extern void zfcp_dbf_hba_berr(struct zfcp_dbf *, struct zfcp_fsf_req *);
2120     extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **);
2121     +extern void zfcp_dbf_hba_basic(char *, struct zfcp_adapter *);
2122     extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32);
2123     extern void zfcp_dbf_san_res(char *, struct zfcp_fsf_req *);
2124     extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *);
2125     @@ -158,6 +159,7 @@ extern void zfcp_scsi_dif_sense_error(struct scsi_cmnd *, int);
2126     extern struct attribute_group zfcp_sysfs_unit_attrs;
2127     extern struct attribute_group zfcp_sysfs_adapter_attrs;
2128     extern struct attribute_group zfcp_sysfs_port_attrs;
2129     +extern struct mutex zfcp_sysfs_port_units_mutex;
2130     extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
2131     extern struct device_attribute *zfcp_sysfs_shost_attrs[];
2132    
2133     diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
2134     index e1c1efc..48f875f 100644
2135     --- a/drivers/s390/scsi/zfcp_fsf.c
2136     +++ b/drivers/s390/scsi/zfcp_fsf.c
2137     @@ -219,7 +219,7 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
2138     return;
2139     }
2140    
2141     - zfcp_dbf_hba_fsf_uss("fssrh_2", req);
2142     + zfcp_dbf_hba_fsf_uss("fssrh_4", req);
2143    
2144     switch (sr_buf->status_type) {
2145     case FSF_STATUS_READ_PORT_CLOSED:
2146     @@ -437,6 +437,34 @@ void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
2147     }
2148     }
2149    
2150     +#define ZFCP_FSF_PORTSPEED_1GBIT (1 << 0)
2151     +#define ZFCP_FSF_PORTSPEED_2GBIT (1 << 1)
2152     +#define ZFCP_FSF_PORTSPEED_4GBIT (1 << 2)
2153     +#define ZFCP_FSF_PORTSPEED_10GBIT (1 << 3)
2154     +#define ZFCP_FSF_PORTSPEED_8GBIT (1 << 4)
2155     +#define ZFCP_FSF_PORTSPEED_16GBIT (1 << 5)
2156     +#define ZFCP_FSF_PORTSPEED_NOT_NEGOTIATED (1 << 15)
2157     +
2158     +static u32 zfcp_fsf_convert_portspeed(u32 fsf_speed)
2159     +{
2160     + u32 fdmi_speed = 0;
2161     + if (fsf_speed & ZFCP_FSF_PORTSPEED_1GBIT)
2162     + fdmi_speed |= FC_PORTSPEED_1GBIT;
2163     + if (fsf_speed & ZFCP_FSF_PORTSPEED_2GBIT)
2164     + fdmi_speed |= FC_PORTSPEED_2GBIT;
2165     + if (fsf_speed & ZFCP_FSF_PORTSPEED_4GBIT)
2166     + fdmi_speed |= FC_PORTSPEED_4GBIT;
2167     + if (fsf_speed & ZFCP_FSF_PORTSPEED_10GBIT)
2168     + fdmi_speed |= FC_PORTSPEED_10GBIT;
2169     + if (fsf_speed & ZFCP_FSF_PORTSPEED_8GBIT)
2170     + fdmi_speed |= FC_PORTSPEED_8GBIT;
2171     + if (fsf_speed & ZFCP_FSF_PORTSPEED_16GBIT)
2172     + fdmi_speed |= FC_PORTSPEED_16GBIT;
2173     + if (fsf_speed & ZFCP_FSF_PORTSPEED_NOT_NEGOTIATED)
2174     + fdmi_speed |= FC_PORTSPEED_NOT_NEGOTIATED;
2175     + return fdmi_speed;
2176     +}
2177     +
2178     static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
2179     {
2180     struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config;
2181     @@ -456,7 +484,8 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
2182     fc_host_port_name(shost) = nsp->fl_wwpn;
2183     fc_host_node_name(shost) = nsp->fl_wwnn;
2184     fc_host_port_id(shost) = ntoh24(bottom->s_id);
2185     - fc_host_speed(shost) = bottom->fc_link_speed;
2186     + fc_host_speed(shost) =
2187     + zfcp_fsf_convert_portspeed(bottom->fc_link_speed);
2188     fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
2189    
2190     adapter->hydra_version = bottom->adapter_type;
2191     @@ -580,7 +609,8 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
2192     } else
2193     fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
2194     fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
2195     - fc_host_supported_speeds(shost) = bottom->supported_speed;
2196     + fc_host_supported_speeds(shost) =
2197     + zfcp_fsf_convert_portspeed(bottom->supported_speed);
2198     memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types,
2199     FC_FC4_LIST_SIZE);
2200     memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types,
2201     @@ -771,12 +801,14 @@ out:
2202     static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
2203     {
2204     struct scsi_device *sdev = req->data;
2205     - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2206     + struct zfcp_scsi_dev *zfcp_sdev;
2207     union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
2208    
2209     if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2210     return;
2211    
2212     + zfcp_sdev = sdev_to_zfcp(sdev);
2213     +
2214     switch (req->qtcb->header.fsf_status) {
2215     case FSF_PORT_HANDLE_NOT_VALID:
2216     if (fsq->word[0] == fsq->word[1]) {
2217     @@ -885,7 +917,7 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
2218    
2219     switch (header->fsf_status) {
2220     case FSF_GOOD:
2221     - zfcp_dbf_san_res("fsscth1", req);
2222     + zfcp_dbf_san_res("fsscth2", req);
2223     ct->status = 0;
2224     break;
2225     case FSF_SERVICE_CLASS_NOT_SUPPORTED:
2226     @@ -1739,13 +1771,15 @@ static void zfcp_fsf_open_lun_handler(struct zfcp_fsf_req *req)
2227     {
2228     struct zfcp_adapter *adapter = req->adapter;
2229     struct scsi_device *sdev = req->data;
2230     - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2231     + struct zfcp_scsi_dev *zfcp_sdev;
2232     struct fsf_qtcb_header *header = &req->qtcb->header;
2233     struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
2234    
2235     if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2236     return;
2237    
2238     + zfcp_sdev = sdev_to_zfcp(sdev);
2239     +
2240     atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
2241     ZFCP_STATUS_COMMON_ACCESS_BOXED |
2242     ZFCP_STATUS_LUN_SHARED |
2243     @@ -1856,11 +1890,13 @@ out:
2244     static void zfcp_fsf_close_lun_handler(struct zfcp_fsf_req *req)
2245     {
2246     struct scsi_device *sdev = req->data;
2247     - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2248     + struct zfcp_scsi_dev *zfcp_sdev;
2249    
2250     if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2251     return;
2252    
2253     + zfcp_sdev = sdev_to_zfcp(sdev);
2254     +
2255     switch (req->qtcb->header.fsf_status) {
2256     case FSF_PORT_HANDLE_NOT_VALID:
2257     zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fscuh_1");
2258     @@ -1950,7 +1986,7 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2259     {
2260     struct fsf_qual_latency_info *lat_in;
2261     struct latency_cont *lat = NULL;
2262     - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scsi->device);
2263     + struct zfcp_scsi_dev *zfcp_sdev;
2264     struct zfcp_blk_drv_data blktrc;
2265     int ticks = req->adapter->timer_ticks;
2266    
2267     @@ -1965,6 +2001,7 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2268    
2269     if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA &&
2270     !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2271     + zfcp_sdev = sdev_to_zfcp(scsi->device);
2272     blktrc.flags |= ZFCP_BLK_LAT_VALID;
2273     blktrc.channel_lat = lat_in->channel_lat * ticks;
2274     blktrc.fabric_lat = lat_in->fabric_lat * ticks;
2275     @@ -2002,12 +2039,14 @@ static void zfcp_fsf_fcp_handler_common(struct zfcp_fsf_req *req)
2276     {
2277     struct scsi_cmnd *scmnd = req->data;
2278     struct scsi_device *sdev = scmnd->device;
2279     - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2280     + struct zfcp_scsi_dev *zfcp_sdev;
2281     struct fsf_qtcb_header *header = &req->qtcb->header;
2282    
2283     if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
2284     return;
2285    
2286     + zfcp_sdev = sdev_to_zfcp(sdev);
2287     +
2288     switch (header->fsf_status) {
2289     case FSF_HANDLE_MISMATCH:
2290     case FSF_PORT_HANDLE_NOT_VALID:
2291     diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
2292     index b9fffc8..50b5615 100644
2293     --- a/drivers/s390/scsi/zfcp_qdio.c
2294     +++ b/drivers/s390/scsi/zfcp_qdio.c
2295     @@ -102,18 +102,22 @@ static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err,
2296     {
2297     struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm;
2298     struct zfcp_adapter *adapter = qdio->adapter;
2299     - struct qdio_buffer_element *sbale;
2300     int sbal_no, sbal_idx;
2301     - void *pl[ZFCP_QDIO_MAX_SBALS_PER_REQ + 1];
2302     - u64 req_id;
2303     - u8 scount;
2304    
2305     if (unlikely(qdio_err)) {
2306     - memset(pl, 0, ZFCP_QDIO_MAX_SBALS_PER_REQ * sizeof(void *));
2307     if (zfcp_adapter_multi_buffer_active(adapter)) {
2308     + void *pl[ZFCP_QDIO_MAX_SBALS_PER_REQ + 1];
2309     + struct qdio_buffer_element *sbale;
2310     + u64 req_id;
2311     + u8 scount;
2312     +
2313     + memset(pl, 0,
2314     + ZFCP_QDIO_MAX_SBALS_PER_REQ * sizeof(void *));
2315     sbale = qdio->res_q[idx]->element;
2316     req_id = (u64) sbale->addr;
2317     - scount = sbale->scount + 1; /* incl. signaling SBAL */
2318     + scount = min(sbale->scount + 1,
2319     + ZFCP_QDIO_MAX_SBALS_PER_REQ + 1);
2320     + /* incl. signaling SBAL */
2321    
2322     for (sbal_no = 0; sbal_no < scount; sbal_no++) {
2323     sbal_idx = (idx + sbal_no) %
2324     diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
2325     index c66af27..1e0eb08 100644
2326     --- a/drivers/s390/scsi/zfcp_sysfs.c
2327     +++ b/drivers/s390/scsi/zfcp_sysfs.c
2328     @@ -227,6 +227,8 @@ static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
2329     static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
2330     zfcp_sysfs_port_rescan_store);
2331    
2332     +DEFINE_MUTEX(zfcp_sysfs_port_units_mutex);
2333     +
2334     static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
2335     struct device_attribute *attr,
2336     const char *buf, size_t count)
2337     @@ -249,6 +251,16 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
2338     else
2339     retval = 0;
2340    
2341     + mutex_lock(&zfcp_sysfs_port_units_mutex);
2342     + if (atomic_read(&port->units) > 0) {
2343     + retval = -EBUSY;
2344     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
2345     + goto out;
2346     + }
2347     + /* port is about to be removed, so no more unit_add */
2348     + atomic_set(&port->units, -1);
2349     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
2350     +
2351     write_lock_irq(&adapter->port_list_lock);
2352     list_del(&port->list);
2353     write_unlock_irq(&adapter->port_list_lock);
2354     @@ -289,12 +301,14 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
2355     {
2356     struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
2357     u64 fcp_lun;
2358     + int retval;
2359    
2360     if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
2361     return -EINVAL;
2362    
2363     - if (zfcp_unit_add(port, fcp_lun))
2364     - return -EINVAL;
2365     + retval = zfcp_unit_add(port, fcp_lun);
2366     + if (retval)
2367     + return retval;
2368    
2369     return count;
2370     }
2371     diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
2372     index 3f2bff0..1cd2b99 100644
2373     --- a/drivers/s390/scsi/zfcp_unit.c
2374     +++ b/drivers/s390/scsi/zfcp_unit.c
2375     @@ -104,7 +104,7 @@ static void zfcp_unit_release(struct device *dev)
2376     {
2377     struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
2378    
2379     - put_device(&unit->port->dev);
2380     + atomic_dec(&unit->port->units);
2381     kfree(unit);
2382     }
2383    
2384     @@ -119,16 +119,27 @@ static void zfcp_unit_release(struct device *dev)
2385     int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
2386     {
2387     struct zfcp_unit *unit;
2388     + int retval = 0;
2389     +
2390     + mutex_lock(&zfcp_sysfs_port_units_mutex);
2391     + if (atomic_read(&port->units) == -1) {
2392     + /* port is already gone */
2393     + retval = -ENODEV;
2394     + goto out;
2395     + }
2396    
2397     unit = zfcp_unit_find(port, fcp_lun);
2398     if (unit) {
2399     put_device(&unit->dev);
2400     - return -EEXIST;
2401     + retval = -EEXIST;
2402     + goto out;
2403     }
2404    
2405     unit = kzalloc(sizeof(struct zfcp_unit), GFP_KERNEL);
2406     - if (!unit)
2407     - return -ENOMEM;
2408     + if (!unit) {
2409     + retval = -ENOMEM;
2410     + goto out;
2411     + }
2412    
2413     unit->port = port;
2414     unit->fcp_lun = fcp_lun;
2415     @@ -139,28 +150,33 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
2416     if (dev_set_name(&unit->dev, "0x%016llx",
2417     (unsigned long long) fcp_lun)) {
2418     kfree(unit);
2419     - return -ENOMEM;
2420     + retval = -ENOMEM;
2421     + goto out;
2422     }
2423    
2424     - get_device(&port->dev);
2425     -
2426     if (device_register(&unit->dev)) {
2427     put_device(&unit->dev);
2428     - return -ENOMEM;
2429     + retval = -ENOMEM;
2430     + goto out;
2431     }
2432    
2433     if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs)) {
2434     device_unregister(&unit->dev);
2435     - return -EINVAL;
2436     + retval = -EINVAL;
2437     + goto out;
2438     }
2439    
2440     + atomic_inc(&port->units); /* under zfcp_sysfs_port_units_mutex ! */
2441     +
2442     write_lock_irq(&port->unit_list_lock);
2443     list_add_tail(&unit->list, &port->unit_list);
2444     write_unlock_irq(&port->unit_list_lock);
2445    
2446     zfcp_unit_scsi_scan(unit);
2447    
2448     - return 0;
2449     +out:
2450     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
2451     + return retval;
2452     }
2453    
2454     /**
2455     diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
2456     index 68ce085..a540162 100644
2457     --- a/drivers/scsi/atp870u.c
2458     +++ b/drivers/scsi/atp870u.c
2459     @@ -1173,7 +1173,16 @@ wait_io1:
2460     outw(val, tmport);
2461     outb(2, 0x80);
2462     TCM_SYNC:
2463     - udelay(0x800);
2464     + /*
2465     + * The funny division into multiple delays is to accomodate
2466     + * arches like ARM where udelay() multiplies its argument by
2467     + * a large number to initialize a loop counter. To avoid
2468     + * overflow, the maximum supported udelay is 2000 microseconds.
2469     + *
2470     + * XXX it would be more polite to find a way to use msleep()
2471     + */
2472     + mdelay(2);
2473     + udelay(48);
2474     if ((inb(tmport) & 0x80) == 0x00) { /* bsy ? */
2475     outw(0, tmport--);
2476     outb(0, tmport);
2477     diff --git a/fs/buffer.c b/fs/buffer.c
2478     index 58e2e7b..b5f0442 100644
2479     --- a/fs/buffer.c
2480     +++ b/fs/buffer.c
2481     @@ -2312,12 +2312,6 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
2482     loff_t size;
2483     int ret;
2484    
2485     - /*
2486     - * Update file times before taking page lock. We may end up failing the
2487     - * fault so this update may be superfluous but who really cares...
2488     - */
2489     - file_update_time(vma->vm_file);
2490     -
2491     lock_page(page);
2492     size = i_size_read(inode);
2493     if ((page->mapping != inode->i_mapping) ||
2494     @@ -2355,6 +2349,13 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
2495     struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb;
2496    
2497     sb_start_pagefault(sb);
2498     +
2499     + /*
2500     + * Update file times before taking page lock. We may end up failing the
2501     + * fault so this update may be superfluous but who really cares...
2502     + */
2503     + file_update_time(vma->vm_file);
2504     +
2505     ret = __block_page_mkwrite(vma, vmf, get_block);
2506     sb_end_pagefault(sb);
2507     return block_page_mkwrite_return(ret);
2508     diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
2509     index 53cf2aa..71d5d0a 100644
2510     --- a/fs/cifs/cifs_unicode.c
2511     +++ b/fs/cifs/cifs_unicode.c
2512     @@ -203,6 +203,27 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len,
2513     int i;
2514     wchar_t wchar_to; /* needed to quiet sparse */
2515    
2516     + /* special case for utf8 to handle no plane0 chars */
2517     + if (!strcmp(codepage->charset, "utf8")) {
2518     + /*
2519     + * convert utf8 -> utf16, we assume we have enough space
2520     + * as caller should have assumed conversion does not overflow
2521     + * in destination len is length in wchar_t units (16bits)
2522     + */
2523     + i = utf8s_to_utf16s(from, len, UTF16_LITTLE_ENDIAN,
2524     + (wchar_t *) to, len);
2525     +
2526     + /* if success terminate and exit */
2527     + if (i >= 0)
2528     + goto success;
2529     + /*
2530     + * if fails fall back to UCS encoding as this
2531     + * function should not return negative values
2532     + * currently can fail only if source contains
2533     + * invalid encoded characters
2534     + */
2535     + }
2536     +
2537     for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
2538     charlen = codepage->char2uni(from, len, &wchar_to);
2539     if (charlen < 1) {
2540     @@ -215,6 +236,7 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len,
2541     put_unaligned_le16(wchar_to, &to[i]);
2542     }
2543    
2544     +success:
2545     put_unaligned_le16(0, &to[i]);
2546     return i;
2547     }
2548     diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
2549     index 6df6fa1..b39bb4a 100644
2550     --- a/fs/cifs/connect.c
2551     +++ b/fs/cifs/connect.c
2552     @@ -67,6 +67,7 @@ enum {
2553     /* Mount options that take no arguments */
2554     Opt_user_xattr, Opt_nouser_xattr,
2555     Opt_forceuid, Opt_noforceuid,
2556     + Opt_forcegid, Opt_noforcegid,
2557     Opt_noblocksend, Opt_noautotune,
2558     Opt_hard, Opt_soft, Opt_perm, Opt_noperm,
2559     Opt_mapchars, Opt_nomapchars, Opt_sfu,
2560     @@ -118,6 +119,8 @@ static const match_table_t cifs_mount_option_tokens = {
2561     { Opt_nouser_xattr, "nouser_xattr" },
2562     { Opt_forceuid, "forceuid" },
2563     { Opt_noforceuid, "noforceuid" },
2564     + { Opt_forcegid, "forcegid" },
2565     + { Opt_noforcegid, "noforcegid" },
2566     { Opt_noblocksend, "noblocksend" },
2567     { Opt_noautotune, "noautotune" },
2568     { Opt_hard, "hard" },
2569     @@ -1190,6 +1193,12 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
2570     case Opt_noforceuid:
2571     override_uid = 0;
2572     break;
2573     + case Opt_forcegid:
2574     + override_gid = 1;
2575     + break;
2576     + case Opt_noforcegid:
2577     + override_gid = 0;
2578     + break;
2579     case Opt_noblocksend:
2580     vol->noblocksnd = 1;
2581     break;
2582     diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2583     index dff171c..2ce16af 100644
2584     --- a/fs/ext4/inode.c
2585     +++ b/fs/ext4/inode.c
2586     @@ -2463,6 +2463,16 @@ static int ext4_nonda_switch(struct super_block *sb)
2587     free_blocks = EXT4_C2B(sbi,
2588     percpu_counter_read_positive(&sbi->s_freeclusters_counter));
2589     dirty_blocks = percpu_counter_read_positive(&sbi->s_dirtyclusters_counter);
2590     + /*
2591     + * Start pushing delalloc when 1/2 of free blocks are dirty.
2592     + */
2593     + if (dirty_blocks && (free_blocks < 2 * dirty_blocks) &&
2594     + !writeback_in_progress(sb->s_bdi) &&
2595     + down_read_trylock(&sb->s_umount)) {
2596     + writeback_inodes_sb(sb, WB_REASON_FS_FREE_SPACE);
2597     + up_read(&sb->s_umount);
2598     + }
2599     +
2600     if (2 * free_blocks < 3 * dirty_blocks ||
2601     free_blocks < (dirty_blocks + EXT4_FREECLUSTERS_WATERMARK)) {
2602     /*
2603     @@ -2471,13 +2481,6 @@ static int ext4_nonda_switch(struct super_block *sb)
2604     */
2605     return 1;
2606     }
2607     - /*
2608     - * Even if we don't switch but are nearing capacity,
2609     - * start pushing delalloc when 1/2 of free blocks are dirty.
2610     - */
2611     - if (free_blocks < 2 * dirty_blocks)
2612     - writeback_inodes_sb_if_idle(sb, WB_REASON_FS_FREE_SPACE);
2613     -
2614     return 0;
2615     }
2616    
2617     @@ -4052,6 +4055,7 @@ static int ext4_do_update_inode(handle_t *handle,
2618     struct ext4_inode_info *ei = EXT4_I(inode);
2619     struct buffer_head *bh = iloc->bh;
2620     int err = 0, rc, block;
2621     + int need_datasync = 0;
2622     uid_t i_uid;
2623     gid_t i_gid;
2624    
2625     @@ -4102,7 +4106,10 @@ static int ext4_do_update_inode(handle_t *handle,
2626     raw_inode->i_file_acl_high =
2627     cpu_to_le16(ei->i_file_acl >> 32);
2628     raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
2629     - ext4_isize_set(raw_inode, ei->i_disksize);
2630     + if (ei->i_disksize != ext4_isize(raw_inode)) {
2631     + ext4_isize_set(raw_inode, ei->i_disksize);
2632     + need_datasync = 1;
2633     + }
2634     if (ei->i_disksize > 0x7fffffffULL) {
2635     struct super_block *sb = inode->i_sb;
2636     if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
2637     @@ -4155,7 +4162,7 @@ static int ext4_do_update_inode(handle_t *handle,
2638     err = rc;
2639     ext4_clear_inode_state(inode, EXT4_STATE_NEW);
2640    
2641     - ext4_update_inode_fsync_trans(handle, inode, 0);
2642     + ext4_update_inode_fsync_trans(handle, inode, need_datasync);
2643     out_brelse:
2644     brelse(bh);
2645     ext4_std_error(inode->i_sb, err);
2646     @@ -4780,6 +4787,7 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
2647     int retries = 0;
2648    
2649     sb_start_pagefault(inode->i_sb);
2650     + file_update_time(vma->vm_file);
2651     /* Delalloc case is easy... */
2652     if (test_opt(inode->i_sb, DELALLOC) &&
2653     !ext4_should_journal_data(inode) &&
2654     diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
2655     index c5826c6..e2016f3 100644
2656     --- a/fs/ext4/move_extent.c
2657     +++ b/fs/ext4/move_extent.c
2658     @@ -141,55 +141,21 @@ mext_next_extent(struct inode *inode, struct ext4_ext_path *path,
2659     }
2660    
2661     /**
2662     - * mext_check_null_inode - NULL check for two inodes
2663     - *
2664     - * If inode1 or inode2 is NULL, return -EIO. Otherwise, return 0.
2665     - */
2666     -static int
2667     -mext_check_null_inode(struct inode *inode1, struct inode *inode2,
2668     - const char *function, unsigned int line)
2669     -{
2670     - int ret = 0;
2671     -
2672     - if (inode1 == NULL) {
2673     - __ext4_error(inode2->i_sb, function, line,
2674     - "Both inodes should not be NULL: "
2675     - "inode1 NULL inode2 %lu", inode2->i_ino);
2676     - ret = -EIO;
2677     - } else if (inode2 == NULL) {
2678     - __ext4_error(inode1->i_sb, function, line,
2679     - "Both inodes should not be NULL: "
2680     - "inode1 %lu inode2 NULL", inode1->i_ino);
2681     - ret = -EIO;
2682     - }
2683     - return ret;
2684     -}
2685     -
2686     -/**
2687     * double_down_write_data_sem - Acquire two inodes' write lock of i_data_sem
2688     *
2689     - * @orig_inode: original inode structure
2690     - * @donor_inode: donor inode structure
2691     - * Acquire write lock of i_data_sem of the two inodes (orig and donor) by
2692     - * i_ino order.
2693     + * Acquire write lock of i_data_sem of the two inodes
2694     */
2695     static void
2696     -double_down_write_data_sem(struct inode *orig_inode, struct inode *donor_inode)
2697     +double_down_write_data_sem(struct inode *first, struct inode *second)
2698     {
2699     - struct inode *first = orig_inode, *second = donor_inode;
2700     + if (first < second) {
2701     + down_write(&EXT4_I(first)->i_data_sem);
2702     + down_write_nested(&EXT4_I(second)->i_data_sem, SINGLE_DEPTH_NESTING);
2703     + } else {
2704     + down_write(&EXT4_I(second)->i_data_sem);
2705     + down_write_nested(&EXT4_I(first)->i_data_sem, SINGLE_DEPTH_NESTING);
2706    
2707     - /*
2708     - * Use the inode number to provide the stable locking order instead
2709     - * of its address, because the C language doesn't guarantee you can
2710     - * compare pointers that don't come from the same array.
2711     - */
2712     - if (donor_inode->i_ino < orig_inode->i_ino) {
2713     - first = donor_inode;
2714     - second = orig_inode;
2715     }
2716     -
2717     - down_write(&EXT4_I(first)->i_data_sem);
2718     - down_write_nested(&EXT4_I(second)->i_data_sem, SINGLE_DEPTH_NESTING);
2719     }
2720    
2721     /**
2722     @@ -969,14 +935,6 @@ mext_check_arguments(struct inode *orig_inode,
2723     return -EINVAL;
2724     }
2725    
2726     - /* Files should be in the same ext4 FS */
2727     - if (orig_inode->i_sb != donor_inode->i_sb) {
2728     - ext4_debug("ext4 move extent: The argument files "
2729     - "should be in same FS [ino:orig %lu, donor %lu]\n",
2730     - orig_inode->i_ino, donor_inode->i_ino);
2731     - return -EINVAL;
2732     - }
2733     -
2734     /* Ext4 move extent supports only extent based file */
2735     if (!(ext4_test_inode_flag(orig_inode, EXT4_INODE_EXTENTS))) {
2736     ext4_debug("ext4 move extent: orig file is not extents "
2737     @@ -1072,35 +1030,19 @@ mext_check_arguments(struct inode *orig_inode,
2738     * @inode1: the inode structure
2739     * @inode2: the inode structure
2740     *
2741     - * Lock two inodes' i_mutex by i_ino order.
2742     - * If inode1 or inode2 is NULL, return -EIO. Otherwise, return 0.
2743     + * Lock two inodes' i_mutex
2744     */
2745     -static int
2746     +static void
2747     mext_inode_double_lock(struct inode *inode1, struct inode *inode2)
2748     {
2749     - int ret = 0;
2750     -
2751     - BUG_ON(inode1 == NULL && inode2 == NULL);
2752     -
2753     - ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__);
2754     - if (ret < 0)
2755     - goto out;
2756     -
2757     - if (inode1 == inode2) {
2758     - mutex_lock(&inode1->i_mutex);
2759     - goto out;
2760     - }
2761     -
2762     - if (inode1->i_ino < inode2->i_ino) {
2763     + BUG_ON(inode1 == inode2);
2764     + if (inode1 < inode2) {
2765     mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT);
2766     mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD);
2767     } else {
2768     mutex_lock_nested(&inode2->i_mutex, I_MUTEX_PARENT);
2769     mutex_lock_nested(&inode1->i_mutex, I_MUTEX_CHILD);
2770     }
2771     -
2772     -out:
2773     - return ret;
2774     }
2775    
2776     /**
2777     @@ -1109,28 +1051,13 @@ out:
2778     * @inode1: the inode that is released first
2779     * @inode2: the inode that is released second
2780     *
2781     - * If inode1 or inode2 is NULL, return -EIO. Otherwise, return 0.
2782     */
2783    
2784     -static int
2785     +static void
2786     mext_inode_double_unlock(struct inode *inode1, struct inode *inode2)
2787     {
2788     - int ret = 0;
2789     -
2790     - BUG_ON(inode1 == NULL && inode2 == NULL);
2791     -
2792     - ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__);
2793     - if (ret < 0)
2794     - goto out;
2795     -
2796     - if (inode1)
2797     - mutex_unlock(&inode1->i_mutex);
2798     -
2799     - if (inode2 && inode2 != inode1)
2800     - mutex_unlock(&inode2->i_mutex);
2801     -
2802     -out:
2803     - return ret;
2804     + mutex_unlock(&inode1->i_mutex);
2805     + mutex_unlock(&inode2->i_mutex);
2806     }
2807    
2808     /**
2809     @@ -1187,16 +1114,23 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2810     ext4_lblk_t block_end, seq_start, add_blocks, file_end, seq_blocks = 0;
2811     ext4_lblk_t rest_blocks;
2812     pgoff_t orig_page_offset = 0, seq_end_page;
2813     - int ret1, ret2, depth, last_extent = 0;
2814     + int ret, depth, last_extent = 0;
2815     int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits;
2816     int data_offset_in_page;
2817     int block_len_in_page;
2818     int uninit;
2819    
2820     - /* orig and donor should be different file */
2821     - if (orig_inode->i_ino == donor_inode->i_ino) {
2822     + if (orig_inode->i_sb != donor_inode->i_sb) {
2823     + ext4_debug("ext4 move extent: The argument files "
2824     + "should be in same FS [ino:orig %lu, donor %lu]\n",
2825     + orig_inode->i_ino, donor_inode->i_ino);
2826     + return -EINVAL;
2827     + }
2828     +
2829     + /* orig and donor should be different inodes */
2830     + if (orig_inode == donor_inode) {
2831     ext4_debug("ext4 move extent: The argument files should not "
2832     - "be same file [ino:orig %lu, donor %lu]\n",
2833     + "be same inode [ino:orig %lu, donor %lu]\n",
2834     orig_inode->i_ino, donor_inode->i_ino);
2835     return -EINVAL;
2836     }
2837     @@ -1208,18 +1142,21 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2838     orig_inode->i_ino, donor_inode->i_ino);
2839     return -EINVAL;
2840     }
2841     -
2842     + /* TODO: This is non obvious task to swap blocks for inodes with full
2843     + jornaling enabled */
2844     + if (ext4_should_journal_data(orig_inode) ||
2845     + ext4_should_journal_data(donor_inode)) {
2846     + return -EINVAL;
2847     + }
2848     /* Protect orig and donor inodes against a truncate */
2849     - ret1 = mext_inode_double_lock(orig_inode, donor_inode);
2850     - if (ret1 < 0)
2851     - return ret1;
2852     + mext_inode_double_lock(orig_inode, donor_inode);
2853    
2854     /* Protect extent tree against block allocations via delalloc */
2855     double_down_write_data_sem(orig_inode, donor_inode);
2856     /* Check the filesystem environment whether move_extent can be done */
2857     - ret1 = mext_check_arguments(orig_inode, donor_inode, orig_start,
2858     + ret = mext_check_arguments(orig_inode, donor_inode, orig_start,
2859     donor_start, &len);
2860     - if (ret1)
2861     + if (ret)
2862     goto out;
2863    
2864     file_end = (i_size_read(orig_inode) - 1) >> orig_inode->i_blkbits;
2865     @@ -1227,13 +1164,13 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2866     if (file_end < block_end)
2867     len -= block_end - file_end;
2868    
2869     - ret1 = get_ext_path(orig_inode, block_start, &orig_path);
2870     - if (ret1)
2871     + ret = get_ext_path(orig_inode, block_start, &orig_path);
2872     + if (ret)
2873     goto out;
2874    
2875     /* Get path structure to check the hole */
2876     - ret1 = get_ext_path(orig_inode, block_start, &holecheck_path);
2877     - if (ret1)
2878     + ret = get_ext_path(orig_inode, block_start, &holecheck_path);
2879     + if (ret)
2880     goto out;
2881    
2882     depth = ext_depth(orig_inode);
2883     @@ -1252,13 +1189,13 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2884     last_extent = mext_next_extent(orig_inode,
2885     holecheck_path, &ext_cur);
2886     if (last_extent < 0) {
2887     - ret1 = last_extent;
2888     + ret = last_extent;
2889     goto out;
2890     }
2891     last_extent = mext_next_extent(orig_inode, orig_path,
2892     &ext_dummy);
2893     if (last_extent < 0) {
2894     - ret1 = last_extent;
2895     + ret = last_extent;
2896     goto out;
2897     }
2898     seq_start = le32_to_cpu(ext_cur->ee_block);
2899     @@ -1272,7 +1209,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2900     if (le32_to_cpu(ext_cur->ee_block) > block_end) {
2901     ext4_debug("ext4 move extent: The specified range of file "
2902     "may be the hole\n");
2903     - ret1 = -EINVAL;
2904     + ret = -EINVAL;
2905     goto out;
2906     }
2907    
2908     @@ -1292,7 +1229,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2909     last_extent = mext_next_extent(orig_inode, holecheck_path,
2910     &ext_cur);
2911     if (last_extent < 0) {
2912     - ret1 = last_extent;
2913     + ret = last_extent;
2914     break;
2915     }
2916     add_blocks = ext4_ext_get_actual_len(ext_cur);
2917     @@ -1349,18 +1286,18 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2918     orig_page_offset,
2919     data_offset_in_page,
2920     block_len_in_page, uninit,
2921     - &ret1);
2922     + &ret);
2923    
2924     /* Count how many blocks we have exchanged */
2925     *moved_len += block_len_in_page;
2926     - if (ret1 < 0)
2927     + if (ret < 0)
2928     break;
2929     if (*moved_len > len) {
2930     EXT4_ERROR_INODE(orig_inode,
2931     "We replaced blocks too much! "
2932     "sum of replaced: %llu requested: %llu",
2933     *moved_len, len);
2934     - ret1 = -EIO;
2935     + ret = -EIO;
2936     break;
2937     }
2938    
2939     @@ -1374,22 +1311,22 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
2940     }
2941    
2942     double_down_write_data_sem(orig_inode, donor_inode);
2943     - if (ret1 < 0)
2944     + if (ret < 0)
2945     break;
2946    
2947     /* Decrease buffer counter */
2948     if (holecheck_path)
2949     ext4_ext_drop_refs(holecheck_path);
2950     - ret1 = get_ext_path(orig_inode, seq_start, &holecheck_path);
2951     - if (ret1)
2952     + ret = get_ext_path(orig_inode, seq_start, &holecheck_path);
2953     + if (ret)
2954     break;
2955     depth = holecheck_path->p_depth;
2956    
2957     /* Decrease buffer counter */
2958     if (orig_path)
2959     ext4_ext_drop_refs(orig_path);
2960     - ret1 = get_ext_path(orig_inode, seq_start, &orig_path);
2961     - if (ret1)
2962     + ret = get_ext_path(orig_inode, seq_start, &orig_path);
2963     + if (ret)
2964     break;
2965    
2966     ext_cur = holecheck_path[depth].p_ext;
2967     @@ -1412,12 +1349,7 @@ out:
2968     kfree(holecheck_path);
2969     }
2970     double_up_write_data_sem(orig_inode, donor_inode);
2971     - ret2 = mext_inode_double_unlock(orig_inode, donor_inode);
2972     -
2973     - if (ret1)
2974     - return ret1;
2975     - else if (ret2)
2976     - return ret2;
2977     + mext_inode_double_unlock(orig_inode, donor_inode);
2978    
2979     - return 0;
2980     + return ret;
2981     }
2982     diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
2983     index 2a42cc0..d13873d 100644
2984     --- a/fs/ext4/namei.c
2985     +++ b/fs/ext4/namei.c
2986     @@ -2149,9 +2149,7 @@ retry:
2987     err = PTR_ERR(inode);
2988     if (!IS_ERR(inode)) {
2989     init_special_inode(inode, inode->i_mode, rdev);
2990     -#ifdef CONFIG_EXT4_FS_XATTR
2991     inode->i_op = &ext4_special_inode_operations;
2992     -#endif
2993     err = ext4_add_nondir(handle, dentry, inode);
2994     }
2995     ext4_journal_stop(handle);
2996     diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
2997     index 41f6ef6..0be1789 100644
2998     --- a/fs/ext4/resize.c
2999     +++ b/fs/ext4/resize.c
3000     @@ -200,8 +200,11 @@ static void free_flex_gd(struct ext4_new_flex_group_data *flex_gd)
3001     * be a partial of a flex group.
3002     *
3003     * @sb: super block of fs to which the groups belongs
3004     + *
3005     + * Returns 0 on a successful allocation of the metadata blocks in the
3006     + * block group.
3007     */
3008     -static void ext4_alloc_group_tables(struct super_block *sb,
3009     +static int ext4_alloc_group_tables(struct super_block *sb,
3010     struct ext4_new_flex_group_data *flex_gd,
3011     int flexbg_size)
3012     {
3013     @@ -226,6 +229,8 @@ static void ext4_alloc_group_tables(struct super_block *sb,
3014     (last_group & ~(flexbg_size - 1))));
3015     next_group:
3016     group = group_data[0].group;
3017     + if (src_group >= group_data[0].group + flex_gd->count)
3018     + return -ENOSPC;
3019     start_blk = ext4_group_first_block_no(sb, src_group);
3020     last_blk = start_blk + group_data[src_group - group].blocks_count;
3021    
3022     @@ -235,7 +240,6 @@ next_group:
3023    
3024     start_blk += overhead;
3025    
3026     - BUG_ON(src_group >= group_data[0].group + flex_gd->count);
3027     /* We collect contiguous blocks as much as possible. */
3028     src_group++;
3029     for (; src_group <= last_group; src_group++)
3030     @@ -300,6 +304,7 @@ next_group:
3031     group_data[i].free_blocks_count);
3032     }
3033     }
3034     + return 0;
3035     }
3036    
3037     static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
3038     @@ -451,6 +456,9 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
3039     gdblocks = ext4_bg_num_gdb(sb, group);
3040     start = ext4_group_first_block_no(sb, group);
3041    
3042     + if (!ext4_bg_has_super(sb, group))
3043     + goto handle_itb;
3044     +
3045     /* Copy all of the GDT blocks into the backup in this group */
3046     for (j = 0, block = start + 1; j < gdblocks; j++, block++) {
3047     struct buffer_head *gdb;
3048     @@ -493,6 +501,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
3049     goto out;
3050     }
3051    
3052     +handle_itb:
3053     /* Initialize group tables of the grop @group */
3054     if (!(bg_flags[i] & EXT4_BG_INODE_ZEROED))
3055     goto handle_bb;
3056     @@ -1349,13 +1358,15 @@ exit_journal:
3057     err = err2;
3058    
3059     if (!err) {
3060     - int i;
3061     + int gdb_num = group / EXT4_DESC_PER_BLOCK(sb);
3062     + int gdb_num_end = ((group + flex_gd->count - 1) /
3063     + EXT4_DESC_PER_BLOCK(sb));
3064     +
3065     update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
3066     sizeof(struct ext4_super_block));
3067     - for (i = 0; i < flex_gd->count; i++, group++) {
3068     + for (; gdb_num <= gdb_num_end; gdb_num++) {
3069     struct buffer_head *gdb_bh;
3070     - int gdb_num;
3071     - gdb_num = group / EXT4_BLOCKS_PER_GROUP(sb);
3072     +
3073     gdb_bh = sbi->s_group_desc[gdb_num];
3074     update_backups(sb, gdb_bh->b_blocknr, gdb_bh->b_data,
3075     gdb_bh->b_size);
3076     @@ -1729,7 +1740,8 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
3077     */
3078     while (ext4_setup_next_flex_gd(sb, flex_gd, n_blocks_count,
3079     flexbg_size)) {
3080     - ext4_alloc_group_tables(sb, flex_gd, flexbg_size);
3081     + if (ext4_alloc_group_tables(sb, flex_gd, flexbg_size) != 0)
3082     + break;
3083     err = ext4_flex_group_add(sb, resize_inode, flex_gd);
3084     if (unlikely(err))
3085     break;
3086     diff --git a/fs/ext4/super.c b/fs/ext4/super.c
3087     index c6e0cb3..e44b233 100644
3088     --- a/fs/ext4/super.c
3089     +++ b/fs/ext4/super.c
3090     @@ -1735,7 +1735,7 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
3091    
3092     static const char *token2str(int token)
3093     {
3094     - static const struct match_token *t;
3095     + const struct match_token *t;
3096    
3097     for (t = tokens; t->token != Opt_err; t++)
3098     if (t->token == token && !strchr(t->pattern, '='))
3099     diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
3100     index be3efc4..5602d73 100644
3101     --- a/fs/fs-writeback.c
3102     +++ b/fs/fs-writeback.c
3103     @@ -63,6 +63,7 @@ int writeback_in_progress(struct backing_dev_info *bdi)
3104     {
3105     return test_bit(BDI_writeback_running, &bdi->state);
3106     }
3107     +EXPORT_SYMBOL(writeback_in_progress);
3108    
3109     static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
3110     {
3111     diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
3112     index e149b99..484b8d1 100644
3113     --- a/fs/jbd2/journal.c
3114     +++ b/fs/jbd2/journal.c
3115     @@ -1354,6 +1354,11 @@ static void jbd2_mark_journal_empty(journal_t *journal)
3116    
3117     BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
3118     read_lock(&journal->j_state_lock);
3119     + /* Is it already empty? */
3120     + if (sb->s_start == 0) {
3121     + read_unlock(&journal->j_state_lock);
3122     + return;
3123     + }
3124     jbd_debug(1, "JBD2: Marking journal as empty (seq %d)\n",
3125     journal->j_tail_sequence);
3126    
3127     diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
3128     index 61ea413..1224d6b 100644
3129     --- a/fs/jffs2/super.c
3130     +++ b/fs/jffs2/super.c
3131     @@ -100,6 +100,10 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
3132     {
3133     struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
3134    
3135     +#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
3136     + cancel_delayed_work_sync(&c->wbuf_dwork);
3137     +#endif
3138     +
3139     mutex_lock(&c->alloc_sem);
3140     jffs2_flush_wbuf_pad(c);
3141     mutex_unlock(&c->alloc_sem);
3142     diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
3143     index 6f4529d..a6597d6 100644
3144     --- a/fs/jffs2/wbuf.c
3145     +++ b/fs/jffs2/wbuf.c
3146     @@ -1044,10 +1044,10 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
3147     ops.datbuf = NULL;
3148    
3149     ret = mtd_read_oob(c->mtd, jeb->offset, &ops);
3150     - if (ret || ops.oobretlen != ops.ooblen) {
3151     + if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) {
3152     pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n",
3153     jeb->offset, ops.ooblen, ops.oobretlen, ret);
3154     - if (!ret)
3155     + if (!ret || mtd_is_bitflip(ret))
3156     ret = -EIO;
3157     return ret;
3158     }
3159     @@ -1086,10 +1086,10 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c,
3160     ops.datbuf = NULL;
3161    
3162     ret = mtd_read_oob(c->mtd, jeb->offset, &ops);
3163     - if (ret || ops.oobretlen != ops.ooblen) {
3164     + if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) {
3165     pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n",
3166     jeb->offset, ops.ooblen, ops.oobretlen, ret);
3167     - if (!ret)
3168     + if (!ret || mtd_is_bitflip(ret))
3169     ret = -EIO;
3170     return ret;
3171     }
3172     diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
3173     index a4d56ac..5b387a4 100644
3174     --- a/fs/nilfs2/file.c
3175     +++ b/fs/nilfs2/file.c
3176     @@ -116,6 +116,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
3177     if (unlikely(ret))
3178     goto out;
3179    
3180     + file_update_time(vma->vm_file);
3181     ret = __block_page_mkwrite(vma, vmf, nilfs_get_block);
3182     if (ret) {
3183     nilfs_transaction_abort(inode->i_sb);
3184     diff --git a/fs/proc/page.c b/fs/proc/page.c
3185     index 7fcd0d6..b8730d9 100644
3186     --- a/fs/proc/page.c
3187     +++ b/fs/proc/page.c
3188     @@ -115,7 +115,13 @@ u64 stable_page_flags(struct page *page)
3189     u |= 1 << KPF_COMPOUND_TAIL;
3190     if (PageHuge(page))
3191     u |= 1 << KPF_HUGE;
3192     - else if (PageTransCompound(page))
3193     + /*
3194     + * PageTransCompound can be true for non-huge compound pages (slab
3195     + * pages or pages allocated by drivers with __GFP_COMP) because it
3196     + * just checks PG_head/PG_tail, so we need to check PageLRU to make
3197     + * sure a given page is a thp, not a non-huge compound page.
3198     + */
3199     + else if (PageTransCompound(page) && PageLRU(compound_trans_head(page)))
3200     u |= 1 << KPF_THP;
3201    
3202     /*
3203     diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
3204     index 95b738c..df08254 100644
3205     --- a/include/linux/mempolicy.h
3206     +++ b/include/linux/mempolicy.h
3207     @@ -188,7 +188,7 @@ struct sp_node {
3208    
3209     struct shared_policy {
3210     struct rb_root root;
3211     - spinlock_t lock;
3212     + struct mutex mutex;
3213     };
3214    
3215     void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol);
3216     diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
3217     index 926142e..9497be1 100644
3218     --- a/include/net/ip_fib.h
3219     +++ b/include/net/ip_fib.h
3220     @@ -102,6 +102,7 @@ struct fib_info {
3221     unsigned char fib_dead;
3222     unsigned char fib_protocol;
3223     unsigned char fib_scope;
3224     + unsigned char fib_type;
3225     __be32 fib_prefsrc;
3226     u32 fib_priority;
3227     u32 *fib_metrics;
3228     diff --git a/kernel/rcutree.c b/kernel/rcutree.c
3229     index f280e54..f7bcd9e 100644
3230     --- a/kernel/rcutree.c
3231     +++ b/kernel/rcutree.c
3232     @@ -305,7 +305,9 @@ cpu_has_callbacks_ready_to_invoke(struct rcu_data *rdp)
3233     static int
3234     cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
3235     {
3236     - return *rdp->nxttail[RCU_DONE_TAIL] && !rcu_gp_in_progress(rsp);
3237     + return *rdp->nxttail[RCU_DONE_TAIL +
3238     + ACCESS_ONCE(rsp->completed) != rdp->completed] &&
3239     + !rcu_gp_in_progress(rsp);
3240     }
3241    
3242     /*
3243     diff --git a/kernel/sched/core.c b/kernel/sched/core.c
3244     index 649c9f8..1a48cdb 100644
3245     --- a/kernel/sched/core.c
3246     +++ b/kernel/sched/core.c
3247     @@ -5604,7 +5604,9 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
3248     migrate_tasks(cpu);
3249     BUG_ON(rq->nr_running != 1); /* the migration thread */
3250     raw_spin_unlock_irqrestore(&rq->lock, flags);
3251     + break;
3252    
3253     + case CPU_DEAD:
3254     calc_load_migrate(rq);
3255     break;
3256     #endif
3257     diff --git a/kernel/sys.c b/kernel/sys.c
3258     index 241507f..6fab59a 100644
3259     --- a/kernel/sys.c
3260     +++ b/kernel/sys.c
3261     @@ -368,6 +368,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
3262     void kernel_restart(char *cmd)
3263     {
3264     kernel_restart_prepare(cmd);
3265     + disable_nonboot_cpus();
3266     if (!cmd)
3267     printk(KERN_EMERG "Restarting system.\n");
3268     else
3269     diff --git a/kernel/workqueue.c b/kernel/workqueue.c
3270     index 3c5a79e..872bd6d 100644
3271     --- a/kernel/workqueue.c
3272     +++ b/kernel/workqueue.c
3273     @@ -1927,10 +1927,9 @@ static void move_linked_works(struct work_struct *work, struct list_head *head,
3274     *nextp = n;
3275     }
3276    
3277     -static void cwq_activate_first_delayed(struct cpu_workqueue_struct *cwq)
3278     +static void cwq_activate_delayed_work(struct work_struct *work)
3279     {
3280     - struct work_struct *work = list_first_entry(&cwq->delayed_works,
3281     - struct work_struct, entry);
3282     + struct cpu_workqueue_struct *cwq = get_work_cwq(work);
3283    
3284     trace_workqueue_activate_work(work);
3285     move_linked_works(work, &cwq->pool->worklist, NULL);
3286     @@ -1938,6 +1937,14 @@ static void cwq_activate_first_delayed(struct cpu_workqueue_struct *cwq)
3287     cwq->nr_active++;
3288     }
3289    
3290     +static void cwq_activate_first_delayed(struct cpu_workqueue_struct *cwq)
3291     +{
3292     + struct work_struct *work = list_first_entry(&cwq->delayed_works,
3293     + struct work_struct, entry);
3294     +
3295     + cwq_activate_delayed_work(work);
3296     +}
3297     +
3298     /**
3299     * cwq_dec_nr_in_flight - decrement cwq's nr_in_flight
3300     * @cwq: cwq of interest
3301     @@ -2073,7 +2080,9 @@ __acquires(&gcwq->lock)
3302    
3303     spin_unlock_irq(&gcwq->lock);
3304    
3305     + smp_wmb(); /* paired with test_and_set_bit(PENDING) */
3306     work_clear_pending(work);
3307     +
3308     lock_map_acquire_read(&cwq->wq->lockdep_map);
3309     lock_map_acquire(&lockdep_map);
3310     trace_workqueue_execute_start(work);
3311     @@ -2844,6 +2853,18 @@ static int try_to_grab_pending(struct work_struct *work)
3312     smp_rmb();
3313     if (gcwq == get_work_gcwq(work)) {
3314     debug_work_deactivate(work);
3315     +
3316     + /*
3317     + * A delayed work item cannot be grabbed directly
3318     + * because it might have linked NO_COLOR work items
3319     + * which, if left on the delayed_list, will confuse
3320     + * cwq->nr_active management later on and cause
3321     + * stall. Make sure the work item is activated
3322     + * before grabbing.
3323     + */
3324     + if (*work_data_bits(work) & WORK_STRUCT_DELAYED)
3325     + cwq_activate_delayed_work(work);
3326     +
3327     list_del_init(&work->entry);
3328     cwq_dec_nr_in_flight(get_work_cwq(work),
3329     get_work_color(work),
3330     diff --git a/lib/gcd.c b/lib/gcd.c
3331     index cce4f3c..3657f12 100644
3332     --- a/lib/gcd.c
3333     +++ b/lib/gcd.c
3334     @@ -9,6 +9,9 @@ unsigned long gcd(unsigned long a, unsigned long b)
3335    
3336     if (a < b)
3337     swap(a, b);
3338     +
3339     + if (!b)
3340     + return a;
3341     while ((r = a % b) != 0) {
3342     a = b;
3343     b = r;
3344     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3345     index bc72712..3adceaf 100644
3346     --- a/mm/hugetlb.c
3347     +++ b/mm/hugetlb.c
3348     @@ -2481,7 +2481,8 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
3349     * from page cache lookup which is in HPAGE_SIZE units.
3350     */
3351     address = address & huge_page_mask(h);
3352     - pgoff = vma_hugecache_offset(h, vma, address);
3353     + pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) +
3354     + vma->vm_pgoff;
3355     mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
3356    
3357     /*
3358     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
3359     index 4ada3be..3d64b36 100644
3360     --- a/mm/mempolicy.c
3361     +++ b/mm/mempolicy.c
3362     @@ -607,6 +607,42 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
3363     return first;
3364     }
3365    
3366     +/*
3367     + * Apply policy to a single VMA
3368     + * This must be called with the mmap_sem held for writing.
3369     + */
3370     +static int vma_replace_policy(struct vm_area_struct *vma,
3371     + struct mempolicy *pol)
3372     +{
3373     + int err;
3374     + struct mempolicy *old;
3375     + struct mempolicy *new;
3376     +
3377     + pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
3378     + vma->vm_start, vma->vm_end, vma->vm_pgoff,
3379     + vma->vm_ops, vma->vm_file,
3380     + vma->vm_ops ? vma->vm_ops->set_policy : NULL);
3381     +
3382     + new = mpol_dup(pol);
3383     + if (IS_ERR(new))
3384     + return PTR_ERR(new);
3385     +
3386     + if (vma->vm_ops && vma->vm_ops->set_policy) {
3387     + err = vma->vm_ops->set_policy(vma, new);
3388     + if (err)
3389     + goto err_out;
3390     + }
3391     +
3392     + old = vma->vm_policy;
3393     + vma->vm_policy = new; /* protected by mmap_sem */
3394     + mpol_put(old);
3395     +
3396     + return 0;
3397     + err_out:
3398     + mpol_put(new);
3399     + return err;
3400     +}
3401     +
3402     /* Step 2: apply policy to a range and do splits. */
3403     static int mbind_range(struct mm_struct *mm, unsigned long start,
3404     unsigned long end, struct mempolicy *new_pol)
3405     @@ -655,23 +691,9 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
3406     if (err)
3407     goto out;
3408     }
3409     -
3410     - /*
3411     - * Apply policy to a single VMA. The reference counting of
3412     - * policy for vma_policy linkages has already been handled by
3413     - * vma_merge and split_vma as necessary. If this is a shared
3414     - * policy then ->set_policy will increment the reference count
3415     - * for an sp node.
3416     - */
3417     - pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
3418     - vma->vm_start, vma->vm_end, vma->vm_pgoff,
3419     - vma->vm_ops, vma->vm_file,
3420     - vma->vm_ops ? vma->vm_ops->set_policy : NULL);
3421     - if (vma->vm_ops && vma->vm_ops->set_policy) {
3422     - err = vma->vm_ops->set_policy(vma, new_pol);
3423     - if (err)
3424     - goto out;
3425     - }
3426     + err = vma_replace_policy(vma, new_pol);
3427     + if (err)
3428     + goto out;
3429     }
3430    
3431     out:
3432     @@ -1530,8 +1552,18 @@ struct mempolicy *get_vma_policy(struct task_struct *task,
3433     addr);
3434     if (vpol)
3435     pol = vpol;
3436     - } else if (vma->vm_policy)
3437     + } else if (vma->vm_policy) {
3438     pol = vma->vm_policy;
3439     +
3440     + /*
3441     + * shmem_alloc_page() passes MPOL_F_SHARED policy with
3442     + * a pseudo vma whose vma->vm_ops=NULL. Take a reference
3443     + * count on these policies which will be dropped by
3444     + * mpol_cond_put() later
3445     + */
3446     + if (mpol_needs_cond_ref(pol))
3447     + mpol_get(pol);
3448     + }
3449     }
3450     if (!pol)
3451     pol = &default_policy;
3452     @@ -2061,7 +2093,7 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b)
3453     */
3454    
3455     /* lookup first element intersecting start-end */
3456     -/* Caller holds sp->lock */
3457     +/* Caller holds sp->mutex */
3458     static struct sp_node *
3459     sp_lookup(struct shared_policy *sp, unsigned long start, unsigned long end)
3460     {
3461     @@ -2125,36 +2157,50 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
3462    
3463     if (!sp->root.rb_node)
3464     return NULL;
3465     - spin_lock(&sp->lock);
3466     + mutex_lock(&sp->mutex);
3467     sn = sp_lookup(sp, idx, idx+1);
3468     if (sn) {
3469     mpol_get(sn->policy);
3470     pol = sn->policy;
3471     }
3472     - spin_unlock(&sp->lock);
3473     + mutex_unlock(&sp->mutex);
3474     return pol;
3475     }
3476    
3477     +static void sp_free(struct sp_node *n)
3478     +{
3479     + mpol_put(n->policy);
3480     + kmem_cache_free(sn_cache, n);
3481     +}
3482     +
3483     static void sp_delete(struct shared_policy *sp, struct sp_node *n)
3484     {
3485     pr_debug("deleting %lx-l%lx\n", n->start, n->end);
3486     rb_erase(&n->nd, &sp->root);
3487     - mpol_put(n->policy);
3488     - kmem_cache_free(sn_cache, n);
3489     + sp_free(n);
3490     }
3491    
3492     static struct sp_node *sp_alloc(unsigned long start, unsigned long end,
3493     struct mempolicy *pol)
3494     {
3495     - struct sp_node *n = kmem_cache_alloc(sn_cache, GFP_KERNEL);
3496     + struct sp_node *n;
3497     + struct mempolicy *newpol;
3498    
3499     + n = kmem_cache_alloc(sn_cache, GFP_KERNEL);
3500     if (!n)
3501     return NULL;
3502     +
3503     + newpol = mpol_dup(pol);
3504     + if (IS_ERR(newpol)) {
3505     + kmem_cache_free(sn_cache, n);
3506     + return NULL;
3507     + }
3508     + newpol->flags |= MPOL_F_SHARED;
3509     +
3510     n->start = start;
3511     n->end = end;
3512     - mpol_get(pol);
3513     - pol->flags |= MPOL_F_SHARED; /* for unref */
3514     - n->policy = pol;
3515     + n->policy = newpol;
3516     +
3517     return n;
3518     }
3519    
3520     @@ -2162,10 +2208,10 @@ static struct sp_node *sp_alloc(unsigned long start, unsigned long end,
3521     static int shared_policy_replace(struct shared_policy *sp, unsigned long start,
3522     unsigned long end, struct sp_node *new)
3523     {
3524     - struct sp_node *n, *new2 = NULL;
3525     + struct sp_node *n;
3526     + int ret = 0;
3527    
3528     -restart:
3529     - spin_lock(&sp->lock);
3530     + mutex_lock(&sp->mutex);
3531     n = sp_lookup(sp, start, end);
3532     /* Take care of old policies in the same range. */
3533     while (n && n->start < end) {
3534     @@ -2178,16 +2224,14 @@ restart:
3535     } else {
3536     /* Old policy spanning whole new range. */
3537     if (n->end > end) {
3538     + struct sp_node *new2;
3539     + new2 = sp_alloc(end, n->end, n->policy);
3540     if (!new2) {
3541     - spin_unlock(&sp->lock);
3542     - new2 = sp_alloc(end, n->end, n->policy);
3543     - if (!new2)
3544     - return -ENOMEM;
3545     - goto restart;
3546     + ret = -ENOMEM;
3547     + goto out;
3548     }
3549     n->end = start;
3550     sp_insert(sp, new2);
3551     - new2 = NULL;
3552     break;
3553     } else
3554     n->end = start;
3555     @@ -2198,12 +2242,9 @@ restart:
3556     }
3557     if (new)
3558     sp_insert(sp, new);
3559     - spin_unlock(&sp->lock);
3560     - if (new2) {
3561     - mpol_put(new2->policy);
3562     - kmem_cache_free(sn_cache, new2);
3563     - }
3564     - return 0;
3565     +out:
3566     + mutex_unlock(&sp->mutex);
3567     + return ret;
3568     }
3569    
3570     /**
3571     @@ -2221,7 +2262,7 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
3572     int ret;
3573    
3574     sp->root = RB_ROOT; /* empty tree == default mempolicy */
3575     - spin_lock_init(&sp->lock);
3576     + mutex_init(&sp->mutex);
3577    
3578     if (mpol) {
3579     struct vm_area_struct pvma;
3580     @@ -2275,7 +2316,7 @@ int mpol_set_shared_policy(struct shared_policy *info,
3581     }
3582     err = shared_policy_replace(info, vma->vm_pgoff, vma->vm_pgoff+sz, new);
3583     if (err && new)
3584     - kmem_cache_free(sn_cache, new);
3585     + sp_free(new);
3586     return err;
3587     }
3588    
3589     @@ -2287,16 +2328,14 @@ void mpol_free_shared_policy(struct shared_policy *p)
3590    
3591     if (!p->root.rb_node)
3592     return;
3593     - spin_lock(&p->lock);
3594     + mutex_lock(&p->mutex);
3595     next = rb_first(&p->root);
3596     while (next) {
3597     n = rb_entry(next, struct sp_node, nd);
3598     next = rb_next(&n->nd);
3599     - rb_erase(&n->nd, &p->root);
3600     - mpol_put(n->policy);
3601     - kmem_cache_free(sn_cache, n);
3602     + sp_delete(p, n);
3603     }
3604     - spin_unlock(&p->lock);
3605     + mutex_unlock(&p->mutex);
3606     }
3607    
3608     /* assumes fs == KERNEL_DS */
3609     diff --git a/mm/slab.c b/mm/slab.c
3610     index c685475..d066037 100644
3611     --- a/mm/slab.c
3612     +++ b/mm/slab.c
3613     @@ -1781,9 +1781,6 @@ void __init kmem_cache_init_late(void)
3614    
3615     slab_state = UP;
3616    
3617     - /* Annotate slab for lockdep -- annotate the malloc caches */
3618     - init_lock_keys();
3619     -
3620     /* 6) resize the head arrays to their final sizes */
3621     mutex_lock(&slab_mutex);
3622     list_for_each_entry(cachep, &slab_caches, list)
3623     @@ -1791,6 +1788,9 @@ void __init kmem_cache_init_late(void)
3624     BUG();
3625     mutex_unlock(&slab_mutex);
3626    
3627     + /* Annotate slab for lockdep -- annotate the malloc caches */
3628     + init_lock_keys();
3629     +
3630     /* Done! */
3631     slab_state = FULL;
3632    
3633     diff --git a/mm/truncate.c b/mm/truncate.c
3634     index 75801ac..f38055c 100644
3635     --- a/mm/truncate.c
3636     +++ b/mm/truncate.c
3637     @@ -394,11 +394,12 @@ invalidate_complete_page2(struct address_space *mapping, struct page *page)
3638     if (page_has_private(page) && !try_to_release_page(page, GFP_KERNEL))
3639     return 0;
3640    
3641     + clear_page_mlock(page);
3642     +
3643     spin_lock_irq(&mapping->tree_lock);
3644     if (PageDirty(page))
3645     goto failed;
3646    
3647     - clear_page_mlock(page);
3648     BUG_ON(page_has_private(page));
3649     __delete_from_page_cache(page);
3650     spin_unlock_irq(&mapping->tree_lock);
3651     diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
3652     index 8ca533c..830059d 100644
3653     --- a/net/8021q/vlan_core.c
3654     +++ b/net/8021q/vlan_core.c
3655     @@ -105,7 +105,6 @@ static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
3656     return NULL;
3657     memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
3658     skb->mac_header += VLAN_HLEN;
3659     - skb_reset_mac_len(skb);
3660     return skb;
3661     }
3662    
3663     @@ -139,6 +138,8 @@ struct sk_buff *vlan_untag(struct sk_buff *skb)
3664    
3665     skb_reset_network_header(skb);
3666     skb_reset_transport_header(skb);
3667     + skb_reset_mac_len(skb);
3668     +
3669     return skb;
3670    
3671     err_free:
3672     diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
3673     index da80dc1..a747100 100644
3674     --- a/net/ipv4/fib_semantics.c
3675     +++ b/net/ipv4/fib_semantics.c
3676     @@ -314,6 +314,7 @@ static struct fib_info *fib_find_info(const struct fib_info *nfi)
3677     nfi->fib_scope == fi->fib_scope &&
3678     nfi->fib_prefsrc == fi->fib_prefsrc &&
3679     nfi->fib_priority == fi->fib_priority &&
3680     + nfi->fib_type == fi->fib_type &&
3681     memcmp(nfi->fib_metrics, fi->fib_metrics,
3682     sizeof(u32) * RTAX_MAX) == 0 &&
3683     ((nfi->fib_flags ^ fi->fib_flags) & ~RTNH_F_DEAD) == 0 &&
3684     @@ -833,6 +834,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
3685     fi->fib_flags = cfg->fc_flags;
3686     fi->fib_priority = cfg->fc_priority;
3687     fi->fib_prefsrc = cfg->fc_prefsrc;
3688     + fi->fib_type = cfg->fc_type;
3689    
3690     fi->fib_nhs = nhs;
3691     change_nexthops(fi) {
3692     diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
3693     index 6bc85f7..ea3e9af 100644
3694     --- a/net/ipv6/addrconf.c
3695     +++ b/net/ipv6/addrconf.c
3696     @@ -788,10 +788,16 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
3697     struct in6_addr prefix;
3698     struct rt6_info *rt;
3699     struct net *net = dev_net(ifp->idev->dev);
3700     + struct flowi6 fl6 = {};
3701     +
3702     ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
3703     - rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
3704     + fl6.flowi6_oif = ifp->idev->dev->ifindex;
3705     + fl6.daddr = prefix;
3706     + rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
3707     + RT6_LOOKUP_F_IFACE);
3708    
3709     - if (rt && addrconf_is_prefix_route(rt)) {
3710     + if (rt != net->ipv6.ip6_null_entry &&
3711     + addrconf_is_prefix_route(rt)) {
3712     if (onlink == 0) {
3713     ip6_del_rt(rt);
3714     rt = NULL;
3715     diff --git a/net/ipv6/route.c b/net/ipv6/route.c
3716     index 854e401..46eff42 100644
3717     --- a/net/ipv6/route.c
3718     +++ b/net/ipv6/route.c
3719     @@ -1589,17 +1589,18 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info)
3720     struct fib6_table *table;
3721     struct net *net = dev_net(rt->dst.dev);
3722    
3723     - if (rt == net->ipv6.ip6_null_entry)
3724     - return -ENOENT;
3725     + if (rt == net->ipv6.ip6_null_entry) {
3726     + err = -ENOENT;
3727     + goto out;
3728     + }
3729    
3730     table = rt->rt6i_table;
3731     write_lock_bh(&table->tb6_lock);
3732     -
3733     err = fib6_del(rt, info);
3734     - dst_release(&rt->dst);
3735     -
3736     write_unlock_bh(&table->tb6_lock);
3737    
3738     +out:
3739     + dst_release(&rt->dst);
3740     return err;
3741     }
3742    
3743     diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
3744     index 6a3ee98..978416d 100644
3745     --- a/scripts/Kbuild.include
3746     +++ b/scripts/Kbuild.include
3747     @@ -98,24 +98,24 @@ try-run = $(shell set -e; \
3748     # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
3749    
3750     as-option = $(call try-run,\
3751     - $(CC) $(KBUILD_CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2))
3752     + $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
3753    
3754     # as-instr
3755     # Usage: cflags-y += $(call as-instr,instr,option1,option2)
3756    
3757     as-instr = $(call try-run,\
3758     - printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
3759     + printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
3760    
3761     # cc-option
3762     # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
3763    
3764     cc-option = $(call try-run,\
3765     - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
3766     + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
3767    
3768     # cc-option-yn
3769     # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
3770     cc-option-yn = $(call try-run,\
3771     - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
3772     + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
3773    
3774     # cc-option-align
3775     # Prefix align with either -falign or -malign
3776     @@ -125,7 +125,7 @@ cc-option-align = $(subst -functions=0,,\
3777     # cc-disable-warning
3778     # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
3779     cc-disable-warning = $(call try-run,\
3780     - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
3781     + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
3782    
3783     # cc-version
3784     # Usage gcc-ver := $(call cc-version)
3785     @@ -143,7 +143,7 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
3786     # cc-ldoption
3787     # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
3788     cc-ldoption = $(call try-run,\
3789     - $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2))
3790     + $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
3791    
3792     # ld-option
3793     # Usage: LDFLAGS += $(call ld-option, -X)
3794     @@ -209,7 +209,7 @@ endif
3795     # >$< substitution to preserve $ when reloading .cmd file
3796     # note: when using inline perl scripts [perl -e '...$$t=1;...']
3797     # in $(cmd_xxx) double $$ your perl vars
3798     -make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
3799     +make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))))
3800    
3801     # Find any prerequisites that is newer than target or that does not exist.
3802     # PHONY targets skipped in both cases.
3803     diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst
3804     index 4d908d1..c3f69ae 100644
3805     --- a/scripts/Makefile.fwinst
3806     +++ b/scripts/Makefile.fwinst
3807     @@ -27,7 +27,7 @@ endif
3808     installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
3809    
3810     installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
3811     -installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./
3812     +installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/.
3813    
3814     # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
3815     PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
3816     @@ -42,7 +42,7 @@ quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
3817     $(installed-fw-dirs):
3818     $(call cmd,mkdir)
3819    
3820     -$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %)
3821     +$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $$(dir $(INSTALL_FW_PATH)/%)
3822     $(call cmd,install)
3823    
3824     PHONY += __fw_install __fw_modinst FORCE
3825     diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
3826     index debecb5..7f2126d 100644
3827     --- a/scripts/gcc-version.sh
3828     +++ b/scripts/gcc-version.sh
3829     @@ -22,10 +22,10 @@ if [ ${#compiler} -eq 0 ]; then
3830     exit 1
3831     fi
3832    
3833     -MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
3834     -MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
3835     +MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
3836     +MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
3837     if [ "x$with_patchlevel" != "x" ] ; then
3838     - PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
3839     + PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
3840     printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
3841     else
3842     printf "%02d%02d\\n" $MAJOR $MINOR
3843     diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh
3844     index 29493dc..12dbd0b 100644
3845     --- a/scripts/gcc-x86_32-has-stack-protector.sh
3846     +++ b/scripts/gcc-x86_32-has-stack-protector.sh
3847     @@ -1,6 +1,6 @@
3848     #!/bin/sh
3849    
3850     -echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
3851     +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
3852     if [ "$?" -eq "0" ] ; then
3853     echo y
3854     else
3855     diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
3856     index afaec61..973e8c1 100644
3857     --- a/scripts/gcc-x86_64-has-stack-protector.sh
3858     +++ b/scripts/gcc-x86_64-has-stack-protector.sh
3859     @@ -1,6 +1,6 @@
3860     #!/bin/sh
3861    
3862     -echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
3863     +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
3864     if [ "$?" -eq "0" ] ; then
3865     echo y
3866     else
3867     diff --git a/scripts/kconfig/check.sh b/scripts/kconfig/check.sh
3868     index fa59cbf..854d9c7 100755
3869     --- a/scripts/kconfig/check.sh
3870     +++ b/scripts/kconfig/check.sh
3871     @@ -1,6 +1,6 @@
3872     #!/bin/sh
3873     # Needed for systems without gettext
3874     -$* -xc -o /dev/null - > /dev/null 2>&1 << EOF
3875     +$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
3876     #include <libintl.h>
3877     int main()
3878     {
3879     diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
3880     index e3b12c0..c8e8a71 100644
3881     --- a/scripts/kconfig/lxdialog/check-lxdialog.sh
3882     +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
3883     @@ -38,7 +38,7 @@ trap "rm -f $tmp" 0 1 2 3 15
3884    
3885     # Check if we can link to ncurses
3886     check() {
3887     - $cc -xc - -o $tmp 2>/dev/null <<'EOF'
3888     + $cc -x c - -o $tmp 2>/dev/null <<'EOF'
3889     #include CURSES_LOC
3890     main() {}
3891     EOF
3892     diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
3893     index 2fbbbc1..5eb3777 100644
3894     --- a/scripts/kconfig/streamline_config.pl
3895     +++ b/scripts/kconfig/streamline_config.pl
3896     @@ -605,6 +605,8 @@ foreach my $line (@config_file) {
3897     if (defined($configs{$1})) {
3898     if ($localyesconfig) {
3899     $setconfigs{$1} = 'y';
3900     + print "$1=y\n";
3901     + next;
3902     } else {
3903     $setconfigs{$1} = $2;
3904     }
3905     diff --git a/scripts/package/buildtar b/scripts/package/buildtar
3906     index 8a7b155..d0d748e 100644
3907     --- a/scripts/package/buildtar
3908     +++ b/scripts/package/buildtar
3909     @@ -109,7 +109,7 @@ esac
3910     if tar --owner=root --group=root --help >/dev/null 2>&1; then
3911     opts="--owner=root --group=root"
3912     fi
3913     - tar cf - . $opts | ${compress} > "${tarball}${file_ext}"
3914     + tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}"
3915     )
3916    
3917     echo "Tarball successfully created in ${tarball}${file_ext}"
3918     diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
3919     index 5a34355..0fe6d64 100644
3920     --- a/sound/drivers/aloop.c
3921     +++ b/sound/drivers/aloop.c
3922     @@ -120,6 +120,7 @@ struct loopback_pcm {
3923     unsigned int last_drift;
3924     unsigned long last_jiffies;
3925     struct timer_list timer;
3926     + spinlock_t timer_lock;
3927     };
3928    
3929     static struct platform_device *devices[SNDRV_CARDS];
3930     @@ -170,6 +171,7 @@ static void loopback_timer_start(struct loopback_pcm *dpcm)
3931     unsigned long tick;
3932     unsigned int rate_shift = get_rate_shift(dpcm);
3933    
3934     + spin_lock(&dpcm->timer_lock);
3935     if (rate_shift != dpcm->pcm_rate_shift) {
3936     dpcm->pcm_rate_shift = rate_shift;
3937     dpcm->period_size_frac = frac_pos(dpcm, dpcm->pcm_period_size);
3938     @@ -182,12 +184,15 @@ static void loopback_timer_start(struct loopback_pcm *dpcm)
3939     tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps;
3940     dpcm->timer.expires = jiffies + tick;
3941     add_timer(&dpcm->timer);
3942     + spin_unlock(&dpcm->timer_lock);
3943     }
3944    
3945     static inline void loopback_timer_stop(struct loopback_pcm *dpcm)
3946     {
3947     + spin_lock(&dpcm->timer_lock);
3948     del_timer(&dpcm->timer);
3949     dpcm->timer.expires = 0;
3950     + spin_unlock(&dpcm->timer_lock);
3951     }
3952    
3953     #define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK)
3954     @@ -667,6 +672,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
3955     dpcm->substream = substream;
3956     setup_timer(&dpcm->timer, loopback_timer_function,
3957     (unsigned long)dpcm);
3958     + spin_lock_init(&dpcm->timer_lock);
3959    
3960     cable = loopback->cables[substream->number][dev];
3961     if (!cable) {
3962     diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
3963     index 1c65cc5..38fdefc 100644
3964     --- a/sound/pci/hda/hda_codec.c
3965     +++ b/sound/pci/hda/hda_codec.c
3966     @@ -3580,7 +3580,7 @@ static inline void hda_exec_init_verbs(struct hda_codec *codec) {}
3967     /*
3968     * call suspend and power-down; used both from PM and power-save
3969     */
3970     -static void hda_call_codec_suspend(struct hda_codec *codec)
3971     +static void hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3972     {
3973     if (codec->patch_ops.suspend)
3974     codec->patch_ops.suspend(codec);
3975     @@ -3589,7 +3589,9 @@ static void hda_call_codec_suspend(struct hda_codec *codec)
3976     codec->afg ? codec->afg : codec->mfg,
3977     AC_PWRST_D3);
3978     #ifdef CONFIG_SND_HDA_POWER_SAVE
3979     - cancel_delayed_work(&codec->power_work);
3980     + /* Cancel delayed work if we aren't currently running from it. */
3981     + if (!in_wq)
3982     + cancel_delayed_work_sync(&codec->power_work);
3983     spin_lock(&codec->power_lock);
3984     snd_hda_update_power_acct(codec);
3985     trace_hda_power_down(codec);
3986     @@ -4410,7 +4412,7 @@ static void hda_power_work(struct work_struct *work)
3987     }
3988     spin_unlock(&codec->power_lock);
3989    
3990     - hda_call_codec_suspend(codec);
3991     + hda_call_codec_suspend(codec, true);
3992     if (bus->ops.pm_notify)
3993     bus->ops.pm_notify(bus);
3994     }
3995     @@ -5076,7 +5078,7 @@ int snd_hda_suspend(struct hda_bus *bus)
3996    
3997     list_for_each_entry(codec, &bus->codec_list, list) {
3998     if (hda_codec_is_power_on(codec))
3999     - hda_call_codec_suspend(codec);
4000     + hda_call_codec_suspend(codec, false);
4001     }
4002     return 0;
4003     }
4004     diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
4005     index c4763c5..12a9432 100644
4006     --- a/sound/pci/hda/hda_intel.c
4007     +++ b/sound/pci/hda/hda_intel.c
4008     @@ -538,6 +538,7 @@ enum {
4009     #define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */
4010     #define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */
4011     #define AZX_DCAPS_POSFIX_COMBO (1 << 24) /* Use COMBO as default */
4012     +#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
4013    
4014     /* quirks for ATI SB / AMD Hudson */
4015     #define AZX_DCAPS_PRESET_ATI_SB \
4016     @@ -2120,6 +2121,27 @@ static unsigned int azx_get_position(struct azx *chip,
4017    
4018     if (pos >= azx_dev->bufsize)
4019     pos = 0;
4020     +
4021     + /* calculate runtime delay from LPIB */
4022     + if (azx_dev->substream->runtime &&
4023     + chip->position_fix[stream] == POS_FIX_POSBUF &&
4024     + (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
4025     + unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB);
4026     + int delay;
4027     + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
4028     + delay = pos - lpib_pos;
4029     + else
4030     + delay = lpib_pos - pos;
4031     + if (delay < 0)
4032     + delay += azx_dev->bufsize;
4033     + if (delay >= azx_dev->period_bytes) {
4034     + snd_printdd("delay %d > period_bytes %d\n",
4035     + delay, azx_dev->period_bytes);
4036     + delay = 0; /* something is wrong */
4037     + }
4038     + azx_dev->substream->runtime->delay =
4039     + bytes_to_frames(azx_dev->substream->runtime, delay);
4040     + }
4041     return pos;
4042     }
4043    
4044     @@ -3260,7 +3282,7 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
4045     /* CPT */
4046     { PCI_DEVICE(0x8086, 0x1c20),
4047     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4048     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4049     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4050     /* PBG */
4051     { PCI_DEVICE(0x8086, 0x1d20),
4052     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4053     @@ -3268,23 +3290,26 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
4054     /* Panther Point */
4055     { PCI_DEVICE(0x8086, 0x1e20),
4056     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4057     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4058     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4059     /* Lynx Point */
4060     { PCI_DEVICE(0x8086, 0x8c20),
4061     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4062     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4063     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4064     /* Lynx Point-LP */
4065     { PCI_DEVICE(0x8086, 0x9c20),
4066     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4067     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4068     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4069     /* Lynx Point-LP */
4070     { PCI_DEVICE(0x8086, 0x9c21),
4071     .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
4072     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4073     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4074     /* Haswell */
4075     { PCI_DEVICE(0x8086, 0x0c0c),
4076     .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
4077     - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO },
4078     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4079     + { PCI_DEVICE(0x8086, 0x0d0c),
4080     + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
4081     + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
4082     /* SCH */
4083     { PCI_DEVICE(0x8086, 0x811b),
4084     .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
4085     diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
4086     index 5e22a8f..784017e 100644
4087     --- a/sound/pci/hda/patch_conexant.c
4088     +++ b/sound/pci/hda/patch_conexant.c
4089     @@ -4462,6 +4462,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
4090     SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
4091     SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
4092     SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
4093     + SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
4094     SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
4095     {}
4096     };
4097     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4098     index 4f81dd4..56a3eef 100644
4099     --- a/sound/pci/hda/patch_realtek.c
4100     +++ b/sound/pci/hda/patch_realtek.c
4101     @@ -6334,6 +6334,12 @@ static int patch_alc269(struct hda_codec *codec)
4102    
4103     spec = codec->spec;
4104    
4105     + alc_pick_fixup(codec, alc269_fixup_models,
4106     + alc269_fixup_tbl, alc269_fixups);
4107     + alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4108     +
4109     + alc_auto_parse_customize_define(codec);
4110     +
4111     if (codec->vendor_id == 0x10ec0269) {
4112     spec->codec_variant = ALC269_TYPE_ALC269VA;
4113     switch (alc_get_coef0(codec) & 0x00f0) {
4114     @@ -6361,12 +6367,6 @@ static int patch_alc269(struct hda_codec *codec)
4115     alc269_fill_coef(codec);
4116     }
4117    
4118     - alc_pick_fixup(codec, alc269_fixup_models,
4119     - alc269_fixup_tbl, alc269_fixups);
4120     - alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4121     -
4122     - alc_auto_parse_customize_define(codec);
4123     -
4124     /* automatic parse from the BIOS config */
4125     err = alc269_parse_auto_config(codec);
4126     if (err < 0)
4127     diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
4128     index 4307717..4b4072f 100644
4129     --- a/sound/pci/hda/patch_via.c
4130     +++ b/sound/pci/hda/patch_via.c
4131     @@ -1672,7 +1672,8 @@ static void via_hp_automute(struct hda_codec *codec)
4132     struct via_spec *spec = codec->spec;
4133    
4134     if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0] &&
4135     - (spec->codec_type != VT1708 || spec->vt1708_jack_detect))
4136     + (spec->codec_type != VT1708 || spec->vt1708_jack_detect) &&
4137     + is_jack_detectable(codec, spec->autocfg.hp_pins[0]))
4138     present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
4139    
4140     if (spec->smart51_enabled)
4141     @@ -3669,6 +3670,32 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec)
4142     update_power_state(codec, 0x21, AC_PWRST_D3);
4143     }
4144    
4145     +/*
4146     + * pin fix-up
4147     + */
4148     +enum {
4149     + VIA_FIXUP_INTMIC_BOOST,
4150     +};
4151     +
4152     +static void via_fixup_intmic_boost(struct hda_codec *codec,
4153     + const struct hda_fixup *fix, int action)
4154     +{
4155     + if (action == HDA_FIXUP_ACT_PRE_PROBE)
4156     + override_mic_boost(codec, 0x30, 0, 2, 40);
4157     +}
4158     +
4159     +static const struct hda_fixup via_fixups[] = {
4160     + [VIA_FIXUP_INTMIC_BOOST] = {
4161     + .type = HDA_FIXUP_FUNC,
4162     + .v.func = via_fixup_intmic_boost,
4163     + },
4164     +};
4165     +
4166     +static const struct snd_pci_quirk vt2002p_fixups[] = {
4167     + SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST),
4168     + {}
4169     +};
4170     +
4171     /* patch for vt2002P */
4172     static int patch_vt2002P(struct hda_codec *codec)
4173     {
4174     @@ -3685,6 +3712,9 @@ static int patch_vt2002P(struct hda_codec *codec)
4175     override_mic_boost(codec, 0x29, 0, 3, 40);
4176     add_secret_dac_path(codec);
4177    
4178     + snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
4179     + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4180     +
4181     /* automatic parse from the BIOS config */
4182     err = via_parse_auto_config(codec);
4183     if (err < 0) {
4184     diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
4185     index 01ebbcc..11dfc33 100644
4186     --- a/sound/soc/codecs/wm5110.c
4187     +++ b/sound/soc/codecs/wm5110.c
4188     @@ -869,6 +869,8 @@ static unsigned int wm5110_digital_vu[] = {
4189     ARIZONA_ADC_DIGITAL_VOLUME_2R,
4190     ARIZONA_ADC_DIGITAL_VOLUME_3L,
4191     ARIZONA_ADC_DIGITAL_VOLUME_3R,
4192     + ARIZONA_ADC_DIGITAL_VOLUME_4L,
4193     + ARIZONA_ADC_DIGITAL_VOLUME_4R,
4194    
4195     ARIZONA_DAC_DIGITAL_VOLUME_1L,
4196     ARIZONA_DAC_DIGITAL_VOLUME_1R,
4197     @@ -880,6 +882,8 @@ static unsigned int wm5110_digital_vu[] = {
4198     ARIZONA_DAC_DIGITAL_VOLUME_4R,
4199     ARIZONA_DAC_DIGITAL_VOLUME_5L,
4200     ARIZONA_DAC_DIGITAL_VOLUME_5R,
4201     + ARIZONA_DAC_DIGITAL_VOLUME_6L,
4202     + ARIZONA_DAC_DIGITAL_VOLUME_6R,
4203     };
4204    
4205     static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
4206     diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
4207     index c6d2076..c9516f0 100644
4208     --- a/sound/soc/codecs/wm9712.c
4209     +++ b/sound/soc/codecs/wm9712.c
4210     @@ -146,7 +146,7 @@ SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_MASTER_TONE, 6, 1, 0),
4211     SOC_SINGLE("Bass Volume", AC97_MASTER_TONE, 8, 15, 1),
4212     SOC_SINGLE("Treble Volume", AC97_MASTER_TONE, 0, 15, 1),
4213    
4214     -SOC_SINGLE("Capture ADC Switch", AC97_REC_GAIN, 15, 1, 1),
4215     +SOC_SINGLE("Capture Switch", AC97_REC_GAIN, 15, 1, 1),
4216     SOC_ENUM("Capture Volume Steps", wm9712_enum[6]),
4217     SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 0),
4218     SOC_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0),
4219     diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
4220     index 61baa48..57b27ef 100644
4221     --- a/sound/soc/codecs/wm_hubs.c
4222     +++ b/sound/soc/codecs/wm_hubs.c
4223     @@ -634,6 +634,11 @@ void wm_hubs_update_class_w(struct snd_soc_codec *codec)
4224    
4225     snd_soc_update_bits(codec, WM8993_CLASS_W_0,
4226     WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ, enable);
4227     +
4228     + snd_soc_write(codec, WM8993_LEFT_OUTPUT_VOLUME,
4229     + snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME));
4230     + snd_soc_write(codec, WM8993_RIGHT_OUTPUT_VOLUME,
4231     + snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME));
4232     }
4233     EXPORT_SYMBOL_GPL(wm_hubs_update_class_w);
4234    
4235     diff --git a/sound/usb/card.h b/sound/usb/card.h
4236     index 2b9ffff..d9d2b5a 100644
4237     --- a/sound/usb/card.h
4238     +++ b/sound/usb/card.h
4239     @@ -92,6 +92,8 @@ struct snd_usb_endpoint {
4240     unsigned char silence_value;
4241     unsigned int stride;
4242     int iface, alt_idx;
4243     + int skip_packets; /* quirks for devices to ignore the first n packets
4244     + in a stream */
4245    
4246     spinlock_t lock;
4247     struct list_head list;
4248     diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
4249     index 060dccb..d9de667 100644
4250     --- a/sound/usb/endpoint.c
4251     +++ b/sound/usb/endpoint.c
4252     @@ -31,6 +31,7 @@
4253     #include "card.h"
4254     #include "endpoint.h"
4255     #include "pcm.h"
4256     +#include "quirks.h"
4257    
4258     #define EP_FLAG_ACTIVATED 0
4259     #define EP_FLAG_RUNNING 1
4260     @@ -170,6 +171,11 @@ static void retire_inbound_urb(struct snd_usb_endpoint *ep,
4261     {
4262     struct urb *urb = urb_ctx->urb;
4263    
4264     + if (unlikely(ep->skip_packets > 0)) {
4265     + ep->skip_packets--;
4266     + return;
4267     + }
4268     +
4269     if (ep->sync_slave)
4270     snd_usb_handle_sync_urb(ep->sync_slave, ep, urb);
4271    
4272     @@ -828,6 +834,8 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep)
4273     ep->unlink_mask = 0;
4274     ep->phase = 0;
4275    
4276     + snd_usb_endpoint_start_quirk(ep);
4277     +
4278     /*
4279     * If this endpoint has a data endpoint as implicit feedback source,
4280     * don't start the urbs here. Instead, mark them all as available,
4281     diff --git a/sound/usb/helper.c b/sound/usb/helper.c
4282     index 9eed8f4..c1db28f 100644
4283     --- a/sound/usb/helper.c
4284     +++ b/sound/usb/helper.c
4285     @@ -21,6 +21,7 @@
4286    
4287     #include "usbaudio.h"
4288     #include "helper.h"
4289     +#include "quirks.h"
4290    
4291     /*
4292     * combine bytes and get an integer value
4293     @@ -97,6 +98,10 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
4294     memcpy(data, buf, size);
4295     kfree(buf);
4296     }
4297     +
4298     + snd_usb_ctl_msg_quirk(dev, pipe, request, requesttype,
4299     + value, index, data, size);
4300     +
4301     return err;
4302     }
4303    
4304     diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
4305     index 4f40ba8..fe56c9d 100644
4306     --- a/sound/usb/mixer.c
4307     +++ b/sound/usb/mixer.c
4308     @@ -1267,6 +1267,13 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
4309     /* disable non-functional volume control */
4310     master_bits &= ~UAC_CONTROL_BIT(UAC_FU_VOLUME);
4311     break;
4312     + case USB_ID(0x1130, 0xf211):
4313     + snd_printk(KERN_INFO
4314     + "usbmixer: volume control quirk for Tenx TP6911 Audio Headset\n");
4315     + /* disable non-functional volume control */
4316     + channels = 0;
4317     + break;
4318     +
4319     }
4320     if (channels > 0)
4321     first_ch_bits = snd_usb_combine_bytes(bmaControls + csize, csize);
4322     diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
4323     index 79780fa..d73ac9b 100644
4324     --- a/sound/usb/quirks-table.h
4325     +++ b/sound/usb/quirks-table.h
4326     @@ -2781,6 +2781,59 @@ YAMAHA_DEVICE(0x7010, "UB99"),
4327     }
4328     },
4329    
4330     +/* Microsoft XboxLive Headset/Xbox Communicator */
4331     +{
4332     + USB_DEVICE(0x045e, 0x0283),
4333     + .bInterfaceClass = USB_CLASS_PER_INTERFACE,
4334     + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
4335     + .vendor_name = "Microsoft",
4336     + .product_name = "XboxLive Headset/Xbox Communicator",
4337     + .ifnum = QUIRK_ANY_INTERFACE,
4338     + .type = QUIRK_COMPOSITE,
4339     + .data = &(const struct snd_usb_audio_quirk[]) {
4340     + {
4341     + /* playback */
4342     + .ifnum = 0,
4343     + .type = QUIRK_AUDIO_FIXED_ENDPOINT,
4344     + .data = &(const struct audioformat) {
4345     + .formats = SNDRV_PCM_FMTBIT_S16_LE,
4346     + .channels = 1,
4347     + .iface = 0,
4348     + .altsetting = 0,
4349     + .altset_idx = 0,
4350     + .attributes = 0,
4351     + .endpoint = 0x04,
4352     + .ep_attr = 0x05,
4353     + .rates = SNDRV_PCM_RATE_CONTINUOUS,
4354     + .rate_min = 22050,
4355     + .rate_max = 22050
4356     + }
4357     + },
4358     + {
4359     + /* capture */
4360     + .ifnum = 1,
4361     + .type = QUIRK_AUDIO_FIXED_ENDPOINT,
4362     + .data = &(const struct audioformat) {
4363     + .formats = SNDRV_PCM_FMTBIT_S16_LE,
4364     + .channels = 1,
4365     + .iface = 1,
4366     + .altsetting = 0,
4367     + .altset_idx = 0,
4368     + .attributes = 0,
4369     + .endpoint = 0x85,
4370     + .ep_attr = 0x05,
4371     + .rates = SNDRV_PCM_RATE_CONTINUOUS,
4372     + .rate_min = 16000,
4373     + .rate_max = 16000
4374     + }
4375     + },
4376     + {
4377     + .ifnum = -1
4378     + }
4379     + }
4380     + }
4381     +},
4382     +
4383     {
4384     /*
4385     * Some USB MIDI devices don't have an audio control interface,
4386     diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
4387     index 2781726..0f58b4b 100644
4388     --- a/sound/usb/quirks.c
4389     +++ b/sound/usb/quirks.c
4390     @@ -761,3 +761,27 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
4391     }
4392     }
4393    
4394     +void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
4395     +{
4396     + /*
4397     + * "Playback Design" products send bogus feedback data at the start
4398     + * of the stream. Ignore them.
4399     + */
4400     + if ((le16_to_cpu(ep->chip->dev->descriptor.idVendor) == 0x23ba) &&
4401     + ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
4402     + ep->skip_packets = 4;
4403     +}
4404     +
4405     +void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
4406     + __u8 request, __u8 requesttype, __u16 value,
4407     + __u16 index, void *data, __u16 size)
4408     +{
4409     + /*
4410     + * "Playback Design" products need a 20ms delay after each
4411     + * class compliant request
4412     + */
4413     + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) &&
4414     + (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
4415     + mdelay(20);
4416     +}
4417     +
4418     diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h
4419     index 03e5e94..0ca9e91 100644
4420     --- a/sound/usb/quirks.h
4421     +++ b/sound/usb/quirks.h
4422     @@ -1,6 +1,10 @@
4423     #ifndef __USBAUDIO_QUIRKS_H
4424     #define __USBAUDIO_QUIRKS_H
4425    
4426     +struct audioformat;
4427     +struct snd_usb_endpoint;
4428     +struct snd_usb_substream;
4429     +
4430     int snd_usb_create_quirk(struct snd_usb_audio *chip,
4431     struct usb_interface *iface,
4432     struct usb_driver *driver,
4433     @@ -20,4 +24,10 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
4434     int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
4435     struct audioformat *fp);
4436    
4437     +void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep);
4438     +
4439     +void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
4440     + __u8 request, __u8 requesttype, __u16 value,
4441     + __u16 index, void *data, __u16 size);
4442     +
4443     #endif /* __USBAUDIO_QUIRKS_H */
4444     diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c
4445     index f759f4f..fd2f922 100644
4446     --- a/tools/lguest/lguest.c
4447     +++ b/tools/lguest/lguest.c
4448     @@ -1299,6 +1299,7 @@ static struct device *new_device(const char *name, u16 type)
4449     dev->feature_len = 0;
4450     dev->num_vq = 0;
4451     dev->running = false;
4452     + dev->next = NULL;
4453    
4454     /*
4455     * Append to device list. Prepending to a single-linked list is
4456     diff --git a/tools/perf/Makefile b/tools/perf/Makefile
4457     index 35655c3..3657ab0 100644
4458     --- a/tools/perf/Makefile
4459     +++ b/tools/perf/Makefile
4460     @@ -62,7 +62,7 @@ ifeq ($(ARCH),x86_64)
4461     ARCH := x86
4462     IS_X86_64 := 0
4463     ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
4464     - IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
4465     + IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
4466     endif
4467     ifeq (${IS_X86_64}, 1)
4468     RAW_ARCH := x86_64
4469     diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
4470     index a93e06c..cf397bd 100644
4471     --- a/tools/power/cpupower/Makefile
4472     +++ b/tools/power/cpupower/Makefile
4473     @@ -111,7 +111,7 @@ GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo $(OUTPUT)po/$$HLANG.gmo;
4474     export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS
4475    
4476     # check if compiler option is supported
4477     -cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;}
4478     +cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -x c /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;}
4479    
4480     # use '-Os' optimization if available, else use -O2
4481     OPTIMIZATION := $(call cc-supports,-Os,-O2)