Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2226 - genpatches-2.6/trunk/3.6
Date: Mon, 29 Oct 2012 14:35:20
Message-Id: 20121029143508.9F61321600@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2012-10-29 14:34:04 +0000 (Mon, 29 Oct 2012)
3 New Revision: 2226
4
5 Added:
6 genpatches-2.6/trunk/3.6/1002_linux-3.6.3.patch
7 genpatches-2.6/trunk/3.6/1003_linux-3.6.4.patch
8 Modified:
9 genpatches-2.6/trunk/3.6/0000_README
10 Log:
11 Linux patches 3.6.3 and 3.6.4
12
13 Modified: genpatches-2.6/trunk/3.6/0000_README
14 ===================================================================
15 --- genpatches-2.6/trunk/3.6/0000_README 2012-10-19 23:31:19 UTC (rev 2225)
16 +++ genpatches-2.6/trunk/3.6/0000_README 2012-10-29 14:34:04 UTC (rev 2226)
17 @@ -47,6 +47,14 @@
18 From: http://www.kernel.org
19 Desc: Linux 3.6.2
20
21 +Patch: 1002_linux-3.6.3.patch
22 +From: http://www.kernel.org
23 +Desc: Linux 3.6.3
24 +
25 +Patch: 1003_linux-3.6.4.patch
26 +From: http://www.kernel.org
27 +Desc: Linux 3.6.4
28 +
29 Patch: 2400_kcopy-patch-for-infiniband-driver.patch
30 From: Alexey Shvetsov <alexxy@g.o>
31 Desc: Zero copy for infiniband psm userspace driver
32
33 Added: genpatches-2.6/trunk/3.6/1002_linux-3.6.3.patch
34 ===================================================================
35 --- genpatches-2.6/trunk/3.6/1002_linux-3.6.3.patch (rev 0)
36 +++ genpatches-2.6/trunk/3.6/1002_linux-3.6.3.patch 2012-10-29 14:34:04 UTC (rev 2226)
37 @@ -0,0 +1,3132 @@
38 +diff --git a/Makefile b/Makefile
39 +index af5d6a9..6cdadf4 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 3
44 + PATCHLEVEL = 6
45 +-SUBLEVEL = 2
46 ++SUBLEVEL = 3
47 + EXTRAVERSION =
48 + NAME = Terrified Chipmunk
49 +
50 +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
51 +index 2f88d8d..48c19d4 100644
52 +--- a/arch/arm/Kconfig
53 ++++ b/arch/arm/Kconfig
54 +@@ -1413,6 +1413,16 @@ config PL310_ERRATA_769419
55 + on systems with an outer cache, the store buffer is drained
56 + explicitly.
57 +
58 ++config ARM_ERRATA_775420
59 ++ bool "ARM errata: A data cache maintenance operation which aborts, might lead to deadlock"
60 ++ depends on CPU_V7
61 ++ help
62 ++ This option enables the workaround for the 775420 Cortex-A9 (r2p2,
63 ++ r2p6,r2p8,r2p10,r3p0) erratum. In case a date cache maintenance
64 ++ operation aborts with MMU exception, it might cause the processor
65 ++ to deadlock. This workaround puts DSB before executing ISB if
66 ++ an abort may occur on cache maintenance.
67 ++
68 + endmenu
69 +
70 + source "arch/arm/common/Kconfig"
71 +diff --git a/arch/arm/include/asm/vfpmacros.h b/arch/arm/include/asm/vfpmacros.h
72 +index 3d5fc41..bf53047 100644
73 +--- a/arch/arm/include/asm/vfpmacros.h
74 ++++ b/arch/arm/include/asm/vfpmacros.h
75 +@@ -28,7 +28,7 @@
76 + ldr \tmp, =elf_hwcap @ may not have MVFR regs
77 + ldr \tmp, [\tmp, #0]
78 + tst \tmp, #HWCAP_VFPv3D16
79 +- ldceq p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
80 ++ ldceql p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
81 + addne \base, \base, #32*4 @ step over unused register space
82 + #else
83 + VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
84 +@@ -52,7 +52,7 @@
85 + ldr \tmp, =elf_hwcap @ may not have MVFR regs
86 + ldr \tmp, [\tmp, #0]
87 + tst \tmp, #HWCAP_VFPv3D16
88 +- stceq p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
89 ++ stceql p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
90 + addne \base, \base, #32*4 @ step over unused register space
91 + #else
92 + VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
93 +diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
94 +index 39e3fb3..3b17227 100644
95 +--- a/arch/arm/mm/cache-v7.S
96 ++++ b/arch/arm/mm/cache-v7.S
97 +@@ -211,6 +211,9 @@ ENTRY(v7_coherent_user_range)
98 + * isn't mapped, fail with -EFAULT.
99 + */
100 + 9001:
101 ++#ifdef CONFIG_ARM_ERRATA_775420
102 ++ dsb
103 ++#endif
104 + mov r0, #-EFAULT
105 + mov pc, lr
106 + UNWIND(.fnend )
107 +diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
108 +index dbf1e03..2bc51fb 100644
109 +--- a/arch/arm/plat-omap/counter_32k.c
110 ++++ b/arch/arm/plat-omap/counter_32k.c
111 +@@ -55,22 +55,29 @@ static u32 notrace omap_32k_read_sched_clock(void)
112 + * nsecs and adds to a monotonically increasing timespec.
113 + */
114 + static struct timespec persistent_ts;
115 +-static cycles_t cycles, last_cycles;
116 ++static cycles_t cycles;
117 + static unsigned int persistent_mult, persistent_shift;
118 ++static DEFINE_SPINLOCK(read_persistent_clock_lock);
119 ++
120 + static void omap_read_persistent_clock(struct timespec *ts)
121 + {
122 + unsigned long long nsecs;
123 +- cycles_t delta;
124 +- struct timespec *tsp = &persistent_ts;
125 ++ cycles_t last_cycles;
126 ++ unsigned long flags;
127 ++
128 ++ spin_lock_irqsave(&read_persistent_clock_lock, flags);
129 +
130 + last_cycles = cycles;
131 + cycles = sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
132 +- delta = cycles - last_cycles;
133 +
134 +- nsecs = clocksource_cyc2ns(delta, persistent_mult, persistent_shift);
135 ++ nsecs = clocksource_cyc2ns(cycles - last_cycles,
136 ++ persistent_mult, persistent_shift);
137 ++
138 ++ timespec_add_ns(&persistent_ts, nsecs);
139 ++
140 ++ *ts = persistent_ts;
141 +
142 +- timespec_add_ns(tsp, nsecs);
143 +- *ts = *tsp;
144 ++ spin_unlock_irqrestore(&read_persistent_clock_lock, flags);
145 + }
146 +
147 + /**
148 +diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c
149 +index d272857..579f452 100644
150 +--- a/arch/mips/ath79/clock.c
151 ++++ b/arch/mips/ath79/clock.c
152 +@@ -17,6 +17,8 @@
153 + #include <linux/err.h>
154 + #include <linux/clk.h>
155 +
156 ++#include <asm/div64.h>
157 ++
158 + #include <asm/mach-ath79/ath79.h>
159 + #include <asm/mach-ath79/ar71xx_regs.h>
160 + #include "common.h"
161 +@@ -166,11 +168,34 @@ static void __init ar933x_clocks_init(void)
162 + ath79_uart_clk.rate = ath79_ref_clk.rate;
163 + }
164 +
165 ++static u32 __init ar934x_get_pll_freq(u32 ref, u32 ref_div, u32 nint, u32 nfrac,
166 ++ u32 frac, u32 out_div)
167 ++{
168 ++ u64 t;
169 ++ u32 ret;
170 ++
171 ++ t = ath79_ref_clk.rate;
172 ++ t *= nint;
173 ++ do_div(t, ref_div);
174 ++ ret = t;
175 ++
176 ++ t = ath79_ref_clk.rate;
177 ++ t *= nfrac;
178 ++ do_div(t, ref_div * frac);
179 ++ ret += t;
180 ++
181 ++ ret /= (1 << out_div);
182 ++ return ret;
183 ++}
184 ++
185 + static void __init ar934x_clocks_init(void)
186 + {
187 +- u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
188 ++ u32 pll, out_div, ref_div, nint, nfrac, frac, clk_ctrl, postdiv;
189 + u32 cpu_pll, ddr_pll;
190 + u32 bootstrap;
191 ++ void __iomem *dpll_base;
192 ++
193 ++ dpll_base = ioremap(AR934X_SRIF_BASE, AR934X_SRIF_SIZE);
194 +
195 + bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
196 + if (bootstrap & AR934X_BOOTSTRAP_REF_CLK_40)
197 +@@ -178,33 +203,59 @@ static void __init ar934x_clocks_init(void)
198 + else
199 + ath79_ref_clk.rate = 25 * 1000 * 1000;
200 +
201 +- pll = ath79_pll_rr(AR934X_PLL_CPU_CONFIG_REG);
202 +- out_div = (pll >> AR934X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
203 +- AR934X_PLL_CPU_CONFIG_OUTDIV_MASK;
204 +- ref_div = (pll >> AR934X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
205 +- AR934X_PLL_CPU_CONFIG_REFDIV_MASK;
206 +- nint = (pll >> AR934X_PLL_CPU_CONFIG_NINT_SHIFT) &
207 +- AR934X_PLL_CPU_CONFIG_NINT_MASK;
208 +- frac = (pll >> AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
209 +- AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
210 +-
211 +- cpu_pll = nint * ath79_ref_clk.rate / ref_div;
212 +- cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 6));
213 +- cpu_pll /= (1 << out_div);
214 +-
215 +- pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
216 +- out_div = (pll >> AR934X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
217 +- AR934X_PLL_DDR_CONFIG_OUTDIV_MASK;
218 +- ref_div = (pll >> AR934X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
219 +- AR934X_PLL_DDR_CONFIG_REFDIV_MASK;
220 +- nint = (pll >> AR934X_PLL_DDR_CONFIG_NINT_SHIFT) &
221 +- AR934X_PLL_DDR_CONFIG_NINT_MASK;
222 +- frac = (pll >> AR934X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
223 +- AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
224 +-
225 +- ddr_pll = nint * ath79_ref_clk.rate / ref_div;
226 +- ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 10));
227 +- ddr_pll /= (1 << out_div);
228 ++ pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL2_REG);
229 ++ if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
230 ++ out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
231 ++ AR934X_SRIF_DPLL2_OUTDIV_MASK;
232 ++ pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL1_REG);
233 ++ nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
234 ++ AR934X_SRIF_DPLL1_NINT_MASK;
235 ++ nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
236 ++ ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
237 ++ AR934X_SRIF_DPLL1_REFDIV_MASK;
238 ++ frac = 1 << 18;
239 ++ } else {
240 ++ pll = ath79_pll_rr(AR934X_PLL_CPU_CONFIG_REG);
241 ++ out_div = (pll >> AR934X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
242 ++ AR934X_PLL_CPU_CONFIG_OUTDIV_MASK;
243 ++ ref_div = (pll >> AR934X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
244 ++ AR934X_PLL_CPU_CONFIG_REFDIV_MASK;
245 ++ nint = (pll >> AR934X_PLL_CPU_CONFIG_NINT_SHIFT) &
246 ++ AR934X_PLL_CPU_CONFIG_NINT_MASK;
247 ++ nfrac = (pll >> AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
248 ++ AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
249 ++ frac = 1 << 6;
250 ++ }
251 ++
252 ++ cpu_pll = ar934x_get_pll_freq(ath79_ref_clk.rate, ref_div, nint,
253 ++ nfrac, frac, out_div);
254 ++
255 ++ pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL2_REG);
256 ++ if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
257 ++ out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
258 ++ AR934X_SRIF_DPLL2_OUTDIV_MASK;
259 ++ pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL1_REG);
260 ++ nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
261 ++ AR934X_SRIF_DPLL1_NINT_MASK;
262 ++ nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
263 ++ ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
264 ++ AR934X_SRIF_DPLL1_REFDIV_MASK;
265 ++ frac = 1 << 18;
266 ++ } else {
267 ++ pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
268 ++ out_div = (pll >> AR934X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
269 ++ AR934X_PLL_DDR_CONFIG_OUTDIV_MASK;
270 ++ ref_div = (pll >> AR934X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
271 ++ AR934X_PLL_DDR_CONFIG_REFDIV_MASK;
272 ++ nint = (pll >> AR934X_PLL_DDR_CONFIG_NINT_SHIFT) &
273 ++ AR934X_PLL_DDR_CONFIG_NINT_MASK;
274 ++ nfrac = (pll >> AR934X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
275 ++ AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
276 ++ frac = 1 << 10;
277 ++ }
278 ++
279 ++ ddr_pll = ar934x_get_pll_freq(ath79_ref_clk.rate, ref_div, nint,
280 ++ nfrac, frac, out_div);
281 +
282 + clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
283 +
284 +@@ -240,6 +291,8 @@ static void __init ar934x_clocks_init(void)
285 +
286 + ath79_wdt_clk.rate = ath79_ref_clk.rate;
287 + ath79_uart_clk.rate = ath79_ref_clk.rate;
288 ++
289 ++ iounmap(dpll_base);
290 + }
291 +
292 + void __init ath79_clocks_init(void)
293 +diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
294 +index dde5044..31a9a7c 100644
295 +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
296 ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
297 +@@ -63,6 +63,8 @@
298 +
299 + #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
300 + #define AR934X_WMAC_SIZE 0x20000
301 ++#define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
302 ++#define AR934X_SRIF_SIZE 0x1000
303 +
304 + /*
305 + * DDR_CTRL block
306 +@@ -399,4 +401,25 @@
307 + #define AR933X_GPIO_COUNT 30
308 + #define AR934X_GPIO_COUNT 23
309 +
310 ++/*
311 ++ * SRIF block
312 ++ */
313 ++#define AR934X_SRIF_CPU_DPLL1_REG 0x1c0
314 ++#define AR934X_SRIF_CPU_DPLL2_REG 0x1c4
315 ++#define AR934X_SRIF_CPU_DPLL3_REG 0x1c8
316 ++
317 ++#define AR934X_SRIF_DDR_DPLL1_REG 0x240
318 ++#define AR934X_SRIF_DDR_DPLL2_REG 0x244
319 ++#define AR934X_SRIF_DDR_DPLL3_REG 0x248
320 ++
321 ++#define AR934X_SRIF_DPLL1_REFDIV_SHIFT 27
322 ++#define AR934X_SRIF_DPLL1_REFDIV_MASK 0x1f
323 ++#define AR934X_SRIF_DPLL1_NINT_SHIFT 18
324 ++#define AR934X_SRIF_DPLL1_NINT_MASK 0x1ff
325 ++#define AR934X_SRIF_DPLL1_NFRAC_MASK 0x0003ffff
326 ++
327 ++#define AR934X_SRIF_DPLL2_LOCAL_PLL BIT(30)
328 ++#define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
329 ++#define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
330 ++
331 + #endif /* __ASM_MACH_AR71XX_REGS_H */
332 +diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
333 +index f4546e9..23817a6 100644
334 +--- a/arch/mips/kernel/kgdb.c
335 ++++ b/arch/mips/kernel/kgdb.c
336 +@@ -283,6 +283,15 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
337 + struct pt_regs *regs = args->regs;
338 + int trap = (regs->cp0_cause & 0x7c) >> 2;
339 +
340 ++#ifdef CONFIG_KPROBES
341 ++ /*
342 ++ * Return immediately if the kprobes fault notifier has set
343 ++ * DIE_PAGE_FAULT.
344 ++ */
345 ++ if (cmd == DIE_PAGE_FAULT)
346 ++ return NOTIFY_DONE;
347 ++#endif /* CONFIG_KPROBES */
348 ++
349 + /* Userspace events, ignore. */
350 + if (user_mode(regs))
351 + return NOTIFY_DONE;
352 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
353 +index 58790bd..05afcca 100644
354 +--- a/arch/x86/Makefile
355 ++++ b/arch/x86/Makefile
356 +@@ -142,7 +142,7 @@ KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
357 + KBUILD_CFLAGS += $(mflags-y)
358 + KBUILD_AFLAGS += $(mflags-y)
359 +
360 +-archscripts:
361 ++archscripts: scripts_basic
362 + $(Q)$(MAKE) $(build)=arch/x86/tools relocs
363 +
364 + ###
365 +diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
366 +index 1fbe75a..c1461de 100644
367 +--- a/arch/x86/xen/enlighten.c
368 ++++ b/arch/x86/xen/enlighten.c
369 +@@ -984,7 +984,16 @@ static void xen_write_cr4(unsigned long cr4)
370 +
371 + native_write_cr4(cr4);
372 + }
373 +-
374 ++#ifdef CONFIG_X86_64
375 ++static inline unsigned long xen_read_cr8(void)
376 ++{
377 ++ return 0;
378 ++}
379 ++static inline void xen_write_cr8(unsigned long val)
380 ++{
381 ++ BUG_ON(val);
382 ++}
383 ++#endif
384 + static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
385 + {
386 + int ret;
387 +@@ -1153,6 +1162,11 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
388 + .read_cr4_safe = native_read_cr4_safe,
389 + .write_cr4 = xen_write_cr4,
390 +
391 ++#ifdef CONFIG_X86_64
392 ++ .read_cr8 = xen_read_cr8,
393 ++ .write_cr8 = xen_write_cr8,
394 ++#endif
395 ++
396 + .wbinvd = native_wbinvd,
397 +
398 + .read_msr = native_read_msr_safe,
399 +@@ -1161,6 +1175,8 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
400 + .read_tsc = native_read_tsc,
401 + .read_pmc = native_read_pmc,
402 +
403 ++ .read_tscp = native_read_tscp,
404 ++
405 + .iret = xen_iret,
406 + .irq_enable_sysexit = xen_sysexit,
407 + #ifdef CONFIG_X86_64
408 +diff --git a/block/blk-core.c b/block/blk-core.c
409 +index ee3cb3a..8471fb7 100644
410 +--- a/block/blk-core.c
411 ++++ b/block/blk-core.c
412 +@@ -696,7 +696,7 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn,
413 + q->request_fn = rfn;
414 + q->prep_rq_fn = NULL;
415 + q->unprep_rq_fn = NULL;
416 +- q->queue_flags = QUEUE_FLAG_DEFAULT;
417 ++ q->queue_flags |= QUEUE_FLAG_DEFAULT;
418 +
419 + /* Override internal queue lock with supplied lock pointer */
420 + if (lock)
421 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
422 +index 7edaccc..a51df96 100644
423 +--- a/drivers/acpi/ec.c
424 ++++ b/drivers/acpi/ec.c
425 +@@ -71,9 +71,6 @@ enum ec_command {
426 + #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
427 + #define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */
428 +
429 +-#define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts
430 +- per one transaction */
431 +-
432 + enum {
433 + EC_FLAGS_QUERY_PENDING, /* Query is pending */
434 + EC_FLAGS_GPE_STORM, /* GPE storm detected */
435 +@@ -87,6 +84,15 @@ static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY;
436 + module_param(ec_delay, uint, 0644);
437 + MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes");
438 +
439 ++/*
440 ++ * If the number of false interrupts per one transaction exceeds
441 ++ * this threshold, will think there is a GPE storm happened and
442 ++ * will disable the GPE for normal transaction.
443 ++ */
444 ++static unsigned int ec_storm_threshold __read_mostly = 8;
445 ++module_param(ec_storm_threshold, uint, 0644);
446 ++MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm");
447 ++
448 + /* If we find an EC via the ECDT, we need to keep a ptr to its context */
449 + /* External interfaces use first EC only, so remember */
450 + typedef int (*acpi_ec_query_func) (void *data);
451 +@@ -319,7 +325,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
452 + msleep(1);
453 + /* It is safe to enable the GPE outside of the transaction. */
454 + acpi_enable_gpe(NULL, ec->gpe);
455 +- } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
456 ++ } else if (t->irq_count > ec_storm_threshold) {
457 + pr_info(PREFIX "GPE storm detected, "
458 + "transactions will use polling mode\n");
459 + set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
460 +@@ -924,6 +930,17 @@ static int ec_flag_msi(const struct dmi_system_id *id)
461 + return 0;
462 + }
463 +
464 ++/*
465 ++ * Clevo M720 notebook actually works ok with IRQ mode, if we lifted
466 ++ * the GPE storm threshold back to 20
467 ++ */
468 ++static int ec_enlarge_storm_threshold(const struct dmi_system_id *id)
469 ++{
470 ++ pr_debug("Setting the EC GPE storm threshold to 20\n");
471 ++ ec_storm_threshold = 20;
472 ++ return 0;
473 ++}
474 ++
475 + static struct dmi_system_id __initdata ec_dmi_table[] = {
476 + {
477 + ec_skip_dsdt_scan, "Compal JFL92", {
478 +@@ -955,10 +972,13 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
479 + {
480 + ec_validate_ecdt, "ASUS hardware", {
481 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL},
482 ++ {
483 ++ ec_enlarge_storm_threshold, "CLEVO hardware", {
484 ++ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
485 ++ DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL},
486 + {},
487 + };
488 +
489 +-
490 + int __init acpi_ec_ecdt_probe(void)
491 + {
492 + acpi_status status;
493 +diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
494 +index 817f0ee..4dc8024 100644
495 +--- a/drivers/char/tpm/tpm.c
496 ++++ b/drivers/char/tpm/tpm.c
497 +@@ -1186,17 +1186,20 @@ ssize_t tpm_write(struct file *file, const char __user *buf,
498 + size_t size, loff_t *off)
499 + {
500 + struct tpm_chip *chip = file->private_data;
501 +- size_t in_size = size, out_size;
502 ++ size_t in_size = size;
503 ++ ssize_t out_size;
504 +
505 + /* cannot perform a write until the read has cleared
506 +- either via tpm_read or a user_read_timer timeout */
507 +- while (atomic_read(&chip->data_pending) != 0)
508 +- msleep(TPM_TIMEOUT);
509 +-
510 +- mutex_lock(&chip->buffer_mutex);
511 ++ either via tpm_read or a user_read_timer timeout.
512 ++ This also prevents splitted buffered writes from blocking here.
513 ++ */
514 ++ if (atomic_read(&chip->data_pending) != 0)
515 ++ return -EBUSY;
516 +
517 + if (in_size > TPM_BUFSIZE)
518 +- in_size = TPM_BUFSIZE;
519 ++ return -E2BIG;
520 ++
521 ++ mutex_lock(&chip->buffer_mutex);
522 +
523 + if (copy_from_user
524 + (chip->data_buffer, (void __user *) buf, in_size)) {
525 +@@ -1206,6 +1209,10 @@ ssize_t tpm_write(struct file *file, const char __user *buf,
526 +
527 + /* atomic tpm command send and result receive */
528 + out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE);
529 ++ if (out_size < 0) {
530 ++ mutex_unlock(&chip->buffer_mutex);
531 ++ return out_size;
532 ++ }
533 +
534 + atomic_set(&chip->data_pending, out_size);
535 + mutex_unlock(&chip->buffer_mutex);
536 +diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
537 +index 2783f69..f8d2287 100644
538 +--- a/drivers/firewire/core-cdev.c
539 ++++ b/drivers/firewire/core-cdev.c
540 +@@ -473,8 +473,8 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg)
541 + client->bus_reset_closure = a->bus_reset_closure;
542 + if (a->bus_reset != 0) {
543 + fill_bus_reset_event(&bus_reset, client);
544 +- ret = copy_to_user(u64_to_uptr(a->bus_reset),
545 +- &bus_reset, sizeof(bus_reset));
546 ++ /* unaligned size of bus_reset is 36 bytes */
547 ++ ret = copy_to_user(u64_to_uptr(a->bus_reset), &bus_reset, 36);
548 + }
549 + if (ret == 0 && list_empty(&client->link))
550 + list_add_tail(&client->link, &client->device->client_list);
551 +diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
552 +index 274d25d..97d4f4b 100644
553 +--- a/drivers/gpu/drm/i915/i915_gem.c
554 ++++ b/drivers/gpu/drm/i915/i915_gem.c
555 +@@ -3893,7 +3893,6 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
556 +
557 + BUG_ON(!list_empty(&dev_priv->mm.active_list));
558 + BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
559 +- BUG_ON(!list_empty(&dev_priv->mm.inactive_list));
560 + mutex_unlock(&dev->struct_mutex);
561 +
562 + ret = drm_irq_install(dev);
563 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
564 +index a3e53c5..f02cfad 100644
565 +--- a/drivers/gpu/drm/i915/i915_reg.h
566 ++++ b/drivers/gpu/drm/i915/i915_reg.h
567 +@@ -513,7 +513,7 @@
568 + */
569 + # define _3D_CHICKEN2_WM_READ_PIPELINED (1 << 14)
570 + #define _3D_CHICKEN3 0x02090
571 +-#define _3D_CHICKEN_SF_DISABLE_FASTCLIP_CULL (1 << 5)
572 ++#define _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL (1 << 5)
573 +
574 + #define MI_MODE 0x0209c
575 + # define VS_TIMER_DISPATCH (1 << 6)
576 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
577 +index 0c7f4aa..b634f6f 100644
578 +--- a/drivers/gpu/drm/i915/intel_display.c
579 ++++ b/drivers/gpu/drm/i915/intel_display.c
580 +@@ -4351,7 +4351,7 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
581 + /* default to 8bpc */
582 + pipeconf &= ~(PIPECONF_BPP_MASK | PIPECONF_DITHER_EN);
583 + if (is_dp) {
584 +- if (mode->private_flags & INTEL_MODE_DP_FORCE_6BPC) {
585 ++ if (adjusted_mode->private_flags & INTEL_MODE_DP_FORCE_6BPC) {
586 + pipeconf |= PIPECONF_BPP_6 |
587 + PIPECONF_DITHER_EN |
588 + PIPECONF_DITHER_TYPE_SP;
589 +@@ -4705,7 +4705,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
590 + /* determine panel color depth */
591 + temp = I915_READ(PIPECONF(pipe));
592 + temp &= ~PIPE_BPC_MASK;
593 +- dither = intel_choose_pipe_bpp_dither(crtc, &pipe_bpp, mode);
594 ++ dither = intel_choose_pipe_bpp_dither(crtc, &pipe_bpp, adjusted_mode);
595 + switch (pipe_bpp) {
596 + case 18:
597 + temp |= PIPE_6BPC;
598 +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
599 +index 8c73fae..c23c9ea 100644
600 +--- a/drivers/gpu/drm/i915/intel_pm.c
601 ++++ b/drivers/gpu/drm/i915/intel_pm.c
602 +@@ -3355,8 +3355,8 @@ static void gen6_init_clock_gating(struct drm_device *dev)
603 + GEN6_RCCUNIT_CLOCK_GATE_DISABLE);
604 +
605 + /* Bspec says we need to always set all mask bits. */
606 +- I915_WRITE(_3D_CHICKEN, (0xFFFF << 16) |
607 +- _3D_CHICKEN_SF_DISABLE_FASTCLIP_CULL);
608 ++ I915_WRITE(_3D_CHICKEN3, (0xFFFF << 16) |
609 ++ _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL);
610 +
611 + /*
612 + * According to the spec the following bits should be
613 +diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
614 +index 670e991..d16f50f 100644
615 +--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
616 ++++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
617 +@@ -974,11 +974,7 @@ static void radeon_legacy_tmds_ext_mode_set(struct drm_encoder *encoder,
618 + static void radeon_ext_tmds_enc_destroy(struct drm_encoder *encoder)
619 + {
620 + struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
621 +- struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
622 +- if (tmds) {
623 +- if (tmds->i2c_bus)
624 +- radeon_i2c_destroy(tmds->i2c_bus);
625 +- }
626 ++ /* don't destroy the i2c bus record here, this will be done in radeon_i2c_fini */
627 + kfree(radeon_encoder->enc_priv);
628 + drm_encoder_cleanup(encoder);
629 + kfree(radeon_encoder);
630 +diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
631 +index 0138a72..a48c215 100644
632 +--- a/drivers/md/raid10.c
633 ++++ b/drivers/md/raid10.c
634 +@@ -3158,7 +3158,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
635 + else {
636 + bad_sectors -= (sector - first_bad);
637 + if (max_sync > bad_sectors)
638 +- max_sync = max_sync;
639 ++ max_sync = bad_sectors;
640 + continue;
641 + }
642 + }
643 +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
644 +index a11253a..c429abd 100644
645 +--- a/drivers/mtd/nand/nand_base.c
646 ++++ b/drivers/mtd/nand/nand_base.c
647 +@@ -2914,8 +2914,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
648 + if (le16_to_cpu(p->features) & 1)
649 + *busw = NAND_BUSWIDTH_16;
650 +
651 +- chip->options &= ~NAND_CHIPOPTIONS_MSK;
652 +- chip->options |= NAND_NO_READRDY & NAND_CHIPOPTIONS_MSK;
653 ++ chip->options |= NAND_NO_READRDY;
654 +
655 + pr_info("ONFI flash detected\n");
656 + return 1;
657 +@@ -3080,9 +3079,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
658 + mtd->erasesize <<= ((id_data[3] & 0x03) << 1);
659 + }
660 + }
661 +- /* Get chip options, preserve non chip based options */
662 +- chip->options &= ~NAND_CHIPOPTIONS_MSK;
663 +- chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
664 ++ /* Get chip options */
665 ++ chip->options |= type->options;
666 +
667 + /*
668 + * Check if chip is not a Samsung device. Do not clear the
669 +diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
670 +index cb3356c..04668b4 100644
671 +--- a/drivers/net/ethernet/intel/e1000e/e1000.h
672 ++++ b/drivers/net/ethernet/intel/e1000e/e1000.h
673 +@@ -175,13 +175,13 @@ struct e1000_info;
674 + /*
675 + * in the case of WTHRESH, it appears at least the 82571/2 hardware
676 + * writes back 4 descriptors when WTHRESH=5, and 3 descriptors when
677 +- * WTHRESH=4, and since we want 64 bytes at a time written back, set
678 +- * it to 5
679 ++ * WTHRESH=4, so a setting of 5 gives the most efficient bus
680 ++ * utilization but to avoid possible Tx stalls, set it to 1
681 + */
682 + #define E1000_TXDCTL_DMA_BURST_ENABLE \
683 + (E1000_TXDCTL_GRAN | /* set descriptor granularity */ \
684 + E1000_TXDCTL_COUNT_DESC | \
685 +- (5 << 16) | /* wthresh must be +1 more than desired */\
686 ++ (1 << 16) | /* wthresh must be +1 more than desired */\
687 + (1 << 8) | /* hthresh */ \
688 + 0x1f) /* pthresh */
689 +
690 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
691 +index d01a099..a46e75e 100644
692 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
693 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
694 +@@ -2831,7 +2831,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
695 + * set up some performance related parameters to encourage the
696 + * hardware to use the bus more efficiently in bursts, depends
697 + * on the tx_int_delay to be enabled,
698 +- * wthresh = 5 ==> burst write a cacheline (64 bytes) at a time
699 ++ * wthresh = 1 ==> burst write is disabled to avoid Tx stalls
700 + * hthresh = 1 ==> prefetch when one or more available
701 + * pthresh = 0x1f ==> prefetch if internal cache 31 or less
702 + * BEWARE: this seems to work but should be considered first if
703 +diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
704 +index 03c2d8d..cc7e720 100644
705 +--- a/drivers/net/usb/mcs7830.c
706 ++++ b/drivers/net/usb/mcs7830.c
707 +@@ -117,6 +117,7 @@ enum {
708 + struct mcs7830_data {
709 + u8 multi_filter[8];
710 + u8 config;
711 ++ u8 link_counter;
712 + };
713 +
714 + static const char driver_name[] = "MOSCHIP usb-ethernet driver";
715 +@@ -632,20 +633,31 @@ static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
716 + static void mcs7830_status(struct usbnet *dev, struct urb *urb)
717 + {
718 + u8 *buf = urb->transfer_buffer;
719 +- bool link;
720 ++ bool link, link_changed;
721 ++ struct mcs7830_data *data = mcs7830_get_data(dev);
722 +
723 + if (urb->actual_length < 16)
724 + return;
725 +
726 + link = !(buf[1] & 0x20);
727 +- if (netif_carrier_ok(dev->net) != link) {
728 +- if (link) {
729 +- netif_carrier_on(dev->net);
730 +- usbnet_defer_kevent(dev, EVENT_LINK_RESET);
731 +- } else
732 +- netif_carrier_off(dev->net);
733 +- netdev_dbg(dev->net, "Link Status is: %d\n", link);
734 +- }
735 ++ link_changed = netif_carrier_ok(dev->net) != link;
736 ++ if (link_changed) {
737 ++ data->link_counter++;
738 ++ /*
739 ++ track link state 20 times to guard against erroneous
740 ++ link state changes reported sometimes by the chip
741 ++ */
742 ++ if (data->link_counter > 20) {
743 ++ data->link_counter = 0;
744 ++ if (link) {
745 ++ netif_carrier_on(dev->net);
746 ++ usbnet_defer_kevent(dev, EVENT_LINK_RESET);
747 ++ } else
748 ++ netif_carrier_off(dev->net);
749 ++ netdev_dbg(dev->net, "Link Status is: %d\n", link);
750 ++ }
751 ++ } else
752 ++ data->link_counter = 0;
753 + }
754 +
755 + static const struct driver_info moschip_info = {
756 +diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
757 +index 76f07d8..1b48414 100644
758 +--- a/drivers/net/wireless/ath/ath9k/beacon.c
759 ++++ b/drivers/net/wireless/ath/ath9k/beacon.c
760 +@@ -120,7 +120,7 @@ static void ath9k_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
761 +
762 + if (ath_tx_start(hw, skb, &txctl) != 0) {
763 + ath_dbg(common, XMIT, "CABQ TX failed\n");
764 +- dev_kfree_skb_any(skb);
765 ++ ieee80211_free_txskb(hw, skb);
766 + }
767 + }
768 +
769 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
770 +index a22df74..61e08e6 100644
771 +--- a/drivers/net/wireless/ath/ath9k/main.c
772 ++++ b/drivers/net/wireless/ath/ath9k/main.c
773 +@@ -767,7 +767,7 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
774 +
775 + return;
776 + exit:
777 +- dev_kfree_skb_any(skb);
778 ++ ieee80211_free_txskb(hw, skb);
779 + }
780 +
781 + static void ath9k_stop(struct ieee80211_hw *hw)
782 +diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
783 +index 0d4155a..423a9f3 100644
784 +--- a/drivers/net/wireless/ath/ath9k/xmit.c
785 ++++ b/drivers/net/wireless/ath/ath9k/xmit.c
786 +@@ -66,8 +66,7 @@ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
787 + static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
788 + struct ath_txq *txq,
789 + struct ath_atx_tid *tid,
790 +- struct sk_buff *skb,
791 +- bool dequeue);
792 ++ struct sk_buff *skb);
793 +
794 + enum {
795 + MCS_HT20,
796 +@@ -176,7 +175,15 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
797 + fi = get_frame_info(skb);
798 + bf = fi->bf;
799 +
800 +- if (bf && fi->retries) {
801 ++ if (!bf) {
802 ++ bf = ath_tx_setup_buffer(sc, txq, tid, skb);
803 ++ if (!bf) {
804 ++ ieee80211_free_txskb(sc->hw, skb);
805 ++ continue;
806 ++ }
807 ++ }
808 ++
809 ++ if (fi->retries) {
810 + list_add_tail(&bf->list, &bf_head);
811 + ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
812 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
813 +@@ -785,10 +792,13 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
814 + fi = get_frame_info(skb);
815 + bf = fi->bf;
816 + if (!fi->bf)
817 +- bf = ath_tx_setup_buffer(sc, txq, tid, skb, true);
818 ++ bf = ath_tx_setup_buffer(sc, txq, tid, skb);
819 +
820 +- if (!bf)
821 ++ if (!bf) {
822 ++ __skb_unlink(skb, &tid->buf_q);
823 ++ ieee80211_free_txskb(sc->hw, skb);
824 + continue;
825 ++ }
826 +
827 + bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
828 + seqno = bf->bf_state.seqno;
829 +@@ -1731,9 +1741,11 @@ static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_atx_tid *tid,
830 + return;
831 + }
832 +
833 +- bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb, false);
834 +- if (!bf)
835 ++ bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
836 ++ if (!bf) {
837 ++ ieee80211_free_txskb(sc->hw, skb);
838 + return;
839 ++ }
840 +
841 + bf->bf_state.bf_type = BUF_AMPDU;
842 + INIT_LIST_HEAD(&bf_head);
843 +@@ -1757,11 +1769,6 @@ static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
844 + struct ath_buf *bf;
845 +
846 + bf = fi->bf;
847 +- if (!bf)
848 +- bf = ath_tx_setup_buffer(sc, txq, tid, skb, false);
849 +-
850 +- if (!bf)
851 +- return;
852 +
853 + INIT_LIST_HEAD(&bf_head);
854 + list_add_tail(&bf->list, &bf_head);
855 +@@ -1834,8 +1841,7 @@ u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate)
856 + static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
857 + struct ath_txq *txq,
858 + struct ath_atx_tid *tid,
859 +- struct sk_buff *skb,
860 +- bool dequeue)
861 ++ struct sk_buff *skb)
862 + {
863 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
864 + struct ath_frame_info *fi = get_frame_info(skb);
865 +@@ -1847,7 +1853,7 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
866 + bf = ath_tx_get_buffer(sc);
867 + if (!bf) {
868 + ath_dbg(common, XMIT, "TX buffers are full\n");
869 +- goto error;
870 ++ return NULL;
871 + }
872 +
873 + ATH_TXBUF_RESET(bf);
874 +@@ -1876,18 +1882,12 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
875 + ath_err(ath9k_hw_common(sc->sc_ah),
876 + "dma_mapping_error() on TX\n");
877 + ath_tx_return_buffer(sc, bf);
878 +- goto error;
879 ++ return NULL;
880 + }
881 +
882 + fi->bf = bf;
883 +
884 + return bf;
885 +-
886 +-error:
887 +- if (dequeue)
888 +- __skb_unlink(skb, &tid->buf_q);
889 +- dev_kfree_skb_any(skb);
890 +- return NULL;
891 + }
892 +
893 + /* FIXME: tx power */
894 +@@ -1916,9 +1916,14 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb,
895 + */
896 + ath_tx_send_ampdu(sc, tid, skb, txctl);
897 + } else {
898 +- bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb, false);
899 +- if (!bf)
900 ++ bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
901 ++ if (!bf) {
902 ++ if (txctl->paprd)
903 ++ dev_kfree_skb_any(skb);
904 ++ else
905 ++ ieee80211_free_txskb(sc->hw, skb);
906 + return;
907 ++ }
908 +
909 + bf->bf_state.bfs_paprd = txctl->paprd;
910 +
911 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
912 +index 5b30132..41b74ba 100644
913 +--- a/drivers/scsi/qla2xxx/qla_target.c
914 ++++ b/drivers/scsi/qla2xxx/qla_target.c
915 +@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha,
916 + ctio->u.status1.scsi_status =
917 + __constant_cpu_to_le16(SS_RESPONSE_INFO_LEN_VALID);
918 + ctio->u.status1.response_len = __constant_cpu_to_le16(8);
919 +- ((uint32_t *)ctio->u.status1.sense_data)[0] = cpu_to_be32(resp_code);
920 ++ ctio->u.status1.sense_data[0] = resp_code;
921 +
922 + qla2x00_start_iocbs(ha, ha->req);
923 + }
924 +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
925 +index 182d5a5..f4cc413 100644
926 +--- a/drivers/scsi/scsi_debug.c
927 ++++ b/drivers/scsi/scsi_debug.c
928 +@@ -2054,7 +2054,7 @@ static void unmap_region(sector_t lba, unsigned int len)
929 + block = lba + alignment;
930 + rem = do_div(block, granularity);
931 +
932 +- if (rem == 0 && lba + granularity <= end && block < map_size) {
933 ++ if (rem == 0 && lba + granularity < end && block < map_size) {
934 + clear_bit(block, map_storep);
935 + if (scsi_debug_lbprz)
936 + memset(fake_storep +
937 +diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
938 +index 528d52b..0144078 100644
939 +--- a/drivers/scsi/storvsc_drv.c
940 ++++ b/drivers/scsi/storvsc_drv.c
941 +@@ -1221,7 +1221,12 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
942 + /*
943 + * At this point, all outstanding requests in the adapter
944 + * should have been flushed out and return to us
945 ++ * There is a potential race here where the host may be in
946 ++ * the process of responding when we return from here.
947 ++ * Just wait for all in-transit packets to be accounted for
948 ++ * before we return from here.
949 + */
950 ++ storvsc_wait_to_drain(stor_device);
951 +
952 + return SUCCESS;
953 + }
954 +diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
955 +index 3e79a2f..7554d78 100644
956 +--- a/drivers/scsi/virtio_scsi.c
957 ++++ b/drivers/scsi/virtio_scsi.c
958 +@@ -219,7 +219,7 @@ static int virtscsi_kick_event(struct virtio_scsi *vscsi,
959 + struct scatterlist sg;
960 + unsigned long flags;
961 +
962 +- sg_set_buf(&sg, &event_node->event, sizeof(struct virtio_scsi_event));
963 ++ sg_init_one(&sg, &event_node->event, sizeof(struct virtio_scsi_event));
964 +
965 + spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
966 +
967 +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
968 +index 97c0f78..dd4fce2 100644
969 +--- a/drivers/target/iscsi/iscsi_target.c
970 ++++ b/drivers/target/iscsi/iscsi_target.c
971 +@@ -3271,7 +3271,6 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
972 + len += 1;
973 +
974 + if ((len + payload_len) > buffer_len) {
975 +- spin_unlock(&tiqn->tiqn_tpg_lock);
976 + end_of_buf = 1;
977 + goto eob;
978 + }
979 +@@ -3424,6 +3423,7 @@ static int iscsit_send_reject(
980 + hdr->opcode = ISCSI_OP_REJECT;
981 + hdr->flags |= ISCSI_FLAG_CMD_FINAL;
982 + hton24(hdr->dlength, ISCSI_HDR_LEN);
983 ++ hdr->ffffffff = 0xffffffff;
984 + cmd->stat_sn = conn->stat_sn++;
985 + hdr->statsn = cpu_to_be32(cmd->stat_sn);
986 + hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn);
987 +diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
988 +index 8a908b2..a90294f 100644
989 +--- a/drivers/target/iscsi/iscsi_target_core.h
990 ++++ b/drivers/target/iscsi/iscsi_target_core.h
991 +@@ -25,10 +25,10 @@
992 + #define NA_DATAOUT_TIMEOUT_RETRIES 5
993 + #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15
994 + #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1
995 +-#define NA_NOPIN_TIMEOUT 5
996 ++#define NA_NOPIN_TIMEOUT 15
997 + #define NA_NOPIN_TIMEOUT_MAX 60
998 + #define NA_NOPIN_TIMEOUT_MIN 3
999 +-#define NA_NOPIN_RESPONSE_TIMEOUT 5
1000 ++#define NA_NOPIN_RESPONSE_TIMEOUT 30
1001 + #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60
1002 + #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3
1003 + #define NA_RANDOM_DATAIN_PDU_OFFSETS 0
1004 +diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
1005 +index a38a3f8..de9ea32 100644
1006 +--- a/drivers/target/iscsi/iscsi_target_tpg.c
1007 ++++ b/drivers/target/iscsi/iscsi_target_tpg.c
1008 +@@ -677,6 +677,12 @@ int iscsit_ta_generate_node_acls(
1009 + pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
1010 + tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled");
1011 +
1012 ++ if (flag == 1 && a->cache_dynamic_acls == 0) {
1013 ++ pr_debug("Explicitly setting cache_dynamic_acls=1 when "
1014 ++ "generate_node_acls=1\n");
1015 ++ a->cache_dynamic_acls = 1;
1016 ++ }
1017 ++
1018 + return 0;
1019 + }
1020 +
1021 +@@ -716,6 +722,12 @@ int iscsit_ta_cache_dynamic_acls(
1022 + return -EINVAL;
1023 + }
1024 +
1025 ++ if (a->generate_node_acls == 1 && flag == 0) {
1026 ++ pr_debug("Skipping cache_dynamic_acls=0 when"
1027 ++ " generate_node_acls=1\n");
1028 ++ return 0;
1029 ++ }
1030 ++
1031 + a->cache_dynamic_acls = flag;
1032 + pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
1033 + " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ?
1034 +diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
1035 +index 801efa8..06aca11 100644
1036 +--- a/drivers/target/target_core_configfs.c
1037 ++++ b/drivers/target/target_core_configfs.c
1038 +@@ -3132,6 +3132,7 @@ static int __init target_core_init_configfs(void)
1039 + GFP_KERNEL);
1040 + if (!target_cg->default_groups) {
1041 + pr_err("Unable to allocate target_cg->default_groups\n");
1042 ++ ret = -ENOMEM;
1043 + goto out_global;
1044 + }
1045 +
1046 +@@ -3147,6 +3148,7 @@ static int __init target_core_init_configfs(void)
1047 + GFP_KERNEL);
1048 + if (!hba_cg->default_groups) {
1049 + pr_err("Unable to allocate hba_cg->default_groups\n");
1050 ++ ret = -ENOMEM;
1051 + goto out_global;
1052 + }
1053 + config_group_init_type_name(&alua_group,
1054 +@@ -3162,6 +3164,7 @@ static int __init target_core_init_configfs(void)
1055 + GFP_KERNEL);
1056 + if (!alua_cg->default_groups) {
1057 + pr_err("Unable to allocate alua_cg->default_groups\n");
1058 ++ ret = -ENOMEM;
1059 + goto out_global;
1060 + }
1061 +
1062 +@@ -3173,14 +3176,17 @@ static int __init target_core_init_configfs(void)
1063 + * Add core/alua/lu_gps/default_lu_gp
1064 + */
1065 + lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1);
1066 +- if (IS_ERR(lu_gp))
1067 ++ if (IS_ERR(lu_gp)) {
1068 ++ ret = -ENOMEM;
1069 + goto out_global;
1070 ++ }
1071 +
1072 + lu_gp_cg = &alua_lu_gps_group;
1073 + lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
1074 + GFP_KERNEL);
1075 + if (!lu_gp_cg->default_groups) {
1076 + pr_err("Unable to allocate lu_gp_cg->default_groups\n");
1077 ++ ret = -ENOMEM;
1078 + goto out_global;
1079 + }
1080 +
1081 +diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
1082 +index cbb5aaf..5c5ed7a 100644
1083 +--- a/drivers/target/target_core_file.c
1084 ++++ b/drivers/target/target_core_file.c
1085 +@@ -125,6 +125,19 @@ static struct se_device *fd_create_virtdevice(
1086 + * of pure timestamp updates.
1087 + */
1088 + flags = O_RDWR | O_CREAT | O_LARGEFILE | O_DSYNC;
1089 ++ /*
1090 ++ * Optionally allow fd_buffered_io=1 to be enabled for people
1091 ++ * who want use the fs buffer cache as an WriteCache mechanism.
1092 ++ *
1093 ++ * This means that in event of a hard failure, there is a risk
1094 ++ * of silent data-loss if the SCSI client has *not* performed a
1095 ++ * forced unit access (FUA) write, or issued SYNCHRONIZE_CACHE
1096 ++ * to write-out the entire device cache.
1097 ++ */
1098 ++ if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
1099 ++ pr_debug("FILEIO: Disabling O_DSYNC, using buffered FILEIO\n");
1100 ++ flags &= ~O_DSYNC;
1101 ++ }
1102 +
1103 + file = filp_open(fd_dev->fd_dev_name, flags, 0600);
1104 + if (IS_ERR(file)) {
1105 +@@ -188,6 +201,12 @@ static struct se_device *fd_create_virtdevice(
1106 + if (!dev)
1107 + goto fail;
1108 +
1109 ++ if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
1110 ++ pr_debug("FILEIO: Forcing setting of emulate_write_cache=1"
1111 ++ " with FDBD_HAS_BUFFERED_IO_WCE\n");
1112 ++ dev->se_sub_dev->se_dev_attrib.emulate_write_cache = 1;
1113 ++ }
1114 ++
1115 + fd_dev->fd_dev_id = fd_host->fd_host_dev_id_count++;
1116 + fd_dev->fd_queue_depth = dev->queue_depth;
1117 +
1118 +@@ -407,6 +426,7 @@ enum {
1119 + static match_table_t tokens = {
1120 + {Opt_fd_dev_name, "fd_dev_name=%s"},
1121 + {Opt_fd_dev_size, "fd_dev_size=%s"},
1122 ++ {Opt_fd_buffered_io, "fd_buffered_io=%d"},
1123 + {Opt_err, NULL}
1124 + };
1125 +
1126 +@@ -418,7 +438,7 @@ static ssize_t fd_set_configfs_dev_params(
1127 + struct fd_dev *fd_dev = se_dev->se_dev_su_ptr;
1128 + char *orig, *ptr, *arg_p, *opts;
1129 + substring_t args[MAX_OPT_ARGS];
1130 +- int ret = 0, token;
1131 ++ int ret = 0, arg, token;
1132 +
1133 + opts = kstrdup(page, GFP_KERNEL);
1134 + if (!opts)
1135 +@@ -459,6 +479,19 @@ static ssize_t fd_set_configfs_dev_params(
1136 + " bytes\n", fd_dev->fd_dev_size);
1137 + fd_dev->fbd_flags |= FBDF_HAS_SIZE;
1138 + break;
1139 ++ case Opt_fd_buffered_io:
1140 ++ match_int(args, &arg);
1141 ++ if (arg != 1) {
1142 ++ pr_err("bogus fd_buffered_io=%d value\n", arg);
1143 ++ ret = -EINVAL;
1144 ++ goto out;
1145 ++ }
1146 ++
1147 ++ pr_debug("FILEIO: Using buffered I/O"
1148 ++ " operations for struct fd_dev\n");
1149 ++
1150 ++ fd_dev->fbd_flags |= FDBD_HAS_BUFFERED_IO_WCE;
1151 ++ break;
1152 + default:
1153 + break;
1154 + }
1155 +@@ -490,8 +523,10 @@ static ssize_t fd_show_configfs_dev_params(
1156 + ssize_t bl = 0;
1157 +
1158 + bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id);
1159 +- bl += sprintf(b + bl, " File: %s Size: %llu Mode: O_DSYNC\n",
1160 +- fd_dev->fd_dev_name, fd_dev->fd_dev_size);
1161 ++ bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n",
1162 ++ fd_dev->fd_dev_name, fd_dev->fd_dev_size,
1163 ++ (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) ?
1164 ++ "Buffered-WCE" : "O_DSYNC");
1165 + return bl;
1166 + }
1167 +
1168 +diff --git a/drivers/target/target_core_file.h b/drivers/target/target_core_file.h
1169 +index 70ce7fd..876ae53 100644
1170 +--- a/drivers/target/target_core_file.h
1171 ++++ b/drivers/target/target_core_file.h
1172 +@@ -14,6 +14,7 @@
1173 +
1174 + #define FBDF_HAS_PATH 0x01
1175 + #define FBDF_HAS_SIZE 0x02
1176 ++#define FDBD_HAS_BUFFERED_IO_WCE 0x04
1177 +
1178 + struct fd_dev {
1179 + u32 fbd_flags;
1180 +diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
1181 +index 388a922..9229bd9 100644
1182 +--- a/drivers/target/target_core_spc.c
1183 ++++ b/drivers/target/target_core_spc.c
1184 +@@ -600,30 +600,11 @@ static int spc_emulate_inquiry(struct se_cmd *cmd)
1185 + {
1186 + struct se_device *dev = cmd->se_dev;
1187 + struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg;
1188 +- unsigned char *buf, *map_buf;
1189 ++ unsigned char *rbuf;
1190 + unsigned char *cdb = cmd->t_task_cdb;
1191 ++ unsigned char buf[SE_INQUIRY_BUF];
1192 + int p, ret;
1193 +
1194 +- map_buf = transport_kmap_data_sg(cmd);
1195 +- /*
1196 +- * If SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is not set, then we
1197 +- * know we actually allocated a full page. Otherwise, if the
1198 +- * data buffer is too small, allocate a temporary buffer so we
1199 +- * don't have to worry about overruns in all our INQUIRY
1200 +- * emulation handling.
1201 +- */
1202 +- if (cmd->data_length < SE_INQUIRY_BUF &&
1203 +- (cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC)) {
1204 +- buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL);
1205 +- if (!buf) {
1206 +- transport_kunmap_data_sg(cmd);
1207 +- cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1208 +- return -ENOMEM;
1209 +- }
1210 +- } else {
1211 +- buf = map_buf;
1212 +- }
1213 +-
1214 + if (dev == tpg->tpg_virt_lun0.lun_se_dev)
1215 + buf[0] = 0x3f; /* Not connected */
1216 + else
1217 +@@ -655,11 +636,11 @@ static int spc_emulate_inquiry(struct se_cmd *cmd)
1218 + ret = -EINVAL;
1219 +
1220 + out:
1221 +- if (buf != map_buf) {
1222 +- memcpy(map_buf, buf, cmd->data_length);
1223 +- kfree(buf);
1224 ++ rbuf = transport_kmap_data_sg(cmd);
1225 ++ if (rbuf) {
1226 ++ memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
1227 ++ transport_kunmap_data_sg(cmd);
1228 + }
1229 +- transport_kunmap_data_sg(cmd);
1230 +
1231 + if (!ret)
1232 + target_complete_cmd(cmd, GOOD);
1233 +@@ -803,7 +784,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
1234 + unsigned char *rbuf;
1235 + int type = dev->transport->get_device_type(dev);
1236 + int ten = (cmd->t_task_cdb[0] == MODE_SENSE_10);
1237 +- int offset = ten ? 8 : 4;
1238 ++ u32 offset = ten ? 8 : 4;
1239 + int length = 0;
1240 + unsigned char buf[SE_MODE_PAGE_BUF];
1241 +
1242 +@@ -836,6 +817,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
1243 + offset -= 2;
1244 + buf[0] = (offset >> 8) & 0xff;
1245 + buf[1] = offset & 0xff;
1246 ++ offset += 2;
1247 +
1248 + if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
1249 + (cmd->se_deve &&
1250 +@@ -845,13 +827,10 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
1251 + if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
1252 + (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
1253 + spc_modesense_dpofua(&buf[3], type);
1254 +-
1255 +- if ((offset + 2) > cmd->data_length)
1256 +- offset = cmd->data_length;
1257 +-
1258 + } else {
1259 + offset -= 1;
1260 + buf[0] = offset & 0xff;
1261 ++ offset += 1;
1262 +
1263 + if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
1264 + (cmd->se_deve &&
1265 +@@ -861,14 +840,13 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
1266 + if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
1267 + (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
1268 + spc_modesense_dpofua(&buf[2], type);
1269 +-
1270 +- if ((offset + 1) > cmd->data_length)
1271 +- offset = cmd->data_length;
1272 + }
1273 +
1274 + rbuf = transport_kmap_data_sg(cmd);
1275 +- memcpy(rbuf, buf, offset);
1276 +- transport_kunmap_data_sg(cmd);
1277 ++ if (rbuf) {
1278 ++ memcpy(rbuf, buf, min(offset, cmd->data_length));
1279 ++ transport_kunmap_data_sg(cmd);
1280 ++ }
1281 +
1282 + target_complete_cmd(cmd, GOOD);
1283 + return 0;
1284 +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
1285 +index 84cbf29..a13f7e1 100644
1286 +--- a/drivers/tty/vt/vt.c
1287 ++++ b/drivers/tty/vt/vt.c
1288 +@@ -3475,6 +3475,19 @@ int con_debug_enter(struct vc_data *vc)
1289 + kdb_set(2, setargs);
1290 + }
1291 + }
1292 ++ if (vc->vc_cols < 999) {
1293 ++ int colcount;
1294 ++ char cols[4];
1295 ++ const char *setargs[3] = {
1296 ++ "set",
1297 ++ "COLUMNS",
1298 ++ cols,
1299 ++ };
1300 ++ if (kdbgetintenv(setargs[0], &colcount)) {
1301 ++ snprintf(cols, 4, "%i", vc->vc_cols);
1302 ++ kdb_set(2, setargs);
1303 ++ }
1304 ++ }
1305 + #endif /* CONFIG_KGDB_KDB */
1306 + return ret;
1307 + }
1308 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1309 +index f763ed7..e8007b8 100644
1310 +--- a/drivers/usb/class/cdc-acm.c
1311 ++++ b/drivers/usb/class/cdc-acm.c
1312 +@@ -1551,6 +1551,9 @@ static const struct usb_device_id acm_ids[] = {
1313 + Maybe we should define a new
1314 + quirk for this. */
1315 + },
1316 ++ { USB_DEVICE(0x0572, 0x1340), /* Conexant CX93010-2x UCMxx */
1317 ++ .driver_info = NO_UNION_NORMAL,
1318 ++ },
1319 + { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */
1320 + .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1321 + },
1322 +diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
1323 +index 1e35963..660fd53 100644
1324 +--- a/drivers/usb/gadget/at91_udc.c
1325 ++++ b/drivers/usb/gadget/at91_udc.c
1326 +@@ -1699,7 +1699,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1327 + int retval;
1328 + struct resource *res;
1329 +
1330 +- if (!dev->platform_data) {
1331 ++ if (!dev->platform_data && !pdev->dev.of_node) {
1332 + /* small (so we copy it) but critical! */
1333 + DBG("missing platform_data\n");
1334 + return -ENODEV;
1335 +diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
1336 +index d8dedc7..3639371 100644
1337 +--- a/drivers/vfio/pci/vfio_pci_intrs.c
1338 ++++ b/drivers/vfio/pci/vfio_pci_intrs.c
1339 +@@ -366,6 +366,17 @@ static int vfio_intx_enable(struct vfio_pci_device *vdev)
1340 + return -ENOMEM;
1341 +
1342 + vdev->num_ctx = 1;
1343 ++
1344 ++ /*
1345 ++ * If the virtual interrupt is masked, restore it. Devices
1346 ++ * supporting DisINTx can be masked at the hardware level
1347 ++ * here, non-PCI-2.3 devices will have to wait until the
1348 ++ * interrupt is enabled.
1349 ++ */
1350 ++ vdev->ctx[0].masked = vdev->virq_disabled;
1351 ++ if (vdev->pci_2_3)
1352 ++ pci_intx(vdev->pdev, !vdev->ctx[0].masked);
1353 ++
1354 + vdev->irq_type = VFIO_PCI_INTX_IRQ_INDEX;
1355 +
1356 + return 0;
1357 +@@ -400,25 +411,26 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
1358 + return PTR_ERR(trigger);
1359 + }
1360 +
1361 ++ vdev->ctx[0].trigger = trigger;
1362 ++
1363 + if (!vdev->pci_2_3)
1364 + irqflags = 0;
1365 +
1366 + ret = request_irq(pdev->irq, vfio_intx_handler,
1367 + irqflags, vdev->ctx[0].name, vdev);
1368 + if (ret) {
1369 ++ vdev->ctx[0].trigger = NULL;
1370 + kfree(vdev->ctx[0].name);
1371 + eventfd_ctx_put(trigger);
1372 + return ret;
1373 + }
1374 +
1375 +- vdev->ctx[0].trigger = trigger;
1376 +-
1377 + /*
1378 + * INTx disable will stick across the new irq setup,
1379 + * disable_irq won't.
1380 + */
1381 + spin_lock_irqsave(&vdev->irqlock, flags);
1382 +- if (!vdev->pci_2_3 && (vdev->ctx[0].masked || vdev->virq_disabled))
1383 ++ if (!vdev->pci_2_3 && vdev->ctx[0].masked)
1384 + disable_irq_nosync(pdev->irq);
1385 + spin_unlock_irqrestore(&vdev->irqlock, flags);
1386 +
1387 +diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
1388 +index 8af6414..38fcfff 100644
1389 +--- a/drivers/video/udlfb.c
1390 ++++ b/drivers/video/udlfb.c
1391 +@@ -647,7 +647,7 @@ static ssize_t dlfb_ops_write(struct fb_info *info, const char __user *buf,
1392 + result = fb_sys_write(info, buf, count, ppos);
1393 +
1394 + if (result > 0) {
1395 +- int start = max((int)(offset / info->fix.line_length) - 1, 0);
1396 ++ int start = max((int)(offset / info->fix.line_length), 0);
1397 + int lines = min((u32)((result / info->fix.line_length) + 1),
1398 + (u32)info->var.yres);
1399 +
1400 +diff --git a/drivers/video/via/via_clock.c b/drivers/video/via/via_clock.c
1401 +index af8f26b..db1e392 100644
1402 +--- a/drivers/video/via/via_clock.c
1403 ++++ b/drivers/video/via/via_clock.c
1404 +@@ -25,6 +25,7 @@
1405 +
1406 + #include <linux/kernel.h>
1407 + #include <linux/via-core.h>
1408 ++#include <asm/olpc.h>
1409 + #include "via_clock.h"
1410 + #include "global.h"
1411 + #include "debug.h"
1412 +@@ -289,6 +290,10 @@ static void dummy_set_pll(struct via_pll_config config)
1413 + printk(KERN_INFO "Using undocumented set PLL.\n%s", via_slap);
1414 + }
1415 +
1416 ++static void noop_set_clock_state(u8 state)
1417 ++{
1418 ++}
1419 ++
1420 + void via_clock_init(struct via_clock *clock, int gfx_chip)
1421 + {
1422 + switch (gfx_chip) {
1423 +@@ -346,4 +351,18 @@ void via_clock_init(struct via_clock *clock, int gfx_chip)
1424 + break;
1425 +
1426 + }
1427 ++
1428 ++ if (machine_is_olpc()) {
1429 ++ /* The OLPC XO-1.5 cannot suspend/resume reliably if the
1430 ++ * IGA1/IGA2 clocks are set as on or off (memory rot
1431 ++ * occasionally happens during suspend under such
1432 ++ * configurations).
1433 ++ *
1434 ++ * The only known stable scenario is to leave this bits as-is,
1435 ++ * which in their default states are documented to enable the
1436 ++ * clock only when it is needed.
1437 ++ */
1438 ++ clock->set_primary_clock_state = noop_set_clock_state;
1439 ++ clock->set_secondary_clock_state = noop_set_clock_state;
1440 ++ }
1441 + }
1442 +diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
1443 +index bce15cf..ca373d1 100644
1444 +--- a/drivers/xen/xenbus/xenbus_xs.c
1445 ++++ b/drivers/xen/xenbus/xenbus_xs.c
1446 +@@ -47,6 +47,7 @@
1447 + #include <xen/xenbus.h>
1448 + #include <xen/xen.h>
1449 + #include "xenbus_comms.h"
1450 ++#include <asm/xen/hypervisor.h>
1451 +
1452 + struct xs_stored_msg {
1453 + struct list_head list;
1454 +@@ -617,7 +618,24 @@ static struct xenbus_watch *find_watch(const char *token)
1455 +
1456 + return NULL;
1457 + }
1458 ++/*
1459 ++ * Certain older XenBus toolstack cannot handle reading values that are
1460 ++ * not populated. Some Xen 3.4 installation are incapable of doing this
1461 ++ * so if we are running on anything older than 4 do not attempt to read
1462 ++ * control/platform-feature-xs_reset_watches.
1463 ++ */
1464 ++static bool xen_strict_xenbus_quirk()
1465 ++{
1466 ++ uint32_t eax, ebx, ecx, edx, base;
1467 ++
1468 ++ base = xen_cpuid_base();
1469 ++ cpuid(base + 1, &eax, &ebx, &ecx, &edx);
1470 +
1471 ++ if ((eax >> 16) < 4)
1472 ++ return true;
1473 ++ return false;
1474 ++
1475 ++}
1476 + static void xs_reset_watches(void)
1477 + {
1478 + int err, supported = 0;
1479 +@@ -625,6 +643,9 @@ static void xs_reset_watches(void)
1480 + if (!xen_hvm_domain())
1481 + return;
1482 +
1483 ++ if (xen_strict_xenbus_quirk())
1484 ++ return;
1485 ++
1486 + err = xenbus_scanf(XBT_NIL, "control",
1487 + "platform-feature-xs_reset_watches", "%d", &supported);
1488 + if (err != 1 || !supported)
1489 +diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
1490 +index e7396cf..91b1165 100644
1491 +--- a/fs/autofs4/root.c
1492 ++++ b/fs/autofs4/root.c
1493 +@@ -392,10 +392,12 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
1494 + ino->flags |= AUTOFS_INF_PENDING;
1495 + spin_unlock(&sbi->fs_lock);
1496 + status = autofs4_mount_wait(dentry);
1497 +- if (status)
1498 +- return ERR_PTR(status);
1499 + spin_lock(&sbi->fs_lock);
1500 + ino->flags &= ~AUTOFS_INF_PENDING;
1501 ++ if (status) {
1502 ++ spin_unlock(&sbi->fs_lock);
1503 ++ return ERR_PTR(status);
1504 ++ }
1505 + }
1506 + done:
1507 + if (!(ino->flags & AUTOFS_INF_EXPIRING)) {
1508 +diff --git a/fs/ceph/export.c b/fs/ceph/export.c
1509 +index 8e1b60e..02ce909 100644
1510 +--- a/fs/ceph/export.c
1511 ++++ b/fs/ceph/export.c
1512 +@@ -99,7 +99,7 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
1513 + * FIXME: we should try harder by querying the mds for the ino.
1514 + */
1515 + static struct dentry *__fh_to_dentry(struct super_block *sb,
1516 +- struct ceph_nfs_fh *fh)
1517 ++ struct ceph_nfs_fh *fh, int fh_len)
1518 + {
1519 + struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
1520 + struct inode *inode;
1521 +@@ -107,6 +107,9 @@ static struct dentry *__fh_to_dentry(struct super_block *sb,
1522 + struct ceph_vino vino;
1523 + int err;
1524 +
1525 ++ if (fh_len < sizeof(*fh) / 4)
1526 ++ return ERR_PTR(-ESTALE);
1527 ++
1528 + dout("__fh_to_dentry %llx\n", fh->ino);
1529 + vino.ino = fh->ino;
1530 + vino.snap = CEPH_NOSNAP;
1531 +@@ -150,7 +153,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb,
1532 + * convert connectable fh to dentry
1533 + */
1534 + static struct dentry *__cfh_to_dentry(struct super_block *sb,
1535 +- struct ceph_nfs_confh *cfh)
1536 ++ struct ceph_nfs_confh *cfh, int fh_len)
1537 + {
1538 + struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
1539 + struct inode *inode;
1540 +@@ -158,6 +161,9 @@ static struct dentry *__cfh_to_dentry(struct super_block *sb,
1541 + struct ceph_vino vino;
1542 + int err;
1543 +
1544 ++ if (fh_len < sizeof(*cfh) / 4)
1545 ++ return ERR_PTR(-ESTALE);
1546 ++
1547 + dout("__cfh_to_dentry %llx (%llx/%x)\n",
1548 + cfh->ino, cfh->parent_ino, cfh->parent_name_hash);
1549 +
1550 +@@ -207,9 +213,11 @@ static struct dentry *ceph_fh_to_dentry(struct super_block *sb, struct fid *fid,
1551 + int fh_len, int fh_type)
1552 + {
1553 + if (fh_type == 1)
1554 +- return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw);
1555 ++ return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw,
1556 ++ fh_len);
1557 + else
1558 +- return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw);
1559 ++ return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw,
1560 ++ fh_len);
1561 + }
1562 +
1563 + /*
1564 +@@ -230,6 +238,8 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
1565 +
1566 + if (fh_type == 1)
1567 + return ERR_PTR(-ESTALE);
1568 ++ if (fh_len < sizeof(*cfh) / 4)
1569 ++ return ERR_PTR(-ESTALE);
1570 +
1571 + pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino,
1572 + cfh->parent_name_hash);
1573 +diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
1574 +index e8ed6d4..4767774 100644
1575 +--- a/fs/gfs2/export.c
1576 ++++ b/fs/gfs2/export.c
1577 +@@ -161,6 +161,8 @@ static struct dentry *gfs2_fh_to_dentry(struct super_block *sb, struct fid *fid,
1578 + case GFS2_SMALL_FH_SIZE:
1579 + case GFS2_LARGE_FH_SIZE:
1580 + case GFS2_OLD_FH_SIZE:
1581 ++ if (fh_len < GFS2_SMALL_FH_SIZE)
1582 ++ return NULL;
1583 + this.no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32;
1584 + this.no_formal_ino |= be32_to_cpu(fh[1]);
1585 + this.no_addr = ((u64)be32_to_cpu(fh[2])) << 32;
1586 +@@ -180,6 +182,8 @@ static struct dentry *gfs2_fh_to_parent(struct super_block *sb, struct fid *fid,
1587 + switch (fh_type) {
1588 + case GFS2_LARGE_FH_SIZE:
1589 + case GFS2_OLD_FH_SIZE:
1590 ++ if (fh_len < GFS2_LARGE_FH_SIZE)
1591 ++ return NULL;
1592 + parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32;
1593 + parent.no_formal_ino |= be32_to_cpu(fh[5]);
1594 + parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32;
1595 +diff --git a/fs/isofs/export.c b/fs/isofs/export.c
1596 +index 1d38044..2b4f235 100644
1597 +--- a/fs/isofs/export.c
1598 ++++ b/fs/isofs/export.c
1599 +@@ -175,7 +175,7 @@ static struct dentry *isofs_fh_to_parent(struct super_block *sb,
1600 + {
1601 + struct isofs_fid *ifid = (struct isofs_fid *)fid;
1602 +
1603 +- if (fh_type != 2)
1604 ++ if (fh_len < 2 || fh_type != 2)
1605 + return NULL;
1606 +
1607 + return isofs_export_iget(sb,
1608 +diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
1609 +index 52c15c7..86b39b1 100644
1610 +--- a/fs/jbd/commit.c
1611 ++++ b/fs/jbd/commit.c
1612 +@@ -86,7 +86,12 @@ nope:
1613 + static void release_data_buffer(struct buffer_head *bh)
1614 + {
1615 + if (buffer_freed(bh)) {
1616 ++ WARN_ON_ONCE(buffer_dirty(bh));
1617 + clear_buffer_freed(bh);
1618 ++ clear_buffer_mapped(bh);
1619 ++ clear_buffer_new(bh);
1620 ++ clear_buffer_req(bh);
1621 ++ bh->b_bdev = NULL;
1622 + release_buffer_page(bh);
1623 + } else
1624 + put_bh(bh);
1625 +@@ -866,17 +871,35 @@ restart_loop:
1626 + * there's no point in keeping a checkpoint record for
1627 + * it. */
1628 +
1629 +- /* A buffer which has been freed while still being
1630 +- * journaled by a previous transaction may end up still
1631 +- * being dirty here, but we want to avoid writing back
1632 +- * that buffer in the future after the "add to orphan"
1633 +- * operation been committed, That's not only a performance
1634 +- * gain, it also stops aliasing problems if the buffer is
1635 +- * left behind for writeback and gets reallocated for another
1636 +- * use in a different page. */
1637 +- if (buffer_freed(bh) && !jh->b_next_transaction) {
1638 +- clear_buffer_freed(bh);
1639 +- clear_buffer_jbddirty(bh);
1640 ++ /*
1641 ++ * A buffer which has been freed while still being journaled by
1642 ++ * a previous transaction.
1643 ++ */
1644 ++ if (buffer_freed(bh)) {
1645 ++ /*
1646 ++ * If the running transaction is the one containing
1647 ++ * "add to orphan" operation (b_next_transaction !=
1648 ++ * NULL), we have to wait for that transaction to
1649 ++ * commit before we can really get rid of the buffer.
1650 ++ * So just clear b_modified to not confuse transaction
1651 ++ * credit accounting and refile the buffer to
1652 ++ * BJ_Forget of the running transaction. If the just
1653 ++ * committed transaction contains "add to orphan"
1654 ++ * operation, we can completely invalidate the buffer
1655 ++ * now. We are rather throughout in that since the
1656 ++ * buffer may be still accessible when blocksize <
1657 ++ * pagesize and it is attached to the last partial
1658 ++ * page.
1659 ++ */
1660 ++ jh->b_modified = 0;
1661 ++ if (!jh->b_next_transaction) {
1662 ++ clear_buffer_freed(bh);
1663 ++ clear_buffer_jbddirty(bh);
1664 ++ clear_buffer_mapped(bh);
1665 ++ clear_buffer_new(bh);
1666 ++ clear_buffer_req(bh);
1667 ++ bh->b_bdev = NULL;
1668 ++ }
1669 + }
1670 +
1671 + if (buffer_jbddirty(bh)) {
1672 +diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
1673 +index febc10d..78b7f84 100644
1674 +--- a/fs/jbd/transaction.c
1675 ++++ b/fs/jbd/transaction.c
1676 +@@ -1843,15 +1843,16 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1677 + * We're outside-transaction here. Either or both of j_running_transaction
1678 + * and j_committing_transaction may be NULL.
1679 + */
1680 +-static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1681 ++static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
1682 ++ int partial_page)
1683 + {
1684 + transaction_t *transaction;
1685 + struct journal_head *jh;
1686 + int may_free = 1;
1687 +- int ret;
1688 +
1689 + BUFFER_TRACE(bh, "entry");
1690 +
1691 ++retry:
1692 + /*
1693 + * It is safe to proceed here without the j_list_lock because the
1694 + * buffers cannot be stolen by try_to_free_buffers as long as we are
1695 +@@ -1879,10 +1880,18 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1696 + * clear the buffer dirty bit at latest at the moment when the
1697 + * transaction marking the buffer as freed in the filesystem
1698 + * structures is committed because from that moment on the
1699 +- * buffer can be reallocated and used by a different page.
1700 ++ * block can be reallocated and used by a different page.
1701 + * Since the block hasn't been freed yet but the inode has
1702 + * already been added to orphan list, it is safe for us to add
1703 + * the buffer to BJ_Forget list of the newest transaction.
1704 ++ *
1705 ++ * Also we have to clear buffer_mapped flag of a truncated buffer
1706 ++ * because the buffer_head may be attached to the page straddling
1707 ++ * i_size (can happen only when blocksize < pagesize) and thus the
1708 ++ * buffer_head can be reused when the file is extended again. So we end
1709 ++ * up keeping around invalidated buffers attached to transactions'
1710 ++ * BJ_Forget list just to stop checkpointing code from cleaning up
1711 ++ * the transaction this buffer was modified in.
1712 + */
1713 + transaction = jh->b_transaction;
1714 + if (transaction == NULL) {
1715 +@@ -1909,13 +1918,9 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1716 + * committed, the buffer won't be needed any
1717 + * longer. */
1718 + JBUFFER_TRACE(jh, "checkpointed: add to BJ_Forget");
1719 +- ret = __dispose_buffer(jh,
1720 ++ may_free = __dispose_buffer(jh,
1721 + journal->j_running_transaction);
1722 +- journal_put_journal_head(jh);
1723 +- spin_unlock(&journal->j_list_lock);
1724 +- jbd_unlock_bh_state(bh);
1725 +- spin_unlock(&journal->j_state_lock);
1726 +- return ret;
1727 ++ goto zap_buffer;
1728 + } else {
1729 + /* There is no currently-running transaction. So the
1730 + * orphan record which we wrote for this file must have
1731 +@@ -1923,13 +1928,9 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1732 + * the committing transaction, if it exists. */
1733 + if (journal->j_committing_transaction) {
1734 + JBUFFER_TRACE(jh, "give to committing trans");
1735 +- ret = __dispose_buffer(jh,
1736 ++ may_free = __dispose_buffer(jh,
1737 + journal->j_committing_transaction);
1738 +- journal_put_journal_head(jh);
1739 +- spin_unlock(&journal->j_list_lock);
1740 +- jbd_unlock_bh_state(bh);
1741 +- spin_unlock(&journal->j_state_lock);
1742 +- return ret;
1743 ++ goto zap_buffer;
1744 + } else {
1745 + /* The orphan record's transaction has
1746 + * committed. We can cleanse this buffer */
1747 +@@ -1950,10 +1951,24 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1748 + }
1749 + /*
1750 + * The buffer is committing, we simply cannot touch
1751 +- * it. So we just set j_next_transaction to the
1752 +- * running transaction (if there is one) and mark
1753 +- * buffer as freed so that commit code knows it should
1754 +- * clear dirty bits when it is done with the buffer.
1755 ++ * it. If the page is straddling i_size we have to wait
1756 ++ * for commit and try again.
1757 ++ */
1758 ++ if (partial_page) {
1759 ++ tid_t tid = journal->j_committing_transaction->t_tid;
1760 ++
1761 ++ journal_put_journal_head(jh);
1762 ++ spin_unlock(&journal->j_list_lock);
1763 ++ jbd_unlock_bh_state(bh);
1764 ++ spin_unlock(&journal->j_state_lock);
1765 ++ log_wait_commit(journal, tid);
1766 ++ goto retry;
1767 ++ }
1768 ++ /*
1769 ++ * OK, buffer won't be reachable after truncate. We just set
1770 ++ * j_next_transaction to the running transaction (if there is
1771 ++ * one) and mark buffer as freed so that commit code knows it
1772 ++ * should clear dirty bits when it is done with the buffer.
1773 + */
1774 + set_buffer_freed(bh);
1775 + if (journal->j_running_transaction && buffer_jbddirty(bh))
1776 +@@ -1976,6 +1991,14 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1777 + }
1778 +
1779 + zap_buffer:
1780 ++ /*
1781 ++ * This is tricky. Although the buffer is truncated, it may be reused
1782 ++ * if blocksize < pagesize and it is attached to the page straddling
1783 ++ * EOF. Since the buffer might have been added to BJ_Forget list of the
1784 ++ * running transaction, journal_get_write_access() won't clear
1785 ++ * b_modified and credit accounting gets confused. So clear b_modified
1786 ++ * here. */
1787 ++ jh->b_modified = 0;
1788 + journal_put_journal_head(jh);
1789 + zap_buffer_no_jh:
1790 + spin_unlock(&journal->j_list_lock);
1791 +@@ -2024,7 +2047,8 @@ void journal_invalidatepage(journal_t *journal,
1792 + if (offset <= curr_off) {
1793 + /* This block is wholly outside the truncation point */
1794 + lock_buffer(bh);
1795 +- may_free &= journal_unmap_buffer(journal, bh);
1796 ++ may_free &= journal_unmap_buffer(journal, bh,
1797 ++ offset > 0);
1798 + unlock_buffer(bh);
1799 + }
1800 + curr_off = next_off;
1801 +diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
1802 +index 7ef14b3..e4fb3ba 100644
1803 +--- a/fs/lockd/mon.c
1804 ++++ b/fs/lockd/mon.c
1805 +@@ -7,7 +7,6 @@
1806 + */
1807 +
1808 + #include <linux/types.h>
1809 +-#include <linux/utsname.h>
1810 + #include <linux/kernel.h>
1811 + #include <linux/ktime.h>
1812 + #include <linux/slab.h>
1813 +@@ -19,6 +18,8 @@
1814 +
1815 + #include <asm/unaligned.h>
1816 +
1817 ++#include "netns.h"
1818 ++
1819 + #define NLMDBG_FACILITY NLMDBG_MONITOR
1820 + #define NSM_PROGRAM 100024
1821 + #define NSM_VERSION 1
1822 +@@ -40,6 +41,7 @@ struct nsm_args {
1823 + u32 proc;
1824 +
1825 + char *mon_name;
1826 ++ char *nodename;
1827 + };
1828 +
1829 + struct nsm_res {
1830 +@@ -70,7 +72,7 @@ static struct rpc_clnt *nsm_create(struct net *net)
1831 + };
1832 + struct rpc_create_args args = {
1833 + .net = net,
1834 +- .protocol = XPRT_TRANSPORT_UDP,
1835 ++ .protocol = XPRT_TRANSPORT_TCP,
1836 + .address = (struct sockaddr *)&sin,
1837 + .addrsize = sizeof(sin),
1838 + .servername = "rpc.statd",
1839 +@@ -83,10 +85,54 @@ static struct rpc_clnt *nsm_create(struct net *net)
1840 + return rpc_create(&args);
1841 + }
1842 +
1843 +-static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
1844 +- struct net *net)
1845 ++static struct rpc_clnt *nsm_client_get(struct net *net)
1846 + {
1847 ++ static DEFINE_MUTEX(nsm_create_mutex);
1848 + struct rpc_clnt *clnt;
1849 ++ struct lockd_net *ln = net_generic(net, lockd_net_id);
1850 ++
1851 ++ spin_lock(&ln->nsm_clnt_lock);
1852 ++ if (ln->nsm_users) {
1853 ++ ln->nsm_users++;
1854 ++ clnt = ln->nsm_clnt;
1855 ++ spin_unlock(&ln->nsm_clnt_lock);
1856 ++ goto out;
1857 ++ }
1858 ++ spin_unlock(&ln->nsm_clnt_lock);
1859 ++
1860 ++ mutex_lock(&nsm_create_mutex);
1861 ++ clnt = nsm_create(net);
1862 ++ if (!IS_ERR(clnt)) {
1863 ++ ln->nsm_clnt = clnt;
1864 ++ smp_wmb();
1865 ++ ln->nsm_users = 1;
1866 ++ }
1867 ++ mutex_unlock(&nsm_create_mutex);
1868 ++out:
1869 ++ return clnt;
1870 ++}
1871 ++
1872 ++static void nsm_client_put(struct net *net)
1873 ++{
1874 ++ struct lockd_net *ln = net_generic(net, lockd_net_id);
1875 ++ struct rpc_clnt *clnt = ln->nsm_clnt;
1876 ++ int shutdown = 0;
1877 ++
1878 ++ spin_lock(&ln->nsm_clnt_lock);
1879 ++ if (ln->nsm_users) {
1880 ++ if (--ln->nsm_users)
1881 ++ ln->nsm_clnt = NULL;
1882 ++ shutdown = !ln->nsm_users;
1883 ++ }
1884 ++ spin_unlock(&ln->nsm_clnt_lock);
1885 ++
1886 ++ if (shutdown)
1887 ++ rpc_shutdown_client(clnt);
1888 ++}
1889 ++
1890 ++static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
1891 ++ struct rpc_clnt *clnt)
1892 ++{
1893 + int status;
1894 + struct nsm_args args = {
1895 + .priv = &nsm->sm_priv,
1896 +@@ -94,31 +140,24 @@ static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
1897 + .vers = 3,
1898 + .proc = NLMPROC_NSM_NOTIFY,
1899 + .mon_name = nsm->sm_mon_name,
1900 ++ .nodename = clnt->cl_nodename,
1901 + };
1902 + struct rpc_message msg = {
1903 + .rpc_argp = &args,
1904 + .rpc_resp = res,
1905 + };
1906 +
1907 +- clnt = nsm_create(net);
1908 +- if (IS_ERR(clnt)) {
1909 +- status = PTR_ERR(clnt);
1910 +- dprintk("lockd: failed to create NSM upcall transport, "
1911 +- "status=%d\n", status);
1912 +- goto out;
1913 +- }
1914 ++ BUG_ON(clnt == NULL);
1915 +
1916 + memset(res, 0, sizeof(*res));
1917 +
1918 + msg.rpc_proc = &clnt->cl_procinfo[proc];
1919 +- status = rpc_call_sync(clnt, &msg, 0);
1920 ++ status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTCONN);
1921 + if (status < 0)
1922 + dprintk("lockd: NSM upcall RPC failed, status=%d\n",
1923 + status);
1924 + else
1925 + status = 0;
1926 +- rpc_shutdown_client(clnt);
1927 +- out:
1928 + return status;
1929 + }
1930 +
1931 +@@ -138,6 +177,7 @@ int nsm_monitor(const struct nlm_host *host)
1932 + struct nsm_handle *nsm = host->h_nsmhandle;
1933 + struct nsm_res res;
1934 + int status;
1935 ++ struct rpc_clnt *clnt;
1936 +
1937 + dprintk("lockd: nsm_monitor(%s)\n", nsm->sm_name);
1938 +
1939 +@@ -150,7 +190,15 @@ int nsm_monitor(const struct nlm_host *host)
1940 + */
1941 + nsm->sm_mon_name = nsm_use_hostnames ? nsm->sm_name : nsm->sm_addrbuf;
1942 +
1943 +- status = nsm_mon_unmon(nsm, NSMPROC_MON, &res, host->net);
1944 ++ clnt = nsm_client_get(host->net);
1945 ++ if (IS_ERR(clnt)) {
1946 ++ status = PTR_ERR(clnt);
1947 ++ dprintk("lockd: failed to create NSM upcall transport, "
1948 ++ "status=%d, net=%p\n", status, host->net);
1949 ++ return status;
1950 ++ }
1951 ++
1952 ++ status = nsm_mon_unmon(nsm, NSMPROC_MON, &res, clnt);
1953 + if (unlikely(res.status != 0))
1954 + status = -EIO;
1955 + if (unlikely(status < 0)) {
1956 +@@ -182,9 +230,11 @@ void nsm_unmonitor(const struct nlm_host *host)
1957 +
1958 + if (atomic_read(&nsm->sm_count) == 1
1959 + && nsm->sm_monitored && !nsm->sm_sticky) {
1960 ++ struct lockd_net *ln = net_generic(host->net, lockd_net_id);
1961 ++
1962 + dprintk("lockd: nsm_unmonitor(%s)\n", nsm->sm_name);
1963 +
1964 +- status = nsm_mon_unmon(nsm, NSMPROC_UNMON, &res, host->net);
1965 ++ status = nsm_mon_unmon(nsm, NSMPROC_UNMON, &res, ln->nsm_clnt);
1966 + if (res.status != 0)
1967 + status = -EIO;
1968 + if (status < 0)
1969 +@@ -192,6 +242,8 @@ void nsm_unmonitor(const struct nlm_host *host)
1970 + nsm->sm_name);
1971 + else
1972 + nsm->sm_monitored = 0;
1973 ++
1974 ++ nsm_client_put(host->net);
1975 + }
1976 + }
1977 +
1978 +@@ -430,7 +482,7 @@ static void encode_my_id(struct xdr_stream *xdr, const struct nsm_args *argp)
1979 + {
1980 + __be32 *p;
1981 +
1982 +- encode_nsm_string(xdr, utsname()->nodename);
1983 ++ encode_nsm_string(xdr, argp->nodename);
1984 + p = xdr_reserve_space(xdr, 4 + 4 + 4);
1985 + *p++ = cpu_to_be32(argp->prog);
1986 + *p++ = cpu_to_be32(argp->vers);
1987 +diff --git a/fs/lockd/netns.h b/fs/lockd/netns.h
1988 +index 4eee248..5010b55 100644
1989 +--- a/fs/lockd/netns.h
1990 ++++ b/fs/lockd/netns.h
1991 +@@ -12,6 +12,10 @@ struct lockd_net {
1992 + struct delayed_work grace_period_end;
1993 + struct lock_manager lockd_manager;
1994 + struct list_head grace_list;
1995 ++
1996 ++ spinlock_t nsm_clnt_lock;
1997 ++ unsigned int nsm_users;
1998 ++ struct rpc_clnt *nsm_clnt;
1999 + };
2000 +
2001 + extern int lockd_net_id;
2002 +diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
2003 +index 31a63f8..7e35587 100644
2004 +--- a/fs/lockd/svc.c
2005 ++++ b/fs/lockd/svc.c
2006 +@@ -596,6 +596,7 @@ static int lockd_init_net(struct net *net)
2007 +
2008 + INIT_DELAYED_WORK(&ln->grace_period_end, grace_ender);
2009 + INIT_LIST_HEAD(&ln->grace_list);
2010 ++ spin_lock_init(&ln->nsm_clnt_lock);
2011 + return 0;
2012 + }
2013 +
2014 +diff --git a/fs/namei.c b/fs/namei.c
2015 +index dd1ed1b..81bd546 100644
2016 +--- a/fs/namei.c
2017 ++++ b/fs/namei.c
2018 +@@ -692,9 +692,9 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
2019 + if (parent->i_uid == inode->i_uid)
2020 + return 0;
2021 +
2022 ++ audit_log_link_denied("follow_link", link);
2023 + path_put_conditional(link, nd);
2024 + path_put(&nd->path);
2025 +- audit_log_link_denied("follow_link", link);
2026 + return -EACCES;
2027 + }
2028 +
2029 +diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
2030 +index dd392ed..f3d16ad 100644
2031 +--- a/fs/nfs/blocklayout/blocklayout.c
2032 ++++ b/fs/nfs/blocklayout/blocklayout.c
2033 +@@ -162,25 +162,39 @@ static struct bio *bl_alloc_init_bio(int npg, sector_t isect,
2034 + return bio;
2035 + }
2036 +
2037 +-static struct bio *bl_add_page_to_bio(struct bio *bio, int npg, int rw,
2038 ++static struct bio *do_add_page_to_bio(struct bio *bio, int npg, int rw,
2039 + sector_t isect, struct page *page,
2040 + struct pnfs_block_extent *be,
2041 + void (*end_io)(struct bio *, int err),
2042 +- struct parallel_io *par)
2043 ++ struct parallel_io *par,
2044 ++ unsigned int offset, int len)
2045 + {
2046 ++ isect = isect + (offset >> SECTOR_SHIFT);
2047 ++ dprintk("%s: npg %d rw %d isect %llu offset %u len %d\n", __func__,
2048 ++ npg, rw, (unsigned long long)isect, offset, len);
2049 + retry:
2050 + if (!bio) {
2051 + bio = bl_alloc_init_bio(npg, isect, be, end_io, par);
2052 + if (!bio)
2053 + return ERR_PTR(-ENOMEM);
2054 + }
2055 +- if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
2056 ++ if (bio_add_page(bio, page, len, offset) < len) {
2057 + bio = bl_submit_bio(rw, bio);
2058 + goto retry;
2059 + }
2060 + return bio;
2061 + }
2062 +
2063 ++static struct bio *bl_add_page_to_bio(struct bio *bio, int npg, int rw,
2064 ++ sector_t isect, struct page *page,
2065 ++ struct pnfs_block_extent *be,
2066 ++ void (*end_io)(struct bio *, int err),
2067 ++ struct parallel_io *par)
2068 ++{
2069 ++ return do_add_page_to_bio(bio, npg, rw, isect, page, be,
2070 ++ end_io, par, 0, PAGE_CACHE_SIZE);
2071 ++}
2072 ++
2073 + /* This is basically copied from mpage_end_io_read */
2074 + static void bl_end_io_read(struct bio *bio, int err)
2075 + {
2076 +@@ -461,6 +475,106 @@ map_block(struct buffer_head *bh, sector_t isect, struct pnfs_block_extent *be)
2077 + return;
2078 + }
2079 +
2080 ++static void
2081 ++bl_read_single_end_io(struct bio *bio, int error)
2082 ++{
2083 ++ struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
2084 ++ struct page *page = bvec->bv_page;
2085 ++
2086 ++ /* Only one page in bvec */
2087 ++ unlock_page(page);
2088 ++}
2089 ++
2090 ++static int
2091 ++bl_do_readpage_sync(struct page *page, struct pnfs_block_extent *be,
2092 ++ unsigned int offset, unsigned int len)
2093 ++{
2094 ++ struct bio *bio;
2095 ++ struct page *shadow_page;
2096 ++ sector_t isect;
2097 ++ char *kaddr, *kshadow_addr;
2098 ++ int ret = 0;
2099 ++
2100 ++ dprintk("%s: offset %u len %u\n", __func__, offset, len);
2101 ++
2102 ++ shadow_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
2103 ++ if (shadow_page == NULL)
2104 ++ return -ENOMEM;
2105 ++
2106 ++ bio = bio_alloc(GFP_NOIO, 1);
2107 ++ if (bio == NULL)
2108 ++ return -ENOMEM;
2109 ++
2110 ++ isect = (page->index << PAGE_CACHE_SECTOR_SHIFT) +
2111 ++ (offset / SECTOR_SIZE);
2112 ++
2113 ++ bio->bi_sector = isect - be->be_f_offset + be->be_v_offset;
2114 ++ bio->bi_bdev = be->be_mdev;
2115 ++ bio->bi_end_io = bl_read_single_end_io;
2116 ++
2117 ++ lock_page(shadow_page);
2118 ++ if (bio_add_page(bio, shadow_page,
2119 ++ SECTOR_SIZE, round_down(offset, SECTOR_SIZE)) == 0) {
2120 ++ unlock_page(shadow_page);
2121 ++ bio_put(bio);
2122 ++ return -EIO;
2123 ++ }
2124 ++
2125 ++ submit_bio(READ, bio);
2126 ++ wait_on_page_locked(shadow_page);
2127 ++ if (unlikely(!test_bit(BIO_UPTODATE, &bio->bi_flags))) {
2128 ++ ret = -EIO;
2129 ++ } else {
2130 ++ kaddr = kmap_atomic(page);
2131 ++ kshadow_addr = kmap_atomic(shadow_page);
2132 ++ memcpy(kaddr + offset, kshadow_addr + offset, len);
2133 ++ kunmap_atomic(kshadow_addr);
2134 ++ kunmap_atomic(kaddr);
2135 ++ }
2136 ++ __free_page(shadow_page);
2137 ++ bio_put(bio);
2138 ++
2139 ++ return ret;
2140 ++}
2141 ++
2142 ++static int
2143 ++bl_read_partial_page_sync(struct page *page, struct pnfs_block_extent *be,
2144 ++ unsigned int dirty_offset, unsigned int dirty_len,
2145 ++ bool full_page)
2146 ++{
2147 ++ int ret = 0;
2148 ++ unsigned int start, end;
2149 ++
2150 ++ if (full_page) {
2151 ++ start = 0;
2152 ++ end = PAGE_CACHE_SIZE;
2153 ++ } else {
2154 ++ start = round_down(dirty_offset, SECTOR_SIZE);
2155 ++ end = round_up(dirty_offset + dirty_len, SECTOR_SIZE);
2156 ++ }
2157 ++
2158 ++ dprintk("%s: offset %u len %d\n", __func__, dirty_offset, dirty_len);
2159 ++ if (!be) {
2160 ++ zero_user_segments(page, start, dirty_offset,
2161 ++ dirty_offset + dirty_len, end);
2162 ++ if (start == 0 && end == PAGE_CACHE_SIZE &&
2163 ++ trylock_page(page)) {
2164 ++ SetPageUptodate(page);
2165 ++ unlock_page(page);
2166 ++ }
2167 ++ return ret;
2168 ++ }
2169 ++
2170 ++ if (start != dirty_offset)
2171 ++ ret = bl_do_readpage_sync(page, be, start, dirty_offset - start);
2172 ++
2173 ++ if (!ret && (dirty_offset + dirty_len < end))
2174 ++ ret = bl_do_readpage_sync(page, be, dirty_offset + dirty_len,
2175 ++ end - dirty_offset - dirty_len);
2176 ++
2177 ++ return ret;
2178 ++}
2179 ++
2180 + /* Given an unmapped page, zero it or read in page for COW, page is locked
2181 + * by caller.
2182 + */
2183 +@@ -494,7 +608,6 @@ init_page_for_write(struct page *page, struct pnfs_block_extent *cow_read)
2184 + SetPageUptodate(page);
2185 +
2186 + cleanup:
2187 +- bl_put_extent(cow_read);
2188 + if (bh)
2189 + free_buffer_head(bh);
2190 + if (ret) {
2191 +@@ -566,6 +679,7 @@ bl_write_pagelist(struct nfs_write_data *wdata, int sync)
2192 + struct parallel_io *par = NULL;
2193 + loff_t offset = wdata->args.offset;
2194 + size_t count = wdata->args.count;
2195 ++ unsigned int pg_offset, pg_len, saved_len;
2196 + struct page **pages = wdata->args.pages;
2197 + struct page *page;
2198 + pgoff_t index;
2199 +@@ -674,10 +788,11 @@ next_page:
2200 + if (!extent_length) {
2201 + /* We've used up the previous extent */
2202 + bl_put_extent(be);
2203 ++ bl_put_extent(cow_read);
2204 + bio = bl_submit_bio(WRITE, bio);
2205 + /* Get the next one */
2206 + be = bl_find_get_extent(BLK_LSEG2EXT(header->lseg),
2207 +- isect, NULL);
2208 ++ isect, &cow_read);
2209 + if (!be || !is_writable(be, isect)) {
2210 + header->pnfs_error = -EINVAL;
2211 + goto out;
2212 +@@ -694,7 +809,26 @@ next_page:
2213 + extent_length = be->be_length -
2214 + (isect - be->be_f_offset);
2215 + }
2216 +- if (be->be_state == PNFS_BLOCK_INVALID_DATA) {
2217 ++
2218 ++ dprintk("%s offset %lld count %Zu\n", __func__, offset, count);
2219 ++ pg_offset = offset & ~PAGE_CACHE_MASK;
2220 ++ if (pg_offset + count > PAGE_CACHE_SIZE)
2221 ++ pg_len = PAGE_CACHE_SIZE - pg_offset;
2222 ++ else
2223 ++ pg_len = count;
2224 ++
2225 ++ saved_len = pg_len;
2226 ++ if (be->be_state == PNFS_BLOCK_INVALID_DATA &&
2227 ++ !bl_is_sector_init(be->be_inval, isect)) {
2228 ++ ret = bl_read_partial_page_sync(pages[i], cow_read,
2229 ++ pg_offset, pg_len, true);
2230 ++ if (ret) {
2231 ++ dprintk("%s bl_read_partial_page_sync fail %d\n",
2232 ++ __func__, ret);
2233 ++ header->pnfs_error = ret;
2234 ++ goto out;
2235 ++ }
2236 ++
2237 + ret = bl_mark_sectors_init(be->be_inval, isect,
2238 + PAGE_CACHE_SECTORS);
2239 + if (unlikely(ret)) {
2240 +@@ -703,15 +837,35 @@ next_page:
2241 + header->pnfs_error = ret;
2242 + goto out;
2243 + }
2244 ++
2245 ++ /* Expand to full page write */
2246 ++ pg_offset = 0;
2247 ++ pg_len = PAGE_CACHE_SIZE;
2248 ++ } else if ((pg_offset & (SECTOR_SIZE - 1)) ||
2249 ++ (pg_len & (SECTOR_SIZE - 1))){
2250 ++ /* ahh, nasty case. We have to do sync full sector
2251 ++ * read-modify-write cycles.
2252 ++ */
2253 ++ unsigned int saved_offset = pg_offset;
2254 ++ ret = bl_read_partial_page_sync(pages[i], be, pg_offset,
2255 ++ pg_len, false);
2256 ++ pg_offset = round_down(pg_offset, SECTOR_SIZE);
2257 ++ pg_len = round_up(saved_offset + pg_len, SECTOR_SIZE)
2258 ++ - pg_offset;
2259 + }
2260 +- bio = bl_add_page_to_bio(bio, wdata->pages.npages - i, WRITE,
2261 ++
2262 ++
2263 ++ bio = do_add_page_to_bio(bio, wdata->pages.npages - i, WRITE,
2264 + isect, pages[i], be,
2265 +- bl_end_io_write, par);
2266 ++ bl_end_io_write, par,
2267 ++ pg_offset, pg_len);
2268 + if (IS_ERR(bio)) {
2269 + header->pnfs_error = PTR_ERR(bio);
2270 + bio = NULL;
2271 + goto out;
2272 + }
2273 ++ offset += saved_len;
2274 ++ count -= saved_len;
2275 + isect += PAGE_CACHE_SECTORS;
2276 + last_isect = isect;
2277 + extent_length -= PAGE_CACHE_SECTORS;
2278 +@@ -729,17 +883,16 @@ next_page:
2279 + }
2280 +
2281 + write_done:
2282 +- wdata->res.count = (last_isect << SECTOR_SHIFT) - (offset);
2283 +- if (count < wdata->res.count) {
2284 +- wdata->res.count = count;
2285 +- }
2286 ++ wdata->res.count = wdata->args.count;
2287 + out:
2288 + bl_put_extent(be);
2289 ++ bl_put_extent(cow_read);
2290 + bl_submit_bio(WRITE, bio);
2291 + put_parallel(par);
2292 + return PNFS_ATTEMPTED;
2293 + out_mds:
2294 + bl_put_extent(be);
2295 ++ bl_put_extent(cow_read);
2296 + kfree(par);
2297 + return PNFS_NOT_ATTEMPTED;
2298 + }
2299 +diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
2300 +index 0335069..39bb51a 100644
2301 +--- a/fs/nfs/blocklayout/blocklayout.h
2302 ++++ b/fs/nfs/blocklayout/blocklayout.h
2303 +@@ -41,6 +41,7 @@
2304 +
2305 + #define PAGE_CACHE_SECTORS (PAGE_CACHE_SIZE >> SECTOR_SHIFT)
2306 + #define PAGE_CACHE_SECTOR_SHIFT (PAGE_CACHE_SHIFT - SECTOR_SHIFT)
2307 ++#define SECTOR_SIZE (1 << SECTOR_SHIFT)
2308 +
2309 + struct block_mount_id {
2310 + spinlock_t bm_lock; /* protects list */
2311 +diff --git a/fs/nfs/client.c b/fs/nfs/client.c
2312 +index 9969444..0e7cd89 100644
2313 +--- a/fs/nfs/client.c
2314 ++++ b/fs/nfs/client.c
2315 +@@ -855,7 +855,6 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
2316 + if (server->wsize > NFS_MAX_FILE_IO_SIZE)
2317 + server->wsize = NFS_MAX_FILE_IO_SIZE;
2318 + server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
2319 +- server->pnfs_blksize = fsinfo->blksize;
2320 +
2321 + server->wtmult = nfs_block_bits(fsinfo->wtmult, NULL);
2322 +
2323 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2324 +index 1e50326..d5a0cf1 100644
2325 +--- a/fs/nfs/nfs4proc.c
2326 ++++ b/fs/nfs/nfs4proc.c
2327 +@@ -1774,7 +1774,11 @@ static void nfs41_clear_delegation_stateid(struct nfs4_state *state)
2328 + * informs us the stateid is unrecognized. */
2329 + if (status != -NFS4ERR_BAD_STATEID)
2330 + nfs41_free_stateid(server, stateid);
2331 ++ nfs_remove_bad_delegation(state->inode);
2332 +
2333 ++ write_seqlock(&state->seqlock);
2334 ++ nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2335 ++ write_sequnlock(&state->seqlock);
2336 + clear_bit(NFS_DELEGATED_STATE, &state->flags);
2337 + }
2338 + }
2339 +@@ -3362,8 +3366,11 @@ static int nfs4_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, s
2340 +
2341 + nfs_fattr_init(fsinfo->fattr);
2342 + error = nfs4_do_fsinfo(server, fhandle, fsinfo);
2343 +- if (error == 0)
2344 ++ if (error == 0) {
2345 ++ /* block layout checks this! */
2346 ++ server->pnfs_blksize = fsinfo->blksize;
2347 + set_pnfs_layoutdriver(server, fhandle, fsinfo->layouttype);
2348 ++ }
2349 +
2350 + return error;
2351 + }
2352 +diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
2353 +index fdc91a6..ccfe0d0 100644
2354 +--- a/fs/nfsd/nfs4idmap.c
2355 ++++ b/fs/nfsd/nfs4idmap.c
2356 +@@ -598,7 +598,7 @@ numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namel
2357 + /* Just to make sure it's null-terminated: */
2358 + memcpy(buf, name, namelen);
2359 + buf[namelen] = '\0';
2360 +- ret = kstrtouint(name, 10, id);
2361 ++ ret = kstrtouint(buf, 10, id);
2362 + return ret == 0;
2363 + }
2364 +
2365 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
2366 +index cc894ed..5b3224c 100644
2367 +--- a/fs/nfsd/nfs4state.c
2368 ++++ b/fs/nfsd/nfs4state.c
2369 +@@ -1223,10 +1223,26 @@ static bool groups_equal(struct group_info *g1, struct group_info *g2)
2370 + return true;
2371 + }
2372 +
2373 ++/*
2374 ++ * RFC 3530 language requires clid_inuse be returned when the
2375 ++ * "principal" associated with a requests differs from that previously
2376 ++ * used. We use uid, gid's, and gss principal string as our best
2377 ++ * approximation. We also don't want to allow non-gss use of a client
2378 ++ * established using gss: in theory cr_principal should catch that
2379 ++ * change, but in practice cr_principal can be null even in the gss case
2380 ++ * since gssd doesn't always pass down a principal string.
2381 ++ */
2382 ++static bool is_gss_cred(struct svc_cred *cr)
2383 ++{
2384 ++ /* Is cr_flavor one of the gss "pseudoflavors"?: */
2385 ++ return (cr->cr_flavor > RPC_AUTH_MAXFLAVOR);
2386 ++}
2387 ++
2388 ++
2389 + static bool
2390 + same_creds(struct svc_cred *cr1, struct svc_cred *cr2)
2391 + {
2392 +- if ((cr1->cr_flavor != cr2->cr_flavor)
2393 ++ if ((is_gss_cred(cr1) != is_gss_cred(cr2))
2394 + || (cr1->cr_uid != cr2->cr_uid)
2395 + || (cr1->cr_gid != cr2->cr_gid)
2396 + || !groups_equal(cr1->cr_group_info, cr2->cr_group_info))
2397 +@@ -3766,6 +3782,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2398 + memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
2399 +
2400 + nfsd4_close_open_stateid(stp);
2401 ++ release_last_closed_stateid(oo);
2402 + oo->oo_last_closed_stid = stp;
2403 +
2404 + if (list_empty(&oo->oo_owner.so_stateids)) {
2405 +diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
2406 +index 855da58..63ce6be 100644
2407 +--- a/fs/reiserfs/inode.c
2408 ++++ b/fs/reiserfs/inode.c
2409 +@@ -1573,8 +1573,10 @@ struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
2410 + reiserfs_warning(sb, "reiserfs-13077",
2411 + "nfsd/reiserfs, fhtype=%d, len=%d - odd",
2412 + fh_type, fh_len);
2413 +- fh_type = 5;
2414 ++ fh_type = fh_len;
2415 + }
2416 ++ if (fh_len < 2)
2417 ++ return NULL;
2418 +
2419 + return reiserfs_get_dentry(sb, fid->raw[0], fid->raw[1],
2420 + (fh_type == 3 || fh_type >= 5) ? fid->raw[2] : 0);
2421 +@@ -1583,6 +1585,8 @@ struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
2422 + struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid,
2423 + int fh_len, int fh_type)
2424 + {
2425 ++ if (fh_type > fh_len)
2426 ++ fh_type = fh_len;
2427 + if (fh_type < 4)
2428 + return NULL;
2429 +
2430 +diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
2431 +index 4267922..8c6d1d7 100644
2432 +--- a/fs/xfs/xfs_export.c
2433 ++++ b/fs/xfs/xfs_export.c
2434 +@@ -189,6 +189,9 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid,
2435 + struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid;
2436 + struct inode *inode = NULL;
2437 +
2438 ++ if (fh_len < xfs_fileid_length(fileid_type))
2439 ++ return NULL;
2440 ++
2441 + switch (fileid_type) {
2442 + case FILEID_INO32_GEN_PARENT:
2443 + inode = xfs_nfs_get_inode(sb, fid->i32.parent_ino,
2444 +diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
2445 +index 57977c6..e5cf2c8 100644
2446 +--- a/include/linux/mtd/nand.h
2447 ++++ b/include/linux/mtd/nand.h
2448 +@@ -212,9 +212,6 @@ typedef enum {
2449 + #define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
2450 + && (chip->page_shift > 9))
2451 +
2452 +-/* Mask to zero out the chip options, which come from the id table */
2453 +-#define NAND_CHIPOPTIONS_MSK 0x0000ffff
2454 +-
2455 + /* Non chip related options */
2456 + /* This option skips the bbt scan during initialization. */
2457 + #define NAND_SKIP_BBTSCAN 0x00010000
2458 +diff --git a/kernel/audit.c b/kernel/audit.c
2459 +index ea3b7b6..a8c84be 100644
2460 +--- a/kernel/audit.c
2461 ++++ b/kernel/audit.c
2462 +@@ -1466,6 +1466,8 @@ void audit_log_link_denied(const char *operation, struct path *link)
2463 +
2464 + ab = audit_log_start(current->audit_context, GFP_KERNEL,
2465 + AUDIT_ANOM_LINK);
2466 ++ if (!ab)
2467 ++ return;
2468 + audit_log_format(ab, "op=%s action=denied", operation);
2469 + audit_log_format(ab, " pid=%d comm=", current->pid);
2470 + audit_log_untrustedstring(ab, current->comm);
2471 +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
2472 +index 0a69d2a..14ff484 100644
2473 +--- a/kernel/debug/kdb/kdb_io.c
2474 ++++ b/kernel/debug/kdb/kdb_io.c
2475 +@@ -552,6 +552,7 @@ int vkdb_printf(const char *fmt, va_list ap)
2476 + {
2477 + int diag;
2478 + int linecount;
2479 ++ int colcount;
2480 + int logging, saved_loglevel = 0;
2481 + int saved_trap_printk;
2482 + int got_printf_lock = 0;
2483 +@@ -584,6 +585,10 @@ int vkdb_printf(const char *fmt, va_list ap)
2484 + if (diag || linecount <= 1)
2485 + linecount = 24;
2486 +
2487 ++ diag = kdbgetintenv("COLUMNS", &colcount);
2488 ++ if (diag || colcount <= 1)
2489 ++ colcount = 80;
2490 ++
2491 + diag = kdbgetintenv("LOGGING", &logging);
2492 + if (diag)
2493 + logging = 0;
2494 +@@ -690,7 +695,7 @@ kdb_printit:
2495 + gdbstub_msg_write(kdb_buffer, retlen);
2496 + } else {
2497 + if (dbg_io_ops && !dbg_io_ops->is_console) {
2498 +- len = strlen(kdb_buffer);
2499 ++ len = retlen;
2500 + cp = kdb_buffer;
2501 + while (len--) {
2502 + dbg_io_ops->write_char(*cp);
2503 +@@ -709,11 +714,29 @@ kdb_printit:
2504 + printk(KERN_INFO "%s", kdb_buffer);
2505 + }
2506 +
2507 +- if (KDB_STATE(PAGER) && strchr(kdb_buffer, '\n'))
2508 +- kdb_nextline++;
2509 ++ if (KDB_STATE(PAGER)) {
2510 ++ /*
2511 ++ * Check printed string to decide how to bump the
2512 ++ * kdb_nextline to control when the more prompt should
2513 ++ * show up.
2514 ++ */
2515 ++ int got = 0;
2516 ++ len = retlen;
2517 ++ while (len--) {
2518 ++ if (kdb_buffer[len] == '\n') {
2519 ++ kdb_nextline++;
2520 ++ got = 0;
2521 ++ } else if (kdb_buffer[len] == '\r') {
2522 ++ got = 0;
2523 ++ } else {
2524 ++ got++;
2525 ++ }
2526 ++ }
2527 ++ kdb_nextline += got / (colcount + 1);
2528 ++ }
2529 +
2530 + /* check for having reached the LINES number of printed lines */
2531 +- if (kdb_nextline == linecount) {
2532 ++ if (kdb_nextline >= linecount) {
2533 + char buf1[16] = "";
2534 +
2535 + /* Watch out for recursion here. Any routine that calls
2536 +@@ -765,7 +788,7 @@ kdb_printit:
2537 + kdb_grepping_flag = 0;
2538 + kdb_printf("\n");
2539 + } else if (buf1[0] == ' ') {
2540 +- kdb_printf("\n");
2541 ++ kdb_printf("\r");
2542 + suspend_grep = 1; /* for this recursion */
2543 + } else if (buf1[0] == '\n') {
2544 + kdb_nextline = linecount - 1;
2545 +diff --git a/kernel/module.c b/kernel/module.c
2546 +index 4edbd9c..9ad9ee9 100644
2547 +--- a/kernel/module.c
2548 ++++ b/kernel/module.c
2549 +@@ -2730,6 +2730,10 @@ static int check_module_license_and_versions(struct module *mod)
2550 + if (strcmp(mod->name, "driverloader") == 0)
2551 + add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
2552 +
2553 ++ /* lve claims to be GPL but upstream won't provide source */
2554 ++ if (strcmp(mod->name, "lve") == 0)
2555 ++ add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
2556 ++
2557 + #ifdef CONFIG_MODVERSIONS
2558 + if ((mod->num_syms && !mod->crcs)
2559 + || (mod->num_gpl_syms && !mod->gpl_crcs)
2560 +diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
2561 +index 3a9e5d5..e430b97 100644
2562 +--- a/kernel/time/tick-sched.c
2563 ++++ b/kernel/time/tick-sched.c
2564 +@@ -835,7 +835,7 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
2565 + */
2566 + if (ts->tick_stopped) {
2567 + touch_softlockup_watchdog();
2568 +- if (idle_cpu(cpu))
2569 ++ if (is_idle_task(current))
2570 + ts->idle_jiffies++;
2571 + }
2572 + update_process_times(user_mode(regs));
2573 +diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
2574 +index d3b91e7..f791637 100644
2575 +--- a/kernel/time/timekeeping.c
2576 ++++ b/kernel/time/timekeeping.c
2577 +@@ -1111,7 +1111,7 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset,
2578 + accumulate_nsecs_to_secs(tk);
2579 +
2580 + /* Accumulate raw time */
2581 +- raw_nsecs = tk->raw_interval << shift;
2582 ++ raw_nsecs = (u64)tk->raw_interval << shift;
2583 + raw_nsecs += tk->raw_time.tv_nsec;
2584 + if (raw_nsecs >= NSEC_PER_SEC) {
2585 + u64 raw_secs = raw_nsecs;
2586 +diff --git a/kernel/timer.c b/kernel/timer.c
2587 +index 8c5e7b9..46ef2b1 100644
2588 +--- a/kernel/timer.c
2589 ++++ b/kernel/timer.c
2590 +@@ -63,6 +63,7 @@ EXPORT_SYMBOL(jiffies_64);
2591 + #define TVR_SIZE (1 << TVR_BITS)
2592 + #define TVN_MASK (TVN_SIZE - 1)
2593 + #define TVR_MASK (TVR_SIZE - 1)
2594 ++#define MAX_TVAL ((unsigned long)((1ULL << (TVR_BITS + 4*TVN_BITS)) - 1))
2595 +
2596 + struct tvec {
2597 + struct list_head vec[TVN_SIZE];
2598 +@@ -358,11 +359,12 @@ __internal_add_timer(struct tvec_base *base, struct timer_list *timer)
2599 + vec = base->tv1.vec + (base->timer_jiffies & TVR_MASK);
2600 + } else {
2601 + int i;
2602 +- /* If the timeout is larger than 0xffffffff on 64-bit
2603 +- * architectures then we use the maximum timeout:
2604 ++ /* If the timeout is larger than MAX_TVAL (on 64-bit
2605 ++ * architectures or with CONFIG_BASE_SMALL=1) then we
2606 ++ * use the maximum timeout.
2607 + */
2608 +- if (idx > 0xffffffffUL) {
2609 +- idx = 0xffffffffUL;
2610 ++ if (idx > MAX_TVAL) {
2611 ++ idx = MAX_TVAL;
2612 + expires = idx + base->timer_jiffies;
2613 + }
2614 + i = (expires >> (TVR_BITS + 3 * TVN_BITS)) & TVN_MASK;
2615 +diff --git a/mm/shmem.c b/mm/shmem.c
2616 +index d4e184e..d2eeca1 100644
2617 +--- a/mm/shmem.c
2618 ++++ b/mm/shmem.c
2619 +@@ -2366,12 +2366,14 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
2620 + {
2621 + struct inode *inode;
2622 + struct dentry *dentry = NULL;
2623 +- u64 inum = fid->raw[2];
2624 +- inum = (inum << 32) | fid->raw[1];
2625 ++ u64 inum;
2626 +
2627 + if (fh_len < 3)
2628 + return NULL;
2629 +
2630 ++ inum = fid->raw[2];
2631 ++ inum = (inum << 32) | fid->raw[1];
2632 ++
2633 + inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]),
2634 + shmem_match, fid->raw);
2635 + if (inode) {
2636 +diff --git a/net/core/pktgen.c b/net/core/pktgen.c
2637 +index 148e73d..e356b8d 100644
2638 +--- a/net/core/pktgen.c
2639 ++++ b/net/core/pktgen.c
2640 +@@ -2927,7 +2927,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2641 + sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
2642 + pkt_dev->pkt_overhead;
2643 +
2644 +- if (datalen < sizeof(struct pktgen_hdr)) {
2645 ++ if (datalen < 0 || datalen < sizeof(struct pktgen_hdr)) {
2646 + datalen = sizeof(struct pktgen_hdr);
2647 + net_info_ratelimited("increased datalen to %d\n", datalen);
2648 + }
2649 +diff --git a/net/mac80211/status.c b/net/mac80211/status.c
2650 +index 8cd7291..118329a 100644
2651 +--- a/net/mac80211/status.c
2652 ++++ b/net/mac80211/status.c
2653 +@@ -34,7 +34,7 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
2654 + skb_queue_len(&local->skb_queue_unreliable);
2655 + while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
2656 + (skb = skb_dequeue(&local->skb_queue_unreliable))) {
2657 +- dev_kfree_skb_irq(skb);
2658 ++ ieee80211_free_txskb(hw, skb);
2659 + tmp--;
2660 + I802_DEBUG_INC(local->tx_status_drop);
2661 + }
2662 +@@ -159,7 +159,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
2663 + "dropped TX filtered frame, queue_len=%d PS=%d @%lu\n",
2664 + skb_queue_len(&sta->tx_filtered[ac]),
2665 + !!test_sta_flag(sta, WLAN_STA_PS_STA), jiffies);
2666 +- dev_kfree_skb(skb);
2667 ++ ieee80211_free_txskb(&local->hw, skb);
2668 + }
2669 +
2670 + static void ieee80211_check_pending_bar(struct sta_info *sta, u8 *addr, u8 tid)
2671 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
2672 +index c5e8c9c..362c418 100644
2673 +--- a/net/mac80211/tx.c
2674 ++++ b/net/mac80211/tx.c
2675 +@@ -354,7 +354,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
2676 + total += skb_queue_len(&sta->ps_tx_buf[ac]);
2677 + if (skb) {
2678 + purged++;
2679 +- dev_kfree_skb(skb);
2680 ++ ieee80211_free_txskb(&local->hw, skb);
2681 + break;
2682 + }
2683 + }
2684 +@@ -466,7 +466,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
2685 + ps_dbg(tx->sdata,
2686 + "STA %pM TX buffer for AC %d full - dropping oldest frame\n",
2687 + sta->sta.addr, ac);
2688 +- dev_kfree_skb(old);
2689 ++ ieee80211_free_txskb(&local->hw, old);
2690 + } else
2691 + tx->local->total_ps_buffered++;
2692 +
2693 +@@ -1103,7 +1103,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,
2694 + spin_unlock(&tx->sta->lock);
2695 +
2696 + if (purge_skb)
2697 +- dev_kfree_skb(purge_skb);
2698 ++ ieee80211_free_txskb(&tx->local->hw, purge_skb);
2699 + }
2700 +
2701 + /* reset session timer */
2702 +@@ -1214,7 +1214,7 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local,
2703 + #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2704 + if (WARN_ON_ONCE(q >= local->hw.queues)) {
2705 + __skb_unlink(skb, skbs);
2706 +- dev_kfree_skb(skb);
2707 ++ ieee80211_free_txskb(&local->hw, skb);
2708 + continue;
2709 + }
2710 + #endif
2711 +@@ -1356,7 +1356,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
2712 + if (unlikely(res == TX_DROP)) {
2713 + I802_DEBUG_INC(tx->local->tx_handlers_drop);
2714 + if (tx->skb)
2715 +- dev_kfree_skb(tx->skb);
2716 ++ ieee80211_free_txskb(&tx->local->hw, tx->skb);
2717 + else
2718 + __skb_queue_purge(&tx->skbs);
2719 + return -1;
2720 +@@ -1393,7 +1393,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
2721 + res_prepare = ieee80211_tx_prepare(sdata, &tx, skb);
2722 +
2723 + if (unlikely(res_prepare == TX_DROP)) {
2724 +- dev_kfree_skb(skb);
2725 ++ ieee80211_free_txskb(&local->hw, skb);
2726 + goto out;
2727 + } else if (unlikely(res_prepare == TX_QUEUED)) {
2728 + goto out;
2729 +@@ -1466,7 +1466,7 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
2730 + headroom = max_t(int, 0, headroom);
2731 +
2732 + if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
2733 +- dev_kfree_skb(skb);
2734 ++ ieee80211_free_txskb(&local->hw, skb);
2735 + rcu_read_unlock();
2736 + return;
2737 + }
2738 +@@ -2060,8 +2060,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2739 + head_need += IEEE80211_ENCRYPT_HEADROOM;
2740 + head_need += local->tx_headroom;
2741 + head_need = max_t(int, 0, head_need);
2742 +- if (ieee80211_skb_resize(sdata, skb, head_need, true))
2743 +- goto fail;
2744 ++ if (ieee80211_skb_resize(sdata, skb, head_need, true)) {
2745 ++ ieee80211_free_txskb(&local->hw, skb);
2746 ++ return NETDEV_TX_OK;
2747 ++ }
2748 + }
2749 +
2750 + if (encaps_data) {
2751 +@@ -2196,7 +2198,7 @@ void ieee80211_tx_pending(unsigned long data)
2752 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2753 +
2754 + if (WARN_ON(!info->control.vif)) {
2755 +- kfree_skb(skb);
2756 ++ ieee80211_free_txskb(&local->hw, skb);
2757 + continue;
2758 + }
2759 +
2760 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
2761 +index a35b8e5..d1988cf 100644
2762 +--- a/net/sunrpc/xprtsock.c
2763 ++++ b/net/sunrpc/xprtsock.c
2764 +@@ -1025,6 +1025,16 @@ static void xs_udp_data_ready(struct sock *sk, int len)
2765 + read_unlock_bh(&sk->sk_callback_lock);
2766 + }
2767 +
2768 ++/*
2769 ++ * Helper function to force a TCP close if the server is sending
2770 ++ * junk and/or it has put us in CLOSE_WAIT
2771 ++ */
2772 ++static void xs_tcp_force_close(struct rpc_xprt *xprt)
2773 ++{
2774 ++ set_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
2775 ++ xprt_force_disconnect(xprt);
2776 ++}
2777 ++
2778 + static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc)
2779 + {
2780 + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
2781 +@@ -1051,7 +1061,7 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_rea
2782 + /* Sanity check of the record length */
2783 + if (unlikely(transport->tcp_reclen < 8)) {
2784 + dprintk("RPC: invalid TCP record fragment length\n");
2785 +- xprt_force_disconnect(xprt);
2786 ++ xs_tcp_force_close(xprt);
2787 + return;
2788 + }
2789 + dprintk("RPC: reading TCP record fragment of length %d\n",
2790 +@@ -1132,7 +1142,7 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport,
2791 + break;
2792 + default:
2793 + dprintk("RPC: invalid request message type\n");
2794 +- xprt_force_disconnect(&transport->xprt);
2795 ++ xs_tcp_force_close(&transport->xprt);
2796 + }
2797 + xs_tcp_check_fraghdr(transport);
2798 + }
2799 +@@ -1455,6 +1465,8 @@ static void xs_tcp_cancel_linger_timeout(struct rpc_xprt *xprt)
2800 + static void xs_sock_mark_closed(struct rpc_xprt *xprt)
2801 + {
2802 + smp_mb__before_clear_bit();
2803 ++ clear_bit(XPRT_CONNECTION_ABORT, &xprt->state);
2804 ++ clear_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
2805 + clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
2806 + clear_bit(XPRT_CLOSING, &xprt->state);
2807 + smp_mb__after_clear_bit();
2808 +@@ -1512,8 +1524,8 @@ static void xs_tcp_state_change(struct sock *sk)
2809 + break;
2810 + case TCP_CLOSE_WAIT:
2811 + /* The server initiated a shutdown of the socket */
2812 +- xprt_force_disconnect(xprt);
2813 + xprt->connect_cookie++;
2814 ++ xs_tcp_force_close(xprt);
2815 + case TCP_CLOSING:
2816 + /*
2817 + * If the server closed down the connection, make sure that
2818 +@@ -2199,8 +2211,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)
2819 + /* We're probably in TIME_WAIT. Get rid of existing socket,
2820 + * and retry
2821 + */
2822 +- set_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
2823 +- xprt_force_disconnect(xprt);
2824 ++ xs_tcp_force_close(xprt);
2825 + break;
2826 + case -ECONNREFUSED:
2827 + case -ECONNRESET:
2828 +diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst
2829 +index c3f69ae..4d908d1 100644
2830 +--- a/scripts/Makefile.fwinst
2831 ++++ b/scripts/Makefile.fwinst
2832 +@@ -27,7 +27,7 @@ endif
2833 + installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
2834 +
2835 + installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
2836 +-installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/.
2837 ++installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./
2838 +
2839 + # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
2840 + PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
2841 +@@ -42,7 +42,7 @@ quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
2842 + $(installed-fw-dirs):
2843 + $(call cmd,mkdir)
2844 +
2845 +-$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $$(dir $(INSTALL_FW_PATH)/%)
2846 ++$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %)
2847 + $(call cmd,install)
2848 +
2849 + PHONY += __fw_install __fw_modinst FORCE
2850 +diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
2851 +index 9473fca..8b0f996 100644
2852 +--- a/sound/pci/ac97/ac97_codec.c
2853 ++++ b/sound/pci/ac97/ac97_codec.c
2854 +@@ -1271,6 +1271,8 @@ static int snd_ac97_cvol_new(struct snd_card *card, char *name, int reg, unsigne
2855 + tmp.index = ac97->num;
2856 + kctl = snd_ctl_new1(&tmp, ac97);
2857 + }
2858 ++ if (!kctl)
2859 ++ return -ENOMEM;
2860 + if (reg >= AC97_PHONE && reg <= AC97_PCM)
2861 + set_tlv_db_scale(kctl, db_scale_5bit_12db_max);
2862 + else
2863 +diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
2864 +index 7549240..a78fdf4 100644
2865 +--- a/sound/pci/emu10k1/emu10k1_main.c
2866 ++++ b/sound/pci/emu10k1/emu10k1_main.c
2867 +@@ -1416,6 +1416,15 @@ static struct snd_emu_chip_details emu_chip_details[] = {
2868 + .ca0108_chip = 1,
2869 + .spk71 = 1,
2870 + .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */
2871 ++ /* Tested by Maxim Kachur <mcdebugger@×××××××.ru> 17th Oct 2012. */
2872 ++ /* This is MAEM8986, 0202 is MAEM8980 */
2873 ++ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40071102,
2874 ++ .driver = "Audigy2", .name = "E-mu 1010 PCIe [MAEM8986]",
2875 ++ .id = "EMU1010",
2876 ++ .emu10k2_chip = 1,
2877 ++ .ca0108_chip = 1,
2878 ++ .spk71 = 1,
2879 ++ .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 PCIe */
2880 + /* Tested by James@×××××××××××.uk 8th July 2005. */
2881 + /* This is MAEM8810, 0202 is MAEM8820 */
2882 + {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
2883 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
2884 +index 12a9432..a5dc746 100644
2885 +--- a/sound/pci/hda/hda_intel.c
2886 ++++ b/sound/pci/hda/hda_intel.c
2887 +@@ -487,6 +487,7 @@ struct azx {
2888 +
2889 + /* VGA-switcheroo setup */
2890 + unsigned int use_vga_switcheroo:1;
2891 ++ unsigned int vga_switcheroo_registered:1;
2892 + unsigned int init_failed:1; /* delayed init failed */
2893 + unsigned int disabled:1; /* disabled by VGA-switcher */
2894 +
2895 +@@ -2135,9 +2136,12 @@ static unsigned int azx_get_position(struct azx *chip,
2896 + if (delay < 0)
2897 + delay += azx_dev->bufsize;
2898 + if (delay >= azx_dev->period_bytes) {
2899 +- snd_printdd("delay %d > period_bytes %d\n",
2900 +- delay, azx_dev->period_bytes);
2901 +- delay = 0; /* something is wrong */
2902 ++ snd_printk(KERN_WARNING SFX
2903 ++ "Unstable LPIB (%d >= %d); "
2904 ++ "disabling LPIB delay counting\n",
2905 ++ delay, azx_dev->period_bytes);
2906 ++ delay = 0;
2907 ++ chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
2908 + }
2909 + azx_dev->substream->runtime->delay =
2910 + bytes_to_frames(azx_dev->substream->runtime, delay);
2911 +@@ -2556,7 +2560,9 @@ static void azx_vs_set_state(struct pci_dev *pci,
2912 + if (disabled) {
2913 + azx_suspend(&pci->dev);
2914 + chip->disabled = true;
2915 +- snd_hda_lock_devices(chip->bus);
2916 ++ if (snd_hda_lock_devices(chip->bus))
2917 ++ snd_printk(KERN_WARNING SFX
2918 ++ "Cannot lock devices!\n");
2919 + } else {
2920 + snd_hda_unlock_devices(chip->bus);
2921 + chip->disabled = false;
2922 +@@ -2599,14 +2605,20 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
2923 +
2924 + static int __devinit register_vga_switcheroo(struct azx *chip)
2925 + {
2926 ++ int err;
2927 ++
2928 + if (!chip->use_vga_switcheroo)
2929 + return 0;
2930 + /* FIXME: currently only handling DIS controller
2931 + * is there any machine with two switchable HDMI audio controllers?
2932 + */
2933 +- return vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
2934 ++ err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
2935 + VGA_SWITCHEROO_DIS,
2936 + chip->bus != NULL);
2937 ++ if (err < 0)
2938 ++ return err;
2939 ++ chip->vga_switcheroo_registered = 1;
2940 ++ return 0;
2941 + }
2942 + #else
2943 + #define init_vga_switcheroo(chip) /* NOP */
2944 +@@ -2626,7 +2638,8 @@ static int azx_free(struct azx *chip)
2945 + if (use_vga_switcheroo(chip)) {
2946 + if (chip->disabled && chip->bus)
2947 + snd_hda_unlock_devices(chip->bus);
2948 +- vga_switcheroo_unregister_client(chip->pci);
2949 ++ if (chip->vga_switcheroo_registered)
2950 ++ vga_switcheroo_unregister_client(chip->pci);
2951 + }
2952 +
2953 + if (chip->initialized) {
2954 +@@ -2974,14 +2987,6 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2955 + }
2956 +
2957 + ok:
2958 +- err = register_vga_switcheroo(chip);
2959 +- if (err < 0) {
2960 +- snd_printk(KERN_ERR SFX
2961 +- "Error registering VGA-switcheroo client\n");
2962 +- azx_free(chip);
2963 +- return err;
2964 +- }
2965 +-
2966 + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
2967 + if (err < 0) {
2968 + snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
2969 +@@ -3208,6 +3213,13 @@ static int __devinit azx_probe(struct pci_dev *pci,
2970 +
2971 + pci_set_drvdata(pci, card);
2972 +
2973 ++ err = register_vga_switcheroo(chip);
2974 ++ if (err < 0) {
2975 ++ snd_printk(KERN_ERR SFX
2976 ++ "Error registering VGA-switcheroo client\n");
2977 ++ goto out_free;
2978 ++ }
2979 ++
2980 + dev++;
2981 + return 0;
2982 +
2983 +diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
2984 +index 0c4c1a6..cc31346 100644
2985 +--- a/sound/pci/hda/patch_cirrus.c
2986 ++++ b/sound/pci/hda/patch_cirrus.c
2987 +@@ -1417,7 +1417,7 @@ static int patch_cs420x(struct hda_codec *codec)
2988 + return 0;
2989 +
2990 + error:
2991 +- kfree(codec->spec);
2992 ++ cs_free(codec);
2993 + codec->spec = NULL;
2994 + return err;
2995 + }
2996 +@@ -1974,7 +1974,7 @@ static int patch_cs4210(struct hda_codec *codec)
2997 + return 0;
2998 +
2999 + error:
3000 +- kfree(codec->spec);
3001 ++ cs_free(codec);
3002 + codec->spec = NULL;
3003 + return err;
3004 + }
3005 +@@ -1999,7 +1999,7 @@ static int patch_cs4213(struct hda_codec *codec)
3006 + return 0;
3007 +
3008 + error:
3009 +- kfree(codec->spec);
3010 ++ cs_free(codec);
3011 + codec->spec = NULL;
3012 + return err;
3013 + }
3014 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3015 +index 56a3eef..155cbd2 100644
3016 +--- a/sound/pci/hda/patch_realtek.c
3017 ++++ b/sound/pci/hda/patch_realtek.c
3018 +@@ -611,6 +611,8 @@ static void alc_line_automute(struct hda_codec *codec)
3019 + {
3020 + struct alc_spec *spec = codec->spec;
3021 +
3022 ++ if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
3023 ++ return;
3024 + /* check LO jack only when it's different from HP */
3025 + if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0])
3026 + return;
3027 +@@ -2627,8 +2629,10 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
3028 + return "PCM";
3029 + break;
3030 + }
3031 +- if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
3032 ++ if (ch >= ARRAY_SIZE(channel_name)) {
3033 ++ snd_BUG();
3034 + return "PCM";
3035 ++ }
3036 +
3037 + return channel_name[ch];
3038 + }
3039 +diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
3040 +index 4b4072f..4c404a0 100644
3041 +--- a/sound/pci/hda/patch_via.c
3042 ++++ b/sound/pci/hda/patch_via.c
3043 +@@ -118,6 +118,8 @@ enum {
3044 + };
3045 +
3046 + struct via_spec {
3047 ++ struct hda_gen_spec gen;
3048 ++
3049 + /* codec parameterization */
3050 + const struct snd_kcontrol_new *mixers[6];
3051 + unsigned int num_mixers;
3052 +@@ -246,6 +248,7 @@ static struct via_spec * via_new_spec(struct hda_codec *codec)
3053 + /* VT1708BCE & VT1708S are almost same */
3054 + if (spec->codec_type == VT1708BCE)
3055 + spec->codec_type = VT1708S;
3056 ++ snd_hda_gen_init(&spec->gen);
3057 + return spec;
3058 + }
3059 +
3060 +@@ -1628,6 +1631,7 @@ static void via_free(struct hda_codec *codec)
3061 + vt1708_stop_hp_work(spec);
3062 + kfree(spec->bind_cap_vol);
3063 + kfree(spec->bind_cap_sw);
3064 ++ snd_hda_gen_free(&spec->gen);
3065 + kfree(spec);
3066 + }
3067 +
3068 +diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
3069 +index 32682c1..c8bff6d 100644
3070 +--- a/sound/soc/codecs/wm2200.c
3071 ++++ b/sound/soc/codecs/wm2200.c
3072 +@@ -1028,7 +1028,7 @@ SOC_DOUBLE_R_TLV("OUT2 Digital Volume", WM2200_DAC_DIGITAL_VOLUME_2L,
3073 + WM2200_DAC_DIGITAL_VOLUME_2R, WM2200_OUT2L_VOL_SHIFT, 0x9f, 0,
3074 + digital_tlv),
3075 + SOC_DOUBLE("OUT2 Switch", WM2200_PDM_1, WM2200_SPK1L_MUTE_SHIFT,
3076 +- WM2200_SPK1R_MUTE_SHIFT, 1, 0),
3077 ++ WM2200_SPK1R_MUTE_SHIFT, 1, 1),
3078 + };
3079 +
3080 + WM2200_MIXER_ENUMS(OUT1L, WM2200_OUT1LMIX_INPUT_1_SOURCE);
3081 +@@ -2091,6 +2091,7 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
3082 +
3083 + switch (wm2200->rev) {
3084 + case 0:
3085 ++ case 1:
3086 + ret = regmap_register_patch(wm2200->regmap, wm2200_reva_patch,
3087 + ARRAY_SIZE(wm2200_reva_patch));
3088 + if (ret != 0) {
3089 +diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
3090 +index 9d93793..f8fba57 100644
3091 +--- a/sound/soc/omap/omap-abe-twl6040.c
3092 ++++ b/sound/soc/omap/omap-abe-twl6040.c
3093 +@@ -190,7 +190,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
3094 + twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
3095 + twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
3096 + twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
3097 +- twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator");
3098 ++ twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vibrator");
3099 + twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
3100 + twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
3101 + twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
3102 +diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
3103 +index 0540408..1bb0d58c 100644
3104 +--- a/sound/soc/sh/fsi.c
3105 ++++ b/sound/soc/sh/fsi.c
3106 +@@ -20,6 +20,7 @@
3107 + #include <linux/sh_dma.h>
3108 + #include <linux/slab.h>
3109 + #include <linux/module.h>
3110 ++#include <linux/workqueue.h>
3111 + #include <sound/soc.h>
3112 + #include <sound/sh_fsi.h>
3113 +
3114 +@@ -223,7 +224,7 @@ struct fsi_stream {
3115 + */
3116 + struct dma_chan *chan;
3117 + struct sh_dmae_slave slave; /* see fsi_handler_init() */
3118 +- struct tasklet_struct tasklet;
3119 ++ struct work_struct work;
3120 + dma_addr_t dma;
3121 + };
3122 +
3123 +@@ -1085,9 +1086,9 @@ static void fsi_dma_complete(void *data)
3124 + snd_pcm_period_elapsed(io->substream);
3125 + }
3126 +
3127 +-static void fsi_dma_do_tasklet(unsigned long data)
3128 ++static void fsi_dma_do_work(struct work_struct *work)
3129 + {
3130 +- struct fsi_stream *io = (struct fsi_stream *)data;
3131 ++ struct fsi_stream *io = container_of(work, struct fsi_stream, work);
3132 + struct fsi_priv *fsi = fsi_stream_to_priv(io);
3133 + struct snd_soc_dai *dai;
3134 + struct dma_async_tx_descriptor *desc;
3135 +@@ -1129,7 +1130,7 @@ static void fsi_dma_do_tasklet(unsigned long data)
3136 + * FIXME
3137 + *
3138 + * In DMAEngine case, codec and FSI cannot be started simultaneously
3139 +- * since FSI is using tasklet.
3140 ++ * since FSI is using the scheduler work queue.
3141 + * Therefore, in capture case, probably FSI FIFO will have got
3142 + * overflow error in this point.
3143 + * in that case, DMA cannot start transfer until error was cleared.
3144 +@@ -1153,7 +1154,7 @@ static bool fsi_dma_filter(struct dma_chan *chan, void *param)
3145 +
3146 + static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io)
3147 + {
3148 +- tasklet_schedule(&io->tasklet);
3149 ++ schedule_work(&io->work);
3150 +
3151 + return 0;
3152 + }
3153 +@@ -1195,14 +1196,14 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct dev
3154 + return fsi_stream_probe(fsi, dev);
3155 + }
3156 +
3157 +- tasklet_init(&io->tasklet, fsi_dma_do_tasklet, (unsigned long)io);
3158 ++ INIT_WORK(&io->work, fsi_dma_do_work);
3159 +
3160 + return 0;
3161 + }
3162 +
3163 + static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
3164 + {
3165 +- tasklet_kill(&io->tasklet);
3166 ++ cancel_work_sync(&io->work);
3167 +
3168 + fsi_stream_stop(fsi, io);
3169 +
3170
3171 Added: genpatches-2.6/trunk/3.6/1003_linux-3.6.4.patch
3172 ===================================================================
3173 --- genpatches-2.6/trunk/3.6/1003_linux-3.6.4.patch (rev 0)
3174 +++ genpatches-2.6/trunk/3.6/1003_linux-3.6.4.patch 2012-10-29 14:34:04 UTC (rev 2226)
3175 @@ -0,0 +1,4828 @@
3176 +diff --git a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
3177 +index c8e5782..683fde9 100644
3178 +--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
3179 ++++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
3180 +@@ -93,7 +93,7 @@ Valid values for pin and group names are:
3181 +
3182 + With some exceptions, these support nvidia,high-speed-mode,
3183 + nvidia,schmitt, nvidia,low-power-mode, nvidia,pull-down-strength,
3184 +- nvidia,pull-up-strength, nvidia,slew_rate-rising, nvidia,slew_rate-falling.
3185 ++ nvidia,pull-up-strength, nvidia,slew-rate-rising, nvidia,slew-rate-falling.
3186 +
3187 + drive_ao1, drive_ao2, drive_at1, drive_at2, drive_cdev1, drive_cdev2,
3188 + drive_csus, drive_dap1, drive_dap2, drive_dap3, drive_dap4, drive_dbg,
3189 +diff --git a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
3190 +index c275b70..6f426ed 100644
3191 +--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
3192 ++++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
3193 +@@ -83,7 +83,7 @@ Valid values for pin and group names are:
3194 + drive groups:
3195 +
3196 + These all support nvidia,pull-down-strength, nvidia,pull-up-strength,
3197 +- nvidia,slew_rate-rising, nvidia,slew_rate-falling. Most but not all
3198 ++ nvidia,slew-rate-rising, nvidia,slew-rate-falling. Most but not all
3199 + support nvidia,high-speed-mode, nvidia,schmitt, nvidia,low-power-mode.
3200 +
3201 + ao1, ao2, at1, at2, at3, at4, at5, cdev1, cdev2, cec, crt, csus, dap1,
3202 +diff --git a/Documentation/hwmon/coretemp b/Documentation/hwmon/coretemp
3203 +index c86b50c..f17256f 100644
3204 +--- a/Documentation/hwmon/coretemp
3205 ++++ b/Documentation/hwmon/coretemp
3206 +@@ -105,6 +105,7 @@ Process Processor TjMax(C)
3207 + 330/230 125
3208 + E680/660/640/620 90
3209 + E680T/660T/640T/620T 110
3210 ++ CE4170/4150/4110 110
3211 +
3212 + 45nm Core2 Processors
3213 + Solo ULV SU3500/3300 100
3214 +diff --git a/Makefile b/Makefile
3215 +index 6cdadf4..dcf132a 100644
3216 +--- a/Makefile
3217 ++++ b/Makefile
3218 +@@ -1,6 +1,6 @@
3219 + VERSION = 3
3220 + PATCHLEVEL = 6
3221 +-SUBLEVEL = 3
3222 ++SUBLEVEL = 4
3223 + EXTRAVERSION =
3224 + NAME = Terrified Chipmunk
3225 +
3226 +diff --git a/arch/s390/boot/compressed/vmlinux.lds.S b/arch/s390/boot/compressed/vmlinux.lds.S
3227 +index d80f79d..8e1fb82 100644
3228 +--- a/arch/s390/boot/compressed/vmlinux.lds.S
3229 ++++ b/arch/s390/boot/compressed/vmlinux.lds.S
3230 +@@ -5,7 +5,7 @@ OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
3231 + OUTPUT_ARCH(s390:64-bit)
3232 + #else
3233 + OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390")
3234 +-OUTPUT_ARCH(s390)
3235 ++OUTPUT_ARCH(s390:31-bit)
3236 + #endif
3237 +
3238 + ENTRY(startup)
3239 +diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
3240 +index de8fa9b..79cb51a 100644
3241 +--- a/arch/s390/kernel/vmlinux.lds.S
3242 ++++ b/arch/s390/kernel/vmlinux.lds.S
3243 +@@ -8,7 +8,7 @@
3244 +
3245 + #ifndef CONFIG_64BIT
3246 + OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390")
3247 +-OUTPUT_ARCH(s390)
3248 ++OUTPUT_ARCH(s390:31-bit)
3249 + ENTRY(startup)
3250 + jiffies = jiffies_64 + 4;
3251 + #else
3252 +diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
3253 +index 5713957..ac18037 100644
3254 +--- a/arch/sparc/kernel/perf_event.c
3255 ++++ b/arch/sparc/kernel/perf_event.c
3256 +@@ -557,11 +557,13 @@ static u64 nop_for_index(int idx)
3257 +
3258 + static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx)
3259 + {
3260 +- u64 val, mask = mask_for_index(idx);
3261 ++ u64 enc, val, mask = mask_for_index(idx);
3262 ++
3263 ++ enc = perf_event_get_enc(cpuc->events[idx]);
3264 +
3265 + val = cpuc->pcr;
3266 + val &= ~mask;
3267 +- val |= hwc->config;
3268 ++ val |= event_encoding(enc, idx);
3269 + cpuc->pcr = val;
3270 +
3271 + pcr_ops->write(cpuc->pcr);
3272 +@@ -1426,8 +1428,6 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
3273 + {
3274 + unsigned long ufp;
3275 +
3276 +- perf_callchain_store(entry, regs->tpc);
3277 +-
3278 + ufp = regs->u_regs[UREG_I6] + STACK_BIAS;
3279 + do {
3280 + struct sparc_stackf *usf, sf;
3281 +@@ -1448,8 +1448,6 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
3282 + {
3283 + unsigned long ufp;
3284 +
3285 +- perf_callchain_store(entry, regs->tpc);
3286 +-
3287 + ufp = regs->u_regs[UREG_I6] & 0xffffffffUL;
3288 + do {
3289 + struct sparc_stackf32 *usf, sf;
3290 +@@ -1468,6 +1466,11 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
3291 + void
3292 + perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
3293 + {
3294 ++ perf_callchain_store(entry, regs->tpc);
3295 ++
3296 ++ if (!current->mm)
3297 ++ return;
3298 ++
3299 + flushw_user();
3300 + if (test_thread_flag(TIF_32BIT))
3301 + perf_callchain_user_32(entry, regs);
3302 +diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
3303 +index 1d7e274..7f5f65d 100644
3304 +--- a/arch/sparc/kernel/syscalls.S
3305 ++++ b/arch/sparc/kernel/syscalls.S
3306 +@@ -212,24 +212,20 @@ linux_sparc_syscall:
3307 + 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
3308 + ret_sys_call:
3309 + ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
3310 +- ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
3311 + sra %o0, 0, %o0
3312 + mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
3313 + sllx %g2, 32, %g2
3314 +
3315 +- /* Check if force_successful_syscall_return()
3316 +- * was invoked.
3317 +- */
3318 +- ldub [%g6 + TI_SYS_NOERROR], %l2
3319 +- brnz,a,pn %l2, 80f
3320 +- stb %g0, [%g6 + TI_SYS_NOERROR]
3321 +-
3322 + cmp %o0, -ERESTART_RESTARTBLOCK
3323 + bgeu,pn %xcc, 1f
3324 +- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
3325 +-80:
3326 ++ andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
3327 ++ ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
3328 ++
3329 ++2:
3330 ++ stb %g0, [%g6 + TI_SYS_NOERROR]
3331 + /* System call success, clear Carry condition code. */
3332 + andn %g3, %g2, %g3
3333 ++3:
3334 + stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
3335 + bne,pn %icc, linux_syscall_trace2
3336 + add %l1, 0x4, %l2 ! npc = npc+4
3337 +@@ -238,20 +234,20 @@ ret_sys_call:
3338 + stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
3339 +
3340 + 1:
3341 ++ /* Check if force_successful_syscall_return()
3342 ++ * was invoked.
3343 ++ */
3344 ++ ldub [%g6 + TI_SYS_NOERROR], %l2
3345 ++ brnz,pn %l2, 2b
3346 ++ ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
3347 + /* System call failure, set Carry condition code.
3348 + * Also, get abs(errno) to return to the process.
3349 + */
3350 +- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
3351 + sub %g0, %o0, %o0
3352 +- or %g3, %g2, %g3
3353 + stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
3354 +- stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
3355 +- bne,pn %icc, linux_syscall_trace2
3356 +- add %l1, 0x4, %l2 ! npc = npc+4
3357 +- stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
3358 ++ ba,pt %xcc, 3b
3359 ++ or %g3, %g2, %g3
3360 +
3361 +- b,pt %xcc, rtrap
3362 +- stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
3363 + linux_syscall_trace2:
3364 + call syscall_trace_leave
3365 + add %sp, PTREGS_OFF, %o0
3366 +diff --git a/arch/tile/Makefile b/arch/tile/Makefile
3367 +index 55640cf..3d15364 100644
3368 +--- a/arch/tile/Makefile
3369 ++++ b/arch/tile/Makefile
3370 +@@ -26,6 +26,10 @@ $(error Set TILERA_ROOT or CROSS_COMPILE when building $(ARCH) on $(HOST_ARCH))
3371 + endif
3372 + endif
3373 +
3374 ++# The tile compiler may emit .eh_frame information for backtracing.
3375 ++# In kernel modules, this causes load failures due to unsupported relocations.
3376 ++KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
3377 ++
3378 + ifneq ($(CONFIG_DEBUG_EXTRA_FLAGS),"")
3379 + KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS)
3380 + endif
3381 +diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
3382 +index c4e916d..698b6ec 100644
3383 +--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
3384 ++++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
3385 +@@ -576,12 +576,10 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
3386 + int err = 0;
3387 +
3388 + if (shared_bank[bank]) {
3389 +-
3390 + nb = node_to_amd_nb(amd_get_nb_id(cpu));
3391 +- WARN_ON(!nb);
3392 +
3393 + /* threshold descriptor already initialized on this node? */
3394 +- if (nb->bank4) {
3395 ++ if (nb && nb->bank4) {
3396 + /* yes, use it */
3397 + b = nb->bank4;
3398 + err = kobject_add(b->kobj, &dev->kobj, name);
3399 +@@ -615,8 +613,10 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
3400 + atomic_set(&b->cpus, 1);
3401 +
3402 + /* nb is already initialized, see above */
3403 +- WARN_ON(nb->bank4);
3404 +- nb->bank4 = b;
3405 ++ if (nb) {
3406 ++ WARN_ON(nb->bank4);
3407 ++ nb->bank4 = b;
3408 ++ }
3409 + }
3410 +
3411 + err = allocate_threshold_blocks(cpu, bank, 0,
3412 +diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
3413 +index 623f288..8f8e8ee 100644
3414 +--- a/arch/x86/kernel/entry_32.S
3415 ++++ b/arch/x86/kernel/entry_32.S
3416 +@@ -1016,7 +1016,7 @@ ENTRY(xen_sysenter_target)
3417 +
3418 + ENTRY(xen_hypervisor_callback)
3419 + CFI_STARTPROC
3420 +- pushl_cfi $0
3421 ++ pushl_cfi $-1 /* orig_ax = -1 => not a system call */
3422 + SAVE_ALL
3423 + TRACE_IRQS_OFF
3424 +
3425 +@@ -1058,14 +1058,16 @@ ENTRY(xen_failsafe_callback)
3426 + 2: mov 8(%esp),%es
3427 + 3: mov 12(%esp),%fs
3428 + 4: mov 16(%esp),%gs
3429 ++ /* EAX == 0 => Category 1 (Bad segment)
3430 ++ EAX != 0 => Category 2 (Bad IRET) */
3431 + testl %eax,%eax
3432 + popl_cfi %eax
3433 + lea 16(%esp),%esp
3434 + CFI_ADJUST_CFA_OFFSET -16
3435 + jz 5f
3436 + addl $16,%esp
3437 +- jmp iret_exc # EAX != 0 => Category 2 (Bad IRET)
3438 +-5: pushl_cfi $0 # EAX == 0 => Category 1 (Bad segment)
3439 ++ jmp iret_exc
3440 ++5: pushl_cfi $-1 /* orig_ax = -1 => not a system call */
3441 + SAVE_ALL
3442 + jmp ret_from_exception
3443 + CFI_ENDPROC
3444 +diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
3445 +index 69babd8..dcdd0ea 100644
3446 +--- a/arch/x86/kernel/entry_64.S
3447 ++++ b/arch/x86/kernel/entry_64.S
3448 +@@ -1363,7 +1363,7 @@ ENTRY(xen_failsafe_callback)
3449 + CFI_RESTORE r11
3450 + addq $0x30,%rsp
3451 + CFI_ADJUST_CFA_OFFSET -0x30
3452 +- pushq_cfi $0
3453 ++ pushq_cfi $-1 /* orig_ax = -1 => not a system call */
3454 + SAVE_ALL
3455 + jmp error_exit
3456 + CFI_ENDPROC
3457 +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
3458 +index f4b9b80..198e774 100644
3459 +--- a/arch/x86/kernel/setup.c
3460 ++++ b/arch/x86/kernel/setup.c
3461 +@@ -919,8 +919,21 @@ void __init setup_arch(char **cmdline_p)
3462 +
3463 + #ifdef CONFIG_X86_64
3464 + if (max_pfn > max_low_pfn) {
3465 +- max_pfn_mapped = init_memory_mapping(1UL<<32,
3466 +- max_pfn<<PAGE_SHIFT);
3467 ++ int i;
3468 ++ for (i = 0; i < e820.nr_map; i++) {
3469 ++ struct e820entry *ei = &e820.map[i];
3470 ++
3471 ++ if (ei->addr + ei->size <= 1UL << 32)
3472 ++ continue;
3473 ++
3474 ++ if (ei->type == E820_RESERVED)
3475 ++ continue;
3476 ++
3477 ++ max_pfn_mapped = init_memory_mapping(
3478 ++ ei->addr < 1UL << 32 ? 1UL << 32 : ei->addr,
3479 ++ ei->addr + ei->size);
3480 ++ }
3481 ++
3482 + /* can we preseve max_low_pfn ?*/
3483 + max_low_pfn = max_pfn;
3484 + }
3485 +diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
3486 +index 26b8a85..48768df 100644
3487 +--- a/arch/x86/oprofile/nmi_int.c
3488 ++++ b/arch/x86/oprofile/nmi_int.c
3489 +@@ -55,7 +55,7 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
3490 + val |= counter_config->extra;
3491 + event &= model->event_mask ? model->event_mask : 0xFF;
3492 + val |= event & 0xFF;
3493 +- val |= (event & 0x0F00) << 24;
3494 ++ val |= (u64)(event & 0x0F00) << 24;
3495 +
3496 + return val;
3497 + }
3498 +diff --git a/arch/xtensa/include/asm/unistd.h b/arch/xtensa/include/asm/unistd.h
3499 +index bc7e005..6b3ff98 100644
3500 +--- a/arch/xtensa/include/asm/unistd.h
3501 ++++ b/arch/xtensa/include/asm/unistd.h
3502 +@@ -148,8 +148,8 @@ __SYSCALL( 59, sys_getdents, 3)
3503 + __SYSCALL( 60, sys_getdents64, 3)
3504 + #define __NR_fcntl64 61
3505 + __SYSCALL( 61, sys_fcntl64, 3)
3506 +-#define __NR_available62 62
3507 +-__SYSCALL( 62, sys_ni_syscall, 0)
3508 ++#define __NR_fallocate 62
3509 ++__SYSCALL( 62, sys_fallocate, 6)
3510 + #define __NR_fadvise64_64 63
3511 + __SYSCALL( 63, xtensa_fadvise64_64, 6)
3512 + #define __NR_utime 64 /* glibc 2.3.3 ?? */
3513 +@@ -264,8 +264,8 @@ __SYSCALL(112, sys_socketpair, 4)
3514 + __SYSCALL(113, sys_sendfile, 4)
3515 + #define __NR_sendfile64 114
3516 + __SYSCALL(114, sys_sendfile64, 4)
3517 +-#define __NR_available115 115
3518 +-__SYSCALL(115, sys_ni_syscall, 0)
3519 ++#define __NR_sendmmsg 115
3520 ++__SYSCALL(115, sys_sendmmsg, 4)
3521 +
3522 + /* Process Operations */
3523 +
3524 +@@ -380,11 +380,11 @@ __SYSCALL(168, sys_msgrcv, 4)
3525 + __SYSCALL(169, sys_msgctl, 4)
3526 + #define __NR_available170 170
3527 + __SYSCALL(170, sys_ni_syscall, 0)
3528 +-#define __NR_available171 171
3529 +-__SYSCALL(171, sys_ni_syscall, 0)
3530 +
3531 + /* File System */
3532 +
3533 ++#define __NR_umount2 171
3534 ++__SYSCALL(171, sys_umount, 2)
3535 + #define __NR_mount 172
3536 + __SYSCALL(172, sys_mount, 5)
3537 + #define __NR_swapon 173
3538 +@@ -399,8 +399,8 @@ __SYSCALL(176, sys_umount, 2)
3539 + __SYSCALL(177, sys_swapoff, 1)
3540 + #define __NR_sync 178
3541 + __SYSCALL(178, sys_sync, 0)
3542 +-#define __NR_available179 179
3543 +-__SYSCALL(179, sys_ni_syscall, 0)
3544 ++#define __NR_syncfs 179
3545 ++__SYSCALL(179, sys_syncfs, 1)
3546 + #define __NR_setfsuid 180
3547 + __SYSCALL(180, sys_setfsuid, 1)
3548 + #define __NR_setfsgid 181
3549 +@@ -455,7 +455,7 @@ __SYSCALL(203, sys_reboot, 3)
3550 + #define __NR_quotactl 204
3551 + __SYSCALL(204, sys_quotactl, 4)
3552 + #define __NR_nfsservctl 205
3553 +-__SYSCALL(205, sys_ni_syscall, 0)
3554 ++__SYSCALL(205, sys_ni_syscall, 0) /* old nfsservctl */
3555 + #define __NR__sysctl 206
3556 + __SYSCALL(206, sys_sysctl, 1)
3557 + #define __NR_bdflush 207
3558 +@@ -562,7 +562,7 @@ __SYSCALL(252, sys_timer_getoverrun, 1)
3559 +
3560 + /* System */
3561 +
3562 +-#define __NR_reserved244 253
3563 ++#define __NR_reserved253 253
3564 + __SYSCALL(253, sys_ni_syscall, 0)
3565 + #define __NR_lookup_dcookie 254
3566 + __SYSCALL(254, sys_lookup_dcookie, 4)
3567 +@@ -609,8 +609,8 @@ __SYSCALL(272, sys_pselect6, 0)
3568 + __SYSCALL(273, sys_ppoll, 0)
3569 + #define __NR_epoll_pwait 274
3570 + __SYSCALL(274, sys_epoll_pwait, 0)
3571 +-#define __NR_available275 275
3572 +-__SYSCALL(275, sys_ni_syscall, 0)
3573 ++#define __NR_epoll_create1 275
3574 ++__SYSCALL(275, sys_epoll_create1, 1)
3575 +
3576 + #define __NR_inotify_init 276
3577 + __SYSCALL(276, sys_inotify_init, 0)
3578 +@@ -618,8 +618,8 @@ __SYSCALL(276, sys_inotify_init, 0)
3579 + __SYSCALL(277, sys_inotify_add_watch, 3)
3580 + #define __NR_inotify_rm_watch 278
3581 + __SYSCALL(278, sys_inotify_rm_watch, 2)
3582 +-#define __NR_available279 279
3583 +-__SYSCALL(279, sys_ni_syscall, 0)
3584 ++#define __NR_inotify_init1 279
3585 ++__SYSCALL(279, sys_inotify_init1, 1)
3586 +
3587 + #define __NR_getcpu 280
3588 + __SYSCALL(280, sys_getcpu, 0)
3589 +@@ -635,10 +635,10 @@ __SYSCALL(283, sys_ioprio_get, 3)
3590 + __SYSCALL(284, sys_set_robust_list, 3)
3591 + #define __NR_get_robust_list 285
3592 + __SYSCALL(285, sys_get_robust_list, 3)
3593 +-#define __NR_reserved286 286 /* sync_file_rangeX */
3594 +-__SYSCALL(286, sys_ni_syscall, 3)
3595 ++#define __NR_available286 286
3596 ++__SYSCALL(286, sys_ni_syscall, 0)
3597 + #define __NR_available287 287
3598 +-__SYSCALL(287, sys_faccessat, 0)
3599 ++__SYSCALL(287, sys_ni_syscall, 0)
3600 +
3601 + /* Relative File Operations */
3602 +
3603 +@@ -683,10 +683,63 @@ __SYSCALL(305, sys_ni_syscall, 0)
3604 + __SYSCALL(306, sys_eventfd, 1)
3605 + #define __NR_recvmmsg 307
3606 + __SYSCALL(307, sys_recvmmsg, 5)
3607 ++
3608 + #define __NR_setns 308
3609 + __SYSCALL(308, sys_setns, 2)
3610 +-
3611 +-#define __NR_syscall_count 309
3612 ++#define __NR_signalfd4 309
3613 ++__SYSCALL(309, sys_signalfd4, 4)
3614 ++#define __NR_dup3 310
3615 ++__SYSCALL(310, sys_dup3, 3)
3616 ++#define __NR_pipe2 311
3617 ++__SYSCALL(311, sys_pipe2, 2)
3618 ++
3619 ++#define __NR_timerfd_create 312
3620 ++__SYSCALL(312, sys_timerfd_create, 2)
3621 ++#define __NR_timerfd_settime 313
3622 ++__SYSCALL(313, sys_timerfd_settime, 4)
3623 ++#define __NR_timerfd_gettime 314
3624 ++__SYSCALL(314, sys_timerfd_gettime, 2)
3625 ++#define __NR_available315 315
3626 ++__SYSCALL(315, sys_ni_syscall, 0)
3627 ++
3628 ++#define __NR_eventfd2 316
3629 ++__SYSCALL(316, sys_eventfd2, 2)
3630 ++#define __NR_preadv 317
3631 ++__SYSCALL(317, sys_preadv, 5)
3632 ++#define __NR_pwritev 318
3633 ++__SYSCALL(318, sys_pwritev, 5)
3634 ++#define __NR_available319 319
3635 ++__SYSCALL(319, sys_ni_syscall, 0)
3636 ++
3637 ++#define __NR_fanotify_init 320
3638 ++__SYSCALL(320, sys_fanotify_init, 2)
3639 ++#define __NR_fanotify_mark 321
3640 ++__SYSCALL(321, sys_fanotify_mark, 6)
3641 ++#define __NR_process_vm_readv 322
3642 ++__SYSCALL(322, sys_process_vm_readv, 6)
3643 ++#define __NR_process_vm_writev 323
3644 ++__SYSCALL(323, sys_process_vm_writev, 6)
3645 ++
3646 ++#define __NR_name_to_handle_at 324
3647 ++__SYSCALL(324, sys_name_to_handle_at, 5)
3648 ++#define __NR_open_by_handle_at 325
3649 ++__SYSCALL(325, sys_open_by_handle_at, 3)
3650 ++#define __NR_sync_file_range 326
3651 ++__SYSCALL(326, sys_sync_file_range2, 6)
3652 ++#define __NR_perf_event_open 327
3653 ++__SYSCALL(327, sys_perf_event_open, 5)
3654 ++
3655 ++#define __NR_rt_tgsigqueueinfo 328
3656 ++__SYSCALL(328, sys_rt_tgsigqueueinfo, 4)
3657 ++#define __NR_clock_adjtime 329
3658 ++__SYSCALL(329, sys_clock_adjtime, 2)
3659 ++#define __NR_prlimit64 330
3660 ++__SYSCALL(330, sys_prlimit64, 4)
3661 ++#define __NR_kcmp 331
3662 ++__SYSCALL(331, sys_kcmp, 5)
3663 ++
3664 ++
3665 ++#define __NR_syscall_count 332
3666 +
3667 + /*
3668 + * sysxtensa syscall handler
3669 +diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
3670 +index 5a297a2..cc8e7c7 100644
3671 +--- a/drivers/edac/amd64_edac.c
3672 ++++ b/drivers/edac/amd64_edac.c
3673 +@@ -170,8 +170,11 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
3674 + * memory controller and apply to register. Search for the first
3675 + * bandwidth entry that is greater or equal than the setting requested
3676 + * and program that. If at last entry, turn off DRAM scrubbing.
3677 ++ *
3678 ++ * If no suitable bandwidth is found, turn off DRAM scrubbing entirely
3679 ++ * by falling back to the last element in scrubrates[].
3680 + */
3681 +- for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
3682 ++ for (i = 0; i < ARRAY_SIZE(scrubrates) - 1; i++) {
3683 + /*
3684 + * skip scrub rates which aren't recommended
3685 + * (see F10 BKDG, F3x58)
3686 +@@ -181,12 +184,6 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
3687 +
3688 + if (scrubrates[i].bandwidth <= new_bw)
3689 + break;
3690 +-
3691 +- /*
3692 +- * if no suitable bandwidth found, turn off DRAM scrubbing
3693 +- * entirely by falling back to the last element in the
3694 +- * scrubrates array.
3695 +- */
3696 + }
3697 +
3698 + scrubval = scrubrates[i].scrubval;
3699 +diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
3700 +index ff2819e..cdf46b5 100644
3701 +--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
3702 ++++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
3703 +@@ -269,6 +269,7 @@ eb_destroy(struct eb_objects *eb)
3704 + static inline int use_cpu_reloc(struct drm_i915_gem_object *obj)
3705 + {
3706 + return (obj->base.write_domain == I915_GEM_DOMAIN_CPU ||
3707 ++ !obj->map_and_fenceable ||
3708 + obj->cache_level != I915_CACHE_NONE);
3709 + }
3710 +
3711 +diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
3712 +index 984a3f1..47b8d84 100644
3713 +--- a/drivers/hwmon/coretemp.c
3714 ++++ b/drivers/hwmon/coretemp.c
3715 +@@ -205,8 +205,11 @@ static const struct tjmax __cpuinitconst tjmax_table[] = {
3716 + { "CPU N455", 100000 },
3717 + { "CPU N470", 100000 },
3718 + { "CPU N475", 100000 },
3719 +- { "CPU 230", 100000 },
3720 +- { "CPU 330", 125000 },
3721 ++ { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */
3722 ++ { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */
3723 ++ { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 */
3724 ++ { "CPU CE4150", 110000 }, /* Model 0x1c, stepping 10 */
3725 ++ { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */
3726 + };
3727 +
3728 + static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
3729 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
3730 +index 7172559..d1febf0 100644
3731 +--- a/drivers/infiniband/core/cma.c
3732 ++++ b/drivers/infiniband/core/cma.c
3733 +@@ -3495,7 +3495,8 @@ out:
3734 + }
3735 +
3736 + static const struct ibnl_client_cbs cma_cb_table[] = {
3737 +- [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats },
3738 ++ [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats,
3739 ++ .module = THIS_MODULE },
3740 + };
3741 +
3742 + static int __init cma_init(void)
3743 +diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
3744 +index 3ae2bfd..53b43a5 100644
3745 +--- a/drivers/infiniband/core/netlink.c
3746 ++++ b/drivers/infiniband/core/netlink.c
3747 +@@ -154,6 +154,7 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
3748 + {
3749 + struct netlink_dump_control c = {
3750 + .dump = client->cb_table[op].dump,
3751 ++ .module = client->cb_table[op].module,
3752 + };
3753 + return netlink_dump_start(nls, skb, nlh, &c);
3754 + }
3755 +diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
3756 +index 2a4bb36..cef812a 100644
3757 +--- a/drivers/iommu/tegra-smmu.c
3758 ++++ b/drivers/iommu/tegra-smmu.c
3759 +@@ -146,7 +146,7 @@
3760 +
3761 + #define SMMU_ADDR_TO_PFN(addr) ((addr) >> 12)
3762 + #define SMMU_ADDR_TO_PDN(addr) ((addr) >> 22)
3763 +-#define SMMU_PDN_TO_ADDR(addr) ((pdn) << 22)
3764 ++#define SMMU_PDN_TO_ADDR(pdn) ((pdn) << 22)
3765 +
3766 + #define _READABLE (1 << SMMU_PTB_DATA_ASID_READABLE_SHIFT)
3767 + #define _WRITABLE (1 << SMMU_PTB_DATA_ASID_WRITABLE_SHIFT)
3768 +diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
3769 +index ac3dd73..902825a 100644
3770 +--- a/drivers/media/video/au0828/au0828-video.c
3771 ++++ b/drivers/media/video/au0828/au0828-video.c
3772 +@@ -1692,14 +1692,18 @@ static int vidioc_streamoff(struct file *file, void *priv,
3773 + (AUVI_INPUT(i).audio_setup)(dev, 0);
3774 + }
3775 +
3776 +- videobuf_streamoff(&fh->vb_vidq);
3777 +- res_free(fh, AU0828_RESOURCE_VIDEO);
3778 ++ if (res_check(fh, AU0828_RESOURCE_VIDEO)) {
3779 ++ videobuf_streamoff(&fh->vb_vidq);
3780 ++ res_free(fh, AU0828_RESOURCE_VIDEO);
3781 ++ }
3782 + } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
3783 + dev->vbi_timeout_running = 0;
3784 + del_timer_sync(&dev->vbi_timeout);
3785 +
3786 +- videobuf_streamoff(&fh->vb_vbiq);
3787 +- res_free(fh, AU0828_RESOURCE_VBI);
3788 ++ if (res_check(fh, AU0828_RESOURCE_VBI)) {
3789 ++ videobuf_streamoff(&fh->vb_vbiq);
3790 ++ res_free(fh, AU0828_RESOURCE_VBI);
3791 ++ }
3792 + }
3793 +
3794 + return 0;
3795 +diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
3796 +index 2b4b4f5..16814b3 100644
3797 +--- a/drivers/net/ethernet/calxeda/xgmac.c
3798 ++++ b/drivers/net/ethernet/calxeda/xgmac.c
3799 +@@ -375,7 +375,6 @@ struct xgmac_priv {
3800 + unsigned int tx_tail;
3801 +
3802 + void __iomem *base;
3803 +- struct sk_buff_head rx_recycle;
3804 + unsigned int dma_buf_sz;
3805 + dma_addr_t dma_rx_phy;
3806 + dma_addr_t dma_tx_phy;
3807 +@@ -672,9 +671,7 @@ static void xgmac_rx_refill(struct xgmac_priv *priv)
3808 + p = priv->dma_rx + entry;
3809 +
3810 + if (priv->rx_skbuff[entry] == NULL) {
3811 +- skb = __skb_dequeue(&priv->rx_recycle);
3812 +- if (skb == NULL)
3813 +- skb = netdev_alloc_skb(priv->dev, priv->dma_buf_sz);
3814 ++ skb = netdev_alloc_skb(priv->dev, priv->dma_buf_sz);
3815 + if (unlikely(skb == NULL))
3816 + break;
3817 +
3818 +@@ -887,17 +884,7 @@ static void xgmac_tx_complete(struct xgmac_priv *priv)
3819 + desc_get_buf_len(p), DMA_TO_DEVICE);
3820 + }
3821 +
3822 +- /*
3823 +- * If there's room in the queue (limit it to size)
3824 +- * we add this skb back into the pool,
3825 +- * if it's the right size.
3826 +- */
3827 +- if ((skb_queue_len(&priv->rx_recycle) <
3828 +- DMA_RX_RING_SZ) &&
3829 +- skb_recycle_check(skb, priv->dma_buf_sz))
3830 +- __skb_queue_head(&priv->rx_recycle, skb);
3831 +- else
3832 +- dev_kfree_skb(skb);
3833 ++ dev_kfree_skb(skb);
3834 + }
3835 +
3836 + if (dma_ring_space(priv->tx_head, priv->tx_tail, DMA_TX_RING_SZ) >
3837 +@@ -1016,7 +1003,6 @@ static int xgmac_open(struct net_device *dev)
3838 + dev->dev_addr);
3839 + }
3840 +
3841 +- skb_queue_head_init(&priv->rx_recycle);
3842 + memset(&priv->xstats, 0, sizeof(struct xgmac_extra_stats));
3843 +
3844 + /* Initialize the XGMAC and descriptors */
3845 +@@ -1053,7 +1039,6 @@ static int xgmac_stop(struct net_device *dev)
3846 + napi_disable(&priv->napi);
3847 +
3848 + writel(0, priv->base + XGMAC_DMA_INTR_ENA);
3849 +- skb_queue_purge(&priv->rx_recycle);
3850 +
3851 + /* Disable the MAC core */
3852 + xgmac_mac_disable(priv->base);
3853 +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
3854 +index d3233f5..e0ef1e5 100644
3855 +--- a/drivers/net/ethernet/freescale/gianfar.c
3856 ++++ b/drivers/net/ethernet/freescale/gianfar.c
3857 +@@ -1757,7 +1757,6 @@ static void free_skb_resources(struct gfar_private *priv)
3858 + sizeof(struct rxbd8) * priv->total_rx_ring_size,
3859 + priv->tx_queue[0]->tx_bd_base,
3860 + priv->tx_queue[0]->tx_bd_dma_base);
3861 +- skb_queue_purge(&priv->rx_recycle);
3862 + }
3863 +
3864 + void gfar_start(struct net_device *dev)
3865 +@@ -1935,8 +1934,6 @@ static int gfar_enet_open(struct net_device *dev)
3866 +
3867 + enable_napi(priv);
3868 +
3869 +- skb_queue_head_init(&priv->rx_recycle);
3870 +-
3871 + /* Initialize a bunch of registers */
3872 + init_registers(dev);
3873 +
3874 +@@ -2525,16 +2522,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
3875 +
3876 + bytes_sent += skb->len;
3877 +
3878 +- /* If there's room in the queue (limit it to rx_buffer_size)
3879 +- * we add this skb back into the pool, if it's the right size
3880 +- */
3881 +- if (skb_queue_len(&priv->rx_recycle) < rx_queue->rx_ring_size &&
3882 +- skb_recycle_check(skb, priv->rx_buffer_size +
3883 +- RXBUF_ALIGNMENT)) {
3884 +- gfar_align_skb(skb);
3885 +- skb_queue_head(&priv->rx_recycle, skb);
3886 +- } else
3887 +- dev_kfree_skb_any(skb);
3888 ++ dev_kfree_skb_any(skb);
3889 +
3890 + tx_queue->tx_skbuff[skb_dirtytx] = NULL;
3891 +
3892 +@@ -2600,7 +2588,7 @@ static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
3893 + static struct sk_buff *gfar_alloc_skb(struct net_device *dev)
3894 + {
3895 + struct gfar_private *priv = netdev_priv(dev);
3896 +- struct sk_buff *skb = NULL;
3897 ++ struct sk_buff *skb;
3898 +
3899 + skb = netdev_alloc_skb(dev, priv->rx_buffer_size + RXBUF_ALIGNMENT);
3900 + if (!skb)
3901 +@@ -2613,14 +2601,7 @@ static struct sk_buff *gfar_alloc_skb(struct net_device *dev)
3902 +
3903 + struct sk_buff *gfar_new_skb(struct net_device *dev)
3904 + {
3905 +- struct gfar_private *priv = netdev_priv(dev);
3906 +- struct sk_buff *skb = NULL;
3907 +-
3908 +- skb = skb_dequeue(&priv->rx_recycle);
3909 +- if (!skb)
3910 +- skb = gfar_alloc_skb(dev);
3911 +-
3912 +- return skb;
3913 ++ return gfar_alloc_skb(dev);
3914 + }
3915 +
3916 + static inline void count_errors(unsigned short status, struct net_device *dev)
3917 +@@ -2779,7 +2760,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
3918 + if (unlikely(!newskb))
3919 + newskb = skb;
3920 + else if (skb)
3921 +- skb_queue_head(&priv->rx_recycle, skb);
3922 ++ dev_kfree_skb(skb);
3923 + } else {
3924 + /* Increment the number of packets */
3925 + rx_queue->stats.rx_packets++;
3926 +diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
3927 +index 2136c7f..27d8aeb 100644
3928 +--- a/drivers/net/ethernet/freescale/gianfar.h
3929 ++++ b/drivers/net/ethernet/freescale/gianfar.h
3930 +@@ -1072,8 +1072,6 @@ struct gfar_private {
3931 +
3932 + u32 cur_filer_idx;
3933 +
3934 +- struct sk_buff_head rx_recycle;
3935 +-
3936 + /* RX queue filer rule set*/
3937 + struct ethtool_rx_list rx_list;
3938 + struct mutex rx_queue_access;
3939 +diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
3940 +index 21c6574..f6259ff 100644
3941 +--- a/drivers/net/ethernet/freescale/ucc_geth.c
3942 ++++ b/drivers/net/ethernet/freescale/ucc_geth.c
3943 +@@ -210,14 +210,12 @@ static struct list_head *dequeue(struct list_head *lh)
3944 + static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth,
3945 + u8 __iomem *bd)
3946 + {
3947 +- struct sk_buff *skb = NULL;
3948 ++ struct sk_buff *skb;
3949 +
3950 +- skb = __skb_dequeue(&ugeth->rx_recycle);
3951 ++ skb = netdev_alloc_skb(ugeth->ndev,
3952 ++ ugeth->ug_info->uf_info.max_rx_buf_length +
3953 ++ UCC_GETH_RX_DATA_BUF_ALIGNMENT);
3954 + if (!skb)
3955 +- skb = netdev_alloc_skb(ugeth->ndev,
3956 +- ugeth->ug_info->uf_info.max_rx_buf_length +
3957 +- UCC_GETH_RX_DATA_BUF_ALIGNMENT);
3958 +- if (skb == NULL)
3959 + return NULL;
3960 +
3961 + /* We need the data buffer to be aligned properly. We will reserve
3962 +@@ -2021,8 +2019,6 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
3963 + iounmap(ugeth->ug_regs);
3964 + ugeth->ug_regs = NULL;
3965 + }
3966 +-
3967 +- skb_queue_purge(&ugeth->rx_recycle);
3968 + }
3969 +
3970 + static void ucc_geth_set_multi(struct net_device *dev)
3971 +@@ -2231,8 +2227,6 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
3972 + return -ENOMEM;
3973 + }
3974 +
3975 +- skb_queue_head_init(&ugeth->rx_recycle);
3976 +-
3977 + return 0;
3978 + }
3979 +
3980 +@@ -3275,12 +3269,7 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3981 + if (netif_msg_rx_err(ugeth))
3982 + ugeth_err("%s, %d: ERROR!!! skb - 0x%08x",
3983 + __func__, __LINE__, (u32) skb);
3984 +- if (skb) {
3985 +- skb->data = skb->head + NET_SKB_PAD;
3986 +- skb->len = 0;
3987 +- skb_reset_tail_pointer(skb);
3988 +- __skb_queue_head(&ugeth->rx_recycle, skb);
3989 +- }
3990 ++ dev_kfree_skb(skb);
3991 +
3992 + ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]] = NULL;
3993 + dev->stats.rx_dropped++;
3994 +@@ -3350,13 +3339,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3995 +
3996 + dev->stats.tx_packets++;
3997 +
3998 +- if (skb_queue_len(&ugeth->rx_recycle) < RX_BD_RING_LEN &&
3999 +- skb_recycle_check(skb,
4000 +- ugeth->ug_info->uf_info.max_rx_buf_length +
4001 +- UCC_GETH_RX_DATA_BUF_ALIGNMENT))
4002 +- __skb_queue_head(&ugeth->rx_recycle, skb);
4003 +- else
4004 +- dev_kfree_skb(skb);
4005 ++ dev_kfree_skb(skb);
4006 +
4007 + ugeth->tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]] = NULL;
4008 + ugeth->skb_dirtytx[txQ] =
4009 +diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethernet/freescale/ucc_geth.h
4010 +index f71b3e7..75f3371 100644
4011 +--- a/drivers/net/ethernet/freescale/ucc_geth.h
4012 ++++ b/drivers/net/ethernet/freescale/ucc_geth.h
4013 +@@ -1214,8 +1214,6 @@ struct ucc_geth_private {
4014 + /* index of the first skb which hasn't been transmitted yet. */
4015 + u16 skb_dirtytx[NUM_TX_QUEUES];
4016 +
4017 +- struct sk_buff_head rx_recycle;
4018 +-
4019 + struct ugeth_mii_info *mii_info;
4020 + struct phy_device *phydev;
4021 + phy_interface_t phy_interface;
4022 +diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
4023 +index 087b9e0..84c1326 100644
4024 +--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
4025 ++++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
4026 +@@ -412,7 +412,6 @@ struct mv643xx_eth_private {
4027 + u8 work_rx_refill;
4028 +
4029 + int skb_size;
4030 +- struct sk_buff_head rx_recycle;
4031 +
4032 + /*
4033 + * RX state.
4034 +@@ -673,9 +672,7 @@ static int rxq_refill(struct rx_queue *rxq, int budget)
4035 + struct rx_desc *rx_desc;
4036 + int size;
4037 +
4038 +- skb = __skb_dequeue(&mp->rx_recycle);
4039 +- if (skb == NULL)
4040 +- skb = netdev_alloc_skb(mp->dev, mp->skb_size);
4041 ++ skb = netdev_alloc_skb(mp->dev, mp->skb_size);
4042 +
4043 + if (skb == NULL) {
4044 + mp->oom = 1;
4045 +@@ -989,14 +986,7 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
4046 + desc->byte_cnt, DMA_TO_DEVICE);
4047 + }
4048 +
4049 +- if (skb != NULL) {
4050 +- if (skb_queue_len(&mp->rx_recycle) <
4051 +- mp->rx_ring_size &&
4052 +- skb_recycle_check(skb, mp->skb_size))
4053 +- __skb_queue_head(&mp->rx_recycle, skb);
4054 +- else
4055 +- dev_kfree_skb(skb);
4056 +- }
4057 ++ dev_kfree_skb(skb);
4058 + }
4059 +
4060 + __netif_tx_unlock(nq);
4061 +@@ -2349,8 +2339,6 @@ static int mv643xx_eth_open(struct net_device *dev)
4062 +
4063 + napi_enable(&mp->napi);
4064 +
4065 +- skb_queue_head_init(&mp->rx_recycle);
4066 +-
4067 + mp->int_mask = INT_EXT;
4068 +
4069 + for (i = 0; i < mp->rxq_count; i++) {
4070 +@@ -2445,8 +2433,6 @@ static int mv643xx_eth_stop(struct net_device *dev)
4071 + mib_counters_update(mp);
4072 + del_timer_sync(&mp->mib_counters_timer);
4073 +
4074 +- skb_queue_purge(&mp->rx_recycle);
4075 +-
4076 + for (i = 0; i < mp->rxq_count; i++)
4077 + rxq_deinit(mp->rxq + i);
4078 + for (i = 0; i < mp->txq_count; i++)
4079 +diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
4080 +index 5a30bf8..f4be8f7 100644
4081 +--- a/drivers/net/ethernet/marvell/skge.c
4082 ++++ b/drivers/net/ethernet/marvell/skge.c
4083 +@@ -4153,6 +4153,13 @@ static struct dmi_system_id skge_32bit_dma_boards[] = {
4084 + DMI_MATCH(DMI_BOARD_NAME, "nForce"),
4085 + },
4086 + },
4087 ++ {
4088 ++ .ident = "ASUS P5NSLI",
4089 ++ .matches = {
4090 ++ DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
4091 ++ DMI_MATCH(DMI_BOARD_NAME, "P5NSLI")
4092 ++ },
4093 ++ },
4094 + {}
4095 + };
4096 +
4097 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
4098 +index e872e1d..7d51a65 100644
4099 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
4100 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
4101 +@@ -50,7 +50,6 @@ struct stmmac_priv {
4102 + unsigned int dirty_rx;
4103 + struct sk_buff **rx_skbuff;
4104 + dma_addr_t *rx_skbuff_dma;
4105 +- struct sk_buff_head rx_recycle;
4106 +
4107 + struct net_device *dev;
4108 + dma_addr_t dma_rx_phy;
4109 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
4110 +index 3be8833..c6cdbc4 100644
4111 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
4112 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
4113 +@@ -747,18 +747,7 @@ static void stmmac_tx(struct stmmac_priv *priv)
4114 + priv->hw->ring->clean_desc3(p);
4115 +
4116 + if (likely(skb != NULL)) {
4117 +- /*
4118 +- * If there's room in the queue (limit it to size)
4119 +- * we add this skb back into the pool,
4120 +- * if it's the right size.
4121 +- */
4122 +- if ((skb_queue_len(&priv->rx_recycle) <
4123 +- priv->dma_rx_size) &&
4124 +- skb_recycle_check(skb, priv->dma_buf_sz))
4125 +- __skb_queue_head(&priv->rx_recycle, skb);
4126 +- else
4127 +- dev_kfree_skb(skb);
4128 +-
4129 ++ dev_kfree_skb(skb);
4130 + priv->tx_skbuff[entry] = NULL;
4131 + }
4132 +
4133 +@@ -1169,7 +1158,6 @@ static int stmmac_open(struct net_device *dev)
4134 + priv->eee_enabled = stmmac_eee_init(priv);
4135 +
4136 + napi_enable(&priv->napi);
4137 +- skb_queue_head_init(&priv->rx_recycle);
4138 + netif_start_queue(dev);
4139 +
4140 + return 0;
4141 +@@ -1222,7 +1210,6 @@ static int stmmac_release(struct net_device *dev)
4142 + kfree(priv->tm);
4143 + #endif
4144 + napi_disable(&priv->napi);
4145 +- skb_queue_purge(&priv->rx_recycle);
4146 +
4147 + /* Free the IRQ lines */
4148 + free_irq(dev->irq, dev);
4149 +@@ -1388,10 +1375,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
4150 + if (likely(priv->rx_skbuff[entry] == NULL)) {
4151 + struct sk_buff *skb;
4152 +
4153 +- skb = __skb_dequeue(&priv->rx_recycle);
4154 +- if (skb == NULL)
4155 +- skb = netdev_alloc_skb_ip_align(priv->dev,
4156 +- bfsize);
4157 ++ skb = netdev_alloc_skb_ip_align(priv->dev, bfsize);
4158 +
4159 + if (unlikely(skb == NULL))
4160 + break;
4161 +diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
4162 +index b066273..7dd879c 100644
4163 +--- a/drivers/pcmcia/pxa2xx_sharpsl.c
4164 ++++ b/drivers/pcmcia/pxa2xx_sharpsl.c
4165 +@@ -194,7 +194,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
4166 + sharpsl_pcmcia_init_reset(skt);
4167 + }
4168 +
4169 +-static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = {
4170 ++static struct pcmcia_low_level sharpsl_pcmcia_ops = {
4171 + .owner = THIS_MODULE,
4172 + .hw_init = sharpsl_pcmcia_hw_init,
4173 + .socket_state = sharpsl_pcmcia_socket_state,
4174 +diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
4175 +index dc5c126..63560c3 100644
4176 +--- a/drivers/pinctrl/core.c
4177 ++++ b/drivers/pinctrl/core.c
4178 +@@ -1059,8 +1059,10 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
4179 + seq_printf(s, "group: %s\n", gname);
4180 + for (i = 0; i < num_pins; i++) {
4181 + pname = pin_get_name(pctldev, pins[i]);
4182 +- if (WARN_ON(!pname))
4183 ++ if (WARN_ON(!pname)) {
4184 ++ mutex_unlock(&pinctrl_mutex);
4185 + return -EINVAL;
4186 ++ }
4187 + seq_printf(s, "pin %d (%s)\n", pins[i], pname);
4188 + }
4189 + seq_puts(s, "\n");
4190 +diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
4191 +index 43f474c..baee2cc 100644
4192 +--- a/drivers/pinctrl/pinconf.c
4193 ++++ b/drivers/pinctrl/pinconf.c
4194 +@@ -537,8 +537,6 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
4195 + seq_puts(s, "Pin config settings per pin group\n");
4196 + seq_puts(s, "Format: group (name): configs\n");
4197 +
4198 +- mutex_lock(&pinctrl_mutex);
4199 +-
4200 + while (selector < ngroups) {
4201 + const char *gname = pctlops->get_group_name(pctldev, selector);
4202 +
4203 +@@ -549,8 +547,6 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
4204 + selector++;
4205 + }
4206 +
4207 +- mutex_unlock(&pinctrl_mutex);
4208 +-
4209 + return 0;
4210 + }
4211 +
4212 +diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
4213 +index ae52e4e..5a5f261 100644
4214 +--- a/drivers/pinctrl/pinctrl-tegra.c
4215 ++++ b/drivers/pinctrl/pinctrl-tegra.c
4216 +@@ -466,7 +466,7 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx,
4217 + *bank = g->drv_bank;
4218 + *reg = g->drv_reg;
4219 + *bit = g->lpmd_bit;
4220 +- *width = 1;
4221 ++ *width = 2;
4222 + break;
4223 + case TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH:
4224 + *bank = g->drv_bank;
4225 +diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c
4226 +index 0386fdf..7894f14 100644
4227 +--- a/drivers/pinctrl/pinctrl-tegra30.c
4228 ++++ b/drivers/pinctrl/pinctrl-tegra30.c
4229 +@@ -3345,10 +3345,10 @@ static const struct tegra_function tegra30_functions[] = {
4230 + FUNCTION(vi_alt3),
4231 + };
4232 +
4233 +-#define MUXCTL_REG_A 0x3000
4234 +-#define PINGROUP_REG_A 0x868
4235 ++#define DRV_PINGROUP_REG_A 0x868 /* bank 0 */
4236 ++#define PINGROUP_REG_A 0x3000 /* bank 1 */
4237 +
4238 +-#define PINGROUP_REG_Y(r) ((r) - MUXCTL_REG_A)
4239 ++#define PINGROUP_REG_Y(r) ((r) - PINGROUP_REG_A)
4240 + #define PINGROUP_REG_N(r) -1
4241 +
4242 + #define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior) \
4243 +@@ -3364,25 +3364,25 @@ static const struct tegra_function tegra30_functions[] = {
4244 + }, \
4245 + .func_safe = TEGRA_MUX_ ## f_safe, \
4246 + .mux_reg = PINGROUP_REG_Y(r), \
4247 +- .mux_bank = 0, \
4248 ++ .mux_bank = 1, \
4249 + .mux_bit = 0, \
4250 + .pupd_reg = PINGROUP_REG_Y(r), \
4251 +- .pupd_bank = 0, \
4252 ++ .pupd_bank = 1, \
4253 + .pupd_bit = 2, \
4254 + .tri_reg = PINGROUP_REG_Y(r), \
4255 +- .tri_bank = 0, \
4256 ++ .tri_bank = 1, \
4257 + .tri_bit = 4, \
4258 + .einput_reg = PINGROUP_REG_Y(r), \
4259 +- .einput_bank = 0, \
4260 ++ .einput_bank = 1, \
4261 + .einput_bit = 5, \
4262 + .odrain_reg = PINGROUP_REG_##od(r), \
4263 +- .odrain_bank = 0, \
4264 ++ .odrain_bank = 1, \
4265 + .odrain_bit = 6, \
4266 + .lock_reg = PINGROUP_REG_Y(r), \
4267 +- .lock_bank = 0, \
4268 ++ .lock_bank = 1, \
4269 + .lock_bit = 7, \
4270 + .ioreset_reg = PINGROUP_REG_##ior(r), \
4271 +- .ioreset_bank = 0, \
4272 ++ .ioreset_bank = 1, \
4273 + .ioreset_bit = 8, \
4274 + .drv_reg = -1, \
4275 + }
4276 +@@ -3401,8 +3401,8 @@ static const struct tegra_function tegra30_functions[] = {
4277 + .odrain_reg = -1, \
4278 + .lock_reg = -1, \
4279 + .ioreset_reg = -1, \
4280 +- .drv_reg = ((r) - PINGROUP_REG_A), \
4281 +- .drv_bank = 1, \
4282 ++ .drv_reg = ((r) - DRV_PINGROUP_REG_A), \
4283 ++ .drv_bank = 0, \
4284 + .hsm_bit = hsm_b, \
4285 + .schmitt_bit = schmitt_b, \
4286 + .lpmd_bit = lpmd_b, \
4287 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
4288 +index e8007b8..84f7dff 100644
4289 +--- a/drivers/usb/class/cdc-acm.c
4290 ++++ b/drivers/usb/class/cdc-acm.c
4291 +@@ -818,10 +818,6 @@ static const __u32 acm_tty_speed[] = {
4292 + 2500000, 3000000, 3500000, 4000000
4293 + };
4294 +
4295 +-static const __u8 acm_tty_size[] = {
4296 +- 5, 6, 7, 8
4297 +-};
4298 +-
4299 + static void acm_tty_set_termios(struct tty_struct *tty,
4300 + struct ktermios *termios_old)
4301 + {
4302 +@@ -835,7 +831,21 @@ static void acm_tty_set_termios(struct tty_struct *tty,
4303 + newline.bParityType = termios->c_cflag & PARENB ?
4304 + (termios->c_cflag & PARODD ? 1 : 2) +
4305 + (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
4306 +- newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
4307 ++ switch (termios->c_cflag & CSIZE) {
4308 ++ case CS5:
4309 ++ newline.bDataBits = 5;
4310 ++ break;
4311 ++ case CS6:
4312 ++ newline.bDataBits = 6;
4313 ++ break;
4314 ++ case CS7:
4315 ++ newline.bDataBits = 7;
4316 ++ break;
4317 ++ case CS8:
4318 ++ default:
4319 ++ newline.bDataBits = 8;
4320 ++ break;
4321 ++ }
4322 + /* FIXME: Needs to clear unsupported bits in the termios */
4323 + acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
4324 +
4325 +@@ -1234,7 +1244,7 @@ made_compressed_probe:
4326 +
4327 + if (usb_endpoint_xfer_int(epwrite))
4328 + usb_fill_int_urb(snd->urb, usb_dev,
4329 +- usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
4330 ++ usb_sndintpipe(usb_dev, epwrite->bEndpointAddress),
4331 + NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
4332 + else
4333 + usb_fill_bulk_urb(snd->urb, usb_dev,
4334 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
4335 +index ebb8a9d..7f75343 100644
4336 +--- a/drivers/usb/core/devio.c
4337 ++++ b/drivers/usb/core/devio.c
4338 +@@ -1348,6 +1348,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
4339 + ret = -EFAULT;
4340 + goto error;
4341 + }
4342 ++ uurb->buffer += u;
4343 + }
4344 + totlen -= u;
4345 + }
4346 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
4347 +index 445455a..fb6e97f 100644
4348 +--- a/drivers/usb/core/driver.c
4349 ++++ b/drivers/usb/core/driver.c
4350 +@@ -372,6 +372,10 @@ static int usb_probe_interface(struct device *dev)
4351 + intf->condition = USB_INTERFACE_UNBOUND;
4352 + usb_cancel_queued_reset(intf);
4353 +
4354 ++ /* If the LPM disable succeeded, balance the ref counts. */
4355 ++ if (!lpm_disable_error)
4356 ++ usb_unlocked_enable_lpm(udev);
4357 ++
4358 + /* Unbound interfaces are always runtime-PM-disabled and -suspended */
4359 + if (driver->supports_autosuspend)
4360 + pm_runtime_disable(dev);
4361 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
4362 +index 128a804..bbff143 100644
4363 +--- a/drivers/usb/core/hub.c
4364 ++++ b/drivers/usb/core/hub.c
4365 +@@ -3258,16 +3258,6 @@ static int usb_set_device_initiated_lpm(struct usb_device *udev,
4366 +
4367 + if (enable) {
4368 + /*
4369 +- * First, let the device know about the exit latencies
4370 +- * associated with the link state we're about to enable.
4371 +- */
4372 +- ret = usb_req_set_sel(udev, state);
4373 +- if (ret < 0) {
4374 +- dev_warn(&udev->dev, "Set SEL for device-initiated "
4375 +- "%s failed.\n", usb3_lpm_names[state]);
4376 +- return -EBUSY;
4377 +- }
4378 +- /*
4379 + * Now send the control transfer to enable device-initiated LPM
4380 + * for either U1 or U2.
4381 + */
4382 +@@ -3352,7 +3342,28 @@ static int usb_set_lpm_timeout(struct usb_device *udev,
4383 + static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
4384 + enum usb3_link_state state)
4385 + {
4386 +- int timeout;
4387 ++ int timeout, ret;
4388 ++ __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat;
4389 ++ __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat;
4390 ++
4391 ++ /* If the device says it doesn't have *any* exit latency to come out of
4392 ++ * U1 or U2, it's probably lying. Assume it doesn't implement that link
4393 ++ * state.
4394 ++ */
4395 ++ if ((state == USB3_LPM_U1 && u1_mel == 0) ||
4396 ++ (state == USB3_LPM_U2 && u2_mel == 0))
4397 ++ return;
4398 ++
4399 ++ /*
4400 ++ * First, let the device know about the exit latencies
4401 ++ * associated with the link state we're about to enable.
4402 ++ */
4403 ++ ret = usb_req_set_sel(udev, state);
4404 ++ if (ret < 0) {
4405 ++ dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n",
4406 ++ usb3_lpm_names[state]);
4407 ++ return;
4408 ++ }
4409 +
4410 + /* We allow the host controller to set the U1/U2 timeout internally
4411 + * first, so that it can change its schedule to account for the
4412 +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
4413 +index c2813c2b..eb0fd10 100644
4414 +--- a/drivers/usb/dwc3/gadget.c
4415 ++++ b/drivers/usb/dwc3/gadget.c
4416 +@@ -1899,6 +1899,7 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum)
4417 + ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
4418 + WARN_ON_ONCE(ret);
4419 + dep->resource_index = 0;
4420 ++ dep->flags &= ~DWC3_EP_BUSY;
4421 + }
4422 +
4423 + static void dwc3_stop_active_transfers(struct dwc3 *dwc)
4424 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4425 +index a49868d..0644f65 100644
4426 +--- a/drivers/usb/host/xhci.c
4427 ++++ b/drivers/usb/host/xhci.c
4428 +@@ -479,7 +479,8 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
4429 +
4430 + if (strstr(dmi_product_name, "Z420") ||
4431 + strstr(dmi_product_name, "Z620") ||
4432 +- strstr(dmi_product_name, "Z820"))
4433 ++ strstr(dmi_product_name, "Z820") ||
4434 ++ strstr(dmi_product_name, "Z1"))
4435 + return true;
4436 +
4437 + return false;
4438 +diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
4439 +index 7a95ab8..ee9ec13 100644
4440 +--- a/drivers/usb/musb/am35x.c
4441 ++++ b/drivers/usb/musb/am35x.c
4442 +@@ -312,6 +312,12 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
4443 + ret = IRQ_HANDLED;
4444 + }
4445 +
4446 ++ /* Drop spurious RX and TX if device is disconnected */
4447 ++ if (musb->int_usb & MUSB_INTR_DISCONNECT) {
4448 ++ musb->int_tx = 0;
4449 ++ musb->int_rx = 0;
4450 ++ }
4451 ++
4452 + if (musb->int_tx || musb->int_rx || musb->int_usb)
4453 + ret |= musb_interrupt(musb);
4454 +
4455 +diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
4456 +index f8ce97d..a6758ff 100644
4457 +--- a/drivers/usb/serial/ark3116.c
4458 ++++ b/drivers/usb/serial/ark3116.c
4459 +@@ -126,9 +126,6 @@ static inline int calc_divisor(int bps)
4460 +
4461 + static int ark3116_attach(struct usb_serial *serial)
4462 + {
4463 +- struct usb_serial_port *port = serial->port[0];
4464 +- struct ark3116_private *priv;
4465 +-
4466 + /* make sure we have our end-points */
4467 + if ((serial->num_bulk_in == 0) ||
4468 + (serial->num_bulk_out == 0) ||
4469 +@@ -143,8 +140,15 @@ static int ark3116_attach(struct usb_serial *serial)
4470 + return -EINVAL;
4471 + }
4472 +
4473 +- priv = kzalloc(sizeof(struct ark3116_private),
4474 +- GFP_KERNEL);
4475 ++ return 0;
4476 ++}
4477 ++
4478 ++static int ark3116_port_probe(struct usb_serial_port *port)
4479 ++{
4480 ++ struct usb_serial *serial = port->serial;
4481 ++ struct ark3116_private *priv;
4482 ++
4483 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
4484 + if (!priv)
4485 + return -ENOMEM;
4486 +
4487 +@@ -199,18 +203,15 @@ static int ark3116_attach(struct usb_serial *serial)
4488 + return 0;
4489 + }
4490 +
4491 +-static void ark3116_release(struct usb_serial *serial)
4492 ++static int ark3116_port_remove(struct usb_serial_port *port)
4493 + {
4494 +- struct usb_serial_port *port = serial->port[0];
4495 + struct ark3116_private *priv = usb_get_serial_port_data(port);
4496 +
4497 + /* device is closed, so URBs and DMA should be down */
4498 +-
4499 +- usb_set_serial_port_data(port, NULL);
4500 +-
4501 + mutex_destroy(&priv->hw_lock);
4502 +-
4503 + kfree(priv);
4504 ++
4505 ++ return 0;
4506 + }
4507 +
4508 + static void ark3116_init_termios(struct tty_struct *tty)
4509 +@@ -725,7 +726,8 @@ static struct usb_serial_driver ark3116_device = {
4510 + .id_table = id_table,
4511 + .num_ports = 1,
4512 + .attach = ark3116_attach,
4513 +- .release = ark3116_release,
4514 ++ .port_probe = ark3116_port_probe,
4515 ++ .port_remove = ark3116_port_remove,
4516 + .set_termios = ark3116_set_termios,
4517 + .init_termios = ark3116_init_termios,
4518 + .ioctl = ark3116_ioctl,
4519 +diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
4520 +index 6b73656..89a3dd3 100644
4521 +--- a/drivers/usb/serial/belkin_sa.c
4522 ++++ b/drivers/usb/serial/belkin_sa.c
4523 +@@ -47,8 +47,8 @@ static bool debug;
4524 + #define DRIVER_DESC "USB Belkin Serial converter driver"
4525 +
4526 + /* function prototypes for a Belkin USB Serial Adapter F5U103 */
4527 +-static int belkin_sa_startup(struct usb_serial *serial);
4528 +-static void belkin_sa_release(struct usb_serial *serial);
4529 ++static int belkin_sa_port_probe(struct usb_serial_port *port);
4530 ++static int belkin_sa_port_remove(struct usb_serial_port *port);
4531 + static int belkin_sa_open(struct tty_struct *tty,
4532 + struct usb_serial_port *port);
4533 + static void belkin_sa_close(struct usb_serial_port *port);
4534 +@@ -90,8 +90,8 @@ static struct usb_serial_driver belkin_device = {
4535 + .break_ctl = belkin_sa_break_ctl,
4536 + .tiocmget = belkin_sa_tiocmget,
4537 + .tiocmset = belkin_sa_tiocmset,
4538 +- .attach = belkin_sa_startup,
4539 +- .release = belkin_sa_release,
4540 ++ .port_probe = belkin_sa_port_probe,
4541 ++ .port_remove = belkin_sa_port_remove,
4542 + };
4543 +
4544 + static struct usb_serial_driver * const serial_drivers[] = {
4545 +@@ -120,17 +120,15 @@ struct belkin_sa_private {
4546 + (c), BELKIN_SA_SET_REQUEST_TYPE, \
4547 + (v), 0, NULL, 0, WDR_TIMEOUT)
4548 +
4549 +-/* do some startup allocations not currently performed by usb_serial_probe() */
4550 +-static int belkin_sa_startup(struct usb_serial *serial)
4551 ++static int belkin_sa_port_probe(struct usb_serial_port *port)
4552 + {
4553 +- struct usb_device *dev = serial->dev;
4554 ++ struct usb_device *dev = port->serial->dev;
4555 + struct belkin_sa_private *priv;
4556 +
4557 +- /* allocate the private data structure */
4558 + priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
4559 + if (!priv)
4560 +- return -1; /* error */
4561 +- /* set initial values for control structures */
4562 ++ return -ENOMEM;
4563 ++
4564 + spin_lock_init(&priv->lock);
4565 + priv->control_state = 0;
4566 + priv->last_lsr = 0;
4567 +@@ -142,18 +140,19 @@ static int belkin_sa_startup(struct usb_serial *serial)
4568 + le16_to_cpu(dev->descriptor.bcdDevice),
4569 + priv->bad_flow_control);
4570 +
4571 +- init_waitqueue_head(&serial->port[0]->write_wait);
4572 +- usb_set_serial_port_data(serial->port[0], priv);
4573 ++ usb_set_serial_port_data(port, priv);
4574 +
4575 + return 0;
4576 + }
4577 +
4578 +-static void belkin_sa_release(struct usb_serial *serial)
4579 ++static int belkin_sa_port_remove(struct usb_serial_port *port)
4580 + {
4581 +- int i;
4582 ++ struct belkin_sa_private *priv;
4583 +
4584 +- for (i = 0; i < serial->num_ports; ++i)
4585 +- kfree(usb_get_serial_port_data(serial->port[i]));
4586 ++ priv = usb_get_serial_port_data(port);
4587 ++ kfree(priv);
4588 ++
4589 ++ return 0;
4590 + }
4591 +
4592 + static int belkin_sa_open(struct tty_struct *tty,
4593 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
4594 +index 1e71079..4ea9e33 100644
4595 +--- a/drivers/usb/serial/cp210x.c
4596 ++++ b/drivers/usb/serial/cp210x.c
4597 +@@ -164,7 +164,7 @@ static const struct usb_device_id id_table[] = {
4598 +
4599 + MODULE_DEVICE_TABLE(usb, id_table);
4600 +
4601 +-struct cp210x_port_private {
4602 ++struct cp210x_serial_private {
4603 + __u8 bInterfaceNumber;
4604 + };
4605 +
4606 +@@ -278,7 +278,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
4607 + unsigned int *data, int size)
4608 + {
4609 + struct usb_serial *serial = port->serial;
4610 +- struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
4611 ++ struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
4612 + __le32 *buf;
4613 + int result, i, length;
4614 +
4615 +@@ -294,7 +294,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
4616 + /* Issue the request, attempting to read 'size' bytes */
4617 + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
4618 + request, REQTYPE_INTERFACE_TO_HOST, 0x0000,
4619 +- port_priv->bInterfaceNumber, buf, size,
4620 ++ spriv->bInterfaceNumber, buf, size,
4621 + USB_CTRL_GET_TIMEOUT);
4622 +
4623 + /* Convert data into an array of integers */
4624 +@@ -326,7 +326,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
4625 + unsigned int *data, int size)
4626 + {
4627 + struct usb_serial *serial = port->serial;
4628 +- struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
4629 ++ struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
4630 + __le32 *buf;
4631 + int result, i, length;
4632 +
4633 +@@ -348,13 +348,13 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
4634 + result = usb_control_msg(serial->dev,
4635 + usb_sndctrlpipe(serial->dev, 0),
4636 + request, REQTYPE_HOST_TO_INTERFACE, 0x0000,
4637 +- port_priv->bInterfaceNumber, buf, size,
4638 ++ spriv->bInterfaceNumber, buf, size,
4639 + USB_CTRL_SET_TIMEOUT);
4640 + } else {
4641 + result = usb_control_msg(serial->dev,
4642 + usb_sndctrlpipe(serial->dev, 0),
4643 + request, REQTYPE_HOST_TO_INTERFACE, data[0],
4644 +- port_priv->bInterfaceNumber, NULL, 0,
4645 ++ spriv->bInterfaceNumber, NULL, 0,
4646 + USB_CTRL_SET_TIMEOUT);
4647 + }
4648 +
4649 +@@ -854,37 +854,30 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
4650 +
4651 + static int cp210x_startup(struct usb_serial *serial)
4652 + {
4653 +- struct cp210x_port_private *port_priv;
4654 +- int i;
4655 ++ struct usb_host_interface *cur_altsetting;
4656 ++ struct cp210x_serial_private *spriv;
4657 +
4658 + /* cp210x buffers behave strangely unless device is reset */
4659 + usb_reset_device(serial->dev);
4660 +
4661 +- for (i = 0; i < serial->num_ports; i++) {
4662 +- port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
4663 +- if (!port_priv)
4664 +- return -ENOMEM;
4665 ++ spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
4666 ++ if (!spriv)
4667 ++ return -ENOMEM;
4668 +
4669 +- memset(port_priv, 0x00, sizeof(*port_priv));
4670 +- port_priv->bInterfaceNumber =
4671 +- serial->interface->cur_altsetting->desc.bInterfaceNumber;
4672 ++ cur_altsetting = serial->interface->cur_altsetting;
4673 ++ spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber;
4674 +
4675 +- usb_set_serial_port_data(serial->port[i], port_priv);
4676 +- }
4677 ++ usb_set_serial_data(serial, spriv);
4678 +
4679 + return 0;
4680 + }
4681 +
4682 + static void cp210x_release(struct usb_serial *serial)
4683 + {
4684 +- struct cp210x_port_private *port_priv;
4685 +- int i;
4686 ++ struct cp210x_serial_private *spriv;
4687 +
4688 +- for (i = 0; i < serial->num_ports; i++) {
4689 +- port_priv = usb_get_serial_port_data(serial->port[i]);
4690 +- kfree(port_priv);
4691 +- usb_set_serial_port_data(serial->port[i], NULL);
4692 +- }
4693 ++ spriv = usb_get_serial_data(serial);
4694 ++ kfree(spriv);
4695 + }
4696 +
4697 + module_usb_serial_driver(serial_drivers, id_table);
4698 +diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
4699 +index 3aa0b53..bfec6f4 100644
4700 +--- a/drivers/usb/serial/cyberjack.c
4701 ++++ b/drivers/usb/serial/cyberjack.c
4702 +@@ -57,9 +57,9 @@ static bool debug;
4703 + #define CYBERJACK_PRODUCT_ID 0x0100
4704 +
4705 + /* Function prototypes */
4706 +-static int cyberjack_startup(struct usb_serial *serial);
4707 + static void cyberjack_disconnect(struct usb_serial *serial);
4708 +-static void cyberjack_release(struct usb_serial *serial);
4709 ++static int cyberjack_port_probe(struct usb_serial_port *port);
4710 ++static int cyberjack_port_remove(struct usb_serial_port *port);
4711 + static int cyberjack_open(struct tty_struct *tty,
4712 + struct usb_serial_port *port);
4713 + static void cyberjack_close(struct usb_serial_port *port);
4714 +@@ -85,9 +85,9 @@ static struct usb_serial_driver cyberjack_device = {
4715 + .description = "Reiner SCT Cyberjack USB card reader",
4716 + .id_table = id_table,
4717 + .num_ports = 1,
4718 +- .attach = cyberjack_startup,
4719 + .disconnect = cyberjack_disconnect,
4720 +- .release = cyberjack_release,
4721 ++ .port_probe = cyberjack_port_probe,
4722 ++ .port_remove = cyberjack_port_remove,
4723 + .open = cyberjack_open,
4724 + .close = cyberjack_close,
4725 + .write = cyberjack_write,
4726 +@@ -109,55 +109,45 @@ struct cyberjack_private {
4727 + short wrsent; /* Data already sent */
4728 + };
4729 +
4730 +-/* do some startup allocations not currently performed by usb_serial_probe() */
4731 +-static int cyberjack_startup(struct usb_serial *serial)
4732 ++static int cyberjack_port_probe(struct usb_serial_port *port)
4733 + {
4734 + struct cyberjack_private *priv;
4735 +- int i;
4736 ++ int result;
4737 +
4738 +- /* allocate the private data structure */
4739 + priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
4740 + if (!priv)
4741 + return -ENOMEM;
4742 +
4743 +- /* set initial values */
4744 + spin_lock_init(&priv->lock);
4745 + priv->rdtodo = 0;
4746 + priv->wrfilled = 0;
4747 + priv->wrsent = 0;
4748 +- usb_set_serial_port_data(serial->port[0], priv);
4749 +
4750 +- init_waitqueue_head(&serial->port[0]->write_wait);
4751 ++ usb_set_serial_port_data(port, priv);
4752 +
4753 +- for (i = 0; i < serial->num_ports; ++i) {
4754 +- int result;
4755 +- result = usb_submit_urb(serial->port[i]->interrupt_in_urb,
4756 +- GFP_KERNEL);
4757 +- if (result)
4758 +- dev_err(&serial->dev->dev,
4759 +- "usb_submit_urb(read int) failed\n");
4760 +- dbg("%s - usb_submit_urb(int urb)", __func__);
4761 +- }
4762 ++ result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
4763 ++ if (result)
4764 ++ dev_err(&port->dev, "usb_submit_urb(read int) failed\n");
4765 +
4766 + return 0;
4767 + }
4768 +
4769 +-static void cyberjack_disconnect(struct usb_serial *serial)
4770 ++static int cyberjack_port_remove(struct usb_serial_port *port)
4771 + {
4772 +- int i;
4773 ++ struct cyberjack_private *priv;
4774 +
4775 +- for (i = 0; i < serial->num_ports; ++i)
4776 +- usb_kill_urb(serial->port[i]->interrupt_in_urb);
4777 ++ priv = usb_get_serial_port_data(port);
4778 ++ kfree(priv);
4779 ++
4780 ++ return 0;
4781 + }
4782 +
4783 +-static void cyberjack_release(struct usb_serial *serial)
4784 ++static void cyberjack_disconnect(struct usb_serial *serial)
4785 + {
4786 + int i;
4787 +
4788 +- for (i = 0; i < serial->num_ports; ++i) {
4789 +- /* My special items, the standard routines free my urbs */
4790 +- kfree(usb_get_serial_port_data(serial->port[i]));
4791 +- }
4792 ++ for (i = 0; i < serial->num_ports; ++i)
4793 ++ usb_kill_urb(serial->port[i]->interrupt_in_urb);
4794 + }
4795 +
4796 + static int cyberjack_open(struct tty_struct *tty,
4797 +diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
4798 +index b78c34e..5ad6e7d 100644
4799 +--- a/drivers/usb/serial/cypress_m8.c
4800 ++++ b/drivers/usb/serial/cypress_m8.c
4801 +@@ -124,10 +124,10 @@ struct cypress_private {
4802 + };
4803 +
4804 + /* function prototypes for the Cypress USB to serial device */
4805 +-static int cypress_earthmate_startup(struct usb_serial *serial);
4806 +-static int cypress_hidcom_startup(struct usb_serial *serial);
4807 +-static int cypress_ca42v2_startup(struct usb_serial *serial);
4808 +-static void cypress_release(struct usb_serial *serial);
4809 ++static int cypress_earthmate_port_probe(struct usb_serial_port *port);
4810 ++static int cypress_hidcom_port_probe(struct usb_serial_port *port);
4811 ++static int cypress_ca42v2_port_probe(struct usb_serial_port *port);
4812 ++static int cypress_port_remove(struct usb_serial_port *port);
4813 + static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
4814 + static void cypress_close(struct usb_serial_port *port);
4815 + static void cypress_dtr_rts(struct usb_serial_port *port, int on);
4816 +@@ -157,8 +157,8 @@ static struct usb_serial_driver cypress_earthmate_device = {
4817 + .description = "DeLorme Earthmate USB",
4818 + .id_table = id_table_earthmate,
4819 + .num_ports = 1,
4820 +- .attach = cypress_earthmate_startup,
4821 +- .release = cypress_release,
4822 ++ .port_probe = cypress_earthmate_port_probe,
4823 ++ .port_remove = cypress_port_remove,
4824 + .open = cypress_open,
4825 + .close = cypress_close,
4826 + .dtr_rts = cypress_dtr_rts,
4827 +@@ -183,8 +183,8 @@ static struct usb_serial_driver cypress_hidcom_device = {
4828 + .description = "HID->COM RS232 Adapter",
4829 + .id_table = id_table_cyphidcomrs232,
4830 + .num_ports = 1,
4831 +- .attach = cypress_hidcom_startup,
4832 +- .release = cypress_release,
4833 ++ .port_probe = cypress_hidcom_port_probe,
4834 ++ .port_remove = cypress_port_remove,
4835 + .open = cypress_open,
4836 + .close = cypress_close,
4837 + .dtr_rts = cypress_dtr_rts,
4838 +@@ -209,8 +209,8 @@ static struct usb_serial_driver cypress_ca42v2_device = {
4839 + .description = "Nokia CA-42 V2 Adapter",
4840 + .id_table = id_table_nokiaca42v2,
4841 + .num_ports = 1,
4842 +- .attach = cypress_ca42v2_startup,
4843 +- .release = cypress_release,
4844 ++ .port_probe = cypress_ca42v2_port_probe,
4845 ++ .port_remove = cypress_port_remove,
4846 + .open = cypress_open,
4847 + .close = cypress_close,
4848 + .dtr_rts = cypress_dtr_rts,
4849 +@@ -437,10 +437,10 @@ static void cypress_set_dead(struct usb_serial_port *port)
4850 + *****************************************************************************/
4851 +
4852 +
4853 +-static int generic_startup(struct usb_serial *serial)
4854 ++static int cypress_generic_port_probe(struct usb_serial_port *port)
4855 + {
4856 ++ struct usb_serial *serial = port->serial;
4857 + struct cypress_private *priv;
4858 +- struct usb_serial_port *port = serial->port[0];
4859 +
4860 + priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
4861 + if (!priv)
4862 +@@ -489,15 +489,17 @@ static int generic_startup(struct usb_serial *serial)
4863 + }
4864 +
4865 +
4866 +-static int cypress_earthmate_startup(struct usb_serial *serial)
4867 ++static int cypress_earthmate_port_probe(struct usb_serial_port *port)
4868 + {
4869 ++ struct usb_serial *serial = port->serial;
4870 + struct cypress_private *priv;
4871 +- struct usb_serial_port *port = serial->port[0];
4872 ++ int ret;
4873 +
4874 +- if (generic_startup(serial)) {
4875 ++ ret = cypress_generic_port_probe(port);
4876 ++ if (ret) {
4877 + dbg("%s - Failed setting up port %d", __func__,
4878 + port->number);
4879 +- return 1;
4880 ++ return ret;
4881 + }
4882 +
4883 + priv = usb_get_serial_port_data(port);
4884 +@@ -517,54 +519,52 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
4885 + }
4886 +
4887 + return 0;
4888 +-} /* cypress_earthmate_startup */
4889 +-
4890 ++}
4891 +
4892 +-static int cypress_hidcom_startup(struct usb_serial *serial)
4893 ++static int cypress_hidcom_port_probe(struct usb_serial_port *port)
4894 + {
4895 + struct cypress_private *priv;
4896 ++ int ret;
4897 +
4898 +- if (generic_startup(serial)) {
4899 +- dbg("%s - Failed setting up port %d", __func__,
4900 +- serial->port[0]->number);
4901 +- return 1;
4902 ++ ret = cypress_generic_port_probe(port);
4903 ++ if (ret) {
4904 ++ dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
4905 ++ return ret;
4906 + }
4907 +
4908 +- priv = usb_get_serial_port_data(serial->port[0]);
4909 ++ priv = usb_get_serial_port_data(port);
4910 + priv->chiptype = CT_CYPHIDCOM;
4911 +
4912 + return 0;
4913 +-} /* cypress_hidcom_startup */
4914 +-
4915 ++}
4916 +
4917 +-static int cypress_ca42v2_startup(struct usb_serial *serial)
4918 ++static int cypress_ca42v2_port_probe(struct usb_serial_port *port)
4919 + {
4920 + struct cypress_private *priv;
4921 ++ int ret;
4922 +
4923 +- if (generic_startup(serial)) {
4924 +- dbg("%s - Failed setting up port %d", __func__,
4925 +- serial->port[0]->number);
4926 +- return 1;
4927 ++ ret = cypress_generic_port_probe(port);
4928 ++ if (ret) {
4929 ++ dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
4930 ++ return ret;
4931 + }
4932 +
4933 +- priv = usb_get_serial_port_data(serial->port[0]);
4934 ++ priv = usb_get_serial_port_data(port);
4935 + priv->chiptype = CT_CA42V2;
4936 +
4937 + return 0;
4938 +-} /* cypress_ca42v2_startup */
4939 +-
4940 ++}
4941 +
4942 +-static void cypress_release(struct usb_serial *serial)
4943 ++static int cypress_port_remove(struct usb_serial_port *port)
4944 + {
4945 + struct cypress_private *priv;
4946 +
4947 +- /* all open ports are closed at this point */
4948 +- priv = usb_get_serial_port_data(serial->port[0]);
4949 ++ priv = usb_get_serial_port_data(port);
4950 ++
4951 ++ kfifo_free(&priv->write_fifo);
4952 ++ kfree(priv);
4953 +
4954 +- if (priv) {
4955 +- kfifo_free(&priv->write_fifo);
4956 +- kfree(priv);
4957 +- }
4958 ++ return 0;
4959 + }
4960 +
4961 +
4962 +diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
4963 +index 499b15f..be94436 100644
4964 +--- a/drivers/usb/serial/f81232.c
4965 ++++ b/drivers/usb/serial/f81232.c
4966 +@@ -319,39 +319,30 @@ static int f81232_ioctl(struct tty_struct *tty,
4967 + return -ENOIOCTLCMD;
4968 + }
4969 +
4970 +-static int f81232_startup(struct usb_serial *serial)
4971 ++static int f81232_port_probe(struct usb_serial_port *port)
4972 + {
4973 + struct f81232_private *priv;
4974 +- int i;
4975 +
4976 +- for (i = 0; i < serial->num_ports; ++i) {
4977 +- priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL);
4978 +- if (!priv)
4979 +- goto cleanup;
4980 +- spin_lock_init(&priv->lock);
4981 +- init_waitqueue_head(&priv->delta_msr_wait);
4982 +- usb_set_serial_port_data(serial->port[i], priv);
4983 +- }
4984 +- return 0;
4985 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
4986 ++ if (!priv)
4987 ++ return -ENOMEM;
4988 +
4989 +-cleanup:
4990 +- for (--i; i >= 0; --i) {
4991 +- priv = usb_get_serial_port_data(serial->port[i]);
4992 +- kfree(priv);
4993 +- usb_set_serial_port_data(serial->port[i], NULL);
4994 +- }
4995 +- return -ENOMEM;
4996 ++ spin_lock_init(&priv->lock);
4997 ++ init_waitqueue_head(&priv->delta_msr_wait);
4998 ++
4999 ++ usb_set_serial_port_data(port, priv);
5000 ++
5001 ++ return 0;
5002 + }
5003 +
5004 +-static void f81232_release(struct usb_serial *serial)
5005 ++static int f81232_port_remove(struct usb_serial_port *port)
5006 + {
5007 +- int i;
5008 + struct f81232_private *priv;
5009 +
5010 +- for (i = 0; i < serial->num_ports; ++i) {
5011 +- priv = usb_get_serial_port_data(serial->port[i]);
5012 +- kfree(priv);
5013 +- }
5014 ++ priv = usb_get_serial_port_data(port);
5015 ++ kfree(priv);
5016 ++
5017 ++ return 0;
5018 + }
5019 +
5020 + static struct usb_serial_driver f81232_device = {
5021 +@@ -374,8 +365,8 @@ static struct usb_serial_driver f81232_device = {
5022 + .tiocmset = f81232_tiocmset,
5023 + .process_read_urb = f81232_process_read_urb,
5024 + .read_int_callback = f81232_read_int_callback,
5025 +- .attach = f81232_startup,
5026 +- .release = f81232_release,
5027 ++ .port_probe = f81232_port_probe,
5028 ++ .port_remove = f81232_port_remove,
5029 + };
5030 +
5031 + static struct usb_serial_driver * const serial_drivers[] = {
5032 +diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
5033 +index 346c15a..de9cfd4 100644
5034 +--- a/drivers/usb/serial/garmin_gps.c
5035 ++++ b/drivers/usb/serial/garmin_gps.c
5036 +@@ -1414,11 +1414,10 @@ static void timeout_handler(unsigned long data)
5037 +
5038 +
5039 +
5040 +-static int garmin_attach(struct usb_serial *serial)
5041 ++static int garmin_port_probe(struct usb_serial_port *port)
5042 + {
5043 +- int status = 0;
5044 +- struct usb_serial_port *port = serial->port[0];
5045 +- struct garmin_data *garmin_data_p = NULL;
5046 ++ int status;
5047 ++ struct garmin_data *garmin_data_p;
5048 +
5049 + garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
5050 + if (garmin_data_p == NULL) {
5051 +@@ -1443,22 +1442,14 @@ static int garmin_attach(struct usb_serial *serial)
5052 + }
5053 +
5054 +
5055 +-static void garmin_disconnect(struct usb_serial *serial)
5056 ++static int garmin_port_remove(struct usb_serial_port *port)
5057 + {
5058 +- struct usb_serial_port *port = serial->port[0];
5059 + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
5060 +
5061 + usb_kill_urb(port->interrupt_in_urb);
5062 + del_timer_sync(&garmin_data_p->timer);
5063 +-}
5064 +-
5065 +-
5066 +-static void garmin_release(struct usb_serial *serial)
5067 +-{
5068 +- struct usb_serial_port *port = serial->port[0];
5069 +- struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
5070 +-
5071 + kfree(garmin_data_p);
5072 ++ return 0;
5073 + }
5074 +
5075 +
5076 +@@ -1475,9 +1466,8 @@ static struct usb_serial_driver garmin_device = {
5077 + .close = garmin_close,
5078 + .throttle = garmin_throttle,
5079 + .unthrottle = garmin_unthrottle,
5080 +- .attach = garmin_attach,
5081 +- .disconnect = garmin_disconnect,
5082 +- .release = garmin_release,
5083 ++ .port_probe = garmin_port_probe,
5084 ++ .port_remove = garmin_port_remove,
5085 + .write = garmin_write,
5086 + .write_room = garmin_write_room,
5087 + .write_bulk_callback = garmin_write_bulk_callback,
5088 +diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
5089 +index e1f5ccd..dca27a5 100644
5090 +--- a/drivers/usb/serial/io_edgeport.c
5091 ++++ b/drivers/usb/serial/io_edgeport.c
5092 +@@ -228,6 +228,8 @@ static int edge_get_icount(struct tty_struct *tty,
5093 + static int edge_startup(struct usb_serial *serial);
5094 + static void edge_disconnect(struct usb_serial *serial);
5095 + static void edge_release(struct usb_serial *serial);
5096 ++static int edge_port_probe(struct usb_serial_port *port);
5097 ++static int edge_port_remove(struct usb_serial_port *port);
5098 +
5099 + #include "io_tables.h" /* all of the devices that this driver supports */
5100 +
5101 +@@ -2921,9 +2923,8 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
5102 + static int edge_startup(struct usb_serial *serial)
5103 + {
5104 + struct edgeport_serial *edge_serial;
5105 +- struct edgeport_port *edge_port;
5106 + struct usb_device *dev;
5107 +- int i, j;
5108 ++ int i;
5109 + int response;
5110 + bool interrupt_in_found;
5111 + bool bulk_in_found;
5112 +@@ -3007,26 +3008,6 @@ static int edge_startup(struct usb_serial *serial)
5113 + /* we set up the pointers to the endpoints in the edge_open function,
5114 + * as the structures aren't created yet. */
5115 +
5116 +- /* set up our port private structures */
5117 +- for (i = 0; i < serial->num_ports; ++i) {
5118 +- edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
5119 +- if (edge_port == NULL) {
5120 +- dev_err(&serial->dev->dev, "%s - Out of memory\n",
5121 +- __func__);
5122 +- for (j = 0; j < i; ++j) {
5123 +- kfree(usb_get_serial_port_data(serial->port[j]));
5124 +- usb_set_serial_port_data(serial->port[j],
5125 +- NULL);
5126 +- }
5127 +- usb_set_serial_data(serial, NULL);
5128 +- kfree(edge_serial);
5129 +- return -ENOMEM;
5130 +- }
5131 +- spin_lock_init(&edge_port->ep_lock);
5132 +- edge_port->port = serial->port[i];
5133 +- usb_set_serial_port_data(serial->port[i], edge_port);
5134 +- }
5135 +-
5136 + response = 0;
5137 +
5138 + if (edge_serial->is_epic) {
5139 +@@ -3175,12 +3156,35 @@ static void edge_release(struct usb_serial *serial)
5140 +
5141 + dbg("%s", __func__);
5142 +
5143 +- for (i = 0; i < serial->num_ports; ++i)
5144 +- kfree(usb_get_serial_port_data(serial->port[i]));
5145 +-
5146 + kfree(edge_serial);
5147 + }
5148 +
5149 ++static int edge_port_probe(struct usb_serial_port *port)
5150 ++{
5151 ++ struct edgeport_port *edge_port;
5152 ++
5153 ++ edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
5154 ++ if (!edge_port)
5155 ++ return -ENOMEM;
5156 ++
5157 ++ spin_lock_init(&edge_port->ep_lock);
5158 ++ edge_port->port = port;
5159 ++
5160 ++ usb_set_serial_port_data(port, edge_port);
5161 ++
5162 ++ return 0;
5163 ++}
5164 ++
5165 ++static int edge_port_remove(struct usb_serial_port *port)
5166 ++{
5167 ++ struct edgeport_port *edge_port;
5168 ++
5169 ++ edge_port = usb_get_serial_port_data(port);
5170 ++ kfree(edge_port);
5171 ++
5172 ++ return 0;
5173 ++}
5174 ++
5175 + module_usb_serial_driver(serial_drivers, id_table_combined);
5176 +
5177 + MODULE_AUTHOR(DRIVER_AUTHOR);
5178 +diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
5179 +index 350afdd..1511dd0 100644
5180 +--- a/drivers/usb/serial/io_tables.h
5181 ++++ b/drivers/usb/serial/io_tables.h
5182 +@@ -110,6 +110,8 @@ static struct usb_serial_driver edgeport_2port_device = {
5183 + .attach = edge_startup,
5184 + .disconnect = edge_disconnect,
5185 + .release = edge_release,
5186 ++ .port_probe = edge_port_probe,
5187 ++ .port_remove = edge_port_remove,
5188 + .ioctl = edge_ioctl,
5189 + .set_termios = edge_set_termios,
5190 + .tiocmget = edge_tiocmget,
5191 +@@ -139,6 +141,8 @@ static struct usb_serial_driver edgeport_4port_device = {
5192 + .attach = edge_startup,
5193 + .disconnect = edge_disconnect,
5194 + .release = edge_release,
5195 ++ .port_probe = edge_port_probe,
5196 ++ .port_remove = edge_port_remove,
5197 + .ioctl = edge_ioctl,
5198 + .set_termios = edge_set_termios,
5199 + .tiocmget = edge_tiocmget,
5200 +@@ -168,6 +172,8 @@ static struct usb_serial_driver edgeport_8port_device = {
5201 + .attach = edge_startup,
5202 + .disconnect = edge_disconnect,
5203 + .release = edge_release,
5204 ++ .port_probe = edge_port_probe,
5205 ++ .port_remove = edge_port_remove,
5206 + .ioctl = edge_ioctl,
5207 + .set_termios = edge_set_termios,
5208 + .tiocmget = edge_tiocmget,
5209 +@@ -197,6 +203,8 @@ static struct usb_serial_driver epic_device = {
5210 + .attach = edge_startup,
5211 + .disconnect = edge_disconnect,
5212 + .release = edge_release,
5213 ++ .port_probe = edge_port_probe,
5214 ++ .port_remove = edge_port_remove,
5215 + .ioctl = edge_ioctl,
5216 + .set_termios = edge_set_termios,
5217 + .tiocmget = edge_tiocmget,
5218 +diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
5219 +index 3936904..ccf297d 100644
5220 +--- a/drivers/usb/serial/io_ti.c
5221 ++++ b/drivers/usb/serial/io_ti.c
5222 +@@ -2594,12 +2594,7 @@ static void edge_break(struct tty_struct *tty, int break_state)
5223 + static int edge_startup(struct usb_serial *serial)
5224 + {
5225 + struct edgeport_serial *edge_serial;
5226 +- struct edgeport_port *edge_port;
5227 +- struct usb_device *dev;
5228 + int status;
5229 +- int i;
5230 +-
5231 +- dev = serial->dev;
5232 +
5233 + /* create our private serial structure */
5234 + edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
5235 +@@ -2617,40 +2612,7 @@ static int edge_startup(struct usb_serial *serial)
5236 + return status;
5237 + }
5238 +
5239 +- /* set up our port private structures */
5240 +- for (i = 0; i < serial->num_ports; ++i) {
5241 +- edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
5242 +- if (edge_port == NULL) {
5243 +- dev_err(&serial->dev->dev, "%s - Out of memory\n",
5244 +- __func__);
5245 +- goto cleanup;
5246 +- }
5247 +- spin_lock_init(&edge_port->ep_lock);
5248 +- if (kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
5249 +- GFP_KERNEL)) {
5250 +- dev_err(&serial->dev->dev, "%s - Out of memory\n",
5251 +- __func__);
5252 +- kfree(edge_port);
5253 +- goto cleanup;
5254 +- }
5255 +- edge_port->port = serial->port[i];
5256 +- edge_port->edge_serial = edge_serial;
5257 +- usb_set_serial_port_data(serial->port[i], edge_port);
5258 +- edge_port->bUartMode = default_uart_mode;
5259 +- }
5260 +-
5261 + return 0;
5262 +-
5263 +-cleanup:
5264 +- for (--i; i >= 0; --i) {
5265 +- edge_port = usb_get_serial_port_data(serial->port[i]);
5266 +- kfifo_free(&edge_port->write_fifo);
5267 +- kfree(edge_port);
5268 +- usb_set_serial_port_data(serial->port[i], NULL);
5269 +- }
5270 +- kfree(edge_serial);
5271 +- usb_set_serial_data(serial, NULL);
5272 +- return -ENOMEM;
5273 + }
5274 +
5275 + static void edge_disconnect(struct usb_serial *serial)
5276 +@@ -2660,19 +2622,54 @@ static void edge_disconnect(struct usb_serial *serial)
5277 +
5278 + static void edge_release(struct usb_serial *serial)
5279 + {
5280 +- int i;
5281 ++ kfree(usb_get_serial_data(serial));
5282 ++}
5283 ++
5284 ++static int edge_port_probe(struct usb_serial_port *port)
5285 ++{
5286 + struct edgeport_port *edge_port;
5287 ++ int ret;
5288 +
5289 +- dbg("%s", __func__);
5290 ++ edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
5291 ++ if (!edge_port)
5292 ++ return -ENOMEM;
5293 ++
5294 ++ ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
5295 ++ GFP_KERNEL);
5296 ++ if (ret) {
5297 ++ kfree(edge_port);
5298 ++ return -ENOMEM;
5299 ++ }
5300 ++
5301 ++ spin_lock_init(&edge_port->ep_lock);
5302 ++ edge_port->port = port;
5303 ++ edge_port->edge_serial = usb_get_serial_data(port->serial);
5304 ++ edge_port->bUartMode = default_uart_mode;
5305 ++
5306 ++ usb_set_serial_port_data(port, edge_port);
5307 +
5308 +- for (i = 0; i < serial->num_ports; ++i) {
5309 +- edge_port = usb_get_serial_port_data(serial->port[i]);
5310 ++ ret = edge_create_sysfs_attrs(port);
5311 ++ if (ret) {
5312 + kfifo_free(&edge_port->write_fifo);
5313 + kfree(edge_port);
5314 ++ return ret;
5315 + }
5316 +- kfree(usb_get_serial_data(serial));
5317 ++
5318 ++ return 0;
5319 + }
5320 +
5321 ++static int edge_port_remove(struct usb_serial_port *port)
5322 ++{
5323 ++ struct edgeport_port *edge_port;
5324 ++
5325 ++ edge_port = usb_get_serial_port_data(port);
5326 ++
5327 ++ edge_remove_sysfs_attrs(port);
5328 ++ kfifo_free(&edge_port->write_fifo);
5329 ++ kfree(edge_port);
5330 ++
5331 ++ return 0;
5332 ++}
5333 +
5334 + /* Sysfs Attributes */
5335 +
5336 +@@ -2732,8 +2729,8 @@ static struct usb_serial_driver edgeport_1port_device = {
5337 + .attach = edge_startup,
5338 + .disconnect = edge_disconnect,
5339 + .release = edge_release,
5340 +- .port_probe = edge_create_sysfs_attrs,
5341 +- .port_remove = edge_remove_sysfs_attrs,
5342 ++ .port_probe = edge_port_probe,
5343 ++ .port_remove = edge_port_remove,
5344 + .ioctl = edge_ioctl,
5345 + .set_termios = edge_set_termios,
5346 + .tiocmget = edge_tiocmget,
5347 +@@ -2763,8 +2760,8 @@ static struct usb_serial_driver edgeport_2port_device = {
5348 + .attach = edge_startup,
5349 + .disconnect = edge_disconnect,
5350 + .release = edge_release,
5351 +- .port_probe = edge_create_sysfs_attrs,
5352 +- .port_remove = edge_remove_sysfs_attrs,
5353 ++ .port_probe = edge_port_probe,
5354 ++ .port_remove = edge_port_remove,
5355 + .ioctl = edge_ioctl,
5356 + .set_termios = edge_set_termios,
5357 + .tiocmget = edge_tiocmget,
5358 +diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
5359 +index 22b1eb5..cdf0f99 100644
5360 +--- a/drivers/usb/serial/iuu_phoenix.c
5361 ++++ b/drivers/usb/serial/iuu_phoenix.c
5362 +@@ -60,6 +60,8 @@ static int iuu_cardout;
5363 + static bool xmas;
5364 + static int vcc_default = 5;
5365 +
5366 ++static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
5367 ++static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
5368 + static void read_rxcmd_callback(struct urb *urb);
5369 +
5370 + struct iuu_private {
5371 +@@ -80,64 +82,64 @@ struct iuu_private {
5372 + u32 clk;
5373 + };
5374 +
5375 +-
5376 +-static void iuu_free_buf(struct iuu_private *priv)
5377 ++static int iuu_port_probe(struct usb_serial_port *port)
5378 + {
5379 +- kfree(priv->buf);
5380 +- kfree(priv->dbgbuf);
5381 +- kfree(priv->writebuf);
5382 +-}
5383 ++ struct iuu_private *priv;
5384 ++ int ret;
5385 ++
5386 ++ priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
5387 ++ if (!priv)
5388 ++ return -ENOMEM;
5389 +
5390 +-static int iuu_alloc_buf(struct iuu_private *priv)
5391 +-{
5392 + priv->buf = kzalloc(256, GFP_KERNEL);
5393 +- priv->dbgbuf = kzalloc(256, GFP_KERNEL);
5394 +- priv->writebuf = kzalloc(256, GFP_KERNEL);
5395 +- if (!priv->buf || !priv->dbgbuf || !priv->writebuf) {
5396 +- iuu_free_buf(priv);
5397 +- dbg("%s problem allocation buffer", __func__);
5398 ++ if (!priv->buf) {
5399 ++ kfree(priv);
5400 + return -ENOMEM;
5401 + }
5402 +- dbg("%s - Privates buffers allocation success", __func__);
5403 +- return 0;
5404 +-}
5405 +
5406 +-static int iuu_startup(struct usb_serial *serial)
5407 +-{
5408 +- struct iuu_private *priv;
5409 +- priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
5410 +- dbg("%s- priv allocation success", __func__);
5411 +- if (!priv)
5412 ++ priv->writebuf = kzalloc(256, GFP_KERNEL);
5413 ++ if (!priv->writebuf) {
5414 ++ kfree(priv->buf);
5415 ++ kfree(priv);
5416 + return -ENOMEM;
5417 +- if (iuu_alloc_buf(priv)) {
5418 ++ }
5419 ++
5420 ++ priv->dbgbuf = kzalloc(256, GFP_KERNEL);
5421 ++ if (!priv->writebuf) {
5422 ++ kfree(priv->writebuf);
5423 ++ kfree(priv->buf);
5424 + kfree(priv);
5425 + return -ENOMEM;
5426 + }
5427 ++
5428 + priv->vcc = vcc_default;
5429 + spin_lock_init(&priv->lock);
5430 + init_waitqueue_head(&priv->delta_msr_wait);
5431 +- usb_set_serial_port_data(serial->port[0], priv);
5432 ++
5433 ++ usb_set_serial_port_data(port, priv);
5434 ++
5435 ++ ret = iuu_create_sysfs_attrs(port);
5436 ++ if (ret) {
5437 ++ kfree(priv->writebuf);
5438 ++ kfree(priv->buf);
5439 ++ kfree(priv);
5440 ++ return ret;
5441 ++ }
5442 ++
5443 + return 0;
5444 + }
5445 +
5446 +-/* Release function */
5447 +-static void iuu_release(struct usb_serial *serial)
5448 ++static int iuu_port_remove(struct usb_serial_port *port)
5449 + {
5450 +- struct usb_serial_port *port = serial->port[0];
5451 + struct iuu_private *priv = usb_get_serial_port_data(port);
5452 +- if (!port)
5453 +- return;
5454 +-
5455 +- if (priv) {
5456 +- iuu_free_buf(priv);
5457 +- dbg("%s - I will free all", __func__);
5458 +- usb_set_serial_port_data(port, NULL);
5459 +
5460 +- dbg("%s - priv is not anymore in port structure", __func__);
5461 +- kfree(priv);
5462 ++ iuu_remove_sysfs_attrs(port);
5463 ++ kfree(priv->dbgbuf);
5464 ++ kfree(priv->writebuf);
5465 ++ kfree(priv->buf);
5466 ++ kfree(priv);
5467 +
5468 +- dbg("%s priv is now kfree", __func__);
5469 +- }
5470 ++ return 0;
5471 + }
5472 +
5473 + static int iuu_tiocmset(struct tty_struct *tty,
5474 +@@ -1231,8 +1233,6 @@ static struct usb_serial_driver iuu_device = {
5475 + .num_ports = 1,
5476 + .bulk_in_size = 512,
5477 + .bulk_out_size = 512,
5478 +- .port_probe = iuu_create_sysfs_attrs,
5479 +- .port_remove = iuu_remove_sysfs_attrs,
5480 + .open = iuu_open,
5481 + .close = iuu_close,
5482 + .write = iuu_uart_write,
5483 +@@ -1241,8 +1241,8 @@ static struct usb_serial_driver iuu_device = {
5484 + .tiocmset = iuu_tiocmset,
5485 + .set_termios = iuu_set_termios,
5486 + .init_termios = iuu_init_termios,
5487 +- .attach = iuu_startup,
5488 +- .release = iuu_release,
5489 ++ .port_probe = iuu_port_probe,
5490 ++ .port_remove = iuu_port_remove,
5491 + };
5492 +
5493 + static struct usb_serial_driver * const serial_drivers[] = {
5494 +diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
5495 +index a4ac3cf..1e73171 100644
5496 +--- a/drivers/usb/serial/keyspan_pda.c
5497 ++++ b/drivers/usb/serial/keyspan_pda.c
5498 +@@ -735,29 +735,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
5499 + MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
5500 + #endif
5501 +
5502 +-static int keyspan_pda_startup(struct usb_serial *serial)
5503 ++static int keyspan_pda_port_probe(struct usb_serial_port *port)
5504 + {
5505 +
5506 + struct keyspan_pda_private *priv;
5507 +
5508 +- /* allocate the private data structures for all ports. Well, for all
5509 +- one ports. */
5510 +-
5511 + priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
5512 + if (!priv)
5513 +- return 1; /* error */
5514 +- usb_set_serial_port_data(serial->port[0], priv);
5515 +- init_waitqueue_head(&serial->port[0]->write_wait);
5516 ++ return -ENOMEM;
5517 ++
5518 + INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
5519 + INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
5520 +- priv->serial = serial;
5521 +- priv->port = serial->port[0];
5522 ++ priv->serial = port->serial;
5523 ++ priv->port = port;
5524 ++
5525 ++ usb_set_serial_port_data(port, priv);
5526 ++
5527 + return 0;
5528 + }
5529 +
5530 +-static void keyspan_pda_release(struct usb_serial *serial)
5531 ++static int keyspan_pda_port_remove(struct usb_serial_port *port)
5532 + {
5533 +- kfree(usb_get_serial_port_data(serial->port[0]));
5534 ++ struct keyspan_pda_private *priv;
5535 ++
5536 ++ priv = usb_get_serial_port_data(port);
5537 ++ kfree(priv);
5538 ++
5539 ++ return 0;
5540 + }
5541 +
5542 + #ifdef KEYSPAN
5543 +@@ -808,8 +812,8 @@ static struct usb_serial_driver keyspan_pda_device = {
5544 + .break_ctl = keyspan_pda_break_ctl,
5545 + .tiocmget = keyspan_pda_tiocmget,
5546 + .tiocmset = keyspan_pda_tiocmset,
5547 +- .attach = keyspan_pda_startup,
5548 +- .release = keyspan_pda_release,
5549 ++ .port_probe = keyspan_pda_port_probe,
5550 ++ .port_remove = keyspan_pda_port_remove,
5551 + };
5552 +
5553 + static struct usb_serial_driver * const serial_drivers[] = {
5554 +diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
5555 +index 5bed59c..366ddee 100644
5556 +--- a/drivers/usb/serial/kl5kusb105.c
5557 ++++ b/drivers/usb/serial/kl5kusb105.c
5558 +@@ -62,8 +62,8 @@ static bool debug;
5559 + /*
5560 + * Function prototypes
5561 + */
5562 +-static int klsi_105_startup(struct usb_serial *serial);
5563 +-static void klsi_105_release(struct usb_serial *serial);
5564 ++static int klsi_105_port_probe(struct usb_serial_port *port);
5565 ++static int klsi_105_port_remove(struct usb_serial_port *port);
5566 + static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
5567 + static void klsi_105_close(struct usb_serial_port *port);
5568 + static void klsi_105_set_termios(struct tty_struct *tty,
5569 +@@ -101,8 +101,8 @@ static struct usb_serial_driver kl5kusb105d_device = {
5570 + /*.break_ctl = klsi_105_break_ctl,*/
5571 + .tiocmget = klsi_105_tiocmget,
5572 + .tiocmset = klsi_105_tiocmset,
5573 +- .attach = klsi_105_startup,
5574 +- .release = klsi_105_release,
5575 ++ .port_probe = klsi_105_port_probe,
5576 ++ .port_remove = klsi_105_port_remove,
5577 + .throttle = usb_serial_generic_throttle,
5578 + .unthrottle = usb_serial_generic_unthrottle,
5579 + .process_read_urb = klsi_105_process_read_urb,
5580 +@@ -225,58 +225,40 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
5581 + * Driver's tty interface functions
5582 + */
5583 +
5584 +-static int klsi_105_startup(struct usb_serial *serial)
5585 ++static int klsi_105_port_probe(struct usb_serial_port *port)
5586 + {
5587 + struct klsi_105_private *priv;
5588 +- int i;
5589 +
5590 +- /* check if we support the product id (see keyspan.c)
5591 +- * FIXME
5592 +- */
5593 ++ priv = kmalloc(sizeof(*priv), GFP_KERNEL);
5594 ++ if (!priv)
5595 ++ return -ENOMEM;
5596 +
5597 +- /* allocate the private data structure */
5598 +- for (i = 0; i < serial->num_ports; i++) {
5599 +- priv = kmalloc(sizeof(struct klsi_105_private),
5600 +- GFP_KERNEL);
5601 +- if (!priv) {
5602 +- dbg("%skmalloc for klsi_105_private failed.", __func__);
5603 +- i--;
5604 +- goto err_cleanup;
5605 +- }
5606 +- /* set initial values for control structures */
5607 +- priv->cfg.pktlen = 5;
5608 +- priv->cfg.baudrate = kl5kusb105a_sio_b9600;
5609 +- priv->cfg.databits = kl5kusb105a_dtb_8;
5610 +- priv->cfg.unknown1 = 0;
5611 +- priv->cfg.unknown2 = 1;
5612 ++ /* set initial values for control structures */
5613 ++ priv->cfg.pktlen = 5;
5614 ++ priv->cfg.baudrate = kl5kusb105a_sio_b9600;
5615 ++ priv->cfg.databits = kl5kusb105a_dtb_8;
5616 ++ priv->cfg.unknown1 = 0;
5617 ++ priv->cfg.unknown2 = 1;
5618 +
5619 +- priv->line_state = 0;
5620 ++ priv->line_state = 0;
5621 +
5622 +- usb_set_serial_port_data(serial->port[i], priv);
5623 ++ spin_lock_init(&priv->lock);
5624 +
5625 +- spin_lock_init(&priv->lock);
5626 ++ /* priv->termios is left uninitialized until port opening */
5627 +
5628 +- /* priv->termios is left uninitialized until port opening */
5629 +- init_waitqueue_head(&serial->port[i]->write_wait);
5630 +- }
5631 ++ usb_set_serial_port_data(port, priv);
5632 +
5633 + return 0;
5634 +-
5635 +-err_cleanup:
5636 +- for (; i >= 0; i--) {
5637 +- priv = usb_get_serial_port_data(serial->port[i]);
5638 +- kfree(priv);
5639 +- usb_set_serial_port_data(serial->port[i], NULL);
5640 +- }
5641 +- return -ENOMEM;
5642 + }
5643 +
5644 +-static void klsi_105_release(struct usb_serial *serial)
5645 ++static int klsi_105_port_remove(struct usb_serial_port *port)
5646 + {
5647 +- int i;
5648 ++ struct klsi_105_private *priv;
5649 +
5650 +- for (i = 0; i < serial->num_ports; ++i)
5651 +- kfree(usb_get_serial_port_data(serial->port[i]));
5652 ++ priv = usb_get_serial_port_data(port);
5653 ++ kfree(priv);
5654 ++
5655 ++ return 0;
5656 + }
5657 +
5658 + static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
5659 +diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
5660 +index fafeabb..a579fdc 100644
5661 +--- a/drivers/usb/serial/kobil_sct.c
5662 ++++ b/drivers/usb/serial/kobil_sct.c
5663 +@@ -56,8 +56,8 @@ static bool debug;
5664 +
5665 +
5666 + /* Function prototypes */
5667 +-static int kobil_startup(struct usb_serial *serial);
5668 +-static void kobil_release(struct usb_serial *serial);
5669 ++static int kobil_port_probe(struct usb_serial_port *probe);
5670 ++static int kobil_port_remove(struct usb_serial_port *probe);
5671 + static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
5672 + static void kobil_close(struct usb_serial_port *port);
5673 + static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
5674 +@@ -91,8 +91,8 @@ static struct usb_serial_driver kobil_device = {
5675 + .description = "KOBIL USB smart card terminal",
5676 + .id_table = id_table,
5677 + .num_ports = 1,
5678 +- .attach = kobil_startup,
5679 +- .release = kobil_release,
5680 ++ .port_probe = kobil_port_probe,
5681 ++ .port_remove = kobil_port_remove,
5682 + .ioctl = kobil_ioctl,
5683 + .set_termios = kobil_set_termios,
5684 + .init_termios = kobil_init_termios,
5685 +@@ -119,9 +119,10 @@ struct kobil_private {
5686 + };
5687 +
5688 +
5689 +-static int kobil_startup(struct usb_serial *serial)
5690 ++static int kobil_port_probe(struct usb_serial_port *port)
5691 + {
5692 + int i;
5693 ++ struct usb_serial *serial = port->serial;
5694 + struct kobil_private *priv;
5695 + struct usb_device *pdev;
5696 + struct usb_host_config *actconfig;
5697 +@@ -152,7 +153,7 @@ static int kobil_startup(struct usb_serial *serial)
5698 + printk(KERN_DEBUG "KOBIL KAAN SIM detected\n");
5699 + break;
5700 + }
5701 +- usb_set_serial_port_data(serial->port[0], priv);
5702 ++ usb_set_serial_port_data(port, priv);
5703 +
5704 + /* search for the necessary endpoints */
5705 + pdev = serial->dev;
5706 +@@ -180,12 +181,14 @@ static int kobil_startup(struct usb_serial *serial)
5707 + }
5708 +
5709 +
5710 +-static void kobil_release(struct usb_serial *serial)
5711 ++static int kobil_port_remove(struct usb_serial_port *port)
5712 + {
5713 +- int i;
5714 ++ struct kobil_private *priv;
5715 +
5716 +- for (i = 0; i < serial->num_ports; ++i)
5717 +- kfree(usb_get_serial_port_data(serial->port[i]));
5718 ++ priv = usb_get_serial_port_data(port);
5719 ++ kfree(priv);
5720 ++
5721 ++ return 0;
5722 + }
5723 +
5724 + static void kobil_init_termios(struct tty_struct *tty)
5725 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
5726 +index 5f30800..a0542ca 100644
5727 +--- a/drivers/usb/serial/option.c
5728 ++++ b/drivers/usb/serial/option.c
5729 +@@ -503,11 +503,19 @@ static const struct option_blacklist_info net_intf5_blacklist = {
5730 + .reserved = BIT(5),
5731 + };
5732 +
5733 ++static const struct option_blacklist_info net_intf6_blacklist = {
5734 ++ .reserved = BIT(6),
5735 ++};
5736 ++
5737 + static const struct option_blacklist_info zte_mf626_blacklist = {
5738 + .sendsetup = BIT(0) | BIT(1),
5739 + .reserved = BIT(4),
5740 + };
5741 +
5742 ++static const struct option_blacklist_info zte_1255_blacklist = {
5743 ++ .reserved = BIT(3) | BIT(4),
5744 ++};
5745 ++
5746 + static const struct usb_device_id option_ids[] = {
5747 + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
5748 + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
5749 +@@ -853,13 +861,19 @@ static const struct usb_device_id option_ids[] = {
5750 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff),
5751 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5752 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) },
5753 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) },
5754 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) },
5755 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff),
5756 ++ .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5757 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff),
5758 ++ .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5759 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) },
5760 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) },
5761 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) },
5762 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) },
5763 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) },
5764 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff),
5765 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5766 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff),
5767 ++ .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5768 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff),
5769 ++ .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
5770 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff),
5771 ++ .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5772 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
5773 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
5774 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
5775 +@@ -872,7 +886,8 @@ static const struct usb_device_id option_ids[] = {
5776 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
5777 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff),
5778 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5779 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) },
5780 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff),
5781 ++ .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
5782 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
5783 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
5784 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
5785 +@@ -880,13 +895,22 @@ static const struct usb_device_id option_ids[] = {
5786 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
5787 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
5788 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5789 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
5790 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5791 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */
5792 ++ .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
5793 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
5794 ++ .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
5795 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
5796 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5797 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
5798 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5799 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
5800 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5801 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
5802 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff),
5803 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5804 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff),
5805 ++ .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5806 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
5807 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
5808 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) },
5809 +@@ -1002,18 +1026,24 @@ static const struct usb_device_id option_ids[] = {
5810 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) },
5811 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) },
5812 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) },
5813 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff) },
5814 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff),
5815 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5816 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) },
5817 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff) },
5818 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff),
5819 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5820 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) },
5821 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) },
5822 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) },
5823 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) },
5824 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff) },
5825 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff),
5826 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5827 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) },
5828 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff) },
5829 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff) },
5830 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff) },
5831 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff),
5832 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5833 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff),
5834 ++ .driver_info = (kernel_ulong_t)&zte_1255_blacklist },
5835 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff),
5836 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5837 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) },
5838 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) },
5839 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) },
5840 +@@ -1058,8 +1088,16 @@ static const struct usb_device_id option_ids[] = {
5841 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
5842 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
5843 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
5844 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff),
5845 ++ .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5846 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
5847 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5848 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff),
5849 ++ .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5850 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff),
5851 ++ .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5852 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */
5853 ++ .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
5854 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
5855 + 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
5856 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
5857 +@@ -1071,15 +1109,21 @@ static const struct usb_device_id option_ids[] = {
5858 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
5859 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
5860 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
5861 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
5862 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) },
5863 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
5864 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff),
5865 ++ .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
5866 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff),
5867 ++ .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
5868 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff),
5869 ++ .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
5870 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
5871 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
5872 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) },
5873 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff),
5874 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
5875 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
5876 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) },
5877 +- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) },
5878 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff),
5879 ++ .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
5880 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
5881 ++ .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
5882 +
5883 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
5884 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
5885 +diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
5886 +index 5976b65..3aa582e 100644
5887 +--- a/drivers/usb/serial/oti6858.c
5888 ++++ b/drivers/usb/serial/oti6858.c
5889 +@@ -139,8 +139,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
5890 + static int oti6858_tiocmget(struct tty_struct *tty);
5891 + static int oti6858_tiocmset(struct tty_struct *tty,
5892 + unsigned int set, unsigned int clear);
5893 +-static int oti6858_startup(struct usb_serial *serial);
5894 +-static void oti6858_release(struct usb_serial *serial);
5895 ++static int oti6858_port_probe(struct usb_serial_port *port);
5896 ++static int oti6858_port_remove(struct usb_serial_port *port);
5897 +
5898 + /* device info */
5899 + static struct usb_serial_driver oti6858_device = {
5900 +@@ -163,8 +163,8 @@ static struct usb_serial_driver oti6858_device = {
5901 + .write_bulk_callback = oti6858_write_bulk_callback,
5902 + .write_room = oti6858_write_room,
5903 + .chars_in_buffer = oti6858_chars_in_buffer,
5904 +- .attach = oti6858_startup,
5905 +- .release = oti6858_release,
5906 ++ .port_probe = oti6858_port_probe,
5907 ++ .port_remove = oti6858_port_remove,
5908 + };
5909 +
5910 + static struct usb_serial_driver * const serial_drivers[] = {
5911 +@@ -333,36 +333,33 @@ static void send_data(struct work_struct *work)
5912 + usb_serial_port_softint(port);
5913 + }
5914 +
5915 +-static int oti6858_startup(struct usb_serial *serial)
5916 ++static int oti6858_port_probe(struct usb_serial_port *port)
5917 + {
5918 +- struct usb_serial_port *port = serial->port[0];
5919 + struct oti6858_private *priv;
5920 +- int i;
5921 +-
5922 +- for (i = 0; i < serial->num_ports; ++i) {
5923 +- priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL);
5924 +- if (!priv)
5925 +- break;
5926 +-
5927 +- spin_lock_init(&priv->lock);
5928 +- init_waitqueue_head(&priv->intr_wait);
5929 +-/* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
5930 +-/* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
5931 +- priv->port = port;
5932 +- INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
5933 +- INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
5934 +-
5935 +- usb_set_serial_port_data(serial->port[i], priv);
5936 +- }
5937 +- if (i == serial->num_ports)
5938 +- return 0;
5939 +
5940 +- for (--i; i >= 0; --i) {
5941 +- priv = usb_get_serial_port_data(serial->port[i]);
5942 +- kfree(priv);
5943 +- usb_set_serial_port_data(serial->port[i], NULL);
5944 +- }
5945 +- return -ENOMEM;
5946 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
5947 ++ if (!priv)
5948 ++ return -ENOMEM;
5949 ++
5950 ++ spin_lock_init(&priv->lock);
5951 ++ init_waitqueue_head(&priv->intr_wait);
5952 ++ priv->port = port;
5953 ++ INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
5954 ++ INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
5955 ++
5956 ++ usb_set_serial_port_data(port, priv);
5957 ++
5958 ++ return 0;
5959 ++}
5960 ++
5961 ++static int oti6858_port_remove(struct usb_serial_port *port)
5962 ++{
5963 ++ struct oti6858_private *priv;
5964 ++
5965 ++ priv = usb_get_serial_port_data(port);
5966 ++ kfree(priv);
5967 ++
5968 ++ return 0;
5969 + }
5970 +
5971 + static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
5972 +@@ -714,15 +711,6 @@ static int oti6858_ioctl(struct tty_struct *tty,
5973 + return -ENOIOCTLCMD;
5974 + }
5975 +
5976 +-
5977 +-static void oti6858_release(struct usb_serial *serial)
5978 +-{
5979 +- int i;
5980 +-
5981 +- for (i = 0; i < serial->num_ports; ++i)
5982 +- kfree(usb_get_serial_port_data(serial->port[i]));
5983 +-}
5984 +-
5985 + static void oti6858_read_int_callback(struct urb *urb)
5986 + {
5987 + struct usb_serial_port *port = urb->context;
5988 +diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
5989 +index 13b8dd6..4d8d210 100644
5990 +--- a/drivers/usb/serial/pl2303.c
5991 ++++ b/drivers/usb/serial/pl2303.c
5992 +@@ -135,12 +135,15 @@ enum pl2303_type {
5993 + HX, /* HX version of the pl2303 chip */
5994 + };
5995 +
5996 ++struct pl2303_serial_private {
5997 ++ enum pl2303_type type;
5998 ++};
5999 ++
6000 + struct pl2303_private {
6001 + spinlock_t lock;
6002 + wait_queue_head_t delta_msr_wait;
6003 + u8 line_control;
6004 + u8 line_status;
6005 +- enum pl2303_type type;
6006 + };
6007 +
6008 + static int pl2303_vendor_read(__u16 value, __u16 index,
6009 +@@ -169,14 +172,19 @@ static int pl2303_vendor_write(__u16 value, __u16 index,
6010 +
6011 + static int pl2303_startup(struct usb_serial *serial)
6012 + {
6013 +- struct pl2303_private *priv;
6014 ++ struct pl2303_serial_private *spriv;
6015 + enum pl2303_type type = type_0;
6016 + unsigned char *buf;
6017 +- int i;
6018 ++
6019 ++ spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
6020 ++ if (!spriv)
6021 ++ return -ENOMEM;
6022 +
6023 + buf = kmalloc(10, GFP_KERNEL);
6024 +- if (buf == NULL)
6025 ++ if (!buf) {
6026 ++ kfree(spriv);
6027 + return -ENOMEM;
6028 ++ }
6029 +
6030 + if (serial->dev->descriptor.bDeviceClass == 0x02)
6031 + type = type_0;
6032 +@@ -188,15 +196,8 @@ static int pl2303_startup(struct usb_serial *serial)
6033 + type = type_1;
6034 + dev_dbg(&serial->interface->dev, "device type: %d\n", type);
6035 +
6036 +- for (i = 0; i < serial->num_ports; ++i) {
6037 +- priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL);
6038 +- if (!priv)
6039 +- goto cleanup;
6040 +- spin_lock_init(&priv->lock);
6041 +- init_waitqueue_head(&priv->delta_msr_wait);
6042 +- priv->type = type;
6043 +- usb_set_serial_port_data(serial->port[i], priv);
6044 +- }
6045 ++ spriv->type = type;
6046 ++ usb_set_serial_data(serial, spriv);
6047 +
6048 + pl2303_vendor_read(0x8484, 0, serial, buf);
6049 + pl2303_vendor_write(0x0404, 0, serial);
6050 +@@ -215,15 +216,40 @@ static int pl2303_startup(struct usb_serial *serial)
6051 +
6052 + kfree(buf);
6053 + return 0;
6054 ++}
6055 +
6056 +-cleanup:
6057 +- kfree(buf);
6058 +- for (--i; i >= 0; --i) {
6059 +- priv = usb_get_serial_port_data(serial->port[i]);
6060 +- kfree(priv);
6061 +- usb_set_serial_port_data(serial->port[i], NULL);
6062 +- }
6063 +- return -ENOMEM;
6064 ++static void pl2303_release(struct usb_serial *serial)
6065 ++{
6066 ++ struct pl2303_serial_private *spriv;
6067 ++
6068 ++ spriv = usb_get_serial_data(serial);
6069 ++ kfree(spriv);
6070 ++}
6071 ++
6072 ++static int pl2303_port_probe(struct usb_serial_port *port)
6073 ++{
6074 ++ struct pl2303_private *priv;
6075 ++
6076 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
6077 ++ if (!priv)
6078 ++ return -ENOMEM;
6079 ++
6080 ++ spin_lock_init(&priv->lock);
6081 ++ init_waitqueue_head(&priv->delta_msr_wait);
6082 ++
6083 ++ usb_set_serial_port_data(port, priv);
6084 ++
6085 ++ return 0;
6086 ++}
6087 ++
6088 ++static int pl2303_port_remove(struct usb_serial_port *port)
6089 ++{
6090 ++ struct pl2303_private *priv;
6091 ++
6092 ++ priv = usb_get_serial_port_data(port);
6093 ++ kfree(priv);
6094 ++
6095 ++ return 0;
6096 + }
6097 +
6098 + static int set_control_lines(struct usb_device *dev, u8 value)
6099 +@@ -242,6 +268,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
6100 + struct usb_serial_port *port, struct ktermios *old_termios)
6101 + {
6102 + struct usb_serial *serial = port->serial;
6103 ++ struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
6104 + struct pl2303_private *priv = usb_get_serial_port_data(port);
6105 + unsigned long flags;
6106 + unsigned int cflag;
6107 +@@ -325,7 +352,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
6108 + }
6109 + if (baud > 1228800) {
6110 + /* type_0, type_1 only support up to 1228800 baud */
6111 +- if (priv->type != HX)
6112 ++ if (spriv->type != HX)
6113 + baud = 1228800;
6114 + else if (baud > 6000000)
6115 + baud = 6000000;
6116 +@@ -428,7 +455,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
6117 + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
6118 +
6119 + if (cflag & CRTSCTS) {
6120 +- if (priv->type == HX)
6121 ++ if (spriv->type == HX)
6122 + pl2303_vendor_write(0x0, 0x61, serial);
6123 + else
6124 + pl2303_vendor_write(0x0, 0x41, serial);
6125 +@@ -470,10 +497,10 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
6126 + {
6127 + struct ktermios tmp_termios;
6128 + struct usb_serial *serial = port->serial;
6129 +- struct pl2303_private *priv = usb_get_serial_port_data(port);
6130 ++ struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
6131 + int result;
6132 +
6133 +- if (priv->type != HX) {
6134 ++ if (spriv->type != HX) {
6135 + usb_clear_halt(serial->dev, port->write_urb->pipe);
6136 + usb_clear_halt(serial->dev, port->read_urb->pipe);
6137 + } else {
6138 +@@ -657,17 +684,6 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
6139 + dev_err(&port->dev, "error sending break = %d\n", result);
6140 + }
6141 +
6142 +-static void pl2303_release(struct usb_serial *serial)
6143 +-{
6144 +- int i;
6145 +- struct pl2303_private *priv;
6146 +-
6147 +- for (i = 0; i < serial->num_ports; ++i) {
6148 +- priv = usb_get_serial_port_data(serial->port[i]);
6149 +- kfree(priv);
6150 +- }
6151 +-}
6152 +-
6153 + static void pl2303_update_line_status(struct usb_serial_port *port,
6154 + unsigned char *data,
6155 + unsigned int actual_length)
6156 +@@ -829,6 +845,8 @@ static struct usb_serial_driver pl2303_device = {
6157 + .read_int_callback = pl2303_read_int_callback,
6158 + .attach = pl2303_startup,
6159 + .release = pl2303_release,
6160 ++ .port_probe = pl2303_port_probe,
6161 ++ .port_remove = pl2303_port_remove,
6162 + };
6163 +
6164 + static struct usb_serial_driver * const serial_drivers[] = {
6165 +diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
6166 +index cad6089..2451c08 100644
6167 +--- a/drivers/usb/serial/spcp8x5.c
6168 ++++ b/drivers/usb/serial/spcp8x5.c
6169 +@@ -159,13 +159,10 @@ struct spcp8x5_private {
6170 + u8 line_status;
6171 + };
6172 +
6173 +-/* desc : when device plug in,this function would be called.
6174 +- * thanks to usb_serial subsystem,then do almost every things for us. And what
6175 +- * we should do just alloc the buffer */
6176 +-static int spcp8x5_startup(struct usb_serial *serial)
6177 ++static int spcp8x5_port_probe(struct usb_serial_port *port)
6178 + {
6179 ++ struct usb_serial *serial = port->serial;
6180 + struct spcp8x5_private *priv;
6181 +- int i;
6182 + enum spcp8x5_type type = SPCP825_007_TYPE;
6183 + u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
6184 +
6185 +@@ -182,34 +179,27 @@ static int spcp8x5_startup(struct usb_serial *serial)
6186 + type = SPCP825_PHILIP_TYPE;
6187 + dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type);
6188 +
6189 +- for (i = 0; i < serial->num_ports; ++i) {
6190 +- priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL);
6191 +- if (!priv)
6192 +- goto cleanup;
6193 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
6194 ++ if (!priv)
6195 ++ return -ENOMEM;
6196 +
6197 +- spin_lock_init(&priv->lock);
6198 +- init_waitqueue_head(&priv->delta_msr_wait);
6199 +- priv->type = type;
6200 +- usb_set_serial_port_data(serial->port[i] , priv);
6201 +- }
6202 ++ spin_lock_init(&priv->lock);
6203 ++ init_waitqueue_head(&priv->delta_msr_wait);
6204 ++ priv->type = type;
6205 ++
6206 ++ usb_set_serial_port_data(port , priv);
6207 +
6208 + return 0;
6209 +-cleanup:
6210 +- for (--i; i >= 0; --i) {
6211 +- priv = usb_get_serial_port_data(serial->port[i]);
6212 +- kfree(priv);
6213 +- usb_set_serial_port_data(serial->port[i] , NULL);
6214 +- }
6215 +- return -ENOMEM;
6216 + }
6217 +
6218 +-/* call when the device plug out. free all the memory alloced by probe */
6219 +-static void spcp8x5_release(struct usb_serial *serial)
6220 ++static int spcp8x5_port_remove(struct usb_serial_port *port)
6221 + {
6222 +- int i;
6223 ++ struct spcp8x5_private *priv;
6224 +
6225 +- for (i = 0; i < serial->num_ports; i++)
6226 +- kfree(usb_get_serial_port_data(serial->port[i]));
6227 ++ priv = usb_get_serial_port_data(port);
6228 ++ kfree(priv);
6229 ++
6230 ++ return 0;
6231 + }
6232 +
6233 + /* set the modem control line of the device.
6234 +@@ -651,8 +641,8 @@ static struct usb_serial_driver spcp8x5_device = {
6235 + .ioctl = spcp8x5_ioctl,
6236 + .tiocmget = spcp8x5_tiocmget,
6237 + .tiocmset = spcp8x5_tiocmset,
6238 +- .attach = spcp8x5_startup,
6239 +- .release = spcp8x5_release,
6240 ++ .port_probe = spcp8x5_port_probe,
6241 ++ .port_remove = spcp8x5_port_remove,
6242 + .process_read_urb = spcp8x5_process_read_urb,
6243 + };
6244 +
6245 +diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
6246 +index 3fee23b..fe3a8a0 100644
6247 +--- a/drivers/usb/serial/ssu100.c
6248 ++++ b/drivers/usb/serial/ssu100.c
6249 +@@ -69,13 +69,6 @@ struct ssu100_port_private {
6250 + struct async_icount icount;
6251 + };
6252 +
6253 +-static void ssu100_release(struct usb_serial *serial)
6254 +-{
6255 +- struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port);
6256 +-
6257 +- kfree(priv);
6258 +-}
6259 +-
6260 + static inline int ssu100_control_msg(struct usb_device *dev,
6261 + u8 request, u16 data, u16 index)
6262 + {
6263 +@@ -444,21 +437,33 @@ static int ssu100_ioctl(struct tty_struct *tty,
6264 +
6265 + static int ssu100_attach(struct usb_serial *serial)
6266 + {
6267 ++ return ssu100_initdevice(serial->dev);
6268 ++}
6269 ++
6270 ++static int ssu100_port_probe(struct usb_serial_port *port)
6271 ++{
6272 + struct ssu100_port_private *priv;
6273 +- struct usb_serial_port *port = *serial->port;
6274 +
6275 + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
6276 +- if (!priv) {
6277 +- dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
6278 +- sizeof(*priv));
6279 ++ if (!priv)
6280 + return -ENOMEM;
6281 +- }
6282 +
6283 + spin_lock_init(&priv->status_lock);
6284 + init_waitqueue_head(&priv->delta_msr_wait);
6285 ++
6286 + usb_set_serial_port_data(port, priv);
6287 +
6288 +- return ssu100_initdevice(serial->dev);
6289 ++ return 0;
6290 ++}
6291 ++
6292 ++static int ssu100_port_remove(struct usb_serial_port *port)
6293 ++{
6294 ++ struct ssu100_port_private *priv;
6295 ++
6296 ++ priv = usb_get_serial_port_data(port);
6297 ++ kfree(priv);
6298 ++
6299 ++ return 0;
6300 + }
6301 +
6302 + static int ssu100_tiocmget(struct tty_struct *tty)
6303 +@@ -649,7 +654,8 @@ static struct usb_serial_driver ssu100_device = {
6304 + .open = ssu100_open,
6305 + .close = ssu100_close,
6306 + .attach = ssu100_attach,
6307 +- .release = ssu100_release,
6308 ++ .port_probe = ssu100_port_probe,
6309 ++ .port_remove = ssu100_port_remove,
6310 + .dtr_rts = ssu100_dtr_rts,
6311 + .process_read_urb = ssu100_process_read_urb,
6312 + .tiocmget = ssu100_tiocmget,
6313 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
6314 +index a4404f5..33537bb 100644
6315 +--- a/drivers/usb/serial/ti_usb_3410_5052.c
6316 ++++ b/drivers/usb/serial/ti_usb_3410_5052.c
6317 +@@ -98,6 +98,8 @@ struct ti_device {
6318 +
6319 + static int ti_startup(struct usb_serial *serial);
6320 + static void ti_release(struct usb_serial *serial);
6321 ++static int ti_port_probe(struct usb_serial_port *port);
6322 ++static int ti_port_remove(struct usb_serial_port *port);
6323 + static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
6324 + static void ti_close(struct usb_serial_port *port);
6325 + static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
6326 +@@ -223,6 +225,8 @@ static struct usb_serial_driver ti_1port_device = {
6327 + .num_ports = 1,
6328 + .attach = ti_startup,
6329 + .release = ti_release,
6330 ++ .port_probe = ti_port_probe,
6331 ++ .port_remove = ti_port_remove,
6332 + .open = ti_open,
6333 + .close = ti_close,
6334 + .write = ti_write,
6335 +@@ -251,6 +255,8 @@ static struct usb_serial_driver ti_2port_device = {
6336 + .num_ports = 2,
6337 + .attach = ti_startup,
6338 + .release = ti_release,
6339 ++ .port_probe = ti_port_probe,
6340 ++ .port_remove = ti_port_remove,
6341 + .open = ti_open,
6342 + .close = ti_close,
6343 + .write = ti_write,
6344 +@@ -358,11 +364,8 @@ module_exit(ti_exit);
6345 + static int ti_startup(struct usb_serial *serial)
6346 + {
6347 + struct ti_device *tdev;
6348 +- struct ti_port *tport;
6349 + struct usb_device *dev = serial->dev;
6350 + int status;
6351 +- int i;
6352 +-
6353 +
6354 + dbg("%s - product 0x%4X, num configurations %d, configuration value %d",
6355 + __func__, le16_to_cpu(dev->descriptor.idProduct),
6356 +@@ -409,42 +412,8 @@ static int ti_startup(struct usb_serial *serial)
6357 + goto free_tdev;
6358 + }
6359 +
6360 +- /* set up port structures */
6361 +- for (i = 0; i < serial->num_ports; ++i) {
6362 +- tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
6363 +- if (tport == NULL) {
6364 +- dev_err(&dev->dev, "%s - out of memory\n", __func__);
6365 +- status = -ENOMEM;
6366 +- goto free_tports;
6367 +- }
6368 +- spin_lock_init(&tport->tp_lock);
6369 +- tport->tp_uart_base_addr = (i == 0 ?
6370 +- TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
6371 +- tport->tp_closing_wait = closing_wait;
6372 +- init_waitqueue_head(&tport->tp_msr_wait);
6373 +- init_waitqueue_head(&tport->tp_write_wait);
6374 +- if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE,
6375 +- GFP_KERNEL)) {
6376 +- dev_err(&dev->dev, "%s - out of memory\n", __func__);
6377 +- kfree(tport);
6378 +- status = -ENOMEM;
6379 +- goto free_tports;
6380 +- }
6381 +- tport->tp_port = serial->port[i];
6382 +- tport->tp_tdev = tdev;
6383 +- usb_set_serial_port_data(serial->port[i], tport);
6384 +- tport->tp_uart_mode = 0; /* default is RS232 */
6385 +- }
6386 +-
6387 + return 0;
6388 +
6389 +-free_tports:
6390 +- for (--i; i >= 0; --i) {
6391 +- tport = usb_get_serial_port_data(serial->port[i]);
6392 +- kfifo_free(&tport->write_fifo);
6393 +- kfree(tport);
6394 +- usb_set_serial_port_data(serial->port[i], NULL);
6395 +- }
6396 + free_tdev:
6397 + kfree(tdev);
6398 + usb_set_serial_data(serial, NULL);
6399 +@@ -454,21 +423,50 @@ free_tdev:
6400 +
6401 + static void ti_release(struct usb_serial *serial)
6402 + {
6403 +- int i;
6404 + struct ti_device *tdev = usb_get_serial_data(serial);
6405 ++
6406 ++ kfree(tdev);
6407 ++}
6408 ++
6409 ++static int ti_port_probe(struct usb_serial_port *port)
6410 ++{
6411 + struct ti_port *tport;
6412 +
6413 +- for (i = 0; i < serial->num_ports; ++i) {
6414 +- tport = usb_get_serial_port_data(serial->port[i]);
6415 +- if (tport) {
6416 +- kfifo_free(&tport->write_fifo);
6417 +- kfree(tport);
6418 +- }
6419 ++ tport = kzalloc(sizeof(*tport), GFP_KERNEL);
6420 ++ if (!tport)
6421 ++ return -ENOMEM;
6422 ++
6423 ++ spin_lock_init(&tport->tp_lock);
6424 ++ if (port == port->serial->port[0])
6425 ++ tport->tp_uart_base_addr = TI_UART1_BASE_ADDR;
6426 ++ else
6427 ++ tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
6428 ++ tport->tp_closing_wait = closing_wait;
6429 ++ init_waitqueue_head(&tport->tp_msr_wait);
6430 ++ init_waitqueue_head(&tport->tp_write_wait);
6431 ++ if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
6432 ++ kfree(tport);
6433 ++ return -ENOMEM;
6434 + }
6435 ++ tport->tp_port = port;
6436 ++ tport->tp_tdev = usb_get_serial_data(port->serial);
6437 ++ tport->tp_uart_mode = 0; /* default is RS232 */
6438 +
6439 +- kfree(tdev);
6440 ++ usb_set_serial_port_data(port, tport);
6441 ++
6442 ++ return 0;
6443 + }
6444 +
6445 ++static int ti_port_remove(struct usb_serial_port *port)
6446 ++{
6447 ++ struct ti_port *tport;
6448 ++
6449 ++ tport = usb_get_serial_port_data(port);
6450 ++ kfifo_free(&tport->write_fifo);
6451 ++ kfree(tport);
6452 ++
6453 ++ return 0;
6454 ++}
6455 +
6456 + static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
6457 + {
6458 +diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
6459 +index 1b50890..cf18217 100644
6460 +--- a/fs/ext4/balloc.c
6461 ++++ b/fs/ext4/balloc.c
6462 +@@ -174,8 +174,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
6463 + ext4_free_inodes_set(sb, gdp, 0);
6464 + ext4_itable_unused_set(sb, gdp, 0);
6465 + memset(bh->b_data, 0xff, sb->s_blocksize);
6466 +- ext4_block_bitmap_csum_set(sb, block_group, gdp, bh,
6467 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6468 ++ ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
6469 + return;
6470 + }
6471 + memset(bh->b_data, 0, sb->s_blocksize);
6472 +@@ -212,8 +211,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
6473 + */
6474 + ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group),
6475 + sb->s_blocksize * 8, bh->b_data);
6476 +- ext4_block_bitmap_csum_set(sb, block_group, gdp, bh,
6477 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6478 ++ ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
6479 + ext4_group_desc_csum_set(sb, block_group, gdp);
6480 + }
6481 +
6482 +@@ -350,7 +348,7 @@ void ext4_validate_block_bitmap(struct super_block *sb,
6483 + return;
6484 + }
6485 + if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
6486 +- desc, bh, EXT4_BLOCKS_PER_GROUP(sb) / 8))) {
6487 ++ desc, bh))) {
6488 + ext4_unlock_group(sb, block_group);
6489 + ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
6490 + return;
6491 +diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
6492 +index 5c2d181..3285aa5 100644
6493 +--- a/fs/ext4/bitmap.c
6494 ++++ b/fs/ext4/bitmap.c
6495 +@@ -58,11 +58,12 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
6496 +
6497 + int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
6498 + struct ext4_group_desc *gdp,
6499 +- struct buffer_head *bh, int sz)
6500 ++ struct buffer_head *bh)
6501 + {
6502 + __u32 hi;
6503 + __u32 provided, calculated;
6504 + struct ext4_sb_info *sbi = EXT4_SB(sb);
6505 ++ int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
6506 +
6507 + if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
6508 + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
6509 +@@ -84,8 +85,9 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
6510 +
6511 + void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
6512 + struct ext4_group_desc *gdp,
6513 +- struct buffer_head *bh, int sz)
6514 ++ struct buffer_head *bh)
6515 + {
6516 ++ int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
6517 + __u32 csum;
6518 + struct ext4_sb_info *sbi = EXT4_SB(sb);
6519 +
6520 +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
6521 +index c3411d4..5c69f2b 100644
6522 +--- a/fs/ext4/ext4.h
6523 ++++ b/fs/ext4/ext4.h
6524 +@@ -1867,10 +1867,10 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
6525 + struct buffer_head *bh, int sz);
6526 + void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
6527 + struct ext4_group_desc *gdp,
6528 +- struct buffer_head *bh, int sz);
6529 ++ struct buffer_head *bh);
6530 + int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
6531 + struct ext4_group_desc *gdp,
6532 +- struct buffer_head *bh, int sz);
6533 ++ struct buffer_head *bh);
6534 +
6535 + /* balloc.c */
6536 + extern void ext4_validate_block_bitmap(struct super_block *sb,
6537 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
6538 +index aabbb3f..741bb94 100644
6539 +--- a/fs/ext4/extents.c
6540 ++++ b/fs/ext4/extents.c
6541 +@@ -52,6 +52,9 @@
6542 + #define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */
6543 + #define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */
6544 +
6545 ++#define EXT4_EXT_DATA_VALID1 0x8 /* first half contains valid data */
6546 ++#define EXT4_EXT_DATA_VALID2 0x10 /* second half contains valid data */
6547 ++
6548 + static __le32 ext4_extent_block_csum(struct inode *inode,
6549 + struct ext4_extent_header *eh)
6550 + {
6551 +@@ -2895,6 +2898,9 @@ static int ext4_split_extent_at(handle_t *handle,
6552 + unsigned int ee_len, depth;
6553 + int err = 0;
6554 +
6555 ++ BUG_ON((split_flag & (EXT4_EXT_DATA_VALID1 | EXT4_EXT_DATA_VALID2)) ==
6556 ++ (EXT4_EXT_DATA_VALID1 | EXT4_EXT_DATA_VALID2));
6557 ++
6558 + ext_debug("ext4_split_extents_at: inode %lu, logical"
6559 + "block %llu\n", inode->i_ino, (unsigned long long)split);
6560 +
6561 +@@ -2953,7 +2959,14 @@ static int ext4_split_extent_at(handle_t *handle,
6562 +
6563 + err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
6564 + if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) {
6565 +- err = ext4_ext_zeroout(inode, &orig_ex);
6566 ++ if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) {
6567 ++ if (split_flag & EXT4_EXT_DATA_VALID1)
6568 ++ err = ext4_ext_zeroout(inode, ex2);
6569 ++ else
6570 ++ err = ext4_ext_zeroout(inode, ex);
6571 ++ } else
6572 ++ err = ext4_ext_zeroout(inode, &orig_ex);
6573 ++
6574 + if (err)
6575 + goto fix_extent_len;
6576 + /* update the extent length and mark as initialized */
6577 +@@ -3006,12 +3019,13 @@ static int ext4_split_extent(handle_t *handle,
6578 + uninitialized = ext4_ext_is_uninitialized(ex);
6579 +
6580 + if (map->m_lblk + map->m_len < ee_block + ee_len) {
6581 +- split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT ?
6582 +- EXT4_EXT_MAY_ZEROOUT : 0;
6583 ++ split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT;
6584 + flags1 = flags | EXT4_GET_BLOCKS_PRE_IO;
6585 + if (uninitialized)
6586 + split_flag1 |= EXT4_EXT_MARK_UNINIT1 |
6587 + EXT4_EXT_MARK_UNINIT2;
6588 ++ if (split_flag & EXT4_EXT_DATA_VALID2)
6589 ++ split_flag1 |= EXT4_EXT_DATA_VALID1;
6590 + err = ext4_split_extent_at(handle, inode, path,
6591 + map->m_lblk + map->m_len, split_flag1, flags1);
6592 + if (err)
6593 +@@ -3024,8 +3038,8 @@ static int ext4_split_extent(handle_t *handle,
6594 + return PTR_ERR(path);
6595 +
6596 + if (map->m_lblk >= ee_block) {
6597 +- split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT ?
6598 +- EXT4_EXT_MAY_ZEROOUT : 0;
6599 ++ split_flag1 = split_flag & (EXT4_EXT_MAY_ZEROOUT |
6600 ++ EXT4_EXT_DATA_VALID2);
6601 + if (uninitialized)
6602 + split_flag1 |= EXT4_EXT_MARK_UNINIT1;
6603 + if (split_flag & EXT4_EXT_MARK_UNINIT2)
6604 +@@ -3303,26 +3317,47 @@ static int ext4_split_unwritten_extents(handle_t *handle,
6605 +
6606 + split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0;
6607 + split_flag |= EXT4_EXT_MARK_UNINIT2;
6608 +-
6609 ++ if (flags & EXT4_GET_BLOCKS_CONVERT)
6610 ++ split_flag |= EXT4_EXT_DATA_VALID2;
6611 + flags |= EXT4_GET_BLOCKS_PRE_IO;
6612 + return ext4_split_extent(handle, inode, path, map, split_flag, flags);
6613 + }
6614 +
6615 + static int ext4_convert_unwritten_extents_endio(handle_t *handle,
6616 +- struct inode *inode,
6617 +- struct ext4_ext_path *path)
6618 ++ struct inode *inode,
6619 ++ struct ext4_map_blocks *map,
6620 ++ struct ext4_ext_path *path)
6621 + {
6622 + struct ext4_extent *ex;
6623 ++ ext4_lblk_t ee_block;
6624 ++ unsigned int ee_len;
6625 + int depth;
6626 + int err = 0;
6627 +
6628 + depth = ext_depth(inode);
6629 + ex = path[depth].p_ext;
6630 ++ ee_block = le32_to_cpu(ex->ee_block);
6631 ++ ee_len = ext4_ext_get_actual_len(ex);
6632 +
6633 + ext_debug("ext4_convert_unwritten_extents_endio: inode %lu, logical"
6634 + "block %llu, max_blocks %u\n", inode->i_ino,
6635 +- (unsigned long long)le32_to_cpu(ex->ee_block),
6636 +- ext4_ext_get_actual_len(ex));
6637 ++ (unsigned long long)ee_block, ee_len);
6638 ++
6639 ++ /* If extent is larger than requested then split is required */
6640 ++ if (ee_block != map->m_lblk || ee_len > map->m_len) {
6641 ++ err = ext4_split_unwritten_extents(handle, inode, map, path,
6642 ++ EXT4_GET_BLOCKS_CONVERT);
6643 ++ if (err < 0)
6644 ++ goto out;
6645 ++ ext4_ext_drop_refs(path);
6646 ++ path = ext4_ext_find_extent(inode, map->m_lblk, path);
6647 ++ if (IS_ERR(path)) {
6648 ++ err = PTR_ERR(path);
6649 ++ goto out;
6650 ++ }
6651 ++ depth = ext_depth(inode);
6652 ++ ex = path[depth].p_ext;
6653 ++ }
6654 +
6655 + err = ext4_ext_get_access(handle, inode, path + depth);
6656 + if (err)
6657 +@@ -3630,7 +3665,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
6658 + }
6659 + /* IO end_io complete, convert the filled extent to written */
6660 + if ((flags & EXT4_GET_BLOCKS_CONVERT)) {
6661 +- ret = ext4_convert_unwritten_extents_endio(handle, inode,
6662 ++ ret = ext4_convert_unwritten_extents_endio(handle, inode, map,
6663 + path);
6664 + if (ret >= 0) {
6665 + ext4_update_inode_fsync_trans(handle, inode, 1);
6666 +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
6667 +index 26154b8..8ce0076 100644
6668 +--- a/fs/ext4/ialloc.c
6669 ++++ b/fs/ext4/ialloc.c
6670 +@@ -753,9 +753,7 @@ got:
6671 + ext4_free_group_clusters_set(sb, gdp,
6672 + ext4_free_clusters_after_init(sb, group, gdp));
6673 + ext4_block_bitmap_csum_set(sb, group, gdp,
6674 +- block_bitmap_bh,
6675 +- EXT4_BLOCKS_PER_GROUP(sb) /
6676 +- 8);
6677 ++ block_bitmap_bh);
6678 + ext4_group_desc_csum_set(sb, group, gdp);
6679 + }
6680 + ext4_unlock_group(sb, group);
6681 +diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
6682 +index 8eae947..b26410c 100644
6683 +--- a/fs/ext4/mballoc.c
6684 ++++ b/fs/ext4/mballoc.c
6685 +@@ -2804,8 +2804,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
6686 + }
6687 + len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len;
6688 + ext4_free_group_clusters_set(sb, gdp, len);
6689 +- ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh,
6690 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6691 ++ ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh);
6692 + ext4_group_desc_csum_set(sb, ac->ac_b_ex.fe_group, gdp);
6693 +
6694 + ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
6695 +@@ -4664,8 +4663,7 @@ do_more:
6696 +
6697 + ret = ext4_free_group_clusters(sb, gdp) + count_clusters;
6698 + ext4_free_group_clusters_set(sb, gdp, ret);
6699 +- ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh,
6700 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6701 ++ ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh);
6702 + ext4_group_desc_csum_set(sb, block_group, gdp);
6703 + ext4_unlock_group(sb, block_group);
6704 + percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters);
6705 +@@ -4809,8 +4807,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
6706 + mb_free_blocks(NULL, &e4b, bit, count);
6707 + blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc);
6708 + ext4_free_group_clusters_set(sb, desc, blk_free_count);
6709 +- ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh,
6710 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6711 ++ ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh);
6712 + ext4_group_desc_csum_set(sb, block_group, desc);
6713 + ext4_unlock_group(sb, block_group);
6714 + percpu_counter_add(&sbi->s_freeclusters_counter,
6715 +@@ -4990,8 +4987,9 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
6716 + end = start + (range->len >> sb->s_blocksize_bits) - 1;
6717 + minlen = range->minlen >> sb->s_blocksize_bits;
6718 +
6719 +- if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
6720 +- unlikely(start >= max_blks))
6721 ++ if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
6722 ++ start >= max_blks ||
6723 ++ range->len < sb->s_blocksize)
6724 + return -EINVAL;
6725 + if (end >= max_blks)
6726 + end = max_blks - 1;
6727 +diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
6728 +index 0be1789..71241bc 100644
6729 +--- a/fs/ext4/resize.c
6730 ++++ b/fs/ext4/resize.c
6731 +@@ -1121,8 +1121,7 @@ static int ext4_set_bitmap_checksums(struct super_block *sb,
6732 + bh = ext4_get_bitmap(sb, group_data->block_bitmap);
6733 + if (!bh)
6734 + return -EIO;
6735 +- ext4_block_bitmap_csum_set(sb, group, gdp, bh,
6736 +- EXT4_BLOCKS_PER_GROUP(sb) / 8);
6737 ++ ext4_block_bitmap_csum_set(sb, group, gdp, bh);
6738 + brelse(bh);
6739 +
6740 + return 0;
6741 +diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c
6742 +index d269ada..982d267 100644
6743 +--- a/fs/lockd/clntxdr.c
6744 ++++ b/fs/lockd/clntxdr.c
6745 +@@ -223,7 +223,7 @@ static void encode_nlm_stat(struct xdr_stream *xdr,
6746 + {
6747 + __be32 *p;
6748 +
6749 +- BUG_ON(be32_to_cpu(stat) > NLM_LCK_DENIED_GRACE_PERIOD);
6750 ++ WARN_ON_ONCE(be32_to_cpu(stat) > NLM_LCK_DENIED_GRACE_PERIOD);
6751 + p = xdr_reserve_space(xdr, 4);
6752 + *p = stat;
6753 + }
6754 +diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
6755 +index 3009a36..21171f0 100644
6756 +--- a/fs/lockd/svcproc.c
6757 ++++ b/fs/lockd/svcproc.c
6758 +@@ -68,7 +68,8 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
6759 +
6760 + /* Obtain file pointer. Not used by FREE_ALL call. */
6761 + if (filp != NULL) {
6762 +- if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0)
6763 ++ error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh));
6764 ++ if (error != 0)
6765 + goto no_locks;
6766 + *filp = file;
6767 +
6768 +diff --git a/fs/proc/stat.c b/fs/proc/stat.c
6769 +index 64c3b31..e296572 100644
6770 +--- a/fs/proc/stat.c
6771 ++++ b/fs/proc/stat.c
6772 +@@ -45,10 +45,13 @@ static cputime64_t get_iowait_time(int cpu)
6773 +
6774 + static u64 get_idle_time(int cpu)
6775 + {
6776 +- u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL);
6777 ++ u64 idle, idle_time = -1ULL;
6778 ++
6779 ++ if (cpu_online(cpu))
6780 ++ idle_time = get_cpu_idle_time_us(cpu, NULL);
6781 +
6782 + if (idle_time == -1ULL)
6783 +- /* !NO_HZ so we can rely on cpustat.idle */
6784 ++ /* !NO_HZ or cpu offline so we can rely on cpustat.idle */
6785 + idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
6786 + else
6787 + idle = usecs_to_cputime64(idle_time);
6788 +@@ -58,10 +61,13 @@ static u64 get_idle_time(int cpu)
6789 +
6790 + static u64 get_iowait_time(int cpu)
6791 + {
6792 +- u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL);
6793 ++ u64 iowait, iowait_time = -1ULL;
6794 ++
6795 ++ if (cpu_online(cpu))
6796 ++ iowait_time = get_cpu_iowait_time_us(cpu, NULL);
6797 +
6798 + if (iowait_time == -1ULL)
6799 +- /* !NO_HZ so we can rely on cpustat.iowait */
6800 ++ /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
6801 + iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
6802 + else
6803 + iowait = usecs_to_cputime64(iowait_time);
6804 +diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
6805 +index a810987..561e130 100644
6806 +--- a/include/linux/if_vlan.h
6807 ++++ b/include/linux/if_vlan.h
6808 +@@ -82,6 +82,8 @@ static inline int is_vlan_dev(struct net_device *dev)
6809 + }
6810 +
6811 + #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
6812 ++#define vlan_tx_nonzero_tag_present(__skb) \
6813 ++ (vlan_tx_tag_present(__skb) && ((__skb)->vlan_tci & VLAN_VID_MASK))
6814 + #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
6815 +
6816 + #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
6817 +@@ -91,7 +93,7 @@ extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
6818 + extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
6819 + extern u16 vlan_dev_vlan_id(const struct net_device *dev);
6820 +
6821 +-extern bool vlan_do_receive(struct sk_buff **skb, bool last_handler);
6822 ++extern bool vlan_do_receive(struct sk_buff **skb);
6823 + extern struct sk_buff *vlan_untag(struct sk_buff *skb);
6824 +
6825 + extern int vlan_vid_add(struct net_device *dev, unsigned short vid);
6826 +@@ -120,10 +122,8 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
6827 + return 0;
6828 + }
6829 +
6830 +-static inline bool vlan_do_receive(struct sk_buff **skb, bool last_handler)
6831 ++static inline bool vlan_do_receive(struct sk_buff **skb)
6832 + {
6833 +- if (((*skb)->vlan_tci & VLAN_VID_MASK) && last_handler)
6834 +- (*skb)->pkt_type = PACKET_OTHERHOST;
6835 + return false;
6836 + }
6837 +
6838 +diff --git a/include/linux/netlink.h b/include/linux/netlink.h
6839 +index f74dd13..e893736 100644
6840 +--- a/include/linux/netlink.h
6841 ++++ b/include/linux/netlink.h
6842 +@@ -153,6 +153,7 @@ struct nlattr {
6843 +
6844 + #include <linux/capability.h>
6845 + #include <linux/skbuff.h>
6846 ++#include <linux/export.h>
6847 +
6848 + struct net;
6849 +
6850 +@@ -232,6 +233,8 @@ struct netlink_callback {
6851 + struct netlink_callback *cb);
6852 + int (*done)(struct netlink_callback *cb);
6853 + void *data;
6854 ++ /* the module that dump function belong to */
6855 ++ struct module *module;
6856 + u16 family;
6857 + u16 min_dump_alloc;
6858 + unsigned int prev_seq, seq;
6859 +@@ -249,14 +252,24 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
6860 +
6861 + struct netlink_dump_control {
6862 + int (*dump)(struct sk_buff *skb, struct netlink_callback *);
6863 +- int (*done)(struct netlink_callback*);
6864 ++ int (*done)(struct netlink_callback *);
6865 + void *data;
6866 ++ struct module *module;
6867 + u16 min_dump_alloc;
6868 + };
6869 +
6870 +-extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
6871 +- const struct nlmsghdr *nlh,
6872 +- struct netlink_dump_control *control);
6873 ++extern int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
6874 ++ const struct nlmsghdr *nlh,
6875 ++ struct netlink_dump_control *control);
6876 ++static inline int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
6877 ++ const struct nlmsghdr *nlh,
6878 ++ struct netlink_dump_control *control)
6879 ++{
6880 ++ if (!control->module)
6881 ++ control->module = THIS_MODULE;
6882 ++
6883 ++ return __netlink_dump_start(ssk, skb, nlh, control);
6884 ++}
6885 +
6886 +
6887 + #define NL_NONROOT_RECV 0x1
6888 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
6889 +index 7632c87..f3165d2 100644
6890 +--- a/include/linux/skbuff.h
6891 ++++ b/include/linux/skbuff.h
6892 +@@ -589,9 +589,6 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
6893 + return __alloc_skb(size, priority, SKB_ALLOC_FCLONE, NUMA_NO_NODE);
6894 + }
6895 +
6896 +-extern void skb_recycle(struct sk_buff *skb);
6897 +-extern bool skb_recycle_check(struct sk_buff *skb, int skb_size);
6898 +-
6899 + extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
6900 + extern int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask);
6901 + extern struct sk_buff *skb_clone(struct sk_buff *skb,
6902 +@@ -2642,27 +2639,6 @@ static inline void skb_checksum_none_assert(const struct sk_buff *skb)
6903 +
6904 + bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
6905 +
6906 +-static inline bool skb_is_recycleable(const struct sk_buff *skb, int skb_size)
6907 +-{
6908 +- if (irqs_disabled())
6909 +- return false;
6910 +-
6911 +- if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY)
6912 +- return false;
6913 +-
6914 +- if (skb_is_nonlinear(skb) || skb->fclone != SKB_FCLONE_UNAVAILABLE)
6915 +- return false;
6916 +-
6917 +- skb_size = SKB_DATA_ALIGN(skb_size + NET_SKB_PAD);
6918 +- if (skb_end_offset(skb) < skb_size)
6919 +- return false;
6920 +-
6921 +- if (skb_shared(skb) || skb_cloned(skb))
6922 +- return false;
6923 +-
6924 +- return true;
6925 +-}
6926 +-
6927 + /**
6928 + * skb_head_is_locked - Determine if the skb->head is locked down
6929 + * @skb: skb to check
6930 +diff --git a/include/net/flow.h b/include/net/flow.h
6931 +index e1dd508..628e11b 100644
6932 +--- a/include/net/flow.h
6933 ++++ b/include/net/flow.h
6934 +@@ -21,6 +21,7 @@ struct flowi_common {
6935 + __u8 flowic_flags;
6936 + #define FLOWI_FLAG_ANYSRC 0x01
6937 + #define FLOWI_FLAG_CAN_SLEEP 0x02
6938 ++#define FLOWI_FLAG_KNOWN_NH 0x04
6939 + __u32 flowic_secid;
6940 + };
6941 +
6942 +diff --git a/include/net/route.h b/include/net/route.h
6943 +index da22243..bc40b63 100644
6944 +--- a/include/net/route.h
6945 ++++ b/include/net/route.h
6946 +@@ -48,7 +48,8 @@ struct rtable {
6947 + int rt_genid;
6948 + unsigned int rt_flags;
6949 + __u16 rt_type;
6950 +- __u16 rt_is_input;
6951 ++ __u8 rt_is_input;
6952 ++ __u8 rt_uses_gateway;
6953 +
6954 + int rt_iif;
6955 +
6956 +diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
6957 +index 3c5363a..bd3d8b2 100644
6958 +--- a/include/rdma/rdma_netlink.h
6959 ++++ b/include/rdma/rdma_netlink.h
6960 +@@ -39,6 +39,7 @@ struct rdma_cm_id_stats {
6961 +
6962 + struct ibnl_client_cbs {
6963 + int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
6964 ++ struct module *module;
6965 + };
6966 +
6967 + int ibnl_init(void);
6968 +diff --git a/kernel/cgroup.c b/kernel/cgroup.c
6969 +index 7981850..ff2bce5 100644
6970 +--- a/kernel/cgroup.c
6971 ++++ b/kernel/cgroup.c
6972 +@@ -1923,9 +1923,8 @@ static void cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
6973 + * trading it for newcg is protected by cgroup_mutex, we're safe to drop
6974 + * it here; it will be freed under RCU.
6975 + */
6976 +- put_css_set(oldcg);
6977 +-
6978 + set_bit(CGRP_RELEASABLE, &oldcgrp->flags);
6979 ++ put_css_set(oldcg);
6980 + }
6981 +
6982 + /**
6983 +@@ -4695,31 +4694,20 @@ static const struct file_operations proc_cgroupstats_operations = {
6984 + *
6985 + * A pointer to the shared css_set was automatically copied in
6986 + * fork.c by dup_task_struct(). However, we ignore that copy, since
6987 +- * it was not made under the protection of RCU, cgroup_mutex or
6988 +- * threadgroup_change_begin(), so it might no longer be a valid
6989 +- * cgroup pointer. cgroup_attach_task() might have already changed
6990 +- * current->cgroups, allowing the previously referenced cgroup
6991 +- * group to be removed and freed.
6992 +- *
6993 +- * Outside the pointer validity we also need to process the css_set
6994 +- * inheritance between threadgoup_change_begin() and
6995 +- * threadgoup_change_end(), this way there is no leak in any process
6996 +- * wide migration performed by cgroup_attach_proc() that could otherwise
6997 +- * miss a thread because it is too early or too late in the fork stage.
6998 ++ * it was not made under the protection of RCU or cgroup_mutex, so
6999 ++ * might no longer be a valid cgroup pointer. cgroup_attach_task() might
7000 ++ * have already changed current->cgroups, allowing the previously
7001 ++ * referenced cgroup group to be removed and freed.
7002 + *
7003 + * At the point that cgroup_fork() is called, 'current' is the parent
7004 + * task, and the passed argument 'child' points to the child task.
7005 + */
7006 + void cgroup_fork(struct task_struct *child)
7007 + {
7008 +- /*
7009 +- * We don't need to task_lock() current because current->cgroups
7010 +- * can't be changed concurrently here. The parent obviously hasn't
7011 +- * exited and called cgroup_exit(), and we are synchronized against
7012 +- * cgroup migration through threadgroup_change_begin().
7013 +- */
7014 ++ task_lock(current);
7015 + child->cgroups = current->cgroups;
7016 + get_css_set(child->cgroups);
7017 ++ task_unlock(current);
7018 + INIT_LIST_HEAD(&child->cg_list);
7019 + }
7020 +
7021 +@@ -4772,19 +4760,10 @@ void cgroup_post_fork(struct task_struct *child)
7022 + */
7023 + if (use_task_css_set_links) {
7024 + write_lock(&css_set_lock);
7025 +- if (list_empty(&child->cg_list)) {
7026 +- /*
7027 +- * It's safe to use child->cgroups without task_lock()
7028 +- * here because we are protected through
7029 +- * threadgroup_change_begin() against concurrent
7030 +- * css_set change in cgroup_task_migrate(). Also
7031 +- * the task can't exit at that point until
7032 +- * wake_up_new_task() is called, so we are protected
7033 +- * against cgroup_exit() setting child->cgroup to
7034 +- * init_css_set.
7035 +- */
7036 ++ task_lock(child);
7037 ++ if (list_empty(&child->cg_list))
7038 + list_add(&child->cg_list, &child->cgroups->tasks);
7039 +- }
7040 ++ task_unlock(child);
7041 + write_unlock(&css_set_lock);
7042 + }
7043 + }
7044 +diff --git a/kernel/sys.c b/kernel/sys.c
7045 +index 6fab59a..909148a 100644
7046 +--- a/kernel/sys.c
7047 ++++ b/kernel/sys.c
7048 +@@ -1265,15 +1265,16 @@ DECLARE_RWSEM(uts_sem);
7049 + * Work around broken programs that cannot handle "Linux 3.0".
7050 + * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
7051 + */
7052 +-static int override_release(char __user *release, int len)
7053 ++static int override_release(char __user *release, size_t len)
7054 + {
7055 + int ret = 0;
7056 +- char buf[65];
7057 +
7058 + if (current->personality & UNAME26) {
7059 +- char *rest = UTS_RELEASE;
7060 ++ const char *rest = UTS_RELEASE;
7061 ++ char buf[65] = { 0 };
7062 + int ndots = 0;
7063 + unsigned v;
7064 ++ size_t copy;
7065 +
7066 + while (*rest) {
7067 + if (*rest == '.' && ++ndots >= 3)
7068 +@@ -1283,8 +1284,9 @@ static int override_release(char __user *release, int len)
7069 + rest++;
7070 + }
7071 + v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
7072 +- snprintf(buf, len, "2.6.%u%s", v, rest);
7073 +- ret = copy_to_user(release, buf, len);
7074 ++ copy = clamp_t(size_t, len, 1, sizeof(buf));
7075 ++ copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
7076 ++ ret = copy_to_user(release, buf, copy + 1);
7077 + }
7078 + return ret;
7079 + }
7080 +diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
7081 +index 49491fa..ebd284f 100644
7082 +--- a/kernel/trace/ring_buffer.c
7083 ++++ b/kernel/trace/ring_buffer.c
7084 +@@ -1567,6 +1567,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
7085 +
7086 + put_online_cpus();
7087 + } else {
7088 ++ /* Make sure this CPU has been intitialized */
7089 ++ if (!cpumask_test_cpu(cpu_id, buffer->cpumask))
7090 ++ goto out;
7091 ++
7092 + cpu_buffer = buffer->buffers[cpu_id];
7093 +
7094 + if (nr_pages == cpu_buffer->nr_pages)
7095 +diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
7096 +index 830059d..fe29a64 100644
7097 +--- a/net/8021q/vlan_core.c
7098 ++++ b/net/8021q/vlan_core.c
7099 +@@ -5,7 +5,7 @@
7100 + #include <linux/export.h>
7101 + #include "vlan.h"
7102 +
7103 +-bool vlan_do_receive(struct sk_buff **skbp, bool last_handler)
7104 ++bool vlan_do_receive(struct sk_buff **skbp)
7105 + {
7106 + struct sk_buff *skb = *skbp;
7107 + u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK;
7108 +@@ -13,14 +13,8 @@ bool vlan_do_receive(struct sk_buff **skbp, bool last_handler)
7109 + struct vlan_pcpu_stats *rx_stats;
7110 +
7111 + vlan_dev = vlan_find_dev(skb->dev, vlan_id);
7112 +- if (!vlan_dev) {
7113 +- /* Only the last call to vlan_do_receive() should change
7114 +- * pkt_type to PACKET_OTHERHOST
7115 +- */
7116 +- if (vlan_id && last_handler)
7117 +- skb->pkt_type = PACKET_OTHERHOST;
7118 ++ if (!vlan_dev)
7119 + return false;
7120 +- }
7121 +
7122 + skb = *skbp = skb_share_check(skb, GFP_ATOMIC);
7123 + if (unlikely(!skb))
7124 +diff --git a/net/core/dev.c b/net/core/dev.c
7125 +index 89e33a5..2fb9f59 100644
7126 +--- a/net/core/dev.c
7127 ++++ b/net/core/dev.c
7128 +@@ -3275,18 +3275,18 @@ ncls:
7129 + && !skb_pfmemalloc_protocol(skb))
7130 + goto drop;
7131 +
7132 +- rx_handler = rcu_dereference(skb->dev->rx_handler);
7133 + if (vlan_tx_tag_present(skb)) {
7134 + if (pt_prev) {
7135 + ret = deliver_skb(skb, pt_prev, orig_dev);
7136 + pt_prev = NULL;
7137 + }
7138 +- if (vlan_do_receive(&skb, !rx_handler))
7139 ++ if (vlan_do_receive(&skb))
7140 + goto another_round;
7141 + else if (unlikely(!skb))
7142 + goto unlock;
7143 + }
7144 +
7145 ++ rx_handler = rcu_dereference(skb->dev->rx_handler);
7146 + if (rx_handler) {
7147 + if (pt_prev) {
7148 + ret = deliver_skb(skb, pt_prev, orig_dev);
7149 +@@ -3306,6 +3306,9 @@ ncls:
7150 + }
7151 + }
7152 +
7153 ++ if (vlan_tx_nonzero_tag_present(skb))
7154 ++ skb->pkt_type = PACKET_OTHERHOST;
7155 ++
7156 + /* deliver only exact match when indicated */
7157 + null_or_dev = deliver_exact ? skb->dev : NULL;
7158 +
7159 +diff --git a/net/core/neighbour.c b/net/core/neighbour.c
7160 +index 117afaf..058bb1e 100644
7161 +--- a/net/core/neighbour.c
7162 ++++ b/net/core/neighbour.c
7163 +@@ -1301,8 +1301,6 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
7164 + if (!dst)
7165 + goto discard;
7166 +
7167 +- __skb_pull(skb, skb_network_offset(skb));
7168 +-
7169 + if (!neigh_event_send(neigh, skb)) {
7170 + int err;
7171 + struct net_device *dev = neigh->dev;
7172 +@@ -1312,6 +1310,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
7173 + neigh_hh_init(neigh, dst);
7174 +
7175 + do {
7176 ++ __skb_pull(skb, skb_network_offset(skb));
7177 + seq = read_seqbegin(&neigh->ha_lock);
7178 + err = dev_hard_header(skb, dev, ntohs(skb->protocol),
7179 + neigh->ha, NULL, skb->len);
7180 +@@ -1342,9 +1341,8 @@ int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb)
7181 + unsigned int seq;
7182 + int err;
7183 +
7184 +- __skb_pull(skb, skb_network_offset(skb));
7185 +-
7186 + do {
7187 ++ __skb_pull(skb, skb_network_offset(skb));
7188 + seq = read_seqbegin(&neigh->ha_lock);
7189 + err = dev_hard_header(skb, dev, ntohs(skb->protocol),
7190 + neigh->ha, NULL, skb->len);
7191 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
7192 +index e33ebae..ef172af 100644
7193 +--- a/net/core/skbuff.c
7194 ++++ b/net/core/skbuff.c
7195 +@@ -641,53 +641,6 @@ void consume_skb(struct sk_buff *skb)
7196 + }
7197 + EXPORT_SYMBOL(consume_skb);
7198 +
7199 +-/**
7200 +- * skb_recycle - clean up an skb for reuse
7201 +- * @skb: buffer
7202 +- *
7203 +- * Recycles the skb to be reused as a receive buffer. This
7204 +- * function does any necessary reference count dropping, and
7205 +- * cleans up the skbuff as if it just came from __alloc_skb().
7206 +- */
7207 +-void skb_recycle(struct sk_buff *skb)
7208 +-{
7209 +- struct skb_shared_info *shinfo;
7210 +-
7211 +- skb_release_head_state(skb);
7212 +-
7213 +- shinfo = skb_shinfo(skb);
7214 +- memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
7215 +- atomic_set(&shinfo->dataref, 1);
7216 +-
7217 +- memset(skb, 0, offsetof(struct sk_buff, tail));
7218 +- skb->data = skb->head + NET_SKB_PAD;
7219 +- skb_reset_tail_pointer(skb);
7220 +-}
7221 +-EXPORT_SYMBOL(skb_recycle);
7222 +-
7223 +-/**
7224 +- * skb_recycle_check - check if skb can be reused for receive
7225 +- * @skb: buffer
7226 +- * @skb_size: minimum receive buffer size
7227 +- *
7228 +- * Checks that the skb passed in is not shared or cloned, and
7229 +- * that it is linear and its head portion at least as large as
7230 +- * skb_size so that it can be recycled as a receive buffer.
7231 +- * If these conditions are met, this function does any necessary
7232 +- * reference count dropping and cleans up the skbuff as if it
7233 +- * just came from __alloc_skb().
7234 +- */
7235 +-bool skb_recycle_check(struct sk_buff *skb, int skb_size)
7236 +-{
7237 +- if (!skb_is_recycleable(skb, skb_size))
7238 +- return false;
7239 +-
7240 +- skb_recycle(skb);
7241 +-
7242 +- return true;
7243 +-}
7244 +-EXPORT_SYMBOL(skb_recycle_check);
7245 +-
7246 + static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
7247 + {
7248 + new->tstamp = old->tstamp;
7249 +diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
7250 +index 8e2b475..f444ac7 100644
7251 +--- a/net/ipv4/fib_frontend.c
7252 ++++ b/net/ipv4/fib_frontend.c
7253 +@@ -322,7 +322,8 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
7254 + {
7255 + int r = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(idev);
7256 +
7257 +- if (!r && !fib_num_tclassid_users(dev_net(dev))) {
7258 ++ if (!r && !fib_num_tclassid_users(dev_net(dev)) &&
7259 ++ (dev->ifindex != oif || !IN_DEV_TX_REDIRECTS(idev))) {
7260 + *itag = 0;
7261 + return 0;
7262 + }
7263 +diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
7264 +index a747100..9633661 100644
7265 +--- a/net/ipv4/fib_semantics.c
7266 ++++ b/net/ipv4/fib_semantics.c
7267 +@@ -840,6 +840,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
7268 + change_nexthops(fi) {
7269 + nexthop_nh->nh_parent = fi;
7270 + nexthop_nh->nh_pcpu_rth_output = alloc_percpu(struct rtable __rcu *);
7271 ++ if (!nexthop_nh->nh_pcpu_rth_output)
7272 ++ goto failure;
7273 + } endfor_nexthops(fi)
7274 +
7275 + if (cfg->fc_mx) {
7276 +diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
7277 +index 7f75f21..0405cc8 100644
7278 +--- a/net/ipv4/inet_connection_sock.c
7279 ++++ b/net/ipv4/inet_connection_sock.c
7280 +@@ -386,7 +386,7 @@ struct dst_entry *inet_csk_route_req(struct sock *sk,
7281 + rt = ip_route_output_flow(net, fl4, sk);
7282 + if (IS_ERR(rt))
7283 + goto no_route;
7284 +- if (opt && opt->opt.is_strictroute && rt->rt_gateway)
7285 ++ if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)
7286 + goto route_err;
7287 + return &rt->dst;
7288 +
7289 +@@ -422,7 +422,7 @@ struct dst_entry *inet_csk_route_child_sock(struct sock *sk,
7290 + rt = ip_route_output_flow(net, fl4, sk);
7291 + if (IS_ERR(rt))
7292 + goto no_route;
7293 +- if (opt && opt->opt.is_strictroute && rt->rt_gateway)
7294 ++ if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)
7295 + goto route_err;
7296 + rcu_read_unlock();
7297 + return &rt->dst;
7298 +diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
7299 +index ab09b12..694de3b 100644
7300 +--- a/net/ipv4/ip_forward.c
7301 ++++ b/net/ipv4/ip_forward.c
7302 +@@ -85,7 +85,7 @@ int ip_forward(struct sk_buff *skb)
7303 +
7304 + rt = skb_rtable(skb);
7305 +
7306 +- if (opt->is_strictroute && opt->nexthop != rt->rt_gateway)
7307 ++ if (opt->is_strictroute && rt->rt_uses_gateway)
7308 + goto sr_failed;
7309 +
7310 + if (unlikely(skb->len > dst_mtu(&rt->dst) && !skb_is_gso(skb) &&
7311 +diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
7312 +index c196d74..94ad7ea 100644
7313 +--- a/net/ipv4/ip_output.c
7314 ++++ b/net/ipv4/ip_output.c
7315 +@@ -193,7 +193,7 @@ static inline int ip_finish_output2(struct sk_buff *skb)
7316 + }
7317 +
7318 + rcu_read_lock_bh();
7319 +- nexthop = rt->rt_gateway ? rt->rt_gateway : ip_hdr(skb)->daddr;
7320 ++ nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr);
7321 + neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
7322 + if (unlikely(!neigh))
7323 + neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
7324 +@@ -371,7 +371,7 @@ int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl)
7325 + skb_dst_set_noref(skb, &rt->dst);
7326 +
7327 + packet_routed:
7328 +- if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_gateway)
7329 ++ if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_uses_gateway)
7330 + goto no_route;
7331 +
7332 + /* OK, we know where to send it, allocate and build IP header. */
7333 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
7334 +index fd9af60..2a1383c 100644
7335 +--- a/net/ipv4/route.c
7336 ++++ b/net/ipv4/route.c
7337 +@@ -802,7 +802,8 @@ void ip_rt_send_redirect(struct sk_buff *skb)
7338 + net = dev_net(rt->dst.dev);
7339 + peer = inet_getpeer_v4(net->ipv4.peers, ip_hdr(skb)->saddr, 1);
7340 + if (!peer) {
7341 +- icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
7342 ++ icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST,
7343 ++ rt_nexthop(rt, ip_hdr(skb)->daddr));
7344 + return;
7345 + }
7346 +
7347 +@@ -827,7 +828,9 @@ void ip_rt_send_redirect(struct sk_buff *skb)
7348 + time_after(jiffies,
7349 + (peer->rate_last +
7350 + (ip_rt_redirect_load << peer->rate_tokens)))) {
7351 +- icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
7352 ++ __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr);
7353 ++
7354 ++ icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, gw);
7355 + peer->rate_last = jiffies;
7356 + ++peer->rate_tokens;
7357 + #ifdef CONFIG_IP_ROUTE_VERBOSE
7358 +@@ -835,7 +838,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
7359 + peer->rate_tokens == ip_rt_redirect_number)
7360 + net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n",
7361 + &ip_hdr(skb)->saddr, inet_iif(skb),
7362 +- &ip_hdr(skb)->daddr, &rt->rt_gateway);
7363 ++ &ip_hdr(skb)->daddr, &gw);
7364 + #endif
7365 + }
7366 + out_put_peer:
7367 +@@ -904,22 +907,32 @@ out: kfree_skb(skb);
7368 + return 0;
7369 + }
7370 +
7371 +-static u32 __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
7372 ++static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
7373 + {
7374 ++ struct dst_entry *dst = &rt->dst;
7375 + struct fib_result res;
7376 +
7377 ++ if (dst->dev->mtu < mtu)
7378 ++ return;
7379 ++
7380 + if (mtu < ip_rt_min_pmtu)
7381 + mtu = ip_rt_min_pmtu;
7382 +
7383 ++ if (!rt->rt_pmtu) {
7384 ++ dst->obsolete = DST_OBSOLETE_KILL;
7385 ++ } else {
7386 ++ rt->rt_pmtu = mtu;
7387 ++ dst->expires = max(1UL, jiffies + ip_rt_mtu_expires);
7388 ++ }
7389 ++
7390 + rcu_read_lock();
7391 +- if (fib_lookup(dev_net(rt->dst.dev), fl4, &res) == 0) {
7392 ++ if (fib_lookup(dev_net(dst->dev), fl4, &res) == 0) {
7393 + struct fib_nh *nh = &FIB_RES_NH(res);
7394 +
7395 + update_or_create_fnhe(nh, fl4->daddr, 0, mtu,
7396 + jiffies + ip_rt_mtu_expires);
7397 + }
7398 + rcu_read_unlock();
7399 +- return mtu;
7400 + }
7401 +
7402 + static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
7403 +@@ -929,14 +942,7 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
7404 + struct flowi4 fl4;
7405 +
7406 + ip_rt_build_flow_key(&fl4, sk, skb);
7407 +- mtu = __ip_rt_update_pmtu(rt, &fl4, mtu);
7408 +-
7409 +- if (!rt->rt_pmtu) {
7410 +- dst->obsolete = DST_OBSOLETE_KILL;
7411 +- } else {
7412 +- rt->rt_pmtu = mtu;
7413 +- rt->dst.expires = max(1UL, jiffies + ip_rt_mtu_expires);
7414 +- }
7415 ++ __ip_rt_update_pmtu(rt, &fl4, mtu);
7416 + }
7417 +
7418 + void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu,
7419 +@@ -1123,7 +1129,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
7420 + mtu = dst->dev->mtu;
7421 +
7422 + if (unlikely(dst_metric_locked(dst, RTAX_MTU))) {
7423 +- if (rt->rt_gateway && mtu > 576)
7424 ++ if (rt->rt_uses_gateway && mtu > 576)
7425 + mtu = 576;
7426 + }
7427 +
7428 +@@ -1174,7 +1180,9 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
7429 + if (fnhe->fnhe_gw) {
7430 + rt->rt_flags |= RTCF_REDIRECTED;
7431 + rt->rt_gateway = fnhe->fnhe_gw;
7432 +- }
7433 ++ rt->rt_uses_gateway = 1;
7434 ++ } else if (!rt->rt_gateway)
7435 ++ rt->rt_gateway = daddr;
7436 +
7437 + orig = rcu_dereference(fnhe->fnhe_rth);
7438 + rcu_assign_pointer(fnhe->fnhe_rth, rt);
7439 +@@ -1183,13 +1191,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
7440 +
7441 + fnhe->fnhe_stamp = jiffies;
7442 + ret = true;
7443 +- } else {
7444 +- /* Routes we intend to cache in nexthop exception have
7445 +- * the DST_NOCACHE bit clear. However, if we are
7446 +- * unsuccessful at storing this route into the cache
7447 +- * we really need to set it.
7448 +- */
7449 +- rt->dst.flags |= DST_NOCACHE;
7450 + }
7451 + spin_unlock_bh(&fnhe_lock);
7452 +
7453 +@@ -1204,8 +1205,6 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
7454 + if (rt_is_input_route(rt)) {
7455 + p = (struct rtable **)&nh->nh_rth_input;
7456 + } else {
7457 +- if (!nh->nh_pcpu_rth_output)
7458 +- goto nocache;
7459 + p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
7460 + }
7461 + orig = *p;
7462 +@@ -1214,16 +1213,8 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
7463 + if (prev == orig) {
7464 + if (orig)
7465 + rt_free(orig);
7466 +- } else {
7467 +- /* Routes we intend to cache in the FIB nexthop have
7468 +- * the DST_NOCACHE bit clear. However, if we are
7469 +- * unsuccessful at storing this route into the cache
7470 +- * we really need to set it.
7471 +- */
7472 +-nocache:
7473 +- rt->dst.flags |= DST_NOCACHE;
7474 ++ } else
7475 + ret = false;
7476 +- }
7477 +
7478 + return ret;
7479 + }
7480 +@@ -1284,8 +1275,10 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
7481 + if (fi) {
7482 + struct fib_nh *nh = &FIB_RES_NH(*res);
7483 +
7484 +- if (nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK)
7485 ++ if (nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) {
7486 + rt->rt_gateway = nh->nh_gw;
7487 ++ rt->rt_uses_gateway = 1;
7488 ++ }
7489 + dst_init_metrics(&rt->dst, fi->fib_metrics, true);
7490 + #ifdef CONFIG_IP_ROUTE_CLASSID
7491 + rt->dst.tclassid = nh->nh_tclassid;
7492 +@@ -1294,8 +1287,18 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
7493 + cached = rt_bind_exception(rt, fnhe, daddr);
7494 + else if (!(rt->dst.flags & DST_NOCACHE))
7495 + cached = rt_cache_route(nh, rt);
7496 +- }
7497 +- if (unlikely(!cached))
7498 ++ if (unlikely(!cached)) {
7499 ++ /* Routes we intend to cache in nexthop exception or
7500 ++ * FIB nexthop have the DST_NOCACHE bit clear.
7501 ++ * However, if we are unsuccessful at storing this
7502 ++ * route into the cache we really need to set it.
7503 ++ */
7504 ++ rt->dst.flags |= DST_NOCACHE;
7505 ++ if (!rt->rt_gateway)
7506 ++ rt->rt_gateway = daddr;
7507 ++ rt_add_uncached_list(rt);
7508 ++ }
7509 ++ } else
7510 + rt_add_uncached_list(rt);
7511 +
7512 + #ifdef CONFIG_IP_ROUTE_CLASSID
7513 +@@ -1363,6 +1366,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
7514 + rth->rt_iif = 0;
7515 + rth->rt_pmtu = 0;
7516 + rth->rt_gateway = 0;
7517 ++ rth->rt_uses_gateway = 0;
7518 + INIT_LIST_HEAD(&rth->rt_uncached);
7519 + if (our) {
7520 + rth->dst.input= ip_local_deliver;
7521 +@@ -1432,7 +1436,6 @@ static int __mkroute_input(struct sk_buff *skb,
7522 + return -EINVAL;
7523 + }
7524 +
7525 +-
7526 + err = fib_validate_source(skb, saddr, daddr, tos, FIB_RES_OIF(*res),
7527 + in_dev->dev, in_dev, &itag);
7528 + if (err < 0) {
7529 +@@ -1442,10 +1445,13 @@ static int __mkroute_input(struct sk_buff *skb,
7530 + goto cleanup;
7531 + }
7532 +
7533 +- if (out_dev == in_dev && err &&
7534 ++ do_cache = res->fi && !itag;
7535 ++ if (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) &&
7536 + (IN_DEV_SHARED_MEDIA(out_dev) ||
7537 +- inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res))))
7538 ++ inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) {
7539 + flags |= RTCF_DOREDIRECT;
7540 ++ do_cache = false;
7541 ++ }
7542 +
7543 + if (skb->protocol != htons(ETH_P_IP)) {
7544 + /* Not IP (i.e. ARP). Do not create route, if it is
7545 +@@ -1462,15 +1468,11 @@ static int __mkroute_input(struct sk_buff *skb,
7546 + }
7547 + }
7548 +
7549 +- do_cache = false;
7550 +- if (res->fi) {
7551 +- if (!itag) {
7552 +- rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
7553 +- if (rt_cache_valid(rth)) {
7554 +- skb_dst_set_noref(skb, &rth->dst);
7555 +- goto out;
7556 +- }
7557 +- do_cache = true;
7558 ++ if (do_cache) {
7559 ++ rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
7560 ++ if (rt_cache_valid(rth)) {
7561 ++ skb_dst_set_noref(skb, &rth->dst);
7562 ++ goto out;
7563 + }
7564 + }
7565 +
7566 +@@ -1489,6 +1491,7 @@ static int __mkroute_input(struct sk_buff *skb,
7567 + rth->rt_iif = 0;
7568 + rth->rt_pmtu = 0;
7569 + rth->rt_gateway = 0;
7570 ++ rth->rt_uses_gateway = 0;
7571 + INIT_LIST_HEAD(&rth->rt_uncached);
7572 +
7573 + rth->dst.input = ip_forward;
7574 +@@ -1656,6 +1659,7 @@ local_input:
7575 + rth->rt_iif = 0;
7576 + rth->rt_pmtu = 0;
7577 + rth->rt_gateway = 0;
7578 ++ rth->rt_uses_gateway = 0;
7579 + INIT_LIST_HEAD(&rth->rt_uncached);
7580 + if (res.type == RTN_UNREACHABLE) {
7581 + rth->dst.input= ip_error;
7582 +@@ -1758,6 +1762,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
7583 + struct in_device *in_dev;
7584 + u16 type = res->type;
7585 + struct rtable *rth;
7586 ++ bool do_cache;
7587 +
7588 + in_dev = __in_dev_get_rcu(dev_out);
7589 + if (!in_dev)
7590 +@@ -1794,24 +1799,36 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
7591 + }
7592 +
7593 + fnhe = NULL;
7594 ++ do_cache = fi != NULL;
7595 + if (fi) {
7596 + struct rtable __rcu **prth;
7597 ++ struct fib_nh *nh = &FIB_RES_NH(*res);
7598 +
7599 +- fnhe = find_exception(&FIB_RES_NH(*res), fl4->daddr);
7600 ++ fnhe = find_exception(nh, fl4->daddr);
7601 + if (fnhe)
7602 + prth = &fnhe->fnhe_rth;
7603 +- else
7604 +- prth = __this_cpu_ptr(FIB_RES_NH(*res).nh_pcpu_rth_output);
7605 ++ else {
7606 ++ if (unlikely(fl4->flowi4_flags &
7607 ++ FLOWI_FLAG_KNOWN_NH &&
7608 ++ !(nh->nh_gw &&
7609 ++ nh->nh_scope == RT_SCOPE_LINK))) {
7610 ++ do_cache = false;
7611 ++ goto add;
7612 ++ }
7613 ++ prth = __this_cpu_ptr(nh->nh_pcpu_rth_output);
7614 ++ }
7615 + rth = rcu_dereference(*prth);
7616 + if (rt_cache_valid(rth)) {
7617 + dst_hold(&rth->dst);
7618 + return rth;
7619 + }
7620 + }
7621 ++
7622 ++add:
7623 + rth = rt_dst_alloc(dev_out,
7624 + IN_DEV_CONF_GET(in_dev, NOPOLICY),
7625 + IN_DEV_CONF_GET(in_dev, NOXFRM),
7626 +- fi);
7627 ++ do_cache);
7628 + if (!rth)
7629 + return ERR_PTR(-ENOBUFS);
7630 +
7631 +@@ -1824,6 +1841,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
7632 + rth->rt_iif = orig_oif ? : 0;
7633 + rth->rt_pmtu = 0;
7634 + rth->rt_gateway = 0;
7635 ++ rth->rt_uses_gateway = 0;
7636 + INIT_LIST_HEAD(&rth->rt_uncached);
7637 +
7638 + RT_CACHE_STAT_INC(out_slow_tot);
7639 +@@ -2102,6 +2120,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
7640 + rt->rt_flags = ort->rt_flags;
7641 + rt->rt_type = ort->rt_type;
7642 + rt->rt_gateway = ort->rt_gateway;
7643 ++ rt->rt_uses_gateway = ort->rt_uses_gateway;
7644 +
7645 + INIT_LIST_HEAD(&rt->rt_uncached);
7646 +
7647 +@@ -2180,12 +2199,22 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
7648 + if (nla_put_be32(skb, RTA_PREFSRC, fl4->saddr))
7649 + goto nla_put_failure;
7650 + }
7651 +- if (rt->rt_gateway &&
7652 ++ if (rt->rt_uses_gateway &&
7653 + nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway))
7654 + goto nla_put_failure;
7655 +
7656 ++ expires = rt->dst.expires;
7657 ++ if (expires) {
7658 ++ unsigned long now = jiffies;
7659 ++
7660 ++ if (time_before(now, expires))
7661 ++ expires -= now;
7662 ++ else
7663 ++ expires = 0;
7664 ++ }
7665 ++
7666 + memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics));
7667 +- if (rt->rt_pmtu)
7668 ++ if (rt->rt_pmtu && expires)
7669 + metrics[RTAX_MTU - 1] = rt->rt_pmtu;
7670 + if (rtnetlink_put_metrics(skb, metrics) < 0)
7671 + goto nla_put_failure;
7672 +@@ -2195,13 +2224,6 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
7673 + goto nla_put_failure;
7674 +
7675 + error = rt->dst.error;
7676 +- expires = rt->dst.expires;
7677 +- if (expires) {
7678 +- if (time_before(jiffies, expires))
7679 +- expires -= jiffies;
7680 +- else
7681 +- expires = 0;
7682 +- }
7683 +
7684 + if (rt_is_input_route(rt)) {
7685 + if (nla_put_u32(skb, RTA_IIF, rt->rt_iif))
7686 +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
7687 +index 00a748d..db7bfad 100644
7688 +--- a/net/ipv4/tcp_ipv4.c
7689 ++++ b/net/ipv4/tcp_ipv4.c
7690 +@@ -693,10 +693,11 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
7691 + arg.csumoffset = offsetof(struct tcphdr, check) / 2;
7692 + arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK : 0;
7693 + /* When socket is gone, all binding information is lost.
7694 +- * routing might fail in this case. using iif for oif to
7695 +- * make sure we can deliver it
7696 ++ * routing might fail in this case. No choice here, if we choose to force
7697 ++ * input interface, we will misroute in case of asymmetric route.
7698 + */
7699 +- arg.bound_dev_if = sk ? sk->sk_bound_dev_if : inet_iif(skb);
7700 ++ if (sk)
7701 ++ arg.bound_dev_if = sk->sk_bound_dev_if;
7702 +
7703 + net = dev_net(skb_dst(skb)->dev);
7704 + arg.tos = ip_hdr(skb)->tos;
7705 +diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
7706 +index 681ea2f..05c5ab8 100644
7707 +--- a/net/ipv4/xfrm4_policy.c
7708 ++++ b/net/ipv4/xfrm4_policy.c
7709 +@@ -91,6 +91,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
7710 + RTCF_LOCAL);
7711 + xdst->u.rt.rt_type = rt->rt_type;
7712 + xdst->u.rt.rt_gateway = rt->rt_gateway;
7713 ++ xdst->u.rt.rt_uses_gateway = rt->rt_uses_gateway;
7714 + xdst->u.rt.rt_pmtu = rt->rt_pmtu;
7715 + INIT_LIST_HEAD(&xdst->u.rt.rt_uncached);
7716 +
7717 +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
7718 +index ea3e9af..b10374d 100644
7719 +--- a/net/ipv6/addrconf.c
7720 ++++ b/net/ipv6/addrconf.c
7721 +@@ -3088,14 +3088,15 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
7722 + struct hlist_node *n;
7723 + hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
7724 + addr_lst) {
7725 ++ if (!net_eq(dev_net(ifa->idev->dev), net))
7726 ++ continue;
7727 + /* sync with offset */
7728 + if (p < state->offset) {
7729 + p++;
7730 + continue;
7731 + }
7732 + state->offset++;
7733 +- if (net_eq(dev_net(ifa->idev->dev), net))
7734 +- return ifa;
7735 ++ return ifa;
7736 + }
7737 +
7738 + /* prepare for next bucket */
7739 +@@ -3113,18 +3114,20 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
7740 + struct hlist_node *n = &ifa->addr_lst;
7741 +
7742 + hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) {
7743 ++ if (!net_eq(dev_net(ifa->idev->dev), net))
7744 ++ continue;
7745 + state->offset++;
7746 +- if (net_eq(dev_net(ifa->idev->dev), net))
7747 +- return ifa;
7748 ++ return ifa;
7749 + }
7750 +
7751 + while (++state->bucket < IN6_ADDR_HSIZE) {
7752 + state->offset = 0;
7753 + hlist_for_each_entry_rcu_bh(ifa, n,
7754 + &inet6_addr_lst[state->bucket], addr_lst) {
7755 ++ if (!net_eq(dev_net(ifa->idev->dev), net))
7756 ++ continue;
7757 + state->offset++;
7758 +- if (net_eq(dev_net(ifa->idev->dev), net))
7759 +- return ifa;
7760 ++ return ifa;
7761 + }
7762 + }
7763 +
7764 +diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
7765 +index e22e6d8..f757e3b 100644
7766 +--- a/net/ipv6/af_inet6.c
7767 ++++ b/net/ipv6/af_inet6.c
7768 +@@ -880,22 +880,25 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
7769 + nlen = skb_network_header_len(skb);
7770 +
7771 + for (p = *head; p; p = p->next) {
7772 +- struct ipv6hdr *iph2;
7773 ++ const struct ipv6hdr *iph2;
7774 ++ __be32 first_word; /* <Version:4><Traffic_Class:8><Flow_Label:20> */
7775 +
7776 + if (!NAPI_GRO_CB(p)->same_flow)
7777 + continue;
7778 +
7779 + iph2 = ipv6_hdr(p);
7780 ++ first_word = *(__be32 *)iph ^ *(__be32 *)iph2 ;
7781 +
7782 +- /* All fields must match except length. */
7783 ++ /* All fields must match except length and Traffic Class. */
7784 + if (nlen != skb_network_header_len(p) ||
7785 +- memcmp(iph, iph2, offsetof(struct ipv6hdr, payload_len)) ||
7786 ++ (first_word & htonl(0xF00FFFFF)) ||
7787 + memcmp(&iph->nexthdr, &iph2->nexthdr,
7788 + nlen - offsetof(struct ipv6hdr, nexthdr))) {
7789 + NAPI_GRO_CB(p)->same_flow = 0;
7790 + continue;
7791 + }
7792 +-
7793 ++ /* flush if Traffic Class fields are different */
7794 ++ NAPI_GRO_CB(p)->flush |= !!(first_word & htonl(0x0FF00000));
7795 + NAPI_GRO_CB(p)->flush |= flush;
7796 + }
7797 +
7798 +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
7799 +index acd32e3..7e32d42 100644
7800 +--- a/net/ipv6/tcp_ipv6.c
7801 ++++ b/net/ipv6/tcp_ipv6.c
7802 +@@ -863,7 +863,8 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
7803 + __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr);
7804 +
7805 + fl6.flowi6_proto = IPPROTO_TCP;
7806 +- fl6.flowi6_oif = inet6_iif(skb);
7807 ++ if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)
7808 ++ fl6.flowi6_oif = inet6_iif(skb);
7809 + fl6.fl6_dport = t1->dest;
7810 + fl6.fl6_sport = t1->source;
7811 + security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
7812 +diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
7813 +index accfa00..a16b7b4 100644
7814 +--- a/net/mac80211/mesh_sync.c
7815 ++++ b/net/mac80211/mesh_sync.c
7816 +@@ -56,7 +56,6 @@ void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
7817 + u64 tsfdelta;
7818 +
7819 + spin_lock_bh(&ifmsh->sync_offset_lock);
7820 +-
7821 + if (ifmsh->sync_offset_clockdrift_max < beacon_int_fraction) {
7822 + msync_dbg(sdata, "TBTT : max clockdrift=%lld; adjusting\n",
7823 + (long long) ifmsh->sync_offset_clockdrift_max);
7824 +@@ -69,11 +68,11 @@ void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
7825 + tsfdelta = -beacon_int_fraction;
7826 + ifmsh->sync_offset_clockdrift_max -= beacon_int_fraction;
7827 + }
7828 ++ spin_unlock_bh(&ifmsh->sync_offset_lock);
7829 +
7830 + tsf = drv_get_tsf(local, sdata);
7831 + if (tsf != -1ULL)
7832 + drv_set_tsf(local, sdata, tsf + tsfdelta);
7833 +- spin_unlock_bh(&ifmsh->sync_offset_lock);
7834 + }
7835 +
7836 + static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
7837 +diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
7838 +index 65b616a..c3c6291 100644
7839 +--- a/net/netfilter/ipvs/ip_vs_xmit.c
7840 ++++ b/net/netfilter/ipvs/ip_vs_xmit.c
7841 +@@ -49,6 +49,7 @@ enum {
7842 + IP_VS_RT_MODE_RDR = 4, /* Allow redirect from remote daddr to
7843 + * local
7844 + */
7845 ++ IP_VS_RT_MODE_KNOWN_NH = 16,/* Route via remote addr */
7846 + };
7847 +
7848 + /*
7849 +@@ -103,6 +104,8 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest,
7850 + memset(&fl4, 0, sizeof(fl4));
7851 + fl4.daddr = dest->addr.ip;
7852 + fl4.flowi4_tos = rtos;
7853 ++ fl4.flowi4_flags = (rt_mode & IP_VS_RT_MODE_KNOWN_NH) ?
7854 ++ FLOWI_FLAG_KNOWN_NH : 0;
7855 + rt = ip_route_output_key(net, &fl4);
7856 + if (IS_ERR(rt)) {
7857 + spin_unlock(&dest->dst_lock);
7858 +@@ -127,6 +130,8 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest,
7859 + memset(&fl4, 0, sizeof(fl4));
7860 + fl4.daddr = daddr;
7861 + fl4.flowi4_tos = rtos;
7862 ++ fl4.flowi4_flags = (rt_mode & IP_VS_RT_MODE_KNOWN_NH) ?
7863 ++ FLOWI_FLAG_KNOWN_NH : 0;
7864 + rt = ip_route_output_key(net, &fl4);
7865 + if (IS_ERR(rt)) {
7866 + IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n",
7867 +@@ -1014,7 +1019,8 @@ ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
7868 + if (!(rt = __ip_vs_get_out_rt(skb, cp->dest, cp->daddr.ip,
7869 + RT_TOS(iph->tos),
7870 + IP_VS_RT_MODE_LOCAL |
7871 +- IP_VS_RT_MODE_NON_LOCAL, NULL)))
7872 ++ IP_VS_RT_MODE_NON_LOCAL |
7873 ++ IP_VS_RT_MODE_KNOWN_NH, NULL)))
7874 + goto tx_error_icmp;
7875 + if (rt->rt_flags & RTCF_LOCAL) {
7876 + ip_rt_put(rt);
7877 +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
7878 +index 5270238..9172179 100644
7879 +--- a/net/netlink/af_netlink.c
7880 ++++ b/net/netlink/af_netlink.c
7881 +@@ -169,6 +169,8 @@ static void netlink_sock_destruct(struct sock *sk)
7882 + if (nlk->cb) {
7883 + if (nlk->cb->done)
7884 + nlk->cb->done(nlk->cb);
7885 ++
7886 ++ module_put(nlk->cb->module);
7887 + netlink_destroy_callback(nlk->cb);
7888 + }
7889 +
7890 +@@ -1760,6 +1762,7 @@ static int netlink_dump(struct sock *sk)
7891 + nlk->cb = NULL;
7892 + mutex_unlock(nlk->cb_mutex);
7893 +
7894 ++ module_put(cb->module);
7895 + netlink_consume_callback(cb);
7896 + return 0;
7897 +
7898 +@@ -1769,9 +1772,9 @@ errout_skb:
7899 + return err;
7900 + }
7901 +
7902 +-int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
7903 +- const struct nlmsghdr *nlh,
7904 +- struct netlink_dump_control *control)
7905 ++int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
7906 ++ const struct nlmsghdr *nlh,
7907 ++ struct netlink_dump_control *control)
7908 + {
7909 + struct netlink_callback *cb;
7910 + struct sock *sk;
7911 +@@ -1786,6 +1789,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
7912 + cb->done = control->done;
7913 + cb->nlh = nlh;
7914 + cb->data = control->data;
7915 ++ cb->module = control->module;
7916 + cb->min_dump_alloc = control->min_dump_alloc;
7917 + atomic_inc(&skb->users);
7918 + cb->skb = skb;
7919 +@@ -1796,19 +1800,28 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
7920 + return -ECONNREFUSED;
7921 + }
7922 + nlk = nlk_sk(sk);
7923 +- /* A dump is in progress... */
7924 ++
7925 + mutex_lock(nlk->cb_mutex);
7926 ++ /* A dump is in progress... */
7927 + if (nlk->cb) {
7928 + mutex_unlock(nlk->cb_mutex);
7929 + netlink_destroy_callback(cb);
7930 +- sock_put(sk);
7931 +- return -EBUSY;
7932 ++ ret = -EBUSY;
7933 ++ goto out;
7934 + }
7935 ++ /* add reference of module which cb->dump belongs to */
7936 ++ if (!try_module_get(cb->module)) {
7937 ++ mutex_unlock(nlk->cb_mutex);
7938 ++ netlink_destroy_callback(cb);
7939 ++ ret = -EPROTONOSUPPORT;
7940 ++ goto out;
7941 ++ }
7942 ++
7943 + nlk->cb = cb;
7944 + mutex_unlock(nlk->cb_mutex);
7945 +
7946 + ret = netlink_dump(sk);
7947 +-
7948 ++out:
7949 + sock_put(sk);
7950 +
7951 + if (ret)
7952 +@@ -1819,7 +1832,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
7953 + */
7954 + return -EINTR;
7955 + }
7956 +-EXPORT_SYMBOL(netlink_dump_start);
7957 ++EXPORT_SYMBOL(__netlink_dump_start);
7958 +
7959 + void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
7960 + {
7961 +diff --git a/net/rds/send.c b/net/rds/send.c
7962 +index 96531d4..88eace5 100644
7963 +--- a/net/rds/send.c
7964 ++++ b/net/rds/send.c
7965 +@@ -1122,7 +1122,7 @@ rds_send_pong(struct rds_connection *conn, __be16 dport)
7966 + rds_stats_inc(s_send_pong);
7967 +
7968 + if (!test_bit(RDS_LL_SEND_FULL, &conn->c_flags))
7969 +- rds_send_xmit(conn);
7970 ++ queue_delayed_work(rds_wq, &conn->c_send_w, 0);
7971 +
7972 + rds_message_put(rm);
7973 + return 0;
7974 +diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
7975 +index 2afd2a8..f86d95e 100644
7976 +--- a/net/sunrpc/cache.c
7977 ++++ b/net/sunrpc/cache.c
7978 +@@ -1409,11 +1409,11 @@ static ssize_t read_flush(struct file *file, char __user *buf,
7979 + size_t count, loff_t *ppos,
7980 + struct cache_detail *cd)
7981 + {
7982 +- char tbuf[20];
7983 ++ char tbuf[22];
7984 + unsigned long p = *ppos;
7985 + size_t len;
7986 +
7987 +- sprintf(tbuf, "%lu\n", convert_to_wallclock(cd->flush_time));
7988 ++ snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time));
7989 + len = strlen(tbuf);
7990 + if (p >= len)
7991 + return 0;
7992 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
7993 +index d1988cf..97f8918 100644
7994 +--- a/net/sunrpc/xprtsock.c
7995 ++++ b/net/sunrpc/xprtsock.c
7996 +@@ -2539,6 +2539,7 @@ static struct rpc_xprt_ops xs_tcp_ops = {
7997 + static struct rpc_xprt_ops bc_tcp_ops = {
7998 + .reserve_xprt = xprt_reserve_xprt,
7999 + .release_xprt = xprt_release_xprt,
8000 ++ .alloc_slot = xprt_alloc_slot,
8001 + .rpcbind = xs_local_rpcbind,
8002 + .buf_alloc = bc_malloc,
8003 + .buf_free = bc_free,