/[linux-patches]/genpatches-2.6/tags/3.0-30/1001_linux-3.0.2.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1001_linux-3.0.2.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: 200740 byte(s)
3.0-30 release
1 diff --git a/Makefile b/Makefile
2 index f124b18..794fa28 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 0
8 -SUBLEVEL = 1
9 +SUBLEVEL = 2
10 EXTRAVERSION =
11 NAME = Sneaky Weasel
12
13 diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
14 index 85026537..466af40 100644
15 --- a/arch/cris/arch-v10/drivers/sync_serial.c
16 +++ b/arch/cris/arch-v10/drivers/sync_serial.c
17 @@ -158,7 +158,7 @@ static int sync_serial_open(struct inode *inode, struct file *file);
18 static int sync_serial_release(struct inode *inode, struct file *file);
19 static unsigned int sync_serial_poll(struct file *filp, poll_table *wait);
20
21 -static int sync_serial_ioctl(struct file *file,
22 +static long sync_serial_ioctl(struct file *file,
23 unsigned int cmd, unsigned long arg);
24 static ssize_t sync_serial_write(struct file *file, const char *buf,
25 size_t count, loff_t *ppos);
26 @@ -625,11 +625,11 @@ static int sync_serial_open(struct inode *inode, struct file *file)
27 *R_IRQ_MASK1_SET = 1 << port->data_avail_bit;
28 DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev));
29 }
30 - ret = 0;
31 + err = 0;
32
33 out:
34 mutex_unlock(&sync_serial_mutex);
35 - return ret;
36 + return err;
37 }
38
39 static int sync_serial_release(struct inode *inode, struct file *file)
40 diff --git a/arch/cris/arch-v10/kernel/irq.c b/arch/cris/arch-v10/kernel/irq.c
41 index 907cfb5..ba0e596 100644
42 --- a/arch/cris/arch-v10/kernel/irq.c
43 +++ b/arch/cris/arch-v10/kernel/irq.c
44 @@ -20,6 +20,9 @@
45 #define crisv10_mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr));
46 #define crisv10_unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr));
47
48 +extern void kgdb_init(void);
49 +extern void breakpoint(void);
50 +
51 /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
52 * global just so that the kernel gdb can use it.
53 */
54 diff --git a/arch/cris/include/asm/thread_info.h b/arch/cris/include/asm/thread_info.h
55 index 29b74a1..332f19c 100644
56 --- a/arch/cris/include/asm/thread_info.h
57 +++ b/arch/cris/include/asm/thread_info.h
58 @@ -11,8 +11,6 @@
59
60 #ifdef __KERNEL__
61
62 -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
63 -
64 #ifndef __ASSEMBLY__
65 #include <asm/types.h>
66 #include <asm/processor.h>
67 @@ -67,8 +65,10 @@ struct thread_info {
68
69 #define init_thread_info (init_thread_union.thread_info)
70
71 +#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
72 /* thread information allocation */
73 -#define alloc_thread_info(tsk, node) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
74 +#define alloc_thread_info_node(tsk, node) \
75 + ((struct thread_info *) __get_free_pages(GFP_KERNEL, 1))
76 #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
77
78 #endif /* !__ASSEMBLY__ */
79 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
80 index f819559..26fd114 100644
81 --- a/arch/parisc/include/asm/atomic.h
82 +++ b/arch/parisc/include/asm/atomic.h
83 @@ -259,10 +259,10 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
84
85 #define ATOMIC64_INIT(i) ((atomic64_t) { (i) })
86
87 -static __inline__ int
88 +static __inline__ s64
89 __atomic64_add_return(s64 i, atomic64_t *v)
90 {
91 - int ret;
92 + s64 ret;
93 unsigned long flags;
94 _atomic_spin_lock_irqsave(v, flags);
95
96 diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h
97 index 67a33cc..2388bdb 100644
98 --- a/arch/parisc/include/asm/futex.h
99 +++ b/arch/parisc/include/asm/futex.h
100 @@ -5,11 +5,14 @@
101
102 #include <linux/futex.h>
103 #include <linux/uaccess.h>
104 +#include <asm/atomic.h>
105 #include <asm/errno.h>
106
107 static inline int
108 futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
109 {
110 + unsigned long int flags;
111 + u32 val;
112 int op = (encoded_op >> 28) & 7;
113 int cmp = (encoded_op >> 24) & 15;
114 int oparg = (encoded_op << 8) >> 20;
115 @@ -18,21 +21,58 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
116 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
117 oparg = 1 << oparg;
118
119 - if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32)))
120 + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr)))
121 return -EFAULT;
122
123 pagefault_disable();
124
125 + _atomic_spin_lock_irqsave(uaddr, flags);
126 +
127 switch (op) {
128 case FUTEX_OP_SET:
129 + /* *(int *)UADDR2 = OPARG; */
130 + ret = get_user(oldval, uaddr);
131 + if (!ret)
132 + ret = put_user(oparg, uaddr);
133 + break;
134 case FUTEX_OP_ADD:
135 + /* *(int *)UADDR2 += OPARG; */
136 + ret = get_user(oldval, uaddr);
137 + if (!ret) {
138 + val = oldval + oparg;
139 + ret = put_user(val, uaddr);
140 + }
141 + break;
142 case FUTEX_OP_OR:
143 + /* *(int *)UADDR2 |= OPARG; */
144 + ret = get_user(oldval, uaddr);
145 + if (!ret) {
146 + val = oldval | oparg;
147 + ret = put_user(val, uaddr);
148 + }
149 + break;
150 case FUTEX_OP_ANDN:
151 + /* *(int *)UADDR2 &= ~OPARG; */
152 + ret = get_user(oldval, uaddr);
153 + if (!ret) {
154 + val = oldval & ~oparg;
155 + ret = put_user(val, uaddr);
156 + }
157 + break;
158 case FUTEX_OP_XOR:
159 + /* *(int *)UADDR2 ^= OPARG; */
160 + ret = get_user(oldval, uaddr);
161 + if (!ret) {
162 + val = oldval ^ oparg;
163 + ret = put_user(val, uaddr);
164 + }
165 + break;
166 default:
167 ret = -ENOSYS;
168 }
169
170 + _atomic_spin_unlock_irqrestore(uaddr, flags);
171 +
172 pagefault_enable();
173
174 if (!ret) {
175 @@ -54,7 +94,9 @@ static inline int
176 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
177 u32 oldval, u32 newval)
178 {
179 + int ret;
180 u32 val;
181 + unsigned long flags;
182
183 /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
184 * our gateway page, and causes no end of trouble...
185 @@ -65,12 +107,24 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
186 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
187 return -EFAULT;
188
189 - if (get_user(val, uaddr))
190 - return -EFAULT;
191 - if (val == oldval && put_user(newval, uaddr))
192 - return -EFAULT;
193 + /* HPPA has no cmpxchg in hardware and therefore the
194 + * best we can do here is use an array of locks. The
195 + * lock selected is based on a hash of the userspace
196 + * address. This should scale to a couple of CPUs.
197 + */
198 +
199 + _atomic_spin_lock_irqsave(uaddr, flags);
200 +
201 + ret = get_user(val, uaddr);
202 +
203 + if (!ret && val == oldval)
204 + ret = put_user(newval, uaddr);
205 +
206 *uval = val;
207 - return 0;
208 +
209 + _atomic_spin_unlock_irqrestore(uaddr, flags);
210 +
211 + return ret;
212 }
213
214 #endif /*__KERNEL__*/
215 diff --git a/arch/parisc/include/asm/unistd.h b/arch/parisc/include/asm/unistd.h
216 index 3392de3..d61de64 100644
217 --- a/arch/parisc/include/asm/unistd.h
218 +++ b/arch/parisc/include/asm/unistd.h
219 @@ -821,8 +821,9 @@
220 #define __NR_open_by_handle_at (__NR_Linux + 326)
221 #define __NR_syncfs (__NR_Linux + 327)
222 #define __NR_setns (__NR_Linux + 328)
223 +#define __NR_sendmmsg (__NR_Linux + 329)
224
225 -#define __NR_Linux_syscalls (__NR_setns + 1)
226 +#define __NR_Linux_syscalls (__NR_sendmmsg + 1)
227
228
229 #define __IGNORE_select /* newselect */
230 diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
231 index 34a4f5a..e66366f 100644
232 --- a/arch/parisc/kernel/syscall_table.S
233 +++ b/arch/parisc/kernel/syscall_table.S
234 @@ -427,6 +427,7 @@
235 ENTRY_COMP(open_by_handle_at)
236 ENTRY_SAME(syncfs)
237 ENTRY_SAME(setns)
238 + ENTRY_COMP(sendmmsg)
239
240 /* Nothing yet */
241
242 diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
243 index c016033..3b22142 100644
244 --- a/arch/powerpc/kernel/prom_init.c
245 +++ b/arch/powerpc/kernel/prom_init.c
246 @@ -1020,7 +1020,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
247 }
248 if (addr == 0)
249 return 0;
250 - RELOC(alloc_bottom) = addr;
251 + RELOC(alloc_bottom) = addr + size;
252
253 prom_debug(" -> %x\n", addr);
254 prom_debug(" alloc_bottom : %x\n", RELOC(alloc_bottom));
255 @@ -1834,7 +1834,7 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
256 chunk = alloc_up(room, 0);
257 if (chunk == 0)
258 prom_panic("No memory for flatten_device_tree (claim failed)");
259 - *mem_end = RELOC(alloc_top);
260 + *mem_end = chunk + room;
261 }
262
263 ret = (void *)*mem_start;
264 @@ -2053,7 +2053,7 @@ static void __init flatten_device_tree(void)
265 mem_start = (unsigned long)alloc_up(room, PAGE_SIZE);
266 if (mem_start == 0)
267 prom_panic("Can't allocate initial device-tree chunk\n");
268 - mem_end = RELOC(alloc_top);
269 + mem_end = mem_start + room;
270
271 /* Get root of tree */
272 root = call_prom("peer", 1, 1, (phandle)0);
273 diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
274 index e919007..0e86563 100644
275 --- a/arch/powerpc/platforms/pseries/dtl.c
276 +++ b/arch/powerpc/platforms/pseries/dtl.c
277 @@ -181,7 +181,7 @@ static void dtl_stop(struct dtl *dtl)
278
279 lppaca_of(dtl->cpu).dtl_enable_mask = 0x0;
280
281 - unregister_dtl(hwcpu, __pa(dtl->buf));
282 + unregister_dtl(hwcpu);
283 }
284
285 static u64 dtl_current_index(struct dtl *dtl)
286 diff --git a/arch/powerpc/platforms/pseries/kexec.c b/arch/powerpc/platforms/pseries/kexec.c
287 index 54cf3a4..1118cb7 100644
288 --- a/arch/powerpc/platforms/pseries/kexec.c
289 +++ b/arch/powerpc/platforms/pseries/kexec.c
290 @@ -26,6 +26,17 @@ static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
291 /* Don't risk a hypervisor call if we're crashing */
292 if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
293 unsigned long addr;
294 + int ret;
295 +
296 + if (get_lppaca()->dtl_enable_mask) {
297 + ret = unregister_dtl(hard_smp_processor_id());
298 + if (ret) {
299 + pr_err("WARNING: DTL deregistration for cpu "
300 + "%d (hw %d) failed with %d\n",
301 + smp_processor_id(),
302 + hard_smp_processor_id(), ret);
303 + }
304 + }
305
306 addr = __pa(get_slb_shadow());
307 if (unregister_slb_shadow(hard_smp_processor_id(), addr))
308 diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
309 index 39e6e0a..ed96b37 100644
310 --- a/arch/powerpc/platforms/pseries/lpar.c
311 +++ b/arch/powerpc/platforms/pseries/lpar.c
312 @@ -395,7 +395,7 @@ static void pSeries_lpar_hptab_clear(void)
313 unsigned long ptel;
314 } ptes[4];
315 long lpar_rc;
316 - int i, j;
317 + unsigned long i, j;
318
319 /* Read in batches of 4,
320 * invalidate only valid entries not in the VRMA
321 diff --git a/arch/powerpc/platforms/pseries/plpar_wrappers.h b/arch/powerpc/platforms/pseries/plpar_wrappers.h
322 index 4bf2120..a6921ae 100644
323 --- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
324 +++ b/arch/powerpc/platforms/pseries/plpar_wrappers.h
325 @@ -73,9 +73,9 @@ static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
326 return vpa_call(0x3, cpu, vpa);
327 }
328
329 -static inline long unregister_dtl(unsigned long cpu, unsigned long vpa)
330 +static inline long unregister_dtl(unsigned long cpu)
331 {
332 - return vpa_call(0x6, cpu, vpa);
333 + return vpa_call(0x6, cpu, 0);
334 }
335
336 static inline long register_dtl(unsigned long cpu, unsigned long vpa)
337 diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
338 index 38e9aa1..3fc595a 100644
339 --- a/arch/sparc/include/asm/bitops_64.h
340 +++ b/arch/sparc/include/asm/bitops_64.h
341 @@ -26,61 +26,28 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);
342 #define smp_mb__before_clear_bit() barrier()
343 #define smp_mb__after_clear_bit() barrier()
344
345 -#include <asm-generic/bitops/ffz.h>
346 -#include <asm-generic/bitops/__ffs.h>
347 #include <asm-generic/bitops/fls.h>
348 #include <asm-generic/bitops/__fls.h>
349 #include <asm-generic/bitops/fls64.h>
350
351 #ifdef __KERNEL__
352
353 +extern int ffs(int x);
354 +extern unsigned long __ffs(unsigned long);
355 +
356 +#include <asm-generic/bitops/ffz.h>
357 #include <asm-generic/bitops/sched.h>
358 -#include <asm-generic/bitops/ffs.h>
359
360 /*
361 * hweightN: returns the hamming weight (i.e. the number
362 * of bits set) of a N-bit word
363 */
364
365 -#ifdef ULTRA_HAS_POPULATION_COUNT
366 -
367 -static inline unsigned int __arch_hweight64(unsigned long w)
368 -{
369 - unsigned int res;
370 -
371 - __asm__ ("popc %1,%0" : "=r" (res) : "r" (w));
372 - return res;
373 -}
374 -
375 -static inline unsigned int __arch_hweight32(unsigned int w)
376 -{
377 - unsigned int res;
378 -
379 - __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff));
380 - return res;
381 -}
382 +extern unsigned long __arch_hweight64(__u64 w);
383 +extern unsigned int __arch_hweight32(unsigned int w);
384 +extern unsigned int __arch_hweight16(unsigned int w);
385 +extern unsigned int __arch_hweight8(unsigned int w);
386
387 -static inline unsigned int __arch_hweight16(unsigned int w)
388 -{
389 - unsigned int res;
390 -
391 - __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff));
392 - return res;
393 -}
394 -
395 -static inline unsigned int __arch_hweight8(unsigned int w)
396 -{
397 - unsigned int res;
398 -
399 - __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff));
400 - return res;
401 -}
402 -
403 -#else
404 -
405 -#include <asm-generic/bitops/arch_hweight.h>
406 -
407 -#endif
408 #include <asm-generic/bitops/const_hweight.h>
409 #include <asm-generic/bitops/lock.h>
410 #endif /* __KERNEL__ */
411 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
412 index e678803..7df8b7f 100644
413 --- a/arch/sparc/include/asm/elf_64.h
414 +++ b/arch/sparc/include/asm/elf_64.h
415 @@ -59,15 +59,33 @@
416 #define R_SPARC_6 45
417
418 /* Bits present in AT_HWCAP, primarily for Sparc32. */
419 -
420 -#define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */
421 -#define HWCAP_SPARC_STBAR 2
422 -#define HWCAP_SPARC_SWAP 4
423 -#define HWCAP_SPARC_MULDIV 8
424 -#define HWCAP_SPARC_V9 16
425 -#define HWCAP_SPARC_ULTRA3 32
426 -#define HWCAP_SPARC_BLKINIT 64
427 -#define HWCAP_SPARC_N2 128
428 +#define HWCAP_SPARC_FLUSH 0x00000001
429 +#define HWCAP_SPARC_STBAR 0x00000002
430 +#define HWCAP_SPARC_SWAP 0x00000004
431 +#define HWCAP_SPARC_MULDIV 0x00000008
432 +#define HWCAP_SPARC_V9 0x00000010
433 +#define HWCAP_SPARC_ULTRA3 0x00000020
434 +#define HWCAP_SPARC_BLKINIT 0x00000040
435 +#define HWCAP_SPARC_N2 0x00000080
436 +
437 +/* Solaris compatible AT_HWCAP bits. */
438 +#define AV_SPARC_MUL32 0x00000100 /* 32x32 multiply is efficient */
439 +#define AV_SPARC_DIV32 0x00000200 /* 32x32 divide is efficient */
440 +#define AV_SPARC_FSMULD 0x00000400 /* 'fsmuld' is efficient */
441 +#define AV_SPARC_V8PLUS 0x00000800 /* v9 insn available to 32bit */
442 +#define AV_SPARC_POPC 0x00001000 /* 'popc' is efficient */
443 +#define AV_SPARC_VIS 0x00002000 /* VIS insns available */
444 +#define AV_SPARC_VIS2 0x00004000 /* VIS2 insns available */
445 +#define AV_SPARC_ASI_BLK_INIT 0x00008000 /* block init ASIs available */
446 +#define AV_SPARC_FMAF 0x00010000 /* fused multiply-add */
447 +#define AV_SPARC_VIS3 0x00020000 /* VIS3 insns available */
448 +#define AV_SPARC_HPC 0x00040000 /* HPC insns available */
449 +#define AV_SPARC_RANDOM 0x00080000 /* 'random' insn available */
450 +#define AV_SPARC_TRANS 0x00100000 /* transaction insns available */
451 +#define AV_SPARC_FJFMAU 0x00200000 /* unfused multiply-add */
452 +#define AV_SPARC_IMA 0x00400000 /* integer multiply-add */
453 +#define AV_SPARC_ASI_CACHE_SPARING \
454 + 0x00800000 /* cache sparing ASIs available */
455
456 #define CORE_DUMP_USE_REGSET
457
458 @@ -162,31 +180,8 @@ typedef struct {
459 #define ELF_ET_DYN_BASE 0x0000010000000000UL
460 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
461
462 -
463 -/* This yields a mask that user programs can use to figure out what
464 - instruction set this cpu supports. */
465 -
466 -/* On Ultra, we support all of the v8 capabilities. */
467 -static inline unsigned int sparc64_elf_hwcap(void)
468 -{
469 - unsigned int cap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
470 - HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
471 - HWCAP_SPARC_V9);
472 -
473 - if (tlb_type == cheetah || tlb_type == cheetah_plus)
474 - cap |= HWCAP_SPARC_ULTRA3;
475 - else if (tlb_type == hypervisor) {
476 - if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
477 - sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
478 - cap |= HWCAP_SPARC_BLKINIT;
479 - if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
480 - cap |= HWCAP_SPARC_N2;
481 - }
482 -
483 - return cap;
484 -}
485 -
486 -#define ELF_HWCAP sparc64_elf_hwcap();
487 +extern unsigned long sparc64_elf_hwcap;
488 +#define ELF_HWCAP sparc64_elf_hwcap
489
490 /* This yields a string that ld.so will use to load implementation
491 specific libraries for optimization. This is more specific in
492 diff --git a/arch/sparc/include/asm/hypervisor.h b/arch/sparc/include/asm/hypervisor.h
493 index 7568640..015a761 100644
494 --- a/arch/sparc/include/asm/hypervisor.h
495 +++ b/arch/sparc/include/asm/hypervisor.h
496 @@ -2927,6 +2927,13 @@ extern unsigned long sun4v_ncs_request(unsigned long request,
497 #define HV_FAST_FIRE_GET_PERFREG 0x120
498 #define HV_FAST_FIRE_SET_PERFREG 0x121
499
500 +#define HV_FAST_REBOOT_DATA_SET 0x172
501 +
502 +#ifndef __ASSEMBLY__
503 +extern unsigned long sun4v_reboot_data_set(unsigned long ra,
504 + unsigned long len);
505 +#endif
506 +
507 /* Function numbers for HV_CORE_TRAP. */
508 #define HV_CORE_SET_VER 0x00
509 #define HV_CORE_PUTCHAR 0x01
510 @@ -2940,16 +2947,23 @@ extern unsigned long sun4v_ncs_request(unsigned long request,
511 #define HV_GRP_CORE 0x0001
512 #define HV_GRP_INTR 0x0002
513 #define HV_GRP_SOFT_STATE 0x0003
514 +#define HV_GRP_TM 0x0080
515 #define HV_GRP_PCI 0x0100
516 #define HV_GRP_LDOM 0x0101
517 #define HV_GRP_SVC_CHAN 0x0102
518 #define HV_GRP_NCS 0x0103
519 #define HV_GRP_RNG 0x0104
520 +#define HV_GRP_PBOOT 0x0105
521 +#define HV_GRP_TPM 0x0107
522 +#define HV_GRP_SDIO 0x0108
523 +#define HV_GRP_SDIO_ERR 0x0109
524 +#define HV_GRP_REBOOT_DATA 0x0110
525 #define HV_GRP_NIAG_PERF 0x0200
526 #define HV_GRP_FIRE_PERF 0x0201
527 #define HV_GRP_N2_CPU 0x0202
528 #define HV_GRP_NIU 0x0204
529 #define HV_GRP_VF_CPU 0x0205
530 +#define HV_GRP_KT_CPU 0x0209
531 #define HV_GRP_DIAG 0x0300
532
533 #ifndef __ASSEMBLY__
534 diff --git a/arch/sparc/include/asm/spitfire.h b/arch/sparc/include/asm/spitfire.h
535 index f0d0c40..55a17c6 100644
536 --- a/arch/sparc/include/asm/spitfire.h
537 +++ b/arch/sparc/include/asm/spitfire.h
538 @@ -42,6 +42,7 @@
539 #define SUN4V_CHIP_INVALID 0x00
540 #define SUN4V_CHIP_NIAGARA1 0x01
541 #define SUN4V_CHIP_NIAGARA2 0x02
542 +#define SUN4V_CHIP_NIAGARA3 0x03
543 #define SUN4V_CHIP_UNKNOWN 0xff
544
545 #ifndef __ASSEMBLY__
546 diff --git a/arch/sparc/include/asm/tsb.h b/arch/sparc/include/asm/tsb.h
547 index 83c571d..1a8afd1 100644
548 --- a/arch/sparc/include/asm/tsb.h
549 +++ b/arch/sparc/include/asm/tsb.h
550 @@ -133,29 +133,6 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
551 sub TSB, 0x8, TSB; \
552 TSB_STORE(TSB, TAG);
553
554 -#define KTSB_LOAD_QUAD(TSB, REG) \
555 - ldda [TSB] ASI_NUCLEUS_QUAD_LDD, REG;
556 -
557 -#define KTSB_STORE(ADDR, VAL) \
558 - stxa VAL, [ADDR] ASI_N;
559 -
560 -#define KTSB_LOCK_TAG(TSB, REG1, REG2) \
561 -99: lduwa [TSB] ASI_N, REG1; \
562 - sethi %hi(TSB_TAG_LOCK_HIGH), REG2;\
563 - andcc REG1, REG2, %g0; \
564 - bne,pn %icc, 99b; \
565 - nop; \
566 - casa [TSB] ASI_N, REG1, REG2;\
567 - cmp REG1, REG2; \
568 - bne,pn %icc, 99b; \
569 - nop; \
570 -
571 -#define KTSB_WRITE(TSB, TTE, TAG) \
572 - add TSB, 0x8, TSB; \
573 - stxa TTE, [TSB] ASI_N; \
574 - sub TSB, 0x8, TSB; \
575 - stxa TAG, [TSB] ASI_N;
576 -
577 /* Do a kernel page table walk. Leaves physical PTE pointer in
578 * REG1. Jumps to FAIL_LABEL on early page table walk termination.
579 * VADDR will not be clobbered, but REG2 will.
580 @@ -239,6 +216,8 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
581 (KERNEL_TSB_SIZE_BYTES / 16)
582 #define KERNEL_TSB4M_NENTRIES 4096
583
584 +#define KTSB_PHYS_SHIFT 15
585 +
586 /* Do a kernel TSB lookup at tl>0 on VADDR+TAG, branch to OK_LABEL
587 * on TSB hit. REG1, REG2, REG3, and REG4 are used as temporaries
588 * and the found TTE will be left in REG1. REG3 and REG4 must
589 @@ -247,13 +226,22 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
590 * VADDR and TAG will be preserved and not clobbered by this macro.
591 */
592 #define KERN_TSB_LOOKUP_TL1(VADDR, TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
593 - sethi %hi(swapper_tsb), REG1; \
594 +661: sethi %hi(swapper_tsb), REG1; \
595 or REG1, %lo(swapper_tsb), REG1; \
596 + .section .swapper_tsb_phys_patch, "ax"; \
597 + .word 661b; \
598 + .previous; \
599 +661: nop; \
600 + .section .tsb_ldquad_phys_patch, "ax"; \
601 + .word 661b; \
602 + sllx REG1, KTSB_PHYS_SHIFT, REG1; \
603 + sllx REG1, KTSB_PHYS_SHIFT, REG1; \
604 + .previous; \
605 srlx VADDR, PAGE_SHIFT, REG2; \
606 and REG2, (KERNEL_TSB_NENTRIES - 1), REG2; \
607 sllx REG2, 4, REG2; \
608 add REG1, REG2, REG2; \
609 - KTSB_LOAD_QUAD(REG2, REG3); \
610 + TSB_LOAD_QUAD(REG2, REG3); \
611 cmp REG3, TAG; \
612 be,a,pt %xcc, OK_LABEL; \
613 mov REG4, REG1;
614 @@ -263,12 +251,21 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
615 * we can make use of that for the index computation.
616 */
617 #define KERN_TSB4M_LOOKUP_TL1(TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
618 - sethi %hi(swapper_4m_tsb), REG1; \
619 +661: sethi %hi(swapper_4m_tsb), REG1; \
620 or REG1, %lo(swapper_4m_tsb), REG1; \
621 + .section .swapper_4m_tsb_phys_patch, "ax"; \
622 + .word 661b; \
623 + .previous; \
624 +661: nop; \
625 + .section .tsb_ldquad_phys_patch, "ax"; \
626 + .word 661b; \
627 + sllx REG1, KTSB_PHYS_SHIFT, REG1; \
628 + sllx REG1, KTSB_PHYS_SHIFT, REG1; \
629 + .previous; \
630 and TAG, (KERNEL_TSB4M_NENTRIES - 1), REG2; \
631 sllx REG2, 4, REG2; \
632 add REG1, REG2, REG2; \
633 - KTSB_LOAD_QUAD(REG2, REG3); \
634 + TSB_LOAD_QUAD(REG2, REG3); \
635 cmp REG3, TAG; \
636 be,a,pt %xcc, OK_LABEL; \
637 mov REG4, REG1;
638 diff --git a/arch/sparc/include/asm/xor_64.h b/arch/sparc/include/asm/xor_64.h
639 index bee4bf4..9ed6ff6 100644
640 --- a/arch/sparc/include/asm/xor_64.h
641 +++ b/arch/sparc/include/asm/xor_64.h
642 @@ -65,6 +65,7 @@ static struct xor_block_template xor_block_niagara = {
643 #define XOR_SELECT_TEMPLATE(FASTEST) \
644 ((tlb_type == hypervisor && \
645 (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \
646 - sun4v_chip_type == SUN4V_CHIP_NIAGARA2)) ? \
647 + sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \
648 + sun4v_chip_type == SUN4V_CHIP_NIAGARA3)) ? \
649 &xor_block_niagara : \
650 &xor_block_VIS)
651 diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
652 index 138dbbc..9810fd8 100644
653 --- a/arch/sparc/kernel/cpu.c
654 +++ b/arch/sparc/kernel/cpu.c
655 @@ -396,6 +396,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
656 , cpu_data(0).clock_tick
657 #endif
658 );
659 + cpucap_info(m);
660 #ifdef CONFIG_SMP
661 smp_bogo(m);
662 #endif
663 @@ -474,11 +475,18 @@ static void __init sun4v_cpu_probe(void)
664 sparc_pmu_type = "niagara2";
665 break;
666
667 + case SUN4V_CHIP_NIAGARA3:
668 + sparc_cpu_type = "UltraSparc T3 (Niagara3)";
669 + sparc_fpu_type = "UltraSparc T3 integrated FPU";
670 + sparc_pmu_type = "niagara3";
671 + break;
672 +
673 default:
674 printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
675 prom_cpu_compatible);
676 sparc_cpu_type = "Unknown SUN4V CPU";
677 sparc_fpu_type = "Unknown SUN4V FPU";
678 + sparc_pmu_type = "Unknown SUN4V PMU";
679 break;
680 }
681 }
682 diff --git a/arch/sparc/kernel/cpumap.c b/arch/sparc/kernel/cpumap.c
683 index d91fd78..4197e8d 100644
684 --- a/arch/sparc/kernel/cpumap.c
685 +++ b/arch/sparc/kernel/cpumap.c
686 @@ -324,6 +324,7 @@ static int iterate_cpu(struct cpuinfo_tree *t, unsigned int root_index)
687 switch (sun4v_chip_type) {
688 case SUN4V_CHIP_NIAGARA1:
689 case SUN4V_CHIP_NIAGARA2:
690 + case SUN4V_CHIP_NIAGARA3:
691 rover_inc_table = niagara_iterate_method;
692 break;
693 default:
694 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
695 index dd1342c..7429b47 100644
696 --- a/arch/sparc/kernel/ds.c
697 +++ b/arch/sparc/kernel/ds.c
698 @@ -15,12 +15,15 @@
699 #include <linux/reboot.h>
700 #include <linux/cpu.h>
701
702 +#include <asm/hypervisor.h>
703 #include <asm/ldc.h>
704 #include <asm/vio.h>
705 #include <asm/mdesc.h>
706 #include <asm/head.h>
707 #include <asm/irq.h>
708
709 +#include "kernel.h"
710 +
711 #define DRV_MODULE_NAME "ds"
712 #define PFX DRV_MODULE_NAME ": "
713 #define DRV_MODULE_VERSION "1.0"
714 @@ -828,18 +831,32 @@ void ldom_set_var(const char *var, const char *value)
715 }
716 }
717
718 +static char full_boot_str[256] __attribute__((aligned(32)));
719 +static int reboot_data_supported;
720 +
721 void ldom_reboot(const char *boot_command)
722 {
723 /* Don't bother with any of this if the boot_command
724 * is empty.
725 */
726 if (boot_command && strlen(boot_command)) {
727 - char full_boot_str[256];
728 + unsigned long len;
729
730 strcpy(full_boot_str, "boot ");
731 strcpy(full_boot_str + strlen("boot "), boot_command);
732 + len = strlen(full_boot_str);
733
734 - ldom_set_var("reboot-command", full_boot_str);
735 + if (reboot_data_supported) {
736 + unsigned long ra = kimage_addr_to_ra(full_boot_str);
737 + unsigned long hv_ret;
738 +
739 + hv_ret = sun4v_reboot_data_set(ra, len);
740 + if (hv_ret != HV_EOK)
741 + pr_err("SUN4V: Unable to set reboot data "
742 + "hv_ret=%lu\n", hv_ret);
743 + } else {
744 + ldom_set_var("reboot-command", full_boot_str);
745 + }
746 }
747 sun4v_mach_sir();
748 }
749 @@ -1237,6 +1254,16 @@ static struct vio_driver ds_driver = {
750
751 static int __init ds_init(void)
752 {
753 + unsigned long hv_ret, major, minor;
754 +
755 + if (tlb_type == hypervisor) {
756 + hv_ret = sun4v_get_version(HV_GRP_REBOOT_DATA, &major, &minor);
757 + if (hv_ret == HV_EOK) {
758 + pr_info("SUN4V: Reboot data supported (maj=%lu,min=%lu).\n",
759 + major, minor);
760 + reboot_data_supported = 1;
761 + }
762 + }
763 kthread_run(ds_thread, NULL, "kldomd");
764
765 return vio_register_driver(&ds_driver);
766 diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
767 index d1f1361..e27f8ea 100644
768 --- a/arch/sparc/kernel/entry.h
769 +++ b/arch/sparc/kernel/entry.h
770 @@ -42,6 +42,20 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
771 extern void fpload(unsigned long *fpregs, unsigned long *fsr);
772
773 #else /* CONFIG_SPARC32 */
774 +struct popc_3insn_patch_entry {
775 + unsigned int addr;
776 + unsigned int insns[3];
777 +};
778 +extern struct popc_3insn_patch_entry __popc_3insn_patch,
779 + __popc_3insn_patch_end;
780 +
781 +struct popc_6insn_patch_entry {
782 + unsigned int addr;
783 + unsigned int insns[6];
784 +};
785 +extern struct popc_6insn_patch_entry __popc_6insn_patch,
786 + __popc_6insn_patch_end;
787 +
788 extern void __init per_cpu_patch(void);
789 extern void __init sun4v_patch(void);
790 extern void __init boot_cpu_id_too_large(int cpu);
791 diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
792 index aa594c7..0cbab31 100644
793 --- a/arch/sparc/kernel/head_64.S
794 +++ b/arch/sparc/kernel/head_64.S
795 @@ -132,6 +132,8 @@ prom_sun4v_name:
796 .asciz "sun4v"
797 prom_niagara_prefix:
798 .asciz "SUNW,UltraSPARC-T"
799 +prom_sparc_prefix:
800 + .asciz "SPARC-T"
801 .align 4
802 prom_root_compatible:
803 .skip 64
804 @@ -382,6 +384,22 @@ sun4v_chip_type:
805 90: ldub [%g7], %g2
806 ldub [%g1], %g4
807 cmp %g2, %g4
808 + bne,pn %icc, 89f
809 + add %g7, 1, %g7
810 + subcc %g3, 1, %g3
811 + bne,pt %xcc, 90b
812 + add %g1, 1, %g1
813 + ba,pt %xcc, 91f
814 + nop
815 +
816 +89: sethi %hi(prom_cpu_compatible), %g1
817 + or %g1, %lo(prom_cpu_compatible), %g1
818 + sethi %hi(prom_sparc_prefix), %g7
819 + or %g7, %lo(prom_sparc_prefix), %g7
820 + mov 7, %g3
821 +90: ldub [%g7], %g2
822 + ldub [%g1], %g4
823 + cmp %g2, %g4
824 bne,pn %icc, 4f
825 add %g7, 1, %g7
826 subcc %g3, 1, %g3
827 @@ -390,6 +408,15 @@ sun4v_chip_type:
828
829 sethi %hi(prom_cpu_compatible), %g1
830 or %g1, %lo(prom_cpu_compatible), %g1
831 + ldub [%g1 + 7], %g2
832 + cmp %g2, '3'
833 + be,pt %xcc, 5f
834 + mov SUN4V_CHIP_NIAGARA3, %g4
835 + ba,pt %xcc, 4f
836 + nop
837 +
838 +91: sethi %hi(prom_cpu_compatible), %g1
839 + or %g1, %lo(prom_cpu_compatible), %g1
840 ldub [%g1 + 17], %g2
841 cmp %g2, '1'
842 be,pt %xcc, 5f
843 @@ -397,6 +424,7 @@ sun4v_chip_type:
844 cmp %g2, '2'
845 be,pt %xcc, 5f
846 mov SUN4V_CHIP_NIAGARA2, %g4
847 +
848 4:
849 mov SUN4V_CHIP_UNKNOWN, %g4
850 5: sethi %hi(sun4v_chip_type), %g2
851 @@ -514,6 +542,9 @@ niagara_tlb_fixup:
852 cmp %g1, SUN4V_CHIP_NIAGARA2
853 be,pt %xcc, niagara2_patch
854 nop
855 + cmp %g1, SUN4V_CHIP_NIAGARA3
856 + be,pt %xcc, niagara2_patch
857 + nop
858
859 call generic_patch_copyops
860 nop
861 @@ -528,7 +559,7 @@ niagara2_patch:
862 nop
863 call niagara_patch_bzero
864 nop
865 - call niagara2_patch_pageops
866 + call niagara_patch_pageops
867 nop
868
869 ba,a,pt %xcc, 80f
870 diff --git a/arch/sparc/kernel/hvapi.c b/arch/sparc/kernel/hvapi.c
871 index 7c60afb..c2d055d 100644
872 --- a/arch/sparc/kernel/hvapi.c
873 +++ b/arch/sparc/kernel/hvapi.c
874 @@ -28,16 +28,23 @@ static struct api_info api_table[] = {
875 { .group = HV_GRP_CORE, .flags = FLAG_PRE_API },
876 { .group = HV_GRP_INTR, },
877 { .group = HV_GRP_SOFT_STATE, },
878 + { .group = HV_GRP_TM, },
879 { .group = HV_GRP_PCI, .flags = FLAG_PRE_API },
880 { .group = HV_GRP_LDOM, },
881 { .group = HV_GRP_SVC_CHAN, .flags = FLAG_PRE_API },
882 { .group = HV_GRP_NCS, .flags = FLAG_PRE_API },
883 { .group = HV_GRP_RNG, },
884 + { .group = HV_GRP_PBOOT, },
885 + { .group = HV_GRP_TPM, },
886 + { .group = HV_GRP_SDIO, },
887 + { .group = HV_GRP_SDIO_ERR, },
888 + { .group = HV_GRP_REBOOT_DATA, },
889 { .group = HV_GRP_NIAG_PERF, .flags = FLAG_PRE_API },
890 { .group = HV_GRP_FIRE_PERF, },
891 { .group = HV_GRP_N2_CPU, },
892 { .group = HV_GRP_NIU, },
893 { .group = HV_GRP_VF_CPU, },
894 + { .group = HV_GRP_KT_CPU, },
895 { .group = HV_GRP_DIAG, .flags = FLAG_PRE_API },
896 };
897
898 diff --git a/arch/sparc/kernel/hvcalls.S b/arch/sparc/kernel/hvcalls.S
899 index 8a5f35f..58d60de 100644
900 --- a/arch/sparc/kernel/hvcalls.S
901 +++ b/arch/sparc/kernel/hvcalls.S
902 @@ -798,3 +798,10 @@ ENTRY(sun4v_niagara2_setperf)
903 retl
904 nop
905 ENDPROC(sun4v_niagara2_setperf)
906 +
907 +ENTRY(sun4v_reboot_data_set)
908 + mov HV_FAST_REBOOT_DATA_SET, %o5
909 + ta HV_FAST_TRAP
910 + retl
911 + nop
912 +ENDPROC(sun4v_reboot_data_set)
913 diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
914 index 6f6544c..fd6c36b 100644
915 --- a/arch/sparc/kernel/kernel.h
916 +++ b/arch/sparc/kernel/kernel.h
917 @@ -4,12 +4,27 @@
918 #include <linux/interrupt.h>
919
920 #include <asm/traps.h>
921 +#include <asm/head.h>
922 +#include <asm/io.h>
923
924 /* cpu.c */
925 extern const char *sparc_pmu_type;
926 extern unsigned int fsr_storage;
927 extern int ncpus_probed;
928
929 +#ifdef CONFIG_SPARC64
930 +/* setup_64.c */
931 +struct seq_file;
932 +extern void cpucap_info(struct seq_file *);
933 +
934 +static inline unsigned long kimage_addr_to_ra(const char *p)
935 +{
936 + unsigned long val = (unsigned long) p;
937 +
938 + return kern_base + (val - KERNBASE);
939 +}
940 +#endif
941 +
942 #ifdef CONFIG_SPARC32
943 /* cpu.c */
944 extern void cpu_probe(void);
945 diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
946 index 1d36147..79f3103 100644
947 --- a/arch/sparc/kernel/ktlb.S
948 +++ b/arch/sparc/kernel/ktlb.S
949 @@ -47,16 +47,16 @@ kvmap_itlb_tsb_miss:
950 kvmap_itlb_vmalloc_addr:
951 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath)
952
953 - KTSB_LOCK_TAG(%g1, %g2, %g7)
954 + TSB_LOCK_TAG(%g1, %g2, %g7)
955
956 /* Load and check PTE. */
957 ldxa [%g5] ASI_PHYS_USE_EC, %g5
958 mov 1, %g7
959 sllx %g7, TSB_TAG_INVALID_BIT, %g7
960 brgez,a,pn %g5, kvmap_itlb_longpath
961 - KTSB_STORE(%g1, %g7)
962 + TSB_STORE(%g1, %g7)
963
964 - KTSB_WRITE(%g1, %g5, %g6)
965 + TSB_WRITE(%g1, %g5, %g6)
966
967 /* fallthrough to TLB load */
968
969 @@ -102,9 +102,9 @@ kvmap_itlb_longpath:
970 kvmap_itlb_obp:
971 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath)
972
973 - KTSB_LOCK_TAG(%g1, %g2, %g7)
974 + TSB_LOCK_TAG(%g1, %g2, %g7)
975
976 - KTSB_WRITE(%g1, %g5, %g6)
977 + TSB_WRITE(%g1, %g5, %g6)
978
979 ba,pt %xcc, kvmap_itlb_load
980 nop
981 @@ -112,17 +112,17 @@ kvmap_itlb_obp:
982 kvmap_dtlb_obp:
983 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath)
984
985 - KTSB_LOCK_TAG(%g1, %g2, %g7)
986 + TSB_LOCK_TAG(%g1, %g2, %g7)
987
988 - KTSB_WRITE(%g1, %g5, %g6)
989 + TSB_WRITE(%g1, %g5, %g6)
990
991 ba,pt %xcc, kvmap_dtlb_load
992 nop
993
994 .align 32
995 kvmap_dtlb_tsb4m_load:
996 - KTSB_LOCK_TAG(%g1, %g2, %g7)
997 - KTSB_WRITE(%g1, %g5, %g6)
998 + TSB_LOCK_TAG(%g1, %g2, %g7)
999 + TSB_WRITE(%g1, %g5, %g6)
1000 ba,pt %xcc, kvmap_dtlb_load
1001 nop
1002
1003 @@ -222,16 +222,16 @@ kvmap_linear_patch:
1004 kvmap_dtlb_vmalloc_addr:
1005 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
1006
1007 - KTSB_LOCK_TAG(%g1, %g2, %g7)
1008 + TSB_LOCK_TAG(%g1, %g2, %g7)
1009
1010 /* Load and check PTE. */
1011 ldxa [%g5] ASI_PHYS_USE_EC, %g5
1012 mov 1, %g7
1013 sllx %g7, TSB_TAG_INVALID_BIT, %g7
1014 brgez,a,pn %g5, kvmap_dtlb_longpath
1015 - KTSB_STORE(%g1, %g7)
1016 + TSB_STORE(%g1, %g7)
1017
1018 - KTSB_WRITE(%g1, %g5, %g6)
1019 + TSB_WRITE(%g1, %g5, %g6)
1020
1021 /* fallthrough to TLB load */
1022
1023 diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
1024 index 42f28c7..acaebb6 100644
1025 --- a/arch/sparc/kernel/mdesc.c
1026 +++ b/arch/sparc/kernel/mdesc.c
1027 @@ -508,6 +508,8 @@ const char *mdesc_node_name(struct mdesc_handle *hp, u64 node)
1028 }
1029 EXPORT_SYMBOL(mdesc_node_name);
1030
1031 +static u64 max_cpus = 64;
1032 +
1033 static void __init report_platform_properties(void)
1034 {
1035 struct mdesc_handle *hp = mdesc_grab();
1036 @@ -543,8 +545,10 @@ static void __init report_platform_properties(void)
1037 if (v)
1038 printk("PLATFORM: watchdog-max-timeout [%llu ms]\n", *v);
1039 v = mdesc_get_property(hp, pn, "max-cpus", NULL);
1040 - if (v)
1041 - printk("PLATFORM: max-cpus [%llu]\n", *v);
1042 + if (v) {
1043 + max_cpus = *v;
1044 + printk("PLATFORM: max-cpus [%llu]\n", max_cpus);
1045 + }
1046
1047 #ifdef CONFIG_SMP
1048 {
1049 @@ -715,7 +719,7 @@ static void __cpuinit set_proc_ids(struct mdesc_handle *hp)
1050 }
1051
1052 static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask,
1053 - unsigned char def)
1054 + unsigned long def, unsigned long max)
1055 {
1056 u64 val;
1057
1058 @@ -726,6 +730,9 @@ static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask,
1059 if (!val || val >= 64)
1060 goto use_default;
1061
1062 + if (val > max)
1063 + val = max;
1064 +
1065 *mask = ((1U << val) * 64U) - 1U;
1066 return;
1067
1068 @@ -736,19 +743,28 @@ use_default:
1069 static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
1070 struct trap_per_cpu *tb)
1071 {
1072 + static int printed;
1073 const u64 *val;
1074
1075 val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL);
1076 - get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7);
1077 + get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7, ilog2(max_cpus * 2));
1078
1079 val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL);
1080 - get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7);
1081 + get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7, 8);
1082
1083 val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL);
1084 - get_one_mondo_bits(val, &tb->resum_qmask, 6);
1085 + get_one_mondo_bits(val, &tb->resum_qmask, 6, 7);
1086
1087 val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL);
1088 - get_one_mondo_bits(val, &tb->nonresum_qmask, 2);
1089 + get_one_mondo_bits(val, &tb->nonresum_qmask, 2, 2);
1090 + if (!printed++) {
1091 + pr_info("SUN4V: Mondo queue sizes "
1092 + "[cpu(%u) dev(%u) r(%u) nr(%u)]\n",
1093 + tb->cpu_mondo_qmask + 1,
1094 + tb->dev_mondo_qmask + 1,
1095 + tb->resum_qmask + 1,
1096 + tb->nonresum_qmask + 1);
1097 + }
1098 }
1099
1100 static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)
1101 diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
1102 index 8ac23e6..343b0f9 100644
1103 --- a/arch/sparc/kernel/pcr.c
1104 +++ b/arch/sparc/kernel/pcr.c
1105 @@ -80,8 +80,11 @@ static void n2_pcr_write(u64 val)
1106 {
1107 unsigned long ret;
1108
1109 - ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val);
1110 - if (ret != HV_EOK)
1111 + if (val & PCR_N2_HTRACE) {
1112 + ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val);
1113 + if (ret != HV_EOK)
1114 + write_pcr(val);
1115 + } else
1116 write_pcr(val);
1117 }
1118
1119 @@ -106,6 +109,10 @@ static int __init register_perf_hsvc(void)
1120 perf_hsvc_group = HV_GRP_N2_CPU;
1121 break;
1122
1123 + case SUN4V_CHIP_NIAGARA3:
1124 + perf_hsvc_group = HV_GRP_KT_CPU;
1125 + break;
1126 +
1127 default:
1128 return -ENODEV;
1129 }
1130 diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
1131 index 2cb0e1c..6860d40 100644
1132 --- a/arch/sparc/kernel/perf_event.c
1133 +++ b/arch/sparc/kernel/perf_event.c
1134 @@ -1301,7 +1301,8 @@ static bool __init supported_pmu(void)
1135 sparc_pmu = &niagara1_pmu;
1136 return true;
1137 }
1138 - if (!strcmp(sparc_pmu_type, "niagara2")) {
1139 + if (!strcmp(sparc_pmu_type, "niagara2") ||
1140 + !strcmp(sparc_pmu_type, "niagara3")) {
1141 sparc_pmu = &niagara2_pmu;
1142 return true;
1143 }
1144 diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
1145 index c4dd099..3e9daea 100644
1146 --- a/arch/sparc/kernel/setup_64.c
1147 +++ b/arch/sparc/kernel/setup_64.c
1148 @@ -29,6 +29,7 @@
1149 #include <linux/interrupt.h>
1150 #include <linux/cpu.h>
1151 #include <linux/initrd.h>
1152 +#include <linux/module.h>
1153
1154 #include <asm/system.h>
1155 #include <asm/io.h>
1156 @@ -46,6 +47,8 @@
1157 #include <asm/mmu.h>
1158 #include <asm/ns87303.h>
1159 #include <asm/btext.h>
1160 +#include <asm/elf.h>
1161 +#include <asm/mdesc.h>
1162
1163 #ifdef CONFIG_IP_PNP
1164 #include <net/ipconfig.h>
1165 @@ -269,6 +272,40 @@ void __init sun4v_patch(void)
1166 sun4v_hvapi_init();
1167 }
1168
1169 +static void __init popc_patch(void)
1170 +{
1171 + struct popc_3insn_patch_entry *p3;
1172 + struct popc_6insn_patch_entry *p6;
1173 +
1174 + p3 = &__popc_3insn_patch;
1175 + while (p3 < &__popc_3insn_patch_end) {
1176 + unsigned long i, addr = p3->addr;
1177 +
1178 + for (i = 0; i < 3; i++) {
1179 + *(unsigned int *) (addr + (i * 4)) = p3->insns[i];
1180 + wmb();
1181 + __asm__ __volatile__("flush %0"
1182 + : : "r" (addr + (i * 4)));
1183 + }
1184 +
1185 + p3++;
1186 + }
1187 +
1188 + p6 = &__popc_6insn_patch;
1189 + while (p6 < &__popc_6insn_patch_end) {
1190 + unsigned long i, addr = p6->addr;
1191 +
1192 + for (i = 0; i < 6; i++) {
1193 + *(unsigned int *) (addr + (i * 4)) = p6->insns[i];
1194 + wmb();
1195 + __asm__ __volatile__("flush %0"
1196 + : : "r" (addr + (i * 4)));
1197 + }
1198 +
1199 + p6++;
1200 + }
1201 +}
1202 +
1203 #ifdef CONFIG_SMP
1204 void __init boot_cpu_id_too_large(int cpu)
1205 {
1206 @@ -278,6 +315,154 @@ void __init boot_cpu_id_too_large(int cpu)
1207 }
1208 #endif
1209
1210 +/* On Ultra, we support all of the v8 capabilities. */
1211 +unsigned long sparc64_elf_hwcap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
1212 + HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
1213 + HWCAP_SPARC_V9);
1214 +EXPORT_SYMBOL(sparc64_elf_hwcap);
1215 +
1216 +static const char *hwcaps[] = {
1217 + "flush", "stbar", "swap", "muldiv", "v9",
1218 + "ultra3", "blkinit", "n2",
1219 +
1220 + /* These strings are as they appear in the machine description
1221 + * 'hwcap-list' property for cpu nodes.
1222 + */
1223 + "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
1224 + "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
1225 + "ima", "cspare",
1226 +};
1227 +
1228 +void cpucap_info(struct seq_file *m)
1229 +{
1230 + unsigned long caps = sparc64_elf_hwcap;
1231 + int i, printed = 0;
1232 +
1233 + seq_puts(m, "cpucaps\t\t: ");
1234 + for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
1235 + unsigned long bit = 1UL << i;
1236 + if (caps & bit) {
1237 + seq_printf(m, "%s%s",
1238 + printed ? "," : "", hwcaps[i]);
1239 + printed++;
1240 + }
1241 + }
1242 + seq_putc(m, '\n');
1243 +}
1244 +
1245 +static void __init report_hwcaps(unsigned long caps)
1246 +{
1247 + int i, printed = 0;
1248 +
1249 + printk(KERN_INFO "CPU CAPS: [");
1250 + for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
1251 + unsigned long bit = 1UL << i;
1252 + if (caps & bit) {
1253 + printk(KERN_CONT "%s%s",
1254 + printed ? "," : "", hwcaps[i]);
1255 + if (++printed == 8) {
1256 + printk(KERN_CONT "]\n");
1257 + printk(KERN_INFO "CPU CAPS: [");
1258 + printed = 0;
1259 + }
1260 + }
1261 + }
1262 + printk(KERN_CONT "]\n");
1263 +}
1264 +
1265 +static unsigned long __init mdesc_cpu_hwcap_list(void)
1266 +{
1267 + struct mdesc_handle *hp;
1268 + unsigned long caps = 0;
1269 + const char *prop;
1270 + int len;
1271 + u64 pn;
1272 +
1273 + hp = mdesc_grab();
1274 + if (!hp)
1275 + return 0;
1276 +
1277 + pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "cpu");
1278 + if (pn == MDESC_NODE_NULL)
1279 + goto out;
1280 +
1281 + prop = mdesc_get_property(hp, pn, "hwcap-list", &len);
1282 + if (!prop)
1283 + goto out;
1284 +
1285 + while (len) {
1286 + int i, plen;
1287 +
1288 + for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
1289 + unsigned long bit = 1UL << i;
1290 +
1291 + if (!strcmp(prop, hwcaps[i])) {
1292 + caps |= bit;
1293 + break;
1294 + }
1295 + }
1296 +
1297 + plen = strlen(prop) + 1;
1298 + prop += plen;
1299 + len -= plen;
1300 + }
1301 +
1302 +out:
1303 + mdesc_release(hp);
1304 + return caps;
1305 +}
1306 +
1307 +/* This yields a mask that user programs can use to figure out what
1308 + * instruction set this cpu supports.
1309 + */
1310 +static void __init init_sparc64_elf_hwcap(void)
1311 +{
1312 + unsigned long cap = sparc64_elf_hwcap;
1313 + unsigned long mdesc_caps;
1314 +
1315 + if (tlb_type == cheetah || tlb_type == cheetah_plus)
1316 + cap |= HWCAP_SPARC_ULTRA3;
1317 + else if (tlb_type == hypervisor) {
1318 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
1319 + sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
1320 + sun4v_chip_type == SUN4V_CHIP_NIAGARA3)
1321 + cap |= HWCAP_SPARC_BLKINIT;
1322 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
1323 + sun4v_chip_type == SUN4V_CHIP_NIAGARA3)
1324 + cap |= HWCAP_SPARC_N2;
1325 + }
1326 +
1327 + cap |= (AV_SPARC_MUL32 | AV_SPARC_DIV32 | AV_SPARC_V8PLUS);
1328 +
1329 + mdesc_caps = mdesc_cpu_hwcap_list();
1330 + if (!mdesc_caps) {
1331 + if (tlb_type == spitfire)
1332 + cap |= AV_SPARC_VIS;
1333 + if (tlb_type == cheetah || tlb_type == cheetah_plus)
1334 + cap |= AV_SPARC_VIS | AV_SPARC_VIS2;
1335 + if (tlb_type == cheetah_plus)
1336 + cap |= AV_SPARC_POPC;
1337 + if (tlb_type == hypervisor) {
1338 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1)
1339 + cap |= AV_SPARC_ASI_BLK_INIT;
1340 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
1341 + sun4v_chip_type == SUN4V_CHIP_NIAGARA3)
1342 + cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
1343 + AV_SPARC_ASI_BLK_INIT |
1344 + AV_SPARC_POPC);
1345 + if (sun4v_chip_type == SUN4V_CHIP_NIAGARA3)
1346 + cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
1347 + AV_SPARC_FMAF);
1348 + }
1349 + }
1350 + sparc64_elf_hwcap = cap | mdesc_caps;
1351 +
1352 + report_hwcaps(sparc64_elf_hwcap);
1353 +
1354 + if (sparc64_elf_hwcap & AV_SPARC_POPC)
1355 + popc_patch();
1356 +}
1357 +
1358 void __init setup_arch(char **cmdline_p)
1359 {
1360 /* Initialize PROM console and command line. */
1361 @@ -337,6 +522,7 @@ void __init setup_arch(char **cmdline_p)
1362 init_cur_cpu_trap(current_thread_info());
1363
1364 paging_init();
1365 + init_sparc64_elf_hwcap();
1366 }
1367
1368 extern int stop_a_enabled;
1369 diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c
1370 index 372ad59..83b47ab 100644
1371 --- a/arch/sparc/kernel/sparc_ksyms_64.c
1372 +++ b/arch/sparc/kernel/sparc_ksyms_64.c
1373 @@ -8,6 +8,7 @@
1374 #include <linux/module.h>
1375 #include <linux/pci.h>
1376 #include <linux/init.h>
1377 +#include <linux/bitops.h>
1378
1379 #include <asm/system.h>
1380 #include <asm/cpudata.h>
1381 @@ -38,5 +39,15 @@ EXPORT_SYMBOL(sun4v_niagara_setperf);
1382 EXPORT_SYMBOL(sun4v_niagara2_getperf);
1383 EXPORT_SYMBOL(sun4v_niagara2_setperf);
1384
1385 +/* from hweight.S */
1386 +EXPORT_SYMBOL(__arch_hweight8);
1387 +EXPORT_SYMBOL(__arch_hweight16);
1388 +EXPORT_SYMBOL(__arch_hweight32);
1389 +EXPORT_SYMBOL(__arch_hweight64);
1390 +
1391 +/* from ffs_ffz.S */
1392 +EXPORT_SYMBOL(ffs);
1393 +EXPORT_SYMBOL(__ffs);
1394 +
1395 /* Exporting a symbol from /init/main.c */
1396 EXPORT_SYMBOL(saved_command_line);
1397 diff --git a/arch/sparc/kernel/sstate.c b/arch/sparc/kernel/sstate.c
1398 index 8cdbe59..c59af54 100644
1399 --- a/arch/sparc/kernel/sstate.c
1400 +++ b/arch/sparc/kernel/sstate.c
1401 @@ -14,14 +14,9 @@
1402 #include <asm/head.h>
1403 #include <asm/io.h>
1404
1405 -static int hv_supports_soft_state;
1406 -
1407 -static unsigned long kimage_addr_to_ra(const char *p)
1408 -{
1409 - unsigned long val = (unsigned long) p;
1410 +#include "kernel.h"
1411
1412 - return kern_base + (val - KERNBASE);
1413 -}
1414 +static int hv_supports_soft_state;
1415
1416 static void do_set_sstate(unsigned long state, const char *msg)
1417 {
1418 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
1419 index b2b019e..9043106 100644
1420 --- a/arch/sparc/kernel/unaligned_64.c
1421 +++ b/arch/sparc/kernel/unaligned_64.c
1422 @@ -22,6 +22,7 @@
1423 #include <linux/bitops.h>
1424 #include <linux/perf_event.h>
1425 #include <linux/ratelimit.h>
1426 +#include <linux/bitops.h>
1427 #include <asm/fpumacro.h>
1428
1429 enum direction {
1430 @@ -373,16 +374,11 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
1431 }
1432 }
1433
1434 -static char popc_helper[] = {
1435 -0, 1, 1, 2, 1, 2, 2, 3,
1436 -1, 2, 2, 3, 2, 3, 3, 4,
1437 -};
1438 -
1439 int handle_popc(u32 insn, struct pt_regs *regs)
1440 {
1441 - u64 value;
1442 - int ret, i, rd = ((insn >> 25) & 0x1f);
1443 int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
1444 + int ret, rd = ((insn >> 25) & 0x1f);
1445 + u64 value;
1446
1447 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
1448 if (insn & 0x2000) {
1449 @@ -392,10 +388,7 @@ int handle_popc(u32 insn, struct pt_regs *regs)
1450 maybe_flush_windows(0, insn & 0x1f, rd, from_kernel);
1451 value = fetch_reg(insn & 0x1f, regs);
1452 }
1453 - for (ret = 0, i = 0; i < 16; i++) {
1454 - ret += popc_helper[value & 0xf];
1455 - value >>= 4;
1456 - }
1457 + ret = hweight64(value);
1458 if (rd < 16) {
1459 if (rd)
1460 regs->u_regs[rd] = ret;
1461 diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
1462 index c022075..0e16056 100644
1463 --- a/arch/sparc/kernel/vmlinux.lds.S
1464 +++ b/arch/sparc/kernel/vmlinux.lds.S
1465 @@ -107,7 +107,26 @@ SECTIONS
1466 *(.sun4v_2insn_patch)
1467 __sun4v_2insn_patch_end = .;
1468 }
1469 -
1470 + .swapper_tsb_phys_patch : {
1471 + __swapper_tsb_phys_patch = .;
1472 + *(.swapper_tsb_phys_patch)
1473 + __swapper_tsb_phys_patch_end = .;
1474 + }
1475 + .swapper_4m_tsb_phys_patch : {
1476 + __swapper_4m_tsb_phys_patch = .;
1477 + *(.swapper_4m_tsb_phys_patch)
1478 + __swapper_4m_tsb_phys_patch_end = .;
1479 + }
1480 + .popc_3insn_patch : {
1481 + __popc_3insn_patch = .;
1482 + *(.popc_3insn_patch)
1483 + __popc_3insn_patch_end = .;
1484 + }
1485 + .popc_6insn_patch : {
1486 + __popc_6insn_patch = .;
1487 + *(.popc_6insn_patch)
1488 + __popc_6insn_patch_end = .;
1489 + }
1490 PERCPU_SECTION(SMP_CACHE_BYTES)
1491
1492 . = ALIGN(PAGE_SIZE);
1493 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
1494 index 7f01b8f..a3fc437 100644
1495 --- a/arch/sparc/lib/Makefile
1496 +++ b/arch/sparc/lib/Makefile
1497 @@ -31,13 +31,13 @@ lib-$(CONFIG_SPARC64) += NGmemcpy.o NGcopy_from_user.o NGcopy_to_user.o
1498 lib-$(CONFIG_SPARC64) += NGpatch.o NGpage.o NGbzero.o
1499
1500 lib-$(CONFIG_SPARC64) += NG2memcpy.o NG2copy_from_user.o NG2copy_to_user.o
1501 -lib-$(CONFIG_SPARC64) += NG2patch.o NG2page.o
1502 +lib-$(CONFIG_SPARC64) += NG2patch.o
1503
1504 lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o
1505 lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
1506
1507 lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
1508 -lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o
1509 +lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
1510
1511 obj-y += iomap.o
1512 obj-$(CONFIG_SPARC32) += atomic32.o
1513 diff --git a/arch/sparc/lib/NG2page.S b/arch/sparc/lib/NG2page.S
1514 deleted file mode 100644
1515 index 73b6b7c..0000000
1516 --- a/arch/sparc/lib/NG2page.S
1517 +++ /dev/null
1518 @@ -1,61 +0,0 @@
1519 -/* NG2page.S: Niagara-2 optimized clear and copy page.
1520 - *
1521 - * Copyright (C) 2007 (davem@davemloft.net)
1522 - */
1523 -
1524 -#include <asm/asi.h>
1525 -#include <asm/page.h>
1526 -#include <asm/visasm.h>
1527 -
1528 - .text
1529 - .align 32
1530 -
1531 - /* This is heavily simplified from the sun4u variants
1532 - * because Niagara-2 does not have any D-cache aliasing issues.
1533 - */
1534 -NG2copy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
1535 - prefetch [%o1 + 0x00], #one_read
1536 - prefetch [%o1 + 0x40], #one_read
1537 - VISEntryHalf
1538 - set PAGE_SIZE, %g7
1539 - sub %o0, %o1, %g3
1540 -1: stxa %g0, [%o1 + %g3] ASI_BLK_INIT_QUAD_LDD_P
1541 - subcc %g7, 64, %g7
1542 - ldda [%o1] ASI_BLK_P, %f0
1543 - stda %f0, [%o1 + %g3] ASI_BLK_P
1544 - add %o1, 64, %o1
1545 - bne,pt %xcc, 1b
1546 - prefetch [%o1 + 0x40], #one_read
1547 - membar #Sync
1548 - VISExitHalf
1549 - retl
1550 - nop
1551 -
1552 -#define BRANCH_ALWAYS 0x10680000
1553 -#define NOP 0x01000000
1554 -#define NG_DO_PATCH(OLD, NEW) \
1555 - sethi %hi(NEW), %g1; \
1556 - or %g1, %lo(NEW), %g1; \
1557 - sethi %hi(OLD), %g2; \
1558 - or %g2, %lo(OLD), %g2; \
1559 - sub %g1, %g2, %g1; \
1560 - sethi %hi(BRANCH_ALWAYS), %g3; \
1561 - sll %g1, 11, %g1; \
1562 - srl %g1, 11 + 2, %g1; \
1563 - or %g3, %lo(BRANCH_ALWAYS), %g3; \
1564 - or %g3, %g1, %g3; \
1565 - stw %g3, [%g2]; \
1566 - sethi %hi(NOP), %g3; \
1567 - or %g3, %lo(NOP), %g3; \
1568 - stw %g3, [%g2 + 0x4]; \
1569 - flush %g2;
1570 -
1571 - .globl niagara2_patch_pageops
1572 - .type niagara2_patch_pageops,#function
1573 -niagara2_patch_pageops:
1574 - NG_DO_PATCH(copy_user_page, NG2copy_user_page)
1575 - NG_DO_PATCH(_clear_page, NGclear_page)
1576 - NG_DO_PATCH(clear_user_page, NGclear_user_page)
1577 - retl
1578 - nop
1579 - .size niagara2_patch_pageops,.-niagara2_patch_pageops
1580 diff --git a/arch/sparc/lib/NGpage.S b/arch/sparc/lib/NGpage.S
1581 index 428920d..b9e790b 100644
1582 --- a/arch/sparc/lib/NGpage.S
1583 +++ b/arch/sparc/lib/NGpage.S
1584 @@ -16,55 +16,91 @@
1585 */
1586
1587 NGcopy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
1588 - prefetch [%o1 + 0x00], #one_read
1589 - mov 8, %g1
1590 - mov 16, %g2
1591 - mov 24, %g3
1592 + save %sp, -192, %sp
1593 + rd %asi, %g3
1594 + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
1595 set PAGE_SIZE, %g7
1596 + prefetch [%i1 + 0x00], #one_read
1597 + prefetch [%i1 + 0x40], #one_read
1598
1599 -1: ldda [%o1 + %g0] ASI_BLK_INIT_QUAD_LDD_P, %o2
1600 - ldda [%o1 + %g2] ASI_BLK_INIT_QUAD_LDD_P, %o4
1601 - prefetch [%o1 + 0x40], #one_read
1602 - add %o1, 32, %o1
1603 - stxa %o2, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
1604 - stxa %o3, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
1605 - ldda [%o1 + %g0] ASI_BLK_INIT_QUAD_LDD_P, %o2
1606 - stxa %o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
1607 - stxa %o5, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
1608 - ldda [%o1 + %g2] ASI_BLK_INIT_QUAD_LDD_P, %o4
1609 - add %o1, 32, %o1
1610 - add %o0, 32, %o0
1611 - stxa %o2, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
1612 - stxa %o3, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
1613 - stxa %o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
1614 - stxa %o5, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
1615 - subcc %g7, 64, %g7
1616 +1: prefetch [%i1 + 0x80], #one_read
1617 + prefetch [%i1 + 0xc0], #one_read
1618 + ldda [%i1 + 0x00] %asi, %o2
1619 + ldda [%i1 + 0x10] %asi, %o4
1620 + ldda [%i1 + 0x20] %asi, %l2
1621 + ldda [%i1 + 0x30] %asi, %l4
1622 + stxa %o2, [%i0 + 0x00] %asi
1623 + stxa %o3, [%i0 + 0x08] %asi
1624 + stxa %o4, [%i0 + 0x10] %asi
1625 + stxa %o5, [%i0 + 0x18] %asi
1626 + stxa %l2, [%i0 + 0x20] %asi
1627 + stxa %l3, [%i0 + 0x28] %asi
1628 + stxa %l4, [%i0 + 0x30] %asi
1629 + stxa %l5, [%i0 + 0x38] %asi
1630 + ldda [%i1 + 0x40] %asi, %o2
1631 + ldda [%i1 + 0x50] %asi, %o4
1632 + ldda [%i1 + 0x60] %asi, %l2
1633 + ldda [%i1 + 0x70] %asi, %l4
1634 + stxa %o2, [%i0 + 0x40] %asi
1635 + stxa %o3, [%i0 + 0x48] %asi
1636 + stxa %o4, [%i0 + 0x50] %asi
1637 + stxa %o5, [%i0 + 0x58] %asi
1638 + stxa %l2, [%i0 + 0x60] %asi
1639 + stxa %l3, [%i0 + 0x68] %asi
1640 + stxa %l4, [%i0 + 0x70] %asi
1641 + stxa %l5, [%i0 + 0x78] %asi
1642 + add %i1, 128, %i1
1643 + subcc %g7, 128, %g7
1644 bne,pt %xcc, 1b
1645 - add %o0, 32, %o0
1646 + add %i0, 128, %i0
1647 + wr %g3, 0x0, %asi
1648 membar #Sync
1649 - retl
1650 - nop
1651 + ret
1652 + restore
1653
1654 - .globl NGclear_page, NGclear_user_page
1655 + .align 32
1656 NGclear_page: /* %o0=dest */
1657 NGclear_user_page: /* %o0=dest, %o1=vaddr */
1658 - mov 8, %g1
1659 - mov 16, %g2
1660 - mov 24, %g3
1661 + rd %asi, %g3
1662 + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
1663 set PAGE_SIZE, %g7
1664
1665 -1: stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
1666 - stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
1667 - stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
1668 - stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
1669 - add %o0, 32, %o0
1670 - stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
1671 - stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
1672 - stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
1673 - stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
1674 - subcc %g7, 64, %g7
1675 +1: stxa %g0, [%o0 + 0x00] %asi
1676 + stxa %g0, [%o0 + 0x08] %asi
1677 + stxa %g0, [%o0 + 0x10] %asi
1678 + stxa %g0, [%o0 + 0x18] %asi
1679 + stxa %g0, [%o0 + 0x20] %asi
1680 + stxa %g0, [%o0 + 0x28] %asi
1681 + stxa %g0, [%o0 + 0x30] %asi
1682 + stxa %g0, [%o0 + 0x38] %asi
1683 + stxa %g0, [%o0 + 0x40] %asi
1684 + stxa %g0, [%o0 + 0x48] %asi
1685 + stxa %g0, [%o0 + 0x50] %asi
1686 + stxa %g0, [%o0 + 0x58] %asi
1687 + stxa %g0, [%o0 + 0x60] %asi
1688 + stxa %g0, [%o0 + 0x68] %asi
1689 + stxa %g0, [%o0 + 0x70] %asi
1690 + stxa %g0, [%o0 + 0x78] %asi
1691 + stxa %g0, [%o0 + 0x80] %asi
1692 + stxa %g0, [%o0 + 0x88] %asi
1693 + stxa %g0, [%o0 + 0x90] %asi
1694 + stxa %g0, [%o0 + 0x98] %asi
1695 + stxa %g0, [%o0 + 0xa0] %asi
1696 + stxa %g0, [%o0 + 0xa8] %asi
1697 + stxa %g0, [%o0 + 0xb0] %asi
1698 + stxa %g0, [%o0 + 0xb8] %asi
1699 + stxa %g0, [%o0 + 0xc0] %asi
1700 + stxa %g0, [%o0 + 0xc8] %asi
1701 + stxa %g0, [%o0 + 0xd0] %asi
1702 + stxa %g0, [%o0 + 0xd8] %asi
1703 + stxa %g0, [%o0 + 0xe0] %asi
1704 + stxa %g0, [%o0 + 0xe8] %asi
1705 + stxa %g0, [%o0 + 0xf0] %asi
1706 + stxa %g0, [%o0 + 0xf8] %asi
1707 + subcc %g7, 256, %g7
1708 bne,pt %xcc, 1b
1709 - add %o0, 32, %o0
1710 + add %o0, 256, %o0
1711 + wr %g3, 0x0, %asi
1712 membar #Sync
1713 retl
1714 nop
1715 diff --git a/arch/sparc/lib/ffs.S b/arch/sparc/lib/ffs.S
1716 new file mode 100644
1717 index 0000000..b39389f
1718 --- /dev/null
1719 +++ b/arch/sparc/lib/ffs.S
1720 @@ -0,0 +1,84 @@
1721 +#include <linux/linkage.h>
1722 +
1723 + .register %g2,#scratch
1724 +
1725 + .text
1726 + .align 32
1727 +
1728 +ENTRY(ffs)
1729 + brnz,pt %o0, 1f
1730 + mov 1, %o1
1731 + retl
1732 + clr %o0
1733 + nop
1734 + nop
1735 +ENTRY(__ffs)
1736 + sllx %o0, 32, %g1 /* 1 */
1737 + srlx %o0, 32, %g2
1738 +
1739 + clr %o1 /* 2 */
1740 + movrz %g1, %g2, %o0
1741 +
1742 + movrz %g1, 32, %o1 /* 3 */
1743 +1: clr %o2
1744 +
1745 + sllx %o0, (64 - 16), %g1 /* 4 */
1746 + srlx %o0, 16, %g2
1747 +
1748 + movrz %g1, %g2, %o0 /* 5 */
1749 + clr %o3
1750 +
1751 + movrz %g1, 16, %o2 /* 6 */
1752 + clr %o4
1753 +
1754 + and %o0, 0xff, %g1 /* 7 */
1755 + srlx %o0, 8, %g2
1756 +
1757 + movrz %g1, %g2, %o0 /* 8 */
1758 + clr %o5
1759 +
1760 + movrz %g1, 8, %o3 /* 9 */
1761 + add %o2, %o1, %o2
1762 +
1763 + and %o0, 0xf, %g1 /* 10 */
1764 + srlx %o0, 4, %g2
1765 +
1766 + movrz %g1, %g2, %o0 /* 11 */
1767 + add %o2, %o3, %o2
1768 +
1769 + movrz %g1, 4, %o4 /* 12 */
1770 +
1771 + and %o0, 0x3, %g1 /* 13 */
1772 + srlx %o0, 2, %g2
1773 +
1774 + movrz %g1, %g2, %o0 /* 14 */
1775 + add %o2, %o4, %o2
1776 +
1777 + movrz %g1, 2, %o5 /* 15 */
1778 +
1779 + and %o0, 0x1, %g1 /* 16 */
1780 +
1781 + add %o2, %o5, %o2 /* 17 */
1782 + xor %g1, 0x1, %g1
1783 +
1784 + retl /* 18 */
1785 + add %o2, %g1, %o0
1786 +ENDPROC(ffs)
1787 +ENDPROC(__ffs)
1788 +
1789 + .section .popc_6insn_patch, "ax"
1790 + .word ffs
1791 + brz,pn %o0, 98f
1792 + neg %o0, %g1
1793 + xnor %o0, %g1, %o1
1794 + popc %o1, %o0
1795 +98: retl
1796 + nop
1797 + .word __ffs
1798 + neg %o0, %g1
1799 + xnor %o0, %g1, %o1
1800 + popc %o1, %o0
1801 + retl
1802 + sub %o0, 1, %o0
1803 + nop
1804 + .previous
1805 diff --git a/arch/sparc/lib/hweight.S b/arch/sparc/lib/hweight.S
1806 new file mode 100644
1807 index 0000000..95414e0
1808 --- /dev/null
1809 +++ b/arch/sparc/lib/hweight.S
1810 @@ -0,0 +1,51 @@
1811 +#include <linux/linkage.h>
1812 +
1813 + .text
1814 + .align 32
1815 +ENTRY(__arch_hweight8)
1816 + ba,pt %xcc, __sw_hweight8
1817 + nop
1818 + nop
1819 +ENDPROC(__arch_hweight8)
1820 + .section .popc_3insn_patch, "ax"
1821 + .word __arch_hweight8
1822 + sllx %o0, 64-8, %g1
1823 + retl
1824 + popc %g1, %o0
1825 + .previous
1826 +
1827 +ENTRY(__arch_hweight16)
1828 + ba,pt %xcc, __sw_hweight16
1829 + nop
1830 + nop
1831 +ENDPROC(__arch_hweight16)
1832 + .section .popc_3insn_patch, "ax"
1833 + .word __arch_hweight16
1834 + sllx %o0, 64-16, %g1
1835 + retl
1836 + popc %g1, %o0
1837 + .previous
1838 +
1839 +ENTRY(__arch_hweight32)
1840 + ba,pt %xcc, __sw_hweight32
1841 + nop
1842 + nop
1843 +ENDPROC(__arch_hweight32)
1844 + .section .popc_3insn_patch, "ax"
1845 + .word __arch_hweight32
1846 + sllx %o0, 64-32, %g1
1847 + retl
1848 + popc %g1, %o0
1849 + .previous
1850 +
1851 +ENTRY(__arch_hweight64)
1852 + ba,pt %xcc, __sw_hweight64
1853 + nop
1854 + nop
1855 +ENDPROC(__arch_hweight64)
1856 + .section .popc_3insn_patch, "ax"
1857 + .word __arch_hweight64
1858 + retl
1859 + popc %o0, %o0
1860 + nop
1861 + .previous
1862 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
1863 index 3fd8e18..581531d 100644
1864 --- a/arch/sparc/mm/init_64.c
1865 +++ b/arch/sparc/mm/init_64.c
1866 @@ -1597,6 +1597,44 @@ static void __init tsb_phys_patch(void)
1867 static struct hv_tsb_descr ktsb_descr[NUM_KTSB_DESCR];
1868 extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES];
1869
1870 +static void patch_one_ktsb_phys(unsigned int *start, unsigned int *end, unsigned long pa)
1871 +{
1872 + pa >>= KTSB_PHYS_SHIFT;
1873 +
1874 + while (start < end) {
1875 + unsigned int *ia = (unsigned int *)(unsigned long)*start;
1876 +
1877 + ia[0] = (ia[0] & ~0x3fffff) | (pa >> 10);
1878 + __asm__ __volatile__("flush %0" : : "r" (ia));
1879 +
1880 + ia[1] = (ia[1] & ~0x3ff) | (pa & 0x3ff);
1881 + __asm__ __volatile__("flush %0" : : "r" (ia + 1));
1882 +
1883 + start++;
1884 + }
1885 +}
1886 +
1887 +static void ktsb_phys_patch(void)
1888 +{
1889 + extern unsigned int __swapper_tsb_phys_patch;
1890 + extern unsigned int __swapper_tsb_phys_patch_end;
1891 + unsigned long ktsb_pa;
1892 +
1893 + ktsb_pa = kern_base + ((unsigned long)&swapper_tsb[0] - KERNBASE);
1894 + patch_one_ktsb_phys(&__swapper_tsb_phys_patch,
1895 + &__swapper_tsb_phys_patch_end, ktsb_pa);
1896 +#ifndef CONFIG_DEBUG_PAGEALLOC
1897 + {
1898 + extern unsigned int __swapper_4m_tsb_phys_patch;
1899 + extern unsigned int __swapper_4m_tsb_phys_patch_end;
1900 + ktsb_pa = (kern_base +
1901 + ((unsigned long)&swapper_4m_tsb[0] - KERNBASE));
1902 + patch_one_ktsb_phys(&__swapper_4m_tsb_phys_patch,
1903 + &__swapper_4m_tsb_phys_patch_end, ktsb_pa);
1904 + }
1905 +#endif
1906 +}
1907 +
1908 static void __init sun4v_ktsb_init(void)
1909 {
1910 unsigned long ktsb_pa;
1911 @@ -1716,8 +1754,10 @@ void __init paging_init(void)
1912 sun4u_pgprot_init();
1913
1914 if (tlb_type == cheetah_plus ||
1915 - tlb_type == hypervisor)
1916 + tlb_type == hypervisor) {
1917 tsb_phys_patch();
1918 + ktsb_phys_patch();
1919 + }
1920
1921 if (tlb_type == hypervisor) {
1922 sun4v_patch_tlb_handlers();
1923 diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
1924 index 17c565d..a6575b9 100644
1925 --- a/arch/x86/xen/Makefile
1926 +++ b/arch/x86/xen/Makefile
1927 @@ -18,5 +18,5 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
1928 obj-$(CONFIG_SMP) += smp.o
1929 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
1930 obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o
1931 -
1932 +obj-$(CONFIG_XEN_DOM0) += vga.o
1933 obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o
1934 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
1935 index 5525163..5325742 100644
1936 --- a/arch/x86/xen/enlighten.c
1937 +++ b/arch/x86/xen/enlighten.c
1938 @@ -1248,6 +1248,14 @@ asmlinkage void __init xen_start_kernel(void)
1939 if (pci_xen)
1940 x86_init.pci.arch_init = pci_xen_init;
1941 } else {
1942 + const struct dom0_vga_console_info *info =
1943 + (void *)((char *)xen_start_info +
1944 + xen_start_info->console.dom0.info_off);
1945 +
1946 + xen_init_vga(info, xen_start_info->console.dom0.info_size);
1947 + xen_start_info->console.domU.mfn = 0;
1948 + xen_start_info->console.domU.evtchn = 0;
1949 +
1950 /* Make sure ACS will be enabled */
1951 pci_request_acs();
1952 }
1953 diff --git a/arch/x86/xen/vga.c b/arch/x86/xen/vga.c
1954 new file mode 100644
1955 index 0000000..1cd7f4d
1956 --- /dev/null
1957 +++ b/arch/x86/xen/vga.c
1958 @@ -0,0 +1,67 @@
1959 +#include <linux/screen_info.h>
1960 +#include <linux/init.h>
1961 +
1962 +#include <asm/bootparam.h>
1963 +#include <asm/setup.h>
1964 +
1965 +#include <xen/interface/xen.h>
1966 +
1967 +#include "xen-ops.h"
1968 +
1969 +void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size)
1970 +{
1971 + struct screen_info *screen_info = &boot_params.screen_info;
1972 +
1973 + /* This is drawn from a dump from vgacon:startup in
1974 + * standard Linux. */
1975 + screen_info->orig_video_mode = 3;
1976 + screen_info->orig_video_isVGA = 1;
1977 + screen_info->orig_video_lines = 25;
1978 + screen_info->orig_video_cols = 80;
1979 + screen_info->orig_video_ega_bx = 3;
1980 + screen_info->orig_video_points = 16;
1981 + screen_info->orig_y = screen_info->orig_video_lines - 1;
1982 +
1983 + switch (info->video_type) {
1984 + case XEN_VGATYPE_TEXT_MODE_3:
1985 + if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3)
1986 + + sizeof(info->u.text_mode_3))
1987 + break;
1988 + screen_info->orig_video_lines = info->u.text_mode_3.rows;
1989 + screen_info->orig_video_cols = info->u.text_mode_3.columns;
1990 + screen_info->orig_x = info->u.text_mode_3.cursor_x;
1991 + screen_info->orig_y = info->u.text_mode_3.cursor_y;
1992 + screen_info->orig_video_points =
1993 + info->u.text_mode_3.font_height;
1994 + break;
1995 +
1996 + case XEN_VGATYPE_VESA_LFB:
1997 + if (size < offsetof(struct dom0_vga_console_info,
1998 + u.vesa_lfb.gbl_caps))
1999 + break;
2000 + screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB;
2001 + screen_info->lfb_width = info->u.vesa_lfb.width;
2002 + screen_info->lfb_height = info->u.vesa_lfb.height;
2003 + screen_info->lfb_depth = info->u.vesa_lfb.bits_per_pixel;
2004 + screen_info->lfb_base = info->u.vesa_lfb.lfb_base;
2005 + screen_info->lfb_size = info->u.vesa_lfb.lfb_size;
2006 + screen_info->lfb_linelength = info->u.vesa_lfb.bytes_per_line;
2007 + screen_info->red_size = info->u.vesa_lfb.red_size;
2008 + screen_info->red_pos = info->u.vesa_lfb.red_pos;
2009 + screen_info->green_size = info->u.vesa_lfb.green_size;
2010 + screen_info->green_pos = info->u.vesa_lfb.green_pos;
2011 + screen_info->blue_size = info->u.vesa_lfb.blue_size;
2012 + screen_info->blue_pos = info->u.vesa_lfb.blue_pos;
2013 + screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size;
2014 + screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos;
2015 + if (size >= offsetof(struct dom0_vga_console_info,
2016 + u.vesa_lfb.gbl_caps)
2017 + + sizeof(info->u.vesa_lfb.gbl_caps))
2018 + screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
2019 + if (size >= offsetof(struct dom0_vga_console_info,
2020 + u.vesa_lfb.mode_attrs)
2021 + + sizeof(info->u.vesa_lfb.mode_attrs))
2022 + screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs;
2023 + break;
2024 + }
2025 +}
2026 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
2027 index 97dfdc8..b095739 100644
2028 --- a/arch/x86/xen/xen-ops.h
2029 +++ b/arch/x86/xen/xen-ops.h
2030 @@ -88,6 +88,17 @@ static inline void xen_uninit_lock_cpu(int cpu)
2031 }
2032 #endif
2033
2034 +struct dom0_vga_console_info;
2035 +
2036 +#ifdef CONFIG_XEN_DOM0
2037 +void __init xen_init_vga(const struct dom0_vga_console_info *, size_t size);
2038 +#else
2039 +static inline void __init xen_init_vga(const struct dom0_vga_console_info *info,
2040 + size_t size)
2041 +{
2042 +}
2043 +#endif
2044 +
2045 /* Declare an asm function, along with symbols needed to make it
2046 inlineable */
2047 #define DECL_ASM(ret, name, ...) \
2048 diff --git a/crypto/md5.c b/crypto/md5.c
2049 index 30efc7d..7febeaa 100644
2050 --- a/crypto/md5.c
2051 +++ b/crypto/md5.c
2052 @@ -21,99 +21,9 @@
2053 #include <linux/module.h>
2054 #include <linux/string.h>
2055 #include <linux/types.h>
2056 +#include <linux/cryptohash.h>
2057 #include <asm/byteorder.h>
2058
2059 -#define F1(x, y, z) (z ^ (x & (y ^ z)))
2060 -#define F2(x, y, z) F1(z, x, y)
2061 -#define F3(x, y, z) (x ^ y ^ z)
2062 -#define F4(x, y, z) (y ^ (x | ~z))
2063 -
2064 -#define MD5STEP(f, w, x, y, z, in, s) \
2065 - (w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
2066 -
2067 -static void md5_transform(u32 *hash, u32 const *in)
2068 -{
2069 - u32 a, b, c, d;
2070 -
2071 - a = hash[0];
2072 - b = hash[1];
2073 - c = hash[2];
2074 - d = hash[3];
2075 -
2076 - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
2077 - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
2078 - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
2079 - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
2080 - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
2081 - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
2082 - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
2083 - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
2084 - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
2085 - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
2086 - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
2087 - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
2088 - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
2089 - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
2090 - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
2091 - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
2092 -
2093 - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
2094 - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
2095 - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
2096 - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
2097 - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
2098 - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
2099 - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
2100 - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
2101 - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
2102 - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
2103 - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
2104 - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
2105 - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
2106 - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
2107 - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
2108 - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
2109 -
2110 - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
2111 - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
2112 - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
2113 - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
2114 - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
2115 - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
2116 - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
2117 - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
2118 - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
2119 - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
2120 - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
2121 - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
2122 - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
2123 - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
2124 - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
2125 - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
2126 -
2127 - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
2128 - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
2129 - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
2130 - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
2131 - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
2132 - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
2133 - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
2134 - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
2135 - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
2136 - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
2137 - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
2138 - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
2139 - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
2140 - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
2141 - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
2142 - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
2143 -
2144 - hash[0] += a;
2145 - hash[1] += b;
2146 - hash[2] += c;
2147 - hash[3] += d;
2148 -}
2149 -
2150 /* XXX: this stuff can be optimized */
2151 static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
2152 {
2153 diff --git a/drivers/char/random.c b/drivers/char/random.c
2154 index d4ddeba..c35a785 100644
2155 --- a/drivers/char/random.c
2156 +++ b/drivers/char/random.c
2157 @@ -1300,330 +1300,14 @@ ctl_table random_table[] = {
2158 };
2159 #endif /* CONFIG_SYSCTL */
2160
2161 -/********************************************************************
2162 - *
2163 - * Random functions for networking
2164 - *
2165 - ********************************************************************/
2166 -
2167 -/*
2168 - * TCP initial sequence number picking. This uses the random number
2169 - * generator to pick an initial secret value. This value is hashed
2170 - * along with the TCP endpoint information to provide a unique
2171 - * starting point for each pair of TCP endpoints. This defeats
2172 - * attacks which rely on guessing the initial TCP sequence number.
2173 - * This algorithm was suggested by Steve Bellovin.
2174 - *
2175 - * Using a very strong hash was taking an appreciable amount of the total
2176 - * TCP connection establishment time, so this is a weaker hash,
2177 - * compensated for by changing the secret periodically.
2178 - */
2179 -
2180 -/* F, G and H are basic MD4 functions: selection, majority, parity */
2181 -#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
2182 -#define G(x, y, z) (((x) & (y)) + (((x) ^ (y)) & (z)))
2183 -#define H(x, y, z) ((x) ^ (y) ^ (z))
2184 -
2185 -/*
2186 - * The generic round function. The application is so specific that
2187 - * we don't bother protecting all the arguments with parens, as is generally
2188 - * good macro practice, in favor of extra legibility.
2189 - * Rotation is separate from addition to prevent recomputation
2190 - */
2191 -#define ROUND(f, a, b, c, d, x, s) \
2192 - (a += f(b, c, d) + x, a = (a << s) | (a >> (32 - s)))
2193 -#define K1 0
2194 -#define K2 013240474631UL
2195 -#define K3 015666365641UL
2196 +static u32 random_int_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
2197
2198 -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
2199 -
2200 -static __u32 twothirdsMD4Transform(__u32 const buf[4], __u32 const in[12])
2201 +static int __init random_int_secret_init(void)
2202 {
2203 - __u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
2204 -
2205 - /* Round 1 */
2206 - ROUND(F, a, b, c, d, in[ 0] + K1, 3);
2207 - ROUND(F, d, a, b, c, in[ 1] + K1, 7);
2208 - ROUND(F, c, d, a, b, in[ 2] + K1, 11);
2209 - ROUND(F, b, c, d, a, in[ 3] + K1, 19);
2210 - ROUND(F, a, b, c, d, in[ 4] + K1, 3);
2211 - ROUND(F, d, a, b, c, in[ 5] + K1, 7);
2212 - ROUND(F, c, d, a, b, in[ 6] + K1, 11);
2213 - ROUND(F, b, c, d, a, in[ 7] + K1, 19);
2214 - ROUND(F, a, b, c, d, in[ 8] + K1, 3);
2215 - ROUND(F, d, a, b, c, in[ 9] + K1, 7);
2216 - ROUND(F, c, d, a, b, in[10] + K1, 11);
2217 - ROUND(F, b, c, d, a, in[11] + K1, 19);
2218 -
2219 - /* Round 2 */
2220 - ROUND(G, a, b, c, d, in[ 1] + K2, 3);
2221 - ROUND(G, d, a, b, c, in[ 3] + K2, 5);
2222 - ROUND(G, c, d, a, b, in[ 5] + K2, 9);
2223 - ROUND(G, b, c, d, a, in[ 7] + K2, 13);
2224 - ROUND(G, a, b, c, d, in[ 9] + K2, 3);
2225 - ROUND(G, d, a, b, c, in[11] + K2, 5);
2226 - ROUND(G, c, d, a, b, in[ 0] + K2, 9);
2227 - ROUND(G, b, c, d, a, in[ 2] + K2, 13);
2228 - ROUND(G, a, b, c, d, in[ 4] + K2, 3);
2229 - ROUND(G, d, a, b, c, in[ 6] + K2, 5);
2230 - ROUND(G, c, d, a, b, in[ 8] + K2, 9);
2231 - ROUND(G, b, c, d, a, in[10] + K2, 13);
2232 -
2233 - /* Round 3 */
2234 - ROUND(H, a, b, c, d, in[ 3] + K3, 3);
2235 - ROUND(H, d, a, b, c, in[ 7] + K3, 9);
2236 - ROUND(H, c, d, a, b, in[11] + K3, 11);
2237 - ROUND(H, b, c, d, a, in[ 2] + K3, 15);
2238 - ROUND(H, a, b, c, d, in[ 6] + K3, 3);
2239 - ROUND(H, d, a, b, c, in[10] + K3, 9);
2240 - ROUND(H, c, d, a, b, in[ 1] + K3, 11);
2241 - ROUND(H, b, c, d, a, in[ 5] + K3, 15);
2242 - ROUND(H, a, b, c, d, in[ 9] + K3, 3);
2243 - ROUND(H, d, a, b, c, in[ 0] + K3, 9);
2244 - ROUND(H, c, d, a, b, in[ 4] + K3, 11);
2245 - ROUND(H, b, c, d, a, in[ 8] + K3, 15);
2246 -
2247 - return buf[1] + b; /* "most hashed" word */
2248 - /* Alternative: return sum of all words? */
2249 -}
2250 -#endif
2251 -
2252 -#undef ROUND
2253 -#undef F
2254 -#undef G
2255 -#undef H
2256 -#undef K1
2257 -#undef K2
2258 -#undef K3
2259 -
2260 -/* This should not be decreased so low that ISNs wrap too fast. */
2261 -#define REKEY_INTERVAL (300 * HZ)
2262 -/*
2263 - * Bit layout of the tcp sequence numbers (before adding current time):
2264 - * bit 24-31: increased after every key exchange
2265 - * bit 0-23: hash(source,dest)
2266 - *
2267 - * The implementation is similar to the algorithm described
2268 - * in the Appendix of RFC 1185, except that
2269 - * - it uses a 1 MHz clock instead of a 250 kHz clock
2270 - * - it performs a rekey every 5 minutes, which is equivalent
2271 - * to a (source,dest) tulple dependent forward jump of the
2272 - * clock by 0..2^(HASH_BITS+1)
2273 - *
2274 - * Thus the average ISN wraparound time is 68 minutes instead of
2275 - * 4.55 hours.
2276 - *
2277 - * SMP cleanup and lock avoidance with poor man's RCU.
2278 - * Manfred Spraul <manfred@colorfullife.com>
2279 - *
2280 - */
2281 -#define COUNT_BITS 8
2282 -#define COUNT_MASK ((1 << COUNT_BITS) - 1)
2283 -#define HASH_BITS 24
2284 -#define HASH_MASK ((1 << HASH_BITS) - 1)
2285 -
2286 -static struct keydata {
2287 - __u32 count; /* already shifted to the final position */
2288 - __u32 secret[12];
2289 -} ____cacheline_aligned ip_keydata[2];
2290 -
2291 -static unsigned int ip_cnt;
2292 -
2293 -static void rekey_seq_generator(struct work_struct *work);
2294 -
2295 -static DECLARE_DELAYED_WORK(rekey_work, rekey_seq_generator);
2296 -
2297 -/*
2298 - * Lock avoidance:
2299 - * The ISN generation runs lockless - it's just a hash over random data.
2300 - * State changes happen every 5 minutes when the random key is replaced.
2301 - * Synchronization is performed by having two copies of the hash function
2302 - * state and rekey_seq_generator always updates the inactive copy.
2303 - * The copy is then activated by updating ip_cnt.
2304 - * The implementation breaks down if someone blocks the thread
2305 - * that processes SYN requests for more than 5 minutes. Should never
2306 - * happen, and even if that happens only a not perfectly compliant
2307 - * ISN is generated, nothing fatal.
2308 - */
2309 -static void rekey_seq_generator(struct work_struct *work)
2310 -{
2311 - struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];
2312 -
2313 - get_random_bytes(keyptr->secret, sizeof(keyptr->secret));
2314 - keyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS;
2315 - smp_wmb();
2316 - ip_cnt++;
2317 - schedule_delayed_work(&rekey_work,
2318 - round_jiffies_relative(REKEY_INTERVAL));
2319 -}
2320 -
2321 -static inline struct keydata *get_keyptr(void)
2322 -{
2323 - struct keydata *keyptr = &ip_keydata[ip_cnt & 1];
2324 -
2325 - smp_rmb();
2326 -
2327 - return keyptr;
2328 -}
2329 -
2330 -static __init int seqgen_init(void)
2331 -{
2332 - rekey_seq_generator(NULL);
2333 + get_random_bytes(random_int_secret, sizeof(random_int_secret));
2334 return 0;
2335 }
2336 -late_initcall(seqgen_init);
2337 -
2338 -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
2339 -__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
2340 - __be16 sport, __be16 dport)
2341 -{
2342 - __u32 seq;
2343 - __u32 hash[12];
2344 - struct keydata *keyptr = get_keyptr();
2345 -
2346 - /* The procedure is the same as for IPv4, but addresses are longer.
2347 - * Thus we must use twothirdsMD4Transform.
2348 - */
2349 -
2350 - memcpy(hash, saddr, 16);
2351 - hash[4] = ((__force u16)sport << 16) + (__force u16)dport;
2352 - memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
2353 -
2354 - seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
2355 - seq += keyptr->count;
2356 -
2357 - seq += ktime_to_ns(ktime_get_real());
2358 -
2359 - return seq;
2360 -}
2361 -EXPORT_SYMBOL(secure_tcpv6_sequence_number);
2362 -#endif
2363 -
2364 -/* The code below is shamelessly stolen from secure_tcp_sequence_number().
2365 - * All blames to Andrey V. Savochkin <saw@msu.ru>.
2366 - */
2367 -__u32 secure_ip_id(__be32 daddr)
2368 -{
2369 - struct keydata *keyptr;
2370 - __u32 hash[4];
2371 -
2372 - keyptr = get_keyptr();
2373 -
2374 - /*
2375 - * Pick a unique starting offset for each IP destination.
2376 - * The dest ip address is placed in the starting vector,
2377 - * which is then hashed with random data.
2378 - */
2379 - hash[0] = (__force __u32)daddr;
2380 - hash[1] = keyptr->secret[9];
2381 - hash[2] = keyptr->secret[10];
2382 - hash[3] = keyptr->secret[11];
2383 -
2384 - return half_md4_transform(hash, keyptr->secret);
2385 -}
2386 -
2387 -#ifdef CONFIG_INET
2388 -
2389 -__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
2390 - __be16 sport, __be16 dport)
2391 -{
2392 - __u32 seq;
2393 - __u32 hash[4];
2394 - struct keydata *keyptr = get_keyptr();
2395 -
2396 - /*
2397 - * Pick a unique starting offset for each TCP connection endpoints
2398 - * (saddr, daddr, sport, dport).
2399 - * Note that the words are placed into the starting vector, which is
2400 - * then mixed with a partial MD4 over random data.
2401 - */
2402 - hash[0] = (__force u32)saddr;
2403 - hash[1] = (__force u32)daddr;
2404 - hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
2405 - hash[3] = keyptr->secret[11];
2406 -
2407 - seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK;
2408 - seq += keyptr->count;
2409 - /*
2410 - * As close as possible to RFC 793, which
2411 - * suggests using a 250 kHz clock.
2412 - * Further reading shows this assumes 2 Mb/s networks.
2413 - * For 10 Mb/s Ethernet, a 1 MHz clock is appropriate.
2414 - * For 10 Gb/s Ethernet, a 1 GHz clock should be ok, but
2415 - * we also need to limit the resolution so that the u32 seq
2416 - * overlaps less than one time per MSL (2 minutes).
2417 - * Choosing a clock of 64 ns period is OK. (period of 274 s)
2418 - */
2419 - seq += ktime_to_ns(ktime_get_real()) >> 6;
2420 -
2421 - return seq;
2422 -}
2423 -
2424 -/* Generate secure starting point for ephemeral IPV4 transport port search */
2425 -u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
2426 -{
2427 - struct keydata *keyptr = get_keyptr();
2428 - u32 hash[4];
2429 -
2430 - /*
2431 - * Pick a unique starting offset for each ephemeral port search
2432 - * (saddr, daddr, dport) and 48bits of random data.
2433 - */
2434 - hash[0] = (__force u32)saddr;
2435 - hash[1] = (__force u32)daddr;
2436 - hash[2] = (__force u32)dport ^ keyptr->secret[10];
2437 - hash[3] = keyptr->secret[11];
2438 -
2439 - return half_md4_transform(hash, keyptr->secret);
2440 -}
2441 -EXPORT_SYMBOL_GPL(secure_ipv4_port_ephemeral);
2442 -
2443 -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
2444 -u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
2445 - __be16 dport)
2446 -{
2447 - struct keydata *keyptr = get_keyptr();
2448 - u32 hash[12];
2449 -
2450 - memcpy(hash, saddr, 16);
2451 - hash[4] = (__force u32)dport;
2452 - memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
2453 -
2454 - return twothirdsMD4Transform((const __u32 *)daddr, hash);
2455 -}
2456 -#endif
2457 -
2458 -#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
2459 -/* Similar to secure_tcp_sequence_number but generate a 48 bit value
2460 - * bit's 32-47 increase every key exchange
2461 - * 0-31 hash(source, dest)
2462 - */
2463 -u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
2464 - __be16 sport, __be16 dport)
2465 -{
2466 - u64 seq;
2467 - __u32 hash[4];
2468 - struct keydata *keyptr = get_keyptr();
2469 -
2470 - hash[0] = (__force u32)saddr;
2471 - hash[1] = (__force u32)daddr;
2472 - hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
2473 - hash[3] = keyptr->secret[11];
2474 -
2475 - seq = half_md4_transform(hash, keyptr->secret);
2476 - seq |= ((u64)keyptr->count) << (32 - HASH_BITS);
2477 -
2478 - seq += ktime_to_ns(ktime_get_real());
2479 - seq &= (1ull << 48) - 1;
2480 -
2481 - return seq;
2482 -}
2483 -EXPORT_SYMBOL(secure_dccp_sequence_number);
2484 -#endif
2485 -
2486 -#endif /* CONFIG_INET */
2487 -
2488 +late_initcall(random_int_secret_init);
2489
2490 /*
2491 * Get a random word for internal kernel use only. Similar to urandom but
2492 @@ -1631,17 +1315,15 @@ EXPORT_SYMBOL(secure_dccp_sequence_number);
2493 * value is not cryptographically secure but for several uses the cost of
2494 * depleting entropy is too high
2495 */
2496 -DEFINE_PER_CPU(__u32 [4], get_random_int_hash);
2497 +DEFINE_PER_CPU(__u32 [MD5_DIGEST_WORDS], get_random_int_hash);
2498 unsigned int get_random_int(void)
2499 {
2500 - struct keydata *keyptr;
2501 __u32 *hash = get_cpu_var(get_random_int_hash);
2502 - int ret;
2503 + unsigned int ret;
2504
2505 - keyptr = get_keyptr();
2506 hash[0] += current->pid + jiffies + get_cycles();
2507 -
2508 - ret = half_md4_transform(hash, keyptr->secret);
2509 + md5_transform(hash, random_int_secret);
2510 + ret = hash[0];
2511 put_cpu_var(get_random_int_hash);
2512
2513 return ret;
2514 diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
2515 index 0929219..1bbb85b 100644
2516 --- a/drivers/gpu/drm/drm_edid.c
2517 +++ b/drivers/gpu/drm/drm_edid.c
2518 @@ -127,6 +127,23 @@ static const u8 edid_header[] = {
2519 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
2520 };
2521
2522 + /*
2523 + * Sanity check the header of the base EDID block. Return 8 if the header
2524 + * is perfect, down to 0 if it's totally wrong.
2525 + */
2526 +int drm_edid_header_is_valid(const u8 *raw_edid)
2527 +{
2528 + int i, score = 0;
2529 +
2530 + for (i = 0; i < sizeof(edid_header); i++)
2531 + if (raw_edid[i] == edid_header[i])
2532 + score++;
2533 +
2534 + return score;
2535 +}
2536 +EXPORT_SYMBOL(drm_edid_header_is_valid);
2537 +
2538 +
2539 /*
2540 * Sanity check the EDID block (base or extension). Return 0 if the block
2541 * doesn't check out, or 1 if it's valid.
2542 @@ -139,12 +156,7 @@ drm_edid_block_valid(u8 *raw_edid)
2543 struct edid *edid = (struct edid *)raw_edid;
2544
2545 if (raw_edid[0] == 0x00) {
2546 - int score = 0;
2547 -
2548 - for (i = 0; i < sizeof(edid_header); i++)
2549 - if (raw_edid[i] == edid_header[i])
2550 - score++;
2551 -
2552 + int score = drm_edid_header_is_valid(raw_edid);
2553 if (score == 8) ;
2554 else if (score >= 6) {
2555 DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
2556 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
2557 index 296fbd6..7eef6e1 100644
2558 --- a/drivers/gpu/drm/i915/i915_dma.c
2559 +++ b/drivers/gpu/drm/i915/i915_dma.c
2560 @@ -61,7 +61,6 @@ static void i915_write_hws_pga(struct drm_device *dev)
2561 static int i915_init_phys_hws(struct drm_device *dev)
2562 {
2563 drm_i915_private_t *dev_priv = dev->dev_private;
2564 - struct intel_ring_buffer *ring = LP_RING(dev_priv);
2565
2566 /* Program Hardware Status Page */
2567 dev_priv->status_page_dmah =
2568 @@ -71,10 +70,9 @@ static int i915_init_phys_hws(struct drm_device *dev)
2569 DRM_ERROR("Can not allocate hardware status page\n");
2570 return -ENOMEM;
2571 }
2572 - ring->status_page.page_addr =
2573 - (void __force __iomem *)dev_priv->status_page_dmah->vaddr;
2574
2575 - memset_io(ring->status_page.page_addr, 0, PAGE_SIZE);
2576 + memset_io((void __force __iomem *)dev_priv->status_page_dmah->vaddr,
2577 + 0, PAGE_SIZE);
2578
2579 i915_write_hws_pga(dev);
2580
2581 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
2582 index 3b03f85..9b1d669 100644
2583 --- a/drivers/gpu/drm/i915/i915_irq.c
2584 +++ b/drivers/gpu/drm/i915/i915_irq.c
2585 @@ -306,12 +306,15 @@ static void i915_hotplug_work_func(struct work_struct *work)
2586 struct drm_mode_config *mode_config = &dev->mode_config;
2587 struct intel_encoder *encoder;
2588
2589 + mutex_lock(&mode_config->mutex);
2590 DRM_DEBUG_KMS("running encoder hotplug functions\n");
2591
2592 list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
2593 if (encoder->hot_plug)
2594 encoder->hot_plug(encoder);
2595
2596 + mutex_unlock(&mode_config->mutex);
2597 +
2598 /* Just fire off a uevent and let userspace tell us what to do */
2599 drm_helper_hpd_irq_event(dev);
2600 }
2601 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
2602 index 0f1c799..5609c06 100644
2603 --- a/drivers/gpu/drm/i915/intel_display.c
2604 +++ b/drivers/gpu/drm/i915/intel_display.c
2605 @@ -2699,14 +2699,18 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
2606 I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
2607 }
2608
2609 + /*
2610 + * On ILK+ LUT must be loaded before the pipe is running but with
2611 + * clocks enabled
2612 + */
2613 + intel_crtc_load_lut(crtc);
2614 +
2615 intel_enable_pipe(dev_priv, pipe, is_pch_port);
2616 intel_enable_plane(dev_priv, plane, pipe);
2617
2618 if (is_pch_port)
2619 ironlake_pch_enable(crtc);
2620
2621 - intel_crtc_load_lut(crtc);
2622 -
2623 mutex_lock(&dev->struct_mutex);
2624 intel_update_fbc(dev);
2625 mutex_unlock(&dev->struct_mutex);
2626 diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
2627 index a06ff07..05f500c 100644
2628 --- a/drivers/gpu/drm/i915/intel_panel.c
2629 +++ b/drivers/gpu/drm/i915/intel_panel.c
2630 @@ -83,11 +83,15 @@ intel_pch_panel_fitting(struct drm_device *dev,
2631 u32 scaled_height = mode->hdisplay * adjusted_mode->vdisplay;
2632 if (scaled_width > scaled_height) { /* pillar */
2633 width = scaled_height / mode->vdisplay;
2634 + if (width & 1)
2635 + width++;
2636 x = (adjusted_mode->hdisplay - width + 1) / 2;
2637 y = 0;
2638 height = adjusted_mode->vdisplay;
2639 } else if (scaled_width < scaled_height) { /* letter */
2640 height = scaled_width / mode->hdisplay;
2641 + if (height & 1)
2642 + height++;
2643 y = (adjusted_mode->vdisplay - height + 1) / 2;
2644 x = 0;
2645 width = adjusted_mode->hdisplay;
2646 diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
2647 index 95c4b14..1f61fc7 100644
2648 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
2649 +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
2650 @@ -1319,6 +1319,9 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
2651 ring->get_seqno = pc_render_get_seqno;
2652 }
2653
2654 + if (!I915_NEED_GFX_HWS(dev))
2655 + ring->status_page.page_addr = dev_priv->status_page_dmah->vaddr;
2656 +
2657 ring->dev = dev;
2658 INIT_LIST_HEAD(&ring->active_list);
2659 INIT_LIST_HEAD(&ring->request_list);
2660 diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
2661 index 9792d4f..6d6b5f1 100644
2662 --- a/drivers/gpu/drm/radeon/radeon_connectors.c
2663 +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
2664 @@ -430,6 +430,45 @@ int radeon_connector_set_property(struct drm_connector *connector, struct drm_pr
2665 return 0;
2666 }
2667
2668 +/*
2669 + * Some integrated ATI Radeon chipset implementations (e. g.
2670 + * Asus M2A-VM HDMI) may indicate the availability of a DDC,
2671 + * even when there's no monitor connected. For these connectors
2672 + * following DDC probe extension will be applied: check also for the
2673 + * availability of EDID with at least a correct EDID header. Only then,
2674 + * DDC is assumed to be available. This prevents drm_get_edid() and
2675 + * drm_edid_block_valid() from periodically dumping data and kernel
2676 + * errors into the logs and onto the terminal.
2677 + */
2678 +static bool radeon_connector_needs_extended_probe(struct radeon_device *dev,
2679 + uint32_t supported_device,
2680 + int connector_type)
2681 +{
2682 + /* Asus M2A-VM HDMI board sends data to i2c bus even,
2683 + * if HDMI add-on card is not plugged in or HDMI is disabled in
2684 + * BIOS. Valid DDC can only be assumed, if also a valid EDID header
2685 + * can be retrieved via i2c bus during DDC probe */
2686 + if ((dev->pdev->device == 0x791e) &&
2687 + (dev->pdev->subsystem_vendor == 0x1043) &&
2688 + (dev->pdev->subsystem_device == 0x826d)) {
2689 + if ((connector_type == DRM_MODE_CONNECTOR_HDMIA) &&
2690 + (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
2691 + return true;
2692 + }
2693 + /* ECS A740GM-M with ATI RADEON 2100 sends data to i2c bus
2694 + * for a DVI connector that is not implemented */
2695 + if ((dev->pdev->device == 0x796e) &&
2696 + (dev->pdev->subsystem_vendor == 0x1019) &&
2697 + (dev->pdev->subsystem_device == 0x2615)) {
2698 + if ((connector_type == DRM_MODE_CONNECTOR_DVID) &&
2699 + (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
2700 + return true;
2701 + }
2702 +
2703 + /* Default: no EDID header probe required for DDC probing */
2704 + return false;
2705 +}
2706 +
2707 static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
2708 struct drm_connector *connector)
2709 {
2710 @@ -661,7 +700,8 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
2711 ret = connector_status_disconnected;
2712
2713 if (radeon_connector->ddc_bus)
2714 - dret = radeon_ddc_probe(radeon_connector);
2715 + dret = radeon_ddc_probe(radeon_connector,
2716 + radeon_connector->requires_extended_probe);
2717 if (dret) {
2718 if (radeon_connector->edid) {
2719 kfree(radeon_connector->edid);
2720 @@ -833,7 +873,8 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
2721 bool dret = false;
2722
2723 if (radeon_connector->ddc_bus)
2724 - dret = radeon_ddc_probe(radeon_connector);
2725 + dret = radeon_ddc_probe(radeon_connector,
2726 + radeon_connector->requires_extended_probe);
2727 if (dret) {
2728 if (radeon_connector->edid) {
2729 kfree(radeon_connector->edid);
2730 @@ -1251,7 +1292,8 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
2731 if (radeon_dp_getdpcd(radeon_connector))
2732 ret = connector_status_connected;
2733 } else {
2734 - if (radeon_ddc_probe(radeon_connector))
2735 + if (radeon_ddc_probe(radeon_connector,
2736 + radeon_connector->requires_extended_probe))
2737 ret = connector_status_connected;
2738 }
2739 }
2740 @@ -1406,6 +1448,9 @@ radeon_add_atom_connector(struct drm_device *dev,
2741 radeon_connector->shared_ddc = shared_ddc;
2742 radeon_connector->connector_object_id = connector_object_id;
2743 radeon_connector->hpd = *hpd;
2744 + radeon_connector->requires_extended_probe =
2745 + radeon_connector_needs_extended_probe(rdev, supported_device,
2746 + connector_type);
2747 radeon_connector->router = *router;
2748 if (router->ddc_valid || router->cd_valid) {
2749 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info);
2750 @@ -1752,6 +1797,9 @@ radeon_add_legacy_connector(struct drm_device *dev,
2751 radeon_connector->devices = supported_device;
2752 radeon_connector->connector_object_id = connector_object_id;
2753 radeon_connector->hpd = *hpd;
2754 + radeon_connector->requires_extended_probe =
2755 + radeon_connector_needs_extended_probe(rdev, supported_device,
2756 + connector_type);
2757 switch (connector_type) {
2758 case DRM_MODE_CONNECTOR_VGA:
2759 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
2760 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
2761 index 7cfaa7e..440e6ec 100644
2762 --- a/drivers/gpu/drm/radeon/radeon_device.c
2763 +++ b/drivers/gpu/drm/radeon/radeon_device.c
2764 @@ -704,8 +704,9 @@ int radeon_device_init(struct radeon_device *rdev,
2765 rdev->gpu_lockup = false;
2766 rdev->accel_working = false;
2767
2768 - DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X).\n",
2769 - radeon_family_name[rdev->family], pdev->vendor, pdev->device);
2770 + DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X).\n",
2771 + radeon_family_name[rdev->family], pdev->vendor, pdev->device,
2772 + pdev->subsystem_vendor, pdev->subsystem_device);
2773
2774 /* mutex initialization are all done here so we
2775 * can recall function without having locking issues */
2776 diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
2777 index 292f73f..ed085ce 100644
2778 --- a/drivers/gpu/drm/radeon/radeon_display.c
2779 +++ b/drivers/gpu/drm/radeon/radeon_display.c
2780 @@ -777,8 +777,17 @@ static int radeon_ddc_dump(struct drm_connector *connector)
2781 if (!radeon_connector->ddc_bus)
2782 return -1;
2783 edid = drm_get_edid(connector, &radeon_connector->ddc_bus->adapter);
2784 + /* Log EDID retrieval status here. In particular with regard to
2785 + * connectors with requires_extended_probe flag set, that will prevent
2786 + * function radeon_dvi_detect() to fetch EDID on this connector,
2787 + * as long as there is no valid EDID header found */
2788 if (edid) {
2789 + DRM_INFO("Radeon display connector %s: Found valid EDID",
2790 + drm_get_connector_name(connector));
2791 kfree(edid);
2792 + } else {
2793 + DRM_INFO("Radeon display connector %s: No monitor connected or invalid EDID",
2794 + drm_get_connector_name(connector));
2795 }
2796 return ret;
2797 }
2798 diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
2799 index 781196d..6c111c1 100644
2800 --- a/drivers/gpu/drm/radeon/radeon_i2c.c
2801 +++ b/drivers/gpu/drm/radeon/radeon_i2c.c
2802 @@ -32,17 +32,17 @@
2803 * radeon_ddc_probe
2804 *
2805 */
2806 -bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
2807 +bool radeon_ddc_probe(struct radeon_connector *radeon_connector, bool requires_extended_probe)
2808 {
2809 - u8 out_buf[] = { 0x0, 0x0};
2810 - u8 buf[2];
2811 + u8 out = 0x0;
2812 + u8 buf[8];
2813 int ret;
2814 struct i2c_msg msgs[] = {
2815 {
2816 .addr = 0x50,
2817 .flags = 0,
2818 .len = 1,
2819 - .buf = out_buf,
2820 + .buf = &out,
2821 },
2822 {
2823 .addr = 0x50,
2824 @@ -52,15 +52,31 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
2825 }
2826 };
2827
2828 + /* Read 8 bytes from i2c for extended probe of EDID header */
2829 + if (requires_extended_probe)
2830 + msgs[1].len = 8;
2831 +
2832 /* on hw with routers, select right port */
2833 if (radeon_connector->router.ddc_valid)
2834 radeon_router_select_ddc_port(radeon_connector);
2835
2836 ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
2837 - if (ret == 2)
2838 - return true;
2839 -
2840 - return false;
2841 + if (ret != 2)
2842 + /* Couldn't find an accessible DDC on this connector */
2843 + return false;
2844 + if (requires_extended_probe) {
2845 + /* Probe also for valid EDID header
2846 + * EDID header starts with:
2847 + * 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00.
2848 + * Only the first 6 bytes must be valid as
2849 + * drm_edid_block_valid() can fix the last 2 bytes */
2850 + if (drm_edid_header_is_valid(buf) < 6) {
2851 + /* Couldn't find an accessible EDID on this
2852 + * connector */
2853 + return false;
2854 + }
2855 + }
2856 + return true;
2857 }
2858
2859 /* bit banging i2c */
2860 diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
2861 index 6df4e3c..d09031c 100644
2862 --- a/drivers/gpu/drm/radeon/radeon_mode.h
2863 +++ b/drivers/gpu/drm/radeon/radeon_mode.h
2864 @@ -438,6 +438,9 @@ struct radeon_connector {
2865 struct radeon_i2c_chan *ddc_bus;
2866 /* some systems have an hdmi and vga port with a shared ddc line */
2867 bool shared_ddc;
2868 + /* for some Radeon chip families we apply an additional EDID header
2869 + check as part of the DDC probe */
2870 + bool requires_extended_probe;
2871 bool use_digital;
2872 /* we need to mind the EDID between detect
2873 and get modes due to analog/digital/tvencoder */
2874 @@ -514,7 +517,8 @@ extern void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c,
2875 u8 val);
2876 extern void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector);
2877 extern void radeon_router_select_cd_port(struct radeon_connector *radeon_connector);
2878 -extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector);
2879 +extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector,
2880 + bool requires_extended_probe);
2881 extern int radeon_ddc_get_modes(struct radeon_connector *radeon_connector);
2882
2883 extern struct drm_encoder *radeon_best_encoder(struct drm_connector *connector);
2884 diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
2885 index 9798811..b145b5a 100644
2886 --- a/drivers/isdn/i4l/isdn_net.c
2887 +++ b/drivers/isdn/i4l/isdn_net.c
2888 @@ -2531,6 +2531,9 @@ static void _isdn_setup(struct net_device *dev)
2889
2890 /* Setup the generic properties */
2891 dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2892 +
2893 + /* isdn prepends a header in the tx path, can't share skbs */
2894 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
2895 dev->header_ops = NULL;
2896 dev->netdev_ops = &isdn_netdev_ops;
2897
2898 diff --git a/drivers/net/Makefile b/drivers/net/Makefile
2899 index 776a478..d5ce011 100644
2900 --- a/drivers/net/Makefile
2901 +++ b/drivers/net/Makefile
2902 @@ -283,6 +283,7 @@ obj-$(CONFIG_USB_HSO) += usb/
2903 obj-$(CONFIG_USB_USBNET) += usb/
2904 obj-$(CONFIG_USB_ZD1201) += usb/
2905 obj-$(CONFIG_USB_IPHETH) += usb/
2906 +obj-$(CONFIG_USB_CDC_PHONET) += usb/
2907
2908 obj-$(CONFIG_WLAN) += wireless/
2909 obj-$(CONFIG_NET_TULIP) += tulip/
2910 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
2911 index 63c22b0..9ea2f21 100644
2912 --- a/drivers/net/bonding/bond_main.c
2913 +++ b/drivers/net/bonding/bond_main.c
2914 @@ -1625,8 +1625,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
2915
2916 if (slave_dev->type != ARPHRD_ETHER)
2917 bond_setup_by_slave(bond_dev, slave_dev);
2918 - else
2919 + else {
2920 ether_setup(bond_dev);
2921 + bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
2922 + }
2923
2924 netdev_bonding_change(bond_dev,
2925 NETDEV_POST_TYPE_CHANGE);
2926 @@ -4398,7 +4400,7 @@ static void bond_setup(struct net_device *bond_dev)
2927 bond_dev->tx_queue_len = 0;
2928 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
2929 bond_dev->priv_flags |= IFF_BONDING;
2930 - bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
2931 + bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
2932
2933 /* At first, we block adding VLANs. That's the only way to
2934 * prevent problems that occur when adding VLANs over an
2935 diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
2936 index 88fcb25..0624610 100644
2937 --- a/drivers/net/bonding/bond_sysfs.c
2938 +++ b/drivers/net/bonding/bond_sysfs.c
2939 @@ -992,6 +992,7 @@ static ssize_t bonding_store_primary(struct device *d,
2940 int i;
2941 struct slave *slave;
2942 struct bonding *bond = to_bond(d);
2943 + char ifname[IFNAMSIZ];
2944
2945 if (!rtnl_trylock())
2946 return restart_syscall();
2947 @@ -1002,32 +1003,33 @@ static ssize_t bonding_store_primary(struct device *d,
2948 if (!USES_PRIMARY(bond->params.mode)) {
2949 pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
2950 bond->dev->name, bond->dev->name, bond->params.mode);
2951 - } else {
2952 - bond_for_each_slave(bond, slave, i) {
2953 - if (strnicmp
2954 - (slave->dev->name, buf,
2955 - strlen(slave->dev->name)) == 0) {
2956 - pr_info("%s: Setting %s as primary slave.\n",
2957 - bond->dev->name, slave->dev->name);
2958 - bond->primary_slave = slave;
2959 - strcpy(bond->params.primary, slave->dev->name);
2960 - bond_select_active_slave(bond);
2961 - goto out;
2962 - }
2963 - }
2964 + goto out;
2965 + }
2966
2967 - /* if we got here, then we didn't match the name of any slave */
2968 + sscanf(buf, "%16s", ifname); /* IFNAMSIZ */
2969
2970 - if (strlen(buf) == 0 || buf[0] == '\n') {
2971 - pr_info("%s: Setting primary slave to None.\n",
2972 - bond->dev->name);
2973 - bond->primary_slave = NULL;
2974 - bond_select_active_slave(bond);
2975 - } else {
2976 - pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n",
2977 - bond->dev->name, (int)strlen(buf) - 1, buf);
2978 + /* check to see if we are clearing primary */
2979 + if (!strlen(ifname) || buf[0] == '\n') {
2980 + pr_info("%s: Setting primary slave to None.\n",
2981 + bond->dev->name);
2982 + bond->primary_slave = NULL;
2983 + bond_select_active_slave(bond);
2984 + goto out;
2985 + }
2986 +
2987 + bond_for_each_slave(bond, slave, i) {
2988 + if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
2989 + pr_info("%s: Setting %s as primary slave.\n",
2990 + bond->dev->name, slave->dev->name);
2991 + bond->primary_slave = slave;
2992 + strcpy(bond->params.primary, slave->dev->name);
2993 + bond_select_active_slave(bond);
2994 + goto out;
2995 }
2996 }
2997 +
2998 + pr_info("%s: Unable to set %.*s as primary slave.\n",
2999 + bond->dev->name, (int)strlen(buf) - 1, buf);
3000 out:
3001 write_unlock_bh(&bond->curr_slave_lock);
3002 read_unlock(&bond->lock);
3003 @@ -1162,6 +1164,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
3004 struct slave *old_active = NULL;
3005 struct slave *new_active = NULL;
3006 struct bonding *bond = to_bond(d);
3007 + char ifname[IFNAMSIZ];
3008
3009 if (!rtnl_trylock())
3010 return restart_syscall();
3011 @@ -1170,56 +1173,62 @@ static ssize_t bonding_store_active_slave(struct device *d,
3012 read_lock(&bond->lock);
3013 write_lock_bh(&bond->curr_slave_lock);
3014
3015 - if (!USES_PRIMARY(bond->params.mode))
3016 + if (!USES_PRIMARY(bond->params.mode)) {
3017 pr_info("%s: Unable to change active slave; %s is in mode %d\n",
3018 bond->dev->name, bond->dev->name, bond->params.mode);
3019 - else {
3020 - bond_for_each_slave(bond, slave, i) {
3021 - if (strnicmp
3022 - (slave->dev->name, buf,
3023 - strlen(slave->dev->name)) == 0) {
3024 - old_active = bond->curr_active_slave;
3025 - new_active = slave;
3026 - if (new_active == old_active) {
3027 - /* do nothing */
3028 - pr_info("%s: %s is already the current active slave.\n",
3029 + goto out;
3030 + }
3031 +
3032 + sscanf(buf, "%16s", ifname); /* IFNAMSIZ */
3033 +
3034 + /* check to see if we are clearing active */
3035 + if (!strlen(ifname) || buf[0] == '\n') {
3036 + pr_info("%s: Clearing current active slave.\n",
3037 + bond->dev->name);
3038 + bond->curr_active_slave = NULL;
3039 + bond_select_active_slave(bond);
3040 + goto out;
3041 + }
3042 +
3043 + bond_for_each_slave(bond, slave, i) {
3044 + if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
3045 + old_active = bond->curr_active_slave;
3046 + new_active = slave;
3047 + if (new_active == old_active) {
3048 + /* do nothing */
3049 + pr_info("%s: %s is already the current"
3050 + " active slave.\n",
3051 + bond->dev->name,
3052 + slave->dev->name);
3053 + goto out;
3054 + }
3055 + else {
3056 + if ((new_active) &&
3057 + (old_active) &&
3058 + (new_active->link == BOND_LINK_UP) &&
3059 + IS_UP(new_active->dev)) {
3060 + pr_info("%s: Setting %s as active"
3061 + " slave.\n",
3062 bond->dev->name,
3063 slave->dev->name);
3064 - goto out;
3065 + bond_change_active_slave(bond,
3066 + new_active);
3067 }
3068 else {
3069 - if ((new_active) &&
3070 - (old_active) &&
3071 - (new_active->link == BOND_LINK_UP) &&
3072 - IS_UP(new_active->dev)) {
3073 - pr_info("%s: Setting %s as active slave.\n",
3074 - bond->dev->name,
3075 - slave->dev->name);
3076 - bond_change_active_slave(bond, new_active);
3077 - }
3078 - else {
3079 - pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n",
3080 - bond->dev->name,
3081 - slave->dev->name,
3082 - slave->dev->name);
3083 - }
3084 - goto out;
3085 + pr_info("%s: Could not set %s as"
3086 + " active slave; either %s is"
3087 + " down or the link is down.\n",
3088 + bond->dev->name,
3089 + slave->dev->name,
3090 + slave->dev->name);
3091 }
3092 + goto out;
3093 }
3094 }
3095 -
3096 - /* if we got here, then we didn't match the name of any slave */
3097 -
3098 - if (strlen(buf) == 0 || buf[0] == '\n') {
3099 - pr_info("%s: Setting active slave to None.\n",
3100 - bond->dev->name);
3101 - bond->primary_slave = NULL;
3102 - bond_select_active_slave(bond);
3103 - } else {
3104 - pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n",
3105 - bond->dev->name, (int)strlen(buf) - 1, buf);
3106 - }
3107 }
3108 +
3109 + pr_info("%s: Unable to set %.*s as active slave.\n",
3110 + bond->dev->name, (int)strlen(buf) - 1, buf);
3111 out:
3112 write_unlock_bh(&bond->curr_slave_lock);
3113 read_unlock(&bond->lock);
3114 diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
3115 index dd8ab05..8d28602 100644
3116 --- a/drivers/net/e1000e/lib.c
3117 +++ b/drivers/net/e1000e/lib.c
3118 @@ -190,7 +190,8 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
3119 /* Check for LOM (vs. NIC) or one of two valid mezzanine cards */
3120 if (!((nvm_data & NVM_COMPAT_LOM) ||
3121 (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_DUAL) ||
3122 - (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)))
3123 + (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) ||
3124 + (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES)))
3125 goto out;
3126
3127 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
3128 diff --git a/drivers/net/gianfar_ptp.c b/drivers/net/gianfar_ptp.c
3129 index d8e1753..c413479 100644
3130 --- a/drivers/net/gianfar_ptp.c
3131 +++ b/drivers/net/gianfar_ptp.c
3132 @@ -193,14 +193,9 @@ static void set_alarm(struct etsects *etsects)
3133 /* Caller must hold etsects->lock. */
3134 static void set_fipers(struct etsects *etsects)
3135 {
3136 - u32 tmr_ctrl = gfar_read(&etsects->regs->tmr_ctrl);
3137 -
3138 - gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl & (~TE));
3139 - gfar_write(&etsects->regs->tmr_prsc, etsects->tmr_prsc);
3140 + set_alarm(etsects);
3141 gfar_write(&etsects->regs->tmr_fiper1, etsects->tmr_fiper1);
3142 gfar_write(&etsects->regs->tmr_fiper2, etsects->tmr_fiper2);
3143 - set_alarm(etsects);
3144 - gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl|TE);
3145 }
3146
3147 /*
3148 @@ -511,7 +506,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
3149 gfar_write(&etsects->regs->tmr_fiper1, etsects->tmr_fiper1);
3150 gfar_write(&etsects->regs->tmr_fiper2, etsects->tmr_fiper2);
3151 set_alarm(etsects);
3152 - gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl|FS|RTPE|TE);
3153 + gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl|FS|RTPE|TE|FRD);
3154
3155 spin_unlock_irqrestore(&etsects->lock, flags);
3156
3157 diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
3158 index 4fecaed..2b98461 100644
3159 --- a/drivers/net/ifb.c
3160 +++ b/drivers/net/ifb.c
3161 @@ -145,7 +145,7 @@ static void ifb_setup(struct net_device *dev)
3162
3163 dev->flags |= IFF_NOARP;
3164 dev->flags &= ~IFF_MULTICAST;
3165 - dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
3166 + dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
3167 random_ether_addr(dev->dev_addr);
3168 }
3169
3170 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
3171 index d6aeaa5..2f3c48d 100644
3172 --- a/drivers/net/macvlan.c
3173 +++ b/drivers/net/macvlan.c
3174 @@ -547,7 +547,7 @@ void macvlan_common_setup(struct net_device *dev)
3175 {
3176 ether_setup(dev);
3177
3178 - dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
3179 + dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
3180 dev->netdev_ops = &macvlan_netdev_ops;
3181 dev->destructor = free_netdev;
3182 dev->header_ops = &macvlan_hard_header_ops,
3183 diff --git a/drivers/net/niu.c b/drivers/net/niu.c
3184 index cc25bff..2f8c351 100644
3185 --- a/drivers/net/niu.c
3186 +++ b/drivers/net/niu.c
3187 @@ -9196,7 +9196,7 @@ static int __devinit niu_ldg_init(struct niu *np)
3188
3189 first_chan = 0;
3190 for (i = 0; i < port; i++)
3191 - first_chan += parent->rxchan_per_port[port];
3192 + first_chan += parent->rxchan_per_port[i];
3193 num_chan = parent->rxchan_per_port[port];
3194
3195 for (i = first_chan; i < (first_chan + num_chan); i++) {
3196 @@ -9212,7 +9212,7 @@ static int __devinit niu_ldg_init(struct niu *np)
3197
3198 first_chan = 0;
3199 for (i = 0; i < port; i++)
3200 - first_chan += parent->txchan_per_port[port];
3201 + first_chan += parent->txchan_per_port[i];
3202 num_chan = parent->txchan_per_port[port];
3203 for (i = first_chan; i < (first_chan + num_chan); i++) {
3204 err = niu_ldg_assign_ldn(np, parent,
3205 diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
3206 index 2cd8dc5..cb6e0b4 100644
3207 --- a/drivers/net/phy/dp83640.c
3208 +++ b/drivers/net/phy/dp83640.c
3209 @@ -34,8 +34,7 @@
3210 #define PAGESEL 0x13
3211 #define LAYER4 0x02
3212 #define LAYER2 0x01
3213 -#define MAX_RXTS 4
3214 -#define MAX_TXTS 4
3215 +#define MAX_RXTS 64
3216 #define N_EXT_TS 1
3217 #define PSF_PTPVER 2
3218 #define PSF_EVNT 0x4000
3219 @@ -218,7 +217,7 @@ static void phy2rxts(struct phy_rxts *p, struct rxts *rxts)
3220 rxts->seqid = p->seqid;
3221 rxts->msgtype = (p->msgtype >> 12) & 0xf;
3222 rxts->hash = p->msgtype & 0x0fff;
3223 - rxts->tmo = jiffies + HZ;
3224 + rxts->tmo = jiffies + 2;
3225 }
3226
3227 static u64 phy2txts(struct phy_txts *p)
3228 diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
3229 index 5990621..5f838ef 100644
3230 --- a/drivers/net/r8169.c
3231 +++ b/drivers/net/r8169.c
3232 @@ -236,6 +236,7 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = {
3233 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
3234 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
3235 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 },
3236 + { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4302), 0, 0, RTL_CFG_0 },
3237 { PCI_DEVICE(PCI_VENDOR_ID_AT, 0xc107), 0, 0, RTL_CFG_0 },
3238 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 },
3239 { PCI_VENDOR_ID_LINKSYS, 0x1032,
3240 diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
3241 index b436e00..f6d26ab 100644
3242 --- a/drivers/net/sis190.c
3243 +++ b/drivers/net/sis190.c
3244 @@ -1824,6 +1824,16 @@ static int sis190_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
3245 generic_mii_ioctl(&tp->mii_if, if_mii(ifr), cmd, NULL);
3246 }
3247
3248 +static int sis190_mac_addr(struct net_device *dev, void *p)
3249 +{
3250 + int rc;
3251 +
3252 + rc = eth_mac_addr(dev, p);
3253 + if (!rc)
3254 + sis190_init_rxfilter(dev);
3255 + return rc;
3256 +}
3257 +
3258 static const struct net_device_ops sis190_netdev_ops = {
3259 .ndo_open = sis190_open,
3260 .ndo_stop = sis190_close,
3261 @@ -1832,7 +1842,7 @@ static const struct net_device_ops sis190_netdev_ops = {
3262 .ndo_tx_timeout = sis190_tx_timeout,
3263 .ndo_set_multicast_list = sis190_set_rx_mode,
3264 .ndo_change_mtu = eth_change_mtu,
3265 - .ndo_set_mac_address = eth_mac_addr,
3266 + .ndo_set_mac_address = sis190_mac_addr,
3267 .ndo_validate_addr = eth_validate_addr,
3268 #ifdef CONFIG_NET_POLL_CONTROLLER
3269 .ndo_poll_controller = sis190_netpoll,
3270 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
3271 index 5235f48..fb50e5a 100644
3272 --- a/drivers/net/tun.c
3273 +++ b/drivers/net/tun.c
3274 @@ -528,6 +528,7 @@ static void tun_net_init(struct net_device *dev)
3275 dev->netdev_ops = &tap_netdev_ops;
3276 /* Ethernet TAP Device */
3277 ether_setup(dev);
3278 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
3279
3280 random_ether_addr(dev->dev_addr);
3281
3282 diff --git a/drivers/net/veth.c b/drivers/net/veth.c
3283 index 8461576..4bf7c6d 100644
3284 --- a/drivers/net/veth.c
3285 +++ b/drivers/net/veth.c
3286 @@ -262,6 +262,8 @@ static void veth_setup(struct net_device *dev)
3287 {
3288 ether_setup(dev);
3289
3290 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
3291 +
3292 dev->netdev_ops = &veth_netdev_ops;
3293 dev->ethtool_ops = &veth_ethtool_ops;
3294 dev->features |= NETIF_F_LLTX;
3295 diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
3296 index fc433f2..13f9997 100644
3297 --- a/drivers/net/wan/hdlc_fr.c
3298 +++ b/drivers/net/wan/hdlc_fr.c
3299 @@ -1083,9 +1083,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
3300
3301 used = pvc_is_used(pvc);
3302
3303 - if (type == ARPHRD_ETHER)
3304 + if (type == ARPHRD_ETHER) {
3305 dev = alloc_netdev(0, "pvceth%d", ether_setup);
3306 - else
3307 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
3308 + } else
3309 dev = alloc_netdev(0, "pvc%d", pvc_setup);
3310
3311 if (!dev) {
3312 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
3313 index 55cf71f..e1b3e3c 100644
3314 --- a/drivers/net/wireless/airo.c
3315 +++ b/drivers/net/wireless/airo.c
3316 @@ -2823,6 +2823,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
3317 dev->wireless_data = &ai->wireless_data;
3318 dev->irq = irq;
3319 dev->base_addr = port;
3320 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
3321
3322 SET_NETDEV_DEV(dev, dmdev);
3323
3324 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
3325 index f344cc2..c32f9d1 100644
3326 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
3327 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
3328 @@ -309,11 +309,7 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
3329 u8 i;
3330 u32 val;
3331
3332 - if (ah->is_pciexpress != true)
3333 - return;
3334 -
3335 - /* Do not touch SerDes registers */
3336 - if (ah->config.pcie_powersave_enable == 2)
3337 + if (ah->is_pciexpress != true || ah->aspm_enabled != true)
3338 return;
3339
3340 /* Nothing to do on restore for 11N */
3341 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
3342 index ff8150e..7e07f0f 100644
3343 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
3344 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
3345 @@ -306,7 +306,7 @@ static const struct ar9300_eeprom ar9300_default = {
3346 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3347 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
3348
3349 - { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
3350 + { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
3351 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3352 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3353
3354 @@ -883,7 +883,7 @@ static const struct ar9300_eeprom ar9300_x113 = {
3355 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3356 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
3357
3358 - { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
3359 + { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
3360 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3361 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3362
3363 @@ -2039,7 +2039,7 @@ static const struct ar9300_eeprom ar9300_x112 = {
3364 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3365 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
3366
3367 - { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
3368 + { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
3369 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3370 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
3371
3372 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
3373 index 392bf0f..7e02fb4 100644
3374 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
3375 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
3376 @@ -351,11 +351,7 @@ static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
3377 int restore,
3378 int power_off)
3379 {
3380 - if (ah->is_pciexpress != true)
3381 - return;
3382 -
3383 - /* Do not touch SerDes registers */
3384 - if (ah->config.pcie_powersave_enable == 2)
3385 + if (ah->is_pciexpress != true || ah->aspm_enabled != true)
3386 return;
3387
3388 /* Nothing to do on restore for 11N */
3389 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
3390 index 443090d..efdbe98 100644
3391 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
3392 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
3393 @@ -848,7 +848,7 @@
3394 #define AR_PHY_TPC_11_B1 (AR_SM1_BASE + 0x220)
3395 #define AR_PHY_PDADC_TAB_1 (AR_SM1_BASE + 0x240)
3396 #define AR_PHY_TX_IQCAL_STATUS_B1 (AR_SM1_BASE + 0x48c)
3397 -#define AR_PHY_TX_IQCAL_CORR_COEFF_B1(_i) (AR_SM_BASE + 0x450 + ((_i) << 2))
3398 +#define AR_PHY_TX_IQCAL_CORR_COEFF_B1(_i) (AR_SM1_BASE + 0x450 + ((_i) << 2))
3399
3400 /*
3401 * Channel 2 Register Map
3402 diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
3403 index 1be7c8b..03900ca 100644
3404 --- a/drivers/net/wireless/ath/ath9k/hw.c
3405 +++ b/drivers/net/wireless/ath/ath9k/hw.c
3406 @@ -299,6 +299,14 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah)
3407 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
3408 }
3409
3410 +static void ath9k_hw_aspm_init(struct ath_hw *ah)
3411 +{
3412 + struct ath_common *common = ath9k_hw_common(ah);
3413 +
3414 + if (common->bus_ops->aspm_init)
3415 + common->bus_ops->aspm_init(common);
3416 +}
3417 +
3418 /* This should work for all families including legacy */
3419 static bool ath9k_hw_chip_test(struct ath_hw *ah)
3420 {
3421 @@ -359,7 +367,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
3422 ah->config.additional_swba_backoff = 0;
3423 ah->config.ack_6mb = 0x0;
3424 ah->config.cwm_ignore_extcca = 0;
3425 - ah->config.pcie_powersave_enable = 0;
3426 ah->config.pcie_clock_req = 0;
3427 ah->config.pcie_waen = 0;
3428 ah->config.analog_shiftreg = 1;
3429 @@ -577,7 +584,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
3430
3431
3432 if (ah->is_pciexpress)
3433 - ath9k_hw_configpcipowersave(ah, 0, 0);
3434 + ath9k_hw_aspm_init(ah);
3435 else
3436 ath9k_hw_disablepcie(ah);
3437
3438 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
3439 index 4b157c5..939cc9d 100644
3440 --- a/drivers/net/wireless/ath/ath9k/hw.h
3441 +++ b/drivers/net/wireless/ath/ath9k/hw.h
3442 @@ -215,7 +215,6 @@ struct ath9k_ops_config {
3443 int additional_swba_backoff;
3444 int ack_6mb;
3445 u32 cwm_ignore_extcca;
3446 - u8 pcie_powersave_enable;
3447 bool pcieSerDesWrite;
3448 u8 pcie_clock_req;
3449 u32 pcie_waen;
3450 @@ -671,6 +670,7 @@ struct ath_hw {
3451
3452 bool sw_mgmt_crypto;
3453 bool is_pciexpress;
3454 + bool aspm_enabled;
3455 bool is_monitoring;
3456 bool need_an_top2_fixup;
3457 u16 tx_trig_level;
3458 @@ -870,6 +870,7 @@ struct ath_bus_ops {
3459 bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
3460 void (*bt_coex_prep)(struct ath_common *common);
3461 void (*extn_synch_en)(struct ath_common *common);
3462 + void (*aspm_init)(struct ath_common *common);
3463 };
3464
3465 static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
3466 diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
3467 index 45c585a..5a9fd21 100644
3468 --- a/drivers/net/wireless/ath/ath9k/init.c
3469 +++ b/drivers/net/wireless/ath/ath9k/init.c
3470 @@ -665,8 +665,10 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
3471 static void ath9k_init_txpower_limits(struct ath_softc *sc)
3472 {
3473 struct ath_hw *ah = sc->sc_ah;
3474 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3475 struct ath9k_channel *curchan = ah->curchan;
3476
3477 + ah->txchainmask = common->tx_chainmask;
3478 if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
3479 ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ);
3480 if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
3481 diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
3482 index 3bad0b2..be4ea13 100644
3483 --- a/drivers/net/wireless/ath/ath9k/pci.c
3484 +++ b/drivers/net/wireless/ath/ath9k/pci.c
3485 @@ -16,6 +16,7 @@
3486
3487 #include <linux/nl80211.h>
3488 #include <linux/pci.h>
3489 +#include <linux/pci-aspm.h>
3490 #include <linux/ath9k_platform.h>
3491 #include "ath9k.h"
3492
3493 @@ -115,12 +116,38 @@ static void ath_pci_extn_synch_enable(struct ath_common *common)
3494 pci_write_config_byte(pdev, sc->sc_ah->caps.pcie_lcr_offset, lnkctl);
3495 }
3496
3497 +static void ath_pci_aspm_init(struct ath_common *common)
3498 +{
3499 + struct ath_softc *sc = (struct ath_softc *) common->priv;
3500 + struct ath_hw *ah = sc->sc_ah;
3501 + struct pci_dev *pdev = to_pci_dev(sc->dev);
3502 + struct pci_dev *parent;
3503 + int pos;
3504 + u8 aspm;
3505 +
3506 + if (!pci_is_pcie(pdev))
3507 + return;
3508 +
3509 + parent = pdev->bus->self;
3510 + if (WARN_ON(!parent))
3511 + return;
3512 +
3513 + pos = pci_pcie_cap(parent);
3514 + pci_read_config_byte(parent, pos + PCI_EXP_LNKCTL, &aspm);
3515 + if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) {
3516 + ah->aspm_enabled = true;
3517 + /* Initialize PCIe PM and SERDES registers. */
3518 + ath9k_hw_configpcipowersave(ah, 0, 0);
3519 + }
3520 +}
3521 +
3522 static const struct ath_bus_ops ath_pci_bus_ops = {
3523 .ath_bus_type = ATH_PCI,
3524 .read_cachesize = ath_pci_read_cachesize,
3525 .eeprom_read = ath_pci_eeprom_read,
3526 .bt_coex_prep = ath_pci_bt_coex_prep,
3527 .extn_synch_en = ath_pci_extn_synch_enable,
3528 + .aspm_init = ath_pci_aspm_init,
3529 };
3530
3531 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3532 diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
3533 index d508482..89a116f 100644
3534 --- a/drivers/net/wireless/hostap/hostap_main.c
3535 +++ b/drivers/net/wireless/hostap/hostap_main.c
3536 @@ -855,6 +855,7 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local,
3537
3538 iface = netdev_priv(dev);
3539 ether_setup(dev);
3540 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
3541
3542 /* kernel callbacks */
3543 if (iface) {
3544 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c
3545 index d096dc2..dcc1552 100644
3546 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c
3547 +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c
3548 @@ -1747,7 +1747,11 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
3549 }
3550
3551 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
3552 -
3553 + /*
3554 + * We do not commit tx power settings while channel changing,
3555 + * do it now if tx power changed.
3556 + */
3557 + iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
3558 return 0;
3559 }
3560
3561 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
3562 index facc94e..0a1babb 100644
3563 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c
3564 +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
3565 @@ -1237,7 +1237,12 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
3566
3567 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
3568 iwl_legacy_print_rx_config_cmd(priv, ctx);
3569 - goto set_tx_power;
3570 + /*
3571 + * We do not commit tx power settings while channel changing,
3572 + * do it now if tx power changed.
3573 + */
3574 + iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
3575 + return 0;
3576 }
3577
3578 /* If we are currently associated and the new config requires
3579 @@ -1317,7 +1322,6 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
3580
3581 iwl4965_init_sensitivity(priv);
3582
3583 -set_tx_power:
3584 /* If we issue a new RXON command which required a tune then we must
3585 * send a new TXPOWER command or we won't be able to Tx any frames */
3586 ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true);
3587 diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
3588 index e816c27..f1c3f49 100644
3589 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c
3590 +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
3591 @@ -421,6 +421,7 @@ static struct iwl_base_params iwl5000_base_params = {
3592 .chain_noise_scale = 1000,
3593 .wd_timeout = IWL_LONG_WD_TIMEOUT,
3594 .max_event_log_size = 512,
3595 + .no_idle_support = true,
3596 };
3597 static struct iwl_ht_params iwl5000_ht_params = {
3598 .ht_greenfield_support = true,
3599 diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
3600 index a54d416..b76996a 100644
3601 --- a/drivers/net/wireless/iwlwifi/iwl-core.h
3602 +++ b/drivers/net/wireless/iwlwifi/iwl-core.h
3603 @@ -195,6 +195,7 @@ struct iwl_mod_params {
3604 * @temperature_kelvin: temperature report by uCode in kelvin
3605 * @max_event_log_size: size of event log buffer size for ucode event logging
3606 * @shadow_reg_enable: HW shadhow register bit
3607 + * @no_idle_support: do not support idle mode
3608 */
3609 struct iwl_base_params {
3610 int eeprom_size;
3611 @@ -216,6 +217,7 @@ struct iwl_base_params {
3612 bool temperature_kelvin;
3613 u32 max_event_log_size;
3614 const bool shadow_reg_enable;
3615 + const bool no_idle_support;
3616 };
3617 /*
3618 * @advanced_bt_coexist: support advanced bt coexist
3619 diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
3620 index 595c930..4a05a6a 100644
3621 --- a/drivers/net/wireless/iwlwifi/iwl-power.c
3622 +++ b/drivers/net/wireless/iwlwifi/iwl-power.c
3623 @@ -355,7 +355,8 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
3624
3625 dtimper = priv->hw->conf.ps_dtim_period ?: 1;
3626
3627 - if (priv->hw->conf.flags & IEEE80211_CONF_IDLE)
3628 + if (!priv->cfg->base_params->no_idle_support &&
3629 + priv->hw->conf.flags & IEEE80211_CONF_IDLE)
3630 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
3631 else if (iwl_tt_is_low_power_state(priv)) {
3632 /* in thermal throttling low power state */
3633 diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
3634 index 2a6aa85..5a45228 100644
3635 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
3636 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
3637 @@ -784,8 +784,7 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
3638 /*
3639 * Add space for the TXWI in front of the skb.
3640 */
3641 - skb_push(entry->skb, TXWI_DESC_SIZE);
3642 - memset(entry->skb, 0, TXWI_DESC_SIZE);
3643 + memset(skb_push(entry->skb, TXWI_DESC_SIZE), 0, TXWI_DESC_SIZE);
3644
3645 /*
3646 * Register descriptor details in skb frame descriptor.
3647 diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
3648 index 93bec14..a76fdbe 100644
3649 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
3650 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
3651 @@ -113,7 +113,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3652 * due to possible race conditions in mac80211.
3653 */
3654 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
3655 - goto exit_fail;
3656 + goto exit_free_skb;
3657
3658 /*
3659 * Use the ATIM queue if appropriate and present.
3660 @@ -127,7 +127,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3661 ERROR(rt2x00dev,
3662 "Attempt to send packet over invalid queue %d.\n"
3663 "Please file bug report to %s.\n", qid, DRV_PROJECT);
3664 - goto exit_fail;
3665 + goto exit_free_skb;
3666 }
3667
3668 /*
3669 @@ -159,6 +159,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3670
3671 exit_fail:
3672 rt2x00queue_pause_queue(queue);
3673 + exit_free_skb:
3674 dev_kfree_skb_any(skb);
3675 }
3676 EXPORT_SYMBOL_GPL(rt2x00mac_tx);
3677 diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
3678 index 254b64b..c872a23 100644
3679 --- a/drivers/net/wireless/rtlwifi/pci.c
3680 +++ b/drivers/net/wireless/rtlwifi/pci.c
3681 @@ -1709,15 +1709,17 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
3682 pcipriv->ndis_adapter.devnumber = PCI_SLOT(pdev->devfn);
3683 pcipriv->ndis_adapter.funcnumber = PCI_FUNC(pdev->devfn);
3684
3685 - /*find bridge info */
3686 - pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor;
3687 - for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) {
3688 - if (bridge_pdev->vendor == pcibridge_vendors[tmp]) {
3689 - pcipriv->ndis_adapter.pcibridge_vendor = tmp;
3690 - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
3691 - ("Pci Bridge Vendor is found index: %d\n",
3692 - tmp));
3693 - break;
3694 + if (bridge_pdev) {
3695 + /*find bridge info if available */
3696 + pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor;
3697 + for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) {
3698 + if (bridge_pdev->vendor == pcibridge_vendors[tmp]) {
3699 + pcipriv->ndis_adapter.pcibridge_vendor = tmp;
3700 + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
3701 + ("Pci Bridge Vendor is found index:"
3702 + " %d\n", tmp));
3703 + break;
3704 + }
3705 }
3706 }
3707
3708 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
3709 index 3c7857c..e1678b9 100644
3710 --- a/drivers/platform/x86/asus-wmi.c
3711 +++ b/drivers/platform/x86/asus-wmi.c
3712 @@ -797,8 +797,8 @@ exit:
3713 * Hwmon device
3714 */
3715 static ssize_t asus_hwmon_pwm1(struct device *dev,
3716 - struct device_attribute *attr,
3717 - char *buf)
3718 + struct device_attribute *attr,
3719 + char *buf)
3720 {
3721 struct asus_wmi *asus = dev_get_drvdata(dev);
3722 u32 value;
3723 @@ -809,7 +809,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev,
3724 if (err < 0)
3725 return err;
3726
3727 - value |= 0xFF;
3728 + value &= 0xFF;
3729
3730 if (value == 1) /* Low Speed */
3731 value = 85;
3732 @@ -869,7 +869,7 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
3733 * - reverved bits are non-zero
3734 * - sfun and presence bit are not set
3735 */
3736 - if (value != ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000
3737 + if (value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000
3738 || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT)))
3739 ok = false;
3740 }
3741 @@ -904,6 +904,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
3742 pr_err("Could not register asus hwmon device\n");
3743 return PTR_ERR(hwmon);
3744 }
3745 + dev_set_drvdata(hwmon, asus);
3746 asus->hwmon_device = hwmon;
3747 result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group);
3748 if (result)
3749 @@ -1164,14 +1165,18 @@ ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
3750 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
3751 const char *buf, size_t count)
3752 {
3753 - int value;
3754 + int value, rv;
3755
3756 if (!count || sscanf(buf, "%i", &value) != 1)
3757 return -EINVAL;
3758 if (value < 0 || value > 2)
3759 return -EINVAL;
3760
3761 - return asus_wmi_evaluate_method(ASUS_WMI_METHODID_CFVS, value, 0, NULL);
3762 + rv = asus_wmi_evaluate_method(ASUS_WMI_METHODID_CFVS, value, 0, NULL);
3763 + if (rv < 0)
3764 + return rv;
3765 +
3766 + return count;
3767 }
3768
3769 static DEVICE_ATTR(cpufv, S_IRUGO | S_IWUSR, NULL, store_cpufv);
3770 diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
3771 index efa0255..1da606c 100644
3772 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c
3773 +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
3774 @@ -94,7 +94,7 @@ module_param(diag_buffer_enable, int, 0);
3775 MODULE_PARM_DESC(diag_buffer_enable, " post diag buffers "
3776 "(TRACE=1/SNAPSHOT=2/EXTENDED=4/default=0)");
3777
3778 -int mpt2sas_fwfault_debug;
3779 +static int mpt2sas_fwfault_debug;
3780 MODULE_PARM_DESC(mpt2sas_fwfault_debug, " enable detection of firmware fault "
3781 "and halt firmware - (default=0)");
3782
3783 @@ -857,7 +857,7 @@ _base_interrupt(int irq, void *bus_id)
3784 completed_cmds = 0;
3785 cb_idx = 0xFF;
3786 do {
3787 - rd.word = rpf->Words;
3788 + rd.word = le64_to_cpu(rpf->Words);
3789 if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX)
3790 goto out;
3791 reply = 0;
3792 @@ -906,7 +906,7 @@ _base_interrupt(int irq, void *bus_id)
3793
3794 next:
3795
3796 - rpf->Words = ULLONG_MAX;
3797 + rpf->Words = cpu_to_le64(ULLONG_MAX);
3798 ioc->reply_post_host_index = (ioc->reply_post_host_index ==
3799 (ioc->reply_post_queue_depth - 1)) ? 0 :
3800 ioc->reply_post_host_index + 1;
3801 @@ -1817,7 +1817,9 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc)
3802 char desc[16];
3803 u8 revision;
3804 u32 iounit_pg1_flags;
3805 + u32 bios_version;
3806
3807 + bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
3808 pci_read_config_byte(ioc->pdev, PCI_CLASS_REVISION, &revision);
3809 strncpy(desc, ioc->manu_pg0.ChipName, 16);
3810 printk(MPT2SAS_INFO_FMT "%s: FWVersion(%02d.%02d.%02d.%02d), "
3811 @@ -1828,10 +1830,10 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc)
3812 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
3813 ioc->facts.FWVersion.Word & 0x000000FF,
3814 revision,
3815 - (ioc->bios_pg3.BiosVersion & 0xFF000000) >> 24,
3816 - (ioc->bios_pg3.BiosVersion & 0x00FF0000) >> 16,
3817 - (ioc->bios_pg3.BiosVersion & 0x0000FF00) >> 8,
3818 - ioc->bios_pg3.BiosVersion & 0x000000FF);
3819 + (bios_version & 0xFF000000) >> 24,
3820 + (bios_version & 0x00FF0000) >> 16,
3821 + (bios_version & 0x0000FF00) >> 8,
3822 + bios_version & 0x000000FF);
3823
3824 _base_display_dell_branding(ioc);
3825 _base_display_intel_branding(ioc);
3826 @@ -2150,7 +2152,7 @@ _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc)
3827 static int
3828 _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3829 {
3830 - Mpi2IOCFactsReply_t *facts;
3831 + struct mpt2sas_facts *facts;
3832 u32 queue_size, queue_diff;
3833 u16 max_sge_elements;
3834 u16 num_of_reply_frames;
3835 @@ -2783,7 +2785,7 @@ _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes,
3836 int i;
3837 u8 failed;
3838 u16 dummy;
3839 - u32 *mfp;
3840 + __le32 *mfp;
3841
3842 /* make sure doorbell is not in use */
3843 if ((readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) {
3844 @@ -2871,7 +2873,7 @@ _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes,
3845 writel(0, &ioc->chip->HostInterruptStatus);
3846
3847 if (ioc->logging_level & MPT_DEBUG_INIT) {
3848 - mfp = (u32 *)reply;
3849 + mfp = (__le32 *)reply;
3850 printk(KERN_INFO "\toffset:data\n");
3851 for (i = 0; i < reply_bytes/4; i++)
3852 printk(KERN_INFO "\t[0x%02x]:%08x\n", i*4,
3853 @@ -3097,7 +3099,8 @@ static int
3854 _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
3855 {
3856 Mpi2PortFactsRequest_t mpi_request;
3857 - Mpi2PortFactsReply_t mpi_reply, *pfacts;
3858 + Mpi2PortFactsReply_t mpi_reply;
3859 + struct mpt2sas_port_facts *pfacts;
3860 int mpi_reply_sz, mpi_request_sz, r;
3861
3862 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3863 @@ -3139,7 +3142,8 @@ static int
3864 _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3865 {
3866 Mpi2IOCFactsRequest_t mpi_request;
3867 - Mpi2IOCFactsReply_t mpi_reply, *facts;
3868 + Mpi2IOCFactsReply_t mpi_reply;
3869 + struct mpt2sas_facts *facts;
3870 int mpi_reply_sz, mpi_request_sz, r;
3871
3872 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3873 @@ -3225,17 +3229,6 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3874 mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION);
3875 mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION);
3876
3877 - /* In MPI Revision I (0xA), the SystemReplyFrameSize(offset 0x18) was
3878 - * removed and made reserved. For those with older firmware will need
3879 - * this fix. It was decided that the Reply and Request frame sizes are
3880 - * the same.
3881 - */
3882 - if ((ioc->facts.HeaderVersion >> 8) < 0xA) {
3883 - mpi_request.Reserved7 = cpu_to_le16(ioc->reply_sz);
3884 -/* mpi_request.SystemReplyFrameSize =
3885 - * cpu_to_le16(ioc->reply_sz);
3886 - */
3887 - }
3888
3889 mpi_request.SystemRequestFrameSize = cpu_to_le16(ioc->request_sz/4);
3890 mpi_request.ReplyDescriptorPostQueueDepth =
3891 @@ -3243,25 +3236,17 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3892 mpi_request.ReplyFreeQueueDepth =
3893 cpu_to_le16(ioc->reply_free_queue_depth);
3894
3895 -#if BITS_PER_LONG > 32
3896 mpi_request.SenseBufferAddressHigh =
3897 - cpu_to_le32(ioc->sense_dma >> 32);
3898 + cpu_to_le32((u64)ioc->sense_dma >> 32);
3899 mpi_request.SystemReplyAddressHigh =
3900 - cpu_to_le32(ioc->reply_dma >> 32);
3901 + cpu_to_le32((u64)ioc->reply_dma >> 32);
3902 mpi_request.SystemRequestFrameBaseAddress =
3903 - cpu_to_le64(ioc->request_dma);
3904 + cpu_to_le64((u64)ioc->request_dma);
3905 mpi_request.ReplyFreeQueueAddress =
3906 - cpu_to_le64(ioc->reply_free_dma);
3907 + cpu_to_le64((u64)ioc->reply_free_dma);
3908 mpi_request.ReplyDescriptorPostQueueAddress =
3909 - cpu_to_le64(ioc->reply_post_free_dma);
3910 -#else
3911 - mpi_request.SystemRequestFrameBaseAddress =
3912 - cpu_to_le32(ioc->request_dma);
3913 - mpi_request.ReplyFreeQueueAddress =
3914 - cpu_to_le32(ioc->reply_free_dma);
3915 - mpi_request.ReplyDescriptorPostQueueAddress =
3916 - cpu_to_le32(ioc->reply_post_free_dma);
3917 -#endif
3918 + cpu_to_le64((u64)ioc->reply_post_free_dma);
3919 +
3920
3921 /* This time stamp specifies number of milliseconds
3922 * since epoch ~ midnight January 1, 1970.
3923 @@ -3271,10 +3256,10 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3924 (current_time.tv_usec / 1000));
3925
3926 if (ioc->logging_level & MPT_DEBUG_INIT) {
3927 - u32 *mfp;
3928 + __le32 *mfp;
3929 int i;
3930
3931 - mfp = (u32 *)&mpi_request;
3932 + mfp = (__le32 *)&mpi_request;
3933 printk(KERN_INFO "\toffset:data\n");
3934 for (i = 0; i < sizeof(Mpi2IOCInitRequest_t)/4; i++)
3935 printk(KERN_INFO "\t[0x%02x]:%08x\n", i*4,
3936 @@ -3759,7 +3744,7 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3937
3938 /* initialize Reply Post Free Queue */
3939 for (i = 0; i < ioc->reply_post_queue_depth; i++)
3940 - ioc->reply_post_free[i].Words = ULLONG_MAX;
3941 + ioc->reply_post_free[i].Words = cpu_to_le64(ULLONG_MAX);
3942
3943 r = _base_send_ioc_init(ioc, sleep_flag);
3944 if (r)
3945 diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
3946 index dcc289c..451dc1c 100644
3947 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h
3948 +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
3949 @@ -541,6 +541,53 @@ struct _tr_list {
3950
3951 typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
3952
3953 +/* IOC Facts and Port Facts converted from little endian to cpu */
3954 +union mpi2_version_union {
3955 + MPI2_VERSION_STRUCT Struct;
3956 + u32 Word;
3957 +};
3958 +
3959 +struct mpt2sas_facts {
3960 + u16 MsgVersion;
3961 + u16 HeaderVersion;
3962 + u8 IOCNumber;
3963 + u8 VP_ID;
3964 + u8 VF_ID;
3965 + u16 IOCExceptions;
3966 + u16 IOCStatus;
3967 + u32 IOCLogInfo;
3968 + u8 MaxChainDepth;
3969 + u8 WhoInit;
3970 + u8 NumberOfPorts;
3971 + u8 MaxMSIxVectors;
3972 + u16 RequestCredit;
3973 + u16 ProductID;
3974 + u32 IOCCapabilities;
3975 + union mpi2_version_union FWVersion;
3976 + u16 IOCRequestFrameSize;
3977 + u16 Reserved3;
3978 + u16 MaxInitiators;
3979 + u16 MaxTargets;
3980 + u16 MaxSasExpanders;
3981 + u16 MaxEnclosures;
3982 + u16 ProtocolFlags;
3983 + u16 HighPriorityCredit;
3984 + u16 MaxReplyDescriptorPostQueueDepth;
3985 + u8 ReplyFrameSize;
3986 + u8 MaxVolumes;
3987 + u16 MaxDevHandle;
3988 + u16 MaxPersistentEntries;
3989 + u16 MinDevHandle;
3990 +};
3991 +
3992 +struct mpt2sas_port_facts {
3993 + u8 PortNumber;
3994 + u8 VP_ID;
3995 + u8 VF_ID;
3996 + u8 PortType;
3997 + u16 MaxPostedCmdBuffers;
3998 +};
3999 +
4000 /**
4001 * struct MPT2SAS_ADAPTER - per adapter struct
4002 * @list: ioc_list
4003 @@ -749,8 +796,8 @@ struct MPT2SAS_ADAPTER {
4004 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
4005
4006 /* static config pages */
4007 - Mpi2IOCFactsReply_t facts;
4008 - Mpi2PortFactsReply_t *pfacts;
4009 + struct mpt2sas_facts facts;
4010 + struct mpt2sas_port_facts *pfacts;
4011 Mpi2ManufacturingPage0_t manu_pg0;
4012 Mpi2BiosPage2_t bios_pg2;
4013 Mpi2BiosPage3_t bios_pg3;
4014 @@ -840,7 +887,7 @@ struct MPT2SAS_ADAPTER {
4015
4016 /* reply free queue */
4017 u16 reply_free_queue_depth;
4018 - u32 *reply_free;
4019 + __le32 *reply_free;
4020 dma_addr_t reply_free_dma;
4021 struct dma_pool *reply_free_dma_pool;
4022 u32 reply_free_host_index;
4023 diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
4024 index 437c2d9..d1c3bba 100644
4025 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
4026 +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
4027 @@ -2706,13 +2706,13 @@ static DEVICE_ATTR(ioc_reset_count, S_IRUGO,
4028 _ctl_ioc_reset_count_show, NULL);
4029
4030 struct DIAG_BUFFER_START {
4031 - u32 Size;
4032 - u32 DiagVersion;
4033 + __le32 Size;
4034 + __le32 DiagVersion;
4035 u8 BufferType;
4036 u8 Reserved[3];
4037 - u32 Reserved1;
4038 - u32 Reserved2;
4039 - u32 Reserved3;
4040 + __le32 Reserved1;
4041 + __le32 Reserved2;
4042 + __le32 Reserved3;
4043 };
4044 /**
4045 * _ctl_host_trace_buffer_size_show - host buffer size (trace only)
4046 diff --git a/drivers/scsi/mpt2sas/mpt2sas_debug.h b/drivers/scsi/mpt2sas/mpt2sas_debug.h
4047 index 3dcddfe..9731f8e 100644
4048 --- a/drivers/scsi/mpt2sas/mpt2sas_debug.h
4049 +++ b/drivers/scsi/mpt2sas/mpt2sas_debug.h
4050 @@ -164,7 +164,7 @@ static inline void
4051 _debug_dump_mf(void *mpi_request, int sz)
4052 {
4053 int i;
4054 - u32 *mfp = (u32 *)mpi_request;
4055 + __le32 *mfp = (__le32 *)mpi_request;
4056
4057 printk(KERN_INFO "mf:\n\t");
4058 for (i = 0; i < sz; i++) {
4059 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
4060 index a7dbc68..e327a3c 100644
4061 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
4062 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
4063 @@ -1956,7 +1956,7 @@ _scsih_slave_configure(struct scsi_device *sdev)
4064 case MPI2_RAID_VOL_TYPE_RAID1E:
4065 qdepth = MPT2SAS_RAID_QUEUE_DEPTH;
4066 if (ioc->manu_pg10.OEMIdentifier &&
4067 - (ioc->manu_pg10.GenericFlags0 &
4068 + (le32_to_cpu(ioc->manu_pg10.GenericFlags0) &
4069 MFG10_GF0_R10_DISPLAY) &&
4070 !(raid_device->num_pds % 2))
4071 r_level = "RAID10";
4072 @@ -4598,7 +4598,7 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
4073 Mpi2SasEnclosurePage0_t enclosure_pg0;
4074 u32 ioc_status;
4075 u16 parent_handle;
4076 - __le64 sas_address, sas_address_parent = 0;
4077 + u64 sas_address, sas_address_parent = 0;
4078 int i;
4079 unsigned long flags;
4080 struct _sas_port *mpt2sas_port = NULL;
4081 @@ -5404,7 +5404,7 @@ _scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc,
4082 {
4083 struct MPT2SAS_TARGET *target_priv_data;
4084 struct _sas_device *sas_device;
4085 - __le64 sas_address;
4086 + u64 sas_address;
4087 unsigned long flags;
4088 Mpi2EventDataSasDeviceStatusChange_t *event_data =
4089 fw_event->event_data;
4090 @@ -6566,7 +6566,7 @@ _scsih_search_responding_expanders(struct MPT2SAS_ADAPTER *ioc)
4091 Mpi2ExpanderPage0_t expander_pg0;
4092 Mpi2ConfigReply_t mpi_reply;
4093 u16 ioc_status;
4094 - __le64 sas_address;
4095 + u64 sas_address;
4096 u16 handle;
4097
4098 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, __func__);
4099 @@ -7505,7 +7505,7 @@ _scsih_suspend(struct pci_dev *pdev, pm_message_t state)
4100 {
4101 struct Scsi_Host *shost = pci_get_drvdata(pdev);
4102 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
4103 - u32 device_state;
4104 + pci_power_t device_state;
4105
4106 mpt2sas_base_stop_watchdog(ioc);
4107 scsi_block_requests(shost);
4108 @@ -7532,7 +7532,7 @@ _scsih_resume(struct pci_dev *pdev)
4109 {
4110 struct Scsi_Host *shost = pci_get_drvdata(pdev);
4111 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
4112 - u32 device_state = pdev->current_state;
4113 + pci_power_t device_state = pdev->current_state;
4114 int r;
4115
4116 printk(MPT2SAS_INFO_FMT "pdev=0x%p, slot=%s, previous "
4117 diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
4118 index cb1cdec..15c7980 100644
4119 --- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
4120 +++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
4121 @@ -299,7 +299,6 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
4122 void *data_out = NULL;
4123 dma_addr_t data_out_dma;
4124 u32 sz;
4125 - u64 *sas_address_le;
4126 u16 wait_state_count;
4127
4128 if (ioc->shost_recovery || ioc->pci_error_recovery) {
4129 @@ -372,8 +371,7 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
4130 mpi_request->PhysicalPort = 0xFF;
4131 mpi_request->VF_ID = 0; /* TODO */
4132 mpi_request->VP_ID = 0;
4133 - sas_address_le = (u64 *)&mpi_request->SASAddress;
4134 - *sas_address_le = cpu_to_le64(sas_address);
4135 + mpi_request->SASAddress = cpu_to_le64(sas_address);
4136 mpi_request->RequestDataLength =
4137 cpu_to_le16(sizeof(struct rep_manu_request));
4138 psge = &mpi_request->SGL;
4139 @@ -1049,14 +1047,14 @@ struct phy_error_log_reply{
4140 u8 function; /* 0x11 */
4141 u8 function_result;
4142 u8 response_length;
4143 - u16 expander_change_count;
4144 + __be16 expander_change_count;
4145 u8 reserved_1[3];
4146 u8 phy_identifier;
4147 u8 reserved_2[2];
4148 - u32 invalid_dword;
4149 - u32 running_disparity_error;
4150 - u32 loss_of_dword_sync;
4151 - u32 phy_reset_problem;
4152 + __be32 invalid_dword;
4153 + __be32 running_disparity_error;
4154 + __be32 loss_of_dword_sync;
4155 + __be32 phy_reset_problem;
4156 };
4157
4158 /**
4159 @@ -1085,7 +1083,6 @@ _transport_get_expander_phy_error_log(struct MPT2SAS_ADAPTER *ioc,
4160 void *data_out = NULL;
4161 dma_addr_t data_out_dma;
4162 u32 sz;
4163 - u64 *sas_address_le;
4164 u16 wait_state_count;
4165
4166 if (ioc->shost_recovery || ioc->pci_error_recovery) {
4167 @@ -1160,8 +1157,7 @@ _transport_get_expander_phy_error_log(struct MPT2SAS_ADAPTER *ioc,
4168 mpi_request->PhysicalPort = 0xFF;
4169 mpi_request->VF_ID = 0; /* TODO */
4170 mpi_request->VP_ID = 0;
4171 - sas_address_le = (u64 *)&mpi_request->SASAddress;
4172 - *sas_address_le = cpu_to_le64(phy->identify.sas_address);
4173 + mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address);
4174 mpi_request->RequestDataLength =
4175 cpu_to_le16(sizeof(struct phy_error_log_request));
4176 psge = &mpi_request->SGL;
4177 @@ -1406,7 +1402,6 @@ _transport_expander_phy_control(struct MPT2SAS_ADAPTER *ioc,
4178 void *data_out = NULL;
4179 dma_addr_t data_out_dma;
4180 u32 sz;
4181 - u64 *sas_address_le;
4182 u16 wait_state_count;
4183
4184 if (ioc->shost_recovery) {
4185 @@ -1486,8 +1481,7 @@ _transport_expander_phy_control(struct MPT2SAS_ADAPTER *ioc,
4186 mpi_request->PhysicalPort = 0xFF;
4187 mpi_request->VF_ID = 0; /* TODO */
4188 mpi_request->VP_ID = 0;
4189 - sas_address_le = (u64 *)&mpi_request->SASAddress;
4190 - *sas_address_le = cpu_to_le64(phy->identify.sas_address);
4191 + mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address);
4192 mpi_request->RequestDataLength =
4193 cpu_to_le16(sizeof(struct phy_error_log_request));
4194 psge = &mpi_request->SGL;
4195 @@ -1914,7 +1908,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
4196 mpi_request->PhysicalPort = 0xFF;
4197 mpi_request->VF_ID = 0; /* TODO */
4198 mpi_request->VP_ID = 0;
4199 - *((u64 *)&mpi_request->SASAddress) = (rphy) ?
4200 + mpi_request->SASAddress = (rphy) ?
4201 cpu_to_le64(rphy->identify.sas_address) :
4202 cpu_to_le64(ioc->sas_hba.sas_address);
4203 mpi_request->RequestDataLength = cpu_to_le16(blk_rq_bytes(req) - 4);
4204 diff --git a/drivers/staging/ath6kl/os/linux/ar6000_drv.c b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
4205 index aa97efc..62487a7 100644
4206 --- a/drivers/staging/ath6kl/os/linux/ar6000_drv.c
4207 +++ b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
4208 @@ -6198,6 +6198,7 @@ int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)
4209
4210 ether_setup(dev);
4211 init_netdev(dev, ap_ifname);
4212 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
4213
4214 if (register_netdev(dev)) {
4215 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: register_netdev failed\n"));
4216 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
4217 index bc4b12c..fc7e57b 100644
4218 --- a/fs/cifs/cifsfs.c
4219 +++ b/fs/cifs/cifsfs.c
4220 @@ -581,6 +581,10 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
4221 mutex_unlock(&dir->i_mutex);
4222 dput(dentry);
4223 dentry = child;
4224 + if (!dentry->d_inode) {
4225 + dput(dentry);
4226 + dentry = ERR_PTR(-ENOENT);
4227 + }
4228 } while (!IS_ERR(dentry));
4229 _FreeXid(xid);
4230 kfree(full_path);
4231 diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
4232 index 9b018c8..a7b2dcd 100644
4233 --- a/fs/cifs/inode.c
4234 +++ b/fs/cifs/inode.c
4235 @@ -764,20 +764,10 @@ char *cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
4236 if (full_path == NULL)
4237 return full_path;
4238
4239 - if (dfsplen) {
4240 + if (dfsplen)
4241 strncpy(full_path, tcon->treeName, dfsplen);
4242 - /* switch slash direction in prepath depending on whether
4243 - * windows or posix style path names
4244 - */
4245 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
4246 - int i;
4247 - for (i = 0; i < dfsplen; i++) {
4248 - if (full_path[i] == '\\')
4249 - full_path[i] = '/';
4250 - }
4251 - }
4252 - }
4253 strncpy(full_path + dfsplen, vol->prepath, pplen);
4254 + convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
4255 full_path[dfsplen + pplen] = 0; /* add trailing null */
4256 return full_path;
4257 }
4258 diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
4259 index 147aa22..c1b9c4b 100644
4260 --- a/fs/cifs/transport.c
4261 +++ b/fs/cifs/transport.c
4262 @@ -362,6 +362,8 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
4263 mid = AllocMidQEntry(hdr, server);
4264 if (mid == NULL) {
4265 mutex_unlock(&server->srv_mutex);
4266 + atomic_dec(&server->inFlight);
4267 + wake_up(&server->request_q);
4268 return -ENOMEM;
4269 }
4270
4271 diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
4272 index 9f1bb74..b4a6bef 100644
4273 --- a/fs/ecryptfs/main.c
4274 +++ b/fs/ecryptfs/main.c
4275 @@ -175,6 +175,7 @@ enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig,
4276 ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig,
4277 ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes,
4278 ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only,
4279 + ecryptfs_opt_check_dev_ruid,
4280 ecryptfs_opt_err };
4281
4282 static const match_table_t tokens = {
4283 @@ -191,6 +192,7 @@ static const match_table_t tokens = {
4284 {ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"},
4285 {ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"},
4286 {ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"},
4287 + {ecryptfs_opt_check_dev_ruid, "ecryptfs_check_dev_ruid"},
4288 {ecryptfs_opt_err, NULL}
4289 };
4290
4291 @@ -236,6 +238,7 @@ static void ecryptfs_init_mount_crypt_stat(
4292 * ecryptfs_parse_options
4293 * @sb: The ecryptfs super block
4294 * @options: The options passed to the kernel
4295 + * @check_ruid: set to 1 if device uid should be checked against the ruid
4296 *
4297 * Parse mount options:
4298 * debug=N - ecryptfs_verbosity level for debug output
4299 @@ -251,7 +254,8 @@ static void ecryptfs_init_mount_crypt_stat(
4300 *
4301 * Returns zero on success; non-zero on error
4302 */
4303 -static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
4304 +static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options,
4305 + uid_t *check_ruid)
4306 {
4307 char *p;
4308 int rc = 0;
4309 @@ -276,6 +280,8 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
4310 char *cipher_key_bytes_src;
4311 char *fn_cipher_key_bytes_src;
4312
4313 + *check_ruid = 0;
4314 +
4315 if (!options) {
4316 rc = -EINVAL;
4317 goto out;
4318 @@ -380,6 +386,9 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
4319 mount_crypt_stat->flags |=
4320 ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY;
4321 break;
4322 + case ecryptfs_opt_check_dev_ruid:
4323 + *check_ruid = 1;
4324 + break;
4325 case ecryptfs_opt_err:
4326 default:
4327 printk(KERN_WARNING
4328 @@ -475,6 +484,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
4329 const char *err = "Getting sb failed";
4330 struct inode *inode;
4331 struct path path;
4332 + uid_t check_ruid;
4333 int rc;
4334
4335 sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL);
4336 @@ -483,7 +493,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
4337 goto out;
4338 }
4339
4340 - rc = ecryptfs_parse_options(sbi, raw_data);
4341 + rc = ecryptfs_parse_options(sbi, raw_data, &check_ruid);
4342 if (rc) {
4343 err = "Error parsing options";
4344 goto out;
4345 @@ -521,6 +531,15 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
4346 "known incompatibilities\n");
4347 goto out_free;
4348 }
4349 +
4350 + if (check_ruid && path.dentry->d_inode->i_uid != current_uid()) {
4351 + rc = -EPERM;
4352 + printk(KERN_ERR "Mount of device (uid: %d) not owned by "
4353 + "requested user (uid: %d)\n",
4354 + path.dentry->d_inode->i_uid, current_uid());
4355 + goto out_free;
4356 + }
4357 +
4358 ecryptfs_set_superblock_lower(s, path.dentry->d_sb);
4359 s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
4360 s->s_blocksize = path.dentry->d_sb->s_blocksize;
4361 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
4362 index 85d4309..3745f7c 100644
4363 --- a/fs/ecryptfs/read_write.c
4364 +++ b/fs/ecryptfs/read_write.c
4365 @@ -39,15 +39,16 @@
4366 int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
4367 loff_t offset, size_t size)
4368 {
4369 - struct ecryptfs_inode_info *inode_info;
4370 + struct file *lower_file;
4371 mm_segment_t fs_save;
4372 ssize_t rc;
4373
4374 - inode_info = ecryptfs_inode_to_private(ecryptfs_inode);
4375 - BUG_ON(!inode_info->lower_file);
4376 + lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
4377 + if (!lower_file)
4378 + return -EIO;
4379 fs_save = get_fs();
4380 set_fs(get_ds());
4381 - rc = vfs_write(inode_info->lower_file, data, size, &offset);
4382 + rc = vfs_write(lower_file, data, size, &offset);
4383 set_fs(fs_save);
4384 mark_inode_dirty_sync(ecryptfs_inode);
4385 return rc;
4386 @@ -225,15 +226,16 @@ out:
4387 int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
4388 struct inode *ecryptfs_inode)
4389 {
4390 - struct ecryptfs_inode_info *inode_info =
4391 - ecryptfs_inode_to_private(ecryptfs_inode);
4392 + struct file *lower_file;
4393 mm_segment_t fs_save;
4394 ssize_t rc;
4395
4396 - BUG_ON(!inode_info->lower_file);
4397 + lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
4398 + if (!lower_file)
4399 + return -EIO;
4400 fs_save = get_fs();
4401 set_fs(get_ds());
4402 - rc = vfs_read(inode_info->lower_file, data, size, &offset);
4403 + rc = vfs_read(lower_file, data, size, &offset);
4404 set_fs(fs_save);
4405 return rc;
4406 }
4407 diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
4408 index 34b6d9b..e5a7111 100644
4409 --- a/fs/ext3/namei.c
4410 +++ b/fs/ext3/namei.c
4411 @@ -2210,9 +2210,11 @@ static int ext3_symlink (struct inode * dir,
4412 /*
4413 * For non-fast symlinks, we just allocate inode and put it on
4414 * orphan list in the first transaction => we need bitmap,
4415 - * group descriptor, sb, inode block, quota blocks.
4416 + * group descriptor, sb, inode block, quota blocks, and
4417 + * possibly selinux xattr blocks.
4418 */
4419 - credits = 4 + EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
4420 + credits = 4 + EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
4421 + EXT3_XATTR_TRANS_BLOCKS;
4422 } else {
4423 /*
4424 * Fast symlink. We have to add entry to directory
4425 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
4426 index b754b77..458a394 100644
4427 --- a/fs/ext4/namei.c
4428 +++ b/fs/ext4/namei.c
4429 @@ -2264,9 +2264,11 @@ static int ext4_symlink(struct inode *dir,
4430 /*
4431 * For non-fast symlinks, we just allocate inode and put it on
4432 * orphan list in the first transaction => we need bitmap,
4433 - * group descriptor, sb, inode block, quota blocks.
4434 + * group descriptor, sb, inode block, quota blocks, and
4435 + * possibly selinux xattr blocks.
4436 */
4437 - credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
4438 + credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
4439 + EXT4_XATTR_TRANS_BLOCKS;
4440 } else {
4441 /*
4442 * Fast symlink. We have to add entry to directory
4443 diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
4444 index 33d12f8..0ec3687 100644
4445 --- a/include/drm/drm_crtc.h
4446 +++ b/include/drm/drm_crtc.h
4447 @@ -802,6 +802,7 @@ extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
4448 extern int drm_add_modes_noedid(struct drm_connector *connector,
4449 int hdisplay, int vdisplay);
4450
4451 +extern int drm_edid_header_is_valid(const u8 *raw_edid);
4452 extern bool drm_edid_is_valid(struct edid *edid);
4453 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
4454 int hsize, int vsize, int fresh);
4455 diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
4456 index c4d6dbf..28c0d11 100644
4457 --- a/include/drm/i915_drm.h
4458 +++ b/include/drm/i915_drm.h
4459 @@ -237,7 +237,7 @@ typedef struct _drm_i915_sarea {
4460 #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
4461 #define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)
4462 #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
4463 -#define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_IOCTL_I915_OVERLAY_ATTRS, struct drm_intel_overlay_put_image)
4464 +#define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
4465 #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
4466
4467 /* Allow drivers to submit batchbuffers directly to hardware, relying
4468 diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
4469 index ec78a4b..d2984fb 100644
4470 --- a/include/linux/cryptohash.h
4471 +++ b/include/linux/cryptohash.h
4472 @@ -8,6 +8,11 @@
4473 void sha_init(__u32 *buf);
4474 void sha_transform(__u32 *digest, const char *data, __u32 *W);
4475
4476 +#define MD5_DIGEST_WORDS 4
4477 +#define MD5_MESSAGE_BYTES 64
4478 +
4479 +void md5_transform(__u32 *hash, __u32 const *in);
4480 +
4481 __u32 half_md4_transform(__u32 buf[4], __u32 const in[8]);
4482
4483 #endif
4484 diff --git a/include/linux/if.h b/include/linux/if.h
4485 index 3bc63e6..03489ca 100644
4486 --- a/include/linux/if.h
4487 +++ b/include/linux/if.h
4488 @@ -76,6 +76,8 @@
4489 #define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */
4490 #define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch
4491 * datapath port */
4492 +#define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing
4493 + * skbs on transmit */
4494
4495 #define IF_GET_IFACE 0x0001 /* for querying only */
4496 #define IF_GET_PROTO 0x0002
4497 diff --git a/include/linux/mm.h b/include/linux/mm.h
4498 index 1036614..ec6e33d 100644
4499 --- a/include/linux/mm.h
4500 +++ b/include/linux/mm.h
4501 @@ -959,6 +959,8 @@ int invalidate_inode_page(struct page *page);
4502 #ifdef CONFIG_MMU
4503 extern int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
4504 unsigned long address, unsigned int flags);
4505 +extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
4506 + unsigned long address, unsigned int fault_flags);
4507 #else
4508 static inline int handle_mm_fault(struct mm_struct *mm,
4509 struct vm_area_struct *vma, unsigned long address,
4510 @@ -968,6 +970,14 @@ static inline int handle_mm_fault(struct mm_struct *mm,
4511 BUG();
4512 return VM_FAULT_SIGBUS;
4513 }
4514 +static inline int fixup_user_fault(struct task_struct *tsk,
4515 + struct mm_struct *mm, unsigned long address,
4516 + unsigned int fault_flags)
4517 +{
4518 + /* should never happen if there's no MMU */
4519 + BUG();
4520 + return -EFAULT;
4521 +}
4522 #endif
4523
4524 extern int make_pages_present(unsigned long addr, unsigned long end);
4525 @@ -985,8 +995,6 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
4526 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
4527 struct page **pages);
4528 struct page *get_dump_page(unsigned long addr);
4529 -extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
4530 - unsigned long address, unsigned int fault_flags);
4531
4532 extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
4533 extern void do_invalidatepage(struct page *page, unsigned long offset);
4534 diff --git a/include/linux/random.h b/include/linux/random.h
4535 index fb7ab9d..d13059f 100644
4536 --- a/include/linux/random.h
4537 +++ b/include/linux/random.h
4538 @@ -57,17 +57,6 @@ extern void add_interrupt_randomness(int irq);
4539 extern void get_random_bytes(void *buf, int nbytes);
4540 void generate_random_uuid(unsigned char uuid_out[16]);
4541
4542 -extern __u32 secure_ip_id(__be32 daddr);
4543 -extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
4544 -extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
4545 - __be16 dport);
4546 -extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
4547 - __be16 sport, __be16 dport);
4548 -extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
4549 - __be16 sport, __be16 dport);
4550 -extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
4551 - __be16 sport, __be16 dport);
4552 -
4553 #ifndef MODULE
4554 extern const struct file_operations random_fops, urandom_fops;
4555 #endif
4556 diff --git a/include/net/ipv6.h b/include/net/ipv6.h
4557 index c033ed0..3b5ac1f 100644
4558 --- a/include/net/ipv6.h
4559 +++ b/include/net/ipv6.h
4560 @@ -463,17 +463,7 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
4561 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
4562 }
4563
4564 -static __inline__ void ipv6_select_ident(struct frag_hdr *fhdr)
4565 -{
4566 - static u32 ipv6_fragmentation_id = 1;
4567 - static DEFINE_SPINLOCK(ip6_id_lock);
4568 -
4569 - spin_lock_bh(&ip6_id_lock);
4570 - fhdr->identification = htonl(ipv6_fragmentation_id);
4571 - if (++ipv6_fragmentation_id == 0)
4572 - ipv6_fragmentation_id = 1;
4573 - spin_unlock_bh(&ip6_id_lock);
4574 -}
4575 +extern void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt);
4576
4577 /*
4578 * Prototypes exported by ipv6
4579 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
4580 new file mode 100644
4581 index 0000000..d97f689
4582 --- /dev/null
4583 +++ b/include/net/secure_seq.h
4584 @@ -0,0 +1,20 @@
4585 +#ifndef _NET_SECURE_SEQ
4586 +#define _NET_SECURE_SEQ
4587 +
4588 +#include <linux/types.h>
4589 +
4590 +extern __u32 secure_ip_id(__be32 daddr);
4591 +extern __u32 secure_ipv6_id(const __be32 daddr[4]);
4592 +extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
4593 +extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
4594 + __be16 dport);
4595 +extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
4596 + __be16 sport, __be16 dport);
4597 +extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
4598 + __be16 sport, __be16 dport);
4599 +extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
4600 + __be16 sport, __be16 dport);
4601 +extern u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
4602 + __be16 sport, __be16 dport);
4603 +
4604 +#endif /* _NET_SECURE_SEQ */
4605 diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
4606 index 5271a74..45ce307 100644
4607 --- a/include/net/transp_v6.h
4608 +++ b/include/net/transp_v6.h
4609 @@ -14,6 +14,8 @@ extern struct proto tcpv6_prot;
4610
4611 struct flowi6;
4612
4613 +extern void initialize_hashidentrnd(void);
4614 +
4615 /* extension headers */
4616 extern int ipv6_exthdrs_init(void);
4617 extern void ipv6_exthdrs_exit(void);
4618 diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
4619 index 70213b4..6acd9ce 100644
4620 --- a/include/xen/interface/xen.h
4621 +++ b/include/xen/interface/xen.h
4622 @@ -450,6 +450,45 @@ struct start_info {
4623 int8_t cmd_line[MAX_GUEST_CMDLINE];
4624 };
4625
4626 +struct dom0_vga_console_info {
4627 + uint8_t video_type;
4628 +#define XEN_VGATYPE_TEXT_MODE_3 0x03
4629 +#define XEN_VGATYPE_VESA_LFB 0x23
4630 +
4631 + union {
4632 + struct {
4633 + /* Font height, in pixels. */
4634 + uint16_t font_height;
4635 + /* Cursor location (column, row). */
4636 + uint16_t cursor_x, cursor_y;
4637 + /* Number of rows and columns (dimensions in characters). */
4638 + uint16_t rows, columns;
4639 + } text_mode_3;
4640 +
4641 + struct {
4642 + /* Width and height, in pixels. */
4643 + uint16_t width, height;
4644 + /* Bytes per scan line. */
4645 + uint16_t bytes_per_line;
4646 + /* Bits per pixel. */
4647 + uint16_t bits_per_pixel;
4648 + /* LFB physical address, and size (in units of 64kB). */
4649 + uint32_t lfb_base;
4650 + uint32_t lfb_size;
4651 + /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
4652 + uint8_t red_pos, red_size;
4653 + uint8_t green_pos, green_size;
4654 + uint8_t blue_pos, blue_size;
4655 + uint8_t rsvd_pos, rsvd_size;
4656 +
4657 + /* VESA capabilities (offset 0xa, VESA command 0x4f00). */
4658 + uint32_t gbl_caps;
4659 + /* Mode attributes (offset 0x0, VESA command 0x4f01). */
4660 + uint16_t mode_attrs;
4661 + } vesa_lfb;
4662 + } u;
4663 +};
4664 +
4665 /* These flags are passed in the 'flags' field of start_info_t. */
4666 #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
4667 #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
4668 diff --git a/kernel/futex.c b/kernel/futex.c
4669 index 7a0a4ed..8b6da25 100644
4670 --- a/kernel/futex.c
4671 +++ b/kernel/futex.c
4672 @@ -218,6 +218,8 @@ static void drop_futex_key_refs(union futex_key *key)
4673 * @uaddr: virtual address of the futex
4674 * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED
4675 * @key: address where result is stored.
4676 + * @rw: mapping needs to be read/write (values: VERIFY_READ,
4677 + * VERIFY_WRITE)
4678 *
4679 * Returns a negative error code or 0
4680 * The key words are stored in *key on success.
4681 @@ -229,12 +231,12 @@ static void drop_futex_key_refs(union futex_key *key)
4682 * lock_page() might sleep, the caller should not hold a spinlock.
4683 */
4684 static int
4685 -get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
4686 +get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
4687 {
4688 unsigned long address = (unsigned long)uaddr;
4689 struct mm_struct *mm = current->mm;
4690 struct page *page, *page_head;
4691 - int err;
4692 + int err, ro = 0;
4693
4694 /*
4695 * The futex address must be "naturally" aligned.
4696 @@ -262,8 +264,18 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
4697
4698 again:
4699 err = get_user_pages_fast(address, 1, 1, &page);
4700 + /*
4701 + * If write access is not required (eg. FUTEX_WAIT), try
4702 + * and get read-only access.
4703 + */
4704 + if (err == -EFAULT && rw == VERIFY_READ) {
4705 + err = get_user_pages_fast(address, 1, 0, &page);
4706 + ro = 1;
4707 + }
4708 if (err < 0)
4709 return err;
4710 + else
4711 + err = 0;
4712
4713 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
4714 page_head = page;
4715 @@ -305,6 +317,13 @@ again:
4716 if (!page_head->mapping) {
4717 unlock_page(page_head);
4718 put_page(page_head);
4719 + /*
4720 + * ZERO_PAGE pages don't have a mapping. Avoid a busy loop
4721 + * trying to find one. RW mapping would have COW'd (and thus
4722 + * have a mapping) so this page is RO and won't ever change.
4723 + */
4724 + if ((page_head == ZERO_PAGE(address)))
4725 + return -EFAULT;
4726 goto again;
4727 }
4728
4729 @@ -316,6 +335,15 @@ again:
4730 * the object not the particular process.
4731 */
4732 if (PageAnon(page_head)) {
4733 + /*
4734 + * A RO anonymous page will never change and thus doesn't make
4735 + * sense for futex operations.
4736 + */
4737 + if (ro) {
4738 + err = -EFAULT;
4739 + goto out;
4740 + }
4741 +
4742 key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */
4743 key->private.mm = mm;
4744 key->private.address = address;
4745 @@ -327,9 +355,10 @@ again:
4746
4747 get_futex_key_refs(key);
4748
4749 +out:
4750 unlock_page(page_head);
4751 put_page(page_head);
4752 - return 0;
4753 + return err;
4754 }
4755
4756 static inline void put_futex_key(union futex_key *key)
4757 @@ -940,7 +969,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)
4758 if (!bitset)
4759 return -EINVAL;
4760
4761 - ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key);
4762 + ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_READ);
4763 if (unlikely(ret != 0))
4764 goto out;
4765
4766 @@ -986,10 +1015,10 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2,
4767 int ret, op_ret;
4768
4769 retry:
4770 - ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1);
4771 + ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ);
4772 if (unlikely(ret != 0))
4773 goto out;
4774 - ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2);
4775 + ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE);
4776 if (unlikely(ret != 0))
4777 goto out_put_key1;
4778
4779 @@ -1243,10 +1272,11 @@ retry:
4780 pi_state = NULL;
4781 }
4782
4783 - ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1);
4784 + ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ);
4785 if (unlikely(ret != 0))
4786 goto out;
4787 - ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2);
4788 + ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2,
4789 + requeue_pi ? VERIFY_WRITE : VERIFY_READ);
4790 if (unlikely(ret != 0))
4791 goto out_put_key1;
4792
4793 @@ -1790,7 +1820,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
4794 * while the syscall executes.
4795 */
4796 retry:
4797 - ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q->key);
4798 + ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q->key, VERIFY_READ);
4799 if (unlikely(ret != 0))
4800 return ret;
4801
4802 @@ -1941,7 +1971,7 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, int detect,
4803 }
4804
4805 retry:
4806 - ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key);
4807 + ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, VERIFY_WRITE);
4808 if (unlikely(ret != 0))
4809 goto out;
4810
4811 @@ -2060,7 +2090,7 @@ retry:
4812 if ((uval & FUTEX_TID_MASK) != vpid)
4813 return -EPERM;
4814
4815 - ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key);
4816 + ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_WRITE);
4817 if (unlikely(ret != 0))
4818 goto out;
4819
4820 @@ -2249,7 +2279,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
4821 debug_rt_mutex_init_waiter(&rt_waiter);
4822 rt_waiter.task = NULL;
4823
4824 - ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2);
4825 + ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE);
4826 if (unlikely(ret != 0))
4827 goto out;
4828
4829 diff --git a/lib/Makefile b/lib/Makefile
4830 index 6b597fd..578414a 100644
4831 --- a/lib/Makefile
4832 +++ b/lib/Makefile
4833 @@ -10,7 +10,7 @@ endif
4834 lib-y := ctype.o string.o vsprintf.o cmdline.o \
4835 rbtree.o radix-tree.o dump_stack.o timerqueue.o\
4836 idr.o int_sqrt.o extable.o prio_tree.o \
4837 - sha1.o irq_regs.o reciprocal_div.o argv_split.o \
4838 + sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \
4839 proportions.o prio_heap.o ratelimit.o show_mem.o \
4840 is_single_threaded.o plist.o decompress.o find_next_bit.o
4841
4842 diff --git a/lib/md5.c b/lib/md5.c
4843 new file mode 100644
4844 index 0000000..c777180
4845 --- /dev/null
4846 +++ b/lib/md5.c
4847 @@ -0,0 +1,95 @@
4848 +#include <linux/kernel.h>
4849 +#include <linux/module.h>
4850 +#include <linux/cryptohash.h>
4851 +
4852 +#define F1(x, y, z) (z ^ (x & (y ^ z)))
4853 +#define F2(x, y, z) F1(z, x, y)
4854 +#define F3(x, y, z) (x ^ y ^ z)
4855 +#define F4(x, y, z) (y ^ (x | ~z))
4856 +
4857 +#define MD5STEP(f, w, x, y, z, in, s) \
4858 + (w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
4859 +
4860 +void md5_transform(__u32 *hash, __u32 const *in)
4861 +{
4862 + u32 a, b, c, d;
4863 +
4864 + a = hash[0];
4865 + b = hash[1];
4866 + c = hash[2];
4867 + d = hash[3];
4868 +
4869 + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
4870 + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
4871 + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
4872 + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
4873 + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
4874 + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
4875 + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
4876 + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
4877 + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
4878 + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
4879 + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
4880 + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
4881 + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
4882 + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
4883 + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
4884 + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
4885 +
4886 + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
4887 + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
4888 + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
4889 + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
4890 + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
4891 + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
4892 + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
4893 + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
4894 + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
4895 + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
4896 + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
4897 + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
4898 + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
4899 + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
4900 + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
4901 + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
4902 +
4903 + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
4904 + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
4905 + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
4906 + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
4907 + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
4908 + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
4909 + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
4910 + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
4911 + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
4912 + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
4913 + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
4914 + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
4915 + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
4916 + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
4917 + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
4918 + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
4919 +
4920 + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
4921 + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
4922 + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
4923 + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
4924 + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
4925 + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
4926 + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
4927 + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
4928 + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
4929 + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
4930 + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
4931 + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
4932 + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
4933 + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
4934 + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
4935 + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
4936 +
4937 + hash[0] += a;
4938 + hash[1] += b;
4939 + hash[2] += c;
4940 + hash[3] += d;
4941 +}
4942 +EXPORT_SYMBOL(md5_transform);
4943 diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
4944 index 6e82148..5b4f51d 100644
4945 --- a/net/8021q/vlan_dev.c
4946 +++ b/net/8021q/vlan_dev.c
4947 @@ -694,7 +694,7 @@ void vlan_setup(struct net_device *dev)
4948 ether_setup(dev);
4949
4950 dev->priv_flags |= IFF_802_1Q_VLAN;
4951 - dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
4952 + dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
4953 dev->tx_queue_len = 0;
4954
4955 dev->netdev_ops = &vlan_netdev_ops;
4956 diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
4957 index 8c100c9..d4f5dff 100644
4958 --- a/net/bluetooth/bnep/netdev.c
4959 +++ b/net/bluetooth/bnep/netdev.c
4960 @@ -231,6 +231,7 @@ void bnep_net_setup(struct net_device *dev)
4961 dev->addr_len = ETH_ALEN;
4962
4963 ether_setup(dev);
4964 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
4965 dev->netdev_ops = &bnep_netdev_ops;
4966
4967 dev->watchdog_timeo = HZ * 2;
4968 diff --git a/net/core/Makefile b/net/core/Makefile
4969 index 8a04dd2..0d357b1 100644
4970 --- a/net/core/Makefile
4971 +++ b/net/core/Makefile
4972 @@ -3,7 +3,7 @@
4973 #
4974
4975 obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \
4976 - gen_stats.o gen_estimator.o net_namespace.o
4977 + gen_stats.o gen_estimator.o net_namespace.o secure_seq.o
4978
4979 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
4980
4981 diff --git a/net/core/link_watch.c b/net/core/link_watch.c
4982 index a7b3421..357bd4e 100644
4983 --- a/net/core/link_watch.c
4984 +++ b/net/core/link_watch.c
4985 @@ -126,7 +126,7 @@ static void linkwatch_schedule_work(int urgent)
4986 return;
4987
4988 /* It's already running which is good enough. */
4989 - if (!cancel_delayed_work(&linkwatch_work))
4990 + if (!__cancel_delayed_work(&linkwatch_work))
4991 return;
4992
4993 /* Otherwise we reschedule it again for immediate execution. */
4994 diff --git a/net/core/pktgen.c b/net/core/pktgen.c
4995 index f76079c..e35a6fb 100644
4996 --- a/net/core/pktgen.c
4997 +++ b/net/core/pktgen.c
4998 @@ -1070,7 +1070,9 @@ static ssize_t pktgen_if_write(struct file *file,
4999 len = num_arg(&user_buffer[i], 10, &value);
5000 if (len < 0)
5001 return len;
5002 -
5003 + if ((value > 0) &&
5004 + (!(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING)))
5005 + return -ENOTSUPP;
5006 i += len;
5007 pkt_dev->clone_skb = value;
5008
5009 @@ -3555,7 +3557,6 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
5010 pkt_dev->min_pkt_size = ETH_ZLEN;
5011 pkt_dev->max_pkt_size = ETH_ZLEN;
5012 pkt_dev->nfrags = 0;
5013 - pkt_dev->clone_skb = pg_clone_skb_d;
5014 pkt_dev->delay = pg_delay_d;
5015 pkt_dev->count = pg_count_d;
5016 pkt_dev->sofar = 0;
5017 @@ -3563,7 +3564,6 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
5018 pkt_dev->udp_src_max = 9;
5019 pkt_dev->udp_dst_min = 9;
5020 pkt_dev->udp_dst_max = 9;
5021 -
5022 pkt_dev->vlan_p = 0;
5023 pkt_dev->vlan_cfi = 0;
5024 pkt_dev->vlan_id = 0xffff;
5025 @@ -3575,6 +3575,8 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
5026 err = pktgen_setup_dev(pkt_dev, ifname);
5027 if (err)
5028 goto out1;
5029 + if (pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING)
5030 + pkt_dev->clone_skb = pg_clone_skb_d;
5031
5032 pkt_dev->entry = proc_create_data(ifname, 0600, pg_proc_dir,
5033 &pktgen_if_fops, pkt_dev);
5034 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
5035 new file mode 100644
5036 index 0000000..45329d7
5037 --- /dev/null
5038 +++ b/net/core/secure_seq.c
5039 @@ -0,0 +1,184 @@
5040 +#include <linux/kernel.h>
5041 +#include <linux/init.h>
5042 +#include <linux/cryptohash.h>
5043 +#include <linux/module.h>
5044 +#include <linux/cache.h>
5045 +#include <linux/random.h>
5046 +#include <linux/hrtimer.h>
5047 +#include <linux/ktime.h>
5048 +#include <linux/string.h>
5049 +
5050 +#include <net/secure_seq.h>
5051 +
5052 +static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
5053 +
5054 +static int __init net_secret_init(void)
5055 +{
5056 + get_random_bytes(net_secret, sizeof(net_secret));
5057 + return 0;
5058 +}
5059 +late_initcall(net_secret_init);
5060 +
5061 +static u32 seq_scale(u32 seq)
5062 +{
5063 + /*
5064 + * As close as possible to RFC 793, which
5065 + * suggests using a 250 kHz clock.
5066 + * Further reading shows this assumes 2 Mb/s networks.
5067 + * For 10 Mb/s Ethernet, a 1 MHz clock is appropriate.
5068 + * For 10 Gb/s Ethernet, a 1 GHz clock should be ok, but
5069 + * we also need to limit the resolution so that the u32 seq
5070 + * overlaps less than one time per MSL (2 minutes).
5071 + * Choosing a clock of 64 ns period is OK. (period of 274 s)
5072 + */
5073 + return seq + (ktime_to_ns(ktime_get_real()) >> 6);
5074 +}
5075 +
5076 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
5077 +__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
5078 + __be16 sport, __be16 dport)
5079 +{
5080 + u32 secret[MD5_MESSAGE_BYTES / 4];
5081 + u32 hash[MD5_DIGEST_WORDS];
5082 + u32 i;
5083 +
5084 + memcpy(hash, saddr, 16);
5085 + for (i = 0; i < 4; i++)
5086 + secret[i] = net_secret[i] + daddr[i];
5087 + secret[4] = net_secret[4] +
5088 + (((__force u16)sport << 16) + (__force u16)dport);
5089 + for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
5090 + secret[i] = net_secret[i];
5091 +
5092 + md5_transform(hash, secret);
5093 +
5094 + return seq_scale(hash[0]);
5095 +}
5096 +EXPORT_SYMBOL(secure_tcpv6_sequence_number);
5097 +
5098 +u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
5099 + __be16 dport)
5100 +{
5101 + u32 secret[MD5_MESSAGE_BYTES / 4];
5102 + u32 hash[MD5_DIGEST_WORDS];
5103 + u32 i;
5104 +
5105 + memcpy(hash, saddr, 16);
5106 + for (i = 0; i < 4; i++)
5107 + secret[i] = net_secret[i] + (__force u32) daddr[i];
5108 + secret[4] = net_secret[4] + (__force u32)dport;
5109 + for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
5110 + secret[i] = net_secret[i];
5111 +
5112 + md5_transform(hash, secret);
5113 +
5114 + return hash[0];
5115 +}
5116 +#endif
5117 +
5118 +#ifdef CONFIG_INET
5119 +__u32 secure_ip_id(__be32 daddr)
5120 +{
5121 + u32 hash[MD5_DIGEST_WORDS];
5122 +
5123 + hash[0] = (__force __u32) daddr;
5124 + hash[1] = net_secret[13];
5125 + hash[2] = net_secret[14];
5126 + hash[3] = net_secret[15];
5127 +
5128 + md5_transform(hash, net_secret);
5129 +
5130 + return hash[0];
5131 +}
5132 +
5133 +__u32 secure_ipv6_id(const __be32 daddr[4])
5134 +{
5135 + __u32 hash[4];
5136 +
5137 + memcpy(hash, daddr, 16);
5138 + md5_transform(hash, net_secret);
5139 +
5140 + return hash[0];
5141 +}
5142 +
5143 +__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
5144 + __be16 sport, __be16 dport)
5145 +{
5146 + u32 hash[MD5_DIGEST_WORDS];
5147 +
5148 + hash[0] = (__force u32)saddr;
5149 + hash[1] = (__force u32)daddr;
5150 + hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
5151 + hash[3] = net_secret[15];
5152 +
5153 + md5_transform(hash, net_secret);
5154 +
5155 + return seq_scale(hash[0]);
5156 +}
5157 +
5158 +u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
5159 +{
5160 + u32 hash[MD5_DIGEST_WORDS];
5161 +
5162 + hash[0] = (__force u32)saddr;
5163 + hash[1] = (__force u32)daddr;
5164 + hash[2] = (__force u32)dport ^ net_secret[14];
5165 + hash[3] = net_secret[15];
5166 +
5167 + md5_transform(hash, net_secret);
5168 +
5169 + return hash[0];
5170 +}
5171 +EXPORT_SYMBOL_GPL(secure_ipv4_port_ephemeral);
5172 +#endif
5173 +
5174 +#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
5175 +u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
5176 + __be16 sport, __be16 dport)
5177 +{
5178 + u32 hash[MD5_DIGEST_WORDS];
5179 + u64 seq;
5180 +
5181 + hash[0] = (__force u32)saddr;
5182 + hash[1] = (__force u32)daddr;
5183 + hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
5184 + hash[3] = net_secret[15];
5185 +
5186 + md5_transform(hash, net_secret);
5187 +
5188 + seq = hash[0] | (((u64)hash[1]) << 32);
5189 + seq += ktime_to_ns(ktime_get_real());
5190 + seq &= (1ull << 48) - 1;
5191 +
5192 + return seq;
5193 +}
5194 +EXPORT_SYMBOL(secure_dccp_sequence_number);
5195 +
5196 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
5197 +u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
5198 + __be16 sport, __be16 dport)
5199 +{
5200 + u32 secret[MD5_MESSAGE_BYTES / 4];
5201 + u32 hash[MD5_DIGEST_WORDS];
5202 + u64 seq;
5203 + u32 i;
5204 +
5205 + memcpy(hash, saddr, 16);
5206 + for (i = 0; i < 4; i++)
5207 + secret[i] = net_secret[i] + daddr[i];
5208 + secret[4] = net_secret[4] +
5209 + (((__force u16)sport << 16) + (__force u16)dport);
5210 + for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
5211 + secret[i] = net_secret[i];
5212 +
5213 + md5_transform(hash, secret);
5214 +
5215 + seq = hash[0] | (((u64)hash[1]) << 32);
5216 + seq += ktime_to_ns(ktime_get_real());
5217 + seq &= (1ull << 48) - 1;
5218 +
5219 + return seq;
5220 +}
5221 +EXPORT_SYMBOL(secure_dccpv6_sequence_number);
5222 +#endif
5223 +#endif
5224 diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
5225 index 8c36adf..332639b 100644
5226 --- a/net/dccp/ipv4.c
5227 +++ b/net/dccp/ipv4.c
5228 @@ -26,6 +26,7 @@
5229 #include <net/timewait_sock.h>
5230 #include <net/tcp_states.h>
5231 #include <net/xfrm.h>
5232 +#include <net/secure_seq.h>
5233
5234 #include "ackvec.h"
5235 #include "ccid.h"
5236 diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
5237 index 8dc4348..b74f761 100644
5238 --- a/net/dccp/ipv6.c
5239 +++ b/net/dccp/ipv6.c
5240 @@ -29,6 +29,7 @@
5241 #include <net/transp_v6.h>
5242 #include <net/ip6_checksum.h>
5243 #include <net/xfrm.h>
5244 +#include <net/secure_seq.h>
5245
5246 #include "dccp.h"
5247 #include "ipv6.h"
5248 @@ -69,13 +70,7 @@ static inline void dccp_v6_send_check(struct sock *sk, struct sk_buff *skb)
5249 dh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &np->daddr);
5250 }
5251
5252 -static inline __u32 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
5253 - __be16 sport, __be16 dport )
5254 -{
5255 - return secure_tcpv6_sequence_number(saddr, daddr, sport, dport);
5256 -}
5257 -
5258 -static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb)
5259 +static inline __u64 dccp_v6_init_sequence(struct sk_buff *skb)
5260 {
5261 return secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
5262 ipv6_hdr(skb)->saddr.s6_addr32,
5263 diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
5264 index 44d2b42..2780e9b 100644
5265 --- a/net/ethernet/eth.c
5266 +++ b/net/ethernet/eth.c
5267 @@ -340,6 +340,7 @@ void ether_setup(struct net_device *dev)
5268 dev->addr_len = ETH_ALEN;
5269 dev->tx_queue_len = 1000; /* Ethernet wants good queues */
5270 dev->flags = IFF_BROADCAST|IFF_MULTICAST;
5271 + dev->priv_flags = IFF_TX_SKB_SHARING;
5272
5273 memset(dev->broadcast, 0xFF, ETH_ALEN);
5274
5275 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
5276 index 0d4a184..4155abc 100644
5277 --- a/net/ipv4/devinet.c
5278 +++ b/net/ipv4/devinet.c
5279 @@ -1134,15 +1134,15 @@ static void inetdev_send_gratuitous_arp(struct net_device *dev,
5280 struct in_device *in_dev)
5281
5282 {
5283 - struct in_ifaddr *ifa = in_dev->ifa_list;
5284 -
5285 - if (!ifa)
5286 - return;
5287 + struct in_ifaddr *ifa;
5288
5289 - arp_send(ARPOP_REQUEST, ETH_P_ARP,
5290 - ifa->ifa_local, dev,
5291 - ifa->ifa_local, NULL,
5292 - dev->dev_addr, NULL);
5293 + for (ifa = in_dev->ifa_list; ifa;
5294 + ifa = ifa->ifa_next) {
5295 + arp_send(ARPOP_REQUEST, ETH_P_ARP,
5296 + ifa->ifa_local, dev,
5297 + ifa->ifa_local, NULL,
5298 + dev->dev_addr, NULL);
5299 + }
5300 }
5301
5302 /* Called only under RTNL semaphore */
5303 diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
5304 index c6933f2..3e3f75d 100644
5305 --- a/net/ipv4/gre.c
5306 +++ b/net/ipv4/gre.c
5307 @@ -15,6 +15,7 @@
5308 #include <linux/kmod.h>
5309 #include <linux/skbuff.h>
5310 #include <linux/in.h>
5311 +#include <linux/ip.h>
5312 #include <linux/netdevice.h>
5313 #include <linux/version.h>
5314 #include <linux/spinlock.h>
5315 @@ -97,27 +98,17 @@ drop:
5316 static void gre_err(struct sk_buff *skb, u32 info)
5317 {
5318 const struct gre_protocol *proto;
5319 - u8 ver;
5320 -
5321 - if (!pskb_may_pull(skb, 12))
5322 - goto drop;
5323 + const struct iphdr *iph = (const struct iphdr *)skb->data;
5324 + u8 ver = skb->data[(iph->ihl<<2) + 1]&0x7f;
5325
5326 - ver = skb->data[1]&0x7f;
5327 if (ver >= GREPROTO_MAX)
5328 - goto drop;
5329 + return;
5330
5331 rcu_read_lock();
5332 proto = rcu_dereference(gre_proto[ver]);
5333 - if (!proto || !proto->err_handler)
5334 - goto drop_unlock;
5335 - proto->err_handler(skb, info);
5336 - rcu_read_unlock();
5337 - return;
5338 -
5339 -drop_unlock:
5340 + if (proto && proto->err_handler)
5341 + proto->err_handler(skb, info);
5342 rcu_read_unlock();
5343 -drop:
5344 - kfree_skb(skb);
5345 }
5346
5347 static const struct net_protocol net_gre_protocol = {
5348 diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
5349 index 5395e45..23ef31b 100644
5350 --- a/net/ipv4/icmp.c
5351 +++ b/net/ipv4/icmp.c
5352 @@ -380,6 +380,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
5353 struct icmp_bxm *param)
5354 {
5355 struct rtable *rt, *rt2;
5356 + struct flowi4 fl4_dec;
5357 int err;
5358
5359 memset(fl4, 0, sizeof(*fl4));
5360 @@ -408,19 +409,19 @@ static struct rtable *icmp_route_lookup(struct net *net,
5361 } else
5362 return rt;
5363
5364 - err = xfrm_decode_session_reverse(skb_in, flowi4_to_flowi(fl4), AF_INET);
5365 + err = xfrm_decode_session_reverse(skb_in, flowi4_to_flowi(&fl4_dec), AF_INET);
5366 if (err)
5367 goto relookup_failed;
5368
5369 - if (inet_addr_type(net, fl4->saddr) == RTN_LOCAL) {
5370 - rt2 = __ip_route_output_key(net, fl4);
5371 + if (inet_addr_type(net, fl4_dec.saddr) == RTN_LOCAL) {
5372 + rt2 = __ip_route_output_key(net, &fl4_dec);
5373 if (IS_ERR(rt2))
5374 err = PTR_ERR(rt2);
5375 } else {
5376 struct flowi4 fl4_2 = {};
5377 unsigned long orefdst;
5378
5379 - fl4_2.daddr = fl4->saddr;
5380 + fl4_2.daddr = fl4_dec.saddr;
5381 rt2 = ip_route_output_key(net, &fl4_2);
5382 if (IS_ERR(rt2)) {
5383 err = PTR_ERR(rt2);
5384 @@ -428,7 +429,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
5385 }
5386 /* Ugh! */
5387 orefdst = skb_in->_skb_refdst; /* save old refdst */
5388 - err = ip_route_input(skb_in, fl4->daddr, fl4->saddr,
5389 + err = ip_route_input(skb_in, fl4_dec.daddr, fl4_dec.saddr,
5390 RT_TOS(tos), rt2->dst.dev);
5391
5392 dst_release(&rt2->dst);
5393 @@ -440,10 +441,11 @@ static struct rtable *icmp_route_lookup(struct net *net,
5394 goto relookup_failed;
5395
5396 rt2 = (struct rtable *) xfrm_lookup(net, &rt2->dst,
5397 - flowi4_to_flowi(fl4), NULL,
5398 + flowi4_to_flowi(&fl4_dec), NULL,
5399 XFRM_LOOKUP_ICMP);
5400 if (!IS_ERR(rt2)) {
5401 dst_release(&rt->dst);
5402 + memcpy(fl4, &fl4_dec, sizeof(*fl4));
5403 rt = rt2;
5404 } else if (PTR_ERR(rt2) == -EPERM) {
5405 if (rt)
5406 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
5407 index f1d27f6..283c0a2 100644
5408 --- a/net/ipv4/igmp.c
5409 +++ b/net/ipv4/igmp.c
5410 @@ -1718,7 +1718,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
5411
5412 pmc->sfcount[sfmode]--;
5413 for (j=0; j<i; j++)
5414 - (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
5415 + (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[j]);
5416 } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
5417 #ifdef CONFIG_IP_MULTICAST
5418 struct ip_sf_list *psf;
5419 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
5420 index 3c0369a..984ec65 100644
5421 --- a/net/ipv4/inet_hashtables.c
5422 +++ b/net/ipv4/inet_hashtables.c
5423 @@ -21,6 +21,7 @@
5424
5425 #include <net/inet_connection_sock.h>
5426 #include <net/inet_hashtables.h>
5427 +#include <net/secure_seq.h>
5428 #include <net/ip.h>
5429
5430 /*
5431 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
5432 index ce616d9..6877645 100644
5433 --- a/net/ipv4/inetpeer.c
5434 +++ b/net/ipv4/inetpeer.c
5435 @@ -19,6 +19,7 @@
5436 #include <linux/net.h>
5437 #include <net/ip.h>
5438 #include <net/inetpeer.h>
5439 +#include <net/secure_seq.h>
5440
5441 /*
5442 * Theory of operations.
5443 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
5444 index 84f26e8..0c99db4 100644
5445 --- a/net/ipv4/ip_output.c
5446 +++ b/net/ipv4/ip_output.c
5447 @@ -734,7 +734,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
5448 int getfrag(void *from, char *to, int offset, int len,
5449 int odd, struct sk_buff *skb),
5450 void *from, int length, int hh_len, int fragheaderlen,
5451 - int transhdrlen, int mtu, unsigned int flags)
5452 + int transhdrlen, int maxfraglen, unsigned int flags)
5453 {
5454 struct sk_buff *skb;
5455 int err;
5456 @@ -767,7 +767,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
5457 skb->csum = 0;
5458
5459 /* specify the length of each IP datagram fragment */
5460 - skb_shinfo(skb)->gso_size = mtu - fragheaderlen;
5461 + skb_shinfo(skb)->gso_size = maxfraglen - fragheaderlen;
5462 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
5463 __skb_queue_tail(queue, skb);
5464 }
5465 @@ -831,7 +831,7 @@ static int __ip_append_data(struct sock *sk,
5466 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) {
5467 err = ip_ufo_append_data(sk, queue, getfrag, from, length,
5468 hh_len, fragheaderlen, transhdrlen,
5469 - mtu, flags);
5470 + maxfraglen, flags);
5471 if (err)
5472 goto error;
5473 return 0;
5474 diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
5475 index 30a7763..f81af8d 100644
5476 --- a/net/ipv4/ipmr.c
5477 +++ b/net/ipv4/ipmr.c
5478 @@ -1796,7 +1796,7 @@ static struct mr_table *ipmr_rt_fib_lookup(struct net *net, struct sk_buff *skb)
5479 struct flowi4 fl4 = {
5480 .daddr = iph->daddr,
5481 .saddr = iph->saddr,
5482 - .flowi4_tos = iph->tos,
5483 + .flowi4_tos = RT_TOS(iph->tos),
5484 .flowi4_oif = rt->rt_oif,
5485 .flowi4_iif = rt->rt_iif,
5486 .flowi4_mark = rt->rt_mark,
5487 diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c
5488 index 3e61faf..f52d41e 100644
5489 --- a/net/ipv4/netfilter/nf_nat_proto_common.c
5490 +++ b/net/ipv4/netfilter/nf_nat_proto_common.c
5491 @@ -12,6 +12,7 @@
5492 #include <linux/ip.h>
5493
5494 #include <linux/netfilter.h>
5495 +#include <net/secure_seq.h>
5496 #include <net/netfilter/nf_nat.h>
5497 #include <net/netfilter/nf_nat_core.h>
5498 #include <net/netfilter/nf_nat_rule.h>
5499 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
5500 index aa13ef1..cdabdbf 100644
5501 --- a/net/ipv4/route.c
5502 +++ b/net/ipv4/route.c
5503 @@ -108,6 +108,7 @@
5504 #ifdef CONFIG_SYSCTL
5505 #include <linux/sysctl.h>
5506 #endif
5507 +#include <net/secure_seq.h>
5508
5509 #define RT_FL_TOS(oldflp4) \
5510 ((u32)(oldflp4->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK)))
5511 @@ -725,6 +726,7 @@ static inline int compare_keys(struct rtable *rt1, struct rtable *rt2)
5512 ((__force u32)rt1->rt_key_src ^ (__force u32)rt2->rt_key_src) |
5513 (rt1->rt_mark ^ rt2->rt_mark) |
5514 (rt1->rt_key_tos ^ rt2->rt_key_tos) |
5515 + (rt1->rt_route_iif ^ rt2->rt_route_iif) |
5516 (rt1->rt_oif ^ rt2->rt_oif) |
5517 (rt1->rt_iif ^ rt2->rt_iif)) == 0;
5518 }
5519 @@ -1703,7 +1705,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)
5520 memset(&fl4, 0, sizeof(fl4));
5521 fl4.daddr = iph->daddr;
5522 fl4.saddr = iph->saddr;
5523 - fl4.flowi4_tos = iph->tos;
5524 + fl4.flowi4_tos = RT_TOS(iph->tos);
5525 fl4.flowi4_oif = rt->dst.dev->ifindex;
5526 fl4.flowi4_iif = skb->dev->ifindex;
5527 fl4.flowi4_mark = skb->mark;
5528 @@ -2281,8 +2283,8 @@ int ip_route_input_common(struct sk_buff *skb, __be32 daddr, __be32 saddr,
5529 if ((((__force u32)rth->rt_key_dst ^ (__force u32)daddr) |
5530 ((__force u32)rth->rt_key_src ^ (__force u32)saddr) |
5531 (rth->rt_iif ^ iif) |
5532 - rth->rt_oif |
5533 (rth->rt_key_tos ^ tos)) == 0 &&
5534 + rt_is_input_route(rth) &&
5535 rth->rt_mark == skb->mark &&
5536 net_eq(dev_net(rth->dst.dev), net) &&
5537 !rt_is_expired(rth)) {
5538 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
5539 index 708dc20..b3e6956 100644
5540 --- a/net/ipv4/tcp_ipv4.c
5541 +++ b/net/ipv4/tcp_ipv4.c
5542 @@ -72,6 +72,7 @@
5543 #include <net/timewait_sock.h>
5544 #include <net/xfrm.h>
5545 #include <net/netdma.h>
5546 +#include <net/secure_seq.h>
5547
5548 #include <linux/inet.h>
5549 #include <linux/ipv6.h>
5550 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
5551 index 3b5669a..5591236 100644
5552 --- a/net/ipv6/af_inet6.c
5553 +++ b/net/ipv6/af_inet6.c
5554 @@ -1078,6 +1078,8 @@ static int __init inet6_init(void)
5555 goto out;
5556 }
5557
5558 + initialize_hashidentrnd();
5559 +
5560 err = proto_register(&tcpv6_prot, 1);
5561 if (err)
5562 goto out;
5563 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
5564 index b531972..73f1a00 100644
5565 --- a/net/ipv6/inet6_hashtables.c
5566 +++ b/net/ipv6/inet6_hashtables.c
5567 @@ -20,6 +20,7 @@
5568 #include <net/inet_connection_sock.h>
5569 #include <net/inet_hashtables.h>
5570 #include <net/inet6_hashtables.h>
5571 +#include <net/secure_seq.h>
5572 #include <net/ip.h>
5573
5574 int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw)
5575 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
5576 index 9d4b165..1661296 100644
5577 --- a/net/ipv6/ip6_output.c
5578 +++ b/net/ipv6/ip6_output.c
5579 @@ -596,6 +596,35 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
5580 return offset;
5581 }
5582
5583 +static u32 hashidentrnd __read_mostly;
5584 +#define FID_HASH_SZ 16
5585 +static u32 ipv6_fragmentation_id[FID_HASH_SZ];
5586 +
5587 +void __init initialize_hashidentrnd(void)
5588 +{
5589 + get_random_bytes(&hashidentrnd, sizeof(hashidentrnd));
5590 +}
5591 +
5592 +static u32 __ipv6_select_ident(const struct in6_addr *addr)
5593 +{
5594 + u32 newid, oldid, hash = jhash2((u32 *)addr, 4, hashidentrnd);
5595 + u32 *pid = &ipv6_fragmentation_id[hash % FID_HASH_SZ];
5596 +
5597 + do {
5598 + oldid = *pid;
5599 + newid = oldid + 1;
5600 + if (!(hash + newid))
5601 + newid++;
5602 + } while (cmpxchg(pid, oldid, newid) != oldid);
5603 +
5604 + return hash + newid;
5605 +}
5606 +
5607 +void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
5608 +{
5609 + fhdr->identification = htonl(__ipv6_select_ident(&rt->rt6i_dst.addr));
5610 +}
5611 +
5612 int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
5613 {
5614 struct sk_buff *frag;
5615 @@ -680,7 +709,7 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
5616 skb_reset_network_header(skb);
5617 memcpy(skb_network_header(skb), tmp_hdr, hlen);
5618
5619 - ipv6_select_ident(fh);
5620 + ipv6_select_ident(fh, rt);
5621 fh->nexthdr = nexthdr;
5622 fh->reserved = 0;
5623 fh->frag_off = htons(IP6_MF);
5624 @@ -826,7 +855,7 @@ slow_path:
5625 fh->nexthdr = nexthdr;
5626 fh->reserved = 0;
5627 if (!frag_id) {
5628 - ipv6_select_ident(fh);
5629 + ipv6_select_ident(fh, rt);
5630 frag_id = fh->identification;
5631 } else
5632 fh->identification = frag_id;
5633 @@ -1072,7 +1101,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
5634 int getfrag(void *from, char *to, int offset, int len,
5635 int odd, struct sk_buff *skb),
5636 void *from, int length, int hh_len, int fragheaderlen,
5637 - int transhdrlen, int mtu,unsigned int flags)
5638 + int transhdrlen, int mtu,unsigned int flags,
5639 + struct rt6_info *rt)
5640
5641 {
5642 struct sk_buff *skb;
5643 @@ -1116,7 +1146,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
5644 skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
5645 sizeof(struct frag_hdr)) & ~7;
5646 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
5647 - ipv6_select_ident(&fhdr);
5648 + ipv6_select_ident(&fhdr, rt);
5649 skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
5650 __skb_queue_tail(&sk->sk_write_queue, skb);
5651
5652 @@ -1282,7 +1312,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
5653
5654 err = ip6_ufo_append_data(sk, getfrag, from, length,
5655 hh_len, fragheaderlen,
5656 - transhdrlen, mtu, flags);
5657 + transhdrlen, mtu, flags, rt);
5658 if (err)
5659 goto error;
5660 return 0;
5661 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
5662 index 87551ca..7c43e86 100644
5663 --- a/net/ipv6/tcp_ipv6.c
5664 +++ b/net/ipv6/tcp_ipv6.c
5665 @@ -61,6 +61,7 @@
5666 #include <net/timewait_sock.h>
5667 #include <net/netdma.h>
5668 #include <net/inet_common.h>
5669 +#include <net/secure_seq.h>
5670
5671 #include <asm/uaccess.h>
5672
5673 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
5674 index 328985c..29213b5 100644
5675 --- a/net/ipv6/udp.c
5676 +++ b/net/ipv6/udp.c
5677 @@ -1359,7 +1359,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features)
5678 fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
5679 fptr->nexthdr = nexthdr;
5680 fptr->reserved = 0;
5681 - ipv6_select_ident(fptr);
5682 + ipv6_select_ident(fptr, (struct rt6_info *)skb_dst(skb));
5683
5684 /* Fragment the skb. ipv6 header and the remaining fields of the
5685 * fragment header are updated in ipv6_gso_segment()
5686 diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
5687 index a8193f5..d2726a7 100644
5688 --- a/net/l2tp/l2tp_eth.c
5689 +++ b/net/l2tp/l2tp_eth.c
5690 @@ -103,7 +103,7 @@ static struct net_device_ops l2tp_eth_netdev_ops = {
5691 static void l2tp_eth_dev_setup(struct net_device *dev)
5692 {
5693 ether_setup(dev);
5694 -
5695 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
5696 dev->netdev_ops = &l2tp_eth_netdev_ops;
5697 dev->destructor = free_netdev;
5698 }
5699 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
5700 index dee30ae..895eec1 100644
5701 --- a/net/mac80211/iface.c
5702 +++ b/net/mac80211/iface.c
5703 @@ -699,6 +699,7 @@ static const struct net_device_ops ieee80211_monitorif_ops = {
5704 static void ieee80211_if_setup(struct net_device *dev)
5705 {
5706 ether_setup(dev);
5707 + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
5708 dev->netdev_ops = &ieee80211_dataif_ops;
5709 dev->destructor = free_netdev;
5710 }
5711 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
5712 index 699c79a..a178cb3 100644
5713 --- a/net/netfilter/ipvs/ip_vs_ctl.c
5714 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
5715 @@ -3771,6 +3771,7 @@ err_sock:
5716 void ip_vs_control_cleanup(void)
5717 {
5718 EnterFunction(2);
5719 + unregister_netdevice_notifier(&ip_vs_dst_notifier);
5720 ip_vs_genl_unregister();
5721 nf_unregister_sockopt(&ip_vs_sockopts);
5722 LeaveFunction(2);
5723 diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
5724 index b6ea6af..69400e3 100644
5725 --- a/net/sched/sch_sfq.c
5726 +++ b/net/sched/sch_sfq.c
5727 @@ -410,7 +410,12 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
5728 /* Return Congestion Notification only if we dropped a packet
5729 * from this flow.
5730 */
5731 - return (qlen != slot->qlen) ? NET_XMIT_CN : NET_XMIT_SUCCESS;
5732 + if (qlen != slot->qlen)
5733 + return NET_XMIT_CN;
5734 +
5735 + /* As we dropped a packet, better let upper stack know this */
5736 + qdisc_tree_decrease_qlen(sch, 1);
5737 + return NET_XMIT_SUCCESS;
5738 }
5739
5740 static struct sk_buff *
5741 diff --git a/net/socket.c b/net/socket.c
5742 index 02dc82d..ed46dbb 100644
5743 --- a/net/socket.c
5744 +++ b/net/socket.c
5745 @@ -1871,8 +1871,14 @@ SYSCALL_DEFINE2(shutdown, int, fd, int, how)
5746 #define COMPAT_NAMELEN(msg) COMPAT_MSG(msg, msg_namelen)
5747 #define COMPAT_FLAGS(msg) COMPAT_MSG(msg, msg_flags)
5748
5749 +struct used_address {
5750 + struct sockaddr_storage name;
5751 + unsigned int name_len;
5752 +};
5753 +
5754 static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
5755 - struct msghdr *msg_sys, unsigned flags, int nosec)
5756 + struct msghdr *msg_sys, unsigned flags,
5757 + struct used_address *used_address)
5758 {
5759 struct compat_msghdr __user *msg_compat =
5760 (struct compat_msghdr __user *)msg;
5761 @@ -1953,8 +1959,28 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
5762
5763 if (sock->file->f_flags & O_NONBLOCK)
5764 msg_sys->msg_flags |= MSG_DONTWAIT;
5765 - err = (nosec ? sock_sendmsg_nosec : sock_sendmsg)(sock, msg_sys,
5766 - total_len);
5767 + /*
5768 + * If this is sendmmsg() and current destination address is same as
5769 + * previously succeeded address, omit asking LSM's decision.
5770 + * used_address->name_len is initialized to UINT_MAX so that the first
5771 + * destination address never matches.
5772 + */
5773 + if (used_address && used_address->name_len == msg_sys->msg_namelen &&
5774 + !memcmp(&used_address->name, msg->msg_name,
5775 + used_address->name_len)) {
5776 + err = sock_sendmsg_nosec(sock, msg_sys, total_len);
5777 + goto out_freectl;
5778 + }
5779 + err = sock_sendmsg(sock, msg_sys, total_len);
5780 + /*
5781 + * If this is sendmmsg() and sending to current destination address was
5782 + * successful, remember it.
5783 + */
5784 + if (used_address && err >= 0) {
5785 + used_address->name_len = msg_sys->msg_namelen;
5786 + memcpy(&used_address->name, msg->msg_name,
5787 + used_address->name_len);
5788 + }
5789
5790 out_freectl:
5791 if (ctl_buf != ctl)
5792 @@ -1979,7 +2005,7 @@ SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned, flags)
5793 if (!sock)
5794 goto out;
5795
5796 - err = __sys_sendmsg(sock, msg, &msg_sys, flags, 0);
5797 + err = __sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
5798
5799 fput_light(sock->file, fput_needed);
5800 out:
5801 @@ -1998,6 +2024,10 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
5802 struct mmsghdr __user *entry;
5803 struct compat_mmsghdr __user *compat_entry;
5804 struct msghdr msg_sys;
5805 + struct used_address used_address;
5806 +
5807 + if (vlen > UIO_MAXIOV)
5808 + vlen = UIO_MAXIOV;
5809
5810 datagrams = 0;
5811
5812 @@ -2005,27 +2035,22 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
5813 if (!sock)
5814 return err;
5815
5816 - err = sock_error(sock->sk);
5817 - if (err)
5818 - goto out_put;
5819 -
5820 + used_address.name_len = UINT_MAX;
5821 entry = mmsg;
5822 compat_entry = (struct compat_mmsghdr __user *)mmsg;
5823 + err = 0;
5824
5825 while (datagrams < vlen) {
5826 - /*
5827 - * No need to ask LSM for more than the first datagram.
5828 - */
5829 if (MSG_CMSG_COMPAT & flags) {
5830 err = __sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
5831 - &msg_sys, flags, datagrams);
5832 + &msg_sys, flags, &used_address);
5833 if (err < 0)
5834 break;
5835 err = __put_user(err, &compat_entry->msg_len);
5836 ++compat_entry;
5837 } else {
5838 err = __sys_sendmsg(sock, (struct msghdr __user *)entry,
5839 - &msg_sys, flags, datagrams);
5840 + &msg_sys, flags, &used_address);
5841 if (err < 0)
5842 break;
5843 err = put_user(err, &entry->msg_len);
5844 @@ -2037,29 +2062,11 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
5845 ++datagrams;
5846 }
5847
5848 -out_put:
5849 fput_light(sock->file, fput_needed);
5850
5851 - if (err == 0)
5852 - return datagrams;
5853 -
5854 - if (datagrams != 0) {
5855 - /*
5856 - * We may send less entries than requested (vlen) if the
5857 - * sock is non blocking...
5858 - */
5859 - if (err != -EAGAIN) {
5860 - /*
5861 - * ... or if sendmsg returns an error after we
5862 - * send some datagrams, where we record the
5863 - * error to return on the next call or if the
5864 - * app asks about it using getsockopt(SO_ERROR).
5865 - */
5866 - sock->sk->sk_err = -err;
5867 - }
5868 -
5869 + /* We only return an error if no datagrams were able to be sent */
5870 + if (datagrams != 0)
5871 return datagrams;
5872 - }
5873
5874 return err;
5875 }
5876 diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
5877 index 58064d9..791ab2e 100644
5878 --- a/net/xfrm/xfrm_algo.c
5879 +++ b/net/xfrm/xfrm_algo.c
5880 @@ -462,8 +462,8 @@ static struct xfrm_algo_desc ealg_list[] = {
5881 .desc = {
5882 .sadb_alg_id = SADB_X_EALG_AESCTR,
5883 .sadb_alg_ivlen = 8,
5884 - .sadb_alg_minbits = 128,
5885 - .sadb_alg_maxbits = 256
5886 + .sadb_alg_minbits = 160,
5887 + .sadb_alg_maxbits = 288
5888 }
5889 },
5890 };
5891 diff --git a/sound/core/timer.c b/sound/core/timer.c
5892 index 7c1cbf0..950eed0 100644
5893 --- a/sound/core/timer.c
5894 +++ b/sound/core/timer.c
5895 @@ -531,6 +531,8 @@ int snd_timer_stop(struct snd_timer_instance *timeri)
5896 if (err < 0)
5897 return err;
5898 timer = timeri->timer;
5899 + if (!timer)
5900 + return -EINVAL;
5901 spin_lock_irqsave(&timer->lock, flags);
5902 timeri->cticks = timeri->ticks;
5903 timeri->pticks = 0;
5904 diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
5905 index ff29380..c49317c 100644
5906 --- a/sound/soc/codecs/sgtl5000.c
5907 +++ b/sound/soc/codecs/sgtl5000.c
5908 @@ -33,73 +33,31 @@
5909 #define SGTL5000_DAP_REG_OFFSET 0x0100
5910 #define SGTL5000_MAX_REG_OFFSET 0x013A
5911
5912 -/* default value of sgtl5000 registers except DAP */
5913 -static const u16 sgtl5000_regs[SGTL5000_MAX_REG_OFFSET >> 1] = {
5914 - 0xa011, /* 0x0000, CHIP_ID. 11 stand for revison 17 */
5915 - 0x0000, /* 0x0002, CHIP_DIG_POWER. */
5916 - 0x0008, /* 0x0004, CHIP_CKL_CTRL */
5917 - 0x0010, /* 0x0006, CHIP_I2S_CTRL */
5918 - 0x0000, /* 0x0008, reserved */
5919 - 0x0008, /* 0x000A, CHIP_SSS_CTRL */
5920 - 0x0000, /* 0x000C, reserved */
5921 - 0x020c, /* 0x000E, CHIP_ADCDAC_CTRL */
5922 - 0x3c3c, /* 0x0010, CHIP_DAC_VOL */
5923 - 0x0000, /* 0x0012, reserved */
5924 - 0x015f, /* 0x0014, CHIP_PAD_STRENGTH */
5925 - 0x0000, /* 0x0016, reserved */
5926 - 0x0000, /* 0x0018, reserved */
5927 - 0x0000, /* 0x001A, reserved */
5928 - 0x0000, /* 0x001E, reserved */
5929 - 0x0000, /* 0x0020, CHIP_ANA_ADC_CTRL */
5930 - 0x1818, /* 0x0022, CHIP_ANA_HP_CTRL */
5931 - 0x0111, /* 0x0024, CHIP_ANN_CTRL */
5932 - 0x0000, /* 0x0026, CHIP_LINREG_CTRL */
5933 - 0x0000, /* 0x0028, CHIP_REF_CTRL */
5934 - 0x0000, /* 0x002A, CHIP_MIC_CTRL */
5935 - 0x0000, /* 0x002C, CHIP_LINE_OUT_CTRL */
5936 - 0x0404, /* 0x002E, CHIP_LINE_OUT_VOL */
5937 - 0x7060, /* 0x0030, CHIP_ANA_POWER */
5938 - 0x5000, /* 0x0032, CHIP_PLL_CTRL */
5939 - 0x0000, /* 0x0034, CHIP_CLK_TOP_CTRL */
5940 - 0x0000, /* 0x0036, CHIP_ANA_STATUS */
5941 - 0x0000, /* 0x0038, reserved */
5942 - 0x0000, /* 0x003A, CHIP_ANA_TEST2 */
5943 - 0x0000, /* 0x003C, CHIP_SHORT_CTRL */
5944 - 0x0000, /* reserved */
5945 -};
5946 -
5947 -/* default value of dap registers */
5948 -static const u16 sgtl5000_dap_regs[] = {
5949 - 0x0000, /* 0x0100, DAP_CONTROL */
5950 - 0x0000, /* 0x0102, DAP_PEQ */
5951 - 0x0040, /* 0x0104, DAP_BASS_ENHANCE */
5952 - 0x051f, /* 0x0106, DAP_BASS_ENHANCE_CTRL */
5953 - 0x0000, /* 0x0108, DAP_AUDIO_EQ */
5954 - 0x0040, /* 0x010A, DAP_SGTL_SURROUND */
5955 - 0x0000, /* 0x010C, DAP_FILTER_COEF_ACCESS */
5956 - 0x0000, /* 0x010E, DAP_COEF_WR_B0_MSB */
5957 - 0x0000, /* 0x0110, DAP_COEF_WR_B0_LSB */
5958 - 0x0000, /* 0x0112, reserved */
5959 - 0x0000, /* 0x0114, reserved */
5960 - 0x002f, /* 0x0116, DAP_AUDIO_EQ_BASS_BAND0 */
5961 - 0x002f, /* 0x0118, DAP_AUDIO_EQ_BAND0 */
5962 - 0x002f, /* 0x011A, DAP_AUDIO_EQ_BAND2 */
5963 - 0x002f, /* 0x011C, DAP_AUDIO_EQ_BAND3 */
5964 - 0x002f, /* 0x011E, DAP_AUDIO_EQ_TREBLE_BAND4 */
5965 - 0x8000, /* 0x0120, DAP_MAIN_CHAN */
5966 - 0x0000, /* 0x0122, DAP_MIX_CHAN */
5967 - 0x0510, /* 0x0124, DAP_AVC_CTRL */
5968 - 0x1473, /* 0x0126, DAP_AVC_THRESHOLD */
5969 - 0x0028, /* 0x0128, DAP_AVC_ATTACK */
5970 - 0x0050, /* 0x012A, DAP_AVC_DECAY */
5971 - 0x0000, /* 0x012C, DAP_COEF_WR_B1_MSB */
5972 - 0x0000, /* 0x012E, DAP_COEF_WR_B1_LSB */
5973 - 0x0000, /* 0x0130, DAP_COEF_WR_B2_MSB */
5974 - 0x0000, /* 0x0132, DAP_COEF_WR_B2_LSB */
5975 - 0x0000, /* 0x0134, DAP_COEF_WR_A1_MSB */
5976 - 0x0000, /* 0x0136, DAP_COEF_WR_A1_LSB */
5977 - 0x0000, /* 0x0138, DAP_COEF_WR_A2_MSB */
5978 - 0x0000, /* 0x013A, DAP_COEF_WR_A2_LSB */
5979 +/* default value of sgtl5000 registers */
5980 +static const u16 sgtl5000_regs[SGTL5000_MAX_REG_OFFSET] = {
5981 + [SGTL5000_CHIP_CLK_CTRL] = 0x0008,
5982 + [SGTL5000_CHIP_I2S_CTRL] = 0x0010,
5983 + [SGTL5000_CHIP_SSS_CTRL] = 0x0008,
5984 + [SGTL5000_CHIP_DAC_VOL] = 0x3c3c,
5985 + [SGTL5000_CHIP_PAD_STRENGTH] = 0x015f,
5986 + [SGTL5000_CHIP_ANA_HP_CTRL] = 0x1818,
5987 + [SGTL5000_CHIP_ANA_CTRL] = 0x0111,
5988 + [SGTL5000_CHIP_LINE_OUT_VOL] = 0x0404,
5989 + [SGTL5000_CHIP_ANA_POWER] = 0x7060,
5990 + [SGTL5000_CHIP_PLL_CTRL] = 0x5000,
5991 + [SGTL5000_DAP_BASS_ENHANCE] = 0x0040,
5992 + [SGTL5000_DAP_BASS_ENHANCE_CTRL] = 0x051f,
5993 + [SGTL5000_DAP_SURROUND] = 0x0040,
5994 + [SGTL5000_DAP_EQ_BASS_BAND0] = 0x002f,
5995 + [SGTL5000_DAP_EQ_BASS_BAND1] = 0x002f,
5996 + [SGTL5000_DAP_EQ_BASS_BAND2] = 0x002f,
5997 + [SGTL5000_DAP_EQ_BASS_BAND3] = 0x002f,
5998 + [SGTL5000_DAP_EQ_BASS_BAND4] = 0x002f,
5999 + [SGTL5000_DAP_MAIN_CHAN] = 0x8000,
6000 + [SGTL5000_DAP_AVC_CTRL] = 0x0510,
6001 + [SGTL5000_DAP_AVC_THRESHOLD] = 0x1473,
6002 + [SGTL5000_DAP_AVC_ATTACK] = 0x0028,
6003 + [SGTL5000_DAP_AVC_DECAY] = 0x0050,
6004 };
6005
6006 /* regulator supplies for sgtl5000, VDDD is an optional external supply */
6007 @@ -1022,12 +980,10 @@ static int sgtl5000_suspend(struct snd_soc_codec *codec, pm_message_t state)
6008 static int sgtl5000_restore_regs(struct snd_soc_codec *codec)
6009 {
6010 u16 *cache = codec->reg_cache;
6011 - int i;
6012 - int regular_regs = SGTL5000_CHIP_SHORT_CTRL >> 1;
6013 + u16 reg;
6014
6015 /* restore regular registers */
6016 - for (i = 0; i < regular_regs; i++) {
6017 - int reg = i << 1;
6018 + for (reg = 0; reg <= SGTL5000_CHIP_SHORT_CTRL; reg += 2) {
6019
6020 /* this regs depends on the others */
6021 if (reg == SGTL5000_CHIP_ANA_POWER ||
6022 @@ -1037,35 +993,31 @@ static int sgtl5000_restore_regs(struct snd_soc_codec *codec)
6023 reg == SGTL5000_CHIP_CLK_CTRL)
6024 continue;
6025
6026 - snd_soc_write(codec, reg, cache[i]);
6027 + snd_soc_write(codec, reg, cache[reg]);
6028 }
6029
6030 /* restore dap registers */
6031 - for (i = SGTL5000_DAP_REG_OFFSET >> 1;
6032 - i < SGTL5000_MAX_REG_OFFSET >> 1; i++) {
6033 - int reg = i << 1;
6034 -
6035 - snd_soc_write(codec, reg, cache[i]);
6036 - }
6037 + for (reg = SGTL5000_DAP_REG_OFFSET; reg < SGTL5000_MAX_REG_OFFSET; reg += 2)
6038 + snd_soc_write(codec, reg, cache[reg]);
6039
6040 /*
6041 * restore power and other regs according
6042 * to set_power() and set_clock()
6043 */
6044 snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL,
6045 - cache[SGTL5000_CHIP_LINREG_CTRL >> 1]);
6046 + cache[SGTL5000_CHIP_LINREG_CTRL]);
6047
6048 snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER,
6049 - cache[SGTL5000_CHIP_ANA_POWER >> 1]);
6050 + cache[SGTL5000_CHIP_ANA_POWER]);
6051
6052 snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL,
6053 - cache[SGTL5000_CHIP_CLK_CTRL >> 1]);
6054 + cache[SGTL5000_CHIP_CLK_CTRL]);
6055
6056 snd_soc_write(codec, SGTL5000_CHIP_REF_CTRL,
6057 - cache[SGTL5000_CHIP_REF_CTRL >> 1]);
6058 + cache[SGTL5000_CHIP_REF_CTRL]);
6059
6060 snd_soc_write(codec, SGTL5000_CHIP_LINE_OUT_CTRL,
6061 - cache[SGTL5000_CHIP_LINE_OUT_CTRL >> 1]);
6062 + cache[SGTL5000_CHIP_LINE_OUT_CTRL]);
6063 return 0;
6064 }
6065
6066 @@ -1460,16 +1412,6 @@ static __devinit int sgtl5000_i2c_probe(struct i2c_client *client,
6067 if (!sgtl5000)
6068 return -ENOMEM;
6069
6070 - /*
6071 - * copy DAP default values to default value array.
6072 - * sgtl5000 register space has a big hole, merge it
6073 - * at init phase makes life easy.
6074 - * FIXME: should we drop 'const' of sgtl5000_regs?
6075 - */
6076 - memcpy((void *)(&sgtl5000_regs[0] + (SGTL5000_DAP_REG_OFFSET >> 1)),
6077 - sgtl5000_dap_regs,
6078 - SGTL5000_MAX_REG_OFFSET - SGTL5000_DAP_REG_OFFSET);
6079 -
6080 i2c_set_clientdata(client, sgtl5000);
6081
6082 ret = snd_soc_register_codec(&client->dev,
6083 diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c
6084 index 4432ef7..a213813 100644
6085 --- a/sound/usb/caiaq/input.c
6086 +++ b/sound/usb/caiaq/input.c
6087 @@ -30,7 +30,7 @@ static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A };
6088 static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4,
6089 KEY_5, KEY_6, KEY_7 };
6090 static unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4,
6091 - KEY_5, KEY_6, KEY_7, KEY_5, KEY_6 };
6092 + KEY_5, KEY_6, KEY_7, KEY_8, KEY_9 };
6093
6094 static unsigned short keycode_kore[] = {
6095 KEY_FN_F1, /* "menu" */
6096 diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
6097 index b0ef9f5..05842c8 100644
6098 --- a/sound/usb/endpoint.c
6099 +++ b/sound/usb/endpoint.c
6100 @@ -352,7 +352,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
6101 continue;
6102 }
6103 if (((protocol == UAC_VERSION_1) && (fmt->bLength < 8)) ||
6104 - ((protocol == UAC_VERSION_2) && (fmt->bLength != 6))) {
6105 + ((protocol == UAC_VERSION_2) && (fmt->bLength < 6))) {
6106 snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n",
6107 dev->devnum, iface_no, altno);
6108 continue;
6109 diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
6110 index c22fa76..c04d7c7 100644
6111 --- a/sound/usb/mixer.c
6112 +++ b/sound/usb/mixer.c
6113 @@ -1191,6 +1191,11 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
6114
6115 if (state->mixer->protocol == UAC_VERSION_1) {
6116 csize = hdr->bControlSize;
6117 + if (!csize) {
6118 + snd_printdd(KERN_ERR "usbaudio: unit %u: "
6119 + "invalid bControlSize == 0\n", unitid);
6120 + return -EINVAL;
6121 + }
6122 channels = (hdr->bLength - 7) / csize - 1;
6123 bmaControls = hdr->bmaControls;
6124 } else {
6125 @@ -1934,15 +1939,13 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
6126 struct mixer_build state;
6127 int err;
6128 const struct usbmix_ctl_map *map;
6129 - struct usb_host_interface *hostif;
6130 void *p;
6131
6132 - hostif = mixer->chip->ctrl_intf;
6133 memset(&state, 0, sizeof(state));
6134 state.chip = mixer->chip;
6135 state.mixer = mixer;
6136 - state.buffer = hostif->extra;
6137 - state.buflen = hostif->extralen;
6138 + state.buffer = mixer->hostif->extra;
6139 + state.buflen = mixer->hostif->extralen;
6140
6141 /* check the mapping table */
6142 for (map = usbmix_ctl_maps; map->id; map++) {
6143 @@ -1955,7 +1958,8 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
6144 }
6145
6146 p = NULL;
6147 - while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) {
6148 + while ((p = snd_usb_find_csint_desc(mixer->hostif->extra, mixer->hostif->extralen,
6149 + p, UAC_OUTPUT_TERMINAL)) != NULL) {
6150 if (mixer->protocol == UAC_VERSION_1) {
6151 struct uac1_output_terminal_descriptor *desc = p;
6152
6153 @@ -2162,17 +2166,15 @@ int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
6154 /* create the handler for the optional status interrupt endpoint */
6155 static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
6156 {
6157 - struct usb_host_interface *hostif;
6158 struct usb_endpoint_descriptor *ep;
6159 void *transfer_buffer;
6160 int buffer_length;
6161 unsigned int epnum;
6162
6163 - hostif = mixer->chip->ctrl_intf;
6164 /* we need one interrupt input endpoint */
6165 - if (get_iface_desc(hostif)->bNumEndpoints < 1)
6166 + if (get_iface_desc(mixer->hostif)->bNumEndpoints < 1)
6167 return 0;
6168 - ep = get_endpoint(hostif, 0);
6169 + ep = get_endpoint(mixer->hostif, 0);
6170 if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_int(ep))
6171 return 0;
6172
6173 @@ -2202,7 +2204,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
6174 };
6175 struct usb_mixer_interface *mixer;
6176 struct snd_info_entry *entry;
6177 - struct usb_host_interface *host_iface;
6178 int err;
6179
6180 strcpy(chip->card->mixername, "USB Mixer");
6181 @@ -2219,8 +2220,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
6182 return -ENOMEM;
6183 }
6184
6185 - host_iface = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
6186 - switch (get_iface_desc(host_iface)->bInterfaceProtocol) {
6187 + mixer->hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
6188 + switch (get_iface_desc(mixer->hostif)->bInterfaceProtocol) {
6189 case UAC_VERSION_1:
6190 default:
6191 mixer->protocol = UAC_VERSION_1;
6192 diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
6193 index ae1a14d..81b2d8a 100644
6194 --- a/sound/usb/mixer.h
6195 +++ b/sound/usb/mixer.h
6196 @@ -3,6 +3,7 @@
6197
6198 struct usb_mixer_interface {
6199 struct snd_usb_audio *chip;
6200 + struct usb_host_interface *hostif;
6201 struct list_head list;
6202 unsigned int ignore_ctl_error;
6203 struct urb *urb;

  ViewVC Help
Powered by ViewVC 1.1.20