1 |
commit: f3c55170f5ab7f92a5cef3ea0b6c5f9f910d1145 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Oct 18 11:51:15 2017 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Oct 18 11:51:15 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=f3c55170 |
7 |
|
8 |
Linux patches 4.1.44 and 4.1.45 |
9 |
|
10 |
0000_README | 8 + |
11 |
1043_linux-4.1.44.patch | 4971 +++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
1044_linux-4.1.45.patch | 4031 ++++++++++++++++++++++++++++++++++++++ |
13 |
3 files changed, 9010 insertions(+) |
14 |
|
15 |
diff --git a/0000_README b/0000_README |
16 |
index 959795e..43ea8eb 100644 |
17 |
--- a/0000_README |
18 |
+++ b/0000_README |
19 |
@@ -215,6 +215,14 @@ Patch: 1042_linux-4.1.43.patch |
20 |
From: http://www.kernel.org |
21 |
Desc: Linux 4.1.43 |
22 |
|
23 |
+Patch: 1043_linux-4.1.44.patch |
24 |
+From: http://www.kernel.org |
25 |
+Desc: Linux 4.1.44 |
26 |
+ |
27 |
+Patch: 1044_linux-4.1.45.patch |
28 |
+From: http://www.kernel.org |
29 |
+Desc: Linux 4.1.45 |
30 |
+ |
31 |
Patch: 1500_XATTR_USER_PREFIX.patch |
32 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
33 |
Desc: Support for namespace user.pax.* on tmpfs. |
34 |
|
35 |
diff --git a/1043_linux-4.1.44.patch b/1043_linux-4.1.44.patch |
36 |
new file mode 100644 |
37 |
index 0000000..962183f |
38 |
--- /dev/null |
39 |
+++ b/1043_linux-4.1.44.patch |
40 |
@@ -0,0 +1,4971 @@ |
41 |
+diff --git a/Makefile b/Makefile |
42 |
+index 50d0a93fa343..9c7aa08c70b7 100644 |
43 |
+--- a/Makefile |
44 |
++++ b/Makefile |
45 |
+@@ -1,6 +1,6 @@ |
46 |
+ VERSION = 4 |
47 |
+ PATCHLEVEL = 1 |
48 |
+-SUBLEVEL = 43 |
49 |
++SUBLEVEL = 44 |
50 |
+ EXTRAVERSION = |
51 |
+ NAME = Series 4800 |
52 |
+ |
53 |
+diff --git a/arch/arm/boot/dts/armada-388-gp.dts b/arch/arm/boot/dts/armada-388-gp.dts |
54 |
+index 757ac079e7f2..bcf4f1b6b2bc 100644 |
55 |
+--- a/arch/arm/boot/dts/armada-388-gp.dts |
56 |
++++ b/arch/arm/boot/dts/armada-388-gp.dts |
57 |
+@@ -91,7 +91,7 @@ |
58 |
+ pinctrl-names = "default"; |
59 |
+ pinctrl-0 = <&pca0_pins>; |
60 |
+ interrupt-parent = <&gpio0>; |
61 |
+- interrupts = <18 IRQ_TYPE_EDGE_FALLING>; |
62 |
++ interrupts = <18 IRQ_TYPE_LEVEL_LOW>; |
63 |
+ gpio-controller; |
64 |
+ #gpio-cells = <2>; |
65 |
+ interrupt-controller; |
66 |
+@@ -103,7 +103,7 @@ |
67 |
+ compatible = "nxp,pca9555"; |
68 |
+ pinctrl-names = "default"; |
69 |
+ interrupt-parent = <&gpio0>; |
70 |
+- interrupts = <18 IRQ_TYPE_EDGE_FALLING>; |
71 |
++ interrupts = <18 IRQ_TYPE_LEVEL_LOW>; |
72 |
+ gpio-controller; |
73 |
+ #gpio-cells = <2>; |
74 |
+ interrupt-controller; |
75 |
+diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts |
76 |
+index 5f5e0f3d5b64..27cd4abfc74d 100644 |
77 |
+--- a/arch/arm/boot/dts/omap3-n900.dts |
78 |
++++ b/arch/arm/boot/dts/omap3-n900.dts |
79 |
+@@ -697,6 +697,8 @@ |
80 |
+ vmmc_aux-supply = <&vsim>; |
81 |
+ bus-width = <8>; |
82 |
+ non-removable; |
83 |
++ no-sdio; |
84 |
++ no-sd; |
85 |
+ }; |
86 |
+ |
87 |
+ &mmc3 { |
88 |
+diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig |
89 |
+index f3142369f594..01116ee1284b 100644 |
90 |
+--- a/arch/arm/configs/s3c2410_defconfig |
91 |
++++ b/arch/arm/configs/s3c2410_defconfig |
92 |
+@@ -87,9 +87,9 @@ CONFIG_IPV6_TUNNEL=m |
93 |
+ CONFIG_NETFILTER=y |
94 |
+ CONFIG_NF_CONNTRACK=m |
95 |
+ CONFIG_NF_CONNTRACK_EVENTS=y |
96 |
+-CONFIG_NF_CT_PROTO_DCCP=m |
97 |
+-CONFIG_NF_CT_PROTO_SCTP=m |
98 |
+-CONFIG_NF_CT_PROTO_UDPLITE=m |
99 |
++CONFIG_NF_CT_PROTO_DCCP=y |
100 |
++CONFIG_NF_CT_PROTO_SCTP=y |
101 |
++CONFIG_NF_CT_PROTO_UDPLITE=y |
102 |
+ CONFIG_NF_CONNTRACK_AMANDA=m |
103 |
+ CONFIG_NF_CONNTRACK_FTP=m |
104 |
+ CONFIG_NF_CONNTRACK_H323=m |
105 |
+diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h |
106 |
+index bfe2a2f5a644..22b73112b75f 100644 |
107 |
+--- a/arch/arm/include/asm/ftrace.h |
108 |
++++ b/arch/arm/include/asm/ftrace.h |
109 |
+@@ -54,6 +54,24 @@ static inline void *return_address(unsigned int level) |
110 |
+ |
111 |
+ #define ftrace_return_address(n) return_address(n) |
112 |
+ |
113 |
++#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME |
114 |
++ |
115 |
++static inline bool arch_syscall_match_sym_name(const char *sym, |
116 |
++ const char *name) |
117 |
++{ |
118 |
++ if (!strcmp(sym, "sys_mmap2")) |
119 |
++ sym = "sys_mmap_pgoff"; |
120 |
++ else if (!strcmp(sym, "sys_statfs64_wrapper")) |
121 |
++ sym = "sys_statfs64"; |
122 |
++ else if (!strcmp(sym, "sys_fstatfs64_wrapper")) |
123 |
++ sym = "sys_fstatfs64"; |
124 |
++ else if (!strcmp(sym, "sys_arm_fadvise64_64")) |
125 |
++ sym = "sys_fadvise64_64"; |
126 |
++ |
127 |
++ /* Ignore case since sym may start with "SyS" instead of "sys" */ |
128 |
++ return !strcasecmp(sym, name); |
129 |
++} |
130 |
++ |
131 |
+ #endif /* ifndef __ASSEMBLY__ */ |
132 |
+ |
133 |
+ #endif /* _ASM_ARM_FTRACE */ |
134 |
+diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c |
135 |
+index 4e15eed87074..3ca19cdb0eac 100644 |
136 |
+--- a/arch/arm/kvm/mmu.c |
137 |
++++ b/arch/arm/kvm/mmu.c |
138 |
+@@ -1611,12 +1611,16 @@ static int kvm_test_age_hva_handler(struct kvm *kvm, gpa_t gpa, void *data) |
139 |
+ |
140 |
+ int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end) |
141 |
+ { |
142 |
++ if (!kvm->arch.pgd) |
143 |
++ return 0; |
144 |
+ trace_kvm_age_hva(start, end); |
145 |
+ return handle_hva_to_gpa(kvm, start, end, kvm_age_hva_handler, NULL); |
146 |
+ } |
147 |
+ |
148 |
+ int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) |
149 |
+ { |
150 |
++ if (!kvm->arch.pgd) |
151 |
++ return 0; |
152 |
+ trace_kvm_test_age_hva(hva); |
153 |
+ return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, NULL); |
154 |
+ } |
155 |
+diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts |
156 |
+index 0a3f40ecd06d..96235d2b135d 100644 |
157 |
+--- a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts |
158 |
++++ b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts |
159 |
+@@ -26,7 +26,7 @@ |
160 |
+ stdout-path = "serial0:115200n8"; |
161 |
+ }; |
162 |
+ |
163 |
+- memory { |
164 |
++ memory@0 { |
165 |
+ device_type = "memory"; |
166 |
+ reg = <0x0 0x0 0x40000000>; |
167 |
+ }; |
168 |
+diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi |
169 |
+index 11e0b00045cf..0cb2cdfd7309 100644 |
170 |
+--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi |
171 |
++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi |
172 |
+@@ -71,7 +71,7 @@ |
173 |
+ <1 10 0xf01>; |
174 |
+ }; |
175 |
+ |
176 |
+- amba_apu { |
177 |
++ amba_apu: amba_apu@0 { |
178 |
+ compatible = "simple-bus"; |
179 |
+ #address-cells = <2>; |
180 |
+ #size-cells = <1>; |
181 |
+@@ -251,7 +251,7 @@ |
182 |
+ }; |
183 |
+ |
184 |
+ i2c0: i2c@ff020000 { |
185 |
+- compatible = "cdns,i2c-r1p10"; |
186 |
++ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; |
187 |
+ status = "disabled"; |
188 |
+ interrupt-parent = <&gic>; |
189 |
+ interrupts = <0 17 4>; |
190 |
+@@ -262,7 +262,7 @@ |
191 |
+ }; |
192 |
+ |
193 |
+ i2c1: i2c@ff030000 { |
194 |
+- compatible = "cdns,i2c-r1p10"; |
195 |
++ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; |
196 |
+ status = "disabled"; |
197 |
+ interrupt-parent = <&gic>; |
198 |
+ interrupts = <0 18 4>; |
199 |
+diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c |
200 |
+index fa5efaa5c3ac..16523fbd9671 100644 |
201 |
+--- a/arch/arm64/mm/fault.c |
202 |
++++ b/arch/arm64/mm/fault.c |
203 |
+@@ -62,21 +62,21 @@ void show_pte(struct mm_struct *mm, unsigned long addr) |
204 |
+ break; |
205 |
+ |
206 |
+ pud = pud_offset(pgd, addr); |
207 |
+- printk(", *pud=%016llx", pud_val(*pud)); |
208 |
++ pr_cont(", *pud=%016llx", pud_val(*pud)); |
209 |
+ if (pud_none(*pud) || pud_bad(*pud)) |
210 |
+ break; |
211 |
+ |
212 |
+ pmd = pmd_offset(pud, addr); |
213 |
+- printk(", *pmd=%016llx", pmd_val(*pmd)); |
214 |
++ pr_cont(", *pmd=%016llx", pmd_val(*pmd)); |
215 |
+ if (pmd_none(*pmd) || pmd_bad(*pmd)) |
216 |
+ break; |
217 |
+ |
218 |
+ pte = pte_offset_map(pmd, addr); |
219 |
+- printk(", *pte=%016llx", pte_val(*pte)); |
220 |
++ pr_cont(", *pte=%016llx", pte_val(*pte)); |
221 |
+ pte_unmap(pte); |
222 |
+ } while(0); |
223 |
+ |
224 |
+- printk("\n"); |
225 |
++ pr_cont("\n"); |
226 |
+ } |
227 |
+ |
228 |
+ /* |
229 |
+diff --git a/arch/mips/include/asm/branch.h b/arch/mips/include/asm/branch.h |
230 |
+index de781cf54bc7..da80878f2c0d 100644 |
231 |
+--- a/arch/mips/include/asm/branch.h |
232 |
++++ b/arch/mips/include/asm/branch.h |
233 |
+@@ -74,10 +74,7 @@ static inline int compute_return_epc(struct pt_regs *regs) |
234 |
+ return __microMIPS_compute_return_epc(regs); |
235 |
+ if (cpu_has_mips16) |
236 |
+ return __MIPS16e_compute_return_epc(regs); |
237 |
+- return regs->cp0_epc; |
238 |
+- } |
239 |
+- |
240 |
+- if (!delay_slot(regs)) { |
241 |
++ } else if (!delay_slot(regs)) { |
242 |
+ regs->cp0_epc += 4; |
243 |
+ return 0; |
244 |
+ } |
245 |
+diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c |
246 |
+index fe376aa705c5..13254da66ce8 100644 |
247 |
+--- a/arch/mips/kernel/branch.c |
248 |
++++ b/arch/mips/kernel/branch.c |
249 |
+@@ -399,7 +399,7 @@ int __MIPS16e_compute_return_epc(struct pt_regs *regs) |
250 |
+ * |
251 |
+ * @regs: Pointer to pt_regs |
252 |
+ * @insn: branch instruction to decode |
253 |
+- * @returns: -EFAULT on error and forces SIGBUS, and on success |
254 |
++ * @returns: -EFAULT on error and forces SIGILL, and on success |
255 |
+ * returns 0 or BRANCH_LIKELY_TAKEN as appropriate after |
256 |
+ * evaluating the branch. |
257 |
+ * |
258 |
+@@ -556,6 +556,7 @@ int __compute_return_epc_for_insn(struct pt_regs *regs, |
259 |
+ /* |
260 |
+ * These are unconditional and in j_format. |
261 |
+ */ |
262 |
++ case jalx_op: |
263 |
+ case jal_op: |
264 |
+ regs->regs[31] = regs->cp0_epc + 8; |
265 |
+ case j_op: |
266 |
+@@ -843,8 +844,9 @@ int __compute_return_epc_for_insn(struct pt_regs *regs, |
267 |
+ return ret; |
268 |
+ |
269 |
+ sigill_dsp: |
270 |
+- printk("%s: DSP branch but not DSP ASE - sending SIGBUS.\n", current->comm); |
271 |
+- force_sig(SIGBUS, current); |
272 |
++ pr_info("%s: DSP branch but not DSP ASE - sending SIGILL.\n", |
273 |
++ current->comm); |
274 |
++ force_sig(SIGILL, current); |
275 |
+ return -EFAULT; |
276 |
+ sigill_r6: |
277 |
+ pr_info("%s: R2 branch but r2-to-r6 emulator is not preset - sending SIGILL.\n", |
278 |
+diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c |
279 |
+index 298b2b773d12..f1fab6ff53e6 100644 |
280 |
+--- a/arch/mips/kernel/proc.c |
281 |
++++ b/arch/mips/kernel/proc.c |
282 |
+@@ -83,7 +83,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) |
283 |
+ } |
284 |
+ |
285 |
+ seq_printf(m, "isa\t\t\t:"); |
286 |
+- if (cpu_has_mips_r1) |
287 |
++ if (cpu_has_mips_1) |
288 |
+ seq_printf(m, " mips1"); |
289 |
+ if (cpu_has_mips_2) |
290 |
+ seq_printf(m, "%s", " mips2"); |
291 |
+diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c |
292 |
+index f7968b5149b0..5c3aa41a162f 100644 |
293 |
+--- a/arch/mips/kernel/ptrace.c |
294 |
++++ b/arch/mips/kernel/ptrace.c |
295 |
+@@ -838,7 +838,7 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs) |
296 |
+ audit_syscall_exit(regs); |
297 |
+ |
298 |
+ if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) |
299 |
+- trace_sys_exit(regs, regs->regs[2]); |
300 |
++ trace_sys_exit(regs, regs_return_value(regs)); |
301 |
+ |
302 |
+ if (test_thread_flag(TIF_SYSCALL_TRACE)) |
303 |
+ tracehook_report_syscall_exit(regs, 0); |
304 |
+diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S |
305 |
+index 6e8de80bb446..d516765ce320 100644 |
306 |
+--- a/arch/mips/kernel/scall32-o32.S |
307 |
++++ b/arch/mips/kernel/scall32-o32.S |
308 |
+@@ -362,7 +362,7 @@ EXPORT(sys_call_table) |
309 |
+ PTR sys_writev |
310 |
+ PTR sys_cacheflush |
311 |
+ PTR sys_cachectl |
312 |
+- PTR sys_sysmips |
313 |
++ PTR __sys_sysmips |
314 |
+ PTR sys_ni_syscall /* 4150 */ |
315 |
+ PTR sys_getsid |
316 |
+ PTR sys_fdatasync |
317 |
+diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S |
318 |
+index a6f6b762c47a..a60edb497da3 100644 |
319 |
+--- a/arch/mips/kernel/scall64-64.S |
320 |
++++ b/arch/mips/kernel/scall64-64.S |
321 |
+@@ -318,7 +318,7 @@ EXPORT(sys_call_table) |
322 |
+ PTR sys_sched_getaffinity |
323 |
+ PTR sys_cacheflush |
324 |
+ PTR sys_cachectl |
325 |
+- PTR sys_sysmips |
326 |
++ PTR __sys_sysmips |
327 |
+ PTR sys_io_setup /* 5200 */ |
328 |
+ PTR sys_io_destroy |
329 |
+ PTR sys_io_getevents |
330 |
+diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S |
331 |
+index 97fa4c7b9a5e..5de53e4b9607 100644 |
332 |
+--- a/arch/mips/kernel/scall64-n32.S |
333 |
++++ b/arch/mips/kernel/scall64-n32.S |
334 |
+@@ -307,7 +307,7 @@ EXPORT(sysn32_call_table) |
335 |
+ PTR compat_sys_sched_getaffinity |
336 |
+ PTR sys_cacheflush |
337 |
+ PTR sys_cachectl |
338 |
+- PTR sys_sysmips |
339 |
++ PTR __sys_sysmips |
340 |
+ PTR compat_sys_io_setup /* 6200 */ |
341 |
+ PTR sys_io_destroy |
342 |
+ PTR compat_sys_io_getevents |
343 |
+diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S |
344 |
+index 80e39776e377..185092b9ecc1 100644 |
345 |
+--- a/arch/mips/kernel/scall64-o32.S |
346 |
++++ b/arch/mips/kernel/scall64-o32.S |
347 |
+@@ -359,7 +359,7 @@ EXPORT(sys32_call_table) |
348 |
+ PTR compat_sys_writev |
349 |
+ PTR sys_cacheflush |
350 |
+ PTR sys_cachectl |
351 |
+- PTR sys_sysmips |
352 |
++ PTR __sys_sysmips |
353 |
+ PTR sys_ni_syscall /* 4150 */ |
354 |
+ PTR sys_getsid |
355 |
+ PTR sys_fdatasync |
356 |
+diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c |
357 |
+index 53a7ef9a8f32..4234b2d726c5 100644 |
358 |
+--- a/arch/mips/kernel/syscall.c |
359 |
++++ b/arch/mips/kernel/syscall.c |
360 |
+@@ -28,6 +28,7 @@ |
361 |
+ #include <linux/elf.h> |
362 |
+ |
363 |
+ #include <asm/asm.h> |
364 |
++#include <asm/asm-eva.h> |
365 |
+ #include <asm/branch.h> |
366 |
+ #include <asm/cachectl.h> |
367 |
+ #include <asm/cacheflush.h> |
368 |
+@@ -138,10 +139,12 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new) |
369 |
+ __asm__ __volatile__ ( |
370 |
+ " .set "MIPS_ISA_ARCH_LEVEL" \n" |
371 |
+ " li %[err], 0 \n" |
372 |
+- "1: ll %[old], (%[addr]) \n" |
373 |
++ "1: \n" |
374 |
++ user_ll("%[old]", "(%[addr])") |
375 |
+ " move %[tmp], %[new] \n" |
376 |
+- "2: sc %[tmp], (%[addr]) \n" |
377 |
+- " bnez %[tmp], 4f \n" |
378 |
++ "2: \n" |
379 |
++ user_sc("%[tmp]", "(%[addr])") |
380 |
++ " beqz %[tmp], 4f \n" |
381 |
+ "3: \n" |
382 |
+ " .insn \n" |
383 |
+ " .subsection 2 \n" |
384 |
+@@ -199,6 +202,12 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new) |
385 |
+ unreachable(); |
386 |
+ } |
387 |
+ |
388 |
++/* |
389 |
++ * mips_atomic_set() normally returns directly via syscall_exit potentially |
390 |
++ * clobbering static registers, so be sure to preserve them. |
391 |
++ */ |
392 |
++save_static_function(sys_sysmips); |
393 |
++ |
394 |
+ SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2) |
395 |
+ { |
396 |
+ switch (cmd) { |
397 |
+diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c |
398 |
+index 81f645973eb3..62ad117675b3 100644 |
399 |
+--- a/arch/mips/math-emu/cp1emu.c |
400 |
++++ b/arch/mips/math-emu/cp1emu.c |
401 |
+@@ -2140,6 +2140,35 @@ dcopuop: |
402 |
+ return 0; |
403 |
+ } |
404 |
+ |
405 |
++/* |
406 |
++ * Emulate FPU instructions. |
407 |
++ * |
408 |
++ * If we use FPU hardware, then we have been typically called to handle |
409 |
++ * an unimplemented operation, such as where an operand is a NaN or |
410 |
++ * denormalized. In that case exit the emulation loop after a single |
411 |
++ * iteration so as to let hardware execute any subsequent instructions. |
412 |
++ * |
413 |
++ * If we have no FPU hardware or it has been disabled, then continue |
414 |
++ * emulating floating-point instructions until one of these conditions |
415 |
++ * has occurred: |
416 |
++ * |
417 |
++ * - a non-FPU instruction has been encountered, |
418 |
++ * |
419 |
++ * - an attempt to emulate has ended with a signal, |
420 |
++ * |
421 |
++ * - the ISA mode has been switched. |
422 |
++ * |
423 |
++ * We need to terminate the emulation loop if we got switched to the |
424 |
++ * MIPS16 mode, whether supported or not, so that we do not attempt |
425 |
++ * to emulate a MIPS16 instruction as a regular MIPS FPU instruction. |
426 |
++ * Similarly if we got switched to the microMIPS mode and only the |
427 |
++ * regular MIPS mode is supported, so that we do not attempt to emulate |
428 |
++ * a microMIPS instruction as a regular MIPS FPU instruction. Or if |
429 |
++ * we got switched to the regular MIPS mode and only the microMIPS mode |
430 |
++ * is supported, so that we do not attempt to emulate a regular MIPS |
431 |
++ * instruction that should cause an Address Error exception instead. |
432 |
++ * For simplicity we always terminate upon an ISA mode switch. |
433 |
++ */ |
434 |
+ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx, |
435 |
+ int has_fpu, void *__user *fault_addr) |
436 |
+ { |
437 |
+@@ -2225,6 +2254,15 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx, |
438 |
+ break; |
439 |
+ if (sig) |
440 |
+ break; |
441 |
++ /* |
442 |
++ * We have to check for the ISA bit explicitly here, |
443 |
++ * because `get_isa16_mode' may return 0 if support |
444 |
++ * for code compression has been globally disabled, |
445 |
++ * or otherwise we may produce the wrong signal or |
446 |
++ * even proceed successfully where we must not. |
447 |
++ */ |
448 |
++ if ((xcp->cp0_epc ^ prevepc) & 0x1) |
449 |
++ break; |
450 |
+ |
451 |
+ cond_resched(); |
452 |
+ } while (xcp->cp0_epc > prevepc); |
453 |
+diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S |
454 |
+index 2d69a853b742..3a08b55609b6 100644 |
455 |
+--- a/arch/openrisc/kernel/vmlinux.lds.S |
456 |
++++ b/arch/openrisc/kernel/vmlinux.lds.S |
457 |
+@@ -38,6 +38,8 @@ SECTIONS |
458 |
+ /* Read-only sections, merged into text segment: */ |
459 |
+ . = LOAD_BASE ; |
460 |
+ |
461 |
++ _text = .; |
462 |
++ |
463 |
+ /* _s_kernel_ro must be page aligned */ |
464 |
+ . = ALIGN(PAGE_SIZE); |
465 |
+ _s_kernel_ro = .; |
466 |
+diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h |
467 |
+index 512d2782b043..0d6670056cd2 100644 |
468 |
+--- a/arch/powerpc/include/asm/atomic.h |
469 |
++++ b/arch/powerpc/include/asm/atomic.h |
470 |
+@@ -453,7 +453,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) |
471 |
+ * Atomically increments @v by 1, so long as @v is non-zero. |
472 |
+ * Returns non-zero if @v was non-zero, and zero otherwise. |
473 |
+ */ |
474 |
+-static __inline__ long atomic64_inc_not_zero(atomic64_t *v) |
475 |
++static __inline__ int atomic64_inc_not_zero(atomic64_t *v) |
476 |
+ { |
477 |
+ long t1, t2; |
478 |
+ |
479 |
+@@ -472,7 +472,7 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v) |
480 |
+ : "r" (&v->counter) |
481 |
+ : "cc", "xer", "memory"); |
482 |
+ |
483 |
+- return t1; |
484 |
++ return t1 != 0; |
485 |
+ } |
486 |
+ |
487 |
+ #endif /* __powerpc64__ */ |
488 |
+diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h |
489 |
+index a4bf6e0eb813..e97e58e28668 100644 |
490 |
+--- a/arch/powerpc/include/asm/reg.h |
491 |
++++ b/arch/powerpc/include/asm/reg.h |
492 |
+@@ -1237,7 +1237,7 @@ static inline unsigned long mfvtb (void) |
493 |
+ " .llong 0\n" \ |
494 |
+ ".previous" \ |
495 |
+ : "=r" (rval) \ |
496 |
+- : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \ |
497 |
++ : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL) : "cr0"); \ |
498 |
+ rval;}) |
499 |
+ #else |
500 |
+ #define mftb() ({unsigned long rval; \ |
501 |
+diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c |
502 |
+index c1e10ffadd17..8e7a6c8efd27 100644 |
503 |
+--- a/arch/powerpc/kvm/book3s_hv.c |
504 |
++++ b/arch/powerpc/kvm/book3s_hv.c |
505 |
+@@ -2232,6 +2232,10 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) |
506 |
+ { |
507 |
+ int r; |
508 |
+ int srcu_idx; |
509 |
++ unsigned long ebb_regs[3] = {}; /* shut up GCC */ |
510 |
++ unsigned long user_tar = 0; |
511 |
++ unsigned long proc_fscr = 0; |
512 |
++ unsigned int user_vrsave; |
513 |
+ |
514 |
+ if (!vcpu->arch.sane) { |
515 |
+ run->exit_reason = KVM_EXIT_INTERNAL_ERROR; |
516 |
+@@ -2281,6 +2285,17 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) |
517 |
+ flush_fp_to_thread(current); |
518 |
+ flush_altivec_to_thread(current); |
519 |
+ flush_vsx_to_thread(current); |
520 |
++ |
521 |
++ /* Save userspace EBB and other register values */ |
522 |
++ if (cpu_has_feature(CPU_FTR_ARCH_207S)) { |
523 |
++ ebb_regs[0] = mfspr(SPRN_EBBHR); |
524 |
++ ebb_regs[1] = mfspr(SPRN_EBBRR); |
525 |
++ ebb_regs[2] = mfspr(SPRN_BESCR); |
526 |
++ user_tar = mfspr(SPRN_TAR); |
527 |
++ proc_fscr = mfspr(SPRN_FSCR); |
528 |
++ } |
529 |
++ user_vrsave = mfspr(SPRN_VRSAVE); |
530 |
++ |
531 |
+ vcpu->arch.wqp = &vcpu->arch.vcore->wq; |
532 |
+ vcpu->arch.pgdir = current->mm->pgd; |
533 |
+ vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; |
534 |
+@@ -2302,6 +2317,16 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) |
535 |
+ } |
536 |
+ } while (is_kvmppc_resume_guest(r)); |
537 |
+ |
538 |
++ /* Restore userspace EBB and other register values */ |
539 |
++ if (cpu_has_feature(CPU_FTR_ARCH_207S)) { |
540 |
++ mtspr(SPRN_EBBHR, ebb_regs[0]); |
541 |
++ mtspr(SPRN_EBBRR, ebb_regs[1]); |
542 |
++ mtspr(SPRN_BESCR, ebb_regs[2]); |
543 |
++ mtspr(SPRN_TAR, user_tar); |
544 |
++ mtspr(SPRN_FSCR, proc_fscr); |
545 |
++ } |
546 |
++ mtspr(SPRN_VRSAVE, user_vrsave); |
547 |
++ |
548 |
+ out: |
549 |
+ vcpu->arch.state = KVMPPC_VCPU_NOTREADY; |
550 |
+ atomic_dec(&vcpu->kvm->arch.vcpus_running); |
551 |
+diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S |
552 |
+index 70eaf547703e..a3018f109cd3 100644 |
553 |
+--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S |
554 |
++++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S |
555 |
+@@ -36,6 +36,13 @@ |
556 |
+ #define NAPPING_CEDE 1 |
557 |
+ #define NAPPING_NOVCPU 2 |
558 |
+ |
559 |
++/* Stack frame offsets for kvmppc_hv_entry */ |
560 |
++#define SFS 112 |
561 |
++#define STACK_SLOT_TRAP (SFS-4) |
562 |
++#define STACK_SLOT_CIABR (SFS-16) |
563 |
++#define STACK_SLOT_DAWR (SFS-24) |
564 |
++#define STACK_SLOT_DAWRX (SFS-32) |
565 |
++ |
566 |
+ /* |
567 |
+ * Call kvmppc_hv_entry in real mode. |
568 |
+ * Must be called with interrupts hard-disabled. |
569 |
+@@ -265,10 +272,10 @@ kvm_novcpu_exit: |
570 |
+ bl kvmhv_accumulate_time |
571 |
+ #endif |
572 |
+ 13: mr r3, r12 |
573 |
+- stw r12, 112-4(r1) |
574 |
++ stw r12, STACK_SLOT_TRAP(r1) |
575 |
+ bl kvmhv_commence_exit |
576 |
+ nop |
577 |
+- lwz r12, 112-4(r1) |
578 |
++ lwz r12, STACK_SLOT_TRAP(r1) |
579 |
+ b kvmhv_switch_to_host |
580 |
+ |
581 |
+ /* |
582 |
+@@ -404,7 +411,7 @@ kvmppc_hv_entry: |
583 |
+ */ |
584 |
+ mflr r0 |
585 |
+ std r0, PPC_LR_STKOFF(r1) |
586 |
+- stdu r1, -112(r1) |
587 |
++ stdu r1, -SFS(r1) |
588 |
+ |
589 |
+ /* Save R1 in the PACA */ |
590 |
+ std r1, HSTATE_HOST_R1(r13) |
591 |
+@@ -558,6 +565,16 @@ kvmppc_got_guest: |
592 |
+ mtspr SPRN_PURR,r7 |
593 |
+ mtspr SPRN_SPURR,r8 |
594 |
+ |
595 |
++ /* Save host values of some registers */ |
596 |
++BEGIN_FTR_SECTION |
597 |
++ mfspr r5, SPRN_CIABR |
598 |
++ mfspr r6, SPRN_DAWR |
599 |
++ mfspr r7, SPRN_DAWRX |
600 |
++ std r5, STACK_SLOT_CIABR(r1) |
601 |
++ std r6, STACK_SLOT_DAWR(r1) |
602 |
++ std r7, STACK_SLOT_DAWRX(r1) |
603 |
++END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) |
604 |
++ |
605 |
+ BEGIN_FTR_SECTION |
606 |
+ /* Set partition DABR */ |
607 |
+ /* Do this before re-enabling PMU to avoid P7 DABR corruption bug */ |
608 |
+@@ -1169,8 +1186,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) |
609 |
+ */ |
610 |
+ li r0, 0 |
611 |
+ mtspr SPRN_IAMR, r0 |
612 |
+- mtspr SPRN_CIABR, r0 |
613 |
+- mtspr SPRN_DAWRX, r0 |
614 |
++ mtspr SPRN_PSPB, r0 |
615 |
+ mtspr SPRN_TCSCR, r0 |
616 |
+ mtspr SPRN_WORT, r0 |
617 |
+ /* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */ |
618 |
+@@ -1186,6 +1202,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) |
619 |
+ std r6,VCPU_UAMOR(r9) |
620 |
+ li r6,0 |
621 |
+ mtspr SPRN_AMR,r6 |
622 |
++ mtspr SPRN_UAMOR, r6 |
623 |
+ |
624 |
+ /* Switch DSCR back to host value */ |
625 |
+ mfspr r8, SPRN_DSCR |
626 |
+@@ -1327,6 +1344,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) |
627 |
+ slbia |
628 |
+ ptesync |
629 |
+ |
630 |
++ /* Restore host values of some registers */ |
631 |
++BEGIN_FTR_SECTION |
632 |
++ ld r5, STACK_SLOT_CIABR(r1) |
633 |
++ ld r6, STACK_SLOT_DAWR(r1) |
634 |
++ ld r7, STACK_SLOT_DAWRX(r1) |
635 |
++ mtspr SPRN_CIABR, r5 |
636 |
++ mtspr SPRN_DAWR, r6 |
637 |
++ mtspr SPRN_DAWRX, r7 |
638 |
++END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) |
639 |
++ |
640 |
+ /* |
641 |
+ * POWER7/POWER8 guest -> host partition switch code. |
642 |
+ * We don't have to lock against tlbies but we do |
643 |
+@@ -1431,8 +1458,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) |
644 |
+ li r0, KVM_GUEST_MODE_NONE |
645 |
+ stb r0, HSTATE_IN_GUEST(r13) |
646 |
+ |
647 |
+- ld r0, 112+PPC_LR_STKOFF(r1) |
648 |
+- addi r1, r1, 112 |
649 |
++ ld r0, SFS+PPC_LR_STKOFF(r1) |
650 |
++ addi r1, r1, SFS |
651 |
+ mtlr r0 |
652 |
+ blr |
653 |
+ |
654 |
+diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c |
655 |
+index 4014881e9843..e37162d356d8 100644 |
656 |
+--- a/arch/powerpc/lib/sstep.c |
657 |
++++ b/arch/powerpc/lib/sstep.c |
658 |
+@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, |
659 |
+ case 19: |
660 |
+ switch ((instr >> 1) & 0x3ff) { |
661 |
+ case 0: /* mcrf */ |
662 |
+- rd = (instr >> 21) & 0x1c; |
663 |
+- ra = (instr >> 16) & 0x1c; |
664 |
++ rd = 7 - ((instr >> 23) & 0x7); |
665 |
++ ra = 7 - ((instr >> 18) & 0x7); |
666 |
++ rd *= 4; |
667 |
++ ra *= 4; |
668 |
+ val = (regs->ccr >> ra) & 0xf; |
669 |
+ regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd); |
670 |
+ goto instr_done; |
671 |
+@@ -967,6 +969,19 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, |
672 |
+ #endif |
673 |
+ |
674 |
+ case 19: /* mfcr */ |
675 |
++ if ((instr >> 20) & 1) { |
676 |
++ imm = 0xf0000000UL; |
677 |
++ for (sh = 0; sh < 8; ++sh) { |
678 |
++ if (instr & (0x80000 >> sh)) { |
679 |
++ regs->gpr[rd] = regs->ccr & imm; |
680 |
++ break; |
681 |
++ } |
682 |
++ imm >>= 4; |
683 |
++ } |
684 |
++ |
685 |
++ goto instr_done; |
686 |
++ } |
687 |
++ |
688 |
+ regs->gpr[rd] = regs->ccr; |
689 |
+ regs->gpr[rd] &= 0xffffffffUL; |
690 |
+ goto instr_done; |
691 |
+diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c |
692 |
+index 0f319521e002..14392b4e4693 100644 |
693 |
+--- a/arch/powerpc/platforms/pseries/reconfig.c |
694 |
++++ b/arch/powerpc/platforms/pseries/reconfig.c |
695 |
+@@ -112,7 +112,6 @@ static int pSeries_reconfig_remove_node(struct device_node *np) |
696 |
+ |
697 |
+ of_detach_node(np); |
698 |
+ of_node_put(parent); |
699 |
+- of_node_put(np); /* Must decrement the refcount */ |
700 |
+ return 0; |
701 |
+ } |
702 |
+ |
703 |
+diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h |
704 |
+index 6ba0bf928909..6bc941be6921 100644 |
705 |
+--- a/arch/s390/include/asm/syscall.h |
706 |
++++ b/arch/s390/include/asm/syscall.h |
707 |
+@@ -64,6 +64,12 @@ static inline void syscall_get_arguments(struct task_struct *task, |
708 |
+ { |
709 |
+ unsigned long mask = -1UL; |
710 |
+ |
711 |
++ /* |
712 |
++ * No arguments for this syscall, there's nothing to do. |
713 |
++ */ |
714 |
++ if (!n) |
715 |
++ return; |
716 |
++ |
717 |
+ BUG_ON(i + n > 6); |
718 |
+ #ifdef CONFIG_COMPAT |
719 |
+ if (test_tsk_thread_flag(task, TIF_31BIT)) |
720 |
+diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c |
721 |
+index dc2d7aa56440..a3b51d30e8d8 100644 |
722 |
+--- a/arch/s390/net/bpf_jit_comp.c |
723 |
++++ b/arch/s390/net/bpf_jit_comp.c |
724 |
+@@ -1139,7 +1139,8 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp) |
725 |
+ insn_count = bpf_jit_insn(jit, fp, i); |
726 |
+ if (insn_count < 0) |
727 |
+ return -1; |
728 |
+- jit->addrs[i + 1] = jit->prg; /* Next instruction address */ |
729 |
++ /* Next instruction address */ |
730 |
++ jit->addrs[i + insn_count] = jit->prg; |
731 |
+ } |
732 |
+ bpf_jit_epilogue(jit); |
733 |
+ |
734 |
+diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h |
735 |
+index 349dd23e2876..0cdeb2b483a0 100644 |
736 |
+--- a/arch/sparc/include/asm/mmu_context_64.h |
737 |
++++ b/arch/sparc/include/asm/mmu_context_64.h |
738 |
+@@ -25,9 +25,11 @@ void destroy_context(struct mm_struct *mm); |
739 |
+ void __tsb_context_switch(unsigned long pgd_pa, |
740 |
+ struct tsb_config *tsb_base, |
741 |
+ struct tsb_config *tsb_huge, |
742 |
+- unsigned long tsb_descr_pa); |
743 |
++ unsigned long tsb_descr_pa, |
744 |
++ unsigned long secondary_ctx); |
745 |
+ |
746 |
+-static inline void tsb_context_switch(struct mm_struct *mm) |
747 |
++static inline void tsb_context_switch_ctx(struct mm_struct *mm, |
748 |
++ unsigned long ctx) |
749 |
+ { |
750 |
+ __tsb_context_switch(__pa(mm->pgd), |
751 |
+ &mm->context.tsb_block[0], |
752 |
+@@ -38,9 +40,12 @@ static inline void tsb_context_switch(struct mm_struct *mm) |
753 |
+ #else |
754 |
+ NULL |
755 |
+ #endif |
756 |
+- , __pa(&mm->context.tsb_descr[0])); |
757 |
++ , __pa(&mm->context.tsb_descr[0]), |
758 |
++ ctx); |
759 |
+ } |
760 |
+ |
761 |
++#define tsb_context_switch(X) tsb_context_switch_ctx(X, 0) |
762 |
++ |
763 |
+ void tsb_grow(struct mm_struct *mm, |
764 |
+ unsigned long tsb_index, |
765 |
+ unsigned long mm_rss); |
766 |
+@@ -110,8 +115,7 @@ static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, str |
767 |
+ * cpu0 to update it's TSB because at that point the cpu_vm_mask |
768 |
+ * only had cpu1 set in it. |
769 |
+ */ |
770 |
+- load_secondary_context(mm); |
771 |
+- tsb_context_switch(mm); |
772 |
++ tsb_context_switch_ctx(mm, CTX_HWBITS(mm->context)); |
773 |
+ |
774 |
+ /* Any time a processor runs a context on an address space |
775 |
+ * for the first time, we must flush that context out of the |
776 |
+diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h |
777 |
+index ec9c04de3664..ff05992dae7a 100644 |
778 |
+--- a/arch/sparc/include/asm/trap_block.h |
779 |
++++ b/arch/sparc/include/asm/trap_block.h |
780 |
+@@ -54,6 +54,7 @@ extern struct trap_per_cpu trap_block[NR_CPUS]; |
781 |
+ void init_cur_cpu_trap(struct thread_info *); |
782 |
+ void setup_tba(void); |
783 |
+ extern int ncpus_probed; |
784 |
++extern u64 cpu_mondo_counter[NR_CPUS]; |
785 |
+ |
786 |
+ unsigned long real_hard_smp_processor_id(void); |
787 |
+ |
788 |
+diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c |
789 |
+index 95a9fa0d2195..4511caa3b7e9 100644 |
790 |
+--- a/arch/sparc/kernel/smp_64.c |
791 |
++++ b/arch/sparc/kernel/smp_64.c |
792 |
+@@ -617,22 +617,48 @@ retry: |
793 |
+ } |
794 |
+ } |
795 |
+ |
796 |
+-/* Multi-cpu list version. */ |
797 |
++#define CPU_MONDO_COUNTER(cpuid) (cpu_mondo_counter[cpuid]) |
798 |
++#define MONDO_USEC_WAIT_MIN 2 |
799 |
++#define MONDO_USEC_WAIT_MAX 100 |
800 |
++#define MONDO_RETRY_LIMIT 500000 |
801 |
++ |
802 |
++/* Multi-cpu list version. |
803 |
++ * |
804 |
++ * Deliver xcalls to 'cnt' number of cpus in 'cpu_list'. |
805 |
++ * Sometimes not all cpus receive the mondo, requiring us to re-send |
806 |
++ * the mondo until all cpus have received, or cpus are truly stuck |
807 |
++ * unable to receive mondo, and we timeout. |
808 |
++ * Occasionally a target cpu strand is borrowed briefly by hypervisor to |
809 |
++ * perform guest service, such as PCIe error handling. Consider the |
810 |
++ * service time, 1 second overall wait is reasonable for 1 cpu. |
811 |
++ * Here two in-between mondo check wait time are defined: 2 usec for |
812 |
++ * single cpu quick turn around and up to 100usec for large cpu count. |
813 |
++ * Deliver mondo to large number of cpus could take longer, we adjusts |
814 |
++ * the retry count as long as target cpus are making forward progress. |
815 |
++ */ |
816 |
+ static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) |
817 |
+ { |
818 |
+- int retries, this_cpu, prev_sent, i, saw_cpu_error; |
819 |
++ int this_cpu, tot_cpus, prev_sent, i, rem; |
820 |
++ int usec_wait, retries, tot_retries; |
821 |
++ u16 first_cpu = 0xffff; |
822 |
++ unsigned long xc_rcvd = 0; |
823 |
+ unsigned long status; |
824 |
++ int ecpuerror_id = 0; |
825 |
++ int enocpu_id = 0; |
826 |
+ u16 *cpu_list; |
827 |
++ u16 cpu; |
828 |
+ |
829 |
+ this_cpu = smp_processor_id(); |
830 |
+- |
831 |
+ cpu_list = __va(tb->cpu_list_pa); |
832 |
+- |
833 |
+- saw_cpu_error = 0; |
834 |
+- retries = 0; |
835 |
++ usec_wait = cnt * MONDO_USEC_WAIT_MIN; |
836 |
++ if (usec_wait > MONDO_USEC_WAIT_MAX) |
837 |
++ usec_wait = MONDO_USEC_WAIT_MAX; |
838 |
++ retries = tot_retries = 0; |
839 |
++ tot_cpus = cnt; |
840 |
+ prev_sent = 0; |
841 |
++ |
842 |
+ do { |
843 |
+- int forward_progress, n_sent; |
844 |
++ int n_sent, mondo_delivered, target_cpu_busy; |
845 |
+ |
846 |
+ status = sun4v_cpu_mondo_send(cnt, |
847 |
+ tb->cpu_list_pa, |
848 |
+@@ -640,94 +666,113 @@ static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) |
849 |
+ |
850 |
+ /* HV_EOK means all cpus received the xcall, we're done. */ |
851 |
+ if (likely(status == HV_EOK)) |
852 |
+- break; |
853 |
++ goto xcall_done; |
854 |
++ |
855 |
++ /* If not these non-fatal errors, panic */ |
856 |
++ if (unlikely((status != HV_EWOULDBLOCK) && |
857 |
++ (status != HV_ECPUERROR) && |
858 |
++ (status != HV_ENOCPU))) |
859 |
++ goto fatal_errors; |
860 |
+ |
861 |
+ /* First, see if we made any forward progress. |
862 |
++ * |
863 |
++ * Go through the cpu_list, count the target cpus that have |
864 |
++ * received our mondo (n_sent), and those that did not (rem). |
865 |
++ * Re-pack cpu_list with the cpus remain to be retried in the |
866 |
++ * front - this simplifies tracking the truly stalled cpus. |
867 |
+ * |
868 |
+ * The hypervisor indicates successful sends by setting |
869 |
+ * cpu list entries to the value 0xffff. |
870 |
++ * |
871 |
++ * EWOULDBLOCK means some target cpus did not receive the |
872 |
++ * mondo and retry usually helps. |
873 |
++ * |
874 |
++ * ECPUERROR means at least one target cpu is in error state, |
875 |
++ * it's usually safe to skip the faulty cpu and retry. |
876 |
++ * |
877 |
++ * ENOCPU means one of the target cpu doesn't belong to the |
878 |
++ * domain, perhaps offlined which is unexpected, but not |
879 |
++ * fatal and it's okay to skip the offlined cpu. |
880 |
+ */ |
881 |
++ rem = 0; |
882 |
+ n_sent = 0; |
883 |
+ for (i = 0; i < cnt; i++) { |
884 |
+- if (likely(cpu_list[i] == 0xffff)) |
885 |
++ cpu = cpu_list[i]; |
886 |
++ if (likely(cpu == 0xffff)) { |
887 |
+ n_sent++; |
888 |
++ } else if ((status == HV_ECPUERROR) && |
889 |
++ (sun4v_cpu_state(cpu) == HV_CPU_STATE_ERROR)) { |
890 |
++ ecpuerror_id = cpu + 1; |
891 |
++ } else if (status == HV_ENOCPU && !cpu_online(cpu)) { |
892 |
++ enocpu_id = cpu + 1; |
893 |
++ } else { |
894 |
++ cpu_list[rem++] = cpu; |
895 |
++ } |
896 |
+ } |
897 |
+ |
898 |
+- forward_progress = 0; |
899 |
+- if (n_sent > prev_sent) |
900 |
+- forward_progress = 1; |
901 |
++ /* No cpu remained, we're done. */ |
902 |
++ if (rem == 0) |
903 |
++ break; |
904 |
+ |
905 |
+- prev_sent = n_sent; |
906 |
++ /* Otherwise, update the cpu count for retry. */ |
907 |
++ cnt = rem; |
908 |
+ |
909 |
+- /* If we get a HV_ECPUERROR, then one or more of the cpus |
910 |
+- * in the list are in error state. Use the cpu_state() |
911 |
+- * hypervisor call to find out which cpus are in error state. |
912 |
++ /* Record the overall number of mondos received by the |
913 |
++ * first of the remaining cpus. |
914 |
+ */ |
915 |
+- if (unlikely(status == HV_ECPUERROR)) { |
916 |
+- for (i = 0; i < cnt; i++) { |
917 |
+- long err; |
918 |
+- u16 cpu; |
919 |
++ if (first_cpu != cpu_list[0]) { |
920 |
++ first_cpu = cpu_list[0]; |
921 |
++ xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
922 |
++ } |
923 |
+ |
924 |
+- cpu = cpu_list[i]; |
925 |
+- if (cpu == 0xffff) |
926 |
+- continue; |
927 |
++ /* Was any mondo delivered successfully? */ |
928 |
++ mondo_delivered = (n_sent > prev_sent); |
929 |
++ prev_sent = n_sent; |
930 |
+ |
931 |
+- err = sun4v_cpu_state(cpu); |
932 |
+- if (err == HV_CPU_STATE_ERROR) { |
933 |
+- saw_cpu_error = (cpu + 1); |
934 |
+- cpu_list[i] = 0xffff; |
935 |
+- } |
936 |
+- } |
937 |
+- } else if (unlikely(status != HV_EWOULDBLOCK)) |
938 |
+- goto fatal_mondo_error; |
939 |
++ /* or, was any target cpu busy processing other mondos? */ |
940 |
++ target_cpu_busy = (xc_rcvd < CPU_MONDO_COUNTER(first_cpu)); |
941 |
++ xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
942 |
+ |
943 |
+- /* Don't bother rewriting the CPU list, just leave the |
944 |
+- * 0xffff and non-0xffff entries in there and the |
945 |
+- * hypervisor will do the right thing. |
946 |
+- * |
947 |
+- * Only advance timeout state if we didn't make any |
948 |
+- * forward progress. |
949 |
++ /* Retry count is for no progress. If we're making progress, |
950 |
++ * reset the retry count. |
951 |
+ */ |
952 |
+- if (unlikely(!forward_progress)) { |
953 |
+- if (unlikely(++retries > 10000)) |
954 |
+- goto fatal_mondo_timeout; |
955 |
+- |
956 |
+- /* Delay a little bit to let other cpus catch up |
957 |
+- * on their cpu mondo queue work. |
958 |
+- */ |
959 |
+- udelay(2 * cnt); |
960 |
++ if (likely(mondo_delivered || target_cpu_busy)) { |
961 |
++ tot_retries += retries; |
962 |
++ retries = 0; |
963 |
++ } else if (unlikely(retries > MONDO_RETRY_LIMIT)) { |
964 |
++ goto fatal_mondo_timeout; |
965 |
+ } |
966 |
+- } while (1); |
967 |
+ |
968 |
+- if (unlikely(saw_cpu_error)) |
969 |
+- goto fatal_mondo_cpu_error; |
970 |
++ /* Delay a little bit to let other cpus catch up on |
971 |
++ * their cpu mondo queue work. |
972 |
++ */ |
973 |
++ if (!mondo_delivered) |
974 |
++ udelay(usec_wait); |
975 |
+ |
976 |
+- return; |
977 |
++ retries++; |
978 |
++ } while (1); |
979 |
+ |
980 |
+-fatal_mondo_cpu_error: |
981 |
+- printk(KERN_CRIT "CPU[%d]: SUN4V mondo cpu error, some target cpus " |
982 |
+- "(including %d) were in error state\n", |
983 |
+- this_cpu, saw_cpu_error - 1); |
984 |
++xcall_done: |
985 |
++ if (unlikely(ecpuerror_id > 0)) { |
986 |
++ pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) was in error state\n", |
987 |
++ this_cpu, ecpuerror_id - 1); |
988 |
++ } else if (unlikely(enocpu_id > 0)) { |
989 |
++ pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) does not belong to the domain\n", |
990 |
++ this_cpu, enocpu_id - 1); |
991 |
++ } |
992 |
+ return; |
993 |
+ |
994 |
++fatal_errors: |
995 |
++ /* fatal errors include bad alignment, etc */ |
996 |
++ pr_crit("CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) mondo_block_pa(%lx)\n", |
997 |
++ this_cpu, tot_cpus, tb->cpu_list_pa, tb->cpu_mondo_block_pa); |
998 |
++ panic("Unexpected SUN4V mondo error %lu\n", status); |
999 |
++ |
1000 |
+ fatal_mondo_timeout: |
1001 |
+- printk(KERN_CRIT "CPU[%d]: SUN4V mondo timeout, no forward " |
1002 |
+- " progress after %d retries.\n", |
1003 |
+- this_cpu, retries); |
1004 |
+- goto dump_cpu_list_and_out; |
1005 |
+- |
1006 |
+-fatal_mondo_error: |
1007 |
+- printk(KERN_CRIT "CPU[%d]: Unexpected SUN4V mondo error %lu\n", |
1008 |
+- this_cpu, status); |
1009 |
+- printk(KERN_CRIT "CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) " |
1010 |
+- "mondo_block_pa(%lx)\n", |
1011 |
+- this_cpu, cnt, tb->cpu_list_pa, tb->cpu_mondo_block_pa); |
1012 |
+- |
1013 |
+-dump_cpu_list_and_out: |
1014 |
+- printk(KERN_CRIT "CPU[%d]: CPU list [ ", this_cpu); |
1015 |
+- for (i = 0; i < cnt; i++) |
1016 |
+- printk("%u ", cpu_list[i]); |
1017 |
+- printk("]\n"); |
1018 |
++ /* some cpus being non-responsive to the cpu mondo */ |
1019 |
++ pr_crit("CPU[%d]: SUN4V mondo timeout, cpu(%d) made no forward progress after %d retries. Total target cpus(%d).\n", |
1020 |
++ this_cpu, first_cpu, (tot_retries + retries), tot_cpus); |
1021 |
++ panic("SUN4V mondo timeout panic\n"); |
1022 |
+ } |
1023 |
+ |
1024 |
+ static void (*xcall_deliver_impl)(struct trap_per_cpu *, int); |
1025 |
+diff --git a/arch/sparc/kernel/sun4v_ivec.S b/arch/sparc/kernel/sun4v_ivec.S |
1026 |
+index 559bc5e9c199..34631995859a 100644 |
1027 |
+--- a/arch/sparc/kernel/sun4v_ivec.S |
1028 |
++++ b/arch/sparc/kernel/sun4v_ivec.S |
1029 |
+@@ -26,6 +26,21 @@ sun4v_cpu_mondo: |
1030 |
+ ldxa [%g0] ASI_SCRATCHPAD, %g4 |
1031 |
+ sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 |
1032 |
+ |
1033 |
++ /* Get smp_processor_id() into %g3 */ |
1034 |
++ sethi %hi(trap_block), %g5 |
1035 |
++ or %g5, %lo(trap_block), %g5 |
1036 |
++ sub %g4, %g5, %g3 |
1037 |
++ srlx %g3, TRAP_BLOCK_SZ_SHIFT, %g3 |
1038 |
++ |
1039 |
++ /* Increment cpu_mondo_counter[smp_processor_id()] */ |
1040 |
++ sethi %hi(cpu_mondo_counter), %g5 |
1041 |
++ or %g5, %lo(cpu_mondo_counter), %g5 |
1042 |
++ sllx %g3, 3, %g3 |
1043 |
++ add %g5, %g3, %g5 |
1044 |
++ ldx [%g5], %g3 |
1045 |
++ add %g3, 1, %g3 |
1046 |
++ stx %g3, [%g5] |
1047 |
++ |
1048 |
+ /* Get CPU mondo queue base phys address into %g7. */ |
1049 |
+ ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 |
1050 |
+ |
1051 |
+diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c |
1052 |
+index cc97a43268ee..d883c5951e8b 100644 |
1053 |
+--- a/arch/sparc/kernel/traps_64.c |
1054 |
++++ b/arch/sparc/kernel/traps_64.c |
1055 |
+@@ -2659,6 +2659,7 @@ void do_getpsr(struct pt_regs *regs) |
1056 |
+ } |
1057 |
+ } |
1058 |
+ |
1059 |
++u64 cpu_mondo_counter[NR_CPUS] = {0}; |
1060 |
+ struct trap_per_cpu trap_block[NR_CPUS]; |
1061 |
+ EXPORT_SYMBOL(trap_block); |
1062 |
+ |
1063 |
+diff --git a/arch/sparc/kernel/tsb.S b/arch/sparc/kernel/tsb.S |
1064 |
+index 8e920d152565..12fe20c9042c 100644 |
1065 |
+--- a/arch/sparc/kernel/tsb.S |
1066 |
++++ b/arch/sparc/kernel/tsb.S |
1067 |
+@@ -367,6 +367,7 @@ tsb_flush: |
1068 |
+ * %o1: TSB base config pointer |
1069 |
+ * %o2: TSB huge config pointer, or NULL if none |
1070 |
+ * %o3: Hypervisor TSB descriptor physical address |
1071 |
++ * %o4: Secondary context to load, if non-zero |
1072 |
+ * |
1073 |
+ * We have to run this whole thing with interrupts |
1074 |
+ * disabled so that the current cpu doesn't change |
1075 |
+@@ -379,6 +380,17 @@ __tsb_context_switch: |
1076 |
+ rdpr %pstate, %g1 |
1077 |
+ wrpr %g1, PSTATE_IE, %pstate |
1078 |
+ |
1079 |
++ brz,pn %o4, 1f |
1080 |
++ mov SECONDARY_CONTEXT, %o5 |
1081 |
++ |
1082 |
++661: stxa %o4, [%o5] ASI_DMMU |
1083 |
++ .section .sun4v_1insn_patch, "ax" |
1084 |
++ .word 661b |
1085 |
++ stxa %o4, [%o5] ASI_MMU |
1086 |
++ .previous |
1087 |
++ flush %g6 |
1088 |
++ |
1089 |
++1: |
1090 |
+ TRAP_LOAD_TRAP_BLOCK(%g2, %g3) |
1091 |
+ |
1092 |
+ stx %o0, [%g2 + TRAP_PER_CPU_PGD_PADDR] |
1093 |
+diff --git a/arch/sparc/power/hibernate.c b/arch/sparc/power/hibernate.c |
1094 |
+index 17bd2e167e07..df707a8ad311 100644 |
1095 |
+--- a/arch/sparc/power/hibernate.c |
1096 |
++++ b/arch/sparc/power/hibernate.c |
1097 |
+@@ -35,6 +35,5 @@ void restore_processor_state(void) |
1098 |
+ { |
1099 |
+ struct mm_struct *mm = current->active_mm; |
1100 |
+ |
1101 |
+- load_secondary_context(mm); |
1102 |
+- tsb_context_switch(mm); |
1103 |
++ tsb_context_switch_ctx(mm, CTX_HWBITS(mm->context)); |
1104 |
+ } |
1105 |
+diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c |
1106 |
+index 318b8465d302..06ceddb3a22e 100644 |
1107 |
+--- a/arch/x86/boot/string.c |
1108 |
++++ b/arch/x86/boot/string.c |
1109 |
+@@ -14,6 +14,7 @@ |
1110 |
+ |
1111 |
+ #include <linux/types.h> |
1112 |
+ #include "ctype.h" |
1113 |
++#include "string.h" |
1114 |
+ |
1115 |
+ int memcmp(const void *s1, const void *s2, size_t len) |
1116 |
+ { |
1117 |
+diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h |
1118 |
+index 725e820602b1..113588ddb43f 100644 |
1119 |
+--- a/arch/x86/boot/string.h |
1120 |
++++ b/arch/x86/boot/string.h |
1121 |
+@@ -18,4 +18,13 @@ int memcmp(const void *s1, const void *s2, size_t len); |
1122 |
+ #define memset(d,c,l) __builtin_memset(d,c,l) |
1123 |
+ #define memcmp __builtin_memcmp |
1124 |
+ |
1125 |
++extern int strcmp(const char *str1, const char *str2); |
1126 |
++extern int strncmp(const char *cs, const char *ct, size_t count); |
1127 |
++extern size_t strlen(const char *s); |
1128 |
++extern char *strstr(const char *s1, const char *s2); |
1129 |
++extern size_t strnlen(const char *s, size_t maxlen); |
1130 |
++extern unsigned int atou(const char *s); |
1131 |
++extern unsigned long long simple_strtoull(const char *cp, char **endp, |
1132 |
++ unsigned int base); |
1133 |
++ |
1134 |
+ #endif /* BOOT_STRING_H */ |
1135 |
+diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h |
1136 |
+index ca08a27b90b3..4ad5a91aea79 100644 |
1137 |
+--- a/arch/x86/include/asm/xen/hypercall.h |
1138 |
++++ b/arch/x86/include/asm/xen/hypercall.h |
1139 |
+@@ -43,6 +43,7 @@ |
1140 |
+ |
1141 |
+ #include <asm/page.h> |
1142 |
+ #include <asm/pgtable.h> |
1143 |
++#include <asm/smap.h> |
1144 |
+ |
1145 |
+ #include <xen/interface/xen.h> |
1146 |
+ #include <xen/interface/sched.h> |
1147 |
+@@ -213,10 +214,12 @@ privcmd_call(unsigned call, |
1148 |
+ __HYPERCALL_DECLS; |
1149 |
+ __HYPERCALL_5ARG(a1, a2, a3, a4, a5); |
1150 |
+ |
1151 |
++ stac(); |
1152 |
+ asm volatile("call *%[call]" |
1153 |
+ : __HYPERCALL_5PARAM |
1154 |
+ : [call] "a" (&hypercall_page[call]) |
1155 |
+ : __HYPERCALL_CLOBBER5); |
1156 |
++ clac(); |
1157 |
+ |
1158 |
+ return (long)__res; |
1159 |
+ } |
1160 |
+diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c |
1161 |
+index 07bea80223f6..60aa02503b48 100644 |
1162 |
+--- a/arch/x86/kernel/acpi/boot.c |
1163 |
++++ b/arch/x86/kernel/acpi/boot.c |
1164 |
+@@ -328,6 +328,14 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, |
1165 |
+ int pin; |
1166 |
+ struct mpc_intsrc mp_irq; |
1167 |
+ |
1168 |
++ /* |
1169 |
++ * Check bus_irq boundary. |
1170 |
++ */ |
1171 |
++ if (bus_irq >= NR_IRQS_LEGACY) { |
1172 |
++ pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq); |
1173 |
++ return; |
1174 |
++ } |
1175 |
++ |
1176 |
+ /* |
1177 |
+ * Convert 'gsi' to 'ioapic.pin'. |
1178 |
+ */ |
1179 |
+diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c |
1180 |
+index df61c2d0cb56..bd7e7d6c29c5 100644 |
1181 |
+--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c |
1182 |
++++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c |
1183 |
+@@ -581,6 +581,9 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank) |
1184 |
+ const char *name = th_names[bank]; |
1185 |
+ int err = 0; |
1186 |
+ |
1187 |
++ if (!dev) |
1188 |
++ return -ENODEV; |
1189 |
++ |
1190 |
+ if (is_shared_bank(bank)) { |
1191 |
+ nb = node_to_amd_nb(amd_get_nb_id(cpu)); |
1192 |
+ |
1193 |
+diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c |
1194 |
+index 27e63c1770e6..916e84aa5447 100644 |
1195 |
+--- a/arch/x86/kernel/kvm.c |
1196 |
++++ b/arch/x86/kernel/kvm.c |
1197 |
+@@ -151,6 +151,8 @@ void kvm_async_pf_task_wait(u32 token) |
1198 |
+ if (hlist_unhashed(&n.link)) |
1199 |
+ break; |
1200 |
+ |
1201 |
++ rcu_irq_exit(); |
1202 |
++ |
1203 |
+ if (!n.halted) { |
1204 |
+ local_irq_enable(); |
1205 |
+ schedule(); |
1206 |
+@@ -159,11 +161,11 @@ void kvm_async_pf_task_wait(u32 token) |
1207 |
+ /* |
1208 |
+ * We cannot reschedule. So halt. |
1209 |
+ */ |
1210 |
+- rcu_irq_exit(); |
1211 |
+ native_safe_halt(); |
1212 |
+ local_irq_disable(); |
1213 |
+- rcu_irq_enter(); |
1214 |
+ } |
1215 |
++ |
1216 |
++ rcu_irq_enter(); |
1217 |
+ } |
1218 |
+ if (!n.halted) |
1219 |
+ finish_wait(&n.wq, &wait); |
1220 |
+diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c |
1221 |
+index 39c485b0c25c..db89f4b8b966 100644 |
1222 |
+--- a/drivers/acpi/glue.c |
1223 |
++++ b/drivers/acpi/glue.c |
1224 |
+@@ -97,7 +97,15 @@ static int find_child_checks(struct acpi_device *adev, bool check_children) |
1225 |
+ if (check_children && list_empty(&adev->children)) |
1226 |
+ return -ENODEV; |
1227 |
+ |
1228 |
+- return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; |
1229 |
++ /* |
1230 |
++ * If the device has a _HID (or _CID) returning a valid ACPI/PNP |
1231 |
++ * device ID, it is better to make it look less attractive here, so that |
1232 |
++ * the other device with the same _ADR value (that may not have a valid |
1233 |
++ * device ID) can be matched going forward. [This means a second spec |
1234 |
++ * violation in a row, so whatever we do here is best effort anyway.] |
1235 |
++ */ |
1236 |
++ return sta_present && list_empty(&adev->pnp.ids) ? |
1237 |
++ FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; |
1238 |
+ } |
1239 |
+ |
1240 |
+ struct acpi_device *acpi_find_child_device(struct acpi_device *parent, |
1241 |
+diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c |
1242 |
+index ae7cfcb562dc..4d4cdade9d7e 100644 |
1243 |
+--- a/drivers/ata/libata-scsi.c |
1244 |
++++ b/drivers/ata/libata-scsi.c |
1245 |
+@@ -2834,10 +2834,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) |
1246 |
+ static struct ata_device *ata_find_dev(struct ata_port *ap, int devno) |
1247 |
+ { |
1248 |
+ if (!sata_pmp_attached(ap)) { |
1249 |
+- if (likely(devno < ata_link_max_devices(&ap->link))) |
1250 |
++ if (likely(devno >= 0 && |
1251 |
++ devno < ata_link_max_devices(&ap->link))) |
1252 |
+ return &ap->link.device[devno]; |
1253 |
+ } else { |
1254 |
+- if (likely(devno < ap->nr_pmp_links)) |
1255 |
++ if (likely(devno >= 0 && |
1256 |
++ devno < ap->nr_pmp_links)) |
1257 |
+ return &ap->pmp_link[devno].device[0]; |
1258 |
+ } |
1259 |
+ |
1260 |
+diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c |
1261 |
+index 2327613d4539..75e29733af54 100644 |
1262 |
+--- a/drivers/base/power/domain.c |
1263 |
++++ b/drivers/base/power/domain.c |
1264 |
+@@ -1440,7 +1440,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, |
1265 |
+ } |
1266 |
+ |
1267 |
+ dev->power.subsys_data->domain_data = &gpd_data->base; |
1268 |
+- dev->pm_domain = &genpd->domain; |
1269 |
+ |
1270 |
+ spin_unlock_irq(&dev->power.lock); |
1271 |
+ |
1272 |
+@@ -1459,7 +1458,6 @@ static void genpd_free_dev_data(struct device *dev, |
1273 |
+ { |
1274 |
+ spin_lock_irq(&dev->power.lock); |
1275 |
+ |
1276 |
+- dev->pm_domain = NULL; |
1277 |
+ dev->power.subsys_data->domain_data = NULL; |
1278 |
+ |
1279 |
+ spin_unlock_irq(&dev->power.lock); |
1280 |
+@@ -1500,6 +1498,8 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, |
1281 |
+ if (ret) |
1282 |
+ goto out; |
1283 |
+ |
1284 |
++ dev->pm_domain = &genpd->domain; |
1285 |
++ |
1286 |
+ genpd->device_count++; |
1287 |
+ genpd->max_off_time_changed = true; |
1288 |
+ |
1289 |
+@@ -1563,6 +1563,8 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, |
1290 |
+ if (genpd->detach_dev) |
1291 |
+ genpd->detach_dev(genpd, dev); |
1292 |
+ |
1293 |
++ dev->pm_domain = NULL; |
1294 |
++ |
1295 |
+ list_del_init(&pdd->list_node); |
1296 |
+ |
1297 |
+ genpd_release_lock(genpd); |
1298 |
+@@ -1673,7 +1675,7 @@ int pm_genpd_add_subdomain_names(const char *master_name, |
1299 |
+ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
1300 |
+ struct generic_pm_domain *subdomain) |
1301 |
+ { |
1302 |
+- struct gpd_link *link; |
1303 |
++ struct gpd_link *l, *link; |
1304 |
+ int ret = -EINVAL; |
1305 |
+ |
1306 |
+ if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) |
1307 |
+@@ -1682,7 +1684,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
1308 |
+ start: |
1309 |
+ genpd_acquire_lock(genpd); |
1310 |
+ |
1311 |
+- list_for_each_entry(link, &genpd->master_links, master_node) { |
1312 |
++ list_for_each_entry_safe(link, l, &genpd->master_links, master_node) { |
1313 |
+ if (link->slave != subdomain) |
1314 |
+ continue; |
1315 |
+ |
1316 |
+@@ -2062,10 +2064,10 @@ EXPORT_SYMBOL_GPL(__of_genpd_add_provider); |
1317 |
+ */ |
1318 |
+ void of_genpd_del_provider(struct device_node *np) |
1319 |
+ { |
1320 |
+- struct of_genpd_provider *cp; |
1321 |
++ struct of_genpd_provider *cp, *tmp; |
1322 |
+ |
1323 |
+ mutex_lock(&of_genpd_mutex); |
1324 |
+- list_for_each_entry(cp, &of_genpd_providers, link) { |
1325 |
++ list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) { |
1326 |
+ if (cp->node == np) { |
1327 |
+ list_del(&cp->link); |
1328 |
+ of_node_put(cp->node); |
1329 |
+diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c |
1330 |
+index 5ea2f0bbbc7c..071c3ea70882 100644 |
1331 |
+--- a/drivers/block/virtio_blk.c |
1332 |
++++ b/drivers/block/virtio_blk.c |
1333 |
+@@ -642,11 +642,12 @@ static int virtblk_probe(struct virtio_device *vdev) |
1334 |
+ if (err) |
1335 |
+ goto out_put_disk; |
1336 |
+ |
1337 |
+- q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set); |
1338 |
++ q = blk_mq_init_queue(&vblk->tag_set); |
1339 |
+ if (IS_ERR(q)) { |
1340 |
+ err = -ENOMEM; |
1341 |
+ goto out_free_tags; |
1342 |
+ } |
1343 |
++ vblk->disk->queue = q; |
1344 |
+ |
1345 |
+ q->queuedata = vblk; |
1346 |
+ |
1347 |
+diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c |
1348 |
+index 3e9ec9523f73..1d8c6cb89c7f 100644 |
1349 |
+--- a/drivers/block/xen-blkback/blkback.c |
1350 |
++++ b/drivers/block/xen-blkback/blkback.c |
1351 |
+@@ -588,8 +588,6 @@ int xen_blkif_schedule(void *arg) |
1352 |
+ unsigned long timeout; |
1353 |
+ int ret; |
1354 |
+ |
1355 |
+- xen_blkif_get(blkif); |
1356 |
+- |
1357 |
+ while (!kthread_should_stop()) { |
1358 |
+ if (try_to_freeze()) |
1359 |
+ continue; |
1360 |
+@@ -643,7 +641,6 @@ purge_gnt_list: |
1361 |
+ print_stats(blkif); |
1362 |
+ |
1363 |
+ blkif->xenblkd = NULL; |
1364 |
+- xen_blkif_put(blkif); |
1365 |
+ |
1366 |
+ return 0; |
1367 |
+ } |
1368 |
+diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c |
1369 |
+index 6ab69ad61ee1..b8c48da3b19f 100644 |
1370 |
+--- a/drivers/block/xen-blkback/xenbus.c |
1371 |
++++ b/drivers/block/xen-blkback/xenbus.c |
1372 |
+@@ -256,7 +256,6 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) |
1373 |
+ if (blkif->xenblkd) { |
1374 |
+ kthread_stop(blkif->xenblkd); |
1375 |
+ wake_up(&blkif->shutdown_wq); |
1376 |
+- blkif->xenblkd = NULL; |
1377 |
+ } |
1378 |
+ |
1379 |
+ /* The above kthread_stop() guarantees that at this point we |
1380 |
+diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c |
1381 |
+index 4bc508c14900..5da703c65d93 100644 |
1382 |
+--- a/drivers/char/ipmi/ipmi_msghandler.c |
1383 |
++++ b/drivers/char/ipmi/ipmi_msghandler.c |
1384 |
+@@ -3871,6 +3871,9 @@ static void smi_recv_tasklet(unsigned long val) |
1385 |
+ * because the lower layer is allowed to hold locks while calling |
1386 |
+ * message delivery. |
1387 |
+ */ |
1388 |
++ |
1389 |
++ rcu_read_lock(); |
1390 |
++ |
1391 |
+ if (!run_to_completion) |
1392 |
+ spin_lock_irqsave(&intf->xmit_msgs_lock, flags); |
1393 |
+ if (intf->curr_msg == NULL && !intf->in_shutdown) { |
1394 |
+@@ -3893,6 +3896,8 @@ static void smi_recv_tasklet(unsigned long val) |
1395 |
+ if (newmsg) |
1396 |
+ intf->handlers->sender(intf->send_info, newmsg); |
1397 |
+ |
1398 |
++ rcu_read_unlock(); |
1399 |
++ |
1400 |
+ handle_new_recv_msgs(intf); |
1401 |
+ } |
1402 |
+ |
1403 |
+diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c |
1404 |
+index 9df92eda8749..9156bbd90b56 100644 |
1405 |
+--- a/drivers/char/ipmi/ipmi_ssif.c |
1406 |
++++ b/drivers/char/ipmi/ipmi_ssif.c |
1407 |
+@@ -757,6 +757,11 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
1408 |
+ result, len, data[2]); |
1409 |
+ } else if (data[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 |
1410 |
+ || data[1] != IPMI_GET_MSG_FLAGS_CMD) { |
1411 |
++ /* |
1412 |
++ * Don't abort here, maybe it was a queued |
1413 |
++ * response to a previous command. |
1414 |
++ */ |
1415 |
++ ipmi_ssif_unlock_cond(ssif_info, flags); |
1416 |
+ pr_warn(PFX "Invalid response getting flags: %x %x\n", |
1417 |
+ data[0], data[1]); |
1418 |
+ } else { |
1419 |
+diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c |
1420 |
+index 37b8be7cba95..f335fcee09af 100644 |
1421 |
+--- a/drivers/char/ipmi/ipmi_watchdog.c |
1422 |
++++ b/drivers/char/ipmi/ipmi_watchdog.c |
1423 |
+@@ -1156,10 +1156,11 @@ static int wdog_reboot_handler(struct notifier_block *this, |
1424 |
+ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; |
1425 |
+ ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); |
1426 |
+ } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { |
1427 |
+- /* Set a long timer to let the reboot happens, but |
1428 |
+- reboot if it hangs, but only if the watchdog |
1429 |
++ /* Set a long timer to let the reboot happen or |
1430 |
++ reset if it hangs, but only if the watchdog |
1431 |
+ timer was already running. */ |
1432 |
+- timeout = 120; |
1433 |
++ if (timeout < 120) |
1434 |
++ timeout = 120; |
1435 |
+ pretimeout = 0; |
1436 |
+ ipmi_watchdog_state = WDOG_TIMEOUT_RESET; |
1437 |
+ ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); |
1438 |
+diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c |
1439 |
+index ee66fd4673f3..62a6117b57d7 100644 |
1440 |
+--- a/drivers/char/tpm/tpm-sysfs.c |
1441 |
++++ b/drivers/char/tpm/tpm-sysfs.c |
1442 |
+@@ -38,6 +38,8 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, |
1443 |
+ |
1444 |
+ struct tpm_chip *chip = dev_get_drvdata(dev); |
1445 |
+ |
1446 |
++ memset(&tpm_cmd, 0, sizeof(tpm_cmd)); |
1447 |
++ |
1448 |
+ tpm_cmd.header.in = tpm_readpubek_header; |
1449 |
+ err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, |
1450 |
+ "attempting to read the PUBEK"); |
1451 |
+diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c |
1452 |
+index f557695a2409..7724ddb0f776 100644 |
1453 |
+--- a/drivers/gpu/drm/drm_dp_mst_topology.c |
1454 |
++++ b/drivers/gpu/drm/drm_dp_mst_topology.c |
1455 |
+@@ -330,6 +330,13 @@ static bool drm_dp_sideband_msg_build(struct drm_dp_sideband_msg_rx *msg, |
1456 |
+ return false; |
1457 |
+ } |
1458 |
+ |
1459 |
++ /* |
1460 |
++ * ignore out-of-order messages or messages that are part of a |
1461 |
++ * failed transaction |
1462 |
++ */ |
1463 |
++ if (!recv_hdr.somt && !msg->have_somt) |
1464 |
++ return false; |
1465 |
++ |
1466 |
+ /* get length contained in this portion */ |
1467 |
+ msg->curchunk_len = recv_hdr.msg_len; |
1468 |
+ msg->curchunk_hdrlen = hdrlen; |
1469 |
+@@ -2161,7 +2168,7 @@ out_unlock: |
1470 |
+ } |
1471 |
+ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_resume); |
1472 |
+ |
1473 |
+-static void drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up) |
1474 |
++static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up) |
1475 |
+ { |
1476 |
+ int len; |
1477 |
+ u8 replyblock[32]; |
1478 |
+@@ -2176,12 +2183,12 @@ static void drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up) |
1479 |
+ replyblock, len); |
1480 |
+ if (ret != len) { |
1481 |
+ DRM_DEBUG_KMS("failed to read DPCD down rep %d %d\n", len, ret); |
1482 |
+- return; |
1483 |
++ return false; |
1484 |
+ } |
1485 |
+ ret = drm_dp_sideband_msg_build(msg, replyblock, len, true); |
1486 |
+ if (!ret) { |
1487 |
+ DRM_DEBUG_KMS("sideband msg build failed %d\n", replyblock[0]); |
1488 |
+- return; |
1489 |
++ return false; |
1490 |
+ } |
1491 |
+ replylen = msg->curchunk_len + msg->curchunk_hdrlen; |
1492 |
+ |
1493 |
+@@ -2193,21 +2200,32 @@ static void drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up) |
1494 |
+ ret = drm_dp_dpcd_read(mgr->aux, basereg + curreply, |
1495 |
+ replyblock, len); |
1496 |
+ if (ret != len) { |
1497 |
+- DRM_DEBUG_KMS("failed to read a chunk\n"); |
1498 |
++ DRM_DEBUG_KMS("failed to read a chunk (len %d, ret %d)\n", |
1499 |
++ len, ret); |
1500 |
++ return false; |
1501 |
+ } |
1502 |
++ |
1503 |
+ ret = drm_dp_sideband_msg_build(msg, replyblock, len, false); |
1504 |
+- if (ret == false) |
1505 |
++ if (!ret) { |
1506 |
+ DRM_DEBUG_KMS("failed to build sideband msg\n"); |
1507 |
++ return false; |
1508 |
++ } |
1509 |
++ |
1510 |
+ curreply += len; |
1511 |
+ replylen -= len; |
1512 |
+ } |
1513 |
++ return true; |
1514 |
+ } |
1515 |
+ |
1516 |
+ static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr) |
1517 |
+ { |
1518 |
+ int ret = 0; |
1519 |
+ |
1520 |
+- drm_dp_get_one_sb_msg(mgr, false); |
1521 |
++ if (!drm_dp_get_one_sb_msg(mgr, false)) { |
1522 |
++ memset(&mgr->down_rep_recv, 0, |
1523 |
++ sizeof(struct drm_dp_sideband_msg_rx)); |
1524 |
++ return 0; |
1525 |
++ } |
1526 |
+ |
1527 |
+ if (mgr->down_rep_recv.have_eomt) { |
1528 |
+ struct drm_dp_sideband_msg_tx *txmsg; |
1529 |
+@@ -2263,7 +2281,12 @@ static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr) |
1530 |
+ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr) |
1531 |
+ { |
1532 |
+ int ret = 0; |
1533 |
+- drm_dp_get_one_sb_msg(mgr, true); |
1534 |
++ |
1535 |
++ if (!drm_dp_get_one_sb_msg(mgr, true)) { |
1536 |
++ memset(&mgr->up_req_recv, 0, |
1537 |
++ sizeof(struct drm_dp_sideband_msg_rx)); |
1538 |
++ return 0; |
1539 |
++ } |
1540 |
+ |
1541 |
+ if (mgr->up_req_recv.have_eomt) { |
1542 |
+ struct drm_dp_sideband_msg_req_body msg; |
1543 |
+@@ -2315,7 +2338,9 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr) |
1544 |
+ DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn); |
1545 |
+ } |
1546 |
+ |
1547 |
+- drm_dp_put_mst_branch_device(mstb); |
1548 |
++ if (mstb) |
1549 |
++ drm_dp_put_mst_branch_device(mstb); |
1550 |
++ |
1551 |
+ memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); |
1552 |
+ } |
1553 |
+ return ret; |
1554 |
+diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c |
1555 |
+index bbdcab0a56c1..3401df5b44db 100644 |
1556 |
+--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c |
1557 |
++++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c |
1558 |
+@@ -193,7 +193,14 @@ int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, |
1559 |
+ void adreno_flush(struct msm_gpu *gpu) |
1560 |
+ { |
1561 |
+ struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); |
1562 |
+- uint32_t wptr = get_wptr(gpu->rb); |
1563 |
++ uint32_t wptr; |
1564 |
++ |
1565 |
++ /* |
1566 |
++ * Mask wptr value that we calculate to fit in the HW range. This is |
1567 |
++ * to account for the possibility that the last command fit exactly into |
1568 |
++ * the ringbuffer and rb->next hasn't wrapped to zero yet |
1569 |
++ */ |
1570 |
++ wptr = get_wptr(gpu->rb) & ((gpu->rb->size / 4) - 1); |
1571 |
+ |
1572 |
+ /* ensure writes to ringbuffer have hit system memory: */ |
1573 |
+ mb(); |
1574 |
+diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c |
1575 |
+index 4ff8c334e7c8..4a45ae01cc3e 100644 |
1576 |
+--- a/drivers/gpu/drm/msm/msm_gem_submit.c |
1577 |
++++ b/drivers/gpu/drm/msm/msm_gem_submit.c |
1578 |
+@@ -90,7 +90,8 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, |
1579 |
+ pagefault_disable(); |
1580 |
+ } |
1581 |
+ |
1582 |
+- if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { |
1583 |
++ if ((submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) || |
1584 |
++ !(submit_bo.flags & MSM_SUBMIT_BO_FLAGS)) { |
1585 |
+ DRM_ERROR("invalid flags: %x\n", submit_bo.flags); |
1586 |
+ ret = -EINVAL; |
1587 |
+ goto out_unlock; |
1588 |
+diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c |
1589 |
+index 1f14b908b221..ae317271cf81 100644 |
1590 |
+--- a/drivers/gpu/drm/msm/msm_ringbuffer.c |
1591 |
++++ b/drivers/gpu/drm/msm/msm_ringbuffer.c |
1592 |
+@@ -23,7 +23,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size) |
1593 |
+ struct msm_ringbuffer *ring; |
1594 |
+ int ret; |
1595 |
+ |
1596 |
+- size = ALIGN(size, 4); /* size should be dword aligned */ |
1597 |
++ if (WARN_ON(!is_power_of_2(size))) |
1598 |
++ return ERR_PTR(-EINVAL); |
1599 |
+ |
1600 |
+ ring = kzalloc(sizeof(*ring), GFP_KERNEL); |
1601 |
+ if (!ring) { |
1602 |
+diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c |
1603 |
+index d4ac8c837314..8e86cf7da614 100644 |
1604 |
+--- a/drivers/gpu/drm/radeon/atombios_encoders.c |
1605 |
++++ b/drivers/gpu/drm/radeon/atombios_encoders.c |
1606 |
+@@ -30,6 +30,7 @@ |
1607 |
+ #include "radeon_audio.h" |
1608 |
+ #include "atom.h" |
1609 |
+ #include <linux/backlight.h> |
1610 |
++#include <linux/dmi.h> |
1611 |
+ |
1612 |
+ extern int atom_debug; |
1613 |
+ |
1614 |
+@@ -2183,9 +2184,17 @@ int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder, int fe_idx) |
1615 |
+ goto assigned; |
1616 |
+ } |
1617 |
+ |
1618 |
+- /* on DCE32 and encoder can driver any block so just crtc id */ |
1619 |
++ /* |
1620 |
++ * On DCE32 any encoder can drive any block so usually just use crtc id, |
1621 |
++ * but Apple thinks different at least on iMac10,1, so there use linkb, |
1622 |
++ * otherwise the internal eDP panel will stay dark. |
1623 |
++ */ |
1624 |
+ if (ASIC_IS_DCE32(rdev)) { |
1625 |
+- enc_idx = radeon_crtc->crtc_id; |
1626 |
++ if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1")) |
1627 |
++ enc_idx = (dig->linkb) ? 1 : 0; |
1628 |
++ else |
1629 |
++ enc_idx = radeon_crtc->crtc_id; |
1630 |
++ |
1631 |
+ goto assigned; |
1632 |
+ } |
1633 |
+ |
1634 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
1635 |
+index 7d0b8ef9bea2..7c6f15d284e3 100644 |
1636 |
+--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
1637 |
++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
1638 |
+@@ -277,26 +277,6 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc) |
1639 |
+ * Page Flip |
1640 |
+ */ |
1641 |
+ |
1642 |
+-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc, |
1643 |
+- struct drm_file *file) |
1644 |
+-{ |
1645 |
+- struct drm_pending_vblank_event *event; |
1646 |
+- struct drm_device *dev = rcrtc->crtc.dev; |
1647 |
+- unsigned long flags; |
1648 |
+- |
1649 |
+- /* Destroy the pending vertical blanking event associated with the |
1650 |
+- * pending page flip, if any, and disable vertical blanking interrupts. |
1651 |
+- */ |
1652 |
+- spin_lock_irqsave(&dev->event_lock, flags); |
1653 |
+- event = rcrtc->event; |
1654 |
+- if (event && event->base.file_priv == file) { |
1655 |
+- rcrtc->event = NULL; |
1656 |
+- event->base.destroy(&event->base); |
1657 |
+- drm_crtc_vblank_put(&rcrtc->crtc); |
1658 |
+- } |
1659 |
+- spin_unlock_irqrestore(&dev->event_lock, flags); |
1660 |
+-} |
1661 |
+- |
1662 |
+ static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc) |
1663 |
+ { |
1664 |
+ struct drm_pending_vblank_event *event; |
1665 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h |
1666 |
+index 5d9aa9b33769..0d61a813054a 100644 |
1667 |
+--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h |
1668 |
++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h |
1669 |
+@@ -53,8 +53,6 @@ enum rcar_du_output { |
1670 |
+ |
1671 |
+ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index); |
1672 |
+ void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable); |
1673 |
+-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc, |
1674 |
+- struct drm_file *file); |
1675 |
+ void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc); |
1676 |
+ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc); |
1677 |
+ |
1678 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c |
1679 |
+index da1216a73969..94133c3ffe20 100644 |
1680 |
+--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c |
1681 |
++++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c |
1682 |
+@@ -205,15 +205,6 @@ done: |
1683 |
+ return ret; |
1684 |
+ } |
1685 |
+ |
1686 |
+-static void rcar_du_preclose(struct drm_device *dev, struct drm_file *file) |
1687 |
+-{ |
1688 |
+- struct rcar_du_device *rcdu = dev->dev_private; |
1689 |
+- unsigned int i; |
1690 |
+- |
1691 |
+- for (i = 0; i < rcdu->num_crtcs; ++i) |
1692 |
+- rcar_du_crtc_cancel_page_flip(&rcdu->crtcs[i], file); |
1693 |
+-} |
1694 |
+- |
1695 |
+ static void rcar_du_lastclose(struct drm_device *dev) |
1696 |
+ { |
1697 |
+ struct rcar_du_device *rcdu = dev->dev_private; |
1698 |
+@@ -256,7 +247,6 @@ static struct drm_driver rcar_du_driver = { |
1699 |
+ | DRIVER_ATOMIC, |
1700 |
+ .load = rcar_du_load, |
1701 |
+ .unload = rcar_du_unload, |
1702 |
+- .preclose = rcar_du_preclose, |
1703 |
+ .lastclose = rcar_du_lastclose, |
1704 |
+ .set_busid = drm_platform_set_busid, |
1705 |
+ .get_vblank_counter = drm_vblank_count, |
1706 |
+diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |
1707 |
+index aee1c6ccc52d..6c312b584802 100644 |
1708 |
+--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |
1709 |
++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |
1710 |
+@@ -285,7 +285,7 @@ static int vmw_cmd_invalid(struct vmw_private *dev_priv, |
1711 |
+ struct vmw_sw_context *sw_context, |
1712 |
+ SVGA3dCmdHeader *header) |
1713 |
+ { |
1714 |
+- return capable(CAP_SYS_ADMIN) ? : -EINVAL; |
1715 |
++ return -EINVAL; |
1716 |
+ } |
1717 |
+ |
1718 |
+ static int vmw_cmd_ok(struct vmw_private *dev_priv, |
1719 |
+diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c |
1720 |
+index 07a963039b60..d786b48f5d7b 100644 |
1721 |
+--- a/drivers/hid/hid-core.c |
1722 |
++++ b/drivers/hid/hid-core.c |
1723 |
+@@ -2391,6 +2391,7 @@ static const struct hid_device_id hid_ignore_list[] = { |
1724 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, |
1725 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, |
1726 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, |
1727 |
++ { HID_USB_DEVICE(USB_VENDOR_ID_PETZL, USB_DEVICE_ID_PETZL_HEADLAMP) }, |
1728 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, |
1729 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, |
1730 |
+ #if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE) |
1731 |
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h |
1732 |
+index 7ce93d927f62..e995058ad264 100644 |
1733 |
+--- a/drivers/hid/hid-ids.h |
1734 |
++++ b/drivers/hid/hid-ids.h |
1735 |
+@@ -760,6 +760,9 @@ |
1736 |
+ #define USB_VENDOR_ID_PETALYNX 0x18b1 |
1737 |
+ #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 |
1738 |
+ |
1739 |
++#define USB_VENDOR_ID_PETZL 0x2122 |
1740 |
++#define USB_DEVICE_ID_PETZL_HEADLAMP 0x1234 |
1741 |
++ |
1742 |
+ #define USB_VENDOR_ID_PHILIPS 0x0471 |
1743 |
+ #define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617 |
1744 |
+ |
1745 |
+diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c |
1746 |
+index 56292ae4538d..9bcad9a444f7 100644 |
1747 |
+--- a/drivers/iio/adc/vf610_adc.c |
1748 |
++++ b/drivers/iio/adc/vf610_adc.c |
1749 |
+@@ -71,7 +71,7 @@ |
1750 |
+ #define VF610_ADC_ADSTS_MASK 0x300 |
1751 |
+ #define VF610_ADC_ADLPC_EN 0x80 |
1752 |
+ #define VF610_ADC_ADHSC_EN 0x400 |
1753 |
+-#define VF610_ADC_REFSEL_VALT 0x100 |
1754 |
++#define VF610_ADC_REFSEL_VALT 0x800 |
1755 |
+ #define VF610_ADC_REFSEL_VBG 0x1000 |
1756 |
+ #define VF610_ADC_ADTRG_HARD 0x2000 |
1757 |
+ #define VF610_ADC_AVGS_8 0x4000 |
1758 |
+diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c |
1759 |
+index 94daa9fc1247..6a135effb7c5 100644 |
1760 |
+--- a/drivers/iio/light/tsl2563.c |
1761 |
++++ b/drivers/iio/light/tsl2563.c |
1762 |
+@@ -626,7 +626,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) |
1763 |
+ struct tsl2563_chip *chip = iio_priv(dev_info); |
1764 |
+ |
1765 |
+ iio_push_event(dev_info, |
1766 |
+- IIO_UNMOD_EVENT_CODE(IIO_LIGHT, |
1767 |
++ IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, |
1768 |
+ 0, |
1769 |
+ IIO_EV_TYPE_THRESH, |
1770 |
+ IIO_EV_DIR_EITHER), |
1771 |
+diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c |
1772 |
+index b52a704c3449..2d515a544f33 100644 |
1773 |
+--- a/drivers/infiniband/ulp/isert/ib_isert.c |
1774 |
++++ b/drivers/infiniband/ulp/isert/ib_isert.c |
1775 |
+@@ -1586,7 +1586,7 @@ isert_rcv_completion(struct iser_rx_desc *desc, |
1776 |
+ struct isert_conn *isert_conn, |
1777 |
+ u32 xfer_len) |
1778 |
+ { |
1779 |
+- struct ib_device *ib_dev = isert_conn->cm_id->device; |
1780 |
++ struct ib_device *ib_dev = isert_conn->device->ib_device; |
1781 |
+ struct iscsi_hdr *hdr; |
1782 |
+ u64 rx_dma; |
1783 |
+ int rx_buflen, outstanding; |
1784 |
+diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c |
1785 |
+index 4cfb0ac797ef..6f15cdf5ff40 100644 |
1786 |
+--- a/drivers/input/serio/i8042.c |
1787 |
++++ b/drivers/input/serio/i8042.c |
1788 |
+@@ -397,8 +397,10 @@ static int i8042_start(struct serio *serio) |
1789 |
+ { |
1790 |
+ struct i8042_port *port = serio->port_data; |
1791 |
+ |
1792 |
++ spin_lock_irq(&i8042_lock); |
1793 |
+ port->exists = true; |
1794 |
+- mb(); |
1795 |
++ spin_unlock_irq(&i8042_lock); |
1796 |
++ |
1797 |
+ return 0; |
1798 |
+ } |
1799 |
+ |
1800 |
+@@ -411,16 +413,20 @@ static void i8042_stop(struct serio *serio) |
1801 |
+ { |
1802 |
+ struct i8042_port *port = serio->port_data; |
1803 |
+ |
1804 |
++ spin_lock_irq(&i8042_lock); |
1805 |
+ port->exists = false; |
1806 |
++ port->serio = NULL; |
1807 |
++ spin_unlock_irq(&i8042_lock); |
1808 |
+ |
1809 |
+ /* |
1810 |
++ * We need to make sure that interrupt handler finishes using |
1811 |
++ * our serio port before we return from this function. |
1812 |
+ * We synchronize with both AUX and KBD IRQs because there is |
1813 |
+ * a (very unlikely) chance that AUX IRQ is raised for KBD port |
1814 |
+ * and vice versa. |
1815 |
+ */ |
1816 |
+ synchronize_irq(I8042_AUX_IRQ); |
1817 |
+ synchronize_irq(I8042_KBD_IRQ); |
1818 |
+- port->serio = NULL; |
1819 |
+ } |
1820 |
+ |
1821 |
+ /* |
1822 |
+@@ -537,7 +543,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) |
1823 |
+ |
1824 |
+ spin_unlock_irqrestore(&i8042_lock, flags); |
1825 |
+ |
1826 |
+- if (likely(port->exists && !filtered)) |
1827 |
++ if (likely(serio && !filtered)) |
1828 |
+ serio_interrupt(serio, data, dfl); |
1829 |
+ |
1830 |
+ out: |
1831 |
+diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c |
1832 |
+index 9c1e8adaf4fc..bf3fbd00a091 100644 |
1833 |
+--- a/drivers/isdn/i4l/isdn_ppp.c |
1834 |
++++ b/drivers/isdn/i4l/isdn_ppp.c |
1835 |
+@@ -2364,7 +2364,7 @@ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_s |
1836 |
+ id); |
1837 |
+ return NULL; |
1838 |
+ } else { |
1839 |
+- rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL); |
1840 |
++ rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_ATOMIC); |
1841 |
+ if (!rs) |
1842 |
+ return NULL; |
1843 |
+ rs->state = CCPResetIdle; |
1844 |
+diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c |
1845 |
+index 19b491d2964f..ac6087f77e08 100644 |
1846 |
+--- a/drivers/mailbox/mailbox.c |
1847 |
++++ b/drivers/mailbox/mailbox.c |
1848 |
+@@ -104,11 +104,14 @@ static void tx_tick(struct mbox_chan *chan, int r) |
1849 |
+ /* Submit next message */ |
1850 |
+ msg_submit(chan); |
1851 |
+ |
1852 |
++ if (!mssg) |
1853 |
++ return; |
1854 |
++ |
1855 |
+ /* Notify the client */ |
1856 |
+- if (mssg && chan->cl->tx_done) |
1857 |
++ if (chan->cl->tx_done) |
1858 |
+ chan->cl->tx_done(chan->cl, mssg, r); |
1859 |
+ |
1860 |
+- if (chan->cl->tx_block) |
1861 |
++ if (r != -ETIME && chan->cl->tx_block) |
1862 |
+ complete(&chan->tx_complete); |
1863 |
+ } |
1864 |
+ |
1865 |
+@@ -258,7 +261,7 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) |
1866 |
+ |
1867 |
+ msg_submit(chan); |
1868 |
+ |
1869 |
+- if (chan->cl->tx_block && chan->active_req) { |
1870 |
++ if (chan->cl->tx_block) { |
1871 |
+ unsigned long wait; |
1872 |
+ int ret; |
1873 |
+ |
1874 |
+@@ -269,8 +272,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) |
1875 |
+ |
1876 |
+ ret = wait_for_completion_timeout(&chan->tx_complete, wait); |
1877 |
+ if (ret == 0) { |
1878 |
+- t = -EIO; |
1879 |
+- tx_tick(chan, -EIO); |
1880 |
++ t = -ETIME; |
1881 |
++ tx_tick(chan, t); |
1882 |
+ } |
1883 |
+ } |
1884 |
+ |
1885 |
+diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c |
1886 |
+index 2b4e51c0544c..bf29edd8e8ee 100644 |
1887 |
+--- a/drivers/md/raid1.c |
1888 |
++++ b/drivers/md/raid1.c |
1889 |
+@@ -1118,7 +1118,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) |
1890 |
+ */ |
1891 |
+ DEFINE_WAIT(w); |
1892 |
+ for (;;) { |
1893 |
+- flush_signals(current); |
1894 |
++ sigset_t full, old; |
1895 |
+ prepare_to_wait(&conf->wait_barrier, |
1896 |
+ &w, TASK_INTERRUPTIBLE); |
1897 |
+ if (bio_end_sector(bio) <= mddev->suspend_lo || |
1898 |
+@@ -1127,7 +1127,10 @@ static void make_request(struct mddev *mddev, struct bio * bio) |
1899 |
+ !md_cluster_ops->area_resyncing(mddev, |
1900 |
+ bio->bi_iter.bi_sector, bio_end_sector(bio)))) |
1901 |
+ break; |
1902 |
++ sigfillset(&full); |
1903 |
++ sigprocmask(SIG_BLOCK, &full, &old); |
1904 |
+ schedule(); |
1905 |
++ sigprocmask(SIG_SETMASK, &old, NULL); |
1906 |
+ } |
1907 |
+ finish_wait(&conf->wait_barrier, &w); |
1908 |
+ } |
1909 |
+diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c |
1910 |
+index d7942cbaa1b0..69542a92e4b0 100644 |
1911 |
+--- a/drivers/md/raid5.c |
1912 |
++++ b/drivers/md/raid5.c |
1913 |
+@@ -5275,12 +5275,15 @@ static void make_request(struct mddev *mddev, struct bio * bi) |
1914 |
+ * userspace, we want an interruptible |
1915 |
+ * wait. |
1916 |
+ */ |
1917 |
+- flush_signals(current); |
1918 |
+ prepare_to_wait(&conf->wait_for_overlap, |
1919 |
+ &w, TASK_INTERRUPTIBLE); |
1920 |
+ if (logical_sector >= mddev->suspend_lo && |
1921 |
+ logical_sector < mddev->suspend_hi) { |
1922 |
++ sigset_t full, old; |
1923 |
++ sigfillset(&full); |
1924 |
++ sigprocmask(SIG_BLOCK, &full, &old); |
1925 |
+ schedule(); |
1926 |
++ sigprocmask(SIG_SETMASK, &old, NULL); |
1927 |
+ do_prepare = true; |
1928 |
+ } |
1929 |
+ goto retry; |
1930 |
+@@ -5796,6 +5799,8 @@ static void raid5_do_work(struct work_struct *work) |
1931 |
+ pr_debug("%d stripes handled\n", handled); |
1932 |
+ |
1933 |
+ spin_unlock_irq(&conf->device_lock); |
1934 |
++ |
1935 |
++ async_tx_issue_pending_all(); |
1936 |
+ blk_finish_plug(&plug); |
1937 |
+ |
1938 |
+ pr_debug("--- raid5worker inactive\n"); |
1939 |
+@@ -7441,12 +7446,10 @@ static void end_reshape(struct r5conf *conf) |
1940 |
+ { |
1941 |
+ |
1942 |
+ if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { |
1943 |
+- struct md_rdev *rdev; |
1944 |
+ |
1945 |
+ spin_lock_irq(&conf->device_lock); |
1946 |
+ conf->previous_raid_disks = conf->raid_disks; |
1947 |
+- rdev_for_each(rdev, conf->mddev) |
1948 |
+- rdev->data_offset = rdev->new_data_offset; |
1949 |
++ md_finish_reshape(conf->mddev); |
1950 |
+ smp_wmb(); |
1951 |
+ conf->reshape_progress = MaxSector; |
1952 |
+ spin_unlock_irq(&conf->device_lock); |
1953 |
+diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c |
1954 |
+index 8001cde1db1e..503135a4f47a 100644 |
1955 |
+--- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c |
1956 |
++++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c |
1957 |
+@@ -211,7 +211,7 @@ static int s5c73m3_3a_lock(struct s5c73m3 *state, struct v4l2_ctrl *ctrl) |
1958 |
+ } |
1959 |
+ |
1960 |
+ if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS) |
1961 |
+- ret = s5c73m3_af_run(state, ~af_lock); |
1962 |
++ ret = s5c73m3_af_run(state, !af_lock); |
1963 |
+ |
1964 |
+ return ret; |
1965 |
+ } |
1966 |
+diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c |
1967 |
+index 8f2556ec3971..61611d1682d1 100644 |
1968 |
+--- a/drivers/media/pci/cx88/cx88-cards.c |
1969 |
++++ b/drivers/media/pci/cx88/cx88-cards.c |
1970 |
+@@ -3691,7 +3691,14 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) |
1971 |
+ core->nr = nr; |
1972 |
+ sprintf(core->name, "cx88[%d]", core->nr); |
1973 |
+ |
1974 |
+- core->tvnorm = V4L2_STD_NTSC_M; |
1975 |
++ /* |
1976 |
++ * Note: Setting initial standard here would cause first call to |
1977 |
++ * cx88_set_tvnorm() to return without programming any registers. Leave |
1978 |
++ * it blank for at this point and it will get set later in |
1979 |
++ * cx8800_initdev() |
1980 |
++ */ |
1981 |
++ core->tvnorm = 0; |
1982 |
++ |
1983 |
+ core->width = 320; |
1984 |
+ core->height = 240; |
1985 |
+ core->field = V4L2_FIELD_INTERLACED; |
1986 |
+diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c |
1987 |
+index c9decd80bf61..53073def2bec 100644 |
1988 |
+--- a/drivers/media/pci/cx88/cx88-video.c |
1989 |
++++ b/drivers/media/pci/cx88/cx88-video.c |
1990 |
+@@ -1429,7 +1429,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, |
1991 |
+ |
1992 |
+ /* initial device configuration */ |
1993 |
+ mutex_lock(&core->lock); |
1994 |
+- cx88_set_tvnorm(core, core->tvnorm); |
1995 |
++ cx88_set_tvnorm(core, V4L2_STD_NTSC_M); |
1996 |
+ v4l2_ctrl_handler_setup(&core->video_hdl); |
1997 |
+ v4l2_ctrl_handler_setup(&core->audio_hdl); |
1998 |
+ cx88_video_mux(core, 0); |
1999 |
+diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c |
2000 |
+index 6c73f5b155f6..1c779ea8b5ec 100644 |
2001 |
+--- a/drivers/media/pci/saa7164/saa7164-bus.c |
2002 |
++++ b/drivers/media/pci/saa7164/saa7164-bus.c |
2003 |
+@@ -393,11 +393,11 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, |
2004 |
+ msg_tmp.size = le16_to_cpu((__force __le16)msg_tmp.size); |
2005 |
+ msg_tmp.command = le32_to_cpu((__force __le32)msg_tmp.command); |
2006 |
+ msg_tmp.controlselector = le16_to_cpu((__force __le16)msg_tmp.controlselector); |
2007 |
++ memcpy(msg, &msg_tmp, sizeof(*msg)); |
2008 |
+ |
2009 |
+ /* No need to update the read positions, because this was a peek */ |
2010 |
+ /* If the caller specifically want to peek, return */ |
2011 |
+ if (peekonly) { |
2012 |
+- memcpy(msg, &msg_tmp, sizeof(*msg)); |
2013 |
+ goto peekout; |
2014 |
+ } |
2015 |
+ |
2016 |
+@@ -442,21 +442,15 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, |
2017 |
+ space_rem = bus->m_dwSizeGetRing - curr_grp; |
2018 |
+ |
2019 |
+ if (space_rem < sizeof(*msg)) { |
2020 |
+- /* msg wraps around the ring */ |
2021 |
+- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem); |
2022 |
+- memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing, |
2023 |
+- sizeof(*msg) - space_rem); |
2024 |
+ if (buf) |
2025 |
+ memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) - |
2026 |
+ space_rem, buf_size); |
2027 |
+ |
2028 |
+ } else if (space_rem == sizeof(*msg)) { |
2029 |
+- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
2030 |
+ if (buf) |
2031 |
+ memcpy_fromio(buf, bus->m_pdwGetRing, buf_size); |
2032 |
+ } else { |
2033 |
+ /* Additional data wraps around the ring */ |
2034 |
+- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
2035 |
+ if (buf) { |
2036 |
+ memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + |
2037 |
+ sizeof(*msg), space_rem - sizeof(*msg)); |
2038 |
+@@ -469,15 +463,10 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, |
2039 |
+ |
2040 |
+ } else { |
2041 |
+ /* No wrapping */ |
2042 |
+- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
2043 |
+ if (buf) |
2044 |
+ memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), |
2045 |
+ buf_size); |
2046 |
+ } |
2047 |
+- /* Convert from little endian to CPU */ |
2048 |
+- msg->size = le16_to_cpu((__force __le16)msg->size); |
2049 |
+- msg->command = le32_to_cpu((__force __le32)msg->command); |
2050 |
+- msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); |
2051 |
+ |
2052 |
+ /* Update the read positions, adjusting the ring */ |
2053 |
+ saa7164_writel(bus->m_dwGetReadPos, new_grp); |
2054 |
+diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c |
2055 |
+index ccfcf3f528d3..445e17aeb8b2 100644 |
2056 |
+--- a/drivers/media/platform/davinci/vpfe_capture.c |
2057 |
++++ b/drivers/media/platform/davinci/vpfe_capture.c |
2058 |
+@@ -1706,27 +1706,9 @@ static long vpfe_param_handler(struct file *file, void *priv, |
2059 |
+ |
2060 |
+ switch (cmd) { |
2061 |
+ case VPFE_CMD_S_CCDC_RAW_PARAMS: |
2062 |
++ ret = -EINVAL; |
2063 |
+ v4l2_warn(&vpfe_dev->v4l2_dev, |
2064 |
+- "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n"); |
2065 |
+- if (ccdc_dev->hw_ops.set_params) { |
2066 |
+- ret = ccdc_dev->hw_ops.set_params(param); |
2067 |
+- if (ret) { |
2068 |
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, |
2069 |
+- "Error setting parameters in CCDC\n"); |
2070 |
+- goto unlock_out; |
2071 |
+- } |
2072 |
+- ret = vpfe_get_ccdc_image_format(vpfe_dev, |
2073 |
+- &vpfe_dev->fmt); |
2074 |
+- if (ret < 0) { |
2075 |
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, |
2076 |
+- "Invalid image format at CCDC\n"); |
2077 |
+- goto unlock_out; |
2078 |
+- } |
2079 |
+- } else { |
2080 |
+- ret = -EINVAL; |
2081 |
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, |
2082 |
+- "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n"); |
2083 |
+- } |
2084 |
++ "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n"); |
2085 |
+ break; |
2086 |
+ default: |
2087 |
+ ret = -ENOTTY; |
2088 |
+diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c |
2089 |
+index 65f80b8b9f7a..eb9e7feb9b13 100644 |
2090 |
+--- a/drivers/media/rc/imon.c |
2091 |
++++ b/drivers/media/rc/imon.c |
2092 |
+@@ -1629,7 +1629,7 @@ static void imon_incoming_packet(struct imon_context *ictx, |
2093 |
+ if (kc == KEY_KEYBOARD && !ictx->release_code) { |
2094 |
+ ictx->last_keycode = kc; |
2095 |
+ if (!nomouse) { |
2096 |
+- ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1; |
2097 |
++ ictx->pad_mouse = !ictx->pad_mouse; |
2098 |
+ dev_dbg(dev, "toggling to %s mode\n", |
2099 |
+ ictx->pad_mouse ? "mouse" : "keyboard"); |
2100 |
+ spin_unlock_irqrestore(&ictx->kc_lock, flags); |
2101 |
+diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c |
2102 |
+index 98893a8332c7..4795c31ceebc 100644 |
2103 |
+--- a/drivers/media/rc/ir-lirc-codec.c |
2104 |
++++ b/drivers/media/rc/ir-lirc-codec.c |
2105 |
+@@ -257,7 +257,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, |
2106 |
+ return 0; |
2107 |
+ |
2108 |
+ case LIRC_GET_REC_RESOLUTION: |
2109 |
+- val = dev->rx_resolution; |
2110 |
++ val = dev->rx_resolution / 1000; |
2111 |
+ break; |
2112 |
+ |
2113 |
+ case LIRC_SET_WIDEBAND_RECEIVER: |
2114 |
+diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c |
2115 |
+index 65fed7146e9b..cc91f7b3d90c 100644 |
2116 |
+--- a/drivers/misc/enclosure.c |
2117 |
++++ b/drivers/misc/enclosure.c |
2118 |
+@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component, |
2119 |
+ struct device *dev) |
2120 |
+ { |
2121 |
+ struct enclosure_component *cdev; |
2122 |
++ int err; |
2123 |
+ |
2124 |
+ if (!edev || component >= edev->components) |
2125 |
+ return -EINVAL; |
2126 |
+@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device *edev, int component, |
2127 |
+ if (cdev->dev == dev) |
2128 |
+ return -EEXIST; |
2129 |
+ |
2130 |
+- if (cdev->dev) |
2131 |
++ if (cdev->dev) { |
2132 |
+ enclosure_remove_links(cdev); |
2133 |
+- |
2134 |
+- put_device(cdev->dev); |
2135 |
++ put_device(cdev->dev); |
2136 |
++ } |
2137 |
+ cdev->dev = get_device(dev); |
2138 |
+- return enclosure_add_links(cdev); |
2139 |
++ err = enclosure_add_links(cdev); |
2140 |
++ if (err) { |
2141 |
++ put_device(cdev->dev); |
2142 |
++ cdev->dev = NULL; |
2143 |
++ } |
2144 |
++ return err; |
2145 |
+ } |
2146 |
+ EXPORT_SYMBOL_GPL(enclosure_add_device); |
2147 |
+ |
2148 |
+diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c |
2149 |
+index 5d5d36272bb5..448123268e3b 100644 |
2150 |
+--- a/drivers/mtd/spi-nor/fsl-quadspi.c |
2151 |
++++ b/drivers/mtd/spi-nor/fsl-quadspi.c |
2152 |
+@@ -140,15 +140,15 @@ |
2153 |
+ #define LUT_MODE 4 |
2154 |
+ #define LUT_MODE2 5 |
2155 |
+ #define LUT_MODE4 6 |
2156 |
+-#define LUT_READ 7 |
2157 |
+-#define LUT_WRITE 8 |
2158 |
++#define LUT_FSL_READ 7 |
2159 |
++#define LUT_FSL_WRITE 8 |
2160 |
+ #define LUT_JMP_ON_CS 9 |
2161 |
+ #define LUT_ADDR_DDR 10 |
2162 |
+ #define LUT_MODE_DDR 11 |
2163 |
+ #define LUT_MODE2_DDR 12 |
2164 |
+ #define LUT_MODE4_DDR 13 |
2165 |
+-#define LUT_READ_DDR 14 |
2166 |
+-#define LUT_WRITE_DDR 15 |
2167 |
++#define LUT_FSL_READ_DDR 14 |
2168 |
++#define LUT_FSL_WRITE_DDR 15 |
2169 |
+ #define LUT_DATA_LEARN 16 |
2170 |
+ |
2171 |
+ /* |
2172 |
+@@ -312,7 +312,7 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) |
2173 |
+ |
2174 |
+ writel(LUT0(CMD, PAD1, cmd) | LUT1(ADDR, PAD1, addrlen), |
2175 |
+ base + QUADSPI_LUT(lut_base)); |
2176 |
+- writel(LUT0(DUMMY, PAD1, dummy) | LUT1(READ, PAD4, rxfifo), |
2177 |
++ writel(LUT0(DUMMY, PAD1, dummy) | LUT1(FSL_READ, PAD4, rxfifo), |
2178 |
+ base + QUADSPI_LUT(lut_base + 1)); |
2179 |
+ |
2180 |
+ /* Write enable */ |
2181 |
+@@ -333,11 +333,11 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) |
2182 |
+ |
2183 |
+ writel(LUT0(CMD, PAD1, cmd) | LUT1(ADDR, PAD1, addrlen), |
2184 |
+ base + QUADSPI_LUT(lut_base)); |
2185 |
+- writel(LUT0(WRITE, PAD1, 0), base + QUADSPI_LUT(lut_base + 1)); |
2186 |
++ writel(LUT0(FSL_WRITE, PAD1, 0), base + QUADSPI_LUT(lut_base + 1)); |
2187 |
+ |
2188 |
+ /* Read Status */ |
2189 |
+ lut_base = SEQID_RDSR * 4; |
2190 |
+- writel(LUT0(CMD, PAD1, SPINOR_OP_RDSR) | LUT1(READ, PAD1, 0x1), |
2191 |
++ writel(LUT0(CMD, PAD1, SPINOR_OP_RDSR) | LUT1(FSL_READ, PAD1, 0x1), |
2192 |
+ base + QUADSPI_LUT(lut_base)); |
2193 |
+ |
2194 |
+ /* Erase a sector */ |
2195 |
+@@ -362,17 +362,17 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) |
2196 |
+ |
2197 |
+ /* READ ID */ |
2198 |
+ lut_base = SEQID_RDID * 4; |
2199 |
+- writel(LUT0(CMD, PAD1, SPINOR_OP_RDID) | LUT1(READ, PAD1, 0x8), |
2200 |
++ writel(LUT0(CMD, PAD1, SPINOR_OP_RDID) | LUT1(FSL_READ, PAD1, 0x8), |
2201 |
+ base + QUADSPI_LUT(lut_base)); |
2202 |
+ |
2203 |
+ /* Write Register */ |
2204 |
+ lut_base = SEQID_WRSR * 4; |
2205 |
+- writel(LUT0(CMD, PAD1, SPINOR_OP_WRSR) | LUT1(WRITE, PAD1, 0x2), |
2206 |
++ writel(LUT0(CMD, PAD1, SPINOR_OP_WRSR) | LUT1(FSL_WRITE, PAD1, 0x2), |
2207 |
+ base + QUADSPI_LUT(lut_base)); |
2208 |
+ |
2209 |
+ /* Read Configuration Register */ |
2210 |
+ lut_base = SEQID_RDCR * 4; |
2211 |
+- writel(LUT0(CMD, PAD1, SPINOR_OP_RDCR) | LUT1(READ, PAD1, 0x1), |
2212 |
++ writel(LUT0(CMD, PAD1, SPINOR_OP_RDCR) | LUT1(FSL_READ, PAD1, 0x1), |
2213 |
+ base + QUADSPI_LUT(lut_base)); |
2214 |
+ |
2215 |
+ /* Write disable */ |
2216 |
+diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c |
2217 |
+index 7896f0f1fa05..f9713fe036ef 100644 |
2218 |
+--- a/drivers/net/ethernet/broadcom/tg3.c |
2219 |
++++ b/drivers/net/ethernet/broadcom/tg3.c |
2220 |
+@@ -8722,11 +8722,14 @@ static void tg3_free_consistent(struct tg3 *tp) |
2221 |
+ tg3_mem_rx_release(tp); |
2222 |
+ tg3_mem_tx_release(tp); |
2223 |
+ |
2224 |
++ /* Protect tg3_get_stats64() from reading freed tp->hw_stats. */ |
2225 |
++ tg3_full_lock(tp, 0); |
2226 |
+ if (tp->hw_stats) { |
2227 |
+ dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), |
2228 |
+ tp->hw_stats, tp->stats_mapping); |
2229 |
+ tp->hw_stats = NULL; |
2230 |
+ } |
2231 |
++ tg3_full_unlock(tp); |
2232 |
+ } |
2233 |
+ |
2234 |
+ /* |
2235 |
+diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c |
2236 |
+index 2a9dd460a95f..e1f9e7cebf8f 100644 |
2237 |
+--- a/drivers/net/ethernet/mellanox/mlx4/icm.c |
2238 |
++++ b/drivers/net/ethernet/mellanox/mlx4/icm.c |
2239 |
+@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem, |
2240 |
+ if (!buf) |
2241 |
+ return -ENOMEM; |
2242 |
+ |
2243 |
++ if (offset_in_page(buf)) { |
2244 |
++ dma_free_coherent(dev, PAGE_SIZE << order, |
2245 |
++ buf, sg_dma_address(mem)); |
2246 |
++ return -ENOMEM; |
2247 |
++ } |
2248 |
++ |
2249 |
+ sg_set_buf(mem, buf, PAGE_SIZE << order); |
2250 |
+- BUG_ON(mem->offset); |
2251 |
+ sg_dma_len(mem) = PAGE_SIZE << order; |
2252 |
+ return 0; |
2253 |
+ } |
2254 |
+diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c |
2255 |
+index 3df51faf18ae..af4b1f4c24d2 100644 |
2256 |
+--- a/drivers/net/ethernet/realtek/r8169.c |
2257 |
++++ b/drivers/net/ethernet/realtek/r8169.c |
2258 |
+@@ -326,6 +326,7 @@ enum cfg_version { |
2259 |
+ static const struct pci_device_id rtl8169_pci_tbl[] = { |
2260 |
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, |
2261 |
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, |
2262 |
++ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161), 0, 0, RTL_CFG_1 }, |
2263 |
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, |
2264 |
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 }, |
2265 |
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, |
2266 |
+diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c |
2267 |
+index c93a458f96f7..e2dd94a91c15 100644 |
2268 |
+--- a/drivers/net/ethernet/renesas/sh_eth.c |
2269 |
++++ b/drivers/net/ethernet/renesas/sh_eth.c |
2270 |
+@@ -726,6 +726,7 @@ static struct sh_eth_cpu_data sh7734_data = { |
2271 |
+ .tsu = 1, |
2272 |
+ .hw_crc = 1, |
2273 |
+ .select_mii = 1, |
2274 |
++ .shift_rd0 = 1, |
2275 |
+ }; |
2276 |
+ |
2277 |
+ /* SH7763 */ |
2278 |
+@@ -794,6 +795,7 @@ static struct sh_eth_cpu_data r8a7740_data = { |
2279 |
+ .rpadir_value = 2 << 16, |
2280 |
+ .no_trimd = 1, |
2281 |
+ .no_ade = 1, |
2282 |
++ .hw_crc = 1, |
2283 |
+ .tsu = 1, |
2284 |
+ .select_mii = 1, |
2285 |
+ .shift_rd0 = 1, |
2286 |
+diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c |
2287 |
+index bca6a1e72d1d..e1bb802d4a4d 100644 |
2288 |
+--- a/drivers/net/irda/mcs7780.c |
2289 |
++++ b/drivers/net/irda/mcs7780.c |
2290 |
+@@ -141,9 +141,19 @@ static int mcs_set_reg(struct mcs_cb *mcs, __u16 reg, __u16 val) |
2291 |
+ static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val) |
2292 |
+ { |
2293 |
+ struct usb_device *dev = mcs->usbdev; |
2294 |
+- int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, |
2295 |
+- MCS_RD_RTYPE, 0, reg, val, 2, |
2296 |
+- msecs_to_jiffies(MCS_CTRL_TIMEOUT)); |
2297 |
++ void *dmabuf; |
2298 |
++ int ret; |
2299 |
++ |
2300 |
++ dmabuf = kmalloc(sizeof(__u16), GFP_KERNEL); |
2301 |
++ if (!dmabuf) |
2302 |
++ return -ENOMEM; |
2303 |
++ |
2304 |
++ ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, |
2305 |
++ MCS_RD_RTYPE, 0, reg, dmabuf, 2, |
2306 |
++ msecs_to_jiffies(MCS_CTRL_TIMEOUT)); |
2307 |
++ |
2308 |
++ memcpy(val, dmabuf, sizeof(__u16)); |
2309 |
++ kfree(dmabuf); |
2310 |
+ |
2311 |
+ return ret; |
2312 |
+ } |
2313 |
+diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c |
2314 |
+index 21a668faacd7..1ca78b46c01b 100644 |
2315 |
+--- a/drivers/net/phy/phy.c |
2316 |
++++ b/drivers/net/phy/phy.c |
2317 |
+@@ -512,6 +512,9 @@ void phy_stop_machine(struct phy_device *phydev) |
2318 |
+ if (phydev->state > PHY_UP && phydev->state != PHY_HALTED) |
2319 |
+ phydev->state = PHY_UP; |
2320 |
+ mutex_unlock(&phydev->lock); |
2321 |
++ |
2322 |
++ /* Now we can run the state machine synchronously */ |
2323 |
++ phy_state_machine(&phydev->state_queue.work); |
2324 |
+ } |
2325 |
+ |
2326 |
+ /** |
2327 |
+diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c |
2328 |
+index d551df62e61a..afb87840f853 100644 |
2329 |
+--- a/drivers/net/phy/phy_device.c |
2330 |
++++ b/drivers/net/phy/phy_device.c |
2331 |
+@@ -1281,6 +1281,8 @@ static int phy_remove(struct device *dev) |
2332 |
+ { |
2333 |
+ struct phy_device *phydev = to_phy_device(dev); |
2334 |
+ |
2335 |
++ cancel_delayed_work_sync(&phydev->state_queue); |
2336 |
++ |
2337 |
+ mutex_lock(&phydev->lock); |
2338 |
+ phydev->state = PHY_DOWN; |
2339 |
+ mutex_unlock(&phydev->lock); |
2340 |
+@@ -1355,7 +1357,7 @@ static struct phy_driver genphy_driver[] = { |
2341 |
+ .phy_id = 0xffffffff, |
2342 |
+ .phy_id_mask = 0xffffffff, |
2343 |
+ .name = "Generic PHY", |
2344 |
+- .soft_reset = genphy_soft_reset, |
2345 |
++ .soft_reset = genphy_no_soft_reset, |
2346 |
+ .config_init = genphy_config_init, |
2347 |
+ .features = PHY_GBIT_FEATURES | SUPPORTED_MII | |
2348 |
+ SUPPORTED_AUI | SUPPORTED_FIBRE | |
2349 |
+diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c |
2350 |
+index 1e9cdca37014..c626971096d4 100644 |
2351 |
+--- a/drivers/net/usb/kaweth.c |
2352 |
++++ b/drivers/net/usb/kaweth.c |
2353 |
+@@ -1009,6 +1009,7 @@ static int kaweth_probe( |
2354 |
+ struct net_device *netdev; |
2355 |
+ const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
2356 |
+ int result = 0; |
2357 |
++ int rv = -EIO; |
2358 |
+ |
2359 |
+ dev_dbg(dev, |
2360 |
+ "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", |
2361 |
+@@ -1029,6 +1030,7 @@ static int kaweth_probe( |
2362 |
+ kaweth = netdev_priv(netdev); |
2363 |
+ kaweth->dev = udev; |
2364 |
+ kaweth->net = netdev; |
2365 |
++ kaweth->intf = intf; |
2366 |
+ |
2367 |
+ spin_lock_init(&kaweth->device_lock); |
2368 |
+ init_waitqueue_head(&kaweth->term_wait); |
2369 |
+@@ -1048,6 +1050,10 @@ static int kaweth_probe( |
2370 |
+ /* Download the firmware */ |
2371 |
+ dev_info(dev, "Downloading firmware...\n"); |
2372 |
+ kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); |
2373 |
++ if (!kaweth->firmware_buf) { |
2374 |
++ rv = -ENOMEM; |
2375 |
++ goto err_free_netdev; |
2376 |
++ } |
2377 |
+ if ((result = kaweth_download_firmware(kaweth, |
2378 |
+ "kaweth/new_code.bin", |
2379 |
+ 100, |
2380 |
+@@ -1139,8 +1145,6 @@ err_fw: |
2381 |
+ |
2382 |
+ dev_dbg(dev, "Initializing net device.\n"); |
2383 |
+ |
2384 |
+- kaweth->intf = intf; |
2385 |
+- |
2386 |
+ kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
2387 |
+ if (!kaweth->tx_urb) |
2388 |
+ goto err_free_netdev; |
2389 |
+@@ -1210,7 +1214,7 @@ err_only_tx: |
2390 |
+ err_free_netdev: |
2391 |
+ free_netdev(netdev); |
2392 |
+ |
2393 |
+- return -EIO; |
2394 |
++ return rv; |
2395 |
+ } |
2396 |
+ |
2397 |
+ /**************************************************************** |
2398 |
+diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h |
2399 |
+index c8b64e7a6089..deed8dcfd91a 100644 |
2400 |
+--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h |
2401 |
++++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h |
2402 |
+@@ -562,6 +562,9 @@ ath10k_wmi_vdev_spectral_conf(struct ath10k *ar, |
2403 |
+ struct sk_buff *skb; |
2404 |
+ u32 cmd_id; |
2405 |
+ |
2406 |
++ if (!ar->wmi.ops->gen_vdev_spectral_conf) |
2407 |
++ return -EOPNOTSUPP; |
2408 |
++ |
2409 |
+ skb = ar->wmi.ops->gen_vdev_spectral_conf(ar, arg); |
2410 |
+ if (IS_ERR(skb)) |
2411 |
+ return PTR_ERR(skb); |
2412 |
+@@ -577,6 +580,9 @@ ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger, |
2413 |
+ struct sk_buff *skb; |
2414 |
+ u32 cmd_id; |
2415 |
+ |
2416 |
++ if (!ar->wmi.ops->gen_vdev_spectral_enable) |
2417 |
++ return -EOPNOTSUPP; |
2418 |
++ |
2419 |
+ skb = ar->wmi.ops->gen_vdev_spectral_enable(ar, vdev_id, trigger, |
2420 |
+ enable); |
2421 |
+ if (IS_ERR(skb)) |
2422 |
+diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c |
2423 |
+index 1ad66b76749b..c1b661e5c8c4 100644 |
2424 |
+--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c |
2425 |
++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c |
2426 |
+@@ -1816,8 +1816,6 @@ static void ar9003_hw_spectral_scan_wait(struct ath_hw *ah) |
2427 |
+ static void ar9003_hw_tx99_start(struct ath_hw *ah, u32 qnum) |
2428 |
+ { |
2429 |
+ REG_SET_BIT(ah, AR_PHY_TEST, PHY_AGC_CLR); |
2430 |
+- REG_SET_BIT(ah, 0x9864, 0x7f000); |
2431 |
+- REG_SET_BIT(ah, 0x9924, 0x7f00fe); |
2432 |
+ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); |
2433 |
+ REG_WRITE(ah, AR_CR, AR_CR_RXD); |
2434 |
+ REG_WRITE(ah, AR_DLCL_IFS(qnum), 0); |
2435 |
+diff --git a/drivers/net/wireless/ath/ath9k/tx99.c b/drivers/net/wireless/ath/ath9k/tx99.c |
2436 |
+index ac4781f37e78..b4e6304afd40 100644 |
2437 |
+--- a/drivers/net/wireless/ath/ath9k/tx99.c |
2438 |
++++ b/drivers/net/wireless/ath/ath9k/tx99.c |
2439 |
+@@ -190,22 +190,27 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf, |
2440 |
+ if (strtobool(buf, &start)) |
2441 |
+ return -EINVAL; |
2442 |
+ |
2443 |
++ mutex_lock(&sc->mutex); |
2444 |
++ |
2445 |
+ if (start == sc->tx99_state) { |
2446 |
+ if (!start) |
2447 |
+- return count; |
2448 |
++ goto out; |
2449 |
+ ath_dbg(common, XMIT, "Resetting TX99\n"); |
2450 |
+ ath9k_tx99_deinit(sc); |
2451 |
+ } |
2452 |
+ |
2453 |
+ if (!start) { |
2454 |
+ ath9k_tx99_deinit(sc); |
2455 |
+- return count; |
2456 |
++ goto out; |
2457 |
+ } |
2458 |
+ |
2459 |
+ r = ath9k_tx99_init(sc); |
2460 |
+- if (r) |
2461 |
++ if (r) { |
2462 |
++ mutex_unlock(&sc->mutex); |
2463 |
+ return r; |
2464 |
+- |
2465 |
++ } |
2466 |
++out: |
2467 |
++ mutex_unlock(&sc->mutex); |
2468 |
+ return count; |
2469 |
+ } |
2470 |
+ |
2471 |
+diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c |
2472 |
+index c2a238426425..a058151f5eed 100644 |
2473 |
+--- a/drivers/net/wireless/ath/wil6210/main.c |
2474 |
++++ b/drivers/net/wireless/ath/wil6210/main.c |
2475 |
+@@ -323,18 +323,19 @@ static void wil_fw_error_worker(struct work_struct *work) |
2476 |
+ |
2477 |
+ wil->last_fw_recovery = jiffies; |
2478 |
+ |
2479 |
++ wil_info(wil, "fw error recovery requested (try %d)...\n", |
2480 |
++ wil->recovery_count); |
2481 |
++ if (!no_fw_recovery) |
2482 |
++ wil->recovery_state = fw_recovery_running; |
2483 |
++ if (wil_wait_for_recovery(wil) != 0) |
2484 |
++ return; |
2485 |
++ |
2486 |
+ mutex_lock(&wil->mutex); |
2487 |
+ switch (wdev->iftype) { |
2488 |
+ case NL80211_IFTYPE_STATION: |
2489 |
+ case NL80211_IFTYPE_P2P_CLIENT: |
2490 |
+ case NL80211_IFTYPE_MONITOR: |
2491 |
+- wil_info(wil, "fw error recovery requested (try %d)...\n", |
2492 |
+- wil->recovery_count); |
2493 |
+- if (!no_fw_recovery) |
2494 |
+- wil->recovery_state = fw_recovery_running; |
2495 |
+- if (0 != wil_wait_for_recovery(wil)) |
2496 |
+- break; |
2497 |
+- |
2498 |
++ /* silent recovery, upper layers will see disconnect */ |
2499 |
+ __wil_down(wil); |
2500 |
+ __wil_up(wil); |
2501 |
+ break; |
2502 |
+diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h |
2503 |
+index 8a495b318b6f..aa8400e3839c 100644 |
2504 |
+--- a/drivers/net/xen-netback/common.h |
2505 |
++++ b/drivers/net/xen-netback/common.h |
2506 |
+@@ -195,6 +195,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */ |
2507 |
+ unsigned long remaining_credit; |
2508 |
+ struct timer_list credit_timeout; |
2509 |
+ u64 credit_window_start; |
2510 |
++ bool rate_limited; |
2511 |
+ |
2512 |
+ /* Statistics */ |
2513 |
+ struct xenvif_stats stats; |
2514 |
+diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c |
2515 |
+index 1a83e190fc15..e34527071260 100644 |
2516 |
+--- a/drivers/net/xen-netback/interface.c |
2517 |
++++ b/drivers/net/xen-netback/interface.c |
2518 |
+@@ -99,7 +99,11 @@ static int xenvif_poll(struct napi_struct *napi, int budget) |
2519 |
+ |
2520 |
+ if (work_done < budget) { |
2521 |
+ napi_complete(napi); |
2522 |
+- xenvif_napi_schedule_or_enable_events(queue); |
2523 |
++ /* If the queue is rate-limited, it shall be |
2524 |
++ * rescheduled in the timer callback. |
2525 |
++ */ |
2526 |
++ if (likely(!queue->rate_limited)) |
2527 |
++ xenvif_napi_schedule_or_enable_events(queue); |
2528 |
+ } |
2529 |
+ |
2530 |
+ return work_done; |
2531 |
+diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c |
2532 |
+index 5e5b6184e720..7bd3c5a8116d 100644 |
2533 |
+--- a/drivers/net/xen-netback/netback.c |
2534 |
++++ b/drivers/net/xen-netback/netback.c |
2535 |
+@@ -640,6 +640,7 @@ static void tx_add_credit(struct xenvif_queue *queue) |
2536 |
+ max_credit = ULONG_MAX; /* wrapped: clamp to ULONG_MAX */ |
2537 |
+ |
2538 |
+ queue->remaining_credit = min(max_credit, max_burst); |
2539 |
++ queue->rate_limited = false; |
2540 |
+ } |
2541 |
+ |
2542 |
+ void xenvif_tx_credit_callback(unsigned long data) |
2543 |
+@@ -1152,8 +1153,10 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size) |
2544 |
+ msecs_to_jiffies(queue->credit_usec / 1000); |
2545 |
+ |
2546 |
+ /* Timer could already be pending in rare cases. */ |
2547 |
+- if (timer_pending(&queue->credit_timeout)) |
2548 |
++ if (timer_pending(&queue->credit_timeout)) { |
2549 |
++ queue->rate_limited = true; |
2550 |
+ return true; |
2551 |
++ } |
2552 |
+ |
2553 |
+ /* Passed the point where we can replenish credit? */ |
2554 |
+ if (time_after_eq64(now, next_credit)) { |
2555 |
+@@ -1168,6 +1171,7 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size) |
2556 |
+ mod_timer(&queue->credit_timeout, |
2557 |
+ next_credit); |
2558 |
+ queue->credit_window_start = next_credit; |
2559 |
++ queue->rate_limited = true; |
2560 |
+ |
2561 |
+ return true; |
2562 |
+ } |
2563 |
+diff --git a/drivers/of/device.c b/drivers/of/device.c |
2564 |
+index 20c1332a0018..493b21bd1199 100644 |
2565 |
+--- a/drivers/of/device.c |
2566 |
++++ b/drivers/of/device.c |
2567 |
+@@ -212,6 +212,7 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) |
2568 |
+ |
2569 |
+ return tsize; |
2570 |
+ } |
2571 |
++EXPORT_SYMBOL_GPL(of_device_get_modalias); |
2572 |
+ |
2573 |
+ /** |
2574 |
+ * of_device_uevent - Display OF related uevent information |
2575 |
+@@ -274,3 +275,4 @@ int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) |
2576 |
+ |
2577 |
+ return 0; |
2578 |
+ } |
2579 |
++EXPORT_SYMBOL_GPL(of_device_uevent_modalias); |
2580 |
+diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c |
2581 |
+index 74f4a26e16b5..98101c4118bb 100644 |
2582 |
+--- a/drivers/pci/pci-driver.c |
2583 |
++++ b/drivers/pci/pci-driver.c |
2584 |
+@@ -937,6 +937,7 @@ static int pci_pm_thaw_noirq(struct device *dev) |
2585 |
+ return pci_legacy_resume_early(dev); |
2586 |
+ |
2587 |
+ pci_update_current_state(pci_dev, PCI_D0); |
2588 |
++ pci_restore_state(pci_dev); |
2589 |
+ |
2590 |
+ if (drv && drv->pm && drv->pm->thaw_noirq) |
2591 |
+ error = drv->pm->thaw_noirq(dev); |
2592 |
+diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c |
2593 |
+index 0b7afa50121a..390feee4d47c 100644 |
2594 |
+--- a/drivers/pinctrl/samsung/pinctrl-exynos.c |
2595 |
++++ b/drivers/pinctrl/samsung/pinctrl-exynos.c |
2596 |
+@@ -194,8 +194,6 @@ static int exynos_irq_request_resources(struct irq_data *irqd) |
2597 |
+ |
2598 |
+ spin_unlock_irqrestore(&bank->slock, flags); |
2599 |
+ |
2600 |
+- exynos_irq_unmask(irqd); |
2601 |
+- |
2602 |
+ return 0; |
2603 |
+ } |
2604 |
+ |
2605 |
+@@ -216,8 +214,6 @@ static void exynos_irq_release_resources(struct irq_data *irqd) |
2606 |
+ shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC]; |
2607 |
+ mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; |
2608 |
+ |
2609 |
+- exynos_irq_mask(irqd); |
2610 |
+- |
2611 |
+ spin_lock_irqsave(&bank->slock, flags); |
2612 |
+ |
2613 |
+ con = readl(d->virt_base + reg_con); |
2614 |
+diff --git a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c |
2615 |
+index 7376a97b5e65..727ce62de0bd 100644 |
2616 |
+--- a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c |
2617 |
++++ b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c |
2618 |
+@@ -800,6 +800,7 @@ static const struct sunxi_desc_pin sun4i_a10_pins[] = { |
2619 |
+ SUNXI_FUNCTION(0x2, "lcd1"), /* D16 */ |
2620 |
+ SUNXI_FUNCTION(0x3, "pata"), /* ATAD12 */ |
2621 |
+ SUNXI_FUNCTION(0x4, "keypad"), /* IN6 */ |
2622 |
++ SUNXI_FUNCTION(0x5, "sim"), /* DET */ |
2623 |
+ SUNXI_FUNCTION_IRQ(0x6, 16), /* EINT16 */ |
2624 |
+ SUNXI_FUNCTION(0x7, "csi1")), /* D16 */ |
2625 |
+ SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 17), |
2626 |
+diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h |
2627 |
+index ce129e595b55..5c935847599c 100644 |
2628 |
+--- a/drivers/scsi/fnic/fnic.h |
2629 |
++++ b/drivers/scsi/fnic/fnic.h |
2630 |
+@@ -248,6 +248,7 @@ struct fnic { |
2631 |
+ struct completion *remove_wait; /* device remove thread blocks */ |
2632 |
+ |
2633 |
+ atomic_t in_flight; /* io counter */ |
2634 |
++ bool internal_reset_inprogress; |
2635 |
+ u32 _reserved; /* fill hole */ |
2636 |
+ unsigned long state_flags; /* protected by host lock */ |
2637 |
+ enum fnic_state state; |
2638 |
+diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c |
2639 |
+index 25436cd2860c..eaf29b18fb7a 100644 |
2640 |
+--- a/drivers/scsi/fnic/fnic_scsi.c |
2641 |
++++ b/drivers/scsi/fnic/fnic_scsi.c |
2642 |
+@@ -2517,6 +2517,19 @@ int fnic_host_reset(struct scsi_cmnd *sc) |
2643 |
+ unsigned long wait_host_tmo; |
2644 |
+ struct Scsi_Host *shost = sc->device->host; |
2645 |
+ struct fc_lport *lp = shost_priv(shost); |
2646 |
++ struct fnic *fnic = lport_priv(lp); |
2647 |
++ unsigned long flags; |
2648 |
++ |
2649 |
++ spin_lock_irqsave(&fnic->fnic_lock, flags); |
2650 |
++ if (fnic->internal_reset_inprogress == 0) { |
2651 |
++ fnic->internal_reset_inprogress = 1; |
2652 |
++ } else { |
2653 |
++ spin_unlock_irqrestore(&fnic->fnic_lock, flags); |
2654 |
++ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, |
2655 |
++ "host reset in progress skipping another host reset\n"); |
2656 |
++ return SUCCESS; |
2657 |
++ } |
2658 |
++ spin_unlock_irqrestore(&fnic->fnic_lock, flags); |
2659 |
+ |
2660 |
+ /* |
2661 |
+ * If fnic_reset is successful, wait for fabric login to complete |
2662 |
+@@ -2537,6 +2550,9 @@ int fnic_host_reset(struct scsi_cmnd *sc) |
2663 |
+ } |
2664 |
+ } |
2665 |
+ |
2666 |
++ spin_lock_irqsave(&fnic->fnic_lock, flags); |
2667 |
++ fnic->internal_reset_inprogress = 0; |
2668 |
++ spin_unlock_irqrestore(&fnic->fnic_lock, flags); |
2669 |
+ return ret; |
2670 |
+ } |
2671 |
+ |
2672 |
+diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c |
2673 |
+index 14a781b6b88d..093f7b4847df 100644 |
2674 |
+--- a/drivers/scsi/mpt3sas/mpt3sas_base.c |
2675 |
++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c |
2676 |
+@@ -4410,14 +4410,13 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, |
2677 |
+ static int |
2678 |
+ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) |
2679 |
+ { |
2680 |
+- int r, i; |
2681 |
++ int r, i, index; |
2682 |
+ unsigned long flags; |
2683 |
+ u32 reply_address; |
2684 |
+ u16 smid; |
2685 |
+ struct _tr_list *delayed_tr, *delayed_tr_next; |
2686 |
+ struct adapter_reply_queue *reply_q; |
2687 |
+- long reply_post_free; |
2688 |
+- u32 reply_post_free_sz, index = 0; |
2689 |
++ Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig; |
2690 |
+ |
2691 |
+ dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
2692 |
+ __func__)); |
2693 |
+@@ -4488,27 +4487,27 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) |
2694 |
+ _base_assign_reply_queues(ioc); |
2695 |
+ |
2696 |
+ /* initialize Reply Post Free Queue */ |
2697 |
+- reply_post_free_sz = ioc->reply_post_queue_depth * |
2698 |
+- sizeof(Mpi2DefaultReplyDescriptor_t); |
2699 |
+- reply_post_free = (long)ioc->reply_post[index].reply_post_free; |
2700 |
++ index = 0; |
2701 |
++ reply_post_free_contig = ioc->reply_post[0].reply_post_free; |
2702 |
+ list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { |
2703 |
++ /* |
2704 |
++ * If RDPQ is enabled, switch to the next allocation. |
2705 |
++ * Otherwise advance within the contiguous region. |
2706 |
++ */ |
2707 |
++ if (ioc->rdpq_array_enable) { |
2708 |
++ reply_q->reply_post_free = |
2709 |
++ ioc->reply_post[index++].reply_post_free; |
2710 |
++ } else { |
2711 |
++ reply_q->reply_post_free = reply_post_free_contig; |
2712 |
++ reply_post_free_contig += ioc->reply_post_queue_depth; |
2713 |
++ } |
2714 |
++ |
2715 |
+ reply_q->reply_post_host_index = 0; |
2716 |
+- reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *) |
2717 |
+- reply_post_free; |
2718 |
+ for (i = 0; i < ioc->reply_post_queue_depth; i++) |
2719 |
+ reply_q->reply_post_free[i].Words = |
2720 |
+ cpu_to_le64(ULLONG_MAX); |
2721 |
+ if (!_base_is_controller_msix_enabled(ioc)) |
2722 |
+ goto skip_init_reply_post_free_queue; |
2723 |
+- /* |
2724 |
+- * If RDPQ is enabled, switch to the next allocation. |
2725 |
+- * Otherwise advance within the contiguous region. |
2726 |
+- */ |
2727 |
+- if (ioc->rdpq_array_enable) |
2728 |
+- reply_post_free = (long) |
2729 |
+- ioc->reply_post[++index].reply_post_free; |
2730 |
+- else |
2731 |
+- reply_post_free += reply_post_free_sz; |
2732 |
+ } |
2733 |
+ skip_init_reply_post_free_queue: |
2734 |
+ |
2735 |
+diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c |
2736 |
+index 82b92c414a9c..c1b2e86839ae 100644 |
2737 |
+--- a/drivers/scsi/qla2xxx/qla_attr.c |
2738 |
++++ b/drivers/scsi/qla2xxx/qla_attr.c |
2739 |
+@@ -329,12 +329,15 @@ qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj, |
2740 |
+ struct qla_hw_data *ha = vha->hw; |
2741 |
+ ssize_t rval = 0; |
2742 |
+ |
2743 |
++ mutex_lock(&ha->optrom_mutex); |
2744 |
++ |
2745 |
+ if (ha->optrom_state != QLA_SREADING) |
2746 |
+- return 0; |
2747 |
++ goto out; |
2748 |
+ |
2749 |
+- mutex_lock(&ha->optrom_mutex); |
2750 |
+ rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer, |
2751 |
+ ha->optrom_region_size); |
2752 |
++ |
2753 |
++out: |
2754 |
+ mutex_unlock(&ha->optrom_mutex); |
2755 |
+ |
2756 |
+ return rval; |
2757 |
+@@ -349,14 +352,19 @@ qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, |
2758 |
+ struct device, kobj))); |
2759 |
+ struct qla_hw_data *ha = vha->hw; |
2760 |
+ |
2761 |
+- if (ha->optrom_state != QLA_SWRITING) |
2762 |
++ mutex_lock(&ha->optrom_mutex); |
2763 |
++ |
2764 |
++ if (ha->optrom_state != QLA_SWRITING) { |
2765 |
++ mutex_unlock(&ha->optrom_mutex); |
2766 |
+ return -EINVAL; |
2767 |
+- if (off > ha->optrom_region_size) |
2768 |
++ } |
2769 |
++ if (off > ha->optrom_region_size) { |
2770 |
++ mutex_unlock(&ha->optrom_mutex); |
2771 |
+ return -ERANGE; |
2772 |
++ } |
2773 |
+ if (off + count > ha->optrom_region_size) |
2774 |
+ count = ha->optrom_region_size - off; |
2775 |
+ |
2776 |
+- mutex_lock(&ha->optrom_mutex); |
2777 |
+ memcpy(&ha->optrom_buffer[off], buf, count); |
2778 |
+ mutex_unlock(&ha->optrom_mutex); |
2779 |
+ |
2780 |
+diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c |
2781 |
+index 4fbfcdc5cb24..ebaefecd6e82 100644 |
2782 |
+--- a/drivers/spi/spi-dw.c |
2783 |
++++ b/drivers/spi/spi-dw.c |
2784 |
+@@ -113,7 +113,10 @@ static const struct file_operations dw_spi_regs_ops = { |
2785 |
+ |
2786 |
+ static int dw_spi_debugfs_init(struct dw_spi *dws) |
2787 |
+ { |
2788 |
+- dws->debugfs = debugfs_create_dir("dw_spi", NULL); |
2789 |
++ char name[128]; |
2790 |
++ |
2791 |
++ snprintf(name, 128, "dw_spi-%s", dev_name(&dws->master->dev)); |
2792 |
++ dws->debugfs = debugfs_create_dir(name, NULL); |
2793 |
+ if (!dws->debugfs) |
2794 |
+ return -ENOMEM; |
2795 |
+ |
2796 |
+diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c |
2797 |
+index 94938436aef9..2f9f2958c203 100644 |
2798 |
+--- a/drivers/spmi/spmi.c |
2799 |
++++ b/drivers/spmi/spmi.c |
2800 |
+@@ -348,11 +348,23 @@ static int spmi_drv_remove(struct device *dev) |
2801 |
+ return 0; |
2802 |
+ } |
2803 |
+ |
2804 |
++static int spmi_drv_uevent(struct device *dev, struct kobj_uevent_env *env) |
2805 |
++{ |
2806 |
++ int ret; |
2807 |
++ |
2808 |
++ ret = of_device_uevent_modalias(dev, env); |
2809 |
++ if (ret != -ENODEV) |
2810 |
++ return ret; |
2811 |
++ |
2812 |
++ return 0; |
2813 |
++} |
2814 |
++ |
2815 |
+ static struct bus_type spmi_bus_type = { |
2816 |
+ .name = "spmi", |
2817 |
+ .match = spmi_device_match, |
2818 |
+ .probe = spmi_drv_probe, |
2819 |
+ .remove = spmi_drv_remove, |
2820 |
++ .uevent = spmi_drv_uevent, |
2821 |
+ }; |
2822 |
+ |
2823 |
+ /** |
2824 |
+diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c |
2825 |
+index a503132f91e8..ab6139b5472f 100644 |
2826 |
+--- a/drivers/staging/comedi/comedi_fops.c |
2827 |
++++ b/drivers/staging/comedi/comedi_fops.c |
2828 |
+@@ -2875,9 +2875,6 @@ static int __init comedi_init(void) |
2829 |
+ |
2830 |
+ comedi_class->dev_groups = comedi_dev_groups; |
2831 |
+ |
2832 |
+- /* XXX requires /proc interface */ |
2833 |
+- comedi_proc_init(); |
2834 |
+- |
2835 |
+ /* create devices files for legacy/manual use */ |
2836 |
+ for (i = 0; i < comedi_num_legacy_minors; i++) { |
2837 |
+ struct comedi_device *dev; |
2838 |
+@@ -2895,6 +2892,9 @@ static int __init comedi_init(void) |
2839 |
+ mutex_unlock(&dev->mutex); |
2840 |
+ } |
2841 |
+ |
2842 |
++ /* XXX requires /proc interface */ |
2843 |
++ comedi_proc_init(); |
2844 |
++ |
2845 |
+ return 0; |
2846 |
+ } |
2847 |
+ module_init(comedi_init); |
2848 |
+diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c |
2849 |
+index 7bc3e4a73834..16af77d20bdb 100644 |
2850 |
+--- a/drivers/staging/iio/resolver/ad2s1210.c |
2851 |
++++ b/drivers/staging/iio/resolver/ad2s1210.c |
2852 |
+@@ -468,7 +468,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, |
2853 |
+ long m) |
2854 |
+ { |
2855 |
+ struct ad2s1210_state *st = iio_priv(indio_dev); |
2856 |
+- bool negative; |
2857 |
++ u16 negative; |
2858 |
+ int ret = 0; |
2859 |
+ u16 pos; |
2860 |
+ s16 vel; |
2861 |
+diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
2862 |
+index ef3c73e38172..4273e34ff3ea 100644 |
2863 |
+--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
2864 |
++++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
2865 |
+@@ -48,6 +48,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = { |
2866 |
+ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ |
2867 |
+ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ |
2868 |
+ {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ |
2869 |
++ {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ |
2870 |
+ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ |
2871 |
+ {} /* Terminating entry */ |
2872 |
+ }; |
2873 |
+diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c |
2874 |
+index 2fc3a231c2b6..7444640a7453 100644 |
2875 |
+--- a/drivers/target/iscsi/iscsi_target.c |
2876 |
++++ b/drivers/target/iscsi/iscsi_target.c |
2877 |
+@@ -426,6 +426,7 @@ int iscsit_reset_np_thread( |
2878 |
+ return 0; |
2879 |
+ } |
2880 |
+ np->np_thread_state = ISCSI_NP_THREAD_RESET; |
2881 |
++ atomic_inc(&np->np_reset_count); |
2882 |
+ |
2883 |
+ if (np->np_thread) { |
2884 |
+ spin_unlock_bh(&np->np_thread_lock); |
2885 |
+@@ -1992,6 +1993,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, |
2886 |
+ cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
2887 |
+ cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
2888 |
+ cmd->data_direction = DMA_NONE; |
2889 |
++ kfree(cmd->text_in_ptr); |
2890 |
+ cmd->text_in_ptr = NULL; |
2891 |
+ |
2892 |
+ return 0; |
2893 |
+@@ -4589,8 +4591,11 @@ static void iscsit_logout_post_handler_closesession( |
2894 |
+ * always sleep waiting for RX/TX thread shutdown to complete |
2895 |
+ * within iscsit_close_connection(). |
2896 |
+ */ |
2897 |
+- if (conn->conn_transport->transport_type == ISCSI_TCP) |
2898 |
++ if (conn->conn_transport->transport_type == ISCSI_TCP) { |
2899 |
+ sleep = cmpxchg(&conn->tx_thread_active, true, false); |
2900 |
++ if (!sleep) |
2901 |
++ return; |
2902 |
++ } |
2903 |
+ |
2904 |
+ atomic_set(&conn->conn_logout_remove, 0); |
2905 |
+ complete(&conn->conn_logout_comp); |
2906 |
+@@ -4606,8 +4611,11 @@ static void iscsit_logout_post_handler_samecid( |
2907 |
+ { |
2908 |
+ int sleep = 1; |
2909 |
+ |
2910 |
+- if (conn->conn_transport->transport_type == ISCSI_TCP) |
2911 |
++ if (conn->conn_transport->transport_type == ISCSI_TCP) { |
2912 |
+ sleep = cmpxchg(&conn->tx_thread_active, true, false); |
2913 |
++ if (!sleep) |
2914 |
++ return; |
2915 |
++ } |
2916 |
+ |
2917 |
+ atomic_set(&conn->conn_logout_remove, 0); |
2918 |
+ complete(&conn->conn_logout_comp); |
2919 |
+diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c |
2920 |
+index c5cbd702e7cd..ee3a4bb9fba7 100644 |
2921 |
+--- a/drivers/target/iscsi/iscsi_target_login.c |
2922 |
++++ b/drivers/target/iscsi/iscsi_target_login.c |
2923 |
+@@ -1290,9 +1290,11 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) |
2924 |
+ flush_signals(current); |
2925 |
+ |
2926 |
+ spin_lock_bh(&np->np_thread_lock); |
2927 |
+- if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { |
2928 |
++ if (atomic_dec_if_positive(&np->np_reset_count) >= 0) { |
2929 |
+ np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; |
2930 |
++ spin_unlock_bh(&np->np_thread_lock); |
2931 |
+ complete(&np->np_restart_comp); |
2932 |
++ return 1; |
2933 |
+ } else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) { |
2934 |
+ spin_unlock_bh(&np->np_thread_lock); |
2935 |
+ goto exit; |
2936 |
+@@ -1325,7 +1327,8 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) |
2937 |
+ goto exit; |
2938 |
+ } else if (rc < 0) { |
2939 |
+ spin_lock_bh(&np->np_thread_lock); |
2940 |
+- if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { |
2941 |
++ if (atomic_dec_if_positive(&np->np_reset_count) >= 0) { |
2942 |
++ np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; |
2943 |
+ spin_unlock_bh(&np->np_thread_lock); |
2944 |
+ complete(&np->np_restart_comp); |
2945 |
+ iscsit_put_transport(conn->conn_transport); |
2946 |
+diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c |
2947 |
+index 95c1c4ecf336..b7d27b816359 100644 |
2948 |
+--- a/drivers/target/target_core_transport.c |
2949 |
++++ b/drivers/target/target_core_transport.c |
2950 |
+@@ -733,6 +733,15 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) |
2951 |
+ if (cmd->transport_state & CMD_T_ABORTED || |
2952 |
+ cmd->transport_state & CMD_T_STOP) { |
2953 |
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
2954 |
++ /* |
2955 |
++ * If COMPARE_AND_WRITE was stopped by __transport_wait_for_tasks(), |
2956 |
++ * release se_device->caw_sem obtained by sbc_compare_and_write() |
2957 |
++ * since target_complete_ok_work() or target_complete_failure_work() |
2958 |
++ * won't be called to invoke the normal CAW completion callbacks. |
2959 |
++ */ |
2960 |
++ if (cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) { |
2961 |
++ up(&dev->caw_sem); |
2962 |
++ } |
2963 |
+ complete_all(&cmd->t_transport_stop_comp); |
2964 |
+ return; |
2965 |
+ } else if (!success) { |
2966 |
+diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
2967 |
+index 7983298ab32c..acab64245923 100644 |
2968 |
+--- a/drivers/usb/class/cdc-acm.c |
2969 |
++++ b/drivers/usb/class/cdc-acm.c |
2970 |
+@@ -1771,6 +1771,9 @@ static const struct usb_device_id acm_ids[] = { |
2971 |
+ { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */ |
2972 |
+ .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ |
2973 |
+ }, |
2974 |
++ { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */ |
2975 |
++ .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ |
2976 |
++ }, |
2977 |
+ |
2978 |
+ { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ |
2979 |
+ .driver_info = CLEAR_HALT_CONDITIONS, |
2980 |
+diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c |
2981 |
+index 029fa26d2ac9..78f357b1a8fd 100644 |
2982 |
+--- a/drivers/usb/core/hcd.c |
2983 |
++++ b/drivers/usb/core/hcd.c |
2984 |
+@@ -2397,6 +2397,8 @@ void usb_hc_died (struct usb_hcd *hcd) |
2985 |
+ } |
2986 |
+ if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) { |
2987 |
+ hcd = hcd->shared_hcd; |
2988 |
++ clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); |
2989 |
++ set_bit(HCD_FLAG_DEAD, &hcd->flags); |
2990 |
+ if (hcd->rh_registered) { |
2991 |
+ clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2992 |
+ |
2993 |
+diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c |
2994 |
+index e479c7d47a9f..fbf5c57b8251 100644 |
2995 |
+--- a/drivers/usb/core/hub.c |
2996 |
++++ b/drivers/usb/core/hub.c |
2997 |
+@@ -4618,7 +4618,8 @@ hub_power_remaining (struct usb_hub *hub) |
2998 |
+ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, |
2999 |
+ u16 portchange) |
3000 |
+ { |
3001 |
+- int status, i; |
3002 |
++ int status = -ENODEV; |
3003 |
++ int i; |
3004 |
+ unsigned unit_load; |
3005 |
+ struct usb_device *hdev = hub->hdev; |
3006 |
+ struct usb_hcd *hcd = bus_to_hcd(hdev->bus); |
3007 |
+@@ -4822,9 +4823,10 @@ loop: |
3008 |
+ |
3009 |
+ done: |
3010 |
+ hub_port_disable(hub, port1, 1); |
3011 |
+- if (hcd->driver->relinquish_port && !hub->hdev->parent) |
3012 |
+- hcd->driver->relinquish_port(hcd, port1); |
3013 |
+- |
3014 |
++ if (hcd->driver->relinquish_port && !hub->hdev->parent) { |
3015 |
++ if (status != -ENOTCONN && status != -ENODEV) |
3016 |
++ hcd->driver->relinquish_port(hcd, port1); |
3017 |
++ } |
3018 |
+ } |
3019 |
+ |
3020 |
+ /* Handle physical or logical connection change events. |
3021 |
+diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c |
3022 |
+index 3116edfcdc18..574da2b4529c 100644 |
3023 |
+--- a/drivers/usb/core/quirks.c |
3024 |
++++ b/drivers/usb/core/quirks.c |
3025 |
+@@ -150,6 +150,9 @@ static const struct usb_device_id usb_quirk_list[] = { |
3026 |
+ /* appletouch */ |
3027 |
+ { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, |
3028 |
+ |
3029 |
++ /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ |
3030 |
++ { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM }, |
3031 |
++ |
3032 |
+ /* Avision AV600U */ |
3033 |
+ { USB_DEVICE(0x0638, 0x0a13), .driver_info = |
3034 |
+ USB_QUIRK_STRING_FETCH_255 }, |
3035 |
+@@ -249,6 +252,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { |
3036 |
+ { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, |
3037 |
+ { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, |
3038 |
+ { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, |
3039 |
++ { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME }, |
3040 |
+ |
3041 |
+ /* Logitech Optical Mouse M90/M100 */ |
3042 |
+ { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, |
3043 |
+diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c |
3044 |
+index f7f35a36c09a..466640afa7be 100644 |
3045 |
+--- a/drivers/usb/gadget/function/f_hid.c |
3046 |
++++ b/drivers/usb/gadget/function/f_hid.c |
3047 |
+@@ -544,7 +544,7 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) |
3048 |
+ } |
3049 |
+ status = usb_ep_enable(hidg->out_ep); |
3050 |
+ if (status < 0) { |
3051 |
+- ERROR(cdev, "Enable IN endpoint FAILED!\n"); |
3052 |
++ ERROR(cdev, "Enable OUT endpoint FAILED!\n"); |
3053 |
+ goto fail; |
3054 |
+ } |
3055 |
+ hidg->out_ep->driver_data = hidg; |
3056 |
+diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c |
3057 |
+index f9400564cb72..03b9a372636f 100644 |
3058 |
+--- a/drivers/usb/host/pci-quirks.c |
3059 |
++++ b/drivers/usb/host/pci-quirks.c |
3060 |
+@@ -89,6 +89,7 @@ enum amd_chipset_gen { |
3061 |
+ AMD_CHIPSET_HUDSON2, |
3062 |
+ AMD_CHIPSET_BOLTON, |
3063 |
+ AMD_CHIPSET_YANGTZE, |
3064 |
++ AMD_CHIPSET_TAISHAN, |
3065 |
+ AMD_CHIPSET_UNKNOWN, |
3066 |
+ }; |
3067 |
+ |
3068 |
+@@ -132,6 +133,11 @@ static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo) |
3069 |
+ pinfo->sb_type.gen = AMD_CHIPSET_SB700; |
3070 |
+ else if (rev >= 0x40 && rev <= 0x4f) |
3071 |
+ pinfo->sb_type.gen = AMD_CHIPSET_SB800; |
3072 |
++ } |
3073 |
++ pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
3074 |
++ 0x145c, NULL); |
3075 |
++ if (pinfo->smbus_dev) { |
3076 |
++ pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN; |
3077 |
+ } else { |
3078 |
+ pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
3079 |
+ PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL); |
3080 |
+@@ -251,11 +257,12 @@ int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev) |
3081 |
+ { |
3082 |
+ /* Make sure amd chipset type has already been initialized */ |
3083 |
+ usb_amd_find_chipset_info(); |
3084 |
+- if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE) |
3085 |
+- return 0; |
3086 |
+- |
3087 |
+- dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n"); |
3088 |
+- return 1; |
3089 |
++ if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE || |
3090 |
++ amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) { |
3091 |
++ dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n"); |
3092 |
++ return 1; |
3093 |
++ } |
3094 |
++ return 0; |
3095 |
+ } |
3096 |
+ EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk); |
3097 |
+ |
3098 |
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c |
3099 |
+index 2dd322e92951..25b1cf0b6848 100644 |
3100 |
+--- a/drivers/usb/host/xhci-hub.c |
3101 |
++++ b/drivers/usb/host/xhci-hub.c |
3102 |
+@@ -651,6 +651,9 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
3103 |
+ clear_bit(wIndex, &bus_state->resuming_ports); |
3104 |
+ |
3105 |
+ set_bit(wIndex, &bus_state->rexit_ports); |
3106 |
++ |
3107 |
++ xhci_test_and_clear_bit(xhci, port_array, wIndex, |
3108 |
++ PORT_PLC); |
3109 |
+ xhci_set_link_state(xhci, port_array, wIndex, |
3110 |
+ XDEV_U0); |
3111 |
+ |
3112 |
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
3113 |
+index fbb77e2b288d..639419066ec4 100644 |
3114 |
+--- a/drivers/usb/host/xhci-ring.c |
3115 |
++++ b/drivers/usb/host/xhci-ring.c |
3116 |
+@@ -789,13 +789,16 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, |
3117 |
+ (ep->ep_state & EP_GETTING_NO_STREAMS)) { |
3118 |
+ int stream_id; |
3119 |
+ |
3120 |
+- for (stream_id = 0; stream_id < ep->stream_info->num_streams; |
3121 |
++ for (stream_id = 1; stream_id < ep->stream_info->num_streams; |
3122 |
+ stream_id++) { |
3123 |
++ ring = ep->stream_info->stream_rings[stream_id]; |
3124 |
++ if (!ring) |
3125 |
++ continue; |
3126 |
++ |
3127 |
+ xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
3128 |
+ "Killing URBs for slot ID %u, ep index %u, stream %u", |
3129 |
+- slot_id, ep_index, stream_id + 1); |
3130 |
+- xhci_kill_ring_urbs(xhci, |
3131 |
+- ep->stream_info->stream_rings[stream_id]); |
3132 |
++ slot_id, ep_index, stream_id); |
3133 |
++ xhci_kill_ring_urbs(xhci, ring); |
3134 |
+ } |
3135 |
+ } else { |
3136 |
+ ring = ep->ring; |
3137 |
+diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c |
3138 |
+index 0f7e850fd4aa..61a898e4a010 100644 |
3139 |
+--- a/drivers/usb/renesas_usbhs/common.c |
3140 |
++++ b/drivers/usb/renesas_usbhs/common.c |
3141 |
+@@ -731,8 +731,10 @@ static int usbhsc_resume(struct device *dev) |
3142 |
+ struct usbhs_priv *priv = dev_get_drvdata(dev); |
3143 |
+ struct platform_device *pdev = usbhs_priv_to_pdev(priv); |
3144 |
+ |
3145 |
+- if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) |
3146 |
++ if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) { |
3147 |
+ usbhsc_power_ctrl(priv, 1); |
3148 |
++ usbhs_mod_autonomy_mode(priv); |
3149 |
++ } |
3150 |
+ |
3151 |
+ usbhs_platform_call(priv, phy_reset, pdev); |
3152 |
+ |
3153 |
+diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c |
3154 |
+index 69040e9069e0..31cd99f59a6a 100644 |
3155 |
+--- a/drivers/usb/serial/cp210x.c |
3156 |
++++ b/drivers/usb/serial/cp210x.c |
3157 |
+@@ -133,6 +133,7 @@ static const struct usb_device_id id_table[] = { |
3158 |
+ { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ |
3159 |
+ { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ |
3160 |
+ { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */ |
3161 |
++ { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */ |
3162 |
+ { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
3163 |
+ { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
3164 |
+ { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ |
3165 |
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
3166 |
+index 5d841485bbe3..f08b35819666 100644 |
3167 |
+--- a/drivers/usb/serial/option.c |
3168 |
++++ b/drivers/usb/serial/option.c |
3169 |
+@@ -2022,6 +2022,8 @@ static const struct usb_device_id option_ids[] = { |
3170 |
+ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) }, /* D-Link DWM-158 */ |
3171 |
+ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff), /* D-Link DWM-221 B1 */ |
3172 |
+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
3173 |
++ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */ |
3174 |
++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
3175 |
+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ |
3176 |
+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ |
3177 |
+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ |
3178 |
+diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c |
3179 |
+index 1db4b61bdf7b..a51b28379850 100644 |
3180 |
+--- a/drivers/usb/serial/pl2303.c |
3181 |
++++ b/drivers/usb/serial/pl2303.c |
3182 |
+@@ -49,6 +49,7 @@ static const struct usb_device_id id_table[] = { |
3183 |
+ { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, |
3184 |
+ { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, |
3185 |
+ { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, |
3186 |
++ { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_UC485) }, |
3187 |
+ { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) }, |
3188 |
+ { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, |
3189 |
+ { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
3190 |
+diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h |
3191 |
+index 09d9be88209e..3b5a15d1dc0d 100644 |
3192 |
+--- a/drivers/usb/serial/pl2303.h |
3193 |
++++ b/drivers/usb/serial/pl2303.h |
3194 |
+@@ -27,6 +27,7 @@ |
3195 |
+ #define ATEN_VENDOR_ID 0x0557 |
3196 |
+ #define ATEN_VENDOR_ID2 0x0547 |
3197 |
+ #define ATEN_PRODUCT_ID 0x2008 |
3198 |
++#define ATEN_PRODUCT_UC485 0x2021 |
3199 |
+ #define ATEN_PRODUCT_ID2 0x2118 |
3200 |
+ |
3201 |
+ #define IODATA_VENDOR_ID 0x04bb |
3202 |
+diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c |
3203 |
+index 076178645ba4..45b18df9fef1 100644 |
3204 |
+--- a/drivers/usb/storage/isd200.c |
3205 |
++++ b/drivers/usb/storage/isd200.c |
3206 |
+@@ -1522,8 +1522,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us) |
3207 |
+ |
3208 |
+ /* Make sure driver was initialized */ |
3209 |
+ |
3210 |
+- if (us->extra == NULL) |
3211 |
++ if (us->extra == NULL) { |
3212 |
+ usb_stor_dbg(us, "ERROR Driver not initialized\n"); |
3213 |
++ srb->result = DID_ERROR << 16; |
3214 |
++ return; |
3215 |
++ } |
3216 |
+ |
3217 |
+ scsi_set_resid(srb, 0); |
3218 |
+ /* scsi_bufflen might change in protocol translation to ata */ |
3219 |
+diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h |
3220 |
+index 53341a77d89f..a37ed1e59e99 100644 |
3221 |
+--- a/drivers/usb/storage/unusual_uas.h |
3222 |
++++ b/drivers/usb/storage/unusual_uas.h |
3223 |
+@@ -123,9 +123,9 @@ UNUSUAL_DEV(0x0bc2, 0xab2a, 0x0000, 0x9999, |
3224 |
+ /* Reported-by: Benjamin Tissoires <benjamin.tissoires@××××××.com> */ |
3225 |
+ UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, |
3226 |
+ "Initio Corporation", |
3227 |
+- "", |
3228 |
++ "INIC-3069", |
3229 |
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
3230 |
+- US_FL_NO_ATA_1X), |
3231 |
++ US_FL_NO_ATA_1X | US_FL_IGNORE_RESIDUE), |
3232 |
+ |
3233 |
+ /* Reported-by: Tom Arild Naess <tanaess@×××××.com> */ |
3234 |
+ UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999, |
3235 |
+diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c |
3236 |
+index ae90cf8867b5..f85e3a17cf5a 100644 |
3237 |
+--- a/drivers/vfio/pci/vfio_pci.c |
3238 |
++++ b/drivers/vfio/pci/vfio_pci.c |
3239 |
+@@ -902,6 +902,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma) |
3240 |
+ return ret; |
3241 |
+ |
3242 |
+ vdev->barmap[index] = pci_iomap(pdev, index, 0); |
3243 |
++ if (!vdev->barmap[index]) { |
3244 |
++ pci_release_selected_regions(pdev, 1 << index); |
3245 |
++ return -ENOMEM; |
3246 |
++ } |
3247 |
+ } |
3248 |
+ |
3249 |
+ vma->vm_private_data = vdev; |
3250 |
+diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c |
3251 |
+index 210db24d2204..4d39f7959adf 100644 |
3252 |
+--- a/drivers/vfio/pci/vfio_pci_rdwr.c |
3253 |
++++ b/drivers/vfio/pci/vfio_pci_rdwr.c |
3254 |
+@@ -190,7 +190,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf, |
3255 |
+ if (!vdev->has_vga) |
3256 |
+ return -EINVAL; |
3257 |
+ |
3258 |
+- switch (pos) { |
3259 |
++ if (pos > 0xbfffful) |
3260 |
++ return -EINVAL; |
3261 |
++ |
3262 |
++ switch ((u32)pos) { |
3263 |
+ case 0xa0000 ... 0xbffff: |
3264 |
+ count = min(count, (size_t)(0xc0000 - pos)); |
3265 |
+ iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1); |
3266 |
+diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c |
3267 |
+index e1278fe04b1e..8b2354536bbb 100644 |
3268 |
+--- a/drivers/vfio/vfio.c |
3269 |
++++ b/drivers/vfio/vfio.c |
3270 |
+@@ -295,6 +295,34 @@ static void vfio_group_put(struct vfio_group *group) |
3271 |
+ kref_put_mutex(&group->kref, vfio_group_release, &vfio.group_lock); |
3272 |
+ } |
3273 |
+ |
3274 |
++struct vfio_group_put_work { |
3275 |
++ struct work_struct work; |
3276 |
++ struct vfio_group *group; |
3277 |
++}; |
3278 |
++ |
3279 |
++static void vfio_group_put_bg(struct work_struct *work) |
3280 |
++{ |
3281 |
++ struct vfio_group_put_work *do_work; |
3282 |
++ |
3283 |
++ do_work = container_of(work, struct vfio_group_put_work, work); |
3284 |
++ |
3285 |
++ vfio_group_put(do_work->group); |
3286 |
++ kfree(do_work); |
3287 |
++} |
3288 |
++ |
3289 |
++static void vfio_group_schedule_put(struct vfio_group *group) |
3290 |
++{ |
3291 |
++ struct vfio_group_put_work *do_work; |
3292 |
++ |
3293 |
++ do_work = kmalloc(sizeof(*do_work), GFP_KERNEL); |
3294 |
++ if (WARN_ON(!do_work)) |
3295 |
++ return; |
3296 |
++ |
3297 |
++ INIT_WORK(&do_work->work, vfio_group_put_bg); |
3298 |
++ do_work->group = group; |
3299 |
++ schedule_work(&do_work->work); |
3300 |
++} |
3301 |
++ |
3302 |
+ /* Assume group_lock or group reference is held */ |
3303 |
+ static void vfio_group_get(struct vfio_group *group) |
3304 |
+ { |
3305 |
+@@ -601,7 +629,14 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, |
3306 |
+ break; |
3307 |
+ } |
3308 |
+ |
3309 |
+- vfio_group_put(group); |
3310 |
++ /* |
3311 |
++ * If we're the last reference to the group, the group will be |
3312 |
++ * released, which includes unregistering the iommu group notifier. |
3313 |
++ * We hold a read-lock on that notifier list, unregistering needs |
3314 |
++ * a write-lock... deadlock. Release our reference asynchronously |
3315 |
++ * to avoid that situation. |
3316 |
++ */ |
3317 |
++ vfio_group_schedule_put(group); |
3318 |
+ return NOTIFY_OK; |
3319 |
+ } |
3320 |
+ |
3321 |
+@@ -1504,6 +1539,15 @@ void vfio_group_put_external_user(struct vfio_group *group) |
3322 |
+ } |
3323 |
+ EXPORT_SYMBOL_GPL(vfio_group_put_external_user); |
3324 |
+ |
3325 |
++bool vfio_external_group_match_file(struct vfio_group *test_group, |
3326 |
++ struct file *filep) |
3327 |
++{ |
3328 |
++ struct vfio_group *group = filep->private_data; |
3329 |
++ |
3330 |
++ return (filep->f_op == &vfio_group_fops) && (group == test_group); |
3331 |
++} |
3332 |
++EXPORT_SYMBOL_GPL(vfio_external_group_match_file); |
3333 |
++ |
3334 |
+ int vfio_external_user_iommu_id(struct vfio_group *group) |
3335 |
+ { |
3336 |
+ return iommu_group_id(group->iommu_group); |
3337 |
+diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c |
3338 |
+index 07675d6f323e..d4530b54479c 100644 |
3339 |
+--- a/drivers/video/fbdev/cobalt_lcdfb.c |
3340 |
++++ b/drivers/video/fbdev/cobalt_lcdfb.c |
3341 |
+@@ -350,6 +350,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev) |
3342 |
+ info->screen_size = resource_size(res); |
3343 |
+ info->screen_base = devm_ioremap(&dev->dev, res->start, |
3344 |
+ info->screen_size); |
3345 |
++ if (!info->screen_base) { |
3346 |
++ framebuffer_release(info); |
3347 |
++ return -ENOMEM; |
3348 |
++ } |
3349 |
++ |
3350 |
+ info->fbops = &cobalt_lcd_fbops; |
3351 |
+ info->fix = cobalt_lcdfb_fix; |
3352 |
+ info->fix.smem_start = res->start; |
3353 |
+diff --git a/fs/ext4/file.c b/fs/ext4/file.c |
3354 |
+index ece4982ee593..f57cf1c42ca3 100644 |
3355 |
+--- a/fs/ext4/file.c |
3356 |
++++ b/fs/ext4/file.c |
3357 |
+@@ -391,6 +391,8 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, |
3358 |
+ lastoff = page_offset(page); |
3359 |
+ bh = head = page_buffers(page); |
3360 |
+ do { |
3361 |
++ if (lastoff + bh->b_size <= startoff) |
3362 |
++ goto next; |
3363 |
+ if (buffer_uptodate(bh) || |
3364 |
+ buffer_unwritten(bh)) { |
3365 |
+ if (whence == SEEK_DATA) |
3366 |
+@@ -405,6 +407,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, |
3367 |
+ unlock_page(page); |
3368 |
+ goto out; |
3369 |
+ } |
3370 |
++next: |
3371 |
+ lastoff += bh->b_size; |
3372 |
+ bh = bh->b_this_page; |
3373 |
+ } while (bh != head); |
3374 |
+diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c |
3375 |
+index 0e783b9f7007..b63e308e2545 100644 |
3376 |
+--- a/fs/ext4/resize.c |
3377 |
++++ b/fs/ext4/resize.c |
3378 |
+@@ -1932,7 +1932,8 @@ retry: |
3379 |
+ n_desc_blocks = o_desc_blocks + |
3380 |
+ le16_to_cpu(es->s_reserved_gdt_blocks); |
3381 |
+ n_group = n_desc_blocks * EXT4_DESC_PER_BLOCK(sb); |
3382 |
+- n_blocks_count = n_group * EXT4_BLOCKS_PER_GROUP(sb); |
3383 |
++ n_blocks_count = (ext4_fsblk_t)n_group * |
3384 |
++ EXT4_BLOCKS_PER_GROUP(sb); |
3385 |
+ n_group--; /* set to last group number */ |
3386 |
+ } |
3387 |
+ |
3388 |
+diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c |
3389 |
+index c5e4a1856a0f..4147d83e6fdd 100644 |
3390 |
+--- a/fs/f2fs/acl.c |
3391 |
++++ b/fs/f2fs/acl.c |
3392 |
+@@ -213,7 +213,7 @@ static int __f2fs_set_acl(struct inode *inode, int type, |
3393 |
+ switch (type) { |
3394 |
+ case ACL_TYPE_ACCESS: |
3395 |
+ name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; |
3396 |
+- if (acl) { |
3397 |
++ if (acl && !ipage) { |
3398 |
+ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); |
3399 |
+ if (error) |
3400 |
+ return error; |
3401 |
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c |
3402 |
+index 660183e9ab7c..f2ada269feb7 100644 |
3403 |
+--- a/fs/f2fs/super.c |
3404 |
++++ b/fs/f2fs/super.c |
3405 |
+@@ -979,6 +979,8 @@ static int sanity_check_ckpt(struct f2fs_sb_info *sbi) |
3406 |
+ unsigned int total, fsmeta; |
3407 |
+ struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); |
3408 |
+ struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); |
3409 |
++ unsigned int main_segs, blocks_per_seg; |
3410 |
++ int i; |
3411 |
+ |
3412 |
+ total = le32_to_cpu(raw_super->segment_count); |
3413 |
+ fsmeta = le32_to_cpu(raw_super->segment_count_ckpt); |
3414 |
+@@ -990,6 +992,20 @@ static int sanity_check_ckpt(struct f2fs_sb_info *sbi) |
3415 |
+ if (unlikely(fsmeta >= total)) |
3416 |
+ return 1; |
3417 |
+ |
3418 |
++ main_segs = le32_to_cpu(raw_super->segment_count_main); |
3419 |
++ blocks_per_seg = sbi->blocks_per_seg; |
3420 |
++ |
3421 |
++ for (i = 0; i < NR_CURSEG_NODE_TYPE; i++) { |
3422 |
++ if (le32_to_cpu(ckpt->cur_node_segno[i]) >= main_segs || |
3423 |
++ le16_to_cpu(ckpt->cur_node_blkoff[i]) >= blocks_per_seg) |
3424 |
++ return 1; |
3425 |
++ } |
3426 |
++ for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) { |
3427 |
++ if (le32_to_cpu(ckpt->cur_data_segno[i]) >= main_segs || |
3428 |
++ le16_to_cpu(ckpt->cur_data_blkoff[i]) >= blocks_per_seg) |
3429 |
++ return 1; |
3430 |
++ } |
3431 |
++ |
3432 |
+ if (unlikely(f2fs_cp_error(sbi))) { |
3433 |
+ f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck"); |
3434 |
+ return 1; |
3435 |
+diff --git a/fs/fuse/file.c b/fs/fuse/file.c |
3436 |
+index 1f03f0a36e35..cacf95ac49fe 100644 |
3437 |
+--- a/fs/fuse/file.c |
3438 |
++++ b/fs/fuse/file.c |
3439 |
+@@ -46,7 +46,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) |
3440 |
+ { |
3441 |
+ struct fuse_file *ff; |
3442 |
+ |
3443 |
+- ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); |
3444 |
++ ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL); |
3445 |
+ if (unlikely(!ff)) |
3446 |
+ return NULL; |
3447 |
+ |
3448 |
+diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig |
3449 |
+index f31fd0dd92c6..b1daeafbea92 100644 |
3450 |
+--- a/fs/nfs/Kconfig |
3451 |
++++ b/fs/nfs/Kconfig |
3452 |
+@@ -121,6 +121,7 @@ config PNFS_FILE_LAYOUT |
3453 |
+ config PNFS_BLOCK |
3454 |
+ tristate |
3455 |
+ depends on NFS_V4_1 && BLK_DEV_DM |
3456 |
++ depends on 64BIT || LBDAF |
3457 |
+ default NFS_V4 |
3458 |
+ |
3459 |
+ config PNFS_OBJLAYOUT |
3460 |
+diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c |
3461 |
+index b6d97dfa9cb6..4227adce3e52 100644 |
3462 |
+--- a/fs/nfs/dir.c |
3463 |
++++ b/fs/nfs/dir.c |
3464 |
+@@ -1154,11 +1154,13 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) |
3465 |
+ /* Force a full look up iff the parent directory has changed */ |
3466 |
+ if (!nfs_is_exclusive_create(dir, flags) && |
3467 |
+ nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { |
3468 |
+- |
3469 |
+- if (nfs_lookup_verify_inode(inode, flags)) { |
3470 |
++ error = nfs_lookup_verify_inode(inode, flags); |
3471 |
++ if (error) { |
3472 |
+ if (flags & LOOKUP_RCU) |
3473 |
+ return -ECHILD; |
3474 |
+- goto out_zap_parent; |
3475 |
++ if (error == -ESTALE) |
3476 |
++ goto out_zap_parent; |
3477 |
++ goto out_error; |
3478 |
+ } |
3479 |
+ goto out_valid; |
3480 |
+ } |
3481 |
+@@ -1182,8 +1184,10 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) |
3482 |
+ trace_nfs_lookup_revalidate_enter(dir, dentry, flags); |
3483 |
+ error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); |
3484 |
+ trace_nfs_lookup_revalidate_exit(dir, dentry, flags, error); |
3485 |
+- if (error) |
3486 |
++ if (error == -ESTALE || error == -ENOENT) |
3487 |
+ goto out_bad; |
3488 |
++ if (error) |
3489 |
++ goto out_error; |
3490 |
+ if (nfs_compare_fh(NFS_FH(inode), fhandle)) |
3491 |
+ goto out_bad; |
3492 |
+ if ((error = nfs_refresh_inode(inode, fattr)) != 0) |
3493 |
+diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c |
3494 |
+index b28fa4cbea52..a84dd247b13a 100644 |
3495 |
+--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c |
3496 |
++++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c |
3497 |
+@@ -30,6 +30,7 @@ void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds) |
3498 |
+ { |
3499 |
+ nfs4_print_deviceid(&mirror_ds->id_node.deviceid); |
3500 |
+ nfs4_pnfs_ds_put(mirror_ds->ds); |
3501 |
++ kfree(mirror_ds->ds_versions); |
3502 |
+ kfree_rcu(mirror_ds, id_node.rcu); |
3503 |
+ } |
3504 |
+ |
3505 |
+diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c |
3506 |
+index 723b8922d76b..8ddff9a72b34 100644 |
3507 |
+--- a/fs/nfs/inode.c |
3508 |
++++ b/fs/nfs/inode.c |
3509 |
+@@ -1227,9 +1227,9 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat |
3510 |
+ return 0; |
3511 |
+ /* Has the inode gone and changed behind our back? */ |
3512 |
+ if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid) |
3513 |
+- return -EIO; |
3514 |
++ return -ESTALE; |
3515 |
+ if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) |
3516 |
+- return -EIO; |
3517 |
++ return -ESTALE; |
3518 |
+ |
3519 |
+ if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && |
3520 |
+ inode->i_version != fattr->change_attr) |
3521 |
+diff --git a/fs/seq_file.c b/fs/seq_file.c |
3522 |
+index 4408057d1dc8..4dcf9d28f022 100644 |
3523 |
+--- a/fs/seq_file.c |
3524 |
++++ b/fs/seq_file.c |
3525 |
+@@ -62,9 +62,10 @@ int seq_open(struct file *file, const struct seq_operations *op) |
3526 |
+ memset(p, 0, sizeof(*p)); |
3527 |
+ mutex_init(&p->lock); |
3528 |
+ p->op = op; |
3529 |
+-#ifdef CONFIG_USER_NS |
3530 |
+- p->user_ns = file->f_cred->user_ns; |
3531 |
+-#endif |
3532 |
++ |
3533 |
++ // No refcounting: the lifetime of 'p' is constrained |
3534 |
++ // to the lifetime of the file. |
3535 |
++ p->file = file; |
3536 |
+ |
3537 |
+ /* |
3538 |
+ * Wrappers around seq_open(e.g. swaps_open) need to be |
3539 |
+diff --git a/fs/udf/inode.c b/fs/udf/inode.c |
3540 |
+index 78a40ef0c463..9635cd478cc9 100644 |
3541 |
+--- a/fs/udf/inode.c |
3542 |
++++ b/fs/udf/inode.c |
3543 |
+@@ -1235,8 +1235,8 @@ int udf_setsize(struct inode *inode, loff_t newsize) |
3544 |
+ return err; |
3545 |
+ } |
3546 |
+ set_size: |
3547 |
+- truncate_setsize(inode, newsize); |
3548 |
+ up_write(&iinfo->i_data_sem); |
3549 |
++ truncate_setsize(inode, newsize); |
3550 |
+ } else { |
3551 |
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
3552 |
+ down_write(&iinfo->i_data_sem); |
3553 |
+@@ -1253,9 +1253,9 @@ set_size: |
3554 |
+ udf_get_block); |
3555 |
+ if (err) |
3556 |
+ return err; |
3557 |
++ truncate_setsize(inode, newsize); |
3558 |
+ down_write(&iinfo->i_data_sem); |
3559 |
+ udf_clear_extent_cache(inode); |
3560 |
+- truncate_setsize(inode, newsize); |
3561 |
+ udf_truncate_extents(inode); |
3562 |
+ up_write(&iinfo->i_data_sem); |
3563 |
+ } |
3564 |
+diff --git a/include/linux/phy.h b/include/linux/phy.h |
3565 |
+index 685809835b5c..d164045e296c 100644 |
3566 |
+--- a/include/linux/phy.h |
3567 |
++++ b/include/linux/phy.h |
3568 |
+@@ -751,6 +751,10 @@ int genphy_read_status(struct phy_device *phydev); |
3569 |
+ int genphy_suspend(struct phy_device *phydev); |
3570 |
+ int genphy_resume(struct phy_device *phydev); |
3571 |
+ int genphy_soft_reset(struct phy_device *phydev); |
3572 |
++static inline int genphy_no_soft_reset(struct phy_device *phydev) |
3573 |
++{ |
3574 |
++ return 0; |
3575 |
++} |
3576 |
+ void phy_driver_unregister(struct phy_driver *drv); |
3577 |
+ void phy_drivers_unregister(struct phy_driver *drv, int n); |
3578 |
+ int phy_driver_register(struct phy_driver *new_driver); |
3579 |
+diff --git a/include/linux/sched.h b/include/linux/sched.h |
3580 |
+index af99802ce7fe..b6c033430b15 100644 |
3581 |
+--- a/include/linux/sched.h |
3582 |
++++ b/include/linux/sched.h |
3583 |
+@@ -774,6 +774,16 @@ struct signal_struct { |
3584 |
+ |
3585 |
+ #define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */ |
3586 |
+ |
3587 |
++#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \ |
3588 |
++ SIGNAL_STOP_CONTINUED) |
3589 |
++ |
3590 |
++static inline void signal_set_stop_flags(struct signal_struct *sig, |
3591 |
++ unsigned int flags) |
3592 |
++{ |
3593 |
++ WARN_ON(sig->flags & (SIGNAL_GROUP_EXIT|SIGNAL_GROUP_COREDUMP)); |
3594 |
++ sig->flags = (sig->flags & ~SIGNAL_STOP_MASK) | flags; |
3595 |
++} |
3596 |
++ |
3597 |
+ /* If true, all threads except ->group_exit_task have pending SIGKILL */ |
3598 |
+ static inline int signal_group_exit(const struct signal_struct *sig) |
3599 |
+ { |
3600 |
+diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h |
3601 |
+index 7848473a5bc8..f36c3a27f7f6 100644 |
3602 |
+--- a/include/linux/seq_file.h |
3603 |
++++ b/include/linux/seq_file.h |
3604 |
+@@ -7,13 +7,10 @@ |
3605 |
+ #include <linux/mutex.h> |
3606 |
+ #include <linux/cpumask.h> |
3607 |
+ #include <linux/nodemask.h> |
3608 |
++#include <linux/fs.h> |
3609 |
++#include <linux/cred.h> |
3610 |
+ |
3611 |
+ struct seq_operations; |
3612 |
+-struct file; |
3613 |
+-struct path; |
3614 |
+-struct inode; |
3615 |
+-struct dentry; |
3616 |
+-struct user_namespace; |
3617 |
+ |
3618 |
+ struct seq_file { |
3619 |
+ char *buf; |
3620 |
+@@ -27,9 +24,7 @@ struct seq_file { |
3621 |
+ struct mutex lock; |
3622 |
+ const struct seq_operations *op; |
3623 |
+ int poll_event; |
3624 |
+-#ifdef CONFIG_USER_NS |
3625 |
+- struct user_namespace *user_ns; |
3626 |
+-#endif |
3627 |
++ const struct file *file; |
3628 |
+ void *private; |
3629 |
+ }; |
3630 |
+ |
3631 |
+@@ -141,7 +136,7 @@ int seq_put_decimal_ll(struct seq_file *m, char delimiter, |
3632 |
+ static inline struct user_namespace *seq_user_ns(struct seq_file *seq) |
3633 |
+ { |
3634 |
+ #ifdef CONFIG_USER_NS |
3635 |
+- return seq->user_ns; |
3636 |
++ return seq->file->f_cred->user_ns; |
3637 |
+ #else |
3638 |
+ extern struct user_namespace init_user_ns; |
3639 |
+ return &init_user_ns; |
3640 |
+diff --git a/include/linux/slab.h b/include/linux/slab.h |
3641 |
+index ffd24c830151..ef441d93cea0 100644 |
3642 |
+--- a/include/linux/slab.h |
3643 |
++++ b/include/linux/slab.h |
3644 |
+@@ -185,7 +185,7 @@ size_t ksize(const void *); |
3645 |
+ * (PAGE_SIZE*2). Larger requests are passed to the page allocator. |
3646 |
+ */ |
3647 |
+ #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) |
3648 |
+-#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT) |
3649 |
++#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) |
3650 |
+ #ifndef KMALLOC_SHIFT_LOW |
3651 |
+ #define KMALLOC_SHIFT_LOW 3 |
3652 |
+ #endif |
3653 |
+@@ -198,7 +198,7 @@ size_t ksize(const void *); |
3654 |
+ * be allocated from the same page. |
3655 |
+ */ |
3656 |
+ #define KMALLOC_SHIFT_HIGH PAGE_SHIFT |
3657 |
+-#define KMALLOC_SHIFT_MAX 30 |
3658 |
++#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) |
3659 |
+ #ifndef KMALLOC_SHIFT_LOW |
3660 |
+ #define KMALLOC_SHIFT_LOW 3 |
3661 |
+ #endif |
3662 |
+diff --git a/include/linux/vfio.h b/include/linux/vfio.h |
3663 |
+index ddb440975382..34851bf2e2c8 100644 |
3664 |
+--- a/include/linux/vfio.h |
3665 |
++++ b/include/linux/vfio.h |
3666 |
+@@ -85,6 +85,8 @@ extern void vfio_unregister_iommu_driver( |
3667 |
+ */ |
3668 |
+ extern struct vfio_group *vfio_group_get_external_user(struct file *filep); |
3669 |
+ extern void vfio_group_put_external_user(struct vfio_group *group); |
3670 |
++extern bool vfio_external_group_match_file(struct vfio_group *group, |
3671 |
++ struct file *filep); |
3672 |
+ extern int vfio_external_user_iommu_id(struct vfio_group *group); |
3673 |
+ extern long vfio_external_check_extension(struct vfio_group *group, |
3674 |
+ unsigned long arg); |
3675 |
+diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h |
3676 |
+index e0f4109e64c6..c2aa73e5e6bb 100644 |
3677 |
+--- a/include/net/iw_handler.h |
3678 |
++++ b/include/net/iw_handler.h |
3679 |
+@@ -556,7 +556,8 @@ iwe_stream_add_point(struct iw_request_info *info, char *stream, char *ends, |
3680 |
+ memcpy(stream + lcp_len, |
3681 |
+ ((char *) &iwe->u) + IW_EV_POINT_OFF, |
3682 |
+ IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); |
3683 |
+- memcpy(stream + point_len, extra, iwe->u.data.length); |
3684 |
++ if (iwe->u.data.length && extra) |
3685 |
++ memcpy(stream + point_len, extra, iwe->u.data.length); |
3686 |
+ stream += event_len; |
3687 |
+ } |
3688 |
+ return stream; |
3689 |
+diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h |
3690 |
+index ce13cf20f625..d33b17ba51d2 100644 |
3691 |
+--- a/include/net/sctp/sctp.h |
3692 |
++++ b/include/net/sctp/sctp.h |
3693 |
+@@ -444,6 +444,8 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) |
3694 |
+ |
3695 |
+ #define _sctp_walk_params(pos, chunk, end, member)\ |
3696 |
+ for (pos.v = chunk->member;\ |
3697 |
++ (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\ |
3698 |
++ (void *)chunk + end) &&\ |
3699 |
+ pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ |
3700 |
+ ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ |
3701 |
+ pos.v += WORD_ROUND(ntohs(pos.p->length))) |
3702 |
+@@ -454,6 +456,8 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) |
3703 |
+ #define _sctp_walk_errors(err, chunk_hdr, end)\ |
3704 |
+ for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ |
3705 |
+ sizeof(sctp_chunkhdr_t));\ |
3706 |
++ ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <=\ |
3707 |
++ (void *)chunk_hdr + end) &&\ |
3708 |
+ (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ |
3709 |
+ ntohs(err->length) >= sizeof(sctp_errhdr_t); \ |
3710 |
+ err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) |
3711 |
+diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h |
3712 |
+index e37059c901e2..e12eec076cd5 100644 |
3713 |
+--- a/include/target/iscsi/iscsi_target_core.h |
3714 |
++++ b/include/target/iscsi/iscsi_target_core.h |
3715 |
+@@ -785,6 +785,7 @@ struct iscsi_np { |
3716 |
+ int np_sock_type; |
3717 |
+ enum np_thread_state_table np_thread_state; |
3718 |
+ bool enabled; |
3719 |
++ atomic_t np_reset_count; |
3720 |
+ enum iscsi_timer_flags_table np_login_timer_flags; |
3721 |
+ u32 np_exports; |
3722 |
+ enum np_flags_table np_flags; |
3723 |
+diff --git a/kernel/events/core.c b/kernel/events/core.c |
3724 |
+index 10e9eec3e228..e871080bc44e 100644 |
3725 |
+--- a/kernel/events/core.c |
3726 |
++++ b/kernel/events/core.c |
3727 |
+@@ -6111,21 +6111,6 @@ static void perf_log_itrace_start(struct perf_event *event) |
3728 |
+ perf_output_end(&handle); |
3729 |
+ } |
3730 |
+ |
3731 |
+-static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs) |
3732 |
+-{ |
3733 |
+- /* |
3734 |
+- * Due to interrupt latency (AKA "skid"), we may enter the |
3735 |
+- * kernel before taking an overflow, even if the PMU is only |
3736 |
+- * counting user events. |
3737 |
+- * To avoid leaking information to userspace, we must always |
3738 |
+- * reject kernel samples when exclude_kernel is set. |
3739 |
+- */ |
3740 |
+- if (event->attr.exclude_kernel && !user_mode(regs)) |
3741 |
+- return false; |
3742 |
+- |
3743 |
+- return true; |
3744 |
+-} |
3745 |
+- |
3746 |
+ /* |
3747 |
+ * Generic event overflow handling, sampling. |
3748 |
+ */ |
3749 |
+@@ -6172,12 +6157,6 @@ static int __perf_event_overflow(struct perf_event *event, |
3750 |
+ perf_adjust_period(event, delta, hwc->last_period, true); |
3751 |
+ } |
3752 |
+ |
3753 |
+- /* |
3754 |
+- * For security, drop the skid kernel samples if necessary. |
3755 |
+- */ |
3756 |
+- if (!sample_is_allowed(event, regs)) |
3757 |
+- return ret; |
3758 |
+- |
3759 |
+ /* |
3760 |
+ * XXX event_limit might not quite work as expected on inherited |
3761 |
+ * events |
3762 |
+diff --git a/kernel/resource.c b/kernel/resource.c |
3763 |
+index a7c27cb71fc5..cbf725c24c3b 100644 |
3764 |
+--- a/kernel/resource.c |
3765 |
++++ b/kernel/resource.c |
3766 |
+@@ -105,16 +105,25 @@ static int r_show(struct seq_file *m, void *v) |
3767 |
+ { |
3768 |
+ struct resource *root = m->private; |
3769 |
+ struct resource *r = v, *p; |
3770 |
++ unsigned long long start, end; |
3771 |
+ int width = root->end < 0x10000 ? 4 : 8; |
3772 |
+ int depth; |
3773 |
+ |
3774 |
+ for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) |
3775 |
+ if (p->parent == root) |
3776 |
+ break; |
3777 |
++ |
3778 |
++ if (file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) { |
3779 |
++ start = r->start; |
3780 |
++ end = r->end; |
3781 |
++ } else { |
3782 |
++ start = end = 0; |
3783 |
++ } |
3784 |
++ |
3785 |
+ seq_printf(m, "%*s%0*llx-%0*llx : %s\n", |
3786 |
+ depth * 2, "", |
3787 |
+- width, (unsigned long long) r->start, |
3788 |
+- width, (unsigned long long) r->end, |
3789 |
++ width, start, |
3790 |
++ width, end, |
3791 |
+ r->name ? r->name : "<BAD>"); |
3792 |
+ return 0; |
3793 |
+ } |
3794 |
+diff --git a/kernel/signal.c b/kernel/signal.c |
3795 |
+index 0206be728dac..525a4cda5598 100644 |
3796 |
+--- a/kernel/signal.c |
3797 |
++++ b/kernel/signal.c |
3798 |
+@@ -346,7 +346,7 @@ static bool task_participate_group_stop(struct task_struct *task) |
3799 |
+ * fresh group stop. Read comment in do_signal_stop() for details. |
3800 |
+ */ |
3801 |
+ if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) { |
3802 |
+- sig->flags = SIGNAL_STOP_STOPPED; |
3803 |
++ signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED); |
3804 |
+ return true; |
3805 |
+ } |
3806 |
+ return false; |
3807 |
+@@ -888,7 +888,7 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force) |
3808 |
+ * will take ->siglock, notice SIGNAL_CLD_MASK, and |
3809 |
+ * notify its parent. See get_signal_to_deliver(). |
3810 |
+ */ |
3811 |
+- signal->flags = why | SIGNAL_STOP_CONTINUED; |
3812 |
++ signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED); |
3813 |
+ signal->group_stop_count = 0; |
3814 |
+ signal->group_exit_code = 0; |
3815 |
+ } |
3816 |
+diff --git a/kernel/workqueue.c b/kernel/workqueue.c |
3817 |
+index d0efe9295a0e..9cdf3bfc9178 100644 |
3818 |
+--- a/kernel/workqueue.c |
3819 |
++++ b/kernel/workqueue.c |
3820 |
+@@ -3854,6 +3854,16 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, |
3821 |
+ struct workqueue_struct *wq; |
3822 |
+ struct pool_workqueue *pwq; |
3823 |
+ |
3824 |
++ /* |
3825 |
++ * Unbound && max_active == 1 used to imply ordered, which is no |
3826 |
++ * longer the case on NUMA machines due to per-node pools. While |
3827 |
++ * alloc_ordered_workqueue() is the right way to create an ordered |
3828 |
++ * workqueue, keep the previous behavior to avoid subtle breakages |
3829 |
++ * on NUMA. |
3830 |
++ */ |
3831 |
++ if ((flags & WQ_UNBOUND) && max_active == 1) |
3832 |
++ flags |= __WQ_ORDERED; |
3833 |
++ |
3834 |
+ /* see the comment above the definition of WQ_POWER_EFFICIENT */ |
3835 |
+ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) |
3836 |
+ flags |= WQ_UNBOUND; |
3837 |
+diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug |
3838 |
+index ba2b0c87e65b..c986a6198b0e 100644 |
3839 |
+--- a/lib/Kconfig.debug |
3840 |
++++ b/lib/Kconfig.debug |
3841 |
+@@ -145,7 +145,7 @@ config DEBUG_INFO_REDUCED |
3842 |
+ |
3843 |
+ config DEBUG_INFO_SPLIT |
3844 |
+ bool "Produce split debuginfo in .dwo files" |
3845 |
+- depends on DEBUG_INFO |
3846 |
++ depends on DEBUG_INFO && !FRV |
3847 |
+ help |
3848 |
+ Generate debug info into separate .dwo files. This significantly |
3849 |
+ reduces the build directory size for builds with DEBUG_INFO, |
3850 |
+diff --git a/mm/mempool.c b/mm/mempool.c |
3851 |
+index 2cc08de8b1db..70cccdcff860 100644 |
3852 |
+--- a/mm/mempool.c |
3853 |
++++ b/mm/mempool.c |
3854 |
+@@ -135,8 +135,8 @@ static void *remove_element(mempool_t *pool) |
3855 |
+ void *element = pool->elements[--pool->curr_nr]; |
3856 |
+ |
3857 |
+ BUG_ON(pool->curr_nr < 0); |
3858 |
+- check_element(pool, element); |
3859 |
+ kasan_unpoison_element(pool, element); |
3860 |
++ check_element(pool, element); |
3861 |
+ return element; |
3862 |
+ } |
3863 |
+ |
3864 |
+diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
3865 |
+index 4f1ff71074c7..35bda77211ea 100644 |
3866 |
+--- a/mm/page_alloc.c |
3867 |
++++ b/mm/page_alloc.c |
3868 |
+@@ -1106,14 +1106,14 @@ int move_freepages(struct zone *zone, |
3869 |
+ #endif |
3870 |
+ |
3871 |
+ for (page = start_page; page <= end_page;) { |
3872 |
+- /* Make sure we are not inadvertently changing nodes */ |
3873 |
+- VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page); |
3874 |
+- |
3875 |
+ if (!pfn_valid_within(page_to_pfn(page))) { |
3876 |
+ page++; |
3877 |
+ continue; |
3878 |
+ } |
3879 |
+ |
3880 |
++ /* Make sure we are not inadvertently changing nodes */ |
3881 |
++ VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page); |
3882 |
++ |
3883 |
+ if (!PageBuddy(page)) { |
3884 |
+ page++; |
3885 |
+ continue; |
3886 |
+@@ -5555,8 +5555,8 @@ unsigned long free_reserved_area(void *start, void *end, int poison, char *s) |
3887 |
+ } |
3888 |
+ |
3889 |
+ if (pages && s) |
3890 |
+- pr_info("Freeing %s memory: %ldK (%p - %p)\n", |
3891 |
+- s, pages << (PAGE_SHIFT - 10), start, end); |
3892 |
++ pr_info("Freeing %s memory: %ldK\n", |
3893 |
++ s, pages << (PAGE_SHIFT - 10)); |
3894 |
+ |
3895 |
+ return pages; |
3896 |
+ } |
3897 |
+@@ -6513,7 +6513,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, |
3898 |
+ |
3899 |
+ /* Make sure the range is really isolated. */ |
3900 |
+ if (test_pages_isolated(outer_start, end, false)) { |
3901 |
+- pr_info("%s: [%lx, %lx) PFNs busy\n", |
3902 |
++ pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", |
3903 |
+ __func__, outer_start, end); |
3904 |
+ ret = -EBUSY; |
3905 |
+ goto done; |
3906 |
+diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c |
3907 |
+index d45e590e8f10..dfecba30d83a 100644 |
3908 |
+--- a/net/8021q/vlan.c |
3909 |
++++ b/net/8021q/vlan.c |
3910 |
+@@ -292,6 +292,10 @@ static void vlan_sync_address(struct net_device *dev, |
3911 |
+ if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr)) |
3912 |
+ return; |
3913 |
+ |
3914 |
++ /* vlan continues to inherit address of lower device */ |
3915 |
++ if (vlan_dev_inherit_address(vlandev, dev)) |
3916 |
++ goto out; |
3917 |
++ |
3918 |
+ /* vlan address was different from the old address and is equal to |
3919 |
+ * the new address */ |
3920 |
+ if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) && |
3921 |
+@@ -304,6 +308,7 @@ static void vlan_sync_address(struct net_device *dev, |
3922 |
+ !ether_addr_equal(vlandev->dev_addr, dev->dev_addr)) |
3923 |
+ dev_uc_add(dev, vlandev->dev_addr); |
3924 |
+ |
3925 |
++out: |
3926 |
+ ether_addr_copy(vlan->real_dev_addr, dev->dev_addr); |
3927 |
+ } |
3928 |
+ |
3929 |
+diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h |
3930 |
+index 9d010a09ab98..cc1557978066 100644 |
3931 |
+--- a/net/8021q/vlan.h |
3932 |
++++ b/net/8021q/vlan.h |
3933 |
+@@ -109,6 +109,8 @@ int vlan_check_real_dev(struct net_device *real_dev, |
3934 |
+ void vlan_setup(struct net_device *dev); |
3935 |
+ int register_vlan_dev(struct net_device *dev); |
3936 |
+ void unregister_vlan_dev(struct net_device *dev, struct list_head *head); |
3937 |
++bool vlan_dev_inherit_address(struct net_device *dev, |
3938 |
++ struct net_device *real_dev); |
3939 |
+ |
3940 |
+ static inline u32 vlan_get_ingress_priority(struct net_device *dev, |
3941 |
+ u16 vlan_tci) |
3942 |
+diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c |
3943 |
+index 01d7ba840df8..93010f34c200 100644 |
3944 |
+--- a/net/8021q/vlan_dev.c |
3945 |
++++ b/net/8021q/vlan_dev.c |
3946 |
+@@ -244,6 +244,17 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result) |
3947 |
+ strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23); |
3948 |
+ } |
3949 |
+ |
3950 |
++bool vlan_dev_inherit_address(struct net_device *dev, |
3951 |
++ struct net_device *real_dev) |
3952 |
++{ |
3953 |
++ if (dev->addr_assign_type != NET_ADDR_STOLEN) |
3954 |
++ return false; |
3955 |
++ |
3956 |
++ ether_addr_copy(dev->dev_addr, real_dev->dev_addr); |
3957 |
++ call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); |
3958 |
++ return true; |
3959 |
++} |
3960 |
++ |
3961 |
+ static int vlan_dev_open(struct net_device *dev) |
3962 |
+ { |
3963 |
+ struct vlan_dev_priv *vlan = vlan_dev_priv(dev); |
3964 |
+@@ -254,7 +265,8 @@ static int vlan_dev_open(struct net_device *dev) |
3965 |
+ !(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) |
3966 |
+ return -ENETDOWN; |
3967 |
+ |
3968 |
+- if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) { |
3969 |
++ if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) && |
3970 |
++ !vlan_dev_inherit_address(dev, real_dev)) { |
3971 |
+ err = dev_uc_add(real_dev, dev->dev_addr); |
3972 |
+ if (err < 0) |
3973 |
+ goto out; |
3974 |
+@@ -558,8 +570,10 @@ static int vlan_dev_init(struct net_device *dev) |
3975 |
+ /* ipv6 shared card related stuff */ |
3976 |
+ dev->dev_id = real_dev->dev_id; |
3977 |
+ |
3978 |
+- if (is_zero_ether_addr(dev->dev_addr)) |
3979 |
+- eth_hw_addr_inherit(dev, real_dev); |
3980 |
++ if (is_zero_ether_addr(dev->dev_addr)) { |
3981 |
++ ether_addr_copy(dev->dev_addr, real_dev->dev_addr); |
3982 |
++ dev->addr_assign_type = NET_ADDR_STOLEN; |
3983 |
++ } |
3984 |
+ if (is_zero_ether_addr(dev->broadcast)) |
3985 |
+ memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len); |
3986 |
+ |
3987 |
+diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c |
3988 |
+index 69ad5091e2ce..e4b56fcb5d4e 100644 |
3989 |
+--- a/net/bluetooth/smp.c |
3990 |
++++ b/net/bluetooth/smp.c |
3991 |
+@@ -23,6 +23,7 @@ |
3992 |
+ #include <linux/debugfs.h> |
3993 |
+ #include <linux/crypto.h> |
3994 |
+ #include <linux/scatterlist.h> |
3995 |
++#include <crypto/algapi.h> |
3996 |
+ #include <crypto/b128ops.h> |
3997 |
+ |
3998 |
+ #include <net/bluetooth/bluetooth.h> |
3999 |
+@@ -506,7 +507,7 @@ bool smp_irk_matches(struct hci_dev *hdev, const u8 irk[16], |
4000 |
+ if (err) |
4001 |
+ return false; |
4002 |
+ |
4003 |
+- return !memcmp(bdaddr->b, hash, 3); |
4004 |
++ return !crypto_memneq(bdaddr->b, hash, 3); |
4005 |
+ } |
4006 |
+ |
4007 |
+ int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa) |
4008 |
+@@ -559,7 +560,7 @@ int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16]) |
4009 |
+ /* This is unlikely, but we need to check that |
4010 |
+ * we didn't accidentially generate a debug key. |
4011 |
+ */ |
4012 |
+- if (memcmp(smp->local_sk, debug_sk, 32)) |
4013 |
++ if (crypto_memneq(smp->local_sk, debug_sk, 32)) |
4014 |
+ break; |
4015 |
+ } |
4016 |
+ smp->debug_key = false; |
4017 |
+@@ -973,7 +974,7 @@ static u8 smp_random(struct smp_chan *smp) |
4018 |
+ if (ret) |
4019 |
+ return SMP_UNSPECIFIED; |
4020 |
+ |
4021 |
+- if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { |
4022 |
++ if (crypto_memneq(smp->pcnf, confirm, sizeof(smp->pcnf))) { |
4023 |
+ BT_ERR("Pairing failed (confirmation values mismatch)"); |
4024 |
+ return SMP_CONFIRM_FAILED; |
4025 |
+ } |
4026 |
+@@ -1490,7 +1491,7 @@ static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op) |
4027 |
+ smp->rrnd, r, cfm)) |
4028 |
+ return SMP_UNSPECIFIED; |
4029 |
+ |
4030 |
+- if (memcmp(smp->pcnf, cfm, 16)) |
4031 |
++ if (crypto_memneq(smp->pcnf, cfm, 16)) |
4032 |
+ return SMP_CONFIRM_FAILED; |
4033 |
+ |
4034 |
+ smp->passkey_round++; |
4035 |
+@@ -1874,7 +1875,7 @@ static u8 sc_send_public_key(struct smp_chan *smp) |
4036 |
+ /* This is unlikely, but we need to check that |
4037 |
+ * we didn't accidentially generate a debug key. |
4038 |
+ */ |
4039 |
+- if (memcmp(smp->local_sk, debug_sk, 32)) |
4040 |
++ if (crypto_memneq(smp->local_sk, debug_sk, 32)) |
4041 |
+ break; |
4042 |
+ } |
4043 |
+ } |
4044 |
+@@ -2139,7 +2140,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) |
4045 |
+ if (err) |
4046 |
+ return SMP_UNSPECIFIED; |
4047 |
+ |
4048 |
+- if (memcmp(smp->pcnf, cfm, 16)) |
4049 |
++ if (crypto_memneq(smp->pcnf, cfm, 16)) |
4050 |
+ return SMP_CONFIRM_FAILED; |
4051 |
+ } else { |
4052 |
+ smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), |
4053 |
+@@ -2594,7 +2595,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) |
4054 |
+ if (err) |
4055 |
+ return SMP_UNSPECIFIED; |
4056 |
+ |
4057 |
+- if (memcmp(cfm.confirm_val, smp->pcnf, 16)) |
4058 |
++ if (crypto_memneq(cfm.confirm_val, smp->pcnf, 16)) |
4059 |
+ return SMP_CONFIRM_FAILED; |
4060 |
+ } |
4061 |
+ |
4062 |
+@@ -2627,7 +2628,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) |
4063 |
+ else |
4064 |
+ hcon->pending_sec_level = BT_SECURITY_FIPS; |
4065 |
+ |
4066 |
+- if (!memcmp(debug_pk, smp->remote_pk, 64)) |
4067 |
++ if (!crypto_memneq(debug_pk, smp->remote_pk, 64)) |
4068 |
+ set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); |
4069 |
+ |
4070 |
+ if (smp->method == DSP_PASSKEY) { |
4071 |
+@@ -2726,7 +2727,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb) |
4072 |
+ if (err) |
4073 |
+ return SMP_UNSPECIFIED; |
4074 |
+ |
4075 |
+- if (memcmp(check->e, e, 16)) |
4076 |
++ if (crypto_memneq(check->e, e, 16)) |
4077 |
+ return SMP_DHKEY_CHECK_FAILED; |
4078 |
+ |
4079 |
+ if (!hcon->out) { |
4080 |
+@@ -3336,7 +3337,7 @@ static int __init test_ah(struct crypto_blkcipher *tfm_aes) |
4081 |
+ if (err) |
4082 |
+ return err; |
4083 |
+ |
4084 |
+- if (memcmp(res, exp, 3)) |
4085 |
++ if (crypto_memneq(res, exp, 3)) |
4086 |
+ return -EINVAL; |
4087 |
+ |
4088 |
+ return 0; |
4089 |
+@@ -3366,7 +3367,7 @@ static int __init test_c1(struct crypto_blkcipher *tfm_aes) |
4090 |
+ if (err) |
4091 |
+ return err; |
4092 |
+ |
4093 |
+- if (memcmp(res, exp, 16)) |
4094 |
++ if (crypto_memneq(res, exp, 16)) |
4095 |
+ return -EINVAL; |
4096 |
+ |
4097 |
+ return 0; |
4098 |
+@@ -3391,7 +3392,7 @@ static int __init test_s1(struct crypto_blkcipher *tfm_aes) |
4099 |
+ if (err) |
4100 |
+ return err; |
4101 |
+ |
4102 |
+- if (memcmp(res, exp, 16)) |
4103 |
++ if (crypto_memneq(res, exp, 16)) |
4104 |
+ return -EINVAL; |
4105 |
+ |
4106 |
+ return 0; |
4107 |
+@@ -3423,7 +3424,7 @@ static int __init test_f4(struct crypto_hash *tfm_cmac) |
4108 |
+ if (err) |
4109 |
+ return err; |
4110 |
+ |
4111 |
+- if (memcmp(res, exp, 16)) |
4112 |
++ if (crypto_memneq(res, exp, 16)) |
4113 |
+ return -EINVAL; |
4114 |
+ |
4115 |
+ return 0; |
4116 |
+@@ -3457,10 +3458,10 @@ static int __init test_f5(struct crypto_hash *tfm_cmac) |
4117 |
+ if (err) |
4118 |
+ return err; |
4119 |
+ |
4120 |
+- if (memcmp(mackey, exp_mackey, 16)) |
4121 |
++ if (crypto_memneq(mackey, exp_mackey, 16)) |
4122 |
+ return -EINVAL; |
4123 |
+ |
4124 |
+- if (memcmp(ltk, exp_ltk, 16)) |
4125 |
++ if (crypto_memneq(ltk, exp_ltk, 16)) |
4126 |
+ return -EINVAL; |
4127 |
+ |
4128 |
+ return 0; |
4129 |
+@@ -3493,7 +3494,7 @@ static int __init test_f6(struct crypto_hash *tfm_cmac) |
4130 |
+ if (err) |
4131 |
+ return err; |
4132 |
+ |
4133 |
+- if (memcmp(res, exp, 16)) |
4134 |
++ if (crypto_memneq(res, exp, 16)) |
4135 |
+ return -EINVAL; |
4136 |
+ |
4137 |
+ return 0; |
4138 |
+@@ -3547,7 +3548,7 @@ static int __init test_h6(struct crypto_hash *tfm_cmac) |
4139 |
+ if (err) |
4140 |
+ return err; |
4141 |
+ |
4142 |
+- if (memcmp(res, exp, 16)) |
4143 |
++ if (crypto_memneq(res, exp, 16)) |
4144 |
+ return -EINVAL; |
4145 |
+ |
4146 |
+ return 0; |
4147 |
+diff --git a/net/core/dev.c b/net/core/dev.c |
4148 |
+index bd47736b689e..bb711e5e345b 100644 |
4149 |
+--- a/net/core/dev.c |
4150 |
++++ b/net/core/dev.c |
4151 |
+@@ -2465,9 +2465,10 @@ EXPORT_SYMBOL(skb_mac_gso_segment); |
4152 |
+ static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path) |
4153 |
+ { |
4154 |
+ if (tx_path) |
4155 |
+- return skb->ip_summed != CHECKSUM_PARTIAL; |
4156 |
+- else |
4157 |
+- return skb->ip_summed == CHECKSUM_NONE; |
4158 |
++ return skb->ip_summed != CHECKSUM_PARTIAL && |
4159 |
++ skb->ip_summed != CHECKSUM_UNNECESSARY; |
4160 |
++ |
4161 |
++ return skb->ip_summed == CHECKSUM_NONE; |
4162 |
+ } |
4163 |
+ |
4164 |
+ /** |
4165 |
+@@ -2486,11 +2487,12 @@ static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path) |
4166 |
+ struct sk_buff *__skb_gso_segment(struct sk_buff *skb, |
4167 |
+ netdev_features_t features, bool tx_path) |
4168 |
+ { |
4169 |
++ struct sk_buff *segs; |
4170 |
++ |
4171 |
+ if (unlikely(skb_needs_check(skb, tx_path))) { |
4172 |
+ int err; |
4173 |
+ |
4174 |
+- skb_warn_bad_offload(skb); |
4175 |
+- |
4176 |
++ /* We're going to init ->check field in TCP or UDP header */ |
4177 |
+ err = skb_cow_head(skb, 0); |
4178 |
+ if (err < 0) |
4179 |
+ return ERR_PTR(err); |
4180 |
+@@ -2505,7 +2507,12 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb, |
4181 |
+ skb_reset_mac_header(skb); |
4182 |
+ skb_reset_mac_len(skb); |
4183 |
+ |
4184 |
+- return skb_mac_gso_segment(skb, features); |
4185 |
++ segs = skb_mac_gso_segment(skb, features); |
4186 |
++ |
4187 |
++ if (unlikely(skb_needs_check(skb, tx_path))) |
4188 |
++ skb_warn_bad_offload(skb); |
4189 |
++ |
4190 |
++ return segs; |
4191 |
+ } |
4192 |
+ EXPORT_SYMBOL(__skb_gso_segment); |
4193 |
+ |
4194 |
+diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c |
4195 |
+index b94b1d293506..151e047ce072 100644 |
4196 |
+--- a/net/core/dev_ioctl.c |
4197 |
++++ b/net/core/dev_ioctl.c |
4198 |
+@@ -28,6 +28,7 @@ static int dev_ifname(struct net *net, struct ifreq __user *arg) |
4199 |
+ |
4200 |
+ if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) |
4201 |
+ return -EFAULT; |
4202 |
++ ifr.ifr_name[IFNAMSIZ-1] = 0; |
4203 |
+ |
4204 |
+ error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex); |
4205 |
+ if (error) |
4206 |
+diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c |
4207 |
+index 7a0d98628137..3936683486e9 100644 |
4208 |
+--- a/net/core/rtnetlink.c |
4209 |
++++ b/net/core/rtnetlink.c |
4210 |
+@@ -1628,7 +1628,8 @@ static int do_setlink(const struct sk_buff *skb, |
4211 |
+ struct sockaddr *sa; |
4212 |
+ int len; |
4213 |
+ |
4214 |
+- len = sizeof(sa_family_t) + dev->addr_len; |
4215 |
++ len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len, |
4216 |
++ sizeof(*sa)); |
4217 |
+ sa = kmalloc(len, GFP_KERNEL); |
4218 |
+ if (!sa) { |
4219 |
+ err = -ENOMEM; |
4220 |
+diff --git a/net/dccp/feat.c b/net/dccp/feat.c |
4221 |
+index 1704948e6a12..f227f002c73d 100644 |
4222 |
+--- a/net/dccp/feat.c |
4223 |
++++ b/net/dccp/feat.c |
4224 |
+@@ -1471,9 +1471,12 @@ int dccp_feat_init(struct sock *sk) |
4225 |
+ * singleton values (which always leads to failure). |
4226 |
+ * These settings can still (later) be overridden via sockopts. |
4227 |
+ */ |
4228 |
+- if (ccid_get_builtin_ccids(&tx.val, &tx.len) || |
4229 |
+- ccid_get_builtin_ccids(&rx.val, &rx.len)) |
4230 |
++ if (ccid_get_builtin_ccids(&tx.val, &tx.len)) |
4231 |
+ return -ENOBUFS; |
4232 |
++ if (ccid_get_builtin_ccids(&rx.val, &rx.len)) { |
4233 |
++ kfree(tx.val); |
4234 |
++ return -ENOBUFS; |
4235 |
++ } |
4236 |
+ |
4237 |
+ if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) || |
4238 |
+ !dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len)) |
4239 |
+diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c |
4240 |
+index ccf4c5629b3c..fd7ac7895c38 100644 |
4241 |
+--- a/net/dccp/ipv4.c |
4242 |
++++ b/net/dccp/ipv4.c |
4243 |
+@@ -661,6 +661,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) |
4244 |
+ goto drop_and_free; |
4245 |
+ |
4246 |
+ inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); |
4247 |
++ reqsk_put(req); |
4248 |
+ return 0; |
4249 |
+ |
4250 |
+ drop_and_free: |
4251 |
+diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c |
4252 |
+index 513b6aabc5b7..765909ba781e 100644 |
4253 |
+--- a/net/ipv4/fib_frontend.c |
4254 |
++++ b/net/ipv4/fib_frontend.c |
4255 |
+@@ -1247,13 +1247,14 @@ static struct pernet_operations fib_net_ops = { |
4256 |
+ |
4257 |
+ void __init ip_fib_init(void) |
4258 |
+ { |
4259 |
+- rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL); |
4260 |
+- rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL); |
4261 |
+- rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL); |
4262 |
++ fib_trie_init(); |
4263 |
+ |
4264 |
+ register_pernet_subsys(&fib_net_ops); |
4265 |
++ |
4266 |
+ register_netdevice_notifier(&fib_netdev_notifier); |
4267 |
+ register_inetaddr_notifier(&fib_inetaddr_notifier); |
4268 |
+ |
4269 |
+- fib_trie_init(); |
4270 |
++ rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL); |
4271 |
++ rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL); |
4272 |
++ rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL); |
4273 |
+ } |
4274 |
+diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c |
4275 |
+index 51573f8a39bc..adbb28b39413 100644 |
4276 |
+--- a/net/ipv4/ip_output.c |
4277 |
++++ b/net/ipv4/ip_output.c |
4278 |
+@@ -891,7 +891,7 @@ static int __ip_append_data(struct sock *sk, |
4279 |
+ csummode = CHECKSUM_PARTIAL; |
4280 |
+ |
4281 |
+ cork->length += length; |
4282 |
+- if (((length > mtu) || (skb && skb_is_gso(skb))) && |
4283 |
++ if ((((length + fragheaderlen) > mtu) || (skb && skb_is_gso(skb))) && |
4284 |
+ (sk->sk_protocol == IPPROTO_UDP) && |
4285 |
+ (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && |
4286 |
+ (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) { |
4287 |
+diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c |
4288 |
+index 4a3a17ff046d..767ee7471c9b 100644 |
4289 |
+--- a/net/ipv4/tcp_input.c |
4290 |
++++ b/net/ipv4/tcp_input.c |
4291 |
+@@ -2536,8 +2536,8 @@ static inline void tcp_end_cwnd_reduction(struct sock *sk) |
4292 |
+ struct tcp_sock *tp = tcp_sk(sk); |
4293 |
+ |
4294 |
+ /* Reset cwnd to ssthresh in CWR or Recovery (unless it's undone) */ |
4295 |
+- if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR || |
4296 |
+- (tp->undo_marker && tp->snd_ssthresh < TCP_INFINITE_SSTHRESH)) { |
4297 |
++ if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH && |
4298 |
++ (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR || tp->undo_marker)) { |
4299 |
+ tp->snd_cwnd = tp->snd_ssthresh; |
4300 |
+ tp->snd_cwnd_stamp = tcp_time_stamp; |
4301 |
+ } |
4302 |
+diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c |
4303 |
+index dfcab88c3e74..8f27dce93f71 100644 |
4304 |
+--- a/net/ipv4/udp_offload.c |
4305 |
++++ b/net/ipv4/udp_offload.c |
4306 |
+@@ -231,7 +231,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, |
4307 |
+ if (uh->check == 0) |
4308 |
+ uh->check = CSUM_MANGLED_0; |
4309 |
+ |
4310 |
+- skb->ip_summed = CHECKSUM_NONE; |
4311 |
++ skb->ip_summed = CHECKSUM_UNNECESSARY; |
4312 |
+ |
4313 |
+ /* Fragment the skb. IP headers of the fragments are updated in |
4314 |
+ * inet_gso_segment() |
4315 |
+diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c |
4316 |
+index eefb8759cfa4..29a1ffa72cd0 100644 |
4317 |
+--- a/net/ipv6/ip6_output.c |
4318 |
++++ b/net/ipv6/ip6_output.c |
4319 |
+@@ -1340,7 +1340,7 @@ emsgsize: |
4320 |
+ */ |
4321 |
+ |
4322 |
+ cork->length += length; |
4323 |
+- if (((length > mtu) || |
4324 |
++ if ((((length + fragheaderlen) > mtu) || |
4325 |
+ (skb && skb_is_gso(skb))) && |
4326 |
+ (sk->sk_protocol == IPPROTO_UDP) && |
4327 |
+ (rt->dst.dev->features & NETIF_F_UFO) && |
4328 |
+diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c |
4329 |
+index 3f6ee4138cab..292ef2e584db 100644 |
4330 |
+--- a/net/ipv6/output_core.c |
4331 |
++++ b/net/ipv6/output_core.c |
4332 |
+@@ -76,7 +76,7 @@ EXPORT_SYMBOL(ipv6_select_ident); |
4333 |
+ |
4334 |
+ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
4335 |
+ { |
4336 |
+- u16 offset = sizeof(struct ipv6hdr); |
4337 |
++ unsigned int offset = sizeof(struct ipv6hdr); |
4338 |
+ unsigned int packet_len = skb_tail_pointer(skb) - |
4339 |
+ skb_network_header(skb); |
4340 |
+ int found_rhdr = 0; |
4341 |
+@@ -84,6 +84,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
4342 |
+ |
4343 |
+ while (offset <= packet_len) { |
4344 |
+ struct ipv6_opt_hdr *exthdr; |
4345 |
++ unsigned int len; |
4346 |
+ |
4347 |
+ switch (**nexthdr) { |
4348 |
+ |
4349 |
+@@ -109,7 +110,10 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
4350 |
+ |
4351 |
+ exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + |
4352 |
+ offset); |
4353 |
+- offset += ipv6_optlen(exthdr); |
4354 |
++ len = ipv6_optlen(exthdr); |
4355 |
++ if (len + offset >= IPV6_MAXPLEN) |
4356 |
++ return -EINVAL; |
4357 |
++ offset += len; |
4358 |
+ *nexthdr = &exthdr->nexthdr; |
4359 |
+ } |
4360 |
+ |
4361 |
+diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c |
4362 |
+index 01582966ffa0..2e3c12eeca07 100644 |
4363 |
+--- a/net/ipv6/udp_offload.c |
4364 |
++++ b/net/ipv6/udp_offload.c |
4365 |
+@@ -86,7 +86,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, |
4366 |
+ if (uh->check == 0) |
4367 |
+ uh->check = CSUM_MANGLED_0; |
4368 |
+ |
4369 |
+- skb->ip_summed = CHECKSUM_NONE; |
4370 |
++ skb->ip_summed = CHECKSUM_UNNECESSARY; |
4371 |
+ |
4372 |
+ /* Check if there is enough headroom to insert fragment header. */ |
4373 |
+ tnl_hlen = skb_tnl_header_len(skb); |
4374 |
+diff --git a/net/key/af_key.c b/net/key/af_key.c |
4375 |
+index 9a556e434f59..39c78c9e1c68 100644 |
4376 |
+--- a/net/key/af_key.c |
4377 |
++++ b/net/key/af_key.c |
4378 |
+@@ -63,8 +63,13 @@ struct pfkey_sock { |
4379 |
+ } u; |
4380 |
+ struct sk_buff *skb; |
4381 |
+ } dump; |
4382 |
++ struct mutex dump_lock; |
4383 |
+ }; |
4384 |
+ |
4385 |
++static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, |
4386 |
++ xfrm_address_t *saddr, xfrm_address_t *daddr, |
4387 |
++ u16 *family); |
4388 |
++ |
4389 |
+ static inline struct pfkey_sock *pfkey_sk(struct sock *sk) |
4390 |
+ { |
4391 |
+ return (struct pfkey_sock *)sk; |
4392 |
+@@ -139,6 +144,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol, |
4393 |
+ { |
4394 |
+ struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
4395 |
+ struct sock *sk; |
4396 |
++ struct pfkey_sock *pfk; |
4397 |
+ int err; |
4398 |
+ |
4399 |
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) |
4400 |
+@@ -153,6 +159,9 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol, |
4401 |
+ if (sk == NULL) |
4402 |
+ goto out; |
4403 |
+ |
4404 |
++ pfk = pfkey_sk(sk); |
4405 |
++ mutex_init(&pfk->dump_lock); |
4406 |
++ |
4407 |
+ sock->ops = &pfkey_ops; |
4408 |
+ sock_init_data(sock, sk); |
4409 |
+ |
4410 |
+@@ -281,13 +290,23 @@ static int pfkey_do_dump(struct pfkey_sock *pfk) |
4411 |
+ struct sadb_msg *hdr; |
4412 |
+ int rc; |
4413 |
+ |
4414 |
++ mutex_lock(&pfk->dump_lock); |
4415 |
++ if (!pfk->dump.dump) { |
4416 |
++ rc = 0; |
4417 |
++ goto out; |
4418 |
++ } |
4419 |
++ |
4420 |
+ rc = pfk->dump.dump(pfk); |
4421 |
+- if (rc == -ENOBUFS) |
4422 |
+- return 0; |
4423 |
++ if (rc == -ENOBUFS) { |
4424 |
++ rc = 0; |
4425 |
++ goto out; |
4426 |
++ } |
4427 |
+ |
4428 |
+ if (pfk->dump.skb) { |
4429 |
+- if (!pfkey_can_dump(&pfk->sk)) |
4430 |
+- return 0; |
4431 |
++ if (!pfkey_can_dump(&pfk->sk)) { |
4432 |
++ rc = 0; |
4433 |
++ goto out; |
4434 |
++ } |
4435 |
+ |
4436 |
+ hdr = (struct sadb_msg *) pfk->dump.skb->data; |
4437 |
+ hdr->sadb_msg_seq = 0; |
4438 |
+@@ -298,6 +317,9 @@ static int pfkey_do_dump(struct pfkey_sock *pfk) |
4439 |
+ } |
4440 |
+ |
4441 |
+ pfkey_terminate_dump(pfk); |
4442 |
++ |
4443 |
++out: |
4444 |
++ mutex_unlock(&pfk->dump_lock); |
4445 |
+ return rc; |
4446 |
+ } |
4447 |
+ |
4448 |
+@@ -1801,19 +1823,26 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms |
4449 |
+ struct xfrm_address_filter *filter = NULL; |
4450 |
+ struct pfkey_sock *pfk = pfkey_sk(sk); |
4451 |
+ |
4452 |
+- if (pfk->dump.dump != NULL) |
4453 |
++ mutex_lock(&pfk->dump_lock); |
4454 |
++ if (pfk->dump.dump != NULL) { |
4455 |
++ mutex_unlock(&pfk->dump_lock); |
4456 |
+ return -EBUSY; |
4457 |
++ } |
4458 |
+ |
4459 |
+ proto = pfkey_satype2proto(hdr->sadb_msg_satype); |
4460 |
+- if (proto == 0) |
4461 |
++ if (proto == 0) { |
4462 |
++ mutex_unlock(&pfk->dump_lock); |
4463 |
+ return -EINVAL; |
4464 |
++ } |
4465 |
+ |
4466 |
+ if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { |
4467 |
+ struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; |
4468 |
+ |
4469 |
+ filter = kmalloc(sizeof(*filter), GFP_KERNEL); |
4470 |
+- if (filter == NULL) |
4471 |
++ if (filter == NULL) { |
4472 |
++ mutex_unlock(&pfk->dump_lock); |
4473 |
+ return -ENOMEM; |
4474 |
++ } |
4475 |
+ |
4476 |
+ memcpy(&filter->saddr, &xfilter->sadb_x_filter_saddr, |
4477 |
+ sizeof(xfrm_address_t)); |
4478 |
+@@ -1829,6 +1858,7 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms |
4479 |
+ pfk->dump.dump = pfkey_dump_sa; |
4480 |
+ pfk->dump.done = pfkey_dump_sa_done; |
4481 |
+ xfrm_state_walk_init(&pfk->dump.u.state, proto, filter); |
4482 |
++ mutex_unlock(&pfk->dump_lock); |
4483 |
+ |
4484 |
+ return pfkey_do_dump(pfk); |
4485 |
+ } |
4486 |
+@@ -1921,19 +1951,14 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq) |
4487 |
+ |
4488 |
+ /* addresses present only in tunnel mode */ |
4489 |
+ if (t->mode == XFRM_MODE_TUNNEL) { |
4490 |
+- u8 *sa = (u8 *) (rq + 1); |
4491 |
+- int family, socklen; |
4492 |
++ int err; |
4493 |
+ |
4494 |
+- family = pfkey_sockaddr_extract((struct sockaddr *)sa, |
4495 |
+- &t->saddr); |
4496 |
+- if (!family) |
4497 |
+- return -EINVAL; |
4498 |
+- |
4499 |
+- socklen = pfkey_sockaddr_len(family); |
4500 |
+- if (pfkey_sockaddr_extract((struct sockaddr *)(sa + socklen), |
4501 |
+- &t->id.daddr) != family) |
4502 |
+- return -EINVAL; |
4503 |
+- t->encap_family = family; |
4504 |
++ err = parse_sockaddr_pair( |
4505 |
++ (struct sockaddr *)(rq + 1), |
4506 |
++ rq->sadb_x_ipsecrequest_len - sizeof(*rq), |
4507 |
++ &t->saddr, &t->id.daddr, &t->encap_family); |
4508 |
++ if (err) |
4509 |
++ return err; |
4510 |
+ } else |
4511 |
+ t->encap_family = xp->family; |
4512 |
+ |
4513 |
+@@ -1953,7 +1978,11 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) |
4514 |
+ if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy)) |
4515 |
+ return -EINVAL; |
4516 |
+ |
4517 |
+- while (len >= sizeof(struct sadb_x_ipsecrequest)) { |
4518 |
++ while (len >= sizeof(*rq)) { |
4519 |
++ if (len < rq->sadb_x_ipsecrequest_len || |
4520 |
++ rq->sadb_x_ipsecrequest_len < sizeof(*rq)) |
4521 |
++ return -EINVAL; |
4522 |
++ |
4523 |
+ if ((err = parse_ipsecrequest(xp, rq)) < 0) |
4524 |
+ return err; |
4525 |
+ len -= rq->sadb_x_ipsecrequest_len; |
4526 |
+@@ -2416,7 +2445,6 @@ out: |
4527 |
+ return err; |
4528 |
+ } |
4529 |
+ |
4530 |
+-#ifdef CONFIG_NET_KEY_MIGRATE |
4531 |
+ static int pfkey_sockaddr_pair_size(sa_family_t family) |
4532 |
+ { |
4533 |
+ return PFKEY_ALIGN8(pfkey_sockaddr_len(family) * 2); |
4534 |
+@@ -2428,7 +2456,7 @@ static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, |
4535 |
+ { |
4536 |
+ int af, socklen; |
4537 |
+ |
4538 |
+- if (ext_len < pfkey_sockaddr_pair_size(sa->sa_family)) |
4539 |
++ if (ext_len < 2 || ext_len < pfkey_sockaddr_pair_size(sa->sa_family)) |
4540 |
+ return -EINVAL; |
4541 |
+ |
4542 |
+ af = pfkey_sockaddr_extract(sa, saddr); |
4543 |
+@@ -2444,6 +2472,7 @@ static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, |
4544 |
+ return 0; |
4545 |
+ } |
4546 |
+ |
4547 |
++#ifdef CONFIG_NET_KEY_MIGRATE |
4548 |
+ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, |
4549 |
+ struct xfrm_migrate *m) |
4550 |
+ { |
4551 |
+@@ -2451,13 +2480,14 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, |
4552 |
+ struct sadb_x_ipsecrequest *rq2; |
4553 |
+ int mode; |
4554 |
+ |
4555 |
+- if (len <= sizeof(struct sadb_x_ipsecrequest) || |
4556 |
+- len < rq1->sadb_x_ipsecrequest_len) |
4557 |
++ if (len < sizeof(*rq1) || |
4558 |
++ len < rq1->sadb_x_ipsecrequest_len || |
4559 |
++ rq1->sadb_x_ipsecrequest_len < sizeof(*rq1)) |
4560 |
+ return -EINVAL; |
4561 |
+ |
4562 |
+ /* old endoints */ |
4563 |
+ err = parse_sockaddr_pair((struct sockaddr *)(rq1 + 1), |
4564 |
+- rq1->sadb_x_ipsecrequest_len, |
4565 |
++ rq1->sadb_x_ipsecrequest_len - sizeof(*rq1), |
4566 |
+ &m->old_saddr, &m->old_daddr, |
4567 |
+ &m->old_family); |
4568 |
+ if (err) |
4569 |
+@@ -2466,13 +2496,14 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, |
4570 |
+ rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len); |
4571 |
+ len -= rq1->sadb_x_ipsecrequest_len; |
4572 |
+ |
4573 |
+- if (len <= sizeof(struct sadb_x_ipsecrequest) || |
4574 |
+- len < rq2->sadb_x_ipsecrequest_len) |
4575 |
++ if (len <= sizeof(*rq2) || |
4576 |
++ len < rq2->sadb_x_ipsecrequest_len || |
4577 |
++ rq2->sadb_x_ipsecrequest_len < sizeof(*rq2)) |
4578 |
+ return -EINVAL; |
4579 |
+ |
4580 |
+ /* new endpoints */ |
4581 |
+ err = parse_sockaddr_pair((struct sockaddr *)(rq2 + 1), |
4582 |
+- rq2->sadb_x_ipsecrequest_len, |
4583 |
++ rq2->sadb_x_ipsecrequest_len - sizeof(*rq2), |
4584 |
+ &m->new_saddr, &m->new_daddr, |
4585 |
+ &m->new_family); |
4586 |
+ if (err) |
4587 |
+@@ -2687,14 +2718,18 @@ static int pfkey_spddump(struct sock *sk, struct sk_buff *skb, const struct sadb |
4588 |
+ { |
4589 |
+ struct pfkey_sock *pfk = pfkey_sk(sk); |
4590 |
+ |
4591 |
+- if (pfk->dump.dump != NULL) |
4592 |
++ mutex_lock(&pfk->dump_lock); |
4593 |
++ if (pfk->dump.dump != NULL) { |
4594 |
++ mutex_unlock(&pfk->dump_lock); |
4595 |
+ return -EBUSY; |
4596 |
++ } |
4597 |
+ |
4598 |
+ pfk->dump.msg_version = hdr->sadb_msg_version; |
4599 |
+ pfk->dump.msg_portid = hdr->sadb_msg_pid; |
4600 |
+ pfk->dump.dump = pfkey_dump_sp; |
4601 |
+ pfk->dump.done = pfkey_dump_sp_done; |
4602 |
+ xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN); |
4603 |
++ mutex_unlock(&pfk->dump_lock); |
4604 |
+ |
4605 |
+ return pfkey_do_dump(pfk); |
4606 |
+ } |
4607 |
+diff --git a/net/nfc/core.c b/net/nfc/core.c |
4608 |
+index cff3f1614ad4..54596f609d04 100644 |
4609 |
+--- a/net/nfc/core.c |
4610 |
++++ b/net/nfc/core.c |
4611 |
+@@ -969,6 +969,8 @@ static void nfc_release(struct device *d) |
4612 |
+ kfree(se); |
4613 |
+ } |
4614 |
+ |
4615 |
++ ida_simple_remove(&nfc_index_ida, dev->idx); |
4616 |
++ |
4617 |
+ kfree(dev); |
4618 |
+ } |
4619 |
+ |
4620 |
+@@ -1043,6 +1045,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, |
4621 |
+ int tx_headroom, int tx_tailroom) |
4622 |
+ { |
4623 |
+ struct nfc_dev *dev; |
4624 |
++ int rc; |
4625 |
+ |
4626 |
+ if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || |
4627 |
+ !ops->deactivate_target || !ops->im_transceive) |
4628 |
+@@ -1055,6 +1058,15 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, |
4629 |
+ if (!dev) |
4630 |
+ return NULL; |
4631 |
+ |
4632 |
++ rc = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL); |
4633 |
++ if (rc < 0) |
4634 |
++ goto err_free_dev; |
4635 |
++ dev->idx = rc; |
4636 |
++ |
4637 |
++ dev->dev.class = &nfc_class; |
4638 |
++ dev_set_name(&dev->dev, "nfc%d", dev->idx); |
4639 |
++ device_initialize(&dev->dev); |
4640 |
++ |
4641 |
+ dev->ops = ops; |
4642 |
+ dev->supported_protocols = supported_protocols; |
4643 |
+ dev->tx_headroom = tx_headroom; |
4644 |
+@@ -1077,6 +1089,11 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, |
4645 |
+ } |
4646 |
+ |
4647 |
+ return dev; |
4648 |
++ |
4649 |
++err_free_dev: |
4650 |
++ kfree(dev); |
4651 |
++ |
4652 |
++ return ERR_PTR(rc); |
4653 |
+ } |
4654 |
+ EXPORT_SYMBOL(nfc_allocate_device); |
4655 |
+ |
4656 |
+@@ -1091,14 +1108,6 @@ int nfc_register_device(struct nfc_dev *dev) |
4657 |
+ |
4658 |
+ pr_debug("dev_name=%s\n", dev_name(&dev->dev)); |
4659 |
+ |
4660 |
+- dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL); |
4661 |
+- if (dev->idx < 0) |
4662 |
+- return dev->idx; |
4663 |
+- |
4664 |
+- dev->dev.class = &nfc_class; |
4665 |
+- dev_set_name(&dev->dev, "nfc%d", dev->idx); |
4666 |
+- device_initialize(&dev->dev); |
4667 |
+- |
4668 |
+ mutex_lock(&nfc_devlist_mutex); |
4669 |
+ nfc_devlist_generation++; |
4670 |
+ rc = device_add(&dev->dev); |
4671 |
+@@ -1136,12 +1145,10 @@ EXPORT_SYMBOL(nfc_register_device); |
4672 |
+ */ |
4673 |
+ void nfc_unregister_device(struct nfc_dev *dev) |
4674 |
+ { |
4675 |
+- int rc, id; |
4676 |
++ int rc; |
4677 |
+ |
4678 |
+ pr_debug("dev_name=%s\n", dev_name(&dev->dev)); |
4679 |
+ |
4680 |
+- id = dev->idx; |
4681 |
+- |
4682 |
+ if (dev->rfkill) { |
4683 |
+ rfkill_unregister(dev->rfkill); |
4684 |
+ rfkill_destroy(dev->rfkill); |
4685 |
+@@ -1166,8 +1173,6 @@ void nfc_unregister_device(struct nfc_dev *dev) |
4686 |
+ nfc_devlist_generation++; |
4687 |
+ device_del(&dev->dev); |
4688 |
+ mutex_unlock(&nfc_devlist_mutex); |
4689 |
+- |
4690 |
+- ida_simple_remove(&nfc_index_ida, id); |
4691 |
+ } |
4692 |
+ EXPORT_SYMBOL(nfc_unregister_device); |
4693 |
+ |
4694 |
+diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c |
4695 |
+index 9578bd6a4f3e..5a6b76f8d157 100644 |
4696 |
+--- a/net/nfc/llcp_sock.c |
4697 |
++++ b/net/nfc/llcp_sock.c |
4698 |
+@@ -76,7 +76,8 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) |
4699 |
+ struct sockaddr_nfc_llcp llcp_addr; |
4700 |
+ int len, ret = 0; |
4701 |
+ |
4702 |
+- if (!addr || addr->sa_family != AF_NFC) |
4703 |
++ if (!addr || alen < offsetofend(struct sockaddr, sa_family) || |
4704 |
++ addr->sa_family != AF_NFC) |
4705 |
+ return -EINVAL; |
4706 |
+ |
4707 |
+ pr_debug("sk %p addr %p family %d\n", sk, addr, addr->sa_family); |
4708 |
+@@ -150,7 +151,8 @@ static int llcp_raw_sock_bind(struct socket *sock, struct sockaddr *addr, |
4709 |
+ struct sockaddr_nfc_llcp llcp_addr; |
4710 |
+ int len, ret = 0; |
4711 |
+ |
4712 |
+- if (!addr || addr->sa_family != AF_NFC) |
4713 |
++ if (!addr || alen < offsetofend(struct sockaddr, sa_family) || |
4714 |
++ addr->sa_family != AF_NFC) |
4715 |
+ return -EINVAL; |
4716 |
+ |
4717 |
+ pr_debug("sk %p addr %p family %d\n", sk, addr, addr->sa_family); |
4718 |
+@@ -655,8 +657,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, |
4719 |
+ |
4720 |
+ pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags); |
4721 |
+ |
4722 |
+- if (!addr || len < sizeof(struct sockaddr_nfc) || |
4723 |
+- addr->sa_family != AF_NFC) |
4724 |
++ if (!addr || len < sizeof(*addr) || addr->sa_family != AF_NFC) |
4725 |
+ return -EINVAL; |
4726 |
+ |
4727 |
+ if (addr->service_name_len == 0 && addr->dsap == 0) |
4728 |
+diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c |
4729 |
+index 49ff32106080..a776fb53d66d 100644 |
4730 |
+--- a/net/nfc/nci/core.c |
4731 |
++++ b/net/nfc/nci/core.c |
4732 |
+@@ -981,8 +981,7 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops, |
4733 |
+ return ndev; |
4734 |
+ |
4735 |
+ free_nfc: |
4736 |
+- kfree(ndev->nfc_dev); |
4737 |
+- |
4738 |
++ nfc_free_device(ndev->nfc_dev); |
4739 |
+ free_nci: |
4740 |
+ kfree(ndev); |
4741 |
+ return NULL; |
4742 |
+diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c |
4743 |
+index 3763036710ae..2f2a2a0e56ec 100644 |
4744 |
+--- a/net/nfc/netlink.c |
4745 |
++++ b/net/nfc/netlink.c |
4746 |
+@@ -865,7 +865,9 @@ static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info) |
4747 |
+ u32 device_idx, target_idx, protocol; |
4748 |
+ int rc; |
4749 |
+ |
4750 |
+- if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) |
4751 |
++ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || |
4752 |
++ !info->attrs[NFC_ATTR_TARGET_INDEX] || |
4753 |
++ !info->attrs[NFC_ATTR_PROTOCOLS]) |
4754 |
+ return -EINVAL; |
4755 |
+ |
4756 |
+ device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); |
4757 |
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
4758 |
+index 93c9a70d046e..c29070c27073 100644 |
4759 |
+--- a/net/packet/af_packet.c |
4760 |
++++ b/net/packet/af_packet.c |
4761 |
+@@ -3370,14 +3370,19 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv |
4762 |
+ |
4763 |
+ if (optlen != sizeof(val)) |
4764 |
+ return -EINVAL; |
4765 |
+- if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) |
4766 |
+- return -EBUSY; |
4767 |
+ if (copy_from_user(&val, optval, sizeof(val))) |
4768 |
+ return -EFAULT; |
4769 |
+ if (val > INT_MAX) |
4770 |
+ return -EINVAL; |
4771 |
+- po->tp_reserve = val; |
4772 |
+- return 0; |
4773 |
++ lock_sock(sk); |
4774 |
++ if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { |
4775 |
++ ret = -EBUSY; |
4776 |
++ } else { |
4777 |
++ po->tp_reserve = val; |
4778 |
++ ret = 0; |
4779 |
++ } |
4780 |
++ release_sock(sk); |
4781 |
++ return ret; |
4782 |
+ } |
4783 |
+ case PACKET_LOSS: |
4784 |
+ { |
4785 |
+@@ -3954,7 +3959,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, |
4786 |
+ register_prot_hook(sk); |
4787 |
+ } |
4788 |
+ spin_unlock(&po->bind_lock); |
4789 |
+- if (closing && (po->tp_version > TPACKET_V2)) { |
4790 |
++ if (pg_vec && (po->tp_version > TPACKET_V2)) { |
4791 |
+ /* Because we don't support block-based V3 on tx-ring */ |
4792 |
+ if (!tx_ring) |
4793 |
+ prb_shutdown_retire_blk_timer(po, tx_ring, rb_queue); |
4794 |
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
4795 |
+index 9b5dd2ac60b6..a0e45ae0a628 100644 |
4796 |
+--- a/sound/pci/hda/patch_realtek.c |
4797 |
++++ b/sound/pci/hda/patch_realtek.c |
4798 |
+@@ -2228,6 +2228,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
4799 |
+ SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3), |
4800 |
+ SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
4801 |
+ SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), |
4802 |
++ SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP), |
4803 |
+ SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), |
4804 |
+ SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP), |
4805 |
+ |
4806 |
+diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c |
4807 |
+index 51c4713ac6e3..468fdf21be4f 100644 |
4808 |
+--- a/sound/soc/codecs/tlv320aic3x.c |
4809 |
++++ b/sound/soc/codecs/tlv320aic3x.c |
4810 |
+@@ -125,6 +125,16 @@ static const struct reg_default aic3x_reg[] = { |
4811 |
+ { 108, 0x00 }, { 109, 0x00 }, |
4812 |
+ }; |
4813 |
+ |
4814 |
++static bool aic3x_volatile_reg(struct device *dev, unsigned int reg) |
4815 |
++{ |
4816 |
++ switch (reg) { |
4817 |
++ case AIC3X_RESET: |
4818 |
++ return true; |
4819 |
++ default: |
4820 |
++ return false; |
4821 |
++ } |
4822 |
++} |
4823 |
++ |
4824 |
+ static const struct regmap_config aic3x_regmap = { |
4825 |
+ .reg_bits = 8, |
4826 |
+ .val_bits = 8, |
4827 |
+@@ -132,6 +142,9 @@ static const struct regmap_config aic3x_regmap = { |
4828 |
+ .max_register = DAC_ICC_ADJ, |
4829 |
+ .reg_defaults = aic3x_reg, |
4830 |
+ .num_reg_defaults = ARRAY_SIZE(aic3x_reg), |
4831 |
++ |
4832 |
++ .volatile_reg = aic3x_volatile_reg, |
4833 |
++ |
4834 |
+ .cache_type = REGCACHE_RBTREE, |
4835 |
+ }; |
4836 |
+ |
4837 |
+diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c |
4838 |
+index 1874cf0e6cab..35805d7e2bc2 100644 |
4839 |
+--- a/sound/soc/soc-compress.c |
4840 |
++++ b/sound/soc/soc-compress.c |
4841 |
+@@ -68,7 +68,8 @@ out: |
4842 |
+ static int soc_compr_open_fe(struct snd_compr_stream *cstream) |
4843 |
+ { |
4844 |
+ struct snd_soc_pcm_runtime *fe = cstream->private_data; |
4845 |
+- struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; |
4846 |
++ struct snd_pcm_substream *fe_substream = |
4847 |
++ fe->pcm->streams[cstream->direction].substream; |
4848 |
+ struct snd_soc_platform *platform = fe->platform; |
4849 |
+ struct snd_soc_dpcm *dpcm; |
4850 |
+ struct snd_soc_dapm_widget_list *list; |
4851 |
+@@ -412,7 +413,8 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, |
4852 |
+ struct snd_compr_params *params) |
4853 |
+ { |
4854 |
+ struct snd_soc_pcm_runtime *fe = cstream->private_data; |
4855 |
+- struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; |
4856 |
++ struct snd_pcm_substream *fe_substream = |
4857 |
++ fe->pcm->streams[cstream->direction].substream; |
4858 |
+ struct snd_soc_platform *platform = fe->platform; |
4859 |
+ int ret = 0, stream; |
4860 |
+ |
4861 |
+diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c |
4862 |
+index 52fe7eb2dea1..c99e18cb2ba7 100644 |
4863 |
+--- a/sound/soc/soc-pcm.c |
4864 |
++++ b/sound/soc/soc-pcm.c |
4865 |
+@@ -163,6 +163,10 @@ int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, |
4866 |
+ dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n", |
4867 |
+ be->dai_link->name, event, dir); |
4868 |
+ |
4869 |
++ if ((event == SND_SOC_DAPM_STREAM_STOP) && |
4870 |
++ (be->dpcm[dir].users >= 1)) |
4871 |
++ continue; |
4872 |
++ |
4873 |
+ snd_soc_dapm_stream_event(be, dir, event); |
4874 |
+ } |
4875 |
+ |
4876 |
+@@ -1991,9 +1995,11 @@ static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd) |
4877 |
+ break; |
4878 |
+ case SNDRV_PCM_TRIGGER_STOP: |
4879 |
+ case SNDRV_PCM_TRIGGER_SUSPEND: |
4880 |
+- case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
4881 |
+ fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; |
4882 |
+ break; |
4883 |
++ case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
4884 |
++ fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; |
4885 |
++ break; |
4886 |
+ } |
4887 |
+ |
4888 |
+ out: |
4889 |
+diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c |
4890 |
+index c2131b851602..5fed093fd447 100644 |
4891 |
+--- a/sound/usb/endpoint.c |
4892 |
++++ b/sound/usb/endpoint.c |
4893 |
+@@ -361,6 +361,9 @@ static void snd_complete_urb(struct urb *urb) |
4894 |
+ if (unlikely(atomic_read(&ep->chip->shutdown))) |
4895 |
+ goto exit_clear; |
4896 |
+ |
4897 |
++ if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) |
4898 |
++ goto exit_clear; |
4899 |
++ |
4900 |
+ if (usb_pipeout(ep->pipe)) { |
4901 |
+ retire_outbound_urb(ep, ctx); |
4902 |
+ /* can be stopped during retire callback */ |
4903 |
+diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c |
4904 |
+index f1ce60065258..ec30c2fcbac0 100644 |
4905 |
+--- a/tools/lib/traceevent/plugin_sched_switch.c |
4906 |
++++ b/tools/lib/traceevent/plugin_sched_switch.c |
4907 |
+@@ -111,7 +111,7 @@ static int sched_switch_handler(struct trace_seq *s, |
4908 |
+ trace_seq_printf(s, "%lld ", val); |
4909 |
+ |
4910 |
+ if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0) |
4911 |
+- trace_seq_printf(s, "[%lld] ", val); |
4912 |
++ trace_seq_printf(s, "[%d] ", (int) val); |
4913 |
+ |
4914 |
+ if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0) |
4915 |
+ write_state(s, val); |
4916 |
+@@ -129,7 +129,7 @@ static int sched_switch_handler(struct trace_seq *s, |
4917 |
+ trace_seq_printf(s, "%lld", val); |
4918 |
+ |
4919 |
+ if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0) |
4920 |
+- trace_seq_printf(s, " [%lld]", val); |
4921 |
++ trace_seq_printf(s, " [%d]", (int) val); |
4922 |
+ |
4923 |
+ return 0; |
4924 |
+ } |
4925 |
+diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c |
4926 |
+index 6680fa5cb9dd..d9f04239a12a 100644 |
4927 |
+--- a/tools/perf/ui/browser.c |
4928 |
++++ b/tools/perf/ui/browser.c |
4929 |
+@@ -673,7 +673,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, |
4930 |
+ ui_browser__gotorc(browser, row, column + 1); |
4931 |
+ SLsmg_draw_hline(2); |
4932 |
+ |
4933 |
+- if (row++ == 0) |
4934 |
++ if (++row == 0) |
4935 |
+ goto out; |
4936 |
+ } else |
4937 |
+ row = 0; |
4938 |
+diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c |
4939 |
+index 3ddfab315e19..ec35cb33e46b 100644 |
4940 |
+--- a/tools/perf/util/symbol-elf.c |
4941 |
++++ b/tools/perf/util/symbol-elf.c |
4942 |
+@@ -488,6 +488,12 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size) |
4943 |
+ break; |
4944 |
+ } else { |
4945 |
+ int n = namesz + descsz; |
4946 |
++ |
4947 |
++ if (n > (int)sizeof(bf)) { |
4948 |
++ n = sizeof(bf); |
4949 |
++ pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n", |
4950 |
++ __func__, filename, nhdr.n_namesz, nhdr.n_descsz); |
4951 |
++ } |
4952 |
+ if (read(fd, bf, n) != n) |
4953 |
+ break; |
4954 |
+ } |
4955 |
+diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c |
4956 |
+index 620e37f741b8..6ddd3c742555 100644 |
4957 |
+--- a/virt/kvm/vfio.c |
4958 |
++++ b/virt/kvm/vfio.c |
4959 |
+@@ -47,6 +47,22 @@ static struct vfio_group *kvm_vfio_group_get_external_user(struct file *filep) |
4960 |
+ return vfio_group; |
4961 |
+ } |
4962 |
+ |
4963 |
++static bool kvm_vfio_external_group_match_file(struct vfio_group *group, |
4964 |
++ struct file *filep) |
4965 |
++{ |
4966 |
++ bool ret, (*fn)(struct vfio_group *, struct file *); |
4967 |
++ |
4968 |
++ fn = symbol_get(vfio_external_group_match_file); |
4969 |
++ if (!fn) |
4970 |
++ return false; |
4971 |
++ |
4972 |
++ ret = fn(group, filep); |
4973 |
++ |
4974 |
++ symbol_put(vfio_external_group_match_file); |
4975 |
++ |
4976 |
++ return ret; |
4977 |
++} |
4978 |
++ |
4979 |
+ static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group) |
4980 |
+ { |
4981 |
+ void (*fn)(struct vfio_group *); |
4982 |
+@@ -169,18 +185,13 @@ static int kvm_vfio_set_group(struct kvm_device *dev, long attr, u64 arg) |
4983 |
+ if (!f.file) |
4984 |
+ return -EBADF; |
4985 |
+ |
4986 |
+- vfio_group = kvm_vfio_group_get_external_user(f.file); |
4987 |
+- fdput(f); |
4988 |
+- |
4989 |
+- if (IS_ERR(vfio_group)) |
4990 |
+- return PTR_ERR(vfio_group); |
4991 |
+- |
4992 |
+ ret = -ENOENT; |
4993 |
+ |
4994 |
+ mutex_lock(&kv->lock); |
4995 |
+ |
4996 |
+ list_for_each_entry(kvg, &kv->group_list, node) { |
4997 |
+- if (kvg->vfio_group != vfio_group) |
4998 |
++ if (!kvm_vfio_external_group_match_file(kvg->vfio_group, |
4999 |
++ f.file)) |
5000 |
+ continue; |
5001 |
+ |
5002 |
+ list_del(&kvg->node); |
5003 |
+@@ -192,7 +203,7 @@ static int kvm_vfio_set_group(struct kvm_device *dev, long attr, u64 arg) |
5004 |
+ |
5005 |
+ mutex_unlock(&kv->lock); |
5006 |
+ |
5007 |
+- kvm_vfio_group_put_external_user(vfio_group); |
5008 |
++ fdput(f); |
5009 |
+ |
5010 |
+ kvm_vfio_update_coherency(dev); |
5011 |
+ |
5012 |
|
5013 |
diff --git a/1044_linux-4.1.45.patch b/1044_linux-4.1.45.patch |
5014 |
new file mode 100644 |
5015 |
index 0000000..eb4d11d |
5016 |
--- /dev/null |
5017 |
+++ b/1044_linux-4.1.45.patch |
5018 |
@@ -0,0 +1,4031 @@ |
5019 |
+diff --git a/Makefile b/Makefile |
5020 |
+index 9c7aa08c70b7..d4c064604058 100644 |
5021 |
+--- a/Makefile |
5022 |
++++ b/Makefile |
5023 |
+@@ -1,6 +1,6 @@ |
5024 |
+ VERSION = 4 |
5025 |
+ PATCHLEVEL = 1 |
5026 |
+-SUBLEVEL = 44 |
5027 |
++SUBLEVEL = 45 |
5028 |
+ EXTRAVERSION = |
5029 |
+ NAME = Series 4800 |
5030 |
+ |
5031 |
+diff --git a/arch/alpha/include/asm/types.h b/arch/alpha/include/asm/types.h |
5032 |
+index 4cb4b6d3452c..0bc66e1d3a7e 100644 |
5033 |
+--- a/arch/alpha/include/asm/types.h |
5034 |
++++ b/arch/alpha/include/asm/types.h |
5035 |
+@@ -1,6 +1,6 @@ |
5036 |
+ #ifndef _ALPHA_TYPES_H |
5037 |
+ #define _ALPHA_TYPES_H |
5038 |
+ |
5039 |
+-#include <asm-generic/int-ll64.h> |
5040 |
++#include <uapi/asm/types.h> |
5041 |
+ |
5042 |
+ #endif /* _ALPHA_TYPES_H */ |
5043 |
+diff --git a/arch/alpha/include/uapi/asm/types.h b/arch/alpha/include/uapi/asm/types.h |
5044 |
+index 9fd3cd459777..8d1024d7be05 100644 |
5045 |
+--- a/arch/alpha/include/uapi/asm/types.h |
5046 |
++++ b/arch/alpha/include/uapi/asm/types.h |
5047 |
+@@ -9,8 +9,18 @@ |
5048 |
+ * need to be careful to avoid a name clashes. |
5049 |
+ */ |
5050 |
+ |
5051 |
+-#ifndef __KERNEL__ |
5052 |
++/* |
5053 |
++ * This is here because we used to use l64 for alpha |
5054 |
++ * and we don't want to impact user mode with our change to ll64 |
5055 |
++ * in the kernel. |
5056 |
++ * |
5057 |
++ * However, some user programs are fine with this. They can |
5058 |
++ * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here. |
5059 |
++ */ |
5060 |
++#if !defined(__SANE_USERSPACE_TYPES__) && !defined(__KERNEL__) |
5061 |
+ #include <asm-generic/int-l64.h> |
5062 |
++#else |
5063 |
++#include <asm-generic/int-ll64.h> |
5064 |
+ #endif |
5065 |
+ |
5066 |
+ #endif /* _UAPI_ALPHA_TYPES_H */ |
5067 |
+diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S |
5068 |
+index d868289c5a26..da600d814035 100644 |
5069 |
+--- a/arch/arc/kernel/entry.S |
5070 |
++++ b/arch/arc/kernel/entry.S |
5071 |
+@@ -315,6 +315,12 @@ ENTRY(EV_MachineCheck) |
5072 |
+ lr r0, [efa] |
5073 |
+ mov r1, sp |
5074 |
+ |
5075 |
++ ; hardware auto-disables MMU, re-enable it to allow kernel vaddr |
5076 |
++ ; access for say stack unwinding of modules for crash dumps |
5077 |
++ lr r3, [ARC_REG_PID] |
5078 |
++ or r3, r3, MMU_ENABLE |
5079 |
++ sr r3, [ARC_REG_PID] |
5080 |
++ |
5081 |
+ lsr r3, r2, 8 |
5082 |
+ bmsk r3, r3, 7 |
5083 |
+ brne r3, ECR_C_MCHK_DUP_TLB, 1f |
5084 |
+diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c |
5085 |
+index 7f47d2a56f44..b7a0c44785c1 100644 |
5086 |
+--- a/arch/arc/mm/tlb.c |
5087 |
++++ b/arch/arc/mm/tlb.c |
5088 |
+@@ -689,9 +689,6 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address, |
5089 |
+ |
5090 |
+ local_irq_save(flags); |
5091 |
+ |
5092 |
+- /* re-enable the MMU */ |
5093 |
+- write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID)); |
5094 |
+- |
5095 |
+ /* loop thru all sets of TLB */ |
5096 |
+ for (set = 0; set < mmu->sets; set++) { |
5097 |
+ |
5098 |
+diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c |
5099 |
+index 6333d9c17875..9c521f9959a9 100644 |
5100 |
+--- a/arch/arm/mm/fault.c |
5101 |
++++ b/arch/arm/mm/fault.c |
5102 |
+@@ -314,8 +314,11 @@ retry: |
5103 |
+ * signal first. We do not need to release the mmap_sem because |
5104 |
+ * it would already be released in __lock_page_or_retry in |
5105 |
+ * mm/filemap.c. */ |
5106 |
+- if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) |
5107 |
++ if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) { |
5108 |
++ if (!user_mode(regs)) |
5109 |
++ goto no_context; |
5110 |
+ return 0; |
5111 |
++ } |
5112 |
+ |
5113 |
+ /* |
5114 |
+ * Major/minor page fault accounting is only done on the |
5115 |
+diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c |
5116 |
+index c31e59fe2cb8..7b4e9ea0b1a4 100644 |
5117 |
+--- a/arch/arm64/kernel/fpsimd.c |
5118 |
++++ b/arch/arm64/kernel/fpsimd.c |
5119 |
+@@ -156,9 +156,11 @@ void fpsimd_thread_switch(struct task_struct *next) |
5120 |
+ |
5121 |
+ void fpsimd_flush_thread(void) |
5122 |
+ { |
5123 |
++ preempt_disable(); |
5124 |
+ memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); |
5125 |
+ fpsimd_flush_task_state(current); |
5126 |
+ set_thread_flag(TIF_FOREIGN_FPSTATE); |
5127 |
++ preempt_enable(); |
5128 |
+ } |
5129 |
+ |
5130 |
+ /* |
5131 |
+diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c |
5132 |
+index 16523fbd9671..d0e42f6fcddd 100644 |
5133 |
+--- a/arch/arm64/mm/fault.c |
5134 |
++++ b/arch/arm64/mm/fault.c |
5135 |
+@@ -253,8 +253,11 @@ retry: |
5136 |
+ * signal first. We do not need to release the mmap_sem because it |
5137 |
+ * would already be released in __lock_page_or_retry in mm/filemap.c. |
5138 |
+ */ |
5139 |
+- if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) |
5140 |
++ if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) { |
5141 |
++ if (!user_mode(regs)) |
5142 |
++ goto no_context; |
5143 |
+ return 0; |
5144 |
++ } |
5145 |
+ |
5146 |
+ /* |
5147 |
+ * Major/minor page fault accounting is only done on the initial |
5148 |
+diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c |
5149 |
+index 91e5c1758b5c..64e016abb2a5 100644 |
5150 |
+--- a/arch/powerpc/kernel/align.c |
5151 |
++++ b/arch/powerpc/kernel/align.c |
5152 |
+@@ -236,6 +236,28 @@ static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr) |
5153 |
+ |
5154 |
+ #define SWIZ_PTR(p) ((unsigned char __user *)((p) ^ swiz)) |
5155 |
+ |
5156 |
++#define __get_user_or_set_dar(_regs, _dest, _addr) \ |
5157 |
++ ({ \ |
5158 |
++ int rc = 0; \ |
5159 |
++ typeof(_addr) __addr = (_addr); \ |
5160 |
++ if (__get_user_inatomic(_dest, __addr)) { \ |
5161 |
++ _regs->dar = (unsigned long)__addr; \ |
5162 |
++ rc = -EFAULT; \ |
5163 |
++ } \ |
5164 |
++ rc; \ |
5165 |
++ }) |
5166 |
++ |
5167 |
++#define __put_user_or_set_dar(_regs, _src, _addr) \ |
5168 |
++ ({ \ |
5169 |
++ int rc = 0; \ |
5170 |
++ typeof(_addr) __addr = (_addr); \ |
5171 |
++ if (__put_user_inatomic(_src, __addr)) { \ |
5172 |
++ _regs->dar = (unsigned long)__addr; \ |
5173 |
++ rc = -EFAULT; \ |
5174 |
++ } \ |
5175 |
++ rc; \ |
5176 |
++ }) |
5177 |
++ |
5178 |
+ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
5179 |
+ unsigned int reg, unsigned int nb, |
5180 |
+ unsigned int flags, unsigned int instr, |
5181 |
+@@ -264,9 +286,10 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
5182 |
+ } else { |
5183 |
+ unsigned long pc = regs->nip ^ (swiz & 4); |
5184 |
+ |
5185 |
+- if (__get_user_inatomic(instr, |
5186 |
+- (unsigned int __user *)pc)) |
5187 |
++ if (__get_user_or_set_dar(regs, instr, |
5188 |
++ (unsigned int __user *)pc)) |
5189 |
+ return -EFAULT; |
5190 |
++ |
5191 |
+ if (swiz == 0 && (flags & SW)) |
5192 |
+ instr = cpu_to_le32(instr); |
5193 |
+ nb = (instr >> 11) & 0x1f; |
5194 |
+@@ -310,31 +333,31 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
5195 |
+ ((nb0 + 3) / 4) * sizeof(unsigned long)); |
5196 |
+ |
5197 |
+ for (i = 0; i < nb; ++i, ++p) |
5198 |
+- if (__get_user_inatomic(REG_BYTE(rptr, i ^ bswiz), |
5199 |
+- SWIZ_PTR(p))) |
5200 |
++ if (__get_user_or_set_dar(regs, REG_BYTE(rptr, i ^ bswiz), |
5201 |
++ SWIZ_PTR(p))) |
5202 |
+ return -EFAULT; |
5203 |
+ if (nb0 > 0) { |
5204 |
+ rptr = ®s->gpr[0]; |
5205 |
+ addr += nb; |
5206 |
+ for (i = 0; i < nb0; ++i, ++p) |
5207 |
+- if (__get_user_inatomic(REG_BYTE(rptr, |
5208 |
+- i ^ bswiz), |
5209 |
+- SWIZ_PTR(p))) |
5210 |
++ if (__get_user_or_set_dar(regs, |
5211 |
++ REG_BYTE(rptr, i ^ bswiz), |
5212 |
++ SWIZ_PTR(p))) |
5213 |
+ return -EFAULT; |
5214 |
+ } |
5215 |
+ |
5216 |
+ } else { |
5217 |
+ for (i = 0; i < nb; ++i, ++p) |
5218 |
+- if (__put_user_inatomic(REG_BYTE(rptr, i ^ bswiz), |
5219 |
+- SWIZ_PTR(p))) |
5220 |
++ if (__put_user_or_set_dar(regs, REG_BYTE(rptr, i ^ bswiz), |
5221 |
++ SWIZ_PTR(p))) |
5222 |
+ return -EFAULT; |
5223 |
+ if (nb0 > 0) { |
5224 |
+ rptr = ®s->gpr[0]; |
5225 |
+ addr += nb; |
5226 |
+ for (i = 0; i < nb0; ++i, ++p) |
5227 |
+- if (__put_user_inatomic(REG_BYTE(rptr, |
5228 |
+- i ^ bswiz), |
5229 |
+- SWIZ_PTR(p))) |
5230 |
++ if (__put_user_or_set_dar(regs, |
5231 |
++ REG_BYTE(rptr, i ^ bswiz), |
5232 |
++ SWIZ_PTR(p))) |
5233 |
+ return -EFAULT; |
5234 |
+ } |
5235 |
+ } |
5236 |
+@@ -346,29 +369,32 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
5237 |
+ * Only POWER6 has these instructions, and it does true little-endian, |
5238 |
+ * so we don't need the address swizzling. |
5239 |
+ */ |
5240 |
+-static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, |
5241 |
+- unsigned int flags) |
5242 |
++static int emulate_fp_pair(struct pt_regs *regs, unsigned char __user *addr, |
5243 |
++ unsigned int reg, unsigned int flags) |
5244 |
+ { |
5245 |
+ char *ptr0 = (char *) ¤t->thread.TS_FPR(reg); |
5246 |
+ char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1); |
5247 |
+- int i, ret, sw = 0; |
5248 |
++ int i, sw = 0; |
5249 |
+ |
5250 |
+ if (reg & 1) |
5251 |
+ return 0; /* invalid form: FRS/FRT must be even */ |
5252 |
+ if (flags & SW) |
5253 |
+ sw = 7; |
5254 |
+- ret = 0; |
5255 |
++ |
5256 |
+ for (i = 0; i < 8; ++i) { |
5257 |
+ if (!(flags & ST)) { |
5258 |
+- ret |= __get_user(ptr0[i^sw], addr + i); |
5259 |
+- ret |= __get_user(ptr1[i^sw], addr + i + 8); |
5260 |
++ if (__get_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
5261 |
++ return -EFAULT; |
5262 |
++ if (__get_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
5263 |
++ return -EFAULT; |
5264 |
+ } else { |
5265 |
+- ret |= __put_user(ptr0[i^sw], addr + i); |
5266 |
+- ret |= __put_user(ptr1[i^sw], addr + i + 8); |
5267 |
++ if (__put_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
5268 |
++ return -EFAULT; |
5269 |
++ if (__put_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
5270 |
++ return -EFAULT; |
5271 |
+ } |
5272 |
+ } |
5273 |
+- if (ret) |
5274 |
+- return -EFAULT; |
5275 |
++ |
5276 |
+ return 1; /* exception handled and fixed up */ |
5277 |
+ } |
5278 |
+ |
5279 |
+@@ -378,24 +404,27 @@ static int emulate_lq_stq(struct pt_regs *regs, unsigned char __user *addr, |
5280 |
+ { |
5281 |
+ char *ptr0 = (char *)®s->gpr[reg]; |
5282 |
+ char *ptr1 = (char *)®s->gpr[reg+1]; |
5283 |
+- int i, ret, sw = 0; |
5284 |
++ int i, sw = 0; |
5285 |
+ |
5286 |
+ if (reg & 1) |
5287 |
+ return 0; /* invalid form: GPR must be even */ |
5288 |
+ if (flags & SW) |
5289 |
+ sw = 7; |
5290 |
+- ret = 0; |
5291 |
++ |
5292 |
+ for (i = 0; i < 8; ++i) { |
5293 |
+ if (!(flags & ST)) { |
5294 |
+- ret |= __get_user(ptr0[i^sw], addr + i); |
5295 |
+- ret |= __get_user(ptr1[i^sw], addr + i + 8); |
5296 |
++ if (__get_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
5297 |
++ return -EFAULT; |
5298 |
++ if (__get_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
5299 |
++ return -EFAULT; |
5300 |
+ } else { |
5301 |
+- ret |= __put_user(ptr0[i^sw], addr + i); |
5302 |
+- ret |= __put_user(ptr1[i^sw], addr + i + 8); |
5303 |
++ if (__put_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
5304 |
++ return -EFAULT; |
5305 |
++ if (__put_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
5306 |
++ return -EFAULT; |
5307 |
+ } |
5308 |
+ } |
5309 |
+- if (ret) |
5310 |
+- return -EFAULT; |
5311 |
++ |
5312 |
+ return 1; /* exception handled and fixed up */ |
5313 |
+ } |
5314 |
+ #endif /* CONFIG_PPC64 */ |
5315 |
+@@ -688,9 +717,14 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg, |
5316 |
+ for (j = 0; j < length; j += elsize) { |
5317 |
+ for (i = 0; i < elsize; ++i) { |
5318 |
+ if (flags & ST) |
5319 |
+- ret |= __put_user(ptr[i^sw], addr + i); |
5320 |
++ ret = __put_user_or_set_dar(regs, ptr[i^sw], |
5321 |
++ addr + i); |
5322 |
+ else |
5323 |
+- ret |= __get_user(ptr[i^sw], addr + i); |
5324 |
++ ret = __get_user_or_set_dar(regs, ptr[i^sw], |
5325 |
++ addr + i); |
5326 |
++ |
5327 |
++ if (ret) |
5328 |
++ return ret; |
5329 |
+ } |
5330 |
+ ptr += elsize; |
5331 |
+ #ifdef __LITTLE_ENDIAN__ |
5332 |
+@@ -740,7 +774,7 @@ int fix_alignment(struct pt_regs *regs) |
5333 |
+ unsigned int dsisr; |
5334 |
+ unsigned char __user *addr; |
5335 |
+ unsigned long p, swiz; |
5336 |
+- int ret, i; |
5337 |
++ int i; |
5338 |
+ union data { |
5339 |
+ u64 ll; |
5340 |
+ double dd; |
5341 |
+@@ -923,7 +957,7 @@ int fix_alignment(struct pt_regs *regs) |
5342 |
+ if (flags & F) { |
5343 |
+ /* Special case for 16-byte FP loads and stores */ |
5344 |
+ PPC_WARN_ALIGNMENT(fp_pair, regs); |
5345 |
+- return emulate_fp_pair(addr, reg, flags); |
5346 |
++ return emulate_fp_pair(regs, addr, reg, flags); |
5347 |
+ } else { |
5348 |
+ #ifdef CONFIG_PPC64 |
5349 |
+ /* Special case for 16-byte loads and stores */ |
5350 |
+@@ -953,15 +987,12 @@ int fix_alignment(struct pt_regs *regs) |
5351 |
+ } |
5352 |
+ |
5353 |
+ data.ll = 0; |
5354 |
+- ret = 0; |
5355 |
+ p = (unsigned long)addr; |
5356 |
+ |
5357 |
+ for (i = 0; i < nb; i++) |
5358 |
+- ret |= __get_user_inatomic(data.v[start + i], |
5359 |
+- SWIZ_PTR(p++)); |
5360 |
+- |
5361 |
+- if (unlikely(ret)) |
5362 |
+- return -EFAULT; |
5363 |
++ if (__get_user_or_set_dar(regs, data.v[start + i], |
5364 |
++ SWIZ_PTR(p++))) |
5365 |
++ return -EFAULT; |
5366 |
+ |
5367 |
+ } else if (flags & F) { |
5368 |
+ data.ll = current->thread.TS_FPR(reg); |
5369 |
+@@ -1031,15 +1062,13 @@ int fix_alignment(struct pt_regs *regs) |
5370 |
+ break; |
5371 |
+ } |
5372 |
+ |
5373 |
+- ret = 0; |
5374 |
+ p = (unsigned long)addr; |
5375 |
+ |
5376 |
+ for (i = 0; i < nb; i++) |
5377 |
+- ret |= __put_user_inatomic(data.v[start + i], |
5378 |
+- SWIZ_PTR(p++)); |
5379 |
++ if (__put_user_or_set_dar(regs, data.v[start + i], |
5380 |
++ SWIZ_PTR(p++))) |
5381 |
++ return -EFAULT; |
5382 |
+ |
5383 |
+- if (unlikely(ret)) |
5384 |
+- return -EFAULT; |
5385 |
+ } else if (flags & F) |
5386 |
+ current->thread.TS_FPR(reg) = data.ll; |
5387 |
+ else |
5388 |
+diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h |
5389 |
+index 2903ff34174c..a8bd57d5ef43 100644 |
5390 |
+--- a/arch/x86/include/asm/elf.h |
5391 |
++++ b/arch/x86/include/asm/elf.h |
5392 |
+@@ -204,6 +204,7 @@ void set_personality_ia32(bool); |
5393 |
+ |
5394 |
+ #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
5395 |
+ do { \ |
5396 |
++ unsigned long base; \ |
5397 |
+ unsigned v; \ |
5398 |
+ (pr_reg)[0] = (regs)->r15; \ |
5399 |
+ (pr_reg)[1] = (regs)->r14; \ |
5400 |
+@@ -226,8 +227,8 @@ do { \ |
5401 |
+ (pr_reg)[18] = (regs)->flags; \ |
5402 |
+ (pr_reg)[19] = (regs)->sp; \ |
5403 |
+ (pr_reg)[20] = (regs)->ss; \ |
5404 |
+- (pr_reg)[21] = current->thread.fs; \ |
5405 |
+- (pr_reg)[22] = current->thread.gs; \ |
5406 |
++ rdmsrl(MSR_FS_BASE, base); (pr_reg)[21] = base; \ |
5407 |
++ rdmsrl(MSR_KERNEL_GS_BASE, base); (pr_reg)[22] = base; \ |
5408 |
+ asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \ |
5409 |
+ asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ |
5410 |
+ asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ |
5411 |
+diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h |
5412 |
+index 34a5b93704d3..b36deb1d9561 100644 |
5413 |
+--- a/arch/x86/include/asm/io.h |
5414 |
++++ b/arch/x86/include/asm/io.h |
5415 |
+@@ -301,13 +301,13 @@ static inline unsigned type in##bwl##_p(int port) \ |
5416 |
+ static inline void outs##bwl(int port, const void *addr, unsigned long count) \ |
5417 |
+ { \ |
5418 |
+ asm volatile("rep; outs" #bwl \ |
5419 |
+- : "+S"(addr), "+c"(count) : "d"(port)); \ |
5420 |
++ : "+S"(addr), "+c"(count) : "d"(port) : "memory"); \ |
5421 |
+ } \ |
5422 |
+ \ |
5423 |
+ static inline void ins##bwl(int port, void *addr, unsigned long count) \ |
5424 |
+ { \ |
5425 |
+ asm volatile("rep; ins" #bwl \ |
5426 |
+- : "+D"(addr), "+c"(count) : "d"(port)); \ |
5427 |
++ : "+D"(addr), "+c"(count) : "d"(port) : "memory"); \ |
5428 |
+ } |
5429 |
+ |
5430 |
+ BUILDIO(b, b, char) |
5431 |
+diff --git a/block/blk-core.c b/block/blk-core.c |
5432 |
+index bbbf36e6066b..a891e1f19f7b 100644 |
5433 |
+--- a/block/blk-core.c |
5434 |
++++ b/block/blk-core.c |
5435 |
+@@ -194,7 +194,7 @@ EXPORT_SYMBOL(blk_delay_queue); |
5436 |
+ **/ |
5437 |
+ void blk_start_queue(struct request_queue *q) |
5438 |
+ { |
5439 |
+- WARN_ON(!irqs_disabled()); |
5440 |
++ WARN_ON(!in_interrupt() && !irqs_disabled()); |
5441 |
+ |
5442 |
+ queue_flag_clear(QUEUE_FLAG_STOPPED, q); |
5443 |
+ __blk_run_queue(q); |
5444 |
+diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c |
5445 |
+index c0f03562a145..3734c5591d07 100644 |
5446 |
+--- a/crypto/algif_skcipher.c |
5447 |
++++ b/crypto/algif_skcipher.c |
5448 |
+@@ -94,8 +94,13 @@ static void skcipher_free_async_sgls(struct skcipher_async_req *sreq) |
5449 |
+ } |
5450 |
+ sgl = sreq->tsg; |
5451 |
+ n = sg_nents(sgl); |
5452 |
+- for_each_sg(sgl, sg, n, i) |
5453 |
+- put_page(sg_page(sg)); |
5454 |
++ for_each_sg(sgl, sg, n, i) { |
5455 |
++ struct page *page = sg_page(sg); |
5456 |
++ |
5457 |
++ /* some SGs may not have a page mapped */ |
5458 |
++ if (page && atomic_read(&page->_count)) |
5459 |
++ put_page(page); |
5460 |
++ } |
5461 |
+ |
5462 |
+ kfree(sreq->tsg); |
5463 |
+ } |
5464 |
+diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c |
5465 |
+index e82d0976a5d0..568120eee7d9 100644 |
5466 |
+--- a/drivers/acpi/apei/ghes.c |
5467 |
++++ b/drivers/acpi/apei/ghes.c |
5468 |
+@@ -1064,6 +1064,7 @@ static int ghes_remove(struct platform_device *ghes_dev) |
5469 |
+ if (list_empty(&ghes_sci)) |
5470 |
+ unregister_acpi_hed_notifier(&ghes_notifier_sci); |
5471 |
+ mutex_unlock(&ghes_list_mutex); |
5472 |
++ synchronize_rcu(); |
5473 |
+ break; |
5474 |
+ case ACPI_HEST_NOTIFY_NMI: |
5475 |
+ ghes_nmi_remove(ghes); |
5476 |
+diff --git a/drivers/acpi/ioapic.c b/drivers/acpi/ioapic.c |
5477 |
+index ccdc8db16bb8..fa2cf2dc4e33 100644 |
5478 |
+--- a/drivers/acpi/ioapic.c |
5479 |
++++ b/drivers/acpi/ioapic.c |
5480 |
+@@ -45,6 +45,12 @@ static acpi_status setup_res(struct acpi_resource *acpi_res, void *data) |
5481 |
+ struct resource *res = data; |
5482 |
+ struct resource_win win; |
5483 |
+ |
5484 |
++ /* |
5485 |
++ * We might assign this to 'res' later, make sure all pointers are |
5486 |
++ * cleared before the resource is added to the global list |
5487 |
++ */ |
5488 |
++ memset(&win, 0, sizeof(win)); |
5489 |
++ |
5490 |
+ res->flags = 0; |
5491 |
+ if (acpi_dev_filter_resource_type(acpi_res, IORESOURCE_MEM) == 0) |
5492 |
+ return AE_OK; |
5493 |
+diff --git a/drivers/android/binder.c b/drivers/android/binder.c |
5494 |
+index 6f086415727c..235ba1fbabdb 100644 |
5495 |
+--- a/drivers/android/binder.c |
5496 |
++++ b/drivers/android/binder.c |
5497 |
+@@ -2865,7 +2865,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma) |
5498 |
+ const char *failure_string; |
5499 |
+ struct binder_buffer *buffer; |
5500 |
+ |
5501 |
+- if (proc->tsk != current) |
5502 |
++ if (proc->tsk != current->group_leader) |
5503 |
+ return -EINVAL; |
5504 |
+ |
5505 |
+ if ((vma->vm_end - vma->vm_start) > SZ_4M) |
5506 |
+diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c |
5507 |
+index 8d4d959a821c..8706533db57b 100644 |
5508 |
+--- a/drivers/ata/pata_amd.c |
5509 |
++++ b/drivers/ata/pata_amd.c |
5510 |
+@@ -616,6 +616,7 @@ static const struct pci_device_id amd[] = { |
5511 |
+ { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 8 }, |
5512 |
+ { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 8 }, |
5513 |
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 }, |
5514 |
++ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_DEV_IDE), 9 }, |
5515 |
+ |
5516 |
+ { }, |
5517 |
+ }; |
5518 |
+diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c |
5519 |
+index 6c15a554efbe..dc1255294628 100644 |
5520 |
+--- a/drivers/ata/pata_cs5536.c |
5521 |
++++ b/drivers/ata/pata_cs5536.c |
5522 |
+@@ -289,6 +289,7 @@ static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
5523 |
+ |
5524 |
+ static const struct pci_device_id cs5536[] = { |
5525 |
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), }, |
5526 |
++ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_DEV_IDE), }, |
5527 |
+ { }, |
5528 |
+ }; |
5529 |
+ |
5530 |
+diff --git a/drivers/base/bus.c b/drivers/base/bus.c |
5531 |
+index 79bc203f51ef..07ea8608fb0b 100644 |
5532 |
+--- a/drivers/base/bus.c |
5533 |
++++ b/drivers/base/bus.c |
5534 |
+@@ -722,7 +722,7 @@ int bus_add_driver(struct device_driver *drv) |
5535 |
+ |
5536 |
+ out_unregister: |
5537 |
+ kobject_put(&priv->kobj); |
5538 |
+- kfree(drv->p); |
5539 |
++ /* drv->p is freed in driver_release() */ |
5540 |
+ drv->p = NULL; |
5541 |
+ out_put_bus: |
5542 |
+ bus_put(bus); |
5543 |
+diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c |
5544 |
+index 1e46eb2305c0..f928e698f659 100644 |
5545 |
+--- a/drivers/block/skd_main.c |
5546 |
++++ b/drivers/block/skd_main.c |
5547 |
+@@ -2214,6 +2214,9 @@ static void skd_send_fitmsg(struct skd_device *skdev, |
5548 |
+ */ |
5549 |
+ qcmd |= FIT_QCMD_MSGSIZE_64; |
5550 |
+ |
5551 |
++ /* Make sure skd_msg_buf is written before the doorbell is triggered. */ |
5552 |
++ smp_wmb(); |
5553 |
++ |
5554 |
+ SKD_WRITEQ(skdev, qcmd, FIT_Q_COMMAND); |
5555 |
+ |
5556 |
+ } |
5557 |
+@@ -2260,6 +2263,9 @@ static void skd_send_special_fitmsg(struct skd_device *skdev, |
5558 |
+ qcmd = skspcl->mb_dma_address; |
5559 |
+ qcmd |= FIT_QCMD_QID_NORMAL + FIT_QCMD_MSGSIZE_128; |
5560 |
+ |
5561 |
++ /* Make sure skd_msg_buf is written before the doorbell is triggered. */ |
5562 |
++ smp_wmb(); |
5563 |
++ |
5564 |
+ SKD_WRITEQ(skdev, qcmd, FIT_Q_COMMAND); |
5565 |
+ } |
5566 |
+ |
5567 |
+@@ -4679,15 +4685,16 @@ static void skd_free_disk(struct skd_device *skdev) |
5568 |
+ { |
5569 |
+ struct gendisk *disk = skdev->disk; |
5570 |
+ |
5571 |
+- if (disk != NULL) { |
5572 |
+- struct request_queue *q = disk->queue; |
5573 |
++ if (disk && (disk->flags & GENHD_FL_UP)) |
5574 |
++ del_gendisk(disk); |
5575 |
+ |
5576 |
+- if (disk->flags & GENHD_FL_UP) |
5577 |
+- del_gendisk(disk); |
5578 |
+- if (q) |
5579 |
+- blk_cleanup_queue(q); |
5580 |
+- put_disk(disk); |
5581 |
++ if (skdev->queue) { |
5582 |
++ blk_cleanup_queue(skdev->queue); |
5583 |
++ skdev->queue = NULL; |
5584 |
++ disk->queue = NULL; |
5585 |
+ } |
5586 |
++ |
5587 |
++ put_disk(disk); |
5588 |
+ skdev->disk = NULL; |
5589 |
+ } |
5590 |
+ |
5591 |
+diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c |
5592 |
+index 3956fd646bf2..0c13dfd1c29d 100644 |
5593 |
+--- a/drivers/bluetooth/btusb.c |
5594 |
++++ b/drivers/bluetooth/btusb.c |
5595 |
+@@ -323,6 +323,7 @@ static const struct usb_device_id blacklist_table[] = { |
5596 |
+ { USB_DEVICE(0x13d3, 0x3410), .driver_info = BTUSB_REALTEK }, |
5597 |
+ { USB_DEVICE(0x13d3, 0x3416), .driver_info = BTUSB_REALTEK }, |
5598 |
+ { USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK }, |
5599 |
++ { USB_DEVICE(0x13d3, 0x3494), .driver_info = BTUSB_REALTEK }, |
5600 |
+ |
5601 |
+ /* Additional Realtek 8821AE Bluetooth devices */ |
5602 |
+ { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK }, |
5603 |
+diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c |
5604 |
+index 6e3b78ee7d16..be9b1c8b9209 100644 |
5605 |
+--- a/drivers/gpu/drm/drm_atomic.c |
5606 |
++++ b/drivers/gpu/drm/drm_atomic.c |
5607 |
+@@ -996,6 +996,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state) |
5608 |
+ if (config->funcs->atomic_check) |
5609 |
+ ret = config->funcs->atomic_check(state->dev, state); |
5610 |
+ |
5611 |
++ if (ret) |
5612 |
++ return ret; |
5613 |
++ |
5614 |
+ if (!state->allow_modeset) { |
5615 |
+ for_each_crtc_in_state(state, crtc, crtc_state, i) { |
5616 |
+ if (crtc_state->mode_changed || |
5617 |
+@@ -1007,7 +1010,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) |
5618 |
+ } |
5619 |
+ } |
5620 |
+ |
5621 |
+- return ret; |
5622 |
++ return 0; |
5623 |
+ } |
5624 |
+ EXPORT_SYMBOL(drm_atomic_check_only); |
5625 |
+ |
5626 |
+diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c |
5627 |
+index 16a164770713..9b2de3ff66d9 100644 |
5628 |
+--- a/drivers/gpu/drm/drm_gem.c |
5629 |
++++ b/drivers/gpu/drm/drm_gem.c |
5630 |
+@@ -710,13 +710,13 @@ drm_gem_object_release_handle(int id, void *ptr, void *data) |
5631 |
+ struct drm_gem_object *obj = ptr; |
5632 |
+ struct drm_device *dev = obj->dev; |
5633 |
+ |
5634 |
++ if (dev->driver->gem_close_object) |
5635 |
++ dev->driver->gem_close_object(obj, file_priv); |
5636 |
++ |
5637 |
+ if (drm_core_check_feature(dev, DRIVER_PRIME)) |
5638 |
+ drm_gem_remove_prime_handles(obj, file_priv); |
5639 |
+ drm_vma_node_revoke(&obj->vma_node, file_priv->filp); |
5640 |
+ |
5641 |
+- if (dev->driver->gem_close_object) |
5642 |
+- dev->driver->gem_close_object(obj, file_priv); |
5643 |
+- |
5644 |
+ drm_gem_object_handle_unreference_unlocked(obj); |
5645 |
+ |
5646 |
+ return 0; |
5647 |
+diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c |
5648 |
+index b728523e194f..bfdbfc431e07 100644 |
5649 |
+--- a/drivers/gpu/drm/i2c/adv7511.c |
5650 |
++++ b/drivers/gpu/drm/i2c/adv7511.c |
5651 |
+@@ -48,6 +48,10 @@ struct adv7511 { |
5652 |
+ struct gpio_desc *gpio_pd; |
5653 |
+ }; |
5654 |
+ |
5655 |
++static const int edid_i2c_addr = 0x7e; |
5656 |
++static const int packet_i2c_addr = 0x70; |
5657 |
++static const int cec_i2c_addr = 0x78; |
5658 |
++ |
5659 |
+ static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder) |
5660 |
+ { |
5661 |
+ return to_encoder_slave(encoder)->slave_priv; |
5662 |
+@@ -362,12 +366,19 @@ static void adv7511_power_on(struct adv7511 *adv7511) |
5663 |
+ { |
5664 |
+ adv7511->current_edid_segment = -1; |
5665 |
+ |
5666 |
+- regmap_write(adv7511->regmap, ADV7511_REG_INT(0), |
5667 |
+- ADV7511_INT0_EDID_READY); |
5668 |
+- regmap_write(adv7511->regmap, ADV7511_REG_INT(1), |
5669 |
+- ADV7511_INT1_DDC_ERROR); |
5670 |
+ regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, |
5671 |
+ ADV7511_POWER_POWER_DOWN, 0); |
5672 |
++ if (adv7511->i2c_main->irq) { |
5673 |
++ /* |
5674 |
++ * Documentation says the INT_ENABLE registers are reset in |
5675 |
++ * POWER_DOWN mode. My 7511w preserved the bits, however. |
5676 |
++ * Still, let's be safe and stick to the documentation. |
5677 |
++ */ |
5678 |
++ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0), |
5679 |
++ ADV7511_INT0_EDID_READY); |
5680 |
++ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1), |
5681 |
++ ADV7511_INT1_DDC_ERROR); |
5682 |
++ } |
5683 |
+ |
5684 |
+ /* |
5685 |
+ * Per spec it is allowed to pulse the HDP signal to indicate that the |
5686 |
+@@ -567,13 +578,18 @@ static int adv7511_get_modes(struct drm_encoder *encoder, |
5687 |
+ |
5688 |
+ /* Reading the EDID only works if the device is powered */ |
5689 |
+ if (!adv7511->powered) { |
5690 |
+- regmap_write(adv7511->regmap, ADV7511_REG_INT(0), |
5691 |
+- ADV7511_INT0_EDID_READY); |
5692 |
+- regmap_write(adv7511->regmap, ADV7511_REG_INT(1), |
5693 |
+- ADV7511_INT1_DDC_ERROR); |
5694 |
+ regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, |
5695 |
+ ADV7511_POWER_POWER_DOWN, 0); |
5696 |
++ if (adv7511->i2c_main->irq) { |
5697 |
++ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0), |
5698 |
++ ADV7511_INT0_EDID_READY); |
5699 |
++ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1), |
5700 |
++ ADV7511_INT1_DDC_ERROR); |
5701 |
++ } |
5702 |
+ adv7511->current_edid_segment = -1; |
5703 |
++ /* Reset the EDID_I2C_ADDR register as it might be cleared */ |
5704 |
++ regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, |
5705 |
++ edid_i2c_addr); |
5706 |
+ } |
5707 |
+ |
5708 |
+ edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); |
5709 |
+@@ -849,10 +865,6 @@ static int adv7511_parse_dt(struct device_node *np, |
5710 |
+ return 0; |
5711 |
+ } |
5712 |
+ |
5713 |
+-static const int edid_i2c_addr = 0x7e; |
5714 |
+-static const int packet_i2c_addr = 0x70; |
5715 |
+-static const int cec_i2c_addr = 0x78; |
5716 |
+- |
5717 |
+ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) |
5718 |
+ { |
5719 |
+ struct adv7511_link_config link_config; |
5720 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
5721 |
+index 7c6f15d284e3..824c835330df 100644 |
5722 |
+--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
5723 |
++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c |
5724 |
+@@ -148,8 +148,8 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) |
5725 |
+ rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? OTAR2 : OTAR, 0); |
5726 |
+ |
5727 |
+ /* Signal polarities */ |
5728 |
+- value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL) |
5729 |
+- | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL) |
5730 |
++ value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? DSMR_VSL : 0) |
5731 |
++ | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? DSMR_HSL : 0) |
5732 |
+ | DSMR_DIPM_DE | DSMR_CSPM; |
5733 |
+ rcar_du_crtc_write(rcrtc, DSMR, value); |
5734 |
+ |
5735 |
+@@ -171,7 +171,7 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) |
5736 |
+ mode->crtc_vsync_start - 1); |
5737 |
+ rcar_du_crtc_write(rcrtc, VCR, mode->crtc_vtotal - 1); |
5738 |
+ |
5739 |
+- rcar_du_crtc_write(rcrtc, DESR, mode->htotal - mode->hsync_start); |
5740 |
++ rcar_du_crtc_write(rcrtc, DESR, mode->htotal - mode->hsync_start - 1); |
5741 |
+ rcar_du_crtc_write(rcrtc, DEWR, mode->hdisplay); |
5742 |
+ } |
5743 |
+ |
5744 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c |
5745 |
+index 85043c5bad03..873e04aa9352 100644 |
5746 |
+--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c |
5747 |
++++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c |
5748 |
+@@ -56,11 +56,11 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds, |
5749 |
+ return ret; |
5750 |
+ |
5751 |
+ /* PLL clock configuration */ |
5752 |
+- if (freq <= 38000) |
5753 |
++ if (freq < 39000) |
5754 |
+ pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_38M; |
5755 |
+- else if (freq <= 60000) |
5756 |
++ else if (freq < 61000) |
5757 |
+ pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_60M; |
5758 |
+- else if (freq <= 121000) |
5759 |
++ else if (freq < 121000) |
5760 |
+ pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_121M; |
5761 |
+ else |
5762 |
+ pllcr = LVDPLLCR_PLLDLYCNT_150M; |
5763 |
+@@ -102,7 +102,7 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds, |
5764 |
+ /* Turn the PLL on, wait for the startup delay, and turn the output |
5765 |
+ * on. |
5766 |
+ */ |
5767 |
+- lvdcr0 |= LVDCR0_PLLEN; |
5768 |
++ lvdcr0 |= LVDCR0_PLLON; |
5769 |
+ rcar_lvds_write(lvds, LVDCR0, lvdcr0); |
5770 |
+ |
5771 |
+ usleep_range(100, 150); |
5772 |
+diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h |
5773 |
+index 77cf9289ab65..b1eafd097a79 100644 |
5774 |
+--- a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h |
5775 |
++++ b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h |
5776 |
+@@ -18,7 +18,7 @@ |
5777 |
+ #define LVDCR0_DMD (1 << 12) |
5778 |
+ #define LVDCR0_LVMD_MASK (0xf << 8) |
5779 |
+ #define LVDCR0_LVMD_SHIFT 8 |
5780 |
+-#define LVDCR0_PLLEN (1 << 4) |
5781 |
++#define LVDCR0_PLLON (1 << 4) |
5782 |
+ #define LVDCR0_BEN (1 << 2) |
5783 |
+ #define LVDCR0_LVEN (1 << 1) |
5784 |
+ #define LVDCR0_LVRES (1 << 0) |
5785 |
+diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c |
5786 |
+index 025c429050c0..5d8dfe027b30 100644 |
5787 |
+--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c |
5788 |
++++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c |
5789 |
+@@ -612,7 +612,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool, |
5790 |
+ } else { |
5791 |
+ pr_err("Failed to fill pool (%p)\n", pool); |
5792 |
+ /* If we have any pages left put them to the pool. */ |
5793 |
+- list_for_each_entry(p, &pool->list, lru) { |
5794 |
++ list_for_each_entry(p, &new_pages, lru) { |
5795 |
+ ++cpages; |
5796 |
+ } |
5797 |
+ list_splice(&new_pages, &pool->list); |
5798 |
+diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c |
5799 |
+index f994712d0904..a9276eeb61d5 100644 |
5800 |
+--- a/drivers/i2c/busses/i2c-ismt.c |
5801 |
++++ b/drivers/i2c/busses/i2c-ismt.c |
5802 |
+@@ -340,8 +340,10 @@ static int ismt_process_desc(const struct ismt_desc *desc, |
5803 |
+ break; |
5804 |
+ case I2C_SMBUS_BLOCK_DATA: |
5805 |
+ case I2C_SMBUS_I2C_BLOCK_DATA: |
5806 |
+- memcpy(&data->block[1], dma_buffer, desc->rxbytes); |
5807 |
+- data->block[0] = desc->rxbytes; |
5808 |
++ if (desc->rxbytes != dma_buffer[0] + 1) |
5809 |
++ return -EMSGSIZE; |
5810 |
++ |
5811 |
++ memcpy(data->block, dma_buffer, desc->rxbytes); |
5812 |
+ break; |
5813 |
+ } |
5814 |
+ return 0; |
5815 |
+diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c |
5816 |
+index 19b2d689a5ef..4880aae98b4c 100644 |
5817 |
+--- a/drivers/i2c/busses/i2c-jz4780.c |
5818 |
++++ b/drivers/i2c/busses/i2c-jz4780.c |
5819 |
+@@ -783,10 +783,6 @@ static int jz4780_i2c_probe(struct platform_device *pdev) |
5820 |
+ |
5821 |
+ jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0); |
5822 |
+ |
5823 |
+- i2c->cmd = 0; |
5824 |
+- memset(i2c->cmd_buf, 0, BUFSIZE); |
5825 |
+- memset(i2c->data_buf, 0, BUFSIZE); |
5826 |
+- |
5827 |
+ i2c->irq = platform_get_irq(pdev, 0); |
5828 |
+ ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, |
5829 |
+ dev_name(&pdev->dev), i2c); |
5830 |
+diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c |
5831 |
+index 595511022795..3460dd0e3e99 100644 |
5832 |
+--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c |
5833 |
++++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c |
5834 |
+@@ -36,8 +36,6 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) |
5835 |
+ s32 poll_value = 0; |
5836 |
+ |
5837 |
+ if (state) { |
5838 |
+- if (!atomic_read(&st->user_requested_state)) |
5839 |
+- return 0; |
5840 |
+ if (sensor_hub_device_open(st->hsdev)) |
5841 |
+ return -EIO; |
5842 |
+ |
5843 |
+@@ -86,6 +84,9 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) |
5844 |
+ &report_val); |
5845 |
+ } |
5846 |
+ |
5847 |
++ pr_debug("HID_SENSOR %s set power_state %d report_state %d\n", |
5848 |
++ st->pdev->name, state_val, report_val); |
5849 |
++ |
5850 |
+ sensor_hub_get_feature(st->hsdev, st->power_state.report_id, |
5851 |
+ st->power_state.index, |
5852 |
+ sizeof(state_val), &state_val); |
5853 |
+@@ -107,6 +108,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) |
5854 |
+ ret = pm_runtime_get_sync(&st->pdev->dev); |
5855 |
+ else { |
5856 |
+ pm_runtime_mark_last_busy(&st->pdev->dev); |
5857 |
++ pm_runtime_use_autosuspend(&st->pdev->dev); |
5858 |
+ ret = pm_runtime_put_autosuspend(&st->pdev->dev); |
5859 |
+ } |
5860 |
+ if (ret < 0) { |
5861 |
+@@ -175,8 +177,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, |
5862 |
+ /* Default to 3 seconds, but can be changed from sysfs */ |
5863 |
+ pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, |
5864 |
+ 3000); |
5865 |
+- pm_runtime_use_autosuspend(&attrb->pdev->dev); |
5866 |
+- |
5867 |
+ return ret; |
5868 |
+ error_unreg_trigger: |
5869 |
+ iio_trigger_unregister(trig); |
5870 |
+diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c |
5871 |
+index b94bfd3f595b..7a9c50842d8b 100644 |
5872 |
+--- a/drivers/iio/imu/adis16480.c |
5873 |
++++ b/drivers/iio/imu/adis16480.c |
5874 |
+@@ -696,7 +696,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { |
5875 |
+ .gyro_max_val = IIO_RAD_TO_DEGREE(22500), |
5876 |
+ .gyro_max_scale = 450, |
5877 |
+ .accel_max_val = IIO_M_S_2_TO_G(12500), |
5878 |
+- .accel_max_scale = 5, |
5879 |
++ .accel_max_scale = 10, |
5880 |
+ }, |
5881 |
+ [ADIS16485] = { |
5882 |
+ .channels = adis16485_channels, |
5883 |
+diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c |
5884 |
+index 354d47ecd66a..7e2dc5e56632 100644 |
5885 |
+--- a/drivers/input/mouse/trackpoint.c |
5886 |
++++ b/drivers/input/mouse/trackpoint.c |
5887 |
+@@ -265,7 +265,8 @@ static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *fir |
5888 |
+ if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) |
5889 |
+ return -1; |
5890 |
+ |
5891 |
+- if (param[0] != TP_MAGIC_IDENT) |
5892 |
++ /* add new TP ID. */ |
5893 |
++ if (!(param[0] & TP_MAGIC_IDENT)) |
5894 |
+ return -1; |
5895 |
+ |
5896 |
+ if (firmware_id) |
5897 |
+@@ -380,8 +381,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) |
5898 |
+ return 0; |
5899 |
+ |
5900 |
+ if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { |
5901 |
+- psmouse_warn(psmouse, "failed to get extended button data\n"); |
5902 |
+- button_info = 0; |
5903 |
++ psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n"); |
5904 |
++ button_info = 0x33; |
5905 |
+ } |
5906 |
+ |
5907 |
+ psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); |
5908 |
+diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h |
5909 |
+index 5617ed3a7d7a..88055755f82e 100644 |
5910 |
+--- a/drivers/input/mouse/trackpoint.h |
5911 |
++++ b/drivers/input/mouse/trackpoint.h |
5912 |
+@@ -21,8 +21,9 @@ |
5913 |
+ #define TP_COMMAND 0xE2 /* Commands start with this */ |
5914 |
+ |
5915 |
+ #define TP_READ_ID 0xE1 /* Sent for device identification */ |
5916 |
+-#define TP_MAGIC_IDENT 0x01 /* Sent after a TP_READ_ID followed */ |
5917 |
++#define TP_MAGIC_IDENT 0x03 /* Sent after a TP_READ_ID followed */ |
5918 |
+ /* by the firmware ID */ |
5919 |
++ /* Firmware ID includes 0x1, 0x2, 0x3 */ |
5920 |
+ |
5921 |
+ |
5922 |
+ /* |
5923 |
+diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h |
5924 |
+index 1f40cdc1b357..18fd4cd6d3c7 100644 |
5925 |
+--- a/drivers/input/serio/i8042-x86ia64io.h |
5926 |
++++ b/drivers/input/serio/i8042-x86ia64io.h |
5927 |
+@@ -814,6 +814,13 @@ static const struct dmi_system_id __initconst i8042_dmi_kbdreset_table[] = { |
5928 |
+ DMI_MATCH(DMI_PRODUCT_NAME, "P34"), |
5929 |
+ }, |
5930 |
+ }, |
5931 |
++ { |
5932 |
++ /* Gigabyte P57 - Elantech touchpad */ |
5933 |
++ .matches = { |
5934 |
++ DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), |
5935 |
++ DMI_MATCH(DMI_PRODUCT_NAME, "P57"), |
5936 |
++ }, |
5937 |
++ }, |
5938 |
+ { |
5939 |
+ /* Schenker XMG C504 - Elantech touchpad */ |
5940 |
+ .matches = { |
5941 |
+diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c |
5942 |
+index 869d01dd4063..af20eac63ad4 100644 |
5943 |
+--- a/drivers/irqchip/irq-atmel-aic-common.c |
5944 |
++++ b/drivers/irqchip/irq-atmel-aic-common.c |
5945 |
+@@ -148,9 +148,9 @@ void __init aic_common_rtc_irq_fixup(struct device_node *root) |
5946 |
+ struct device_node *np; |
5947 |
+ void __iomem *regs; |
5948 |
+ |
5949 |
+- np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc"); |
5950 |
++ np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc"); |
5951 |
+ if (!np) |
5952 |
+- np = of_find_compatible_node(root, NULL, |
5953 |
++ np = of_find_compatible_node(NULL, NULL, |
5954 |
+ "atmel,at91sam9x5-rtc"); |
5955 |
+ |
5956 |
+ if (!np) |
5957 |
+@@ -202,7 +202,6 @@ void __init aic_common_irq_fixup(const struct of_device_id *matches) |
5958 |
+ return; |
5959 |
+ |
5960 |
+ match = of_match_node(matches, root); |
5961 |
+- of_node_put(root); |
5962 |
+ |
5963 |
+ if (match) { |
5964 |
+ void (*fixup)(struct device_node *) = match->data; |
5965 |
+diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c |
5966 |
+index 269c2354c431..e1d71574bdb5 100644 |
5967 |
+--- a/drivers/irqchip/irq-mips-gic.c |
5968 |
++++ b/drivers/irqchip/irq-mips-gic.c |
5969 |
+@@ -861,8 +861,11 @@ static int __init gic_of_init(struct device_node *node, |
5970 |
+ gic_len = resource_size(&res); |
5971 |
+ } |
5972 |
+ |
5973 |
+- if (mips_cm_present()) |
5974 |
++ if (mips_cm_present()) { |
5975 |
+ write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK); |
5976 |
++ /* Ensure GIC region is enabled before trying to access it */ |
5977 |
++ __sync(); |
5978 |
++ } |
5979 |
+ gic_present = true; |
5980 |
+ |
5981 |
+ __gic_init(gic_base, gic_len, cpu_vec, 0, node); |
5982 |
+diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h |
5983 |
+index 04f7bc28ef83..dfdd1908641c 100644 |
5984 |
+--- a/drivers/md/bcache/bcache.h |
5985 |
++++ b/drivers/md/bcache/bcache.h |
5986 |
+@@ -348,6 +348,7 @@ struct cached_dev { |
5987 |
+ /* Limit number of writeback bios in flight */ |
5988 |
+ struct semaphore in_flight; |
5989 |
+ struct task_struct *writeback_thread; |
5990 |
++ struct workqueue_struct *writeback_write_wq; |
5991 |
+ |
5992 |
+ struct keybuf writeback_keys; |
5993 |
+ |
5994 |
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c |
5995 |
+index a7a03a21d78a..8e5666ac8a6a 100644 |
5996 |
+--- a/drivers/md/bcache/super.c |
5997 |
++++ b/drivers/md/bcache/super.c |
5998 |
+@@ -1054,7 +1054,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) |
5999 |
+ } |
6000 |
+ |
6001 |
+ if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) { |
6002 |
+- bch_sectors_dirty_init(dc); |
6003 |
++ bch_sectors_dirty_init(&dc->disk); |
6004 |
+ atomic_set(&dc->has_dirty, 1); |
6005 |
+ atomic_inc(&dc->count); |
6006 |
+ bch_writeback_queue(dc); |
6007 |
+@@ -1087,6 +1087,8 @@ static void cached_dev_free(struct closure *cl) |
6008 |
+ cancel_delayed_work_sync(&dc->writeback_rate_update); |
6009 |
+ if (!IS_ERR_OR_NULL(dc->writeback_thread)) |
6010 |
+ kthread_stop(dc->writeback_thread); |
6011 |
++ if (dc->writeback_write_wq) |
6012 |
++ destroy_workqueue(dc->writeback_write_wq); |
6013 |
+ |
6014 |
+ mutex_lock(&bch_register_lock); |
6015 |
+ |
6016 |
+@@ -1258,6 +1260,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) |
6017 |
+ goto err; |
6018 |
+ |
6019 |
+ bcache_device_attach(d, c, u - c->uuids); |
6020 |
++ bch_sectors_dirty_init(d); |
6021 |
+ bch_flash_dev_request_init(d); |
6022 |
+ add_disk(d->disk); |
6023 |
+ |
6024 |
+@@ -1996,6 +1999,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, |
6025 |
+ else |
6026 |
+ err = "device busy"; |
6027 |
+ mutex_unlock(&bch_register_lock); |
6028 |
++ if (!IS_ERR(bdev)) |
6029 |
++ bdput(bdev); |
6030 |
+ if (attr == &ksysfs_register_quiet) |
6031 |
+ goto out; |
6032 |
+ } |
6033 |
+diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c |
6034 |
+index b3ff57d61dde..4fbb5532f24c 100644 |
6035 |
+--- a/drivers/md/bcache/sysfs.c |
6036 |
++++ b/drivers/md/bcache/sysfs.c |
6037 |
+@@ -191,7 +191,7 @@ STORE(__cached_dev) |
6038 |
+ { |
6039 |
+ struct cached_dev *dc = container_of(kobj, struct cached_dev, |
6040 |
+ disk.kobj); |
6041 |
+- unsigned v = size; |
6042 |
++ ssize_t v = size; |
6043 |
+ struct cache_set *c; |
6044 |
+ struct kobj_uevent_env *env; |
6045 |
+ |
6046 |
+@@ -226,7 +226,7 @@ STORE(__cached_dev) |
6047 |
+ bch_cached_dev_run(dc); |
6048 |
+ |
6049 |
+ if (attr == &sysfs_cache_mode) { |
6050 |
+- ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1); |
6051 |
++ v = bch_read_string_list(buf, bch_cache_modes + 1); |
6052 |
+ |
6053 |
+ if (v < 0) |
6054 |
+ return v; |
6055 |
+diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c |
6056 |
+index db3ae4c2b223..6c18e3ec3e48 100644 |
6057 |
+--- a/drivers/md/bcache/util.c |
6058 |
++++ b/drivers/md/bcache/util.c |
6059 |
+@@ -73,24 +73,44 @@ STRTO_H(strtouint, unsigned int) |
6060 |
+ STRTO_H(strtoll, long long) |
6061 |
+ STRTO_H(strtoull, unsigned long long) |
6062 |
+ |
6063 |
++/** |
6064 |
++ * bch_hprint() - formats @v to human readable string for sysfs. |
6065 |
++ * |
6066 |
++ * @v - signed 64 bit integer |
6067 |
++ * @buf - the (at least 8 byte) buffer to format the result into. |
6068 |
++ * |
6069 |
++ * Returns the number of bytes used by format. |
6070 |
++ */ |
6071 |
+ ssize_t bch_hprint(char *buf, int64_t v) |
6072 |
+ { |
6073 |
+ static const char units[] = "?kMGTPEZY"; |
6074 |
+- char dec[4] = ""; |
6075 |
+- int u, t = 0; |
6076 |
+- |
6077 |
+- for (u = 0; v >= 1024 || v <= -1024; u++) { |
6078 |
+- t = v & ~(~0 << 10); |
6079 |
+- v >>= 10; |
6080 |
+- } |
6081 |
+- |
6082 |
+- if (!u) |
6083 |
+- return sprintf(buf, "%llu", v); |
6084 |
+- |
6085 |
+- if (v < 100 && v > -100) |
6086 |
+- snprintf(dec, sizeof(dec), ".%i", t / 100); |
6087 |
+- |
6088 |
+- return sprintf(buf, "%lli%s%c", v, dec, units[u]); |
6089 |
++ int u = 0, t; |
6090 |
++ |
6091 |
++ uint64_t q; |
6092 |
++ |
6093 |
++ if (v < 0) |
6094 |
++ q = -v; |
6095 |
++ else |
6096 |
++ q = v; |
6097 |
++ |
6098 |
++ /* For as long as the number is more than 3 digits, but at least |
6099 |
++ * once, shift right / divide by 1024. Keep the remainder for |
6100 |
++ * a digit after the decimal point. |
6101 |
++ */ |
6102 |
++ do { |
6103 |
++ u++; |
6104 |
++ |
6105 |
++ t = q & ~(~0 << 10); |
6106 |
++ q >>= 10; |
6107 |
++ } while (q >= 1000); |
6108 |
++ |
6109 |
++ if (v < 0) |
6110 |
++ /* '-', up to 3 digits, '.', 1 digit, 1 character, null; |
6111 |
++ * yields 8 bytes. |
6112 |
++ */ |
6113 |
++ return sprintf(buf, "-%llu.%i%c", q, t * 10 / 1024, units[u]); |
6114 |
++ else |
6115 |
++ return sprintf(buf, "%llu.%i%c", q, t * 10 / 1024, units[u]); |
6116 |
+ } |
6117 |
+ |
6118 |
+ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[], |
6119 |
+diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c |
6120 |
+index 540256a0df4f..b0667b321a3f 100644 |
6121 |
+--- a/drivers/md/bcache/writeback.c |
6122 |
++++ b/drivers/md/bcache/writeback.c |
6123 |
+@@ -21,7 +21,8 @@ |
6124 |
+ static void __update_writeback_rate(struct cached_dev *dc) |
6125 |
+ { |
6126 |
+ struct cache_set *c = dc->disk.c; |
6127 |
+- uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size; |
6128 |
++ uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size - |
6129 |
++ bcache_flash_devs_sectors_dirty(c); |
6130 |
+ uint64_t cache_dirty_target = |
6131 |
+ div_u64(cache_sectors * dc->writeback_percent, 100); |
6132 |
+ |
6133 |
+@@ -190,7 +191,7 @@ static void write_dirty(struct closure *cl) |
6134 |
+ |
6135 |
+ closure_bio_submit(&io->bio, cl, &io->dc->disk); |
6136 |
+ |
6137 |
+- continue_at(cl, write_dirty_finish, system_wq); |
6138 |
++ continue_at(cl, write_dirty_finish, io->dc->writeback_write_wq); |
6139 |
+ } |
6140 |
+ |
6141 |
+ static void read_dirty_endio(struct bio *bio, int error) |
6142 |
+@@ -210,7 +211,7 @@ static void read_dirty_submit(struct closure *cl) |
6143 |
+ |
6144 |
+ closure_bio_submit(&io->bio, cl, &io->dc->disk); |
6145 |
+ |
6146 |
+- continue_at(cl, write_dirty, system_wq); |
6147 |
++ continue_at(cl, write_dirty, io->dc->writeback_write_wq); |
6148 |
+ } |
6149 |
+ |
6150 |
+ static void read_dirty(struct cached_dev *dc) |
6151 |
+@@ -488,17 +489,17 @@ static int sectors_dirty_init_fn(struct btree_op *_op, struct btree *b, |
6152 |
+ return MAP_CONTINUE; |
6153 |
+ } |
6154 |
+ |
6155 |
+-void bch_sectors_dirty_init(struct cached_dev *dc) |
6156 |
++void bch_sectors_dirty_init(struct bcache_device *d) |
6157 |
+ { |
6158 |
+ struct sectors_dirty_init op; |
6159 |
+ |
6160 |
+ bch_btree_op_init(&op.op, -1); |
6161 |
+- op.inode = dc->disk.id; |
6162 |
++ op.inode = d->id; |
6163 |
+ |
6164 |
+- bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), |
6165 |
++ bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0), |
6166 |
+ sectors_dirty_init_fn, 0); |
6167 |
+ |
6168 |
+- dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk); |
6169 |
++ d->sectors_dirty_last = bcache_dev_sectors_dirty(d); |
6170 |
+ } |
6171 |
+ |
6172 |
+ void bch_cached_dev_writeback_init(struct cached_dev *dc) |
6173 |
+@@ -522,6 +523,11 @@ void bch_cached_dev_writeback_init(struct cached_dev *dc) |
6174 |
+ |
6175 |
+ int bch_cached_dev_writeback_start(struct cached_dev *dc) |
6176 |
+ { |
6177 |
++ dc->writeback_write_wq = alloc_workqueue("bcache_writeback_wq", |
6178 |
++ WQ_MEM_RECLAIM, 0); |
6179 |
++ if (!dc->writeback_write_wq) |
6180 |
++ return -ENOMEM; |
6181 |
++ |
6182 |
+ dc->writeback_thread = kthread_create(bch_writeback_thread, dc, |
6183 |
+ "bcache_writeback"); |
6184 |
+ if (IS_ERR(dc->writeback_thread)) |
6185 |
+diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h |
6186 |
+index 073a042aed24..daec4fd782ea 100644 |
6187 |
+--- a/drivers/md/bcache/writeback.h |
6188 |
++++ b/drivers/md/bcache/writeback.h |
6189 |
+@@ -14,6 +14,25 @@ static inline uint64_t bcache_dev_sectors_dirty(struct bcache_device *d) |
6190 |
+ return ret; |
6191 |
+ } |
6192 |
+ |
6193 |
++static inline uint64_t bcache_flash_devs_sectors_dirty(struct cache_set *c) |
6194 |
++{ |
6195 |
++ uint64_t i, ret = 0; |
6196 |
++ |
6197 |
++ mutex_lock(&bch_register_lock); |
6198 |
++ |
6199 |
++ for (i = 0; i < c->nr_uuids; i++) { |
6200 |
++ struct bcache_device *d = c->devices[i]; |
6201 |
++ |
6202 |
++ if (!d || !UUID_FLASH_ONLY(&c->uuids[i])) |
6203 |
++ continue; |
6204 |
++ ret += bcache_dev_sectors_dirty(d); |
6205 |
++ } |
6206 |
++ |
6207 |
++ mutex_unlock(&bch_register_lock); |
6208 |
++ |
6209 |
++ return ret; |
6210 |
++} |
6211 |
++ |
6212 |
+ static inline unsigned offset_to_stripe(struct bcache_device *d, |
6213 |
+ uint64_t offset) |
6214 |
+ { |
6215 |
+@@ -85,7 +104,7 @@ static inline void bch_writeback_add(struct cached_dev *dc) |
6216 |
+ |
6217 |
+ void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int); |
6218 |
+ |
6219 |
+-void bch_sectors_dirty_init(struct cached_dev *dc); |
6220 |
++void bch_sectors_dirty_init(struct bcache_device *); |
6221 |
+ void bch_cached_dev_writeback_init(struct cached_dev *); |
6222 |
+ int bch_cached_dev_writeback_start(struct cached_dev *); |
6223 |
+ |
6224 |
+diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c |
6225 |
+index a7621a258936..7078447c8cd7 100644 |
6226 |
+--- a/drivers/md/bitmap.c |
6227 |
++++ b/drivers/md/bitmap.c |
6228 |
+@@ -1965,6 +1965,11 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks, |
6229 |
+ long pages; |
6230 |
+ struct bitmap_page *new_bp; |
6231 |
+ |
6232 |
++ if (bitmap->storage.file && !init) { |
6233 |
++ pr_info("md: cannot resize file-based bitmap\n"); |
6234 |
++ return -EINVAL; |
6235 |
++ } |
6236 |
++ |
6237 |
+ if (chunksize == 0) { |
6238 |
+ /* If there is enough space, leave the chunk size unchanged, |
6239 |
+ * else increase by factor of two until there is enough space. |
6240 |
+diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c |
6241 |
+index 3e59b288b8a8..618e4e2b4207 100644 |
6242 |
+--- a/drivers/media/usb/uvc/uvc_ctrl.c |
6243 |
++++ b/drivers/media/usb/uvc/uvc_ctrl.c |
6244 |
+@@ -2001,6 +2001,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, |
6245 |
+ goto done; |
6246 |
+ } |
6247 |
+ |
6248 |
++ /* Validate the user-provided bit-size and offset */ |
6249 |
++ if (mapping->size > 32 || |
6250 |
++ mapping->offset + mapping->size > ctrl->info.size * 8) { |
6251 |
++ ret = -EINVAL; |
6252 |
++ goto done; |
6253 |
++ } |
6254 |
++ |
6255 |
+ list_for_each_entry(map, &ctrl->info.mappings, list) { |
6256 |
+ if (mapping->id == map->id) { |
6257 |
+ uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', " |
6258 |
+diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
6259 |
+index 4b777be714a4..4f002d0bebb1 100644 |
6260 |
+--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
6261 |
++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
6262 |
+@@ -750,7 +750,8 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u |
6263 |
+ copy_to_user(&up->u, &kp->u, sizeof(kp->u)) || |
6264 |
+ put_user(kp->pending, &up->pending) || |
6265 |
+ put_user(kp->sequence, &up->sequence) || |
6266 |
+- compat_put_timespec(&kp->timestamp, &up->timestamp) || |
6267 |
++ put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) || |
6268 |
++ put_user(kp->timestamp.tv_nsec, &up->timestamp.tv_nsec) || |
6269 |
+ put_user(kp->id, &up->id) || |
6270 |
+ copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32))) |
6271 |
+ return -EFAULT; |
6272 |
+diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c |
6273 |
+index 4ee080d49bc0..3ea651afa63d 100644 |
6274 |
+--- a/drivers/net/ethernet/freescale/gianfar.c |
6275 |
++++ b/drivers/net/ethernet/freescale/gianfar.c |
6276 |
+@@ -3512,7 +3512,7 @@ static noinline void gfar_update_link_state(struct gfar_private *priv) |
6277 |
+ u32 tempval1 = gfar_read(®s->maccfg1); |
6278 |
+ u32 tempval = gfar_read(®s->maccfg2); |
6279 |
+ u32 ecntrl = gfar_read(®s->ecntrl); |
6280 |
+- u32 tx_flow_oldval = (tempval & MACCFG1_TX_FLOW); |
6281 |
++ u32 tx_flow_oldval = (tempval1 & MACCFG1_TX_FLOW); |
6282 |
+ |
6283 |
+ if (phydev->duplex != priv->oldduplex) { |
6284 |
+ if (!(phydev->duplex)) |
6285 |
+diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c |
6286 |
+index 829be21f97b2..be258d90de9e 100644 |
6287 |
+--- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c |
6288 |
++++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c |
6289 |
+@@ -724,7 +724,7 @@ static void ql_build_coredump_seg_header( |
6290 |
+ seg_hdr->cookie = MPI_COREDUMP_COOKIE; |
6291 |
+ seg_hdr->segNum = seg_number; |
6292 |
+ seg_hdr->segSize = seg_size; |
6293 |
+- memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1); |
6294 |
++ strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1); |
6295 |
+ } |
6296 |
+ |
6297 |
+ /* |
6298 |
+diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c |
6299 |
+index 34a59e79a33c..480c9366d6b6 100644 |
6300 |
+--- a/drivers/net/usb/qmi_wwan.c |
6301 |
++++ b/drivers/net/usb/qmi_wwan.c |
6302 |
+@@ -750,6 +750,7 @@ static const struct usb_device_id products[] = { |
6303 |
+ {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */ |
6304 |
+ {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ |
6305 |
+ {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ |
6306 |
++ {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ |
6307 |
+ {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ |
6308 |
+ {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ |
6309 |
+ {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */ |
6310 |
+diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c |
6311 |
+index c0e454bb6a8d..e0e23470a380 100644 |
6312 |
+--- a/drivers/net/wireless/ath/ath10k/core.c |
6313 |
++++ b/drivers/net/wireless/ath/ath10k/core.c |
6314 |
+@@ -1040,6 +1040,12 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) |
6315 |
+ goto err_wmi_detach; |
6316 |
+ } |
6317 |
+ |
6318 |
++ /* If firmware indicates Full Rx Reorder support it must be used in a |
6319 |
++ * slightly different manner. Let HTT code know. |
6320 |
++ */ |
6321 |
++ ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER, |
6322 |
++ ar->wmi.svc_map)); |
6323 |
++ |
6324 |
+ status = ath10k_htt_rx_alloc(&ar->htt); |
6325 |
+ if (status) { |
6326 |
+ ath10k_err(ar, "failed to alloc htt rx: %d\n", status); |
6327 |
+@@ -1104,12 +1110,6 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) |
6328 |
+ goto err_hif_stop; |
6329 |
+ } |
6330 |
+ |
6331 |
+- /* If firmware indicates Full Rx Reorder support it must be used in a |
6332 |
+- * slightly different manner. Let HTT code know. |
6333 |
+- */ |
6334 |
+- ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER, |
6335 |
+- ar->wmi.svc_map)); |
6336 |
+- |
6337 |
+ status = ath10k_htt_rx_ring_refill(ar); |
6338 |
+ if (status) { |
6339 |
+ ath10k_err(ar, "failed to refill htt rx ring: %d\n", status); |
6340 |
+diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c |
6341 |
+index 275408eaf95e..8a11dab8f4b3 100644 |
6342 |
+--- a/drivers/net/wireless/p54/fwio.c |
6343 |
++++ b/drivers/net/wireless/p54/fwio.c |
6344 |
+@@ -489,7 +489,7 @@ int p54_scan(struct p54_common *priv, u16 mode, u16 dwell) |
6345 |
+ |
6346 |
+ entry += sizeof(__le16); |
6347 |
+ chan->pa_points_per_curve = 8; |
6348 |
+- memset(chan->curve_data, 0, sizeof(*chan->curve_data)); |
6349 |
++ memset(chan->curve_data, 0, sizeof(chan->curve_data)); |
6350 |
+ memcpy(chan->curve_data, entry, |
6351 |
+ sizeof(struct p54_pa_curve_data_sample) * |
6352 |
+ min((u8)8, curve_data->points_per_channel)); |
6353 |
+diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c |
6354 |
+index 5d54d16a59e7..040bf3c66958 100644 |
6355 |
+--- a/drivers/net/wireless/ti/wl1251/main.c |
6356 |
++++ b/drivers/net/wireless/ti/wl1251/main.c |
6357 |
+@@ -1571,6 +1571,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void) |
6358 |
+ |
6359 |
+ wl->state = WL1251_STATE_OFF; |
6360 |
+ mutex_init(&wl->mutex); |
6361 |
++ spin_lock_init(&wl->wl_lock); |
6362 |
+ |
6363 |
+ wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; |
6364 |
+ wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; |
6365 |
+diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c |
6366 |
+index bf89754fe973..308a95ead432 100644 |
6367 |
+--- a/drivers/of/fdt.c |
6368 |
++++ b/drivers/of/fdt.c |
6369 |
+@@ -413,7 +413,7 @@ static void __unflatten_device_tree(void *blob, |
6370 |
+ /* Allocate memory for the expanded device tree */ |
6371 |
+ mem = dt_alloc(size + 4, __alignof__(struct device_node)); |
6372 |
+ if (!mem) |
6373 |
+- return NULL; |
6374 |
++ return; |
6375 |
+ |
6376 |
+ memset(mem, 0, size); |
6377 |
+ |
6378 |
+diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c |
6379 |
+index 7b0ca1551d7b..005ea632ba53 100644 |
6380 |
+--- a/drivers/parisc/dino.c |
6381 |
++++ b/drivers/parisc/dino.c |
6382 |
+@@ -954,7 +954,7 @@ static int __init dino_probe(struct parisc_device *dev) |
6383 |
+ |
6384 |
+ dino_dev->hba.dev = dev; |
6385 |
+ dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096); |
6386 |
+- dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ |
6387 |
++ dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND; |
6388 |
+ spin_lock_init(&dino_dev->dinosaur_pen); |
6389 |
+ dino_dev->hba.iommu = ccio_get_iommu(dev); |
6390 |
+ |
6391 |
+diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c |
6392 |
+index 7d223e9080ef..77dddee2753a 100644 |
6393 |
+--- a/drivers/pci/hotplug/shpchp_hpc.c |
6394 |
++++ b/drivers/pci/hotplug/shpchp_hpc.c |
6395 |
+@@ -1062,6 +1062,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) |
6396 |
+ if (rc) { |
6397 |
+ ctrl_info(ctrl, "Can't get msi for the hotplug controller\n"); |
6398 |
+ ctrl_info(ctrl, "Use INTx for the hotplug controller\n"); |
6399 |
++ } else { |
6400 |
++ pci_set_master(pdev); |
6401 |
+ } |
6402 |
+ |
6403 |
+ rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, |
6404 |
+diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c |
6405 |
+index 5d7fbe4e907e..296889dc193f 100644 |
6406 |
+--- a/drivers/s390/scsi/zfcp_dbf.c |
6407 |
++++ b/drivers/s390/scsi/zfcp_dbf.c |
6408 |
+@@ -418,8 +418,8 @@ void zfcp_dbf_scsi(char *tag, struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf) |
6409 |
+ rec->scsi_retries = sc->retries; |
6410 |
+ rec->scsi_allowed = sc->allowed; |
6411 |
+ rec->scsi_id = sc->device->id; |
6412 |
+- /* struct zfcp_dbf_scsi needs to be updated to handle 64bit LUNs */ |
6413 |
+ rec->scsi_lun = (u32)sc->device->lun; |
6414 |
++ rec->scsi_lun_64_hi = (u32)(sc->device->lun >> 32); |
6415 |
+ rec->host_scribble = (unsigned long)sc->host_scribble; |
6416 |
+ |
6417 |
+ memcpy(rec->scsi_opcode, sc->cmnd, |
6418 |
+@@ -427,19 +427,32 @@ void zfcp_dbf_scsi(char *tag, struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf) |
6419 |
+ |
6420 |
+ if (fsf) { |
6421 |
+ rec->fsf_req_id = fsf->req_id; |
6422 |
++ rec->pl_len = FCP_RESP_WITH_EXT; |
6423 |
+ fcp_rsp = (struct fcp_resp_with_ext *) |
6424 |
+ &(fsf->qtcb->bottom.io.fcp_rsp); |
6425 |
++ /* mandatory parts of FCP_RSP IU in this SCSI record */ |
6426 |
+ memcpy(&rec->fcp_rsp, fcp_rsp, FCP_RESP_WITH_EXT); |
6427 |
+ if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) { |
6428 |
+ fcp_rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1]; |
6429 |
+ rec->fcp_rsp_info = fcp_rsp_info->rsp_code; |
6430 |
++ rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_rsp_len); |
6431 |
+ } |
6432 |
+ if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { |
6433 |
+- rec->pl_len = min((u16)SCSI_SENSE_BUFFERSIZE, |
6434 |
+- (u16)ZFCP_DBF_PAY_MAX_REC); |
6435 |
+- zfcp_dbf_pl_write(dbf, sc->sense_buffer, rec->pl_len, |
6436 |
+- "fcp_sns", fsf->req_id); |
6437 |
++ rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_sns_len); |
6438 |
+ } |
6439 |
++ /* complete FCP_RSP IU in associated PAYload record |
6440 |
++ * but only if there are optional parts |
6441 |
++ */ |
6442 |
++ if (fcp_rsp->resp.fr_flags != 0) |
6443 |
++ zfcp_dbf_pl_write( |
6444 |
++ dbf, fcp_rsp, |
6445 |
++ /* at least one full PAY record |
6446 |
++ * but not beyond hardware response field |
6447 |
++ */ |
6448 |
++ min_t(u16, max_t(u16, rec->pl_len, |
6449 |
++ ZFCP_DBF_PAY_MAX_REC), |
6450 |
++ FSF_FCP_RSP_SIZE), |
6451 |
++ "fcp_riu", fsf->req_id); |
6452 |
+ } |
6453 |
+ |
6454 |
+ debug_event(dbf->scsi, 1, rec, sizeof(*rec)); |
6455 |
+diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h |
6456 |
+index 0be3d48681ae..2039e7510a30 100644 |
6457 |
+--- a/drivers/s390/scsi/zfcp_dbf.h |
6458 |
++++ b/drivers/s390/scsi/zfcp_dbf.h |
6459 |
+@@ -196,7 +196,7 @@ enum zfcp_dbf_scsi_id { |
6460 |
+ * @id: unique number of recovery record type |
6461 |
+ * @tag: identifier string specifying the location of initiation |
6462 |
+ * @scsi_id: scsi device id |
6463 |
+- * @scsi_lun: scsi device logical unit number |
6464 |
++ * @scsi_lun: scsi device logical unit number, low part of 64 bit, old 32 bit |
6465 |
+ * @scsi_result: scsi result |
6466 |
+ * @scsi_retries: current retry number of scsi request |
6467 |
+ * @scsi_allowed: allowed retries |
6468 |
+@@ -206,6 +206,7 @@ enum zfcp_dbf_scsi_id { |
6469 |
+ * @host_scribble: LLD specific data attached to SCSI request |
6470 |
+ * @pl_len: length of paload stored as zfcp_dbf_pay |
6471 |
+ * @fsf_rsp: response for fsf request |
6472 |
++ * @scsi_lun_64_hi: scsi device logical unit number, high part of 64 bit |
6473 |
+ */ |
6474 |
+ struct zfcp_dbf_scsi { |
6475 |
+ u8 id; |
6476 |
+@@ -222,6 +223,7 @@ struct zfcp_dbf_scsi { |
6477 |
+ u64 host_scribble; |
6478 |
+ u16 pl_len; |
6479 |
+ struct fcp_resp_with_ext fcp_rsp; |
6480 |
++ u32 scsi_lun_64_hi; |
6481 |
+ } __packed; |
6482 |
+ |
6483 |
+ /** |
6484 |
+@@ -291,7 +293,11 @@ void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req) |
6485 |
+ { |
6486 |
+ struct fsf_qtcb *qtcb = req->qtcb; |
6487 |
+ |
6488 |
+- if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
6489 |
++ if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED | |
6490 |
++ ZFCP_STATUS_FSFREQ_ERROR))) { |
6491 |
++ zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req); |
6492 |
++ |
6493 |
++ } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
6494 |
+ (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { |
6495 |
+ zfcp_dbf_hba_fsf_resp("fs_perr", 1, req); |
6496 |
+ |
6497 |
+diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h |
6498 |
+index df2b541c8287..a2275825186f 100644 |
6499 |
+--- a/drivers/s390/scsi/zfcp_fc.h |
6500 |
++++ b/drivers/s390/scsi/zfcp_fc.h |
6501 |
+@@ -4,7 +4,7 @@ |
6502 |
+ * Fibre Channel related definitions and inline functions for the zfcp |
6503 |
+ * device driver |
6504 |
+ * |
6505 |
+- * Copyright IBM Corp. 2009 |
6506 |
++ * Copyright IBM Corp. 2009, 2017 |
6507 |
+ */ |
6508 |
+ |
6509 |
+ #ifndef ZFCP_FC_H |
6510 |
+@@ -279,6 +279,10 @@ void zfcp_fc_eval_fcp_rsp(struct fcp_resp_with_ext *fcp_rsp, |
6511 |
+ !(rsp_flags & FCP_SNS_LEN_VAL) && |
6512 |
+ fcp_rsp->resp.fr_status == SAM_STAT_GOOD) |
6513 |
+ set_host_byte(scsi, DID_ERROR); |
6514 |
++ } else if (unlikely(rsp_flags & FCP_RESID_OVER)) { |
6515 |
++ /* FCP_DL was not sufficient for SCSI data length */ |
6516 |
++ if (fcp_rsp->resp.fr_status == SAM_STAT_GOOD) |
6517 |
++ set_host_byte(scsi, DID_ERROR); |
6518 |
+ } |
6519 |
+ } |
6520 |
+ |
6521 |
+diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c |
6522 |
+index 21ec5e2f584c..7d77c318cc16 100644 |
6523 |
+--- a/drivers/s390/scsi/zfcp_fsf.c |
6524 |
++++ b/drivers/s390/scsi/zfcp_fsf.c |
6525 |
+@@ -2246,7 +2246,8 @@ int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd) |
6526 |
+ fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
6527 |
+ zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd, 0); |
6528 |
+ |
6529 |
+- if (scsi_prot_sg_count(scsi_cmnd)) { |
6530 |
++ if ((scsi_get_prot_op(scsi_cmnd) != SCSI_PROT_NORMAL) && |
6531 |
++ scsi_prot_sg_count(scsi_cmnd)) { |
6532 |
+ zfcp_qdio_set_data_div(qdio, &req->qdio_req, |
6533 |
+ scsi_prot_sg_count(scsi_cmnd)); |
6534 |
+ retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, |
6535 |
+diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c |
6536 |
+index 75f4bfc2b98a..6de09147e791 100644 |
6537 |
+--- a/drivers/s390/scsi/zfcp_scsi.c |
6538 |
++++ b/drivers/s390/scsi/zfcp_scsi.c |
6539 |
+@@ -224,8 +224,10 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) |
6540 |
+ |
6541 |
+ zfcp_erp_wait(adapter); |
6542 |
+ ret = fc_block_scsi_eh(scpnt); |
6543 |
+- if (ret) |
6544 |
++ if (ret) { |
6545 |
++ zfcp_dbf_scsi_devreset("fiof", scpnt, tm_flags, NULL); |
6546 |
+ return ret; |
6547 |
++ } |
6548 |
+ |
6549 |
+ if (!(atomic_read(&adapter->status) & |
6550 |
+ ZFCP_STATUS_COMMON_RUNNING)) { |
6551 |
+@@ -233,8 +235,10 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) |
6552 |
+ return SUCCESS; |
6553 |
+ } |
6554 |
+ } |
6555 |
+- if (!fsf_req) |
6556 |
++ if (!fsf_req) { |
6557 |
++ zfcp_dbf_scsi_devreset("reqf", scpnt, tm_flags, NULL); |
6558 |
+ return FAILED; |
6559 |
++ } |
6560 |
+ |
6561 |
+ wait_for_completion(&fsf_req->completion); |
6562 |
+ |
6563 |
+diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c |
6564 |
+index 1910100638a2..00602abec0ea 100644 |
6565 |
+--- a/drivers/scsi/isci/remote_node_context.c |
6566 |
++++ b/drivers/scsi/isci/remote_node_context.c |
6567 |
+@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state) |
6568 |
+ { |
6569 |
+ static const char * const strings[] = RNC_STATES; |
6570 |
+ |
6571 |
++ if (state >= ARRAY_SIZE(strings)) |
6572 |
++ return "UNKNOWN"; |
6573 |
++ |
6574 |
+ return strings[state]; |
6575 |
+ } |
6576 |
+ #undef C |
6577 |
+diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c |
6578 |
+index 0e5b3584e918..4da8963315c7 100644 |
6579 |
+--- a/drivers/scsi/lpfc/lpfc_els.c |
6580 |
++++ b/drivers/scsi/lpfc/lpfc_els.c |
6581 |
+@@ -1068,7 +1068,10 @@ stop_rr_fcf_flogi: |
6582 |
+ lpfc_sli4_unreg_all_rpis(vport); |
6583 |
+ } |
6584 |
+ } |
6585 |
+- lpfc_issue_reg_vfi(vport); |
6586 |
++ |
6587 |
++ /* Do not register VFI if the driver aborted FLOGI */ |
6588 |
++ if (!lpfc_error_lost_link(irsp)) |
6589 |
++ lpfc_issue_reg_vfi(vport); |
6590 |
+ lpfc_nlp_put(ndlp); |
6591 |
+ goto out; |
6592 |
+ } |
6593 |
+diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c |
6594 |
+index a991690167aa..b66a7a6a601d 100644 |
6595 |
+--- a/drivers/scsi/megaraid/megaraid_sas_base.c |
6596 |
++++ b/drivers/scsi/megaraid/megaraid_sas_base.c |
6597 |
+@@ -1709,9 +1709,12 @@ void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) |
6598 |
+ if (cmd_fusion->sync_cmd_idx != (u32)ULONG_MAX) { |
6599 |
+ cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; |
6600 |
+ if (cmd_mfi->sync_cmd && |
6601 |
+- cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT) |
6602 |
++ (cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT)) { |
6603 |
++ cmd_mfi->frame->hdr.cmd_status = |
6604 |
++ MFI_STAT_WRONG_STATE; |
6605 |
+ megasas_complete_cmd(instance, |
6606 |
+ cmd_mfi, DID_OK); |
6607 |
++ } |
6608 |
+ } |
6609 |
+ } |
6610 |
+ } else { |
6611 |
+diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c |
6612 |
+index c1b2e86839ae..e9cd3013dcd0 100644 |
6613 |
+--- a/drivers/scsi/qla2xxx/qla_attr.c |
6614 |
++++ b/drivers/scsi/qla2xxx/qla_attr.c |
6615 |
+@@ -404,6 +404,8 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
6616 |
+ return -EINVAL; |
6617 |
+ if (start > ha->optrom_size) |
6618 |
+ return -EINVAL; |
6619 |
++ if (size > ha->optrom_size - start) |
6620 |
++ size = ha->optrom_size - start; |
6621 |
+ |
6622 |
+ mutex_lock(&ha->optrom_mutex); |
6623 |
+ switch (val) { |
6624 |
+@@ -429,8 +431,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
6625 |
+ } |
6626 |
+ |
6627 |
+ ha->optrom_region_start = start; |
6628 |
+- ha->optrom_region_size = start + size > ha->optrom_size ? |
6629 |
+- ha->optrom_size - start : size; |
6630 |
++ ha->optrom_region_size = start + size; |
6631 |
+ |
6632 |
+ ha->optrom_state = QLA_SREADING; |
6633 |
+ ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
6634 |
+@@ -503,8 +504,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
6635 |
+ } |
6636 |
+ |
6637 |
+ ha->optrom_region_start = start; |
6638 |
+- ha->optrom_region_size = start + size > ha->optrom_size ? |
6639 |
+- ha->optrom_size - start : size; |
6640 |
++ ha->optrom_region_size = start + size; |
6641 |
+ |
6642 |
+ ha->optrom_state = QLA_SWRITING; |
6643 |
+ ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
6644 |
+diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c |
6645 |
+index c94191369452..fbdba7925723 100644 |
6646 |
+--- a/drivers/scsi/sg.c |
6647 |
++++ b/drivers/scsi/sg.c |
6648 |
+@@ -133,7 +133,7 @@ struct sg_device; /* forward declarations */ |
6649 |
+ struct sg_fd; |
6650 |
+ |
6651 |
+ typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */ |
6652 |
+- struct sg_request *nextrp; /* NULL -> tail request (slist) */ |
6653 |
++ struct list_head entry; /* list entry */ |
6654 |
+ struct sg_fd *parentfp; /* NULL -> not in use */ |
6655 |
+ Sg_scatter_hold data; /* hold buffer, perhaps scatter list */ |
6656 |
+ sg_io_hdr_t header; /* scsi command+info, see <scsi/sg.h> */ |
6657 |
+@@ -153,11 +153,11 @@ typedef struct sg_fd { /* holds the state of a file descriptor */ |
6658 |
+ struct sg_device *parentdp; /* owning device */ |
6659 |
+ wait_queue_head_t read_wait; /* queue read until command done */ |
6660 |
+ rwlock_t rq_list_lock; /* protect access to list in req_arr */ |
6661 |
++ struct mutex f_mutex; /* protect against changes in this fd */ |
6662 |
+ int timeout; /* defaults to SG_DEFAULT_TIMEOUT */ |
6663 |
+ int timeout_user; /* defaults to SG_DEFAULT_TIMEOUT_USER */ |
6664 |
+ Sg_scatter_hold reserve; /* buffer held for this file descriptor */ |
6665 |
+- unsigned save_scat_len; /* original length of trunc. scat. element */ |
6666 |
+- Sg_request *headrp; /* head of request slist, NULL->empty */ |
6667 |
++ struct list_head rq_list; /* head of request list */ |
6668 |
+ struct fasync_struct *async_qp; /* used by asynchronous notification */ |
6669 |
+ Sg_request req_arr[SG_MAX_QUEUE]; /* used as singly-linked list */ |
6670 |
+ char low_dma; /* as in parent but possibly overridden to 1 */ |
6671 |
+@@ -166,6 +166,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */ |
6672 |
+ unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */ |
6673 |
+ char keep_orphan; /* 0 -> drop orphan (def), 1 -> keep for read() */ |
6674 |
+ char mmap_called; /* 0 -> mmap() never called on this fd */ |
6675 |
++ char res_in_use; /* 1 -> 'reserve' array in use */ |
6676 |
+ struct kref f_ref; |
6677 |
+ struct execute_work ew; |
6678 |
+ } Sg_fd; |
6679 |
+@@ -209,7 +210,6 @@ static void sg_remove_sfp(struct kref *); |
6680 |
+ static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); |
6681 |
+ static Sg_request *sg_add_request(Sg_fd * sfp); |
6682 |
+ static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); |
6683 |
+-static int sg_res_in_use(Sg_fd * sfp); |
6684 |
+ static Sg_device *sg_get_dev(int dev); |
6685 |
+ static void sg_device_destroy(struct kref *kref); |
6686 |
+ |
6687 |
+@@ -625,6 +625,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) |
6688 |
+ } |
6689 |
+ buf += SZ_SG_HEADER; |
6690 |
+ __get_user(opcode, buf); |
6691 |
++ mutex_lock(&sfp->f_mutex); |
6692 |
+ if (sfp->next_cmd_len > 0) { |
6693 |
+ cmd_size = sfp->next_cmd_len; |
6694 |
+ sfp->next_cmd_len = 0; /* reset so only this write() effected */ |
6695 |
+@@ -633,6 +634,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) |
6696 |
+ if ((opcode >= 0xc0) && old_hdr.twelve_byte) |
6697 |
+ cmd_size = 12; |
6698 |
+ } |
6699 |
++ mutex_unlock(&sfp->f_mutex); |
6700 |
+ SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp, |
6701 |
+ "sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size)); |
6702 |
+ /* Determine buffer size. */ |
6703 |
+@@ -732,7 +734,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, |
6704 |
+ sg_remove_request(sfp, srp); |
6705 |
+ return -EINVAL; /* either MMAP_IO or DIRECT_IO (not both) */ |
6706 |
+ } |
6707 |
+- if (sg_res_in_use(sfp)) { |
6708 |
++ if (sfp->res_in_use) { |
6709 |
+ sg_remove_request(sfp, srp); |
6710 |
+ return -EBUSY; /* reserve buffer already being used */ |
6711 |
+ } |
6712 |
+@@ -831,6 +833,39 @@ static int max_sectors_bytes(struct request_queue *q) |
6713 |
+ return max_sectors << 9; |
6714 |
+ } |
6715 |
+ |
6716 |
++static void |
6717 |
++sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo) |
6718 |
++{ |
6719 |
++ Sg_request *srp; |
6720 |
++ int val; |
6721 |
++ unsigned int ms; |
6722 |
++ |
6723 |
++ val = 0; |
6724 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
6725 |
++ if (val > SG_MAX_QUEUE) |
6726 |
++ break; |
6727 |
++ rinfo[val].req_state = srp->done + 1; |
6728 |
++ rinfo[val].problem = |
6729 |
++ srp->header.masked_status & |
6730 |
++ srp->header.host_status & |
6731 |
++ srp->header.driver_status; |
6732 |
++ if (srp->done) |
6733 |
++ rinfo[val].duration = |
6734 |
++ srp->header.duration; |
6735 |
++ else { |
6736 |
++ ms = jiffies_to_msecs(jiffies); |
6737 |
++ rinfo[val].duration = |
6738 |
++ (ms > srp->header.duration) ? |
6739 |
++ (ms - srp->header.duration) : 0; |
6740 |
++ } |
6741 |
++ rinfo[val].orphan = srp->orphan; |
6742 |
++ rinfo[val].sg_io_owned = srp->sg_io_owned; |
6743 |
++ rinfo[val].pack_id = srp->header.pack_id; |
6744 |
++ rinfo[val].usr_ptr = srp->header.usr_ptr; |
6745 |
++ val++; |
6746 |
++ } |
6747 |
++} |
6748 |
++ |
6749 |
+ static long |
6750 |
+ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6751 |
+ { |
6752 |
+@@ -896,7 +931,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6753 |
+ return result; |
6754 |
+ if (val) { |
6755 |
+ sfp->low_dma = 1; |
6756 |
+- if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) { |
6757 |
++ if ((0 == sfp->low_dma) && !sfp->res_in_use) { |
6758 |
+ val = (int) sfp->reserve.bufflen; |
6759 |
+ sg_remove_scat(sfp, &sfp->reserve); |
6760 |
+ sg_build_reserve(sfp, val); |
6761 |
+@@ -942,7 +977,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6762 |
+ if (!access_ok(VERIFY_WRITE, ip, sizeof (int))) |
6763 |
+ return -EFAULT; |
6764 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
6765 |
+- for (srp = sfp->headrp; srp; srp = srp->nextrp) { |
6766 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
6767 |
+ if ((1 == srp->done) && (!srp->sg_io_owned)) { |
6768 |
+ read_unlock_irqrestore(&sfp->rq_list_lock, |
6769 |
+ iflags); |
6770 |
+@@ -955,7 +990,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6771 |
+ return 0; |
6772 |
+ case SG_GET_NUM_WAITING: |
6773 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
6774 |
+- for (val = 0, srp = sfp->headrp; srp; srp = srp->nextrp) { |
6775 |
++ val = 0; |
6776 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
6777 |
+ if ((1 == srp->done) && (!srp->sg_io_owned)) |
6778 |
+ ++val; |
6779 |
+ } |
6780 |
+@@ -971,12 +1007,18 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6781 |
+ return -EINVAL; |
6782 |
+ val = min_t(int, val, |
6783 |
+ max_sectors_bytes(sdp->device->request_queue)); |
6784 |
++ mutex_lock(&sfp->f_mutex); |
6785 |
+ if (val != sfp->reserve.bufflen) { |
6786 |
+- if (sg_res_in_use(sfp) || sfp->mmap_called) |
6787 |
++ if (sfp->mmap_called || |
6788 |
++ sfp->res_in_use) { |
6789 |
++ mutex_unlock(&sfp->f_mutex); |
6790 |
+ return -EBUSY; |
6791 |
++ } |
6792 |
++ |
6793 |
+ sg_remove_scat(sfp, &sfp->reserve); |
6794 |
+ sg_build_reserve(sfp, val); |
6795 |
+ } |
6796 |
++ mutex_unlock(&sfp->f_mutex); |
6797 |
+ return 0; |
6798 |
+ case SG_GET_RESERVED_SIZE: |
6799 |
+ val = min_t(int, sfp->reserve.bufflen, |
6800 |
+@@ -1017,42 +1059,15 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
6801 |
+ return -EFAULT; |
6802 |
+ else { |
6803 |
+ sg_req_info_t *rinfo; |
6804 |
+- unsigned int ms; |
6805 |
+ |
6806 |
+- rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, |
6807 |
+- GFP_KERNEL); |
6808 |
++ rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, |
6809 |
++ GFP_KERNEL); |
6810 |
+ if (!rinfo) |
6811 |
+ return -ENOMEM; |
6812 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
6813 |
+- for (srp = sfp->headrp, val = 0; val < SG_MAX_QUEUE; |
6814 |
+- ++val, srp = srp ? srp->nextrp : srp) { |
6815 |
+- memset(&rinfo[val], 0, SZ_SG_REQ_INFO); |
6816 |
+- if (srp) { |
6817 |
+- rinfo[val].req_state = srp->done + 1; |
6818 |
+- rinfo[val].problem = |
6819 |
+- srp->header.masked_status & |
6820 |
+- srp->header.host_status & |
6821 |
+- srp->header.driver_status; |
6822 |
+- if (srp->done) |
6823 |
+- rinfo[val].duration = |
6824 |
+- srp->header.duration; |
6825 |
+- else { |
6826 |
+- ms = jiffies_to_msecs(jiffies); |
6827 |
+- rinfo[val].duration = |
6828 |
+- (ms > srp->header.duration) ? |
6829 |
+- (ms - srp->header.duration) : 0; |
6830 |
+- } |
6831 |
+- rinfo[val].orphan = srp->orphan; |
6832 |
+- rinfo[val].sg_io_owned = |
6833 |
+- srp->sg_io_owned; |
6834 |
+- rinfo[val].pack_id = |
6835 |
+- srp->header.pack_id; |
6836 |
+- rinfo[val].usr_ptr = |
6837 |
+- srp->header.usr_ptr; |
6838 |
+- } |
6839 |
+- } |
6840 |
++ sg_fill_request_table(sfp, rinfo); |
6841 |
+ read_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
6842 |
+- result = __copy_to_user(p, rinfo, |
6843 |
++ result = __copy_to_user(p, rinfo, |
6844 |
+ SZ_SG_REQ_INFO * SG_MAX_QUEUE); |
6845 |
+ result = result ? -EFAULT : 0; |
6846 |
+ kfree(rinfo); |
6847 |
+@@ -1158,7 +1173,7 @@ sg_poll(struct file *filp, poll_table * wait) |
6848 |
+ return POLLERR; |
6849 |
+ poll_wait(filp, &sfp->read_wait, wait); |
6850 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
6851 |
+- for (srp = sfp->headrp; srp; srp = srp->nextrp) { |
6852 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
6853 |
+ /* if any read waiting, flag it */ |
6854 |
+ if ((0 == res) && (1 == srp->done) && (!srp->sg_io_owned)) |
6855 |
+ res = POLLIN | POLLRDNORM; |
6856 |
+@@ -1239,6 +1254,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) |
6857 |
+ unsigned long req_sz, len, sa; |
6858 |
+ Sg_scatter_hold *rsv_schp; |
6859 |
+ int k, length; |
6860 |
++ int ret = 0; |
6861 |
+ |
6862 |
+ if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) |
6863 |
+ return -ENXIO; |
6864 |
+@@ -1249,8 +1265,11 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) |
6865 |
+ if (vma->vm_pgoff) |
6866 |
+ return -EINVAL; /* want no offset */ |
6867 |
+ rsv_schp = &sfp->reserve; |
6868 |
+- if (req_sz > rsv_schp->bufflen) |
6869 |
+- return -ENOMEM; /* cannot map more than reserved buffer */ |
6870 |
++ mutex_lock(&sfp->f_mutex); |
6871 |
++ if (req_sz > rsv_schp->bufflen) { |
6872 |
++ ret = -ENOMEM; /* cannot map more than reserved buffer */ |
6873 |
++ goto out; |
6874 |
++ } |
6875 |
+ |
6876 |
+ sa = vma->vm_start; |
6877 |
+ length = 1 << (PAGE_SHIFT + rsv_schp->page_order); |
6878 |
+@@ -1264,7 +1283,9 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) |
6879 |
+ vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP; |
6880 |
+ vma->vm_private_data = sfp; |
6881 |
+ vma->vm_ops = &sg_mmap_vm_ops; |
6882 |
+- return 0; |
6883 |
++out: |
6884 |
++ mutex_unlock(&sfp->f_mutex); |
6885 |
++ return ret; |
6886 |
+ } |
6887 |
+ |
6888 |
+ static void |
6889 |
+@@ -1731,13 +1752,25 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) |
6890 |
+ md = &map_data; |
6891 |
+ |
6892 |
+ if (md) { |
6893 |
+- if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen) |
6894 |
++ mutex_lock(&sfp->f_mutex); |
6895 |
++ if (dxfer_len <= rsv_schp->bufflen && |
6896 |
++ !sfp->res_in_use) { |
6897 |
++ sfp->res_in_use = 1; |
6898 |
+ sg_link_reserve(sfp, srp, dxfer_len); |
6899 |
+- else { |
6900 |
++ } else if (hp->flags & SG_FLAG_MMAP_IO) { |
6901 |
++ res = -EBUSY; /* sfp->res_in_use == 1 */ |
6902 |
++ if (dxfer_len > rsv_schp->bufflen) |
6903 |
++ res = -ENOMEM; |
6904 |
++ mutex_unlock(&sfp->f_mutex); |
6905 |
++ return res; |
6906 |
++ } else { |
6907 |
+ res = sg_build_indirect(req_schp, sfp, dxfer_len); |
6908 |
+- if (res) |
6909 |
++ if (res) { |
6910 |
++ mutex_unlock(&sfp->f_mutex); |
6911 |
+ return res; |
6912 |
++ } |
6913 |
+ } |
6914 |
++ mutex_unlock(&sfp->f_mutex); |
6915 |
+ |
6916 |
+ md->pages = req_schp->pages; |
6917 |
+ md->page_order = req_schp->page_order; |
6918 |
+@@ -2026,8 +2059,9 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) |
6919 |
+ req_schp->pages = NULL; |
6920 |
+ req_schp->page_order = 0; |
6921 |
+ req_schp->sglist_len = 0; |
6922 |
+- sfp->save_scat_len = 0; |
6923 |
+ srp->res_used = 0; |
6924 |
++ /* Called without mutex lock to avoid deadlock */ |
6925 |
++ sfp->res_in_use = 0; |
6926 |
+ } |
6927 |
+ |
6928 |
+ static Sg_request * |
6929 |
+@@ -2037,7 +2071,7 @@ sg_get_rq_mark(Sg_fd * sfp, int pack_id) |
6930 |
+ unsigned long iflags; |
6931 |
+ |
6932 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
6933 |
+- for (resp = sfp->headrp; resp; resp = resp->nextrp) { |
6934 |
++ list_for_each_entry(resp, &sfp->rq_list, entry) { |
6935 |
+ /* look for requests that are ready + not SG_IO owned */ |
6936 |
+ if ((1 == resp->done) && (!resp->sg_io_owned) && |
6937 |
+ ((-1 == pack_id) || (resp->header.pack_id == pack_id))) { |
6938 |
+@@ -2055,70 +2089,45 @@ sg_add_request(Sg_fd * sfp) |
6939 |
+ { |
6940 |
+ int k; |
6941 |
+ unsigned long iflags; |
6942 |
+- Sg_request *resp; |
6943 |
+ Sg_request *rp = sfp->req_arr; |
6944 |
+ |
6945 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
6946 |
+- resp = sfp->headrp; |
6947 |
+- if (!resp) { |
6948 |
+- memset(rp, 0, sizeof (Sg_request)); |
6949 |
+- rp->parentfp = sfp; |
6950 |
+- resp = rp; |
6951 |
+- sfp->headrp = resp; |
6952 |
+- } else { |
6953 |
+- if (0 == sfp->cmd_q) |
6954 |
+- resp = NULL; /* command queuing disallowed */ |
6955 |
+- else { |
6956 |
+- for (k = 0; k < SG_MAX_QUEUE; ++k, ++rp) { |
6957 |
+- if (!rp->parentfp) |
6958 |
+- break; |
6959 |
+- } |
6960 |
+- if (k < SG_MAX_QUEUE) { |
6961 |
+- memset(rp, 0, sizeof (Sg_request)); |
6962 |
+- rp->parentfp = sfp; |
6963 |
+- while (resp->nextrp) |
6964 |
+- resp = resp->nextrp; |
6965 |
+- resp->nextrp = rp; |
6966 |
+- resp = rp; |
6967 |
+- } else |
6968 |
+- resp = NULL; |
6969 |
++ if (!list_empty(&sfp->rq_list)) { |
6970 |
++ if (!sfp->cmd_q) |
6971 |
++ goto out_unlock; |
6972 |
++ |
6973 |
++ for (k = 0; k < SG_MAX_QUEUE; ++k, ++rp) { |
6974 |
++ if (!rp->parentfp) |
6975 |
++ break; |
6976 |
+ } |
6977 |
++ if (k >= SG_MAX_QUEUE) |
6978 |
++ goto out_unlock; |
6979 |
+ } |
6980 |
+- if (resp) { |
6981 |
+- resp->nextrp = NULL; |
6982 |
+- resp->header.duration = jiffies_to_msecs(jiffies); |
6983 |
+- } |
6984 |
++ memset(rp, 0, sizeof (Sg_request)); |
6985 |
++ rp->parentfp = sfp; |
6986 |
++ rp->header.duration = jiffies_to_msecs(jiffies); |
6987 |
++ list_add_tail(&rp->entry, &sfp->rq_list); |
6988 |
+ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
6989 |
+- return resp; |
6990 |
++ return rp; |
6991 |
++out_unlock: |
6992 |
++ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
6993 |
++ return NULL; |
6994 |
+ } |
6995 |
+ |
6996 |
+ /* Return of 1 for found; 0 for not found */ |
6997 |
+ static int |
6998 |
+ sg_remove_request(Sg_fd * sfp, Sg_request * srp) |
6999 |
+ { |
7000 |
+- Sg_request *prev_rp; |
7001 |
+- Sg_request *rp; |
7002 |
+ unsigned long iflags; |
7003 |
+ int res = 0; |
7004 |
+ |
7005 |
+- if ((!sfp) || (!srp) || (!sfp->headrp)) |
7006 |
++ if (!sfp || !srp || list_empty(&sfp->rq_list)) |
7007 |
+ return res; |
7008 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
7009 |
+- prev_rp = sfp->headrp; |
7010 |
+- if (srp == prev_rp) { |
7011 |
+- sfp->headrp = prev_rp->nextrp; |
7012 |
+- prev_rp->parentfp = NULL; |
7013 |
++ if (!list_empty(&srp->entry)) { |
7014 |
++ list_del(&srp->entry); |
7015 |
++ srp->parentfp = NULL; |
7016 |
+ res = 1; |
7017 |
+- } else { |
7018 |
+- while ((rp = prev_rp->nextrp)) { |
7019 |
+- if (srp == rp) { |
7020 |
+- prev_rp->nextrp = rp->nextrp; |
7021 |
+- rp->parentfp = NULL; |
7022 |
+- res = 1; |
7023 |
+- break; |
7024 |
+- } |
7025 |
+- prev_rp = rp; |
7026 |
+- } |
7027 |
+ } |
7028 |
+ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
7029 |
+ return res; |
7030 |
+@@ -2137,8 +2146,9 @@ sg_add_sfp(Sg_device * sdp) |
7031 |
+ |
7032 |
+ init_waitqueue_head(&sfp->read_wait); |
7033 |
+ rwlock_init(&sfp->rq_list_lock); |
7034 |
+- |
7035 |
++ INIT_LIST_HEAD(&sfp->rq_list); |
7036 |
+ kref_init(&sfp->f_ref); |
7037 |
++ mutex_init(&sfp->f_mutex); |
7038 |
+ sfp->timeout = SG_DEFAULT_TIMEOUT; |
7039 |
+ sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER; |
7040 |
+ sfp->force_packid = SG_DEF_FORCE_PACK_ID; |
7041 |
+@@ -2177,10 +2187,13 @@ sg_remove_sfp_usercontext(struct work_struct *work) |
7042 |
+ { |
7043 |
+ struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work); |
7044 |
+ struct sg_device *sdp = sfp->parentdp; |
7045 |
++ Sg_request *srp; |
7046 |
+ |
7047 |
+ /* Cleanup any responses which were never read(). */ |
7048 |
+- while (sfp->headrp) |
7049 |
+- sg_finish_rem_req(sfp->headrp); |
7050 |
++ while (!list_empty(&sfp->rq_list)) { |
7051 |
++ srp = list_first_entry(&sfp->rq_list, Sg_request, entry); |
7052 |
++ sg_finish_rem_req(srp); |
7053 |
++ } |
7054 |
+ |
7055 |
+ if (sfp->reserve.bufflen > 0) { |
7056 |
+ SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp, |
7057 |
+@@ -2214,20 +2227,6 @@ sg_remove_sfp(struct kref *kref) |
7058 |
+ schedule_work(&sfp->ew.work); |
7059 |
+ } |
7060 |
+ |
7061 |
+-static int |
7062 |
+-sg_res_in_use(Sg_fd * sfp) |
7063 |
+-{ |
7064 |
+- const Sg_request *srp; |
7065 |
+- unsigned long iflags; |
7066 |
+- |
7067 |
+- read_lock_irqsave(&sfp->rq_list_lock, iflags); |
7068 |
+- for (srp = sfp->headrp; srp; srp = srp->nextrp) |
7069 |
+- if (srp->res_used) |
7070 |
+- break; |
7071 |
+- read_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
7072 |
+- return srp ? 1 : 0; |
7073 |
+-} |
7074 |
+- |
7075 |
+ #ifdef CONFIG_SCSI_PROC_FS |
7076 |
+ static int |
7077 |
+ sg_idr_max_id(int id, void *p, void *data) |
7078 |
+@@ -2597,7 +2596,7 @@ static int sg_proc_seq_show_devstrs(struct seq_file *s, void *v) |
7079 |
+ /* must be called while holding sg_index_lock */ |
7080 |
+ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
7081 |
+ { |
7082 |
+- int k, m, new_interface, blen, usg; |
7083 |
++ int k, new_interface, blen, usg; |
7084 |
+ Sg_request *srp; |
7085 |
+ Sg_fd *fp; |
7086 |
+ const sg_io_hdr_t *hp; |
7087 |
+@@ -2617,13 +2616,11 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
7088 |
+ seq_printf(s, " cmd_q=%d f_packid=%d k_orphan=%d closed=0\n", |
7089 |
+ (int) fp->cmd_q, (int) fp->force_packid, |
7090 |
+ (int) fp->keep_orphan); |
7091 |
+- for (m = 0, srp = fp->headrp; |
7092 |
+- srp != NULL; |
7093 |
+- ++m, srp = srp->nextrp) { |
7094 |
++ list_for_each_entry(srp, &fp->rq_list, entry) { |
7095 |
+ hp = &srp->header; |
7096 |
+ new_interface = (hp->interface_id == '\0') ? 0 : 1; |
7097 |
+ if (srp->res_used) { |
7098 |
+- if (new_interface && |
7099 |
++ if (new_interface && |
7100 |
+ (SG_FLAG_MMAP_IO & hp->flags)) |
7101 |
+ cp = " mmap>> "; |
7102 |
+ else |
7103 |
+@@ -2654,7 +2651,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
7104 |
+ seq_printf(s, "ms sgat=%d op=0x%02x\n", usg, |
7105 |
+ (int) srp->data.cmd_opcode); |
7106 |
+ } |
7107 |
+- if (0 == m) |
7108 |
++ if (list_empty(&fp->rq_list)) |
7109 |
+ seq_puts(s, " No requests active\n"); |
7110 |
+ read_unlock(&fp->rq_list_lock); |
7111 |
+ } |
7112 |
+diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c |
7113 |
+index 6c52d1411a73..51a0cc047b5f 100644 |
7114 |
+--- a/drivers/scsi/storvsc_drv.c |
7115 |
++++ b/drivers/scsi/storvsc_drv.c |
7116 |
+@@ -1699,6 +1699,8 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) |
7117 |
+ ret = storvsc_do_io(dev, cmd_request); |
7118 |
+ |
7119 |
+ if (ret == -EAGAIN) { |
7120 |
++ if (payload_sz > sizeof(cmd_request->mpb)) |
7121 |
++ kfree(payload); |
7122 |
+ /* no more space */ |
7123 |
+ |
7124 |
+ if (cmd_request->bounce_sgl_count) |
7125 |
+diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
7126 |
+index 4273e34ff3ea..9af6ce2b6782 100644 |
7127 |
+--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
7128 |
++++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c |
7129 |
+@@ -50,6 +50,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = { |
7130 |
+ {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ |
7131 |
+ {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ |
7132 |
+ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ |
7133 |
++ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ |
7134 |
+ {} /* Terminating entry */ |
7135 |
+ }; |
7136 |
+ |
7137 |
+diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c |
7138 |
+index 8a5d6a8e780f..ba32ac8d1747 100644 |
7139 |
+--- a/drivers/staging/rts5208/rtsx_scsi.c |
7140 |
++++ b/drivers/staging/rts5208/rtsx_scsi.c |
7141 |
+@@ -414,7 +414,7 @@ void set_sense_data(struct rtsx_chip *chip, unsigned int lun, u8 err_code, |
7142 |
+ sense->ascq = ascq; |
7143 |
+ if (sns_key_info0 != 0) { |
7144 |
+ sense->sns_key_info[0] = SKSV | sns_key_info0; |
7145 |
+- sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 8; |
7146 |
++ sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 4; |
7147 |
+ sense->sns_key_info[2] = sns_key_info1 & 0x0f; |
7148 |
+ } |
7149 |
+ } |
7150 |
+diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c |
7151 |
+index aa9fad4f35b9..25c15910af77 100644 |
7152 |
+--- a/drivers/tty/tty_buffer.c |
7153 |
++++ b/drivers/tty/tty_buffer.c |
7154 |
+@@ -355,6 +355,32 @@ int tty_insert_flip_string_flags(struct tty_port *port, |
7155 |
+ } |
7156 |
+ EXPORT_SYMBOL(tty_insert_flip_string_flags); |
7157 |
+ |
7158 |
++/** |
7159 |
++ * __tty_insert_flip_char - Add one character to the tty buffer |
7160 |
++ * @port: tty port |
7161 |
++ * @ch: character |
7162 |
++ * @flag: flag byte |
7163 |
++ * |
7164 |
++ * Queue a single byte to the tty buffering, with an optional flag. |
7165 |
++ * This is the slow path of tty_insert_flip_char. |
7166 |
++ */ |
7167 |
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) |
7168 |
++{ |
7169 |
++ struct tty_buffer *tb; |
7170 |
++ int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; |
7171 |
++ |
7172 |
++ if (!__tty_buffer_request_room(port, 1, flags)) |
7173 |
++ return 0; |
7174 |
++ |
7175 |
++ tb = port->buf.tail; |
7176 |
++ if (~tb->flags & TTYB_NORMAL) |
7177 |
++ *flag_buf_ptr(tb, tb->used) = flag; |
7178 |
++ *char_buf_ptr(tb, tb->used++) = ch; |
7179 |
++ |
7180 |
++ return 1; |
7181 |
++} |
7182 |
++EXPORT_SYMBOL(__tty_insert_flip_char); |
7183 |
++ |
7184 |
+ /** |
7185 |
+ * tty_schedule_flip - push characters to ldisc |
7186 |
+ * @port: tty port to push from |
7187 |
+diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c |
7188 |
+index eb8fdc75843b..a235e9ab932c 100644 |
7189 |
+--- a/drivers/usb/core/devio.c |
7190 |
++++ b/drivers/usb/core/devio.c |
7191 |
+@@ -519,6 +519,8 @@ static void async_completed(struct urb *urb) |
7192 |
+ if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && |
7193 |
+ as->status != -ENOENT) |
7194 |
+ cancel_bulk_urbs(ps, as->bulk_addr); |
7195 |
++ |
7196 |
++ wake_up(&ps->wait); |
7197 |
+ spin_unlock(&ps->lock); |
7198 |
+ |
7199 |
+ if (signr) { |
7200 |
+@@ -526,8 +528,6 @@ static void async_completed(struct urb *urb) |
7201 |
+ put_pid(pid); |
7202 |
+ put_cred(cred); |
7203 |
+ } |
7204 |
+- |
7205 |
+- wake_up(&ps->wait); |
7206 |
+ } |
7207 |
+ |
7208 |
+ static void destroy_async(struct usb_dev_state *ps, struct list_head *list) |
7209 |
+diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c |
7210 |
+index 574da2b4529c..82806e311202 100644 |
7211 |
+--- a/drivers/usb/core/quirks.c |
7212 |
++++ b/drivers/usb/core/quirks.c |
7213 |
+@@ -57,8 +57,9 @@ static const struct usb_device_id usb_quirk_list[] = { |
7214 |
+ /* Microsoft LifeCam-VX700 v2.0 */ |
7215 |
+ { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, |
7216 |
+ |
7217 |
+- /* Logitech HD Pro Webcams C920 and C930e */ |
7218 |
++ /* Logitech HD Pro Webcams C920, C920-C and C930e */ |
7219 |
+ { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, |
7220 |
++ { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, |
7221 |
+ { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, |
7222 |
+ |
7223 |
+ /* Logitech ConferenceCam CC3000e */ |
7224 |
+@@ -217,6 +218,9 @@ static const struct usb_device_id usb_quirk_list[] = { |
7225 |
+ { USB_DEVICE(0x1a0a, 0x0200), .driver_info = |
7226 |
+ USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, |
7227 |
+ |
7228 |
++ /* Corsair Strafe RGB */ |
7229 |
++ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, |
7230 |
++ |
7231 |
+ /* Acer C120 LED Projector */ |
7232 |
+ { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, |
7233 |
+ |
7234 |
+diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c |
7235 |
+index 2776cfe64c09..ef9cf4a21afe 100644 |
7236 |
+--- a/drivers/usb/core/usb-acpi.c |
7237 |
++++ b/drivers/usb/core/usb-acpi.c |
7238 |
+@@ -127,6 +127,22 @@ out: |
7239 |
+ */ |
7240 |
+ #define USB_ACPI_LOCATION_VALID (1 << 31) |
7241 |
+ |
7242 |
++static struct acpi_device *usb_acpi_find_port(struct acpi_device *parent, |
7243 |
++ int raw) |
7244 |
++{ |
7245 |
++ struct acpi_device *adev; |
7246 |
++ |
7247 |
++ if (!parent) |
7248 |
++ return NULL; |
7249 |
++ |
7250 |
++ list_for_each_entry(adev, &parent->children, node) { |
7251 |
++ if (acpi_device_adr(adev) == raw) |
7252 |
++ return adev; |
7253 |
++ } |
7254 |
++ |
7255 |
++ return acpi_find_child_device(parent, raw, false); |
7256 |
++} |
7257 |
++ |
7258 |
+ static struct acpi_device *usb_acpi_find_companion(struct device *dev) |
7259 |
+ { |
7260 |
+ struct usb_device *udev; |
7261 |
+@@ -174,8 +190,10 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) |
7262 |
+ int raw; |
7263 |
+ |
7264 |
+ raw = usb_hcd_find_raw_port_number(hcd, port1); |
7265 |
+- adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev), |
7266 |
+- raw, false); |
7267 |
++ |
7268 |
++ adev = usb_acpi_find_port(ACPI_COMPANION(&udev->dev), |
7269 |
++ raw); |
7270 |
++ |
7271 |
+ if (!adev) |
7272 |
+ return NULL; |
7273 |
+ } else { |
7274 |
+@@ -186,7 +204,9 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) |
7275 |
+ return NULL; |
7276 |
+ |
7277 |
+ acpi_bus_get_device(parent_handle, &adev); |
7278 |
+- adev = acpi_find_child_device(adev, port1, false); |
7279 |
++ |
7280 |
++ adev = usb_acpi_find_port(adev, port1); |
7281 |
++ |
7282 |
+ if (!adev) |
7283 |
+ return NULL; |
7284 |
+ } |
7285 |
+diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c |
7286 |
+index 03b9a372636f..1fc6f478a02c 100644 |
7287 |
+--- a/drivers/usb/host/pci-quirks.c |
7288 |
++++ b/drivers/usb/host/pci-quirks.c |
7289 |
+@@ -133,29 +133,30 @@ static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo) |
7290 |
+ pinfo->sb_type.gen = AMD_CHIPSET_SB700; |
7291 |
+ else if (rev >= 0x40 && rev <= 0x4f) |
7292 |
+ pinfo->sb_type.gen = AMD_CHIPSET_SB800; |
7293 |
+- } |
7294 |
+- pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
7295 |
+- 0x145c, NULL); |
7296 |
+- if (pinfo->smbus_dev) { |
7297 |
+- pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN; |
7298 |
+ } else { |
7299 |
+ pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
7300 |
+ PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL); |
7301 |
+ |
7302 |
+- if (!pinfo->smbus_dev) { |
7303 |
+- pinfo->sb_type.gen = NOT_AMD_CHIPSET; |
7304 |
+- return 0; |
7305 |
++ if (pinfo->smbus_dev) { |
7306 |
++ rev = pinfo->smbus_dev->revision; |
7307 |
++ if (rev >= 0x11 && rev <= 0x14) |
7308 |
++ pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2; |
7309 |
++ else if (rev >= 0x15 && rev <= 0x18) |
7310 |
++ pinfo->sb_type.gen = AMD_CHIPSET_BOLTON; |
7311 |
++ else if (rev >= 0x39 && rev <= 0x3a) |
7312 |
++ pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE; |
7313 |
++ } else { |
7314 |
++ pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, |
7315 |
++ 0x145c, NULL); |
7316 |
++ if (pinfo->smbus_dev) { |
7317 |
++ rev = pinfo->smbus_dev->revision; |
7318 |
++ pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN; |
7319 |
++ } else { |
7320 |
++ pinfo->sb_type.gen = NOT_AMD_CHIPSET; |
7321 |
++ return 0; |
7322 |
++ } |
7323 |
+ } |
7324 |
+- |
7325 |
+- rev = pinfo->smbus_dev->revision; |
7326 |
+- if (rev >= 0x11 && rev <= 0x14) |
7327 |
+- pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2; |
7328 |
+- else if (rev >= 0x15 && rev <= 0x18) |
7329 |
+- pinfo->sb_type.gen = AMD_CHIPSET_BOLTON; |
7330 |
+- else if (rev >= 0x39 && rev <= 0x3a) |
7331 |
+- pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE; |
7332 |
+ } |
7333 |
+- |
7334 |
+ pinfo->sb_type.rev = rev; |
7335 |
+ return 1; |
7336 |
+ } |
7337 |
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
7338 |
+index f08b35819666..a0fbc4e5a272 100644 |
7339 |
+--- a/drivers/usb/serial/option.c |
7340 |
++++ b/drivers/usb/serial/option.c |
7341 |
+@@ -2020,6 +2020,7 @@ static const struct usb_device_id option_ids[] = { |
7342 |
+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) }, |
7343 |
+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, |
7344 |
+ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) }, /* D-Link DWM-158 */ |
7345 |
++ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d0e, 0xff) }, /* D-Link DWM-157 C1 */ |
7346 |
+ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff), /* D-Link DWM-221 B1 */ |
7347 |
+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
7348 |
+ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */ |
7349 |
+diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c |
7350 |
+index a40b454aea44..4f6a3afc45f4 100644 |
7351 |
+--- a/fs/btrfs/super.c |
7352 |
++++ b/fs/btrfs/super.c |
7353 |
+@@ -1593,6 +1593,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) |
7354 |
+ goto restore; |
7355 |
+ } |
7356 |
+ |
7357 |
++ btrfs_qgroup_rescan_resume(fs_info); |
7358 |
++ |
7359 |
+ if (!fs_info->uuid_root) { |
7360 |
+ btrfs_info(fs_info, "creating UUID tree"); |
7361 |
+ ret = btrfs_create_uuid_tree(fs_info); |
7362 |
+diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c |
7363 |
+index 26a3b389a265..297e05c9e2b0 100644 |
7364 |
+--- a/fs/cifs/dir.c |
7365 |
++++ b/fs/cifs/dir.c |
7366 |
+@@ -183,15 +183,20 @@ cifs_bp_rename_retry: |
7367 |
+ } |
7368 |
+ |
7369 |
+ /* |
7370 |
++ * Don't allow path components longer than the server max. |
7371 |
+ * Don't allow the separator character in a path component. |
7372 |
+ * The VFS will not allow "/", but "\" is allowed by posix. |
7373 |
+ */ |
7374 |
+ static int |
7375 |
+-check_name(struct dentry *direntry) |
7376 |
++check_name(struct dentry *direntry, struct cifs_tcon *tcon) |
7377 |
+ { |
7378 |
+ struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); |
7379 |
+ int i; |
7380 |
+ |
7381 |
++ if (unlikely(direntry->d_name.len > |
7382 |
++ le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength))) |
7383 |
++ return -ENAMETOOLONG; |
7384 |
++ |
7385 |
+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) { |
7386 |
+ for (i = 0; i < direntry->d_name.len; i++) { |
7387 |
+ if (direntry->d_name.name[i] == '\\') { |
7388 |
+@@ -489,10 +494,6 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, |
7389 |
+ return finish_no_open(file, res); |
7390 |
+ } |
7391 |
+ |
7392 |
+- rc = check_name(direntry); |
7393 |
+- if (rc) |
7394 |
+- return rc; |
7395 |
+- |
7396 |
+ xid = get_xid(); |
7397 |
+ |
7398 |
+ cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n", |
7399 |
+@@ -505,6 +506,11 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, |
7400 |
+ } |
7401 |
+ |
7402 |
+ tcon = tlink_tcon(tlink); |
7403 |
++ |
7404 |
++ rc = check_name(direntry, tcon); |
7405 |
++ if (rc) |
7406 |
++ goto out_free_xid; |
7407 |
++ |
7408 |
+ server = tcon->ses->server; |
7409 |
+ |
7410 |
+ if (server->ops->new_lease_key) |
7411 |
+@@ -765,7 +771,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, |
7412 |
+ } |
7413 |
+ pTcon = tlink_tcon(tlink); |
7414 |
+ |
7415 |
+- rc = check_name(direntry); |
7416 |
++ rc = check_name(direntry, pTcon); |
7417 |
+ if (rc) |
7418 |
+ goto lookup_out; |
7419 |
+ |
7420 |
+diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c |
7421 |
+index f8ae041d60fe..2f6f164c83ab 100644 |
7422 |
+--- a/fs/cifs/smb2pdu.c |
7423 |
++++ b/fs/cifs/smb2pdu.c |
7424 |
+@@ -2554,8 +2554,8 @@ copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf, |
7425 |
+ kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) * |
7426 |
+ le32_to_cpu(pfs_inf->SectorsPerAllocationUnit); |
7427 |
+ kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits); |
7428 |
+- kst->f_bfree = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits); |
7429 |
+- kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits); |
7430 |
++ kst->f_bfree = kst->f_bavail = |
7431 |
++ le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits); |
7432 |
+ return; |
7433 |
+ } |
7434 |
+ |
7435 |
+diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h |
7436 |
+index 70867d54fb8b..31acb20d0b6e 100644 |
7437 |
+--- a/fs/cifs/smb2pdu.h |
7438 |
++++ b/fs/cifs/smb2pdu.h |
7439 |
+@@ -82,8 +82,8 @@ |
7440 |
+ |
7441 |
+ #define NUMBER_OF_SMB2_COMMANDS 0x0013 |
7442 |
+ |
7443 |
+-/* BB FIXME - analyze following length BB */ |
7444 |
+-#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */ |
7445 |
++/* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */ |
7446 |
++#define MAX_SMB2_HDR_SIZE 0x00b0 |
7447 |
+ |
7448 |
+ #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) |
7449 |
+ |
7450 |
+diff --git a/fs/dlm/user.c b/fs/dlm/user.c |
7451 |
+index fb85f32e9eca..0221731a9462 100644 |
7452 |
+--- a/fs/dlm/user.c |
7453 |
++++ b/fs/dlm/user.c |
7454 |
+@@ -355,6 +355,10 @@ static int dlm_device_register(struct dlm_ls *ls, char *name) |
7455 |
+ error = misc_register(&ls->ls_device); |
7456 |
+ if (error) { |
7457 |
+ kfree(ls->ls_device.name); |
7458 |
++ /* this has to be set to NULL |
7459 |
++ * to avoid a double-free in dlm_device_deregister |
7460 |
++ */ |
7461 |
++ ls->ls_device.name = NULL; |
7462 |
+ } |
7463 |
+ fail: |
7464 |
+ return error; |
7465 |
+diff --git a/fs/eventpoll.c b/fs/eventpoll.c |
7466 |
+index 1e009cad8d5c..1b08556776ce 100644 |
7467 |
+--- a/fs/eventpoll.c |
7468 |
++++ b/fs/eventpoll.c |
7469 |
+@@ -518,8 +518,13 @@ static void ep_remove_wait_queue(struct eppoll_entry *pwq) |
7470 |
+ wait_queue_head_t *whead; |
7471 |
+ |
7472 |
+ rcu_read_lock(); |
7473 |
+- /* If it is cleared by POLLFREE, it should be rcu-safe */ |
7474 |
+- whead = rcu_dereference(pwq->whead); |
7475 |
++ /* |
7476 |
++ * If it is cleared by POLLFREE, it should be rcu-safe. |
7477 |
++ * If we read NULL we need a barrier paired with |
7478 |
++ * smp_store_release() in ep_poll_callback(), otherwise |
7479 |
++ * we rely on whead->lock. |
7480 |
++ */ |
7481 |
++ whead = smp_load_acquire(&pwq->whead); |
7482 |
+ if (whead) |
7483 |
+ remove_wait_queue(whead, &pwq->wait); |
7484 |
+ rcu_read_unlock(); |
7485 |
+@@ -1003,17 +1008,6 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k |
7486 |
+ struct epitem *epi = ep_item_from_wait(wait); |
7487 |
+ struct eventpoll *ep = epi->ep; |
7488 |
+ |
7489 |
+- if ((unsigned long)key & POLLFREE) { |
7490 |
+- ep_pwq_from_wait(wait)->whead = NULL; |
7491 |
+- /* |
7492 |
+- * whead = NULL above can race with ep_remove_wait_queue() |
7493 |
+- * which can do another remove_wait_queue() after us, so we |
7494 |
+- * can't use __remove_wait_queue(). whead->lock is held by |
7495 |
+- * the caller. |
7496 |
+- */ |
7497 |
+- list_del_init(&wait->task_list); |
7498 |
+- } |
7499 |
+- |
7500 |
+ spin_lock_irqsave(&ep->lock, flags); |
7501 |
+ |
7502 |
+ /* |
7503 |
+@@ -1078,6 +1072,23 @@ out_unlock: |
7504 |
+ if (pwake) |
7505 |
+ ep_poll_safewake(&ep->poll_wait); |
7506 |
+ |
7507 |
++ |
7508 |
++ if ((unsigned long)key & POLLFREE) { |
7509 |
++ /* |
7510 |
++ * If we race with ep_remove_wait_queue() it can miss |
7511 |
++ * ->whead = NULL and do another remove_wait_queue() after |
7512 |
++ * us, so we can't use __remove_wait_queue(). |
7513 |
++ */ |
7514 |
++ list_del_init(&wait->task_list); |
7515 |
++ /* |
7516 |
++ * ->whead != NULL protects us from the race with ep_free() |
7517 |
++ * or ep_remove(), ep_remove_wait_queue() takes whead->lock |
7518 |
++ * held by the caller. Once we nullify it, nothing protects |
7519 |
++ * ep/epi or even wait. |
7520 |
++ */ |
7521 |
++ smp_store_release(&ep_pwq_from_wait(wait)->whead, NULL); |
7522 |
++ } |
7523 |
++ |
7524 |
+ return 1; |
7525 |
+ } |
7526 |
+ |
7527 |
+diff --git a/fs/ext4/super.c b/fs/ext4/super.c |
7528 |
+index 97aa8be40175..ccc43e2f07e2 100644 |
7529 |
+--- a/fs/ext4/super.c |
7530 |
++++ b/fs/ext4/super.c |
7531 |
+@@ -2233,7 +2233,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, |
7532 |
+ #ifdef CONFIG_QUOTA |
7533 |
+ /* Needed for iput() to work correctly and not trash data */ |
7534 |
+ sb->s_flags |= MS_ACTIVE; |
7535 |
+- /* Turn on quotas so that they are updated correctly */ |
7536 |
++ /* Turn on journaled quotas so that they are updated correctly */ |
7537 |
+ for (i = 0; i < EXT4_MAXQUOTAS; i++) { |
7538 |
+ if (EXT4_SB(sb)->s_qf_names[i]) { |
7539 |
+ int ret = ext4_quota_on_mount(sb, i); |
7540 |
+@@ -2299,9 +2299,9 @@ static void ext4_orphan_cleanup(struct super_block *sb, |
7541 |
+ ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", |
7542 |
+ PLURAL(nr_truncates)); |
7543 |
+ #ifdef CONFIG_QUOTA |
7544 |
+- /* Turn quotas off */ |
7545 |
++ /* Turn off journaled quotas if they were enabled for orphan cleanup */ |
7546 |
+ for (i = 0; i < EXT4_MAXQUOTAS; i++) { |
7547 |
+- if (sb_dqopt(sb)->files[i]) |
7548 |
++ if (EXT4_SB(sb)->s_qf_names[i] && sb_dqopt(sb)->files[i]) |
7549 |
+ dquot_quota_off(sb, i); |
7550 |
+ } |
7551 |
+ #endif |
7552 |
+diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c |
7553 |
+index 8d8ea99f2156..e195cc5e3590 100644 |
7554 |
+--- a/fs/f2fs/recovery.c |
7555 |
++++ b/fs/f2fs/recovery.c |
7556 |
+@@ -265,7 +265,7 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi, |
7557 |
+ return 0; |
7558 |
+ |
7559 |
+ /* Get the previous summary */ |
7560 |
+- for (i = CURSEG_WARM_DATA; i <= CURSEG_COLD_DATA; i++) { |
7561 |
++ for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { |
7562 |
+ struct curseg_info *curseg = CURSEG_I(sbi, i); |
7563 |
+ if (curseg->segno == segno) { |
7564 |
+ sum = curseg->sum_blk->entries[blkoff]; |
7565 |
+diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c |
7566 |
+index 16fcfdd6011c..280cd3d9151f 100644 |
7567 |
+--- a/fs/nfsd/nfs4xdr.c |
7568 |
++++ b/fs/nfsd/nfs4xdr.c |
7569 |
+@@ -128,7 +128,7 @@ static void next_decode_page(struct nfsd4_compoundargs *argp) |
7570 |
+ argp->p = page_address(argp->pagelist[0]); |
7571 |
+ argp->pagelist++; |
7572 |
+ if (argp->pagelen < PAGE_SIZE) { |
7573 |
+- argp->end = argp->p + (argp->pagelen>>2); |
7574 |
++ argp->end = argp->p + XDR_QUADLEN(argp->pagelen); |
7575 |
+ argp->pagelen = 0; |
7576 |
+ } else { |
7577 |
+ argp->end = argp->p + (PAGE_SIZE>>2); |
7578 |
+@@ -1245,9 +1245,7 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) |
7579 |
+ argp->pagelen -= pages * PAGE_SIZE; |
7580 |
+ len -= pages * PAGE_SIZE; |
7581 |
+ |
7582 |
+- argp->p = (__be32 *)page_address(argp->pagelist[0]); |
7583 |
+- argp->pagelist++; |
7584 |
+- argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE); |
7585 |
++ next_decode_page(argp); |
7586 |
+ } |
7587 |
+ argp->p += XDR_QUADLEN(len); |
7588 |
+ |
7589 |
+diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h |
7590 |
+index 7c7842c85a08..530c2f9c47c7 100644 |
7591 |
+--- a/fs/xfs/xfs_linux.h |
7592 |
++++ b/fs/xfs/xfs_linux.h |
7593 |
+@@ -376,7 +376,14 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) |
7594 |
+ #endif /* DEBUG */ |
7595 |
+ |
7596 |
+ #ifdef CONFIG_XFS_RT |
7597 |
+-#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) |
7598 |
++ |
7599 |
++/* |
7600 |
++ * make sure we ignore the inode flag if the filesystem doesn't have a |
7601 |
++ * configured realtime device. |
7602 |
++ */ |
7603 |
++#define XFS_IS_REALTIME_INODE(ip) \ |
7604 |
++ (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) && \ |
7605 |
++ (ip)->i_mount->m_rtdev_targp) |
7606 |
+ #else |
7607 |
+ #define XFS_IS_REALTIME_INODE(ip) (0) |
7608 |
+ #endif |
7609 |
+diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h |
7610 |
+index fc824e2828f3..5d2add1a6c96 100644 |
7611 |
+--- a/include/asm-generic/topology.h |
7612 |
++++ b/include/asm-generic/topology.h |
7613 |
+@@ -48,7 +48,11 @@ |
7614 |
+ #define parent_node(node) ((void)(node),0) |
7615 |
+ #endif |
7616 |
+ #ifndef cpumask_of_node |
7617 |
+-#define cpumask_of_node(node) ((void)node, cpu_online_mask) |
7618 |
++ #ifdef CONFIG_NEED_MULTIPLE_NODES |
7619 |
++ #define cpumask_of_node(node) ((node) == 0 ? cpu_online_mask : cpu_none_mask) |
7620 |
++ #else |
7621 |
++ #define cpumask_of_node(node) ((void)node, cpu_online_mask) |
7622 |
++ #endif |
7623 |
+ #endif |
7624 |
+ #ifndef pcibus_to_node |
7625 |
+ #define pcibus_to_node(bus) ((void)(bus), -1) |
7626 |
+diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h |
7627 |
+index 9b6f5dc58732..d57b902407dd 100644 |
7628 |
+--- a/include/linux/pci_ids.h |
7629 |
++++ b/include/linux/pci_ids.h |
7630 |
+@@ -573,6 +573,7 @@ |
7631 |
+ #define PCI_DEVICE_ID_AMD_CS5536_EHC 0x2095 |
7632 |
+ #define PCI_DEVICE_ID_AMD_CS5536_UDC 0x2096 |
7633 |
+ #define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 |
7634 |
++#define PCI_DEVICE_ID_AMD_CS5536_DEV_IDE 0x2092 |
7635 |
+ #define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A |
7636 |
+ #define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 |
7637 |
+ #define PCI_DEVICE_ID_AMD_LX_AES 0x2082 |
7638 |
+diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h |
7639 |
+index c28dd523f96e..d43837f2ce3a 100644 |
7640 |
+--- a/include/linux/tty_flip.h |
7641 |
++++ b/include/linux/tty_flip.h |
7642 |
+@@ -12,6 +12,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, |
7643 |
+ unsigned char **chars, size_t size); |
7644 |
+ extern void tty_flip_buffer_push(struct tty_port *port); |
7645 |
+ void tty_schedule_flip(struct tty_port *port); |
7646 |
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag); |
7647 |
+ |
7648 |
+ static inline int tty_insert_flip_char(struct tty_port *port, |
7649 |
+ unsigned char ch, char flag) |
7650 |
+@@ -26,7 +27,7 @@ static inline int tty_insert_flip_char(struct tty_port *port, |
7651 |
+ *char_buf_ptr(tb, tb->used++) = ch; |
7652 |
+ return 1; |
7653 |
+ } |
7654 |
+- return tty_insert_flip_string_flags(port, &ch, &flag, 1); |
7655 |
++ return __tty_insert_flip_char(port, ch, flag); |
7656 |
+ } |
7657 |
+ |
7658 |
+ static inline int tty_insert_flip_string(struct tty_port *port, |
7659 |
+diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h |
7660 |
+index 530bdca19803..35fdedac3e25 100644 |
7661 |
+--- a/include/net/sch_generic.h |
7662 |
++++ b/include/net/sch_generic.h |
7663 |
+@@ -701,8 +701,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new, |
7664 |
+ old = *pold; |
7665 |
+ *pold = new; |
7666 |
+ if (old != NULL) { |
7667 |
+- qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog); |
7668 |
++ unsigned int qlen = old->q.qlen; |
7669 |
++ unsigned int backlog = old->qstats.backlog; |
7670 |
++ |
7671 |
+ qdisc_reset(old); |
7672 |
++ qdisc_tree_reduce_backlog(old, qlen, backlog); |
7673 |
+ } |
7674 |
+ sch_tree_unlock(sch); |
7675 |
+ |
7676 |
+diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c |
7677 |
+index 6e30024d9aac..d53c6e284e87 100644 |
7678 |
+--- a/kernel/audit_watch.c |
7679 |
++++ b/kernel/audit_watch.c |
7680 |
+@@ -455,13 +455,15 @@ void audit_remove_watch_rule(struct audit_krule *krule) |
7681 |
+ list_del(&krule->rlist); |
7682 |
+ |
7683 |
+ if (list_empty(&watch->rules)) { |
7684 |
++ /* |
7685 |
++ * audit_remove_watch() drops our reference to 'parent' which |
7686 |
++ * can get freed. Grab our own reference to be safe. |
7687 |
++ */ |
7688 |
++ audit_get_parent(parent); |
7689 |
+ audit_remove_watch(watch); |
7690 |
+- |
7691 |
+- if (list_empty(&parent->watches)) { |
7692 |
+- audit_get_parent(parent); |
7693 |
++ if (list_empty(&parent->watches)) |
7694 |
+ fsnotify_destroy_mark(&parent->mark, audit_watch_group); |
7695 |
+- audit_put_parent(parent); |
7696 |
+- } |
7697 |
++ audit_put_parent(parent); |
7698 |
+ } |
7699 |
+ } |
7700 |
+ |
7701 |
+diff --git a/kernel/events/core.c b/kernel/events/core.c |
7702 |
+index e871080bc44e..e5553bdaf6c2 100644 |
7703 |
+--- a/kernel/events/core.c |
7704 |
++++ b/kernel/events/core.c |
7705 |
+@@ -8102,28 +8102,27 @@ SYSCALL_DEFINE5(perf_event_open, |
7706 |
+ goto err_context; |
7707 |
+ |
7708 |
+ /* |
7709 |
+- * Do not allow to attach to a group in a different |
7710 |
+- * task or CPU context: |
7711 |
++ * Make sure we're both events for the same CPU; |
7712 |
++ * grouping events for different CPUs is broken; since |
7713 |
++ * you can never concurrently schedule them anyhow. |
7714 |
+ */ |
7715 |
+- if (move_group) { |
7716 |
+- /* |
7717 |
+- * Make sure we're both on the same task, or both |
7718 |
+- * per-cpu events. |
7719 |
+- */ |
7720 |
+- if (group_leader->ctx->task != ctx->task) |
7721 |
+- goto err_context; |
7722 |
++ if (group_leader->cpu != event->cpu) |
7723 |
++ goto err_context; |
7724 |
+ |
7725 |
+- /* |
7726 |
+- * Make sure we're both events for the same CPU; |
7727 |
+- * grouping events for different CPUs is broken; since |
7728 |
+- * you can never concurrently schedule them anyhow. |
7729 |
+- */ |
7730 |
+- if (group_leader->cpu != event->cpu) |
7731 |
+- goto err_context; |
7732 |
+- } else { |
7733 |
+- if (group_leader->ctx != ctx) |
7734 |
+- goto err_context; |
7735 |
+- } |
7736 |
++ /* |
7737 |
++ * Make sure we're both on the same task, or both |
7738 |
++ * per-CPU events. |
7739 |
++ */ |
7740 |
++ if (group_leader->ctx->task != ctx->task) |
7741 |
++ goto err_context; |
7742 |
++ |
7743 |
++ /* |
7744 |
++ * Do not allow to attach to a group in a different task |
7745 |
++ * or CPU context. If we're moving SW events, we'll fix |
7746 |
++ * this up later, so allow that. |
7747 |
++ */ |
7748 |
++ if (!move_group && group_leader->ctx != ctx) |
7749 |
++ goto err_context; |
7750 |
+ |
7751 |
+ /* |
7752 |
+ * Only a group leader can be exclusive or pinned |
7753 |
+diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c |
7754 |
+index ec8cce259779..a25e3a11f1b3 100644 |
7755 |
+--- a/kernel/locking/locktorture.c |
7756 |
++++ b/kernel/locking/locktorture.c |
7757 |
+@@ -630,6 +630,8 @@ static void lock_torture_cleanup(void) |
7758 |
+ else |
7759 |
+ lock_torture_print_module_parms(cxt.cur_ops, |
7760 |
+ "End of test: SUCCESS"); |
7761 |
++ kfree(cxt.lwsa); |
7762 |
++ kfree(cxt.lrsa); |
7763 |
+ torture_cleanup_end(); |
7764 |
+ } |
7765 |
+ |
7766 |
+@@ -763,6 +765,8 @@ static int __init lock_torture_init(void) |
7767 |
+ GFP_KERNEL); |
7768 |
+ if (reader_tasks == NULL) { |
7769 |
+ VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory"); |
7770 |
++ kfree(writer_tasks); |
7771 |
++ writer_tasks = NULL; |
7772 |
+ firsterr = -ENOMEM; |
7773 |
+ goto unwind; |
7774 |
+ } |
7775 |
+diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
7776 |
+index eb11011b5292..06d0e5712e86 100644 |
7777 |
+--- a/kernel/trace/ftrace.c |
7778 |
++++ b/kernel/trace/ftrace.c |
7779 |
+@@ -2657,13 +2657,14 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) |
7780 |
+ |
7781 |
+ if (!command || !ftrace_enabled) { |
7782 |
+ /* |
7783 |
+- * If these are control ops, they still need their |
7784 |
+- * per_cpu field freed. Since, function tracing is |
7785 |
++ * If these are dynamic or control ops, they still |
7786 |
++ * need their data freed. Since, function tracing is |
7787 |
+ * not currently active, we can just free them |
7788 |
+ * without synchronizing all CPUs. |
7789 |
+ */ |
7790 |
+- if (ops->flags & FTRACE_OPS_FL_CONTROL) |
7791 |
+- control_ops_free(ops); |
7792 |
++ if (ops->flags & (FTRACE_OPS_FL_DYNAMIC | FTRACE_OPS_FL_CONTROL)) |
7793 |
++ goto free_ops; |
7794 |
++ |
7795 |
+ return 0; |
7796 |
+ } |
7797 |
+ |
7798 |
+@@ -2718,6 +2719,7 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) |
7799 |
+ if (ops->flags & (FTRACE_OPS_FL_DYNAMIC | FTRACE_OPS_FL_CONTROL)) { |
7800 |
+ schedule_on_each_cpu(ftrace_sync); |
7801 |
+ |
7802 |
++ free_ops: |
7803 |
+ arch_ftrace_trampoline_free(ops); |
7804 |
+ |
7805 |
+ if (ops->flags & FTRACE_OPS_FL_CONTROL) |
7806 |
+diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c |
7807 |
+index 591b3b4f5337..17213d74540b 100644 |
7808 |
+--- a/kernel/trace/trace.c |
7809 |
++++ b/kernel/trace/trace.c |
7810 |
+@@ -5204,7 +5204,7 @@ static int tracing_set_clock(struct trace_array *tr, const char *clockstr) |
7811 |
+ tracing_reset_online_cpus(&tr->trace_buffer); |
7812 |
+ |
7813 |
+ #ifdef CONFIG_TRACER_MAX_TRACE |
7814 |
+- if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) |
7815 |
++ if (tr->max_buffer.buffer) |
7816 |
+ ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); |
7817 |
+ tracing_reset_online_cpus(&tr->max_buffer); |
7818 |
+ #endif |
7819 |
+diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c |
7820 |
+index 52adf02d7619..f186066f8b87 100644 |
7821 |
+--- a/kernel/trace/trace_events_filter.c |
7822 |
++++ b/kernel/trace/trace_events_filter.c |
7823 |
+@@ -1928,6 +1928,10 @@ static int create_filter(struct ftrace_event_call *call, |
7824 |
+ if (err && set_str) |
7825 |
+ append_filter_err(ps, filter); |
7826 |
+ } |
7827 |
++ if (err && !set_str) { |
7828 |
++ free_event_filter(filter); |
7829 |
++ filter = NULL; |
7830 |
++ } |
7831 |
+ create_filter_finish(ps); |
7832 |
+ |
7833 |
+ *filterp = filter; |
7834 |
+diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c |
7835 |
+index b0f86ea77881..ca70d11b8aa7 100644 |
7836 |
+--- a/kernel/trace/trace_selftest.c |
7837 |
++++ b/kernel/trace/trace_selftest.c |
7838 |
+@@ -272,7 +272,7 @@ static int trace_selftest_ops(struct trace_array *tr, int cnt) |
7839 |
+ goto out_free; |
7840 |
+ if (cnt > 1) { |
7841 |
+ if (trace_selftest_test_global_cnt == 0) |
7842 |
+- goto out; |
7843 |
++ goto out_free; |
7844 |
+ } |
7845 |
+ if (trace_selftest_test_dyn_cnt == 0) |
7846 |
+ goto out_free; |
7847 |
+diff --git a/mm/mempolicy.c b/mm/mempolicy.c |
7848 |
+index ea06282f8a3e..dacd2e9a5b68 100644 |
7849 |
+--- a/mm/mempolicy.c |
7850 |
++++ b/mm/mempolicy.c |
7851 |
+@@ -897,11 +897,6 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, |
7852 |
+ *policy |= (pol->flags & MPOL_MODE_FLAGS); |
7853 |
+ } |
7854 |
+ |
7855 |
+- if (vma) { |
7856 |
+- up_read(¤t->mm->mmap_sem); |
7857 |
+- vma = NULL; |
7858 |
+- } |
7859 |
+- |
7860 |
+ err = 0; |
7861 |
+ if (nmask) { |
7862 |
+ if (mpol_store_user_nodemask(pol)) { |
7863 |
+diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c |
7864 |
+index 1641367e54ca..69f56073b337 100644 |
7865 |
+--- a/net/bluetooth/bnep/core.c |
7866 |
++++ b/net/bluetooth/bnep/core.c |
7867 |
+@@ -484,16 +484,16 @@ static int bnep_session(void *arg) |
7868 |
+ struct net_device *dev = s->dev; |
7869 |
+ struct sock *sk = s->sock->sk; |
7870 |
+ struct sk_buff *skb; |
7871 |
+- wait_queue_t wait; |
7872 |
++ DEFINE_WAIT_FUNC(wait, woken_wake_function); |
7873 |
+ |
7874 |
+ BT_DBG(""); |
7875 |
+ |
7876 |
+ set_user_nice(current, -15); |
7877 |
+ |
7878 |
+- init_waitqueue_entry(&wait, current); |
7879 |
+ add_wait_queue(sk_sleep(sk), &wait); |
7880 |
+ while (1) { |
7881 |
+- set_current_state(TASK_INTERRUPTIBLE); |
7882 |
++ /* Ensure session->terminate is updated */ |
7883 |
++ smp_mb__before_atomic(); |
7884 |
+ |
7885 |
+ if (atomic_read(&s->terminate)) |
7886 |
+ break; |
7887 |
+@@ -515,9 +515,8 @@ static int bnep_session(void *arg) |
7888 |
+ break; |
7889 |
+ netif_wake_queue(dev); |
7890 |
+ |
7891 |
+- schedule(); |
7892 |
++ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); |
7893 |
+ } |
7894 |
+- __set_current_state(TASK_RUNNING); |
7895 |
+ remove_wait_queue(sk_sleep(sk), &wait); |
7896 |
+ |
7897 |
+ /* Cleanup session */ |
7898 |
+@@ -663,7 +662,7 @@ int bnep_del_connection(struct bnep_conndel_req *req) |
7899 |
+ s = __bnep_get_session(req->dst); |
7900 |
+ if (s) { |
7901 |
+ atomic_inc(&s->terminate); |
7902 |
+- wake_up_process(s->task); |
7903 |
++ wake_up_interruptible(sk_sleep(s->sock->sk)); |
7904 |
+ } else |
7905 |
+ err = -ENOENT; |
7906 |
+ |
7907 |
+diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c |
7908 |
+index 298ed37010e6..3a39fd523e40 100644 |
7909 |
+--- a/net/bluetooth/cmtp/core.c |
7910 |
++++ b/net/bluetooth/cmtp/core.c |
7911 |
+@@ -281,16 +281,16 @@ static int cmtp_session(void *arg) |
7912 |
+ struct cmtp_session *session = arg; |
7913 |
+ struct sock *sk = session->sock->sk; |
7914 |
+ struct sk_buff *skb; |
7915 |
+- wait_queue_t wait; |
7916 |
++ DEFINE_WAIT_FUNC(wait, woken_wake_function); |
7917 |
+ |
7918 |
+ BT_DBG("session %p", session); |
7919 |
+ |
7920 |
+ set_user_nice(current, -15); |
7921 |
+ |
7922 |
+- init_waitqueue_entry(&wait, current); |
7923 |
+ add_wait_queue(sk_sleep(sk), &wait); |
7924 |
+ while (1) { |
7925 |
+- set_current_state(TASK_INTERRUPTIBLE); |
7926 |
++ /* Ensure session->terminate is updated */ |
7927 |
++ smp_mb__before_atomic(); |
7928 |
+ |
7929 |
+ if (atomic_read(&session->terminate)) |
7930 |
+ break; |
7931 |
+@@ -307,9 +307,8 @@ static int cmtp_session(void *arg) |
7932 |
+ |
7933 |
+ cmtp_process_transmit(session); |
7934 |
+ |
7935 |
+- schedule(); |
7936 |
++ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); |
7937 |
+ } |
7938 |
+- __set_current_state(TASK_RUNNING); |
7939 |
+ remove_wait_queue(sk_sleep(sk), &wait); |
7940 |
+ |
7941 |
+ down_write(&cmtp_session_sem); |
7942 |
+@@ -394,7 +393,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock) |
7943 |
+ err = cmtp_attach_device(session); |
7944 |
+ if (err < 0) { |
7945 |
+ atomic_inc(&session->terminate); |
7946 |
+- wake_up_process(session->task); |
7947 |
++ wake_up_interruptible(sk_sleep(session->sock->sk)); |
7948 |
+ up_write(&cmtp_session_sem); |
7949 |
+ return err; |
7950 |
+ } |
7951 |
+@@ -432,7 +431,11 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) |
7952 |
+ |
7953 |
+ /* Stop session thread */ |
7954 |
+ atomic_inc(&session->terminate); |
7955 |
+- wake_up_process(session->task); |
7956 |
++ |
7957 |
++ /* Ensure session->terminate is updated */ |
7958 |
++ smp_mb__after_atomic(); |
7959 |
++ |
7960 |
++ wake_up_interruptible(sk_sleep(session->sock->sk)); |
7961 |
+ } else |
7962 |
+ err = -ENOENT; |
7963 |
+ |
7964 |
+diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c |
7965 |
+index 4a0015e16d4f..b9eb90109f7c 100644 |
7966 |
+--- a/net/bluetooth/hidp/core.c |
7967 |
++++ b/net/bluetooth/hidp/core.c |
7968 |
+@@ -36,6 +36,7 @@ |
7969 |
+ #define VERSION "1.2" |
7970 |
+ |
7971 |
+ static DECLARE_RWSEM(hidp_session_sem); |
7972 |
++static DECLARE_WAIT_QUEUE_HEAD(hidp_session_wq); |
7973 |
+ static LIST_HEAD(hidp_session_list); |
7974 |
+ |
7975 |
+ static unsigned char hidp_keycode[256] = { |
7976 |
+@@ -1067,12 +1068,12 @@ static int hidp_session_start_sync(struct hidp_session *session) |
7977 |
+ * Wake up session thread and notify it to stop. This is asynchronous and |
7978 |
+ * returns immediately. Call this whenever a runtime error occurs and you want |
7979 |
+ * the session to stop. |
7980 |
+- * Note: wake_up_process() performs any necessary memory-barriers for us. |
7981 |
++ * Note: wake_up_interruptible() performs any necessary memory-barriers for us. |
7982 |
+ */ |
7983 |
+ static void hidp_session_terminate(struct hidp_session *session) |
7984 |
+ { |
7985 |
+ atomic_inc(&session->terminate); |
7986 |
+- wake_up_process(session->task); |
7987 |
++ wake_up_interruptible(&hidp_session_wq); |
7988 |
+ } |
7989 |
+ |
7990 |
+ /* |
7991 |
+@@ -1179,7 +1180,9 @@ static void hidp_session_run(struct hidp_session *session) |
7992 |
+ struct sock *ctrl_sk = session->ctrl_sock->sk; |
7993 |
+ struct sock *intr_sk = session->intr_sock->sk; |
7994 |
+ struct sk_buff *skb; |
7995 |
++ DEFINE_WAIT_FUNC(wait, woken_wake_function); |
7996 |
+ |
7997 |
++ add_wait_queue(&hidp_session_wq, &wait); |
7998 |
+ for (;;) { |
7999 |
+ /* |
8000 |
+ * This thread can be woken up two ways: |
8001 |
+@@ -1187,12 +1190,10 @@ static void hidp_session_run(struct hidp_session *session) |
8002 |
+ * session->terminate flag and wakes this thread up. |
8003 |
+ * - Via modifying the socket state of ctrl/intr_sock. This |
8004 |
+ * thread is woken up by ->sk_state_changed(). |
8005 |
+- * |
8006 |
+- * Note: set_current_state() performs any necessary |
8007 |
+- * memory-barriers for us. |
8008 |
+ */ |
8009 |
+- set_current_state(TASK_INTERRUPTIBLE); |
8010 |
+ |
8011 |
++ /* Ensure session->terminate is updated */ |
8012 |
++ smp_mb__before_atomic(); |
8013 |
+ if (atomic_read(&session->terminate)) |
8014 |
+ break; |
8015 |
+ |
8016 |
+@@ -1226,11 +1227,22 @@ static void hidp_session_run(struct hidp_session *session) |
8017 |
+ hidp_process_transmit(session, &session->ctrl_transmit, |
8018 |
+ session->ctrl_sock); |
8019 |
+ |
8020 |
+- schedule(); |
8021 |
++ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); |
8022 |
+ } |
8023 |
++ remove_wait_queue(&hidp_session_wq, &wait); |
8024 |
+ |
8025 |
+ atomic_inc(&session->terminate); |
8026 |
+- set_current_state(TASK_RUNNING); |
8027 |
++ |
8028 |
++ /* Ensure session->terminate is updated */ |
8029 |
++ smp_mb__after_atomic(); |
8030 |
++} |
8031 |
++ |
8032 |
++static int hidp_session_wake_function(wait_queue_t *wait, |
8033 |
++ unsigned int mode, |
8034 |
++ int sync, void *key) |
8035 |
++{ |
8036 |
++ wake_up_interruptible(&hidp_session_wq); |
8037 |
++ return false; |
8038 |
+ } |
8039 |
+ |
8040 |
+ /* |
8041 |
+@@ -1243,7 +1255,8 @@ static void hidp_session_run(struct hidp_session *session) |
8042 |
+ static int hidp_session_thread(void *arg) |
8043 |
+ { |
8044 |
+ struct hidp_session *session = arg; |
8045 |
+- wait_queue_t ctrl_wait, intr_wait; |
8046 |
++ DEFINE_WAIT_FUNC(ctrl_wait, hidp_session_wake_function); |
8047 |
++ DEFINE_WAIT_FUNC(intr_wait, hidp_session_wake_function); |
8048 |
+ |
8049 |
+ BT_DBG("session %p", session); |
8050 |
+ |
8051 |
+@@ -1253,8 +1266,6 @@ static int hidp_session_thread(void *arg) |
8052 |
+ set_user_nice(current, -15); |
8053 |
+ hidp_set_timer(session); |
8054 |
+ |
8055 |
+- init_waitqueue_entry(&ctrl_wait, current); |
8056 |
+- init_waitqueue_entry(&intr_wait, current); |
8057 |
+ add_wait_queue(sk_sleep(session->ctrl_sock->sk), &ctrl_wait); |
8058 |
+ add_wait_queue(sk_sleep(session->intr_sock->sk), &intr_wait); |
8059 |
+ /* This memory barrier is paired with wq_has_sleeper(). See |
8060 |
+diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c |
8061 |
+index dad419782a12..9b6b35977f48 100644 |
8062 |
+--- a/net/bluetooth/l2cap_core.c |
8063 |
++++ b/net/bluetooth/l2cap_core.c |
8064 |
+@@ -57,7 +57,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, |
8065 |
+ u8 code, u8 ident, u16 dlen, void *data); |
8066 |
+ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, |
8067 |
+ void *data); |
8068 |
+-static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); |
8069 |
++static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data_size); |
8070 |
+ static void l2cap_send_disconn_req(struct l2cap_chan *chan, int err); |
8071 |
+ |
8072 |
+ static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, |
8073 |
+@@ -1462,7 +1462,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) |
8074 |
+ |
8075 |
+ set_bit(CONF_REQ_SENT, &chan->conf_state); |
8076 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
8077 |
+- l2cap_build_conf_req(chan, buf), buf); |
8078 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); |
8079 |
+ chan->num_conf_req++; |
8080 |
+ } |
8081 |
+ |
8082 |
+@@ -2970,12 +2970,15 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, |
8083 |
+ return len; |
8084 |
+ } |
8085 |
+ |
8086 |
+-static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) |
8087 |
++static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val, size_t size) |
8088 |
+ { |
8089 |
+ struct l2cap_conf_opt *opt = *ptr; |
8090 |
+ |
8091 |
+ BT_DBG("type 0x%2.2x len %u val 0x%lx", type, len, val); |
8092 |
+ |
8093 |
++ if (size < L2CAP_CONF_OPT_SIZE + len) |
8094 |
++ return; |
8095 |
++ |
8096 |
+ opt->type = type; |
8097 |
+ opt->len = len; |
8098 |
+ |
8099 |
+@@ -3000,7 +3003,7 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) |
8100 |
+ *ptr += L2CAP_CONF_OPT_SIZE + len; |
8101 |
+ } |
8102 |
+ |
8103 |
+-static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) |
8104 |
++static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan, size_t size) |
8105 |
+ { |
8106 |
+ struct l2cap_conf_efs efs; |
8107 |
+ |
8108 |
+@@ -3028,7 +3031,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) |
8109 |
+ } |
8110 |
+ |
8111 |
+ l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs), |
8112 |
+- (unsigned long) &efs); |
8113 |
++ (unsigned long) &efs, size); |
8114 |
+ } |
8115 |
+ |
8116 |
+ static void l2cap_ack_timeout(struct work_struct *work) |
8117 |
+@@ -3174,11 +3177,12 @@ static inline void l2cap_txwin_setup(struct l2cap_chan *chan) |
8118 |
+ chan->ack_win = chan->tx_win; |
8119 |
+ } |
8120 |
+ |
8121 |
+-static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) |
8122 |
++static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data_size) |
8123 |
+ { |
8124 |
+ struct l2cap_conf_req *req = data; |
8125 |
+ struct l2cap_conf_rfc rfc = { .mode = chan->mode }; |
8126 |
+ void *ptr = req->data; |
8127 |
++ void *endptr = data + data_size; |
8128 |
+ u16 size; |
8129 |
+ |
8130 |
+ BT_DBG("chan %p", chan); |
8131 |
+@@ -3203,7 +3207,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) |
8132 |
+ |
8133 |
+ done: |
8134 |
+ if (chan->imtu != L2CAP_DEFAULT_MTU) |
8135 |
+- l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu); |
8136 |
++ l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu, endptr - ptr); |
8137 |
+ |
8138 |
+ switch (chan->mode) { |
8139 |
+ case L2CAP_MODE_BASIC: |
8140 |
+@@ -3222,7 +3226,7 @@ done: |
8141 |
+ rfc.max_pdu_size = 0; |
8142 |
+ |
8143 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
8144 |
+- (unsigned long) &rfc); |
8145 |
++ (unsigned long) &rfc, endptr - ptr); |
8146 |
+ break; |
8147 |
+ |
8148 |
+ case L2CAP_MODE_ERTM: |
8149 |
+@@ -3242,21 +3246,21 @@ done: |
8150 |
+ L2CAP_DEFAULT_TX_WINDOW); |
8151 |
+ |
8152 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
8153 |
+- (unsigned long) &rfc); |
8154 |
++ (unsigned long) &rfc, endptr - ptr); |
8155 |
+ |
8156 |
+ if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
8157 |
+- l2cap_add_opt_efs(&ptr, chan); |
8158 |
++ l2cap_add_opt_efs(&ptr, chan, endptr - ptr); |
8159 |
+ |
8160 |
+ if (test_bit(FLAG_EXT_CTRL, &chan->flags)) |
8161 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, |
8162 |
+- chan->tx_win); |
8163 |
++ chan->tx_win, endptr - ptr); |
8164 |
+ |
8165 |
+ if (chan->conn->feat_mask & L2CAP_FEAT_FCS) |
8166 |
+ if (chan->fcs == L2CAP_FCS_NONE || |
8167 |
+ test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) { |
8168 |
+ chan->fcs = L2CAP_FCS_NONE; |
8169 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, |
8170 |
+- chan->fcs); |
8171 |
++ chan->fcs, endptr - ptr); |
8172 |
+ } |
8173 |
+ break; |
8174 |
+ |
8175 |
+@@ -3274,17 +3278,17 @@ done: |
8176 |
+ rfc.max_pdu_size = cpu_to_le16(size); |
8177 |
+ |
8178 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
8179 |
+- (unsigned long) &rfc); |
8180 |
++ (unsigned long) &rfc, endptr - ptr); |
8181 |
+ |
8182 |
+ if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
8183 |
+- l2cap_add_opt_efs(&ptr, chan); |
8184 |
++ l2cap_add_opt_efs(&ptr, chan, endptr - ptr); |
8185 |
+ |
8186 |
+ if (chan->conn->feat_mask & L2CAP_FEAT_FCS) |
8187 |
+ if (chan->fcs == L2CAP_FCS_NONE || |
8188 |
+ test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) { |
8189 |
+ chan->fcs = L2CAP_FCS_NONE; |
8190 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, |
8191 |
+- chan->fcs); |
8192 |
++ chan->fcs, endptr - ptr); |
8193 |
+ } |
8194 |
+ break; |
8195 |
+ } |
8196 |
+@@ -3295,10 +3299,11 @@ done: |
8197 |
+ return ptr - data; |
8198 |
+ } |
8199 |
+ |
8200 |
+-static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) |
8201 |
++static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data_size) |
8202 |
+ { |
8203 |
+ struct l2cap_conf_rsp *rsp = data; |
8204 |
+ void *ptr = rsp->data; |
8205 |
++ void *endptr = data + data_size; |
8206 |
+ void *req = chan->conf_req; |
8207 |
+ int len = chan->conf_len; |
8208 |
+ int type, hint, olen; |
8209 |
+@@ -3400,7 +3405,7 @@ done: |
8210 |
+ return -ECONNREFUSED; |
8211 |
+ |
8212 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
8213 |
+- (unsigned long) &rfc); |
8214 |
++ (unsigned long) &rfc, endptr - ptr); |
8215 |
+ } |
8216 |
+ |
8217 |
+ if (result == L2CAP_CONF_SUCCESS) { |
8218 |
+@@ -3413,7 +3418,7 @@ done: |
8219 |
+ chan->omtu = mtu; |
8220 |
+ set_bit(CONF_MTU_DONE, &chan->conf_state); |
8221 |
+ } |
8222 |
+- l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); |
8223 |
++ l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu, endptr - ptr); |
8224 |
+ |
8225 |
+ if (remote_efs) { |
8226 |
+ if (chan->local_stype != L2CAP_SERV_NOTRAFIC && |
8227 |
+@@ -3427,7 +3432,7 @@ done: |
8228 |
+ |
8229 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
8230 |
+ sizeof(efs), |
8231 |
+- (unsigned long) &efs); |
8232 |
++ (unsigned long) &efs, endptr - ptr); |
8233 |
+ } else { |
8234 |
+ /* Send PENDING Conf Rsp */ |
8235 |
+ result = L2CAP_CONF_PENDING; |
8236 |
+@@ -3460,7 +3465,7 @@ done: |
8237 |
+ set_bit(CONF_MODE_DONE, &chan->conf_state); |
8238 |
+ |
8239 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
8240 |
+- sizeof(rfc), (unsigned long) &rfc); |
8241 |
++ sizeof(rfc), (unsigned long) &rfc, endptr - ptr); |
8242 |
+ |
8243 |
+ if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { |
8244 |
+ chan->remote_id = efs.id; |
8245 |
+@@ -3474,7 +3479,7 @@ done: |
8246 |
+ le32_to_cpu(efs.sdu_itime); |
8247 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
8248 |
+ sizeof(efs), |
8249 |
+- (unsigned long) &efs); |
8250 |
++ (unsigned long) &efs, endptr - ptr); |
8251 |
+ } |
8252 |
+ break; |
8253 |
+ |
8254 |
+@@ -3488,7 +3493,7 @@ done: |
8255 |
+ set_bit(CONF_MODE_DONE, &chan->conf_state); |
8256 |
+ |
8257 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
8258 |
+- (unsigned long) &rfc); |
8259 |
++ (unsigned long) &rfc, endptr - ptr); |
8260 |
+ |
8261 |
+ break; |
8262 |
+ |
8263 |
+@@ -3510,10 +3515,11 @@ done: |
8264 |
+ } |
8265 |
+ |
8266 |
+ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
8267 |
+- void *data, u16 *result) |
8268 |
++ void *data, size_t size, u16 *result) |
8269 |
+ { |
8270 |
+ struct l2cap_conf_req *req = data; |
8271 |
+ void *ptr = req->data; |
8272 |
++ void *endptr = data + size; |
8273 |
+ int type, olen; |
8274 |
+ unsigned long val; |
8275 |
+ struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; |
8276 |
+@@ -3531,13 +3537,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
8277 |
+ chan->imtu = L2CAP_DEFAULT_MIN_MTU; |
8278 |
+ } else |
8279 |
+ chan->imtu = val; |
8280 |
+- l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu); |
8281 |
++ l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu, endptr - ptr); |
8282 |
+ break; |
8283 |
+ |
8284 |
+ case L2CAP_CONF_FLUSH_TO: |
8285 |
+ chan->flush_to = val; |
8286 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, |
8287 |
+- 2, chan->flush_to); |
8288 |
++ 2, chan->flush_to, endptr - ptr); |
8289 |
+ break; |
8290 |
+ |
8291 |
+ case L2CAP_CONF_RFC: |
8292 |
+@@ -3551,13 +3557,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
8293 |
+ chan->fcs = 0; |
8294 |
+ |
8295 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
8296 |
+- sizeof(rfc), (unsigned long) &rfc); |
8297 |
++ sizeof(rfc), (unsigned long) &rfc, endptr - ptr); |
8298 |
+ break; |
8299 |
+ |
8300 |
+ case L2CAP_CONF_EWS: |
8301 |
+ chan->ack_win = min_t(u16, val, chan->ack_win); |
8302 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, |
8303 |
+- chan->tx_win); |
8304 |
++ chan->tx_win, endptr - ptr); |
8305 |
+ break; |
8306 |
+ |
8307 |
+ case L2CAP_CONF_EFS: |
8308 |
+@@ -3570,7 +3576,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
8309 |
+ return -ECONNREFUSED; |
8310 |
+ |
8311 |
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), |
8312 |
+- (unsigned long) &efs); |
8313 |
++ (unsigned long) &efs, endptr - ptr); |
8314 |
+ break; |
8315 |
+ |
8316 |
+ case L2CAP_CONF_FCS: |
8317 |
+@@ -3675,7 +3681,7 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) |
8318 |
+ return; |
8319 |
+ |
8320 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
8321 |
+- l2cap_build_conf_req(chan, buf), buf); |
8322 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); |
8323 |
+ chan->num_conf_req++; |
8324 |
+ } |
8325 |
+ |
8326 |
+@@ -3883,7 +3889,7 @@ sendresp: |
8327 |
+ u8 buf[128]; |
8328 |
+ set_bit(CONF_REQ_SENT, &chan->conf_state); |
8329 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
8330 |
+- l2cap_build_conf_req(chan, buf), buf); |
8331 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); |
8332 |
+ chan->num_conf_req++; |
8333 |
+ } |
8334 |
+ |
8335 |
+@@ -3961,7 +3967,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, |
8336 |
+ break; |
8337 |
+ |
8338 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
8339 |
+- l2cap_build_conf_req(chan, req), req); |
8340 |
++ l2cap_build_conf_req(chan, req, sizeof(req)), req); |
8341 |
+ chan->num_conf_req++; |
8342 |
+ break; |
8343 |
+ |
8344 |
+@@ -4073,7 +4079,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, |
8345 |
+ } |
8346 |
+ |
8347 |
+ /* Complete config. */ |
8348 |
+- len = l2cap_parse_conf_req(chan, rsp); |
8349 |
++ len = l2cap_parse_conf_req(chan, rsp, sizeof(rsp)); |
8350 |
+ if (len < 0) { |
8351 |
+ l2cap_send_disconn_req(chan, ECONNRESET); |
8352 |
+ goto unlock; |
8353 |
+@@ -4107,7 +4113,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, |
8354 |
+ if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { |
8355 |
+ u8 buf[64]; |
8356 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
8357 |
+- l2cap_build_conf_req(chan, buf), buf); |
8358 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); |
8359 |
+ chan->num_conf_req++; |
8360 |
+ } |
8361 |
+ |
8362 |
+@@ -4167,7 +4173,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, |
8363 |
+ char buf[64]; |
8364 |
+ |
8365 |
+ len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
8366 |
+- buf, &result); |
8367 |
++ buf, sizeof(buf), &result); |
8368 |
+ if (len < 0) { |
8369 |
+ l2cap_send_disconn_req(chan, ECONNRESET); |
8370 |
+ goto done; |
8371 |
+@@ -4197,7 +4203,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, |
8372 |
+ /* throw out any old stored conf requests */ |
8373 |
+ result = L2CAP_CONF_SUCCESS; |
8374 |
+ len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
8375 |
+- req, &result); |
8376 |
++ req, sizeof(req), &result); |
8377 |
+ if (len < 0) { |
8378 |
+ l2cap_send_disconn_req(chan, ECONNRESET); |
8379 |
+ goto done; |
8380 |
+@@ -4774,7 +4780,7 @@ static void l2cap_do_create(struct l2cap_chan *chan, int result, |
8381 |
+ set_bit(CONF_REQ_SENT, &chan->conf_state); |
8382 |
+ l2cap_send_cmd(chan->conn, l2cap_get_ident(chan->conn), |
8383 |
+ L2CAP_CONF_REQ, |
8384 |
+- l2cap_build_conf_req(chan, buf), buf); |
8385 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), buf); |
8386 |
+ chan->num_conf_req++; |
8387 |
+ } |
8388 |
+ } |
8389 |
+@@ -7430,7 +7436,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) |
8390 |
+ set_bit(CONF_REQ_SENT, &chan->conf_state); |
8391 |
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), |
8392 |
+ L2CAP_CONF_REQ, |
8393 |
+- l2cap_build_conf_req(chan, buf), |
8394 |
++ l2cap_build_conf_req(chan, buf, sizeof(buf)), |
8395 |
+ buf); |
8396 |
+ chan->num_conf_req++; |
8397 |
+ } |
8398 |
+diff --git a/net/dccp/proto.c b/net/dccp/proto.c |
8399 |
+index 52a94016526d..522658179cca 100644 |
8400 |
+--- a/net/dccp/proto.c |
8401 |
++++ b/net/dccp/proto.c |
8402 |
+@@ -24,6 +24,7 @@ |
8403 |
+ #include <net/checksum.h> |
8404 |
+ |
8405 |
+ #include <net/inet_sock.h> |
8406 |
++#include <net/inet_common.h> |
8407 |
+ #include <net/sock.h> |
8408 |
+ #include <net/xfrm.h> |
8409 |
+ |
8410 |
+@@ -170,6 +171,15 @@ const char *dccp_packet_name(const int type) |
8411 |
+ |
8412 |
+ EXPORT_SYMBOL_GPL(dccp_packet_name); |
8413 |
+ |
8414 |
++static void dccp_sk_destruct(struct sock *sk) |
8415 |
++{ |
8416 |
++ struct dccp_sock *dp = dccp_sk(sk); |
8417 |
++ |
8418 |
++ ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); |
8419 |
++ dp->dccps_hc_tx_ccid = NULL; |
8420 |
++ inet_sock_destruct(sk); |
8421 |
++} |
8422 |
++ |
8423 |
+ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) |
8424 |
+ { |
8425 |
+ struct dccp_sock *dp = dccp_sk(sk); |
8426 |
+@@ -179,6 +189,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) |
8427 |
+ icsk->icsk_syn_retries = sysctl_dccp_request_retries; |
8428 |
+ sk->sk_state = DCCP_CLOSED; |
8429 |
+ sk->sk_write_space = dccp_write_space; |
8430 |
++ sk->sk_destruct = dccp_sk_destruct; |
8431 |
+ icsk->icsk_sync_mss = dccp_sync_mss; |
8432 |
+ dp->dccps_mss_cache = 536; |
8433 |
+ dp->dccps_rate_last = jiffies; |
8434 |
+@@ -201,10 +212,7 @@ void dccp_destroy_sock(struct sock *sk) |
8435 |
+ { |
8436 |
+ struct dccp_sock *dp = dccp_sk(sk); |
8437 |
+ |
8438 |
+- /* |
8439 |
+- * DCCP doesn't use sk_write_queue, just sk_send_head |
8440 |
+- * for retransmissions |
8441 |
+- */ |
8442 |
++ __skb_queue_purge(&sk->sk_write_queue); |
8443 |
+ if (sk->sk_send_head != NULL) { |
8444 |
+ kfree_skb(sk->sk_send_head); |
8445 |
+ sk->sk_send_head = NULL; |
8446 |
+@@ -222,8 +230,7 @@ void dccp_destroy_sock(struct sock *sk) |
8447 |
+ dp->dccps_hc_rx_ackvec = NULL; |
8448 |
+ } |
8449 |
+ ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); |
8450 |
+- ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); |
8451 |
+- dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; |
8452 |
++ dp->dccps_hc_rx_ccid = NULL; |
8453 |
+ |
8454 |
+ /* clean up feature negotiation state */ |
8455 |
+ dccp_feat_list_purge(&dp->dccps_featneg); |
8456 |
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
8457 |
+index d935c9815564..1ba4d0964042 100644 |
8458 |
+--- a/net/ipv4/tcp.c |
8459 |
++++ b/net/ipv4/tcp.c |
8460 |
+@@ -2220,6 +2220,10 @@ int tcp_disconnect(struct sock *sk, int flags) |
8461 |
+ tcp_set_ca_state(sk, TCP_CA_Open); |
8462 |
+ tcp_clear_retrans(tp); |
8463 |
+ inet_csk_delack_init(sk); |
8464 |
++ /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0 |
8465 |
++ * issue in __tcp_select_window() |
8466 |
++ */ |
8467 |
++ icsk->icsk_ack.rcv_mss = TCP_MIN_MSS; |
8468 |
+ tcp_init_send_head(sk); |
8469 |
+ memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); |
8470 |
+ __sk_dst_reset(sk); |
8471 |
+diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c |
8472 |
+index 767ee7471c9b..95f98d2444fa 100644 |
8473 |
+--- a/net/ipv4/tcp_input.c |
8474 |
++++ b/net/ipv4/tcp_input.c |
8475 |
+@@ -2989,8 +2989,7 @@ void tcp_rearm_rto(struct sock *sk) |
8476 |
+ /* delta may not be positive if the socket is locked |
8477 |
+ * when the retrans timer fires and is rescheduled. |
8478 |
+ */ |
8479 |
+- if (delta > 0) |
8480 |
+- rto = delta; |
8481 |
++ rto = max(delta, 1); |
8482 |
+ } |
8483 |
+ inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, |
8484 |
+ TCP_RTO_MAX); |
8485 |
+diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c |
8486 |
+index bde57b113009..e7a60f5de097 100644 |
8487 |
+--- a/net/ipv6/ip6_fib.c |
8488 |
++++ b/net/ipv6/ip6_fib.c |
8489 |
+@@ -160,6 +160,12 @@ static void rt6_release(struct rt6_info *rt) |
8490 |
+ dst_free(&rt->dst); |
8491 |
+ } |
8492 |
+ |
8493 |
++static void fib6_free_table(struct fib6_table *table) |
8494 |
++{ |
8495 |
++ inetpeer_invalidate_tree(&table->tb6_peers); |
8496 |
++ kfree(table); |
8497 |
++} |
8498 |
++ |
8499 |
+ static void fib6_link_table(struct net *net, struct fib6_table *tb) |
8500 |
+ { |
8501 |
+ unsigned int h; |
8502 |
+@@ -853,6 +859,8 @@ add: |
8503 |
+ } |
8504 |
+ nsiblings = iter->rt6i_nsiblings; |
8505 |
+ fib6_purge_rt(iter, fn, info->nl_net); |
8506 |
++ if (fn->rr_ptr == iter) |
8507 |
++ fn->rr_ptr = NULL; |
8508 |
+ rt6_release(iter); |
8509 |
+ |
8510 |
+ if (nsiblings) { |
8511 |
+@@ -863,6 +871,8 @@ add: |
8512 |
+ if (rt6_qualify_for_ecmp(iter)) { |
8513 |
+ *ins = iter->dst.rt6_next; |
8514 |
+ fib6_purge_rt(iter, fn, info->nl_net); |
8515 |
++ if (fn->rr_ptr == iter) |
8516 |
++ fn->rr_ptr = NULL; |
8517 |
+ rt6_release(iter); |
8518 |
+ nsiblings--; |
8519 |
+ } else { |
8520 |
+@@ -1818,15 +1828,22 @@ out_timer: |
8521 |
+ |
8522 |
+ static void fib6_net_exit(struct net *net) |
8523 |
+ { |
8524 |
++ unsigned int i; |
8525 |
++ |
8526 |
+ rt6_ifdown(net, NULL); |
8527 |
+ del_timer_sync(&net->ipv6.ip6_fib_timer); |
8528 |
+ |
8529 |
+-#ifdef CONFIG_IPV6_MULTIPLE_TABLES |
8530 |
+- inetpeer_invalidate_tree(&net->ipv6.fib6_local_tbl->tb6_peers); |
8531 |
+- kfree(net->ipv6.fib6_local_tbl); |
8532 |
+-#endif |
8533 |
+- inetpeer_invalidate_tree(&net->ipv6.fib6_main_tbl->tb6_peers); |
8534 |
+- kfree(net->ipv6.fib6_main_tbl); |
8535 |
++ for (i = 0; i < FIB6_TABLE_HASHSZ; i++) { |
8536 |
++ struct hlist_head *head = &net->ipv6.fib_table_hash[i]; |
8537 |
++ struct hlist_node *tmp; |
8538 |
++ struct fib6_table *tb; |
8539 |
++ |
8540 |
++ hlist_for_each_entry_safe(tb, tmp, head, tb6_hlist) { |
8541 |
++ hlist_del(&tb->tb6_hlist); |
8542 |
++ fib6_free_table(tb); |
8543 |
++ } |
8544 |
++ } |
8545 |
++ |
8546 |
+ kfree(net->ipv6.fib_table_hash); |
8547 |
+ kfree(net->ipv6.rt6_stats); |
8548 |
+ } |
8549 |
+diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c |
8550 |
+index 606a07890c68..1cb68e01c301 100644 |
8551 |
+--- a/net/ipv6/ip6_offload.c |
8552 |
++++ b/net/ipv6/ip6_offload.c |
8553 |
+@@ -261,19 +261,6 @@ out: |
8554 |
+ return pp; |
8555 |
+ } |
8556 |
+ |
8557 |
+-static struct sk_buff **sit_gro_receive(struct sk_buff **head, |
8558 |
+- struct sk_buff *skb) |
8559 |
+-{ |
8560 |
+- if (NAPI_GRO_CB(skb)->encap_mark) { |
8561 |
+- NAPI_GRO_CB(skb)->flush = 1; |
8562 |
+- return NULL; |
8563 |
+- } |
8564 |
+- |
8565 |
+- NAPI_GRO_CB(skb)->encap_mark = 1; |
8566 |
+- |
8567 |
+- return ipv6_gro_receive(head, skb); |
8568 |
+-} |
8569 |
+- |
8570 |
+ static int ipv6_gro_complete(struct sk_buff *skb, int nhoff) |
8571 |
+ { |
8572 |
+ const struct net_offload *ops; |
8573 |
+diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c |
8574 |
+index 292ef2e584db..7c6159b1481a 100644 |
8575 |
+--- a/net/ipv6/output_core.c |
8576 |
++++ b/net/ipv6/output_core.c |
8577 |
+@@ -84,7 +84,6 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
8578 |
+ |
8579 |
+ while (offset <= packet_len) { |
8580 |
+ struct ipv6_opt_hdr *exthdr; |
8581 |
+- unsigned int len; |
8582 |
+ |
8583 |
+ switch (**nexthdr) { |
8584 |
+ |
8585 |
+@@ -110,10 +109,9 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
8586 |
+ |
8587 |
+ exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + |
8588 |
+ offset); |
8589 |
+- len = ipv6_optlen(exthdr); |
8590 |
+- if (len + offset >= IPV6_MAXPLEN) |
8591 |
++ offset += ipv6_optlen(exthdr); |
8592 |
++ if (offset > IPV6_MAXPLEN) |
8593 |
+ return -EINVAL; |
8594 |
+- offset += len; |
8595 |
+ *nexthdr = &exthdr->nexthdr; |
8596 |
+ } |
8597 |
+ |
8598 |
+diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c |
8599 |
+index eca46d3d3ff3..d7637c9218bd 100644 |
8600 |
+--- a/net/irda/af_irda.c |
8601 |
++++ b/net/irda/af_irda.c |
8602 |
+@@ -2228,7 +2228,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, |
8603 |
+ { |
8604 |
+ struct sock *sk = sock->sk; |
8605 |
+ struct irda_sock *self = irda_sk(sk); |
8606 |
+- struct irda_device_list list; |
8607 |
++ struct irda_device_list list = { 0 }; |
8608 |
+ struct irda_device_info *discoveries; |
8609 |
+ struct irda_ias_set * ias_opt; /* IAS get/query params */ |
8610 |
+ struct ias_object * ias_obj; /* Object in IAS */ |
8611 |
+diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c |
8612 |
+index 1a9545965c0d..531ca55f1af6 100644 |
8613 |
+--- a/net/netfilter/nf_conntrack_extend.c |
8614 |
++++ b/net/netfilter/nf_conntrack_extend.c |
8615 |
+@@ -53,7 +53,11 @@ nf_ct_ext_create(struct nf_ct_ext **ext, enum nf_ct_ext_id id, |
8616 |
+ |
8617 |
+ rcu_read_lock(); |
8618 |
+ t = rcu_dereference(nf_ct_ext_types[id]); |
8619 |
+- BUG_ON(t == NULL); |
8620 |
++ if (!t) { |
8621 |
++ rcu_read_unlock(); |
8622 |
++ return NULL; |
8623 |
++ } |
8624 |
++ |
8625 |
+ off = ALIGN(sizeof(struct nf_ct_ext), t->align); |
8626 |
+ len = off + t->len + var_alloc_len; |
8627 |
+ alloc_size = t->alloc_size + var_alloc_len; |
8628 |
+@@ -88,7 +92,10 @@ void *__nf_ct_ext_add_length(struct nf_conn *ct, enum nf_ct_ext_id id, |
8629 |
+ |
8630 |
+ rcu_read_lock(); |
8631 |
+ t = rcu_dereference(nf_ct_ext_types[id]); |
8632 |
+- BUG_ON(t == NULL); |
8633 |
++ if (!t) { |
8634 |
++ rcu_read_unlock(); |
8635 |
++ return NULL; |
8636 |
++ } |
8637 |
+ |
8638 |
+ newoff = ALIGN(old->len, t->align); |
8639 |
+ newlen = newoff + t->len + var_alloc_len; |
8640 |
+@@ -186,6 +193,6 @@ void nf_ct_extend_unregister(struct nf_ct_ext_type *type) |
8641 |
+ RCU_INIT_POINTER(nf_ct_ext_types[type->id], NULL); |
8642 |
+ update_alloc_size(type); |
8643 |
+ mutex_unlock(&nf_ct_ext_type_mutex); |
8644 |
+- rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
8645 |
++ synchronize_rcu(); |
8646 |
+ } |
8647 |
+ EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); |
8648 |
+diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c |
8649 |
+index fdcced6aa71d..78d0eaf5de61 100644 |
8650 |
+--- a/net/sched/sch_sfq.c |
8651 |
++++ b/net/sched/sch_sfq.c |
8652 |
+@@ -457,6 +457,7 @@ congestion_drop: |
8653 |
+ qdisc_drop(head, sch); |
8654 |
+ |
8655 |
+ slot_queue_add(slot, skb); |
8656 |
++ qdisc_tree_reduce_backlog(sch, 0, delta); |
8657 |
+ return NET_XMIT_CN; |
8658 |
+ } |
8659 |
+ |
8660 |
+@@ -488,8 +489,10 @@ enqueue: |
8661 |
+ /* Return Congestion Notification only if we dropped a packet |
8662 |
+ * from this flow. |
8663 |
+ */ |
8664 |
+- if (qlen != slot->qlen) |
8665 |
++ if (qlen != slot->qlen) { |
8666 |
++ qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb)); |
8667 |
+ return NET_XMIT_CN; |
8668 |
++ } |
8669 |
+ |
8670 |
+ /* As we dropped a packet, better let upper stack know this */ |
8671 |
+ qdisc_tree_reduce_backlog(sch, 1, dropped); |
8672 |
+diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c |
8673 |
+index 29fa707d61fd..2bb7240c6f8b 100644 |
8674 |
+--- a/net/sctp/ipv6.c |
8675 |
++++ b/net/sctp/ipv6.c |
8676 |
+@@ -491,7 +491,9 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr, |
8677 |
+ { |
8678 |
+ addr->sa.sa_family = AF_INET6; |
8679 |
+ addr->v6.sin6_port = port; |
8680 |
++ addr->v6.sin6_flowinfo = 0; |
8681 |
+ addr->v6.sin6_addr = *saddr; |
8682 |
++ addr->v6.sin6_scope_id = 0; |
8683 |
+ } |
8684 |
+ |
8685 |
+ /* Compare addresses exactly. |
8686 |
+diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c |
8687 |
+index e5ec86dd8dc1..a8dd585fcc38 100644 |
8688 |
+--- a/net/tipc/netlink_compat.c |
8689 |
++++ b/net/tipc/netlink_compat.c |
8690 |
+@@ -256,13 +256,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, |
8691 |
+ arg = nlmsg_new(0, GFP_KERNEL); |
8692 |
+ if (!arg) { |
8693 |
+ kfree_skb(msg->rep); |
8694 |
++ msg->rep = NULL; |
8695 |
+ return -ENOMEM; |
8696 |
+ } |
8697 |
+ |
8698 |
+ err = __tipc_nl_compat_dumpit(cmd, msg, arg); |
8699 |
+- if (err) |
8700 |
++ if (err) { |
8701 |
+ kfree_skb(msg->rep); |
8702 |
+- |
8703 |
++ msg->rep = NULL; |
8704 |
++ } |
8705 |
+ kfree_skb(arg); |
8706 |
+ |
8707 |
+ return err; |
8708 |
+diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c |
8709 |
+index 155070f500aa..04a025218d13 100644 |
8710 |
+--- a/net/xfrm/xfrm_policy.c |
8711 |
++++ b/net/xfrm/xfrm_policy.c |
8712 |
+@@ -3255,9 +3255,15 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, |
8713 |
+ struct xfrm_state *x_new[XFRM_MAX_DEPTH]; |
8714 |
+ struct xfrm_migrate *mp; |
8715 |
+ |
8716 |
++ /* Stage 0 - sanity checks */ |
8717 |
+ if ((err = xfrm_migrate_check(m, num_migrate)) < 0) |
8718 |
+ goto out; |
8719 |
+ |
8720 |
++ if (dir >= XFRM_POLICY_MAX) { |
8721 |
++ err = -EINVAL; |
8722 |
++ goto out; |
8723 |
++ } |
8724 |
++ |
8725 |
+ /* Stage 1 - find policy */ |
8726 |
+ if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) { |
8727 |
+ err = -ENOENT; |
8728 |
+diff --git a/sound/core/control.c b/sound/core/control.c |
8729 |
+index b4fe9b002512..bd01d492f46a 100644 |
8730 |
+--- a/sound/core/control.c |
8731 |
++++ b/sound/core/control.c |
8732 |
+@@ -1126,7 +1126,7 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, |
8733 |
+ mutex_lock(&ue->card->user_ctl_lock); |
8734 |
+ change = ue->tlv_data_size != size; |
8735 |
+ if (!change) |
8736 |
+- change = memcmp(ue->tlv_data, new_data, size); |
8737 |
++ change = memcmp(ue->tlv_data, new_data, size) != 0; |
8738 |
+ kfree(ue->tlv_data); |
8739 |
+ ue->tlv_data = new_data; |
8740 |
+ ue->tlv_data_size = size; |
8741 |
+diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c |
8742 |
+index 8158ba354b48..b6f5f47048ba 100644 |
8743 |
+--- a/sound/core/seq/seq_clientmgr.c |
8744 |
++++ b/sound/core/seq/seq_clientmgr.c |
8745 |
+@@ -1530,19 +1530,14 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, |
8746 |
+ void __user *arg) |
8747 |
+ { |
8748 |
+ struct snd_seq_queue_info info; |
8749 |
+- int result; |
8750 |
+ struct snd_seq_queue *q; |
8751 |
+ |
8752 |
+ if (copy_from_user(&info, arg, sizeof(info))) |
8753 |
+ return -EFAULT; |
8754 |
+ |
8755 |
+- result = snd_seq_queue_alloc(client->number, info.locked, info.flags); |
8756 |
+- if (result < 0) |
8757 |
+- return result; |
8758 |
+- |
8759 |
+- q = queueptr(result); |
8760 |
+- if (q == NULL) |
8761 |
+- return -EINVAL; |
8762 |
++ q = snd_seq_queue_alloc(client->number, info.locked, info.flags); |
8763 |
++ if (IS_ERR(q)) |
8764 |
++ return PTR_ERR(q); |
8765 |
+ |
8766 |
+ info.queue = q->queue; |
8767 |
+ info.locked = q->locked; |
8768 |
+@@ -1552,7 +1547,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, |
8769 |
+ if (! info.name[0]) |
8770 |
+ snprintf(info.name, sizeof(info.name), "Queue-%d", q->queue); |
8771 |
+ strlcpy(q->name, info.name, sizeof(q->name)); |
8772 |
+- queuefree(q); |
8773 |
++ snd_use_lock_free(&q->use_lock); |
8774 |
+ |
8775 |
+ if (copy_to_user(arg, &info, sizeof(info))) |
8776 |
+ return -EFAULT; |
8777 |
+diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c |
8778 |
+index f676ae53c477..a7bd074f6c0e 100644 |
8779 |
+--- a/sound/core/seq/seq_queue.c |
8780 |
++++ b/sound/core/seq/seq_queue.c |
8781 |
+@@ -184,22 +184,26 @@ void __exit snd_seq_queues_delete(void) |
8782 |
+ static void queue_use(struct snd_seq_queue *queue, int client, int use); |
8783 |
+ |
8784 |
+ /* allocate a new queue - |
8785 |
+- * return queue index value or negative value for error |
8786 |
++ * return pointer to new queue or ERR_PTR(-errno) for error |
8787 |
++ * The new queue's use_lock is set to 1. It is the caller's responsibility to |
8788 |
++ * call snd_use_lock_free(&q->use_lock). |
8789 |
+ */ |
8790 |
+-int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) |
8791 |
++struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) |
8792 |
+ { |
8793 |
+ struct snd_seq_queue *q; |
8794 |
+ |
8795 |
+ q = queue_new(client, locked); |
8796 |
+ if (q == NULL) |
8797 |
+- return -ENOMEM; |
8798 |
++ return ERR_PTR(-ENOMEM); |
8799 |
+ q->info_flags = info_flags; |
8800 |
+ queue_use(q, client, 1); |
8801 |
++ snd_use_lock_use(&q->use_lock); |
8802 |
+ if (queue_list_add(q) < 0) { |
8803 |
++ snd_use_lock_free(&q->use_lock); |
8804 |
+ queue_delete(q); |
8805 |
+- return -ENOMEM; |
8806 |
++ return ERR_PTR(-ENOMEM); |
8807 |
+ } |
8808 |
+- return q->queue; |
8809 |
++ return q; |
8810 |
+ } |
8811 |
+ |
8812 |
+ /* delete a queue - queue must be owned by the client */ |
8813 |
+diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h |
8814 |
+index 30c8111477f6..719093489a2c 100644 |
8815 |
+--- a/sound/core/seq/seq_queue.h |
8816 |
++++ b/sound/core/seq/seq_queue.h |
8817 |
+@@ -71,7 +71,7 @@ void snd_seq_queues_delete(void); |
8818 |
+ |
8819 |
+ |
8820 |
+ /* create new queue (constructor) */ |
8821 |
+-int snd_seq_queue_alloc(int client, int locked, unsigned int flags); |
8822 |
++struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags); |
8823 |
+ |
8824 |
+ /* delete queue (destructor) */ |
8825 |
+ int snd_seq_queue_delete(int client, int queueid); |
8826 |
+diff --git a/sound/isa/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c |
8827 |
+index ffc67fd80c23..58e59cd3c95c 100644 |
8828 |
+--- a/sound/isa/msnd/msnd_midi.c |
8829 |
++++ b/sound/isa/msnd/msnd_midi.c |
8830 |
+@@ -120,24 +120,24 @@ void snd_msndmidi_input_read(void *mpuv) |
8831 |
+ unsigned long flags; |
8832 |
+ struct snd_msndmidi *mpu = mpuv; |
8833 |
+ void *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF; |
8834 |
++ u16 head, tail, size; |
8835 |
+ |
8836 |
+ spin_lock_irqsave(&mpu->input_lock, flags); |
8837 |
+- while (readw(mpu->dev->MIDQ + JQS_wTail) != |
8838 |
+- readw(mpu->dev->MIDQ + JQS_wHead)) { |
8839 |
+- u16 wTmp, val; |
8840 |
+- val = readw(pwMIDQData + 2 * readw(mpu->dev->MIDQ + JQS_wHead)); |
8841 |
+- |
8842 |
+- if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, |
8843 |
+- &mpu->mode)) |
8844 |
+- snd_rawmidi_receive(mpu->substream_input, |
8845 |
+- (unsigned char *)&val, 1); |
8846 |
+- |
8847 |
+- wTmp = readw(mpu->dev->MIDQ + JQS_wHead) + 1; |
8848 |
+- if (wTmp > readw(mpu->dev->MIDQ + JQS_wSize)) |
8849 |
+- writew(0, mpu->dev->MIDQ + JQS_wHead); |
8850 |
+- else |
8851 |
+- writew(wTmp, mpu->dev->MIDQ + JQS_wHead); |
8852 |
++ head = readw(mpu->dev->MIDQ + JQS_wHead); |
8853 |
++ tail = readw(mpu->dev->MIDQ + JQS_wTail); |
8854 |
++ size = readw(mpu->dev->MIDQ + JQS_wSize); |
8855 |
++ if (head > size || tail > size) |
8856 |
++ goto out; |
8857 |
++ while (head != tail) { |
8858 |
++ unsigned char val = readw(pwMIDQData + 2 * head); |
8859 |
++ |
8860 |
++ if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode)) |
8861 |
++ snd_rawmidi_receive(mpu->substream_input, &val, 1); |
8862 |
++ if (++head > size) |
8863 |
++ head = 0; |
8864 |
++ writew(head, mpu->dev->MIDQ + JQS_wHead); |
8865 |
+ } |
8866 |
++ out: |
8867 |
+ spin_unlock_irqrestore(&mpu->input_lock, flags); |
8868 |
+ } |
8869 |
+ EXPORT_SYMBOL(snd_msndmidi_input_read); |
8870 |
+diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c |
8871 |
+index 4c072666115d..a31ea6c22d19 100644 |
8872 |
+--- a/sound/isa/msnd/msnd_pinnacle.c |
8873 |
++++ b/sound/isa/msnd/msnd_pinnacle.c |
8874 |
+@@ -170,23 +170,24 @@ static irqreturn_t snd_msnd_interrupt(int irq, void *dev_id) |
8875 |
+ { |
8876 |
+ struct snd_msnd *chip = dev_id; |
8877 |
+ void *pwDSPQData = chip->mappedbase + DSPQ_DATA_BUFF; |
8878 |
++ u16 head, tail, size; |
8879 |
+ |
8880 |
+ /* Send ack to DSP */ |
8881 |
+ /* inb(chip->io + HP_RXL); */ |
8882 |
+ |
8883 |
+ /* Evaluate queued DSP messages */ |
8884 |
+- while (readw(chip->DSPQ + JQS_wTail) != readw(chip->DSPQ + JQS_wHead)) { |
8885 |
+- u16 wTmp; |
8886 |
+- |
8887 |
+- snd_msnd_eval_dsp_msg(chip, |
8888 |
+- readw(pwDSPQData + 2 * readw(chip->DSPQ + JQS_wHead))); |
8889 |
+- |
8890 |
+- wTmp = readw(chip->DSPQ + JQS_wHead) + 1; |
8891 |
+- if (wTmp > readw(chip->DSPQ + JQS_wSize)) |
8892 |
+- writew(0, chip->DSPQ + JQS_wHead); |
8893 |
+- else |
8894 |
+- writew(wTmp, chip->DSPQ + JQS_wHead); |
8895 |
++ head = readw(chip->DSPQ + JQS_wHead); |
8896 |
++ tail = readw(chip->DSPQ + JQS_wTail); |
8897 |
++ size = readw(chip->DSPQ + JQS_wSize); |
8898 |
++ if (head > size || tail > size) |
8899 |
++ goto out; |
8900 |
++ while (head != tail) { |
8901 |
++ snd_msnd_eval_dsp_msg(chip, readw(pwDSPQData + 2 * head)); |
8902 |
++ if (++head > size) |
8903 |
++ head = 0; |
8904 |
++ writew(head, chip->DSPQ + JQS_wHead); |
8905 |
+ } |
8906 |
++ out: |
8907 |
+ /* Send ack to DSP */ |
8908 |
+ inb(chip->io + HP_RXL); |
8909 |
+ return IRQ_HANDLED; |
8910 |
+diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c |
8911 |
+index 74177189063c..d3125c169684 100644 |
8912 |
+--- a/sound/pci/au88x0/au88x0_core.c |
8913 |
++++ b/sound/pci/au88x0/au88x0_core.c |
8914 |
+@@ -2150,8 +2150,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, |
8915 |
+ stream->resources, en, |
8916 |
+ VORTEX_RESOURCE_SRC)) < 0) { |
8917 |
+ memset(stream->resources, 0, |
8918 |
+- sizeof(unsigned char) * |
8919 |
+- VORTEX_RESOURCE_LAST); |
8920 |
++ sizeof(stream->resources)); |
8921 |
+ return -EBUSY; |
8922 |
+ } |
8923 |
+ if (stream->type != VORTEX_PCM_A3D) { |
8924 |
+@@ -2161,7 +2160,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, |
8925 |
+ VORTEX_RESOURCE_MIXIN)) < 0) { |
8926 |
+ memset(stream->resources, |
8927 |
+ 0, |
8928 |
+- sizeof(unsigned char) * VORTEX_RESOURCE_LAST); |
8929 |
++ sizeof(stream->resources)); |
8930 |
+ return -EBUSY; |
8931 |
+ } |
8932 |
+ } |
8933 |
+@@ -2174,8 +2173,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, |
8934 |
+ stream->resources, en, |
8935 |
+ VORTEX_RESOURCE_A3D)) < 0) { |
8936 |
+ memset(stream->resources, 0, |
8937 |
+- sizeof(unsigned char) * |
8938 |
+- VORTEX_RESOURCE_LAST); |
8939 |
++ sizeof(stream->resources)); |
8940 |
+ dev_err(vortex->card->dev, |
8941 |
+ "out of A3D sources. Sorry\n"); |
8942 |
+ return -EBUSY; |
8943 |
+@@ -2289,8 +2287,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, |
8944 |
+ VORTEX_RESOURCE_MIXOUT)) |
8945 |
+ < 0) { |
8946 |
+ memset(stream->resources, 0, |
8947 |
+- sizeof(unsigned char) * |
8948 |
+- VORTEX_RESOURCE_LAST); |
8949 |
++ sizeof(stream->resources)); |
8950 |
+ return -EBUSY; |
8951 |
+ } |
8952 |
+ if ((src[i] = |
8953 |
+@@ -2298,8 +2295,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, |
8954 |
+ stream->resources, en, |
8955 |
+ VORTEX_RESOURCE_SRC)) < 0) { |
8956 |
+ memset(stream->resources, 0, |
8957 |
+- sizeof(unsigned char) * |
8958 |
+- VORTEX_RESOURCE_LAST); |
8959 |
++ sizeof(stream->resources)); |
8960 |
+ return -EBUSY; |
8961 |
+ } |
8962 |
+ } |
8963 |
+diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c |
8964 |
+index 91b77bad03ea..a780540b7d4f 100644 |
8965 |
+--- a/sound/pci/hda/patch_conexant.c |
8966 |
++++ b/sound/pci/hda/patch_conexant.c |
8967 |
+@@ -827,6 +827,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { |
8968 |
+ SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC), |
8969 |
+ SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), |
8970 |
+ SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), |
8971 |
++ SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC), |
8972 |
+ SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), |
8973 |
+ SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), |
8974 |
+ SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), |
8975 |
+diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c |
8976 |
+index 7bb9c087f3dc..4599983cfc8a 100644 |
8977 |
+--- a/sound/soc/sh/rcar/ssi.c |
8978 |
++++ b/sound/soc/sh/rcar/ssi.c |
8979 |
+@@ -39,6 +39,7 @@ |
8980 |
+ #define SCKP (1 << 13) /* Serial Bit Clock Polarity */ |
8981 |
+ #define SWSP (1 << 12) /* Serial WS Polarity */ |
8982 |
+ #define SDTA (1 << 10) /* Serial Data Alignment */ |
8983 |
++#define PDTA (1 << 9) /* Parallel Data Alignment */ |
8984 |
+ #define DEL (1 << 8) /* Serial Data Delay */ |
8985 |
+ #define CKDV(v) (v << 4) /* Serial Clock Division Ratio */ |
8986 |
+ #define TRMD (1 << 1) /* Transmit/Receive Mode Select */ |
8987 |
+@@ -278,7 +279,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, |
8988 |
+ struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); |
8989 |
+ u32 cr; |
8990 |
+ |
8991 |
+- cr = FORCE; |
8992 |
++ cr = FORCE | PDTA; |
8993 |
+ |
8994 |
+ /* |
8995 |
+ * always use 32bit system word for easy clock calculation. |
8996 |
+diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c |
8997 |
+index 4a033cbbd361..33c544acf3f6 100644 |
8998 |
+--- a/sound/usb/mixer.c |
8999 |
++++ b/sound/usb/mixer.c |
9000 |
+@@ -541,6 +541,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
9001 |
+ |
9002 |
+ if (size < sizeof(scale)) |
9003 |
+ return -ENOMEM; |
9004 |
++ if (cval->min_mute) |
9005 |
++ scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE; |
9006 |
+ scale[2] = cval->dBmin; |
9007 |
+ scale[3] = cval->dBmax; |
9008 |
+ if (copy_to_user(_tlv, scale, sizeof(scale))) |
9009 |
+diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h |
9010 |
+index 3417ef347e40..2b4b067646ab 100644 |
9011 |
+--- a/sound/usb/mixer.h |
9012 |
++++ b/sound/usb/mixer.h |
9013 |
+@@ -64,6 +64,7 @@ struct usb_mixer_elem_info { |
9014 |
+ int cached; |
9015 |
+ int cache_val[MAX_CHANNELS]; |
9016 |
+ u8 initialized; |
9017 |
++ u8 min_mute; |
9018 |
+ void *private_data; |
9019 |
+ }; |
9020 |
+ |
9021 |
+diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c |
9022 |
+index 940442848fc8..de3f18059213 100644 |
9023 |
+--- a/sound/usb/mixer_quirks.c |
9024 |
++++ b/sound/usb/mixer_quirks.c |
9025 |
+@@ -1863,6 +1863,12 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, |
9026 |
+ if (unitid == 7 && cval->min == 0 && cval->max == 50) |
9027 |
+ snd_dragonfly_quirk_db_scale(mixer, kctl); |
9028 |
+ break; |
9029 |
++ /* lowest playback value is muted on C-Media devices */ |
9030 |
++ case USB_ID(0x0d8c, 0x000c): |
9031 |
++ case USB_ID(0x0d8c, 0x0014): |
9032 |
++ if (strstr(kctl->id.name, "Playback")) |
9033 |
++ cval->min_mute = 1; |
9034 |
++ break; |
9035 |
+ } |
9036 |
+ } |
9037 |
+ |
9038 |
+diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
9039 |
+index 2c71e5682716..693b2ac6720a 100644 |
9040 |
+--- a/sound/usb/quirks.c |
9041 |
++++ b/sound/usb/quirks.c |
9042 |
+@@ -1138,6 +1138,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) |
9043 |
+ case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ |
9044 |
+ case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ |
9045 |
+ case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
9046 |
++ case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ |
9047 |
+ case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ |
9048 |
+ case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ |
9049 |
+ case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ |