Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0341-4.9.242-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3643 - (show annotations) (download)
Mon Oct 24 14:07:23 2022 UTC (18 months, 1 week ago) by niro
File size: 130338 byte(s)
-linux-4.9.242
1 diff --git a/Makefile b/Makefile
2 index c4f3d2ea9b43e..d41de2c1159e7 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 241
9 +SUBLEVEL = 242
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
14 index 705a682084232..85d9ea4a0accc 100644
15 --- a/arch/arc/kernel/entry.S
16 +++ b/arch/arc/kernel/entry.S
17 @@ -156,6 +156,7 @@ END(EV_Extension)
18 tracesys:
19 ; save EFA in case tracer wants the PC of traced task
20 ; using ERET won't work since next-PC has already committed
21 + lr r12, [efa]
22 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11
23 st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address
24
25 @@ -198,9 +199,15 @@ tracesys_exit:
26 ; Breakpoint TRAP
27 ; ---------------------------------------------
28 trap_with_param:
29 - mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc
30 +
31 + ; stop_pc info by gdb needs this info
32 + lr r0, [efa]
33 mov r1, sp
34
35 + ; Now that we have read EFA, it is safe to do "fake" rtie
36 + ; and get out of CPU exception mode
37 + FAKE_RET_FROM_EXCPN
38 +
39 ; Save callee regs in case gdb wants to have a look
40 ; SP will grow up by size of CALLEE Reg-File
41 ; NOTE: clobbers r12
42 @@ -227,10 +234,6 @@ ENTRY(EV_Trap)
43
44 EXCEPTION_PROLOGUE
45
46 - lr r12, [efa]
47 -
48 - FAKE_RET_FROM_EXCPN
49 -
50 ;============ TRAP 1 :breakpoints
51 ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR)
52 bmsk.f 0, r9, 7
53 @@ -238,6 +241,9 @@ ENTRY(EV_Trap)
54
55 ;============ TRAP (no param): syscall top level
56
57 + ; First return from Exception to pure K mode (Exception/IRQs renabled)
58 + FAKE_RET_FROM_EXCPN
59 +
60 ; If syscall tracing ongoing, invoke pre-post-hooks
61 GET_CURR_THR_INFO_FLAGS r10
62 btst r10, TIF_SYSCALL_TRACE
63 diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c
64 index b9192a653b7e3..165158735aa6b 100644
65 --- a/arch/arc/kernel/stacktrace.c
66 +++ b/arch/arc/kernel/stacktrace.c
67 @@ -113,7 +113,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
68 int (*consumer_fn) (unsigned int, void *), void *arg)
69 {
70 #ifdef CONFIG_ARC_DW2_UNWIND
71 - int ret = 0;
72 + int ret = 0, cnt = 0;
73 unsigned int address;
74 struct unwind_frame_info frame_info;
75
76 @@ -133,6 +133,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
77 break;
78
79 frame_info.regs.r63 = frame_info.regs.r31;
80 +
81 + if (cnt++ > 128) {
82 + printk("unwinder looping too long, aborting !\n");
83 + return 0;
84 + }
85 }
86
87 return address; /* return the last address it saw */
88 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
89 index 56bd9beb6a35c..ae55f5db97f8d 100644
90 --- a/arch/arm/Kconfig
91 +++ b/arch/arm/Kconfig
92 @@ -601,7 +601,9 @@ config ARCH_S3C24XX
93 select HAVE_S3C_RTC if RTC_CLASS
94 select MULTI_IRQ_HANDLER
95 select NEED_MACH_IO_H
96 + select S3C2410_WATCHDOG
97 select SAMSUNG_ATAGS
98 + select WATCHDOG
99 help
100 Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443
101 and S3C2450 SoCs based systems, such as the Simtec Electronics BAST
102 diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi
103 index 0c10ba517cd04..798f676041e09 100644
104 --- a/arch/arm/boot/dts/s5pv210.dtsi
105 +++ b/arch/arm/boot/dts/s5pv210.dtsi
106 @@ -101,19 +101,16 @@
107 };
108
109 clocks: clock-controller@e0100000 {
110 - compatible = "samsung,s5pv210-clock", "simple-bus";
111 + compatible = "samsung,s5pv210-clock";
112 reg = <0xe0100000 0x10000>;
113 clock-names = "xxti", "xusbxti";
114 clocks = <&xxti>, <&xusbxti>;
115 #clock-cells = <1>;
116 - #address-cells = <1>;
117 - #size-cells = <1>;
118 - ranges;
119 + };
120
121 - pmu_syscon: syscon@e0108000 {
122 - compatible = "samsung-s5pv210-pmu", "syscon";
123 - reg = <0xe0108000 0x8000>;
124 - };
125 + pmu_syscon: syscon@e0108000 {
126 + compatible = "samsung-s5pv210-pmu", "syscon";
127 + reg = <0xe0108000 0x8000>;
128 };
129
130 pinctrl0: pinctrl@e0200000 {
131 @@ -129,35 +126,28 @@
132 };
133 };
134
135 - amba {
136 - #address-cells = <1>;
137 - #size-cells = <1>;
138 - compatible = "simple-bus";
139 - ranges;
140 -
141 - pdma0: dma@e0900000 {
142 - compatible = "arm,pl330", "arm,primecell";
143 - reg = <0xe0900000 0x1000>;
144 - interrupt-parent = <&vic0>;
145 - interrupts = <19>;
146 - clocks = <&clocks CLK_PDMA0>;
147 - clock-names = "apb_pclk";
148 - #dma-cells = <1>;
149 - #dma-channels = <8>;
150 - #dma-requests = <32>;
151 - };
152 + pdma0: dma@e0900000 {
153 + compatible = "arm,pl330", "arm,primecell";
154 + reg = <0xe0900000 0x1000>;
155 + interrupt-parent = <&vic0>;
156 + interrupts = <19>;
157 + clocks = <&clocks CLK_PDMA0>;
158 + clock-names = "apb_pclk";
159 + #dma-cells = <1>;
160 + #dma-channels = <8>;
161 + #dma-requests = <32>;
162 + };
163
164 - pdma1: dma@e0a00000 {
165 - compatible = "arm,pl330", "arm,primecell";
166 - reg = <0xe0a00000 0x1000>;
167 - interrupt-parent = <&vic0>;
168 - interrupts = <20>;
169 - clocks = <&clocks CLK_PDMA1>;
170 - clock-names = "apb_pclk";
171 - #dma-cells = <1>;
172 - #dma-channels = <8>;
173 - #dma-requests = <32>;
174 - };
175 + pdma1: dma@e0a00000 {
176 + compatible = "arm,pl330", "arm,primecell";
177 + reg = <0xe0a00000 0x1000>;
178 + interrupt-parent = <&vic0>;
179 + interrupts = <20>;
180 + clocks = <&clocks CLK_PDMA1>;
181 + clock-names = "apb_pclk";
182 + #dma-cells = <1>;
183 + #dma-channels = <8>;
184 + #dma-requests = <32>;
185 };
186
187 spi0: spi@e1300000 {
188 @@ -230,43 +220,36 @@
189 status = "disabled";
190 };
191
192 - audio-subsystem {
193 - compatible = "samsung,s5pv210-audss", "simple-bus";
194 - #address-cells = <1>;
195 - #size-cells = <1>;
196 - ranges;
197 -
198 - clk_audss: clock-controller@eee10000 {
199 - compatible = "samsung,s5pv210-audss-clock";
200 - reg = <0xeee10000 0x1000>;
201 - clock-names = "hclk", "xxti",
202 - "fout_epll",
203 - "sclk_audio0";
204 - clocks = <&clocks DOUT_HCLKP>, <&xxti>,
205 - <&clocks FOUT_EPLL>,
206 - <&clocks SCLK_AUDIO0>;
207 - #clock-cells = <1>;
208 - };
209 + clk_audss: clock-controller@eee10000 {
210 + compatible = "samsung,s5pv210-audss-clock";
211 + reg = <0xeee10000 0x1000>;
212 + clock-names = "hclk", "xxti",
213 + "fout_epll",
214 + "sclk_audio0";
215 + clocks = <&clocks DOUT_HCLKP>, <&xxti>,
216 + <&clocks FOUT_EPLL>,
217 + <&clocks SCLK_AUDIO0>;
218 + #clock-cells = <1>;
219 + };
220
221 - i2s0: i2s@eee30000 {
222 - compatible = "samsung,s5pv210-i2s";
223 - reg = <0xeee30000 0x1000>;
224 - interrupt-parent = <&vic2>;
225 - interrupts = <16>;
226 - dma-names = "rx", "tx", "tx-sec";
227 - dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>;
228 - clock-names = "iis",
229 - "i2s_opclk0",
230 - "i2s_opclk1";
231 - clocks = <&clk_audss CLK_I2S>,
232 - <&clk_audss CLK_I2S>,
233 - <&clk_audss CLK_DOUT_AUD_BUS>;
234 - samsung,idma-addr = <0xc0010000>;
235 - pinctrl-names = "default";
236 - pinctrl-0 = <&i2s0_bus>;
237 - #sound-dai-cells = <0>;
238 - status = "disabled";
239 - };
240 + i2s0: i2s@eee30000 {
241 + compatible = "samsung,s5pv210-i2s";
242 + reg = <0xeee30000 0x1000>;
243 + interrupt-parent = <&vic2>;
244 + interrupts = <16>;
245 + dma-names = "rx", "tx", "tx-sec";
246 + dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>;
247 + clock-names = "iis",
248 + "i2s_opclk0",
249 + "i2s_opclk1";
250 + clocks = <&clk_audss CLK_I2S>,
251 + <&clk_audss CLK_I2S>,
252 + <&clk_audss CLK_DOUT_AUD_BUS>;
253 + samsung,idma-addr = <0xc0010000>;
254 + pinctrl-names = "default";
255 + pinctrl-0 = <&i2s0_bus>;
256 + #sound-dai-cells = <0>;
257 + status = "disabled";
258 };
259
260 i2s1: i2s@e2100000 {
261 diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
262 index 7e7dfc2b43db0..d1af56d2f25e5 100644
263 --- a/arch/arm/boot/dts/sun4i-a10.dtsi
264 +++ b/arch/arm/boot/dts/sun4i-a10.dtsi
265 @@ -144,7 +144,7 @@
266 trips {
267 cpu_alert0: cpu_alert0 {
268 /* milliCelsius */
269 - temperature = <850000>;
270 + temperature = <85000>;
271 hysteresis = <2000>;
272 type = "passive";
273 };
274 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
275 index 283084f6286d9..671dbc28e5d46 100644
276 --- a/arch/arm/kernel/hw_breakpoint.c
277 +++ b/arch/arm/kernel/hw_breakpoint.c
278 @@ -688,6 +688,40 @@ static void disable_single_step(struct perf_event *bp)
279 arch_install_hw_breakpoint(bp);
280 }
281
282 +/*
283 + * Arm32 hardware does not always report a watchpoint hit address that matches
284 + * one of the watchpoints set. It can also report an address "near" the
285 + * watchpoint if a single instruction access both watched and unwatched
286 + * addresses. There is no straight-forward way, short of disassembling the
287 + * offending instruction, to map that address back to the watchpoint. This
288 + * function computes the distance of the memory access from the watchpoint as a
289 + * heuristic for the likelyhood that a given access triggered the watchpoint.
290 + *
291 + * See this same function in the arm64 platform code, which has the same
292 + * problem.
293 + *
294 + * The function returns the distance of the address from the bytes watched by
295 + * the watchpoint. In case of an exact match, it returns 0.
296 + */
297 +static u32 get_distance_from_watchpoint(unsigned long addr, u32 val,
298 + struct arch_hw_breakpoint_ctrl *ctrl)
299 +{
300 + u32 wp_low, wp_high;
301 + u32 lens, lene;
302 +
303 + lens = __ffs(ctrl->len);
304 + lene = __fls(ctrl->len);
305 +
306 + wp_low = val + lens;
307 + wp_high = val + lene;
308 + if (addr < wp_low)
309 + return wp_low - addr;
310 + else if (addr > wp_high)
311 + return addr - wp_high;
312 + else
313 + return 0;
314 +}
315 +
316 static int watchpoint_fault_on_uaccess(struct pt_regs *regs,
317 struct arch_hw_breakpoint *info)
318 {
319 @@ -697,23 +731,25 @@ static int watchpoint_fault_on_uaccess(struct pt_regs *regs,
320 static void watchpoint_handler(unsigned long addr, unsigned int fsr,
321 struct pt_regs *regs)
322 {
323 - int i, access;
324 - u32 val, ctrl_reg, alignment_mask;
325 + int i, access, closest_match = 0;
326 + u32 min_dist = -1, dist;
327 + u32 val, ctrl_reg;
328 struct perf_event *wp, **slots;
329 struct arch_hw_breakpoint *info;
330 struct arch_hw_breakpoint_ctrl ctrl;
331
332 slots = this_cpu_ptr(wp_on_reg);
333
334 + /*
335 + * Find all watchpoints that match the reported address. If no exact
336 + * match is found. Attribute the hit to the closest watchpoint.
337 + */
338 + rcu_read_lock();
339 for (i = 0; i < core_num_wrps; ++i) {
340 - rcu_read_lock();
341 -
342 wp = slots[i];
343 -
344 if (wp == NULL)
345 - goto unlock;
346 + continue;
347
348 - info = counter_arch_bp(wp);
349 /*
350 * The DFAR is an unknown value on debug architectures prior
351 * to 7.1. Since we only allow a single watchpoint on these
352 @@ -722,33 +758,31 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
353 */
354 if (debug_arch < ARM_DEBUG_ARCH_V7_1) {
355 BUG_ON(i > 0);
356 + info = counter_arch_bp(wp);
357 info->trigger = wp->attr.bp_addr;
358 } else {
359 - if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
360 - alignment_mask = 0x7;
361 - else
362 - alignment_mask = 0x3;
363 -
364 - /* Check if the watchpoint value matches. */
365 - val = read_wb_reg(ARM_BASE_WVR + i);
366 - if (val != (addr & ~alignment_mask))
367 - goto unlock;
368 -
369 - /* Possible match, check the byte address select. */
370 - ctrl_reg = read_wb_reg(ARM_BASE_WCR + i);
371 - decode_ctrl_reg(ctrl_reg, &ctrl);
372 - if (!((1 << (addr & alignment_mask)) & ctrl.len))
373 - goto unlock;
374 -
375 /* Check that the access type matches. */
376 if (debug_exception_updates_fsr()) {
377 access = (fsr & ARM_FSR_ACCESS_MASK) ?
378 HW_BREAKPOINT_W : HW_BREAKPOINT_R;
379 if (!(access & hw_breakpoint_type(wp)))
380 - goto unlock;
381 + continue;
382 }
383
384 + val = read_wb_reg(ARM_BASE_WVR + i);
385 + ctrl_reg = read_wb_reg(ARM_BASE_WCR + i);
386 + decode_ctrl_reg(ctrl_reg, &ctrl);
387 + dist = get_distance_from_watchpoint(addr, val, &ctrl);
388 + if (dist < min_dist) {
389 + min_dist = dist;
390 + closest_match = i;
391 + }
392 + /* Is this an exact match? */
393 + if (dist != 0)
394 + continue;
395 +
396 /* We have a winner. */
397 + info = counter_arch_bp(wp);
398 info->trigger = addr;
399 }
400
401 @@ -770,13 +804,23 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
402 * we can single-step over the watchpoint trigger.
403 */
404 if (!is_default_overflow_handler(wp))
405 - goto unlock;
406 -
407 + continue;
408 step:
409 enable_single_step(wp, instruction_pointer(regs));
410 -unlock:
411 - rcu_read_unlock();
412 }
413 +
414 + if (min_dist > 0 && min_dist != -1) {
415 + /* No exact match found. */
416 + wp = slots[closest_match];
417 + info = counter_arch_bp(wp);
418 + info->trigger = addr;
419 + pr_debug("watchpoint fired: address = 0x%x\n", info->trigger);
420 + perf_bp_event(wp, regs);
421 + if (is_default_overflow_handler(wp))
422 + enable_single_step(wp, instruction_pointer(regs));
423 + }
424 +
425 + rcu_read_unlock();
426 }
427
428 static void watchpoint_single_step_handler(unsigned long pc)
429 diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
430 index 3265b8f860694..6ec01491735ec 100644
431 --- a/arch/arm/plat-samsung/Kconfig
432 +++ b/arch/arm/plat-samsung/Kconfig
433 @@ -242,6 +242,7 @@ config SAMSUNG_PM_DEBUG
434 bool "Samsung PM Suspend debug"
435 depends on PM && DEBUG_KERNEL
436 depends on DEBUG_EXYNOS_UART || DEBUG_S3C24XX_UART || DEBUG_S3C2410_UART
437 + depends on DEBUG_LL && MMU
438 help
439 Say Y here if you want verbose debugging from the PM Suspend and
440 Resume code. See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
441 diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
442 index 3428a4ba2ccdf..2f9c2a95c40e0 100644
443 --- a/arch/arm64/Kconfig.platforms
444 +++ b/arch/arm64/Kconfig.platforms
445 @@ -41,6 +41,7 @@ config ARCH_BCM_IPROC
446 config ARCH_BERLIN
447 bool "Marvell Berlin SoC Family"
448 select DW_APB_ICTL
449 + select DW_APB_TIMER_OF
450 select GPIOLIB
451 select PINCTRL
452 help
453 diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
454 index 367ebb48170be..86c0ef23157c2 100644
455 --- a/arch/arm64/include/asm/kvm_host.h
456 +++ b/arch/arm64/include/asm/kvm_host.h
457 @@ -188,6 +188,7 @@ enum vcpu_sysreg {
458 #define cp14_DBGWCR0 (DBGWCR0_EL1 * 2)
459 #define cp14_DBGWVR0 (DBGWVR0_EL1 * 2)
460 #define cp14_DBGDCCINT (MDCCINT_EL1 * 2)
461 +#define cp14_DBGVCR (DBGVCR32_EL2 * 2)
462
463 #define NR_COPRO_REGS (NR_SYS_REGS * 2)
464
465 diff --git a/arch/arm64/include/asm/numa.h b/arch/arm64/include/asm/numa.h
466 index 600887e491fdf..496070f97c541 100644
467 --- a/arch/arm64/include/asm/numa.h
468 +++ b/arch/arm64/include/asm/numa.h
469 @@ -25,6 +25,9 @@ const struct cpumask *cpumask_of_node(int node);
470 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
471 static inline const struct cpumask *cpumask_of_node(int node)
472 {
473 + if (node == NUMA_NO_NODE)
474 + return cpu_all_mask;
475 +
476 return node_to_cpumask_map[node];
477 }
478 #endif
479 diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
480 index 7cee552ce0bf0..dce732f51e50e 100644
481 --- a/arch/arm64/kvm/sys_regs.c
482 +++ b/arch/arm64/kvm/sys_regs.c
483 @@ -1207,9 +1207,9 @@ static const struct sys_reg_desc cp14_regs[] = {
484 { Op1( 0), CRn( 0), CRm( 1), Op2( 0), trap_raz_wi },
485 DBG_BCR_BVR_WCR_WVR(1),
486 /* DBGDCCINT */
487 - { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32 },
488 + { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32, NULL, cp14_DBGDCCINT },
489 /* DBGDSCRext */
490 - { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32 },
491 + { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32, NULL, cp14_DBGDSCRext },
492 DBG_BCR_BVR_WCR_WVR(2),
493 /* DBGDTR[RT]Xint */
494 { Op1( 0), CRn( 0), CRm( 3), Op2( 0), trap_raz_wi },
495 @@ -1224,7 +1224,7 @@ static const struct sys_reg_desc cp14_regs[] = {
496 { Op1( 0), CRn( 0), CRm( 6), Op2( 2), trap_raz_wi },
497 DBG_BCR_BVR_WCR_WVR(6),
498 /* DBGVCR */
499 - { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32 },
500 + { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32, NULL, cp14_DBGVCR },
501 DBG_BCR_BVR_WCR_WVR(7),
502 DBG_BCR_BVR_WCR_WVR(8),
503 DBG_BCR_BVR_WCR_WVR(9),
504 diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
505 index b1e42bad69ac3..fddae9b8e1bf1 100644
506 --- a/arch/arm64/mm/numa.c
507 +++ b/arch/arm64/mm/numa.c
508 @@ -58,7 +58,11 @@ EXPORT_SYMBOL(node_to_cpumask_map);
509 */
510 const struct cpumask *cpumask_of_node(int node)
511 {
512 - if (WARN_ON(node >= nr_node_ids))
513 +
514 + if (node == NUMA_NO_NODE)
515 + return cpu_all_mask;
516 +
517 + if (WARN_ON(node < 0 || node >= nr_node_ids))
518 return cpu_none_mask;
519
520 if (WARN_ON(node_to_cpumask_map[node] == NULL))
521 diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
522 index 9edda5466020d..bcd3668f1bb82 100644
523 --- a/arch/ia64/kernel/Makefile
524 +++ b/arch/ia64/kernel/Makefile
525 @@ -42,7 +42,7 @@ endif
526 obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o
527 obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
528
529 -obj-$(CONFIG_BINFMT_ELF) += elfcore.o
530 +obj-$(CONFIG_ELF_CORE) += elfcore.o
531
532 # fp_emulate() expects f2-f5,f16-f31 to contain the user-level state.
533 CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
534 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
535 index c4f1d1f7bae09..6949a360c584e 100644
536 --- a/arch/powerpc/kernel/sysfs.c
537 +++ b/arch/powerpc/kernel/sysfs.c
538 @@ -28,29 +28,27 @@
539
540 static DEFINE_PER_CPU(struct cpu, cpu_devices);
541
542 -/*
543 - * SMT snooze delay stuff, 64-bit only for now
544 - */
545 -
546 #ifdef CONFIG_PPC64
547
548 -/* Time in microseconds we delay before sleeping in the idle loop */
549 -static DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 };
550 +/*
551 + * Snooze delay has not been hooked up since 3fa8cad82b94 ("powerpc/pseries/cpuidle:
552 + * smt-snooze-delay cleanup.") and has been broken even longer. As was foretold in
553 + * 2014:
554 + *
555 + * "ppc64_util currently utilises it. Once we fix ppc64_util, propose to clean
556 + * up the kernel code."
557 + *
558 + * powerpc-utils stopped using it as of 1.3.8. At some point in the future this
559 + * code should be removed.
560 + */
561
562 static ssize_t store_smt_snooze_delay(struct device *dev,
563 struct device_attribute *attr,
564 const char *buf,
565 size_t count)
566 {
567 - struct cpu *cpu = container_of(dev, struct cpu, dev);
568 - ssize_t ret;
569 - long snooze;
570 -
571 - ret = sscanf(buf, "%ld", &snooze);
572 - if (ret != 1)
573 - return -EINVAL;
574 -
575 - per_cpu(smt_snooze_delay, cpu->dev.id) = snooze;
576 + pr_warn_once("%s (%d) stored to unsupported smt_snooze_delay, which has no effect.\n",
577 + current->comm, current->pid);
578 return count;
579 }
580
581 @@ -58,9 +56,9 @@ static ssize_t show_smt_snooze_delay(struct device *dev,
582 struct device_attribute *attr,
583 char *buf)
584 {
585 - struct cpu *cpu = container_of(dev, struct cpu, dev);
586 -
587 - return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->dev.id));
588 + pr_warn_once("%s (%d) read from unsupported smt_snooze_delay\n",
589 + current->comm, current->pid);
590 + return sprintf(buf, "100\n");
591 }
592
593 static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
594 @@ -68,16 +66,10 @@ static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
595
596 static int __init setup_smt_snooze_delay(char *str)
597 {
598 - unsigned int cpu;
599 - long snooze;
600 -
601 if (!cpu_has_feature(CPU_FTR_SMT))
602 return 1;
603
604 - snooze = simple_strtol(str, NULL, 10);
605 - for_each_possible_cpu(cpu)
606 - per_cpu(smt_snooze_delay, cpu) = snooze;
607 -
608 + pr_warn("smt-snooze-delay command line option has no effect\n");
609 return 1;
610 }
611 __setup("smt-snooze-delay=", setup_smt_snooze_delay);
612 diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
613 index e21e2c0af69d2..1a8b6e276a112 100644
614 --- a/arch/powerpc/platforms/powernv/opal-dump.c
615 +++ b/arch/powerpc/platforms/powernv/opal-dump.c
616 @@ -385,13 +385,12 @@ static irqreturn_t process_dump(int irq, void *data)
617 {
618 int rc;
619 uint32_t dump_id, dump_size, dump_type;
620 - struct dump_obj *dump;
621 char name[22];
622 struct kobject *kobj;
623
624 rc = dump_read_info(&dump_id, &dump_size, &dump_type);
625 if (rc != OPAL_SUCCESS)
626 - return rc;
627 + return IRQ_HANDLED;
628
629 sprintf(name, "0x%x-0x%x", dump_type, dump_id);
630
631 @@ -403,12 +402,10 @@ static irqreturn_t process_dump(int irq, void *data)
632 if (kobj) {
633 /* Drop reference added by kset_find_obj() */
634 kobject_put(kobj);
635 - return 0;
636 + return IRQ_HANDLED;
637 }
638
639 - dump = create_dump_obj(dump_id, dump_size, dump_type);
640 - if (!dump)
641 - return -1;
642 + create_dump_obj(dump_id, dump_size, dump_type);
643
644 return IRQ_HANDLED;
645 }
646 diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
647 index f2344cbd2f464..3595f3cfefa35 100644
648 --- a/arch/powerpc/platforms/powernv/opal-elog.c
649 +++ b/arch/powerpc/platforms/powernv/opal-elog.c
650 @@ -183,14 +183,14 @@ static ssize_t raw_attr_read(struct file *filep, struct kobject *kobj,
651 return count;
652 }
653
654 -static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
655 +static void create_elog_obj(uint64_t id, size_t size, uint64_t type)
656 {
657 struct elog_obj *elog;
658 int rc;
659
660 elog = kzalloc(sizeof(*elog), GFP_KERNEL);
661 if (!elog)
662 - return NULL;
663 + return;
664
665 elog->kobj.kset = elog_kset;
666
667 @@ -223,18 +223,37 @@ static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
668 rc = kobject_add(&elog->kobj, NULL, "0x%llx", id);
669 if (rc) {
670 kobject_put(&elog->kobj);
671 - return NULL;
672 + return;
673 }
674
675 + /*
676 + * As soon as the sysfs file for this elog is created/activated there is
677 + * a chance the opal_errd daemon (or any userspace) might read and
678 + * acknowledge the elog before kobject_uevent() is called. If that
679 + * happens then there is a potential race between
680 + * elog_ack_store->kobject_put() and kobject_uevent() which leads to a
681 + * use-after-free of a kernfs object resulting in a kernel crash.
682 + *
683 + * To avoid that, we need to take a reference on behalf of the bin file,
684 + * so that our reference remains valid while we call kobject_uevent().
685 + * We then drop our reference before exiting the function, leaving the
686 + * bin file to drop the last reference (if it hasn't already).
687 + */
688 +
689 + /* Take a reference for the bin file */
690 + kobject_get(&elog->kobj);
691 rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr);
692 - if (rc) {
693 + if (rc == 0) {
694 + kobject_uevent(&elog->kobj, KOBJ_ADD);
695 + } else {
696 + /* Drop the reference taken for the bin file */
697 kobject_put(&elog->kobj);
698 - return NULL;
699 }
700
701 - kobject_uevent(&elog->kobj, KOBJ_ADD);
702 + /* Drop our reference */
703 + kobject_put(&elog->kobj);
704
705 - return elog;
706 + return;
707 }
708
709 static irqreturn_t elog_event(int irq, void *data)
710 diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
711 index eec0e8d0454d1..7e0f5fa0452b3 100644
712 --- a/arch/powerpc/platforms/powernv/smp.c
713 +++ b/arch/powerpc/platforms/powernv/smp.c
714 @@ -41,7 +41,7 @@
715 #include <asm/udbg.h>
716 #define DBG(fmt...) udbg_printf(fmt)
717 #else
718 -#define DBG(fmt...)
719 +#define DBG(fmt...) do { } while (0)
720 #endif
721
722 static void pnv_smp_setup_cpu(int cpu)
723 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
724 index ca7cb8e57ab0f..b81cdd53d0906 100644
725 --- a/arch/sparc/kernel/smp_64.c
726 +++ b/arch/sparc/kernel/smp_64.c
727 @@ -1034,38 +1034,9 @@ void smp_fetch_global_pmu(void)
728 * are flush_tlb_*() routines, and these run after flush_cache_*()
729 * which performs the flushw.
730 *
731 - * The SMP TLB coherency scheme we use works as follows:
732 - *
733 - * 1) mm->cpu_vm_mask is a bit mask of which cpus an address
734 - * space has (potentially) executed on, this is the heuristic
735 - * we use to avoid doing cross calls.
736 - *
737 - * Also, for flushing from kswapd and also for clones, we
738 - * use cpu_vm_mask as the list of cpus to make run the TLB.
739 - *
740 - * 2) TLB context numbers are shared globally across all processors
741 - * in the system, this allows us to play several games to avoid
742 - * cross calls.
743 - *
744 - * One invariant is that when a cpu switches to a process, and
745 - * that processes tsk->active_mm->cpu_vm_mask does not have the
746 - * current cpu's bit set, that tlb context is flushed locally.
747 - *
748 - * If the address space is non-shared (ie. mm->count == 1) we avoid
749 - * cross calls when we want to flush the currently running process's
750 - * tlb state. This is done by clearing all cpu bits except the current
751 - * processor's in current->mm->cpu_vm_mask and performing the
752 - * flush locally only. This will force any subsequent cpus which run
753 - * this task to flush the context from the local tlb if the process
754 - * migrates to another cpu (again).
755 - *
756 - * 3) For shared address spaces (threads) and swapping we bite the
757 - * bullet for most cases and perform the cross call (but only to
758 - * the cpus listed in cpu_vm_mask).
759 - *
760 - * The performance gain from "optimizing" away the cross call for threads is
761 - * questionable (in theory the big win for threads is the massive sharing of
762 - * address space state across processors).
763 + * mm->cpu_vm_mask is a bit mask of which cpus an address
764 + * space has (potentially) executed on, this is the heuristic
765 + * we use to limit cross calls.
766 */
767
768 /* This currently is only used by the hugetlb arch pre-fault
769 @@ -1075,18 +1046,13 @@ void smp_fetch_global_pmu(void)
770 void smp_flush_tlb_mm(struct mm_struct *mm)
771 {
772 u32 ctx = CTX_HWBITS(mm->context);
773 - int cpu = get_cpu();
774
775 - if (atomic_read(&mm->mm_users) == 1) {
776 - cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
777 - goto local_flush_and_out;
778 - }
779 + get_cpu();
780
781 smp_cross_call_masked(&xcall_flush_tlb_mm,
782 ctx, 0, 0,
783 mm_cpumask(mm));
784
785 -local_flush_and_out:
786 __flush_tlb_mm(ctx, SECONDARY_CONTEXT);
787
788 put_cpu();
789 @@ -1109,17 +1075,15 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long
790 {
791 u32 ctx = CTX_HWBITS(mm->context);
792 struct tlb_pending_info info;
793 - int cpu = get_cpu();
794 +
795 + get_cpu();
796
797 info.ctx = ctx;
798 info.nr = nr;
799 info.vaddrs = vaddrs;
800
801 - if (mm == current->mm && atomic_read(&mm->mm_users) == 1)
802 - cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
803 - else
804 - smp_call_function_many(mm_cpumask(mm), tlb_pending_func,
805 - &info, 1);
806 + smp_call_function_many(mm_cpumask(mm), tlb_pending_func,
807 + &info, 1);
808
809 __flush_tlb_pending(ctx, nr, vaddrs);
810
811 @@ -1129,14 +1093,13 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long
812 void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
813 {
814 unsigned long context = CTX_HWBITS(mm->context);
815 - int cpu = get_cpu();
816
817 - if (mm == current->mm && atomic_read(&mm->mm_users) == 1)
818 - cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
819 - else
820 - smp_cross_call_masked(&xcall_flush_tlb_page,
821 - context, vaddr, 0,
822 - mm_cpumask(mm));
823 + get_cpu();
824 +
825 + smp_cross_call_masked(&xcall_flush_tlb_page,
826 + context, vaddr, 0,
827 + mm_cpumask(mm));
828 +
829 __flush_tlb_page(context, vaddr);
830
831 put_cpu();
832 diff --git a/arch/um/kernel/sigio.c b/arch/um/kernel/sigio.c
833 index b5e0cbb343828..476ded92affac 100644
834 --- a/arch/um/kernel/sigio.c
835 +++ b/arch/um/kernel/sigio.c
836 @@ -36,14 +36,14 @@ int write_sigio_irq(int fd)
837 }
838
839 /* These are called from os-Linux/sigio.c to protect its pollfds arrays. */
840 -static DEFINE_SPINLOCK(sigio_spinlock);
841 +static DEFINE_MUTEX(sigio_mutex);
842
843 void sigio_lock(void)
844 {
845 - spin_lock(&sigio_spinlock);
846 + mutex_lock(&sigio_mutex);
847 }
848
849 void sigio_unlock(void)
850 {
851 - spin_unlock(&sigio_spinlock);
852 + mutex_unlock(&sigio_mutex);
853 }
854 diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
855 index 5f72b473f3ed3..f6e57bebbc6bb 100644
856 --- a/arch/x86/events/amd/ibs.c
857 +++ b/arch/x86/events/amd/ibs.c
858 @@ -88,6 +88,7 @@ struct perf_ibs {
859 u64 max_period;
860 unsigned long offset_mask[1];
861 int offset_max;
862 + unsigned int fetch_count_reset_broken : 1;
863 struct cpu_perf_ibs __percpu *pcpu;
864
865 struct attribute **format_attrs;
866 @@ -345,11 +346,15 @@ static u64 get_ibs_op_count(u64 config)
867 {
868 u64 count = 0;
869
870 + /*
871 + * If the internal 27-bit counter rolled over, the count is MaxCnt
872 + * and the lower 7 bits of CurCnt are randomized.
873 + * Otherwise CurCnt has the full 27-bit current counter value.
874 + */
875 if (config & IBS_OP_VAL)
876 - count += (config & IBS_OP_MAX_CNT) << 4; /* cnt rolled over */
877 -
878 - if (ibs_caps & IBS_CAPS_RDWROPCNT)
879 - count += (config & IBS_OP_CUR_CNT) >> 32;
880 + count = (config & IBS_OP_MAX_CNT) << 4;
881 + else if (ibs_caps & IBS_CAPS_RDWROPCNT)
882 + count = (config & IBS_OP_CUR_CNT) >> 32;
883
884 return count;
885 }
886 @@ -374,7 +379,12 @@ perf_ibs_event_update(struct perf_ibs *perf_ibs, struct perf_event *event,
887 static inline void perf_ibs_enable_event(struct perf_ibs *perf_ibs,
888 struct hw_perf_event *hwc, u64 config)
889 {
890 - wrmsrl(hwc->config_base, hwc->config | config | perf_ibs->enable_mask);
891 + u64 tmp = hwc->config | config;
892 +
893 + if (perf_ibs->fetch_count_reset_broken)
894 + wrmsrl(hwc->config_base, tmp & ~perf_ibs->enable_mask);
895 +
896 + wrmsrl(hwc->config_base, tmp | perf_ibs->enable_mask);
897 }
898
899 /*
900 @@ -636,18 +646,24 @@ fail:
901 perf_ibs->offset_max,
902 offset + 1);
903 } while (offset < offset_max);
904 + /*
905 + * Read IbsBrTarget, IbsOpData4, and IbsExtdCtl separately
906 + * depending on their availability.
907 + * Can't add to offset_max as they are staggered
908 + */
909 if (event->attr.sample_type & PERF_SAMPLE_RAW) {
910 - /*
911 - * Read IbsBrTarget and IbsOpData4 separately
912 - * depending on their availability.
913 - * Can't add to offset_max as they are staggered
914 - */
915 - if (ibs_caps & IBS_CAPS_BRNTRGT) {
916 - rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++);
917 - size++;
918 + if (perf_ibs == &perf_ibs_op) {
919 + if (ibs_caps & IBS_CAPS_BRNTRGT) {
920 + rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++);
921 + size++;
922 + }
923 + if (ibs_caps & IBS_CAPS_OPDATA4) {
924 + rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++);
925 + size++;
926 + }
927 }
928 - if (ibs_caps & IBS_CAPS_OPDATA4) {
929 - rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++);
930 + if (perf_ibs == &perf_ibs_fetch && (ibs_caps & IBS_CAPS_FETCHCTLEXTD)) {
931 + rdmsrl(MSR_AMD64_ICIBSEXTDCTL, *buf++);
932 size++;
933 }
934 }
935 @@ -743,6 +759,13 @@ static __init void perf_event_ibs_init(void)
936 {
937 struct attribute **attr = ibs_op_format_attrs;
938
939 + /*
940 + * Some chips fail to reset the fetch count when it is written; instead
941 + * they need a 0-1 transition of IbsFetchEn.
942 + */
943 + if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
944 + perf_ibs_fetch.fetch_count_reset_broken = 1;
945 +
946 perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
947
948 if (ibs_caps & IBS_CAPS_OPCNT) {
949 diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
950 index b12b0a50ad1f7..1fdea3c334e7c 100644
951 --- a/arch/x86/include/asm/msr-index.h
952 +++ b/arch/x86/include/asm/msr-index.h
953 @@ -356,6 +356,7 @@
954 #define MSR_AMD64_IBSOP_REG_MASK ((1UL<<MSR_AMD64_IBSOP_REG_COUNT)-1)
955 #define MSR_AMD64_IBSCTL 0xc001103a
956 #define MSR_AMD64_IBSBRTARGET 0xc001103b
957 +#define MSR_AMD64_ICIBSEXTDCTL 0xc001103c
958 #define MSR_AMD64_IBSOPDATA4 0xc001103d
959 #define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */
960
961 diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
962 index 167ecc270ca55..316c05b8b728b 100644
963 --- a/arch/x86/kernel/kexec-bzimage64.c
964 +++ b/arch/x86/kernel/kexec-bzimage64.c
965 @@ -211,8 +211,7 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
966 params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
967
968 /* Copying screen_info will do? */
969 - memcpy(&params->screen_info, &boot_params.screen_info,
970 - sizeof(struct screen_info));
971 + memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info));
972
973 /* Fill in memsize later */
974 params->screen_info.ext_mem_k = 0;
975 diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
976 index dee86925a9a10..1cc38ca54817e 100644
977 --- a/drivers/acpi/acpi_dbg.c
978 +++ b/drivers/acpi/acpi_dbg.c
979 @@ -757,6 +757,9 @@ int __init acpi_aml_init(void)
980 goto err_exit;
981 }
982
983 + if (acpi_disabled)
984 + return -ENODEV;
985 +
986 /* Initialize AML IO interface */
987 mutex_init(&acpi_aml_io.lock);
988 init_waitqueue_head(&acpi_aml_io.wait);
989 diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
990 index b3842ffc19ba2..46d201fc7ecc7 100644
991 --- a/drivers/acpi/acpi_extlog.c
992 +++ b/drivers/acpi/acpi_extlog.c
993 @@ -223,9 +223,9 @@ static int __init extlog_init(void)
994 u64 cap;
995 int rc;
996
997 - rdmsrl(MSR_IA32_MCG_CAP, cap);
998 -
999 - if (!(cap & MCG_ELOG_P) || !extlog_get_l1addr())
1000 + if (rdmsrl_safe(MSR_IA32_MCG_CAP, &cap) ||
1001 + !(cap & MCG_ELOG_P) ||
1002 + !extlog_get_l1addr())
1003 return -ENODEV;
1004
1005 if (get_edac_report_status() == EDAC_REPORTING_FORCE) {
1006 diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
1007 index 31a07609f7a23..b7fd8e00b346b 100644
1008 --- a/drivers/acpi/nfit/core.c
1009 +++ b/drivers/acpi/nfit/core.c
1010 @@ -1219,7 +1219,7 @@ static ssize_t format1_show(struct device *dev,
1011 le16_to_cpu(nfit_dcr->dcr->code));
1012 break;
1013 }
1014 - if (rc != ENXIO)
1015 + if (rc != -ENXIO)
1016 break;
1017 }
1018 mutex_unlock(&acpi_desc->init_mutex);
1019 diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
1020 index 25f02f5fe0fdb..ec2f77a471501 100644
1021 --- a/drivers/acpi/video_detect.c
1022 +++ b/drivers/acpi/video_detect.c
1023 @@ -268,6 +268,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
1024 DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
1025 },
1026 },
1027 + /* https://bugs.launchpad.net/bugs/1894667 */
1028 + {
1029 + .callback = video_detect_force_video,
1030 + .ident = "HP 635 Notebook",
1031 + .matches = {
1032 + DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1033 + DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"),
1034 + },
1035 + },
1036
1037 /* Non win8 machines which need native backlight nevertheless */
1038 {
1039 diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
1040 index 301419325b975..e62b254c419f0 100644
1041 --- a/drivers/ata/sata_rcar.c
1042 +++ b/drivers/ata/sata_rcar.c
1043 @@ -122,7 +122,7 @@
1044 /* Descriptor table word 0 bit (when DTA32M = 1) */
1045 #define SATA_RCAR_DTEND BIT(0)
1046
1047 -#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFEUL
1048 +#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFFUL
1049
1050 /* Gen2 Physical Layer Control Registers */
1051 #define RCAR_GEN2_PHY_CTL1_REG 0x1704
1052 diff --git a/drivers/base/core.c b/drivers/base/core.c
1053 index fe9f2aea84bd4..ec5cc5d98a3e7 100644
1054 --- a/drivers/base/core.c
1055 +++ b/drivers/base/core.c
1056 @@ -2348,6 +2348,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
1057 */
1058 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
1059 {
1060 + struct device *parent = dev->parent;
1061 struct fwnode_handle *fn = dev->fwnode;
1062
1063 if (fwnode) {
1064 @@ -2362,7 +2363,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
1065 } else {
1066 if (fwnode_is_primary(fn)) {
1067 dev->fwnode = fn->secondary;
1068 - fn->secondary = NULL;
1069 + if (!(parent && fn == parent->fwnode))
1070 + fn->secondary = ERR_PTR(-ENODEV);
1071 } else {
1072 dev->fwnode = NULL;
1073 }
1074 diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c
1075 index 6cf9dd189a924..4e5e952380869 100644
1076 --- a/drivers/clk/ti/clockdomain.c
1077 +++ b/drivers/clk/ti/clockdomain.c
1078 @@ -124,10 +124,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
1079 if (clk_hw_get_flags(clk_hw) & CLK_IS_BASIC) {
1080 pr_warn("can't setup clkdm for basic clk %s\n",
1081 __clk_get_name(clk));
1082 + clk_put(clk);
1083 continue;
1084 }
1085 to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name;
1086 omap2_init_clk_clkdm(clk_hw);
1087 + clk_put(clk);
1088 }
1089 }
1090
1091 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
1092 index 1ee3674a99bb8..3bd816cf4a7d3 100644
1093 --- a/drivers/cpufreq/acpi-cpufreq.c
1094 +++ b/drivers/cpufreq/acpi-cpufreq.c
1095 @@ -720,7 +720,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
1096 cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
1097 }
1098
1099 - if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
1100 + if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 &&
1101 + !acpi_pstate_strict) {
1102 cpumask_clear(policy->cpus);
1103 cpumask_set_cpu(cpu, policy->cpus);
1104 cpumask_copy(data->freqdomain_cpus,
1105 diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c
1106 index b366e6d830ea3..2cb3346e82d35 100644
1107 --- a/drivers/cpufreq/sti-cpufreq.c
1108 +++ b/drivers/cpufreq/sti-cpufreq.c
1109 @@ -144,7 +144,8 @@ static const struct reg_field sti_stih407_dvfs_regfields[DVFS_MAX_REGFIELDS] = {
1110 static const struct reg_field *sti_cpufreq_match(void)
1111 {
1112 if (of_machine_is_compatible("st,stih407") ||
1113 - of_machine_is_compatible("st,stih410"))
1114 + of_machine_is_compatible("st,stih410") ||
1115 + of_machine_is_compatible("st,stih418"))
1116 return sti_stih407_dvfs_regfields;
1117
1118 return NULL;
1119 @@ -260,7 +261,8 @@ static int sti_cpufreq_init(void)
1120 int ret;
1121
1122 if ((!of_machine_is_compatible("st,stih407")) &&
1123 - (!of_machine_is_compatible("st,stih410")))
1124 + (!of_machine_is_compatible("st,stih410")) &&
1125 + (!of_machine_is_compatible("st,stih418")))
1126 return -ENODEV;
1127
1128 ddata.cpu = get_cpu_device(0);
1129 diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
1130 index aca2d6fd92d56..e1b6787f0e68f 100644
1131 --- a/drivers/dma/dma-jz4780.c
1132 +++ b/drivers/dma/dma-jz4780.c
1133 @@ -567,11 +567,11 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan,
1134 enum dma_status status;
1135 unsigned long flags;
1136
1137 + spin_lock_irqsave(&jzchan->vchan.lock, flags);
1138 +
1139 status = dma_cookie_status(chan, cookie, txstate);
1140 if ((status == DMA_COMPLETE) || (txstate == NULL))
1141 - return status;
1142 -
1143 - spin_lock_irqsave(&jzchan->vchan.lock, flags);
1144 + goto out_unlock_irqrestore;
1145
1146 vdesc = vchan_find_desc(&jzchan->vchan, cookie);
1147 if (vdesc) {
1148 @@ -588,6 +588,7 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan,
1149 && jzchan->desc->status & (JZ_DMA_DCS_AR | JZ_DMA_DCS_HLT))
1150 status = DMA_ERROR;
1151
1152 +out_unlock_irqrestore:
1153 spin_unlock_irqrestore(&jzchan->vchan.lock, flags);
1154 return status;
1155 }
1156 diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c
1157 index 072f03bfe6a06..1410a41782cc9 100644
1158 --- a/drivers/iio/adc/ti-adc12138.c
1159 +++ b/drivers/iio/adc/ti-adc12138.c
1160 @@ -50,6 +50,12 @@ struct adc12138 {
1161 struct completion complete;
1162 /* The number of cclk periods for the S/H's acquisition time */
1163 unsigned int acquisition_time;
1164 + /*
1165 + * Maximum size needed: 16x 2 bytes ADC data + 8 bytes timestamp.
1166 + * Less may be need if not all channels are enabled, as long as
1167 + * the 8 byte alignment of the timestamp is maintained.
1168 + */
1169 + __be16 data[20] __aligned(8);
1170
1171 u8 tx_buf[2] ____cacheline_aligned;
1172 u8 rx_buf[2];
1173 @@ -333,7 +339,6 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p)
1174 struct iio_poll_func *pf = p;
1175 struct iio_dev *indio_dev = pf->indio_dev;
1176 struct adc12138 *adc = iio_priv(indio_dev);
1177 - __be16 data[20] = { }; /* 16x 2 bytes ADC data + 8 bytes timestamp */
1178 __be16 trash;
1179 int ret;
1180 int scan_index;
1181 @@ -349,7 +354,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p)
1182 reinit_completion(&adc->complete);
1183
1184 ret = adc12138_start_and_read_conv(adc, scan_chan,
1185 - i ? &data[i - 1] : &trash);
1186 + i ? &adc->data[i - 1] : &trash);
1187 if (ret) {
1188 dev_warn(&adc->spi->dev,
1189 "failed to start conversion\n");
1190 @@ -366,7 +371,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p)
1191 }
1192
1193 if (i) {
1194 - ret = adc12138_read_conv_data(adc, &data[i - 1]);
1195 + ret = adc12138_read_conv_data(adc, &adc->data[i - 1]);
1196 if (ret) {
1197 dev_warn(&adc->spi->dev,
1198 "failed to get conversion data\n");
1199 @@ -374,7 +379,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p)
1200 }
1201 }
1202
1203 - iio_push_to_buffers_with_timestamp(indio_dev, data,
1204 + iio_push_to_buffers_with_timestamp(indio_dev, adc->data,
1205 iio_get_time_ns(indio_dev));
1206 out:
1207 mutex_unlock(&adc->lock);
1208 diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
1209 index eef50e91f17cf..e04483254b283 100644
1210 --- a/drivers/iio/gyro/itg3200_buffer.c
1211 +++ b/drivers/iio/gyro/itg3200_buffer.c
1212 @@ -49,13 +49,20 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
1213 struct iio_poll_func *pf = p;
1214 struct iio_dev *indio_dev = pf->indio_dev;
1215 struct itg3200 *st = iio_priv(indio_dev);
1216 - __be16 buf[ITG3200_SCAN_ELEMENTS + sizeof(s64)/sizeof(u16)];
1217 -
1218 - int ret = itg3200_read_all_channels(st->i2c, buf);
1219 + /*
1220 + * Ensure correct alignment and padding including for the
1221 + * timestamp that may be inserted.
1222 + */
1223 + struct {
1224 + __be16 buf[ITG3200_SCAN_ELEMENTS];
1225 + s64 ts __aligned(8);
1226 + } scan;
1227 +
1228 + int ret = itg3200_read_all_channels(st->i2c, scan.buf);
1229 if (ret < 0)
1230 goto error_ret;
1231
1232 - iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp);
1233 + iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
1234
1235 iio_trigger_notify_done(indio_dev->trig);
1236
1237 diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
1238 index 096034c126a45..c292d98161180 100644
1239 --- a/drivers/iio/light/si1145.c
1240 +++ b/drivers/iio/light/si1145.c
1241 @@ -172,6 +172,7 @@ struct si1145_part_info {
1242 * @part_info: Part information
1243 * @trig: Pointer to iio trigger
1244 * @meas_rate: Value of MEAS_RATE register. Only set in HW in auto mode
1245 + * @buffer: Used to pack data read from sensor.
1246 */
1247 struct si1145_data {
1248 struct i2c_client *client;
1249 @@ -183,6 +184,14 @@ struct si1145_data {
1250 bool autonomous;
1251 struct iio_trigger *trig;
1252 int meas_rate;
1253 + /*
1254 + * Ensure timestamp will be naturally aligned if present.
1255 + * Maximum buffer size (may be only partly used if not all
1256 + * channels are enabled):
1257 + * 6*2 bytes channels data + 4 bytes alignment +
1258 + * 8 bytes timestamp
1259 + */
1260 + u8 buffer[24] __aligned(8);
1261 };
1262
1263 /**
1264 @@ -444,12 +453,6 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private)
1265 struct iio_poll_func *pf = private;
1266 struct iio_dev *indio_dev = pf->indio_dev;
1267 struct si1145_data *data = iio_priv(indio_dev);
1268 - /*
1269 - * Maximum buffer size:
1270 - * 6*2 bytes channels data + 4 bytes alignment +
1271 - * 8 bytes timestamp
1272 - */
1273 - u8 buffer[24];
1274 int i, j = 0;
1275 int ret;
1276 u8 irq_status = 0;
1277 @@ -482,7 +485,7 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private)
1278
1279 ret = i2c_smbus_read_i2c_block_data_or_emulated(
1280 data->client, indio_dev->channels[i].address,
1281 - sizeof(u16) * run, &buffer[j]);
1282 + sizeof(u16) * run, &data->buffer[j]);
1283 if (ret < 0)
1284 goto done;
1285 j += run * sizeof(u16);
1286 @@ -497,7 +500,7 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private)
1287 goto done;
1288 }
1289
1290 - iio_push_to_buffers_with_timestamp(indio_dev, buffer,
1291 + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1292 iio_get_time_ns(indio_dev));
1293
1294 done:
1295 diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
1296 index 65605e4ef3cf6..1491a9a5c6b06 100644
1297 --- a/drivers/input/serio/hil_mlc.c
1298 +++ b/drivers/input/serio/hil_mlc.c
1299 @@ -74,7 +74,7 @@ EXPORT_SYMBOL(hil_mlc_unregister);
1300 static LIST_HEAD(hil_mlcs);
1301 static DEFINE_RWLOCK(hil_mlcs_lock);
1302 static struct timer_list hil_mlcs_kicker;
1303 -static int hil_mlcs_probe;
1304 +static int hil_mlcs_probe, hil_mlc_stop;
1305
1306 static void hil_mlcs_process(unsigned long unused);
1307 static DECLARE_TASKLET_DISABLED(hil_mlcs_tasklet, hil_mlcs_process, 0);
1308 @@ -704,9 +704,13 @@ static int hilse_donode(hil_mlc *mlc)
1309 if (!mlc->ostarted) {
1310 mlc->ostarted = 1;
1311 mlc->opacket = pack;
1312 - mlc->out(mlc);
1313 + rc = mlc->out(mlc);
1314 nextidx = HILSEN_DOZE;
1315 write_unlock_irqrestore(&mlc->lock, flags);
1316 + if (rc) {
1317 + hil_mlc_stop = 1;
1318 + return 1;
1319 + }
1320 break;
1321 }
1322 mlc->ostarted = 0;
1323 @@ -717,8 +721,13 @@ static int hilse_donode(hil_mlc *mlc)
1324
1325 case HILSE_CTS:
1326 write_lock_irqsave(&mlc->lock, flags);
1327 - nextidx = mlc->cts(mlc) ? node->bad : node->good;
1328 + rc = mlc->cts(mlc);
1329 + nextidx = rc ? node->bad : node->good;
1330 write_unlock_irqrestore(&mlc->lock, flags);
1331 + if (rc) {
1332 + hil_mlc_stop = 1;
1333 + return 1;
1334 + }
1335 break;
1336
1337 default:
1338 @@ -786,6 +795,12 @@ static void hil_mlcs_process(unsigned long unused)
1339
1340 static void hil_mlcs_timer(unsigned long data)
1341 {
1342 + if (hil_mlc_stop) {
1343 + /* could not send packet - stop immediately. */
1344 + pr_warn(PREFIX "HIL seems stuck - Disabling HIL MLC.\n");
1345 + return;
1346 + }
1347 +
1348 hil_mlcs_probe = 1;
1349 tasklet_schedule(&hil_mlcs_tasklet);
1350 /* Re-insert the periodic task. */
1351 diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c
1352 index d50f0678bf47a..078cbe6522a2a 100644
1353 --- a/drivers/input/serio/hp_sdc_mlc.c
1354 +++ b/drivers/input/serio/hp_sdc_mlc.c
1355 @@ -213,7 +213,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc)
1356 priv->tseq[2] = 1;
1357 priv->tseq[3] = 0;
1358 priv->tseq[4] = 0;
1359 - __hp_sdc_enqueue_transaction(&priv->trans);
1360 + return __hp_sdc_enqueue_transaction(&priv->trans);
1361 busy:
1362 return 1;
1363 done:
1364 @@ -222,7 +222,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc)
1365 return 0;
1366 }
1367
1368 -static void hp_sdc_mlc_out(hil_mlc *mlc)
1369 +static int hp_sdc_mlc_out(hil_mlc *mlc)
1370 {
1371 struct hp_sdc_mlc_priv_s *priv;
1372
1373 @@ -237,7 +237,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
1374 do_data:
1375 if (priv->emtestmode) {
1376 up(&mlc->osem);
1377 - return;
1378 + return 0;
1379 }
1380 /* Shouldn't be sending commands when loop may be busy */
1381 BUG_ON(down_trylock(&mlc->csem));
1382 @@ -299,7 +299,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
1383 BUG_ON(down_trylock(&mlc->csem));
1384 }
1385 enqueue:
1386 - hp_sdc_enqueue_transaction(&priv->trans);
1387 + return hp_sdc_enqueue_transaction(&priv->trans);
1388 }
1389
1390 static int __init hp_sdc_mlc_init(void)
1391 diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c
1392 index 1548259297c18..d6d6fb0622b45 100644
1393 --- a/drivers/leds/leds-bcm6328.c
1394 +++ b/drivers/leds/leds-bcm6328.c
1395 @@ -336,7 +336,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
1396 led->cdev.brightness_set = bcm6328_led_set;
1397 led->cdev.blink_set = bcm6328_blink_set;
1398
1399 - rc = led_classdev_register(dev, &led->cdev);
1400 + rc = devm_led_classdev_register(dev, &led->cdev);
1401 if (rc < 0)
1402 return rc;
1403
1404 diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
1405 index b2cc06618abed..a86ab6197a4ea 100644
1406 --- a/drivers/leds/leds-bcm6358.c
1407 +++ b/drivers/leds/leds-bcm6358.c
1408 @@ -141,7 +141,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
1409
1410 led->cdev.brightness_set = bcm6358_led_set;
1411
1412 - rc = led_classdev_register(dev, &led->cdev);
1413 + rc = devm_led_classdev_register(dev, &led->cdev);
1414 if (rc < 0)
1415 return rc;
1416
1417 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
1418 index 63bff4cc70984..863fe19e906e6 100644
1419 --- a/drivers/md/bitmap.c
1420 +++ b/drivers/md/bitmap.c
1421 @@ -1339,7 +1339,7 @@ __acquires(bitmap->lock)
1422 if (bitmap->bp[page].hijacked ||
1423 bitmap->bp[page].map == NULL)
1424 csize = ((sector_t)1) << (bitmap->chunkshift +
1425 - PAGE_COUNTER_SHIFT - 1);
1426 + PAGE_COUNTER_SHIFT);
1427 else
1428 csize = ((sector_t)1) << bitmap->chunkshift;
1429 *blocks = csize - (offset & (csize - 1));
1430 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
1431 index 30a853b187802..1e9321410bbb6 100644
1432 --- a/drivers/md/raid5.c
1433 +++ b/drivers/md/raid5.c
1434 @@ -2259,8 +2259,6 @@ static int resize_stripes(struct r5conf *conf, int newsize)
1435 } else
1436 err = -ENOMEM;
1437
1438 - mutex_unlock(&conf->cache_size_mutex);
1439 -
1440 conf->slab_cache = sc;
1441 conf->active_name = 1-conf->active_name;
1442
1443 @@ -2283,6 +2281,8 @@ static int resize_stripes(struct r5conf *conf, int newsize)
1444
1445 if (!err)
1446 conf->pool_size = newsize;
1447 + mutex_unlock(&conf->cache_size_mutex);
1448 +
1449 return err;
1450 }
1451
1452 diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
1453 index 27ff6e0d98453..023ff9ebde5e7 100644
1454 --- a/drivers/media/pci/tw5864/tw5864-video.c
1455 +++ b/drivers/media/pci/tw5864/tw5864-video.c
1456 @@ -767,6 +767,9 @@ static int tw5864_enum_frameintervals(struct file *file, void *priv,
1457 fintv->type = V4L2_FRMIVAL_TYPE_STEPWISE;
1458
1459 ret = tw5864_frameinterval_get(input, &frameinterval);
1460 + if (ret)
1461 + return ret;
1462 +
1463 fintv->stepwise.step = frameinterval;
1464 fintv->stepwise.min = frameinterval;
1465 fintv->stepwise.max = frameinterval;
1466 @@ -785,6 +788,9 @@ static int tw5864_g_parm(struct file *file, void *priv,
1467 cp->capability = V4L2_CAP_TIMEPERFRAME;
1468
1469 ret = tw5864_frameinterval_get(input, &cp->timeperframe);
1470 + if (ret)
1471 + return ret;
1472 +
1473 cp->timeperframe.numerator *= input->frame_interval;
1474 cp->capturemode = 0;
1475 cp->readbuffers = 2;
1476 diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
1477 index 04644e7b42b12..88c32b8dc88a1 100644
1478 --- a/drivers/memory/emif.c
1479 +++ b/drivers/memory/emif.c
1480 @@ -165,35 +165,12 @@ static const struct file_operations emif_mr4_fops = {
1481
1482 static int __init_or_module emif_debugfs_init(struct emif_data *emif)
1483 {
1484 - struct dentry *dentry;
1485 - int ret;
1486 -
1487 - dentry = debugfs_create_dir(dev_name(emif->dev), NULL);
1488 - if (!dentry) {
1489 - ret = -ENOMEM;
1490 - goto err0;
1491 - }
1492 - emif->debugfs_root = dentry;
1493 -
1494 - dentry = debugfs_create_file("regcache_dump", S_IRUGO,
1495 - emif->debugfs_root, emif, &emif_regdump_fops);
1496 - if (!dentry) {
1497 - ret = -ENOMEM;
1498 - goto err1;
1499 - }
1500 -
1501 - dentry = debugfs_create_file("mr4", S_IRUGO,
1502 - emif->debugfs_root, emif, &emif_mr4_fops);
1503 - if (!dentry) {
1504 - ret = -ENOMEM;
1505 - goto err1;
1506 - }
1507 -
1508 + emif->debugfs_root = debugfs_create_dir(dev_name(emif->dev), NULL);
1509 + debugfs_create_file("regcache_dump", S_IRUGO, emif->debugfs_root, emif,
1510 + &emif_regdump_fops);
1511 + debugfs_create_file("mr4", S_IRUGO, emif->debugfs_root, emif,
1512 + &emif_mr4_fops);
1513 return 0;
1514 -err1:
1515 - debugfs_remove_recursive(emif->debugfs_root);
1516 -err0:
1517 - return ret;
1518 }
1519
1520 static void __exit emif_debugfs_exit(struct emif_data *emif)
1521 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
1522 index e77185e143ab7..32083759b93d0 100644
1523 --- a/drivers/message/fusion/mptscsih.c
1524 +++ b/drivers/message/fusion/mptscsih.c
1525 @@ -1176,8 +1176,10 @@ mptscsih_remove(struct pci_dev *pdev)
1526
1527 scsi_remove_host(host);
1528
1529 - if((hd = shost_priv(host)) == NULL)
1530 - return;
1531 + if (host == NULL)
1532 + hd = NULL;
1533 + else
1534 + hd = shost_priv(host);
1535
1536 mptscsih_shutdown(pdev);
1537
1538 @@ -1193,14 +1195,15 @@ mptscsih_remove(struct pci_dev *pdev)
1539 "Free'd ScsiLookup (%d) memory\n",
1540 ioc->name, sz1));
1541
1542 - kfree(hd->info_kbuf);
1543 + if (hd)
1544 + kfree(hd->info_kbuf);
1545
1546 /* NULL the Scsi_Host pointer
1547 */
1548 ioc->sh = NULL;
1549
1550 - scsi_host_put(host);
1551 -
1552 + if (host)
1553 + scsi_host_put(host);
1554 mpt_detach(pdev);
1555
1556 }
1557 diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c
1558 index 63fac78b3d46a..b455e9cf95afc 100644
1559 --- a/drivers/mmc/host/via-sdmmc.c
1560 +++ b/drivers/mmc/host/via-sdmmc.c
1561 @@ -1269,11 +1269,14 @@ static void via_init_sdc_pm(struct via_crdr_mmc_host *host)
1562 static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state)
1563 {
1564 struct via_crdr_mmc_host *host;
1565 + unsigned long flags;
1566
1567 host = pci_get_drvdata(pcidev);
1568
1569 + spin_lock_irqsave(&host->lock, flags);
1570 via_save_pcictrlreg(host);
1571 via_save_sdcreg(host);
1572 + spin_unlock_irqrestore(&host->lock, flags);
1573
1574 pci_save_state(pcidev);
1575 pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0);
1576 diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
1577 index a8f74d9bba4ff..545a92eb8f569 100644
1578 --- a/drivers/mtd/ubi/wl.c
1579 +++ b/drivers/mtd/ubi/wl.c
1580 @@ -1478,6 +1478,19 @@ int ubi_thread(void *u)
1581 !ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) {
1582 set_current_state(TASK_INTERRUPTIBLE);
1583 spin_unlock(&ubi->wl_lock);
1584 +
1585 + /*
1586 + * Check kthread_should_stop() after we set the task
1587 + * state to guarantee that we either see the stop bit
1588 + * and exit or the task state is reset to runnable such
1589 + * that it's not scheduled out indefinitely and detects
1590 + * the stop bit at kthread_should_stop().
1591 + */
1592 + if (kthread_should_stop()) {
1593 + set_current_state(TASK_RUNNING);
1594 + break;
1595 + }
1596 +
1597 schedule();
1598 continue;
1599 }
1600 diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
1601 index 95ab44aa0eeab..2df646348dbd4 100644
1602 --- a/drivers/net/ethernet/freescale/gianfar.c
1603 +++ b/drivers/net/ethernet/freescale/gianfar.c
1604 @@ -1385,7 +1385,7 @@ static int gfar_probe(struct platform_device *ofdev)
1605
1606 if (dev->features & NETIF_F_IP_CSUM ||
1607 priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
1608 - dev->needed_headroom = GMAC_FCB_LEN;
1609 + dev->needed_headroom = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
1610
1611 /* Initializing some of the rx/tx queue level parameters */
1612 for (i = 0; i < priv->num_tx_queues; i++) {
1613 @@ -2367,20 +2367,12 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1614 fcb_len = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
1615
1616 /* make space for additional header when fcb is needed */
1617 - if (fcb_len && unlikely(skb_headroom(skb) < fcb_len)) {
1618 - struct sk_buff *skb_new;
1619 -
1620 - skb_new = skb_realloc_headroom(skb, fcb_len);
1621 - if (!skb_new) {
1622 + if (fcb_len) {
1623 + if (unlikely(skb_cow_head(skb, fcb_len))) {
1624 dev->stats.tx_errors++;
1625 dev_kfree_skb_any(skb);
1626 return NETDEV_TX_OK;
1627 }
1628 -
1629 - if (skb->sk)
1630 - skb_set_owner_w(skb_new, skb->sk);
1631 - dev_consume_skb_any(skb);
1632 - skb = skb_new;
1633 }
1634
1635 /* total number of fragments in the SKB */
1636 diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
1637 index 808d924dbe21e..bdf29d0cf4d77 100644
1638 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c
1639 +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
1640 @@ -485,6 +485,9 @@ static void mlxsw_emad_transmit_retry(struct mlxsw_core *mlxsw_core,
1641 err = mlxsw_emad_transmit(trans->core, trans);
1642 if (err == 0)
1643 return;
1644 +
1645 + if (!atomic_dec_and_test(&trans->active))
1646 + return;
1647 } else {
1648 err = -EIO;
1649 }
1650 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
1651 index 93d3152752ff4..5452fe4bf12ad 100644
1652 --- a/drivers/net/ethernet/renesas/ravb_main.c
1653 +++ b/drivers/net/ethernet/renesas/ravb_main.c
1654 @@ -1729,12 +1729,16 @@ static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req)
1655 config.flags = 0;
1656 config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON :
1657 HWTSTAMP_TX_OFF;
1658 - if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT)
1659 + switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) {
1660 + case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT:
1661 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
1662 - else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL)
1663 + break;
1664 + case RAVB_RXTSTAMP_TYPE_ALL:
1665 config.rx_filter = HWTSTAMP_FILTER_ALL;
1666 - else
1667 + break;
1668 + default:
1669 config.rx_filter = HWTSTAMP_FILTER_NONE;
1670 + }
1671
1672 return copy_to_user(req->ifr_data, &config, sizeof(config)) ?
1673 -EFAULT : 0;
1674 diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
1675 index bba19d068207a..487605d2b389d 100644
1676 --- a/drivers/net/wan/hdlc_fr.c
1677 +++ b/drivers/net/wan/hdlc_fr.c
1678 @@ -275,63 +275,69 @@ static inline struct net_device **get_dev_p(struct pvc_device *pvc,
1679
1680 static int fr_hard_header(struct sk_buff **skb_p, u16 dlci)
1681 {
1682 - u16 head_len;
1683 struct sk_buff *skb = *skb_p;
1684
1685 - switch (skb->protocol) {
1686 - case cpu_to_be16(NLPID_CCITT_ANSI_LMI):
1687 - head_len = 4;
1688 - skb_push(skb, head_len);
1689 - skb->data[3] = NLPID_CCITT_ANSI_LMI;
1690 - break;
1691 -
1692 - case cpu_to_be16(NLPID_CISCO_LMI):
1693 - head_len = 4;
1694 - skb_push(skb, head_len);
1695 - skb->data[3] = NLPID_CISCO_LMI;
1696 - break;
1697 -
1698 - case cpu_to_be16(ETH_P_IP):
1699 - head_len = 4;
1700 - skb_push(skb, head_len);
1701 - skb->data[3] = NLPID_IP;
1702 - break;
1703 -
1704 - case cpu_to_be16(ETH_P_IPV6):
1705 - head_len = 4;
1706 - skb_push(skb, head_len);
1707 - skb->data[3] = NLPID_IPV6;
1708 - break;
1709 -
1710 - case cpu_to_be16(ETH_P_802_3):
1711 - head_len = 10;
1712 - if (skb_headroom(skb) < head_len) {
1713 - struct sk_buff *skb2 = skb_realloc_headroom(skb,
1714 - head_len);
1715 + if (!skb->dev) { /* Control packets */
1716 + switch (dlci) {
1717 + case LMI_CCITT_ANSI_DLCI:
1718 + skb_push(skb, 4);
1719 + skb->data[3] = NLPID_CCITT_ANSI_LMI;
1720 + break;
1721 +
1722 + case LMI_CISCO_DLCI:
1723 + skb_push(skb, 4);
1724 + skb->data[3] = NLPID_CISCO_LMI;
1725 + break;
1726 +
1727 + default:
1728 + return -EINVAL;
1729 + }
1730 +
1731 + } else if (skb->dev->type == ARPHRD_DLCI) {
1732 + switch (skb->protocol) {
1733 + case htons(ETH_P_IP):
1734 + skb_push(skb, 4);
1735 + skb->data[3] = NLPID_IP;
1736 + break;
1737 +
1738 + case htons(ETH_P_IPV6):
1739 + skb_push(skb, 4);
1740 + skb->data[3] = NLPID_IPV6;
1741 + break;
1742 +
1743 + default:
1744 + skb_push(skb, 10);
1745 + skb->data[3] = FR_PAD;
1746 + skb->data[4] = NLPID_SNAP;
1747 + /* OUI 00-00-00 indicates an Ethertype follows */
1748 + skb->data[5] = 0x00;
1749 + skb->data[6] = 0x00;
1750 + skb->data[7] = 0x00;
1751 + /* This should be an Ethertype: */
1752 + *(__be16 *)(skb->data + 8) = skb->protocol;
1753 + }
1754 +
1755 + } else if (skb->dev->type == ARPHRD_ETHER) {
1756 + if (skb_headroom(skb) < 10) {
1757 + struct sk_buff *skb2 = skb_realloc_headroom(skb, 10);
1758 if (!skb2)
1759 return -ENOBUFS;
1760 dev_kfree_skb(skb);
1761 skb = *skb_p = skb2;
1762 }
1763 - skb_push(skb, head_len);
1764 + skb_push(skb, 10);
1765 skb->data[3] = FR_PAD;
1766 skb->data[4] = NLPID_SNAP;
1767 - skb->data[5] = FR_PAD;
1768 + /* OUI 00-80-C2 stands for the 802.1 organization */
1769 + skb->data[5] = 0x00;
1770 skb->data[6] = 0x80;
1771 skb->data[7] = 0xC2;
1772 + /* PID 00-07 stands for Ethernet frames without FCS */
1773 skb->data[8] = 0x00;
1774 - skb->data[9] = 0x07; /* bridged Ethernet frame w/out FCS */
1775 - break;
1776 + skb->data[9] = 0x07;
1777
1778 - default:
1779 - head_len = 10;
1780 - skb_push(skb, head_len);
1781 - skb->data[3] = FR_PAD;
1782 - skb->data[4] = NLPID_SNAP;
1783 - skb->data[5] = FR_PAD;
1784 - skb->data[6] = FR_PAD;
1785 - skb->data[7] = FR_PAD;
1786 - *(__be16*)(skb->data + 8) = skb->protocol;
1787 + } else {
1788 + return -EINVAL;
1789 }
1790
1791 dlci_to_q922(skb->data, dlci);
1792 @@ -427,8 +433,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
1793 skb_put(skb, pad);
1794 memset(skb->data + len, 0, pad);
1795 }
1796 - skb->protocol = cpu_to_be16(ETH_P_802_3);
1797 }
1798 + skb->dev = dev;
1799 if (!fr_hard_header(&skb, pvc->dlci)) {
1800 dev->stats.tx_bytes += skb->len;
1801 dev->stats.tx_packets++;
1802 @@ -496,10 +502,8 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
1803 memset(skb->data, 0, len);
1804 skb_reserve(skb, 4);
1805 if (lmi == LMI_CISCO) {
1806 - skb->protocol = cpu_to_be16(NLPID_CISCO_LMI);
1807 fr_hard_header(&skb, LMI_CISCO_DLCI);
1808 } else {
1809 - skb->protocol = cpu_to_be16(NLPID_CCITT_ANSI_LMI);
1810 fr_hard_header(&skb, LMI_CCITT_ANSI_DLCI);
1811 }
1812 data = skb_tail_pointer(skb);
1813 diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
1814 index fce2064ebc469..3cbc71fa70d18 100644
1815 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
1816 +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
1817 @@ -620,6 +620,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
1818 u8 preamble = 0;
1819 u8 group_id;
1820 u32 info1, info2, info3;
1821 + u32 stbc, nsts_su;
1822
1823 info1 = __le32_to_cpu(rxd->ppdu_start.info1);
1824 info2 = __le32_to_cpu(rxd->ppdu_start.info2);
1825 @@ -663,11 +664,16 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
1826 TODO check this */
1827 bw = info2 & 3;
1828 sgi = info3 & 1;
1829 + stbc = (info2 >> 3) & 1;
1830 group_id = (info2 >> 4) & 0x3F;
1831
1832 if (GROUP_ID_IS_SU_MIMO(group_id)) {
1833 mcs = (info3 >> 4) & 0x0F;
1834 - nss = ((info2 >> 10) & 0x07) + 1;
1835 + nsts_su = ((info2 >> 10) & 0x07);
1836 + if (stbc)
1837 + nss = (nsts_su >> 2) + 1;
1838 + else
1839 + nss = (nsts_su + 1);
1840 } else {
1841 /* Hardware doesn't decode VHT-SIG-B into Rx descriptor
1842 * so it's impossible to decode MCS. Also since
1843 diff --git a/drivers/net/wireless/intersil/p54/p54pci.c b/drivers/net/wireless/intersil/p54/p54pci.c
1844 index 57ad56435dda5..8bc0286b4f8c1 100644
1845 --- a/drivers/net/wireless/intersil/p54/p54pci.c
1846 +++ b/drivers/net/wireless/intersil/p54/p54pci.c
1847 @@ -332,10 +332,12 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1848 struct p54p_desc *desc;
1849 dma_addr_t mapping;
1850 u32 idx, i;
1851 + __le32 device_addr;
1852
1853 spin_lock_irqsave(&priv->lock, flags);
1854 idx = le32_to_cpu(ring_control->host_idx[1]);
1855 i = idx % ARRAY_SIZE(ring_control->tx_data);
1856 + device_addr = ((struct p54_hdr *)skb->data)->req_id;
1857
1858 mapping = pci_map_single(priv->pdev, skb->data, skb->len,
1859 PCI_DMA_TODEVICE);
1860 @@ -349,7 +351,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1861
1862 desc = &ring_control->tx_data[i];
1863 desc->host_addr = cpu_to_le32(mapping);
1864 - desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
1865 + desc->device_addr = device_addr;
1866 desc->len = cpu_to_le16(skb->len);
1867 desc->flags = 0;
1868
1869 diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
1870 index 366d8c3c79893..f15bb936dfd84 100644
1871 --- a/drivers/of/of_reserved_mem.c
1872 +++ b/drivers/of/of_reserved_mem.c
1873 @@ -222,6 +222,16 @@ static int __init __rmem_cmp(const void *a, const void *b)
1874 if (ra->base > rb->base)
1875 return 1;
1876
1877 + /*
1878 + * Put the dynamic allocations (address == 0, size == 0) before static
1879 + * allocations at address 0x0 so that overlap detection works
1880 + * correctly.
1881 + */
1882 + if (ra->size < rb->size)
1883 + return -1;
1884 + if (ra->size > rb->size)
1885 + return 1;
1886 +
1887 return 0;
1888 }
1889
1890 @@ -239,8 +249,7 @@ static void __init __rmem_check_for_overlap(void)
1891
1892 this = &reserved_mem[i];
1893 next = &reserved_mem[i + 1];
1894 - if (!(this->base && next->base))
1895 - continue;
1896 +
1897 if (this->base + this->size > next->base) {
1898 phys_addr_t this_end, next_end;
1899
1900 diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c
1901 index 57246cdbd0426..925abec45380f 100644
1902 --- a/drivers/power/supply/test_power.c
1903 +++ b/drivers/power/supply/test_power.c
1904 @@ -344,6 +344,7 @@ static int param_set_ac_online(const char *key, const struct kernel_param *kp)
1905 static int param_get_ac_online(char *buffer, const struct kernel_param *kp)
1906 {
1907 strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown"));
1908 + strcat(buffer, "\n");
1909 return strlen(buffer);
1910 }
1911
1912 @@ -357,6 +358,7 @@ static int param_set_usb_online(const char *key, const struct kernel_param *kp)
1913 static int param_get_usb_online(char *buffer, const struct kernel_param *kp)
1914 {
1915 strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown"));
1916 + strcat(buffer, "\n");
1917 return strlen(buffer);
1918 }
1919
1920 @@ -371,6 +373,7 @@ static int param_set_battery_status(const char *key,
1921 static int param_get_battery_status(char *buffer, const struct kernel_param *kp)
1922 {
1923 strcpy(buffer, map_get_key(map_status, battery_status, "unknown"));
1924 + strcat(buffer, "\n");
1925 return strlen(buffer);
1926 }
1927
1928 @@ -385,6 +388,7 @@ static int param_set_battery_health(const char *key,
1929 static int param_get_battery_health(char *buffer, const struct kernel_param *kp)
1930 {
1931 strcpy(buffer, map_get_key(map_health, battery_health, "unknown"));
1932 + strcat(buffer, "\n");
1933 return strlen(buffer);
1934 }
1935
1936 @@ -400,6 +404,7 @@ static int param_get_battery_present(char *buffer,
1937 const struct kernel_param *kp)
1938 {
1939 strcpy(buffer, map_get_key(map_present, battery_present, "unknown"));
1940 + strcat(buffer, "\n");
1941 return strlen(buffer);
1942 }
1943
1944 @@ -417,6 +422,7 @@ static int param_get_battery_technology(char *buffer,
1945 {
1946 strcpy(buffer,
1947 map_get_key(map_technology, battery_technology, "unknown"));
1948 + strcat(buffer, "\n");
1949 return strlen(buffer);
1950 }
1951
1952 diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
1953 index d08da371912cd..93b1d8d9d2e93 100644
1954 --- a/drivers/rtc/rtc-rx8010.c
1955 +++ b/drivers/rtc/rtc-rx8010.c
1956 @@ -423,16 +423,26 @@ static int rx8010_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
1957 }
1958 }
1959
1960 -static struct rtc_class_ops rx8010_rtc_ops = {
1961 +static const struct rtc_class_ops rx8010_rtc_ops_default = {
1962 .read_time = rx8010_get_time,
1963 .set_time = rx8010_set_time,
1964 .ioctl = rx8010_ioctl,
1965 };
1966
1967 +static const struct rtc_class_ops rx8010_rtc_ops_alarm = {
1968 + .read_time = rx8010_get_time,
1969 + .set_time = rx8010_set_time,
1970 + .ioctl = rx8010_ioctl,
1971 + .read_alarm = rx8010_read_alarm,
1972 + .set_alarm = rx8010_set_alarm,
1973 + .alarm_irq_enable = rx8010_alarm_irq_enable,
1974 +};
1975 +
1976 static int rx8010_probe(struct i2c_client *client,
1977 const struct i2c_device_id *id)
1978 {
1979 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
1980 + const struct rtc_class_ops *rtc_ops;
1981 struct rx8010_data *rx8010;
1982 int err = 0;
1983
1984 @@ -463,16 +473,16 @@ static int rx8010_probe(struct i2c_client *client,
1985
1986 if (err) {
1987 dev_err(&client->dev, "unable to request IRQ\n");
1988 - client->irq = 0;
1989 - } else {
1990 - rx8010_rtc_ops.read_alarm = rx8010_read_alarm;
1991 - rx8010_rtc_ops.set_alarm = rx8010_set_alarm;
1992 - rx8010_rtc_ops.alarm_irq_enable = rx8010_alarm_irq_enable;
1993 + return err;
1994 }
1995 +
1996 + rtc_ops = &rx8010_rtc_ops_alarm;
1997 + } else {
1998 + rtc_ops = &rx8010_rtc_ops_default;
1999 }
2000
2001 rx8010->rtc = devm_rtc_device_register(&client->dev, client->name,
2002 - &rx8010_rtc_ops, THIS_MODULE);
2003 + rtc_ops, THIS_MODULE);
2004
2005 if (IS_ERR(rx8010->rtc)) {
2006 dev_err(&client->dev, "unable to register the class device\n");
2007 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
2008 index 67f6f134abc44..397deb69c6595 100644
2009 --- a/drivers/scsi/scsi_scan.c
2010 +++ b/drivers/scsi/scsi_scan.c
2011 @@ -1734,15 +1734,16 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
2012 */
2013 static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
2014 {
2015 - struct async_scan_data *data;
2016 + struct async_scan_data *data = NULL;
2017 unsigned long flags;
2018
2019 if (strncmp(scsi_scan_type, "sync", 4) == 0)
2020 return NULL;
2021
2022 + mutex_lock(&shost->scan_mutex);
2023 if (shost->async_scan) {
2024 shost_printk(KERN_DEBUG, shost, "%s called twice\n", __func__);
2025 - return NULL;
2026 + goto err;
2027 }
2028
2029 data = kmalloc(sizeof(*data), GFP_KERNEL);
2030 @@ -1753,7 +1754,6 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
2031 goto err;
2032 init_completion(&data->prev_finished);
2033
2034 - mutex_lock(&shost->scan_mutex);
2035 spin_lock_irqsave(shost->host_lock, flags);
2036 shost->async_scan = 1;
2037 spin_unlock_irqrestore(shost->host_lock, flags);
2038 @@ -1768,6 +1768,7 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
2039 return data;
2040
2041 err:
2042 + mutex_unlock(&shost->scan_mutex);
2043 kfree(data);
2044 return NULL;
2045 }
2046 diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
2047 index 3cd008acb657a..3ea15bb0e56ef 100644
2048 --- a/drivers/staging/comedi/drivers/cb_pcidas.c
2049 +++ b/drivers/staging/comedi/drivers/cb_pcidas.c
2050 @@ -1351,6 +1351,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
2051 if (dev->irq && board->has_ao_fifo) {
2052 dev->write_subdev = s;
2053 s->subdev_flags |= SDF_CMD_WRITE;
2054 + s->len_chanlist = s->n_chan;
2055 s->do_cmdtest = cb_pcidas_ao_cmdtest;
2056 s->do_cmd = cb_pcidas_ao_cmd;
2057 s->cancel = cb_pcidas_ao_cancel;
2058 diff --git a/drivers/staging/fsl-mc/bus/mc-io.c b/drivers/staging/fsl-mc/bus/mc-io.c
2059 index 798c965fe2033..3fa6774946fae 100644
2060 --- a/drivers/staging/fsl-mc/bus/mc-io.c
2061 +++ b/drivers/staging/fsl-mc/bus/mc-io.c
2062 @@ -167,7 +167,12 @@ error_destroy_mc_io:
2063 */
2064 void fsl_destroy_mc_io(struct fsl_mc_io *mc_io)
2065 {
2066 - struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev;
2067 + struct fsl_mc_device *dpmcp_dev;
2068 +
2069 + if (!mc_io)
2070 + return;
2071 +
2072 + dpmcp_dev = mc_io->dpmcp_dev;
2073
2074 if (dpmcp_dev)
2075 fsl_mc_io_unset_dpmcp(mc_io);
2076 diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
2077 index 691e4a51ace43..99f45012bc3f8 100644
2078 --- a/drivers/staging/octeon/ethernet-mdio.c
2079 +++ b/drivers/staging/octeon/ethernet-mdio.c
2080 @@ -155,12 +155,6 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
2081
2082 phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
2083 if (!phy_node && of_phy_is_fixed_link(priv->of_node)) {
2084 - int rc;
2085 -
2086 - rc = of_phy_register_fixed_link(priv->of_node);
2087 - if (rc)
2088 - return rc;
2089 -
2090 phy_node = of_node_get(priv->of_node);
2091 }
2092 if (!phy_node)
2093 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
2094 index f0900d1c4d7b5..47a195921f3c9 100644
2095 --- a/drivers/staging/octeon/ethernet-rx.c
2096 +++ b/drivers/staging/octeon/ethernet-rx.c
2097 @@ -83,15 +83,17 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
2098 else
2099 port = work->word1.cn38xx.ipprt;
2100
2101 - if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) {
2102 + if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64))
2103 /*
2104 * Ignore length errors on min size packets. Some
2105 * equipment incorrectly pads packets to 64+4FCS
2106 * instead of 60+4FCS. Note these packets still get
2107 * counted as frame errors.
2108 */
2109 - } else if (work->word2.snoip.err_code == 5 ||
2110 - work->word2.snoip.err_code == 7) {
2111 + return 0;
2112 +
2113 + if (work->word2.snoip.err_code == 5 ||
2114 + work->word2.snoip.err_code == 7) {
2115 /*
2116 * We received a packet with either an alignment error
2117 * or a FCS error. This may be signalling that we are
2118 @@ -122,7 +124,10 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
2119 /* Port received 0xd5 preamble */
2120 work->packet_ptr.s.addr += i + 1;
2121 work->word1.len -= i + 5;
2122 - } else if ((*ptr & 0xf) == 0xd) {
2123 + return 0;
2124 + }
2125 +
2126 + if ((*ptr & 0xf) == 0xd) {
2127 /* Port received 0xd preamble */
2128 work->packet_ptr.s.addr += i;
2129 work->word1.len -= i + 4;
2130 @@ -132,21 +137,20 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
2131 ((*(ptr + 1) & 0xf) << 4);
2132 ptr++;
2133 }
2134 - } else {
2135 - printk_ratelimited("Port %d unknown preamble, packet dropped\n",
2136 - port);
2137 - cvm_oct_free_work(work);
2138 - return 1;
2139 + return 0;
2140 }
2141 +
2142 + printk_ratelimited("Port %d unknown preamble, packet dropped\n",
2143 + port);
2144 + cvm_oct_free_work(work);
2145 + return 1;
2146 }
2147 - } else {
2148 - printk_ratelimited("Port %d receive error code %d, packet dropped\n",
2149 - port, work->word2.snoip.err_code);
2150 - cvm_oct_free_work(work);
2151 - return 1;
2152 }
2153
2154 - return 0;
2155 + printk_ratelimited("Port %d receive error code %d, packet dropped\n",
2156 + port, work->word2.snoip.err_code);
2157 + cvm_oct_free_work(work);
2158 + return 1;
2159 }
2160
2161 static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
2162 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
2163 index 12354440a334a..7601b800de077 100644
2164 --- a/drivers/staging/octeon/ethernet.c
2165 +++ b/drivers/staging/octeon/ethernet.c
2166 @@ -16,6 +16,7 @@
2167 #include <linux/phy.h>
2168 #include <linux/slab.h>
2169 #include <linux/interrupt.h>
2170 +#include <linux/of_mdio.h>
2171 #include <linux/of_net.h>
2172 #include <linux/if_ether.h>
2173 #include <linux/if_vlan.h>
2174 @@ -880,6 +881,14 @@ static int cvm_oct_probe(struct platform_device *pdev)
2175 break;
2176 }
2177
2178 + if (priv->of_node && of_phy_is_fixed_link(priv->of_node)) {
2179 + if (of_phy_register_fixed_link(priv->of_node)) {
2180 + netdev_err(dev, "Failed to register fixed link for interface %d, port %d\n",
2181 + interface, priv->port);
2182 + dev->netdev_ops = NULL;
2183 + }
2184 + }
2185 +
2186 if (!dev->netdev_ops) {
2187 free_netdev(dev);
2188 } else if (register_netdev(dev) < 0) {
2189 diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
2190 index c54f57e4a7dd6..d7421f0f857b9 100644
2191 --- a/drivers/tty/serial/8250/8250_mtk.c
2192 +++ b/drivers/tty/serial/8250/8250_mtk.c
2193 @@ -56,7 +56,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
2194 */
2195 baud = tty_termios_baud_rate(termios);
2196
2197 - serial8250_do_set_termios(port, termios, old);
2198 + serial8250_do_set_termios(port, termios, NULL);
2199
2200 tty_termios_encode_baud_rate(termios, baud, baud);
2201
2202 diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
2203 index f80312eed4fda..ffb3fb1bda9e7 100644
2204 --- a/drivers/tty/serial/serial_txx9.c
2205 +++ b/drivers/tty/serial/serial_txx9.c
2206 @@ -1287,6 +1287,9 @@ static int __init serial_txx9_init(void)
2207
2208 #ifdef ENABLE_SERIAL_TXX9_PCI
2209 ret = pci_register_driver(&serial_txx9_pci_driver);
2210 + if (ret) {
2211 + platform_driver_unregister(&serial_txx9_plat_driver);
2212 + }
2213 #endif
2214 if (ret == 0)
2215 goto out;
2216 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
2217 index d9eba79389176..4bc6261ef3c1a 100644
2218 --- a/drivers/tty/vt/keyboard.c
2219 +++ b/drivers/tty/vt/keyboard.c
2220 @@ -712,8 +712,13 @@ static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
2221 return;
2222
2223 if ((unsigned)value < ARRAY_SIZE(func_table)) {
2224 + unsigned long flags;
2225 +
2226 + spin_lock_irqsave(&func_buf_lock, flags);
2227 if (func_table[value])
2228 puts_queue(vc, func_table[value]);
2229 + spin_unlock_irqrestore(&func_buf_lock, flags);
2230 +
2231 } else
2232 pr_err("k_fn called with value=%d\n", value);
2233 }
2234 @@ -1959,13 +1964,11 @@ out:
2235 #undef s
2236 #undef v
2237
2238 -/* FIXME: This one needs untangling and locking */
2239 +/* FIXME: This one needs untangling */
2240 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
2241 {
2242 struct kbsentry *kbs;
2243 - char *p;
2244 u_char *q;
2245 - u_char __user *up;
2246 int sz, fnw_sz;
2247 int delta;
2248 char *first_free, *fj, *fnw;
2249 @@ -1991,23 +1994,19 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
2250 i = kbs->kb_func;
2251
2252 switch (cmd) {
2253 - case KDGKBSENT:
2254 - sz = sizeof(kbs->kb_string) - 1; /* sz should have been
2255 - a struct member */
2256 - up = user_kdgkb->kb_string;
2257 - p = func_table[i];
2258 - if(p)
2259 - for ( ; *p && sz; p++, sz--)
2260 - if (put_user(*p, up++)) {
2261 - ret = -EFAULT;
2262 - goto reterr;
2263 - }
2264 - if (put_user('\0', up)) {
2265 - ret = -EFAULT;
2266 - goto reterr;
2267 - }
2268 - kfree(kbs);
2269 - return ((p && *p) ? -EOVERFLOW : 0);
2270 + case KDGKBSENT: {
2271 + /* size should have been a struct member */
2272 + ssize_t len = sizeof(user_kdgkb->kb_string);
2273 +
2274 + spin_lock_irqsave(&func_buf_lock, flags);
2275 + len = strlcpy(kbs->kb_string, func_table[i] ? : "", len);
2276 + spin_unlock_irqrestore(&func_buf_lock, flags);
2277 +
2278 + ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string,
2279 + len + 1) ? -EFAULT : 0;
2280 +
2281 + goto reterr;
2282 + }
2283 case KDSKBSENT:
2284 if (!perm) {
2285 ret = -EPERM;
2286 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
2287 index 1f00f42213c27..2fa7527b1230e 100644
2288 --- a/drivers/tty/vt/vt.c
2289 +++ b/drivers/tty/vt/vt.c
2290 @@ -4235,27 +4235,6 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
2291 return rc;
2292 }
2293
2294 -static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
2295 -{
2296 - int con = op->height;
2297 - int rc;
2298 -
2299 -
2300 - console_lock();
2301 - if (vc->vc_mode != KD_TEXT)
2302 - rc = -EINVAL;
2303 - else if (!vc->vc_sw->con_font_copy)
2304 - rc = -ENOSYS;
2305 - else if (con < 0 || !vc_cons_allocated(con))
2306 - rc = -ENOTTY;
2307 - else if (con == vc->vc_num) /* nothing to do */
2308 - rc = 0;
2309 - else
2310 - rc = vc->vc_sw->con_font_copy(vc, con);
2311 - console_unlock();
2312 - return rc;
2313 -}
2314 -
2315 int con_font_op(struct vc_data *vc, struct console_font_op *op)
2316 {
2317 switch (op->op) {
2318 @@ -4266,7 +4245,8 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op)
2319 case KD_FONT_OP_SET_DEFAULT:
2320 return con_font_default(vc, op);
2321 case KD_FONT_OP_COPY:
2322 - return con_font_copy(vc, op);
2323 + /* was buggy and never really used */
2324 + return -EINVAL;
2325 }
2326 return -ENOSYS;
2327 }
2328 diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
2329 index 78a3b969cae71..275ec49b30b9f 100644
2330 --- a/drivers/tty/vt/vt_ioctl.c
2331 +++ b/drivers/tty/vt/vt_ioctl.c
2332 @@ -243,7 +243,7 @@ int vt_waitactive(int n)
2333
2334
2335 static inline int
2336 -do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struct console_font_op *op)
2337 +do_fontx_ioctl(struct vc_data *vc, int cmd, struct consolefontdesc __user *user_cfd, int perm, struct console_font_op *op)
2338 {
2339 struct consolefontdesc cfdarg;
2340 int i;
2341 @@ -261,15 +261,16 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc
2342 op->height = cfdarg.charheight;
2343 op->charcount = cfdarg.charcount;
2344 op->data = cfdarg.chardata;
2345 - return con_font_op(vc_cons[fg_console].d, op);
2346 - case GIO_FONTX: {
2347 + return con_font_op(vc, op);
2348 +
2349 + case GIO_FONTX:
2350 op->op = KD_FONT_OP_GET;
2351 op->flags = KD_FONT_FLAG_OLD;
2352 op->width = 8;
2353 op->height = cfdarg.charheight;
2354 op->charcount = cfdarg.charcount;
2355 op->data = cfdarg.chardata;
2356 - i = con_font_op(vc_cons[fg_console].d, op);
2357 + i = con_font_op(vc, op);
2358 if (i)
2359 return i;
2360 cfdarg.charheight = op->height;
2361 @@ -277,7 +278,6 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc
2362 if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc)))
2363 return -EFAULT;
2364 return 0;
2365 - }
2366 }
2367 return -EINVAL;
2368 }
2369 @@ -927,7 +927,7 @@ int vt_ioctl(struct tty_struct *tty,
2370 op.height = 0;
2371 op.charcount = 256;
2372 op.data = up;
2373 - ret = con_font_op(vc_cons[fg_console].d, &op);
2374 + ret = con_font_op(vc, &op);
2375 break;
2376 }
2377
2378 @@ -938,7 +938,7 @@ int vt_ioctl(struct tty_struct *tty,
2379 op.height = 32;
2380 op.charcount = 256;
2381 op.data = up;
2382 - ret = con_font_op(vc_cons[fg_console].d, &op);
2383 + ret = con_font_op(vc, &op);
2384 break;
2385 }
2386
2387 @@ -955,7 +955,7 @@ int vt_ioctl(struct tty_struct *tty,
2388
2389 case PIO_FONTX:
2390 case GIO_FONTX:
2391 - ret = do_fontx_ioctl(cmd, up, perm, &op);
2392 + ret = do_fontx_ioctl(vc, cmd, up, perm, &op);
2393 break;
2394
2395 case PIO_FONTRESET:
2396 @@ -972,11 +972,11 @@ int vt_ioctl(struct tty_struct *tty,
2397 {
2398 op.op = KD_FONT_OP_SET_DEFAULT;
2399 op.data = NULL;
2400 - ret = con_font_op(vc_cons[fg_console].d, &op);
2401 + ret = con_font_op(vc, &op);
2402 if (ret)
2403 break;
2404 console_lock();
2405 - con_set_default_unimap(vc_cons[fg_console].d);
2406 + con_set_default_unimap(vc);
2407 console_unlock();
2408 break;
2409 }
2410 @@ -1103,8 +1103,9 @@ struct compat_consolefontdesc {
2411 };
2412
2413 static inline int
2414 -compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
2415 - int perm, struct console_font_op *op)
2416 +compat_fontx_ioctl(struct vc_data *vc, int cmd,
2417 + struct compat_consolefontdesc __user *user_cfd,
2418 + int perm, struct console_font_op *op)
2419 {
2420 struct compat_consolefontdesc cfdarg;
2421 int i;
2422 @@ -1122,7 +1123,8 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
2423 op->height = cfdarg.charheight;
2424 op->charcount = cfdarg.charcount;
2425 op->data = compat_ptr(cfdarg.chardata);
2426 - return con_font_op(vc_cons[fg_console].d, op);
2427 + return con_font_op(vc, op);
2428 +
2429 case GIO_FONTX:
2430 op->op = KD_FONT_OP_GET;
2431 op->flags = KD_FONT_FLAG_OLD;
2432 @@ -1130,7 +1132,7 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
2433 op->height = cfdarg.charheight;
2434 op->charcount = cfdarg.charcount;
2435 op->data = compat_ptr(cfdarg.chardata);
2436 - i = con_font_op(vc_cons[fg_console].d, op);
2437 + i = con_font_op(vc, op);
2438 if (i)
2439 return i;
2440 cfdarg.charheight = op->height;
2441 @@ -1225,7 +1227,7 @@ long vt_compat_ioctl(struct tty_struct *tty,
2442 */
2443 case PIO_FONTX:
2444 case GIO_FONTX:
2445 - ret = compat_fontx_ioctl(cmd, up, perm, &op);
2446 + ret = compat_fontx_ioctl(vc, cmd, up, perm, &op);
2447 break;
2448
2449 case KDFONTOP:
2450 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
2451 index dd72e85f2e176..ca74b67c4450d 100644
2452 --- a/drivers/usb/core/quirks.c
2453 +++ b/drivers/usb/core/quirks.c
2454 @@ -217,6 +217,9 @@ static const struct usb_device_id usb_quirk_list[] = {
2455 { USB_DEVICE(0x0926, 0x3333), .driver_info =
2456 USB_QUIRK_CONFIG_INTF_STRINGS },
2457
2458 + /* Kingston DataTraveler 3.0 */
2459 + { USB_DEVICE(0x0951, 0x1666), .driver_info = USB_QUIRK_NO_LPM },
2460 +
2461 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
2462 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
2463
2464 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
2465 index a89072f3bd3fb..66254500e7a94 100644
2466 --- a/drivers/usb/dwc3/core.c
2467 +++ b/drivers/usb/dwc3/core.c
2468 @@ -1148,6 +1148,17 @@ static int dwc3_probe(struct platform_device *pdev)
2469
2470 err5:
2471 dwc3_event_buffers_cleanup(dwc);
2472 +
2473 + usb_phy_shutdown(dwc->usb2_phy);
2474 + usb_phy_shutdown(dwc->usb3_phy);
2475 + phy_exit(dwc->usb2_generic_phy);
2476 + phy_exit(dwc->usb3_generic_phy);
2477 +
2478 + usb_phy_set_suspend(dwc->usb2_phy, 1);
2479 + usb_phy_set_suspend(dwc->usb3_phy, 1);
2480 + phy_power_off(dwc->usb2_generic_phy);
2481 + phy_power_off(dwc->usb3_generic_phy);
2482 +
2483 dwc3_ulpi_exit(dwc);
2484
2485 err4:
2486 @@ -1194,9 +1205,9 @@ static int dwc3_remove(struct platform_device *pdev)
2487 dwc3_core_exit(dwc);
2488 dwc3_ulpi_exit(dwc);
2489
2490 - pm_runtime_put_sync(&pdev->dev);
2491 - pm_runtime_allow(&pdev->dev);
2492 pm_runtime_disable(&pdev->dev);
2493 + pm_runtime_put_noidle(&pdev->dev);
2494 + pm_runtime_set_suspended(&pdev->dev);
2495
2496 dwc3_free_event_buffers(dwc);
2497 dwc3_free_scratch_buffers(dwc);
2498 diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
2499 index f07ccb25bc244..6f006cbf1f839 100644
2500 --- a/drivers/usb/host/fsl-mph-dr-of.c
2501 +++ b/drivers/usb/host/fsl-mph-dr-of.c
2502 @@ -98,10 +98,13 @@ static struct platform_device *fsl_usb2_device_register(
2503
2504 pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
2505
2506 - if (!pdev->dev.dma_mask)
2507 + if (!pdev->dev.dma_mask) {
2508 pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask;
2509 - else
2510 - dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
2511 + } else {
2512 + retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
2513 + if (retval)
2514 + goto error;
2515 + }
2516
2517 retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
2518 if (retval)
2519 diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
2520 index 7fb0590187d40..a1bc516be154d 100644
2521 --- a/drivers/usb/misc/adutux.c
2522 +++ b/drivers/usb/misc/adutux.c
2523 @@ -210,6 +210,7 @@ static void adu_interrupt_out_callback(struct urb *urb)
2524
2525 if (status != 0) {
2526 if ((status != -ENOENT) &&
2527 + (status != -ESHUTDOWN) &&
2528 (status != -ECONNRESET)) {
2529 dev_dbg(&dev->udev->dev,
2530 "%s :nonzero status received: %d\n", __func__,
2531 diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
2532 index 80260b08398b2..b22a7b487a9f9 100644
2533 --- a/drivers/usb/serial/cyberjack.c
2534 +++ b/drivers/usb/serial/cyberjack.c
2535 @@ -367,11 +367,12 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
2536 struct cyberjack_private *priv = usb_get_serial_port_data(port);
2537 struct device *dev = &port->dev;
2538 int status = urb->status;
2539 + bool resubmitted = false;
2540
2541 - set_bit(0, &port->write_urbs_free);
2542 if (status) {
2543 dev_dbg(dev, "%s - nonzero write bulk status received: %d\n",
2544 __func__, status);
2545 + set_bit(0, &port->write_urbs_free);
2546 return;
2547 }
2548
2549 @@ -404,6 +405,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
2550 goto exit;
2551 }
2552
2553 + resubmitted = true;
2554 +
2555 dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent);
2556 dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled);
2557
2558 @@ -420,6 +423,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
2559
2560 exit:
2561 spin_unlock(&priv->lock);
2562 + if (!resubmitted)
2563 + set_bit(0, &port->write_urbs_free);
2564 usb_serial_port_softint(port);
2565 }
2566
2567 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2568 index 5017d37afe392..34ac1265afe46 100644
2569 --- a/drivers/usb/serial/option.c
2570 +++ b/drivers/usb/serial/option.c
2571 @@ -1174,6 +1174,8 @@ static const struct usb_device_id option_ids[] = {
2572 .driver_info = NCTRL(0) | RSVD(1) },
2573 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1054, 0xff), /* Telit FT980-KS */
2574 .driver_info = NCTRL(2) | RSVD(3) },
2575 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1055, 0xff), /* Telit FN980 (PCIe) */
2576 + .driver_info = NCTRL(0) | RSVD(1) },
2577 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
2578 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
2579 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
2580 @@ -1186,6 +1188,8 @@ static const struct usb_device_id option_ids[] = {
2581 .driver_info = NCTRL(0) },
2582 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
2583 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
2584 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1203, 0xff), /* Telit LE910Cx (RNDIS) */
2585 + .driver_info = NCTRL(2) | RSVD(3) },
2586 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
2587 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
2588 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
2589 @@ -1200,6 +1204,10 @@ static const struct usb_device_id option_ids[] = {
2590 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) },
2591 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214),
2592 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
2593 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1230, 0xff), /* Telit LE910Cx (rmnet) */
2594 + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
2595 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1231, 0xff), /* Telit LE910Cx (RNDIS) */
2596 + .driver_info = NCTRL(2) | RSVD(3) },
2597 { USB_DEVICE(TELIT_VENDOR_ID, 0x1260),
2598 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
2599 { USB_DEVICE(TELIT_VENDOR_ID, 0x1261),
2600 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
2601 index 3bb02c60a2f5f..d56736655dec4 100644
2602 --- a/drivers/vhost/vringh.c
2603 +++ b/drivers/vhost/vringh.c
2604 @@ -272,13 +272,14 @@ __vringh_iov(struct vringh *vrh, u16 i,
2605 desc_max = vrh->vring.num;
2606 up_next = -1;
2607
2608 + /* You must want something! */
2609 + if (WARN_ON(!riov && !wiov))
2610 + return -EINVAL;
2611 +
2612 if (riov)
2613 riov->i = riov->used = 0;
2614 - else if (wiov)
2615 + if (wiov)
2616 wiov->i = wiov->used = 0;
2617 - else
2618 - /* You must want something! */
2619 - BUG();
2620
2621 for (;;) {
2622 void *addr;
2623 diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c
2624 index a2564ab91e62d..27478ffeeacdc 100644
2625 --- a/drivers/video/fbdev/pvr2fb.c
2626 +++ b/drivers/video/fbdev/pvr2fb.c
2627 @@ -1029,6 +1029,8 @@ static int __init pvr2fb_setup(char *options)
2628 if (!options || !*options)
2629 return 0;
2630
2631 + cable_arg[0] = output_arg[0] = 0;
2632 +
2633 while ((this_opt = strsep(&options, ","))) {
2634 if (!*this_opt)
2635 continue;
2636 diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
2637 index dacb5919970c5..d2e9d2f6a7843 100644
2638 --- a/drivers/w1/masters/mxc_w1.c
2639 +++ b/drivers/w1/masters/mxc_w1.c
2640 @@ -15,7 +15,7 @@
2641 #include <linux/clk.h>
2642 #include <linux/delay.h>
2643 #include <linux/io.h>
2644 -#include <linux/jiffies.h>
2645 +#include <linux/ktime.h>
2646 #include <linux/module.h>
2647 #include <linux/platform_device.h>
2648
2649 @@ -48,12 +48,12 @@ struct mxc_w1_device {
2650 static u8 mxc_w1_ds2_reset_bus(void *data)
2651 {
2652 struct mxc_w1_device *dev = data;
2653 - unsigned long timeout;
2654 + ktime_t timeout;
2655
2656 writeb(MXC_W1_CONTROL_RPP, dev->regs + MXC_W1_CONTROL);
2657
2658 /* Wait for reset sequence 511+512us, use 1500us for sure */
2659 - timeout = jiffies + usecs_to_jiffies(1500);
2660 + timeout = ktime_add_us(ktime_get(), 1500);
2661
2662 udelay(511 + 512);
2663
2664 @@ -63,7 +63,7 @@ static u8 mxc_w1_ds2_reset_bus(void *data)
2665 /* PST bit is valid after the RPP bit is self-cleared */
2666 if (!(ctrl & MXC_W1_CONTROL_RPP))
2667 return !(ctrl & MXC_W1_CONTROL_PST);
2668 - } while (time_is_after_jiffies(timeout));
2669 + } while (ktime_before(ktime_get(), timeout));
2670
2671 return 1;
2672 }
2673 @@ -76,12 +76,12 @@ static u8 mxc_w1_ds2_reset_bus(void *data)
2674 static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit)
2675 {
2676 struct mxc_w1_device *dev = data;
2677 - unsigned long timeout;
2678 + ktime_t timeout;
2679
2680 writeb(MXC_W1_CONTROL_WR(bit), dev->regs + MXC_W1_CONTROL);
2681
2682 /* Wait for read/write bit (60us, Max 120us), use 200us for sure */
2683 - timeout = jiffies + usecs_to_jiffies(200);
2684 + timeout = ktime_add_us(ktime_get(), 200);
2685
2686 udelay(60);
2687
2688 @@ -91,7 +91,7 @@ static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit)
2689 /* RDST bit is valid after the WR1/RD bit is self-cleared */
2690 if (!(ctrl & MXC_W1_CONTROL_WR(bit)))
2691 return !!(ctrl & MXC_W1_CONTROL_RDST);
2692 - } while (time_is_after_jiffies(timeout));
2693 + } while (ktime_before(ktime_get(), timeout));
2694
2695 return 0;
2696 }
2697 diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
2698 index 47a8f1b1087d4..4568af9a165be 100644
2699 --- a/drivers/watchdog/rdc321x_wdt.c
2700 +++ b/drivers/watchdog/rdc321x_wdt.c
2701 @@ -244,6 +244,8 @@ static int rdc321x_wdt_probe(struct platform_device *pdev)
2702
2703 rdc321x_wdt_device.sb_pdev = pdata->sb_pdev;
2704 rdc321x_wdt_device.base_reg = r->start;
2705 + rdc321x_wdt_device.queue = 0;
2706 + rdc321x_wdt_device.default_ticks = ticks;
2707
2708 err = misc_register(&rdc321x_wdt_misc);
2709 if (err < 0) {
2710 @@ -258,14 +260,11 @@ static int rdc321x_wdt_probe(struct platform_device *pdev)
2711 rdc321x_wdt_device.base_reg, RDC_WDT_RST);
2712
2713 init_completion(&rdc321x_wdt_device.stop);
2714 - rdc321x_wdt_device.queue = 0;
2715
2716 clear_bit(0, &rdc321x_wdt_device.inuse);
2717
2718 setup_timer(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0);
2719
2720 - rdc321x_wdt_device.default_ticks = ticks;
2721 -
2722 dev_info(&pdev->dev, "watchdog init success\n");
2723
2724 return 0;
2725 diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2726 index 0dadfabcfd80b..83bb9fdbadc6a 100644
2727 --- a/drivers/xen/events/events_base.c
2728 +++ b/drivers/xen/events/events_base.c
2729 @@ -91,6 +91,8 @@ static bool (*pirq_needs_eoi)(unsigned irq);
2730 /* Xen will never allocate port zero for any purpose. */
2731 #define VALID_EVTCHN(chn) ((chn) != 0)
2732
2733 +static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY];
2734 +
2735 static struct irq_chip xen_dynamic_chip;
2736 static struct irq_chip xen_percpu_chip;
2737 static struct irq_chip xen_pirq_chip;
2738 @@ -155,7 +157,18 @@ int get_evtchn_to_irq(unsigned evtchn)
2739 /* Get info for IRQ */
2740 struct irq_info *info_for_irq(unsigned irq)
2741 {
2742 - return irq_get_chip_data(irq);
2743 + if (irq < nr_legacy_irqs())
2744 + return legacy_info_ptrs[irq];
2745 + else
2746 + return irq_get_chip_data(irq);
2747 +}
2748 +
2749 +static void set_info_for_irq(unsigned int irq, struct irq_info *info)
2750 +{
2751 + if (irq < nr_legacy_irqs())
2752 + legacy_info_ptrs[irq] = info;
2753 + else
2754 + irq_set_chip_data(irq, info);
2755 }
2756
2757 /* Constructors for packed IRQ information. */
2758 @@ -384,7 +397,7 @@ static void xen_irq_init(unsigned irq)
2759 info->type = IRQT_UNBOUND;
2760 info->refcnt = -1;
2761
2762 - irq_set_chip_data(irq, info);
2763 + set_info_for_irq(irq, info);
2764
2765 list_add_tail(&info->list, &xen_irq_list_head);
2766 }
2767 @@ -433,14 +446,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
2768
2769 static void xen_free_irq(unsigned irq)
2770 {
2771 - struct irq_info *info = irq_get_chip_data(irq);
2772 + struct irq_info *info = info_for_irq(irq);
2773
2774 if (WARN_ON(!info))
2775 return;
2776
2777 list_del(&info->list);
2778
2779 - irq_set_chip_data(irq, NULL);
2780 + set_info_for_irq(irq, NULL);
2781
2782 WARN_ON(info->refcnt > 0);
2783
2784 @@ -610,7 +623,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
2785 static void __unbind_from_irq(unsigned int irq)
2786 {
2787 int evtchn = evtchn_from_irq(irq);
2788 - struct irq_info *info = irq_get_chip_data(irq);
2789 + struct irq_info *info = info_for_irq(irq);
2790
2791 if (info->refcnt > 0) {
2792 info->refcnt--;
2793 @@ -1114,7 +1127,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
2794
2795 void unbind_from_irqhandler(unsigned int irq, void *dev_id)
2796 {
2797 - struct irq_info *info = irq_get_chip_data(irq);
2798 + struct irq_info *info = info_for_irq(irq);
2799
2800 if (WARN_ON(!info))
2801 return;
2802 @@ -1148,7 +1161,7 @@ int evtchn_make_refcounted(unsigned int evtchn)
2803 if (irq == -1)
2804 return -ENOENT;
2805
2806 - info = irq_get_chip_data(irq);
2807 + info = info_for_irq(irq);
2808
2809 if (!info)
2810 return -ENOENT;
2811 @@ -1176,7 +1189,7 @@ int evtchn_get(unsigned int evtchn)
2812 if (irq == -1)
2813 goto done;
2814
2815 - info = irq_get_chip_data(irq);
2816 + info = info_for_irq(irq);
2817
2818 if (!info)
2819 goto done;
2820 diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
2821 index e963b83afc717..6be16c74e3e9e 100644
2822 --- a/fs/9p/vfs_file.c
2823 +++ b/fs/9p/vfs_file.c
2824 @@ -624,9 +624,9 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
2825 struct writeback_control wbc = {
2826 .nr_to_write = LONG_MAX,
2827 .sync_mode = WB_SYNC_ALL,
2828 - .range_start = vma->vm_pgoff * PAGE_SIZE,
2829 + .range_start = (loff_t)vma->vm_pgoff * PAGE_SIZE,
2830 /* absolute end, byte at end included */
2831 - .range_end = vma->vm_pgoff * PAGE_SIZE +
2832 + .range_end = (loff_t)vma->vm_pgoff * PAGE_SIZE +
2833 (vma->vm_end - vma->vm_start - 1),
2834 };
2835
2836 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
2837 index 65689cbc362db..89eeca5bb23e5 100644
2838 --- a/fs/btrfs/ctree.c
2839 +++ b/fs/btrfs/ctree.c
2840 @@ -1122,6 +1122,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
2841
2842 ret = update_ref_for_cow(trans, root, buf, cow, &last_ref);
2843 if (ret) {
2844 + btrfs_tree_unlock(cow);
2845 + free_extent_buffer(cow);
2846 btrfs_abort_transaction(trans, ret);
2847 return ret;
2848 }
2849 @@ -1129,6 +1131,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
2850 if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) {
2851 ret = btrfs_reloc_cow_block(trans, root, buf, cow);
2852 if (ret) {
2853 + btrfs_tree_unlock(cow);
2854 + free_extent_buffer(cow);
2855 btrfs_abort_transaction(trans, ret);
2856 return ret;
2857 }
2858 @@ -1160,6 +1164,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
2859 if (last_ref) {
2860 ret = tree_mod_log_free_eb(root->fs_info, buf);
2861 if (ret) {
2862 + btrfs_tree_unlock(cow);
2863 + free_extent_buffer(cow);
2864 btrfs_abort_transaction(trans, ret);
2865 return ret;
2866 }
2867 diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
2868 index 0d1565d712314..d4ab8e185ef29 100644
2869 --- a/fs/btrfs/reada.c
2870 +++ b/fs/btrfs/reada.c
2871 @@ -456,6 +456,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
2872 }
2873 have_zone = 1;
2874 }
2875 + if (!have_zone)
2876 + radix_tree_delete(&fs_info->reada_tree, index);
2877 spin_unlock(&fs_info->reada_lock);
2878 btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
2879
2880 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
2881 index 5bd1758f57b64..9909b63d2acda 100644
2882 --- a/fs/btrfs/tree-log.c
2883 +++ b/fs/btrfs/tree-log.c
2884 @@ -3357,6 +3357,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2885 * search and this search we'll not find the key again and can just
2886 * bail.
2887 */
2888 +search:
2889 ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
2890 if (ret != 0)
2891 goto done;
2892 @@ -3376,6 +3377,13 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2893
2894 if (min_key.objectid != ino || min_key.type != key_type)
2895 goto done;
2896 +
2897 + if (need_resched()) {
2898 + btrfs_release_path(path);
2899 + cond_resched();
2900 + goto search;
2901 + }
2902 +
2903 ret = overwrite_item(trans, log, dst_path, src, i,
2904 &min_key);
2905 if (ret) {
2906 diff --git a/fs/buffer.c b/fs/buffer.c
2907 index 52f1a60417d1d..681b249039ebb 100644
2908 --- a/fs/buffer.c
2909 +++ b/fs/buffer.c
2910 @@ -2753,16 +2753,6 @@ int nobh_writepage(struct page *page, get_block_t *get_block,
2911 /* Is the page fully outside i_size? (truncate in progress) */
2912 offset = i_size & (PAGE_SIZE-1);
2913 if (page->index >= end_index+1 || !offset) {
2914 - /*
2915 - * The page may have dirty, unmapped buffers. For example,
2916 - * they may have been added in ext3_writepage(). Make them
2917 - * freeable here, so the page does not leak.
2918 - */
2919 -#if 0
2920 - /* Not really sure about this - do we need this ? */
2921 - if (page->mapping->a_ops->invalidatepage)
2922 - page->mapping->a_ops->invalidatepage(page, offset);
2923 -#endif
2924 unlock_page(page);
2925 return 0; /* don't care */
2926 }
2927 @@ -2957,12 +2947,6 @@ int block_write_full_page(struct page *page, get_block_t *get_block,
2928 /* Is the page fully outside i_size? (truncate in progress) */
2929 offset = i_size & (PAGE_SIZE-1);
2930 if (page->index >= end_index+1 || !offset) {
2931 - /*
2932 - * The page may have dirty, unmapped buffers. For example,
2933 - * they may have been added in ext3_writepage(). Make them
2934 - * freeable here, so the page does not leak.
2935 - */
2936 - do_invalidatepage(page, 0, PAGE_SIZE);
2937 unlock_page(page);
2938 return 0; /* don't care */
2939 }
2940 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
2941 index 7dba96d5fef1e..496eeceae0406 100644
2942 --- a/fs/cachefiles/rdwr.c
2943 +++ b/fs/cachefiles/rdwr.c
2944 @@ -125,7 +125,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
2945 _debug("reissue read");
2946 ret = bmapping->a_ops->readpage(NULL, backpage);
2947 if (ret < 0)
2948 - goto unlock_discard;
2949 + goto discard;
2950 }
2951
2952 /* but the page may have been read before the monitor was installed, so
2953 @@ -142,6 +142,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
2954
2955 unlock_discard:
2956 unlock_page(backpage);
2957 +discard:
2958 spin_lock_irq(&object->work_lock);
2959 list_del(&monitor->op_link);
2960 spin_unlock_irq(&object->work_lock);
2961 diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
2962 index 7b79a54a27898..36aa6d8cdff71 100644
2963 --- a/fs/ceph/addr.c
2964 +++ b/fs/ceph/addr.c
2965 @@ -1392,7 +1392,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
2966 struct ceph_inode_info *ci = ceph_inode(inode);
2967 struct ceph_file_info *fi = vma->vm_file->private_data;
2968 struct page *pinned_page = NULL;
2969 - loff_t off = vmf->pgoff << PAGE_SHIFT;
2970 + loff_t off = (loff_t)vmf->pgoff << PAGE_SHIFT;
2971 int want, got, ret;
2972 sigset_t oldset;
2973
2974 diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
2975 index 57a97b38a2fa2..2bf6e0a2a57ca 100644
2976 --- a/fs/crypto/policy.c
2977 +++ b/fs/crypto/policy.c
2978 @@ -93,16 +93,19 @@ static int create_encryption_context_from_policy(struct inode *inode,
2979 return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL);
2980 }
2981
2982 -int fscrypt_process_policy(struct file *filp,
2983 - const struct fscrypt_policy *policy)
2984 +int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
2985 {
2986 + struct fscrypt_policy policy;
2987 struct inode *inode = file_inode(filp);
2988 int ret;
2989
2990 + if (copy_from_user(&policy, arg, sizeof(policy)))
2991 + return -EFAULT;
2992 +
2993 if (!inode_owner_or_capable(inode))
2994 return -EACCES;
2995
2996 - if (policy->version != 0)
2997 + if (policy.version != 0)
2998 return -EINVAL;
2999
3000 ret = mnt_want_write_file(filp);
3001 @@ -122,13 +125,13 @@ int fscrypt_process_policy(struct file *filp,
3002 ret = -ENOTEMPTY;
3003 else
3004 ret = create_encryption_context_from_policy(inode,
3005 - policy);
3006 + &policy);
3007 } else if (!is_encryption_context_consistent_with_policy(inode,
3008 - policy)) {
3009 + &policy)) {
3010 printk(KERN_WARNING
3011 "%s: Policy inconsistent with encryption context\n",
3012 __func__);
3013 - ret = -EINVAL;
3014 + ret = -EEXIST;
3015 }
3016
3017 inode_unlock(inode);
3018 @@ -136,11 +139,13 @@ int fscrypt_process_policy(struct file *filp,
3019 mnt_drop_write_file(filp);
3020 return ret;
3021 }
3022 -EXPORT_SYMBOL(fscrypt_process_policy);
3023 +EXPORT_SYMBOL(fscrypt_ioctl_set_policy);
3024
3025 -int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy)
3026 +int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
3027 {
3028 + struct inode *inode = file_inode(filp);
3029 struct fscrypt_context ctx;
3030 + struct fscrypt_policy policy;
3031 int res;
3032
3033 if (!inode->i_sb->s_cop->get_context ||
3034 @@ -153,15 +158,18 @@ int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy)
3035 if (ctx.format != FS_ENCRYPTION_CONTEXT_FORMAT_V1)
3036 return -EINVAL;
3037
3038 - policy->version = 0;
3039 - policy->contents_encryption_mode = ctx.contents_encryption_mode;
3040 - policy->filenames_encryption_mode = ctx.filenames_encryption_mode;
3041 - policy->flags = ctx.flags;
3042 - memcpy(&policy->master_key_descriptor, ctx.master_key_descriptor,
3043 + policy.version = 0;
3044 + policy.contents_encryption_mode = ctx.contents_encryption_mode;
3045 + policy.filenames_encryption_mode = ctx.filenames_encryption_mode;
3046 + policy.flags = ctx.flags;
3047 + memcpy(policy.master_key_descriptor, ctx.master_key_descriptor,
3048 FS_KEY_DESCRIPTOR_SIZE);
3049 +
3050 + if (copy_to_user(arg, &policy, sizeof(policy)))
3051 + return -EFAULT;
3052 return 0;
3053 }
3054 -EXPORT_SYMBOL(fscrypt_get_policy);
3055 +EXPORT_SYMBOL(fscrypt_ioctl_get_policy);
3056
3057 /**
3058 * fscrypt_has_permitted_context() - is a file's encryption policy permitted
3059 @@ -180,8 +188,7 @@ EXPORT_SYMBOL(fscrypt_get_policy);
3060 * malicious offline violations of this constraint, while the link and rename
3061 * checks are needed to prevent online violations of this constraint.
3062 *
3063 - * Return: 1 if permitted, 0 if forbidden. If forbidden, the caller must fail
3064 - * the filesystem operation with EPERM.
3065 + * Return: 1 if permitted, 0 if forbidden.
3066 */
3067 int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
3068 {
3069 diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
3070 index d7a7c53803c1b..b1e6acec53041 100644
3071 --- a/fs/efivarfs/super.c
3072 +++ b/fs/efivarfs/super.c
3073 @@ -146,6 +146,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
3074
3075 name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';
3076
3077 + /* replace invalid slashes like kobject_set_name_vargs does for /sys/firmware/efi/vars. */
3078 + strreplace(name, '/', '!');
3079 +
3080 inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0,
3081 is_removable);
3082 if (!inode)
3083 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
3084 index b41ac328c3964..360954196e2f3 100644
3085 --- a/fs/ext4/ext4.h
3086 +++ b/fs/ext4/ext4.h
3087 @@ -2354,8 +2354,8 @@ static inline void ext4_fname_free_filename(struct ext4_filename *fname) { }
3088 #define fscrypt_pullback_bio_page fscrypt_notsupp_pullback_bio_page
3089 #define fscrypt_restore_control_page fscrypt_notsupp_restore_control_page
3090 #define fscrypt_zeroout_range fscrypt_notsupp_zeroout_range
3091 -#define fscrypt_process_policy fscrypt_notsupp_process_policy
3092 -#define fscrypt_get_policy fscrypt_notsupp_get_policy
3093 +#define fscrypt_ioctl_set_policy fscrypt_notsupp_ioctl_set_policy
3094 +#define fscrypt_ioctl_get_policy fscrypt_notsupp_ioctl_get_policy
3095 #define fscrypt_has_permitted_context fscrypt_notsupp_has_permitted_context
3096 #define fscrypt_inherit_context fscrypt_notsupp_inherit_context
3097 #define fscrypt_get_encryption_info fscrypt_notsupp_get_encryption_info
3098 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
3099 index eada4172c4ef1..2016f5a5d3cf1 100644
3100 --- a/fs/ext4/ioctl.c
3101 +++ b/fs/ext4/ioctl.c
3102 @@ -774,22 +774,12 @@ resizefs_out:
3103 }
3104 case EXT4_IOC_PRECACHE_EXTENTS:
3105 return ext4_ext_precache(inode);
3106 - case EXT4_IOC_SET_ENCRYPTION_POLICY: {
3107 -#ifdef CONFIG_EXT4_FS_ENCRYPTION
3108 - struct fscrypt_policy policy;
3109
3110 + case EXT4_IOC_SET_ENCRYPTION_POLICY:
3111 if (!ext4_has_feature_encrypt(sb))
3112 return -EOPNOTSUPP;
3113 + return fscrypt_ioctl_set_policy(filp, (const void __user *)arg);
3114
3115 - if (copy_from_user(&policy,
3116 - (struct fscrypt_policy __user *)arg,
3117 - sizeof(policy)))
3118 - return -EFAULT;
3119 - return fscrypt_process_policy(filp, &policy);
3120 -#else
3121 - return -EOPNOTSUPP;
3122 -#endif
3123 - }
3124 case EXT4_IOC_GET_ENCRYPTION_PWSALT: {
3125 int err, err2;
3126 struct ext4_sb_info *sbi = EXT4_SB(sb);
3127 @@ -826,23 +816,9 @@ resizefs_out:
3128 return -EFAULT;
3129 return 0;
3130 }
3131 - case EXT4_IOC_GET_ENCRYPTION_POLICY: {
3132 -#ifdef CONFIG_EXT4_FS_ENCRYPTION
3133 - struct fscrypt_policy policy;
3134 - int err = 0;
3135 -
3136 - if (!ext4_encrypted_inode(inode))
3137 - return -ENOENT;
3138 - err = fscrypt_get_policy(inode, &policy);
3139 - if (err)
3140 - return err;
3141 - if (copy_to_user((void __user *)arg, &policy, sizeof(policy)))
3142 - return -EFAULT;
3143 - return 0;
3144 -#else
3145 - return -EOPNOTSUPP;
3146 -#endif
3147 - }
3148 + case EXT4_IOC_GET_ENCRYPTION_POLICY:
3149 + return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
3150 +
3151 case EXT4_IOC_FSGETXATTR:
3152 {
3153 struct fsxattr fa;
3154 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
3155 index 157dbbe235f90..8ded38ac4cdef 100644
3156 --- a/fs/ext4/namei.c
3157 +++ b/fs/ext4/namei.c
3158 @@ -3259,7 +3259,7 @@ static int ext4_link(struct dentry *old_dentry,
3159 return -EMLINK;
3160 if (ext4_encrypted_inode(dir) &&
3161 !fscrypt_has_permitted_context(dir, inode))
3162 - return -EPERM;
3163 + return -EXDEV;
3164
3165 if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
3166 (!projid_eq(EXT4_I(dir)->i_projid,
3167 @@ -3597,7 +3597,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3168 if ((old.dir != new.dir) &&
3169 ext4_encrypted_inode(new.dir) &&
3170 !fscrypt_has_permitted_context(new.dir, old.inode)) {
3171 - retval = -EPERM;
3172 + retval = -EXDEV;
3173 goto end_rename;
3174 }
3175
3176 @@ -3776,7 +3776,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3177 (old_dir != new_dir) &&
3178 (!fscrypt_has_permitted_context(new_dir, old.inode) ||
3179 !fscrypt_has_permitted_context(old_dir, new.inode)))
3180 - return -EPERM;
3181 + return -EXDEV;
3182
3183 if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
3184 !projid_eq(EXT4_I(new_dir)->i_projid,
3185 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
3186 index 472fa29c6f604..2527eb3049494 100644
3187 --- a/fs/ext4/super.c
3188 +++ b/fs/ext4/super.c
3189 @@ -5412,6 +5412,11 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
3190 /* Quotafile not on the same filesystem? */
3191 if (path->dentry->d_sb != sb)
3192 return -EXDEV;
3193 +
3194 + /* Quota already enabled for this file? */
3195 + if (IS_NOQUOTA(d_inode(path->dentry)))
3196 + return -EBUSY;
3197 +
3198 /* Journaling quota? */
3199 if (EXT4_SB(sb)->s_qf_names[type]) {
3200 /* Quotafile not in fs root? */
3201 diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
3202 index 0b061bbf1639a..5e9f8ec8251d3 100644
3203 --- a/fs/f2fs/checkpoint.c
3204 +++ b/fs/f2fs/checkpoint.c
3205 @@ -201,6 +201,8 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
3206 blkno * NAT_ENTRY_PER_BLOCK);
3207 break;
3208 case META_SIT:
3209 + if (unlikely(blkno >= TOTAL_SEGS(sbi)))
3210 + goto out;
3211 /* get sit block addr */
3212 fio.new_blkaddr = current_sit_addr(sbi,
3213 blkno * SIT_ENTRY_PER_BLOCK);
3214 @@ -904,8 +906,12 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
3215 get_pages(sbi, is_dir ?
3216 F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
3217 retry:
3218 - if (unlikely(f2fs_cp_error(sbi)))
3219 + if (unlikely(f2fs_cp_error(sbi))) {
3220 + trace_f2fs_sync_dirty_inodes_exit(sbi->sb, is_dir,
3221 + get_pages(sbi, is_dir ?
3222 + F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
3223 return -EIO;
3224 + }
3225
3226 spin_lock(&sbi->inode_lock[type]);
3227
3228 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
3229 index b16ab4187234d..7016a59142e3e 100644
3230 --- a/fs/f2fs/f2fs.h
3231 +++ b/fs/f2fs/f2fs.h
3232 @@ -2513,8 +2513,8 @@ static inline bool f2fs_may_encrypt(struct inode *inode)
3233 #define fscrypt_pullback_bio_page fscrypt_notsupp_pullback_bio_page
3234 #define fscrypt_restore_control_page fscrypt_notsupp_restore_control_page
3235 #define fscrypt_zeroout_range fscrypt_notsupp_zeroout_range
3236 -#define fscrypt_process_policy fscrypt_notsupp_process_policy
3237 -#define fscrypt_get_policy fscrypt_notsupp_get_policy
3238 +#define fscrypt_ioctl_set_policy fscrypt_notsupp_ioctl_set_policy
3239 +#define fscrypt_ioctl_get_policy fscrypt_notsupp_ioctl_get_policy
3240 #define fscrypt_has_permitted_context fscrypt_notsupp_has_permitted_context
3241 #define fscrypt_inherit_context fscrypt_notsupp_inherit_context
3242 #define fscrypt_get_encryption_info fscrypt_notsupp_get_encryption_info
3243 diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
3244 index e3c438c8b8ce0..0bedcd70b51f4 100644
3245 --- a/fs/f2fs/file.c
3246 +++ b/fs/f2fs/file.c
3247 @@ -1774,31 +1774,16 @@ static bool uuid_is_nonzero(__u8 u[16])
3248
3249 static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
3250 {
3251 - struct fscrypt_policy policy;
3252 struct inode *inode = file_inode(filp);
3253
3254 - if (copy_from_user(&policy, (struct fscrypt_policy __user *)arg,
3255 - sizeof(policy)))
3256 - return -EFAULT;
3257 -
3258 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
3259
3260 - return fscrypt_process_policy(filp, &policy);
3261 + return fscrypt_ioctl_set_policy(filp, (const void __user *)arg);
3262 }
3263
3264 static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
3265 {
3266 - struct fscrypt_policy policy;
3267 - struct inode *inode = file_inode(filp);
3268 - int err;
3269 -
3270 - err = fscrypt_get_policy(inode, &policy);
3271 - if (err)
3272 - return err;
3273 -
3274 - if (copy_to_user((struct fscrypt_policy __user *)arg, &policy, sizeof(policy)))
3275 - return -EFAULT;
3276 - return 0;
3277 + return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
3278 }
3279
3280 static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
3281 diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
3282 index ccb99d5cfd8b0..ce0957318771c 100644
3283 --- a/fs/f2fs/namei.c
3284 +++ b/fs/f2fs/namei.c
3285 @@ -177,7 +177,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
3286
3287 if (f2fs_encrypted_inode(dir) &&
3288 !fscrypt_has_permitted_context(dir, inode))
3289 - return -EPERM;
3290 + return -EXDEV;
3291
3292 f2fs_balance_fs(sbi, true);
3293
3294 @@ -667,7 +667,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
3295
3296 if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) &&
3297 !fscrypt_has_permitted_context(new_dir, old_inode)) {
3298 - err = -EPERM;
3299 + err = -EXDEV;
3300 goto out;
3301 }
3302
3303 @@ -855,7 +855,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3304 (old_dir != new_dir) &&
3305 (!fscrypt_has_permitted_context(new_dir, old_inode) ||
3306 !fscrypt_has_permitted_context(old_dir, new_inode)))
3307 - return -EPERM;
3308 + return -EXDEV;
3309
3310 old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
3311 if (!old_entry) {
3312 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
3313 index f0129c033bd66..33c90e24f91aa 100644
3314 --- a/fs/fuse/dev.c
3315 +++ b/fs/fuse/dev.c
3316 @@ -846,15 +846,16 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
3317 struct page *newpage;
3318 struct pipe_buffer *buf = cs->pipebufs;
3319
3320 + get_page(oldpage);
3321 err = unlock_request(cs->req);
3322 if (err)
3323 - return err;
3324 + goto out_put_old;
3325
3326 fuse_copy_finish(cs);
3327
3328 err = pipe_buf_confirm(cs->pipe, buf);
3329 if (err)
3330 - return err;
3331 + goto out_put_old;
3332
3333 BUG_ON(!cs->nr_segs);
3334 cs->currbuf = buf;
3335 @@ -894,7 +895,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
3336 err = replace_page_cache_page(oldpage, newpage, GFP_KERNEL);
3337 if (err) {
3338 unlock_page(newpage);
3339 - return err;
3340 + goto out_put_old;
3341 }
3342
3343 get_page(newpage);
3344 @@ -913,14 +914,19 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
3345 if (err) {
3346 unlock_page(newpage);
3347 put_page(newpage);
3348 - return err;
3349 + goto out_put_old;
3350 }
3351
3352 unlock_page(oldpage);
3353 + /* Drop ref for ap->pages[] array */
3354 put_page(oldpage);
3355 cs->len = 0;
3356
3357 - return 0;
3358 + err = 0;
3359 +out_put_old:
3360 + /* Drop ref obtained in this function */
3361 + put_page(oldpage);
3362 + return err;
3363
3364 out_fallback_unlock:
3365 unlock_page(newpage);
3366 @@ -929,10 +935,10 @@ out_fallback:
3367 cs->offset = buf->offset;
3368
3369 err = lock_request(cs->req);
3370 - if (err)
3371 - return err;
3372 + if (!err)
3373 + err = 1;
3374
3375 - return 1;
3376 + goto out_put_old;
3377 }
3378
3379 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
3380 @@ -944,14 +950,16 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
3381 if (cs->nr_segs == cs->pipe->buffers)
3382 return -EIO;
3383
3384 + get_page(page);
3385 err = unlock_request(cs->req);
3386 - if (err)
3387 + if (err) {
3388 + put_page(page);
3389 return err;
3390 + }
3391
3392 fuse_copy_finish(cs);
3393
3394 buf = cs->pipebufs;
3395 - get_page(page);
3396 buf->page = page;
3397 buf->offset = offset;
3398 buf->len = count;
3399 diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
3400 index bb5ddaabc218b..0e6fa91f4c8f2 100644
3401 --- a/fs/gfs2/ops_fstype.c
3402 +++ b/fs/gfs2/ops_fstype.c
3403 @@ -160,15 +160,19 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
3404 return -EINVAL;
3405 }
3406
3407 - /* If format numbers match exactly, we're done. */
3408 -
3409 - if (sb->sb_fs_format == GFS2_FORMAT_FS &&
3410 - sb->sb_multihost_format == GFS2_FORMAT_MULTI)
3411 - return 0;
3412 + if (sb->sb_fs_format != GFS2_FORMAT_FS ||
3413 + sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
3414 + fs_warn(sdp, "Unknown on-disk format, unable to mount\n");
3415 + return -EINVAL;
3416 + }
3417
3418 - fs_warn(sdp, "Unknown on-disk format, unable to mount\n");
3419 + if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE ||
3420 + (sb->sb_bsize & (sb->sb_bsize - 1))) {
3421 + pr_warn("Invalid superblock size\n");
3422 + return -EINVAL;
3423 + }
3424
3425 - return -EINVAL;
3426 + return 0;
3427 }
3428
3429 static void end_bio_io_page(struct bio *bio)
3430 diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
3431 index e49d831c4e853..4f539473862a7 100644
3432 --- a/fs/nfs/namespace.c
3433 +++ b/fs/nfs/namespace.c
3434 @@ -30,9 +30,9 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
3435 /*
3436 * nfs_path - reconstruct the path given an arbitrary dentry
3437 * @base - used to return pointer to the end of devname part of path
3438 - * @dentry - pointer to dentry
3439 + * @dentry_in - pointer to dentry
3440 * @buffer - result buffer
3441 - * @buflen - length of buffer
3442 + * @buflen_in - length of buffer
3443 * @flags - options (see below)
3444 *
3445 * Helper function for constructing the server pathname
3446 @@ -47,15 +47,19 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
3447 * the original device (export) name
3448 * (if unset, the original name is returned verbatim)
3449 */
3450 -char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen,
3451 - unsigned flags)
3452 +char *nfs_path(char **p, struct dentry *dentry_in, char *buffer,
3453 + ssize_t buflen_in, unsigned flags)
3454 {
3455 char *end;
3456 int namelen;
3457 unsigned seq;
3458 const char *base;
3459 + struct dentry *dentry;
3460 + ssize_t buflen;
3461
3462 rename_retry:
3463 + buflen = buflen_in;
3464 + dentry = dentry_in;
3465 end = buffer+buflen;
3466 *--end = '\0';
3467 buflen--;
3468 diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
3469 index 69e287e207327..8223e43309810 100644
3470 --- a/fs/ubifs/debug.c
3471 +++ b/fs/ubifs/debug.c
3472 @@ -1125,6 +1125,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir)
3473 err = PTR_ERR(dent);
3474 if (err == -ENOENT)
3475 break;
3476 + kfree(pdent);
3477 return err;
3478 }
3479
3480 diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
3481 index d812f84252d5b..3ce400158a0a8 100644
3482 --- a/fs/xfs/xfs_rtalloc.c
3483 +++ b/fs/xfs/xfs_rtalloc.c
3484 @@ -1014,10 +1014,13 @@ xfs_growfs_rt(
3485 xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
3486 xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
3487 /*
3488 - * Update the bitmap inode's size.
3489 + * Update the bitmap inode's size ondisk and incore. We need
3490 + * to update the incore size so that inode inactivation won't
3491 + * punch what it thinks are "posteof" blocks.
3492 */
3493 mp->m_rbmip->i_d.di_size =
3494 nsbp->sb_rbmblocks * nsbp->sb_blocksize;
3495 + i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size);
3496 xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
3497 /*
3498 * Get the summary inode into the transaction.
3499 @@ -1025,9 +1028,12 @@ xfs_growfs_rt(
3500 xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL);
3501 xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL);
3502 /*
3503 - * Update the summary inode's size.
3504 + * Update the summary inode's size. We need to update the
3505 + * incore size so that inode inactivation won't punch what it
3506 + * thinks are "posteof" blocks.
3507 */
3508 mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
3509 + i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size);
3510 xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE);
3511 /*
3512 * Copy summary data from old to new sizes.
3513 diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h
3514 index f6dfc2950f764..3b1f17dbf92d9 100644
3515 --- a/include/linux/fscrypto.h
3516 +++ b/include/linux/fscrypto.h
3517 @@ -249,8 +249,8 @@ extern void fscrypt_restore_control_page(struct page *);
3518 extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t,
3519 unsigned int);
3520 /* policy.c */
3521 -extern int fscrypt_process_policy(struct file *, const struct fscrypt_policy *);
3522 -extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *);
3523 +extern int fscrypt_ioctl_set_policy(struct file *, const void __user *);
3524 +extern int fscrypt_ioctl_get_policy(struct file *, void __user *);
3525 extern int fscrypt_has_permitted_context(struct inode *, struct inode *);
3526 extern int fscrypt_inherit_context(struct inode *, struct inode *,
3527 void *, bool);
3528 @@ -318,14 +318,14 @@ static inline int fscrypt_notsupp_zeroout_range(struct inode *i, pgoff_t p,
3529 }
3530
3531 /* policy.c */
3532 -static inline int fscrypt_notsupp_process_policy(struct file *f,
3533 - const struct fscrypt_policy *p)
3534 +static inline int fscrypt_notsupp_ioctl_set_policy(struct file *f,
3535 + const void __user *arg)
3536 {
3537 return -EOPNOTSUPP;
3538 }
3539
3540 -static inline int fscrypt_notsupp_get_policy(struct inode *i,
3541 - struct fscrypt_policy *p)
3542 +static inline int fscrypt_notsupp_ioctl_get_policy(struct file *f,
3543 + void __user *arg)
3544 {
3545 return -EOPNOTSUPP;
3546 }
3547 diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h
3548 index 394a8405dd74d..e0521a1d93250 100644
3549 --- a/include/linux/hil_mlc.h
3550 +++ b/include/linux/hil_mlc.h
3551 @@ -103,7 +103,7 @@ struct hilse_node {
3552
3553 /* Methods for back-end drivers, e.g. hp_sdc_mlc */
3554 typedef int (hil_mlc_cts) (hil_mlc *mlc);
3555 -typedef void (hil_mlc_out) (hil_mlc *mlc);
3556 +typedef int (hil_mlc_out) (hil_mlc *mlc);
3557 typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout);
3558
3559 struct hil_mlc_devinfo {
3560 diff --git a/include/linux/mtd/pfow.h b/include/linux/mtd/pfow.h
3561 index 42ff7ff09bf59..09404fb36b345 100644
3562 --- a/include/linux/mtd/pfow.h
3563 +++ b/include/linux/mtd/pfow.h
3564 @@ -127,7 +127,7 @@ static inline void print_drs_error(unsigned dsr)
3565
3566 if (!(dsr & DSR_AVAILABLE))
3567 printk(KERN_NOTICE"DSR.15: (0) Device not Available\n");
3568 - if (prog_status & 0x03)
3569 + if ((prog_status & 0x03) == 0x03)
3570 printk(KERN_NOTICE"DSR.9,8: (11) Attempt to program invalid "
3571 "half with 41h command\n");
3572 else if (prog_status & 0x02)
3573 diff --git a/init/Kconfig b/init/Kconfig
3574 index b331feeabda42..0a615bdc203a4 100644
3575 --- a/init/Kconfig
3576 +++ b/init/Kconfig
3577 @@ -822,7 +822,8 @@ config IKCONFIG_PROC
3578
3579 config LOG_BUF_SHIFT
3580 int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
3581 - range 12 25
3582 + range 12 25 if !H8300
3583 + range 12 19 if H8300
3584 default 17
3585 depends on PRINTK
3586 help
3587 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
3588 index 321ccdbb73649..bc791cec58e63 100644
3589 --- a/kernel/debug/debug_core.c
3590 +++ b/kernel/debug/debug_core.c
3591 @@ -94,14 +94,6 @@ int dbg_switch_cpu;
3592 /* Use kdb or gdbserver mode */
3593 int dbg_kdb_mode = 1;
3594
3595 -static int __init opt_kgdb_con(char *str)
3596 -{
3597 - kgdb_use_con = 1;
3598 - return 0;
3599 -}
3600 -
3601 -early_param("kgdbcon", opt_kgdb_con);
3602 -
3603 module_param(kgdb_use_con, int, 0644);
3604 module_param(kgdbreboot, int, 0644);
3605
3606 @@ -811,6 +803,20 @@ static struct console kgdbcons = {
3607 .index = -1,
3608 };
3609
3610 +static int __init opt_kgdb_con(char *str)
3611 +{
3612 + kgdb_use_con = 1;
3613 +
3614 + if (kgdb_io_module_registered && !kgdb_con_registered) {
3615 + register_console(&kgdbcons);
3616 + kgdb_con_registered = 1;
3617 + }
3618 +
3619 + return 0;
3620 +}
3621 +
3622 +early_param("kgdbcon", opt_kgdb_con);
3623 +
3624 #ifdef CONFIG_MAGIC_SYSRQ
3625 static void sysrq_handle_dbg(int key)
3626 {
3627 diff --git a/kernel/fork.c b/kernel/fork.c
3628 index 288504431a531..b64efec4a6e6e 100644
3629 --- a/kernel/fork.c
3630 +++ b/kernel/fork.c
3631 @@ -1734,14 +1734,9 @@ static __latent_entropy struct task_struct *copy_process(
3632 /* ok, now we should be set up.. */
3633 p->pid = pid_nr(pid);
3634 if (clone_flags & CLONE_THREAD) {
3635 - p->exit_signal = -1;
3636 p->group_leader = current->group_leader;
3637 p->tgid = current->tgid;
3638 } else {
3639 - if (clone_flags & CLONE_PARENT)
3640 - p->exit_signal = current->group_leader->exit_signal;
3641 - else
3642 - p->exit_signal = (clone_flags & CSIGNAL);
3643 p->group_leader = p;
3644 p->tgid = p->pid;
3645 }
3646 @@ -1786,9 +1781,14 @@ static __latent_entropy struct task_struct *copy_process(
3647 if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
3648 p->real_parent = current->real_parent;
3649 p->parent_exec_id = current->parent_exec_id;
3650 + if (clone_flags & CLONE_THREAD)
3651 + p->exit_signal = -1;
3652 + else
3653 + p->exit_signal = current->group_leader->exit_signal;
3654 } else {
3655 p->real_parent = current;
3656 p->parent_exec_id = current->self_exec_id;
3657 + p->exit_signal = (clone_flags & CSIGNAL);
3658 }
3659
3660 spin_lock(&current->sighand->siglock);
3661 diff --git a/kernel/kthread.c b/kernel/kthread.c
3662 index fbc230e419690..60f54c5a07a46 100644
3663 --- a/kernel/kthread.c
3664 +++ b/kernel/kthread.c
3665 @@ -828,7 +828,8 @@ void kthread_delayed_work_timer_fn(unsigned long __data)
3666 /* Move the work from worker->delayed_work_list. */
3667 WARN_ON_ONCE(list_empty(&work->node));
3668 list_del_init(&work->node);
3669 - kthread_insert_work(worker, work, &worker->work_list);
3670 + if (!work->canceling)
3671 + kthread_insert_work(worker, work, &worker->work_list);
3672
3673 spin_unlock(&worker->lock);
3674 }
3675 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
3676 index 2cfe11e1190ba..fb2aa2430edcc 100644
3677 --- a/kernel/trace/ring_buffer.c
3678 +++ b/kernel/trace/ring_buffer.c
3679 @@ -1650,18 +1650,18 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
3680 {
3681 struct ring_buffer_per_cpu *cpu_buffer;
3682 unsigned long nr_pages;
3683 - int cpu, err = 0;
3684 + int cpu, err;
3685
3686 /*
3687 * Always succeed at resizing a non-existent buffer:
3688 */
3689 if (!buffer)
3690 - return size;
3691 + return 0;
3692
3693 /* Make sure the requested buffer exists */
3694 if (cpu_id != RING_BUFFER_ALL_CPUS &&
3695 !cpumask_test_cpu(cpu_id, buffer->cpumask))
3696 - return size;
3697 + return 0;
3698
3699 nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
3700
3701 @@ -1801,7 +1801,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
3702 }
3703
3704 mutex_unlock(&buffer->mutex);
3705 - return size;
3706 + return 0;
3707
3708 out_err:
3709 for_each_buffer_cpu(buffer, cpu) {
3710 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
3711 index 2388fb50d1885..2fdebbb30839e 100644
3712 --- a/kernel/trace/trace.c
3713 +++ b/kernel/trace/trace.c
3714 @@ -2382,7 +2382,7 @@ static char *get_trace_buf(void)
3715
3716 /* Interrupts must see nesting incremented before we use the buffer */
3717 barrier();
3718 - return &buffer->buffer[buffer->nesting][0];
3719 + return &buffer->buffer[buffer->nesting - 1][0];
3720 }
3721
3722 static void put_trace_buf(void)
3723 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
3724 index 476c6c4204da1..950c0e12a391a 100644
3725 --- a/kernel/trace/trace.h
3726 +++ b/kernel/trace/trace.h
3727 @@ -491,6 +491,12 @@ enum {
3728 * can only be modified by current, we can reuse trace_recursion.
3729 */
3730 TRACE_IRQ_BIT,
3731 +
3732 + /*
3733 + * When transitioning between context, the preempt_count() may
3734 + * not be correct. Allow for a single recursion to cover this case.
3735 + */
3736 + TRACE_TRANSITION_BIT,
3737 };
3738
3739 #define trace_recursion_set(bit) do { (current)->trace_recursion |= (1<<(bit)); } while (0)
3740 @@ -535,14 +541,27 @@ static __always_inline int trace_test_and_set_recursion(int start, int max)
3741 return 0;
3742
3743 bit = trace_get_context_bit() + start;
3744 - if (unlikely(val & (1 << bit)))
3745 - return -1;
3746 + if (unlikely(val & (1 << bit))) {
3747 + /*
3748 + * It could be that preempt_count has not been updated during
3749 + * a switch between contexts. Allow for a single recursion.
3750 + */
3751 + bit = TRACE_TRANSITION_BIT;
3752 + if (trace_recursion_test(bit))
3753 + return -1;
3754 + trace_recursion_set(bit);
3755 + barrier();
3756 + return bit + 1;
3757 + }
3758 +
3759 + /* Normal check passed, clear the transition to allow it again */
3760 + trace_recursion_clear(TRACE_TRANSITION_BIT);
3761
3762 val |= 1 << bit;
3763 current->trace_recursion = val;
3764 barrier();
3765
3766 - return bit;
3767 + return bit + 1;
3768 }
3769
3770 static __always_inline void trace_clear_recursion(int bit)
3771 @@ -552,6 +571,7 @@ static __always_inline void trace_clear_recursion(int bit)
3772 if (!bit)
3773 return;
3774
3775 + bit--;
3776 bit = 1 << bit;
3777 val &= ~bit;
3778
3779 diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
3780 index ca70d11b8aa78..f444f57f1338b 100644
3781 --- a/kernel/trace/trace_selftest.c
3782 +++ b/kernel/trace/trace_selftest.c
3783 @@ -490,8 +490,13 @@ trace_selftest_function_recursion(void)
3784 unregister_ftrace_function(&test_rec_probe);
3785
3786 ret = -1;
3787 - if (trace_selftest_recursion_cnt != 1) {
3788 - pr_cont("*callback not called once (%d)* ",
3789 + /*
3790 + * Recursion allows for transitions between context,
3791 + * and may call the callback twice.
3792 + */
3793 + if (trace_selftest_recursion_cnt != 1 &&
3794 + trace_selftest_recursion_cnt != 2) {
3795 + pr_cont("*callback not called once (or twice) (%d)* ",
3796 trace_selftest_recursion_cnt);
3797 goto out;
3798 }
3799 diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c
3800 index 87e904f550c15..0ea39bfdc3cfa 100644
3801 --- a/lib/fonts/font_10x18.c
3802 +++ b/lib/fonts/font_10x18.c
3803 @@ -7,7 +7,7 @@
3804
3805 #define FONTDATAMAX 9216
3806
3807 -static struct font_data fontdata_10x18 = {
3808 +static const struct font_data fontdata_10x18 = {
3809 { 0, 0, FONTDATAMAX, 0 }, {
3810 /* 0 0x00 '^@' */
3811 0x00, 0x00, /* 0000000000 */
3812 diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c
3813 index 896ffa987c97b..ec243d7d2e0e3 100644
3814 --- a/lib/fonts/font_6x10.c
3815 +++ b/lib/fonts/font_6x10.c
3816 @@ -2,7 +2,7 @@
3817
3818 #define FONTDATAMAX 2560
3819
3820 -static struct font_data fontdata_6x10 = {
3821 +static const struct font_data fontdata_6x10 = {
3822 { 0, 0, FONTDATAMAX, 0 }, {
3823 /* 0 0x00 '^@' */
3824 0x00, /* 00000000 */
3825 diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c
3826 index eb46a59307d2e..0010e213fbe22 100644
3827 --- a/lib/fonts/font_6x11.c
3828 +++ b/lib/fonts/font_6x11.c
3829 @@ -8,7 +8,7 @@
3830
3831 #define FONTDATAMAX (11*256)
3832
3833 -static struct font_data fontdata_6x11 = {
3834 +static const struct font_data fontdata_6x11 = {
3835 { 0, 0, FONTDATAMAX, 0 }, {
3836 /* 0 0x00 '^@' */
3837 0x00, /* 00000000 */
3838 diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c
3839 index c88b3bba001bd..2900b59325e5f 100644
3840 --- a/lib/fonts/font_7x14.c
3841 +++ b/lib/fonts/font_7x14.c
3842 @@ -7,7 +7,7 @@
3843
3844 #define FONTDATAMAX 3584
3845
3846 -static struct font_data fontdata_7x14 = {
3847 +static const struct font_data fontdata_7x14 = {
3848 { 0, 0, FONTDATAMAX, 0 }, {
3849 /* 0 0x00 '^@' */
3850 0x00, /* 0000000 */
3851 diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c
3852 index ba53e2643670b..cc3fa17ff94df 100644
3853 --- a/lib/fonts/font_8x16.c
3854 +++ b/lib/fonts/font_8x16.c
3855 @@ -9,7 +9,7 @@
3856
3857 #define FONTDATAMAX 4096
3858
3859 -static struct font_data fontdata_8x16 = {
3860 +static const struct font_data fontdata_8x16 = {
3861 { 0, 0, FONTDATAMAX, 0 }, {
3862 /* 0 0x00 '^@' */
3863 0x00, /* 00000000 */
3864 diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c
3865 index 4d28b81e8237c..1519b7ce88278 100644
3866 --- a/lib/fonts/font_8x8.c
3867 +++ b/lib/fonts/font_8x8.c
3868 @@ -8,7 +8,7 @@
3869
3870 #define FONTDATAMAX 2048
3871
3872 -static struct font_data fontdata_8x8 = {
3873 +static const struct font_data fontdata_8x8 = {
3874 { 0, 0, FONTDATAMAX, 0 }, {
3875 /* 0 0x00 '^@' */
3876 0x00, /* 00000000 */
3877 diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c
3878 index 957398b762d38..c6367ed4c5bcf 100644
3879 --- a/lib/fonts/font_acorn_8x8.c
3880 +++ b/lib/fonts/font_acorn_8x8.c
3881 @@ -4,7 +4,7 @@
3882
3883 #define FONTDATAMAX 2048
3884
3885 -static struct font_data acorndata_8x8 = {
3886 +static const struct font_data acorndata_8x8 = {
3887 { 0, 0, FONTDATAMAX, 0 }, {
3888 /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
3889 /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
3890 diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c
3891 index 1449876c6a270..592774a90917b 100644
3892 --- a/lib/fonts/font_mini_4x6.c
3893 +++ b/lib/fonts/font_mini_4x6.c
3894 @@ -43,7 +43,7 @@ __END__;
3895
3896 #define FONTDATAMAX 1536
3897
3898 -static struct font_data fontdata_mini_4x6 = {
3899 +static const struct font_data fontdata_mini_4x6 = {
3900 { 0, 0, FONTDATAMAX, 0 }, {
3901 /*{*/
3902 /* Char 0: ' ' */
3903 diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c
3904 index 4649314333bb0..6351b759ae702 100644
3905 --- a/lib/fonts/font_pearl_8x8.c
3906 +++ b/lib/fonts/font_pearl_8x8.c
3907 @@ -13,7 +13,7 @@
3908
3909 #define FONTDATAMAX 2048
3910
3911 -static struct font_data fontdata_pearl8x8 = {
3912 +static const struct font_data fontdata_pearl8x8 = {
3913 { 0, 0, FONTDATAMAX, 0 }, {
3914 /* 0 0x00 '^@' */
3915 0x00, /* 00000000 */
3916 diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c
3917 index c6967cdf4207b..057b0bf368a2a 100644
3918 --- a/lib/fonts/font_sun12x22.c
3919 +++ b/lib/fonts/font_sun12x22.c
3920 @@ -2,7 +2,7 @@
3921
3922 #define FONTDATAMAX 11264
3923
3924 -static struct font_data fontdata_sun12x22 = {
3925 +static const struct font_data fontdata_sun12x22 = {
3926 { 0, 0, FONTDATAMAX, 0 }, {
3927 /* 0 0x00 '^@' */
3928 0x00, 0x00, /* 000000000000 */
3929 diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c
3930 index 7d979e5788999..84db7275e0534 100644
3931 --- a/lib/fonts/font_sun8x16.c
3932 +++ b/lib/fonts/font_sun8x16.c
3933 @@ -2,7 +2,7 @@
3934
3935 #define FONTDATAMAX 4096
3936
3937 -static struct font_data fontdata_sun8x16 = {
3938 +static const struct font_data fontdata_sun8x16 = {
3939 { 0, 0, FONTDATAMAX, 0 }, {
3940 /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
3941 /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
3942 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
3943 index bad27b0ec65d6..33b317a25a2d5 100644
3944 --- a/net/9p/trans_fd.c
3945 +++ b/net/9p/trans_fd.c
3946 @@ -1013,7 +1013,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
3947
3948 csocket = NULL;
3949
3950 - if (addr == NULL)
3951 + if (!addr || !strlen(addr))
3952 return -EINVAL;
3953
3954 if (strlen(addr) >= UNIX_PATH_MAX) {
3955 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
3956 index 7e27cabb04ef9..776d5ab24af6b 100644
3957 --- a/net/ceph/messenger.c
3958 +++ b/net/ceph/messenger.c
3959 @@ -2983,6 +2983,11 @@ static void con_fault(struct ceph_connection *con)
3960 ceph_msg_put(con->in_msg);
3961 con->in_msg = NULL;
3962 }
3963 + if (con->out_msg) {
3964 + BUG_ON(con->out_msg->con != con);
3965 + ceph_msg_put(con->out_msg);
3966 + con->out_msg = NULL;
3967 + }
3968
3969 /* Requeue anything that hasn't been acked */
3970 list_splice_init(&con->out_sent, &con->out_queue);
3971 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
3972 index de18a463ac964..eef2f732fbe3a 100644
3973 --- a/net/sunrpc/clnt.c
3974 +++ b/net/sunrpc/clnt.c
3975 @@ -1936,6 +1936,14 @@ call_connect_status(struct rpc_task *task)
3976 task->tk_status = 0;
3977 switch (status) {
3978 case -ECONNREFUSED:
3979 + /* A positive refusal suggests a rebind is needed. */
3980 + if (RPC_IS_SOFTCONN(task))
3981 + break;
3982 + if (clnt->cl_autobind) {
3983 + rpc_force_rebind(clnt);
3984 + task->tk_action = call_bind;
3985 + return;
3986 + }
3987 case -ECONNRESET:
3988 case -ECONNABORTED:
3989 case -ENETUNREACH:
3990 diff --git a/net/tipc/core.c b/net/tipc/core.c
3991 index 799900c0f2c9f..c5d52c9a1acba 100644
3992 --- a/net/tipc/core.c
3993 +++ b/net/tipc/core.c
3994 @@ -89,6 +89,11 @@ out_sk_rht:
3995 static void __net_exit tipc_exit_net(struct net *net)
3996 {
3997 tipc_net_stop(net);
3998 +
3999 + /* Make sure the tipc_net_finalize_work stopped
4000 + * before releasing the resources.
4001 + */
4002 + flush_scheduled_work();
4003 tipc_bcast_stop(net);
4004 tipc_nametbl_stop(net);
4005 tipc_sk_rht_destroy(net);
4006 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
4007 index 41290fe810220..aeb4554dfddac 100644
4008 --- a/net/tipc/msg.c
4009 +++ b/net/tipc/msg.c
4010 @@ -140,12 +140,11 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
4011 if (fragid == FIRST_FRAGMENT) {
4012 if (unlikely(head))
4013 goto err;
4014 - if (skb_cloned(frag))
4015 - frag = skb_copy(frag, GFP_ATOMIC);
4016 + *buf = NULL;
4017 + frag = skb_unshare(frag, GFP_ATOMIC);
4018 if (unlikely(!frag))
4019 goto err;
4020 head = *headbuf = frag;
4021 - *buf = NULL;
4022 TIPC_SKB_CB(head)->tail = NULL;
4023 if (skb_is_nonlinear(head)) {
4024 skb_walk_frags(head, tail) {
4025 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
4026 index d6473b8d9a81a..3a2543b9701a9 100644
4027 --- a/net/vmw_vsock/af_vsock.c
4028 +++ b/net/vmw_vsock/af_vsock.c
4029 @@ -651,7 +651,7 @@ struct sock *__vsock_create(struct net *net,
4030 vsk->owner = get_cred(psk->owner);
4031 vsk->connect_timeout = psk->connect_timeout;
4032 } else {
4033 - vsk->trusted = capable(CAP_NET_ADMIN);
4034 + vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN);
4035 vsk->owner = get_current_cred();
4036 vsk->connect_timeout = VSOCK_DEFAULT_CONNECT_TIMEOUT;
4037 }
4038 diff --git a/scripts/setlocalversion b/scripts/setlocalversion
4039 index aa28c3f298093..0c8741b795d0c 100755
4040 --- a/scripts/setlocalversion
4041 +++ b/scripts/setlocalversion
4042 @@ -44,7 +44,7 @@ scm_version()
4043
4044 # Check for git and a git repo.
4045 if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
4046 - head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
4047 + head=$(git rev-parse --verify HEAD 2>/dev/null); then
4048
4049 # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
4050 # it, because this version is defined in the top level Makefile.
4051 @@ -58,11 +58,22 @@ scm_version()
4052 fi
4053 # If we are past a tagged commit (like
4054 # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
4055 - if atag="`git describe 2>/dev/null`"; then
4056 - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
4057 -
4058 - # If we don't have a tag at all we print -g{commitish}.
4059 + #
4060 + # Ensure the abbreviated sha1 has exactly 12
4061 + # hex characters, to make the output
4062 + # independent of git version, local
4063 + # core.abbrev settings and/or total number of
4064 + # objects in the current repository - passing
4065 + # --abbrev=12 ensures a minimum of 12, and the
4066 + # awk substr() then picks the 'g' and first 12
4067 + # hex chars.
4068 + if atag="$(git describe --abbrev=12 2>/dev/null)"; then
4069 + echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}'
4070 +
4071 + # If we don't have a tag at all we print -g{commitish},
4072 + # again using exactly 12 hex chars.
4073 else
4074 + head="$(echo $head | cut -c1-12)"
4075 printf '%s%s' -g $head
4076 fi
4077 fi
4078 diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
4079 index ec7bea45c852c..95d02e25a3133 100644
4080 --- a/sound/usb/pcm.c
4081 +++ b/sound/usb/pcm.c
4082 @@ -332,6 +332,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
4083 switch (subs->stream->chip->usb_id) {
4084 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
4085 case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */
4086 + case USB_ID(0x22f0, 0x0006): /* Allen&Heath Qu-16 */
4087 ep = 0x81;
4088 iface = usb_ifnum_to_if(dev, 3);
4089