Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Fri, 31 May 2019 16:42:41
Message-Id: 1559320938.a18abc2809788f1c84a8a54f98b0a59babe97ed8.mpagano@gentoo
1 commit: a18abc2809788f1c84a8a54f98b0a59babe97ed8
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 31 16:42:18 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri May 31 16:42:18 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=a18abc28
7
8 Linux patch 4.9.180
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1179_linux-4.9.180.patch | 3776 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 3780 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 1ff80f1..531733f 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -759,6 +759,10 @@ Patch: 1178_linux-4.9.179.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.9.179
23
24 +Patch: 1179_linux-4.9.180.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.9.180
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1179_linux-4.9.180.patch b/1179_linux-4.9.180.patch
33 new file mode 100644
34 index 0000000..27bf989
35 --- /dev/null
36 +++ b/1179_linux-4.9.180.patch
37 @@ -0,0 +1,3776 @@
38 +diff --git a/Makefile b/Makefile
39 +index d60795319d8a..0b996e9d2c5f 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 9
45 +-SUBLEVEL = 179
46 ++SUBLEVEL = 180
47 + EXTRAVERSION =
48 + NAME = Roaring Lionus
49 +
50 +diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h
51 +index b74b174ac9fc..b458e4122794 100644
52 +--- a/arch/arm/include/asm/cp15.h
53 ++++ b/arch/arm/include/asm/cp15.h
54 +@@ -67,6 +67,8 @@
55 + #define BPIALL __ACCESS_CP15(c7, 0, c5, 6)
56 + #define ICIALLU __ACCESS_CP15(c7, 0, c5, 0)
57 +
58 ++#define CNTVCT __ACCESS_CP15_64(1, c14)
59 ++
60 + extern unsigned long cr_alignment; /* defined in entry-armv.S */
61 +
62 + static inline unsigned long get_cr(void)
63 +diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c
64 +index 79214d5ff097..3af02d2a0b7f 100644
65 +--- a/arch/arm/vdso/vgettimeofday.c
66 ++++ b/arch/arm/vdso/vgettimeofday.c
67 +@@ -18,9 +18,9 @@
68 + #include <linux/compiler.h>
69 + #include <linux/hrtimer.h>
70 + #include <linux/time.h>
71 +-#include <asm/arch_timer.h>
72 + #include <asm/barrier.h>
73 + #include <asm/bug.h>
74 ++#include <asm/cp15.h>
75 + #include <asm/page.h>
76 + #include <asm/unistd.h>
77 + #include <asm/vdso_datapage.h>
78 +@@ -123,7 +123,8 @@ static notrace u64 get_ns(struct vdso_data *vdata)
79 + u64 cycle_now;
80 + u64 nsec;
81 +
82 +- cycle_now = arch_counter_get_cntvct();
83 ++ isb();
84 ++ cycle_now = read_sysreg(CNTVCT);
85 +
86 + cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
87 +
88 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
89 +index 3a30a3994e4a..73e3718356b0 100644
90 +--- a/arch/arm64/include/asm/pgtable.h
91 ++++ b/arch/arm64/include/asm/pgtable.h
92 +@@ -413,6 +413,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
93 + return pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK;
94 + }
95 +
96 ++static inline void pte_unmap(pte_t *pte) { }
97 ++
98 + /* Find an entry in the third-level page table. */
99 + #define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
100 +
101 +@@ -421,7 +423,6 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
102 +
103 + #define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
104 + #define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
105 +-#define pte_unmap(pte) do { } while (0)
106 + #define pte_unmap_nested(pte) do { } while (0)
107 +
108 + #define pte_set_fixmap(addr) ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
109 +diff --git a/arch/arm64/include/asm/vdso_datapage.h b/arch/arm64/include/asm/vdso_datapage.h
110 +index 2b9a63771eda..f89263c8e11a 100644
111 +--- a/arch/arm64/include/asm/vdso_datapage.h
112 ++++ b/arch/arm64/include/asm/vdso_datapage.h
113 +@@ -38,6 +38,7 @@ struct vdso_data {
114 + __u32 tz_minuteswest; /* Whacky timezone stuff */
115 + __u32 tz_dsttime;
116 + __u32 use_syscall;
117 ++ __u32 hrtimer_res;
118 + };
119 +
120 + #endif /* !__ASSEMBLY__ */
121 +diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
122 +index bd239b1b7a68..95878bea27f9 100644
123 +--- a/arch/arm64/kernel/asm-offsets.c
124 ++++ b/arch/arm64/kernel/asm-offsets.c
125 +@@ -92,7 +92,7 @@ int main(void)
126 + DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
127 + DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
128 + DEFINE(CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_RAW);
129 +- DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
130 ++ DEFINE(CLOCK_REALTIME_RES, offsetof(struct vdso_data, hrtimer_res));
131 + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
132 + DEFINE(CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE);
133 + DEFINE(CLOCK_COARSE_RES, LOW_RES_NSEC);
134 +diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
135 +index e137ceaf5016..82b465207ed0 100644
136 +--- a/arch/arm64/kernel/cpu_ops.c
137 ++++ b/arch/arm64/kernel/cpu_ops.c
138 +@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)
139 + pr_err("%s: missing enable-method property\n",
140 + dn->full_name);
141 + }
142 ++ of_node_put(dn);
143 + } else {
144 + enable_method = acpi_get_enable_method(cpu);
145 + if (!enable_method) {
146 +diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
147 +index 4bcfe01b5aad..c9b9a5a322eb 100644
148 +--- a/arch/arm64/kernel/vdso.c
149 ++++ b/arch/arm64/kernel/vdso.c
150 +@@ -213,6 +213,9 @@ void update_vsyscall(struct timekeeper *tk)
151 + vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
152 + vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
153 +
154 ++ /* Read without the seqlock held by clock_getres() */
155 ++ WRITE_ONCE(vdso_data->hrtimer_res, hrtimer_resolution);
156 ++
157 + if (!use_syscall) {
158 + /* tkr_mono.cycle_last == tkr_raw.cycle_last */
159 + vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last;
160 +diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
161 +index 76320e920965..df829c4346fa 100644
162 +--- a/arch/arm64/kernel/vdso/gettimeofday.S
163 ++++ b/arch/arm64/kernel/vdso/gettimeofday.S
164 +@@ -301,13 +301,14 @@ ENTRY(__kernel_clock_getres)
165 + ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne
166 + b.ne 1f
167 +
168 +- ldr x2, 5f
169 ++ adr vdso_data, _vdso_data
170 ++ ldr w2, [vdso_data, #CLOCK_REALTIME_RES]
171 + b 2f
172 + 1:
173 + cmp w0, #CLOCK_REALTIME_COARSE
174 + ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
175 + b.ne 4f
176 +- ldr x2, 6f
177 ++ ldr x2, 5f
178 + 2:
179 + cbz w1, 3f
180 + stp xzr, x2, [x1]
181 +@@ -321,8 +322,6 @@ ENTRY(__kernel_clock_getres)
182 + svc #0
183 + ret
184 + 5:
185 +- .quad CLOCK_REALTIME_RES
186 +-6:
187 + .quad CLOCK_COARSE_RES
188 + .cfi_endproc
189 + ENDPROC(__kernel_clock_getres)
190 +diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
191 +index f5fde8d389c9..3ceec224d3d2 100644
192 +--- a/arch/arm64/mm/proc.S
193 ++++ b/arch/arm64/mm/proc.S
194 +@@ -64,17 +64,18 @@ ENTRY(cpu_do_suspend)
195 + mrs x2, tpidr_el0
196 + mrs x3, tpidrro_el0
197 + mrs x4, contextidr_el1
198 +- mrs x5, cpacr_el1
199 +- mrs x6, tcr_el1
200 +- mrs x7, vbar_el1
201 +- mrs x8, mdscr_el1
202 +- mrs x9, oslsr_el1
203 +- mrs x10, sctlr_el1
204 ++ mrs x5, osdlr_el1
205 ++ mrs x6, cpacr_el1
206 ++ mrs x7, tcr_el1
207 ++ mrs x8, vbar_el1
208 ++ mrs x9, mdscr_el1
209 ++ mrs x10, oslsr_el1
210 ++ mrs x11, sctlr_el1
211 + stp x2, x3, [x0]
212 +- stp x4, xzr, [x0, #16]
213 +- stp x5, x6, [x0, #32]
214 +- stp x7, x8, [x0, #48]
215 +- stp x9, x10, [x0, #64]
216 ++ stp x4, x5, [x0, #16]
217 ++ stp x6, x7, [x0, #32]
218 ++ stp x8, x9, [x0, #48]
219 ++ stp x10, x11, [x0, #64]
220 + ret
221 + ENDPROC(cpu_do_suspend)
222 +
223 +@@ -96,8 +97,8 @@ ENTRY(cpu_do_resume)
224 + msr cpacr_el1, x6
225 +
226 + /* Don't change t0sz here, mask those bits when restoring */
227 +- mrs x5, tcr_el1
228 +- bfi x8, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
229 ++ mrs x7, tcr_el1
230 ++ bfi x8, x7, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
231 +
232 + msr tcr_el1, x8
233 + msr vbar_el1, x9
234 +@@ -115,6 +116,7 @@ ENTRY(cpu_do_resume)
235 + /*
236 + * Restore oslsr_el1 by writing oslar_el1
237 + */
238 ++ msr osdlr_el1, x5
239 + ubfx x11, x11, #1, #1
240 + msr oslar_el1, x11
241 + reset_pmuserenr_el0 x0 // Disable PMU access from EL0
242 +diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
243 +index 9d9f6f334d3c..3da3e2b1b51b 100644
244 +--- a/arch/powerpc/boot/addnote.c
245 ++++ b/arch/powerpc/boot/addnote.c
246 +@@ -223,7 +223,11 @@ main(int ac, char **av)
247 + PUT_16(E_PHNUM, np + 2);
248 +
249 + /* write back */
250 +- lseek(fd, (long) 0, SEEK_SET);
251 ++ i = lseek(fd, (long) 0, SEEK_SET);
252 ++ if (i < 0) {
253 ++ perror("lseek");
254 ++ exit(1);
255 ++ }
256 + i = write(fd, buf, n);
257 + if (i < 0) {
258 + perror("write");
259 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
260 +index 9cad2ed812ab..31e9064ba628 100644
261 +--- a/arch/powerpc/mm/numa.c
262 ++++ b/arch/powerpc/mm/numa.c
263 +@@ -1574,6 +1574,9 @@ int start_topology_update(void)
264 + {
265 + int rc = 0;
266 +
267 ++ if (!topology_updates_enabled)
268 ++ return 0;
269 ++
270 + if (firmware_has_feature(FW_FEATURE_PRRN)) {
271 + if (!prrn_enabled) {
272 + prrn_enabled = 1;
273 +@@ -1603,6 +1606,9 @@ int stop_topology_update(void)
274 + {
275 + int rc = 0;
276 +
277 ++ if (!topology_updates_enabled)
278 ++ return 0;
279 ++
280 + if (prrn_enabled) {
281 + prrn_enabled = 0;
282 + #ifdef CONFIG_SMP
283 +@@ -1648,11 +1654,13 @@ static ssize_t topology_write(struct file *file, const char __user *buf,
284 +
285 + kbuf[read_len] = '\0';
286 +
287 +- if (!strncmp(kbuf, "on", 2))
288 ++ if (!strncmp(kbuf, "on", 2)) {
289 ++ topology_updates_enabled = true;
290 + start_topology_update();
291 +- else if (!strncmp(kbuf, "off", 3))
292 ++ } else if (!strncmp(kbuf, "off", 3)) {
293 + stop_topology_update();
294 +- else
295 ++ topology_updates_enabled = false;
296 ++ } else
297 + return -EINVAL;
298 +
299 + return count;
300 +@@ -1667,9 +1675,7 @@ static const struct file_operations topology_ops = {
301 +
302 + static int topology_update_init(void)
303 + {
304 +- /* Do not poll for changes if disabled at boot */
305 +- if (topology_updates_enabled)
306 +- start_topology_update();
307 ++ start_topology_update();
308 +
309 + if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
310 + return -ENOMEM;
311 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
312 +index b5226a009973..2996a1d0a410 100644
313 +--- a/arch/x86/Makefile
314 ++++ b/arch/x86/Makefile
315 +@@ -47,7 +47,7 @@ export REALMODE_CFLAGS
316 + export BITS
317 +
318 + ifdef CONFIG_X86_NEED_RELOCS
319 +- LDFLAGS_vmlinux := --emit-relocs
320 ++ LDFLAGS_vmlinux := --emit-relocs --discard-none
321 + endif
322 +
323 + #
324 +diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
325 +index cb13c0564ea7..9978ea4382bf 100644
326 +--- a/arch/x86/ia32/ia32_signal.c
327 ++++ b/arch/x86/ia32/ia32_signal.c
328 +@@ -60,9 +60,8 @@
329 + } while (0)
330 +
331 + #define RELOAD_SEG(seg) { \
332 +- unsigned int pre = GET_SEG(seg); \
333 ++ unsigned int pre = (seg) | 3; \
334 + unsigned int cur = get_user_seg(seg); \
335 +- pre |= 3; \
336 + if (pre != cur) \
337 + set_user_seg(seg, pre); \
338 + }
339 +@@ -71,6 +70,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
340 + struct sigcontext_32 __user *sc)
341 + {
342 + unsigned int tmpflags, err = 0;
343 ++ u16 gs, fs, es, ds;
344 + void __user *buf;
345 + u32 tmp;
346 +
347 +@@ -78,16 +78,10 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
348 + current->restart_block.fn = do_no_restart_syscall;
349 +
350 + get_user_try {
351 +- /*
352 +- * Reload fs and gs if they have changed in the signal
353 +- * handler. This does not handle long fs/gs base changes in
354 +- * the handler, but does not clobber them at least in the
355 +- * normal case.
356 +- */
357 +- RELOAD_SEG(gs);
358 +- RELOAD_SEG(fs);
359 +- RELOAD_SEG(ds);
360 +- RELOAD_SEG(es);
361 ++ gs = GET_SEG(gs);
362 ++ fs = GET_SEG(fs);
363 ++ ds = GET_SEG(ds);
364 ++ es = GET_SEG(es);
365 +
366 + COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
367 + COPY(dx); COPY(cx); COPY(ip); COPY(ax);
368 +@@ -105,6 +99,17 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
369 + buf = compat_ptr(tmp);
370 + } get_user_catch(err);
371 +
372 ++ /*
373 ++ * Reload fs and gs if they have changed in the signal
374 ++ * handler. This does not handle long fs/gs base changes in
375 ++ * the handler, but does not clobber them at least in the
376 ++ * normal case.
377 ++ */
378 ++ RELOAD_SEG(gs);
379 ++ RELOAD_SEG(fs);
380 ++ RELOAD_SEG(ds);
381 ++ RELOAD_SEG(es);
382 ++
383 + err |= fpu__restore_sig(buf, 1);
384 +
385 + force_iret();
386 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
387 +index d9ad49ca3cbe..e348bee411e3 100644
388 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
389 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
390 +@@ -673,20 +673,50 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
391 +
392 + barrier();
393 + m.status = mce_rdmsrl(msr_ops.status(i));
394 ++
395 ++ /* If this entry is not valid, ignore it */
396 + if (!(m.status & MCI_STATUS_VAL))
397 + continue;
398 +
399 +
400 + /*
401 +- * Uncorrected or signalled events are handled by the exception
402 +- * handler when it is enabled, so don't process those here.
403 +- *
404 +- * TBD do the same check for MCI_STATUS_EN here?
405 ++ * If we are logging everything (at CPU online) or this
406 ++ * is a corrected error, then we must log it.
407 + */
408 +- if (!(flags & MCP_UC) &&
409 +- (m.status & (mca_cfg.ser ? MCI_STATUS_S : MCI_STATUS_UC)))
410 +- continue;
411 ++ if ((flags & MCP_UC) || !(m.status & MCI_STATUS_UC))
412 ++ goto log_it;
413 ++
414 ++ /*
415 ++ * Newer Intel systems that support software error
416 ++ * recovery need to make additional checks. Other
417 ++ * CPUs should skip over uncorrected errors, but log
418 ++ * everything else.
419 ++ */
420 ++ if (!mca_cfg.ser) {
421 ++ if (m.status & MCI_STATUS_UC)
422 ++ continue;
423 ++ goto log_it;
424 ++ }
425 ++
426 ++ /* Log "not enabled" (speculative) errors */
427 ++ if (!(m.status & MCI_STATUS_EN))
428 ++ goto log_it;
429 ++
430 ++ /*
431 ++ * Log UCNA (SDM: 15.6.3 "UCR Error Classification")
432 ++ * UC == 1 && PCC == 0 && S == 0
433 ++ */
434 ++ if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S))
435 ++ goto log_it;
436 ++
437 ++ /*
438 ++ * Skip anything else. Presumption is that our read of this
439 ++ * bank is racing with a machine check. Leave the log alone
440 ++ * for do_machine_check() to deal with it.
441 ++ */
442 ++ continue;
443 +
444 ++log_it:
445 + error_seen = true;
446 +
447 + mce_read_aux(&m, i);
448 +diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
449 +index bcd1b82c86e8..005e9a77a664 100644
450 +--- a/arch/x86/kernel/irq_64.c
451 ++++ b/arch/x86/kernel/irq_64.c
452 +@@ -25,9 +25,18 @@ int sysctl_panic_on_stackoverflow;
453 + /*
454 + * Probabilistic stack overflow check:
455 + *
456 +- * Only check the stack in process context, because everything else
457 +- * runs on the big interrupt stacks. Checking reliably is too expensive,
458 +- * so we just check from interrupts.
459 ++ * Regular device interrupts can enter on the following stacks:
460 ++ *
461 ++ * - User stack
462 ++ *
463 ++ * - Kernel task stack
464 ++ *
465 ++ * - Interrupt stack if a device driver reenables interrupts
466 ++ * which should only happen in really old drivers.
467 ++ *
468 ++ * - Debug IST stack
469 ++ *
470 ++ * All other contexts are invalid.
471 + */
472 + static inline void stack_overflow_check(struct pt_regs *regs)
473 + {
474 +@@ -52,8 +61,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
475 + return;
476 +
477 + oist = this_cpu_ptr(&orig_ist);
478 +- estack_top = (u64)oist->ist[0] - EXCEPTION_STKSZ + STACK_TOP_MARGIN;
479 +- estack_bottom = (u64)oist->ist[N_EXCEPTION_STACKS - 1];
480 ++ estack_bottom = (u64)oist->ist[DEBUG_STACK];
481 ++ estack_top = estack_bottom - DEBUG_STKSZ + STACK_TOP_MARGIN;
482 + if (regs->sp >= estack_top && regs->sp <= estack_bottom)
483 + return;
484 +
485 +diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
486 +index b1a5d252d482..ca010dfb9682 100644
487 +--- a/arch/x86/kernel/signal.c
488 ++++ b/arch/x86/kernel/signal.c
489 +@@ -129,16 +129,6 @@ static int restore_sigcontext(struct pt_regs *regs,
490 + COPY_SEG_CPL3(cs);
491 + COPY_SEG_CPL3(ss);
492 +
493 +-#ifdef CONFIG_X86_64
494 +- /*
495 +- * Fix up SS if needed for the benefit of old DOSEMU and
496 +- * CRIU.
497 +- */
498 +- if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) &&
499 +- user_64bit_mode(regs)))
500 +- force_valid_ss(regs);
501 +-#endif
502 +-
503 + get_user_ex(tmpflags, &sc->flags);
504 + regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
505 + regs->orig_ax = -1; /* disable syscall checks */
506 +@@ -147,6 +137,15 @@ static int restore_sigcontext(struct pt_regs *regs,
507 + buf = (void __user *)buf_val;
508 + } get_user_catch(err);
509 +
510 ++#ifdef CONFIG_X86_64
511 ++ /*
512 ++ * Fix up SS if needed for the benefit of old DOSEMU and
513 ++ * CRIU.
514 ++ */
515 ++ if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && user_64bit_mode(regs)))
516 ++ force_valid_ss(regs);
517 ++#endif
518 ++
519 + err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
520 +
521 + force_iret();
522 +@@ -458,6 +457,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
523 + {
524 + struct rt_sigframe __user *frame;
525 + void __user *fp = NULL;
526 ++ unsigned long uc_flags;
527 + int err = 0;
528 +
529 + frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
530 +@@ -470,9 +470,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
531 + return -EFAULT;
532 + }
533 +
534 ++ uc_flags = frame_uc_flags(regs);
535 ++
536 + put_user_try {
537 + /* Create the ucontext. */
538 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
539 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
540 + put_user_ex(0, &frame->uc.uc_link);
541 + save_altstack_ex(&frame->uc.uc_stack, regs->sp);
542 +
543 +@@ -538,6 +540,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
544 + {
545 + #ifdef CONFIG_X86_X32_ABI
546 + struct rt_sigframe_x32 __user *frame;
547 ++ unsigned long uc_flags;
548 + void __user *restorer;
549 + int err = 0;
550 + void __user *fpstate = NULL;
551 +@@ -552,9 +555,11 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
552 + return -EFAULT;
553 + }
554 +
555 ++ uc_flags = frame_uc_flags(regs);
556 ++
557 + put_user_try {
558 + /* Create the ucontext. */
559 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
560 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
561 + put_user_ex(0, &frame->uc.uc_link);
562 + compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
563 + put_user_ex(0, &frame->uc.uc__pad0);
564 +diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
565 +index 55f04875293f..51b772f9d886 100644
566 +--- a/arch/x86/kernel/vmlinux.lds.S
567 ++++ b/arch/x86/kernel/vmlinux.lds.S
568 +@@ -111,11 +111,11 @@ SECTIONS
569 + *(.text.__x86.indirect_thunk)
570 + __indirect_thunk_end = .;
571 + #endif
572 +-
573 +- /* End of text section */
574 +- _etext = .;
575 + } :text = 0x9090
576 +
577 ++ /* End of text section */
578 ++ _etext = .;
579 ++
580 + NOTES :text :note
581 +
582 + EXCEPTION_TABLE(16) :text = 0x9090
583 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
584 +index 9338136a6a23..f7a7b98b3271 100644
585 +--- a/arch/x86/kvm/svm.c
586 ++++ b/arch/x86/kvm/svm.c
587 +@@ -1518,7 +1518,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
588 + if (!kvm_vcpu_apicv_active(vcpu))
589 + return;
590 +
591 +- if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT))
592 ++ /*
593 ++ * Since the host physical APIC id is 8 bits,
594 ++ * we can support host APIC ID upto 255.
595 ++ */
596 ++ if (WARN_ON(h_physical_id > AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
597 + return;
598 +
599 + entry = READ_ONCE(*(svm->avic_physical_id_cache));
600 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
601 +index 1f32c4e32a00..72efecc4288b 100644
602 +--- a/arch/x86/kvm/x86.c
603 ++++ b/arch/x86/kvm/x86.c
604 +@@ -1109,7 +1109,7 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
605 + u64 efer = msr_info->data;
606 +
607 + if (efer & efer_reserved_bits)
608 +- return false;
609 ++ return 1;
610 +
611 + if (!msr_info->host_initiated) {
612 + if (!__kvm_valid_efer(vcpu, efer))
613 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
614 +index 5c419b8f99a0..c140198d9fa5 100644
615 +--- a/arch/x86/mm/fault.c
616 ++++ b/arch/x86/mm/fault.c
617 +@@ -430,8 +430,6 @@ static noinline int vmalloc_fault(unsigned long address)
618 + if (!(address >= VMALLOC_START && address < VMALLOC_END))
619 + return -1;
620 +
621 +- WARN_ON_ONCE(in_nmi());
622 +-
623 + /*
624 + * Copy kernel mappings over when needed. This can also
625 + * happen within a race in page table update. In the later
626 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
627 +index 98517216879d..a2714890fe43 100644
628 +--- a/drivers/base/power/main.c
629 ++++ b/drivers/base/power/main.c
630 +@@ -1383,6 +1383,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
631 + if (dev->power.syscore)
632 + goto Complete;
633 +
634 ++ /* Avoid direct_complete to let wakeup_path propagate. */
635 ++ if (device_may_wakeup(dev) || dev->power.wakeup_path)
636 ++ dev->power.direct_complete = false;
637 ++
638 + if (dev->power.direct_complete) {
639 + if (pm_runtime_status_suspended(dev)) {
640 + pm_runtime_disable(dev);
641 +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
642 +index 8c0017d48571..800ced0a5a24 100644
643 +--- a/drivers/char/virtio_console.c
644 ++++ b/drivers/char/virtio_console.c
645 +@@ -75,7 +75,7 @@ struct ports_driver_data {
646 + /* All the console devices handled by this driver */
647 + struct list_head consoles;
648 + };
649 +-static struct ports_driver_data pdrvdata;
650 ++static struct ports_driver_data pdrvdata = { .next_vtermno = 1};
651 +
652 + static DEFINE_SPINLOCK(pdrvdata_lock);
653 + static DECLARE_COMPLETION(early_console_added);
654 +@@ -1425,6 +1425,7 @@ static int add_port(struct ports_device *portdev, u32 id)
655 + port->async_queue = NULL;
656 +
657 + port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
658 ++ port->cons.vtermno = 0;
659 +
660 + port->host_connected = port->guest_connected = false;
661 + port->stats = (struct port_stats) { 0 };
662 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
663 +index a38a23f0b3f4..e917521a3ef9 100644
664 +--- a/drivers/cpufreq/cpufreq.c
665 ++++ b/drivers/cpufreq/cpufreq.c
666 +@@ -1065,6 +1065,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
667 + cpufreq_global_kobject, "policy%u", cpu);
668 + if (ret) {
669 + pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
670 ++ kobject_put(&policy->kobj);
671 + goto err_free_real_cpus;
672 + }
673 +
674 +diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
675 +index 38d1a8216084..32c9524a6ec5 100644
676 +--- a/drivers/cpufreq/cpufreq_governor.c
677 ++++ b/drivers/cpufreq/cpufreq_governor.c
678 +@@ -449,6 +449,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
679 + /* Failure, so roll back. */
680 + pr_err("initialization failed (dbs_data kobject init error %d)\n", ret);
681 +
682 ++ kobject_put(&dbs_data->attr_set.kobj);
683 ++
684 + policy->governor_data = NULL;
685 +
686 + if (!have_governor_per_policy())
687 +diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
688 +index 35dd4d7ffee0..58c933f48300 100644
689 +--- a/drivers/cpufreq/pasemi-cpufreq.c
690 ++++ b/drivers/cpufreq/pasemi-cpufreq.c
691 +@@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
692 +
693 + cpu = of_get_cpu_node(policy->cpu, NULL);
694 +
695 ++ of_node_put(cpu);
696 + if (!cpu)
697 + goto out;
698 +
699 +diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
700 +index ff44016ea031..641f8021855a 100644
701 +--- a/drivers/cpufreq/pmac32-cpufreq.c
702 ++++ b/drivers/cpufreq/pmac32-cpufreq.c
703 +@@ -551,6 +551,7 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
704 + volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
705 + if (volt_gpio_np)
706 + voltage_gpio = read_gpio(volt_gpio_np);
707 ++ of_node_put(volt_gpio_np);
708 + if (!voltage_gpio){
709 + pr_err("missing cpu-vcore-select gpio\n");
710 + return 1;
711 +@@ -587,6 +588,7 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
712 + if (volt_gpio_np)
713 + voltage_gpio = read_gpio(volt_gpio_np);
714 +
715 ++ of_node_put(volt_gpio_np);
716 + pvr = mfspr(SPRN_PVR);
717 + has_cpu_l2lve = !((pvr & 0xf00) == 0x100);
718 +
719 +diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
720 +index 5a4c5a639f61..2eaeebcc93af 100644
721 +--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
722 ++++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
723 +@@ -86,6 +86,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
724 + if (!cbe_get_cpu_pmd_regs(policy->cpu) ||
725 + !cbe_get_cpu_mic_tm_regs(policy->cpu)) {
726 + pr_info("invalid CBE regs pointers for cpufreq\n");
727 ++ of_node_put(cpu);
728 + return -EINVAL;
729 + }
730 +
731 +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
732 +index 0de2f62d51ff..ec16ec2e284d 100644
733 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
734 ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
735 +@@ -250,7 +250,10 @@ static int sun4i_hash(struct ahash_request *areq)
736 + }
737 + } else {
738 + /* Since we have the flag final, we can go up to modulo 4 */
739 +- end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
740 ++ if (areq->nbytes < 4)
741 ++ end = 0;
742 ++ else
743 ++ end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
744 + }
745 +
746 + /* TODO if SGlen % 4 and op->len == 0 then DMA */
747 +diff --git a/drivers/crypto/vmx/aesp8-ppc.pl b/drivers/crypto/vmx/aesp8-ppc.pl
748 +index d9281a28818d..930a3f1e3ec0 100644
749 +--- a/drivers/crypto/vmx/aesp8-ppc.pl
750 ++++ b/drivers/crypto/vmx/aesp8-ppc.pl
751 +@@ -1318,7 +1318,7 @@ Loop_ctr32_enc:
752 + addi $idx,$idx,16
753 + bdnz Loop_ctr32_enc
754 +
755 +- vadduwm $ivec,$ivec,$one
756 ++ vadduqm $ivec,$ivec,$one
757 + vmr $dat,$inptail
758 + lvx $inptail,0,$inp
759 + addi $inp,$inp,16
760 +diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
761 +index b222dd7afe8e..12d904829324 100644
762 +--- a/drivers/dma/at_xdmac.c
763 ++++ b/drivers/dma/at_xdmac.c
764 +@@ -1608,7 +1608,11 @@ static void at_xdmac_tasklet(unsigned long data)
765 + struct at_xdmac_desc,
766 + xfer_node);
767 + dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
768 +- BUG_ON(!desc->active_xfer);
769 ++ if (!desc->active_xfer) {
770 ++ dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
771 ++ spin_unlock_bh(&atchan->lock);
772 ++ return;
773 ++ }
774 +
775 + txd = &desc->tx_dma_desc;
776 +
777 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
778 +index 6d7e3cd4aba4..57b375d0de29 100644
779 +--- a/drivers/dma/pl330.c
780 ++++ b/drivers/dma/pl330.c
781 +@@ -1020,6 +1020,7 @@ static void _stop(struct pl330_thread *thrd)
782 + {
783 + void __iomem *regs = thrd->dmac->base;
784 + u8 insn[6] = {0, 0, 0, 0, 0, 0};
785 ++ u32 inten = readl(regs + INTEN);
786 +
787 + if (_state(thrd) == PL330_STATE_FAULT_COMPLETING)
788 + UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING);
789 +@@ -1032,10 +1033,13 @@ static void _stop(struct pl330_thread *thrd)
790 +
791 + _emit_KILL(0, insn);
792 +
793 +- /* Stop generating interrupts for SEV */
794 +- writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN);
795 +-
796 + _execute_DBGINSN(thrd, insn, is_manager(thrd));
797 ++
798 ++ /* clear the event */
799 ++ if (inten & (1 << thrd->ev))
800 ++ writel(1 << thrd->ev, regs + INTCLR);
801 ++ /* Stop generating interrupts for SEV */
802 ++ writel(inten & ~(1 << thrd->ev), regs + INTEN);
803 + }
804 +
805 + /* Start doing req 'idx' of thread 'thrd' */
806 +diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
807 +index b10cbaa82ff5..e9e46a520745 100644
808 +--- a/drivers/dma/tegra210-adma.c
809 ++++ b/drivers/dma/tegra210-adma.c
810 +@@ -22,7 +22,6 @@
811 + #include <linux/of_device.h>
812 + #include <linux/of_dma.h>
813 + #include <linux/of_irq.h>
814 +-#include <linux/pm_clock.h>
815 + #include <linux/pm_runtime.h>
816 + #include <linux/slab.h>
817 +
818 +@@ -141,6 +140,7 @@ struct tegra_adma {
819 + struct dma_device dma_dev;
820 + struct device *dev;
821 + void __iomem *base_addr;
822 ++ struct clk *ahub_clk;
823 + unsigned int nr_channels;
824 + unsigned long rx_requests_reserved;
825 + unsigned long tx_requests_reserved;
826 +@@ -637,8 +637,9 @@ static int tegra_adma_runtime_suspend(struct device *dev)
827 + struct tegra_adma *tdma = dev_get_drvdata(dev);
828 +
829 + tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD);
830 ++ clk_disable_unprepare(tdma->ahub_clk);
831 +
832 +- return pm_clk_suspend(dev);
833 ++ return 0;
834 + }
835 +
836 + static int tegra_adma_runtime_resume(struct device *dev)
837 +@@ -646,10 +647,11 @@ static int tegra_adma_runtime_resume(struct device *dev)
838 + struct tegra_adma *tdma = dev_get_drvdata(dev);
839 + int ret;
840 +
841 +- ret = pm_clk_resume(dev);
842 +- if (ret)
843 ++ ret = clk_prepare_enable(tdma->ahub_clk);
844 ++ if (ret) {
845 ++ dev_err(dev, "ahub clk_enable failed: %d\n", ret);
846 + return ret;
847 +-
848 ++ }
849 + tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd);
850 +
851 + return 0;
852 +@@ -692,13 +694,11 @@ static int tegra_adma_probe(struct platform_device *pdev)
853 + if (IS_ERR(tdma->base_addr))
854 + return PTR_ERR(tdma->base_addr);
855 +
856 +- ret = pm_clk_create(&pdev->dev);
857 +- if (ret)
858 +- return ret;
859 +-
860 +- ret = of_pm_clk_add_clk(&pdev->dev, "d_audio");
861 +- if (ret)
862 +- goto clk_destroy;
863 ++ tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio");
864 ++ if (IS_ERR(tdma->ahub_clk)) {
865 ++ dev_err(&pdev->dev, "Error: Missing ahub controller clock\n");
866 ++ return PTR_ERR(tdma->ahub_clk);
867 ++ }
868 +
869 + pm_runtime_enable(&pdev->dev);
870 +
871 +@@ -775,8 +775,6 @@ rpm_put:
872 + pm_runtime_put_sync(&pdev->dev);
873 + rpm_disable:
874 + pm_runtime_disable(&pdev->dev);
875 +-clk_destroy:
876 +- pm_clk_destroy(&pdev->dev);
877 +
878 + return ret;
879 + }
880 +@@ -786,6 +784,7 @@ static int tegra_adma_remove(struct platform_device *pdev)
881 + struct tegra_adma *tdma = platform_get_drvdata(pdev);
882 + int i;
883 +
884 ++ of_dma_controller_free(pdev->dev.of_node);
885 + dma_async_device_unregister(&tdma->dma_dev);
886 +
887 + for (i = 0; i < tdma->nr_channels; ++i)
888 +@@ -793,7 +792,6 @@ static int tegra_adma_remove(struct platform_device *pdev)
889 +
890 + pm_runtime_put_sync(&pdev->dev);
891 + pm_runtime_disable(&pdev->dev);
892 +- pm_clk_destroy(&pdev->dev);
893 +
894 + return 0;
895 + }
896 +diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
897 +index 56e6c4c7c60d..4c0b6df8b5dd 100644
898 +--- a/drivers/extcon/extcon-arizona.c
899 ++++ b/drivers/extcon/extcon-arizona.c
900 +@@ -1684,6 +1684,16 @@ static int arizona_extcon_remove(struct platform_device *pdev)
901 + struct arizona_extcon_info *info = platform_get_drvdata(pdev);
902 + struct arizona *arizona = info->arizona;
903 + int jack_irq_rise, jack_irq_fall;
904 ++ bool change;
905 ++
906 ++ regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
907 ++ ARIZONA_MICD_ENA, 0,
908 ++ &change);
909 ++
910 ++ if (change) {
911 ++ regulator_disable(info->micvdd);
912 ++ pm_runtime_put(info->dev);
913 ++ }
914 +
915 + gpiod_put(info->micd_pol_gpio);
916 +
917 +diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
918 +index c37b7b5f1dd3..921f7f690ae9 100644
919 +--- a/drivers/gpu/drm/drm_fops.c
920 ++++ b/drivers/gpu/drm/drm_fops.c
921 +@@ -515,6 +515,7 @@ put_back_event:
922 + file_priv->event_space -= length;
923 + list_add(&e->link, &file_priv->event_list);
924 + spin_unlock_irq(&dev->event_lock);
925 ++ wake_up_interruptible(&file_priv->event_wait);
926 + break;
927 + }
928 +
929 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
930 +index 70597854397f..ceb4df96e0d5 100644
931 +--- a/drivers/hid/hid-core.c
932 ++++ b/drivers/hid/hid-core.c
933 +@@ -200,13 +200,14 @@ static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
934 + * Add a usage to the temporary parser table.
935 + */
936 +
937 +-static int hid_add_usage(struct hid_parser *parser, unsigned usage)
938 ++static int hid_add_usage(struct hid_parser *parser, unsigned usage, u8 size)
939 + {
940 + if (parser->local.usage_index >= HID_MAX_USAGES) {
941 + hid_err(parser->device, "usage index exceeded\n");
942 + return -1;
943 + }
944 + parser->local.usage[parser->local.usage_index] = usage;
945 ++ parser->local.usage_size[parser->local.usage_index] = size;
946 + parser->local.collection_index[parser->local.usage_index] =
947 + parser->collection_stack_ptr ?
948 + parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
949 +@@ -463,10 +464,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
950 + return 0;
951 + }
952 +
953 +- if (item->size <= 2)
954 +- data = (parser->global.usage_page << 16) + data;
955 +-
956 +- return hid_add_usage(parser, data);
957 ++ return hid_add_usage(parser, data, item->size);
958 +
959 + case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
960 +
961 +@@ -475,9 +473,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
962 + return 0;
963 + }
964 +
965 +- if (item->size <= 2)
966 +- data = (parser->global.usage_page << 16) + data;
967 +-
968 + parser->local.usage_minimum = data;
969 + return 0;
970 +
971 +@@ -488,9 +483,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
972 + return 0;
973 + }
974 +
975 +- if (item->size <= 2)
976 +- data = (parser->global.usage_page << 16) + data;
977 +-
978 + count = data - parser->local.usage_minimum;
979 + if (count + parser->local.usage_index >= HID_MAX_USAGES) {
980 + /*
981 +@@ -510,7 +502,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
982 + }
983 +
984 + for (n = parser->local.usage_minimum; n <= data; n++)
985 +- if (hid_add_usage(parser, n)) {
986 ++ if (hid_add_usage(parser, n, item->size)) {
987 + dbg_hid("hid_add_usage failed\n");
988 + return -1;
989 + }
990 +@@ -524,6 +516,22 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
991 + return 0;
992 + }
993 +
994 ++/*
995 ++ * Concatenate Usage Pages into Usages where relevant:
996 ++ * As per specification, 6.2.2.8: "When the parser encounters a main item it
997 ++ * concatenates the last declared Usage Page with a Usage to form a complete
998 ++ * usage value."
999 ++ */
1000 ++
1001 ++static void hid_concatenate_usage_page(struct hid_parser *parser)
1002 ++{
1003 ++ int i;
1004 ++
1005 ++ for (i = 0; i < parser->local.usage_index; i++)
1006 ++ if (parser->local.usage_size[i] <= 2)
1007 ++ parser->local.usage[i] += parser->global.usage_page << 16;
1008 ++}
1009 ++
1010 + /*
1011 + * Process a main item.
1012 + */
1013 +@@ -533,6 +541,8 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
1014 + __u32 data;
1015 + int ret;
1016 +
1017 ++ hid_concatenate_usage_page(parser);
1018 ++
1019 + data = item_udata(item);
1020 +
1021 + switch (item->tag) {
1022 +@@ -746,6 +756,8 @@ static int hid_scan_main(struct hid_parser *parser, struct hid_item *item)
1023 + __u32 data;
1024 + int i;
1025 +
1026 ++ hid_concatenate_usage_page(parser);
1027 ++
1028 + data = item_udata(item);
1029 +
1030 + switch (item->tag) {
1031 +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
1032 +index 3198faf5cff4..38d9deb03d16 100644
1033 +--- a/drivers/hid/hid-logitech-hidpp.c
1034 ++++ b/drivers/hid/hid-logitech-hidpp.c
1035 +@@ -449,13 +449,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
1036 +
1037 + static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1038 + {
1039 ++ const u8 ping_byte = 0x5a;
1040 ++ u8 ping_data[3] = { 0, 0, ping_byte };
1041 + struct hidpp_report response;
1042 + int ret;
1043 +
1044 +- ret = hidpp_send_fap_command_sync(hidpp,
1045 ++ ret = hidpp_send_rap_command_sync(hidpp,
1046 ++ REPORT_ID_HIDPP_SHORT,
1047 + HIDPP_PAGE_ROOT_IDX,
1048 + CMD_ROOT_GET_PROTOCOL_VERSION,
1049 +- NULL, 0, &response);
1050 ++ ping_data, sizeof(ping_data), &response);
1051 +
1052 + if (ret == HIDPP_ERROR_INVALID_SUBID) {
1053 + hidpp->protocol_major = 1;
1054 +@@ -475,8 +478,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1055 + if (ret)
1056 + return ret;
1057 +
1058 +- hidpp->protocol_major = response.fap.params[0];
1059 +- hidpp->protocol_minor = response.fap.params[1];
1060 ++ if (response.rap.params[2] != ping_byte) {
1061 ++ hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n",
1062 ++ __func__, response.rap.params[2], ping_byte);
1063 ++ return -EPROTO;
1064 ++ }
1065 ++
1066 ++ hidpp->protocol_major = response.rap.params[0];
1067 ++ hidpp->protocol_minor = response.rap.params[1];
1068 +
1069 + return ret;
1070 + }
1071 +diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
1072 +index facd05cda26d..e8c089886427 100644
1073 +--- a/drivers/hwmon/f71805f.c
1074 ++++ b/drivers/hwmon/f71805f.c
1075 +@@ -96,17 +96,23 @@ superio_select(int base, int ld)
1076 + outb(ld, base + 1);
1077 + }
1078 +
1079 +-static inline void
1080 ++static inline int
1081 + superio_enter(int base)
1082 + {
1083 ++ if (!request_muxed_region(base, 2, DRVNAME))
1084 ++ return -EBUSY;
1085 ++
1086 + outb(0x87, base);
1087 + outb(0x87, base);
1088 ++
1089 ++ return 0;
1090 + }
1091 +
1092 + static inline void
1093 + superio_exit(int base)
1094 + {
1095 + outb(0xaa, base);
1096 ++ release_region(base, 2);
1097 + }
1098 +
1099 + /*
1100 +@@ -1561,7 +1567,7 @@ exit:
1101 + static int __init f71805f_find(int sioaddr, unsigned short *address,
1102 + struct f71805f_sio_data *sio_data)
1103 + {
1104 +- int err = -ENODEV;
1105 ++ int err;
1106 + u16 devid;
1107 +
1108 + static const char * const names[] = {
1109 +@@ -1569,8 +1575,11 @@ static int __init f71805f_find(int sioaddr, unsigned short *address,
1110 + "F71872F/FG or F71806F/FG",
1111 + };
1112 +
1113 +- superio_enter(sioaddr);
1114 ++ err = superio_enter(sioaddr);
1115 ++ if (err)
1116 ++ return err;
1117 +
1118 ++ err = -ENODEV;
1119 + devid = superio_inw(sioaddr, SIO_REG_MANID);
1120 + if (devid != SIO_FINTEK_ID)
1121 + goto exit;
1122 +diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
1123 +index cb9fdd37bd0d..2b5b8c3de8fc 100644
1124 +--- a/drivers/hwmon/pc87427.c
1125 ++++ b/drivers/hwmon/pc87427.c
1126 +@@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
1127 + #define LD_IN 1
1128 + #define LD_TEMP 1
1129 +
1130 ++static inline int superio_enter(int sioaddr)
1131 ++{
1132 ++ if (!request_muxed_region(sioaddr, 2, DRVNAME))
1133 ++ return -EBUSY;
1134 ++ return 0;
1135 ++}
1136 ++
1137 + static inline void superio_outb(int sioaddr, int reg, int val)
1138 + {
1139 + outb(reg, sioaddr);
1140 +@@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
1141 + {
1142 + outb(0x02, sioaddr);
1143 + outb(0x02, sioaddr + 1);
1144 ++ release_region(sioaddr, 2);
1145 + }
1146 +
1147 + /*
1148 +@@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
1149 + {
1150 + u16 val;
1151 + u8 cfg, cfg_b;
1152 +- int i, err = 0;
1153 ++ int i, err;
1154 ++
1155 ++ err = superio_enter(sioaddr);
1156 ++ if (err)
1157 ++ return err;
1158 +
1159 + /* Identify device */
1160 + val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);
1161 +diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
1162 +index 6bd200756560..cbdb5c4991ae 100644
1163 +--- a/drivers/hwmon/smsc47b397.c
1164 ++++ b/drivers/hwmon/smsc47b397.c
1165 +@@ -72,14 +72,19 @@ static inline void superio_select(int ld)
1166 + superio_outb(0x07, ld);
1167 + }
1168 +
1169 +-static inline void superio_enter(void)
1170 ++static inline int superio_enter(void)
1171 + {
1172 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1173 ++ return -EBUSY;
1174 ++
1175 + outb(0x55, REG);
1176 ++ return 0;
1177 + }
1178 +
1179 + static inline void superio_exit(void)
1180 + {
1181 + outb(0xAA, REG);
1182 ++ release_region(REG, 2);
1183 + }
1184 +
1185 + #define SUPERIO_REG_DEVID 0x20
1186 +@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
1187 + u8 id, rev;
1188 + char *name;
1189 + unsigned short addr;
1190 ++ int err;
1191 ++
1192 ++ err = superio_enter();
1193 ++ if (err)
1194 ++ return err;
1195 +
1196 +- superio_enter();
1197 + id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1198 +
1199 + switch (id) {
1200 +diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
1201 +index 5d323186d2c1..d24df0c50bea 100644
1202 +--- a/drivers/hwmon/smsc47m1.c
1203 ++++ b/drivers/hwmon/smsc47m1.c
1204 +@@ -73,16 +73,21 @@ superio_inb(int reg)
1205 + /* logical device for fans is 0x0A */
1206 + #define superio_select() superio_outb(0x07, 0x0A)
1207 +
1208 +-static inline void
1209 ++static inline int
1210 + superio_enter(void)
1211 + {
1212 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1213 ++ return -EBUSY;
1214 ++
1215 + outb(0x55, REG);
1216 ++ return 0;
1217 + }
1218 +
1219 + static inline void
1220 + superio_exit(void)
1221 + {
1222 + outb(0xAA, REG);
1223 ++ release_region(REG, 2);
1224 + }
1225 +
1226 + #define SUPERIO_REG_ACT 0x30
1227 +@@ -531,8 +536,12 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1228 + {
1229 + u8 val;
1230 + unsigned short addr;
1231 ++ int err;
1232 ++
1233 ++ err = superio_enter();
1234 ++ if (err)
1235 ++ return err;
1236 +
1237 +- superio_enter();
1238 + val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1239 +
1240 + /*
1241 +@@ -608,13 +617,14 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1242 + static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
1243 + {
1244 + if ((sio_data->activate & 0x01) == 0) {
1245 +- superio_enter();
1246 +- superio_select();
1247 +-
1248 +- pr_info("Disabling device\n");
1249 +- superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1250 +-
1251 +- superio_exit();
1252 ++ if (!superio_enter()) {
1253 ++ superio_select();
1254 ++ pr_info("Disabling device\n");
1255 ++ superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1256 ++ superio_exit();
1257 ++ } else {
1258 ++ pr_warn("Failed to disable device\n");
1259 ++ }
1260 + }
1261 + }
1262 +
1263 +diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
1264 +index 3a6bfa51cb94..95d5e8ec8b7f 100644
1265 +--- a/drivers/hwmon/vt1211.c
1266 ++++ b/drivers/hwmon/vt1211.c
1267 +@@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
1268 + outb(ldn, sio_cip + 1);
1269 + }
1270 +
1271 +-static inline void superio_enter(int sio_cip)
1272 ++static inline int superio_enter(int sio_cip)
1273 + {
1274 ++ if (!request_muxed_region(sio_cip, 2, DRVNAME))
1275 ++ return -EBUSY;
1276 ++
1277 + outb(0x87, sio_cip);
1278 + outb(0x87, sio_cip);
1279 ++
1280 ++ return 0;
1281 + }
1282 +
1283 + static inline void superio_exit(int sio_cip)
1284 + {
1285 + outb(0xaa, sio_cip);
1286 ++ release_region(sio_cip, 2);
1287 + }
1288 +
1289 + /* ---------------------------------------------------------------------
1290 +@@ -1282,11 +1288,14 @@ EXIT:
1291 +
1292 + static int __init vt1211_find(int sio_cip, unsigned short *address)
1293 + {
1294 +- int err = -ENODEV;
1295 ++ int err;
1296 + int devid;
1297 +
1298 +- superio_enter(sio_cip);
1299 ++ err = superio_enter(sio_cip);
1300 ++ if (err)
1301 ++ return err;
1302 +
1303 ++ err = -ENODEV;
1304 + devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
1305 + if (devid != SIO_VT1211_ID)
1306 + goto EXIT;
1307 +diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
1308 +index a1d072ecb717..30f200ad6b97 100644
1309 +--- a/drivers/iio/adc/ad_sigma_delta.c
1310 ++++ b/drivers/iio/adc/ad_sigma_delta.c
1311 +@@ -62,7 +62,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
1312 + struct spi_transfer t = {
1313 + .tx_buf = data,
1314 + .len = size + 1,
1315 +- .cs_change = sigma_delta->bus_locked,
1316 ++ .cs_change = sigma_delta->keep_cs_asserted,
1317 + };
1318 + struct spi_message m;
1319 + int ret;
1320 +@@ -217,6 +217,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1321 +
1322 + spi_bus_lock(sigma_delta->spi->master);
1323 + sigma_delta->bus_locked = true;
1324 ++ sigma_delta->keep_cs_asserted = true;
1325 + reinit_completion(&sigma_delta->completion);
1326 +
1327 + ret = ad_sigma_delta_set_mode(sigma_delta, mode);
1328 +@@ -234,9 +235,10 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1329 + ret = 0;
1330 + }
1331 + out:
1332 ++ sigma_delta->keep_cs_asserted = false;
1333 ++ ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1334 + sigma_delta->bus_locked = false;
1335 + spi_bus_unlock(sigma_delta->spi->master);
1336 +- ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1337 +
1338 + return ret;
1339 + }
1340 +@@ -288,6 +290,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1341 +
1342 + spi_bus_lock(sigma_delta->spi->master);
1343 + sigma_delta->bus_locked = true;
1344 ++ sigma_delta->keep_cs_asserted = true;
1345 + reinit_completion(&sigma_delta->completion);
1346 +
1347 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_SINGLE);
1348 +@@ -297,9 +300,6 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1349 + ret = wait_for_completion_interruptible_timeout(
1350 + &sigma_delta->completion, HZ);
1351 +
1352 +- sigma_delta->bus_locked = false;
1353 +- spi_bus_unlock(sigma_delta->spi->master);
1354 +-
1355 + if (ret == 0)
1356 + ret = -EIO;
1357 + if (ret < 0)
1358 +@@ -315,7 +315,10 @@ out:
1359 + sigma_delta->irq_dis = true;
1360 + }
1361 +
1362 ++ sigma_delta->keep_cs_asserted = false;
1363 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1364 ++ sigma_delta->bus_locked = false;
1365 ++ spi_bus_unlock(sigma_delta->spi->master);
1366 + mutex_unlock(&indio_dev->mlock);
1367 +
1368 + if (ret)
1369 +@@ -352,6 +355,8 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
1370 +
1371 + spi_bus_lock(sigma_delta->spi->master);
1372 + sigma_delta->bus_locked = true;
1373 ++ sigma_delta->keep_cs_asserted = true;
1374 ++
1375 + ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS);
1376 + if (ret)
1377 + goto err_unlock;
1378 +@@ -380,6 +385,7 @@ static int ad_sd_buffer_postdisable(struct iio_dev *indio_dev)
1379 + sigma_delta->irq_dis = true;
1380 + }
1381 +
1382 ++ sigma_delta->keep_cs_asserted = false;
1383 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1384 +
1385 + sigma_delta->bus_locked = false;
1386 +diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
1387 +index a3ae165f8d9f..16180e6321bd 100644
1388 +--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
1389 ++++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
1390 +@@ -80,7 +80,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
1391 + unsigned int len, int64_t timestamp)
1392 + {
1393 + __le32 time;
1394 +- int64_t calculated_time;
1395 ++ int64_t calculated_time = 0;
1396 + struct ssp_sensor_data *spd = iio_priv(indio_dev);
1397 +
1398 + if (indio_dev->scan_bytes == 0)
1399 +diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
1400 +index 3de7f4426ac4..86abba5827a2 100644
1401 +--- a/drivers/iio/magnetometer/hmc5843_i2c.c
1402 ++++ b/drivers/iio/magnetometer/hmc5843_i2c.c
1403 +@@ -58,8 +58,13 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
1404 + static int hmc5843_i2c_probe(struct i2c_client *cli,
1405 + const struct i2c_device_id *id)
1406 + {
1407 ++ struct regmap *regmap = devm_regmap_init_i2c(cli,
1408 ++ &hmc5843_i2c_regmap_config);
1409 ++ if (IS_ERR(regmap))
1410 ++ return PTR_ERR(regmap);
1411 ++
1412 + return hmc5843_common_probe(&cli->dev,
1413 +- devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
1414 ++ regmap,
1415 + id->driver_data, id->name);
1416 + }
1417 +
1418 +diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
1419 +index 535f03a70d63..79b2b707f90e 100644
1420 +--- a/drivers/iio/magnetometer/hmc5843_spi.c
1421 ++++ b/drivers/iio/magnetometer/hmc5843_spi.c
1422 +@@ -58,6 +58,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = {
1423 + static int hmc5843_spi_probe(struct spi_device *spi)
1424 + {
1425 + int ret;
1426 ++ struct regmap *regmap;
1427 + const struct spi_device_id *id = spi_get_device_id(spi);
1428 +
1429 + spi->mode = SPI_MODE_3;
1430 +@@ -67,8 +68,12 @@ static int hmc5843_spi_probe(struct spi_device *spi)
1431 + if (ret)
1432 + return ret;
1433 +
1434 ++ regmap = devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config);
1435 ++ if (IS_ERR(regmap))
1436 ++ return PTR_ERR(regmap);
1437 ++
1438 + return hmc5843_common_probe(&spi->dev,
1439 +- devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
1440 ++ regmap,
1441 + id->driver_data, id->name);
1442 + }
1443 +
1444 +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
1445 +index a2322b2dbd82..e5752352e0fb 100644
1446 +--- a/drivers/infiniband/hw/cxgb4/cm.c
1447 ++++ b/drivers/infiniband/hw/cxgb4/cm.c
1448 +@@ -455,6 +455,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp)
1449 + skb_reset_transport_header(skb);
1450 + } else {
1451 + skb = alloc_skb(len, gfp);
1452 ++ if (!skb)
1453 ++ return NULL;
1454 + }
1455 + t4_set_arp_err_handler(skb, NULL, NULL);
1456 + return skb;
1457 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
1458 +index dd344ee9e62b..ebacd21714ef 100644
1459 +--- a/drivers/md/bcache/alloc.c
1460 ++++ b/drivers/md/bcache/alloc.c
1461 +@@ -322,10 +322,11 @@ static int bch_allocator_thread(void *arg)
1462 + * possibly issue discards to them, then we add the bucket to
1463 + * the free list:
1464 + */
1465 +- while (!fifo_empty(&ca->free_inc)) {
1466 ++ while (1) {
1467 + long bucket;
1468 +
1469 +- fifo_pop(&ca->free_inc, bucket);
1470 ++ if (!fifo_pop(&ca->free_inc, bucket))
1471 ++ break;
1472 +
1473 + if (ca->discard) {
1474 + mutex_unlock(&ca->set->bucket_lock);
1475 +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
1476 +index c76a0176b5c6..6ee5370eb916 100644
1477 +--- a/drivers/md/bcache/journal.c
1478 ++++ b/drivers/md/bcache/journal.c
1479 +@@ -309,6 +309,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list)
1480 + }
1481 + }
1482 +
1483 ++bool is_discard_enabled(struct cache_set *s)
1484 ++{
1485 ++ struct cache *ca;
1486 ++ unsigned int i;
1487 ++
1488 ++ for_each_cache(ca, s, i)
1489 ++ if (ca->discard)
1490 ++ return true;
1491 ++
1492 ++ return false;
1493 ++}
1494 ++
1495 + int bch_journal_replay(struct cache_set *s, struct list_head *list)
1496 + {
1497 + int ret = 0, keys = 0, entries = 0;
1498 +@@ -322,9 +334,17 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
1499 + list_for_each_entry(i, list, list) {
1500 + BUG_ON(i->pin && atomic_read(i->pin) != 1);
1501 +
1502 +- cache_set_err_on(n != i->j.seq, s,
1503 +-"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
1504 +- n, i->j.seq - 1, start, end);
1505 ++ if (n != i->j.seq) {
1506 ++ if (n == start && is_discard_enabled(s))
1507 ++ pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)",
1508 ++ n, i->j.seq - 1, start, end);
1509 ++ else {
1510 ++ pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
1511 ++ n, i->j.seq - 1, start, end);
1512 ++ ret = -EIO;
1513 ++ goto err;
1514 ++ }
1515 ++ }
1516 +
1517 + for (k = i->j.start;
1518 + k < bset_bkey_last(&i->j);
1519 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
1520 +index 362efc8dd16f..9f2588eaaf5f 100644
1521 +--- a/drivers/md/bcache/super.c
1522 ++++ b/drivers/md/bcache/super.c
1523 +@@ -1561,7 +1561,7 @@ err:
1524 + return NULL;
1525 + }
1526 +
1527 +-static void run_cache_set(struct cache_set *c)
1528 ++static int run_cache_set(struct cache_set *c)
1529 + {
1530 + const char *err = "cannot allocate memory";
1531 + struct cached_dev *dc, *t;
1532 +@@ -1653,7 +1653,9 @@ static void run_cache_set(struct cache_set *c)
1533 + if (j->version < BCACHE_JSET_VERSION_UUID)
1534 + __uuid_write(c);
1535 +
1536 +- bch_journal_replay(c, &journal);
1537 ++ err = "bcache: replay journal failed";
1538 ++ if (bch_journal_replay(c, &journal))
1539 ++ goto err;
1540 + } else {
1541 + pr_notice("invalidating existing data");
1542 +
1543 +@@ -1721,11 +1723,13 @@ static void run_cache_set(struct cache_set *c)
1544 + flash_devs_run(c);
1545 +
1546 + set_bit(CACHE_SET_RUNNING, &c->flags);
1547 +- return;
1548 ++ return 0;
1549 + err:
1550 + closure_sync(&cl);
1551 + /* XXX: test this, it's broken */
1552 + bch_cache_set_error(c, "%s", err);
1553 ++
1554 ++ return -EIO;
1555 + }
1556 +
1557 + static bool can_attach_cache(struct cache *ca, struct cache_set *c)
1558 +@@ -1789,8 +1793,11 @@ found:
1559 + ca->set->cache[ca->sb.nr_this_dev] = ca;
1560 + c->cache_by_alloc[c->caches_loaded++] = ca;
1561 +
1562 +- if (c->caches_loaded == c->sb.nr_in_set)
1563 +- run_cache_set(c);
1564 ++ if (c->caches_loaded == c->sb.nr_in_set) {
1565 ++ err = "failed to run cache set";
1566 ++ if (run_cache_set(c) < 0)
1567 ++ goto err;
1568 ++ }
1569 +
1570 + return NULL;
1571 + err:
1572 +diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
1573 +index 31f16105184c..59a4563c0466 100644
1574 +--- a/drivers/media/dvb-frontends/m88ds3103.c
1575 ++++ b/drivers/media/dvb-frontends/m88ds3103.c
1576 +@@ -309,6 +309,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
1577 + u16 u16tmp;
1578 + u32 tuner_frequency_khz, target_mclk;
1579 + s32 s32tmp;
1580 ++ static const struct reg_sequence reset_buf[] = {
1581 ++ {0x07, 0x80}, {0x07, 0x00}
1582 ++ };
1583 +
1584 + dev_dbg(&client->dev,
1585 + "delivery_system=%d modulation=%d frequency=%u symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n",
1586 +@@ -321,11 +324,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
1587 + }
1588 +
1589 + /* reset */
1590 +- ret = regmap_write(dev->regmap, 0x07, 0x80);
1591 +- if (ret)
1592 +- goto err;
1593 +-
1594 +- ret = regmap_write(dev->regmap, 0x07, 0x00);
1595 ++ ret = regmap_multi_reg_write(dev->regmap, reset_buf, 2);
1596 + if (ret)
1597 + goto err;
1598 +
1599 +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
1600 +index 1f999e9c0118..3554eea77e04 100644
1601 +--- a/drivers/media/i2c/ov2659.c
1602 ++++ b/drivers/media/i2c/ov2659.c
1603 +@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
1604 + if (ov2659_formats[index].code == mf->code)
1605 + break;
1606 +
1607 +- if (index < 0)
1608 +- return -EINVAL;
1609 ++ if (index < 0) {
1610 ++ index = 0;
1611 ++ mf->code = ov2659_formats[index].code;
1612 ++ }
1613 +
1614 + mf->colorspace = V4L2_COLORSPACE_SRGB;
1615 + mf->code = ov2659_formats[index].code;
1616 +diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
1617 +index e21b7e1c2ee1..fc187c5aeb1e 100644
1618 +--- a/drivers/media/i2c/soc_camera/ov6650.c
1619 ++++ b/drivers/media/i2c/soc_camera/ov6650.c
1620 +@@ -840,9 +840,16 @@ static int ov6650_video_probe(struct i2c_client *client)
1621 + u8 pidh, pidl, midh, midl;
1622 + int ret;
1623 +
1624 ++ priv->clk = v4l2_clk_get(&client->dev, NULL);
1625 ++ if (IS_ERR(priv->clk)) {
1626 ++ ret = PTR_ERR(priv->clk);
1627 ++ dev_err(&client->dev, "v4l2_clk request err: %d\n", ret);
1628 ++ return ret;
1629 ++ }
1630 ++
1631 + ret = ov6650_s_power(&priv->subdev, 1);
1632 + if (ret < 0)
1633 +- return ret;
1634 ++ goto eclkput;
1635 +
1636 + msleep(20);
1637 +
1638 +@@ -879,6 +886,11 @@ static int ov6650_video_probe(struct i2c_client *client)
1639 +
1640 + done:
1641 + ov6650_s_power(&priv->subdev, 0);
1642 ++ if (!ret)
1643 ++ return 0;
1644 ++eclkput:
1645 ++ v4l2_clk_put(priv->clk);
1646 ++
1647 + return ret;
1648 + }
1649 +
1650 +@@ -1035,18 +1047,9 @@ static int ov6650_probe(struct i2c_client *client,
1651 + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
1652 + priv->colorspace = V4L2_COLORSPACE_JPEG;
1653 +
1654 +- priv->clk = v4l2_clk_get(&client->dev, NULL);
1655 +- if (IS_ERR(priv->clk)) {
1656 +- ret = PTR_ERR(priv->clk);
1657 +- goto eclkget;
1658 +- }
1659 +-
1660 + ret = ov6650_video_probe(client);
1661 +- if (ret) {
1662 +- v4l2_clk_put(priv->clk);
1663 +-eclkget:
1664 ++ if (ret)
1665 + v4l2_ctrl_handler_free(&priv->hdl);
1666 +- }
1667 +
1668 + return ret;
1669 + }
1670 +diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
1671 +index c889ec9f8a5a..f5fc8bcbd14b 100644
1672 +--- a/drivers/media/pci/saa7146/hexium_gemini.c
1673 ++++ b/drivers/media/pci/saa7146/hexium_gemini.c
1674 +@@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
1675 + /* enable i2c-port pins */
1676 + saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
1677 +
1678 +- hexium->i2c_adapter = (struct i2c_adapter) {
1679 +- .name = "hexium gemini",
1680 +- };
1681 ++ strscpy(hexium->i2c_adapter.name, "hexium gemini",
1682 ++ sizeof(hexium->i2c_adapter.name));
1683 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
1684 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
1685 + DEB_S("cannot register i2c-device. skipping.\n");
1686 +diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
1687 +index c306a92e8909..dc07ca37ebd0 100644
1688 +--- a/drivers/media/pci/saa7146/hexium_orion.c
1689 ++++ b/drivers/media/pci/saa7146/hexium_orion.c
1690 +@@ -232,9 +232,8 @@ static int hexium_probe(struct saa7146_dev *dev)
1691 + saa7146_write(dev, DD1_STREAM_B, 0x00000000);
1692 + saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
1693 +
1694 +- hexium->i2c_adapter = (struct i2c_adapter) {
1695 +- .name = "hexium orion",
1696 +- };
1697 ++ strscpy(hexium->i2c_adapter.name, "hexium orion",
1698 ++ sizeof(hexium->i2c_adapter.name));
1699 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
1700 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
1701 + DEB_S("cannot register i2c-device. skipping.\n");
1702 +diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
1703 +index b6625047250d..717ee9a6a80e 100644
1704 +--- a/drivers/media/platform/coda/coda-bit.c
1705 ++++ b/drivers/media/platform/coda/coda-bit.c
1706 +@@ -1829,6 +1829,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
1707 + /* Clear decode success flag */
1708 + coda_write(dev, 0, CODA_RET_DEC_PIC_SUCCESS);
1709 +
1710 ++ /* Clear error return value */
1711 ++ coda_write(dev, 0, CODA_RET_DEC_PIC_ERR_MB);
1712 ++
1713 + trace_coda_dec_pic_run(ctx, meta);
1714 +
1715 + coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
1716 +diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
1717 +index 25d4fd4f4c0b..a72982df4777 100644
1718 +--- a/drivers/media/platform/vivid/vivid-vid-cap.c
1719 ++++ b/drivers/media/platform/vivid/vivid-vid-cap.c
1720 +@@ -984,7 +984,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selection
1721 + v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect);
1722 + if (dev->bitmap_cap && (compose->width != s->r.width ||
1723 + compose->height != s->r.height)) {
1724 +- kfree(dev->bitmap_cap);
1725 ++ vfree(dev->bitmap_cap);
1726 + dev->bitmap_cap = NULL;
1727 + }
1728 + *compose = s->r;
1729 +diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
1730 +index 642b89c66bcb..c1457cf46698 100644
1731 +--- a/drivers/media/radio/wl128x/fmdrv_common.c
1732 ++++ b/drivers/media/radio/wl128x/fmdrv_common.c
1733 +@@ -494,7 +494,8 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload,
1734 + return -EIO;
1735 + }
1736 + /* Send response data to caller */
1737 +- if (response != NULL && response_len != NULL && evt_hdr->dlen) {
1738 ++ if (response != NULL && response_len != NULL && evt_hdr->dlen &&
1739 ++ evt_hdr->dlen <= payload_len) {
1740 + /* Skip header info and copy only response data */
1741 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
1742 + memcpy(response, skb->data, evt_hdr->dlen);
1743 +@@ -590,6 +591,8 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev)
1744 + return;
1745 +
1746 + fm_evt_hdr = (void *)skb->data;
1747 ++ if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag))
1748 ++ return;
1749 +
1750 + /* Skip header info and copy only response data */
1751 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
1752 +@@ -1315,7 +1318,7 @@ static int load_default_rx_configuration(struct fmdev *fmdev)
1753 + static int fm_power_up(struct fmdev *fmdev, u8 mode)
1754 + {
1755 + u16 payload;
1756 +- __be16 asic_id, asic_ver;
1757 ++ __be16 asic_id = 0, asic_ver = 0;
1758 + int resp_len, ret;
1759 + u8 fw_name[50];
1760 +
1761 +diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
1762 +index 85dd9a8e83ff..48eeb5a6a209 100644
1763 +--- a/drivers/media/usb/au0828/au0828-video.c
1764 ++++ b/drivers/media/usb/au0828/au0828-video.c
1765 +@@ -764,6 +764,9 @@ static int au0828_analog_stream_enable(struct au0828_dev *d)
1766 +
1767 + dprintk(1, "au0828_analog_stream_enable called\n");
1768 +
1769 ++ if (test_bit(DEV_DISCONNECTED, &d->dev_state))
1770 ++ return -ENODEV;
1771 ++
1772 + iface = usb_ifnum_to_if(d->usbdev, 0);
1773 + if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) {
1774 + dprintk(1, "Changing intf#0 to alt 5\n");
1775 +@@ -852,9 +855,9 @@ int au0828_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
1776 + return rc;
1777 + }
1778 +
1779 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1);
1780 ++
1781 + if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1782 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video,
1783 +- s_stream, 1);
1784 + dev->vid_timeout_running = 1;
1785 + mod_timer(&dev->vid_timeout, jiffies + (HZ / 10));
1786 + } else if (vq->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
1787 +@@ -874,10 +877,11 @@ static void au0828_stop_streaming(struct vb2_queue *vq)
1788 +
1789 + dprintk(1, "au0828_stop_streaming called %d\n", dev->streaming_users);
1790 +
1791 +- if (dev->streaming_users-- == 1)
1792 ++ if (dev->streaming_users-- == 1) {
1793 + au0828_uninit_isoc(dev);
1794 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
1795 ++ }
1796 +
1797 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
1798 + dev->vid_timeout_running = 0;
1799 + del_timer_sync(&dev->vid_timeout);
1800 +
1801 +@@ -906,8 +910,10 @@ void au0828_stop_vbi_streaming(struct vb2_queue *vq)
1802 + dprintk(1, "au0828_stop_vbi_streaming called %d\n",
1803 + dev->streaming_users);
1804 +
1805 +- if (dev->streaming_users-- == 1)
1806 ++ if (dev->streaming_users-- == 1) {
1807 + au0828_uninit_isoc(dev);
1808 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
1809 ++ }
1810 +
1811 + spin_lock_irqsave(&dev->slock, flags);
1812 + if (dev->isoc_ctl.vbi_buf != NULL) {
1813 +diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
1814 +index d793c630f1dd..05e7edb213de 100644
1815 +--- a/drivers/media/usb/cpia2/cpia2_v4l.c
1816 ++++ b/drivers/media/usb/cpia2/cpia2_v4l.c
1817 +@@ -1248,8 +1248,7 @@ static int __init cpia2_init(void)
1818 + LOG("%s v%s\n",
1819 + ABOUT, CPIA_VERSION);
1820 + check_parameters();
1821 +- cpia2_usb_init();
1822 +- return 0;
1823 ++ return cpia2_usb_init();
1824 + }
1825 +
1826 +
1827 +diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c
1828 +index 60bf5f0644d1..a5efcd4f7b4f 100644
1829 +--- a/drivers/media/usb/go7007/go7007-fw.c
1830 ++++ b/drivers/media/usb/go7007/go7007-fw.c
1831 +@@ -1499,8 +1499,8 @@ static int modet_to_package(struct go7007 *go, __le16 *code, int space)
1832 + return cnt;
1833 + }
1834 +
1835 +-static int do_special(struct go7007 *go, u16 type, __le16 *code, int space,
1836 +- int *framelen)
1837 ++static noinline_for_stack int do_special(struct go7007 *go, u16 type,
1838 ++ __le16 *code, int space, int *framelen)
1839 + {
1840 + switch (type) {
1841 + case SPECIAL_FRM_HEAD:
1842 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1843 +index 1eb4f7ba2967..ff489645e070 100644
1844 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1845 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1846 +@@ -670,6 +670,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
1847 +
1848 + static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
1849 + {
1850 ++ if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
1851 ++ return 0;
1852 + return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
1853 + }
1854 +
1855 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
1856 +index a82a00dd7329..80869990ffbb 100644
1857 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
1858 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
1859 +@@ -54,6 +54,7 @@
1860 + #define PVR2_CVAL_INPUT_COMPOSITE 2
1861 + #define PVR2_CVAL_INPUT_SVIDEO 3
1862 + #define PVR2_CVAL_INPUT_RADIO 4
1863 ++#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
1864 +
1865 + enum pvr2_config {
1866 + pvr2_config_empty, /* No configuration */
1867 +diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c
1868 +index adc9c0c614fb..4493c299d85e 100644
1869 +--- a/drivers/mmc/core/pwrseq_emmc.c
1870 ++++ b/drivers/mmc/core/pwrseq_emmc.c
1871 +@@ -30,19 +30,14 @@ struct mmc_pwrseq_emmc {
1872 +
1873 + #define to_pwrseq_emmc(p) container_of(p, struct mmc_pwrseq_emmc, pwrseq)
1874 +
1875 +-static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq)
1876 +-{
1877 +- gpiod_set_value(pwrseq->reset_gpio, 1);
1878 +- udelay(1);
1879 +- gpiod_set_value(pwrseq->reset_gpio, 0);
1880 +- udelay(200);
1881 +-}
1882 +-
1883 + static void mmc_pwrseq_emmc_reset(struct mmc_host *host)
1884 + {
1885 + struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(host->pwrseq);
1886 +
1887 +- __mmc_pwrseq_emmc_reset(pwrseq);
1888 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
1889 ++ udelay(1);
1890 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
1891 ++ udelay(200);
1892 + }
1893 +
1894 + static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
1895 +@@ -50,8 +45,11 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
1896 + {
1897 + struct mmc_pwrseq_emmc *pwrseq = container_of(this,
1898 + struct mmc_pwrseq_emmc, reset_nb);
1899 ++ gpiod_set_value(pwrseq->reset_gpio, 1);
1900 ++ udelay(1);
1901 ++ gpiod_set_value(pwrseq->reset_gpio, 0);
1902 ++ udelay(200);
1903 +
1904 +- __mmc_pwrseq_emmc_reset(pwrseq);
1905 + return NOTIFY_DONE;
1906 + }
1907 +
1908 +@@ -72,14 +70,18 @@ static int mmc_pwrseq_emmc_probe(struct platform_device *pdev)
1909 + if (IS_ERR(pwrseq->reset_gpio))
1910 + return PTR_ERR(pwrseq->reset_gpio);
1911 +
1912 +- /*
1913 +- * register reset handler to ensure emmc reset also from
1914 +- * emergency_reboot(), priority 255 is the highest priority
1915 +- * so it will be executed before any system reboot handler.
1916 +- */
1917 +- pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
1918 +- pwrseq->reset_nb.priority = 255;
1919 +- register_restart_handler(&pwrseq->reset_nb);
1920 ++ if (!gpiod_cansleep(pwrseq->reset_gpio)) {
1921 ++ /*
1922 ++ * register reset handler to ensure emmc reset also from
1923 ++ * emergency_reboot(), priority 255 is the highest priority
1924 ++ * so it will be executed before any system reboot handler.
1925 ++ */
1926 ++ pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
1927 ++ pwrseq->reset_nb.priority = 255;
1928 ++ register_restart_handler(&pwrseq->reset_nb);
1929 ++ } else {
1930 ++ dev_notice(dev, "EMMC reset pin tied to a sleepy GPIO driver; reset on emergency-reboot disabled\n");
1931 ++ }
1932 +
1933 + pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops;
1934 + pwrseq->pwrseq.dev = dev;
1935 +diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
1936 +index f09148a4ab55..00ba8807dafe 100644
1937 +--- a/drivers/mmc/core/sd.c
1938 ++++ b/drivers/mmc/core/sd.c
1939 +@@ -214,6 +214,14 @@ static int mmc_decode_scr(struct mmc_card *card)
1940 +
1941 + if (scr->sda_spec3)
1942 + scr->cmds = UNSTUFF_BITS(resp, 32, 2);
1943 ++
1944 ++ /* SD Spec says: any SD Card shall set at least bits 0 and 2 */
1945 ++ if (!(scr->bus_widths & SD_SCR_BUS_WIDTH_1) ||
1946 ++ !(scr->bus_widths & SD_SCR_BUS_WIDTH_4)) {
1947 ++ pr_err("%s: invalid bus width\n", mmc_hostname(card->host));
1948 ++ return -EINVAL;
1949 ++ }
1950 ++
1951 + return 0;
1952 + }
1953 +
1954 +diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
1955 +index 6224ad37fd80..c2df68e958b3 100644
1956 +--- a/drivers/mmc/host/mmc_spi.c
1957 ++++ b/drivers/mmc/host/mmc_spi.c
1958 +@@ -819,6 +819,10 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
1959 + }
1960 +
1961 + status = spi_sync_locked(spi, &host->m);
1962 ++ if (status < 0) {
1963 ++ dev_dbg(&spi->dev, "read error %d\n", status);
1964 ++ return status;
1965 ++ }
1966 +
1967 + if (host->dma_dev) {
1968 + dma_sync_single_for_cpu(host->dma_dev,
1969 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
1970 +index a51d636c2312..6f11cd95bb5f 100644
1971 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
1972 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
1973 +@@ -636,6 +636,11 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
1974 + if (esdhc->vendor_ver > VENDOR_V_22)
1975 + host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
1976 +
1977 ++ if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
1978 ++ host->quirks2 |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
1979 ++ host->quirks2 |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
1980 ++ }
1981 ++
1982 + if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
1983 + of_device_is_compatible(np, "fsl,p5020-esdhc") ||
1984 + of_device_is_compatible(np, "fsl,p4080-esdhc") ||
1985 +diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
1986 +index 0c298878bf46..0780900b37c7 100644
1987 +--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
1988 ++++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
1989 +@@ -2116,7 +2116,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
1990 +
1991 + host_info->os_type = ENA_ADMIN_OS_LINUX;
1992 + host_info->kernel_ver = LINUX_VERSION_CODE;
1993 +- strncpy(host_info->kernel_ver_str, utsname()->version,
1994 ++ strlcpy(host_info->kernel_ver_str, utsname()->version,
1995 + sizeof(host_info->kernel_ver_str) - 1);
1996 + host_info->os_dist = 0;
1997 + strncpy(host_info->os_dist_str, utsname()->release,
1998 +diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
1999 +index 8cffcdfd5678..38b5858c335a 100644
2000 +--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
2001 ++++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
2002 +@@ -75,8 +75,8 @@ struct l2t_data {
2003 + struct l2t_entry *rover; /* starting point for next allocation */
2004 + atomic_t nfree; /* number of free entries */
2005 + rwlock_t lock;
2006 +- struct l2t_entry l2tab[0];
2007 + struct rcu_head rcu_head; /* to handle rcu cleanup */
2008 ++ struct l2t_entry l2tab[];
2009 + };
2010 +
2011 + typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
2012 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2013 +index c71a52a2f801..5478a2ab45c4 100644
2014 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2015 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2016 +@@ -5203,15 +5203,24 @@ static int __init cxgb4_init_module(void)
2017 +
2018 + ret = pci_register_driver(&cxgb4_driver);
2019 + if (ret < 0)
2020 +- debugfs_remove(cxgb4_debugfs_root);
2021 ++ goto err_pci;
2022 +
2023 + #if IS_ENABLED(CONFIG_IPV6)
2024 + if (!inet6addr_registered) {
2025 +- register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
2026 +- inet6addr_registered = true;
2027 ++ ret = register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
2028 ++ if (ret)
2029 ++ pci_unregister_driver(&cxgb4_driver);
2030 ++ else
2031 ++ inet6addr_registered = true;
2032 + }
2033 + #endif
2034 +
2035 ++ if (ret == 0)
2036 ++ return ret;
2037 ++
2038 ++err_pci:
2039 ++ debugfs_remove(cxgb4_debugfs_root);
2040 ++
2041 + return ret;
2042 + }
2043 +
2044 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
2045 +index 7836072d3f63..886378c5334f 100644
2046 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
2047 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
2048 +@@ -2285,6 +2285,10 @@ void i40e_vlan_stripping_enable(struct i40e_vsi *vsi)
2049 + struct i40e_vsi_context ctxt;
2050 + i40e_status ret;
2051 +
2052 ++ /* Don't modify stripping options if a port VLAN is active */
2053 ++ if (vsi->info.pvid)
2054 ++ return;
2055 ++
2056 + if ((vsi->info.valid_sections &
2057 + cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
2058 + ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_MODE_MASK) == 0))
2059 +@@ -2315,6 +2319,10 @@ void i40e_vlan_stripping_disable(struct i40e_vsi *vsi)
2060 + struct i40e_vsi_context ctxt;
2061 + i40e_status ret;
2062 +
2063 ++ /* Don't modify stripping options if a port VLAN is active */
2064 ++ if (vsi->info.pvid)
2065 ++ return;
2066 ++
2067 + if ((vsi->info.valid_sections &
2068 + cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
2069 + ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_EMOD_MASK) ==
2070 +diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c b/drivers/net/wireless/atmel/at76c50x-usb.c
2071 +index 0e180677c7fc..09dbab464fe1 100644
2072 +--- a/drivers/net/wireless/atmel/at76c50x-usb.c
2073 ++++ b/drivers/net/wireless/atmel/at76c50x-usb.c
2074 +@@ -2583,8 +2583,8 @@ static int __init at76_mod_init(void)
2075 + if (result < 0)
2076 + printk(KERN_ERR DRIVER_NAME
2077 + ": usb_register failed (status %d)\n", result);
2078 +-
2079 +- led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
2080 ++ else
2081 ++ led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
2082 + return result;
2083 + }
2084 +
2085 +diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c b/drivers/net/wireless/broadcom/b43/phy_lp.c
2086 +index 6922cbb99a04..5a0699fb4b9a 100644
2087 +--- a/drivers/net/wireless/broadcom/b43/phy_lp.c
2088 ++++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
2089 +@@ -1834,7 +1834,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct lpphy_tx_gains gains,
2090 + static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
2091 + {
2092 + struct b43_phy_lp *lpphy = dev->phy.lp;
2093 +- struct lpphy_tx_gains gains, oldgains;
2094 ++ struct lpphy_tx_gains oldgains;
2095 + int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
2096 +
2097 + lpphy_read_tx_pctl_mode_from_hardware(dev);
2098 +@@ -1848,9 +1848,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
2099 + lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
2100 +
2101 + if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
2102 +- lpphy_papd_cal(dev, gains, 0, 1, 30);
2103 ++ lpphy_papd_cal(dev, oldgains, 0, 1, 30);
2104 + else
2105 +- lpphy_papd_cal(dev, gains, 0, 1, 65);
2106 ++ lpphy_papd_cal(dev, oldgains, 0, 1, 65);
2107 +
2108 + if (old_afe_ovr)
2109 + lpphy_set_tx_gains(dev, oldgains);
2110 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2111 +index 530f52120972..8f8fe6f2af5b 100644
2112 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2113 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2114 +@@ -5374,6 +5374,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
2115 + conn_info->req_ie =
2116 + kmemdup(cfg->extra_buf, conn_info->req_ie_len,
2117 + GFP_KERNEL);
2118 ++ if (!conn_info->req_ie)
2119 ++ conn_info->req_ie_len = 0;
2120 + } else {
2121 + conn_info->req_ie_len = 0;
2122 + conn_info->req_ie = NULL;
2123 +@@ -5390,6 +5392,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
2124 + conn_info->resp_ie =
2125 + kmemdup(cfg->extra_buf, conn_info->resp_ie_len,
2126 + GFP_KERNEL);
2127 ++ if (!conn_info->resp_ie)
2128 ++ conn_info->resp_ie_len = 0;
2129 + } else {
2130 + conn_info->resp_ie_len = 0;
2131 + conn_info->resp_ie = NULL;
2132 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2133 +index f877301c9454..ecfe056d7643 100644
2134 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2135 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2136 +@@ -685,17 +685,17 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
2137 + bool rtnl_locked)
2138 + {
2139 + struct brcmf_if *ifp;
2140 ++ int ifidx;
2141 +
2142 + ifp = drvr->iflist[bsscfgidx];
2143 +- drvr->iflist[bsscfgidx] = NULL;
2144 + if (!ifp) {
2145 + brcmf_err("Null interface, bsscfgidx=%d\n", bsscfgidx);
2146 + return;
2147 + }
2148 + brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", bsscfgidx,
2149 + ifp->ifidx);
2150 +- if (drvr->if2bss[ifp->ifidx] == bsscfgidx)
2151 +- drvr->if2bss[ifp->ifidx] = BRCMF_BSSIDX_INVALID;
2152 ++ ifidx = ifp->ifidx;
2153 ++
2154 + if (ifp->ndev) {
2155 + if (bsscfgidx == 0) {
2156 + if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
2157 +@@ -723,6 +723,10 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
2158 + brcmf_p2p_ifp_removed(ifp, rtnl_locked);
2159 + kfree(ifp);
2160 + }
2161 ++
2162 ++ drvr->iflist[bsscfgidx] = NULL;
2163 ++ if (drvr->if2bss[ifidx] == bsscfgidx)
2164 ++ drvr->if2bss[ifidx] = BRCMF_BSSIDX_INVALID;
2165 + }
2166 +
2167 + void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked)
2168 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2169 +index 053f3b59f21e..acf513fd9e6d 100644
2170 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2171 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2172 +@@ -157,7 +157,7 @@ struct brcmf_usbdev_info {
2173 +
2174 + struct usb_device *usbdev;
2175 + struct device *dev;
2176 +- struct mutex dev_init_lock;
2177 ++ struct completion dev_init_done;
2178 +
2179 + int ctl_in_pipe, ctl_out_pipe;
2180 + struct urb *ctl_urb; /* URB for control endpoint */
2181 +@@ -681,12 +681,18 @@ static int brcmf_usb_up(struct device *dev)
2182 +
2183 + static void brcmf_cancel_all_urbs(struct brcmf_usbdev_info *devinfo)
2184 + {
2185 ++ int i;
2186 ++
2187 + if (devinfo->ctl_urb)
2188 + usb_kill_urb(devinfo->ctl_urb);
2189 + if (devinfo->bulk_urb)
2190 + usb_kill_urb(devinfo->bulk_urb);
2191 +- brcmf_usb_free_q(&devinfo->tx_postq, true);
2192 +- brcmf_usb_free_q(&devinfo->rx_postq, true);
2193 ++ if (devinfo->tx_reqs)
2194 ++ for (i = 0; i < devinfo->bus_pub.ntxq; i++)
2195 ++ usb_kill_urb(devinfo->tx_reqs[i].urb);
2196 ++ if (devinfo->rx_reqs)
2197 ++ for (i = 0; i < devinfo->bus_pub.nrxq; i++)
2198 ++ usb_kill_urb(devinfo->rx_reqs[i].urb);
2199 + }
2200 +
2201 + static void brcmf_usb_down(struct device *dev)
2202 +@@ -1189,11 +1195,11 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
2203 + if (ret)
2204 + goto error;
2205 +
2206 +- mutex_unlock(&devinfo->dev_init_lock);
2207 ++ complete(&devinfo->dev_init_done);
2208 + return;
2209 + error:
2210 + brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), ret);
2211 +- mutex_unlock(&devinfo->dev_init_lock);
2212 ++ complete(&devinfo->dev_init_done);
2213 + device_release_driver(dev);
2214 + }
2215 +
2216 +@@ -1239,7 +1245,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
2217 + if (ret)
2218 + goto fail;
2219 + /* we are done */
2220 +- mutex_unlock(&devinfo->dev_init_lock);
2221 ++ complete(&devinfo->dev_init_done);
2222 + return 0;
2223 + }
2224 + bus->chip = bus_pub->devid;
2225 +@@ -1300,11 +1306,10 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
2226 +
2227 + devinfo->usbdev = usb;
2228 + devinfo->dev = &usb->dev;
2229 +- /* Take an init lock, to protect for disconnect while still loading.
2230 ++ /* Init completion, to protect for disconnect while still loading.
2231 + * Necessary because of the asynchronous firmware load construction
2232 + */
2233 +- mutex_init(&devinfo->dev_init_lock);
2234 +- mutex_lock(&devinfo->dev_init_lock);
2235 ++ init_completion(&devinfo->dev_init_done);
2236 +
2237 + usb_set_intfdata(intf, devinfo);
2238 +
2239 +@@ -1382,7 +1387,7 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
2240 + return 0;
2241 +
2242 + fail:
2243 +- mutex_unlock(&devinfo->dev_init_lock);
2244 ++ complete(&devinfo->dev_init_done);
2245 + kfree(devinfo);
2246 + usb_set_intfdata(intf, NULL);
2247 + return ret;
2248 +@@ -1397,7 +1402,7 @@ brcmf_usb_disconnect(struct usb_interface *intf)
2249 + devinfo = (struct brcmf_usbdev_info *)usb_get_intfdata(intf);
2250 +
2251 + if (devinfo) {
2252 +- mutex_lock(&devinfo->dev_init_lock);
2253 ++ wait_for_completion(&devinfo->dev_init_done);
2254 + /* Make sure that devinfo still exists. Firmware probe routines
2255 + * may have released the device and cleared the intfdata.
2256 + */
2257 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
2258 +index 8eff2753abad..d493021f6031 100644
2259 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
2260 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
2261 +@@ -35,9 +35,10 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,
2262 + struct brcmf_if *ifp;
2263 + const struct brcmf_vndr_dcmd_hdr *cmdhdr = data;
2264 + struct sk_buff *reply;
2265 +- int ret, payload, ret_len;
2266 ++ unsigned int payload, ret_len;
2267 + void *dcmd_buf = NULL, *wr_pointer;
2268 + u16 msglen, maxmsglen = PAGE_SIZE - 0x100;
2269 ++ int ret;
2270 +
2271 + if (len < sizeof(*cmdhdr)) {
2272 + brcmf_err("vendor command too short: %d\n", len);
2273 +@@ -65,7 +66,7 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,
2274 + brcmf_err("oversize return buffer %d\n", ret_len);
2275 + ret_len = BRCMF_DCMD_MAXLEN;
2276 + }
2277 +- payload = max(ret_len, len) + 1;
2278 ++ payload = max_t(unsigned int, ret_len, len) + 1;
2279 + dcmd_buf = vzalloc(payload);
2280 + if (NULL == dcmd_buf)
2281 + return -ENOMEM;
2282 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2283 +index c21f8bd32d08..25f2a0aceaa2 100644
2284 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2285 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2286 +@@ -1225,10 +1225,15 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
2287 + static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
2288 + {
2289 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2290 +- struct iwl_rxq *rxq = &trans_pcie->rxq[queue];
2291 ++ struct iwl_rxq *rxq;
2292 + u32 r, i, count = 0;
2293 + bool emergency = false;
2294 +
2295 ++ if (WARN_ON_ONCE(!trans_pcie->rxq || !trans_pcie->rxq[queue].bd))
2296 ++ return;
2297 ++
2298 ++ rxq = &trans_pcie->rxq[queue];
2299 ++
2300 + restart:
2301 + spin_lock(&rxq->lock);
2302 + /* uCode's read index (stored in shared DRAM) indicates the last Rx
2303 +diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
2304 +index 4da3541471e6..46d0099fd6e8 100644
2305 +--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
2306 ++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
2307 +@@ -4018,16 +4018,20 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
2308 +
2309 + if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd, true)) {
2310 + dev_err(priv->adapter->dev, "Failed to process hostcmd\n");
2311 ++ kfree(hostcmd);
2312 + return -EFAULT;
2313 + }
2314 +
2315 + /* process hostcmd response*/
2316 + skb = cfg80211_testmode_alloc_reply_skb(wiphy, hostcmd->len);
2317 +- if (!skb)
2318 ++ if (!skb) {
2319 ++ kfree(hostcmd);
2320 + return -ENOMEM;
2321 ++ }
2322 + err = nla_put(skb, MWIFIEX_TM_ATTR_DATA,
2323 + hostcmd->len, hostcmd->cmd);
2324 + if (err) {
2325 ++ kfree(hostcmd);
2326 + kfree_skb(skb);
2327 + return -EMSGSIZE;
2328 + }
2329 +diff --git a/drivers/net/wireless/marvell/mwifiex/cfp.c b/drivers/net/wireless/marvell/mwifiex/cfp.c
2330 +index 1ff22055e54f..9ddaa767ea74 100644
2331 +--- a/drivers/net/wireless/marvell/mwifiex/cfp.c
2332 ++++ b/drivers/net/wireless/marvell/mwifiex/cfp.c
2333 +@@ -533,5 +533,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
2334 + rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
2335 + rx_rate - 1 : rx_rate;
2336 +
2337 ++ if (rate_index >= MWIFIEX_MAX_AC_RX_RATES)
2338 ++ rate_index = MWIFIEX_MAX_AC_RX_RATES - 1;
2339 ++
2340 + return rate_index;
2341 + }
2342 +diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
2343 +index 4ac928bf1f8e..7de18ed10db8 100644
2344 +--- a/drivers/net/wireless/realtek/rtlwifi/base.c
2345 ++++ b/drivers/net/wireless/realtek/rtlwifi/base.c
2346 +@@ -466,6 +466,11 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
2347 + /* <2> work queue */
2348 + rtlpriv->works.hw = hw;
2349 + rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
2350 ++ if (unlikely(!rtlpriv->works.rtl_wq)) {
2351 ++ pr_err("Failed to allocate work queue\n");
2352 ++ return;
2353 ++ }
2354 ++
2355 + INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
2356 + (void *)rtl_watchdog_wq_callback);
2357 + INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
2358 +diff --git a/drivers/net/wireless/st/cw1200/main.c b/drivers/net/wireless/st/cw1200/main.c
2359 +index dc478cedbde0..84624c812a15 100644
2360 +--- a/drivers/net/wireless/st/cw1200/main.c
2361 ++++ b/drivers/net/wireless/st/cw1200/main.c
2362 +@@ -345,6 +345,11 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr,
2363 + mutex_init(&priv->wsm_cmd_mux);
2364 + mutex_init(&priv->conf_mutex);
2365 + priv->workqueue = create_singlethread_workqueue("cw1200_wq");
2366 ++ if (!priv->workqueue) {
2367 ++ ieee80211_free_hw(hw);
2368 ++ return NULL;
2369 ++ }
2370 ++
2371 + sema_init(&priv->scan.lock, 1);
2372 + INIT_WORK(&priv->scan.work, cw1200_scan_work);
2373 + INIT_DELAYED_WORK(&priv->scan.probe_work, cw1200_probe_work);
2374 +diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
2375 +index 66a089d561cf..9108004a0d9b 100644
2376 +--- a/drivers/nvdimm/label.c
2377 ++++ b/drivers/nvdimm/label.c
2378 +@@ -490,15 +490,26 @@ static unsigned long nd_label_offset(struct nvdimm_drvdata *ndd,
2379 + - (unsigned long) to_namespace_index(ndd, 0);
2380 + }
2381 +
2382 ++static void reap_victim(struct nd_mapping *nd_mapping,
2383 ++ struct nd_label_ent *victim)
2384 ++{
2385 ++ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
2386 ++ u32 slot = to_slot(ndd, victim->label);
2387 ++
2388 ++ dev_dbg(ndd->dev, "free: %d\n", slot);
2389 ++ nd_label_free_slot(ndd, slot);
2390 ++ victim->label = NULL;
2391 ++}
2392 ++
2393 + static int __pmem_label_update(struct nd_region *nd_region,
2394 + struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm,
2395 + int pos, unsigned long flags)
2396 + {
2397 + u64 cookie = nd_region_interleave_set_cookie(nd_region);
2398 + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
2399 +- struct nd_label_ent *label_ent, *victim = NULL;
2400 + struct nd_namespace_label *nd_label;
2401 + struct nd_namespace_index *nsindex;
2402 ++ struct nd_label_ent *label_ent;
2403 + struct nd_label_id label_id;
2404 + struct resource *res;
2405 + unsigned long *free;
2406 +@@ -551,18 +562,10 @@ static int __pmem_label_update(struct nd_region *nd_region,
2407 + list_for_each_entry(label_ent, &nd_mapping->labels, list) {
2408 + if (!label_ent->label)
2409 + continue;
2410 +- if (memcmp(nspm->uuid, label_ent->label->uuid,
2411 +- NSLABEL_UUID_LEN) != 0)
2412 +- continue;
2413 +- victim = label_ent;
2414 +- list_move_tail(&victim->list, &nd_mapping->labels);
2415 +- break;
2416 +- }
2417 +- if (victim) {
2418 +- dev_dbg(ndd->dev, "%s: free: %d\n", __func__, slot);
2419 +- slot = to_slot(ndd, victim->label);
2420 +- nd_label_free_slot(ndd, slot);
2421 +- victim->label = NULL;
2422 ++ if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)
2423 ++ || memcmp(nspm->uuid, label_ent->label->uuid,
2424 ++ NSLABEL_UUID_LEN) == 0)
2425 ++ reap_victim(nd_mapping, label_ent);
2426 + }
2427 +
2428 + /* update index */
2429 +diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
2430 +index cf4a90b50f8b..e83453e1b308 100644
2431 +--- a/drivers/nvdimm/namespace_devs.c
2432 ++++ b/drivers/nvdimm/namespace_devs.c
2433 +@@ -1210,12 +1210,27 @@ static int namespace_update_uuid(struct nd_region *nd_region,
2434 + for (i = 0; i < nd_region->ndr_mappings; i++) {
2435 + struct nd_mapping *nd_mapping = &nd_region->mapping[i];
2436 + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
2437 ++ struct nd_label_ent *label_ent;
2438 + struct resource *res;
2439 +
2440 + for_each_dpa_resource(ndd, res)
2441 + if (strcmp(res->name, old_label_id.id) == 0)
2442 + sprintf((void *) res->name, "%s",
2443 + new_label_id.id);
2444 ++
2445 ++ mutex_lock(&nd_mapping->lock);
2446 ++ list_for_each_entry(label_ent, &nd_mapping->labels, list) {
2447 ++ struct nd_namespace_label *nd_label = label_ent->label;
2448 ++ struct nd_label_id label_id;
2449 ++
2450 ++ if (!nd_label)
2451 ++ continue;
2452 ++ nd_label_gen_id(&label_id, nd_label->uuid,
2453 ++ __le32_to_cpu(nd_label->flags));
2454 ++ if (strcmp(old_label_id.id, label_id.id) == 0)
2455 ++ set_bit(ND_LABEL_REAP, &label_ent->flags);
2456 ++ }
2457 ++ mutex_unlock(&nd_mapping->lock);
2458 + }
2459 + kfree(*old_uuid);
2460 + out:
2461 +diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
2462 +index d869236b474f..bd29e598bac1 100644
2463 +--- a/drivers/nvdimm/nd.h
2464 ++++ b/drivers/nvdimm/nd.h
2465 +@@ -113,8 +113,12 @@ struct nd_percpu_lane {
2466 + spinlock_t lock;
2467 + };
2468 +
2469 ++enum nd_label_flags {
2470 ++ ND_LABEL_REAP,
2471 ++};
2472 + struct nd_label_ent {
2473 + struct list_head list;
2474 ++ unsigned long flags;
2475 + struct nd_namespace_label *label;
2476 + };
2477 +
2478 +diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
2479 +index 55375b1b3cc8..b2b7e238bda9 100644
2480 +--- a/drivers/pinctrl/pinctrl-pistachio.c
2481 ++++ b/drivers/pinctrl/pinctrl-pistachio.c
2482 +@@ -1368,6 +1368,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
2483 + if (!of_find_property(child, "gpio-controller", NULL)) {
2484 + dev_err(pctl->dev,
2485 + "No gpio-controller property for bank %u\n", i);
2486 ++ of_node_put(child);
2487 + ret = -ENODEV;
2488 + goto err;
2489 + }
2490 +@@ -1375,6 +1376,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
2491 + irq = irq_of_parse_and_map(child, 0);
2492 + if (irq < 0) {
2493 + dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
2494 ++ of_node_put(child);
2495 + ret = irq;
2496 + goto err;
2497 + }
2498 +diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
2499 +index 19e53b3b8e00..166faae3a59c 100644
2500 +--- a/drivers/rtc/rtc-88pm860x.c
2501 ++++ b/drivers/rtc/rtc-88pm860x.c
2502 +@@ -414,7 +414,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev)
2503 + struct pm860x_rtc_info *info = platform_get_drvdata(pdev);
2504 +
2505 + #ifdef VRTC_CALIBRATION
2506 +- flush_scheduled_work();
2507 ++ cancel_delayed_work_sync(&info->calib_work);
2508 + /* disable measurement */
2509 + pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
2510 + #endif /* VRTC_CALIBRATION */
2511 +diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
2512 +index f0e57aefb5f2..d167652a6a23 100644
2513 +--- a/drivers/s390/cio/cio.h
2514 ++++ b/drivers/s390/cio/cio.h
2515 +@@ -114,7 +114,7 @@ struct subchannel {
2516 + struct schib_config config;
2517 + } __attribute__ ((aligned(8)));
2518 +
2519 +-DECLARE_PER_CPU(struct irb, cio_irb);
2520 ++DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb);
2521 +
2522 + #define to_subchannel(n) container_of(n, struct subchannel, dev)
2523 +
2524 +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
2525 +index 1a6f65db615e..ee1f9ee995e5 100644
2526 +--- a/drivers/scsi/libsas/sas_expander.c
2527 ++++ b/drivers/scsi/libsas/sas_expander.c
2528 +@@ -2027,6 +2027,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
2529 + if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) {
2530 + phy->phy_state = PHY_EMPTY;
2531 + sas_unregister_devs_sas_addr(dev, phy_id, last);
2532 ++ /*
2533 ++ * Even though the PHY is empty, for convenience we discover
2534 ++ * the PHY to update the PHY info, like negotiated linkrate.
2535 ++ */
2536 ++ sas_ex_phy_discover(dev, phy_id);
2537 + return res;
2538 + } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
2539 + dev_type_flutter(type, phy->attached_dev_type)) {
2540 +diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
2541 +index 4ac03b16d17f..52afbcff362f 100644
2542 +--- a/drivers/scsi/lpfc/lpfc_ct.c
2543 ++++ b/drivers/scsi/lpfc/lpfc_ct.c
2544 +@@ -1561,6 +1561,9 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
2545 + ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
2546 + memset(ae, 0, 256);
2547 +
2548 ++ /* This string MUST be consistent with other FC platforms
2549 ++ * supported by Broadcom.
2550 ++ */
2551 + strncpy(ae->un.AttrString,
2552 + "Emulex Corporation",
2553 + sizeof(ae->un.AttrString));
2554 +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
2555 +index 81736457328a..9cca5ddbc50c 100644
2556 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
2557 ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
2558 +@@ -901,7 +901,11 @@ lpfc_linkdown(struct lpfc_hba *phba)
2559