Magellan Linux

Annotation of /trunk/kernel-magellan/patches-3.9/0100-3.9.1-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2178 - (hide annotations) (download)
Wed May 22 06:42:34 2013 UTC (10 years, 11 months ago) by niro
File size: 114460 byte(s)
-linux-3.9.1-3
1 niro 2178 diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
2     index cb7bcc5..02b70a4 100644
3     --- a/arch/arm/boot/dts/at91sam9260.dtsi
4     +++ b/arch/arm/boot/dts/at91sam9260.dtsi
5     @@ -158,8 +158,8 @@
6     usart1 {
7     pinctrl_usart1: usart1-0 {
8     atmel,pins =
9     - <2 6 0x1 0x1 /* PB6 periph A with pullup */
10     - 2 7 0x1 0x0>; /* PB7 periph A */
11     + <1 6 0x1 0x1 /* PB6 periph A with pullup */
12     + 1 7 0x1 0x0>; /* PB7 periph A */
13     };
14    
15     pinctrl_usart1_rts: usart1_rts-0 {
16     @@ -194,18 +194,18 @@
17     usart3 {
18     pinctrl_usart3: usart3-0 {
19     atmel,pins =
20     - <2 10 0x1 0x1 /* PB10 periph A with pullup */
21     - 2 11 0x1 0x0>; /* PB11 periph A */
22     + <1 10 0x1 0x1 /* PB10 periph A with pullup */
23     + 1 11 0x1 0x0>; /* PB11 periph A */
24     };
25    
26     pinctrl_usart3_rts: usart3_rts-0 {
27     atmel,pins =
28     - <3 8 0x2 0x0>; /* PB8 periph B */
29     + <2 8 0x2 0x0>; /* PC8 periph B */
30     };
31    
32     pinctrl_usart3_cts: usart3_cts-0 {
33     atmel,pins =
34     - <3 10 0x2 0x0>; /* PB10 periph B */
35     + <2 10 0x2 0x0>; /* PC10 periph B */
36     };
37     };
38    
39     @@ -220,8 +220,8 @@
40     uart1 {
41     pinctrl_uart1: uart1-0 {
42     atmel,pins =
43     - <2 12 0x1 0x1 /* PB12 periph A with pullup */
44     - 2 13 0x1 0x0>; /* PB13 periph A */
45     + <1 12 0x1 0x1 /* PB12 periph A with pullup */
46     + 1 13 0x1 0x0>; /* PB13 periph A */
47     };
48     };
49    
50     diff --git a/arch/arm/boot/dts/at91sam9g15.dtsi b/arch/arm/boot/dts/at91sam9g15.dtsi
51     index fbe7a70..28467fd 100644
52     --- a/arch/arm/boot/dts/at91sam9g15.dtsi
53     +++ b/arch/arm/boot/dts/at91sam9g15.dtsi
54     @@ -10,7 +10,7 @@
55    
56     / {
57     model = "Atmel AT91SAM9G15 SoC";
58     - compatible = "atmel, at91sam9g15, atmel,at91sam9x5";
59     + compatible = "atmel,at91sam9g15", "atmel,at91sam9x5";
60    
61     ahb {
62     apb {
63     diff --git a/arch/arm/boot/dts/at91sam9g15ek.dts b/arch/arm/boot/dts/at91sam9g15ek.dts
64     index 86dd3f6..5427b2d 100644
65     --- a/arch/arm/boot/dts/at91sam9g15ek.dts
66     +++ b/arch/arm/boot/dts/at91sam9g15ek.dts
67     @@ -11,6 +11,6 @@
68     /include/ "at91sam9x5ek.dtsi"
69    
70     / {
71     - model = "Atmel AT91SAM9G25-EK";
72     + model = "Atmel AT91SAM9G15-EK";
73     compatible = "atmel,at91sam9g15ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
74     };
75     diff --git a/arch/arm/boot/dts/at91sam9g25.dtsi b/arch/arm/boot/dts/at91sam9g25.dtsi
76     index 05a718f..5fd32df 100644
77     --- a/arch/arm/boot/dts/at91sam9g25.dtsi
78     +++ b/arch/arm/boot/dts/at91sam9g25.dtsi
79     @@ -10,7 +10,7 @@
80    
81     / {
82     model = "Atmel AT91SAM9G25 SoC";
83     - compatible = "atmel, at91sam9g25, atmel,at91sam9x5";
84     + compatible = "atmel,at91sam9g25", "atmel,at91sam9x5";
85    
86     ahb {
87     apb {
88     diff --git a/arch/arm/boot/dts/at91sam9g35.dtsi b/arch/arm/boot/dts/at91sam9g35.dtsi
89     index f9d14a7..d6fa8af 100644
90     --- a/arch/arm/boot/dts/at91sam9g35.dtsi
91     +++ b/arch/arm/boot/dts/at91sam9g35.dtsi
92     @@ -10,7 +10,7 @@
93    
94     / {
95     model = "Atmel AT91SAM9G35 SoC";
96     - compatible = "atmel, at91sam9g35, atmel,at91sam9x5";
97     + compatible = "atmel,at91sam9g35", "atmel,at91sam9x5";
98    
99     ahb {
100     apb {
101     diff --git a/arch/arm/boot/dts/at91sam9x25.dtsi b/arch/arm/boot/dts/at91sam9x25.dtsi
102     index 54eb33b..9ac2bc2 100644
103     --- a/arch/arm/boot/dts/at91sam9x25.dtsi
104     +++ b/arch/arm/boot/dts/at91sam9x25.dtsi
105     @@ -10,7 +10,7 @@
106    
107     / {
108     model = "Atmel AT91SAM9X25 SoC";
109     - compatible = "atmel, at91sam9x25, atmel,at91sam9x5";
110     + compatible = "atmel,at91sam9x25", "atmel,at91sam9x5";
111    
112     ahb {
113     apb {
114     diff --git a/arch/arm/boot/dts/at91sam9x35.dtsi b/arch/arm/boot/dts/at91sam9x35.dtsi
115     index fb102d6..ba67d83 100644
116     --- a/arch/arm/boot/dts/at91sam9x35.dtsi
117     +++ b/arch/arm/boot/dts/at91sam9x35.dtsi
118     @@ -10,7 +10,7 @@
119    
120     / {
121     model = "Atmel AT91SAM9X35 SoC";
122     - compatible = "atmel, at91sam9x35, atmel,at91sam9x5";
123     + compatible = "atmel,at91sam9x35", "atmel,at91sam9x5";
124    
125     ahb {
126     apb {
127     diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi
128     index 8a7cf1d..ccab256 100644
129     --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi
130     +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi
131     @@ -13,7 +13,7 @@
132     compatible = "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
133    
134     chosen {
135     - bootargs = "128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
136     + bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
137     };
138    
139     ahb {
140     diff --git a/arch/arm/configs/at91sam9g45_defconfig b/arch/arm/configs/at91sam9g45_defconfig
141     index 606d48f..8aab786 100644
142     --- a/arch/arm/configs/at91sam9g45_defconfig
143     +++ b/arch/arm/configs/at91sam9g45_defconfig
144     @@ -173,7 +173,6 @@ CONFIG_MMC=y
145     # CONFIG_MMC_BLOCK_BOUNCE is not set
146     CONFIG_SDIO_UART=m
147     CONFIG_MMC_ATMELMCI=y
148     -CONFIG_MMC_ATMELMCI_DMA=y
149     CONFIG_LEDS_ATMEL_PWM=y
150     CONFIG_LEDS_GPIO=y
151     CONFIG_LEDS_TRIGGER_TIMER=y
152     diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
153     index 80d6fc4..9bcd262 100644
154     --- a/arch/arm/include/asm/pgtable.h
155     +++ b/arch/arm/include/asm/pgtable.h
156     @@ -61,6 +61,15 @@ extern void __pgd_error(const char *file, int line, pgd_t);
157     #define FIRST_USER_ADDRESS PAGE_SIZE
158    
159     /*
160     + * Use TASK_SIZE as the ceiling argument for free_pgtables() and
161     + * free_pgd_range() to avoid freeing the modules pmd when LPAE is enabled (pmd
162     + * page shared between user and kernel).
163     + */
164     +#ifdef CONFIG_ARM_LPAE
165     +#define USER_PGTABLES_CEILING TASK_SIZE
166     +#endif
167     +
168     +/*
169     * The pgprot_* and protection_map entries will be fixed up in runtime
170     * to include the cachable and bufferable bits based on memory policy,
171     * as well as any architecture dependent bits like global/ASID and SMP
172     diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
173     index 4b67847..6b4608d 100644
174     --- a/arch/arm/mach-at91/setup.c
175     +++ b/arch/arm/mach-at91/setup.c
176     @@ -333,7 +333,7 @@ static void at91_dt_rstc(void)
177    
178     of_id = of_match_node(rstc_ids, np);
179     if (!of_id)
180     - panic("AT91: rtsc no restart function availlable\n");
181     + panic("AT91: rtsc no restart function available\n");
182    
183     arm_pm_restart = of_id->data;
184    
185     diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
186     index 80392fc..4f67a5b 100644
187     --- a/arch/arm/mach-omap2/cpuidle34xx.c
188     +++ b/arch/arm/mach-omap2/cpuidle34xx.c
189     @@ -274,8 +274,9 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
190     static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
191    
192     static struct cpuidle_driver omap3_idle_driver = {
193     - .name = "omap3_idle",
194     - .owner = THIS_MODULE,
195     + .name = "omap3_idle",
196     + .owner = THIS_MODULE,
197     + .en_core_tk_irqen = 1,
198     .states = {
199     {
200     .enter = omap3_enter_idle_bm,
201     diff --git a/arch/arm/mach-u300/include/mach/u300-regs.h b/arch/arm/mach-u300/include/mach/u300-regs.h
202     index 1e49d90..0320495 100644
203     --- a/arch/arm/mach-u300/include/mach/u300-regs.h
204     +++ b/arch/arm/mach-u300/include/mach/u300-regs.h
205     @@ -95,7 +95,7 @@
206     #define U300_SPI_BASE (U300_FAST_PER_PHYS_BASE+0x6000)
207    
208     /* Fast UART1 on U335 only */
209     -#define U300_UART1_BASE (U300_SLOW_PER_PHYS_BASE+0x7000)
210     +#define U300_UART1_BASE (U300_FAST_PER_PHYS_BASE+0x7000)
211    
212     /*
213     * SLOW peripherals
214     diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig
215     index 0421498..9791820 100644
216     --- a/arch/avr32/configs/favr-32_defconfig
217     +++ b/arch/avr32/configs/favr-32_defconfig
218     @@ -122,7 +122,6 @@ CONFIG_USB_G_SERIAL=m
219     CONFIG_USB_CDC_COMPOSITE=m
220     CONFIG_MMC=y
221     CONFIG_MMC_ATMELMCI=y
222     -CONFIG_MMC_ATMELMCI_DMA=y
223     CONFIG_NEW_LEDS=y
224     CONFIG_LEDS_CLASS=y
225     CONFIG_LEDS_ATMEL_PWM=m
226     diff --git a/arch/avr32/configs/merisc_defconfig b/arch/avr32/configs/merisc_defconfig
227     index 3befab9..65de443 100644
228     --- a/arch/avr32/configs/merisc_defconfig
229     +++ b/arch/avr32/configs/merisc_defconfig
230     @@ -102,7 +102,6 @@ CONFIG_FRAMEBUFFER_CONSOLE=y
231     CONFIG_LOGO=y
232     CONFIG_MMC=y
233     CONFIG_MMC_ATMELMCI=y
234     -CONFIG_MMC_ATMELMCI_DMA=y
235     CONFIG_NEW_LEDS=y
236     CONFIG_LEDS_CLASS=y
237     CONFIG_LEDS_ATMEL_PWM=y
238     diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h
239     index d2bf1fd..76acbcd 100644
240     --- a/arch/ia64/include/asm/futex.h
241     +++ b/arch/ia64/include/asm/futex.h
242     @@ -106,16 +106,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
243     return -EFAULT;
244    
245     {
246     - register unsigned long r8 __asm ("r8");
247     + register unsigned long r8 __asm ("r8") = 0;
248     unsigned long prev;
249     __asm__ __volatile__(
250     " mf;; \n"
251     - " mov %0=r0 \n"
252     " mov ar.ccv=%4;; \n"
253     "[1:] cmpxchg4.acq %1=[%2],%3,ar.ccv \n"
254     " .xdata4 \"__ex_table\", 1b-., 2f-. \n"
255     "[2:]"
256     - : "=r" (r8), "=r" (prev)
257     + : "+r" (r8), "=&r" (prev)
258     : "r" (uaddr), "r" (newval),
259     "rO" ((long) (unsigned) oldval)
260     : "memory");
261     diff --git a/arch/ia64/include/asm/mca.h b/arch/ia64/include/asm/mca.h
262     index 43f96ab..8c70961 100644
263     --- a/arch/ia64/include/asm/mca.h
264     +++ b/arch/ia64/include/asm/mca.h
265     @@ -143,6 +143,7 @@ extern unsigned long __per_cpu_mca[NR_CPUS];
266     extern int cpe_vector;
267     extern int ia64_cpe_irq;
268     extern void ia64_mca_init(void);
269     +extern void ia64_mca_irq_init(void);
270     extern void ia64_mca_cpu_init(void *);
271     extern void ia64_os_mca_dispatch(void);
272     extern void ia64_os_mca_dispatch_end(void);
273     diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
274     index ad69606..f2c41828 100644
275     --- a/arch/ia64/kernel/irq.c
276     +++ b/arch/ia64/kernel/irq.c
277     @@ -23,6 +23,8 @@
278     #include <linux/interrupt.h>
279     #include <linux/kernel_stat.h>
280    
281     +#include <asm/mca.h>
282     +
283     /*
284     * 'what should we do if we get a hw irq event on an illegal vector'.
285     * each architecture has to answer this themselves.
286     @@ -83,6 +85,12 @@ bool is_affinity_mask_valid(const struct cpumask *cpumask)
287    
288     #endif /* CONFIG_SMP */
289    
290     +int __init arch_early_irq_init(void)
291     +{
292     + ia64_mca_irq_init();
293     + return 0;
294     +}
295     +
296     #ifdef CONFIG_HOTPLUG_CPU
297     unsigned int vectors_in_migration[NR_IRQS];
298    
299     diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
300     index 65bf9cd..d7396db 100644
301     --- a/arch/ia64/kernel/mca.c
302     +++ b/arch/ia64/kernel/mca.c
303     @@ -2074,22 +2074,16 @@ ia64_mca_init(void)
304     printk(KERN_INFO "MCA related initialization done\n");
305     }
306    
307     +
308     /*
309     - * ia64_mca_late_init
310     - *
311     - * Opportunity to setup things that require initialization later
312     - * than ia64_mca_init. Setup a timer to poll for CPEs if the
313     - * platform doesn't support an interrupt driven mechanism.
314     - *
315     - * Inputs : None
316     - * Outputs : Status
317     + * These pieces cannot be done in ia64_mca_init() because it is called before
318     + * early_irq_init() which would wipe out our percpu irq registrations. But we
319     + * cannot leave them until ia64_mca_late_init() because by then all the other
320     + * processors have been brought online and have set their own CMC vectors to
321     + * point at a non-existant action. Called from arch_early_irq_init().
322     */
323     -static int __init
324     -ia64_mca_late_init(void)
325     +void __init ia64_mca_irq_init(void)
326     {
327     - if (!mca_init)
328     - return 0;
329     -
330     /*
331     * Configure the CMCI/P vector and handler. Interrupts for CMC are
332     * per-processor, so AP CMC interrupts are setup in smp_callin() (smpboot.c).
333     @@ -2108,6 +2102,23 @@ ia64_mca_late_init(void)
334     /* Setup the CPEI/P handler */
335     register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction);
336     #endif
337     +}
338     +
339     +/*
340     + * ia64_mca_late_init
341     + *
342     + * Opportunity to setup things that require initialization later
343     + * than ia64_mca_init. Setup a timer to poll for CPEs if the
344     + * platform doesn't support an interrupt driven mechanism.
345     + *
346     + * Inputs : None
347     + * Outputs : Status
348     + */
349     +static int __init
350     +ia64_mca_late_init(void)
351     +{
352     + if (!mca_init)
353     + return 0;
354    
355     register_hotcpu_notifier(&mca_cpu_notifier);
356    
357     diff --git a/arch/ia64/kvm/vtlb.c b/arch/ia64/kvm/vtlb.c
358     index 4332f7e..a7869f8 100644
359     --- a/arch/ia64/kvm/vtlb.c
360     +++ b/arch/ia64/kvm/vtlb.c
361     @@ -256,7 +256,7 @@ u64 guest_vhpt_lookup(u64 iha, u64 *pte)
362     "srlz.d;;"
363     "ssm psr.i;;"
364     "srlz.d;;"
365     - : "=r"(ret) : "r"(iha), "r"(pte):"memory");
366     + : "=&r"(ret) : "r"(iha), "r"(pte) : "memory");
367    
368     return ret;
369     }
370     diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
371     index ea847ab..1167008 100644
372     --- a/arch/powerpc/kernel/cpu_setup_power.S
373     +++ b/arch/powerpc/kernel/cpu_setup_power.S
374     @@ -66,6 +66,7 @@ _GLOBAL(__restore_cpu_power8)
375     bl __init_FSCR
376     mfmsr r3
377     rldicl. r0,r3,4,63
378     + mtlr r11
379     beqlr
380     li r0,0
381     mtspr SPRN_LPID,r0
382     diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
383     index 56bd923..3bbe7ed 100644
384     --- a/arch/powerpc/kernel/exceptions-64s.S
385     +++ b/arch/powerpc/kernel/exceptions-64s.S
386     @@ -797,7 +797,7 @@ hardware_interrupt_relon_hv:
387     _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
388     FTR_SECTION_ELSE
389     _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
390     - ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_206)
391     + ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
392     STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment)
393     STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check)
394     STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable)
395     diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
396     index 0886ae6..b61363d 100644
397     --- a/arch/powerpc/kernel/head_64.S
398     +++ b/arch/powerpc/kernel/head_64.S
399     @@ -509,6 +509,7 @@ _GLOBAL(copy_and_flush)
400     sync
401     addi r5,r5,8
402     addi r6,r6,8
403     + isync
404     blr
405    
406     .align 8
407     diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
408     index 3f3bb4c..35f77a4 100644
409     --- a/arch/powerpc/platforms/cell/spufs/inode.c
410     +++ b/arch/powerpc/platforms/cell/spufs/inode.c
411     @@ -99,6 +99,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
412     if (!inode)
413     goto out;
414    
415     + inode->i_ino = get_next_ino();
416     inode->i_mode = mode;
417     inode->i_uid = current_fsuid();
418     inode->i_gid = current_fsgid();
419     diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
420     index cf1a7ec..a59c643 100644
421     --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
422     +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
423     @@ -42,6 +42,7 @@
424     * SOFTWARE.
425     */
426    
427     +#include <asm/inst.h>
428     #include <linux/linkage.h>
429    
430     ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
431     @@ -225,10 +226,10 @@ LABEL crc_ %i
432     movdqa (bufp), %xmm0 # 2 consts: K1:K2
433    
434     movq crc_init, %xmm1 # CRC for block 1
435     - pclmulqdq $0x00,%xmm0,%xmm1 # Multiply by K2
436     + PCLMULQDQ 0x00,%xmm0,%xmm1 # Multiply by K2
437    
438     movq crc1, %xmm2 # CRC for block 2
439     - pclmulqdq $0x10, %xmm0, %xmm2 # Multiply by K1
440     + PCLMULQDQ 0x10, %xmm0, %xmm2 # Multiply by K1
441    
442     pxor %xmm2,%xmm1
443     movq %xmm1, %rax
444     diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
445     index c5e403f..1c68ccb 100644
446     --- a/arch/x86/kernel/head64.c
447     +++ b/arch/x86/kernel/head64.c
448     @@ -34,6 +34,7 @@
449     extern pgd_t early_level4_pgt[PTRS_PER_PGD];
450     extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
451     static unsigned int __initdata next_early_pgt = 2;
452     +pmdval_t __initdata early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
453    
454     /* Wipe all early page tables except for the kernel symbol map */
455     static void __init reset_early_page_tables(void)
456     @@ -99,7 +100,7 @@ again:
457     pmd_p[i] = 0;
458     *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
459     }
460     - pmd = (physaddr & PMD_MASK) + (__PAGE_KERNEL_LARGE & ~_PAGE_GLOBAL);
461     + pmd = (physaddr & PMD_MASK) + early_pmd_flags;
462     pmd_p[pmd_index(address)] = pmd;
463    
464     return 0;
465     diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
466     index 6859e96..08f7e80 100644
467     --- a/arch/x86/kernel/head_64.S
468     +++ b/arch/x86/kernel/head_64.S
469     @@ -200,6 +200,7 @@ ENTRY(secondary_startup_64)
470     btl $20,%edi /* No Execute supported? */
471     jnc 1f
472     btsl $_EFER_NX, %eax
473     + btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
474     1: wrmsr /* Make changes effective */
475    
476     /* Setup cr0 */
477     diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
478     index e4595f1..84b7789 100644
479     --- a/arch/x86/kernel/irq.c
480     +++ b/arch/x86/kernel/irq.c
481     @@ -165,10 +165,6 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
482     u64 arch_irq_stat(void)
483     {
484     u64 sum = atomic_read(&irq_err_count);
485     -
486     -#ifdef CONFIG_X86_IO_APIC
487     - sum += atomic_read(&irq_mis_count);
488     -#endif
489     return sum;
490     }
491    
492     diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
493     index a335cc6..a9c9d3e 100644
494     --- a/arch/x86/kvm/emulate.c
495     +++ b/arch/x86/kvm/emulate.c
496     @@ -4162,6 +4162,10 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
497     break;
498     case OpMem8:
499     ctxt->memop.bytes = 1;
500     + if (ctxt->memop.type == OP_REG) {
501     + ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm, 1);
502     + fetch_register_operand(&ctxt->memop);
503     + }
504     goto mem_common;
505     case OpMem16:
506     ctxt->memop.bytes = 2;
507     diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
508     index c8e1c7b..2363127 100644
509     --- a/arch/x86/xen/enlighten.c
510     +++ b/arch/x86/xen/enlighten.c
511     @@ -1589,8 +1589,11 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
512     switch (action) {
513     case CPU_UP_PREPARE:
514     xen_vcpu_setup(cpu);
515     - if (xen_have_vector_callback)
516     + if (xen_have_vector_callback) {
517     xen_init_lock_cpu(cpu);
518     + if (xen_feature(XENFEAT_hvm_safe_pvclock))
519     + xen_setup_timer(cpu);
520     + }
521     break;
522     default:
523     break;
524     diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
525     index 09ea61d..22c800a 100644
526     --- a/arch/x86/xen/smp.c
527     +++ b/arch/x86/xen/smp.c
528     @@ -662,6 +662,8 @@ static void xen_hvm_cpu_die(unsigned int cpu)
529     unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
530     unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu), NULL);
531     unbind_from_irqhandler(per_cpu(xen_irq_work, cpu), NULL);
532     + xen_uninit_lock_cpu(cpu);
533     + xen_teardown_timer(cpu);
534     native_cpu_die(cpu);
535     }
536    
537     diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
538     index 0296a95..054cc01 100644
539     --- a/arch/x86/xen/time.c
540     +++ b/arch/x86/xen/time.c
541     @@ -497,7 +497,11 @@ static void xen_hvm_setup_cpu_clockevents(void)
542     {
543     int cpu = smp_processor_id();
544     xen_setup_runstate_info(cpu);
545     - xen_setup_timer(cpu);
546     + /*
547     + * xen_setup_timer(cpu) - snprintf is bad in atomic context. Hence
548     + * doing it xen_hvm_cpu_notify (which gets called by smp_init during
549     + * early bootup and also during CPU hotplug events).
550     + */
551     xen_setup_cpu_clockevents();
552     }
553    
554     diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
555     index 586e7e9..bcb7a3b 100644
556     --- a/drivers/acpi/osl.c
557     +++ b/drivers/acpi/osl.c
558     @@ -641,7 +641,7 @@ void __init acpi_initrd_override(void *data, size_t size)
559     * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
560     * works fine.
561     */
562     - memblock_reserve(acpi_tables_addr, acpi_tables_addr + all_tables_size);
563     + memblock_reserve(acpi_tables_addr, all_tables_size);
564     arch_reserve_mem_area(acpi_tables_addr, all_tables_size);
565    
566     p = early_ioremap(acpi_tables_addr, all_tables_size);
567     diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
568     index 6ae5e44..4241b8d 100644
569     --- a/drivers/acpi/pci_root.c
570     +++ b/drivers/acpi/pci_root.c
571     @@ -201,8 +201,8 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
572     *control &= OSC_PCI_CONTROL_MASKS;
573     capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set;
574     } else {
575     - /* Run _OSC query for all possible controls. */
576     - capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
577     + /* Run _OSC query only with existing controls. */
578     + capbuf[OSC_CONTROL_TYPE] = root->osc_control_set;
579     }
580    
581     status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
582     diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
583     index 8470771..a33821c 100644
584     --- a/drivers/acpi/thermal.c
585     +++ b/drivers/acpi/thermal.c
586     @@ -723,9 +723,19 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
587     return -EINVAL;
588    
589     if (type == THERMAL_TRIP_ACTIVE) {
590     - /* aggressive active cooling */
591     - *trend = THERMAL_TREND_RAISING;
592     - return 0;
593     + unsigned long trip_temp;
594     + unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature,
595     + tz->kelvin_offset);
596     + if (thermal_get_trip_temp(thermal, trip, &trip_temp))
597     + return -EINVAL;
598     +
599     + if (temp > trip_temp) {
600     + *trend = THERMAL_TREND_RAISING;
601     + return 0;
602     + } else {
603     + /* Fall back on default trend */
604     + return -EINVAL;
605     + }
606     }
607    
608     /*
609     diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
610     index 8a52dab..3badf18 100644
611     --- a/drivers/ata/libata-acpi.c
612     +++ b/drivers/ata/libata-acpi.c
613     @@ -61,7 +61,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
614     if (ap->flags & ATA_FLAG_ACPI_SATA)
615     return NULL;
616    
617     - return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no);
618     + return ap->scsi_host ?
619     + DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
620     }
621     EXPORT_SYMBOL(ata_ap_acpi_handle);
622    
623     @@ -240,28 +241,15 @@ void ata_acpi_dissociate(struct ata_host *host)
624     }
625     }
626    
627     -/**
628     - * ata_acpi_gtm - execute _GTM
629     - * @ap: target ATA port
630     - * @gtm: out parameter for _GTM result
631     - *
632     - * Evaluate _GTM and store the result in @gtm.
633     - *
634     - * LOCKING:
635     - * EH context.
636     - *
637     - * RETURNS:
638     - * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
639     - */
640     -int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
641     +static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
642     + struct ata_acpi_gtm *gtm)
643     {
644     struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
645     union acpi_object *out_obj;
646     acpi_status status;
647     int rc = 0;
648    
649     - status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL,
650     - &output);
651     + status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
652    
653     rc = -ENOENT;
654     if (status == AE_NOT_FOUND)
655     @@ -295,6 +283,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
656     return rc;
657     }
658    
659     +/**
660     + * ata_acpi_gtm - execute _GTM
661     + * @ap: target ATA port
662     + * @gtm: out parameter for _GTM result
663     + *
664     + * Evaluate _GTM and store the result in @gtm.
665     + *
666     + * LOCKING:
667     + * EH context.
668     + *
669     + * RETURNS:
670     + * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
671     + */
672     +int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
673     +{
674     + if (ata_ap_acpi_handle(ap))
675     + return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
676     + else
677     + return -EINVAL;
678     +}
679     +
680     EXPORT_SYMBOL_GPL(ata_acpi_gtm);
681    
682     /**
683     @@ -1080,7 +1089,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
684     if (!*handle)
685     return -ENODEV;
686    
687     - if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
688     + if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
689     ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
690    
691     return 0;
692     diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
693     index 5dba77c..b1a664a 100644
694     --- a/drivers/ata/sata_highbank.c
695     +++ b/drivers/ata/sata_highbank.c
696     @@ -251,7 +251,7 @@ static const struct ata_port_info ahci_highbank_port_info = {
697     };
698    
699     static struct scsi_host_template ahci_highbank_platform_sht = {
700     - AHCI_SHT("highbank-ahci"),
701     + AHCI_SHT("sata_highbank"),
702     };
703    
704     static const struct of_device_id ahci_of_match[] = {
705     diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
706     index 0d2e82f..7c3b3dc 100644
707     --- a/drivers/char/tpm/tpm.c
708     +++ b/drivers/char/tpm/tpm.c
709     @@ -1337,7 +1337,7 @@ int tpm_pm_suspend(struct device *dev)
710     {
711     struct tpm_chip *chip = dev_get_drvdata(dev);
712     struct tpm_cmd_t cmd;
713     - int rc;
714     + int rc, try;
715    
716     u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 };
717    
718     @@ -1355,9 +1355,32 @@ int tpm_pm_suspend(struct device *dev)
719     }
720    
721     /* now do the actual savestate */
722     - cmd.header.in = savestate_header;
723     - rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE,
724     - "sending savestate before suspend");
725     + for (try = 0; try < TPM_RETRY; try++) {
726     + cmd.header.in = savestate_header;
727     + rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL);
728     +
729     + /*
730     + * If the TPM indicates that it is too busy to respond to
731     + * this command then retry before giving up. It can take
732     + * several seconds for this TPM to be ready.
733     + *
734     + * This can happen if the TPM has already been sent the
735     + * SaveState command before the driver has loaded. TCG 1.2
736     + * specification states that any communication after SaveState
737     + * may cause the TPM to invalidate previously saved state.
738     + */
739     + if (rc != TPM_WARN_RETRY)
740     + break;
741     + msleep(TPM_TIMEOUT_RETRY);
742     + }
743     +
744     + if (rc)
745     + dev_err(chip->dev,
746     + "Error (%d) sending savestate before suspend\n", rc);
747     + else if (try > 0)
748     + dev_warn(chip->dev, "TPM savestate took %dms\n",
749     + try * TPM_TIMEOUT_RETRY);
750     +
751     return rc;
752     }
753     EXPORT_SYMBOL_GPL(tpm_pm_suspend);
754     diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
755     index 81b5201..0770d1d 100644
756     --- a/drivers/char/tpm/tpm.h
757     +++ b/drivers/char/tpm/tpm.h
758     @@ -32,10 +32,12 @@ enum tpm_const {
759     TPM_MINOR = 224, /* officially assigned */
760     TPM_BUFSIZE = 4096,
761     TPM_NUM_DEVICES = 256,
762     + TPM_RETRY = 50, /* 5 seconds */
763     };
764    
765     enum tpm_timeout {
766     TPM_TIMEOUT = 5, /* msecs */
767     + TPM_TIMEOUT_RETRY = 100 /* msecs */
768     };
769    
770     /* TPM addresses */
771     @@ -44,6 +46,7 @@ enum tpm_addr {
772     TPM_ADDR = 0x4E,
773     };
774    
775     +#define TPM_WARN_RETRY 0x800
776     #define TPM_WARN_DOING_SELFTEST 0x802
777     #define TPM_ERR_DEACTIVATED 0x6
778     #define TPM_ERR_DISABLED 0x7
779     diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
780     index cafa72f..d6fbb577 100644
781     --- a/drivers/hv/ring_buffer.c
782     +++ b/drivers/hv/ring_buffer.c
783     @@ -71,6 +71,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
784    
785     static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
786     {
787     + smp_mb();
788     if (rbi->ring_buffer->interrupt_mask)
789     return false;
790    
791     diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
792     index 332c720..3d0f052 100644
793     --- a/drivers/i2c/busses/i2c-xiic.c
794     +++ b/drivers/i2c/busses/i2c-xiic.c
795     @@ -312,10 +312,8 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c)
796     /* last message in transfer -> STOP */
797     data |= XIIC_TX_DYN_STOP_MASK;
798     dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__);
799     -
800     - xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
801     - } else
802     - xiic_setreg8(i2c, XIIC_DTR_REG_OFFSET, data);
803     + }
804     + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
805     }
806     }
807    
808     diff --git a/drivers/md/md.c b/drivers/md/md.c
809     index aeceedf..a4a93b9 100644
810     --- a/drivers/md/md.c
811     +++ b/drivers/md/md.c
812     @@ -1564,8 +1564,8 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
813     sector, count, 1) == 0)
814     return -EINVAL;
815     }
816     - } else if (sb->bblog_offset == 0)
817     - rdev->badblocks.shift = -1;
818     + } else if (sb->bblog_offset != 0)
819     + rdev->badblocks.shift = 0;
820    
821     if (!refdev) {
822     ret = 1;
823     @@ -3221,7 +3221,7 @@ int md_rdev_init(struct md_rdev *rdev)
824     * be used - I wonder if that matters
825     */
826     rdev->badblocks.count = 0;
827     - rdev->badblocks.shift = 0;
828     + rdev->badblocks.shift = -1; /* disabled until explicitly enabled */
829     rdev->badblocks.page = kmalloc(PAGE_SIZE, GFP_KERNEL);
830     seqlock_init(&rdev->badblocks.lock);
831     if (rdev->badblocks.page == NULL)
832     @@ -3293,9 +3293,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
833     goto abort_free;
834     }
835     }
836     - if (super_format == -1)
837     - /* hot-add for 0.90, or non-persistent: so no badblocks */
838     - rdev->badblocks.shift = -1;
839    
840     return rdev;
841    
842     diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
843     index fd86b37..6af167f 100644
844     --- a/drivers/md/raid1.c
845     +++ b/drivers/md/raid1.c
846     @@ -981,7 +981,12 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
847     while (bio) { /* submit pending writes */
848     struct bio *next = bio->bi_next;
849     bio->bi_next = NULL;
850     - generic_make_request(bio);
851     + if (unlikely((bio->bi_rw & REQ_DISCARD) &&
852     + !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
853     + /* Just ignore it */
854     + bio_endio(bio, 0);
855     + else
856     + generic_make_request(bio);
857     bio = next;
858     }
859     kfree(plug);
860     diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
861     index 77b562d..46c14e5 100644
862     --- a/drivers/md/raid10.c
863     +++ b/drivers/md/raid10.c
864     @@ -1133,7 +1133,12 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
865     while (bio) { /* submit pending writes */
866     struct bio *next = bio->bi_next;
867     bio->bi_next = NULL;
868     - generic_make_request(bio);
869     + if (unlikely((bio->bi_rw & REQ_DISCARD) &&
870     + !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
871     + /* Just ignore it */
872     + bio_endio(bio, 0);
873     + else
874     + generic_make_request(bio);
875     bio = next;
876     }
877     kfree(plug);
878     diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
879     index 210dd03..6b40e0c 100644
880     --- a/drivers/mfd/adp5520.c
881     +++ b/drivers/mfd/adp5520.c
882     @@ -36,6 +36,7 @@ struct adp5520_chip {
883     struct blocking_notifier_head notifier_list;
884     int irq;
885     unsigned long id;
886     + uint8_t mode;
887     };
888    
889     static int __adp5520_read(struct i2c_client *client,
890     @@ -326,7 +327,10 @@ static int adp5520_suspend(struct device *dev)
891     struct i2c_client *client = to_i2c_client(dev);
892     struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
893    
894     - adp5520_clr_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
895     + adp5520_read(chip->dev, ADP5520_MODE_STATUS, &chip->mode);
896     + /* All other bits are W1C */
897     + chip->mode &= ADP5520_BL_EN | ADP5520_DIM_EN | ADP5520_nSTNBY;
898     + adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
899     return 0;
900     }
901    
902     @@ -335,7 +339,7 @@ static int adp5520_resume(struct device *dev)
903     struct i2c_client *client = to_i2c_client(dev);
904     struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
905    
906     - adp5520_set_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
907     + adp5520_write(chip->dev, ADP5520_MODE_STATUS, chip->mode);
908     return 0;
909     }
910     #endif
911     diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
912     index c8f3d6e..8ac5101 100644
913     --- a/drivers/mmc/core/mmc.c
914     +++ b/drivers/mmc/core/mmc.c
915     @@ -368,13 +368,13 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
916     ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT];
917     card->ext_csd.raw_trim_mult =
918     ext_csd[EXT_CSD_TRIM_MULT];
919     + card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
920     if (card->ext_csd.rev >= 4) {
921     /*
922     * Enhanced area feature support -- check whether the eMMC
923     * card has the Enhanced area enabled. If so, export enhanced
924     * area offset and size to user by adding sysfs interface.
925     */
926     - card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
927     if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
928     (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
929     hc_erase_grp_sz =
930     diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
931     index d88219e..9c581c2 100644
932     --- a/drivers/mmc/host/Kconfig
933     +++ b/drivers/mmc/host/Kconfig
934     @@ -300,16 +300,6 @@ config MMC_ATMELMCI
935    
936     If unsure, say N.
937    
938     -config MMC_ATMELMCI_DMA
939     - bool "Atmel MCI DMA support"
940     - depends on MMC_ATMELMCI && (AVR32 || ARCH_AT91SAM9G45) && DMA_ENGINE
941     - help
942     - Say Y here to have the Atmel MCI driver use a DMA engine to
943     - do data transfers and thus increase the throughput and
944     - reduce the CPU utilization.
945     -
946     - If unsure, say N.
947     -
948     config MMC_MSM
949     tristate "Qualcomm SDCC Controller Support"
950     depends on MMC && ARCH_MSM
951     diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
952     index 722af1d..e75774f 100644
953     --- a/drivers/mmc/host/atmel-mci.c
954     +++ b/drivers/mmc/host/atmel-mci.c
955     @@ -178,6 +178,7 @@ struct atmel_mci {
956     void __iomem *regs;
957    
958     struct scatterlist *sg;
959     + unsigned int sg_len;
960     unsigned int pio_offset;
961     unsigned int *buffer;
962     unsigned int buf_size;
963     @@ -892,6 +893,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
964     data->error = -EINPROGRESS;
965    
966     host->sg = data->sg;
967     + host->sg_len = data->sg_len;
968     host->data = data;
969     host->data_chan = NULL;
970    
971     @@ -1826,7 +1828,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
972     if (offset == sg->length) {
973     flush_dcache_page(sg_page(sg));
974     host->sg = sg = sg_next(sg);
975     - if (!sg)
976     + host->sg_len--;
977     + if (!sg || !host->sg_len)
978     goto done;
979    
980     offset = 0;
981     @@ -1839,7 +1842,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
982    
983     flush_dcache_page(sg_page(sg));
984     host->sg = sg = sg_next(sg);
985     - if (!sg)
986     + host->sg_len--;
987     + if (!sg || !host->sg_len)
988     goto done;
989    
990     offset = 4 - remaining;
991     @@ -1890,7 +1894,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
992     nbytes += 4;
993     if (offset == sg->length) {
994     host->sg = sg = sg_next(sg);
995     - if (!sg)
996     + host->sg_len--;
997     + if (!sg || !host->sg_len)
998     goto done;
999    
1000     offset = 0;
1001     @@ -1904,7 +1909,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
1002     nbytes += remaining;
1003    
1004     host->sg = sg = sg_next(sg);
1005     - if (!sg) {
1006     + host->sg_len--;
1007     + if (!sg || !host->sg_len) {
1008     atmci_writel(host, ATMCI_TDR, value);
1009     goto done;
1010     }
1011     @@ -2487,10 +2493,8 @@ static int __exit atmci_remove(struct platform_device *pdev)
1012     atmci_readl(host, ATMCI_SR);
1013     clk_disable(host->mck);
1014    
1015     -#ifdef CONFIG_MMC_ATMELMCI_DMA
1016     if (host->dma.chan)
1017     dma_release_channel(host->dma.chan);
1018     -#endif
1019    
1020     free_irq(platform_get_irq(pdev, 0), host);
1021     iounmap(host->regs);
1022     diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
1023     index 2e5daee..a3f8a25 100644
1024     --- a/drivers/net/ethernet/freescale/gianfar_ptp.c
1025     +++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
1026     @@ -127,7 +127,6 @@ struct gianfar_ptp_registers {
1027    
1028     #define DRIVER "gianfar_ptp"
1029     #define DEFAULT_CKSEL 1
1030     -#define N_ALARM 1 /* first alarm is used internally to reset fipers */
1031     #define N_EXT_TS 2
1032     #define REG_SIZE sizeof(struct gianfar_ptp_registers)
1033    
1034     @@ -410,7 +409,7 @@ static struct ptp_clock_info ptp_gianfar_caps = {
1035     .owner = THIS_MODULE,
1036     .name = "gianfar clock",
1037     .max_adj = 512000,
1038     - .n_alarm = N_ALARM,
1039     + .n_alarm = 0,
1040     .n_ext_ts = N_EXT_TS,
1041     .n_per_out = 0,
1042     .pps = 1,
1043     diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
1044     index b477fa5..065f8c8 100644
1045     --- a/drivers/net/ethernet/intel/e1000e/ptp.c
1046     +++ b/drivers/net/ethernet/intel/e1000e/ptp.c
1047     @@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp,
1048     unsigned long flags;
1049     u64 ns;
1050    
1051     - ns = ts->tv_sec * NSEC_PER_SEC;
1052     - ns += ts->tv_nsec;
1053     + ns = timespec_to_ns(ts);
1054    
1055     /* reset the timecounter */
1056     spin_lock_irqsave(&adapter->systim_lock, flags);
1057     diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1058     index 79f4a26..a892efd 100644
1059     --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1060     +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1061     @@ -2405,6 +2405,16 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
1062     * with the write to EICR.
1063     */
1064     eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
1065     +
1066     + /* The lower 16bits of the EICR register are for the queue interrupts
1067     + * which should be masked here in order to not accidently clear them if
1068     + * the bits are high when ixgbe_msix_other is called. There is a race
1069     + * condition otherwise which results in possible performance loss
1070     + * especially if the ixgbe_msix_other interrupt is triggering
1071     + * consistently (as it would when PPS is turned on for the X540 device)
1072     + */
1073     + eicr &= 0xFFFF0000;
1074     +
1075     IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
1076    
1077     if (eicr & IXGBE_EICR_LSC)
1078     diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1079     index 20806ca..81d4071 100644
1080     --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1081     +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1082     @@ -2237,15 +2237,15 @@ static ssize_t iwl_dbgfs_log_event_read(struct file *file,
1083     size_t count, loff_t *ppos)
1084     {
1085     struct iwl_priv *priv = file->private_data;
1086     - char *buf;
1087     - int pos = 0;
1088     - ssize_t ret = -ENOMEM;
1089     + char *buf = NULL;
1090     + ssize_t ret;
1091    
1092     - ret = pos = iwl_dump_nic_event_log(priv, true, &buf, true);
1093     - if (buf) {
1094     - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1095     - kfree(buf);
1096     - }
1097     + ret = iwl_dump_nic_event_log(priv, true, &buf, true);
1098     + if (ret < 0)
1099     + goto err;
1100     + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1101     +err:
1102     + kfree(buf);
1103     return ret;
1104     }
1105    
1106     diff --git a/drivers/net/wireless/iwlwifi/dvm/sta.c b/drivers/net/wireless/iwlwifi/dvm/sta.c
1107     index b775769..db183b4 100644
1108     --- a/drivers/net/wireless/iwlwifi/dvm/sta.c
1109     +++ b/drivers/net/wireless/iwlwifi/dvm/sta.c
1110     @@ -695,6 +695,7 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv,
1111     void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1112     {
1113     struct iwl_addsta_cmd sta_cmd;
1114     + static const struct iwl_link_quality_cmd zero_lq = {};
1115     struct iwl_link_quality_cmd lq;
1116     int i;
1117     bool found = false;
1118     @@ -733,7 +734,9 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1119     else
1120     memcpy(&lq, priv->stations[i].lq,
1121     sizeof(struct iwl_link_quality_cmd));
1122     - send_lq = true;
1123     +
1124     + if (!memcmp(&lq, &zero_lq, sizeof(lq)))
1125     + send_lq = true;
1126     }
1127     spin_unlock_bh(&priv->sta_lock);
1128     ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
1129     diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
1130     index feb2046..f024fb0 100644
1131     --- a/drivers/net/wireless/mwifiex/pcie.c
1132     +++ b/drivers/net/wireless/mwifiex/pcie.c
1133     @@ -2281,9 +2281,9 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
1134     if (pdev) {
1135     pci_iounmap(pdev, card->pci_mmap);
1136     pci_iounmap(pdev, card->pci_mmap1);
1137     -
1138     - pci_release_regions(pdev);
1139     pci_disable_device(pdev);
1140     + pci_release_region(pdev, 2);
1141     + pci_release_region(pdev, 0);
1142     pci_set_drvdata(pdev, NULL);
1143     }
1144     }
1145     diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
1146     index a658b4b..92849e5 100644
1147     --- a/drivers/net/wireless/rt2x00/rt2800lib.c
1148     +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1149     @@ -4436,6 +4436,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1150    
1151     if (!rt2x00_rt(rt2x00dev, RT5390) &&
1152     !rt2x00_rt(rt2x00dev, RT5392)) {
1153     + u8 min_gain = rt2x00_rt(rt2x00dev, RT3070) ? 1 : 2;
1154     +
1155     rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
1156     rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
1157     if (rt2x00_rt(rt2x00dev, RT3070) ||
1158     @@ -4446,8 +4448,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1159     &rt2x00dev->cap_flags))
1160     rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
1161     }
1162     - rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
1163     - drv_data->txmixer_gain_24g);
1164     + if (drv_data->txmixer_gain_24g >= min_gain) {
1165     + rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
1166     + drv_data->txmixer_gain_24g);
1167     + }
1168     rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
1169     }
1170    
1171     diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
1172     index b099e00..fc9bd81 100644
1173     --- a/drivers/pci/pci.c
1174     +++ b/drivers/pci/pci.c
1175     @@ -646,15 +646,11 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
1176     error = platform_pci_set_power_state(dev, state);
1177     if (!error)
1178     pci_update_current_state(dev, state);
1179     - /* Fall back to PCI_D0 if native PM is not supported */
1180     - if (!dev->pm_cap)
1181     - dev->current_state = PCI_D0;
1182     - } else {
1183     + } else
1184     error = -ENODEV;
1185     - /* Fall back to PCI_D0 if native PM is not supported */
1186     - if (!dev->pm_cap)
1187     - dev->current_state = PCI_D0;
1188     - }
1189     +
1190     + if (error && !dev->pm_cap) /* Fall back to PCI_D0 */
1191     + dev->current_state = PCI_D0;
1192    
1193     return error;
1194     }
1195     diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
1196     index 434ebc3..eebd8ac 100644
1197     --- a/drivers/rtc/rtc-at91rm9200.c
1198     +++ b/drivers/rtc/rtc-at91rm9200.c
1199     @@ -297,7 +297,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
1200     "at91_rtc", pdev);
1201     if (ret) {
1202     dev_err(&pdev->dev, "IRQ %d already in use.\n", irq);
1203     - return ret;
1204     + goto err_unmap;
1205     }
1206    
1207     /* cpu init code should really have flagged this device as
1208     @@ -309,13 +309,20 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
1209     rtc = rtc_device_register(pdev->name, &pdev->dev,
1210     &at91_rtc_ops, THIS_MODULE);
1211     if (IS_ERR(rtc)) {
1212     - free_irq(irq, pdev);
1213     - return PTR_ERR(rtc);
1214     + ret = PTR_ERR(rtc);
1215     + goto err_free_irq;
1216     }
1217     platform_set_drvdata(pdev, rtc);
1218    
1219     dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n");
1220     return 0;
1221     +
1222     +err_free_irq:
1223     + free_irq(irq, pdev);
1224     +err_unmap:
1225     + iounmap(at91_rtc_regs);
1226     +
1227     + return ret;
1228     }
1229    
1230     /*
1231     @@ -332,6 +339,7 @@ static int __exit at91_rtc_remove(struct platform_device *pdev)
1232     free_irq(irq, pdev);
1233    
1234     rtc_device_unregister(rtc);
1235     + iounmap(at91_rtc_regs);
1236     platform_set_drvdata(pdev, NULL);
1237    
1238     return 0;
1239     diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
1240     index af97c94..cc5bea9 100644
1241     --- a/drivers/rtc/rtc-cmos.c
1242     +++ b/drivers/rtc/rtc-cmos.c
1243     @@ -804,9 +804,8 @@ static int cmos_suspend(struct device *dev)
1244     mask = RTC_IRQMASK;
1245     tmp &= ~mask;
1246     CMOS_WRITE(tmp, RTC_CONTROL);
1247     + hpet_mask_rtc_irq_bit(mask);
1248    
1249     - /* shut down hpet emulation - we don't need it for alarm */
1250     - hpet_mask_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE);
1251     cmos_checkintr(cmos, tmp);
1252     }
1253     spin_unlock_irq(&rtc_lock);
1254     @@ -870,6 +869,7 @@ static int cmos_resume(struct device *dev)
1255     rtc_update_irq(cmos->rtc, 1, mask);
1256     tmp &= ~RTC_AIE;
1257     hpet_mask_rtc_irq_bit(RTC_AIE);
1258     + hpet_rtc_timer_init();
1259     } while (mask & RTC_AIE);
1260     spin_unlock_irq(&rtc_lock);
1261     }
1262     diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
1263     index cd79838..178836e 100644
1264     --- a/drivers/s390/char/sclp_cmd.c
1265     +++ b/drivers/s390/char/sclp_cmd.c
1266     @@ -561,6 +561,8 @@ static void __init sclp_add_standby_memory(void)
1267     add_memory_merged(0);
1268     }
1269    
1270     +#define MEM_SCT_SIZE (1UL << SECTION_SIZE_BITS)
1271     +
1272     static void __init insert_increment(u16 rn, int standby, int assigned)
1273     {
1274     struct memory_increment *incr, *new_incr;
1275     @@ -573,7 +575,7 @@ static void __init insert_increment(u16 rn, int standby, int assigned)
1276     new_incr->rn = rn;
1277     new_incr->standby = standby;
1278     if (!standby)
1279     - new_incr->usecount = 1;
1280     + new_incr->usecount = rzm > MEM_SCT_SIZE ? rzm/MEM_SCT_SIZE : 1;
1281     last_rn = 0;
1282     prev = &sclp_mem_list;
1283     list_for_each_entry(incr, &sclp_mem_list, list) {
1284     diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig
1285     index 9084565..7fab032 100644
1286     --- a/drivers/staging/zsmalloc/Kconfig
1287     +++ b/drivers/staging/zsmalloc/Kconfig
1288     @@ -1,5 +1,5 @@
1289     config ZSMALLOC
1290     - tristate "Memory allocator for compressed pages"
1291     + bool "Memory allocator for compressed pages"
1292     default n
1293     help
1294     zsmalloc is a slab-based memory allocator designed to store
1295     diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
1296     index e78d262..324e123 100644
1297     --- a/drivers/staging/zsmalloc/zsmalloc-main.c
1298     +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
1299     @@ -656,11 +656,8 @@ static inline void __zs_unmap_object(struct mapping_area *area,
1300     struct page *pages[2], int off, int size)
1301     {
1302     unsigned long addr = (unsigned long)area->vm_addr;
1303     - unsigned long end = addr + (PAGE_SIZE * 2);
1304    
1305     - flush_cache_vunmap(addr, end);
1306     - unmap_kernel_range_noflush(addr, PAGE_SIZE * 2);
1307     - flush_tlb_kernel_range(addr, end);
1308     + unmap_kernel_range(addr, PAGE_SIZE * 2);
1309     }
1310    
1311     #else /* USE_PGTABLE_MAPPING */
1312     diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
1313     index c24b4db..125e0fd 100644
1314     --- a/drivers/tty/pty.c
1315     +++ b/drivers/tty/pty.c
1316     @@ -682,6 +682,9 @@ static int ptmx_open(struct inode *inode, struct file *filp)
1317    
1318     nonseekable_open(inode, filp);
1319    
1320     + /* We refuse fsnotify events on ptmx, since it's a shared resource */
1321     + filp->f_mode |= FMODE_NONOTIFY;
1322     +
1323     retval = tty_alloc_file(filp);
1324     if (retval)
1325     return retval;
1326     diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
1327     index a400002..8fbb6d2 100644
1328     --- a/drivers/tty/serial/serial_core.c
1329     +++ b/drivers/tty/serial/serial_core.c
1330     @@ -1941,6 +1941,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
1331     mutex_unlock(&port->mutex);
1332     return 0;
1333     }
1334     + put_device(tty_dev);
1335     +
1336     if (console_suspend_enabled || !uart_console(uport))
1337     uport->suspended = 1;
1338    
1339     @@ -2006,9 +2008,11 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
1340     disable_irq_wake(uport->irq);
1341     uport->irq_wake = 0;
1342     }
1343     + put_device(tty_dev);
1344     mutex_unlock(&port->mutex);
1345     return 0;
1346     }
1347     + put_device(tty_dev);
1348     uport->suspended = 0;
1349    
1350     /*
1351     diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
1352     index b045268..a9cd0b9 100644
1353     --- a/drivers/tty/tty_io.c
1354     +++ b/drivers/tty/tty_io.c
1355     @@ -941,10 +941,10 @@ void start_tty(struct tty_struct *tty)
1356    
1357     EXPORT_SYMBOL(start_tty);
1358    
1359     +/* We limit tty time update visibility to every 8 seconds or so. */
1360     static void tty_update_time(struct timespec *time)
1361     {
1362     - unsigned long sec = get_seconds();
1363     - sec -= sec % 60;
1364     + unsigned long sec = get_seconds() & ~7;
1365     if ((long)(sec - time->tv_sec) > 0)
1366     time->tv_sec = sec;
1367     }
1368     diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
1369     index f64fbea..d86333b 100644
1370     --- a/drivers/usb/chipidea/udc.c
1371     +++ b/drivers/usb/chipidea/udc.c
1372     @@ -461,6 +461,8 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1373     mReq->ptr->page[i] =
1374     (mReq->req.dma + i * CI13XXX_PAGE_SIZE) & ~TD_RESERVED_MASK;
1375    
1376     + wmb();
1377     +
1378     if (!list_empty(&mEp->qh.queue)) {
1379     struct ci13xxx_req *mReqPrev;
1380     int n = hw_ep_bit(mEp->num, mEp->dir);
1381     @@ -561,6 +563,12 @@ __acquires(mEp->lock)
1382     struct ci13xxx_req *mReq = \
1383     list_entry(mEp->qh.queue.next,
1384     struct ci13xxx_req, queue);
1385     +
1386     + if (mReq->zptr) {
1387     + dma_pool_free(mEp->td_pool, mReq->zptr, mReq->zdma);
1388     + mReq->zptr = NULL;
1389     + }
1390     +
1391     list_del_init(&mReq->queue);
1392     mReq->req.status = -ESHUTDOWN;
1393    
1394     diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h
1395     index 4ff2384d..d12e8b5 100644
1396     --- a/drivers/usb/chipidea/udc.h
1397     +++ b/drivers/usb/chipidea/udc.h
1398     @@ -40,7 +40,7 @@ struct ci13xxx_td {
1399     #define TD_CURR_OFFSET (0x0FFFUL << 0)
1400     #define TD_FRAME_NUM (0x07FFUL << 0)
1401     #define TD_RESERVED_MASK (0x0FFFUL << 0)
1402     -} __attribute__ ((packed));
1403     +} __attribute__ ((packed, aligned(4)));
1404    
1405     /* DMA layout of queue heads */
1406     struct ci13xxx_qh {
1407     @@ -57,7 +57,7 @@ struct ci13xxx_qh {
1408     /* 9 */
1409     u32 RESERVED;
1410     struct usb_ctrlrequest setup;
1411     -} __attribute__ ((packed));
1412     +} __attribute__ ((packed, aligned(4)));
1413    
1414     /**
1415     * struct ci13xxx_req - usb request representation
1416     diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1417     index 8823e98..caefc80 100644
1418     --- a/drivers/usb/core/devio.c
1419     +++ b/drivers/usb/core/devio.c
1420     @@ -739,6 +739,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
1421     index &= 0xff;
1422     switch (requesttype & USB_RECIP_MASK) {
1423     case USB_RECIP_ENDPOINT:
1424     + if ((index & ~USB_DIR_IN) == 0)
1425     + return 0;
1426     ret = findintfep(ps->dev, index);
1427     if (ret >= 0)
1428     ret = checkintf(ps, ret);
1429     diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
1430     index 416a6dc..83b5a172 100644
1431     --- a/drivers/usb/host/ehci-hcd.c
1432     +++ b/drivers/usb/host/ehci-hcd.c
1433     @@ -670,9 +670,6 @@ int ehci_setup(struct usb_hcd *hcd)
1434     if (retval)
1435     return retval;
1436    
1437     - if (ehci_is_TDI(ehci))
1438     - tdi_reset(ehci);
1439     -
1440     ehci_reset(ehci);
1441    
1442     return 0;
1443     diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
1444     index 0fc6e5f..ba6a5d6 100644
1445     --- a/drivers/usb/misc/appledisplay.c
1446     +++ b/drivers/usb/misc/appledisplay.c
1447     @@ -63,6 +63,7 @@ static const struct usb_device_id appledisplay_table[] = {
1448     { APPLEDISPLAY_DEVICE(0x9219) },
1449     { APPLEDISPLAY_DEVICE(0x921c) },
1450     { APPLEDISPLAY_DEVICE(0x921d) },
1451     + { APPLEDISPLAY_DEVICE(0x9236) },
1452    
1453     /* Terminating entry */
1454     { }
1455     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
1456     index 9886180..be2dcb0 100644
1457     --- a/drivers/usb/serial/ftdi_sio.c
1458     +++ b/drivers/usb/serial/ftdi_sio.c
1459     @@ -189,6 +189,7 @@ static struct usb_device_id id_table_combined [] = {
1460     { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
1461     { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
1462     { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
1463     + { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_BOOST_PID) },
1464     { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) },
1465     { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
1466     { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
1467     @@ -870,7 +871,9 @@ static struct usb_device_id id_table_combined [] = {
1468     { USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) },
1469     { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID),
1470     .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
1471     - { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
1472     + { USB_DEVICE(ST_VID, ST_STMCLT_2232_PID),
1473     + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
1474     + { USB_DEVICE(ST_VID, ST_STMCLT_4232_PID),
1475     .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
1476     { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
1477     { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID),
1478     @@ -1792,20 +1795,24 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
1479     }
1480    
1481     /*
1482     - * First and second port on STMCLiteadaptors is reserved for JTAG interface
1483     - * and the forth port for pio
1484     + * First two ports on JTAG adaptors using an FT4232 such as STMicroelectronics's
1485     + * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
1486     + * can be accessed from userspace.
1487     + * The next two ports are enabled as UARTs by default, where port 2 is
1488     + * a conventional RS-232 UART.
1489     */
1490     static int ftdi_stmclite_probe(struct usb_serial *serial)
1491     {
1492     struct usb_device *udev = serial->dev;
1493     struct usb_interface *interface = serial->interface;
1494    
1495     - if (interface == udev->actconfig->interface[2])
1496     - return 0;
1497     -
1498     - dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
1499     + if (interface == udev->actconfig->interface[0] ||
1500     + interface == udev->actconfig->interface[1]) {
1501     + dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
1502     + return -ENODEV;
1503     + }
1504    
1505     - return -ENODEV;
1506     + return 0;
1507     }
1508    
1509     /*
1510     diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
1511     index e79861e..9852827 100644
1512     --- a/drivers/usb/serial/ftdi_sio_ids.h
1513     +++ b/drivers/usb/serial/ftdi_sio_ids.h
1514     @@ -74,6 +74,7 @@
1515     #define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
1516     #define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
1517     #define FTDI_OPENDCC_GBM_PID 0xBFDC
1518     +#define FTDI_OPENDCC_GBM_BOOST_PID 0xBFDD
1519    
1520     /* NZR SEM 16+ USB (http://www.nzr.de) */
1521     #define FTDI_NZR_SEM_USB_PID 0xC1E0 /* NZR SEM-LOG16+ */
1522     @@ -1150,7 +1151,8 @@
1523     * STMicroelectonics
1524     */
1525     #define ST_VID 0x0483
1526     -#define ST_STMCLT1030_PID 0x3747 /* ST Micro Connect Lite STMCLT1030 */
1527     +#define ST_STMCLT_2232_PID 0x3746
1528     +#define ST_STMCLT_4232_PID 0x3747
1529    
1530     /*
1531     * Papouch products (http://www.papouch.com/)
1532     diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
1533     index 7777172..38f2489 100644
1534     --- a/drivers/usb/serial/io_ti.c
1535     +++ b/drivers/usb/serial/io_ti.c
1536     @@ -2392,7 +2392,7 @@ static int get_serial_info(struct edgeport_port *edge_port,
1537    
1538     cwait = edge_port->port->port.closing_wait;
1539     if (cwait != ASYNC_CLOSING_WAIT_NONE)
1540     - cwait = jiffies_to_msecs(closing_wait) / 10;
1541     + cwait = jiffies_to_msecs(cwait) / 10;
1542    
1543     memset(&tmp, 0, sizeof(tmp));
1544    
1545     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1546     index 558adfc..bff059a 100644
1547     --- a/drivers/usb/serial/option.c
1548     +++ b/drivers/usb/serial/option.c
1549     @@ -347,6 +347,7 @@ static void option_instat_callback(struct urb *urb);
1550     /* Olivetti products */
1551     #define OLIVETTI_VENDOR_ID 0x0b3c
1552     #define OLIVETTI_PRODUCT_OLICARD100 0xc000
1553     +#define OLIVETTI_PRODUCT_OLICARD145 0xc003
1554    
1555     /* Celot products */
1556     #define CELOT_VENDOR_ID 0x211f
1557     @@ -1273,6 +1274,7 @@ static const struct usb_device_id option_ids[] = {
1558     { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
1559    
1560     { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
1561     + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
1562     { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
1563     { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
1564     { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
1565     @@ -1350,6 +1352,12 @@ static const struct usb_device_id option_ids[] = {
1566     { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
1567     .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1568     { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) },
1569     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */
1570     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) }, /* D-Link DWM-156 (variant) */
1571     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x02, 0x01) },
1572     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
1573     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
1574     + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
1575     { } /* Terminating entry */
1576     };
1577     MODULE_DEVICE_TABLE(usb, option_ids);
1578     diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
1579     index 070b5c0..d944088 100644
1580     --- a/drivers/usb/storage/cypress_atacb.c
1581     +++ b/drivers/usb/storage/cypress_atacb.c
1582     @@ -248,14 +248,26 @@ static int cypress_probe(struct usb_interface *intf,
1583     {
1584     struct us_data *us;
1585     int result;
1586     + struct usb_device *device;
1587    
1588     result = usb_stor_probe1(&us, intf, id,
1589     (id - cypress_usb_ids) + cypress_unusual_dev_list);
1590     if (result)
1591     return result;
1592    
1593     - us->protocol_name = "Transparent SCSI with Cypress ATACB";
1594     - us->proto_handler = cypress_atacb_passthrough;
1595     + /* Among CY7C68300 chips, the A revision does not support Cypress ATACB
1596     + * Filter out this revision from EEPROM default descriptor values
1597     + */
1598     + device = interface_to_usbdev(intf);
1599     + if (device->descriptor.iManufacturer != 0x38 ||
1600     + device->descriptor.iProduct != 0x4e ||
1601     + device->descriptor.iSerialNumber != 0x64) {
1602     + us->protocol_name = "Transparent SCSI with Cypress ATACB";
1603     + us->proto_handler = cypress_atacb_passthrough;
1604     + } else {
1605     + us->protocol_name = "Transparent SCSI";
1606     + us->proto_handler = usb_stor_transparent_scsi_command;
1607     + }
1608    
1609     result = usb_stor_probe2(us);
1610     return result;
1611     diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1612     index 3cd6759..a92783e 100644
1613     --- a/drivers/video/console/fbcon.c
1614     +++ b/drivers/video/console/fbcon.c
1615     @@ -1228,6 +1228,8 @@ static void fbcon_deinit(struct vc_data *vc)
1616     finished:
1617    
1618     fbcon_free_font(p, free_font);
1619     + if (free_font)
1620     + vc->vc_font.data = NULL;
1621    
1622     if (!con_is_bound(&fb_con))
1623     fbcon_exit();
1624     diff --git a/fs/dcache.c b/fs/dcache.c
1625     index e8bc342..e689268 100644
1626     --- a/fs/dcache.c
1627     +++ b/fs/dcache.c
1628     @@ -1230,8 +1230,10 @@ void shrink_dcache_parent(struct dentry * parent)
1629     LIST_HEAD(dispose);
1630     int found;
1631    
1632     - while ((found = select_parent(parent, &dispose)) != 0)
1633     + while ((found = select_parent(parent, &dispose)) != 0) {
1634     shrink_dentry_list(&dispose);
1635     + cond_resched();
1636     + }
1637     }
1638     EXPORT_SYMBOL(shrink_dcache_parent);
1639    
1640     diff --git a/fs/exec.c b/fs/exec.c
1641     index a96a488..6d56ff2 100644
1642     --- a/fs/exec.c
1643     +++ b/fs/exec.c
1644     @@ -613,7 +613,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
1645     * when the old and new regions overlap clear from new_end.
1646     */
1647     free_pgd_range(&tlb, new_end, old_end, new_end,
1648     - vma->vm_next ? vma->vm_next->vm_start : 0);
1649     + vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
1650     } else {
1651     /*
1652     * otherwise, clean from old_start; this is done to not touch
1653     @@ -622,7 +622,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
1654     * for the others its just a little faster.
1655     */
1656     free_pgd_range(&tlb, old_start, old_end, new_end,
1657     - vma->vm_next ? vma->vm_next->vm_start : 0);
1658     + vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
1659     }
1660     tlb_finish_mmu(&tlb, new_end, old_end);
1661    
1662     @@ -898,11 +898,13 @@ static int de_thread(struct task_struct *tsk)
1663    
1664     sig->notify_count = -1; /* for exit_notify() */
1665     for (;;) {
1666     + threadgroup_change_begin(tsk);
1667     write_lock_irq(&tasklist_lock);
1668     if (likely(leader->exit_state))
1669     break;
1670     __set_current_state(TASK_KILLABLE);
1671     write_unlock_irq(&tasklist_lock);
1672     + threadgroup_change_end(tsk);
1673     schedule();
1674     if (unlikely(__fatal_signal_pending(tsk)))
1675     goto killed;
1676     @@ -960,6 +962,7 @@ static int de_thread(struct task_struct *tsk)
1677     if (unlikely(leader->ptrace))
1678     __wake_up_parent(leader, leader->parent);
1679     write_unlock_irq(&tasklist_lock);
1680     + threadgroup_change_end(tsk);
1681    
1682     release_task(leader);
1683     }
1684     diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig
1685     index 9873587..efea5d5 100644
1686     --- a/fs/ext4/Kconfig
1687     +++ b/fs/ext4/Kconfig
1688     @@ -71,4 +71,5 @@ config EXT4_DEBUG
1689     Enables run-time debugging support for the ext4 filesystem.
1690    
1691     If you select Y here, then you will be able to turn on debugging
1692     - with a command such as "echo 1 > /sys/kernel/debug/ext4/mballoc-debug"
1693     + with a command such as:
1694     + echo 1 > /sys/module/ext4/parameters/mballoc_debug
1695     diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
1696     index 4c216b1..aeed0ba 100644
1697     --- a/fs/ext4/ext4_jbd2.h
1698     +++ b/fs/ext4/ext4_jbd2.h
1699     @@ -194,16 +194,20 @@ static inline void ext4_journal_callback_add(handle_t *handle,
1700     * ext4_journal_callback_del: delete a registered callback
1701     * @handle: active journal transaction handle on which callback was registered
1702     * @jce: registered journal callback entry to unregister
1703     + * Return true if object was sucessfully removed
1704     */
1705     -static inline void ext4_journal_callback_del(handle_t *handle,
1706     +static inline bool ext4_journal_callback_try_del(handle_t *handle,
1707     struct ext4_journal_cb_entry *jce)
1708     {
1709     + bool deleted;
1710     struct ext4_sb_info *sbi =
1711     EXT4_SB(handle->h_transaction->t_journal->j_private);
1712    
1713     spin_lock(&sbi->s_md_lock);
1714     + deleted = !list_empty(&jce->jce_list);
1715     list_del_init(&jce->jce_list);
1716     spin_unlock(&sbi->s_md_lock);
1717     + return deleted;
1718     }
1719    
1720     int
1721     diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
1722     index 3278e64..e0ba8a4 100644
1723     --- a/fs/ext4/fsync.c
1724     +++ b/fs/ext4/fsync.c
1725     @@ -166,8 +166,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1726     if (journal->j_flags & JBD2_BARRIER &&
1727     !jbd2_trans_will_send_data_barrier(journal, commit_tid))
1728     needs_barrier = true;
1729     - jbd2_log_start_commit(journal, commit_tid);
1730     - ret = jbd2_log_wait_commit(journal, commit_tid);
1731     + ret = jbd2_complete_transaction(journal, commit_tid);
1732     if (needs_barrier) {
1733     err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
1734     if (!ret)
1735     diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
1736     index b3a5213..d69e954 100644
1737     --- a/fs/ext4/inode.c
1738     +++ b/fs/ext4/inode.c
1739     @@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
1740     __u16 csum_hi = 0;
1741     __u32 csum;
1742    
1743     - csum_lo = raw->i_checksum_lo;
1744     + csum_lo = le16_to_cpu(raw->i_checksum_lo);
1745     raw->i_checksum_lo = 0;
1746     if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
1747     EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
1748     - csum_hi = raw->i_checksum_hi;
1749     + csum_hi = le16_to_cpu(raw->i_checksum_hi);
1750     raw->i_checksum_hi = 0;
1751     }
1752    
1753     csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
1754     EXT4_INODE_SIZE(inode->i_sb));
1755    
1756     - raw->i_checksum_lo = csum_lo;
1757     + raw->i_checksum_lo = cpu_to_le16(csum_lo);
1758     if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
1759     EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
1760     - raw->i_checksum_hi = csum_hi;
1761     + raw->i_checksum_hi = cpu_to_le16(csum_hi);
1762    
1763     return csum;
1764     }
1765     @@ -210,8 +210,7 @@ void ext4_evict_inode(struct inode *inode)
1766     journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
1767     tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
1768    
1769     - jbd2_log_start_commit(journal, commit_tid);
1770     - jbd2_log_wait_commit(journal, commit_tid);
1771     + jbd2_complete_transaction(journal, commit_tid);
1772     filemap_write_and_wait(&inode->i_data);
1773     }
1774     truncate_inode_pages(&inode->i_data, 0);
1775     diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
1776     index ee6614b..cf3025c 100644
1777     --- a/fs/ext4/mballoc.c
1778     +++ b/fs/ext4/mballoc.c
1779     @@ -4420,11 +4420,11 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
1780     node = rb_prev(new_node);
1781     if (node) {
1782     entry = rb_entry(node, struct ext4_free_data, efd_node);
1783     - if (can_merge(entry, new_entry)) {
1784     + if (can_merge(entry, new_entry) &&
1785     + ext4_journal_callback_try_del(handle, &entry->efd_jce)) {
1786     new_entry->efd_start_cluster = entry->efd_start_cluster;
1787     new_entry->efd_count += entry->efd_count;
1788     rb_erase(node, &(db->bb_free_root));
1789     - ext4_journal_callback_del(handle, &entry->efd_jce);
1790     kmem_cache_free(ext4_free_data_cachep, entry);
1791     }
1792     }
1793     @@ -4432,10 +4432,10 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
1794     node = rb_next(new_node);
1795     if (node) {
1796     entry = rb_entry(node, struct ext4_free_data, efd_node);
1797     - if (can_merge(new_entry, entry)) {
1798     + if (can_merge(new_entry, entry) &&
1799     + ext4_journal_callback_try_del(handle, &entry->efd_jce)) {
1800     new_entry->efd_count += entry->efd_count;
1801     rb_erase(node, &(db->bb_free_root));
1802     - ext4_journal_callback_del(handle, &entry->efd_jce);
1803     kmem_cache_free(ext4_free_data_cachep, entry);
1804     }
1805     }
1806     diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
1807     index f9b5515..b3b1f7d 100644
1808     --- a/fs/ext4/mmp.c
1809     +++ b/fs/ext4/mmp.c
1810     @@ -7,7 +7,7 @@
1811     #include "ext4.h"
1812    
1813     /* Checksumming functions */
1814     -static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
1815     +static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
1816     {
1817     struct ext4_sb_info *sbi = EXT4_SB(sb);
1818     int offset = offsetof(struct mmp_struct, mmp_checksum);
1819     diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
1820     index c169477..1357260 100644
1821     --- a/fs/ext4/resize.c
1822     +++ b/fs/ext4/resize.c
1823     @@ -1341,6 +1341,8 @@ static void ext4_update_super(struct super_block *sb,
1824    
1825     /* Update the global fs size fields */
1826     sbi->s_groups_count += flex_gd->count;
1827     + sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
1828     + (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
1829    
1830     /* Update the reserved block counts only once the new group is
1831     * active. */
1832     diff --git a/fs/ext4/super.c b/fs/ext4/super.c
1833     index 5d6d5357..febbe0e 100644
1834     --- a/fs/ext4/super.c
1835     +++ b/fs/ext4/super.c
1836     @@ -353,10 +353,13 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
1837     struct super_block *sb = journal->j_private;
1838     struct ext4_sb_info *sbi = EXT4_SB(sb);
1839     int error = is_journal_aborted(journal);
1840     - struct ext4_journal_cb_entry *jce, *tmp;
1841     + struct ext4_journal_cb_entry *jce;
1842    
1843     + BUG_ON(txn->t_state == T_FINISHED);
1844     spin_lock(&sbi->s_md_lock);
1845     - list_for_each_entry_safe(jce, tmp, &txn->t_private_list, jce_list) {
1846     + while (!list_empty(&txn->t_private_list)) {
1847     + jce = list_entry(txn->t_private_list.next,
1848     + struct ext4_journal_cb_entry, jce_list);
1849     list_del_init(&jce->jce_list);
1850     spin_unlock(&sbi->s_md_lock);
1851     jce->jce_func(sb, jce, error);
1852     @@ -3698,6 +3701,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
1853     sbi->s_err_report.function = print_daily_error_info;
1854     sbi->s_err_report.data = (unsigned long) sb;
1855    
1856     + /* Register extent status tree shrinker */
1857     + ext4_es_register_shrinker(sb);
1858     +
1859     err = percpu_counter_init(&sbi->s_freeclusters_counter,
1860     ext4_count_free_clusters(sb));
1861     if (!err) {
1862     @@ -3723,9 +3729,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
1863     sbi->s_max_writeback_mb_bump = 128;
1864     sbi->s_extent_max_zeroout_kb = 32;
1865    
1866     - /* Register extent status tree shrinker */
1867     - ext4_es_register_shrinker(sb);
1868     -
1869     /*
1870     * set up enough so that it can read an inode
1871     */
1872     @@ -4010,6 +4013,7 @@ failed_mount_wq:
1873     sbi->s_journal = NULL;
1874     }
1875     failed_mount3:
1876     + ext4_es_unregister_shrinker(sb);
1877     del_timer(&sbi->s_err_report);
1878     if (sbi->s_flex_groups)
1879     ext4_kvfree(sbi->s_flex_groups);
1880     diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
1881     index 8179e8b..40d13c7 100644
1882     --- a/fs/fscache/stats.c
1883     +++ b/fs/fscache/stats.c
1884     @@ -287,5 +287,5 @@ const struct file_operations fscache_stats_fops = {
1885     .open = fscache_stats_open,
1886     .read = seq_read,
1887     .llseek = seq_lseek,
1888     - .release = seq_release,
1889     + .release = single_release,
1890     };
1891     diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
1892     index 750c701..0f53946 100644
1893     --- a/fs/jbd2/commit.c
1894     +++ b/fs/jbd2/commit.c
1895     @@ -382,7 +382,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
1896     int space_left = 0;
1897     int first_tag = 0;
1898     int tag_flag;
1899     - int i, to_free = 0;
1900     + int i;
1901     int tag_bytes = journal_tag_bytes(journal);
1902     struct buffer_head *cbh = NULL; /* For transactional checksums */
1903     __u32 crc32_sum = ~0;
1904     @@ -1134,7 +1134,7 @@ restart_loop:
1905     journal->j_stats.run.rs_blocks_logged += stats.run.rs_blocks_logged;
1906     spin_unlock(&journal->j_history_lock);
1907    
1908     - commit_transaction->t_state = T_FINISHED;
1909     + commit_transaction->t_state = T_COMMIT_CALLBACK;
1910     J_ASSERT(commit_transaction == journal->j_committing_transaction);
1911     journal->j_commit_sequence = commit_transaction->t_tid;
1912     journal->j_committing_transaction = NULL;
1913     @@ -1149,38 +1149,44 @@ restart_loop:
1914     journal->j_average_commit_time*3) / 4;
1915     else
1916     journal->j_average_commit_time = commit_time;
1917     +
1918     write_unlock(&journal->j_state_lock);
1919    
1920     - if (commit_transaction->t_checkpoint_list == NULL &&
1921     - commit_transaction->t_checkpoint_io_list == NULL) {
1922     - __jbd2_journal_drop_transaction(journal, commit_transaction);
1923     - to_free = 1;
1924     + if (journal->j_checkpoint_transactions == NULL) {
1925     + journal->j_checkpoint_transactions = commit_transaction;
1926     + commit_transaction->t_cpnext = commit_transaction;
1927     + commit_transaction->t_cpprev = commit_transaction;
1928     } else {
1929     - if (journal->j_checkpoint_transactions == NULL) {
1930     - journal->j_checkpoint_transactions = commit_transaction;
1931     - commit_transaction->t_cpnext = commit_transaction;
1932     - commit_transaction->t_cpprev = commit_transaction;
1933     - } else {
1934     - commit_transaction->t_cpnext =
1935     - journal->j_checkpoint_transactions;
1936     - commit_transaction->t_cpprev =
1937     - commit_transaction->t_cpnext->t_cpprev;
1938     - commit_transaction->t_cpnext->t_cpprev =
1939     - commit_transaction;
1940     - commit_transaction->t_cpprev->t_cpnext =
1941     + commit_transaction->t_cpnext =
1942     + journal->j_checkpoint_transactions;
1943     + commit_transaction->t_cpprev =
1944     + commit_transaction->t_cpnext->t_cpprev;
1945     + commit_transaction->t_cpnext->t_cpprev =
1946     + commit_transaction;
1947     + commit_transaction->t_cpprev->t_cpnext =
1948     commit_transaction;
1949     - }
1950     }
1951     spin_unlock(&journal->j_list_lock);
1952     -
1953     + /* Drop all spin_locks because commit_callback may be block.
1954     + * __journal_remove_checkpoint() can not destroy transaction
1955     + * under us because it is not marked as T_FINISHED yet */
1956     if (journal->j_commit_callback)
1957     journal->j_commit_callback(journal, commit_transaction);
1958    
1959     trace_jbd2_end_commit(journal, commit_transaction);
1960     jbd_debug(1, "JBD2: commit %d complete, head %d\n",
1961     journal->j_commit_sequence, journal->j_tail_sequence);
1962     - if (to_free)
1963     - jbd2_journal_free_transaction(commit_transaction);
1964    
1965     + write_lock(&journal->j_state_lock);
1966     + spin_lock(&journal->j_list_lock);
1967     + commit_transaction->t_state = T_FINISHED;
1968     + /* Recheck checkpoint lists after j_list_lock was dropped */
1969     + if (commit_transaction->t_checkpoint_list == NULL &&
1970     + commit_transaction->t_checkpoint_io_list == NULL) {
1971     + __jbd2_journal_drop_transaction(journal, commit_transaction);
1972     + jbd2_journal_free_transaction(commit_transaction);
1973     + }
1974     + spin_unlock(&journal->j_list_lock);
1975     + write_unlock(&journal->j_state_lock);
1976     wake_up(&journal->j_wait_done_commit);
1977     }
1978     diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
1979     index ed10991..886ec2f 100644
1980     --- a/fs/jbd2/journal.c
1981     +++ b/fs/jbd2/journal.c
1982     @@ -710,6 +710,37 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
1983     }
1984    
1985     /*
1986     + * When this function returns the transaction corresponding to tid
1987     + * will be completed. If the transaction has currently running, start
1988     + * committing that transaction before waiting for it to complete. If
1989     + * the transaction id is stale, it is by definition already completed,
1990     + * so just return SUCCESS.
1991     + */
1992     +int jbd2_complete_transaction(journal_t *journal, tid_t tid)
1993     +{
1994     + int need_to_wait = 1;
1995     +
1996     + read_lock(&journal->j_state_lock);
1997     + if (journal->j_running_transaction &&
1998     + journal->j_running_transaction->t_tid == tid) {
1999     + if (journal->j_commit_request != tid) {
2000     + /* transaction not yet started, so request it */
2001     + read_unlock(&journal->j_state_lock);
2002     + jbd2_log_start_commit(journal, tid);
2003     + goto wait_commit;
2004     + }
2005     + } else if (!(journal->j_committing_transaction &&
2006     + journal->j_committing_transaction->t_tid == tid))
2007     + need_to_wait = 0;
2008     + read_unlock(&journal->j_state_lock);
2009     + if (!need_to_wait)
2010     + return 0;
2011     +wait_commit:
2012     + return jbd2_log_wait_commit(journal, tid);
2013     +}
2014     +EXPORT_SYMBOL(jbd2_complete_transaction);
2015     +
2016     +/*
2017     * Log buffer allocation routines:
2018     */
2019    
2020     diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
2021     index 0796c45..01bfe76 100644
2022     --- a/fs/lockd/clntlock.c
2023     +++ b/fs/lockd/clntlock.c
2024     @@ -144,6 +144,9 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
2025     timeout);
2026     if (ret < 0)
2027     return -ERESTARTSYS;
2028     + /* Reset the lock status after a server reboot so we resend */
2029     + if (block->b_status == nlm_lck_denied_grace_period)
2030     + block->b_status = nlm_lck_blocked;
2031     req->a_res.status = block->b_status;
2032     return 0;
2033     }
2034     diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
2035     index 7e529c3..9760ecb 100644
2036     --- a/fs/lockd/clntproc.c
2037     +++ b/fs/lockd/clntproc.c
2038     @@ -550,9 +550,6 @@ again:
2039     status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT);
2040     if (status < 0)
2041     break;
2042     - /* Resend the blocking lock request after a server reboot */
2043     - if (resp->status == nlm_lck_denied_grace_period)
2044     - continue;
2045     if (resp->status != nlm_lck_blocked)
2046     break;
2047     }
2048     diff --git a/fs/namespace.c b/fs/namespace.c
2049     index 341d3f5..e945b81 100644
2050     --- a/fs/namespace.c
2051     +++ b/fs/namespace.c
2052     @@ -2238,12 +2238,11 @@ long do_mount(const char *dev_name, const char *dir_name,
2053    
2054     retval = security_sb_mount(dev_name, &path,
2055     type_page, flags, data_page);
2056     + if (!retval && !may_mount())
2057     + retval = -EPERM;
2058     if (retval)
2059     goto dput_out;
2060    
2061     - if (!may_mount())
2062     - return -EPERM;
2063     -
2064     /* Default to relatime unless overriden */
2065     if (!(flags & MS_NOATIME))
2066     mnt_flags |= MNT_RELATIME;
2067     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2068     index 0ad025e..c7856a1 100644
2069     --- a/fs/nfs/nfs4proc.c
2070     +++ b/fs/nfs/nfs4proc.c
2071     @@ -1380,6 +1380,12 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
2072     case -ENOMEM:
2073     err = 0;
2074     goto out;
2075     + case -NFS4ERR_DELAY:
2076     + case -NFS4ERR_GRACE:
2077     + set_bit(NFS_DELEGATED_STATE, &state->flags);
2078     + ssleep(1);
2079     + err = -EAGAIN;
2080     + goto out;
2081     }
2082     set_bit(NFS_DELEGATED_STATE, &state->flags);
2083     err = nfs4_handle_exception(server, err, &exception);
2084     @@ -5025,6 +5031,12 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
2085     nfs4_schedule_stateid_recovery(server, state);
2086     err = 0;
2087     goto out;
2088     + case -NFS4ERR_DELAY:
2089     + case -NFS4ERR_GRACE:
2090     + set_bit(NFS_DELEGATED_STATE, &state->flags);
2091     + ssleep(1);
2092     + err = -EAGAIN;
2093     + goto out;
2094     case -ENOMEM:
2095     case -NFS4ERR_DENIED:
2096     /* kill_proc(fl->fl_pid, SIGLOST, 1); */
2097     diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
2098     index ae73175..8288b08 100644
2099     --- a/fs/nfsd/nfs4proc.c
2100     +++ b/fs/nfsd/nfs4proc.c
2101     @@ -931,14 +931,14 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2102     nfs4_lock_state();
2103     status = nfs4_preprocess_stateid_op(SVC_NET(rqstp),
2104     cstate, stateid, WR_STATE, &filp);
2105     - if (filp)
2106     - get_file(filp);
2107     - nfs4_unlock_state();
2108     -
2109     if (status) {
2110     + nfs4_unlock_state();
2111     dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
2112     return status;
2113     }
2114     + if (filp)
2115     + get_file(filp);
2116     + nfs4_unlock_state();
2117    
2118     cnt = write->wr_buflen;
2119     write->wr_how_written = write->wr_stable_how;
2120     diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
2121     index 2e27430..f9a5e62 100644
2122     --- a/fs/nfsd/nfs4state.c
2123     +++ b/fs/nfsd/nfs4state.c
2124     @@ -210,13 +210,7 @@ static void __nfs4_file_put_access(struct nfs4_file *fp, int oflag)
2125     {
2126     if (atomic_dec_and_test(&fp->fi_access[oflag])) {
2127     nfs4_file_put_fd(fp, oflag);
2128     - /*
2129     - * It's also safe to get rid of the RDWR open *if*
2130     - * we no longer have need of the other kind of access
2131     - * or if we already have the other kind of open:
2132     - */
2133     - if (fp->fi_fds[1-oflag]
2134     - || atomic_read(&fp->fi_access[1 - oflag]) == 0)
2135     + if (atomic_read(&fp->fi_access[1 - oflag]) == 0)
2136     nfs4_file_put_fd(fp, O_RDWR);
2137     }
2138     }
2139     @@ -267,7 +261,7 @@ kmem_cache *slab)
2140     min_stateid = 0;
2141     return stid;
2142     out_free:
2143     - kfree(stid);
2144     + kmem_cache_free(slab, stid);
2145     return NULL;
2146     }
2147    
2148     diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
2149     index a272007..6eb0dc5 100644
2150     --- a/fs/nfsd/nfs4xdr.c
2151     +++ b/fs/nfsd/nfs4xdr.c
2152     @@ -344,10 +344,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
2153     all 32 bits of 'nseconds'. */
2154     READ_BUF(12);
2155     len += 12;
2156     - READ32(dummy32);
2157     - if (dummy32)
2158     - return nfserr_inval;
2159     - READ32(iattr->ia_atime.tv_sec);
2160     + READ64(iattr->ia_atime.tv_sec);
2161     READ32(iattr->ia_atime.tv_nsec);
2162     if (iattr->ia_atime.tv_nsec >= (u32)1000000000)
2163     return nfserr_inval;
2164     @@ -370,10 +367,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
2165     all 32 bits of 'nseconds'. */
2166     READ_BUF(12);
2167     len += 12;
2168     - READ32(dummy32);
2169     - if (dummy32)
2170     - return nfserr_inval;
2171     - READ32(iattr->ia_mtime.tv_sec);
2172     + READ64(iattr->ia_mtime.tv_sec);
2173     READ32(iattr->ia_mtime.tv_nsec);
2174     if (iattr->ia_mtime.tv_nsec >= (u32)1000000000)
2175     return nfserr_inval;
2176     @@ -2401,8 +2395,7 @@ out_acl:
2177     if (bmval1 & FATTR4_WORD1_TIME_ACCESS) {
2178     if ((buflen -= 12) < 0)
2179     goto out_resource;
2180     - WRITE32(0);
2181     - WRITE32(stat.atime.tv_sec);
2182     + WRITE64((s64)stat.atime.tv_sec);
2183     WRITE32(stat.atime.tv_nsec);
2184     }
2185     if (bmval1 & FATTR4_WORD1_TIME_DELTA) {
2186     @@ -2415,15 +2408,13 @@ out_acl:
2187     if (bmval1 & FATTR4_WORD1_TIME_METADATA) {
2188     if ((buflen -= 12) < 0)
2189     goto out_resource;
2190     - WRITE32(0);
2191     - WRITE32(stat.ctime.tv_sec);
2192     + WRITE64((s64)stat.ctime.tv_sec);
2193     WRITE32(stat.ctime.tv_nsec);
2194     }
2195     if (bmval1 & FATTR4_WORD1_TIME_MODIFY) {
2196     if ((buflen -= 12) < 0)
2197     goto out_resource;
2198     - WRITE32(0);
2199     - WRITE32(stat.mtime.tv_sec);
2200     + WRITE64((s64)stat.mtime.tv_sec);
2201     WRITE32(stat.mtime.tv_nsec);
2202     }
2203     if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
2204     diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
2205     index e0f7c12..5fe21d6 100644
2206     --- a/fs/notify/inotify/inotify_user.c
2207     +++ b/fs/notify/inotify/inotify_user.c
2208     @@ -572,7 +572,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
2209     int add = (arg & IN_MASK_ADD);
2210     int ret;
2211    
2212     - /* don't allow invalid bits: we don't want flags set */
2213     mask = inotify_arg_to_mask(arg);
2214    
2215     fsn_mark = fsnotify_find_inode_mark(group, inode);
2216     @@ -623,7 +622,6 @@ static int inotify_new_watch(struct fsnotify_group *group,
2217     struct idr *idr = &group->inotify_data.idr;
2218     spinlock_t *idr_lock = &group->inotify_data.idr_lock;
2219    
2220     - /* don't allow invalid bits: we don't want flags set */
2221     mask = inotify_arg_to_mask(arg);
2222    
2223     tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
2224     @@ -751,6 +749,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
2225     int ret;
2226     unsigned flags = 0;
2227    
2228     + /* don't allow invalid bits: we don't want flags set */
2229     + if (unlikely(!(mask & ALL_INOTIFY_BITS)))
2230     + return -EINVAL;
2231     +
2232     f = fdget(fd);
2233     if (unlikely(!f.file))
2234     return -EBADF;
2235     diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
2236     index e145126..6f31590 100644
2237     --- a/fs/sysfs/dir.c
2238     +++ b/fs/sysfs/dir.c
2239     @@ -1012,6 +1012,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2240     enum kobj_ns_type type;
2241     const void *ns;
2242     ino_t ino;
2243     + loff_t off;
2244    
2245     type = sysfs_ns_type(parent_sd);
2246     ns = sysfs_info(dentry->d_sb)->ns[type];
2247     @@ -1034,6 +1035,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2248     return 0;
2249     }
2250     mutex_lock(&sysfs_mutex);
2251     + off = filp->f_pos;
2252     for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos);
2253     pos;
2254     pos = sysfs_dir_next_pos(ns, parent_sd, filp->f_pos, pos)) {
2255     @@ -1045,19 +1047,24 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2256     len = strlen(name);
2257     ino = pos->s_ino;
2258     type = dt_type(pos);
2259     - filp->f_pos = pos->s_hash;
2260     + off = filp->f_pos = pos->s_hash;
2261     filp->private_data = sysfs_get(pos);
2262    
2263     mutex_unlock(&sysfs_mutex);
2264     - ret = filldir(dirent, name, len, filp->f_pos, ino, type);
2265     + ret = filldir(dirent, name, len, off, ino, type);
2266     mutex_lock(&sysfs_mutex);
2267     if (ret < 0)
2268     break;
2269     }
2270     mutex_unlock(&sysfs_mutex);
2271     - if ((filp->f_pos > 1) && !pos) { /* EOF */
2272     - filp->f_pos = INT_MAX;
2273     +
2274     + /* don't reference last entry if its refcount is dropped */
2275     + if (!pos) {
2276     filp->private_data = NULL;
2277     +
2278     + /* EOF and not changed as 0 or 1 in read/write path */
2279     + if (off == filp->f_pos && off > 1)
2280     + filp->f_pos = INT_MAX;
2281     }
2282     return 0;
2283     }
2284     diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
2285     index bfd8768..a59ff51 100644
2286     --- a/include/asm-generic/pgtable.h
2287     +++ b/include/asm-generic/pgtable.h
2288     @@ -7,6 +7,16 @@
2289     #include <linux/mm_types.h>
2290     #include <linux/bug.h>
2291    
2292     +/*
2293     + * On almost all architectures and configurations, 0 can be used as the
2294     + * upper ceiling to free_pgtables(): on many architectures it has the same
2295     + * effect as using TASK_SIZE. However, there is one configuration which
2296     + * must impose a more careful limit, to avoid freeing kernel pgtables.
2297     + */
2298     +#ifndef USER_PGTABLES_CEILING
2299     +#define USER_PGTABLES_CEILING 0UL
2300     +#endif
2301     +
2302     #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
2303     extern int ptep_set_access_flags(struct vm_area_struct *vma,
2304     unsigned long address, pte_t *ptep,
2305     diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
2306     index 900af59..16d4d09 100644
2307     --- a/include/linux/cgroup.h
2308     +++ b/include/linux/cgroup.h
2309     @@ -304,9 +304,6 @@ struct cftype {
2310     /* CFTYPE_* flags */
2311     unsigned int flags;
2312    
2313     - /* file xattrs */
2314     - struct simple_xattrs xattrs;
2315     -
2316     int (*open)(struct inode *inode, struct file *file);
2317     ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
2318     struct file *file,
2319     diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
2320     index ae221a7..c4d870b 100644
2321     --- a/include/linux/ipc_namespace.h
2322     +++ b/include/linux/ipc_namespace.h
2323     @@ -43,8 +43,8 @@ struct ipc_namespace {
2324    
2325     size_t shm_ctlmax;
2326     size_t shm_ctlall;
2327     + unsigned long shm_tot;
2328     int shm_ctlmni;
2329     - int shm_tot;
2330     /*
2331     * Defines whether IPC_RMID is forced for _all_ shm segments regardless
2332     * of shmctl()
2333     diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
2334     index 50e5a5e..f9fe889 100644
2335     --- a/include/linux/jbd2.h
2336     +++ b/include/linux/jbd2.h
2337     @@ -480,6 +480,7 @@ struct transaction_s
2338     T_COMMIT,
2339     T_COMMIT_DFLUSH,
2340     T_COMMIT_JFLUSH,
2341     + T_COMMIT_CALLBACK,
2342     T_FINISHED
2343     } t_state;
2344    
2345     @@ -1200,6 +1201,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
2346     int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
2347     int jbd2_journal_force_commit_nested(journal_t *journal);
2348     int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
2349     +int jbd2_complete_transaction(journal_t *journal, tid_t tid);
2350     int jbd2_log_do_checkpoint(journal_t *journal);
2351     int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid);
2352    
2353     diff --git a/include/linux/sched.h b/include/linux/sched.h
2354     index e692a02..be4e742 100644
2355     --- a/include/linux/sched.h
2356     +++ b/include/linux/sched.h
2357     @@ -2413,27 +2413,18 @@ static inline void threadgroup_change_end(struct task_struct *tsk)
2358     *
2359     * Lock the threadgroup @tsk belongs to. No new task is allowed to enter
2360     * and member tasks aren't allowed to exit (as indicated by PF_EXITING) or
2361     - * perform exec. This is useful for cases where the threadgroup needs to
2362     - * stay stable across blockable operations.
2363     + * change ->group_leader/pid. This is useful for cases where the threadgroup
2364     + * needs to stay stable across blockable operations.
2365     *
2366     * fork and exit paths explicitly call threadgroup_change_{begin|end}() for
2367     * synchronization. While held, no new task will be added to threadgroup
2368     * and no existing live task will have its PF_EXITING set.
2369     *
2370     - * During exec, a task goes and puts its thread group through unusual
2371     - * changes. After de-threading, exclusive access is assumed to resources
2372     - * which are usually shared by tasks in the same group - e.g. sighand may
2373     - * be replaced with a new one. Also, the exec'ing task takes over group
2374     - * leader role including its pid. Exclude these changes while locked by
2375     - * grabbing cred_guard_mutex which is used to synchronize exec path.
2376     + * de_thread() does threadgroup_change_{begin|end}() when a non-leader
2377     + * sub-thread becomes a new leader.
2378     */
2379     static inline void threadgroup_lock(struct task_struct *tsk)
2380     {
2381     - /*
2382     - * exec uses exit for de-threading nesting group_rwsem inside
2383     - * cred_guard_mutex. Grab cred_guard_mutex first.
2384     - */
2385     - mutex_lock(&tsk->signal->cred_guard_mutex);
2386     down_write(&tsk->signal->group_rwsem);
2387     }
2388    
2389     @@ -2446,7 +2437,6 @@ static inline void threadgroup_lock(struct task_struct *tsk)
2390     static inline void threadgroup_unlock(struct task_struct *tsk)
2391     {
2392     up_write(&tsk->signal->group_rwsem);
2393     - mutex_unlock(&tsk->signal->cred_guard_mutex);
2394     }
2395     #else
2396     static inline void threadgroup_change_begin(struct task_struct *tsk) {}
2397     diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
2398     index f841ba4..dfb42ca 100644
2399     --- a/include/sound/emu10k1.h
2400     +++ b/include/sound/emu10k1.h
2401     @@ -1787,6 +1787,7 @@ struct snd_emu10k1 {
2402     unsigned int next_free_voice;
2403    
2404     const struct firmware *firmware;
2405     + const struct firmware *dock_fw;
2406    
2407     #ifdef CONFIG_PM_SLEEP
2408     unsigned int *saved_ptr;
2409     diff --git a/ipc/shm.c b/ipc/shm.c
2410     index cb858df..8247c49 100644
2411     --- a/ipc/shm.c
2412     +++ b/ipc/shm.c
2413     @@ -462,7 +462,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
2414     size_t size = params->u.size;
2415     int error;
2416     struct shmid_kernel *shp;
2417     - int numpages = (size + PAGE_SIZE -1) >> PAGE_SHIFT;
2418     + size_t numpages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
2419     struct file * file;
2420     char name[13];
2421     int id;
2422     diff --git a/kernel/cgroup.c b/kernel/cgroup.c
2423     index a32f943..ba1f977 100644
2424     --- a/kernel/cgroup.c
2425     +++ b/kernel/cgroup.c
2426     @@ -162,6 +162,9 @@ struct cfent {
2427     struct list_head node;
2428     struct dentry *dentry;
2429     struct cftype *type;
2430     +
2431     + /* file xattrs */
2432     + struct simple_xattrs xattrs;
2433     };
2434    
2435     /*
2436     @@ -910,13 +913,12 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
2437     } else {
2438     struct cfent *cfe = __d_cfe(dentry);
2439     struct cgroup *cgrp = dentry->d_parent->d_fsdata;
2440     - struct cftype *cft = cfe->type;
2441    
2442     WARN_ONCE(!list_empty(&cfe->node) &&
2443     cgrp != &cgrp->root->top_cgroup,
2444     "cfe still linked for %s\n", cfe->type->name);
2445     + simple_xattrs_free(&cfe->xattrs);
2446     kfree(cfe);
2447     - simple_xattrs_free(&cft->xattrs);
2448     }
2449     iput(inode);
2450     }
2451     @@ -2065,7 +2067,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
2452     if (!group)
2453     return -ENOMEM;
2454     /* pre-allocate to guarantee space while iterating in rcu read-side. */
2455     - retval = flex_array_prealloc(group, 0, group_size - 1, GFP_KERNEL);
2456     + retval = flex_array_prealloc(group, 0, group_size, GFP_KERNEL);
2457     if (retval)
2458     goto out_free_group_list;
2459    
2460     @@ -2551,7 +2553,7 @@ static struct simple_xattrs *__d_xattrs(struct dentry *dentry)
2461     if (S_ISDIR(dentry->d_inode->i_mode))
2462     return &__d_cgrp(dentry)->xattrs;
2463     else
2464     - return &__d_cft(dentry)->xattrs;
2465     + return &__d_cfe(dentry)->xattrs;
2466     }
2467    
2468     static inline int xattr_enabled(struct dentry *dentry)
2469     @@ -2727,8 +2729,6 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
2470     umode_t mode;
2471     char name[MAX_CGROUP_TYPE_NAMELEN + MAX_CFTYPE_NAME + 2] = { 0 };
2472    
2473     - simple_xattrs_init(&cft->xattrs);
2474     -
2475     if (subsys && !test_bit(ROOT_NOPREFIX, &cgrp->root->flags)) {
2476     strcpy(name, subsys->name);
2477     strcat(name, ".");
2478     @@ -2753,6 +2753,7 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
2479     cfe->type = (void *)cft;
2480     cfe->dentry = dentry;
2481     dentry->d_fsdata = cfe;
2482     + simple_xattrs_init(&cfe->xattrs);
2483     list_add_tail(&cfe->node, &parent->files);
2484     cfe = NULL;
2485     }
2486     diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
2487     index 14be27f..7ef5556 100644
2488     --- a/kernel/hrtimer.c
2489     +++ b/kernel/hrtimer.c
2490     @@ -276,6 +276,10 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
2491     } else {
2492     unsigned long rem = do_div(nsec, NSEC_PER_SEC);
2493    
2494     + /* Make sure nsec fits into long */
2495     + if (unlikely(nsec > KTIME_SEC_MAX))
2496     + return (ktime_t){ .tv64 = KTIME_MAX };
2497     +
2498     tmp = ktime_set((long)nsec, rem);
2499     }
2500    
2501     @@ -1310,6 +1314,8 @@ retry:
2502    
2503     expires = ktime_sub(hrtimer_get_expires(timer),
2504     base->offset);
2505     + if (expires.tv64 < 0)
2506     + expires.tv64 = KTIME_MAX;
2507     if (expires.tv64 < expires_next.tv64)
2508     expires_next = expires;
2509     break;
2510     diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
2511     index 0d095dc..93f8e8f 100644
2512     --- a/kernel/rcutree_trace.c
2513     +++ b/kernel/rcutree_trace.c
2514     @@ -97,7 +97,7 @@ static const struct file_operations rcubarrier_fops = {
2515     .open = rcubarrier_open,
2516     .read = seq_read,
2517     .llseek = no_llseek,
2518     - .release = seq_release,
2519     + .release = single_release,
2520     };
2521    
2522     #ifdef CONFIG_RCU_BOOST
2523     @@ -208,7 +208,7 @@ static const struct file_operations rcuexp_fops = {
2524     .open = rcuexp_open,
2525     .read = seq_read,
2526     .llseek = no_llseek,
2527     - .release = seq_release,
2528     + .release = single_release,
2529     };
2530    
2531     #ifdef CONFIG_RCU_BOOST
2532     @@ -308,7 +308,7 @@ static const struct file_operations rcuhier_fops = {
2533     .open = rcuhier_open,
2534     .read = seq_read,
2535     .llseek = no_llseek,
2536     - .release = seq_release,
2537     + .release = single_release,
2538     };
2539    
2540     static void show_one_rcugp(struct seq_file *m, struct rcu_state *rsp)
2541     @@ -350,7 +350,7 @@ static const struct file_operations rcugp_fops = {
2542     .open = rcugp_open,
2543     .read = seq_read,
2544     .llseek = no_llseek,
2545     - .release = seq_release,
2546     + .release = single_release,
2547     };
2548    
2549     static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
2550     diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
2551     index 7f32fe0..90ad470 100644
2552     --- a/kernel/time/tick-broadcast.c
2553     +++ b/kernel/time/tick-broadcast.c
2554     @@ -67,6 +67,8 @@ static void tick_broadcast_start_periodic(struct clock_event_device *bc)
2555     */
2556     int tick_check_broadcast_device(struct clock_event_device *dev)
2557     {
2558     + struct clock_event_device *cur = tick_broadcast_device.evtdev;
2559     +
2560     if ((dev->features & CLOCK_EVT_FEAT_DUMMY) ||
2561     (tick_broadcast_device.evtdev &&
2562     tick_broadcast_device.evtdev->rating >= dev->rating) ||
2563     @@ -74,6 +76,8 @@ int tick_check_broadcast_device(struct clock_event_device *dev)
2564     return 0;
2565    
2566     clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
2567     + if (cur)
2568     + cur->event_handler = clockevents_handle_noop;
2569     tick_broadcast_device.evtdev = dev;
2570     if (!cpumask_empty(tick_get_broadcast_mask()))
2571     tick_broadcast_start_periodic(dev);
2572     diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
2573     index b1600a6..7076b3f 100644
2574     --- a/kernel/time/tick-common.c
2575     +++ b/kernel/time/tick-common.c
2576     @@ -323,6 +323,7 @@ static void tick_shutdown(unsigned int *cpup)
2577     */
2578     dev->mode = CLOCK_EVT_MODE_UNUSED;
2579     clockevents_exchange_device(dev, NULL);
2580     + dev->event_handler = clockevents_handle_noop;
2581     td->evtdev = NULL;
2582     }
2583     raw_spin_unlock_irqrestore(&tick_device_lock, flags);
2584     diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
2585     index b3fde6d..0a0e2a6 100644
2586     --- a/kernel/trace/ftrace.c
2587     +++ b/kernel/trace/ftrace.c
2588     @@ -676,7 +676,7 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
2589    
2590     pages = DIV_ROUND_UP(functions, PROFILES_PER_PAGE);
2591    
2592     - for (i = 0; i < pages; i++) {
2593     + for (i = 1; i < pages; i++) {
2594     pg->next = (void *)get_zeroed_page(GFP_KERNEL);
2595     if (!pg->next)
2596     goto out_free;
2597     @@ -3736,7 +3736,8 @@ out:
2598     if (fail)
2599     return -EINVAL;
2600    
2601     - ftrace_graph_filter_enabled = 1;
2602     + ftrace_graph_filter_enabled = !!(*idx);
2603     +
2604     return 0;
2605     }
2606    
2607     diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
2608     index 66338c4..7713d1b 100644
2609     --- a/kernel/trace/trace.c
2610     +++ b/kernel/trace/trace.c
2611     @@ -5028,6 +5028,8 @@ static __init int tracer_init_debugfs(void)
2612     trace_access_lock_init();
2613    
2614     d_tracer = tracing_init_dentry();
2615     + if (!d_tracer)
2616     + return 0;
2617    
2618     trace_create_file("trace_options", 0644, d_tracer,
2619     NULL, &tracing_iter_fops);
2620     diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
2621     index 83a8b5b..b20428c 100644
2622     --- a/kernel/trace/trace_stack.c
2623     +++ b/kernel/trace/trace_stack.c
2624     @@ -20,13 +20,24 @@
2625    
2626     #define STACK_TRACE_ENTRIES 500
2627    
2628     +#ifdef CC_USING_FENTRY
2629     +# define fentry 1
2630     +#else
2631     +# define fentry 0
2632     +#endif
2633     +
2634     static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES+1] =
2635     { [0 ... (STACK_TRACE_ENTRIES)] = ULONG_MAX };
2636     static unsigned stack_dump_index[STACK_TRACE_ENTRIES];
2637    
2638     +/*
2639     + * Reserve one entry for the passed in ip. This will allow
2640     + * us to remove most or all of the stack size overhead
2641     + * added by the stack tracer itself.
2642     + */
2643     static struct stack_trace max_stack_trace = {
2644     - .max_entries = STACK_TRACE_ENTRIES,
2645     - .entries = stack_dump_trace,
2646     + .max_entries = STACK_TRACE_ENTRIES - 1,
2647     + .entries = &stack_dump_trace[1],
2648     };
2649    
2650     static unsigned long max_stack_size;
2651     @@ -39,25 +50,34 @@ static DEFINE_MUTEX(stack_sysctl_mutex);
2652     int stack_tracer_enabled;
2653     static int last_stack_tracer_enabled;
2654    
2655     -static inline void check_stack(void)
2656     +static inline void
2657     +check_stack(unsigned long ip, unsigned long *stack)
2658     {
2659     unsigned long this_size, flags;
2660     unsigned long *p, *top, *start;
2661     + static int tracer_frame;
2662     + int frame_size = ACCESS_ONCE(tracer_frame);
2663     int i;
2664    
2665     - this_size = ((unsigned long)&this_size) & (THREAD_SIZE-1);
2666     + this_size = ((unsigned long)stack) & (THREAD_SIZE-1);
2667     this_size = THREAD_SIZE - this_size;
2668     + /* Remove the frame of the tracer */
2669     + this_size -= frame_size;
2670    
2671     if (this_size <= max_stack_size)
2672     return;
2673    
2674     /* we do not handle interrupt stacks yet */
2675     - if (!object_is_on_stack(&this_size))
2676     + if (!object_is_on_stack(stack))
2677     return;
2678    
2679     local_irq_save(flags);
2680     arch_spin_lock(&max_stack_lock);
2681    
2682     + /* In case another CPU set the tracer_frame on us */
2683     + if (unlikely(!frame_size))
2684     + this_size -= tracer_frame;
2685     +
2686     /* a race could have already updated it */
2687     if (this_size <= max_stack_size)
2688     goto out;
2689     @@ -70,10 +90,18 @@ static inline void check_stack(void)
2690     save_stack_trace(&max_stack_trace);
2691    
2692     /*
2693     + * Add the passed in ip from the function tracer.
2694     + * Searching for this on the stack will skip over
2695     + * most of the overhead from the stack tracer itself.
2696     + */
2697     + stack_dump_trace[0] = ip;
2698     + max_stack_trace.nr_entries++;
2699     +
2700     + /*
2701     * Now find where in the stack these are.
2702     */
2703     i = 0;
2704     - start = &this_size;
2705     + start = stack;
2706     top = (unsigned long *)
2707     (((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
2708    
2709     @@ -97,6 +125,18 @@ static inline void check_stack(void)
2710     found = 1;
2711     /* Start the search from here */
2712     start = p + 1;
2713     + /*
2714     + * We do not want to show the overhead
2715     + * of the stack tracer stack in the
2716     + * max stack. If we haven't figured
2717     + * out what that is, then figure it out
2718     + * now.
2719     + */
2720     + if (unlikely(!tracer_frame) && i == 1) {
2721     + tracer_frame = (p - stack) *
2722     + sizeof(unsigned long);
2723     + max_stack_size -= tracer_frame;
2724     + }
2725     }
2726     }
2727    
2728     @@ -113,6 +153,7 @@ static void
2729     stack_trace_call(unsigned long ip, unsigned long parent_ip,
2730     struct ftrace_ops *op, struct pt_regs *pt_regs)
2731     {
2732     + unsigned long stack;
2733     int cpu;
2734    
2735     preempt_disable_notrace();
2736     @@ -122,7 +163,26 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip,
2737     if (per_cpu(trace_active, cpu)++ != 0)
2738     goto out;
2739    
2740     - check_stack();
2741     + /*
2742     + * When fentry is used, the traced function does not get
2743     + * its stack frame set up, and we lose the parent.
2744     + * The ip is pretty useless because the function tracer
2745     + * was called before that function set up its stack frame.
2746     + * In this case, we use the parent ip.
2747     + *
2748     + * By adding the return address of either the parent ip
2749     + * or the current ip we can disregard most of the stack usage
2750     + * caused by the stack tracer itself.
2751     + *
2752     + * The function tracer always reports the address of where the
2753     + * mcount call was, but the stack will hold the return address.
2754     + */
2755     + if (fentry)
2756     + ip = parent_ip;
2757     + else
2758     + ip += MCOUNT_INSN_SIZE;
2759     +
2760     + check_stack(ip, &stack);
2761    
2762     out:
2763     per_cpu(trace_active, cpu)--;
2764     @@ -371,6 +431,8 @@ static __init int stack_trace_init(void)
2765     struct dentry *d_tracer;
2766    
2767     d_tracer = tracing_init_dentry();
2768     + if (!d_tracer)
2769     + return 0;
2770    
2771     trace_create_file("stack_max_size", 0644, d_tracer,
2772     &max_stack_size, &stack_max_size_fops);
2773     diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
2774     index 96cffb2..847f88a 100644
2775     --- a/kernel/trace/trace_stat.c
2776     +++ b/kernel/trace/trace_stat.c
2777     @@ -307,6 +307,8 @@ static int tracing_stat_init(void)
2778     struct dentry *d_tracing;
2779    
2780     d_tracing = tracing_init_dentry();
2781     + if (!d_tracing)
2782     + return 0;
2783    
2784     stat_dir = debugfs_create_dir("trace_stat", d_tracing);
2785     if (!stat_dir)
2786     diff --git a/lib/oid_registry.c b/lib/oid_registry.c
2787     index d8de11f..318f382 100644
2788     --- a/lib/oid_registry.c
2789     +++ b/lib/oid_registry.c
2790     @@ -9,6 +9,7 @@
2791     * 2 of the Licence, or (at your option) any later version.
2792     */
2793    
2794     +#include <linux/module.h>
2795     #include <linux/export.h>
2796     #include <linux/oid_registry.h>
2797     #include <linux/kernel.h>
2798     @@ -16,6 +17,10 @@
2799     #include <linux/bug.h>
2800     #include "oid_registry_data.c"
2801    
2802     +MODULE_DESCRIPTION("OID Registry");
2803     +MODULE_AUTHOR("Red Hat, Inc.");
2804     +MODULE_LICENSE("GPL");
2805     +
2806     /**
2807     * look_up_OID - Find an OID registration for the specified data
2808     * @data: Binary representation of the OID
2809     diff --git a/mm/mmap.c b/mm/mmap.c
2810     index 0db0de1..033094b 100644
2811     --- a/mm/mmap.c
2812     +++ b/mm/mmap.c
2813     @@ -2305,7 +2305,7 @@ static void unmap_region(struct mm_struct *mm,
2814     update_hiwater_rss(mm);
2815     unmap_vmas(&tlb, vma, start, end);
2816     free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
2817     - next ? next->vm_start : 0);
2818     + next ? next->vm_start : USER_PGTABLES_CEILING);
2819     tlb_finish_mmu(&tlb, start, end);
2820     }
2821    
2822     @@ -2685,7 +2685,7 @@ void exit_mmap(struct mm_struct *mm)
2823     /* Use -1 here to ensure all VMAs in the mm are unmapped */
2824     unmap_vmas(&tlb, vma, 0, -1);
2825    
2826     - free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
2827     + free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING);
2828     tlb_finish_mmu(&tlb, 0, -1);
2829    
2830     /*
2831     diff --git a/mm/page_io.c b/mm/page_io.c
2832     index 78eee32..6182870 100644
2833     --- a/mm/page_io.c
2834     +++ b/mm/page_io.c
2835     @@ -214,6 +214,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
2836     kiocb.ki_left = PAGE_SIZE;
2837     kiocb.ki_nbytes = PAGE_SIZE;
2838    
2839     + set_page_writeback(page);
2840     unlock_page(page);
2841     ret = mapping->a_ops->direct_IO(KERNEL_WRITE,
2842     &kiocb, &iov,
2843     @@ -222,7 +223,23 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
2844     if (ret == PAGE_SIZE) {
2845     count_vm_event(PSWPOUT);
2846     ret = 0;
2847     + } else {
2848     + /*
2849     + * In the case of swap-over-nfs, this can be a
2850     + * temporary failure if the system has limited
2851     + * memory for allocating transmit buffers.
2852     + * Mark the page dirty and avoid
2853     + * rotate_reclaimable_page but rate-limit the
2854     + * messages but do not flag PageError like
2855     + * the normal direct-to-bio case as it could
2856     + * be temporary.
2857     + */
2858     + set_page_dirty(page);
2859     + ClearPageReclaim(page);
2860     + pr_err_ratelimited("Write error on dio swapfile (%Lu)\n",
2861     + page_file_offset(page));
2862     }
2863     + end_page_writeback(page);
2864     return ret;
2865     }
2866    
2867     diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
2868     index a689360..843d8c4 100644
2869     --- a/net/mac80211/cfg.c
2870     +++ b/net/mac80211/cfg.c
2871     @@ -1034,6 +1034,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
2872     list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
2873     sta_info_flush_defer(vlan);
2874     sta_info_flush_defer(sdata);
2875     + synchronize_net();
2876     rcu_barrier();
2877     list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
2878     sta_info_flush_cleanup(vlan);
2879     diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
2880     index 9ed49ad..d51ca9d 100644
2881     --- a/net/mac80211/iface.c
2882     +++ b/net/mac80211/iface.c
2883     @@ -844,11 +844,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
2884     *
2885     * sta_info_flush_cleanup() requires rcu_barrier()
2886     * first to wait for the station call_rcu() calls
2887     - * to complete, here we need at least sychronize_rcu()
2888     - * it to wait for the RX path in case it is using the
2889     + * to complete, and we also need synchronize_rcu()
2890     + * to wait for the RX path in case it is using the
2891     * interface and enqueuing frames at this very time on
2892     * another CPU.
2893     */
2894     + synchronize_rcu();
2895     rcu_barrier();
2896     sta_info_flush_cleanup(sdata);
2897    
2898     diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
2899     index d0275f3..835584c 100644
2900     --- a/net/mac80211/pm.c
2901     +++ b/net/mac80211/pm.c
2902     @@ -53,8 +53,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
2903     ieee80211_stop_queues_by_reason(hw,
2904     IEEE80211_QUEUE_STOP_REASON_SUSPEND);
2905    
2906     - /* flush out all packets */
2907     + /* flush out all packets and station cleanup call_rcu()s */
2908     synchronize_net();
2909     + rcu_barrier();
2910    
2911     drv_flush(local, false);
2912    
2913     diff --git a/net/wireless/reg.c b/net/wireless/reg.c
2914     index 98532c00..6dee0ad 100644
2915     --- a/net/wireless/reg.c
2916     +++ b/net/wireless/reg.c
2917     @@ -855,7 +855,7 @@ static void handle_channel(struct wiphy *wiphy,
2918     return;
2919    
2920     REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
2921     - chan->flags = IEEE80211_CHAN_DISABLED;
2922     + chan->flags |= IEEE80211_CHAN_DISABLED;
2923     return;
2924     }
2925    
2926     diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
2927     index 3368939..68b85e1 100644
2928     --- a/scripts/kconfig/streamline_config.pl
2929     +++ b/scripts/kconfig/streamline_config.pl
2930     @@ -156,7 +156,6 @@ sub read_kconfig {
2931    
2932     my $state = "NONE";
2933     my $config;
2934     - my @kconfigs;
2935    
2936     my $cont = 0;
2937     my $line;
2938     @@ -190,7 +189,13 @@ sub read_kconfig {
2939    
2940     # collect any Kconfig sources
2941     if (/^source\s*"(.*)"/) {
2942     - $kconfigs[$#kconfigs+1] = $1;
2943     + my $kconfig = $1;
2944     + # prevent reading twice.
2945     + if (!defined($read_kconfigs{$kconfig})) {
2946     + $read_kconfigs{$kconfig} = 1;
2947     + read_kconfig($kconfig);
2948     + }
2949     + next;
2950     }
2951    
2952     # configs found
2953     @@ -250,14 +255,6 @@ sub read_kconfig {
2954     }
2955     }
2956     close($kinfile);
2957     -
2958     - # read in any configs that were found.
2959     - foreach my $kconfig (@kconfigs) {
2960     - if (!defined($read_kconfigs{$kconfig})) {
2961     - $read_kconfigs{$kconfig} = 1;
2962     - read_kconfig($kconfig);
2963     - }
2964     - }
2965     }
2966    
2967     if ($kconfig) {
2968     diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
2969     index e6b0166..bdd888e 100644
2970     --- a/sound/pci/emu10k1/emu10k1_main.c
2971     +++ b/sound/pci/emu10k1/emu10k1_main.c
2972     @@ -657,14 +657,14 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu)
2973     return 0;
2974     }
2975    
2976     -static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu)
2977     +static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu,
2978     + const struct firmware *fw_entry)
2979     {
2980     int n, i;
2981     int reg;
2982     int value;
2983     unsigned int write_post;
2984     unsigned long flags;
2985     - const struct firmware *fw_entry = emu->firmware;
2986    
2987     if (!fw_entry)
2988     return -EIO;
2989     @@ -725,9 +725,34 @@ static int emu1010_firmware_thread(void *data)
2990     /* Return to Audio Dock programming mode */
2991     snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
2992     snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
2993     - err = snd_emu1010_load_firmware(emu);
2994     - if (err != 0)
2995     - continue;
2996     +
2997     + if (!emu->dock_fw) {
2998     + const char *filename = NULL;
2999     + switch (emu->card_capabilities->emu_model) {
3000     + case EMU_MODEL_EMU1010:
3001     + filename = DOCK_FILENAME;
3002     + break;
3003     + case EMU_MODEL_EMU1010B:
3004     + filename = MICRO_DOCK_FILENAME;
3005     + break;
3006     + case EMU_MODEL_EMU1616:
3007     + filename = MICRO_DOCK_FILENAME;
3008     + break;
3009     + }
3010     + if (filename) {
3011     + err = request_firmware(&emu->dock_fw,
3012     + filename,
3013     + &emu->pci->dev);
3014     + if (err)
3015     + continue;
3016     + }
3017     + }
3018     +
3019     + if (emu->dock_fw) {
3020     + err = snd_emu1010_load_firmware(emu, emu->dock_fw);
3021     + if (err)
3022     + continue;
3023     + }
3024    
3025     snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
3026     snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
3027     @@ -862,7 +887,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
3028     filename, emu->firmware->size);
3029     }
3030    
3031     - err = snd_emu1010_load_firmware(emu);
3032     + err = snd_emu1010_load_firmware(emu, emu->firmware);
3033     if (err != 0) {
3034     snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n");
3035     return err;
3036     @@ -1253,6 +1278,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
3037     kthread_stop(emu->emu1010.firmware_thread);
3038     if (emu->firmware)
3039     release_firmware(emu->firmware);
3040     + if (emu->dock_fw)
3041     + release_firmware(emu->dock_fw);
3042     if (emu->irq >= 0)
3043     free_irq(emu->irq, emu);
3044     /* remove reserved page */
3045     diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
3046     index 2dbe767..d74500b 100644
3047     --- a/sound/pci/hda/hda_generic.c
3048     +++ b/sound/pci/hda/hda_generic.c
3049     @@ -2072,6 +2072,14 @@ get_multiio_path(struct hda_codec *codec, int idx)
3050    
3051     static void update_automute_all(struct hda_codec *codec);
3052    
3053     +/* Default value to be passed as aamix argument for snd_hda_activate_path();
3054     + * used for output paths
3055     + */
3056     +static bool aamix_default(struct hda_gen_spec *spec)
3057     +{
3058     + return !spec->have_aamix_ctl || spec->aamix_mode;
3059     +}
3060     +
3061     static int set_multi_io(struct hda_codec *codec, int idx, bool output)
3062     {
3063     struct hda_gen_spec *spec = codec->spec;
3064     @@ -2087,11 +2095,11 @@ static int set_multi_io(struct hda_codec *codec, int idx, bool output)
3065    
3066     if (output) {
3067     set_pin_target(codec, nid, PIN_OUT, true);
3068     - snd_hda_activate_path(codec, path, true, true);
3069     + snd_hda_activate_path(codec, path, true, aamix_default(spec));
3070     set_pin_eapd(codec, nid, true);
3071     } else {
3072     set_pin_eapd(codec, nid, false);
3073     - snd_hda_activate_path(codec, path, false, true);
3074     + snd_hda_activate_path(codec, path, false, aamix_default(spec));
3075     set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true);
3076     path_power_down_sync(codec, path);
3077     }
3078     @@ -2182,8 +2190,8 @@ static void update_aamix_paths(struct hda_codec *codec, bool do_mix,
3079     snd_hda_activate_path(codec, mix_path, true, true);
3080     path_power_down_sync(codec, nomix_path);
3081     } else {
3082     - snd_hda_activate_path(codec, mix_path, false, true);
3083     - snd_hda_activate_path(codec, nomix_path, true, true);
3084     + snd_hda_activate_path(codec, mix_path, false, false);
3085     + snd_hda_activate_path(codec, nomix_path, true, false);
3086     path_power_down_sync(codec, mix_path);
3087     }
3088     }
3089     @@ -4729,7 +4737,8 @@ static void set_output_and_unmute(struct hda_codec *codec, int path_idx)
3090     return;
3091     pin = path->path[path->depth - 1];
3092     restore_pin_ctl(codec, pin);
3093     - snd_hda_activate_path(codec, path, path->active, true);
3094     + snd_hda_activate_path(codec, path, path->active,
3095     + aamix_default(codec->spec));
3096     set_pin_eapd(codec, pin, path->active);
3097     }
3098    
3099     @@ -4779,7 +4788,8 @@ static void init_multi_io(struct hda_codec *codec)
3100     if (!spec->multi_io[i].ctl_in)
3101     spec->multi_io[i].ctl_in =
3102     snd_hda_codec_get_pin_target(codec, pin);
3103     - snd_hda_activate_path(codec, path, path->active, true);
3104     + snd_hda_activate_path(codec, path, path->active,
3105     + aamix_default(spec));
3106     }
3107     }
3108    
3109     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3110     index f15c36b..fd1970c 100644
3111     --- a/sound/pci/hda/patch_realtek.c
3112     +++ b/sound/pci/hda/patch_realtek.c
3113     @@ -2515,6 +2515,7 @@ enum {
3114     ALC269_TYPE_ALC280,
3115     ALC269_TYPE_ALC282,
3116     ALC269_TYPE_ALC284,
3117     + ALC269_TYPE_ALC286,
3118     };
3119    
3120     /*
3121     @@ -2538,6 +2539,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
3122     case ALC269_TYPE_ALC269VB:
3123     case ALC269_TYPE_ALC269VD:
3124     case ALC269_TYPE_ALC282:
3125     + case ALC269_TYPE_ALC286:
3126     ssids = alc269_ssids;
3127     break;
3128     default:
3129     @@ -3172,6 +3174,9 @@ static int patch_alc269(struct hda_codec *codec)
3130     case 0x10ec0292:
3131     spec->codec_variant = ALC269_TYPE_ALC284;
3132     break;
3133     + case 0x10ec0286:
3134     + spec->codec_variant = ALC269_TYPE_ALC286;
3135     + break;
3136     }
3137    
3138     /* automatic parse from the BIOS config */
3139     @@ -3878,6 +3883,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
3140     { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
3141     { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
3142     { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
3143     + { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
3144     { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
3145     { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
3146     { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
3147     diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
3148     index a4c16fd..5d36319 100644
3149     --- a/sound/soc/codecs/max98088.c
3150     +++ b/sound/soc/codecs/max98088.c
3151     @@ -2006,7 +2006,7 @@ static int max98088_probe(struct snd_soc_codec *codec)
3152     ret);
3153     goto err_access;
3154     }
3155     - dev_info(codec->dev, "revision %c\n", ret + 'A');
3156     + dev_info(codec->dev, "revision %c\n", ret - 0x40 + 'A');
3157    
3158     snd_soc_write(codec, M98088_REG_51_PWR_SYS, M98088_PWRSV);
3159    
3160     diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
3161     index e2ca12f..40dd50a 100644
3162     --- a/sound/usb/6fire/pcm.c
3163     +++ b/sound/usb/6fire/pcm.c
3164     @@ -575,7 +575,6 @@ static void usb6fire_pcm_init_urb(struct pcm_urb *urb,
3165     urb->instance.pipe = in ? usb_rcvisocpipe(chip->dev, ep)
3166     : usb_sndisocpipe(chip->dev, ep);
3167     urb->instance.interval = 1;
3168     - urb->instance.transfer_flags = URB_ISO_ASAP;
3169     urb->instance.complete = handler;
3170     urb->instance.context = urb;
3171     urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB;
3172     diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
3173     index fde9a7a..b45e29b 100644
3174     --- a/sound/usb/caiaq/audio.c
3175     +++ b/sound/usb/caiaq/audio.c
3176     @@ -670,7 +670,6 @@ static void read_completed(struct urb *urb)
3177    
3178     if (send_it) {
3179     out->number_of_packets = outframe;
3180     - out->transfer_flags = URB_ISO_ASAP;
3181     usb_submit_urb(out, GFP_ATOMIC);
3182     } else {
3183     struct snd_usb_caiaq_cb_info *oinfo = out->context;
3184     @@ -686,7 +685,6 @@ requeue:
3185     }
3186    
3187     urb->number_of_packets = FRAMES_PER_URB;
3188     - urb->transfer_flags = URB_ISO_ASAP;
3189     usb_submit_urb(urb, GFP_ATOMIC);
3190     }
3191    
3192     @@ -751,7 +749,6 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
3193     * BYTES_PER_FRAME;
3194     urbs[i]->context = &dev->data_cb_info[i];
3195     urbs[i]->interval = 1;
3196     - urbs[i]->transfer_flags = URB_ISO_ASAP;
3197     urbs[i]->number_of_packets = FRAMES_PER_URB;
3198     urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
3199     read_completed : write_completed;
3200     diff --git a/sound/usb/card.c b/sound/usb/card.c
3201     index 2da8ad7..b79b7dc 100644
3202     --- a/sound/usb/card.c
3203     +++ b/sound/usb/card.c
3204     @@ -627,7 +627,9 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
3205     int err = -ENODEV;
3206    
3207     down_read(&chip->shutdown_rwsem);
3208     - if (!chip->shutdown && !chip->probing)
3209     + if (chip->probing)
3210     + err = 0;
3211     + else if (!chip->shutdown)
3212     err = usb_autopm_get_interface(chip->pm_intf);
3213     up_read(&chip->shutdown_rwsem);
3214    
3215     diff --git a/sound/usb/card.h b/sound/usb/card.h
3216     index 8a751b4..d32ea41 100644
3217     --- a/sound/usb/card.h
3218     +++ b/sound/usb/card.h
3219     @@ -116,6 +116,7 @@ struct snd_usb_substream {
3220     unsigned int altset_idx; /* USB data format: index of alternate setting */
3221     unsigned int txfr_quirk:1; /* allow sub-frame alignment */
3222     unsigned int fmt_type; /* USB audio format type (1-3) */
3223     + unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */
3224    
3225     unsigned int running: 1; /* running status */
3226    
3227     diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
3228     index 21049b8..63cca3a 100644
3229     --- a/sound/usb/endpoint.c
3230     +++ b/sound/usb/endpoint.c
3231     @@ -677,7 +677,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
3232     if (!u->urb->transfer_buffer)
3233     goto out_of_memory;
3234     u->urb->pipe = ep->pipe;
3235     - u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
3236     + u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3237     u->urb->interval = 1 << ep->datainterval;
3238     u->urb->context = u;
3239     u->urb->complete = snd_complete_urb;
3240     @@ -716,8 +716,7 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep,
3241     u->urb->transfer_dma = ep->sync_dma + i * 4;
3242     u->urb->transfer_buffer_length = 4;
3243     u->urb->pipe = ep->pipe;
3244     - u->urb->transfer_flags = URB_ISO_ASAP |
3245     - URB_NO_TRANSFER_DMA_MAP;
3246     + u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3247     u->urb->number_of_packets = 1;
3248     u->urb->interval = 1 << ep->syncinterval;
3249     u->urb->context = u;
3250     diff --git a/sound/usb/midi.c b/sound/usb/midi.c
3251     index 34b9bb7..e5fee18 100644
3252     --- a/sound/usb/midi.c
3253     +++ b/sound/usb/midi.c
3254     @@ -126,7 +126,6 @@ struct snd_usb_midi {
3255     struct snd_usb_midi_in_endpoint *in;
3256     } endpoints[MIDI_MAX_ENDPOINTS];
3257     unsigned long input_triggered;
3258     - bool autopm_reference;
3259     unsigned int opened[2];
3260     unsigned char disconnected;
3261     unsigned char input_running;
3262     @@ -1040,7 +1039,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3263     {
3264     struct snd_usb_midi* umidi = substream->rmidi->private_data;
3265     struct snd_kcontrol *ctl;
3266     - int err;
3267    
3268     down_read(&umidi->disc_rwsem);
3269     if (umidi->disconnected) {
3270     @@ -1051,13 +1049,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3271     mutex_lock(&umidi->mutex);
3272     if (open) {
3273     if (!umidi->opened[0] && !umidi->opened[1]) {
3274     - err = usb_autopm_get_interface(umidi->iface);
3275     - umidi->autopm_reference = err >= 0;
3276     - if (err < 0 && err != -EACCES) {
3277     - mutex_unlock(&umidi->mutex);
3278     - up_read(&umidi->disc_rwsem);
3279     - return -EIO;
3280     - }
3281     if (umidi->roland_load_ctl) {
3282     ctl = umidi->roland_load_ctl;
3283     ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
3284     @@ -1080,8 +1071,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3285     snd_ctl_notify(umidi->card,
3286     SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
3287     }
3288     - if (umidi->autopm_reference)
3289     - usb_autopm_put_interface(umidi->iface);
3290     }
3291     }
3292     mutex_unlock(&umidi->mutex);
3293     @@ -2256,6 +2245,8 @@ int snd_usbmidi_create(struct snd_card *card,
3294     return err;
3295     }
3296    
3297     + usb_autopm_get_interface_no_resume(umidi->iface);
3298     +
3299     list_add_tail(&umidi->list, midi_list);
3300     return 0;
3301     }
3302     diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
3303     index 8b81cb5..6ad617b 100644
3304     --- a/sound/usb/misc/ua101.c
3305     +++ b/sound/usb/misc/ua101.c
3306     @@ -1120,8 +1120,7 @@ static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream,
3307     usb_init_urb(&urb->urb);
3308     urb->urb.dev = ua->dev;
3309     urb->urb.pipe = stream->usb_pipe;
3310     - urb->urb.transfer_flags = URB_ISO_ASAP |
3311     - URB_NO_TRANSFER_DMA_MAP;
3312     + urb->urb.transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3313     urb->urb.transfer_buffer = addr;
3314     urb->urb.transfer_dma = dma;
3315     urb->urb.transfer_buffer_length = max_packet_size;
3316     diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
3317     index f94397b..a481fea 100644
3318     --- a/sound/usb/pcm.c
3319     +++ b/sound/usb/pcm.c
3320     @@ -1170,7 +1170,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
3321     stride = runtime->frame_bits >> 3;
3322    
3323     for (i = 0; i < urb->number_of_packets; i++) {
3324     - cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
3325     + cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj;
3326     if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
3327     snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
3328     // continue;
3329     diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
3330     index 9c5ab22..0c7eb49 100644
3331     --- a/sound/usb/quirks.c
3332     +++ b/sound/usb/quirks.c
3333     @@ -837,6 +837,7 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs,
3334     break;
3335     }
3336     snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
3337     + subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
3338     }
3339    
3340     void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
3341     diff --git a/sound/usb/stream.c b/sound/usb/stream.c
3342     index ad181d5..cfc4d4e 100644
3343     --- a/sound/usb/stream.c
3344     +++ b/sound/usb/stream.c
3345     @@ -94,6 +94,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
3346     subs->dev = as->chip->dev;
3347     subs->txfr_quirk = as->chip->txfr_quirk;
3348     subs->speed = snd_usb_get_speed(subs->dev);
3349     + subs->pkt_offset_adj = 0;
3350    
3351     snd_usb_set_pcm_ops(as->pcm, stream);
3352    
3353     @@ -396,6 +397,14 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
3354     if (!csep && altsd->bNumEndpoints >= 2)
3355     csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT);
3356    
3357     + /*
3358     + * If we can't locate the USB_DT_CS_ENDPOINT descriptor in the extra
3359     + * bytes after the first endpoint, go search the entire interface.
3360     + * Some devices have it directly *before* the standard endpoint.
3361     + */
3362     + if (!csep)
3363     + csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT);
3364     +
3365     if (!csep || csep->bLength < 7 ||
3366     csep->bDescriptorSubtype != UAC_EP_GENERAL) {
3367     snd_printk(KERN_WARNING "%d:%u:%d : no or invalid"
3368     diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
3369     index 1e7a47a..bf618e1 100644
3370     --- a/sound/usb/usx2y/usb_stream.c
3371     +++ b/sound/usb/usx2y/usb_stream.c
3372     @@ -69,7 +69,6 @@ static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
3373     ++u, transfer += transfer_length) {
3374     struct urb *urb = urbs[u];
3375     struct usb_iso_packet_descriptor *desc;
3376     - urb->transfer_flags = URB_ISO_ASAP;
3377     urb->transfer_buffer = transfer;
3378     urb->dev = dev;
3379     urb->pipe = pipe;
3380     diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
3381     index 520ef96..b376532 100644
3382     --- a/sound/usb/usx2y/usbusx2yaudio.c
3383     +++ b/sound/usb/usx2y/usbusx2yaudio.c
3384     @@ -503,7 +503,6 @@ static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs)
3385     if (0 == i)
3386     atomic_set(&subs->state, state_STARTING3);
3387     urb->dev = usX2Y->dev;
3388     - urb->transfer_flags = URB_ISO_ASAP;
3389     for (pack = 0; pack < nr_of_packs(); pack++) {
3390     urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack;
3391     urb->iso_frame_desc[pack].length = subs->maxpacksize;
3392     diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
3393     index cc56007..f2a1acd 100644
3394     --- a/sound/usb/usx2y/usx2yhwdeppcm.c
3395     +++ b/sound/usb/usx2y/usx2yhwdeppcm.c
3396     @@ -443,7 +443,6 @@ static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs)
3397     if (0 == u)
3398     atomic_set(&subs->state, state_STARTING3);
3399     urb->dev = usX2Y->dev;
3400     - urb->transfer_flags = URB_ISO_ASAP;
3401     for (pack = 0; pack < nr_of_packs(); pack++) {
3402     urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs());
3403     urb->iso_frame_desc[pack].length = subs->maxpacksize;