Magellan Linux

Annotation of /trunk/kernel-alx/patches-3.10/0115-3.10.16-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2343 - (hide annotations) (download)
Mon Dec 16 10:04:29 2013 UTC (10 years, 5 months ago) by niro
File size: 139298 byte(s)
-linux-3.10.16
1 niro 2343 diff --git a/Makefile b/Makefile
2     index 9a77179..e9528d2 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 3
7     PATCHLEVEL = 10
8     -SUBLEVEL = 15
9     +SUBLEVEL = 16
10     EXTRAVERSION =
11     NAME = TOSSUG Baby Fish
12    
13     diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
14     index 869a1c6..12f828a 100644
15     --- a/arch/avr32/kernel/time.c
16     +++ b/arch/avr32/kernel/time.c
17     @@ -98,7 +98,14 @@ static void comparator_mode(enum clock_event_mode mode,
18     case CLOCK_EVT_MODE_SHUTDOWN:
19     sysreg_write(COMPARE, 0);
20     pr_debug("%s: stop\n", evdev->name);
21     - cpu_idle_poll_ctrl(false);
22     + if (evdev->mode == CLOCK_EVT_MODE_ONESHOT ||
23     + evdev->mode == CLOCK_EVT_MODE_RESUME) {
24     + /*
25     + * Only disable idle poll if we have forced that
26     + * in a previous call.
27     + */
28     + cpu_idle_poll_ctrl(false);
29     + }
30     break;
31     default:
32     BUG();
33     diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
34     index c0d0dbd..93d8d96 100644
35     --- a/arch/powerpc/kernel/iommu.c
36     +++ b/arch/powerpc/kernel/iommu.c
37     @@ -658,7 +658,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
38     /* number of bytes needed for the bitmap */
39     sz = BITS_TO_LONGS(tbl->it_size) * sizeof(unsigned long);
40    
41     - page = alloc_pages_node(nid, GFP_ATOMIC, get_order(sz));
42     + page = alloc_pages_node(nid, GFP_KERNEL, get_order(sz));
43     if (!page)
44     panic("iommu_init_table: Can't allocate %ld bytes\n", sz);
45     tbl->it_map = page_address(page);
46     diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
47     index e68a845..a15fd1a 100644
48     --- a/arch/powerpc/kernel/sysfs.c
49     +++ b/arch/powerpc/kernel/sysfs.c
50     @@ -17,6 +17,7 @@
51     #include <asm/machdep.h>
52     #include <asm/smp.h>
53     #include <asm/pmc.h>
54     +#include <asm/firmware.h>
55    
56     #include "cacheinfo.h"
57    
58     @@ -179,15 +180,25 @@ SYSFS_PMCSETUP(spurr, SPRN_SPURR);
59     SYSFS_PMCSETUP(dscr, SPRN_DSCR);
60     SYSFS_PMCSETUP(pir, SPRN_PIR);
61    
62     +/*
63     + Lets only enable read for phyp resources and
64     + enable write when needed with a separate function.
65     + Lets be conservative and default to pseries.
66     +*/
67     static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
68     static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
69     static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr);
70     -static DEVICE_ATTR(purr, 0600, show_purr, store_purr);
71     +static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
72     static DEVICE_ATTR(pir, 0400, show_pir, NULL);
73    
74     unsigned long dscr_default = 0;
75     EXPORT_SYMBOL(dscr_default);
76    
77     +static void add_write_permission_dev_attr(struct device_attribute *attr)
78     +{
79     + attr->attr.mode |= 0200;
80     +}
81     +
82     static ssize_t show_dscr_default(struct device *dev,
83     struct device_attribute *attr, char *buf)
84     {
85     @@ -394,8 +405,11 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
86     if (cpu_has_feature(CPU_FTR_MMCRA))
87     device_create_file(s, &dev_attr_mmcra);
88    
89     - if (cpu_has_feature(CPU_FTR_PURR))
90     + if (cpu_has_feature(CPU_FTR_PURR)) {
91     + if (!firmware_has_feature(FW_FEATURE_LPAR))
92     + add_write_permission_dev_attr(&dev_attr_purr);
93     device_create_file(s, &dev_attr_purr);
94     + }
95    
96     if (cpu_has_feature(CPU_FTR_SPURR))
97     device_create_file(s, &dev_attr_spurr);
98     diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
99     index 1edd6c2..f2abb21 100644
100     --- a/arch/powerpc/kernel/tm.S
101     +++ b/arch/powerpc/kernel/tm.S
102     @@ -79,6 +79,11 @@ _GLOBAL(tm_abort)
103     TABORT(R3)
104     blr
105    
106     + .section ".toc","aw"
107     +DSCR_DEFAULT:
108     + .tc dscr_default[TC],dscr_default
109     +
110     + .section ".text"
111    
112     /* void tm_reclaim(struct thread_struct *thread,
113     * unsigned long orig_msr,
114     @@ -178,11 +183,18 @@ dont_backup_fp:
115     std r1, PACATMSCRATCH(r13)
116     ld r1, PACAR1(r13)
117    
118     + /* Store the PPR in r11 and reset to decent value */
119     + std r11, GPR11(r1) /* Temporary stash */
120     + mfspr r11, SPRN_PPR
121     + HMT_MEDIUM
122     +
123     /* Now get some more GPRS free */
124     std r7, GPR7(r1) /* Temporary stash */
125     std r12, GPR12(r1) /* '' '' '' */
126     ld r12, STACK_PARAM(0)(r1) /* Param 0, thread_struct * */
127    
128     + std r11, THREAD_TM_PPR(r12) /* Store PPR and free r11 */
129     +
130     addi r7, r12, PT_CKPT_REGS /* Thread's ckpt_regs */
131    
132     /* Make r7 look like an exception frame so that we
133     @@ -194,15 +206,19 @@ dont_backup_fp:
134     SAVE_GPR(0, r7) /* user r0 */
135     SAVE_GPR(2, r7) /* user r2 */
136     SAVE_4GPRS(3, r7) /* user r3-r6 */
137     - SAVE_4GPRS(8, r7) /* user r8-r11 */
138     + SAVE_GPR(8, r7) /* user r8 */
139     + SAVE_GPR(9, r7) /* user r9 */
140     + SAVE_GPR(10, r7) /* user r10 */
141     ld r3, PACATMSCRATCH(r13) /* user r1 */
142     ld r4, GPR7(r1) /* user r7 */
143     - ld r5, GPR12(r1) /* user r12 */
144     - GET_SCRATCH0(6) /* user r13 */
145     + ld r5, GPR11(r1) /* user r11 */
146     + ld r6, GPR12(r1) /* user r12 */
147     + GET_SCRATCH0(8) /* user r13 */
148     std r3, GPR1(r7)
149     std r4, GPR7(r7)
150     - std r5, GPR12(r7)
151     - std r6, GPR13(r7)
152     + std r5, GPR11(r7)
153     + std r6, GPR12(r7)
154     + std r8, GPR13(r7)
155    
156     SAVE_NVGPRS(r7) /* user r14-r31 */
157    
158     @@ -225,14 +241,12 @@ dont_backup_fp:
159     std r6, _XER(r7)
160    
161    
162     - /* ******************** TAR, PPR, DSCR ********** */
163     + /* ******************** TAR, DSCR ********** */
164     mfspr r3, SPRN_TAR
165     - mfspr r4, SPRN_PPR
166     - mfspr r5, SPRN_DSCR
167     + mfspr r4, SPRN_DSCR
168    
169     std r3, THREAD_TM_TAR(r12)
170     - std r4, THREAD_TM_PPR(r12)
171     - std r5, THREAD_TM_DSCR(r12)
172     + std r4, THREAD_TM_DSCR(r12)
173    
174     /* MSR and flags: We don't change CRs, and we don't need to alter
175     * MSR.
176     @@ -249,7 +263,7 @@ dont_backup_fp:
177     std r3, THREAD_TM_TFHAR(r12)
178     std r4, THREAD_TM_TFIAR(r12)
179    
180     - /* AMR and PPR are checkpointed too, but are unsupported by Linux. */
181     + /* AMR is checkpointed too, but is unsupported by Linux. */
182    
183     /* Restore original MSR/IRQ state & clear TM mode */
184     ld r14, TM_FRAME_L0(r1) /* Orig MSR */
185     @@ -265,6 +279,12 @@ dont_backup_fp:
186     mtcr r4
187     mtlr r0
188     ld r2, 40(r1)
189     +
190     + /* Load system default DSCR */
191     + ld r4, DSCR_DEFAULT@toc(r2)
192     + ld r0, 0(r4)
193     + mtspr SPRN_DSCR, r0
194     +
195     blr
196    
197    
198     @@ -349,44 +369,50 @@ dont_restore_fp:
199    
200     restore_gprs:
201    
202     - /* ******************** TAR, PPR, DSCR ********** */
203     - ld r4, THREAD_TM_TAR(r3)
204     - ld r5, THREAD_TM_PPR(r3)
205     - ld r6, THREAD_TM_DSCR(r3)
206     + /* ******************** CR,LR,CCR,MSR ********** */
207     + ld r4, _CTR(r7)
208     + ld r5, _LINK(r7)
209     + ld r6, _CCR(r7)
210     + ld r8, _XER(r7)
211    
212     - mtspr SPRN_TAR, r4
213     - mtspr SPRN_PPR, r5
214     - mtspr SPRN_DSCR, r6
215     + mtctr r4
216     + mtlr r5
217     + mtcr r6
218     + mtxer r8
219    
220     - /* ******************** CR,LR,CCR,MSR ********** */
221     - ld r3, _CTR(r7)
222     - ld r4, _LINK(r7)
223     - ld r5, _CCR(r7)
224     - ld r6, _XER(r7)
225     + /* ******************** TAR ******************** */
226     + ld r4, THREAD_TM_TAR(r3)
227     + mtspr SPRN_TAR, r4
228    
229     - mtctr r3
230     - mtlr r4
231     - mtcr r5
232     - mtxer r6
233     + /* Load up the PPR and DSCR in GPRs only at this stage */
234     + ld r5, THREAD_TM_DSCR(r3)
235     + ld r6, THREAD_TM_PPR(r3)
236    
237     /* MSR and flags: We don't change CRs, and we don't need to alter
238     * MSR.
239     */
240    
241     REST_4GPRS(0, r7) /* GPR0-3 */
242     - REST_GPR(4, r7) /* GPR4-6 */
243     - REST_GPR(5, r7)
244     - REST_GPR(6, r7)
245     + REST_GPR(4, r7) /* GPR4 */
246     REST_4GPRS(8, r7) /* GPR8-11 */
247     REST_2GPRS(12, r7) /* GPR12-13 */
248    
249     REST_NVGPRS(r7) /* GPR14-31 */
250    
251     - ld r7, GPR7(r7) /* GPR7 */
252     + /* Load up PPR and DSCR here so we don't run with user values for long
253     + */
254     + mtspr SPRN_DSCR, r5
255     + mtspr SPRN_PPR, r6
256     +
257     + REST_GPR(5, r7) /* GPR5-7 */
258     + REST_GPR(6, r7)
259     + ld r7, GPR7(r7)
260    
261     /* Commit register state as checkpointed state: */
262     TRECHKPT
263    
264     + HMT_MEDIUM
265     +
266     /* Our transactional state has now changed.
267     *
268     * Now just get out of here. Transactional (current) state will be
269     @@ -405,6 +431,12 @@ restore_gprs:
270     mtcr r4
271     mtlr r0
272     ld r2, 40(r1)
273     +
274     + /* Load system default DSCR */
275     + ld r4, DSCR_DEFAULT@toc(r2)
276     + ld r0, 0(r4)
277     + mtspr SPRN_DSCR, r0
278     +
279     blr
280    
281     /* ****************************************************************** */
282     diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
283     index 536016d..2d845d8 100644
284     --- a/arch/powerpc/kernel/vio.c
285     +++ b/arch/powerpc/kernel/vio.c
286     @@ -1529,11 +1529,15 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
287     const char *cp;
288    
289     dn = dev->of_node;
290     - if (!dn)
291     - return -ENODEV;
292     + if (!dn) {
293     + strcat(buf, "\n");
294     + return strlen(buf);
295     + }
296     cp = of_get_property(dn, "compatible", NULL);
297     - if (!cp)
298     - return -ENODEV;
299     + if (!cp) {
300     + strcat(buf, "\n");
301     + return strlen(buf);
302     + }
303    
304     return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
305     }
306     diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
307     index 167f725..57a0720 100644
308     --- a/arch/powerpc/lib/checksum_64.S
309     +++ b/arch/powerpc/lib/checksum_64.S
310     @@ -226,19 +226,35 @@ _GLOBAL(csum_partial)
311     blr
312    
313    
314     - .macro source
315     + .macro srcnr
316     100:
317     .section __ex_table,"a"
318     .align 3
319     - .llong 100b,.Lsrc_error
320     + .llong 100b,.Lsrc_error_nr
321     .previous
322     .endm
323    
324     - .macro dest
325     + .macro source
326     +150:
327     + .section __ex_table,"a"
328     + .align 3
329     + .llong 150b,.Lsrc_error
330     + .previous
331     + .endm
332     +
333     + .macro dstnr
334     200:
335     .section __ex_table,"a"
336     .align 3
337     - .llong 200b,.Ldest_error
338     + .llong 200b,.Ldest_error_nr
339     + .previous
340     + .endm
341     +
342     + .macro dest
343     +250:
344     + .section __ex_table,"a"
345     + .align 3
346     + .llong 250b,.Ldest_error
347     .previous
348     .endm
349    
350     @@ -269,16 +285,16 @@ _GLOBAL(csum_partial_copy_generic)
351     rldicl. r6,r3,64-1,64-2 /* r6 = (r3 & 0x3) >> 1 */
352     beq .Lcopy_aligned
353    
354     - li r7,4
355     - sub r6,r7,r6
356     + li r9,4
357     + sub r6,r9,r6
358     mtctr r6
359    
360     1:
361     -source; lhz r6,0(r3) /* align to doubleword */
362     +srcnr; lhz r6,0(r3) /* align to doubleword */
363     subi r5,r5,2
364     addi r3,r3,2
365     adde r0,r0,r6
366     -dest; sth r6,0(r4)
367     +dstnr; sth r6,0(r4)
368     addi r4,r4,2
369     bdnz 1b
370    
371     @@ -392,10 +408,10 @@ dest; std r16,56(r4)
372    
373     mtctr r6
374     3:
375     -source; ld r6,0(r3)
376     +srcnr; ld r6,0(r3)
377     addi r3,r3,8
378     adde r0,r0,r6
379     -dest; std r6,0(r4)
380     +dstnr; std r6,0(r4)
381     addi r4,r4,8
382     bdnz 3b
383    
384     @@ -405,10 +421,10 @@ dest; std r6,0(r4)
385     srdi. r6,r5,2
386     beq .Lcopy_tail_halfword
387    
388     -source; lwz r6,0(r3)
389     +srcnr; lwz r6,0(r3)
390     addi r3,r3,4
391     adde r0,r0,r6
392     -dest; stw r6,0(r4)
393     +dstnr; stw r6,0(r4)
394     addi r4,r4,4
395     subi r5,r5,4
396    
397     @@ -416,10 +432,10 @@ dest; stw r6,0(r4)
398     srdi. r6,r5,1
399     beq .Lcopy_tail_byte
400    
401     -source; lhz r6,0(r3)
402     +srcnr; lhz r6,0(r3)
403     addi r3,r3,2
404     adde r0,r0,r6
405     -dest; sth r6,0(r4)
406     +dstnr; sth r6,0(r4)
407     addi r4,r4,2
408     subi r5,r5,2
409    
410     @@ -427,10 +443,10 @@ dest; sth r6,0(r4)
411     andi. r6,r5,1
412     beq .Lcopy_finish
413    
414     -source; lbz r6,0(r3)
415     +srcnr; lbz r6,0(r3)
416     sldi r9,r6,8 /* Pad the byte out to 16 bits */
417     adde r0,r0,r9
418     -dest; stb r6,0(r4)
419     +dstnr; stb r6,0(r4)
420    
421     .Lcopy_finish:
422     addze r0,r0 /* add in final carry */
423     @@ -440,6 +456,11 @@ dest; stb r6,0(r4)
424     blr
425    
426     .Lsrc_error:
427     + ld r14,STK_REG(R14)(r1)
428     + ld r15,STK_REG(R15)(r1)
429     + ld r16,STK_REG(R16)(r1)
430     + addi r1,r1,STACKFRAMESIZE
431     +.Lsrc_error_nr:
432     cmpdi 0,r7,0
433     beqlr
434     li r6,-EFAULT
435     @@ -447,6 +468,11 @@ dest; stb r6,0(r4)
436     blr
437    
438     .Ldest_error:
439     + ld r14,STK_REG(R14)(r1)
440     + ld r15,STK_REG(R15)(r1)
441     + ld r16,STK_REG(R16)(r1)
442     + addi r1,r1,STACKFRAMESIZE
443     +.Ldest_error_nr:
444     cmpdi 0,r8,0
445     beqlr
446     li r6,-EFAULT
447     diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
448     index d59f5b2..9aefaeb 100644
449     --- a/arch/powerpc/perf/power8-pmu.c
450     +++ b/arch/powerpc/perf/power8-pmu.c
451     @@ -194,6 +194,7 @@
452     #define MMCR1_UNIT_SHIFT(pmc) (60 - (4 * ((pmc) - 1)))
453     #define MMCR1_COMBINE_SHIFT(pmc) (35 - ((pmc) - 1))
454     #define MMCR1_PMCSEL_SHIFT(pmc) (24 - (((pmc) - 1)) * 8)
455     +#define MMCR1_FAB_SHIFT 36
456     #define MMCR1_DC_QUAL_SHIFT 47
457     #define MMCR1_IC_QUAL_SHIFT 46
458    
459     @@ -367,8 +368,8 @@ static int power8_compute_mmcr(u64 event[], int n_ev,
460     * the threshold bits are used for the match value.
461     */
462     if (event_is_fab_match(event[i])) {
463     - mmcr1 |= (event[i] >> EVENT_THR_CTL_SHIFT) &
464     - EVENT_THR_CTL_MASK;
465     + mmcr1 |= ((event[i] >> EVENT_THR_CTL_SHIFT) &
466     + EVENT_THR_CTL_MASK) << MMCR1_FAB_SHIFT;
467     } else {
468     val = (event[i] >> EVENT_THR_CTL_SHIFT) & EVENT_THR_CTL_MASK;
469     mmcra |= val << MMCRA_THR_CTL_SHIFT;
470     diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
471     index 4d5e6f8..32bb7bf 100644
472     --- a/arch/s390/kernel/entry.S
473     +++ b/arch/s390/kernel/entry.S
474     @@ -265,6 +265,7 @@ sysc_sigpending:
475     tm __TI_flags+3(%r12),_TIF_SYSCALL
476     jno sysc_return
477     lm %r2,%r7,__PT_R2(%r11) # load svc arguments
478     + l %r10,__TI_sysc_table(%r12) # 31 bit system call table
479     xr %r8,%r8 # svc 0 returns -ENOSYS
480     clc __PT_INT_CODE+2(2,%r11),BASED(.Lnr_syscalls+2)
481     jnl sysc_nr_ok # invalid svc number -> do svc 0
482     diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
483     index 4c17eec..2e3befd 100644
484     --- a/arch/s390/kernel/entry64.S
485     +++ b/arch/s390/kernel/entry64.S
486     @@ -293,6 +293,7 @@ sysc_sigpending:
487     tm __TI_flags+7(%r12),_TIF_SYSCALL
488     jno sysc_return
489     lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
490     + lg %r10,__TI_sysc_table(%r12) # address of system call table
491     lghi %r8,0 # svc 0 returns -ENOSYS
492     llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
493     cghi %r1,NR_syscalls
494     diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
495     index 5ef48da..252f876 100644
496     --- a/arch/sparc/kernel/ds.c
497     +++ b/arch/sparc/kernel/ds.c
498     @@ -842,9 +842,8 @@ void ldom_reboot(const char *boot_command)
499     if (boot_command && strlen(boot_command)) {
500     unsigned long len;
501    
502     - strcpy(full_boot_str, "boot ");
503     - strlcpy(full_boot_str + strlen("boot "), boot_command,
504     - sizeof(full_boot_str + strlen("boot ")));
505     + snprintf(full_boot_str, sizeof(full_boot_str), "boot %s",
506     + boot_command);
507     len = strlen(full_boot_str);
508    
509     if (reboot_data_supported) {
510     diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
511     index e2a0300..33c02b1 100644
512     --- a/arch/sparc/kernel/entry.S
513     +++ b/arch/sparc/kernel/entry.S
514     @@ -839,7 +839,7 @@ sys_sigreturn:
515     nop
516    
517     call syscall_trace
518     - nop
519     + mov 1, %o1
520    
521     1:
522     /* We don't want to muck with user registers like a
523     diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
524     index 0746e5e..fde5a41 100644
525     --- a/arch/sparc/kernel/ktlb.S
526     +++ b/arch/sparc/kernel/ktlb.S
527     @@ -25,11 +25,10 @@ kvmap_itlb:
528     */
529     kvmap_itlb_4v:
530    
531     -kvmap_itlb_nonlinear:
532     /* Catch kernel NULL pointer calls. */
533     sethi %hi(PAGE_SIZE), %g5
534     cmp %g4, %g5
535     - bleu,pn %xcc, kvmap_dtlb_longpath
536     + blu,pn %xcc, kvmap_itlb_longpath
537     nop
538    
539     KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_itlb_load)
540     diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
541     index 22a1098..73ec8a7 100644
542     --- a/arch/sparc/kernel/syscalls.S
543     +++ b/arch/sparc/kernel/syscalls.S
544     @@ -152,7 +152,7 @@ linux_syscall_trace32:
545     srl %i4, 0, %o4
546     srl %i1, 0, %o1
547     srl %i2, 0, %o2
548     - ba,pt %xcc, 2f
549     + ba,pt %xcc, 5f
550     srl %i3, 0, %o3
551    
552     linux_syscall_trace:
553     @@ -182,13 +182,13 @@ linux_sparc_syscall32:
554     srl %i1, 0, %o1 ! IEU0 Group
555     ldx [%g6 + TI_FLAGS], %l0 ! Load
556    
557     - srl %i5, 0, %o5 ! IEU1
558     + srl %i3, 0, %o3 ! IEU0
559     srl %i2, 0, %o2 ! IEU0 Group
560     andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
561     bne,pn %icc, linux_syscall_trace32 ! CTI
562     mov %i0, %l5 ! IEU1
563     - call %l7 ! CTI Group brk forced
564     - srl %i3, 0, %o3 ! IEU0
565     +5: call %l7 ! CTI Group brk forced
566     + srl %i5, 0, %o5 ! IEU1
567     ba,a,pt %xcc, 3f
568    
569     /* Linux native system calls enter here... */
570     diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
571     index 2e973a2..3a43edb 100644
572     --- a/arch/sparc/kernel/trampoline_64.S
573     +++ b/arch/sparc/kernel/trampoline_64.S
574     @@ -131,7 +131,6 @@ startup_continue:
575     clr %l5
576     sethi %hi(num_kernel_image_mappings), %l6
577     lduw [%l6 + %lo(num_kernel_image_mappings)], %l6
578     - add %l6, 1, %l6
579    
580     mov 15, %l7
581     BRANCH_IF_ANY_CHEETAH(g1,g5,2f)
582     @@ -224,7 +223,6 @@ niagara_lock_tlb:
583     clr %l5
584     sethi %hi(num_kernel_image_mappings), %l6
585     lduw [%l6 + %lo(num_kernel_image_mappings)], %l6
586     - add %l6, 1, %l6
587    
588     1:
589     mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
590     diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
591     index 0c4e35e..323335b 100644
592     --- a/arch/sparc/lib/ksyms.c
593     +++ b/arch/sparc/lib/ksyms.c
594     @@ -98,15 +98,6 @@ EXPORT_SYMBOL(___copy_from_user);
595     EXPORT_SYMBOL(___copy_in_user);
596     EXPORT_SYMBOL(__clear_user);
597    
598     -/* RW semaphores */
599     -EXPORT_SYMBOL(__down_read);
600     -EXPORT_SYMBOL(__down_read_trylock);
601     -EXPORT_SYMBOL(__down_write);
602     -EXPORT_SYMBOL(__down_write_trylock);
603     -EXPORT_SYMBOL(__up_read);
604     -EXPORT_SYMBOL(__up_write);
605     -EXPORT_SYMBOL(__downgrade_write);
606     -
607     /* Atomic counter implementation. */
608     EXPORT_SYMBOL(atomic_add);
609     EXPORT_SYMBOL(atomic_add_ret);
610     diff --git a/arch/tile/include/asm/percpu.h b/arch/tile/include/asm/percpu.h
611     index 63294f5..4f7ae39 100644
612     --- a/arch/tile/include/asm/percpu.h
613     +++ b/arch/tile/include/asm/percpu.h
614     @@ -15,9 +15,37 @@
615     #ifndef _ASM_TILE_PERCPU_H
616     #define _ASM_TILE_PERCPU_H
617    
618     -register unsigned long __my_cpu_offset __asm__("tp");
619     -#define __my_cpu_offset __my_cpu_offset
620     -#define set_my_cpu_offset(tp) (__my_cpu_offset = (tp))
621     +register unsigned long my_cpu_offset_reg asm("tp");
622     +
623     +#ifdef CONFIG_PREEMPT
624     +/*
625     + * For full preemption, we can't just use the register variable
626     + * directly, since we need barrier() to hazard against it, causing the
627     + * compiler to reload anything computed from a previous "tp" value.
628     + * But we also don't want to use volatile asm, since we'd like the
629     + * compiler to be able to cache the value across multiple percpu reads.
630     + * So we use a fake stack read as a hazard against barrier().
631     + * The 'U' constraint is like 'm' but disallows postincrement.
632     + */
633     +static inline unsigned long __my_cpu_offset(void)
634     +{
635     + unsigned long tp;
636     + register unsigned long *sp asm("sp");
637     + asm("move %0, tp" : "=r" (tp) : "U" (*sp));
638     + return tp;
639     +}
640     +#define __my_cpu_offset __my_cpu_offset()
641     +#else
642     +/*
643     + * We don't need to hazard against barrier() since "tp" doesn't ever
644     + * change with PREEMPT_NONE, and with PREEMPT_VOLUNTARY it only
645     + * changes at function call points, at which we are already re-reading
646     + * the value of "tp" due to "my_cpu_offset_reg" being a global variable.
647     + */
648     +#define __my_cpu_offset my_cpu_offset_reg
649     +#endif
650     +
651     +#define set_my_cpu_offset(tp) (my_cpu_offset_reg = (tp))
652    
653     #include <asm-generic/percpu.h>
654    
655     diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
656     index f40acef..a6977e1 100644
657     --- a/drivers/acpi/acpi_ipmi.c
658     +++ b/drivers/acpi/acpi_ipmi.c
659     @@ -39,6 +39,7 @@
660     #include <linux/ipmi.h>
661     #include <linux/device.h>
662     #include <linux/pnp.h>
663     +#include <linux/spinlock.h>
664    
665     MODULE_AUTHOR("Zhao Yakui");
666     MODULE_DESCRIPTION("ACPI IPMI Opregion driver");
667     @@ -57,7 +58,7 @@ struct acpi_ipmi_device {
668     struct list_head head;
669     /* the IPMI request message list */
670     struct list_head tx_msg_list;
671     - struct mutex tx_msg_lock;
672     + spinlock_t tx_msg_lock;
673     acpi_handle handle;
674     struct pnp_dev *pnp_dev;
675     ipmi_user_t user_interface;
676     @@ -147,6 +148,7 @@ static void acpi_format_ipmi_msg(struct acpi_ipmi_msg *tx_msg,
677     struct kernel_ipmi_msg *msg;
678     struct acpi_ipmi_buffer *buffer;
679     struct acpi_ipmi_device *device;
680     + unsigned long flags;
681    
682     msg = &tx_msg->tx_message;
683     /*
684     @@ -177,10 +179,10 @@ static void acpi_format_ipmi_msg(struct acpi_ipmi_msg *tx_msg,
685    
686     /* Get the msgid */
687     device = tx_msg->device;
688     - mutex_lock(&device->tx_msg_lock);
689     + spin_lock_irqsave(&device->tx_msg_lock, flags);
690     device->curr_msgid++;
691     tx_msg->tx_msgid = device->curr_msgid;
692     - mutex_unlock(&device->tx_msg_lock);
693     + spin_unlock_irqrestore(&device->tx_msg_lock, flags);
694     }
695    
696     static void acpi_format_ipmi_response(struct acpi_ipmi_msg *msg,
697     @@ -242,6 +244,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
698     int msg_found = 0;
699     struct acpi_ipmi_msg *tx_msg;
700     struct pnp_dev *pnp_dev = ipmi_device->pnp_dev;
701     + unsigned long flags;
702    
703     if (msg->user != ipmi_device->user_interface) {
704     dev_warn(&pnp_dev->dev, "Unexpected response is returned. "
705     @@ -250,7 +253,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
706     ipmi_free_recv_msg(msg);
707     return;
708     }
709     - mutex_lock(&ipmi_device->tx_msg_lock);
710     + spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
711     list_for_each_entry(tx_msg, &ipmi_device->tx_msg_list, head) {
712     if (msg->msgid == tx_msg->tx_msgid) {
713     msg_found = 1;
714     @@ -258,7 +261,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
715     }
716     }
717    
718     - mutex_unlock(&ipmi_device->tx_msg_lock);
719     + spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
720     if (!msg_found) {
721     dev_warn(&pnp_dev->dev, "Unexpected response (msg id %ld) is "
722     "returned.\n", msg->msgid);
723     @@ -378,6 +381,7 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
724     struct acpi_ipmi_device *ipmi_device = handler_context;
725     int err, rem_time;
726     acpi_status status;
727     + unsigned long flags;
728     /*
729     * IPMI opregion message.
730     * IPMI message is firstly written to the BMC and system software
731     @@ -395,9 +399,9 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
732     return AE_NO_MEMORY;
733    
734     acpi_format_ipmi_msg(tx_msg, address, value);
735     - mutex_lock(&ipmi_device->tx_msg_lock);
736     + spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
737     list_add_tail(&tx_msg->head, &ipmi_device->tx_msg_list);
738     - mutex_unlock(&ipmi_device->tx_msg_lock);
739     + spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
740     err = ipmi_request_settime(ipmi_device->user_interface,
741     &tx_msg->addr,
742     tx_msg->tx_msgid,
743     @@ -413,9 +417,9 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
744     status = AE_OK;
745    
746     end_label:
747     - mutex_lock(&ipmi_device->tx_msg_lock);
748     + spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
749     list_del(&tx_msg->head);
750     - mutex_unlock(&ipmi_device->tx_msg_lock);
751     + spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
752     kfree(tx_msg);
753     return status;
754     }
755     @@ -457,7 +461,7 @@ static void acpi_add_ipmi_device(struct acpi_ipmi_device *ipmi_device)
756    
757     INIT_LIST_HEAD(&ipmi_device->head);
758    
759     - mutex_init(&ipmi_device->tx_msg_lock);
760     + spin_lock_init(&ipmi_device->tx_msg_lock);
761     INIT_LIST_HEAD(&ipmi_device->tx_msg_list);
762     ipmi_install_space_handler(ipmi_device);
763    
764     diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
765     index 62b6c2c..90a4e6b 100644
766     --- a/drivers/block/cciss.c
767     +++ b/drivers/block/cciss.c
768     @@ -1189,6 +1189,7 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
769     int err;
770     u32 cp;
771    
772     + memset(&arg64, 0, sizeof(arg64));
773     err = 0;
774     err |=
775     copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
776     diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
777     index 639d26b..2b94403 100644
778     --- a/drivers/block/cpqarray.c
779     +++ b/drivers/block/cpqarray.c
780     @@ -1193,6 +1193,7 @@ out_passthru:
781     ida_pci_info_struct pciinfo;
782    
783     if (!arg) return -EINVAL;
784     + memset(&pciinfo, 0, sizeof(pciinfo));
785     pciinfo.bus = host->pci_dev->bus->number;
786     pciinfo.dev_fn = host->pci_dev->devfn;
787     pciinfo.board_id = host->board_id;
788     diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
789     index a12b923..0a327f4 100644
790     --- a/drivers/bluetooth/ath3k.c
791     +++ b/drivers/bluetooth/ath3k.c
792     @@ -85,6 +85,7 @@ static struct usb_device_id ath3k_table[] = {
793     { USB_DEVICE(0x04CA, 0x3008) },
794     { USB_DEVICE(0x13d3, 0x3362) },
795     { USB_DEVICE(0x0CF3, 0xE004) },
796     + { USB_DEVICE(0x0CF3, 0xE005) },
797     { USB_DEVICE(0x0930, 0x0219) },
798     { USB_DEVICE(0x0489, 0xe057) },
799     { USB_DEVICE(0x13d3, 0x3393) },
800     @@ -126,6 +127,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
801     { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
802     { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
803     { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
804     + { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
805     { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
806     { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
807     { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
808     diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
809     index d0b3d90..58491f1 100644
810     --- a/drivers/bluetooth/btusb.c
811     +++ b/drivers/bluetooth/btusb.c
812     @@ -102,6 +102,7 @@ static struct usb_device_id btusb_table[] = {
813    
814     /* Broadcom BCM20702A0 */
815     { USB_DEVICE(0x0b05, 0x17b5) },
816     + { USB_DEVICE(0x0b05, 0x17cb) },
817     { USB_DEVICE(0x04ca, 0x2003) },
818     { USB_DEVICE(0x0489, 0xe042) },
819     { USB_DEVICE(0x413c, 0x8197) },
820     @@ -148,6 +149,7 @@ static struct usb_device_id blacklist_table[] = {
821     { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
822     { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
823     { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
824     + { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
825     { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
826     { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
827     { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
828     diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
829     index f285833..617d170 100644
830     --- a/drivers/dma/imx-dma.c
831     +++ b/drivers/dma/imx-dma.c
832     @@ -414,17 +414,18 @@ static void dma_irq_handle_channel(struct imxdma_channel *imxdmac)
833     struct imxdma_engine *imxdma = imxdmac->imxdma;
834     int chno = imxdmac->channel;
835     struct imxdma_desc *desc;
836     + unsigned long flags;
837    
838     - spin_lock(&imxdma->lock);
839     + spin_lock_irqsave(&imxdma->lock, flags);
840     if (list_empty(&imxdmac->ld_active)) {
841     - spin_unlock(&imxdma->lock);
842     + spin_unlock_irqrestore(&imxdma->lock, flags);
843     goto out;
844     }
845    
846     desc = list_first_entry(&imxdmac->ld_active,
847     struct imxdma_desc,
848     node);
849     - spin_unlock(&imxdma->lock);
850     + spin_unlock_irqrestore(&imxdma->lock, flags);
851    
852     if (desc->sg) {
853     u32 tmp;
854     @@ -496,7 +497,6 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
855     {
856     struct imxdma_channel *imxdmac = to_imxdma_chan(d->desc.chan);
857     struct imxdma_engine *imxdma = imxdmac->imxdma;
858     - unsigned long flags;
859     int slot = -1;
860     int i;
861    
862     @@ -504,7 +504,6 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
863     switch (d->type) {
864     case IMXDMA_DESC_INTERLEAVED:
865     /* Try to get a free 2D slot */
866     - spin_lock_irqsave(&imxdma->lock, flags);
867     for (i = 0; i < IMX_DMA_2D_SLOTS; i++) {
868     if ((imxdma->slots_2d[i].count > 0) &&
869     ((imxdma->slots_2d[i].xsr != d->x) ||
870     @@ -514,10 +513,8 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
871     slot = i;
872     break;
873     }
874     - if (slot < 0) {
875     - spin_unlock_irqrestore(&imxdma->lock, flags);
876     + if (slot < 0)
877     return -EBUSY;
878     - }
879    
880     imxdma->slots_2d[slot].xsr = d->x;
881     imxdma->slots_2d[slot].ysr = d->y;
882     @@ -526,7 +523,6 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
883    
884     imxdmac->slot_2d = slot;
885     imxdmac->enabled_2d = true;
886     - spin_unlock_irqrestore(&imxdma->lock, flags);
887    
888     if (slot == IMX_DMA_2D_SLOT_A) {
889     d->config_mem &= ~CCR_MSEL_B;
890     @@ -602,18 +598,17 @@ static void imxdma_tasklet(unsigned long data)
891     struct imxdma_channel *imxdmac = (void *)data;
892     struct imxdma_engine *imxdma = imxdmac->imxdma;
893     struct imxdma_desc *desc;
894     + unsigned long flags;
895    
896     - spin_lock(&imxdma->lock);
897     + spin_lock_irqsave(&imxdma->lock, flags);
898    
899     if (list_empty(&imxdmac->ld_active)) {
900     /* Someone might have called terminate all */
901     - goto out;
902     + spin_unlock_irqrestore(&imxdma->lock, flags);
903     + return;
904     }
905     desc = list_first_entry(&imxdmac->ld_active, struct imxdma_desc, node);
906    
907     - if (desc->desc.callback)
908     - desc->desc.callback(desc->desc.callback_param);
909     -
910     /* If we are dealing with a cyclic descriptor, keep it on ld_active
911     * and dont mark the descriptor as complete.
912     * Only in non-cyclic cases it would be marked as complete
913     @@ -640,7 +635,11 @@ static void imxdma_tasklet(unsigned long data)
914     __func__, imxdmac->channel);
915     }
916     out:
917     - spin_unlock(&imxdma->lock);
918     + spin_unlock_irqrestore(&imxdma->lock, flags);
919     +
920     + if (desc->desc.callback)
921     + desc->desc.callback(desc->desc.callback_param);
922     +
923     }
924    
925     static int imxdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
926     @@ -862,7 +861,7 @@ static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic(
927     kfree(imxdmac->sg_list);
928    
929     imxdmac->sg_list = kcalloc(periods + 1,
930     - sizeof(struct scatterlist), GFP_KERNEL);
931     + sizeof(struct scatterlist), GFP_ATOMIC);
932     if (!imxdmac->sg_list)
933     return NULL;
934    
935     diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
936     index 4a43036..5405212 100644
937     --- a/drivers/gpio/gpio-omap.c
938     +++ b/drivers/gpio/gpio-omap.c
939     @@ -63,6 +63,7 @@ struct gpio_bank {
940     struct gpio_chip chip;
941     struct clk *dbck;
942     u32 mod_usage;
943     + u32 irq_usage;
944     u32 dbck_enable_mask;
945     bool dbck_enabled;
946     struct device *dev;
947     @@ -86,6 +87,9 @@ struct gpio_bank {
948     #define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
949     #define GPIO_MOD_CTRL_BIT BIT(0)
950    
951     +#define BANK_USED(bank) (bank->mod_usage || bank->irq_usage)
952     +#define LINE_USED(line, offset) (line & (1 << offset))
953     +
954     static int irq_to_gpio(struct gpio_bank *bank, unsigned int gpio_irq)
955     {
956     return bank->chip.base + gpio_irq;
957     @@ -420,15 +424,69 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
958     return 0;
959     }
960    
961     +static void _enable_gpio_module(struct gpio_bank *bank, unsigned offset)
962     +{
963     + if (bank->regs->pinctrl) {
964     + void __iomem *reg = bank->base + bank->regs->pinctrl;
965     +
966     + /* Claim the pin for MPU */
967     + __raw_writel(__raw_readl(reg) | (1 << offset), reg);
968     + }
969     +
970     + if (bank->regs->ctrl && !BANK_USED(bank)) {
971     + void __iomem *reg = bank->base + bank->regs->ctrl;
972     + u32 ctrl;
973     +
974     + ctrl = __raw_readl(reg);
975     + /* Module is enabled, clocks are not gated */
976     + ctrl &= ~GPIO_MOD_CTRL_BIT;
977     + __raw_writel(ctrl, reg);
978     + bank->context.ctrl = ctrl;
979     + }
980     +}
981     +
982     +static void _disable_gpio_module(struct gpio_bank *bank, unsigned offset)
983     +{
984     + void __iomem *base = bank->base;
985     +
986     + if (bank->regs->wkup_en &&
987     + !LINE_USED(bank->mod_usage, offset) &&
988     + !LINE_USED(bank->irq_usage, offset)) {
989     + /* Disable wake-up during idle for dynamic tick */
990     + _gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
991     + bank->context.wake_en =
992     + __raw_readl(bank->base + bank->regs->wkup_en);
993     + }
994     +
995     + if (bank->regs->ctrl && !BANK_USED(bank)) {
996     + void __iomem *reg = bank->base + bank->regs->ctrl;
997     + u32 ctrl;
998     +
999     + ctrl = __raw_readl(reg);
1000     + /* Module is disabled, clocks are gated */
1001     + ctrl |= GPIO_MOD_CTRL_BIT;
1002     + __raw_writel(ctrl, reg);
1003     + bank->context.ctrl = ctrl;
1004     + }
1005     +}
1006     +
1007     +static int gpio_is_input(struct gpio_bank *bank, int mask)
1008     +{
1009     + void __iomem *reg = bank->base + bank->regs->direction;
1010     +
1011     + return __raw_readl(reg) & mask;
1012     +}
1013     +
1014     static int gpio_irq_type(struct irq_data *d, unsigned type)
1015     {
1016     struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
1017     unsigned gpio = 0;
1018     int retval;
1019     unsigned long flags;
1020     + unsigned offset;
1021    
1022     - if (WARN_ON(!bank->mod_usage))
1023     - return -EINVAL;
1024     + if (!BANK_USED(bank))
1025     + pm_runtime_get_sync(bank->dev);
1026    
1027     #ifdef CONFIG_ARCH_OMAP1
1028     if (d->irq > IH_MPUIO_BASE)
1029     @@ -446,7 +504,17 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
1030     return -EINVAL;
1031    
1032     spin_lock_irqsave(&bank->lock, flags);
1033     - retval = _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), type);
1034     + offset = GPIO_INDEX(bank, gpio);
1035     + retval = _set_gpio_triggering(bank, offset, type);
1036     + if (!LINE_USED(bank->mod_usage, offset)) {
1037     + _enable_gpio_module(bank, offset);
1038     + _set_gpio_direction(bank, offset, 1);
1039     + } else if (!gpio_is_input(bank, 1 << offset)) {
1040     + spin_unlock_irqrestore(&bank->lock, flags);
1041     + return -EINVAL;
1042     + }
1043     +
1044     + bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio);
1045     spin_unlock_irqrestore(&bank->lock, flags);
1046    
1047     if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
1048     @@ -603,35 +671,19 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
1049     * If this is the first gpio_request for the bank,
1050     * enable the bank module.
1051     */
1052     - if (!bank->mod_usage)
1053     + if (!BANK_USED(bank))
1054     pm_runtime_get_sync(bank->dev);
1055    
1056     spin_lock_irqsave(&bank->lock, flags);
1057     /* Set trigger to none. You need to enable the desired trigger with
1058     - * request_irq() or set_irq_type().
1059     + * request_irq() or set_irq_type(). Only do this if the IRQ line has
1060     + * not already been requested.
1061     */
1062     - _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
1063     -
1064     - if (bank->regs->pinctrl) {
1065     - void __iomem *reg = bank->base + bank->regs->pinctrl;
1066     -
1067     - /* Claim the pin for MPU */
1068     - __raw_writel(__raw_readl(reg) | (1 << offset), reg);
1069     - }
1070     -
1071     - if (bank->regs->ctrl && !bank->mod_usage) {
1072     - void __iomem *reg = bank->base + bank->regs->ctrl;
1073     - u32 ctrl;
1074     -
1075     - ctrl = __raw_readl(reg);
1076     - /* Module is enabled, clocks are not gated */
1077     - ctrl &= ~GPIO_MOD_CTRL_BIT;
1078     - __raw_writel(ctrl, reg);
1079     - bank->context.ctrl = ctrl;
1080     + if (!LINE_USED(bank->irq_usage, offset)) {
1081     + _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
1082     + _enable_gpio_module(bank, offset);
1083     }
1084     -
1085     bank->mod_usage |= 1 << offset;
1086     -
1087     spin_unlock_irqrestore(&bank->lock, flags);
1088    
1089     return 0;
1090     @@ -640,31 +692,11 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
1091     static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
1092     {
1093     struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
1094     - void __iomem *base = bank->base;
1095     unsigned long flags;
1096    
1097     spin_lock_irqsave(&bank->lock, flags);
1098     -
1099     - if (bank->regs->wkup_en) {
1100     - /* Disable wake-up during idle for dynamic tick */
1101     - _gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
1102     - bank->context.wake_en =
1103     - __raw_readl(bank->base + bank->regs->wkup_en);
1104     - }
1105     -
1106     bank->mod_usage &= ~(1 << offset);
1107     -
1108     - if (bank->regs->ctrl && !bank->mod_usage) {
1109     - void __iomem *reg = bank->base + bank->regs->ctrl;
1110     - u32 ctrl;
1111     -
1112     - ctrl = __raw_readl(reg);
1113     - /* Module is disabled, clocks are gated */
1114     - ctrl |= GPIO_MOD_CTRL_BIT;
1115     - __raw_writel(ctrl, reg);
1116     - bank->context.ctrl = ctrl;
1117     - }
1118     -
1119     + _disable_gpio_module(bank, offset);
1120     _reset_gpio(bank, bank->chip.base + offset);
1121     spin_unlock_irqrestore(&bank->lock, flags);
1122    
1123     @@ -672,7 +704,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
1124     * If this is the last gpio to be freed in the bank,
1125     * disable the bank module.
1126     */
1127     - if (!bank->mod_usage)
1128     + if (!BANK_USED(bank))
1129     pm_runtime_put(bank->dev);
1130     }
1131    
1132     @@ -762,10 +794,20 @@ static void gpio_irq_shutdown(struct irq_data *d)
1133     struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
1134     unsigned int gpio = irq_to_gpio(bank, d->hwirq);
1135     unsigned long flags;
1136     + unsigned offset = GPIO_INDEX(bank, gpio);
1137    
1138     spin_lock_irqsave(&bank->lock, flags);
1139     + bank->irq_usage &= ~(1 << offset);
1140     + _disable_gpio_module(bank, offset);
1141     _reset_gpio(bank, gpio);
1142     spin_unlock_irqrestore(&bank->lock, flags);
1143     +
1144     + /*
1145     + * If this is the last IRQ to be freed in the bank,
1146     + * disable the bank module.
1147     + */
1148     + if (!BANK_USED(bank))
1149     + pm_runtime_put(bank->dev);
1150     }
1151    
1152     static void gpio_ack_irq(struct irq_data *d)
1153     @@ -897,13 +939,6 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset)
1154     return 0;
1155     }
1156    
1157     -static int gpio_is_input(struct gpio_bank *bank, int mask)
1158     -{
1159     - void __iomem *reg = bank->base + bank->regs->direction;
1160     -
1161     - return __raw_readl(reg) & mask;
1162     -}
1163     -
1164     static int gpio_get(struct gpio_chip *chip, unsigned offset)
1165     {
1166     struct gpio_bank *bank;
1167     @@ -922,13 +957,22 @@ static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
1168     {
1169     struct gpio_bank *bank;
1170     unsigned long flags;
1171     + int retval = 0;
1172    
1173     bank = container_of(chip, struct gpio_bank, chip);
1174     spin_lock_irqsave(&bank->lock, flags);
1175     +
1176     + if (LINE_USED(bank->irq_usage, offset)) {
1177     + retval = -EINVAL;
1178     + goto exit;
1179     + }
1180     +
1181     bank->set_dataout(bank, offset, value);
1182     _set_gpio_direction(bank, offset, 0);
1183     +
1184     +exit:
1185     spin_unlock_irqrestore(&bank->lock, flags);
1186     - return 0;
1187     + return retval;
1188     }
1189    
1190     static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
1191     @@ -1400,7 +1444,7 @@ void omap2_gpio_prepare_for_idle(int pwr_mode)
1192     struct gpio_bank *bank;
1193    
1194     list_for_each_entry(bank, &omap_gpio_list, node) {
1195     - if (!bank->mod_usage || !bank->loses_context)
1196     + if (!BANK_USED(bank) || !bank->loses_context)
1197     continue;
1198    
1199     bank->power_mode = pwr_mode;
1200     @@ -1414,7 +1458,7 @@ void omap2_gpio_resume_after_idle(void)
1201     struct gpio_bank *bank;
1202    
1203     list_for_each_entry(bank, &omap_gpio_list, node) {
1204     - if (!bank->mod_usage || !bank->loses_context)
1205     + if (!BANK_USED(bank) || !bank->loses_context)
1206     continue;
1207    
1208     pm_runtime_get_sync(bank->dev);
1209     diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1210     index c434d39..e2d7f38 100644
1211     --- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1212     +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
1213     @@ -580,8 +580,22 @@ static void
1214     init_reserved(struct nvbios_init *init)
1215     {
1216     u8 opcode = nv_ro08(init->bios, init->offset);
1217     - trace("RESERVED\t0x%02x\n", opcode);
1218     - init->offset += 1;
1219     + u8 length, i;
1220     +
1221     + switch (opcode) {
1222     + case 0xaa:
1223     + length = 4;
1224     + break;
1225     + default:
1226     + length = 1;
1227     + break;
1228     + }
1229     +
1230     + trace("RESERVED 0x%02x\t", opcode);
1231     + for (i = 1; i < length; i++)
1232     + cont(" 0x%02x", nv_ro08(init->bios, init->offset + i));
1233     + cont("\n");
1234     + init->offset += length;
1235     }
1236    
1237     /**
1238     @@ -2136,6 +2150,7 @@ static struct nvbios_init_opcode {
1239     [0x99] = { init_zm_auxch },
1240     [0x9a] = { init_i2c_long_if },
1241     [0xa9] = { init_gpio_ne },
1242     + [0xaa] = { init_reserved },
1243     };
1244    
1245     #define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0]))
1246     diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
1247     index 7fadfd5..de36c47 100644
1248     --- a/drivers/gpu/drm/radeon/radeon_asic.c
1249     +++ b/drivers/gpu/drm/radeon/radeon_asic.c
1250     @@ -892,8 +892,6 @@ static struct radeon_asic r520_asic = {
1251     .wait_for_vblank = &avivo_wait_for_vblank,
1252     .set_backlight_level = &atombios_set_backlight_level,
1253     .get_backlight_level = &atombios_get_backlight_level,
1254     - .hdmi_enable = &r600_hdmi_enable,
1255     - .hdmi_setmode = &r600_hdmi_setmode,
1256     },
1257     .copy = {
1258     .blit = &r100_copy_blit,
1259     diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1260     index ca959cf..e04bf0ef 100644
1261     --- a/drivers/hid/hid-core.c
1262     +++ b/drivers/hid/hid-core.c
1263     @@ -1188,7 +1188,8 @@ static void hid_output_field(const struct hid_device *hid,
1264     }
1265    
1266     /*
1267     - * Create a report.
1268     + * Create a report. 'data' has to be allocated using
1269     + * hid_alloc_report_buf() so that it has proper size.
1270     */
1271    
1272     void hid_output_report(struct hid_report *report, __u8 *data)
1273     @@ -1205,6 +1206,22 @@ void hid_output_report(struct hid_report *report, __u8 *data)
1274     EXPORT_SYMBOL_GPL(hid_output_report);
1275    
1276     /*
1277     + * Allocator for buffer that is going to be passed to hid_output_report()
1278     + */
1279     +u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
1280     +{
1281     + /*
1282     + * 7 extra bytes are necessary to achieve proper functionality
1283     + * of implement() working on 8 byte chunks
1284     + */
1285     +
1286     + int len = ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7;
1287     +
1288     + return kmalloc(len, flags);
1289     +}
1290     +EXPORT_SYMBOL_GPL(hid_alloc_report_buf);
1291     +
1292     +/*
1293     * Set a field value. The report this field belongs to has to be
1294     * created and transferred to the device, to set this value in the
1295     * device.
1296     @@ -1738,6 +1755,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1297     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
1298     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
1299     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE) },
1300     + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE_OPTICAL) },
1301     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
1302     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) },
1303     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
1304     diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1305     index ca0219f..114fd16 100644
1306     --- a/drivers/hid/hid-ids.h
1307     +++ b/drivers/hid/hid-ids.h
1308     @@ -705,6 +705,7 @@
1309     #define USB_DEVICE_ID_ROCCAT_KONE 0x2ced
1310     #define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51
1311     #define USB_DEVICE_ID_ROCCAT_KONEPURE 0x2dbe
1312     +#define USB_DEVICE_ID_ROCCAT_KONEPURE_OPTICAL 0x2db4
1313     #define USB_DEVICE_ID_ROCCAT_KONEXTD 0x2e22
1314     #define USB_DEVICE_ID_ROCCAT_KOVAPLUS 0x2d50
1315     #define USB_DEVICE_ID_ROCCAT_LUA 0x2c2e
1316     diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
1317     index 0522b80..4f762bc 100644
1318     --- a/drivers/hid/hid-logitech-dj.c
1319     +++ b/drivers/hid/hid-logitech-dj.c
1320     @@ -574,7 +574,7 @@ static int logi_dj_ll_input_event(struct input_dev *dev, unsigned int type,
1321    
1322     struct hid_field *field;
1323     struct hid_report *report;
1324     - unsigned char data[8];
1325     + unsigned char *data;
1326     int offset;
1327    
1328     dbg_hid("%s: %s, type:%d | code:%d | value:%d\n",
1329     @@ -590,6 +590,13 @@ static int logi_dj_ll_input_event(struct input_dev *dev, unsigned int type,
1330     return -1;
1331     }
1332     hid_set_field(field, offset, value);
1333     +
1334     + data = hid_alloc_report_buf(field->report, GFP_KERNEL);
1335     + if (!data) {
1336     + dev_warn(&dev->dev, "failed to allocate report buf memory\n");
1337     + return -1;
1338     + }
1339     +
1340     hid_output_report(field->report, &data[0]);
1341    
1342     output_report_enum = &dj_rcv_hiddev->report_enum[HID_OUTPUT_REPORT];
1343     @@ -600,8 +607,9 @@ static int logi_dj_ll_input_event(struct input_dev *dev, unsigned int type,
1344    
1345     hid_hw_request(dj_rcv_hiddev, report, HID_REQ_SET_REPORT);
1346    
1347     - return 0;
1348     + kfree(data);
1349    
1350     + return 0;
1351     }
1352    
1353     static int logi_dj_ll_start(struct hid_device *hid)
1354     diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
1355     index 59ab8e1..024cdf3 100644
1356     --- a/drivers/hid/hid-picolcd_debugfs.c
1357     +++ b/drivers/hid/hid-picolcd_debugfs.c
1358     @@ -394,7 +394,7 @@ static void dump_buff_as_hex(char *dst, size_t dst_sz, const u8 *data,
1359     void picolcd_debug_out_report(struct picolcd_data *data,
1360     struct hid_device *hdev, struct hid_report *report)
1361     {
1362     - u8 raw_data[70];
1363     + u8 *raw_data;
1364     int raw_size = (report->size >> 3) + 1;
1365     char *buff;
1366     #define BUFF_SZ 256
1367     @@ -407,20 +407,20 @@ void picolcd_debug_out_report(struct picolcd_data *data,
1368     if (!buff)
1369     return;
1370    
1371     - snprintf(buff, BUFF_SZ, "\nout report %d (size %d) = ",
1372     - report->id, raw_size);
1373     - hid_debug_event(hdev, buff);
1374     - if (raw_size + 5 > sizeof(raw_data)) {
1375     + raw_data = hid_alloc_report_buf(report, GFP_ATOMIC);
1376     + if (!raw_data) {
1377     kfree(buff);
1378     - hid_debug_event(hdev, " TOO BIG\n");
1379     return;
1380     - } else {
1381     - raw_data[0] = report->id;
1382     - hid_output_report(report, raw_data);
1383     - dump_buff_as_hex(buff, BUFF_SZ, raw_data, raw_size);
1384     - hid_debug_event(hdev, buff);
1385     }
1386    
1387     + snprintf(buff, BUFF_SZ, "\nout report %d (size %d) = ",
1388     + report->id, raw_size);
1389     + hid_debug_event(hdev, buff);
1390     + raw_data[0] = report->id;
1391     + hid_output_report(report, raw_data);
1392     + dump_buff_as_hex(buff, BUFF_SZ, raw_data, raw_size);
1393     + hid_debug_event(hdev, buff);
1394     +
1395     switch (report->id) {
1396     case REPORT_LED_STATE:
1397     /* 1 data byte with GPO state */
1398     @@ -644,6 +644,7 @@ void picolcd_debug_out_report(struct picolcd_data *data,
1399     break;
1400     }
1401     wake_up_interruptible(&hdev->debug_wait);
1402     + kfree(raw_data);
1403     kfree(buff);
1404     }
1405    
1406     diff --git a/drivers/hid/hid-roccat-konepure.c b/drivers/hid/hid-roccat-konepure.c
1407     index c79d0b0..5850959 100644
1408     --- a/drivers/hid/hid-roccat-konepure.c
1409     +++ b/drivers/hid/hid-roccat-konepure.c
1410     @@ -262,6 +262,7 @@ static int konepure_raw_event(struct hid_device *hdev,
1411    
1412     static const struct hid_device_id konepure_devices[] = {
1413     { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE) },
1414     + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE_OPTICAL) },
1415     { }
1416     };
1417    
1418     @@ -300,5 +301,5 @@ module_init(konepure_init);
1419     module_exit(konepure_exit);
1420    
1421     MODULE_AUTHOR("Stefan Achatz");
1422     -MODULE_DESCRIPTION("USB Roccat KonePure driver");
1423     +MODULE_DESCRIPTION("USB Roccat KonePure/Optical driver");
1424     MODULE_LICENSE("GPL v2");
1425     diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
1426     index fc307e0..145a4cb 100644
1427     --- a/drivers/hid/uhid.c
1428     +++ b/drivers/hid/uhid.c
1429     @@ -640,7 +640,7 @@ static const struct file_operations uhid_fops = {
1430    
1431     static struct miscdevice uhid_misc = {
1432     .fops = &uhid_fops,
1433     - .minor = MISC_DYNAMIC_MINOR,
1434     + .minor = UHID_MINOR,
1435     .name = UHID_NAME,
1436     };
1437    
1438     @@ -659,3 +659,5 @@ module_exit(uhid_exit);
1439     MODULE_LICENSE("GPL");
1440     MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
1441     MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");
1442     +MODULE_ALIAS_MISCDEV(UHID_MINOR);
1443     +MODULE_ALIAS("devname:" UHID_NAME);
1444     diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
1445     index 9941828..ada164e 100644
1446     --- a/drivers/hid/usbhid/hid-core.c
1447     +++ b/drivers/hid/usbhid/hid-core.c
1448     @@ -535,7 +535,6 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
1449     {
1450     int head;
1451     struct usbhid_device *usbhid = hid->driver_data;
1452     - int len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
1453    
1454     if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN)
1455     return;
1456     @@ -546,7 +545,7 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
1457     return;
1458     }
1459    
1460     - usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC);
1461     + usbhid->out[usbhid->outhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC);
1462     if (!usbhid->out[usbhid->outhead].raw_report) {
1463     hid_warn(hid, "output queueing failed\n");
1464     return;
1465     @@ -595,7 +594,7 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
1466     }
1467    
1468     if (dir == USB_DIR_OUT) {
1469     - usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC);
1470     + usbhid->ctrl[usbhid->ctrlhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC);
1471     if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) {
1472     hid_warn(hid, "control queueing failed\n");
1473     return;
1474     diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
1475     index 3f3f041..6c66a72 100644
1476     --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
1477     +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
1478     @@ -1588,7 +1588,7 @@ static int srpt_build_tskmgmt_rsp(struct srpt_rdma_ch *ch,
1479     int resp_data_len;
1480     int resp_len;
1481    
1482     - resp_data_len = (rsp_code == SRP_TSK_MGMT_SUCCESS) ? 0 : 4;
1483     + resp_data_len = 4;
1484     resp_len = sizeof(*srp_rsp) + resp_data_len;
1485    
1486     srp_rsp = ioctx->ioctx.buf;
1487     @@ -1600,11 +1600,9 @@ static int srpt_build_tskmgmt_rsp(struct srpt_rdma_ch *ch,
1488     + atomic_xchg(&ch->req_lim_delta, 0));
1489     srp_rsp->tag = tag;
1490    
1491     - if (rsp_code != SRP_TSK_MGMT_SUCCESS) {
1492     - srp_rsp->flags |= SRP_RSP_FLAG_RSPVALID;
1493     - srp_rsp->resp_data_len = cpu_to_be32(resp_data_len);
1494     - srp_rsp->data[3] = rsp_code;
1495     - }
1496     + srp_rsp->flags |= SRP_RSP_FLAG_RSPVALID;
1497     + srp_rsp->resp_data_len = cpu_to_be32(resp_data_len);
1498     + srp_rsp->data[3] = rsp_code;
1499    
1500     return resp_len;
1501     }
1502     @@ -2358,6 +2356,8 @@ static void srpt_release_channel_work(struct work_struct *w)
1503     transport_deregister_session(se_sess);
1504     ch->sess = NULL;
1505    
1506     + ib_destroy_cm_id(ch->cm_id);
1507     +
1508     srpt_destroy_ch_ib(ch);
1509    
1510     srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring,
1511     @@ -2368,8 +2368,6 @@ static void srpt_release_channel_work(struct work_struct *w)
1512     list_del(&ch->list);
1513     spin_unlock_irq(&sdev->spinlock);
1514    
1515     - ib_destroy_cm_id(ch->cm_id);
1516     -
1517     if (ch->release_done)
1518     complete(ch->release_done);
1519    
1520     diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
1521     index 2fe37fa..cbcf8b3 100644
1522     --- a/drivers/md/bcache/request.c
1523     +++ b/drivers/md/bcache/request.c
1524     @@ -1055,6 +1055,7 @@ static void request_write(struct cached_dev *dc, struct search *s)
1525     } else {
1526     trace_bcache_writeback(s->orig_bio);
1527     bch_writeback_add(dc, bio_sectors(bio));
1528     + s->op.cache_bio = bio;
1529    
1530     if (bio->bi_rw & REQ_FLUSH) {
1531     /* Also need to send a flush to the backing device */
1532     @@ -1067,8 +1068,6 @@ static void request_write(struct cached_dev *dc, struct search *s)
1533     flush->bi_private = cl;
1534    
1535     closure_bio_submit(flush, cl, s->d);
1536     - } else {
1537     - s->op.cache_bio = bio;
1538     }
1539     }
1540     out:
1541     diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
1542     index 666cf3a..8395b09 100644
1543     --- a/drivers/net/bonding/bond_main.c
1544     +++ b/drivers/net/bonding/bond_main.c
1545     @@ -1991,6 +1991,7 @@ static int __bond_release_one(struct net_device *bond_dev,
1546     struct bonding *bond = netdev_priv(bond_dev);
1547     struct slave *slave, *oldcurrent;
1548     struct sockaddr addr;
1549     + int old_flags = bond_dev->flags;
1550     netdev_features_t old_features = bond_dev->features;
1551    
1552     /* slave is not a slave or master is not master of this slave */
1553     @@ -2123,12 +2124,18 @@ static int __bond_release_one(struct net_device *bond_dev,
1554     * already taken care of above when we detached the slave
1555     */
1556     if (!USES_PRIMARY(bond->params.mode)) {
1557     - /* unset promiscuity level from slave */
1558     - if (bond_dev->flags & IFF_PROMISC)
1559     + /* unset promiscuity level from slave
1560     + * NOTE: The NETDEV_CHANGEADDR call above may change the value
1561     + * of the IFF_PROMISC flag in the bond_dev, but we need the
1562     + * value of that flag before that change, as that was the value
1563     + * when this slave was attached, so we cache at the start of the
1564     + * function and use it here. Same goes for ALLMULTI below
1565     + */
1566     + if (old_flags & IFF_PROMISC)
1567     dev_set_promiscuity(slave_dev, -1);
1568    
1569     /* unset allmulti level from slave */
1570     - if (bond_dev->flags & IFF_ALLMULTI)
1571     + if (old_flags & IFF_ALLMULTI)
1572     dev_set_allmulti(slave_dev, -1);
1573    
1574     /* flush master's mc_list from slave */
1575     diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
1576     index 393f961..7199d2a 100644
1577     --- a/drivers/net/ethernet/realtek/r8169.c
1578     +++ b/drivers/net/ethernet/realtek/r8169.c
1579     @@ -4218,6 +4218,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
1580     case RTL_GIGA_MAC_VER_23:
1581     case RTL_GIGA_MAC_VER_24:
1582     case RTL_GIGA_MAC_VER_34:
1583     + case RTL_GIGA_MAC_VER_35:
1584     RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
1585     break;
1586     case RTL_GIGA_MAC_VER_40:
1587     diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
1588     index ca98aca..75b82b6 100644
1589     --- a/drivers/net/ethernet/via/via-rhine.c
1590     +++ b/drivers/net/ethernet/via/via-rhine.c
1591     @@ -32,7 +32,7 @@
1592     #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1593    
1594     #define DRV_NAME "via-rhine"
1595     -#define DRV_VERSION "1.5.0"
1596     +#define DRV_VERSION "1.5.1"
1597     #define DRV_RELDATE "2010-10-09"
1598    
1599     #include <linux/types.h>
1600     @@ -1694,7 +1694,12 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
1601     cpu_to_le32(TXDESC | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN));
1602    
1603     if (unlikely(vlan_tx_tag_present(skb))) {
1604     - rp->tx_ring[entry].tx_status = cpu_to_le32((vlan_tx_tag_get(skb)) << 16);
1605     + u16 vid_pcp = vlan_tx_tag_get(skb);
1606     +
1607     + /* drop CFI/DEI bit, register needs VID and PCP */
1608     + vid_pcp = (vid_pcp & VLAN_VID_MASK) |
1609     + ((vid_pcp & VLAN_PRIO_MASK) >> 1);
1610     + rp->tx_ring[entry].tx_status = cpu_to_le32((vid_pcp) << 16);
1611     /* request tagging */
1612     rp->tx_ring[entry].desc_length |= cpu_to_le32(0x020000);
1613     }
1614     diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
1615     index 57c2e5e..5444f2b 100644
1616     --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
1617     +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
1618     @@ -297,6 +297,12 @@ static int temac_dma_bd_init(struct net_device *ndev)
1619     lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
1620     lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p);
1621    
1622     + /* Init descriptor indexes */
1623     + lp->tx_bd_ci = 0;
1624     + lp->tx_bd_next = 0;
1625     + lp->tx_bd_tail = 0;
1626     + lp->rx_bd_ci = 0;
1627     +
1628     return 0;
1629    
1630     out:
1631     diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
1632     index 162464f..7f10588 100644
1633     --- a/drivers/net/ppp/pptp.c
1634     +++ b/drivers/net/ppp/pptp.c
1635     @@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
1636     nf_reset(skb);
1637    
1638     skb->ip_summed = CHECKSUM_NONE;
1639     - ip_select_ident(iph, &rt->dst, NULL);
1640     + ip_select_ident(skb, &rt->dst, NULL);
1641     ip_send_check(iph);
1642    
1643     ip_local_out(skb);
1644     diff --git a/drivers/net/tun.c b/drivers/net/tun.c
1645     index 7b54f4f..b18ead5 100644
1646     --- a/drivers/net/tun.c
1647     +++ b/drivers/net/tun.c
1648     @@ -1693,11 +1693,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1649     INIT_LIST_HEAD(&tun->disabled);
1650     err = tun_attach(tun, file);
1651     if (err < 0)
1652     - goto err_free_dev;
1653     + goto err_free_flow;
1654    
1655     err = register_netdevice(tun->dev);
1656     if (err < 0)
1657     - goto err_free_dev;
1658     + goto err_detach;
1659    
1660     if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1661     device_create_file(&tun->dev->dev, &dev_attr_owner) ||
1662     @@ -1741,7 +1741,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1663     strcpy(ifr->ifr_name, tun->dev->name);
1664     return 0;
1665    
1666     - err_free_dev:
1667     +err_detach:
1668     + tun_detach_all(dev);
1669     +err_free_flow:
1670     + tun_flow_uninit(tun);
1671     + security_tun_dev_free_security(tun->security);
1672     +err_free_dev:
1673     free_netdev(dev);
1674     return err;
1675     }
1676     diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
1677     index 2dbb946..c6867f9 100644
1678     --- a/drivers/net/usb/dm9601.c
1679     +++ b/drivers/net/usb/dm9601.c
1680     @@ -303,7 +303,7 @@ static void dm9601_set_multicast(struct net_device *net)
1681     rx_ctl |= 0x02;
1682     } else if (net->flags & IFF_ALLMULTI ||
1683     netdev_mc_count(net) > DM_MAX_MCAST) {
1684     - rx_ctl |= 0x04;
1685     + rx_ctl |= 0x08;
1686     } else if (!netdev_mc_empty(net)) {
1687     struct netdev_hw_addr *ha;
1688    
1689     diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
1690     index 5645921..34a081f 100644
1691     --- a/drivers/net/usb/qmi_wwan.c
1692     +++ b/drivers/net/usb/qmi_wwan.c
1693     @@ -518,6 +518,135 @@ static const struct usb_device_id products[] = {
1694    
1695     /* 3. Combined interface devices matching on interface number */
1696     {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
1697     + {QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
1698     + {QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
1699     + {QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
1700     + {QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
1701     + {QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
1702     + {QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
1703     + {QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
1704     + {QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
1705     + {QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
1706     + {QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
1707     + {QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
1708     + {QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
1709     + {QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
1710     + {QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
1711     + {QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
1712     + {QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
1713     + {QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
1714     + {QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
1715     + {QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
1716     + {QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
1717     + {QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
1718     + {QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
1719     + {QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
1720     + {QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
1721     + {QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
1722     + {QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
1723     + {QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
1724     + {QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
1725     + {QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
1726     + {QMI_FIXED_INTF(0x05c6, 0x9025, 4)}, /* Alcatel-sbell ASB TL131 TDD LTE (China Mobile) */
1727     + {QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
1728     + {QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
1729     + {QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
1730     + {QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
1731     + {QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
1732     + {QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
1733     + {QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
1734     + {QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
1735     + {QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
1736     + {QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
1737     + {QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
1738     + {QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
1739     + {QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
1740     + {QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
1741     + {QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
1742     + {QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
1743     + {QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
1744     + {QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
1745     + {QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
1746     + {QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
1747     + {QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
1748     + {QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
1749     + {QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
1750     + {QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
1751     + {QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
1752     + {QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
1753     + {QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
1754     + {QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
1755     + {QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
1756     + {QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
1757     + {QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
1758     + {QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
1759     + {QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
1760     + {QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
1761     + {QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
1762     + {QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
1763     + {QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
1764     + {QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
1765     + {QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
1766     + {QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
1767     + {QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
1768     + {QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
1769     + {QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
1770     + {QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
1771     + {QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
1772     + {QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
1773     + {QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
1774     + {QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
1775     + {QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
1776     + {QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
1777     + {QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
1778     + {QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
1779     + {QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
1780     + {QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
1781     + {QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
1782     + {QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
1783     + {QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
1784     + {QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
1785     + {QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
1786     + {QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
1787     + {QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
1788     + {QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
1789     + {QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
1790     + {QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
1791     + {QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
1792     + {QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
1793     + {QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
1794     + {QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
1795     + {QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
1796     + {QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
1797     + {QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
1798     + {QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
1799     + {QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
1800     + {QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
1801     + {QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
1802     + {QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
1803     + {QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
1804     + {QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
1805     + {QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
1806     + {QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
1807     + {QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
1808     + {QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
1809     + {QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
1810     + {QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
1811     + {QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
1812     + {QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
1813     + {QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
1814     + {QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
1815     + {QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
1816     + {QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
1817     + {QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
1818     + {QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
1819     + {QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
1820     + {QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
1821     + {QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
1822     + {QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
1823     + {QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
1824     + {QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
1825     + {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
1826     {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
1827     {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
1828     {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
1829     @@ -610,7 +739,6 @@ static const struct usb_device_id products[] = {
1830     {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
1831     {QMI_GOBI_DEVICE(0x413c, 0x8194)}, /* Dell Gobi 3000 Composite */
1832     {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
1833     - {QMI_GOBI_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */
1834     {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
1835     {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
1836     {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
1837     diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
1838     index 44fa0cd..0f6eb2b 100644
1839     --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
1840     +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
1841     @@ -575,8 +575,6 @@ static struct sdio_driver brcmf_sdmmc_driver = {
1842    
1843     static int brcmf_sdio_pd_probe(struct platform_device *pdev)
1844     {
1845     - int ret;
1846     -
1847     brcmf_dbg(SDIO, "Enter\n");
1848    
1849     brcmfmac_sdio_pdata = pdev->dev.platform_data;
1850     @@ -584,11 +582,7 @@ static int brcmf_sdio_pd_probe(struct platform_device *pdev)
1851     if (brcmfmac_sdio_pdata->power_on)
1852     brcmfmac_sdio_pdata->power_on();
1853    
1854     - ret = sdio_register_driver(&brcmf_sdmmc_driver);
1855     - if (ret)
1856     - brcmf_err("sdio_register_driver failed: %d\n", ret);
1857     -
1858     - return ret;
1859     + return 0;
1860     }
1861    
1862     static int brcmf_sdio_pd_remove(struct platform_device *pdev)
1863     @@ -610,6 +604,15 @@ static struct platform_driver brcmf_sdio_pd = {
1864     }
1865     };
1866    
1867     +void brcmf_sdio_register(void)
1868     +{
1869     + int ret;
1870     +
1871     + ret = sdio_register_driver(&brcmf_sdmmc_driver);
1872     + if (ret)
1873     + brcmf_err("sdio_register_driver failed: %d\n", ret);
1874     +}
1875     +
1876     void brcmf_sdio_exit(void)
1877     {
1878     brcmf_dbg(SDIO, "Enter\n");
1879     @@ -620,18 +623,13 @@ void brcmf_sdio_exit(void)
1880     sdio_unregister_driver(&brcmf_sdmmc_driver);
1881     }
1882    
1883     -void brcmf_sdio_init(void)
1884     +void __init brcmf_sdio_init(void)
1885     {
1886     int ret;
1887    
1888     brcmf_dbg(SDIO, "Enter\n");
1889    
1890     ret = platform_driver_probe(&brcmf_sdio_pd, brcmf_sdio_pd_probe);
1891     - if (ret == -ENODEV) {
1892     - brcmf_dbg(SDIO, "No platform data available, registering without.\n");
1893     - ret = sdio_register_driver(&brcmf_sdmmc_driver);
1894     - }
1895     -
1896     - if (ret)
1897     - brcmf_err("driver registration failed: %d\n", ret);
1898     + if (ret == -ENODEV)
1899     + brcmf_dbg(SDIO, "No platform data available.\n");
1900     }
1901     diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
1902     index 080395f..e715d33 100644
1903     --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
1904     +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
1905     @@ -154,10 +154,11 @@ extern int brcmf_bus_start(struct device *dev);
1906     #ifdef CONFIG_BRCMFMAC_SDIO
1907     extern void brcmf_sdio_exit(void);
1908     extern void brcmf_sdio_init(void);
1909     +extern void brcmf_sdio_register(void);
1910     #endif
1911     #ifdef CONFIG_BRCMFMAC_USB
1912     extern void brcmf_usb_exit(void);
1913     -extern void brcmf_usb_init(void);
1914     +extern void brcmf_usb_register(void);
1915     #endif
1916    
1917     #endif /* _BRCMF_BUS_H_ */
1918     diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
1919     index 2c59357..95d7099 100644
1920     --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
1921     +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
1922     @@ -1034,21 +1034,23 @@ u32 brcmf_get_chip_info(struct brcmf_if *ifp)
1923     return bus->chip << 4 | bus->chiprev;
1924     }
1925    
1926     -static void brcmf_driver_init(struct work_struct *work)
1927     +static void brcmf_driver_register(struct work_struct *work)
1928     {
1929     - brcmf_debugfs_init();
1930     -
1931     #ifdef CONFIG_BRCMFMAC_SDIO
1932     - brcmf_sdio_init();
1933     + brcmf_sdio_register();
1934     #endif
1935     #ifdef CONFIG_BRCMFMAC_USB
1936     - brcmf_usb_init();
1937     + brcmf_usb_register();
1938     #endif
1939     }
1940     -static DECLARE_WORK(brcmf_driver_work, brcmf_driver_init);
1941     +static DECLARE_WORK(brcmf_driver_work, brcmf_driver_register);
1942    
1943     static int __init brcmfmac_module_init(void)
1944     {
1945     + brcmf_debugfs_init();
1946     +#ifdef CONFIG_BRCMFMAC_SDIO
1947     + brcmf_sdio_init();
1948     +#endif
1949     if (!schedule_work(&brcmf_driver_work))
1950     return -EBUSY;
1951    
1952     diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
1953     index 01aed7a..b0ab98b 100644
1954     --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
1955     +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
1956     @@ -1532,7 +1532,7 @@ void brcmf_usb_exit(void)
1957     brcmf_release_fw(&fw_image_list);
1958     }
1959    
1960     -void brcmf_usb_init(void)
1961     +void brcmf_usb_register(void)
1962     {
1963     brcmf_dbg(USB, "Enter\n");
1964     INIT_LIST_HEAD(&fw_image_list);
1965     diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
1966     index a78e065..d69d024 100644
1967     --- a/drivers/net/wireless/mwifiex/11n_aggr.c
1968     +++ b/drivers/net/wireless/mwifiex/11n_aggr.c
1969     @@ -149,7 +149,7 @@ mwifiex_11n_form_amsdu_txpd(struct mwifiex_private *priv,
1970     */
1971     int
1972     mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
1973     - struct mwifiex_ra_list_tbl *pra_list, int headroom,
1974     + struct mwifiex_ra_list_tbl *pra_list,
1975     int ptrindex, unsigned long ra_list_flags)
1976     __releases(&priv->wmm.ra_list_spinlock)
1977     {
1978     @@ -159,6 +159,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
1979     int pad = 0, ret;
1980     struct mwifiex_tx_param tx_param;
1981     struct txpd *ptx_pd = NULL;
1982     + int headroom = adapter->iface_type == MWIFIEX_USB ? 0 : INTF_HEADER_LEN;
1983    
1984     skb_src = skb_peek(&pra_list->skb_head);
1985     if (!skb_src) {
1986     diff --git a/drivers/net/wireless/mwifiex/11n_aggr.h b/drivers/net/wireless/mwifiex/11n_aggr.h
1987     index 900e1c6..892098d 100644
1988     --- a/drivers/net/wireless/mwifiex/11n_aggr.h
1989     +++ b/drivers/net/wireless/mwifiex/11n_aggr.h
1990     @@ -26,7 +26,7 @@
1991     int mwifiex_11n_deaggregate_pkt(struct mwifiex_private *priv,
1992     struct sk_buff *skb);
1993     int mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
1994     - struct mwifiex_ra_list_tbl *ptr, int headroom,
1995     + struct mwifiex_ra_list_tbl *ptr,
1996     int ptr_index, unsigned long flags)
1997     __releases(&priv->wmm.ra_list_spinlock);
1998    
1999     diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
2000     index 26755d9..7a97f6c 100644
2001     --- a/drivers/net/wireless/mwifiex/cmdevt.c
2002     +++ b/drivers/net/wireless/mwifiex/cmdevt.c
2003     @@ -1154,7 +1154,7 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
2004     uint32_t conditions = le32_to_cpu(phs_cfg->params.hs_config.conditions);
2005    
2006     if (phs_cfg->action == cpu_to_le16(HS_ACTIVATE) &&
2007     - adapter->iface_type == MWIFIEX_SDIO) {
2008     + adapter->iface_type != MWIFIEX_USB) {
2009     mwifiex_hs_activated_event(priv, true);
2010     return 0;
2011     } else {
2012     @@ -1166,8 +1166,7 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
2013     }
2014     if (conditions != HS_CFG_CANCEL) {
2015     adapter->is_hs_configured = true;
2016     - if (adapter->iface_type == MWIFIEX_USB ||
2017     - adapter->iface_type == MWIFIEX_PCIE)
2018     + if (adapter->iface_type == MWIFIEX_USB)
2019     mwifiex_hs_activated_event(priv, true);
2020     } else {
2021     adapter->is_hs_configured = false;
2022     diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
2023     index c4a2e77..8fc4499 100644
2024     --- a/drivers/net/wireless/mwifiex/main.c
2025     +++ b/drivers/net/wireless/mwifiex/main.c
2026     @@ -559,9 +559,8 @@ static void mwifiex_set_multicast_list(struct net_device *dev)
2027     mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
2028     } else {
2029     mcast_list.mode = MWIFIEX_MULTICAST_MODE;
2030     - if (netdev_mc_count(dev))
2031     - mcast_list.num_multicast_addr =
2032     - mwifiex_copy_mcast_addr(&mcast_list, dev);
2033     + mcast_list.num_multicast_addr =
2034     + mwifiex_copy_mcast_addr(&mcast_list, dev);
2035     }
2036     mwifiex_request_set_multicast_list(priv, &mcast_list);
2037     }
2038     diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
2039     index 1a8a19d..23aa910 100644
2040     --- a/drivers/net/wireless/mwifiex/sta_ioctl.c
2041     +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
2042     @@ -104,16 +104,14 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
2043     } else {
2044     priv->curr_pkt_filter &=
2045     ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
2046     - if (mcast_list->num_multicast_addr) {
2047     - dev_dbg(priv->adapter->dev,
2048     - "info: Set multicast list=%d\n",
2049     - mcast_list->num_multicast_addr);
2050     - /* Send multicast addresses to firmware */
2051     - ret = mwifiex_send_cmd_async(priv,
2052     - HostCmd_CMD_MAC_MULTICAST_ADR,
2053     - HostCmd_ACT_GEN_SET, 0,
2054     - mcast_list);
2055     - }
2056     + dev_dbg(priv->adapter->dev,
2057     + "info: Set multicast list=%d\n",
2058     + mcast_list->num_multicast_addr);
2059     + /* Send multicast addresses to firmware */
2060     + ret = mwifiex_send_cmd_async(priv,
2061     + HostCmd_CMD_MAC_MULTICAST_ADR,
2062     + HostCmd_ACT_GEN_SET, 0,
2063     + mcast_list);
2064     }
2065     }
2066     dev_dbg(priv->adapter->dev,
2067     diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
2068     index f90fe21..b7adf3d 100644
2069     --- a/drivers/net/wireless/mwifiex/usb.c
2070     +++ b/drivers/net/wireless/mwifiex/usb.c
2071     @@ -446,9 +446,6 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message)
2072     */
2073     adapter->is_suspended = true;
2074    
2075     - for (i = 0; i < adapter->priv_num; i++)
2076     - netif_carrier_off(adapter->priv[i]->netdev);
2077     -
2078     if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb)
2079     usb_kill_urb(card->rx_cmd.urb);
2080    
2081     @@ -508,10 +505,6 @@ static int mwifiex_usb_resume(struct usb_interface *intf)
2082     MWIFIEX_RX_CMD_BUF_SIZE);
2083     }
2084    
2085     - for (i = 0; i < adapter->priv_num; i++)
2086     - if (adapter->priv[i]->media_connected)
2087     - netif_carrier_on(adapter->priv[i]->netdev);
2088     -
2089     /* Disable Host Sleep */
2090     if (adapter->hs_activated)
2091     mwifiex_cancel_hs(mwifiex_get_priv(adapter,
2092     diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
2093     index 4be3d33..ae31e8d 100644
2094     --- a/drivers/net/wireless/mwifiex/wmm.c
2095     +++ b/drivers/net/wireless/mwifiex/wmm.c
2096     @@ -1236,8 +1236,7 @@ mwifiex_dequeue_tx_packet(struct mwifiex_adapter *adapter)
2097     if (mwifiex_is_amsdu_allowed(priv, tid) &&
2098     mwifiex_is_11n_aggragation_possible(priv, ptr,
2099     adapter->tx_buf_size))
2100     - mwifiex_11n_aggregate_pkt(priv, ptr, INTF_HEADER_LEN,
2101     - ptr_index, flags);
2102     + mwifiex_11n_aggregate_pkt(priv, ptr, ptr_index, flags);
2103     /* ra_list_spinlock has been freed in
2104     mwifiex_11n_aggregate_pkt() */
2105     else
2106     diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
2107     index b9deef6..f42dc3c 100644
2108     --- a/drivers/net/wireless/p54/p54usb.c
2109     +++ b/drivers/net/wireless/p54/p54usb.c
2110     @@ -83,6 +83,7 @@ static struct usb_device_id p54u_table[] = {
2111     {USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
2112     {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
2113     {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
2114     + {USB_DEVICE(0x07aa, 0x0020)}, /* Corega WLUSB2GTST USB */
2115     {USB_DEVICE(0x0803, 0x4310)}, /* Zoom 4410a */
2116     {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
2117     {USB_DEVICE(0x083a, 0x4531)}, /* T-Com Sinus 154 data II */
2118     diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
2119     index cc03e7c..7032587 100644
2120     --- a/drivers/net/wireless/rtlwifi/wifi.h
2121     +++ b/drivers/net/wireless/rtlwifi/wifi.h
2122     @@ -2057,7 +2057,7 @@ struct rtl_priv {
2123     that it points to the data allocated
2124     beyond this structure like:
2125     rtl_pci_priv or rtl_usb_priv */
2126     - u8 priv[0];
2127     + u8 priv[0] __aligned(sizeof(void *));
2128     };
2129    
2130     #define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv))
2131     diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
2132     index 8c20935..0071f21 100644
2133     --- a/drivers/net/xen-netback/netback.c
2134     +++ b/drivers/net/xen-netback/netback.c
2135     @@ -354,6 +354,49 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
2136     return false;
2137     }
2138    
2139     +struct xenvif_count_slot_state {
2140     + unsigned long copy_off;
2141     + bool head;
2142     +};
2143     +
2144     +unsigned int xenvif_count_frag_slots(struct xenvif *vif,
2145     + unsigned long offset, unsigned long size,
2146     + struct xenvif_count_slot_state *state)
2147     +{
2148     + unsigned count = 0;
2149     +
2150     + offset &= ~PAGE_MASK;
2151     +
2152     + while (size > 0) {
2153     + unsigned long bytes;
2154     +
2155     + bytes = PAGE_SIZE - offset;
2156     +
2157     + if (bytes > size)
2158     + bytes = size;
2159     +
2160     + if (start_new_rx_buffer(state->copy_off, bytes, state->head)) {
2161     + count++;
2162     + state->copy_off = 0;
2163     + }
2164     +
2165     + if (state->copy_off + bytes > MAX_BUFFER_OFFSET)
2166     + bytes = MAX_BUFFER_OFFSET - state->copy_off;
2167     +
2168     + state->copy_off += bytes;
2169     +
2170     + offset += bytes;
2171     + size -= bytes;
2172     +
2173     + if (offset == PAGE_SIZE)
2174     + offset = 0;
2175     +
2176     + state->head = false;
2177     + }
2178     +
2179     + return count;
2180     +}
2181     +
2182     /*
2183     * Figure out how many ring slots we're going to need to send @skb to
2184     * the guest. This function is essentially a dry run of
2185     @@ -361,48 +404,39 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
2186     */
2187     unsigned int xen_netbk_count_skb_slots(struct xenvif *vif, struct sk_buff *skb)
2188     {
2189     + struct xenvif_count_slot_state state;
2190     unsigned int count;
2191     - int i, copy_off;
2192     + unsigned char *data;
2193     + unsigned i;
2194    
2195     - count = DIV_ROUND_UP(skb_headlen(skb), PAGE_SIZE);
2196     + state.head = true;
2197     + state.copy_off = 0;
2198    
2199     - copy_off = skb_headlen(skb) % PAGE_SIZE;
2200     + /* Slot for the first (partial) page of data. */
2201     + count = 1;
2202    
2203     + /* Need a slot for the GSO prefix for GSO extra data? */
2204     if (skb_shinfo(skb)->gso_size)
2205     count++;
2206    
2207     - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2208     - unsigned long size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
2209     - unsigned long offset = skb_shinfo(skb)->frags[i].page_offset;
2210     - unsigned long bytes;
2211     -
2212     - offset &= ~PAGE_MASK;
2213     -
2214     - while (size > 0) {
2215     - BUG_ON(offset >= PAGE_SIZE);
2216     - BUG_ON(copy_off > MAX_BUFFER_OFFSET);
2217     -
2218     - bytes = PAGE_SIZE - offset;
2219     -
2220     - if (bytes > size)
2221     - bytes = size;
2222     + data = skb->data;
2223     + while (data < skb_tail_pointer(skb)) {
2224     + unsigned long offset = offset_in_page(data);
2225     + unsigned long size = PAGE_SIZE - offset;
2226    
2227     - if (start_new_rx_buffer(copy_off, bytes, 0)) {
2228     - count++;
2229     - copy_off = 0;
2230     - }
2231     + if (data + size > skb_tail_pointer(skb))
2232     + size = skb_tail_pointer(skb) - data;
2233    
2234     - if (copy_off + bytes > MAX_BUFFER_OFFSET)
2235     - bytes = MAX_BUFFER_OFFSET - copy_off;
2236     + count += xenvif_count_frag_slots(vif, offset, size, &state);
2237    
2238     - copy_off += bytes;
2239     + data += size;
2240     + }
2241    
2242     - offset += bytes;
2243     - size -= bytes;
2244     + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2245     + unsigned long size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
2246     + unsigned long offset = skb_shinfo(skb)->frags[i].page_offset;
2247    
2248     - if (offset == PAGE_SIZE)
2249     - offset = 0;
2250     - }
2251     + count += xenvif_count_frag_slots(vif, offset, size, &state);
2252     }
2253     return count;
2254     }
2255     diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
2256     index 34552bf..55548dc 100644
2257     --- a/drivers/scsi/esp_scsi.c
2258     +++ b/drivers/scsi/esp_scsi.c
2259     @@ -530,7 +530,7 @@ static int esp_need_to_nego_sync(struct esp_target_data *tp)
2260     static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
2261     struct esp_lun_data *lp)
2262     {
2263     - if (!ent->tag[0]) {
2264     + if (!ent->orig_tag[0]) {
2265     /* Non-tagged, slot already taken? */
2266     if (lp->non_tagged_cmd)
2267     return -EBUSY;
2268     @@ -564,9 +564,9 @@ static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
2269     return -EBUSY;
2270     }
2271    
2272     - BUG_ON(lp->tagged_cmds[ent->tag[1]]);
2273     + BUG_ON(lp->tagged_cmds[ent->orig_tag[1]]);
2274    
2275     - lp->tagged_cmds[ent->tag[1]] = ent;
2276     + lp->tagged_cmds[ent->orig_tag[1]] = ent;
2277     lp->num_tagged++;
2278    
2279     return 0;
2280     @@ -575,9 +575,9 @@ static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
2281     static void esp_free_lun_tag(struct esp_cmd_entry *ent,
2282     struct esp_lun_data *lp)
2283     {
2284     - if (ent->tag[0]) {
2285     - BUG_ON(lp->tagged_cmds[ent->tag[1]] != ent);
2286     - lp->tagged_cmds[ent->tag[1]] = NULL;
2287     + if (ent->orig_tag[0]) {
2288     + BUG_ON(lp->tagged_cmds[ent->orig_tag[1]] != ent);
2289     + lp->tagged_cmds[ent->orig_tag[1]] = NULL;
2290     lp->num_tagged--;
2291     } else {
2292     BUG_ON(lp->non_tagged_cmd != ent);
2293     @@ -667,6 +667,8 @@ static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp)
2294     ent->tag[0] = 0;
2295     ent->tag[1] = 0;
2296     }
2297     + ent->orig_tag[0] = ent->tag[0];
2298     + ent->orig_tag[1] = ent->tag[1];
2299    
2300     if (esp_alloc_lun_tag(ent, lp) < 0)
2301     continue;
2302     diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
2303     index 28e22ac..cd68805 100644
2304     --- a/drivers/scsi/esp_scsi.h
2305     +++ b/drivers/scsi/esp_scsi.h
2306     @@ -271,6 +271,7 @@ struct esp_cmd_entry {
2307     #define ESP_CMD_FLAG_AUTOSENSE 0x04 /* Doing automatic REQUEST_SENSE */
2308    
2309     u8 tag[2];
2310     + u8 orig_tag[2];
2311    
2312     u8 status;
2313     u8 message;
2314     diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
2315     index 3f71f0f..05eb6fe 100644
2316     --- a/drivers/staging/comedi/drivers/ni_65xx.c
2317     +++ b/drivers/staging/comedi/drivers/ni_65xx.c
2318     @@ -383,28 +383,23 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
2319     {
2320     const struct ni_65xx_board *board = comedi_board(dev);
2321     struct ni_65xx_private *devpriv = dev->private;
2322     - unsigned base_bitfield_channel;
2323     - const unsigned max_ports_per_bitfield = 5;
2324     + int base_bitfield_channel;
2325     unsigned read_bits = 0;
2326     - unsigned j;
2327     + int last_port_offset = ni_65xx_port_by_channel(s->n_chan - 1);
2328     + int port_offset;
2329    
2330     base_bitfield_channel = CR_CHAN(insn->chanspec);
2331     - for (j = 0; j < max_ports_per_bitfield; ++j) {
2332     - const unsigned port_offset =
2333     - ni_65xx_port_by_channel(base_bitfield_channel) + j;
2334     - const unsigned port =
2335     - sprivate(s)->base_port + port_offset;
2336     - unsigned base_port_channel;
2337     + for (port_offset = ni_65xx_port_by_channel(base_bitfield_channel);
2338     + port_offset <= last_port_offset; port_offset++) {
2339     + unsigned port = sprivate(s)->base_port + port_offset;
2340     + int base_port_channel = port_offset * ni_65xx_channels_per_port;
2341     unsigned port_mask, port_data, port_read_bits;
2342     - int bitshift;
2343     - if (port >= ni_65xx_total_num_ports(board))
2344     + int bitshift = base_port_channel - base_bitfield_channel;
2345     +
2346     + if (bitshift >= 32)
2347     break;
2348     - base_port_channel = port_offset * ni_65xx_channels_per_port;
2349     port_mask = data[0];
2350     port_data = data[1];
2351     - bitshift = base_port_channel - base_bitfield_channel;
2352     - if (bitshift >= 32 || bitshift <= -32)
2353     - break;
2354     if (bitshift > 0) {
2355     port_mask >>= bitshift;
2356     port_data >>= bitshift;
2357     diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
2358     index 96e7fdb..77dad24 100644
2359     --- a/drivers/target/iscsi/iscsi_target_util.c
2360     +++ b/drivers/target/iscsi/iscsi_target_util.c
2361     @@ -734,7 +734,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
2362     * Fallthrough
2363     */
2364     case ISCSI_OP_SCSI_TMFUNC:
2365     - rc = transport_generic_free_cmd(&cmd->se_cmd, 1);
2366     + rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown);
2367     if (!rc && shutdown && se_cmd && se_cmd->se_sess) {
2368     __iscsit_free_cmd(cmd, true, shutdown);
2369     target_put_sess_cmd(se_cmd->se_sess, se_cmd);
2370     @@ -750,7 +750,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
2371     se_cmd = &cmd->se_cmd;
2372     __iscsit_free_cmd(cmd, true, shutdown);
2373    
2374     - rc = transport_generic_free_cmd(&cmd->se_cmd, 1);
2375     + rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown);
2376     if (!rc && shutdown && se_cmd->se_sess) {
2377     __iscsit_free_cmd(cmd, true, shutdown);
2378     target_put_sess_cmd(se_cmd->se_sess, se_cmd);
2379     diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
2380     index 682210d..4fc32c8 100644
2381     --- a/drivers/tty/hvc/hvc_xen.c
2382     +++ b/drivers/tty/hvc/hvc_xen.c
2383     @@ -636,6 +636,7 @@ struct console xenboot_console = {
2384     .name = "xenboot",
2385     .write = xenboot_write_console,
2386     .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
2387     + .index = -1,
2388     };
2389     #endif /* CONFIG_EARLY_PRINTK */
2390    
2391     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2392     index 1cf6f12..80a7104 100644
2393     --- a/drivers/usb/serial/option.c
2394     +++ b/drivers/usb/serial/option.c
2395     @@ -81,6 +81,7 @@ static void option_instat_callback(struct urb *urb);
2396    
2397     #define HUAWEI_VENDOR_ID 0x12D1
2398     #define HUAWEI_PRODUCT_E173 0x140C
2399     +#define HUAWEI_PRODUCT_E1750 0x1406
2400     #define HUAWEI_PRODUCT_K4505 0x1464
2401     #define HUAWEI_PRODUCT_K3765 0x1465
2402     #define HUAWEI_PRODUCT_K4605 0x14C6
2403     @@ -567,6 +568,8 @@ static const struct usb_device_id option_ids[] = {
2404     { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
2405     { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
2406     .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
2407     + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
2408     + .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
2409     { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
2410     { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1442, USB_CLASS_COMM, 0x02, 0xff) },
2411     { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff),
2412     diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
2413     index f8a0b0e..3aac8e9 100644
2414     --- a/fs/binfmt_elf.c
2415     +++ b/fs/binfmt_elf.c
2416     @@ -1415,7 +1415,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
2417     * long file_ofs
2418     * followed by COUNT filenames in ASCII: "FILE1" NUL "FILE2" NUL...
2419     */
2420     -static void fill_files_note(struct memelfnote *note)
2421     +static int fill_files_note(struct memelfnote *note)
2422     {
2423     struct vm_area_struct *vma;
2424     unsigned count, size, names_ofs, remaining, n;
2425     @@ -1430,11 +1430,11 @@ static void fill_files_note(struct memelfnote *note)
2426     names_ofs = (2 + 3 * count) * sizeof(data[0]);
2427     alloc:
2428     if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */
2429     - goto err;
2430     + return -EINVAL;
2431     size = round_up(size, PAGE_SIZE);
2432     data = vmalloc(size);
2433     if (!data)
2434     - goto err;
2435     + return -ENOMEM;
2436    
2437     start_end_ofs = data + 2;
2438     name_base = name_curpos = ((char *)data) + names_ofs;
2439     @@ -1487,7 +1487,7 @@ static void fill_files_note(struct memelfnote *note)
2440    
2441     size = name_curpos - (char *)data;
2442     fill_note(note, "CORE", NT_FILE, size, data);
2443     - err: ;
2444     + return 0;
2445     }
2446    
2447     #ifdef CORE_DUMP_USE_REGSET
2448     @@ -1688,8 +1688,8 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
2449     fill_auxv_note(&info->auxv, current->mm);
2450     info->size += notesize(&info->auxv);
2451    
2452     - fill_files_note(&info->files);
2453     - info->size += notesize(&info->files);
2454     + if (fill_files_note(&info->files) == 0)
2455     + info->size += notesize(&info->files);
2456    
2457     return 1;
2458     }
2459     @@ -1721,7 +1721,8 @@ static int write_note_info(struct elf_note_info *info,
2460     return 0;
2461     if (first && !writenote(&info->auxv, file, foffset))
2462     return 0;
2463     - if (first && !writenote(&info->files, file, foffset))
2464     + if (first && info->files.data &&
2465     + !writenote(&info->files, file, foffset))
2466     return 0;
2467    
2468     for (i = 1; i < info->thread_notes; ++i)
2469     @@ -1808,6 +1809,7 @@ static int elf_dump_thread_status(long signr, struct elf_thread_status *t)
2470    
2471     struct elf_note_info {
2472     struct memelfnote *notes;
2473     + struct memelfnote *notes_files;
2474     struct elf_prstatus *prstatus; /* NT_PRSTATUS */
2475     struct elf_prpsinfo *psinfo; /* NT_PRPSINFO */
2476     struct list_head thread_list;
2477     @@ -1898,9 +1900,12 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
2478    
2479     fill_siginfo_note(info->notes + 2, &info->csigdata, siginfo);
2480     fill_auxv_note(info->notes + 3, current->mm);
2481     - fill_files_note(info->notes + 4);
2482     + info->numnote = 4;
2483    
2484     - info->numnote = 5;
2485     + if (fill_files_note(info->notes + info->numnote) == 0) {
2486     + info->notes_files = info->notes + info->numnote;
2487     + info->numnote++;
2488     + }
2489    
2490     /* Try to dump the FPU. */
2491     info->prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, regs,
2492     @@ -1962,8 +1967,9 @@ static void free_note_info(struct elf_note_info *info)
2493     kfree(list_entry(tmp, struct elf_thread_status, list));
2494     }
2495    
2496     - /* Free data allocated by fill_files_note(): */
2497     - vfree(info->notes[4].data);
2498     + /* Free data possibly allocated by fill_files_note(): */
2499     + if (info->notes_files)
2500     + vfree(info->notes_files->data);
2501    
2502     kfree(info->prstatus);
2503     kfree(info->psinfo);
2504     @@ -2046,7 +2052,7 @@ static int elf_core_dump(struct coredump_params *cprm)
2505     struct vm_area_struct *vma, *gate_vma;
2506     struct elfhdr *elf = NULL;
2507     loff_t offset = 0, dataoff, foffset;
2508     - struct elf_note_info info;
2509     + struct elf_note_info info = { };
2510     struct elf_phdr *phdr4note = NULL;
2511     struct elf_shdr *shdr4extnum = NULL;
2512     Elf_Half e_phnum;
2513     diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
2514     index 0b272d0..3b6d20b 100644
2515     --- a/fs/btrfs/extent-tree.c
2516     +++ b/fs/btrfs/extent-tree.c
2517     @@ -2402,6 +2402,8 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
2518     default:
2519     WARN_ON(1);
2520     }
2521     + } else {
2522     + list_del_init(&locked_ref->cluster);
2523     }
2524     spin_unlock(&delayed_refs->lock);
2525    
2526     @@ -2424,7 +2426,6 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
2527     * list before we release it.
2528     */
2529     if (btrfs_delayed_ref_is_head(ref)) {
2530     - list_del_init(&locked_ref->cluster);
2531     btrfs_delayed_ref_unlock(locked_ref);
2532     locked_ref = NULL;
2533     }
2534     diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
2535     index 4febca4..b3896d5 100644
2536     --- a/fs/btrfs/relocation.c
2537     +++ b/fs/btrfs/relocation.c
2538     @@ -691,6 +691,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
2539     int cowonly;
2540     int ret;
2541     int err = 0;
2542     + bool need_check = true;
2543    
2544     path1 = btrfs_alloc_path();
2545     path2 = btrfs_alloc_path();
2546     @@ -914,6 +915,7 @@ again:
2547     cur->bytenr);
2548    
2549     lower = cur;
2550     + need_check = true;
2551     for (; level < BTRFS_MAX_LEVEL; level++) {
2552     if (!path2->nodes[level]) {
2553     BUG_ON(btrfs_root_bytenr(&root->root_item) !=
2554     @@ -957,14 +959,12 @@ again:
2555    
2556     /*
2557     * add the block to pending list if we
2558     - * need check its backrefs. only block
2559     - * at 'cur->level + 1' is added to the
2560     - * tail of pending list. this guarantees
2561     - * we check backrefs from lower level
2562     - * blocks to upper level blocks.
2563     + * need check its backrefs, we only do this once
2564     + * while walking up a tree as we will catch
2565     + * anything else later on.
2566     */
2567     - if (!upper->checked &&
2568     - level == cur->level + 1) {
2569     + if (!upper->checked && need_check) {
2570     + need_check = false;
2571     list_add_tail(&edge->list[UPPER],
2572     &list);
2573     } else
2574     diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
2575     index ba9690b..09ea0bd 100644
2576     --- a/fs/btrfs/send.c
2577     +++ b/fs/btrfs/send.c
2578     @@ -2524,7 +2524,8 @@ static int did_create_dir(struct send_ctx *sctx, u64 dir)
2579     di = btrfs_item_ptr(eb, slot, struct btrfs_dir_item);
2580     btrfs_dir_item_key_to_cpu(eb, di, &di_key);
2581    
2582     - if (di_key.objectid < sctx->send_progress) {
2583     + if (di_key.type != BTRFS_ROOT_ITEM_KEY &&
2584     + di_key.objectid < sctx->send_progress) {
2585     ret = 1;
2586     goto out;
2587     }
2588     diff --git a/fs/fuse/file.c b/fs/fuse/file.c
2589     index 473e845..4fafb84 100644
2590     --- a/fs/fuse/file.c
2591     +++ b/fs/fuse/file.c
2592     @@ -2468,6 +2468,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
2593     {
2594     struct fuse_file *ff = file->private_data;
2595     struct inode *inode = file->f_inode;
2596     + struct fuse_inode *fi = get_fuse_inode(inode);
2597     struct fuse_conn *fc = ff->fc;
2598     struct fuse_req *req;
2599     struct fuse_fallocate_in inarg = {
2600     @@ -2485,10 +2486,20 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
2601    
2602     if (lock_inode) {
2603     mutex_lock(&inode->i_mutex);
2604     - if (mode & FALLOC_FL_PUNCH_HOLE)
2605     - fuse_set_nowrite(inode);
2606     + if (mode & FALLOC_FL_PUNCH_HOLE) {
2607     + loff_t endbyte = offset + length - 1;
2608     + err = filemap_write_and_wait_range(inode->i_mapping,
2609     + offset, endbyte);
2610     + if (err)
2611     + goto out;
2612     +
2613     + fuse_sync_writes(inode);
2614     + }
2615     }
2616    
2617     + if (!(mode & FALLOC_FL_KEEP_SIZE))
2618     + set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
2619     +
2620     req = fuse_get_req_nopages(fc);
2621     if (IS_ERR(req)) {
2622     err = PTR_ERR(req);
2623     @@ -2521,11 +2532,11 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
2624     fuse_invalidate_attr(inode);
2625    
2626     out:
2627     - if (lock_inode) {
2628     - if (mode & FALLOC_FL_PUNCH_HOLE)
2629     - fuse_release_nowrite(inode);
2630     + if (!(mode & FALLOC_FL_KEEP_SIZE))
2631     + clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
2632     +
2633     + if (lock_inode)
2634     mutex_unlock(&inode->i_mutex);
2635     - }
2636    
2637     return err;
2638     }
2639     diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
2640     index 661a0f6..678cb89 100644
2641     --- a/fs/nfs/nfs4filelayoutdev.c
2642     +++ b/fs/nfs/nfs4filelayoutdev.c
2643     @@ -797,34 +797,34 @@ nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
2644     struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr;
2645     struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx];
2646     struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg);
2647     -
2648     - if (filelayout_test_devid_unavailable(devid))
2649     - return NULL;
2650     + struct nfs4_pnfs_ds *ret = ds;
2651    
2652     if (ds == NULL) {
2653     printk(KERN_ERR "NFS: %s: No data server for offset index %d\n",
2654     __func__, ds_idx);
2655     filelayout_mark_devid_invalid(devid);
2656     - return NULL;
2657     + goto out;
2658     }
2659     if (ds->ds_clp)
2660     - return ds;
2661     + goto out_test_devid;
2662    
2663     if (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) == 0) {
2664     struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode);
2665     int err;
2666    
2667     err = nfs4_ds_connect(s, ds);
2668     - if (err) {
2669     + if (err)
2670     nfs4_mark_deviceid_unavailable(devid);
2671     - ds = NULL;
2672     - }
2673     nfs4_clear_ds_conn_bit(ds);
2674     } else {
2675     /* Either ds is connected, or ds is NULL */
2676     nfs4_wait_ds_connect(ds);
2677     }
2678     - return ds;
2679     +out_test_devid:
2680     + if (filelayout_test_devid_unavailable(devid))
2681     + ret = NULL;
2682     +out:
2683     + return ret;
2684     }
2685    
2686     module_param(dataserver_retrans, uint, 0644);
2687     diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
2688     index 0ba6798..da27664 100644
2689     --- a/fs/nilfs2/page.c
2690     +++ b/fs/nilfs2/page.c
2691     @@ -94,6 +94,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)
2692     clear_buffer_nilfs_volatile(bh);
2693     clear_buffer_nilfs_checked(bh);
2694     clear_buffer_nilfs_redirected(bh);
2695     + clear_buffer_async_write(bh);
2696     clear_buffer_dirty(bh);
2697     if (nilfs_page_buffers_clean(page))
2698     __nilfs_clear_page_dirty(page);
2699     @@ -429,6 +430,7 @@ void nilfs_clear_dirty_page(struct page *page, bool silent)
2700     "discard block %llu, size %zu",
2701     (u64)bh->b_blocknr, bh->b_size);
2702     }
2703     + clear_buffer_async_write(bh);
2704     clear_buffer_dirty(bh);
2705     clear_buffer_nilfs_volatile(bh);
2706     clear_buffer_nilfs_checked(bh);
2707     diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
2708     index a5752a58..cbd6618 100644
2709     --- a/fs/nilfs2/segment.c
2710     +++ b/fs/nilfs2/segment.c
2711     @@ -665,7 +665,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
2712    
2713     bh = head = page_buffers(page);
2714     do {
2715     - if (!buffer_dirty(bh))
2716     + if (!buffer_dirty(bh) || buffer_async_write(bh))
2717     continue;
2718     get_bh(bh);
2719     list_add_tail(&bh->b_assoc_buffers, listp);
2720     @@ -699,7 +699,8 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode,
2721     for (i = 0; i < pagevec_count(&pvec); i++) {
2722     bh = head = page_buffers(pvec.pages[i]);
2723     do {
2724     - if (buffer_dirty(bh)) {
2725     + if (buffer_dirty(bh) &&
2726     + !buffer_async_write(bh)) {
2727     get_bh(bh);
2728     list_add_tail(&bh->b_assoc_buffers,
2729     listp);
2730     @@ -1579,6 +1580,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
2731    
2732     list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
2733     b_assoc_buffers) {
2734     + set_buffer_async_write(bh);
2735     if (bh->b_page != bd_page) {
2736     if (bd_page) {
2737     lock_page(bd_page);
2738     @@ -1592,6 +1594,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
2739    
2740     list_for_each_entry(bh, &segbuf->sb_payload_buffers,
2741     b_assoc_buffers) {
2742     + set_buffer_async_write(bh);
2743     if (bh == segbuf->sb_super_root) {
2744     if (bh->b_page != bd_page) {
2745     lock_page(bd_page);
2746     @@ -1677,6 +1680,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
2747     list_for_each_entry(segbuf, logs, sb_list) {
2748     list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
2749     b_assoc_buffers) {
2750     + clear_buffer_async_write(bh);
2751     if (bh->b_page != bd_page) {
2752     if (bd_page)
2753     end_page_writeback(bd_page);
2754     @@ -1686,6 +1690,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
2755    
2756     list_for_each_entry(bh, &segbuf->sb_payload_buffers,
2757     b_assoc_buffers) {
2758     + clear_buffer_async_write(bh);
2759     if (bh == segbuf->sb_super_root) {
2760     if (bh->b_page != bd_page) {
2761     end_page_writeback(bd_page);
2762     @@ -1755,6 +1760,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
2763     b_assoc_buffers) {
2764     set_buffer_uptodate(bh);
2765     clear_buffer_dirty(bh);
2766     + clear_buffer_async_write(bh);
2767     if (bh->b_page != bd_page) {
2768     if (bd_page)
2769     end_page_writeback(bd_page);
2770     @@ -1776,6 +1782,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
2771     b_assoc_buffers) {
2772     set_buffer_uptodate(bh);
2773     clear_buffer_dirty(bh);
2774     + clear_buffer_async_write(bh);
2775     clear_buffer_delay(bh);
2776     clear_buffer_nilfs_volatile(bh);
2777     clear_buffer_nilfs_redirected(bh);
2778     diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
2779     index 0b8b2a1..eca6f9d 100644
2780     --- a/fs/xfs/xfs_da_btree.c
2781     +++ b/fs/xfs/xfs_da_btree.c
2782     @@ -1223,6 +1223,7 @@ xfs_da3_node_toosmall(
2783     /* start with smaller blk num */
2784     forward = nodehdr.forw < nodehdr.back;
2785     for (i = 0; i < 2; forward = !forward, i++) {
2786     + struct xfs_da3_icnode_hdr thdr;
2787     if (forward)
2788     blkno = nodehdr.forw;
2789     else
2790     @@ -1235,10 +1236,10 @@ xfs_da3_node_toosmall(
2791     return(error);
2792    
2793     node = bp->b_addr;
2794     - xfs_da3_node_hdr_from_disk(&nodehdr, node);
2795     + xfs_da3_node_hdr_from_disk(&thdr, node);
2796     xfs_trans_brelse(state->args->trans, bp);
2797    
2798     - if (count - nodehdr.count >= 0)
2799     + if (count - thdr.count >= 0)
2800     break; /* fits with at least 25% to spare */
2801     }
2802     if (i >= 2) {
2803     diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h
2804     index d06079c..99b490b 100644
2805     --- a/include/asm-generic/hugetlb.h
2806     +++ b/include/asm-generic/hugetlb.h
2807     @@ -6,12 +6,12 @@ static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
2808     return mk_pte(page, pgprot);
2809     }
2810    
2811     -static inline int huge_pte_write(pte_t pte)
2812     +static inline unsigned long huge_pte_write(pte_t pte)
2813     {
2814     return pte_write(pte);
2815     }
2816    
2817     -static inline int huge_pte_dirty(pte_t pte)
2818     +static inline unsigned long huge_pte_dirty(pte_t pte)
2819     {
2820     return pte_dirty(pte);
2821     }
2822     diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
2823     index f7f1d71..089743a 100644
2824     --- a/include/linux/balloon_compaction.h
2825     +++ b/include/linux/balloon_compaction.h
2826     @@ -159,6 +159,26 @@ static inline bool balloon_page_movable(struct page *page)
2827     }
2828    
2829     /*
2830     + * isolated_balloon_page - identify an isolated balloon page on private
2831     + * compaction/migration page lists.
2832     + *
2833     + * After a compaction thread isolates a balloon page for migration, it raises
2834     + * the page refcount to prevent concurrent compaction threads from re-isolating
2835     + * the same page. For that reason putback_movable_pages(), or other routines
2836     + * that need to identify isolated balloon pages on private pagelists, cannot
2837     + * rely on balloon_page_movable() to accomplish the task.
2838     + */
2839     +static inline bool isolated_balloon_page(struct page *page)
2840     +{
2841     + /* Already isolated balloon pages, by default, have a raised refcount */
2842     + if (page_flags_cleared(page) && !page_mapped(page) &&
2843     + page_count(page) >= 2)
2844     + return __is_movable_balloon_page(page);
2845     +
2846     + return false;
2847     +}
2848     +
2849     +/*
2850     * balloon_page_insert - insert a page into the balloon's page list and make
2851     * the page->mapping assignment accordingly.
2852     * @page : page to be assigned as a 'balloon page'
2853     @@ -243,6 +263,11 @@ static inline bool balloon_page_movable(struct page *page)
2854     return false;
2855     }
2856    
2857     +static inline bool isolated_balloon_page(struct page *page)
2858     +{
2859     + return false;
2860     +}
2861     +
2862     static inline bool balloon_page_isolate(struct page *page)
2863     {
2864     return false;
2865     diff --git a/include/linux/hid.h b/include/linux/hid.h
2866     index 6e18550..4f8aa47 100644
2867     --- a/include/linux/hid.h
2868     +++ b/include/linux/hid.h
2869     @@ -746,6 +746,7 @@ struct hid_field *hidinput_get_led_field(struct hid_device *hid);
2870     unsigned int hidinput_count_leds(struct hid_device *hid);
2871     __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code);
2872     void hid_output_report(struct hid_report *report, __u8 *data);
2873     +u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
2874     struct hid_device *hid_allocate_device(void);
2875     struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
2876     int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
2877     diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
2878     index 09c2300..cb35835 100644
2879     --- a/include/linux/miscdevice.h
2880     +++ b/include/linux/miscdevice.h
2881     @@ -45,6 +45,7 @@
2882     #define MAPPER_CTRL_MINOR 236
2883     #define LOOP_CTRL_MINOR 237
2884     #define VHOST_NET_MINOR 238
2885     +#define UHID_MINOR 239
2886     #define MISC_DYNAMIC_MINOR 255
2887    
2888     struct device;
2889     diff --git a/include/net/addrconf.h b/include/net/addrconf.h
2890     index 01b1a1a..2510068 100644
2891     --- a/include/net/addrconf.h
2892     +++ b/include/net/addrconf.h
2893     @@ -73,6 +73,10 @@ extern int ipv6_chk_home_addr(struct net *net,
2894     const struct in6_addr *addr);
2895     #endif
2896    
2897     +bool ipv6_chk_custom_prefix(const struct in6_addr *addr,
2898     + const unsigned int prefix_len,
2899     + struct net_device *dev);
2900     +
2901     extern int ipv6_chk_prefix(const struct in6_addr *addr,
2902     struct net_device *dev);
2903    
2904     diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
2905     index e0512aa..0ef0006 100644
2906     --- a/include/net/bluetooth/hci.h
2907     +++ b/include/net/bluetooth/hci.h
2908     @@ -104,6 +104,7 @@ enum {
2909     enum {
2910     HCI_SETUP,
2911     HCI_AUTO_OFF,
2912     + HCI_RFKILLED,
2913     HCI_MGMT,
2914     HCI_PAIRABLE,
2915     HCI_SERVICE_CACHE,
2916     diff --git a/include/net/ip.h b/include/net/ip.h
2917     index a68f838..edfa591 100644
2918     --- a/include/net/ip.h
2919     +++ b/include/net/ip.h
2920     @@ -254,9 +254,11 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
2921    
2922     extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
2923    
2924     -static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
2925     +static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
2926     {
2927     - if (iph->frag_off & htons(IP_DF)) {
2928     + struct iphdr *iph = ip_hdr(skb);
2929     +
2930     + if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
2931     /* This is only to work around buggy Windows95/2000
2932     * VJ compression implementations. If the ID field
2933     * does not change, they drop every other packet in
2934     @@ -268,9 +270,11 @@ static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, str
2935     __ip_select_ident(iph, dst, 0);
2936     }
2937    
2938     -static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
2939     +static inline void ip_select_ident_more(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk, int more)
2940     {
2941     - if (iph->frag_off & htons(IP_DF)) {
2942     + struct iphdr *iph = ip_hdr(skb);
2943     +
2944     + if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
2945     if (sk && inet_sk(sk)->inet_daddr) {
2946     iph->id = htons(inet_sk(sk)->inet_id);
2947     inet_sk(sk)->inet_id += 1 + more;
2948     diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
2949     index 6ca975b..c2e542b 100644
2950     --- a/include/net/secure_seq.h
2951     +++ b/include/net/secure_seq.h
2952     @@ -3,7 +3,6 @@
2953    
2954     #include <linux/types.h>
2955    
2956     -extern void net_secret_init(void);
2957     extern __u32 secure_ip_id(__be32 daddr);
2958     extern __u32 secure_ipv6_id(const __be32 daddr[4]);
2959     extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
2960     diff --git a/kernel/softirq.c b/kernel/softirq.c
2961     index 3d6833f..787b3a0 100644
2962     --- a/kernel/softirq.c
2963     +++ b/kernel/softirq.c
2964     @@ -330,10 +330,19 @@ void irq_enter(void)
2965    
2966     static inline void invoke_softirq(void)
2967     {
2968     - if (!force_irqthreads)
2969     - __do_softirq();
2970     - else
2971     + if (!force_irqthreads) {
2972     + /*
2973     + * We can safely execute softirq on the current stack if
2974     + * it is the irq stack, because it should be near empty
2975     + * at this stage. But we have no way to know if the arch
2976     + * calls irq_exit() on the irq stack. So call softirq
2977     + * in its own stack to prevent from any overrun on top
2978     + * of a potentially deep task stack.
2979     + */
2980     + do_softirq();
2981     + } else {
2982     wakeup_softirqd();
2983     + }
2984     }
2985    
2986     static inline void tick_irq_exit(void)
2987     diff --git a/mm/bounce.c b/mm/bounce.c
2988     index c9f0a43..5a7d58f 100644
2989     --- a/mm/bounce.c
2990     +++ b/mm/bounce.c
2991     @@ -204,6 +204,8 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
2992     struct bio_vec *to, *from;
2993     unsigned i;
2994    
2995     + if (force)
2996     + goto bounce;
2997     bio_for_each_segment(from, *bio_orig, i)
2998     if (page_to_pfn(from->bv_page) > queue_bounce_pfn(q))
2999     goto bounce;
3000     diff --git a/mm/migrate.c b/mm/migrate.c
3001     index 6f0c244..25ca7ca 100644
3002     --- a/mm/migrate.c
3003     +++ b/mm/migrate.c
3004     @@ -103,7 +103,7 @@ void putback_movable_pages(struct list_head *l)
3005     list_del(&page->lru);
3006     dec_zone_page_state(page, NR_ISOLATED_ANON +
3007     page_is_file_cache(page));
3008     - if (unlikely(balloon_page_movable(page)))
3009     + if (unlikely(isolated_balloon_page(page)))
3010     balloon_page_putback(page);
3011     else
3012     putback_lru_page(page);
3013     diff --git a/mm/vmscan.c b/mm/vmscan.c
3014     index fa6a853..7dbdb6a 100644
3015     --- a/mm/vmscan.c
3016     +++ b/mm/vmscan.c
3017     @@ -48,6 +48,7 @@
3018     #include <asm/div64.h>
3019    
3020     #include <linux/swapops.h>
3021     +#include <linux/balloon_compaction.h>
3022    
3023     #include "internal.h"
3024    
3025     @@ -978,7 +979,8 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
3026     LIST_HEAD(clean_pages);
3027    
3028     list_for_each_entry_safe(page, next, page_list, lru) {
3029     - if (page_is_file_cache(page) && !PageDirty(page)) {
3030     + if (page_is_file_cache(page) && !PageDirty(page) &&
3031     + !isolated_balloon_page(page)) {
3032     ClearPageActive(page);
3033     list_move(&page->lru, &clean_pages);
3034     }
3035     diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
3036     index ace5e55..7c88f5f 100644
3037     --- a/net/bluetooth/hci_core.c
3038     +++ b/net/bluetooth/hci_core.c
3039     @@ -1123,7 +1123,11 @@ int hci_dev_open(__u16 dev)
3040     goto done;
3041     }
3042    
3043     - if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) {
3044     + /* Check for rfkill but allow the HCI setup stage to proceed
3045     + * (which in itself doesn't cause any RF activity).
3046     + */
3047     + if (test_bit(HCI_RFKILLED, &hdev->dev_flags) &&
3048     + !test_bit(HCI_SETUP, &hdev->dev_flags)) {
3049     ret = -ERFKILL;
3050     goto done;
3051     }
3052     @@ -1545,10 +1549,13 @@ static int hci_rfkill_set_block(void *data, bool blocked)
3053    
3054     BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
3055    
3056     - if (!blocked)
3057     - return 0;
3058     -
3059     - hci_dev_do_close(hdev);
3060     + if (blocked) {
3061     + set_bit(HCI_RFKILLED, &hdev->dev_flags);
3062     + if (!test_bit(HCI_SETUP, &hdev->dev_flags))
3063     + hci_dev_do_close(hdev);
3064     + } else {
3065     + clear_bit(HCI_RFKILLED, &hdev->dev_flags);
3066     +}
3067    
3068     return 0;
3069     }
3070     @@ -1570,9 +1577,13 @@ static void hci_power_on(struct work_struct *work)
3071     return;
3072     }
3073    
3074     - if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
3075     + if (test_bit(HCI_RFKILLED, &hdev->dev_flags)) {
3076     + clear_bit(HCI_AUTO_OFF, &hdev->dev_flags);
3077     + hci_dev_do_close(hdev);
3078     + } else if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
3079     queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
3080     HCI_AUTO_OFF_TIMEOUT);
3081     + }
3082    
3083     if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags))
3084     mgmt_index_added(hdev);
3085     @@ -2241,6 +2252,9 @@ int hci_register_dev(struct hci_dev *hdev)
3086     }
3087     }
3088    
3089     + if (hdev->rfkill && rfkill_blocked(hdev->rfkill))
3090     + set_bit(HCI_RFKILLED, &hdev->dev_flags);
3091     +
3092     set_bit(HCI_SETUP, &hdev->dev_flags);
3093    
3094     if (hdev->dev_type != HCI_AMP)
3095     diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
3096     index b93cd2e..dcaa6db 100644
3097     --- a/net/bluetooth/hci_event.c
3098     +++ b/net/bluetooth/hci_event.c
3099     @@ -3611,7 +3611,11 @@ static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
3100     cp.handle = cpu_to_le16(conn->handle);
3101    
3102     if (ltk->authenticated)
3103     - conn->sec_level = BT_SECURITY_HIGH;
3104     + conn->pending_sec_level = BT_SECURITY_HIGH;
3105     + else
3106     + conn->pending_sec_level = BT_SECURITY_MEDIUM;
3107     +
3108     + conn->enc_key_size = ltk->enc_size;
3109    
3110     hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
3111    
3112     diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
3113     index 940f5ac..de030f5 100644
3114     --- a/net/bluetooth/hidp/core.c
3115     +++ b/net/bluetooth/hidp/core.c
3116     @@ -231,17 +231,22 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
3117    
3118     static int hidp_send_report(struct hidp_session *session, struct hid_report *report)
3119     {
3120     - unsigned char buf[32], hdr;
3121     - int rsize;
3122     + unsigned char hdr;
3123     + u8 *buf;
3124     + int rsize, ret;
3125    
3126     - rsize = ((report->size - 1) >> 3) + 1 + (report->id > 0);
3127     - if (rsize > sizeof(buf))
3128     + buf = hid_alloc_report_buf(report, GFP_ATOMIC);
3129     + if (!buf)
3130     return -EIO;
3131    
3132     hid_output_report(report, buf);
3133     hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
3134    
3135     - return hidp_send_intr_message(session, hdr, buf, rsize);
3136     + rsize = ((report->size - 1) >> 3) + 1 + (report->id > 0);
3137     + ret = hidp_send_intr_message(session, hdr, buf, rsize);
3138     +
3139     + kfree(buf);
3140     + return ret;
3141     }
3142    
3143     static int hidp_get_raw_report(struct hid_device *hid,
3144     diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
3145     index f66a034..06873e8 100644
3146     --- a/net/bridge/br_netlink.c
3147     +++ b/net/bridge/br_netlink.c
3148     @@ -203,7 +203,7 @@ int br_getlink(struct sk_buff *skb, u32 pid, u32 seq,
3149     struct net_device *dev, u32 filter_mask)
3150     {
3151     int err = 0;
3152     - struct net_bridge_port *port = br_port_get_rcu(dev);
3153     + struct net_bridge_port *port = br_port_get_rtnl(dev);
3154    
3155     /* not a bridge port and */
3156     if (!port && !(filter_mask & RTEXT_FILTER_BRVLAN))
3157     @@ -443,7 +443,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)
3158     struct net_port_vlans *pv;
3159    
3160     if (br_port_exists(dev))
3161     - pv = nbp_get_vlan_info(br_port_get_rcu(dev));
3162     + pv = nbp_get_vlan_info(br_port_get_rtnl(dev));
3163     else if (dev->priv_flags & IFF_EBRIDGE)
3164     pv = br_get_vlan_info((struct net_bridge *)netdev_priv(dev));
3165     else
3166     diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
3167     index d2c043a..e696833 100644
3168     --- a/net/bridge/br_private.h
3169     +++ b/net/bridge/br_private.h
3170     @@ -183,13 +183,10 @@ struct net_bridge_port
3171    
3172     static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
3173     {
3174     - struct net_bridge_port *port =
3175     - rcu_dereference_rtnl(dev->rx_handler_data);
3176     -
3177     - return br_port_exists(dev) ? port : NULL;
3178     + return rcu_dereference(dev->rx_handler_data);
3179     }
3180    
3181     -static inline struct net_bridge_port *br_port_get_rtnl(struct net_device *dev)
3182     +static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
3183     {
3184     return br_port_exists(dev) ?
3185     rtnl_dereference(dev->rx_handler_data) : NULL;
3186     @@ -714,6 +711,7 @@ extern struct net_bridge_port *br_get_port(struct net_bridge *br,
3187     extern void br_init_port(struct net_bridge_port *p);
3188     extern void br_become_designated_port(struct net_bridge_port *p);
3189    
3190     +extern void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
3191     extern int br_set_forward_delay(struct net_bridge *br, unsigned long x);
3192     extern int br_set_hello_time(struct net_bridge *br, unsigned long x);
3193     extern int br_set_max_age(struct net_bridge *br, unsigned long x);
3194     diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
3195     index 1c0a50f..3c86f05 100644
3196     --- a/net/bridge/br_stp.c
3197     +++ b/net/bridge/br_stp.c
3198     @@ -209,7 +209,7 @@ static void br_record_config_information(struct net_bridge_port *p,
3199     p->designated_age = jiffies - bpdu->message_age;
3200    
3201     mod_timer(&p->message_age_timer, jiffies
3202     - + (p->br->max_age - bpdu->message_age));
3203     + + (bpdu->max_age - bpdu->message_age));
3204     }
3205    
3206     /* called under bridge lock */
3207     @@ -544,18 +544,27 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
3208    
3209     }
3210    
3211     +void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
3212     +{
3213     + br->bridge_forward_delay = t;
3214     + if (br_is_root_bridge(br))
3215     + br->forward_delay = br->bridge_forward_delay;
3216     +}
3217     +
3218     int br_set_forward_delay(struct net_bridge *br, unsigned long val)
3219     {
3220     unsigned long t = clock_t_to_jiffies(val);
3221     + int err = -ERANGE;
3222    
3223     + spin_lock_bh(&br->lock);
3224     if (br->stp_enabled != BR_NO_STP &&
3225     (t < BR_MIN_FORWARD_DELAY || t > BR_MAX_FORWARD_DELAY))
3226     - return -ERANGE;
3227     + goto unlock;
3228    
3229     - spin_lock_bh(&br->lock);
3230     - br->bridge_forward_delay = t;
3231     - if (br_is_root_bridge(br))
3232     - br->forward_delay = br->bridge_forward_delay;
3233     + __br_set_forward_delay(br, t);
3234     + err = 0;
3235     +
3236     +unlock:
3237     spin_unlock_bh(&br->lock);
3238     - return 0;
3239     + return err;
3240     }
3241     diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
3242     index d45e760..108084a 100644
3243     --- a/net/bridge/br_stp_if.c
3244     +++ b/net/bridge/br_stp_if.c
3245     @@ -129,6 +129,14 @@ static void br_stp_start(struct net_bridge *br)
3246     char *envp[] = { NULL };
3247    
3248     r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
3249     +
3250     + spin_lock_bh(&br->lock);
3251     +
3252     + if (br->bridge_forward_delay < BR_MIN_FORWARD_DELAY)
3253     + __br_set_forward_delay(br, BR_MIN_FORWARD_DELAY);
3254     + else if (br->bridge_forward_delay < BR_MAX_FORWARD_DELAY)
3255     + __br_set_forward_delay(br, BR_MAX_FORWARD_DELAY);
3256     +
3257     if (r == 0) {
3258     br->stp_enabled = BR_USER_STP;
3259     br_debug(br, "userspace STP started\n");
3260     @@ -137,10 +145,10 @@ static void br_stp_start(struct net_bridge *br)
3261     br_debug(br, "using kernel STP\n");
3262    
3263     /* To start timers on any ports left in blocking */
3264     - spin_lock_bh(&br->lock);
3265     br_port_state_selection(br);
3266     - spin_unlock_bh(&br->lock);
3267     }
3268     +
3269     + spin_unlock_bh(&br->lock);
3270     }
3271    
3272     static void br_stp_stop(struct net_bridge *br)
3273     diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
3274     index 2bd4b58..0f45522 100644
3275     --- a/net/caif/cfctrl.c
3276     +++ b/net/caif/cfctrl.c
3277     @@ -293,9 +293,10 @@ int cfctrl_linkup_request(struct cflayer *layer,
3278    
3279     count = cfctrl_cancel_req(&cfctrl->serv.layer,
3280     user_layer);
3281     - if (count != 1)
3282     + if (count != 1) {
3283     pr_err("Could not remove request (%d)", count);
3284     return -ENODEV;
3285     + }
3286     }
3287     return 0;
3288     }
3289     diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
3290     index c99cc37..44db78a 100644
3291     --- a/net/core/flow_dissector.c
3292     +++ b/net/core/flow_dissector.c
3293     @@ -149,8 +149,8 @@ ipv6:
3294     if (poff >= 0) {
3295     __be32 *ports, _ports;
3296    
3297     - nhoff += poff;
3298     - ports = skb_header_pointer(skb, nhoff, sizeof(_ports), &_ports);
3299     + ports = skb_header_pointer(skb, nhoff + poff,
3300     + sizeof(_ports), &_ports);
3301     if (ports)
3302     flow->ports = *ports;
3303     }
3304     @@ -347,7 +347,7 @@ u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
3305    
3306     if (queue_index != new_index && sk &&
3307     rcu_access_pointer(sk->sk_dst_cache))
3308     - sk_tx_queue_set(sk, queue_index);
3309     + sk_tx_queue_set(sk, new_index);
3310    
3311     queue_index = new_index;
3312     }
3313     diff --git a/net/core/netpoll.c b/net/core/netpoll.c
3314     index cec074b..b04f738 100644
3315     --- a/net/core/netpoll.c
3316     +++ b/net/core/netpoll.c
3317     @@ -550,7 +550,7 @@ static void netpoll_neigh_reply(struct sk_buff *skb, struct netpoll_info *npinfo
3318     return;
3319    
3320     proto = ntohs(eth_hdr(skb)->h_proto);
3321     - if (proto == ETH_P_IP) {
3322     + if (proto == ETH_P_ARP) {
3323     struct arphdr *arp;
3324     unsigned char *arp_ptr;
3325     /* No arp on this interface */
3326     @@ -1289,15 +1289,14 @@ EXPORT_SYMBOL_GPL(__netpoll_free_async);
3327    
3328     void netpoll_cleanup(struct netpoll *np)
3329     {
3330     - if (!np->dev)
3331     - return;
3332     -
3333     rtnl_lock();
3334     + if (!np->dev)
3335     + goto out;
3336     __netpoll_cleanup(np);
3337     - rtnl_unlock();
3338     -
3339     dev_put(np->dev);
3340     np->dev = NULL;
3341     +out:
3342     + rtnl_unlock();
3343     }
3344     EXPORT_SYMBOL(netpoll_cleanup);
3345    
3346     diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
3347     index 6a2f13c..3f1ec15 100644
3348     --- a/net/core/secure_seq.c
3349     +++ b/net/core/secure_seq.c
3350     @@ -10,11 +10,24 @@
3351    
3352     #include <net/secure_seq.h>
3353    
3354     -static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
3355     +#define NET_SECRET_SIZE (MD5_MESSAGE_BYTES / 4)
3356    
3357     -void net_secret_init(void)
3358     +static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
3359     +
3360     +static void net_secret_init(void)
3361     {
3362     - get_random_bytes(net_secret, sizeof(net_secret));
3363     + u32 tmp;
3364     + int i;
3365     +
3366     + if (likely(net_secret[0]))
3367     + return;
3368     +
3369     + for (i = NET_SECRET_SIZE; i > 0;) {
3370     + do {
3371     + get_random_bytes(&tmp, sizeof(tmp));
3372     + } while (!tmp);
3373     + cmpxchg(&net_secret[--i], 0, tmp);
3374     + }
3375     }
3376    
3377     #ifdef CONFIG_INET
3378     @@ -42,6 +55,7 @@ __u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr,
3379     u32 hash[MD5_DIGEST_WORDS];
3380     u32 i;
3381    
3382     + net_secret_init();
3383     memcpy(hash, saddr, 16);
3384     for (i = 0; i < 4; i++)
3385     secret[i] = net_secret[i] + (__force u32)daddr[i];
3386     @@ -63,6 +77,7 @@ u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
3387     u32 hash[MD5_DIGEST_WORDS];
3388     u32 i;
3389    
3390     + net_secret_init();
3391     memcpy(hash, saddr, 16);
3392     for (i = 0; i < 4; i++)
3393     secret[i] = net_secret[i] + (__force u32) daddr[i];
3394     @@ -82,6 +97,7 @@ __u32 secure_ip_id(__be32 daddr)
3395     {
3396     u32 hash[MD5_DIGEST_WORDS];
3397    
3398     + net_secret_init();
3399     hash[0] = (__force __u32) daddr;
3400     hash[1] = net_secret[13];
3401     hash[2] = net_secret[14];
3402     @@ -96,6 +112,7 @@ __u32 secure_ipv6_id(const __be32 daddr[4])
3403     {
3404     __u32 hash[4];
3405    
3406     + net_secret_init();
3407     memcpy(hash, daddr, 16);
3408     md5_transform(hash, net_secret);
3409    
3410     @@ -107,6 +124,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
3411     {
3412     u32 hash[MD5_DIGEST_WORDS];
3413    
3414     + net_secret_init();
3415     hash[0] = (__force u32)saddr;
3416     hash[1] = (__force u32)daddr;
3417     hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
3418     @@ -121,6 +139,7 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
3419     {
3420     u32 hash[MD5_DIGEST_WORDS];
3421    
3422     + net_secret_init();
3423     hash[0] = (__force u32)saddr;
3424     hash[1] = (__force u32)daddr;
3425     hash[2] = (__force u32)dport ^ net_secret[14];
3426     @@ -140,6 +159,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
3427     u32 hash[MD5_DIGEST_WORDS];
3428     u64 seq;
3429    
3430     + net_secret_init();
3431     hash[0] = (__force u32)saddr;
3432     hash[1] = (__force u32)daddr;
3433     hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
3434     @@ -164,6 +184,7 @@ u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
3435     u64 seq;
3436     u32 i;
3437    
3438     + net_secret_init();
3439     memcpy(hash, saddr, 16);
3440     for (i = 0; i < 4; i++)
3441     secret[i] = net_secret[i] + daddr[i];
3442     diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
3443     index 9c61f9c..6cf9f77 100644
3444     --- a/net/dccp/ipv6.c
3445     +++ b/net/dccp/ipv6.c
3446     @@ -135,6 +135,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
3447    
3448     if (dst)
3449     dst->ops->redirect(dst, sk, skb);
3450     + goto out;
3451     }
3452    
3453     if (type == ICMPV6_PKT_TOOBIG) {
3454     diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
3455     index d01be2a..c4adc31 100644
3456     --- a/net/ipv4/af_inet.c
3457     +++ b/net/ipv4/af_inet.c
3458     @@ -263,10 +263,8 @@ void build_ehash_secret(void)
3459     get_random_bytes(&rnd, sizeof(rnd));
3460     } while (rnd == 0);
3461    
3462     - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
3463     + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
3464     get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
3465     - net_secret_init();
3466     - }
3467     }
3468     EXPORT_SYMBOL(build_ehash_secret);
3469    
3470     diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
3471     index d8c2327..089b4af 100644
3472     --- a/net/ipv4/igmp.c
3473     +++ b/net/ipv4/igmp.c
3474     @@ -343,7 +343,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
3475     pip->saddr = fl4.saddr;
3476     pip->protocol = IPPROTO_IGMP;
3477     pip->tot_len = 0; /* filled in later */
3478     - ip_select_ident(pip, &rt->dst, NULL);
3479     + ip_select_ident(skb, &rt->dst, NULL);
3480     ((u8 *)&pip[1])[0] = IPOPT_RA;
3481     ((u8 *)&pip[1])[1] = 4;
3482     ((u8 *)&pip[1])[2] = 0;
3483     @@ -687,7 +687,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
3484     iph->daddr = dst;
3485     iph->saddr = fl4.saddr;
3486     iph->protocol = IPPROTO_IGMP;
3487     - ip_select_ident(iph, &rt->dst, NULL);
3488     + ip_select_ident(skb, &rt->dst, NULL);
3489     ((u8 *)&iph[1])[0] = IPOPT_RA;
3490     ((u8 *)&iph[1])[1] = 4;
3491     ((u8 *)&iph[1])[2] = 0;
3492     @@ -709,7 +709,7 @@ static void igmp_gq_timer_expire(unsigned long data)
3493    
3494     in_dev->mr_gq_running = 0;
3495     igmpv3_send_report(in_dev, NULL);
3496     - __in_dev_put(in_dev);
3497     + in_dev_put(in_dev);
3498     }
3499    
3500     static void igmp_ifc_timer_expire(unsigned long data)
3501     @@ -721,7 +721,7 @@ static void igmp_ifc_timer_expire(unsigned long data)
3502     in_dev->mr_ifc_count--;
3503     igmp_ifc_start_timer(in_dev, IGMP_Unsolicited_Report_Interval);
3504     }
3505     - __in_dev_put(in_dev);
3506     + in_dev_put(in_dev);
3507     }
3508    
3509     static void igmp_ifc_event(struct in_device *in_dev)
3510     diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
3511     index 000e3d2..33d5537 100644
3512     --- a/net/ipv4/inetpeer.c
3513     +++ b/net/ipv4/inetpeer.c
3514     @@ -32,8 +32,8 @@
3515     * At the moment of writing this notes identifier of IP packets is generated
3516     * to be unpredictable using this code only for packets subjected
3517     * (actually or potentially) to defragmentation. I.e. DF packets less than
3518     - * PMTU in size uses a constant ID and do not use this code (see
3519     - * ip_select_ident() in include/net/ip.h).
3520     + * PMTU in size when local fragmentation is disabled use a constant ID and do
3521     + * not use this code (see ip_select_ident() in include/net/ip.h).
3522     *
3523     * Route cache entries hold references to our nodes.
3524     * New cache entries get references via lookup by destination IP address in
3525     diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
3526     index 4bcabf3..ec2d430 100644
3527     --- a/net/ipv4/ip_output.c
3528     +++ b/net/ipv4/ip_output.c
3529     @@ -148,7 +148,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
3530     iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
3531     iph->saddr = saddr;
3532     iph->protocol = sk->sk_protocol;
3533     - ip_select_ident(iph, &rt->dst, sk);
3534     + ip_select_ident(skb, &rt->dst, sk);
3535    
3536     if (opt && opt->opt.optlen) {
3537     iph->ihl += opt->opt.optlen>>2;
3538     @@ -394,7 +394,7 @@ packet_routed:
3539     ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
3540     }
3541    
3542     - ip_select_ident_more(iph, &rt->dst, sk,
3543     + ip_select_ident_more(skb, &rt->dst, sk,
3544     (skb_shinfo(skb)->gso_segs ?: 1) - 1);
3545    
3546     skb->priority = sk->sk_priority;
3547     @@ -1324,7 +1324,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
3548     else
3549     ttl = ip_select_ttl(inet, &rt->dst);
3550    
3551     - iph = (struct iphdr *)skb->data;
3552     + iph = ip_hdr(skb);
3553     iph->version = 4;
3554     iph->ihl = 5;
3555     iph->tos = inet->tos;
3556     @@ -1332,7 +1332,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
3557     iph->ttl = ttl;
3558     iph->protocol = sk->sk_protocol;
3559     ip_copy_addrs(iph, fl4);
3560     - ip_select_ident(iph, &rt->dst, sk);
3561     + ip_select_ident(skb, &rt->dst, sk);
3562    
3563     if (opt) {
3564     iph->ihl += opt->optlen>>2;
3565     diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
3566     index b7a4c21..92d2f0f 100644
3567     --- a/net/ipv4/ip_tunnel.c
3568     +++ b/net/ipv4/ip_tunnel.c
3569     @@ -659,13 +659,13 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
3570    
3571     max_headroom = LL_RESERVED_SPACE(tdev) + sizeof(struct iphdr)
3572     + rt->dst.header_len;
3573     - if (max_headroom > dev->needed_headroom) {
3574     + if (max_headroom > dev->needed_headroom)
3575     dev->needed_headroom = max_headroom;
3576     - if (skb_cow_head(skb, dev->needed_headroom)) {
3577     - dev->stats.tx_dropped++;
3578     - dev_kfree_skb(skb);
3579     - return;
3580     - }
3581     +
3582     + if (skb_cow_head(skb, dev->needed_headroom)) {
3583     + dev->stats.tx_dropped++;
3584     + dev_kfree_skb(skb);
3585     + return;
3586     }
3587    
3588     skb_dst_drop(skb);
3589     diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
3590     index 9d9610a..2c581da 100644
3591     --- a/net/ipv4/ipmr.c
3592     +++ b/net/ipv4/ipmr.c
3593     @@ -1658,7 +1658,7 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
3594     iph->protocol = IPPROTO_IPIP;
3595     iph->ihl = 5;
3596     iph->tot_len = htons(skb->len);
3597     - ip_select_ident(iph, skb_dst(skb), NULL);
3598     + ip_select_ident(skb, skb_dst(skb), NULL);
3599     ip_send_check(iph);
3600    
3601     memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
3602     diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
3603     index 61e60d6..6fb2337 100644
3604     --- a/net/ipv4/raw.c
3605     +++ b/net/ipv4/raw.c
3606     @@ -387,7 +387,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
3607     iph->check = 0;
3608     iph->tot_len = htons(length);
3609     if (!iph->id)
3610     - ip_select_ident(iph, &rt->dst, NULL);
3611     + ip_select_ident(skb, &rt->dst, NULL);
3612    
3613     iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
3614     }
3615     diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
3616     index 2005561..2b1b57f 100644
3617     --- a/net/ipv4/tcp.c
3618     +++ b/net/ipv4/tcp.c
3619     @@ -2447,10 +2447,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
3620     case TCP_THIN_DUPACK:
3621     if (val < 0 || val > 1)
3622     err = -EINVAL;
3623     - else
3624     + else {
3625     tp->thin_dupack = val;
3626     if (tp->thin_dupack)
3627     tcp_disable_early_retrans(tp);
3628     + }
3629     break;
3630    
3631     case TCP_REPAIR:
3632     diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
3633     index eb1dd4d..b5663c3 100644
3634     --- a/net/ipv4/xfrm4_mode_tunnel.c
3635     +++ b/net/ipv4/xfrm4_mode_tunnel.c
3636     @@ -117,7 +117,7 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
3637    
3638     top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
3639     0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF));
3640     - ip_select_ident(top_iph, dst->child, NULL);
3641     + ip_select_ident(skb, dst->child, NULL);
3642    
3643     top_iph->ttl = ip4_dst_hoplimit(dst->child);
3644    
3645     diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
3646     index d3057f9..b78a3ee 100644
3647     --- a/net/ipv6/addrconf.c
3648     +++ b/net/ipv6/addrconf.c
3649     @@ -1533,6 +1533,33 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
3650     return false;
3651     }
3652    
3653     +/* Compares an address/prefix_len with addresses on device @dev.
3654     + * If one is found it returns true.
3655     + */
3656     +bool ipv6_chk_custom_prefix(const struct in6_addr *addr,
3657     + const unsigned int prefix_len, struct net_device *dev)
3658     +{
3659     + struct inet6_dev *idev;
3660     + struct inet6_ifaddr *ifa;
3661     + bool ret = false;
3662     +
3663     + rcu_read_lock();
3664     + idev = __in6_dev_get(dev);
3665     + if (idev) {
3666     + read_lock_bh(&idev->lock);
3667     + list_for_each_entry(ifa, &idev->addr_list, if_list) {
3668     + ret = ipv6_prefix_equal(addr, &ifa->addr, prefix_len);
3669     + if (ret)
3670     + break;
3671     + }
3672     + read_unlock_bh(&idev->lock);
3673     + }
3674     + rcu_read_unlock();
3675     +
3676     + return ret;
3677     +}
3678     +EXPORT_SYMBOL(ipv6_chk_custom_prefix);
3679     +
3680     int ipv6_chk_prefix(const struct in6_addr *addr, struct net_device *dev)
3681     {
3682     struct inet6_dev *idev;
3683     diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
3684     index 07a7d65..8d67900 100644
3685     --- a/net/ipv6/exthdrs.c
3686     +++ b/net/ipv6/exthdrs.c
3687     @@ -162,12 +162,6 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs, struct sk_buff *skb)
3688     off += optlen;
3689     len -= optlen;
3690     }
3691     - /* This case will not be caught by above check since its padding
3692     - * length is smaller than 7:
3693     - * 1 byte NH + 1 byte Length + 6 bytes Padding
3694     - */
3695     - if ((padlen == 6) && ((off - skb_network_header_len(skb)) == 8))
3696     - goto bad;
3697    
3698     if (len == 0)
3699     return true;
3700     diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
3701     index 2221ff6..9c06ecb 100644
3702     --- a/net/ipv6/ip6_fib.c
3703     +++ b/net/ipv6/ip6_fib.c
3704     @@ -825,9 +825,9 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
3705     fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr),
3706     rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst),
3707     allow_create, replace_required);
3708     -
3709     if (IS_ERR(fn)) {
3710     err = PTR_ERR(fn);
3711     + fn = NULL;
3712     goto out;
3713     }
3714    
3715     diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
3716     index ecd6073..1f9a1a5 100644
3717     --- a/net/ipv6/ip6_gre.c
3718     +++ b/net/ipv6/ip6_gre.c
3719     @@ -620,7 +620,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
3720     struct ip6_tnl *tunnel = netdev_priv(dev);
3721     struct net_device *tdev; /* Device to other host */
3722     struct ipv6hdr *ipv6h; /* Our new IP header */
3723     - unsigned int max_headroom; /* The extra header space needed */
3724     + unsigned int max_headroom = 0; /* The extra header space needed */
3725     int gre_hlen;
3726     struct ipv6_tel_txoption opt;
3727     int mtu;
3728     @@ -693,7 +693,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
3729     tunnel->err_count = 0;
3730     }
3731    
3732     - max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;
3733     + max_headroom += LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;
3734    
3735     if (skb_headroom(skb) < max_headroom || skb_shared(skb) ||
3736     (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
3737     diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
3738     index 6e3ddf8..44ffdb9 100644
3739     --- a/net/ipv6/ip6_output.c
3740     +++ b/net/ipv6/ip6_output.c
3741     @@ -1039,6 +1039,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
3742     * udp datagram
3743     */
3744     if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
3745     + struct frag_hdr fhdr;
3746     +
3747     skb = sock_alloc_send_skb(sk,
3748     hh_len + fragheaderlen + transhdrlen + 20,
3749     (flags & MSG_DONTWAIT), &err);
3750     @@ -1059,12 +1061,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
3751    
3752     skb->ip_summed = CHECKSUM_PARTIAL;
3753     skb->csum = 0;
3754     - }
3755     -
3756     - err = skb_append_datato_frags(sk,skb, getfrag, from,
3757     - (length - transhdrlen));
3758     - if (!err) {
3759     - struct frag_hdr fhdr;
3760    
3761     /* Specify the length of each IPv6 datagram fragment.
3762     * It has to be a multiple of 8.
3763     @@ -1075,15 +1071,10 @@ static inline int ip6_ufo_append_data(struct sock *sk,
3764     ipv6_select_ident(&fhdr, rt);
3765     skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
3766     __skb_queue_tail(&sk->sk_write_queue, skb);
3767     -
3768     - return 0;
3769     }
3770     - /* There is not enough support do UPD LSO,
3771     - * so follow normal path
3772     - */
3773     - kfree_skb(skb);
3774    
3775     - return err;
3776     + return skb_append_datato_frags(sk, skb, getfrag, from,
3777     + (length - transhdrlen));
3778     }
3779    
3780     static inline struct ipv6_opt_hdr *ip6_opt_dup(struct ipv6_opt_hdr *src,
3781     @@ -1250,27 +1241,27 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
3782     * --yoshfuji
3783     */
3784    
3785     - cork->length += length;
3786     - if (length > mtu) {
3787     - int proto = sk->sk_protocol;
3788     - if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){
3789     - ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
3790     - return -EMSGSIZE;
3791     - }
3792     -
3793     - if (proto == IPPROTO_UDP &&
3794     - (rt->dst.dev->features & NETIF_F_UFO)) {
3795     + if ((length > mtu) && dontfrag && (sk->sk_protocol == IPPROTO_UDP ||
3796     + sk->sk_protocol == IPPROTO_RAW)) {
3797     + ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
3798     + return -EMSGSIZE;
3799     + }
3800    
3801     - err = ip6_ufo_append_data(sk, getfrag, from, length,
3802     - hh_len, fragheaderlen,
3803     - transhdrlen, mtu, flags, rt);
3804     - if (err)
3805     - goto error;
3806     - return 0;
3807     - }
3808     + skb = skb_peek_tail(&sk->sk_write_queue);
3809     + cork->length += length;
3810     + if (((length > mtu) ||
3811     + (skb && skb_is_gso(skb))) &&
3812     + (sk->sk_protocol == IPPROTO_UDP) &&
3813     + (rt->dst.dev->features & NETIF_F_UFO)) {
3814     + err = ip6_ufo_append_data(sk, getfrag, from, length,
3815     + hh_len, fragheaderlen,
3816     + transhdrlen, mtu, flags, rt);
3817     + if (err)
3818     + goto error;
3819     + return 0;
3820     }
3821    
3822     - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
3823     + if (!skb)
3824     goto alloc_new_skb;
3825    
3826     while (length > 0) {
3827     diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
3828     index 1e55866..0516ebb 100644
3829     --- a/net/ipv6/ip6_tunnel.c
3830     +++ b/net/ipv6/ip6_tunnel.c
3831     @@ -1646,9 +1646,9 @@ static int ip6_tnl_fill_info(struct sk_buff *skb, const struct net_device *dev)
3832    
3833     if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
3834     nla_put(skb, IFLA_IPTUN_LOCAL, sizeof(struct in6_addr),
3835     - &parm->raddr) ||
3836     - nla_put(skb, IFLA_IPTUN_REMOTE, sizeof(struct in6_addr),
3837     &parm->laddr) ||
3838     + nla_put(skb, IFLA_IPTUN_REMOTE, sizeof(struct in6_addr),
3839     + &parm->raddr) ||
3840     nla_put_u8(skb, IFLA_IPTUN_TTL, parm->hop_limit) ||
3841     nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
3842     nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
3843     @@ -1732,6 +1732,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
3844     if (!ip6n->fb_tnl_dev)
3845     goto err_alloc_dev;
3846     dev_net_set(ip6n->fb_tnl_dev, net);
3847     + ip6n->fb_tnl_dev->rtnl_link_ops = &ip6_link_ops;
3848    
3849     err = ip6_fb_tnl_dev_init(ip6n->fb_tnl_dev);
3850     if (err < 0)
3851     diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
3852     index c3998c2..952eaed 100644
3853     --- a/net/ipv6/mcast.c
3854     +++ b/net/ipv6/mcast.c
3855     @@ -2158,7 +2158,7 @@ static void mld_gq_timer_expire(unsigned long data)
3856    
3857     idev->mc_gq_running = 0;
3858     mld_send_report(idev, NULL);
3859     - __in6_dev_put(idev);
3860     + in6_dev_put(idev);
3861     }
3862    
3863     static void mld_ifc_timer_expire(unsigned long data)
3864     @@ -2171,7 +2171,7 @@ static void mld_ifc_timer_expire(unsigned long data)
3865     if (idev->mc_ifc_count)
3866     mld_ifc_start_timer(idev, idev->mc_maxdelay);
3867     }
3868     - __in6_dev_put(idev);
3869     + in6_dev_put(idev);
3870     }
3871    
3872     static void mld_ifc_event(struct inet6_dev *idev)
3873     diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
3874     index 60df36d..0491264 100644
3875     --- a/net/ipv6/sit.c
3876     +++ b/net/ipv6/sit.c
3877     @@ -566,6 +566,70 @@ static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr,
3878     return false;
3879     }
3880    
3881     +/* Checks if an address matches an address on the tunnel interface.
3882     + * Used to detect the NAT of proto 41 packets and let them pass spoofing test.
3883     + * Long story:
3884     + * This function is called after we considered the packet as spoofed
3885     + * in is_spoofed_6rd.
3886     + * We may have a router that is doing NAT for proto 41 packets
3887     + * for an internal station. Destination a.a.a.a/PREFIX:bbbb:bbbb
3888     + * will be translated to n.n.n.n/PREFIX:bbbb:bbbb. And is_spoofed_6rd
3889     + * function will return true, dropping the packet.
3890     + * But, we can still check if is spoofed against the IP
3891     + * addresses associated with the interface.
3892     + */
3893     +static bool only_dnatted(const struct ip_tunnel *tunnel,
3894     + const struct in6_addr *v6dst)
3895     +{
3896     + int prefix_len;
3897     +
3898     +#ifdef CONFIG_IPV6_SIT_6RD
3899     + prefix_len = tunnel->ip6rd.prefixlen + 32
3900     + - tunnel->ip6rd.relay_prefixlen;
3901     +#else
3902     + prefix_len = 48;
3903     +#endif
3904     + return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev);
3905     +}
3906     +
3907     +/* Returns true if a packet is spoofed */
3908     +static bool packet_is_spoofed(struct sk_buff *skb,
3909     + const struct iphdr *iph,
3910     + struct ip_tunnel *tunnel)
3911     +{
3912     + const struct ipv6hdr *ipv6h;
3913     +
3914     + if (tunnel->dev->priv_flags & IFF_ISATAP) {
3915     + if (!isatap_chksrc(skb, iph, tunnel))
3916     + return true;
3917     +
3918     + return false;
3919     + }
3920     +
3921     + if (tunnel->dev->flags & IFF_POINTOPOINT)
3922     + return false;
3923     +
3924     + ipv6h = ipv6_hdr(skb);
3925     +
3926     + if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) {
3927     + net_warn_ratelimited("Src spoofed %pI4/%pI6c -> %pI4/%pI6c\n",
3928     + &iph->saddr, &ipv6h->saddr,
3929     + &iph->daddr, &ipv6h->daddr);
3930     + return true;
3931     + }
3932     +
3933     + if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr)))
3934     + return false;
3935     +
3936     + if (only_dnatted(tunnel, &ipv6h->daddr))
3937     + return false;
3938     +
3939     + net_warn_ratelimited("Dst spoofed %pI4/%pI6c -> %pI4/%pI6c\n",
3940     + &iph->saddr, &ipv6h->saddr,
3941     + &iph->daddr, &ipv6h->daddr);
3942     + return true;
3943     +}
3944     +
3945     static int ipip6_rcv(struct sk_buff *skb)
3946     {
3947     const struct iphdr *iph = ip_hdr(skb);
3948     @@ -584,19 +648,9 @@ static int ipip6_rcv(struct sk_buff *skb)
3949     skb->protocol = htons(ETH_P_IPV6);
3950     skb->pkt_type = PACKET_HOST;
3951    
3952     - if (tunnel->dev->priv_flags & IFF_ISATAP) {
3953     - if (!isatap_chksrc(skb, iph, tunnel)) {
3954     - tunnel->dev->stats.rx_errors++;
3955     - goto out;
3956     - }
3957     - } else if (!(tunnel->dev->flags&IFF_POINTOPOINT)) {
3958     - if (is_spoofed_6rd(tunnel, iph->saddr,
3959     - &ipv6_hdr(skb)->saddr) ||
3960     - is_spoofed_6rd(tunnel, iph->daddr,
3961     - &ipv6_hdr(skb)->daddr)) {
3962     - tunnel->dev->stats.rx_errors++;
3963     - goto out;
3964     - }
3965     + if (packet_is_spoofed(skb, iph, tunnel)) {
3966     + tunnel->dev->stats.rx_errors++;
3967     + goto out;
3968     }
3969    
3970     __skb_tunnel_rx(skb, tunnel->dev);
3971     @@ -713,7 +767,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
3972     neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
3973    
3974     if (neigh == NULL) {
3975     - net_dbg_ratelimited("sit: nexthop == NULL\n");
3976     + net_dbg_ratelimited("nexthop == NULL\n");
3977     goto tx_error;
3978     }
3979    
3980     @@ -742,7 +796,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
3981     neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
3982    
3983     if (neigh == NULL) {
3984     - net_dbg_ratelimited("sit: nexthop == NULL\n");
3985     + net_dbg_ratelimited("nexthop == NULL\n");
3986     goto tx_error;
3987     }
3988    
3989     @@ -865,7 +919,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
3990     iph->ttl = iph6->hop_limit;
3991    
3992     skb->ip_summed = CHECKSUM_NONE;
3993     - ip_select_ident(iph, skb_dst(skb), NULL);
3994     + ip_select_ident(skb, skb_dst(skb), NULL);
3995     iptunnel_xmit(skb, dev);
3996     return NETDEV_TX_OK;
3997    
3998     @@ -1507,6 +1561,7 @@ static int __net_init sit_init_net(struct net *net)
3999     goto err_alloc_dev;
4000     }
4001     dev_net_set(sitn->fb_tunnel_dev, net);
4002     + sitn->fb_tunnel_dev->rtnl_link_ops = &sit_link_ops;
4003    
4004     err = ipip6_fb_tunnel_init(sitn->fb_tunnel_dev);
4005     if (err)
4006     diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
4007     index b75ff64..c47444e 100644
4008     --- a/net/netfilter/ipvs/ip_vs_xmit.c
4009     +++ b/net/netfilter/ipvs/ip_vs_xmit.c
4010     @@ -883,7 +883,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
4011     iph->daddr = cp->daddr.ip;
4012     iph->saddr = saddr;
4013     iph->ttl = old_iph->ttl;
4014     - ip_select_ident(iph, &rt->dst, NULL);
4015     + ip_select_ident(skb, &rt->dst, NULL);
4016    
4017     /* Another hack: avoid icmp_send in ip_fragment */
4018     skb->local_df = 1;
4019     diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
4020     index 910667c..e09b074 100644
4021     --- a/net/sched/sch_htb.c
4022     +++ b/net/sched/sch_htb.c
4023     @@ -1476,7 +1476,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
4024     psched_ratecfg_precompute(&cl->ceil, &hopt->ceil);
4025    
4026     cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
4027     - cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);
4028     + cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer);
4029    
4030     sch_tree_unlock(sch);
4031    
4032     diff --git a/net/sctp/input.c b/net/sctp/input.c
4033     index 4b2c831..bd4fb45 100644
4034     --- a/net/sctp/input.c
4035     +++ b/net/sctp/input.c
4036     @@ -648,8 +648,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
4037     break;
4038     case ICMP_REDIRECT:
4039     sctp_icmp_redirect(sk, transport, skb);
4040     - err = 0;
4041     - break;
4042     + /* Fall through to out_unlock. */
4043     default:
4044     goto out_unlock;
4045     }
4046     diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
4047     index 391a245..422d8bd 100644
4048     --- a/net/sctp/ipv6.c
4049     +++ b/net/sctp/ipv6.c
4050     @@ -189,7 +189,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
4051     break;
4052     case NDISC_REDIRECT:
4053     sctp_icmp_redirect(sk, transport, skb);
4054     - break;
4055     + goto out_unlock;
4056     default:
4057     break;
4058     }
4059     @@ -210,45 +210,24 @@ out:
4060     in6_dev_put(idev);
4061     }
4062    
4063     -/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
4064     static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
4065     {
4066     struct sock *sk = skb->sk;
4067     struct ipv6_pinfo *np = inet6_sk(sk);
4068     - struct flowi6 fl6;
4069     -
4070     - memset(&fl6, 0, sizeof(fl6));
4071     -
4072     - fl6.flowi6_proto = sk->sk_protocol;
4073     -
4074     - /* Fill in the dest address from the route entry passed with the skb
4075     - * and the source address from the transport.
4076     - */
4077     - fl6.daddr = transport->ipaddr.v6.sin6_addr;
4078     - fl6.saddr = transport->saddr.v6.sin6_addr;
4079     -
4080     - fl6.flowlabel = np->flow_label;
4081     - IP6_ECN_flow_xmit(sk, fl6.flowlabel);
4082     - if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
4083     - fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
4084     - else
4085     - fl6.flowi6_oif = sk->sk_bound_dev_if;
4086     -
4087     - if (np->opt && np->opt->srcrt) {
4088     - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
4089     - fl6.daddr = *rt0->addr;
4090     - }
4091     + struct flowi6 *fl6 = &transport->fl.u.ip6;
4092    
4093     SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n",
4094     __func__, skb, skb->len,
4095     - &fl6.saddr, &fl6.daddr);
4096     + &fl6->saddr, &fl6->daddr);
4097    
4098     - SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
4099     + IP6_ECN_flow_xmit(sk, fl6->flowlabel);
4100    
4101     if (!(transport->param_flags & SPP_PMTUD_ENABLE))
4102     skb->local_df = 1;
4103    
4104     - return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
4105     + SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
4106     +
4107     + return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
4108     }
4109    
4110     /* Returns the dst cache entry for the given source and destination ip
4111     @@ -261,10 +240,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
4112     struct dst_entry *dst = NULL;
4113     struct flowi6 *fl6 = &fl->u.ip6;
4114     struct sctp_bind_addr *bp;
4115     + struct ipv6_pinfo *np = inet6_sk(sk);
4116     struct sctp_sockaddr_entry *laddr;
4117     union sctp_addr *baddr = NULL;
4118     union sctp_addr *daddr = &t->ipaddr;
4119     union sctp_addr dst_saddr;
4120     + struct in6_addr *final_p, final;
4121     __u8 matchlen = 0;
4122     __u8 bmatchlen;
4123     sctp_scope_t scope;
4124     @@ -287,7 +268,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
4125     SCTP_DEBUG_PRINTK("SRC=%pI6 - ", &fl6->saddr);
4126     }
4127    
4128     - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
4129     + final_p = fl6_update_dst(fl6, np->opt, &final);
4130     + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
4131     if (!asoc || saddr)
4132     goto out;
4133    
4134     @@ -339,10 +321,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
4135     }
4136     }
4137     rcu_read_unlock();
4138     +
4139     if (baddr) {
4140     fl6->saddr = baddr->v6.sin6_addr;
4141     fl6->fl6_sport = baddr->v6.sin6_port;
4142     - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
4143     + final_p = fl6_update_dst(fl6, np->opt, &final);
4144     + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
4145     }
4146    
4147     out:
4148     diff --git a/net/sctp/socket.c b/net/sctp/socket.c
4149     index 6abb1ca..79bc251 100644
4150     --- a/net/sctp/socket.c
4151     +++ b/net/sctp/socket.c
4152     @@ -820,6 +820,9 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
4153     goto skip_mkasconf;
4154     }
4155    
4156     + if (laddr == NULL)
4157     + return -EINVAL;
4158     +
4159     /* We do not need RCU protection throughout this loop
4160     * because this is done under a socket lock from the
4161     * setsockopt call.
4162     @@ -6193,7 +6196,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
4163     /* Is there any exceptional events? */
4164     if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
4165     mask |= POLLERR |
4166     - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
4167     + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
4168     if (sk->sk_shutdown & RCV_SHUTDOWN)
4169     mask |= POLLRDHUP | POLLIN | POLLRDNORM;
4170     if (sk->sk_shutdown == SHUTDOWN_MASK)
4171     diff --git a/net/sysctl_net.c b/net/sysctl_net.c
4172     index 9bc6db0..e7000be 100644
4173     --- a/net/sysctl_net.c
4174     +++ b/net/sysctl_net.c
4175     @@ -47,12 +47,12 @@ static int net_ctl_permissions(struct ctl_table_header *head,
4176    
4177     /* Allow network administrator to have same access as root. */
4178     if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
4179     - uid_eq(root_uid, current_uid())) {
4180     + uid_eq(root_uid, current_euid())) {
4181     int mode = (table->mode >> 6) & 7;
4182     return (mode << 6) | (mode << 3) | mode;
4183     }
4184     /* Allow netns root group to have the same access as the root group */
4185     - if (gid_eq(root_gid, current_gid())) {
4186     + if (in_egroup_p(root_gid)) {
4187     int mode = (table->mode >> 3) & 7;
4188     return (mode << 3) | mode;
4189     }
4190     diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
4191     index b314d3e..c96e194 100644
4192     --- a/sound/pci/hda/patch_conexant.c
4193     +++ b/sound/pci/hda/patch_conexant.c
4194     @@ -3225,6 +3225,7 @@ enum {
4195     CXT_PINCFG_LEMOTE_A1205,
4196     CXT_FIXUP_STEREO_DMIC,
4197     CXT_FIXUP_INC_MIC_BOOST,
4198     + CXT_FIXUP_GPIO1,
4199     };
4200    
4201     static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
4202     @@ -3303,6 +3304,15 @@ static const struct hda_fixup cxt_fixups[] = {
4203     .type = HDA_FIXUP_FUNC,
4204     .v.func = cxt5066_increase_mic_boost,
4205     },
4206     + [CXT_FIXUP_GPIO1] = {
4207     + .type = HDA_FIXUP_VERBS,
4208     + .v.verbs = (const struct hda_verb[]) {
4209     + { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
4210     + { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
4211     + { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 },
4212     + { }
4213     + },
4214     + },
4215     };
4216    
4217     static const struct snd_pci_quirk cxt5051_fixups[] = {
4218     @@ -3312,6 +3322,7 @@ static const struct snd_pci_quirk cxt5051_fixups[] = {
4219    
4220     static const struct snd_pci_quirk cxt5066_fixups[] = {
4221     SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
4222     + SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1),
4223     SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
4224     SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
4225     SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
4226     diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
4227     index 60159c0..6fd174b 100644
4228     --- a/sound/soc/codecs/88pm860x-codec.c
4229     +++ b/sound/soc/codecs/88pm860x-codec.c
4230     @@ -351,6 +351,9 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
4231     val = ucontrol->value.integer.value[0];
4232     val2 = ucontrol->value.integer.value[1];
4233    
4234     + if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table))
4235     + return -EINVAL;
4236     +
4237     err = snd_soc_update_bits(codec, reg, 0x3f, st_table[val].m);
4238     if (err < 0)
4239     return err;
4240     diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
4241     index a153b16..bce45c1 100644
4242     --- a/sound/soc/codecs/ab8500-codec.c
4243     +++ b/sound/soc/codecs/ab8500-codec.c
4244     @@ -1225,13 +1225,18 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
4245     struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
4246     struct device *dev = codec->dev;
4247     bool apply_fir, apply_iir;
4248     - int req, status;
4249     + unsigned int req;
4250     + int status;
4251    
4252     dev_dbg(dev, "%s: Enter.\n", __func__);
4253    
4254     mutex_lock(&drvdata->anc_lock);
4255    
4256     req = ucontrol->value.integer.value[0];
4257     + if (req >= ARRAY_SIZE(enum_anc_state)) {
4258     + status = -EINVAL;
4259     + goto cleanup;
4260     + }
4261     if (req != ANC_APPLY_FIR_IIR && req != ANC_APPLY_FIR &&
4262     req != ANC_APPLY_IIR) {
4263     dev_err(dev, "%s: ERROR: Unsupported status to set '%s'!\n",
4264     diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
4265     index 41cdd16..8dbcacd 100644
4266     --- a/sound/soc/codecs/max98095.c
4267     +++ b/sound/soc/codecs/max98095.c
4268     @@ -1863,7 +1863,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
4269     struct max98095_pdata *pdata = max98095->pdata;
4270     int channel = max98095_get_eq_channel(kcontrol->id.name);
4271     struct max98095_cdata *cdata;
4272     - int sel = ucontrol->value.integer.value[0];
4273     + unsigned int sel = ucontrol->value.integer.value[0];
4274     struct max98095_eq_cfg *coef_set;
4275     int fs, best, best_val, i;
4276     int regmask, regsave;
4277     @@ -2016,7 +2016,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
4278     struct max98095_pdata *pdata = max98095->pdata;
4279     int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
4280     struct max98095_cdata *cdata;
4281     - int sel = ucontrol->value.integer.value[0];
4282     + unsigned int sel = ucontrol->value.integer.value[0];
4283     struct max98095_biquad_cfg *coef_set;
4284     int fs, best, best_val, i;
4285     int regmask, regsave;