/[linux-patches]/genpatches-2.6/tags/3.0-30/1004_linux-3.0.5.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1004_linux-3.0.5.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (show annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (2 years, 3 months ago) by mpagano
File size: 399139 byte(s)
3.0-30 release
1 diff --git a/Makefile b/Makefile
2 index 7d2192c..eeff5df 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 0
8 -SUBLEVEL = 4
9 +SUBLEVEL = 5
10 EXTRAVERSION =
11 NAME = Sneaky Weasel
12
13 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
14 index 9adc278..91c84cb 100644
15 --- a/arch/arm/Kconfig
16 +++ b/arch/arm/Kconfig
17 @@ -1298,6 +1298,20 @@ source "drivers/pci/Kconfig"
18
19 source "drivers/pcmcia/Kconfig"
20
21 +config ARM_ERRATA_764369
22 + bool "ARM errata: Data cache line maintenance operation by MVA may not succeed"
23 + depends on CPU_V7 && SMP
24 + help
25 + This option enables the workaround for erratum 764369
26 + affecting Cortex-A9 MPCore with two or more processors (all
27 + current revisions). Under certain timing circumstances, a data
28 + cache line maintenance operation by MVA targeting an Inner
29 + Shareable memory region may fail to proceed up to either the
30 + Point of Coherency or to the Point of Unification of the
31 + system. This workaround adds a DSB instruction before the
32 + relevant cache maintenance functions and sets a specific bit
33 + in the diagnostic control register of the SCU.
34 +
35 endmenu
36
37 menu "Kernel Features"
38 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
39 index 8c73900..253cc86 100644
40 --- a/arch/arm/include/asm/futex.h
41 +++ b/arch/arm/include/asm/futex.h
42 @@ -25,17 +25,17 @@
43
44 #ifdef CONFIG_SMP
45
46 -#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
47 +#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
48 smp_mb(); \
49 __asm__ __volatile__( \
50 - "1: ldrex %1, [%2]\n" \
51 + "1: ldrex %1, [%3]\n" \
52 " " insn "\n" \
53 - "2: strex %1, %0, [%2]\n" \
54 - " teq %1, #0\n" \
55 + "2: strex %2, %0, [%3]\n" \
56 + " teq %2, #0\n" \
57 " bne 1b\n" \
58 " mov %0, #0\n" \
59 - __futex_atomic_ex_table("%4") \
60 - : "=&r" (ret), "=&r" (oldval) \
61 + __futex_atomic_ex_table("%5") \
62 + : "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
63 : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
64 : "cc", "memory")
65
66 @@ -73,14 +73,14 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
67 #include <linux/preempt.h>
68 #include <asm/domain.h>
69
70 -#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
71 +#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
72 __asm__ __volatile__( \
73 - "1: " T(ldr) " %1, [%2]\n" \
74 + "1: " T(ldr) " %1, [%3]\n" \
75 " " insn "\n" \
76 - "2: " T(str) " %0, [%2]\n" \
77 + "2: " T(str) " %0, [%3]\n" \
78 " mov %0, #0\n" \
79 - __futex_atomic_ex_table("%4") \
80 - : "=&r" (ret), "=&r" (oldval) \
81 + __futex_atomic_ex_table("%5") \
82 + : "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
83 : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
84 : "cc", "memory")
85
86 @@ -117,7 +117,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
87 int cmp = (encoded_op >> 24) & 15;
88 int oparg = (encoded_op << 8) >> 20;
89 int cmparg = (encoded_op << 20) >> 20;
90 - int oldval = 0, ret;
91 + int oldval = 0, ret, tmp;
92
93 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
94 oparg = 1 << oparg;
95 @@ -129,19 +129,19 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
96
97 switch (op) {
98 case FUTEX_OP_SET:
99 - __futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg);
100 + __futex_atomic_op("mov %0, %4", ret, oldval, tmp, uaddr, oparg);
101 break;
102 case FUTEX_OP_ADD:
103 - __futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg);
104 + __futex_atomic_op("add %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
105 break;
106 case FUTEX_OP_OR:
107 - __futex_atomic_op("orr %0, %1, %3", ret, oldval, uaddr, oparg);
108 + __futex_atomic_op("orr %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
109 break;
110 case FUTEX_OP_ANDN:
111 - __futex_atomic_op("and %0, %1, %3", ret, oldval, uaddr, ~oparg);
112 + __futex_atomic_op("and %0, %1, %4", ret, oldval, tmp, uaddr, ~oparg);
113 break;
114 case FUTEX_OP_XOR:
115 - __futex_atomic_op("eor %0, %1, %3", ret, oldval, uaddr, oparg);
116 + __futex_atomic_op("eor %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
117 break;
118 default:
119 ret = -ENOSYS;
120 diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h
121 index 16bd480..bfa706f 100644
122 --- a/arch/arm/include/asm/hardware/cache-l2x0.h
123 +++ b/arch/arm/include/asm/hardware/cache-l2x0.h
124 @@ -64,7 +64,7 @@
125 #define L2X0_AUX_CTRL_MASK 0xc0000fff
126 #define L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT 16
127 #define L2X0_AUX_CTRL_WAY_SIZE_SHIFT 17
128 -#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x3 << 17)
129 +#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x7 << 17)
130 #define L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT 22
131 #define L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT 26
132 #define L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT 27
133 diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c
134 index a1e757c..cb7dd40 100644
135 --- a/arch/arm/kernel/smp_scu.c
136 +++ b/arch/arm/kernel/smp_scu.c
137 @@ -13,6 +13,7 @@
138
139 #include <asm/smp_scu.h>
140 #include <asm/cacheflush.h>
141 +#include <asm/cputype.h>
142
143 #define SCU_CTRL 0x00
144 #define SCU_CONFIG 0x04
145 @@ -36,6 +37,15 @@ void __init scu_enable(void __iomem *scu_base)
146 {
147 u32 scu_ctrl;
148
149 +#ifdef CONFIG_ARM_ERRATA_764369
150 + /* Cortex-A9 only */
151 + if ((read_cpuid(CPUID_ID) & 0xff0ffff0) == 0x410fc090) {
152 + scu_ctrl = __raw_readl(scu_base + 0x30);
153 + if (!(scu_ctrl & 1))
154 + __raw_writel(scu_ctrl | 0x1, scu_base + 0x30);
155 + }
156 +#endif
157 +
158 scu_ctrl = __raw_readl(scu_base + SCU_CTRL);
159 /* already enabled? */
160 if (scu_ctrl & 1)
161 diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
162 index a7b41bf..e83cc86 100644
163 --- a/arch/arm/mach-davinci/board-da850-evm.c
164 +++ b/arch/arm/mach-davinci/board-da850-evm.c
165 @@ -115,6 +115,32 @@ static struct spi_board_info da850evm_spi_info[] = {
166 },
167 };
168
169 +#ifdef CONFIG_MTD
170 +static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
171 +{
172 + char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
173 + size_t retlen;
174 +
175 + if (!strcmp(mtd->name, "MAC-Address")) {
176 + mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
177 + if (retlen == ETH_ALEN)
178 + pr_info("Read MAC addr from SPI Flash: %pM\n",
179 + mac_addr);
180 + }
181 +}
182 +
183 +static struct mtd_notifier da850evm_spi_notifier = {
184 + .add = da850_evm_m25p80_notify_add,
185 +};
186 +
187 +static void da850_evm_setup_mac_addr(void)
188 +{
189 + register_mtd_user(&da850evm_spi_notifier);
190 +}
191 +#else
192 +static void da850_evm_setup_mac_addr(void) { }
193 +#endif
194 +
195 static struct mtd_partition da850_evm_norflash_partition[] = {
196 {
197 .name = "bootloaders + env",
198 @@ -1237,6 +1263,8 @@ static __init void da850_evm_init(void)
199 if (ret)
200 pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
201 ret);
202 +
203 + da850_evm_setup_mac_addr();
204 }
205
206 #ifdef CONFIG_SERIAL_8250_CONSOLE
207 diff --git a/arch/arm/mach-davinci/sleep.S b/arch/arm/mach-davinci/sleep.S
208 index fb5e72b..5f1e045 100644
209 --- a/arch/arm/mach-davinci/sleep.S
210 +++ b/arch/arm/mach-davinci/sleep.S
211 @@ -217,7 +217,11 @@ ddr2clk_stop_done:
212 ENDPROC(davinci_ddr_psc_config)
213
214 CACHE_FLUSH:
215 - .word arm926_flush_kern_cache_all
216 +#ifdef CONFIG_CPU_V6
217 + .word v6_flush_kern_cache_all
218 +#else
219 + .word arm926_flush_kern_cache_all
220 +#endif
221
222 ENTRY(davinci_cpu_suspend_sz)
223 .word . - davinci_cpu_suspend
224 diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
225 index 5ed51b8..cf7e598 100644
226 --- a/arch/arm/mach-dove/common.c
227 +++ b/arch/arm/mach-dove/common.c
228 @@ -160,7 +160,7 @@ void __init dove_spi0_init(void)
229
230 void __init dove_spi1_init(void)
231 {
232 - orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
233 + orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk());
234 }
235
236 /*****************************************************************************
237 diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
238 index 2fbbdd5..fcf0ae9 100644
239 --- a/arch/arm/mach-integrator/integrator_ap.c
240 +++ b/arch/arm/mach-integrator/integrator_ap.c
241 @@ -337,15 +337,15 @@ static unsigned long timer_reload;
242 static void integrator_clocksource_init(u32 khz)
243 {
244 void __iomem *base = (void __iomem *)TIMER2_VA_BASE;
245 - u32 ctrl = TIMER_CTRL_ENABLE;
246 + u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
247
248 if (khz >= 1500) {
249 khz /= 16;
250 - ctrl = TIMER_CTRL_DIV16;
251 + ctrl |= TIMER_CTRL_DIV16;
252 }
253
254 - writel(ctrl, base + TIMER_CTRL);
255 writel(0xffff, base + TIMER_LOAD);
256 + writel(ctrl, base + TIMER_CTRL);
257
258 clocksource_mmio_init(base + TIMER_VALUE, "timer2",
259 khz * 1000, 200, 16, clocksource_mmio_readl_down);
260 diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
261 index d32f02b..3593119 100644
262 --- a/arch/arm/mm/cache-v7.S
263 +++ b/arch/arm/mm/cache-v7.S
264 @@ -174,6 +174,10 @@ ENTRY(v7_coherent_user_range)
265 dcache_line_size r2, r3
266 sub r3, r2, #1
267 bic r12, r0, r3
268 +#ifdef CONFIG_ARM_ERRATA_764369
269 + ALT_SMP(W(dsb))
270 + ALT_UP(W(nop))
271 +#endif
272 1:
273 USER( mcr p15, 0, r12, c7, c11, 1 ) @ clean D line to the point of unification
274 add r12, r12, r2
275 @@ -223,6 +227,10 @@ ENTRY(v7_flush_kern_dcache_area)
276 add r1, r0, r1
277 sub r3, r2, #1
278 bic r0, r0, r3
279 +#ifdef CONFIG_ARM_ERRATA_764369
280 + ALT_SMP(W(dsb))
281 + ALT_UP(W(nop))
282 +#endif
283 1:
284 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line / unified line
285 add r0, r0, r2
286 @@ -247,6 +255,10 @@ v7_dma_inv_range:
287 sub r3, r2, #1
288 tst r0, r3
289 bic r0, r0, r3
290 +#ifdef CONFIG_ARM_ERRATA_764369
291 + ALT_SMP(W(dsb))
292 + ALT_UP(W(nop))
293 +#endif
294 mcrne p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line
295
296 tst r1, r3
297 @@ -270,6 +282,10 @@ v7_dma_clean_range:
298 dcache_line_size r2, r3
299 sub r3, r2, #1
300 bic r0, r0, r3
301 +#ifdef CONFIG_ARM_ERRATA_764369
302 + ALT_SMP(W(dsb))
303 + ALT_UP(W(nop))
304 +#endif
305 1:
306 mcr p15, 0, r0, c7, c10, 1 @ clean D / U line
307 add r0, r0, r2
308 @@ -288,6 +304,10 @@ ENTRY(v7_dma_flush_range)
309 dcache_line_size r2, r3
310 sub r3, r2, #1
311 bic r0, r0, r3
312 +#ifdef CONFIG_ARM_ERRATA_764369
313 + ALT_SMP(W(dsb))
314 + ALT_UP(W(nop))
315 +#endif
316 1:
317 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line
318 add r0, r0, r2
319 diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
320 index 82a093c..f96d2c7 100644
321 --- a/arch/arm/mm/dma-mapping.c
322 +++ b/arch/arm/mm/dma-mapping.c
323 @@ -322,6 +322,8 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
324
325 if (addr)
326 *handle = pfn_to_dma(dev, page_to_pfn(page));
327 + else
328 + __dma_free_buffer(page, size);
329
330 return addr;
331 }
332 diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
333 index 82620af..ebbce33 100644
334 --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
335 +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
336 @@ -66,7 +66,6 @@ typedef u64 iomux_v3_cfg_t;
337 #define MUX_MODE_MASK ((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
338 #define MUX_PAD_CTRL_SHIFT 41
339 #define MUX_PAD_CTRL_MASK ((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
340 -#define NO_PAD_CTRL ((iomux_v3_cfg_t)1 << (MUX_PAD_CTRL_SHIFT + 16))
341 #define MUX_SEL_INPUT_SHIFT 58
342 #define MUX_SEL_INPUT_MASK ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
343
344 @@ -85,6 +84,7 @@ typedef u64 iomux_v3_cfg_t;
345 * Use to set PAD control
346 */
347
348 +#define NO_PAD_CTRL (1 << 16)
349 #define PAD_CTL_DVS (1 << 13)
350 #define PAD_CTL_HYS (1 << 8)
351
352 diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
353 index b3fd081..cdd765b 100644
354 --- a/arch/powerpc/sysdev/fsl_rio.c
355 +++ b/arch/powerpc/sysdev/fsl_rio.c
356 @@ -54,6 +54,7 @@
357 #define ODSR_CLEAR 0x1c00
358 #define LTLEECSR_ENABLE_ALL 0xFFC000FC
359 #define ESCSR_CLEAR 0x07120204
360 +#define IECSR_CLEAR 0x80000000
361
362 #define RIO_PORT1_EDCSR 0x0640
363 #define RIO_PORT2_EDCSR 0x0680
364 @@ -1089,11 +1090,11 @@ static void port_error_handler(struct rio_mport *port, int offset)
365
366 if (offset == 0) {
367 out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0);
368 - out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), 0);
369 + out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), IECSR_CLEAR);
370 out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR);
371 } else {
372 out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0);
373 - out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), 0);
374 + out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), IECSR_CLEAR);
375 out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR);
376 }
377 }
378 diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
379 index 253986b..2e79419 100644
380 --- a/arch/sparc/Kconfig
381 +++ b/arch/sparc/Kconfig
382 @@ -53,6 +53,7 @@ config SPARC64
383 select HAVE_PERF_EVENTS
384 select PERF_USE_VMALLOC
385 select IRQ_PREFLOW_FASTEOI
386 + select HAVE_C_RECORDMCOUNT
387
388 config ARCH_DEFCONFIG
389 string
390 diff --git a/arch/sparc/include/asm/sigcontext.h b/arch/sparc/include/asm/sigcontext.h
391 index a1607d1..69914d7 100644
392 --- a/arch/sparc/include/asm/sigcontext.h
393 +++ b/arch/sparc/include/asm/sigcontext.h
394 @@ -45,6 +45,19 @@ typedef struct {
395 int si_mask;
396 } __siginfo32_t;
397
398 +#define __SIGC_MAXWIN 7
399 +
400 +typedef struct {
401 + unsigned long locals[8];
402 + unsigned long ins[8];
403 +} __siginfo_reg_window;
404 +
405 +typedef struct {
406 + int wsaved;
407 + __siginfo_reg_window reg_window[__SIGC_MAXWIN];
408 + unsigned long rwbuf_stkptrs[__SIGC_MAXWIN];
409 +} __siginfo_rwin_t;
410 +
411 #ifdef CONFIG_SPARC64
412 typedef struct {
413 unsigned int si_float_regs [64];
414 @@ -73,6 +86,7 @@ struct sigcontext {
415 unsigned long ss_size;
416 } sigc_stack;
417 unsigned long sigc_mask;
418 + __siginfo_rwin_t * sigc_rwin_save;
419 };
420
421 #else
422 diff --git a/arch/sparc/include/asm/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h
423 index 5f5b8bf..bcc98fc 100644
424 --- a/arch/sparc/include/asm/spinlock_32.h
425 +++ b/arch/sparc/include/asm/spinlock_32.h
426 @@ -131,6 +131,15 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
427 *(volatile __u32 *)&lp->lock = ~0U;
428 }
429
430 +static void inline arch_write_unlock(arch_rwlock_t *lock)
431 +{
432 + __asm__ __volatile__(
433 +" st %%g0, [%0]"
434 + : /* no outputs */
435 + : "r" (lock)
436 + : "memory");
437 +}
438 +
439 static inline int arch_write_trylock(arch_rwlock_t *rw)
440 {
441 unsigned int val;
442 @@ -175,8 +184,6 @@ static inline int __arch_read_trylock(arch_rwlock_t *rw)
443 res; \
444 })
445
446 -#define arch_write_unlock(rw) do { (rw)->lock = 0; } while(0)
447 -
448 #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
449 #define arch_read_lock_flags(rw, flags) arch_read_lock(rw)
450 #define arch_write_lock_flags(rw, flags) arch_write_lock(rw)
451 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
452 index 073936a..9689176 100644
453 --- a/arch/sparc/include/asm/spinlock_64.h
454 +++ b/arch/sparc/include/asm/spinlock_64.h
455 @@ -210,14 +210,8 @@ static int inline arch_write_trylock(arch_rwlock_t *lock)
456 return result;
457 }
458
459 -#define arch_read_lock(p) arch_read_lock(p)
460 #define arch_read_lock_flags(p, f) arch_read_lock(p)
461 -#define arch_read_trylock(p) arch_read_trylock(p)
462 -#define arch_read_unlock(p) arch_read_unlock(p)
463 -#define arch_write_lock(p) arch_write_lock(p)
464 #define arch_write_lock_flags(p, f) arch_write_lock(p)
465 -#define arch_write_unlock(p) arch_write_unlock(p)
466 -#define arch_write_trylock(p) arch_write_trylock(p)
467
468 #define arch_read_can_lock(rw) (!((rw)->lock & 0x80000000UL))
469 #define arch_write_can_lock(rw) (!(rw)->lock)
470 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
471 index b90b4a1..cb85458 100644
472 --- a/arch/sparc/kernel/Makefile
473 +++ b/arch/sparc/kernel/Makefile
474 @@ -32,6 +32,7 @@ obj-$(CONFIG_SPARC32) += sun4m_irq.o sun4c_irq.o sun4d_irq.o
475
476 obj-y += process_$(BITS).o
477 obj-y += signal_$(BITS).o
478 +obj-y += sigutil_$(BITS).o
479 obj-$(CONFIG_SPARC32) += ioport.o
480 obj-y += setup_$(BITS).o
481 obj-y += idprom.o
482 diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
483 index 100b9c2..4285112 100644
484 --- a/arch/sparc/kernel/irq.h
485 +++ b/arch/sparc/kernel/irq.h
486 @@ -88,7 +88,7 @@ BTFIXUPDEF_CALL(void, set_irq_udt, int)
487 #define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
488
489 /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
490 -#define SUN4D_IPI_IRQ 14
491 +#define SUN4D_IPI_IRQ 13
492
493 extern void sun4d_ipi_interrupt(void);
494
495 diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
496 index 948601a..6418ba6 100644
497 --- a/arch/sparc/kernel/pcic.c
498 +++ b/arch/sparc/kernel/pcic.c
499 @@ -352,8 +352,8 @@ int __init pcic_probe(void)
500 strcpy(pbm->prom_name, namebuf);
501
502 {
503 - extern volatile int t_nmi[1];
504 - extern int pcic_nmi_trap_patch[1];
505 + extern volatile int t_nmi[4];
506 + extern int pcic_nmi_trap_patch[4];
507
508 t_nmi[0] = pcic_nmi_trap_patch[0];
509 t_nmi[1] = pcic_nmi_trap_patch[1];
510 diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
511 index 3e9daea..3c5bb78 100644
512 --- a/arch/sparc/kernel/setup_64.c
513 +++ b/arch/sparc/kernel/setup_64.c
514 @@ -440,8 +440,14 @@ static void __init init_sparc64_elf_hwcap(void)
515 cap |= AV_SPARC_VIS;
516 if (tlb_type == cheetah || tlb_type == cheetah_plus)
517 cap |= AV_SPARC_VIS | AV_SPARC_VIS2;
518 - if (tlb_type == cheetah_plus)
519 - cap |= AV_SPARC_POPC;
520 + if (tlb_type == cheetah_plus) {
521 + unsigned long impl, ver;
522 +
523 + __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
524 + impl = ((ver >> 32) & 0xffff);
525 + if (impl == PANTHER_IMPL)
526 + cap |= AV_SPARC_POPC;
527 + }
528 if (tlb_type == hypervisor) {
529 if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1)
530 cap |= AV_SPARC_ASI_BLK_INIT;
531 diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
532 index 75fad42..5d92488 100644
533 --- a/arch/sparc/kernel/signal32.c
534 +++ b/arch/sparc/kernel/signal32.c
535 @@ -29,6 +29,8 @@
536 #include <asm/visasm.h>
537 #include <asm/compat_signal.h>
538
539 +#include "sigutil.h"
540 +
541 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
542
543 /* This magic should be in g_upper[0] for all upper parts
544 @@ -44,14 +46,14 @@ typedef struct {
545 struct signal_frame32 {
546 struct sparc_stackf32 ss;
547 __siginfo32_t info;
548 - /* __siginfo_fpu32_t * */ u32 fpu_save;
549 + /* __siginfo_fpu_t * */ u32 fpu_save;
550 unsigned int insns[2];
551 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
552 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
553 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
554 siginfo_extra_v8plus_t v8plus;
555 - __siginfo_fpu_t fpu_state;
556 -};
557 + /* __siginfo_rwin_t * */u32 rwin_save;
558 +} __attribute__((aligned(8)));
559
560 typedef struct compat_siginfo{
561 int si_signo;
562 @@ -110,18 +112,14 @@ struct rt_signal_frame32 {
563 compat_siginfo_t info;
564 struct pt_regs32 regs;
565 compat_sigset_t mask;
566 - /* __siginfo_fpu32_t * */ u32 fpu_save;
567 + /* __siginfo_fpu_t * */ u32 fpu_save;
568 unsigned int insns[2];
569 stack_t32 stack;
570 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
571 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
572 siginfo_extra_v8plus_t v8plus;
573 - __siginfo_fpu_t fpu_state;
574 -};
575 -
576 -/* Align macros */
577 -#define SF_ALIGNEDSZ (((sizeof(struct signal_frame32) + 15) & (~15)))
578 -#define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 15) & (~15)))
579 + /* __siginfo_rwin_t * */u32 rwin_save;
580 +} __attribute__((aligned(8)));
581
582 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
583 {
584 @@ -192,30 +190,13 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
585 return 0;
586 }
587
588 -static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
589 -{
590 - unsigned long *fpregs = current_thread_info()->fpregs;
591 - unsigned long fprs;
592 - int err;
593 -
594 - err = __get_user(fprs, &fpu->si_fprs);
595 - fprs_write(0);
596 - regs->tstate &= ~TSTATE_PEF;
597 - if (fprs & FPRS_DL)
598 - err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32));
599 - if (fprs & FPRS_DU)
600 - err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32));
601 - err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
602 - err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
603 - current_thread_info()->fpsaved[0] |= fprs;
604 - return err;
605 -}
606 -
607 void do_sigreturn32(struct pt_regs *regs)
608 {
609 struct signal_frame32 __user *sf;
610 + compat_uptr_t fpu_save;
611 + compat_uptr_t rwin_save;
612 unsigned int psr;
613 - unsigned pc, npc, fpu_save;
614 + unsigned pc, npc;
615 sigset_t set;
616 unsigned seta[_COMPAT_NSIG_WORDS];
617 int err, i;
618 @@ -273,8 +254,13 @@ void do_sigreturn32(struct pt_regs *regs)
619 pt_regs_clear_syscall(regs);
620
621 err |= __get_user(fpu_save, &sf->fpu_save);
622 - if (fpu_save)
623 - err |= restore_fpu_state32(regs, &sf->fpu_state);
624 + if (!err && fpu_save)
625 + err |= restore_fpu_state(regs, compat_ptr(fpu_save));
626 + err |= __get_user(rwin_save, &sf->rwin_save);
627 + if (!err && rwin_save) {
628 + if (restore_rwin_state(compat_ptr(rwin_save)))
629 + goto segv;
630 + }
631 err |= __get_user(seta[0], &sf->info.si_mask);
632 err |= copy_from_user(seta+1, &sf->extramask,
633 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
634 @@ -300,7 +286,9 @@ segv:
635 asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
636 {
637 struct rt_signal_frame32 __user *sf;
638 - unsigned int psr, pc, npc, fpu_save, u_ss_sp;
639 + unsigned int psr, pc, npc, u_ss_sp;
640 + compat_uptr_t fpu_save;
641 + compat_uptr_t rwin_save;
642 mm_segment_t old_fs;
643 sigset_t set;
644 compat_sigset_t seta;
645 @@ -359,8 +347,8 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
646 pt_regs_clear_syscall(regs);
647
648 err |= __get_user(fpu_save, &sf->fpu_save);
649 - if (fpu_save)
650 - err |= restore_fpu_state32(regs, &sf->fpu_state);
651 + if (!err && fpu_save)
652 + err |= restore_fpu_state(regs, compat_ptr(fpu_save));
653 err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t));
654 err |= __get_user(u_ss_sp, &sf->stack.ss_sp);
655 st.ss_sp = compat_ptr(u_ss_sp);
656 @@ -376,6 +364,12 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
657 do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf);
658 set_fs(old_fs);
659
660 + err |= __get_user(rwin_save, &sf->rwin_save);
661 + if (!err && rwin_save) {
662 + if (restore_rwin_state(compat_ptr(rwin_save)))
663 + goto segv;
664 + }
665 +
666 switch (_NSIG_WORDS) {
667 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
668 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
669 @@ -433,26 +427,6 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns
670 return (void __user *) sp;
671 }
672
673 -static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
674 -{
675 - unsigned long *fpregs = current_thread_info()->fpregs;
676 - unsigned long fprs;
677 - int err = 0;
678 -
679 - fprs = current_thread_info()->fpsaved[0];
680 - if (fprs & FPRS_DL)
681 - err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
682 - (sizeof(unsigned int) * 32));
683 - if (fprs & FPRS_DU)
684 - err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
685 - (sizeof(unsigned int) * 32));
686 - err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
687 - err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
688 - err |= __put_user(fprs, &fpu->si_fprs);
689 -
690 - return err;
691 -}
692 -
693 /* The I-cache flush instruction only works in the primary ASI, which
694 * right now is the nucleus, aka. kernel space.
695 *
696 @@ -515,18 +489,23 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
697 int signo, sigset_t *oldset)
698 {
699 struct signal_frame32 __user *sf;
700 + int i, err, wsaved;
701 + void __user *tail;
702 int sigframe_size;
703 u32 psr;
704 - int i, err;
705 unsigned int seta[_COMPAT_NSIG_WORDS];
706
707 /* 1. Make sure everything is clean */
708 synchronize_user_stack();
709 save_and_clear_fpu();
710
711 - sigframe_size = SF_ALIGNEDSZ;
712 - if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
713 - sigframe_size -= sizeof(__siginfo_fpu_t);
714 + wsaved = get_thread_wsaved();
715 +
716 + sigframe_size = sizeof(*sf);
717 + if (current_thread_info()->fpsaved[0] & FPRS_FEF)
718 + sigframe_size += sizeof(__siginfo_fpu_t);
719 + if (wsaved)
720 + sigframe_size += sizeof(__siginfo_rwin_t);
721
722 sf = (struct signal_frame32 __user *)
723 get_sigframe(&ka->sa, regs, sigframe_size);
724 @@ -534,8 +513,7 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
725 if (invalid_frame_pointer(sf, sigframe_size))
726 goto sigill;
727
728 - if (get_thread_wsaved() != 0)
729 - goto sigill;
730 + tail = (sf + 1);
731
732 /* 2. Save the current process state */
733 if (test_thread_flag(TIF_32BIT)) {
734 @@ -560,11 +538,22 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
735 &sf->v8plus.asi);
736
737 if (psr & PSR_EF) {
738 - err |= save_fpu_state32(regs, &sf->fpu_state);
739 - err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
740 + __siginfo_fpu_t __user *fp = tail;
741 + tail += sizeof(*fp);
742 + err |= save_fpu_state(regs, fp);
743 + err |= __put_user((u64)fp, &sf->fpu_save);
744 } else {
745 err |= __put_user(0, &sf->fpu_save);
746 }
747 + if (wsaved) {
748 + __siginfo_rwin_t __user *rwp = tail;
749 + tail += sizeof(*rwp);
750 + err |= save_rwin_state(wsaved, rwp);
751 + err |= __put_user((u64)rwp, &sf->rwin_save);
752 + set_thread_wsaved(0);
753 + } else {
754 + err |= __put_user(0, &sf->rwin_save);
755 + }
756
757 switch (_NSIG_WORDS) {
758 case 4: seta[7] = (oldset->sig[3] >> 32);
759 @@ -580,10 +569,21 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
760 err |= __copy_to_user(sf->extramask, seta + 1,
761 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
762
763 - err |= copy_in_user((u32 __user *)sf,
764 - (u32 __user *)(regs->u_regs[UREG_FP]),
765 - sizeof(struct reg_window32));
766 -
767 + if (!wsaved) {
768 + err |= copy_in_user((u32 __user *)sf,
769 + (u32 __user *)(regs->u_regs[UREG_FP]),
770 + sizeof(struct reg_window32));
771 + } else {
772 + struct reg_window *rp;
773 +
774 + rp = &current_thread_info()->reg_window[wsaved - 1];
775 + for (i = 0; i < 8; i++)
776 + err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
777 + for (i = 0; i < 6; i++)
778 + err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
779 + err |= __put_user(rp->ins[6], &sf->ss.fp);
780 + err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
781 + }
782 if (err)
783 goto sigsegv;
784
785 @@ -613,7 +613,6 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
786 err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/
787 if (err)
788 goto sigsegv;
789 -
790 flush_signal_insns(address);
791 }
792 return 0;
793 @@ -632,18 +631,23 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
794 siginfo_t *info)
795 {
796 struct rt_signal_frame32 __user *sf;
797 + int i, err, wsaved;
798 + void __user *tail;
799 int sigframe_size;
800 u32 psr;
801 - int i, err;
802 compat_sigset_t seta;
803
804 /* 1. Make sure everything is clean */
805 synchronize_user_stack();
806 save_and_clear_fpu();
807
808 - sigframe_size = RT_ALIGNEDSZ;
809 - if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
810 - sigframe_size -= sizeof(__siginfo_fpu_t);
811 + wsaved = get_thread_wsaved();
812 +
813 + sigframe_size = sizeof(*sf);
814 + if (current_thread_info()->fpsaved[0] & FPRS_FEF)
815 + sigframe_size += sizeof(__siginfo_fpu_t);
816 + if (wsaved)
817 + sigframe_size += sizeof(__siginfo_rwin_t);
818
819 sf = (struct rt_signal_frame32 __user *)
820 get_sigframe(&ka->sa, regs, sigframe_size);
821 @@ -651,8 +655,7 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
822 if (invalid_frame_pointer(sf, sigframe_size))
823 goto sigill;
824
825 - if (get_thread_wsaved() != 0)
826 - goto sigill;
827 + tail = (sf + 1);
828
829 /* 2. Save the current process state */
830 if (test_thread_flag(TIF_32BIT)) {
831 @@ -677,11 +680,22 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
832 &sf->v8plus.asi);
833
834 if (psr & PSR_EF) {
835 - err |= save_fpu_state32(regs, &sf->fpu_state);
836 - err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
837 + __siginfo_fpu_t __user *fp = tail;
838 + tail += sizeof(*fp);
839 + err |= save_fpu_state(regs, fp);
840 + err |= __put_user((u64)fp, &sf->fpu_save);
841 } else {
842 err |= __put_user(0, &sf->fpu_save);
843 }
844 + if (wsaved) {
845 + __siginfo_rwin_t __user *rwp = tail;
846 + tail += sizeof(*rwp);
847 + err |= save_rwin_state(wsaved, rwp);
848 + err |= __put_user((u64)rwp, &sf->rwin_save);
849 + set_thread_wsaved(0);
850 + } else {
851 + err |= __put_user(0, &sf->rwin_save);
852 + }
853
854 /* Update the siginfo structure. */
855 err |= copy_siginfo_to_user32(&sf->info, info);
856 @@ -703,9 +717,21 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
857 }
858 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
859
860 - err |= copy_in_user((u32 __user *)sf,
861 - (u32 __user *)(regs->u_regs[UREG_FP]),
862 - sizeof(struct reg_window32));
863 + if (!wsaved) {
864 + err |= copy_in_user((u32 __user *)sf,
865 + (u32 __user *)(regs->u_regs[UREG_FP]),
866 + sizeof(struct reg_window32));
867 + } else {
868 + struct reg_window *rp;
869 +
870 + rp = &current_thread_info()->reg_window[wsaved - 1];
871 + for (i = 0; i < 8; i++)
872 + err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
873 + for (i = 0; i < 6; i++)
874 + err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
875 + err |= __put_user(rp->ins[6], &sf->ss.fp);
876 + err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
877 + }
878 if (err)
879 goto sigsegv;
880
881 diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
882 index 5e5c5fd..04ede8f 100644
883 --- a/arch/sparc/kernel/signal_32.c
884 +++ b/arch/sparc/kernel/signal_32.c
885 @@ -26,6 +26,8 @@
886 #include <asm/pgtable.h>
887 #include <asm/cacheflush.h> /* flush_sig_insns */
888
889 +#include "sigutil.h"
890 +
891 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
892
893 extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
894 @@ -39,8 +41,8 @@ struct signal_frame {
895 unsigned long insns[2] __attribute__ ((aligned (8)));
896 unsigned int extramask[_NSIG_WORDS - 1];
897 unsigned int extra_size; /* Should be 0 */
898 - __siginfo_fpu_t fpu_state;
899 -};
900 + __siginfo_rwin_t __user *rwin_save;
901 +} __attribute__((aligned(8)));
902
903 struct rt_signal_frame {
904 struct sparc_stackf ss;
905 @@ -51,8 +53,8 @@ struct rt_signal_frame {
906 unsigned int insns[2];
907 stack_t stack;
908 unsigned int extra_size; /* Should be 0 */
909 - __siginfo_fpu_t fpu_state;
910 -};
911 + __siginfo_rwin_t __user *rwin_save;
912 +} __attribute__((aligned(8)));
913
914 /* Align macros */
915 #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7)))
916 @@ -79,43 +81,13 @@ asmlinkage int sys_sigsuspend(old_sigset_t set)
917 return _sigpause_common(set);
918 }
919
920 -static inline int
921 -restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
922 -{
923 - int err;
924 -#ifdef CONFIG_SMP
925 - if (test_tsk_thread_flag(current, TIF_USEDFPU))
926 - regs->psr &= ~PSR_EF;
927 -#else
928 - if (current == last_task_used_math) {
929 - last_task_used_math = NULL;
930 - regs->psr &= ~PSR_EF;
931 - }
932 -#endif
933 - set_used_math();
934 - clear_tsk_thread_flag(current, TIF_USEDFPU);
935 -
936 - if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
937 - return -EFAULT;
938 -
939 - err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
940 - (sizeof(unsigned long) * 32));
941 - err |= __get_user(current->thread.fsr, &fpu->si_fsr);
942 - err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
943 - if (current->thread.fpqdepth != 0)
944 - err |= __copy_from_user(&current->thread.fpqueue[0],
945 - &fpu->si_fpqueue[0],
946 - ((sizeof(unsigned long) +
947 - (sizeof(unsigned long *)))*16));
948 - return err;
949 -}
950 -
951 asmlinkage void do_sigreturn(struct pt_regs *regs)
952 {
953 struct signal_frame __user *sf;
954 unsigned long up_psr, pc, npc;
955 sigset_t set;
956 __siginfo_fpu_t __user *fpu_save;
957 + __siginfo_rwin_t __user *rwin_save;
958 int err;
959
960 /* Always make any pending restarted system calls return -EINTR */
961 @@ -150,9 +122,11 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
962 pt_regs_clear_syscall(regs);
963
964 err |= __get_user(fpu_save, &sf->fpu_save);
965 -
966 if (fpu_save)
967 err |= restore_fpu_state(regs, fpu_save);
968 + err |= __get_user(rwin_save, &sf->rwin_save);
969 + if (rwin_save)
970 + err |= restore_rwin_state(rwin_save);
971
972 /* This is pretty much atomic, no amount locking would prevent
973 * the races which exist anyways.
974 @@ -180,6 +154,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
975 struct rt_signal_frame __user *sf;
976 unsigned int psr, pc, npc;
977 __siginfo_fpu_t __user *fpu_save;
978 + __siginfo_rwin_t __user *rwin_save;
979 mm_segment_t old_fs;
980 sigset_t set;
981 stack_t st;
982 @@ -207,8 +182,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
983 pt_regs_clear_syscall(regs);
984
985 err |= __get_user(fpu_save, &sf->fpu_save);
986 -
987 - if (fpu_save)
988 + if (!err && fpu_save)
989 err |= restore_fpu_state(regs, fpu_save);
990 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
991
992 @@ -228,6 +202,12 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
993 do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
994 set_fs(old_fs);
995
996 + err |= __get_user(rwin_save, &sf->rwin_save);
997 + if (!err && rwin_save) {
998 + if (restore_rwin_state(rwin_save))
999 + goto segv;
1000 + }
1001 +
1002 sigdelsetmask(&set, ~_BLOCKABLE);
1003 spin_lock_irq(&current->sighand->siglock);
1004 current->blocked = set;
1005 @@ -280,53 +260,23 @@ static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *re
1006 return (void __user *) sp;
1007 }
1008
1009 -static inline int
1010 -save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1011 -{
1012 - int err = 0;
1013 -#ifdef CONFIG_SMP
1014 - if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
1015 - put_psr(get_psr() | PSR_EF);
1016 - fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1017 - &current->thread.fpqueue[0], &current->thread.fpqdepth);
1018 - regs->psr &= ~(PSR_EF);
1019 - clear_tsk_thread_flag(current, TIF_USEDFPU);
1020 - }
1021 -#else
1022 - if (current == last_task_used_math) {
1023 - put_psr(get_psr() | PSR_EF);
1024 - fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1025 - &current->thread.fpqueue[0], &current->thread.fpqdepth);
1026 - last_task_used_math = NULL;
1027 - regs->psr &= ~(PSR_EF);
1028 - }
1029 -#endif
1030 - err |= __copy_to_user(&fpu->si_float_regs[0],
1031 - &current->thread.float_regs[0],
1032 - (sizeof(unsigned long) * 32));
1033 - err |= __put_user(current->thread.fsr, &fpu->si_fsr);
1034 - err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1035 - if (current->thread.fpqdepth != 0)
1036 - err |= __copy_to_user(&fpu->si_fpqueue[0],
1037 - &current->thread.fpqueue[0],
1038 - ((sizeof(unsigned long) +
1039 - (sizeof(unsigned long *)))*16));
1040 - clear_used_math();
1041 - return err;
1042 -}
1043 -
1044 static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1045 int signo, sigset_t *oldset)
1046 {
1047 struct signal_frame __user *sf;
1048 - int sigframe_size, err;
1049 + int sigframe_size, err, wsaved;
1050 + void __user *tail;
1051
1052 /* 1. Make sure everything is clean */
1053 synchronize_user_stack();
1054
1055 - sigframe_size = SF_ALIGNEDSZ;
1056 - if (!used_math())
1057 - sigframe_size -= sizeof(__siginfo_fpu_t);
1058 + wsaved = current_thread_info()->w_saved;
1059 +
1060 + sigframe_size = sizeof(*sf);
1061 + if (used_math())
1062 + sigframe_size += sizeof(__siginfo_fpu_t);
1063 + if (wsaved)
1064 + sigframe_size += sizeof(__siginfo_rwin_t);
1065
1066 sf = (struct signal_frame __user *)
1067 get_sigframe(&ka->sa, regs, sigframe_size);
1068 @@ -334,8 +284,7 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1069 if (invalid_frame_pointer(sf, sigframe_size))
1070 goto sigill_and_return;
1071
1072 - if (current_thread_info()->w_saved != 0)
1073 - goto sigill_and_return;
1074 + tail = sf + 1;
1075
1076 /* 2. Save the current process state */
1077 err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
1078 @@ -343,17 +292,34 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
1079 err |= __put_user(0, &sf->extra_size);
1080
1081 if (used_math()) {
1082 - err |= save_fpu_state(regs, &sf->fpu_state);
1083 - err |= __put_user(&sf->fpu_state, &sf->fpu_save);
1084 + __siginfo_fpu_t __user *fp = tail;
1085 + tail += sizeof(*fp);
1086 + err |= save_fpu_state(regs, fp);
1087 + err |= __put_user(fp, &sf->fpu_save);
1088 } else {
1089 err |= __put_user(0, &sf->fpu_save);
1090 }
1091 + if (wsaved) {
1092 + __siginfo_rwin_t __user *rwp = tail;
1093 + tail += sizeof(*rwp);
1094 + err |= save_rwin_state(wsaved, rwp);
1095 + err |= __put_user(rwp, &sf->rwin_save);
1096 + } else {
1097 + err |= __put_user(0, &sf->rwin_save);
1098 + }
1099
1100 err |= __put_user(oldset->sig[0], &sf->info.si_mask);
1101 err |= __copy_to_user(sf->extramask, &oldset->sig[1],
1102 (_NSIG_WORDS - 1) * sizeof(unsigned int));
1103 - err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1104 - sizeof(struct reg_window32));
1105 + if (!wsaved) {
1106 + err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1107 + sizeof(struct reg_window32));
1108 + } else {
1109 + struct reg_window32 *rp;
1110 +
1111 + rp = &current_thread_info()->reg_window[wsaved - 1];
1112 + err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
1113 + }
1114 if (err)
1115 goto sigsegv;
1116
1117 @@ -399,21 +365,24 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1118 int signo, sigset_t *oldset, siginfo_t *info)
1119 {
1120 struct rt_signal_frame __user *sf;
1121 - int sigframe_size;
1122 + int sigframe_size, wsaved;
1123 + void __user *tail;
1124 unsigned int psr;
1125 int err;
1126
1127 synchronize_user_stack();
1128 - sigframe_size = RT_ALIGNEDSZ;
1129 - if (!used_math())
1130 - sigframe_size -= sizeof(__siginfo_fpu_t);
1131 + wsaved = current_thread_info()->w_saved;
1132 + sigframe_size = sizeof(*sf);
1133 + if (used_math())
1134 + sigframe_size += sizeof(__siginfo_fpu_t);
1135 + if (wsaved)
1136 + sigframe_size += sizeof(__siginfo_rwin_t);
1137 sf = (struct rt_signal_frame __user *)
1138 get_sigframe(&ka->sa, regs, sigframe_size);
1139 if (invalid_frame_pointer(sf, sigframe_size))
1140 goto sigill;
1141 - if (current_thread_info()->w_saved != 0)
1142 - goto sigill;
1143
1144 + tail = sf + 1;
1145 err = __put_user(regs->pc, &sf->regs.pc);
1146 err |= __put_user(regs->npc, &sf->regs.npc);
1147 err |= __put_user(regs->y, &sf->regs.y);
1148 @@ -425,11 +394,21 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1149 err |= __put_user(0, &sf->extra_size);
1150
1151 if (psr & PSR_EF) {
1152 - err |= save_fpu_state(regs, &sf->fpu_state);
1153 - err |= __put_user(&sf->fpu_state, &sf->fpu_save);
1154 + __siginfo_fpu_t *fp = tail;
1155 + tail += sizeof(*fp);
1156 + err |= save_fpu_state(regs, fp);
1157 + err |= __put_user(fp, &sf->fpu_save);
1158 } else {
1159 err |= __put_user(0, &sf->fpu_save);
1160 }
1161 + if (wsaved) {
1162 + __siginfo_rwin_t *rwp = tail;
1163 + tail += sizeof(*rwp);
1164 + err |= save_rwin_state(wsaved, rwp);
1165 + err |= __put_user(rwp, &sf->rwin_save);
1166 + } else {
1167 + err |= __put_user(0, &sf->rwin_save);
1168 + }
1169 err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
1170
1171 /* Setup sigaltstack */
1172 @@ -437,8 +416,15 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1173 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
1174 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
1175
1176 - err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1177 - sizeof(struct reg_window32));
1178 + if (!wsaved) {
1179 + err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
1180 + sizeof(struct reg_window32));
1181 + } else {
1182 + struct reg_window32 *rp;
1183 +
1184 + rp = &current_thread_info()->reg_window[wsaved - 1];
1185 + err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
1186 + }
1187
1188 err |= copy_siginfo_to_user(&sf->info, info);
1189
1190 diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
1191 index 006fe45..47509df 100644
1192 --- a/arch/sparc/kernel/signal_64.c
1193 +++ b/arch/sparc/kernel/signal_64.c
1194 @@ -34,6 +34,7 @@
1195
1196 #include "entry.h"
1197 #include "systbls.h"
1198 +#include "sigutil.h"
1199
1200 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
1201
1202 @@ -236,7 +237,7 @@ struct rt_signal_frame {
1203 __siginfo_fpu_t __user *fpu_save;
1204 stack_t stack;
1205 sigset_t mask;
1206 - __siginfo_fpu_t fpu_state;
1207 + __siginfo_rwin_t *rwin_save;
1208 };
1209
1210 static long _sigpause_common(old_sigset_t set)
1211 @@ -266,33 +267,12 @@ asmlinkage long sys_sigsuspend(old_sigset_t set)
1212 return _sigpause_common(set);
1213 }
1214
1215 -static inline int
1216 -restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1217 -{
1218 - unsigned long *fpregs = current_thread_info()->fpregs;
1219 - unsigned long fprs;
1220 - int err;
1221 -
1222 - err = __get_user(fprs, &fpu->si_fprs);
1223 - fprs_write(0);
1224 - regs->tstate &= ~TSTATE_PEF;
1225 - if (fprs & FPRS_DL)
1226 - err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
1227 - (sizeof(unsigned int) * 32));
1228 - if (fprs & FPRS_DU)
1229 - err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
1230 - (sizeof(unsigned int) * 32));
1231 - err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1232 - err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1233 - current_thread_info()->fpsaved[0] |= fprs;
1234 - return err;
1235 -}
1236 -
1237 void do_rt_sigreturn(struct pt_regs *regs)
1238 {
1239 struct rt_signal_frame __user *sf;
1240 unsigned long tpc, tnpc, tstate;
1241 __siginfo_fpu_t __user *fpu_save;
1242 + __siginfo_rwin_t __user *rwin_save;
1243 sigset_t set;
1244 int err;
1245
1246 @@ -325,8 +305,8 @@ void do_rt_sigreturn(struct pt_regs *regs)
1247 regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
1248
1249 err |= __get_user(fpu_save, &sf->fpu_save);
1250 - if (fpu_save)
1251 - err |= restore_fpu_state(regs, &sf->fpu_state);
1252 + if (!err && fpu_save)
1253 + err |= restore_fpu_state(regs, fpu_save);
1254
1255 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
1256 err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf);
1257 @@ -334,6 +314,12 @@ void do_rt_sigreturn(struct pt_regs *regs)
1258 if (err)
1259 goto segv;
1260
1261 + err |= __get_user(rwin_save, &sf->rwin_save);
1262 + if (!err && rwin_save) {
1263 + if (restore_rwin_state(rwin_save))
1264 + goto segv;
1265 + }
1266 +
1267 regs->tpc = tpc;
1268 regs->tnpc = tnpc;
1269
1270 @@ -351,34 +337,13 @@ segv:
1271 }
1272
1273 /* Checks if the fp is valid */
1274 -static int invalid_frame_pointer(void __user *fp, int fplen)
1275 +static int invalid_frame_pointer(void __user *fp)
1276 {
1277 if (((unsigned long) fp) & 15)
1278 return 1;
1279 return 0;
1280 }
1281
1282 -static inline int
1283 -save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1284 -{
1285 - unsigned long *fpregs = current_thread_info()->fpregs;
1286 - unsigned long fprs;
1287 - int err = 0;
1288 -
1289 - fprs = current_thread_info()->fpsaved[0];
1290 - if (fprs & FPRS_DL)
1291 - err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
1292 - (sizeof(unsigned int) * 32));
1293 - if (fprs & FPRS_DU)
1294 - err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
1295 - (sizeof(unsigned int) * 32));
1296 - err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1297 - err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1298 - err |= __put_user(fprs, &fpu->si_fprs);
1299 -
1300 - return err;
1301 -}
1302 -
1303 static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize)
1304 {
1305 unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
1306 @@ -414,34 +379,48 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1307 int signo, sigset_t *oldset, siginfo_t *info)
1308 {
1309 struct rt_signal_frame __user *sf;
1310 - int sigframe_size, err;
1311 + int wsaved, err, sf_size;
1312 + void __user *tail;
1313
1314 /* 1. Make sure everything is clean */
1315 synchronize_user_stack();
1316 save_and_clear_fpu();
1317
1318 - sigframe_size = sizeof(struct rt_signal_frame);
1319 - if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
1320 - sigframe_size -= sizeof(__siginfo_fpu_t);
1321 + wsaved = get_thread_wsaved();
1322
1323 + sf_size = sizeof(struct rt_signal_frame);
1324 + if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1325 + sf_size += sizeof(__siginfo_fpu_t);
1326 + if (wsaved)
1327 + sf_size += sizeof(__siginfo_rwin_t);
1328 sf = (struct rt_signal_frame __user *)
1329 - get_sigframe(ka, regs, sigframe_size);
1330 -
1331 - if (invalid_frame_pointer (sf, sigframe_size))
1332 - goto sigill;
1333 + get_sigframe(ka, regs, sf_size);
1334
1335 - if (get_thread_wsaved() != 0)
1336 + if (invalid_frame_pointer (sf))
1337 goto sigill;
1338
1339 + tail = (sf + 1);
1340 +
1341 /* 2. Save the current process state */
1342 err = copy_to_user(&sf->regs, regs, sizeof (*regs));
1343
1344 if (current_thread_info()->fpsaved[0] & FPRS_FEF) {
1345 - err |= save_fpu_state(regs, &sf->fpu_state);
1346 - err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
1347 + __siginfo_fpu_t __user *fpu_save = tail;
1348 + tail += sizeof(__siginfo_fpu_t);
1349 + err |= save_fpu_state(regs, fpu_save);
1350 + err |= __put_user((u64)fpu_save, &sf->fpu_save);
1351 } else {
1352 err |= __put_user(0, &sf->fpu_save);
1353 }
1354 + if (wsaved) {
1355 + __siginfo_rwin_t __user *rwin_save = tail;
1356 + tail += sizeof(__siginfo_rwin_t);
1357 + err |= save_rwin_state(wsaved, rwin_save);
1358 + err |= __put_user((u64)rwin_save, &sf->rwin_save);
1359 + set_thread_wsaved(0);
1360 + } else {
1361 + err |= __put_user(0, &sf->rwin_save);
1362 + }
1363
1364 /* Setup sigaltstack */
1365 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
1366 @@ -450,10 +429,17 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
1367
1368 err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t));
1369
1370 - err |= copy_in_user((u64 __user *)sf,
1371 - (u64 __user *)(regs->u_regs[UREG_FP]+STACK_BIAS),
1372 - sizeof(struct reg_window));
1373 + if (!wsaved) {
1374 + err |= copy_in_user((u64 __user *)sf,
1375 + (u64 __user *)(regs->u_regs[UREG_FP] +
1376 + STACK_BIAS),
1377 + sizeof(struct reg_window));
1378 + } else {
1379 + struct reg_window *rp;
1380
1381 + rp = &current_thread_info()->reg_window[wsaved - 1];
1382 + err |= copy_to_user(sf, rp, sizeof(struct reg_window));
1383 + }
1384 if (info)
1385 err |= copy_siginfo_to_user(&sf->info, info);
1386 else {
1387 diff --git a/arch/sparc/kernel/sigutil.h b/arch/sparc/kernel/sigutil.h
1388 new file mode 100644
1389 index 0000000..d223aa4
1390 --- /dev/null
1391 +++ b/arch/sparc/kernel/sigutil.h
1392 @@ -0,0 +1,9 @@
1393 +#ifndef _SIGUTIL_H
1394 +#define _SIGUTIL_H
1395 +
1396 +int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
1397 +int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
1398 +int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin);
1399 +int restore_rwin_state(__siginfo_rwin_t __user *rp);
1400 +
1401 +#endif /* _SIGUTIL_H */
1402 diff --git a/arch/sparc/kernel/sigutil_32.c b/arch/sparc/kernel/sigutil_32.c
1403 new file mode 100644
1404 index 0000000..35c7897
1405 --- /dev/null
1406 +++ b/arch/sparc/kernel/sigutil_32.c
1407 @@ -0,0 +1,120 @@
1408 +#include <linux/kernel.h>
1409 +#include <linux/types.h>
1410 +#include <linux/thread_info.h>
1411 +#include <linux/uaccess.h>
1412 +#include <linux/sched.h>
1413 +
1414 +#include <asm/sigcontext.h>
1415 +#include <asm/fpumacro.h>
1416 +#include <asm/ptrace.h>
1417 +
1418 +#include "sigutil.h"
1419 +
1420 +int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1421 +{
1422 + int err = 0;
1423 +#ifdef CONFIG_SMP
1424 + if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
1425 + put_psr(get_psr() | PSR_EF);
1426 + fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1427 + &current->thread.fpqueue[0], &current->thread.fpqdepth);
1428 + regs->psr &= ~(PSR_EF);
1429 + clear_tsk_thread_flag(current, TIF_USEDFPU);
1430 + }
1431 +#else
1432 + if (current == last_task_used_math) {
1433 + put_psr(get_psr() | PSR_EF);
1434 + fpsave(&current->thread.float_regs[0], &current->thread.fsr,
1435 + &current->thread.fpqueue[0], &current->thread.fpqdepth);
1436 + last_task_used_math = NULL;
1437 + regs->psr &= ~(PSR_EF);
1438 + }
1439 +#endif
1440 + err |= __copy_to_user(&fpu->si_float_regs[0],
1441 + &current->thread.float_regs[0],
1442 + (sizeof(unsigned long) * 32));
1443 + err |= __put_user(current->thread.fsr, &fpu->si_fsr);
1444 + err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1445 + if (current->thread.fpqdepth != 0)
1446 + err |= __copy_to_user(&fpu->si_fpqueue[0],
1447 + &current->thread.fpqueue[0],
1448 + ((sizeof(unsigned long) +
1449 + (sizeof(unsigned long *)))*16));
1450 + clear_used_math();
1451 + return err;
1452 +}
1453 +
1454 +int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1455 +{
1456 + int err;
1457 +#ifdef CONFIG_SMP
1458 + if (test_tsk_thread_flag(current, TIF_USEDFPU))
1459 + regs->psr &= ~PSR_EF;
1460 +#else
1461 + if (current == last_task_used_math) {
1462 + last_task_used_math = NULL;
1463 + regs->psr &= ~PSR_EF;
1464 + }
1465 +#endif
1466 + set_used_math();
1467 + clear_tsk_thread_flag(current, TIF_USEDFPU);
1468 +
1469 + if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
1470 + return -EFAULT;
1471 +
1472 + err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
1473 + (sizeof(unsigned long) * 32));
1474 + err |= __get_user(current->thread.fsr, &fpu->si_fsr);
1475 + err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
1476 + if (current->thread.fpqdepth != 0)
1477 + err |= __copy_from_user(&current->thread.fpqueue[0],
1478 + &fpu->si_fpqueue[0],
1479 + ((sizeof(unsigned long) +
1480 + (sizeof(unsigned long *)))*16));
1481 + return err;
1482 +}
1483 +
1484 +int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
1485 +{
1486 + int i, err = __put_user(wsaved, &rwin->wsaved);
1487 +
1488 + for (i = 0; i < wsaved; i++) {
1489 + struct reg_window32 *rp;
1490 + unsigned long fp;
1491 +
1492 + rp = &current_thread_info()->reg_window[i];
1493 + fp = current_thread_info()->rwbuf_stkptrs[i];
1494 + err |= copy_to_user(&rwin->reg_window[i], rp,
1495 + sizeof(struct reg_window32));
1496 + err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
1497 + }
1498 + return err;
1499 +}
1500 +
1501 +int restore_rwin_state(__siginfo_rwin_t __user *rp)
1502 +{
1503 + struct thread_info *t = current_thread_info();
1504 + int i, wsaved, err;
1505 +
1506 + __get_user(wsaved, &rp->wsaved);
1507 + if (wsaved > NSWINS)
1508 + return -EFAULT;
1509 +
1510 + err = 0;
1511 + for (i = 0; i < wsaved; i++) {
1512 + err |= copy_from_user(&t->reg_window[i],
1513 + &rp->reg_window[i],
1514 + sizeof(struct reg_window32));
1515 + err |= __get_user(t->rwbuf_stkptrs[i],
1516 + &rp->rwbuf_stkptrs[i]);
1517 + }
1518 + if (err)
1519 + return err;
1520 +
1521 + t->w_saved = wsaved;
1522 + synchronize_user_stack();
1523 + if (t->w_saved)
1524 + return -EFAULT;
1525 + return 0;
1526 +
1527 +}
1528 diff --git a/arch/sparc/kernel/sigutil_64.c b/arch/sparc/kernel/sigutil_64.c
1529 new file mode 100644
1530 index 0000000..6edc4e5
1531 --- /dev/null
1532 +++ b/arch/sparc/kernel/sigutil_64.c
1533 @@ -0,0 +1,93 @@
1534 +#include <linux/kernel.h>
1535 +#include <linux/types.h>
1536 +#include <linux/thread_info.h>
1537 +#include <linux/uaccess.h>
1538 +
1539 +#include <asm/sigcontext.h>
1540 +#include <asm/fpumacro.h>
1541 +#include <asm/ptrace.h>
1542 +
1543 +#include "sigutil.h"
1544 +
1545 +int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1546 +{
1547 + unsigned long *fpregs = current_thread_info()->fpregs;
1548 + unsigned long fprs;
1549 + int err = 0;
1550 +
1551 + fprs = current_thread_info()->fpsaved[0];
1552 + if (fprs & FPRS_DL)
1553 + err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
1554 + (sizeof(unsigned int) * 32));
1555 + if (fprs & FPRS_DU)
1556 + err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
1557 + (sizeof(unsigned int) * 32));
1558 + err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1559 + err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1560 + err |= __put_user(fprs, &fpu->si_fprs);
1561 +
1562 + return err;
1563 +}
1564 +
1565 +int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
1566 +{
1567 + unsigned long *fpregs = current_thread_info()->fpregs;
1568 + unsigned long fprs;
1569 + int err;
1570 +
1571 + err = __get_user(fprs, &fpu->si_fprs);
1572 + fprs_write(0);
1573 + regs->tstate &= ~TSTATE_PEF;
1574 + if (fprs & FPRS_DL)
1575 + err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
1576 + (sizeof(unsigned int) * 32));
1577 + if (fprs & FPRS_DU)
1578 + err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
1579 + (sizeof(unsigned int) * 32));
1580 + err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
1581 + err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
1582 + current_thread_info()->fpsaved[0] |= fprs;
1583 + return err;
1584 +}
1585 +
1586 +int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
1587 +{
1588 + int i, err = __put_user(wsaved, &rwin->wsaved);
1589 +
1590 + for (i = 0; i < wsaved; i++) {
1591 + struct reg_window *rp = &current_thread_info()->reg_window[i];
1592 + unsigned long fp = current_thread_info()->rwbuf_stkptrs[i];
1593 +
1594 + err |= copy_to_user(&rwin->reg_window[i], rp,
1595 + sizeof(struct reg_window));
1596 + err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
1597 + }
1598 + return err;
1599 +}
1600 +
1601 +int restore_rwin_state(__siginfo_rwin_t __user *rp)
1602 +{
1603 + struct thread_info *t = current_thread_info();
1604 + int i, wsaved, err;
1605 +
1606 + __get_user(wsaved, &rp->wsaved);
1607 + if (wsaved > NSWINS)
1608 + return -EFAULT;
1609 +
1610 + err = 0;
1611 + for (i = 0; i < wsaved; i++) {
1612 + err |= copy_from_user(&t->reg_window[i],
1613 + &rp->reg_window[i],
1614 + sizeof(struct reg_window));
1615 + err |= __get_user(t->rwbuf_stkptrs[i],
1616 + &rp->rwbuf_stkptrs[i]);
1617 + }
1618 + if (err)
1619 + return err;
1620 +
1621 + set_thread_wsaved(wsaved);
1622 + synchronize_user_stack();
1623 + if (get_thread_wsaved())
1624 + return -EFAULT;
1625 + return 0;
1626 +}
1627 diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
1628 index 7c3a95e..d3d9d50 100644
1629 --- a/arch/x86/kernel/amd_iommu.c
1630 +++ b/arch/x86/kernel/amd_iommu.c
1631 @@ -531,7 +531,9 @@ static void build_inv_all(struct iommu_cmd *cmd)
1632 * Writes the command to the IOMMUs command buffer and informs the
1633 * hardware about the new command.
1634 */
1635 -static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
1636 +static int iommu_queue_command_sync(struct amd_iommu *iommu,
1637 + struct iommu_cmd *cmd,
1638 + bool sync)
1639 {
1640 u32 left, tail, head, next_tail;
1641 unsigned long flags;
1642 @@ -565,13 +567,18 @@ again:
1643 copy_cmd_to_buffer(iommu, cmd, tail);
1644
1645 /* We need to sync now to make sure all commands are processed */
1646 - iommu->need_sync = true;
1647 + iommu->need_sync = sync;
1648
1649 spin_unlock_irqrestore(&iommu->lock, flags);
1650
1651 return 0;
1652 }
1653
1654 +static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
1655 +{
1656 + return iommu_queue_command_sync(iommu, cmd, true);
1657 +}
1658 +
1659 /*
1660 * This function queues a completion wait command into the command
1661 * buffer of an IOMMU
1662 @@ -587,7 +594,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
1663
1664 build_completion_wait(&cmd, (u64)&sem);
1665
1666 - ret = iommu_queue_command(iommu, &cmd);
1667 + ret = iommu_queue_command_sync(iommu, &cmd, false);
1668 if (ret)
1669 return ret;
1670
1671 @@ -773,14 +780,9 @@ static void domain_flush_complete(struct protection_domain *domain)
1672 static void domain_flush_devices(struct protection_domain *domain)
1673 {
1674 struct iommu_dev_data *dev_data;
1675 - unsigned long flags;
1676 -
1677 - spin_lock_irqsave(&domain->lock, flags);
1678
1679 list_for_each_entry(dev_data, &domain->dev_list, list)
1680 device_flush_dte(dev_data->dev);
1681 -
1682 - spin_unlock_irqrestore(&domain->lock, flags);
1683 }
1684
1685 /****************************************************************************
1686 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
1687 index 3a0338b..bf6d692 100644
1688 --- a/arch/x86/kernel/cpu/perf_event.c
1689 +++ b/arch/x86/kernel/cpu/perf_event.c
1690 @@ -1856,6 +1856,9 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1691
1692 perf_callchain_store(entry, regs->ip);
1693
1694 + if (!current->mm)
1695 + return;
1696 +
1697 if (perf_callchain_user32(regs, entry))
1698 return;
1699
1700 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
1701 index 41178c8..dd208a8 100644
1702 --- a/arch/x86/kernel/cpu/perf_event_intel.c
1703 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
1704 @@ -1495,6 +1495,7 @@ static __init int intel_pmu_init(void)
1705 break;
1706
1707 case 42: /* SandyBridge */
1708 + case 45: /* SandyBridge, "Romely-EP" */
1709 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
1710 sizeof(hw_cache_event_ids));
1711
1712 diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
1713 index 60aeeb5..acea42e 100644
1714 --- a/arch/x86/xen/setup.c
1715 +++ b/arch/x86/xen/setup.c
1716 @@ -185,6 +185,19 @@ static unsigned long __init xen_set_identity(const struct e820entry *list,
1717 PFN_UP(start_pci), PFN_DOWN(last));
1718 return identity;
1719 }
1720 +
1721 +static unsigned long __init xen_get_max_pages(void)
1722 +{
1723 + unsigned long max_pages = MAX_DOMAIN_PAGES;
1724 + domid_t domid = DOMID_SELF;
1725 + int ret;
1726 +
1727 + ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
1728 + if (ret > 0)
1729 + max_pages = ret;
1730 + return min(max_pages, MAX_DOMAIN_PAGES);
1731 +}
1732 +
1733 /**
1734 * machine_specific_memory_setup - Hook for machine specific memory setup.
1735 **/
1736 @@ -293,6 +306,14 @@ char * __init xen_memory_setup(void)
1737
1738 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
1739
1740 + extra_limit = xen_get_max_pages();
1741 + if (max_pfn + extra_pages > extra_limit) {
1742 + if (extra_limit > max_pfn)
1743 + extra_pages = extra_limit - max_pfn;
1744 + else
1745 + extra_pages = 0;
1746 + }
1747 +
1748 extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820);
1749
1750 /*
1751 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
1752 index e79dbb9..d4fc6d4 100644
1753 --- a/arch/x86/xen/smp.c
1754 +++ b/arch/x86/xen/smp.c
1755 @@ -32,6 +32,7 @@
1756 #include <xen/page.h>
1757 #include <xen/events.h>
1758
1759 +#include <xen/hvc-console.h>
1760 #include "xen-ops.h"
1761 #include "mmu.h"
1762
1763 @@ -207,6 +208,15 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
1764 unsigned cpu;
1765 unsigned int i;
1766
1767 + if (skip_ioapic_setup) {
1768 + char *m = (max_cpus == 0) ?
1769 + "The nosmp parameter is incompatible with Xen; " \
1770 + "use Xen dom0_max_vcpus=1 parameter" :
1771 + "The noapic parameter is incompatible with Xen";
1772 +
1773 + xen_raw_printk(m);
1774 + panic(m);
1775 + }
1776 xen_init_lock_cpu(0);
1777
1778 smp_store_cpu_info(0);
1779 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
1780 index 22a2093..b040b0e 100644
1781 --- a/arch/x86/xen/xen-asm_32.S
1782 +++ b/arch/x86/xen/xen-asm_32.S
1783 @@ -113,11 +113,13 @@ xen_iret_start_crit:
1784
1785 /*
1786 * If there's something pending, mask events again so we can
1787 - * jump back into xen_hypervisor_callback
1788 + * jump back into xen_hypervisor_callback. Otherwise do not
1789 + * touch XEN_vcpu_info_mask.
1790 */
1791 - sete XEN_vcpu_info_mask(%eax)
1792 + jne 1f
1793 + movb $1, XEN_vcpu_info_mask(%eax)
1794
1795 - popl %eax
1796 +1: popl %eax
1797
1798 /*
1799 * From this point on the registers are restored and the stack
1800 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
1801 index bcaf16e..b596e54 100644
1802 --- a/block/blk-cgroup.c
1803 +++ b/block/blk-cgroup.c
1804 @@ -785,10 +785,10 @@ static int blkio_policy_parse_and_set(char *buf,
1805 {
1806 char *s[4], *p, *major_s = NULL, *minor_s = NULL;
1807 int ret;
1808 - unsigned long major, minor, temp;
1809 + unsigned long major, minor;
1810 int i = 0;
1811 dev_t dev;
1812 - u64 bps, iops;
1813 + u64 temp;
1814
1815 memset(s, 0, sizeof(s));
1816
1817 @@ -826,20 +826,23 @@ static int blkio_policy_parse_and_set(char *buf,
1818
1819 dev = MKDEV(major, minor);
1820
1821 - ret = blkio_check_dev_num(dev);
1822 + ret = strict_strtoull(s[1], 10, &temp);
1823 if (ret)
1824 - return ret;
1825 + return -EINVAL;
1826
1827 - newpn->dev = dev;
1828 + /* For rule removal, do not check for device presence. */
1829 + if (temp) {
1830 + ret = blkio_check_dev_num(dev);
1831 + if (ret)
1832 + return ret;
1833 + }
1834
1835 - if (s[1] == NULL)
1836 - return -EINVAL;
1837 + newpn->dev = dev;
1838
1839 switch (plid) {
1840 case BLKIO_POLICY_PROP:
1841 - ret = strict_strtoul(s[1], 10, &temp);
1842 - if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
1843 - temp > BLKIO_WEIGHT_MAX)
1844 + if ((temp < BLKIO_WEIGHT_MIN && temp > 0) ||
1845 + temp > BLKIO_WEIGHT_MAX)
1846 return -EINVAL;
1847
1848 newpn->plid = plid;
1849 @@ -850,26 +853,18 @@ static int blkio_policy_parse_and_set(char *buf,
1850 switch(fileid) {
1851 case BLKIO_THROTL_read_bps_device:
1852 case BLKIO_THROTL_write_bps_device:
1853 - ret = strict_strtoull(s[1], 10, &bps);
1854 - if (ret)
1855 - return -EINVAL;
1856 -
1857 newpn->plid = plid;
1858 newpn->fileid = fileid;
1859 - newpn->val.bps = bps;
1860 + newpn->val.bps = temp;
1861 break;
1862 case BLKIO_THROTL_read_iops_device:
1863 case BLKIO_THROTL_write_iops_device:
1864 - ret = strict_strtoull(s[1], 10, &iops);
1865 - if (ret)
1866 - return -EINVAL;
1867 -
1868 - if (iops > THROTL_IOPS_MAX)
1869 + if (temp > THROTL_IOPS_MAX)
1870 return -EINVAL;
1871
1872 newpn->plid = plid;
1873 newpn->fileid = fileid;
1874 - newpn->val.iops = (unsigned int)iops;
1875 + newpn->val.iops = (unsigned int)temp;
1876 break;
1877 }
1878 break;
1879 diff --git a/block/blk-core.c b/block/blk-core.c
1880 index 1d49e1c..847d04e 100644
1881 --- a/block/blk-core.c
1882 +++ b/block/blk-core.c
1883 @@ -348,9 +348,10 @@ void blk_put_queue(struct request_queue *q)
1884 EXPORT_SYMBOL(blk_put_queue);
1885
1886 /*
1887 - * Note: If a driver supplied the queue lock, it should not zap that lock
1888 - * unexpectedly as some queue cleanup components like elevator_exit() and
1889 - * blk_throtl_exit() need queue lock.
1890 + * Note: If a driver supplied the queue lock, it is disconnected
1891 + * by this function. The actual state of the lock doesn't matter
1892 + * here as the request_queue isn't accessible after this point
1893 + * (QUEUE_FLAG_DEAD is set) and no other requests will be queued.
1894 */
1895 void blk_cleanup_queue(struct request_queue *q)
1896 {
1897 @@ -367,10 +368,8 @@ void blk_cleanup_queue(struct request_queue *q)
1898 queue_flag_set_unlocked(QUEUE_FLAG_DEAD, q);
1899 mutex_unlock(&q->sysfs_lock);
1900
1901 - if (q->elevator)
1902 - elevator_exit(q->elevator);
1903 -
1904 - blk_throtl_exit(q);
1905 + if (q->queue_lock != &q->__queue_lock)
1906 + q->queue_lock = &q->__queue_lock;
1907
1908 blk_put_queue(q);
1909 }
1910 diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
1911 index d935bd8..45c56d8 100644
1912 --- a/block/blk-sysfs.c
1913 +++ b/block/blk-sysfs.c
1914 @@ -472,6 +472,11 @@ static void blk_release_queue(struct kobject *kobj)
1915
1916 blk_sync_queue(q);
1917
1918 + if (q->elevator)
1919 + elevator_exit(q->elevator);
1920 +
1921 + blk_throtl_exit(q);
1922 +
1923 if (rl->rq_pool)
1924 mempool_destroy(rl->rq_pool);
1925
1926 diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
1927 index bc533dd..f895a24 100644
1928 --- a/drivers/acpi/acpica/acconfig.h
1929 +++ b/drivers/acpi/acpica/acconfig.h
1930 @@ -121,7 +121,7 @@
1931
1932 /* Maximum sleep allowed via Sleep() operator */
1933
1934 -#define ACPI_MAX_SLEEP 20000 /* Two seconds */
1935 +#define ACPI_MAX_SLEEP 2000 /* Two seconds */
1936
1937 /******************************************************************************
1938 *
1939 diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
1940 index c7f743c..5552125 100644
1941 --- a/drivers/acpi/acpica/aclocal.h
1942 +++ b/drivers/acpi/acpica/aclocal.h
1943 @@ -357,6 +357,7 @@ struct acpi_predefined_data {
1944 char *pathname;
1945 const union acpi_predefined_info *predefined;
1946 union acpi_operand_object *parent_package;
1947 + struct acpi_namespace_node *node;
1948 u32 flags;
1949 u8 node_flags;
1950 };
1951 diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
1952 index 9fb03fa..dc00582 100644
1953 --- a/drivers/acpi/acpica/nspredef.c
1954 +++ b/drivers/acpi/acpica/nspredef.c
1955 @@ -212,6 +212,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
1956 goto cleanup;
1957 }
1958 data->predefined = predefined;
1959 + data->node = node;
1960 data->node_flags = node->flags;
1961 data->pathname = pathname;
1962
1963 diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
1964 index 973883b..024c4f2 100644
1965 --- a/drivers/acpi/acpica/nsrepair2.c
1966 +++ b/drivers/acpi/acpica/nsrepair2.c
1967 @@ -503,6 +503,21 @@ acpi_ns_repair_TSS(struct acpi_predefined_data *data,
1968 {
1969 union acpi_operand_object *return_object = *return_object_ptr;
1970 acpi_status status;
1971 + struct acpi_namespace_node *node;
1972 +
1973 + /*
1974 + * We can only sort the _TSS return package if there is no _PSS in the
1975 + * same scope. This is because if _PSS is present, the ACPI specification
1976 + * dictates that the _TSS Power Dissipation field is to be ignored, and
1977 + * therefore some BIOSs leave garbage values in the _TSS Power field(s).
1978 + * In this case, it is best to just return the _TSS package as-is.
1979 + * (May, 2011)
1980 + */
1981 + status =
1982 + acpi_ns_get_node(data->node, "^_PSS", ACPI_NS_NO_UPSEARCH, &node);
1983 + if (ACPI_SUCCESS(status)) {
1984 + return (AE_OK);
1985 + }
1986
1987 status = acpi_ns_check_sorted_list(data, return_object, 5, 1,
1988 ACPI_SORT_DESCENDING,
1989 diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
1990 index 71afe03..cab6960 100644
1991 --- a/drivers/ata/ahci.c
1992 +++ b/drivers/ata/ahci.c
1993 @@ -267,6 +267,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
1994 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
1995 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
1996 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
1997 + { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
1998
1999 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
2000 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
2001 diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
2002 index ac8d7d9..d6d4f57 100644
2003 --- a/drivers/ata/pata_via.c
2004 +++ b/drivers/ata/pata_via.c
2005 @@ -124,6 +124,17 @@ static const struct via_isa_bridge {
2006 { NULL }
2007 };
2008
2009 +static const struct dmi_system_id no_atapi_dma_dmi_table[] = {
2010 + {
2011 + .ident = "AVERATEC 3200",
2012 + .matches = {
2013 + DMI_MATCH(DMI_BOARD_VENDOR, "AVERATEC"),
2014 + DMI_MATCH(DMI_BOARD_NAME, "3200"),
2015 + },
2016 + },
2017 + { }
2018 +};
2019 +
2020 struct via_port {
2021 u8 cached_device;
2022 };
2023 @@ -355,6 +366,13 @@ static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask)
2024 mask &= ~ ATA_MASK_UDMA;
2025 }
2026 }
2027 +
2028 + if (dev->class == ATA_DEV_ATAPI &&
2029 + dmi_check_system(no_atapi_dma_dmi_table)) {
2030 + ata_dev_printk(dev, KERN_WARNING, "controller locks up on ATAPI DMA, forcing PIO\n");
2031 + mask &= ATA_MASK_PIO;
2032 + }
2033 +
2034 return mask;
2035 }
2036
2037 diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
2038 index bbb03e6..06ed6b4 100644
2039 --- a/drivers/base/firmware_class.c
2040 +++ b/drivers/base/firmware_class.c
2041 @@ -521,11 +521,6 @@ static int _request_firmware(const struct firmware **firmware_p,
2042 if (!firmware_p)
2043 return -EINVAL;
2044
2045 - if (WARN_ON(usermodehelper_is_disabled())) {
2046 - dev_err(device, "firmware: %s will not be loaded\n", name);
2047 - return -EBUSY;
2048 - }
2049 -
2050 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
2051 if (!firmware) {
2052 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
2053 @@ -539,6 +534,12 @@ static int _request_firmware(const struct firmware **firmware_p,
2054 return 0;
2055 }
2056
2057 + if (WARN_ON(usermodehelper_is_disabled())) {
2058 + dev_err(device, "firmware: %s will not be loaded\n", name);
2059 + retval = -EBUSY;
2060 + goto out;
2061 + }
2062 +
2063 if (uevent)
2064 dev_dbg(device, "firmware: requesting %s\n", name);
2065
2066 diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
2067 index 98de8f4..9955a53 100644
2068 --- a/drivers/block/floppy.c
2069 +++ b/drivers/block/floppy.c
2070 @@ -4250,7 +4250,7 @@ static int __init floppy_init(void)
2071 use_virtual_dma = can_use_virtual_dma & 1;
2072 fdc_state[0].address = FDC1;
2073 if (fdc_state[0].address == -1) {
2074 - del_timer(&fd_timeout);
2075 + del_timer_sync(&fd_timeout);
2076 err = -ENODEV;
2077 goto out_unreg_region;
2078 }
2079 @@ -4261,7 +4261,7 @@ static int __init floppy_init(void)
2080 fdc = 0; /* reset fdc in case of unexpected interrupt */
2081 err = floppy_grab_irq_and_dma();
2082 if (err) {
2083 - del_timer(&fd_timeout);
2084 + del_timer_sync(&fd_timeout);
2085 err = -EBUSY;
2086 goto out_unreg_region;
2087 }
2088 @@ -4318,7 +4318,7 @@ static int __init floppy_init(void)
2089 user_reset_fdc(-1, FD_RESET_ALWAYS, false);
2090 }
2091 fdc = 0;
2092 - del_timer(&fd_timeout);
2093 + del_timer_sync(&fd_timeout);
2094 current_drive = 0;
2095 initialized = true;
2096 if (have_no_fdc) {
2097 @@ -4368,7 +4368,7 @@ out_unreg_blkdev:
2098 unregister_blkdev(FLOPPY_MAJOR, "fd");
2099 out_put_disk:
2100 while (dr--) {
2101 - del_timer(&motor_off_timer[dr]);
2102 + del_timer_sync(&motor_off_timer[dr]);
2103 if (disks[dr]->queue)
2104 blk_cleanup_queue(disks[dr]->queue);
2105 put_disk(disks[dr]);
2106 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
2107 index 7beb0e2..b85ee76 100644
2108 --- a/drivers/char/tpm/tpm.c
2109 +++ b/drivers/char/tpm/tpm.c
2110 @@ -383,6 +383,9 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
2111 u32 count, ordinal;
2112 unsigned long stop;
2113
2114 + if (bufsiz > TPM_BUFSIZE)
2115 + bufsiz = TPM_BUFSIZE;
2116 +
2117 count = be32_to_cpu(*((__be32 *) (buf + 2)));
2118 ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
2119 if (count == 0)
2120 @@ -1052,6 +1055,7 @@ ssize_t tpm_read(struct file *file, char __user *buf,
2121 {
2122 struct tpm_chip *chip = file->private_data;
2123 ssize_t ret_size;
2124 + int rc;
2125
2126 del_singleshot_timer_sync(&chip->user_read_timer);
2127 flush_work_sync(&chip->work);
2128 @@ -1062,8 +1066,11 @@ ssize_t tpm_read(struct file *file, char __user *buf,
2129 ret_size = size;
2130
2131 mutex_lock(&chip->buffer_mutex);
2132 - if (copy_to_user(buf, chip->data_buffer, ret_size))
2133 + rc = copy_to_user(buf, chip->data_buffer, ret_size);
2134 + memset(chip->data_buffer, 0, ret_size);
2135 + if (rc)
2136 ret_size = -EFAULT;
2137 +
2138 mutex_unlock(&chip->buffer_mutex);
2139 }
2140
2141 diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
2142 index 7b0603e..cdc02ac 100644
2143 --- a/drivers/cpufreq/pcc-cpufreq.c
2144 +++ b/drivers/cpufreq/pcc-cpufreq.c
2145 @@ -261,6 +261,9 @@ static int pcc_get_offset(int cpu)
2146 pr = per_cpu(processors, cpu);
2147 pcc_cpu_data = per_cpu_ptr(pcc_cpu_info, cpu);
2148
2149 + if (!pr)
2150 + return -ENODEV;
2151 +
2152 status = acpi_evaluate_object(pr->handle, "PCCP", NULL, &buffer);
2153 if (ACPI_FAILURE(status))
2154 return -ENODEV;
2155 diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
2156 index ebb8973..ee76c8e 100644
2157 --- a/drivers/firewire/ohci.c
2158 +++ b/drivers/firewire/ohci.c
2159 @@ -291,6 +291,9 @@ static const struct {
2160 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, PCI_ANY_ID,
2161 QUIRK_CYCLE_TIMER},
2162
2163 + {PCI_VENDOR_ID_O2, PCI_ANY_ID, PCI_ANY_ID,
2164 + QUIRK_NO_MSI},
2165 +
2166 {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, PCI_ANY_ID,
2167 QUIRK_CYCLE_TIMER},
2168
2169 diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2170 index 82fad91..ca6028f 100644
2171 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2172 +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
2173 @@ -37,8 +37,11 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages,
2174 return -ENOMEM;
2175
2176 nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL);
2177 - if (!nvbe->ttm_alloced)
2178 + if (!nvbe->ttm_alloced) {
2179 + kfree(nvbe->pages);
2180 + nvbe->pages = NULL;
2181 return -ENOMEM;
2182 + }
2183
2184 nvbe->nr_pages = 0;
2185 while (num_pages--) {
2186 diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
2187 index 15bd047..c975581 100644
2188 --- a/drivers/gpu/drm/radeon/evergreen.c
2189 +++ b/drivers/gpu/drm/radeon/evergreen.c
2190 @@ -41,6 +41,31 @@ static void evergreen_gpu_init(struct radeon_device *rdev);
2191 void evergreen_fini(struct radeon_device *rdev);
2192 static void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
2193
2194 +void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)
2195 +{
2196 + u16 ctl, v;
2197 + int cap, err;
2198 +
2199 + cap = pci_pcie_cap(rdev->pdev);
2200 + if (!cap)
2201 + return;
2202 +
2203 + err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl);
2204 + if (err)
2205 + return;
2206 +
2207 + v = (ctl & PCI_EXP_DEVCTL_READRQ) >> 12;
2208 +
2209 + /* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it
2210 + * to avoid hangs or perfomance issues
2211 + */
2212 + if ((v == 0) || (v == 6) || (v == 7)) {
2213 + ctl &= ~PCI_EXP_DEVCTL_READRQ;
2214 + ctl |= (2 << 12);
2215 + pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl);
2216 + }
2217 +}
2218 +
2219 void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc)
2220 {
2221 /* enable the pflip int */
2222 @@ -1357,6 +1382,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2223 SOFT_RESET_PA |
2224 SOFT_RESET_SH |
2225 SOFT_RESET_VGT |
2226 + SOFT_RESET_SPI |
2227 SOFT_RESET_SX));
2228 RREG32(GRBM_SOFT_RESET);
2229 mdelay(15);
2230 @@ -1378,7 +1404,8 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2231 /* Initialize the ring buffer's read and write pointers */
2232 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
2233 WREG32(CP_RB_RPTR_WR, 0);
2234 - WREG32(CP_RB_WPTR, 0);
2235 + rdev->cp.wptr = 0;
2236 + WREG32(CP_RB_WPTR, rdev->cp.wptr);
2237
2238 /* set the wb address wether it's enabled or not */
2239 WREG32(CP_RB_RPTR_ADDR,
2240 @@ -1403,7 +1430,6 @@ int evergreen_cp_resume(struct radeon_device *rdev)
2241 WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
2242
2243 rdev->cp.rptr = RREG32(CP_RB_RPTR);
2244 - rdev->cp.wptr = RREG32(CP_RB_WPTR);
2245
2246 evergreen_cp_start(rdev);
2247 rdev->cp.ready = true;
2248 @@ -1865,6 +1891,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
2249
2250 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
2251
2252 + evergreen_fix_pci_max_read_req_size(rdev);
2253 +
2254 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2;
2255
2256 cc_gc_shader_pipe_config |=
2257 @@ -3142,21 +3170,23 @@ int evergreen_suspend(struct radeon_device *rdev)
2258 }
2259
2260 int evergreen_copy_blit(struct radeon_device *rdev,
2261 - uint64_t src_offset, uint64_t dst_offset,
2262 - unsigned num_pages, struct radeon_fence *fence)
2263 + uint64_t src_offset,
2264 + uint64_t dst_offset,
2265 + unsigned num_gpu_pages,
2266 + struct radeon_fence *fence)
2267 {
2268 int r;
2269
2270 mutex_lock(&rdev->r600_blit.mutex);
2271 rdev->r600_blit.vb_ib = NULL;
2272 - r = evergreen_blit_prepare_copy(rdev, num_pages * RADEON_GPU_PAGE_SIZE);
2273 + r = evergreen_blit_prepare_copy(rdev, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2274 if (r) {
2275 if (rdev->r600_blit.vb_ib)
2276 radeon_ib_free(rdev, &rdev->r600_blit.vb_ib);
2277 mutex_unlock(&rdev->r600_blit.mutex);
2278 return r;
2279 }
2280 - evergreen_kms_blit_copy(rdev, src_offset, dst_offset, num_pages * RADEON_GPU_PAGE_SIZE);
2281 + evergreen_kms_blit_copy(rdev, src_offset, dst_offset, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2282 evergreen_blit_done_copy(rdev, fence);
2283 mutex_unlock(&rdev->r600_blit.mutex);
2284 return 0;
2285 diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
2286 index 559dbd4..0b132a3 100644
2287 --- a/drivers/gpu/drm/radeon/ni.c
2288 +++ b/drivers/gpu/drm/radeon/ni.c
2289 @@ -39,6 +39,7 @@ extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev);
2290 extern void evergreen_mc_program(struct radeon_device *rdev);
2291 extern void evergreen_irq_suspend(struct radeon_device *rdev);
2292 extern int evergreen_mc_init(struct radeon_device *rdev);
2293 +extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
2294
2295 #define EVERGREEN_PFP_UCODE_SIZE 1120
2296 #define EVERGREEN_PM4_UCODE_SIZE 1376
2297 @@ -669,6 +670,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
2298
2299 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
2300
2301 + evergreen_fix_pci_max_read_req_size(rdev);
2302 +
2303 mc_shared_chmap = RREG32(MC_SHARED_CHMAP);
2304 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG);
2305
2306 @@ -1158,6 +1161,7 @@ int cayman_cp_resume(struct radeon_device *rdev)
2307 SOFT_RESET_PA |
2308 SOFT_RESET_SH |
2309 SOFT_RESET_VGT |
2310 + SOFT_RESET_SPI |
2311 SOFT_RESET_SX));
2312 RREG32(GRBM_SOFT_RESET);
2313 mdelay(15);
2314 @@ -1182,7 +1186,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2315
2316 /* Initialize the ring buffer's read and write pointers */
2317 WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA);
2318 - WREG32(CP_RB0_WPTR, 0);
2319 + rdev->cp.wptr = 0;
2320 + WREG32(CP_RB0_WPTR, rdev->cp.wptr);
2321
2322 /* set the wb address wether it's enabled or not */
2323 WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC);
2324 @@ -1202,7 +1207,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2325 WREG32(CP_RB0_BASE, rdev->cp.gpu_addr >> 8);
2326
2327 rdev->cp.rptr = RREG32(CP_RB0_RPTR);
2328 - rdev->cp.wptr = RREG32(CP_RB0_WPTR);
2329
2330 /* ring1 - compute only */
2331 /* Set ring buffer size */
2332 @@ -1215,7 +1219,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2333
2334 /* Initialize the ring buffer's read and write pointers */
2335 WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA);
2336 - WREG32(CP_RB1_WPTR, 0);
2337 + rdev->cp1.wptr = 0;
2338 + WREG32(CP_RB1_WPTR, rdev->cp1.wptr);
2339
2340 /* set the wb address wether it's enabled or not */
2341 WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC);
2342 @@ -1227,7 +1232,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2343 WREG32(CP_RB1_BASE, rdev->cp1.gpu_addr >> 8);
2344
2345 rdev->cp1.rptr = RREG32(CP_RB1_RPTR);
2346 - rdev->cp1.wptr = RREG32(CP_RB1_WPTR);
2347
2348 /* ring2 - compute only */
2349 /* Set ring buffer size */
2350 @@ -1240,7 +1244,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
2351
2352 /* Initialize the ring buffer's read and write pointers */
2353 WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA);
2354 - WREG32(CP_RB2_WPTR, 0);
2355 + rdev->cp2.wptr = 0;
2356 + WREG32(CP_RB2_WPTR, rdev->cp2.wptr);
2357
2358 /* set the wb address wether it's enabled or not */
2359 WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC);
2360 @@ -1252,7 +1257,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
2361 WREG32(CP_RB2_BASE, rdev->cp2.gpu_addr >> 8);
2362
2363 rdev->cp2.rptr = RREG32(CP_RB2_RPTR);
2364 - rdev->cp2.wptr = RREG32(CP_RB2_WPTR);
2365
2366 /* start the rings */
2367 cayman_cp_start(rdev);
2368 diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
2369 index f2204cb..830e1f1 100644
2370 --- a/drivers/gpu/drm/radeon/r100.c
2371 +++ b/drivers/gpu/drm/radeon/r100.c
2372 @@ -721,11 +721,11 @@ void r100_fence_ring_emit(struct radeon_device *rdev,
2373 int r100_copy_blit(struct radeon_device *rdev,
2374 uint64_t src_offset,
2375 uint64_t dst_offset,
2376 - unsigned num_pages,
2377 + unsigned num_gpu_pages,
2378 struct radeon_fence *fence)
2379 {
2380 uint32_t cur_pages;
2381 - uint32_t stride_bytes = PAGE_SIZE;
2382 + uint32_t stride_bytes = RADEON_GPU_PAGE_SIZE;
2383 uint32_t pitch;
2384 uint32_t stride_pixels;
2385 unsigned ndw;
2386 @@ -737,7 +737,7 @@ int r100_copy_blit(struct radeon_device *rdev,
2387 /* radeon pitch is /64 */
2388 pitch = stride_bytes / 64;
2389 stride_pixels = stride_bytes / 4;
2390 - num_loops = DIV_ROUND_UP(num_pages, 8191);
2391 + num_loops = DIV_ROUND_UP(num_gpu_pages, 8191);
2392
2393 /* Ask for enough room for blit + flush + fence */
2394 ndw = 64 + (10 * num_loops);
2395 @@ -746,12 +746,12 @@ int r100_copy_blit(struct radeon_device *rdev,
2396 DRM_ERROR("radeon: moving bo (%d) asking for %u dw.\n", r, ndw);
2397 return -EINVAL;
2398 }
2399 - while (num_pages > 0) {
2400 - cur_pages = num_pages;
2401 + while (num_gpu_pages > 0) {
2402 + cur_pages = num_gpu_pages;
2403 if (cur_pages > 8191) {
2404 cur_pages = 8191;
2405 }
2406 - num_pages -= cur_pages;
2407 + num_gpu_pages -= cur_pages;
2408
2409 /* pages are in Y direction - height
2410 page width in X direction - width */
2411 @@ -990,7 +990,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
2412 /* Force read & write ptr to 0 */
2413 WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA | RADEON_RB_NO_UPDATE);
2414 WREG32(RADEON_CP_RB_RPTR_WR, 0);
2415 - WREG32(RADEON_CP_RB_WPTR, 0);
2416 + rdev->cp.wptr = 0;
2417 + WREG32(RADEON_CP_RB_WPTR, rdev->cp.wptr);
2418
2419 /* set the wb address whether it's enabled or not */
2420 WREG32(R_00070C_CP_RB_RPTR_ADDR,
2421 @@ -1007,9 +1008,6 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
2422 WREG32(RADEON_CP_RB_CNTL, tmp);
2423 udelay(10);
2424 rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
2425 - rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR);
2426 - /* protect against crazy HW on resume */
2427 - rdev->cp.wptr &= rdev->cp.ptr_mask;
2428 /* Set cp mode to bus mastering & enable cp*/
2429 WREG32(RADEON_CP_CSQ_MODE,
2430 REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
2431 diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
2432 index f240583..a1f3ba0 100644
2433 --- a/drivers/gpu/drm/radeon/r200.c
2434 +++ b/drivers/gpu/drm/radeon/r200.c
2435 @@ -84,7 +84,7 @@ static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)
2436 int r200_copy_dma(struct radeon_device *rdev,
2437 uint64_t src_offset,
2438 uint64_t dst_offset,
2439 - unsigned num_pages,
2440 + unsigned num_gpu_pages,
2441 struct radeon_fence *fence)
2442 {
2443 uint32_t size;
2444 @@ -93,7 +93,7 @@ int r200_copy_dma(struct radeon_device *rdev,
2445 int r = 0;
2446
2447 /* radeon pitch is /64 */
2448 - size = num_pages << PAGE_SHIFT;
2449 + size = num_gpu_pages << RADEON_GPU_PAGE_SHIFT;
2450 num_loops = DIV_ROUND_UP(size, 0x1FFFFF);
2451 r = radeon_ring_lock(rdev, num_loops * 4 + 64);
2452 if (r) {
2453 diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
2454 index bc54b26..1dea9d6 100644
2455 --- a/drivers/gpu/drm/radeon/r600.c
2456 +++ b/drivers/gpu/drm/radeon/r600.c
2457 @@ -2208,7 +2208,8 @@ int r600_cp_resume(struct radeon_device *rdev)
2458 /* Initialize the ring buffer's read and write pointers */
2459 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
2460 WREG32(CP_RB_RPTR_WR, 0);
2461 - WREG32(CP_RB_WPTR, 0);
2462 + rdev->cp.wptr = 0;
2463 + WREG32(CP_RB_WPTR, rdev->cp.wptr);
2464
2465 /* set the wb address whether it's enabled or not */
2466 WREG32(CP_RB_RPTR_ADDR,
2467 @@ -2233,7 +2234,6 @@ int r600_cp_resume(struct radeon_device *rdev)
2468 WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
2469
2470 rdev->cp.rptr = RREG32(CP_RB_RPTR);
2471 - rdev->cp.wptr = RREG32(CP_RB_WPTR);
2472
2473 r600_cp_start(rdev);
2474 rdev->cp.ready = true;
2475 @@ -2355,21 +2355,23 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
2476 }
2477
2478 int r600_copy_blit(struct radeon_device *rdev,
2479 - uint64_t src_offset, uint64_t dst_offset,
2480 - unsigned num_pages, struct radeon_fence *fence)
2481 + uint64_t src_offset,
2482 + uint64_t dst_offset,
2483 + unsigned num_gpu_pages,
2484 + struct radeon_fence *fence)
2485 {
2486 int r;
2487
2488 mutex_lock(&rdev->r600_blit.mutex);
2489 rdev->r600_blit.vb_ib = NULL;
2490 - r = r600_blit_prepare_copy(rdev, num_pages * RADEON_GPU_PAGE_SIZE);
2491 + r = r600_blit_prepare_copy(rdev, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2492 if (r) {
2493 if (rdev->r600_blit.vb_ib)
2494 radeon_ib_free(rdev, &rdev->r600_blit.vb_ib);
2495 mutex_unlock(&rdev->r600_blit.mutex);
2496 return r;
2497 }
2498 - r600_kms_blit_copy(rdev, src_offset, dst_offset, num_pages * RADEON_GPU_PAGE_SIZE);
2499 + r600_kms_blit_copy(rdev, src_offset, dst_offset, num_gpu_pages * RADEON_GPU_PAGE_SIZE);
2500 r600_blit_done_copy(rdev, fence);
2501 mutex_unlock(&rdev->r600_blit.mutex);
2502 return 0;
2503 diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
2504 index ef0e0e0..0bb4ddf 100644
2505 --- a/drivers/gpu/drm/radeon/radeon.h
2506 +++ b/drivers/gpu/drm/radeon/radeon.h
2507 @@ -322,6 +322,7 @@ union radeon_gart_table {
2508
2509 #define RADEON_GPU_PAGE_SIZE 4096
2510 #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
2511 +#define RADEON_GPU_PAGE_SHIFT 12
2512
2513 struct radeon_gart {
2514 dma_addr_t table_addr;
2515 @@ -914,17 +915,17 @@ struct radeon_asic {
2516 int (*copy_blit)(struct radeon_device *rdev,
2517 uint64_t src_offset,
2518 uint64_t dst_offset,
2519 - unsigned num_pages,
2520 + unsigned num_gpu_pages,
2521 struct radeon_fence *fence);
2522 int (*copy_dma)(struct radeon_device *rdev,
2523 uint64_t src_offset,
2524 uint64_t dst_offset,
2525 - unsigned num_pages,
2526 + unsigned num_gpu_pages,
2527 struct radeon_fence *fence);
2528 int (*copy)(struct radeon_device *rdev,
2529 uint64_t src_offset,
2530 uint64_t dst_offset,
2531 - unsigned num_pages,
2532 + unsigned num_gpu_pages,
2533 struct radeon_fence *fence);
2534 uint32_t (*get_engine_clock)(struct radeon_device *rdev);
2535 void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
2536 diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
2537 index 3d7a0d7..3dedaa0 100644
2538 --- a/drivers/gpu/drm/radeon/radeon_asic.h
2539 +++ b/drivers/gpu/drm/radeon/radeon_asic.h
2540 @@ -75,7 +75,7 @@ uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg);
2541 int r100_copy_blit(struct radeon_device *rdev,
2542 uint64_t src_offset,
2543 uint64_t dst_offset,
2544 - unsigned num_pages,
2545 + unsigned num_gpu_pages,
2546 struct radeon_fence *fence);
2547 int r100_set_surface_reg(struct radeon_device *rdev, int reg,
2548 uint32_t tiling_flags, uint32_t pitch,
2549 @@ -143,7 +143,7 @@ extern void r100_post_page_flip(struct radeon_device *rdev, int crtc);
2550 extern int r200_copy_dma(struct radeon_device *rdev,
2551 uint64_t src_offset,
2552 uint64_t dst_offset,
2553 - unsigned num_pages,
2554 + unsigned num_gpu_pages,
2555 struct radeon_fence *fence);
2556 void r200_set_safe_registers(struct radeon_device *rdev);
2557
2558 @@ -311,7 +311,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
2559 int r600_ring_test(struct radeon_device *rdev);
2560 int r600_copy_blit(struct radeon_device *rdev,
2561 uint64_t src_offset, uint64_t dst_offset,
2562 - unsigned num_pages, struct radeon_fence *fence);
2563 + unsigned num_gpu_pages, struct radeon_fence *fence);
2564 void r600_hpd_init(struct radeon_device *rdev);
2565 void r600_hpd_fini(struct radeon_device *rdev);
2566 bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
2567 @@ -403,7 +403,7 @@ void evergreen_bandwidth_update(struct radeon_device *rdev);
2568 void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
2569 int evergreen_copy_blit(struct radeon_device *rdev,
2570 uint64_t src_offset, uint64_t dst_offset,
2571 - unsigned num_pages, struct radeon_fence *fence);
2572 + unsigned num_gpu_pages, struct radeon_fence *fence);
2573 void evergreen_hpd_init(struct radeon_device *rdev);
2574 void evergreen_hpd_fini(struct radeon_device *rdev);
2575 bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
2576 diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c
2577 index 2d48e7a..b956cf1 100644
2578 --- a/drivers/gpu/drm/radeon/radeon_clocks.c
2579 +++ b/drivers/gpu/drm/radeon/radeon_clocks.c
2580 @@ -219,6 +219,9 @@ void radeon_get_clock_info(struct drm_device *dev)
2581 } else {
2582 DRM_INFO("Using generic clock info\n");
2583
2584 + /* may need to be per card */
2585 + rdev->clock.max_pixel_clock = 35000;
2586 +
2587 if (rdev->flags & RADEON_IS_IGP) {
2588 p1pll->reference_freq = 1432;
2589 p2pll->reference_freq = 1432;
2590 diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
2591 index a74217c..cd3c86c 100644
2592 --- a/drivers/gpu/drm/radeon/radeon_combios.c
2593 +++ b/drivers/gpu/drm/radeon/radeon_combios.c
2594 @@ -3279,6 +3279,14 @@ void radeon_combios_asic_init(struct drm_device *dev)
2595 rdev->pdev->subsystem_device == 0x30a4)
2596 return;
2597
2598 + /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume
2599 + * - it hangs on resume inside the dynclk 1 table.
2600 + */
2601 + if (rdev->family == CHIP_RS480 &&
2602 + rdev->pdev->subsystem_vendor == 0x103c &&
2603 + rdev->pdev->subsystem_device == 0x30ae)
2604 + return;
2605 +
2606 /* DYN CLK 1 */
2607 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2608 if (table)
2609 diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
2610 index 319d85d..13690f3 100644
2611 --- a/drivers/gpu/drm/radeon/radeon_encoders.c
2612 +++ b/drivers/gpu/drm/radeon/radeon_encoders.c
2613 @@ -1507,7 +1507,14 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
2614 switch (mode) {
2615 case DRM_MODE_DPMS_ON:
2616 args.ucAction = ATOM_ENABLE;
2617 - atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2618 + /* workaround for DVOOutputControl on some RS690 systems */
2619 + if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DDI) {
2620 + u32 reg = RREG32(RADEON_BIOS_3_SCRATCH);
2621 + WREG32(RADEON_BIOS_3_SCRATCH, reg & ~ATOM_S3_DFP2I_ACTIVE);
2622 + atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2623 + WREG32(RADEON_BIOS_3_SCRATCH, reg);
2624 + } else
2625 + atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2626 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
2627 args.ucAction = ATOM_LCD_BLON;
2628 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2629 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
2630 index 60125dd..3e9b41b 100644
2631 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
2632 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
2633 @@ -277,7 +277,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
2634 DRM_ERROR("Trying to move memory with CP turned off.\n");
2635 return -EINVAL;
2636 }
2637 - r = radeon_copy(rdev, old_start, new_start, new_mem->num_pages, fence);
2638 +
2639 + BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0);
2640 +
2641 + r = radeon_copy(rdev, old_start, new_start,
2642 + new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */
2643 + fence);
2644 /* FIXME: handle copy error */
2645 r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL,
2646 evict, no_wait_reserve, no_wait_gpu, new_mem);
2647 diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
2648 index 257957c..4f7c3fc 100644
2649 --- a/drivers/hwmon/ds620.c
2650 +++ b/drivers/hwmon/ds620.c
2651 @@ -72,7 +72,7 @@ struct ds620_data {
2652 char valid; /* !=0 if following fields are valid */
2653 unsigned long last_updated; /* In jiffies */
2654
2655 - u16 temp[3]; /* Register values, word */
2656 + s16 temp[3]; /* Register values, word */
2657 };
2658
2659 /*
2660 diff --git a/drivers/hwmon/max16065.c b/drivers/hwmon/max16065.c
2661 index d94a24f..dd2d7b9 100644
2662 --- a/drivers/hwmon/max16065.c
2663 +++ b/drivers/hwmon/max16065.c
2664 @@ -124,7 +124,7 @@ static inline int MV_TO_LIMIT(int mv, int range)
2665
2666 static inline int ADC_TO_CURR(int adc, int gain)
2667 {
2668 - return adc * 1400000 / gain * 255;
2669 + return adc * 1400000 / (gain * 255);
2670 }
2671
2672 /*
2673 diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
2674 index 0a5008f..2332dc2 100644
2675 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
2676 +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
2677 @@ -287,7 +287,7 @@ void __free_ep(struct kref *kref)
2678 if (test_bit(RELEASE_RESOURCES, &ep->com.flags)) {
2679 cxgb3_remove_tid(ep->com.tdev, (void *)ep, ep->hwtid);
2680 dst_release(ep->dst);
2681 - l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2682 + l2t_release(ep->com.tdev, ep->l2t);
2683 }
2684 kfree(ep);
2685 }
2686 @@ -1178,7 +1178,7 @@ static int act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2687 release_tid(ep->com.tdev, GET_TID(rpl), NULL);
2688 cxgb3_free_atid(ep->com.tdev, ep->atid);
2689 dst_release(ep->dst);
2690 - l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2691 + l2t_release(ep->com.tdev, ep->l2t);
2692 put_ep(&ep->com);
2693 return CPL_RET_BUF_DONE;
2694 }
2695 @@ -1375,7 +1375,7 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2696 if (!child_ep) {
2697 printk(KERN_ERR MOD "%s - failed to allocate ep entry!\n",
2698 __func__);
2699 - l2t_release(L2DATA(tdev), l2t);
2700 + l2t_release(tdev, l2t);
2701 dst_release(dst);
2702 goto reject;
2703 }
2704 @@ -1952,7 +1952,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2705 if (!err)
2706 goto out;
2707
2708 - l2t_release(L2DATA(h->rdev.t3cdev_p), ep->l2t);
2709 + l2t_release(h->rdev.t3cdev_p, ep->l2t);
2710 fail4:
2711 dst_release(ep->dst);
2712 fail3:
2713 @@ -2123,7 +2123,7 @@ int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
2714 PDBG("%s ep %p redirect to dst %p l2t %p\n", __func__, ep, new,
2715 l2t);
2716 dst_hold(new);
2717 - l2t_release(L2DATA(ep->com.tdev), ep->l2t);
2718 + l2t_release(ep->com.tdev, ep->l2t);
2719 ep->l2t = l2t;
2720 dst_release(old);
2721 ep->dst = new;
2722 diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
2723 index d87c9d0..328c64c 100644
2724 --- a/drivers/leds/ledtrig-timer.c
2725 +++ b/drivers/leds/ledtrig-timer.c
2726 @@ -41,6 +41,7 @@ static ssize_t led_delay_on_store(struct device *dev,
2727
2728 if (count == size) {
2729 led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
2730 + led_cdev->blink_delay_on = state;
2731 ret = count;
2732 }
2733
2734 @@ -69,6 +70,7 @@ static ssize_t led_delay_off_store(struct device *dev,
2735
2736 if (count == size) {
2737 led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
2738 + led_cdev->blink_delay_off = state;
2739 ret = count;
2740 }
2741
2742 diff --git a/drivers/md/linear.h b/drivers/md/linear.h
2743 index 0ce29b6..2f2da05 100644
2744 --- a/drivers/md/linear.h
2745 +++ b/drivers/md/linear.h
2746 @@ -10,9 +10,9 @@ typedef struct dev_info dev_info_t;
2747
2748 struct linear_private_data
2749 {
2750 + struct rcu_head rcu;
2751 sector_t array_sectors;
2752 dev_info_t disks[0];
2753 - struct rcu_head rcu;
2754 };
2755
2756
2757 diff --git a/drivers/md/md.c b/drivers/md/md.c
2758 index 91e31e2..8554082 100644
2759 --- a/drivers/md/md.c
2760 +++ b/drivers/md/md.c
2761 @@ -1084,8 +1084,11 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
2762 ret = 0;
2763 }
2764 rdev->sectors = rdev->sb_start;
2765 + /* Limit to 4TB as metadata cannot record more than that */
2766 + if (rdev->sectors >= (2ULL << 32))
2767 + rdev->sectors = (2ULL << 32) - 2;
2768
2769 - if (rdev->sectors < sb->size * 2 && sb->level > 1)
2770 + if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1)
2771 /* "this cannot possibly happen" ... */
2772 ret = -EINVAL;
2773
2774 @@ -1119,7 +1122,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
2775 mddev->clevel[0] = 0;
2776 mddev->layout = sb->layout;
2777 mddev->raid_disks = sb->raid_disks;
2778 - mddev->dev_sectors = sb->size * 2;
2779 + mddev->dev_sectors = ((sector_t)sb->size) * 2;
2780 mddev->events = ev1;
2781 mddev->bitmap_info.offset = 0;
2782 mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9;
2783 @@ -1361,6 +1364,11 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
2784 rdev->sb_start = calc_dev_sboffset(rdev);
2785 if (!num_sectors || num_sectors > rdev->sb_start)
2786 num_sectors = rdev->sb_start;
2787 + /* Limit to 4TB as metadata cannot record more than that.
2788 + * 4TB == 2^32 KB, or 2*2^32 sectors.
2789 + */
2790 + if (num_sectors >= (2ULL << 32))
2791 + num_sectors = (2ULL << 32) - 2;
2792 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
2793 rdev->sb_page);
2794 md_super_wait(rdev->mddev);
2795 diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
2796 index 3db89e3..536c16c 100644
2797 --- a/drivers/media/dvb/dvb-usb/vp7045.c
2798 +++ b/drivers/media/dvb/dvb-usb/vp7045.c
2799 @@ -224,26 +224,8 @@ static struct dvb_usb_device_properties vp7045_properties;
2800 static int vp7045_usb_probe(struct usb_interface *intf,
2801 const struct usb_device_id *id)
2802 {
2803 - struct dvb_usb_device *d;
2804 - int ret = dvb_usb_device_init(intf, &vp7045_properties,
2805 - THIS_MODULE, &d, adapter_nr);
2806 - if (ret)
2807 - return ret;
2808 -
2809 - d->priv = kmalloc(20, GFP_KERNEL);
2810 - if (!d->priv) {
2811 - dvb_usb_device_exit(intf);
2812 - return -ENOMEM;
2813 - }
2814 -
2815 - return ret;
2816 -}
2817 -
2818 -static void vp7045_usb_disconnect(struct usb_interface *intf)
2819 -{
2820 - struct dvb_usb_device *d = usb_get_intfdata(intf);
2821 - kfree(d->priv);
2822 - dvb_usb_device_exit(intf);
2823 + return dvb_usb_device_init(intf, &vp7045_properties,
2824 + THIS_MODULE, NULL, adapter_nr);
2825 }
2826
2827 static struct usb_device_id vp7045_usb_table [] = {
2828 @@ -258,7 +240,7 @@ MODULE_DEVICE_TABLE(usb, vp7045_usb_table);
2829 static struct dvb_usb_device_properties vp7045_properties = {
2830 .usb_ctrl = CYPRESS_FX2,
2831 .firmware = "dvb-usb-vp7045-01.fw",
2832 - .size_of_priv = sizeof(u8 *),
2833 + .size_of_priv = 20,
2834
2835 .num_adapters = 1,
2836 .adapter = {
2837 @@ -305,7 +287,7 @@ static struct dvb_usb_device_properties vp7045_properties = {
2838 static struct usb_driver vp7045_usb_driver = {
2839 .name = "dvb_usb_vp7045",
2840 .probe = vp7045_usb_probe,
2841 - .disconnect = vp7045_usb_disconnect,
2842 + .disconnect = dvb_usb_device_exit,
2843 .id_table = vp7045_usb_table,
2844 };
2845
2846 diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
2847 index ce595f9..9fd019e 100644
2848 --- a/drivers/media/rc/nuvoton-cir.c
2849 +++ b/drivers/media/rc/nuvoton-cir.c
2850 @@ -624,7 +624,6 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt)
2851 static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
2852 {
2853 DEFINE_IR_RAW_EVENT(rawir);
2854 - unsigned int count;
2855 u32 carrier;
2856 u8 sample;
2857 int i;
2858 @@ -637,65 +636,38 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
2859 if (nvt->carrier_detect_enabled)
2860 carrier = nvt_rx_carrier_detect(nvt);
2861
2862 - count = nvt->pkts;
2863 - nvt_dbg_verbose("Processing buffer of len %d", count);
2864 + nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts);
2865
2866 init_ir_raw_event(&rawir);
2867
2868 - for (i = 0; i < count; i++) {
2869 - nvt->pkts--;
2870 + for (i = 0; i < nvt->pkts; i++) {
2871 sample = nvt->buf[i];
2872
2873 rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
2874 rawir.duration = US_TO_NS((sample & BUF_LEN_MASK)
2875 * SAMPLE_PERIOD);
2876
2877 - if ((sample & BUF_LEN_MASK) == BUF_LEN_MASK) {
2878 - if (nvt->rawir.pulse == rawir.pulse)
2879 - nvt->rawir.duration += rawir.duration;
2880 - else {
2881 - nvt->rawir.duration = rawir.duration;
2882 - nvt->rawir.pulse = rawir.pulse;
2883 - }
2884 - continue;
2885 - }
2886 -
2887 - rawir.duration += nvt->rawir.duration;
2888 + nvt_dbg("Storing %s with duration %d",
2889 + rawir.pulse ? "pulse" : "space", rawir.duration);
2890
2891 - init_ir_raw_event(&nvt->rawir);
2892 - nvt->rawir.duration = 0;
2893 - nvt->rawir.pulse = rawir.pulse;
2894 -
2895 - if (sample == BUF_PULSE_BIT)
2896 - rawir.pulse = false;
2897 -
2898 - if (rawir.duration) {
2899 - nvt_dbg("Storing %s with duration %d",
2900 - rawir.pulse ? "pulse" : "space",
2901 - rawir.duration);
2902 -
2903 - ir_raw_event_store_with_filter(nvt->rdev, &rawir);
2904 - }
2905 + ir_raw_event_store_with_filter(nvt->rdev, &rawir);
2906
2907 /*
2908 * BUF_PULSE_BIT indicates end of IR data, BUF_REPEAT_BYTE
2909 * indicates end of IR signal, but new data incoming. In both
2910 * cases, it means we're ready to call ir_raw_event_handle
2911 */
2912 - if ((sample == BUF_PULSE_BIT) && nvt->pkts) {
2913 + if ((sample == BUF_PULSE_BIT) && (i + 1 < nvt->pkts)) {
2914 nvt_dbg("Calling ir_raw_event_handle (signal end)\n");
2915 ir_raw_event_handle(nvt->rdev);
2916 }
2917 }
2918
2919 + nvt->pkts = 0;
2920 +
2921 nvt_dbg("Calling ir_raw_event_handle (buffer empty)\n");
2922 ir_raw_event_handle(nvt->rdev);
2923
2924 - if (nvt->pkts) {
2925 - nvt_dbg("Odd, pkts should be 0 now... (its %u)", nvt->pkts);
2926 - nvt->pkts = 0;
2927 - }
2928 -
2929 nvt_dbg_verbose("%s done", __func__);
2930 }
2931
2932 @@ -1054,7 +1026,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
2933
2934 spin_lock_init(&nvt->nvt_lock);
2935 spin_lock_init(&nvt->tx.lock);
2936 - init_ir_raw_event(&nvt->rawir);
2937
2938 ret = -EBUSY;
2939 /* now claim resources */
2940 diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
2941 index 1241fc8..0d5e087 100644
2942 --- a/drivers/media/rc/nuvoton-cir.h
2943 +++ b/drivers/media/rc/nuvoton-cir.h
2944 @@ -67,7 +67,6 @@ static int debug;
2945 struct nvt_dev {
2946 struct pnp_dev *pdev;
2947 struct rc_dev *rdev;
2948 - struct ir_raw_event rawir;
2949
2950 spinlock_t nvt_lock;
2951
2952 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
2953 index 1717144..e67c3d3 100644
2954 --- a/drivers/mfd/omap-usb-host.c
2955 +++ b/drivers/mfd/omap-usb-host.c
2956 @@ -676,7 +676,6 @@ static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count)
2957 | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
2958 | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
2959
2960 - reg |= (1 << (i + 1));
2961 } else
2962 continue;
2963
2964 diff --git a/drivers/mfd/tps65910-irq.c b/drivers/mfd/tps65910-irq.c
2965 index 2bfad5c..a56be93 100644
2966 --- a/drivers/mfd/tps65910-irq.c
2967 +++ b/drivers/mfd/tps65910-irq.c
2968 @@ -178,8 +178,10 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq,
2969 switch (tps65910_chip_id(tps65910)) {
2970 case TPS65910:
2971 tps65910->irq_num = TPS65910_NUM_IRQ;
2972 + break;
2973 case TPS65911:
2974 tps65910->irq_num = TPS65911_NUM_IRQ;
2975 + break;
2976 }
2977
2978 /* Register with genirq */
2979 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
2980 index 7843efe..38089b2 100644
2981 --- a/drivers/mmc/core/core.c
2982 +++ b/drivers/mmc/core/core.c
2983 @@ -132,7 +132,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
2984 if (mrq->done)
2985 mrq->done(mrq);
2986
2987 - mmc_host_clk_gate(host);
2988 + mmc_host_clk_release(host);
2989 }
2990 }
2991
2992 @@ -191,7 +191,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
2993 mrq->stop->mrq = mrq;
2994 }
2995 }
2996 - mmc_host_clk_ungate(host);
2997 + mmc_host_clk_hold(host);
2998 led_trigger_event(host->led, LED_FULL);
2999 host->ops->request(host, mrq);
3000 }
3001 @@ -634,15 +634,17 @@ static inline void mmc_set_ios(struct mmc_host *host)
3002 */
3003 void mmc_set_chip_select(struct mmc_host *host, int mode)
3004 {
3005 + mmc_host_clk_hold(host);
3006 host->ios.chip_select = mode;
3007 mmc_set_ios(host);
3008 + mmc_host_clk_release(host);
3009 }
3010
3011 /*
3012 * Sets the host clock to the highest possible frequency that
3013 * is below "hz".
3014 */
3015 -void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3016 +static void __mmc_set_clock(struct mmc_host *host, unsigned int hz)
3017 {
3018 WARN_ON(hz < host->f_min);
3019
3020 @@ -653,6 +655,13 @@ void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3021 mmc_set_ios(host);
3022 }
3023
3024 +void mmc_set_clock(struct mmc_host *host, unsigned int hz)
3025 +{
3026 + mmc_host_clk_hold(host);
3027 + __mmc_set_clock(host, hz);
3028 + mmc_host_clk_release(host);
3029 +}
3030 +
3031 #ifdef CONFIG_MMC_CLKGATE
3032 /*
3033 * This gates the clock by setting it to 0 Hz.
3034 @@ -685,7 +694,7 @@ void mmc_ungate_clock(struct mmc_host *host)
3035 if (host->clk_old) {
3036 BUG_ON(host->ios.clock);
3037 /* This call will also set host->clk_gated to false */
3038 - mmc_set_clock(host, host->clk_old);
3039 + __mmc_set_clock(host, host->clk_old);
3040 }
3041 }
3042
3043 @@ -713,8 +722,10 @@ void mmc_set_ungated(struct mmc_host *host)
3044 */
3045 void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
3046 {
3047 + mmc_host_clk_hold(host);
3048 host->ios.bus_mode = mode;
3049 mmc_set_ios(host);
3050 + mmc_host_clk_release(host);
3051 }
3052
3053 /*
3054 @@ -722,8 +733,10 @@ void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
3055 */
3056 void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
3057 {
3058 + mmc_host_clk_hold(host);
3059 host->ios.bus_width = width;
3060 mmc_set_ios(host);
3061 + mmc_host_clk_release(host);
3062 }
3063
3064 /**
3065 @@ -921,8 +934,10 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
3066
3067 ocr &= 3 << bit;
3068
3069 + mmc_host_clk_hold(host);
3070 host->ios.vdd = bit;
3071 mmc_set_ios(host);
3072 + mmc_host_clk_release(host);
3073 } else {
3074 pr_warning("%s: host doesn't support card's voltages\n",
3075 mmc_hostname(host));
3076 @@ -969,8 +984,10 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11
3077 */
3078 void mmc_set_timing(struct mmc_host *host, unsigned int timing)
3079 {
3080 + mmc_host_clk_hold(host);
3081 host->ios.timing = timing;
3082 mmc_set_ios(host);
3083 + mmc_host_clk_release(host);
3084 }
3085
3086 /*
3087 @@ -978,8 +995,10 @@ void mmc_set_timing(struct mmc_host *host, unsigned int timing)
3088 */
3089 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)
3090 {
3091 + mmc_host_clk_hold(host);
3092 host->ios.drv_type = drv_type;
3093 mmc_set_ios(host);
3094 + mmc_host_clk_release(host);
3095 }
3096
3097 /*
3098 @@ -997,6 +1016,8 @@ static void mmc_power_up(struct mmc_host *host)
3099 {
3100 int bit;
3101
3102 + mmc_host_clk_hold(host);
3103 +
3104 /* If ocr is set, we use it */
3105 if (host->ocr)
3106 bit = ffs(host->ocr) - 1;
3107 @@ -1032,10 +1053,14 @@ static void mmc_power_up(struct mmc_host *host)
3108 * time required to reach a stable voltage.
3109 */
3110 mmc_delay(10);
3111 +
3112 + mmc_host_clk_release(host);
3113 }
3114
3115 static void mmc_power_off(struct mmc_host *host)
3116 {
3117 + mmc_host_clk_hold(host);
3118 +
3119 host->ios.clock = 0;
3120 host->ios.vdd = 0;
3121
3122 @@ -1053,6 +1078,8 @@ static void mmc_power_off(struct mmc_host *host)
3123 host->ios.bus_width = MMC_BUS_WIDTH_1;
3124 host->ios.timing = MMC_TIMING_LEGACY;
3125 mmc_set_ios(host);
3126 +
3127 + mmc_host_clk_release(host);
3128 }
3129
3130 /*
3131 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
3132 index b29d3e8..793d0a0 100644
3133 --- a/drivers/mmc/core/host.c
3134 +++ b/drivers/mmc/core/host.c
3135 @@ -119,14 +119,14 @@ static void mmc_host_clk_gate_work(struct work_struct *work)
3136 }
3137
3138 /**
3139 - * mmc_host_clk_ungate - ungate hardware MCI clocks
3140 + * mmc_host_clk_hold - ungate hardware MCI clocks
3141 * @host: host to ungate.
3142 *
3143 * Makes sure the host ios.clock is restored to a non-zero value
3144 * past this call. Increase clock reference count and ungate clock
3145 * if we're the first user.
3146 */
3147 -void mmc_host_clk_ungate(struct mmc_host *host)
3148 +void mmc_host_clk_hold(struct mmc_host *host)
3149 {
3150 unsigned long flags;
3151
3152 @@ -164,14 +164,14 @@ static bool mmc_host_may_gate_card(struct mmc_card *card)
3153 }
3154
3155 /**
3156 - * mmc_host_clk_gate - gate off hardware MCI clocks
3157 + * mmc_host_clk_release - gate off hardware MCI clocks
3158 * @host: host to gate.
3159 *
3160 * Calls the host driver with ios.clock set to zero as often as possible
3161 * in order to gate off hardware MCI clocks. Decrease clock reference
3162 * count and schedule disabling of clock.
3163 */
3164 -void mmc_host_clk_gate(struct mmc_host *host)
3165 +void mmc_host_clk_release(struct mmc_host *host)
3166 {
3167 unsigned long flags;
3168
3169 @@ -179,7 +179,7 @@ void mmc_host_clk_gate(struct mmc_host *host)
3170 host->clk_requests--;
3171 if (mmc_host_may_gate_card(host->card) &&
3172 !host->clk_requests)
3173 - schedule_work(&host->clk_gate_work);
3174 + queue_work(system_nrt_wq, &host->clk_gate_work);
3175 spin_unlock_irqrestore(&host->clk_lock, flags);
3176 }
3177
3178 @@ -231,7 +231,7 @@ static inline void mmc_host_clk_exit(struct mmc_host *host)
3179 if (cancel_work_sync(&host->clk_gate_work))
3180 mmc_host_clk_gate_delayed(host);
3181 if (host->clk_gated)
3182 - mmc_host_clk_ungate(host);
3183 + mmc_host_clk_hold(host);
3184 /* There should be only one user now */
3185 WARN_ON(host->clk_requests > 1);
3186 }
3187 diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h
3188 index de199f9..fb8a5cd 100644
3189 --- a/drivers/mmc/core/host.h
3190 +++ b/drivers/mmc/core/host.h
3191 @@ -16,16 +16,16 @@ int mmc_register_host_class(void);
3192 void mmc_unregister_host_class(void);
3193
3194 #ifdef CONFIG_MMC_CLKGATE
3195 -void mmc_host_clk_ungate(struct mmc_host *host);
3196 -void mmc_host_clk_gate(struct mmc_host *host);
3197 +void mmc_host_clk_hold(struct mmc_host *host);
3198 +void mmc_host_clk_release(struct mmc_host *host);
3199 unsigned int mmc_host_clk_rate(struct mmc_host *host);
3200
3201 #else
3202 -static inline void mmc_host_clk_ungate(struct mmc_host *host)
3203 +static inline void mmc_host_clk_hold(struct mmc_host *host)
3204 {
3205 }
3206
3207 -static inline void mmc_host_clk_gate(struct mmc_host *host)
3208 +static inline void mmc_host_clk_release(struct mmc_host *host)
3209 {
3210 }
3211
3212 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
3213 index 69e3ee3..8cd999f 100644
3214 --- a/drivers/mmc/host/sdhci-s3c.c
3215 +++ b/drivers/mmc/host/sdhci-s3c.c
3216 @@ -301,6 +301,8 @@ static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width)
3217 ctrl &= ~SDHCI_CTRL_8BITBUS;
3218 break;
3219 default:
3220 + ctrl &= ~SDHCI_CTRL_4BITBUS;
3221 + ctrl &= ~SDHCI_CTRL_8BITBUS;
3222 break;
3223 }
3224
3225 diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
3226 index 57d3293..74580bb 100644
3227 --- a/drivers/net/bnx2.c
3228 +++ b/drivers/net/bnx2.c
3229 @@ -416,6 +416,9 @@ struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)
3230 struct bnx2 *bp = netdev_priv(dev);
3231 struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
3232
3233 + if (!cp->max_iscsi_conn)
3234 + return NULL;
3235 +
3236 cp->drv_owner = THIS_MODULE;
3237 cp->chip_id = bp->chip_id;
3238 cp->pdev = bp->pdev;
3239 @@ -8177,6 +8180,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
3240 bp->timer.data = (unsigned long) bp;
3241 bp->timer.function = bnx2_timer;
3242
3243 +#ifdef BCM_CNIC
3244 + bp->cnic_eth_dev.max_iscsi_conn =
3245 + bnx2_reg_rd_ind(bp, BNX2_FW_MAX_ISCSI_CONN);
3246 +#endif
3247 pci_save_state(pdev);
3248
3249 return 0;
3250 diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c
3251 index 410a49e..d11af7c 100644
3252 --- a/drivers/net/bnx2x/bnx2x_dcb.c
3253 +++ b/drivers/net/bnx2x/bnx2x_dcb.c
3254 @@ -1858,6 +1858,7 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
3255 break;
3256 case DCB_CAP_ATTR_DCBX:
3257 *cap = BNX2X_DCBX_CAPS;
3258 + break;
3259 default:
3260 rval = -EINVAL;
3261 break;
3262 diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
3263 index 74be989..04976db 100644
3264 --- a/drivers/net/bnx2x/bnx2x_main.c
3265 +++ b/drivers/net/bnx2x/bnx2x_main.c
3266 @@ -4138,7 +4138,7 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3267 int igu_seg_id;
3268 int port = BP_PORT(bp);
3269 int func = BP_FUNC(bp);
3270 - int reg_offset;
3271 + int reg_offset, reg_offset_en5;
3272 u64 section;
3273 int index;
3274 struct hc_sp_status_block_data sp_sb_data;
3275 @@ -4161,6 +4161,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3276
3277 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
3278 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
3279 + reg_offset_en5 = (port ? MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 :
3280 + MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0);
3281 for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) {
3282 int sindex;
3283 /* take care of sig[0]..sig[4] */
3284 @@ -4175,7 +4177,7 @@ static void bnx2x_init_def_sb(struct bnx2x *bp)
3285 * and not 16 between the different groups
3286 */
3287 bp->attn_group[index].sig[4] = REG_RD(bp,
3288 - reg_offset + 0x10 + 0x4*index);
3289 + reg_offset_en5 + 0x4*index);
3290 else
3291 bp->attn_group[index].sig[4] = 0;
3292 }
3293 diff --git a/drivers/net/bnx2x/bnx2x_reg.h b/drivers/net/bnx2x/bnx2x_reg.h
3294 index 86bba25..0380b3a 100644
3295 --- a/drivers/net/bnx2x/bnx2x_reg.h
3296 +++ b/drivers/net/bnx2x/bnx2x_reg.h
3297 @@ -1325,6 +1325,18 @@
3298 Latched ump_tx_parity; [31] MCP Latched scpad_parity; */
3299 #define MISC_REG_AEU_ENABLE4_PXP_0 0xa108
3300 #define MISC_REG_AEU_ENABLE4_PXP_1 0xa1a8
3301 +/* [RW 32] fifth 32b for enabling the output for function 0 output0. Mapped
3302 + * as follows: [0] PGLUE config_space; [1] PGLUE misc_flr; [2] PGLUE B RBC
3303 + * attention [3] PGLUE B RBC parity; [4] ATC attention; [5] ATC parity; [6]
3304 + * mstat0 attention; [7] mstat0 parity; [8] mstat1 attention; [9] mstat1
3305 + * parity; [31-10] Reserved; */
3306 +#define MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0 0xa688
3307 +/* [RW 32] Fifth 32b for enabling the output for function 1 output0. Mapped
3308 + * as follows: [0] PGLUE config_space; [1] PGLUE misc_flr; [2] PGLUE B RBC
3309 + * attention [3] PGLUE B RBC parity; [4] ATC attention; [5] ATC parity; [6]
3310 + * mstat0 attention; [7] mstat0 parity; [8] mstat1 attention; [9] mstat1
3311 + * parity; [31-10] Reserved; */
3312 +#define MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 0xa6b0
3313 /* [RW 1] set/clr general attention 0; this will set/clr bit 94 in the aeu
3314 128 bit vector */
3315 #define MISC_REG_AEU_GENERAL_ATTN_0 0xa000
3316 diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
3317 index 11a92af..363c7f3 100644
3318 --- a/drivers/net/cnic.c
3319 +++ b/drivers/net/cnic.c
3320 @@ -605,11 +605,12 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
3321 }
3322 EXPORT_SYMBOL(cnic_unregister_driver);
3323
3324 -static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id)
3325 +static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id,
3326 + u32 next)
3327 {
3328 id_tbl->start = start_id;
3329 id_tbl->max = size;
3330 - id_tbl->next = 0;
3331 + id_tbl->next = next;
3332 spin_lock_init(&id_tbl->lock);
3333 id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
3334 if (!id_tbl->table)
3335 @@ -2778,13 +2779,10 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)
3336
3337 /* Tell compiler that status_blk fields can change. */
3338 barrier();
3339 - if (status_idx != *cp->kcq1.status_idx_ptr) {
3340 - status_idx = (u16) *cp->kcq1.status_idx_ptr;
3341 - /* status block index must be read first */
3342 - rmb();
3343 - cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
3344 - } else
3345 - break;
3346 + status_idx = (u16) *cp->kcq1.status_idx_ptr;
3347 + /* status block index must be read first */
3348 + rmb();
3349 + cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
3350 }
3351
3352 CNIC_WR16(dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);
3353 @@ -2908,8 +2906,6 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info)
3354
3355 /* Tell compiler that sblk fields can change. */
3356 barrier();
3357 - if (last_status == *info->status_idx_ptr)
3358 - break;
3359
3360 last_status = *info->status_idx_ptr;
3361 /* status block index must be read before reading the KCQ */
3362 @@ -3772,7 +3768,13 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
3363 break;
3364
3365 case L4_KCQE_OPCODE_VALUE_CLOSE_RECEIVED:
3366 - cnic_cm_upcall(cp, csk, opcode);
3367 + /* after we already sent CLOSE_REQ */
3368 + if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags) &&
3369 + !test_bit(SK_F_OFFLD_COMPLETE, &csk->flags) &&
3370 + csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)
3371 + cp->close_conn(csk, L4_KCQE_OPCODE_VALUE_RESET_COMP);
3372 + else
3373 + cnic_cm_upcall(cp, csk, opcode);
3374 break;
3375 }
3376 csk_put(csk);
3377 @@ -3803,14 +3805,17 @@ static void cnic_cm_free_mem(struct cnic_dev *dev)
3378 static int cnic_cm_alloc_mem(struct cnic_dev *dev)
3379 {
3380 struct cnic_local *cp = dev->cnic_priv;
3381 + u32 port_id;
3382
3383 cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ,
3384 GFP_KERNEL);
3385 if (!cp->csk_tbl)
3386 return -ENOMEM;
3387
3388 + get_random_bytes(&port_id, sizeof(port_id));
3389 + port_id %= CNIC_LOCAL_PORT_RANGE;
3390 if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
3391 - CNIC_LOCAL_PORT_MIN)) {
3392 + CNIC_LOCAL_PORT_MIN, port_id)) {
3393 cnic_cm_free_mem(dev);
3394 return -ENOMEM;
3395 }
3396 @@ -3826,12 +3831,14 @@ static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode)
3397 }
3398
3399 /* 1. If event opcode matches the expected event in csk->state
3400 - * 2. If the expected event is CLOSE_COMP, we accept any event
3401 + * 2. If the expected event is CLOSE_COMP or RESET_COMP, we accept any
3402 + * event
3403 * 3. If the expected event is 0, meaning the connection was never
3404 * never established, we accept the opcode from cm_abort.
3405 */
3406 if (opcode == csk->state || csk->state == 0 ||
3407 - csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
3408 + csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP ||
3409 + csk->state == L4_KCQE_OPCODE_VALUE_RESET_COMP) {
3410 if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) {
3411 if (csk->state == 0)
3412 csk->state = opcode;
3413 @@ -4218,14 +4225,6 @@ static void cnic_enable_bnx2_int(struct cnic_dev *dev)
3414 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx);
3415 }
3416
3417 -static void cnic_get_bnx2_iscsi_info(struct cnic_dev *dev)
3418 -{
3419 - u32 max_conn;
3420 -
3421 - max_conn = cnic_reg_rd_ind(dev, BNX2_FW_MAX_ISCSI_CONN);
3422 - dev->max_iscsi_conn = max_conn;
3423 -}
3424 -
3425 static void cnic_disable_bnx2_int_sync(struct cnic_dev *dev)
3426 {
3427 struct cnic_local *cp = dev->cnic_priv;
3428 @@ -4550,8 +4549,6 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)
3429 return err;
3430 }
3431
3432 - cnic_get_bnx2_iscsi_info(dev);
3433 -
3434 return 0;
3435 }
3436
3437 @@ -4826,7 +4823,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)
3438 pfid = cp->pfid;
3439
3440 ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ,
3441 - cp->iscsi_start_cid);
3442 + cp->iscsi_start_cid, 0);
3443
3444 if (ret)
3445 return -ENOMEM;
3446 @@ -4834,7 +4831,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)
3447 if (BNX2X_CHIP_IS_E2(cp->chip_id)) {
3448 ret = cnic_init_id_tbl(&cp->fcoe_cid_tbl,
3449 BNX2X_FCOE_NUM_CONNECTIONS,
3450 - cp->fcoe_start_cid);
3451 + cp->fcoe_start_cid, 0);
3452
3453 if (ret)
3454 return -ENOMEM;
3455 @@ -5217,6 +5214,8 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev)
3456 cdev->pcidev = pdev;
3457 cp->chip_id = ethdev->chip_id;
3458
3459 + cdev->max_iscsi_conn = ethdev->max_iscsi_conn;
3460 +
3461 cp->cnic_ops = &cnic_bnx2_ops;
3462 cp->start_hw = cnic_start_bnx2_hw;
3463 cp->stop_hw = cnic_stop_bnx2_hw;
3464 @@ -5335,7 +5334,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
3465
3466 dev = cnic_from_netdev(netdev);
3467
3468 - if (!dev && (event == NETDEV_REGISTER || event == NETDEV_UP)) {
3469 + if (!dev && (event == NETDEV_REGISTER || netif_running(netdev))) {
3470 /* Check for the hot-plug device */
3471 dev = is_cnic_dev(netdev);
3472 if (dev) {
3473 @@ -5351,7 +5350,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
3474 else if (event == NETDEV_UNREGISTER)
3475 cnic_ulp_exit(dev);
3476
3477 - if (event == NETDEV_UP) {
3478 + if (event == NETDEV_UP || (new_dev && netif_running(netdev))) {
3479 if (cnic_register_netdev(dev) != 0) {
3480 cnic_put(dev);
3481 goto done;
3482 diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
3483 index 862804f..3f2e12c 100644
3484 --- a/drivers/net/cxgb3/cxgb3_offload.c
3485 +++ b/drivers/net/cxgb3/cxgb3_offload.c
3486 @@ -1149,12 +1149,14 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
3487 if (te && te->ctx && te->client && te->client->redirect) {
3488 update_tcb = te->client->redirect(te->ctx, old, new, e);
3489 if (update_tcb) {
3490 + rcu_read_lock();
3491 l2t_hold(L2DATA(tdev), e);
3492 + rcu_read_unlock();
3493 set_l2t_ix(tdev, tid, e);
3494 }
3495 }
3496 }
3497 - l2t_release(L2DATA(tdev), e);
3498 + l2t_release(tdev, e);
3499 }
3500
3501 /*
3502 @@ -1267,7 +1269,7 @@ int cxgb3_offload_activate(struct adapter *adapter)
3503 goto out_free;
3504
3505 err = -ENOMEM;
3506 - L2DATA(dev) = t3_init_l2t(l2t_capacity);
3507 + RCU_INIT_POINTER(dev->l2opt, t3_init_l2t(l2t_capacity));
3508 if (!L2DATA(dev))
3509 goto out_free;
3510
3511 @@ -1301,16 +1303,24 @@ int cxgb3_offload_activate(struct adapter *adapter)
3512
3513 out_free_l2t:
3514 t3_free_l2t(L2DATA(dev));
3515 - L2DATA(dev) = NULL;
3516 + rcu_assign_pointer(dev->l2opt, NULL);
3517 out_free:
3518 kfree(t);
3519 return err;
3520 }
3521
3522 +static void clean_l2_data(struct rcu_head *head)
3523 +{
3524 + struct l2t_data *d = container_of(head, struct l2t_data, rcu_head);
3525 + t3_free_l2t(d);
3526 +}
3527 +
3528 +
3529 void cxgb3_offload_deactivate(struct adapter *adapter)
3530 {
3531 struct t3cdev *tdev = &adapter->tdev;
3532 struct t3c_data *t = T3C_DATA(tdev);
3533 + struct l2t_data *d;
3534
3535 remove_adapter(adapter);
3536 if (list_empty(&adapter_list))
3537 @@ -1318,8 +1328,11 @@ void cxgb3_offload_deactivate(struct adapter *adapter)
3538
3539 free_tid_maps(&t->tid_maps);
3540 T3C_DATA(tdev) = NULL;
3541 - t3_free_l2t(L2DATA(tdev));
3542 - L2DATA(tdev) = NULL;
3543 + rcu_read_lock();
3544 + d = L2DATA(tdev);
3545 + rcu_read_unlock();
3546 + rcu_assign_pointer(tdev->l2opt, NULL);
3547 + call_rcu(&d->rcu_head, clean_l2_data);
3548 if (t->nofail_skb)
3549 kfree_skb(t->nofail_skb);
3550 kfree(t);
3551 diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
3552 index f452c40..4154097 100644
3553 --- a/drivers/net/cxgb3/l2t.c
3554 +++ b/drivers/net/cxgb3/l2t.c
3555 @@ -300,14 +300,21 @@ static inline void reuse_entry(struct l2t_entry *e, struct neighbour *neigh)
3556 struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
3557 struct net_device *dev)
3558 {
3559 - struct l2t_entry *e;
3560 - struct l2t_data *d = L2DATA(cdev);
3561 + struct l2t_entry *e = NULL;
3562 + struct l2t_data *d;
3563 + int hash;
3564 u32 addr = *(u32 *) neigh->primary_key;
3565 int ifidx = neigh->dev->ifindex;
3566 - int hash = arp_hash(addr, ifidx, d);
3567 struct port_info *p = netdev_priv(dev);
3568 int smt_idx = p->port_id;
3569
3570 + rcu_read_lock();
3571 + d = L2DATA(cdev);
3572 + if (!d)
3573 + goto done_rcu;
3574 +
3575 + hash = arp_hash(addr, ifidx, d);
3576 +
3577 write_lock_bh(&d->lock);
3578 for (e = d->l2tab[hash].first; e; e = e->next)
3579 if (e->addr == addr && e->ifindex == ifidx &&
3580 @@ -338,6 +345,8 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
3581 }
3582 done:
3583 write_unlock_bh(&d->lock);
3584 +done_rcu:
3585 + rcu_read_unlock();
3586 return e;
3587 }
3588
3589 diff --git a/drivers/net/cxgb3/l2t.h b/drivers/net/cxgb3/l2t.h
3590 index fd3eb07..c4dd066 100644
3591 --- a/drivers/net/cxgb3/l2t.h
3592 +++ b/drivers/net/cxgb3/l2t.h
3593 @@ -76,6 +76,7 @@ struct l2t_data {
3594 atomic_t nfree; /* number of free entries */
3595 rwlock_t lock;
3596 struct l2t_entry l2tab[0];
3597 + struct rcu_head rcu_head; /* to handle rcu cleanup */
3598 };
3599
3600 typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
3601 @@ -99,7 +100,7 @@ static inline void set_arp_failure_handler(struct sk_buff *skb,
3602 /*
3603 * Getting to the L2 data from an offload device.
3604 */
3605 -#define L2DATA(dev) ((dev)->l2opt)
3606 +#define L2DATA(cdev) (rcu_dereference((cdev)->l2opt))
3607
3608 #define W_TCB_L2T_IX 0
3609 #define S_TCB_L2T_IX 7
3610 @@ -126,15 +127,22 @@ static inline int l2t_send(struct t3cdev *dev, struct sk_buff *skb,
3611 return t3_l2t_send_slow(dev, skb, e);
3612 }
3613
3614 -static inline void l2t_release(struct l2t_data *d, struct l2t_entry *e)
3615 +static inline void l2t_release(struct t3cdev *t, struct l2t_entry *e)
3616 {
3617 - if (atomic_dec_and_test(&e->refcnt))
3618 + struct l2t_data *d;
3619 +
3620 + rcu_read_lock();
3621 + d = L2DATA(t);
3622 +
3623 + if (atomic_dec_and_test(&e->refcnt) && d)
3624 t3_l2e_free(d, e);
3625 +
3626 + rcu_read_unlock();
3627 }
3628
3629 static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e)
3630 {
3631 - if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
3632 + if (d && atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
3633 atomic_dec(&d->nfree);
3634 }
3635
3636 diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
3637 index 7501d97..f17aaa1 100644
3638 --- a/drivers/net/e1000/e1000_hw.c
3639 +++ b/drivers/net/e1000/e1000_hw.c
3640 @@ -4028,6 +4028,12 @@ s32 e1000_validate_eeprom_checksum(struct e1000_hw *hw)
3641 checksum += eeprom_data;
3642 }
3643
3644 +#ifdef CONFIG_PARISC
3645 + /* This is a signature and not a checksum on HP c8000 */
3646 + if ((hw->subsystem_vendor_id == 0x103C) && (eeprom_data == 0x16d6))
3647 + return E1000_SUCCESS;
3648 +
3649 +#endif
3650 if (checksum == (u16) EEPROM_SUM)
3651 return E1000_SUCCESS;
3652 else {
3653 diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
3654 index b388d78..145c924 100644
3655 --- a/drivers/net/ibmveth.c
3656 +++ b/drivers/net/ibmveth.c
3657 @@ -394,7 +394,7 @@ static inline struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *ada
3658 }
3659
3660 /* recycle the current buffer on the rx queue */
3661 -static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3662 +static int ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3663 {
3664 u32 q_index = adapter->rx_queue.index;
3665 u64 correlator = adapter->rx_queue.queue_addr[q_index].correlator;
3666 @@ -402,6 +402,7 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3667 unsigned int index = correlator & 0xffffffffUL;
3668 union ibmveth_buf_desc desc;
3669 unsigned long lpar_rc;
3670 + int ret = 1;
3671
3672 BUG_ON(pool >= IBMVETH_NUM_BUFF_POOLS);
3673 BUG_ON(index >= adapter->rx_buff_pool[pool].size);
3674 @@ -409,7 +410,7 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3675 if (!adapter->rx_buff_pool[pool].active) {
3676 ibmveth_rxq_harvest_buffer(adapter);
3677 ibmveth_free_buffer_pool(adapter, &adapter->rx_buff_pool[pool]);
3678 - return;
3679 + goto out;
3680 }
3681
3682 desc.fields.flags_len = IBMVETH_BUF_VALID |
3683 @@ -422,12 +423,16 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
3684 netdev_dbg(adapter->netdev, "h_add_logical_lan_buffer failed "
3685 "during recycle rc=%ld", lpar_rc);
3686 ibmveth_remove_buffer_from_pool(adapter, adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator);
3687 + ret = 0;
3688 }
3689
3690 if (++adapter->rx_queue.index == adapter->rx_queue.num_slots) {
3691 adapter->rx_queue.index = 0;
3692 adapter->rx_queue.toggle = !adapter->rx_queue.toggle;
3693 }
3694 +
3695 +out:
3696 + return ret;
3697 }
3698
3699 static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter)
3700 @@ -806,7 +811,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
3701 } else
3702 adapter->fw_ipv6_csum_support = data;
3703
3704 - if (ret != H_SUCCESS || ret6 != H_SUCCESS)
3705 + if (ret == H_SUCCESS || ret6 == H_SUCCESS)
3706 adapter->rx_csum = data;
3707 else
3708 rc1 = -EIO;
3709 @@ -924,6 +929,7 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
3710 union ibmveth_buf_desc descs[6];
3711 int last, i;
3712 int force_bounce = 0;
3713 + dma_addr_t dma_addr;
3714
3715 /*
3716 * veth handles a maximum of 6 segments including the header, so
3717 @@ -988,17 +994,16 @@ retry_bounce:
3718 }
3719
3720 /* Map the header */
3721 - descs[0].fields.address = dma_map_single(&adapter->vdev->dev, skb->data,
3722 - skb_headlen(skb),
3723 - DMA_TO_DEVICE);
3724 - if (dma_mapping_error(&adapter->vdev->dev, descs[0].fields.address))
3725 + dma_addr = dma_map_single(&adapter->vdev->dev, skb->data,
3726 + skb_headlen(skb), DMA_TO_DEVICE);
3727 + if (dma_mapping_error(&adapter->vdev->dev, dma_addr))
3728 goto map_failed;
3729
3730 descs[0].fields.flags_len = desc_flags | skb_headlen(skb);
3731 + descs[0].fields.address = dma_addr;
3732
3733 /* Map the frags */
3734 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
3735 - unsigned long dma_addr;
3736 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3737
3738 dma_addr = dma_map_page(&adapter->vdev->dev, frag->page,
3739 @@ -1020,7 +1025,12 @@ retry_bounce:
3740 netdev->stats.tx_bytes += skb->len;
3741 }
3742
3743 - for (i = 0; i < skb_shinfo(skb)->nr_frags + 1; i++)
3744 + dma_unmap_single(&adapter->vdev->dev,
3745 + descs[0].fields.address,
3746 + descs[0].fields.flags_len & IBMVETH_BUF_LEN_MASK,
3747 + DMA_TO_DEVICE);
3748 +
3749 + for (i = 1; i < skb_shinfo(skb)->nr_frags + 1; i++)
3750 dma_unmap_page(&adapter->vdev->dev, descs[i].fields.address,
3751 descs[i].fields.flags_len & IBMVETH_BUF_LEN_MASK,
3752 DMA_TO_DEVICE);
3753 @@ -1083,8 +1093,9 @@ restart_poll:
3754 if (rx_flush)
3755 ibmveth_flush_buffer(skb->data,
3756 length + offset);
3757 + if (!ibmveth_rxq_recycle_buffer(adapter))
3758 + kfree_skb(skb);
3759 skb = new_skb;
3760 - ibmveth_rxq_recycle_buffer(adapter);
3761 } else {
3762 ibmveth_rxq_harvest_buffer(adapter);
3763 skb_reserve(skb, offset);
3764 diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
3765 index 2c28621..97f46ac 100644
3766 --- a/drivers/net/igb/igb_main.c
3767 +++ b/drivers/net/igb/igb_main.c
3768 @@ -1985,7 +1985,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
3769
3770 if (hw->bus.func == 0)
3771 hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
3772 - else if (hw->mac.type == e1000_82580)
3773 + else if (hw->mac.type >= e1000_82580)
3774 hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
3775 NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
3776 &eeprom_data);
3777 diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
3778 index 8800e1f..6a4826a 100644
3779 --- a/drivers/net/irda/smsc-ircc2.c
3780 +++ b/drivers/net/irda/smsc-ircc2.c
3781 @@ -515,7 +515,7 @@ static const struct net_device_ops smsc_ircc_netdev_ops = {
3782 * Try to open driver instance
3783 *
3784 */
3785 -static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
3786 +static int __devinit smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
3787 {
3788 struct smsc_ircc_cb *self;
3789 struct net_device *dev;
3790 diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
3791 index 08e8e25..83f197d 100644
3792 --- a/drivers/net/ixgbe/ixgbe_main.c
3793 +++ b/drivers/net/ixgbe/ixgbe_main.c
3794 @@ -1366,8 +1366,8 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
3795 if (ring_is_rsc_enabled(rx_ring))
3796 pkt_is_rsc = ixgbe_get_rsc_state(rx_desc);
3797
3798 - /* if this is a skb from previous receive DMA will be 0 */
3799 - if (rx_buffer_info->dma) {
3800 + /* linear means we are building an skb from multiple pages */
3801 + if (!skb_is_nonlinear(skb)) {
3802 u16 hlen;
3803 if (pkt_is_rsc &&
3804 !(staterr & IXGBE_RXD_STAT_EOP) &&
3805 diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
3806 index 5d3436d..ca4694e 100644
3807 --- a/drivers/net/rionet.c
3808 +++ b/drivers/net/rionet.c
3809 @@ -80,13 +80,13 @@ static int rionet_capable = 1;
3810 */
3811 static struct rio_dev **rionet_active;
3812
3813 -#define is_rionet_capable(pef, src_ops, dst_ops) \
3814 - ((pef & RIO_PEF_INB_MBOX) && \
3815 - (pef & RIO_PEF_INB_DOORBELL) && \
3816 +#define is_rionet_capable(src_ops, dst_ops) \
3817 + ((src_ops & RIO_SRC_OPS_DATA_MSG) && \
3818 + (dst_ops & RIO_DST_OPS_DATA_MSG) && \
3819 (src_ops & RIO_SRC_OPS_DOORBELL) && \
3820 (dst_ops & RIO_DST_OPS_DOORBELL))
3821 #define dev_rionet_capable(dev) \
3822 - is_rionet_capable(dev->pef, dev->src_ops, dev->dst_ops)
3823 + is_rionet_capable(dev->src_ops, dev->dst_ops)
3824
3825 #define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)
3826 #define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))
3827 @@ -282,7 +282,6 @@ static int rionet_open(struct net_device *ndev)
3828 {
3829 int i, rc = 0;
3830 struct rionet_peer *peer, *tmp;
3831 - u32 pwdcsr;
3832 struct rionet_private *rnet = netdev_priv(ndev);
3833
3834 if (netif_msg_ifup(rnet))
3835 @@ -332,13 +331,8 @@ static int rionet_open(struct net_device *ndev)
3836 continue;
3837 }
3838
3839 - /*
3840 - * If device has initialized inbound doorbells,
3841 - * send a join message
3842 - */
3843 - rio_read_config_32(peer->rdev, RIO_WRITE_PORT_CSR, &pwdcsr);
3844 - if (pwdcsr & RIO_DOORBELL_AVAIL)
3845 - rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
3846 + /* Send a join message */
3847 + rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
3848 }
3849
3850 out:
3851 @@ -492,7 +486,7 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
3852 static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
3853 {
3854 int rc = -ENODEV;
3855 - u32 lpef, lsrc_ops, ldst_ops;
3856 + u32 lsrc_ops, ldst_ops;
3857 struct rionet_peer *peer;
3858 struct net_device *ndev = NULL;
3859
3860 @@ -515,12 +509,11 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
3861 * on later probes
3862 */
3863 if (!rionet_check) {
3864 - rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
3865 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,
3866 &lsrc_ops);
3867 rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR,
3868 &ldst_ops);
3869 - if (!is_rionet_capable(lpef, lsrc_ops, ldst_ops)) {
3870 + if (!is_rionet_capable(lsrc_ops, ldst_ops)) {
3871 printk(KERN_ERR
3872 "%s: local device is not network capable\n",
3873 DRV_NAME);
3874 diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
3875 index c914729..7d1651b 100644
3876 --- a/drivers/net/sfc/efx.c
3877 +++ b/drivers/net/sfc/efx.c
3878 @@ -1051,7 +1051,6 @@ static int efx_init_io(struct efx_nic *efx)
3879 {
3880 struct pci_dev *pci_dev = efx->pci_dev;
3881 dma_addr_t dma_mask = efx->type->max_dma_mask;
3882 - bool use_wc;
3883 int rc;
3884
3885 netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n");
3886 @@ -1102,21 +1101,8 @@ static int efx_init_io(struct efx_nic *efx)
3887 rc = -EIO;
3888 goto fail3;
3889 }
3890 -
3891 - /* bug22643: If SR-IOV is enabled then tx push over a write combined
3892 - * mapping is unsafe. We need to disable write combining in this case.
3893 - * MSI is unsupported when SR-IOV is enabled, and the firmware will
3894 - * have removed the MSI capability. So write combining is safe if
3895 - * there is an MSI capability.
3896 - */
3897 - use_wc = (!EFX_WORKAROUND_22643(efx) ||
3898 - pci_find_capability(pci_dev, PCI_CAP_ID_MSI));
3899 - if (use_wc)
3900 - efx->membase = ioremap_wc(efx->membase_phys,
3901 - efx->type->mem_map_size);
3902 - else
3903 - efx->membase = ioremap_nocache(efx->membase_phys,
3904 - efx->type->mem_map_size);
3905 + efx->membase = ioremap_nocache(efx->membase_phys,
3906 + efx->type->mem_map_size);
3907 if (!efx->membase) {
3908 netif_err(efx, probe, efx->net_dev,
3909 "could not map memory BAR at %llx+%x\n",
3910 diff --git a/drivers/net/sfc/io.h b/drivers/net/sfc/io.h
3911 index cc97880..dc45110 100644
3912 --- a/drivers/net/sfc/io.h
3913 +++ b/drivers/net/sfc/io.h
3914 @@ -48,9 +48,9 @@
3915 * replacing the low 96 bits with zero does not affect functionality.
3916 * - If the host writes to the last dword address of such a register
3917 * (i.e. the high 32 bits) the underlying register will always be
3918 - * written. If the collector and the current write together do not
3919 - * provide values for all 128 bits of the register, the low 96 bits
3920 - * will be written as zero.
3921 + * written. If the collector does not hold values for the low 96
3922 + * bits of the register, they will be written as zero. Writing to
3923 + * the last qword does not have this effect and must not be done.
3924 * - If the host writes to the address of any other part of such a
3925 * register while the collector already holds values for some other
3926 * register, the write is discarded and the collector maintains its
3927 @@ -103,7 +103,6 @@ static inline void efx_writeo(struct efx_nic *efx, efx_oword_t *value,
3928 _efx_writed(efx, value->u32[2], reg + 8);
3929 _efx_writed(efx, value->u32[3], reg + 12);
3930 #endif
3931 - wmb();
3932 mmiowb();
3933 spin_unlock_irqrestore(&efx->biu_lock, flags);
3934 }
3935 @@ -126,7 +125,6 @@ static inline void efx_sram_writeq(struct efx_nic *efx, void __iomem *membase,
3936 __raw_writel((__force u32)value->u32[0], membase + addr);
3937 __raw_writel((__force u32)value->u32[1], membase + addr + 4);
3938 #endif
3939 - wmb();
3940 mmiowb();
3941 spin_unlock_irqrestore(&efx->biu_lock, flags);
3942 }
3943 @@ -141,7 +139,6 @@ static inline void efx_writed(struct efx_nic *efx, efx_dword_t *value,
3944
3945 /* No lock required */
3946 _efx_writed(efx, value->u32[0], reg);
3947 - wmb();
3948 }
3949
3950 /* Read a 128-bit CSR, locking as appropriate. */
3951 @@ -152,7 +149,6 @@ static inline void efx_reado(struct efx_nic *efx, efx_oword_t *value,
3952
3953 spin_lock_irqsave(&efx->biu_lock, flags);
3954 value->u32[0] = _efx_readd(efx, reg + 0);
3955 - rmb();
3956 value->u32[1] = _efx_readd(efx, reg + 4);
3957 value->u32[2] = _efx_readd(efx, reg + 8);
3958 value->u32[3] = _efx_readd(efx, reg + 12);
3959 @@ -175,7 +171,6 @@ static inline void efx_sram_readq(struct efx_nic *efx, void __iomem *membase,
3960 value->u64[0] = (__force __le64)__raw_readq(membase + addr);
3961 #else
3962 value->u32[0] = (__force __le32)__raw_readl(membase + addr);
3963 - rmb();
3964 value->u32[1] = (__force __le32)__raw_readl(membase + addr + 4);
3965 #endif
3966 spin_unlock_irqrestore(&efx->biu_lock, flags);
3967 @@ -242,14 +237,12 @@ static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
3968
3969 #ifdef EFX_USE_QWORD_IO
3970 _efx_writeq(efx, value->u64[0], reg + 0);
3971 - _efx_writeq(efx, value->u64[1], reg + 8);
3972 #else
3973 _efx_writed(efx, value->u32[0], reg + 0);
3974 _efx_writed(efx, value->u32[1], reg + 4);
3975 +#endif
3976 _efx_writed(efx, value->u32[2], reg + 8);
3977 _efx_writed(efx, value->u32[3], reg + 12);
3978 -#endif
3979 - wmb();
3980 }
3981 #define efx_writeo_page(efx, value, reg, page) \
3982 _efx_writeo_page(efx, value, \
3983 diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c
3984 index 3dd45ed..81a4253 100644
3985 --- a/drivers/net/sfc/mcdi.c
3986 +++ b/drivers/net/sfc/mcdi.c
3987 @@ -50,20 +50,6 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
3988 return &nic_data->mcdi;
3989 }
3990
3991 -static inline void
3992 -efx_mcdi_readd(struct efx_nic *efx, efx_dword_t *value, unsigned reg)
3993 -{
3994 - struct siena_nic_data *nic_data = efx->nic_data;
3995 - value->u32[0] = (__force __le32)__raw_readl(nic_data->mcdi_smem + reg);
3996 -}
3997 -
3998 -static inline void
3999 -efx_mcdi_writed(struct efx_nic *efx, const efx_dword_t *value, unsigned reg)
4000 -{
4001 - struct siena_nic_data *nic_data = efx->nic_data;
4002 - __raw_writel((__force u32)value->u32[0], nic_data->mcdi_smem + reg);
4003 -}
4004 -
4005 void efx_mcdi_init(struct efx_nic *efx)
4006 {
4007 struct efx_mcdi_iface *mcdi;
4008 @@ -84,8 +70,8 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
4009 const u8 *inbuf, size_t inlen)
4010 {
4011 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4012 - unsigned pdu = MCDI_PDU(efx);
4013 - unsigned doorbell = MCDI_DOORBELL(efx);
4014 + unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4015 + unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx);
4016 unsigned int i;
4017 efx_dword_t hdr;
4018 u32 xflags, seqno;
4019 @@ -106,28 +92,29 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
4020 MCDI_HEADER_SEQ, seqno,
4021 MCDI_HEADER_XFLAGS, xflags);
4022
4023 - efx_mcdi_writed(efx, &hdr, pdu);
4024 + efx_writed(efx, &hdr, pdu);
4025
4026 for (i = 0; i < inlen; i += 4)
4027 - efx_mcdi_writed(efx, (const efx_dword_t *)(inbuf + i),
4028 - pdu + 4 + i);
4029 + _efx_writed(efx, *((__le32 *)(inbuf + i)), pdu + 4 + i);
4030 +
4031 + /* Ensure the payload is written out before the header */
4032 + wmb();
4033
4034 /* ring the doorbell with a distinctive value */
4035 - EFX_POPULATE_DWORD_1(hdr, EFX_DWORD_0, 0x45789abc);
4036 - efx_mcdi_writed(efx, &hdr, doorbell);
4037 + _efx_writed(efx, (__force __le32) 0x45789abc, doorbell);
4038 }
4039
4040 static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen)
4041 {
4042 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4043 - unsigned int pdu = MCDI_PDU(efx);
4044 + unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4045 int i;
4046
4047 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
4048 BUG_ON(outlen & 3 || outlen >= 0x100);
4049
4050 for (i = 0; i < outlen; i += 4)
4051 - efx_mcdi_readd(efx, (efx_dword_t *)(outbuf + i), pdu + 4 + i);
4052 + *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i);
4053 }
4054
4055 static int efx_mcdi_poll(struct efx_nic *efx)
4056 @@ -135,7 +122,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4057 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
4058 unsigned int time, finish;
4059 unsigned int respseq, respcmd, error;
4060 - unsigned int pdu = MCDI_PDU(efx);
4061 + unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
4062 unsigned int rc, spins;
4063 efx_dword_t reg;
4064
4065 @@ -161,7 +148,8 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4066
4067 time = get_seconds();
4068
4069 - efx_mcdi_readd(efx, &reg, pdu);
4070 + rmb();
4071 + efx_readd(efx, &reg, pdu);
4072
4073 /* All 1's indicates that shared memory is in reset (and is
4074 * not a valid header). Wait for it to come out reset before
4075 @@ -188,7 +176,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
4076 respseq, mcdi->seqno);
4077 rc = EIO;
4078 } else if (error) {
4079 - efx_mcdi_readd(efx, &reg, pdu + 4);
4080 + efx_readd(efx, &reg, pdu + 4);
4081 switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) {
4082 #define TRANSLATE_ERROR(name) \
4083 case MC_CMD_ERR_ ## name: \
4084 @@ -222,21 +210,21 @@ out:
4085 /* Test and clear MC-rebooted flag for this port/function */
4086 int efx_mcdi_poll_reboot(struct efx_nic *efx)
4087 {
4088 - unsigned int addr = MCDI_REBOOT_FLAG(efx);
4089 + unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx);
4090 efx_dword_t reg;
4091 uint32_t value;
4092
4093 if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
4094 return false;
4095
4096 - efx_mcdi_readd(efx, &reg, addr);
4097 + efx_readd(efx, &reg, addr);
4098 value = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
4099
4100 if (value == 0)
4101 return 0;
4102
4103 EFX_ZERO_DWORD(reg);
4104 - efx_mcdi_writed(efx, &reg, addr);
4105 + efx_writed(efx, &reg, addr);
4106
4107 if (value == MC_STATUS_DWORD_ASSERT)
4108 return -EINTR;
4109 diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c
4110 index f2a2b94..5ac9fa2 100644
4111 --- a/drivers/net/sfc/nic.c
4112 +++ b/drivers/net/sfc/nic.c
4113 @@ -1935,13 +1935,6 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
4114
4115 size = min_t(size_t, table->step, 16);
4116
4117 - if (table->offset >= efx->type->mem_map_size) {
4118 - /* No longer mapped; return dummy data */
4119 - memcpy(buf, "\xde\xc0\xad\xde", 4);
4120 - buf += table->rows * size;
4121 - continue;
4122 - }
4123 -
4124 for (i = 0; i < table->rows; i++) {
4125 switch (table->step) {
4126 case 4: /* 32-bit register or SRAM */
4127 diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
4128 index 4bd1f28..7443f99 100644
4129 --- a/drivers/net/sfc/nic.h
4130 +++ b/drivers/net/sfc/nic.h
4131 @@ -143,12 +143,10 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
4132 /**
4133 * struct siena_nic_data - Siena NIC state
4134 * @mcdi: Management-Controller-to-Driver Interface
4135 - * @mcdi_smem: MCDI shared memory mapping. The mapping is always uncacheable.
4136 * @wol_filter_id: Wake-on-LAN packet filter id
4137 */
4138 struct siena_nic_data {
4139 struct efx_mcdi_iface mcdi;
4140 - void __iomem *mcdi_smem;
4141 int wol_filter_id;
4142 };
4143
4144 diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
4145 index fb4721f..ceac1c9 100644
4146 --- a/drivers/net/sfc/siena.c
4147 +++ b/drivers/net/sfc/siena.c
4148 @@ -220,26 +220,12 @@ static int siena_probe_nic(struct efx_nic *efx)
4149 efx_reado(efx, &reg, FR_AZ_CS_DEBUG);
4150 efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
4151
4152 - /* Initialise MCDI */
4153 - nic_data->mcdi_smem = ioremap_nocache(efx->membase_phys +
4154 - FR_CZ_MC_TREG_SMEM,
4155 - FR_CZ_MC_TREG_SMEM_STEP *
4156 - FR_CZ_MC_TREG_SMEM_ROWS);
4157 - if (!nic_data->mcdi_smem) {
4158 - netif_err(efx, probe, efx->net_dev,
4159 - "could not map MCDI at %llx+%x\n",
4160 - (unsigned long long)efx->membase_phys +
4161 - FR_CZ_MC_TREG_SMEM,
4162 - FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS);
4163 - rc = -ENOMEM;
4164 - goto fail1;
4165 - }
4166 efx_mcdi_init(efx);
4167
4168 /* Recover from a failed assertion before probing */
4169 rc = efx_mcdi_handle_assertion(efx);
4170 if (rc)
4171 - goto fail2;
4172 + goto fail1;
4173
4174 /* Let the BMC know that the driver is now in charge of link and
4175 * filter settings. We must do this before we reset the NIC */
4176 @@ -294,7 +280,6 @@ fail4:
4177 fail3:
4178 efx_mcdi_drv_attach(efx, false, NULL);
4179 fail2:
4180 - iounmap(nic_data->mcdi_smem);
4181 fail1:
4182 kfree(efx->nic_data);
4183 return rc;
4184 @@ -374,8 +359,6 @@ static int siena_init_nic(struct efx_nic *efx)
4185
4186 static void siena_remove_nic(struct efx_nic *efx)
4187 {
4188 - struct siena_nic_data *nic_data = efx->nic_data;
4189 -
4190 efx_nic_free_buffer(efx, &efx->irq_status);
4191
4192 siena_reset_hw(efx, RESET_TYPE_ALL);
4193 @@ -385,8 +368,7 @@ static void siena_remove_nic(struct efx_nic *efx)
4194 efx_mcdi_drv_attach(efx, false, NULL);
4195
4196 /* Tear down the private nic state */
4197 - iounmap(nic_data->mcdi_smem);
4198 - kfree(nic_data);
4199 + kfree(efx->nic_data);
4200 efx->nic_data = NULL;
4201 }
4202
4203 @@ -624,7 +606,8 @@ const struct efx_nic_type siena_a0_nic_type = {
4204 .default_mac_ops = &efx_mcdi_mac_operations,
4205
4206 .revision = EFX_REV_SIENA_A0,
4207 - .mem_map_size = FR_CZ_MC_TREG_SMEM, /* MC_TREG_SMEM mapped separately */
4208 + .mem_map_size = (FR_CZ_MC_TREG_SMEM +
4209 + FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS),
4210 .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
4211 .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL,
4212 .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
4213 diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h
4214 index 99ff114..e4dd3a7 100644
4215 --- a/drivers/net/sfc/workarounds.h
4216 +++ b/drivers/net/sfc/workarounds.h
4217 @@ -38,8 +38,6 @@
4218 #define EFX_WORKAROUND_15783 EFX_WORKAROUND_ALWAYS
4219 /* Legacy interrupt storm when interrupt fifo fills */
4220 #define EFX_WORKAROUND_17213 EFX_WORKAROUND_SIENA
4221 -/* Write combining and sriov=enabled are incompatible */
4222 -#define EFX_WORKAROUND_22643 EFX_WORKAROUND_SIENA
4223
4224 /* Spurious parity errors in TSORT buffers */
4225 #define EFX_WORKAROUND_5129 EFX_WORKAROUND_FALCON_A
4226 diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
4227 index a1f9f9e..38f6859 100644
4228 --- a/drivers/net/tg3.c
4229 +++ b/drivers/net/tg3.c
4230 @@ -7267,16 +7267,11 @@ static int tg3_chip_reset(struct tg3 *tp)
4231 tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
4232 }
4233
4234 - if (tg3_flag(tp, ENABLE_APE))
4235 - tp->mac_mode = MAC_MODE_APE_TX_EN |
4236 - MAC_MODE_APE_RX_EN |
4237 - MAC_MODE_TDE_ENABLE;
4238 -
4239 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) {
4240 - tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
4241 + tp->mac_mode = MAC_MODE_PORT_MODE_TBI;
4242 val = tp->mac_mode;
4243 } else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) {
4244 - tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
4245 + tp->mac_mode = MAC_MODE_PORT_MODE_GMII;
4246 val = tp->mac_mode;
4247 } else
4248 val = 0;
4249 @@ -8408,12 +8403,11 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
4250 udelay(10);
4251 }
4252
4253 - if (tg3_flag(tp, ENABLE_APE))
4254 - tp->mac_mode = MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN;
4255 - else
4256 - tp->mac_mode = 0;
4257 tp->mac_mode |= MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
4258 - MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
4259 + MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE |
4260 + MAC_MODE_FHDE_ENABLE;
4261 + if (tg3_flag(tp, ENABLE_APE))
4262 + tp->mac_mode |= MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN;
4263 if (!tg3_flag(tp, 5705_PLUS) &&
4264 !(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) &&
4265 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
4266 @@ -8988,7 +8982,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
4267 * Turn off MSI one shot mode. Otherwise this test has no
4268 * observable way to know whether the interrupt was delivered.
4269 */
4270 - if (tg3_flag(tp, 57765_PLUS) && tg3_flag(tp, USING_MSI)) {
4271 + if (tg3_flag(tp, 57765_PLUS)) {
4272 val = tr32(MSGINT_MODE) | MSGINT_MODE_ONE_SHOT_DISABLE;
4273 tw32(MSGINT_MODE, val);
4274 }
4275 @@ -9016,6 +9010,10 @@ static int tg3_test_interrupt(struct tg3 *tp)
4276 break;
4277 }
4278
4279 + if (tg3_flag(tp, 57765_PLUS) &&
4280 + tnapi->hw_status->status_tag != tnapi->last_tag)
4281 + tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24);
4282 +
4283 msleep(10);
4284 }
4285
4286 @@ -9030,7 +9028,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
4287
4288 if (intr_ok) {
4289 /* Reenable MSI one shot mode. */
4290 - if (tg3_flag(tp, 57765_PLUS) && tg3_flag(tp, USING_MSI)) {
4291 + if (tg3_flag(tp, 57765_PLUS)) {
4292 val = tr32(MSGINT_MODE) & ~MSGINT_MODE_ONE_SHOT_DISABLE;
4293 tw32(MSGINT_MODE, val);
4294 }
4295 @@ -12947,7 +12945,9 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
4296 }
4297
4298 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
4299 - ((tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
4300 + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
4301 + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720 ||
4302 + (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
4303 tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) ||
4304 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 &&
4305 tp->pci_chip_rev_id != CHIPREV_ID_57765_A0)))
4306 diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
4307 index 6998aa6..5250288 100644
4308 --- a/drivers/net/usb/asix.c
4309 +++ b/drivers/net/usb/asix.c
4310 @@ -1502,6 +1502,10 @@ static const struct usb_device_id products [] = {
4311 USB_DEVICE (0x04f1, 0x3008),
4312 .driver_info = (unsigned long) &ax8817x_info,
4313 }, {
4314 + // ASIX AX88772B 10/100
4315 + USB_DEVICE (0x0b95, 0x772b),
4316 + .driver_info = (unsigned long) &ax88772_info,
4317 +}, {
4318 // ASIX AX88772 10/100
4319 USB_DEVICE (0x0b95, 0x7720),
4320 .driver_info = (unsigned long) &ax88772_info,
4321 diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
4322 index f33ca6a..d3b9e95 100644
4323 --- a/drivers/net/usb/cdc_ncm.c
4324 +++ b/drivers/net/usb/cdc_ncm.c
4325 @@ -54,7 +54,7 @@
4326 #include <linux/usb/usbnet.h>
4327 #include <linux/usb/cdc.h>
4328
4329 -#define DRIVER_VERSION "01-June-2011"
4330 +#define DRIVER_VERSION "04-Aug-2011"
4331
4332 /* CDC NCM subclass 3.2.1 */
4333 #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
4334 @@ -164,35 +164,8 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
4335 usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
4336 }
4337
4338 -static int
4339 -cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
4340 - void *data, u16 flags, u16 *actlen, u16 timeout)
4341 -{
4342 - int err;
4343 -
4344 - err = usb_control_msg(ctx->udev, (req->bmRequestType & USB_DIR_IN) ?
4345 - usb_rcvctrlpipe(ctx->udev, 0) :
4346 - usb_sndctrlpipe(ctx->udev, 0),
4347 - req->bNotificationType, req->bmRequestType,
4348 - req->wValue,
4349 - req->wIndex, data,
4350 - req->wLength, timeout);
4351 -
4352 - if (err < 0) {
4353 - if (actlen)
4354 - *actlen = 0;
4355 - return err;
4356 - }
4357 -
4358 - if (actlen)
4359 - *actlen = err;
4360 -
4361 - return 0;
4362 -}
4363 -
4364 static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4365 {
4366 - struct usb_cdc_notification req;
4367 u32 val;
4368 u8 flags;
4369 u8 iface_no;
4370 @@ -201,14 +174,14 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4371
4372 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
4373
4374 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE;
4375 - req.bNotificationType = USB_CDC_GET_NTB_PARAMETERS;
4376 - req.wValue = 0;
4377 - req.wIndex = cpu_to_le16(iface_no);
4378 - req.wLength = cpu_to_le16(sizeof(ctx->ncm_parm));
4379 -
4380 - err = cdc_ncm_do_request(ctx, &req, &ctx->ncm_parm, 0, NULL, 1000);
4381 - if (err) {
4382 + err = usb_control_msg(ctx->udev,
4383 + usb_rcvctrlpipe(ctx->udev, 0),
4384 + USB_CDC_GET_NTB_PARAMETERS,
4385 + USB_TYPE_CLASS | USB_DIR_IN
4386 + | USB_RECIP_INTERFACE,
4387 + 0, iface_no, &ctx->ncm_parm,
4388 + sizeof(ctx->ncm_parm), 10000);
4389 + if (err < 0) {
4390 pr_debug("failed GET_NTB_PARAMETERS\n");
4391 return 1;
4392 }
4393 @@ -254,31 +227,26 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4394
4395 /* inform device about NTB input size changes */
4396 if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
4397 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4398 - USB_RECIP_INTERFACE;
4399 - req.bNotificationType = USB_CDC_SET_NTB_INPUT_SIZE;
4400 - req.wValue = 0;
4401 - req.wIndex = cpu_to_le16(iface_no);
4402
4403 if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
4404 struct usb_cdc_ncm_ndp_input_size ndp_in_sz;
4405 -
4406 - req.wLength = 8;
4407 - ndp_in_sz.dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
4408 - ndp_in_sz.wNtbInMaxDatagrams =
4409 - cpu_to_le16(CDC_NCM_DPT_DATAGRAMS_MAX);
4410 - ndp_in_sz.wReserved = 0;
4411 - err = cdc_ncm_do_request(ctx, &req, &ndp_in_sz, 0, NULL,
4412 - 1000);
4413 + err = usb_control_msg(ctx->udev,
4414 + usb_sndctrlpipe(ctx->udev, 0),
4415 + USB_CDC_SET_NTB_INPUT_SIZE,
4416 + USB_TYPE_CLASS | USB_DIR_OUT
4417 + | USB_RECIP_INTERFACE,
4418 + 0, iface_no, &ndp_in_sz, 8, 1000);
4419 } else {
4420 __le32 dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
4421 -
4422 - req.wLength = 4;
4423 - err = cdc_ncm_do_request(ctx, &req, &dwNtbInMaxSize, 0,
4424 - NULL, 1000);
4425 + err = usb_control_msg(ctx->udev,
4426 + usb_sndctrlpipe(ctx->udev, 0),
4427 + USB_CDC_SET_NTB_INPUT_SIZE,
4428 + USB_TYPE_CLASS | USB_DIR_OUT
4429 + | USB_RECIP_INTERFACE,
4430 + 0, iface_no, &dwNtbInMaxSize, 4, 1000);
4431 }
4432
4433 - if (err)
4434 + if (err < 0)
4435 pr_debug("Setting NTB Input Size failed\n");
4436 }
4437
4438 @@ -333,29 +301,24 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4439
4440 /* set CRC Mode */
4441 if (flags & USB_CDC_NCM_NCAP_CRC_MODE) {
4442 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4443 - USB_RECIP_INTERFACE;
4444 - req.bNotificationType = USB_CDC_SET_CRC_MODE;
4445 - req.wValue = cpu_to_le16(USB_CDC_NCM_CRC_NOT_APPENDED);
4446 - req.wIndex = cpu_to_le16(iface_no);
4447 - req.wLength = 0;
4448 -
4449 - err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
4450 - if (err)
4451 + err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
4452 + USB_CDC_SET_CRC_MODE,
4453 + USB_TYPE_CLASS | USB_DIR_OUT
4454 + | USB_RECIP_INTERFACE,
4455 + USB_CDC_NCM_CRC_NOT_APPENDED,
4456 + iface_no, NULL, 0, 1000);
4457 + if (err < 0)
4458 pr_debug("Setting CRC mode off failed\n");
4459 }
4460
4461 /* set NTB format, if both formats are supported */
4462 if (ntb_fmt_supported & USB_CDC_NCM_NTH32_SIGN) {
4463 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4464 - USB_RECIP_INTERFACE;
4465 - req.bNotificationType = USB_CDC_SET_NTB_FORMAT;
4466 - req.wValue = cpu_to_le16(USB_CDC_NCM_NTB16_FORMAT);
4467 - req.wIndex = cpu_to_le16(iface_no);
4468 - req.wLength = 0;
4469 -
4470 - err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
4471 - if (err)
4472 + err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
4473 + USB_CDC_SET_NTB_FORMAT, USB_TYPE_CLASS
4474 + | USB_DIR_OUT | USB_RECIP_INTERFACE,
4475 + USB_CDC_NCM_NTB16_FORMAT,
4476 + iface_no, NULL, 0, 1000);
4477 + if (err < 0)
4478 pr_debug("Setting NTB format to 16-bit failed\n");
4479 }
4480
4481 @@ -365,17 +328,13 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4482 if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) {
4483 __le16 max_datagram_size;
4484 u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
4485 -
4486 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN |
4487 - USB_RECIP_INTERFACE;
4488 - req.bNotificationType = USB_CDC_GET_MAX_DATAGRAM_SIZE;
4489 - req.wValue = 0;
4490 - req.wIndex = cpu_to_le16(iface_no);
4491 - req.wLength = cpu_to_le16(2);
4492 -
4493 - err = cdc_ncm_do_request(ctx, &req, &max_datagram_size, 0, NULL,
4494 - 1000);
4495 - if (err) {
4496 + err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0),
4497 + USB_CDC_GET_MAX_DATAGRAM_SIZE,
4498 + USB_TYPE_CLASS | USB_DIR_IN
4499 + | USB_RECIP_INTERFACE,
4500 + 0, iface_no, &max_datagram_size,
4501 + 2, 1000);
4502 + if (err < 0) {
4503 pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
4504 CDC_NCM_MIN_DATAGRAM_SIZE);
4505 } else {
4506 @@ -396,17 +355,15 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4507 CDC_NCM_MIN_DATAGRAM_SIZE;
4508
4509 /* if value changed, update device */
4510 - req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
4511 - USB_RECIP_INTERFACE;
4512 - req.bNotificationType = USB_CDC_SET_MAX_DATAGRAM_SIZE;
4513 - req.wValue = 0;
4514 - req.wIndex = cpu_to_le16(iface_no);
4515 - req.wLength = 2;
4516 - max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
4517 -
4518 - err = cdc_ncm_do_request(ctx, &req, &max_datagram_size,
4519 - 0, NULL, 1000);
4520 - if (err)
4521 + err = usb_control_msg(ctx->udev,
4522 + usb_sndctrlpipe(ctx->udev, 0),
4523 + USB_CDC_SET_MAX_DATAGRAM_SIZE,
4524 + USB_TYPE_CLASS | USB_DIR_OUT
4525 + | USB_RECIP_INTERFACE,
4526 + 0,
4527 + iface_no, &max_datagram_size,
4528 + 2, 1000);
4529 + if (err < 0)
4530 pr_debug("SET_MAX_DATAGRAM_SIZE failed\n");
4531 }
4532
4533 @@ -672,7 +629,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4534 u32 rem;
4535 u32 offset;
4536 u32 last_offset;
4537 - u16 n = 0;
4538 + u16 n = 0, index;
4539 u8 ready2send = 0;
4540
4541 /* if there is a remaining skb, it gets priority */
4542 @@ -860,8 +817,8 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4543 cpu_to_le16(sizeof(ctx->tx_ncm.nth16));
4544 ctx->tx_ncm.nth16.wSequence = cpu_to_le16(ctx->tx_seq);
4545 ctx->tx_ncm.nth16.wBlockLength = cpu_to_le16(last_offset);
4546 - ctx->tx_ncm.nth16.wNdpIndex = ALIGN(sizeof(struct usb_cdc_ncm_nth16),
4547 - ctx->tx_ndp_modulus);
4548 + index = ALIGN(sizeof(struct usb_cdc_ncm_nth16), ctx->tx_ndp_modulus);
4549 + ctx->tx_ncm.nth16.wNdpIndex = cpu_to_le16(index);
4550
4551 memcpy(skb_out->data, &(ctx->tx_ncm.nth16), sizeof(ctx->tx_ncm.nth16));
4552 ctx->tx_seq++;
4553 @@ -874,12 +831,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
4554 ctx->tx_ncm.ndp16.wLength = cpu_to_le16(rem);
4555 ctx->tx_ncm.ndp16.wNextNdpIndex = 0; /* reserved */
4556
4557 - memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex,
4558 + memcpy(((u8 *)skb_out->data) + index,
4559 &(ctx->tx_ncm.ndp16),
4560 sizeof(ctx->tx_ncm.ndp16));
4561
4562 - memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex +
4563 - sizeof(ctx->tx_ncm.ndp16),
4564 + memcpy(((u8 *)skb_out->data) + index + sizeof(ctx->tx_ncm.ndp16),
4565 &(ctx->tx_ncm.dpe16),
4566 (ctx->tx_curr_frame_num + 1) *
4567 sizeof(struct usb_cdc_ncm_dpe16));
4568 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4569 index 2d4c091..2d394af 100644
4570 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4571 +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
4572 @@ -41,7 +41,8 @@ static bool ar9002_hw_is_cal_supported(struct ath_hw *ah,
4573 case ADC_DC_CAL:
4574 /* Run ADC Gain Cal for non-CCK & non 2GHz-HT20 only */
4575 if (!IS_CHAN_B(chan) &&
4576 - !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
4577 + !((IS_CHAN_2GHZ(chan) || IS_CHAN_A_FAST_CLOCK(ah, chan)) &&
4578 + IS_CHAN_HT20(chan)))
4579 supported = true;
4580 break;
4581 }
4582 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4583 index e8ac70d..029773c 100644
4584 --- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4585 +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
4586 @@ -1516,7 +1516,7 @@ static const u32 ar9300_2p2_mac_core[][2] = {
4587 {0x00008258, 0x00000000},
4588 {0x0000825c, 0x40000000},
4589 {0x00008260, 0x00080922},
4590 - {0x00008264, 0x9bc00010},
4591 + {0x00008264, 0x9d400010},
4592 {0x00008268, 0xffffffff},
4593 {0x0000826c, 0x0000ffff},
4594 {0x00008270, 0x00000000},
4595 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4596 index 7e07f0f..417106b 100644
4597 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4598 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
4599 @@ -68,7 +68,7 @@ static int ar9003_hw_power_interpolate(int32_t x,
4600 static const struct ar9300_eeprom ar9300_default = {
4601 .eepromVersion = 2,
4602 .templateVersion = 2,
4603 - .macAddr = {1, 2, 3, 4, 5, 6},
4604 + .macAddr = {0, 2, 3, 4, 5, 6},
4605 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4606 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4607 .baseEepHeader = {
4608 diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
4609 index 2ca351f..5362306 100644
4610 --- a/drivers/net/wireless/ath/ath9k/main.c
4611 +++ b/drivers/net/wireless/ath/ath9k/main.c
4612 @@ -2260,7 +2260,11 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
4613
4614 mutex_lock(&sc->mutex);
4615 ah->coverage_class = coverage_class;
4616 +
4617 + ath9k_ps_wakeup(sc);
4618 ath9k_hw_init_global_settings(ah);
4619 + ath9k_ps_restore(sc);
4620 +
4621 mutex_unlock(&sc->mutex);
4622 }
4623
4624 diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
4625 index 54d093c..b54966c 100644
4626 --- a/drivers/net/wireless/ath/carl9170/main.c
4627 +++ b/drivers/net/wireless/ath/carl9170/main.c
4628 @@ -1066,8 +1066,10 @@ static int carl9170_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
4629 * the high througput speed in 802.11n networks.
4630 */
4631
4632 - if (!is_main_vif(ar, vif))
4633 + if (!is_main_vif(ar, vif)) {
4634 + mutex_lock(&ar->mutex);
4635 goto err_softw;
4636 + }
4637
4638 /*
4639 * While the hardware supports *catch-all* key, for offloading
4640 diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
4641 index eb41596..b1fe4fe 100644
4642 --- a/drivers/net/wireless/b43/main.c
4643 +++ b/drivers/net/wireless/b43/main.c
4644 @@ -1571,7 +1571,8 @@ static void handle_irq_beacon(struct b43_wldev *dev)
4645 u32 cmd, beacon0_valid, beacon1_valid;
4646
4647 if (!b43_is_mode(wl, NL80211_IFTYPE_AP) &&
4648 - !b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
4649 + !b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT) &&
4650 + !b43_is_mode(wl, NL80211_IFTYPE_ADHOC))
4651 return;
4652
4653 /* This is the bottom half of the asynchronous beacon update. */
4654 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4655 index 977bd24..164bcae 100644
4656 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4657 +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
4658 @@ -822,12 +822,15 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
4659
4660 out:
4661
4662 - rs_sta->last_txrate_idx = index;
4663 - if (sband->band == IEEE80211_BAND_5GHZ)
4664 - info->control.rates[0].idx = rs_sta->last_txrate_idx -
4665 - IWL_FIRST_OFDM_RATE;
4666 - else
4667 + if (sband->band == IEEE80211_BAND_5GHZ) {
4668 + if (WARN_ON_ONCE(index < IWL_FIRST_OFDM_RATE))
4669 + index = IWL_FIRST_OFDM_RATE;
4670 + rs_sta->last_txrate_idx = index;
4671 + info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE;
4672 + } else {
4673 + rs_sta->last_txrate_idx = index;
4674 info->control.rates[0].idx = rs_sta->last_txrate_idx;
4675 + }
4676
4677 IWL_DEBUG_RATE(priv, "leave: %d\n", index);
4678 }
4679 diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
4680 index 3be76bd..d273d50 100644
4681 --- a/drivers/net/wireless/iwlegacy/iwl-core.c
4682 +++ b/drivers/net/wireless/iwlegacy/iwl-core.c
4683 @@ -938,7 +938,7 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv)
4684 &priv->contexts[IWL_RXON_CTX_BSS]);
4685 #endif
4686
4687 - wake_up_interruptible(&priv->wait_command_queue);
4688 + wake_up(&priv->wait_command_queue);
4689
4690 /* Keep the restart process from trying to send host
4691 * commands by clearing the INIT status bit */
4692 @@ -1776,7 +1776,7 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external)
4693 IWL_ERR(priv, "On demand firmware reload\n");
4694 /* Set the FW error flag -- cleared on iwl_down */
4695 set_bit(STATUS_FW_ERROR, &priv->status);
4696 - wake_up_interruptible(&priv->wait_command_queue);
4697 + wake_up(&priv->wait_command_queue);
4698 /*
4699 * Keep the restart process from trying to send host
4700 * commands by clearing the INIT status bit
4701 diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4702 index 62b4b09..ce1fc9f 100644
4703 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4704 +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
4705 @@ -167,7 +167,7 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
4706 goto out;
4707 }
4708
4709 - ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4710 + ret = wait_event_timeout(priv->wait_command_queue,
4711 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
4712 HOST_COMPLETE_TIMEOUT);
4713 if (!ret) {
4714 diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c
4715 index 4fff995..ef9e268 100644
4716 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c
4717 +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c
4718 @@ -625,6 +625,8 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4719 cmd = txq->cmd[cmd_index];
4720 meta = &txq->meta[cmd_index];
4721
4722 + txq->time_stamp = jiffies;
4723 +
4724 pci_unmap_single(priv->pci_dev,
4725 dma_unmap_addr(meta, mapping),
4726 dma_unmap_len(meta, len),
4727 @@ -645,7 +647,7 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4728 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
4729 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n",
4730 iwl_legacy_get_cmd_string(cmd->hdr.cmd));
4731 - wake_up_interruptible(&priv->wait_command_queue);
4732 + wake_up(&priv->wait_command_queue);
4733 }
4734
4735 /* Mark as unmapped */
4736 diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
4737 index 0ee6be6..421d5c8 100644
4738 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
4739 +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
4740 @@ -841,7 +841,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv,
4741 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
4742 test_bit(STATUS_RF_KILL_HW, &priv->status));
4743 else
4744 - wake_up_interruptible(&priv->wait_command_queue);
4745 + wake_up(&priv->wait_command_queue);
4746 }
4747
4748 /**
4749 @@ -2518,7 +2518,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
4750 iwl3945_reg_txpower_periodic(priv);
4751
4752 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
4753 - wake_up_interruptible(&priv->wait_command_queue);
4754 + wake_up(&priv->wait_command_queue);
4755
4756 return;
4757
4758 @@ -2549,7 +2549,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
4759 iwl_legacy_clear_driver_stations(priv);
4760
4761 /* Unblock any waiting calls */
4762 - wake_up_interruptible_all(&priv->wait_command_queue);
4763 + wake_up_all(&priv->wait_command_queue);
4764
4765 /* Wipe out the EXIT_PENDING status bit if we are not actually
4766 * exiting the module */
4767 @@ -3125,7 +3125,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
4768
4769 /* Wait for START_ALIVE from ucode. Otherwise callbacks from
4770 * mac80211 will not be run successfully. */
4771 - ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4772 + ret = wait_event_timeout(priv->wait_command_queue,
4773 test_bit(STATUS_READY, &priv->status),
4774 UCODE_READY_TIMEOUT);
4775 if (!ret) {
4776 diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
4777 index 7157ba5..0c37c02 100644
4778 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
4779 +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
4780 @@ -704,7 +704,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
4781 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
4782 test_bit(STATUS_RF_KILL_HW, &priv->status));
4783 else
4784 - wake_up_interruptible(&priv->wait_command_queue);
4785 + wake_up(&priv->wait_command_queue);
4786 }
4787
4788 /**
4789 @@ -1054,7 +1054,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
4790 handled |= CSR_INT_BIT_FH_TX;
4791 /* Wake up uCode load routine, now that load is complete */
4792 priv->ucode_write_complete = 1;
4793 - wake_up_interruptible(&priv->wait_command_queue);
4794 + wake_up(&priv->wait_command_queue);
4795 }
4796
4797 if (inta & ~handled) {
4798 @@ -2126,7 +2126,7 @@ static void iwl4965_alive_start(struct iwl_priv *priv)
4799 iwl4965_rf_kill_ct_config(priv);
4800
4801 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
4802 - wake_up_interruptible(&priv->wait_command_queue);
4803 + wake_up(&priv->wait_command_queue);
4804
4805 iwl_legacy_power_update_mode(priv, true);
4806 IWL_DEBUG_INFO(priv, "Updated power mode\n");
4807 @@ -2159,7 +2159,7 @@ static void __iwl4965_down(struct iwl_priv *priv)
4808 iwl_legacy_clear_driver_stations(priv);
4809
4810 /* Unblock any waiting calls */
4811 - wake_up_interruptible_all(&priv->wait_command_queue);
4812 + wake_up_all(&priv->wait_command_queue);
4813
4814 /* Wipe out the EXIT_PENDING status bit if we are not actually
4815 * exiting the module */
4816 @@ -2597,7 +2597,7 @@ int iwl4965_mac_start(struct ieee80211_hw *hw)
4817
4818 /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
4819 * mac80211 will not be run successfully. */
4820 - ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4821 + ret = wait_event_timeout(priv->wait_command_queue,
4822 test_bit(STATUS_READY, &priv->status),
4823 UCODE_READY_TIMEOUT);
4824 if (!ret) {
4825 diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
4826 index 8e1942e..f24165d 100644
4827 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c
4828 +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
4829 @@ -2440,7 +2440,12 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
4830 IEEE80211_HW_SPECTRUM_MGMT |
4831 IEEE80211_HW_REPORTS_TX_ACK_STATUS;
4832
4833 + /*
4834 + * Including the following line will crash some AP's. This
4835 + * workaround removes the stimulus which causes the crash until
4836 + * the AP software can be fixed.
4837 hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
4838 + */
4839
4840 hw->flags |= IEEE80211_HW_SUPPORTS_PS |
4841 IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
4842 diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
4843 index d60d630..f524016 100644
4844 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c
4845 +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
4846 @@ -406,31 +406,33 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
4847
4848 mutex_lock(&priv->mutex);
4849
4850 - if (test_bit(STATUS_SCANNING, &priv->status) &&
4851 - priv->scan_type != IWL_SCAN_NORMAL) {
4852 - IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
4853 - ret = -EAGAIN;
4854 - goto out_unlock;
4855 - }
4856 -
4857 - /* mac80211 will only ask for one band at a time */
4858 - priv->scan_request = req;
4859 - priv->scan_vif = vif;
4860 -
4861 /*
4862 * If an internal scan is in progress, just set
4863 * up the scan_request as per above.
4864 */
4865 if (priv->scan_type != IWL_SCAN_NORMAL) {
4866 - IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n");
4867 + IWL_DEBUG_SCAN(priv,
4868 + "SCAN request during internal scan - defer\n");
4869 + priv->scan_request = req;
4870 + priv->scan_vif = vif;
4871 ret = 0;
4872 - } else
4873 + } else {
4874 + priv->scan_request = req;
4875 + priv->scan_vif = vif;
4876 + /*
4877 + * mac80211 will only ask for one band at a time
4878 + * so using channels[0] here is ok
4879 + */
4880 ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL,
4881 req->channels[0]->band);
4882 + if (ret) {
4883 + priv->scan_request = NULL;
4884 + priv->scan_vif = NULL;
4885 + }
4886 + }
4887
4888 IWL_DEBUG_MAC80211(priv, "leave\n");
4889
4890 -out_unlock:
4891 mutex_unlock(&priv->mutex);
4892
4893 return ret;
4894 diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
4895 index 137dba9..c368c50 100644
4896 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c
4897 +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
4898 @@ -802,6 +802,8 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4899 cmd = txq->cmd[cmd_index];
4900 meta = &txq->meta[cmd_index];
4901
4902 + txq->time_stamp = jiffies;
4903 +
4904 iwlagn_unmap_tfd(priv, meta, &txq->tfds[index], PCI_DMA_BIDIRECTIONAL);
4905
4906 /* Input error checking is done when commands are added to queue. */
4907 diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
4908 index 5a45228..3f7ea1c 100644
4909 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
4910 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
4911 @@ -38,6 +38,7 @@
4912 #include <linux/kernel.h>
4913 #include <linux/module.h>
4914 #include <linux/slab.h>
4915 +#include <linux/sched.h>
4916
4917 #include "rt2x00.h"
4918 #include "rt2800lib.h"
4919 @@ -607,6 +608,15 @@ static bool rt2800_txdone_entry_check(struct queue_entry *entry, u32 reg)
4920 int wcid, ack, pid;
4921 int tx_wcid, tx_ack, tx_pid;
4922
4923 + if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
4924 + !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) {
4925 + WARNING(entry->queue->rt2x00dev,
4926 + "Data pending for entry %u in queue %u\n",
4927 + entry->entry_idx, entry->queue->qid);
4928 + cond_resched();
4929 + return false;
4930 + }
4931 +
4932 wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
4933 ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
4934 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
4935 @@ -754,12 +764,11 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
4936 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
4937 if (rt2800_txdone_entry_check(entry, reg))
4938 break;
4939 + entry = NULL;
4940 }
4941
4942 - if (!entry || rt2x00queue_empty(queue))
4943 - break;
4944 -
4945 - rt2800_txdone_entry(entry, reg);
4946 + if (entry)
4947 + rt2800_txdone_entry(entry, reg);
4948 }
4949 }
4950 EXPORT_SYMBOL_GPL(rt2800_txdone);
4951 @@ -3503,14 +3512,15 @@ static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i)
4952 rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
4953
4954 /* Apparently the data is read from end to start */
4955 - rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3,
4956 - (u32 *)&rt2x00dev->eeprom[i]);
4957 - rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2,
4958 - (u32 *)&rt2x00dev->eeprom[i + 2]);
4959 - rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1,
4960 - (u32 *)&rt2x00dev->eeprom[i + 4]);
4961 - rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0,
4962 - (u32 *)&rt2x00dev->eeprom[i + 6]);
4963 + rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, &reg);
4964 + /* The returned value is in CPU order, but eeprom is le */
4965 + rt2x00dev->eeprom[i] = cpu_to_le32(reg);
4966 + rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2, &reg);
4967 + *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg);
4968 + rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1, &reg);
4969 + *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg);
4970 + rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0, &reg);
4971 + *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg);
4972
4973 mutex_unlock(&rt2x00dev->csr_mutex);
4974 }
4975 @@ -3676,19 +3686,23 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
4976 return -ENODEV;
4977 }
4978
4979 - if (!rt2x00_rf(rt2x00dev, RF2820) &&
4980 - !rt2x00_rf(rt2x00dev, RF2850) &&
4981 - !rt2x00_rf(rt2x00dev, RF2720) &&
4982 - !rt2x00_rf(rt2x00dev, RF2750) &&
4983 - !rt2x00_rf(rt2x00dev, RF3020) &&
4984 - !rt2x00_rf(rt2x00dev, RF2020) &&
4985 - !rt2x00_rf(rt2x00dev, RF3021) &&
4986 - !rt2x00_rf(rt2x00dev, RF3022) &&
4987 - !rt2x00_rf(rt2x00dev, RF3052) &&
4988 - !rt2x00_rf(rt2x00dev, RF3320) &&
4989 - !rt2x00_rf(rt2x00dev, RF5370) &&
4990 - !rt2x00_rf(rt2x00dev, RF5390)) {
4991 - ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
4992 + switch (rt2x00dev->chip.rf) {
4993 + case RF2820:
4994 + case RF2850:
4995 + case RF2720:
4996 + case RF2750:
4997 + case RF3020:
4998 + case RF2020:
4999 + case RF3021:
5000 + case RF3022:
5001 + case RF3052:
5002 + case RF3320:
5003 + case RF5370:
5004 + case RF5390:
5005 + break;
5006 + default:
5007 + ERROR(rt2x00dev, "Invalid RF chipset 0x%x detected.\n",
5008 + rt2x00dev->chip.rf);
5009 return -ENODEV;
5010 }
5011
5012 diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
5013 index ba82c97..6e7fe94 100644
5014 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
5015 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
5016 @@ -477,8 +477,10 @@ static void rt2800usb_work_txdone(struct work_struct *work)
5017 while (!rt2x00queue_empty(queue)) {
5018 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
5019
5020 - if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
5021 + if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
5022 + !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
5023 break;
5024 +
5025 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
5026 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
5027 else if (rt2x00queue_status_timeout(entry))
5028 diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
5029 index 241a099..54f0b13 100644
5030 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c
5031 +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
5032 @@ -870,18 +870,8 @@ int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state)
5033 {
5034 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
5035 struct rt2x00_dev *rt2x00dev = hw->priv;
5036 - int retval;
5037 -
5038 - retval = rt2x00lib_suspend(rt2x00dev, state);
5039 - if (retval)
5040 - return retval;
5041
5042 - /*
5043 - * Decrease usbdev refcount.
5044 - */
5045 - usb_put_dev(interface_to_usbdev(usb_intf));
5046 -
5047 - return 0;
5048 + return rt2x00lib_suspend(rt2x00dev, state);
5049 }
5050 EXPORT_SYMBOL_GPL(rt2x00usb_suspend);
5051
5052 @@ -890,8 +880,6 @@ int rt2x00usb_resume(struct usb_interface *usb_intf)
5053 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
5054 struct rt2x00_dev *rt2x00dev = hw->priv;
5055
5056 - usb_get_dev(interface_to_usbdev(usb_intf));
5057 -
5058 return rt2x00lib_resume(rt2x00dev);
5059 }
5060 EXPORT_SYMBOL_GPL(rt2x00usb_resume);
5061 diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
5062 index d2ec253..ce0444c 100644
5063 --- a/drivers/net/wireless/rtlwifi/core.c
5064 +++ b/drivers/net/wireless/rtlwifi/core.c
5065 @@ -610,6 +610,11 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
5066
5067 mac->link_state = MAC80211_NOLINK;
5068 memset(mac->bssid, 0, 6);
5069 +
5070 + /* reset sec info */
5071 + rtl_cam_reset_sec_info(hw);
5072 +
5073 + rtl_cam_reset_all_entry(hw);
5074 mac->vendor = PEER_UNKNOWN;
5075
5076 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
5077 @@ -1063,6 +1068,9 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
5078 *or clear all entry here.
5079 */
5080 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
5081 +
5082 + rtl_cam_reset_sec_info(hw);
5083 +
5084 break;
5085 default:
5086 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
5087 diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5088 index 3a92ba3..10b2ef0 100644
5089 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5090 +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
5091 @@ -549,15 +549,16 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
5092 (tcb_desc->rts_use_shortpreamble ? 1 : 0)
5093 : (tcb_desc->rts_use_shortgi ? 1 : 0)));
5094 if (mac->bw_40) {
5095 - if (tcb_desc->packet_bw) {
5096 + if (rate_flag & IEEE80211_TX_RC_DUP_DATA) {
5097 SET_TX_DESC_DATA_BW(txdesc, 1);
5098 SET_TX_DESC_DATA_SC(txdesc, 3);
5099 + } else if(rate_flag & IEEE80211_TX_RC_40_MHZ_WIDTH){
5100 + SET_TX_DESC_DATA_BW(txdesc, 1);
5101 + SET_TX_DESC_DATA_SC(txdesc, mac->cur_40_prime_sc);
5102 } else {
5103 SET_TX_DESC_DATA_BW(txdesc, 0);
5104 - if (rate_flag & IEEE80211_TX_RC_DUP_DATA)
5105 - SET_TX_DESC_DATA_SC(txdesc,
5106 - mac->cur_40_prime_sc);
5107 - }
5108 + SET_TX_DESC_DATA_SC(txdesc, 0);
5109 + }
5110 } else {
5111 SET_TX_DESC_DATA_BW(txdesc, 0);
5112 SET_TX_DESC_DATA_SC(txdesc, 0);
5113 diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
5114 index a9367eb..e4272b9 100644
5115 --- a/drivers/net/wireless/rtlwifi/usb.c
5116 +++ b/drivers/net/wireless/rtlwifi/usb.c
5117 @@ -861,6 +861,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb,
5118 u8 tid = 0;
5119 u16 seq_number = 0;
5120
5121 + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
5122 if (ieee80211_is_auth(fc)) {
5123 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n"));
5124 rtl_ips_nic_on(hw);
5125 diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
5126 index 3dc9bef..6dcc7e2 100644
5127 --- a/drivers/pci/dmar.c
5128 +++ b/drivers/pci/dmar.c
5129 @@ -1388,7 +1388,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
5130 return ret;
5131 }
5132
5133 - ret = request_irq(irq, dmar_fault, 0, iommu->name, iommu);
5134 + ret = request_irq(irq, dmar_fault, IRQF_NO_THREAD, iommu->name, iommu);
5135 if (ret)
5136 printk(KERN_ERR "IOMMU: can't request irq\n");
5137 return ret;
5138 diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
5139 index ee89358..ebe77dd 100644
5140 --- a/drivers/rapidio/rio-scan.c
5141 +++ b/drivers/rapidio/rio-scan.c
5142 @@ -505,8 +505,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
5143 rdev->dev.dma_mask = &rdev->dma_mask;
5144 rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
5145
5146 - if ((rdev->pef & RIO_PEF_INB_DOORBELL) &&
5147 - (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
5148 + if (rdev->dst_ops & RIO_DST_OPS_DOORBELL)
5149 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
5150 0, 0xffff);
5151
5152 diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
5153 index 55dd4e6..425aab3 100644
5154 --- a/drivers/regulator/tps65910-regulator.c
5155 +++ b/drivers/regulator/tps65910-regulator.c
5156 @@ -759,8 +759,13 @@ static int tps65910_list_voltage_dcdc(struct regulator_dev *dev,
5157 mult = (selector / VDD1_2_NUM_VOLTS) + 1;
5158 volt = VDD1_2_MIN_VOLT +
5159 (selector % VDD1_2_NUM_VOLTS) * VDD1_2_OFFSET;
5160 + break;
5161 case TPS65911_REG_VDDCTRL:
5162 volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET);
5163 + break;
5164 + default:
5165 + BUG();
5166 + return -EINVAL;
5167 }
5168
5169 return volt * 100 * mult;
5170 @@ -898,9 +903,11 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
5171 case TPS65910:
5172 pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
5173 info = tps65910_regs;
5174 + break;
5175 case TPS65911:
5176 pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
5177 info = tps65911_regs;
5178 + break;
5179 default:
5180 pr_err("Invalid tps chip version\n");
5181 return -ENODEV;
5182 diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
5183 index 3195dbd..eb4c883 100644
5184 --- a/drivers/rtc/interface.c
5185 +++ b/drivers/rtc/interface.c
5186 @@ -708,7 +708,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
5187 int err = 0;
5188 unsigned long flags;
5189
5190 - if (freq <= 0 || freq > 5000)
5191 + if (freq <= 0 || freq > RTC_MAX_FREQ)
5192 return -EINVAL;
5193 retry:
5194 spin_lock_irqsave(&rtc->irq_task_lock, flags);
5195 diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
5196 index 5c4e741..68be6e1 100644
5197 --- a/drivers/s390/cio/qdio_thinint.c
5198 +++ b/drivers/s390/cio/qdio_thinint.c
5199 @@ -95,9 +95,11 @@ void tiqdio_remove_input_queues(struct qdio_irq *irq_ptr)
5200 }
5201 }
5202
5203 -static inline u32 shared_ind_set(void)
5204 +static inline u32 clear_shared_ind(void)
5205 {
5206 - return q_indicators[TIQDIO_SHARED_IND].ind;
5207 + if (!atomic_read(&q_indicators[TIQDIO_SHARED_IND].count))
5208 + return 0;
5209 + return xchg(&q_indicators[TIQDIO_SHARED_IND].ind, 0);
5210 }
5211
5212 /**
5213 @@ -107,7 +109,7 @@ static inline u32 shared_ind_set(void)
5214 */
5215 static void tiqdio_thinint_handler(void *alsi, void *data)
5216 {
5217 - u32 si_used = shared_ind_set();
5218 + u32 si_used = clear_shared_ind();
5219 struct qdio_q *q;
5220
5221 last_ai_time = S390_lowcore.int_clock;
5222 @@ -150,13 +152,6 @@ static void tiqdio_thinint_handler(void *alsi, void *data)
5223 qperf_inc(q, adapter_int);
5224 }
5225 rcu_read_unlock();
5226 -
5227 - /*
5228 - * If the shared indicator was used clear it now after all queues
5229 - * were processed.
5230 - */
5231 - if (si_used && shared_ind_set())
5232 - xchg(&q_indicators[TIQDIO_SHARED_IND].ind, 0);
5233 }
5234
5235 static int set_subchannel_ind(struct qdio_irq *irq_ptr, int reset)
5236 diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
5237 index b7bd5b0..3868ab2 100644
5238 --- a/drivers/scsi/3w-9xxx.c
5239 +++ b/drivers/scsi/3w-9xxx.c
5240 @@ -1800,10 +1800,12 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
5241 switch (retval) {
5242 case SCSI_MLQUEUE_HOST_BUSY:
5243 twa_free_request_id(tw_dev, request_id);
5244 + twa_unmap_scsi_data(tw_dev, request_id);
5245 break;
5246 case 1:
5247 tw_dev->state[request_id] = TW_S_COMPLETED;
5248 twa_free_request_id(tw_dev, request_id);
5249 + twa_unmap_scsi_data(tw_dev, request_id);
5250 SCpnt->result = (DID_ERROR << 16);
5251 done(SCpnt);
5252 retval = 0;
5253 diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
5254 index 3c08f53..6153a66 100644
5255 --- a/drivers/scsi/Makefile
5256 +++ b/drivers/scsi/Makefile
5257 @@ -88,7 +88,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
5258 obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
5259 obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
5260 obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
5261 -obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/
5262 +obj-$(CONFIG_SCSI_QLA_ISCSI) += libiscsi.o qla4xxx/
5263 obj-$(CONFIG_SCSI_LPFC) += lpfc/
5264 obj-$(CONFIG_SCSI_BFA_FC) += bfa/
5265 obj-$(CONFIG_SCSI_PAS16) += pas16.o
5266 diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
5267 index e7d0d47..e5f2d7d 100644
5268 --- a/drivers/scsi/aacraid/commsup.c
5269 +++ b/drivers/scsi/aacraid/commsup.c
5270 @@ -1283,6 +1283,8 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced)
5271 kfree(aac->queues);
5272 aac->queues = NULL;
5273 free_irq(aac->pdev->irq, aac);
5274 + if (aac->msi)
5275 + pci_disable_msi(aac->pdev);
5276 kfree(aac->fsa_dev);
5277 aac->fsa_dev = NULL;
5278 quirks = aac_get_driver_ident(index)->quirks;
5279 diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
5280 index 0a404bf..856fcbf 100644
5281 --- a/drivers/scsi/bnx2fc/bnx2fc.h
5282 +++ b/drivers/scsi/bnx2fc/bnx2fc.h
5283 @@ -152,7 +152,6 @@ struct bnx2fc_percpu_s {
5284 spinlock_t fp_work_lock;
5285 };
5286
5287 -
5288 struct bnx2fc_hba {
5289 struct list_head link;
5290 struct cnic_dev *cnic;
5291 @@ -179,6 +178,7 @@ struct bnx2fc_hba {
5292 #define BNX2FC_CTLR_INIT_DONE 1
5293 #define BNX2FC_CREATE_DONE 2
5294 struct fcoe_ctlr ctlr;
5295 + struct list_head vports;
5296 u8 vlan_enabled;
5297 int vlan_id;
5298 u32 next_conn_id;
5299 @@ -232,6 +232,11 @@ struct bnx2fc_hba {
5300
5301 #define bnx2fc_from_ctlr(fip) container_of(fip, struct bnx2fc_hba, ctlr)
5302
5303 +struct bnx2fc_lport {
5304 + struct list_head list;
5305 + struct fc_lport *lport;
5306 +};
5307 +
5308 struct bnx2fc_cmd_mgr {
5309 struct bnx2fc_hba *hba;
5310 u16 next_idx;
5311 @@ -423,6 +428,7 @@ struct bnx2fc_work {
5312 struct bnx2fc_unsol_els {
5313 struct fc_lport *lport;
5314 struct fc_frame *fp;
5315 + struct bnx2fc_hba *hba;
5316 struct work_struct unsol_els_work;
5317 };
5318
5319 diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5320 index ab255fb..bdf62a5 100644
5321 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5322 +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
5323 @@ -1225,6 +1225,7 @@ static int bnx2fc_interface_setup(struct bnx2fc_hba *hba,
5324 hba->ctlr.get_src_addr = bnx2fc_get_src_mac;
5325 set_bit(BNX2FC_CTLR_INIT_DONE, &hba->init_done);
5326
5327 + INIT_LIST_HEAD(&hba->vports);
5328 rc = bnx2fc_netdev_setup(hba);
5329 if (rc)
5330 goto setup_err;
5331 @@ -1261,8 +1262,15 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5332 struct fcoe_port *port;
5333 struct Scsi_Host *shost;
5334 struct fc_vport *vport = dev_to_vport(parent);
5335 + struct bnx2fc_lport *blport;
5336 int rc = 0;
5337
5338 + blport = kzalloc(sizeof(struct bnx2fc_lport), GFP_KERNEL);
5339 + if (!blport) {
5340 + BNX2FC_HBA_DBG(hba->ctlr.lp, "Unable to alloc bnx2fc_lport\n");
5341 + return NULL;
5342 + }
5343 +
5344 /* Allocate Scsi_Host structure */
5345 if (!npiv)
5346 lport = libfc_host_alloc(&bnx2fc_shost_template, sizeof(*port));
5347 @@ -1271,7 +1279,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5348
5349 if (!lport) {
5350 printk(KERN_ERR PFX "could not allocate scsi host structure\n");
5351 - return NULL;
5352 + goto free_blport;
5353 }
5354 shost = lport->host;
5355 port = lport_priv(lport);
5356 @@ -1327,12 +1335,20 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba,
5357 }
5358
5359 bnx2fc_interface_get(hba);
5360 +
5361 + spin_lock_bh(&hba->hba_lock);
5362 + blport->lport = lport;
5363 + list_add_tail(&blport->list, &hba->vports);
5364 + spin_unlock_bh(&hba->hba_lock);
5365 +
5366 return lport;
5367
5368 shost_err:
5369 scsi_remove_host(shost);
5370 lp_config_err:
5371 scsi_host_put(lport->host);
5372 +free_blport:
5373 + kfree(blport);
5374 return NULL;
5375 }
5376
5377 @@ -1348,6 +1364,7 @@ static void bnx2fc_if_destroy(struct fc_lport *lport)
5378 {
5379 struct fcoe_port *port = lport_priv(lport);
5380 struct bnx2fc_hba *hba = port->priv;
5381 + struct bnx2fc_lport *blport, *tmp;
5382
5383 BNX2FC_HBA_DBG(hba->ctlr.lp, "ENTERED bnx2fc_if_destroy\n");
5384 /* Stop the transmit retry timer */
5385 @@ -1372,6 +1389,15 @@ static void bnx2fc_if_destroy(struct fc_lport *lport)
5386 /* Free memory used by statistical counters */
5387 fc_lport_free_stats(lport);
5388
5389 + spin_lock_bh(&hba->hba_lock);
5390 + list_for_each_entry_safe(blport, tmp, &hba->vports, list) {
5391 + if (blport->lport == lport) {
5392 + list_del(&blport->list);
5393 + kfree(blport);
5394 + }
5395 + }
5396 + spin_unlock_bh(&hba->hba_lock);
5397 +
5398 /* Release Scsi_Host */
5399 scsi_host_put(lport->host);
5400
5401 diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5402 index f756d5f..78baa46 100644
5403 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5404 +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
5405 @@ -480,16 +480,36 @@ int bnx2fc_send_session_destroy_req(struct bnx2fc_hba *hba,
5406 return rc;
5407 }
5408
5409 +static bool is_valid_lport(struct bnx2fc_hba *hba, struct fc_lport *lport)
5410 +{
5411 + struct bnx2fc_lport *blport;
5412 +
5413 + spin_lock_bh(&hba->hba_lock);
5414 + list_for_each_entry(blport, &hba->vports, list) {
5415 + if (blport->lport == lport) {
5416 + spin_unlock_bh(&hba->hba_lock);
5417 + return true;
5418 + }
5419 + }
5420 + spin_unlock_bh(&hba->hba_lock);
5421 + return false;
5422 +
5423 +}
5424 +
5425 +
5426 static void bnx2fc_unsol_els_work(struct work_struct *work)
5427 {
5428 struct bnx2fc_unsol_els *unsol_els;
5429 struct fc_lport *lport;
5430 + struct bnx2fc_hba *hba;
5431 struct fc_frame *fp;
5432
5433 unsol_els = container_of(work, struct bnx2fc_unsol_els, unsol_els_work);
5434 lport = unsol_els->lport;
5435 fp = unsol_els->fp;
5436 - fc_exch_recv(lport, fp);
5437 + hba = unsol_els->hba;
5438 + if (is_valid_lport(hba, lport))
5439 + fc_exch_recv(lport, fp);
5440 kfree(unsol_els);
5441 }
5442
5443 @@ -499,6 +519,7 @@ void bnx2fc_process_l2_frame_compl(struct bnx2fc_rport *tgt,
5444 {
5445 struct fcoe_port *port = tgt->port;
5446 struct fc_lport *lport = port->lport;
5447 + struct bnx2fc_hba *hba = port->priv;
5448 struct bnx2fc_unsol_els *unsol_els;
5449 struct fc_frame_header *fh;
5450 struct fc_frame *fp;
5451 @@ -559,6 +580,7 @@ void bnx2fc_process_l2_frame_compl(struct bnx2fc_rport *tgt,
5452 fr_eof(fp) = FC_EOF_T;
5453 fr_crc(fp) = cpu_to_le32(~crc);
5454 unsol_els->lport = lport;
5455 + unsol_els->hba = hba;
5456 unsol_els->fp = fp;
5457 INIT_WORK(&unsol_els->unsol_els_work, bnx2fc_unsol_els_work);
5458 queue_work(bnx2fc_wq, &unsol_els->unsol_els_work);
5459 diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
5460 index b5b5c34..454c72c 100644
5461 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
5462 +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
5463 @@ -1734,7 +1734,6 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
5464 printk(KERN_ERR PFX "SCp.ptr is NULL\n");
5465 return;
5466 }
5467 - io_req->sc_cmd = NULL;
5468
5469 if (io_req->on_active_queue) {
5470 list_del_init(&io_req->link);
5471 @@ -1754,6 +1753,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
5472 }
5473
5474 bnx2fc_unmap_sg_list(io_req);
5475 + io_req->sc_cmd = NULL;
5476
5477 switch (io_req->fcp_status) {
5478 case FC_GOOD:
5479 diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5480 index fc2cdb6..b2d6611 100644
5481 --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5482 +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
5483 @@ -913,7 +913,7 @@ static void l2t_put(struct cxgbi_sock *csk)
5484 struct t3cdev *t3dev = (struct t3cdev *)csk->cdev->lldev;
5485
5486 if (csk->l2t) {
5487 - l2t_release(L2DATA(t3dev), csk->l2t);
5488 + l2t_release(t3dev, csk->l2t);
5489 csk->l2t = NULL;
5490 cxgbi_sock_put(csk);
5491 }
5492 diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
5493 index 155d7b9..8885b3e 100644
5494 --- a/drivers/scsi/fcoe/fcoe.c
5495 +++ b/drivers/scsi/fcoe/fcoe.c
5496 @@ -749,12 +749,27 @@ static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
5497 * The offload EM that this routine is associated with will handle any
5498 * packets that are for SCSI read requests.
5499 *
5500 + * This has been enhanced to work when FCoE stack is operating in target
5501 + * mode.
5502 + *
5503 * Returns: True for read types I/O, otherwise returns false.
5504 */
5505 bool fcoe_oem_match(struct fc_frame *fp)
5506 {
5507 - return fc_fcp_is_read(fr_fsp(fp)) &&
5508 - (fr_fsp(fp)->data_len > fcoe_ddp_min);
5509 + struct fc_frame_header *fh = fc_frame_header_get(fp);
5510 + struct fcp_cmnd *fcp;
5511 +
5512 + if (fc_fcp_is_read(fr_fsp(fp)) &&
5513 + (fr_fsp(fp)->data_len > fcoe_ddp_min))
5514 + return true;
5515 + else if (!(ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX)) {
5516 + fcp = fc_frame_payload_get(fp, sizeof(*fcp));
5517 + if (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN &&
5518 + fcp && (ntohl(fcp->fc_dl) > fcoe_ddp_min) &&
5519 + (fcp->fc_flags & FCP_CFL_WRDATA))
5520 + return true;
5521 + }
5522 + return false;
5523 }
5524
5525 /**
5526 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
5527 index 6bba23a..78c2e20 100644
5528 --- a/drivers/scsi/hpsa.c
5529 +++ b/drivers/scsi/hpsa.c
5530 @@ -676,6 +676,16 @@ static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno,
5531 BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA);
5532 removed[*nremoved] = h->dev[entry];
5533 (*nremoved)++;
5534 +
5535 + /*
5536 + * New physical devices won't have target/lun assigned yet
5537 + * so we need to preserve the values in the slot we are replacing.
5538 + */
5539 + if (new_entry->target == -1) {
5540 + new_entry->target = h->dev[entry]->target;
5541 + new_entry->lun = h->dev[entry]->lun;
5542 + }
5543 +
5544 h->dev[entry] = new_entry;
5545 added[*nadded] = new_entry;
5546 (*nadded)++;
5547 @@ -1548,10 +1558,17 @@ static inline void hpsa_set_bus_target_lun(struct hpsa_scsi_dev_t *device,
5548 }
5549
5550 static int hpsa_update_device_info(struct ctlr_info *h,
5551 - unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device)
5552 + unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
5553 + unsigned char *is_OBDR_device)
5554 {
5555 -#define OBDR_TAPE_INQ_SIZE 49
5556 +
5557 +#define OBDR_SIG_OFFSET 43
5558 +#define OBDR_TAPE_SIG "$DR-10"
5559 +#define OBDR_SIG_LEN (sizeof(OBDR_TAPE_SIG) - 1)
5560 +#define OBDR_TAPE_INQ_SIZE (OBDR_SIG_OFFSET + OBDR_SIG_LEN)
5561 +
5562 unsigned char *inq_buff;
5563 + unsigned char *obdr_sig;
5564
5565 inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
5566 if (!inq_buff)
5567 @@ -1583,6 +1600,16 @@ static int hpsa_update_device_info(struct ctlr_info *h,
5568 else
5569 this_device->raid_level = RAID_UNKNOWN;
5570
5571 + if (is_OBDR_device) {
5572 + /* See if this is a One-Button-Disaster-Recovery device
5573 + * by looking for "$DR-10" at offset 43 in inquiry data.
5574 + */
5575 + obdr_sig = &inq_buff[OBDR_SIG_OFFSET];
5576 + *is_OBDR_device = (this_device->devtype == TYPE_ROM &&
5577 + strncmp(obdr_sig, OBDR_TAPE_SIG,
5578 + OBDR_SIG_LEN) == 0);
5579 + }
5580 +
5581 kfree(inq_buff);
5582 return 0;
5583
5584 @@ -1716,7 +1743,7 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
5585 return 0;
5586 }
5587
5588 - if (hpsa_update_device_info(h, scsi3addr, this_device))
5589 + if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
5590 return 0;
5591 (*nmsa2xxx_enclosures)++;
5592 hpsa_set_bus_target_lun(this_device, bus, target, 0);
5593 @@ -1808,7 +1835,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5594 */
5595 struct ReportLUNdata *physdev_list = NULL;
5596 struct ReportLUNdata *logdev_list = NULL;
5597 - unsigned char *inq_buff = NULL;
5598 u32 nphysicals = 0;
5599 u32 nlogicals = 0;
5600 u32 ndev_allocated = 0;
5601 @@ -1824,11 +1850,9 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5602 GFP_KERNEL);
5603 physdev_list = kzalloc(reportlunsize, GFP_KERNEL);
5604 logdev_list = kzalloc(reportlunsize, GFP_KERNEL);
5605 - inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
5606 tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
5607
5608 - if (!currentsd || !physdev_list || !logdev_list ||
5609 - !inq_buff || !tmpdevice) {
5610 + if (!currentsd || !physdev_list || !logdev_list || !tmpdevice) {
5611 dev_err(&h->pdev->dev, "out of memory\n");
5612 goto out;
5613 }
5614 @@ -1863,7 +1887,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5615 /* adjust our table of devices */
5616 nmsa2xxx_enclosures = 0;
5617 for (i = 0; i < nphysicals + nlogicals + 1; i++) {
5618 - u8 *lunaddrbytes;
5619 + u8 *lunaddrbytes, is_OBDR = 0;
5620
5621 /* Figure out where the LUN ID info is coming from */
5622 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
5623 @@ -1874,7 +1898,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5624 continue;
5625
5626 /* Get device type, vendor, model, device id */
5627 - if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice))
5628 + if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
5629 + &is_OBDR))
5630 continue; /* skip it if we can't talk to it. */
5631 figure_bus_target_lun(h, lunaddrbytes, &bus, &target, &lun,
5632 tmpdevice);
5633 @@ -1898,7 +1923,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5634 hpsa_set_bus_target_lun(this_device, bus, target, lun);
5635
5636 switch (this_device->devtype) {
5637 - case TYPE_ROM: {
5638 + case TYPE_ROM:
5639 /* We don't *really* support actual CD-ROM devices,
5640 * just "One Button Disaster Recovery" tape drive
5641 * which temporarily pretends to be a CD-ROM drive.
5642 @@ -1906,15 +1931,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
5643 * device by checking for "$DR-10" in bytes 43-48 of
5644 * the inquiry data.
5645 */
5646 - char obdr_sig[7];
5647 -#define OBDR_TAPE_SIG "$DR-10"
5648 - strncpy(obdr_sig, &inq_buff[43], 6);
5649 - obdr_sig[6] = '\0';
5650 - if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0)
5651 - /* Not OBDR device, ignore it. */
5652 - break;
5653 - }
5654 - ncurrent++;
5655 + if (is_OBDR)
5656 + ncurrent++;
5657 break;
5658 case TYPE_DISK:
5659 if (i < nphysicals)
5660 @@ -1947,7 +1965,6 @@ out:
5661 for (i = 0; i < ndev_allocated; i++)
5662 kfree(currentsd[i]);
5663 kfree(currentsd);
5664 - kfree(inq_buff);
5665 kfree(physdev_list);
5666 kfree(logdev_list);
5667 }
5668 diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
5669 index 26072f1..ef46d83 100644
5670 --- a/drivers/scsi/isci/host.c
5671 +++ b/drivers/scsi/isci/host.c
5672 @@ -531,6 +531,9 @@ static void sci_controller_process_completions(struct isci_host *ihost)
5673 break;
5674
5675 case SCU_COMPLETION_TYPE_EVENT:
5676 + sci_controller_event_completion(ihost, ent);
5677 + break;
5678 +
5679 case SCU_COMPLETION_TYPE_NOTIFY: {
5680 event_cycle ^= ((event_get+1) & SCU_MAX_EVENTS) <<
5681 (SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_SHIFT - SCU_MAX_EVENTS_SHIFT);
5682 diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
5683 index 79313a7..430fc8f 100644
5684 --- a/drivers/scsi/isci/phy.c
5685 +++ b/drivers/scsi/isci/phy.c
5686 @@ -104,6 +104,7 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
5687 u32 parity_count = 0;
5688 u32 llctl, link_rate;
5689 u32 clksm_value = 0;
5690 + u32 sp_timeouts = 0;
5691
5692 iphy->link_layer_registers = reg;
5693
5694 @@ -211,6 +212,18 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
5695 llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
5696 writel(llctl, &iphy->link_layer_registers->link_layer_control);
5697
5698 + sp_timeouts = readl(&iphy->link_layer_registers->sas_phy_timeouts);
5699 +
5700 + /* Clear the default 0x36 (54us) RATE_CHANGE timeout value. */
5701 + sp_timeouts &= ~SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0xFF);
5702 +
5703 + /* Set RATE_CHANGE timeout value to 0x3B (59us). This ensures SCU can
5704 + * lock with 3Gb drive when SCU max rate is set to 1.5Gb.
5705 + */
5706 + sp_timeouts |= SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0x3B);
5707 +
5708 + writel(sp_timeouts, &iphy->link_layer_registers->sas_phy_timeouts);
5709 +
5710 if (is_a2(ihost->pdev)) {
5711 /* Program the max ARB time for the PHY to 700us so we inter-operate with
5712 * the PMC expander which shuts down PHYs if the expander PHY generates too
5713 diff --git a/drivers/scsi/isci/registers.h b/drivers/scsi/isci/registers.h
5714 index 9b266c7..00afc73 100644
5715 --- a/drivers/scsi/isci/registers.h
5716 +++ b/drivers/scsi/isci/registers.h
5717 @@ -1299,6 +1299,18 @@ struct scu_transport_layer_registers {
5718 #define SCU_AFE_XCVRCR_OFFSET 0x00DC
5719 #define SCU_AFE_LUTCR_OFFSET 0x00E0
5720
5721 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_ALIGN_DETECTION_SHIFT (0UL)
5722 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_ALIGN_DETECTION_MASK (0x000000FFUL)
5723 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_HOT_PLUG_SHIFT (8UL)
5724 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_HOT_PLUG_MASK (0x0000FF00UL)
5725 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_COMSAS_DETECTION_SHIFT (16UL)
5726 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_COMSAS_DETECTION_MASK (0x00FF0000UL)
5727 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_RATE_CHANGE_SHIFT (24UL)
5728 +#define SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_RATE_CHANGE_MASK (0xFF000000UL)
5729 +
5730 +#define SCU_SAS_PHYTOV_GEN_VAL(name, value) \
5731 + SCU_GEN_VALUE(SCU_SAS_PHY_TIMER_TIMEOUT_VALUES_##name, value)
5732 +
5733 #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_SHIFT (0)
5734 #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_MASK (0x00000003)
5735 #define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1 (0)
5736 diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
5737 index a46e07a..b5d3a8c 100644
5738 --- a/drivers/scsi/isci/request.c
5739 +++ b/drivers/scsi/isci/request.c
5740 @@ -732,12 +732,20 @@ sci_io_request_terminate(struct isci_request *ireq)
5741 sci_change_state(&ireq->sm, SCI_REQ_ABORTING);
5742 return SCI_SUCCESS;
5743 case SCI_REQ_TASK_WAIT_TC_RESP:
5744 + /* The task frame was already confirmed to have been
5745 + * sent by the SCU HW. Since the state machine is
5746 + * now only waiting for the task response itself,
5747 + * abort the request and complete it immediately
5748 + * and don't wait for the task response.
5749 + */
5750 sci_change_state(&ireq->sm, SCI_REQ_ABORTING);
5751 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED);
5752 return SCI_SUCCESS;
5753 case SCI_REQ_ABORTING:
5754 - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED);
5755 - return SCI_SUCCESS;
5756 + /* If a request has a termination requested twice, return
5757 + * a failure indication, since HW confirmation of the first
5758 + * abort is still outstanding.
5759 + */
5760 case SCI_REQ_COMPLETED:
5761 default:
5762 dev_warn(&ireq->owning_controller->pdev->dev,
5763 @@ -2399,22 +2407,19 @@ static void isci_task_save_for_upper_layer_completion(
5764 }
5765 }
5766
5767 -static void isci_request_process_stp_response(struct sas_task *task,
5768 - void *response_buffer)
5769 +static void isci_process_stp_response(struct sas_task *task, struct dev_to_host_fis *fis)
5770 {
5771 - struct dev_to_host_fis *d2h_reg_fis = response_buffer;
5772 struct task_status_struct *ts = &task->task_status;
5773 struct ata_task_resp *resp = (void *)&ts->buf[0];
5774
5775 - resp->frame_len = le16_to_cpu(*(__le16 *)(response_buffer + 6));
5776 - memcpy(&resp->ending_fis[0], response_buffer + 16, 24);
5777 + resp->frame_len = sizeof(*fis);
5778 + memcpy(resp->ending_fis, fis, sizeof(*fis));
5779 ts->buf_valid_size = sizeof(*resp);
5780
5781 - /**
5782 - * If the device fault bit is set in the status register, then
5783 + /* If the device fault bit is set in the status register, then
5784 * set the sense data and return.
5785 */
5786 - if (d2h_reg_fis->status & ATA_DF)
5787 + if (fis->status & ATA_DF)
5788 ts->stat = SAS_PROTO_RESPONSE;
5789 else
5790 ts->stat = SAM_STAT_GOOD;
5791 @@ -2428,7 +2433,6 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
5792 {
5793 struct sas_task *task = isci_request_access_task(request);
5794 struct ssp_response_iu *resp_iu;
5795 - void *resp_buf;
5796 unsigned long task_flags;
5797 struct isci_remote_device *idev = isci_lookup_device(task->dev);
5798 enum service_response response = SAS_TASK_UNDELIVERED;
5799 @@ -2565,9 +2569,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
5800 task);
5801
5802 if (sas_protocol_ata(task->task_proto)) {
5803 - resp_buf = &request->stp.rsp;
5804 - isci_request_process_stp_response(task,
5805 - resp_buf);
5806 + isci_process_stp_response(task, &request->stp.rsp);
5807 } else if (SAS_PROTOCOL_SSP == task->task_proto) {
5808
5809 /* crack the iu response buffer. */
5810 diff --git a/drivers/scsi/isci/unsolicited_frame_control.c b/drivers/scsi/isci/unsolicited_frame_control.c
5811 index e9e1e2a..16f88ab 100644
5812 --- a/drivers/scsi/isci/unsolicited_frame_control.c
5813 +++ b/drivers/scsi/isci/unsolicited_frame_control.c
5814 @@ -72,7 +72,7 @@ int sci_unsolicited_frame_control_construct(struct isci_host *ihost)
5815 */
5816 buf_len = SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
5817 header_len = SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header);
5818 - size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(dma_addr_t);
5819 + size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(uf_control->address_table.array[0]);
5820
5821 /*
5822 * The Unsolicited Frame buffers are set at the start of the UF
5823 diff --git a/drivers/scsi/isci/unsolicited_frame_control.h b/drivers/scsi/isci/unsolicited_frame_control.h
5824 index 31cb950..75d8966 100644
5825 --- a/drivers/scsi/isci/unsolicited_frame_control.h
5826 +++ b/drivers/scsi/isci/unsolicited_frame_control.h
5827 @@ -214,7 +214,7 @@ struct sci_uf_address_table_array {
5828 * starting address of the UF address table.
5829 * 64-bit pointers are required by the hardware.
5830 */
5831 - dma_addr_t *array;
5832 + u64 *array;
5833
5834 /**
5835 * This field specifies the physical address location for the UF
5836 diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
5837 index 3df9853..7724414 100644
5838 --- a/drivers/scsi/iscsi_tcp.c
5839 +++ b/drivers/scsi/iscsi_tcp.c
5840 @@ -107,10 +107,12 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
5841 * If the socket is in CLOSE or CLOSE_WAIT we should
5842 * not close the connection if there is still some
5843 * data pending.
5844 + *
5845 + * Must be called with sk_callback_lock.
5846 */
5847 static inline int iscsi_sw_sk_state_check(struct sock *sk)
5848 {
5849 - struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
5850 + struct iscsi_conn *conn = sk->sk_user_data;
5851
5852 if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
5853 !atomic_read(&sk->sk_rmem_alloc)) {
5854 @@ -123,11 +125,17 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
5855
5856 static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag)
5857 {
5858 - struct iscsi_conn *conn = sk->sk_user_data;
5859 - struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
5860 + struct iscsi_conn *conn;
5861 + struct iscsi_tcp_conn *tcp_conn;
5862 read_descriptor_t rd_desc;
5863
5864 read_lock(&sk->sk_callback_lock);
5865 + conn = sk->sk_user_data;
5866 + if (!conn) {
5867 + read_unlock(&sk->sk_callback_lock);
5868 + return;
5869 + }
5870 + tcp_conn = conn->dd_data;
5871
5872 /*
5873 * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
5874 @@ -141,11 +149,10 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag)
5875
5876 iscsi_sw_sk_state_check(sk);
5877
5878 - read_unlock(&sk->sk_callback_lock);
5879 -
5880 /* If we had to (atomically) map a highmem page,
5881 * unmap it now. */
5882 iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
5883 + read_unlock(&sk->sk_callback_lock);
5884 }
5885
5886 static void iscsi_sw_tcp_state_change(struct sock *sk)
5887 @@ -157,8 +164,11 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
5888 void (*old_state_change)(struct sock *);
5889
5890 read_lock(&sk->sk_callback_lock);
5891 -
5892 - conn = (struct iscsi_conn*)sk->sk_user_data;
5893 + conn = sk->sk_user_data;
5894 + if (!conn) {
5895 + read_unlock(&sk->sk_callback_lock);
5896 + return;
5897 + }
5898 session = conn->session;
5899
5900 iscsi_sw_sk_state_check(sk);
5901 @@ -178,11 +188,25 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
5902 **/
5903 static void iscsi_sw_tcp_write_space(struct sock *sk)
5904 {
5905 - struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
5906 - struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
5907 - struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
5908 + struct iscsi_conn *conn;
5909 + struct iscsi_tcp_conn *tcp_conn;
5910 + struct iscsi_sw_tcp_conn *tcp_sw_conn;
5911 + void (*old_write_space)(struct sock *);
5912 +
5913 + read_lock_bh(&sk->sk_callback_lock);
5914 + conn = sk->sk_user_data;
5915 + if (!conn) {
5916 + read_unlock_bh(&sk->sk_callback_lock);
5917 + return;
5918 + }
5919 +
5920 + tcp_conn = conn->dd_data;
5921 + tcp_sw_conn = tcp_conn->dd_data;
5922 + old_write_space = tcp_sw_conn->old_write_space;
5923 + read_unlock_bh(&sk->sk_callback_lock);
5924 +
5925 + old_write_space(sk);
5926
5927 - tcp_sw_conn->old_write_space(sk);
5928 ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n");
5929 iscsi_conn_queue_work(conn);
5930 }
5931 @@ -592,20 +616,17 @@ static void iscsi_sw_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
5932 /* userspace may have goofed up and not bound us */
5933 if (!sock)
5934 return;
5935 - /*
5936 - * Make sure our recv side is stopped.
5937 - * Older tools called conn stop before ep_disconnect
5938 - * so IO could still be coming in.
5939 - */
5940 - write_lock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock);
5941 - set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
5942 - write_unlock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock);
5943
5944 sock->sk->sk_err = EIO;
5945 wake_up_interruptible(sk_sleep(sock->sk));
5946
5947 - iscsi_conn_stop(cls_conn, flag);
5948 + /* stop xmit side */
5949 + iscsi_suspend_tx(conn);
5950 +
5951 + /* stop recv side and release socket */
5952 iscsi_sw_tcp_release_conn(conn);
5953 +
5954 + iscsi_conn_stop(cls_conn, flag);
5955 }
5956
5957 static int
5958 diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
5959 index 49e1ccc..3b66937 100644
5960 --- a/drivers/scsi/libfc/fc_rport.c
5961 +++ b/drivers/scsi/libfc/fc_rport.c
5962 @@ -801,6 +801,20 @@ static void fc_rport_recv_flogi_req(struct fc_lport *lport,
5963
5964 switch (rdata->rp_state) {
5965 case RPORT_ST_INIT:
5966 + /*
5967 + * If received the FLOGI request on RPORT which is INIT state
5968 + * (means not transition to FLOGI either fc_rport timeout
5969 + * function didn;t trigger or this end hasn;t received
5970 + * beacon yet from other end. In that case only, allow RPORT
5971 + * state machine to continue, otherwise fall through which
5972 + * causes the code to send reject response.
5973 + * NOTE; Not checking for FIP->state such as VNMP_UP or
5974 + * VNMP_CLAIM because if FIP state is not one of those,
5975 + * RPORT wouldn;t have created and 'rport_lookup' would have
5976 + * failed anyway in that case.
5977 + */
5978 + if (lport->point_to_multipoint)
5979 + break;
5980 case RPORT_ST_DELETE:
5981 mutex_unlock(&rdata->rp_mutex);
5982 rjt_data.reason = ELS_RJT_FIP;
5983 diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
5984 index e98ae33..09b232f 100644
5985 --- a/drivers/scsi/libiscsi_tcp.c
5986 +++ b/drivers/scsi/libiscsi_tcp.c
5987 @@ -1084,7 +1084,8 @@ iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
5988 struct iscsi_cls_conn *cls_conn;
5989 struct iscsi_tcp_conn *tcp_conn;
5990
5991 - cls_conn = iscsi_conn_setup(cls_session, sizeof(*tcp_conn), conn_idx);
5992 + cls_conn = iscsi_conn_setup(cls_session,
5993 + sizeof(*tcp_conn) + dd_data_size, conn_idx);
5994 if (!cls_conn)
5995 return NULL;
5996 conn = cls_conn->dd_data;
5997 @@ -1096,22 +1097,13 @@ iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
5998
5999 tcp_conn = conn->dd_data;
6000 tcp_conn->iscsi_conn = conn;
6001 -
6002 - tcp_conn->dd_data = kzalloc(dd_data_size, GFP_KERNEL);
6003 - if (!tcp_conn->dd_data) {
6004 - iscsi_conn_teardown(cls_conn);
6005 - return NULL;
6006 - }
6007 + tcp_conn->dd_data = conn->dd_data + sizeof(*tcp_conn);
6008 return cls_conn;
6009 }
6010 EXPORT_SYMBOL_GPL(iscsi_tcp_conn_setup);
6011
6012 void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn)
6013 {
6014 - struct iscsi_conn *conn = cls_conn->dd_data;
6015 - struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
6016 -
6017 - kfree(tcp_conn->dd_data);
6018 iscsi_conn_teardown(cls_conn);
6019 }
6020 EXPORT_SYMBOL_GPL(iscsi_tcp_conn_teardown);
6021 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
6022 index f84084b..c9e3dc0 100644
6023 --- a/drivers/scsi/libsas/sas_expander.c
6024 +++ b/drivers/scsi/libsas/sas_expander.c
6025 @@ -1721,7 +1721,7 @@ static int sas_find_bcast_dev(struct domain_device *dev,
6026 list_for_each_entry(ch, &ex->children, siblings) {
6027 if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) {
6028 res = sas_find_bcast_dev(ch, src_dev);
6029 - if (src_dev)
6030 + if (*src_dev)
6031 return res;
6032 }
6033 }
6034 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
6035 index 8ec2c86..0441361 100644
6036 --- a/drivers/scsi/lpfc/lpfc.h
6037 +++ b/drivers/scsi/lpfc/lpfc.h
6038 @@ -20,6 +20,11 @@
6039 *******************************************************************/
6040
6041 #include <scsi/scsi_host.h>
6042 +
6043 +#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
6044 +#define CONFIG_SCSI_LPFC_DEBUG_FS
6045 +#endif
6046 +
6047 struct lpfc_sli2_slim;
6048
6049 #define LPFC_PCI_DEV_LP 0x1
6050 @@ -465,9 +470,10 @@ enum intr_type_t {
6051 struct unsol_rcv_ct_ctx {
6052 uint32_t ctxt_id;
6053 uint32_t SID;
6054 - uint32_t oxid;
6055 uint32_t flags;
6056 #define UNSOL_VALID 0x00000001
6057 + uint16_t oxid;
6058 + uint16_t rxid;
6059 };
6060
6061 #define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
6062 diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
6063 index 135a53b..80ca11c 100644
6064 --- a/drivers/scsi/lpfc/lpfc_attr.c
6065 +++ b/drivers/scsi/lpfc/lpfc_attr.c
6066 @@ -755,6 +755,47 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
6067 }
6068
6069 /**
6070 + * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness
6071 + * @phba: lpfc_hba pointer.
6072 + *
6073 + * Description:
6074 + * SLI4 interface type-2 device to wait on the sliport status register for
6075 + * the readyness after performing a firmware reset.
6076 + *
6077 + * Returns:
6078 + * zero for success
6079 + **/
6080 +static int
6081 +lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
6082 +{
6083 + struct lpfc_register portstat_reg;
6084 + int i;
6085 +
6086 +
6087 + lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
6088 + &portstat_reg.word0);
6089 +
6090 + /* wait for the SLI port firmware ready after firmware reset */
6091 + for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
6092 + msleep(10);
6093 + lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
6094 + &portstat_reg.word0);
6095 + if (!bf_get(lpfc_sliport_status_err, &portstat_reg))
6096 + continue;
6097 + if (!bf_get(lpfc_sliport_status_rn, &portstat_reg))
6098 + continue;
6099 + if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg))
6100 + continue;
6101 + break;
6102 + }
6103 +
6104 + if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT)
6105 + return 0;
6106 + else
6107 + return -EIO;
6108 +}
6109 +
6110 +/**
6111 * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc
6112 * @phba: lpfc_hba pointer.
6113 *
6114 @@ -805,7 +846,10 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
6115 readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
6116
6117 /* delay driver action following IF_TYPE_2 reset */
6118 - msleep(100);
6119 + rc = lpfc_sli4_pdev_status_reg_wait(phba);
6120 +
6121 + if (rc)
6122 + return -EIO;
6123
6124 init_completion(&online_compl);
6125 rc = lpfc_workq_post_event(phba, &status, &online_compl,
6126 @@ -895,6 +939,10 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
6127
6128 if (!phba->cfg_enable_hba_reset)
6129 return -EACCES;
6130 +
6131 + lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6132 + "3050 lpfc_board_mode set to %s\n", buf);
6133 +
6134 init_completion(&online_compl);
6135
6136 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
6137 @@ -1290,6 +1338,10 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr,
6138 if (phba->sli_rev == LPFC_SLI_REV4)
6139 val = 0;
6140
6141 + lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6142 + "3051 lpfc_poll changed from %d to %d\n",
6143 + phba->cfg_poll, val);
6144 +
6145 spin_lock_irq(&phba->hbalock);
6146
6147 old_val = phba->cfg_poll;
6148 @@ -1414,80 +1466,10 @@ lpfc_sriov_hw_max_virtfn_show(struct device *dev,
6149 struct Scsi_Host *shost = class_to_shost(dev);
6150 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
6151 struct lpfc_hba *phba = vport->phba;
6152 - struct pci_dev *pdev = phba->pcidev;
6153 - union lpfc_sli4_cfg_shdr *shdr;
6154 - uint32_t shdr_status, shdr_add_status;
6155 - LPFC_MBOXQ_t *mboxq;
6156 - struct lpfc_mbx_get_prof_cfg *get_prof_cfg;
6157 - struct lpfc_rsrc_desc_pcie *desc;
6158 - uint32_t max_nr_virtfn;
6159 - uint32_t desc_count;
6160 - int length, rc, i;
6161 -
6162 - if ((phba->sli_rev < LPFC_SLI_REV4) ||
6163 - (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
6164 - LPFC_SLI_INTF_IF_TYPE_2))
6165 - return -EPERM;
6166 -
6167 - if (!pdev->is_physfn)
6168 - return snprintf(buf, PAGE_SIZE, "%d\n", 0);
6169 -
6170 - mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
6171 - if (!mboxq)
6172 - return -ENOMEM;
6173 + uint16_t max_nr_virtfn;
6174
6175 - /* get the maximum number of virtfn support by physfn */
6176 - length = (sizeof(struct lpfc_mbx_get_prof_cfg) -
6177 - sizeof(struct lpfc_sli4_cfg_mhdr));
6178 - lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
6179 - LPFC_MBOX_OPCODE_GET_PROFILE_CONFIG,
6180 - length, LPFC_SLI4_MBX_EMBED);
6181 - shdr = (union lpfc_sli4_cfg_shdr *)
6182 - &mboxq->u.mqe.un.sli4_config.header.cfg_shdr;
6183 - bf_set(lpfc_mbox_hdr_pf_num, &shdr->request,
6184 - phba->sli4_hba.iov.pf_number + 1);
6185 -
6186 - get_prof_cfg = &mboxq->u.mqe.un.get_prof_cfg;
6187 - bf_set(lpfc_mbx_get_prof_cfg_prof_tp, &get_prof_cfg->u.request,
6188 - LPFC_CFG_TYPE_CURRENT_ACTIVE);
6189 -
6190 - rc = lpfc_sli_issue_mbox_wait(phba, mboxq,
6191 - lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG));
6192 -
6193 - if (rc != MBX_TIMEOUT) {
6194 - /* check return status */
6195 - shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
6196 - shdr_add_status = bf_get(lpfc_mbox_hdr_add_status,
6197 - &shdr->response);
6198 - if (shdr_status || shdr_add_status || rc)
6199 - goto error_out;
6200 -
6201 - } else
6202 - goto error_out;
6203 -
6204 - desc_count = get_prof_cfg->u.response.prof_cfg.rsrc_desc_count;
6205 -
6206 - for (i = 0; i < LPFC_RSRC_DESC_MAX_NUM; i++) {
6207 - desc = (struct lpfc_rsrc_desc_pcie *)
6208 - &get_prof_cfg->u.response.prof_cfg.desc[i];
6209 - if (LPFC_RSRC_DESC_TYPE_PCIE ==
6210 - bf_get(lpfc_rsrc_desc_pcie_type, desc)) {
6211 - max_nr_virtfn = bf_get(lpfc_rsrc_desc_pcie_nr_virtfn,
6212 - desc);
6213 - break;
6214 - }
6215 - }
6216 -
6217 - if (i < LPFC_RSRC_DESC_MAX_NUM) {
6218 - if (rc != MBX_TIMEOUT)
6219 - mempool_free(mboxq, phba->mbox_mem_pool);
6220 - return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
6221 - }
6222 -
6223 -error_out:
6224 - if (rc != MBX_TIMEOUT)
6225 - mempool_free(mboxq, phba->mbox_mem_pool);
6226 - return -EIO;
6227 + max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
6228 + return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
6229 }
6230
6231 /**
6232 @@ -1605,6 +1587,9 @@ static int \
6233 lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
6234 { \
6235 if (val >= minval && val <= maxval) {\
6236 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
6237 + "3052 lpfc_" #attr " changed from %d to %d\n", \
6238 + phba->cfg_##attr, val); \
6239 phba->cfg_##attr = val;\
6240 return 0;\
6241 }\
6242 @@ -1762,6 +1747,9 @@ static int \
6243 lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
6244 { \
6245 if (val >= minval && val <= maxval) {\
6246 + lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
6247 + "3053 lpfc_" #attr " changed from %d to %d\n", \
6248 + vport->cfg_##attr, val); \
6249 vport->cfg_##attr = val;\
6250 return 0;\
6251 }\
6252 @@ -2678,6 +2666,9 @@ lpfc_topology_store(struct device *dev, struct device_attribute *attr,
6253 if (nolip)
6254 return strlen(buf);
6255
6256 + lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6257 + "3054 lpfc_topology changed from %d to %d\n",
6258 + prev_val, val);
6259 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
6260 if (err) {
6261 phba->cfg_topology = prev_val;
6262 @@ -3101,6 +3092,10 @@ lpfc_link_speed_store(struct device *dev, struct device_attribute *attr,
6263 if (sscanf(val_buf, "%i", &val) != 1)
6264 return -EINVAL;
6265
6266 + lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6267 + "3055 lpfc_link_speed changed from %d to %d %s\n",
6268 + phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)");
6269 +
6270 if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
6271 ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
6272 ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
6273 @@ -3678,7 +3673,9 @@ LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
6274 # - Default will result in registering capabilities for all profiles.
6275 #
6276 */
6277 -unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION;
6278 +unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION |
6279 + SHOST_DIX_TYPE0_PROTECTION |
6280 + SHOST_DIX_TYPE1_PROTECTION;
6281
6282 module_param(lpfc_prot_mask, uint, S_IRUGO);
6283 MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask");
6284 diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
6285 index 7fb0ba4..f46378f 100644
6286 --- a/drivers/scsi/lpfc/lpfc_bsg.c
6287 +++ b/drivers/scsi/lpfc/lpfc_bsg.c
6288 @@ -960,8 +960,10 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
6289 evt_dat->immed_dat].oxid,
6290 phba->ct_ctx[
6291 evt_dat->immed_dat].SID);
6292 + phba->ct_ctx[evt_dat->immed_dat].rxid =
6293 + piocbq->iocb.ulpContext;
6294 phba->ct_ctx[evt_dat->immed_dat].oxid =
6295 - piocbq->iocb.ulpContext;
6296 + piocbq->iocb.unsli3.rcvsli3.ox_id;
6297 phba->ct_ctx[evt_dat->immed_dat].SID =
6298 piocbq->iocb.un.rcvels.remoteID;
6299 phba->ct_ctx[evt_dat->immed_dat].flags = UNSOL_VALID;
6300 @@ -1312,7 +1314,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6301 rc = IOCB_ERROR;
6302 goto issue_ct_rsp_exit;
6303 }
6304 - icmd->ulpContext = phba->ct_ctx[tag].oxid;
6305 + icmd->ulpContext = phba->ct_ctx[tag].rxid;
6306 + icmd->unsli3.rcvsli3.ox_id = phba->ct_ctx[tag].oxid;
6307 ndlp = lpfc_findnode_did(phba->pport, phba->ct_ctx[tag].SID);
6308 if (!ndlp) {
6309 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS,
6310 @@ -1337,9 +1340,7 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6311 goto issue_ct_rsp_exit;
6312 }
6313
6314 - icmd->un.ulpWord[3] = ndlp->nlp_rpi;
6315 - if (phba->sli_rev == LPFC_SLI_REV4)
6316 - icmd->ulpContext =
6317 + icmd->un.ulpWord[3] =
6318 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
6319
6320 /* The exchange is done, mark the entry as invalid */
6321 @@ -1351,8 +1352,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
6322
6323 /* Xmit CT response on exchange <xid> */
6324 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
6325 - "2722 Xmit CT response on exchange x%x Data: x%x x%x\n",
6326 - icmd->ulpContext, icmd->ulpIoTag, phba->link_state);
6327 + "2722 Xmit CT response on exchange x%x Data: x%x x%x x%x\n",
6328 + icmd->ulpContext, icmd->ulpIoTag, tag, phba->link_state);
6329
6330 ctiocb->iocb_cmpl = NULL;
6331 ctiocb->iocb_flag |= LPFC_IO_LIBDFC;
6332 @@ -1471,13 +1472,12 @@ send_mgmt_rsp_exit:
6333 /**
6334 * lpfc_bsg_diag_mode_enter - process preparing into device diag loopback mode
6335 * @phba: Pointer to HBA context object.
6336 - * @job: LPFC_BSG_VENDOR_DIAG_MODE
6337 *
6338 * This function is responsible for preparing driver for diag loopback
6339 * on device.
6340 */
6341 static int
6342 -lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
6343 +lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
6344 {
6345 struct lpfc_vport **vports;
6346 struct Scsi_Host *shost;
6347 @@ -1521,7 +1521,6 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
6348 /**
6349 * lpfc_bsg_diag_mode_exit - exit process from device diag loopback mode
6350 * @phba: Pointer to HBA context object.
6351 - * @job: LPFC_BSG_VENDOR_DIAG_MODE
6352 *
6353 * This function is responsible for driver exit processing of setting up
6354 * diag loopback mode on device.
6355 @@ -1586,7 +1585,7 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
6356 goto job_error;
6357 }
6358
6359 - rc = lpfc_bsg_diag_mode_enter(phba, job);
6360 + rc = lpfc_bsg_diag_mode_enter(phba);
6361 if (rc)
6362 goto job_error;
6363
6364 @@ -1758,7 +1757,7 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
6365 goto job_error;
6366 }
6367
6368 - rc = lpfc_bsg_diag_mode_enter(phba, job);
6369 + rc = lpfc_bsg_diag_mode_enter(phba);
6370 if (rc)
6371 goto job_error;
6372
6373 @@ -1982,7 +1981,7 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job)
6374 goto job_error;
6375 }
6376
6377 - rc = lpfc_bsg_diag_mode_enter(phba, job);
6378 + rc = lpfc_bsg_diag_mode_enter(phba);
6379 if (rc)
6380 goto job_error;
6381
6382 @@ -3511,7 +3510,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,