Contents of /trunk/kernel-alx/patches-4.14/0143-4.14.44-all-fixes.patch
Parent Directory | Revision Log
Revision 3238 -
(show annotations)
(download)
Fri Nov 9 12:14:58 2018 UTC (5 years, 10 months ago) by niro
File size: 209535 byte(s)
Fri Nov 9 12:14:58 2018 UTC (5 years, 10 months ago) by niro
File size: 209535 byte(s)
-added up to patches-4.14.79
1 | diff --git a/Makefile b/Makefile |
2 | index 9be88c9d9fc9..787cf6605209 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,7 +1,7 @@ |
6 | # SPDX-License-Identifier: GPL-2.0 |
7 | VERSION = 4 |
8 | PATCHLEVEL = 14 |
9 | -SUBLEVEL = 43 |
10 | +SUBLEVEL = 44 |
11 | EXTRAVERSION = |
12 | NAME = Petit Gorille |
13 | |
14 | diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts |
15 | index 44637cabcc56..255e64ba32e2 100644 |
16 | --- a/arch/arm/boot/dts/imx7d-sdb.dts |
17 | +++ b/arch/arm/boot/dts/imx7d-sdb.dts |
18 | @@ -82,7 +82,7 @@ |
19 | enable-active-high; |
20 | }; |
21 | |
22 | - reg_usb_otg2_vbus: regulator-usb-otg1-vbus { |
23 | + reg_usb_otg2_vbus: regulator-usb-otg2-vbus { |
24 | compatible = "regulator-fixed"; |
25 | regulator-name = "usb_otg2_vbus"; |
26 | regulator-min-microvolt = <5000000>; |
27 | diff --git a/arch/s390/crypto/crc32be-vx.S b/arch/s390/crypto/crc32be-vx.S |
28 | index e8077f0971f8..2bf01ba44107 100644 |
29 | --- a/arch/s390/crypto/crc32be-vx.S |
30 | +++ b/arch/s390/crypto/crc32be-vx.S |
31 | @@ -13,6 +13,7 @@ |
32 | */ |
33 | |
34 | #include <linux/linkage.h> |
35 | +#include <asm/nospec-insn.h> |
36 | #include <asm/vx-insn.h> |
37 | |
38 | /* Vector register range containing CRC-32 constants */ |
39 | @@ -67,6 +68,8 @@ |
40 | |
41 | .previous |
42 | |
43 | + GEN_BR_THUNK %r14 |
44 | + |
45 | .text |
46 | /* |
47 | * The CRC-32 function(s) use these calling conventions: |
48 | @@ -203,6 +206,6 @@ ENTRY(crc32_be_vgfm_16) |
49 | |
50 | .Ldone: |
51 | VLGVF %r2,%v2,3 |
52 | - br %r14 |
53 | + BR_EX %r14 |
54 | |
55 | .previous |
56 | diff --git a/arch/s390/crypto/crc32le-vx.S b/arch/s390/crypto/crc32le-vx.S |
57 | index d8c67a58c0c5..7d6f568bd3ad 100644 |
58 | --- a/arch/s390/crypto/crc32le-vx.S |
59 | +++ b/arch/s390/crypto/crc32le-vx.S |
60 | @@ -14,6 +14,7 @@ |
61 | */ |
62 | |
63 | #include <linux/linkage.h> |
64 | +#include <asm/nospec-insn.h> |
65 | #include <asm/vx-insn.h> |
66 | |
67 | /* Vector register range containing CRC-32 constants */ |
68 | @@ -76,6 +77,7 @@ |
69 | |
70 | .previous |
71 | |
72 | + GEN_BR_THUNK %r14 |
73 | |
74 | .text |
75 | |
76 | @@ -264,6 +266,6 @@ crc32_le_vgfm_generic: |
77 | |
78 | .Ldone: |
79 | VLGVF %r2,%v2,2 |
80 | - br %r14 |
81 | + BR_EX %r14 |
82 | |
83 | .previous |
84 | diff --git a/arch/s390/include/asm/alternative-asm.h b/arch/s390/include/asm/alternative-asm.h |
85 | new file mode 100644 |
86 | index 000000000000..955d620db23e |
87 | --- /dev/null |
88 | +++ b/arch/s390/include/asm/alternative-asm.h |
89 | @@ -0,0 +1,108 @@ |
90 | +/* SPDX-License-Identifier: GPL-2.0 */ |
91 | +#ifndef _ASM_S390_ALTERNATIVE_ASM_H |
92 | +#define _ASM_S390_ALTERNATIVE_ASM_H |
93 | + |
94 | +#ifdef __ASSEMBLY__ |
95 | + |
96 | +/* |
97 | + * Check the length of an instruction sequence. The length may not be larger |
98 | + * than 254 bytes and it has to be divisible by 2. |
99 | + */ |
100 | +.macro alt_len_check start,end |
101 | + .if ( \end - \start ) > 254 |
102 | + .error "cpu alternatives does not support instructions blocks > 254 bytes\n" |
103 | + .endif |
104 | + .if ( \end - \start ) % 2 |
105 | + .error "cpu alternatives instructions length is odd\n" |
106 | + .endif |
107 | +.endm |
108 | + |
109 | +/* |
110 | + * Issue one struct alt_instr descriptor entry (need to put it into |
111 | + * the section .altinstructions, see below). This entry contains |
112 | + * enough information for the alternatives patching code to patch an |
113 | + * instruction. See apply_alternatives(). |
114 | + */ |
115 | +.macro alt_entry orig_start, orig_end, alt_start, alt_end, feature |
116 | + .long \orig_start - . |
117 | + .long \alt_start - . |
118 | + .word \feature |
119 | + .byte \orig_end - \orig_start |
120 | + .byte \alt_end - \alt_start |
121 | +.endm |
122 | + |
123 | +/* |
124 | + * Fill up @bytes with nops. The macro emits 6-byte nop instructions |
125 | + * for the bulk of the area, possibly followed by a 4-byte and/or |
126 | + * a 2-byte nop if the size of the area is not divisible by 6. |
127 | + */ |
128 | +.macro alt_pad_fill bytes |
129 | + .fill ( \bytes ) / 6, 6, 0xc0040000 |
130 | + .fill ( \bytes ) % 6 / 4, 4, 0x47000000 |
131 | + .fill ( \bytes ) % 6 % 4 / 2, 2, 0x0700 |
132 | +.endm |
133 | + |
134 | +/* |
135 | + * Fill up @bytes with nops. If the number of bytes is larger |
136 | + * than 6, emit a jg instruction to branch over all nops, then |
137 | + * fill an area of size (@bytes - 6) with nop instructions. |
138 | + */ |
139 | +.macro alt_pad bytes |
140 | + .if ( \bytes > 0 ) |
141 | + .if ( \bytes > 6 ) |
142 | + jg . + \bytes |
143 | + alt_pad_fill \bytes - 6 |
144 | + .else |
145 | + alt_pad_fill \bytes |
146 | + .endif |
147 | + .endif |
148 | +.endm |
149 | + |
150 | +/* |
151 | + * Define an alternative between two instructions. If @feature is |
152 | + * present, early code in apply_alternatives() replaces @oldinstr with |
153 | + * @newinstr. ".skip" directive takes care of proper instruction padding |
154 | + * in case @newinstr is longer than @oldinstr. |
155 | + */ |
156 | +.macro ALTERNATIVE oldinstr, newinstr, feature |
157 | + .pushsection .altinstr_replacement,"ax" |
158 | +770: \newinstr |
159 | +771: .popsection |
160 | +772: \oldinstr |
161 | +773: alt_len_check 770b, 771b |
162 | + alt_len_check 772b, 773b |
163 | + alt_pad ( ( 771b - 770b ) - ( 773b - 772b ) ) |
164 | +774: .pushsection .altinstructions,"a" |
165 | + alt_entry 772b, 774b, 770b, 771b, \feature |
166 | + .popsection |
167 | +.endm |
168 | + |
169 | +/* |
170 | + * Define an alternative between two instructions. If @feature is |
171 | + * present, early code in apply_alternatives() replaces @oldinstr with |
172 | + * @newinstr. ".skip" directive takes care of proper instruction padding |
173 | + * in case @newinstr is longer than @oldinstr. |
174 | + */ |
175 | +.macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 |
176 | + .pushsection .altinstr_replacement,"ax" |
177 | +770: \newinstr1 |
178 | +771: \newinstr2 |
179 | +772: .popsection |
180 | +773: \oldinstr |
181 | +774: alt_len_check 770b, 771b |
182 | + alt_len_check 771b, 772b |
183 | + alt_len_check 773b, 774b |
184 | + .if ( 771b - 770b > 772b - 771b ) |
185 | + alt_pad ( ( 771b - 770b ) - ( 774b - 773b ) ) |
186 | + .else |
187 | + alt_pad ( ( 772b - 771b ) - ( 774b - 773b ) ) |
188 | + .endif |
189 | +775: .pushsection .altinstructions,"a" |
190 | + alt_entry 773b, 775b, 770b, 771b,\feature1 |
191 | + alt_entry 773b, 775b, 771b, 772b,\feature2 |
192 | + .popsection |
193 | +.endm |
194 | + |
195 | +#endif /* __ASSEMBLY__ */ |
196 | + |
197 | +#endif /* _ASM_S390_ALTERNATIVE_ASM_H */ |
198 | diff --git a/arch/s390/include/asm/nospec-insn.h b/arch/s390/include/asm/nospec-insn.h |
199 | new file mode 100644 |
200 | index 000000000000..9a56e738d645 |
201 | --- /dev/null |
202 | +++ b/arch/s390/include/asm/nospec-insn.h |
203 | @@ -0,0 +1,195 @@ |
204 | +/* SPDX-License-Identifier: GPL-2.0 */ |
205 | +#ifndef _ASM_S390_NOSPEC_ASM_H |
206 | +#define _ASM_S390_NOSPEC_ASM_H |
207 | + |
208 | +#include <asm/alternative-asm.h> |
209 | +#include <asm/asm-offsets.h> |
210 | + |
211 | +#ifdef __ASSEMBLY__ |
212 | + |
213 | +#ifdef CONFIG_EXPOLINE |
214 | + |
215 | +_LC_BR_R1 = __LC_BR_R1 |
216 | + |
217 | +/* |
218 | + * The expoline macros are used to create thunks in the same format |
219 | + * as gcc generates them. The 'comdat' section flag makes sure that |
220 | + * the various thunks are merged into a single copy. |
221 | + */ |
222 | + .macro __THUNK_PROLOG_NAME name |
223 | + .pushsection .text.\name,"axG",@progbits,\name,comdat |
224 | + .globl \name |
225 | + .hidden \name |
226 | + .type \name,@function |
227 | +\name: |
228 | + .cfi_startproc |
229 | + .endm |
230 | + |
231 | + .macro __THUNK_EPILOG |
232 | + .cfi_endproc |
233 | + .popsection |
234 | + .endm |
235 | + |
236 | + .macro __THUNK_PROLOG_BR r1,r2 |
237 | + __THUNK_PROLOG_NAME __s390x_indirect_jump_r\r2\()use_r\r1 |
238 | + .endm |
239 | + |
240 | + .macro __THUNK_PROLOG_BC d0,r1,r2 |
241 | + __THUNK_PROLOG_NAME __s390x_indirect_branch_\d0\()_\r2\()use_\r1 |
242 | + .endm |
243 | + |
244 | + .macro __THUNK_BR r1,r2 |
245 | + jg __s390x_indirect_jump_r\r2\()use_r\r1 |
246 | + .endm |
247 | + |
248 | + .macro __THUNK_BC d0,r1,r2 |
249 | + jg __s390x_indirect_branch_\d0\()_\r2\()use_\r1 |
250 | + .endm |
251 | + |
252 | + .macro __THUNK_BRASL r1,r2,r3 |
253 | + brasl \r1,__s390x_indirect_jump_r\r3\()use_r\r2 |
254 | + .endm |
255 | + |
256 | + .macro __DECODE_RR expand,reg,ruse |
257 | + .set __decode_fail,1 |
258 | + .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
259 | + .ifc \reg,%r\r1 |
260 | + .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
261 | + .ifc \ruse,%r\r2 |
262 | + \expand \r1,\r2 |
263 | + .set __decode_fail,0 |
264 | + .endif |
265 | + .endr |
266 | + .endif |
267 | + .endr |
268 | + .if __decode_fail == 1 |
269 | + .error "__DECODE_RR failed" |
270 | + .endif |
271 | + .endm |
272 | + |
273 | + .macro __DECODE_RRR expand,rsave,rtarget,ruse |
274 | + .set __decode_fail,1 |
275 | + .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
276 | + .ifc \rsave,%r\r1 |
277 | + .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
278 | + .ifc \rtarget,%r\r2 |
279 | + .irp r3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
280 | + .ifc \ruse,%r\r3 |
281 | + \expand \r1,\r2,\r3 |
282 | + .set __decode_fail,0 |
283 | + .endif |
284 | + .endr |
285 | + .endif |
286 | + .endr |
287 | + .endif |
288 | + .endr |
289 | + .if __decode_fail == 1 |
290 | + .error "__DECODE_RRR failed" |
291 | + .endif |
292 | + .endm |
293 | + |
294 | + .macro __DECODE_DRR expand,disp,reg,ruse |
295 | + .set __decode_fail,1 |
296 | + .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
297 | + .ifc \reg,%r\r1 |
298 | + .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
299 | + .ifc \ruse,%r\r2 |
300 | + \expand \disp,\r1,\r2 |
301 | + .set __decode_fail,0 |
302 | + .endif |
303 | + .endr |
304 | + .endif |
305 | + .endr |
306 | + .if __decode_fail == 1 |
307 | + .error "__DECODE_DRR failed" |
308 | + .endif |
309 | + .endm |
310 | + |
311 | + .macro __THUNK_EX_BR reg,ruse |
312 | + # Be very careful when adding instructions to this macro! |
313 | + # The ALTERNATIVE replacement code has a .+10 which targets |
314 | + # the "br \reg" after the code has been patched. |
315 | +#ifdef CONFIG_HAVE_MARCH_Z10_FEATURES |
316 | + exrl 0,555f |
317 | + j . |
318 | +#else |
319 | + .ifc \reg,%r1 |
320 | + ALTERNATIVE "ex %r0,_LC_BR_R1", ".insn ril,0xc60000000000,0,.+10", 35 |
321 | + j . |
322 | + .else |
323 | + larl \ruse,555f |
324 | + ex 0,0(\ruse) |
325 | + j . |
326 | + .endif |
327 | +#endif |
328 | +555: br \reg |
329 | + .endm |
330 | + |
331 | + .macro __THUNK_EX_BC disp,reg,ruse |
332 | +#ifdef CONFIG_HAVE_MARCH_Z10_FEATURES |
333 | + exrl 0,556f |
334 | + j . |
335 | +#else |
336 | + larl \ruse,556f |
337 | + ex 0,0(\ruse) |
338 | + j . |
339 | +#endif |
340 | +556: b \disp(\reg) |
341 | + .endm |
342 | + |
343 | + .macro GEN_BR_THUNK reg,ruse=%r1 |
344 | + __DECODE_RR __THUNK_PROLOG_BR,\reg,\ruse |
345 | + __THUNK_EX_BR \reg,\ruse |
346 | + __THUNK_EPILOG |
347 | + .endm |
348 | + |
349 | + .macro GEN_B_THUNK disp,reg,ruse=%r1 |
350 | + __DECODE_DRR __THUNK_PROLOG_BC,\disp,\reg,\ruse |
351 | + __THUNK_EX_BC \disp,\reg,\ruse |
352 | + __THUNK_EPILOG |
353 | + .endm |
354 | + |
355 | + .macro BR_EX reg,ruse=%r1 |
356 | +557: __DECODE_RR __THUNK_BR,\reg,\ruse |
357 | + .pushsection .s390_indirect_branches,"a",@progbits |
358 | + .long 557b-. |
359 | + .popsection |
360 | + .endm |
361 | + |
362 | + .macro B_EX disp,reg,ruse=%r1 |
363 | +558: __DECODE_DRR __THUNK_BC,\disp,\reg,\ruse |
364 | + .pushsection .s390_indirect_branches,"a",@progbits |
365 | + .long 558b-. |
366 | + .popsection |
367 | + .endm |
368 | + |
369 | + .macro BASR_EX rsave,rtarget,ruse=%r1 |
370 | +559: __DECODE_RRR __THUNK_BRASL,\rsave,\rtarget,\ruse |
371 | + .pushsection .s390_indirect_branches,"a",@progbits |
372 | + .long 559b-. |
373 | + .popsection |
374 | + .endm |
375 | + |
376 | +#else |
377 | + .macro GEN_BR_THUNK reg,ruse=%r1 |
378 | + .endm |
379 | + |
380 | + .macro GEN_B_THUNK disp,reg,ruse=%r1 |
381 | + .endm |
382 | + |
383 | + .macro BR_EX reg,ruse=%r1 |
384 | + br \reg |
385 | + .endm |
386 | + |
387 | + .macro B_EX disp,reg,ruse=%r1 |
388 | + b \disp(\reg) |
389 | + .endm |
390 | + |
391 | + .macro BASR_EX rsave,rtarget,ruse=%r1 |
392 | + basr \rsave,\rtarget |
393 | + .endm |
394 | +#endif |
395 | + |
396 | +#endif /* __ASSEMBLY__ */ |
397 | + |
398 | +#endif /* _ASM_S390_NOSPEC_ASM_H */ |
399 | diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile |
400 | index a3a4cafb6080..e0784fff07f5 100644 |
401 | --- a/arch/s390/kernel/Makefile |
402 | +++ b/arch/s390/kernel/Makefile |
403 | @@ -63,6 +63,7 @@ obj-y += nospec-branch.o |
404 | |
405 | extra-y += head.o head64.o vmlinux.lds |
406 | |
407 | +obj-$(CONFIG_SYSFS) += nospec-sysfs.o |
408 | CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE) |
409 | |
410 | obj-$(CONFIG_MODULES) += module.o |
411 | diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c |
412 | index 0e6d2b032484..4e69bf909e87 100644 |
413 | --- a/arch/s390/kernel/asm-offsets.c |
414 | +++ b/arch/s390/kernel/asm-offsets.c |
415 | @@ -177,6 +177,7 @@ int main(void) |
416 | OFFSET(__LC_PREEMPT_COUNT, lowcore, preempt_count); |
417 | OFFSET(__LC_GMAP, lowcore, gmap); |
418 | OFFSET(__LC_PASTE, lowcore, paste); |
419 | + OFFSET(__LC_BR_R1, lowcore, br_r1_trampoline); |
420 | /* software defined ABI-relevant lowcore locations 0xe00 - 0xe20 */ |
421 | OFFSET(__LC_DUMP_REIPL, lowcore, ipib); |
422 | /* hardware defined lowcore locations 0x1000 - 0x18ff */ |
423 | diff --git a/arch/s390/kernel/base.S b/arch/s390/kernel/base.S |
424 | index f6c56009e822..b65874b0b412 100644 |
425 | --- a/arch/s390/kernel/base.S |
426 | +++ b/arch/s390/kernel/base.S |
427 | @@ -9,18 +9,22 @@ |
428 | |
429 | #include <linux/linkage.h> |
430 | #include <asm/asm-offsets.h> |
431 | +#include <asm/nospec-insn.h> |
432 | #include <asm/ptrace.h> |
433 | #include <asm/sigp.h> |
434 | |
435 | + GEN_BR_THUNK %r9 |
436 | + GEN_BR_THUNK %r14 |
437 | + |
438 | ENTRY(s390_base_mcck_handler) |
439 | basr %r13,0 |
440 | 0: lg %r15,__LC_PANIC_STACK # load panic stack |
441 | aghi %r15,-STACK_FRAME_OVERHEAD |
442 | larl %r1,s390_base_mcck_handler_fn |
443 | - lg %r1,0(%r1) |
444 | - ltgr %r1,%r1 |
445 | + lg %r9,0(%r1) |
446 | + ltgr %r9,%r9 |
447 | jz 1f |
448 | - basr %r14,%r1 |
449 | + BASR_EX %r14,%r9 |
450 | 1: la %r1,4095 |
451 | lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1) |
452 | lpswe __LC_MCK_OLD_PSW |
453 | @@ -37,10 +41,10 @@ ENTRY(s390_base_ext_handler) |
454 | basr %r13,0 |
455 | 0: aghi %r15,-STACK_FRAME_OVERHEAD |
456 | larl %r1,s390_base_ext_handler_fn |
457 | - lg %r1,0(%r1) |
458 | - ltgr %r1,%r1 |
459 | + lg %r9,0(%r1) |
460 | + ltgr %r9,%r9 |
461 | jz 1f |
462 | - basr %r14,%r1 |
463 | + BASR_EX %r14,%r9 |
464 | 1: lmg %r0,%r15,__LC_SAVE_AREA_ASYNC |
465 | ni __LC_EXT_OLD_PSW+1,0xfd # clear wait state bit |
466 | lpswe __LC_EXT_OLD_PSW |
467 | @@ -57,10 +61,10 @@ ENTRY(s390_base_pgm_handler) |
468 | basr %r13,0 |
469 | 0: aghi %r15,-STACK_FRAME_OVERHEAD |
470 | larl %r1,s390_base_pgm_handler_fn |
471 | - lg %r1,0(%r1) |
472 | - ltgr %r1,%r1 |
473 | + lg %r9,0(%r1) |
474 | + ltgr %r9,%r9 |
475 | jz 1f |
476 | - basr %r14,%r1 |
477 | + BASR_EX %r14,%r9 |
478 | lmg %r0,%r15,__LC_SAVE_AREA_SYNC |
479 | lpswe __LC_PGM_OLD_PSW |
480 | 1: lpswe disabled_wait_psw-0b(%r13) |
481 | @@ -117,7 +121,7 @@ ENTRY(diag308_reset) |
482 | larl %r4,.Lcontinue_psw # Restore PSW flags |
483 | lpswe 0(%r4) |
484 | .Lcontinue: |
485 | - br %r14 |
486 | + BR_EX %r14 |
487 | .align 16 |
488 | .Lrestart_psw: |
489 | .long 0x00080000,0x80000000 + .Lrestart_part2 |
490 | diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S |
491 | index ed9aaa212d4a..be20b1f73384 100644 |
492 | --- a/arch/s390/kernel/entry.S |
493 | +++ b/arch/s390/kernel/entry.S |
494 | @@ -25,6 +25,7 @@ |
495 | #include <asm/setup.h> |
496 | #include <asm/nmi.h> |
497 | #include <asm/export.h> |
498 | +#include <asm/nospec-insn.h> |
499 | |
500 | __PT_R0 = __PT_GPRS |
501 | __PT_R1 = __PT_GPRS + 8 |
502 | @@ -221,67 +222,9 @@ _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART) |
503 | .popsection |
504 | .endm |
505 | |
506 | -#ifdef CONFIG_EXPOLINE |
507 | - |
508 | - .macro GEN_BR_THUNK name,reg,tmp |
509 | - .section .text.\name,"axG",@progbits,\name,comdat |
510 | - .globl \name |
511 | - .hidden \name |
512 | - .type \name,@function |
513 | -\name: |
514 | - .cfi_startproc |
515 | -#ifdef CONFIG_HAVE_MARCH_Z10_FEATURES |
516 | - exrl 0,0f |
517 | -#else |
518 | - larl \tmp,0f |
519 | - ex 0,0(\tmp) |
520 | -#endif |
521 | - j . |
522 | -0: br \reg |
523 | - .cfi_endproc |
524 | - .endm |
525 | - |
526 | - GEN_BR_THUNK __s390x_indirect_jump_r1use_r9,%r9,%r1 |
527 | - GEN_BR_THUNK __s390x_indirect_jump_r1use_r14,%r14,%r1 |
528 | - GEN_BR_THUNK __s390x_indirect_jump_r11use_r14,%r14,%r11 |
529 | - |
530 | - .macro BASR_R14_R9 |
531 | -0: brasl %r14,__s390x_indirect_jump_r1use_r9 |
532 | - .pushsection .s390_indirect_branches,"a",@progbits |
533 | - .long 0b-. |
534 | - .popsection |
535 | - .endm |
536 | - |
537 | - .macro BR_R1USE_R14 |
538 | -0: jg __s390x_indirect_jump_r1use_r14 |
539 | - .pushsection .s390_indirect_branches,"a",@progbits |
540 | - .long 0b-. |
541 | - .popsection |
542 | - .endm |
543 | - |
544 | - .macro BR_R11USE_R14 |
545 | -0: jg __s390x_indirect_jump_r11use_r14 |
546 | - .pushsection .s390_indirect_branches,"a",@progbits |
547 | - .long 0b-. |
548 | - .popsection |
549 | - .endm |
550 | - |
551 | -#else /* CONFIG_EXPOLINE */ |
552 | - |
553 | - .macro BASR_R14_R9 |
554 | - basr %r14,%r9 |
555 | - .endm |
556 | - |
557 | - .macro BR_R1USE_R14 |
558 | - br %r14 |
559 | - .endm |
560 | - |
561 | - .macro BR_R11USE_R14 |
562 | - br %r14 |
563 | - .endm |
564 | - |
565 | -#endif /* CONFIG_EXPOLINE */ |
566 | - |
567 | + GEN_BR_THUNK %r9 |
568 | + GEN_BR_THUNK %r14 |
569 | + GEN_BR_THUNK %r14,%r11 |
570 | |
571 | .section .kprobes.text, "ax" |
572 | .Ldummy: |
573 | @@ -298,7 +241,7 @@ _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART) |
574 | ENTRY(__bpon) |
575 | .globl __bpon |
576 | BPON |
577 | - BR_R1USE_R14 |
578 | + BR_EX %r14 |
579 | |
580 | /* |
581 | * Scheduler resume function, called by switch_to |
582 | @@ -325,7 +268,7 @@ ENTRY(__switch_to) |
583 | TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP |
584 | jz 0f |
585 | .insn s,0xb2800000,__LC_LPP # set program parameter |
586 | -0: BR_R1USE_R14 |
587 | +0: BR_EX %r14 |
588 | |
589 | .L__critical_start: |
590 | |
591 | @@ -392,7 +335,7 @@ sie_exit: |
592 | xgr %r5,%r5 |
593 | lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers |
594 | lg %r2,__SF_EMPTY+16(%r15) # return exit reason code |
595 | - BR_R1USE_R14 |
596 | + BR_EX %r14 |
597 | .Lsie_fault: |
598 | lghi %r14,-EFAULT |
599 | stg %r14,__SF_EMPTY+16(%r15) # set exit reason code |
600 | @@ -451,7 +394,7 @@ ENTRY(system_call) |
601 | lgf %r9,0(%r8,%r10) # get system call add. |
602 | TSTMSK __TI_flags(%r12),_TIF_TRACE |
603 | jnz .Lsysc_tracesys |
604 | - BASR_R14_R9 # call sys_xxxx |
605 | + BASR_EX %r14,%r9 # call sys_xxxx |
606 | stg %r2,__PT_R2(%r11) # store return value |
607 | |
608 | .Lsysc_return: |
609 | @@ -628,7 +571,7 @@ ENTRY(system_call) |
610 | lmg %r3,%r7,__PT_R3(%r11) |
611 | stg %r7,STACK_FRAME_OVERHEAD(%r15) |
612 | lg %r2,__PT_ORIG_GPR2(%r11) |
613 | - BASR_R14_R9 # call sys_xxx |
614 | + BASR_EX %r14,%r9 # call sys_xxx |
615 | stg %r2,__PT_R2(%r11) # store return value |
616 | .Lsysc_tracenogo: |
617 | TSTMSK __TI_flags(%r12),_TIF_TRACE |
618 | @@ -652,7 +595,7 @@ ENTRY(ret_from_fork) |
619 | lmg %r9,%r10,__PT_R9(%r11) # load gprs |
620 | ENTRY(kernel_thread_starter) |
621 | la %r2,0(%r10) |
622 | - BASR_R14_R9 |
623 | + BASR_EX %r14,%r9 |
624 | j .Lsysc_tracenogo |
625 | |
626 | /* |
627 | @@ -731,7 +674,7 @@ ENTRY(pgm_check_handler) |
628 | je .Lpgm_return |
629 | lgf %r9,0(%r10,%r1) # load address of handler routine |
630 | lgr %r2,%r11 # pass pointer to pt_regs |
631 | - BASR_R14_R9 # branch to interrupt-handler |
632 | + BASR_EX %r14,%r9 # branch to interrupt-handler |
633 | .Lpgm_return: |
634 | LOCKDEP_SYS_EXIT |
635 | tm __PT_PSW+1(%r11),0x01 # returning to user ? |
636 | @@ -1041,7 +984,7 @@ ENTRY(psw_idle) |
637 | stpt __TIMER_IDLE_ENTER(%r2) |
638 | .Lpsw_idle_lpsw: |
639 | lpswe __SF_EMPTY(%r15) |
640 | - BR_R1USE_R14 |
641 | + BR_EX %r14 |
642 | .Lpsw_idle_end: |
643 | |
644 | /* |
645 | @@ -1083,7 +1026,7 @@ ENTRY(save_fpu_regs) |
646 | .Lsave_fpu_regs_done: |
647 | oi __LC_CPU_FLAGS+7,_CIF_FPU |
648 | .Lsave_fpu_regs_exit: |
649 | - BR_R1USE_R14 |
650 | + BR_EX %r14 |
651 | .Lsave_fpu_regs_end: |
652 | EXPORT_SYMBOL(save_fpu_regs) |
653 | |
654 | @@ -1129,7 +1072,7 @@ load_fpu_regs: |
655 | .Lload_fpu_regs_done: |
656 | ni __LC_CPU_FLAGS+7,255-_CIF_FPU |
657 | .Lload_fpu_regs_exit: |
658 | - BR_R1USE_R14 |
659 | + BR_EX %r14 |
660 | .Lload_fpu_regs_end: |
661 | |
662 | .L__critical_end: |
663 | @@ -1301,7 +1244,7 @@ cleanup_critical: |
664 | jl 0f |
665 | clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end |
666 | jl .Lcleanup_load_fpu_regs |
667 | -0: BR_R11USE_R14 |
668 | +0: BR_EX %r14 |
669 | |
670 | .align 8 |
671 | .Lcleanup_table: |
672 | @@ -1337,7 +1280,7 @@ cleanup_critical: |
673 | ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE |
674 | lctlg %c1,%c1,__LC_USER_ASCE # load primary asce |
675 | larl %r9,sie_exit # skip forward to sie_exit |
676 | - BR_R11USE_R14 |
677 | + BR_EX %r14 |
678 | #endif |
679 | |
680 | .Lcleanup_system_call: |
681 | @@ -1391,7 +1334,7 @@ cleanup_critical: |
682 | stg %r15,56(%r11) # r15 stack pointer |
683 | # set new psw address and exit |
684 | larl %r9,.Lsysc_do_svc |
685 | - BR_R11USE_R14 |
686 | + BR_EX %r14,%r11 |
687 | .Lcleanup_system_call_insn: |
688 | .quad system_call |
689 | .quad .Lsysc_stmg |
690 | @@ -1403,7 +1346,7 @@ cleanup_critical: |
691 | |
692 | .Lcleanup_sysc_tif: |
693 | larl %r9,.Lsysc_tif |
694 | - BR_R11USE_R14 |
695 | + BR_EX %r14,%r11 |
696 | |
697 | .Lcleanup_sysc_restore: |
698 | # check if stpt has been executed |
699 | @@ -1420,14 +1363,14 @@ cleanup_critical: |
700 | mvc 0(64,%r11),__PT_R8(%r9) |
701 | lmg %r0,%r7,__PT_R0(%r9) |
702 | 1: lmg %r8,%r9,__LC_RETURN_PSW |
703 | - BR_R11USE_R14 |
704 | + BR_EX %r14,%r11 |
705 | .Lcleanup_sysc_restore_insn: |
706 | .quad .Lsysc_exit_timer |
707 | .quad .Lsysc_done - 4 |
708 | |
709 | .Lcleanup_io_tif: |
710 | larl %r9,.Lio_tif |
711 | - BR_R11USE_R14 |
712 | + BR_EX %r14,%r11 |
713 | |
714 | .Lcleanup_io_restore: |
715 | # check if stpt has been executed |
716 | @@ -1441,7 +1384,7 @@ cleanup_critical: |
717 | mvc 0(64,%r11),__PT_R8(%r9) |
718 | lmg %r0,%r7,__PT_R0(%r9) |
719 | 1: lmg %r8,%r9,__LC_RETURN_PSW |
720 | - BR_R11USE_R14 |
721 | + BR_EX %r14,%r11 |
722 | .Lcleanup_io_restore_insn: |
723 | .quad .Lio_exit_timer |
724 | .quad .Lio_done - 4 |
725 | @@ -1494,17 +1437,17 @@ cleanup_critical: |
726 | # prepare return psw |
727 | nihh %r8,0xfcfd # clear irq & wait state bits |
728 | lg %r9,48(%r11) # return from psw_idle |
729 | - BR_R11USE_R14 |
730 | + BR_EX %r14,%r11 |
731 | .Lcleanup_idle_insn: |
732 | .quad .Lpsw_idle_lpsw |
733 | |
734 | .Lcleanup_save_fpu_regs: |
735 | larl %r9,save_fpu_regs |
736 | - BR_R11USE_R14 |
737 | + BR_EX %r14,%r11 |
738 | |
739 | .Lcleanup_load_fpu_regs: |
740 | larl %r9,load_fpu_regs |
741 | - BR_R11USE_R14 |
742 | + BR_EX %r14,%r11 |
743 | |
744 | /* |
745 | * Integer constants |
746 | diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S |
747 | index 82df7d80fab2..27110f3294ed 100644 |
748 | --- a/arch/s390/kernel/mcount.S |
749 | +++ b/arch/s390/kernel/mcount.S |
750 | @@ -9,13 +9,17 @@ |
751 | #include <linux/linkage.h> |
752 | #include <asm/asm-offsets.h> |
753 | #include <asm/ftrace.h> |
754 | +#include <asm/nospec-insn.h> |
755 | #include <asm/ptrace.h> |
756 | #include <asm/export.h> |
757 | |
758 | + GEN_BR_THUNK %r1 |
759 | + GEN_BR_THUNK %r14 |
760 | + |
761 | .section .kprobes.text, "ax" |
762 | |
763 | ENTRY(ftrace_stub) |
764 | - br %r14 |
765 | + BR_EX %r14 |
766 | |
767 | #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE) |
768 | #define STACK_PTREGS (STACK_FRAME_OVERHEAD) |
769 | @@ -23,7 +27,7 @@ ENTRY(ftrace_stub) |
770 | #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW) |
771 | |
772 | ENTRY(_mcount) |
773 | - br %r14 |
774 | + BR_EX %r14 |
775 | |
776 | EXPORT_SYMBOL(_mcount) |
777 | |
778 | @@ -53,7 +57,7 @@ ENTRY(ftrace_caller) |
779 | #endif |
780 | lgr %r3,%r14 |
781 | la %r5,STACK_PTREGS(%r15) |
782 | - basr %r14,%r1 |
783 | + BASR_EX %r14,%r1 |
784 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
785 | # The j instruction gets runtime patched to a nop instruction. |
786 | # See ftrace_enable_ftrace_graph_caller. |
787 | @@ -68,7 +72,7 @@ ftrace_graph_caller_end: |
788 | #endif |
789 | lg %r1,(STACK_PTREGS_PSW+8)(%r15) |
790 | lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15) |
791 | - br %r1 |
792 | + BR_EX %r1 |
793 | |
794 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
795 | |
796 | @@ -81,6 +85,6 @@ ENTRY(return_to_handler) |
797 | aghi %r15,STACK_FRAME_OVERHEAD |
798 | lgr %r14,%r2 |
799 | lmg %r2,%r5,32(%r15) |
800 | - br %r14 |
801 | + BR_EX %r14 |
802 | |
803 | #endif |
804 | diff --git a/arch/s390/kernel/nospec-branch.c b/arch/s390/kernel/nospec-branch.c |
805 | index 9f3b5b382743..d5eed651b5ab 100644 |
806 | --- a/arch/s390/kernel/nospec-branch.c |
807 | +++ b/arch/s390/kernel/nospec-branch.c |
808 | @@ -44,24 +44,6 @@ static int __init nospec_report(void) |
809 | } |
810 | arch_initcall(nospec_report); |
811 | |
812 | -#ifdef CONFIG_SYSFS |
813 | -ssize_t cpu_show_spectre_v1(struct device *dev, |
814 | - struct device_attribute *attr, char *buf) |
815 | -{ |
816 | - return sprintf(buf, "Mitigation: __user pointer sanitization\n"); |
817 | -} |
818 | - |
819 | -ssize_t cpu_show_spectre_v2(struct device *dev, |
820 | - struct device_attribute *attr, char *buf) |
821 | -{ |
822 | - if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) |
823 | - return sprintf(buf, "Mitigation: execute trampolines\n"); |
824 | - if (__test_facility(82, S390_lowcore.alt_stfle_fac_list)) |
825 | - return sprintf(buf, "Mitigation: limited branch prediction.\n"); |
826 | - return sprintf(buf, "Vulnerable\n"); |
827 | -} |
828 | -#endif |
829 | - |
830 | #ifdef CONFIG_EXPOLINE |
831 | |
832 | int nospec_disable = IS_ENABLED(CONFIG_EXPOLINE_OFF); |
833 | @@ -112,7 +94,6 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end) |
834 | s32 *epo; |
835 | |
836 | /* Second part of the instruction replace is always a nop */ |
837 | - memcpy(insnbuf + 2, (char[]) { 0x47, 0x00, 0x00, 0x00 }, 4); |
838 | for (epo = start; epo < end; epo++) { |
839 | instr = (u8 *) epo + *epo; |
840 | if (instr[0] == 0xc0 && (instr[1] & 0x0f) == 0x04) |
841 | @@ -133,18 +114,34 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end) |
842 | br = thunk + (*(int *)(thunk + 2)) * 2; |
843 | else |
844 | continue; |
845 | - if (br[0] != 0x07 || (br[1] & 0xf0) != 0xf0) |
846 | + /* Check for unconditional branch 0x07f? or 0x47f???? */ |
847 | + if ((br[0] & 0xbf) != 0x07 || (br[1] & 0xf0) != 0xf0) |
848 | continue; |
849 | + |
850 | + memcpy(insnbuf + 2, (char[]) { 0x47, 0x00, 0x07, 0x00 }, 4); |
851 | switch (type) { |
852 | case BRCL_EXPOLINE: |
853 | - /* brcl to thunk, replace with br + nop */ |
854 | insnbuf[0] = br[0]; |
855 | insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f); |
856 | + if (br[0] == 0x47) { |
857 | + /* brcl to b, replace with bc + nopr */ |
858 | + insnbuf[2] = br[2]; |
859 | + insnbuf[3] = br[3]; |
860 | + } else { |
861 | + /* brcl to br, replace with bcr + nop */ |
862 | + } |
863 | break; |
864 | case BRASL_EXPOLINE: |
865 | - /* brasl to thunk, replace with basr + nop */ |
866 | - insnbuf[0] = 0x0d; |
867 | insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f); |
868 | + if (br[0] == 0x47) { |
869 | + /* brasl to b, replace with bas + nopr */ |
870 | + insnbuf[0] = 0x4d; |
871 | + insnbuf[2] = br[2]; |
872 | + insnbuf[3] = br[3]; |
873 | + } else { |
874 | + /* brasl to br, replace with basr + nop */ |
875 | + insnbuf[0] = 0x0d; |
876 | + } |
877 | break; |
878 | } |
879 | |
880 | diff --git a/arch/s390/kernel/nospec-sysfs.c b/arch/s390/kernel/nospec-sysfs.c |
881 | new file mode 100644 |
882 | index 000000000000..8affad5f18cb |
883 | --- /dev/null |
884 | +++ b/arch/s390/kernel/nospec-sysfs.c |
885 | @@ -0,0 +1,21 @@ |
886 | +// SPDX-License-Identifier: GPL-2.0 |
887 | +#include <linux/device.h> |
888 | +#include <linux/cpu.h> |
889 | +#include <asm/facility.h> |
890 | +#include <asm/nospec-branch.h> |
891 | + |
892 | +ssize_t cpu_show_spectre_v1(struct device *dev, |
893 | + struct device_attribute *attr, char *buf) |
894 | +{ |
895 | + return sprintf(buf, "Mitigation: __user pointer sanitization\n"); |
896 | +} |
897 | + |
898 | +ssize_t cpu_show_spectre_v2(struct device *dev, |
899 | + struct device_attribute *attr, char *buf) |
900 | +{ |
901 | + if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) |
902 | + return sprintf(buf, "Mitigation: execute trampolines\n"); |
903 | + if (__test_facility(82, S390_lowcore.alt_stfle_fac_list)) |
904 | + return sprintf(buf, "Mitigation: limited branch prediction\n"); |
905 | + return sprintf(buf, "Vulnerable\n"); |
906 | +} |
907 | diff --git a/arch/s390/kernel/reipl.S b/arch/s390/kernel/reipl.S |
908 | index a40ebd1d29d0..8e954c102639 100644 |
909 | --- a/arch/s390/kernel/reipl.S |
910 | +++ b/arch/s390/kernel/reipl.S |
911 | @@ -7,8 +7,11 @@ |
912 | |
913 | #include <linux/linkage.h> |
914 | #include <asm/asm-offsets.h> |
915 | +#include <asm/nospec-insn.h> |
916 | #include <asm/sigp.h> |
917 | |
918 | + GEN_BR_THUNK %r9 |
919 | + |
920 | # |
921 | # Issue "store status" for the current CPU to its prefix page |
922 | # and call passed function afterwards |
923 | @@ -67,9 +70,9 @@ ENTRY(store_status) |
924 | st %r4,0(%r1) |
925 | st %r5,4(%r1) |
926 | stg %r2,8(%r1) |
927 | - lgr %r1,%r2 |
928 | + lgr %r9,%r2 |
929 | lgr %r2,%r3 |
930 | - br %r1 |
931 | + BR_EX %r9 |
932 | |
933 | .section .bss |
934 | .align 8 |
935 | diff --git a/arch/s390/kernel/swsusp.S b/arch/s390/kernel/swsusp.S |
936 | index e99187149f17..a049a7b9d6e8 100644 |
937 | --- a/arch/s390/kernel/swsusp.S |
938 | +++ b/arch/s390/kernel/swsusp.S |
939 | @@ -13,6 +13,7 @@ |
940 | #include <asm/ptrace.h> |
941 | #include <asm/thread_info.h> |
942 | #include <asm/asm-offsets.h> |
943 | +#include <asm/nospec-insn.h> |
944 | #include <asm/sigp.h> |
945 | |
946 | /* |
947 | @@ -24,6 +25,8 @@ |
948 | * (see below) in the resume process. |
949 | * This function runs with disabled interrupts. |
950 | */ |
951 | + GEN_BR_THUNK %r14 |
952 | + |
953 | .section .text |
954 | ENTRY(swsusp_arch_suspend) |
955 | stmg %r6,%r15,__SF_GPRS(%r15) |
956 | @@ -103,7 +106,7 @@ ENTRY(swsusp_arch_suspend) |
957 | spx 0x318(%r1) |
958 | lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15) |
959 | lghi %r2,0 |
960 | - br %r14 |
961 | + BR_EX %r14 |
962 | |
963 | /* |
964 | * Restore saved memory image to correct place and restore register context. |
965 | @@ -197,11 +200,10 @@ pgm_check_entry: |
966 | larl %r15,init_thread_union |
967 | ahi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER) |
968 | larl %r2,.Lpanic_string |
969 | - larl %r3,sclp_early_printk |
970 | lghi %r1,0 |
971 | sam31 |
972 | sigp %r1,%r0,SIGP_SET_ARCHITECTURE |
973 | - basr %r14,%r3 |
974 | + brasl %r14,sclp_early_printk |
975 | larl %r3,.Ldisabled_wait_31 |
976 | lpsw 0(%r3) |
977 | 4: |
978 | @@ -267,7 +269,7 @@ restore_registers: |
979 | /* Return 0 */ |
980 | lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15) |
981 | lghi %r2,0 |
982 | - br %r14 |
983 | + BR_EX %r14 |
984 | |
985 | .section .data..nosave,"aw",@progbits |
986 | .align 8 |
987 | diff --git a/arch/s390/lib/mem.S b/arch/s390/lib/mem.S |
988 | index d66751397e72..e1fa974ac500 100644 |
989 | --- a/arch/s390/lib/mem.S |
990 | +++ b/arch/s390/lib/mem.S |
991 | @@ -7,6 +7,9 @@ |
992 | |
993 | #include <linux/linkage.h> |
994 | #include <asm/export.h> |
995 | +#include <asm/nospec-insn.h> |
996 | + |
997 | + GEN_BR_THUNK %r14 |
998 | |
999 | /* |
1000 | * void *memmove(void *dest, const void *src, size_t n) |
1001 | @@ -33,14 +36,14 @@ ENTRY(memmove) |
1002 | .Lmemmove_forward_remainder: |
1003 | larl %r5,.Lmemmove_mvc |
1004 | ex %r4,0(%r5) |
1005 | - br %r14 |
1006 | + BR_EX %r14 |
1007 | .Lmemmove_reverse: |
1008 | ic %r0,0(%r4,%r3) |
1009 | stc %r0,0(%r4,%r1) |
1010 | brctg %r4,.Lmemmove_reverse |
1011 | ic %r0,0(%r4,%r3) |
1012 | stc %r0,0(%r4,%r1) |
1013 | - br %r14 |
1014 | + BR_EX %r14 |
1015 | .Lmemmove_mvc: |
1016 | mvc 0(1,%r1),0(%r3) |
1017 | EXPORT_SYMBOL(memmove) |
1018 | @@ -77,7 +80,7 @@ ENTRY(memset) |
1019 | .Lmemset_clear_remainder: |
1020 | larl %r3,.Lmemset_xc |
1021 | ex %r4,0(%r3) |
1022 | - br %r14 |
1023 | + BR_EX %r14 |
1024 | .Lmemset_fill: |
1025 | stc %r3,0(%r2) |
1026 | cghi %r4,1 |
1027 | @@ -94,7 +97,7 @@ ENTRY(memset) |
1028 | .Lmemset_fill_remainder: |
1029 | larl %r3,.Lmemset_mvc |
1030 | ex %r4,0(%r3) |
1031 | - br %r14 |
1032 | + BR_EX %r14 |
1033 | .Lmemset_xc: |
1034 | xc 0(1,%r1),0(%r1) |
1035 | .Lmemset_mvc: |
1036 | @@ -117,7 +120,7 @@ ENTRY(memcpy) |
1037 | .Lmemcpy_remainder: |
1038 | larl %r5,.Lmemcpy_mvc |
1039 | ex %r4,0(%r5) |
1040 | - br %r14 |
1041 | + BR_EX %r14 |
1042 | .Lmemcpy_loop: |
1043 | mvc 0(256,%r1),0(%r3) |
1044 | la %r1,256(%r1) |
1045 | diff --git a/arch/s390/net/bpf_jit.S b/arch/s390/net/bpf_jit.S |
1046 | index 25bb4643c4f4..9f794869c1b0 100644 |
1047 | --- a/arch/s390/net/bpf_jit.S |
1048 | +++ b/arch/s390/net/bpf_jit.S |
1049 | @@ -9,6 +9,7 @@ |
1050 | */ |
1051 | |
1052 | #include <linux/linkage.h> |
1053 | +#include <asm/nospec-insn.h> |
1054 | #include "bpf_jit.h" |
1055 | |
1056 | /* |
1057 | @@ -54,7 +55,7 @@ ENTRY(sk_load_##NAME##_pos); \ |
1058 | clg %r3,STK_OFF_HLEN(%r15); /* Offset + SIZE > hlen? */ \ |
1059 | jh sk_load_##NAME##_slow; \ |
1060 | LOAD %r14,-SIZE(%r3,%r12); /* Get data from skb */ \ |
1061 | - b OFF_OK(%r6); /* Return */ \ |
1062 | + B_EX OFF_OK,%r6; /* Return */ \ |
1063 | \ |
1064 | sk_load_##NAME##_slow:; \ |
1065 | lgr %r2,%r7; /* Arg1 = skb pointer */ \ |
1066 | @@ -64,11 +65,14 @@ sk_load_##NAME##_slow:; \ |
1067 | brasl %r14,skb_copy_bits; /* Get data from skb */ \ |
1068 | LOAD %r14,STK_OFF_TMP(%r15); /* Load from temp bufffer */ \ |
1069 | ltgr %r2,%r2; /* Set cc to (%r2 != 0) */ \ |
1070 | - br %r6; /* Return */ |
1071 | + BR_EX %r6; /* Return */ |
1072 | |
1073 | sk_load_common(word, 4, llgf) /* r14 = *(u32 *) (skb->data+offset) */ |
1074 | sk_load_common(half, 2, llgh) /* r14 = *(u16 *) (skb->data+offset) */ |
1075 | |
1076 | + GEN_BR_THUNK %r6 |
1077 | + GEN_B_THUNK OFF_OK,%r6 |
1078 | + |
1079 | /* |
1080 | * Load 1 byte from SKB (optimized version) |
1081 | */ |
1082 | @@ -80,7 +84,7 @@ ENTRY(sk_load_byte_pos) |
1083 | clg %r3,STK_OFF_HLEN(%r15) # Offset >= hlen? |
1084 | jnl sk_load_byte_slow |
1085 | llgc %r14,0(%r3,%r12) # Get byte from skb |
1086 | - b OFF_OK(%r6) # Return OK |
1087 | + B_EX OFF_OK,%r6 # Return OK |
1088 | |
1089 | sk_load_byte_slow: |
1090 | lgr %r2,%r7 # Arg1 = skb pointer |
1091 | @@ -90,7 +94,7 @@ sk_load_byte_slow: |
1092 | brasl %r14,skb_copy_bits # Get data from skb |
1093 | llgc %r14,STK_OFF_TMP(%r15) # Load result from temp buffer |
1094 | ltgr %r2,%r2 # Set cc to (%r2 != 0) |
1095 | - br %r6 # Return cc |
1096 | + BR_EX %r6 # Return cc |
1097 | |
1098 | #define sk_negative_common(NAME, SIZE, LOAD) \ |
1099 | sk_load_##NAME##_slow_neg:; \ |
1100 | @@ -104,7 +108,7 @@ sk_load_##NAME##_slow_neg:; \ |
1101 | jz bpf_error; \ |
1102 | LOAD %r14,0(%r2); /* Get data from pointer */ \ |
1103 | xr %r3,%r3; /* Set cc to zero */ \ |
1104 | - br %r6; /* Return cc */ |
1105 | + BR_EX %r6; /* Return cc */ |
1106 | |
1107 | sk_negative_common(word, 4, llgf) |
1108 | sk_negative_common(half, 2, llgh) |
1109 | @@ -113,4 +117,4 @@ sk_negative_common(byte, 1, llgc) |
1110 | bpf_error: |
1111 | # force a return 0 from jit handler |
1112 | ltgr %r15,%r15 # Set condition code |
1113 | - br %r6 |
1114 | + BR_EX %r6 |
1115 | diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c |
1116 | index 33e2785f6842..11cd151733d4 100644 |
1117 | --- a/arch/s390/net/bpf_jit_comp.c |
1118 | +++ b/arch/s390/net/bpf_jit_comp.c |
1119 | @@ -25,6 +25,8 @@ |
1120 | #include <linux/bpf.h> |
1121 | #include <asm/cacheflush.h> |
1122 | #include <asm/dis.h> |
1123 | +#include <asm/facility.h> |
1124 | +#include <asm/nospec-branch.h> |
1125 | #include <asm/set_memory.h> |
1126 | #include "bpf_jit.h" |
1127 | |
1128 | @@ -43,6 +45,8 @@ struct bpf_jit { |
1129 | int base_ip; /* Base address for literal pool */ |
1130 | int ret0_ip; /* Address of return 0 */ |
1131 | int exit_ip; /* Address of exit */ |
1132 | + int r1_thunk_ip; /* Address of expoline thunk for 'br %r1' */ |
1133 | + int r14_thunk_ip; /* Address of expoline thunk for 'br %r14' */ |
1134 | int tail_call_start; /* Tail call start offset */ |
1135 | int labels[1]; /* Labels for local jumps */ |
1136 | }; |
1137 | @@ -252,6 +256,19 @@ static inline void reg_set_seen(struct bpf_jit *jit, u32 b1) |
1138 | REG_SET_SEEN(b2); \ |
1139 | }) |
1140 | |
1141 | +#define EMIT6_PCREL_RILB(op, b, target) \ |
1142 | +({ \ |
1143 | + int rel = (target - jit->prg) / 2; \ |
1144 | + _EMIT6(op | reg_high(b) << 16 | rel >> 16, rel & 0xffff); \ |
1145 | + REG_SET_SEEN(b); \ |
1146 | +}) |
1147 | + |
1148 | +#define EMIT6_PCREL_RIL(op, target) \ |
1149 | +({ \ |
1150 | + int rel = (target - jit->prg) / 2; \ |
1151 | + _EMIT6(op | rel >> 16, rel & 0xffff); \ |
1152 | +}) |
1153 | + |
1154 | #define _EMIT6_IMM(op, imm) \ |
1155 | ({ \ |
1156 | unsigned int __imm = (imm); \ |
1157 | @@ -471,8 +488,45 @@ static void bpf_jit_epilogue(struct bpf_jit *jit) |
1158 | EMIT4(0xb9040000, REG_2, BPF_REG_0); |
1159 | /* Restore registers */ |
1160 | save_restore_regs(jit, REGS_RESTORE); |
1161 | + if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) { |
1162 | + jit->r14_thunk_ip = jit->prg; |
1163 | + /* Generate __s390_indirect_jump_r14 thunk */ |
1164 | + if (test_facility(35)) { |
1165 | + /* exrl %r0,.+10 */ |
1166 | + EMIT6_PCREL_RIL(0xc6000000, jit->prg + 10); |
1167 | + } else { |
1168 | + /* larl %r1,.+14 */ |
1169 | + EMIT6_PCREL_RILB(0xc0000000, REG_1, jit->prg + 14); |
1170 | + /* ex 0,0(%r1) */ |
1171 | + EMIT4_DISP(0x44000000, REG_0, REG_1, 0); |
1172 | + } |
1173 | + /* j . */ |
1174 | + EMIT4_PCREL(0xa7f40000, 0); |
1175 | + } |
1176 | /* br %r14 */ |
1177 | _EMIT2(0x07fe); |
1178 | + |
1179 | + if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable && |
1180 | + (jit->seen & SEEN_FUNC)) { |
1181 | + jit->r1_thunk_ip = jit->prg; |
1182 | + /* Generate __s390_indirect_jump_r1 thunk */ |
1183 | + if (test_facility(35)) { |
1184 | + /* exrl %r0,.+10 */ |
1185 | + EMIT6_PCREL_RIL(0xc6000000, jit->prg + 10); |
1186 | + /* j . */ |
1187 | + EMIT4_PCREL(0xa7f40000, 0); |
1188 | + /* br %r1 */ |
1189 | + _EMIT2(0x07f1); |
1190 | + } else { |
1191 | + /* larl %r1,.+14 */ |
1192 | + EMIT6_PCREL_RILB(0xc0000000, REG_1, jit->prg + 14); |
1193 | + /* ex 0,S390_lowcore.br_r1_tampoline */ |
1194 | + EMIT4_DISP(0x44000000, REG_0, REG_0, |
1195 | + offsetof(struct lowcore, br_r1_trampoline)); |
1196 | + /* j . */ |
1197 | + EMIT4_PCREL(0xa7f40000, 0); |
1198 | + } |
1199 | + } |
1200 | } |
1201 | |
1202 | /* |
1203 | @@ -978,8 +1032,13 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i |
1204 | /* lg %w1,<d(imm)>(%l) */ |
1205 | EMIT6_DISP_LH(0xe3000000, 0x0004, REG_W1, REG_0, REG_L, |
1206 | EMIT_CONST_U64(func)); |
1207 | - /* basr %r14,%w1 */ |
1208 | - EMIT2(0x0d00, REG_14, REG_W1); |
1209 | + if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) { |
1210 | + /* brasl %r14,__s390_indirect_jump_r1 */ |
1211 | + EMIT6_PCREL_RILB(0xc0050000, REG_14, jit->r1_thunk_ip); |
1212 | + } else { |
1213 | + /* basr %r14,%w1 */ |
1214 | + EMIT2(0x0d00, REG_14, REG_W1); |
1215 | + } |
1216 | /* lgr %b0,%r2: load return value into %b0 */ |
1217 | EMIT4(0xb9040000, BPF_REG_0, REG_2); |
1218 | if ((jit->seen & SEEN_SKB) && |
1219 | diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c |
1220 | index 1a0fa10cb6b7..32bae68e34c1 100644 |
1221 | --- a/arch/sparc/kernel/vio.c |
1222 | +++ b/arch/sparc/kernel/vio.c |
1223 | @@ -403,7 +403,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, |
1224 | if (err) { |
1225 | printk(KERN_ERR "VIO: Could not register device %s, err=%d\n", |
1226 | dev_name(&vdev->dev), err); |
1227 | - kfree(vdev); |
1228 | + put_device(&vdev->dev); |
1229 | return NULL; |
1230 | } |
1231 | if (vdev->dp) |
1232 | diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c |
1233 | index edfede768688..5167f3f74136 100644 |
1234 | --- a/arch/x86/kernel/machine_kexec_32.c |
1235 | +++ b/arch/x86/kernel/machine_kexec_32.c |
1236 | @@ -57,12 +57,17 @@ static void load_segments(void) |
1237 | static void machine_kexec_free_page_tables(struct kimage *image) |
1238 | { |
1239 | free_page((unsigned long)image->arch.pgd); |
1240 | + image->arch.pgd = NULL; |
1241 | #ifdef CONFIG_X86_PAE |
1242 | free_page((unsigned long)image->arch.pmd0); |
1243 | + image->arch.pmd0 = NULL; |
1244 | free_page((unsigned long)image->arch.pmd1); |
1245 | + image->arch.pmd1 = NULL; |
1246 | #endif |
1247 | free_page((unsigned long)image->arch.pte0); |
1248 | + image->arch.pte0 = NULL; |
1249 | free_page((unsigned long)image->arch.pte1); |
1250 | + image->arch.pte1 = NULL; |
1251 | } |
1252 | |
1253 | static int machine_kexec_alloc_page_tables(struct kimage *image) |
1254 | @@ -79,7 +84,6 @@ static int machine_kexec_alloc_page_tables(struct kimage *image) |
1255 | !image->arch.pmd0 || !image->arch.pmd1 || |
1256 | #endif |
1257 | !image->arch.pte0 || !image->arch.pte1) { |
1258 | - machine_kexec_free_page_tables(image); |
1259 | return -ENOMEM; |
1260 | } |
1261 | return 0; |
1262 | diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c |
1263 | index 3b7427aa7d85..5bce2a88e8a3 100644 |
1264 | --- a/arch/x86/kernel/machine_kexec_64.c |
1265 | +++ b/arch/x86/kernel/machine_kexec_64.c |
1266 | @@ -38,9 +38,13 @@ static struct kexec_file_ops *kexec_file_loaders[] = { |
1267 | static void free_transition_pgtable(struct kimage *image) |
1268 | { |
1269 | free_page((unsigned long)image->arch.p4d); |
1270 | + image->arch.p4d = NULL; |
1271 | free_page((unsigned long)image->arch.pud); |
1272 | + image->arch.pud = NULL; |
1273 | free_page((unsigned long)image->arch.pmd); |
1274 | + image->arch.pmd = NULL; |
1275 | free_page((unsigned long)image->arch.pte); |
1276 | + image->arch.pte = NULL; |
1277 | } |
1278 | |
1279 | static int init_transition_pgtable(struct kimage *image, pgd_t *pgd) |
1280 | @@ -90,7 +94,6 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd) |
1281 | set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC_NOENC)); |
1282 | return 0; |
1283 | err: |
1284 | - free_transition_pgtable(image); |
1285 | return result; |
1286 | } |
1287 | |
1288 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c |
1289 | index 754852156622..1a87f87c88d0 100644 |
1290 | --- a/drivers/block/loop.c |
1291 | +++ b/drivers/block/loop.c |
1292 | @@ -1166,21 +1166,17 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) |
1293 | static int |
1294 | loop_get_status(struct loop_device *lo, struct loop_info64 *info) |
1295 | { |
1296 | - struct file *file = lo->lo_backing_file; |
1297 | + struct file *file; |
1298 | struct kstat stat; |
1299 | - int error; |
1300 | + int ret; |
1301 | |
1302 | - if (lo->lo_state != Lo_bound) |
1303 | + if (lo->lo_state != Lo_bound) { |
1304 | + mutex_unlock(&lo->lo_ctl_mutex); |
1305 | return -ENXIO; |
1306 | - error = vfs_getattr(&file->f_path, &stat, |
1307 | - STATX_INO, AT_STATX_SYNC_AS_STAT); |
1308 | - if (error) |
1309 | - return error; |
1310 | + } |
1311 | + |
1312 | memset(info, 0, sizeof(*info)); |
1313 | info->lo_number = lo->lo_number; |
1314 | - info->lo_device = huge_encode_dev(stat.dev); |
1315 | - info->lo_inode = stat.ino; |
1316 | - info->lo_rdevice = huge_encode_dev(lo->lo_device ? stat.rdev : stat.dev); |
1317 | info->lo_offset = lo->lo_offset; |
1318 | info->lo_sizelimit = lo->lo_sizelimit; |
1319 | info->lo_flags = lo->lo_flags; |
1320 | @@ -1193,7 +1189,19 @@ loop_get_status(struct loop_device *lo, struct loop_info64 *info) |
1321 | memcpy(info->lo_encrypt_key, lo->lo_encrypt_key, |
1322 | lo->lo_encrypt_key_size); |
1323 | } |
1324 | - return 0; |
1325 | + |
1326 | + /* Drop lo_ctl_mutex while we call into the filesystem. */ |
1327 | + file = get_file(lo->lo_backing_file); |
1328 | + mutex_unlock(&lo->lo_ctl_mutex); |
1329 | + ret = vfs_getattr(&file->f_path, &stat, STATX_INO, |
1330 | + AT_STATX_SYNC_AS_STAT); |
1331 | + if (!ret) { |
1332 | + info->lo_device = huge_encode_dev(stat.dev); |
1333 | + info->lo_inode = stat.ino; |
1334 | + info->lo_rdevice = huge_encode_dev(stat.rdev); |
1335 | + } |
1336 | + fput(file); |
1337 | + return ret; |
1338 | } |
1339 | |
1340 | static void |
1341 | @@ -1274,12 +1282,13 @@ static int |
1342 | loop_get_status_old(struct loop_device *lo, struct loop_info __user *arg) { |
1343 | struct loop_info info; |
1344 | struct loop_info64 info64; |
1345 | - int err = 0; |
1346 | + int err; |
1347 | |
1348 | - if (!arg) |
1349 | - err = -EINVAL; |
1350 | - if (!err) |
1351 | - err = loop_get_status(lo, &info64); |
1352 | + if (!arg) { |
1353 | + mutex_unlock(&lo->lo_ctl_mutex); |
1354 | + return -EINVAL; |
1355 | + } |
1356 | + err = loop_get_status(lo, &info64); |
1357 | if (!err) |
1358 | err = loop_info64_to_old(&info64, &info); |
1359 | if (!err && copy_to_user(arg, &info, sizeof(info))) |
1360 | @@ -1291,12 +1300,13 @@ loop_get_status_old(struct loop_device *lo, struct loop_info __user *arg) { |
1361 | static int |
1362 | loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) { |
1363 | struct loop_info64 info64; |
1364 | - int err = 0; |
1365 | + int err; |
1366 | |
1367 | - if (!arg) |
1368 | - err = -EINVAL; |
1369 | - if (!err) |
1370 | - err = loop_get_status(lo, &info64); |
1371 | + if (!arg) { |
1372 | + mutex_unlock(&lo->lo_ctl_mutex); |
1373 | + return -EINVAL; |
1374 | + } |
1375 | + err = loop_get_status(lo, &info64); |
1376 | if (!err && copy_to_user(arg, &info64, sizeof(info64))) |
1377 | err = -EFAULT; |
1378 | |
1379 | @@ -1373,7 +1383,8 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, |
1380 | break; |
1381 | case LOOP_GET_STATUS: |
1382 | err = loop_get_status_old(lo, (struct loop_info __user *) arg); |
1383 | - break; |
1384 | + /* loop_get_status() unlocks lo_ctl_mutex */ |
1385 | + goto out_unlocked; |
1386 | case LOOP_SET_STATUS64: |
1387 | err = -EPERM; |
1388 | if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) |
1389 | @@ -1382,7 +1393,8 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, |
1390 | break; |
1391 | case LOOP_GET_STATUS64: |
1392 | err = loop_get_status64(lo, (struct loop_info64 __user *) arg); |
1393 | - break; |
1394 | + /* loop_get_status() unlocks lo_ctl_mutex */ |
1395 | + goto out_unlocked; |
1396 | case LOOP_SET_CAPACITY: |
1397 | err = -EPERM; |
1398 | if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) |
1399 | @@ -1515,12 +1527,13 @@ loop_get_status_compat(struct loop_device *lo, |
1400 | struct compat_loop_info __user *arg) |
1401 | { |
1402 | struct loop_info64 info64; |
1403 | - int err = 0; |
1404 | + int err; |
1405 | |
1406 | - if (!arg) |
1407 | - err = -EINVAL; |
1408 | - if (!err) |
1409 | - err = loop_get_status(lo, &info64); |
1410 | + if (!arg) { |
1411 | + mutex_unlock(&lo->lo_ctl_mutex); |
1412 | + return -EINVAL; |
1413 | + } |
1414 | + err = loop_get_status(lo, &info64); |
1415 | if (!err) |
1416 | err = loop_info64_to_compat(&info64, arg); |
1417 | return err; |
1418 | @@ -1543,7 +1556,7 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, |
1419 | mutex_lock(&lo->lo_ctl_mutex); |
1420 | err = loop_get_status_compat( |
1421 | lo, (struct compat_loop_info __user *) arg); |
1422 | - mutex_unlock(&lo->lo_ctl_mutex); |
1423 | + /* loop_get_status() unlocks lo_ctl_mutex */ |
1424 | break; |
1425 | case LOOP_SET_CAPACITY: |
1426 | case LOOP_CLR_FD: |
1427 | diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c |
1428 | index 7fcc4d7f4909..86d7975afaeb 100644 |
1429 | --- a/drivers/bluetooth/btusb.c |
1430 | +++ b/drivers/bluetooth/btusb.c |
1431 | @@ -370,6 +370,9 @@ static const struct usb_device_id blacklist_table[] = { |
1432 | { USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK }, |
1433 | { USB_DEVICE(0x13d3, 0x3494), .driver_info = BTUSB_REALTEK }, |
1434 | |
1435 | + /* Additional Realtek 8723BU Bluetooth devices */ |
1436 | + { USB_DEVICE(0x7392, 0xa611), .driver_info = BTUSB_REALTEK }, |
1437 | + |
1438 | /* Additional Realtek 8821AE Bluetooth devices */ |
1439 | { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK }, |
1440 | { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK }, |
1441 | @@ -377,6 +380,9 @@ static const struct usb_device_id blacklist_table[] = { |
1442 | { USB_DEVICE(0x13d3, 0x3461), .driver_info = BTUSB_REALTEK }, |
1443 | { USB_DEVICE(0x13d3, 0x3462), .driver_info = BTUSB_REALTEK }, |
1444 | |
1445 | + /* Additional Realtek 8822BE Bluetooth devices */ |
1446 | + { USB_DEVICE(0x0b05, 0x185c), .driver_info = BTUSB_REALTEK }, |
1447 | + |
1448 | /* Silicon Wave based devices */ |
1449 | { USB_DEVICE(0x0c10, 0x0000), .driver_info = BTUSB_SWAVE }, |
1450 | |
1451 | diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c |
1452 | index 60c7fde37d23..4e21f5bcd954 100644 |
1453 | --- a/drivers/clk/clk.c |
1454 | +++ b/drivers/clk/clk.c |
1455 | @@ -1931,6 +1931,9 @@ static int clk_core_get_phase(struct clk_core *core) |
1456 | int ret; |
1457 | |
1458 | clk_prepare_lock(); |
1459 | + /* Always try to update cached phase if possible */ |
1460 | + if (core->ops->get_phase) |
1461 | + core->phase = core->ops->get_phase(core->hw); |
1462 | ret = core->phase; |
1463 | clk_prepare_unlock(); |
1464 | |
1465 | diff --git a/drivers/clk/hisilicon/crg-hi3516cv300.c b/drivers/clk/hisilicon/crg-hi3516cv300.c |
1466 | index 2007123832bb..53450b651e4c 100644 |
1467 | --- a/drivers/clk/hisilicon/crg-hi3516cv300.c |
1468 | +++ b/drivers/clk/hisilicon/crg-hi3516cv300.c |
1469 | @@ -204,7 +204,7 @@ static const struct hisi_crg_funcs hi3516cv300_crg_funcs = { |
1470 | /* hi3516CV300 sysctrl CRG */ |
1471 | #define HI3516CV300_SYSCTRL_NR_CLKS 16 |
1472 | |
1473 | -static const char *wdt_mux_p[] __initconst = { "3m", "apb" }; |
1474 | +static const char *const wdt_mux_p[] __initconst = { "3m", "apb" }; |
1475 | static u32 wdt_mux_table[] = {0, 1}; |
1476 | |
1477 | static const struct hisi_mux_clock hi3516cv300_sysctrl_mux_clks[] = { |
1478 | diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c |
1479 | index 077fcdc7908b..fe7d9ed1d436 100644 |
1480 | --- a/drivers/clk/rockchip/clk-mmc-phase.c |
1481 | +++ b/drivers/clk/rockchip/clk-mmc-phase.c |
1482 | @@ -58,6 +58,12 @@ static int rockchip_mmc_get_phase(struct clk_hw *hw) |
1483 | u16 degrees; |
1484 | u32 delay_num = 0; |
1485 | |
1486 | + /* See the comment for rockchip_mmc_set_phase below */ |
1487 | + if (!rate) { |
1488 | + pr_err("%s: invalid clk rate\n", __func__); |
1489 | + return -EINVAL; |
1490 | + } |
1491 | + |
1492 | raw_value = readl(mmc_clock->reg) >> (mmc_clock->shift); |
1493 | |
1494 | degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90; |
1495 | @@ -84,6 +90,23 @@ static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees) |
1496 | u32 raw_value; |
1497 | u32 delay; |
1498 | |
1499 | + /* |
1500 | + * The below calculation is based on the output clock from |
1501 | + * MMC host to the card, which expects the phase clock inherits |
1502 | + * the clock rate from its parent, namely the output clock |
1503 | + * provider of MMC host. However, things may go wrong if |
1504 | + * (1) It is orphan. |
1505 | + * (2) It is assigned to the wrong parent. |
1506 | + * |
1507 | + * This check help debug the case (1), which seems to be the |
1508 | + * most likely problem we often face and which makes it difficult |
1509 | + * for people to debug unstable mmc tuning results. |
1510 | + */ |
1511 | + if (!rate) { |
1512 | + pr_err("%s: invalid clk rate\n", __func__); |
1513 | + return -EINVAL; |
1514 | + } |
1515 | + |
1516 | nineties = degrees / 90; |
1517 | remainder = (degrees % 90); |
1518 | |
1519 | diff --git a/drivers/clk/rockchip/clk-rk3228.c b/drivers/clk/rockchip/clk-rk3228.c |
1520 | index 11e7f2d1c054..7af48184b022 100644 |
1521 | --- a/drivers/clk/rockchip/clk-rk3228.c |
1522 | +++ b/drivers/clk/rockchip/clk-rk3228.c |
1523 | @@ -387,7 +387,7 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = { |
1524 | RK2928_CLKSEL_CON(23), 5, 2, MFLAGS, 0, 6, DFLAGS, |
1525 | RK2928_CLKGATE_CON(2), 15, GFLAGS), |
1526 | |
1527 | - COMPOSITE(SCLK_SDMMC, "sclk_sdmmc0", mux_mmc_src_p, 0, |
1528 | + COMPOSITE(SCLK_SDMMC, "sclk_sdmmc", mux_mmc_src_p, 0, |
1529 | RK2928_CLKSEL_CON(11), 8, 2, MFLAGS, 0, 8, DFLAGS, |
1530 | RK2928_CLKGATE_CON(2), 11, GFLAGS), |
1531 | |
1532 | diff --git a/drivers/clk/samsung/clk-exynos3250.c b/drivers/clk/samsung/clk-exynos3250.c |
1533 | index 1b81e283f605..ed36728424a2 100644 |
1534 | --- a/drivers/clk/samsung/clk-exynos3250.c |
1535 | +++ b/drivers/clk/samsung/clk-exynos3250.c |
1536 | @@ -698,7 +698,7 @@ static const struct samsung_pll_rate_table exynos3250_epll_rates[] __initconst = |
1537 | PLL_36XX_RATE(144000000, 96, 2, 3, 0), |
1538 | PLL_36XX_RATE( 96000000, 128, 2, 4, 0), |
1539 | PLL_36XX_RATE( 84000000, 112, 2, 4, 0), |
1540 | - PLL_36XX_RATE( 80000004, 106, 2, 4, 43691), |
1541 | + PLL_36XX_RATE( 80000003, 106, 2, 4, 43691), |
1542 | PLL_36XX_RATE( 73728000, 98, 2, 4, 19923), |
1543 | PLL_36XX_RATE( 67737598, 270, 3, 5, 62285), |
1544 | PLL_36XX_RATE( 65535999, 174, 2, 5, 49982), |
1545 | @@ -734,7 +734,7 @@ static const struct samsung_pll_rate_table exynos3250_vpll_rates[] __initconst = |
1546 | PLL_36XX_RATE(148352005, 98, 2, 3, 59070), |
1547 | PLL_36XX_RATE(108000000, 144, 2, 4, 0), |
1548 | PLL_36XX_RATE( 74250000, 99, 2, 4, 0), |
1549 | - PLL_36XX_RATE( 74176002, 98, 3, 4, 59070), |
1550 | + PLL_36XX_RATE( 74176002, 98, 2, 4, 59070), |
1551 | PLL_36XX_RATE( 54054000, 216, 3, 5, 14156), |
1552 | PLL_36XX_RATE( 54000000, 144, 2, 5, 0), |
1553 | { /* sentinel */ } |
1554 | diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c |
1555 | index 27a227d6620c..6a0cb8a515e8 100644 |
1556 | --- a/drivers/clk/samsung/clk-exynos5250.c |
1557 | +++ b/drivers/clk/samsung/clk-exynos5250.c |
1558 | @@ -711,13 +711,13 @@ static const struct samsung_pll_rate_table epll_24mhz_tbl[] __initconst = { |
1559 | /* sorted in descending order */ |
1560 | /* PLL_36XX_RATE(rate, m, p, s, k) */ |
1561 | PLL_36XX_RATE(192000000, 64, 2, 2, 0), |
1562 | - PLL_36XX_RATE(180633600, 90, 3, 2, 20762), |
1563 | + PLL_36XX_RATE(180633605, 90, 3, 2, 20762), |
1564 | PLL_36XX_RATE(180000000, 90, 3, 2, 0), |
1565 | PLL_36XX_RATE(73728000, 98, 2, 4, 19923), |
1566 | - PLL_36XX_RATE(67737600, 90, 2, 4, 20762), |
1567 | + PLL_36XX_RATE(67737602, 90, 2, 4, 20762), |
1568 | PLL_36XX_RATE(49152000, 98, 3, 4, 19923), |
1569 | - PLL_36XX_RATE(45158400, 90, 3, 4, 20762), |
1570 | - PLL_36XX_RATE(32768000, 131, 3, 5, 4719), |
1571 | + PLL_36XX_RATE(45158401, 90, 3, 4, 20762), |
1572 | + PLL_36XX_RATE(32768001, 131, 3, 5, 4719), |
1573 | { }, |
1574 | }; |
1575 | |
1576 | diff --git a/drivers/clk/samsung/clk-exynos5260.c b/drivers/clk/samsung/clk-exynos5260.c |
1577 | index fd1d9bfc151b..8eae1752d700 100644 |
1578 | --- a/drivers/clk/samsung/clk-exynos5260.c |
1579 | +++ b/drivers/clk/samsung/clk-exynos5260.c |
1580 | @@ -65,7 +65,7 @@ static const struct samsung_pll_rate_table pll2650_24mhz_tbl[] __initconst = { |
1581 | PLL_36XX_RATE(480000000, 160, 2, 2, 0), |
1582 | PLL_36XX_RATE(432000000, 144, 2, 2, 0), |
1583 | PLL_36XX_RATE(400000000, 200, 3, 2, 0), |
1584 | - PLL_36XX_RATE(394073130, 459, 7, 2, 49282), |
1585 | + PLL_36XX_RATE(394073128, 459, 7, 2, 49282), |
1586 | PLL_36XX_RATE(333000000, 111, 2, 2, 0), |
1587 | PLL_36XX_RATE(300000000, 100, 2, 2, 0), |
1588 | PLL_36XX_RATE(266000000, 266, 3, 3, 0), |
1589 | diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c |
1590 | index 11343a597093..1d2265f9ee97 100644 |
1591 | --- a/drivers/clk/samsung/clk-exynos5433.c |
1592 | +++ b/drivers/clk/samsung/clk-exynos5433.c |
1593 | @@ -725,7 +725,7 @@ static const struct samsung_pll_rate_table exynos5433_pll_rates[] __initconst = |
1594 | PLL_35XX_RATE(800000000U, 400, 6, 1), |
1595 | PLL_35XX_RATE(733000000U, 733, 12, 1), |
1596 | PLL_35XX_RATE(700000000U, 175, 3, 1), |
1597 | - PLL_35XX_RATE(667000000U, 222, 4, 1), |
1598 | + PLL_35XX_RATE(666000000U, 222, 4, 1), |
1599 | PLL_35XX_RATE(633000000U, 211, 4, 1), |
1600 | PLL_35XX_RATE(600000000U, 500, 5, 2), |
1601 | PLL_35XX_RATE(552000000U, 460, 5, 2), |
1602 | @@ -753,12 +753,12 @@ static const struct samsung_pll_rate_table exynos5433_pll_rates[] __initconst = |
1603 | /* AUD_PLL */ |
1604 | static const struct samsung_pll_rate_table exynos5433_aud_pll_rates[] __initconst = { |
1605 | PLL_36XX_RATE(400000000U, 200, 3, 2, 0), |
1606 | - PLL_36XX_RATE(393216000U, 197, 3, 2, -25690), |
1607 | + PLL_36XX_RATE(393216003U, 197, 3, 2, -25690), |
1608 | PLL_36XX_RATE(384000000U, 128, 2, 2, 0), |
1609 | - PLL_36XX_RATE(368640000U, 246, 4, 2, -15729), |
1610 | - PLL_36XX_RATE(361507200U, 181, 3, 2, -16148), |
1611 | - PLL_36XX_RATE(338688000U, 113, 2, 2, -6816), |
1612 | - PLL_36XX_RATE(294912000U, 98, 1, 3, 19923), |
1613 | + PLL_36XX_RATE(368639991U, 246, 4, 2, -15729), |
1614 | + PLL_36XX_RATE(361507202U, 181, 3, 2, -16148), |
1615 | + PLL_36XX_RATE(338687988U, 113, 2, 2, -6816), |
1616 | + PLL_36XX_RATE(294912002U, 98, 1, 3, 19923), |
1617 | PLL_36XX_RATE(288000000U, 96, 1, 3, 0), |
1618 | PLL_36XX_RATE(252000000U, 84, 1, 3, 0), |
1619 | { /* sentinel */ } |
1620 | diff --git a/drivers/clk/samsung/clk-exynos7.c b/drivers/clk/samsung/clk-exynos7.c |
1621 | index 5931a4140c3d..bbfa57b4e017 100644 |
1622 | --- a/drivers/clk/samsung/clk-exynos7.c |
1623 | +++ b/drivers/clk/samsung/clk-exynos7.c |
1624 | @@ -140,7 +140,7 @@ static const struct samsung_div_clock topc_div_clks[] __initconst = { |
1625 | }; |
1626 | |
1627 | static const struct samsung_pll_rate_table pll1460x_24mhz_tbl[] __initconst = { |
1628 | - PLL_36XX_RATE(491520000, 20, 1, 0, 31457), |
1629 | + PLL_36XX_RATE(491519897, 20, 1, 0, 31457), |
1630 | {}, |
1631 | }; |
1632 | |
1633 | diff --git a/drivers/clk/samsung/clk-s3c2410.c b/drivers/clk/samsung/clk-s3c2410.c |
1634 | index e0650c33863b..d8e58a659467 100644 |
1635 | --- a/drivers/clk/samsung/clk-s3c2410.c |
1636 | +++ b/drivers/clk/samsung/clk-s3c2410.c |
1637 | @@ -168,7 +168,7 @@ static struct samsung_pll_rate_table pll_s3c2410_12mhz_tbl[] __initdata = { |
1638 | PLL_35XX_RATE(226000000, 105, 1, 1), |
1639 | PLL_35XX_RATE(210000000, 132, 2, 1), |
1640 | /* 2410 common */ |
1641 | - PLL_35XX_RATE(203000000, 161, 3, 1), |
1642 | + PLL_35XX_RATE(202800000, 161, 3, 1), |
1643 | PLL_35XX_RATE(192000000, 88, 1, 1), |
1644 | PLL_35XX_RATE(186000000, 85, 1, 1), |
1645 | PLL_35XX_RATE(180000000, 82, 1, 1), |
1646 | @@ -178,18 +178,18 @@ static struct samsung_pll_rate_table pll_s3c2410_12mhz_tbl[] __initdata = { |
1647 | PLL_35XX_RATE(147000000, 90, 2, 1), |
1648 | PLL_35XX_RATE(135000000, 82, 2, 1), |
1649 | PLL_35XX_RATE(124000000, 116, 1, 2), |
1650 | - PLL_35XX_RATE(118000000, 150, 2, 2), |
1651 | + PLL_35XX_RATE(118500000, 150, 2, 2), |
1652 | PLL_35XX_RATE(113000000, 105, 1, 2), |
1653 | - PLL_35XX_RATE(101000000, 127, 2, 2), |
1654 | + PLL_35XX_RATE(101250000, 127, 2, 2), |
1655 | PLL_35XX_RATE(90000000, 112, 2, 2), |
1656 | - PLL_35XX_RATE(85000000, 105, 2, 2), |
1657 | + PLL_35XX_RATE(84750000, 105, 2, 2), |
1658 | PLL_35XX_RATE(79000000, 71, 1, 2), |
1659 | - PLL_35XX_RATE(68000000, 82, 2, 2), |
1660 | - PLL_35XX_RATE(56000000, 142, 2, 3), |
1661 | + PLL_35XX_RATE(67500000, 82, 2, 2), |
1662 | + PLL_35XX_RATE(56250000, 142, 2, 3), |
1663 | PLL_35XX_RATE(48000000, 120, 2, 3), |
1664 | - PLL_35XX_RATE(51000000, 161, 3, 3), |
1665 | + PLL_35XX_RATE(50700000, 161, 3, 3), |
1666 | PLL_35XX_RATE(45000000, 82, 1, 3), |
1667 | - PLL_35XX_RATE(34000000, 82, 2, 3), |
1668 | + PLL_35XX_RATE(33750000, 82, 2, 3), |
1669 | { /* sentinel */ }, |
1670 | }; |
1671 | |
1672 | diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c |
1673 | index 7c369e21c91c..830d1c87fa7c 100644 |
1674 | --- a/drivers/clk/tegra/clk-pll.c |
1675 | +++ b/drivers/clk/tegra/clk-pll.c |
1676 | @@ -1151,6 +1151,8 @@ static const struct clk_ops tegra_clk_pllu_ops = { |
1677 | .enable = clk_pllu_enable, |
1678 | .disable = clk_pll_disable, |
1679 | .recalc_rate = clk_pll_recalc_rate, |
1680 | + .round_rate = clk_pll_round_rate, |
1681 | + .set_rate = clk_pll_set_rate, |
1682 | }; |
1683 | |
1684 | static int _pll_fixed_mdiv(struct tegra_clk_pll_params *pll_params, |
1685 | diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c |
1686 | index 29e20c37f3a6..11129b796dda 100644 |
1687 | --- a/drivers/crypto/atmel-aes.c |
1688 | +++ b/drivers/crypto/atmel-aes.c |
1689 | @@ -2145,7 +2145,7 @@ static int atmel_aes_authenc_setkey(struct crypto_aead *tfm, const u8 *key, |
1690 | |
1691 | badkey: |
1692 | crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
1693 | - memzero_explicit(&key, sizeof(keys)); |
1694 | + memzero_explicit(&keys, sizeof(keys)); |
1695 | return -EINVAL; |
1696 | } |
1697 | |
1698 | diff --git a/drivers/crypto/ccp/ccp-debugfs.c b/drivers/crypto/ccp/ccp-debugfs.c |
1699 | index 59d4ca4e72d8..1a734bd2070a 100644 |
1700 | --- a/drivers/crypto/ccp/ccp-debugfs.c |
1701 | +++ b/drivers/crypto/ccp/ccp-debugfs.c |
1702 | @@ -278,7 +278,7 @@ static const struct file_operations ccp_debugfs_stats_ops = { |
1703 | }; |
1704 | |
1705 | static struct dentry *ccp_debugfs_dir; |
1706 | -static DEFINE_RWLOCK(ccp_debugfs_lock); |
1707 | +static DEFINE_MUTEX(ccp_debugfs_lock); |
1708 | |
1709 | #define MAX_NAME_LEN 20 |
1710 | |
1711 | @@ -290,16 +290,15 @@ void ccp5_debugfs_setup(struct ccp_device *ccp) |
1712 | struct dentry *debugfs_stats; |
1713 | struct dentry *debugfs_q_instance; |
1714 | struct dentry *debugfs_q_stats; |
1715 | - unsigned long flags; |
1716 | int i; |
1717 | |
1718 | if (!debugfs_initialized()) |
1719 | return; |
1720 | |
1721 | - write_lock_irqsave(&ccp_debugfs_lock, flags); |
1722 | + mutex_lock(&ccp_debugfs_lock); |
1723 | if (!ccp_debugfs_dir) |
1724 | ccp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL); |
1725 | - write_unlock_irqrestore(&ccp_debugfs_lock, flags); |
1726 | + mutex_unlock(&ccp_debugfs_lock); |
1727 | if (!ccp_debugfs_dir) |
1728 | return; |
1729 | |
1730 | diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c |
1731 | index d4c81cb73bee..3ee68ecde9ec 100644 |
1732 | --- a/drivers/crypto/inside-secure/safexcel.c |
1733 | +++ b/drivers/crypto/inside-secure/safexcel.c |
1734 | @@ -462,6 +462,15 @@ void safexcel_dequeue(struct safexcel_crypto_priv *priv, int ring) |
1735 | if (backlog) |
1736 | backlog->complete(backlog, -EINPROGRESS); |
1737 | |
1738 | + /* In case the send() helper did not issue any command to push |
1739 | + * to the engine because the input data was cached, continue to |
1740 | + * dequeue other requests as this is valid and not an error. |
1741 | + */ |
1742 | + if (!commands && !results) { |
1743 | + kfree(request); |
1744 | + continue; |
1745 | + } |
1746 | + |
1747 | spin_lock_bh(&priv->ring[ring].egress_lock); |
1748 | list_add_tail(&request->list, &priv->ring[ring].list); |
1749 | spin_unlock_bh(&priv->ring[ring].egress_lock); |
1750 | diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c |
1751 | index fcc0a606d748..29cf7e00b574 100644 |
1752 | --- a/drivers/crypto/inside-secure/safexcel_cipher.c |
1753 | +++ b/drivers/crypto/inside-secure/safexcel_cipher.c |
1754 | @@ -446,7 +446,7 @@ static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm) |
1755 | if (!priv->ring[ring].need_dequeue) |
1756 | safexcel_dequeue(priv, ring); |
1757 | |
1758 | - wait_for_completion_interruptible(&result.completion); |
1759 | + wait_for_completion(&result.completion); |
1760 | |
1761 | if (result.error) { |
1762 | dev_warn(priv->dev, |
1763 | diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c |
1764 | index d626aa485a76..69f29776591a 100644 |
1765 | --- a/drivers/crypto/inside-secure/safexcel_hash.c |
1766 | +++ b/drivers/crypto/inside-secure/safexcel_hash.c |
1767 | @@ -185,7 +185,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, |
1768 | int i, queued, len, cache_len, extra, n_cdesc = 0, ret = 0; |
1769 | |
1770 | queued = len = req->len - req->processed; |
1771 | - if (queued < crypto_ahash_blocksize(ahash)) |
1772 | + if (queued <= crypto_ahash_blocksize(ahash)) |
1773 | cache_len = queued; |
1774 | else |
1775 | cache_len = queued - areq->nbytes; |
1776 | @@ -199,7 +199,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, |
1777 | /* If this is not the last request and the queued data |
1778 | * is a multiple of a block, cache the last one for now. |
1779 | */ |
1780 | - extra = queued - crypto_ahash_blocksize(ahash); |
1781 | + extra = crypto_ahash_blocksize(ahash); |
1782 | |
1783 | if (extra) { |
1784 | sg_pcopy_to_buffer(areq->src, sg_nents(areq->src), |
1785 | @@ -494,7 +494,7 @@ static int safexcel_ahash_exit_inv(struct crypto_tfm *tfm) |
1786 | if (!priv->ring[ring].need_dequeue) |
1787 | safexcel_dequeue(priv, ring); |
1788 | |
1789 | - wait_for_completion_interruptible(&result.completion); |
1790 | + wait_for_completion(&result.completion); |
1791 | |
1792 | if (result.error) { |
1793 | dev_warn(priv->dev, "hash: completion error (%d)\n", |
1794 | @@ -819,7 +819,7 @@ static int safexcel_hmac_init_pad(struct ahash_request *areq, |
1795 | init_completion(&result.completion); |
1796 | |
1797 | ret = crypto_ahash_digest(areq); |
1798 | - if (ret == -EINPROGRESS) { |
1799 | + if (ret == -EINPROGRESS || ret == -EBUSY) { |
1800 | wait_for_completion_interruptible(&result.completion); |
1801 | ret = result.error; |
1802 | } |
1803 | diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c |
1804 | index 1547cbe13dc2..a81d89b3b7d8 100644 |
1805 | --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c |
1806 | +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c |
1807 | @@ -451,6 +451,7 @@ static struct platform_driver sun4i_ss_driver = { |
1808 | |
1809 | module_platform_driver(sun4i_ss_driver); |
1810 | |
1811 | +MODULE_ALIAS("platform:sun4i-ss"); |
1812 | MODULE_DESCRIPTION("Allwinner Security System cryptographic accelerator"); |
1813 | MODULE_LICENSE("GPL"); |
1814 | MODULE_AUTHOR("Corentin LABBE <clabbe.montjoie@gmail.com>"); |
1815 | diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c |
1816 | index 18e4230865be..51009b2718a3 100644 |
1817 | --- a/drivers/media/dvb-core/dmxdev.c |
1818 | +++ b/drivers/media/dvb-core/dmxdev.c |
1819 | @@ -1055,7 +1055,7 @@ static int dvb_demux_do_ioctl(struct file *file, |
1820 | break; |
1821 | |
1822 | default: |
1823 | - ret = -EINVAL; |
1824 | + ret = -ENOTTY; |
1825 | break; |
1826 | } |
1827 | mutex_unlock(&dmxdev->mutex); |
1828 | diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c |
1829 | index c9b1eb38444e..fbb3b2f49d2d 100644 |
1830 | --- a/drivers/media/dvb-frontends/lgdt3306a.c |
1831 | +++ b/drivers/media/dvb-frontends/lgdt3306a.c |
1832 | @@ -1767,7 +1767,13 @@ static void lgdt3306a_release(struct dvb_frontend *fe) |
1833 | struct lgdt3306a_state *state = fe->demodulator_priv; |
1834 | |
1835 | dbg_info("\n"); |
1836 | - kfree(state); |
1837 | + |
1838 | + /* |
1839 | + * If state->muxc is not NULL, then we are an i2c device |
1840 | + * and lgdt3306a_remove will clean up state |
1841 | + */ |
1842 | + if (!state->muxc) |
1843 | + kfree(state); |
1844 | } |
1845 | |
1846 | static const struct dvb_frontend_ops lgdt3306a_ops; |
1847 | @@ -2168,7 +2174,7 @@ static int lgdt3306a_probe(struct i2c_client *client, |
1848 | sizeof(struct lgdt3306a_config)); |
1849 | |
1850 | config->i2c_addr = client->addr; |
1851 | - fe = lgdt3306a_attach(config, client->adapter); |
1852 | + fe = dvb_attach(lgdt3306a_attach, config, client->adapter); |
1853 | if (fe == NULL) { |
1854 | ret = -ENODEV; |
1855 | goto err_fe; |
1856 | diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c |
1857 | index 4da4253553fc..10d229a4f088 100644 |
1858 | --- a/drivers/media/i2c/adv748x/adv748x-hdmi.c |
1859 | +++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c |
1860 | @@ -105,6 +105,9 @@ static void adv748x_hdmi_fill_format(struct adv748x_hdmi *hdmi, |
1861 | |
1862 | fmt->width = hdmi->timings.bt.width; |
1863 | fmt->height = hdmi->timings.bt.height; |
1864 | + |
1865 | + if (fmt->field == V4L2_FIELD_ALTERNATE) |
1866 | + fmt->height /= 2; |
1867 | } |
1868 | |
1869 | static void adv748x_fill_optional_dv_timings(struct v4l2_dv_timings *timings) |
1870 | diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c |
1871 | index d28845f7356f..a31fe18c71d6 100644 |
1872 | --- a/drivers/media/i2c/ov5645.c |
1873 | +++ b/drivers/media/i2c/ov5645.c |
1874 | @@ -1131,13 +1131,14 @@ static int ov5645_probe(struct i2c_client *client, |
1875 | |
1876 | ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), |
1877 | &ov5645->ep); |
1878 | + |
1879 | + of_node_put(endpoint); |
1880 | + |
1881 | if (ret < 0) { |
1882 | dev_err(dev, "parsing endpoint node failed\n"); |
1883 | return ret; |
1884 | } |
1885 | |
1886 | - of_node_put(endpoint); |
1887 | - |
1888 | if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) { |
1889 | dev_err(dev, "invalid bus type, must be CSI2\n"); |
1890 | return -EINVAL; |
1891 | diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c |
1892 | index 7b79a7498751..698fa764999c 100644 |
1893 | --- a/drivers/media/i2c/tvp5150.c |
1894 | +++ b/drivers/media/i2c/tvp5150.c |
1895 | @@ -506,80 +506,77 @@ static struct i2c_vbi_ram_value vbi_ram_default[] = |
1896 | /* FIXME: Current api doesn't handle all VBI types, those not |
1897 | yet supported are placed under #if 0 */ |
1898 | #if 0 |
1899 | - {0x010, /* Teletext, SECAM, WST System A */ |
1900 | + [0] = {0x010, /* Teletext, SECAM, WST System A */ |
1901 | {V4L2_SLICED_TELETEXT_SECAM,6,23,1}, |
1902 | { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26, |
1903 | 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 } |
1904 | }, |
1905 | #endif |
1906 | - {0x030, /* Teletext, PAL, WST System B */ |
1907 | + [1] = {0x030, /* Teletext, PAL, WST System B */ |
1908 | {V4L2_SLICED_TELETEXT_B,6,22,1}, |
1909 | { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b, |
1910 | 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 } |
1911 | }, |
1912 | #if 0 |
1913 | - {0x050, /* Teletext, PAL, WST System C */ |
1914 | + [2] = {0x050, /* Teletext, PAL, WST System C */ |
1915 | {V4L2_SLICED_TELETEXT_PAL_C,6,22,1}, |
1916 | { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22, |
1917 | 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 } |
1918 | }, |
1919 | - {0x070, /* Teletext, NTSC, WST System B */ |
1920 | + [3] = {0x070, /* Teletext, NTSC, WST System B */ |
1921 | {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1}, |
1922 | { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23, |
1923 | 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 } |
1924 | }, |
1925 | - {0x090, /* Tetetext, NTSC NABTS System C */ |
1926 | + [4] = {0x090, /* Tetetext, NTSC NABTS System C */ |
1927 | {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1}, |
1928 | { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22, |
1929 | 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 } |
1930 | }, |
1931 | - {0x0b0, /* Teletext, NTSC-J, NABTS System D */ |
1932 | + [5] = {0x0b0, /* Teletext, NTSC-J, NABTS System D */ |
1933 | {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1}, |
1934 | { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23, |
1935 | 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 } |
1936 | }, |
1937 | - {0x0d0, /* Closed Caption, PAL/SECAM */ |
1938 | + [6] = {0x0d0, /* Closed Caption, PAL/SECAM */ |
1939 | {V4L2_SLICED_CAPTION_625,22,22,1}, |
1940 | { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02, |
1941 | 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 } |
1942 | }, |
1943 | #endif |
1944 | - {0x0f0, /* Closed Caption, NTSC */ |
1945 | + [7] = {0x0f0, /* Closed Caption, NTSC */ |
1946 | {V4L2_SLICED_CAPTION_525,21,21,1}, |
1947 | { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02, |
1948 | 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 } |
1949 | }, |
1950 | - {0x110, /* Wide Screen Signal, PAL/SECAM */ |
1951 | + [8] = {0x110, /* Wide Screen Signal, PAL/SECAM */ |
1952 | {V4L2_SLICED_WSS_625,23,23,1}, |
1953 | { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42, |
1954 | 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 } |
1955 | }, |
1956 | #if 0 |
1957 | - {0x130, /* Wide Screen Signal, NTSC C */ |
1958 | + [9] = {0x130, /* Wide Screen Signal, NTSC C */ |
1959 | {V4L2_SLICED_WSS_525,20,20,1}, |
1960 | { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43, |
1961 | 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 } |
1962 | }, |
1963 | - {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */ |
1964 | + [10] = {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */ |
1965 | {V4l2_SLICED_VITC_625,6,22,0}, |
1966 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49, |
1967 | 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 } |
1968 | }, |
1969 | - {0x170, /* Vertical Interval Timecode (VITC), NTSC */ |
1970 | + [11] = {0x170, /* Vertical Interval Timecode (VITC), NTSC */ |
1971 | {V4l2_SLICED_VITC_525,10,20,0}, |
1972 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49, |
1973 | 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 } |
1974 | }, |
1975 | #endif |
1976 | - {0x190, /* Video Program System (VPS), PAL */ |
1977 | + [12] = {0x190, /* Video Program System (VPS), PAL */ |
1978 | {V4L2_SLICED_VPS,16,16,0}, |
1979 | { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d, |
1980 | 0xa6, 0xda, 0x0b, 0x00, 0x00, 0x00, 0x60, 0x00 } |
1981 | }, |
1982 | /* 0x1d0 User programmable */ |
1983 | - |
1984 | - /* End of struct */ |
1985 | - { (u16)-1 } |
1986 | }; |
1987 | |
1988 | static int tvp5150_write_inittab(struct v4l2_subdev *sd, |
1989 | @@ -592,10 +589,10 @@ static int tvp5150_write_inittab(struct v4l2_subdev *sd, |
1990 | return 0; |
1991 | } |
1992 | |
1993 | -static int tvp5150_vdp_init(struct v4l2_subdev *sd, |
1994 | - const struct i2c_vbi_ram_value *regs) |
1995 | +static int tvp5150_vdp_init(struct v4l2_subdev *sd) |
1996 | { |
1997 | unsigned int i; |
1998 | + int j; |
1999 | |
2000 | /* Disable Full Field */ |
2001 | tvp5150_write(sd, TVP5150_FULL_FIELD_ENA, 0); |
2002 | @@ -605,14 +602,17 @@ static int tvp5150_vdp_init(struct v4l2_subdev *sd, |
2003 | tvp5150_write(sd, i, 0xff); |
2004 | |
2005 | /* Load Ram Table */ |
2006 | - while (regs->reg != (u16)-1) { |
2007 | + for (j = 0; j < ARRAY_SIZE(vbi_ram_default); j++) { |
2008 | + const struct i2c_vbi_ram_value *regs = &vbi_ram_default[j]; |
2009 | + |
2010 | + if (!regs->type.vbi_type) |
2011 | + continue; |
2012 | + |
2013 | tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_HIGH, regs->reg >> 8); |
2014 | tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_LOW, regs->reg); |
2015 | |
2016 | for (i = 0; i < 16; i++) |
2017 | tvp5150_write(sd, TVP5150_VDP_CONF_RAM_DATA, regs->values[i]); |
2018 | - |
2019 | - regs++; |
2020 | } |
2021 | return 0; |
2022 | } |
2023 | @@ -621,19 +621,23 @@ static int tvp5150_vdp_init(struct v4l2_subdev *sd, |
2024 | static int tvp5150_g_sliced_vbi_cap(struct v4l2_subdev *sd, |
2025 | struct v4l2_sliced_vbi_cap *cap) |
2026 | { |
2027 | - const struct i2c_vbi_ram_value *regs = vbi_ram_default; |
2028 | - int line; |
2029 | + int line, i; |
2030 | |
2031 | dev_dbg_lvl(sd->dev, 1, debug, "g_sliced_vbi_cap\n"); |
2032 | memset(cap, 0, sizeof *cap); |
2033 | |
2034 | - while (regs->reg != (u16)-1 ) { |
2035 | - for (line=regs->type.ini_line;line<=regs->type.end_line;line++) { |
2036 | + for (i = 0; i < ARRAY_SIZE(vbi_ram_default); i++) { |
2037 | + const struct i2c_vbi_ram_value *regs = &vbi_ram_default[i]; |
2038 | + |
2039 | + if (!regs->type.vbi_type) |
2040 | + continue; |
2041 | + |
2042 | + for (line = regs->type.ini_line; |
2043 | + line <= regs->type.end_line; |
2044 | + line++) { |
2045 | cap->service_lines[0][line] |= regs->type.vbi_type; |
2046 | } |
2047 | cap->service_set |= regs->type.vbi_type; |
2048 | - |
2049 | - regs++; |
2050 | } |
2051 | return 0; |
2052 | } |
2053 | @@ -652,14 +656,13 @@ static int tvp5150_g_sliced_vbi_cap(struct v4l2_subdev *sd, |
2054 | * MSB = field2 |
2055 | */ |
2056 | static int tvp5150_set_vbi(struct v4l2_subdev *sd, |
2057 | - const struct i2c_vbi_ram_value *regs, |
2058 | unsigned int type,u8 flags, int line, |
2059 | const int fields) |
2060 | { |
2061 | struct tvp5150 *decoder = to_tvp5150(sd); |
2062 | v4l2_std_id std = decoder->norm; |
2063 | u8 reg; |
2064 | - int pos = 0; |
2065 | + int i, pos = 0; |
2066 | |
2067 | if (std == V4L2_STD_ALL) { |
2068 | dev_err(sd->dev, "VBI can't be configured without knowing number of lines\n"); |
2069 | @@ -672,19 +675,19 @@ static int tvp5150_set_vbi(struct v4l2_subdev *sd, |
2070 | if (line < 6 || line > 27) |
2071 | return 0; |
2072 | |
2073 | - while (regs->reg != (u16)-1) { |
2074 | + for (i = 0; i < ARRAY_SIZE(vbi_ram_default); i++) { |
2075 | + const struct i2c_vbi_ram_value *regs = &vbi_ram_default[i]; |
2076 | + |
2077 | + if (!regs->type.vbi_type) |
2078 | + continue; |
2079 | + |
2080 | if ((type & regs->type.vbi_type) && |
2081 | (line >= regs->type.ini_line) && |
2082 | (line <= regs->type.end_line)) |
2083 | break; |
2084 | - |
2085 | - regs++; |
2086 | pos++; |
2087 | } |
2088 | |
2089 | - if (regs->reg == (u16)-1) |
2090 | - return 0; |
2091 | - |
2092 | type = pos | (flags & 0xf0); |
2093 | reg = ((line - 6) << 1) + TVP5150_LINE_MODE_INI; |
2094 | |
2095 | @@ -697,8 +700,7 @@ static int tvp5150_set_vbi(struct v4l2_subdev *sd, |
2096 | return type; |
2097 | } |
2098 | |
2099 | -static int tvp5150_get_vbi(struct v4l2_subdev *sd, |
2100 | - const struct i2c_vbi_ram_value *regs, int line) |
2101 | +static int tvp5150_get_vbi(struct v4l2_subdev *sd, int line) |
2102 | { |
2103 | struct tvp5150 *decoder = to_tvp5150(sd); |
2104 | v4l2_std_id std = decoder->norm; |
2105 | @@ -727,8 +729,8 @@ static int tvp5150_get_vbi(struct v4l2_subdev *sd, |
2106 | return 0; |
2107 | } |
2108 | pos = ret & 0x0f; |
2109 | - if (pos < 0x0f) |
2110 | - type |= regs[pos].type.vbi_type; |
2111 | + if (pos < ARRAY_SIZE(vbi_ram_default)) |
2112 | + type |= vbi_ram_default[pos].type.vbi_type; |
2113 | } |
2114 | |
2115 | return type; |
2116 | @@ -789,7 +791,7 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val) |
2117 | tvp5150_write_inittab(sd, tvp5150_init_default); |
2118 | |
2119 | /* Initializes VDP registers */ |
2120 | - tvp5150_vdp_init(sd, vbi_ram_default); |
2121 | + tvp5150_vdp_init(sd); |
2122 | |
2123 | /* Selects decoder input */ |
2124 | tvp5150_selmux(sd); |
2125 | @@ -1122,8 +1124,8 @@ static int tvp5150_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f |
2126 | for (i = 0; i <= 23; i++) { |
2127 | svbi->service_lines[1][i] = 0; |
2128 | svbi->service_lines[0][i] = |
2129 | - tvp5150_set_vbi(sd, vbi_ram_default, |
2130 | - svbi->service_lines[0][i], 0xf0, i, 3); |
2131 | + tvp5150_set_vbi(sd, svbi->service_lines[0][i], |
2132 | + 0xf0, i, 3); |
2133 | } |
2134 | /* Enables FIFO */ |
2135 | tvp5150_write(sd, TVP5150_FIFO_OUT_CTRL, 1); |
2136 | @@ -1149,7 +1151,7 @@ static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f |
2137 | |
2138 | for (i = 0; i <= 23; i++) { |
2139 | svbi->service_lines[0][i] = |
2140 | - tvp5150_get_vbi(sd, vbi_ram_default, i); |
2141 | + tvp5150_get_vbi(sd, i); |
2142 | mask |= svbi->service_lines[0][i]; |
2143 | } |
2144 | svbi->service_set = mask; |
2145 | diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c |
2146 | index 78a8836d03e4..6c0fd9438dd9 100644 |
2147 | --- a/drivers/media/pci/cx23885/cx23885-cards.c |
2148 | +++ b/drivers/media/pci/cx23885/cx23885-cards.c |
2149 | @@ -2286,6 +2286,10 @@ void cx23885_card_setup(struct cx23885_dev *dev) |
2150 | &dev->i2c_bus[2].i2c_adap, |
2151 | "cx25840", 0x88 >> 1, NULL); |
2152 | if (dev->sd_cx25840) { |
2153 | + /* set host data for clk_freq configuration */ |
2154 | + v4l2_set_subdev_hostdata(dev->sd_cx25840, |
2155 | + &dev->clk_freq); |
2156 | + |
2157 | dev->sd_cx25840->grp_id = CX23885_HW_AV_CORE; |
2158 | v4l2_subdev_call(dev->sd_cx25840, core, load_fw); |
2159 | } |
2160 | diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c |
2161 | index 8f63df1cb418..4612f26fcd6d 100644 |
2162 | --- a/drivers/media/pci/cx23885/cx23885-core.c |
2163 | +++ b/drivers/media/pci/cx23885/cx23885-core.c |
2164 | @@ -873,6 +873,16 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) |
2165 | if (cx23885_boards[dev->board].clk_freq > 0) |
2166 | dev->clk_freq = cx23885_boards[dev->board].clk_freq; |
2167 | |
2168 | + if (dev->board == CX23885_BOARD_HAUPPAUGE_IMPACTVCBE && |
2169 | + dev->pci->subsystem_device == 0x7137) { |
2170 | + /* Hauppauge ImpactVCBe device ID 0x7137 is populated |
2171 | + * with an 888, and a 25Mhz crystal, instead of the |
2172 | + * usual third overtone 50Mhz. The default clock rate must |
2173 | + * be overridden so the cx25840 is properly configured |
2174 | + */ |
2175 | + dev->clk_freq = 25000000; |
2176 | + } |
2177 | + |
2178 | dev->pci_bus = dev->pci->bus->number; |
2179 | dev->pci_slot = PCI_SLOT(dev->pci->devfn); |
2180 | cx23885_irq_add(dev, 0x001f00); |
2181 | diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c |
2182 | index 04aa4a68a0ae..040c6c251d3a 100644 |
2183 | --- a/drivers/media/pci/cx25821/cx25821-core.c |
2184 | +++ b/drivers/media/pci/cx25821/cx25821-core.c |
2185 | @@ -867,6 +867,10 @@ static int cx25821_dev_setup(struct cx25821_dev *dev) |
2186 | dev->nr = ++cx25821_devcount; |
2187 | sprintf(dev->name, "cx25821[%d]", dev->nr); |
2188 | |
2189 | + if (dev->nr >= ARRAY_SIZE(card)) { |
2190 | + CX25821_INFO("dev->nr >= %zd", ARRAY_SIZE(card)); |
2191 | + return -ENODEV; |
2192 | + } |
2193 | if (dev->pci->device != 0x8210) { |
2194 | pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n", |
2195 | __func__, dev->pci->device); |
2196 | @@ -882,9 +886,6 @@ static int cx25821_dev_setup(struct cx25821_dev *dev) |
2197 | dev->channels[i].sram_channels = &cx25821_sram_channels[i]; |
2198 | } |
2199 | |
2200 | - if (dev->nr > 1) |
2201 | - CX25821_INFO("dev->nr > 1!"); |
2202 | - |
2203 | /* board config */ |
2204 | dev->board = 1; /* card[dev->nr]; */ |
2205 | dev->_max_num_decoders = MAX_DECODERS; |
2206 | diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c |
2207 | index 25c7a7d42292..0f0324a14d51 100644 |
2208 | --- a/drivers/media/platform/s3c-camif/camif-capture.c |
2209 | +++ b/drivers/media/platform/s3c-camif/camif-capture.c |
2210 | @@ -1256,16 +1256,17 @@ static void __camif_subdev_try_format(struct camif_dev *camif, |
2211 | { |
2212 | const struct s3c_camif_variant *variant = camif->variant; |
2213 | const struct vp_pix_limits *pix_lim; |
2214 | - int i = ARRAY_SIZE(camif_mbus_formats); |
2215 | + unsigned int i; |
2216 | |
2217 | /* FIXME: constraints against codec or preview path ? */ |
2218 | pix_lim = &variant->vp_pix_limits[VP_CODEC]; |
2219 | |
2220 | - while (i-- >= 0) |
2221 | + for (i = 0; i < ARRAY_SIZE(camif_mbus_formats); i++) |
2222 | if (camif_mbus_formats[i] == mf->code) |
2223 | break; |
2224 | |
2225 | - mf->code = camif_mbus_formats[i]; |
2226 | + if (i == ARRAY_SIZE(camif_mbus_formats)) |
2227 | + mf->code = camif_mbus_formats[0]; |
2228 | |
2229 | if (pad == CAMIF_SD_PAD_SINK) { |
2230 | v4l_bound_align_image(&mf->width, 8, CAMIF_MAX_PIX_WIDTH, |
2231 | diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c |
2232 | index 34731f71cc00..8ca9343b6730 100644 |
2233 | --- a/drivers/media/platform/vivid/vivid-ctrls.c |
2234 | +++ b/drivers/media/platform/vivid/vivid-ctrls.c |
2235 | @@ -1191,6 +1191,7 @@ static int vivid_radio_rx_s_ctrl(struct v4l2_ctrl *ctrl) |
2236 | v4l2_ctrl_activate(dev->radio_rx_rds_ta, dev->radio_rx_rds_controls); |
2237 | v4l2_ctrl_activate(dev->radio_rx_rds_tp, dev->radio_rx_rds_controls); |
2238 | v4l2_ctrl_activate(dev->radio_rx_rds_ms, dev->radio_rx_rds_controls); |
2239 | + dev->radio_rx_dev.device_caps = dev->radio_rx_caps; |
2240 | break; |
2241 | case V4L2_CID_RDS_RECEPTION: |
2242 | dev->radio_rx_rds_enabled = ctrl->val; |
2243 | @@ -1265,6 +1266,7 @@ static int vivid_radio_tx_s_ctrl(struct v4l2_ctrl *ctrl) |
2244 | dev->radio_tx_caps &= ~V4L2_CAP_READWRITE; |
2245 | if (!dev->radio_tx_rds_controls) |
2246 | dev->radio_tx_caps |= V4L2_CAP_READWRITE; |
2247 | + dev->radio_tx_dev.device_caps = dev->radio_tx_caps; |
2248 | break; |
2249 | case V4L2_CID_RDS_TX_PTY: |
2250 | if (dev->radio_rx_rds_controls) |
2251 | diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c |
2252 | index 4dfbeac8f42c..d3cd57f6ba52 100644 |
2253 | --- a/drivers/media/platform/vsp1/vsp1_drm.c |
2254 | +++ b/drivers/media/platform/vsp1/vsp1_drm.c |
2255 | @@ -504,6 +504,15 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index) |
2256 | struct vsp1_rwpf *rpf = vsp1->rpf[i]; |
2257 | unsigned int j; |
2258 | |
2259 | + /* |
2260 | + * Make sure we don't accept more inputs than the hardware can |
2261 | + * handle. This is a temporary fix to avoid display stall, we |
2262 | + * need to instead allocate the BRU or BRS to display pipelines |
2263 | + * dynamically based on the number of planes they each use. |
2264 | + */ |
2265 | + if (pipe->num_inputs >= pipe->bru->source_pad) |
2266 | + pipe->inputs[i] = NULL; |
2267 | + |
2268 | if (!pipe->inputs[i]) |
2269 | continue; |
2270 | |
2271 | diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c |
2272 | index 4c57fd7929cb..11a59854a0a6 100644 |
2273 | --- a/drivers/media/usb/em28xx/em28xx-cards.c |
2274 | +++ b/drivers/media/usb/em28xx/em28xx-cards.c |
2275 | @@ -508,8 +508,10 @@ static struct em28xx_reg_seq plex_px_bcud[] = { |
2276 | }; |
2277 | |
2278 | /* |
2279 | - * 2040:0265 Hauppauge WinTV-dualHD DVB |
2280 | - * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM |
2281 | + * 2040:0265 Hauppauge WinTV-dualHD DVB Isoc |
2282 | + * 2040:8265 Hauppauge WinTV-dualHD DVB Bulk |
2283 | + * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM Isoc |
2284 | + * 2040:826d Hauppauge WinTV-dualHD ATSC/QAM Bulk |
2285 | * reg 0x80/0x84: |
2286 | * GPIO_0: Yellow LED tuner 1, 0=on, 1=off |
2287 | * GPIO_1: Green LED tuner 1, 0=on, 1=off |
2288 | @@ -2392,7 +2394,8 @@ struct em28xx_board em28xx_boards[] = { |
2289 | .has_dvb = 1, |
2290 | }, |
2291 | /* |
2292 | - * 2040:0265 Hauppauge WinTV-dualHD (DVB version). |
2293 | + * 2040:0265 Hauppauge WinTV-dualHD (DVB version) Isoc. |
2294 | + * 2040:8265 Hauppauge WinTV-dualHD (DVB version) Bulk. |
2295 | * Empia EM28274, 2x Silicon Labs Si2168, 2x Silicon Labs Si2157 |
2296 | */ |
2297 | [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB] = { |
2298 | @@ -2407,7 +2410,8 @@ struct em28xx_board em28xx_boards[] = { |
2299 | .leds = hauppauge_dualhd_leds, |
2300 | }, |
2301 | /* |
2302 | - * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM). |
2303 | + * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) Isoc. |
2304 | + * 2040:826d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) Bulk. |
2305 | * Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157 |
2306 | */ |
2307 | [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = { |
2308 | @@ -2548,8 +2552,12 @@ struct usb_device_id em28xx_id_table[] = { |
2309 | .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 }, |
2310 | { USB_DEVICE(0x2040, 0x0265), |
2311 | .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB }, |
2312 | + { USB_DEVICE(0x2040, 0x8265), |
2313 | + .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB }, |
2314 | { USB_DEVICE(0x2040, 0x026d), |
2315 | .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 }, |
2316 | + { USB_DEVICE(0x2040, 0x826d), |
2317 | + .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 }, |
2318 | { USB_DEVICE(0x0438, 0xb002), |
2319 | .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 }, |
2320 | { USB_DEVICE(0x2001, 0xf112), |
2321 | @@ -2610,7 +2618,11 @@ struct usb_device_id em28xx_id_table[] = { |
2322 | .driver_info = EM28178_BOARD_PCTV_461E }, |
2323 | { USB_DEVICE(0x2013, 0x025f), |
2324 | .driver_info = EM28178_BOARD_PCTV_292E }, |
2325 | - { USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD */ |
2326 | + { USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD Isoc */ |
2327 | + .driver_info = EM28178_BOARD_PCTV_292E }, |
2328 | + { USB_DEVICE(0x2040, 0x8264), /* Hauppauge OEM Generic WinTV-soloHD Bulk */ |
2329 | + .driver_info = EM28178_BOARD_PCTV_292E }, |
2330 | + { USB_DEVICE(0x2040, 0x8268), /* Hauppauge Retail WinTV-soloHD Bulk */ |
2331 | .driver_info = EM28178_BOARD_PCTV_292E }, |
2332 | { USB_DEVICE(0x0413, 0x6f07), |
2333 | .driver_info = EM2861_BOARD_LEADTEK_VC100 }, |
2334 | diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h |
2335 | index 88084f24f033..094e83b6908d 100644 |
2336 | --- a/drivers/media/usb/em28xx/em28xx.h |
2337 | +++ b/drivers/media/usb/em28xx/em28xx.h |
2338 | @@ -191,7 +191,7 @@ |
2339 | USB 2.0 spec says bulk packet size is always 512 bytes |
2340 | */ |
2341 | #define EM28XX_BULK_PACKET_MULTIPLIER 384 |
2342 | -#define EM28XX_DVB_BULK_PACKET_MULTIPLIER 384 |
2343 | +#define EM28XX_DVB_BULK_PACKET_MULTIPLIER 94 |
2344 | |
2345 | #define EM28XX_INTERLACED_DEFAULT 1 |
2346 | |
2347 | diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c |
2348 | index 3a7c80cd1a17..359fb9804d16 100644 |
2349 | --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c |
2350 | +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c |
2351 | @@ -106,7 +106,7 @@ static void *vb2_vmalloc_get_userptr(struct device *dev, unsigned long vaddr, |
2352 | if (nums[i-1] + 1 != nums[i]) |
2353 | goto fail_map; |
2354 | buf->vaddr = (__force void *) |
2355 | - ioremap_nocache(nums[0] << PAGE_SHIFT, size); |
2356 | + ioremap_nocache(__pfn_to_phys(nums[0]), size + offset); |
2357 | } else { |
2358 | buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1, |
2359 | PAGE_KERNEL); |
2360 | diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c |
2361 | index 7b3b41368931..cf6ce9f600ca 100644 |
2362 | --- a/drivers/message/fusion/mptctl.c |
2363 | +++ b/drivers/message/fusion/mptctl.c |
2364 | @@ -2698,6 +2698,8 @@ mptctl_hp_targetinfo(unsigned long arg) |
2365 | __FILE__, __LINE__, iocnum); |
2366 | return -ENODEV; |
2367 | } |
2368 | + if (karg.hdr.id >= MPT_MAX_FC_DEVICES) |
2369 | + return -EINVAL; |
2370 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", |
2371 | ioc->name)); |
2372 | |
2373 | diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c |
2374 | index e61c99ef741d..c273a3ebb8e8 100644 |
2375 | --- a/drivers/net/ethernet/mellanox/mlx4/main.c |
2376 | +++ b/drivers/net/ethernet/mellanox/mlx4/main.c |
2377 | @@ -3007,6 +3007,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) |
2378 | mlx4_err(dev, "Failed to create file for port %d\n", port); |
2379 | devlink_port_unregister(&info->devlink_port); |
2380 | info->port = -1; |
2381 | + return err; |
2382 | } |
2383 | |
2384 | sprintf(info->dev_mtu_name, "mlx4_port%d_mtu", port); |
2385 | @@ -3028,9 +3029,10 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) |
2386 | &info->port_attr); |
2387 | devlink_port_unregister(&info->devlink_port); |
2388 | info->port = -1; |
2389 | + return err; |
2390 | } |
2391 | |
2392 | - return err; |
2393 | + return 0; |
2394 | } |
2395 | |
2396 | static void mlx4_cleanup_port_info(struct mlx4_port_info *info) |
2397 | diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h |
2398 | index 4f3afcf92a7c..01017dd88802 100644 |
2399 | --- a/drivers/net/hyperv/hyperv_net.h |
2400 | +++ b/drivers/net/hyperv/hyperv_net.h |
2401 | @@ -179,7 +179,7 @@ struct rndis_device { |
2402 | |
2403 | u8 hw_mac_adr[ETH_ALEN]; |
2404 | u8 rss_key[NETVSC_HASH_KEYLEN]; |
2405 | - u16 ind_table[ITAB_NUM]; |
2406 | + u16 rx_table[ITAB_NUM]; |
2407 | }; |
2408 | |
2409 | |
2410 | @@ -192,7 +192,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2411 | const struct netvsc_device_info *info); |
2412 | int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx); |
2413 | void netvsc_device_remove(struct hv_device *device); |
2414 | -int netvsc_send(struct net_device_context *ndc, |
2415 | +int netvsc_send(struct net_device *net, |
2416 | struct hv_netvsc_packet *packet, |
2417 | struct rndis_message *rndis_msg, |
2418 | struct hv_page_buffer *page_buffer, |
2419 | @@ -208,7 +208,6 @@ void netvsc_channel_cb(void *context); |
2420 | int netvsc_poll(struct napi_struct *napi, int budget); |
2421 | |
2422 | void rndis_set_subchannel(struct work_struct *w); |
2423 | -bool rndis_filter_opened(const struct netvsc_device *nvdev); |
2424 | int rndis_filter_open(struct netvsc_device *nvdev); |
2425 | int rndis_filter_close(struct netvsc_device *nvdev); |
2426 | struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
2427 | @@ -659,6 +658,10 @@ struct nvsp_message { |
2428 | #define NETVSC_RECEIVE_BUFFER_ID 0xcafe |
2429 | #define NETVSC_SEND_BUFFER_ID 0 |
2430 | |
2431 | +#define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \ |
2432 | + NETIF_F_TSO | NETIF_F_IPV6_CSUM | \ |
2433 | + NETIF_F_TSO6) |
2434 | + |
2435 | #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */ |
2436 | #define VRSS_CHANNEL_MAX 64 |
2437 | #define VRSS_CHANNEL_DEFAULT 8 |
2438 | @@ -734,7 +737,7 @@ struct net_device_context { |
2439 | |
2440 | u32 tx_checksum_mask; |
2441 | |
2442 | - u32 tx_send_table[VRSS_SEND_TAB_SIZE]; |
2443 | + u32 tx_table[VRSS_SEND_TAB_SIZE]; |
2444 | |
2445 | /* Ethtool settings */ |
2446 | bool udp4_l4_hash; |
2447 | diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c |
2448 | index a6bafcf55776..99be63eacaeb 100644 |
2449 | --- a/drivers/net/hyperv/netvsc.c |
2450 | +++ b/drivers/net/hyperv/netvsc.c |
2451 | @@ -89,6 +89,11 @@ static void free_netvsc_device(struct rcu_head *head) |
2452 | = container_of(head, struct netvsc_device, rcu); |
2453 | int i; |
2454 | |
2455 | + kfree(nvdev->extension); |
2456 | + vfree(nvdev->recv_buf); |
2457 | + vfree(nvdev->send_buf); |
2458 | + kfree(nvdev->send_section_map); |
2459 | + |
2460 | for (i = 0; i < VRSS_CHANNEL_MAX; i++) |
2461 | vfree(nvdev->chan_table[i].mrc.slots); |
2462 | |
2463 | @@ -100,12 +105,11 @@ static void free_netvsc_device_rcu(struct netvsc_device *nvdev) |
2464 | call_rcu(&nvdev->rcu, free_netvsc_device); |
2465 | } |
2466 | |
2467 | -static void netvsc_destroy_buf(struct hv_device *device) |
2468 | +static void netvsc_revoke_recv_buf(struct hv_device *device, |
2469 | + struct netvsc_device *net_device) |
2470 | { |
2471 | - struct nvsp_message *revoke_packet; |
2472 | struct net_device *ndev = hv_get_drvdata(device); |
2473 | - struct net_device_context *ndc = netdev_priv(ndev); |
2474 | - struct netvsc_device *net_device = rtnl_dereference(ndc->nvdev); |
2475 | + struct nvsp_message *revoke_packet; |
2476 | int ret; |
2477 | |
2478 | /* |
2479 | @@ -147,28 +151,14 @@ static void netvsc_destroy_buf(struct hv_device *device) |
2480 | } |
2481 | net_device->recv_section_cnt = 0; |
2482 | } |
2483 | +} |
2484 | |
2485 | - /* Teardown the gpadl on the vsp end */ |
2486 | - if (net_device->recv_buf_gpadl_handle) { |
2487 | - ret = vmbus_teardown_gpadl(device->channel, |
2488 | - net_device->recv_buf_gpadl_handle); |
2489 | - |
2490 | - /* If we failed here, we might as well return and have a leak |
2491 | - * rather than continue and a bugchk |
2492 | - */ |
2493 | - if (ret != 0) { |
2494 | - netdev_err(ndev, |
2495 | - "unable to teardown receive buffer's gpadl\n"); |
2496 | - return; |
2497 | - } |
2498 | - net_device->recv_buf_gpadl_handle = 0; |
2499 | - } |
2500 | - |
2501 | - if (net_device->recv_buf) { |
2502 | - /* Free up the receive buffer */ |
2503 | - vfree(net_device->recv_buf); |
2504 | - net_device->recv_buf = NULL; |
2505 | - } |
2506 | +static void netvsc_revoke_send_buf(struct hv_device *device, |
2507 | + struct netvsc_device *net_device) |
2508 | +{ |
2509 | + struct net_device *ndev = hv_get_drvdata(device); |
2510 | + struct nvsp_message *revoke_packet; |
2511 | + int ret; |
2512 | |
2513 | /* Deal with the send buffer we may have setup. |
2514 | * If we got a send section size, it means we received a |
2515 | @@ -210,7 +200,36 @@ static void netvsc_destroy_buf(struct hv_device *device) |
2516 | } |
2517 | net_device->send_section_cnt = 0; |
2518 | } |
2519 | - /* Teardown the gpadl on the vsp end */ |
2520 | +} |
2521 | + |
2522 | +static void netvsc_teardown_recv_gpadl(struct hv_device *device, |
2523 | + struct netvsc_device *net_device) |
2524 | +{ |
2525 | + struct net_device *ndev = hv_get_drvdata(device); |
2526 | + int ret; |
2527 | + |
2528 | + if (net_device->recv_buf_gpadl_handle) { |
2529 | + ret = vmbus_teardown_gpadl(device->channel, |
2530 | + net_device->recv_buf_gpadl_handle); |
2531 | + |
2532 | + /* If we failed here, we might as well return and have a leak |
2533 | + * rather than continue and a bugchk |
2534 | + */ |
2535 | + if (ret != 0) { |
2536 | + netdev_err(ndev, |
2537 | + "unable to teardown receive buffer's gpadl\n"); |
2538 | + return; |
2539 | + } |
2540 | + net_device->recv_buf_gpadl_handle = 0; |
2541 | + } |
2542 | +} |
2543 | + |
2544 | +static void netvsc_teardown_send_gpadl(struct hv_device *device, |
2545 | + struct netvsc_device *net_device) |
2546 | +{ |
2547 | + struct net_device *ndev = hv_get_drvdata(device); |
2548 | + int ret; |
2549 | + |
2550 | if (net_device->send_buf_gpadl_handle) { |
2551 | ret = vmbus_teardown_gpadl(device->channel, |
2552 | net_device->send_buf_gpadl_handle); |
2553 | @@ -225,12 +244,6 @@ static void netvsc_destroy_buf(struct hv_device *device) |
2554 | } |
2555 | net_device->send_buf_gpadl_handle = 0; |
2556 | } |
2557 | - if (net_device->send_buf) { |
2558 | - /* Free up the send buffer */ |
2559 | - vfree(net_device->send_buf); |
2560 | - net_device->send_buf = NULL; |
2561 | - } |
2562 | - kfree(net_device->send_section_map); |
2563 | } |
2564 | |
2565 | int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx) |
2566 | @@ -425,7 +438,10 @@ static int netvsc_init_buf(struct hv_device *device, |
2567 | goto exit; |
2568 | |
2569 | cleanup: |
2570 | - netvsc_destroy_buf(device); |
2571 | + netvsc_revoke_recv_buf(device, net_device); |
2572 | + netvsc_revoke_send_buf(device, net_device); |
2573 | + netvsc_teardown_recv_gpadl(device, net_device); |
2574 | + netvsc_teardown_send_gpadl(device, net_device); |
2575 | |
2576 | exit: |
2577 | return ret; |
2578 | @@ -544,11 +560,6 @@ static int netvsc_connect_vsp(struct hv_device *device, |
2579 | return ret; |
2580 | } |
2581 | |
2582 | -static void netvsc_disconnect_vsp(struct hv_device *device) |
2583 | -{ |
2584 | - netvsc_destroy_buf(device); |
2585 | -} |
2586 | - |
2587 | /* |
2588 | * netvsc_device_remove - Callback when the root bus device is removed |
2589 | */ |
2590 | @@ -560,12 +571,24 @@ void netvsc_device_remove(struct hv_device *device) |
2591 | = rtnl_dereference(net_device_ctx->nvdev); |
2592 | int i; |
2593 | |
2594 | - cancel_work_sync(&net_device->subchan_work); |
2595 | + /* |
2596 | + * Revoke receive buffer. If host is pre-Win2016 then tear down |
2597 | + * receive buffer GPADL. Do the same for send buffer. |
2598 | + */ |
2599 | + netvsc_revoke_recv_buf(device, net_device); |
2600 | + if (vmbus_proto_version < VERSION_WIN10) |
2601 | + netvsc_teardown_recv_gpadl(device, net_device); |
2602 | |
2603 | - netvsc_disconnect_vsp(device); |
2604 | + netvsc_revoke_send_buf(device, net_device); |
2605 | + if (vmbus_proto_version < VERSION_WIN10) |
2606 | + netvsc_teardown_send_gpadl(device, net_device); |
2607 | |
2608 | RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); |
2609 | |
2610 | + /* And disassociate NAPI context from device */ |
2611 | + for (i = 0; i < net_device->num_chn; i++) |
2612 | + netif_napi_del(&net_device->chan_table[i].napi); |
2613 | + |
2614 | /* |
2615 | * At this point, no one should be accessing net_device |
2616 | * except in here |
2617 | @@ -575,9 +598,14 @@ void netvsc_device_remove(struct hv_device *device) |
2618 | /* Now, we can close the channel safely */ |
2619 | vmbus_close(device->channel); |
2620 | |
2621 | - /* And dissassociate NAPI context from device */ |
2622 | - for (i = 0; i < net_device->num_chn; i++) |
2623 | - netif_napi_del(&net_device->chan_table[i].napi); |
2624 | + /* |
2625 | + * If host is Win2016 or higher then we do the GPADL tear down |
2626 | + * here after VMBus is closed. |
2627 | + */ |
2628 | + if (vmbus_proto_version >= VERSION_WIN10) { |
2629 | + netvsc_teardown_recv_gpadl(device, net_device); |
2630 | + netvsc_teardown_send_gpadl(device, net_device); |
2631 | + } |
2632 | |
2633 | /* Release all resources */ |
2634 | free_netvsc_device_rcu(net_device); |
2635 | @@ -643,13 +671,18 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, |
2636 | queue_sends = |
2637 | atomic_dec_return(&net_device->chan_table[q_idx].queue_sends); |
2638 | |
2639 | - if (net_device->destroy && queue_sends == 0) |
2640 | - wake_up(&net_device->wait_drain); |
2641 | + if (unlikely(net_device->destroy)) { |
2642 | + if (queue_sends == 0) |
2643 | + wake_up(&net_device->wait_drain); |
2644 | + } else { |
2645 | + struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); |
2646 | |
2647 | - if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && |
2648 | - (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || |
2649 | - queue_sends < 1)) |
2650 | - netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx)); |
2651 | + if (netif_tx_queue_stopped(txq) && |
2652 | + (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || |
2653 | + queue_sends < 1)) { |
2654 | + netif_tx_wake_queue(txq); |
2655 | + } |
2656 | + } |
2657 | } |
2658 | |
2659 | static void netvsc_send_completion(struct netvsc_device *net_device, |
2660 | @@ -697,13 +730,13 @@ static u32 netvsc_get_next_send_section(struct netvsc_device *net_device) |
2661 | return NETVSC_INVALID_INDEX; |
2662 | } |
2663 | |
2664 | -static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, |
2665 | - unsigned int section_index, |
2666 | - u32 pend_size, |
2667 | - struct hv_netvsc_packet *packet, |
2668 | - struct rndis_message *rndis_msg, |
2669 | - struct hv_page_buffer *pb, |
2670 | - struct sk_buff *skb) |
2671 | +static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, |
2672 | + unsigned int section_index, |
2673 | + u32 pend_size, |
2674 | + struct hv_netvsc_packet *packet, |
2675 | + struct rndis_message *rndis_msg, |
2676 | + struct hv_page_buffer *pb, |
2677 | + bool xmit_more) |
2678 | { |
2679 | char *start = net_device->send_buf; |
2680 | char *dest = start + (section_index * net_device->send_section_size) |
2681 | @@ -716,7 +749,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, |
2682 | packet->page_buf_cnt; |
2683 | |
2684 | /* Add padding */ |
2685 | - if (skb->xmit_more && remain && !packet->cp_partial) { |
2686 | + remain = packet->total_data_buflen & (net_device->pkt_align - 1); |
2687 | + if (xmit_more && remain) { |
2688 | padding = net_device->pkt_align - remain; |
2689 | rndis_msg->msg_len += padding; |
2690 | packet->total_data_buflen += padding; |
2691 | @@ -736,8 +770,6 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, |
2692 | memset(dest, 0, padding); |
2693 | msg_size += padding; |
2694 | } |
2695 | - |
2696 | - return msg_size; |
2697 | } |
2698 | |
2699 | static inline int netvsc_send_pkt( |
2700 | @@ -825,12 +857,13 @@ static inline void move_pkt_msd(struct hv_netvsc_packet **msd_send, |
2701 | } |
2702 | |
2703 | /* RCU already held by caller */ |
2704 | -int netvsc_send(struct net_device_context *ndev_ctx, |
2705 | +int netvsc_send(struct net_device *ndev, |
2706 | struct hv_netvsc_packet *packet, |
2707 | struct rndis_message *rndis_msg, |
2708 | struct hv_page_buffer *pb, |
2709 | struct sk_buff *skb) |
2710 | { |
2711 | + struct net_device_context *ndev_ctx = netdev_priv(ndev); |
2712 | struct netvsc_device *net_device |
2713 | = rcu_dereference_bh(ndev_ctx->nvdev); |
2714 | struct hv_device *device = ndev_ctx->device_ctx; |
2715 | @@ -841,20 +874,12 @@ int netvsc_send(struct net_device_context *ndev_ctx, |
2716 | struct multi_send_data *msdp; |
2717 | struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL; |
2718 | struct sk_buff *msd_skb = NULL; |
2719 | - bool try_batch; |
2720 | - bool xmit_more = (skb != NULL) ? skb->xmit_more : false; |
2721 | + bool try_batch, xmit_more; |
2722 | |
2723 | /* If device is rescinded, return error and packet will get dropped. */ |
2724 | if (unlikely(!net_device || net_device->destroy)) |
2725 | return -ENODEV; |
2726 | |
2727 | - /* We may race with netvsc_connect_vsp()/netvsc_init_buf() and get |
2728 | - * here before the negotiation with the host is finished and |
2729 | - * send_section_map may not be allocated yet. |
2730 | - */ |
2731 | - if (unlikely(!net_device->send_section_map)) |
2732 | - return -EAGAIN; |
2733 | - |
2734 | nvchan = &net_device->chan_table[packet->q_idx]; |
2735 | packet->send_buf_index = NETVSC_INVALID_INDEX; |
2736 | packet->cp_partial = false; |
2737 | @@ -862,10 +887,8 @@ int netvsc_send(struct net_device_context *ndev_ctx, |
2738 | /* Send control message directly without accessing msd (Multi-Send |
2739 | * Data) field which may be changed during data packet processing. |
2740 | */ |
2741 | - if (!skb) { |
2742 | - cur_send = packet; |
2743 | - goto send_now; |
2744 | - } |
2745 | + if (!skb) |
2746 | + return netvsc_send_pkt(device, packet, net_device, pb, skb); |
2747 | |
2748 | /* batch packets in send buffer if possible */ |
2749 | msdp = &nvchan->msd; |
2750 | @@ -893,10 +916,17 @@ int netvsc_send(struct net_device_context *ndev_ctx, |
2751 | } |
2752 | } |
2753 | |
2754 | + /* Keep aggregating only if stack says more data is coming |
2755 | + * and not doing mixed modes send and not flow blocked |
2756 | + */ |
2757 | + xmit_more = skb->xmit_more && |
2758 | + !packet->cp_partial && |
2759 | + !netif_xmit_stopped(netdev_get_tx_queue(ndev, packet->q_idx)); |
2760 | + |
2761 | if (section_index != NETVSC_INVALID_INDEX) { |
2762 | netvsc_copy_to_send_buf(net_device, |
2763 | section_index, msd_len, |
2764 | - packet, rndis_msg, pb, skb); |
2765 | + packet, rndis_msg, pb, xmit_more); |
2766 | |
2767 | packet->send_buf_index = section_index; |
2768 | |
2769 | @@ -916,7 +946,7 @@ int netvsc_send(struct net_device_context *ndev_ctx, |
2770 | if (msdp->skb) |
2771 | dev_consume_skb_any(msdp->skb); |
2772 | |
2773 | - if (xmit_more && !packet->cp_partial) { |
2774 | + if (xmit_more) { |
2775 | msdp->skb = skb; |
2776 | msdp->pkt = packet; |
2777 | msdp->count++; |
2778 | @@ -942,7 +972,6 @@ int netvsc_send(struct net_device_context *ndev_ctx, |
2779 | } |
2780 | } |
2781 | |
2782 | -send_now: |
2783 | if (cur_send) |
2784 | ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb); |
2785 | |
2786 | @@ -1107,7 +1136,7 @@ static void netvsc_send_table(struct hv_device *hdev, |
2787 | nvmsg->msg.v5_msg.send_table.offset); |
2788 | |
2789 | for (i = 0; i < count; i++) |
2790 | - net_device_ctx->tx_send_table[i] = tab[i]; |
2791 | + net_device_ctx->tx_table[i] = tab[i]; |
2792 | } |
2793 | |
2794 | static void netvsc_send_vf(struct net_device_context *net_device_ctx, |
2795 | @@ -1206,9 +1235,10 @@ int netvsc_poll(struct napi_struct *napi, int budget) |
2796 | if (send_recv_completions(ndev, net_device, nvchan) == 0 && |
2797 | work_done < budget && |
2798 | napi_complete_done(napi, work_done) && |
2799 | - hv_end_read(&channel->inbound)) { |
2800 | + hv_end_read(&channel->inbound) && |
2801 | + napi_schedule_prep(napi)) { |
2802 | hv_begin_read(&channel->inbound); |
2803 | - napi_reschedule(napi); |
2804 | + __napi_schedule(napi); |
2805 | } |
2806 | |
2807 | /* Driver may overshoot since multiple packets per descriptor */ |
2808 | @@ -1252,6 +1282,9 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2809 | if (!net_device) |
2810 | return ERR_PTR(-ENOMEM); |
2811 | |
2812 | + for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) |
2813 | + net_device_ctx->tx_table[i] = 0; |
2814 | + |
2815 | net_device->ring_size = ring_size; |
2816 | |
2817 | /* Because the device uses NAPI, all the interrupt batching and |
2818 | @@ -1286,7 +1319,6 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2819 | net_device->chan_table); |
2820 | |
2821 | if (ret != 0) { |
2822 | - netif_napi_del(&net_device->chan_table[0].napi); |
2823 | netdev_err(ndev, "unable to open channel: %d\n", ret); |
2824 | goto cleanup; |
2825 | } |
2826 | @@ -1296,11 +1328,6 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2827 | |
2828 | napi_enable(&net_device->chan_table[0].napi); |
2829 | |
2830 | - /* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is |
2831 | - * populated. |
2832 | - */ |
2833 | - rcu_assign_pointer(net_device_ctx->nvdev, net_device); |
2834 | - |
2835 | /* Connect with the NetVsp */ |
2836 | ret = netvsc_connect_vsp(device, net_device, device_info); |
2837 | if (ret != 0) { |
2838 | @@ -1309,6 +1336,11 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2839 | goto close; |
2840 | } |
2841 | |
2842 | + /* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is |
2843 | + * populated. |
2844 | + */ |
2845 | + rcu_assign_pointer(net_device_ctx->nvdev, net_device); |
2846 | + |
2847 | return net_device; |
2848 | |
2849 | close: |
2850 | @@ -1319,6 +1351,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, |
2851 | vmbus_close(device->channel); |
2852 | |
2853 | cleanup: |
2854 | + netif_napi_del(&net_device->chan_table[0].napi); |
2855 | free_netvsc_device(&net_device->rcu); |
2856 | |
2857 | return ERR_PTR(ret); |
2858 | diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c |
2859 | index 444e560d928b..11b46c8d2d67 100644 |
2860 | --- a/drivers/net/hyperv/netvsc_drv.c |
2861 | +++ b/drivers/net/hyperv/netvsc_drv.c |
2862 | @@ -45,7 +45,10 @@ |
2863 | |
2864 | #include "hyperv_net.h" |
2865 | |
2866 | -#define RING_SIZE_MIN 64 |
2867 | +#define RING_SIZE_MIN 64 |
2868 | +#define RETRY_US_LO 5000 |
2869 | +#define RETRY_US_HI 10000 |
2870 | +#define RETRY_MAX 2000 /* >10 sec */ |
2871 | |
2872 | #define LINKCHANGE_INT (2 * HZ) |
2873 | #define VF_TAKEOVER_INT (HZ / 10) |
2874 | @@ -88,10 +91,7 @@ static int netvsc_open(struct net_device *net) |
2875 | return ret; |
2876 | } |
2877 | |
2878 | - netif_tx_wake_all_queues(net); |
2879 | - |
2880 | rdev = nvdev->extension; |
2881 | - |
2882 | if (!rdev->link_state) |
2883 | netif_carrier_on(net); |
2884 | |
2885 | @@ -109,36 +109,25 @@ static int netvsc_open(struct net_device *net) |
2886 | return 0; |
2887 | } |
2888 | |
2889 | -static int netvsc_close(struct net_device *net) |
2890 | +static int netvsc_wait_until_empty(struct netvsc_device *nvdev) |
2891 | { |
2892 | - struct net_device_context *net_device_ctx = netdev_priv(net); |
2893 | - struct net_device *vf_netdev |
2894 | - = rtnl_dereference(net_device_ctx->vf_netdev); |
2895 | - struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); |
2896 | - int ret = 0; |
2897 | - u32 aread, i, msec = 10, retry = 0, retry_max = 20; |
2898 | - struct vmbus_channel *chn; |
2899 | - |
2900 | - netif_tx_disable(net); |
2901 | - |
2902 | - /* No need to close rndis filter if it is removed already */ |
2903 | - if (!nvdev) |
2904 | - goto out; |
2905 | - |
2906 | - ret = rndis_filter_close(nvdev); |
2907 | - if (ret != 0) { |
2908 | - netdev_err(net, "unable to close device (ret %d).\n", ret); |
2909 | - return ret; |
2910 | - } |
2911 | + unsigned int retry = 0; |
2912 | + int i; |
2913 | |
2914 | /* Ensure pending bytes in ring are read */ |
2915 | - while (true) { |
2916 | - aread = 0; |
2917 | + for (;;) { |
2918 | + u32 aread = 0; |
2919 | + |
2920 | for (i = 0; i < nvdev->num_chn; i++) { |
2921 | - chn = nvdev->chan_table[i].channel; |
2922 | + struct vmbus_channel *chn |
2923 | + = nvdev->chan_table[i].channel; |
2924 | + |
2925 | if (!chn) |
2926 | continue; |
2927 | |
2928 | + /* make sure receive not running now */ |
2929 | + napi_synchronize(&nvdev->chan_table[i].napi); |
2930 | + |
2931 | aread = hv_get_bytes_to_read(&chn->inbound); |
2932 | if (aread) |
2933 | break; |
2934 | @@ -148,22 +137,40 @@ static int netvsc_close(struct net_device *net) |
2935 | break; |
2936 | } |
2937 | |
2938 | - retry++; |
2939 | - if (retry > retry_max || aread == 0) |
2940 | - break; |
2941 | + if (aread == 0) |
2942 | + return 0; |
2943 | |
2944 | - msleep(msec); |
2945 | + if (++retry > RETRY_MAX) |
2946 | + return -ETIMEDOUT; |
2947 | |
2948 | - if (msec < 1000) |
2949 | - msec *= 2; |
2950 | + usleep_range(RETRY_US_LO, RETRY_US_HI); |
2951 | } |
2952 | +} |
2953 | |
2954 | - if (aread) { |
2955 | - netdev_err(net, "Ring buffer not empty after closing rndis\n"); |
2956 | - ret = -ETIMEDOUT; |
2957 | +static int netvsc_close(struct net_device *net) |
2958 | +{ |
2959 | + struct net_device_context *net_device_ctx = netdev_priv(net); |
2960 | + struct net_device *vf_netdev |
2961 | + = rtnl_dereference(net_device_ctx->vf_netdev); |
2962 | + struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); |
2963 | + int ret; |
2964 | + |
2965 | + netif_tx_disable(net); |
2966 | + |
2967 | + /* No need to close rndis filter if it is removed already */ |
2968 | + if (!nvdev) |
2969 | + return 0; |
2970 | + |
2971 | + ret = rndis_filter_close(nvdev); |
2972 | + if (ret != 0) { |
2973 | + netdev_err(net, "unable to close device (ret %d).\n", ret); |
2974 | + return ret; |
2975 | } |
2976 | |
2977 | -out: |
2978 | + ret = netvsc_wait_until_empty(nvdev); |
2979 | + if (ret) |
2980 | + netdev_err(net, "Ring buffer not empty after closing rndis\n"); |
2981 | + |
2982 | if (vf_netdev) |
2983 | dev_close(vf_netdev); |
2984 | |
2985 | @@ -234,8 +241,8 @@ static inline int netvsc_get_tx_queue(struct net_device *ndev, |
2986 | struct sock *sk = skb->sk; |
2987 | int q_idx; |
2988 | |
2989 | - q_idx = ndc->tx_send_table[netvsc_get_hash(skb, ndc) & |
2990 | - (VRSS_SEND_TAB_SIZE - 1)]; |
2991 | + q_idx = ndc->tx_table[netvsc_get_hash(skb, ndc) & |
2992 | + (VRSS_SEND_TAB_SIZE - 1)]; |
2993 | |
2994 | /* If queue index changed record the new value */ |
2995 | if (q_idx != old_idx && |
2996 | @@ -284,8 +291,19 @@ static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb, |
2997 | rcu_read_lock(); |
2998 | vf_netdev = rcu_dereference(ndc->vf_netdev); |
2999 | if (vf_netdev) { |
3000 | - txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : 0; |
3001 | - qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb->queue_mapping; |
3002 | + const struct net_device_ops *vf_ops = vf_netdev->netdev_ops; |
3003 | + |
3004 | + if (vf_ops->ndo_select_queue) |
3005 | + txq = vf_ops->ndo_select_queue(vf_netdev, skb, |
3006 | + accel_priv, fallback); |
3007 | + else |
3008 | + txq = fallback(vf_netdev, skb); |
3009 | + |
3010 | + /* Record the queue selected by VF so that it can be |
3011 | + * used for common case where VF has more queues than |
3012 | + * the synthetic device. |
3013 | + */ |
3014 | + qdisc_skb_cb(skb)->slave_dev_queue_mapping = txq; |
3015 | } else { |
3016 | txq = netvsc_pick_tx(ndev, skb); |
3017 | } |
3018 | @@ -614,7 +632,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) |
3019 | /* timestamp packet in software */ |
3020 | skb_tx_timestamp(skb); |
3021 | |
3022 | - ret = netvsc_send(net_device_ctx, packet, rndis_msg, pb, skb); |
3023 | + ret = netvsc_send(net, packet, rndis_msg, pb, skb); |
3024 | if (likely(ret == 0)) |
3025 | return NETDEV_TX_OK; |
3026 | |
3027 | @@ -810,16 +828,81 @@ static void netvsc_get_channels(struct net_device *net, |
3028 | } |
3029 | } |
3030 | |
3031 | +static int netvsc_detach(struct net_device *ndev, |
3032 | + struct netvsc_device *nvdev) |
3033 | +{ |
3034 | + struct net_device_context *ndev_ctx = netdev_priv(ndev); |
3035 | + struct hv_device *hdev = ndev_ctx->device_ctx; |
3036 | + int ret; |
3037 | + |
3038 | + /* Don't try continuing to try and setup sub channels */ |
3039 | + if (cancel_work_sync(&nvdev->subchan_work)) |
3040 | + nvdev->num_chn = 1; |
3041 | + |
3042 | + /* If device was up (receiving) then shutdown */ |
3043 | + if (netif_running(ndev)) { |
3044 | + netif_tx_disable(ndev); |
3045 | + |
3046 | + ret = rndis_filter_close(nvdev); |
3047 | + if (ret) { |
3048 | + netdev_err(ndev, |
3049 | + "unable to close device (ret %d).\n", ret); |
3050 | + return ret; |
3051 | + } |
3052 | + |
3053 | + ret = netvsc_wait_until_empty(nvdev); |
3054 | + if (ret) { |
3055 | + netdev_err(ndev, |
3056 | + "Ring buffer not empty after closing rndis\n"); |
3057 | + return ret; |
3058 | + } |
3059 | + } |
3060 | + |
3061 | + netif_device_detach(ndev); |
3062 | + |
3063 | + rndis_filter_device_remove(hdev, nvdev); |
3064 | + |
3065 | + return 0; |
3066 | +} |
3067 | + |
3068 | +static int netvsc_attach(struct net_device *ndev, |
3069 | + struct netvsc_device_info *dev_info) |
3070 | +{ |
3071 | + struct net_device_context *ndev_ctx = netdev_priv(ndev); |
3072 | + struct hv_device *hdev = ndev_ctx->device_ctx; |
3073 | + struct netvsc_device *nvdev; |
3074 | + struct rndis_device *rdev; |
3075 | + int ret; |
3076 | + |
3077 | + nvdev = rndis_filter_device_add(hdev, dev_info); |
3078 | + if (IS_ERR(nvdev)) |
3079 | + return PTR_ERR(nvdev); |
3080 | + |
3081 | + /* Note: enable and attach happen when sub-channels setup */ |
3082 | + |
3083 | + netif_carrier_off(ndev); |
3084 | + |
3085 | + if (netif_running(ndev)) { |
3086 | + ret = rndis_filter_open(nvdev); |
3087 | + if (ret) |
3088 | + return ret; |
3089 | + |
3090 | + rdev = nvdev->extension; |
3091 | + if (!rdev->link_state) |
3092 | + netif_carrier_on(ndev); |
3093 | + } |
3094 | + |
3095 | + return 0; |
3096 | +} |
3097 | + |
3098 | static int netvsc_set_channels(struct net_device *net, |
3099 | struct ethtool_channels *channels) |
3100 | { |
3101 | struct net_device_context *net_device_ctx = netdev_priv(net); |
3102 | - struct hv_device *dev = net_device_ctx->device_ctx; |
3103 | struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); |
3104 | unsigned int orig, count = channels->combined_count; |
3105 | struct netvsc_device_info device_info; |
3106 | - bool was_opened; |
3107 | - int ret = 0; |
3108 | + int ret; |
3109 | |
3110 | /* We do not support separate count for rx, tx, or other */ |
3111 | if (count == 0 || |
3112 | @@ -836,9 +919,6 @@ static int netvsc_set_channels(struct net_device *net, |
3113 | return -EINVAL; |
3114 | |
3115 | orig = nvdev->num_chn; |
3116 | - was_opened = rndis_filter_opened(nvdev); |
3117 | - if (was_opened) |
3118 | - rndis_filter_close(nvdev); |
3119 | |
3120 | memset(&device_info, 0, sizeof(device_info)); |
3121 | device_info.num_chn = count; |
3122 | @@ -848,28 +928,17 @@ static int netvsc_set_channels(struct net_device *net, |
3123 | device_info.recv_sections = nvdev->recv_section_cnt; |
3124 | device_info.recv_section_size = nvdev->recv_section_size; |
3125 | |
3126 | - rndis_filter_device_remove(dev, nvdev); |
3127 | + ret = netvsc_detach(net, nvdev); |
3128 | + if (ret) |
3129 | + return ret; |
3130 | |
3131 | - nvdev = rndis_filter_device_add(dev, &device_info); |
3132 | - if (IS_ERR(nvdev)) { |
3133 | - ret = PTR_ERR(nvdev); |
3134 | + ret = netvsc_attach(net, &device_info); |
3135 | + if (ret) { |
3136 | device_info.num_chn = orig; |
3137 | - nvdev = rndis_filter_device_add(dev, &device_info); |
3138 | - |
3139 | - if (IS_ERR(nvdev)) { |
3140 | - netdev_err(net, "restoring channel setting failed: %ld\n", |
3141 | - PTR_ERR(nvdev)); |
3142 | - return ret; |
3143 | - } |
3144 | + if (netvsc_attach(net, &device_info)) |
3145 | + netdev_err(net, "restoring channel setting failed\n"); |
3146 | } |
3147 | |
3148 | - if (was_opened) |
3149 | - rndis_filter_open(nvdev); |
3150 | - |
3151 | - /* We may have missed link change notifications */ |
3152 | - net_device_ctx->last_reconfig = 0; |
3153 | - schedule_delayed_work(&net_device_ctx->dwork, 0); |
3154 | - |
3155 | return ret; |
3156 | } |
3157 | |
3158 | @@ -936,10 +1005,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) |
3159 | struct net_device_context *ndevctx = netdev_priv(ndev); |
3160 | struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); |
3161 | struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); |
3162 | - struct hv_device *hdev = ndevctx->device_ctx; |
3163 | int orig_mtu = ndev->mtu; |
3164 | struct netvsc_device_info device_info; |
3165 | - bool was_opened; |
3166 | int ret = 0; |
3167 | |
3168 | if (!nvdev || nvdev->destroy) |
3169 | @@ -952,11 +1019,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) |
3170 | return ret; |
3171 | } |
3172 | |
3173 | - netif_device_detach(ndev); |
3174 | - was_opened = rndis_filter_opened(nvdev); |
3175 | - if (was_opened) |
3176 | - rndis_filter_close(nvdev); |
3177 | - |
3178 | memset(&device_info, 0, sizeof(device_info)); |
3179 | device_info.ring_size = ring_size; |
3180 | device_info.num_chn = nvdev->num_chn; |
3181 | @@ -965,35 +1027,27 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) |
3182 | device_info.recv_sections = nvdev->recv_section_cnt; |
3183 | device_info.recv_section_size = nvdev->recv_section_size; |
3184 | |
3185 | - rndis_filter_device_remove(hdev, nvdev); |
3186 | + ret = netvsc_detach(ndev, nvdev); |
3187 | + if (ret) |
3188 | + goto rollback_vf; |
3189 | |
3190 | ndev->mtu = mtu; |
3191 | |
3192 | - nvdev = rndis_filter_device_add(hdev, &device_info); |
3193 | - if (IS_ERR(nvdev)) { |
3194 | - ret = PTR_ERR(nvdev); |
3195 | - |
3196 | - /* Attempt rollback to original MTU */ |
3197 | - ndev->mtu = orig_mtu; |
3198 | - nvdev = rndis_filter_device_add(hdev, &device_info); |
3199 | - |
3200 | - if (vf_netdev) |
3201 | - dev_set_mtu(vf_netdev, orig_mtu); |
3202 | - |
3203 | - if (IS_ERR(nvdev)) { |
3204 | - netdev_err(ndev, "restoring mtu failed: %ld\n", |
3205 | - PTR_ERR(nvdev)); |
3206 | - return ret; |
3207 | - } |
3208 | - } |
3209 | + ret = netvsc_attach(ndev, &device_info); |
3210 | + if (ret) |
3211 | + goto rollback; |
3212 | |
3213 | - if (was_opened) |
3214 | - rndis_filter_open(nvdev); |
3215 | + return 0; |
3216 | |
3217 | - netif_device_attach(ndev); |
3218 | +rollback: |
3219 | + /* Attempt rollback to original MTU */ |
3220 | + ndev->mtu = orig_mtu; |
3221 | |
3222 | - /* We may have missed link change notifications */ |
3223 | - schedule_delayed_work(&ndevctx->dwork, 0); |
3224 | + if (netvsc_attach(ndev, &device_info)) |
3225 | + netdev_err(ndev, "restoring mtu failed\n"); |
3226 | +rollback_vf: |
3227 | + if (vf_netdev) |
3228 | + dev_set_mtu(vf_netdev, orig_mtu); |
3229 | |
3230 | return ret; |
3231 | } |
3232 | @@ -1378,7 +1432,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, |
3233 | rndis_dev = ndev->extension; |
3234 | if (indir) { |
3235 | for (i = 0; i < ITAB_NUM; i++) |
3236 | - indir[i] = rndis_dev->ind_table[i]; |
3237 | + indir[i] = rndis_dev->rx_table[i]; |
3238 | } |
3239 | |
3240 | if (key) |
3241 | @@ -1408,7 +1462,7 @@ static int netvsc_set_rxfh(struct net_device *dev, const u32 *indir, |
3242 | return -EINVAL; |
3243 | |
3244 | for (i = 0; i < ITAB_NUM; i++) |
3245 | - rndis_dev->ind_table[i] = indir[i]; |
3246 | + rndis_dev->rx_table[i] = indir[i]; |
3247 | } |
3248 | |
3249 | if (!key) { |
3250 | @@ -1459,11 +1513,9 @@ static int netvsc_set_ringparam(struct net_device *ndev, |
3251 | { |
3252 | struct net_device_context *ndevctx = netdev_priv(ndev); |
3253 | struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); |
3254 | - struct hv_device *hdev = ndevctx->device_ctx; |
3255 | struct netvsc_device_info device_info; |
3256 | struct ethtool_ringparam orig; |
3257 | u32 new_tx, new_rx; |
3258 | - bool was_opened; |
3259 | int ret = 0; |
3260 | |
3261 | if (!nvdev || nvdev->destroy) |
3262 | @@ -1489,34 +1541,18 @@ static int netvsc_set_ringparam(struct net_device *ndev, |
3263 | device_info.recv_sections = new_rx; |
3264 | device_info.recv_section_size = nvdev->recv_section_size; |
3265 | |
3266 | - netif_device_detach(ndev); |
3267 | - was_opened = rndis_filter_opened(nvdev); |
3268 | - if (was_opened) |
3269 | - rndis_filter_close(nvdev); |
3270 | - |
3271 | - rndis_filter_device_remove(hdev, nvdev); |
3272 | - |
3273 | - nvdev = rndis_filter_device_add(hdev, &device_info); |
3274 | - if (IS_ERR(nvdev)) { |
3275 | - ret = PTR_ERR(nvdev); |
3276 | + ret = netvsc_detach(ndev, nvdev); |
3277 | + if (ret) |
3278 | + return ret; |
3279 | |
3280 | + ret = netvsc_attach(ndev, &device_info); |
3281 | + if (ret) { |
3282 | device_info.send_sections = orig.tx_pending; |
3283 | device_info.recv_sections = orig.rx_pending; |
3284 | - nvdev = rndis_filter_device_add(hdev, &device_info); |
3285 | - if (IS_ERR(nvdev)) { |
3286 | - netdev_err(ndev, "restoring ringparam failed: %ld\n", |
3287 | - PTR_ERR(nvdev)); |
3288 | - return ret; |
3289 | - } |
3290 | - } |
3291 | - |
3292 | - if (was_opened) |
3293 | - rndis_filter_open(nvdev); |
3294 | - netif_device_attach(ndev); |
3295 | |
3296 | - /* We may have missed link change notifications */ |
3297 | - ndevctx->last_reconfig = 0; |
3298 | - schedule_delayed_work(&ndevctx->dwork, 0); |
3299 | + if (netvsc_attach(ndev, &device_info)) |
3300 | + netdev_err(ndev, "restoring ringparam failed"); |
3301 | + } |
3302 | |
3303 | return ret; |
3304 | } |
3305 | @@ -1932,6 +1968,12 @@ static int netvsc_probe(struct hv_device *dev, |
3306 | /* We always need headroom for rndis header */ |
3307 | net->needed_headroom = RNDIS_AND_PPI_SIZE; |
3308 | |
3309 | + /* Initialize the number of queues to be 1, we may change it if more |
3310 | + * channels are offered later. |
3311 | + */ |
3312 | + netif_set_real_num_tx_queues(net, 1); |
3313 | + netif_set_real_num_rx_queues(net, 1); |
3314 | + |
3315 | /* Notify the netvsc driver of the new device */ |
3316 | memset(&device_info, 0, sizeof(device_info)); |
3317 | device_info.ring_size = ring_size; |
3318 | @@ -1950,7 +1992,7 @@ static int netvsc_probe(struct hv_device *dev, |
3319 | |
3320 | memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); |
3321 | |
3322 | - /* hw_features computed in rndis_filter_device_add */ |
3323 | + /* hw_features computed in rndis_netdev_set_hwcaps() */ |
3324 | net->features = net->hw_features | |
3325 | NETIF_F_HIGHDMA | NETIF_F_SG | |
3326 | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; |
3327 | @@ -1987,8 +2029,8 @@ static int netvsc_probe(struct hv_device *dev, |
3328 | static int netvsc_remove(struct hv_device *dev) |
3329 | { |
3330 | struct net_device_context *ndev_ctx; |
3331 | - struct net_device *vf_netdev; |
3332 | - struct net_device *net; |
3333 | + struct net_device *vf_netdev, *net; |
3334 | + struct netvsc_device *nvdev; |
3335 | |
3336 | net = hv_get_drvdata(dev); |
3337 | if (net == NULL) { |
3338 | @@ -1998,10 +2040,14 @@ static int netvsc_remove(struct hv_device *dev) |
3339 | |
3340 | ndev_ctx = netdev_priv(net); |
3341 | |
3342 | - netif_device_detach(net); |
3343 | - |
3344 | cancel_delayed_work_sync(&ndev_ctx->dwork); |
3345 | |
3346 | + rcu_read_lock(); |
3347 | + nvdev = rcu_dereference(ndev_ctx->nvdev); |
3348 | + |
3349 | + if (nvdev) |
3350 | + cancel_work_sync(&nvdev->subchan_work); |
3351 | + |
3352 | /* |
3353 | * Call to the vsc driver to let it know that the device is being |
3354 | * removed. Also blocks mtu and channel changes. |
3355 | @@ -2011,11 +2057,13 @@ static int netvsc_remove(struct hv_device *dev) |
3356 | if (vf_netdev) |
3357 | netvsc_unregister_vf(vf_netdev); |
3358 | |
3359 | + if (nvdev) |
3360 | + rndis_filter_device_remove(dev, nvdev); |
3361 | + |
3362 | unregister_netdevice(net); |
3363 | |
3364 | - rndis_filter_device_remove(dev, |
3365 | - rtnl_dereference(ndev_ctx->nvdev)); |
3366 | rtnl_unlock(); |
3367 | + rcu_read_unlock(); |
3368 | |
3369 | hv_set_drvdata(dev, NULL); |
3370 | |
3371 | diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c |
3372 | index 065b204d8e17..6dde92c1c113 100644 |
3373 | --- a/drivers/net/hyperv/rndis_filter.c |
3374 | +++ b/drivers/net/hyperv/rndis_filter.c |
3375 | @@ -217,7 +217,6 @@ static int rndis_filter_send_request(struct rndis_device *dev, |
3376 | struct hv_netvsc_packet *packet; |
3377 | struct hv_page_buffer page_buf[2]; |
3378 | struct hv_page_buffer *pb = page_buf; |
3379 | - struct net_device_context *net_device_ctx = netdev_priv(dev->ndev); |
3380 | int ret; |
3381 | |
3382 | /* Setup the packet to send it */ |
3383 | @@ -245,7 +244,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, |
3384 | } |
3385 | |
3386 | rcu_read_lock_bh(); |
3387 | - ret = netvsc_send(net_device_ctx, packet, NULL, pb, NULL); |
3388 | + ret = netvsc_send(dev->ndev, packet, NULL, pb, NULL); |
3389 | rcu_read_unlock_bh(); |
3390 | |
3391 | return ret; |
3392 | @@ -267,13 +266,23 @@ static void rndis_set_link_state(struct rndis_device *rdev, |
3393 | } |
3394 | } |
3395 | |
3396 | -static void rndis_filter_receive_response(struct rndis_device *dev, |
3397 | - struct rndis_message *resp) |
3398 | +static void rndis_filter_receive_response(struct net_device *ndev, |
3399 | + struct netvsc_device *nvdev, |
3400 | + const struct rndis_message *resp) |
3401 | { |
3402 | + struct rndis_device *dev = nvdev->extension; |
3403 | struct rndis_request *request = NULL; |
3404 | bool found = false; |
3405 | unsigned long flags; |
3406 | - struct net_device *ndev = dev->ndev; |
3407 | + |
3408 | + /* This should never happen, it means control message |
3409 | + * response received after device removed. |
3410 | + */ |
3411 | + if (dev->state == RNDIS_DEV_UNINITIALIZED) { |
3412 | + netdev_err(ndev, |
3413 | + "got rndis message uninitialized\n"); |
3414 | + return; |
3415 | + } |
3416 | |
3417 | spin_lock_irqsave(&dev->request_lock, flags); |
3418 | list_for_each_entry(request, &dev->req_list, list_ent) { |
3419 | @@ -354,7 +363,7 @@ static inline void *rndis_get_ppi(struct rndis_packet *rpkt, u32 type) |
3420 | } |
3421 | |
3422 | static int rndis_filter_receive_data(struct net_device *ndev, |
3423 | - struct rndis_device *dev, |
3424 | + struct netvsc_device *nvdev, |
3425 | struct rndis_message *msg, |
3426 | struct vmbus_channel *channel, |
3427 | void *data, u32 data_buflen) |
3428 | @@ -374,7 +383,7 @@ static int rndis_filter_receive_data(struct net_device *ndev, |
3429 | * should be the data packet size plus the trailer padding size |
3430 | */ |
3431 | if (unlikely(data_buflen < rndis_pkt->data_len)) { |
3432 | - netdev_err(dev->ndev, "rndis message buffer " |
3433 | + netdev_err(ndev, "rndis message buffer " |
3434 | "overflow detected (got %u, min %u)" |
3435 | "...dropping this message!\n", |
3436 | data_buflen, rndis_pkt->data_len); |
3437 | @@ -402,34 +411,20 @@ int rndis_filter_receive(struct net_device *ndev, |
3438 | void *data, u32 buflen) |
3439 | { |
3440 | struct net_device_context *net_device_ctx = netdev_priv(ndev); |
3441 | - struct rndis_device *rndis_dev = net_dev->extension; |
3442 | struct rndis_message *rndis_msg = data; |
3443 | |
3444 | - /* Make sure the rndis device state is initialized */ |
3445 | - if (unlikely(!rndis_dev)) { |
3446 | - netif_err(net_device_ctx, rx_err, ndev, |
3447 | - "got rndis message but no rndis device!\n"); |
3448 | - return NVSP_STAT_FAIL; |
3449 | - } |
3450 | - |
3451 | - if (unlikely(rndis_dev->state == RNDIS_DEV_UNINITIALIZED)) { |
3452 | - netif_err(net_device_ctx, rx_err, ndev, |
3453 | - "got rndis message uninitialized\n"); |
3454 | - return NVSP_STAT_FAIL; |
3455 | - } |
3456 | - |
3457 | if (netif_msg_rx_status(net_device_ctx)) |
3458 | dump_rndis_message(dev, rndis_msg); |
3459 | |
3460 | switch (rndis_msg->ndis_msg_type) { |
3461 | case RNDIS_MSG_PACKET: |
3462 | - return rndis_filter_receive_data(ndev, rndis_dev, rndis_msg, |
3463 | + return rndis_filter_receive_data(ndev, net_dev, rndis_msg, |
3464 | channel, data, buflen); |
3465 | case RNDIS_MSG_INIT_C: |
3466 | case RNDIS_MSG_QUERY_C: |
3467 | case RNDIS_MSG_SET_C: |
3468 | /* completion msgs */ |
3469 | - rndis_filter_receive_response(rndis_dev, rndis_msg); |
3470 | + rndis_filter_receive_response(ndev, net_dev, rndis_msg); |
3471 | break; |
3472 | |
3473 | case RNDIS_MSG_INDICATE: |
3474 | @@ -759,7 +754,7 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev, |
3475 | /* Set indirection table entries */ |
3476 | itab = (u32 *)(rssp + 1); |
3477 | for (i = 0; i < ITAB_NUM; i++) |
3478 | - itab[i] = rdev->ind_table[i]; |
3479 | + itab[i] = rdev->rx_table[i]; |
3480 | |
3481 | /* Set hask key values */ |
3482 | keyp = (u8 *)((unsigned long)rssp + rssp->kashkey_offset); |
3483 | @@ -1114,6 +1109,10 @@ void rndis_set_subchannel(struct work_struct *w) |
3484 | netif_set_real_num_tx_queues(ndev, nvdev->num_chn); |
3485 | netif_set_real_num_rx_queues(ndev, nvdev->num_chn); |
3486 | |
3487 | + for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) |
3488 | + ndev_ctx->tx_table[i] = i % nvdev->num_chn; |
3489 | + |
3490 | + netif_device_attach(ndev); |
3491 | rtnl_unlock(); |
3492 | return; |
3493 | |
3494 | @@ -1124,73 +1123,26 @@ void rndis_set_subchannel(struct work_struct *w) |
3495 | |
3496 | nvdev->max_chn = 1; |
3497 | nvdev->num_chn = 1; |
3498 | + |
3499 | + netif_device_attach(ndev); |
3500 | unlock: |
3501 | rtnl_unlock(); |
3502 | } |
3503 | |
3504 | -struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3505 | - struct netvsc_device_info *device_info) |
3506 | +static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, |
3507 | + struct netvsc_device *nvdev) |
3508 | { |
3509 | - struct net_device *net = hv_get_drvdata(dev); |
3510 | + struct net_device *net = rndis_device->ndev; |
3511 | struct net_device_context *net_device_ctx = netdev_priv(net); |
3512 | - struct netvsc_device *net_device; |
3513 | - struct rndis_device *rndis_device; |
3514 | struct ndis_offload hwcaps; |
3515 | struct ndis_offload_params offloads; |
3516 | - struct ndis_recv_scale_cap rsscap; |
3517 | - u32 rsscap_size = sizeof(struct ndis_recv_scale_cap); |
3518 | unsigned int gso_max_size = GSO_MAX_SIZE; |
3519 | - u32 mtu, size; |
3520 | - const struct cpumask *node_cpu_mask; |
3521 | - u32 num_possible_rss_qs; |
3522 | - int i, ret; |
3523 | - |
3524 | - rndis_device = get_rndis_device(); |
3525 | - if (!rndis_device) |
3526 | - return ERR_PTR(-ENODEV); |
3527 | - |
3528 | - /* |
3529 | - * Let the inner driver handle this first to create the netvsc channel |
3530 | - * NOTE! Once the channel is created, we may get a receive callback |
3531 | - * (RndisFilterOnReceive()) before this call is completed |
3532 | - */ |
3533 | - net_device = netvsc_device_add(dev, device_info); |
3534 | - if (IS_ERR(net_device)) { |
3535 | - kfree(rndis_device); |
3536 | - return net_device; |
3537 | - } |
3538 | - |
3539 | - /* Initialize the rndis device */ |
3540 | - net_device->max_chn = 1; |
3541 | - net_device->num_chn = 1; |
3542 | - |
3543 | - net_device->extension = rndis_device; |
3544 | - rndis_device->ndev = net; |
3545 | - |
3546 | - /* Send the rndis initialization message */ |
3547 | - ret = rndis_filter_init_device(rndis_device, net_device); |
3548 | - if (ret != 0) |
3549 | - goto err_dev_remv; |
3550 | - |
3551 | - /* Get the MTU from the host */ |
3552 | - size = sizeof(u32); |
3553 | - ret = rndis_filter_query_device(rndis_device, net_device, |
3554 | - RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, |
3555 | - &mtu, &size); |
3556 | - if (ret == 0 && size == sizeof(u32) && mtu < net->mtu) |
3557 | - net->mtu = mtu; |
3558 | - |
3559 | - /* Get the mac address */ |
3560 | - ret = rndis_filter_query_device_mac(rndis_device, net_device); |
3561 | - if (ret != 0) |
3562 | - goto err_dev_remv; |
3563 | - |
3564 | - memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); |
3565 | + int ret; |
3566 | |
3567 | /* Find HW offload capabilities */ |
3568 | - ret = rndis_query_hwcaps(rndis_device, net_device, &hwcaps); |
3569 | + ret = rndis_query_hwcaps(rndis_device, nvdev, &hwcaps); |
3570 | if (ret != 0) |
3571 | - goto err_dev_remv; |
3572 | + return ret; |
3573 | |
3574 | /* A value of zero means "no change"; now turn on what we want. */ |
3575 | memset(&offloads, 0, sizeof(struct ndis_offload_params)); |
3576 | @@ -1198,8 +1150,12 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3577 | /* Linux does not care about IP checksum, always does in kernel */ |
3578 | offloads.ip_v4_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED; |
3579 | |
3580 | + /* Reset previously set hw_features flags */ |
3581 | + net->hw_features &= ~NETVSC_SUPPORTED_HW_FEATURES; |
3582 | + net_device_ctx->tx_checksum_mask = 0; |
3583 | + |
3584 | /* Compute tx offload settings based on hw capabilities */ |
3585 | - net->hw_features = NETIF_F_RXCSUM; |
3586 | + net->hw_features |= NETIF_F_RXCSUM; |
3587 | |
3588 | if ((hwcaps.csum.ip4_txcsum & NDIS_TXCSUM_ALL_TCP4) == NDIS_TXCSUM_ALL_TCP4) { |
3589 | /* Can checksum TCP */ |
3590 | @@ -1243,10 +1199,74 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3591 | } |
3592 | } |
3593 | |
3594 | + /* In case some hw_features disappeared we need to remove them from |
3595 | + * net->features list as they're no longer supported. |
3596 | + */ |
3597 | + net->features &= ~NETVSC_SUPPORTED_HW_FEATURES | net->hw_features; |
3598 | + |
3599 | netif_set_gso_max_size(net, gso_max_size); |
3600 | |
3601 | - ret = rndis_filter_set_offload_params(net, net_device, &offloads); |
3602 | - if (ret) |
3603 | + ret = rndis_filter_set_offload_params(net, nvdev, &offloads); |
3604 | + |
3605 | + return ret; |
3606 | +} |
3607 | + |
3608 | +struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3609 | + struct netvsc_device_info *device_info) |
3610 | +{ |
3611 | + struct net_device *net = hv_get_drvdata(dev); |
3612 | + struct netvsc_device *net_device; |
3613 | + struct rndis_device *rndis_device; |
3614 | + struct ndis_recv_scale_cap rsscap; |
3615 | + u32 rsscap_size = sizeof(struct ndis_recv_scale_cap); |
3616 | + u32 mtu, size; |
3617 | + u32 num_possible_rss_qs; |
3618 | + int i, ret; |
3619 | + |
3620 | + rndis_device = get_rndis_device(); |
3621 | + if (!rndis_device) |
3622 | + return ERR_PTR(-ENODEV); |
3623 | + |
3624 | + /* Let the inner driver handle this first to create the netvsc channel |
3625 | + * NOTE! Once the channel is created, we may get a receive callback |
3626 | + * (RndisFilterOnReceive()) before this call is completed |
3627 | + */ |
3628 | + net_device = netvsc_device_add(dev, device_info); |
3629 | + if (IS_ERR(net_device)) { |
3630 | + kfree(rndis_device); |
3631 | + return net_device; |
3632 | + } |
3633 | + |
3634 | + /* Initialize the rndis device */ |
3635 | + net_device->max_chn = 1; |
3636 | + net_device->num_chn = 1; |
3637 | + |
3638 | + net_device->extension = rndis_device; |
3639 | + rndis_device->ndev = net; |
3640 | + |
3641 | + /* Send the rndis initialization message */ |
3642 | + ret = rndis_filter_init_device(rndis_device, net_device); |
3643 | + if (ret != 0) |
3644 | + goto err_dev_remv; |
3645 | + |
3646 | + /* Get the MTU from the host */ |
3647 | + size = sizeof(u32); |
3648 | + ret = rndis_filter_query_device(rndis_device, net_device, |
3649 | + RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, |
3650 | + &mtu, &size); |
3651 | + if (ret == 0 && size == sizeof(u32) && mtu < net->mtu) |
3652 | + net->mtu = mtu; |
3653 | + |
3654 | + /* Get the mac address */ |
3655 | + ret = rndis_filter_query_device_mac(rndis_device, net_device); |
3656 | + if (ret != 0) |
3657 | + goto err_dev_remv; |
3658 | + |
3659 | + memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); |
3660 | + |
3661 | + /* Query and set hardware capabilities */ |
3662 | + ret = rndis_netdev_set_hwcaps(rndis_device, net_device); |
3663 | + if (ret != 0) |
3664 | goto err_dev_remv; |
3665 | |
3666 | rndis_filter_query_device_link_status(rndis_device, net_device); |
3667 | @@ -1256,7 +1276,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3668 | rndis_device->link_state ? "down" : "up"); |
3669 | |
3670 | if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) |
3671 | - return net_device; |
3672 | + goto out; |
3673 | |
3674 | rndis_filter_query_link_speed(rndis_device, net_device); |
3675 | |
3676 | @@ -1268,14 +1288,8 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3677 | if (ret || rsscap.num_recv_que < 2) |
3678 | goto out; |
3679 | |
3680 | - /* |
3681 | - * We will limit the VRSS channels to the number CPUs in the NUMA node |
3682 | - * the primary channel is currently bound to. |
3683 | - * |
3684 | - * This also guarantees that num_possible_rss_qs <= num_online_cpus |
3685 | - */ |
3686 | - node_cpu_mask = cpumask_of_node(cpu_to_node(dev->channel->target_cpu)); |
3687 | - num_possible_rss_qs = min_t(u32, cpumask_weight(node_cpu_mask), |
3688 | + /* This guarantees that num_possible_rss_qs <= num_online_cpus */ |
3689 | + num_possible_rss_qs = min_t(u32, num_online_cpus(), |
3690 | rsscap.num_recv_que); |
3691 | |
3692 | net_device->max_chn = min_t(u32, VRSS_CHANNEL_MAX, num_possible_rss_qs); |
3693 | @@ -1284,8 +1298,8 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3694 | net_device->num_chn = min(net_device->max_chn, device_info->num_chn); |
3695 | |
3696 | for (i = 0; i < ITAB_NUM; i++) |
3697 | - rndis_device->ind_table[i] = ethtool_rxfh_indir_default(i, |
3698 | - net_device->num_chn); |
3699 | + rndis_device->rx_table[i] = ethtool_rxfh_indir_default( |
3700 | + i, net_device->num_chn); |
3701 | |
3702 | atomic_set(&net_device->open_chn, 1); |
3703 | vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open); |
3704 | @@ -1313,6 +1327,10 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, |
3705 | net_device->num_chn = 1; |
3706 | } |
3707 | |
3708 | + /* No sub channels, device is ready */ |
3709 | + if (net_device->num_chn == 1) |
3710 | + netif_device_attach(net); |
3711 | + |
3712 | return net_device; |
3713 | |
3714 | err_dev_remv: |
3715 | @@ -1331,7 +1349,6 @@ void rndis_filter_device_remove(struct hv_device *dev, |
3716 | net_dev->extension = NULL; |
3717 | |
3718 | netvsc_device_remove(dev); |
3719 | - kfree(rndis_dev); |
3720 | } |
3721 | |
3722 | int rndis_filter_open(struct netvsc_device *nvdev) |
3723 | @@ -1355,8 +1372,3 @@ int rndis_filter_close(struct netvsc_device *nvdev) |
3724 | |
3725 | return rndis_filter_close_device(nvdev->extension); |
3726 | } |
3727 | - |
3728 | -bool rndis_filter_opened(const struct netvsc_device *nvdev) |
3729 | -{ |
3730 | - return atomic_read(&nvdev->open_cnt) > 0; |
3731 | -} |
3732 | diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c |
3733 | index 2f828eb9ace6..e522085ecbf7 100644 |
3734 | --- a/drivers/net/usb/qmi_wwan.c |
3735 | +++ b/drivers/net/usb/qmi_wwan.c |
3736 | @@ -1105,6 +1105,9 @@ static const struct usb_device_id products[] = { |
3737 | {QMI_FIXED_INTF(0x0846, 0x68a2, 8)}, |
3738 | {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ |
3739 | {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */ |
3740 | + {QMI_FIXED_INTF(0x1435, 0xd181, 3)}, /* Wistron NeWeb D18Q1 */ |
3741 | + {QMI_FIXED_INTF(0x1435, 0xd181, 4)}, /* Wistron NeWeb D18Q1 */ |
3742 | + {QMI_FIXED_INTF(0x1435, 0xd181, 5)}, /* Wistron NeWeb D18Q1 */ |
3743 | {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */ |
3744 | {QMI_FIXED_INTF(0x16d8, 0x6007, 0)}, /* CMOTech CHE-628S */ |
3745 | {QMI_FIXED_INTF(0x16d8, 0x6008, 0)}, /* CMOTech CMU-301 */ |
3746 | @@ -1241,6 +1244,7 @@ static const struct usb_device_id products[] = { |
3747 | {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ |
3748 | {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ |
3749 | {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ |
3750 | + {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ |
3751 | {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ |
3752 | {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */ |
3753 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ |
3754 | diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c |
3755 | index 42baad125a7d..32fc69539126 100644 |
3756 | --- a/drivers/net/usb/usbnet.c |
3757 | +++ b/drivers/net/usb/usbnet.c |
3758 | @@ -315,6 +315,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev) |
3759 | void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) |
3760 | { |
3761 | struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); |
3762 | + unsigned long flags; |
3763 | int status; |
3764 | |
3765 | if (test_bit(EVENT_RX_PAUSED, &dev->flags)) { |
3766 | @@ -326,10 +327,10 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) |
3767 | if (skb->protocol == 0) |
3768 | skb->protocol = eth_type_trans (skb, dev->net); |
3769 | |
3770 | - u64_stats_update_begin(&stats64->syncp); |
3771 | + flags = u64_stats_update_begin_irqsave(&stats64->syncp); |
3772 | stats64->rx_packets++; |
3773 | stats64->rx_bytes += skb->len; |
3774 | - u64_stats_update_end(&stats64->syncp); |
3775 | + u64_stats_update_end_irqrestore(&stats64->syncp, flags); |
3776 | |
3777 | netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n", |
3778 | skb->len + sizeof (struct ethhdr), skb->protocol); |
3779 | @@ -1250,11 +1251,12 @@ static void tx_complete (struct urb *urb) |
3780 | |
3781 | if (urb->status == 0) { |
3782 | struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); |
3783 | + unsigned long flags; |
3784 | |
3785 | - u64_stats_update_begin(&stats64->syncp); |
3786 | + flags = u64_stats_update_begin_irqsave(&stats64->syncp); |
3787 | stats64->tx_packets += entry->packets; |
3788 | stats64->tx_bytes += entry->length; |
3789 | - u64_stats_update_end(&stats64->syncp); |
3790 | + u64_stats_update_end_irqrestore(&stats64->syncp, flags); |
3791 | } else { |
3792 | dev->net->stats.tx_errors++; |
3793 | |
3794 | diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c |
3795 | index cf95290b160c..3628fd7e606f 100644 |
3796 | --- a/drivers/net/vmxnet3/vmxnet3_drv.c |
3797 | +++ b/drivers/net/vmxnet3/vmxnet3_drv.c |
3798 | @@ -369,6 +369,11 @@ vmxnet3_tq_tx_complete(struct vmxnet3_tx_queue *tq, |
3799 | |
3800 | gdesc = tq->comp_ring.base + tq->comp_ring.next2proc; |
3801 | while (VMXNET3_TCD_GET_GEN(&gdesc->tcd) == tq->comp_ring.gen) { |
3802 | + /* Prevent any &gdesc->tcd field from being (speculatively) |
3803 | + * read before (&gdesc->tcd)->gen is read. |
3804 | + */ |
3805 | + dma_rmb(); |
3806 | + |
3807 | completed += vmxnet3_unmap_pkt(VMXNET3_TCD_GET_TXIDX( |
3808 | &gdesc->tcd), tq, adapter->pdev, |
3809 | adapter); |
3810 | @@ -1099,6 +1104,11 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, |
3811 | gdesc->txd.tci = skb_vlan_tag_get(skb); |
3812 | } |
3813 | |
3814 | + /* Ensure that the write to (&gdesc->txd)->gen will be observed after |
3815 | + * all other writes to &gdesc->txd. |
3816 | + */ |
3817 | + dma_wmb(); |
3818 | + |
3819 | /* finally flips the GEN bit of the SOP desc. */ |
3820 | gdesc->dword[2] = cpu_to_le32(le32_to_cpu(gdesc->dword[2]) ^ |
3821 | VMXNET3_TXD_GEN); |
3822 | @@ -1286,6 +1296,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, |
3823 | */ |
3824 | break; |
3825 | } |
3826 | + |
3827 | + /* Prevent any rcd field from being (speculatively) read before |
3828 | + * rcd->gen is read. |
3829 | + */ |
3830 | + dma_rmb(); |
3831 | + |
3832 | BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 && |
3833 | rcd->rqID != rq->dataRingQid); |
3834 | idx = rcd->rxdIdx; |
3835 | @@ -1515,6 +1531,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, |
3836 | ring->next2comp = idx; |
3837 | num_to_alloc = vmxnet3_cmd_ring_desc_avail(ring); |
3838 | ring = rq->rx_ring + ring_idx; |
3839 | + |
3840 | + /* Ensure that the writes to rxd->gen bits will be observed |
3841 | + * after all other writes to rxd objects. |
3842 | + */ |
3843 | + dma_wmb(); |
3844 | + |
3845 | while (num_to_alloc) { |
3846 | vmxnet3_getRxDesc(rxd, &ring->base[ring->next2fill].rxd, |
3847 | &rxCmdDesc); |
3848 | @@ -2675,7 +2697,7 @@ vmxnet3_set_mac_addr(struct net_device *netdev, void *p) |
3849 | /* ==================== initialization and cleanup routines ============ */ |
3850 | |
3851 | static int |
3852 | -vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter, bool *dma64) |
3853 | +vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter) |
3854 | { |
3855 | int err; |
3856 | unsigned long mmio_start, mmio_len; |
3857 | @@ -2687,30 +2709,12 @@ vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter, bool *dma64) |
3858 | return err; |
3859 | } |
3860 | |
3861 | - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) == 0) { |
3862 | - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) { |
3863 | - dev_err(&pdev->dev, |
3864 | - "pci_set_consistent_dma_mask failed\n"); |
3865 | - err = -EIO; |
3866 | - goto err_set_mask; |
3867 | - } |
3868 | - *dma64 = true; |
3869 | - } else { |
3870 | - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) { |
3871 | - dev_err(&pdev->dev, |
3872 | - "pci_set_dma_mask failed\n"); |
3873 | - err = -EIO; |
3874 | - goto err_set_mask; |
3875 | - } |
3876 | - *dma64 = false; |
3877 | - } |
3878 | - |
3879 | err = pci_request_selected_regions(pdev, (1 << 2) - 1, |
3880 | vmxnet3_driver_name); |
3881 | if (err) { |
3882 | dev_err(&pdev->dev, |
3883 | "Failed to request region for adapter: error %d\n", err); |
3884 | - goto err_set_mask; |
3885 | + goto err_enable_device; |
3886 | } |
3887 | |
3888 | pci_set_master(pdev); |
3889 | @@ -2738,7 +2742,7 @@ vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter, bool *dma64) |
3890 | iounmap(adapter->hw_addr0); |
3891 | err_ioremap: |
3892 | pci_release_selected_regions(pdev, (1 << 2) - 1); |
3893 | -err_set_mask: |
3894 | +err_enable_device: |
3895 | pci_disable_device(pdev); |
3896 | return err; |
3897 | } |
3898 | @@ -3243,7 +3247,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, |
3899 | #endif |
3900 | }; |
3901 | int err; |
3902 | - bool dma64 = false; /* stupid gcc */ |
3903 | + bool dma64; |
3904 | u32 ver; |
3905 | struct net_device *netdev; |
3906 | struct vmxnet3_adapter *adapter; |
3907 | @@ -3289,6 +3293,24 @@ vmxnet3_probe_device(struct pci_dev *pdev, |
3908 | adapter->rx_ring_size = VMXNET3_DEF_RX_RING_SIZE; |
3909 | adapter->rx_ring2_size = VMXNET3_DEF_RX_RING2_SIZE; |
3910 | |
3911 | + if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) == 0) { |
3912 | + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) { |
3913 | + dev_err(&pdev->dev, |
3914 | + "pci_set_consistent_dma_mask failed\n"); |
3915 | + err = -EIO; |
3916 | + goto err_set_mask; |
3917 | + } |
3918 | + dma64 = true; |
3919 | + } else { |
3920 | + if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) { |
3921 | + dev_err(&pdev->dev, |
3922 | + "pci_set_dma_mask failed\n"); |
3923 | + err = -EIO; |
3924 | + goto err_set_mask; |
3925 | + } |
3926 | + dma64 = false; |
3927 | + } |
3928 | + |
3929 | spin_lock_init(&adapter->cmd_lock); |
3930 | adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter, |
3931 | sizeof(struct vmxnet3_adapter), |
3932 | @@ -3296,7 +3318,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, |
3933 | if (dma_mapping_error(&adapter->pdev->dev, adapter->adapter_pa)) { |
3934 | dev_err(&pdev->dev, "Failed to map dma\n"); |
3935 | err = -EFAULT; |
3936 | - goto err_dma_map; |
3937 | + goto err_set_mask; |
3938 | } |
3939 | adapter->shared = dma_alloc_coherent( |
3940 | &adapter->pdev->dev, |
3941 | @@ -3347,7 +3369,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, |
3942 | } |
3943 | #endif /* VMXNET3_RSS */ |
3944 | |
3945 | - err = vmxnet3_alloc_pci_resources(adapter, &dma64); |
3946 | + err = vmxnet3_alloc_pci_resources(adapter); |
3947 | if (err < 0) |
3948 | goto err_alloc_pci; |
3949 | |
3950 | @@ -3493,7 +3515,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, |
3951 | err_alloc_shared: |
3952 | dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa, |
3953 | sizeof(struct vmxnet3_adapter), PCI_DMA_TODEVICE); |
3954 | -err_dma_map: |
3955 | +err_set_mask: |
3956 | free_netdev(netdev); |
3957 | return err; |
3958 | } |
3959 | diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c |
3960 | index e1cfa06810ef..e79f2a181ad2 100644 |
3961 | --- a/drivers/rtc/hctosys.c |
3962 | +++ b/drivers/rtc/hctosys.c |
3963 | @@ -49,6 +49,11 @@ static int __init rtc_hctosys(void) |
3964 | |
3965 | tv64.tv_sec = rtc_tm_to_time64(&tm); |
3966 | |
3967 | +#if BITS_PER_LONG == 32 |
3968 | + if (tv64.tv_sec > INT_MAX) |
3969 | + goto err_read; |
3970 | +#endif |
3971 | + |
3972 | err = do_settimeofday64(&tv64); |
3973 | |
3974 | dev_info(rtc->dev.parent, |
3975 | diff --git a/drivers/rtc/rtc-goldfish.c b/drivers/rtc/rtc-goldfish.c |
3976 | index d67769265185..a1c44d0c8557 100644 |
3977 | --- a/drivers/rtc/rtc-goldfish.c |
3978 | +++ b/drivers/rtc/rtc-goldfish.c |
3979 | @@ -235,3 +235,5 @@ static struct platform_driver goldfish_rtc = { |
3980 | }; |
3981 | |
3982 | module_platform_driver(goldfish_rtc); |
3983 | + |
3984 | +MODULE_LICENSE("GPL v2"); |
3985 | diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c |
3986 | index c90fba3ed861..6620016869cf 100644 |
3987 | --- a/drivers/rtc/rtc-m41t80.c |
3988 | +++ b/drivers/rtc/rtc-m41t80.c |
3989 | @@ -885,7 +885,6 @@ static int m41t80_probe(struct i2c_client *client, |
3990 | { |
3991 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
3992 | int rc = 0; |
3993 | - struct rtc_device *rtc = NULL; |
3994 | struct rtc_time tm; |
3995 | struct m41t80_data *m41t80_data = NULL; |
3996 | bool wakeup_source = false; |
3997 | @@ -909,6 +908,10 @@ static int m41t80_probe(struct i2c_client *client, |
3998 | m41t80_data->features = id->driver_data; |
3999 | i2c_set_clientdata(client, m41t80_data); |
4000 | |
4001 | + m41t80_data->rtc = devm_rtc_allocate_device(&client->dev); |
4002 | + if (IS_ERR(m41t80_data->rtc)) |
4003 | + return PTR_ERR(m41t80_data->rtc); |
4004 | + |
4005 | #ifdef CONFIG_OF |
4006 | wakeup_source = of_property_read_bool(client->dev.of_node, |
4007 | "wakeup-source"); |
4008 | @@ -932,15 +935,11 @@ static int m41t80_probe(struct i2c_client *client, |
4009 | device_init_wakeup(&client->dev, true); |
4010 | } |
4011 | |
4012 | - rtc = devm_rtc_device_register(&client->dev, client->name, |
4013 | - &m41t80_rtc_ops, THIS_MODULE); |
4014 | - if (IS_ERR(rtc)) |
4015 | - return PTR_ERR(rtc); |
4016 | + m41t80_data->rtc->ops = &m41t80_rtc_ops; |
4017 | |
4018 | - m41t80_data->rtc = rtc; |
4019 | if (client->irq <= 0) { |
4020 | /* We cannot support UIE mode if we do not have an IRQ line */ |
4021 | - rtc->uie_unsupported = 1; |
4022 | + m41t80_data->rtc->uie_unsupported = 1; |
4023 | } |
4024 | |
4025 | /* Make sure HT (Halt Update) bit is cleared */ |
4026 | @@ -993,6 +992,11 @@ static int m41t80_probe(struct i2c_client *client, |
4027 | if (m41t80_data->features & M41T80_FEATURE_SQ) |
4028 | m41t80_sqw_register_clk(m41t80_data); |
4029 | #endif |
4030 | + |
4031 | + rc = rtc_register_device(m41t80_data->rtc); |
4032 | + if (rc) |
4033 | + return rc; |
4034 | + |
4035 | return 0; |
4036 | } |
4037 | |
4038 | diff --git a/drivers/rtc/rtc-rk808.c b/drivers/rtc/rtc-rk808.c |
4039 | index 35c9aada07c8..79c8da54e922 100644 |
4040 | --- a/drivers/rtc/rtc-rk808.c |
4041 | +++ b/drivers/rtc/rtc-rk808.c |
4042 | @@ -416,12 +416,11 @@ static int rk808_rtc_probe(struct platform_device *pdev) |
4043 | |
4044 | device_init_wakeup(&pdev->dev, 1); |
4045 | |
4046 | - rk808_rtc->rtc = devm_rtc_device_register(&pdev->dev, "rk808-rtc", |
4047 | - &rk808_rtc_ops, THIS_MODULE); |
4048 | - if (IS_ERR(rk808_rtc->rtc)) { |
4049 | - ret = PTR_ERR(rk808_rtc->rtc); |
4050 | - return ret; |
4051 | - } |
4052 | + rk808_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); |
4053 | + if (IS_ERR(rk808_rtc->rtc)) |
4054 | + return PTR_ERR(rk808_rtc->rtc); |
4055 | + |
4056 | + rk808_rtc->rtc->ops = &rk808_rtc_ops; |
4057 | |
4058 | rk808_rtc->irq = platform_get_irq(pdev, 0); |
4059 | if (rk808_rtc->irq < 0) { |
4060 | @@ -438,9 +437,10 @@ static int rk808_rtc_probe(struct platform_device *pdev) |
4061 | if (ret) { |
4062 | dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n", |
4063 | rk808_rtc->irq, ret); |
4064 | + return ret; |
4065 | } |
4066 | |
4067 | - return ret; |
4068 | + return rtc_register_device(rk808_rtc->rtc); |
4069 | } |
4070 | |
4071 | static struct platform_driver rk808_rtc_driver = { |
4072 | diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c |
4073 | index 026035373ae6..38a12435b5a0 100644 |
4074 | --- a/drivers/rtc/rtc-rp5c01.c |
4075 | +++ b/drivers/rtc/rtc-rp5c01.c |
4076 | @@ -249,16 +249,24 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) |
4077 | |
4078 | platform_set_drvdata(dev, priv); |
4079 | |
4080 | - rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops, |
4081 | - THIS_MODULE); |
4082 | + rtc = devm_rtc_allocate_device(&dev->dev); |
4083 | if (IS_ERR(rtc)) |
4084 | return PTR_ERR(rtc); |
4085 | + |
4086 | + rtc->ops = &rp5c01_rtc_ops; |
4087 | + |
4088 | priv->rtc = rtc; |
4089 | |
4090 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
4091 | if (error) |
4092 | return error; |
4093 | |
4094 | + error = rtc_register_device(rtc); |
4095 | + if (error) { |
4096 | + sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
4097 | + return error; |
4098 | + } |
4099 | + |
4100 | return 0; |
4101 | } |
4102 | |
4103 | diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c |
4104 | index d8ef9e052c4f..9af591d5223c 100644 |
4105 | --- a/drivers/rtc/rtc-snvs.c |
4106 | +++ b/drivers/rtc/rtc-snvs.c |
4107 | @@ -132,20 +132,23 @@ static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm) |
4108 | { |
4109 | struct snvs_rtc_data *data = dev_get_drvdata(dev); |
4110 | unsigned long time; |
4111 | + int ret; |
4112 | |
4113 | rtc_tm_to_time(tm, &time); |
4114 | |
4115 | /* Disable RTC first */ |
4116 | - snvs_rtc_enable(data, false); |
4117 | + ret = snvs_rtc_enable(data, false); |
4118 | + if (ret) |
4119 | + return ret; |
4120 | |
4121 | /* Write 32-bit time to 47-bit timer, leaving 15 LSBs blank */ |
4122 | regmap_write(data->regmap, data->offset + SNVS_LPSRTCLR, time << CNTR_TO_SECS_SH); |
4123 | regmap_write(data->regmap, data->offset + SNVS_LPSRTCMR, time >> (32 - CNTR_TO_SECS_SH)); |
4124 | |
4125 | /* Enable RTC again */ |
4126 | - snvs_rtc_enable(data, true); |
4127 | + ret = snvs_rtc_enable(data, true); |
4128 | |
4129 | - return 0; |
4130 | + return ret; |
4131 | } |
4132 | |
4133 | static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
4134 | @@ -288,7 +291,11 @@ static int snvs_rtc_probe(struct platform_device *pdev) |
4135 | regmap_write(data->regmap, data->offset + SNVS_LPSR, 0xffffffff); |
4136 | |
4137 | /* Enable RTC */ |
4138 | - snvs_rtc_enable(data, true); |
4139 | + ret = snvs_rtc_enable(data, true); |
4140 | + if (ret) { |
4141 | + dev_err(&pdev->dev, "failed to enable rtc %d\n", ret); |
4142 | + goto error_rtc_device_register; |
4143 | + } |
4144 | |
4145 | device_init_wakeup(&pdev->dev, true); |
4146 | |
4147 | diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c |
4148 | index 560d9a5e0225..a9528083061d 100644 |
4149 | --- a/drivers/rtc/rtc-tx4939.c |
4150 | +++ b/drivers/rtc/rtc-tx4939.c |
4151 | @@ -86,7 +86,8 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm) |
4152 | for (i = 2; i < 6; i++) |
4153 | buf[i] = __raw_readl(&rtcreg->dat); |
4154 | spin_unlock_irq(&pdata->lock); |
4155 | - sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2]; |
4156 | + sec = ((unsigned long)buf[5] << 24) | (buf[4] << 16) | |
4157 | + (buf[3] << 8) | buf[2]; |
4158 | rtc_time_to_tm(sec, tm); |
4159 | return rtc_valid_tm(tm); |
4160 | } |
4161 | @@ -147,7 +148,8 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
4162 | alrm->enabled = (ctl & TX4939_RTCCTL_ALME) ? 1 : 0; |
4163 | alrm->pending = (ctl & TX4939_RTCCTL_ALMD) ? 1 : 0; |
4164 | spin_unlock_irq(&pdata->lock); |
4165 | - sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2]; |
4166 | + sec = ((unsigned long)buf[5] << 24) | (buf[4] << 16) | |
4167 | + (buf[3] << 8) | buf[2]; |
4168 | rtc_time_to_tm(sec, &alrm->time); |
4169 | return rtc_valid_tm(&alrm->time); |
4170 | } |
4171 | diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c |
4172 | index a8b831000b2d..18c4f933e8b9 100644 |
4173 | --- a/drivers/s390/scsi/zfcp_dbf.c |
4174 | +++ b/drivers/s390/scsi/zfcp_dbf.c |
4175 | @@ -4,7 +4,7 @@ |
4176 | * |
4177 | * Debug traces for zfcp. |
4178 | * |
4179 | - * Copyright IBM Corp. 2002, 2017 |
4180 | + * Copyright IBM Corp. 2002, 2018 |
4181 | */ |
4182 | |
4183 | #define KMSG_COMPONENT "zfcp" |
4184 | @@ -308,6 +308,27 @@ void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter, |
4185 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
4186 | } |
4187 | |
4188 | +/** |
4189 | + * zfcp_dbf_rec_trig_lock - trace event related to triggered recovery with lock |
4190 | + * @tag: identifier for event |
4191 | + * @adapter: adapter on which the erp_action should run |
4192 | + * @port: remote port involved in the erp_action |
4193 | + * @sdev: scsi device involved in the erp_action |
4194 | + * @want: wanted erp_action |
4195 | + * @need: required erp_action |
4196 | + * |
4197 | + * The adapter->erp_lock must not be held. |
4198 | + */ |
4199 | +void zfcp_dbf_rec_trig_lock(char *tag, struct zfcp_adapter *adapter, |
4200 | + struct zfcp_port *port, struct scsi_device *sdev, |
4201 | + u8 want, u8 need) |
4202 | +{ |
4203 | + unsigned long flags; |
4204 | + |
4205 | + read_lock_irqsave(&adapter->erp_lock, flags); |
4206 | + zfcp_dbf_rec_trig(tag, adapter, port, sdev, want, need); |
4207 | + read_unlock_irqrestore(&adapter->erp_lock, flags); |
4208 | +} |
4209 | |
4210 | /** |
4211 | * zfcp_dbf_rec_run_lvl - trace event related to running recovery |
4212 | diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h |
4213 | index 8ca2ab7deaa9..b1cbb14fb2ae 100644 |
4214 | --- a/drivers/s390/scsi/zfcp_ext.h |
4215 | +++ b/drivers/s390/scsi/zfcp_ext.h |
4216 | @@ -4,7 +4,7 @@ |
4217 | * |
4218 | * External function declarations. |
4219 | * |
4220 | - * Copyright IBM Corp. 2002, 2016 |
4221 | + * Copyright IBM Corp. 2002, 2018 |
4222 | */ |
4223 | |
4224 | #ifndef ZFCP_EXT_H |
4225 | @@ -35,6 +35,9 @@ extern int zfcp_dbf_adapter_register(struct zfcp_adapter *); |
4226 | extern void zfcp_dbf_adapter_unregister(struct zfcp_adapter *); |
4227 | extern void zfcp_dbf_rec_trig(char *, struct zfcp_adapter *, |
4228 | struct zfcp_port *, struct scsi_device *, u8, u8); |
4229 | +extern void zfcp_dbf_rec_trig_lock(char *tag, struct zfcp_adapter *adapter, |
4230 | + struct zfcp_port *port, |
4231 | + struct scsi_device *sdev, u8 want, u8 need); |
4232 | extern void zfcp_dbf_rec_run(char *, struct zfcp_erp_action *); |
4233 | extern void zfcp_dbf_rec_run_lvl(int level, char *tag, |
4234 | struct zfcp_erp_action *erp); |
4235 | diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c |
4236 | index 4d2ba5682493..22f9562f415c 100644 |
4237 | --- a/drivers/s390/scsi/zfcp_scsi.c |
4238 | +++ b/drivers/s390/scsi/zfcp_scsi.c |
4239 | @@ -4,7 +4,7 @@ |
4240 | * |
4241 | * Interface to Linux SCSI midlayer. |
4242 | * |
4243 | - * Copyright IBM Corp. 2002, 2017 |
4244 | + * Copyright IBM Corp. 2002, 2018 |
4245 | */ |
4246 | |
4247 | #define KMSG_COMPONENT "zfcp" |
4248 | @@ -618,9 +618,9 @@ static void zfcp_scsi_rport_register(struct zfcp_port *port) |
4249 | ids.port_id = port->d_id; |
4250 | ids.roles = FC_RPORT_ROLE_FCP_TARGET; |
4251 | |
4252 | - zfcp_dbf_rec_trig("scpaddy", port->adapter, port, NULL, |
4253 | - ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD, |
4254 | - ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD); |
4255 | + zfcp_dbf_rec_trig_lock("scpaddy", port->adapter, port, NULL, |
4256 | + ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD, |
4257 | + ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD); |
4258 | rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids); |
4259 | if (!rport) { |
4260 | dev_err(&port->adapter->ccw_device->dev, |
4261 | @@ -642,9 +642,9 @@ static void zfcp_scsi_rport_block(struct zfcp_port *port) |
4262 | struct fc_rport *rport = port->rport; |
4263 | |
4264 | if (rport) { |
4265 | - zfcp_dbf_rec_trig("scpdely", port->adapter, port, NULL, |
4266 | - ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL, |
4267 | - ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL); |
4268 | + zfcp_dbf_rec_trig_lock("scpdely", port->adapter, port, NULL, |
4269 | + ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL, |
4270 | + ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL); |
4271 | fc_remote_port_delete(rport); |
4272 | port->rport = NULL; |
4273 | } |
4274 | diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c |
4275 | index 3696f9ded252..998788a967be 100644 |
4276 | --- a/drivers/scsi/aacraid/commsup.c |
4277 | +++ b/drivers/scsi/aacraid/commsup.c |
4278 | @@ -1530,9 +1530,10 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) |
4279 | host = aac->scsi_host_ptr; |
4280 | scsi_block_requests(host); |
4281 | aac_adapter_disable_int(aac); |
4282 | - if (aac->thread->pid != current->pid) { |
4283 | + if (aac->thread && aac->thread->pid != current->pid) { |
4284 | spin_unlock_irq(host->host_lock); |
4285 | kthread_stop(aac->thread); |
4286 | + aac->thread = NULL; |
4287 | jafo = 1; |
4288 | } |
4289 | |
4290 | @@ -1619,6 +1620,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) |
4291 | aac->name); |
4292 | if (IS_ERR(aac->thread)) { |
4293 | retval = PTR_ERR(aac->thread); |
4294 | + aac->thread = NULL; |
4295 | goto out; |
4296 | } |
4297 | } |
4298 | diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c |
4299 | index 509fe23fafe1..4917649cacd5 100644 |
4300 | --- a/drivers/scsi/aacraid/linit.c |
4301 | +++ b/drivers/scsi/aacraid/linit.c |
4302 | @@ -1565,6 +1565,7 @@ static void __aac_shutdown(struct aac_dev * aac) |
4303 | up(&fib->event_wait); |
4304 | } |
4305 | kthread_stop(aac->thread); |
4306 | + aac->thread = NULL; |
4307 | } |
4308 | |
4309 | aac_send_shutdown(aac); |
4310 | @@ -1690,8 +1691,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) |
4311 | * Map in the registers from the adapter. |
4312 | */ |
4313 | aac->base_size = AAC_MIN_FOOTPRINT_SIZE; |
4314 | - if ((*aac_drivers[index].init)(aac)) |
4315 | + if ((*aac_drivers[index].init)(aac)) { |
4316 | + error = -ENODEV; |
4317 | goto out_unmap; |
4318 | + } |
4319 | |
4320 | if (aac->sync_mode) { |
4321 | if (aac_sync_mode) |
4322 | diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c |
4323 | index 5b6153f23f01..6626b28ba8fe 100644 |
4324 | --- a/drivers/scsi/bnx2fc/bnx2fc_io.c |
4325 | +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c |
4326 | @@ -1865,6 +1865,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, |
4327 | /* we will not receive ABTS response for this IO */ |
4328 | BNX2FC_IO_DBG(io_req, "Timer context finished processing " |
4329 | "this scsi cmd\n"); |
4330 | + return; |
4331 | } |
4332 | |
4333 | /* Cancel the timeout_work, as we received IO completion */ |
4334 | diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c |
4335 | index 4d934d6c3e13..e11eff6b0e97 100644 |
4336 | --- a/drivers/scsi/iscsi_tcp.c |
4337 | +++ b/drivers/scsi/iscsi_tcp.c |
4338 | @@ -37,6 +37,7 @@ |
4339 | #include <linux/kfifo.h> |
4340 | #include <linux/scatterlist.h> |
4341 | #include <linux/module.h> |
4342 | +#include <linux/backing-dev.h> |
4343 | #include <net/tcp.h> |
4344 | #include <scsi/scsi_cmnd.h> |
4345 | #include <scsi/scsi_device.h> |
4346 | @@ -952,6 +953,13 @@ static int iscsi_sw_tcp_slave_alloc(struct scsi_device *sdev) |
4347 | |
4348 | static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev) |
4349 | { |
4350 | + struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(sdev->host); |
4351 | + struct iscsi_session *session = tcp_sw_host->session; |
4352 | + struct iscsi_conn *conn = session->leadconn; |
4353 | + |
4354 | + if (conn->datadgst_en) |
4355 | + sdev->request_queue->backing_dev_info->capabilities |
4356 | + |= BDI_CAP_STABLE_WRITES; |
4357 | blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_ANY); |
4358 | blk_queue_dma_alignment(sdev->request_queue, 0); |
4359 | return 0; |
4360 | diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c |
4361 | index 10b17da20176..0c4b186c852a 100644 |
4362 | --- a/drivers/scsi/libsas/sas_scsi_host.c |
4363 | +++ b/drivers/scsi/libsas/sas_scsi_host.c |
4364 | @@ -222,6 +222,7 @@ int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
4365 | static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) |
4366 | { |
4367 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(cmd->device->host); |
4368 | + struct domain_device *dev = cmd_to_domain_dev(cmd); |
4369 | struct sas_task *task = TO_SAS_TASK(cmd); |
4370 | |
4371 | /* At this point, we only get called following an actual abort |
4372 | @@ -230,6 +231,14 @@ static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) |
4373 | */ |
4374 | sas_end_task(cmd, task); |
4375 | |
4376 | + if (dev_is_sata(dev)) { |
4377 | + /* defer commands to libata so that libata EH can |
4378 | + * handle ata qcs correctly |
4379 | + */ |
4380 | + list_move_tail(&cmd->eh_entry, &sas_ha->eh_ata_q); |
4381 | + return; |
4382 | + } |
4383 | + |
4384 | /* now finish the command and move it on to the error |
4385 | * handler done list, this also takes it off the |
4386 | * error handler pending list. |
4387 | @@ -237,22 +246,6 @@ static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) |
4388 | scsi_eh_finish_cmd(cmd, &sas_ha->eh_done_q); |
4389 | } |
4390 | |
4391 | -static void sas_eh_defer_cmd(struct scsi_cmnd *cmd) |
4392 | -{ |
4393 | - struct domain_device *dev = cmd_to_domain_dev(cmd); |
4394 | - struct sas_ha_struct *ha = dev->port->ha; |
4395 | - struct sas_task *task = TO_SAS_TASK(cmd); |
4396 | - |
4397 | - if (!dev_is_sata(dev)) { |
4398 | - sas_eh_finish_cmd(cmd); |
4399 | - return; |
4400 | - } |
4401 | - |
4402 | - /* report the timeout to libata */ |
4403 | - sas_end_task(cmd, task); |
4404 | - list_move_tail(&cmd->eh_entry, &ha->eh_ata_q); |
4405 | -} |
4406 | - |
4407 | static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd) |
4408 | { |
4409 | struct scsi_cmnd *cmd, *n; |
4410 | @@ -260,7 +253,7 @@ static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd |
4411 | list_for_each_entry_safe(cmd, n, error_q, eh_entry) { |
4412 | if (cmd->device->sdev_target == my_cmd->device->sdev_target && |
4413 | cmd->device->lun == my_cmd->device->lun) |
4414 | - sas_eh_defer_cmd(cmd); |
4415 | + sas_eh_finish_cmd(cmd); |
4416 | } |
4417 | } |
4418 | |
4419 | @@ -630,12 +623,12 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head * |
4420 | case TASK_IS_DONE: |
4421 | SAS_DPRINTK("%s: task 0x%p is done\n", __func__, |
4422 | task); |
4423 | - sas_eh_defer_cmd(cmd); |
4424 | + sas_eh_finish_cmd(cmd); |
4425 | continue; |
4426 | case TASK_IS_ABORTED: |
4427 | SAS_DPRINTK("%s: task 0x%p is aborted\n", |
4428 | __func__, task); |
4429 | - sas_eh_defer_cmd(cmd); |
4430 | + sas_eh_finish_cmd(cmd); |
4431 | continue; |
4432 | case TASK_IS_AT_LU: |
4433 | SAS_DPRINTK("task 0x%p is at LU: lu recover\n", task); |
4434 | @@ -646,7 +639,7 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head * |
4435 | "recovered\n", |
4436 | SAS_ADDR(task->dev), |
4437 | cmd->device->lun); |
4438 | - sas_eh_defer_cmd(cmd); |
4439 | + sas_eh_finish_cmd(cmd); |
4440 | sas_scsi_clear_queue_lu(work_q, cmd); |
4441 | goto Again; |
4442 | } |
4443 | diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c |
4444 | index dc6519b2c53a..3da242201cb4 100644 |
4445 | --- a/drivers/scsi/lpfc/lpfc_attr.c |
4446 | +++ b/drivers/scsi/lpfc/lpfc_attr.c |
4447 | @@ -871,7 +871,12 @@ lpfc_issue_lip(struct Scsi_Host *shost) |
4448 | LPFC_MBOXQ_t *pmboxq; |
4449 | int mbxstatus = MBXERR_ERROR; |
4450 | |
4451 | + /* |
4452 | + * If the link is offline, disabled or BLOCK_MGMT_IO |
4453 | + * it doesn't make any sense to allow issue_lip |
4454 | + */ |
4455 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
4456 | + (phba->hba_flag & LINK_DISABLED) || |
4457 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
4458 | return -EPERM; |
4459 | |
4460 | diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c |
4461 | index d9a03beb76a4..4962d665b4d2 100644 |
4462 | --- a/drivers/scsi/lpfc/lpfc_hbadisc.c |
4463 | +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c |
4464 | @@ -698,8 +698,9 @@ lpfc_work_done(struct lpfc_hba *phba) |
4465 | phba->hba_flag & HBA_SP_QUEUE_EVT)) { |
4466 | if (pring->flag & LPFC_STOP_IOCB_EVENT) { |
4467 | pring->flag |= LPFC_DEFERRED_RING_EVENT; |
4468 | - /* Set the lpfc data pending flag */ |
4469 | - set_bit(LPFC_DATA_READY, &phba->data_flags); |
4470 | + /* Preserve legacy behavior. */ |
4471 | + if (!(phba->hba_flag & HBA_SP_QUEUE_EVT)) |
4472 | + set_bit(LPFC_DATA_READY, &phba->data_flags); |
4473 | } else { |
4474 | if (phba->link_state >= LPFC_LINK_UP || |
4475 | phba->link_flag & LS_MDS_LOOPBACK) { |
4476 | diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c |
4477 | index 455f3ce9fda9..dc83498024dc 100644 |
4478 | --- a/drivers/scsi/lpfc/lpfc_sli.c |
4479 | +++ b/drivers/scsi/lpfc/lpfc_sli.c |
4480 | @@ -129,6 +129,8 @@ lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe *wqe) |
4481 | /* set consumption flag every once in a while */ |
4482 | if (!((q->host_index + 1) % q->entry_repost)) |
4483 | bf_set(wqe_wqec, &wqe->generic.wqe_com, 1); |
4484 | + else |
4485 | + bf_set(wqe_wqec, &wqe->generic.wqe_com, 0); |
4486 | if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED) |
4487 | bf_set(wqe_wqid, &wqe->generic.wqe_com, q->queue_id); |
4488 | lpfc_sli_pcimem_bcopy(wqe, temp_wqe, q->entry_size); |
4489 | diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c |
4490 | index 6efa739a1912..9b716c8c558a 100644 |
4491 | --- a/drivers/scsi/mpt3sas/mpt3sas_base.c |
4492 | +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c |
4493 | @@ -1921,8 +1921,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) |
4494 | continue; |
4495 | } |
4496 | |
4497 | - for_each_cpu(cpu, mask) |
4498 | + for_each_cpu_and(cpu, mask, cpu_online_mask) { |
4499 | + if (cpu >= ioc->cpu_msix_table_sz) |
4500 | + break; |
4501 | ioc->cpu_msix_table[cpu] = reply_q->msix_index; |
4502 | + } |
4503 | } |
4504 | return; |
4505 | } |
4506 | diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c |
4507 | index 139219c994e9..ae5e579ac473 100644 |
4508 | --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c |
4509 | +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c |
4510 | @@ -8941,7 +8941,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
4511 | snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), |
4512 | "fw_event_%s%d", ioc->driver_name, ioc->id); |
4513 | ioc->firmware_event_thread = alloc_ordered_workqueue( |
4514 | - ioc->firmware_event_name, WQ_MEM_RECLAIM); |
4515 | + ioc->firmware_event_name, 0); |
4516 | if (!ioc->firmware_event_thread) { |
4517 | pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", |
4518 | ioc->name, __FILE__, __LINE__, __func__); |
4519 | diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c |
4520 | index 7de5d8d75480..eb5471bc7263 100644 |
4521 | --- a/drivers/scsi/mvsas/mv_94xx.c |
4522 | +++ b/drivers/scsi/mvsas/mv_94xx.c |
4523 | @@ -1080,16 +1080,16 @@ static int mvs_94xx_gpio_write(struct mvs_prv_info *mvs_prv, |
4524 | void __iomem *regs = mvi->regs_ex - 0x10200; |
4525 | |
4526 | int drive = (i/3) & (4-1); /* drive number on host */ |
4527 | - u32 block = mr32(MVS_SGPIO_DCTRL + |
4528 | + int driveshift = drive * 8; /* bit offset of drive */ |
4529 | + u32 block = ioread32be(regs + MVS_SGPIO_DCTRL + |
4530 | MVS_SGPIO_HOST_OFFSET * mvi->id); |
4531 | |
4532 | - |
4533 | /* |
4534 | * if bit is set then create a mask with the first |
4535 | * bit of the drive set in the mask ... |
4536 | */ |
4537 | - u32 bit = (write_data[i/8] & (1 << (i&(8-1)))) ? |
4538 | - 1<<(24-drive*8) : 0; |
4539 | + u32 bit = get_unaligned_be32(write_data) & (1 << i) ? |
4540 | + 1 << driveshift : 0; |
4541 | |
4542 | /* |
4543 | * ... and then shift it to the right position based |
4544 | @@ -1098,26 +1098,27 @@ static int mvs_94xx_gpio_write(struct mvs_prv_info *mvs_prv, |
4545 | switch (i%3) { |
4546 | case 0: /* activity */ |
4547 | block &= ~((0x7 << MVS_SGPIO_DCTRL_ACT_SHIFT) |
4548 | - << (24-drive*8)); |
4549 | + << driveshift); |
4550 | /* hardwire activity bit to SOF */ |
4551 | block |= LED_BLINKA_SOF << ( |
4552 | MVS_SGPIO_DCTRL_ACT_SHIFT + |
4553 | - (24-drive*8)); |
4554 | + driveshift); |
4555 | break; |
4556 | case 1: /* id */ |
4557 | block &= ~((0x3 << MVS_SGPIO_DCTRL_LOC_SHIFT) |
4558 | - << (24-drive*8)); |
4559 | + << driveshift); |
4560 | block |= bit << MVS_SGPIO_DCTRL_LOC_SHIFT; |
4561 | break; |
4562 | case 2: /* fail */ |
4563 | block &= ~((0x7 << MVS_SGPIO_DCTRL_ERR_SHIFT) |
4564 | - << (24-drive*8)); |
4565 | + << driveshift); |
4566 | block |= bit << MVS_SGPIO_DCTRL_ERR_SHIFT; |
4567 | break; |
4568 | } |
4569 | |
4570 | - mw32(MVS_SGPIO_DCTRL + MVS_SGPIO_HOST_OFFSET * mvi->id, |
4571 | - block); |
4572 | + iowrite32be(block, |
4573 | + regs + MVS_SGPIO_DCTRL + |
4574 | + MVS_SGPIO_HOST_OFFSET * mvi->id); |
4575 | |
4576 | } |
4577 | |
4578 | @@ -1132,7 +1133,7 @@ static int mvs_94xx_gpio_write(struct mvs_prv_info *mvs_prv, |
4579 | void __iomem *regs = mvi->regs_ex - 0x10200; |
4580 | |
4581 | mw32(MVS_SGPIO_DCTRL + MVS_SGPIO_HOST_OFFSET * mvi->id, |
4582 | - be32_to_cpu(((u32 *) write_data)[i])); |
4583 | + ((u32 *) write_data)[i]); |
4584 | } |
4585 | return reg_count; |
4586 | } |
4587 | diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c |
4588 | index 93d54acd4a22..2e5e04a7623f 100644 |
4589 | --- a/drivers/scsi/qedi/qedi_fw.c |
4590 | +++ b/drivers/scsi/qedi/qedi_fw.c |
4591 | @@ -769,6 +769,11 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, |
4592 | |
4593 | iscsi_cid = cqe->conn_id; |
4594 | qedi_conn = qedi->cid_que.conn_cid_tbl[iscsi_cid]; |
4595 | + if (!qedi_conn) { |
4596 | + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, |
4597 | + "icid not found 0x%x\n", cqe->conn_id); |
4598 | + return; |
4599 | + } |
4600 | |
4601 | /* Based on this itt get the corresponding qedi_cmd */ |
4602 | spin_lock_bh(&qedi_conn->tmf_work_lock); |
4603 | diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c |
4604 | index cccc34adc0e0..1573749fe615 100644 |
4605 | --- a/drivers/scsi/qedi/qedi_main.c |
4606 | +++ b/drivers/scsi/qedi/qedi_main.c |
4607 | @@ -1840,8 +1840,8 @@ static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) |
4608 | |
4609 | switch (type) { |
4610 | case ISCSI_BOOT_INI_INITIATOR_NAME: |
4611 | - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", |
4612 | - initiator->initiator_name.byte); |
4613 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
4614 | + initiator->initiator_name.byte); |
4615 | break; |
4616 | default: |
4617 | rc = 0; |
4618 | @@ -1908,8 +1908,8 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, |
4619 | |
4620 | switch (type) { |
4621 | case ISCSI_BOOT_TGT_NAME: |
4622 | - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", |
4623 | - block->target[idx].target_name.byte); |
4624 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
4625 | + block->target[idx].target_name.byte); |
4626 | break; |
4627 | case ISCSI_BOOT_TGT_IP_ADDR: |
4628 | if (ipv6_en) |
4629 | @@ -1930,20 +1930,20 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, |
4630 | block->target[idx].lun.value[0]); |
4631 | break; |
4632 | case ISCSI_BOOT_TGT_CHAP_NAME: |
4633 | - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", |
4634 | - chap_name); |
4635 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
4636 | + chap_name); |
4637 | break; |
4638 | case ISCSI_BOOT_TGT_CHAP_SECRET: |
4639 | - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", |
4640 | - chap_secret); |
4641 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
4642 | + chap_secret); |
4643 | break; |
4644 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: |
4645 | - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", |
4646 | - mchap_name); |
4647 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
4648 | + mchap_name); |
4649 | break; |
4650 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: |
4651 | - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", |
4652 | - mchap_secret); |
4653 | + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
4654 | + mchap_secret); |
4655 | break; |
4656 | case ISCSI_BOOT_TGT_FLAGS: |
4657 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); |
4658 | diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c |
4659 | index d95b879c2bca..13a00a42b3ca 100644 |
4660 | --- a/drivers/scsi/qla2xxx/qla_isr.c |
4661 | +++ b/drivers/scsi/qla2xxx/qla_isr.c |
4662 | @@ -272,7 +272,8 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
4663 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
4664 | |
4665 | /* Read all mbox registers? */ |
4666 | - mboxes = (1 << ha->mbx_count) - 1; |
4667 | + WARN_ON_ONCE(ha->mbx_count > 32); |
4668 | + mboxes = (1ULL << ha->mbx_count) - 1; |
4669 | if (!ha->mcp) |
4670 | ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); |
4671 | else |
4672 | @@ -2821,7 +2822,8 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
4673 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
4674 | |
4675 | /* Read all mbox registers? */ |
4676 | - mboxes = (1 << ha->mbx_count) - 1; |
4677 | + WARN_ON_ONCE(ha->mbx_count > 32); |
4678 | + mboxes = (1ULL << ha->mbx_count) - 1; |
4679 | if (!ha->mcp) |
4680 | ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); |
4681 | else |
4682 | diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c |
4683 | index 8e7c0626f8b5..1be76695e692 100644 |
4684 | --- a/drivers/scsi/qla2xxx/qla_os.c |
4685 | +++ b/drivers/scsi/qla2xxx/qla_os.c |
4686 | @@ -3581,6 +3581,8 @@ qla2x00_remove_one(struct pci_dev *pdev) |
4687 | } |
4688 | qla2x00_wait_for_hba_ready(base_vha); |
4689 | |
4690 | + qla2x00_wait_for_sess_deletion(base_vha); |
4691 | + |
4692 | /* |
4693 | * if UNLOAD flag is already set, then continue unload, |
4694 | * where it was set first. |
4695 | diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h |
4696 | index fc233717355f..817f312023a9 100644 |
4697 | --- a/drivers/scsi/qla4xxx/ql4_def.h |
4698 | +++ b/drivers/scsi/qla4xxx/ql4_def.h |
4699 | @@ -168,6 +168,8 @@ |
4700 | #define DEV_DB_NON_PERSISTENT 0 |
4701 | #define DEV_DB_PERSISTENT 1 |
4702 | |
4703 | +#define QL4_ISP_REG_DISCONNECT 0xffffffffU |
4704 | + |
4705 | #define COPY_ISID(dst_isid, src_isid) { \ |
4706 | int i, j; \ |
4707 | for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \ |
4708 | diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c |
4709 | index 64c6fa563fdb..a6aa08d9a171 100644 |
4710 | --- a/drivers/scsi/qla4xxx/ql4_os.c |
4711 | +++ b/drivers/scsi/qla4xxx/ql4_os.c |
4712 | @@ -262,6 +262,24 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { |
4713 | |
4714 | static struct scsi_transport_template *qla4xxx_scsi_transport; |
4715 | |
4716 | +static int qla4xxx_isp_check_reg(struct scsi_qla_host *ha) |
4717 | +{ |
4718 | + u32 reg_val = 0; |
4719 | + int rval = QLA_SUCCESS; |
4720 | + |
4721 | + if (is_qla8022(ha)) |
4722 | + reg_val = readl(&ha->qla4_82xx_reg->host_status); |
4723 | + else if (is_qla8032(ha) || is_qla8042(ha)) |
4724 | + reg_val = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_ALIVE_COUNTER); |
4725 | + else |
4726 | + reg_val = readw(&ha->reg->ctrl_status); |
4727 | + |
4728 | + if (reg_val == QL4_ISP_REG_DISCONNECT) |
4729 | + rval = QLA_ERROR; |
4730 | + |
4731 | + return rval; |
4732 | +} |
4733 | + |
4734 | static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num, |
4735 | uint32_t iface_type, uint32_t payload_size, |
4736 | uint32_t pid, struct sockaddr *dst_addr) |
4737 | @@ -9188,10 +9206,17 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd) |
4738 | struct srb *srb = NULL; |
4739 | int ret = SUCCESS; |
4740 | int wait = 0; |
4741 | + int rval; |
4742 | |
4743 | ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", |
4744 | ha->host_no, id, lun, cmd, cmd->cmnd[0]); |
4745 | |
4746 | + rval = qla4xxx_isp_check_reg(ha); |
4747 | + if (rval != QLA_SUCCESS) { |
4748 | + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); |
4749 | + return FAILED; |
4750 | + } |
4751 | + |
4752 | spin_lock_irqsave(&ha->hardware_lock, flags); |
4753 | srb = (struct srb *) CMD_SP(cmd); |
4754 | if (!srb) { |
4755 | @@ -9243,6 +9268,7 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) |
4756 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); |
4757 | struct ddb_entry *ddb_entry = cmd->device->hostdata; |
4758 | int ret = FAILED, stat; |
4759 | + int rval; |
4760 | |
4761 | if (!ddb_entry) |
4762 | return ret; |
4763 | @@ -9262,6 +9288,12 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) |
4764 | cmd, jiffies, cmd->request->timeout / HZ, |
4765 | ha->dpc_flags, cmd->result, cmd->allowed)); |
4766 | |
4767 | + rval = qla4xxx_isp_check_reg(ha); |
4768 | + if (rval != QLA_SUCCESS) { |
4769 | + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); |
4770 | + return FAILED; |
4771 | + } |
4772 | + |
4773 | /* FIXME: wait for hba to go online */ |
4774 | stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); |
4775 | if (stat != QLA_SUCCESS) { |
4776 | @@ -9305,6 +9337,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) |
4777 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); |
4778 | struct ddb_entry *ddb_entry = cmd->device->hostdata; |
4779 | int stat, ret; |
4780 | + int rval; |
4781 | |
4782 | if (!ddb_entry) |
4783 | return FAILED; |
4784 | @@ -9322,6 +9355,12 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) |
4785 | ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, |
4786 | ha->dpc_flags, cmd->result, cmd->allowed)); |
4787 | |
4788 | + rval = qla4xxx_isp_check_reg(ha); |
4789 | + if (rval != QLA_SUCCESS) { |
4790 | + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); |
4791 | + return FAILED; |
4792 | + } |
4793 | + |
4794 | stat = qla4xxx_reset_target(ha, ddb_entry); |
4795 | if (stat != QLA_SUCCESS) { |
4796 | starget_printk(KERN_INFO, scsi_target(cmd->device), |
4797 | @@ -9376,9 +9415,16 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd) |
4798 | { |
4799 | int return_status = FAILED; |
4800 | struct scsi_qla_host *ha; |
4801 | + int rval; |
4802 | |
4803 | ha = to_qla_host(cmd->device->host); |
4804 | |
4805 | + rval = qla4xxx_isp_check_reg(ha); |
4806 | + if (rval != QLA_SUCCESS) { |
4807 | + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); |
4808 | + return FAILED; |
4809 | + } |
4810 | + |
4811 | if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) |
4812 | qla4_83xx_set_idc_dontreset(ha); |
4813 | |
4814 | diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c |
4815 | index 359386730523..bfd8f12d4e9a 100644 |
4816 | --- a/drivers/scsi/scsi_lib.c |
4817 | +++ b/drivers/scsi/scsi_lib.c |
4818 | @@ -855,6 +855,17 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) |
4819 | /* for passthrough error may be set */ |
4820 | error = BLK_STS_OK; |
4821 | } |
4822 | + /* |
4823 | + * Another corner case: the SCSI status byte is non-zero but 'good'. |
4824 | + * Example: PRE-FETCH command returns SAM_STAT_CONDITION_MET when |
4825 | + * it is able to fit nominated LBs in its cache (and SAM_STAT_GOOD |
4826 | + * if it can't fit). Treat SAM_STAT_CONDITION_MET and the related |
4827 | + * intermediate statuses (both obsolete in SAM-4) as good. |
4828 | + */ |
4829 | + if (status_byte(result) && scsi_status_is_good(result)) { |
4830 | + result = 0; |
4831 | + error = BLK_STS_OK; |
4832 | + } |
4833 | |
4834 | /* |
4835 | * special case: failed zero length commands always need to |
4836 | diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c |
4837 | index 2f9912de2212..4a532318b211 100644 |
4838 | --- a/drivers/scsi/sd.c |
4839 | +++ b/drivers/scsi/sd.c |
4840 | @@ -2608,6 +2608,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) |
4841 | int res; |
4842 | struct scsi_device *sdp = sdkp->device; |
4843 | struct scsi_mode_data data; |
4844 | + int disk_ro = get_disk_ro(sdkp->disk); |
4845 | int old_wp = sdkp->write_prot; |
4846 | |
4847 | set_disk_ro(sdkp->disk, 0); |
4848 | @@ -2648,7 +2649,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) |
4849 | "Test WP failed, assume Write Enabled\n"); |
4850 | } else { |
4851 | sdkp->write_prot = ((data.device_specific & 0x80) != 0); |
4852 | - set_disk_ro(sdkp->disk, sdkp->write_prot); |
4853 | + set_disk_ro(sdkp->disk, sdkp->write_prot || disk_ro); |
4854 | if (sdkp->first_scan || old_wp != sdkp->write_prot) { |
4855 | sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", |
4856 | sdkp->write_prot ? "on" : "off"); |
4857 | diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c |
4858 | index aa28874e8fb9..17a4cc138b00 100644 |
4859 | --- a/drivers/scsi/sg.c |
4860 | +++ b/drivers/scsi/sg.c |
4861 | @@ -1894,7 +1894,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) |
4862 | num = (rem_sz > scatter_elem_sz_prev) ? |
4863 | scatter_elem_sz_prev : rem_sz; |
4864 | |
4865 | - schp->pages[k] = alloc_pages(gfp_mask, order); |
4866 | + schp->pages[k] = alloc_pages(gfp_mask | __GFP_ZERO, order); |
4867 | if (!schp->pages[k]) |
4868 | goto out; |
4869 | |
4870 | diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c |
4871 | index a3e480e7a257..c44de0b4a995 100644 |
4872 | --- a/drivers/scsi/storvsc_drv.c |
4873 | +++ b/drivers/scsi/storvsc_drv.c |
4874 | @@ -1661,7 +1661,7 @@ static struct scsi_host_template scsi_driver = { |
4875 | .eh_timed_out = storvsc_eh_timed_out, |
4876 | .slave_alloc = storvsc_device_alloc, |
4877 | .slave_configure = storvsc_device_configure, |
4878 | - .cmd_per_lun = 255, |
4879 | + .cmd_per_lun = 2048, |
4880 | .this_id = -1, |
4881 | .use_clustering = ENABLE_CLUSTERING, |
4882 | /* Make sure we dont get a sg segment crosses a page boundary */ |
4883 | diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c |
4884 | index ca360daa6a25..378af306fda1 100644 |
4885 | --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c |
4886 | +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c |
4887 | @@ -536,7 +536,7 @@ sym_getsync(struct sym_hcb *np, u_char dt, u_char sfac, u_char *divp, u_char *fa |
4888 | * Look for the greatest clock divisor that allows an |
4889 | * input speed faster than the period. |
4890 | */ |
4891 | - while (div-- > 0) |
4892 | + while (--div > 0) |
4893 | if (kpc >= (div_10M[div] << 2)) break; |
4894 | |
4895 | /* |
4896 | diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c |
4897 | index d344fef01f1d..3bb1f6cc297a 100644 |
4898 | --- a/drivers/scsi/ufs/ufshcd.c |
4899 | +++ b/drivers/scsi/ufs/ufshcd.c |
4900 | @@ -4347,6 +4347,8 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) |
4901 | /* REPORT SUPPORTED OPERATION CODES is not supported */ |
4902 | sdev->no_report_opcodes = 1; |
4903 | |
4904 | + /* WRITE_SAME command is not supported */ |
4905 | + sdev->no_write_same = 1; |
4906 | |
4907 | ufshcd_set_queue_depth(sdev); |
4908 | |
4909 | diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |
4910 | index 8e84b2e7f5bd..b83d17db06bd 100644 |
4911 | --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |
4912 | +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |
4913 | @@ -315,7 +315,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch) |
4914 | } |
4915 | |
4916 | fd = dpaa2_dq_fd(dq); |
4917 | - fq = (struct dpaa2_eth_fq *)dpaa2_dq_fqd_ctx(dq); |
4918 | + fq = (struct dpaa2_eth_fq *)(uintptr_t)dpaa2_dq_fqd_ctx(dq); |
4919 | fq->stats.frames++; |
4920 | |
4921 | fq->consume(priv, ch, fd, &ch->napi); |
4922 | @@ -1888,7 +1888,7 @@ static int setup_rx_flow(struct dpaa2_eth_priv *priv, |
4923 | queue.destination.id = fq->channel->dpcon_id; |
4924 | queue.destination.type = DPNI_DEST_DPCON; |
4925 | queue.destination.priority = 1; |
4926 | - queue.user_context = (u64)fq; |
4927 | + queue.user_context = (u64)(uintptr_t)fq; |
4928 | err = dpni_set_queue(priv->mc_io, 0, priv->mc_token, |
4929 | DPNI_QUEUE_RX, 0, fq->flowid, |
4930 | DPNI_QUEUE_OPT_USER_CTX | DPNI_QUEUE_OPT_DEST, |
4931 | @@ -1940,7 +1940,7 @@ static int setup_tx_flow(struct dpaa2_eth_priv *priv, |
4932 | queue.destination.id = fq->channel->dpcon_id; |
4933 | queue.destination.type = DPNI_DEST_DPCON; |
4934 | queue.destination.priority = 0; |
4935 | - queue.user_context = (u64)fq; |
4936 | + queue.user_context = (u64)(uintptr_t)fq; |
4937 | err = dpni_set_queue(priv->mc_io, 0, priv->mc_token, |
4938 | DPNI_QUEUE_TX_CONFIRM, 0, fq->flowid, |
4939 | DPNI_QUEUE_OPT_USER_CTX | DPNI_QUEUE_OPT_DEST, |
4940 | diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c |
4941 | index 975dbbb3abd0..7da3eb4ca4be 100644 |
4942 | --- a/drivers/staging/ks7010/ks_hostif.c |
4943 | +++ b/drivers/staging/ks7010/ks_hostif.c |
4944 | @@ -242,9 +242,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, |
4945 | offset = 0; |
4946 | |
4947 | while (bsize > offset) { |
4948 | - /* DPRINTK(4, "Element ID=%d\n",*bp); */ |
4949 | - switch (*bp) { |
4950 | - case 0: /* ssid */ |
4951 | + switch (*bp) { /* Information Element ID */ |
4952 | + case WLAN_EID_SSID: |
4953 | if (*(bp + 1) <= SSID_MAX_SIZE) { |
4954 | ap->ssid.size = *(bp + 1); |
4955 | } else { |
4956 | @@ -254,8 +253,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, |
4957 | } |
4958 | memcpy(ap->ssid.body, bp + 2, ap->ssid.size); |
4959 | break; |
4960 | - case 1: /* rate */ |
4961 | - case 50: /* ext rate */ |
4962 | + case WLAN_EID_SUPP_RATES: |
4963 | + case WLAN_EID_EXT_SUPP_RATES: |
4964 | if ((*(bp + 1) + ap->rate_set.size) <= |
4965 | RATE_SET_MAX_SIZE) { |
4966 | memcpy(&ap->rate_set.body[ap->rate_set.size], |
4967 | @@ -271,9 +270,9 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, |
4968 | (RATE_SET_MAX_SIZE - ap->rate_set.size); |
4969 | } |
4970 | break; |
4971 | - case 3: /* DS parameter */ |
4972 | + case WLAN_EID_DS_PARAMS: |
4973 | break; |
4974 | - case 48: /* RSN(WPA2) */ |
4975 | + case WLAN_EID_RSN: |
4976 | ap->rsn_ie.id = *bp; |
4977 | if (*(bp + 1) <= RSN_IE_BODY_MAX) { |
4978 | ap->rsn_ie.size = *(bp + 1); |
4979 | @@ -284,8 +283,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, |
4980 | } |
4981 | memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size); |
4982 | break; |
4983 | - case 221: /* WPA */ |
4984 | - if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */ |
4985 | + case WLAN_EID_VENDOR_SPECIFIC: /* WPA */ |
4986 | + if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */ |
4987 | ap->wpa_ie.id = *bp; |
4988 | if (*(bp + 1) <= RSN_IE_BODY_MAX) { |
4989 | ap->wpa_ie.size = *(bp + 1); |
4990 | @@ -300,18 +299,18 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, |
4991 | } |
4992 | break; |
4993 | |
4994 | - case 2: /* FH parameter */ |
4995 | - case 4: /* CF parameter */ |
4996 | - case 5: /* TIM */ |
4997 | - case 6: /* IBSS parameter */ |
4998 | - case 7: /* Country */ |
4999 | - case 42: /* ERP information */ |
5000 | - case 47: /* Reserve ID 47 Broadcom AP */ |
5001 | + case WLAN_EID_FH_PARAMS: |
5002 | + case WLAN_EID_CF_PARAMS: |
5003 | + case WLAN_EID_TIM: |
5004 | + case WLAN_EID_IBSS_PARAMS: |
5005 | + case WLAN_EID_COUNTRY: |
5006 | + case WLAN_EID_ERP_INFO: |
5007 | break; |
5008 | default: |
5009 | DPRINTK(4, "unknown Element ID=%d\n", *bp); |
5010 | break; |
5011 | } |
5012 | + |
5013 | offset += 2; /* id & size field */ |
5014 | offset += *(bp + 1); /* +size offset */ |
5015 | bp += (*(bp + 1) + 2); /* pointer update */ |
5016 | diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h |
5017 | index 5bae8d468e23..9ac317e4b507 100644 |
5018 | --- a/drivers/staging/ks7010/ks_hostif.h |
5019 | +++ b/drivers/staging/ks7010/ks_hostif.h |
5020 | @@ -13,6 +13,7 @@ |
5021 | #define _KS_HOSTIF_H_ |
5022 | |
5023 | #include <linux/compiler.h> |
5024 | +#include <linux/ieee80211.h> |
5025 | |
5026 | /* |
5027 | * HOST-MAC I/F events |
5028 | diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h |
5029 | index a986737ec010..82a499fb23bb 100644 |
5030 | --- a/drivers/staging/lustre/lustre/include/obd.h |
5031 | +++ b/drivers/staging/lustre/lustre/include/obd.h |
5032 | @@ -190,7 +190,7 @@ struct client_obd { |
5033 | struct sptlrpc_flavor cl_flvr_mgc; /* fixed flavor of mgc->mgs */ |
5034 | |
5035 | /* the grant values are protected by loi_list_lock below */ |
5036 | - unsigned long cl_dirty_pages; /* all _dirty_ in pahges */ |
5037 | + unsigned long cl_dirty_pages; /* all _dirty_ in pages */ |
5038 | unsigned long cl_dirty_max_pages; /* allowed w/o rpc */ |
5039 | unsigned long cl_dirty_transit; /* dirty synchronous */ |
5040 | unsigned long cl_avail_grant; /* bytes of credit for ost */ |
5041 | diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c |
5042 | index 6e16c930a021..c2aadb2d1fea 100644 |
5043 | --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c |
5044 | +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c |
5045 | @@ -2694,7 +2694,7 @@ static int lmv_unpackmd(struct obd_export *exp, struct lmv_stripe_md **lsmp, |
5046 | if (lsm && !lmm) { |
5047 | int i; |
5048 | |
5049 | - for (i = 1; i < lsm->lsm_md_stripe_count; i++) { |
5050 | + for (i = 0; i < lsm->lsm_md_stripe_count; i++) { |
5051 | /* |
5052 | * For migrating inode, the master stripe and master |
5053 | * object will be the same, so do not need iput, see |
5054 | diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c |
5055 | index e1207c227b79..c356d00d87a5 100644 |
5056 | --- a/drivers/staging/lustre/lustre/osc/osc_cache.c |
5057 | +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c |
5058 | @@ -1528,7 +1528,7 @@ static int osc_enter_cache_try(struct client_obd *cli, |
5059 | if (rc < 0) |
5060 | return 0; |
5061 | |
5062 | - if (cli->cl_dirty_pages <= cli->cl_dirty_max_pages && |
5063 | + if (cli->cl_dirty_pages < cli->cl_dirty_max_pages && |
5064 | atomic_long_read(&obd_dirty_pages) + 1 <= obd_max_dirty_pages) { |
5065 | osc_consume_write_grant(cli, &oap->oap_brw_page); |
5066 | if (transient) { |
5067 | diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c |
5068 | index 46b3f19e0878..db3eb7ec5809 100644 |
5069 | --- a/drivers/staging/rtl8192u/r8192U_core.c |
5070 | +++ b/drivers/staging/rtl8192u/r8192U_core.c |
5071 | @@ -1702,6 +1702,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) |
5072 | |
5073 | priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL); |
5074 | priv->oldaddr = kmalloc(16, GFP_KERNEL); |
5075 | + if (!priv->oldaddr) |
5076 | + return -ENOMEM; |
5077 | oldaddr = priv->oldaddr; |
5078 | align = ((long)oldaddr) & 3; |
5079 | if (align) { |
5080 | diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c |
5081 | index 8f2d508183b2..9030d71a3d0b 100644 |
5082 | --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c |
5083 | +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c |
5084 | @@ -36,6 +36,10 @@ MODULE_PARM_DESC(enable_compat_alsa, |
5085 | static void snd_devm_unregister_child(struct device *dev, void *res) |
5086 | { |
5087 | struct device *childdev = *(struct device **)res; |
5088 | + struct bcm2835_chip *chip = dev_get_drvdata(childdev); |
5089 | + struct snd_card *card = chip->card; |
5090 | + |
5091 | + snd_card_free(card); |
5092 | |
5093 | device_unregister(childdev); |
5094 | } |
5095 | @@ -61,6 +65,13 @@ static int snd_devm_add_child(struct device *dev, struct device *child) |
5096 | return 0; |
5097 | } |
5098 | |
5099 | +static void snd_bcm2835_release(struct device *dev) |
5100 | +{ |
5101 | + struct bcm2835_chip *chip = dev_get_drvdata(dev); |
5102 | + |
5103 | + kfree(chip); |
5104 | +} |
5105 | + |
5106 | static struct device * |
5107 | snd_create_device(struct device *parent, |
5108 | struct device_driver *driver, |
5109 | @@ -76,6 +87,7 @@ snd_create_device(struct device *parent, |
5110 | device_initialize(device); |
5111 | device->parent = parent; |
5112 | device->driver = driver; |
5113 | + device->release = snd_bcm2835_release; |
5114 | |
5115 | dev_set_name(device, "%s", name); |
5116 | |
5117 | @@ -86,18 +98,19 @@ snd_create_device(struct device *parent, |
5118 | return device; |
5119 | } |
5120 | |
5121 | -static int snd_bcm2835_free(struct bcm2835_chip *chip) |
5122 | -{ |
5123 | - kfree(chip); |
5124 | - return 0; |
5125 | -} |
5126 | - |
5127 | /* component-destructor |
5128 | * (see "Management of Cards and Components") |
5129 | */ |
5130 | static int snd_bcm2835_dev_free(struct snd_device *device) |
5131 | { |
5132 | - return snd_bcm2835_free(device->device_data); |
5133 | + struct bcm2835_chip *chip = device->device_data; |
5134 | + struct snd_card *card = chip->card; |
5135 | + |
5136 | + /* TODO: free pcm, ctl */ |
5137 | + |
5138 | + snd_device_free(card, chip); |
5139 | + |
5140 | + return 0; |
5141 | } |
5142 | |
5143 | /* chip-specific constructor |
5144 | @@ -122,7 +135,7 @@ static int snd_bcm2835_create(struct snd_card *card, |
5145 | |
5146 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
5147 | if (err) { |
5148 | - snd_bcm2835_free(chip); |
5149 | + kfree(chip); |
5150 | return err; |
5151 | } |
5152 | |
5153 | @@ -130,31 +143,14 @@ static int snd_bcm2835_create(struct snd_card *card, |
5154 | return 0; |
5155 | } |
5156 | |
5157 | -static void snd_devm_card_free(struct device *dev, void *res) |
5158 | +static struct snd_card *snd_bcm2835_card_new(struct device *dev) |
5159 | { |
5160 | - struct snd_card *snd_card = *(struct snd_card **)res; |
5161 | - |
5162 | - snd_card_free(snd_card); |
5163 | -} |
5164 | - |
5165 | -static struct snd_card *snd_devm_card_new(struct device *dev) |
5166 | -{ |
5167 | - struct snd_card **dr; |
5168 | struct snd_card *card; |
5169 | int ret; |
5170 | |
5171 | - dr = devres_alloc(snd_devm_card_free, sizeof(*dr), GFP_KERNEL); |
5172 | - if (!dr) |
5173 | - return ERR_PTR(-ENOMEM); |
5174 | - |
5175 | ret = snd_card_new(dev, -1, NULL, THIS_MODULE, 0, &card); |
5176 | - if (ret) { |
5177 | - devres_free(dr); |
5178 | + if (ret) |
5179 | return ERR_PTR(ret); |
5180 | - } |
5181 | - |
5182 | - *dr = card; |
5183 | - devres_add(dev, dr); |
5184 | |
5185 | return card; |
5186 | } |
5187 | @@ -271,7 +267,7 @@ static int snd_add_child_device(struct device *device, |
5188 | return PTR_ERR(child); |
5189 | } |
5190 | |
5191 | - card = snd_devm_card_new(child); |
5192 | + card = snd_bcm2835_card_new(child); |
5193 | if (IS_ERR(card)) { |
5194 | dev_err(child, "Failed to create card"); |
5195 | return PTR_ERR(card); |
5196 | @@ -313,7 +309,7 @@ static int snd_add_child_device(struct device *device, |
5197 | return err; |
5198 | } |
5199 | |
5200 | - dev_set_drvdata(child, card); |
5201 | + dev_set_drvdata(child, chip); |
5202 | dev_info(child, "card created with %d channels\n", numchans); |
5203 | |
5204 | return 0; |
5205 | diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c |
5206 | index e32c51d549c3..be456ea27ab2 100644 |
5207 | --- a/drivers/tty/serial/8250/8250_port.c |
5208 | +++ b/drivers/tty/serial/8250/8250_port.c |
5209 | @@ -1874,7 +1874,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) |
5210 | |
5211 | status = serial_port_in(port, UART_LSR); |
5212 | |
5213 | - if (status & (UART_LSR_DR | UART_LSR_BI)) { |
5214 | + if (status & (UART_LSR_DR | UART_LSR_BI) && |
5215 | + iir & UART_IIR_RDI) { |
5216 | if (!up->dma || handle_rx_dma(up, iir)) |
5217 | status = serial8250_rx_chars(up, status); |
5218 | } |
5219 | diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c |
5220 | index 3e4b717670d7..59cb62de236b 100644 |
5221 | --- a/drivers/tty/serial/altera_uart.c |
5222 | +++ b/drivers/tty/serial/altera_uart.c |
5223 | @@ -331,7 +331,7 @@ static int altera_uart_startup(struct uart_port *port) |
5224 | |
5225 | /* Enable RX interrupts now */ |
5226 | pp->imr = ALTERA_UART_CONTROL_RRDY_MSK; |
5227 | - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); |
5228 | + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); |
5229 | |
5230 | spin_unlock_irqrestore(&port->lock, flags); |
5231 | |
5232 | @@ -347,7 +347,7 @@ static void altera_uart_shutdown(struct uart_port *port) |
5233 | |
5234 | /* Disable all interrupts now */ |
5235 | pp->imr = 0; |
5236 | - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); |
5237 | + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); |
5238 | |
5239 | spin_unlock_irqrestore(&port->lock, flags); |
5240 | |
5241 | @@ -436,7 +436,7 @@ static void altera_uart_console_putc(struct uart_port *port, int c) |
5242 | ALTERA_UART_STATUS_TRDY_MSK)) |
5243 | cpu_relax(); |
5244 | |
5245 | - writel(c, port->membase + ALTERA_UART_TXDATA_REG); |
5246 | + altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); |
5247 | } |
5248 | |
5249 | static void altera_uart_console_write(struct console *co, const char *s, |
5250 | @@ -506,13 +506,13 @@ static int __init altera_uart_earlycon_setup(struct earlycon_device *dev, |
5251 | return -ENODEV; |
5252 | |
5253 | /* Enable RX interrupts now */ |
5254 | - writel(ALTERA_UART_CONTROL_RRDY_MSK, |
5255 | - port->membase + ALTERA_UART_CONTROL_REG); |
5256 | + altera_uart_writel(port, ALTERA_UART_CONTROL_RRDY_MSK, |
5257 | + ALTERA_UART_CONTROL_REG); |
5258 | |
5259 | if (dev->baud) { |
5260 | unsigned int baudclk = port->uartclk / dev->baud; |
5261 | |
5262 | - writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG); |
5263 | + altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); |
5264 | } |
5265 | |
5266 | dev->con->write = altera_uart_earlycon_write; |
5267 | diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c |
5268 | index 77fe306690c4..71e37abb6bcb 100644 |
5269 | --- a/drivers/tty/serial/arc_uart.c |
5270 | +++ b/drivers/tty/serial/arc_uart.c |
5271 | @@ -596,6 +596,11 @@ static int arc_serial_probe(struct platform_device *pdev) |
5272 | if (dev_id < 0) |
5273 | dev_id = 0; |
5274 | |
5275 | + if (dev_id >= ARRAY_SIZE(arc_uart_ports)) { |
5276 | + dev_err(&pdev->dev, "serial%d out of range\n", dev_id); |
5277 | + return -EINVAL; |
5278 | + } |
5279 | + |
5280 | uart = &arc_uart_ports[dev_id]; |
5281 | port = &uart->port; |
5282 | |
5283 | diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c |
5284 | index f0252184291e..7a3db9378fa3 100644 |
5285 | --- a/drivers/tty/serial/fsl_lpuart.c |
5286 | +++ b/drivers/tty/serial/fsl_lpuart.c |
5287 | @@ -2151,6 +2151,10 @@ static int lpuart_probe(struct platform_device *pdev) |
5288 | dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); |
5289 | return ret; |
5290 | } |
5291 | + if (ret >= ARRAY_SIZE(lpuart_ports)) { |
5292 | + dev_err(&pdev->dev, "serial%d out of range\n", ret); |
5293 | + return -EINVAL; |
5294 | + } |
5295 | sport->port.line = ret; |
5296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
5297 | sport->port.membase = devm_ioremap_resource(&pdev->dev, res); |
5298 | diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c |
5299 | index 521500c575c8..8deaf2ad8b34 100644 |
5300 | --- a/drivers/tty/serial/imx.c |
5301 | +++ b/drivers/tty/serial/imx.c |
5302 | @@ -2096,6 +2096,12 @@ static int serial_imx_probe(struct platform_device *pdev) |
5303 | else if (ret < 0) |
5304 | return ret; |
5305 | |
5306 | + if (sport->port.line >= ARRAY_SIZE(imx_ports)) { |
5307 | + dev_err(&pdev->dev, "serial%d out of range\n", |
5308 | + sport->port.line); |
5309 | + return -EINVAL; |
5310 | + } |
5311 | + |
5312 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
5313 | base = devm_ioremap_resource(&pdev->dev, res); |
5314 | if (IS_ERR(base)) |
5315 | diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c |
5316 | index be94246b6fcc..673c8fd7e34f 100644 |
5317 | --- a/drivers/tty/serial/mxs-auart.c |
5318 | +++ b/drivers/tty/serial/mxs-auart.c |
5319 | @@ -1667,6 +1667,10 @@ static int mxs_auart_probe(struct platform_device *pdev) |
5320 | s->port.line = pdev->id < 0 ? 0 : pdev->id; |
5321 | else if (ret < 0) |
5322 | return ret; |
5323 | + if (s->port.line >= ARRAY_SIZE(auart_port)) { |
5324 | + dev_err(&pdev->dev, "serial%d out of range\n", s->port.line); |
5325 | + return -EINVAL; |
5326 | + } |
5327 | |
5328 | if (of_id) { |
5329 | pdev->id_entry = of_id->data; |
5330 | diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c |
5331 | index 8aca18c4cdea..bedd4bdec4ab 100644 |
5332 | --- a/drivers/tty/serial/samsung.c |
5333 | +++ b/drivers/tty/serial/samsung.c |
5334 | @@ -1821,6 +1821,10 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) |
5335 | |
5336 | dbg("s3c24xx_serial_probe(%p) %d\n", pdev, index); |
5337 | |
5338 | + if (index >= ARRAY_SIZE(s3c24xx_serial_ports)) { |
5339 | + dev_err(&pdev->dev, "serial%d out of range\n", index); |
5340 | + return -EINVAL; |
5341 | + } |
5342 | ourport = &s3c24xx_serial_ports[index]; |
5343 | |
5344 | ourport->drv_data = s3c24xx_get_driver_data(pdev); |
5345 | diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c |
5346 | index 22f60239026c..8a58ee32ff61 100644 |
5347 | --- a/drivers/tty/serial/sh-sci.c |
5348 | +++ b/drivers/tty/serial/sh-sci.c |
5349 | @@ -3076,6 +3076,10 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev, |
5350 | dev_err(&pdev->dev, "failed to get alias id (%d)\n", id); |
5351 | return NULL; |
5352 | } |
5353 | + if (id >= ARRAY_SIZE(sci_ports)) { |
5354 | + dev_err(&pdev->dev, "serial%d out of range\n", id); |
5355 | + return NULL; |
5356 | + } |
5357 | |
5358 | sp = &sci_ports[id]; |
5359 | *dev_id = id; |
5360 | diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c |
5361 | index 31a630ae0870..21c35ad72b99 100644 |
5362 | --- a/drivers/tty/serial/xilinx_uartps.c |
5363 | +++ b/drivers/tty/serial/xilinx_uartps.c |
5364 | @@ -1115,7 +1115,7 @@ static struct uart_port *cdns_uart_get_port(int id) |
5365 | struct uart_port *port; |
5366 | |
5367 | /* Try the given port id if failed use default method */ |
5368 | - if (cdns_uart_port[id].mapbase != 0) { |
5369 | + if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) { |
5370 | /* Find the next unused port */ |
5371 | for (id = 0; id < CDNS_UART_NR_PORTS; id++) |
5372 | if (cdns_uart_port[id].mapbase == 0) |
5373 | diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
5374 | index 4149a965516e..22952d70b981 100644 |
5375 | --- a/drivers/usb/class/cdc-acm.c |
5376 | +++ b/drivers/usb/class/cdc-acm.c |
5377 | @@ -187,6 +187,7 @@ static int acm_wb_alloc(struct acm *acm) |
5378 | wb = &acm->wb[wbn]; |
5379 | if (!wb->use) { |
5380 | wb->use = 1; |
5381 | + wb->len = 0; |
5382 | return wbn; |
5383 | } |
5384 | wbn = (wbn + 1) % ACM_NW; |
5385 | @@ -818,16 +819,18 @@ static int acm_tty_write(struct tty_struct *tty, |
5386 | static void acm_tty_flush_chars(struct tty_struct *tty) |
5387 | { |
5388 | struct acm *acm = tty->driver_data; |
5389 | - struct acm_wb *cur = acm->putbuffer; |
5390 | + struct acm_wb *cur; |
5391 | int err; |
5392 | unsigned long flags; |
5393 | |
5394 | + spin_lock_irqsave(&acm->write_lock, flags); |
5395 | + |
5396 | + cur = acm->putbuffer; |
5397 | if (!cur) /* nothing to do */ |
5398 | - return; |
5399 | + goto out; |
5400 | |
5401 | acm->putbuffer = NULL; |
5402 | err = usb_autopm_get_interface_async(acm->control); |
5403 | - spin_lock_irqsave(&acm->write_lock, flags); |
5404 | if (err < 0) { |
5405 | cur->use = 0; |
5406 | acm->putbuffer = cur; |
5407 | diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h |
5408 | index 8367d4f985c1..ec965ac5f1f5 100644 |
5409 | --- a/drivers/usb/dwc2/core.h |
5410 | +++ b/drivers/usb/dwc2/core.h |
5411 | @@ -216,7 +216,7 @@ struct dwc2_hsotg_ep { |
5412 | unsigned char dir_in; |
5413 | unsigned char index; |
5414 | unsigned char mc; |
5415 | - unsigned char interval; |
5416 | + u16 interval; |
5417 | |
5418 | unsigned int halted:1; |
5419 | unsigned int periodic:1; |
5420 | diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c |
5421 | index 0d8e09ccb59c..6ef001a83fe2 100644 |
5422 | --- a/drivers/usb/dwc2/gadget.c |
5423 | +++ b/drivers/usb/dwc2/gadget.c |
5424 | @@ -3414,12 +3414,6 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, |
5425 | dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | |
5426 | DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0); |
5427 | |
5428 | - dwc2_hsotg_enqueue_setup(hsotg); |
5429 | - |
5430 | - dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", |
5431 | - dwc2_readl(hsotg->regs + DIEPCTL0), |
5432 | - dwc2_readl(hsotg->regs + DOEPCTL0)); |
5433 | - |
5434 | /* clear global NAKs */ |
5435 | val = DCTL_CGOUTNAK | DCTL_CGNPINNAK; |
5436 | if (!is_usb_reset) |
5437 | @@ -3430,6 +3424,12 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, |
5438 | mdelay(3); |
5439 | |
5440 | hsotg->lx_state = DWC2_L0; |
5441 | + |
5442 | + dwc2_hsotg_enqueue_setup(hsotg); |
5443 | + |
5444 | + dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", |
5445 | + dwc2_readl(hsotg->regs + DIEPCTL0), |
5446 | + dwc2_readl(hsotg->regs + DOEPCTL0)); |
5447 | } |
5448 | |
5449 | static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) |
5450 | diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c |
5451 | index 9bd60ec83ac6..87484f71b2ab 100644 |
5452 | --- a/drivers/usb/dwc2/hcd.c |
5453 | +++ b/drivers/usb/dwc2/hcd.c |
5454 | @@ -979,6 +979,24 @@ void dwc2_hc_halt(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan, |
5455 | |
5456 | if (dbg_hc(chan)) |
5457 | dev_vdbg(hsotg->dev, "%s()\n", __func__); |
5458 | + |
5459 | + /* |
5460 | + * In buffer DMA or external DMA mode channel can't be halted |
5461 | + * for non-split periodic channels. At the end of the next |
5462 | + * uframe/frame (in the worst case), the core generates a channel |
5463 | + * halted and disables the channel automatically. |
5464 | + */ |
5465 | + if ((hsotg->params.g_dma && !hsotg->params.g_dma_desc) || |
5466 | + hsotg->hw_params.arch == GHWCFG2_EXT_DMA_ARCH) { |
5467 | + if (!chan->do_split && |
5468 | + (chan->ep_type == USB_ENDPOINT_XFER_ISOC || |
5469 | + chan->ep_type == USB_ENDPOINT_XFER_INT)) { |
5470 | + dev_err(hsotg->dev, "%s() Channel can't be halted\n", |
5471 | + __func__); |
5472 | + return; |
5473 | + } |
5474 | + } |
5475 | + |
5476 | if (halt_status == DWC2_HC_XFER_NO_HALT_STATUS) |
5477 | dev_err(hsotg->dev, "!!! halt_status = %d !!!\n", halt_status); |
5478 | |
5479 | @@ -2311,10 +2329,22 @@ static int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup) |
5480 | */ |
5481 | static void dwc2_core_host_init(struct dwc2_hsotg *hsotg) |
5482 | { |
5483 | - u32 hcfg, hfir, otgctl; |
5484 | + u32 hcfg, hfir, otgctl, usbcfg; |
5485 | |
5486 | dev_dbg(hsotg->dev, "%s(%p)\n", __func__, hsotg); |
5487 | |
5488 | + /* Set HS/FS Timeout Calibration to 7 (max available value). |
5489 | + * The number of PHY clocks that the application programs in |
5490 | + * this field is added to the high/full speed interpacket timeout |
5491 | + * duration in the core to account for any additional delays |
5492 | + * introduced by the PHY. This can be required, because the delay |
5493 | + * introduced by the PHY in generating the linestate condition |
5494 | + * can vary from one PHY to another. |
5495 | + */ |
5496 | + usbcfg = dwc2_readl(hsotg->regs + GUSBCFG); |
5497 | + usbcfg |= GUSBCFG_TOUTCAL(7); |
5498 | + dwc2_writel(usbcfg, hsotg->regs + GUSBCFG); |
5499 | + |
5500 | /* Restart the Phy Clock */ |
5501 | dwc2_writel(0, hsotg->regs + PCGCTL); |
5502 | |
5503 | diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile |
5504 | index 7ac725038f8d..025bc68094fc 100644 |
5505 | --- a/drivers/usb/dwc3/Makefile |
5506 | +++ b/drivers/usb/dwc3/Makefile |
5507 | @@ -6,7 +6,7 @@ obj-$(CONFIG_USB_DWC3) += dwc3.o |
5508 | |
5509 | dwc3-y := core.o |
5510 | |
5511 | -ifneq ($(CONFIG_FTRACE),) |
5512 | +ifneq ($(CONFIG_TRACING),) |
5513 | dwc3-y += trace.o |
5514 | endif |
5515 | |
5516 | diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c |
5517 | index c3f3f1a89b0f..dca78bb20e5d 100644 |
5518 | --- a/drivers/usb/dwc3/core.c |
5519 | +++ b/drivers/usb/dwc3/core.c |
5520 | @@ -243,12 +243,26 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) |
5521 | do { |
5522 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
5523 | if (!(reg & DWC3_DCTL_CSFTRST)) |
5524 | - return 0; |
5525 | + goto done; |
5526 | |
5527 | udelay(1); |
5528 | } while (--retries); |
5529 | |
5530 | + phy_exit(dwc->usb3_generic_phy); |
5531 | + phy_exit(dwc->usb2_generic_phy); |
5532 | + |
5533 | return -ETIMEDOUT; |
5534 | + |
5535 | +done: |
5536 | + /* |
5537 | + * For DWC_usb31 controller, once DWC3_DCTL_CSFTRST bit is cleared, |
5538 | + * we must wait at least 50ms before accessing the PHY domain |
5539 | + * (synchronization delay). DWC_usb31 programming guide section 1.3.2. |
5540 | + */ |
5541 | + if (dwc3_is_usb31(dwc)) |
5542 | + msleep(50); |
5543 | + |
5544 | + return 0; |
5545 | } |
5546 | |
5547 | /* |
5548 | diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h |
5549 | index fc28819253f7..b782ba58a7fc 100644 |
5550 | --- a/drivers/usb/dwc3/core.h |
5551 | +++ b/drivers/usb/dwc3/core.h |
5552 | @@ -249,6 +249,8 @@ |
5553 | #define DWC3_GUSB3PIPECTL_TX_DEEPH(n) ((n) << 1) |
5554 | |
5555 | /* Global TX Fifo Size Register */ |
5556 | +#define DWC31_GTXFIFOSIZ_TXFRAMNUM BIT(15) /* DWC_usb31 only */ |
5557 | +#define DWC31_GTXFIFOSIZ_TXFDEF(n) ((n) & 0x7fff) /* DWC_usb31 only */ |
5558 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) |
5559 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) |
5560 | |
5561 | diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c |
5562 | index 3530795bbb8f..fdd0d5aa1f5e 100644 |
5563 | --- a/drivers/usb/dwc3/dwc3-omap.c |
5564 | +++ b/drivers/usb/dwc3/dwc3-omap.c |
5565 | @@ -590,9 +590,25 @@ static int dwc3_omap_resume(struct device *dev) |
5566 | return 0; |
5567 | } |
5568 | |
5569 | +static void dwc3_omap_complete(struct device *dev) |
5570 | +{ |
5571 | + struct dwc3_omap *omap = dev_get_drvdata(dev); |
5572 | + |
5573 | + if (extcon_get_state(omap->edev, EXTCON_USB)) |
5574 | + dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); |
5575 | + else |
5576 | + dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); |
5577 | + |
5578 | + if (extcon_get_state(omap->edev, EXTCON_USB_HOST)) |
5579 | + dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); |
5580 | + else |
5581 | + dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); |
5582 | +} |
5583 | + |
5584 | static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { |
5585 | |
5586 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) |
5587 | + .complete = dwc3_omap_complete, |
5588 | }; |
5589 | |
5590 | #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops) |
5591 | diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c |
5592 | index ed9346f0b000..940de04ed72a 100644 |
5593 | --- a/drivers/usb/gadget/composite.c |
5594 | +++ b/drivers/usb/gadget/composite.c |
5595 | @@ -1425,7 +1425,7 @@ static int count_ext_compat(struct usb_configuration *c) |
5596 | return res; |
5597 | } |
5598 | |
5599 | -static void fill_ext_compat(struct usb_configuration *c, u8 *buf) |
5600 | +static int fill_ext_compat(struct usb_configuration *c, u8 *buf) |
5601 | { |
5602 | int i, count; |
5603 | |
5604 | @@ -1452,10 +1452,12 @@ static void fill_ext_compat(struct usb_configuration *c, u8 *buf) |
5605 | buf += 23; |
5606 | } |
5607 | count += 24; |
5608 | - if (count >= 4096) |
5609 | - return; |
5610 | + if (count + 24 >= USB_COMP_EP0_OS_DESC_BUFSIZ) |
5611 | + return count; |
5612 | } |
5613 | } |
5614 | + |
5615 | + return count; |
5616 | } |
5617 | |
5618 | static int count_ext_prop(struct usb_configuration *c, int interface) |
5619 | @@ -1500,25 +1502,20 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf) |
5620 | struct usb_os_desc *d; |
5621 | struct usb_os_desc_ext_prop *ext_prop; |
5622 | int j, count, n, ret; |
5623 | - u8 *start = buf; |
5624 | |
5625 | f = c->interface[interface]; |
5626 | + count = 10; /* header length */ |
5627 | for (j = 0; j < f->os_desc_n; ++j) { |
5628 | if (interface != f->os_desc_table[j].if_id) |
5629 | continue; |
5630 | d = f->os_desc_table[j].os_desc; |
5631 | if (d) |
5632 | list_for_each_entry(ext_prop, &d->ext_prop, entry) { |
5633 | - /* 4kB minus header length */ |
5634 | - n = buf - start; |
5635 | - if (n >= 4086) |
5636 | - return 0; |
5637 | - |
5638 | - count = ext_prop->data_len + |
5639 | + n = ext_prop->data_len + |
5640 | ext_prop->name_len + 14; |
5641 | - if (count > 4086 - n) |
5642 | - return -EINVAL; |
5643 | - usb_ext_prop_put_size(buf, count); |
5644 | + if (count + n >= USB_COMP_EP0_OS_DESC_BUFSIZ) |
5645 | + return count; |
5646 | + usb_ext_prop_put_size(buf, n); |
5647 | usb_ext_prop_put_type(buf, ext_prop->type); |
5648 | ret = usb_ext_prop_put_name(buf, ext_prop->name, |
5649 | ext_prop->name_len); |
5650 | @@ -1544,11 +1541,12 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf) |
5651 | default: |
5652 | return -EINVAL; |
5653 | } |
5654 | - buf += count; |
5655 | + buf += n; |
5656 | + count += n; |
5657 | } |
5658 | } |
5659 | |
5660 | - return 0; |
5661 | + return count; |
5662 | } |
5663 | |
5664 | /* |
5665 | @@ -1830,6 +1828,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) |
5666 | req->complete = composite_setup_complete; |
5667 | buf = req->buf; |
5668 | os_desc_cfg = cdev->os_desc_config; |
5669 | + w_length = min_t(u16, w_length, USB_COMP_EP0_OS_DESC_BUFSIZ); |
5670 | memset(buf, 0, w_length); |
5671 | buf[5] = 0x01; |
5672 | switch (ctrl->bRequestType & USB_RECIP_MASK) { |
5673 | @@ -1853,8 +1852,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) |
5674 | count += 16; /* header */ |
5675 | put_unaligned_le32(count, buf); |
5676 | buf += 16; |
5677 | - fill_ext_compat(os_desc_cfg, buf); |
5678 | - value = w_length; |
5679 | + value = fill_ext_compat(os_desc_cfg, buf); |
5680 | + value = min_t(u16, w_length, value); |
5681 | } |
5682 | break; |
5683 | case USB_RECIP_INTERFACE: |
5684 | @@ -1883,8 +1882,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) |
5685 | interface, buf); |
5686 | if (value < 0) |
5687 | return value; |
5688 | - |
5689 | - value = w_length; |
5690 | + value = min_t(u16, w_length, value); |
5691 | } |
5692 | break; |
5693 | } |
5694 | @@ -2159,8 +2157,8 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev, |
5695 | goto end; |
5696 | } |
5697 | |
5698 | - /* OS feature descriptor length <= 4kB */ |
5699 | - cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL); |
5700 | + cdev->os_desc_req->buf = kmalloc(USB_COMP_EP0_OS_DESC_BUFSIZ, |
5701 | + GFP_KERNEL); |
5702 | if (!cdev->os_desc_req->buf) { |
5703 | ret = -ENOMEM; |
5704 | usb_ep_free_request(ep0, cdev->os_desc_req); |
5705 | diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c |
5706 | index 0904cb6ce4de..7b53ac548b1a 100644 |
5707 | --- a/drivers/usb/gadget/function/f_fs.c |
5708 | +++ b/drivers/usb/gadget/function/f_fs.c |
5709 | @@ -759,9 +759,13 @@ static void ffs_user_copy_worker(struct work_struct *work) |
5710 | bool kiocb_has_eventfd = io_data->kiocb->ki_flags & IOCB_EVENTFD; |
5711 | |
5712 | if (io_data->read && ret > 0) { |
5713 | + mm_segment_t oldfs = get_fs(); |
5714 | + |
5715 | + set_fs(USER_DS); |
5716 | use_mm(io_data->mm); |
5717 | ret = ffs_copy_to_iter(io_data->buf, ret, &io_data->data); |
5718 | unuse_mm(io_data->mm); |
5719 | + set_fs(oldfs); |
5720 | } |
5721 | |
5722 | io_data->kiocb->ki_complete(io_data->kiocb, ret, ret); |
5723 | @@ -3239,7 +3243,7 @@ static int ffs_func_setup(struct usb_function *f, |
5724 | __ffs_event_add(ffs, FUNCTIONFS_SETUP); |
5725 | spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags); |
5726 | |
5727 | - return 0; |
5728 | + return USB_GADGET_DELAYED_STATUS; |
5729 | } |
5730 | |
5731 | static bool ffs_func_req_match(struct usb_function *f, |
5732 | diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c |
5733 | index f05c3f3e6103..97cb2dfd6369 100644 |
5734 | --- a/drivers/usb/gadget/function/f_uac2.c |
5735 | +++ b/drivers/usb/gadget/function/f_uac2.c |
5736 | @@ -528,6 +528,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) |
5737 | dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); |
5738 | return ret; |
5739 | } |
5740 | + iad_desc.bFirstInterface = ret; |
5741 | + |
5742 | std_ac_if_desc.bInterfaceNumber = ret; |
5743 | uac2->ac_intf = ret; |
5744 | uac2->ac_alt = 0; |
5745 | diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c |
5746 | index 5bab09294a8a..ad315c4c6f35 100644 |
5747 | --- a/drivers/usb/gadget/udc/core.c |
5748 | +++ b/drivers/usb/gadget/udc/core.c |
5749 | @@ -191,8 +191,8 @@ EXPORT_SYMBOL_GPL(usb_ep_alloc_request); |
5750 | void usb_ep_free_request(struct usb_ep *ep, |
5751 | struct usb_request *req) |
5752 | { |
5753 | - ep->ops->free_request(ep, req); |
5754 | trace_usb_ep_free_request(ep, req, 0); |
5755 | + ep->ops->free_request(ep, req); |
5756 | } |
5757 | EXPORT_SYMBOL_GPL(usb_ep_free_request); |
5758 | |
5759 | diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c |
5760 | index 6f2f71c054be..7874c112f3fd 100644 |
5761 | --- a/drivers/usb/gadget/udc/fsl_udc_core.c |
5762 | +++ b/drivers/usb/gadget/udc/fsl_udc_core.c |
5763 | @@ -1309,7 +1309,7 @@ static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) |
5764 | { |
5765 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); |
5766 | |
5767 | - if (ep->name) |
5768 | + if (ep->ep.name) |
5769 | nuke(ep, -ESHUTDOWN); |
5770 | } |
5771 | |
5772 | @@ -1697,7 +1697,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) |
5773 | curr_ep = get_ep_by_pipe(udc, i); |
5774 | |
5775 | /* If the ep is configured */ |
5776 | - if (curr_ep->name == NULL) { |
5777 | + if (!curr_ep->ep.name) { |
5778 | WARNING("Invalid EP?"); |
5779 | continue; |
5780 | } |
5781 | diff --git a/drivers/usb/gadget/udc/goku_udc.h b/drivers/usb/gadget/udc/goku_udc.h |
5782 | index 86d2adafe149..64eb0f2b5ea0 100644 |
5783 | --- a/drivers/usb/gadget/udc/goku_udc.h |
5784 | +++ b/drivers/usb/gadget/udc/goku_udc.h |
5785 | @@ -28,7 +28,7 @@ struct goku_udc_regs { |
5786 | # define INT_EP1DATASET 0x00040 |
5787 | # define INT_EP2DATASET 0x00080 |
5788 | # define INT_EP3DATASET 0x00100 |
5789 | -#define INT_EPnNAK(n) (0x00100 < (n)) /* 0 < n < 4 */ |
5790 | +#define INT_EPnNAK(n) (0x00100 << (n)) /* 0 < n < 4 */ |
5791 | # define INT_EP1NAK 0x00200 |
5792 | # define INT_EP2NAK 0x00400 |
5793 | # define INT_EP3NAK 0x00800 |
5794 | diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c |
5795 | index 1099465b27f0..b4599aa428f3 100644 |
5796 | --- a/drivers/usb/host/ohci-hcd.c |
5797 | +++ b/drivers/usb/host/ohci-hcd.c |
5798 | @@ -446,7 +446,8 @@ static int ohci_init (struct ohci_hcd *ohci) |
5799 | struct usb_hcd *hcd = ohci_to_hcd(ohci); |
5800 | |
5801 | /* Accept arbitrarily long scatter-gather lists */ |
5802 | - hcd->self.sg_tablesize = ~0; |
5803 | + if (!(hcd->driver->flags & HCD_LOCAL_MEM)) |
5804 | + hcd->self.sg_tablesize = ~0; |
5805 | |
5806 | if (distrust_firmware) |
5807 | ohci->flags |= OHCI_QUIRK_HUB_POWER; |
5808 | diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c |
5809 | index ccdc971283d0..efd7e4882d66 100644 |
5810 | --- a/drivers/usb/host/xhci-mem.c |
5811 | +++ b/drivers/usb/host/xhci-mem.c |
5812 | @@ -926,6 +926,8 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) |
5813 | if (dev->out_ctx) |
5814 | xhci_free_container_ctx(xhci, dev->out_ctx); |
5815 | |
5816 | + if (dev->udev && dev->udev->slot_id) |
5817 | + dev->udev->slot_id = 0; |
5818 | kfree(xhci->devs[slot_id]); |
5819 | xhci->devs[slot_id] = NULL; |
5820 | } |
5821 | diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c |
5822 | index 7d9e085f7b85..830dd0dbbce0 100644 |
5823 | --- a/drivers/usb/host/xhci-plat.c |
5824 | +++ b/drivers/usb/host/xhci-plat.c |
5825 | @@ -355,7 +355,6 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) |
5826 | { |
5827 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
5828 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
5829 | - int ret; |
5830 | |
5831 | /* |
5832 | * xhci_suspend() needs `do_wakeup` to know whether host is allowed |
5833 | @@ -365,12 +364,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) |
5834 | * reconsider this when xhci_plat_suspend enlarges its scope, e.g., |
5835 | * also applies to runtime suspend. |
5836 | */ |
5837 | - ret = xhci_suspend(xhci, device_may_wakeup(dev)); |
5838 | - |
5839 | - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) |
5840 | - clk_disable_unprepare(xhci->clk); |
5841 | - |
5842 | - return ret; |
5843 | + return xhci_suspend(xhci, device_may_wakeup(dev)); |
5844 | } |
5845 | |
5846 | static int __maybe_unused xhci_plat_resume(struct device *dev) |
5847 | @@ -379,9 +373,6 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) |
5848 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
5849 | int ret; |
5850 | |
5851 | - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) |
5852 | - clk_prepare_enable(xhci->clk); |
5853 | - |
5854 | ret = xhci_priv_resume_quirk(hcd); |
5855 | if (ret) |
5856 | return ret; |
5857 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
5858 | index bcf315b32bff..d8b185b0d0f9 100644 |
5859 | --- a/drivers/usb/host/xhci.c |
5860 | +++ b/drivers/usb/host/xhci.c |
5861 | @@ -4764,6 +4764,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) |
5862 | * quirks |
5863 | */ |
5864 | struct device *dev = hcd->self.sysdev; |
5865 | + unsigned int minor_rev; |
5866 | int retval; |
5867 | |
5868 | /* Accept arbitrarily long scatter-gather lists */ |
5869 | @@ -4791,12 +4792,19 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) |
5870 | */ |
5871 | hcd->has_tt = 1; |
5872 | } else { |
5873 | - /* Some 3.1 hosts return sbrn 0x30, can't rely on sbrn alone */ |
5874 | - if (xhci->sbrn == 0x31 || xhci->usb3_rhub.min_rev >= 1) { |
5875 | - xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n"); |
5876 | + /* |
5877 | + * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol |
5878 | + * minor revision instead of sbrn |
5879 | + */ |
5880 | + minor_rev = xhci->usb3_rhub.min_rev; |
5881 | + if (minor_rev) { |
5882 | hcd->speed = HCD_USB31; |
5883 | hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; |
5884 | } |
5885 | + xhci_info(xhci, "Host supports USB 3.%x %s SuperSpeed\n", |
5886 | + minor_rev, |
5887 | + minor_rev ? "Enhanced" : ""); |
5888 | + |
5889 | /* xHCI private pointer was set in xhci_pci_probe for the second |
5890 | * registered roothub. |
5891 | */ |
5892 | diff --git a/drivers/usb/usbip/Kconfig b/drivers/usb/usbip/Kconfig |
5893 | index eeefa29f8aa2..a20b65cb6678 100644 |
5894 | --- a/drivers/usb/usbip/Kconfig |
5895 | +++ b/drivers/usb/usbip/Kconfig |
5896 | @@ -27,7 +27,7 @@ config USBIP_VHCI_HCD |
5897 | |
5898 | config USBIP_VHCI_HC_PORTS |
5899 | int "Number of ports per USB/IP virtual host controller" |
5900 | - range 1 31 |
5901 | + range 1 15 |
5902 | default 8 |
5903 | depends on USBIP_VHCI_HCD |
5904 | ---help--- |
5905 | diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c |
5906 | index 1442a4c734c8..a7c87d593083 100644 |
5907 | --- a/fs/ext2/inode.c |
5908 | +++ b/fs/ext2/inode.c |
5909 | @@ -1261,21 +1261,11 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset) |
5910 | |
5911 | static void ext2_truncate_blocks(struct inode *inode, loff_t offset) |
5912 | { |
5913 | - /* |
5914 | - * XXX: it seems like a bug here that we don't allow |
5915 | - * IS_APPEND inode to have blocks-past-i_size trimmed off. |
5916 | - * review and fix this. |
5917 | - * |
5918 | - * Also would be nice to be able to handle IO errors and such, |
5919 | - * but that's probably too much to ask. |
5920 | - */ |
5921 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
5922 | S_ISLNK(inode->i_mode))) |
5923 | return; |
5924 | if (ext2_inode_is_fast_symlink(inode)) |
5925 | return; |
5926 | - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) |
5927 | - return; |
5928 | |
5929 | dax_sem_down_write(EXT2_I(inode)); |
5930 | __ext2_truncate_blocks(inode, offset); |
5931 | diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c |
5932 | index e5bb2de2262a..3cba08c931ee 100644 |
5933 | --- a/fs/hfsplus/super.c |
5934 | +++ b/fs/hfsplus/super.c |
5935 | @@ -588,6 +588,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) |
5936 | return 0; |
5937 | |
5938 | out_put_hidden_dir: |
5939 | + cancel_delayed_work_sync(&sbi->sync_work); |
5940 | iput(sbi->hidden_dir); |
5941 | out_put_root: |
5942 | dput(sb->s_root); |
5943 | diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h |
5944 | index 5bdbd9f49395..07ee0f84a46c 100644 |
5945 | --- a/include/linux/u64_stats_sync.h |
5946 | +++ b/include/linux/u64_stats_sync.h |
5947 | @@ -90,6 +90,28 @@ static inline void u64_stats_update_end(struct u64_stats_sync *syncp) |
5948 | #endif |
5949 | } |
5950 | |
5951 | +static inline unsigned long |
5952 | +u64_stats_update_begin_irqsave(struct u64_stats_sync *syncp) |
5953 | +{ |
5954 | + unsigned long flags = 0; |
5955 | + |
5956 | +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) |
5957 | + local_irq_save(flags); |
5958 | + write_seqcount_begin(&syncp->seq); |
5959 | +#endif |
5960 | + return flags; |
5961 | +} |
5962 | + |
5963 | +static inline void |
5964 | +u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp, |
5965 | + unsigned long flags) |
5966 | +{ |
5967 | +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) |
5968 | + write_seqcount_end(&syncp->seq); |
5969 | + local_irq_restore(flags); |
5970 | +#endif |
5971 | +} |
5972 | + |
5973 | static inline void u64_stats_update_begin_raw(struct u64_stats_sync *syncp) |
5974 | { |
5975 | #if BITS_PER_LONG==32 && defined(CONFIG_SMP) |
5976 | diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h |
5977 | index f665d2ceac20..590d313b5f39 100644 |
5978 | --- a/include/linux/usb/composite.h |
5979 | +++ b/include/linux/usb/composite.h |
5980 | @@ -53,6 +53,9 @@ |
5981 | /* big enough to hold our biggest descriptor */ |
5982 | #define USB_COMP_EP0_BUFSIZ 1024 |
5983 | |
5984 | +/* OS feature descriptor length <= 4kB */ |
5985 | +#define USB_COMP_EP0_OS_DESC_BUFSIZ 4096 |
5986 | + |
5987 | #define USB_MS_TO_HS_INTERVAL(x) (ilog2((x * 1000 / 125)) + 1) |
5988 | struct usb_configuration; |
5989 | |
5990 | diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h |
5991 | index cb85eddb47ea..eb7853c1a23b 100644 |
5992 | --- a/include/scsi/scsi.h |
5993 | +++ b/include/scsi/scsi.h |
5994 | @@ -47,6 +47,8 @@ static inline int scsi_status_is_good(int status) |
5995 | */ |
5996 | status &= 0xfe; |
5997 | return ((status == SAM_STAT_GOOD) || |
5998 | + (status == SAM_STAT_CONDITION_MET) || |
5999 | + /* Next two "intermediate" statuses are obsolete in SAM-4 */ |
6000 | (status == SAM_STAT_INTERMEDIATE) || |
6001 | (status == SAM_STAT_INTERMEDIATE_CONDITION_MET) || |
6002 | /* FIXME: this is obsolete in SAM-3 */ |
6003 | diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h |
6004 | index 51626b4175c0..3fab6c81917f 100644 |
6005 | --- a/include/uapi/linux/nl80211.h |
6006 | +++ b/include/uapi/linux/nl80211.h |
6007 | @@ -2604,6 +2604,8 @@ enum nl80211_attrs { |
6008 | #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS |
6009 | #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS |
6010 | |
6011 | +#define NL80211_WIPHY_NAME_MAXLEN 128 |
6012 | + |
6013 | #define NL80211_MAX_SUPP_RATES 32 |
6014 | #define NL80211_MAX_SUPP_HT_RATES 77 |
6015 | #define NL80211_MAX_SUPP_REG_RULES 64 |
6016 | diff --git a/net/core/dev.c b/net/core/dev.c |
6017 | index e7d56c5adde6..6ca771f2f25b 100644 |
6018 | --- a/net/core/dev.c |
6019 | +++ b/net/core/dev.c |
6020 | @@ -2058,7 +2058,7 @@ static bool remove_xps_queue_cpu(struct net_device *dev, |
6021 | int i, j; |
6022 | |
6023 | for (i = count, j = offset; i--; j++) { |
6024 | - if (!remove_xps_queue(dev_maps, cpu, j)) |
6025 | + if (!remove_xps_queue(dev_maps, tci, j)) |
6026 | break; |
6027 | } |
6028 | |
6029 | diff --git a/net/core/sock.c b/net/core/sock.c |
6030 | index ec6eb546b228..68d08ed5521e 100644 |
6031 | --- a/net/core/sock.c |
6032 | +++ b/net/core/sock.c |
6033 | @@ -1595,7 +1595,7 @@ void sk_destruct(struct sock *sk) |
6034 | |
6035 | static void __sk_free(struct sock *sk) |
6036 | { |
6037 | - if (unlikely(sock_diag_has_destroy_listeners(sk) && sk->sk_net_refcnt)) |
6038 | + if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk))) |
6039 | sock_diag_broadcast_destroy(sk); |
6040 | else |
6041 | sk_destruct(sk); |
6042 | diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c |
6043 | index e8e675be60ec..63d5d66e040a 100644 |
6044 | --- a/net/ipv4/ip_output.c |
6045 | +++ b/net/ipv4/ip_output.c |
6046 | @@ -1040,7 +1040,8 @@ static int __ip_append_data(struct sock *sk, |
6047 | if (copy > length) |
6048 | copy = length; |
6049 | |
6050 | - if (!(rt->dst.dev->features&NETIF_F_SG)) { |
6051 | + if (!(rt->dst.dev->features&NETIF_F_SG) && |
6052 | + skb_tailroom(skb) >= copy) { |
6053 | unsigned int off; |
6054 | |
6055 | off = skb->len; |
6056 | diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c |
6057 | index 83d11cd2eb65..abae5196cd3a 100644 |
6058 | --- a/net/ipv4/tcp_output.c |
6059 | +++ b/net/ipv4/tcp_output.c |
6060 | @@ -2814,8 +2814,10 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) |
6061 | return -EBUSY; |
6062 | |
6063 | if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) { |
6064 | - if (before(TCP_SKB_CB(skb)->end_seq, tp->snd_una)) |
6065 | - BUG(); |
6066 | + if (unlikely(before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))) { |
6067 | + WARN_ON_ONCE(1); |
6068 | + return -EINVAL; |
6069 | + } |
6070 | if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq)) |
6071 | return -ENOMEM; |
6072 | } |
6073 | @@ -3312,6 +3314,7 @@ static void tcp_connect_init(struct sock *sk) |
6074 | sock_reset_flag(sk, SOCK_DONE); |
6075 | tp->snd_wnd = 0; |
6076 | tcp_init_wl(tp, 0); |
6077 | + tcp_write_queue_purge(sk); |
6078 | tp->snd_una = tp->write_seq; |
6079 | tp->snd_sml = tp->write_seq; |
6080 | tp->snd_up = tp->write_seq; |
6081 | diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c |
6082 | index ffbb81609016..0f2d74885bcb 100644 |
6083 | --- a/net/ipv6/ip6_output.c |
6084 | +++ b/net/ipv6/ip6_output.c |
6085 | @@ -1488,7 +1488,8 @@ static int __ip6_append_data(struct sock *sk, |
6086 | if (copy > length) |
6087 | copy = length; |
6088 | |
6089 | - if (!(rt->dst.dev->features&NETIF_F_SG)) { |
6090 | + if (!(rt->dst.dev->features&NETIF_F_SG) && |
6091 | + skb_tailroom(skb) >= copy) { |
6092 | unsigned int off; |
6093 | |
6094 | off = skb->len; |
6095 | diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
6096 | index 3994b71f8197..8351faabba62 100644 |
6097 | --- a/net/packet/af_packet.c |
6098 | +++ b/net/packet/af_packet.c |
6099 | @@ -2912,13 +2912,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) |
6100 | if (skb == NULL) |
6101 | goto out_unlock; |
6102 | |
6103 | - skb_set_network_header(skb, reserve); |
6104 | + skb_reset_network_header(skb); |
6105 | |
6106 | err = -EINVAL; |
6107 | if (sock->type == SOCK_DGRAM) { |
6108 | offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len); |
6109 | if (unlikely(offset < 0)) |
6110 | goto out_free; |
6111 | + } else if (reserve) { |
6112 | + skb_push(skb, reserve); |
6113 | } |
6114 | |
6115 | /* Returns -EFAULT on error */ |
6116 | diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c |
6117 | index 16eb067a8d8f..5c10a0fce35b 100644 |
6118 | --- a/net/sched/act_vlan.c |
6119 | +++ b/net/sched/act_vlan.c |
6120 | @@ -154,6 +154,8 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, |
6121 | case htons(ETH_P_8021AD): |
6122 | break; |
6123 | default: |
6124 | + if (exists) |
6125 | + tcf_idr_release(*a, bind); |
6126 | return -EPROTONOSUPPORT; |
6127 | } |
6128 | } else { |
6129 | diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c |
6130 | index d87c41e82917..c453b8d81c9e 100644 |
6131 | --- a/net/sched/sch_red.c |
6132 | +++ b/net/sched/sch_red.c |
6133 | @@ -191,10 +191,11 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt) |
6134 | child = fifo_create_dflt(sch, &bfifo_qdisc_ops, ctl->limit); |
6135 | if (IS_ERR(child)) |
6136 | return PTR_ERR(child); |
6137 | - } |
6138 | |
6139 | - if (child != &noop_qdisc) |
6140 | + /* child is fifo, no need to check for noop_qdisc */ |
6141 | qdisc_hash_add(child, true); |
6142 | + } |
6143 | + |
6144 | sch_tree_lock(sch); |
6145 | q->flags = ctl->flags; |
6146 | q->limit = ctl->limit; |
6147 | diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c |
6148 | index 120f4f365967..b36ecb58aa6e 100644 |
6149 | --- a/net/sched/sch_tbf.c |
6150 | +++ b/net/sched/sch_tbf.c |
6151 | @@ -388,6 +388,9 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) |
6152 | err = PTR_ERR(child); |
6153 | goto done; |
6154 | } |
6155 | + |
6156 | + /* child is fifo, no need to check for noop_qdisc */ |
6157 | + qdisc_hash_add(child, true); |
6158 | } |
6159 | |
6160 | sch_tree_lock(sch); |
6161 | @@ -396,8 +399,6 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) |
6162 | q->qdisc->qstats.backlog); |
6163 | qdisc_destroy(q->qdisc); |
6164 | q->qdisc = child; |
6165 | - if (child != &noop_qdisc) |
6166 | - qdisc_hash_add(child, true); |
6167 | } |
6168 | q->limit = qopt->limit; |
6169 | if (tb[TCA_TBF_PBURST]) |
6170 | diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c |
6171 | index 74568cdbca70..d7b88b2d1b22 100644 |
6172 | --- a/net/smc/smc_pnet.c |
6173 | +++ b/net/smc/smc_pnet.c |
6174 | @@ -245,40 +245,45 @@ static struct smc_ib_device *smc_pnet_find_ib(char *ib_name) |
6175 | static int smc_pnet_fill_entry(struct net *net, struct smc_pnetentry *pnetelem, |
6176 | struct nlattr *tb[]) |
6177 | { |
6178 | - char *string, *ibname = NULL; |
6179 | - int rc = 0; |
6180 | + char *string, *ibname; |
6181 | + int rc; |
6182 | |
6183 | memset(pnetelem, 0, sizeof(*pnetelem)); |
6184 | INIT_LIST_HEAD(&pnetelem->list); |
6185 | - if (tb[SMC_PNETID_NAME]) { |
6186 | - string = (char *)nla_data(tb[SMC_PNETID_NAME]); |
6187 | - if (!smc_pnetid_valid(string, pnetelem->pnet_name)) { |
6188 | - rc = -EINVAL; |
6189 | - goto error; |
6190 | - } |
6191 | - } |
6192 | - if (tb[SMC_PNETID_ETHNAME]) { |
6193 | - string = (char *)nla_data(tb[SMC_PNETID_ETHNAME]); |
6194 | - pnetelem->ndev = dev_get_by_name(net, string); |
6195 | - if (!pnetelem->ndev) |
6196 | - return -ENOENT; |
6197 | - } |
6198 | - if (tb[SMC_PNETID_IBNAME]) { |
6199 | - ibname = (char *)nla_data(tb[SMC_PNETID_IBNAME]); |
6200 | - ibname = strim(ibname); |
6201 | - pnetelem->smcibdev = smc_pnet_find_ib(ibname); |
6202 | - if (!pnetelem->smcibdev) { |
6203 | - rc = -ENOENT; |
6204 | - goto error; |
6205 | - } |
6206 | - } |
6207 | - if (tb[SMC_PNETID_IBPORT]) { |
6208 | - pnetelem->ib_port = nla_get_u8(tb[SMC_PNETID_IBPORT]); |
6209 | - if (pnetelem->ib_port > SMC_MAX_PORTS) { |
6210 | - rc = -EINVAL; |
6211 | - goto error; |
6212 | - } |
6213 | - } |
6214 | + |
6215 | + rc = -EINVAL; |
6216 | + if (!tb[SMC_PNETID_NAME]) |
6217 | + goto error; |
6218 | + string = (char *)nla_data(tb[SMC_PNETID_NAME]); |
6219 | + if (!smc_pnetid_valid(string, pnetelem->pnet_name)) |
6220 | + goto error; |
6221 | + |
6222 | + rc = -EINVAL; |
6223 | + if (!tb[SMC_PNETID_ETHNAME]) |
6224 | + goto error; |
6225 | + rc = -ENOENT; |
6226 | + string = (char *)nla_data(tb[SMC_PNETID_ETHNAME]); |
6227 | + pnetelem->ndev = dev_get_by_name(net, string); |
6228 | + if (!pnetelem->ndev) |
6229 | + goto error; |
6230 | + |
6231 | + rc = -EINVAL; |
6232 | + if (!tb[SMC_PNETID_IBNAME]) |
6233 | + goto error; |
6234 | + rc = -ENOENT; |
6235 | + ibname = (char *)nla_data(tb[SMC_PNETID_IBNAME]); |
6236 | + ibname = strim(ibname); |
6237 | + pnetelem->smcibdev = smc_pnet_find_ib(ibname); |
6238 | + if (!pnetelem->smcibdev) |
6239 | + goto error; |
6240 | + |
6241 | + rc = -EINVAL; |
6242 | + if (!tb[SMC_PNETID_IBPORT]) |
6243 | + goto error; |
6244 | + pnetelem->ib_port = nla_get_u8(tb[SMC_PNETID_IBPORT]); |
6245 | + if (pnetelem->ib_port < 1 || pnetelem->ib_port > SMC_MAX_PORTS) |
6246 | + goto error; |
6247 | + |
6248 | return 0; |
6249 | |
6250 | error: |
6251 | @@ -307,6 +312,8 @@ static int smc_pnet_get(struct sk_buff *skb, struct genl_info *info) |
6252 | void *hdr; |
6253 | int rc; |
6254 | |
6255 | + if (!info->attrs[SMC_PNETID_NAME]) |
6256 | + return -EINVAL; |
6257 | pnetelem = smc_pnet_find_pnetid( |
6258 | (char *)nla_data(info->attrs[SMC_PNETID_NAME])); |
6259 | if (!pnetelem) |
6260 | @@ -359,6 +366,8 @@ static int smc_pnet_add(struct sk_buff *skb, struct genl_info *info) |
6261 | |
6262 | static int smc_pnet_del(struct sk_buff *skb, struct genl_info *info) |
6263 | { |
6264 | + if (!info->attrs[SMC_PNETID_NAME]) |
6265 | + return -EINVAL; |
6266 | return smc_pnet_remove_by_pnetid( |
6267 | (char *)nla_data(info->attrs[SMC_PNETID_NAME])); |
6268 | } |
6269 | diff --git a/net/wireless/core.c b/net/wireless/core.c |
6270 | index 33ce0484b2a0..45cbade9ad68 100644 |
6271 | --- a/net/wireless/core.c |
6272 | +++ b/net/wireless/core.c |
6273 | @@ -95,6 +95,9 @@ static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev, |
6274 | |
6275 | ASSERT_RTNL(); |
6276 | |
6277 | + if (strlen(newname) > NL80211_WIPHY_NAME_MAXLEN) |
6278 | + return -EINVAL; |
6279 | + |
6280 | /* prohibit calling the thing phy%d when %d is not its number */ |
6281 | sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken); |
6282 | if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) { |
6283 | diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c |
6284 | index 3abf82563408..cf3b905b4ead 100644 |
6285 | --- a/sound/soc/codecs/hdmi-codec.c |
6286 | +++ b/sound/soc/codecs/hdmi-codec.c |
6287 | @@ -801,12 +801,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) |
6288 | |
6289 | static int hdmi_codec_remove(struct platform_device *pdev) |
6290 | { |
6291 | - struct device *dev = &pdev->dev; |
6292 | - struct hdmi_codec_priv *hcp; |
6293 | - |
6294 | - hcp = dev_get_drvdata(dev); |
6295 | - kfree(hcp->chmap_info); |
6296 | - snd_soc_unregister_codec(dev); |
6297 | + snd_soc_unregister_codec(&pdev->dev); |
6298 | |
6299 | return 0; |
6300 | } |
6301 | diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig |
6302 | index b0825370d262..957046ac6c8c 100644 |
6303 | --- a/sound/soc/rockchip/Kconfig |
6304 | +++ b/sound/soc/rockchip/Kconfig |
6305 | @@ -56,6 +56,9 @@ config SND_SOC_RK3288_HDMI_ANALOG |
6306 | depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP |
6307 | select SND_SOC_ROCKCHIP_I2S |
6308 | select SND_SOC_HDMI_CODEC |
6309 | + select SND_SOC_ES8328_I2C |
6310 | + select SND_SOC_ES8328_SPI if SPI_MASTER |
6311 | + select DRM_DW_HDMI_I2S_AUDIO if DRM_DW_HDMI |
6312 | help |
6313 | Say Y or M here if you want to add support for SoC audio on Rockchip |
6314 | RK3288 boards using an analog output and the built-in HDMI audio. |
6315 | diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c |
6316 | index 10a4da06c0a1..f058f2bdd519 100644 |
6317 | --- a/sound/soc/samsung/i2s.c |
6318 | +++ b/sound/soc/samsung/i2s.c |
6319 | @@ -653,8 +653,12 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, |
6320 | tmp |= mod_slave; |
6321 | break; |
6322 | case SND_SOC_DAIFMT_CBS_CFS: |
6323 | - /* Set default source clock in Master mode */ |
6324 | - if (i2s->rclk_srcrate == 0) |
6325 | + /* |
6326 | + * Set default source clock in Master mode, only when the |
6327 | + * CLK_I2S_RCLK_SRC clock is not exposed so we ensure any |
6328 | + * clock configuration assigned in DT is not overwritten. |
6329 | + */ |
6330 | + if (i2s->rclk_srcrate == 0 && i2s->clk_data.clks == NULL) |
6331 | i2s_set_sysclk(dai, SAMSUNG_I2S_RCLKSRC_0, |
6332 | 0, SND_SOC_CLOCK_IN); |
6333 | break; |
6334 | @@ -878,6 +882,11 @@ static int config_setup(struct i2s_dai *i2s) |
6335 | return 0; |
6336 | |
6337 | if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { |
6338 | + struct clk *rclksrc = i2s->clk_table[CLK_I2S_RCLK_SRC]; |
6339 | + |
6340 | + if (i2s->rclk_srcrate == 0 && rclksrc && !IS_ERR(rclksrc)) |
6341 | + i2s->rclk_srcrate = clk_get_rate(rclksrc); |
6342 | + |
6343 | psr = i2s->rclk_srcrate / i2s->frmclk / rfs; |
6344 | writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR); |
6345 | dev_dbg(&i2s->pdev->dev, |
6346 | diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c |
6347 | index 44b6de5a331a..06a31a9585a0 100644 |
6348 | --- a/sound/soc/samsung/odroid.c |
6349 | +++ b/sound/soc/samsung/odroid.c |
6350 | @@ -36,23 +36,26 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, |
6351 | { |
6352 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
6353 | struct odroid_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
6354 | - unsigned int pll_freq, rclk_freq; |
6355 | + unsigned int pll_freq, rclk_freq, rfs; |
6356 | int ret; |
6357 | |
6358 | switch (params_rate(params)) { |
6359 | - case 32000: |
6360 | case 64000: |
6361 | - pll_freq = 131072006U; |
6362 | + pll_freq = 196608001U; |
6363 | + rfs = 384; |
6364 | break; |
6365 | case 44100: |
6366 | case 88200: |
6367 | case 176400: |
6368 | pll_freq = 180633609U; |
6369 | + rfs = 512; |
6370 | break; |
6371 | + case 32000: |
6372 | case 48000: |
6373 | case 96000: |
6374 | case 192000: |
6375 | pll_freq = 196608001U; |
6376 | + rfs = 512; |
6377 | break; |
6378 | default: |
6379 | return -EINVAL; |
6380 | @@ -67,7 +70,7 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, |
6381 | * frequency values due to the EPLL output frequency not being exact |
6382 | * multiple of the audio sampling rate. |
6383 | */ |
6384 | - rclk_freq = params_rate(params) * 256 + 1; |
6385 | + rclk_freq = params_rate(params) * rfs + 1; |
6386 | |
6387 | ret = clk_set_rate(priv->sclk_i2s, rclk_freq); |
6388 | if (ret < 0) |
6389 | diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c |
6390 | index 782c580b7aa3..e5049fbfc4f1 100644 |
6391 | --- a/sound/soc/soc-topology.c |
6392 | +++ b/sound/soc/soc-topology.c |
6393 | @@ -1276,6 +1276,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( |
6394 | kfree(sm); |
6395 | continue; |
6396 | } |
6397 | + |
6398 | + /* create any TLV data */ |
6399 | + soc_tplg_create_tlv(tplg, &kc[i], &mc->hdr); |
6400 | } |
6401 | return kc; |
6402 | |
6403 | diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
6404 | index 58f94f399efb..ad14d6b78bdc 100644 |
6405 | --- a/sound/usb/quirks.c |
6406 | +++ b/sound/usb/quirks.c |
6407 | @@ -1155,24 +1155,27 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) |
6408 | return false; |
6409 | } |
6410 | |
6411 | -/* Marantz/Denon USB DACs need a vendor cmd to switch |
6412 | +/* ITF-USB DSD based DACs need a vendor cmd to switch |
6413 | * between PCM and native DSD mode |
6414 | + * (2 altsets version) |
6415 | */ |
6416 | -static bool is_marantz_denon_dac(unsigned int id) |
6417 | +static bool is_itf_usb_dsd_2alts_dac(unsigned int id) |
6418 | { |
6419 | switch (id) { |
6420 | case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */ |
6421 | case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */ |
6422 | case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */ |
6423 | + case USB_ID(0x1852, 0x5065): /* Luxman DA-06 */ |
6424 | return true; |
6425 | } |
6426 | return false; |
6427 | } |
6428 | |
6429 | -/* TEAC UD-501/UD-503/NT-503 USB DACs need a vendor cmd to switch |
6430 | - * between PCM/DOP and native DSD mode |
6431 | +/* ITF-USB DSD based DACs need a vendor cmd to switch |
6432 | + * between PCM and native DSD mode |
6433 | + * (3 altsets version) |
6434 | */ |
6435 | -static bool is_teac_dsd_dac(unsigned int id) |
6436 | +static bool is_itf_usb_dsd_3alts_dac(unsigned int id) |
6437 | { |
6438 | switch (id) { |
6439 | case USB_ID(0x0644, 0x8043): /* TEAC UD-501/UD-503/NT-503 */ |
6440 | @@ -1189,7 +1192,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs, |
6441 | struct usb_device *dev = subs->dev; |
6442 | int err; |
6443 | |
6444 | - if (is_marantz_denon_dac(subs->stream->chip->usb_id)) { |
6445 | + if (is_itf_usb_dsd_2alts_dac(subs->stream->chip->usb_id)) { |
6446 | /* First switch to alt set 0, otherwise the mode switch cmd |
6447 | * will not be accepted by the DAC |
6448 | */ |
6449 | @@ -1210,7 +1213,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs, |
6450 | break; |
6451 | } |
6452 | mdelay(20); |
6453 | - } else if (is_teac_dsd_dac(subs->stream->chip->usb_id)) { |
6454 | + } else if (is_itf_usb_dsd_3alts_dac(subs->stream->chip->usb_id)) { |
6455 | /* Vendor mode switch cmd is required. */ |
6456 | switch (fmt->altsetting) { |
6457 | case 3: /* DSD mode (DSD_U32) requested */ |
6458 | @@ -1306,10 +1309,10 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
6459 | (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) |
6460 | mdelay(20); |
6461 | |
6462 | - /* Marantz/Denon devices with USB DAC functionality need a delay |
6463 | + /* ITF-USB DSD based DACs functionality need a delay |
6464 | * after each class compliant request |
6465 | */ |
6466 | - if (is_marantz_denon_dac(chip->usb_id) |
6467 | + if (is_itf_usb_dsd_2alts_dac(chip->usb_id) |
6468 | && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) |
6469 | mdelay(20); |
6470 | |
6471 | @@ -1396,14 +1399,14 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, |
6472 | break; |
6473 | } |
6474 | |
6475 | - /* Denon/Marantz devices with USB DAC functionality */ |
6476 | - if (is_marantz_denon_dac(chip->usb_id)) { |
6477 | + /* ITF-USB DSD based DACs (2 altsets version) */ |
6478 | + if (is_itf_usb_dsd_2alts_dac(chip->usb_id)) { |
6479 | if (fp->altsetting == 2) |
6480 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
6481 | } |
6482 | |
6483 | - /* TEAC devices with USB DAC functionality */ |
6484 | - if (is_teac_dsd_dac(chip->usb_id)) { |
6485 | + /* ITF-USB DSD based DACs (3 altsets version) */ |
6486 | + if (is_itf_usb_dsd_3alts_dac(chip->usb_id)) { |
6487 | if (fp->altsetting == 3) |
6488 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
6489 | } |