Gentoo Archives: gentoo-commits

From: "Stratos Psomadakis (psomas)" <psomas@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r1986 - genpatches-2.6/trunk/3.0
Date: Tue, 04 Oct 2011 07:35:01
Message-Id: 20111004073448.10F082004B@flycatcher.gentoo.org
1 Author: psomas
2 Date: 2011-10-04 07:34:47 +0000 (Tue, 04 Oct 2011)
3 New Revision: 1986
4
5 Added:
6 genpatches-2.6/trunk/3.0/1004_linux-3.0.5.patch
7 Removed:
8 genpatches-2.6/trunk/3.0/1805_vmscan-count-in-small-memcfgs-fix.patch
9 Modified:
10 genpatches-2.6/trunk/3.0/0000_README
11 Log:
12 Linux patch 3.0.5 (includes vmscan count fix)
13
14 Modified: genpatches-2.6/trunk/3.0/0000_README
15 ===================================================================
16 --- genpatches-2.6/trunk/3.0/0000_README 2011-10-02 19:00:24 UTC (rev 1985)
17 +++ genpatches-2.6/trunk/3.0/0000_README 2011-10-04 07:34:47 UTC (rev 1986)
18 @@ -55,6 +55,10 @@
19 From: http://www.kernel.org
20 Desc: Linux 3.0.4
21
22 +Patch: 1004_linux-3.0.5.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 3.0.5
25 +
26 Patch: 1700_i386-bigsmp-early-lapicid-override.patch
27 From: http://bugs.gentoo.org/show_bug.cgi?id=379867
28 Desc: Eliminate false warnings regarding logical APIC ID mismatches for i386/bigsmp
29 @@ -63,10 +67,6 @@
30 From: http://bugs.gentoo.org/show_bug.cgi?id=376325
31 Desc: Fix zcache build error
32
33 -Patch: 1805_vmscan-count-in-small-memcfgs-fix.patch
34 -From: http://bugs.gentoo.org/show_bug.cgi?id=381963
35 -Desc: Fix vmscan count in small memcgs
36 -
37 Patch: 2600_Input-ALPS-Move-protocol-information-to-Documentation.patch
38 From: http://bugs.gentoo.org/show_bug.cgi?id=318567
39 Desc: ALPS Touchpad - Move protocol information to Documentation
40
41 Added: genpatches-2.6/trunk/3.0/1004_linux-3.0.5.patch
42 ===================================================================
43 --- genpatches-2.6/trunk/3.0/1004_linux-3.0.5.patch (rev 0)
44 +++ genpatches-2.6/trunk/3.0/1004_linux-3.0.5.patch 2011-10-04 07:34:47 UTC (rev 1986)
45 @@ -0,0 +1,11930 @@
46 +diff --git a/Makefile b/Makefile
47 +index 7d2192c..eeff5df 100644
48 +--- a/Makefile
49 ++++ b/Makefile
50 +@@ -1,6 +1,6 @@
51 + VERSION = 3
52 + PATCHLEVEL = 0
53 +-SUBLEVEL = 4
54 ++SUBLEVEL = 5
55 + EXTRAVERSION =
56 + NAME = Sneaky Weasel
57 +
58 +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
59 +index 9adc278..91c84cb 100644
60 +--- a/arch/arm/Kconfig
61 ++++ b/arch/arm/Kconfig
62 +@@ -1298,6 +1298,20 @@ source "drivers/pci/Kconfig"
63 +
64 + source "drivers/pcmcia/Kconfig"
65 +
66 ++config ARM_ERRATA_764369
67 ++ bool "ARM errata: Data cache line maintenance operation by MVA may not succeed"
68 ++ depends on CPU_V7 && SMP
69 ++ help
70 ++ This option enables the workaround for erratum 764369
71 ++ affecting Cortex-A9 MPCore with two or more processors (all
72 ++ current revisions). Under certain timing circumstances, a data
73 ++ cache line maintenance operation by MVA targeting an Inner
74 ++ Shareable memory region may fail to proceed up to either the
75 ++ Point of Coherency or to the Point of Unification of the
76 ++ system. This workaround adds a DSB instruction before the
77 ++ relevant cache maintenance functions and sets a specific bit
78 ++ in the diagnostic control register of the SCU.
79 ++
80 + endmenu
81 +
82 + menu "Kernel Features"
83 +diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
84 +index 8c73900..253cc86 100644
85 +--- a/arch/arm/include/asm/futex.h
86 ++++ b/arch/arm/include/asm/futex.h
87 +@@ -25,17 +25,17 @@
88 +
89 + #ifdef CONFIG_SMP
90 +
91 +-#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
92 ++#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
93 + smp_mb(); \
94 + __asm__ __volatile__( \
95 +- "1: ldrex %1, [%2]\n" \
96 ++ "1: ldrex %1, [%3]\n" \
97 + " " insn "\n" \
98 +- "2: strex %1, %0, [%2]\n" \
99 +- " teq %1, #0\n" \
100 ++ "2: strex %2, %0, [%3]\n" \
101 ++ " teq %2, #0\n" \
102 + " bne 1b\n" \
103 + " mov %0, #0\n" \
104 +- __futex_atomic_ex_table("%4") \
105 +- : "=&r" (ret), "=&r" (oldval) \
106 ++ __futex_atomic_ex_table("%5") \
107 ++ : "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
108 + : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
109 + : "cc", "memory")
110 +
111 +@@ -73,14 +73,14 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
112 + #include <linux/preempt.h>
113 + #include <asm/domain.h>
114 +
115 +-#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
116 ++#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
117 + __asm__ __volatile__( \
118 +- "1: " T(ldr) " %1, [%2]\n" \
119 ++ "1: " T(ldr) " %1, [%3]\n" \
120 + " " insn "\n" \
121 +- "2: " T(str) " %0, [%2]\n" \
122 ++ "2: " T(str) " %0, [%3]\n" \
123 + " mov %0, #0\n" \
124 +- __futex_atomic_ex_table("%4") \
125 +- : "=&r" (ret), "=&r" (oldval) \
126 ++ __futex_atomic_ex_table("%5") \
127 ++ : "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
128 + : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
129 + : "cc", "memory")
130 +
131 +@@ -117,7 +117,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
132 + int cmp = (encoded_op >> 24) & 15;
133 + int oparg = (encoded_op << 8) >> 20;
134 + int cmparg = (encoded_op << 20) >> 20;
135 +- int oldval = 0, ret;
136 ++ int oldval = 0, ret, tmp;
137 +
138 + if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
139 + oparg = 1 << oparg;
140 +@@ -129,19 +129,19 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
141 +
142 + switch (op) {
143 + case FUTEX_OP_SET:
144 +- __futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg);
145 ++ __futex_atomic_op("mov %0, %4", ret, oldval, tmp, uaddr, oparg);
146 + break;
147 + case FUTEX_OP_ADD:
148 +- __futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg);
149 ++ __futex_atomic_op("add %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
150 + break;
151 + case FUTEX_OP_OR:
152 +- __futex_atomic_op("orr %0, %1, %3", ret, oldval, uaddr, oparg);
153 ++ __futex_atomic_op("orr %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
154 + break;
155 + case FUTEX_OP_ANDN:
156 +- __futex_atomic_op("and %0, %1, %3", ret, oldval, uaddr, ~oparg);
157 ++ __futex_atomic_op("and %0, %1, %4", ret, oldval, tmp, uaddr, ~oparg);
158 + break;
159 + case FUTEX_OP_XOR:
160 +- __futex_atomic_op("eor %0, %1, %3", ret, oldval, uaddr, oparg);
161 ++ __futex_atomic_op("eor %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
162 + break;
163 + default:
164 + ret = -ENOSYS;
165 +diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h
166 +index 16bd480..bfa706f 100644
167 +--- a/arch/arm/include/asm/hardware/cache-l2x0.h
168 ++++ b/arch/arm/include/asm/hardware/cache-l2x0.h
169 +@@ -64,7 +64,7 @@
170 + #define L2X0_AUX_CTRL_MASK 0xc0000fff
171 + #define L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT 16
172 + #define L2X0_AUX_CTRL_WAY_SIZE_SHIFT 17
173 +-#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x3 << 17)
174 ++#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x7 << 17)
175 + #define L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT 22
176 + #define L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT 26
177 + #define L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT 27
178 +diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c
179 +index a1e757c..cb7dd40 100644
180 +--- a/arch/arm/kernel/smp_scu.c
181 ++++ b/arch/arm/kernel/smp_scu.c
182 +@@ -13,6 +13,7 @@
183 +
184 + #include <asm/smp_scu.h>
185 + #include <asm/cacheflush.h>
186 ++#include <asm/cputype.h>
187 +
188 + #define SCU_CTRL 0x00
189 + #define SCU_CONFIG 0x04
190 +@@ -36,6 +37,15 @@ void __init scu_enable(void __iomem *scu_base)
191 + {
192 + u32 scu_ctrl;
193 +
194 ++#ifdef CONFIG_ARM_ERRATA_764369
195 ++ /* Cortex-A9 only */
196 ++ if ((read_cpuid(CPUID_ID) & 0xff0ffff0) == 0x410fc090) {
197 ++ scu_ctrl = __raw_readl(scu_base + 0x30);
198 ++ if (!(scu_ctrl & 1))
199 ++ __raw_writel(scu_ctrl | 0x1, scu_base + 0x30);
200 ++ }
201 ++#endif
202 ++
203 + scu_ctrl = __raw_readl(scu_base + SCU_CTRL);
204 + /* already enabled? */
205 + if (scu_ctrl & 1)
206 +diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
207 +index a7b41bf..e83cc86 100644
208 +--- a/arch/arm/mach-davinci/board-da850-evm.c
209 ++++ b/arch/arm/mach-davinci/board-da850-evm.c
210 +@@ -115,6 +115,32 @@ static struct spi_board_info da850evm_spi_info[] = {
211 + },
212 + };
213 +
214 ++#ifdef CONFIG_MTD
215 ++static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
216 ++{
217 ++ char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
218 ++ size_t retlen;
219 ++
220 ++ if (!strcmp(mtd->name, "MAC-Address")) {
221 ++ mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
222 ++ if (retlen == ETH_ALEN)
223 ++ pr_info("Read MAC addr from SPI Flash: %pM\n",
224 ++ mac_addr);
225 ++ }
226 ++}
227 ++
228 ++static struct mtd_notifier da850evm_spi_notifier = {
229 ++ .add = da850_evm_m25p80_notify_add,
230 ++};
231 ++
232 ++static void da850_evm_setup_mac_addr(void)
233 ++{
234 ++ register_mtd_user(&da850evm_spi_notifier);
235 ++}
236 ++#else
237 ++static void da850_evm_setup_mac_addr(void) { }
238 ++#endif
239 ++
240 + static struct mtd_partition da850_evm_norflash_partition[] = {
241 + {
242 + .name = "bootloaders + env",
243 +@@ -1237,6 +1263,8 @@ static __init void da850_evm_init(void)
244 + if (ret)
245 + pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
246 + ret);
247 ++
248 ++ da850_evm_setup_mac_addr();
249 + }
250 +
251 + #ifdef CONFIG_SERIAL_8250_CONSOLE
252 +diff --git a/arch/arm/mach-davinci/sleep.S b/arch/arm/mach-davinci/sleep.S
253 +index fb5e72b..5f1e045 100644
254 +--- a/arch/arm/mach-davinci/sleep.S
255 ++++ b/arch/arm/mach-davinci/sleep.S
256 +@@ -217,7 +217,11 @@ ddr2clk_stop_done:
257 + ENDPROC(davinci_ddr_psc_config)
258 +
259 + CACHE_FLUSH:
260 +- .word arm926_flush_kern_cache_all
261 ++#ifdef CONFIG_CPU_V6
262 ++ .word v6_flush_kern_cache_all
263 ++#else
264 ++ .word arm926_flush_kern_cache_all
265 ++#endif
266 +
267 + ENTRY(davinci_cpu_suspend_sz)
268 + .word . - davinci_cpu_suspend
269 +diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
270 +index 5ed51b8..cf7e598 100644
271 +--- a/arch/arm/mach-dove/common.c
272 ++++ b/arch/arm/mach-dove/common.c
273 +@@ -160,7 +160,7 @@ void __init dove_spi0_init(void)
274 +
275 + void __init dove_spi1_init(void)
276 + {
277 +- orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
278 ++ orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk());
279 + }
280 +
281 + /*****************************************************************************
282 +diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
283 +index 2fbbdd5..fcf0ae9 100644
284 +--- a/arch/arm/mach-integrator/integrator_ap.c
285 ++++ b/arch/arm/mach-integrator/integrator_ap.c
286 +@@ -337,15 +337,15 @@ static unsigned long timer_reload;
287 + static void integrator_clocksource_init(u32 khz)
288 + {
289 + void __iomem *base = (void __iomem *)TIMER2_VA_BASE;
290 +- u32 ctrl = TIMER_CTRL_ENABLE;
291 ++ u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
292 +
293 + if (khz >= 1500) {
294 + khz /= 16;
295 +- ctrl = TIMER_CTRL_DIV16;
296 ++ ctrl |= TIMER_CTRL_DIV16;
297 + }
298 +
299 +- writel(ctrl, base + TIMER_CTRL);
300 + writel(0xffff, base + TIMER_LOAD);
301 ++ writel(ctrl, base + TIMER_CTRL);
302 +
303 + clocksource_mmio_init(base + TIMER_VALUE, "timer2",
304 + khz * 1000, 200, 16, clocksource_mmio_readl_down);
305 +diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
306 +index d32f02b..3593119 100644
307 +--- a/arch/arm/mm/cache-v7.S
308 ++++ b/arch/arm/mm/cache-v7.S
309 +@@ -174,6 +174,10 @@ ENTRY(v7_coherent_user_range)
310 + dcache_line_size r2, r3
311 + sub r3, r2, #1
312 + bic r12, r0, r3
313 ++#ifdef CONFIG_ARM_ERRATA_764369
314 ++ ALT_SMP(W(dsb))
315 ++ ALT_UP(W(nop))
316 ++#endif
317 + 1:
318 + USER( mcr p15, 0, r12, c7, c11, 1 ) @ clean D line to the point of unification
319 + add r12, r12, r2
320 +@@ -223,6 +227,10 @@ ENTRY(v7_flush_kern_dcache_area)
321 + add r1, r0, r1
322 + sub r3, r2, #1
323 + bic r0, r0, r3
324 ++#ifdef CONFIG_ARM_ERRATA_764369
325 ++ ALT_SMP(W(dsb))
326 ++ ALT_UP(W(nop))
327 ++#endif
328 + 1:
329 + mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line / unified line
330 + add r0, r0, r2
331 +@@ -247,6 +255,10 @@ v7_dma_inv_range:
332 + sub r3, r2, #1
333 + tst r0, r3
334 + bic r0, r0, r3
335 ++#ifdef CONFIG_ARM_ERRATA_764369
336 ++ ALT_SMP(W(dsb))
337 ++ ALT_UP(W(nop))
338 ++#endif
339 + mcrne p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line
340 +
341 + tst r1, r3
342 +@@ -270,6 +282,10 @@ v7_dma_clean_range:
343 + dcache_line_size r2, r3
344 + sub r3, r2, #1
345 + bic r0, r0, r3
346 ++#ifdef CONFIG_ARM_ERRATA_764369
347 ++ ALT_SMP(W(dsb))
348 ++ ALT_UP(W(nop))
349 ++#endif
350 + 1:
351 + mcr p15, 0, r0, c7, c10, 1 @ clean D / U line
352 + add r0, r0, r2
353 +@@ -288,6 +304,10 @@ ENTRY(v7_dma_flush_range)
354 + dcache_line_size r2, r3
355 + sub r3, r2, #1
356 + bic r0, r0, r3
357 ++#ifdef CONFIG_ARM_ERRATA_764369
358 ++ ALT_SMP(W(dsb))
359 ++ ALT_UP(W(nop))
360 ++#endif
361 + 1:
362 + mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line
363 + add r0, r0, r2
364 +diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
365 +index 82a093c..f96d2c7 100644
366 +--- a/arch/arm/mm/dma-mapping.c
367 ++++ b/arch/arm/mm/dma-mapping.c
368 +@@ -322,6 +322,8 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
369 +
370 + if (addr)
371 + *handle = pfn_to_dma(dev, page_to_pfn(page));
372 ++ else
373 ++ __dma_free_buffer(page, size);
374 +
375 + return addr;
376 + }
377 +diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
378 +index 82620af..ebbce33 100644
379 +--- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
380 ++++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
381 +@@ -66,7 +66,6 @@ typedef u64 iomux_v3_cfg_t;
382 + #define MUX_MODE_MASK ((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
383 + #define MUX_PAD_CTRL_SHIFT 41
384 + #define MUX_PAD_CTRL_MASK ((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
385 +-#define NO_PAD_CTRL ((iomux_v3_cfg_t)1 << (MUX_PAD_CTRL_SHIFT + 16))
386 + #define MUX_SEL_INPUT_SHIFT 58
387 + #define MUX_SEL_INPUT_MASK ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
388 +
389 +@@ -85,6 +84,7 @@ typedef u64 iomux_v3_cfg_t;
390 + * Use to set PAD control
391 + */
392 +
393 ++#define NO_PAD_CTRL (1 << 16)
394 + #define PAD_CTL_DVS (1 << 13)
395 + #define PAD_CTL_HYS (1 << 8)
396 +
397 +diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
398 +index b3fd081..cdd765b 100644
399 +--- a/arch/powerpc/sysdev/fsl_rio.c
400 ++++ b/arch/powerpc/sysdev/fsl_rio.c
401 +@@ -54,6 +54,7 @@
402 + #define ODSR_CLEAR 0x1c00
403 + #define LTLEECSR_ENABLE_ALL 0xFFC000FC
404 + #define ESCSR_CLEAR 0x07120204
405 ++#define IECSR_CLEAR 0x80000000
406 +
407 + #define RIO_PORT1_EDCSR 0x0640
408 + #define RIO_PORT2_EDCSR 0x0680
409 +@@ -1089,11 +1090,11 @@ static void port_error_handler(struct rio_mport *port, int offset)
410 +
411 + if (offset == 0) {
412 + out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0);
413 +- out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), 0);
414 ++ out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), IECSR_CLEAR);
415 + out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR);
416 + } else {
417 + out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0);
418 +- out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), 0);
419 ++ out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), IECSR_CLEAR);
420 + out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR);
421 + }
422 + }
423 +diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
424 +index 253986b..2e79419 100644
425 +--- a/arch/sparc/Kconfig
426 ++++ b/arch/sparc/Kconfig
427 +@@ -53,6 +53,7 @@ config SPARC64
428 + select HAVE_PERF_EVENTS
429 + select PERF_USE_VMALLOC
430 + select IRQ_PREFLOW_FASTEOI
431 ++ select HAVE_C_RECORDMCOUNT
432 +
433 + config ARCH_DEFCONFIG
434 + string
435 +diff --git a/arch/sparc/include/asm/sigcontext.h b/arch/sparc/include/asm/sigcontext.h
436 +index a1607d1..69914d7 100644
437 +--- a/arch/sparc/include/asm/sigcontext.h
438 ++++ b/arch/sparc/include/asm/sigcontext.h
439 +@@ -45,6 +45,19 @@ typedef struct {
440 + int si_mask;
441 + } __siginfo32_t;
442 +
443 ++#define __SIGC_MAXWIN 7
444 ++
445 ++typedef struct {
446 ++ unsigned long locals[8];
447 ++ unsigned long ins[8];
448 ++} __siginfo_reg_window;
449 ++
450 ++typedef struct {
451 ++ int wsaved;
452 ++ __siginfo_reg_window reg_window[__SIGC_MAXWIN];
453 ++ unsigned long rwbuf_stkptrs[__SIGC_MAXWIN];
454 ++} __siginfo_rwin_t;
455 ++
456 + #ifdef CONFIG_SPARC64
457 + typedef struct {
458 + unsigned int si_float_regs [64];
459 +@@ -73,6 +86,7 @@ struct sigcontext {
460 + unsigned long ss_size;
461 + } sigc_stack;
462 + unsigned long sigc_mask;
463 ++ __siginfo_rwin_t * sigc_rwin_save;
464 + };
465 +
466 + #else
467 +diff --git a/arch/sparc/include/asm/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h
468 +index 5f5b8bf..bcc98fc 100644
469 +--- a/arch/sparc/include/asm/spinlock_32.h
470 ++++ b/arch/sparc/include/asm/spinlock_32.h
471 +@@ -131,6 +131,15 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
472 + *(volatile __u32 *)&lp->lock = ~0U;
473 + }
474 +
475 ++static void inline arch_write_unlock(arch_rwlock_t *lock)
476 ++{
477 ++ __asm__ __volatile__(
478 ++" st %%g0, [%0]"
479 ++ : /* no outputs */
480 ++ : "r" (lock)
481 ++ : "memory");
482 ++}
483 ++
484 + static inline int arch_write_trylock(arch_rwlock_t *rw)
485 + {
486 + unsigned int val;
487 +@@ -175,8 +184,6 @@ static inline int __arch_read_trylock(arch_rwlock_t *rw)
488 + res; \
489 + })
490 +
491 +-#define arch_write_unlock(rw) do { (rw)->lock = 0; } while(0)
492 +-
493 + #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
494 + #define arch_read_lock_flags(rw, flags) arch_read_lock(rw)
495 + #define arch_write_lock_flags(rw, flags) arch_write_lock(rw)
496 +diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
497 +index 073936a..9689176 100644
498 +--- a/arch/sparc/include/asm/spinlock_64.h
499 ++++ b/arch/sparc/include/asm/spinlock_64.h
500 +@@ -210,14 +210,8 @@ static int inline arch_write_trylock(arch_rwlock_t *lock)
501 + return result;
502 + }
503 +
504 +-#define arch_read_lock(p) arch_read_lock(p)
505 + #define arch_read_lock_flags(p, f) arch_read_lock(p)
506 +-#define arch_read_trylock(p) arch_read_trylock(p)
507 +-#define arch_read_unlock(p) arch_read_unlock(p)
508 +-#define arch_write_lock(p) arch_write_lock(p)
509 + #define arch_write_lock_flags(p, f) arch_write_lock(p)
510 +-#define arch_write_unlock(p) arch_write_unlock(p)
511 +-#define arch_write_trylock(p) arch_write_trylock(p)
512 +
513 + #define arch_read_can_lock(rw) (!((rw)->lock & 0x80000000UL))
514 + #define arch_write_can_lock(rw) (!(rw)->lock)
515 +diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
516 +index b90b4a1..cb85458 100644
517 +--- a/arch/sparc/kernel/Makefile
518 ++++ b/arch/sparc/kernel/Makefile
519 +@@ -32,6 +32,7 @@ obj-$(CONFIG_SPARC32) += sun4m_irq.o sun4c_irq.o sun4d_irq.o
520 +
521 + obj-y += process_$(BITS).o
522 + obj-y += signal_$(BITS).o
523 ++obj-y += sigutil_$(BITS).o
524 + obj-$(CONFIG_SPARC32) += ioport.o
525 + obj-y += setup_$(BITS).o
526 + obj-y += idprom.o
527 +diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
528 +index 100b9c2..4285112 100644
529 +--- a/arch/sparc/kernel/irq.h
530 ++++ b/arch/sparc/kernel/irq.h
531 +@@ -88,7 +88,7 @@ BTFIXUPDEF_CALL(void, set_irq_udt, int)
532 + #define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
533 +
534 + /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
535 +-#define SUN4D_IPI_IRQ 14
536 ++#define SUN4D_IPI_IRQ 13
537 +
538 + extern void sun4d_ipi_interrupt(void);
539 +
540 +diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
541 +index 948601a..6418ba6 100644
542 +--- a/arch/sparc/kernel/pcic.c
543 ++++ b/arch/sparc/kernel/pcic.c
544 +@@ -352,8 +352,8 @@ int __init pcic_probe(void)
545 + strcpy(pbm->prom_name, namebuf);
546 +
547 + {
548 +- extern volatile int t_nmi[1];
549 +- extern int pcic_nmi_trap_patch[1];
550 ++ extern volatile int t_nmi[4];
551 ++ extern int pcic_nmi_trap_patch[4];
552 +
553 + t_nmi[0] = pcic_nmi_trap_patch[0];
554 + t_nmi[1] = pcic_nmi_trap_patch[1];
555 +diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
556 +index 3e9daea..3c5bb78 100644
557 +--- a/arch/sparc/kernel/setup_64.c
558 ++++ b/arch/sparc/kernel/setup_64.c
559 +@@ -440,8 +440,14 @@ static void __init init_sparc64_elf_hwcap(void)
560 + cap |= AV_SPARC_VIS;
561 + if (tlb_type == cheetah || tlb_type == cheetah_plus)
562 + cap |= AV_SPARC_VIS | AV_SPARC_VIS2;
563 +- if (tlb_type == cheetah_plus)
564 +- cap |= AV_SPARC_POPC;
565 ++ if (tlb_type == cheetah_plus) {
566 ++ unsigned long impl, ver;
567 ++
568 ++ __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
569 ++ impl = ((ver >> 32) & 0xffff);
570 ++ if (impl == PANTHER_IMPL)
571 ++ cap |= AV_SPARC_POPC;
572 ++ }
573 + if (tlb_type == hypervisor) {
574 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1)
575 + cap |= AV_SPARC_ASI_BLK_INIT;
576 +diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
577 +index 75fad42..5d92488 100644
578 +--- a/arch/sparc/kernel/signal32.c
579 ++++ b/arch/sparc/kernel/signal32.c
580 +@@ -29,6 +29,8 @@
581 + #include <asm/visasm.h>
582 + #include <asm/compat_signal.h>
583 +
584 ++#include "sigutil.h"
585 ++
586 + #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
587 +
588 + /* This magic should be in g_upper[0] for all upper parts
589 +@@ -44,14 +46,14 @@ typedef struct {
590 + struct signal_frame32 {
591 + struct sparc_stackf32 ss;
592 + __siginfo32_t info;
593 +- /* __siginfo_fpu32_t * */ u32 fpu_save;
594 ++ /* __siginfo_fpu_t * */ u32 fpu_save;
595 + unsigned int insns[2];
596 + unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
597 + unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
598 + /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
599 + siginfo_extra_v8plus_t v8plus;
600 +- __siginfo_fpu_t fpu_state;
601 +-};
602 ++ /* __siginfo_rwin_t * */u32 rwin_save;
603 ++} __attribute__((aligned(8)));
604 +
605 + typedef struct compat_siginfo{
606 + int si_signo;
607 +@@ -110,18 +112,14 @@ struct rt_signal_frame32 {
608 + compat_siginfo_t info;
609 + struct pt_regs32 regs;
610 + compat_sigset_t mask;
611 +- /* __siginfo_fpu32_t * */ u32 fpu_save;
612 ++ /* __siginfo_fpu_t * */ u32 fpu_save;
613 + unsigned int insns[2];
614 + stack_t32 stack;
615 + unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
616 + /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
617 + siginfo_extra_v8plus_t v8plus;
618 +- __siginfo_fpu_t fpu_state;
619 +-};
620 +-
621 +-/* Align macros */
622 +-#define SF_ALIGNEDSZ (((sizeof(struct signal_frame32) + 15) & (~15)))
623 +-#define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 15) & (~15)))
624 ++ /* __siginfo_rwin_t * */u32 rwin_save;
625 ++} __attribute__((aligned(8)));
626 +
627 + int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
628 + {
629 +@@ -192,30 +190,13 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
630 + return 0;
631 + }
632 +
633 +-static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
634 +-{
635 +- unsigned long *fpregs = current_thread_info()->fpregs;
636 +- unsigned long fprs;
637 +- int err;
638 +-
639 +- err = __get_user(fprs, &fpu->si_fprs);
640 +- fprs_write(0);
641 +- regs->tstate &= ~TSTATE_PEF;
642 +- if (fprs & FPRS_DL)
643 +- err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32));
644 +- if (fprs & FPRS_DU)
645 +- err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32));
646 +- err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
647 +- err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
648 +- current_thread_info()->fpsaved[0] |= fprs;
649 +- return err;
650 +-}
651 +-
652 + void do_sigreturn32(struct pt_regs *regs)
653 + {
654 + struct signal_frame32 __user *sf;
655 ++ compat_uptr_t fpu_save;
656 ++ compat_uptr_t rwin_save;
657 + unsigned int psr;
658 +- unsigned pc, npc, fpu_save;
659 ++ unsigned pc, npc;
660 + sigset_t set;
661 + unsigned seta[_COMPAT_NSIG_WORDS];
662 + int err, i;
663 +@@ -273,8 +254,13 @@ void do_sigreturn32(struct pt_regs *regs)
664 + pt_regs_clear_syscall(regs);
665 +
666 + err |= __get_user(fpu_save, &sf->fpu_save);
667 +- if (fpu_save)
668 +- err |= restore_fpu_state32(regs, &sf->fpu_state);
669 ++ if (!err && fpu_save)
670 ++ err |= restore_fpu_state(regs, compat_ptr(fpu_save));
671 ++ err |= __get_user(rwin_save, &sf->rwin_save);
672 ++ if (!err && rwin_save) {
673 ++ if (restore_rwin_state(compat_ptr(rwin_save)))
674 ++ goto segv;
675 ++ }
676 + err |= __get_user(seta[0], &sf->info.si_mask);
677 + err |= copy_from_user(seta+1, &sf->extramask,
678 + (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
679 +@@ -300,7 +286,9 @@ segv:
680 + asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
681 + {
682 + struct rt_signal_frame32 __user *sf;
683 +- unsigned int psr, pc, npc, fpu_save, u_ss_sp;
684 ++ unsigned int psr, pc, npc, u_ss_sp;
685 ++ compat_uptr_t fpu_save;
686 ++ compat_uptr_t rwin_save;
687 + mm_segment_t old_fs;
688 + sigset_t set;
689 + compat_sigset_t seta;
690 +@@ -359,8 +347,8 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
691 + pt_regs_clear_syscall(regs);
692 +
693 + err |= __get_user(fpu_save, &sf->fpu_save);
694 +- if (fpu_save)
695 +- err |= restore_fpu_state32(regs, &sf->fpu_state);
696 ++ if (!err && fpu_save)
697 ++ err |= restore_fpu_state(regs, compat_ptr(fpu_save));
698 + err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t));
699 + err |= __get_user(u_ss_sp, &sf->stack.ss_sp);
700 + st.ss_sp = compat_ptr(u_ss_sp);
701 +@@ -376,6 +364,12 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
702 + do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf);
703 + set_fs(old_fs);
704 +
705 ++ err |= __get_user(rwin_save, &sf->rwin_save);
706 ++ if (!err && rwin_save) {
707 ++ if (restore_rwin_state(compat_ptr(rwin_save)))
708 ++ goto segv;
709 ++ }
710 ++
711 + switch (_NSIG_WORDS) {
712 + case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
713 + case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
714 +@@ -433,26 +427,6 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns
715 + return (void __user *) sp;
716 + }
717 +
718 +-static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
719 +-{
720 +- unsigned long *fpregs = current_thread_info()->fpregs;
721 +- unsigned long fprs;
722 +- int err = 0;
723 +-
724 +- fprs = current_thread_info()->fpsaved[0];
725 +- if (fprs & FPRS_DL)
726 +- err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
727 +- (sizeof(unsigned int) * 32));
728 +- if (fprs & FPRS_DU)
729 +- err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
730 +- (sizeof(unsigned int) * 32));
731 +- err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
732 +- err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
733 +- err |= __put_user(fprs, &fpu->si_fprs);
734 +-
735 +- return err;
736 +-}
737 +-
738 + /* The I-cache flush instruction only works in the primary ASI, which
739 + * right now is the nucleus, aka. kernel space.
740 + *
741 +@@ -515,18 +489,23 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
742 + int signo, sigset_t *oldset)
743 + {
744 + struct signal_frame32 __user *sf;
745 ++ int i, err, wsaved;
746 ++ void __user *tail;
747 + int sigframe_size;
748 + u32 psr;
749 +- int i, err;
750 + unsigned int seta[_COMPAT_NSIG_WORDS];
751 +
752 + /* 1. Make sure everything is clean */
753 + synchronize_user_stack();
754 + save_and_clear_fpu();
755 +
756 +- sigframe_size = SF_ALIGNEDSZ;
757 +- if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
758 +- sigframe_size -= sizeof(__siginfo_fpu_t);
759 ++ wsaved = get_thread_wsaved();
760 ++
761 ++ sigframe_size = sizeof(*sf);
762 ++ if (current_thread_info()->fpsaved[0] & FPRS_FEF)
763 ++ sigframe_size += sizeof(__siginfo_fpu_t);
764 ++ if (wsaved)
765 ++ sigframe_size += sizeof(__siginfo_rwin_t);
766 +
767 + sf = (struct signal_frame32 __user *)
768 + get_sigframe(&ka->sa, regs, sigframe_size);
769 +@@ -534,8 +513,7 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
770 + if (invalid_frame_pointer(sf, sigframe_size))
771 + goto sigill;
772 +
773 +- if (get_thread_wsaved() != 0)
774 +- goto sigill;
775 ++ tail = (sf + 1);
776 +
777 + /* 2. Save the current process state */
778 + if (test_thread_flag(TIF_32BIT)) {
779 +@@ -560,11 +538,22 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
780 + &sf->v8plus.asi);
781 +
782 + if (psr & PSR_EF) {
783 +- err |= save_fpu_state32(regs, &sf->fpu_state);
784 +- err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
785 ++ __siginfo_fpu_t __user *fp = tail;
786 ++ tail += sizeof(*fp);
787 ++ err |= save_fpu_state(regs, fp);
788 ++ err |= __put_user((u64)fp, &sf->fpu_save);
789 + } else {
790 + err |= __put_user(0, &sf->fpu_save);
791 + }
792 ++ if (wsaved) {
793 ++ __siginfo_rwin_t __user *rwp = tail;
794 ++ tail += sizeof(*rwp);
795 ++ err |= save_rwin_state(wsaved, rwp);
796 ++ err |= __put_user((u64)rwp, &sf->rwin_save);
797 ++ set_thread_wsaved(0);
798 ++ } else {
799 ++ err |= __put_user(0, &sf->rwin_save);
800 ++ }
801 +
802 + switch (_NSIG_WORDS) {
803 + case 4: seta[7] = (oldset->sig[3] >> 32);
804 +@@ -580,10 +569,21 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
805 + err |= __copy_to_user(sf->extramask, seta + 1,
806 + (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
807 +
808 +- err |= copy_in_user((u32 __user *)sf,
809 +- (u32 __user *)(regs->u_regs[UREG_FP]),
810 +- sizeof(struct reg_window32));
811 +-
812 ++ if (!wsaved) {
813 ++ err |= copy_in_user((u32 __user *)sf,
814 ++ (u32 __user *)(regs->u_regs[UREG_FP]),
815 ++ sizeof(struct reg_window32));
816 ++ } else {
817 ++ struct reg_window *rp;
818 ++
819 ++ rp = &current_thread_info()->reg_window[wsaved - 1];
820 ++ for (i = 0; i < 8; i++)
821 ++ err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
822 ++ for (i = 0; i < 6; i++)
823 ++ err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
824 ++ err |= __put_user(rp->ins[6], &sf->ss.fp);
825 ++ err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
826 ++ }
827 + if (err)
828 + goto sigsegv;
829 +
830 +@@ -613,7 +613,6 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
831 + err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/
832 + if (err)
833 + goto sigsegv;
834 +-
835 + flush_signal_insns(address);
836 + }
837 + return 0;
838 +@@ -632,18 +631,23 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
839 + siginfo_t *info)
840 + {
841 + struct rt_signal_frame32 __user *sf;
842 ++ int i, err, wsaved;
843 ++ void __user *tail;
844 + int sigframe_size;
845 + u32 psr;
846 +- int i, err;
847 + compat_sigset_t seta;
848 +
849 + /* 1. Make sure everything is clean */
850 + synchronize_user_stack();
851 + save_and_clear_fpu();
852 +
853 +- sigframe_size = RT_ALIGNEDSZ;
854 +- if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
855 +- sigframe_size -= sizeof(__siginfo_fpu_t);
856 ++ wsaved = get_thread_wsaved();
857 ++
858 ++ sigframe_size = sizeof(*sf);
859 ++ if (current_thread_info()->fpsaved[0] & FPRS_FEF)
860 ++ sigframe_size += sizeof(__siginfo_fpu_t);
861 ++ if (wsaved)
862 ++ sigframe_size += sizeof(__siginfo_rwin_t);
863 +
864 + sf = (struct rt_signal_frame32 __user *)
865 + get_sigframe(&ka->sa, regs, sigframe_size);
866 +@@ -651,8 +655,7 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
867 + if (invalid_frame_pointer(sf, sigframe_size))
868 + goto sigill;
869 +
870 +- if (get_thread_wsaved() != 0)
871 +- goto sigill;
872 ++ tail = (sf + 1);
873 +
874 + /* 2. Save the current process state */
875 + if (test_thread_flag(TIF_32BIT)) {
876 +@@ -677,11 +680,22 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
877 + &sf->v8plus.asi);
878 +
879 + if (psr & PSR_EF) {
880 +- err |= save_fpu_state32(regs, &sf->fpu_state);
881 +- err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
882 ++ __siginfo_fpu_t __user *fp = tail;
883 ++ tail += sizeof(*fp);
884 ++ err |= save_fpu_state(regs, fp);
885 ++ err |= __put_user((u64)fp, &sf->fpu_save);
886 + } else {
887 + err |= __put_user(0, &sf->fpu_save);
888 + }
889 ++ if (wsaved) {
890 ++ __siginfo_rwin_t __user *rwp = tail;
891 ++ tail += sizeof(*rwp);
892 ++ err |= save_rwin_state(wsaved, rwp);
893 ++ err |= __put_user((u64)rwp, &sf->rwin_save);
894 ++ set_thread_wsaved(0);
895 ++ } else {
896 ++ err |= __put_user(0, &sf->rwin_save);
897 ++ }
898 +
899 + /* Update the siginfo structure. */
900 + err |= copy_siginfo_to_user32(&sf->info, info);
901 +@@ -703,9 +717,21 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
902 + }
903 + err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
904 +
905 +- err |= copy_in_user((u32 __user *)sf,
906 +- (u32 __user *)(regs->u_regs[UREG_FP]),
907 +- sizeof(struct reg_window32));
908 ++ if (!wsaved) {
909 ++ err |= copy_in_user((u32 __user *)sf,
910 ++ (u32 __user *)(regs->u_regs[UREG_FP]),
911 ++ sizeof(struct reg_window32));
912 ++ } else {
913 ++ struct reg_window *rp;
914 ++
915 ++ rp = &current_thread_info()->reg_window[wsaved - 1];
916 ++ for (i = 0; i < 8; i++)
917 ++ err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
918 ++ for (i = 0; i < 6; i++)
919 ++ err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
920 ++ err |= __put_user(rp->ins[6], &sf->ss.fp);
921 ++ err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
922 ++ }
923 + if (err)
924 + goto sigsegv;
925 +
926 +diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
927 +index 5e5c5fd..04ede8f 100644
928 +--- a/arch/sparc/kernel/signal_32.c
929 ++++ b/arch/sparc/kernel/signal_32.c
930 +@@ -26,6 +26,8 @@
931 + #include <asm/pgtable.h>
932 + #include <asm/cacheflush.h> /* flush_sig_insns */
933 +
934 ++#include "sigutil.h"
935 ++
936 + #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
937 +
938 + extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
939 +@@ -39,8 +41,8 @@ struct signal_frame {
940 + unsigned long insns[2] __attribute__ ((aligned (8)));
941 + unsigned int extramask[_NSIG_WORDS - 1];
942 + unsigned int extra_size; /* Should be 0 */
943 +- __siginfo_fpu_t fpu_state;
944 +-};
945 ++ __siginfo_rwin_t __user *rwin_save;
946 ++} __attribute__((aligned(8)));
947 +
948 + struct rt_signal_frame {
949 + struct sparc_stackf ss;
950 +@@ -51,8 +53,8 @@ struct rt_signal_frame {
951 + unsigned int insns[2];
952 + stack_t stack;
953 + unsigned int extra_size; /* Should be 0 */
954 +- __siginfo_fpu_t fpu_state;
955 +-};
956 ++ __siginfo_rwin_t __user *rwin_save;
957 ++} __attribute__((aligned(8)));
958 +
959 + /* Align macros */
960 + #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7)))
961 +@@ -79,43 +81,13 @@ asmlinkage int sys_sigsuspend(old_sigset_t set)
962 + return _sigpause_common(set);
963 + }
964 +
965 +-static inline int
966 +-restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
967 +-{
968 +- int err;
969 +-#ifdef CONFIG_SMP
970 +- if (test_tsk_thread_flag(current, TIF_USEDFPU))
971 +- regs->psr &= ~PSR_EF;
972 +-#else
973 +- if (current == last_task_used_math) {
974 +- last_task_used_math = NULL;
975 +- regs->psr &= ~PSR_EF;
976 +- }
977 +-#endif
978 +- set_used_math();
979 +- clear_tsk_thread_flag(current, TIF_USEDFPU);
980 +-
981 +- if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
982 +- return -EFAULT;
983 +-
984 +- err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
985 +- (sizeof(unsigned long) * 32));
986 +- err |= __get_user(current->thread.fsr, &fpu->si_fsr);
987 +- err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
988 +- if (current->thread.fpqdepth != 0)
989 +- err |= __copy_from_user(&current->thread.fpqueue[0],
990 +- &fpu->si_fpqueue[0],
991 +- ((sizeof(unsigned long) +
992 +- (sizeof(unsigned long *)))*16));
993 +- return err;
994 +-}
995 +-
996 + asmlinkage void do_sigreturn(struct pt_regs *regs)
997 + {
998 + struct signal_frame __user *sf;
999 + unsigned long up_psr, pc, npc;
1000 + sigset_t set;
1001 + __siginfo_fpu_t __user *fpu_save;
1002 ++ __siginfo_rwin_t __user *rwin_save;
1003 + int err;
1004 +
1005 + /* Always make any pending restarted system calls return -EINTR */
1006 +@@ -150,9 +122,11 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
1007 + pt_regs_clear_syscall(regs);
1008 +
1009 + err |= __get_user(fpu_save, &sf->fpu_save);
1010 +-
1011 + if (fpu_save)
1012 + err |= restore_fpu_state(regs, fpu_save);
1013 ++ err |= __get_user(rwin_save, &sf->rwin_save);
1014 ++ if (rwin_save)
1015 ++ err |= restore_rwin_state(rwin_save);
1016 +
1017 + /* This is pretty much atomic, no amount locking would prevent
1018 + * the races which exist anyways.
1019 +@@ -180,6 +154,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
1020 + struct rt_signal_frame __user *sf;
1021 + unsigned int psr, pc, npc;
1022 + __siginfo_fpu_t __user *fpu_save;
1023 ++ __siginfo_rwin_t __user *rwin_save;
1024 + mm_segment_t old_fs;
1025 + sigset_t set;
1026 + stack_t st;
1027 +@@ -207,8 +182,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
1028 + pt_regs_clear_syscall(regs);
1029 +
1030 + err |= __get_user(fpu_save, &sf->fpu_save);
1031 +-
1032 +- if (fpu_save)
1033 ++ if (!err && fpu_save)
1034 + err |= restore_fpu_state(regs, fpu_save);
1035 + err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
1036 +
1037 +@@ -228,6 +202,12 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
1038 + do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
1039 + set_fs(old_fs);
1040 +
1041 ++ err |= __get_user(rwin_save, &sf->rwin_save);
1042 ++ if (!err && rwin_save) {
1043 ++ if (restore_rwin_state(rwin_save))
1044 ++ goto segv;
1045 ++ }
1046 ++
1047 + sigdelsetmask(&set, ~_BLOCKABLE);
1048 + spin_lock_irq(&current->sighand->siglock);
1049 + current->blocked = set;
1050 +@@ -280,53 +260,23 @@ static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *re
1051 + return (void __user *) sp;
1052 + }
1053 +
1054 +-static inline int
1055 +-save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1056 +-{
1057 +- int err = 0;
1058 +-#ifdef CONFIG_SMP
1059 +- if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
1060 +- put_psr(get_psr() | PSR_EF);
1061 +- fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1062 +- &current->thread.fpqueue[0], &current->thread.fpqdepth);
1063 +- regs->psr &= ~(PSR_EF);
1064 +- clear_tsk_thread_flag(current, TIF_USEDFPU);
1065 +- }
1066 +-#else
1067 +- if (current == last_task_used_math) {
1068 +- put_psr(get_psr() | PSR_EF);
1069 +- fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1070 +- &current->thread.fpqueue[0], &current->thread.fpqdepth);
1071 +- last_task_used_math = NULL;
1072 +- regs->psr &= ~(PSR_EF);
1073 +- }
1074 +-#endif
1075 +- err |= __copy_to_user(&fpu->si_float_regs[0],
1076 +- &current->thread.float_regs[0],
1077 +- (sizeof(unsigned long) * 32));
1078 +- err |= __put_user(current->thread.fsr, &fpu->si_fsr);
1079 +- err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1080 +- if (current->thread.fpqdepth != 0)
1081 +- err |= __copy_to_user(&fpu->si_fpqueue[0],
1082 +- &current->thread.fpqueue[0],
1083 +- ((sizeof(unsigned long) +
1084 +- (sizeof(unsigned long *)))*16));
1085 +- clear_used_math();
1086 +- return err;
1087 +-}
1088 +-
1089 + static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1090 + int signo, sigset_t *oldset)
1091 + {
1092 + struct signal_frame __user *sf;
1093 +- int sigframe_size, err;
1094 ++ int sigframe_size, err, wsaved;
1095 ++ void __user *tail;
1096 +
1097 + /* 1. Make sure everything is clean */
1098 + synchronize_user_stack();
1099 +
1100 +- sigframe_size = SF_ALIGNEDSZ;
1101 +- if (!used_math())
1102 +- sigframe_size -= sizeof(__siginfo_fpu_t);
1103 ++ wsaved = current_thread_info()->w_saved;
1104 ++
1105 ++ sigframe_size = sizeof(*sf);
1106 ++ if (used_math())
1107 ++ sigframe_size += sizeof(__siginfo_fpu_t);
1108 ++ if (wsaved)
1109 ++ sigframe_size += sizeof(__siginfo_rwin_t);
1110 +
1111 + sf = (struct signal_frame __user *)
1112 + get_sigframe(&ka->sa, regs, sigframe_size);
1113 +@@ -334,8 +284,7 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1114 + if (invalid_frame_pointer(sf, sigframe_size))
1115 + goto sigill_and_return;
1116 +
1117 +- if (current_thread_info()->w_saved != 0)
1118 +- goto sigill_and_return;
1119 ++ tail = sf + 1;
1120 +
1121 + /* 2. Save the current process state */
1122 + err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
1123 +@@ -343,17 +292,34 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1124 + err |= __put_user(0, &sf->extra_size);
1125 +
1126 + if (used_math()) {
1127 +- err |= save_fpu_state(regs, &sf->fpu_state);
1128 +- err |= __put_user(&sf->fpu_state, &sf->fpu_save);
1129 ++ __siginfo_fpu_t __user *fp = tail;
1130 ++ tail += sizeof(*fp);
1131 ++ err |= save_fpu_state(regs, fp);
1132 ++ err |= __put_user(fp, &sf->fpu_save);
1133 + } else {
1134 + err |= __put_user(0, &sf->fpu_save);
1135 + }
1136 ++ if (wsaved) {
1137 ++ __siginfo_rwin_t __user *rwp = tail;
1138 ++ tail += sizeof(*rwp);
1139 ++ err |= save_rwin_state(wsaved, rwp);
1140 ++ err |= __put_user(rwp, &sf->rwin_save);
1141 ++ } else {
1142 ++ err |= __put_user(0, &sf->rwin_save);
1143 ++ }
1144 +
1145 + err |= __put_user(oldset->sig[0], &sf->info.si_mask);
1146 + err |= __copy_to_user(sf->extramask, &oldset->sig[1],
1147 + (_NSIG_WORDS - 1) * sizeof(unsigned int));
1148 +- err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1149 +- sizeof(struct reg_window32));
1150 ++ if (!wsaved) {
1151 ++ err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1152 ++ sizeof(struct reg_window32));
1153 ++ } else {
1154 ++ struct reg_window32 *rp;
1155 ++
1156 ++ rp = &current_thread_info()->reg_window[wsaved - 1];
1157 ++ err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
1158 ++ }
1159 + if (err)
1160 + goto sigsegv;
1161 +
1162 +@@ -399,21 +365,24 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1163 + int signo, sigset_t *oldset, siginfo_t *info)
1164 + {
1165 + struct rt_signal_frame __user *sf;
1166 +- int sigframe_size;
1167 ++ int sigframe_size, wsaved;
1168 ++ void __user *tail;
1169 + unsigned int psr;
1170 + int err;
1171 +
1172 + synchronize_user_stack();
1173 +- sigframe_size = RT_ALIGNEDSZ;
1174 +- if (!used_math())
1175 +- sigframe_size -= sizeof(__siginfo_fpu_t);
1176 ++ wsaved = current_thread_info()->w_saved;
1177 ++ sigframe_size = sizeof(*sf);
1178 ++ if (used_math())
1179 ++ sigframe_size += sizeof(__siginfo_fpu_t);
1180 ++ if (wsaved)
1181 ++ sigframe_size += sizeof(__siginfo_rwin_t);
1182 + sf = (struct rt_signal_frame __user *)
1183 + get_sigframe(&ka->sa, regs, sigframe_size);
1184 + if (invalid_frame_pointer(sf, sigframe_size))
1185 + goto sigill;
1186 +- if (current_thread_info()->w_saved != 0)
1187 +- goto sigill;
1188 +
1189 ++ tail = sf + 1;
1190 + err = __put_user(regs->pc, &sf->regs.pc);
1191 + err |= __put_user(regs->npc, &sf->regs.npc);
1192 + err |= __put_user(regs->y, &sf->regs.y);
1193 +@@ -425,11 +394,21 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1194 + err |= __put_user(0, &sf->extra_size);
1195 +
1196 + if (psr & PSR_EF) {
1197 +- err |= save_fpu_state(regs, &sf->fpu_state);
1198 +- err |= __put_user(&sf->fpu_state, &sf->fpu_save);
1199 ++ __siginfo_fpu_t *fp = tail;
1200 ++ tail += sizeof(*fp);
1201 ++ err |= save_fpu_state(regs, fp);
1202 ++ err |= __put_user(fp, &sf->fpu_save);
1203 + } else {
1204 + err |= __put_user(0, &sf->fpu_save);
1205 + }
1206 ++ if (wsaved) {
1207 ++ __siginfo_rwin_t *rwp = tail;
1208 ++ tail += sizeof(*rwp);
1209 ++ err |= save_rwin_state(wsaved, rwp);
1210 ++ err |= __put_user(rwp, &sf->rwin_save);
1211 ++ } else {
1212 ++ err |= __put_user(0, &sf->rwin_save);
1213 ++ }
1214 + err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
1215 +
1216 + /* Setup sigaltstack */
1217 +@@ -437,8 +416,15 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1218 + err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
1219 + err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
1220 +
1221 +- err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1222 +- sizeof(struct reg_window32));
1223 ++ if (!wsaved) {
1224 ++ err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1225 ++ sizeof(struct reg_window32));
1226 ++ } else {
1227 ++ struct reg_window32 *rp;
1228 ++
1229 ++ rp = &current_thread_info()->reg_window[wsaved - 1];
1230 ++ err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
1231 ++ }
1232 +
1233 + err |= copy_siginfo_to_user(&sf->info, info);
1234 +
1235 +diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
1236 +index 006fe45..47509df 100644
1237 +--- a/arch/sparc/kernel/signal_64.c
1238 ++++ b/arch/sparc/kernel/signal_64.c
1239 +@@ -34,6 +34,7 @@
1240 +
1241 + #include "entry.h"
1242 + #include "systbls.h"
1243 ++#include "sigutil.h"
1244 +
1245 + #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
1246 +
1247 +@@ -236,7 +237,7 @@ struct rt_signal_frame {
1248 + __siginfo_fpu_t __user *fpu_save;
1249 + stack_t stack;
1250 + sigset_t mask;
1251 +- __siginfo_fpu_t fpu_state;
1252 ++ __siginfo_rwin_t *rwin_save;
1253 + };
1254 +
1255 + static long _sigpause_common(old_sigset_t set)
1256 +@@ -266,33 +267,12 @@ asmlinkage long sys_sigsuspend(old_sigset_t set)
1257 + return _sigpause_common(set);
1258 + }
1259 +
1260 +-static inline int
1261 +-restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1262 +-{
1263 +- unsigned long *fpregs = current_thread_info()->fpregs;
1264 +- unsigned long fprs;
1265 +- int err;
1266 +-
1267 +- err = __get_user(fprs, &fpu->si_fprs);
1268 +- fprs_write(0);
1269 +- regs->tstate &= ~TSTATE_PEF;
1270 +- if (fprs & FPRS_DL)
1271 +- err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
1272 +- (sizeof(unsigned int) * 32));
1273 +- if (fprs & FPRS_DU)
1274 +- err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
1275 +- (sizeof(unsigned int) * 32));
1276 +- err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1277 +- err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1278 +- current_thread_info()->fpsaved[0] |= fprs;
1279 +- return err;
1280 +-}
1281 +-
1282 + void do_rt_sigreturn(struct pt_regs *regs)
1283 + {
1284 + struct rt_signal_frame __user *sf;
1285 + unsigned long tpc, tnpc, tstate;
1286 + __siginfo_fpu_t __user *fpu_save;
1287 ++ __siginfo_rwin_t __user *rwin_save;
1288 + sigset_t set;
1289 + int err;
1290 +
1291 +@@ -325,8 +305,8 @@ void do_rt_sigreturn(struct pt_regs *regs)
1292 + regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
1293 +
1294 + err |= __get_user(fpu_save, &sf->fpu_save);
1295 +- if (fpu_save)
1296 +- err |= restore_fpu_state(regs, &sf->fpu_state);
1297 ++ if (!err && fpu_save)
1298 ++ err |= restore_fpu_state(regs, fpu_save);
1299 +
1300 + err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
1301 + err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf);
1302 +@@ -334,6 +314,12 @@ void do_rt_sigreturn(struct pt_regs *regs)
1303 + if (err)
1304 + goto segv;
1305 +
1306 ++ err |= __get_user(rwin_save, &sf->rwin_save);
1307 ++ if (!err && rwin_save) {
1308 ++ if (restore_rwin_state(rwin_save))
1309 ++ goto segv;
1310 ++ }
1311 ++
1312 + regs->tpc = tpc;
1313 + regs->tnpc = tnpc;
1314 +
1315 +@@ -351,34 +337,13 @@ segv:
1316 + }
1317 +
1318 + /* Checks if the fp is valid */
1319 +-static int invalid_frame_pointer(void __user *fp, int fplen)
1320 ++static int invalid_frame_pointer(void __user *fp)
1321 + {
1322 + if (((unsigned long) fp) & 15)
1323 + return 1;
1324 + return 0;
1325 + }
1326 +
1327 +-static inline int
1328 +-save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1329 +-{
1330 +- unsigned long *fpregs = current_thread_info()->fpregs;
1331 +- unsigned long fprs;
1332 +- int err = 0;
1333 +-
1334 +- fprs = current_thread_info()->fpsaved[0];
1335 +- if (fprs & FPRS_DL)
1336 +- err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
1337 +- (sizeof(unsigned int) * 32));
1338 +- if (fprs & FPRS_DU)
1339 +- err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
1340 +- (sizeof(unsigned int) * 32));
1341 +- err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1342 +- err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1343 +- err |= __put_user(fprs, &fpu->si_fprs);
1344 +-
1345 +- return err;
1346 +-}
1347 +-
1348 + static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize)
1349 + {
1350 + unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
1351 +@@ -414,34 +379,48 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1352 + int signo, sigset_t *oldset, siginfo_t *info)
1353 + {
1354 + struct rt_signal_frame __user *sf;
1355 +- int sigframe_size, err;
1356 ++ int wsaved, err, sf_size;
1357 ++ void __user *tail;
1358 +
1359 + /* 1. Make sure everything is clean */
1360 + synchronize_user_stack();
1361 + save_and_clear_fpu();
1362 +
1363 +- sigframe_size = sizeof(struct rt_signal_frame);
1364 +- if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
1365 +- sigframe_size -= sizeof(__siginfo_fpu_t);
1366 ++ wsaved = get_thread_wsaved();
1367 +
1368 ++ sf_size = sizeof(struct rt_signal_frame);
1369 ++ if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1370 ++ sf_size += sizeof(__siginfo_fpu_t);
1371 ++ if (wsaved)
1372 ++ sf_size += sizeof(__siginfo_rwin_t);
1373 + sf = (struct rt_signal_frame __user *)
1374 +- get_sigframe(ka, regs, sigframe_size);
1375 +-
1376 +- if (invalid_frame_pointer (sf, sigframe_size))
1377 +- goto sigill;
1378 ++ get_sigframe(ka, regs, sf_size);
1379 +
1380 +- if (get_thread_wsaved() != 0)
1381 ++ if (invalid_frame_pointer (sf))
1382 + goto sigill;
1383 +
1384 ++ tail = (sf + 1);
1385 ++
1386 + /* 2. Save the current process state */
1387 + err = copy_to_user(&sf->regs, regs, sizeof (*regs));
1388 +
1389 + if (current_thread_info()->fpsaved[0] & FPRS_FEF) {
1390 +- err |= save_fpu_state(regs, &sf->fpu_state);
1391 +- err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
1392 ++ __siginfo_fpu_t __user *fpu_save = tail;
1393 ++ tail += sizeof(__siginfo_fpu_t);
1394 ++ err |= save_fpu_state(regs, fpu_save);
1395 ++ err |= __put_user((u64)fpu_save, &sf->fpu_save);
1396 + } else {
1397 + err |= __put_user(0, &sf->fpu_save);
1398 + }
1399 ++ if (wsaved) {
1400 ++ __siginfo_rwin_t __user *rwin_save = tail;
1401 ++ tail += sizeof(__siginfo_rwin_t);
1402 ++ err |= save_rwin_state(wsaved, rwin_save);
1403 ++ err |= __put_user((u64)rwin_save, &sf->rwin_save);
1404 ++ set_thread_wsaved(0);
1405 ++ } else {
1406 ++ err |= __put_user(0, &sf->rwin_save);
1407 ++ }
1408 +
1409 + /* Setup sigaltstack */
1410 + err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
1411 +@@ -450,10 +429,17 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1412 +
1413 + err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t));
1414 +
1415 +- err |= copy_in_user((u64 __user *)sf,
1416 +- (u64 __user *)(regs->u_regs[UREG_FP]+STACK_BIAS),
1417 +- sizeof(struct reg_window));
1418 ++ if (!wsaved) {
1419 ++ err |= copy_in_user((u64 __user *)sf,
1420 ++ (u64 __user *)(regs->u_regs[UREG_FP] +
1421 ++ STACK_BIAS),
1422 ++ sizeof(struct reg_window));
1423 ++ } else {
1424 ++ struct reg_window *rp;
1425 +
1426 ++ rp = &current_thread_info()->reg_window[wsaved - 1];
1427 ++ err |= copy_to_user(sf, rp, sizeof(struct reg_window));
1428 ++ }
1429 + if (info)
1430 + err |= copy_siginfo_to_user(&sf->info, info);
1431 + else {
1432 +diff --git a/arch/sparc/kernel/sigutil.h b/arch/sparc/kernel/sigutil.h
1433 +new file mode 100644
1434 +index 0000000..d223aa4
1435 +--- /dev/null
1436 ++++ b/arch/sparc/kernel/sigutil.h
1437 +@@ -0,0 +1,9 @@
1438 ++#ifndef _SIGUTIL_H
1439 ++#define _SIGUTIL_H
1440 ++
1441 ++int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
1442 ++int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
1443 ++int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin);
1444 ++int restore_rwin_state(__siginfo_rwin_t __user *rp);
1445 ++
1446 ++#endif /* _SIGUTIL_H */
1447 +diff --git a/arch/sparc/kernel/sigutil_32.c b/arch/sparc/kernel/sigutil_32.c
1448 +new file mode 100644
1449 +index 0000000..35c7897
1450 +--- /dev/null
1451 ++++ b/arch/sparc/kernel/sigutil_32.c
1452 +@@ -0,0 +1,120 @@
1453 ++#include <linux/kernel.h>
1454 ++#include <linux/types.h>
1455 ++#include <linux/thread_info.h>
1456 ++#include <linux/uaccess.h>
1457 ++#include <linux/sched.h>
1458 ++
1459 ++#include <asm/sigcontext.h>
1460 ++#include <asm/fpumacro.h>
1461 ++#include <asm/ptrace.h>
1462 ++
1463 ++#include "sigutil.h"
1464 ++
1465 ++int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1466 ++{
1467 ++ int err = 0;
1468 ++#ifdef CONFIG_SMP
1469 ++ if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
1470 ++ put_psr(get_psr() | PSR_EF);
1471 ++ fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1472 ++ &current->thread.fpqueue[0], &current->thread.fpqdepth);
1473 ++ regs->psr &= ~(PSR_EF);
1474 ++ clear_tsk_thread_flag(current, TIF_USEDFPU);
1475 ++ }
1476 ++#else
1477 ++ if (current == last_task_used_math) {
1478 ++ put_psr(get_psr() | PSR_EF);
1479 ++ fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1480 ++ &current->thread.fpqueue[0], &current->thread.fpqdepth);
1481 ++ last_task_used_math = NULL;
1482 ++ regs->psr &= ~(PSR_EF);
1483 ++ }
1484 ++#endif
1485 ++ err |= __copy_to_user(&fpu->si_float_regs[0],
1486 ++ &current->thread.float_regs[0],
1487 ++ (sizeof(unsigned long) * 32));
1488 ++ err |= __put_user(current->thread.fsr, &fpu->si_fsr);
1489 ++ err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1490 ++ if (current->thread.fpqdepth != 0)
1491 ++ err |= __copy_to_user(&fpu->si_fpqueue[0],
1492 ++ &current->thread.fpqueue[0],
1493 ++ ((sizeof(unsigned long) +
1494 ++ (sizeof(unsigned long *)))*16));
1495 ++ clear_used_math();
1496 ++ return err;
1497 ++}
1498 ++
1499 ++int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1500 ++{
1501 ++ int err;
1502 ++#ifdef CONFIG_SMP
1503 ++ if (test_tsk_thread_flag(current, TIF_USEDFPU))
1504 ++ regs->psr &= ~PSR_EF;
1505 ++#else
1506 ++ if (current == last_task_used_math) {
1507 ++ last_task_used_math = NULL;
1508 ++ regs->psr &= ~PSR_EF;
1509 ++ }
1510 ++#endif
1511 ++ set_used_math();
1512 ++ clear_tsk_thread_flag(current, TIF_USEDFPU);
1513 ++
1514 ++ if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
1515 ++ return -EFAULT;
1516 ++
1517 ++ err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
1518 ++ (sizeof(unsigned long) * 32));
1519 ++ err |= __get_user(current->thread.fsr, &fpu->si_fsr);
1520 ++ err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1521 ++ if (current->thread.fpqdepth != 0)
1522 ++ err |= __copy_from_user(&current->thread.fpqueue[0],
1523 ++ &fpu->si_fpqueue[0],
1524 ++ ((sizeof(unsigned long) +
1525 ++ (sizeof(unsigned long *)))*16));
1526 ++ return err;
1527 ++}
1528 ++
1529 ++int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
1530 ++{
1531 ++ int i, err = __put_user(wsaved, &rwin->wsaved);
1532 ++
1533 ++ for (i = 0; i < wsaved; i++) {
1534 ++ struct reg_window32 *rp;
1535 ++ unsigned long fp;
1536 ++
1537 ++ rp = &current_thread_info()->reg_window[i];
1538 ++ fp = current_thread_info()->rwbuf_stkptrs[i];
1539 ++ err |= copy_to_user(&rwin->reg_window[i], rp,
1540 ++ sizeof(struct reg_window32));
1541 ++ err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
1542 ++ }
1543 ++ return err;
1544 ++}
1545 ++
1546 ++int restore_rwin_state(__siginfo_rwin_t __user *rp)
1547 ++{
1548 ++ struct thread_info *t = current_thread_info();
1549 ++ int i, wsaved, err;
1550 ++
1551 ++ __get_user(wsaved, &rp->wsaved);
1552 ++ if (wsaved > NSWINS)
1553 ++ return -EFAULT;
1554 ++
1555 ++ err = 0;
1556 ++ for (i = 0; i < wsaved; i++) {
1557 ++ err |= copy_from_user(&t->reg_window[i],
1558 ++ &rp->reg_window[i],
1559 ++ sizeof(struct reg_window32));
1560 ++ err |= __get_user(t->rwbuf_stkptrs[i],
1561 ++ &rp->rwbuf_stkptrs[i]);
1562 ++ }
1563 ++ if (err)
1564 ++ return err;
1565 ++
1566 ++ t->w_saved = wsaved;
1567 ++ synchronize_user_stack();
1568 ++ if (t->w_saved)
1569 ++ return -EFAULT;
1570 ++ return 0;
1571 ++
1572 ++}
1573 +diff --git a/arch/sparc/kernel/sigutil_64.c b/arch/sparc/kernel/sigutil_64.c
1574 +new file mode 100644
1575 +index 0000000..6edc4e5
1576 +--- /dev/null
1577 ++++ b/arch/sparc/kernel/sigutil_64.c
1578 +@@ -0,0 +1,93 @@
1579 ++#include <linux/kernel.h>
1580 ++#include <linux/types.h>
1581 ++#include <linux/thread_info.h>
1582 ++#include <linux/uaccess.h>
1583 ++
1584 ++#include <asm/sigcontext.h>
1585 ++#include <asm/fpumacro.h>
1586 ++#include <asm/ptrace.h>
1587 ++
1588 ++#include "sigutil.h"
1589 ++
1590 ++int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1591 ++{
1592 ++ unsigned long *fpregs = current_thread_info()->fpregs;
1593 ++ unsigned long fprs;
1594 ++ int err = 0;
1595 ++
1596 ++ fprs = current_thread_info()->fpsaved[0];
1597 ++ if (fprs & FPRS_DL)
1598 ++ err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
1599 ++ (sizeof(unsigned int) * 32));
1600 ++ if (fprs & FPRS_DU)
1601 ++ err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
1602 ++ (sizeof(unsigned int) * 32));
1603 ++ err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1604 ++ err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1605 ++ err |= __put_user(fprs, &fpu->si_fprs);
1606 ++
1607 ++ return err;
1608 ++}
1609 ++
1610 ++int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1611 ++{
1612 ++ unsigned long *fpregs = current_thread_info()->fpregs;
1613 ++ unsigned long fprs;
1614 ++ int err;
1615 ++
1616 ++ err = __get_user(fprs, &fpu->si_fprs);
1617 ++ fprs_write(0);
1618 ++ regs->tstate &= ~TSTATE_PEF;
1619 ++ if (fprs & FPRS_DL)
1620 ++ err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
1621 ++ (sizeof(unsigned int) * 32));
1622 ++ if (fprs & FPRS_DU)
1623 ++ err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
1624 ++ (sizeof(unsigned int) * 32));
1625 ++ err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1626 ++ err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1627 ++ current_thread_info()->fpsaved[0] |= fprs;
1628 ++ return err;
1629 ++}
1630 ++
1631 ++int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
1632 ++{
1633 ++ int i, err = __put_user(wsaved, &rwin->wsaved);
1634 ++
1635 ++ for (i = 0; i < wsaved; i++) {
1636 ++ struct reg_window *rp = &current_thread_info()->reg_window[i];
1637 ++ unsigned long fp = current_thread_info()->rwbuf_stkptrs[i];
1638 ++
1639 ++ err |= copy_to_user(&rwin->reg_window[i], rp,
1640 ++ sizeof(struct reg_window));
1641 ++ err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
1642 ++ }
1643 ++ return err;
1644 ++}
1645 ++
1646 ++int restore_rwin_state(__siginfo_rwin_t __user *rp)
1647 ++{
1648 ++ struct thread_info *t = current_thread_info();
1649 ++ int i, wsaved, err;
1650 ++
1651 ++ __get_user(wsaved, &rp->wsaved);
1652 ++ if (wsaved > NSWINS)
1653 ++ return -EFAULT;
1654 ++
1655 ++ err = 0;
1656 ++ for (i = 0; i < wsaved; i++) {
1657 ++ err |= copy_from_user(&t->reg_window[i],
1658 ++ &rp->reg_window[i],
1659 ++ sizeof(struct reg_window));
1660 ++ err |= __get_user(t->rwbuf_stkptrs[i],
1661 ++ &rp->rwbuf_stkptrs[i]);
1662 ++ }
1663 ++ if (err)
1664 ++ return err;
1665 ++
1666 ++ set_thread_wsaved(wsaved);
1667 ++ synchronize_user_stack();
1668 ++ if (get_thread_wsaved())
1669 ++ return -EFAULT;
1670 ++ return 0;
1671 ++}
1672 +diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
1673 +index 7c3a95e..d3d9d50 100644
1674 +--- a/arch/x86/kernel/amd_iommu.c
1675 ++++ b/arch/x86/kernel/amd_iommu.c
1676 +@@ -531,7 +531,9 @@ static void build_inv_all(struct iommu_cmd *cmd)
1677 + * Writes the command to the IOMMUs command buffer and informs the
1678 + * hardware about the new command.
1679 + */
1680 +-static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
1681 ++static int iommu_queue_command_sync(struct amd_iommu *iommu,
1682 ++ struct iommu_cmd *cmd,
1683 ++ bool sync)
1684 + {
1685 + u32 left, tail, head, next_tail;
1686 + unsigned long flags;
1687 +@@ -565,13 +567,18 @@ again:
1688 + copy_cmd_to_buffer(iommu, cmd, tail);
1689 +
1690 + /* We need to sync now to make sure all commands are processed */
1691 +- iommu->need_sync = true;
1692 ++ iommu->need_sync = sync;
1693 +
1694 + spin_unlock_irqrestore(&iommu->lock, flags);
1695 +
1696 + return 0;
1697 + }
1698 +
1699 ++static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
1700 ++{
1701 ++ return iommu_queue_command_sync(iommu, cmd, true);
1702 ++}
1703 ++
1704 + /*
1705 + * This function queues a completion wait command into the command
1706 + * buffer of an IOMMU
1707 +@@ -587,7 +594,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
1708 +
1709 + build_completion_wait(&cmd, (u64)&sem);
1710 +
1711 +- ret = iommu_queue_command(iommu, &cmd);
1712 ++ ret = iommu_queue_command_sync(iommu, &cmd, false);
1713 + if (ret)
1714 + return ret;
1715 +
1716 +@@ -773,14 +780,9 @@ static void domain_flush_complete(struct protection_domain *domain)
1717 + static void domain_flush_devices(struct protection_domain *domain)
1718 + {
1719 + struct iommu_dev_data *dev_data;
1720 +- unsigned long flags;
1721 +-
1722 +- spin_lock_irqsave(&domain->lock, flags);
1723 +
1724 + list_for_each_entry(dev_data, &domain->dev_list, list)
1725 + device_flush_dte(dev_data->dev);
1726 +-
1727 +- spin_unlock_irqrestore(&domain->lock, flags);
1728 + }
1729 +
1730 + /****************************************************************************
1731 +diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
1732 +index 3a0338b..bf6d692 100644
1733 +--- a/arch/x86/kernel/cpu/perf_event.c
1734 ++++ b/arch/x86/kernel/cpu/perf_event.c
1735 +@@ -1856,6 +1856,9 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1736 +
1737 + perf_callchain_store(entry, regs->ip);
1738 +
1739 ++ if (!current->mm)
1740 ++ return;
1741 ++
1742 + if (perf_callchain_user32(regs, entry))
1743 + return;
1744 +
1745 +diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
1746 +index 41178c8..dd208a8 100644
1747 +--- a/arch/x86/kernel/cpu/perf_event_intel.c
1748 ++++ b/arch/x86/kernel/cpu/perf_event_intel.c
1749 +@@ -1495,6 +1495,7 @@ static __init int intel_pmu_init(void)
1750 + break;
1751 +
1752 + case 42: /* SandyBridge */
1753 ++ case 45: /* SandyBridge, "Romely-EP" */
1754 + memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
1755 + sizeof(hw_cache_event_ids));
1756 +
1757 +diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
1758 +index 60aeeb5..acea42e 100644
1759 +--- a/arch/x86/xen/setup.c
1760 ++++ b/arch/x86/xen/setup.c
1761 +@@ -185,6 +185,19 @@ static unsigned long __init xen_set_identity(const struct e820entry *list,
1762 + PFN_UP(start_pci), PFN_DOWN(last));
1763 + return identity;
1764 + }
1765 ++
1766 ++static unsigned long __init xen_get_max_pages(void)
1767 ++{
1768 ++ unsigned long max_pages = MAX_DOMAIN_PAGES;
1769 ++ domid_t domid = DOMID_SELF;
1770 ++ int ret;
1771 ++
1772 ++ ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
1773 ++ if (ret > 0)
1774 ++ max_pages = ret;
1775 ++ return min(max_pages, MAX_DOMAIN_PAGES);
1776 ++}
1777 ++
1778 + /**
1779 + * machine_specific_memory_setup - Hook for machine specific memory setup.
1780 + **/
1781 +@@ -293,6 +306,14 @@ char * __init xen_memory_setup(void)
1782 +
1783 + sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
1784 +
1785 ++ extra_limit = xen_get_max_pages();
1786 ++ if (max_pfn + extra_pages > extra_limit) {
1787 ++ if (extra_limit > max_pfn)
1788 ++ extra_pages = extra_limit - max_pfn;
1789 ++ else
1790 ++ extra_pages = 0;
1791 ++ }
1792 ++
1793 + extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820);
1794 +
1795 + /*
1796 +diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
1797 +index e79dbb9..d4fc6d4 100644
1798 +--- a/arch/x86/xen/smp.c
1799 ++++ b/arch/x86/xen/smp.c
1800 +@@ -32,6 +32,7 @@
1801 + #include <xen/page.h>
1802 + #include <xen/events.h>
1803 +
1804 ++#include <xen/hvc-console.h>
1805 + #include "xen-ops.h"
1806 + #include "mmu.h"
1807 +
1808 +@@ -207,6 +208,15 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
1809 + unsigned cpu;
1810 + unsigned int i;
1811 +
1812 ++ if (skip_ioapic_setup) {
1813 ++ char *m = (max_cpus == 0) ?
1814 ++ "The nosmp parameter is incompatible with Xen; " \
1815 ++ "use Xen dom0_max_vcpus=1 parameter" :
1816 ++ "The noapic parameter is incompatible with Xen";
1817 ++
1818 ++ xen_raw_printk(m);
1819 ++ panic(m);
1820 ++ }
1821 + xen_init_lock_cpu(0);
1822 +
1823 + smp_store_cpu_info(0);
1824 +diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
1825 +index 22a2093..b040b0e 100644
1826 +--- a/arch/x86/xen/xen-asm_32.S
1827 ++++ b/arch/x86/xen/xen-asm_32.S
1828 +@@ -113,11 +113,13 @@ xen_iret_start_crit:
1829 +
1830 + /*
1831 + * If there's something pending, mask events again so we can
1832 +- * jump back into xen_hypervisor_callback
1833 ++ * jump back into xen_hypervisor_callback. Otherwise do not
1834 ++ * touch XEN_vcpu_info_mask.
1835 + */
1836 +- sete XEN_vcpu_info_mask(%eax)
1837 ++ jne 1f
1838 ++ movb $1, XEN_vcpu_info_mask(%eax)
1839 +
1840 +- popl %eax
1841 ++1: popl %eax
1842 +
1843 + /*
1844 + * From this point on the registers are restored and the stack
1845 +diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
1846 +index bcaf16e..b596e54 100644
1847 +--- a/block/blk-cgroup.c
1848 ++++ b/block/blk-cgroup.c
1849 +@@ -785,10 +785,10 @@ static int blkio_policy_parse_and_set(char *buf,
1850 + {
1851 + char *s[4], *p, *major_s = NULL, *minor_s = NULL;
1852 + int ret;
1853 +- unsigned long major, minor, temp;
1854 ++ unsigned long major, minor;
1855 + int i = 0;
1856 + dev_t dev;
1857 +- u64 bps, iops;
1858 ++ u64 temp;
1859 +
1860 + memset(s, 0, sizeof(s));
1861 +
1862 +@@ -826,20 +826,23 @@ static int blkio_policy_parse_and_set(char *buf,
1863 +
1864 + dev = MKDEV(major, minor);
1865 +
1866 +- ret = blkio_check_dev_num(dev);
1867 ++ ret = strict_strtoull(s[1], 10, &temp);
1868 + if (ret)
1869 +- return ret;
1870 ++ return -EINVAL;
1871 +
1872 +- newpn->dev = dev;
1873 ++ /* For rule removal, do not check for device presence. */
1874 ++ if (temp) {
1875 ++ ret = blkio_check_dev_num(dev);
1876 ++ if (ret)
1877 ++ return ret;
1878 ++ }
1879 +
1880 +- if (s[1] == NULL)
1881 +- return -EINVAL;
1882 ++ newpn->dev = dev;
1883 +
1884 + switch (plid) {
1885 + case BLKIO_POLICY_PROP:
1886 +- ret = strict_strtoul(s[1], 10, &temp);
1887 +- if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
1888 +- temp > BLKIO_WEIGHT_MAX)
1889 ++ if ((temp < BLKIO_WEIGHT_MIN && temp > 0) ||
1890 ++ temp > BLKIO_WEIGHT_MAX)
1891 + return -EINVAL;
1892 +
1893 + newpn->plid = plid;
1894 +@@ -850,26 +853,18 @@ static int blkio_policy_parse_and_set(char *buf,
1895 + switch(fileid) {
1896 + case BLKIO_THROTL_read_bps_device:
1897 + case BLKIO_THROTL_write_bps_device:
1898 +- ret = strict_strtoull(s[1], 10, &bps);
1899 +- if (ret)
1900 +- return -EINVAL;
1901 +-
1902 + newpn->plid = plid;
1903 + newpn->fileid = fileid;
1904 +- newpn->val.bps = bps;
1905 ++ newpn->val.bps = temp;
1906 + break;
1907 + case BLKIO_THROTL_read_iops_device:
1908 + case BLKIO_THROTL_write_iops_device:
1909 +- ret = strict_strtoull(s[1], 10, &iops);
1910 +- if (ret)
1911 +- return -EINVAL;
1912 +-
1913 +- if (iops > THROTL_IOPS_MAX)
1914 ++ if (temp > THROTL_IOPS_MAX)
1915 + return -EINVAL;
1916 +
1917 + newpn->plid = plid;
1918 + newpn->fileid = fileid;
1919 +- newpn->val.iops = (unsigned int)iops;
1920 ++ newpn->val.iops = (unsigned int)temp;
1921 + break;
1922 + }
1923 + break;
1924 +diff --git a/block/blk-core.c b/block/blk-core.c
1925 +index 1d49e1c..847d04e 100644
1926 +--- a/block/blk-core.c
1927 ++++ b/block/blk-core.c
1928 +@@ -348,9 +348,10 @@ void blk_put_queue(struct request_queue *q)
1929 + EXPORT_SYMBOL(blk_put_queue);
1930 +
1931 + /*
1932 +- * Note: If a driver supplied the queue lock, it should not zap that lock
1933 +- * unexpectedly as some queue cleanup components like elevator_exit() and
1934 +- * blk_throtl_exit() need queue lock.
1935 ++ * Note: If a driver supplied the queue lock, it is disconnected
1936 ++ * by this function. The actual state of the lock doesn't matter
1937 ++ * here as the request_queue isn't accessible after this point
1938 ++ * (QUEUE_FLAG_DEAD is set) and no other requests will be queued.
1939 + */
1940 + void blk_cleanup_queue(struct request_queue *q)
1941 + {
1942 +@@ -367,10 +368,8 @@ void blk_cleanup_queue(struct request_queue *q)
1943 + queue_flag_set_unlocked(QUEUE_FLAG_DEAD, q);
1944 + mutex_unlock(&q->sysfs_lock);
1945 +
1946 +- if (q->elevator)
1947 +- elevator_exit(q->elevator);
1948 +-
1949 +- blk_throtl_exit(q);
1950 ++ if (q->queue_lock != &q->__queue_lock)
1951 ++ q->queue_lock = &q->__queue_lock;
1952 +
1953 + blk_put_queue(q);
1954 + }
1955 +diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
1956 +index d935bd8..45c56d8 100644
1957 +--- a/block/blk-sysfs.c
1958 ++++ b/block/blk-sysfs.c
1959 +@@ -472,6 +472,11 @@ static void blk_release_queue(struct kobject *kobj)
1960 +
1961 + blk_sync_queue(q);
1962 +
1963 ++ if (q->elevator)
1964 ++ elevator_exit(q->elevator);
1965 ++
1966 ++ blk_throtl_exit(q);
1967 ++
1968 + if (rl->rq_pool)
1969 + mempool_destroy(rl->rq_pool);
1970 +
1971 +diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
1972 +index bc533dd..f895a24 100644
1973 +--- a/drivers/acpi/acpica/acconfig.h
1974 ++++ b/drivers/acpi/acpica/acconfig.h
1975 +@@ -121,7 +121,7 @@
1976 +
1977 + /* Maximum sleep allowed via Sleep() operator */
1978 +
1979 +-#define ACPI_MAX_SLEEP 20000 /* Two seconds */
1980 ++#define ACPI_MAX_SLEEP 2000 /* Two seconds */
1981 +
1982 + /******************************************************************************
1983 + *
1984 +diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
1985 +index c7f743c..5552125 100644
1986 +--- a/drivers/acpi/acpica/aclocal.h
1987 ++++ b/drivers/acpi/acpica/aclocal.h
1988 +@@ -357,6 +357,7 @@ struct acpi_predefined_data {
1989 + char *pathname;
1990 + const union acpi_predefined_info *predefined;
1991 + union acpi_operand_object *parent_package;
1992 ++ struct acpi_namespace_node *node;
1993 + u32 flags;
1994 + u8 node_flags;
1995 + };
1996 +diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
1997 +index 9fb03fa..dc00582 100644
1998 +--- a/drivers/acpi/acpica/nspredef.c
1999 ++++ b/drivers/acpi/acpica/nspredef.c
2000 +@@ -212,6 +212,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
2001 + goto cleanup;
2002 + }
2003 + data->predefined = predefined;
2004 ++ data->node = node;
2005 + data->node_flags = node->flags;
2006 + data->pathname = pathname;
2007 +
2008 +diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
2009 +index 973883b..024c4f2 100644
2010 +--- a/drivers/acpi/acpica/nsrepair2.c
2011 ++++ b/drivers/acpi/acpica/nsrepair2.c
2012 +@@ -503,6 +503,21 @@ acpi_ns_repair_TSS(struct acpi_predefined_data *data,
2013 + {
2014 + union acpi_operand_object *return_object = *return_object_ptr;
2015 + acpi_status status;
2016 ++ struct acpi_namespace_node *node;
2017 ++
2018 ++ /*
2019 ++ * We can only sort the _TSS return package if there is no _PSS in the
2020 ++ * same scope. This is because if _PSS is present, the ACPI specification
2021 ++ * dictates that the _TSS Power Dissipation field is to be ignored, and
2022 ++ * therefore some BIOSs leave garbage values in the _TSS Power field(s).
2023 ++ * In this case, it is best to just return the _TSS package as-is.
2024 ++ * (May, 2011)
2025 ++ */
2026 ++ status =
2027 ++ acpi_ns_get_node(data->node, "^_PSS", ACPI_NS_NO_UPSEARCH, &node);
2028 ++ if (ACPI_SUCCESS(status)) {
2029 ++ return (AE_OK);
2030 ++ }
2031 +
2032 + status = acpi_ns_check_sorted_list(data, return_object, 5, 1,
2033 + ACPI_SORT_DESCENDING,
2034 +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
2035 +index 71afe03..cab6960 100644
2036 +--- a/drivers/ata/ahci.c
2037 ++++ b/drivers/ata/ahci.c
2038 +@@ -267,6 +267,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
2039 + { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
2040 + { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
2041 + { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
2042 ++ { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
2043 +
2044 + /* JMicron 360/1/3/5/6, match class to avoid IDE function */
2045 + { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
2046 +diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
2047 +index ac8d7d9..d6d4f57 100644
2048 +--- a/drivers/ata/pata_via.c
2049 ++++ b/drivers/ata/pata_via.c
2050 +@@ -124,6 +124,17 @@ static const struct via_isa_bridge {
2051 + { NULL }
2052 + };
2053 +
2054 ++static const struct dmi_system_id no_atapi_dma_dmi_table[] = {
2055 ++ {
2056 ++ .ident = "AVERATEC 3200",
2057 ++ .matches = {
2058 ++ DMI_MATCH(DMI_BOARD_VENDOR, "AVERATEC"),
2059 ++ DMI_MATCH(DMI_BOARD_NAME, "3200"),
2060 ++ },
2061 ++ },
2062 ++ { }
2063 ++};
2064 ++
2065 + struct via_port {
2066 + u8 cached_device;
2067 + };
2068 +@@ -355,6 +366,13 @@ static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask)
2069 + mask &= ~ ATA_MASK_UDMA;
2070 + }
2071 + }
2072 ++
2073 ++ if (dev->class == ATA_DEV_ATAPI &&
2074 ++ dmi_check_system(no_atapi_dma_dmi_table)) {
2075 ++ ata_dev_printk(dev, KERN_WARNING, "controller locks up on ATAPI DMA, forcing PIO\n");
2076 ++ mask &= ATA_MASK_PIO;
2077 ++ }
2078 ++
2079 + return mask;
2080 + }
2081 +
2082 +diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
2083 +index bbb03e6..06ed6b4 100644
2084 +--- a/drivers/base/firmware_class.c
2085 ++++ b/drivers/base/firmware_class.c
2086 +@@ -521,11 +521,6 @@ static int _request_firmware(const struct firmware **firmware_p,
2087 + if (!firmware_p)
2088 + return -EINVAL;
2089 +
2090 +- if (WARN_ON(usermodehelper_is_disabled())) {
2091 +- dev_err(device, "firmware: %s will not be loaded\n", name);
2092 +- return -EBUSY;
2093 +- }
2094 +-
2095 + *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
2096 + if (!firmware) {
2097 + dev_err(device, "%s: kmalloc(struct firmware) failed\n",
2098 +@@ -539,6 +534,12 @@ static int _request_firmware(const struct firmware **firmware_p,
2099 + return 0;
2100 + }
2101 +
2102 ++ if (WARN_ON(usermodehelper_is_disabled())) {
2103 ++ dev_err(device, "firmware: %s will not be loaded\n", name);
2104 ++ retval = -EBUSY;
2105 ++ goto out;
2106 ++ }
2107 ++
2108 + if (uevent)
2109 + dev_dbg(device, "firmware: requesting %s\n", name);
2110 +
2111 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
2112 +index 98de8f4..9955a53 100644
2113 +--- a/drivers/block/floppy.c
2114 ++++ b/drivers/block/floppy.c
2115 +@@ -4250,7 +4250,7 @@ static int __init floppy_init(void)
2116 + use_virtual_dma = can_use_virtual_dma & 1;
2117 + fdc_state[0].address = FDC1;
2118 + if (fdc_state[0].address == -1) {
2119 +- del_timer(&fd_timeout);
2120 ++ del_timer_sync(&fd_timeout);
2121 + err = -ENODEV;
2122 + goto out_unreg_region;
2123 + }
2124 +@@ -4261,7 +4261,7 @@ static int __init floppy_init(void)
2125 + fdc = 0; /* reset fdc in case of unexpected interrupt */
2126 + err = floppy_grab_irq_and_dma();
2127 + if (err) {
2128 +- del_timer(&fd_timeout);
2129 ++ del_timer_sync(&fd_timeout);
2130 + err = -EBUSY;
2131 + goto out_unreg_region;
2132 + }
2133 +@@ -4318,7 +4318,7 @@ static int __init floppy_init(void)
2134 + user_reset_fdc(-1, FD_RESET_ALWAYS, false);
2135 + }
2136 + fdc = 0;
2137 +- del_timer(&fd_timeout);
2138 ++ del_timer_sync(&fd_timeout);
2139 + current_drive = 0;
2140 + initialized = true;
2141 + if (have_no_fdc) {
2142 +@@ -4368,7 +4368,7 @@ out_unreg_blkdev:
2143 + unregister_blkdev(FLOPPY_MAJOR, "fd");
2144 + out_put_disk:
2145 + while (dr--) {
2146 +- del_timer(&motor_off_timer[dr]);
2147 ++ del_timer_sync(&motor_off_timer[dr]);
2148 + if (disks[dr]->queue)
2149 + blk_cleanup_queue(disks[dr]->queue);
2150 + put_disk(disks[dr]);
2151 +diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
2152 +index 7beb0e2..b85ee76 100644
2153 +--- a/drivers/char/tpm/tpm.c
2154 ++++ b/drivers/char/tpm/tpm.c
2155 +@@ -383,6 +383,9 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
2156 + u32 count, ordinal;
2157 + unsigned long stop;
2158 +
2159 ++ if (bufsiz > TPM_BUFSIZE)
2160 ++ bufsiz = TPM_BUFSIZE;
2161 ++
2162 + count = be32_to_cpu(*((__be32 *) (buf + 2)));
2163 + ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
2164 + if (count == 0)
2165 +@@ -1052,6 +1055,7 @@ ssize_t tpm_read(struct file *file, char __user *buf,
2166 + {
2167 + struct tpm_chip *chip = file->private_data;
2168 + ssize_t ret_size;
2169 ++ int rc;
2170 +
2171 + del_singleshot_timer_sync(&chip->user_read_timer);
2172 + flush_work_sync(&chip->work);
2173 +@@ -1062,8 +1066,11 @@ ssize_t tpm_read(struct file *file, char __user *buf,
2174 + ret_size = size;
2175 +
2176 + mutex_lock(&chip->buffer_mutex);
2177 +- if (copy_to_user(buf, chip->data_buffer, ret_size))
2178 ++ rc = copy_to_user(buf, chip->data_buffer, ret_size);
2179 ++ memset(chip->data_buffer, 0, ret_size);
2180 ++ if (rc)
2181 + ret_size = -EFAULT;
2182 ++
2183 + mutex_unlock(&chip->buffer_mutex);
2184 + }
2185 +
2186 +diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
2187 +index 7b0603e..cdc02ac 100644
2188 +--- a/drivers/cpufreq/pcc-cpufreq.c
2189 ++++ b/drivers/cpufreq/pcc-cpufreq.c
2190 +@@ -261,6 +261,9 @@ static int pcc_get_offset(int cpu)
2191 + pr = per_cpu(processors, cpu);
2192 + pcc_cpu_data = per_cpu_ptr(pcc_cpu_info, cpu);
2193 +
2194 ++ if (!pr)
2195 ++ return -ENODEV;
2196 ++
2197 + status = acpi_evaluate_object(pr->handle, "PCCP", NULL, &buffer);
2198 + if (ACPI_FAILURE(status))
2199 + return -ENODEV;
2200 +diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
2201 +index ebb8973..ee76c8e 100644
2202 +--- a/drivers/firewire/ohci.c
2203 ++++ b/drivers/firewire/ohci.c
2204 +@@ -291,6 +291,9 @@ static const struct {
2205 + {PCI_VENDOR_ID_NEC, PCI_ANY_ID, PCI_ANY_ID,
2206 + QUIRK_CYCLE_TIMER},
2207 +
2208 ++ {PCI_VENDOR_ID_O2, PCI_ANY_ID, PCI_ANY_ID,
2209 ++ QUIRK_NO_MSI},
2210 ++
2211 + {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, PCI_ANY_ID,
2212 + QUIRK_CYCLE_TIMER},
2213 +
2214 +diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2215 +index 82fad91..ca6028f 100644
2216 +--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2217 ++++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2218 +@@ -37,8 +37,11 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages,
2219 + return -ENOMEM;
2220 +
2221 + nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL);
2222 +- if (!nvbe->ttm_alloced)
2223 ++ if (!nvbe->ttm_alloced) {
2224 ++ kfree(nvbe->pages);
2225 ++ nvbe->pages = NULL;
2226 + return -ENOMEM;
2227 ++ }
2228 +
2229 + nvbe->nr_pages = 0;
2230 + while (num_pages--) {
2231 +diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
2232 +index 15bd047..c975581 100644
2233 +--- a/drivers/gpu/drm/radeon/evergreen.c
2234 ++++ b/drivers/gpu/drm/radeon/evergreen.c
2235 +@@ -41,6 +41,31 @@ static void evergreen_gpu_init(struct radeon_device *rdev);
2236 + void evergreen_fini(struct radeon_device *rdev);
2237 + static void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
2238 +
2239 ++void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)
2240 ++{
2241 ++ u16 ctl, v;
2242 ++ int cap, err;
2243 ++
2244 ++ cap = pci_pcie_cap(rdev->pdev);
2245 ++ if (!cap)
2246 ++ return;
2247 ++
2248 ++ err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl);
2249 ++ if (err)
2250 ++ return;
2251 ++
2252 ++ v = (ctl & PCI_EXP_DEVCTL_READRQ) >> 12;
2253 ++
2254 ++ /* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it
2255 ++ * to avoid hangs or perfomance issues
2256 ++ */
2257 ++ if ((v == 0) || (v == 6) || (v == 7)) {
2258 ++ ctl &= ~PCI_EXP_DEVCTL_READRQ;
2259 ++ ctl |= (2 << 12);
2260 ++ pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl);
2261 ++ }
2262 ++}
2263 ++
2264 + void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc)
2265 + {
2266 + /* enable the pflip int */
2267 +@@ -1357,6 +1382,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2268 + SOFT_RESET_PA |
2269 + SOFT_RESET_SH |
2270 + SOFT_RESET_VGT |
2271 ++ SOFT_RESET_SPI |
2272 + SOFT_RESET_SX));
2273 + RREG32(GRBM_SOFT_RESET);
2274 + mdelay(15);
2275 +@@ -1378,7 +1404,8 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2276 + /* Initialize the ring buffer's read and write pointers */
2277 + WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
2278 + WREG32(CP_RB_RPTR_WR, 0);
2279 +- WREG32(CP_RB_WPTR, 0);
2280 ++ rdev->cp.wptr = 0;
2281 ++ WREG32(CP_RB_WPTR, rdev->cp.wptr);
2282 +
2283 + /* set the wb address wether it's enabled or not */
2284 + WREG32(CP_RB_RPTR_ADDR,
2285 +@@ -1403,7 +1430,6 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2286 + WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
2287 +
2288 + rdev->cp.rptr = RREG32(CP_RB_RPTR);
2289 +- rdev->cp.wptr = RREG32(CP_RB_WPTR);
2290 +
2291 + evergreen_cp_start(rdev);
2292 + rdev->cp.ready = true;
2293 +@@ -1865,6 +1891,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
2294 +
2295 + WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
2296 +
2297 ++ evergreen_fix_pci_max_read_req_size(rdev);
2298 ++
2299 + cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2;
2300 +
2301 + cc_gc_shader_pipe_config |=
2302 +@@ -3142,21 +3170,23 @@ int evergreen_suspend(struct radeon_device *rdev)
2303 + }
2304 +
2305 + int evergreen_copy_blit(struct radeon_device *rdev,
2306 +- uint64_t src_offset, uint64_t dst_offset,
2307 +- unsigned num_pages, struct radeon_fence *fence)
2308 ++ uint64_t src_offset,
2309 ++ uint64_t dst_offset,
2310 ++ unsigned num_gpu_pages,
2311 ++ struct radeon_fence *fence)
2312 + {
2313 + int r;
2314 +
2315 + mutex_lock(&rdev->r600_blit.mutex);
2316 + rdev->r600_blit.vb_ib = NULL;
2317 +- r = evergreen_blit_prepare_copy(rdev, num_pages * RADEON_GPU_PAGE_SIZE);
2318 ++ r = evergreen_blit_prepare_copy(rdev, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2319 + if (r) {
2320 + if (rdev->r600_blit.vb_ib)
2321 + radeon_ib_free(rdev, &rdev->r600_blit.vb_ib);
2322 + mutex_unlock(&rdev->r600_blit.mutex);
2323 + return r;
2324 + }
2325 +- evergreen_kms_blit_copy(rdev, src_offset, dst_offset, num_pages * RADEON_GPU_PAGE_SIZE);
2326 ++ evergreen_kms_blit_copy(rdev, src_offset, dst_offset, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2327 + evergreen_blit_done_copy(rdev, fence);
2328 + mutex_unlock(&rdev->r600_blit.mutex);
2329 + return 0;
2330 +diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
2331 +index 559dbd4..0b132a3 100644
2332 +--- a/drivers/gpu/drm/radeon/ni.c
2333 ++++ b/drivers/gpu/drm/radeon/ni.c
2334 +@@ -39,6 +39,7 @@ extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev);
2335 + extern void evergreen_mc_program(struct radeon_device *rdev);
2336 + extern void evergreen_irq_suspend(struct radeon_device *rdev);
2337 + extern int evergreen_mc_init(struct radeon_device *rdev);
2338 ++extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
2339 +
2340 + #define EVERGREEN_PFP_UCODE_SIZE 1120
2341 + #define EVERGREEN_PM4_UCODE_SIZE 1376
2342 +@@ -669,6 +670,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
2343 +
2344 + WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
2345 +
2346 ++ evergreen_fix_pci_max_read_req_size(rdev);
2347 ++
2348 + mc_shared_chmap = RREG32(MC_SHARED_CHMAP);
2349 + mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG);
2350 +
2351 +@@ -1158,6 +1161,7 @@ int cayman_cp_resume(struct radeon_device *rdev)
2352 + SOFT_RESET_PA |
2353 + SOFT_RESET_SH |
2354 + SOFT_RESET_VGT |
2355 ++ SOFT_RESET_SPI |
2356 + SOFT_RESET_SX));
2357 + RREG32(GRBM_SOFT_RESET);
2358 + mdelay(15);
2359 +@@ -1182,7 +1186,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2360 +
2361 + /* Initialize the ring buffer's read and write pointers */
2362 + WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA);
2363 +- WREG32(CP_RB0_WPTR, 0);
2364 ++ rdev->cp.wptr = 0;
2365 ++ WREG32(CP_RB0_WPTR, rdev->cp.wptr);
2366 +
2367 + /* set the wb address wether it's enabled or not */
2368 + WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC);
2369 +@@ -1202,7 +1207,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2370 + WREG32(CP_RB0_BASE, rdev->cp.gpu_addr >> 8);
2371 +
2372 + rdev->cp.rptr = RREG32(CP_RB0_RPTR);
2373 +- rdev->cp.wptr = RREG32(CP_RB0_WPTR);
2374 +
2375 + /* ring1 - compute only */
2376 + /* Set ring buffer size */
2377 +@@ -1215,7 +1219,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2378 +
2379 + /* Initialize the ring buffer's read and write pointers */
2380 + WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA);
2381 +- WREG32(CP_RB1_WPTR, 0);
2382 ++ rdev->cp1.wptr = 0;
2383 ++ WREG32(CP_RB1_WPTR, rdev->cp1.wptr);
2384 +
2385 + /* set the wb address wether it's enabled or not */
2386 + WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC);
2387 +@@ -1227,7 +1232,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2388 + WREG32(CP_RB1_BASE, rdev->cp1.gpu_addr >> 8);
2389 +
2390 + rdev->cp1.rptr = RREG32(CP_RB1_RPTR);
2391 +- rdev->cp1.wptr = RREG32(CP_RB1_WPTR);
2392 +
2393 + /* ring2 - compute only */
2394 + /* Set ring buffer size */
2395 +@@ -1240,7 +1244,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2396 +
2397 + /* Initialize the ring buffer's read and write pointers */
2398 + WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA);
2399 +- WREG32(CP_RB2_WPTR, 0);
2400 ++ rdev->cp2.wptr = 0;
2401 ++ WREG32(CP_RB2_WPTR, rdev->cp2.wptr);
2402 +
2403 + /* set the wb address wether it's enabled or not */
2404 + WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC);
2405 +@@ -1252,7 +1257,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2406 + WREG32(CP_RB2_BASE, rdev->cp2.gpu_addr >> 8);
2407 +
2408 + rdev->cp2.rptr = RREG32(CP_RB2_RPTR);
2409 +- rdev->cp2.wptr = RREG32(CP_RB2_WPTR);
2410 +
2411 + /* start the rings */
2412 + cayman_cp_start(rdev);
2413 +diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
2414 +index f2204cb..830e1f1 100644
2415 +--- a/drivers/gpu/drm/radeon/r100.c
2416 ++++ b/drivers/gpu/drm/radeon/r100.c
2417 +@@ -721,11 +721,11 @@ void r100_fence_ring_emit(struct radeon_device *rdev,
2418 + int r100_copy_blit(struct radeon_device *rdev,
2419 + uint64_t src_offset,
2420 + uint64_t dst_offset,
2421 +- unsigned num_pages,
2422 ++ unsigned num_gpu_pages,
2423 + struct radeon_fence *fence)
2424 + {
2425 + uint32_t cur_pages;
2426 +- uint32_t stride_bytes = PAGE_SIZE;
2427 ++ uint32_t stride_bytes = RADEON_GPU_PAGE_SIZE;
2428 + uint32_t pitch;
2429 + uint32_t stride_pixels;
2430 + unsigned ndw;
2431 +@@ -737,7 +737,7 @@ int r100_copy_blit(struct radeon_device *rdev,
2432 + /* radeon pitch is /64 */
2433 + pitch = stride_bytes / 64;
2434 + stride_pixels = stride_bytes / 4;
2435 +- num_loops = DIV_ROUND_UP(num_pages, 8191);
2436 ++ num_loops = DIV_ROUND_UP(num_gpu_pages, 8191);
2437 +
2438 + /* Ask for enough room for blit + flush + fence */
2439 + ndw = 64 + (10 * num_loops);
2440 +@@ -746,12 +746,12 @@ int r100_copy_blit(struct radeon_device *rdev,
2441 + DRM_ERROR("radeon: moving bo (%d) asking for %u dw.\n", r, ndw);
2442 + return -EINVAL;
2443 + }
2444 +- while (num_pages > 0) {
2445 +- cur_pages = num_pages;
2446 ++ while (num_gpu_pages > 0) {
2447 ++ cur_pages = num_gpu_pages;
2448 + if (cur_pages > 8191) {
2449 + cur_pages = 8191;
2450 + }
2451 +- num_pages -= cur_pages;
2452 ++ num_gpu_pages -= cur_pages;
2453 +
2454 + /* pages are in Y direction - height
2455 + page width in X direction - width */
2456 +@@ -990,7 +990,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
2457 + /* Force read & write ptr to 0 */
2458 + WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA | RADEON_RB_NO_UPDATE);
2459 + WREG32(RADEON_CP_RB_RPTR_WR, 0);
2460 +- WREG32(RADEON_CP_RB_WPTR, 0);
2461 ++ rdev->cp.wptr = 0;
2462 ++ WREG32(RADEON_CP_RB_WPTR, rdev->cp.wptr);
2463 +
2464 + /* set the wb address whether it's enabled or not */
2465 + WREG32(R_00070C_CP_RB_RPTR_ADDR,
2466 +@@ -1007,9 +1008,6 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
2467 + WREG32(RADEON_CP_RB_CNTL, tmp);
2468 + udelay(10);
2469 + rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
2470 +- rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR);
2471 +- /* protect against crazy HW on resume */
2472 +- rdev->cp.wptr &= rdev->cp.ptr_mask;
2473 + /* Set cp mode to bus mastering & enable cp*/
2474 + WREG32(RADEON_CP_CSQ_MODE,
2475 + REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
2476 +diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
2477 +index f240583..a1f3ba0 100644
2478 +--- a/drivers/gpu/drm/radeon/r200.c
2479 ++++ b/drivers/gpu/drm/radeon/r200.c
2480 +@@ -84,7 +84,7 @@ static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)
2481 + int r200_copy_dma(struct radeon_device *rdev,
2482 + uint64_t src_offset,
2483 + uint64_t dst_offset,
2484 +- unsigned num_pages,
2485 ++ unsigned num_gpu_pages,
2486 + struct radeon_fence *fence)
2487 + {
2488 + uint32_t size;
2489 +@@ -93,7 +93,7 @@ int r200_copy_dma(struct radeon_device *rdev,
2490 + int r = 0;
2491 +
2492 + /* radeon pitch is /64 */
2493 +- size = num_pages << PAGE_SHIFT;
2494 ++ size = num_gpu_pages << RADEON_GPU_PAGE_SHIFT;
2495 + num_loops = DIV_ROUND_UP(size, 0x1FFFFF);
2496 + r = radeon_ring_lock(rdev, num_loops * 4 + 64);
2497 + if (r) {
2498 +diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
2499 +index bc54b26..1dea9d6 100644
2500 +--- a/drivers/gpu/drm/radeon/r600.c
2501 ++++ b/drivers/gpu/drm/radeon/r600.c
2502 +@@ -2208,7 +2208,8 @@ int r600_cp_resume(struct radeon_device *rdev)
2503 + /* Initialize the ring buffer's read and write pointers */
2504 + WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
2505 + WREG32(CP_RB_RPTR_WR, 0);
2506 +- WREG32(CP_RB_WPTR, 0);
2507 ++ rdev->cp.wptr = 0;
2508 ++ WREG32(CP_RB_WPTR, rdev->cp.wptr);
2509 +
2510 + /* set the wb address whether it's enabled or not */
2511 + WREG32(CP_RB_RPTR_ADDR,
2512 +@@ -2233,7 +2234,6 @@ int r600_cp_resume(struct radeon_device *rdev)
2513 + WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
2514 +
2515 + rdev->cp.rptr = RREG32(CP_RB_RPTR);
2516 +- rdev->cp.wptr = RREG32(CP_RB_WPTR);
2517 +
2518 + r600_cp_start(rdev);
2519 + rdev->cp.ready = true;
2520 +@@ -2355,21 +2355,23 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
2521 + }
2522 +
2523 + int r600_copy_blit(struct radeon_device *rdev,
2524 +- uint64_t src_offset, uint64_t dst_offset,
2525 +- unsigned num_pages, struct radeon_fence *fence)
2526 ++ uint64_t src_offset,
2527 ++ uint64_t dst_offset,
2528 ++ unsigned num_gpu_pages,
2529 ++ struct radeon_fence *fence)
2530 + {
2531 + int r;
2532 +
2533 + mutex_lock(&rdev->r600_blit.mutex);
2534 + rdev->r600_blit.vb_ib = NULL;
2535 +- r = r600_blit_prepare_copy(rdev, num_pages * RADEON_GPU_PAGE_SIZE);
2536 ++ r = r600_blit_prepare_copy(rdev, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2537 + if (r) {
2538 + if (rdev->r600_blit.vb_ib)
2539 + radeon_ib_free(rdev, &rdev->r600_blit.vb_ib);
2540 + mutex_unlock(&rdev->r600_blit.mutex);
2541 + return r;
2542 + }
2543 +- r600_kms_blit_copy(rdev, src_offset, dst_offset, num_pages * RADEON_GPU_PAGE_SIZE);
2544 ++ r600_kms_blit_copy(rdev, src_offset, dst_offset, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2545 + r600_blit_done_copy(rdev, fence);
2546 + mutex_unlock(&rdev->r600_blit.mutex);
2547 + return 0;
2548 +diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
2549 +index ef0e0e0..0bb4ddf 100644
2550 +--- a/drivers/gpu/drm/radeon/radeon.h
2551 ++++ b/drivers/gpu/drm/radeon/radeon.h
2552 +@@ -322,6 +322,7 @@ union radeon_gart_table {
2553 +
2554 + #define RADEON_GPU_PAGE_SIZE 4096
2555 + #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
2556 ++#define RADEON_GPU_PAGE_SHIFT 12
2557 +
2558 + struct radeon_gart {
2559 + dma_addr_t table_addr;
2560 +@@ -914,17 +915,17 @@ struct radeon_asic {
2561 + int (*copy_blit)(struct radeon_device *rdev,
2562 + uint64_t src_offset,
2563 + uint64_t dst_offset,
2564 +- unsigned num_pages,
2565 ++ unsigned num_gpu_pages,
2566 + struct radeon_fence *fence);
2567 + int (*copy_dma)(struct radeon_device *rdev,
2568 + uint64_t src_offset,
2569 + uint64_t dst_offset,
2570 +- unsigned num_pages,
2571 ++ unsigned num_gpu_pages,
2572 + struct radeon_fence *fence);
2573 + int (*copy)(struct radeon_device *rdev,
2574 + uint64_t src_offset,
2575 + uint64_t dst_offset,
2576 +- unsigned num_pages,
2577 ++ unsigned num_gpu_pages,
2578 + struct radeon_fence *fence);
2579 + uint32_t (*get_engine_clock)(struct radeon_device *rdev);
2580 + void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
2581 +diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
2582 +index 3d7a0d7..3dedaa0 100644
2583 +--- a/drivers/gpu/drm/radeon/radeon_asic.h
2584 ++++ b/drivers/gpu/drm/radeon/radeon_asic.h
2585 +@@ -75,7 +75,7 @@ uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg);
2586 + int r100_copy_blit(struct radeon_device *rdev,
2587 + uint64_t src_offset,
2588 + uint64_t dst_offset,
2589 +- unsigned num_pages,
2590 ++ unsigned num_gpu_pages,
2591 + struct radeon_fence *fence);
2592 + int r100_set_surface_reg(struct radeon_device *rdev, int reg,
2593 + uint32_t tiling_flags, uint32_t pitch,
2594 +@@ -143,7 +143,7 @@ extern void r100_post_page_flip(struct radeon_device *rdev, int crtc);
2595 + extern int r200_copy_dma(struct radeon_device *rdev,
2596 + uint64_t src_offset,
2597 + uint64_t dst_offset,
2598 +- unsigned num_pages,
2599 ++ unsigned num_gpu_pages,
2600 + struct radeon_fence *fence);
2601 + void r200_set_safe_registers(struct radeon_device *rdev);
2602 +
2603 +@@ -311,7 +311,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
2604 + int r600_ring_test(struct radeon_device *rdev);
2605 + int r600_copy_blit(struct radeon_device *rdev,
2606 + uint64_t src_offset, uint64_t dst_offset,
2607 +- unsigned num_pages, struct radeon_fence *fence);
2608 ++ unsigned num_gpu_pages, struct radeon_fence *fence);
2609 + void r600_hpd_init(struct radeon_device *rdev);
2610 + void r600_hpd_fini(struct radeon_device *rdev);
2611 + bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
2612 +@@ -403,7 +403,7 @@ void evergreen_bandwidth_update(struct radeon_device *rdev);
2613 + void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
2614 + int evergreen_copy_blit(struct radeon_device *rdev,
2615 + uint64_t src_offset, uint64_t dst_offset,
2616 +- unsigned num_pages, struct radeon_fence *fence);
2617 ++ unsigned num_gpu_pages, struct radeon_fence *fence);
2618 + void evergreen_hpd_init(struct radeon_device *rdev);
2619 + void evergreen_hpd_fini(struct radeon_device *rdev);
2620 + bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
2621 +diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c
2622 +index 2d48e7a..b956cf1 100644
2623 +--- a/drivers/gpu/drm/radeon/radeon_clocks.c
2624 ++++ b/drivers/gpu/drm/radeon/radeon_clocks.c
2625 +@@ -219,6 +219,9 @@ void radeon_get_clock_info(struct drm_device *dev)
2626 + } else {
2627 + DRM_INFO("Using generic clock info\n");
2628 +
2629 ++ /* may need to be per card */
2630 ++ rdev->clock.max_pixel_clock = 35000;
2631 ++
2632 + if (rdev->flags & RADEON_IS_IGP) {
2633 + p1pll->reference_freq = 1432;
2634 + p2pll->reference_freq = 1432;
2635 +diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
2636 +index a74217c..cd3c86c 100644
2637 +--- a/drivers/gpu/drm/radeon/radeon_combios.c
2638 ++++ b/drivers/gpu/drm/radeon/radeon_combios.c
2639 +@@ -3279,6 +3279,14 @@ void radeon_combios_asic_init(struct drm_device *dev)
2640 + rdev->pdev->subsystem_device == 0x30a4)
2641 + return;
2642 +
2643 ++ /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume
2644 ++ * - it hangs on resume inside the dynclk 1 table.
2645 ++ */
2646 ++ if (rdev->family == CHIP_RS480 &&
2647 ++ rdev->pdev->subsystem_vendor == 0x103c &&
2648 ++ rdev->pdev->subsystem_device == 0x30ae)
2649 ++ return;
2650 ++
2651 + /* DYN CLK 1 */
2652 + table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2653 + if (table)
2654 +diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
2655 +index 319d85d..13690f3 100644
2656 +--- a/drivers/gpu/drm/radeon/radeon_encoders.c
2657 ++++ b/drivers/gpu/drm/radeon/radeon_encoders.c
2658 +@@ -1507,7 +1507,14 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
2659 + switch (mode) {
2660 + case DRM_MODE_DPMS_ON:
2661 + args.ucAction = ATOM_ENABLE;
2662 +- atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2663 ++ /* workaround for DVOOutputControl on some RS690 systems */
2664 ++ if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DDI) {
2665 ++ u32 reg = RREG32(RADEON_BIOS_3_SCRATCH);
2666 ++ WREG32(RADEON_BIOS_3_SCRATCH, reg & ~ATOM_S3_DFP2I_ACTIVE);
2667 ++ atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2668 ++ WREG32(RADEON_BIOS_3_SCRATCH, reg);
2669 ++ } else
2670 ++ atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2671 + if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
2672 + args.ucAction = ATOM_LCD_BLON;
2673 + atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2674 +diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
2675 +index 60125dd..3e9b41b 100644
2676 +--- a/drivers/gpu/drm/radeon/radeon_ttm.c
2677 ++++ b/drivers/gpu/drm/radeon/radeon_ttm.c
2678 +@@ -277,7 +277,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
2679 + DRM_ERROR("Trying to move memory with CP turned off.\n");
2680 + return -EINVAL;
2681 + }
2682 +- r = radeon_copy(rdev, old_start, new_start, new_mem->num_pages, fence);
2683 ++
2684 ++ BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0);
2685 ++
2686 ++ r = radeon_copy(rdev, old_start, new_start,
2687 ++ new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */
2688 ++ fence);
2689 + /* FIXME: handle copy error */
2690 + r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL,
2691 + evict, no_wait_reserve, no_wait_gpu, new_mem);
2692 +diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
2693 +index 257957c..4f7c3fc 100644
2694 +--- a/drivers/hwmon/ds620.c
2695 ++++ b/drivers/hwmon/ds620.c
2696 +@@ -72,7 +72,7 @@ struct ds620_data {
2697 + char valid; /* !=0 if following fields are valid */
2698 + unsigned long last_updated; /* In jiffies */
2699 +
2700 +- u16 temp[3]; /* Register values, word */
2701 ++ s16 temp[3]; /* Register values, word */
2702 + };
2703 +
2704 + /*
2705 +diff --git a/drivers/hwmon/max16065.c b/drivers/hwmon/max16065.c
2706 +index d94a24f..dd2d7b9 100644
2707 +--- a/drivers/hwmon/max16065.c
2708 ++++ b/drivers/hwmon/max16065.c
2709 +@@ -124,7 +124,7 @@ static inline int MV_TO_LIMIT(int mv, int range)
2710 +
2711 + static inline int ADC_TO_CURR(int adc, int gain)
2712 + {
2713 +- return adc * 1400000 / gain * 255;
2714 ++ return adc * 1400000 / (gain * 255);
2715 + }
2716 +
2717 + /*
2718 +diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
2719 +index 0a5008f..2332dc2 100644
2720 +--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
2721 ++++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
2722 +@@ -287,7 +287,7 @@ void __free_ep(struct kref *kref)
2723 + if (test_bit(RELEASE_RESOURCES, &ep->com.flags)) {
2724 + cxgb3_remove_tid(ep->com.tdev, (void *)ep, ep->hwtid);
2725 + dst_release(ep->dst);
2726 +- l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2727 ++ l2t_release(ep->com.tdev, ep->l2t);
2728 + }
2729 + kfree(ep);
2730 + }
2731 +@@ -1178,7 +1178,7 @@ static int act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2732 + release_tid(ep->com.tdev, GET_TID(rpl), NULL);
2733 + cxgb3_free_atid(ep->com.tdev, ep->atid);
2734 + dst_release(ep->dst);
2735 +- l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2736 ++ l2t_release(ep->com.tdev, ep->l2t);
2737 + put_ep(&ep->com);
2738 + return CPL_RET_BUF_DONE;
2739 + }
2740 +@@ -1375,7 +1375,7 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2741 + if (!child_ep) {
2742 + printk(KERN_ERR MOD "%s - failed to allocate ep entry!\n",
2743 + __func__);
2744 +- l2t_release(L2DATA(tdev), l2t);
2745 ++ l2t_release(tdev, l2t);
2746 + dst_release(dst);
2747 + goto reject;
2748 + }
2749 +@@ -1952,7 +1952,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2750 + if (!err)
2751 + goto out;
2752 +
2753 +- l2t_release(L2DATA(h->rdev.t3cdev_p), ep->l2t);
2754 ++ l2t_release(h->rdev.t3cdev_p, ep->l2t);
2755 + fail4:
2756 + dst_release(ep->dst);
2757 + fail3:
2758 +@@ -2123,7 +2123,7 @@ int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
2759 + PDBG("%s ep %p redirect to dst %p l2t %p\n", __func__, ep, new,
2760 + l2t);
2761 + dst_hold(new);
2762 +- l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2763 ++ l2t_release(ep->com.tdev, ep->l2t);
2764 + ep->l2t = l2t;
2765 + dst_release(old);
2766 + ep->dst = new;
2767 +diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
2768 +index d87c9d0..328c64c 100644
2769 +--- a/drivers/leds/ledtrig-timer.c
2770 ++++ b/drivers/leds/ledtrig-timer.c
2771 +@@ -41,6 +41,7 @@ static ssize_t led_delay_on_store(struct device *dev,
2772 +
2773 + if (count == size) {
2774 + led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
2775 ++ led_cdev->blink_delay_on = state;
2776 + ret = count;
2777 + }
2778 +
2779 +@@ -69,6 +70,7 @@ static ssize_t led_delay_off_store(struct device *dev,
2780 +
2781 + if (count == size) {
2782 + led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
2783 ++ led_cdev->blink_delay_off = state;
2784 + ret = count;
2785 + }
2786 +
2787 +diff --git a/drivers/md/linear.h b/drivers/md/linear.h
2788 +index 0ce29b6..2f2da05 100644
2789 +--- a/drivers/md/linear.h
2790 ++++ b/drivers/md/linear.h
2791 +@@ -10,9 +10,9 @@ typedef struct dev_info dev_info_t;
2792 +
2793 + struct linear_private_data
2794 + {
2795 ++ struct rcu_head rcu;
2796 + sector_t array_sectors;
2797 + dev_info_t disks[0];
2798 +- struct rcu_head rcu;
2799 + };
2800 +
2801 +
2802 +diff --git a/drivers/md/md.c b/drivers/md/md.c
2803 +index 91e31e2..8554082 100644
2804 +--- a/drivers/md/md.c
2805 ++++ b/drivers/md/md.c
2806 +@@ -1084,8 +1084,11 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
2807 + ret = 0;
2808 + }
2809 + rdev->sectors = rdev->sb_start;
2810 ++ /* Limit to 4TB as metadata cannot record more than that */
2811 ++ if (rdev->sectors >= (2ULL << 32))
2812 ++ rdev->sectors = (2ULL << 32) - 2;
2813 +
2814 +- if (rdev->sectors < sb->size * 2 && sb->level > 1)
2815 ++ if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1)
2816 + /* "this cannot possibly happen" ... */
2817 + ret = -EINVAL;
2818 +
2819 +@@ -1119,7 +1122,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
2820 + mddev->clevel[0] = 0;
2821 + mddev->layout = sb->layout;
2822 + mddev->raid_disks = sb->raid_disks;
2823 +- mddev->dev_sectors = sb->size * 2;
2824 ++ mddev->dev_sectors = ((sector_t)sb->size) * 2;
2825 + mddev->events = ev1;
2826 + mddev->bitmap_info.offset = 0;
2827 + mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9;
2828 +@@ -1361,6 +1364,11 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
2829 + rdev->sb_start = calc_dev_sboffset(rdev);
2830 + if (!num_sectors || num_sectors > rdev->sb_start)
2831 + num_sectors = rdev->sb_start;
2832 ++ /* Limit to 4TB as metadata cannot record more than that.
2833 ++ * 4TB == 2^32 KB, or 2*2^32 sectors.
2834 ++ */
2835 ++ if (num_sectors >= (2ULL << 32))
2836 ++ num_sectors = (2ULL << 32) - 2;
2837 + md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
2838 + rdev->sb_page);
2839 + md_super_wait(rdev->mddev);
2840 +diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
2841 +index 3db89e3..536c16c 100644
2842 +--- a/drivers/media/dvb/dvb-usb/vp7045.c
2843 ++++ b/drivers/media/dvb/dvb-usb/vp7045.c
2844 +@@ -224,26 +224,8 @@ static struct dvb_usb_device_properties vp7045_properties;
2845 + static int vp7045_usb_probe(struct usb_interface *intf,
2846 + const struct usb_device_id *id)
2847 + {
2848 +- struct dvb_usb_device *d;
2849 +- int ret = dvb_usb_device_init(intf, &vp7045_properties,
2850 +- THIS_MODULE, &d, adapter_nr);
2851 +- if (ret)
2852 +- return ret;
2853 +-
2854 +- d->priv = kmalloc(20, GFP_KERNEL);
2855 +- if (!d->priv) {
2856 +- dvb_usb_device_exit(intf);
2857 +- return -ENOMEM;
2858 +- }
2859 +-
2860 +- return ret;
2861 +-}
2862 +-
2863 +-static void vp7045_usb_disconnect(struct usb_interface *intf)
2864 +-{
2865 +- struct dvb_usb_device *d = usb_get_intfdata(intf);
2866 +- kfree(d->priv);
2867 +- dvb_usb_device_exit(intf);
2868 ++ return dvb_usb_device_init(intf, &vp7045_properties,
2869 ++ THIS_MODULE, NULL, adapter_nr);
2870 + }
2871 +
2872 + static struct usb_device_id vp7045_usb_table [] = {
2873 +@@ -258,7 +240,7 @@ MODULE_DEVICE_TABLE(usb, vp7045_usb_table);
2874 + static struct dvb_usb_device_properties vp7045_properties = {
2875 + .usb_ctrl = CYPRESS_FX2,
2876 + .firmware = "dvb-usb-vp7045-01.fw",
2877 +- .size_of_priv = sizeof(u8 *),
2878 ++ .size_of_priv = 20,
2879 +
2880 + .num_adapters = 1,
2881 + .adapter = {
2882 +@@ -305,7 +287,7 @@ static struct dvb_usb_device_properties vp7045_properties = {
2883 + static struct usb_driver vp7045_usb_driver = {
2884 + .name = "dvb_usb_vp7045",
2885 + .probe = vp7045_usb_probe,
2886 +- .disconnect = vp7045_usb_disconnect,
2887 ++ .disconnect = dvb_usb_device_exit,
2888 + .id_table = vp7045_usb_table,
2889 + };
2890 +
2891 +diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
2892 +index ce595f9..9fd019e 100644
2893 +--- a/drivers/media/rc/nuvoton-cir.c
2894 ++++ b/drivers/media/rc/nuvoton-cir.c
2895 +@@ -624,7 +624,6 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt)
2896 + static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
2897 + {
2898 + DEFINE_IR_RAW_EVENT(rawir);
2899 +- unsigned int count;
2900 + u32 carrier;
2901 + u8 sample;
2902 + int i;
2903 +@@ -637,65 +636,38 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
2904 + if (nvt->carrier_detect_enabled)
2905 + carrier = nvt_rx_carrier_detect(nvt);
2906 +
2907 +- count = nvt->pkts;
2908 +- nvt_dbg_verbose("Processing buffer of len %d", count);
2909 ++ nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts);
2910 +
2911 + init_ir_raw_event(&rawir);
2912 +
2913 +- for (i = 0; i < count; i++) {
2914 +- nvt->pkts--;
2915 ++ for (i = 0; i < nvt->pkts; i++) {
2916 + sample = nvt->buf[i];
2917 +
2918 + rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
2919 + rawir.duration = US_TO_NS((sample & BUF_LEN_MASK)
2920 + * SAMPLE_PERIOD);
2921 +
2922 +- if ((sample & BUF_LEN_MASK) == BUF_LEN_MASK) {
2923 +- if (nvt->rawir.pulse == rawir.pulse)
2924 +- nvt->rawir.duration += rawir.duration;
2925 +- else {
2926 +- nvt->rawir.duration = rawir.duration;
2927 +- nvt->rawir.pulse = rawir.pulse;
2928 +- }
2929 +- continue;
2930 +- }
2931 +-
2932 +- rawir.duration += nvt->rawir.duration;
2933 ++ nvt_dbg("Storing %s with duration %d",
2934 ++ rawir.pulse ? "pulse" : "space", rawir.duration);
2935 +
2936 +- init_ir_raw_event(&nvt->rawir);
2937 +- nvt->rawir.duration = 0;
2938 +- nvt->rawir.pulse = rawir.pulse;
2939 +-
2940 +- if (sample == BUF_PULSE_BIT)
2941 +- rawir.pulse = false;
2942 +-
2943 +- if (rawir.duration) {
2944 +- nvt_dbg("Storing %s with duration %d",
2945 +- rawir.pulse ? "pulse" : "space",
2946 +- rawir.duration);
2947 +-
2948 +- ir_raw_event_store_with_filter(nvt->rdev, &rawir);
2949 +- }
2950 ++ ir_raw_event_store_with_filter(nvt->rdev, &rawir);
2951 +
2952 + /*
2953 + * BUF_PULSE_BIT indicates end of IR data, BUF_REPEAT_BYTE
2954 + * indicates end of IR signal, but new data incoming. In both
2955 + * cases, it means we're ready to call ir_raw_event_handle
2956 + */
2957 +- if ((sample == BUF_PULSE_BIT) && nvt->pkts) {
2958 ++ if ((sample == BUF_PULSE_BIT) && (i + 1 < nvt->pkts)) {
2959 + nvt_dbg("Calling ir_raw_event_handle (signal end)\n");
2960 + ir_raw_event_handle(nvt->rdev);
2961 + }
2962 + }
2963 +
2964 ++ nvt->pkts = 0;
2965 ++
2966 + nvt_dbg("Calling ir_raw_event_handle (buffer empty)\n");
2967 + ir_raw_event_handle(nvt->rdev);
2968 +
2969 +- if (nvt->pkts) {
2970 +- nvt_dbg("Odd, pkts should be 0 now... (its %u)", nvt->pkts);
2971 +- nvt->pkts = 0;
2972 +- }
2973 +-
2974 + nvt_dbg_verbose("%s done", __func__);
2975 + }
2976 +
2977 +@@ -1054,7 +1026,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
2978 +
2979 + spin_lock_init(&nvt->nvt_lock);
2980 + spin_lock_init(&nvt->tx.lock);
2981 +- init_ir_raw_event(&nvt->rawir);
2982 +
2983 + ret = -EBUSY;
2984 + /* now claim resources */
2985 +diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
2986 +index 1241fc8..0d5e087 100644
2987 +--- a/drivers/media/rc/nuvoton-cir.h
2988 ++++ b/drivers/media/rc/nuvoton-cir.h
2989 +@@ -67,7 +67,6 @@ static int debug;
2990 + struct nvt_dev {
2991 + struct pnp_dev *pdev;
2992 + struct rc_dev *rdev;
2993 +- struct ir_raw_event rawir;
2994 +
2995 + spinlock_t nvt_lock;
2996 +
2997 +diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
2998 +index 1717144..e67c3d3 100644
2999 +--- a/drivers/mfd/omap-usb-host.c
3000 ++++ b/drivers/mfd/omap-usb-host.c
3001 +@@ -676,7 +676,6 @@ static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count)
3002 + | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
3003 + | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
3004 +
3005 +- reg |= (1 << (i + 1));
3006 + } else
3007 + continue;
3008 +
3009 +diff --git a/drivers/mfd/tps65910-irq.c b/drivers/mfd/tps65910-irq.c
3010 +index 2bfad5c..a56be93 100644
3011 +--- a/drivers/mfd/tps65910-irq.c
3012 ++++ b/drivers/mfd/tps65910-irq.c
3013 +@@ -178,8 +178,10 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq,
3014 + switch (tps65910_chip_id(tps65910)) {
3015 + case TPS65910:
3016 + tps65910->irq_num = TPS65910_NUM_IRQ;
3017 ++ break;
3018 + case TPS65911:
3019 + tps65910->irq_num = TPS65911_NUM_IRQ;
3020 ++ break;
3021 + }
3022 +
3023 + /* Register with genirq */
3024 +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
3025 +index 7843efe..38089b2 100644
3026 +--- a/drivers/mmc/core/core.c
3027 ++++ b/drivers/mmc/core/core.c
3028 +@@ -132,7 +132,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
3029 + if (mrq->done)
3030 + mrq->done(mrq);
3031 +
3032 +- mmc_host_clk_gate(host);
3033 ++ mmc_host_clk_release(host);
3034 + }
3035 + }
3036 +
3037 +@@ -191,7 +191,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
3038 + mrq->stop->mrq = mrq;
3039 + }
3040 + }
3041 +- mmc_host_clk_ungate(host);
3042 ++ mmc_host_clk_hold(host);
3043 + led_trigger_event(host->led, LED_FULL);
3044 + host->ops->request(host, mrq);
3045 + }
3046 +@@ -634,15 +634,17 @@ static inline void mmc_set_ios(struct mmc_host *host)
3047 + */
3048 + void mmc_set_chip_select(struct mmc_host *host, int mode)
3049 + {
3050 ++ mmc_host_clk_hold(host);
3051 + host->ios.chip_select = mode;
3052 + mmc_set_ios(host);
3053 ++ mmc_host_clk_release(host);
3054 + }
3055 +
3056 + /*
3057 + * Sets the host clock to the highest possible frequency that
3058 + * is below "hz".
3059 + */
3060 +-void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3061 ++static void __mmc_set_clock(struct mmc_host *host, unsigned int hz)
3062 + {
3063 + WARN_ON(hz < host->f_min);
3064 +
3065 +@@ -653,6 +655,13 @@ void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3066 + mmc_set_ios(host);
3067 + }
3068 +
3069 ++void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3070 ++{
3071 ++ mmc_host_clk_hold(host);
3072 ++ __mmc_set_clock(host, hz);
3073 ++ mmc_host_clk_release(host);
3074 ++}
3075 ++
3076 + #ifdef CONFIG_MMC_CLKGATE
3077 + /*
3078 + * This gates the clock by setting it to 0 Hz.
3079 +@@ -685,7 +694,7 @@ void mmc_ungate_clock(struct mmc_host *host)
3080 + if (host->clk_old) {
3081 + BUG_ON(host->ios.clock);
3082 + /* This call will also set host->clk_gated to false */
3083 +- mmc_set_clock(host, host->clk_old);
3084 ++ __mmc_set_clock(host, host->clk_old);
3085 + }
3086 + }
3087 +
3088 +@@ -713,8 +722,10 @@ void mmc_set_ungated(struct mmc_host *host)
3089 + */
3090 + void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
3091 + {
3092 ++ mmc_host_clk_hold(host);
3093 + host->ios.bus_mode = mode;
3094 + mmc_set_ios(host);
3095 ++ mmc_host_clk_release(host);
3096 + }
3097 +
3098 + /*
3099 +@@ -722,8 +733,10 @@ void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
3100 + */
3101 + void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
3102 + {
3103 ++ mmc_host_clk_hold(host);
3104 + host->ios.bus_width = width;
3105 + mmc_set_ios(host);
3106 ++ mmc_host_clk_release(host);
3107 + }
3108 +
3109 + /**
3110 +@@ -921,8 +934,10 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
3111 +
3112 + ocr &= 3 << bit;
3113 +
3114 ++ mmc_host_clk_hold(host);
3115 + host->ios.vdd = bit;
3116 + mmc_set_ios(host);
3117 ++ mmc_host_clk_release(host);
3118 + } else {
3119 + pr_warning("%s: host doesn't support card's voltages\n",
3120 + mmc_hostname(host));
3121 +@@ -969,8 +984,10 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11
3122 + */
3123 + void mmc_set_timing(struct mmc_host *host, unsigned int timing)
3124 + {
3125 ++ mmc_host_clk_hold(host);
3126 + host->ios.timing = timing;
3127 + mmc_set_ios(host);
3128 ++ mmc_host_clk_release(host);
3129 + }
3130 +
3131 + /*
3132 +@@ -978,8 +995,10 @@ void mmc_set_timing(struct mmc_host *host, unsigned int timing)
3133 + */
3134 + void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)
3135 + {
3136 ++ mmc_host_clk_hold(host);
3137 + host->ios.drv_type = drv_type;
3138 + mmc_set_ios(host);
3139 ++ mmc_host_clk_release(host);
3140 + }
3141 +
3142 + /*
3143 +@@ -997,6 +1016,8 @@ static void mmc_power_up(struct mmc_host *host)
3144 + {
3145 + int bit;
3146 +
3147 ++ mmc_host_clk_hold(host);
3148 ++
3149 + /* If ocr is set, we use it */
3150 + if (host->ocr)
3151 + bit = ffs(host->ocr) - 1;
3152 +@@ -1032,10 +1053,14 @@ static void mmc_power_up(struct mmc_host *host)
3153 + * time required to reach a stable voltage.
3154 + */
3155 + mmc_delay(10);
3156 ++
3157 ++ mmc_host_clk_release(host);
3158 + }
3159 +
3160 + static void mmc_power_off(struct mmc_host *host)
3161 + {
3162 ++ mmc_host_clk_hold(host);
3163 ++
3164 + host->ios.clock = 0;
3165 + host->ios.vdd = 0;
3166 +
3167 +@@ -1053,6 +1078,8 @@ static void mmc_power_off(struct mmc_host *host)
3168 + host->ios.bus_width = MMC_BUS_WIDTH_1;
3169 + host->ios.timing = MMC_TIMING_LEGACY;
3170 + mmc_set_ios(host);
3171 ++
3172 ++ mmc_host_clk_release(host);
3173 + }
3174 +
3175 + /*
3176 +diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
3177 +index b29d3e8..793d0a0 100644
3178 +--- a/drivers/mmc/core/host.c
3179 ++++ b/drivers/mmc/core/host.c
3180 +@@ -119,14 +119,14 @@ static void mmc_host_clk_gate_work(struct work_struct *work)
3181 + }
3182 +
3183 + /**
3184 +- * mmc_host_clk_ungate - ungate hardware MCI clocks
3185 ++ * mmc_host_clk_hold - ungate hardware MCI clocks
3186 + * @host: host to ungate.
3187 + *
3188 + * Makes sure the host ios.clock is restored to a non-zero value
3189 + * past this call. Increase clock reference count and ungate clock
3190 + * if we're the first user.
3191 + */
3192 +-void mmc_host_clk_ungate(struct mmc_host *host)
3193 ++void mmc_host_clk_hold(struct mmc_host *host)
3194 + {
3195 + unsigned long flags;
3196 +
3197 +@@ -164,14 +164,14 @@ static bool mmc_host_may_gate_card(struct mmc_card *card)
3198 + }
3199 +
3200 + /**
3201 +- * mmc_host_clk_gate - gate off hardware MCI clocks
3202 ++ * mmc_host_clk_release - gate off hardware MCI clocks
3203 + * @host: host to gate.
3204 + *
3205 + * Calls the host driver with ios.clock set to zero as often as possible
3206 + * in order to gate off hardware MCI clocks. Decrease clock reference
3207 + * count and schedule disabling of clock.
3208 + */
3209 +-void mmc_host_clk_gate(struct mmc_host *host)
3210 ++void mmc_host_clk_release(struct mmc_host *host)
3211 + {
3212 + unsigned long flags;
3213 +
3214 +@@ -179,7 +179,7 @@ void mmc_host_clk_gate(struct mmc_host *host)
3215 + host->clk_requests--;
3216 + if (mmc_host_may_gate_card(host->card) &&
3217 + !host->clk_requests)
3218 +- schedule_work(&host->clk_gate_work);
3219 ++ queue_work(system_nrt_wq, &host->clk_gate_work);
3220 + spin_unlock_irqrestore(&host->clk_lock, flags);
3221 + }
3222 +
3223 +@@ -231,7 +231,7 @@ static inline void mmc_host_clk_exit(struct mmc_host *host)
3224 + if (cancel_work_sync(&host->clk_gate_work))
3225 + mmc_host_clk_gate_delayed(host);
3226 + if (host->clk_gated)
3227 +- mmc_host_clk_ungate(host);
3228 ++ mmc_host_clk_hold(host);
3229 + /* There should be only one user now */
3230 + WARN_ON(host->clk_requests > 1);
3231 + }
3232 +diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h
3233 +index de199f9..fb8a5cd 100644
3234 +--- a/drivers/mmc/core/host.h
3235 ++++ b/drivers/mmc/core/host.h
3236 +@@ -16,16 +16,16 @@ int mmc_register_host_class(void);
3237 + void mmc_unregister_host_class(void);
3238 +
3239 + #ifdef CONFIG_MMC_CLKGATE
3240 +-void mmc_host_clk_ungate(struct mmc_host *host);
3241 +-void mmc_host_clk_gate(struct mmc_host *host);
3242 ++void mmc_host_clk_hold(struct mmc_host *host);
3243 ++void mmc_host_clk_release(struct mmc_host *host);
3244 + unsigned int mmc_host_clk_rate(struct mmc_host *host);
3245 +
3246 + #else
3247 +-static inline void mmc_host_clk_ungate(struct mmc_host *host)
3248 ++static inline void mmc_host_clk_hold(struct mmc_host *host)
3249 + {
3250 + }
3251 +
3252 +-static inline void mmc_host_clk_gate(struct mmc_host *host)
3253 ++static inline void mmc_host_clk_release(struct mmc_host *host)
3254 + {
3255 + }
3256 +
3257 +diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
3258 +index 69e3ee3..8cd999f 100644
3259 +--- a/drivers/mmc/host/sdhci-s3c.c
3260 ++++ b/drivers/mmc/host/sdhci-s3c.c
3261 +@@ -301,6 +301,8 @@ static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width)
3262 + ctrl &= ~SDHCI_CTRL_8BITBUS;
3263 + break;
3264 + default:
3265 ++ ctrl &= ~SDHCI_CTRL_4BITBUS;
3266 ++ ctrl &= ~SDHCI_CTRL_8BITBUS;
3267 + break;
3268 + }
3269 +
3270 +diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
3271 +index 57d3293..74580bb 100644
3272 +--- a/drivers/net/bnx2.c
3273 ++++ b/drivers/net/bnx2.c
3274 +@@ -416,6 +416,9 @@ struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)
3275 + struct bnx2 *bp = netdev_priv(dev);
3276 + struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
3277 +
3278 ++ if (!cp->max_iscsi_conn)
3279 ++ return NULL;
3280 ++
3281 + cp->drv_owner = THIS_MODULE;
3282 + cp->chip_id = bp->chip_id;
3283 + cp->pdev = bp->pdev;
3284 +@@ -8177,6 +8180,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
3285 + bp->timer.data = (unsigned long) bp;
3286 + bp->timer.function = bnx2_timer;
3287 +
3288 ++#ifdef BCM_CNIC
3289 ++ bp->cnic_eth_dev.max_iscsi_conn =
3290 ++ bnx2_reg_rd_ind(bp, BNX2_FW_MAX_ISCSI_CONN);
3291 ++#endif
3292 + pci_save_state(pdev);
3293 +
3294 + return 0;
3295 +diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c
3296 +index 410a49e..d11af7c 100644
3297 +--- a/drivers/net/bnx2x/bnx2x_dcb.c
3298 ++++ b/drivers/net/bnx2x/bnx2x_dcb.c
3299 +@@ -1858,6 +1858,7 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
3300 + break;
3301 + case DCB_CAP_ATTR_DCBX:
3302 + *cap = BNX2X_DCBX_CAPS;
3303 ++ break;
3304 + default:
3305 + rval = -EINVAL;
3306 + break;
3307 +diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
3308 +index 74be989..04976db 100644
3309 +--- a/drivers/net/bnx2x/bnx2x_main.c
3310 ++++ b/drivers/net/bnx2x/bnx2x_main.c
3311 +@@ -4138,7 +4138,7 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3312 + int igu_seg_id;
3313 + int port = BP_PORT(bp);
3314 + int func = BP_FUNC(bp);
3315 +- int reg_offset;
3316 ++ int reg_offset, reg_offset_en5;
3317 + u64 section;
3318 + int index;
3319 + struct hc_sp_status_block_data sp_sb_data;
3320 +@@ -4161,6 +4161,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3321 +
3322 + reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
3323 + MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
3324 ++ reg_offset_en5 = (port ? MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 :
3325 ++ MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0);
3326 + for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) {
3327 + int sindex;
3328 + /* take care of sig[0]..sig[4] */
3329 +@@ -4175,7 +4177,7 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3330 + * and not 16 between the different groups
3331 + */
3332 + bp->attn_group[index].sig[4] = REG_RD(bp,
3333 +- reg_offset + 0x10 + 0x4*index);
3334 ++ reg_offset_en5 + 0x4*index);
3335 + else
3336 + bp->attn_group[index].sig[4] = 0;
3337 + }
3338 +diff --git a/drivers/net/bnx2x/bnx2x_reg.h b/drivers/net/bnx2x/bnx2x_reg.h
3339 +index 86bba25..0380b3a 100644
3340 +--- a/drivers/net/bnx2x/bnx2x_reg.h
3341 ++++ b/drivers/net/bnx2x/bnx2x_reg.h
3342 +@@ -1325,6 +1325,18 @@
3343 + Latched ump_tx_parity; [31] MCP Latched scpad_parity; */
3344 + #define MISC_REG_AEU_ENABLE4_PXP_0 0xa108
3345 + #define MISC_REG_AEU_ENABLE4_PXP_1 0xa1a8
3346 ++/* [RW 32] fifth 32b for enabling the output for function 0 output0. Mapped
3347 ++ * as follows: [0] PGLUE config_space; [1] PGLUE misc_flr; [2] PGLUE B RBC
3348 ++ * attention [3] PGLUE B RBC parity; [4] ATC attention; [5] ATC parity; [6]
3349 ++ * mstat0 attention; [7] mstat0 parity; [8] mstat1 attention; [9] mstat1
3350 ++ * parity; [31-10] Reserved; */
3351 ++#define MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0 0xa688
3352 ++/* [RW 32] Fifth 32b for enabling the output for function 1 output0. Mapped
3353 ++ * as follows: [0] PGLUE config_space; [1] PGLUE misc_flr; [2] PGLUE B RBC
3354 ++ * attention [3] PGLUE B RBC parity; [4] ATC attention; [5] ATC parity; [6]
3355 ++ * mstat0 attention; [7] mstat0 parity; [8] mstat1 attention; [9] mstat1
3356 ++ * parity; [31-10] Reserved; */
3357 ++#define MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 0xa6b0
3358 + /* [RW 1] set/clr general attention 0; this will set/clr bit 94 in the aeu
3359 + 128 bit vector */
3360 + #define MISC_REG_AEU_GENERAL_ATTN_0 0xa000
3361 +diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
3362 +index 11a92af..363c7f3 100644
3363 +--- a/drivers/net/cnic.c
3364 ++++ b/drivers/net/cnic.c
3365 +@@ -605,11 +605,12 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
3366 + }
3367 + EXPORT_SYMBOL(cnic_unregister_driver);
3368 +
3369 +-static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id)
3370 ++static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id,
3371 ++ u32 next)
3372 + {
3373 + id_tbl->start = start_id;
3374 + id_tbl->max = size;
3375 +- id_tbl->next = 0;
3376 ++ id_tbl->next = next;
3377 + spin_lock_init(&id_tbl->lock);
3378 + id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
3379 + if (!id_tbl->table)
3380 +@@ -2778,13 +2779,10 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)
3381 +
3382 + /* Tell compiler that status_blk fields can change. */
3383 + barrier();
3384 +- if (status_idx != *cp->kcq1.status_idx_ptr) {
3385 +- status_idx = (u16) *cp->kcq1.status_idx_ptr;
3386 +- /* status block index must be read first */
3387 +- rmb();
3388 +- cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
3389 +- } else
3390 +- break;
3391 ++ status_idx = (u16) *cp->kcq1.status_idx_ptr;
3392 ++ /* status block index must be read first */
3393 ++ rmb();
3394 ++ cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
3395 + }
3396 +
3397 + CNIC_WR16(dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);
3398 +@@ -2908,8 +2906,6 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info)
3399 +
3400 + /* Tell compiler that sblk fields can change. */
3401 + barrier();
3402 +- if (last_status == *info->status_idx_ptr)
3403 +- break;
3404 +
3405 + last_status = *info->status_idx_ptr;
3406 + /* status block index must be read before reading the KCQ */
3407 +@@ -3772,7 +3768,13 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
3408 + break;
3409 +
3410 + case L4_KCQE_OPCODE_VALUE_CLOSE_RECEIVED:
3411 +- cnic_cm_upcall(cp, csk, opcode);
3412 ++ /* after we already sent CLOSE_REQ */
3413 ++ if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags) &&
3414 ++ !test_bit(SK_F_OFFLD_COMPLETE, &csk->flags) &&
3415 ++ csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)
3416 ++ cp->close_conn(csk, L4_KCQE_OPCODE_VALUE_RESET_COMP);
3417 ++ else
3418 ++ cnic_cm_upcall(cp, csk, opcode);
3419 + break;
3420 + }
3421 + csk_put(csk);
3422 +@@ -3803,14 +3805,17 @@ static void cnic_cm_free_mem(struct cnic_dev *dev)
3423 + static int cnic_cm_alloc_mem(struct cnic_dev *dev)
3424 + {
3425 + struct cnic_local *cp = dev->cnic_priv;
3426 ++ u32 port_id;
3427 +
3428 + cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ,
3429 + GFP_KERNEL);
3430 + if (!cp->csk_tbl)
3431 + return -ENOMEM;
3432 +
3433 ++ get_random_bytes(&port_id, sizeof(port_id));
3434 ++ port_id %= CNIC_LOCAL_PORT_RANGE;
3435 + if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
3436 +- CNIC_LOCAL_PORT_MIN)) {
3437 ++ CNIC_LOCAL_PORT_MIN, port_id)) {
3438 + cnic_cm_free_mem(dev);
3439 + return -ENOMEM;
3440 + }
3441 +@@ -3826,12 +3831,14 @@ static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode)
3442 + }
3443 +
3444 + /* 1. If event opcode matches the expected event in csk->state
3445 +- * 2. If the expected event is CLOSE_COMP, we accept any event
3446 ++ * 2. If the expected event is CLOSE_COMP or RESET_COMP, we accept any
3447 ++ * event
3448 + * 3. If the expected event is 0, meaning the connection was never
3449 + * never established, we accept the opcode from cm_abort.
3450 + */
3451 + if (opcode == csk->state || csk->state == 0 ||
3452 +- csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
3453 ++ csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP ||
3454 ++ csk->state == L4_KCQE_OPCODE_VALUE_RESET_COMP) {
3455 + if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) {
3456 + if (csk->state == 0)
3457 + csk->state = opcode;
3458 +@@ -4218,14 +4225,6 @@ static void cnic_enable_bnx2_int(struct cnic_dev *dev)
3459 + BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx);
3460 + }
3461 +
3462 +-static void cnic_get_bnx2_iscsi_info(struct cnic_dev *dev)
3463 +-{
3464 +- u32 max_conn;
3465 +-
3466 +- max_conn = cnic_reg_rd_ind(dev, BNX2_FW_MAX_ISCSI_CONN);
3467 +- dev->max_iscsi_conn = max_conn;
3468 +-}
3469 +-
3470 + static void cnic_disable_bnx2_int_sync(struct cnic_dev *dev)
3471 + {
3472 + struct cnic_local *cp = dev->cnic_priv;
3473 +@@ -4550,8 +4549,6 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)
3474 + return err;
3475 + }
3476 +
3477 +- cnic_get_bnx2_iscsi_info(dev);
3478 +-
3479 + return 0;
3480 + }
3481 +
3482 +@@ -4826,7 +4823,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)
3483 + pfid = cp->pfid;
3484 +
3485 + ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ,
3486 +- cp->iscsi_start_cid);
3487 ++ cp->iscsi_start_cid, 0);
3488 +
3489 + if (ret)
3490 + return -ENOMEM;
3491 +@@ -4834,7 +4831,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)
3492 + if (BNX2X_CHIP_IS_E2(cp->chip_id)) {
3493 + ret = cnic_init_id_tbl(&cp->fcoe_cid_tbl,
3494 + BNX2X_FCOE_NUM_CONNECTIONS,
3495 +- cp->fcoe_start_cid);
3496 ++ cp->fcoe_start_cid, 0);
3497 +
3498 + if (ret)
3499 + return -ENOMEM;
3500 +@@ -5217,6 +5214,8 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev)
3501 + cdev->pcidev = pdev;
3502 + cp->chip_id = ethdev->chip_id;
3503 +
3504 ++ cdev->max_iscsi_conn = ethdev->max_iscsi_conn;
3505 ++
3506 + cp->cnic_ops = &cnic_bnx2_ops;
3507 + cp->start_hw = cnic_start_bnx2_hw;
3508 + cp->stop_hw = cnic_stop_bnx2_hw;
3509 +@@ -5335,7 +5334,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
3510 +
3511 + dev = cnic_from_netdev(netdev);
3512 +
3513 +- if (!dev && (event == NETDEV_REGISTER || event == NETDEV_UP)) {
3514 ++ if (!dev && (event == NETDEV_REGISTER || netif_running(netdev))) {
3515 + /* Check for the hot-plug device */
3516 + dev = is_cnic_dev(netdev);
3517 + if (dev) {
3518 +@@ -5351,7 +5350,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
3519 + else if (event == NETDEV_UNREGISTER)
3520 + cnic_ulp_exit(dev);
3521 +
3522 +- if (event == NETDEV_UP) {
3523 ++ if (event == NETDEV_UP || (new_dev && netif_running(netdev))) {
3524 + if (cnic_register_netdev(dev) != 0) {
3525 + cnic_put(dev);
3526 + goto done;
3527 +diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
3528 +index 862804f..3f2e12c 100644
3529 +--- a/drivers/net/cxgb3/cxgb3_offload.c
3530 ++++ b/drivers/net/cxgb3/cxgb3_offload.c
3531 +@@ -1149,12 +1149,14 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
3532 + if (te && te->ctx && te->client && te->client->redirect) {
3533 + update_tcb = te->client->redirect(te->ctx, old, new, e);
3534 + if (update_tcb) {
3535 ++ rcu_read_lock();
3536 + l2t_hold(L2DATA(tdev), e);
3537 ++ rcu_read_unlock();
3538 + set_l2t_ix(tdev, tid, e);
3539 + }
3540 + }
3541 + }
3542 +- l2t_release(L2DATA(tdev), e);
3543 ++ l2t_release(tdev, e);
3544 + }
3545 +
3546 + /*
3547 +@@ -1267,7 +1269,7 @@ int cxgb3_offload_activate(struct adapter *adapter)
3548 + goto out_free;
3549 +
3550 + err = -ENOMEM;
3551 +- L2DATA(dev) = t3_init_l2t(l2t_capacity);
3552 ++ RCU_INIT_POINTER(dev->l2opt, t3_init_l2t(l2t_capacity));
3553 + if (!L2DATA(dev))
3554 + goto out_free;
3555 +
3556 +@@ -1301,16 +1303,24 @@ int cxgb3_offload_activate(struct adapter *adapter)
3557 +
3558 + out_free_l2t:
3559 + t3_free_l2t(L2DATA(dev));
3560 +- L2DATA(dev) = NULL;
3561 ++ rcu_assign_pointer(dev->l2opt, NULL);
3562 + out_free:
3563 + kfree(t);
3564 + return err;
3565 + }
3566 +
3567 ++static void clean_l2_data(struct rcu_head *head)
3568 ++{
3569 ++ struct l2t_data *d = container_of(head, struct l2t_data, rcu_head);
3570 ++ t3_free_l2t(d);
3571 ++}
3572 ++
3573 ++
3574 + void cxgb3_offload_deactivate(struct adapter *adapter)
3575 + {
3576 + struct t3cdev *tdev = &adapter->tdev;
3577 + struct t3c_data *t = T3C_DATA(tdev);
3578 ++ struct l2t_data *d;
3579 +
3580 + remove_adapter(adapter);
3581 + if (list_empty(&adapter_list))
3582 +@@ -1318,8 +1328,11 @@ void cxgb3_offload_deactivate(struct adapter *adapter)
3583 +
3584 + free_tid_maps(&t->tid_maps);
3585 + T3C_DATA(tdev) = NULL;
3586 +- t3_free_l2t(L2DATA(tdev));
3587 +- L2DATA(tdev) = NULL;
3588 ++ rcu_read_lock();
3589 ++ d = L2DATA(tdev);
3590 ++ rcu_read_unlock();
3591 ++ rcu_assign_pointer(tdev->l2opt, NULL);
3592 ++ call_rcu(&d->rcu_head, clean_l2_data);
3593 + if (t->nofail_skb)
3594 + kfree_skb(t->nofail_skb);
3595 + kfree(t);
3596 +diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
3597 +index f452c40..4154097 100644
3598 +--- a/drivers/net/cxgb3/l2t.c
3599 ++++ b/drivers/net/cxgb3/l2t.c
3600 +@@ -300,14 +300,21 @@ static inline void reuse_entry(struct l2t_entry *e, struct neighbour *neigh)
3601 + struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
3602 + struct net_device *dev)
3603 + {
3604 +- struct l2t_entry *e;
3605 +- struct l2t_data *d = L2DATA(cdev);
3606 ++ struct l2t_entry *e = NULL;
3607 ++ struct l2t_data *d;
3608 ++ int hash;
3609 + u32 addr = *(u32 *) neigh->primary_key;
3610 + int ifidx = neigh->dev->ifindex;
3611 +- int hash = arp_hash(addr, ifidx, d);
3612 + struct port_info *p = netdev_priv(dev);
3613 + int smt_idx = p->port_id;
3614 +
3615 ++ rcu_read_lock();
3616 ++ d = L2DATA(cdev);
3617 ++ if (!d)
3618 ++ goto done_rcu;
3619 ++
3620 ++ hash = arp_hash(addr, ifidx, d);
3621 ++
3622 + write_lock_bh(&d->lock);
3623 + for (e = d->l2tab[hash].first; e; e = e->next)
3624 + if (e->addr == addr && e->ifindex == ifidx &&
3625 +@@ -338,6 +345,8 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
3626 + }
3627 + done:
3628 + write_unlock_bh(&d->lock);
3629 ++done_rcu:
3630 ++ rcu_read_unlock();
3631 + return e;
3632 + }
3633 +
3634 +diff --git a/drivers/net/cxgb3/l2t.h b/drivers/net/cxgb3/l2t.h
3635 +index fd3eb07..c4dd066 100644
3636 +--- a/drivers/net/cxgb3/l2t.h
3637 ++++ b/drivers/net/cxgb3/l2t.h
3638 +@@ -76,6 +76,7 @@ struct l2t_data {
3639 + atomic_t nfree; /* number of free entries */
3640 + rwlock_t lock;
3641 + struct l2t_entry l2tab[0];
3642 ++ struct rcu_head rcu_head; /* to handle rcu cleanup */
3643 + };
3644 +
3645 + typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
3646 +@@ -99,7 +100,7 @@ static inline void set_arp_failure_handler(struct sk_buff *skb,
3647 + /*
3648 + * Getting to the L2 data from an offload device.
3649 + */
3650 +-#define L2DATA(dev) ((dev)->l2opt)
3651 ++#define L2DATA(cdev) (rcu_dereference((cdev)->l2opt))
3652 +
3653 + #define W_TCB_L2T_IX 0
3654 + #define S_TCB_L2T_IX 7
3655 +@@ -126,15 +127,22 @@ static inline int l2t_send(struct t3cdev *dev, struct sk_buff *skb,
3656 + return t3_l2t_send_slow(dev, skb, e);
3657 + }
3658 +
3659 +-static inline void l2t_release(struct l2t_data *d, struct l2t_entry *e)
3660 ++static inline void l2t_release(struct t3cdev *t, struct l2t_entry *e)
3661 + {
3662 +- if (atomic_dec_and_test(&e->refcnt))
3663 ++ struct l2t_data *d;
3664 ++
3665 ++ rcu_read_lock();
3666 ++ d = L2DATA(t);
3667 ++
3668 ++ if (atomic_dec_and_test(&e->refcnt) && d)
3669 + t3_l2e_free(d, e);
3670 ++
3671 ++ rcu_read_unlock();
3672 + }
3673 +
3674 + static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e)
3675 + {
3676 +- if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
3677 ++ if (d && atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
3678 + atomic_dec(&d->nfree);
3679 + }
3680 +
3681 +diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
3682 +index 7501d97..f17aaa1 100644
3683 +--- a/drivers/net/e1000/e1000_hw.c
3684 ++++ b/drivers/net/e1000/e1000_hw.c
3685 +@@ -4028,6 +4028,12 @@ s32 e1000_validate_eeprom_checksum(struct e1000_hw *hw)
3686 + checksum += eeprom_data;
3687 + }
3688 +
3689 ++#ifdef CONFIG_PARISC
3690 ++ /* This is a signature and not a checksum on HP c8000 */
3691 ++ if ((hw->subsystem_vendor_id == 0x103C) && (eeprom_data == 0x16d6))
3692 ++ return E1000_SUCCESS;
3693 ++
3694 ++#endif
3695 + if (checksum == (u16) EEPROM_SUM)
3696 + return E1000_SUCCESS;
3697 + else {
3698 +diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
3699 +index b388d78..145c924 100644
3700 +--- a/drivers/net/ibmveth.c
3701 ++++ b/drivers/net/ibmveth.c
3702 +@@ -394,7 +394,7 @@ static inline struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *ada
3703 + }
3704 +
3705 + /* recycle the current buffer on the rx queue */
3706 +-static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3707 ++static int ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3708 + {
3709 + u32 q_index = adapter->rx_queue.index;
3710 + u64 correlator = adapter->rx_queue.queue_addr[q_index].correlator;
3711 +@@ -402,6 +402,7 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3712 + unsigned int index = correlator & 0xffffffffUL;
3713 + union ibmveth_buf_desc desc;
3714 + unsigned long lpar_rc;
3715 ++ int ret = 1;
3716 +
3717 + BUG_ON(pool >= IBMVETH_NUM_BUFF_POOLS);
3718 + BUG_ON(index >= adapter->rx_buff_pool[pool].size);
3719 +@@ -409,7 +410,7 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3720 + if (!adapter->rx_buff_pool[pool].active) {
3721 + ibmveth_rxq_harvest_buffer(adapter);
3722 + ibmveth_free_buffer_pool(adapter, &adapter->rx_buff_pool[pool]);
3723 +- return;
3724 ++ goto out;
3725 + }
3726 +
3727 + desc.fields.flags_len = IBMVETH_BUF_VALID |
3728 +@@ -422,12 +423,16 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3729 + netdev_dbg(adapter->netdev, "h_add_logical_lan_buffer failed "
3730 + "during recycle rc=%ld", lpar_rc);
3731 + ibmveth_remove_buffer_from_pool(adapter, adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator);
3732 ++ ret = 0;
3733 + }
3734 +
3735 + if (++adapter->rx_queue.index == adapter->rx_queue.num_slots) {
3736 + adapter->rx_queue.index = 0;
3737 + adapter->rx_queue.toggle = !adapter->rx_queue.toggle;
3738 + }
3739 ++
3740 ++out:
3741 ++ return ret;
3742 + }
3743 +
3744 + static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter)
3745 +@@ -806,7 +811,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
3746 + } else
3747 + adapter->fw_ipv6_csum_support = data;
3748 +
3749 +- if (ret != H_SUCCESS || ret6 != H_SUCCESS)
3750 ++ if (ret == H_SUCCESS || ret6 == H_SUCCESS)
3751 + adapter->rx_csum = data;
3752 + else
3753 + rc1 = -EIO;
3754 +@@ -924,6 +929,7 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
3755 + union ibmveth_buf_desc descs[6];
3756 + int last, i;
3757 + int force_bounce = 0;
3758 ++ dma_addr_t dma_addr;
3759 +
3760 + /*
3761 + * veth handles a maximum of 6 segments including the header, so
3762 +@@ -988,17 +994,16 @@ retry_bounce:
3763 + }
3764 +
3765 + /* Map the header */
3766 +- descs[0].fields.address = dma_map_single(&adapter->vdev->dev, skb->data,
3767 +- skb_headlen(skb),
3768 +- DMA_TO_DEVICE);
3769 +- if (dma_mapping_error(&adapter->vdev->dev, descs[0].fields.address))
3770 ++ dma_addr = dma_map_single(&adapter->vdev->dev, skb->data,
3771 ++ skb_headlen(skb), DMA_TO_DEVICE);
3772 ++ if (dma_mapping_error(&adapter->vdev->dev, dma_addr))
3773 + goto map_failed;
3774 +
3775 + descs[0].fields.flags_len = desc_flags | skb_headlen(skb);
3776 ++ descs[0].fields.address = dma_addr;
3777 +
3778 + /* Map the frags */
3779 + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
3780 +- unsigned long dma_addr;
3781 + skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3782 +
3783 + dma_addr = dma_map_page(&adapter->vdev->dev, frag->page,
3784 +@@ -1020,7 +1025,12 @@ retry_bounce:
3785 + netdev->stats.tx_bytes += skb->len;
3786 + }
3787 +
3788 +- for (i = 0; i < skb_shinfo(skb)->nr_frags + 1; i++)
3789 ++ dma_unmap_single(&adapter->vdev->dev,
3790 ++ descs[0].fields.address,
3791 ++ descs[0].fields.flags_len & IBMVETH_BUF_LEN_MASK,
3792 ++ DMA_TO_DEVICE);
3793 ++
3794 ++ for (i = 1; i < skb_shinfo(skb)->nr_frags + 1; i++)
3795 + dma_unmap_page(&adapter->vdev->dev, descs[i].fields.address,
3796 + descs[i].fields.flags_len & IBMVETH_BUF_LEN_MASK,
3797 + DMA_TO_DEVICE);
3798 +@@ -1083,8 +1093,9 @@ restart_poll:
3799 + if (rx_flush)
3800 + ibmveth_flush_buffer(skb->data,
3801 + length + offset);
3802 ++ if (!ibmveth_rxq_recycle_buffer(adapter))
3803 ++ kfree_skb(skb);
3804 + skb = new_skb;
3805 +- ibmveth_rxq_recycle_buffer(adapter);
3806 + } else {
3807 + ibmveth_rxq_harvest_buffer(adapter);
3808 + skb_reserve(skb, offset);
3809 +diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
3810 +index 2c28621..97f46ac 100644
3811 +--- a/drivers/net/igb/igb_main.c
3812 ++++ b/drivers/net/igb/igb_main.c
3813 +@@ -1985,7 +1985,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
3814 +
3815 + if (hw->bus.func == 0)
3816 + hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
3817 +- else if (hw->mac.type == e1000_82580)
3818 ++ else if (hw->mac.type >= e1000_82580)
3819 + hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
3820 + NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
3821 + &eeprom_data);
3822 +diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
3823 +index 8800e1f..6a4826a 100644
3824 +--- a/drivers/net/irda/smsc-ircc2.c
3825 ++++ b/drivers/net/irda/smsc-ircc2.c
3826 +@@ -515,7 +515,7 @@ static const struct net_device_ops smsc_ircc_netdev_ops = {
3827 + * Try to open driver instance
3828 + *
3829 + */
3830 +-static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
3831 ++static int __devinit smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
3832 + {
3833 + struct smsc_ircc_cb *self;
3834 + struct net_device *dev;
3835 +diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
3836 +index 08e8e25..83f197d 100644
3837 +--- a/drivers/net/ixgbe/ixgbe_main.c
3838 ++++ b/drivers/net/ixgbe/ixgbe_main.c
3839 +@@ -1366,8 +1366,8 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
3840 + if (ring_is_rsc_enabled(rx_ring))
3841 + pkt_is_rsc = ixgbe_get_rsc_state(rx_desc);
3842 +
3843 +- /* if this is a skb from previous receive DMA will be 0 */
3844 +- if (rx_buffer_info->dma) {
3845 ++ /* linear means we are building an skb from multiple pages */
3846 ++ if (!skb_is_nonlinear(skb)) {
3847 + u16 hlen;
3848 + if (pkt_is_rsc &&
3849 + !(staterr & IXGBE_RXD_STAT_EOP) &&
3850 +diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
3851 +index 5d3436d..ca4694e 100644
3852 +--- a/drivers/net/rionet.c
3853 ++++ b/drivers/net/rionet.c
3854 +@@ -80,13 +80,13 @@ static int rionet_capable = 1;
3855 + */
3856 + static struct rio_dev **rionet_active;
3857 +
3858 +-#define is_rionet_capable(pef, src_ops, dst_ops) \
3859 +- ((pef & RIO_PEF_INB_MBOX) && \
3860 +- (pef & RIO_PEF_INB_DOORBELL) && \
3861 ++#define is_rionet_capable(src_ops, dst_ops) \
3862 ++ ((src_ops & RIO_SRC_OPS_DATA_MSG) && \
3863 ++ (dst_ops & RIO_DST_OPS_DATA_MSG) && \
3864 + (src_ops & RIO_SRC_OPS_DOORBELL) && \
3865 + (dst_ops & RIO_DST_OPS_DOORBELL))
3866 + #define dev_rionet_capable(dev) \
3867 +- is_rionet_capable(dev->pef, dev->src_ops, dev->dst_ops)
3868 ++ is_rionet_capable(dev->src_ops, dev->dst_ops)
3869 +
3870 + #define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)
3871 + #define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))
3872 +@@ -282,7 +282,6 @@ static int rionet_open(struct net_device *ndev)
3873 + {
3874 + int i, rc = 0;
3875 + struct rionet_peer *peer, *tmp;
3876 +- u32 pwdcsr;
3877 + struct rionet_private *rnet = netdev_priv(ndev);
3878 +
3879 + if (netif_msg_ifup(rnet))
3880 +@@ -332,13 +331,8 @@ static int rionet_open(struct net_device *ndev)
3881 + continue;
3882 + }
3883 +
3884 +- /*
3885 +- * If device has initialized inbound doorbells,
3886 +- * send a join message
3887 +- */
3888 +- rio_read_config_32(peer->rdev, RIO_WRITE_PORT_CSR, &pwdcsr);
3889 +- if (pwdcsr & RIO_DOORBELL_AVAIL)
3890 +- rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
3891 ++ /* Send a join message */
3892 ++ rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
3893 + }
3894 +
3895 + out:
3896 +@@ -492,7 +486,7 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
3897 + static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
3898 + {
3899 + int rc = -ENODEV;
3900 +- u32 lpef, lsrc_ops, ldst_ops;
3901 ++ u32 lsrc_ops, ldst_ops;
3902 + struct rionet_peer *peer;
3903 + struct net_device *ndev = NULL;
3904 +
3905 +@@ -515,12 +509,11 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
3906 + * on later probes
3907 + */
3908 + if (!rionet_check) {
3909 +- rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
3910 + rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,
3911 + &lsrc_ops);
3912 + rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR,
3913 + &ldst_ops);
3914 +- if (!is_rionet_capable(lpef, lsrc_ops, ldst_ops)) {
3915 ++ if (!is_rionet_capable(lsrc_ops, ldst_ops)) {
3916 + printk(KERN_ERR
3917 + "%s: local device is not network capable\n",
3918 + DRV_NAME);
3919 +diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
3920 +index c914729..7d1651b 100644
3921 +--- a/drivers/net/sfc/efx.c
3922 ++++ b/drivers/net/sfc/efx.c
3923 +@@ -1051,7 +1051,6 @@ static int efx_init_io(struct efx_nic *efx)
3924 + {
3925 + struct pci_dev *pci_dev = efx->pci_dev;
3926 + dma_addr_t dma_mask = efx->type->max_dma_mask;
3927 +- bool use_wc;
3928 + int rc;
3929 +
3930 + netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n");
3931 +@@ -1102,21 +1101,8 @@ static int efx_init_io(struct efx_nic *efx)
3932 + rc = -EIO;
3933 + goto fail3;
3934 + }
3935 +-
3936 +- /* bug22643: If SR-IOV is enabled then tx push over a write combined
3937 +- * mapping is unsafe. We need to disable write combining in this case.
3938 +- * MSI is unsupported when SR-IOV is enabled, and the firmware will
3939 +- * have removed the MSI capability. So write combining is safe if
3940 +- * there is an MSI capability.
3941 +- */
3942 +- use_wc = (!EFX_WORKAROUND_22643(efx) ||
3943 +- pci_find_capability(pci_dev, PCI_CAP_ID_MSI));
3944 +- if (use_wc)
3945 +- efx->membase = ioremap_wc(efx->membase_phys,
3946 +- efx->type->mem_map_size);
3947 +- else
3948 +- efx->membase = ioremap_nocache(efx->membase_phys,
3949 +- efx->type->mem_map_size);
3950 ++ efx->membase = ioremap_nocache(efx->membase_phys,
3951 ++ efx->type->mem_map_size);
3952 + if (!efx->membase) {
3953 + netif_err(efx, probe, efx->net_dev,
3954 + "could not map memory BAR at %llx+%x\n",
3955 +diff --git a/drivers/net/sfc/io.h b/drivers/net/sfc/io.h
3956 +index cc97880..dc45110 100644
3957 +--- a/drivers/net/sfc/io.h
3958 ++++ b/drivers/net/sfc/io.h
3959 +@@ -48,9 +48,9 @@
3960 + * replacing the low 96 bits with zero does not affect functionality.
3961 + * - If the host writes to the last dword address of such a register
3962 + * (i.e. the high 32 bits) the underlying register will always be
3963 +- * written. If the collector and the current write together do not
3964 +- * provide values for all 128 bits of the register, the low 96 bits
3965 +- * will be written as zero.
3966 ++ * written. If the collector does not hold values for the low 96
3967 ++ * bits of the register, they will be written as zero. Writing to
3968 ++ * the last qword does not have this effect and must not be done.
3969 + * - If the host writes to the address of any other part of such a
3970 + * register while the collector already holds values for some other
3971 + * register, the write is discarded and the collector maintains its
3972 +@@ -103,7 +103,6 @@ static inline void efx_writeo(struct efx_nic *efx, efx_oword_t *value,
3973 + _efx_writed(efx, value->u32[2], reg + 8);
3974 + _efx_writed(efx, value->u32[3], reg + 12);
3975 + #endif
3976 +- wmb();
3977 + mmiowb();
3978 + spin_unlock_irqrestore(&efx->biu_lock, flags);
3979 + }
3980 +@@ -126,7 +125,6 @@ static inline void efx_sram_writeq(struct efx_nic *efx, void __iomem *membase,
3981 + __raw_writel((__force u32)value->u32[0], membase + addr);
3982 + __raw_writel((__force u32)value->u32[1], membase + addr + 4);
3983 + #endif
3984 +- wmb();
3985 + mmiowb();
3986 + spin_unlock_irqrestore(&efx->biu_lock, flags);
3987 + }
3988 +@@ -141,7 +139,6 @@ static inline void efx_writed(struct efx_nic *efx, efx_dword_t *value,
3989 +
3990 + /* No lock required */
3991 + _efx_writed(efx, value->u32[0], reg);
3992 +- wmb();
3993 + }
3994 +
3995 + /* Read a 128-bit CSR, locking as appropriate. */
3996 +@@ -152,7 +149,6 @@ static inline void efx_reado(struct efx_nic *efx, efx_oword_t *value,
3997 +
3998 + spin_lock_irqsave(&efx->biu_lock, flags);
3999 + value->u32[0] = _efx_readd(efx, reg + 0);
4000 +- rmb();
4001 + value->u32[1] = _efx_readd(efx, reg + 4);
4002 + value->u32[2] = _efx_readd(efx, reg + 8);
4003 + value->u32[3] = _efx_readd(efx, reg + 12);
4004 +@@ -175,7 +171,6 @@ static inline void efx_sram_readq(struct efx_nic *efx, void __iomem *membase,
4005 + value->u64[0] = (__force __le64)__raw_readq(membase + addr);
4006 + #else
4007 + value->u32[0] = (__force __le32)__raw_readl(membase + addr);
4008 +- rmb();
4009 + value->u32[1] = (__force __le32)__raw_readl(membase + addr + 4);
4010 + #endif
4011 + spin_unlock_irqrestore(&efx->biu_lock, flags);
4012 +@@ -242,14 +237,12 @@ static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
4013 +
4014 + #ifdef EFX_USE_QWORD_IO
4015 + _efx_writeq(efx, value->u64[0], reg + 0);
4016 +- _efx_writeq(efx, value->u64[1], reg + 8);
4017 + #else
4018 + _efx_writed(efx, value->u32[0], reg + 0);
4019 + _efx_writed(efx, value->u32[1], reg + 4);
4020 ++#endif
4021 + _efx_writed(efx, value->u32[2], reg + 8);
4022 + _efx_writed(efx, value->u32[3], reg + 12);
4023 +-#endif
4024 +- wmb();
4025 + }
4026 + #define efx_writeo_page(efx, value, reg, page) \
4027 + _efx_writeo_page(efx, value, \
4028 +diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c
4029 +index 3dd45ed..81a4253 100644
4030 +--- a/drivers/net/sfc/mcdi.c
4031 ++++ b/drivers/net/sfc/mcdi.c
4032 +@@ -50,20 +50,6 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
4033 + return &nic_data->mcdi;
4034 + }
4035 +
4036 +-static inline void
4037 +-efx_mcdi_readd(struct efx_nic *efx, efx_dword_t *value, unsigned reg)
4038 +-{
4039 +- struct siena_nic_data *nic_data = efx->nic_data;
4040 +- value->u32[0] = (__force __le32)__raw_readl(nic_data->mcdi_smem + reg);
4041 +-}
4042 +-
4043 +-static inline void
4044 +-efx_mcdi_writed(struct efx_nic *efx, const efx_dword_t *value, unsigned reg)
4045 +-{
4046 +- struct siena_nic_data *nic_data = efx->nic_data;
4047 +- __raw_writel((__force u32)value->u32[0], nic_data->mcdi_smem + reg);
4048 +-}
4049 +-
4050 + void efx_mcdi_init(struct efx_nic *efx)
4051 + {
4052 + struct efx_mcdi_iface *mcdi;
4053 +@@ -84,8 +70,8 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
4054 + const u8 *inbuf, size_t inlen)
4055 + {
4056 + struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4057 +- unsigned pdu = MCDI_PDU(efx);
4058 +- unsigned doorbell = MCDI_DOORBELL(efx);
4059 ++ unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4060 ++ unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx);
4061 + unsigned int i;
4062 + efx_dword_t hdr;
4063 + u32 xflags, seqno;
4064 +@@ -106,28 +92,29 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
4065 + MCDI_HEADER_SEQ, seqno,
4066 + MCDI_HEADER_XFLAGS, xflags);
4067 +
4068 +- efx_mcdi_writed(efx, &hdr, pdu);
4069 ++ efx_writed(efx, &hdr, pdu);
4070 +
4071 + for (i = 0; i < inlen; i += 4)
4072 +- efx_mcdi_writed(efx, (const efx_dword_t *)(inbuf + i),
4073 +- pdu + 4 + i);
4074 ++ _efx_writed(efx, *((__le32 *)(inbuf + i)), pdu + 4 + i);
4075 ++
4076 ++ /* Ensure the payload is written out before the header */
4077 ++ wmb();
4078 +
4079 + /* ring the doorbell with a distinctive value */
4080 +- EFX_POPULATE_DWORD_1(hdr, EFX_DWORD_0, 0x45789abc);
4081 +- efx_mcdi_writed(efx, &hdr, doorbell);
4082 ++ _efx_writed(efx, (__force __le32) 0x45789abc, doorbell);
4083 + }
4084 +
4085 + static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen)
4086 + {
4087 + struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4088 +- unsigned int pdu = MCDI_PDU(efx);
4089 ++ unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4090 + int i;
4091 +
4092 + BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
4093 + BUG_ON(outlen & 3 || outlen >= 0x100);
4094 +
4095 + for (i = 0; i < outlen; i += 4)
4096 +- efx_mcdi_readd(efx, (efx_dword_t *)(outbuf + i), pdu + 4 + i);
4097 ++ *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i);
4098 + }
4099 +
4100 + static int efx_mcdi_poll(struct efx_nic *efx)
4101 +@@ -135,7 +122,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4102 + struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4103 + unsigned int time, finish;
4104 + unsigned int respseq, respcmd, error;
4105 +- unsigned int pdu = MCDI_PDU(efx);
4106 ++ unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4107 + unsigned int rc, spins;
4108 + efx_dword_t reg;
4109 +
4110 +@@ -161,7 +148,8 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4111 +
4112 + time = get_seconds();
4113 +
4114 +- efx_mcdi_readd(efx, &reg, pdu);
4115 ++ rmb();
4116 ++ efx_readd(efx, &reg, pdu);
4117 +
4118 + /* All 1's indicates that shared memory is in reset (and is
4119 + * not a valid header). Wait for it to come out reset before
4120 +@@ -188,7 +176,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4121 + respseq, mcdi->seqno);
4122 + rc = EIO;
4123 + } else if (error) {
4124 +- efx_mcdi_readd(efx, &reg, pdu + 4);
4125 ++ efx_readd(efx, &reg, pdu + 4);
4126 + switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) {
4127 + #define TRANSLATE_ERROR(name) \
4128 + case MC_CMD_ERR_ ## name: \
4129 +@@ -222,21 +210,21 @@ out:
4130 + /* Test and clear MC-rebooted flag for this port/function */
4131 + int efx_mcdi_poll_reboot(struct efx_nic *efx)
4132 + {
4133 +- unsigned int addr = MCDI_REBOOT_FLAG(efx);
4134 ++ unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx);
4135 + efx_dword_t reg;
4136 + uint32_t value;
4137 +
4138 + if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
4139 + return false;
4140 +
4141 +- efx_mcdi_readd(efx, &reg, addr);
4142 ++ efx_readd(efx, &reg, addr);
4143 + value = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
4144 +
4145 + if (value == 0)
4146 + return 0;
4147 +
4148 + EFX_ZERO_DWORD(reg);
4149 +- efx_mcdi_writed(efx, &reg, addr);
4150 ++ efx_writed(efx, &reg, addr);
4151 +
4152 + if (value == MC_STATUS_DWORD_ASSERT)
4153 + return -EINTR;
4154 +diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c
4155 +index f2a2b94..5ac9fa2 100644
4156 +--- a/drivers/net/sfc/nic.c
4157 ++++ b/drivers/net/sfc/nic.c
4158 +@@ -1935,13 +1935,6 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
4159 +
4160 + size = min_t(size_t, table->step, 16);
4161 +
4162 +- if (table->offset >= efx->type->mem_map_size) {
4163 +- /* No longer mapped; return dummy data */
4164 +- memcpy(buf, "\xde\xc0\xad\xde", 4);
4165 +- buf += table->rows * size;
4166 +- continue;
4167 +- }
4168 +-
4169 + for (i = 0; i < table->rows; i++) {
4170 + switch (table->step) {
4171 + case 4: /* 32-bit register or SRAM */
4172 +diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
4173 +index 4bd1f28..7443f99 100644
4174 +--- a/drivers/net/sfc/nic.h
4175 ++++ b/drivers/net/sfc/nic.h
4176 +@@ -143,12 +143,10 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
4177 + /**
4178 + * struct siena_nic_data - Siena NIC state
4179 + * @mcdi: Management-Controller-to-Driver Interface
4180 +- * @mcdi_smem: MCDI shared memory mapping. The mapping is always uncacheable.
4181 + * @wol_filter_id: Wake-on-LAN packet filter id
4182 + */
4183 + struct siena_nic_data {
4184 + struct efx_mcdi_iface mcdi;
4185 +- void __iomem *mcdi_smem;
4186 + int wol_filter_id;
4187 + };
4188 +
4189 +diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
4190 +index fb4721f..ceac1c9 100644
4191 +--- a/drivers/net/sfc/siena.c
4192 ++++ b/drivers/net/sfc/siena.c
4193 +@@ -220,26 +220,12 @@ static int siena_probe_nic(struct efx_nic *efx)
4194 + efx_reado(efx, &reg, FR_AZ_CS_DEBUG);
4195 + efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
4196 +
4197 +- /* Initialise MCDI */
4198 +- nic_data->mcdi_smem = ioremap_nocache(efx->membase_phys +
4199 +- FR_CZ_MC_TREG_SMEM,
4200 +- FR_CZ_MC_TREG_SMEM_STEP *
4201 +- FR_CZ_MC_TREG_SMEM_ROWS);
4202 +- if (!nic_data->mcdi_smem) {
4203 +- netif_err(efx, probe, efx->net_dev,
4204 +- "could not map MCDI at %llx+%x\n",
4205 +- (unsigned long long)efx->membase_phys +
4206 +- FR_CZ_MC_TREG_SMEM,
4207 +- FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS);
4208 +- rc = -ENOMEM;
4209 +- goto fail1;
4210 +- }
4211 + efx_mcdi_init(efx);
4212 +
4213 + /* Recover from a failed assertion before probing */
4214 + rc = efx_mcdi_handle_assertion(efx);
4215 + if (rc)
4216 +- goto fail2;
4217 ++ goto fail1;
4218 +
4219 + /* Let the BMC know that the driver is now in charge of link and
4220 + * filter settings. We must do this before we reset the NIC */
4221 +@@ -294,7 +280,6 @@ fail4:
4222 + fail3:
4223 + efx_mcdi_drv_attach(efx, false, NULL);
4224 + fail2:
4225 +- iounmap(nic_data->mcdi_smem);
4226 + fail1:
4227 + kfree(efx->nic_data);
4228 + return rc;
4229 +@@ -374,8 +359,6 @@ static int siena_init_nic(struct efx_nic *efx)
4230 +
4231 + static void siena_remove_nic(struct efx_nic *efx)
4232 + {
4233 +- struct siena_nic_data *nic_data = efx->nic_data;
4234 +-
4235 + efx_nic_free_buffer(efx, &efx->irq_status);
4236 +
4237 + siena_reset_hw(efx, RESET_TYPE_ALL);
4238 +@@ -385,8 +368,7 @@ static void siena_remove_nic(struct efx_nic *efx)
4239 + efx_mcdi_drv_attach(efx, false, NULL);
4240 +
4241 + /* Tear down the private nic state */
4242 +- iounmap(nic_data->mcdi_smem);
4243 +- kfree(nic_data);
4244 ++ kfree(efx->nic_data);
4245 + efx->nic_data = NULL;
4246 + }
4247 +
4248 +@@ -624,7 +606,8 @@ const struct efx_nic_type siena_a0_nic_type = {
4249 + .default_mac_ops = &efx_mcdi_mac_operations,
4250 +
4251 + .revision = EFX_REV_SIENA_A0,
4252 +- .mem_map_size = FR_CZ_MC_TREG_SMEM, /* MC_TREG_SMEM mapped separately */
4253 ++ .mem_map_size = (FR_CZ_MC_TREG_SMEM +
4254 ++ FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS),
4255 + .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
4256 + .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL,
4257 + .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
4258 +diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h
4259 +index 99ff114..e4dd3a7 100644
4260 +--- a/drivers/net/sfc/workarounds.h
4261 ++++ b/drivers/net/sfc/workarounds.h
4262 +@@ -38,8 +38,6 @@
4263 + #define EFX_WORKAROUND_15783 EFX_WORKAROUND_ALWAYS
4264 + /* Legacy interrupt storm when interrupt fifo fills */
4265 + #define EFX_WORKAROUND_17213 EFX_WORKAROUND_SIENA
4266 +-/* Write combining and sriov=enabled are incompatible */
4267 +-#define EFX_WORKAROUND_22643 EFX_WORKAROUND_SIENA
4268 +
4269 + /* Spurious parity errors in TSORT buffers */
4270 + #define EFX_WORKAROUND_5129 EFX_WORKAROUND_FALCON_A
4271 +diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
4272 +index a1f9f9e..38f6859 100644
4273 +--- a/drivers/net/tg3.c
4274 ++++ b/drivers/net/tg3.c
4275 +@@ -7267,16 +7267,11 @@ static int tg3_chip_reset(struct tg3 *tp)
4276 + tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
4277 + }
4278 +
4279 +- if (tg3_flag(tp, ENABLE_APE))
4280 +- tp->mac_mode = MAC_MODE_APE_TX_EN |
4281 +- MAC_MODE_APE_RX_EN |
4282 +- MAC_MODE_TDE_ENABLE;
4283 +-
4284 + if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) {
4285 +- tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
4286 ++ tp->mac_mode = MAC_MODE_PORT_MODE_TBI;
4287 + val = tp->mac_mode;
4288 + } else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) {
4289 +- tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
4290 ++ tp->mac_mode = MAC_MODE_PORT_MODE_GMII;
4291 + val = tp->mac_mode;
4292 + } else
4293 + val = 0;
4294 +@@ -8408,12 +8403,11 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
4295 + udelay(10);
4296 + }
4297 +
4298 +- if (tg3_flag(tp, ENABLE_APE))
4299 +- tp->mac_mode = MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN;
4300 +- else
4301 +- tp->mac_mode = 0;
4302 + tp->mac_mode |= MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
4303 +- MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
4304 ++ MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE |
4305 ++ MAC_MODE_FHDE_ENABLE;
4306 ++ if (tg3_flag(tp, ENABLE_APE))
4307 ++ tp->mac_mode |= MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN;
4308 + if (!tg3_flag(tp, 5705_PLUS) &&
4309 + !(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) &&
4310 + GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
4311 +@@ -8988,7 +8982,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
4312 + * Turn off MSI one shot mode. Otherwise this test has no
4313 + * observable way to know whether the interrupt was delivered.
4314 + */
4315 +- if (tg3_flag(tp, 57765_PLUS) && tg3_flag(tp, USING_MSI)) {
4316 ++ if (tg3_flag(tp, 57765_PLUS)) {
4317 + val = tr32(MSGINT_MODE) | MSGINT_MODE_ONE_SHOT_DISABLE;
4318 + tw32(MSGINT_MODE, val);
4319 + }
4320 +@@ -9016,6 +9010,10 @@ static int tg3_test_interrupt(struct tg3 *tp)
4321 + break;
4322 + }
4323 +
4324 ++ if (tg3_flag(tp, 57765_PLUS) &&
4325 ++ tnapi->hw_status->status_tag != tnapi->last_tag)
4326 ++ tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24);
4327 ++
4328 + msleep(10);
4329 + }
4330 +
4331 +@@ -9030,7 +9028,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
4332 +
4333 + if (intr_ok) {
4334 + /* Reenable MSI one shot mode. */
4335 +- if (tg3_flag(tp, 57765_PLUS) && tg3_flag(tp, USING_MSI)) {
4336 ++ if (tg3_flag(tp, 57765_PLUS)) {
4337 + val = tr32(MSGINT_MODE) & ~MSGINT_MODE_ONE_SHOT_DISABLE;
4338 + tw32(MSGINT_MODE, val);
4339 + }
4340 +@@ -12947,7 +12945,9 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
4341 + }
4342 +
4343 + if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
4344 +- ((tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
4345 ++ (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
4346 ++ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720 ||
4347 ++ (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
4348 + tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) ||
4349 + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 &&
4350 + tp->pci_chip_rev_id != CHIPREV_ID_57765_A0)))
4351 +diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
4352 +index 6998aa6..5250288 100644
4353 +--- a/drivers/net/usb/asix.c
4354 ++++ b/drivers/net/usb/asix.c
4355 +@@ -1502,6 +1502,10 @@ static const struct usb_device_id products [] = {
4356 + USB_DEVICE (0x04f1, 0x3008),
4357 + .driver_info = (unsigned long) &ax8817x_info,
4358 + }, {
4359 ++ // ASIX AX88772B 10/100
4360 ++ USB_DEVICE (0x0b95, 0x772b),
4361 ++ .driver_info = (unsigned long) &ax88772_info,
4362 ++}, {
4363 + // ASIX AX88772 10/100
4364 + USB_DEVICE (0x0b95, 0x7720),
4365 + .driver_info = (unsigned long) &ax88772_info,
4366 +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
4367 +index f33ca6a..d3b9e95 100644
4368 +--- a/drivers/net/usb/cdc_ncm.c
4369 ++++ b/drivers/net/usb/cdc_ncm.c
4370 +@@ -54,7 +54,7 @@
4371 + #include <linux/usb/usbnet.h>
4372 + #include <linux/usb/cdc.h>
4373 +
4374 +-#define DRIVER_VERSION "01-June-2011"
4375 ++#define DRIVER_VERSION "04-Aug-2011"
4376 +
4377 + /* CDC NCM subclass 3.2.1 */
4378 + #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
4379 +@@ -164,35 +164,8 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
4380 + usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
4381 + }
4382 +
4383 +-static int
4384 +-cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
4385 +- void *data, u16 flags, u16 *actlen, u16 timeout)
4386 +-{
4387 +- int err;
4388 +-
4389 +- err = usb_control_msg(ctx->udev, (req->bmRequestType & USB_DIR_IN) ?
4390 +- usb_rcvctrlpipe(ctx->udev, 0) :
4391 +- usb_sndctrlpipe(ctx->udev, 0),
4392 +- req->bNotificationType, req->bmRequestType,
4393 +- req->wValue,
4394 +- req->wIndex, data,
4395 +- req->wLength, timeout);
4396 +-
4397 +- if (err < 0) {
4398 +- if (actlen)
4399 +- *actlen = 0;
4400 +- return err;
4401 +- }
4402 +-
4403 +- if (actlen)
4404 +- *actlen = err;
4405 +-
4406 +- return 0;
4407 +-}
4408 +-
4409 + static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4410 + {
4411 +- struct usb_cdc_notification req;
4412 + u32 val;
4413 + u8 flags;
4414 + u8 iface_no;
4415 +@@ -201,14 +174,14 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4416 +
4417 + iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
4418 +
4419 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE;
4420 +- req.bNotificationType = USB_CDC_GET_NTB_PARAMETERS;
4421 +- req.wValue = 0;
4422 +- req.wIndex = cpu_to_le16(iface_no);
4423 +- req.wLength = cpu_to_le16(sizeof(ctx->ncm_parm));
4424 +-
4425 +- err = cdc_ncm_do_request(ctx, &req, &ctx->ncm_parm, 0, NULL, 1000);
4426 +- if (err) {
4427 ++ err = usb_control_msg(ctx->udev,
4428 ++ usb_rcvctrlpipe(ctx->udev, 0),
4429 ++ USB_CDC_GET_NTB_PARAMETERS,
4430 ++ USB_TYPE_CLASS | USB_DIR_IN
4431 ++ | USB_RECIP_INTERFACE,
4432 ++ 0, iface_no, &ctx->ncm_parm,
4433 ++ sizeof(ctx->ncm_parm), 10000);
4434 ++ if (err < 0) {
4435 + pr_debug("failed GET_NTB_PARAMETERS\n");
4436 + return 1;
4437 + }
4438 +@@ -254,31 +227,26 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4439 +
4440 + /* inform device about NTB input size changes */
4441 + if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
4442 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4443 +- USB_RECIP_INTERFACE;
4444 +- req.bNotificationType = USB_CDC_SET_NTB_INPUT_SIZE;
4445 +- req.wValue = 0;
4446 +- req.wIndex = cpu_to_le16(iface_no);
4447 +
4448 + if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
4449 + struct usb_cdc_ncm_ndp_input_size ndp_in_sz;
4450 +-
4451 +- req.wLength = 8;
4452 +- ndp_in_sz.dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
4453 +- ndp_in_sz.wNtbInMaxDatagrams =
4454 +- cpu_to_le16(CDC_NCM_DPT_DATAGRAMS_MAX);
4455 +- ndp_in_sz.wReserved = 0;
4456 +- err = cdc_ncm_do_request(ctx, &req, &ndp_in_sz, 0, NULL,
4457 +- 1000);
4458 ++ err = usb_control_msg(ctx->udev,
4459 ++ usb_sndctrlpipe(ctx->udev, 0),
4460 ++ USB_CDC_SET_NTB_INPUT_SIZE,
4461 ++ USB_TYPE_CLASS | USB_DIR_OUT
4462 ++ | USB_RECIP_INTERFACE,
4463 ++ 0, iface_no, &ndp_in_sz, 8, 1000);
4464 + } else {
4465 + __le32 dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
4466 +-
4467 +- req.wLength = 4;
4468 +- err = cdc_ncm_do_request(ctx, &req, &dwNtbInMaxSize, 0,
4469 +- NULL, 1000);
4470 ++ err = usb_control_msg(ctx->udev,
4471 ++ usb_sndctrlpipe(ctx->udev, 0),
4472 ++ USB_CDC_SET_NTB_INPUT_SIZE,
4473 ++ USB_TYPE_CLASS | USB_DIR_OUT
4474 ++ | USB_RECIP_INTERFACE,
4475 ++ 0, iface_no, &dwNtbInMaxSize, 4, 1000);
4476 + }
4477 +
4478 +- if (err)
4479 ++ if (err < 0)
4480 + pr_debug("Setting NTB Input Size failed\n");
4481 + }
4482 +
4483 +@@ -333,29 +301,24 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4484 +
4485 + /* set CRC Mode */
4486 + if (flags & USB_CDC_NCM_NCAP_CRC_MODE) {
4487 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4488 +- USB_RECIP_INTERFACE;
4489 +- req.bNotificationType = USB_CDC_SET_CRC_MODE;
4490 +- req.wValue = cpu_to_le16(USB_CDC_NCM_CRC_NOT_APPENDED);
4491 +- req.wIndex = cpu_to_le16(iface_no);
4492 +- req.wLength = 0;
4493 +-
4494 +- err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
4495 +- if (err)
4496 ++ err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
4497 ++ USB_CDC_SET_CRC_MODE,
4498 ++ USB_TYPE_CLASS | USB_DIR_OUT
4499 ++ | USB_RECIP_INTERFACE,
4500 ++ USB_CDC_NCM_CRC_NOT_APPENDED,
4501 ++ iface_no, NULL, 0, 1000);
4502 ++ if (err < 0)
4503 + pr_debug("Setting CRC mode off failed\n");
4504 + }
4505 +
4506 + /* set NTB format, if both formats are supported */
4507 + if (ntb_fmt_supported & USB_CDC_NCM_NTH32_SIGN) {
4508 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4509 +- USB_RECIP_INTERFACE;
4510 +- req.bNotificationType = USB_CDC_SET_NTB_FORMAT;
4511 +- req.wValue = cpu_to_le16(USB_CDC_NCM_NTB16_FORMAT);
4512 +- req.wIndex = cpu_to_le16(iface_no);
4513 +- req.wLength = 0;
4514 +-
4515 +- err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
4516 +- if (err)
4517 ++ err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
4518 ++ USB_CDC_SET_NTB_FORMAT, USB_TYPE_CLASS
4519 ++ | USB_DIR_OUT | USB_RECIP_INTERFACE,
4520 ++ USB_CDC_NCM_NTB16_FORMAT,
4521 ++ iface_no, NULL, 0, 1000);
4522 ++ if (err < 0)
4523 + pr_debug("Setting NTB format to 16-bit failed\n");
4524 + }
4525 +
4526 +@@ -365,17 +328,13 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4527 + if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) {
4528 + __le16 max_datagram_size;
4529 + u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
4530 +-
4531 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN |
4532 +- USB_RECIP_INTERFACE;
4533 +- req.bNotificationType = USB_CDC_GET_MAX_DATAGRAM_SIZE;
4534 +- req.wValue = 0;
4535 +- req.wIndex = cpu_to_le16(iface_no);
4536 +- req.wLength = cpu_to_le16(2);
4537 +-
4538 +- err = cdc_ncm_do_request(ctx, &req, &max_datagram_size, 0, NULL,
4539 +- 1000);
4540 +- if (err) {
4541 ++ err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0),
4542 ++ USB_CDC_GET_MAX_DATAGRAM_SIZE,
4543 ++ USB_TYPE_CLASS | USB_DIR_IN
4544 ++ | USB_RECIP_INTERFACE,
4545 ++ 0, iface_no, &max_datagram_size,
4546 ++ 2, 1000);
4547 ++ if (err < 0) {
4548 + pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
4549 + CDC_NCM_MIN_DATAGRAM_SIZE);
4550 + } else {
4551 +@@ -396,17 +355,15 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4552 + CDC_NCM_MIN_DATAGRAM_SIZE;
4553 +
4554 + /* if value changed, update device */
4555 +- req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4556 +- USB_RECIP_INTERFACE;
4557 +- req.bNotificationType = USB_CDC_SET_MAX_DATAGRAM_SIZE;
4558 +- req.wValue = 0;
4559 +- req.wIndex = cpu_to_le16(iface_no);
4560 +- req.wLength = 2;
4561 +- max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
4562 +-
4563 +- err = cdc_ncm_do_request(ctx, &req, &max_datagram_size,
4564 +- 0, NULL, 1000);
4565 +- if (err)
4566 ++ err = usb_control_msg(ctx->udev,
4567 ++ usb_sndctrlpipe(ctx->udev, 0),
4568 ++ USB_CDC_SET_MAX_DATAGRAM_SIZE,
4569 ++ USB_TYPE_CLASS | USB_DIR_OUT
4570 ++ | USB_RECIP_INTERFACE,
4571 ++ 0,
4572 ++ iface_no, &max_datagram_size,
4573 ++ 2, 1000);
4574 ++ if (err < 0)
4575 + pr_debug("SET_MAX_DATAGRAM_SIZE failed\n");
4576 + }
4577 +
4578 +@@ -672,7 +629,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4579 + u32 rem;
4580 + u32 offset;
4581 + u32 last_offset;
4582 +- u16 n = 0;
4583 ++ u16 n = 0, index;
4584 + u8 ready2send = 0;
4585 +
4586 + /* if there is a remaining skb, it gets priority */
4587 +@@ -860,8 +817,8 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4588 + cpu_to_le16(sizeof(ctx->tx_ncm.nth16));
4589 + ctx->tx_ncm.nth16.wSequence = cpu_to_le16(ctx->tx_seq);
4590 + ctx->tx_ncm.nth16.wBlockLength = cpu_to_le16(last_offset);
4591 +- ctx->tx_ncm.nth16.wNdpIndex = ALIGN(sizeof(struct usb_cdc_ncm_nth16),
4592 +- ctx->tx_ndp_modulus);
4593 ++ index = ALIGN(sizeof(struct usb_cdc_ncm_nth16), ctx->tx_ndp_modulus);
4594 ++ ctx->tx_ncm.nth16.wNdpIndex = cpu_to_le16(index);
4595 +
4596 + memcpy(skb_out->data, &(ctx->tx_ncm.nth16), sizeof(ctx->tx_ncm.nth16));
4597 + ctx->tx_seq++;
4598 +@@ -874,12 +831,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4599 + ctx->tx_ncm.ndp16.wLength = cpu_to_le16(rem);
4600 + ctx->tx_ncm.ndp16.wNextNdpIndex = 0; /* reserved */
4601 +
4602 +- memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex,
4603 ++ memcpy(((u8 *)skb_out->data) + index,
4604 + &(ctx->tx_ncm.ndp16),
4605 + sizeof(ctx->tx_ncm.ndp16));
4606 +
4607 +- memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex +
4608 +- sizeof(ctx->tx_ncm.ndp16),
4609 ++ memcpy(((u8 *)skb_out->data) + index + sizeof(ctx->tx_ncm.ndp16),
4610 + &(ctx->tx_ncm.dpe16),
4611 + (ctx->tx_curr_frame_num + 1) *
4612 + sizeof(struct usb_cdc_ncm_dpe16));
4613 +diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4614 +index 2d4c091..2d394af 100644
4615 +--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4616 ++++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4617 +@@ -41,7 +41,8 @@ static bool ar9002_hw_is_cal_supported(struct ath_hw *ah,
4618 + case ADC_DC_CAL:
4619 + /* Run ADC Gain Cal for non-CCK & non 2GHz-HT20 only */
4620 + if (!IS_CHAN_B(chan) &&
4621 +- !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
4622 ++ !((IS_CHAN_2GHZ(chan) || IS_CHAN_A_FAST_CLOCK(ah, chan)) &&
4623 ++ IS_CHAN_HT20(chan)))
4624 + supported = true;
4625 + break;
4626 + }
4627 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4628 +index e8ac70d..029773c 100644
4629 +--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4630 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4631 +@@ -1516,7 +1516,7 @@ static const u32 ar9300_2p2_mac_core[][2] = {
4632 + {0x00008258, 0x00000000},
4633 + {0x0000825c, 0x40000000},
4634 + {0x00008260, 0x00080922},
4635 +- {0x00008264, 0x9bc00010},
4636 ++ {0x00008264, 0x9d400010},
4637 + {0x00008268, 0xffffffff},
4638 + {0x0000826c, 0x0000ffff},
4639 + {0x00008270, 0x00000000},
4640 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4641 +index 7e07f0f..417106b 100644
4642 +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4643 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4644 +@@ -68,7 +68,7 @@ static int ar9003_hw_power_interpolate(int32_t x,
4645 + static const struct ar9300_eeprom ar9300_default = {
4646 + .eepromVersion = 2,
4647 + .templateVersion = 2,
4648 +- .macAddr = {1, 2, 3, 4, 5, 6},
4649 ++ .macAddr = {0, 2, 3, 4, 5, 6},
4650 + .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4651 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4652 + .baseEepHeader = {
4653 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
4654 +index 2ca351f..5362306 100644
4655 +--- a/drivers/net/wireless/ath/ath9k/main.c
4656 ++++ b/drivers/net/wireless/ath/ath9k/main.c
4657 +@@ -2260,7 +2260,11 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
4658 +
4659 + mutex_lock(&sc->mutex);
4660 + ah->coverage_class = coverage_class;
4661 ++
4662 ++ ath9k_ps_wakeup(sc);
4663 + ath9k_hw_init_global_settings(ah);
4664 ++ ath9k_ps_restore(sc);
4665 ++
4666 + mutex_unlock(&sc->mutex);
4667 + }
4668 +
4669 +diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
4670 +index 54d093c..b54966c 100644
4671 +--- a/drivers/net/wireless/ath/carl9170/main.c
4672 ++++ b/drivers/net/wireless/ath/carl9170/main.c
4673 +@@ -1066,8 +1066,10 @@ static int carl9170_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
4674 + * the high througput speed in 802.11n networks.
4675 + */
4676 +
4677 +- if (!is_main_vif(ar, vif))
4678 ++ if (!is_main_vif(ar, vif)) {
4679 ++ mutex_lock(&ar->mutex);
4680 + goto err_softw;
4681 ++ }
4682 +
4683 + /*
4684 + * While the hardware supports *catch-all* key, for offloading
4685 +diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
4686 +index eb41596..b1fe4fe 100644
4687 +--- a/drivers/net/wireless/b43/main.c
4688 ++++ b/drivers/net/wireless/b43/main.c
4689 +@@ -1571,7 +1571,8 @@ static void handle_irq_beacon(struct b43_wldev *dev)
4690 + u32 cmd, beacon0_valid, beacon1_valid;
4691 +
4692 + if (!b43_is_mode(wl, NL80211_IFTYPE_AP) &&
4693 +- !b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
4694 ++ !b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT) &&
4695 ++ !b43_is_mode(wl, NL80211_IFTYPE_ADHOC))
4696 + return;
4697 +
4698 + /* This is the bottom half of the asynchronous beacon update. */
4699 +diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4700 +index 977bd24..164bcae 100644
4701 +--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4702 ++++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4703 +@@ -822,12 +822,15 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
4704 +
4705 + out:
4706 +
4707 +- rs_sta->last_txrate_idx = index;
4708 +- if (sband->band == IEEE80211_BAND_5GHZ)
4709 +- info->control.rates[0].idx = rs_sta->last_txrate_idx -
4710 +- IWL_FIRST_OFDM_RATE;
4711 +- else
4712 ++ if (sband->band == IEEE80211_BAND_5GHZ) {
4713 ++ if (WARN_ON_ONCE(index < IWL_FIRST_OFDM_RATE))
4714 ++ index = IWL_FIRST_OFDM_RATE;
4715 ++ rs_sta->last_txrate_idx = index;
4716 ++ info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE;
4717 ++ } else {
4718 ++ rs_sta->last_txrate_idx = index;
4719 + info->control.rates[0].idx = rs_sta->last_txrate_idx;
4720 ++ }
4721 +
4722 + IWL_DEBUG_RATE(priv, "leave: %d\n", index);
4723 + }
4724 +diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
4725 +index 3be76bd..d273d50 100644
4726 +--- a/drivers/net/wireless/iwlegacy/iwl-core.c
4727 ++++ b/drivers/net/wireless/iwlegacy/iwl-core.c
4728 +@@ -938,7 +938,7 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv)
4729 + &priv->contexts[IWL_RXON_CTX_BSS]);
4730 + #endif
4731 +
4732 +- wake_up_interruptible(&priv->wait_command_queue);
4733 ++ wake_up(&priv->wait_command_queue);
4734 +
4735 + /* Keep the restart process from trying to send host
4736 + * commands by clearing the INIT status bit */
4737 +@@ -1776,7 +1776,7 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external)
4738 + IWL_ERR(priv, "On demand firmware reload\n");
4739 + /* Set the FW error flag -- cleared on iwl_down */
4740 + set_bit(STATUS_FW_ERROR, &priv->status);
4741 +- wake_up_interruptible(&priv->wait_command_queue);
4742 ++ wake_up(&priv->wait_command_queue);
4743 + /*
4744 + * Keep the restart process from trying to send host
4745 + * commands by clearing the INIT status bit
4746 +diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4747 +index 62b4b09..ce1fc9f 100644
4748 +--- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4749 ++++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4750 +@@ -167,7 +167,7 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
4751 + goto out;
4752 + }
4753 +
4754 +- ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4755 ++ ret = wait_event_timeout(priv->wait_command_queue,
4756 + !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
4757 + HOST_COMPLETE_TIMEOUT);
4758 + if (!ret) {
4759 +diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c
4760 +index 4fff995..ef9e268 100644
4761 +--- a/drivers/net/wireless/iwlegacy/iwl-tx.c
4762 ++++ b/drivers/net/wireless/iwlegacy/iwl-tx.c
4763 +@@ -625,6 +625,8 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4764 + cmd = txq->cmd[cmd_index];
4765 + meta = &txq->meta[cmd_index];
4766 +
4767 ++ txq->time_stamp = jiffies;
4768 ++
4769 + pci_unmap_single(priv->pci_dev,
4770 + dma_unmap_addr(meta, mapping),
4771 + dma_unmap_len(meta, len),
4772 +@@ -645,7 +647,7 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4773 + clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
4774 + IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n",
4775 + iwl_legacy_get_cmd_string(cmd->hdr.cmd));
4776 +- wake_up_interruptible(&priv->wait_command_queue);
4777 ++ wake_up(&priv->wait_command_queue);
4778 + }
4779 +
4780 + /* Mark as unmapped */
4781 +diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
4782 +index 0ee6be6..421d5c8 100644
4783 +--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
4784 ++++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
4785 +@@ -841,7 +841,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv,
4786 + wiphy_rfkill_set_hw_state(priv->hw->wiphy,
4787 + test_bit(STATUS_RF_KILL_HW, &priv->status));
4788 + else
4789 +- wake_up_interruptible(&priv->wait_command_queue);
4790 ++ wake_up(&priv->wait_command_queue);
4791 + }
4792 +
4793 + /**
4794 +@@ -2518,7 +2518,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
4795 + iwl3945_reg_txpower_periodic(priv);
4796 +
4797 + IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
4798 +- wake_up_interruptible(&priv->wait_command_queue);
4799 ++ wake_up(&priv->wait_command_queue);
4800 +
4801 + return;
4802 +
4803 +@@ -2549,7 +2549,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
4804 + iwl_legacy_clear_driver_stations(priv);
4805 +
4806 + /* Unblock any waiting calls */
4807 +- wake_up_interruptible_all(&priv->wait_command_queue);
4808 ++ wake_up_all(&priv->wait_command_queue);
4809 +
4810 + /* Wipe out the EXIT_PENDING status bit if we are not actually
4811 + * exiting the module */
4812 +@@ -3125,7 +3125,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
4813 +
4814 + /* Wait for START_ALIVE from ucode. Otherwise callbacks from
4815 + * mac80211 will not be run successfully. */
4816 +- ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4817 ++ ret = wait_event_timeout(priv->wait_command_queue,
4818 + test_bit(STATUS_READY, &priv->status),
4819 + UCODE_READY_TIMEOUT);
4820 + if (!ret) {
4821 +diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
4822 +index 7157ba5..0c37c02 100644
4823 +--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
4824 ++++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
4825 +@@ -704,7 +704,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
4826 + wiphy_rfkill_set_hw_state(priv->hw->wiphy,
4827 + test_bit(STATUS_RF_KILL_HW, &priv->status));
4828 + else
4829 +- wake_up_interruptible(&priv->wait_command_queue);
4830 ++ wake_up(&priv->wait_command_queue);
4831 + }
4832 +
4833 + /**
4834 +@@ -1054,7 +1054,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
4835 + handled |= CSR_INT_BIT_FH_TX;
4836 + /* Wake up uCode load routine, now that load is complete */
4837 + priv->ucode_write_complete = 1;
4838 +- wake_up_interruptible(&priv->wait_command_queue);
4839 ++ wake_up(&priv->wait_command_queue);
4840 + }
4841 +
4842 + if (inta & ~handled) {
4843 +@@ -2126,7 +2126,7 @@ static void iwl4965_alive_start(struct iwl_priv *priv)
4844 + iwl4965_rf_kill_ct_config(priv);
4845 +
4846 + IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
4847 +- wake_up_interruptible(&priv->wait_command_queue);
4848 ++ wake_up(&priv->wait_command_queue);
4849 +
4850 + iwl_legacy_power_update_mode(priv, true);
4851 + IWL_DEBUG_INFO(priv, "Updated power mode\n");
4852 +@@ -2159,7 +2159,7 @@ static void __iwl4965_down(struct iwl_priv *priv)
4853 + iwl_legacy_clear_driver_stations(priv);
4854 +
4855 + /* Unblock any waiting calls */
4856 +- wake_up_interruptible_all(&priv->wait_command_queue);
4857 ++ wake_up_all(&priv->wait_command_queue);
4858 +
4859 + /* Wipe out the EXIT_PENDING status bit if we are not actually
4860 + * exiting the module */
4861 +@@ -2597,7 +2597,7 @@ int iwl4965_mac_start(struct ieee80211_hw *hw)
4862 +
4863 + /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
4864 + * mac80211 will not be run successfully. */
4865 +- ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4866 ++ ret = wait_event_timeout(priv->wait_command_queue,
4867 + test_bit(STATUS_READY, &priv->status),
4868 + UCODE_READY_TIMEOUT);
4869 + if (!ret) {
4870 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
4871 +index 8e1942e..f24165d 100644
4872 +--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
4873 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
4874 +@@ -2440,7 +2440,12 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
4875 + IEEE80211_HW_SPECTRUM_MGMT |
4876 + IEEE80211_HW_REPORTS_TX_ACK_STATUS;
4877 +
4878 ++ /*
4879 ++ * Including the following line will crash some AP's. This
4880 ++ * workaround removes the stimulus which causes the crash until
4881 ++ * the AP software can be fixed.
4882 + hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
4883 ++ */
4884 +
4885 + hw->flags |= IEEE80211_HW_SUPPORTS_PS |
4886 + IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
4887 +diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
4888 +index d60d630..f524016 100644
4889 +--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
4890 ++++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
4891 +@@ -406,31 +406,33 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
4892 +
4893 + mutex_lock(&priv->mutex);
4894 +
4895 +- if (test_bit(STATUS_SCANNING, &priv->status) &&
4896 +- priv->scan_type != IWL_SCAN_NORMAL) {
4897 +- IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
4898 +- ret = -EAGAIN;
4899 +- goto out_unlock;
4900 +- }
4901 +-
4902 +- /* mac80211 will only ask for one band at a time */
4903 +- priv->scan_request = req;
4904 +- priv->scan_vif = vif;
4905 +-
4906 + /*
4907 + * If an internal scan is in progress, just set
4908 + * up the scan_request as per above.
4909 + */
4910 + if (priv->scan_type != IWL_SCAN_NORMAL) {
4911 +- IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n");
4912 ++ IWL_DEBUG_SCAN(priv,
4913 ++ "SCAN request during internal scan - defer\n");
4914 ++ priv->scan_request = req;
4915 ++ priv->scan_vif = vif;
4916 + ret = 0;
4917 +- } else
4918 ++ } else {
4919 ++ priv->scan_request = req;
4920 ++ priv->scan_vif = vif;
4921 ++ /*
4922 ++ * mac80211 will only ask for one band at a time
4923 ++ * so using channels[0] here is ok
4924 ++ */
4925 + ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL,
4926 + req->channels[0]->band);
4927 ++ if (ret) {
4928 ++ priv->scan_request = NULL;
4929 ++ priv->scan_vif = NULL;
4930 ++ }
4931 ++ }
4932 +
4933 + IWL_DEBUG_MAC80211(priv, "leave\n");
4934 +
4935 +-out_unlock:
4936 + mutex_unlock(&priv->mutex);
4937 +
4938 + return ret;
4939 +diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
4940 +index 137dba9..c368c50 100644
4941 +--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
4942 ++++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
4943 +@@ -802,6 +802,8 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4944 + cmd = txq->cmd[cmd_index];
4945 + meta = &txq->meta[cmd_index];
4946 +
4947 ++ txq->time_stamp = jiffies;
4948 ++
4949 + iwlagn_unmap_tfd(priv, meta, &txq->tfds[index], PCI_DMA_BIDIRECTIONAL);
4950 +
4951 + /* Input error checking is done when commands are added to queue. */
4952 +diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
4953 +index 5a45228..3f7ea1c 100644
4954 +--- a/drivers/net/wireless/rt2x00/rt2800lib.c
4955 ++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
4956 +@@ -38,6 +38,7 @@
4957 + #include <linux/kernel.h>
4958 + #include <linux/module.h>
4959 + #include <linux/slab.h>
4960 ++#include <linux/sched.h>
4961 +
4962 + #include "rt2x00.h"
4963 + #include "rt2800lib.h"
4964 +@@ -607,6 +608,15 @@ static bool rt2800_txdone_entry_check(struct queue_entry *entry, u32 reg)
4965 + int wcid, ack, pid;
4966 + int tx_wcid, tx_ack, tx_pid;
4967 +
4968 ++ if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
4969 ++ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) {
4970 ++ WARNING(entry->queue->rt2x00dev,
4971 ++ "Data pending for entry %u in queue %u\n",
4972 ++ entry->entry_idx, entry->queue->qid);
4973 ++ cond_resched();
4974 ++ return false;
4975 ++ }
4976 ++
4977 + wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
4978 + ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
4979 + pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
4980 +@@ -754,12 +764,11 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
4981 + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
4982 + if (rt2800_txdone_entry_check(entry, reg))
4983 + break;
4984 ++ entry = NULL;
4985 + }
4986 +
4987 +- if (!entry || rt2x00queue_empty(queue))
4988 +- break;
4989 +-
4990 +- rt2800_txdone_entry(entry, reg);
4991 ++ if (entry)
4992 ++ rt2800_txdone_entry(entry, reg);
4993 + }
4994 + }
4995 + EXPORT_SYMBOL_GPL(rt2800_txdone);
4996 +@@ -3503,14 +3512,15 @@ static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i)
4997 + rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
4998 +
4999 + /* Apparently the data is read from end to start */
5000 +- rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3,
5001 +- (u32 *)&rt2x00dev->eeprom[i]);
5002 +- rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2,
5003 +- (u32 *)&rt2x00dev->eeprom[i + 2]);
5004 +- rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1,
5005 +- (u32 *)&rt2x00dev->eeprom[i + 4]);
5006 +- rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0,
5007 +- (u32 *)&rt2x00dev->eeprom[i + 6]);
5008 ++ rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, &reg);
5009 ++ /* The returned value is in CPU order, but eeprom is le */
5010 ++ rt2x00dev->eeprom[i] = cpu_to_le32(reg);
5011 ++ rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2, &reg);
5012 ++ *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg);
5013 ++ rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1, &reg);
5014 ++ *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg);
5015 ++ rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0, &reg);
5016 ++ *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg);
5017 +
5018 + mutex_unlock(&rt2x00dev->csr_mutex);
5019 + }
5020 +@@ -3676,19 +3686,23 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
5021 + return -ENODEV;
5022 + }
5023 +
5024 +- if (!rt2x00_rf(rt2x00dev, RF2820) &&
5025 +- !rt2x00_rf(rt2x00dev, RF2850) &&
5026 +- !rt2x00_rf(rt2x00dev, RF2720) &&
5027 +- !rt2x00_rf(rt2x00dev, RF2750) &&
5028 +- !rt2x00_rf(rt2x00dev, RF3020) &&
5029 +- !rt2x00_rf(rt2x00dev, RF2020) &&
5030 +- !rt2x00_rf(rt2x00dev, RF3021) &&
5031 +- !rt2x00_rf(rt2x00dev, RF3022) &&
5032 +- !rt2x00_rf(rt2x00dev, RF3052) &&
5033 +- !rt2x00_rf(rt2x00dev, RF3320) &&
5034 +- !rt2x00_rf(rt2x00dev, RF5370) &&
5035 +- !rt2x00_rf(rt2x00dev, RF5390)) {
5036 +- ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
5037 ++ switch (rt2x00dev->chip.rf) {
5038 ++ case RF2820:
5039 ++ case RF2850:
5040 ++ case RF2720:
5041 ++ case RF2750:
5042 ++ case RF3020:
5043 ++ case RF2020:
5044 ++ case RF3021:
5045 ++ case RF3022:
5046 ++ case RF3052:
5047 ++ case RF3320:
5048 ++ case RF5370:
5049 ++ case RF5390:
5050 ++ break;
5051 ++ default:
5052 ++ ERROR(rt2x00dev, "Invalid RF chipset 0x%x detected.\n",
5053 ++ rt2x00dev->chip.rf);
5054 + return -ENODEV;
5055 + }
5056 +
5057 +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
5058 +index ba82c97..6e7fe94 100644
5059 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c
5060 ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c
5061 +@@ -477,8 +477,10 @@ static void rt2800usb_work_txdone(struct work_struct *work)
5062 + while (!rt2x00queue_empty(queue)) {
5063 + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
5064 +
5065 +- if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
5066 ++ if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
5067 ++ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
5068 + break;
5069 ++
5070 + if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
5071 + rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
5072 + else if (rt2x00queue_status_timeout(entry))
5073 +diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
5074 +index 241a099..54f0b13 100644
5075 +--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
5076 ++++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
5077 +@@ -870,18 +870,8 @@ int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state)
5078 + {
5079 + struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
5080 + struct rt2x00_dev *rt2x00dev = hw->priv;
5081 +- int retval;
5082 +-
5083 +- retval = rt2x00lib_suspend(rt2x00dev, state);
5084 +- if (retval)
5085 +- return retval;
5086 +
5087 +- /*
5088 +- * Decrease usbdev refcount.
5089 +- */
5090 +- usb_put_dev(interface_to_usbdev(usb_intf));
5091 +-
5092 +- return 0;
5093 ++ return rt2x00lib_suspend(rt2x00dev, state);
5094 + }
5095 + EXPORT_SYMBOL_GPL(rt2x00usb_suspend);
5096 +
5097 +@@ -890,8 +880,6 @@ int rt2x00usb_resume(struct usb_interface *usb_intf)
5098 + struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
5099 + struct rt2x00_dev *rt2x00dev = hw->priv;
5100 +
5101 +- usb_get_dev(interface_to_usbdev(usb_intf));
5102 +-
5103 + return rt2x00lib_resume(rt2x00dev);
5104 + }
5105 + EXPORT_SYMBOL_GPL(rt2x00usb_resume);
5106 +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
5107 +index d2ec253..ce0444c 100644
5108 +--- a/drivers/net/wireless/rtlwifi/core.c
5109 ++++ b/drivers/net/wireless/rtlwifi/core.c
5110 +@@ -610,6 +610,11 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
5111 +
5112 + mac->link_state = MAC80211_NOLINK;
5113 + memset(mac->bssid, 0, 6);
5114 ++
5115 ++ /* reset sec info */
5116 ++ rtl_cam_reset_sec_info(hw);
5117 ++
5118 ++ rtl_cam_reset_all_entry(hw);
5119 + mac->vendor = PEER_UNKNOWN;
5120 +
5121 + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
5122 +@@ -1063,6 +1068,9 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
5123 + *or clear all entry here.
5124 + */
5125 + rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
5126 ++
5127 ++ rtl_cam_reset_sec_info(hw);
5128 ++
5129 + break;
5130 + default:
5131 + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
5132 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5133 +index 3a92ba3..10b2ef0 100644
5134 +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5135 ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5136 +@@ -549,15 +549,16 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
5137 + (tcb_desc->rts_use_shortpreamble ? 1 : 0)
5138 + : (tcb_desc->rts_use_shortgi ? 1 : 0)));
5139 + if (mac->bw_40) {
5140 +- if (tcb_desc->packet_bw) {
5141 ++ if (rate_flag & IEEE80211_TX_RC_DUP_DATA) {
5142 + SET_TX_DESC_DATA_BW(txdesc, 1);
5143 + SET_TX_DESC_DATA_SC(txdesc, 3);
5144 ++ } else if(rate_flag & IEEE80211_TX_RC_40_MHZ_WIDTH){
5145 ++ SET_TX_DESC_DATA_BW(txdesc, 1);
5146 ++ SET_TX_DESC_DATA_SC(txdesc, mac->cur_40_prime_sc);
5147 + } else {
5148 + SET_TX_DESC_DATA_BW(txdesc, 0);
5149 +- if (rate_flag & IEEE80211_TX_RC_DUP_DATA)
5150 +- SET_TX_DESC_DATA_SC(txdesc,
5151 +- mac->cur_40_prime_sc);
5152 +- }
5153 ++ SET_TX_DESC_DATA_SC(txdesc, 0);
5154 ++ }
5155 + } else {
5156 + SET_TX_DESC_DATA_BW(txdesc, 0);
5157 + SET_TX_DESC_DATA_SC(txdesc, 0);
5158 +diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
5159 +index a9367eb..e4272b9 100644
5160 +--- a/drivers/net/wireless/rtlwifi/usb.c
5161 ++++ b/drivers/net/wireless/rtlwifi/usb.c
5162 +@@ -861,6 +861,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb,
5163 + u8 tid = 0;
5164 + u16 seq_number = 0;
5165 +
5166 ++ memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
5167 + if (ieee80211_is_auth(fc)) {
5168 + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n"));
5169 + rtl_ips_nic_on(hw);
5170 +diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
5171 +index 3dc9bef..6dcc7e2 100644
5172 +--- a/drivers/pci/dmar.c
5173 ++++ b/drivers/pci/dmar.c
5174 +@@ -1388,7 +1388,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
5175 + return ret;
5176 + }
5177 +
5178 +- ret = request_irq(irq, dmar_fault, 0, iommu->name, iommu);
5179 ++ ret = request_irq(irq, dmar_fault, IRQF_NO_THREAD, iommu->name, iommu);
5180 + if (ret)
5181 + printk(KERN_ERR "IOMMU: can't request irq\n");
5182 + return ret;
5183 +diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
5184 +index ee89358..ebe77dd 100644
5185 +--- a/drivers/rapidio/rio-scan.c
5186 ++++ b/drivers/rapidio/rio-scan.c
5187 +@@ -505,8 +505,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
5188 + rdev->dev.dma_mask = &rdev->dma_mask;
5189 + rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
5190 +
5191 +- if ((rdev->pef & RIO_PEF_INB_DOORBELL) &&
5192 +- (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
5193 ++ if (rdev->dst_ops & RIO_DST_OPS_DOORBELL)
5194 + rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
5195 + 0, 0xffff);
5196 +
5197 +diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
5198 +index 55dd4e6..425aab3 100644
5199 +--- a/drivers/regulator/tps65910-regulator.c
5200 ++++ b/drivers/regulator/tps65910-regulator.c
5201 +@@ -759,8 +759,13 @@ static int tps65910_list_voltage_dcdc(struct regulator_dev *dev,
5202 + mult = (selector / VDD1_2_NUM_VOLTS) + 1;
5203 + volt = VDD1_2_MIN_VOLT +
5204 + (selector % VDD1_2_NUM_VOLTS) * VDD1_2_OFFSET;
5205 ++ break;
5206 + case TPS65911_REG_VDDCTRL:
5207 + volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET);
5208 ++ break;
5209 ++ default:
5210 ++ BUG();
5211 ++ return -EINVAL;
5212 + }
5213 +
5214 + return volt * 100 * mult;
5215 +@@ -898,9 +903,11 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
5216 + case TPS65910:
5217 + pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
5218 + info = tps65910_regs;
5219 ++ break;
5220 + case TPS65911:
5221 + pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
5222 + info = tps65911_regs;
5223 ++ break;
5224 + default:
5225 + pr_err("Invalid tps chip version\n");
5226 + return -ENODEV;
5227 +diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
5228 +index 3195dbd..eb4c883 100644
5229 +--- a/drivers/rtc/interface.c
5230 ++++ b/drivers/rtc/interface.c
5231 +@@ -708,7 +708,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
5232 + int err = 0;
5233 + unsigned long flags;
5234 +
5235 +- if (freq <= 0 || freq > 5000)
5236 ++ if (freq <= 0 || freq > RTC_MAX_FREQ)
5237 + return -EINVAL;
5238 + retry:
5239 + spin_lock_irqsave(&rtc->irq_task_lock, flags);
5240 +diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
5241 +index 5c4e741..68be6e1 100644
5242 +--- a/drivers/s390/cio/qdio_thinint.c
5243 ++++ b/drivers/s390/cio/qdio_thinint.c
5244 +@@ -95,9 +95,11 @@ void tiqdio_remove_input_queues(struct qdio_irq *irq_ptr)
5245 + }
5246 + }
5247 +
5248 +-static inline u32 shared_ind_set(void)
5249 ++static inline u32 clear_shared_ind(void)
5250 + {
5251 +- return q_indicators[TIQDIO_SHARED_IND].ind;
5252 ++ if (!atomic_read(&q_indicators[TIQDIO_SHARED_IND].count))
5253 ++ return 0;
5254 ++ return xchg(&q_indicators[TIQDIO_SHARED_IND].ind, 0);
5255 + }
5256 +
5257 + /**
5258 +@@ -107,7 +109,7 @@ static inline u32 shared_ind_set(void)
5259 + */
5260 + static void tiqdio_thinint_handler(void *alsi, void *data)
5261 + {
5262 +- u32 si_used = shared_ind_set();
5263 ++ u32 si_used = clear_shared_ind();
5264 + struct qdio_q *q;
5265 +
5266 + last_ai_time = S390_lowcore.int_clock;
5267 +@@ -150,13 +152,6 @@ static void tiqdio_thinint_handler(void *alsi, void *data)
5268 + qperf_inc(q, adapter_int);
5269 + }
5270 + rcu_read_unlock();
5271 +-
5272 +- /*
5273 +- * If the shared indicator was used clear it now after all queues
5274 +- * were processed.
5275 +- */
5276 +- if (si_used && shared_ind_set())
5277 +- xchg(&q_indicators[TIQDIO_SHARED_IND].ind, 0);
5278 + }
5279 +
5280 + static int set_subchannel_ind(struct qdio_irq *irq_ptr, int reset)
5281 +diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
5282 +index b7bd5b0..3868ab2 100644
5283 +--- a/drivers/scsi/3w-9xxx.c
5284 ++++ b/drivers/scsi/3w-9xxx.c
5285 +@@ -1800,10 +1800,12 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
5286 + switch (retval) {
5287 + case SCSI_MLQUEUE_HOST_BUSY:
5288 + twa_free_request_id(tw_dev, request_id);
5289 ++ twa_unmap_scsi_data(tw_dev, request_id);
5290 + break;
5291 + case 1:
5292 + tw_dev->state[request_id] = TW_S_COMPLETED;
5293 + twa_free_request_id(tw_dev, request_id);
5294 ++ twa_unmap_scsi_data(tw_dev, request_id);
5295 + SCpnt->result = (DID_ERROR << 16);
5296 + done(SCpnt);
5297 + retval = 0;
5298 +diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
5299 +index 3c08f53..6153a66 100644
5300 +--- a/drivers/scsi/Makefile
5301 ++++ b/drivers/scsi/Makefile
5302 +@@ -88,7 +88,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
5303 + obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
5304 + obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
5305 + obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
5306 +-obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/
5307 ++obj-$(CONFIG_SCSI_QLA_ISCSI) += libiscsi.o qla4xxx/
5308 + obj-$(CONFIG_SCSI_LPFC) += lpfc/
5309 + obj-$(CONFIG_SCSI_BFA_FC) += bfa/
5310 + obj-$(CONFIG_SCSI_PAS16) += pas16.o
5311 +diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
5312 +index e7d0d47..e5f2d7d 100644
5313 +--- a/drivers/scsi/aacraid/commsup.c
5314 ++++ b/drivers/scsi/aacraid/commsup.c
5315 +@@ -1283,6 +1283,8 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced)
5316 + kfree(aac->queues);
5317 + aac->queues = NULL;
5318 + free_irq(aac->pdev->irq, aac);
5319 ++ if (aac->msi)
5320 ++ pci_disable_msi(aac->pdev);
5321 + kfree(aac->fsa_dev);
5322 + aac->fsa_dev = NULL;
5323 + quirks = aac_get_driver_ident(index)->quirks;
5324 +diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
5325 +index 0a404bf..856fcbf 100644
5326 +--- a/drivers/scsi/bnx2fc/bnx2fc.h
5327 ++++ b/drivers/scsi/bnx2fc/bnx2fc.h
5328 +@@ -152,7 +152,6 @@ struct bnx2fc_percpu_s {
5329 + spinlock_t fp_work_lock;
5330 + };
5331 +
5332 +-
5333 + struct bnx2fc_hba {
5334 + struct list_head link;
5335 + struct cnic_dev *cnic;
5336 +@@ -179,6 +178,7 @@ struct bnx2fc_hba {
5337 + #define BNX2FC_CTLR_INIT_DONE 1
5338 + #define BNX2FC_CREATE_DONE 2
5339 + struct fcoe_ctlr ctlr;
5340 ++ struct list_head vports;
5341 + u8 vlan_enabled;
5342 + int vlan_id;
5343 + u32 next_conn_id;
5344 +@@ -232,6 +232,11 @@ struct bnx2fc_hba {
5345 +
5346 + #define bnx2fc_from_ctlr(fip) container_of(fip, struct bnx2fc_hba, ctlr)
5347 +
5348 ++struct bnx2fc_lport {
5349 ++ struct list_head list;
5350 ++ struct fc_lport *lport;
5351 ++};
5352 ++
5353 + struct bnx2fc_cmd_mgr {
5354 + struct bnx2fc_hba *hba;
5355 + u16 next_idx;
5356 +@@ -423,6 +428,7 @@ struct bnx2fc_work {
5357 + struct bnx2fc_unsol_els {
5358 + struct fc_lport *lport;
5359 + struct fc_frame *fp;
5360 ++ struct bnx2fc_hba *hba;
5361 + struct work_struct unsol_els_work;
5362 + };
5363 +
5364 +diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5365 +index ab255fb..bdf62a5 100644
5366 +--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5367 ++++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5368 +@@ -1225,6 +1225,7 @@ static int bnx2fc_interface_setup(struct bnx2fc_hba *hba,
5369 + hba->ctlr.get_src_addr = bnx2fc_get_src_mac;
5370 + set_bit(BNX2FC_CTLR_INIT_DONE, &hba->init_done);
5371 +
5372 ++ INIT_LIST_HEAD(&hba->vports);
5373 + rc = bnx2fc_netdev_setup(hba);
5374 + if (rc)
5375 + goto setup_err;
5376 +@@ -1261,8 +1262,15 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5377 + struct fcoe_port *port;
5378 + struct Scsi_Host *shost;
5379 + struct fc_vport *vport = dev_to_vport(parent);
5380 ++ struct bnx2fc_lport *blport;
5381 + int rc = 0;
5382 +
5383 ++ blport = kzalloc(sizeof(struct bnx2fc_lport), GFP_KERNEL);
5384 ++ if (!blport) {
5385 ++ BNX2FC_HBA_DBG(hba->ctlr.lp, "Unable to alloc bnx2fc_lport\n");
5386 ++ return NULL;
5387 ++ }
5388 ++
5389 + /* Allocate Scsi_Host structure */
5390 + if (!npiv)
5391 + lport = libfc_host_alloc(&bnx2fc_shost_template, sizeof(*port));
5392 +@@ -1271,7 +1279,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5393 +
5394 + if (!lport) {
5395 + printk(KERN_ERR PFX "could not allocate scsi host structure\n");
5396 +- return NULL;
5397 ++ goto free_blport;
5398 + }
5399 + shost = lport->host;
5400 + port = lport_priv(lport);
5401 +@@ -1327,12 +1335,20 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5402 + }
5403 +
5404 + bnx2fc_interface_get(hba);
5405 ++
5406 ++ spin_lock_bh(&hba->hba_lock);
5407 ++ blport->lport = lport;
5408 ++ list_add_tail(&blport->list, &hba->vports);
5409 ++ spin_unlock_bh(&hba->hba_lock);
5410 ++
5411 + return lport;
5412 +
5413 + shost_err:
5414 + scsi_remove_host(shost);
5415 + lp_config_err:
5416 + scsi_host_put(lport->host);
5417 ++free_blport:
5418 ++ kfree(blport);
5419 + return NULL;
5420 + }
5421 +
5422 +@@ -1348,6 +1364,7 @@ static void bnx2fc_if_destroy(struct fc_lport *lport)
5423 + {
5424 + struct fcoe_port *port = lport_priv(lport);
5425 + struct bnx2fc_hba *hba = port->priv;
5426 ++ struct bnx2fc_lport *blport, *tmp;
5427 +
5428 + BNX2FC_HBA_DBG(hba->ctlr.lp, "ENTERED bnx2fc_if_destroy\n");
5429 + /* Stop the transmit retry timer */
5430 +@@ -1372,6 +1389,15 @@ static void bnx2fc_if_destroy(struct fc_lport *lport)
5431 + /* Free memory used by statistical counters */
5432 + fc_lport_free_stats(lport);
5433 +
5434 ++ spin_lock_bh(&hba->hba_lock);
5435 ++ list_for_each_entry_safe(blport, tmp, &hba->vports, list) {
5436 ++ if (blport->lport == lport) {
5437 ++ list_del(&blport->list);
5438 ++ kfree(blport);
5439 ++ }
5440 ++ }
5441 ++ spin_unlock_bh(&hba->hba_lock);
5442 ++
5443 + /* Release Scsi_Host */
5444 + scsi_host_put(lport->host);
5445 +
5446 +diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5447 +index f756d5f..78baa46 100644
5448 +--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5449 ++++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5450 +@@ -480,16 +480,36 @@ int bnx2fc_send_session_destroy_req(struct bnx2fc_hba *hba,
5451 + return rc;
5452 + }
5453 +
5454 ++static bool is_valid_lport(struct bnx2fc_hba *hba, struct fc_lport *lport)
5455 ++{
5456 ++ struct bnx2fc_lport *blport;
5457 ++
5458 ++ spin_lock_bh(&hba->hba_lock);
5459 ++ list_for_each_entry(blport, &hba->vports, list) {
5460 ++ if (blport->lport == lport) {
5461 ++ spin_unlock_bh(&hba->hba_lock);
5462 ++ return true;
5463 ++ }
5464 ++ }
5465 ++ spin_unlock_bh(&hba->hba_lock);
5466 ++ return false;
5467 ++
5468 ++}
5469 ++
5470 ++
5471 + static void bnx2fc_unsol_els_work(struct work_struct *work)
5472 + {
5473 + struct bnx2fc_unsol_els *unsol_els;
5474 + struct fc_lport *lport;
5475 ++ struct bnx2fc_hba *hba;
5476 + struct fc_frame *fp;
5477 +
5478 + unsol_els = container_of(work, struct bnx2fc_unsol_els, unsol_els_work);
5479 + lport = unsol_els->lport;
5480 + fp = unsol_els->fp;
5481 +- fc_exch_recv(lport, fp);
5482 ++ hba = unsol_els->hba;
5483 ++ if (is_valid_lport(hba, lport))
5484 ++ fc_exch_recv(lport, fp);
5485 + kfree(unsol_els);
5486 + }
5487 +
5488 +@@ -499,6 +519,7 @@ void bnx2fc_process_l2_frame_compl(struct bnx2fc_rport *tgt,
5489 + {
5490 + struct fcoe_port *port = tgt->port;
5491 + struct fc_lport *lport = port->lport;
5492 ++ struct bnx2fc_hba *hba = port->priv;
5493 + struct bnx2fc_unsol_els *unsol_els;
5494 + struct fc_frame_header *fh;
5495 + struct fc_frame *fp;
5496 +@@ -559,6 +580,7 @@ void bnx2fc_process_l2_frame_compl(struct bnx2fc_rport *tgt,
5497 + fr_eof(fp) = FC_EOF_T;
5498 + fr_crc(fp) = cpu_to_le32(~crc);
5499 + unsol_els->lport = lport;
5500 ++ unsol_els->hba = hba;
5501 + unsol_els->fp = fp;
5502 + INIT_WORK(&unsol_els->unsol_els_work, bnx2fc_unsol_els_work);
5503 + queue_work(bnx2fc_wq, &unsol_els->unsol_els_work);
5504 +diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
5505 +index b5b5c34..454c72c 100644
5506 +--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
5507 ++++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
5508 +@@ -1734,7 +1734,6 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
5509 + printk(KERN_ERR PFX "SCp.ptr is NULL\n");
5510 + return;
5511 + }
5512 +- io_req->sc_cmd = NULL;
5513 +
5514 + if (io_req->on_active_queue) {
5515 + list_del_init(&io_req->link);
5516 +@@ -1754,6 +1753,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
5517 + }
5518 +
5519 + bnx2fc_unmap_sg_list(io_req);
5520 ++ io_req->sc_cmd = NULL;
5521 +
5522 + switch (io_req->fcp_status) {
5523 + case FC_GOOD:
5524 +diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5525 +index fc2cdb6..b2d6611 100644
5526 +--- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5527 ++++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5528 +@@ -913,7 +913,7 @@ static void l2t_put(struct cxgbi_sock *csk)
5529 + struct t3cdev *t3dev = (struct t3cdev *)csk->cdev->lldev;
5530 +
5531 + if (csk->l2t) {
5532 +- l2t_release(L2DATA(t3dev), csk->l2t);
5533 ++ l2t_release(t3dev, csk->l2t);
5534 + csk->l2t = NULL;
5535 + cxgbi_sock_put(csk);
5536 + }
5537 +diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
5538 +index 155d7b9..8885b3e 100644
5539 +--- a/drivers/scsi/fcoe/fcoe.c
5540 ++++ b/drivers/scsi/fcoe/fcoe.c
5541 +@@ -749,12 +749,27 @@ static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
5542 + * The offload EM that this routine is associated with will handle any
5543 + * packets that are for SCSI read requests.
5544 + *
5545 ++ * This has been enhanced to work when FCoE stack is operating in target
5546 ++ * mode.
5547 ++ *
5548 + * Returns: True for read types I/O, otherwise returns false.
5549 + */
5550 + bool fcoe_oem_match(struct fc_frame *fp)
5551 + {
5552 +- return fc_fcp_is_read(fr_fsp(fp)) &&
5553 +- (fr_fsp(fp)->data_len > fcoe_ddp_min);
5554 ++ struct fc_frame_header *fh = fc_frame_header_get(fp);
5555 ++ struct fcp_cmnd *fcp;
5556 ++
5557 ++ if (fc_fcp_is_read(fr_fsp(fp)) &&
5558 ++ (fr_fsp(fp)->data_len > fcoe_ddp_min))
5559 ++ return true;
5560 ++ else if (!(ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX)) {
5561 ++ fcp = fc_frame_payload_get(fp, sizeof(*fcp));
5562 ++ if (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN &&
5563 ++ fcp && (ntohl(fcp->fc_dl) > fcoe_ddp_min) &&
5564 ++ (fcp->fc_flags & FCP_CFL_WRDATA))
5565 ++ return true;
5566 ++ }
5567 ++ return false;
5568 + }
5569 +
5570 + /**
5571 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
5572 +index 6bba23a..78c2e20 100644
5573 +--- a/drivers/scsi/hpsa.c
5574 ++++ b/drivers/scsi/hpsa.c
5575 +@@ -676,6 +676,16 @@ static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno,
5576 + BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA);
5577 + removed[*nremoved] = h->dev[entry];
5578 + (*nremoved)++;
5579 ++
5580 ++ /*
5581 ++ * New physical devices won't have target/lun assigned yet
5582 ++ * so we need to preserve the values in the slot we are replacing.
5583 ++ */
5584 ++ if (new_entry->target == -1) {
5585 ++ new_entry->target = h->dev[entry]->target;
5586 ++ new_entry->lun = h->dev[entry]->lun;
5587 ++ }
5588 ++
5589 + h->dev[entry] = new_entry;
5590 + added[*nadded] = new_entry;
5591 + (*nadded)++;
5592 +@@ -1548,10 +1558,17 @@ static inline void hpsa_set_bus_target_lun(struct hpsa_scsi_dev_t *device,
5593 + }
5594 +
5595 + static int hpsa_update_device_info(struct ctlr_info *h,
5596 +- unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device)
5597 ++ unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
5598 ++ unsigned char *is_OBDR_device)
5599 + {
5600 +-#define OBDR_TAPE_INQ_SIZE 49
5601 ++
5602 ++#define OBDR_SIG_OFFSET 43
5603 ++#define OBDR_TAPE_SIG "$DR-10"
5604 ++#define OBDR_SIG_LEN (sizeof(OBDR_TAPE_SIG) - 1)
5605 ++#define OBDR_TAPE_INQ_SIZE (OBDR_SIG_OFFSET + OBDR_SIG_LEN)
5606 ++
5607 + unsigned char *inq_buff;
5608 ++ unsigned char *obdr_sig;
5609 +
5610 + inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
5611 + if (!inq_buff)
5612 +@@ -1583,6 +1600,16 @@ static int hpsa_update_device_info(struct ctlr_info *h,
5613 + else
5614 + this_device->raid_level = RAID_UNKNOWN;
5615 +
5616 ++ if (is_OBDR_device) {
5617 ++ /* See if this is a One-Button-Disaster-Recovery device
5618 ++ * by looking for "$DR-10" at offset 43 in inquiry data.
5619 ++ */
5620 ++ obdr_sig = &inq_buff[OBDR_SIG_OFFSET];
5621 ++ *is_OBDR_device = (this_device->devtype == TYPE_ROM &&
5622 ++ strncmp(obdr_sig, OBDR_TAPE_SIG,
5623 ++ OBDR_SIG_LEN) == 0);
5624 ++ }
5625 ++
5626 + kfree(inq_buff);
5627 + return 0;
5628 +
5629 +@@ -1716,7 +1743,7 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
5630 + return 0;
5631 + }
5632 +
5633 +- if (hpsa_update_device_info(h, scsi3addr, this_device))
5634 ++ if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
5635 + return 0;
5636 + (*nmsa2xxx_enclosures)++;
5637 + hpsa_set_bus_target_lun(this_device, bus, target, 0);
5638 +@@ -1808,7 +1835,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5639 + */
5640 + struct ReportLUNdata *physdev_list = NULL;
5641 + struct ReportLUNdata *logdev_list = NULL;
5642 +- unsigned char *inq_buff = NULL;
5643 + u32 nphysicals = 0;
5644 + u32 nlogicals = 0;
5645 + u32 ndev_allocated = 0;
5646 +@@ -1824,11 +1850,9 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5647 + GFP_KERNEL);
5648 + physdev_list = kzalloc(reportlunsize, GFP_KERNEL);
5649 + logdev_list = kzalloc(reportlunsize, GFP_KERNEL);
5650 +- inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
5651 + tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
5652 +
5653 +- if (!currentsd || !physdev_list || !logdev_list ||
5654 +- !inq_buff || !tmpdevice) {
5655 ++ if (!currentsd || !physdev_list || !logdev_list || !tmpdevice) {
5656 + dev_err(&h->pdev->dev, "out of memory\n");
5657 + goto out;
5658 + }
5659 +@@ -1863,7 +1887,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5660 + /* adjust our table of devices */
5661 + nmsa2xxx_enclosures = 0;
5662 + for (i = 0; i < nphysicals + nlogicals + 1; i++) {
5663 +- u8 *lunaddrbytes;
5664 ++ u8 *lunaddrbytes, is_OBDR = 0;
5665 +
5666 + /* Figure out where the LUN ID info is coming from */
5667 + lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
5668 +@@ -1874,7 +1898,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5669 + continue;
5670 +
5671 + /* Get device type, vendor, model, device id */
5672 +- if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice))
5673 ++ if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
5674 ++ &is_OBDR))
5675 + continue; /* skip it if we can't talk to it. */
5676 + figure_bus_target_lun(h, lunaddrbytes, &bus, &target, &lun,
5677 + tmpdevice);
5678 +@@ -1898,7 +1923,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5679 + hpsa_set_bus_target_lun(this_device, bus, target, lun);
5680 +
5681 + switch (this_device->devtype) {
5682 +- case TYPE_ROM: {
5683 ++ case TYPE_ROM:
5684 + /* We don't *really* support actual CD-ROM devices,
5685 + * just "One Button Disaster Recovery" tape drive
5686 + * which temporarily pretends to be a CD-ROM drive.
5687 +@@ -1906,15 +1931,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5688 + * device by checking for "$DR-10" in bytes 43-48 of
5689 + * the inquiry data.
5690 + */
5691 +- char obdr_sig[7];
5692 +-#define OBDR_TAPE_SIG "$DR-10"
5693 +- strncpy(obdr_sig, &inq_buff[43], 6);
5694 +- obdr_sig[6] = '\0';
5695 +- if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0)
5696 +- /* Not OBDR device, ignore it. */
5697 +- break;
5698 +- }
5699 +- ncurrent++;
5700 ++ if (is_OBDR)
5701 ++ ncurrent++;
5702 + break;
5703 + case TYPE_DISK:
5704 + if (i < nphysicals)
5705 +@@ -1947,7 +1965,6 @@ out:
5706 + for (i = 0; i < ndev_allocated; i++)
5707 + kfree(currentsd[i]);
5708 + kfree(currentsd);
5709 +- kfree(inq_buff);
5710 + kfree(physdev_list);
5711 + kfree(logdev_list);
5712 + }
5713 +diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
5714 +index 26072f1..ef46d83 100644
5715 +--- a/drivers/scsi/isci/host.c
5716 ++++ b/drivers/scsi/isci/host.c
5717 +@@ -531,6 +531,9 @@ static void sci_controller_process_completions(struct isci_host *ihost)
5718 + break;
5719 +
5720 + case SCU_COMPLETION_TYPE_EVENT:
5721 ++ sci_controller_event_completion(ihost, ent);
5722 ++ break;
5723 ++
5724 + case SCU_COMPLETION_TYPE_NOTIFY: {
5725 + event_cycle ^= ((event_get+1) & SCU_MAX_EVENTS) <<
5726 + (SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_SHIFT - SCU_MAX_EVENTS_SHIFT);
5727 +diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
5728 +index 79313a7..430fc8f 100644
5729 +--- a/drivers/scsi/isci/phy.c
5730 ++++ b/drivers/scsi/isci/phy.c
5731 +@@ -104,6 +104,7 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
5732 + u32 parity_count = 0;
5733 + u32 llctl, link_rate;
5734 + u32 clksm_value = 0;
5735 ++ u32 sp_timeouts = 0;
5736 +
5737 + iphy->link_layer_registers = reg;
5738 +
5739 +@@ -211,6 +212,18 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
5740 + llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
5741 + writel(llctl, &iphy->link_layer_registers->link_layer_control);
5742 +
5743 ++ sp_timeouts = readl(&iphy->link_layer_registers->sas_phy_timeouts);
5744 ++
5745 ++ /* Clear the default 0x36 (54us) RATE_CHANGE timeout value. */
5746 ++ sp_timeouts &= ~SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0xFF);
5747 ++
5748 ++ /* Set RATE_CHANGE timeout value to 0x3B (59us). This ensures SCU can
5749 ++ * lock with 3Gb drive when SCU max rate is set to 1.5Gb.
5750 ++ */
5751 ++ sp_timeouts |= SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0x3B);
5752 ++
5753 ++ writel(sp_timeouts, &iphy->link_layer_registers->sas_phy_timeouts);
5754 ++
5755 + if (is_a2(ihost->pdev)) {
5756 + /* Program the max ARB time for the PHY to 700us so we inter-operate with
5757 + * the PMC expander which shuts down PHYs if the expander PHY generates too
5758 +diff --git a/drivers/scsi/isci/registers.h b/drivers/scsi/isci/registers.h
5759 +index 9b266c7..00afc73 100644
5760 +--- a/drivers/scsi/isci/registers.h
5761 ++++ b/drivers/scsi/isci/registers.h
5762 +@@ -1299,6 +1299,18 @@ struct scu_transport_layer_registers {
5763 + #define SCU_AFE_XCVRCR_OFFSET 0x00DC
5764 + #define SCU_AFE_LUTCR_OFFSET 0x00E0
5765 +
5766 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_ALIGN_DETECTION_SHIFT (0UL)
5767 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_ALIGN_DETECTION_MASK (0x000000FFUL)
5768 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_HOT_PLUG_SHIFT (8UL)
5769 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_HOT_PLUG_MASK (0x0000FF00UL)
5770 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_COMSAS_DETECTION_SHIFT (16UL)
5771 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_COMSAS_DETECTION_MASK (0x00FF0000UL)
5772 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_RATE_CHANGE_SHIFT (24UL)
5773 ++#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_RATE_CHANGE_MASK (0xFF000000UL)
5774 ++
5775 ++#define SCU_SAS_PHYTOV_GEN_VAL(name, value) \
5776 ++ SCU_GEN_VALUE(SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_##name, value)
5777 ++
5778 + #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_SHIFT (0)
5779 + #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_MASK (0x00000003)
5780 + #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1 (0)
5781 +diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
5782 +index a46e07a..b5d3a8c 100644
5783 +--- a/drivers/scsi/isci/request.c
5784 ++++ b/drivers/scsi/isci/request.c
5785 +@@ -732,12 +732,20 @@ sci_io_request_terminate(struct isci_request *ireq)
5786 + sci_change_state(&ireq->sm, SCI_REQ_ABORTING);
5787 + return SCI_SUCCESS;
5788 + case SCI_REQ_TASK_WAIT_TC_RESP:
5789 ++ /* The task frame was already confirmed to have been
5790 ++ * sent by the SCU HW. Since the state machine is
5791 ++ * now only waiting for the task response itself,
5792 ++ * abort the request and complete it immediately
5793 ++ * and don't wait for the task response.
5794 ++ */
5795 + sci_change_state(&ireq->sm, SCI_REQ_ABORTING);
5796 + sci_change_state(&ireq->sm, SCI_REQ_COMPLETED);
5797 + return SCI_SUCCESS;
5798 + case SCI_REQ_ABORTING:
5799 +- sci_change_state(&ireq->sm, SCI_REQ_COMPLETED);
5800 +- return SCI_SUCCESS;
5801 ++ /* If a request has a termination requested twice, return
5802 ++ * a failure indication, since HW confirmation of the first
5803 ++ * abort is still outstanding.
5804 ++ */
5805 + case SCI_REQ_COMPLETED:
5806 + default:
5807 + dev_warn(&ireq->owning_controller->pdev->dev,
5808 +@@ -2399,22 +2407,19 @@ static void isci_task_save_for_upper_layer_completion(
5809 + }
5810 + }
5811 +
5812 +-static void isci_request_process_stp_response(struct sas_task *task,
5813 +- void *response_buffer)
5814 ++static void isci_process_stp_response(struct sas_task *task, struct dev_to_host_fis *fis)
5815 + {
5816 +- struct dev_to_host_fis *d2h_reg_fis = response_buffer;
5817 + struct task_status_struct *ts = &task->task_status;
5818 + struct ata_task_resp *resp = (void *)&ts->buf[0];
5819 +
5820 +- resp->frame_len = le16_to_cpu(*(__le16 *)(response_buffer + 6));
5821 +- memcpy(&resp->ending_fis[0], response_buffer + 16, 24);
5822 ++ resp->frame_len = sizeof(*fis);
5823 ++ memcpy(resp->ending_fis, fis, sizeof(*fis));
5824 + ts->buf_valid_size = sizeof(*resp);
5825 +
5826 +- /**
5827 +- * If the device fault bit is set in the status register, then
5828 ++ /* If the device fault bit is set in the status register, then
5829 + * set the sense data and return.
5830 + */
5831 +- if (d2h_reg_fis->status & ATA_DF)
5832 ++ if (fis->status & ATA_DF)
5833 + ts->stat = SAS_PROTO_RESPONSE;
5834 + else
5835 + ts->stat = SAM_STAT_GOOD;
5836 +@@ -2428,7 +2433,6 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
5837 + {
5838 + struct sas_task *task = isci_request_access_task(request);
5839 + struct ssp_response_iu *resp_iu;
5840 +- void *resp_buf;
5841 + unsigned long task_flags;
5842 + struct isci_remote_device *idev = isci_lookup_device(task->dev);
5843 + enum service_response response = SAS_TASK_UNDELIVERED;
5844 +@@ -2565,9 +2569,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
5845 + task);
5846 +
5847 + if (sas_protocol_ata(task->task_proto)) {
5848 +- resp_buf = &request->stp.rsp;
5849 +- isci_request_process_stp_response(task,
5850 +- resp_buf);
5851 ++ isci_process_stp_response(task, &request->stp.rsp);
5852 + } else if (SAS_PROTOCOL_SSP == task->task_proto) {
5853 +
5854 + /* crack the iu response buffer. */
5855 +diff --git a/drivers/scsi/isci/unsolicited_frame_control.c b/drivers/scsi/isci/unsolicited_frame_control.c
5856 +index e9e1e2a..16f88ab 100644
5857 +--- a/drivers/scsi/isci/unsolicited_frame_control.c
5858 ++++ b/drivers/scsi/isci/unsolicited_frame_control.c
5859 +@@ -72,7 +72,7 @@ int sci_unsolicited_frame_control_construct(struct isci_host *ihost)
5860 + */
5861 + buf_len = SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
5862 + header_len = SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header);
5863 +- size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(dma_addr_t);
5864 ++ size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(uf_control->address_table.array[0]);
5865 +
5866 + /*
5867 + * The Unsolicited Frame buffers are set at the start of the UF
5868 +diff --git a/drivers/scsi/isci/unsolicited_frame_control.h b/drivers/scsi/isci/unsolicited_frame_control.h
5869 +index 31cb950..75d8966 100644
5870 +--- a/drivers/scsi/isci/unsolicited_frame_control.h
5871 ++++ b/drivers/scsi/isci/unsolicited_frame_control.h
5872 +@@ -214,7 +214,7 @@ struct sci_uf_address_table_array {
5873 + * starting address of the UF address table.
5874 + * 64-bit pointers are required by the hardware.
5875 + */
5876 +- dma_addr_t *array;
5877 ++ u64 *array;
5878 +
5879 + /**
5880 + * This field specifies the physical address location for the UF
5881 +diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
5882 +index 3df9853..7724414 100644
5883 +--- a/drivers/scsi/iscsi_tcp.c
5884 ++++ b/drivers/scsi/iscsi_tcp.c
5885 +@@ -107,10 +107,12 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
5886 + * If the socket is in CLOSE or CLOSE_WAIT we should
5887 + * not close the connection if there is still some
5888 + * data pending.
5889 ++ *
5890 ++ * Must be called with sk_callback_lock.
5891 + */
5892 + static inline int iscsi_sw_sk_state_check(struct sock *sk)
5893 + {
5894 +- struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
5895 ++ struct iscsi_conn *conn = sk->sk_user_data;
5896 +
5897 + if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
5898 + !atomic_read(&sk->sk_rmem_alloc)) {
5899 +@@ -123,11 +125,17 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
5900 +
5901 + static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag)
5902 + {
5903 +- struct iscsi_conn *conn = sk->sk_user_data;
5904 +- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
5905 ++ struct iscsi_conn *conn;
5906 ++ struct iscsi_tcp_conn *tcp_conn;
5907 + read_descriptor_t rd_desc;
5908 +
5909 + read_lock(&sk->sk_callback_lock);
5910 ++ conn = sk->sk_user_data;
5911 ++ if (!conn) {
5912 ++ read_unlock(&sk->sk_callback_lock);
5913 ++ return;
5914 ++ }
5915 ++ tcp_conn = conn->dd_data;
5916 +
5917 + /*
5918 + * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
5919 +@@ -141,11 +149,10 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag)
5920 +
5921 + iscsi_sw_sk_state_check(sk);
5922 +
5923 +- read_unlock(&sk->sk_callback_lock);
5924 +-
5925 + /* If we had to (atomically) map a highmem page,
5926 + * unmap it now. */
5927 + iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
5928 ++ read_unlock(&sk->sk_callback_lock);
5929 + }
5930 +
5931 + static void iscsi_sw_tcp_state_change(struct sock *sk)
5932 +@@ -157,8 +164,11 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
5933 + void (*old_state_change)(struct sock *);
5934 +
5935 + read_lock(&sk->sk_callback_lock);
5936 +-
5937 +- conn = (struct iscsi_conn*)sk->sk_user_data;
5938 ++ conn = sk->sk_user_data;
5939 ++ if (!conn) {
5940 ++ read_unlock(&sk->sk_callback_lock);
5941 ++ return;
5942 ++ }
5943 + session = conn->session;
5944 +
5945 + iscsi_sw_sk_state_check(sk);
5946 +@@ -178,11 +188,25 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
5947 + **/
5948 + static void iscsi_sw_tcp_write_space(struct sock *sk)
5949 + {
5950 +- struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
5951 +- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
5952 +- struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
5953 ++ struct iscsi_conn *conn;
5954 ++ struct iscsi_tcp_conn *tcp_conn;
5955 ++ struct iscsi_sw_tcp_conn *tcp_sw_conn;
5956 ++ void (*old_write_space)(struct sock *);
5957 ++
5958 ++ read_lock_bh(&sk->sk_callback_lock);
5959 ++ conn = sk->sk_user_data;
5960 ++ if (!conn) {
5961 ++ read_unlock_bh(&sk->sk_callback_lock);
5962 ++ return;
5963 ++ }
5964 ++
5965 ++ tcp_conn = conn->dd_data;
5966 ++ tcp_sw_conn = tcp_conn->dd_data;
5967 ++ old_write_space = tcp_sw_conn->old_write_space;
5968 ++ read_unlock_bh(&sk->sk_callback_lock);
5969 ++
5970 ++ old_write_space(sk);
5971 +
5972 +- tcp_sw_conn->old_write_space(sk);
5973 + ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n");
5974 + iscsi_conn_queue_work(conn);
5975 + }
5976 +@@ -592,20 +616,17 @@ static void iscsi_sw_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
5977 + /* userspace may have goofed up and not bound us */
5978 + if (!sock)
5979 + return;
5980 +- /*
5981 +- * Make sure our recv side is stopped.
5982 +- * Older tools called conn stop before ep_disconnect
5983 +- * so IO could still be coming in.
5984 +- */
5985 +- write_lock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock);
5986 +- set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
5987 +- write_unlock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock);
5988 +
5989 + sock->sk->sk_err = EIO;
5990 + wake_up_interruptible(sk_sleep(sock->sk));
5991 +
5992 +- iscsi_conn_stop(cls_conn, flag);
5993 ++ /* stop xmit side */
5994 ++ iscsi_suspend_tx(conn);
5995 ++
5996 ++ /* stop recv side and release socket */
5997 + iscsi_sw_tcp_release_conn(conn);
5998 ++
5999 ++ iscsi_conn_stop(cls_conn, flag);
6000 + }
6001 +
6002 + static int
6003 +diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
6004 +index 49e1ccc..3b66937 100644
6005 +--- a/drivers/scsi/libfc/fc_rport.c
6006 ++++ b/drivers/scsi/libfc/fc_rport.c
6007 +@@ -801,6 +801,20 @@ static void fc_rport_recv_flogi_req(struct fc_lport *lport,
6008 +
6009 + switch (rdata->rp_state) {
6010 + case RPORT_ST_INIT:
6011 ++ /*
6012 ++ * If received the FLOGI request on RPORT which is INIT state
6013 ++ * (means not transition to FLOGI either fc_rport timeout
6014 ++ * function didn;t trigger or this end hasn;t received
6015 ++ * beacon yet from other end. In that case only, allow RPORT
6016 ++ * state machine to continue, otherwise fall through which
6017 ++ * causes the code to send reject response.
6018 ++ * NOTE; Not checking for FIP->state such as VNMP_UP or
6019 ++ * VNMP_CLAIM because if FIP state is not one of those,
6020 ++ * RPORT wouldn;t have created and 'rport_lookup' would have
6021 ++ * failed anyway in that case.
6022 ++ */
6023 ++ if (lport->point_to_multipoint)
6024 ++ break;
6025 + case RPORT_ST_DELETE:
6026 + mutex_unlock(&rdata->rp_mutex);
6027 + rjt_data.reason = ELS_RJT_FIP;
6028 +diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
6029 +index e98ae33..09b232f 100644
6030 +--- a/drivers/scsi/libiscsi_tcp.c
6031 ++++ b/drivers/scsi/libiscsi_tcp.c
6032 +@@ -1084,7 +1084,8 @@ iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
6033 + struct iscsi_cls_conn *cls_conn;
6034 + struct iscsi_tcp_conn *tcp_conn;
6035 +
6036 +- cls_conn = iscsi_conn_setup(cls_session, sizeof(*tcp_conn), conn_idx);
6037 ++ cls_conn = iscsi_conn_setup(cls_session,
6038 ++ sizeof(*tcp_conn) + dd_data_size, conn_idx);
6039 + if (!cls_conn)
6040 + return NULL;
6041 + conn = cls_conn->dd_data;
6042 +@@ -1096,22 +1097,13 @@ iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
6043 +
6044 + tcp_conn = conn->dd_data;
6045 + tcp_conn->iscsi_conn = conn;
6046 +-
6047 +- tcp_conn->dd_data = kzalloc(dd_data_size, GFP_KERNEL);
6048 +- if (!tcp_conn->dd_data) {
6049 +- iscsi_conn_teardown(cls_conn);
6050 +- return NULL;
6051 +- }
6052 ++ tcp_conn->dd_data = conn->dd_data + sizeof(*tcp_conn);
6053 + return cls_conn;
6054 + }
6055 + EXPORT_SYMBOL_GPL(iscsi_tcp_conn_setup);
6056 +
6057 + void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn)
6058 + {
6059 +- struct iscsi_conn *conn = cls_conn->dd_data;
6060 +- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
6061 +-
6062 +- kfree(tcp_conn->dd_data);
6063 + iscsi_conn_teardown(cls_conn);
6064 + }
6065 + EXPORT_SYMBOL_GPL(iscsi_tcp_conn_teardown);
6066 +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
6067 +index f84084b..c9e3dc0 100644
6068 +--- a/drivers/scsi/libsas/sas_expander.c
6069 ++++ b/drivers/scsi/libsas/sas_expander.c
6070 +@@ -1721,7 +1721,7 @@ static int sas_find_bcast_dev(struct domain_device *dev,
6071 + list_for_each_entry(ch, &ex->children, siblings) {
6072 + if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) {
6073 + res = sas_find_bcast_dev(ch, src_dev);
6074 +- if (src_dev)
6075 ++ if (*src_dev)
6076 + return res;
6077 + }
6078 + }
6079 +diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
6080 +index 8ec2c86..0441361 100644
6081 +--- a/drivers/scsi/lpfc/lpfc.h
6082 ++++ b/drivers/scsi/lpfc/lpfc.h
6083 +@@ -20,6 +20,11 @@
6084 + *******************************************************************/
6085 +
6086 + #include <scsi/scsi_host.h>
6087 ++
6088 ++#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
6089 ++#define CONFIG_SCSI_LPFC_DEBUG_FS
6090 ++#endif
6091 ++
6092 + struct lpfc_sli2_slim;
6093 +
6094 + #define LPFC_PCI_DEV_LP 0x1
6095 +@@ -465,9 +470,10 @@ enum intr_type_t {
6096 + struct unsol_rcv_ct_ctx {
6097 + uint32_t ctxt_id;
6098 + uint32_t SID;
6099 +- uint32_t oxid;
6100 + uint32_t flags;
6101 + #define UNSOL_VALID 0x00000001
6102 ++ uint16_t oxid;
6103 ++ uint16_t rxid;
6104 + };
6105 +
6106 + #define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
6107 +diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
6108 +index 135a53b..80ca11c 100644
6109 +--- a/drivers/scsi/lpfc/lpfc_attr.c
6110 ++++ b/drivers/scsi/lpfc/lpfc_attr.c
6111 +@@ -755,6 +755,47 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
6112 + }
6113 +
6114 + /**
6115 ++ * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
6116 ++ * @phba: lpfc_hba pointer.
6117 ++ *
6118 ++ * Description:
6119 ++ * SLI4 interface type-2 device to wait on the sliport status register for
6120 ++ * the readyness after performing a firmware reset.
6121 ++ *
6122 ++ * Returns:
6123 ++ * zero for success
6124 ++ **/
6125 ++static int
6126 ++lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
6127 ++{
6128 ++ struct lpfc_register portstat_reg;
6129 ++ int i;
6130 ++
6131 ++
6132 ++ lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
6133 ++ &portstat_reg.word0);
6134 ++
6135 ++ /* wait for the SLI port firmware ready after firmware reset */
6136 ++ for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
6137 ++ msleep(10);
6138 ++ lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
6139 ++ &portstat_reg.word0);
6140 ++ if (!bf_get(lpfc_sliport_status_err, &portstat_reg))
6141 ++ continue;
6142 ++ if (!bf_get(lpfc_sliport_status_rn, &portstat_reg))
6143 ++ continue;
6144 ++ if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg))
6145 ++ continue;
6146 ++ break;
6147 ++ }
6148 ++
6149 ++ if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT)
6150 ++ return 0;
6151 ++ else
6152 ++ return -EIO;
6153 ++}
6154 ++
6155 ++/**
6156 + * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
6157 + * @phba: lpfc_hba pointer.
6158 + *
6159 +@@ -805,7 +846,10 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
6160 + readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
6161 +
6162 + /* delay driver action following IF_TYPE_2 reset */
6163 +- msleep(100);
6164 ++ rc = lpfc_sli4_pdev_status_reg_wait(phba);
6165 ++
6166 ++ if (rc)
6167 ++ return -EIO;
6168 +
6169 + init_completion(&online_compl);
6170 + rc = lpfc_workq_post_event(phba, &status, &online_compl,
6171 +@@ -895,6 +939,10 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
6172 +
6173 + if (!phba->cfg_enable_hba_reset)
6174 + return -EACCES;
6175 ++
6176 ++ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6177 ++ "3050 lpfc_board_mode set to %s\n", buf);
6178 ++
6179 + init_completion(&online_compl);
6180 +
6181 + if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
6182 +@@ -1290,6 +1338,10 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr,
6183 + if (phba->sli_rev == LPFC_SLI_REV4)
6184 + val = 0;
6185 +
6186 ++ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6187 ++ "3051 lpfc_poll changed from %d to %d\n",
6188 ++ phba->cfg_poll, val);
6189 ++
6190 + spin_lock_irq(&phba->hbalock);
6191 +
6192 + old_val = phba->cfg_poll;
6193 +@@ -1414,80 +1466,10 @@ lpfc_sriov_hw_max_virtfn_show(struct device *dev,
6194 + struct Scsi_Host *shost = class_to_shost(dev);
6195 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
6196 + struct lpfc_hba *phba = vport->phba;
6197 +- struct pci_dev *pdev = phba->pcidev;
6198 +- union lpfc_sli4_cfg_shdr *shdr;
6199 +- uint32_t shdr_status, shdr_add_status;
6200 +- LPFC_MBOXQ_t *mboxq;
6201 +- struct lpfc_mbx_get_prof_cfg *get_prof_cfg;
6202 +- struct lpfc_rsrc_desc_pcie *desc;
6203 +- uint32_t max_nr_virtfn;
6204 +- uint32_t desc_count;
6205 +- int length, rc, i;
6206 +-
6207 +- if ((phba->sli_rev < LPFC_SLI_REV4) ||
6208 +- (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
6209 +- LPFC_SLI_INTF_IF_TYPE_2))
6210 +- return -EPERM;
6211 +-
6212 +- if (!pdev->is_physfn)
6213 +- return snprintf(buf, PAGE_SIZE, "%d\n", 0);
6214 +-
6215 +- mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
6216 +- if (!mboxq)
6217 +- return -ENOMEM;
6218 ++ uint16_t max_nr_virtfn;
6219 +
6220 +- /* get the maximum number of virtfn support by physfn */
6221 +- length = (sizeof(struct lpfc_mbx_get_prof_cfg) -
6222 +- sizeof(struct lpfc_sli4_cfg_mhdr));
6223 +- lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
6224 +- LPFC_MBOX_OPCODE_GET_PROFILE_CONFIG,
6225 +- length, LPFC_SLI4_MBX_EMBED);
6226 +- shdr = (union lpfc_sli4_cfg_shdr *)
6227 +- &mboxq->u.mqe.un.sli4_config.header.cfg_shdr;
6228 +- bf_set(lpfc_mbox_hdr_pf_num, &shdr->request,
6229 +- phba->sli4_hba.iov.pf_number + 1);
6230 +-
6231 +- get_prof_cfg = &mboxq->u.mqe.un.get_prof_cfg;
6232 +- bf_set(lpfc_mbx_get_prof_cfg_prof_tp, &get_prof_cfg->u.request,
6233 +- LPFC_CFG_TYPE_CURRENT_ACTIVE);
6234 +-
6235 +- rc = lpfc_sli_issue_mbox_wait(phba, mboxq,
6236 +- lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG));
6237 +-
6238 +- if (rc != MBX_TIMEOUT) {
6239 +- /* check return status */
6240 +- shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
6241 +- shdr_add_status = bf_get(lpfc_mbox_hdr_add_status,
6242 +- &shdr->response);
6243 +- if (shdr_status || shdr_add_status || rc)
6244 +- goto error_out;
6245 +-
6246 +- } else
6247 +- goto error_out;
6248 +-
6249 +- desc_count = get_prof_cfg->u.response.prof_cfg.rsrc_desc_count;
6250 +-
6251 +- for (i = 0; i < LPFC_RSRC_DESC_MAX_NUM; i++) {
6252 +- desc = (struct lpfc_rsrc_desc_pcie *)
6253 +- &get_prof_cfg->u.response.prof_cfg.desc[i];
6254 +- if (LPFC_RSRC_DESC_TYPE_PCIE ==
6255 +- bf_get(lpfc_rsrc_desc_pcie_type, desc)) {
6256 +- max_nr_virtfn = bf_get(lpfc_rsrc_desc_pcie_nr_virtfn,
6257 +- desc);
6258 +- break;
6259 +- }
6260 +- }
6261 +-
6262 +- if (i < LPFC_RSRC_DESC_MAX_NUM) {
6263 +- if (rc != MBX_TIMEOUT)
6264 +- mempool_free(mboxq, phba->mbox_mem_pool);
6265 +- return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
6266 +- }
6267 +-
6268 +-error_out:
6269 +- if (rc != MBX_TIMEOUT)
6270 +- mempool_free(mboxq, phba->mbox_mem_pool);
6271 +- return -EIO;
6272 ++ max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
6273 ++ return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
6274 + }
6275 +
6276 + /**
6277 +@@ -1605,6 +1587,9 @@ static int \
6278 + lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
6279 + { \
6280 + if (val >= minval && val <= maxval) {\
6281 ++ lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
6282 ++ "3052 lpfc_" #attr " changed from %d to %d\n", \
6283 ++ phba->cfg_##attr, val); \
6284 + phba->cfg_##attr = val;\
6285 + return 0;\
6286 + }\
6287 +@@ -1762,6 +1747,9 @@ static int \
6288 + lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
6289 + { \
6290 + if (val >= minval && val <= maxval) {\
6291 ++ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
6292 ++ "3053 lpfc_" #attr " changed from %d to %d\n", \
6293 ++ vport->cfg_##attr, val); \
6294 + vport->cfg_##attr = val;\
6295 + return 0;\
6296 + }\
6297 +@@ -2678,6 +2666,9 @@ lpfc_topology_store(struct device *dev, struct device_attribute *attr,
6298 + if (nolip)
6299 + return strlen(buf);
6300 +
6301 ++ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6302 ++ "3054 lpfc_topology changed from %d to %d\n",
6303 ++ prev_val, val);
6304 + err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
6305 + if (err) {
6306 + phba->cfg_topology = prev_val;
6307 +@@ -3101,6 +3092,10 @@ lpfc_link_speed_store(struct device *dev, struct device_attribute *attr,
6308 + if (sscanf(val_buf, "%i", &val) != 1)
6309 + return -EINVAL;
6310 +
6311 ++ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6312 ++ "3055 lpfc_link_speed changed from %d to %d %s\n",
6313 ++ phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)");
6314 ++
6315 + if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
6316 + ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
6317 + ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
6318 +@@ -3678,7 +3673,9 @@ LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
6319 + # - Default will result in registering capabilities for all profiles.
6320 + #
6321 + */
6322 +-unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION;
6323 ++unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION |
6324 ++ SHOST_DIX_TYPE0_PROTECTION |
6325 ++ SHOST_DIX_TYPE1_PROTECTION;
6326 +
6327 + module_param(lpfc_prot_mask, uint, S_IRUGO);
6328 + MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask");
6329 +diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
6330 +index 7fb0ba4..f46378f 100644
6331 +--- a/drivers/scsi/lpfc/lpfc_bsg.c
6332 ++++ b/drivers/scsi/lpfc/lpfc_bsg.c
6333 +@@ -960,8 +960,10 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
6334 + evt_dat->immed_dat].oxid,
6335 + phba->ct_ctx[
6336 + evt_dat->immed_dat].SID);
6337 ++ phba->ct_ctx[evt_dat->immed_dat].rxid =
6338 ++ piocbq->iocb.ulpContext;
6339 + phba->ct_ctx[evt_dat->immed_dat].oxid =
6340 +- piocbq->iocb.ulpContext;
6341 ++ piocbq->iocb.unsli3.rcvsli3.ox_id;
6342 + phba->ct_ctx[evt_dat->immed_dat].SID =
6343 + piocbq->iocb.un.rcvels.remoteID;
6344 + phba->ct_ctx[evt_dat->immed_dat].flags = UNSOL_VALID;
6345 +@@ -1312,7 +1314,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6346 + rc = IOCB_ERROR;
6347 + goto issue_ct_rsp_exit;
6348 + }
6349 +- icmd->ulpContext = phba->ct_ctx[tag].oxid;
6350 ++ icmd->ulpContext = phba->ct_ctx[tag].rxid;
6351 ++ icmd->unsli3.rcvsli3.ox_id = phba->ct_ctx[tag].oxid;
6352 + ndlp = lpfc_findnode_did(phba->pport, phba->ct_ctx[tag].SID);
6353 + if (!ndlp) {
6354 + lpfc_printf_log(phba, KERN_WARNING, LOG_ELS,
6355 +@@ -1337,9 +1340,7 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6356 + goto issue_ct_rsp_exit;
6357 + }
6358 +
6359 +- icmd->un.ulpWord[3] = ndlp->nlp_rpi;
6360 +- if (phba->sli_rev == LPFC_SLI_REV4)
6361 +- icmd->ulpContext =
6362 ++ icmd->un.ulpWord[3] =
6363 + phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
6364 +
6365 + /* The exchange is done, mark the entry as invalid */
6366 +@@ -1351,8 +1352,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6367 +
6368 + /* Xmit CT response on exchange <xid> */
6369 + lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
6370 +- "2722 Xmit CT response on exchange x%x Data: x%x x%x\n",
6371 +- icmd->ulpContext, icmd->ulpIoTag, phba->link_state);
6372 ++ "2722 Xmit CT response on exchange x%x Data: x%x x%x x%x\n",
6373 ++ icmd->ulpContext, icmd->ulpIoTag, tag, phba->link_state);
6374 +
6375 + ctiocb->iocb_cmpl = NULL;
6376 + ctiocb->iocb_flag |= LPFC_IO_LIBDFC;
6377 +@@ -1471,13 +1472,12 @@ send_mgmt_rsp_exit:
6378 + /**
6379 + * lpfc_bsg_diag_mode_enter - process preparing into device diag loopback mode
6380 + * @phba: Pointer to HBA context object.
6381 +- * @job: LPFC_BSG_VENDOR_DIAG_MODE
6382 + *
6383 + * This function is responsible for preparing driver for diag loopback
6384 + * on device.
6385 + */
6386 + static int
6387 +-lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
6388 ++lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
6389 + {
6390 + struct lpfc_vport **vports;
6391 + struct Scsi_Host *shost;
6392 +@@ -1521,7 +1521,6 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
6393 + /**
6394 + * lpfc_bsg_diag_mode_exit - exit process from device diag loopback mode
6395 + * @phba: Pointer to HBA context object.
6396 +- * @job: LPFC_BSG_VENDOR_DIAG_MODE
6397 + *
6398 + * This function is responsible for driver exit processing of setting up
6399 + * diag loopback mode on device.
6400 +@@ -1586,7 +1585,7 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
6401 + goto job_error;
6402 + }
6403 +
6404 +- rc = lpfc_bsg_diag_mode_enter(phba, job);
6405 ++ rc = lpfc_bsg_diag_mode_enter(phba);
6406 + if (rc)
6407 + goto job_error;
6408 +
6409 +@@ -1758,7 +1757,7 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
6410 + goto job_error;
6411 + }
6412 +
6413 +- rc = lpfc_bsg_diag_mode_enter(phba, job);
6414 ++ rc = lpfc_bsg_diag_mode_enter(phba);
6415 + if (rc)
6416 + goto job_error;
6417 +
6418 +@@ -1982,7 +1981,7 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job)
6419 + goto job_error;
6420 + }
6421 +
6422 +- rc = lpfc_bsg_diag_mode_enter(phba, job);
6423 ++ rc = lpfc_bsg_diag_mode_enter(phba);
6424 + if (rc)
6425 + goto job_error;
6426 +
6427 +@@ -3511,7 +3510,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
6428 + lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
6429 + "2947 Issued SLI_CONFIG ext-buffer "
6430 + "maibox command, rc:x%x\n", rc);
6431 +- return 1;
6432 ++ return SLI_CONFIG_HANDLED;
6433 + }
6434 + lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
6435 + "2948 Failed to issue SLI_CONFIG ext-buffer "
6436 +@@ -3549,7 +3548,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
6437 + LPFC_MBOXQ_t *pmboxq = NULL;
6438 + MAILBOX_t *pmb;
6439 + uint8_t *mbx;
6440 +- int rc = 0, i;
6441 ++ int rc = SLI_CONFIG_NOT_HANDLED, i;
6442 +
6443 + mbox_req =
6444 + (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
6445 +@@ -3660,7 +3659,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
6446 + lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
6447 + "2955 Issued SLI_CONFIG ext-buffer "
6448 + "maibox command, rc:x%x\n", rc);
6449 +- return 1;
6450 ++ return SLI_CONFIG_HANDLED;
6451 + }
6452 + lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
6453 + "2956 Failed to issue SLI_CONFIG ext-buffer "
6454 +@@ -3668,6 +3667,11 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
6455 + rc = -EPIPE;
6456 + }
6457 +
6458 ++ /* wait for additoinal external buffers */
6459 ++ job->reply->result = 0;
6460 ++ job->job_done(job);
6461 ++ return SLI_CONFIG_HANDLED;
6462 ++
6463 + job_error:
6464 + if (pmboxq)
6465 + mempool_free(pmboxq, phba->mbox_mem_pool);
6466 +@@ -3959,7 +3963,7 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct fc_bsg_job *job,
6467 + lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
6468 + "2969 Issued SLI_CONFIG ext-buffer "
6469 + "maibox command, rc:x%x\n", rc);
6470 +- return 1;
6471 ++ return SLI_CONFIG_HANDLED;
6472 + }
6473 + lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
6474 + "2970 Failed to issue SLI_CONFIG ext-buffer "
6475 +@@ -4039,14 +4043,14 @@ lpfc_bsg_handle_sli_cfg_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
6476 + struct lpfc_dmabuf *dmabuf)
6477 + {
6478 + struct dfc_mbox_req *mbox_req;
6479 +- int rc;
6480 ++ int rc = SLI_CONFIG_NOT_HANDLED;
6481 +
6482 + mbox_req =
6483 + (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
6484 +
6485 + /* mbox command with/without single external buffer */
6486 + if (mbox_req->extMboxTag == 0 && mbox_req->extSeqNum == 0)
6487 +- return SLI_CONFIG_NOT_HANDLED;
6488 ++ return rc;
6489 +
6490 + /* mbox command and first external buffer */
6491 + if (phba->mbox_ext_buf_ctx.state == LPFC_BSG_MBOX_IDLE) {
6492 +@@ -4249,7 +4253,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
6493 + * mailbox extension size
6494 + */
6495 + if ((transmit_length > receive_length) ||
6496 +- (transmit_length > MAILBOX_EXT_SIZE)) {
6497 ++ (transmit_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
6498 + rc = -ERANGE;
6499 + goto job_done;
6500 + }
6501 +@@ -4272,7 +4276,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
6502 + /* receive length cannot be greater than mailbox
6503 + * extension size
6504 + */
6505 +- if (receive_length > MAILBOX_EXT_SIZE) {
6506 ++ if (receive_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
6507 + rc = -ERANGE;
6508 + goto job_done;
6509 + }
6510 +@@ -4306,7 +4310,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
6511 + bde = (struct ulp_bde64 *)&pmb->un.varWords[4];
6512 +
6513 + /* bde size cannot be greater than mailbox ext size */
6514 +- if (bde->tus.f.bdeSize > MAILBOX_EXT_SIZE) {
6515 ++ if (bde->tus.f.bdeSize >
6516 ++ BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
6517 + rc = -ERANGE;
6518 + goto job_done;
6519 + }
6520 +@@ -4332,7 +4337,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
6521 + * mailbox extension size
6522 + */
6523 + if ((receive_length == 0) ||
6524 +- (receive_length > MAILBOX_EXT_SIZE)) {
6525 ++ (receive_length >
6526 ++ BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
6527 + rc = -ERANGE;
6528 + goto job_done;
6529 + }
6530 +diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
6531 +index fc20c24..1e41af8 100644
6532 +--- a/drivers/scsi/lpfc/lpfc_crtn.h
6533 ++++ b/drivers/scsi/lpfc/lpfc_crtn.h
6534 +@@ -432,6 +432,7 @@ void lpfc_handle_rrq_active(struct lpfc_hba *);
6535 + int lpfc_send_rrq(struct lpfc_hba *, struct lpfc_node_rrq *);
6536 + int lpfc_set_rrq_active(struct lpfc_hba *, struct lpfc_nodelist *,
6537 + uint16_t, uint16_t, uint16_t);
6538 ++uint16_t lpfc_sli4_xri_inrange(struct lpfc_hba *, uint16_t);
6539 + void lpfc_cleanup_wt_rrqs(struct lpfc_hba *);
6540 + void lpfc_cleanup_vports_rrqs(struct lpfc_vport *, struct lpfc_nodelist *);
6541 + struct lpfc_node_rrq *lpfc_get_active_rrq(struct lpfc_vport *, uint16_t,
6542 +@@ -439,3 +440,4 @@ struct lpfc_node_rrq *lpfc_get_active_rrq(struct lpfc_vport *, uint16_t,
6543 + int lpfc_wr_object(struct lpfc_hba *, struct list_head *, uint32_t, uint32_t *);
6544 + /* functions to support SR-IOV */
6545 + int lpfc_sli_probe_sriov_nr_virtfn(struct lpfc_hba *, int);
6546 ++uint16_t lpfc_sli_sriov_nr_virtfn_get(struct lpfc_hba *);
6547 +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
6548 +index 32a0845..1725b81 100644
6549 +--- a/drivers/scsi/lpfc/lpfc_els.c
6550 ++++ b/drivers/scsi/lpfc/lpfc_els.c
6551 +@@ -647,21 +647,15 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
6552 + }
6553 + lpfc_cleanup_pending_mbox(vport);
6554 +
6555 +- if (phba->sli_rev == LPFC_SLI_REV4)
6556 ++ if (phba->sli_rev == LPFC_SLI_REV4) {
6557 + lpfc_sli4_unreg_all_rpis(vport);
6558 +-
6559 +- if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
6560 + lpfc_mbx_unreg_vpi(vport);
6561 + spin_lock_irq(shost->host_lock);
6562 + vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
6563 +- spin_unlock_irq(shost->host_lock);
6564 +- }
6565 +- /*
6566 +- * If VPI is unreged, driver need to do INIT_VPI
6567 +- * before re-registering
6568 +- */
6569 +- if (phba->sli_rev == LPFC_SLI_REV4) {
6570 +- spin_lock_irq(shost->host_lock);
6571 ++ /*
6572 ++ * If VPI is unreged, driver need to do INIT_VPI
6573 ++ * before re-registering
6574 ++ */
6575 + vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
6576 + spin_unlock_irq(shost->host_lock);
6577 + }
6578 +@@ -1096,11 +1090,14 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
6579 + /* Set the fcfi to the fcfi we registered with */
6580 + elsiocb->iocb.ulpContext = phba->fcf.fcfi;
6581 + }
6582 +- } else if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
6583 +- sp->cmn.request_multiple_Nport = 1;
6584 +- /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */
6585 +- icmd->ulpCt_h = 1;
6586 +- icmd->ulpCt_l = 0;
6587 ++ } else {
6588 ++ if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
6589 ++ sp->cmn.request_multiple_Nport = 1;
6590 ++ /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */
6591 ++ icmd->ulpCt_h = 1;
6592 ++ icmd->ulpCt_l = 0;
6593 ++ } else
6594 ++ sp->cmn.request_multiple_Nport = 0;
6595 + }
6596 +
6597 + if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) {
6598 +@@ -3656,7 +3653,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
6599 + }
6600 +
6601 + icmd = &elsiocb->iocb;
6602 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6603 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6604 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6605 + pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6606 + *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6607 + pcmd += sizeof(uint32_t);
6608 +@@ -3673,7 +3671,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
6609 + return 1;
6610 +
6611 + icmd = &elsiocb->iocb;
6612 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6613 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6614 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6615 + pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6616 +
6617 + if (mbox)
6618 +@@ -3695,7 +3694,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
6619 + return 1;
6620 +
6621 + icmd = &elsiocb->iocb;
6622 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6623 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6624 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6625 + pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6626 +
6627 + memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt,
6628 +@@ -3781,7 +3781,8 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
6629 +
6630 + icmd = &elsiocb->iocb;
6631 + oldcmd = &oldiocb->iocb;
6632 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6633 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6634 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6635 + pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6636 +
6637 + *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;
6638 +@@ -3853,7 +3854,8 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
6639 +
6640 + icmd = &elsiocb->iocb;
6641 + oldcmd = &oldiocb->iocb;
6642 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6643 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6644 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6645 +
6646 + /* Xmit ADISC ACC response tag <ulpIoTag> */
6647 + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6648 +@@ -3931,7 +3933,9 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
6649 +
6650 + icmd = &elsiocb->iocb;
6651 + oldcmd = &oldiocb->iocb;
6652 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6653 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6654 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6655 ++
6656 + /* Xmit PRLI ACC response tag <ulpIoTag> */
6657 + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6658 + "0131 Xmit PRLI ACC response tag x%x xri x%x, "
6659 +@@ -4035,7 +4039,9 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
6660 +
6661 + icmd = &elsiocb->iocb;
6662 + oldcmd = &oldiocb->iocb;
6663 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6664 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6665 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6666 ++
6667 + /* Xmit RNID ACC response tag <ulpIoTag> */
6668 + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6669 + "0132 Xmit RNID ACC response tag x%x xri x%x\n",
6670 +@@ -4163,7 +4169,9 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data,
6671 + if (!elsiocb)
6672 + return 1;
6673 +
6674 +- elsiocb->iocb.ulpContext = oldiocb->iocb.ulpContext; /* Xri */
6675 ++ elsiocb->iocb.ulpContext = oldiocb->iocb.ulpContext; /* Xri / rx_id */
6676 ++ elsiocb->iocb.unsli3.rcvsli3.ox_id = oldiocb->iocb.unsli3.rcvsli3.ox_id;
6677 ++
6678 + /* Xmit ECHO ACC response tag <ulpIoTag> */
6679 + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6680 + "2876 Xmit ECHO ACC response tag x%x xri x%x\n",
6681 +@@ -5054,13 +5062,15 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
6682 + uint8_t *pcmd;
6683 + struct lpfc_iocbq *elsiocb;
6684 + struct lpfc_nodelist *ndlp;
6685 +- uint16_t xri;
6686 ++ uint16_t oxid;
6687 ++ uint16_t rxid;
6688 + uint32_t cmdsize;
6689 +
6690 + mb = &pmb->u.mb;
6691 +
6692 + ndlp = (struct lpfc_nodelist *) pmb->context2;
6693 +- xri = (uint16_t) ((unsigned long)(pmb->context1));
6694 ++ rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff);
6695 ++ oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff);
6696 + pmb->context1 = NULL;
6697 + pmb->context2 = NULL;
6698 +
6699 +@@ -5082,7 +5092,8 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
6700 + return;
6701 +
6702 + icmd = &elsiocb->iocb;
6703 +- icmd->ulpContext = xri;
6704 ++ icmd->ulpContext = rxid;
6705 ++ icmd->unsli3.rcvsli3.ox_id = oxid;
6706 +
6707 + pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6708 + *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6709 +@@ -5137,13 +5148,16 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
6710 + uint8_t *pcmd;
6711 + struct lpfc_iocbq *elsiocb;
6712 + struct lpfc_nodelist *ndlp;
6713 +- uint16_t xri, status;
6714 ++ uint16_t status;
6715 ++ uint16_t oxid;
6716 ++ uint16_t rxid;
6717 + uint32_t cmdsize;
6718 +
6719 + mb = &pmb->u.mb;
6720 +
6721 + ndlp = (struct lpfc_nodelist *) pmb->context2;
6722 +- xri = (uint16_t) ((unsigned long)(pmb->context1));
6723 ++ rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff);
6724 ++ oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff);
6725 + pmb->context1 = NULL;
6726 + pmb->context2 = NULL;
6727 +
6728 +@@ -5165,7 +5179,8 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
6729 + return;
6730 +
6731 + icmd = &elsiocb->iocb;
6732 +- icmd->ulpContext = xri;
6733 ++ icmd->ulpContext = rxid;
6734 ++ icmd->unsli3.rcvsli3.ox_id = oxid;
6735 +
6736 + pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6737 + *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6738 +@@ -5238,8 +5253,9 @@ lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6739 + mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC);
6740 + if (mbox) {
6741 + lpfc_read_lnk_stat(phba, mbox);
6742 +- mbox->context1 =
6743 +- (void *)((unsigned long) cmdiocb->iocb.ulpContext);
6744 ++ mbox->context1 = (void *)((unsigned long)
6745 ++ ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) |
6746 ++ cmdiocb->iocb.ulpContext)); /* rx_id */
6747 + mbox->context2 = lpfc_nlp_get(ndlp);
6748 + mbox->vport = vport;
6749 + mbox->mbox_cmpl = lpfc_els_rsp_rls_acc;
6750 +@@ -5314,7 +5330,8 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6751 + pcmd += sizeof(uint32_t); /* Skip past command */
6752 +
6753 + /* use the command's xri in the response */
6754 +- elsiocb->iocb.ulpContext = cmdiocb->iocb.ulpContext;
6755 ++ elsiocb->iocb.ulpContext = cmdiocb->iocb.ulpContext; /* Xri / rx_id */
6756 ++ elsiocb->iocb.unsli3.rcvsli3.ox_id = cmdiocb->iocb.unsli3.rcvsli3.ox_id;
6757 +
6758 + rtv_rsp = (struct RTV_RSP *)pcmd;
6759 +
6760 +@@ -5399,8 +5416,9 @@ lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6761 + mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC);
6762 + if (mbox) {
6763 + lpfc_read_lnk_stat(phba, mbox);
6764 +- mbox->context1 =
6765 +- (void *)((unsigned long) cmdiocb->iocb.ulpContext);
6766 ++ mbox->context1 = (void *)((unsigned long)
6767 ++ ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) |
6768 ++ cmdiocb->iocb.ulpContext)); /* rx_id */
6769 + mbox->context2 = lpfc_nlp_get(ndlp);
6770 + mbox->vport = vport;
6771 + mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;
6772 +@@ -5554,7 +5572,8 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
6773 +
6774 + icmd = &elsiocb->iocb;
6775 + oldcmd = &oldiocb->iocb;
6776 +- icmd->ulpContext = oldcmd->ulpContext; /* Xri */
6777 ++ icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */
6778 ++ icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
6779 +
6780 + pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6781 + *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6782 +@@ -6586,7 +6605,7 @@ lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi)
6783 + {
6784 + struct lpfc_vport *vport;
6785 + unsigned long flags;
6786 +- int i;
6787 ++ int i = 0;
6788 +
6789 + /* The physical ports are always vpi 0 - translate is unnecessary. */
6790 + if (vpi > 0) {
6791 +@@ -6609,7 +6628,7 @@ lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi)
6792 +
6793 + spin_lock_irqsave(&phba->hbalock, flags);
6794 + list_for_each_entry(vport, &phba->port_list, listentry) {
6795 +- if (vport->vpi == vpi) {
6796 ++ if (vport->vpi == i) {
6797 + spin_unlock_irqrestore(&phba->hbalock, flags);
6798 + return vport;
6799 + }
6800 +@@ -7787,6 +7806,7 @@ lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba,
6801 + {
6802 + uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
6803 + uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri);
6804 ++ uint16_t lxri = 0;
6805 +
6806 + struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL;
6807 + unsigned long iflag = 0;
6808 +@@ -7815,7 +7835,12 @@ lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba,
6809 + }
6810 + }
6811 + spin_unlock(&phba->sli4_hba.abts_sgl_list_lock);
6812 +- sglq_entry = __lpfc_get_active_sglq(phba, xri);
6813 ++ lxri = lpfc_sli4_xri_inrange(phba, xri);
6814 ++ if (lxri == NO_XRI) {
6815 ++ spin_unlock_irqrestore(&phba->hbalock, iflag);
6816 ++ return;
6817 ++ }
6818 ++ sglq_entry = __lpfc_get_active_sglq(phba, lxri);
6819 + if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) {
6820 + spin_unlock_irqrestore(&phba->hbalock, iflag);
6821 + return;
6822 +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
6823 +index 18d0dbf..bef17e3 100644
6824 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
6825 ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
6826 +@@ -2247,7 +2247,6 @@ read_next_fcf:
6827 + spin_lock_irq(&phba->hbalock);
6828 + phba->fcf.fcf_flag |= FCF_REDISC_FOV;
6829 + spin_unlock_irq(&phba->hbalock);
6830 +- lpfc_sli4_mbox_cmd_free(phba, mboxq);
6831 + lpfc_sli4_fcf_scan_read_fcf_rec(phba,
6832 + LPFC_FCOE_FCF_GET_FIRST);
6833 + return;
6834 +@@ -2645,6 +2644,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
6835 + vport->vpi_state |= LPFC_VPI_REGISTERED;
6836 + vport->fc_flag |= FC_VFI_REGISTERED;
6837 + vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
6838 ++ vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI;
6839 + spin_unlock_irq(shost->host_lock);
6840 +
6841 + if (vport->port_state == LPFC_FABRIC_CFG_LINK) {
6842 +diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
6843 +index 9059524..df53d10 100644
6844 +--- a/drivers/scsi/lpfc/lpfc_hw.h
6845 ++++ b/drivers/scsi/lpfc/lpfc_hw.h
6846 +@@ -3470,11 +3470,16 @@ typedef struct {
6847 + or CMD_IOCB_RCV_SEQ64_CX (0xB5) */
6848 +
6849 + struct rcv_sli3 {
6850 +- uint32_t word8Rsvd;
6851 + #ifdef __BIG_ENDIAN_BITFIELD
6852 ++ uint16_t ox_id;
6853 ++ uint16_t seq_cnt;
6854 ++
6855 + uint16_t vpi;
6856 + uint16_t word9Rsvd;
6857 + #else /* __LITTLE_ENDIAN */
6858 ++ uint16_t seq_cnt;
6859 ++ uint16_t ox_id;
6860 ++
6861 + uint16_t word9Rsvd;
6862 + uint16_t vpi;
6863 + #endif
6864 +diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
6865 +index 11e26a2..7f8003b 100644
6866 +--- a/drivers/scsi/lpfc/lpfc_hw4.h
6867 ++++ b/drivers/scsi/lpfc/lpfc_hw4.h
6868 +@@ -170,15 +170,8 @@ struct lpfc_sli_intf {
6869 + #define LPFC_PCI_FUNC3 3
6870 + #define LPFC_PCI_FUNC4 4
6871 +
6872 +-/* SLI4 interface type-2 control register offsets */
6873 +-#define LPFC_CTL_PORT_SEM_OFFSET 0x400
6874 +-#define LPFC_CTL_PORT_STA_OFFSET 0x404
6875 +-#define LPFC_CTL_PORT_CTL_OFFSET 0x408
6876 +-#define LPFC_CTL_PORT_ER1_OFFSET 0x40C
6877 +-#define LPFC_CTL_PORT_ER2_OFFSET 0x410
6878 ++/* SLI4 interface type-2 PDEV_CTL register */
6879 + #define LPFC_CTL_PDEV_CTL_OFFSET 0x414
6880 +-
6881 +-/* Some SLI4 interface type-2 PDEV_CTL register bits */
6882 + #define LPFC_CTL_PDEV_CTL_DRST 0x00000001
6883 + #define LPFC_CTL_PDEV_CTL_FRST 0x00000002
6884 + #define LPFC_CTL_PDEV_CTL_DD 0x00000004
6885 +@@ -337,6 +330,7 @@ struct lpfc_cqe {
6886 + #define CQE_CODE_RELEASE_WQE 0x2
6887 + #define CQE_CODE_RECEIVE 0x4
6888 + #define CQE_CODE_XRI_ABORTED 0x5
6889 ++#define CQE_CODE_RECEIVE_V1 0x9
6890 +
6891 + /* completion queue entry for wqe completions */
6892 + struct lpfc_wcqe_complete {
6893 +@@ -440,7 +434,10 @@ struct lpfc_rcqe {
6894 + #define FC_STATUS_RQ_BUF_LEN_EXCEEDED 0x11 /* payload truncated */
6895 + #define FC_STATUS_INSUFF_BUF_NEED_BUF 0x12 /* Insufficient buffers */
6896 + #define FC_STATUS_INSUFF_BUF_FRM_DISC 0x13 /* Frame Discard */
6897 +- uint32_t reserved1;
6898 ++ uint32_t word1;
6899 ++#define lpfc_rcqe_fcf_id_v1_SHIFT 0
6900 ++#define lpfc_rcqe_fcf_id_v1_MASK 0x0000003F
6901 ++#define lpfc_rcqe_fcf_id_v1_WORD word1
6902 + uint32_t word2;
6903 + #define lpfc_rcqe_length_SHIFT 16
6904 + #define lpfc_rcqe_length_MASK 0x0000FFFF
6905 +@@ -451,6 +448,9 @@ struct lpfc_rcqe {
6906 + #define lpfc_rcqe_fcf_id_SHIFT 0
6907 + #define lpfc_rcqe_fcf_id_MASK 0x0000003F
6908 + #define lpfc_rcqe_fcf_id_WORD word2
6909 ++#define lpfc_rcqe_rq_id_v1_SHIFT 0
6910 ++#define lpfc_rcqe_rq_id_v1_MASK 0x0000FFFF
6911 ++#define lpfc_rcqe_rq_id_v1_WORD word2
6912 + uint32_t word3;
6913 + #define lpfc_rcqe_valid_SHIFT lpfc_cqe_valid_SHIFT
6914 + #define lpfc_rcqe_valid_MASK lpfc_cqe_valid_MASK
6915 +@@ -515,7 +515,7 @@ struct lpfc_register {
6916 + /* The following BAR0 register sets are defined for if_type 0 and 2 UCNAs. */
6917 + #define LPFC_SLI_INTF 0x0058
6918 +
6919 +-#define LPFC_SLIPORT_IF2_SMPHR 0x0400
6920 ++#define LPFC_CTL_PORT_SEM_OFFSET 0x400
6921 + #define lpfc_port_smphr_perr_SHIFT 31
6922 + #define lpfc_port_smphr_perr_MASK 0x1
6923 + #define lpfc_port_smphr_perr_WORD word0
6924 +@@ -575,7 +575,7 @@ struct lpfc_register {
6925 + #define LPFC_POST_STAGE_PORT_READY 0xC000
6926 + #define LPFC_POST_STAGE_PORT_UE 0xF000
6927 +
6928 +-#define LPFC_SLIPORT_STATUS 0x0404
6929 ++#define LPFC_CTL_PORT_STA_OFFSET 0x404
6930 + #define lpfc_sliport_status_err_SHIFT 31
6931 + #define lpfc_sliport_status_err_MASK 0x1
6932 + #define lpfc_sliport_status_err_WORD word0
6933 +@@ -593,7 +593,7 @@ struct lpfc_register {
6934 + #define lpfc_sliport_status_rdy_WORD word0
6935 + #define MAX_IF_TYPE_2_RESETS 1000
6936 +
6937 +-#define LPFC_SLIPORT_CNTRL 0x0408
6938 ++#define LPFC_CTL_PORT_CTL_OFFSET 0x408
6939 + #define lpfc_sliport_ctrl_end_SHIFT 30
6940 + #define lpfc_sliport_ctrl_end_MASK 0x1
6941 + #define lpfc_sliport_ctrl_end_WORD word0
6942 +@@ -604,8 +604,8 @@ struct lpfc_register {
6943 + #define lpfc_sliport_ctrl_ip_WORD word0
6944 + #define LPFC_SLIPORT_INIT_PORT 1
6945 +
6946 +-#define LPFC_SLIPORT_ERR_1 0x040C
6947 +-#define LPFC_SLIPORT_ERR_2 0x0410
6948 ++#define LPFC_CTL_PORT_ER1_OFFSET 0x40C
6949 ++#define LPFC_CTL_PORT_ER2_OFFSET 0x410
6950 +
6951 + /* The following Registers apply to SLI4 if_type 0 UCNAs. They typically
6952 + * reside in BAR 2.
6953 +@@ -3198,6 +3198,8 @@ struct lpfc_grp_hdr {
6954 + #define lpfc_grp_hdr_id_MASK 0x000000FF
6955 + #define lpfc_grp_hdr_id_WORD word2
6956 + uint8_t rev_name[128];
6957 ++ uint8_t date[12];
6958 ++ uint8_t revision[32];
6959 + };
6960 +
6961 + #define FCP_COMMAND 0x0
6962 +diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
6963 +index 148b98d..027b797 100644
6964 +--- a/drivers/scsi/lpfc/lpfc_init.c
6965 ++++ b/drivers/scsi/lpfc/lpfc_init.c
6966 +@@ -2927,6 +2927,8 @@ void lpfc_host_attrib_init(struct Scsi_Host *shost)
6967 + sizeof fc_host_symbolic_name(shost));
6968 +
6969 + fc_host_supported_speeds(shost) = 0;
6970 ++ if (phba->lmt & LMT_16Gb)
6971 ++ fc_host_supported_speeds(shost) |= FC_PORTSPEED_16GBIT;
6972 + if (phba->lmt & LMT_10Gb)
6973 + fc_host_supported_speeds(shost) |= FC_PORTSPEED_10GBIT;
6974 + if (phba->lmt & LMT_8Gb)
6975 +@@ -3647,7 +3649,7 @@ lpfc_sli4_async_fip_evt(struct lpfc_hba *phba,
6976 + " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag);
6977 +
6978 + vport = lpfc_find_vport_by_vpid(phba,
6979 +- acqe_fip->index - phba->vpi_base);
6980 ++ acqe_fip->index);
6981 + ndlp = lpfc_sli4_perform_vport_cvl(vport);
6982 + if (!ndlp)
6983 + break;
6984 +@@ -4035,6 +4037,34 @@ lpfc_reset_hba(struct lpfc_hba *phba)
6985 + }
6986 +
6987 + /**
6988 ++ * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
6989 ++ * @phba: pointer to lpfc hba data structure.
6990 ++ *
6991 ++ * This function enables the PCI SR-IOV virtual functions to a physical
6992 ++ * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6993 ++ * enable the number of virtual functions to the physical function. As
6994 ++ * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6995 ++ * API call does not considered as an error condition for most of the device.
6996 ++ **/
6997 ++uint16_t
6998 ++lpfc_sli_sriov_nr_virtfn_get(struct lpfc_hba *phba)
6999 ++{
7000 ++ struct pci_dev *pdev = phba->pcidev;
7001 ++ uint16_t nr_virtfn;
7002 ++ int pos;
7003 ++
7004 ++ if (!pdev->is_physfn)
7005 ++ return 0;
7006 ++
7007 ++ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
7008 ++ if (pos == 0)
7009 ++ return 0;
7010 ++
7011 ++ pci_read_config_word(pdev, pos + PCI_SRIOV_TOTAL_VF, &nr_virtfn);
7012 ++ return nr_virtfn;
7013 ++}
7014 ++
7015 ++/**
7016 + * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7017 + * @phba: pointer to lpfc hba data structure.
7018 + * @nr_vfn: number of virtual functions to be enabled.
7019 +@@ -4049,8 +4079,17 @@ int
7020 + lpfc_sli_probe_sriov_nr_virtfn(struct lpfc_hba *phba, int nr_vfn)
7021 + {
7022 + struct pci_dev *pdev = phba->pcidev;
7023 ++ uint16_t max_nr_vfn;
7024 + int rc;
7025 +
7026 ++ max_nr_vfn = lpfc_sli_sriov_nr_virtfn_get(phba);
7027 ++ if (nr_vfn > max_nr_vfn) {
7028 ++ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
7029 ++ "3057 Requested vfs (%d) greater than "
7030 ++ "supported vfs (%d)", nr_vfn, max_nr_vfn);
7031 ++ return -EINVAL;
7032 ++ }
7033 ++
7034 + rc = pci_enable_sriov(pdev, nr_vfn);
7035 + if (rc) {
7036 + lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
7037 +@@ -4516,7 +4555,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
7038 + }
7039 + }
7040 +
7041 +- return rc;
7042 ++ return 0;
7043 +
7044 + out_free_fcp_eq_hdl:
7045 + kfree(phba->sli4_hba.fcp_eq_hdl);
7046 +@@ -4966,17 +5005,14 @@ out_free_mem:
7047 + * @phba: pointer to lpfc hba data structure.
7048 + *
7049 + * This routine is invoked to post rpi header templates to the
7050 +- * HBA consistent with the SLI-4 interface spec. This routine
7051 ++ * port for those SLI4 ports that do not support extents. This routine
7052 + * posts a PAGE_SIZE memory region to the port to hold up to
7053 +- * PAGE_SIZE modulo 64 rpi context headers.
7054 +- * No locks are held here because this is an initialization routine
7055 +- * called only from probe or lpfc_online when interrupts are not
7056 +- * enabled and the driver is reinitializing the device.
7057 ++ * PAGE_SIZE modulo 64 rpi context headers. This is an initialization routine
7058 ++ * and should be called only when interrupts are disabled.
7059 + *
7060 + * Return codes
7061 + * 0 - successful
7062 +- * -ENOMEM - No available memory
7063 +- * -EIO - The mailbox failed to complete successfully.
7064 ++ * -ERROR - otherwise.
7065 + **/
7066 + int
7067 + lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *phba)
7068 +@@ -5687,17 +5723,22 @@ lpfc_sli4_bar0_register_memmap(struct lpfc_hba *phba, uint32_t if_type)
7069 + break;
7070 + case LPFC_SLI_INTF_IF_TYPE_2:
7071 + phba->sli4_hba.u.if_type2.ERR1regaddr =
7072 +- phba->sli4_hba.conf_regs_memmap_p + LPFC_SLIPORT_ERR_1;
7073 ++ phba->sli4_hba.conf_regs_memmap_p +
7074 ++ LPFC_CTL_PORT_ER1_OFFSET;
7075 + phba->sli4_hba.u.if_type2.ERR2regaddr =
7076 +- phba->sli4_hba.conf_regs_memmap_p + LPFC_SLIPORT_ERR_2;
7077 ++ phba->sli4_hba.conf_regs_memmap_p +
7078 ++ LPFC_CTL_PORT_ER2_OFFSET;
7079 + phba->sli4_hba.u.if_type2.CTRLregaddr =
7080 +- phba->sli4_hba.conf_regs_memmap_p + LPFC_SLIPORT_CNTRL;
7081 ++ phba->sli4_hba.conf_regs_memmap_p +
7082 ++ LPFC_CTL_PORT_CTL_OFFSET;
7083 + phba->sli4_hba.u.if_type2.STATUSregaddr =
7084 +- phba->sli4_hba.conf_regs_memmap_p + LPFC_SLIPORT_STATUS;
7085 ++ phba->sli4_hba.conf_regs_memmap_p +
7086 ++ LPFC_CTL_PORT_STA_OFFSET;
7087 + phba->sli4_hba.SLIINTFregaddr =
7088 + phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF;
7089 + phba->sli4_hba.PSMPHRregaddr =
7090 +- phba->sli4_hba.conf_regs_memmap_p + LPFC_SLIPORT_IF2_SMPHR;
7091 ++ phba->sli4_hba.conf_regs_memmap_p +
7092 ++ LPFC_CTL_PORT_SEM_OFFSET;
7093 + phba->sli4_hba.RQDBregaddr =
7094 + phba->sli4_hba.conf_regs_memmap_p + LPFC_RQ_DOORBELL;
7095 + phba->sli4_hba.WQDBregaddr =
7096 +@@ -8859,11 +8900,11 @@ lpfc_write_firmware(struct lpfc_hba *phba, const struct firmware *fw)
7097 + return -EINVAL;
7098 + }
7099 + lpfc_decode_firmware_rev(phba, fwrev, 1);
7100 +- if (strncmp(fwrev, image->rev_name, strnlen(fwrev, 16))) {
7101 ++ if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) {
7102 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
7103 + "3023 Updating Firmware. Current Version:%s "
7104 + "New Version:%s\n",
7105 +- fwrev, image->rev_name);
7106 ++ fwrev, image->revision);
7107 + for (i = 0; i < LPFC_MBX_WR_CONFIG_MAX_BDE; i++) {
7108 + dmabuf = kzalloc(sizeof(struct lpfc_dmabuf),
7109 + GFP_KERNEL);
7110 +@@ -8892,9 +8933,9 @@ lpfc_write_firmware(struct lpfc_hba *phba, const struct firmware *fw)
7111 + fw->size - offset);
7112 + break;
7113 + }
7114 +- temp_offset += SLI4_PAGE_SIZE;
7115 + memcpy(dmabuf->virt, fw->data + temp_offset,
7116 + SLI4_PAGE_SIZE);
7117 ++ temp_offset += SLI4_PAGE_SIZE;
7118 + }
7119 + rc = lpfc_wr_object(phba, &dma_buffer_list,
7120 + (fw->size - offset), &offset);
7121 +@@ -9483,6 +9524,13 @@ lpfc_io_slot_reset_s4(struct pci_dev *pdev)
7122 + }
7123 +
7124 + pci_restore_state(pdev);
7125 ++
7126 ++ /*
7127 ++ * As the new kernel behavior of pci_restore_state() API call clears
7128 ++ * device saved_state flag, need to save the restored state again.
7129 ++ */
7130 ++ pci_save_state(pdev);
7131 ++
7132 + if (pdev->is_busmaster)
7133 + pci_set_master(pdev);
7134 +
7135 +diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
7136 +index 5567670..83450cc 100644
7137 +--- a/drivers/scsi/lpfc/lpfc_mbox.c
7138 ++++ b/drivers/scsi/lpfc/lpfc_mbox.c
7139 +@@ -2031,7 +2031,7 @@ lpfc_init_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport)
7140 + bf_set(lpfc_init_vfi_vp, init_vfi, 1);
7141 + bf_set(lpfc_init_vfi_vfi, init_vfi,
7142 + vport->phba->sli4_hba.vfi_ids[vport->vfi]);
7143 +- bf_set(lpfc_init_vpi_vpi, init_vfi,
7144 ++ bf_set(lpfc_init_vfi_vpi, init_vfi,
7145 + vport->phba->vpi_ids[vport->vpi]);
7146 + bf_set(lpfc_init_vfi_fcfi, init_vfi,
7147 + vport->phba->fcf.fcfi);
7148 +diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
7149 +index 3ccc974..eadd241 100644
7150 +--- a/drivers/scsi/lpfc/lpfc_scsi.c
7151 ++++ b/drivers/scsi/lpfc/lpfc_scsi.c
7152 +@@ -1302,13 +1302,13 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7153 + case SCSI_PROT_NORMAL:
7154 + default:
7155 + lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7156 +- "9063 BLKGRD: Bad op/guard:%d/%d combination\n",
7157 +- scsi_get_prot_op(sc), guard_type);
7158 ++ "9063 BLKGRD: Bad op/guard:%d/IP combination\n",
7159 ++ scsi_get_prot_op(sc));
7160 + ret = 1;
7161 + break;
7162 +
7163 + }
7164 +- } else if (guard_type == SHOST_DIX_GUARD_CRC) {
7165 ++ } else {
7166 + switch (scsi_get_prot_op(sc)) {
7167 + case SCSI_PROT_READ_STRIP:
7168 + case SCSI_PROT_WRITE_INSERT:
7169 +@@ -1324,17 +1324,18 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7170 +
7171 + case SCSI_PROT_READ_INSERT:
7172 + case SCSI_PROT_WRITE_STRIP:
7173 ++ *txop = BG_OP_IN_CRC_OUT_NODIF;
7174 ++ *rxop = BG_OP_IN_NODIF_OUT_CRC;
7175 ++ break;
7176 ++
7177 + case SCSI_PROT_NORMAL:
7178 + default:
7179 + lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7180 +- "9075 BLKGRD: Bad op/guard:%d/%d combination\n",
7181 +- scsi_get_prot_op(sc), guard_type);
7182 ++ "9075 BLKGRD: Bad op/guard:%d/CRC combination\n",
7183 ++ scsi_get_prot_op(sc));
7184 + ret = 1;
7185 + break;
7186 + }
7187 +- } else {
7188 +- /* unsupported format */
7189 +- BUG();
7190 + }
7191 +
7192 + return ret;
7193 +@@ -1352,45 +1353,6 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc)
7194 + return sc->device->sector_size;
7195 + }
7196 +
7197 +-/**
7198 +- * lpfc_get_cmd_dif_parms - Extract DIF parameters from SCSI command
7199 +- * @sc: in: SCSI command
7200 +- * @apptagmask: out: app tag mask
7201 +- * @apptagval: out: app tag value
7202 +- * @reftag: out: ref tag (reference tag)
7203 +- *
7204 +- * Description:
7205 +- * Extract DIF parameters from the command if possible. Otherwise,
7206 +- * use default parameters.
7207 +- *
7208 +- **/
7209 +-static inline void
7210 +-lpfc_get_cmd_dif_parms(struct scsi_cmnd *sc, uint16_t *apptagmask,
7211 +- uint16_t *apptagval, uint32_t *reftag)
7212 +-{
7213 +- struct scsi_dif_tuple *spt;
7214 +- unsigned char op = scsi_get_prot_op(sc);
7215 +- unsigned int protcnt = scsi_prot_sg_count(sc);
7216 +- static int cnt;
7217 +-
7218 +- if (protcnt && (op == SCSI_PROT_WRITE_STRIP ||
7219 +- op == SCSI_PROT_WRITE_PASS)) {
7220 +-
7221 +- cnt++;
7222 +- spt = page_address(sg_page(scsi_prot_sglist(sc))) +
7223 +- scsi_prot_sglist(sc)[0].offset;
7224 +- *apptagmask = 0;
7225 +- *apptagval = 0;
7226 +- *reftag = cpu_to_be32(spt->ref_tag);
7227 +-
7228 +- } else {
7229 +- /* SBC defines ref tag to be lower 32bits of LBA */
7230 +- *reftag = (uint32_t) (0xffffffff & scsi_get_lba(sc));
7231 +- *apptagmask = 0;
7232 +- *apptagval = 0;
7233 +- }
7234 +-}
7235 +-
7236 + /*
7237 + * This function sets up buffer list for protection groups of
7238 + * type LPFC_PG_TYPE_NO_DIF
7239 +@@ -1427,9 +1389,8 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7240 + dma_addr_t physaddr;
7241 + int i = 0, num_bde = 0, status;
7242 + int datadir = sc->sc_data_direction;
7243 +- unsigned blksize;
7244 + uint32_t reftag;
7245 +- uint16_t apptagmask, apptagval;
7246 ++ unsigned blksize;
7247 + uint8_t txop, rxop;
7248 +
7249 + status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
7250 +@@ -1438,17 +1399,16 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7251 +
7252 + /* extract some info from the scsi command for pde*/
7253 + blksize = lpfc_cmd_blksize(sc);
7254 +- lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag);
7255 ++ reftag = scsi_get_lba(sc) & 0xffffffff;
7256 +
7257 + /* setup PDE5 with what we have */
7258 + pde5 = (struct lpfc_pde5 *) bpl;
7259 + memset(pde5, 0, sizeof(struct lpfc_pde5));
7260 + bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
7261 +- pde5->reftag = reftag;
7262 +
7263 + /* Endianness conversion if necessary for PDE5 */
7264 + pde5->word0 = cpu_to_le32(pde5->word0);
7265 +- pde5->reftag = cpu_to_le32(pde5->reftag);
7266 ++ pde5->reftag = cpu_to_le32(reftag);
7267 +
7268 + /* advance bpl and increment bde count */
7269 + num_bde++;
7270 +@@ -1463,10 +1423,10 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7271 + if (datadir == DMA_FROM_DEVICE) {
7272 + bf_set(pde6_ce, pde6, 1);
7273 + bf_set(pde6_re, pde6, 1);
7274 +- bf_set(pde6_ae, pde6, 1);
7275 + }
7276 + bf_set(pde6_ai, pde6, 1);
7277 +- bf_set(pde6_apptagval, pde6, apptagval);
7278 ++ bf_set(pde6_ae, pde6, 0);
7279 ++ bf_set(pde6_apptagval, pde6, 0);
7280 +
7281 + /* Endianness conversion if necessary for PDE6 */
7282 + pde6->word0 = cpu_to_le32(pde6->word0);
7283 +@@ -1551,7 +1511,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7284 + unsigned char pgdone = 0, alldone = 0;
7285 + unsigned blksize;
7286 + uint32_t reftag;
7287 +- uint16_t apptagmask, apptagval;
7288 + uint8_t txop, rxop;
7289 + int num_bde = 0;
7290 +
7291 +@@ -1571,7 +1530,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7292 +
7293 + /* extract some info from the scsi command */
7294 + blksize = lpfc_cmd_blksize(sc);
7295 +- lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag);
7296 ++ reftag = scsi_get_lba(sc) & 0xffffffff;
7297 +
7298 + split_offset = 0;
7299 + do {
7300 +@@ -1579,11 +1538,10 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7301 + pde5 = (struct lpfc_pde5 *) bpl;
7302 + memset(pde5, 0, sizeof(struct lpfc_pde5));
7303 + bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
7304 +- pde5->reftag = reftag;
7305 +
7306 + /* Endianness conversion if necessary for PDE5 */
7307 + pde5->word0 = cpu_to_le32(pde5->word0);
7308 +- pde5->reftag = cpu_to_le32(pde5->reftag);
7309 ++ pde5->reftag = cpu_to_le32(reftag);
7310 +
7311 + /* advance bpl and increment bde count */
7312 + num_bde++;
7313 +@@ -1597,9 +1555,9 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7314 + bf_set(pde6_oprx, pde6, rxop);
7315 + bf_set(pde6_ce, pde6, 1);
7316 + bf_set(pde6_re, pde6, 1);
7317 +- bf_set(pde6_ae, pde6, 1);
7318 + bf_set(pde6_ai, pde6, 1);
7319 +- bf_set(pde6_apptagval, pde6, apptagval);
7320 ++ bf_set(pde6_ae, pde6, 0);
7321 ++ bf_set(pde6_apptagval, pde6, 0);
7322 +
7323 + /* Endianness conversion if necessary for PDE6 */
7324 + pde6->word0 = cpu_to_le32(pde6->word0);
7325 +@@ -1621,8 +1579,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7326 + memset(pde7, 0, sizeof(struct lpfc_pde7));
7327 + bf_set(pde7_type, pde7, LPFC_PDE7_DESCRIPTOR);
7328 +
7329 +- pde7->addrHigh = le32_to_cpu(putPaddrLow(protphysaddr));
7330 +- pde7->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr));
7331 ++ pde7->addrHigh = le32_to_cpu(putPaddrHigh(protphysaddr));
7332 ++ pde7->addrLow = le32_to_cpu(putPaddrLow(protphysaddr));
7333 +
7334 + protgrp_blks = protgroup_len / 8;
7335 + protgrp_bytes = protgrp_blks * blksize;
7336 +@@ -1632,7 +1590,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
7337 + protgroup_remainder = 0x1000 - (pde7->addrLow & 0xfff);
7338 + protgroup_offset += protgroup_remainder;
7339 + protgrp_blks = protgroup_remainder / 8;
7340 +- protgrp_bytes = protgroup_remainder * blksize;
7341 ++ protgrp_bytes = protgrp_blks * blksize;
7342 + } else {
7343 + protgroup_offset = 0;
7344 + curr_prot++;
7345 +@@ -2006,16 +1964,21 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
7346 + if (lpfc_bgs_get_hi_water_mark_present(bgstat)) {
7347 + /*
7348 + * setup sense data descriptor 0 per SPC-4 as an information
7349 +- * field, and put the failing LBA in it
7350 ++ * field, and put the failing LBA in it.
7351 ++ * This code assumes there was also a guard/app/ref tag error
7352 ++ * indication.
7353 + */
7354 +- cmd->sense_buffer[8] = 0; /* Information */
7355 +- cmd->sense_buffer[9] = 0xa; /* Add. length */
7356 ++ cmd->sense_buffer[7] = 0xc; /* Additional sense length */
7357 ++ cmd->sense_buffer[8] = 0; /* Information descriptor type */
7358 ++ cmd->sense_buffer[9] = 0xa; /* Additional descriptor length */
7359 ++ cmd->sense_buffer[10] = 0x80; /* Validity bit */
7360 + bghm /= cmd->device->sector_size;
7361 +
7362 + failing_sector = scsi_get_lba(cmd);
7363 + failing_sector += bghm;
7364 +
7365 +- put_unaligned_be64(failing_sector, &cmd->sense_buffer[10]);
7366 ++ /* Descriptor Information */
7367 ++ put_unaligned_be64(failing_sector, &cmd->sense_buffer[12]);
7368 + }
7369 +
7370 + if (!ret) {
7371 +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
7372 +index 98999bb..5b28ea1 100644
7373 +--- a/drivers/scsi/lpfc/lpfc_sli.c
7374 ++++ b/drivers/scsi/lpfc/lpfc_sli.c
7375 +@@ -560,7 +560,7 @@ __lpfc_set_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
7376 + rrq = mempool_alloc(phba->rrq_pool, GFP_KERNEL);
7377 + if (rrq) {
7378 + rrq->send_rrq = send_rrq;
7379 +- rrq->xritag = phba->sli4_hba.xri_ids[xritag];
7380 ++ rrq->xritag = xritag;
7381 + rrq->rrq_stop_time = jiffies + HZ * (phba->fc_ratov + 1);
7382 + rrq->ndlp = ndlp;
7383 + rrq->nlp_DID = ndlp->nlp_DID;
7384 +@@ -2452,7 +2452,8 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
7385 +
7386 + /* search continue save q for same XRI */
7387 + list_for_each_entry(iocbq, &pring->iocb_continue_saveq, clist) {
7388 +- if (iocbq->iocb.ulpContext == saveq->iocb.ulpContext) {
7389 ++ if (iocbq->iocb.unsli3.rcvsli3.ox_id ==
7390 ++ saveq->iocb.unsli3.rcvsli3.ox_id) {
7391 + list_add_tail(&saveq->list, &iocbq->list);
7392 + found = 1;
7393 + break;
7394 +@@ -3355,6 +3356,7 @@ lpfc_sli_handle_slow_ring_event_s4(struct lpfc_hba *phba,
7395 + irspiocbq);
7396 + break;
7397 + case CQE_CODE_RECEIVE:
7398 ++ case CQE_CODE_RECEIVE_V1:
7399 + dmabuf = container_of(cq_event, struct hbq_dmabuf,
7400 + cq_event);
7401 + lpfc_sli4_handle_received_buffer(phba, dmabuf);
7402 +@@ -5837,6 +5839,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
7403 + "Advanced Error Reporting (AER)\n");
7404 + phba->cfg_aer_support = 0;
7405 + }
7406 ++ rc = 0;
7407 + }
7408 +
7409 + if (!(phba->hba_flag & HBA_FCOE_MODE)) {
7410 +@@ -7318,12 +7321,12 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7411 + bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1);
7412 + bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE);
7413 + bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0);
7414 +- break;
7415 ++ break;
7416 + case CMD_XMIT_SEQUENCE64_CX:
7417 + bf_set(wqe_ctxt_tag, &wqe->xmit_sequence.wqe_com,
7418 + iocbq->iocb.un.ulpWord[3]);
7419 + bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com,
7420 +- iocbq->iocb.ulpContext);
7421 ++ iocbq->iocb.unsli3.rcvsli3.ox_id);
7422 + /* The entire sequence is transmitted for this IOCB */
7423 + xmit_len = total_len;
7424 + cmnd = CMD_XMIT_SEQUENCE64_CR;
7425 +@@ -7341,7 +7344,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7426 + bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0);
7427 + wqe->xmit_sequence.xmit_len = xmit_len;
7428 + command_type = OTHER_COMMAND;
7429 +- break;
7430 ++ break;
7431 + case CMD_XMIT_BCAST64_CN:
7432 + /* word3 iocb=iotag32 wqe=seq_payload_len */
7433 + wqe->xmit_bcast64.seq_payload_len = xmit_len;
7434 +@@ -7355,7 +7358,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7435 + bf_set(wqe_lenloc, &wqe->xmit_bcast64.wqe_com,
7436 + LPFC_WQE_LENLOC_WORD3);
7437 + bf_set(wqe_ebde_cnt, &wqe->xmit_bcast64.wqe_com, 0);
7438 +- break;
7439 ++ break;
7440 + case CMD_FCP_IWRITE64_CR:
7441 + command_type = FCP_COMMAND_DATA_OUT;
7442 + /* word3 iocb=iotag wqe=payload_offset_len */
7443 +@@ -7375,7 +7378,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7444 + LPFC_WQE_LENLOC_WORD4);
7445 + bf_set(wqe_ebde_cnt, &wqe->fcp_iwrite.wqe_com, 0);
7446 + bf_set(wqe_pu, &wqe->fcp_iwrite.wqe_com, iocbq->iocb.ulpPU);
7447 +- break;
7448 ++ break;
7449 + case CMD_FCP_IREAD64_CR:
7450 + /* word3 iocb=iotag wqe=payload_offset_len */
7451 + /* Add the FCP_CMD and FCP_RSP sizes to get the offset */
7452 +@@ -7394,7 +7397,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7453 + LPFC_WQE_LENLOC_WORD4);
7454 + bf_set(wqe_ebde_cnt, &wqe->fcp_iread.wqe_com, 0);
7455 + bf_set(wqe_pu, &wqe->fcp_iread.wqe_com, iocbq->iocb.ulpPU);
7456 +- break;
7457 ++ break;
7458 + case CMD_FCP_ICMND64_CR:
7459 + /* word3 iocb=IO_TAG wqe=reserved */
7460 + wqe->fcp_icmd.rsrvd3 = 0;
7461 +@@ -7407,7 +7410,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7462 + bf_set(wqe_lenloc, &wqe->fcp_icmd.wqe_com,
7463 + LPFC_WQE_LENLOC_NONE);
7464 + bf_set(wqe_ebde_cnt, &wqe->fcp_icmd.wqe_com, 0);
7465 +- break;
7466 ++ break;
7467 + case CMD_GEN_REQUEST64_CR:
7468 + /* For this command calculate the xmit length of the
7469 + * request bde.
7470 +@@ -7442,7 +7445,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7471 + bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE);
7472 + bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0);
7473 + command_type = OTHER_COMMAND;
7474 +- break;
7475 ++ break;
7476 + case CMD_XMIT_ELS_RSP64_CX:
7477 + ndlp = (struct lpfc_nodelist *)iocbq->context1;
7478 + /* words0-2 BDE memcpy */
7479 +@@ -7457,7 +7460,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7480 + ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l));
7481 + bf_set(wqe_pu, &wqe->xmit_els_rsp.wqe_com, iocbq->iocb.ulpPU);
7482 + bf_set(wqe_rcvoxid, &wqe->xmit_els_rsp.wqe_com,
7483 +- iocbq->iocb.ulpContext);
7484 ++ iocbq->iocb.unsli3.rcvsli3.ox_id);
7485 + if (!iocbq->iocb.ulpCt_h && iocbq->iocb.ulpCt_l)
7486 + bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com,
7487 + phba->vpi_ids[iocbq->vport->vpi]);
7488 +@@ -7470,7 +7473,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7489 + bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp,
7490 + phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
7491 + command_type = OTHER_COMMAND;
7492 +- break;
7493 ++ break;
7494 + case CMD_CLOSE_XRI_CN:
7495 + case CMD_ABORT_XRI_CN:
7496 + case CMD_ABORT_XRI_CX:
7497 +@@ -7509,7 +7512,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7498 + cmnd = CMD_ABORT_XRI_CX;
7499 + command_type = OTHER_COMMAND;
7500 + xritag = 0;
7501 +- break;
7502 ++ break;
7503 + case CMD_XMIT_BLS_RSP64_CX:
7504 + /* As BLS ABTS RSP WQE is very different from other WQEs,
7505 + * we re-construct this WQE here based on information in
7506 +@@ -7553,7 +7556,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7507 + bf_get(lpfc_rsn_code, &iocbq->iocb.un.bls_rsp));
7508 + }
7509 +
7510 +- break;
7511 ++ break;
7512 + case CMD_XRI_ABORTED_CX:
7513 + case CMD_CREATE_XRI_CR: /* Do we expect to use this? */
7514 + case CMD_IOCB_FCP_IBIDIR64_CR: /* bidirectional xfer */
7515 +@@ -7565,7 +7568,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7516 + "2014 Invalid command 0x%x\n",
7517 + iocbq->iocb.ulpCommand);
7518 + return IOCB_ERROR;
7519 +- break;
7520 ++ break;
7521 + }
7522 +
7523 + bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag);
7524 +@@ -10481,10 +10484,14 @@ lpfc_sli4_sp_handle_rcqe(struct lpfc_hba *phba, struct lpfc_rcqe *rcqe)
7525 + struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq;
7526 + struct lpfc_queue *drq = phba->sli4_hba.dat_rq;
7527 + struct hbq_dmabuf *dma_buf;
7528 +- uint32_t status;
7529 ++ uint32_t status, rq_id;
7530 + unsigned long iflags;
7531 +
7532 +- if (bf_get(lpfc_rcqe_rq_id, rcqe) != hrq->queue_id)
7533 ++ if (bf_get(lpfc_cqe_code, rcqe) == CQE_CODE_RECEIVE_V1)
7534 ++ rq_id = bf_get(lpfc_rcqe_rq_id_v1, rcqe);
7535 ++ else
7536 ++ rq_id = bf_get(lpfc_rcqe_rq_id, rcqe);
7537 ++ if (rq_id != hrq->queue_id)
7538 + goto out;
7539 +
7540 + status = bf_get(lpfc_rcqe_status, rcqe);
7541 +@@ -10563,6 +10570,7 @@ lpfc_sli4_sp_handle_cqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
7542 + (struct sli4_wcqe_xri_aborted *)&cqevt);
7543 + break;
7544 + case CQE_CODE_RECEIVE:
7545 ++ case CQE_CODE_RECEIVE_V1:
7546 + /* Process the RQ event */
7547 + phba->last_completion_time = jiffies;
7548 + workposted = lpfc_sli4_sp_handle_rcqe(phba,
7549 +@@ -12345,19 +12353,18 @@ lpfc_sli4_post_sgl(struct lpfc_hba *phba,
7550 + }
7551 +
7552 + /**
7553 +- * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
7554 ++ * lpfc_sli4_alloc_xri - Get an available rpi in the device's range
7555 + * @phba: pointer to lpfc hba data structure.
7556 + *
7557 + * This routine is invoked to post rpi header templates to the
7558 +- * port for those SLI4 ports that do not support extents. This routine
7559 +- * posts a PAGE_SIZE memory region to the port to hold up to
7560 +- * PAGE_SIZE modulo 64 rpi context headers. This is an initialization routine
7561 +- * and should be called only when interrupts are disabled.
7562 ++ * HBA consistent with the SLI-4 interface spec. This routine
7563 ++ * posts a SLI4_PAGE_SIZE memory region to the port to hold up to
7564 ++ * SLI4_PAGE_SIZE modulo 64 rpi context headers.
7565 + *
7566 +- * Return codes
7567 +- * 0 - successful
7568 +- * -ERROR - otherwise.
7569 +- */
7570 ++ * Returns
7571 ++ * A nonzero rpi defined as rpi_base <= rpi < max_rpi if successful
7572 ++ * LPFC_RPI_ALLOC_ERROR if no rpis are available.
7573 ++ **/
7574 + uint16_t
7575 + lpfc_sli4_alloc_xri(struct lpfc_hba *phba)
7576 + {
7577 +@@ -13406,7 +13413,7 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba,
7578 + * This function validates the xri maps to the known range of XRIs allocated an
7579 + * used by the driver.
7580 + **/
7581 +-static uint16_t
7582 ++uint16_t
7583 + lpfc_sli4_xri_inrange(struct lpfc_hba *phba,
7584 + uint16_t xri)
7585 + {
7586 +@@ -13643,10 +13650,12 @@ lpfc_seq_complete(struct hbq_dmabuf *dmabuf)
7587 + static struct lpfc_iocbq *
7588 + lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7589 + {
7590 ++ struct hbq_dmabuf *hbq_buf;
7591 + struct lpfc_dmabuf *d_buf, *n_buf;
7592 + struct lpfc_iocbq *first_iocbq, *iocbq;
7593 + struct fc_frame_header *fc_hdr;
7594 + uint32_t sid;
7595 ++ uint32_t len, tot_len;
7596 + struct ulp_bde64 *pbde;
7597 +
7598 + fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt;
7599 +@@ -13655,6 +13664,7 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7600 + lpfc_update_rcv_time_stamp(vport);
7601 + /* get the Remote Port's SID */
7602 + sid = sli4_sid_from_fc_hdr(fc_hdr);
7603 ++ tot_len = 0;
7604 + /* Get an iocbq struct to fill in. */
7605 + first_iocbq = lpfc_sli_get_iocbq(vport->phba);
7606 + if (first_iocbq) {
7607 +@@ -13662,9 +13672,12 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7608 + first_iocbq->iocb.unsli3.rcvsli3.acc_len = 0;
7609 + first_iocbq->iocb.ulpStatus = IOSTAT_SUCCESS;
7610 + first_iocbq->iocb.ulpCommand = CMD_IOCB_RCV_SEQ64_CX;
7611 +- first_iocbq->iocb.ulpContext = be16_to_cpu(fc_hdr->fh_ox_id);
7612 +- /* iocbq is prepped for internal consumption. Logical vpi. */
7613 +- first_iocbq->iocb.unsli3.rcvsli3.vpi = vport->vpi;
7614 ++ first_iocbq->iocb.ulpContext = NO_XRI;
7615 ++ first_iocbq->iocb.unsli3.rcvsli3.ox_id =
7616 ++ be16_to_cpu(fc_hdr->fh_ox_id);
7617 ++ /* iocbq is prepped for internal consumption. Physical vpi. */
7618 ++ first_iocbq->iocb.unsli3.rcvsli3.vpi =
7619 ++ vport->phba->vpi_ids[vport->vpi];
7620 + /* put the first buffer into the first IOCBq */
7621 + first_iocbq->context2 = &seq_dmabuf->dbuf;
7622 + first_iocbq->context3 = NULL;
7623 +@@ -13672,9 +13685,9 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7624 + first_iocbq->iocb.un.cont64[0].tus.f.bdeSize =
7625 + LPFC_DATA_BUF_SIZE;
7626 + first_iocbq->iocb.un.rcvels.remoteID = sid;
7627 +- first_iocbq->iocb.unsli3.rcvsli3.acc_len +=
7628 +- bf_get(lpfc_rcqe_length,
7629 ++ tot_len = bf_get(lpfc_rcqe_length,
7630 + &seq_dmabuf->cq_event.cqe.rcqe_cmpl);
7631 ++ first_iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len;
7632 + }
7633 + iocbq = first_iocbq;
7634 + /*
7635 +@@ -13692,9 +13705,13 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7636 + pbde = (struct ulp_bde64 *)
7637 + &iocbq->iocb.unsli3.sli3Words[4];
7638 + pbde->tus.f.bdeSize = LPFC_DATA_BUF_SIZE;
7639 +- first_iocbq->iocb.unsli3.rcvsli3.acc_len +=
7640 +- bf_get(lpfc_rcqe_length,
7641 +- &seq_dmabuf->cq_event.cqe.rcqe_cmpl);
7642 ++
7643 ++ /* We need to get the size out of the right CQE */
7644 ++ hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
7645 ++ len = bf_get(lpfc_rcqe_length,
7646 ++ &hbq_buf->cq_event.cqe.rcqe_cmpl);
7647 ++ iocbq->iocb.unsli3.rcvsli3.acc_len += len;
7648 ++ tot_len += len;
7649 + } else {
7650 + iocbq = lpfc_sli_get_iocbq(vport->phba);
7651 + if (!iocbq) {
7652 +@@ -13712,9 +13729,14 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
7653 + iocbq->iocb.ulpBdeCount = 1;
7654 + iocbq->iocb.un.cont64[0].tus.f.bdeSize =
7655 + LPFC_DATA_BUF_SIZE;
7656 +- first_iocbq->iocb.unsli3.rcvsli3.acc_len +=
7657 +- bf_get(lpfc_rcqe_length,
7658 +- &seq_dmabuf->cq_event.cqe.rcqe_cmpl);
7659 ++
7660 ++ /* We need to get the size out of the right CQE */
7661 ++ hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
7662 ++ len = bf_get(lpfc_rcqe_length,
7663 ++ &hbq_buf->cq_event.cqe.rcqe_cmpl);
7664 ++ tot_len += len;
7665 ++ iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len;
7666 ++
7667 + iocbq->iocb.un.rcvels.remoteID = sid;
7668 + list_add_tail(&iocbq->list, &first_iocbq->list);
7669 + }
7670 +@@ -13787,7 +13809,13 @@ lpfc_sli4_handle_received_buffer(struct lpfc_hba *phba,
7671 + lpfc_in_buf_free(phba, &dmabuf->dbuf);
7672 + return;
7673 + }
7674 +- fcfi = bf_get(lpfc_rcqe_fcf_id, &dmabuf->cq_event.cqe.rcqe_cmpl);
7675 ++ if ((bf_get(lpfc_cqe_code,
7676 ++ &dmabuf->cq_event.cqe.rcqe_cmpl) == CQE_CODE_RECEIVE_V1))
7677 ++ fcfi = bf_get(lpfc_rcqe_fcf_id_v1,
7678 ++ &dmabuf->cq_event.cqe.rcqe_cmpl);
7679 ++ else
7680 ++ fcfi = bf_get(lpfc_rcqe_fcf_id,
7681 ++ &dmabuf->cq_event.cqe.rcqe_cmpl);
7682 + vport = lpfc_fc_frame_to_vport(phba, fc_hdr, fcfi);
7683 + if (!vport || !(vport->vpi_state & LPFC_VPI_REGISTERED)) {
7684 + /* throw out the frame */
7685 +diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
7686 +index 4b17035..88387c1 100644
7687 +--- a/drivers/scsi/lpfc/lpfc_sli4.h
7688 ++++ b/drivers/scsi/lpfc/lpfc_sli4.h
7689 +@@ -81,6 +81,8 @@
7690 + (fc_hdr)->fh_f_ctl[1] << 8 | \
7691 + (fc_hdr)->fh_f_ctl[2])
7692 +
7693 ++#define LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT 12000
7694 ++
7695 + enum lpfc_sli4_queue_type {
7696 + LPFC_EQ,
7697 + LPFC_GCQ,
7698 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
7699 +index 1da606c..83035bd 100644
7700 +--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
7701 ++++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
7702 +@@ -1740,9 +1740,11 @@ _base_display_dell_branding(struct MPT2SAS_ADAPTER *ioc)
7703 + static void
7704 + _base_display_intel_branding(struct MPT2SAS_ADAPTER *ioc)
7705 + {
7706 +- if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_INTEL &&
7707 +- ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008) {
7708 ++ if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_INTEL)
7709 ++ return;
7710 +
7711 ++ switch (ioc->pdev->device) {
7712 ++ case MPI2_MFGPAGE_DEVID_SAS2008:
7713 + switch (ioc->pdev->subsystem_device) {
7714 + case MPT2SAS_INTEL_RMS2LL080_SSDID:
7715 + printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
7716 +@@ -1752,7 +1754,20 @@ _base_display_intel_branding(struct MPT2SAS_ADAPTER *ioc)
7717 + printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
7718 + MPT2SAS_INTEL_RMS2LL040_BRANDING);
7719 + break;
7720 ++ default:
7721 ++ break;
7722 + }
7723 ++ case MPI2_MFGPAGE_DEVID_SAS2308_2:
7724 ++ switch (ioc->pdev->subsystem_device) {
7725 ++ case MPT2SAS_INTEL_RS25GB008_SSDID:
7726 ++ printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
7727 ++ MPT2SAS_INTEL_RS25GB008_BRANDING);
7728 ++ break;
7729 ++ default:
7730 ++ break;
7731 ++ }
7732 ++ default:
7733 ++ break;
7734 + }
7735 + }
7736 +
7737 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
7738 +index 451dc1c..41a57a7 100644
7739 +--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
7740 ++++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
7741 +@@ -161,12 +161,15 @@
7742 + "Intel Integrated RAID Module RMS2LL080"
7743 + #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
7744 + "Intel Integrated RAID Module RMS2LL040"
7745 ++#define MPT2SAS_INTEL_RS25GB008_BRANDING \
7746 ++ "Intel(R) RAID Controller RS25GB008"
7747 +
7748 + /*
7749 + * Intel HBA SSDIDs
7750 + */
7751 + #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
7752 + #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
7753 ++#define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
7754 +
7755 +
7756 + /*
7757 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
7758 +index e327a3c..8dc2ad4 100644
7759 +--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
7760 ++++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
7761 +@@ -3698,7 +3698,7 @@ _scsih_qcmd_lck(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
7762 + return 0;
7763 + }
7764 +
7765 +- if (ioc->pci_error_recovery) {
7766 ++ if (ioc->pci_error_recovery || ioc->remove_host) {
7767 + scmd->result = DID_NO_CONNECT << 16;
7768 + scmd->scsi_done(scmd);
7769 + return 0;
7770 +@@ -7211,7 +7211,6 @@ _scsih_remove(struct pci_dev *pdev)
7771 + }
7772 +
7773 + sas_remove_host(shost);
7774 +- _scsih_shutdown(pdev);
7775 + list_del(&ioc->list);
7776 + scsi_remove_host(shost);
7777 + scsi_host_put(shost);
7778 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
7779 +index 920b76b..b2df2f9 100644
7780 +--- a/drivers/scsi/qla2xxx/qla_init.c
7781 ++++ b/drivers/scsi/qla2xxx/qla_init.c
7782 +@@ -3822,15 +3822,12 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
7783 + req = vha->req;
7784 + rsp = req->rsp;
7785 +
7786 +- atomic_set(&vha->loop_state, LOOP_UPDATE);
7787 + clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
7788 + if (vha->flags.online) {
7789 + if (!(rval = qla2x00_fw_ready(vha))) {
7790 + /* Wait at most MAX_TARGET RSCNs for a stable link. */
7791 + wait_time = 256;
7792 + do {
7793 +- atomic_set(&vha->loop_state, LOOP_UPDATE);
7794 +-
7795 + /* Issue a marker after FW becomes ready. */
7796 + qla2x00_marker(vha, req, rsp, 0, 0,
7797 + MK_SYNC_ALL);
7798 +diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
7799 +index 1b60a95..e0fa877 100644
7800 +--- a/drivers/scsi/qla2xxx/qla_isr.c
7801 ++++ b/drivers/scsi/qla2xxx/qla_isr.c
7802 +@@ -736,7 +736,6 @@ skip_rio:
7803 + vha->flags.rscn_queue_overflow = 1;
7804 + }
7805 +
7806 +- atomic_set(&vha->loop_state, LOOP_UPDATE);
7807 + atomic_set(&vha->loop_down_timer, 0);
7808 + vha->flags.management_server_logged_in = 0;
7809 +
7810 +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
7811 +index 98b6e3b..e809e9d 100644
7812 +--- a/drivers/tty/pty.c
7813 ++++ b/drivers/tty/pty.c
7814 +@@ -446,8 +446,19 @@ static inline void legacy_pty_init(void) { }
7815 + int pty_limit = NR_UNIX98_PTY_DEFAULT;
7816 + static int pty_limit_min;
7817 + static int pty_limit_max = NR_UNIX98_PTY_MAX;
7818 ++static int tty_count;
7819 + static int pty_count;
7820 +
7821 ++static inline void pty_inc_count(void)
7822 ++{
7823 ++ pty_count = (++tty_count) / 2;
7824 ++}
7825 ++
7826 ++static inline void pty_dec_count(void)
7827 ++{
7828 ++ pty_count = (--tty_count) / 2;
7829 ++}
7830 ++
7831 + static struct cdev ptmx_cdev;
7832 +
7833 + static struct ctl_table pty_table[] = {
7834 +@@ -542,6 +553,7 @@ static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver,
7835 +
7836 + static void pty_unix98_shutdown(struct tty_struct *tty)
7837 + {
7838 ++ tty_driver_remove_tty(tty->driver, tty);
7839 + /* We have our own method as we don't use the tty index */
7840 + kfree(tty->termios);
7841 + }
7842 +@@ -588,7 +600,8 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
7843 + */
7844 + tty_driver_kref_get(driver);
7845 + tty->count++;
7846 +- pty_count++;
7847 ++ pty_inc_count(); /* tty */
7848 ++ pty_inc_count(); /* tty->link */
7849 + return 0;
7850 + err_free_mem:
7851 + deinitialize_tty_struct(o_tty);
7852 +@@ -602,7 +615,7 @@ err_free_tty:
7853 +
7854 + static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
7855 + {
7856 +- pty_count--;
7857 ++ pty_dec_count();
7858 + }
7859 +
7860 + static const struct tty_operations ptm_unix98_ops = {
7861 +diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
7862 +index d32b5bb..762ce72 100644
7863 +--- a/drivers/tty/serial/8250.c
7864 ++++ b/drivers/tty/serial/8250.c
7865 +@@ -1819,6 +1819,8 @@ static void serial8250_backup_timeout(unsigned long data)
7866 + unsigned int iir, ier = 0, lsr;
7867 + unsigned long flags;
7868 +
7869 ++ spin_lock_irqsave(&up->port.lock, flags);
7870 ++
7871 + /*
7872 + * Must disable interrupts or else we risk racing with the interrupt
7873 + * based handler.
7874 +@@ -1836,10 +1838,8 @@ static void serial8250_backup_timeout(unsigned long data)
7875 + * the "Diva" UART used on the management processor on many HP
7876 + * ia64 and parisc boxes.
7877 + */
7878 +- spin_lock_irqsave(&up->port.lock, flags);
7879 + lsr = serial_in(up, UART_LSR);
7880 + up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
7881 +- spin_unlock_irqrestore(&up->port.lock, flags);
7882 + if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&
7883 + (!uart_circ_empty(&up->port.state->xmit) || up->port.x_char) &&
7884 + (lsr & UART_LSR_THRE)) {
7885 +@@ -1848,11 +1848,13 @@ static void serial8250_backup_timeout(unsigned long data)
7886 + }
7887 +
7888 + if (!(iir & UART_IIR_NO_INT))
7889 +- serial8250_handle_port(up);
7890 ++ transmit_chars(up);
7891 +
7892 + if (is_real_interrupt(up->port.irq))
7893 + serial_out(up, UART_IER, ier);
7894 +
7895 ++ spin_unlock_irqrestore(&up->port.lock, flags);
7896 ++
7897 + /* Standard timer interval plus 0.2s to keep the port running */
7898 + mod_timer(&up->timer,
7899 + jiffies + uart_poll_timeout(&up->port) + HZ / 5);
7900 +diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
7901 +index f41b425..ff48fdb 100644
7902 +--- a/drivers/tty/serial/8250_pci.c
7903 ++++ b/drivers/tty/serial/8250_pci.c
7904 +@@ -3886,7 +3886,7 @@ static struct pci_device_id serial_pci_tbl[] = {
7905 + 0, 0, pbn_b0_1_115200 },
7906 +
7907 + /*
7908 +- * Best Connectivity PCI Multi I/O cards
7909 ++ * Best Connectivity and Rosewill PCI Multi I/O cards
7910 + */
7911 +
7912 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865,
7913 +@@ -3894,6 +3894,10 @@ static struct pci_device_id serial_pci_tbl[] = {
7914 + 0, 0, pbn_b0_1_115200 },
7915 +
7916 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865,
7917 ++ 0xA000, 0x3002,
7918 ++ 0, 0, pbn_b0_bt_2_115200 },
7919 ++
7920 ++ { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865,
7921 + 0xA000, 0x3004,
7922 + 0, 0, pbn_b0_bt_4_115200 },
7923 + /* Intel CE4100 */
7924 +diff --git a/drivers/tty/serial/8250_pnp.c b/drivers/tty/serial/8250_pnp.c
7925 +index fc301f6..a2f2365 100644
7926 +--- a/drivers/tty/serial/8250_pnp.c
7927 ++++ b/drivers/tty/serial/8250_pnp.c
7928 +@@ -109,6 +109,9 @@ static const struct pnp_device_id pnp_dev_table[] = {
7929 + /* IBM */
7930 + /* IBM Thinkpad 701 Internal Modem Voice */
7931 + { "IBM0033", 0 },
7932 ++ /* Intermec */
7933 ++ /* Intermec CV60 touchscreen port */
7934 ++ { "PNP4972", 0 },
7935 + /* Intertex */
7936 + /* Intertex 28k8 33k6 Voice EXT PnP */
7937 + { "IXDC801", 0 },
7938 +diff --git a/drivers/tty/serial/max3107-aava.c b/drivers/tty/serial/max3107-aava.c
7939 +index a1fe304..d73aadd 100644
7940 +--- a/drivers/tty/serial/max3107-aava.c
7941 ++++ b/drivers/tty/serial/max3107-aava.c
7942 +@@ -340,5 +340,5 @@ module_exit(max3107_exit);
7943 +
7944 + MODULE_DESCRIPTION("MAX3107 driver");
7945 + MODULE_AUTHOR("Aavamobile");
7946 +-MODULE_ALIAS("aava-max3107-spi");
7947 ++MODULE_ALIAS("spi:aava-max3107");
7948 + MODULE_LICENSE("GPL v2");
7949 +diff --git a/drivers/tty/serial/max3107.c b/drivers/tty/serial/max3107.c
7950 +index 750b4f6..a816460 100644
7951 +--- a/drivers/tty/serial/max3107.c
7952 ++++ b/drivers/tty/serial/max3107.c
7953 +@@ -1209,5 +1209,5 @@ module_exit(max3107_exit);
7954 +
7955 + MODULE_DESCRIPTION("MAX3107 driver");
7956 + MODULE_AUTHOR("Aavamobile");
7957 +-MODULE_ALIAS("max3107-spi");
7958 ++MODULE_ALIAS("spi:max3107");
7959 + MODULE_LICENSE("GPL v2");
7960 +diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
7961 +index a764bf9..23bc743 100644
7962 +--- a/drivers/tty/serial/mrst_max3110.c
7963 ++++ b/drivers/tty/serial/mrst_max3110.c
7964 +@@ -917,4 +917,4 @@ module_init(serial_m3110_init);
7965 + module_exit(serial_m3110_exit);
7966 +
7967 + MODULE_LICENSE("GPL v2");
7968 +-MODULE_ALIAS("max3110-uart");
7969 ++MODULE_ALIAS("spi:max3110-uart");
7970 +diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
7971 +index 47cadf4..6d3ec14 100644
7972 +--- a/drivers/tty/serial/omap-serial.c
7973 ++++ b/drivers/tty/serial/omap-serial.c
7974 +@@ -806,8 +806,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
7975 +
7976 + serial_omap_set_mctrl(&up->port, up->port.mctrl);
7977 + /* Software Flow Control Configuration */
7978 +- if (termios->c_iflag & (IXON | IXOFF))
7979 +- serial_omap_configure_xonxoff(up, termios);
7980 ++ serial_omap_configure_xonxoff(up, termios);
7981 +
7982 + spin_unlock_irqrestore(&up->port.lock, flags);
7983 + dev_dbg(up->port.dev, "serial_omap_set_termios+%d\n", up->pdev->id);
7984 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
7985 +index 6556f74..b6f92d3 100644
7986 +--- a/drivers/tty/tty_io.c
7987 ++++ b/drivers/tty/tty_io.c
7988 +@@ -1294,8 +1294,7 @@ static int tty_driver_install_tty(struct tty_driver *driver,
7989 + *
7990 + * Locking: tty_mutex for now
7991 + */
7992 +-static void tty_driver_remove_tty(struct tty_driver *driver,
7993 +- struct tty_struct *tty)
7994 ++void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty)
7995 + {
7996 + if (driver->ops->remove)
7997 + driver->ops->remove(driver, tty);
7998 +diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
7999 +index 88cfb8f..0f3a724 100644
8000 +--- a/drivers/usb/host/ehci-hub.c
8001 ++++ b/drivers/usb/host/ehci-hub.c
8002 +@@ -343,7 +343,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
8003 + u32 temp;
8004 + u32 power_okay;
8005 + int i;
8006 +- u8 resume_needed = 0;
8007 ++ unsigned long resume_needed = 0;
8008 +
8009 + if (time_before (jiffies, ehci->next_statechange))
8010 + msleep(5);
8011 +@@ -416,7 +416,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
8012 + if (test_bit(i, &ehci->bus_suspended) &&
8013 + (temp & PORT_SUSPEND)) {
8014 + temp |= PORT_RESUME;
8015 +- resume_needed = 1;
8016 ++ set_bit(i, &resume_needed);
8017 + }
8018 + ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
8019 + }
8020 +@@ -431,8 +431,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
8021 + i = HCS_N_PORTS (ehci->hcs_params);
8022 + while (i--) {
8023 + temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
8024 +- if (test_bit(i, &ehci->bus_suspended) &&
8025 +- (temp & PORT_SUSPEND)) {
8026 ++ if (test_bit(i, &resume_needed)) {
8027 + temp &= ~(PORT_RWC_BITS | PORT_RESUME);
8028 + ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
8029 + ehci_vdbg (ehci, "resumed port %d\n", i + 1);
8030 +diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
8031 +index e3374c8..491a209 100644
8032 +--- a/drivers/usb/host/ehci-s5p.c
8033 ++++ b/drivers/usb/host/ehci-s5p.c
8034 +@@ -86,6 +86,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
8035 + goto fail_hcd;
8036 + }
8037 +
8038 ++ s5p_ehci->hcd = hcd;
8039 + s5p_ehci->clk = clk_get(&pdev->dev, "usbhost");
8040 +
8041 + if (IS_ERR(s5p_ehci->clk)) {
8042 +diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
8043 +index e9f004e..629a968 100644
8044 +--- a/drivers/usb/host/pci-quirks.c
8045 ++++ b/drivers/usb/host/pci-quirks.c
8046 +@@ -535,20 +535,34 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
8047 + iounmap(base);
8048 + }
8049 +
8050 ++static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = {
8051 ++ {
8052 ++ /* Pegatron Lucid (ExoPC) */
8053 ++ .matches = {
8054 ++ DMI_MATCH(DMI_BOARD_NAME, "EXOPG06411"),
8055 ++ DMI_MATCH(DMI_BIOS_VERSION, "Lucid-CE-133"),
8056 ++ },
8057 ++ },
8058 ++ {
8059 ++ /* Pegatron Lucid (Ordissimo AIRIS) */
8060 ++ .matches = {
8061 ++ DMI_MATCH(DMI_BOARD_NAME, "M11JB"),
8062 ++ DMI_MATCH(DMI_BIOS_VERSION, "Lucid-GE-133"),
8063 ++ },
8064 ++ },
8065 ++ { }
8066 ++};
8067 ++
8068 + static void __devinit ehci_bios_handoff(struct pci_dev *pdev,
8069 + void __iomem *op_reg_base,
8070 + u32 cap, u8 offset)
8071 + {
8072 + int try_handoff = 1, tried_handoff = 0;
8073 +
8074 +- /* The Pegatron Lucid (ExoPC) tablet sporadically waits for 90
8075 +- * seconds trying the handoff on its unused controller. Skip
8076 +- * it. */
8077 ++ /* The Pegatron Lucid tablet sporadically waits for 98 seconds trying
8078 ++ * the handoff on its unused controller. Skip it. */
8079 + if (pdev->vendor == 0x8086 && pdev->device == 0x283a) {
8080 +- const char *dmi_bn = dmi_get_system_info(DMI_BOARD_NAME);
8081 +- const char *dmi_bv = dmi_get_system_info(DMI_BIOS_VERSION);
8082 +- if (dmi_bn && !strcmp(dmi_bn, "EXOPG06411") &&
8083 +- dmi_bv && !strcmp(dmi_bv, "Lucid-CE-133"))
8084 ++ if (dmi_check_system(ehci_dmi_nohandoff_table))
8085 + try_handoff = 0;
8086 + }
8087 +
8088 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
8089 +index 0be788c..723f823 100644
8090 +--- a/drivers/usb/host/xhci-hub.c
8091 ++++ b/drivers/usb/host/xhci-hub.c
8092 +@@ -463,11 +463,12 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
8093 + && (temp & PORT_POWER))
8094 + status |= USB_PORT_STAT_SUSPEND;
8095 + }
8096 +- if ((temp & PORT_PLS_MASK) == XDEV_RESUME) {
8097 ++ if ((temp & PORT_PLS_MASK) == XDEV_RESUME &&
8098 ++ !DEV_SUPERSPEED(temp)) {
8099 + if ((temp & PORT_RESET) || !(temp & PORT_PE))
8100 + goto error;
8101 +- if (!DEV_SUPERSPEED(temp) && time_after_eq(jiffies,
8102 +- bus_state->resume_done[wIndex])) {
8103 ++ if (time_after_eq(jiffies,
8104 ++ bus_state->resume_done[wIndex])) {
8105 + xhci_dbg(xhci, "Resume USB2 port %d\n",
8106 + wIndex + 1);
8107 + bus_state->resume_done[wIndex] = 0;
8108 +@@ -487,6 +488,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
8109 + xhci_ring_device(xhci, slot_id);
8110 + bus_state->port_c_suspend |= 1 << wIndex;
8111 + bus_state->suspended_ports &= ~(1 << wIndex);
8112 ++ } else {
8113 ++ /*
8114 ++ * The resume has been signaling for less than
8115 ++ * 20ms. Report the port status as SUSPEND,
8116 ++ * let the usbcore check port status again
8117 ++ * and clear resume signaling later.
8118 ++ */
8119 ++ status |= USB_PORT_STAT_SUSPEND;
8120 + }
8121 + }
8122 + if ((temp & PORT_PLS_MASK) == XDEV_U0
8123 +@@ -664,7 +673,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
8124 + xhci_dbg(xhci, "PORTSC %04x\n", temp);
8125 + if (temp & PORT_RESET)
8126 + goto error;
8127 +- if (temp & XDEV_U3) {
8128 ++ if ((temp & PORT_PLS_MASK) == XDEV_U3) {
8129 + if ((temp & PORT_PE) == 0)
8130 + goto error;
8131 +
8132 +@@ -752,7 +761,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
8133 + memset(buf, 0, retval);
8134 + status = 0;
8135 +
8136 +- mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC;
8137 ++ mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC;
8138 +
8139 + spin_lock_irqsave(&xhci->lock, flags);
8140 + /* For each port, did anything change? If so, set that bit in buf. */
8141 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
8142 +index 70cacbb..d0871ea 100644
8143 +--- a/drivers/usb/host/xhci-ring.c
8144 ++++ b/drivers/usb/host/xhci-ring.c
8145 +@@ -516,8 +516,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
8146 + (unsigned long long) addr);
8147 + }
8148 +
8149 ++/* flip_cycle means flip the cycle bit of all but the first and last TRB.
8150 ++ * (The last TRB actually points to the ring enqueue pointer, which is not part
8151 ++ * of this TD.) This is used to remove partially enqueued isoc TDs from a ring.
8152 ++ */
8153 + static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
8154 +- struct xhci_td *cur_td)
8155 ++ struct xhci_td *cur_td, bool flip_cycle)
8156 + {
8157 + struct xhci_segment *cur_seg;
8158 + union xhci_trb *cur_trb;
8159 +@@ -531,6 +535,12 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
8160 + * leave the pointers intact.
8161 + */
8162 + cur_trb->generic.field[3] &= cpu_to_le32(~TRB_CHAIN);
8163 ++ /* Flip the cycle bit (link TRBs can't be the first
8164 ++ * or last TRB).
8165 ++ */
8166 ++ if (flip_cycle)
8167 ++ cur_trb->generic.field[3] ^=
8168 ++ cpu_to_le32(TRB_CYCLE);
8169 + xhci_dbg(xhci, "Cancel (unchain) link TRB\n");
8170 + xhci_dbg(xhci, "Address = %p (0x%llx dma); "
8171 + "in seg %p (0x%llx dma)\n",
8172 +@@ -544,6 +554,11 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
8173 + cur_trb->generic.field[2] = 0;
8174 + /* Preserve only the cycle bit of this TRB */
8175 + cur_trb->generic.field[3] &= cpu_to_le32(TRB_CYCLE);
8176 ++ /* Flip the cycle bit except on the first or last TRB */
8177 ++ if (flip_cycle && cur_trb != cur_td->first_trb &&
8178 ++ cur_trb != cur_td->last_trb)
8179 ++ cur_trb->generic.field[3] ^=
8180 ++ cpu_to_le32(TRB_CYCLE);
8181 + cur_trb->generic.field[3] |= cpu_to_le32(
8182 + TRB_TYPE(TRB_TR_NOOP));
8183 + xhci_dbg(xhci, "Cancel TRB %p (0x%llx dma) "
8184 +@@ -722,14 +737,14 @@ static void handle_stopped_endpoint(struct xhci_hcd *xhci,
8185 + cur_td->urb->stream_id,
8186 + cur_td, &deq_state);
8187 + else
8188 +- td_to_noop(xhci, ep_ring, cur_td);
8189 ++ td_to_noop(xhci, ep_ring, cur_td, false);
8190 + remove_finished_td:
8191 + /*
8192 + * The event handler won't see a completion for this TD anymore,
8193 + * so remove it from the endpoint ring's TD list. Keep it in
8194 + * the cancelled TD list for URB completion later.
8195 + */
8196 +- list_del(&cur_td->td_list);
8197 ++ list_del_init(&cur_td->td_list);
8198 + }
8199 + last_unlinked_td = cur_td;
8200 + xhci_stop_watchdog_timer_in_irq(xhci, ep);
8201 +@@ -757,7 +772,7 @@ remove_finished_td:
8202 + do {
8203 + cur_td = list_entry(ep->cancelled_td_list.next,
8204 + struct xhci_td, cancelled_td_list);
8205 +- list_del(&cur_td->cancelled_td_list);
8206 ++ list_del_init(&cur_td->cancelled_td_list);
8207 +
8208 + /* Clean up the cancelled URB */
8209 + /* Doesn't matter what we pass for status, since the core will
8210 +@@ -865,9 +880,9 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
8211 + cur_td = list_first_entry(&ring->td_list,
8212 + struct xhci_td,
8213 + td_list);
8214 +- list_del(&cur_td->td_list);
8215 ++ list_del_init(&cur_td->td_list);
8216 + if (!list_empty(&cur_td->cancelled_td_list))
8217 +- list_del(&cur_td->cancelled_td_list);
8218 ++ list_del_init(&cur_td->cancelled_td_list);
8219 + xhci_giveback_urb_in_irq(xhci, cur_td,
8220 + -ESHUTDOWN, "killed");
8221 + }
8222 +@@ -876,7 +891,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
8223 + &temp_ep->cancelled_td_list,
8224 + struct xhci_td,
8225 + cancelled_td_list);
8226 +- list_del(&cur_td->cancelled_td_list);
8227 ++ list_del_init(&cur_td->cancelled_td_list);
8228 + xhci_giveback_urb_in_irq(xhci, cur_td,
8229 + -ESHUTDOWN, "killed");
8230 + }
8231 +@@ -1567,10 +1582,10 @@ td_cleanup:
8232 + else
8233 + *status = 0;
8234 + }
8235 +- list_del(&td->td_list);
8236 ++ list_del_init(&td->td_list);
8237 + /* Was this TD slated to be cancelled but completed anyway? */
8238 + if (!list_empty(&td->cancelled_td_list))
8239 +- list_del(&td->cancelled_td_list);
8240 ++ list_del_init(&td->cancelled_td_list);
8241 +
8242 + urb_priv->td_cnt++;
8243 + /* Giveback the urb when all the tds are completed */
8244 +@@ -2508,11 +2523,8 @@ static int prepare_transfer(struct xhci_hcd *xhci,
8245 +
8246 + if (td_index == 0) {
8247 + ret = usb_hcd_link_urb_to_ep(bus_to_hcd(urb->dev->bus), urb);
8248 +- if (unlikely(ret)) {
8249 +- xhci_urb_free_priv(xhci, urb_priv);
8250 +- urb->hcpriv = NULL;
8251 ++ if (unlikely(ret))
8252 + return ret;
8253 +- }
8254 + }
8255 +
8256 + td->urb = urb;
8257 +@@ -2680,6 +2692,10 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
8258 + {
8259 + int packets_transferred;
8260 +
8261 ++ /* One TRB with a zero-length data packet. */
8262 ++ if (running_total == 0 && trb_buff_len == 0)
8263 ++ return 0;
8264 ++
8265 + /* All the TRB queueing functions don't count the current TRB in
8266 + * running_total.
8267 + */
8268 +@@ -3121,20 +3137,15 @@ static int count_isoc_trbs_needed(struct xhci_hcd *xhci,
8269 + struct urb *urb, int i)
8270 + {
8271 + int num_trbs = 0;
8272 +- u64 addr, td_len, running_total;
8273 ++ u64 addr, td_len;
8274 +
8275 + addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset);
8276 + td_len = urb->iso_frame_desc[i].length;
8277 +
8278 +- running_total = TRB_MAX_BUFF_SIZE - (addr & (TRB_MAX_BUFF_SIZE - 1));
8279 +- running_total &= TRB_MAX_BUFF_SIZE - 1;
8280 +- if (running_total != 0)
8281 +- num_trbs++;
8282 +-
8283 +- while (running_total < td_len) {
8284 ++ num_trbs = DIV_ROUND_UP(td_len + (addr & (TRB_MAX_BUFF_SIZE - 1)),
8285 ++ TRB_MAX_BUFF_SIZE);
8286 ++ if (num_trbs == 0)
8287 + num_trbs++;
8288 +- running_total += TRB_MAX_BUFF_SIZE;
8289 +- }
8290 +
8291 + return num_trbs;
8292 + }
8293 +@@ -3234,6 +3245,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
8294 + start_trb = &ep_ring->enqueue->generic;
8295 + start_cycle = ep_ring->cycle_state;
8296 +
8297 ++ urb_priv = urb->hcpriv;
8298 + /* Queue the first TRB, even if it's zero-length */
8299 + for (i = 0; i < num_tds; i++) {
8300 + unsigned int total_packet_count;
8301 +@@ -3245,9 +3257,11 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
8302 + addr = start_addr + urb->iso_frame_desc[i].offset;
8303 + td_len = urb->iso_frame_desc[i].length;
8304 + td_remain_len = td_len;
8305 +- /* FIXME: Ignoring zero-length packets, can those happen? */
8306 + total_packet_count = roundup(td_len,
8307 + le16_to_cpu(urb->ep->desc.wMaxPacketSize));
8308 ++ /* A zero-length transfer still involves at least one packet. */
8309 ++ if (total_packet_count == 0)
8310 ++ total_packet_count++;
8311 + burst_count = xhci_get_burst_count(xhci, urb->dev, urb,
8312 + total_packet_count);
8313 + residue = xhci_get_last_burst_packet_count(xhci,
8314 +@@ -3257,12 +3271,13 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
8315 +
8316 + ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index,
8317 + urb->stream_id, trbs_per_td, urb, i, mem_flags);
8318 +- if (ret < 0)
8319 +- return ret;
8320 ++ if (ret < 0) {
8321 ++ if (i == 0)
8322 ++ return ret;
8323 ++ goto cleanup;
8324 ++ }
8325 +
8326 +- urb_priv = urb->hcpriv;
8327 + td = urb_priv->td[i];
8328 +-
8329 + for (j = 0; j < trbs_per_td; j++) {
8330 + u32 remainder = 0;
8331 + field = TRB_TBC(burst_count) | TRB_TLBPC(residue);
8332 +@@ -3352,6 +3367,27 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
8333 + giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
8334 + start_cycle, start_trb);
8335 + return 0;
8336 ++cleanup:
8337 ++ /* Clean up a partially enqueued isoc transfer. */
8338 ++
8339 ++ for (i--; i >= 0; i--)
8340 ++ list_del_init(&urb_priv->td[i]->td_list);
8341 ++
8342 ++ /* Use the first TD as a temporary variable to turn the TDs we've queued
8343 ++ * into No-ops with a software-owned cycle bit. That way the hardware
8344 ++ * won't accidentally start executing bogus TDs when we partially
8345 ++ * overwrite them. td->first_trb and td->start_seg are already set.
8346 ++ */
8347 ++ urb_priv->td[0]->last_trb = ep_ring->enqueue;
8348 ++ /* Every TRB except the first & last will have its cycle bit flipped. */
8349 ++ td_to_noop(xhci, ep_ring, urb_priv->td[0], true);
8350 ++
8351 ++ /* Reset the ring enqueue back to the first TRB and its cycle bit. */
8352 ++ ep_ring->enqueue = urb_priv->td[0]->first_trb;
8353 ++ ep_ring->enq_seg = urb_priv->td[0]->start_seg;
8354 ++ ep_ring->cycle_state = start_cycle;
8355 ++ usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);
8356 ++ return ret;
8357 + }
8358 +
8359 + /*
8360 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
8361 +index 9824761..7ea48b3 100644
8362 +--- a/drivers/usb/host/xhci.c
8363 ++++ b/drivers/usb/host/xhci.c
8364 +@@ -1085,8 +1085,11 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
8365 + if (urb->dev->speed == USB_SPEED_FULL) {
8366 + ret = xhci_check_maxpacket(xhci, slot_id,
8367 + ep_index, urb);
8368 +- if (ret < 0)
8369 ++ if (ret < 0) {
8370 ++ xhci_urb_free_priv(xhci, urb_priv);
8371 ++ urb->hcpriv = NULL;
8372 + return ret;
8373 ++ }
8374 + }
8375 +
8376 + /* We have a spinlock and interrupts disabled, so we must pass
8377 +@@ -1097,6 +1100,8 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
8378 + goto dying;
8379 + ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,
8380 + slot_id, ep_index);
8381 ++ if (ret)
8382 ++ goto free_priv;
8383 + spin_unlock_irqrestore(&xhci->lock, flags);
8384 + } else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) {
8385 + spin_lock_irqsave(&xhci->lock, flags);
8386 +@@ -1117,6 +1122,8 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
8387 + ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,
8388 + slot_id, ep_index);
8389 + }
8390 ++ if (ret)
8391 ++ goto free_priv;
8392 + spin_unlock_irqrestore(&xhci->lock, flags);
8393 + } else if (usb_endpoint_xfer_int(&urb->ep->desc)) {
8394 + spin_lock_irqsave(&xhci->lock, flags);
8395 +@@ -1124,6 +1131,8 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
8396 + goto dying;
8397 + ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb,
8398 + slot_id, ep_index);
8399 ++ if (ret)
8400 ++ goto free_priv;
8401 + spin_unlock_irqrestore(&xhci->lock, flags);
8402 + } else {
8403 + spin_lock_irqsave(&xhci->lock, flags);
8404 +@@ -1131,18 +1140,22 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
8405 + goto dying;
8406 + ret = xhci_queue_isoc_tx_prepare(xhci, GFP_ATOMIC, urb,
8407 + slot_id, ep_index);
8408 ++ if (ret)
8409 ++ goto free_priv;
8410 + spin_unlock_irqrestore(&xhci->lock, flags);
8411 + }
8412 + exit:
8413 + return ret;
8414 + dying:
8415 +- xhci_urb_free_priv(xhci, urb_priv);
8416 +- urb->hcpriv = NULL;
8417 + xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for "
8418 + "non-responsive xHCI host.\n",
8419 + urb->ep->desc.bEndpointAddress, urb);
8420 ++ ret = -ESHUTDOWN;
8421 ++free_priv:
8422 ++ xhci_urb_free_priv(xhci, urb_priv);
8423 ++ urb->hcpriv = NULL;
8424 + spin_unlock_irqrestore(&xhci->lock, flags);
8425 +- return -ESHUTDOWN;
8426 ++ return ret;
8427 + }
8428 +
8429 + /* Get the right ring for the given URB.
8430 +@@ -1239,6 +1252,13 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
8431 + if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) {
8432 + xhci_dbg(xhci, "HW died, freeing TD.\n");
8433 + urb_priv = urb->hcpriv;
8434 ++ for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {
8435 ++ td = urb_priv->td[i];
8436 ++ if (!list_empty(&td->td_list))
8437 ++ list_del_init(&td->td_list);
8438 ++ if (!list_empty(&td->cancelled_td_list))
8439 ++ list_del_init(&td->cancelled_td_list);
8440 ++ }
8441 +
8442 + usb_hcd_unlink_urb_from_ep(hcd, urb);
8443 + spin_unlock_irqrestore(&xhci->lock, flags);
8444 +diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
8445 +index 149f3f3..318fb4e 100644
8446 +--- a/drivers/usb/musb/cppi_dma.c
8447 ++++ b/drivers/usb/musb/cppi_dma.c
8448 +@@ -226,8 +226,10 @@ static int cppi_controller_stop(struct dma_controller *c)
8449 + struct cppi *controller;
8450 + void __iomem *tibase;
8451 + int i;
8452 ++ struct musb *musb;
8453 +
8454 + controller = container_of(c, struct cppi, controller);
8455 ++ musb = controller->musb;
8456 +
8457 + tibase = controller->tibase;
8458 + /* DISABLE INDIVIDUAL CHANNEL Interrupts */
8459 +@@ -289,9 +291,11 @@ cppi_channel_allocate(struct dma_controller *c,
8460 + u8 index;
8461 + struct cppi_channel *cppi_ch;
8462 + void __iomem *tibase;
8463 ++ struct musb *musb;
8464 +
8465 + controller = container_of(c, struct cppi, controller);
8466 + tibase = controller->tibase;
8467 ++ musb = controller->musb;
8468 +
8469 + /* ep0 doesn't use DMA; remember cppi indices are 0..N-1 */
8470 + index = ep->epnum - 1;
8471 +@@ -339,7 +343,8 @@ static void cppi_channel_release(struct dma_channel *channel)
8472 + c = container_of(channel, struct cppi_channel, channel);
8473 + tibase = c->controller->tibase;
8474 + if (!c->hw_ep)
8475 +- dev_dbg(musb->controller, "releasing idle DMA channel %p\n", c);
8476 ++ dev_dbg(c->controller->musb->controller,
8477 ++ "releasing idle DMA channel %p\n", c);
8478 + else if (!c->transmit)
8479 + core_rxirq_enable(tibase, c->index + 1);
8480 +
8481 +@@ -357,10 +362,11 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char *tag)
8482 +
8483 + musb_ep_select(base, c->index + 1);
8484 +
8485 +- DBG(level, "RX DMA%d%s: %d left, csr %04x, "
8486 +- "%08x H%08x S%08x C%08x, "
8487 +- "B%08x L%08x %08x .. %08x"
8488 +- "\n",
8489 ++ dev_dbg(c->controller->musb->controller,
8490 ++ "RX DMA%d%s: %d left, csr %04x, "
8491 ++ "%08x H%08x S%08x C%08x, "
8492 ++ "B%08x L%08x %08x .. %08x"
8493 ++ "\n",
8494 + c->index, tag,
8495 + musb_readl(c->controller->tibase,
8496 + DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index),
8497 +@@ -387,10 +393,11 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char *tag)
8498 +
8499 + musb_ep_select(base, c->index + 1);
8500 +
8501 +- DBG(level, "TX DMA%d%s: csr %04x, "
8502 +- "H%08x S%08x C%08x %08x, "
8503 +- "F%08x L%08x .. %08x"
8504 +- "\n",
8505 ++ dev_dbg(c->controller->musb->controller,
8506 ++ "TX DMA%d%s: csr %04x, "
8507 ++ "H%08x S%08x C%08x %08x, "
8508 ++ "F%08x L%08x .. %08x"
8509 ++ "\n",
8510 + c->index, tag,
8511 + musb_readw(c->hw_ep->regs, MUSB_TXCSR),
8512 +
8513 +@@ -1022,6 +1029,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
8514 + int i;
8515 + dma_addr_t safe2ack;
8516 + void __iomem *regs = rx->hw_ep->regs;
8517 ++ struct musb *musb = cppi->musb;
8518 +
8519 + cppi_dump_rx(6, rx, "/K");
8520 +
8521 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
8522 +index 9afb361..f968a3d 100644
8523 +--- a/drivers/usb/serial/ftdi_sio.c
8524 ++++ b/drivers/usb/serial/ftdi_sio.c
8525 +@@ -101,6 +101,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial);
8526 + static int ftdi_mtxorb_hack_setup(struct usb_serial *serial);
8527 + static int ftdi_NDI_device_setup(struct usb_serial *serial);
8528 + static int ftdi_stmclite_probe(struct usb_serial *serial);
8529 ++static int ftdi_8u2232c_probe(struct usb_serial *serial);
8530 + static void ftdi_USB_UIRT_setup(struct ftdi_private *priv);
8531 + static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
8532 +
8533 +@@ -128,6 +129,10 @@ static struct ftdi_sio_quirk ftdi_stmclite_quirk = {
8534 + .probe = ftdi_stmclite_probe,
8535 + };
8536 +
8537 ++static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
8538 ++ .probe = ftdi_8u2232c_probe,
8539 ++};
8540 ++
8541 + /*
8542 + * The 8U232AM has the same API as the sio except for:
8543 + * - it can support MUCH higher baudrates; up to:
8544 +@@ -177,7 +182,8 @@ static struct usb_device_id id_table_combined [] = {
8545 + { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
8546 + { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
8547 + { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) },
8548 +- { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
8549 ++ { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) ,
8550 ++ .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk },
8551 + { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
8552 + { USB_DEVICE(FTDI_VID, FTDI_232H_PID) },
8553 + { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
8554 +@@ -1733,6 +1739,18 @@ static int ftdi_jtag_probe(struct usb_serial *serial)
8555 + return 0;
8556 + }
8557 +
8558 ++static int ftdi_8u2232c_probe(struct usb_serial *serial)
8559 ++{
8560 ++ struct usb_device *udev = serial->dev;
8561 ++
8562 ++ dbg("%s", __func__);
8563 ++
8564 ++ if (strcmp(udev->manufacturer, "CALAO Systems") == 0)
8565 ++ return ftdi_jtag_probe(serial);
8566 ++
8567 ++ return 0;
8568 ++}
8569 ++
8570 + /*
8571 + * First and second port on STMCLiteadaptors is reserved for JTAG interface
8572 + * and the forth port for pio
8573 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
8574 +index 8156561..fe22e90 100644
8575 +--- a/drivers/usb/serial/option.c
8576 ++++ b/drivers/usb/serial/option.c
8577 +@@ -148,6 +148,8 @@ static void option_instat_callback(struct urb *urb);
8578 + #define HUAWEI_PRODUCT_K4505 0x1464
8579 + #define HUAWEI_PRODUCT_K3765 0x1465
8580 + #define HUAWEI_PRODUCT_E14AC 0x14AC
8581 ++#define HUAWEI_PRODUCT_K3806 0x14AE
8582 ++#define HUAWEI_PRODUCT_K4605 0x14C6
8583 + #define HUAWEI_PRODUCT_K3770 0x14C9
8584 + #define HUAWEI_PRODUCT_K3771 0x14CA
8585 + #define HUAWEI_PRODUCT_K4510 0x14CB
8586 +@@ -416,6 +418,56 @@ static void option_instat_callback(struct urb *urb);
8587 + #define SAMSUNG_VENDOR_ID 0x04e8
8588 + #define SAMSUNG_PRODUCT_GT_B3730 0x6889
8589 +
8590 ++/* YUGA products www.yuga-info.com*/
8591 ++#define YUGA_VENDOR_ID 0x257A
8592 ++#define YUGA_PRODUCT_CEM600 0x1601
8593 ++#define YUGA_PRODUCT_CEM610 0x1602
8594 ++#define YUGA_PRODUCT_CEM500 0x1603
8595 ++#define YUGA_PRODUCT_CEM510 0x1604
8596 ++#define YUGA_PRODUCT_CEM800 0x1605
8597 ++#define YUGA_PRODUCT_CEM900 0x1606
8598 ++
8599 ++#define YUGA_PRODUCT_CEU818 0x1607
8600 ++#define YUGA_PRODUCT_CEU816 0x1608
8601 ++#define YUGA_PRODUCT_CEU828 0x1609
8602 ++#define YUGA_PRODUCT_CEU826 0x160A
8603 ++#define YUGA_PRODUCT_CEU518 0x160B
8604 ++#define YUGA_PRODUCT_CEU516 0x160C
8605 ++#define YUGA_PRODUCT_CEU528 0x160D
8606 ++#define YUGA_PRODUCT_CEU526 0x160F
8607 ++
8608 ++#define YUGA_PRODUCT_CWM600 0x2601
8609 ++#define YUGA_PRODUCT_CWM610 0x2602
8610 ++#define YUGA_PRODUCT_CWM500 0x2603
8611 ++#define YUGA_PRODUCT_CWM510 0x2604
8612 ++#define YUGA_PRODUCT_CWM800 0x2605
8613 ++#define YUGA_PRODUCT_CWM900 0x2606
8614 ++
8615 ++#define YUGA_PRODUCT_CWU718 0x2607
8616 ++#define YUGA_PRODUCT_CWU716 0x2608
8617 ++#define YUGA_PRODUCT_CWU728 0x2609
8618 ++#define YUGA_PRODUCT_CWU726 0x260A
8619 ++#define YUGA_PRODUCT_CWU518 0x260B
8620 ++#define YUGA_PRODUCT_CWU516 0x260C
8621 ++#define YUGA_PRODUCT_CWU528 0x260D
8622 ++#define YUGA_PRODUCT_CWU526 0x260F
8623 ++
8624 ++#define YUGA_PRODUCT_CLM600 0x2601
8625 ++#define YUGA_PRODUCT_CLM610 0x2602
8626 ++#define YUGA_PRODUCT_CLM500 0x2603
8627 ++#define YUGA_PRODUCT_CLM510 0x2604
8628 ++#define YUGA_PRODUCT_CLM800 0x2605
8629 ++#define YUGA_PRODUCT_CLM900 0x2606
8630 ++
8631 ++#define YUGA_PRODUCT_CLU718 0x2607
8632 ++#define YUGA_PRODUCT_CLU716 0x2608
8633 ++#define YUGA_PRODUCT_CLU728 0x2609
8634 ++#define YUGA_PRODUCT_CLU726 0x260A
8635 ++#define YUGA_PRODUCT_CLU518 0x260B
8636 ++#define YUGA_PRODUCT_CLU516 0x260C
8637 ++#define YUGA_PRODUCT_CLU528 0x260D
8638 ++#define YUGA_PRODUCT_CLU526 0x260F
8639 ++
8640 + /* some devices interfaces need special handling due to a number of reasons */
8641 + enum option_blacklist_reason {
8642 + OPTION_BLACKLIST_NONE = 0,
8643 +@@ -551,6 +603,8 @@ static const struct usb_device_id option_ids[] = {
8644 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff) },
8645 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ETS1220, 0xff, 0xff, 0xff) },
8646 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14AC, 0xff, 0xff, 0xff) },
8647 ++ { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3806, 0xff, 0xff, 0xff) },
8648 ++ { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4605, 0xff, 0xff, 0xff) },
8649 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3770, 0xff, 0x02, 0x31) },
8650 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3770, 0xff, 0x02, 0x32) },
8651 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3771, 0xff, 0x02, 0x31) },
8652 +@@ -1005,6 +1059,48 @@ static const struct usb_device_id option_ids[] = {
8653 + { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
8654 + { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
8655 + { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
8656 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
8657 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) },
8658 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM500) },
8659 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM510) },
8660 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM800) },
8661 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM900) },
8662 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU818) },
8663 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU816) },
8664 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU828) },
8665 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU826) },
8666 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU518) },
8667 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU516) },
8668 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU528) },
8669 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU526) },
8670 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM600) },
8671 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM610) },
8672 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM500) },
8673 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM510) },
8674 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM800) },
8675 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM900) },
8676 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU718) },
8677 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU716) },
8678 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU728) },
8679 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU726) },
8680 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU518) },
8681 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU516) },
8682 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU528) },
8683 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU526) },
8684 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM600) },
8685 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM610) },
8686 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM500) },
8687 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM510) },
8688 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM800) },
8689 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM900) },
8690 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU718) },
8691 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU716) },
8692 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU728) },
8693 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU726) },
8694 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU518) },
8695 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU516) },
8696 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU528) },
8697 ++ { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) },
8698 + { } /* Terminating entry */
8699 + };
8700 + MODULE_DEVICE_TABLE(usb, option_ids);
8701 +@@ -1134,11 +1230,13 @@ static int option_probe(struct usb_serial *serial,
8702 + serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff)
8703 + return -ENODEV;
8704 +
8705 +- /* Don't bind network interfaces on Huawei K3765 & K4505 */
8706 ++ /* Don't bind network interfaces on Huawei K3765, K4505 & K4605 */
8707 + if (serial->dev->descriptor.idVendor == HUAWEI_VENDOR_ID &&
8708 + (serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K3765 ||
8709 +- serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K4505) &&
8710 +- serial->interface->cur_altsetting->desc.bInterfaceNumber == 1)
8711 ++ serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K4505 ||
8712 ++ serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K4605) &&
8713 ++ (serial->interface->cur_altsetting->desc.bInterfaceNumber == 1 ||
8714 ++ serial->interface->cur_altsetting->desc.bInterfaceNumber == 2))
8715 + return -ENODEV;
8716 +
8717 + /* Don't bind network interface on Samsung GT-B3730, it is handled by a separate module */
8718 +diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
8719 +index 0c20831..1d33260 100644
8720 +--- a/drivers/usb/serial/pl2303.c
8721 ++++ b/drivers/usb/serial/pl2303.c
8722 +@@ -343,10 +343,28 @@ static void pl2303_set_termios(struct tty_struct *tty,
8723 + baud = 6000000;
8724 + }
8725 + dbg("%s - baud set = %d", __func__, baud);
8726 +- buf[0] = baud & 0xff;
8727 +- buf[1] = (baud >> 8) & 0xff;
8728 +- buf[2] = (baud >> 16) & 0xff;
8729 +- buf[3] = (baud >> 24) & 0xff;
8730 ++ if (baud <= 115200) {
8731 ++ buf[0] = baud & 0xff;
8732 ++ buf[1] = (baud >> 8) & 0xff;
8733 ++ buf[2] = (baud >> 16) & 0xff;
8734 ++ buf[3] = (baud >> 24) & 0xff;
8735 ++ } else {
8736 ++ /* apparently the formula for higher speeds is:
8737 ++ * baudrate = 12M * 32 / (2^buf[1]) / buf[0]
8738 ++ */
8739 ++ unsigned tmp = 12*1000*1000*32 / baud;
8740 ++ buf[3] = 0x80;
8741 ++ buf[2] = 0;
8742 ++ buf[1] = (tmp >= 256);
8743 ++ while (tmp >= 256) {
8744 ++ tmp >>= 2;
8745 ++ buf[1] <<= 1;
8746 ++ }
8747 ++ if (tmp > 256) {
8748 ++ tmp %= 256;
8749 ++ }
8750 ++ buf[0] = tmp;
8751 ++ }
8752 + }
8753 +
8754 + /* For reference buf[4]=0 is 1 stop bits */
8755 +diff --git a/drivers/video/savage/savagefb.h b/drivers/video/savage/savagefb.h
8756 +index 32549d1..dcaab90 100644
8757 +--- a/drivers/video/savage/savagefb.h
8758 ++++ b/drivers/video/savage/savagefb.h
8759 +@@ -55,7 +55,7 @@
8760 +
8761 + #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
8762 +
8763 +-#define S3_SAVAGE4_SERIES(chip) ((chip>=S3_SAVAGE4) || (chip<=S3_PROSAVAGEDDR))
8764 ++#define S3_SAVAGE4_SERIES(chip) ((chip>=S3_SAVAGE4) && (chip<=S3_PROSAVAGEDDR))
8765 +
8766 + #define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE))
8767 +
8768 +diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
8769 +index e0c2807..181fa81 100644
8770 +--- a/drivers/zorro/zorro.c
8771 ++++ b/drivers/zorro/zorro.c
8772 +@@ -148,10 +148,10 @@ static int __init amiga_zorro_probe(struct platform_device *pdev)
8773 + }
8774 + platform_set_drvdata(pdev, bus);
8775 +
8776 +- /* Register all devices */
8777 + pr_info("Zorro: Probing AutoConfig expansion devices: %u device%s\n",
8778 + zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
8779 +
8780 ++ /* First identify all devices ... */
8781 + for (i = 0; i < zorro_num_autocon; i++) {
8782 + z = &zorro_autocon[i];
8783 + z->id = (z->rom.er_Manufacturer<<16) | (z->rom.er_Product<<8);
8784 +@@ -172,6 +172,11 @@ static int __init amiga_zorro_probe(struct platform_device *pdev)
8785 + dev_set_name(&z->dev, "%02x", i);
8786 + z->dev.parent = &bus->dev;
8787 + z->dev.bus = &zorro_bus_type;
8788 ++ }
8789 ++
8790 ++ /* ... then register them */
8791 ++ for (i = 0; i < zorro_num_autocon; i++) {
8792 ++ z = &zorro_autocon[i];
8793 + error = device_register(&z->dev);
8794 + if (error) {
8795 + dev_err(&bus->dev, "Error registering device %s\n",
8796 +diff --git a/fs/9p/acl.c b/fs/9p/acl.c
8797 +index 535ab6e..4a866cd 100644
8798 +--- a/fs/9p/acl.c
8799 ++++ b/fs/9p/acl.c
8800 +@@ -185,12 +185,15 @@ int v9fs_acl_chmod(struct dentry *dentry)
8801 + }
8802 +
8803 + int v9fs_set_create_acl(struct dentry *dentry,
8804 +- struct posix_acl *dpacl, struct posix_acl *pacl)
8805 ++ struct posix_acl **dpacl, struct posix_acl **pacl)
8806 + {
8807 +- v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, dpacl);
8808 +- v9fs_set_acl(dentry, ACL_TYPE_ACCESS, pacl);
8809 +- posix_acl_release(dpacl);
8810 +- posix_acl_release(pacl);
8811 ++ if (dentry) {
8812 ++ v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl);
8813 ++ v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl);
8814 ++ }
8815 ++ posix_acl_release(*dpacl);
8816 ++ posix_acl_release(*pacl);
8817 ++ *dpacl = *pacl = NULL;
8818 + return 0;
8819 + }
8820 +
8821 +@@ -212,11 +215,11 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
8822 + struct posix_acl *clone;
8823 +
8824 + if (S_ISDIR(mode))
8825 +- *dpacl = acl;
8826 ++ *dpacl = posix_acl_dup(acl);
8827 + clone = posix_acl_clone(acl, GFP_NOFS);
8828 +- retval = -ENOMEM;
8829 ++ posix_acl_release(acl);
8830 + if (!clone)
8831 +- goto cleanup;
8832 ++ return -ENOMEM;
8833 +
8834 + retval = posix_acl_create_masq(clone, &mode);
8835 + if (retval < 0) {
8836 +@@ -225,11 +228,12 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
8837 + }
8838 + if (retval > 0)
8839 + *pacl = clone;
8840 ++ else
8841 ++ posix_acl_release(clone);
8842 + }
8843 + *modep = mode;
8844 + return 0;
8845 + cleanup:
8846 +- posix_acl_release(acl);
8847 + return retval;
8848 +
8849 + }
8850 +diff --git a/fs/9p/acl.h b/fs/9p/acl.h
8851 +index 7ef3ac9..c47ea9c 100644
8852 +--- a/fs/9p/acl.h
8853 ++++ b/fs/9p/acl.h
8854 +@@ -19,7 +19,7 @@ extern int v9fs_get_acl(struct inode *, struct p9_fid *);
8855 + extern int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags);
8856 + extern int v9fs_acl_chmod(struct dentry *);
8857 + extern int v9fs_set_create_acl(struct dentry *,
8858 +- struct posix_acl *, struct posix_acl *);
8859 ++ struct posix_acl **, struct posix_acl **);
8860 + extern int v9fs_acl_mode(struct inode *dir, mode_t *modep,
8861 + struct posix_acl **dpacl, struct posix_acl **pacl);
8862 + #else
8863 +@@ -33,8 +33,8 @@ static inline int v9fs_acl_chmod(struct dentry *dentry)
8864 + return 0;
8865 + }
8866 + static inline int v9fs_set_create_acl(struct dentry *dentry,
8867 +- struct posix_acl *dpacl,
8868 +- struct posix_acl *pacl)
8869 ++ struct posix_acl **dpacl,
8870 ++ struct posix_acl **pacl)
8871 + {
8872 + return 0;
8873 + }
8874 +diff --git a/fs/9p/cache.c b/fs/9p/cache.c
8875 +index 5b335c5..945aa5f 100644
8876 +--- a/fs/9p/cache.c
8877 ++++ b/fs/9p/cache.c
8878 +@@ -108,11 +108,10 @@ static uint16_t v9fs_cache_inode_get_key(const void *cookie_netfs_data,
8879 + void *buffer, uint16_t bufmax)
8880 + {
8881 + const struct v9fs_inode *v9inode = cookie_netfs_data;
8882 +- memcpy(buffer, &v9inode->fscache_key->path,
8883 +- sizeof(v9inode->fscache_key->path));
8884 ++ memcpy(buffer, &v9inode->qid.path, sizeof(v9inode->qid.path));
8885 + P9_DPRINTK(P9_DEBUG_FSC, "inode %p get key %llu", &v9inode->vfs_inode,
8886 +- v9inode->fscache_key->path);
8887 +- return sizeof(v9inode->fscache_key->path);
8888 ++ v9inode->qid.path);
8889 ++ return sizeof(v9inode->qid.path);
8890 + }
8891 +
8892 + static void v9fs_cache_inode_get_attr(const void *cookie_netfs_data,
8893 +@@ -129,11 +128,10 @@ static uint16_t v9fs_cache_inode_get_aux(const void *cookie_netfs_data,
8894 + void *buffer, uint16_t buflen)
8895 + {
8896 + const struct v9fs_inode *v9inode = cookie_netfs_data;
8897 +- memcpy(buffer, &v9inode->fscache_key->version,
8898 +- sizeof(v9inode->fscache_key->version));
8899 ++ memcpy(buffer, &v9inode->qid.version, sizeof(v9inode->qid.version));
8900 + P9_DPRINTK(P9_DEBUG_FSC, "inode %p get aux %u", &v9inode->vfs_inode,
8901 +- v9inode->fscache_key->version);
8902 +- return sizeof(v9inode->fscache_key->version);
8903 ++ v9inode->qid.version);
8904 ++ return sizeof(v9inode->qid.version);
8905 + }
8906 +
8907 + static enum
8908 +@@ -143,11 +141,11 @@ fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
8909 + {
8910 + const struct v9fs_inode *v9inode = cookie_netfs_data;
8911 +
8912 +- if (buflen != sizeof(v9inode->fscache_key->version))
8913 ++ if (buflen != sizeof(v9inode->qid.version))
8914 + return FSCACHE_CHECKAUX_OBSOLETE;
8915 +
8916 +- if (memcmp(buffer, &v9inode->fscache_key->version,
8917 +- sizeof(v9inode->fscache_key->version)))
8918 ++ if (memcmp(buffer, &v9inode->qid.version,
8919 ++ sizeof(v9inode->qid.version)))
8920 + return FSCACHE_CHECKAUX_OBSOLETE;
8921 +
8922 + return FSCACHE_CHECKAUX_OKAY;
8923 +diff --git a/fs/9p/cache.h b/fs/9p/cache.h
8924 +index 049507a..40cc54c 100644
8925 +--- a/fs/9p/cache.h
8926 ++++ b/fs/9p/cache.h
8927 +@@ -93,15 +93,6 @@ static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
8928 + BUG_ON(PageFsCache(page));
8929 + }
8930 +
8931 +-static inline void v9fs_fscache_set_key(struct inode *inode,
8932 +- struct p9_qid *qid)
8933 +-{
8934 +- struct v9fs_inode *v9inode = V9FS_I(inode);
8935 +- spin_lock(&v9inode->fscache_lock);
8936 +- v9inode->fscache_key = qid;
8937 +- spin_unlock(&v9inode->fscache_lock);
8938 +-}
8939 +-
8940 + static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
8941 + struct page *page)
8942 + {
8943 +diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
8944 +index c82b017..ef96618 100644
8945 +--- a/fs/9p/v9fs.c
8946 ++++ b/fs/9p/v9fs.c
8947 +@@ -78,6 +78,25 @@ static const match_table_t tokens = {
8948 + {Opt_err, NULL}
8949 + };
8950 +
8951 ++/* Interpret mount options for cache mode */
8952 ++static int get_cache_mode(char *s)
8953 ++{
8954 ++ int version = -EINVAL;
8955 ++
8956 ++ if (!strcmp(s, "loose")) {
8957 ++ version = CACHE_LOOSE;
8958 ++ P9_DPRINTK(P9_DEBUG_9P, "Cache mode: loose\n");
8959 ++ } else if (!strcmp(s, "fscache")) {
8960 ++ version = CACHE_FSCACHE;
8961 ++ P9_DPRINTK(P9_DEBUG_9P, "Cache mode: fscache\n");
8962 ++ } else if (!strcmp(s, "none")) {
8963 ++ version = CACHE_NONE;
8964 ++ P9_DPRINTK(P9_DEBUG_9P, "Cache mode: none\n");
8965 ++ } else
8966 ++ printk(KERN_INFO "9p: Unknown Cache mode %s.\n", s);
8967 ++ return version;
8968 ++}
8969 ++
8970 + /**
8971 + * v9fs_parse_options - parse mount options into session structure
8972 + * @v9ses: existing v9fs session information
8973 +@@ -97,7 +116,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
8974 + /* setup defaults */
8975 + v9ses->afid = ~0;
8976 + v9ses->debug = 0;
8977 +- v9ses->cache = 0;
8978 ++ v9ses->cache = CACHE_NONE;
8979 + #ifdef CONFIG_9P_FSCACHE
8980 + v9ses->cachetag = NULL;
8981 + #endif
8982 +@@ -171,13 +190,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
8983 + "problem allocating copy of cache arg\n");
8984 + goto free_and_return;
8985 + }
8986 ++ ret = get_cache_mode(s);
8987 ++ if (ret == -EINVAL) {
8988 ++ kfree(s);
8989 ++ goto free_and_return;
8990 ++ }
8991 +
8992 +- if (strcmp(s, "loose") == 0)
8993 +- v9ses->cache = CACHE_LOOSE;
8994 +- else if (strcmp(s, "fscache") == 0)
8995 +- v9ses->cache = CACHE_FSCACHE;
8996 +- else
8997 +- v9ses->cache = CACHE_NONE;
8998 ++ v9ses->cache = ret;
8999 + kfree(s);
9000 + break;
9001 +
9002 +@@ -200,9 +219,15 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
9003 + } else {
9004 + v9ses->flags |= V9FS_ACCESS_SINGLE;
9005 + v9ses->uid = simple_strtoul(s, &e, 10);
9006 +- if (*e != '\0')
9007 +- v9ses->uid = ~0;
9008 ++ if (*e != '\0') {
9009 ++ ret = -EINVAL;
9010 ++ printk(KERN_INFO "9p: Unknown access "
9011 ++ "argument %s.\n", s);
9012 ++ kfree(s);
9013 ++ goto free_and_return;
9014 ++ }
9015 + }
9016 ++
9017 + kfree(s);
9018 + break;
9019 +
9020 +@@ -487,8 +512,8 @@ static void v9fs_inode_init_once(void *foo)
9021 + struct v9fs_inode *v9inode = (struct v9fs_inode *)foo;
9022 + #ifdef CONFIG_9P_FSCACHE
9023 + v9inode->fscache = NULL;
9024 +- v9inode->fscache_key = NULL;
9025 + #endif
9026 ++ memset(&v9inode->qid, 0, sizeof(v9inode->qid));
9027 + inode_init_once(&v9inode->vfs_inode);
9028 + }
9029 +
9030 +diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
9031 +index e5ebedf..e78956c 100644
9032 +--- a/fs/9p/v9fs.h
9033 ++++ b/fs/9p/v9fs.h
9034 +@@ -125,8 +125,8 @@ struct v9fs_inode {
9035 + #ifdef CONFIG_9P_FSCACHE
9036 + spinlock_t fscache_lock;
9037 + struct fscache_cookie *fscache;
9038 +- struct p9_qid *fscache_key;
9039 + #endif
9040 ++ struct p9_qid qid;
9041 + unsigned int cache_validity;
9042 + struct p9_fid *writeback_fid;
9043 + struct mutex v_mutex;
9044 +@@ -153,13 +153,13 @@ extern void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd,
9045 + void *p);
9046 + extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
9047 + struct p9_fid *fid,
9048 +- struct super_block *sb);
9049 ++ struct super_block *sb, int new);
9050 + extern const struct inode_operations v9fs_dir_inode_operations_dotl;
9051 + extern const struct inode_operations v9fs_file_inode_operations_dotl;
9052 + extern const struct inode_operations v9fs_symlink_inode_operations_dotl;
9053 + extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,
9054 + struct p9_fid *fid,
9055 +- struct super_block *sb);
9056 ++ struct super_block *sb, int new);
9057 +
9058 + /* other default globals */
9059 + #define V9FS_PORT 564
9060 +@@ -201,8 +201,27 @@ v9fs_get_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
9061 + struct super_block *sb)
9062 + {
9063 + if (v9fs_proto_dotl(v9ses))
9064 +- return v9fs_inode_from_fid_dotl(v9ses, fid, sb);
9065 ++ return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 0);
9066 + else
9067 +- return v9fs_inode_from_fid(v9ses, fid, sb);
9068 ++ return v9fs_inode_from_fid(v9ses, fid, sb, 0);
9069 + }
9070 ++
9071 ++/**
9072 ++ * v9fs_get_new_inode_from_fid - Helper routine to populate an inode by
9073 ++ * issuing a attribute request
9074 ++ * @v9ses: session information
9075 ++ * @fid: fid to issue attribute request for
9076 ++ * @sb: superblock on which to create inode
9077 ++ *
9078 ++ */
9079 ++static inline struct inode *
9080 ++v9fs_get_new_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
9081 ++ struct super_block *sb)
9082 ++{
9083 ++ if (v9fs_proto_dotl(v9ses))
9084 ++ return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 1);
9085 ++ else
9086 ++ return v9fs_inode_from_fid(v9ses, fid, sb, 1);
9087 ++}
9088 ++
9089 + #endif
9090 +diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
9091 +index 4014160..f9a28ea 100644
9092 +--- a/fs/9p/v9fs_vfs.h
9093 ++++ b/fs/9p/v9fs_vfs.h
9094 +@@ -54,9 +54,9 @@ extern struct kmem_cache *v9fs_inode_cache;
9095 +
9096 + struct inode *v9fs_alloc_inode(struct super_block *sb);
9097 + void v9fs_destroy_inode(struct inode *inode);
9098 +-struct inode *v9fs_get_inode(struct super_block *sb, int mode);
9099 ++struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t);
9100 + int v9fs_init_inode(struct v9fs_session_info *v9ses,
9101 +- struct inode *inode, int mode);
9102 ++ struct inode *inode, int mode, dev_t);
9103 + void v9fs_evict_inode(struct inode *inode);
9104 + ino_t v9fs_qid2ino(struct p9_qid *qid);
9105 + void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);
9106 +@@ -82,4 +82,6 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode)
9107 + v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
9108 + return;
9109 + }
9110 ++
9111 ++int v9fs_open_to_dotl_flags(int flags);
9112 + #endif
9113 +diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
9114 +index ffed558..9d6e168 100644
9115 +--- a/fs/9p/vfs_file.c
9116 ++++ b/fs/9p/vfs_file.c
9117 +@@ -65,7 +65,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
9118 + v9inode = V9FS_I(inode);
9119 + v9ses = v9fs_inode2v9ses(inode);
9120 + if (v9fs_proto_dotl(v9ses))
9121 +- omode = file->f_flags;
9122 ++ omode = v9fs_open_to_dotl_flags(file->f_flags);
9123 + else
9124 + omode = v9fs_uflags2omode(file->f_flags,
9125 + v9fs_proto_dotu(v9ses));
9126 +@@ -169,7 +169,18 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
9127 +
9128 + /* convert posix lock to p9 tlock args */
9129 + memset(&flock, 0, sizeof(flock));
9130 +- flock.type = fl->fl_type;
9131 ++ /* map the lock type */
9132 ++ switch (fl->fl_type) {
9133 ++ case F_RDLCK:
9134 ++ flock.type = P9_LOCK_TYPE_RDLCK;
9135 ++ break;
9136 ++ case F_WRLCK:
9137 ++ flock.type = P9_LOCK_TYPE_WRLCK;
9138 ++ break;
9139 ++ case F_UNLCK:
9140 ++ flock.type = P9_LOCK_TYPE_UNLCK;
9141 ++ break;
9142 ++ }
9143 + flock.start = fl->fl_start;
9144 + if (fl->fl_end == OFFSET_MAX)
9145 + flock.length = 0;
9146 +@@ -245,7 +256,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
9147 +
9148 + /* convert posix lock to p9 tgetlock args */
9149 + memset(&glock, 0, sizeof(glock));
9150 +- glock.type = fl->fl_type;
9151 ++ glock.type = P9_LOCK_TYPE_UNLCK;
9152 + glock.start = fl->fl_start;
9153 + if (fl->fl_end == OFFSET_MAX)
9154 + glock.length = 0;
9155 +@@ -257,17 +268,26 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
9156 + res = p9_client_getlock_dotl(fid, &glock);
9157 + if (res < 0)
9158 + return res;
9159 +- if (glock.type != F_UNLCK) {
9160 +- fl->fl_type = glock.type;
9161 ++ /* map 9p lock type to os lock type */
9162 ++ switch (glock.type) {
9163 ++ case P9_LOCK_TYPE_RDLCK:
9164 ++ fl->fl_type = F_RDLCK;
9165 ++ break;
9166 ++ case P9_LOCK_TYPE_WRLCK:
9167 ++ fl->fl_type = F_WRLCK;
9168 ++ break;
9169 ++ case P9_LOCK_TYPE_UNLCK:
9170 ++ fl->fl_type = F_UNLCK;
9171 ++ break;
9172 ++ }
9173 ++ if (glock.type != P9_LOCK_TYPE_UNLCK) {
9174 + fl->fl_start = glock.start;
9175 + if (glock.length == 0)
9176 + fl->fl_end = OFFSET_MAX;
9177 + else
9178 + fl->fl_end = glock.start + glock.length - 1;
9179 + fl->fl_pid = glock.proc_id;
9180 +- } else
9181 +- fl->fl_type = F_UNLCK;
9182 +-
9183 ++ }
9184 + return res;
9185 + }
9186 +
9187 +diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
9188 +index 7f6c677..c72e20c 100644
9189 +--- a/fs/9p/vfs_inode.c
9190 ++++ b/fs/9p/vfs_inode.c
9191 +@@ -95,15 +95,18 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
9192 + /**
9193 + * p9mode2unixmode- convert plan9 mode bits to unix mode bits
9194 + * @v9ses: v9fs session information
9195 +- * @mode: mode to convert
9196 ++ * @stat: p9_wstat from which mode need to be derived
9197 ++ * @rdev: major number, minor number in case of device files.
9198 + *
9199 + */
9200 +-
9201 +-static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
9202 ++static int p9mode2unixmode(struct v9fs_session_info *v9ses,
9203 ++ struct p9_wstat *stat, dev_t *rdev)
9204 + {
9205 + int res;
9206 ++ int mode = stat->mode;
9207 +
9208 +- res = mode & 0777;
9209 ++ res = mode & S_IALLUGO;
9210 ++ *rdev = 0;
9211 +
9212 + if ((mode & P9_DMDIR) == P9_DMDIR)
9213 + res |= S_IFDIR;
9214 +@@ -116,9 +119,26 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
9215 + && (v9ses->nodev == 0))
9216 + res |= S_IFIFO;
9217 + else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
9218 +- && (v9ses->nodev == 0))
9219 +- res |= S_IFBLK;
9220 +- else
9221 ++ && (v9ses->nodev == 0)) {
9222 ++ char type = 0, ext[32];
9223 ++ int major = -1, minor = -1;
9224 ++
9225 ++ strncpy(ext, stat->extension, sizeof(ext));
9226 ++ sscanf(ext, "%c %u %u", &type, &major, &minor);
9227 ++ switch (type) {
9228 ++ case 'c':
9229 ++ res |= S_IFCHR;
9230 ++ break;
9231 ++ case 'b':
9232 ++ res |= S_IFBLK;
9233 ++ break;
9234 ++ default:
9235 ++ P9_DPRINTK(P9_DEBUG_ERROR,
9236 ++ "Unknown special type %c %s\n", type,
9237 ++ stat->extension);
9238 ++ };
9239 ++ *rdev = MKDEV(major, minor);
9240 ++ } else
9241 + res |= S_IFREG;
9242 +
9243 + if (v9fs_proto_dotu(v9ses)) {
9244 +@@ -131,7 +151,6 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
9245 + if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
9246 + res |= S_ISVTX;
9247 + }
9248 +-
9249 + return res;
9250 + }
9251 +
9252 +@@ -216,7 +235,6 @@ struct inode *v9fs_alloc_inode(struct super_block *sb)
9253 + return NULL;
9254 + #ifdef CONFIG_9P_FSCACHE
9255 + v9inode->fscache = NULL;
9256 +- v9inode->fscache_key = NULL;
9257 + spin_lock_init(&v9inode->fscache_lock);
9258 + #endif
9259 + v9inode->writeback_fid = NULL;
9260 +@@ -243,13 +261,13 @@ void v9fs_destroy_inode(struct inode *inode)
9261 + }
9262 +
9263 + int v9fs_init_inode(struct v9fs_session_info *v9ses,
9264 +- struct inode *inode, int mode)
9265 ++ struct inode *inode, int mode, dev_t rdev)
9266 + {
9267 + int err = 0;
9268 +
9269 + inode_init_owner(inode, NULL, mode);
9270 + inode->i_blocks = 0;
9271 +- inode->i_rdev = 0;
9272 ++ inode->i_rdev = rdev;
9273 + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
9274 + inode->i_mapping->a_ops = &v9fs_addr_operations;
9275 +
9276 +@@ -336,7 +354,7 @@ error:
9277 + *
9278 + */
9279 +
9280 +-struct inode *v9fs_get_inode(struct super_block *sb, int mode)
9281 ++struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev)
9282 + {
9283 + int err;
9284 + struct inode *inode;
9285 +@@ -349,7 +367,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
9286 + P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
9287 + return ERR_PTR(-ENOMEM);
9288 + }
9289 +- err = v9fs_init_inode(v9ses, inode, mode);
9290 ++ err = v9fs_init_inode(v9ses, inode, mode, rdev);
9291 + if (err) {
9292 + iput(inode);
9293 + return ERR_PTR(err);
9294 +@@ -433,17 +451,62 @@ void v9fs_evict_inode(struct inode *inode)
9295 + }
9296 + }
9297 +
9298 ++static int v9fs_test_inode(struct inode *inode, void *data)
9299 ++{
9300 ++ int umode;
9301 ++ dev_t rdev;
9302 ++ struct v9fs_inode *v9inode = V9FS_I(inode);
9303 ++ struct p9_wstat *st = (struct p9_wstat *)data;
9304 ++ struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
9305 ++
9306 ++ umode = p9mode2unixmode(v9ses, st, &rdev);
9307 ++ /* don't match inode of different type */
9308 ++ if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
9309 ++ return 0;
9310 ++
9311 ++ /* compare qid details */
9312 ++ if (memcmp(&v9inode->qid.version,
9313 ++ &st->qid.version, sizeof(v9inode->qid.version)))
9314 ++ return 0;
9315 ++
9316 ++ if (v9inode->qid.type != st->qid.type)
9317 ++ return 0;
9318 ++ return 1;
9319 ++}
9320 ++
9321 ++static int v9fs_test_new_inode(struct inode *inode, void *data)
9322 ++{
9323 ++ return 0;
9324 ++}
9325 ++
9326 ++static int v9fs_set_inode(struct inode *inode, void *data)
9327 ++{
9328 ++ struct v9fs_inode *v9inode = V9FS_I(inode);
9329 ++ struct p9_wstat *st = (struct p9_wstat *)data;
9330 ++
9331 ++ memcpy(&v9inode->qid, &st->qid, sizeof(st->qid));
9332 ++ return 0;
9333 ++}
9334 ++
9335 + static struct inode *v9fs_qid_iget(struct super_block *sb,
9336 + struct p9_qid *qid,
9337 +- struct p9_wstat *st)
9338 ++ struct p9_wstat *st,
9339 ++ int new)
9340 + {
9341 ++ dev_t rdev;
9342 + int retval, umode;
9343 + unsigned long i_ino;
9344 + struct inode *inode;
9345 + struct v9fs_session_info *v9ses = sb->s_fs_info;
9346 ++ int (*test)(struct inode *, void *);
9347 ++
9348 ++ if (new)
9349 ++ test = v9fs_test_new_inode;
9350 ++ else
9351 ++ test = v9fs_test_inode;
9352 +
9353 + i_ino = v9fs_qid2ino(qid);
9354 +- inode = iget_locked(sb, i_ino);
9355 ++ inode = iget5_locked(sb, i_ino, test, v9fs_set_inode, st);
9356 + if (!inode)
9357 + return ERR_PTR(-ENOMEM);
9358 + if (!(inode->i_state & I_NEW))
9359 +@@ -453,14 +516,14 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
9360 + * FIXME!! we may need support for stale inodes
9361 + * later.
9362 + */
9363 +- umode = p9mode2unixmode(v9ses, st->mode);
9364 +- retval = v9fs_init_inode(v9ses, inode, umode);
9365 ++ inode->i_ino = i_ino;
9366 ++ umode = p9mode2unixmode(v9ses, st, &rdev);
9367 ++ retval = v9fs_init_inode(v9ses, inode, umode, rdev);
9368 + if (retval)
9369 + goto error;
9370 +
9371 + v9fs_stat2inode(st, inode, sb);
9372 + #ifdef CONFIG_9P_FSCACHE
9373 +- v9fs_fscache_set_key(inode, &st->qid);
9374 + v9fs_cache_inode_get_cookie(inode);
9375 + #endif
9376 + unlock_new_inode(inode);
9377 +@@ -474,7 +537,7 @@ error:
9378 +
9379 + struct inode *
9380 + v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
9381 +- struct super_block *sb)
9382 ++ struct super_block *sb, int new)
9383 + {
9384 + struct p9_wstat *st;
9385 + struct inode *inode = NULL;
9386 +@@ -483,7 +546,7 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
9387 + if (IS_ERR(st))
9388 + return ERR_CAST(st);
9389 +
9390 +- inode = v9fs_qid_iget(sb, &st->qid, st);
9391 ++ inode = v9fs_qid_iget(sb, &st->qid, st, new);
9392 + p9stat_free(st);
9393 + kfree(st);
9394 + return inode;
9395 +@@ -585,19 +648,17 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
9396 + }
9397 +
9398 + /* instantiate inode and assign the unopened fid to the dentry */
9399 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9400 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9401 + if (IS_ERR(inode)) {
9402 + err = PTR_ERR(inode);
9403 + P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
9404 + goto error;
9405 + }
9406 +- d_instantiate(dentry, inode);
9407 + err = v9fs_fid_add(dentry, fid);
9408 + if (err < 0)
9409 + goto error;
9410 +-
9411 ++ d_instantiate(dentry, inode);
9412 + return ofid;
9413 +-
9414 + error:
9415 + if (ofid)
9416 + p9_client_clunk(ofid);
9417 +@@ -738,6 +799,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
9418 + struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
9419 + struct nameidata *nameidata)
9420 + {
9421 ++ struct dentry *res;
9422 + struct super_block *sb;
9423 + struct v9fs_session_info *v9ses;
9424 + struct p9_fid *dfid, *fid;
9425 +@@ -769,22 +831,35 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
9426 +
9427 + return ERR_PTR(result);
9428 + }
9429 +-
9430 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9431 ++ /*
9432 ++ * Make sure we don't use a wrong inode due to parallel
9433 ++ * unlink. For cached mode create calls request for new
9434 ++ * inode. But with cache disabled, lookup should do this.
9435 ++ */
9436 ++ if (v9ses->cache)
9437 ++ inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9438 ++ else
9439 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9440 + if (IS_ERR(inode)) {
9441 + result = PTR_ERR(inode);
9442 + inode = NULL;
9443 + goto error;
9444 + }
9445 +-
9446 + result = v9fs_fid_add(dentry, fid);
9447 + if (result < 0)
9448 + goto error_iput;
9449 +-
9450 + inst_out:
9451 +- d_add(dentry, inode);
9452 +- return NULL;
9453 +-
9454 ++ /*
9455 ++ * If we had a rename on the server and a parallel lookup
9456 ++ * for the new name, then make sure we instantiate with
9457 ++ * the new name. ie look up for a/b, while on server somebody
9458 ++ * moved b under k and client parallely did a lookup for
9459 ++ * k/b.
9460 ++ */
9461 ++ res = d_materialise_unique(dentry, inode);
9462 ++ if (!IS_ERR(res))
9463 ++ return res;
9464 ++ result = PTR_ERR(res);
9465 + error_iput:
9466 + iput(inode);
9467 + error:
9468 +@@ -950,7 +1025,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
9469 + return PTR_ERR(st);
9470 +
9471 + v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
9472 +- generic_fillattr(dentry->d_inode, stat);
9473 ++ generic_fillattr(dentry->d_inode, stat);
9474 +
9475 + p9stat_free(st);
9476 + kfree(st);
9477 +@@ -1034,6 +1109,7 @@ void
9478 + v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
9479 + struct super_block *sb)
9480 + {
9481 ++ mode_t mode;
9482 + char ext[32];
9483 + char tag_name[14];
9484 + unsigned int i_nlink;
9485 +@@ -1069,31 +1145,9 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
9486 + inode->i_nlink = i_nlink;
9487 + }
9488 + }
9489 +- inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
9490 +- if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
9491 +- char type = 0;
9492 +- int major = -1;
9493 +- int minor = -1;
9494 +-
9495 +- strncpy(ext, stat->extension, sizeof(ext));
9496 +- sscanf(ext, "%c %u %u", &type, &major, &minor);
9497 +- switch (type) {
9498 +- case 'c':
9499 +- inode->i_mode &= ~S_IFBLK;
9500 +- inode->i_mode |= S_IFCHR;
9501 +- break;
9502 +- case 'b':
9503 +- break;
9504 +- default:
9505 +- P9_DPRINTK(P9_DEBUG_ERROR,
9506 +- "Unknown special type %c %s\n", type,
9507 +- stat->extension);
9508 +- };
9509 +- inode->i_rdev = MKDEV(major, minor);
9510 +- init_special_inode(inode, inode->i_mode, inode->i_rdev);
9511 +- } else
9512 +- inode->i_rdev = 0;
9513 +-
9514 ++ mode = stat->mode & S_IALLUGO;
9515 ++ mode |= inode->i_mode & ~S_IALLUGO;
9516 ++ inode->i_mode = mode;
9517 + i_size_write(inode, stat->length);
9518 +
9519 + /* not real number of blocks, but 512 byte ones ... */
9520 +@@ -1359,6 +1413,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
9521 +
9522 + int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
9523 + {
9524 ++ int umode;
9525 ++ dev_t rdev;
9526 + loff_t i_size;
9527 + struct p9_wstat *st;
9528 + struct v9fs_session_info *v9ses;
9529 +@@ -1367,6 +1423,12 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
9530 + st = p9_client_stat(fid);
9531 + if (IS_ERR(st))
9532 + return PTR_ERR(st);
9533 ++ /*
9534 ++ * Don't update inode if the file type is different
9535 ++ */
9536 ++ umode = p9mode2unixmode(v9ses, st, &rdev);
9537 ++ if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
9538 ++ goto out;
9539 +
9540 + spin_lock(&inode->i_lock);
9541 + /*
9542 +@@ -1378,6 +1440,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
9543 + if (v9ses->cache)
9544 + inode->i_size = i_size;
9545 + spin_unlock(&inode->i_lock);
9546 ++out:
9547 + p9stat_free(st);
9548 + kfree(st);
9549 + return 0;
9550 +diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
9551 +index 691c78f..c873172 100644
9552 +--- a/fs/9p/vfs_inode_dotl.c
9553 ++++ b/fs/9p/vfs_inode_dotl.c
9554 +@@ -86,18 +86,63 @@ static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode)
9555 + return dentry;
9556 + }
9557 +
9558 ++static int v9fs_test_inode_dotl(struct inode *inode, void *data)
9559 ++{
9560 ++ struct v9fs_inode *v9inode = V9FS_I(inode);
9561 ++ struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
9562 ++
9563 ++ /* don't match inode of different type */
9564 ++ if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
9565 ++ return 0;
9566 ++
9567 ++ if (inode->i_generation != st->st_gen)
9568 ++ return 0;
9569 ++
9570 ++ /* compare qid details */
9571 ++ if (memcmp(&v9inode->qid.version,
9572 ++ &st->qid.version, sizeof(v9inode->qid.version)))
9573 ++ return 0;
9574 ++
9575 ++ if (v9inode->qid.type != st->qid.type)
9576 ++ return 0;
9577 ++ return 1;
9578 ++}
9579 ++
9580 ++/* Always get a new inode */
9581 ++static int v9fs_test_new_inode_dotl(struct inode *inode, void *data)
9582 ++{
9583 ++ return 0;
9584 ++}
9585 ++
9586 ++static int v9fs_set_inode_dotl(struct inode *inode, void *data)
9587 ++{
9588 ++ struct v9fs_inode *v9inode = V9FS_I(inode);
9589 ++ struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
9590 ++
9591 ++ memcpy(&v9inode->qid, &st->qid, sizeof(st->qid));
9592 ++ inode->i_generation = st->st_gen;
9593 ++ return 0;
9594 ++}
9595 ++
9596 + static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
9597 + struct p9_qid *qid,
9598 + struct p9_fid *fid,
9599 +- struct p9_stat_dotl *st)
9600 ++ struct p9_stat_dotl *st,
9601 ++ int new)
9602 + {
9603 + int retval;
9604 + unsigned long i_ino;
9605 + struct inode *inode;
9606 + struct v9fs_session_info *v9ses = sb->s_fs_info;
9607 ++ int (*test)(struct inode *, void *);
9608 ++
9609 ++ if (new)
9610 ++ test = v9fs_test_new_inode_dotl;
9611 ++ else
9612 ++ test = v9fs_test_inode_dotl;
9613 +
9614 + i_ino = v9fs_qid2ino(qid);
9615 +- inode = iget_locked(sb, i_ino);
9616 ++ inode = iget5_locked(sb, i_ino, test, v9fs_set_inode_dotl, st);
9617 + if (!inode)
9618 + return ERR_PTR(-ENOMEM);
9619 + if (!(inode->i_state & I_NEW))
9620 +@@ -107,13 +152,14 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
9621 + * FIXME!! we may need support for stale inodes
9622 + * later.
9623 + */
9624 +- retval = v9fs_init_inode(v9ses, inode, st->st_mode);
9625 ++ inode->i_ino = i_ino;
9626 ++ retval = v9fs_init_inode(v9ses, inode,
9627 ++ st->st_mode, new_decode_dev(st->st_rdev));
9628 + if (retval)
9629 + goto error;
9630 +
9631 + v9fs_stat2inode_dotl(st, inode);
9632 + #ifdef CONFIG_9P_FSCACHE
9633 +- v9fs_fscache_set_key(inode, &st->qid);
9634 + v9fs_cache_inode_get_cookie(inode);
9635 + #endif
9636 + retval = v9fs_get_acl(inode, fid);
9637 +@@ -131,20 +177,72 @@ error:
9638 +
9639 + struct inode *
9640 + v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
9641 +- struct super_block *sb)
9642 ++ struct super_block *sb, int new)
9643 + {
9644 + struct p9_stat_dotl *st;
9645 + struct inode *inode = NULL;
9646 +
9647 +- st = p9_client_getattr_dotl(fid, P9_STATS_BASIC);
9648 ++ st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN);
9649 + if (IS_ERR(st))
9650 + return ERR_CAST(st);
9651 +
9652 +- inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st);
9653 ++ inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st, new);
9654 + kfree(st);
9655 + return inode;
9656 + }
9657 +
9658 ++struct dotl_openflag_map {
9659 ++ int open_flag;
9660 ++ int dotl_flag;
9661 ++};
9662 ++
9663 ++static int v9fs_mapped_dotl_flags(int flags)
9664 ++{
9665 ++ int i;
9666 ++ int rflags = 0;
9667 ++ struct dotl_openflag_map dotl_oflag_map[] = {
9668 ++ { O_CREAT, P9_DOTL_CREATE },
9669 ++ { O_EXCL, P9_DOTL_EXCL },
9670 ++ { O_NOCTTY, P9_DOTL_NOCTTY },
9671 ++ { O_TRUNC, P9_DOTL_TRUNC },
9672 ++ { O_APPEND, P9_DOTL_APPEND },
9673 ++ { O_NONBLOCK, P9_DOTL_NONBLOCK },
9674 ++ { O_DSYNC, P9_DOTL_DSYNC },
9675 ++ { FASYNC, P9_DOTL_FASYNC },
9676 ++ { O_DIRECT, P9_DOTL_DIRECT },
9677 ++ { O_LARGEFILE, P9_DOTL_LARGEFILE },
9678 ++ { O_DIRECTORY, P9_DOTL_DIRECTORY },
9679 ++ { O_NOFOLLOW, P9_DOTL_NOFOLLOW },
9680 ++ { O_NOATIME, P9_DOTL_NOATIME },
9681 ++ { O_CLOEXEC, P9_DOTL_CLOEXEC },
9682 ++ { O_SYNC, P9_DOTL_SYNC},
9683 ++ };
9684 ++ for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
9685 ++ if (flags & dotl_oflag_map[i].open_flag)
9686 ++ rflags |= dotl_oflag_map[i].dotl_flag;
9687 ++ }
9688 ++ return rflags;
9689 ++}
9690 ++
9691 ++/**
9692 ++ * v9fs_open_to_dotl_flags- convert Linux specific open flags to
9693 ++ * plan 9 open flag.
9694 ++ * @flags: flags to convert
9695 ++ */
9696 ++int v9fs_open_to_dotl_flags(int flags)
9697 ++{
9698 ++ int rflags = 0;
9699 ++
9700 ++ /*
9701 ++ * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
9702 ++ * and P9_DOTL_NOACCESS
9703 ++ */
9704 ++ rflags |= flags & O_ACCMODE;
9705 ++ rflags |= v9fs_mapped_dotl_flags(flags);
9706 ++
9707 ++ return rflags;
9708 ++}
9709 ++
9710 + /**
9711 + * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
9712 + * @dir: directory inode that is being created
9713 +@@ -213,7 +311,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
9714 + "Failed to get acl values in creat %d\n", err);
9715 + goto error;
9716 + }
9717 +- err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
9718 ++ err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
9719 ++ mode, gid, &qid);
9720 + if (err < 0) {
9721 + P9_DPRINTK(P9_DEBUG_VFS,
9722 + "p9_client_open_dotl failed in creat %d\n",
9723 +@@ -230,19 +329,19 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
9724 + fid = NULL;
9725 + goto error;
9726 + }
9727 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9728 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9729 + if (IS_ERR(inode)) {
9730 + err = PTR_ERR(inode);
9731 + P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
9732 + goto error;
9733 + }
9734 +- d_instantiate(dentry, inode);
9735 + err = v9fs_fid_add(dentry, fid);
9736 + if (err < 0)
9737 + goto error;
9738 ++ d_instantiate(dentry, inode);
9739 +
9740 + /* Now set the ACL based on the default value */
9741 +- v9fs_set_create_acl(dentry, dacl, pacl);
9742 ++ v9fs_set_create_acl(dentry, &dacl, &pacl);
9743 +
9744 + v9inode = V9FS_I(inode);
9745 + mutex_lock(&v9inode->v_mutex);
9746 +@@ -283,6 +382,7 @@ error:
9747 + err_clunk_old_fid:
9748 + if (ofid)
9749 + p9_client_clunk(ofid);
9750 ++ v9fs_set_create_acl(NULL, &dacl, &pacl);
9751 + return err;
9752 + }
9753 +
9754 +@@ -350,17 +450,17 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
9755 + goto error;
9756 + }
9757 +
9758 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9759 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9760 + if (IS_ERR(inode)) {
9761 + err = PTR_ERR(inode);
9762 + P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
9763 + err);
9764 + goto error;
9765 + }
9766 +- d_instantiate(dentry, inode);
9767 + err = v9fs_fid_add(dentry, fid);
9768 + if (err < 0)
9769 + goto error;
9770 ++ d_instantiate(dentry, inode);
9771 + fid = NULL;
9772 + } else {
9773 + /*
9774 +@@ -368,7 +468,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
9775 + * inode with stat. We need to get an inode
9776 + * so that we can set the acl with dentry
9777 + */
9778 +- inode = v9fs_get_inode(dir->i_sb, mode);
9779 ++ inode = v9fs_get_inode(dir->i_sb, mode, 0);
9780 + if (IS_ERR(inode)) {
9781 + err = PTR_ERR(inode);
9782 + goto error;
9783 +@@ -376,12 +476,13 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
9784 + d_instantiate(dentry, inode);
9785 + }
9786 + /* Now set the ACL based on the default value */
9787 +- v9fs_set_create_acl(dentry, dacl, pacl);
9788 ++ v9fs_set_create_acl(dentry, &dacl, &pacl);
9789 + inc_nlink(dir);
9790 + v9fs_invalidate_inode_attr(dir);
9791 + error:
9792 + if (fid)
9793 + p9_client_clunk(fid);
9794 ++ v9fs_set_create_acl(NULL, &dacl, &pacl);
9795 + return err;
9796 + }
9797 +
9798 +@@ -493,6 +594,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
9799 + void
9800 + v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
9801 + {
9802 ++ mode_t mode;
9803 + struct v9fs_inode *v9inode = V9FS_I(inode);
9804 +
9805 + if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
9806 +@@ -505,11 +607,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
9807 + inode->i_uid = stat->st_uid;
9808 + inode->i_gid = stat->st_gid;
9809 + inode->i_nlink = stat->st_nlink;
9810 +- inode->i_mode = stat->st_mode;
9811 +- inode->i_rdev = new_decode_dev(stat->st_rdev);
9812 +
9813 +- if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode)))
9814 +- init_special_inode(inode, inode->i_mode, inode->i_rdev);
9815 ++ mode = stat->st_mode & S_IALLUGO;
9816 ++ mode |= inode->i_mode & ~S_IALLUGO;
9817 ++ inode->i_mode = mode;
9818 +
9819 + i_size_write(inode, stat->st_size);
9820 + inode->i_blocks = stat->st_blocks;
9821 +@@ -547,7 +648,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
9822 + inode->i_blocks = stat->st_blocks;
9823 + }
9824 + if (stat->st_result_mask & P9_STATS_GEN)
9825 +- inode->i_generation = stat->st_gen;
9826 ++ inode->i_generation = stat->st_gen;
9827 +
9828 + /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
9829 + * because the inode structure does not have fields for them.
9830 +@@ -603,21 +704,21 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
9831 + }
9832 +
9833 + /* instantiate inode and assign the unopened fid to dentry */
9834 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9835 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9836 + if (IS_ERR(inode)) {
9837 + err = PTR_ERR(inode);
9838 + P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
9839 + err);
9840 + goto error;
9841 + }
9842 +- d_instantiate(dentry, inode);
9843 + err = v9fs_fid_add(dentry, fid);
9844 + if (err < 0)
9845 + goto error;
9846 ++ d_instantiate(dentry, inode);
9847 + fid = NULL;
9848 + } else {
9849 + /* Not in cached mode. No need to populate inode with stat */
9850 +- inode = v9fs_get_inode(dir->i_sb, S_IFLNK);
9851 ++ inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
9852 + if (IS_ERR(inode)) {
9853 + err = PTR_ERR(inode);
9854 + goto error;
9855 +@@ -756,24 +857,24 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
9856 + goto error;
9857 + }
9858 +
9859 +- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
9860 ++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
9861 + if (IS_ERR(inode)) {
9862 + err = PTR_ERR(inode);
9863 + P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
9864 + err);
9865 + goto error;
9866 + }
9867 +- d_instantiate(dentry, inode);
9868 + err = v9fs_fid_add(dentry, fid);
9869 + if (err < 0)
9870 + goto error;
9871 ++ d_instantiate(dentry, inode);
9872 + fid = NULL;
9873 + } else {
9874 + /*
9875 + * Not in cached mode. No need to populate inode with stat.
9876 + * socket syscall returns a fd, so we need instantiate
9877 + */
9878 +- inode = v9fs_get_inode(dir->i_sb, mode);
9879 ++ inode = v9fs_get_inode(dir->i_sb, mode, rdev);
9880 + if (IS_ERR(inode)) {
9881 + err = PTR_ERR(inode);
9882 + goto error;
9883 +@@ -781,10 +882,11 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
9884 + d_instantiate(dentry, inode);
9885 + }
9886 + /* Now set the ACL based on the default value */
9887 +- v9fs_set_create_acl(dentry, dacl, pacl);
9888 ++ v9fs_set_create_acl(dentry, &dacl, &pacl);
9889 + error:
9890 + if (fid)
9891 + p9_client_clunk(fid);
9892 ++ v9fs_set_create_acl(NULL, &dacl, &pacl);
9893 + return err;
9894 + }
9895 +
9896 +@@ -838,6 +940,11 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
9897 + st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
9898 + if (IS_ERR(st))
9899 + return PTR_ERR(st);
9900 ++ /*
9901 ++ * Don't update inode if the file type is different
9902 ++ */
9903 ++ if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
9904 ++ goto out;
9905 +
9906 + spin_lock(&inode->i_lock);
9907 + /*
9908 +@@ -849,6 +956,7 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
9909 + if (v9ses->cache)
9910 + inode->i_size = i_size;
9911 + spin_unlock(&inode->i_lock);
9912 ++out:
9913 + kfree(st);
9914 + return 0;
9915 + }
9916 +diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
9917 +index feef6cd..c70251d 100644
9918 +--- a/fs/9p/vfs_super.c
9919 ++++ b/fs/9p/vfs_super.c
9920 +@@ -149,7 +149,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
9921 + else
9922 + sb->s_d_op = &v9fs_dentry_operations;
9923 +
9924 +- inode = v9fs_get_inode(sb, S_IFDIR | mode);
9925 ++ inode = v9fs_get_inode(sb, S_IFDIR | mode, 0);
9926 + if (IS_ERR(inode)) {
9927 + retval = PTR_ERR(inode);
9928 + goto release_sb;
9929 +diff --git a/fs/block_dev.c b/fs/block_dev.c
9930 +index 610e8e0..194cf66 100644
9931 +--- a/fs/block_dev.c
9932 ++++ b/fs/block_dev.c
9933 +@@ -1419,6 +1419,11 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
9934 + WARN_ON_ONCE(bdev->bd_holders);
9935 + sync_blockdev(bdev);
9936 + kill_bdev(bdev);
9937 ++ /* ->release can cause the old bdi to disappear,
9938 ++ * so must switch it out first
9939 ++ */
9940 ++ bdev_inode_switch_bdi(bdev->bd_inode,
9941 ++ &default_backing_dev_info);
9942 + }
9943 + if (bdev->bd_contains == bdev) {
9944 + if (disk->fops->release)
9945 +@@ -1432,8 +1437,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
9946 + disk_put_part(bdev->bd_part);
9947 + bdev->bd_part = NULL;
9948 + bdev->bd_disk = NULL;
9949 +- bdev_inode_switch_bdi(bdev->bd_inode,
9950 +- &default_backing_dev_info);
9951 + if (bdev != bdev->bd_contains)
9952 + victim = bdev->bd_contains;
9953 + bdev->bd_contains = NULL;
9954 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
9955 +index 3601f0a..d42e6bf 100644
9956 +--- a/fs/btrfs/inode.c
9957 ++++ b/fs/btrfs/inode.c
9958 +@@ -4124,7 +4124,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
9959 +
9960 + /* special case for "." */
9961 + if (filp->f_pos == 0) {
9962 +- over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR);
9963 ++ over = filldir(dirent, ".", 1,
9964 ++ filp->f_pos, btrfs_ino(inode), DT_DIR);
9965 + if (over)
9966 + return 0;
9967 + filp->f_pos = 1;
9968 +@@ -4133,7 +4134,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
9969 + if (filp->f_pos == 1) {
9970 + u64 pino = parent_ino(filp->f_path.dentry);
9971 + over = filldir(dirent, "..", 2,
9972 +- 2, pino, DT_DIR);
9973 ++ filp->f_pos, pino, DT_DIR);
9974 + if (over)
9975 + return 0;
9976 + filp->f_pos = 2;
9977 +diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
9978 +index 1a9fe7f..07132c4 100644
9979 +--- a/fs/cifs/cifssmb.c
9980 ++++ b/fs/cifs/cifssmb.c
9981 +@@ -4079,7 +4079,8 @@ int CIFSFindNext(const int xid, struct cifs_tcon *tcon,
9982 + T2_FNEXT_RSP_PARMS *parms;
9983 + char *response_data;
9984 + int rc = 0;
9985 +- int bytes_returned, name_len;
9986 ++ int bytes_returned;
9987 ++ unsigned int name_len;
9988 + __u16 params, byte_count;
9989 +
9990 + cFYI(1, "In FindNext");
9991 +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
9992 +index e0ea721..2451627 100644
9993 +--- a/fs/cifs/connect.c
9994 ++++ b/fs/cifs/connect.c
9995 +@@ -1258,7 +1258,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
9996 + /* ignore */
9997 + } else if (strnicmp(data, "guest", 5) == 0) {
9998 + /* ignore */
9999 +- } else if (strnicmp(data, "rw", 2) == 0) {
10000 ++ } else if (strnicmp(data, "rw", 2) == 0 && strlen(data) == 2) {
10001 + /* ignore */
10002 + } else if (strnicmp(data, "ro", 2) == 0) {
10003 + /* ignore */
10004 +@@ -1361,7 +1361,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
10005 + vol->server_ino = 1;
10006 + } else if (strnicmp(data, "noserverino", 9) == 0) {
10007 + vol->server_ino = 0;
10008 +- } else if (strnicmp(data, "rwpidforward", 4) == 0) {
10009 ++ } else if (strnicmp(data, "rwpidforward", 12) == 0) {
10010 + vol->rwpidforward = 1;
10011 + } else if (strnicmp(data, "cifsacl", 7) == 0) {
10012 + vol->cifs_acl = 1;
10013 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
10014 +index b864839..c94774c 100644
10015 +--- a/fs/ext4/inode.c
10016 ++++ b/fs/ext4/inode.c
10017 +@@ -2756,7 +2756,7 @@ static int write_cache_pages_da(struct address_space *mapping,
10018 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
10019 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
10020 +
10021 +- if (wbc->sync_mode == WB_SYNC_ALL)
10022 ++ if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
10023 + tag = PAGECACHE_TAG_TOWRITE;
10024 + else
10025 + tag = PAGECACHE_TAG_DIRTY;
10026 +@@ -2988,7 +2988,7 @@ static int ext4_da_writepages(struct address_space *mapping,
10027 + }
10028 +
10029 + retry:
10030 +- if (wbc->sync_mode == WB_SYNC_ALL)
10031 ++ if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
10032 + tag_pages_for_writeback(mapping, index, end);
10033 +
10034 + while (!ret && wbc->nr_to_write > 0) {
10035 +diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
10036 +index 0f015a0..fe190a8 100644
10037 +--- a/fs/fs-writeback.c
10038 ++++ b/fs/fs-writeback.c
10039 +@@ -36,6 +36,7 @@ struct wb_writeback_work {
10040 + long nr_pages;
10041 + struct super_block *sb;
10042 + enum writeback_sync_modes sync_mode;
10043 ++ unsigned int tagged_writepages:1;
10044 + unsigned int for_kupdate:1;
10045 + unsigned int range_cyclic:1;
10046 + unsigned int for_background:1;
10047 +@@ -418,6 +419,15 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
10048 + spin_lock(&inode->i_lock);
10049 + inode->i_state &= ~I_SYNC;
10050 + if (!(inode->i_state & I_FREEING)) {
10051 ++ /*
10052 ++ * Sync livelock prevention. Each inode is tagged and synced in
10053 ++ * one shot. If still dirty, it will be redirty_tail()'ed below.
10054 ++ * Update the dirty time to prevent enqueue and sync it again.
10055 ++ */
10056 ++ if ((inode->i_state & I_DIRTY) &&
10057 ++ (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages))
10058 ++ inode->dirtied_when = jiffies;
10059 ++
10060 + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
10061 + /*
10062 + * We didn't write back all the pages. nfs_writepages()
10063 +@@ -650,6 +660,7 @@ static long wb_writeback(struct bdi_writeback *wb,
10064 + {
10065 + struct writeback_control wbc = {
10066 + .sync_mode = work->sync_mode,
10067 ++ .tagged_writepages = work->tagged_writepages,
10068 + .older_than_this = NULL,
10069 + .for_kupdate = work->for_kupdate,
10070 + .for_background = work->for_background,
10071 +@@ -657,7 +668,7 @@ static long wb_writeback(struct bdi_writeback *wb,
10072 + };
10073 + unsigned long oldest_jif;
10074 + long wrote = 0;
10075 +- long write_chunk;
10076 ++ long write_chunk = MAX_WRITEBACK_PAGES;
10077 + struct inode *inode;
10078 +
10079 + if (wbc.for_kupdate) {
10080 +@@ -683,9 +694,7 @@ static long wb_writeback(struct bdi_writeback *wb,
10081 + * (quickly) tag currently dirty pages
10082 + * (maybe slowly) sync all tagged pages
10083 + */
10084 +- if (wbc.sync_mode == WB_SYNC_NONE)
10085 +- write_chunk = MAX_WRITEBACK_PAGES;
10086 +- else
10087 ++ if (wbc.sync_mode == WB_SYNC_ALL || wbc.tagged_writepages)
10088 + write_chunk = LONG_MAX;
10089 +
10090 + wbc.wb_start = jiffies; /* livelock avoidance */
10091 +@@ -1188,10 +1197,11 @@ void writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr)
10092 + {
10093 + DECLARE_COMPLETION_ONSTACK(done);
10094 + struct wb_writeback_work work = {
10095 +- .sb = sb,
10096 +- .sync_mode = WB_SYNC_NONE,
10097 +- .done = &done,
10098 +- .nr_pages = nr,
10099 ++ .sb = sb,
10100 ++ .sync_mode = WB_SYNC_NONE,
10101 ++ .tagged_writepages = 1,
10102 ++ .done = &done,
10103 ++ .nr_pages = nr,
10104 + };
10105 +
10106 + WARN_ON(!rwsem_is_locked(&sb->s_umount));
10107 +diff --git a/fs/namei.c b/fs/namei.c
10108 +index 14ab8d3..b456c7a 100644
10109 +--- a/fs/namei.c
10110 ++++ b/fs/namei.c
10111 +@@ -2582,6 +2582,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
10112 + if (!dir->i_op->rmdir)
10113 + return -EPERM;
10114 +
10115 ++ dget(dentry);
10116 + mutex_lock(&dentry->d_inode->i_mutex);
10117 +
10118 + error = -EBUSY;
10119 +@@ -2602,6 +2603,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
10120 +
10121 + out:
10122 + mutex_unlock(&dentry->d_inode->i_mutex);
10123 ++ dput(dentry);
10124 + if (!error)
10125 + d_delete(dentry);
10126 + return error;
10127 +@@ -3005,6 +3007,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
10128 + if (error)
10129 + return error;
10130 +
10131 ++ dget(new_dentry);
10132 + if (target)
10133 + mutex_lock(&target->i_mutex);
10134 +
10135 +@@ -3025,6 +3028,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
10136 + out:
10137 + if (target)
10138 + mutex_unlock(&target->i_mutex);
10139 ++ dput(new_dentry);
10140 + if (!error)
10141 + if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE))
10142 + d_move(old_dentry,new_dentry);
10143 +diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
10144 +index 25b6a88..5afaa58 100644
10145 +--- a/fs/proc/task_mmu.c
10146 ++++ b/fs/proc/task_mmu.c
10147 +@@ -877,30 +877,54 @@ struct numa_maps_private {
10148 + struct numa_maps md;
10149 + };
10150 +
10151 +-static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty)
10152 ++static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty,
10153 ++ unsigned long nr_pages)
10154 + {
10155 + int count = page_mapcount(page);
10156 +
10157 +- md->pages++;
10158 ++ md->pages += nr_pages;
10159 + if (pte_dirty || PageDirty(page))
10160 +- md->dirty++;
10161 ++ md->dirty += nr_pages;
10162 +
10163 + if (PageSwapCache(page))
10164 +- md->swapcache++;
10165 ++ md->swapcache += nr_pages;
10166 +
10167 + if (PageActive(page) || PageUnevictable(page))
10168 +- md->active++;
10169 ++ md->active += nr_pages;
10170 +
10171 + if (PageWriteback(page))
10172 +- md->writeback++;
10173 ++ md->writeback += nr_pages;
10174 +
10175 + if (PageAnon(page))
10176 +- md->anon++;
10177 ++ md->anon += nr_pages;
10178 +
10179 + if (count > md->mapcount_max)
10180 + md->mapcount_max = count;
10181 +
10182 +- md->node[page_to_nid(page)]++;
10183 ++ md->node[page_to_nid(page)] += nr_pages;
10184 ++}
10185 ++
10186 ++static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma,
10187 ++ unsigned long addr)
10188 ++{
10189 ++ struct page *page;
10190 ++ int nid;
10191 ++
10192 ++ if (!pte_present(pte))
10193 ++ return NULL;
10194 ++
10195 ++ page = vm_normal_page(vma, addr, pte);
10196 ++ if (!page)
10197 ++ return NULL;
10198 ++
10199 ++ if (PageReserved(page))
10200 ++ return NULL;
10201 ++
10202 ++ nid = page_to_nid(page);
10203 ++ if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
10204 ++ return NULL;
10205 ++
10206 ++ return page;
10207 + }
10208 +
10209 + static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
10210 +@@ -912,26 +936,32 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
10211 + pte_t *pte;
10212 +
10213 + md = walk->private;
10214 +- orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
10215 +- do {
10216 +- struct page *page;
10217 +- int nid;
10218 ++ spin_lock(&walk->mm->page_table_lock);
10219 ++ if (pmd_trans_huge(*pmd)) {
10220 ++ if (pmd_trans_splitting(*pmd)) {
10221 ++ spin_unlock(&walk->mm->page_table_lock);
10222 ++ wait_split_huge_page(md->vma->anon_vma, pmd);
10223 ++ } else {
10224 ++ pte_t huge_pte = *(pte_t *)pmd;
10225 ++ struct page *page;
10226 +
10227 +- if (!pte_present(*pte))
10228 +- continue;
10229 ++ page = can_gather_numa_stats(huge_pte, md->vma, addr);
10230 ++ if (page)
10231 ++ gather_stats(page, md, pte_dirty(huge_pte),
10232 ++ HPAGE_PMD_SIZE/PAGE_SIZE);
10233 ++ spin_unlock(&walk->mm->page_table_lock);
10234 ++ return 0;
10235 ++ }
10236 ++ } else {
10237 ++ spin_unlock(&walk->mm->page_table_lock);
10238 ++ }
10239 +
10240 +- page = vm_normal_page(md->vma, addr, *pte);
10241 ++ orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
10242 ++ do {
10243 ++ struct page *page = can_gather_numa_stats(*pte, md->vma, addr);
10244 + if (!page)
10245 + continue;
10246 +-
10247 +- if (PageReserved(page))
10248 +- continue;
10249 +-
10250 +- nid = page_to_nid(page);
10251 +- if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
10252 +- continue;
10253 +-
10254 +- gather_stats(page, md, pte_dirty(*pte));
10255 ++ gather_stats(page, md, pte_dirty(*pte), 1);
10256 +
10257 + } while (pte++, addr += PAGE_SIZE, addr != end);
10258 + pte_unmap_unlock(orig_pte, ptl);
10259 +@@ -952,7 +982,7 @@ static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,
10260 + return 0;
10261 +
10262 + md = walk->private;
10263 +- gather_stats(page, md, pte_dirty(*pte));
10264 ++ gather_stats(page, md, pte_dirty(*pte), 1);
10265 + return 0;
10266 + }
10267 +
10268 +diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
10269 +index d12f8d6..97cf4f2 100644
10270 +--- a/include/linux/mfd/wm8994/pdata.h
10271 ++++ b/include/linux/mfd/wm8994/pdata.h
10272 +@@ -26,7 +26,7 @@ struct wm8994_ldo_pdata {
10273 + struct regulator_init_data *init_data;
10274 + };
10275 +
10276 +-#define WM8994_CONFIGURE_GPIO 0x8000
10277 ++#define WM8994_CONFIGURE_GPIO 0x10000
10278 +
10279 + #define WM8994_DRC_REGS 5
10280 + #define WM8994_EQ_REGS 20
10281 +diff --git a/include/linux/rio_regs.h b/include/linux/rio_regs.h
10282 +index 9026b30..218168a 100644
10283 +--- a/include/linux/rio_regs.h
10284 ++++ b/include/linux/rio_regs.h
10285 +@@ -36,12 +36,12 @@
10286 + #define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */
10287 + #define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */
10288 + #define RIO_PEF_MULTIPORT 0x08000000 /* [VI, 2.1] Multiport */
10289 +-#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */
10290 +-#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */
10291 +-#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */
10292 +-#define RIO_PEF_INB_MBOX2 0x00200000 /* [II] Mailbox 2 */
10293 +-#define RIO_PEF_INB_MBOX3 0x00100000 /* [II] Mailbox 3 */
10294 +-#define RIO_PEF_INB_DOORBELL 0x00080000 /* [II] Doorbells */
10295 ++#define RIO_PEF_INB_MBOX 0x00f00000 /* [II, <= 1.2] Mailboxes */
10296 ++#define RIO_PEF_INB_MBOX0 0x00800000 /* [II, <= 1.2] Mailbox 0 */
10297 ++#define RIO_PEF_INB_MBOX1 0x00400000 /* [II, <= 1.2] Mailbox 1 */
10298 ++#define RIO_PEF_INB_MBOX2 0x00200000 /* [II, <= 1.2] Mailbox 2 */
10299 ++#define RIO_PEF_INB_MBOX3 0x00100000 /* [II, <= 1.2] Mailbox 3 */
10300 ++#define RIO_PEF_INB_DOORBELL 0x00080000 /* [II, <= 1.2] Doorbells */
10301 + #define RIO_PEF_EXT_RT 0x00000200 /* [III, 1.3] Extended route table support */
10302 + #define RIO_PEF_STD_RT 0x00000100 /* [III, 1.3] Standard route table support */
10303 + #define RIO_PEF_CTLS 0x00000010 /* [III] CTLS */
10304 +@@ -102,7 +102,7 @@
10305 + #define RIO_SWITCH_RT_LIMIT 0x34 /* [III, 1.3] Switch Route Table Destination ID Limit CAR */
10306 + #define RIO_RT_MAX_DESTID 0x0000ffff
10307 +
10308 +-#define RIO_MBOX_CSR 0x40 /* [II] Mailbox CSR */
10309 ++#define RIO_MBOX_CSR 0x40 /* [II, <= 1.2] Mailbox CSR */
10310 + #define RIO_MBOX0_AVAIL 0x80000000 /* [II] Mbox 0 avail */
10311 + #define RIO_MBOX0_FULL 0x40000000 /* [II] Mbox 0 full */
10312 + #define RIO_MBOX0_EMPTY 0x20000000 /* [II] Mbox 0 empty */
10313 +@@ -128,8 +128,8 @@
10314 + #define RIO_MBOX3_FAIL 0x00000008 /* [II] Mbox 3 fail */
10315 + #define RIO_MBOX3_ERROR 0x00000004 /* [II] Mbox 3 error */
10316 +
10317 +-#define RIO_WRITE_PORT_CSR 0x44 /* [I] Write Port CSR */
10318 +-#define RIO_DOORBELL_CSR 0x44 /* [II] Doorbell CSR */
10319 ++#define RIO_WRITE_PORT_CSR 0x44 /* [I, <= 1.2] Write Port CSR */
10320 ++#define RIO_DOORBELL_CSR 0x44 /* [II, <= 1.2] Doorbell CSR */
10321 + #define RIO_DOORBELL_AVAIL 0x80000000 /* [II] Doorbell avail */
10322 + #define RIO_DOORBELL_FULL 0x40000000 /* [II] Doorbell full */
10323 + #define RIO_DOORBELL_EMPTY 0x20000000 /* [II] Doorbell empty */
10324 +diff --git a/include/linux/rtc.h b/include/linux/rtc.h
10325 +index b27ebea..93f4d03 100644
10326 +--- a/include/linux/rtc.h
10327 ++++ b/include/linux/rtc.h
10328 +@@ -97,6 +97,9 @@ struct rtc_pll_info {
10329 + #define RTC_AF 0x20 /* Alarm interrupt */
10330 + #define RTC_UF 0x10 /* Update interrupt for 1Hz RTC */
10331 +
10332 ++
10333 ++#define RTC_MAX_FREQ 8192
10334 ++
10335 + #ifdef __KERNEL__
10336 +
10337 + #include <linux/types.h>
10338 +diff --git a/include/linux/tty.h b/include/linux/tty.h
10339 +index d6f0529..6660c41 100644
10340 +--- a/include/linux/tty.h
10341 ++++ b/include/linux/tty.h
10342 +@@ -420,6 +420,8 @@ extern void tty_driver_flush_buffer(struct tty_struct *tty);
10343 + extern void tty_throttle(struct tty_struct *tty);
10344 + extern void tty_unthrottle(struct tty_struct *tty);
10345 + extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
10346 ++extern void tty_driver_remove_tty(struct tty_driver *driver,
10347 ++ struct tty_struct *tty);
10348 + extern void tty_shutdown(struct tty_struct *tty);
10349 + extern void tty_free_termios(struct tty_struct *tty);
10350 + extern int is_current_pgrp_orphaned(void);
10351 +diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
10352 +index 9deeac8..ecdaeb9 100644
10353 +--- a/include/linux/tty_driver.h
10354 ++++ b/include/linux/tty_driver.h
10355 +@@ -47,6 +47,9 @@
10356 + *
10357 + * This routine is called synchronously when a particular tty device
10358 + * is closed for the last time freeing up the resources.
10359 ++ * Note that tty_shutdown() is not called if ops->shutdown is defined.
10360 ++ * This means one is responsible to take care of calling ops->remove (e.g.
10361 ++ * via tty_driver_remove_tty) and releasing tty->termios.
10362 + *
10363 + *
10364 + * void (*cleanup)(struct tty_struct * tty);
10365 +diff --git a/include/linux/writeback.h b/include/linux/writeback.h
10366 +index 17e7ccc..3f6542c 100644
10367 +--- a/include/linux/writeback.h
10368 ++++ b/include/linux/writeback.h
10369 +@@ -47,6 +47,7 @@ struct writeback_control {
10370 + unsigned encountered_congestion:1; /* An output: a queue is full */
10371 + unsigned for_kupdate:1; /* A kupdate writeback */
10372 + unsigned for_background:1; /* A background writeback */
10373 ++ unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
10374 + unsigned for_reclaim:1; /* Invoked from the page allocator */
10375 + unsigned range_cyclic:1; /* range_start is cyclic */
10376 + unsigned more_io:1; /* more io to be dispatched */
10377 +diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
10378 +index 008711e..32f67c3 100644
10379 +--- a/include/net/9p/9p.h
10380 ++++ b/include/net/9p/9p.h
10381 +@@ -278,6 +278,30 @@ enum p9_perm_t {
10382 + P9_DMSETVTX = 0x00010000,
10383 + };
10384 +
10385 ++/* 9p2000.L open flags */
10386 ++#define P9_DOTL_RDONLY 00000000
10387 ++#define P9_DOTL_WRONLY 00000001
10388 ++#define P9_DOTL_RDWR 00000002
10389 ++#define P9_DOTL_NOACCESS 00000003
10390 ++#define P9_DOTL_CREATE 00000100
10391 ++#define P9_DOTL_EXCL 00000200
10392 ++#define P9_DOTL_NOCTTY 00000400
10393 ++#define P9_DOTL_TRUNC 00001000
10394 ++#define P9_DOTL_APPEND 00002000
10395 ++#define P9_DOTL_NONBLOCK 00004000
10396 ++#define P9_DOTL_DSYNC 00010000
10397 ++#define P9_DOTL_FASYNC 00020000
10398 ++#define P9_DOTL_DIRECT 00040000
10399 ++#define P9_DOTL_LARGEFILE 00100000
10400 ++#define P9_DOTL_DIRECTORY 00200000
10401 ++#define P9_DOTL_NOFOLLOW 00400000
10402 ++#define P9_DOTL_NOATIME 01000000
10403 ++#define P9_DOTL_CLOEXEC 02000000
10404 ++#define P9_DOTL_SYNC 04000000
10405 ++
10406 ++/* 9p2000.L at flags */
10407 ++#define P9_DOTL_AT_REMOVEDIR 0x200
10408 ++
10409 + /**
10410 + * enum p9_qid_t - QID types
10411 + * @P9_QTDIR: directory
10412 +@@ -320,6 +344,11 @@ enum p9_qid_t {
10413 + /* Room for readdir header */
10414 + #define P9_READDIRHDRSZ 24
10415 +
10416 ++/* 9p2000.L lock type */
10417 ++#define P9_LOCK_TYPE_RDLCK 0
10418 ++#define P9_LOCK_TYPE_WRLCK 1
10419 ++#define P9_LOCK_TYPE_UNLCK 2
10420 ++
10421 + /**
10422 + * struct p9_str - length prefixed string type
10423 + * @len: length of the string
10424 +diff --git a/ipc/mqueue.c b/ipc/mqueue.c
10425 +index 14fb6d6..ed049ea 100644
10426 +--- a/ipc/mqueue.c
10427 ++++ b/ipc/mqueue.c
10428 +@@ -113,72 +113,75 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
10429 + {
10430 + struct user_struct *u = current_user();
10431 + struct inode *inode;
10432 ++ int ret = -ENOMEM;
10433 +
10434 + inode = new_inode(sb);
10435 +- if (inode) {
10436 +- inode->i_ino = get_next_ino();
10437 +- inode->i_mode = mode;
10438 +- inode->i_uid = current_fsuid();
10439 +- inode->i_gid = current_fsgid();
10440 +- inode->i_mtime = inode->i_ctime = inode->i_atime =
10441 +- CURRENT_TIME;
10442 ++ if (!inode)
10443 ++ goto err;
10444 +
10445 +- if (S_ISREG(mode)) {
10446 +- struct mqueue_inode_info *info;
10447 +- struct task_struct *p = current;
10448 +- unsigned long mq_bytes, mq_msg_tblsz;
10449 +-
10450 +- inode->i_fop = &mqueue_file_operations;
10451 +- inode->i_size = FILENT_SIZE;
10452 +- /* mqueue specific info */
10453 +- info = MQUEUE_I(inode);
10454 +- spin_lock_init(&info->lock);
10455 +- init_waitqueue_head(&info->wait_q);
10456 +- INIT_LIST_HEAD(&info->e_wait_q[0].list);
10457 +- INIT_LIST_HEAD(&info->e_wait_q[1].list);
10458 +- info->notify_owner = NULL;
10459 +- info->qsize = 0;
10460 +- info->user = NULL; /* set when all is ok */
10461 +- memset(&info->attr, 0, sizeof(info->attr));
10462 +- info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
10463 +- info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
10464 +- if (attr) {
10465 +- info->attr.mq_maxmsg = attr->mq_maxmsg;
10466 +- info->attr.mq_msgsize = attr->mq_msgsize;
10467 +- }
10468 +- mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *);
10469 +- info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
10470 +- if (!info->messages)
10471 +- goto out_inode;
10472 +-
10473 +- mq_bytes = (mq_msg_tblsz +
10474 +- (info->attr.mq_maxmsg * info->attr.mq_msgsize));
10475 +-
10476 +- spin_lock(&mq_lock);
10477 +- if (u->mq_bytes + mq_bytes < u->mq_bytes ||
10478 +- u->mq_bytes + mq_bytes >
10479 +- task_rlimit(p, RLIMIT_MSGQUEUE)) {
10480 +- spin_unlock(&mq_lock);
10481 +- /* mqueue_evict_inode() releases info->messages */
10482 +- goto out_inode;
10483 +- }
10484 +- u->mq_bytes += mq_bytes;
10485 +- spin_unlock(&mq_lock);
10486 ++ inode->i_ino = get_next_ino();
10487 ++ inode->i_mode = mode;
10488 ++ inode->i_uid = current_fsuid();
10489 ++ inode->i_gid = current_fsgid();
10490 ++ inode->i_mtime = inode->i_ctime = inode->i_atime = CURRENT_TIME;
10491 ++
10492 ++ if (S_ISREG(mode)) {
10493 ++ struct mqueue_inode_info *info;
10494 ++ struct task_struct *p = current;
10495 ++ unsigned long mq_bytes, mq_msg_tblsz;
10496 ++
10497 ++ inode->i_fop = &mqueue_file_operations;
10498 ++ inode->i_size = FILENT_SIZE;
10499 ++ /* mqueue specific info */
10500 ++ info = MQUEUE_I(inode);
10501 ++ spin_lock_init(&info->lock);
10502 ++ init_waitqueue_head(&info->wait_q);
10503 ++ INIT_LIST_HEAD(&info->e_wait_q[0].list);
10504 ++ INIT_LIST_HEAD(&info->e_wait_q[1].list);
10505 ++ info->notify_owner = NULL;
10506 ++ info->qsize = 0;
10507 ++ info->user = NULL; /* set when all is ok */
10508 ++ memset(&info->attr, 0, sizeof(info->attr));
10509 ++ info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
10510 ++ info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
10511 ++ if (attr) {
10512 ++ info->attr.mq_maxmsg = attr->mq_maxmsg;
10513 ++ info->attr.mq_msgsize = attr->mq_msgsize;
10514 ++ }
10515 ++ mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *);
10516 ++ info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
10517 ++ if (!info->messages)
10518 ++ goto out_inode;
10519 +
10520 +- /* all is ok */
10521 +- info->user = get_uid(u);
10522 +- } else if (S_ISDIR(mode)) {
10523 +- inc_nlink(inode);
10524 +- /* Some things misbehave if size == 0 on a directory */
10525 +- inode->i_size = 2 * DIRENT_SIZE;
10526 +- inode->i_op = &mqueue_dir_inode_operations;
10527 +- inode->i_fop = &simple_dir_operations;
10528 ++ mq_bytes = (mq_msg_tblsz +
10529 ++ (info->attr.mq_maxmsg * info->attr.mq_msgsize));
10530 ++
10531 ++ spin_lock(&mq_lock);
10532 ++ if (u->mq_bytes + mq_bytes < u->mq_bytes ||
10533 ++ u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
10534 ++ spin_unlock(&mq_lock);
10535 ++ /* mqueue_evict_inode() releases info->messages */
10536 ++ ret = -EMFILE;
10537 ++ goto out_inode;
10538 + }
10539 ++ u->mq_bytes += mq_bytes;
10540 ++ spin_unlock(&mq_lock);
10541 ++
10542 ++ /* all is ok */
10543 ++ info->user = get_uid(u);
10544 ++ } else if (S_ISDIR(mode)) {
10545 ++ inc_nlink(inode);
10546 ++ /* Some things misbehave if size == 0 on a directory */
10547 ++ inode->i_size = 2 * DIRENT_SIZE;
10548 ++ inode->i_op = &mqueue_dir_inode_operations;
10549 ++ inode->i_fop = &simple_dir_operations;
10550 + }
10551 ++
10552 + return inode;
10553 + out_inode:
10554 + iput(inode);
10555 +- return NULL;
10556 ++err:
10557 ++ return ERR_PTR(ret);
10558 + }
10559 +
10560 + static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
10561 +@@ -194,8 +197,8 @@ static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
10562 +
10563 + inode = mqueue_get_inode(sb, ns, S_IFDIR | S_ISVTX | S_IRWXUGO,
10564 + NULL);
10565 +- if (!inode) {
10566 +- error = -ENOMEM;
10567 ++ if (IS_ERR(inode)) {
10568 ++ error = PTR_ERR(inode);
10569 + goto out;
10570 + }
10571 +
10572 +@@ -315,8 +318,8 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
10573 + spin_unlock(&mq_lock);
10574 +
10575 + inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
10576 +- if (!inode) {
10577 +- error = -ENOMEM;
10578 ++ if (IS_ERR(inode)) {
10579 ++ error = PTR_ERR(inode);
10580 + spin_lock(&mq_lock);
10581 + ipc_ns->mq_queues_count--;
10582 + goto out_unlock;
10583 +diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
10584 +index d5a3009..dc5114b 100644
10585 +--- a/kernel/irq/chip.c
10586 ++++ b/kernel/irq/chip.c
10587 +@@ -178,7 +178,7 @@ void irq_shutdown(struct irq_desc *desc)
10588 + desc->depth = 1;
10589 + if (desc->irq_data.chip->irq_shutdown)
10590 + desc->irq_data.chip->irq_shutdown(&desc->irq_data);
10591 +- if (desc->irq_data.chip->irq_disable)
10592 ++ else if (desc->irq_data.chip->irq_disable)
10593 + desc->irq_data.chip->irq_disable(&desc->irq_data);
10594 + else
10595 + desc->irq_data.chip->irq_mask(&desc->irq_data);
10596 +diff --git a/kernel/printk.c b/kernel/printk.c
10597 +index 3518539..084982f 100644
10598 +--- a/kernel/printk.c
10599 ++++ b/kernel/printk.c
10600 +@@ -1584,7 +1584,7 @@ static int __init printk_late_init(void)
10601 + struct console *con;
10602 +
10603 + for_each_console(con) {
10604 +- if (con->flags & CON_BOOT) {
10605 ++ if (!keep_bootcon && con->flags & CON_BOOT) {
10606 + printk(KERN_INFO "turn off boot console %s%d\n",
10607 + con->name, con->index);
10608 + unregister_console(con);
10609 +diff --git a/kernel/sched.c b/kernel/sched.c
10610 +index fde6ff9..8b37360 100644
10611 +--- a/kernel/sched.c
10612 ++++ b/kernel/sched.c
10613 +@@ -4242,9 +4242,9 @@ pick_next_task(struct rq *rq)
10614 + }
10615 +
10616 + /*
10617 +- * schedule() is the main scheduler function.
10618 ++ * __schedule() is the main scheduler function.
10619 + */
10620 +-asmlinkage void __sched schedule(void)
10621 ++static void __sched __schedule(void)
10622 + {
10623 + struct task_struct *prev, *next;
10624 + unsigned long *switch_count;
10625 +@@ -4285,16 +4285,6 @@ need_resched:
10626 + if (to_wakeup)
10627 + try_to_wake_up_local(to_wakeup);
10628 + }
10629 +-
10630 +- /*
10631 +- * If we are going to sleep and we have plugged IO
10632 +- * queued, make sure to submit it to avoid deadlocks.
10633 +- */
10634 +- if (blk_needs_flush_plug(prev)) {
10635 +- raw_spin_unlock(&rq->lock);
10636 +- blk_schedule_flush_plug(prev);
10637 +- raw_spin_lock(&rq->lock);
10638 +- }
10639 + }
10640 + switch_count = &prev->nvcsw;
10641 + }
10642 +@@ -4332,6 +4322,26 @@ need_resched:
10643 + if (need_resched())
10644 + goto need_resched;
10645 + }
10646 ++
10647 ++static inline void sched_submit_work(struct task_struct *tsk)
10648 ++{
10649 ++ if (!tsk->state)
10650 ++ return;
10651 ++ /*
10652 ++ * If we are going to sleep and we have plugged IO queued,
10653 ++ * make sure to submit it to avoid deadlocks.
10654 ++ */
10655 ++ if (blk_needs_flush_plug(tsk))
10656 ++ blk_schedule_flush_plug(tsk);
10657 ++}
10658 ++
10659 ++asmlinkage void schedule(void)
10660 ++{
10661 ++ struct task_struct *tsk = current;
10662 ++
10663 ++ sched_submit_work(tsk);
10664 ++ __schedule();
10665 ++}
10666 + EXPORT_SYMBOL(schedule);
10667 +
10668 + #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
10669 +@@ -4405,7 +4415,7 @@ asmlinkage void __sched notrace preempt_schedule(void)
10670 +
10671 + do {
10672 + add_preempt_count_notrace(PREEMPT_ACTIVE);
10673 +- schedule();
10674 ++ __schedule();
10675 + sub_preempt_count_notrace(PREEMPT_ACTIVE);
10676 +
10677 + /*
10678 +@@ -4433,7 +4443,7 @@ asmlinkage void __sched preempt_schedule_irq(void)
10679 + do {
10680 + add_preempt_count(PREEMPT_ACTIVE);
10681 + local_irq_enable();
10682 +- schedule();
10683 ++ __schedule();
10684 + local_irq_disable();
10685 + sub_preempt_count(PREEMPT_ACTIVE);
10686 +
10687 +@@ -5558,7 +5568,7 @@ static inline int should_resched(void)
10688 + static void __cond_resched(void)
10689 + {
10690 + add_preempt_count(PREEMPT_ACTIVE);
10691 +- schedule();
10692 ++ __schedule();
10693 + sub_preempt_count(PREEMPT_ACTIVE);
10694 + }
10695 +
10696 +@@ -7413,6 +7423,7 @@ static void __sdt_free(const struct cpumask *cpu_map)
10697 + struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
10698 + if (sd && (sd->flags & SD_OVERLAP))
10699 + free_sched_groups(sd->groups, 0);
10700 ++ kfree(*per_cpu_ptr(sdd->sd, j));
10701 + kfree(*per_cpu_ptr(sdd->sg, j));
10702 + kfree(*per_cpu_ptr(sdd->sgp, j));
10703 + }
10704 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
10705 +index 59f369f..ea5e1a9 100644
10706 +--- a/kernel/time/alarmtimer.c
10707 ++++ b/kernel/time/alarmtimer.c
10708 +@@ -441,6 +441,8 @@ static int alarm_timer_create(struct k_itimer *new_timer)
10709 + static void alarm_timer_get(struct k_itimer *timr,
10710 + struct itimerspec *cur_setting)
10711 + {
10712 ++ memset(cur_setting, 0, sizeof(struct itimerspec));
10713 ++
10714 + cur_setting->it_interval =
10715 + ktime_to_timespec(timr->it.alarmtimer.period);
10716 + cur_setting->it_value =
10717 +@@ -479,11 +481,17 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
10718 + if (!rtcdev)
10719 + return -ENOTSUPP;
10720 +
10721 +- /* Save old values */
10722 +- old_setting->it_interval =
10723 +- ktime_to_timespec(timr->it.alarmtimer.period);
10724 +- old_setting->it_value =
10725 +- ktime_to_timespec(timr->it.alarmtimer.node.expires);
10726 ++ /*
10727 ++ * XXX HACK! Currently we can DOS a system if the interval
10728 ++ * period on alarmtimers is too small. Cap the interval here
10729 ++ * to 100us and solve this properly in a future patch! -jstultz
10730 ++ */
10731 ++ if ((new_setting->it_interval.tv_sec == 0) &&
10732 ++ (new_setting->it_interval.tv_nsec < 100000))
10733 ++ new_setting->it_interval.tv_nsec = 100000;
10734 ++
10735 ++ if (old_setting)
10736 ++ alarm_timer_get(timr, old_setting);
10737 +
10738 + /* If the timer was already set, cancel it */
10739 + alarm_cancel(&timr->it.alarmtimer);
10740 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
10741 +index 0400553..aec02b6 100644
10742 +--- a/kernel/workqueue.c
10743 ++++ b/kernel/workqueue.c
10744 +@@ -3026,8 +3026,13 @@ reflush:
10745 +
10746 + for_each_cwq_cpu(cpu, wq) {
10747 + struct cpu_workqueue_struct *cwq = get_cwq(cpu, wq);
10748 ++ bool drained;
10749 +
10750 +- if (!cwq->nr_active && list_empty(&cwq->delayed_works))
10751 ++ spin_lock_irq(&cwq->gcwq->lock);
10752 ++ drained = !cwq->nr_active && list_empty(&cwq->delayed_works);
10753 ++ spin_unlock_irq(&cwq->gcwq->lock);
10754 ++
10755 ++ if (drained)
10756 + continue;
10757 +
10758 + if (++flush_cnt == 10 ||
10759 +diff --git a/lib/xz/xz_dec_bcj.c b/lib/xz/xz_dec_bcj.c
10760 +index e51e255..a768e6d 100644
10761 +--- a/lib/xz/xz_dec_bcj.c
10762 ++++ b/lib/xz/xz_dec_bcj.c
10763 +@@ -441,8 +441,12 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
10764 + * next filter in the chain. Apply the BCJ filter on the new data
10765 + * in the output buffer. If everything cannot be filtered, copy it
10766 + * to temp and rewind the output buffer position accordingly.
10767 ++ *
10768 ++ * This needs to be always run when temp.size == 0 to handle a special
10769 ++ * case where the output buffer is full and the next filter has no
10770 ++ * more output coming but hasn't returned XZ_STREAM_END yet.
10771 + */
10772 +- if (s->temp.size < b->out_size - b->out_pos) {
10773 ++ if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0) {
10774 + out_start = b->out_pos;
10775 + memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
10776 + b->out_pos += s->temp.size;
10777 +@@ -465,16 +469,25 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
10778 + s->temp.size = b->out_pos - out_start;
10779 + b->out_pos -= s->temp.size;
10780 + memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size);
10781 ++
10782 ++ /*
10783 ++ * If there wasn't enough input to the next filter to fill
10784 ++ * the output buffer with unfiltered data, there's no point
10785 ++ * to try decoding more data to temp.
10786 ++ */
10787 ++ if (b->out_pos + s->temp.size < b->out_size)
10788 ++ return XZ_OK;
10789 + }
10790 +
10791 + /*
10792 +- * If we have unfiltered data in temp, try to fill by decoding more
10793 +- * data from the next filter. Apply the BCJ filter on temp. Then we
10794 +- * hopefully can fill the actual output buffer by copying filtered
10795 +- * data from temp. A mix of filtered and unfiltered data may be left
10796 +- * in temp; it will be taken care on the next call to this function.
10797 ++ * We have unfiltered data in temp. If the output buffer isn't full
10798 ++ * yet, try to fill the temp buffer by decoding more data from the
10799 ++ * next filter. Apply the BCJ filter on temp. Then we hopefully can
10800 ++ * fill the actual output buffer by copying filtered data from temp.
10801 ++ * A mix of filtered and unfiltered data may be left in temp; it will
10802 ++ * be taken care on the next call to this function.
10803 + */
10804 +- if (s->temp.size > 0) {
10805 ++ if (b->out_pos < b->out_size) {
10806 + /* Make b->out{,_pos,_size} temporarily point to s->temp. */
10807 + s->out = b->out;
10808 + s->out_pos = b->out_pos;
10809 +diff --git a/mm/page-writeback.c b/mm/page-writeback.c
10810 +index 31f6988..955fe35 100644
10811 +--- a/mm/page-writeback.c
10812 ++++ b/mm/page-writeback.c
10813 +@@ -892,12 +892,12 @@ int write_cache_pages(struct address_space *mapping,
10814 + range_whole = 1;
10815 + cycled = 1; /* ignore range_cyclic tests */
10816 + }
10817 +- if (wbc->sync_mode == WB_SYNC_ALL)
10818 ++ if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
10819 + tag = PAGECACHE_TAG_TOWRITE;
10820 + else
10821 + tag = PAGECACHE_TAG_DIRTY;
10822 + retry:
10823 +- if (wbc->sync_mode == WB_SYNC_ALL)
10824 ++ if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
10825 + tag_pages_for_writeback(mapping, index, end);
10826 + done_index = index;
10827 + while (!done && (index <= end)) {
10828 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
10829 +index 4e8985a..0f50cdb 100644
10830 +--- a/mm/page_alloc.c
10831 ++++ b/mm/page_alloc.c
10832 +@@ -1616,6 +1616,21 @@ static void zlc_mark_zone_full(struct zonelist *zonelist, struct zoneref *z)
10833 + set_bit(i, zlc->fullzones);
10834 + }
10835 +
10836 ++/*
10837 ++ * clear all zones full, called after direct reclaim makes progress so that
10838 ++ * a zone that was recently full is not skipped over for up to a second
10839 ++ */
10840 ++static void zlc_clear_zones_full(struct zonelist *zonelist)
10841 ++{
10842 ++ struct zonelist_cache *zlc; /* cached zonelist speedup info */
10843 ++
10844 ++ zlc = zonelist->zlcache_ptr;
10845 ++ if (!zlc)
10846 ++ return;
10847 ++
10848 ++ bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
10849 ++}
10850 ++
10851 + #else /* CONFIG_NUMA */
10852 +
10853 + static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
10854 +@@ -1632,6 +1647,10 @@ static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zoneref *z,
10855 + static void zlc_mark_zone_full(struct zonelist *zonelist, struct zoneref *z)
10856 + {
10857 + }
10858 ++
10859 ++static void zlc_clear_zones_full(struct zonelist *zonelist)
10860 ++{
10861 ++}
10862 + #endif /* CONFIG_NUMA */
10863 +
10864 + /*
10865 +@@ -1664,7 +1683,7 @@ zonelist_scan:
10866 + continue;
10867 + if ((alloc_flags & ALLOC_CPUSET) &&
10868 + !cpuset_zone_allowed_softwall(zone, gfp_mask))
10869 +- goto try_next_zone;
10870 ++ continue;
10871 +
10872 + BUILD_BUG_ON(ALLOC_NO_WATERMARKS < NR_WMARK);
10873 + if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
10874 +@@ -1676,17 +1695,36 @@ zonelist_scan:
10875 + classzone_idx, alloc_flags))
10876 + goto try_this_zone;
10877 +
10878 ++ if (NUMA_BUILD && !did_zlc_setup && nr_online_nodes > 1) {
10879 ++ /*
10880 ++ * we do zlc_setup if there are multiple nodes
10881 ++ * and before considering the first zone allowed
10882 ++ * by the cpuset.
10883 ++ */
10884 ++ allowednodes = zlc_setup(zonelist, alloc_flags);
10885 ++ zlc_active = 1;
10886 ++ did_zlc_setup = 1;
10887 ++ }
10888 ++
10889 + if (zone_reclaim_mode == 0)
10890 + goto this_zone_full;
10891 +
10892 ++ /*
10893 ++ * As we may have just activated ZLC, check if the first
10894 ++ * eligible zone has failed zone_reclaim recently.
10895 ++ */
10896 ++ if (NUMA_BUILD && zlc_active &&
10897 ++ !zlc_zone_worth_trying(zonelist, z, allowednodes))
10898 ++ continue;
10899 ++
10900 + ret = zone_reclaim(zone, gfp_mask, order);
10901 + switch (ret) {
10902 + case ZONE_RECLAIM_NOSCAN:
10903 + /* did not scan */
10904 +- goto try_next_zone;
10905 ++ continue;
10906 + case ZONE_RECLAIM_FULL:
10907 + /* scanned but unreclaimable */
10908 +- goto this_zone_full;
10909 ++ continue;
10910 + default:
10911 + /* did we reclaim enough */
10912 + if (!zone_watermark_ok(zone, order, mark,
10913 +@@ -1703,16 +1741,6 @@ try_this_zone:
10914 + this_zone_full:
10915 + if (NUMA_BUILD)
10916 + zlc_mark_zone_full(zonelist, z);
10917 +-try_next_zone:
10918 +- if (NUMA_BUILD && !did_zlc_setup && nr_online_nodes > 1) {
10919 +- /*
10920 +- * we do zlc_setup after the first zone is tried but only
10921 +- * if there are multiple nodes make it worthwhile
10922 +- */
10923 +- allowednodes = zlc_setup(zonelist, alloc_flags);
10924 +- zlc_active = 1;
10925 +- did_zlc_setup = 1;
10926 +- }
10927 + }
10928 +
10929 + if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
10930 +@@ -1954,6 +1982,10 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
10931 + if (unlikely(!(*did_some_progress)))
10932 + return NULL;
10933 +
10934 ++ /* After successful reclaim, reconsider all zones for allocation */
10935 ++ if (NUMA_BUILD)
10936 ++ zlc_clear_zones_full(zonelist);
10937 ++
10938 + retry:
10939 + page = get_page_from_freelist(gfp_mask, nodemask, order,
10940 + zonelist, high_zoneidx,
10941 +diff --git a/mm/vmalloc.c b/mm/vmalloc.c
10942 +index d3d451b..45ece89 100644
10943 +--- a/mm/vmalloc.c
10944 ++++ b/mm/vmalloc.c
10945 +@@ -2154,6 +2154,14 @@ struct vm_struct *alloc_vm_area(size_t size)
10946 + return NULL;
10947 + }
10948 +
10949 ++ /*
10950 ++ * If the allocated address space is passed to a hypercall
10951 ++ * before being used then we cannot rely on a page fault to
10952 ++ * trigger an update of the page tables. So sync all the page
10953 ++ * tables here.
10954 ++ */
10955 ++ vmalloc_sync_all();
10956 ++
10957 + return area;
10958 + }
10959 + EXPORT_SYMBOL_GPL(alloc_vm_area);
10960 +diff --git a/mm/vmscan.c b/mm/vmscan.c
10961 +index d036e59..6072d74 100644
10962 +--- a/mm/vmscan.c
10963 ++++ b/mm/vmscan.c
10964 +@@ -1748,6 +1748,7 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
10965 + enum lru_list l;
10966 + int noswap = 0;
10967 + int force_scan = 0;
10968 ++ unsigned long nr_force_scan[2];
10969 +
10970 +
10971 + anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) +
10972 +@@ -1770,6 +1771,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
10973 + fraction[0] = 0;
10974 + fraction[1] = 1;
10975 + denominator = 1;
10976 ++ nr_force_scan[0] = 0;
10977 ++ nr_force_scan[1] = SWAP_CLUSTER_MAX;
10978 + goto out;
10979 + }
10980 +
10981 +@@ -1781,6 +1784,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
10982 + fraction[0] = 1;
10983 + fraction[1] = 0;
10984 + denominator = 1;
10985 ++ nr_force_scan[0] = SWAP_CLUSTER_MAX;
10986 ++ nr_force_scan[1] = 0;
10987 + goto out;
10988 + }
10989 + }
10990 +@@ -1829,6 +1834,11 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
10991 + fraction[0] = ap;
10992 + fraction[1] = fp;
10993 + denominator = ap + fp + 1;
10994 ++ if (force_scan) {
10995 ++ unsigned long scan = SWAP_CLUSTER_MAX;
10996 ++ nr_force_scan[0] = div64_u64(scan * ap, denominator);
10997 ++ nr_force_scan[1] = div64_u64(scan * fp, denominator);
10998 ++ }
10999 + out:
11000 + for_each_evictable_lru(l) {
11001 + int file = is_file_lru(l);
11002 +@@ -1849,12 +1859,8 @@ out:
11003 + * memcg, priority drop can cause big latency. So, it's better
11004 + * to scan small amount. See may_noscan above.
11005 + */
11006 +- if (!scan && force_scan) {
11007 +- if (file)
11008 +- scan = SWAP_CLUSTER_MAX;
11009 +- else if (!noswap)
11010 +- scan = SWAP_CLUSTER_MAX;
11011 +- }
11012 ++ if (!scan && force_scan)
11013 ++ scan = nr_force_scan[file];
11014 + nr[l] = scan;
11015 + }
11016 + }
11017 +diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
11018 +index fcc6846..27263fb 100644
11019 +--- a/net/8021q/vlan_core.c
11020 ++++ b/net/8021q/vlan_core.c
11021 +@@ -171,6 +171,8 @@ struct sk_buff *vlan_untag(struct sk_buff *skb)
11022 + if (unlikely(!skb))
11023 + goto err_free;
11024 +
11025 ++ skb_reset_network_header(skb);
11026 ++ skb_reset_transport_header(skb);
11027 + return skb;
11028 +
11029 + err_free:
11030 +diff --git a/net/9p/client.c b/net/9p/client.c
11031 +index 9e3b0e6..5532710 100644
11032 +--- a/net/9p/client.c
11033 ++++ b/net/9p/client.c
11034 +@@ -280,7 +280,8 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag)
11035 + * buffer to read the data into */
11036 + tag++;
11037 +
11038 +- BUG_ON(tag >= c->max_tag);
11039 ++ if(tag >= c->max_tag)
11040 ++ return NULL;
11041 +
11042 + row = tag / P9_ROW_MAXTAG;
11043 + col = tag % P9_ROW_MAXTAG;
11044 +@@ -821,8 +822,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
11045 + if (err)
11046 + goto destroy_fidpool;
11047 +
11048 +- if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize)
11049 +- clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ;
11050 ++ if (clnt->msize > clnt->trans_mod->maxsize)
11051 ++ clnt->msize = clnt->trans_mod->maxsize;
11052 +
11053 + err = p9_client_version(clnt);
11054 + if (err)
11055 +@@ -1249,9 +1250,11 @@ int p9_client_clunk(struct p9_fid *fid)
11056 + P9_DPRINTK(P9_DEBUG_9P, "<<< RCLUNK fid %d\n", fid->fid);
11057 +
11058 + p9_free_req(clnt, req);
11059 +- p9_fid_destroy(fid);
11060 +-
11061 + error:
11062 ++ /*
11063 ++ * Fid is not valid even after a failed clunk
11064 ++ */
11065 ++ p9_fid_destroy(fid);
11066 + return err;
11067 + }
11068 + EXPORT_SYMBOL(p9_client_clunk);
11069 +diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
11070 +index 244e707..e317583 100644
11071 +--- a/net/9p/trans_virtio.c
11072 ++++ b/net/9p/trans_virtio.c
11073 +@@ -263,7 +263,6 @@ p9_virtio_request(struct p9_client *client, struct p9_req_t *req)
11074 + {
11075 + int in, out, inp, outp;
11076 + struct virtio_chan *chan = client->trans;
11077 +- char *rdata = (char *)req->rc+sizeof(struct p9_fcall);
11078 + unsigned long flags;
11079 + size_t pdata_off = 0;
11080 + struct trans_rpage_info *rpinfo = NULL;
11081 +@@ -346,7 +345,8 @@ req_retry_pinned:
11082 + * Arrange in such a way that server places header in the
11083 + * alloced memory and payload onto the user buffer.
11084 + */
11085 +- inp = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, 11);
11086 ++ inp = pack_sg_list(chan->sg, out,
11087 ++ VIRTQUEUE_NUM, req->rc->sdata, 11);
11088 + /*
11089 + * Running executables in the filesystem may result in
11090 + * a read request with kernel buffer as opposed to user buffer.
11091 +@@ -366,8 +366,8 @@ req_retry_pinned:
11092 + }
11093 + in += inp;
11094 + } else {
11095 +- in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata,
11096 +- client->msize);
11097 ++ in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM,
11098 ++ req->rc->sdata, req->rc->capacity);
11099 + }
11100 +
11101 + err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc);
11102 +@@ -592,7 +592,14 @@ static struct p9_trans_module p9_virtio_trans = {
11103 + .close = p9_virtio_close,
11104 + .request = p9_virtio_request,
11105 + .cancel = p9_virtio_cancel,
11106 +- .maxsize = PAGE_SIZE*16,
11107 ++
11108 ++ /*
11109 ++ * We leave one entry for input and one entry for response
11110 ++ * headers. We also skip one more entry to accomodate, address
11111 ++ * that are not at page boundary, that can result in an extra
11112 ++ * page in zero copy.
11113 ++ */
11114 ++ .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3),
11115 + .pref = P9_TRANS_PREF_PAYLOAD_SEP,
11116 + .def = 0,
11117 + .owner = THIS_MODULE,
11118 +diff --git a/net/atm/br2684.c b/net/atm/br2684.c
11119 +index 52cfd0c..d07223c 100644
11120 +--- a/net/atm/br2684.c
11121 ++++ b/net/atm/br2684.c
11122 +@@ -558,12 +558,13 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
11123 + spin_unlock_irqrestore(&rq->lock, flags);
11124 +
11125 + skb_queue_walk_safe(&queue, skb, tmp) {
11126 +- struct net_device *dev = skb->dev;
11127 ++ struct net_device *dev;
11128 ++
11129 ++ br2684_push(atmvcc, skb);
11130 ++ dev = skb->dev;
11131 +
11132 + dev->stats.rx_bytes -= skb->len;
11133 + dev->stats.rx_packets--;
11134 +-
11135 +- br2684_push(atmvcc, skb);
11136 + }
11137 +
11138 + /* initialize netdev carrier state */
11139 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
11140 +index 77930aa..01aa7e7 100644
11141 +--- a/net/bluetooth/hci_event.c
11142 ++++ b/net/bluetooth/hci_event.c
11143 +@@ -56,8 +56,8 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
11144 + if (status)
11145 + return;
11146 +
11147 +- if (test_bit(HCI_MGMT, &hdev->flags) &&
11148 +- test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
11149 ++ if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) &&
11150 ++ test_bit(HCI_MGMT, &hdev->flags))
11151 + mgmt_discovering(hdev->id, 0);
11152 +
11153 + hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
11154 +@@ -74,8 +74,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
11155 + if (status)
11156 + return;
11157 +
11158 +- if (test_bit(HCI_MGMT, &hdev->flags) &&
11159 +- test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
11160 ++ if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) &&
11161 ++ test_bit(HCI_MGMT, &hdev->flags))
11162 + mgmt_discovering(hdev->id, 0);
11163 +
11164 + hci_conn_check_pending(hdev);
11165 +@@ -851,9 +851,8 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
11166 + return;
11167 + }
11168 +
11169 +- if (test_bit(HCI_MGMT, &hdev->flags) &&
11170 +- !test_and_set_bit(HCI_INQUIRY,
11171 +- &hdev->flags))
11172 ++ if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags) &&
11173 ++ test_bit(HCI_MGMT, &hdev->flags))
11174 + mgmt_discovering(hdev->id, 1);
11175 + }
11176 +
11177 +@@ -1225,8 +1224,8 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
11178 +
11179 + BT_DBG("%s status %d", hdev->name, status);
11180 +
11181 +- if (test_bit(HCI_MGMT, &hdev->flags) &&
11182 +- test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
11183 ++ if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) &&
11184 ++ test_bit(HCI_MGMT, &hdev->flags))
11185 + mgmt_discovering(hdev->id, 0);
11186 +
11187 + hci_req_complete(hdev, HCI_OP_INQUIRY, status);
11188 +diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
11189 +index 1bacca4..6f156c1 100644
11190 +--- a/net/bridge/br_if.c
11191 ++++ b/net/bridge/br_if.c
11192 +@@ -231,6 +231,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
11193 + int br_add_bridge(struct net *net, const char *name)
11194 + {
11195 + struct net_device *dev;
11196 ++ int res;
11197 +
11198 + dev = alloc_netdev(sizeof(struct net_bridge), name,
11199 + br_dev_setup);
11200 +@@ -240,7 +241,10 @@ int br_add_bridge(struct net *net, const char *name)
11201 +
11202 + dev_net_set(dev, net);
11203 +
11204 +- return register_netdev(dev);
11205 ++ res = register_netdev(dev);
11206 ++ if (res)
11207 ++ free_netdev(dev);
11208 ++ return res;
11209 + }
11210 +
11211 + int br_del_bridge(struct net *net, const char *name)
11212 +diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
11213 +index 2d85ca7..995cbe0 100644
11214 +--- a/net/bridge/br_multicast.c
11215 ++++ b/net/bridge/br_multicast.c
11216 +@@ -1456,7 +1456,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
11217 + {
11218 + struct sk_buff *skb2;
11219 + const struct ipv6hdr *ip6h;
11220 +- struct icmp6hdr *icmp6h;
11221 ++ u8 icmp6_type;
11222 + u8 nexthdr;
11223 + unsigned len;
11224 + int offset;
11225 +@@ -1502,9 +1502,9 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
11226 + __skb_pull(skb2, offset);
11227 + skb_reset_transport_header(skb2);
11228 +
11229 +- icmp6h = icmp6_hdr(skb2);
11230 ++ icmp6_type = icmp6_hdr(skb2)->icmp6_type;
11231 +
11232 +- switch (icmp6h->icmp6_type) {
11233 ++ switch (icmp6_type) {
11234 + case ICMPV6_MGM_QUERY:
11235 + case ICMPV6_MGM_REPORT:
11236 + case ICMPV6_MGM_REDUCTION:
11237 +@@ -1520,16 +1520,23 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
11238 + err = pskb_trim_rcsum(skb2, len);
11239 + if (err)
11240 + goto out;
11241 ++ err = -EINVAL;
11242 + }
11243 +
11244 ++ ip6h = ipv6_hdr(skb2);
11245 ++
11246 + switch (skb2->ip_summed) {
11247 + case CHECKSUM_COMPLETE:
11248 +- if (!csum_fold(skb2->csum))
11249 ++ if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, skb2->len,
11250 ++ IPPROTO_ICMPV6, skb2->csum))
11251 + break;
11252 + /*FALLTHROUGH*/
11253 + case CHECKSUM_NONE:
11254 +- skb2->csum = 0;
11255 +- if (skb_checksum_complete(skb2))
11256 ++ skb2->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr,
11257 ++ &ip6h->daddr,
11258 ++ skb2->len,
11259 ++ IPPROTO_ICMPV6, 0));
11260 ++ if (__skb_checksum_complete(skb2))
11261 + goto out;
11262 + }
11263 +
11264 +@@ -1537,7 +1544,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
11265 +
11266 + BR_INPUT_SKB_CB(skb)->igmp = 1;
11267 +
11268 +- switch (icmp6h->icmp6_type) {
11269 ++ switch (icmp6_type) {
11270 + case ICMPV6_MGM_REPORT:
11271 + {
11272 + struct mld_msg *mld;
11273 +diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
11274 +index 008dc70..f39ef5c 100644
11275 +--- a/net/core/fib_rules.c
11276 ++++ b/net/core/fib_rules.c
11277 +@@ -384,8 +384,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
11278 + */
11279 + list_for_each_entry(r, &ops->rules_list, list) {
11280 + if (r->action == FR_ACT_GOTO &&
11281 +- r->target == rule->pref) {
11282 +- BUG_ON(rtnl_dereference(r->ctarget) != NULL);
11283 ++ r->target == rule->pref &&
11284 ++ rtnl_dereference(r->ctarget) == NULL) {
11285 + rcu_assign_pointer(r->ctarget, rule);
11286 + if (--ops->unresolved_rules == 0)
11287 + break;
11288 +diff --git a/net/core/neighbour.c b/net/core/neighbour.c
11289 +index 799f06e..16db887 100644
11290 +--- a/net/core/neighbour.c
11291 ++++ b/net/core/neighbour.c
11292 +@@ -1383,11 +1383,15 @@ static void neigh_proxy_process(unsigned long arg)
11293 +
11294 + if (tdif <= 0) {
11295 + struct net_device *dev = skb->dev;
11296 ++
11297 + __skb_unlink(skb, &tbl->proxy_queue);
11298 +- if (tbl->proxy_redo && netif_running(dev))
11299 ++ if (tbl->proxy_redo && netif_running(dev)) {
11300 ++ rcu_read_lock();
11301 + tbl->proxy_redo(skb);
11302 +- else
11303 ++ rcu_read_unlock();
11304 ++ } else {
11305 + kfree_skb(skb);
11306 ++ }
11307 +
11308 + dev_put(dev);
11309 + } else if (!sched_next || tdif < sched_next)
11310 +diff --git a/net/core/scm.c b/net/core/scm.c
11311 +index 4c1ef02..811b53f 100644
11312 +--- a/net/core/scm.c
11313 ++++ b/net/core/scm.c
11314 +@@ -192,7 +192,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
11315 + goto error;
11316 +
11317 + cred->uid = cred->euid = p->creds.uid;
11318 +- cred->gid = cred->egid = p->creds.uid;
11319 ++ cred->gid = cred->egid = p->creds.gid;
11320 + put_cred(p->cred);
11321 + p->cred = cred;
11322 + }
11323 +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
11324 +index 283c0a2..d577199 100644
11325 +--- a/net/ipv4/igmp.c
11326 ++++ b/net/ipv4/igmp.c
11327 +@@ -767,7 +767,7 @@ static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
11328 + break;
11329 + for (i=0; i<nsrcs; i++) {
11330 + /* skip inactive filters */
11331 +- if (pmc->sfcount[MCAST_INCLUDE] ||
11332 ++ if (psf->sf_count[MCAST_INCLUDE] ||
11333 + pmc->sfcount[MCAST_EXCLUDE] !=
11334 + psf->sf_count[MCAST_EXCLUDE])
11335 + continue;
11336 +diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
11337 +index 2e97e3e..929b27b 100644
11338 +--- a/net/ipv4/netfilter.c
11339 ++++ b/net/ipv4/netfilter.c
11340 +@@ -18,17 +18,15 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
11341 + struct rtable *rt;
11342 + struct flowi4 fl4 = {};
11343 + __be32 saddr = iph->saddr;
11344 +- __u8 flags = 0;
11345 ++ __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0;
11346 + unsigned int hh_len;
11347 +
11348 +- if (!skb->sk && addr_type != RTN_LOCAL) {
11349 +- if (addr_type == RTN_UNSPEC)
11350 +- addr_type = inet_addr_type(net, saddr);
11351 +- if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST)
11352 +- flags |= FLOWI_FLAG_ANYSRC;
11353 +- else
11354 +- saddr = 0;
11355 +- }
11356 ++ if (addr_type == RTN_UNSPEC)
11357 ++ addr_type = inet_addr_type(net, saddr);
11358 ++ if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST)
11359 ++ flags |= FLOWI_FLAG_ANYSRC;
11360 ++ else
11361 ++ saddr = 0;
11362 +
11363 + /* some non-standard hacks like ipt_REJECT.c:send_reset() can cause
11364 + * packets with foreign saddr to appear on the NF_INET_LOCAL_OUT hook.
11365 +@@ -38,7 +36,7 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
11366 + fl4.flowi4_tos = RT_TOS(iph->tos);
11367 + fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0;
11368 + fl4.flowi4_mark = skb->mark;
11369 +- fl4.flowi4_flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : flags;
11370 ++ fl4.flowi4_flags = flags;
11371 + rt = ip_route_output_key(net, &fl4);
11372 + if (IS_ERR(rt))
11373 + return -1;
11374 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
11375 +index cdabdbf..75ef66f 100644
11376 +--- a/net/ipv4/route.c
11377 ++++ b/net/ipv4/route.c
11378 +@@ -717,7 +717,7 @@ static inline bool compare_hash_inputs(const struct rtable *rt1,
11379 + {
11380 + return ((((__force u32)rt1->rt_key_dst ^ (__force u32)rt2->rt_key_dst) |
11381 + ((__force u32)rt1->rt_key_src ^ (__force u32)rt2->rt_key_src) |
11382 +- (rt1->rt_iif ^ rt2->rt_iif)) == 0);
11383 ++ (rt1->rt_route_iif ^ rt2->rt_route_iif)) == 0);
11384 + }
11385 +
11386 + static inline int compare_keys(struct rtable *rt1, struct rtable *rt2)
11387 +@@ -727,8 +727,7 @@ static inline int compare_keys(struct rtable *rt1, struct rtable *rt2)
11388 + (rt1->rt_mark ^ rt2->rt_mark) |
11389 + (rt1->rt_key_tos ^ rt2->rt_key_tos) |
11390 + (rt1->rt_route_iif ^ rt2->rt_route_iif) |
11391 +- (rt1->rt_oif ^ rt2->rt_oif) |
11392 +- (rt1->rt_iif ^ rt2->rt_iif)) == 0;
11393 ++ (rt1->rt_oif ^ rt2->rt_oif)) == 0;
11394 + }
11395 +
11396 + static inline int compare_netns(struct rtable *rt1, struct rtable *rt2)
11397 +@@ -2282,9 +2281,8 @@ int ip_route_input_common(struct sk_buff *skb, __be32 daddr, __be32 saddr,
11398 + rth = rcu_dereference(rth->dst.rt_next)) {
11399 + if ((((__force u32)rth->rt_key_dst ^ (__force u32)daddr) |
11400 + ((__force u32)rth->rt_key_src ^ (__force u32)saddr) |
11401 +- (rth->rt_iif ^ iif) |
11402 ++ (rth->rt_route_iif ^ iif) |
11403 + (rth->rt_key_tos ^ tos)) == 0 &&
11404 +- rt_is_input_route(rth) &&
11405 + rth->rt_mark == skb->mark &&
11406 + net_eq(dev_net(rth->dst.dev), net) &&
11407 + !rt_is_expired(rth)) {
11408 +diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
11409 +index 2646149..4382629 100644
11410 +--- a/net/ipv4/syncookies.c
11411 ++++ b/net/ipv4/syncookies.c
11412 +@@ -276,7 +276,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
11413 + int mss;
11414 + struct rtable *rt;
11415 + __u8 rcv_wscale;
11416 +- bool ecn_ok;
11417 ++ bool ecn_ok = false;
11418 +
11419 + if (!sysctl_tcp_syncookies || !th->ack || th->rst)
11420 + goto out;
11421 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
11422 +index bef9f04..b6771f9 100644
11423 +--- a/net/ipv4/tcp_input.c
11424 ++++ b/net/ipv4/tcp_input.c
11425 +@@ -1115,7 +1115,7 @@ static int tcp_is_sackblock_valid(struct tcp_sock *tp, int is_dsack,
11426 + return 0;
11427 +
11428 + /* ...Then it's D-SACK, and must reside below snd_una completely */
11429 +- if (!after(end_seq, tp->snd_una))
11430 ++ if (after(end_seq, tp->snd_una))
11431 + return 0;
11432 +
11433 + if (!before(start_seq, tp->undo_marker))
11434 +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
11435 +index 9cb191e..147ede38 100644
11436 +--- a/net/ipv6/ipv6_sockglue.c
11437 ++++ b/net/ipv6/ipv6_sockglue.c
11438 +@@ -913,7 +913,7 @@ static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
11439 + }
11440 +
11441 + static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
11442 +- char __user *optval, int __user *optlen)
11443 ++ char __user *optval, int __user *optlen, unsigned flags)
11444 + {
11445 + struct ipv6_pinfo *np = inet6_sk(sk);
11446 + int len;
11447 +@@ -962,7 +962,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
11448 +
11449 + msg.msg_control = optval;
11450 + msg.msg_controllen = len;
11451 +- msg.msg_flags = 0;
11452 ++ msg.msg_flags = flags;
11453 +
11454 + lock_sock(sk);
11455 + skb = np->pktoptions;
11456 +@@ -1222,7 +1222,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
11457 + if(level != SOL_IPV6)
11458 + return -ENOPROTOOPT;
11459 +
11460 +- err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
11461 ++ err = do_ipv6_getsockopt(sk, level, optname, optval, optlen, 0);
11462 + #ifdef CONFIG_NETFILTER
11463 + /* we need to exclude all possible ENOPROTOOPTs except default case */
11464 + if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
11465 +@@ -1264,7 +1264,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
11466 + return compat_mc_getsockopt(sk, level, optname, optval, optlen,
11467 + ipv6_getsockopt);
11468 +
11469 +- err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
11470 ++ err = do_ipv6_getsockopt(sk, level, optname, optval, optlen,
11471 ++ MSG_CMSG_COMPAT);
11472 + #ifdef CONFIG_NETFILTER
11473 + /* we need to exclude all possible ENOPROTOOPTs except default case */
11474 + if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
11475 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
11476 +index 3e6ebcd..ee7839f 100644
11477 +--- a/net/ipv6/mcast.c
11478 ++++ b/net/ipv6/mcast.c
11479 +@@ -1059,7 +1059,7 @@ static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
11480 + break;
11481 + for (i=0; i<nsrcs; i++) {
11482 + /* skip inactive filters */
11483 +- if (pmc->mca_sfcount[MCAST_INCLUDE] ||
11484 ++ if (psf->sf_count[MCAST_INCLUDE] ||
11485 + pmc->mca_sfcount[MCAST_EXCLUDE] !=
11486 + psf->sf_count[MCAST_EXCLUDE])
11487 + continue;
11488 +diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
11489 +index 8b9644a..14b8339 100644
11490 +--- a/net/ipv6/syncookies.c
11491 ++++ b/net/ipv6/syncookies.c
11492 +@@ -165,7 +165,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
11493 + int mss;
11494 + struct dst_entry *dst;
11495 + __u8 rcv_wscale;
11496 +- bool ecn_ok;
11497 ++ bool ecn_ok = false;
11498 +
11499 + if (!sysctl_tcp_syncookies || !th->ack || th->rst)
11500 + goto out;
11501 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
11502 +index b83870b..ca7bf10 100644
11503 +--- a/net/mac80211/sta_info.c
11504 ++++ b/net/mac80211/sta_info.c
11505 +@@ -669,7 +669,7 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
11506 + BUG_ON(!sdata->bss);
11507 +
11508 + atomic_dec(&sdata->bss->num_sta_ps);
11509 +- __sta_info_clear_tim_bit(sdata->bss, sta);
11510 ++ sta_info_clear_tim_bit(sta);
11511 + }
11512 +
11513 + local->num_sta--;
11514 +diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
11515 +index 2a318f2..b5d56a2 100644
11516 +--- a/net/sched/sch_prio.c
11517 ++++ b/net/sched/sch_prio.c
11518 +@@ -112,7 +112,7 @@ static struct sk_buff *prio_dequeue(struct Qdisc *sch)
11519 +
11520 + for (prio = 0; prio < q->bands; prio++) {
11521 + struct Qdisc *qdisc = q->queues[prio];
11522 +- struct sk_buff *skb = qdisc->dequeue(qdisc);
11523 ++ struct sk_buff *skb = qdisc_dequeue_peeked(qdisc);
11524 + if (skb) {
11525 + qdisc_bstats_update(sch, skb);
11526 + sch->q.qlen--;
11527 +diff --git a/net/socket.c b/net/socket.c
11528 +index ed46dbb..1ad42d3 100644
11529 +--- a/net/socket.c
11530 ++++ b/net/socket.c
11531 +@@ -1965,8 +1965,9 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
11532 + * used_address->name_len is initialized to UINT_MAX so that the first
11533 + * destination address never matches.
11534 + */
11535 +- if (used_address && used_address->name_len == msg_sys->msg_namelen &&
11536 +- !memcmp(&used_address->name, msg->msg_name,
11537 ++ if (used_address && msg_sys->msg_name &&
11538 ++ used_address->name_len == msg_sys->msg_namelen &&
11539 ++ !memcmp(&used_address->name, msg_sys->msg_name,
11540 + used_address->name_len)) {
11541 + err = sock_sendmsg_nosec(sock, msg_sys, total_len);
11542 + goto out_freectl;
11543 +@@ -1978,8 +1979,9 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
11544 + */
11545 + if (used_address && err >= 0) {
11546 + used_address->name_len = msg_sys->msg_namelen;
11547 +- memcpy(&used_address->name, msg->msg_name,
11548 +- used_address->name_len);
11549 ++ if (msg_sys->msg_name)
11550 ++ memcpy(&used_address->name, msg_sys->msg_name,
11551 ++ used_address->name_len);
11552 + }
11553 +
11554 + out_freectl:
11555 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
11556 +index cea3381..1ac9443 100644
11557 +--- a/net/wireless/nl80211.c
11558 ++++ b/net/wireless/nl80211.c
11559 +@@ -4044,9 +4044,12 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
11560 + if (len % sizeof(u32))
11561 + return -EINVAL;
11562 +
11563 ++ if (settings->n_akm_suites > NL80211_MAX_NR_AKM_SUITES)
11564 ++ return -EINVAL;
11565 ++
11566 + memcpy(settings->akm_suites, data, len);
11567 +
11568 +- for (i = 0; i < settings->n_ciphers_pairwise; i++)
11569 ++ for (i = 0; i < settings->n_akm_suites; i++)
11570 + if (!nl80211_valid_akm_suite(settings->akm_suites[i]))
11571 + return -EINVAL;
11572 + }
11573 +diff --git a/net/wireless/reg.c b/net/wireless/reg.c
11574 +index 4453eb7..379574c 100644
11575 +--- a/net/wireless/reg.c
11576 ++++ b/net/wireless/reg.c
11577 +@@ -852,6 +852,7 @@ static void handle_channel(struct wiphy *wiphy,
11578 + return;
11579 + }
11580 +
11581 ++ chan->beacon_found = false;
11582 + chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags);
11583 + chan->max_antenna_gain = min(chan->orig_mag,
11584 + (int) MBI_TO_DBI(power_rule->max_antenna_gain));
11585 +diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
11586 +index a026b0e..54a0dc2 100644
11587 +--- a/net/xfrm/xfrm_input.c
11588 ++++ b/net/xfrm/xfrm_input.c
11589 +@@ -212,6 +212,11 @@ resume:
11590 + /* only the first xfrm gets the encap type */
11591 + encap_type = 0;
11592 +
11593 ++ if (async && x->repl->check(x, skb, seq)) {
11594 ++ XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR);
11595 ++ goto drop_unlock;
11596 ++ }
11597 ++
11598 + x->repl->advance(x, seq);
11599 +
11600 + x->curlft.bytes += skb->len;
11601 +diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
11602 +index f134130..3388442 100644
11603 +--- a/sound/core/pcm_lib.c
11604 ++++ b/sound/core/pcm_lib.c
11605 +@@ -1758,6 +1758,10 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
11606 + snd_pcm_uframes_t avail = 0;
11607 + long wait_time, tout;
11608 +
11609 ++ init_waitqueue_entry(&wait, current);
11610 ++ set_current_state(TASK_INTERRUPTIBLE);
11611 ++ add_wait_queue(&runtime->tsleep, &wait);
11612 ++
11613 + if (runtime->no_period_wakeup)
11614 + wait_time = MAX_SCHEDULE_TIMEOUT;
11615 + else {
11616 +@@ -1768,16 +1772,32 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
11617 + }
11618 + wait_time = msecs_to_jiffies(wait_time * 1000);
11619 + }
11620 +- init_waitqueue_entry(&wait, current);
11621 +- add_wait_queue(&runtime->tsleep, &wait);
11622 ++
11623 + for (;;) {
11624 + if (signal_pending(current)) {
11625 + err = -ERESTARTSYS;
11626 + break;
11627 + }
11628 ++
11629 ++ /*
11630 ++ * We need to check if space became available already
11631 ++ * (and thus the wakeup happened already) first to close
11632 ++ * the race of space already having become available.
11633 ++ * This check must happen after been added to the waitqueue
11634 ++ * and having current state be INTERRUPTIBLE.
11635 ++ */
11636 ++ if (is_playback)
11637 ++ avail = snd_pcm_playback_avail(runtime);
11638 ++ else
11639 ++ avail = snd_pcm_capture_avail(runtime);
11640 ++ if (avail >= runtime->twake)
11641 ++ break;
11642 + snd_pcm_stream_unlock_irq(substream);
11643 +- tout = schedule_timeout_interruptible(wait_time);
11644 ++
11645 ++ tout = schedule_timeout(wait_time);
11646 ++
11647 + snd_pcm_stream_lock_irq(substream);
11648 ++ set_current_state(TASK_INTERRUPTIBLE);
11649 + switch (runtime->status->state) {
11650 + case SNDRV_PCM_STATE_SUSPENDED:
11651 + err = -ESTRPIPE;
11652 +@@ -1803,14 +1823,9 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
11653 + err = -EIO;
11654 + break;
11655 + }
11656 +- if (is_playback)
11657 +- avail = snd_pcm_playback_avail(runtime);
11658 +- else
11659 +- avail = snd_pcm_capture_avail(runtime);
11660 +- if (avail >= runtime->twake)
11661 +- break;
11662 + }
11663 + _endloop:
11664 ++ set_current_state(TASK_RUNNING);
11665 + remove_wait_queue(&runtime->tsleep, &wait);
11666 + *availp = avail;
11667 + return err;
11668 +diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
11669 +index a7ec703..ecce948 100644
11670 +--- a/sound/pci/fm801.c
11671 ++++ b/sound/pci/fm801.c
11672 +@@ -68,6 +68,7 @@ MODULE_PARM_DESC(enable, "Enable FM801 soundcard.");
11673 + module_param_array(tea575x_tuner, int, NULL, 0444);
11674 + MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (0 = auto, 1 = SF256-PCS, 2=SF256-PCP, 3=SF64-PCR, 8=disable, +16=tuner-only).");
11675 +
11676 ++#define TUNER_DISABLED (1<<3)
11677 + #define TUNER_ONLY (1<<4)
11678 + #define TUNER_TYPE_MASK (~TUNER_ONLY & 0xFFFF)
11679 +
11680 +@@ -1150,7 +1151,8 @@ static int snd_fm801_free(struct fm801 *chip)
11681 +
11682 + __end_hw:
11683 + #ifdef CONFIG_SND_FM801_TEA575X_BOOL
11684 +- snd_tea575x_exit(&chip->tea);
11685 ++ if (!(chip->tea575x_tuner & TUNER_DISABLED))
11686 ++ snd_tea575x_exit(&chip->tea);
11687 + #endif
11688 + if (chip->irq >= 0)
11689 + free_irq(chip->irq, chip);
11690 +@@ -1236,7 +1238,6 @@ static int __devinit snd_fm801_create(struct snd_card *card,
11691 + (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
11692 + if (snd_tea575x_init(&chip->tea)) {
11693 + snd_printk(KERN_ERR "TEA575x radio not found\n");
11694 +- snd_fm801_free(chip);
11695 + return -ENODEV;
11696 + }
11697 + } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) {
11698 +@@ -1251,11 +1252,15 @@ static int __devinit snd_fm801_create(struct snd_card *card,
11699 + }
11700 + if (tea575x_tuner == 4) {
11701 + snd_printk(KERN_ERR "TEA575x radio not found\n");
11702 +- snd_fm801_free(chip);
11703 +- return -ENODEV;
11704 ++ chip->tea575x_tuner = TUNER_DISABLED;
11705 + }
11706 + }
11707 +- strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
11708 ++ if (!(chip->tea575x_tuner & TUNER_DISABLED)) {
11709 ++ strlcpy(chip->tea.card,
11710 ++ snd_fm801_tea575x_gpios[(tea575x_tuner &
11711 ++ TUNER_TYPE_MASK) - 1].name,
11712 ++ sizeof(chip->tea.card));
11713 ++ }
11714 + #endif
11715 +
11716 + *rchip = chip;
11717 +diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
11718 +index 26a1521..fb6fbe4 100644
11719 +--- a/sound/pci/hda/patch_cirrus.c
11720 ++++ b/sound/pci/hda/patch_cirrus.c
11721 +@@ -508,7 +508,7 @@ static int add_volume(struct hda_codec *codec, const char *name,
11722 + int index, unsigned int pval, int dir,
11723 + struct snd_kcontrol **kctlp)
11724 + {
11725 +- char tmp[32];
11726 ++ char tmp[44];
11727 + struct snd_kcontrol_new knew =
11728 + HDA_CODEC_VOLUME_IDX(tmp, index, 0, 0, HDA_OUTPUT);
11729 + knew.private_value = pval;
11730 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
11731 +index 524ff26..4c7cd6b 100644
11732 +--- a/sound/pci/hda/patch_realtek.c
11733 ++++ b/sound/pci/hda/patch_realtek.c
11734 +@@ -397,7 +397,7 @@ struct alc_spec {
11735 + unsigned int auto_mic:1;
11736 + unsigned int automute:1; /* HP automute enabled */
11737 + unsigned int detect_line:1; /* Line-out detection enabled */
11738 +- unsigned int automute_lines:1; /* automute line-out as well */
11739 ++ unsigned int automute_lines:1; /* automute line-out as well; NOP when automute_hp_lo isn't set */
11740 + unsigned int automute_hp_lo:1; /* both HP and LO available */
11741 +
11742 + /* other flags */
11743 +@@ -1161,7 +1161,7 @@ static void update_speakers(struct hda_codec *codec)
11744 + if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
11745 + spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
11746 + return;
11747 +- if (!spec->automute_lines || !spec->automute)
11748 ++ if (!spec->automute || (spec->automute_hp_lo && !spec->automute_lines))
11749 + on = 0;
11750 + else
11751 + on = spec->jack_present;
11752 +@@ -1494,7 +1494,7 @@ static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
11753 + unsigned int val;
11754 + if (!spec->automute)
11755 + val = 0;
11756 +- else if (!spec->automute_lines)
11757 ++ else if (!spec->automute_hp_lo || !spec->automute_lines)
11758 + val = 1;
11759 + else
11760 + val = 2;
11761 +@@ -1515,7 +1515,8 @@ static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
11762 + spec->automute = 0;
11763 + break;
11764 + case 1:
11765 +- if (spec->automute && !spec->automute_lines)
11766 ++ if (spec->automute &&
11767 ++ (!spec->automute_hp_lo || !spec->automute_lines))
11768 + return 0;
11769 + spec->automute = 1;
11770 + spec->automute_lines = 0;
11771 +@@ -1858,7 +1859,9 @@ do_sku:
11772 + * 15 : 1 --> enable the function "Mute internal speaker
11773 + * when the external headphone out jack is plugged"
11774 + */
11775 +- if (!spec->autocfg.hp_pins[0]) {
11776 ++ if (!spec->autocfg.hp_pins[0] &&
11777 ++ !(spec->autocfg.line_out_pins[0] &&
11778 ++ spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
11779 + hda_nid_t nid;
11780 + tmp = (ass >> 11) & 0x3; /* HP to chassis */
11781 + if (tmp == 0)
11782 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
11783 +index 7f81cc2..5c42f3e 100644
11784 +--- a/sound/pci/hda/patch_sigmatel.c
11785 ++++ b/sound/pci/hda/patch_sigmatel.c
11786 +@@ -5470,6 +5470,7 @@ again:
11787 + switch (codec->vendor_id) {
11788 + case 0x111d76d1:
11789 + case 0x111d76d9:
11790 ++ case 0x111d76df:
11791 + case 0x111d76e5:
11792 + case 0x111d7666:
11793 + case 0x111d7667:
11794 +@@ -6399,6 +6400,7 @@ static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
11795 + { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
11796 + { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
11797 + { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
11798 ++ { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
11799 + { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
11800 + { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
11801 + { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
11802 +diff --git a/sound/soc/blackfin/bf5xx-ad193x.c b/sound/soc/blackfin/bf5xx-ad193x.c
11803 +index d6651c0..2f0f836 100644
11804 +--- a/sound/soc/blackfin/bf5xx-ad193x.c
11805 ++++ b/sound/soc/blackfin/bf5xx-ad193x.c
11806 +@@ -103,7 +103,7 @@ static struct snd_soc_dai_link bf5xx_ad193x_dai[] = {
11807 + .cpu_dai_name = "bfin-tdm.0",
11808 + .codec_dai_name ="ad193x-hifi",
11809 + .platform_name = "bfin-tdm-pcm-audio",
11810 +- .codec_name = "ad193x.5",
11811 ++ .codec_name = "spi0.5",
11812 + .ops = &bf5xx_ad193x_ops,
11813 + },
11814 + {
11815 +@@ -112,7 +112,7 @@ static struct snd_soc_dai_link bf5xx_ad193x_dai[] = {
11816 + .cpu_dai_name = "bfin-tdm.1",
11817 + .codec_dai_name ="ad193x-hifi",
11818 + .platform_name = "bfin-tdm-pcm-audio",
11819 +- .codec_name = "ad193x.5",
11820 ++ .codec_name = "spi0.5",
11821 + .ops = &bf5xx_ad193x_ops,
11822 + },
11823 + };
11824 +diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
11825 +index 2374ca5..f1a8be5 100644
11826 +--- a/sound/soc/codecs/ad193x.c
11827 ++++ b/sound/soc/codecs/ad193x.c
11828 +@@ -307,7 +307,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream,
11829 + snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, reg);
11830 +
11831 + reg = snd_soc_read(codec, AD193X_DAC_CTRL2);
11832 +- reg = (reg & (~AD193X_DAC_WORD_LEN_MASK)) | word_len;
11833 ++ reg = (reg & (~AD193X_DAC_WORD_LEN_MASK))
11834 ++ | (word_len << AD193X_DAC_WORD_LEN_SHFT);
11835 + snd_soc_write(codec, AD193X_DAC_CTRL2, reg);
11836 +
11837 + reg = snd_soc_read(codec, AD193X_ADC_CTRL1);
11838 +diff --git a/sound/soc/codecs/ad193x.h b/sound/soc/codecs/ad193x.h
11839 +index 9747b54..cccc2e8 100644
11840 +--- a/sound/soc/codecs/ad193x.h
11841 ++++ b/sound/soc/codecs/ad193x.h
11842 +@@ -34,7 +34,8 @@
11843 + #define AD193X_DAC_LEFT_HIGH (1 << 3)
11844 + #define AD193X_DAC_BCLK_INV (1 << 7)
11845 + #define AD193X_DAC_CTRL2 0x804
11846 +-#define AD193X_DAC_WORD_LEN_MASK 0xC
11847 ++#define AD193X_DAC_WORD_LEN_SHFT 3
11848 ++#define AD193X_DAC_WORD_LEN_MASK 0x18
11849 + #define AD193X_DAC_MASTER_MUTE 1
11850 + #define AD193X_DAC_CHNL_MUTE 0x805
11851 + #define AD193X_DACL1_MUTE 0
11852 +@@ -63,7 +64,7 @@
11853 + #define AD193X_ADC_CTRL1 0x80f
11854 + #define AD193X_ADC_SERFMT_MASK 0x60
11855 + #define AD193X_ADC_SERFMT_STEREO (0 << 5)
11856 +-#define AD193X_ADC_SERFMT_TDM (1 << 2)
11857 ++#define AD193X_ADC_SERFMT_TDM (1 << 5)
11858 + #define AD193X_ADC_SERFMT_AUX (2 << 5)
11859 + #define AD193X_ADC_WORD_LEN_MASK 0x3
11860 + #define AD193X_ADC_CTRL2 0x810
11861 +diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
11862 +index 84f4ad5..9801cd7 100644
11863 +--- a/sound/soc/codecs/ssm2602.c
11864 ++++ b/sound/soc/codecs/ssm2602.c
11865 +@@ -431,7 +431,8 @@ static int ssm2602_set_dai_fmt(struct snd_soc_dai *codec_dai,
11866 + static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
11867 + enum snd_soc_bias_level level)
11868 + {
11869 +- u16 reg = snd_soc_read(codec, SSM2602_PWR) & 0xff7f;
11870 ++ u16 reg = snd_soc_read(codec, SSM2602_PWR);
11871 ++ reg &= ~(PWR_POWER_OFF | PWR_OSC_PDN);
11872 +
11873 + switch (level) {
11874 + case SND_SOC_BIAS_ON:
11875 +diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
11876 +index fff695c..cbaf8b7 100644
11877 +--- a/sound/soc/fsl/mpc5200_dma.c
11878 ++++ b/sound/soc/fsl/mpc5200_dma.c
11879 +@@ -368,7 +368,7 @@ static struct snd_soc_platform_driver mpc5200_audio_dma_platform = {
11880 + .pcm_free = &psc_dma_free,
11881 + };
11882 +
11883 +-static int mpc5200_hpcd_probe(struct of_device *op)
11884 ++static int mpc5200_hpcd_probe(struct platform_device *op)
11885 + {
11886 + phys_addr_t fifo;
11887 + struct psc_dma *psc_dma;
11888 +@@ -486,7 +486,7 @@ out_unmap:
11889 + return ret;
11890 + }
11891 +
11892 +-static int mpc5200_hpcd_remove(struct of_device *op)
11893 ++static int mpc5200_hpcd_remove(struct platform_device *op)
11894 + {
11895 + struct psc_dma *psc_dma = dev_get_drvdata(&op->dev);
11896 +
11897 +@@ -518,7 +518,7 @@ MODULE_DEVICE_TABLE(of, mpc5200_hpcd_match);
11898 + static struct platform_driver mpc5200_hpcd_of_driver = {
11899 + .probe = mpc5200_hpcd_probe,
11900 + .remove = mpc5200_hpcd_remove,
11901 +- .dev = {
11902 ++ .driver = {
11903 + .owner = THIS_MODULE,
11904 + .name = "mpc5200-pcm-audio",
11905 + .of_match_table = mpc5200_hpcd_match,
11906 +diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
11907 +index 07b7723..4b82290 100644
11908 +--- a/sound/soc/omap/omap-mcbsp.c
11909 ++++ b/sound/soc/omap/omap-mcbsp.c
11910 +@@ -516,6 +516,12 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
11911 + struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
11912 + int err = 0;
11913 +
11914 ++ if (mcbsp_data->active)
11915 ++ if (freq == mcbsp_data->in_freq)
11916 ++ return 0;
11917 ++ else
11918 ++ return -EBUSY;
11919 ++
11920 + /* The McBSP signal muxing functions are only available on McBSP1 */
11921 + if (clk_id == OMAP_MCBSP_CLKR_SRC_CLKR ||
11922 + clk_id == OMAP_MCBSP_CLKR_SRC_CLKX ||
11923 +diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
11924 +index 7c17b98..fa31d9c 100644
11925 +--- a/sound/soc/soc-jack.c
11926 ++++ b/sound/soc/soc-jack.c
11927 +@@ -105,7 +105,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
11928 +
11929 + snd_soc_dapm_sync(dapm);
11930 +
11931 +- snd_jack_report(jack->jack, status);
11932 ++ snd_jack_report(jack->jack, jack->status);
11933 +
11934 + out:
11935 + mutex_unlock(&codec->mutex);
11936 +@@ -327,7 +327,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
11937 + IRQF_TRIGGER_FALLING,
11938 + gpios[i].name,
11939 + &gpios[i]);
11940 +- if (ret)
11941 ++ if (ret < 0)
11942 + goto err;
11943 +
11944 + if (gpios[i].wake) {
11945 +diff --git a/sound/usb/card.c b/sound/usb/card.c
11946 +index 220c616..57a8e2d 100644
11947 +--- a/sound/usb/card.c
11948 ++++ b/sound/usb/card.c
11949 +@@ -529,8 +529,11 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
11950 + return chip;
11951 +
11952 + __error:
11953 +- if (chip && !chip->num_interfaces)
11954 +- snd_card_free(chip->card);
11955 ++ if (chip) {
11956 ++ if (!chip->num_interfaces)
11957 ++ snd_card_free(chip->card);
11958 ++ chip->probing = 0;
11959 ++ }
11960 + mutex_unlock(&register_mutex);
11961 + __err_val:
11962 + return NULL;
11963 +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
11964 +index eec1963..40fd1c7 100644
11965 +--- a/tools/perf/util/symbol.c
11966 ++++ b/tools/perf/util/symbol.c
11967 +@@ -1111,6 +1111,8 @@ static int dso__load_sym(struct dso *dso, struct map *map, const char *name,
11968 + }
11969 +
11970 + opdsec = elf_section_by_name(elf, &ehdr, &opdshdr, ".opd", &opdidx);
11971 ++ if (opdshdr.sh_type != SHT_PROGBITS)
11972 ++ opdsec = NULL;
11973 + if (opdsec)
11974 + opddata = elf_rawdata(opdsec, NULL);
11975 +
11976
11977 Deleted: genpatches-2.6/trunk/3.0/1805_vmscan-count-in-small-memcfgs-fix.patch
11978 ===================================================================
11979 --- genpatches-2.6/trunk/3.0/1805_vmscan-count-in-small-memcfgs-fix.patch 2011-10-02 19:00:24 UTC (rev 1985)
11980 +++ genpatches-2.6/trunk/3.0/1805_vmscan-count-in-small-memcfgs-fix.patch 2011-10-04 07:34:47 UTC (rev 1986)
11981 @@ -1,110 +0,0 @@
11982 -commit 4508378b9523e22a2a0175d8bf64d932fb10a67d
11983 -Author: KAMEZAWA Hiroyuki <kamezawa.hiroyu@××××××××××.com>
11984 -Date: Tue Jul 26 16:08:24 2011 -0700
11985 -
11986 - memcg: fix vmscan count in small memcgs
11987 -
11988 - Commit 246e87a93934 ("memcg: fix get_scan_count() for small targets")
11989 - fixes the memcg/kswapd behavior against small targets and prevent vmscan
11990 - priority too high.
11991 -
11992 - But the implementation is too naive and adds another problem to small
11993 - memcg. It always force scan to 32 pages of file/anon and doesn't handle
11994 - swappiness and other rotate_info. It makes vmscan to scan anon LRU
11995 - regardless of swappiness and make reclaim bad. This patch fixes it by
11996 - adjusting scanning count with regard to swappiness at el.
11997 -
11998 - At a test "cat 1G file under 300M limit." (swappiness=20)
11999 - before patch
12000 - scanned_pages_by_limit 360919
12001 - scanned_anon_pages_by_limit 180469
12002 - scanned_file_pages_by_limit 180450
12003 - rotated_pages_by_limit 31
12004 - rotated_anon_pages_by_limit 25
12005 - rotated_file_pages_by_limit 6
12006 - freed_pages_by_limit 180458
12007 - freed_anon_pages_by_limit 19
12008 - freed_file_pages_by_limit 180439
12009 - elapsed_ns_by_limit 429758872
12010 - after patch
12011 - scanned_pages_by_limit 180674
12012 - scanned_anon_pages_by_limit 24
12013 - scanned_file_pages_by_limit 180650
12014 - rotated_pages_by_limit 35
12015 - rotated_anon_pages_by_limit 24
12016 - rotated_file_pages_by_limit 11
12017 - freed_pages_by_limit 180634
12018 - freed_anon_pages_by_limit 0
12019 - freed_file_pages_by_limit 180634
12020 - elapsed_ns_by_limit 367119089
12021 - scanned_pages_by_system 0
12022 -
12023 - the numbers of scanning anon are decreased(as expected), and elapsed time
12024 - reduced. By this patch, small memcgs will work better.
12025 - (*) Because the amount of file-cache is much bigger than anon,
12026 - recalaim_stat's rotate-scan counter make scanning files more.
12027 -
12028 - Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@××××××××××.com>
12029 - Cc: Daisuke Nishimura <nishimura@××××××××××××××.jp>
12030 - Cc: Michal Hocko <mhocko@××××.cz>
12031 - Cc: Ying Han <yinghan@××××××.com>
12032 - Signed-off-by: Andrew Morton <akpm@××××××××××××××××.org>
12033 - Signed-off-by: Linus Torvalds <torvalds@××××××××××××××××.org>
12034 -
12035 -diff --git a/mm/vmscan.c b/mm/vmscan.c
12036 -index 91cee9d..f87702a 100644
12037 ---- a/mm/vmscan.c
12038 -+++ b/mm/vmscan.c
12039 -@@ -1795,6 +1795,7 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
12040 - enum lru_list l;
12041 - int noswap = 0;
12042 - int force_scan = 0;
12043 -+ unsigned long nr_force_scan[2];
12044 -
12045 -
12046 - anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) +
12047 -@@ -1817,6 +1818,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
12048 - fraction[0] = 0;
12049 - fraction[1] = 1;
12050 - denominator = 1;
12051 -+ nr_force_scan[0] = 0;
12052 -+ nr_force_scan[1] = SWAP_CLUSTER_MAX;
12053 - goto out;
12054 - }
12055 -
12056 -@@ -1828,6 +1831,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
12057 - fraction[0] = 1;
12058 - fraction[1] = 0;
12059 - denominator = 1;
12060 -+ nr_force_scan[0] = SWAP_CLUSTER_MAX;
12061 -+ nr_force_scan[1] = 0;
12062 - goto out;
12063 - }
12064 - }
12065 -@@ -1876,6 +1881,11 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
12066 - fraction[0] = ap;
12067 - fraction[1] = fp;
12068 - denominator = ap + fp + 1;
12069 -+ if (force_scan) {
12070 -+ unsigned long scan = SWAP_CLUSTER_MAX;
12071 -+ nr_force_scan[0] = div64_u64(scan * ap, denominator);
12072 -+ nr_force_scan[1] = div64_u64(scan * fp, denominator);
12073 -+ }
12074 - out:
12075 - for_each_evictable_lru(l) {
12076 - int file = is_file_lru(l);
12077 -@@ -1896,12 +1906,8 @@ out:
12078 - * memcg, priority drop can cause big latency. So, it's better
12079 - * to scan small amount. See may_noscan above.
12080 - */
12081 -- if (!scan && force_scan) {
12082 -- if (file)
12083 -- scan = SWAP_CLUSTER_MAX;
12084 -- else if (!noswap)
12085 -- scan = SWAP_CLUSTER_MAX;
12086 -- }
12087 -+ if (!scan && force_scan)
12088 -+ scan = nr_force_scan[file];
12089 - nr[l] = scan;
12090 - }
12091 - }