Magellan Linux

Contents of /trunk/kernel-alx/patches-3.10/0124-3.10.25-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2360 - (show annotations) (download)
Fri Dec 27 12:14:31 2013 UTC (10 years, 4 months ago) by niro
File size: 88639 byte(s)
-linux-3.10.25
1 diff --git a/Makefile b/Makefile
2 index ae6ccebf8af4..cd97e9a25410 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 10
8 -SUBLEVEL = 24
9 +SUBLEVEL = 25
10 EXTRAVERSION =
11 NAME = TOSSUG Baby Fish
12
13 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
14 index ab1fe3bb31f0..ac4c2e5e17e4 100644
15 --- a/arch/arm/kernel/process.c
16 +++ b/arch/arm/kernel/process.c
17 @@ -408,6 +408,7 @@ EXPORT_SYMBOL(dump_fpu);
18 unsigned long get_wchan(struct task_struct *p)
19 {
20 struct stackframe frame;
21 + unsigned long stack_page;
22 int count = 0;
23 if (!p || p == current || p->state == TASK_RUNNING)
24 return 0;
25 @@ -416,9 +417,11 @@ unsigned long get_wchan(struct task_struct *p)
26 frame.sp = thread_saved_sp(p);
27 frame.lr = 0; /* recovered from the stack */
28 frame.pc = thread_saved_pc(p);
29 + stack_page = (unsigned long)task_stack_page(p);
30 do {
31 - int ret = unwind_frame(&frame);
32 - if (ret < 0)
33 + if (frame.sp < stack_page ||
34 + frame.sp >= stack_page + THREAD_SIZE ||
35 + unwind_frame(&frame) < 0)
36 return 0;
37 if (!in_sched_functions(frame.pc))
38 return frame.pc;
39 diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
40 index 00f79e59985b..af4e8c8a5422 100644
41 --- a/arch/arm/kernel/stacktrace.c
42 +++ b/arch/arm/kernel/stacktrace.c
43 @@ -31,7 +31,7 @@ int notrace unwind_frame(struct stackframe *frame)
44 high = ALIGN(low, THREAD_SIZE);
45
46 /* check current frame pointer is within bounds */
47 - if (fp < (low + 12) || fp + 4 >= high)
48 + if (fp < low + 12 || fp > high - 4)
49 return -EINVAL;
50
51 /* restore the registers from the stack frame */
52 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
53 index 7341eff63f56..44c609a1ec5d 100644
54 --- a/arch/arm/mach-omap2/omap_hwmod.c
55 +++ b/arch/arm/mach-omap2/omap_hwmod.c
56 @@ -399,7 +399,7 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
57 }
58
59 /**
60 - * _set_softreset: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v
61 + * _set_softreset: set OCP_SYSCONFIG.SOFTRESET bit in @v
62 * @oh: struct omap_hwmod *
63 * @v: pointer to register contents to modify
64 *
65 @@ -427,6 +427,36 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
66 }
67
68 /**
69 + * _clear_softreset: clear OCP_SYSCONFIG.SOFTRESET bit in @v
70 + * @oh: struct omap_hwmod *
71 + * @v: pointer to register contents to modify
72 + *
73 + * Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
74 + * error or 0 upon success.
75 + */
76 +static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
77 +{
78 + u32 softrst_mask;
79 +
80 + if (!oh->class->sysc ||
81 + !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
82 + return -EINVAL;
83 +
84 + if (!oh->class->sysc->sysc_fields) {
85 + WARN(1,
86 + "omap_hwmod: %s: sysc_fields absent for sysconfig class\n",
87 + oh->name);
88 + return -EINVAL;
89 + }
90 +
91 + softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
92 +
93 + *v &= ~softrst_mask;
94 +
95 + return 0;
96 +}
97 +
98 +/**
99 * _wait_softreset_complete - wait for an OCP softreset to complete
100 * @oh: struct omap_hwmod * to wait on
101 *
102 @@ -1909,6 +1939,12 @@ static int _ocp_softreset(struct omap_hwmod *oh)
103 ret = _set_softreset(oh, &v);
104 if (ret)
105 goto dis_opt_clks;
106 +
107 + _write_sysconfig(v, oh);
108 + ret = _clear_softreset(oh, &v);
109 + if (ret)
110 + goto dis_opt_clks;
111 +
112 _write_sysconfig(v, oh);
113
114 if (oh->class->sysc->srst_udelay)
115 @@ -3148,6 +3184,11 @@ int omap_hwmod_softreset(struct omap_hwmod *oh)
116 goto error;
117 _write_sysconfig(v, oh);
118
119 + ret = _clear_softreset(oh, &v);
120 + if (ret)
121 + goto error;
122 + _write_sysconfig(v, oh);
123 +
124 error:
125 return ret;
126 }
127 diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
128 index 31c7126eb3bb..02b1b10537bc 100644
129 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
130 +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
131 @@ -1930,7 +1930,8 @@ static struct omap_hwmod_class_sysconfig omap3xxx_usb_host_hs_sysc = {
132 .syss_offs = 0x0014,
133 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
134 SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP |
135 - SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE),
136 + SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
137 + SYSS_HAS_RESET_STATUS),
138 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
139 MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
140 .sysc_fields = &omap_hwmod_sysc_type1,
141 @@ -2008,15 +2009,7 @@ static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = {
142 * hence HWMOD_SWSUP_MSTANDBY
143 */
144
145 - /*
146 - * During system boot; If the hwmod framework resets the module
147 - * the module will have smart idle settings; which can lead to deadlock
148 - * (above Errata Id:i660); so, dont reset the module during boot;
149 - * Use HWMOD_INIT_NO_RESET.
150 - */
151 -
152 - .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
153 - HWMOD_INIT_NO_RESET,
154 + .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
155 };
156
157 /*
158 diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
159 index 3fab583755d4..0616390b857f 100644
160 --- a/arch/arm/mach-pxa/reset.c
161 +++ b/arch/arm/mach-pxa/reset.c
162 @@ -13,6 +13,7 @@
163
164 #include <mach/regs-ost.h>
165 #include <mach/reset.h>
166 +#include <mach/smemc.h>
167
168 unsigned int reset_status;
169 EXPORT_SYMBOL(reset_status);
170 @@ -81,6 +82,12 @@ static void do_hw_reset(void)
171 writel_relaxed(OSSR_M3, OSSR);
172 /* ... in 100 ms */
173 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
174 + /*
175 + * SDRAM hangs on watchdog reset on Marvell PXA270 (erratum 71)
176 + * we put SDRAM into self-refresh to prevent that
177 + */
178 + while (1)
179 + writel_relaxed(MDREFR_SLFRSH, MDREFR);
180 }
181
182 void pxa_restart(char mode, const char *cmd)
183 @@ -104,4 +111,3 @@ void pxa_restart(char mode, const char *cmd)
184 break;
185 }
186 }
187 -
188 diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
189 index 3d91d2e5bf3a..d91fcf403cee 100644
190 --- a/arch/arm/mach-pxa/tosa.c
191 +++ b/arch/arm/mach-pxa/tosa.c
192 @@ -424,57 +424,57 @@ static struct platform_device tosa_power_device = {
193 * Tosa Keyboard
194 */
195 static const uint32_t tosakbd_keymap[] = {
196 - KEY(0, 2, KEY_W),
197 - KEY(0, 6, KEY_K),
198 - KEY(0, 7, KEY_BACKSPACE),
199 - KEY(0, 8, KEY_P),
200 - KEY(1, 1, KEY_Q),
201 - KEY(1, 2, KEY_E),
202 - KEY(1, 3, KEY_T),
203 - KEY(1, 4, KEY_Y),
204 - KEY(1, 6, KEY_O),
205 - KEY(1, 7, KEY_I),
206 - KEY(1, 8, KEY_COMMA),
207 - KEY(2, 1, KEY_A),
208 - KEY(2, 2, KEY_D),
209 - KEY(2, 3, KEY_G),
210 - KEY(2, 4, KEY_U),
211 - KEY(2, 6, KEY_L),
212 - KEY(2, 7, KEY_ENTER),
213 - KEY(2, 8, KEY_DOT),
214 - KEY(3, 1, KEY_Z),
215 - KEY(3, 2, KEY_C),
216 - KEY(3, 3, KEY_V),
217 - KEY(3, 4, KEY_J),
218 - KEY(3, 5, TOSA_KEY_ADDRESSBOOK),
219 - KEY(3, 6, TOSA_KEY_CANCEL),
220 - KEY(3, 7, TOSA_KEY_CENTER),
221 - KEY(3, 8, TOSA_KEY_OK),
222 - KEY(3, 9, KEY_LEFTSHIFT),
223 - KEY(4, 1, KEY_S),
224 - KEY(4, 2, KEY_R),
225 - KEY(4, 3, KEY_B),
226 - KEY(4, 4, KEY_N),
227 - KEY(4, 5, TOSA_KEY_CALENDAR),
228 - KEY(4, 6, TOSA_KEY_HOMEPAGE),
229 - KEY(4, 7, KEY_LEFTCTRL),
230 - KEY(4, 8, TOSA_KEY_LIGHT),
231 - KEY(4, 10, KEY_RIGHTSHIFT),
232 - KEY(5, 1, KEY_TAB),
233 - KEY(5, 2, KEY_SLASH),
234 - KEY(5, 3, KEY_H),
235 - KEY(5, 4, KEY_M),
236 - KEY(5, 5, TOSA_KEY_MENU),
237 - KEY(5, 7, KEY_UP),
238 - KEY(5, 11, TOSA_KEY_FN),
239 - KEY(6, 1, KEY_X),
240 - KEY(6, 2, KEY_F),
241 - KEY(6, 3, KEY_SPACE),
242 - KEY(6, 4, KEY_APOSTROPHE),
243 - KEY(6, 5, TOSA_KEY_MAIL),
244 - KEY(6, 6, KEY_LEFT),
245 - KEY(6, 7, KEY_DOWN),
246 - KEY(6, 8, KEY_RIGHT),
247 + KEY(0, 1, KEY_W),
248 + KEY(0, 5, KEY_K),
249 + KEY(0, 6, KEY_BACKSPACE),
250 + KEY(0, 7, KEY_P),
251 + KEY(1, 0, KEY_Q),
252 + KEY(1, 1, KEY_E),
253 + KEY(1, 2, KEY_T),
254 + KEY(1, 3, KEY_Y),
255 + KEY(1, 5, KEY_O),
256 + KEY(1, 6, KEY_I),
257 + KEY(1, 7, KEY_COMMA),
258 + KEY(2, 0, KEY_A),
259 + KEY(2, 1, KEY_D),
260 + KEY(2, 2, KEY_G),
261 + KEY(2, 3, KEY_U),
262 + KEY(2, 5, KEY_L),
263 + KEY(2, 6, KEY_ENTER),
264 + KEY(2, 7, KEY_DOT),
265 + KEY(3, 0, KEY_Z),
266 + KEY(3, 1, KEY_C),
267 + KEY(3, 2, KEY_V),
268 + KEY(3, 3, KEY_J),
269 + KEY(3, 4, TOSA_KEY_ADDRESSBOOK),
270 + KEY(3, 5, TOSA_KEY_CANCEL),
271 + KEY(3, 6, TOSA_KEY_CENTER),
272 + KEY(3, 7, TOSA_KEY_OK),
273 + KEY(3, 8, KEY_LEFTSHIFT),
274 + KEY(4, 0, KEY_S),
275 + KEY(4, 1, KEY_R),
276 + KEY(4, 2, KEY_B),
277 + KEY(4, 3, KEY_N),
278 + KEY(4, 4, TOSA_KEY_CALENDAR),
279 + KEY(4, 5, TOSA_KEY_HOMEPAGE),
280 + KEY(4, 6, KEY_LEFTCTRL),
281 + KEY(4, 7, TOSA_KEY_LIGHT),
282 + KEY(4, 9, KEY_RIGHTSHIFT),
283 + KEY(5, 0, KEY_TAB),
284 + KEY(5, 1, KEY_SLASH),
285 + KEY(5, 2, KEY_H),
286 + KEY(5, 3, KEY_M),
287 + KEY(5, 4, TOSA_KEY_MENU),
288 + KEY(5, 6, KEY_UP),
289 + KEY(5, 10, TOSA_KEY_FN),
290 + KEY(6, 0, KEY_X),
291 + KEY(6, 1, KEY_F),
292 + KEY(6, 2, KEY_SPACE),
293 + KEY(6, 3, KEY_APOSTROPHE),
294 + KEY(6, 4, TOSA_KEY_MAIL),
295 + KEY(6, 5, KEY_LEFT),
296 + KEY(6, 6, KEY_DOWN),
297 + KEY(6, 7, KEY_RIGHT),
298 };
299
300 static struct matrix_keymap_data tosakbd_keymap_data = {
301 diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
302 index caf92ecb37d6..23129d1005db 100644
303 --- a/arch/mips/mm/dma-default.c
304 +++ b/arch/mips/mm/dma-default.c
305 @@ -50,16 +50,20 @@ static inline struct page *dma_addr_to_page(struct device *dev,
306 }
307
308 /*
309 + * The affected CPUs below in 'cpu_needs_post_dma_flush()' can
310 + * speculatively fill random cachelines with stale data at any time,
311 + * requiring an extra flush post-DMA.
312 + *
313 * Warning on the terminology - Linux calls an uncached area coherent;
314 * MIPS terminology calls memory areas with hardware maintained coherency
315 * coherent.
316 */
317 -
318 -static inline int cpu_is_noncoherent_r10000(struct device *dev)
319 +static inline int cpu_needs_post_dma_flush(struct device *dev)
320 {
321 return !plat_device_is_coherent(dev) &&
322 (current_cpu_type() == CPU_R10000 ||
323 - current_cpu_type() == CPU_R12000);
324 + current_cpu_type() == CPU_R12000 ||
325 + current_cpu_type() == CPU_BMIPS5000);
326 }
327
328 static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
329 @@ -230,7 +234,7 @@ static inline void __dma_sync(struct page *page,
330 static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
331 size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
332 {
333 - if (cpu_is_noncoherent_r10000(dev))
334 + if (cpu_needs_post_dma_flush(dev))
335 __dma_sync(dma_addr_to_page(dev, dma_addr),
336 dma_addr & ~PAGE_MASK, size, direction);
337
338 @@ -281,7 +285,7 @@ static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
339 static void mips_dma_sync_single_for_cpu(struct device *dev,
340 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
341 {
342 - if (cpu_is_noncoherent_r10000(dev))
343 + if (cpu_needs_post_dma_flush(dev))
344 __dma_sync(dma_addr_to_page(dev, dma_handle),
345 dma_handle & ~PAGE_MASK, size, direction);
346 }
347 @@ -302,7 +306,7 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev,
348
349 /* Make sure that gcc doesn't leave the empty loop body. */
350 for (i = 0; i < nelems; i++, sg++) {
351 - if (cpu_is_noncoherent_r10000(dev))
352 + if (cpu_needs_post_dma_flush(dev))
353 __dma_sync(sg_page(sg), sg->offset, sg->length,
354 direction);
355 }
356 diff --git a/arch/powerpc/include/asm/pgalloc-32.h b/arch/powerpc/include/asm/pgalloc-32.h
357 index 27b2386f738a..842846c1b711 100644
358 --- a/arch/powerpc/include/asm/pgalloc-32.h
359 +++ b/arch/powerpc/include/asm/pgalloc-32.h
360 @@ -84,10 +84,8 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
361 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
362 unsigned long address)
363 {
364 - struct page *page = page_address(table);
365 -
366 tlb_flush_pgtable(tlb, address);
367 - pgtable_page_dtor(page);
368 - pgtable_free_tlb(tlb, page, 0);
369 + pgtable_page_dtor(table);
370 + pgtable_free_tlb(tlb, page_address(table), 0);
371 }
372 #endif /* _ASM_POWERPC_PGALLOC_32_H */
373 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
374 index b66ae722a8e9..64aaf016b478 100644
375 --- a/arch/powerpc/include/asm/pgalloc-64.h
376 +++ b/arch/powerpc/include/asm/pgalloc-64.h
377 @@ -144,11 +144,9 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
378 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
379 unsigned long address)
380 {
381 - struct page *page = page_address(table);
382 -
383 tlb_flush_pgtable(tlb, address);
384 - pgtable_page_dtor(page);
385 - pgtable_free_tlb(tlb, page, 0);
386 + pgtable_page_dtor(table);
387 + pgtable_free_tlb(tlb, page_address(table), 0);
388 }
389
390 #else /* if CONFIG_PPC_64K_PAGES */
391 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
392 index d5cf85057d63..412189d2bff9 100644
393 --- a/arch/x86/Makefile
394 +++ b/arch/x86/Makefile
395 @@ -31,8 +31,8 @@ ifeq ($(CONFIG_X86_32),y)
396
397 KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
398
399 - # Don't autogenerate SSE instructions
400 - KBUILD_CFLAGS += -mno-sse
401 + # Don't autogenerate MMX or SSE instructions
402 + KBUILD_CFLAGS += -mno-mmx -mno-sse
403
404 # Never want PIC in a 32-bit kernel, prevent breakage with GCC built
405 # with nonstandard options
406 @@ -60,8 +60,8 @@ else
407 KBUILD_AFLAGS += -m64
408 KBUILD_CFLAGS += -m64
409
410 - # Don't autogenerate SSE instructions
411 - KBUILD_CFLAGS += -mno-sse
412 + # Don't autogenerate MMX or SSE instructions
413 + KBUILD_CFLAGS += -mno-mmx -mno-sse
414
415 # Use -mpreferred-stack-boundary=3 if supported.
416 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
417 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
418 index 379814bc41e3..6cf0111783d3 100644
419 --- a/arch/x86/boot/Makefile
420 +++ b/arch/x86/boot/Makefile
421 @@ -53,18 +53,18 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
422
423 # How to compile the 16-bit code. Note we always compile for -march=i386,
424 # that way we can complain to the user if the CPU is insufficient.
425 -KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
426 +KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
427 -DDISABLE_BRANCH_PROFILING \
428 -Wall -Wstrict-prototypes \
429 -march=i386 -mregparm=3 \
430 -include $(srctree)/$(src)/code16gcc.h \
431 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
432 + -mno-mmx -mno-sse \
433 $(call cc-option, -ffreestanding) \
434 $(call cc-option, -fno-toplevel-reorder,\
435 - $(call cc-option, -fno-unit-at-a-time)) \
436 + $(call cc-option, -fno-unit-at-a-time)) \
437 $(call cc-option, -fno-stack-protector) \
438 $(call cc-option, -mpreferred-stack-boundary=2)
439 -KBUILD_CFLAGS += $(call cc-option, -m32)
440 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
441 GCOV_PROFILE := n
442
443 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
444 index 5ef205c5f37b..7194d9f094bc 100644
445 --- a/arch/x86/boot/compressed/Makefile
446 +++ b/arch/x86/boot/compressed/Makefile
447 @@ -12,6 +12,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
448 cflags-$(CONFIG_X86_32) := -march=i386
449 cflags-$(CONFIG_X86_64) := -mcmodel=small
450 KBUILD_CFLAGS += $(cflags-y)
451 +KBUILD_CFLAGS += -mno-mmx -mno-sse
452 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
453 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
454
455 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
456 index 0eee2c8b64d1..0987c638db11 100644
457 --- a/arch/x86/kvm/lapic.c
458 +++ b/arch/x86/kvm/lapic.c
459 @@ -153,6 +153,8 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
460 return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
461 }
462
463 +#define KVM_X2APIC_CID_BITS 0
464 +
465 static void recalculate_apic_map(struct kvm *kvm)
466 {
467 struct kvm_apic_map *new, *old = NULL;
468 @@ -190,7 +192,8 @@ static void recalculate_apic_map(struct kvm *kvm)
469 if (apic_x2apic_mode(apic)) {
470 new->ldr_bits = 32;
471 new->cid_shift = 16;
472 - new->cid_mask = new->lid_mask = 0xffff;
473 + new->cid_mask = (1 << KVM_X2APIC_CID_BITS) - 1;
474 + new->lid_mask = 0xffff;
475 } else if (kvm_apic_sw_enabled(apic) &&
476 !new->cid_mask /* flat mode */ &&
477 kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) {
478 @@ -855,7 +858,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
479 ASSERT(apic != NULL);
480
481 /* if initial count is 0, current count should also be 0 */
482 - if (kvm_apic_get_reg(apic, APIC_TMICT) == 0)
483 + if (kvm_apic_get_reg(apic, APIC_TMICT) == 0 ||
484 + apic->lapic_timer.period == 0)
485 return 0;
486
487 remaining = hrtimer_get_remaining(&apic->lapic_timer.timer);
488 @@ -1705,7 +1709,6 @@ static void apic_sync_pv_eoi_from_guest(struct kvm_vcpu *vcpu,
489 void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
490 {
491 u32 data;
492 - void *vapic;
493
494 if (test_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention))
495 apic_sync_pv_eoi_from_guest(vcpu, vcpu->arch.apic);
496 @@ -1713,9 +1716,8 @@ void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
497 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
498 return;
499
500 - vapic = kmap_atomic(vcpu->arch.apic->vapic_page);
501 - data = *(u32 *)(vapic + offset_in_page(vcpu->arch.apic->vapic_addr));
502 - kunmap_atomic(vapic);
503 + kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
504 + sizeof(u32));
505
506 apic_set_tpr(vcpu->arch.apic, data & 0xff);
507 }
508 @@ -1751,7 +1753,6 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
509 u32 data, tpr;
510 int max_irr, max_isr;
511 struct kvm_lapic *apic = vcpu->arch.apic;
512 - void *vapic;
513
514 apic_sync_pv_eoi_to_guest(vcpu, apic);
515
516 @@ -1767,18 +1768,24 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
517 max_isr = 0;
518 data = (tpr & 0xff) | ((max_isr & 0xf0) << 8) | (max_irr << 24);
519
520 - vapic = kmap_atomic(vcpu->arch.apic->vapic_page);
521 - *(u32 *)(vapic + offset_in_page(vcpu->arch.apic->vapic_addr)) = data;
522 - kunmap_atomic(vapic);
523 + kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
524 + sizeof(u32));
525 }
526
527 -void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)
528 +int kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)
529 {
530 - vcpu->arch.apic->vapic_addr = vapic_addr;
531 - if (vapic_addr)
532 + if (vapic_addr) {
533 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
534 + &vcpu->arch.apic->vapic_cache,
535 + vapic_addr, sizeof(u32)))
536 + return -EINVAL;
537 __set_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
538 - else
539 + } else {
540 __clear_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
541 + }
542 +
543 + vcpu->arch.apic->vapic_addr = vapic_addr;
544 + return 0;
545 }
546
547 int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data)
548 diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
549 index c730ac9fe801..c8b0d0d2da5c 100644
550 --- a/arch/x86/kvm/lapic.h
551 +++ b/arch/x86/kvm/lapic.h
552 @@ -34,7 +34,7 @@ struct kvm_lapic {
553 */
554 void *regs;
555 gpa_t vapic_addr;
556 - struct page *vapic_page;
557 + struct gfn_to_hva_cache vapic_cache;
558 unsigned long pending_events;
559 unsigned int sipi_vector;
560 };
561 @@ -76,7 +76,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data);
562 void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset);
563 void kvm_apic_set_eoi_accelerated(struct kvm_vcpu *vcpu, int vector);
564
565 -void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr);
566 +int kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr);
567 void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu);
568 void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu);
569
570 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
571 index e8ba99c34180..ad6a01605aaa 100644
572 --- a/arch/x86/kvm/x86.c
573 +++ b/arch/x86/kvm/x86.c
574 @@ -3138,8 +3138,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
575 r = -EFAULT;
576 if (copy_from_user(&va, argp, sizeof va))
577 goto out;
578 - r = 0;
579 - kvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);
580 + r = kvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);
581 break;
582 }
583 case KVM_X86_SETUP_MCE: {
584 @@ -5539,36 +5538,6 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
585 !kvm_event_needs_reinjection(vcpu);
586 }
587
588 -static int vapic_enter(struct kvm_vcpu *vcpu)
589 -{
590 - struct kvm_lapic *apic = vcpu->arch.apic;
591 - struct page *page;
592 -
593 - if (!apic || !apic->vapic_addr)
594 - return 0;
595 -
596 - page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
597 - if (is_error_page(page))
598 - return -EFAULT;
599 -
600 - vcpu->arch.apic->vapic_page = page;
601 - return 0;
602 -}
603 -
604 -static void vapic_exit(struct kvm_vcpu *vcpu)
605 -{
606 - struct kvm_lapic *apic = vcpu->arch.apic;
607 - int idx;
608 -
609 - if (!apic || !apic->vapic_addr)
610 - return;
611 -
612 - idx = srcu_read_lock(&vcpu->kvm->srcu);
613 - kvm_release_page_dirty(apic->vapic_page);
614 - mark_page_dirty(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
615 - srcu_read_unlock(&vcpu->kvm->srcu, idx);
616 -}
617 -
618 static void update_cr8_intercept(struct kvm_vcpu *vcpu)
619 {
620 int max_irr, tpr;
621 @@ -5889,11 +5858,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
622 struct kvm *kvm = vcpu->kvm;
623
624 vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
625 - r = vapic_enter(vcpu);
626 - if (r) {
627 - srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
628 - return r;
629 - }
630
631 r = 1;
632 while (r > 0) {
633 @@ -5951,8 +5915,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
634
635 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
636
637 - vapic_exit(vcpu);
638 -
639 return r;
640 }
641
642 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
643 index 91ac654ff4ea..3474a2ccd8b1 100644
644 --- a/arch/x86/platform/efi/efi.c
645 +++ b/arch/x86/platform/efi/efi.c
646 @@ -766,13 +766,6 @@ void __init efi_init(void)
647
648 set_bit(EFI_MEMMAP, &x86_efi_facility);
649
650 -#ifdef CONFIG_X86_32
651 - if (efi_is_native()) {
652 - x86_platform.get_wallclock = efi_get_time;
653 - x86_platform.set_wallclock = efi_set_rtc_mmss;
654 - }
655 -#endif
656 -
657 #if EFI_DEBUG
658 print_efi_memmap();
659 #endif
660 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
661 index 88692871823f..9cac82588cbc 100644
662 --- a/arch/x86/realmode/rm/Makefile
663 +++ b/arch/x86/realmode/rm/Makefile
664 @@ -73,9 +73,10 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
665 -march=i386 -mregparm=3 \
666 -include $(srctree)/$(src)/../../boot/code16gcc.h \
667 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
668 + -mno-mmx -mno-sse \
669 $(call cc-option, -ffreestanding) \
670 $(call cc-option, -fno-toplevel-reorder,\
671 - $(call cc-option, -fno-unit-at-a-time)) \
672 + $(call cc-option, -fno-unit-at-a-time)) \
673 $(call cc-option, -fno-stack-protector) \
674 $(call cc-option, -mpreferred-stack-boundary=2)
675 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
676 diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
677 index 585c3b279feb..850246206b12 100644
678 --- a/crypto/algif_hash.c
679 +++ b/crypto/algif_hash.c
680 @@ -117,9 +117,6 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page,
681 if (flags & MSG_SENDPAGE_NOTLAST)
682 flags |= MSG_MORE;
683
684 - if (flags & MSG_SENDPAGE_NOTLAST)
685 - flags |= MSG_MORE;
686 -
687 lock_sock(sk);
688 sg_init_table(ctx->sgl.sg, 1);
689 sg_set_page(ctx->sgl.sg, page, size, offset);
690 diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
691 index 918a3b4148b8..a19c027b29bd 100644
692 --- a/crypto/algif_skcipher.c
693 +++ b/crypto/algif_skcipher.c
694 @@ -381,9 +381,6 @@ static ssize_t skcipher_sendpage(struct socket *sock, struct page *page,
695 if (flags & MSG_SENDPAGE_NOTLAST)
696 flags |= MSG_MORE;
697
698 - if (flags & MSG_SENDPAGE_NOTLAST)
699 - flags |= MSG_MORE;
700 -
701 lock_sock(sk);
702 if (!ctx->more && ctx->used)
703 goto unlock;
704 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
705 index c714d4d5bedb..f1e600490bb2 100644
706 --- a/drivers/gpu/drm/i915/intel_display.c
707 +++ b/drivers/gpu/drm/i915/intel_display.c
708 @@ -5225,7 +5225,7 @@ static void intel_set_pipe_csc(struct drm_crtc *crtc)
709 uint16_t postoff = 0;
710
711 if (intel_crtc->config.limited_color_range)
712 - postoff = (16 * (1 << 13) / 255) & 0x1fff;
713 + postoff = (16 * (1 << 12) / 255) & 0x1fff;
714
715 I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), postoff);
716 I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff);
717 diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
718 index 01ed8ac4d156..5df711659049 100644
719 --- a/drivers/gpu/drm/radeon/r600_hdmi.c
720 +++ b/drivers/gpu/drm/radeon/r600_hdmi.c
721 @@ -279,9 +279,9 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
722 WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100);
723 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
724 }
725 - } else if (ASIC_IS_DCE3(rdev)) {
726 + } else {
727 /* according to the reg specs, this should DCE3.2 only, but in
728 - * practice it seems to cover DCE3.0/3.1 as well.
729 + * practice it seems to cover DCE2.0/3.0/3.1 as well.
730 */
731 if (dig->dig_encoder == 0) {
732 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
733 @@ -292,10 +292,6 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
734 WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100);
735 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
736 }
737 - } else {
738 - /* according to the reg specs, this should be DCE2.0 and DCE3.0/3.1 */
739 - WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
740 - AUDIO_DTO_MODULE(clock / 10));
741 }
742 }
743
744 diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
745 index f054a3b6c4b8..bf14a6b89b59 100644
746 --- a/drivers/gpu/drm/radeon/si.c
747 +++ b/drivers/gpu/drm/radeon/si.c
748 @@ -3615,8 +3615,15 @@ static int si_mc_init(struct radeon_device *rdev)
749 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
750 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
751 /* size in MB on si */
752 - rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
753 - rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
754 + tmp = RREG32(CONFIG_MEMSIZE);
755 + /* some boards may have garbage in the upper 16 bits */
756 + if (tmp & 0xffff0000) {
757 + DRM_INFO("Probable bad vram size: 0x%08x\n", tmp);
758 + if (tmp & 0xffff)
759 + tmp &= 0xffff;
760 + }
761 + rdev->mc.mc_vram_size = tmp * 1024ULL * 1024ULL;
762 + rdev->mc.real_vram_size = rdev->mc.mc_vram_size;
763 rdev->mc.visible_vram_size = rdev->mc.aper_size;
764 si_vram_gtt_location(rdev, &rdev->mc);
765 radeon_update_bandwidth_info(rdev);
766 diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
767 index 2dc37c7c6947..7d68a08baaa8 100644
768 --- a/drivers/hwmon/hih6130.c
769 +++ b/drivers/hwmon/hih6130.c
770 @@ -43,6 +43,7 @@
771 * @last_update: time of last update (jiffies)
772 * @temperature: cached temperature measurement value
773 * @humidity: cached humidity measurement value
774 + * @write_length: length for I2C measurement request
775 */
776 struct hih6130 {
777 struct device *hwmon_dev;
778 @@ -51,6 +52,7 @@ struct hih6130 {
779 unsigned long last_update;
780 int temperature;
781 int humidity;
782 + size_t write_length;
783 };
784
785 /**
786 @@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client)
787 */
788 if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
789
790 - /* write to slave address, no data, to request a measurement */
791 - ret = i2c_master_send(client, tmp, 0);
792 + /*
793 + * Write to slave address to request a measurement.
794 + * According with the datasheet it should be with no data, but
795 + * for systems with I2C bus drivers that do not allow zero
796 + * length packets we write one dummy byte to allow sensor
797 + * measurements on them.
798 + */
799 + tmp[0] = 0;
800 + ret = i2c_master_send(client, tmp, hih6130->write_length);
801 if (ret < 0)
802 goto out;
803
804 @@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client,
805 goto fail_remove_sysfs;
806 }
807
808 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK))
809 + hih6130->write_length = 1;
810 +
811 return 0;
812
813 fail_remove_sysfs:
814 diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
815 index 6cf6bff79003..a2f3b4a365e4 100644
816 --- a/drivers/hwmon/lm78.c
817 +++ b/drivers/hwmon/lm78.c
818 @@ -94,6 +94,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
819 {
820 if (rpm <= 0)
821 return 255;
822 + if (rpm > 1350000)
823 + return 1;
824 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
825 }
826
827 diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
828 index 1404e6319deb..72a889702f0d 100644
829 --- a/drivers/hwmon/sis5595.c
830 +++ b/drivers/hwmon/sis5595.c
831 @@ -141,6 +141,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
832 {
833 if (rpm <= 0)
834 return 255;
835 + if (rpm > 1350000)
836 + return 1;
837 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
838 }
839
840 diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
841 index 0e7017841f7d..aee14e2192f8 100644
842 --- a/drivers/hwmon/vt8231.c
843 +++ b/drivers/hwmon/vt8231.c
844 @@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 };
845 */
846 static inline u8 FAN_TO_REG(long rpm, int div)
847 {
848 - if (rpm == 0)
849 + if (rpm <= 0 || rpm > 1310720)
850 return 0;
851 return clamp_val(1310720 / (rpm * div), 1, 255);
852 }
853 diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c
854 index edb06cda5a68..6ed76ceb9270 100644
855 --- a/drivers/hwmon/w83l786ng.c
856 +++ b/drivers/hwmon/w83l786ng.c
857 @@ -481,9 +481,11 @@ store_pwm(struct device *dev, struct device_attribute *attr,
858 if (err)
859 return err;
860 val = clamp_val(val, 0, 255);
861 + val = DIV_ROUND_CLOSEST(val, 0x11);
862
863 mutex_lock(&data->update_lock);
864 - data->pwm[nr] = val;
865 + data->pwm[nr] = val * 0x11;
866 + val |= w83l786ng_read_value(client, W83L786NG_REG_PWM[nr]) & 0xf0;
867 w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val);
868 mutex_unlock(&data->update_lock);
869 return count;
870 @@ -510,7 +512,7 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
871 mutex_lock(&data->update_lock);
872 reg = w83l786ng_read_value(client, W83L786NG_REG_FAN_CFG);
873 data->pwm_enable[nr] = val;
874 - reg &= ~(0x02 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
875 + reg &= ~(0x03 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
876 reg |= (val - 1) << W83L786NG_PWM_ENABLE_SHIFT[nr];
877 w83l786ng_write_value(client, W83L786NG_REG_FAN_CFG, reg);
878 mutex_unlock(&data->update_lock);
879 @@ -776,9 +778,10 @@ static struct w83l786ng_data *w83l786ng_update_device(struct device *dev)
880 ((pwmcfg >> W83L786NG_PWM_MODE_SHIFT[i]) & 1)
881 ? 0 : 1;
882 data->pwm_enable[i] =
883 - ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 2) + 1;
884 - data->pwm[i] = w83l786ng_read_value(client,
885 - W83L786NG_REG_PWM[i]);
886 + ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3) + 1;
887 + data->pwm[i] =
888 + (w83l786ng_read_value(client, W83L786NG_REG_PWM[i])
889 + & 0x0f) * 0x11;
890 }
891
892
893 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
894 index fa061d46527f..75e3b102ce45 100644
895 --- a/drivers/input/joystick/xpad.c
896 +++ b/drivers/input/joystick/xpad.c
897 @@ -167,6 +167,7 @@ static const struct xpad_device {
898 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
899 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
900 { 0x1689, 0xfd00, "Razer Onza Tournament Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
901 + { 0x1689, 0xfd01, "Razer Onza Classic Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
902 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
903 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
904 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
905 diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
906 index ae4b6b903629..5f87bed05467 100644
907 --- a/drivers/input/touchscreen/usbtouchscreen.c
908 +++ b/drivers/input/touchscreen/usbtouchscreen.c
909 @@ -106,6 +106,7 @@ struct usbtouch_device_info {
910 struct usbtouch_usb {
911 unsigned char *data;
912 dma_addr_t data_dma;
913 + int data_size;
914 unsigned char *buffer;
915 int buf_len;
916 struct urb *irq;
917 @@ -1521,7 +1522,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf)
918 static void usbtouch_free_buffers(struct usb_device *udev,
919 struct usbtouch_usb *usbtouch)
920 {
921 - usb_free_coherent(udev, usbtouch->type->rept_size,
922 + usb_free_coherent(udev, usbtouch->data_size,
923 usbtouch->data, usbtouch->data_dma);
924 kfree(usbtouch->buffer);
925 }
926 @@ -1566,7 +1567,20 @@ static int usbtouch_probe(struct usb_interface *intf,
927 if (!type->process_pkt)
928 type->process_pkt = usbtouch_process_pkt;
929
930 - usbtouch->data = usb_alloc_coherent(udev, type->rept_size,
931 + usbtouch->data_size = type->rept_size;
932 + if (type->get_pkt_len) {
933 + /*
934 + * When dealing with variable-length packets we should
935 + * not request more than wMaxPacketSize bytes at once
936 + * as we do not know if there is more data coming or
937 + * we filled exactly wMaxPacketSize bytes and there is
938 + * nothing else.
939 + */
940 + usbtouch->data_size = min(usbtouch->data_size,
941 + usb_endpoint_maxp(endpoint));
942 + }
943 +
944 + usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size,
945 GFP_KERNEL, &usbtouch->data_dma);
946 if (!usbtouch->data)
947 goto out_free;
948 @@ -1626,12 +1640,12 @@ static int usbtouch_probe(struct usb_interface *intf,
949 if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
950 usb_fill_int_urb(usbtouch->irq, udev,
951 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
952 - usbtouch->data, type->rept_size,
953 + usbtouch->data, usbtouch->data_size,
954 usbtouch_irq, usbtouch, endpoint->bInterval);
955 else
956 usb_fill_bulk_urb(usbtouch->irq, udev,
957 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
958 - usbtouch->data, type->rept_size,
959 + usbtouch->data, usbtouch->data_size,
960 usbtouch_irq, usbtouch);
961
962 usbtouch->irq->dev = udev;
963 diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
964 index 0387e05cdb98..a6e985fcceb8 100644
965 --- a/drivers/md/dm-bufio.c
966 +++ b/drivers/md/dm-bufio.c
967 @@ -1660,6 +1660,11 @@ static int __init dm_bufio_init(void)
968 {
969 __u64 mem;
970
971 + dm_bufio_allocated_kmem_cache = 0;
972 + dm_bufio_allocated_get_free_pages = 0;
973 + dm_bufio_allocated_vmalloc = 0;
974 + dm_bufio_current_allocated = 0;
975 +
976 memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
977 memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
978
979 diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
980 index 496d5f3646a5..2f91d6d4a2cc 100644
981 --- a/drivers/md/dm-delay.c
982 +++ b/drivers/md/dm-delay.c
983 @@ -20,6 +20,7 @@
984 struct delay_c {
985 struct timer_list delay_timer;
986 struct mutex timer_lock;
987 + struct workqueue_struct *kdelayd_wq;
988 struct work_struct flush_expired_bios;
989 struct list_head delayed_bios;
990 atomic_t may_delay;
991 @@ -45,14 +46,13 @@ struct dm_delay_info {
992
993 static DEFINE_MUTEX(delayed_bios_lock);
994
995 -static struct workqueue_struct *kdelayd_wq;
996 static struct kmem_cache *delayed_cache;
997
998 static void handle_delayed_timer(unsigned long data)
999 {
1000 struct delay_c *dc = (struct delay_c *)data;
1001
1002 - queue_work(kdelayd_wq, &dc->flush_expired_bios);
1003 + queue_work(dc->kdelayd_wq, &dc->flush_expired_bios);
1004 }
1005
1006 static void queue_timeout(struct delay_c *dc, unsigned long expires)
1007 @@ -191,6 +191,12 @@ out:
1008 goto bad_dev_write;
1009 }
1010
1011 + dc->kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
1012 + if (!dc->kdelayd_wq) {
1013 + DMERR("Couldn't start kdelayd");
1014 + goto bad_queue;
1015 + }
1016 +
1017 setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc);
1018
1019 INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
1020 @@ -203,6 +209,8 @@ out:
1021 ti->private = dc;
1022 return 0;
1023
1024 +bad_queue:
1025 + mempool_destroy(dc->delayed_pool);
1026 bad_dev_write:
1027 if (dc->dev_write)
1028 dm_put_device(ti, dc->dev_write);
1029 @@ -217,7 +225,7 @@ static void delay_dtr(struct dm_target *ti)
1030 {
1031 struct delay_c *dc = ti->private;
1032
1033 - flush_workqueue(kdelayd_wq);
1034 + destroy_workqueue(dc->kdelayd_wq);
1035
1036 dm_put_device(ti, dc->dev_read);
1037
1038 @@ -350,12 +358,6 @@ static int __init dm_delay_init(void)
1039 {
1040 int r = -ENOMEM;
1041
1042 - kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
1043 - if (!kdelayd_wq) {
1044 - DMERR("Couldn't start kdelayd");
1045 - goto bad_queue;
1046 - }
1047 -
1048 delayed_cache = KMEM_CACHE(dm_delay_info, 0);
1049 if (!delayed_cache) {
1050 DMERR("Couldn't create delayed bio cache.");
1051 @@ -373,8 +375,6 @@ static int __init dm_delay_init(void)
1052 bad_register:
1053 kmem_cache_destroy(delayed_cache);
1054 bad_memcache:
1055 - destroy_workqueue(kdelayd_wq);
1056 -bad_queue:
1057 return r;
1058 }
1059
1060 @@ -382,7 +382,6 @@ static void __exit dm_delay_exit(void)
1061 {
1062 dm_unregister_target(&delay_target);
1063 kmem_cache_destroy(delayed_cache);
1064 - destroy_workqueue(kdelayd_wq);
1065 }
1066
1067 /* Module hooks */
1068 diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
1069 index aec57d76db5d..944690bafd93 100644
1070 --- a/drivers/md/dm-snap.c
1071 +++ b/drivers/md/dm-snap.c
1072 @@ -66,6 +66,18 @@ struct dm_snapshot {
1073
1074 atomic_t pending_exceptions_count;
1075
1076 + /* Protected by "lock" */
1077 + sector_t exception_start_sequence;
1078 +
1079 + /* Protected by kcopyd single-threaded callback */
1080 + sector_t exception_complete_sequence;
1081 +
1082 + /*
1083 + * A list of pending exceptions that completed out of order.
1084 + * Protected by kcopyd single-threaded callback.
1085 + */
1086 + struct list_head out_of_order_list;
1087 +
1088 mempool_t *pending_pool;
1089
1090 struct dm_exception_table pending;
1091 @@ -173,6 +185,14 @@ struct dm_snap_pending_exception {
1092 */
1093 int started;
1094
1095 + /* There was copying error. */
1096 + int copy_error;
1097 +
1098 + /* A sequence number, it is used for in-order completion. */
1099 + sector_t exception_sequence;
1100 +
1101 + struct list_head out_of_order_entry;
1102 +
1103 /*
1104 * For writing a complete chunk, bypassing the copy.
1105 */
1106 @@ -1094,6 +1114,9 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1107 s->valid = 1;
1108 s->active = 0;
1109 atomic_set(&s->pending_exceptions_count, 0);
1110 + s->exception_start_sequence = 0;
1111 + s->exception_complete_sequence = 0;
1112 + INIT_LIST_HEAD(&s->out_of_order_list);
1113 init_rwsem(&s->lock);
1114 INIT_LIST_HEAD(&s->list);
1115 spin_lock_init(&s->pe_lock);
1116 @@ -1443,6 +1466,19 @@ static void commit_callback(void *context, int success)
1117 pending_complete(pe, success);
1118 }
1119
1120 +static void complete_exception(struct dm_snap_pending_exception *pe)
1121 +{
1122 + struct dm_snapshot *s = pe->snap;
1123 +
1124 + if (unlikely(pe->copy_error))
1125 + pending_complete(pe, 0);
1126 +
1127 + else
1128 + /* Update the metadata if we are persistent */
1129 + s->store->type->commit_exception(s->store, &pe->e,
1130 + commit_callback, pe);
1131 +}
1132 +
1133 /*
1134 * Called when the copy I/O has finished. kcopyd actually runs
1135 * this code so don't block.
1136 @@ -1452,13 +1488,32 @@ static void copy_callback(int read_err, unsigned long write_err, void *context)
1137 struct dm_snap_pending_exception *pe = context;
1138 struct dm_snapshot *s = pe->snap;
1139
1140 - if (read_err || write_err)
1141 - pending_complete(pe, 0);
1142 + pe->copy_error = read_err || write_err;
1143
1144 - else
1145 - /* Update the metadata if we are persistent */
1146 - s->store->type->commit_exception(s->store, &pe->e,
1147 - commit_callback, pe);
1148 + if (pe->exception_sequence == s->exception_complete_sequence) {
1149 + s->exception_complete_sequence++;
1150 + complete_exception(pe);
1151 +
1152 + while (!list_empty(&s->out_of_order_list)) {
1153 + pe = list_entry(s->out_of_order_list.next,
1154 + struct dm_snap_pending_exception, out_of_order_entry);
1155 + if (pe->exception_sequence != s->exception_complete_sequence)
1156 + break;
1157 + s->exception_complete_sequence++;
1158 + list_del(&pe->out_of_order_entry);
1159 + complete_exception(pe);
1160 + }
1161 + } else {
1162 + struct list_head *lh;
1163 + struct dm_snap_pending_exception *pe2;
1164 +
1165 + list_for_each_prev(lh, &s->out_of_order_list) {
1166 + pe2 = list_entry(lh, struct dm_snap_pending_exception, out_of_order_entry);
1167 + if (pe2->exception_sequence < pe->exception_sequence)
1168 + break;
1169 + }
1170 + list_add(&pe->out_of_order_entry, lh);
1171 + }
1172 }
1173
1174 /*
1175 @@ -1553,6 +1608,8 @@ __find_pending_exception(struct dm_snapshot *s,
1176 return NULL;
1177 }
1178
1179 + pe->exception_sequence = s->exception_start_sequence++;
1180 +
1181 dm_insert_exception(&s->pending, &pe->e);
1182
1183 return pe;
1184 @@ -2192,7 +2249,7 @@ static struct target_type origin_target = {
1185
1186 static struct target_type snapshot_target = {
1187 .name = "snapshot",
1188 - .version = {1, 11, 1},
1189 + .version = {1, 12, 0},
1190 .module = THIS_MODULE,
1191 .ctr = snapshot_ctr,
1192 .dtr = snapshot_dtr,
1193 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
1194 index 9e3a045eb7a2..bd88d3dade1e 100644
1195 --- a/drivers/md/dm-table.c
1196 +++ b/drivers/md/dm-table.c
1197 @@ -215,6 +215,11 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
1198
1199 num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
1200
1201 + if (!num_targets) {
1202 + kfree(t);
1203 + return -ENOMEM;
1204 + }
1205 +
1206 if (alloc_targets(t, num_targets)) {
1207 kfree(t);
1208 return -ENOMEM;
1209 diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
1210 index 88f2f802d528..e36f81e282eb 100644
1211 --- a/drivers/md/dm-thin.c
1212 +++ b/drivers/md/dm-thin.c
1213 @@ -640,7 +640,9 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
1214 */
1215 r = dm_thin_insert_block(tc->td, m->virt_block, m->data_block);
1216 if (r) {
1217 - DMERR_LIMIT("dm_thin_insert_block() failed");
1218 + DMERR_LIMIT("%s: dm_thin_insert_block() failed: error = %d",
1219 + dm_device_name(pool->pool_md), r);
1220 + set_pool_mode(pool, PM_READ_ONLY);
1221 cell_error(pool, m->cell);
1222 goto out;
1223 }
1224 diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
1225 index af96e24ec328..1d75b1dc1e2e 100644
1226 --- a/drivers/md/persistent-data/dm-array.c
1227 +++ b/drivers/md/persistent-data/dm-array.c
1228 @@ -317,8 +317,16 @@ static int shadow_ablock(struct dm_array_info *info, dm_block_t *root,
1229 * The shadow op will often be a noop. Only insert if it really
1230 * copied data.
1231 */
1232 - if (dm_block_location(*block) != b)
1233 + if (dm_block_location(*block) != b) {
1234 + /*
1235 + * dm_tm_shadow_block will have already decremented the old
1236 + * block, but it is still referenced by the btree. We
1237 + * increment to stop the insert decrementing it below zero
1238 + * when overwriting the old value.
1239 + */
1240 + dm_tm_inc(info->btree_info.tm, b);
1241 r = insert_ablock(info, index, *block, root);
1242 + }
1243
1244 return r;
1245 }
1246 diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
1247 index 1c959684caef..58fc1eef7499 100644
1248 --- a/drivers/md/persistent-data/dm-space-map-metadata.c
1249 +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
1250 @@ -384,12 +384,16 @@ static int sm_metadata_new_block(struct dm_space_map *sm, dm_block_t *b)
1251 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
1252
1253 int r = sm_metadata_new_block_(sm, b);
1254 - if (r)
1255 + if (r) {
1256 DMERR("unable to allocate new metadata block");
1257 + return r;
1258 + }
1259
1260 r = sm_metadata_get_nr_free(sm, &count);
1261 - if (r)
1262 + if (r) {
1263 DMERR("couldn't get free block count");
1264 + return r;
1265 + }
1266
1267 check_threshold(&smm->threshold, count);
1268
1269 diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
1270 index 30ee59052157..65728c25ea05 100644
1271 --- a/drivers/media/dvb-frontends/af9033.c
1272 +++ b/drivers/media/dvb-frontends/af9033.c
1273 @@ -170,18 +170,18 @@ static int af9033_rd_reg_mask(struct af9033_state *state, u32 reg, u8 *val,
1274 static int af9033_wr_reg_val_tab(struct af9033_state *state,
1275 const struct reg_val *tab, int tab_len)
1276 {
1277 +#define MAX_TAB_LEN 212
1278 int ret, i, j;
1279 - u8 buf[MAX_XFER_SIZE];
1280 + u8 buf[1 + MAX_TAB_LEN];
1281 +
1282 + dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
1283
1284 if (tab_len > sizeof(buf)) {
1285 - dev_warn(&state->i2c->dev,
1286 - "%s: i2c wr len=%d is too big!\n",
1287 - KBUILD_MODNAME, tab_len);
1288 + dev_warn(&state->i2c->dev, "%s: tab len %d is too big\n",
1289 + KBUILD_MODNAME, tab_len);
1290 return -EINVAL;
1291 }
1292
1293 - dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
1294 -
1295 for (i = 0, j = 0; i < tab_len; i++) {
1296 buf[j] = tab[i].val;
1297
1298 diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
1299 index 51447a04d8f2..03930d5e9fea 100644
1300 --- a/drivers/media/dvb-frontends/cxd2820r_core.c
1301 +++ b/drivers/media/dvb-frontends/cxd2820r_core.c
1302 @@ -34,7 +34,7 @@ static int cxd2820r_wr_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
1303 {
1304 .addr = i2c,
1305 .flags = 0,
1306 - .len = sizeof(buf),
1307 + .len = len + 1,
1308 .buf = buf,
1309 }
1310 };
1311 @@ -75,7 +75,7 @@ static int cxd2820r_rd_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
1312 }, {
1313 .addr = i2c,
1314 .flags = I2C_M_RD,
1315 - .len = sizeof(buf),
1316 + .len = len,
1317 .buf = buf,
1318 }
1319 };
1320 diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c
1321 index 27c27b4ae238..e5f3a78cf55b 100644
1322 --- a/drivers/media/i2c/wm8775.c
1323 +++ b/drivers/media/i2c/wm8775.c
1324 @@ -131,12 +131,10 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
1325 return -EINVAL;
1326 }
1327 state->input = input;
1328 - if (!v4l2_ctrl_g_ctrl(state->mute))
1329 + if (v4l2_ctrl_g_ctrl(state->mute))
1330 return 0;
1331 if (!v4l2_ctrl_g_ctrl(state->vol))
1332 return 0;
1333 - if (!v4l2_ctrl_g_ctrl(state->bal))
1334 - return 0;
1335 wm8775_set_audio(sd, 1);
1336 return 0;
1337 }
1338 diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
1339 index e7d088413411..e2633d9270b7 100644
1340 --- a/drivers/media/pci/bt8xx/bttv-driver.c
1341 +++ b/drivers/media/pci/bt8xx/bttv-driver.c
1342 @@ -4226,7 +4226,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
1343 }
1344 btv->std = V4L2_STD_PAL;
1345 init_irqreg(btv);
1346 - v4l2_ctrl_handler_setup(hdl);
1347 + if (!bttv_tvcards[btv->c.type].no_video)
1348 + v4l2_ctrl_handler_setup(hdl);
1349 if (hdl->error) {
1350 result = hdl->error;
1351 goto fail2;
1352 diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
1353 index 7618fdae811e..62141b8f1e1a 100644
1354 --- a/drivers/media/pci/saa7164/saa7164-core.c
1355 +++ b/drivers/media/pci/saa7164/saa7164-core.c
1356 @@ -1348,9 +1348,11 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1357 if (fw_debug) {
1358 dev->kthread = kthread_run(saa7164_thread_function, dev,
1359 "saa7164 debug");
1360 - if (!dev->kthread)
1361 + if (IS_ERR(dev->kthread)) {
1362 + dev->kthread = NULL;
1363 printk(KERN_ERR "%s() Failed to create "
1364 "debug kernel thread\n", __func__);
1365 + }
1366 }
1367
1368 } /* != BOARD_UNKNOWN */
1369 diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
1370 index 3968bff341e6..46f05ad529f9 100644
1371 --- a/drivers/media/usb/dvb-usb-v2/af9035.c
1372 +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
1373 @@ -130,7 +130,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
1374 {
1375 u8 wbuf[MAX_XFER_SIZE];
1376 u8 mbox = (reg >> 16) & 0xff;
1377 - struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
1378 + struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
1379
1380 if (6 + len > sizeof(wbuf)) {
1381 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
1382 @@ -237,14 +237,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
1383 } else {
1384 /* I2C */
1385 u8 buf[MAX_XFER_SIZE];
1386 - struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
1387 + struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
1388 buf, msg[1].len, msg[1].buf };
1389
1390 if (5 + msg[0].len > sizeof(buf)) {
1391 dev_warn(&d->udev->dev,
1392 "%s: i2c xfer: len=%d is too big!\n",
1393 KBUILD_MODNAME, msg[0].len);
1394 - return -EOPNOTSUPP;
1395 + ret = -EOPNOTSUPP;
1396 + goto unlock;
1397 }
1398 req.mbox |= ((msg[0].addr & 0x80) >> 3);
1399 buf[0] = msg[1].len;
1400 @@ -273,14 +274,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
1401 } else {
1402 /* I2C */
1403 u8 buf[MAX_XFER_SIZE];
1404 - struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
1405 - 0, NULL };
1406 + struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
1407 + buf, 0, NULL };
1408
1409 if (5 + msg[0].len > sizeof(buf)) {
1410 dev_warn(&d->udev->dev,
1411 "%s: i2c xfer: len=%d is too big!\n",
1412 KBUILD_MODNAME, msg[0].len);
1413 - return -EOPNOTSUPP;
1414 + ret = -EOPNOTSUPP;
1415 + goto unlock;
1416 }
1417 req.mbox |= ((msg[0].addr & 0x80) >> 3);
1418 buf[0] = msg[0].len;
1419 @@ -300,6 +302,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
1420 ret = -EOPNOTSUPP;
1421 }
1422
1423 +unlock:
1424 mutex_unlock(&d->i2c_mutex);
1425
1426 if (ret < 0)
1427 @@ -1512,6 +1515,8 @@ static const struct usb_device_id af9035_id_table[] = {
1428 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
1429 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
1430 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) },
1431 + { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a05,
1432 + &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) },
1433 { }
1434 };
1435 MODULE_DEVICE_TABLE(usb, af9035_id_table);
1436 diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
1437 index 115b0da6e013..5dec66a96793 100644
1438 --- a/drivers/net/ethernet/intel/igb/e1000_phy.c
1439 +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
1440 @@ -1595,7 +1595,10 @@ s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
1441 * ownership of the resources, wait and try again to
1442 * see if they have relinquished the resources yet.
1443 */
1444 - udelay(usec_interval);
1445 + if (usec_interval >= 1000)
1446 + mdelay(usec_interval/1000);
1447 + else
1448 + udelay(usec_interval);
1449 }
1450 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
1451 if (ret_val)
1452 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1453 index 25b8bbbe74fe..f71a9eded5a4 100644
1454 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1455 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1456 @@ -3937,18 +3937,20 @@ static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
1457 int quick_drop;
1458 s32 t[3], f[3] = {5180, 5500, 5785};
1459
1460 - if (!(pBase->miscConfiguration & BIT(1)))
1461 + if (!(pBase->miscConfiguration & BIT(4)))
1462 return;
1463
1464 - if (freq < 4000)
1465 - quick_drop = eep->modalHeader2G.quick_drop;
1466 - else {
1467 - t[0] = eep->base_ext1.quick_drop_low;
1468 - t[1] = eep->modalHeader5G.quick_drop;
1469 - t[2] = eep->base_ext1.quick_drop_high;
1470 - quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
1471 + if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
1472 + if (freq < 4000) {
1473 + quick_drop = eep->modalHeader2G.quick_drop;
1474 + } else {
1475 + t[0] = eep->base_ext1.quick_drop_low;
1476 + t[1] = eep->modalHeader5G.quick_drop;
1477 + t[2] = eep->base_ext1.quick_drop_high;
1478 + quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
1479 + }
1480 + REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
1481 }
1482 - REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
1483 }
1484
1485 static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
1486 @@ -3988,7 +3990,7 @@ static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
1487 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
1488 u8 bias;
1489
1490 - if (!(eep->baseEepHeader.featureEnable & 0x40))
1491 + if (!(eep->baseEepHeader.miscConfiguration & 0x40))
1492 return;
1493
1494 if (!AR_SREV_9300(ah))
1495 diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
1496 index 2053dccefcd6..109dc8e437f5 100644
1497 --- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
1498 +++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
1499 @@ -119,6 +119,10 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct file *file,
1500
1501 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
1502 return -EINVAL;
1503 + if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
1504 + return -EINVAL;
1505 + if (drain < 0 || drain > 1)
1506 + return -EINVAL;
1507
1508 mutex_lock(&mvm->mutex);
1509
1510 diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
1511 index 23aa910bc5d0..0a9f59c5ab5a 100644
1512 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c
1513 +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
1514 @@ -309,8 +309,8 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1515 if (bss_desc && bss_desc->ssid.ssid_len &&
1516 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
1517 ssid, &bss_desc->ssid))) {
1518 - kfree(bss_desc);
1519 - return 0;
1520 + ret = 0;
1521 + goto done;
1522 }
1523
1524 /* Exit Adhoc mode first */
1525 diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
1526 index 79277fb36c6b..66aabde82727 100644
1527 --- a/drivers/pci/pci-driver.c
1528 +++ b/drivers/pci/pci-driver.c
1529 @@ -19,6 +19,7 @@
1530 #include <linux/cpu.h>
1531 #include <linux/pm_runtime.h>
1532 #include <linux/suspend.h>
1533 +#include <linux/kexec.h>
1534 #include "pci.h"
1535
1536 struct pci_dynid {
1537 @@ -388,12 +389,17 @@ static void pci_device_shutdown(struct device *dev)
1538 pci_msi_shutdown(pci_dev);
1539 pci_msix_shutdown(pci_dev);
1540
1541 +#ifdef CONFIG_KEXEC
1542 /*
1543 - * Turn off Bus Master bit on the device to tell it to not
1544 - * continue to do DMA. Don't touch devices in D3cold or unknown states.
1545 + * If this is a kexec reboot, turn off Bus Master bit on the
1546 + * device to tell it to not continue to do DMA. Don't touch
1547 + * devices in D3cold or unknown states.
1548 + * If it is not a kexec reboot, firmware will hit the PCI
1549 + * devices with big hammer and stop their DMA any way.
1550 */
1551 - if (pci_dev->current_state <= PCI_D3hot)
1552 + if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
1553 pci_clear_master(pci_dev);
1554 +#endif
1555 }
1556
1557 #ifdef CONFIG_PM
1558 diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
1559 index f296f3f7db9b..1237c2173c6d 100644
1560 --- a/drivers/rtc/rtc-at91rm9200.c
1561 +++ b/drivers/rtc/rtc-at91rm9200.c
1562 @@ -221,6 +221,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
1563
1564 at91_alarm_year = tm.tm_year;
1565
1566 + tm.tm_mon = alrm->time.tm_mon;
1567 + tm.tm_mday = alrm->time.tm_mday;
1568 tm.tm_hour = alrm->time.tm_hour;
1569 tm.tm_min = alrm->time.tm_min;
1570 tm.tm_sec = alrm->time.tm_sec;
1571 diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
1572 index 94a752d852bb..0d88e6227761 100644
1573 --- a/drivers/staging/comedi/drivers/amplc_pc263.c
1574 +++ b/drivers/staging/comedi/drivers/amplc_pc263.c
1575 @@ -72,6 +72,9 @@ static int pc263_do_insn_bits(struct comedi_device *dev,
1576 outb(s->state & 0xFF, dev->iobase);
1577 outb(s->state >> 8, dev->iobase + 1);
1578 }
1579 +
1580 + data[1] = s->state;
1581 +
1582 return insn->n;
1583 }
1584
1585 diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c
1586 index 8b57533bf406..9c53199a419b 100644
1587 --- a/drivers/staging/comedi/drivers/amplc_pci263.c
1588 +++ b/drivers/staging/comedi/drivers/amplc_pci263.c
1589 @@ -59,6 +59,9 @@ static int pci263_do_insn_bits(struct comedi_device *dev,
1590 outb(s->state & 0xFF, dev->iobase);
1591 outb(s->state >> 8, dev->iobase + 1);
1592 }
1593 +
1594 + data[1] = s->state;
1595 +
1596 return insn->n;
1597 }
1598
1599 diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
1600 index 0c98e26bbba1..b5ed093e59c3 100644
1601 --- a/drivers/staging/comedi/drivers/pcmuio.c
1602 +++ b/drivers/staging/comedi/drivers/pcmuio.c
1603 @@ -935,12 +935,13 @@ static void pcmuio_detach(struct comedi_device *dev)
1604 struct pcmuio_private *devpriv = dev->private;
1605 int i;
1606
1607 - for (i = 0; i < MAX_ASICS; ++i) {
1608 - if (devpriv->asics[i].irq)
1609 - free_irq(devpriv->asics[i].irq, dev);
1610 - }
1611 - if (devpriv && devpriv->sprivs)
1612 + if (devpriv) {
1613 + for (i = 0; i < MAX_ASICS; ++i) {
1614 + if (devpriv->asics[i].irq)
1615 + free_irq(devpriv->asics[i].irq, dev);
1616 + }
1617 kfree(devpriv->sprivs);
1618 + }
1619 comedi_legacy_detach(dev);
1620 }
1621
1622 diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c
1623 index a76df092a57b..8c84dc0cfe07 100644
1624 --- a/drivers/staging/comedi/drivers/ssv_dnp.c
1625 +++ b/drivers/staging/comedi/drivers/ssv_dnp.c
1626 @@ -87,11 +87,11 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
1627
1628 /* on return, data[1] contains the value of the digital input lines. */
1629 outb(PADR, CSCIR);
1630 - data[0] = inb(CSCDR);
1631 + data[1] = inb(CSCDR);
1632 outb(PBDR, CSCIR);
1633 - data[0] += inb(CSCDR) << 8;
1634 + data[1] += inb(CSCDR) << 8;
1635 outb(PCDR, CSCIR);
1636 - data[0] += ((inb(CSCDR) & 0xF0) << 12);
1637 + data[1] += ((inb(CSCDR) & 0xF0) << 12);
1638
1639 return insn->n;
1640
1641 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
1642 index 1424a8988849..4d25bff2dac1 100644
1643 --- a/drivers/usb/core/hub.c
1644 +++ b/drivers/usb/core/hub.c
1645 @@ -4808,8 +4808,9 @@ static void hub_events(void)
1646 hub->ports[i - 1]->child;
1647
1648 dev_dbg(hub_dev, "warm reset port %d\n", i);
1649 - if (!udev || !(portstatus &
1650 - USB_PORT_STAT_CONNECTION)) {
1651 + if (!udev ||
1652 + !(portstatus & USB_PORT_STAT_CONNECTION) ||
1653 + udev->state == USB_STATE_NOTATTACHED) {
1654 status = hub_port_reset(hub, i,
1655 NULL, HUB_BH_RESET_TIME,
1656 true);
1657 diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
1658 index 5acbb948b704..3cea676ba901 100644
1659 --- a/drivers/usb/dwc3/ep0.c
1660 +++ b/drivers/usb/dwc3/ep0.c
1661 @@ -478,6 +478,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
1662 dep = dwc3_wIndex_to_dep(dwc, wIndex);
1663 if (!dep)
1664 return -EINVAL;
1665 + if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
1666 + break;
1667 ret = __dwc3_gadget_ep_set_halt(dep, set);
1668 if (ret)
1669 return -EINVAL;
1670 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
1671 index 14d28d6184f6..69948ad39837 100644
1672 --- a/drivers/usb/dwc3/gadget.c
1673 +++ b/drivers/usb/dwc3/gadget.c
1674 @@ -1220,9 +1220,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1675 else
1676 dep->flags |= DWC3_EP_STALL;
1677 } else {
1678 - if (dep->flags & DWC3_EP_WEDGE)
1679 - return 0;
1680 -
1681 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
1682 DWC3_DEPCMD_CLEARSTALL, &params);
1683 if (ret)
1684 @@ -1230,7 +1227,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1685 value ? "set" : "clear",
1686 dep->name);
1687 else
1688 - dep->flags &= ~DWC3_EP_STALL;
1689 + dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
1690 }
1691
1692 return ret;
1693 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
1694 index 55f4df60f327..44a292b75012 100644
1695 --- a/drivers/usb/gadget/composite.c
1696 +++ b/drivers/usb/gadget/composite.c
1697 @@ -593,6 +593,7 @@ static void reset_config(struct usb_composite_dev *cdev)
1698 bitmap_zero(f->endpoints, 32);
1699 }
1700 cdev->config = NULL;
1701 + cdev->delayed_status = 0;
1702 }
1703
1704 static int set_config(struct usb_composite_dev *cdev,
1705 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1706 index c3d94853b4ab..496b7e39d5be 100644
1707 --- a/drivers/usb/serial/option.c
1708 +++ b/drivers/usb/serial/option.c
1709 @@ -85,6 +85,7 @@ static void option_instat_callback(struct urb *urb);
1710 #define HUAWEI_PRODUCT_K4505 0x1464
1711 #define HUAWEI_PRODUCT_K3765 0x1465
1712 #define HUAWEI_PRODUCT_K4605 0x14C6
1713 +#define HUAWEI_PRODUCT_E173S6 0x1C07
1714
1715 #define QUANTA_VENDOR_ID 0x0408
1716 #define QUANTA_PRODUCT_Q101 0xEA02
1717 @@ -572,6 +573,8 @@ static const struct usb_device_id option_ids[] = {
1718 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
1719 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
1720 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
1721 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S6, 0xff, 0xff, 0xff),
1722 + .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
1723 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
1724 .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
1725 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
1726 @@ -634,6 +637,10 @@ static const struct usb_device_id option_ids[] = {
1727 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) },
1728 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) },
1729 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) },
1730 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) },
1731 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) },
1732 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) },
1733 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) },
1734 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) },
1735 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) },
1736 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) },
1737 @@ -688,6 +695,10 @@ static const struct usb_device_id option_ids[] = {
1738 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) },
1739 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) },
1740 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) },
1741 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) },
1742 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) },
1743 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) },
1744 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) },
1745 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) },
1746 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) },
1747 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
1748 @@ -742,6 +753,10 @@ static const struct usb_device_id option_ids[] = {
1749 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
1750 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
1751 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
1752 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) },
1753 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) },
1754 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) },
1755 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) },
1756 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
1757 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
1758 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
1759 @@ -796,6 +811,10 @@ static const struct usb_device_id option_ids[] = {
1760 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
1761 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
1762 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
1763 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) },
1764 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) },
1765 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) },
1766 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) },
1767 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
1768 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
1769 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
1770 @@ -850,6 +869,10 @@ static const struct usb_device_id option_ids[] = {
1771 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
1772 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
1773 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
1774 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) },
1775 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) },
1776 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) },
1777 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) },
1778 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
1779 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
1780 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
1781 @@ -904,6 +927,10 @@ static const struct usb_device_id option_ids[] = {
1782 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
1783 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
1784 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
1785 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) },
1786 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) },
1787 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) },
1788 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) },
1789 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) },
1790 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) },
1791 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
1792 diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
1793 index 3fb83b0c28c2..ab6d3f56cbca 100644
1794 --- a/drivers/watchdog/sc1200wdt.c
1795 +++ b/drivers/watchdog/sc1200wdt.c
1796 @@ -409,8 +409,9 @@ static int __init sc1200wdt_init(void)
1797 #if defined CONFIG_PNP
1798 /* now that the user has specified an IO port and we haven't detected
1799 * any devices, disable pnp support */
1800 + if (isapnp)
1801 + pnp_unregister_driver(&scl200wdt_pnp_driver);
1802 isapnp = 0;
1803 - pnp_unregister_driver(&scl200wdt_pnp_driver);
1804 #endif
1805
1806 if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
1807 diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
1808 index e15d2b0d8d3b..0890c83643e9 100644
1809 --- a/fs/btrfs/acl.c
1810 +++ b/fs/btrfs/acl.c
1811 @@ -229,7 +229,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
1812 if (ret > 0) {
1813 /* we need an acl */
1814 ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
1815 - } else {
1816 + } else if (ret < 0) {
1817 cache_no_acl(inode);
1818 }
1819 } else {
1820 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
1821 index 1e2288dc5346..0bcee78cde16 100644
1822 --- a/fs/btrfs/inode.c
1823 +++ b/fs/btrfs/inode.c
1824 @@ -2419,10 +2419,23 @@ out_unlock:
1825 return ret;
1826 }
1827
1828 +static void free_sa_defrag_extent(struct new_sa_defrag_extent *new)
1829 +{
1830 + struct old_sa_defrag_extent *old, *tmp;
1831 +
1832 + if (!new)
1833 + return;
1834 +
1835 + list_for_each_entry_safe(old, tmp, &new->head, list) {
1836 + list_del(&old->list);
1837 + kfree(old);
1838 + }
1839 + kfree(new);
1840 +}
1841 +
1842 static void relink_file_extents(struct new_sa_defrag_extent *new)
1843 {
1844 struct btrfs_path *path;
1845 - struct old_sa_defrag_extent *old, *tmp;
1846 struct sa_defrag_extent_backref *backref;
1847 struct sa_defrag_extent_backref *prev = NULL;
1848 struct inode *inode;
1849 @@ -2465,16 +2478,11 @@ static void relink_file_extents(struct new_sa_defrag_extent *new)
1850 kfree(prev);
1851
1852 btrfs_free_path(path);
1853 -
1854 - list_for_each_entry_safe(old, tmp, &new->head, list) {
1855 - list_del(&old->list);
1856 - kfree(old);
1857 - }
1858 out:
1859 + free_sa_defrag_extent(new);
1860 +
1861 atomic_dec(&root->fs_info->defrag_running);
1862 wake_up(&root->fs_info->transaction_wait);
1863 -
1864 - kfree(new);
1865 }
1866
1867 static struct new_sa_defrag_extent *
1868 @@ -2484,7 +2492,7 @@ record_old_file_extents(struct inode *inode,
1869 struct btrfs_root *root = BTRFS_I(inode)->root;
1870 struct btrfs_path *path;
1871 struct btrfs_key key;
1872 - struct old_sa_defrag_extent *old, *tmp;
1873 + struct old_sa_defrag_extent *old;
1874 struct new_sa_defrag_extent *new;
1875 int ret;
1876
1877 @@ -2532,7 +2540,7 @@ record_old_file_extents(struct inode *inode,
1878 if (slot >= btrfs_header_nritems(l)) {
1879 ret = btrfs_next_leaf(root, path);
1880 if (ret < 0)
1881 - goto out_free_list;
1882 + goto out_free_path;
1883 else if (ret > 0)
1884 break;
1885 continue;
1886 @@ -2561,7 +2569,7 @@ record_old_file_extents(struct inode *inode,
1887
1888 old = kmalloc(sizeof(*old), GFP_NOFS);
1889 if (!old)
1890 - goto out_free_list;
1891 + goto out_free_path;
1892
1893 offset = max(new->file_pos, key.offset);
1894 end = min(new->file_pos + new->len, key.offset + num_bytes);
1895 @@ -2583,15 +2591,10 @@ next:
1896
1897 return new;
1898
1899 -out_free_list:
1900 - list_for_each_entry_safe(old, tmp, &new->head, list) {
1901 - list_del(&old->list);
1902 - kfree(old);
1903 - }
1904 out_free_path:
1905 btrfs_free_path(path);
1906 out_kfree:
1907 - kfree(new);
1908 + free_sa_defrag_extent(new);
1909 return NULL;
1910 }
1911
1912 @@ -2743,8 +2746,14 @@ out:
1913 btrfs_remove_ordered_extent(inode, ordered_extent);
1914
1915 /* for snapshot-aware defrag */
1916 - if (new)
1917 - relink_file_extents(new);
1918 + if (new) {
1919 + if (ret) {
1920 + free_sa_defrag_extent(new);
1921 + atomic_dec(&root->fs_info->defrag_running);
1922 + } else {
1923 + relink_file_extents(new);
1924 + }
1925 + }
1926
1927 /* once for us */
1928 btrfs_put_ordered_extent(ordered_extent);
1929 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
1930 index 8dedf4019672..145b2c75ab83 100644
1931 --- a/fs/btrfs/ioctl.c
1932 +++ b/fs/btrfs/ioctl.c
1933 @@ -2093,7 +2093,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
1934
1935 err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT);
1936 if (err == -EINTR)
1937 - goto out;
1938 + goto out_drop_write;
1939 dentry = lookup_one_len(vol_args->name, parent, namelen);
1940 if (IS_ERR(dentry)) {
1941 err = PTR_ERR(dentry);
1942 @@ -2235,6 +2235,7 @@ out_dput:
1943 dput(dentry);
1944 out_unlock_dir:
1945 mutex_unlock(&dir->i_mutex);
1946 +out_drop_write:
1947 mnt_drop_write_file(file);
1948 out:
1949 kfree(vol_args);
1950 diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
1951 index 09ea0bdde65f..256a9a46d544 100644
1952 --- a/fs/btrfs/send.c
1953 +++ b/fs/btrfs/send.c
1954 @@ -4623,8 +4623,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
1955 }
1956
1957 if (!access_ok(VERIFY_READ, arg->clone_sources,
1958 - sizeof(*arg->clone_sources *
1959 - arg->clone_sources_count))) {
1960 + sizeof(*arg->clone_sources) *
1961 + arg->clone_sources_count)) {
1962 ret = -EFAULT;
1963 goto out;
1964 }
1965 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
1966 index cf68596b51fb..bca436330681 100644
1967 --- a/fs/btrfs/tree-log.c
1968 +++ b/fs/btrfs/tree-log.c
1969 @@ -3314,7 +3314,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
1970 btrfs_set_token_file_extent_type(leaf, fi,
1971 BTRFS_FILE_EXTENT_REG,
1972 &token);
1973 - if (em->block_start == 0)
1974 + if (em->block_start == EXTENT_MAP_HOLE)
1975 skip_csum = true;
1976 }
1977
1978 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
1979 index 8bffb9174afb..b6c23c4abae2 100644
1980 --- a/fs/btrfs/volumes.c
1981 +++ b/fs/btrfs/volumes.c
1982 @@ -4248,6 +4248,7 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
1983 btrfs_emerg(fs_info, "Invalid mapping for %Lu-%Lu, got "
1984 "%Lu-%Lu\n", logical, logical+len, em->start,
1985 em->start + em->len);
1986 + free_extent_map(em);
1987 return 1;
1988 }
1989
1990 @@ -4429,6 +4430,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
1991 btrfs_crit(fs_info, "found a bad mapping, wanted %Lu, "
1992 "found %Lu-%Lu\n", logical, em->start,
1993 em->start + em->len);
1994 + free_extent_map(em);
1995 return -EINVAL;
1996 }
1997
1998 diff --git a/fs/nfs/blocklayout/extents.c b/fs/nfs/blocklayout/extents.c
1999 index 9c3e117c3ed1..4d0161442565 100644
2000 --- a/fs/nfs/blocklayout/extents.c
2001 +++ b/fs/nfs/blocklayout/extents.c
2002 @@ -44,7 +44,7 @@
2003 static inline sector_t normalize(sector_t s, int base)
2004 {
2005 sector_t tmp = s; /* Since do_div modifies its argument */
2006 - return s - do_div(tmp, base);
2007 + return s - sector_div(tmp, base);
2008 }
2009
2010 static inline sector_t normalize_up(sector_t s, int base)
2011 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2012 index 23881380dc6f..75e49d42a7fb 100644
2013 --- a/fs/nfs/nfs4proc.c
2014 +++ b/fs/nfs/nfs4proc.c
2015 @@ -4222,8 +4222,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
2016 dprintk("%s ERROR %d, Reset session\n", __func__,
2017 task->tk_status);
2018 nfs4_schedule_session_recovery(clp->cl_session, task->tk_status);
2019 - task->tk_status = 0;
2020 - return -EAGAIN;
2021 + goto wait_on_recovery;
2022 #endif /* CONFIG_NFS_V4_1 */
2023 case -NFS4ERR_DELAY:
2024 nfs_inc_server_stats(server, NFSIOS_DELAY);
2025 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
2026 index e76244edd748..ec8d97ddc635 100644
2027 --- a/fs/nfsd/nfscache.c
2028 +++ b/fs/nfsd/nfscache.c
2029 @@ -129,6 +129,13 @@ nfsd_reply_cache_alloc(void)
2030 }
2031
2032 static void
2033 +nfsd_reply_cache_unhash(struct svc_cacherep *rp)
2034 +{
2035 + hlist_del_init(&rp->c_hash);
2036 + list_del_init(&rp->c_lru);
2037 +}
2038 +
2039 +static void
2040 nfsd_reply_cache_free_locked(struct svc_cacherep *rp)
2041 {
2042 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) {
2043 @@ -403,7 +410,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
2044 rp = list_first_entry(&lru_head, struct svc_cacherep, c_lru);
2045 if (nfsd_cache_entry_expired(rp) ||
2046 num_drc_entries >= max_drc_entries) {
2047 - lru_put_end(rp);
2048 + nfsd_reply_cache_unhash(rp);
2049 prune_cache_entries();
2050 goto search_cache;
2051 }
2052 diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
2053 index 3c3644ea825b..2288db4e1784 100644
2054 --- a/fs/xfs/xfs_fsops.c
2055 +++ b/fs/xfs/xfs_fsops.c
2056 @@ -216,6 +216,8 @@ xfs_growfs_data_private(
2057 */
2058 nfree = 0;
2059 for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) {
2060 + __be32 *agfl_bno;
2061 +
2062 /*
2063 * AG freespace header block
2064 */
2065 @@ -275,8 +277,10 @@ xfs_growfs_data_private(
2066 agfl->agfl_seqno = cpu_to_be32(agno);
2067 uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_uuid);
2068 }
2069 +
2070 + agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, bp);
2071 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
2072 - agfl->agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
2073 + agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
2074
2075 error = xfs_bwrite(bp);
2076 xfs_buf_relse(bp);
2077 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
2078 index ca01d830e989..83dfe6e73235 100644
2079 --- a/fs/xfs/xfs_ioctl.c
2080 +++ b/fs/xfs/xfs_ioctl.c
2081 @@ -409,7 +409,8 @@ xfs_attrlist_by_handle(
2082 return -XFS_ERROR(EPERM);
2083 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
2084 return -XFS_ERROR(EFAULT);
2085 - if (al_hreq.buflen > XATTR_LIST_MAX)
2086 + if (al_hreq.buflen < sizeof(struct attrlist) ||
2087 + al_hreq.buflen > XATTR_LIST_MAX)
2088 return -XFS_ERROR(EINVAL);
2089
2090 /*
2091 diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
2092 index c0c66259cc91..68799d7f02cc 100644
2093 --- a/fs/xfs/xfs_ioctl32.c
2094 +++ b/fs/xfs/xfs_ioctl32.c
2095 @@ -359,7 +359,8 @@ xfs_compat_attrlist_by_handle(
2096 if (copy_from_user(&al_hreq, arg,
2097 sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
2098 return -XFS_ERROR(EFAULT);
2099 - if (al_hreq.buflen > XATTR_LIST_MAX)
2100 + if (al_hreq.buflen < sizeof(struct attrlist) ||
2101 + al_hreq.buflen > XATTR_LIST_MAX)
2102 return -XFS_ERROR(EINVAL);
2103
2104 /*
2105 diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h
2106 index 973ce10c40b6..dc1bd3dcf11f 100644
2107 --- a/include/linux/compiler-intel.h
2108 +++ b/include/linux/compiler-intel.h
2109 @@ -28,8 +28,6 @@
2110
2111 #endif
2112
2113 -#define uninitialized_var(x) x
2114 -
2115 #ifndef __HAVE_BUILTIN_BSWAP16__
2116 /* icc has this, but it's called _bswap16 */
2117 #define __HAVE_BUILTIN_BSWAP16__
2118 diff --git a/include/linux/kexec.h b/include/linux/kexec.h
2119 index d78d28a733b1..5fd33dc1fe3a 100644
2120 --- a/include/linux/kexec.h
2121 +++ b/include/linux/kexec.h
2122 @@ -198,6 +198,9 @@ extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
2123 extern size_t vmcoreinfo_size;
2124 extern size_t vmcoreinfo_max_size;
2125
2126 +/* flag to track if kexec reboot is in progress */
2127 +extern bool kexec_in_progress;
2128 +
2129 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
2130 unsigned long long *crash_size, unsigned long long *crash_base);
2131 int parse_crashkernel_high(char *cmdline, unsigned long long system_ram,
2132 diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h
2133 index cf15b8213df7..54aff2d73150 100644
2134 --- a/include/sound/memalloc.h
2135 +++ b/include/sound/memalloc.h
2136 @@ -103,7 +103,7 @@ static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
2137 {
2138 struct snd_sg_buf *sgbuf = dmab->private_data;
2139 dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
2140 - addr &= PAGE_MASK;
2141 + addr &= ~((dma_addr_t)PAGE_SIZE - 1);
2142 return addr + offset % PAGE_SIZE;
2143 }
2144
2145 diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
2146 index d630163b9a2e..5759810e1c1b 100644
2147 --- a/include/uapi/sound/compress_offload.h
2148 +++ b/include/uapi/sound/compress_offload.h
2149 @@ -30,7 +30,7 @@
2150 #include <sound/compress_params.h>
2151
2152
2153 -#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 1)
2154 +#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 2)
2155 /**
2156 * struct snd_compressed_buffer: compressed buffer
2157 * @fragment_size: size of buffer fragment in bytes
2158 @@ -67,8 +67,8 @@ struct snd_compr_params {
2159 struct snd_compr_tstamp {
2160 __u32 byte_offset;
2161 __u32 copied_total;
2162 - snd_pcm_uframes_t pcm_frames;
2163 - snd_pcm_uframes_t pcm_io_frames;
2164 + __u32 pcm_frames;
2165 + __u32 pcm_io_frames;
2166 __u32 sampling_rate;
2167 };
2168
2169 diff --git a/kernel/futex.c b/kernel/futex.c
2170 index 49dacfb45745..a283b3041072 100644
2171 --- a/kernel/futex.c
2172 +++ b/kernel/futex.c
2173 @@ -287,7 +287,7 @@ again:
2174 put_page(page);
2175 /* serialize against __split_huge_page_splitting() */
2176 local_irq_disable();
2177 - if (likely(__get_user_pages_fast(address, 1, 1, &page) == 1)) {
2178 + if (likely(__get_user_pages_fast(address, 1, !ro, &page) == 1)) {
2179 page_head = compound_head(page);
2180 /*
2181 * page_head is valid pointer but we must pin
2182 diff --git a/kernel/kexec.c b/kernel/kexec.c
2183 index 59f7b55ba745..1f8d9382dbac 100644
2184 --- a/kernel/kexec.c
2185 +++ b/kernel/kexec.c
2186 @@ -47,6 +47,9 @@ u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
2187 size_t vmcoreinfo_size;
2188 size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
2189
2190 +/* Flag to indicate we are going to kexec a new kernel */
2191 +bool kexec_in_progress = false;
2192 +
2193 /* Location of the reserved area for the crash kernel */
2194 struct resource crashk_res = {
2195 .name = "Crash kernel",
2196 @@ -1678,6 +1681,7 @@ int kernel_kexec(void)
2197 } else
2198 #endif
2199 {
2200 + kexec_in_progress = true;
2201 kernel_restart_prepare(NULL);
2202 printk(KERN_EMERG "Starting new kernel\n");
2203 machine_shutdown();
2204 diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
2205 index 75024a673520..e745a1548367 100644
2206 --- a/kernel/sched/debug.c
2207 +++ b/kernel/sched/debug.c
2208 @@ -224,6 +224,14 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
2209 SEQ_printf(m, " .%-30s: %d\n", "tg->runnable_avg",
2210 atomic_read(&cfs_rq->tg->runnable_avg));
2211 #endif
2212 +#ifdef CONFIG_CFS_BANDWIDTH
2213 + SEQ_printf(m, " .%-30s: %d\n", "tg->cfs_bandwidth.timer_active",
2214 + cfs_rq->tg->cfs_bandwidth.timer_active);
2215 + SEQ_printf(m, " .%-30s: %d\n", "throttled",
2216 + cfs_rq->throttled);
2217 + SEQ_printf(m, " .%-30s: %d\n", "throttle_count",
2218 + cfs_rq->throttle_count);
2219 +#endif
2220
2221 print_cfs_group_stats(m, cpu, cfs_rq->tg);
2222 #endif
2223 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
2224 index 009a62bb859d..da7eebb22b06 100644
2225 --- a/kernel/sched/fair.c
2226 +++ b/kernel/sched/fair.c
2227 @@ -2288,6 +2288,8 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
2228 cfs_rq->throttled_clock = rq->clock;
2229 raw_spin_lock(&cfs_b->lock);
2230 list_add_tail_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
2231 + if (!cfs_b->timer_active)
2232 + __start_cfs_bandwidth(cfs_b);
2233 raw_spin_unlock(&cfs_b->lock);
2234 }
2235
2236 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
2237 index 233f1911dc34..c3075b552248 100644
2238 --- a/net/ipv4/udp.c
2239 +++ b/net/ipv4/udp.c
2240 @@ -1073,9 +1073,6 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset,
2241 if (flags & MSG_SENDPAGE_NOTLAST)
2242 flags |= MSG_MORE;
2243
2244 - if (flags & MSG_SENDPAGE_NOTLAST)
2245 - flags |= MSG_MORE;
2246 -
2247 if (!up->pending) {
2248 struct msghdr msg = { .msg_flags = flags|MSG_MORE };
2249
2250 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
2251 index 0516ebbea80b..209bb4d6e188 100644
2252 --- a/net/ipv6/ip6_tunnel.c
2253 +++ b/net/ipv6/ip6_tunnel.c
2254 @@ -1711,8 +1711,6 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
2255 }
2256 }
2257
2258 - t = rtnl_dereference(ip6n->tnls_wc[0]);
2259 - unregister_netdevice_queue(t->dev, &list);
2260 unregister_netdevice_many(&list);
2261 }
2262
2263 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
2264 index 5ab17b82605d..18687f1fca75 100644
2265 --- a/net/mac80211/cfg.c
2266 +++ b/net/mac80211/cfg.c
2267 @@ -2356,8 +2356,7 @@ static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2268 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2269 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2270
2271 - if (sdata->vif.type != NL80211_IFTYPE_STATION &&
2272 - sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
2273 + if (sdata->vif.type != NL80211_IFTYPE_STATION)
2274 return -EOPNOTSUPP;
2275
2276 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2277 diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
2278 index ec09bcba9bae..fae73b0ef14b 100644
2279 --- a/net/mac80211/rx.c
2280 +++ b/net/mac80211/rx.c
2281 @@ -864,7 +864,8 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx,
2282 u16 sc;
2283 u8 tid, ack_policy;
2284
2285 - if (!ieee80211_is_data_qos(hdr->frame_control))
2286 + if (!ieee80211_is_data_qos(hdr->frame_control) ||
2287 + is_multicast_ether_addr(hdr->addr1))
2288 goto dont_reorder;
2289
2290 /*
2291 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
2292 index 5c6f2cd2d095..5e58d7dd7b69 100644
2293 --- a/security/selinux/hooks.c
2294 +++ b/security/selinux/hooks.c
2295 @@ -53,6 +53,7 @@
2296 #include <net/ip.h> /* for local_port_range[] */
2297 #include <net/sock.h>
2298 #include <net/tcp.h> /* struct or_callable used in sock_rcv_skb */
2299 +#include <net/inet_connection_sock.h>
2300 #include <net/net_namespace.h>
2301 #include <net/netlabel.h>
2302 #include <linux/uaccess.h>
2303 @@ -3736,6 +3737,30 @@ static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid)
2304 return 0;
2305 }
2306
2307 +/**
2308 + * selinux_conn_sid - Determine the child socket label for a connection
2309 + * @sk_sid: the parent socket's SID
2310 + * @skb_sid: the packet's SID
2311 + * @conn_sid: the resulting connection SID
2312 + *
2313 + * If @skb_sid is valid then the user:role:type information from @sk_sid is
2314 + * combined with the MLS information from @skb_sid in order to create
2315 + * @conn_sid. If @skb_sid is not valid then then @conn_sid is simply a copy
2316 + * of @sk_sid. Returns zero on success, negative values on failure.
2317 + *
2318 + */
2319 +static int selinux_conn_sid(u32 sk_sid, u32 skb_sid, u32 *conn_sid)
2320 +{
2321 + int err = 0;
2322 +
2323 + if (skb_sid != SECSID_NULL)
2324 + err = security_sid_mls_copy(sk_sid, skb_sid, conn_sid);
2325 + else
2326 + *conn_sid = sk_sid;
2327 +
2328 + return err;
2329 +}
2330 +
2331 /* socket security operations */
2332
2333 static int socket_sockcreate_sid(const struct task_security_struct *tsec,
2334 @@ -4342,7 +4367,7 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
2335 struct sk_security_struct *sksec = sk->sk_security;
2336 int err;
2337 u16 family = sk->sk_family;
2338 - u32 newsid;
2339 + u32 connsid;
2340 u32 peersid;
2341
2342 /* handle mapped IPv4 packets arriving via IPv6 sockets */
2343 @@ -4352,16 +4377,11 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
2344 err = selinux_skb_peerlbl_sid(skb, family, &peersid);
2345 if (err)
2346 return err;
2347 - if (peersid == SECSID_NULL) {
2348 - req->secid = sksec->sid;
2349 - req->peer_secid = SECSID_NULL;
2350 - } else {
2351 - err = security_sid_mls_copy(sksec->sid, peersid, &newsid);
2352 - if (err)
2353 - return err;
2354 - req->secid = newsid;
2355 - req->peer_secid = peersid;
2356 - }
2357 + err = selinux_conn_sid(sksec->sid, peersid, &connsid);
2358 + if (err)
2359 + return err;
2360 + req->secid = connsid;
2361 + req->peer_secid = peersid;
2362
2363 return selinux_netlbl_inet_conn_request(req, family);
2364 }
2365 @@ -4621,6 +4641,7 @@ static unsigned int selinux_ipv6_forward(unsigned int hooknum,
2366 static unsigned int selinux_ip_output(struct sk_buff *skb,
2367 u16 family)
2368 {
2369 + struct sock *sk;
2370 u32 sid;
2371
2372 if (!netlbl_enabled())
2373 @@ -4629,8 +4650,27 @@ static unsigned int selinux_ip_output(struct sk_buff *skb,
2374 /* we do this in the LOCAL_OUT path and not the POST_ROUTING path
2375 * because we want to make sure we apply the necessary labeling
2376 * before IPsec is applied so we can leverage AH protection */
2377 - if (skb->sk) {
2378 - struct sk_security_struct *sksec = skb->sk->sk_security;
2379 + sk = skb->sk;
2380 + if (sk) {
2381 + struct sk_security_struct *sksec;
2382 +
2383 + if (sk->sk_state == TCP_LISTEN)
2384 + /* if the socket is the listening state then this
2385 + * packet is a SYN-ACK packet which means it needs to
2386 + * be labeled based on the connection/request_sock and
2387 + * not the parent socket. unfortunately, we can't
2388 + * lookup the request_sock yet as it isn't queued on
2389 + * the parent socket until after the SYN-ACK is sent.
2390 + * the "solution" is to simply pass the packet as-is
2391 + * as any IP option based labeling should be copied
2392 + * from the initial connection request (in the IP
2393 + * layer). it is far from ideal, but until we get a
2394 + * security label in the packet itself this is the
2395 + * best we can do. */
2396 + return NF_ACCEPT;
2397 +
2398 + /* standard practice, label using the parent socket */
2399 + sksec = sk->sk_security;
2400 sid = sksec->sid;
2401 } else
2402 sid = SECINITSID_KERNEL;
2403 @@ -4715,12 +4755,12 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
2404 if (!secmark_active && !peerlbl_active)
2405 return NF_ACCEPT;
2406
2407 - /* if the packet is being forwarded then get the peer label from the
2408 - * packet itself; otherwise check to see if it is from a local
2409 - * application or the kernel, if from an application get the peer label
2410 - * from the sending socket, otherwise use the kernel's sid */
2411 sk = skb->sk;
2412 if (sk == NULL) {
2413 + /* Without an associated socket the packet is either coming
2414 + * from the kernel or it is being forwarded; check the packet
2415 + * to determine which and if the packet is being forwarded
2416 + * query the packet directly to determine the security label. */
2417 if (skb->skb_iif) {
2418 secmark_perm = PACKET__FORWARD_OUT;
2419 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid))
2420 @@ -4729,7 +4769,26 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
2421 secmark_perm = PACKET__SEND;
2422 peer_sid = SECINITSID_KERNEL;
2423 }
2424 + } else if (sk->sk_state == TCP_LISTEN) {
2425 + /* Locally generated packet but the associated socket is in the
2426 + * listening state which means this is a SYN-ACK packet. In
2427 + * this particular case the correct security label is assigned
2428 + * to the connection/request_sock but unfortunately we can't
2429 + * query the request_sock as it isn't queued on the parent
2430 + * socket until after the SYN-ACK packet is sent; the only
2431 + * viable choice is to regenerate the label like we do in
2432 + * selinux_inet_conn_request(). See also selinux_ip_output()
2433 + * for similar problems. */
2434 + u32 skb_sid;
2435 + struct sk_security_struct *sksec = sk->sk_security;
2436 + if (selinux_skb_peerlbl_sid(skb, family, &skb_sid))
2437 + return NF_DROP;
2438 + if (selinux_conn_sid(sksec->sid, skb_sid, &peer_sid))
2439 + return NF_DROP;
2440 + secmark_perm = PACKET__SEND;
2441 } else {
2442 + /* Locally generated packet, fetch the security label from the
2443 + * associated socket. */
2444 struct sk_security_struct *sksec = sk->sk_security;
2445 peer_sid = sksec->sid;
2446 secmark_perm = PACKET__SEND;
2447 diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
2448 index 7975031312cb..8536266e4004 100644
2449 --- a/sound/pci/hda/hda_generic.c
2450 +++ b/sound/pci/hda/hda_generic.c
2451 @@ -468,6 +468,20 @@ static void invalidate_nid_path(struct hda_codec *codec, int idx)
2452 memset(path, 0, sizeof(*path));
2453 }
2454
2455 +/* return a DAC if paired to the given pin by codec driver */
2456 +static hda_nid_t get_preferred_dac(struct hda_codec *codec, hda_nid_t pin)
2457 +{
2458 + struct hda_gen_spec *spec = codec->spec;
2459 + const hda_nid_t *list = spec->preferred_dacs;
2460 +
2461 + if (!list)
2462 + return 0;
2463 + for (; *list; list += 2)
2464 + if (*list == pin)
2465 + return list[1];
2466 + return 0;
2467 +}
2468 +
2469 /* look for an empty DAC slot */
2470 static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin,
2471 bool is_digital)
2472 @@ -1134,7 +1148,14 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
2473 continue;
2474 }
2475
2476 - dacs[i] = look_for_dac(codec, pin, false);
2477 + dacs[i] = get_preferred_dac(codec, pin);
2478 + if (dacs[i]) {
2479 + if (is_dac_already_used(codec, dacs[i]))
2480 + badness += bad->shared_primary;
2481 + }
2482 +
2483 + if (!dacs[i])
2484 + dacs[i] = look_for_dac(codec, pin, false);
2485 if (!dacs[i] && !i) {
2486 /* try to steal the DAC of surrounds for the front */
2487 for (j = 1; j < num_outs; j++) {
2488 @@ -4201,6 +4222,26 @@ static unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
2489 return AC_PWRST_D3;
2490 }
2491
2492 +/* mute all aamix inputs initially; parse up to the first leaves */
2493 +static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix)
2494 +{
2495 + int i, nums;
2496 + const hda_nid_t *conn;
2497 + bool has_amp;
2498 +
2499 + nums = snd_hda_get_conn_list(codec, mix, &conn);
2500 + has_amp = nid_has_mute(codec, mix, HDA_INPUT);
2501 + for (i = 0; i < nums; i++) {
2502 + if (has_amp)
2503 + snd_hda_codec_amp_stereo(codec, mix,
2504 + HDA_INPUT, i,
2505 + 0xff, HDA_AMP_MUTE);
2506 + else if (nid_has_volume(codec, conn[i], HDA_OUTPUT))
2507 + snd_hda_codec_amp_stereo(codec, conn[i],
2508 + HDA_OUTPUT, 0,
2509 + 0xff, HDA_AMP_MUTE);
2510 + }
2511 +}
2512
2513 /*
2514 * Parse the given BIOS configuration and set up the hda_gen_spec
2515 @@ -4339,6 +4380,10 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
2516 }
2517 }
2518
2519 + /* mute all aamix input initially */
2520 + if (spec->mixer_nid)
2521 + mute_all_mixer_nid(codec, spec->mixer_nid);
2522 +
2523 dig_only:
2524 parse_digital(codec);
2525
2526 diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
2527 index 76200314ee95..a18a1005002f 100644
2528 --- a/sound/pci/hda/hda_generic.h
2529 +++ b/sound/pci/hda/hda_generic.h
2530 @@ -241,6 +241,9 @@ struct hda_gen_spec {
2531 const struct badness_table *main_out_badness;
2532 const struct badness_table *extra_out_badness;
2533
2534 + /* preferred pin/DAC pairs; an array of paired NIDs */
2535 + const hda_nid_t *preferred_dacs;
2536 +
2537 /* loopback mixing mode */
2538 bool aamix_mode;
2539
2540 diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
2541 index e17b55a95bc5..a7b07f72c9dd 100644
2542 --- a/sound/pci/hda/patch_analog.c
2543 +++ b/sound/pci/hda/patch_analog.c
2544 @@ -1227,6 +1227,14 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec)
2545 {
2546 int err;
2547 struct ad198x_spec *spec;
2548 + static hda_nid_t preferred_pairs[] = {
2549 + 0x1a, 0x03,
2550 + 0x1b, 0x03,
2551 + 0x1c, 0x04,
2552 + 0x1d, 0x05,
2553 + 0x1e, 0x03,
2554 + 0
2555 + };
2556
2557 err = alloc_ad_spec(codec);
2558 if (err < 0)
2559 @@ -1247,6 +1255,8 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec)
2560 * So, let's disable the shared stream.
2561 */
2562 spec->gen.multiout.no_share_stream = 1;
2563 + /* give fixed DAC/pin pairs */
2564 + spec->gen.preferred_dacs = preferred_pairs;
2565
2566 snd_hda_pick_fixup(codec, NULL, ad1986a_fixup_tbl, ad1986a_fixups);
2567 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2568 diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
2569 index b93799201578..8c1d1cf0c0cd 100644
2570 --- a/sound/pci/hda/patch_hdmi.c
2571 +++ b/sound/pci/hda/patch_hdmi.c
2572 @@ -2001,8 +2001,9 @@ static int simple_playback_build_controls(struct hda_codec *codec)
2573 int err;
2574
2575 per_cvt = get_cvt(spec, 0);
2576 - err = snd_hda_create_spdif_out_ctls(codec, per_cvt->cvt_nid,
2577 - per_cvt->cvt_nid);
2578 + err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid,
2579 + per_cvt->cvt_nid,
2580 + HDA_PCM_TYPE_HDMI);
2581 if (err < 0)
2582 return err;
2583 return simple_hdmi_build_jack(codec, 0);
2584 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
2585 index 302681c4aa44..eb99458f5b68 100644
2586 --- a/virt/kvm/kvm_main.c
2587 +++ b/virt/kvm/kvm_main.c
2588 @@ -1904,6 +1904,9 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
2589 int r;
2590 struct kvm_vcpu *vcpu, *v;
2591
2592 + if (id >= KVM_MAX_VCPUS)
2593 + return -EINVAL;
2594 +
2595 vcpu = kvm_arch_vcpu_create(kvm, id);
2596 if (IS_ERR(vcpu))
2597 return PTR_ERR(vcpu);