Magellan Linux

Annotation of /trunk/kernel-magellan/patches-3.18/0108-3.18.9-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2552 - (hide annotations) (download)
Wed Mar 18 09:21:19 2015 UTC (9 years, 2 months ago) by niro
File size: 192335 byte(s)
-linux-3.18.9
1 niro 2552 diff --git a/Makefile b/Makefile
2     index 0b3f8a1b3715..62b333802a0e 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 3
7     PATCHLEVEL = 18
8     -SUBLEVEL = 8
9     +SUBLEVEL = 9
10     EXTRAVERSION =
11     NAME = Diseased Newt
12    
13     diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
14     index 6b0b7f7ef783..7670f33b9ce2 100644
15     --- a/arch/arc/include/asm/pgtable.h
16     +++ b/arch/arc/include/asm/pgtable.h
17     @@ -259,7 +259,8 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
18     #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0)
19    
20     #define pte_page(x) (mem_map + \
21     - (unsigned long)(((pte_val(x) - PAGE_OFFSET) >> PAGE_SHIFT)))
22     + (unsigned long)(((pte_val(x) - CONFIG_LINUX_LINK_BASE) >> \
23     + PAGE_SHIFT)))
24    
25     #define mk_pte(page, pgprot) \
26     ({ \
27     diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
28     index 6cc25ed912ee..2c6248d9a9ef 100644
29     --- a/arch/arm/boot/dts/am335x-bone-common.dtsi
30     +++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
31     @@ -195,6 +195,7 @@
32    
33     &usb0 {
34     status = "okay";
35     + dr_mode = "peripheral";
36     };
37    
38     &usb1 {
39     diff --git a/arch/arm/boot/dts/bcm63138.dtsi b/arch/arm/boot/dts/bcm63138.dtsi
40     index f3bb2dd6269e..c97844cac4e7 100644
41     --- a/arch/arm/boot/dts/bcm63138.dtsi
42     +++ b/arch/arm/boot/dts/bcm63138.dtsi
43     @@ -66,8 +66,9 @@
44     reg = <0x1d000 0x1000>;
45     cache-unified;
46     cache-level = <2>;
47     - cache-sets = <16>;
48     - cache-size = <0x80000>;
49     + cache-size = <524288>;
50     + cache-sets = <1024>;
51     + cache-line-size = <32>;
52     interrupts = <GIC_PPI 0 IRQ_TYPE_LEVEL_HIGH>;
53     };
54    
55     diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
56     index 8acf5d85c99d..f76fe94267d6 100644
57     --- a/arch/arm/boot/dts/tegra20.dtsi
58     +++ b/arch/arm/boot/dts/tegra20.dtsi
59     @@ -68,9 +68,9 @@
60     reset-names = "2d";
61     };
62    
63     - gr3d@54140000 {
64     + gr3d@54180000 {
65     compatible = "nvidia,tegra20-gr3d";
66     - reg = <0x54140000 0x00040000>;
67     + reg = <0x54180000 0x00040000>;
68     clocks = <&tegra_car TEGRA20_CLK_GR3D>;
69     resets = <&tegra_car 24>;
70     reset-names = "3d";
71     @@ -130,9 +130,9 @@
72     status = "disabled";
73     };
74    
75     - dsi@542c0000 {
76     + dsi@54300000 {
77     compatible = "nvidia,tegra20-dsi";
78     - reg = <0x542c0000 0x00040000>;
79     + reg = <0x54300000 0x00040000>;
80     clocks = <&tegra_car TEGRA20_CLK_DSI>;
81     resets = <&tegra_car 48>;
82     reset-names = "dsi";
83     diff --git a/arch/arm/mach-mvebu/system-controller.c b/arch/arm/mach-mvebu/system-controller.c
84     index a068cb5c2ce8..c6c132acd7a6 100644
85     --- a/arch/arm/mach-mvebu/system-controller.c
86     +++ b/arch/arm/mach-mvebu/system-controller.c
87     @@ -126,7 +126,7 @@ int mvebu_system_controller_get_soc_id(u32 *dev, u32 *rev)
88     return -ENODEV;
89     }
90    
91     -#ifdef CONFIG_SMP
92     +#if defined(CONFIG_SMP) && defined(CONFIG_MACH_MVEBU_V7)
93     void mvebu_armada375_smp_wa_init(void)
94     {
95     u32 dev, rev;
96     diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
97     index 5684f112654b..4e9d2a97c2cb 100644
98     --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
99     +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
100     @@ -2017,7 +2017,7 @@ static struct omap_hwmod dra7xx_uart3_hwmod = {
101     .class = &dra7xx_uart_hwmod_class,
102     .clkdm_name = "l4per_clkdm",
103     .main_clk = "uart3_gfclk_mux",
104     - .flags = HWMOD_SWSUP_SIDLE_ACT,
105     + .flags = HWMOD_SWSUP_SIDLE_ACT | DEBUG_OMAP4UART3_FLAGS,
106     .prcm = {
107     .omap4 = {
108     .clkctrl_offs = DRA7XX_CM_L4PER_UART3_CLKCTRL_OFFSET,
109     diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
110     index 06022b235730..89f790dda93e 100644
111     --- a/arch/arm/mach-pxa/corgi.c
112     +++ b/arch/arm/mach-pxa/corgi.c
113     @@ -26,6 +26,7 @@
114     #include <linux/i2c.h>
115     #include <linux/i2c/pxa-i2c.h>
116     #include <linux/io.h>
117     +#include <linux/regulator/machine.h>
118     #include <linux/spi/spi.h>
119     #include <linux/spi/ads7846.h>
120     #include <linux/spi/corgi_lcd.h>
121     @@ -752,6 +753,8 @@ static void __init corgi_init(void)
122     sharpsl_nand_partitions[1].size = 53 * 1024 * 1024;
123    
124     platform_add_devices(devices, ARRAY_SIZE(devices));
125     +
126     + regulator_has_full_constraints();
127     }
128    
129     static void __init fixup_corgi(struct tag *tags, char **cmdline)
130     diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
131     index c66ad4edc5e3..5fb41ad6e3bc 100644
132     --- a/arch/arm/mach-pxa/hx4700.c
133     +++ b/arch/arm/mach-pxa/hx4700.c
134     @@ -893,6 +893,8 @@ static void __init hx4700_init(void)
135     mdelay(10);
136     gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
137     mdelay(10);
138     +
139     + regulator_has_full_constraints();
140     }
141    
142     MACHINE_START(H4700, "HP iPAQ HX4700")
143     diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
144     index 131991629116..e81d216b05e4 100644
145     --- a/arch/arm/mach-pxa/poodle.c
146     +++ b/arch/arm/mach-pxa/poodle.c
147     @@ -25,6 +25,7 @@
148     #include <linux/gpio.h>
149     #include <linux/i2c.h>
150     #include <linux/i2c/pxa-i2c.h>
151     +#include <linux/regulator/machine.h>
152     #include <linux/spi/spi.h>
153     #include <linux/spi/ads7846.h>
154     #include <linux/spi/pxa2xx_spi.h>
155     @@ -455,6 +456,7 @@ static void __init poodle_init(void)
156     pxa_set_i2c_info(NULL);
157     i2c_register_board_info(0, ARRAY_AND_SIZE(poodle_i2c_devices));
158     poodle_init_spi();
159     + regulator_has_full_constraints();
160     }
161    
162     static void __init fixup_poodle(struct tag *tags, char **cmdline)
163     diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
164     index 6645d1e31f14..34853d5dfda2 100644
165     --- a/arch/arm/mach-sa1100/pm.c
166     +++ b/arch/arm/mach-sa1100/pm.c
167     @@ -81,6 +81,7 @@ static int sa11x0_pm_enter(suspend_state_t state)
168     /*
169     * Ensure not to come back here if it wasn't intended
170     */
171     + RCSR = RCSR_SMR;
172     PSPR = 0;
173    
174     /*
175     diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
176     index b2cfba16c4e8..18865136156f 100644
177     --- a/arch/arm/mach-vexpress/Kconfig
178     +++ b/arch/arm/mach-vexpress/Kconfig
179     @@ -75,6 +75,7 @@ config ARCH_VEXPRESS_TC2_PM
180     depends on MCPM
181     select ARM_CCI
182     select ARCH_VEXPRESS_SPC
183     + select ARM_CPU_SUSPEND
184     help
185     Support for CPU and cluster power management on Versatile Express
186     with a TC2 (A15x2 A7x3) big.LITTLE core tile.
187     diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
188     index 1b9ad02837cf..76920d4040d4 100644
189     --- a/arch/arm64/kernel/signal32.c
190     +++ b/arch/arm64/kernel/signal32.c
191     @@ -154,8 +154,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
192     case __SI_TIMER:
193     err |= __put_user(from->si_tid, &to->si_tid);
194     err |= __put_user(from->si_overrun, &to->si_overrun);
195     - err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr,
196     - &to->si_ptr);
197     + err |= __put_user(from->si_int, &to->si_int);
198     break;
199     case __SI_POLL:
200     err |= __put_user(from->si_band, &to->si_band);
201     @@ -184,7 +183,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
202     case __SI_MESGQ: /* But this is */
203     err |= __put_user(from->si_pid, &to->si_pid);
204     err |= __put_user(from->si_uid, &to->si_uid);
205     - err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, &to->si_ptr);
206     + err |= __put_user(from->si_int, &to->si_int);
207     break;
208     default: /* this is just in case for now ... */
209     err |= __put_user(from->si_pid, &to->si_pid);
210     diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
211     index 881071c07942..13272fd5a5ba 100644
212     --- a/arch/metag/include/asm/processor.h
213     +++ b/arch/metag/include/asm/processor.h
214     @@ -149,8 +149,8 @@ extern void exit_thread(void);
215    
216     unsigned long get_wchan(struct task_struct *p);
217    
218     -#define KSTK_EIP(tsk) ((tsk)->thread.kernel_context->CurrPC)
219     -#define KSTK_ESP(tsk) ((tsk)->thread.kernel_context->AX[0].U0)
220     +#define KSTK_EIP(tsk) (task_pt_regs(tsk)->ctx.CurrPC)
221     +#define KSTK_ESP(tsk) (task_pt_regs(tsk)->ctx.AX[0].U0)
222    
223     #define user_stack_pointer(regs) ((regs)->ctx.AX[0].U0)
224    
225     diff --git a/arch/mips/alchemy/common/clock.c b/arch/mips/alchemy/common/clock.c
226     index d7557cde271a..3fff11ec7dc0 100644
227     --- a/arch/mips/alchemy/common/clock.c
228     +++ b/arch/mips/alchemy/common/clock.c
229     @@ -128,6 +128,8 @@ static unsigned long alchemy_clk_cpu_recalc(struct clk_hw *hw,
230     t = 396000000;
231     else {
232     t = alchemy_rdsys(AU1000_SYS_CPUPLL) & 0x7f;
233     + if (alchemy_get_cputype() < ALCHEMY_CPU_AU1300)
234     + t &= 0x3f;
235     t *= parent_rate;
236     }
237    
238     diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
239     index 6caf8766b80f..71fef0af9c9a 100644
240     --- a/arch/mips/include/asm/asmmacro.h
241     +++ b/arch/mips/include/asm/asmmacro.h
242     @@ -304,7 +304,7 @@
243     .set push
244     .set noat
245     SET_HARDFLOAT
246     - add $1, \base, \off
247     + addu $1, \base, \off
248     .word LDD_MSA_INSN | (\wd << 6)
249     .set pop
250     .endm
251     @@ -313,7 +313,7 @@
252     .set push
253     .set noat
254     SET_HARDFLOAT
255     - add $1, \base, \off
256     + addu $1, \base, \off
257     .word STD_MSA_INSN | (\wd << 6)
258     .set pop
259     .endm
260     diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h
261     index a6c9ccb33c5c..c3f4f2d2e108 100644
262     --- a/arch/mips/include/asm/cpu-info.h
263     +++ b/arch/mips/include/asm/cpu-info.h
264     @@ -84,6 +84,11 @@ struct cpuinfo_mips {
265     * (shifted by _CACHE_SHIFT)
266     */
267     unsigned int writecombine;
268     + /*
269     + * Simple counter to prevent enabling HTW in nested
270     + * htw_start/htw_stop calls
271     + */
272     + unsigned int htw_seq;
273     } __attribute__((aligned(SMP_CACHE_BYTES)));
274    
275     extern struct cpuinfo_mips cpu_data[];
276     diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h
277     index 2f82568a3ee4..bc01579a907a 100644
278     --- a/arch/mips/include/asm/mmu_context.h
279     +++ b/arch/mips/include/asm/mmu_context.h
280     @@ -25,7 +25,6 @@ do { \
281     if (cpu_has_htw) { \
282     write_c0_pwbase(pgd); \
283     back_to_back_c0_hazard(); \
284     - htw_reset(); \
285     } \
286     } while (0)
287    
288     @@ -142,6 +141,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
289     unsigned long flags;
290     local_irq_save(flags);
291    
292     + htw_stop();
293     /* Check if our ASID is of an older version and thus invalid */
294     if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & ASID_VERSION_MASK)
295     get_new_mmu_context(next, cpu);
296     @@ -154,6 +154,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
297     */
298     cpumask_clear_cpu(cpu, mm_cpumask(prev));
299     cpumask_set_cpu(cpu, mm_cpumask(next));
300     + htw_start();
301    
302     local_irq_restore(flags);
303     }
304     @@ -180,6 +181,7 @@ activate_mm(struct mm_struct *prev, struct mm_struct *next)
305    
306     local_irq_save(flags);
307    
308     + htw_stop();
309     /* Unconditionally get a new ASID. */
310     get_new_mmu_context(next, cpu);
311    
312     @@ -189,6 +191,7 @@ activate_mm(struct mm_struct *prev, struct mm_struct *next)
313     /* mark mmu ownership change */
314     cpumask_clear_cpu(cpu, mm_cpumask(prev));
315     cpumask_set_cpu(cpu, mm_cpumask(next));
316     + htw_start();
317    
318     local_irq_restore(flags);
319     }
320     @@ -203,6 +206,7 @@ drop_mmu_context(struct mm_struct *mm, unsigned cpu)
321     unsigned long flags;
322    
323     local_irq_save(flags);
324     + htw_stop();
325    
326     if (cpumask_test_cpu(cpu, mm_cpumask(mm))) {
327     get_new_mmu_context(mm, cpu);
328     @@ -211,6 +215,7 @@ drop_mmu_context(struct mm_struct *mm, unsigned cpu)
329     /* will get a new context next time */
330     cpu_context(cpu, mm) = 0;
331     }
332     + htw_start();
333     local_irq_restore(flags);
334     }
335    
336     diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
337     index d6d1928539b1..bc3fc4fdc9ab 100644
338     --- a/arch/mips/include/asm/pgtable.h
339     +++ b/arch/mips/include/asm/pgtable.h
340     @@ -99,29 +99,35 @@ extern void paging_init(void);
341    
342     #define htw_stop() \
343     do { \
344     - if (cpu_has_htw) \
345     - write_c0_pwctl(read_c0_pwctl() & \
346     - ~(1 << MIPS_PWCTL_PWEN_SHIFT)); \
347     + unsigned long flags; \
348     + \
349     + if (cpu_has_htw) { \
350     + local_irq_save(flags); \
351     + if(!raw_current_cpu_data.htw_seq++) { \
352     + write_c0_pwctl(read_c0_pwctl() & \
353     + ~(1 << MIPS_PWCTL_PWEN_SHIFT)); \
354     + back_to_back_c0_hazard(); \
355     + } \
356     + local_irq_restore(flags); \
357     + } \
358     } while(0)
359    
360     #define htw_start() \
361     do { \
362     - if (cpu_has_htw) \
363     - write_c0_pwctl(read_c0_pwctl() | \
364     - (1 << MIPS_PWCTL_PWEN_SHIFT)); \
365     -} while(0)
366     -
367     -
368     -#define htw_reset() \
369     -do { \
370     + unsigned long flags; \
371     + \
372     if (cpu_has_htw) { \
373     - htw_stop(); \
374     - back_to_back_c0_hazard(); \
375     - htw_start(); \
376     - back_to_back_c0_hazard(); \
377     + local_irq_save(flags); \
378     + if (!--raw_current_cpu_data.htw_seq) { \
379     + write_c0_pwctl(read_c0_pwctl() | \
380     + (1 << MIPS_PWCTL_PWEN_SHIFT)); \
381     + back_to_back_c0_hazard(); \
382     + } \
383     + local_irq_restore(flags); \
384     } \
385     } while(0)
386    
387     +
388     extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
389     pte_t pteval);
390    
391     @@ -153,12 +159,13 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
392     {
393     pte_t null = __pte(0);
394    
395     + htw_stop();
396     /* Preserve global status for the pair */
397     if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL)
398     null.pte_low = null.pte_high = _PAGE_GLOBAL;
399    
400     set_pte_at(mm, addr, ptep, null);
401     - htw_reset();
402     + htw_start();
403     }
404     #else
405    
406     @@ -188,6 +195,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
407    
408     static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
409     {
410     + htw_stop();
411     #if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
412     /* Preserve global status for the pair */
413     if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
414     @@ -195,7 +203,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
415     else
416     #endif
417     set_pte_at(mm, addr, ptep, __pte(0));
418     - htw_reset();
419     + htw_start();
420     }
421     #endif
422    
423     diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
424     index 0384b05ab5a0..55b759a0019e 100644
425     --- a/arch/mips/kernel/cps-vec.S
426     +++ b/arch/mips/kernel/cps-vec.S
427     @@ -99,11 +99,11 @@ not_nmi:
428     xori t2, t1, 0x7
429     beqz t2, 1f
430     li t3, 32
431     - addi t1, t1, 1
432     + addiu t1, t1, 1
433     sllv t1, t3, t1
434     1: /* At this point t1 == I-cache sets per way */
435     _EXT t2, v0, MIPS_CONF1_IA_SHF, MIPS_CONF1_IA_SZ
436     - addi t2, t2, 1
437     + addiu t2, t2, 1
438     mul t1, t1, t0
439     mul t1, t1, t2
440    
441     @@ -126,11 +126,11 @@ icache_done:
442     xori t2, t1, 0x7
443     beqz t2, 1f
444     li t3, 32
445     - addi t1, t1, 1
446     + addiu t1, t1, 1
447     sllv t1, t3, t1
448     1: /* At this point t1 == D-cache sets per way */
449     _EXT t2, v0, MIPS_CONF1_DA_SHF, MIPS_CONF1_DA_SZ
450     - addi t2, t2, 1
451     + addiu t2, t2, 1
452     mul t1, t1, t0
453     mul t1, t1, t2
454    
455     @@ -250,7 +250,7 @@ LEAF(mips_cps_core_init)
456     mfc0 t0, CP0_MVPCONF0
457     srl t0, t0, MVPCONF0_PVPE_SHIFT
458     andi t0, t0, (MVPCONF0_PVPE >> MVPCONF0_PVPE_SHIFT)
459     - addi t7, t0, 1
460     + addiu t7, t0, 1
461    
462     /* If there's only 1, we're done */
463     beqz t0, 2f
464     @@ -280,7 +280,7 @@ LEAF(mips_cps_core_init)
465     mttc0 t0, CP0_TCHALT
466    
467     /* Next VPE */
468     - addi t5, t5, 1
469     + addiu t5, t5, 1
470     slt t0, t5, t7
471     bnez t0, 1b
472     nop
473     @@ -317,7 +317,7 @@ LEAF(mips_cps_boot_vpes)
474     mfc0 t1, CP0_MVPCONF0
475     srl t1, t1, MVPCONF0_PVPE_SHIFT
476     andi t1, t1, MVPCONF0_PVPE >> MVPCONF0_PVPE_SHIFT
477     - addi t1, t1, 1
478     + addiu t1, t1, 1
479    
480     /* Calculate a mask for the VPE ID from EBase.CPUNum */
481     clz t1, t1
482     @@ -424,7 +424,7 @@ LEAF(mips_cps_boot_vpes)
483    
484     /* Next VPE */
485     2: srl t6, t6, 1
486     - addi t5, t5, 1
487     + addiu t5, t5, 1
488     bnez t6, 1b
489     nop
490    
491     diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
492     index dc49cf30c2db..5d6e59f20750 100644
493     --- a/arch/mips/kernel/cpu-probe.c
494     +++ b/arch/mips/kernel/cpu-probe.c
495     @@ -367,8 +367,10 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c)
496     if (config3 & MIPS_CONF3_MSA)
497     c->ases |= MIPS_ASE_MSA;
498     /* Only tested on 32-bit cores */
499     - if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT))
500     + if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
501     + c->htw_seq = 0;
502     c->options |= MIPS_CPU_HTW;
503     + }
504    
505     return config3 & MIPS_CONF_M;
506     }
507     diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
508     index 2607c3a4ff7e..1b2452e2be67 100644
509     --- a/arch/mips/kernel/mips_ksyms.c
510     +++ b/arch/mips/kernel/mips_ksyms.c
511     @@ -14,6 +14,8 @@
512     #include <linux/mm.h>
513     #include <asm/uaccess.h>
514     #include <asm/ftrace.h>
515     +#include <asm/fpu.h>
516     +#include <asm/msa.h>
517    
518     extern void *__bzero(void *__s, size_t __count);
519     extern long __strncpy_from_kernel_nocheck_asm(char *__to,
520     @@ -34,6 +36,14 @@ extern long __strnlen_user_nocheck_asm(const char *s);
521     extern long __strnlen_user_asm(const char *s);
522    
523     /*
524     + * Core architecture code
525     + */
526     +EXPORT_SYMBOL_GPL(_save_fp);
527     +#ifdef CONFIG_CPU_HAS_MSA
528     +EXPORT_SYMBOL_GPL(_save_msa);
529     +#endif
530     +
531     +/*
532     * String functions
533     */
534     EXPORT_SYMBOL(memset);
535     diff --git a/arch/mips/kvm/locore.S b/arch/mips/kvm/locore.S
536     index d7279c03c517..4a68b176d6e4 100644
537     --- a/arch/mips/kvm/locore.S
538     +++ b/arch/mips/kvm/locore.S
539     @@ -434,7 +434,7 @@ __kvm_mips_return_to_guest:
540     /* Setup status register for running guest in UM */
541     .set at
542     or v1, v1, (ST0_EXL | KSU_USER | ST0_IE)
543     - and v1, v1, ~ST0_CU0
544     + and v1, v1, ~(ST0_CU0 | ST0_MX)
545     .set noat
546     mtc0 v1, CP0_STATUS
547     ehb
548     diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
549     index e3b21e51ff7e..270bbd41769e 100644
550     --- a/arch/mips/kvm/mips.c
551     +++ b/arch/mips/kvm/mips.c
552     @@ -15,9 +15,11 @@
553     #include <linux/vmalloc.h>
554     #include <linux/fs.h>
555     #include <linux/bootmem.h>
556     +#include <asm/fpu.h>
557     #include <asm/page.h>
558     #include <asm/cacheflush.h>
559     #include <asm/mmu_context.h>
560     +#include <asm/pgtable.h>
561    
562     #include <linux/kvm_host.h>
563    
564     @@ -378,6 +380,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
565     vcpu->mmio_needed = 0;
566     }
567    
568     + lose_fpu(1);
569     +
570     local_irq_disable();
571     /* Check if we have any exceptions/interrupts pending */
572     kvm_mips_deliver_interrupts(vcpu,
573     @@ -385,8 +389,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
574    
575     kvm_guest_enter();
576    
577     + /* Disable hardware page table walking while in guest */
578     + htw_stop();
579     +
580     r = __kvm_mips_vcpu_run(run, vcpu);
581    
582     + /* Re-enable HTW before enabling interrupts */
583     + htw_start();
584     +
585     kvm_guest_exit();
586     local_irq_enable();
587    
588     @@ -980,9 +990,6 @@ static void kvm_mips_set_c0_status(void)
589     {
590     uint32_t status = read_c0_status();
591    
592     - if (cpu_has_fpu)
593     - status |= (ST0_CU1);
594     -
595     if (cpu_has_dsp)
596     status |= (ST0_MX);
597    
598     @@ -1002,6 +1009,9 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
599     enum emulation_result er = EMULATE_DONE;
600     int ret = RESUME_GUEST;
601    
602     + /* re-enable HTW before enabling interrupts */
603     + htw_start();
604     +
605     /* Set a default exit reason */
606     run->exit_reason = KVM_EXIT_UNKNOWN;
607     run->ready_for_interrupt_injection = 1;
608     @@ -1136,6 +1146,9 @@ skip_emul:
609     }
610     }
611    
612     + /* Disable HTW before returning to guest or host */
613     + htw_stop();
614     +
615     return ret;
616     }
617    
618     diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
619     index ad56edc39919..e8bb33b2d3cc 100644
620     --- a/arch/powerpc/sysdev/axonram.c
621     +++ b/arch/powerpc/sysdev/axonram.c
622     @@ -156,7 +156,7 @@ axon_ram_direct_access(struct block_device *device, sector_t sector,
623     }
624    
625     *kaddr = (void *)(bank->ph_addr + offset);
626     - *pfn = virt_to_phys(kaddr) >> PAGE_SHIFT;
627     + *pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT;
628    
629     return 0;
630     }
631     diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
632     index 4fc3fed636dc..29e2e5aa2111 100644
633     --- a/arch/s390/kvm/interrupt.c
634     +++ b/arch/s390/kvm/interrupt.c
635     @@ -613,7 +613,7 @@ no_timer:
636     __unset_cpu_idle(vcpu);
637     vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
638    
639     - hrtimer_try_to_cancel(&vcpu->arch.ckc_timer);
640     + hrtimer_cancel(&vcpu->arch.ckc_timer);
641     return 0;
642     }
643    
644     @@ -633,10 +633,20 @@ void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu)
645     enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer)
646     {
647     struct kvm_vcpu *vcpu;
648     + u64 now, sltime;
649    
650     vcpu = container_of(timer, struct kvm_vcpu, arch.ckc_timer);
651     - kvm_s390_vcpu_wakeup(vcpu);
652     + now = get_tod_clock_fast() + vcpu->arch.sie_block->epoch;
653     + sltime = tod_to_ns(vcpu->arch.sie_block->ckc - now);
654    
655     + /*
656     + * If the monotonic clock runs faster than the tod clock we might be
657     + * woken up too early and have to go back to sleep to avoid deadlocks.
658     + */
659     + if (vcpu->arch.sie_block->ckc > now &&
660     + hrtimer_forward_now(timer, ns_to_ktime(sltime)))
661     + return HRTIMER_RESTART;
662     + kvm_s390_vcpu_wakeup(vcpu);
663     return HRTIMER_NORESTART;
664     }
665    
666     @@ -840,6 +850,8 @@ static int __inject_vm(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
667     list_add_tail(&inti->list, &iter->list);
668     }
669     atomic_set(&fi->active, 1);
670     + if (atomic_read(&kvm->online_vcpus) == 0)
671     + goto unlock_fi;
672     sigcpu = find_first_bit(fi->idle_mask, KVM_MAX_VCPUS);
673     if (sigcpu == KVM_MAX_VCPUS) {
674     do {
675     @@ -864,6 +876,7 @@ int kvm_s390_inject_vm(struct kvm *kvm,
676     struct kvm_s390_interrupt *s390int)
677     {
678     struct kvm_s390_interrupt_info *inti;
679     + int rc;
680    
681     inti = kzalloc(sizeof(*inti), GFP_KERNEL);
682     if (!inti)
683     @@ -911,7 +924,10 @@ int kvm_s390_inject_vm(struct kvm *kvm,
684     trace_kvm_s390_inject_vm(s390int->type, s390int->parm, s390int->parm64,
685     2);
686    
687     - return __inject_vm(kvm, inti);
688     + rc = __inject_vm(kvm, inti);
689     + if (rc)
690     + kfree(inti);
691     + return rc;
692     }
693    
694     void kvm_s390_reinject_io_int(struct kvm *kvm,
695     diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
696     index 55aade49b6d1..ced09d8738b4 100644
697     --- a/arch/s390/kvm/kvm-s390.c
698     +++ b/arch/s390/kvm/kvm-s390.c
699     @@ -662,7 +662,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
700     if (rc)
701     return rc;
702     }
703     - hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
704     + hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
705     vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
706     get_cpu_id(&vcpu->arch.cpu_id);
707     vcpu->arch.cpu_id.version = 0xff;
708     diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
709     index 6a1a8458c042..30c0acf4ea6c 100644
710     --- a/arch/x86/boot/compressed/Makefile
711     +++ b/arch/x86/boot/compressed/Makefile
712     @@ -36,6 +36,7 @@ vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
713     $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
714    
715     vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
716     +vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
717    
718     $(obj)/vmlinux: $(vmlinux-objs-y) FORCE
719     $(call if_changed,ld)
720     diff --git a/arch/x86/boot/compressed/efi_stub_64.S b/arch/x86/boot/compressed/efi_stub_64.S
721     index 7ff3632806b1..99494dff2113 100644
722     --- a/arch/x86/boot/compressed/efi_stub_64.S
723     +++ b/arch/x86/boot/compressed/efi_stub_64.S
724     @@ -3,28 +3,3 @@
725     #include <asm/processor-flags.h>
726    
727     #include "../../platform/efi/efi_stub_64.S"
728     -
729     -#ifdef CONFIG_EFI_MIXED
730     - .code64
731     - .text
732     -ENTRY(efi64_thunk)
733     - push %rbp
734     - push %rbx
735     -
736     - subq $16, %rsp
737     - leaq efi_exit32(%rip), %rax
738     - movl %eax, 8(%rsp)
739     - leaq efi_gdt64(%rip), %rax
740     - movl %eax, 4(%rsp)
741     - movl %eax, 2(%rax) /* Fixup the gdt base address */
742     - leaq efi32_boot_gdt(%rip), %rax
743     - movl %eax, (%rsp)
744     -
745     - call __efi64_thunk
746     -
747     - addq $16, %rsp
748     - pop %rbx
749     - pop %rbp
750     - ret
751     -ENDPROC(efi64_thunk)
752     -#endif /* CONFIG_EFI_MIXED */
753     diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
754     new file mode 100644
755     index 000000000000..630384a4c14a
756     --- /dev/null
757     +++ b/arch/x86/boot/compressed/efi_thunk_64.S
758     @@ -0,0 +1,196 @@
759     +/*
760     + * Copyright (C) 2014, 2015 Intel Corporation; author Matt Fleming
761     + *
762     + * Early support for invoking 32-bit EFI services from a 64-bit kernel.
763     + *
764     + * Because this thunking occurs before ExitBootServices() we have to
765     + * restore the firmware's 32-bit GDT before we make EFI serivce calls,
766     + * since the firmware's 32-bit IDT is still currently installed and it
767     + * needs to be able to service interrupts.
768     + *
769     + * On the plus side, we don't have to worry about mangling 64-bit
770     + * addresses into 32-bits because we're executing with an identify
771     + * mapped pagetable and haven't transitioned to 64-bit virtual addresses
772     + * yet.
773     + */
774     +
775     +#include <linux/linkage.h>
776     +#include <asm/msr.h>
777     +#include <asm/page_types.h>
778     +#include <asm/processor-flags.h>
779     +#include <asm/segment.h>
780     +
781     + .code64
782     + .text
783     +ENTRY(efi64_thunk)
784     + push %rbp
785     + push %rbx
786     +
787     + subq $8, %rsp
788     + leaq efi_exit32(%rip), %rax
789     + movl %eax, 4(%rsp)
790     + leaq efi_gdt64(%rip), %rax
791     + movl %eax, (%rsp)
792     + movl %eax, 2(%rax) /* Fixup the gdt base address */
793     +
794     + movl %ds, %eax
795     + push %rax
796     + movl %es, %eax
797     + push %rax
798     + movl %ss, %eax
799     + push %rax
800     +
801     + /*
802     + * Convert x86-64 ABI params to i386 ABI
803     + */
804     + subq $32, %rsp
805     + movl %esi, 0x0(%rsp)
806     + movl %edx, 0x4(%rsp)
807     + movl %ecx, 0x8(%rsp)
808     + movq %r8, %rsi
809     + movl %esi, 0xc(%rsp)
810     + movq %r9, %rsi
811     + movl %esi, 0x10(%rsp)
812     +
813     + sgdt save_gdt(%rip)
814     +
815     + leaq 1f(%rip), %rbx
816     + movq %rbx, func_rt_ptr(%rip)
817     +
818     + /*
819     + * Switch to gdt with 32-bit segments. This is the firmware GDT
820     + * that was installed when the kernel started executing. This
821     + * pointer was saved at the EFI stub entry point in head_64.S.
822     + */
823     + leaq efi32_boot_gdt(%rip), %rax
824     + lgdt (%rax)
825     +
826     + pushq $__KERNEL_CS
827     + leaq efi_enter32(%rip), %rax
828     + pushq %rax
829     + lretq
830     +
831     +1: addq $32, %rsp
832     +
833     + lgdt save_gdt(%rip)
834     +
835     + pop %rbx
836     + movl %ebx, %ss
837     + pop %rbx
838     + movl %ebx, %es
839     + pop %rbx
840     + movl %ebx, %ds
841     +
842     + /*
843     + * Convert 32-bit status code into 64-bit.
844     + */
845     + test %rax, %rax
846     + jz 1f
847     + movl %eax, %ecx
848     + andl $0x0fffffff, %ecx
849     + andl $0xf0000000, %eax
850     + shl $32, %rax
851     + or %rcx, %rax
852     +1:
853     + addq $8, %rsp
854     + pop %rbx
855     + pop %rbp
856     + ret
857     +ENDPROC(efi64_thunk)
858     +
859     +ENTRY(efi_exit32)
860     + movq func_rt_ptr(%rip), %rax
861     + push %rax
862     + mov %rdi, %rax
863     + ret
864     +ENDPROC(efi_exit32)
865     +
866     + .code32
867     +/*
868     + * EFI service pointer must be in %edi.
869     + *
870     + * The stack should represent the 32-bit calling convention.
871     + */
872     +ENTRY(efi_enter32)
873     + movl $__KERNEL_DS, %eax
874     + movl %eax, %ds
875     + movl %eax, %es
876     + movl %eax, %ss
877     +
878     + /* Reload pgtables */
879     + movl %cr3, %eax
880     + movl %eax, %cr3
881     +
882     + /* Disable paging */
883     + movl %cr0, %eax
884     + btrl $X86_CR0_PG_BIT, %eax
885     + movl %eax, %cr0
886     +
887     + /* Disable long mode via EFER */
888     + movl $MSR_EFER, %ecx
889     + rdmsr
890     + btrl $_EFER_LME, %eax
891     + wrmsr
892     +
893     + call *%edi
894     +
895     + /* We must preserve return value */
896     + movl %eax, %edi
897     +
898     + /*
899     + * Some firmware will return with interrupts enabled. Be sure to
900     + * disable them before we switch GDTs.
901     + */
902     + cli
903     +
904     + movl 56(%esp), %eax
905     + movl %eax, 2(%eax)
906     + lgdtl (%eax)
907     +
908     + movl %cr4, %eax
909     + btsl $(X86_CR4_PAE_BIT), %eax
910     + movl %eax, %cr4
911     +
912     + movl %cr3, %eax
913     + movl %eax, %cr3
914     +
915     + movl $MSR_EFER, %ecx
916     + rdmsr
917     + btsl $_EFER_LME, %eax
918     + wrmsr
919     +
920     + xorl %eax, %eax
921     + lldt %ax
922     +
923     + movl 60(%esp), %eax
924     + pushl $__KERNEL_CS
925     + pushl %eax
926     +
927     + /* Enable paging */
928     + movl %cr0, %eax
929     + btsl $X86_CR0_PG_BIT, %eax
930     + movl %eax, %cr0
931     + lret
932     +ENDPROC(efi_enter32)
933     +
934     + .data
935     + .balign 8
936     + .global efi32_boot_gdt
937     +efi32_boot_gdt: .word 0
938     + .quad 0
939     +
940     +save_gdt: .word 0
941     + .quad 0
942     +func_rt_ptr: .quad 0
943     +
944     + .global efi_gdt64
945     +efi_gdt64:
946     + .word efi_gdt64_end - efi_gdt64
947     + .long 0 /* Filled out by user */
948     + .word 0
949     + .quad 0x0000000000000000 /* NULL descriptor */
950     + .quad 0x00af9a000000ffff /* __KERNEL_CS */
951     + .quad 0x00cf92000000ffff /* __KERNEL_DS */
952     + .quad 0x0080890000000000 /* TS descriptor */
953     + .quad 0x0000000000000000 /* TS continued */
954     +efi_gdt64_end:
955     diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
956     index a142e77693e1..a3eadfdc3e04 100644
957     --- a/arch/x86/kernel/acpi/boot.c
958     +++ b/arch/x86/kernel/acpi/boot.c
959     @@ -604,18 +604,24 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
960    
961     int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
962     {
963     - int irq;
964     + int rc, irq, trigger, polarity;
965    
966     if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
967     *irqp = gsi;
968     - } else {
969     - irq = mp_map_gsi_to_irq(gsi,
970     - IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
971     - if (irq < 0)
972     - return -1;
973     - *irqp = irq;
974     + return 0;
975     }
976     - return 0;
977     +
978     + rc = acpi_get_override_irq(gsi, &trigger, &polarity);
979     + if (rc == 0) {
980     + trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
981     + polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
982     + irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
983     + if (irq >= 0) {
984     + *irqp = irq;
985     + return 0;
986     + }
987     + }
988     + return -1;
989     }
990     EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
991    
992     diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c
993     index 0ee5025e0fa4..8bb9a611ca23 100644
994     --- a/arch/x86/kernel/pmc_atom.c
995     +++ b/arch/x86/kernel/pmc_atom.c
996     @@ -217,6 +217,8 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc, struct pci_dev *pdev)
997     if (!dir)
998     return -ENOMEM;
999    
1000     + pmc->dbgfs_dir = dir;
1001     +
1002     f = debugfs_create_file("dev_state", S_IFREG | S_IRUGO,
1003     dir, pmc, &pmc_dev_state_ops);
1004     if (!f) {
1005     @@ -229,7 +231,7 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc, struct pci_dev *pdev)
1006     dev_err(&pdev->dev, "sleep_state register failed\n");
1007     goto err;
1008     }
1009     - pmc->dbgfs_dir = dir;
1010     +
1011     return 0;
1012     err:
1013     pmc_dbgfs_unregister(pmc);
1014     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
1015     index 506488cfa385..8b92cf4b165a 100644
1016     --- a/arch/x86/kvm/x86.c
1017     +++ b/arch/x86/kvm/x86.c
1018     @@ -1237,21 +1237,22 @@ void kvm_track_tsc_matching(struct kvm_vcpu *vcpu)
1019     {
1020     #ifdef CONFIG_X86_64
1021     bool vcpus_matched;
1022     - bool do_request = false;
1023     struct kvm_arch *ka = &vcpu->kvm->arch;
1024     struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
1025    
1026     vcpus_matched = (ka->nr_vcpus_matched_tsc + 1 ==
1027     atomic_read(&vcpu->kvm->online_vcpus));
1028    
1029     - if (vcpus_matched && gtod->clock.vclock_mode == VCLOCK_TSC)
1030     - if (!ka->use_master_clock)
1031     - do_request = 1;
1032     -
1033     - if (!vcpus_matched && ka->use_master_clock)
1034     - do_request = 1;
1035     -
1036     - if (do_request)
1037     + /*
1038     + * Once the masterclock is enabled, always perform request in
1039     + * order to update it.
1040     + *
1041     + * In order to enable masterclock, the host clocksource must be TSC
1042     + * and the vcpus need to have matched TSCs. When that happens,
1043     + * perform request to enable masterclock.
1044     + */
1045     + if (ka->use_master_clock ||
1046     + (gtod->clock.vclock_mode == VCLOCK_TSC && vcpus_matched))
1047     kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);
1048    
1049     trace_kvm_track_tsc(vcpu->vcpu_id, ka->nr_vcpus_matched_tsc,
1050     diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
1051     index 207d9aef662d..448ee8912d9b 100644
1052     --- a/arch/x86/mm/gup.c
1053     +++ b/arch/x86/mm/gup.c
1054     @@ -172,7 +172,7 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
1055     */
1056     if (pmd_none(pmd) || pmd_trans_splitting(pmd))
1057     return 0;
1058     - if (unlikely(pmd_large(pmd))) {
1059     + if (unlikely(pmd_large(pmd) || !pmd_present(pmd))) {
1060     /*
1061     * NUMA hinting faults need to be handled in the GUP
1062     * slowpath for accounting purposes and so that they
1063     diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
1064     index 8b977ebf9388..006cc914994b 100644
1065     --- a/arch/x86/mm/hugetlbpage.c
1066     +++ b/arch/x86/mm/hugetlbpage.c
1067     @@ -66,9 +66,15 @@ follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
1068     return ERR_PTR(-EINVAL);
1069     }
1070    
1071     +/*
1072     + * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal
1073     + * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry.
1074     + * Otherwise, returns 0.
1075     + */
1076     int pmd_huge(pmd_t pmd)
1077     {
1078     - return !!(pmd_val(pmd) & _PAGE_PSE);
1079     + return !pmd_none(pmd) &&
1080     + (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT;
1081     }
1082    
1083     int pud_huge(pud_t pud)
1084     diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
1085     index 919b91205cd4..df4552bd239e 100644
1086     --- a/arch/x86/mm/mmap.c
1087     +++ b/arch/x86/mm/mmap.c
1088     @@ -35,12 +35,12 @@ struct va_alignment __read_mostly va_align = {
1089     .flags = -1,
1090     };
1091    
1092     -static unsigned int stack_maxrandom_size(void)
1093     +static unsigned long stack_maxrandom_size(void)
1094     {
1095     - unsigned int max = 0;
1096     + unsigned long max = 0;
1097     if ((current->flags & PF_RANDOMIZE) &&
1098     !(current->personality & ADDR_NO_RANDOMIZE)) {
1099     - max = ((-1U) & STACK_RND_MASK) << PAGE_SHIFT;
1100     + max = ((-1UL) & STACK_RND_MASK) << PAGE_SHIFT;
1101     }
1102    
1103     return max;
1104     diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
1105     index 093f5f4272d3..6b3cf7c4e5c2 100644
1106     --- a/arch/x86/pci/xen.c
1107     +++ b/arch/x86/pci/xen.c
1108     @@ -452,52 +452,6 @@ int __init pci_xen_hvm_init(void)
1109     }
1110    
1111     #ifdef CONFIG_XEN_DOM0
1112     -static __init void xen_setup_acpi_sci(void)
1113     -{
1114     - int rc;
1115     - int trigger, polarity;
1116     - int gsi = acpi_sci_override_gsi;
1117     - int irq = -1;
1118     - int gsi_override = -1;
1119     -
1120     - if (!gsi)
1121     - return;
1122     -
1123     - rc = acpi_get_override_irq(gsi, &trigger, &polarity);
1124     - if (rc) {
1125     - printk(KERN_WARNING "xen: acpi_get_override_irq failed for acpi"
1126     - " sci, rc=%d\n", rc);
1127     - return;
1128     - }
1129     - trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
1130     - polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
1131     -
1132     - printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d "
1133     - "polarity=%d\n", gsi, trigger, polarity);
1134     -
1135     - /* Before we bind the GSI to a Linux IRQ, check whether
1136     - * we need to override it with bus_irq (IRQ) value. Usually for
1137     - * IRQs below IRQ_LEGACY_IRQ this holds IRQ == GSI, as so:
1138     - * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level)
1139     - * but there are oddballs where the IRQ != GSI:
1140     - * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level)
1141     - * which ends up being: gsi_to_irq[9] == 20
1142     - * (which is what acpi_gsi_to_irq ends up calling when starting the
1143     - * the ACPI interpreter and keels over since IRQ 9 has not been
1144     - * setup as we had setup IRQ 20 for it).
1145     - */
1146     - if (acpi_gsi_to_irq(gsi, &irq) == 0) {
1147     - /* Use the provided value if it's valid. */
1148     - if (irq >= 0)
1149     - gsi_override = irq;
1150     - }
1151     -
1152     - gsi = xen_register_gsi(gsi, gsi_override, trigger, polarity);
1153     - printk(KERN_INFO "xen: acpi sci %d\n", gsi);
1154     -
1155     - return;
1156     -}
1157     -
1158     int __init pci_xen_initial_domain(void)
1159     {
1160     int irq;
1161     @@ -509,7 +463,6 @@ int __init pci_xen_initial_domain(void)
1162     x86_msi.msi_mask_irq = xen_nop_msi_mask_irq;
1163     x86_msi.msix_mask_irq = xen_nop_msix_mask_irq;
1164     #endif
1165     - xen_setup_acpi_sci();
1166     __acpi_register_gsi = acpi_register_gsi_xen;
1167     /* Pre-allocate legacy irqs */
1168     for (irq = 0; irq < nr_legacy_irqs(); irq++) {
1169     diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
1170     index 5fcda7272550..86d0f9e08dd9 100644
1171     --- a/arch/x86/platform/efi/efi_stub_64.S
1172     +++ b/arch/x86/platform/efi/efi_stub_64.S
1173     @@ -91,167 +91,6 @@ ENTRY(efi_call)
1174     ret
1175     ENDPROC(efi_call)
1176    
1177     -#ifdef CONFIG_EFI_MIXED
1178     -
1179     -/*
1180     - * We run this function from the 1:1 mapping.
1181     - *
1182     - * This function must be invoked with a 1:1 mapped stack.
1183     - */
1184     -ENTRY(__efi64_thunk)
1185     - movl %ds, %eax
1186     - push %rax
1187     - movl %es, %eax
1188     - push %rax
1189     - movl %ss, %eax
1190     - push %rax
1191     -
1192     - subq $32, %rsp
1193     - movl %esi, 0x0(%rsp)
1194     - movl %edx, 0x4(%rsp)
1195     - movl %ecx, 0x8(%rsp)
1196     - movq %r8, %rsi
1197     - movl %esi, 0xc(%rsp)
1198     - movq %r9, %rsi
1199     - movl %esi, 0x10(%rsp)
1200     -
1201     - sgdt save_gdt(%rip)
1202     -
1203     - leaq 1f(%rip), %rbx
1204     - movq %rbx, func_rt_ptr(%rip)
1205     -
1206     - /* Switch to gdt with 32-bit segments */
1207     - movl 64(%rsp), %eax
1208     - lgdt (%rax)
1209     -
1210     - leaq efi_enter32(%rip), %rax
1211     - pushq $__KERNEL_CS
1212     - pushq %rax
1213     - lretq
1214     -
1215     -1: addq $32, %rsp
1216     -
1217     - lgdt save_gdt(%rip)
1218     -
1219     - pop %rbx
1220     - movl %ebx, %ss
1221     - pop %rbx
1222     - movl %ebx, %es
1223     - pop %rbx
1224     - movl %ebx, %ds
1225     -
1226     - /*
1227     - * Convert 32-bit status code into 64-bit.
1228     - */
1229     - test %rax, %rax
1230     - jz 1f
1231     - movl %eax, %ecx
1232     - andl $0x0fffffff, %ecx
1233     - andl $0xf0000000, %eax
1234     - shl $32, %rax
1235     - or %rcx, %rax
1236     -1:
1237     - ret
1238     -ENDPROC(__efi64_thunk)
1239     -
1240     -ENTRY(efi_exit32)
1241     - movq func_rt_ptr(%rip), %rax
1242     - push %rax
1243     - mov %rdi, %rax
1244     - ret
1245     -ENDPROC(efi_exit32)
1246     -
1247     - .code32
1248     -/*
1249     - * EFI service pointer must be in %edi.
1250     - *
1251     - * The stack should represent the 32-bit calling convention.
1252     - */
1253     -ENTRY(efi_enter32)
1254     - movl $__KERNEL_DS, %eax
1255     - movl %eax, %ds
1256     - movl %eax, %es
1257     - movl %eax, %ss
1258     -
1259     - /* Reload pgtables */
1260     - movl %cr3, %eax
1261     - movl %eax, %cr3
1262     -
1263     - /* Disable paging */
1264     - movl %cr0, %eax
1265     - btrl $X86_CR0_PG_BIT, %eax
1266     - movl %eax, %cr0
1267     -
1268     - /* Disable long mode via EFER */
1269     - movl $MSR_EFER, %ecx
1270     - rdmsr
1271     - btrl $_EFER_LME, %eax
1272     - wrmsr
1273     -
1274     - call *%edi
1275     -
1276     - /* We must preserve return value */
1277     - movl %eax, %edi
1278     -
1279     - /*
1280     - * Some firmware will return with interrupts enabled. Be sure to
1281     - * disable them before we switch GDTs.
1282     - */
1283     - cli
1284     -
1285     - movl 68(%esp), %eax
1286     - movl %eax, 2(%eax)
1287     - lgdtl (%eax)
1288     -
1289     - movl %cr4, %eax
1290     - btsl $(X86_CR4_PAE_BIT), %eax
1291     - movl %eax, %cr4
1292     -
1293     - movl %cr3, %eax
1294     - movl %eax, %cr3
1295     -
1296     - movl $MSR_EFER, %ecx
1297     - rdmsr
1298     - btsl $_EFER_LME, %eax
1299     - wrmsr
1300     -
1301     - xorl %eax, %eax
1302     - lldt %ax
1303     -
1304     - movl 72(%esp), %eax
1305     - pushl $__KERNEL_CS
1306     - pushl %eax
1307     -
1308     - /* Enable paging */
1309     - movl %cr0, %eax
1310     - btsl $X86_CR0_PG_BIT, %eax
1311     - movl %eax, %cr0
1312     - lret
1313     -ENDPROC(efi_enter32)
1314     -
1315     - .data
1316     - .balign 8
1317     - .global efi32_boot_gdt
1318     -efi32_boot_gdt: .word 0
1319     - .quad 0
1320     -
1321     -save_gdt: .word 0
1322     - .quad 0
1323     -func_rt_ptr: .quad 0
1324     -
1325     - .global efi_gdt64
1326     -efi_gdt64:
1327     - .word efi_gdt64_end - efi_gdt64
1328     - .long 0 /* Filled out by user */
1329     - .word 0
1330     - .quad 0x0000000000000000 /* NULL descriptor */
1331     - .quad 0x00af9a000000ffff /* __KERNEL_CS */
1332     - .quad 0x00cf92000000ffff /* __KERNEL_DS */
1333     - .quad 0x0080890000000000 /* TS descriptor */
1334     - .quad 0x0000000000000000 /* TS continued */
1335     -efi_gdt64_end:
1336     -#endif /* CONFIG_EFI_MIXED */
1337     -
1338     .data
1339     ENTRY(efi_scratch)
1340     .fill 3,8,0
1341     diff --git a/arch/x86/platform/efi/efi_thunk_64.S b/arch/x86/platform/efi/efi_thunk_64.S
1342     index 8806fa73e6e6..ff85d28c50f2 100644
1343     --- a/arch/x86/platform/efi/efi_thunk_64.S
1344     +++ b/arch/x86/platform/efi/efi_thunk_64.S
1345     @@ -1,9 +1,26 @@
1346     /*
1347     * Copyright (C) 2014 Intel Corporation; author Matt Fleming
1348     + *
1349     + * Support for invoking 32-bit EFI runtime services from a 64-bit
1350     + * kernel.
1351     + *
1352     + * The below thunking functions are only used after ExitBootServices()
1353     + * has been called. This simplifies things considerably as compared with
1354     + * the early EFI thunking because we can leave all the kernel state
1355     + * intact (GDT, IDT, etc) and simply invoke the the 32-bit EFI runtime
1356     + * services from __KERNEL32_CS. This means we can continue to service
1357     + * interrupts across an EFI mixed mode call.
1358     + *
1359     + * We do however, need to handle the fact that we're running in a full
1360     + * 64-bit virtual address space. Things like the stack and instruction
1361     + * addresses need to be accessible by the 32-bit firmware, so we rely on
1362     + * using the identity mappings in the EFI page table to access the stack
1363     + * and kernel text (see efi_setup_page_tables()).
1364     */
1365    
1366     #include <linux/linkage.h>
1367     #include <asm/page_types.h>
1368     +#include <asm/segment.h>
1369    
1370     .text
1371     .code64
1372     @@ -33,14 +50,6 @@ ENTRY(efi64_thunk)
1373     leaq efi_exit32(%rip), %rbx
1374     subq %rax, %rbx
1375     movl %ebx, 8(%rsp)
1376     - leaq efi_gdt64(%rip), %rbx
1377     - subq %rax, %rbx
1378     - movl %ebx, 2(%ebx)
1379     - movl %ebx, 4(%rsp)
1380     - leaq efi_gdt32(%rip), %rbx
1381     - subq %rax, %rbx
1382     - movl %ebx, 2(%ebx)
1383     - movl %ebx, (%rsp)
1384    
1385     leaq __efi64_thunk(%rip), %rbx
1386     subq %rax, %rbx
1387     @@ -52,14 +61,92 @@ ENTRY(efi64_thunk)
1388     retq
1389     ENDPROC(efi64_thunk)
1390    
1391     - .data
1392     -efi_gdt32:
1393     - .word efi_gdt32_end - efi_gdt32
1394     - .long 0 /* Filled out above */
1395     - .word 0
1396     - .quad 0x0000000000000000 /* NULL descriptor */
1397     - .quad 0x00cf9a000000ffff /* __KERNEL_CS */
1398     - .quad 0x00cf93000000ffff /* __KERNEL_DS */
1399     -efi_gdt32_end:
1400     +/*
1401     + * We run this function from the 1:1 mapping.
1402     + *
1403     + * This function must be invoked with a 1:1 mapped stack.
1404     + */
1405     +ENTRY(__efi64_thunk)
1406     + movl %ds, %eax
1407     + push %rax
1408     + movl %es, %eax
1409     + push %rax
1410     + movl %ss, %eax
1411     + push %rax
1412     +
1413     + subq $32, %rsp
1414     + movl %esi, 0x0(%rsp)
1415     + movl %edx, 0x4(%rsp)
1416     + movl %ecx, 0x8(%rsp)
1417     + movq %r8, %rsi
1418     + movl %esi, 0xc(%rsp)
1419     + movq %r9, %rsi
1420     + movl %esi, 0x10(%rsp)
1421     +
1422     + leaq 1f(%rip), %rbx
1423     + movq %rbx, func_rt_ptr(%rip)
1424     +
1425     + /* Switch to 32-bit descriptor */
1426     + pushq $__KERNEL32_CS
1427     + leaq efi_enter32(%rip), %rax
1428     + pushq %rax
1429     + lretq
1430     +
1431     +1: addq $32, %rsp
1432     +
1433     + pop %rbx
1434     + movl %ebx, %ss
1435     + pop %rbx
1436     + movl %ebx, %es
1437     + pop %rbx
1438     + movl %ebx, %ds
1439    
1440     + /*
1441     + * Convert 32-bit status code into 64-bit.
1442     + */
1443     + test %rax, %rax
1444     + jz 1f
1445     + movl %eax, %ecx
1446     + andl $0x0fffffff, %ecx
1447     + andl $0xf0000000, %eax
1448     + shl $32, %rax
1449     + or %rcx, %rax
1450     +1:
1451     + ret
1452     +ENDPROC(__efi64_thunk)
1453     +
1454     +ENTRY(efi_exit32)
1455     + movq func_rt_ptr(%rip), %rax
1456     + push %rax
1457     + mov %rdi, %rax
1458     + ret
1459     +ENDPROC(efi_exit32)
1460     +
1461     + .code32
1462     +/*
1463     + * EFI service pointer must be in %edi.
1464     + *
1465     + * The stack should represent the 32-bit calling convention.
1466     + */
1467     +ENTRY(efi_enter32)
1468     + movl $__KERNEL_DS, %eax
1469     + movl %eax, %ds
1470     + movl %eax, %es
1471     + movl %eax, %ss
1472     +
1473     + call *%edi
1474     +
1475     + /* We must preserve return value */
1476     + movl %eax, %edi
1477     +
1478     + movl 72(%esp), %eax
1479     + pushl $__KERNEL_CS
1480     + pushl %eax
1481     +
1482     + lret
1483     +ENDPROC(efi_enter32)
1484     +
1485     + .data
1486     + .balign 8
1487     +func_rt_ptr: .quad 0
1488     efi_saved_sp: .quad 0
1489     diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
1490     index ff18dab6b585..702ae29b8d90 100644
1491     --- a/block/blk-mq-tag.c
1492     +++ b/block/blk-mq-tag.c
1493     @@ -500,6 +500,7 @@ static int bt_alloc(struct blk_mq_bitmap_tags *bt, unsigned int depth,
1494     bt->bs = kzalloc(BT_WAIT_QUEUES * sizeof(*bt->bs), GFP_KERNEL);
1495     if (!bt->bs) {
1496     kfree(bt->map);
1497     + bt->map = NULL;
1498     return -ENOMEM;
1499     }
1500    
1501     diff --git a/block/blk-throttle.c b/block/blk-throttle.c
1502     index 9273d0969ebd..5b9c6d5c3636 100644
1503     --- a/block/blk-throttle.c
1504     +++ b/block/blk-throttle.c
1505     @@ -1292,6 +1292,9 @@ static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,
1506     struct blkg_rwstat rwstat = { }, tmp;
1507     int i, cpu;
1508    
1509     + if (tg->stats_cpu == NULL)
1510     + return 0;
1511     +
1512     for_each_possible_cpu(cpu) {
1513     struct tg_stats_cpu *sc = per_cpu_ptr(tg->stats_cpu, cpu);
1514    
1515     diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
1516     index 6f2751d305de..5da8e6e9ab4b 100644
1517     --- a/block/cfq-iosched.c
1518     +++ b/block/cfq-iosched.c
1519     @@ -3590,6 +3590,11 @@ retry:
1520    
1521     blkcg = bio_blkcg(bio);
1522     cfqg = cfq_lookup_create_cfqg(cfqd, blkcg);
1523     + if (!cfqg) {
1524     + cfqq = &cfqd->oom_cfqq;
1525     + goto out;
1526     + }
1527     +
1528     cfqq = cic_to_cfqq(cic, is_sync);
1529    
1530     /*
1531     @@ -3626,7 +3631,7 @@ retry:
1532     } else
1533     cfqq = &cfqd->oom_cfqq;
1534     }
1535     -
1536     +out:
1537     if (new_cfqq)
1538     kmem_cache_free(cfq_pool, new_cfqq);
1539    
1540     @@ -3656,12 +3661,17 @@ static struct cfq_queue *
1541     cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic,
1542     struct bio *bio, gfp_t gfp_mask)
1543     {
1544     - const int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
1545     - const int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
1546     + int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
1547     + int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
1548     struct cfq_queue **async_cfqq = NULL;
1549     struct cfq_queue *cfqq = NULL;
1550    
1551     if (!is_sync) {
1552     + if (!ioprio_valid(cic->ioprio)) {
1553     + struct task_struct *tsk = current;
1554     + ioprio = task_nice_ioprio(tsk);
1555     + ioprio_class = task_nice_ioclass(tsk);
1556     + }
1557     async_cfqq = cfq_async_queue_prio(cfqd, ioprio_class, ioprio);
1558     cfqq = *async_cfqq;
1559     }
1560     diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
1561     index 93d160661f4c..41e9c199e874 100644
1562     --- a/drivers/acpi/acpi_lpss.c
1563     +++ b/drivers/acpi/acpi_lpss.c
1564     @@ -105,7 +105,7 @@ static void lpss_uart_setup(struct lpss_private_data *pdata)
1565     }
1566     }
1567    
1568     -static void byt_i2c_setup(struct lpss_private_data *pdata)
1569     +static void lpss_deassert_reset(struct lpss_private_data *pdata)
1570     {
1571     unsigned int offset;
1572     u32 val;
1573     @@ -114,9 +114,18 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
1574     val = readl(pdata->mmio_base + offset);
1575     val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC;
1576     writel(val, pdata->mmio_base + offset);
1577     +}
1578     +
1579     +#define LPSS_I2C_ENABLE 0x6c
1580     +
1581     +static void byt_i2c_setup(struct lpss_private_data *pdata)
1582     +{
1583     + lpss_deassert_reset(pdata);
1584    
1585     if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset))
1586     pdata->fixed_clk_rate = 133000000;
1587     +
1588     + writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
1589     }
1590    
1591     static struct lpss_device_desc lpt_dev_desc = {
1592     @@ -166,6 +175,12 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
1593     .setup = byt_i2c_setup,
1594     };
1595    
1596     +static struct lpss_device_desc bsw_spi_dev_desc = {
1597     + .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
1598     + .prv_offset = 0x400,
1599     + .setup = lpss_deassert_reset,
1600     +};
1601     +
1602     #else
1603    
1604     #define LPSS_ADDR(desc) (0UL)
1605     @@ -198,7 +213,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
1606     /* Braswell LPSS devices */
1607     { "80862288", LPSS_ADDR(byt_pwm_dev_desc) },
1608     { "8086228A", LPSS_ADDR(byt_uart_dev_desc) },
1609     - { "8086228E", LPSS_ADDR(byt_spi_dev_desc) },
1610     + { "8086228E", LPSS_ADDR(bsw_spi_dev_desc) },
1611     { "808622C1", LPSS_ADDR(byt_i2c_dev_desc) },
1612    
1613     { "INT3430", LPSS_ADDR(lpt_dev_desc) },
1614     diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
1615     index 086240cd29c3..fe1678c4ff89 100644
1616     --- a/drivers/bluetooth/ath3k.c
1617     +++ b/drivers/bluetooth/ath3k.c
1618     @@ -106,6 +106,7 @@ static const struct usb_device_id ath3k_table[] = {
1619     { USB_DEVICE(0x13d3, 0x3393) },
1620     { USB_DEVICE(0x13d3, 0x3402) },
1621     { USB_DEVICE(0x13d3, 0x3408) },
1622     + { USB_DEVICE(0x13d3, 0x3423) },
1623     { USB_DEVICE(0x13d3, 0x3432) },
1624    
1625     /* Atheros AR5BBU12 with sflash firmware */
1626     @@ -158,6 +159,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
1627     { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
1628     { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
1629     { USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 },
1630     + { USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 },
1631     { USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 },
1632    
1633     /* Atheros AR5BBU22 with sflash firmware */
1634     @@ -170,6 +172,8 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
1635     #define USB_REQ_DFU_DNLOAD 1
1636     #define BULK_SIZE 4096
1637     #define FW_HDR_SIZE 20
1638     +#define TIMEGAP_USEC_MIN 50
1639     +#define TIMEGAP_USEC_MAX 100
1640    
1641     static int ath3k_load_firmware(struct usb_device *udev,
1642     const struct firmware *firmware)
1643     @@ -201,6 +205,9 @@ static int ath3k_load_firmware(struct usb_device *udev,
1644     pipe = usb_sndbulkpipe(udev, 0x02);
1645    
1646     while (count) {
1647     + /* workaround the compatibility issue with xHCI controller*/
1648     + usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
1649     +
1650     size = min_t(uint, count, BULK_SIZE);
1651     memcpy(send_buf, firmware->data + sent, size);
1652    
1653     @@ -298,6 +305,9 @@ static int ath3k_load_fwfile(struct usb_device *udev,
1654     pipe = usb_sndbulkpipe(udev, 0x02);
1655    
1656     while (count) {
1657     + /* workaround the compatibility issue with xHCI controller*/
1658     + usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
1659     +
1660     size = min_t(uint, count, BULK_SIZE);
1661     memcpy(send_buf, firmware->data + sent, size);
1662    
1663     diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1664     index 091c813df8e9..f0e2f721c8ce 100644
1665     --- a/drivers/bluetooth/btusb.c
1666     +++ b/drivers/bluetooth/btusb.c
1667     @@ -107,15 +107,23 @@ static const struct usb_device_id btusb_table[] = {
1668     { USB_DEVICE(0x0b05, 0x17cb) },
1669     { USB_DEVICE(0x413c, 0x8197) },
1670    
1671     + /* Broadcom BCM20702B0 (Dynex/Insignia) */
1672     + { USB_DEVICE(0x19ff, 0x0239), .driver_info = BTUSB_BCM_PATCHRAM },
1673     +
1674     /* Foxconn - Hon Hai */
1675     { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
1676    
1677     + /* Lite-On Technology - Broadcom based */
1678     + { USB_VENDOR_AND_INTERFACE_INFO(0x04ca, 0xff, 0x01, 0x01),
1679     + .driver_info = BTUSB_BCM_PATCHRAM },
1680     +
1681     /* Broadcom devices with vendor specific id */
1682     { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01),
1683     .driver_info = BTUSB_BCM_PATCHRAM },
1684    
1685     /* ASUSTek Computer - Broadcom based */
1686     - { USB_VENDOR_AND_INTERFACE_INFO(0x0b05, 0xff, 0x01, 0x01) },
1687     + { USB_VENDOR_AND_INTERFACE_INFO(0x0b05, 0xff, 0x01, 0x01),
1688     + .driver_info = BTUSB_BCM_PATCHRAM },
1689    
1690     /* Belkin F8065bf - Broadcom based */
1691     { USB_VENDOR_AND_INTERFACE_INFO(0x050d, 0xff, 0x01, 0x01) },
1692     @@ -183,6 +191,7 @@ static const struct usb_device_id blacklist_table[] = {
1693     { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
1694     { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
1695     { USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 },
1696     + { USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 },
1697     { USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 },
1698    
1699     /* Atheros AR5BBU12 with sflash firmware */
1700     diff --git a/drivers/char/random.c b/drivers/char/random.c
1701     index 04645c09fe5e..9cd6968e2f92 100644
1702     --- a/drivers/char/random.c
1703     +++ b/drivers/char/random.c
1704     @@ -569,19 +569,19 @@ static void fast_mix(struct fast_pool *f)
1705     __u32 c = f->pool[2], d = f->pool[3];
1706    
1707     a += b; c += d;
1708     - b = rol32(a, 6); d = rol32(c, 27);
1709     + b = rol32(b, 6); d = rol32(d, 27);
1710     d ^= a; b ^= c;
1711    
1712     a += b; c += d;
1713     - b = rol32(a, 16); d = rol32(c, 14);
1714     + b = rol32(b, 16); d = rol32(d, 14);
1715     d ^= a; b ^= c;
1716    
1717     a += b; c += d;
1718     - b = rol32(a, 6); d = rol32(c, 27);
1719     + b = rol32(b, 6); d = rol32(d, 27);
1720     d ^= a; b ^= c;
1721    
1722     a += b; c += d;
1723     - b = rol32(a, 16); d = rol32(c, 14);
1724     + b = rol32(b, 16); d = rol32(d, 14);
1725     d ^= a; b ^= c;
1726    
1727     f->pool[0] = a; f->pool[1] = b;
1728     diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
1729     index 6af17002a115..cfb9089887bd 100644
1730     --- a/drivers/char/tpm/tpm-interface.c
1731     +++ b/drivers/char/tpm/tpm-interface.c
1732     @@ -1122,7 +1122,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1733    
1734     /* Make chip available */
1735     spin_lock(&driver_lock);
1736     - list_add_rcu(&chip->list, &tpm_chip_list);
1737     + list_add_tail_rcu(&chip->list, &tpm_chip_list);
1738     spin_unlock(&driver_lock);
1739    
1740     return chip;
1741     diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
1742     index 77272925dee6..503a85ae176c 100644
1743     --- a/drivers/char/tpm/tpm_i2c_atmel.c
1744     +++ b/drivers/char/tpm/tpm_i2c_atmel.c
1745     @@ -168,6 +168,10 @@ static int i2c_atmel_probe(struct i2c_client *client,
1746    
1747     chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
1748     GFP_KERNEL);
1749     + if (!chip->vendor.priv) {
1750     + rc = -ENOMEM;
1751     + goto out_err;
1752     + }
1753    
1754     /* Default timeouts */
1755     chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
1756     diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
1757     index 7b158efd49f7..23c7b137a7fd 100644
1758     --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
1759     +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
1760     @@ -538,6 +538,11 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
1761    
1762     chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
1763     GFP_KERNEL);
1764     + if (!chip->vendor.priv) {
1765     + rc = -ENOMEM;
1766     + goto out_err;
1767     + }
1768     +
1769     init_waitqueue_head(&chip->vendor.read_queue);
1770     init_waitqueue_head(&chip->vendor.int_queue);
1771    
1772     diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
1773     index 4669e3713428..7d1c540fa26a 100644
1774     --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
1775     +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
1776     @@ -487,7 +487,7 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf,
1777     if (burstcnt < 0)
1778     return burstcnt;
1779     size = min_t(int, len - i - 1, burstcnt);
1780     - ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf, size);
1781     + ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf + i, size);
1782     if (ret < 0)
1783     goto out_err;
1784    
1785     diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
1786     index af74c57e5090..eff9d5870034 100644
1787     --- a/drivers/char/tpm/tpm_ibmvtpm.c
1788     +++ b/drivers/char/tpm/tpm_ibmvtpm.c
1789     @@ -148,7 +148,8 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
1790     crq.len = (u16)count;
1791     crq.data = ibmvtpm->rtce_dma_handle;
1792    
1793     - rc = ibmvtpm_send_crq(ibmvtpm->vdev, word[0], word[1]);
1794     + rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]),
1795     + cpu_to_be64(word[1]));
1796     if (rc != H_SUCCESS) {
1797     dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
1798     rc = 0;
1799     @@ -186,7 +187,8 @@ static int ibmvtpm_crq_get_rtce_size(struct ibmvtpm_dev *ibmvtpm)
1800     crq.valid = (u8)IBMVTPM_VALID_CMD;
1801     crq.msg = (u8)VTPM_GET_RTCE_BUFFER_SIZE;
1802    
1803     - rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
1804     + rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
1805     + cpu_to_be64(buf[1]));
1806     if (rc != H_SUCCESS)
1807     dev_err(ibmvtpm->dev,
1808     "ibmvtpm_crq_get_rtce_size failed rc=%d\n", rc);
1809     @@ -212,7 +214,8 @@ static int ibmvtpm_crq_get_version(struct ibmvtpm_dev *ibmvtpm)
1810     crq.valid = (u8)IBMVTPM_VALID_CMD;
1811     crq.msg = (u8)VTPM_GET_VERSION;
1812    
1813     - rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
1814     + rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
1815     + cpu_to_be64(buf[1]));
1816     if (rc != H_SUCCESS)
1817     dev_err(ibmvtpm->dev,
1818     "ibmvtpm_crq_get_version failed rc=%d\n", rc);
1819     @@ -307,6 +310,14 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
1820     static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
1821     {
1822     struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
1823     +
1824     + /* ibmvtpm initializes at probe time, so the data we are
1825     + * asking for may not be set yet. Estimate that 4K required
1826     + * for TCE-mapped buffer in addition to CRQ.
1827     + */
1828     + if (!ibmvtpm)
1829     + return CRQ_RES_BUF_SIZE + PAGE_SIZE;
1830     +
1831     return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size;
1832     }
1833    
1834     @@ -327,7 +338,8 @@ static int tpm_ibmvtpm_suspend(struct device *dev)
1835     crq.valid = (u8)IBMVTPM_VALID_CMD;
1836     crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND;
1837    
1838     - rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
1839     + rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
1840     + cpu_to_be64(buf[1]));
1841     if (rc != H_SUCCESS)
1842     dev_err(ibmvtpm->dev,
1843     "tpm_ibmvtpm_suspend failed rc=%d\n", rc);
1844     @@ -472,11 +484,11 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
1845     case IBMVTPM_VALID_CMD:
1846     switch (crq->msg) {
1847     case VTPM_GET_RTCE_BUFFER_SIZE_RES:
1848     - if (crq->len <= 0) {
1849     + if (be16_to_cpu(crq->len) <= 0) {
1850     dev_err(ibmvtpm->dev, "Invalid rtce size\n");
1851     return;
1852     }
1853     - ibmvtpm->rtce_size = crq->len;
1854     + ibmvtpm->rtce_size = be16_to_cpu(crq->len);
1855     ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size,
1856     GFP_KERNEL);
1857     if (!ibmvtpm->rtce_buf) {
1858     @@ -497,11 +509,11 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
1859    
1860     return;
1861     case VTPM_GET_VERSION_RES:
1862     - ibmvtpm->vtpm_version = crq->data;
1863     + ibmvtpm->vtpm_version = be32_to_cpu(crq->data);
1864     return;
1865     case VTPM_TPM_COMMAND_RES:
1866     /* len of the data in rtce buffer */
1867     - ibmvtpm->res_len = crq->len;
1868     + ibmvtpm->res_len = be16_to_cpu(crq->len);
1869     wake_up_interruptible(&ibmvtpm->wq);
1870     return;
1871     default:
1872     diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
1873     index 2c46734b266d..51350cd0847e 100644
1874     --- a/drivers/char/tpm/tpm_tis.c
1875     +++ b/drivers/char/tpm/tpm_tis.c
1876     @@ -75,6 +75,10 @@ enum tis_defaults {
1877     #define TPM_DID_VID(l) (0x0F00 | ((l) << 12))
1878     #define TPM_RID(l) (0x0F04 | ((l) << 12))
1879    
1880     +struct priv_data {
1881     + bool irq_tested;
1882     +};
1883     +
1884     static LIST_HEAD(tis_chips);
1885     static DEFINE_MUTEX(tis_lock);
1886    
1887     @@ -338,12 +342,27 @@ out_err:
1888     return rc;
1889     }
1890    
1891     +static void disable_interrupts(struct tpm_chip *chip)
1892     +{
1893     + u32 intmask;
1894     +
1895     + intmask =
1896     + ioread32(chip->vendor.iobase +
1897     + TPM_INT_ENABLE(chip->vendor.locality));
1898     + intmask &= ~TPM_GLOBAL_INT_ENABLE;
1899     + iowrite32(intmask,
1900     + chip->vendor.iobase +
1901     + TPM_INT_ENABLE(chip->vendor.locality));
1902     + free_irq(chip->vendor.irq, chip);
1903     + chip->vendor.irq = 0;
1904     +}
1905     +
1906     /*
1907     * If interrupts are used (signaled by an irq set in the vendor structure)
1908     * tpm.c can skip polling for the data to be available as the interrupt is
1909     * waited for here
1910     */
1911     -static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
1912     +static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
1913     {
1914     int rc;
1915     u32 ordinal;
1916     @@ -373,6 +392,30 @@ out_err:
1917     return rc;
1918     }
1919    
1920     +static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
1921     +{
1922     + int rc, irq;
1923     + struct priv_data *priv = chip->vendor.priv;
1924     +
1925     + if (!chip->vendor.irq || priv->irq_tested)
1926     + return tpm_tis_send_main(chip, buf, len);
1927     +
1928     + /* Verify receipt of the expected IRQ */
1929     + irq = chip->vendor.irq;
1930     + chip->vendor.irq = 0;
1931     + rc = tpm_tis_send_main(chip, buf, len);
1932     + chip->vendor.irq = irq;
1933     + if (!priv->irq_tested)
1934     + msleep(1);
1935     + if (!priv->irq_tested) {
1936     + disable_interrupts(chip);
1937     + dev_err(chip->dev,
1938     + FW_BUG "TPM interrupt not working, polling instead\n");
1939     + }
1940     + priv->irq_tested = true;
1941     + return rc;
1942     +}
1943     +
1944     struct tis_vendor_timeout_override {
1945     u32 did_vid;
1946     unsigned long timeout_us[4];
1947     @@ -505,6 +548,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
1948     if (interrupt == 0)
1949     return IRQ_NONE;
1950    
1951     + ((struct priv_data *)chip->vendor.priv)->irq_tested = true;
1952     if (interrupt & TPM_INTF_DATA_AVAIL_INT)
1953     wake_up_interruptible(&chip->vendor.read_queue);
1954     if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
1955     @@ -534,9 +578,14 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
1956     u32 vendor, intfcaps, intmask;
1957     int rc, i, irq_s, irq_e, probe;
1958     struct tpm_chip *chip;
1959     + struct priv_data *priv;
1960    
1961     + priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
1962     + if (priv == NULL)
1963     + return -ENOMEM;
1964     if (!(chip = tpm_register_hardware(dev, &tpm_tis)))
1965     return -ENODEV;
1966     + chip->vendor.priv = priv;
1967    
1968     chip->vendor.iobase = ioremap(start, len);
1969     if (!chip->vendor.iobase) {
1970     @@ -605,19 +654,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
1971     if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
1972     dev_dbg(dev, "\tData Avail Int Support\n");
1973    
1974     - /* get the timeouts before testing for irqs */
1975     - if (tpm_get_timeouts(chip)) {
1976     - dev_err(dev, "Could not get TPM timeouts and durations\n");
1977     - rc = -ENODEV;
1978     - goto out_err;
1979     - }
1980     -
1981     - if (tpm_do_selftest(chip)) {
1982     - dev_err(dev, "TPM self test failed\n");
1983     - rc = -ENODEV;
1984     - goto out_err;
1985     - }
1986     -
1987     /* INTERRUPT Setup */
1988     init_waitqueue_head(&chip->vendor.read_queue);
1989     init_waitqueue_head(&chip->vendor.int_queue);
1990     @@ -719,6 +755,18 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
1991     }
1992     }
1993    
1994     + if (tpm_get_timeouts(chip)) {
1995     + dev_err(dev, "Could not get TPM timeouts and durations\n");
1996     + rc = -ENODEV;
1997     + goto out_err;
1998     + }
1999     +
2000     + if (tpm_do_selftest(chip)) {
2001     + dev_err(dev, "TPM self test failed\n");
2002     + rc = -ENODEV;
2003     + goto out_err;
2004     + }
2005     +
2006     INIT_LIST_HEAD(&chip->vendor.list);
2007     mutex_lock(&tis_lock);
2008     list_add(&chip->vendor.list, &tis_chips);
2009     diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
2010     index 32a3d25795d3..68ab42356d0e 100644
2011     --- a/drivers/clocksource/mtk_timer.c
2012     +++ b/drivers/clocksource/mtk_timer.c
2013     @@ -224,6 +224,8 @@ static void __init mtk_timer_init(struct device_node *node)
2014     }
2015     rate = clk_get_rate(clk);
2016    
2017     + mtk_timer_global_reset(evt);
2018     +
2019     if (request_irq(evt->dev.irq, mtk_timer_interrupt,
2020     IRQF_TIMER | IRQF_IRQPOLL, "mtk_timer", evt)) {
2021     pr_warn("failed to setup irq %d\n", evt->dev.irq);
2022     @@ -232,8 +234,6 @@ static void __init mtk_timer_init(struct device_node *node)
2023    
2024     evt->ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
2025    
2026     - mtk_timer_global_reset(evt);
2027     -
2028     /* Configure clock source */
2029     mtk_timer_setup(evt, GPT_CLK_SRC, TIMER_CTRL_OP_FREERUN);
2030     clocksource_mmio_init(evt->gpt_base + TIMER_CNT_REG(GPT_CLK_SRC),
2031     @@ -241,10 +241,11 @@ static void __init mtk_timer_init(struct device_node *node)
2032    
2033     /* Configure clock event */
2034     mtk_timer_setup(evt, GPT_CLK_EVT, TIMER_CTRL_OP_REPEAT);
2035     - mtk_timer_enable_irq(evt, GPT_CLK_EVT);
2036     -
2037     clockevents_config_and_register(&evt->dev, rate, 0x3,
2038     0xffffffff);
2039     +
2040     + mtk_timer_enable_irq(evt, GPT_CLK_EVT);
2041     +
2042     return;
2043    
2044     err_clk_disable:
2045     diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
2046     index 4473eba1d6b0..e3bf702b5588 100644
2047     --- a/drivers/cpufreq/cpufreq.c
2048     +++ b/drivers/cpufreq/cpufreq.c
2049     @@ -1409,9 +1409,10 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
2050     unsigned long flags;
2051     struct cpufreq_policy *policy;
2052    
2053     - read_lock_irqsave(&cpufreq_driver_lock, flags);
2054     + write_lock_irqsave(&cpufreq_driver_lock, flags);
2055     policy = per_cpu(cpufreq_cpu_data, cpu);
2056     - read_unlock_irqrestore(&cpufreq_driver_lock, flags);
2057     + per_cpu(cpufreq_cpu_data, cpu) = NULL;
2058     + write_unlock_irqrestore(&cpufreq_driver_lock, flags);
2059    
2060     if (!policy) {
2061     pr_debug("%s: No cpu_data found\n", __func__);
2062     @@ -1466,7 +1467,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
2063     }
2064     }
2065    
2066     - per_cpu(cpufreq_cpu_data, cpu) = NULL;
2067     return 0;
2068     }
2069    
2070     diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
2071     index 2fd53eaaec20..d6d425773fa4 100644
2072     --- a/drivers/cpufreq/s3c2416-cpufreq.c
2073     +++ b/drivers/cpufreq/s3c2416-cpufreq.c
2074     @@ -263,7 +263,7 @@ out:
2075     }
2076    
2077     #ifdef CONFIG_ARM_S3C2416_CPUFREQ_VCORESCALE
2078     -static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq)
2079     +static void s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq)
2080     {
2081     int count, v, i, found;
2082     struct cpufreq_frequency_table *pos;
2083     @@ -333,7 +333,7 @@ static struct notifier_block s3c2416_cpufreq_reboot_notifier = {
2084     .notifier_call = s3c2416_cpufreq_reboot_notifier_evt,
2085     };
2086    
2087     -static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
2088     +static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
2089     {
2090     struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
2091     struct cpufreq_frequency_table *pos;
2092     diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
2093     index d00f1cee4509..733aa5153e74 100644
2094     --- a/drivers/cpufreq/s3c24xx-cpufreq.c
2095     +++ b/drivers/cpufreq/s3c24xx-cpufreq.c
2096     @@ -144,11 +144,6 @@ static void s3c_cpufreq_setfvco(struct s3c_cpufreq_config *cfg)
2097     (cfg->info->set_fvco)(cfg);
2098     }
2099    
2100     -static inline void s3c_cpufreq_resume_clocks(void)
2101     -{
2102     - cpu_cur.info->resume_clocks();
2103     -}
2104     -
2105     static inline void s3c_cpufreq_updateclk(struct clk *clk,
2106     unsigned int freq)
2107     {
2108     @@ -417,9 +412,6 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
2109    
2110     last_target = ~0; /* invalidate last_target setting */
2111    
2112     - /* first, find out what speed we resumed at. */
2113     - s3c_cpufreq_resume_clocks();
2114     -
2115     /* whilst we will be called later on, we try and re-set the
2116     * cpu frequencies as soon as possible so that we do not end
2117     * up resuming devices and then immediately having to re-set
2118     @@ -454,7 +446,7 @@ static struct cpufreq_driver s3c24xx_driver = {
2119     };
2120    
2121    
2122     -int __init s3c_cpufreq_register(struct s3c_cpufreq_info *info)
2123     +int s3c_cpufreq_register(struct s3c_cpufreq_info *info)
2124     {
2125     if (!info || !info->name) {
2126     printk(KERN_ERR "%s: failed to pass valid information\n",
2127     diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-lib.c
2128     index 7047821a7f8a..4ab7a2156672 100644
2129     --- a/drivers/cpufreq/speedstep-lib.c
2130     +++ b/drivers/cpufreq/speedstep-lib.c
2131     @@ -400,6 +400,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
2132    
2133     pr_debug("previous speed is %u\n", prev_speed);
2134    
2135     + preempt_disable();
2136     local_irq_save(flags);
2137    
2138     /* switch to low state */
2139     @@ -464,6 +465,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
2140    
2141     out:
2142     local_irq_restore(flags);
2143     + preempt_enable();
2144     +
2145     return ret;
2146     }
2147     EXPORT_SYMBOL_GPL(speedstep_get_freqs);
2148     diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
2149     index 5fc96d5d656b..819229e824fb 100644
2150     --- a/drivers/cpufreq/speedstep-smi.c
2151     +++ b/drivers/cpufreq/speedstep-smi.c
2152     @@ -156,6 +156,7 @@ static void speedstep_set_state(unsigned int state)
2153     return;
2154    
2155     /* Disable IRQs */
2156     + preempt_disable();
2157     local_irq_save(flags);
2158    
2159     command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
2160     @@ -166,9 +167,19 @@ static void speedstep_set_state(unsigned int state)
2161    
2162     do {
2163     if (retry) {
2164     + /*
2165     + * We need to enable interrupts, otherwise the blockage
2166     + * won't resolve.
2167     + *
2168     + * We disable preemption so that other processes don't
2169     + * run. If other processes were running, they could
2170     + * submit more DMA requests, making the blockage worse.
2171     + */
2172     pr_debug("retry %u, previous result %u, waiting...\n",
2173     retry, result);
2174     + local_irq_enable();
2175     mdelay(retry * 50);
2176     + local_irq_disable();
2177     }
2178     retry++;
2179     __asm__ __volatile__(
2180     @@ -185,6 +196,7 @@ static void speedstep_set_state(unsigned int state)
2181    
2182     /* enable IRQs */
2183     local_irq_restore(flags);
2184     + preempt_enable();
2185    
2186     if (new_state == state)
2187     pr_debug("change to %u MHz succeeded after %u tries "
2188     diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
2189     index bbd65149cdb2..c7236ba92b8e 100644
2190     --- a/drivers/edac/amd64_edac.c
2191     +++ b/drivers/edac/amd64_edac.c
2192     @@ -2039,14 +2039,20 @@ static void __log_bus_error(struct mem_ctl_info *mci, struct err_info *err,
2193    
2194     static inline void decode_bus_error(int node_id, struct mce *m)
2195     {
2196     - struct mem_ctl_info *mci = mcis[node_id];
2197     - struct amd64_pvt *pvt = mci->pvt_info;
2198     + struct mem_ctl_info *mci;
2199     + struct amd64_pvt *pvt;
2200     u8 ecc_type = (m->status >> 45) & 0x3;
2201     u8 xec = XEC(m->status, 0x1f);
2202     u16 ec = EC(m->status);
2203     u64 sys_addr;
2204     struct err_info err;
2205    
2206     + mci = edac_mc_find(node_id);
2207     + if (!mci)
2208     + return;
2209     +
2210     + pvt = mci->pvt_info;
2211     +
2212     /* Bail out early if this was an 'observed' error */
2213     if (PP(ec) == NBSL_PP_OBS)
2214     return;
2215     diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
2216     index e9bb1af67c8d..3cdaac8944eb 100644
2217     --- a/drivers/edac/sb_edac.c
2218     +++ b/drivers/edac/sb_edac.c
2219     @@ -2297,7 +2297,7 @@ static int sbridge_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2220     rc = sbridge_get_all_devices(&num_mc, pci_dev_descr_ibridge_table);
2221     type = IVY_BRIDGE;
2222     break;
2223     - case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA:
2224     + case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_HA0:
2225     rc = sbridge_get_all_devices(&num_mc, pci_dev_descr_sbridge_table);
2226     type = SANDY_BRIDGE;
2227     break;
2228     @@ -2306,8 +2306,11 @@ static int sbridge_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2229     type = HASWELL;
2230     break;
2231     }
2232     - if (unlikely(rc < 0))
2233     + if (unlikely(rc < 0)) {
2234     + edac_dbg(0, "couldn't get all devices for 0x%x\n", pdev->device);
2235     goto fail0;
2236     + }
2237     +
2238     mc = 0;
2239    
2240     list_for_each_entry(sbridge_dev, &sbridge_edac_list, list) {
2241     @@ -2320,7 +2323,7 @@ static int sbridge_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2242     goto fail1;
2243     }
2244    
2245     - sbridge_printk(KERN_INFO, "Driver loaded.\n");
2246     + sbridge_printk(KERN_INFO, "%s\n", SBRIDGE_REVISION);
2247    
2248     mutex_unlock(&sbridge_edac_lock);
2249     return 0;
2250     diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
2251     index 22052d84c63b..a8c783099af9 100644
2252     --- a/drivers/gpio/gpio-tps65912.c
2253     +++ b/drivers/gpio/gpio-tps65912.c
2254     @@ -26,9 +26,12 @@ struct tps65912_gpio_data {
2255     struct gpio_chip gpio_chip;
2256     };
2257    
2258     +#define to_tgd(gc) container_of(gc, struct tps65912_gpio_data, gpio_chip)
2259     +
2260     static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
2261     {
2262     - struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
2263     + struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
2264     + struct tps65912 *tps65912 = tps65912_gpio->tps65912;
2265     int val;
2266    
2267     val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset);
2268     @@ -42,7 +45,8 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
2269     static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
2270     int value)
2271     {
2272     - struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
2273     + struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
2274     + struct tps65912 *tps65912 = tps65912_gpio->tps65912;
2275    
2276     if (value)
2277     tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset,
2278     @@ -55,7 +59,8 @@ static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
2279     static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
2280     int value)
2281     {
2282     - struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
2283     + struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
2284     + struct tps65912 *tps65912 = tps65912_gpio->tps65912;
2285    
2286     /* Set the initial value */
2287     tps65912_gpio_set(gc, offset, value);
2288     @@ -66,7 +71,8 @@ static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
2289    
2290     static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset)
2291     {
2292     - struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
2293     + struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
2294     + struct tps65912 *tps65912 = tps65912_gpio->tps65912;
2295    
2296     return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset,
2297     GPIO_CFG_MASK);
2298     diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
2299     index 08261f2b3a82..26645a847bb8 100644
2300     --- a/drivers/gpio/gpiolib-of.c
2301     +++ b/drivers/gpio/gpiolib-of.c
2302     @@ -46,12 +46,13 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
2303    
2304     ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
2305     if (ret < 0) {
2306     - /* We've found the gpio chip, but the translation failed.
2307     - * Return true to stop looking and return the translation
2308     - * error via out_gpio
2309     + /* We've found a gpio chip, but the translation failed.
2310     + * Store translation error in out_gpio.
2311     + * Return false to keep looking, as more than one gpio chip
2312     + * could be registered per of-node.
2313     */
2314     gg_data->out_gpio = ERR_PTR(ret);
2315     - return true;
2316     + return false;
2317     }
2318    
2319     gg_data->out_gpio = gpiochip_get_desc(gc, ret);
2320     diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
2321     index 80e33e0abc52..6d7c9c580ceb 100644
2322     --- a/drivers/hid/i2c-hid/i2c-hid.c
2323     +++ b/drivers/hid/i2c-hid/i2c-hid.c
2324     @@ -370,7 +370,10 @@ static int i2c_hid_hwreset(struct i2c_client *client)
2325     static void i2c_hid_get_input(struct i2c_hid *ihid)
2326     {
2327     int ret, ret_size;
2328     - int size = ihid->bufsize;
2329     + int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
2330     +
2331     + if (size > ihid->bufsize)
2332     + size = ihid->bufsize;
2333    
2334     ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
2335     if (ret != size) {
2336     diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
2337     index 40b35be34f8d..2f2f38f4d83c 100644
2338     --- a/drivers/md/raid1.c
2339     +++ b/drivers/md/raid1.c
2340     @@ -560,7 +560,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
2341     if (test_bit(WriteMostly, &rdev->flags)) {
2342     /* Don't balance among write-mostly, just
2343     * use the first as a last resort */
2344     - if (best_disk < 0) {
2345     + if (best_dist_disk < 0) {
2346     if (is_badblock(rdev, this_sector, sectors,
2347     &first_bad, &bad_sectors)) {
2348     if (first_bad < this_sector)
2349     @@ -569,7 +569,8 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
2350     best_good_sectors = first_bad - this_sector;
2351     } else
2352     best_good_sectors = sectors;
2353     - best_disk = disk;
2354     + best_dist_disk = disk;
2355     + best_pending_disk = disk;
2356     }
2357     continue;
2358     }
2359     diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2360     index b98765f6f77f..8577cc7db47e 100644
2361     --- a/drivers/md/raid5.c
2362     +++ b/drivers/md/raid5.c
2363     @@ -3102,7 +3102,8 @@ static void handle_stripe_dirtying(struct r5conf *conf,
2364     * generate correct data from the parity.
2365     */
2366     if (conf->max_degraded == 2 ||
2367     - (recovery_cp < MaxSector && sh->sector >= recovery_cp)) {
2368     + (recovery_cp < MaxSector && sh->sector >= recovery_cp &&
2369     + s->failed == 0)) {
2370     /* Calculate the real rcw later - for now make it
2371     * look like rcw is cheaper
2372     */
2373     diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
2374     index 1cd93be281ed..64a759c017d4 100644
2375     --- a/drivers/media/dvb-frontends/si2168.c
2376     +++ b/drivers/media/dvb-frontends/si2168.c
2377     @@ -605,6 +605,8 @@ static const struct dvb_frontend_ops si2168_ops = {
2378     .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A},
2379     .info = {
2380     .name = "Silicon Labs Si2168",
2381     + .symbol_rate_min = 1000000,
2382     + .symbol_rate_max = 7200000,
2383     .caps = FE_CAN_FEC_1_2 |
2384     FE_CAN_FEC_2_3 |
2385     FE_CAN_FEC_3_4 |
2386     diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
2387     index 3aac88f1d54a..736277236ba2 100644
2388     --- a/drivers/media/platform/Kconfig
2389     +++ b/drivers/media/platform/Kconfig
2390     @@ -56,10 +56,8 @@ config VIDEO_VIU
2391    
2392     config VIDEO_TIMBERDALE
2393     tristate "Support for timberdale Video In/LogiWIN"
2394     - depends on VIDEO_V4L2 && I2C && DMADEVICES
2395     - depends on MFD_TIMBERDALE || COMPILE_TEST
2396     - select DMA_ENGINE
2397     - select TIMB_DMA
2398     + depends on VIDEO_V4L2 && I2C
2399     + depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
2400     select VIDEO_ADV7180
2401     select VIDEOBUF_DMA_CONTIG
2402     ---help---
2403     diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
2404     index 8d3b74c5a717..fc369b033484 100644
2405     --- a/drivers/media/rc/rc-main.c
2406     +++ b/drivers/media/rc/rc-main.c
2407     @@ -1021,16 +1021,16 @@ static ssize_t store_protocols(struct device *device,
2408     goto out;
2409     }
2410    
2411     - if (new_protocols == old_protocols) {
2412     - rc = len;
2413     - goto out;
2414     + if (new_protocols != old_protocols) {
2415     + *current_protocols = new_protocols;
2416     + IR_dprintk(1, "Protocols changed to 0x%llx\n",
2417     + (long long)new_protocols);
2418     }
2419    
2420     - *current_protocols = new_protocols;
2421     - IR_dprintk(1, "Protocols changed to 0x%llx\n", (long long)new_protocols);
2422     -
2423     /*
2424     - * If the protocol is changed the filter needs updating.
2425     + * If a protocol change was attempted the filter may need updating, even
2426     + * if the actual protocol mask hasn't changed (since the driver may have
2427     + * cleared the filter).
2428     * Try setting the same filter with the new protocol (if any).
2429     * Fall back to clearing the filter.
2430     */
2431     diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
2432     index 9f2c5459b73a..2273ce78f5c8 100644
2433     --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
2434     +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
2435     @@ -344,15 +344,17 @@ static void lme2510_int_response(struct urb *lme_urb)
2436    
2437     usb_submit_urb(lme_urb, GFP_ATOMIC);
2438    
2439     - /* interrupt urb is due every 48 msecs while streaming
2440     - * add 12msecs for system lag */
2441     - st->int_urb_due = jiffies + msecs_to_jiffies(60);
2442     + /* Interrupt urb is due every 48 msecs while streaming the buffer
2443     + * stores up to 4 periods if missed. Allow 200 msec for next interrupt.
2444     + */
2445     + st->int_urb_due = jiffies + msecs_to_jiffies(200);
2446     }
2447    
2448     static int lme2510_int_read(struct dvb_usb_adapter *adap)
2449     {
2450     struct dvb_usb_device *d = adap_to_d(adap);
2451     struct lme2510_state *lme_int = adap_to_priv(adap);
2452     + struct usb_host_endpoint *ep;
2453    
2454     lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC);
2455    
2456     @@ -374,6 +376,12 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
2457     adap,
2458     8);
2459    
2460     + /* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */
2461     + ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe);
2462     +
2463     + if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
2464     + lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa),
2465     +
2466     lme_int->lme_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2467    
2468     usb_submit_urb(lme_int->lme_urb, GFP_ATOMIC);
2469     diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
2470     index 957c7ae30efe..1ead904a7043 100644
2471     --- a/drivers/media/usb/em28xx/em28xx-audio.c
2472     +++ b/drivers/media/usb/em28xx/em28xx-audio.c
2473     @@ -821,7 +821,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
2474     if (urb_size > ep_size * npackets)
2475     npackets = DIV_ROUND_UP(urb_size, ep_size);
2476    
2477     - em28xx_info("Number of URBs: %d, with %d packets and %d size",
2478     + em28xx_info("Number of URBs: %d, with %d packets and %d size\n",
2479     num_urb, npackets, urb_size);
2480    
2481     /* Estimate the bytes per period */
2482     @@ -982,7 +982,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
2483     return 0;
2484     }
2485    
2486     - em28xx_info("Closing audio extension");
2487     + em28xx_info("Closing audio extension\n");
2488    
2489     if (dev->adev.sndcard) {
2490     snd_card_disconnect(dev->adev.sndcard);
2491     @@ -1006,7 +1006,7 @@ static int em28xx_audio_suspend(struct em28xx *dev)
2492     if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
2493     return 0;
2494    
2495     - em28xx_info("Suspending audio extension");
2496     + em28xx_info("Suspending audio extension\n");
2497     em28xx_deinit_isoc_audio(dev);
2498     atomic_set(&dev->adev.stream_started, 0);
2499     return 0;
2500     @@ -1020,7 +1020,7 @@ static int em28xx_audio_resume(struct em28xx *dev)
2501     if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
2502     return 0;
2503    
2504     - em28xx_info("Resuming audio extension");
2505     + em28xx_info("Resuming audio extension\n");
2506     /* Nothing to do other than schedule_work() ?? */
2507     schedule_work(&dev->adev.wq_trigger);
2508     return 0;
2509     diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
2510     index 901cf2b952d7..84dd4aec70fb 100644
2511     --- a/drivers/media/usb/em28xx/em28xx-core.c
2512     +++ b/drivers/media/usb/em28xx/em28xx-core.c
2513     @@ -1122,7 +1122,7 @@ int em28xx_suspend_extension(struct em28xx *dev)
2514     {
2515     const struct em28xx_ops *ops = NULL;
2516    
2517     - em28xx_info("Suspending extensions");
2518     + em28xx_info("Suspending extensions\n");
2519     mutex_lock(&em28xx_devlist_mutex);
2520     list_for_each_entry(ops, &em28xx_extension_devlist, next) {
2521     if (ops->suspend)
2522     @@ -1136,7 +1136,7 @@ int em28xx_resume_extension(struct em28xx *dev)
2523     {
2524     const struct em28xx_ops *ops = NULL;
2525    
2526     - em28xx_info("Resuming extensions");
2527     + em28xx_info("Resuming extensions\n");
2528     mutex_lock(&em28xx_devlist_mutex);
2529     list_for_each_entry(ops, &em28xx_extension_devlist, next) {
2530     if (ops->resume)
2531     diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
2532     index 9682c52d67d1..41a6864ab8d2 100644
2533     --- a/drivers/media/usb/em28xx/em28xx-dvb.c
2534     +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
2535     @@ -1667,7 +1667,7 @@ static int em28xx_dvb_fini(struct em28xx *dev)
2536     if (!dev->dvb)
2537     return 0;
2538    
2539     - em28xx_info("Closing DVB extension");
2540     + em28xx_info("Closing DVB extension\n");
2541    
2542     dvb = dev->dvb;
2543     client = dvb->i2c_client_tuner;
2544     @@ -1718,17 +1718,17 @@ static int em28xx_dvb_suspend(struct em28xx *dev)
2545     if (!dev->board.has_dvb)
2546     return 0;
2547    
2548     - em28xx_info("Suspending DVB extension");
2549     + em28xx_info("Suspending DVB extension\n");
2550     if (dev->dvb) {
2551     struct em28xx_dvb *dvb = dev->dvb;
2552    
2553     if (dvb->fe[0]) {
2554     ret = dvb_frontend_suspend(dvb->fe[0]);
2555     - em28xx_info("fe0 suspend %d", ret);
2556     + em28xx_info("fe0 suspend %d\n", ret);
2557     }
2558     if (dvb->fe[1]) {
2559     dvb_frontend_suspend(dvb->fe[1]);
2560     - em28xx_info("fe1 suspend %d", ret);
2561     + em28xx_info("fe1 suspend %d\n", ret);
2562     }
2563     }
2564    
2565     @@ -1745,18 +1745,18 @@ static int em28xx_dvb_resume(struct em28xx *dev)
2566     if (!dev->board.has_dvb)
2567     return 0;
2568    
2569     - em28xx_info("Resuming DVB extension");
2570     + em28xx_info("Resuming DVB extension\n");
2571     if (dev->dvb) {
2572     struct em28xx_dvb *dvb = dev->dvb;
2573    
2574     if (dvb->fe[0]) {
2575     ret = dvb_frontend_resume(dvb->fe[0]);
2576     - em28xx_info("fe0 resume %d", ret);
2577     + em28xx_info("fe0 resume %d\n", ret);
2578     }
2579    
2580     if (dvb->fe[1]) {
2581     ret = dvb_frontend_resume(dvb->fe[1]);
2582     - em28xx_info("fe1 resume %d", ret);
2583     + em28xx_info("fe1 resume %d\n", ret);
2584     }
2585     }
2586    
2587     diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
2588     index 23f8f6afa2e0..b31e275faa2e 100644
2589     --- a/drivers/media/usb/em28xx/em28xx-input.c
2590     +++ b/drivers/media/usb/em28xx/em28xx-input.c
2591     @@ -833,7 +833,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
2592     return 0;
2593     }
2594    
2595     - em28xx_info("Closing input extension");
2596     + em28xx_info("Closing input extension\n");
2597    
2598     em28xx_shutdown_buttons(dev);
2599    
2600     @@ -863,7 +863,7 @@ static int em28xx_ir_suspend(struct em28xx *dev)
2601     if (dev->is_audio_only)
2602     return 0;
2603    
2604     - em28xx_info("Suspending input extension");
2605     + em28xx_info("Suspending input extension\n");
2606     if (ir)
2607     cancel_delayed_work_sync(&ir->work);
2608     cancel_delayed_work_sync(&dev->buttons_query_work);
2609     @@ -880,7 +880,7 @@ static int em28xx_ir_resume(struct em28xx *dev)
2610     if (dev->is_audio_only)
2611     return 0;
2612    
2613     - em28xx_info("Resuming input extension");
2614     + em28xx_info("Resuming input extension\n");
2615     /* if suspend calls ir_raw_event_unregister(), the should call
2616     ir_raw_event_register() */
2617     if (ir)
2618     diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
2619     index 03d5ece0319c..e0f4be8c5a19 100644
2620     --- a/drivers/media/usb/em28xx/em28xx-video.c
2621     +++ b/drivers/media/usb/em28xx/em28xx-video.c
2622     @@ -1956,7 +1956,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
2623     if (v4l2 == NULL)
2624     return 0;
2625    
2626     - em28xx_info("Closing video extension");
2627     + em28xx_info("Closing video extension\n");
2628    
2629     mutex_lock(&dev->lock);
2630    
2631     @@ -2005,7 +2005,7 @@ static int em28xx_v4l2_suspend(struct em28xx *dev)
2632     if (!dev->has_video)
2633     return 0;
2634    
2635     - em28xx_info("Suspending video extension");
2636     + em28xx_info("Suspending video extension\n");
2637     em28xx_stop_urbs(dev);
2638     return 0;
2639     }
2640     @@ -2018,7 +2018,7 @@ static int em28xx_v4l2_resume(struct em28xx *dev)
2641     if (!dev->has_video)
2642     return 0;
2643    
2644     - em28xx_info("Resuming video extension");
2645     + em28xx_info("Resuming video extension\n");
2646     /* what do we do here */
2647     return 0;
2648     }
2649     diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
2650     index 432aec8dd3ce..350a28af98aa 100644
2651     --- a/drivers/misc/mei/hw-me.c
2652     +++ b/drivers/misc/mei/hw-me.c
2653     @@ -242,7 +242,7 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
2654     if ((hcsr & H_RST) == H_RST) {
2655     dev_warn(dev->dev, "H_RST is set = 0x%08X", hcsr);
2656     hcsr &= ~H_RST;
2657     - mei_me_reg_write(hw, H_CSR, hcsr);
2658     + mei_hcsr_set(hw, hcsr);
2659     hcsr = mei_hcsr_read(hw);
2660     }
2661    
2662     @@ -335,6 +335,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)
2663     return -ETIME;
2664     }
2665    
2666     + mei_me_hw_reset_release(dev);
2667     dev->recvd_hw_ready = false;
2668     return 0;
2669     }
2670     @@ -729,9 +730,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
2671     /* check if we need to start the dev */
2672     if (!mei_host_is_ready(dev)) {
2673     if (mei_hw_is_ready(dev)) {
2674     - mei_me_hw_reset_release(dev);
2675     dev_dbg(dev->dev, "we need to start the dev.\n");
2676     -
2677     dev->recvd_hw_ready = true;
2678     wake_up(&dev->wait_hw_ready);
2679     } else {
2680     diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
2681     index 5036d7d39529..38251da7ba32 100644
2682     --- a/drivers/mmc/host/sdhci-pxav3.c
2683     +++ b/drivers/mmc/host/sdhci-pxav3.c
2684     @@ -112,6 +112,38 @@ static int mv_conf_mbus_windows(struct platform_device *pdev,
2685     return 0;
2686     }
2687    
2688     +static int armada_38x_quirks(struct platform_device *pdev,
2689     + struct sdhci_host *host)
2690     +{
2691     + struct device_node *np = pdev->dev.of_node;
2692     +
2693     + host->quirks |= SDHCI_QUIRK_MISSING_CAPS;
2694     + /*
2695     + * According to erratum 'FE-2946959' both SDR50 and DDR50
2696     + * modes require specific clock adjustments in SDIO3
2697     + * Configuration register, if the adjustment is not done,
2698     + * remove them from the capabilities.
2699     + */
2700     + host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
2701     + host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
2702     +
2703     + /*
2704     + * According to erratum 'ERR-7878951' Armada 38x SDHCI
2705     + * controller has different capabilities than the ones shown
2706     + * in its registers
2707     + */
2708     + host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
2709     + if (of_property_read_bool(np, "no-1-8-v")) {
2710     + host->caps &= ~SDHCI_CAN_VDD_180;
2711     + host->mmc->caps &= ~MMC_CAP_1_8V_DDR;
2712     + } else {
2713     + host->caps &= ~SDHCI_CAN_VDD_330;
2714     + }
2715     + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_USE_SDR50_TUNING);
2716     +
2717     + return 0;
2718     +}
2719     +
2720     static void pxav3_reset(struct sdhci_host *host, u8 mask)
2721     {
2722     struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
2723     @@ -261,8 +293,8 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
2724     if (!pdata)
2725     return NULL;
2726    
2727     - of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
2728     - if (clk_delay_cycles > 0)
2729     + if (!of_property_read_u32(np, "mrvl,clk-delay-cycles",
2730     + &clk_delay_cycles))
2731     pdata->clk_delay_cycles = clk_delay_cycles;
2732    
2733     return pdata;
2734     @@ -295,7 +327,13 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
2735     if (IS_ERR(host))
2736     return PTR_ERR(host);
2737    
2738     + /* enable 1/8V DDR capable */
2739     + host->mmc->caps |= MMC_CAP_1_8V_DDR;
2740     +
2741     if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {
2742     + ret = armada_38x_quirks(pdev, host);
2743     + if (ret < 0)
2744     + goto err_clk_get;
2745     ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());
2746     if (ret < 0)
2747     goto err_mbus_win;
2748     @@ -314,9 +352,6 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
2749     pltfm_host->clk = clk;
2750     clk_prepare_enable(clk);
2751    
2752     - /* enable 1/8V DDR capable */
2753     - host->mmc->caps |= MMC_CAP_1_8V_DDR;
2754     -
2755     match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev);
2756     if (match) {
2757     ret = mmc_of_parse(host->mmc);
2758     @@ -355,10 +390,11 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
2759     }
2760     }
2761    
2762     - pm_runtime_enable(&pdev->dev);
2763     - pm_runtime_get_sync(&pdev->dev);
2764     + pm_runtime_get_noresume(&pdev->dev);
2765     + pm_runtime_set_active(&pdev->dev);
2766     pm_runtime_set_autosuspend_delay(&pdev->dev, PXAV3_RPM_DELAY_MS);
2767     pm_runtime_use_autosuspend(&pdev->dev);
2768     + pm_runtime_enable(&pdev->dev);
2769     pm_suspend_ignore_children(&pdev->dev, 1);
2770    
2771     ret = sdhci_add_host(host);
2772     @@ -381,8 +417,8 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
2773     return 0;
2774    
2775     err_add_host:
2776     - pm_runtime_put_sync(&pdev->dev);
2777     pm_runtime_disable(&pdev->dev);
2778     + pm_runtime_put_noidle(&pdev->dev);
2779     err_of_parse:
2780     err_cd_req:
2781     clk_disable_unprepare(clk);
2782     diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
2783     index b6d2683da3a9..f71c22f8beea 100644
2784     --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
2785     +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
2786     @@ -668,9 +668,6 @@ static void iwl_mvm_cleanup_iterator(void *data, u8 *mac,
2787     mvmvif->uploaded = false;
2788     mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
2789    
2790     - /* does this make sense at all? */
2791     - mvmvif->color++;
2792     -
2793     spin_lock_bh(&mvm->time_event_lock);
2794     iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data);
2795     spin_unlock_bh(&mvm->time_event_lock);
2796     @@ -1014,7 +1011,7 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
2797    
2798     ret = iwl_mvm_power_update_mac(mvm);
2799     if (ret)
2800     - goto out_release;
2801     + goto out_remove_mac;
2802    
2803     /* beacon filtering */
2804     ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
2805     diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
2806     index c6a517c771df..5928c9db49ce 100644
2807     --- a/drivers/net/wireless/iwlwifi/mvm/tx.c
2808     +++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
2809     @@ -902,6 +902,11 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
2810     sta_id = ba_notif->sta_id;
2811     tid = ba_notif->tid;
2812    
2813     + if (WARN_ONCE(sta_id >= IWL_MVM_STATION_COUNT ||
2814     + tid >= IWL_MAX_TID_COUNT,
2815     + "sta_id %d tid %d", sta_id, tid))
2816     + return 0;
2817     +
2818     rcu_read_lock();
2819    
2820     sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
2821     diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c
2822     index eb8e2984c5e9..62ea2b550832 100644
2823     --- a/drivers/net/wireless/iwlwifi/pcie/tx.c
2824     +++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
2825     @@ -722,7 +722,12 @@ void iwl_trans_pcie_tx_reset(struct iwl_trans *trans)
2826     iwl_write_direct32(trans, FH_KW_MEM_ADDR_REG,
2827     trans_pcie->kw.dma >> 4);
2828    
2829     - iwl_pcie_tx_start(trans, trans_pcie->scd_base_addr);
2830     + /*
2831     + * Send 0 as the scd_base_addr since the device may have be reset
2832     + * while we were in WoWLAN in which case SCD_SRAM_BASE_ADDR will
2833     + * contain garbage.
2834     + */
2835     + iwl_pcie_tx_start(trans, 0);
2836     }
2837    
2838     /*
2839     diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
2840     index c70efb9a6e78..e25faacf58b7 100644
2841     --- a/drivers/net/wireless/rtlwifi/pci.c
2842     +++ b/drivers/net/wireless/rtlwifi/pci.c
2843     @@ -816,11 +816,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
2844    
2845     /* get a new skb - if fail, old one will be reused */
2846     new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
2847     - if (unlikely(!new_skb)) {
2848     - pr_err("Allocation of new skb failed in %s\n",
2849     - __func__);
2850     + if (unlikely(!new_skb))
2851     goto no_new;
2852     - }
2853     if (rtlpriv->use_new_trx_flow) {
2854     buffer_desc =
2855     &rtlpci->rx_ring[rxring_idx].buffer_desc
2856     diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h
2857     index 5e832306dba9..d4567d12e07e 100644
2858     --- a/drivers/net/wireless/rtlwifi/pci.h
2859     +++ b/drivers/net/wireless/rtlwifi/pci.h
2860     @@ -325,4 +325,11 @@ static inline void pci_write32_async(struct rtl_priv *rtlpriv,
2861     writel(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr);
2862     }
2863    
2864     +static inline u16 calc_fifo_space(u16 rp, u16 wp)
2865     +{
2866     + if (rp <= wp)
2867     + return RTL_PCI_MAX_RX_COUNT - 1 + rp - wp;
2868     + return rp - wp - 1;
2869     +}
2870     +
2871     #endif
2872     diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/fw.c b/drivers/net/wireless/rtlwifi/rtl8192ee/fw.c
2873     index 45c128b91f7f..c5d4b8013cde 100644
2874     --- a/drivers/net/wireless/rtlwifi/rtl8192ee/fw.c
2875     +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/fw.c
2876     @@ -666,7 +666,6 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
2877     struct sk_buff *skb = NULL;
2878    
2879     u32 totalpacketlen;
2880     - bool rtstatus;
2881     u8 u1rsvdpageloc[5] = { 0 };
2882     bool b_dlok = false;
2883    
2884     @@ -728,10 +727,7 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
2885     memcpy((u8 *)skb_put(skb, totalpacketlen),
2886     &reserved_page_packet, totalpacketlen);
2887    
2888     - rtstatus = rtl_cmd_send_packet(hw, skb);
2889     -
2890     - if (rtstatus)
2891     - b_dlok = true;
2892     + b_dlok = true;
2893    
2894     if (b_dlok) {
2895     RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD ,
2896     diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
2897     index 1a87edca2c3f..b461b3128da5 100644
2898     --- a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
2899     +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
2900     @@ -85,29 +85,6 @@ static void _rtl92ee_enable_bcn_sub_func(struct ieee80211_hw *hw)
2901     _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(1));
2902     }
2903    
2904     -static void _rtl92ee_return_beacon_queue_skb(struct ieee80211_hw *hw)
2905     -{
2906     - struct rtl_priv *rtlpriv = rtl_priv(hw);
2907     - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2908     - struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[BEACON_QUEUE];
2909     - unsigned long flags;
2910     -
2911     - spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
2912     - while (skb_queue_len(&ring->queue)) {
2913     - struct rtl_tx_buffer_desc *entry =
2914     - &ring->buffer_desc[ring->idx];
2915     - struct sk_buff *skb = __skb_dequeue(&ring->queue);
2916     -
2917     - pci_unmap_single(rtlpci->pdev,
2918     - rtlpriv->cfg->ops->get_desc(
2919     - (u8 *)entry, true, HW_DESC_TXBUFF_ADDR),
2920     - skb->len, PCI_DMA_TODEVICE);
2921     - kfree_skb(skb);
2922     - ring->idx = (ring->idx + 1) % ring->entries;
2923     - }
2924     - spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
2925     -}
2926     -
2927     static void _rtl92ee_disable_bcn_sub_func(struct ieee80211_hw *hw)
2928     {
2929     _rtl92ee_set_bcn_ctrl_reg(hw, BIT(1), 0);
2930     @@ -403,9 +380,6 @@ static void _rtl92ee_download_rsvd_page(struct ieee80211_hw *hw)
2931     rtl_write_byte(rtlpriv, REG_DWBCN0_CTRL + 2,
2932     bcnvalid_reg | BIT(0));
2933    
2934     - /* Return Beacon TCB */
2935     - _rtl92ee_return_beacon_queue_skb(hw);
2936     -
2937     /* download rsvd page */
2938     rtl92ee_set_fw_rsvdpagepkt(hw, false);
2939    
2940     @@ -1163,6 +1137,139 @@ void rtl92ee_enable_hw_security_config(struct ieee80211_hw *hw)
2941     rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
2942     }
2943    
2944     +static bool _rtl8192ee_check_pcie_dma_hang(struct rtl_priv *rtlpriv)
2945     +{
2946     + u8 tmp;
2947     +
2948     + /* write reg 0x350 Bit[26]=1. Enable debug port. */
2949     + tmp = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 3);
2950     + if (!(tmp & BIT(2))) {
2951     + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 3,
2952     + tmp | BIT(2));
2953     + mdelay(100); /* Suggested by DD Justin_tsai. */
2954     + }
2955     +
2956     + /* read reg 0x350 Bit[25] if 1 : RX hang
2957     + * read reg 0x350 Bit[24] if 1 : TX hang
2958     + */
2959     + tmp = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 3);
2960     + if ((tmp & BIT(0)) || (tmp & BIT(1))) {
2961     + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
2962     + "CheckPcieDMAHang8192EE(): true!!\n");
2963     + return true;
2964     + }
2965     + return false;
2966     +}
2967     +
2968     +static void _rtl8192ee_reset_pcie_interface_dma(struct rtl_priv *rtlpriv,
2969     + bool mac_power_on)
2970     +{
2971     + u8 tmp;
2972     + bool release_mac_rx_pause;
2973     + u8 backup_pcie_dma_pause;
2974     +
2975     + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
2976     + "ResetPcieInterfaceDMA8192EE()\n");
2977     +
2978     + /* Revise Note: Follow the document "PCIe RX DMA Hang Reset Flow_v03"
2979     + * released by SD1 Alan.
2980     + */
2981     +
2982     + /* 1. disable register write lock
2983     + * write 0x1C bit[1:0] = 2'h0
2984     + * write 0xCC bit[2] = 1'b1
2985     + */
2986     + tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL);
2987     + tmp &= ~(BIT(1) | BIT(0));
2988     + rtl_write_byte(rtlpriv, REG_RSV_CTRL, tmp);
2989     + tmp = rtl_read_byte(rtlpriv, REG_PMC_DBG_CTRL2);
2990     + tmp |= BIT(2);
2991     + rtl_write_byte(rtlpriv, REG_PMC_DBG_CTRL2, tmp);
2992     +
2993     + /* 2. Check and pause TRX DMA
2994     + * write 0x284 bit[18] = 1'b1
2995     + * write 0x301 = 0xFF
2996     + */
2997     + tmp = rtl_read_byte(rtlpriv, REG_RXDMA_CONTROL);
2998     + if (tmp & BIT(2)) {
2999     + /* Already pause before the function for another reason. */
3000     + release_mac_rx_pause = false;
3001     + } else {
3002     + rtl_write_byte(rtlpriv, REG_RXDMA_CONTROL, (tmp | BIT(2)));
3003     + release_mac_rx_pause = true;
3004     + }
3005     +
3006     + backup_pcie_dma_pause = rtl_read_byte(rtlpriv, REG_PCIE_CTRL_REG + 1);
3007     + if (backup_pcie_dma_pause != 0xFF)
3008     + rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xFF);
3009     +
3010     + if (mac_power_on) {
3011     + /* 3. reset TRX function
3012     + * write 0x100 = 0x00
3013     + */
3014     + rtl_write_byte(rtlpriv, REG_CR, 0);
3015     + }
3016     +
3017     + /* 4. Reset PCIe DMA
3018     + * write 0x003 bit[0] = 0
3019     + */
3020     + tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
3021     + tmp &= ~(BIT(0));
3022     + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmp);
3023     +
3024     + /* 5. Enable PCIe DMA
3025     + * write 0x003 bit[0] = 1
3026     + */
3027     + tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
3028     + tmp |= BIT(0);
3029     + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmp);
3030     +
3031     + if (mac_power_on) {
3032     + /* 6. enable TRX function
3033     + * write 0x100 = 0xFF
3034     + */
3035     + rtl_write_byte(rtlpriv, REG_CR, 0xFF);
3036     +
3037     + /* We should init LLT & RQPN and
3038     + * prepare Tx/Rx descrptor address later
3039     + * because MAC function is reset.
3040     + */
3041     + }
3042     +
3043     + /* 7. Restore PCIe autoload down bit
3044     + * write 0xF8 bit[17] = 1'b1
3045     + */
3046     + tmp = rtl_read_byte(rtlpriv, REG_MAC_PHY_CTRL_NORMAL + 2);
3047     + tmp |= BIT(1);
3048     + rtl_write_byte(rtlpriv, REG_MAC_PHY_CTRL_NORMAL + 2, tmp);
3049     +
3050     + /* In MAC power on state, BB and RF maybe in ON state,
3051     + * if we release TRx DMA here
3052     + * it will cause packets to be started to Tx/Rx,
3053     + * so we release Tx/Rx DMA later.
3054     + */
3055     + if (!mac_power_on) {
3056     + /* 8. release TRX DMA
3057     + * write 0x284 bit[18] = 1'b0
3058     + * write 0x301 = 0x00
3059     + */
3060     + if (release_mac_rx_pause) {
3061     + tmp = rtl_read_byte(rtlpriv, REG_RXDMA_CONTROL);
3062     + rtl_write_byte(rtlpriv, REG_RXDMA_CONTROL,
3063     + (tmp & (~BIT(2))));
3064     + }
3065     + rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1,
3066     + backup_pcie_dma_pause);
3067     + }
3068     +
3069     + /* 9. lock system register
3070     + * write 0xCC bit[2] = 1'b0
3071     + */
3072     + tmp = rtl_read_byte(rtlpriv, REG_PMC_DBG_CTRL2);
3073     + tmp &= ~(BIT(2));
3074     + rtl_write_byte(rtlpriv, REG_PMC_DBG_CTRL2, tmp);
3075     +}
3076     +
3077     int rtl92ee_hw_init(struct ieee80211_hw *hw)
3078     {
3079     struct rtl_priv *rtlpriv = rtl_priv(hw);
3080     @@ -1188,6 +1295,13 @@ int rtl92ee_hw_init(struct ieee80211_hw *hw)
3081     rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_92E;
3082     }
3083    
3084     + if (_rtl8192ee_check_pcie_dma_hang(rtlpriv)) {
3085     + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "92ee dma hang!\n");
3086     + _rtl8192ee_reset_pcie_interface_dma(rtlpriv,
3087     + rtlhal->mac_func_enable);
3088     + rtlhal->mac_func_enable = false;
3089     + }
3090     +
3091     rtstatus = _rtl92ee_init_mac(hw);
3092    
3093     rtl_write_byte(rtlpriv, 0x577, 0x03);
3094     diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ee/reg.h
3095     index 3f2a9596e7cd..1eaa1fab550d 100644
3096     --- a/drivers/net/wireless/rtlwifi/rtl8192ee/reg.h
3097     +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/reg.h
3098     @@ -77,9 +77,11 @@
3099     #define REG_HIMRE 0x00B8
3100     #define REG_HISRE 0x00BC
3101    
3102     +#define REG_PMC_DBG_CTRL2 0x00CC
3103     #define REG_EFUSE_ACCESS 0x00CF
3104     #define REG_HPON_FSM 0x00EC
3105     #define REG_SYS_CFG1 0x00F0
3106     +#define REG_MAC_PHY_CTRL_NORMAL 0x00F8
3107     #define REG_SYS_CFG2 0x00FC
3108    
3109     #define REG_CR 0x0100
3110     diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
3111     index 2fcbef1d029f..00690040be37 100644
3112     --- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
3113     +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
3114     @@ -512,6 +512,10 @@ bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
3115     struct ieee80211_hdr *hdr;
3116     u32 phystatus = GET_RX_DESC_PHYST(pdesc);
3117    
3118     + if (GET_RX_STATUS_DESC_RPT_SEL(pdesc) == 0)
3119     + status->packet_report_type = NORMAL_RX;
3120     + else
3121     + status->packet_report_type = C2H_PACKET;
3122     status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc);
3123     status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) *
3124     RX_DRV_INFO_SIZE_UNIT;
3125     @@ -654,14 +658,7 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, u8 queue_index)
3126     if (!start_rx)
3127     return 0;
3128    
3129     - if ((last_read_point > (RX_DESC_NUM_92E / 2)) &&
3130     - (read_point <= (RX_DESC_NUM_92E / 2))) {
3131     - remind_cnt = RX_DESC_NUM_92E - write_point;
3132     - } else {
3133     - remind_cnt = (read_point >= write_point) ?
3134     - (read_point - write_point) :
3135     - (RX_DESC_NUM_92E - write_point + read_point);
3136     - }
3137     + remind_cnt = calc_fifo_space(read_point, write_point);
3138    
3139     if (remind_cnt == 0)
3140     return 0;
3141     @@ -1207,8 +1204,7 @@ bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index)
3142     static u8 stop_report_cnt;
3143     struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
3144    
3145     - /*checking Read/Write Point each interrupt wastes CPU */
3146     - if (stop_report_cnt > 15 || !rtlpriv->link_info.busytraffic) {
3147     + {
3148     u16 point_diff = 0;
3149     u16 cur_tx_rp, cur_tx_wp;
3150     u32 tmpu32 = 0;
3151     diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
3152     index 6f9be1c7515c..8effef9b13dd 100644
3153     --- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
3154     +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
3155     @@ -542,6 +542,8 @@
3156     LE_BITS_TO_4BYTE(__pdesc+8, 12, 4)
3157     #define GET_RX_DESC_RX_IS_QOS(__pdesc) \
3158     LE_BITS_TO_4BYTE(__pdesc+8, 16, 1)
3159     +#define GET_RX_STATUS_DESC_RPT_SEL(__pdesc) \
3160     + LE_BITS_TO_4BYTE(__pdesc+8, 28, 1)
3161    
3162     #define GET_RX_DESC_RXMCS(__pdesc) \
3163     LE_BITS_TO_4BYTE(__pdesc+12, 0, 7)
3164     diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
3165     index 2b3c89425bb5..b720e7816a72 100644
3166     --- a/drivers/pci/pci-driver.c
3167     +++ b/drivers/pci/pci-driver.c
3168     @@ -1389,7 +1389,7 @@ static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
3169     if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev)))
3170     return -ENOMEM;
3171    
3172     - if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
3173     + if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02X",
3174     pdev->vendor, pdev->device,
3175     pdev->subsystem_vendor, pdev->subsystem_device,
3176     (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
3177     diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
3178     index f955edb9bea7..eb0ad530dc43 100644
3179     --- a/drivers/pci/rom.c
3180     +++ b/drivers/pci/rom.c
3181     @@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
3182     {
3183     void __iomem *image;
3184     int last_image;
3185     + unsigned length;
3186    
3187     image = rom;
3188     do {
3189     @@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
3190     if (readb(pds + 3) != 'R')
3191     break;
3192     last_image = readb(pds + 21) & 0x80;
3193     - /* this length is reliable */
3194     - image += readw(pds + 16) * 512;
3195     - } while (!last_image);
3196     + length = readw(pds + 16);
3197     + image += length * 512;
3198     + } while (length && !last_image);
3199    
3200     /* never return a size larger than the PCI resource window */
3201     /* there are known ROMs that get the size wrong */
3202     diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
3203     index ff765d8e1a09..ce364a41842a 100644
3204     --- a/drivers/platform/x86/samsung-laptop.c
3205     +++ b/drivers/platform/x86/samsung-laptop.c
3206     @@ -353,6 +353,7 @@ struct samsung_quirks {
3207     bool broken_acpi_video;
3208     bool four_kbd_backlight_levels;
3209     bool enable_kbd_backlight;
3210     + bool use_native_backlight;
3211     };
3212    
3213     static struct samsung_quirks samsung_unknown = {};
3214     @@ -361,6 +362,10 @@ static struct samsung_quirks samsung_broken_acpi_video = {
3215     .broken_acpi_video = true,
3216     };
3217    
3218     +static struct samsung_quirks samsung_use_native_backlight = {
3219     + .use_native_backlight = true,
3220     +};
3221     +
3222     static struct samsung_quirks samsung_np740u3e = {
3223     .four_kbd_backlight_levels = true,
3224     .enable_kbd_backlight = true,
3225     @@ -1507,7 +1512,7 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
3226     DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
3227     DMI_MATCH(DMI_BOARD_NAME, "N150P"),
3228     },
3229     - .driver_data = &samsung_broken_acpi_video,
3230     + .driver_data = &samsung_use_native_backlight,
3231     },
3232     {
3233     .callback = samsung_dmi_matched,
3234     @@ -1517,7 +1522,7 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
3235     DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
3236     DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
3237     },
3238     - .driver_data = &samsung_broken_acpi_video,
3239     + .driver_data = &samsung_use_native_backlight,
3240     },
3241     {
3242     .callback = samsung_dmi_matched,
3243     @@ -1557,7 +1562,7 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
3244     DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
3245     DMI_MATCH(DMI_BOARD_NAME, "N250P"),
3246     },
3247     - .driver_data = &samsung_broken_acpi_video,
3248     + .driver_data = &samsung_use_native_backlight,
3249     },
3250     {
3251     .callback = samsung_dmi_matched,
3252     @@ -1616,6 +1621,15 @@ static int __init samsung_init(void)
3253     pr_info("Disabling ACPI video driver\n");
3254     acpi_video_unregister();
3255     }
3256     +
3257     + if (samsung->quirks->use_native_backlight) {
3258     + pr_info("Using native backlight driver\n");
3259     + /* Tell acpi-video to not handle the backlight */
3260     + acpi_video_dmi_promote_vendor();
3261     + acpi_video_unregister();
3262     + /* And also do not handle it ourselves */
3263     + samsung->handle_backlight = false;
3264     + }
3265     #endif
3266    
3267     ret = samsung_platform_init(samsung);
3268     diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c
3269     index de029bbc1cc1..5ccca8743ce6 100644
3270     --- a/drivers/power/88pm860x_charger.c
3271     +++ b/drivers/power/88pm860x_charger.c
3272     @@ -711,6 +711,7 @@ static int pm860x_charger_probe(struct platform_device *pdev)
3273     return 0;
3274    
3275     out_irq:
3276     + power_supply_unregister(&info->usb);
3277     while (--i >= 0)
3278     free_irq(info->irq[i], info);
3279     out:
3280     diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c
3281     index ad3ff8fbfbbb..e4c95e1a6733 100644
3282     --- a/drivers/power/bq24190_charger.c
3283     +++ b/drivers/power/bq24190_charger.c
3284     @@ -929,7 +929,7 @@ static void bq24190_charger_init(struct power_supply *charger)
3285     charger->properties = bq24190_charger_properties;
3286     charger->num_properties = ARRAY_SIZE(bq24190_charger_properties);
3287     charger->supplied_to = bq24190_charger_supplied_to;
3288     - charger->num_supplies = ARRAY_SIZE(bq24190_charger_supplied_to);
3289     + charger->num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to);
3290     charger->get_property = bq24190_charger_get_property;
3291     charger->set_property = bq24190_charger_set_property;
3292     charger->property_is_writeable = bq24190_charger_property_is_writeable;
3293     diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
3294     index 7536933d0ab9..e5deb11bf1d5 100644
3295     --- a/drivers/power/gpio-charger.c
3296     +++ b/drivers/power/gpio-charger.c
3297     @@ -168,7 +168,7 @@ static int gpio_charger_suspend(struct device *dev)
3298    
3299     if (device_may_wakeup(dev))
3300     gpio_charger->wakeup_enabled =
3301     - enable_irq_wake(gpio_charger->irq);
3302     + !enable_irq_wake(gpio_charger->irq);
3303    
3304     return 0;
3305     }
3306     @@ -178,7 +178,7 @@ static int gpio_charger_resume(struct device *dev)
3307     struct platform_device *pdev = to_platform_device(dev);
3308     struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
3309    
3310     - if (gpio_charger->wakeup_enabled)
3311     + if (device_may_wakeup(dev) && gpio_charger->wakeup_enabled)
3312     disable_irq_wake(gpio_charger->irq);
3313     power_supply_changed(&gpio_charger->charger);
3314    
3315     diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
3316     index 5e881e5e67b6..6e503802947a 100644
3317     --- a/drivers/scsi/megaraid/megaraid_sas_base.c
3318     +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
3319     @@ -3556,7 +3556,6 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3320     int i;
3321     u32 max_cmd;
3322     u32 sge_sz;
3323     - u32 sgl_sz;
3324     u32 total_sz;
3325     u32 frame_count;
3326     struct megasas_cmd *cmd;
3327     @@ -3575,24 +3574,23 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3328     }
3329    
3330     /*
3331     - * Calculated the number of 64byte frames required for SGL
3332     - */
3333     - sgl_sz = sge_sz * instance->max_num_sge;
3334     - frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE;
3335     - frame_count = 15;
3336     -
3337     - /*
3338     - * We need one extra frame for the MFI command
3339     + * For MFI controllers.
3340     + * max_num_sge = 60
3341     + * max_sge_sz = 16 byte (sizeof megasas_sge_skinny)
3342     + * Total 960 byte (15 MFI frame of 64 byte)
3343     + *
3344     + * Fusion adapter require only 3 extra frame.
3345     + * max_num_sge = 16 (defined as MAX_IOCTL_SGE)
3346     + * max_sge_sz = 12 byte (sizeof megasas_sge64)
3347     + * Total 192 byte (3 MFI frame of 64 byte)
3348     */
3349     - frame_count++;
3350     -
3351     + frame_count = instance->ctrl_context ? (3 + 1) : (15 + 1);
3352     total_sz = MEGAMFI_FRAME_SIZE * frame_count;
3353     /*
3354     * Use DMA pool facility provided by PCI layer
3355     */
3356     instance->frame_dma_pool = pci_pool_create("megasas frame pool",
3357     - instance->pdev, total_sz, 64,
3358     - 0);
3359     + instance->pdev, total_sz, 256, 0);
3360    
3361     if (!instance->frame_dma_pool) {
3362     printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
3363     diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
3364     index 0f66d0ef0b26..7d2d424bc8d0 100644
3365     --- a/drivers/scsi/megaraid/megaraid_sas_fp.c
3366     +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
3367     @@ -170,6 +170,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
3368     struct MR_FW_RAID_MAP_ALL *fw_map_old = NULL;
3369     struct MR_FW_RAID_MAP *pFwRaidMap = NULL;
3370     int i;
3371     + u16 ld_count;
3372    
3373    
3374     struct MR_DRV_RAID_MAP_ALL *drv_map =
3375     @@ -189,9 +190,10 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
3376     fw_map_old = (struct MR_FW_RAID_MAP_ALL *)
3377     fusion->ld_map[(instance->map_id & 1)];
3378     pFwRaidMap = &fw_map_old->raidMap;
3379     + ld_count = (u16)le32_to_cpu(pFwRaidMap->ldCount);
3380    
3381     #if VD_EXT_DEBUG
3382     - for (i = 0; i < le16_to_cpu(pFwRaidMap->ldCount); i++) {
3383     + for (i = 0; i < ld_count; i++) {
3384     dev_dbg(&instance->pdev->dev, "(%d) :Index 0x%x "
3385     "Target Id 0x%x Seq Num 0x%x Size 0/%llx\n",
3386     instance->unique_id, i,
3387     @@ -203,12 +205,15 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
3388    
3389     memset(drv_map, 0, fusion->drv_map_sz);
3390     pDrvRaidMap->totalSize = pFwRaidMap->totalSize;
3391     - pDrvRaidMap->ldCount = (__le16)pFwRaidMap->ldCount;
3392     + pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
3393     pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec;
3394     for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
3395     pDrvRaidMap->ldTgtIdToLd[i] =
3396     (u8)pFwRaidMap->ldTgtIdToLd[i];
3397     - for (i = 0; i < le16_to_cpu(pDrvRaidMap->ldCount); i++) {
3398     + for (i = (MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS);
3399     + i < MAX_LOGICAL_DRIVES_EXT; i++)
3400     + pDrvRaidMap->ldTgtIdToLd[i] = 0xff;
3401     + for (i = 0; i < ld_count; i++) {
3402     pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
3403     #if VD_EXT_DEBUG
3404     dev_dbg(&instance->pdev->dev,
3405     @@ -250,7 +255,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
3406     struct LD_LOAD_BALANCE_INFO *lbInfo;
3407     PLD_SPAN_INFO ldSpanInfo;
3408     struct MR_LD_RAID *raid;
3409     - int ldCount, num_lds;
3410     + u16 ldCount, num_lds;
3411     u16 ld;
3412     u32 expected_size;
3413    
3414     @@ -354,7 +359,7 @@ static int getSpanInfo(struct MR_DRV_RAID_MAP_ALL *map,
3415    
3416     for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
3417     ld = MR_TargetIdToLdGet(ldCount, map);
3418     - if (ld >= MAX_LOGICAL_DRIVES_EXT)
3419     + if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
3420     continue;
3421     raid = MR_LdRaidGet(ld, map);
3422     dev_dbg(&instance->pdev->dev, "LD %x: span_depth=%x\n",
3423     @@ -1155,7 +1160,7 @@ void mr_update_span_set(struct MR_DRV_RAID_MAP_ALL *map,
3424    
3425     for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
3426     ld = MR_TargetIdToLdGet(ldCount, map);
3427     - if (ld >= MAX_LOGICAL_DRIVES_EXT)
3428     + if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
3429     continue;
3430     raid = MR_LdRaidGet(ld, map);
3431     for (element = 0; element < MAX_QUAD_DEPTH; element++) {
3432     diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3433     index 9d9c27cd4687..554395634592 100644
3434     --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
3435     +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3436     @@ -101,6 +101,8 @@ megasas_enable_intr_fusion(struct megasas_instance *instance)
3437     {
3438     struct megasas_register_set __iomem *regs;
3439     regs = instance->reg_set;
3440     +
3441     + instance->mask_interrupts = 0;
3442     /* For Thunderbolt/Invader also clear intr on enable */
3443     writel(~0, &regs->outbound_intr_status);
3444     readl(&regs->outbound_intr_status);
3445     @@ -109,7 +111,6 @@ megasas_enable_intr_fusion(struct megasas_instance *instance)
3446    
3447     /* Dummy readl to force pci flush */
3448     readl(&regs->outbound_intr_mask);
3449     - instance->mask_interrupts = 0;
3450     }
3451    
3452     /**
3453     @@ -696,12 +697,11 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
3454     cpu_to_le32(lower_32_bits(ioc_init_handle));
3455     init_frame->data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST));
3456    
3457     - req_desc.Words = 0;
3458     + req_desc.u.low = cpu_to_le32(lower_32_bits(cmd->frame_phys_addr));
3459     + req_desc.u.high = cpu_to_le32(upper_32_bits(cmd->frame_phys_addr));
3460     req_desc.MFAIo.RequestFlags =
3461     (MEGASAS_REQ_DESCRIPT_FLAGS_MFA <<
3462     - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
3463     - cpu_to_le32s((u32 *)&req_desc.MFAIo);
3464     - req_desc.Words |= cpu_to_le64(cmd->frame_phys_addr);
3465     + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
3466    
3467     /*
3468     * disable the intr before firing the init frame
3469     @@ -1753,9 +1753,19 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance,
3470     if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS)
3471     goto NonFastPath;
3472    
3473     + /*
3474     + * For older firmware, Driver should not access ldTgtIdToLd
3475     + * beyond index 127 and for Extended VD firmware, ldTgtIdToLd
3476     + * should not go beyond 255.
3477     + */
3478     +
3479     + if ((!fusion->fast_path_io) ||
3480     + (device_id >= instance->fw_supported_vd_count))
3481     + goto NonFastPath;
3482     +
3483     ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
3484     - if ((ld >= instance->fw_supported_vd_count) ||
3485     - (!fusion->fast_path_io))
3486     +
3487     + if (ld >= instance->fw_supported_vd_count)
3488     goto NonFastPath;
3489    
3490     raid = MR_LdRaidGet(ld, local_map_ptr);
3491     diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
3492     index 0d183d521bdd..a7f216f27ae3 100644
3493     --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
3494     +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
3495     @@ -304,14 +304,9 @@ struct MPI2_RAID_SCSI_IO_REQUEST {
3496     * MPT RAID MFA IO Descriptor.
3497     */
3498     struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
3499     -#if defined(__BIG_ENDIAN_BITFIELD)
3500     - u32 MessageAddress1:24; /* bits 31:8*/
3501     - u32 RequestFlags:8;
3502     -#else
3503     u32 RequestFlags:8;
3504     - u32 MessageAddress1:24; /* bits 31:8*/
3505     -#endif
3506     - u32 MessageAddress2; /* bits 61:32 */
3507     + u32 MessageAddress1:24;
3508     + u32 MessageAddress2;
3509     };
3510    
3511     /* Default Request Descriptor */
3512     diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
3513     index 60354449d9ed..843594c2583d 100644
3514     --- a/drivers/scsi/sg.c
3515     +++ b/drivers/scsi/sg.c
3516     @@ -1376,6 +1376,17 @@ sg_rq_end_io(struct request *rq, int uptodate)
3517     }
3518     /* Rely on write phase to clean out srp status values, so no "else" */
3519    
3520     + /*
3521     + * Free the request as soon as it is complete so that its resources
3522     + * can be reused without waiting for userspace to read() the
3523     + * result. But keep the associated bio (if any) around until
3524     + * blk_rq_unmap_user() can be called from user context.
3525     + */
3526     + srp->rq = NULL;
3527     + if (rq->cmd != rq->__cmd)
3528     + kfree(rq->cmd);
3529     + __blk_put_request(rq->q, rq);
3530     +
3531     write_lock_irqsave(&sfp->rq_list_lock, iflags);
3532     if (unlikely(srp->orphan)) {
3533     if (sfp->keep_orphan)
3534     @@ -1710,7 +1721,22 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
3535     return -ENOMEM;
3536     }
3537    
3538     - rq = blk_get_request(q, rw, GFP_ATOMIC);
3539     + /*
3540     + * NOTE
3541     + *
3542     + * With scsi-mq enabled, there are a fixed number of preallocated
3543     + * requests equal in number to shost->can_queue. If all of the
3544     + * preallocated requests are already in use, then using GFP_ATOMIC with
3545     + * blk_get_request() will return -EWOULDBLOCK, whereas using GFP_KERNEL
3546     + * will cause blk_get_request() to sleep until an active command
3547     + * completes, freeing up a request. Neither option is ideal, but
3548     + * GFP_KERNEL is the better choice to prevent userspace from getting an
3549     + * unexpected EWOULDBLOCK.
3550     + *
3551     + * With scsi-mq disabled, blk_get_request() with GFP_KERNEL usually
3552     + * does not sleep except under memory pressure.
3553     + */
3554     + rq = blk_get_request(q, rw, GFP_KERNEL);
3555     if (IS_ERR(rq)) {
3556     kfree(long_cmdp);
3557     return PTR_ERR(rq);
3558     @@ -1803,10 +1829,10 @@ sg_finish_rem_req(Sg_request *srp)
3559     SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
3560     "sg_finish_rem_req: res_used=%d\n",
3561     (int) srp->res_used));
3562     - if (srp->rq) {
3563     - if (srp->bio)
3564     - ret = blk_rq_unmap_user(srp->bio);
3565     + if (srp->bio)
3566     + ret = blk_rq_unmap_user(srp->bio);
3567    
3568     + if (srp->rq) {
3569     if (srp->rq->cmd != srp->rq->__cmd)
3570     kfree(srp->rq->cmd);
3571     blk_put_request(srp->rq);
3572     diff --git a/drivers/target/iscsi/iscsi_target_tq.c b/drivers/target/iscsi/iscsi_target_tq.c
3573     index 601e9cc61e98..bb2890e79ca0 100644
3574     --- a/drivers/target/iscsi/iscsi_target_tq.c
3575     +++ b/drivers/target/iscsi/iscsi_target_tq.c
3576     @@ -24,36 +24,22 @@
3577     #include "iscsi_target_tq.h"
3578     #include "iscsi_target.h"
3579    
3580     -static LIST_HEAD(active_ts_list);
3581     static LIST_HEAD(inactive_ts_list);
3582     -static DEFINE_SPINLOCK(active_ts_lock);
3583     static DEFINE_SPINLOCK(inactive_ts_lock);
3584     static DEFINE_SPINLOCK(ts_bitmap_lock);
3585    
3586     -static void iscsi_add_ts_to_active_list(struct iscsi_thread_set *ts)
3587     -{
3588     - spin_lock(&active_ts_lock);
3589     - list_add_tail(&ts->ts_list, &active_ts_list);
3590     - iscsit_global->active_ts++;
3591     - spin_unlock(&active_ts_lock);
3592     -}
3593     -
3594     static void iscsi_add_ts_to_inactive_list(struct iscsi_thread_set *ts)
3595     {
3596     + if (!list_empty(&ts->ts_list)) {
3597     + WARN_ON(1);
3598     + return;
3599     + }
3600     spin_lock(&inactive_ts_lock);
3601     list_add_tail(&ts->ts_list, &inactive_ts_list);
3602     iscsit_global->inactive_ts++;
3603     spin_unlock(&inactive_ts_lock);
3604     }
3605    
3606     -static void iscsi_del_ts_from_active_list(struct iscsi_thread_set *ts)
3607     -{
3608     - spin_lock(&active_ts_lock);
3609     - list_del(&ts->ts_list);
3610     - iscsit_global->active_ts--;
3611     - spin_unlock(&active_ts_lock);
3612     -}
3613     -
3614     static struct iscsi_thread_set *iscsi_get_ts_from_inactive_list(void)
3615     {
3616     struct iscsi_thread_set *ts;
3617     @@ -66,7 +52,7 @@ static struct iscsi_thread_set *iscsi_get_ts_from_inactive_list(void)
3618    
3619     ts = list_first_entry(&inactive_ts_list, struct iscsi_thread_set, ts_list);
3620    
3621     - list_del(&ts->ts_list);
3622     + list_del_init(&ts->ts_list);
3623     iscsit_global->inactive_ts--;
3624     spin_unlock(&inactive_ts_lock);
3625    
3626     @@ -204,8 +190,6 @@ static void iscsi_deallocate_extra_thread_sets(void)
3627    
3628     void iscsi_activate_thread_set(struct iscsi_conn *conn, struct iscsi_thread_set *ts)
3629     {
3630     - iscsi_add_ts_to_active_list(ts);
3631     -
3632     spin_lock_bh(&ts->ts_state_lock);
3633     conn->thread_set = ts;
3634     ts->conn = conn;
3635     @@ -397,7 +381,6 @@ struct iscsi_conn *iscsi_rx_thread_pre_handler(struct iscsi_thread_set *ts)
3636    
3637     if (ts->delay_inactive && (--ts->thread_count == 0)) {
3638     spin_unlock_bh(&ts->ts_state_lock);
3639     - iscsi_del_ts_from_active_list(ts);
3640    
3641     if (!iscsit_global->in_shutdown)
3642     iscsi_deallocate_extra_thread_sets();
3643     @@ -452,7 +435,6 @@ struct iscsi_conn *iscsi_tx_thread_pre_handler(struct iscsi_thread_set *ts)
3644    
3645     if (ts->delay_inactive && (--ts->thread_count == 0)) {
3646     spin_unlock_bh(&ts->ts_state_lock);
3647     - iscsi_del_ts_from_active_list(ts);
3648    
3649     if (!iscsit_global->in_shutdown)
3650     iscsi_deallocate_extra_thread_sets();
3651     diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
3652     index 7c4447a5c0f4..082304dcbe8c 100644
3653     --- a/drivers/tty/pty.c
3654     +++ b/drivers/tty/pty.c
3655     @@ -210,6 +210,9 @@ static int pty_signal(struct tty_struct *tty, int sig)
3656     unsigned long flags;
3657     struct pid *pgrp;
3658    
3659     + if (sig != SIGINT && sig != SIGQUIT && sig != SIGTSTP)
3660     + return -EINVAL;
3661     +
3662     if (tty->link) {
3663     spin_lock_irqsave(&tty->link->ctrl_lock, flags);
3664     pgrp = get_pid(tty->link->pgrp);
3665     diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
3666     index edde3eca055d..6ee5c6cefac0 100644
3667     --- a/drivers/tty/serial/atmel_serial.c
3668     +++ b/drivers/tty/serial/atmel_serial.c
3669     @@ -2577,7 +2577,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
3670    
3671     ret = atmel_init_port(port, pdev);
3672     if (ret)
3673     - goto err;
3674     + goto err_clear_bit;
3675    
3676     if (!atmel_use_pdc_rx(&port->uart)) {
3677     ret = -ENOMEM;
3678     @@ -2626,6 +2626,8 @@ err_alloc_ring:
3679     clk_put(port->clk);
3680     port->clk = NULL;
3681     }
3682     +err_clear_bit:
3683     + clear_bit(port->uart.line, atmel_ports_in_use);
3684     err:
3685     return ret;
3686     }
3687     diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
3688     index 6dd53af546a3..eb9bc7e1dbaa 100644
3689     --- a/drivers/tty/serial/fsl_lpuart.c
3690     +++ b/drivers/tty/serial/fsl_lpuart.c
3691     @@ -506,9 +506,6 @@ static inline void lpuart_prepare_rx(struct lpuart_port *sport)
3692    
3693     spin_lock_irqsave(&sport->port.lock, flags);
3694    
3695     - init_timer(&sport->lpuart_timer);
3696     - sport->lpuart_timer.function = lpuart_timer_func;
3697     - sport->lpuart_timer.data = (unsigned long)sport;
3698     sport->lpuart_timer.expires = jiffies + sport->dma_rx_timeout;
3699     add_timer(&sport->lpuart_timer);
3700    
3701     @@ -758,18 +755,18 @@ out:
3702     static irqreturn_t lpuart_int(int irq, void *dev_id)
3703     {
3704     struct lpuart_port *sport = dev_id;
3705     - unsigned char sts;
3706     + unsigned char sts, crdma;
3707    
3708     sts = readb(sport->port.membase + UARTSR1);
3709     + crdma = readb(sport->port.membase + UARTCR5);
3710    
3711     - if (sts & UARTSR1_RDRF) {
3712     + if (sts & UARTSR1_RDRF && !(crdma & UARTCR5_RDMAS)) {
3713     if (sport->lpuart_dma_use)
3714     lpuart_prepare_rx(sport);
3715     else
3716     lpuart_rxint(irq, dev_id);
3717     }
3718     - if (sts & UARTSR1_TDRE &&
3719     - !(readb(sport->port.membase + UARTCR5) & UARTCR5_TDMAS)) {
3720     + if (sts & UARTSR1_TDRE && !(crdma & UARTCR5_TDMAS)) {
3721     if (sport->lpuart_dma_use)
3722     lpuart_pio_tx(sport);
3723     else
3724     @@ -1106,7 +1103,10 @@ static int lpuart_startup(struct uart_port *port)
3725     sport->lpuart_dma_use = false;
3726     } else {
3727     sport->lpuart_dma_use = true;
3728     + setup_timer(&sport->lpuart_timer, lpuart_timer_func,
3729     + (unsigned long)sport);
3730     temp = readb(port->membase + UARTCR5);
3731     + temp &= ~UARTCR5_RDMAS;
3732     writeb(temp | UARTCR5_TDMAS, port->membase + UARTCR5);
3733     }
3734    
3735     @@ -1180,6 +1180,8 @@ static void lpuart_shutdown(struct uart_port *port)
3736     devm_free_irq(port->dev, port->irq, sport);
3737    
3738     if (sport->lpuart_dma_use) {
3739     + del_timer_sync(&sport->lpuart_timer);
3740     +
3741     lpuart_dma_tx_free(port);
3742     lpuart_dma_rx_free(port);
3743     }
3744     diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
3745     index b33b00b386de..53c25bca7d05 100644
3746     --- a/drivers/tty/vt/vt.c
3747     +++ b/drivers/tty/vt/vt.c
3748     @@ -498,6 +498,7 @@ void invert_screen(struct vc_data *vc, int offset, int count, int viewed)
3749     #endif
3750     if (DO_UPDATE(vc))
3751     do_update_region(vc, (unsigned long) p, count);
3752     + notify_update(vc);
3753     }
3754    
3755     /* used by selection: complement pointer position */
3756     @@ -514,6 +515,7 @@ void complement_pos(struct vc_data *vc, int offset)
3757     scr_writew(old, screenpos(vc, old_offset, 1));
3758     if (DO_UPDATE(vc))
3759     vc->vc_sw->con_putc(vc, old, oldy, oldx);
3760     + notify_update(vc);
3761     }
3762    
3763     old_offset = offset;
3764     @@ -531,8 +533,8 @@ void complement_pos(struct vc_data *vc, int offset)
3765     oldy = (offset >> 1) / vc->vc_cols;
3766     vc->vc_sw->con_putc(vc, new, oldy, oldx);
3767     }
3768     + notify_update(vc);
3769     }
3770     -
3771     }
3772    
3773     static void insert_char(struct vc_data *vc, unsigned int nr)
3774     diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
3775     index 684ef70dc09d..506b969ea7fd 100644
3776     --- a/drivers/usb/core/buffer.c
3777     +++ b/drivers/usb/core/buffer.c
3778     @@ -22,17 +22,25 @@
3779     */
3780    
3781     /* FIXME tune these based on pool statistics ... */
3782     -static const size_t pool_max[HCD_BUFFER_POOLS] = {
3783     - /* platforms without dma-friendly caches might need to
3784     - * prevent cacheline sharing...
3785     - */
3786     - 32,
3787     - 128,
3788     - 512,
3789     - PAGE_SIZE / 2
3790     - /* bigger --> allocate pages */
3791     +static size_t pool_max[HCD_BUFFER_POOLS] = {
3792     + 32, 128, 512, 2048,
3793     };
3794    
3795     +void __init usb_init_pool_max(void)
3796     +{
3797     + /*
3798     + * The pool_max values must never be smaller than
3799     + * ARCH_KMALLOC_MINALIGN.
3800     + */
3801     + if (ARCH_KMALLOC_MINALIGN <= 32)
3802     + ; /* Original value is okay */
3803     + else if (ARCH_KMALLOC_MINALIGN <= 64)
3804     + pool_max[0] = 64;
3805     + else if (ARCH_KMALLOC_MINALIGN <= 128)
3806     + pool_max[0] = 0; /* Don't use this pool */
3807     + else
3808     + BUILD_BUG(); /* We don't allow this */
3809     +}
3810    
3811     /* SETUP primitives */
3812    
3813     diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
3814     index 9bffd26cea05..d7a6d8bc510b 100644
3815     --- a/drivers/usb/core/driver.c
3816     +++ b/drivers/usb/core/driver.c
3817     @@ -275,21 +275,6 @@ static int usb_unbind_device(struct device *dev)
3818     return 0;
3819     }
3820    
3821     -/*
3822     - * Cancel any pending scheduled resets
3823     - *
3824     - * [see usb_queue_reset_device()]
3825     - *
3826     - * Called after unconfiguring / when releasing interfaces. See
3827     - * comments in __usb_queue_reset_device() regarding
3828     - * udev->reset_running.
3829     - */
3830     -static void usb_cancel_queued_reset(struct usb_interface *iface)
3831     -{
3832     - if (iface->reset_running == 0)
3833     - cancel_work_sync(&iface->reset_ws);
3834     -}
3835     -
3836     /* called from driver core with dev locked */
3837     static int usb_probe_interface(struct device *dev)
3838     {
3839     @@ -380,7 +365,6 @@ static int usb_probe_interface(struct device *dev)
3840     usb_set_intfdata(intf, NULL);
3841     intf->needs_remote_wakeup = 0;
3842     intf->condition = USB_INTERFACE_UNBOUND;
3843     - usb_cancel_queued_reset(intf);
3844    
3845     /* If the LPM disable succeeded, balance the ref counts. */
3846     if (!lpm_disable_error)
3847     @@ -425,7 +409,6 @@ static int usb_unbind_interface(struct device *dev)
3848     usb_disable_interface(udev, intf, false);
3849    
3850     driver->disconnect(intf);
3851     - usb_cancel_queued_reset(intf);
3852    
3853     /* Free streams */
3854     for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
3855     @@ -1801,6 +1784,18 @@ static int autosuspend_check(struct usb_device *udev)
3856     dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n");
3857     return -EOPNOTSUPP;
3858     }
3859     +
3860     + /*
3861     + * If the device is a direct child of the root hub and the HCD
3862     + * doesn't handle wakeup requests, don't allow autosuspend when
3863     + * wakeup is needed.
3864     + */
3865     + if (w && udev->parent == udev->bus->root_hub &&
3866     + bus_to_hcd(udev->bus)->cant_recv_wakeups) {
3867     + dev_dbg(&udev->dev, "HCD doesn't handle wakeup requests\n");
3868     + return -EOPNOTSUPP;
3869     + }
3870     +
3871     udev->do_remote_wakeup = w;
3872     return 0;
3873     }
3874     diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
3875     index a6efb4184f2b..0009fc847eee 100644
3876     --- a/drivers/usb/core/hcd.c
3877     +++ b/drivers/usb/core/hcd.c
3878     @@ -1618,6 +1618,7 @@ static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status)
3879     int usb_hcd_unlink_urb (struct urb *urb, int status)
3880     {
3881     struct usb_hcd *hcd;
3882     + struct usb_device *udev = urb->dev;
3883     int retval = -EIDRM;
3884     unsigned long flags;
3885    
3886     @@ -1629,20 +1630,19 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
3887     spin_lock_irqsave(&hcd_urb_unlink_lock, flags);
3888     if (atomic_read(&urb->use_count) > 0) {
3889     retval = 0;
3890     - usb_get_dev(urb->dev);
3891     + usb_get_dev(udev);
3892     }
3893     spin_unlock_irqrestore(&hcd_urb_unlink_lock, flags);
3894     if (retval == 0) {
3895     hcd = bus_to_hcd(urb->dev->bus);
3896     retval = unlink1(hcd, urb, status);
3897     - usb_put_dev(urb->dev);
3898     + if (retval == 0)
3899     + retval = -EINPROGRESS;
3900     + else if (retval != -EIDRM && retval != -EBUSY)
3901     + dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n",
3902     + urb, retval);
3903     + usb_put_dev(udev);
3904     }
3905     -
3906     - if (retval == 0)
3907     - retval = -EINPROGRESS;
3908     - else if (retval != -EIDRM && retval != -EBUSY)
3909     - dev_dbg(&urb->dev->dev, "hcd_unlink_urb %p fail %d\n",
3910     - urb, retval);
3911     return retval;
3912     }
3913    
3914     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3915     index b649fef2e35d..2246954d7df3 100644
3916     --- a/drivers/usb/core/hub.c
3917     +++ b/drivers/usb/core/hub.c
3918     @@ -5591,26 +5591,19 @@ EXPORT_SYMBOL_GPL(usb_reset_device);
3919     * possible; depending on how the driver attached to each interface
3920     * handles ->pre_reset(), the second reset might happen or not.
3921     *
3922     - * - If a driver is unbound and it had a pending reset, the reset will
3923     - * be cancelled.
3924     + * - If the reset is delayed so long that the interface is unbound from
3925     + * its driver, the reset will be skipped.
3926     *
3927     - * - This function can be called during .probe() or .disconnect()
3928     - * times. On return from .disconnect(), any pending resets will be
3929     - * cancelled.
3930     - *
3931     - * There is no no need to lock/unlock the @reset_ws as schedule_work()
3932     - * does its own.
3933     - *
3934     - * NOTE: We don't do any reference count tracking because it is not
3935     - * needed. The lifecycle of the work_struct is tied to the
3936     - * usb_interface. Before destroying the interface we cancel the
3937     - * work_struct, so the fact that work_struct is queued and or
3938     - * running means the interface (and thus, the device) exist and
3939     - * are referenced.
3940     + * - This function can be called during .probe(). It can also be called
3941     + * during .disconnect(), but doing so is pointless because the reset
3942     + * will not occur. If you really want to reset the device during
3943     + * .disconnect(), call usb_reset_device() directly -- but watch out
3944     + * for nested unbinding issues!
3945     */
3946     void usb_queue_reset_device(struct usb_interface *iface)
3947     {
3948     - schedule_work(&iface->reset_ws);
3949     + if (schedule_work(&iface->reset_ws))
3950     + usb_get_intf(iface);
3951     }
3952     EXPORT_SYMBOL_GPL(usb_queue_reset_device);
3953    
3954     diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
3955     index f7b7713cfb2a..f368d2053da5 100644
3956     --- a/drivers/usb/core/message.c
3957     +++ b/drivers/usb/core/message.c
3958     @@ -1551,6 +1551,7 @@ static void usb_release_interface(struct device *dev)
3959     altsetting_to_usb_interface_cache(intf->altsetting);
3960    
3961     kref_put(&intfc->ref, usb_release_interface_cache);
3962     + usb_put_dev(interface_to_usbdev(intf));
3963     kfree(intf);
3964     }
3965    
3966     @@ -1626,24 +1627,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev,
3967    
3968     /*
3969     * Internal function to queue a device reset
3970     - *
3971     - * This is initialized into the workstruct in 'struct
3972     - * usb_device->reset_ws' that is launched by
3973     - * message.c:usb_set_configuration() when initializing each 'struct
3974     - * usb_interface'.
3975     - *
3976     - * It is safe to get the USB device without reference counts because
3977     - * the life cycle of @iface is bound to the life cycle of @udev. Then,
3978     - * this function will be ran only if @iface is alive (and before
3979     - * freeing it any scheduled instances of it will have been cancelled).
3980     - *
3981     - * We need to set a flag (usb_dev->reset_running) because when we call
3982     - * the reset, the interfaces might be unbound. The current interface
3983     - * cannot try to remove the queued work as it would cause a deadlock
3984     - * (you cannot remove your work from within your executing
3985     - * workqueue). This flag lets it know, so that
3986     - * usb_cancel_queued_reset() doesn't try to do it.
3987     - *
3988     * See usb_queue_reset_device() for more details
3989     */
3990     static void __usb_queue_reset_device(struct work_struct *ws)
3991     @@ -1655,11 +1638,10 @@ static void __usb_queue_reset_device(struct work_struct *ws)
3992    
3993     rc = usb_lock_device_for_reset(udev, iface);
3994     if (rc >= 0) {
3995     - iface->reset_running = 1;
3996     usb_reset_device(udev);
3997     - iface->reset_running = 0;
3998     usb_unlock_device(udev);
3999     }
4000     + usb_put_intf(iface); /* Undo _get_ in usb_queue_reset_device() */
4001     }
4002    
4003    
4004     @@ -1854,6 +1836,7 @@ free_interfaces:
4005     dev_set_name(&intf->dev, "%d-%s:%d.%d",
4006     dev->bus->busnum, dev->devpath,
4007     configuration, alt->desc.bInterfaceNumber);
4008     + usb_get_dev(dev);
4009     }
4010     kfree(new_interfaces);
4011    
4012     diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
4013     index 2dd2362198d2..29ee9363faa5 100644
4014     --- a/drivers/usb/core/usb.c
4015     +++ b/drivers/usb/core/usb.c
4016     @@ -1051,6 +1051,7 @@ static int __init usb_init(void)
4017     pr_info("%s: USB support disabled\n", usbcore_name);
4018     return 0;
4019     }
4020     + usb_init_pool_max();
4021    
4022     retval = usb_debugfs_init();
4023     if (retval)
4024     diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
4025     index e752c3098f38..d2a856528471 100644
4026     --- a/drivers/usb/host/isp1760-hcd.c
4027     +++ b/drivers/usb/host/isp1760-hcd.c
4028     @@ -2247,6 +2247,9 @@ struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
4029     hcd->rsrc_start = res_start;
4030     hcd->rsrc_len = res_len;
4031    
4032     + /* This driver doesn't support wakeup requests */
4033     + hcd->cant_recv_wakeups = 1;
4034     +
4035     ret = usb_add_hcd(hcd, irq, irqflags);
4036     if (ret)
4037     goto err_unmap;
4038     diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
4039     index f4c56fc1a9f6..f40c856ff758 100644
4040     --- a/drivers/usb/serial/cp210x.c
4041     +++ b/drivers/usb/serial/cp210x.c
4042     @@ -56,6 +56,7 @@ static const struct usb_device_id id_table[] = {
4043     { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */
4044     { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
4045     { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
4046     + { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
4047     { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
4048     { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
4049     { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
4050     diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
4051     index f8bb36f9d9ce..bf1940706422 100644
4052     --- a/drivers/xen/manage.c
4053     +++ b/drivers/xen/manage.c
4054     @@ -105,10 +105,16 @@ static void do_suspend(void)
4055    
4056     err = freeze_processes();
4057     if (err) {
4058     - pr_err("%s: freeze failed %d\n", __func__, err);
4059     + pr_err("%s: freeze processes failed %d\n", __func__, err);
4060     goto out;
4061     }
4062    
4063     + err = freeze_kernel_threads();
4064     + if (err) {
4065     + pr_err("%s: freeze kernel threads failed %d\n", __func__, err);
4066     + goto out_thaw;
4067     + }
4068     +
4069     err = dpm_suspend_start(PMSG_FREEZE);
4070     if (err) {
4071     pr_err("%s: dpm_suspend_start %d\n", __func__, err);
4072     diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
4073     index 3e32146472a5..d30c6b246342 100644
4074     --- a/drivers/xen/xen-scsiback.c
4075     +++ b/drivers/xen/xen-scsiback.c
4076     @@ -712,12 +712,11 @@ static int prepare_pending_reqs(struct vscsibk_info *info,
4077     static int scsiback_do_cmd_fn(struct vscsibk_info *info)
4078     {
4079     struct vscsiif_back_ring *ring = &info->ring;
4080     - struct vscsiif_request *ring_req;
4081     + struct vscsiif_request ring_req;
4082     struct vscsibk_pend *pending_req;
4083     RING_IDX rc, rp;
4084     int err, more_to_do;
4085     uint32_t result;
4086     - uint8_t act;
4087    
4088     rc = ring->req_cons;
4089     rp = ring->sring->req_prod;
4090     @@ -738,11 +737,10 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
4091     if (!pending_req)
4092     return 1;
4093    
4094     - ring_req = RING_GET_REQUEST(ring, rc);
4095     + ring_req = *RING_GET_REQUEST(ring, rc);
4096     ring->req_cons = ++rc;
4097    
4098     - act = ring_req->act;
4099     - err = prepare_pending_reqs(info, ring_req, pending_req);
4100     + err = prepare_pending_reqs(info, &ring_req, pending_req);
4101     if (err) {
4102     switch (err) {
4103     case -ENODEV:
4104     @@ -758,9 +756,9 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
4105     return 1;
4106     }
4107    
4108     - switch (act) {
4109     + switch (ring_req.act) {
4110     case VSCSIIF_ACT_SCSI_CDB:
4111     - if (scsiback_gnttab_data_map(ring_req, pending_req)) {
4112     + if (scsiback_gnttab_data_map(&ring_req, pending_req)) {
4113     scsiback_fast_flush_area(pending_req);
4114     scsiback_do_resp_with_sense(NULL,
4115     DRIVER_ERROR << 24, 0, pending_req);
4116     @@ -771,7 +769,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
4117     break;
4118     case VSCSIIF_ACT_SCSI_ABORT:
4119     scsiback_device_action(pending_req, TMR_ABORT_TASK,
4120     - ring_req->ref_rqid);
4121     + ring_req.ref_rqid);
4122     break;
4123     case VSCSIIF_ACT_SCSI_RESET:
4124     scsiback_device_action(pending_req, TMR_LUN_RESET, 0);
4125     diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
4126     index d8fc0605b9d2..e1efcaa1b245 100644
4127     --- a/fs/binfmt_elf.c
4128     +++ b/fs/binfmt_elf.c
4129     @@ -554,11 +554,12 @@ out:
4130    
4131     static unsigned long randomize_stack_top(unsigned long stack_top)
4132     {
4133     - unsigned int random_variable = 0;
4134     + unsigned long random_variable = 0;
4135    
4136     if ((current->flags & PF_RANDOMIZE) &&
4137     !(current->personality & ADDR_NO_RANDOMIZE)) {
4138     - random_variable = get_random_int() & STACK_RND_MASK;
4139     + random_variable = (unsigned long) get_random_int();
4140     + random_variable &= STACK_RND_MASK;
4141     random_variable <<= PAGE_SHIFT;
4142     }
4143     #ifdef CONFIG_STACK_GROWSUP
4144     diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
4145     index 150822ee0a0b..c81ce0c7c1a9 100644
4146     --- a/fs/btrfs/ctree.c
4147     +++ b/fs/btrfs/ctree.c
4148     @@ -2609,32 +2609,23 @@ static int key_search(struct extent_buffer *b, struct btrfs_key *key,
4149     return 0;
4150     }
4151    
4152     -int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path,
4153     +int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
4154     u64 iobjectid, u64 ioff, u8 key_type,
4155     struct btrfs_key *found_key)
4156     {
4157     int ret;
4158     struct btrfs_key key;
4159     struct extent_buffer *eb;
4160     - struct btrfs_path *path;
4161     +
4162     + ASSERT(path);
4163    
4164     key.type = key_type;
4165     key.objectid = iobjectid;
4166     key.offset = ioff;
4167    
4168     - if (found_path == NULL) {
4169     - path = btrfs_alloc_path();
4170     - if (!path)
4171     - return -ENOMEM;
4172     - } else
4173     - path = found_path;
4174     -
4175     ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0);
4176     - if ((ret < 0) || (found_key == NULL)) {
4177     - if (path != found_path)
4178     - btrfs_free_path(path);
4179     + if ((ret < 0) || (found_key == NULL))
4180     return ret;
4181     - }
4182    
4183     eb = path->nodes[0];
4184     if (ret && path->slots[0] >= btrfs_header_nritems(eb)) {
4185     diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
4186     index 97676731190c..b1709831b1a1 100644
4187     --- a/fs/btrfs/disk-io.c
4188     +++ b/fs/btrfs/disk-io.c
4189     @@ -1630,6 +1630,7 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
4190     bool check_ref)
4191     {
4192     struct btrfs_root *root;
4193     + struct btrfs_path *path;
4194     int ret;
4195    
4196     if (location->objectid == BTRFS_ROOT_TREE_OBJECTID)
4197     @@ -1669,8 +1670,14 @@ again:
4198     if (ret)
4199     goto fail;
4200    
4201     - ret = btrfs_find_item(fs_info->tree_root, NULL, BTRFS_ORPHAN_OBJECTID,
4202     + path = btrfs_alloc_path();
4203     + if (!path) {
4204     + ret = -ENOMEM;
4205     + goto fail;
4206     + }
4207     + ret = btrfs_find_item(fs_info->tree_root, path, BTRFS_ORPHAN_OBJECTID,
4208     location->objectid, BTRFS_ORPHAN_ITEM_KEY, NULL);
4209     + btrfs_free_path(path);
4210     if (ret < 0)
4211     goto fail;
4212     if (ret == 0)
4213     @@ -2496,7 +2503,7 @@ int open_ctree(struct super_block *sb,
4214     features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
4215    
4216     if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
4217     - printk(KERN_ERR "BTRFS: has skinny extents\n");
4218     + printk(KERN_INFO "BTRFS: has skinny extents\n");
4219    
4220     /*
4221     * flag our filesystem as having big metadata blocks if
4222     diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
4223     index 7d96cc961663..ee1c60454a5f 100644
4224     --- a/fs/btrfs/tree-log.c
4225     +++ b/fs/btrfs/tree-log.c
4226     @@ -488,8 +488,20 @@ insert:
4227     src_item = (struct btrfs_inode_item *)src_ptr;
4228     dst_item = (struct btrfs_inode_item *)dst_ptr;
4229    
4230     - if (btrfs_inode_generation(eb, src_item) == 0)
4231     + if (btrfs_inode_generation(eb, src_item) == 0) {
4232     + struct extent_buffer *dst_eb = path->nodes[0];
4233     +
4234     + if (S_ISREG(btrfs_inode_mode(eb, src_item)) &&
4235     + S_ISREG(btrfs_inode_mode(dst_eb, dst_item))) {
4236     + struct btrfs_map_token token;
4237     + u64 ino_size = btrfs_inode_size(eb, src_item);
4238     +
4239     + btrfs_init_map_token(&token);
4240     + btrfs_set_token_inode_size(dst_eb, dst_item,
4241     + ino_size, &token);
4242     + }
4243     goto no_copy;
4244     + }
4245    
4246     if (overwrite_root &&
4247     S_ISDIR(btrfs_inode_mode(eb, src_item)) &&
4248     @@ -1257,10 +1269,19 @@ static int insert_orphan_item(struct btrfs_trans_handle *trans,
4249     struct btrfs_root *root, u64 offset)
4250     {
4251     int ret;
4252     - ret = btrfs_find_item(root, NULL, BTRFS_ORPHAN_OBJECTID,
4253     + struct btrfs_path *path;
4254     +
4255     + path = btrfs_alloc_path();
4256     + if (!path)
4257     + return -ENOMEM;
4258     +
4259     + ret = btrfs_find_item(root, path, BTRFS_ORPHAN_OBJECTID,
4260     offset, BTRFS_ORPHAN_ITEM_KEY, NULL);
4261     if (ret > 0)
4262     ret = btrfs_insert_orphan_item(trans, root, offset);
4263     +
4264     + btrfs_free_path(path);
4265     +
4266     return ret;
4267     }
4268    
4269     @@ -3209,7 +3230,8 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
4270     static void fill_inode_item(struct btrfs_trans_handle *trans,
4271     struct extent_buffer *leaf,
4272     struct btrfs_inode_item *item,
4273     - struct inode *inode, int log_inode_only)
4274     + struct inode *inode, int log_inode_only,
4275     + u64 logged_isize)
4276     {
4277     struct btrfs_map_token token;
4278    
4279     @@ -3222,7 +3244,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
4280     * to say 'update this inode with these values'
4281     */
4282     btrfs_set_token_inode_generation(leaf, item, 0, &token);
4283     - btrfs_set_token_inode_size(leaf, item, 0, &token);
4284     + btrfs_set_token_inode_size(leaf, item, logged_isize, &token);
4285     } else {
4286     btrfs_set_token_inode_generation(leaf, item,
4287     BTRFS_I(inode)->generation,
4288     @@ -3274,7 +3296,7 @@ static int log_inode_item(struct btrfs_trans_handle *trans,
4289     return ret;
4290     inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
4291     struct btrfs_inode_item);
4292     - fill_inode_item(trans, path->nodes[0], inode_item, inode, 0);
4293     + fill_inode_item(trans, path->nodes[0], inode_item, inode, 0, 0);
4294     btrfs_release_path(path);
4295     return 0;
4296     }
4297     @@ -3283,7 +3305,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
4298     struct inode *inode,
4299     struct btrfs_path *dst_path,
4300     struct btrfs_path *src_path, u64 *last_extent,
4301     - int start_slot, int nr, int inode_only)
4302     + int start_slot, int nr, int inode_only,
4303     + u64 logged_isize)
4304     {
4305     unsigned long src_offset;
4306     unsigned long dst_offset;
4307     @@ -3340,7 +3363,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
4308     dst_path->slots[0],
4309     struct btrfs_inode_item);
4310     fill_inode_item(trans, dst_path->nodes[0], inode_item,
4311     - inode, inode_only == LOG_INODE_EXISTS);
4312     + inode, inode_only == LOG_INODE_EXISTS,
4313     + logged_isize);
4314     } else {
4315     copy_extent_buffer(dst_path->nodes[0], src, dst_offset,
4316     src_offset, ins_sizes[i]);
4317     @@ -3886,6 +3910,33 @@ process:
4318     return ret;
4319     }
4320    
4321     +static int logged_inode_size(struct btrfs_root *log, struct inode *inode,
4322     + struct btrfs_path *path, u64 *size_ret)
4323     +{
4324     + struct btrfs_key key;
4325     + int ret;
4326     +
4327     + key.objectid = btrfs_ino(inode);
4328     + key.type = BTRFS_INODE_ITEM_KEY;
4329     + key.offset = 0;
4330     +
4331     + ret = btrfs_search_slot(NULL, log, &key, path, 0, 0);
4332     + if (ret < 0) {
4333     + return ret;
4334     + } else if (ret > 0) {
4335     + *size_ret = i_size_read(inode);
4336     + } else {
4337     + struct btrfs_inode_item *item;
4338     +
4339     + item = btrfs_item_ptr(path->nodes[0], path->slots[0],
4340     + struct btrfs_inode_item);
4341     + *size_ret = btrfs_inode_size(path->nodes[0], item);
4342     + }
4343     +
4344     + btrfs_release_path(path);
4345     + return 0;
4346     +}
4347     +
4348     /* log a single inode in the tree log.
4349     * At least one parent directory for this inode must exist in the tree
4350     * or be logged already.
4351     @@ -3923,6 +3974,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4352     bool fast_search = false;
4353     u64 ino = btrfs_ino(inode);
4354     struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
4355     + u64 logged_isize = 0;
4356    
4357     path = btrfs_alloc_path();
4358     if (!path)
4359     @@ -3976,6 +4028,25 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4360     max_key_type = BTRFS_XATTR_ITEM_KEY;
4361     ret = drop_objectid_items(trans, log, path, ino, max_key_type);
4362     } else {
4363     + if (inode_only == LOG_INODE_EXISTS) {
4364     + /*
4365     + * Make sure the new inode item we write to the log has
4366     + * the same isize as the current one (if it exists).
4367     + * This is necessary to prevent data loss after log
4368     + * replay, and also to prevent doing a wrong expanding
4369     + * truncate - for e.g. create file, write 4K into offset
4370     + * 0, fsync, write 4K into offset 4096, add hard link,
4371     + * fsync some other file (to sync log), power fail - if
4372     + * we use the inode's current i_size, after log replay
4373     + * we get a 8Kb file, with the last 4Kb extent as a hole
4374     + * (zeroes), as if an expanding truncate happened,
4375     + * instead of getting a file of 4Kb only.
4376     + */
4377     + err = logged_inode_size(log, inode, path,
4378     + &logged_isize);
4379     + if (err)
4380     + goto out_unlock;
4381     + }
4382     if (test_and_clear_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
4383     &BTRFS_I(inode)->runtime_flags)) {
4384     clear_bit(BTRFS_INODE_COPY_EVERYTHING,
4385     @@ -4031,7 +4102,8 @@ again:
4386     }
4387    
4388     ret = copy_items(trans, inode, dst_path, path, &last_extent,
4389     - ins_start_slot, ins_nr, inode_only);
4390     + ins_start_slot, ins_nr, inode_only,
4391     + logged_isize);
4392     if (ret < 0) {
4393     err = ret;
4394     goto out_unlock;
4395     @@ -4055,7 +4127,7 @@ next_slot:
4396     if (ins_nr) {
4397     ret = copy_items(trans, inode, dst_path, path,
4398     &last_extent, ins_start_slot,
4399     - ins_nr, inode_only);
4400     + ins_nr, inode_only, logged_isize);
4401     if (ret < 0) {
4402     err = ret;
4403     goto out_unlock;
4404     @@ -4076,7 +4148,8 @@ next_slot:
4405     }
4406     if (ins_nr) {
4407     ret = copy_items(trans, inode, dst_path, path, &last_extent,
4408     - ins_start_slot, ins_nr, inode_only);
4409     + ins_start_slot, ins_nr, inode_only,
4410     + logged_isize);
4411     if (ret < 0) {
4412     err = ret;
4413     goto out_unlock;
4414     diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
4415     index 7654e87b0428..9ad5ba4b299b 100644
4416     --- a/fs/jffs2/scan.c
4417     +++ b/fs/jffs2/scan.c
4418     @@ -510,6 +510,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
4419     sumlen = c->sector_size - je32_to_cpu(sm->offset);
4420     sumptr = buf + buf_size - sumlen;
4421    
4422     + /* sm->offset maybe wrong but MAGIC maybe right */
4423     + if (sumlen > c->sector_size)
4424     + goto full_scan;
4425     +
4426     /* Now, make sure the summary itself is available */
4427     if (sumlen > buf_size) {
4428     /* Need to kmalloc for this. */
4429     @@ -544,6 +548,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
4430     }
4431     }
4432    
4433     +full_scan:
4434     buf_ofs = jeb->offset;
4435    
4436     if (!buf_size) {
4437     diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
4438     index 9106f42c472c..67bdc0bb9aea 100644
4439     --- a/fs/lockd/mon.c
4440     +++ b/fs/lockd/mon.c
4441     @@ -65,7 +65,7 @@ static inline struct sockaddr *nsm_addr(const struct nsm_handle *nsm)
4442     return (struct sockaddr *)&nsm->sm_addr;
4443     }
4444    
4445     -static struct rpc_clnt *nsm_create(struct net *net)
4446     +static struct rpc_clnt *nsm_create(struct net *net, const char *nodename)
4447     {
4448     struct sockaddr_in sin = {
4449     .sin_family = AF_INET,
4450     @@ -77,6 +77,7 @@ static struct rpc_clnt *nsm_create(struct net *net)
4451     .address = (struct sockaddr *)&sin,
4452     .addrsize = sizeof(sin),
4453     .servername = "rpc.statd",
4454     + .nodename = nodename,
4455     .program = &nsm_program,
4456     .version = NSM_VERSION,
4457     .authflavor = RPC_AUTH_NULL,
4458     @@ -102,7 +103,7 @@ out:
4459     return clnt;
4460     }
4461    
4462     -static struct rpc_clnt *nsm_client_get(struct net *net)
4463     +static struct rpc_clnt *nsm_client_get(struct net *net, const char *nodename)
4464     {
4465     struct rpc_clnt *clnt, *new;
4466     struct lockd_net *ln = net_generic(net, lockd_net_id);
4467     @@ -111,7 +112,7 @@ static struct rpc_clnt *nsm_client_get(struct net *net)
4468     if (clnt != NULL)
4469     goto out;
4470    
4471     - clnt = new = nsm_create(net);
4472     + clnt = new = nsm_create(net, nodename);
4473     if (IS_ERR(clnt))
4474     goto out;
4475    
4476     @@ -190,19 +191,23 @@ int nsm_monitor(const struct nlm_host *host)
4477     struct nsm_res res;
4478     int status;
4479     struct rpc_clnt *clnt;
4480     + const char *nodename = NULL;
4481    
4482     dprintk("lockd: nsm_monitor(%s)\n", nsm->sm_name);
4483    
4484     if (nsm->sm_monitored)
4485     return 0;
4486    
4487     + if (host->h_rpcclnt)
4488     + nodename = host->h_rpcclnt->cl_nodename;
4489     +
4490     /*
4491     * Choose whether to record the caller_name or IP address of
4492     * this peer in the local rpc.statd's database.
4493     */
4494     nsm->sm_mon_name = nsm_use_hostnames ? nsm->sm_name : nsm->sm_addrbuf;
4495    
4496     - clnt = nsm_client_get(host->net);
4497     + clnt = nsm_client_get(host->net, nodename);
4498     if (IS_ERR(clnt)) {
4499     status = PTR_ERR(clnt);
4500     dprintk("lockd: failed to create NSM upcall transport, "
4501     diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
4502     index b8fb3a4ef649..351be9205bf8 100644
4503     --- a/fs/nfs/callback.c
4504     +++ b/fs/nfs/callback.c
4505     @@ -128,22 +128,24 @@ nfs41_callback_svc(void *vrqstp)
4506     if (try_to_freeze())
4507     continue;
4508    
4509     - prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
4510     + prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_UNINTERRUPTIBLE);
4511     spin_lock_bh(&serv->sv_cb_lock);
4512     if (!list_empty(&serv->sv_cb_list)) {
4513     req = list_first_entry(&serv->sv_cb_list,
4514     struct rpc_rqst, rq_bc_list);
4515     list_del(&req->rq_bc_list);
4516     spin_unlock_bh(&serv->sv_cb_lock);
4517     + finish_wait(&serv->sv_cb_waitq, &wq);
4518     dprintk("Invoking bc_svc_process()\n");
4519     error = bc_svc_process(serv, req, rqstp);
4520     dprintk("bc_svc_process() returned w/ error code= %d\n",
4521     error);
4522     } else {
4523     spin_unlock_bh(&serv->sv_cb_lock);
4524     - schedule();
4525     + /* schedule_timeout to game the hung task watchdog */
4526     + schedule_timeout(60 * HZ);
4527     + finish_wait(&serv->sv_cb_waitq, &wq);
4528     }
4529     - finish_wait(&serv->sv_cb_waitq, &wq);
4530     }
4531     return 0;
4532     }
4533     diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
4534     index f4ccfe6521ec..02f8d09e119f 100644
4535     --- a/fs/nfs/callback_xdr.c
4536     +++ b/fs/nfs/callback_xdr.c
4537     @@ -464,8 +464,10 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
4538    
4539     for (i = 0; i < args->csa_nrclists; i++) {
4540     status = decode_rc_list(xdr, &args->csa_rclists[i]);
4541     - if (status)
4542     + if (status) {
4543     + args->csa_nrclists = i;
4544     goto out_free;
4545     + }
4546     }
4547     }
4548     status = 0;
4549     diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
4550     index 294692ff83b1..a094b0c34ac3 100644
4551     --- a/fs/nfs/direct.c
4552     +++ b/fs/nfs/direct.c
4553     @@ -242,7 +242,7 @@ static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
4554     void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
4555     struct nfs_direct_req *dreq)
4556     {
4557     - cinfo->lock = &dreq->lock;
4558     + cinfo->lock = &dreq->inode->i_lock;
4559     cinfo->mds = &dreq->mds_cinfo;
4560     cinfo->ds = &dreq->ds_cinfo;
4561     cinfo->dreq = dreq;
4562     diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
4563     index efaa31c70fbe..e1acc1c4ce65 100644
4564     --- a/fs/nfs/internal.h
4565     +++ b/fs/nfs/internal.h
4566     @@ -377,7 +377,7 @@ extern struct rpc_stat nfs_rpcstat;
4567    
4568     extern int __init register_nfs_fs(void);
4569     extern void __exit unregister_nfs_fs(void);
4570     -extern void nfs_sb_active(struct super_block *sb);
4571     +extern bool nfs_sb_active(struct super_block *sb);
4572     extern void nfs_sb_deactive(struct super_block *sb);
4573    
4574     /* namespace.c */
4575     @@ -495,6 +495,26 @@ extern int nfs41_walk_client_list(struct nfs_client *clp,
4576     struct nfs_client **result,
4577     struct rpc_cred *cred);
4578    
4579     +static inline struct inode *nfs_igrab_and_active(struct inode *inode)
4580     +{
4581     + inode = igrab(inode);
4582     + if (inode != NULL && !nfs_sb_active(inode->i_sb)) {
4583     + iput(inode);
4584     + inode = NULL;
4585     + }
4586     + return inode;
4587     +}
4588     +
4589     +static inline void nfs_iput_and_deactive(struct inode *inode)
4590     +{
4591     + if (inode != NULL) {
4592     + struct super_block *sb = inode->i_sb;
4593     +
4594     + iput(inode);
4595     + nfs_sb_deactive(sb);
4596     + }
4597     +}
4598     +
4599     /*
4600     * Determine the device name as a string
4601     */
4602     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4603     index 83f3a7d7466e..cd617076aeca 100644
4604     --- a/fs/nfs/nfs4proc.c
4605     +++ b/fs/nfs/nfs4proc.c
4606     @@ -5130,9 +5130,13 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
4607     static void nfs4_delegreturn_release(void *calldata)
4608     {
4609     struct nfs4_delegreturndata *data = calldata;
4610     + struct inode *inode = data->inode;
4611    
4612     - if (data->roc)
4613     - pnfs_roc_release(data->inode);
4614     + if (inode) {
4615     + if (data->roc)
4616     + pnfs_roc_release(inode);
4617     + nfs_iput_and_deactive(inode);
4618     + }
4619     kfree(calldata);
4620     }
4621    
4622     @@ -5189,9 +5193,9 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
4623     nfs_fattr_init(data->res.fattr);
4624     data->timestamp = jiffies;
4625     data->rpc_status = 0;
4626     - data->inode = inode;
4627     - data->roc = list_empty(&NFS_I(inode)->open_files) ?
4628     - pnfs_roc(inode) : false;
4629     + data->inode = nfs_igrab_and_active(inode);
4630     + if (data->inode)
4631     + data->roc = nfs4_roc(inode);
4632    
4633     task_setup_data.callback_data = data;
4634     msg.rpc_argp = &data->args;
4635     diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
4636     index 0a5dda4d85c2..883ee88e5f5e 100644
4637     --- a/fs/nfs/pnfs.c
4638     +++ b/fs/nfs/pnfs.c
4639     @@ -1445,19 +1445,19 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r
4640     {
4641     u64 rd_size = req->wb_bytes;
4642    
4643     - WARN_ON_ONCE(pgio->pg_lseg != NULL);
4644     -
4645     - if (pgio->pg_dreq == NULL)
4646     - rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
4647     - else
4648     - rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
4649     -
4650     - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
4651     - req->wb_context,
4652     - req_offset(req),
4653     - rd_size,
4654     - IOMODE_READ,
4655     - GFP_KERNEL);
4656     + if (pgio->pg_lseg == NULL) {
4657     + if (pgio->pg_dreq == NULL)
4658     + rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
4659     + else
4660     + rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
4661     +
4662     + pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
4663     + req->wb_context,
4664     + req_offset(req),
4665     + rd_size,
4666     + IOMODE_READ,
4667     + GFP_KERNEL);
4668     + }
4669     /* If no lseg, fall back to read through mds */
4670     if (pgio->pg_lseg == NULL)
4671     nfs_pageio_reset_read_mds(pgio);
4672     @@ -1469,14 +1469,13 @@ void
4673     pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
4674     struct nfs_page *req, u64 wb_size)
4675     {
4676     - WARN_ON_ONCE(pgio->pg_lseg != NULL);
4677     -
4678     - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
4679     - req->wb_context,
4680     - req_offset(req),
4681     - wb_size,
4682     - IOMODE_RW,
4683     - GFP_NOFS);
4684     + if (pgio->pg_lseg == NULL)
4685     + pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
4686     + req->wb_context,
4687     + req_offset(req),
4688     + wb_size,
4689     + IOMODE_RW,
4690     + GFP_NOFS);
4691     /* If no lseg, fall back to write through mds */
4692     if (pgio->pg_lseg == NULL)
4693     nfs_pageio_reset_write_mds(pgio);
4694     diff --git a/fs/nfs/super.c b/fs/nfs/super.c
4695     index 31a11b0e885d..368d9395d2e7 100644
4696     --- a/fs/nfs/super.c
4697     +++ b/fs/nfs/super.c
4698     @@ -405,12 +405,15 @@ void __exit unregister_nfs_fs(void)
4699     unregister_filesystem(&nfs_fs_type);
4700     }
4701    
4702     -void nfs_sb_active(struct super_block *sb)
4703     +bool nfs_sb_active(struct super_block *sb)
4704     {
4705     struct nfs_server *server = NFS_SB(sb);
4706    
4707     - if (atomic_inc_return(&server->active) == 1)
4708     - atomic_inc(&sb->s_active);
4709     + if (!atomic_inc_not_zero(&sb->s_active))
4710     + return false;
4711     + if (atomic_inc_return(&server->active) != 1)
4712     + atomic_dec(&sb->s_active);
4713     + return true;
4714     }
4715     EXPORT_SYMBOL_GPL(nfs_sb_active);
4716    
4717     diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
4718     index 10b653930ee2..465223b7592e 100644
4719     --- a/fs/ocfs2/quota_local.c
4720     +++ b/fs/ocfs2/quota_local.c
4721     @@ -701,8 +701,8 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
4722     /* We don't need the lock and we have to acquire quota file locks
4723     * which will later depend on this lock */
4724     mutex_unlock(&sb_dqopt(sb)->dqio_mutex);
4725     - info->dqi_maxblimit = 0x7fffffffffffffffLL;
4726     - info->dqi_maxilimit = 0x7fffffffffffffffLL;
4727     + info->dqi_max_spc_limit = 0x7fffffffffffffffLL;
4728     + info->dqi_max_ino_limit = 0x7fffffffffffffffLL;
4729     oinfo = kmalloc(sizeof(struct ocfs2_mem_dqinfo), GFP_NOFS);
4730     if (!oinfo) {
4731     mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota"
4732     diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
4733     index 4e0388cffe3d..e8972bcddfb4 100644
4734     --- a/fs/proc/task_mmu.c
4735     +++ b/fs/proc/task_mmu.c
4736     @@ -1034,7 +1034,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
4737     struct vm_area_struct *vma;
4738     struct pagemapread *pm = walk->private;
4739     spinlock_t *ptl;
4740     - pte_t *pte;
4741     + pte_t *pte, *orig_pte;
4742     int err = 0;
4743    
4744     /* find the first VMA at or above 'addr' */
4745     @@ -1095,15 +1095,19 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
4746     BUG_ON(is_vm_hugetlb_page(vma));
4747    
4748     /* Addresses in the VMA. */
4749     - for (; addr < min(end, vma->vm_end); addr += PAGE_SIZE) {
4750     + orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
4751     + for (; addr < min(end, vma->vm_end); pte++, addr += PAGE_SIZE) {
4752     pagemap_entry_t pme;
4753     - pte = pte_offset_map(pmd, addr);
4754     +
4755     pte_to_pagemap_entry(&pme, pm, vma, addr, *pte);
4756     - pte_unmap(pte);
4757     err = add_to_pagemap(addr, &pme, pm);
4758     if (err)
4759     - return err;
4760     + break;
4761     }
4762     + pte_unmap_unlock(orig_pte, ptl);
4763     +
4764     + if (err)
4765     + return err;
4766    
4767     if (addr == end)
4768     break;
4769     diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
4770     index 9340228aff6e..05fea2ac116c 100644
4771     --- a/fs/quota/dquot.c
4772     +++ b/fs/quota/dquot.c
4773     @@ -2380,16 +2380,6 @@ out:
4774     }
4775     EXPORT_SYMBOL(dquot_quota_on_mount);
4776    
4777     -static inline qsize_t qbtos(qsize_t blocks)
4778     -{
4779     - return blocks << QIF_DQBLKSIZE_BITS;
4780     -}
4781     -
4782     -static inline qsize_t stoqb(qsize_t space)
4783     -{
4784     - return (space + QIF_DQBLKSIZE - 1) >> QIF_DQBLKSIZE_BITS;
4785     -}
4786     -
4787     /* Generic routine for getting common part of quota structure */
4788     static void do_get_dqblk(struct dquot *dquot, struct qc_dqblk *di)
4789     {
4790     @@ -2439,13 +2429,13 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
4791     return -EINVAL;
4792    
4793     if (((di->d_fieldmask & QC_SPC_SOFT) &&
4794     - stoqb(di->d_spc_softlimit) > dqi->dqi_maxblimit) ||
4795     + di->d_spc_softlimit > dqi->dqi_max_spc_limit) ||
4796     ((di->d_fieldmask & QC_SPC_HARD) &&
4797     - stoqb(di->d_spc_hardlimit) > dqi->dqi_maxblimit) ||
4798     + di->d_spc_hardlimit > dqi->dqi_max_spc_limit) ||
4799     ((di->d_fieldmask & QC_INO_SOFT) &&
4800     - (di->d_ino_softlimit > dqi->dqi_maxilimit)) ||
4801     + (di->d_ino_softlimit > dqi->dqi_max_ino_limit)) ||
4802     ((di->d_fieldmask & QC_INO_HARD) &&
4803     - (di->d_ino_hardlimit > dqi->dqi_maxilimit)))
4804     + (di->d_ino_hardlimit > dqi->dqi_max_ino_limit)))
4805     return -ERANGE;
4806    
4807     spin_lock(&dq_data_lock);
4808     diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
4809     index 469c6848b322..8fe79beced5c 100644
4810     --- a/fs/quota/quota_v1.c
4811     +++ b/fs/quota/quota_v1.c
4812     @@ -169,8 +169,8 @@ static int v1_read_file_info(struct super_block *sb, int type)
4813     }
4814     ret = 0;
4815     /* limits are stored as unsigned 32-bit data */
4816     - dqopt->info[type].dqi_maxblimit = 0xffffffff;
4817     - dqopt->info[type].dqi_maxilimit = 0xffffffff;
4818     + dqopt->info[type].dqi_max_spc_limit = 0xffffffffULL << QUOTABLOCK_BITS;
4819     + dqopt->info[type].dqi_max_ino_limit = 0xffffffff;
4820     dqopt->info[type].dqi_igrace =
4821     dqblk.dqb_itime ? dqblk.dqb_itime : MAX_IQ_TIME;
4822     dqopt->info[type].dqi_bgrace =
4823     diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
4824     index 02751ec695c5..d1a8054bba9a 100644
4825     --- a/fs/quota/quota_v2.c
4826     +++ b/fs/quota/quota_v2.c
4827     @@ -117,12 +117,12 @@ static int v2_read_file_info(struct super_block *sb, int type)
4828     qinfo = info->dqi_priv;
4829     if (version == 0) {
4830     /* limits are stored as unsigned 32-bit data */
4831     - info->dqi_maxblimit = 0xffffffff;
4832     - info->dqi_maxilimit = 0xffffffff;
4833     + info->dqi_max_spc_limit = 0xffffffffULL << QUOTABLOCK_BITS;
4834     + info->dqi_max_ino_limit = 0xffffffff;
4835     } else {
4836     - /* used space is stored as unsigned 64-bit value */
4837     - info->dqi_maxblimit = 0xffffffffffffffffULL; /* 2^64-1 */
4838     - info->dqi_maxilimit = 0xffffffffffffffffULL;
4839     + /* used space is stored as unsigned 64-bit value in bytes */
4840     + info->dqi_max_spc_limit = 0xffffffffffffffffULL; /* 2^64-1 */
4841     + info->dqi_max_ino_limit = 0xffffffffffffffffULL;
4842     }
4843     info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
4844     info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
4845     diff --git a/fs/udf/inode.c b/fs/udf/inode.c
4846     index 5bc71d9a674a..7b72b7dd8906 100644
4847     --- a/fs/udf/inode.c
4848     +++ b/fs/udf/inode.c
4849     @@ -1288,6 +1288,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
4850     struct kernel_lb_addr *iloc = &iinfo->i_location;
4851     unsigned int link_count;
4852     unsigned int indirections = 0;
4853     + int bs = inode->i_sb->s_blocksize;
4854     int ret = -EIO;
4855    
4856     reread:
4857     @@ -1374,38 +1375,35 @@ reread:
4858     if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) {
4859     iinfo->i_efe = 1;
4860     iinfo->i_use = 0;
4861     - ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize -
4862     + ret = udf_alloc_i_data(inode, bs -
4863     sizeof(struct extendedFileEntry));
4864     if (ret)
4865     goto out;
4866     memcpy(iinfo->i_ext.i_data,
4867     bh->b_data + sizeof(struct extendedFileEntry),
4868     - inode->i_sb->s_blocksize -
4869     - sizeof(struct extendedFileEntry));
4870     + bs - sizeof(struct extendedFileEntry));
4871     } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) {
4872     iinfo->i_efe = 0;
4873     iinfo->i_use = 0;
4874     - ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize -
4875     - sizeof(struct fileEntry));
4876     + ret = udf_alloc_i_data(inode, bs - sizeof(struct fileEntry));
4877     if (ret)
4878     goto out;
4879     memcpy(iinfo->i_ext.i_data,
4880     bh->b_data + sizeof(struct fileEntry),
4881     - inode->i_sb->s_blocksize - sizeof(struct fileEntry));
4882     + bs - sizeof(struct fileEntry));
4883     } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) {
4884     iinfo->i_efe = 0;
4885     iinfo->i_use = 1;
4886     iinfo->i_lenAlloc = le32_to_cpu(
4887     ((struct unallocSpaceEntry *)bh->b_data)->
4888     lengthAllocDescs);
4889     - ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize -
4890     + ret = udf_alloc_i_data(inode, bs -
4891     sizeof(struct unallocSpaceEntry));
4892     if (ret)
4893     goto out;
4894     memcpy(iinfo->i_ext.i_data,
4895     bh->b_data + sizeof(struct unallocSpaceEntry),
4896     - inode->i_sb->s_blocksize -
4897     - sizeof(struct unallocSpaceEntry));
4898     + bs - sizeof(struct unallocSpaceEntry));
4899     return 0;
4900     }
4901    
4902     @@ -1489,6 +1487,15 @@ reread:
4903     }
4904     inode->i_generation = iinfo->i_unique;
4905    
4906     + /*
4907     + * Sanity check length of allocation descriptors and extended attrs to
4908     + * avoid integer overflows
4909     + */
4910     + if (iinfo->i_lenEAttr > bs || iinfo->i_lenAlloc > bs)
4911     + goto out;
4912     + /* Now do exact checks */
4913     + if (udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc > bs)
4914     + goto out;
4915     /* Sanity checks for files in ICB so that we don't get confused later */
4916     if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
4917     /*
4918     @@ -1498,8 +1505,7 @@ reread:
4919     if (iinfo->i_lenAlloc != inode->i_size)
4920     goto out;
4921     /* File in ICB has to fit in there... */
4922     - if (inode->i_size > inode->i_sb->s_blocksize -
4923     - udf_file_entry_alloc_offset(inode))
4924     + if (inode->i_size > bs - udf_file_entry_alloc_offset(inode))
4925     goto out;
4926     }
4927    
4928     diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
4929     index 79c981984dca..661666ecac22 100644
4930     --- a/fs/xfs/libxfs/xfs_bmap.c
4931     +++ b/fs/xfs/libxfs/xfs_bmap.c
4932     @@ -976,7 +976,11 @@ xfs_bmap_local_to_extents(
4933     *firstblock = args.fsbno;
4934     bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
4935    
4936     - /* initialise the block and copy the data */
4937     + /*
4938     + * Initialise the block and copy the data
4939     + *
4940     + * Note: init_fn must set the buffer log item type correctly!
4941     + */
4942     init_fn(tp, bp, ip, ifp);
4943    
4944     /* account for the change in fork size and log everything */
4945     diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
4946     index 5782f037eab4..a7dce9aea5b5 100644
4947     --- a/fs/xfs/libxfs/xfs_symlink_remote.c
4948     +++ b/fs/xfs/libxfs/xfs_symlink_remote.c
4949     @@ -180,6 +180,8 @@ xfs_symlink_local_to_remote(
4950     struct xfs_mount *mp = ip->i_mount;
4951     char *buf;
4952    
4953     + xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF);
4954     +
4955     if (!xfs_sb_version_hascrc(&mp->m_sb)) {
4956     bp->b_ops = NULL;
4957     memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes);
4958     diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
4959     index f15969543326..1a6c9b936789 100644
4960     --- a/fs/xfs/xfs_buf_item.c
4961     +++ b/fs/xfs/xfs_buf_item.c
4962     @@ -319,6 +319,10 @@ xfs_buf_item_format(
4963     ASSERT(atomic_read(&bip->bli_refcount) > 0);
4964     ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
4965     (bip->bli_flags & XFS_BLI_STALE));
4966     + ASSERT((bip->bli_flags & XFS_BLI_STALE) ||
4967     + (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF
4968     + && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF));
4969     +
4970    
4971     /*
4972     * If it is an inode buffer, transfer the in-memory state to the
4973     diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
4974     index 8ed049d1e332..3cc309a19ea8 100644
4975     --- a/fs/xfs/xfs_inode.c
4976     +++ b/fs/xfs/xfs_inode.c
4977     @@ -2000,6 +2000,7 @@ xfs_iunlink(
4978     agi->agi_unlinked[bucket_index] = cpu_to_be32(agino);
4979     offset = offsetof(xfs_agi_t, agi_unlinked) +
4980     (sizeof(xfs_agino_t) * bucket_index);
4981     + xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF);
4982     xfs_trans_log_buf(tp, agibp, offset,
4983     (offset + sizeof(xfs_agino_t) - 1));
4984     return 0;
4985     @@ -2091,6 +2092,7 @@ xfs_iunlink_remove(
4986     agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino);
4987     offset = offsetof(xfs_agi_t, agi_unlinked) +
4988     (sizeof(xfs_agino_t) * bucket_index);
4989     + xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF);
4990     xfs_trans_log_buf(tp, agibp, offset,
4991     (offset + sizeof(xfs_agino_t) - 1));
4992     } else {
4993     diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
4994     index d68f23021af3..cf2bc2dd702e 100644
4995     --- a/fs/xfs/xfs_qm.c
4996     +++ b/fs/xfs/xfs_qm.c
4997     @@ -844,6 +844,11 @@ xfs_qm_reset_dqcounts(
4998     */
4999     xfs_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR,
5000     "xfs_quotacheck");
5001     + /*
5002     + * Reset type in case we are reusing group quota file for
5003     + * project quotas or vice versa
5004     + */
5005     + ddq->d_flags = type;
5006     ddq->d_bcount = 0;
5007     ddq->d_icount = 0;
5008     ddq->d_rtbcount = 0;
5009     diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
5010     index 30e8e3410955..32dfdb5d3e6b 100644
5011     --- a/fs/xfs/xfs_trans.c
5012     +++ b/fs/xfs/xfs_trans.c
5013     @@ -474,6 +474,7 @@ xfs_trans_apply_sb_deltas(
5014     whole = 1;
5015     }
5016    
5017     + xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
5018     if (whole)
5019     /*
5020     * Log the whole thing, the fields are noncontiguous.
5021     diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
5022     index 1c804b057fb1..7ee1774edee5 100644
5023     --- a/include/linux/fsnotify.h
5024     +++ b/include/linux/fsnotify.h
5025     @@ -101,8 +101,10 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
5026     new_dir_mask |= FS_ISDIR;
5027     }
5028    
5029     - fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie);
5030     - fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie);
5031     + fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name,
5032     + fs_cookie);
5033     + fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name,
5034     + fs_cookie);
5035    
5036     if (target)
5037     fsnotify_link_count(target);
5038     diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
5039     index 47ebb4fafd87..d77a08d25223 100644
5040     --- a/include/linux/nfs_xdr.h
5041     +++ b/include/linux/nfs_xdr.h
5042     @@ -1328,7 +1328,7 @@ struct nfs_commit_completion_ops {
5043     };
5044    
5045     struct nfs_commit_info {
5046     - spinlock_t *lock;
5047     + spinlock_t *lock; /* inode->i_lock */
5048     struct nfs_mds_commit_info *mds;
5049     struct pnfs_ds_commit_info *ds;
5050     struct nfs_direct_req *dreq; /* O_DIRECT request */
5051     diff --git a/include/linux/quota.h b/include/linux/quota.h
5052     index 224fb8154f8f..8b0877faa7f5 100644
5053     --- a/include/linux/quota.h
5054     +++ b/include/linux/quota.h
5055     @@ -211,8 +211,8 @@ struct mem_dqinfo {
5056     unsigned long dqi_flags;
5057     unsigned int dqi_bgrace;
5058     unsigned int dqi_igrace;
5059     - qsize_t dqi_maxblimit;
5060     - qsize_t dqi_maxilimit;
5061     + qsize_t dqi_max_spc_limit;
5062     + qsize_t dqi_max_ino_limit;
5063     void *dqi_priv;
5064     };
5065    
5066     diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
5067     index 70736b98c721..b363a0f6dfe1 100644
5068     --- a/include/linux/sunrpc/clnt.h
5069     +++ b/include/linux/sunrpc/clnt.h
5070     @@ -57,7 +57,7 @@ struct rpc_clnt {
5071     const struct rpc_timeout *cl_timeout; /* Timeout strategy */
5072    
5073     int cl_nodelen; /* nodename length */
5074     - char cl_nodename[UNX_MAXNODENAME];
5075     + char cl_nodename[UNX_MAXNODENAME+1];
5076     struct rpc_pipe_dir_head cl_pipedir_objects;
5077     struct rpc_clnt * cl_parent; /* Points to parent of clones */
5078     struct rpc_rtt cl_rtt_default;
5079     @@ -109,6 +109,7 @@ struct rpc_create_args {
5080     struct sockaddr *saddress;
5081     const struct rpc_timeout *timeout;
5082     const char *servername;
5083     + const char *nodename;
5084     const struct rpc_program *program;
5085     u32 prognumber; /* overrides program->number */
5086     u32 version;
5087     diff --git a/include/linux/usb.h b/include/linux/usb.h
5088     index 447a7e2fc19b..3827bffc11a7 100644
5089     --- a/include/linux/usb.h
5090     +++ b/include/linux/usb.h
5091     @@ -127,10 +127,6 @@ enum usb_interface_condition {
5092     * to the sysfs representation for that device.
5093     * @pm_usage_cnt: PM usage counter for this interface
5094     * @reset_ws: Used for scheduling resets from atomic context.
5095     - * @reset_running: set to 1 if the interface is currently running a
5096     - * queued reset so that usb_cancel_queued_reset() doesn't try to
5097     - * remove from the workqueue when running inside the worker
5098     - * thread. See __usb_queue_reset_device().
5099     * @resetting_device: USB core reset the device, so use alt setting 0 as
5100     * current; needs bandwidth alloc after reset.
5101     *
5102     @@ -181,7 +177,6 @@ struct usb_interface {
5103     unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
5104     unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
5105     unsigned needs_binding:1; /* needs delayed unbind/rebind */
5106     - unsigned reset_running:1;
5107     unsigned resetting_device:1; /* true: bandwidth alloc after reset */
5108    
5109     struct device dev; /* interface specific device info */
5110     diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
5111     index cd96a2bc3388..2f48e1756cbd 100644
5112     --- a/include/linux/usb/hcd.h
5113     +++ b/include/linux/usb/hcd.h
5114     @@ -146,6 +146,8 @@ struct usb_hcd {
5115     unsigned amd_resume_bug:1; /* AMD remote wakeup quirk */
5116     unsigned can_do_streams:1; /* HC supports streams */
5117     unsigned tpl_support:1; /* OTG & EH TPL support */
5118     + unsigned cant_recv_wakeups:1;
5119     + /* wakeup requests from downstream aren't received */
5120    
5121     unsigned int irq; /* irq allocated */
5122     void __iomem *regs; /* device memory/io */
5123     @@ -450,6 +452,7 @@ extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
5124     #endif /* CONFIG_PCI */
5125    
5126     /* pci-ish (pdev null is ok) buffer alloc/mapping support */
5127     +void usb_init_pool_max(void);
5128     int hcd_buffer_create(struct usb_hcd *hcd);
5129     void hcd_buffer_destroy(struct usb_hcd *hcd);
5130    
5131     diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
5132     index a6fd939f202d..3ebb168b9afc 100644
5133     --- a/include/net/cipso_ipv4.h
5134     +++ b/include/net/cipso_ipv4.h
5135     @@ -121,13 +121,6 @@ extern int cipso_v4_rbm_strictvalid;
5136     #endif
5137    
5138     /*
5139     - * Helper Functions
5140     - */
5141     -
5142     -#define CIPSO_V4_OPTEXIST(x) (IPCB(x)->opt.cipso != 0)
5143     -#define CIPSO_V4_OPTPTR(x) (skb_network_header(x) + IPCB(x)->opt.cipso)
5144     -
5145     -/*
5146     * DOI List Functions
5147     */
5148    
5149     @@ -190,7 +183,7 @@ static inline int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def,
5150    
5151     #ifdef CONFIG_NETLABEL
5152     void cipso_v4_cache_invalidate(void);
5153     -int cipso_v4_cache_add(const struct sk_buff *skb,
5154     +int cipso_v4_cache_add(const unsigned char *cipso_ptr,
5155     const struct netlbl_lsm_secattr *secattr);
5156     #else
5157     static inline void cipso_v4_cache_invalidate(void)
5158     @@ -198,7 +191,7 @@ static inline void cipso_v4_cache_invalidate(void)
5159     return;
5160     }
5161    
5162     -static inline int cipso_v4_cache_add(const struct sk_buff *skb,
5163     +static inline int cipso_v4_cache_add(const unsigned char *cipso_ptr,
5164     const struct netlbl_lsm_secattr *secattr)
5165     {
5166     return 0;
5167     @@ -211,6 +204,8 @@ static inline int cipso_v4_cache_add(const struct sk_buff *skb,
5168    
5169     #ifdef CONFIG_NETLABEL
5170     void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway);
5171     +int cipso_v4_getattr(const unsigned char *cipso,
5172     + struct netlbl_lsm_secattr *secattr);
5173     int cipso_v4_sock_setattr(struct sock *sk,
5174     const struct cipso_v4_doi *doi_def,
5175     const struct netlbl_lsm_secattr *secattr);
5176     @@ -226,6 +221,7 @@ int cipso_v4_skbuff_setattr(struct sk_buff *skb,
5177     int cipso_v4_skbuff_delattr(struct sk_buff *skb);
5178     int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
5179     struct netlbl_lsm_secattr *secattr);
5180     +unsigned char *cipso_v4_optptr(const struct sk_buff *skb);
5181     int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option);
5182     #else
5183     static inline void cipso_v4_error(struct sk_buff *skb,
5184     @@ -235,6 +231,12 @@ static inline void cipso_v4_error(struct sk_buff *skb,
5185     return;
5186     }
5187    
5188     +static inline int cipso_v4_getattr(const unsigned char *cipso,
5189     + struct netlbl_lsm_secattr *secattr)
5190     +{
5191     + return -ENOSYS;
5192     +}
5193     +
5194     static inline int cipso_v4_sock_setattr(struct sock *sk,
5195     const struct cipso_v4_doi *doi_def,
5196     const struct netlbl_lsm_secattr *secattr)
5197     @@ -282,6 +284,11 @@ static inline int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
5198     return -ENOSYS;
5199     }
5200    
5201     +static inline unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
5202     +{
5203     + return NULL;
5204     +}
5205     +
5206     static inline int cipso_v4_validate(const struct sk_buff *skb,
5207     unsigned char **option)
5208     {
5209     diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
5210     index 379650b984f8..6ffdc96059a0 100644
5211     --- a/kernel/debug/kdb/kdb_main.c
5212     +++ b/kernel/debug/kdb/kdb_main.c
5213     @@ -2535,7 +2535,7 @@ static int kdb_summary(int argc, const char **argv)
5214     #define K(x) ((x) << (PAGE_SHIFT - 10))
5215     kdb_printf("\nMemTotal: %8lu kB\nMemFree: %8lu kB\n"
5216     "Buffers: %8lu kB\n",
5217     - val.totalram, val.freeram, val.bufferram);
5218     + K(val.totalram), K(val.freeram), K(val.bufferram));
5219     return 0;
5220     }
5221    
5222     diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
5223     index 28bf91c60a0b..85fb3d632bd8 100644
5224     --- a/kernel/time/ntp.c
5225     +++ b/kernel/time/ntp.c
5226     @@ -633,10 +633,14 @@ int ntp_validate_timex(struct timex *txc)
5227     if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
5228     return -EPERM;
5229    
5230     - if (txc->modes & ADJ_FREQUENCY) {
5231     - if (LONG_MIN / PPM_SCALE > txc->freq)
5232     + /*
5233     + * Check for potential multiplication overflows that can
5234     + * only happen on 64-bit systems:
5235     + */
5236     + if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
5237     + if (LLONG_MIN / PPM_SCALE > txc->freq)
5238     return -EINVAL;
5239     - if (LONG_MAX / PPM_SCALE < txc->freq)
5240     + if (LLONG_MAX / PPM_SCALE < txc->freq)
5241     return -EINVAL;
5242     }
5243    
5244     diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
5245     index a56e07c8d15b..f4fbbfcdf399 100644
5246     --- a/kernel/trace/ring_buffer.c
5247     +++ b/kernel/trace/ring_buffer.c
5248     @@ -450,7 +450,10 @@ int ring_buffer_print_page_header(struct trace_seq *s)
5249     struct rb_irq_work {
5250     struct irq_work work;
5251     wait_queue_head_t waiters;
5252     + wait_queue_head_t full_waiters;
5253     bool waiters_pending;
5254     + bool full_waiters_pending;
5255     + bool wakeup_full;
5256     };
5257    
5258     /*
5259     @@ -532,6 +535,10 @@ static void rb_wake_up_waiters(struct irq_work *work)
5260     struct rb_irq_work *rbwork = container_of(work, struct rb_irq_work, work);
5261    
5262     wake_up_all(&rbwork->waiters);
5263     + if (rbwork->wakeup_full) {
5264     + rbwork->wakeup_full = false;
5265     + wake_up_all(&rbwork->full_waiters);
5266     + }
5267     }
5268    
5269     /**
5270     @@ -556,9 +563,11 @@ int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full)
5271     * data in any cpu buffer, or a specific buffer, put the
5272     * caller on the appropriate wait queue.
5273     */
5274     - if (cpu == RING_BUFFER_ALL_CPUS)
5275     + if (cpu == RING_BUFFER_ALL_CPUS) {
5276     work = &buffer->irq_work;
5277     - else {
5278     + /* Full only makes sense on per cpu reads */
5279     + full = false;
5280     + } else {
5281     if (!cpumask_test_cpu(cpu, buffer->cpumask))
5282     return -ENODEV;
5283     cpu_buffer = buffer->buffers[cpu];
5284     @@ -567,7 +576,10 @@ int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full)
5285    
5286    
5287     while (true) {
5288     - prepare_to_wait(&work->waiters, &wait, TASK_INTERRUPTIBLE);
5289     + if (full)
5290     + prepare_to_wait(&work->full_waiters, &wait, TASK_INTERRUPTIBLE);
5291     + else
5292     + prepare_to_wait(&work->waiters, &wait, TASK_INTERRUPTIBLE);
5293    
5294     /*
5295     * The events can happen in critical sections where
5296     @@ -589,7 +601,10 @@ int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full)
5297     * that is necessary is that the wake up happens after
5298     * a task has been queued. It's OK for spurious wake ups.
5299     */
5300     - work->waiters_pending = true;
5301     + if (full)
5302     + work->full_waiters_pending = true;
5303     + else
5304     + work->waiters_pending = true;
5305    
5306     if (signal_pending(current)) {
5307     ret = -EINTR;
5308     @@ -618,7 +633,10 @@ int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full)
5309     schedule();
5310     }
5311    
5312     - finish_wait(&work->waiters, &wait);
5313     + if (full)
5314     + finish_wait(&work->full_waiters, &wait);
5315     + else
5316     + finish_wait(&work->waiters, &wait);
5317    
5318     return ret;
5319     }
5320     @@ -1233,6 +1251,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int nr_pages, int cpu)
5321     init_completion(&cpu_buffer->update_done);
5322     init_irq_work(&cpu_buffer->irq_work.work, rb_wake_up_waiters);
5323     init_waitqueue_head(&cpu_buffer->irq_work.waiters);
5324     + init_waitqueue_head(&cpu_buffer->irq_work.full_waiters);
5325    
5326     bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),
5327     GFP_KERNEL, cpu_to_node(cpu));
5328     @@ -2804,6 +2823,8 @@ static void rb_commit(struct ring_buffer_per_cpu *cpu_buffer,
5329     static __always_inline void
5330     rb_wakeups(struct ring_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer)
5331     {
5332     + bool pagebusy;
5333     +
5334     if (buffer->irq_work.waiters_pending) {
5335     buffer->irq_work.waiters_pending = false;
5336     /* irq_work_queue() supplies it's own memory barriers */
5337     @@ -2815,6 +2836,15 @@ rb_wakeups(struct ring_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer)
5338     /* irq_work_queue() supplies it's own memory barriers */
5339     irq_work_queue(&cpu_buffer->irq_work.work);
5340     }
5341     +
5342     + pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page;
5343     +
5344     + if (!pagebusy && cpu_buffer->irq_work.full_waiters_pending) {
5345     + cpu_buffer->irq_work.wakeup_full = true;
5346     + cpu_buffer->irq_work.full_waiters_pending = false;
5347     + /* irq_work_queue() supplies it's own memory barriers */
5348     + irq_work_queue(&cpu_buffer->irq_work.work);
5349     + }
5350     }
5351    
5352     /**
5353     diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
5354     index 426962b04183..72c71345db81 100644
5355     --- a/kernel/trace/trace.c
5356     +++ b/kernel/trace/trace.c
5357     @@ -4916,7 +4916,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
5358     *fpos += written;
5359    
5360     out_unlock:
5361     - for (i = 0; i < nr_pages; i++){
5362     + for (i = nr_pages - 1; i >= 0; i--) {
5363     kunmap_atomic(map_page[i]);
5364     put_page(pages[i]);
5365     }
5366     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
5367     index 9fd722769927..f08fec71ec5a 100644
5368     --- a/mm/hugetlb.c
5369     +++ b/mm/hugetlb.c
5370     @@ -3659,6 +3659,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
5371     {
5372     struct page *page;
5373    
5374     + if (!pmd_present(*pmd))
5375     + return NULL;
5376     page = pte_page(*(pte_t *)pmd);
5377     if (page)
5378     page += ((address & ~PMD_MASK) >> PAGE_SHIFT);
5379     diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
5380     index f09b6b65cf6b..9ebc394ea5e5 100644
5381     --- a/net/bluetooth/smp.c
5382     +++ b/net/bluetooth/smp.c
5383     @@ -1392,8 +1392,12 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,
5384     * implementations are not known of and in order to not over
5385     * complicate our implementation, simply pretend that we never
5386     * received an IRK for such a device.
5387     + *
5388     + * The Identity Address must also be a Static Random or Public
5389     + * Address, which hci_is_identity_address() checks for.
5390     */
5391     - if (!bacmp(&info->bdaddr, BDADDR_ANY)) {
5392     + if (!bacmp(&info->bdaddr, BDADDR_ANY) ||
5393     + !hci_is_identity_address(&info->bdaddr, info->addr_type)) {
5394     BT_ERR("Ignoring IRK with no identity address");
5395     goto distribute;
5396     }
5397     diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
5398     index 6f164289bde8..b0cf1f287aed 100644
5399     --- a/net/ceph/osd_client.c
5400     +++ b/net/ceph/osd_client.c
5401     @@ -1006,14 +1006,24 @@ static void put_osd(struct ceph_osd *osd)
5402     */
5403     static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
5404     {
5405     - dout("__remove_osd %p\n", osd);
5406     + dout("%s %p osd%d\n", __func__, osd, osd->o_osd);
5407     WARN_ON(!list_empty(&osd->o_requests));
5408     WARN_ON(!list_empty(&osd->o_linger_requests));
5409    
5410     - rb_erase(&osd->o_node, &osdc->osds);
5411     list_del_init(&osd->o_osd_lru);
5412     - ceph_con_close(&osd->o_con);
5413     - put_osd(osd);
5414     + rb_erase(&osd->o_node, &osdc->osds);
5415     + RB_CLEAR_NODE(&osd->o_node);
5416     +}
5417     +
5418     +static void remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
5419     +{
5420     + dout("%s %p osd%d\n", __func__, osd, osd->o_osd);
5421     +
5422     + if (!RB_EMPTY_NODE(&osd->o_node)) {
5423     + ceph_con_close(&osd->o_con);
5424     + __remove_osd(osdc, osd);
5425     + put_osd(osd);
5426     + }
5427     }
5428    
5429     static void remove_all_osds(struct ceph_osd_client *osdc)
5430     @@ -1023,7 +1033,7 @@ static void remove_all_osds(struct ceph_osd_client *osdc)
5431     while (!RB_EMPTY_ROOT(&osdc->osds)) {
5432     struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds),
5433     struct ceph_osd, o_node);
5434     - __remove_osd(osdc, osd);
5435     + remove_osd(osdc, osd);
5436     }
5437     mutex_unlock(&osdc->request_mutex);
5438     }
5439     @@ -1064,7 +1074,7 @@ static void remove_old_osds(struct ceph_osd_client *osdc)
5440     list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) {
5441     if (time_before(jiffies, osd->lru_ttl))
5442     break;
5443     - __remove_osd(osdc, osd);
5444     + remove_osd(osdc, osd);
5445     }
5446     mutex_unlock(&osdc->request_mutex);
5447     }
5448     @@ -1079,8 +1089,7 @@ static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
5449     dout("__reset_osd %p osd%d\n", osd, osd->o_osd);
5450     if (list_empty(&osd->o_requests) &&
5451     list_empty(&osd->o_linger_requests)) {
5452     - __remove_osd(osdc, osd);
5453     -
5454     + remove_osd(osdc, osd);
5455     return -ENODEV;
5456     }
5457    
5458     @@ -1884,6 +1893,7 @@ static void reset_changed_osds(struct ceph_osd_client *osdc)
5459     {
5460     struct rb_node *p, *n;
5461    
5462     + dout("%s %p\n", __func__, osdc);
5463     for (p = rb_first(&osdc->osds); p; p = n) {
5464     struct ceph_osd *osd = rb_entry(p, struct ceph_osd, o_node);
5465    
5466     diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
5467     index 4715f25dfe03..bc7c9662a904 100644
5468     --- a/net/ipv4/cipso_ipv4.c
5469     +++ b/net/ipv4/cipso_ipv4.c
5470     @@ -376,20 +376,18 @@ static int cipso_v4_cache_check(const unsigned char *key,
5471     * negative values on failure.
5472     *
5473     */
5474     -int cipso_v4_cache_add(const struct sk_buff *skb,
5475     +int cipso_v4_cache_add(const unsigned char *cipso_ptr,
5476     const struct netlbl_lsm_secattr *secattr)
5477     {
5478     int ret_val = -EPERM;
5479     u32 bkt;
5480     struct cipso_v4_map_cache_entry *entry = NULL;
5481     struct cipso_v4_map_cache_entry *old_entry = NULL;
5482     - unsigned char *cipso_ptr;
5483     u32 cipso_ptr_len;
5484    
5485     if (!cipso_v4_cache_enabled || cipso_v4_cache_bucketsize <= 0)
5486     return 0;
5487    
5488     - cipso_ptr = CIPSO_V4_OPTPTR(skb);
5489     cipso_ptr_len = cipso_ptr[1];
5490    
5491     entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
5492     @@ -1577,6 +1575,33 @@ static int cipso_v4_parsetag_loc(const struct cipso_v4_doi *doi_def,
5493     }
5494    
5495     /**
5496     + * cipso_v4_optptr - Find the CIPSO option in the packet
5497     + * @skb: the packet
5498     + *
5499     + * Description:
5500     + * Parse the packet's IP header looking for a CIPSO option. Returns a pointer
5501     + * to the start of the CIPSO option on success, NULL if one if not found.
5502     + *
5503     + */
5504     +unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
5505     +{
5506     + const struct iphdr *iph = ip_hdr(skb);
5507     + unsigned char *optptr = (unsigned char *)&(ip_hdr(skb)[1]);
5508     + int optlen;
5509     + int taglen;
5510     +
5511     + for (optlen = iph->ihl*4 - sizeof(struct iphdr); optlen > 0; ) {
5512     + if (optptr[0] == IPOPT_CIPSO)
5513     + return optptr;
5514     + taglen = optptr[1];
5515     + optlen -= taglen;
5516     + optptr += taglen;
5517     + }
5518     +
5519     + return NULL;
5520     +}
5521     +
5522     +/**
5523     * cipso_v4_validate - Validate a CIPSO option
5524     * @option: the start of the option, on error it is set to point to the error
5525     *
5526     @@ -2117,8 +2142,8 @@ void cipso_v4_req_delattr(struct request_sock *req)
5527     * on success and negative values on failure.
5528     *
5529     */
5530     -static int cipso_v4_getattr(const unsigned char *cipso,
5531     - struct netlbl_lsm_secattr *secattr)
5532     +int cipso_v4_getattr(const unsigned char *cipso,
5533     + struct netlbl_lsm_secattr *secattr)
5534     {
5535     int ret_val = -ENOMSG;
5536     u32 doi;
5537     @@ -2303,22 +2328,6 @@ int cipso_v4_skbuff_delattr(struct sk_buff *skb)
5538     return 0;
5539     }
5540    
5541     -/**
5542     - * cipso_v4_skbuff_getattr - Get the security attributes from the CIPSO option
5543     - * @skb: the packet
5544     - * @secattr: the security attributes
5545     - *
5546     - * Description:
5547     - * Parse the given packet's CIPSO option and return the security attributes.
5548     - * Returns zero on success and negative values on failure.
5549     - *
5550     - */
5551     -int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
5552     - struct netlbl_lsm_secattr *secattr)
5553     -{
5554     - return cipso_v4_getattr(CIPSO_V4_OPTPTR(skb), secattr);
5555     -}
5556     -
5557     /*
5558     * Setup Functions
5559     */
5560     diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
5561     index a845cd4cf21e..28cddc85b700 100644
5562     --- a/net/netlabel/netlabel_kapi.c
5563     +++ b/net/netlabel/netlabel_kapi.c
5564     @@ -1065,10 +1065,12 @@ int netlbl_skbuff_getattr(const struct sk_buff *skb,
5565     u16 family,
5566     struct netlbl_lsm_secattr *secattr)
5567     {
5568     + unsigned char *ptr;
5569     +
5570     switch (family) {
5571     case AF_INET:
5572     - if (CIPSO_V4_OPTEXIST(skb) &&
5573     - cipso_v4_skbuff_getattr(skb, secattr) == 0)
5574     + ptr = cipso_v4_optptr(skb);
5575     + if (ptr && cipso_v4_getattr(ptr, secattr) == 0)
5576     return 0;
5577     break;
5578     #if IS_ENABLED(CONFIG_IPV6)
5579     @@ -1094,7 +1096,7 @@ int netlbl_skbuff_getattr(const struct sk_buff *skb,
5580     */
5581     void netlbl_skbuff_err(struct sk_buff *skb, int error, int gateway)
5582     {
5583     - if (CIPSO_V4_OPTEXIST(skb))
5584     + if (cipso_v4_optptr(skb))
5585     cipso_v4_error(skb, error, gateway);
5586     }
5587    
5588     @@ -1126,11 +1128,14 @@ void netlbl_cache_invalidate(void)
5589     int netlbl_cache_add(const struct sk_buff *skb,
5590     const struct netlbl_lsm_secattr *secattr)
5591     {
5592     + unsigned char *ptr;
5593     +
5594     if ((secattr->flags & NETLBL_SECATTR_CACHE) == 0)
5595     return -ENOMSG;
5596    
5597     - if (CIPSO_V4_OPTEXIST(skb))
5598     - return cipso_v4_cache_add(skb, secattr);
5599     + ptr = cipso_v4_optptr(skb);
5600     + if (ptr)
5601     + return cipso_v4_cache_add(ptr, secattr);
5602    
5603     return -ENOMSG;
5604     }
5605     diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
5606     index 9acd6ce88db7..ae46f0198608 100644
5607     --- a/net/sunrpc/clnt.c
5608     +++ b/net/sunrpc/clnt.c
5609     @@ -286,10 +286,8 @@ static struct rpc_xprt *rpc_clnt_set_transport(struct rpc_clnt *clnt,
5610    
5611     static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)
5612     {
5613     - clnt->cl_nodelen = strlen(nodename);
5614     - if (clnt->cl_nodelen > UNX_MAXNODENAME)
5615     - clnt->cl_nodelen = UNX_MAXNODENAME;
5616     - memcpy(clnt->cl_nodename, nodename, clnt->cl_nodelen);
5617     + clnt->cl_nodelen = strlcpy(clnt->cl_nodename,
5618     + nodename, sizeof(clnt->cl_nodename));
5619     }
5620    
5621     static int rpc_client_register(struct rpc_clnt *clnt,
5622     @@ -360,6 +358,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args,
5623     const struct rpc_version *version;
5624     struct rpc_clnt *clnt = NULL;
5625     const struct rpc_timeout *timeout;
5626     + const char *nodename = args->nodename;
5627     int err;
5628    
5629     /* sanity check the name before trying to print it */
5630     @@ -415,8 +414,10 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args,
5631    
5632     atomic_set(&clnt->cl_count, 1);
5633    
5634     + if (nodename == NULL)
5635     + nodename = utsname()->nodename;
5636     /* save the nodename */
5637     - rpc_clnt_set_nodename(clnt, utsname()->nodename);
5638     + rpc_clnt_set_nodename(clnt, nodename);
5639    
5640     err = rpc_client_register(clnt, args->authflavor, args->client_name);
5641     if (err)
5642     @@ -571,6 +572,7 @@ static struct rpc_clnt *__rpc_clone_client(struct rpc_create_args *args,
5643     if (xprt == NULL)
5644     goto out_err;
5645     args->servername = xprt->servername;
5646     + args->nodename = clnt->cl_nodename;
5647    
5648     new = rpc_new_client(args, xprt, clnt);
5649     if (IS_ERR(new)) {
5650     diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
5651     index 1891a1022c17..74b75c3ce39d 100644
5652     --- a/net/sunrpc/rpcb_clnt.c
5653     +++ b/net/sunrpc/rpcb_clnt.c
5654     @@ -355,7 +355,8 @@ out:
5655     return result;
5656     }
5657    
5658     -static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
5659     +static struct rpc_clnt *rpcb_create(struct net *net, const char *nodename,
5660     + const char *hostname,
5661     struct sockaddr *srvaddr, size_t salen,
5662     int proto, u32 version)
5663     {
5664     @@ -365,6 +366,7 @@ static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
5665     .address = srvaddr,
5666     .addrsize = salen,
5667     .servername = hostname,
5668     + .nodename = nodename,
5669     .program = &rpcb_program,
5670     .version = version,
5671     .authflavor = RPC_AUTH_UNIX,
5672     @@ -740,7 +742,9 @@ void rpcb_getport_async(struct rpc_task *task)
5673     dprintk("RPC: %5u %s: trying rpcbind version %u\n",
5674     task->tk_pid, __func__, bind_version);
5675    
5676     - rpcb_clnt = rpcb_create(xprt->xprt_net, xprt->servername, sap, salen,
5677     + rpcb_clnt = rpcb_create(xprt->xprt_net,
5678     + clnt->cl_nodename,
5679     + xprt->servername, sap, salen,
5680     xprt->prot, bind_version);
5681     if (IS_ERR(rpcb_clnt)) {
5682     status = PTR_ERR(rpcb_clnt);
5683     diff --git a/security/smack/smack.h b/security/smack/smack.h
5684     index b828a379377c..b48359c0da32 100644
5685     --- a/security/smack/smack.h
5686     +++ b/security/smack/smack.h
5687     @@ -298,6 +298,16 @@ static inline struct smack_known *smk_of_task(const struct task_smack *tsp)
5688     return tsp->smk_task;
5689     }
5690    
5691     +static inline struct smack_known *smk_of_task_struct(const struct task_struct *t)
5692     +{
5693     + struct smack_known *skp;
5694     +
5695     + rcu_read_lock();
5696     + skp = smk_of_task(__task_cred(t)->security);
5697     + rcu_read_unlock();
5698     + return skp;
5699     +}
5700     +
5701     /*
5702     * Present a pointer to the forked smack label entry in an task blob.
5703     */
5704     diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
5705     index d515ec25ae9f..9d3c64af1ca9 100644
5706     --- a/security/smack/smack_lsm.c
5707     +++ b/security/smack/smack_lsm.c
5708     @@ -43,8 +43,6 @@
5709     #include <linux/binfmts.h>
5710     #include "smack.h"
5711    
5712     -#define task_security(task) (task_cred_xxx((task), security))
5713     -
5714     #define TRANS_TRUE "TRUE"
5715     #define TRANS_TRUE_SIZE 4
5716    
5717     @@ -119,7 +117,7 @@ static int smk_bu_current(char *note, struct smack_known *oskp,
5718     static int smk_bu_task(struct task_struct *otp, int mode, int rc)
5719     {
5720     struct task_smack *tsp = current_security();
5721     - struct task_smack *otsp = task_security(otp);
5722     + struct smack_known *smk_task = smk_of_task_struct(otp);
5723     char acc[SMK_NUM_ACCESS_TYPE + 1];
5724    
5725     if (rc <= 0)
5726     @@ -127,7 +125,7 @@ static int smk_bu_task(struct task_struct *otp, int mode, int rc)
5727    
5728     smk_bu_mode(mode, acc);
5729     pr_info("Smack Bringup: (%s %s %s) %s to %s\n",
5730     - tsp->smk_task->smk_known, otsp->smk_task->smk_known, acc,
5731     + tsp->smk_task->smk_known, smk_task->smk_known, acc,
5732     current->comm, otp->comm);
5733     return 0;
5734     }
5735     @@ -344,7 +342,8 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
5736     saip = &ad;
5737     }
5738    
5739     - tsp = task_security(tracer);
5740     + rcu_read_lock();
5741     + tsp = __task_cred(tracer)->security;
5742     tracer_known = smk_of_task(tsp);
5743    
5744     if ((mode & PTRACE_MODE_ATTACH) &&
5745     @@ -364,11 +363,14 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
5746     tracee_known->smk_known,
5747     0, rc, saip);
5748    
5749     + rcu_read_unlock();
5750     return rc;
5751     }
5752    
5753     /* In case of rule==SMACK_PTRACE_DEFAULT or mode==PTRACE_MODE_READ */
5754     rc = smk_tskacc(tsp, tracee_known, smk_ptrace_mode(mode), saip);
5755     +
5756     + rcu_read_unlock();
5757     return rc;
5758     }
5759    
5760     @@ -395,7 +397,7 @@ static int smack_ptrace_access_check(struct task_struct *ctp, unsigned int mode)
5761     if (rc != 0)
5762     return rc;
5763    
5764     - skp = smk_of_task(task_security(ctp));
5765     + skp = smk_of_task_struct(ctp);
5766    
5767     rc = smk_ptrace_rule_check(current, skp, mode, __func__);
5768     return rc;
5769     @@ -1825,7 +1827,7 @@ static int smk_curacc_on_task(struct task_struct *p, int access,
5770     const char *caller)
5771     {
5772     struct smk_audit_info ad;
5773     - struct smack_known *skp = smk_of_task(task_security(p));
5774     + struct smack_known *skp = smk_of_task_struct(p);
5775     int rc;
5776    
5777     smk_ad_init(&ad, caller, LSM_AUDIT_DATA_TASK);
5778     @@ -1878,7 +1880,7 @@ static int smack_task_getsid(struct task_struct *p)
5779     */
5780     static void smack_task_getsecid(struct task_struct *p, u32 *secid)
5781     {
5782     - struct smack_known *skp = smk_of_task(task_security(p));
5783     + struct smack_known *skp = smk_of_task_struct(p);
5784    
5785     *secid = skp->smk_secid;
5786     }
5787     @@ -1985,7 +1987,7 @@ static int smack_task_kill(struct task_struct *p, struct siginfo *info,
5788     {
5789     struct smk_audit_info ad;
5790     struct smack_known *skp;
5791     - struct smack_known *tkp = smk_of_task(task_security(p));
5792     + struct smack_known *tkp = smk_of_task_struct(p);
5793     int rc;
5794    
5795     smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);
5796     @@ -2039,7 +2041,7 @@ static int smack_task_wait(struct task_struct *p)
5797     static void smack_task_to_inode(struct task_struct *p, struct inode *inode)
5798     {
5799     struct inode_smack *isp = inode->i_security;
5800     - struct smack_known *skp = smk_of_task(task_security(p));
5801     + struct smack_known *skp = smk_of_task_struct(p);
5802    
5803     isp->smk_inode = skp;
5804     }
5805     @@ -3199,7 +3201,7 @@ unlockandout:
5806     */
5807     static int smack_getprocattr(struct task_struct *p, char *name, char **value)
5808     {
5809     - struct smack_known *skp = smk_of_task(task_security(p));
5810     + struct smack_known *skp = smk_of_task_struct(p);
5811     char *cp;
5812     int slen;
5813    
5814     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5815     index c879c3709eae..50762cf62b2d 100644
5816     --- a/sound/pci/hda/patch_realtek.c
5817     +++ b/sound/pci/hda/patch_realtek.c
5818     @@ -4805,6 +4805,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5819     SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
5820     SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
5821     /* ALC282 */
5822     + SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5823     SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5824     SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5825     SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
5826     diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
5827     index 605d14003d25..6d36c5b78805 100644
5828     --- a/sound/pci/hda/patch_sigmatel.c
5829     +++ b/sound/pci/hda/patch_sigmatel.c
5830     @@ -99,6 +99,7 @@ enum {
5831     STAC_HP_ENVY_BASS,
5832     STAC_HP_BNB13_EQ,
5833     STAC_HP_ENVY_TS_BASS,
5834     + STAC_92HD83XXX_GPIO10_EAPD,
5835     STAC_92HD83XXX_MODELS
5836     };
5837    
5838     @@ -2141,6 +2142,19 @@ static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
5839     spec->headset_jack = 1;
5840     }
5841    
5842     +static void stac92hd83xxx_fixup_gpio10_eapd(struct hda_codec *codec,
5843     + const struct hda_fixup *fix,
5844     + int action)
5845     +{
5846     + struct sigmatel_spec *spec = codec->spec;
5847     +
5848     + if (action != HDA_FIXUP_ACT_PRE_PROBE)
5849     + return;
5850     + spec->eapd_mask = spec->gpio_mask = spec->gpio_dir =
5851     + spec->gpio_data = 0x10;
5852     + spec->eapd_switch = 0;
5853     +}
5854     +
5855     static const struct hda_verb hp_bnb13_eq_verbs[] = {
5856     /* 44.1KHz base */
5857     { 0x22, 0x7A6, 0x3E },
5858     @@ -2656,6 +2670,10 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = {
5859     {}
5860     },
5861     },
5862     + [STAC_92HD83XXX_GPIO10_EAPD] = {
5863     + .type = HDA_FIXUP_FUNC,
5864     + .v.func = stac92hd83xxx_fixup_gpio10_eapd,
5865     + },
5866     };
5867    
5868     static const struct hda_model_fixup stac92hd83xxx_models[] = {
5869     @@ -2861,6 +2879,8 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
5870     SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
5871     "HP Mini", STAC_92HD83XXX_HP_LED),
5872     SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
5873     + SND_PCI_QUIRK(PCI_VENDOR_ID_TOSHIBA, 0xfa91,
5874     + "Toshiba Satellite S50D", STAC_92HD83XXX_GPIO10_EAPD),
5875     {} /* terminator */
5876     };
5877    
5878     diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
5879     index 6abc2ac8fffb..e76857277695 100644
5880     --- a/sound/pci/riptide/riptide.c
5881     +++ b/sound/pci/riptide/riptide.c
5882     @@ -2030,32 +2030,43 @@ snd_riptide_joystick_probe(struct pci_dev *pci, const struct pci_device_id *id)
5883     {
5884     static int dev;
5885     struct gameport *gameport;
5886     + int ret;
5887    
5888     if (dev >= SNDRV_CARDS)
5889     return -ENODEV;
5890     +
5891     if (!enable[dev]) {
5892     - dev++;
5893     - return -ENOENT;
5894     + ret = -ENOENT;
5895     + goto inc_dev;
5896     }
5897    
5898     - if (!joystick_port[dev++])
5899     - return 0;
5900     + if (!joystick_port[dev]) {
5901     + ret = 0;
5902     + goto inc_dev;
5903     + }
5904    
5905     gameport = gameport_allocate_port();
5906     - if (!gameport)
5907     - return -ENOMEM;
5908     + if (!gameport) {
5909     + ret = -ENOMEM;
5910     + goto inc_dev;
5911     + }
5912     if (!request_region(joystick_port[dev], 8, "Riptide gameport")) {
5913     snd_printk(KERN_WARNING
5914     "Riptide: cannot grab gameport 0x%x\n",
5915     joystick_port[dev]);
5916     gameport_free_port(gameport);
5917     - return -EBUSY;
5918     + ret = -EBUSY;
5919     + goto inc_dev;
5920     }
5921    
5922     gameport->io = joystick_port[dev];
5923     gameport_register_port(gameport);
5924     pci_set_drvdata(pci, gameport);
5925     - return 0;
5926     +
5927     + ret = 0;
5928     +inc_dev:
5929     + dev++;
5930     + return ret;
5931     }
5932    
5933     static void snd_riptide_joystick_remove(struct pci_dev *pci)
5934     diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
5935     index 52d86af3ef2d..fcf91ee0328d 100644
5936     --- a/sound/pci/rme9652/hdspm.c
5937     +++ b/sound/pci/rme9652/hdspm.c
5938     @@ -6114,6 +6114,9 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
5939     snd_pcm_hw_constraint_minmax(runtime,
5940     SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
5941     64, 8192);
5942     + snd_pcm_hw_constraint_minmax(runtime,
5943     + SNDRV_PCM_HW_PARAM_PERIODS,
5944     + 2, 2);
5945     break;
5946     }
5947    
5948     @@ -6188,6 +6191,9 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
5949     snd_pcm_hw_constraint_minmax(runtime,
5950     SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
5951     64, 8192);
5952     + snd_pcm_hw_constraint_minmax(runtime,
5953     + SNDRV_PCM_HW_PARAM_PERIODS,
5954     + 2, 2);
5955     break;
5956     }
5957    
5958     diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
5959     index 9bd8b4f63303..7134f9ebf2f3 100644
5960     --- a/sound/soc/codecs/rt5670.c
5961     +++ b/sound/soc/codecs/rt5670.c
5962     @@ -2439,6 +2439,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5670 = {
5963     static const struct regmap_config rt5670_regmap = {
5964     .reg_bits = 8,
5965     .val_bits = 16,
5966     + .use_single_rw = true,
5967     .max_register = RT5670_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5670_ranges) *
5968     RT5670_PR_SPACING),
5969     .volatile_reg = rt5670_volatile_register,
5970     diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
5971     index 8e948c63f3d9..2b81ca418d2a 100644
5972     --- a/sound/soc/davinci/Kconfig
5973     +++ b/sound/soc/davinci/Kconfig
5974     @@ -58,13 +58,12 @@ choice
5975     depends on MACH_DAVINCI_DM365_EVM
5976    
5977     config SND_DM365_AIC3X_CODEC
5978     - bool "Audio Codec - AIC3101"
5979     + tristate "Audio Codec - AIC3101"
5980     help
5981     Say Y if you want to add support for AIC3101 audio codec
5982    
5983     config SND_DM365_VOICE_CODEC
5984     tristate "Voice Codec - CQ93VC"
5985     - depends on SND_DAVINCI_SOC
5986     select MFD_DAVINCI_VOICECODEC
5987     select SND_DAVINCI_SOC_VCIF
5988     select SND_SOC_CQ0093VC
5989     diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c
5990     index 595eee341e90..a08a877fc10c 100644
5991     --- a/sound/soc/pxa/mioa701_wm9713.c
5992     +++ b/sound/soc/pxa/mioa701_wm9713.c
5993     @@ -81,7 +81,7 @@ static int rear_amp_power(struct snd_soc_codec *codec, int power)
5994     static int rear_amp_event(struct snd_soc_dapm_widget *widget,
5995     struct snd_kcontrol *kctl, int event)
5996     {
5997     - struct snd_soc_codec *codec = widget->codec;
5998     + struct snd_soc_codec *codec = widget->dapm->card->rtd[0].codec;
5999    
6000     return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event));
6001     }
6002     diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
6003     index 47b78b3f0325..6da965bdbc2c 100644
6004     --- a/tools/perf/util/cloexec.c
6005     +++ b/tools/perf/util/cloexec.c
6006     @@ -25,6 +25,10 @@ static int perf_flag_probe(void)
6007     if (cpu < 0)
6008     cpu = 0;
6009    
6010     + /*
6011     + * Using -1 for the pid is a workaround to avoid gratuitous jump label
6012     + * changes.
6013     + */
6014     while (1) {
6015     /* check cloexec flag */
6016     fd = sys_perf_event_open(&attr, pid, cpu, -1,
6017     @@ -47,16 +51,24 @@ static int perf_flag_probe(void)
6018     err, strerror_r(err, sbuf, sizeof(sbuf)));
6019    
6020     /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */
6021     - fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
6022     + while (1) {
6023     + fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
6024     + if (fd < 0 && pid == -1 && errno == EACCES) {
6025     + pid = 0;
6026     + continue;
6027     + }
6028     + break;
6029     + }
6030     err = errno;
6031    
6032     + if (fd >= 0)
6033     + close(fd);
6034     +
6035     if (WARN_ONCE(fd < 0 && err != EBUSY,
6036     "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n",
6037     err, strerror_r(err, sbuf, sizeof(sbuf))))
6038     return -1;
6039    
6040     - close(fd);
6041     -
6042     return 0;
6043     }
6044