Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Fri, 31 May 2019 16:41:34
Message-Id: 1559320867.44ac09cc56d587cf3dce78163ce613230680c0aa.mpagano@gentoo
1 commit: 44ac09cc56d587cf3dce78163ce613230680c0aa
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 31 16:41:07 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri May 31 16:41:07 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=44ac09cc
7
8 Linux patch 4.14.123
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1122_linux-4.14.123.patch | 5631 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 5635 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index ac52010..81872ea 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -531,6 +531,10 @@ Patch: 1121_4.14.122.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.122
23
24 +Patch: 1122_4.14.123.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.123
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/1122_linux-4.14.123.patch b/1122_linux-4.14.123.patch
33 new file mode 100644
34 index 0000000..504bbf4
35 --- /dev/null
36 +++ b/1122_linux-4.14.123.patch
37 @@ -0,0 +1,5631 @@
38 +diff --git a/Makefile b/Makefile
39 +index 0c4424292649..a8e8a53cc08b 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 122
47 ++SUBLEVEL = 123
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h
52 +index 07e27f212dc7..d2453e2d3f1f 100644
53 +--- a/arch/arm/include/asm/cp15.h
54 ++++ b/arch/arm/include/asm/cp15.h
55 +@@ -68,6 +68,8 @@
56 + #define BPIALL __ACCESS_CP15(c7, 0, c5, 6)
57 + #define ICIALLU __ACCESS_CP15(c7, 0, c5, 0)
58 +
59 ++#define CNTVCT __ACCESS_CP15_64(1, c14)
60 ++
61 + extern unsigned long cr_alignment; /* defined in entry-armv.S */
62 +
63 + static inline unsigned long get_cr(void)
64 +diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c
65 +index 79214d5ff097..3af02d2a0b7f 100644
66 +--- a/arch/arm/vdso/vgettimeofday.c
67 ++++ b/arch/arm/vdso/vgettimeofday.c
68 +@@ -18,9 +18,9 @@
69 + #include <linux/compiler.h>
70 + #include <linux/hrtimer.h>
71 + #include <linux/time.h>
72 +-#include <asm/arch_timer.h>
73 + #include <asm/barrier.h>
74 + #include <asm/bug.h>
75 ++#include <asm/cp15.h>
76 + #include <asm/page.h>
77 + #include <asm/unistd.h>
78 + #include <asm/vdso_datapage.h>
79 +@@ -123,7 +123,8 @@ static notrace u64 get_ns(struct vdso_data *vdata)
80 + u64 cycle_now;
81 + u64 nsec;
82 +
83 +- cycle_now = arch_counter_get_cntvct();
84 ++ isb();
85 ++ cycle_now = read_sysreg(CNTVCT);
86 +
87 + cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
88 +
89 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
90 +index aafea648a30f..ee77556b0124 100644
91 +--- a/arch/arm64/include/asm/pgtable.h
92 ++++ b/arch/arm64/include/asm/pgtable.h
93 +@@ -420,6 +420,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
94 + return pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK;
95 + }
96 +
97 ++static inline void pte_unmap(pte_t *pte) { }
98 ++
99 + /* Find an entry in the third-level page table. */
100 + #define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
101 +
102 +@@ -428,7 +430,6 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
103 +
104 + #define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
105 + #define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
106 +-#define pte_unmap(pte) do { } while (0)
107 + #define pte_unmap_nested(pte) do { } while (0)
108 +
109 + #define pte_set_fixmap(addr) ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
110 +diff --git a/arch/arm64/include/asm/vdso_datapage.h b/arch/arm64/include/asm/vdso_datapage.h
111 +index 2b9a63771eda..f89263c8e11a 100644
112 +--- a/arch/arm64/include/asm/vdso_datapage.h
113 ++++ b/arch/arm64/include/asm/vdso_datapage.h
114 +@@ -38,6 +38,7 @@ struct vdso_data {
115 + __u32 tz_minuteswest; /* Whacky timezone stuff */
116 + __u32 tz_dsttime;
117 + __u32 use_syscall;
118 ++ __u32 hrtimer_res;
119 + };
120 +
121 + #endif /* !__ASSEMBLY__ */
122 +diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
123 +index b5e43b01b396..b4a0f4ab770a 100644
124 +--- a/arch/arm64/kernel/asm-offsets.c
125 ++++ b/arch/arm64/kernel/asm-offsets.c
126 +@@ -95,7 +95,7 @@ int main(void)
127 + DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
128 + DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
129 + DEFINE(CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_RAW);
130 +- DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
131 ++ DEFINE(CLOCK_REALTIME_RES, offsetof(struct vdso_data, hrtimer_res));
132 + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
133 + DEFINE(CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE);
134 + DEFINE(CLOCK_COARSE_RES, LOW_RES_NSEC);
135 +diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
136 +index d16978213c5b..e2a9d04d0517 100644
137 +--- a/arch/arm64/kernel/cpu_ops.c
138 ++++ b/arch/arm64/kernel/cpu_ops.c
139 +@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)
140 + pr_err("%pOF: missing enable-method property\n",
141 + dn);
142 + }
143 ++ of_node_put(dn);
144 + } else {
145 + enable_method = acpi_get_enable_method(cpu);
146 + if (!enable_method) {
147 +diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
148 +index 2d419006ad43..ec0bb588d755 100644
149 +--- a/arch/arm64/kernel/vdso.c
150 ++++ b/arch/arm64/kernel/vdso.c
151 +@@ -232,6 +232,9 @@ void update_vsyscall(struct timekeeper *tk)
152 + vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
153 + vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
154 +
155 ++ /* Read without the seqlock held by clock_getres() */
156 ++ WRITE_ONCE(vdso_data->hrtimer_res, hrtimer_resolution);
157 ++
158 + if (!use_syscall) {
159 + /* tkr_mono.cycle_last == tkr_raw.cycle_last */
160 + vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last;
161 +diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
162 +index 76320e920965..df829c4346fa 100644
163 +--- a/arch/arm64/kernel/vdso/gettimeofday.S
164 ++++ b/arch/arm64/kernel/vdso/gettimeofday.S
165 +@@ -301,13 +301,14 @@ ENTRY(__kernel_clock_getres)
166 + ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne
167 + b.ne 1f
168 +
169 +- ldr x2, 5f
170 ++ adr vdso_data, _vdso_data
171 ++ ldr w2, [vdso_data, #CLOCK_REALTIME_RES]
172 + b 2f
173 + 1:
174 + cmp w0, #CLOCK_REALTIME_COARSE
175 + ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
176 + b.ne 4f
177 +- ldr x2, 6f
178 ++ ldr x2, 5f
179 + 2:
180 + cbz w1, 3f
181 + stp xzr, x2, [x1]
182 +@@ -321,8 +322,6 @@ ENTRY(__kernel_clock_getres)
183 + svc #0
184 + ret
185 + 5:
186 +- .quad CLOCK_REALTIME_RES
187 +-6:
188 + .quad CLOCK_COARSE_RES
189 + .cfi_endproc
190 + ENDPROC(__kernel_clock_getres)
191 +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
192 +index ba88b5b68db6..56c110844c01 100644
193 +--- a/arch/arm64/mm/dma-mapping.c
194 ++++ b/arch/arm64/mm/dma-mapping.c
195 +@@ -710,6 +710,11 @@ static int __iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
196 + if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
197 + return ret;
198 +
199 ++ if (!is_vmalloc_addr(cpu_addr)) {
200 ++ unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr));
201 ++ return __swiotlb_mmap_pfn(vma, pfn, size);
202 ++ }
203 ++
204 + if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
205 + /*
206 + * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,
207 +@@ -733,6 +738,11 @@ static int __iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
208 + unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
209 + struct vm_struct *area = find_vm_area(cpu_addr);
210 +
211 ++ if (!is_vmalloc_addr(cpu_addr)) {
212 ++ struct page *page = virt_to_page(cpu_addr);
213 ++ return __swiotlb_get_sgtable_page(sgt, page, size);
214 ++ }
215 ++
216 + if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
217 + /*
218 + * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,
219 +diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
220 +index 9d9f6f334d3c..3da3e2b1b51b 100644
221 +--- a/arch/powerpc/boot/addnote.c
222 ++++ b/arch/powerpc/boot/addnote.c
223 +@@ -223,7 +223,11 @@ main(int ac, char **av)
224 + PUT_16(E_PHNUM, np + 2);
225 +
226 + /* write back */
227 +- lseek(fd, (long) 0, SEEK_SET);
228 ++ i = lseek(fd, (long) 0, SEEK_SET);
229 ++ if (i < 0) {
230 ++ perror("lseek");
231 ++ exit(1);
232 ++ }
233 + i = write(fd, buf, n);
234 + if (i < 0) {
235 + perror("write");
236 +diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
237 +index ff8511d6d8ea..4f2e18266e34 100644
238 +--- a/arch/powerpc/kernel/head_64.S
239 ++++ b/arch/powerpc/kernel/head_64.S
240 +@@ -961,7 +961,9 @@ start_here_multiplatform:
241 +
242 + /* Restore parameters passed from prom_init/kexec */
243 + mr r3,r31
244 +- bl early_setup /* also sets r13 and SPRG_PACA */
245 ++ LOAD_REG_ADDR(r12, DOTSYM(early_setup))
246 ++ mtctr r12
247 ++ bctrl /* also sets r13 and SPRG_PACA */
248 +
249 + LOAD_REG_ADDR(r3, start_here_common)
250 + ld r4,PACAKMSR(r13)
251 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
252 +index 0a02c73a27b3..417ea6db7b1d 100644
253 +--- a/arch/powerpc/mm/numa.c
254 ++++ b/arch/powerpc/mm/numa.c
255 +@@ -1561,6 +1561,9 @@ int start_topology_update(void)
256 + {
257 + int rc = 0;
258 +
259 ++ if (!topology_updates_enabled)
260 ++ return 0;
261 ++
262 + if (firmware_has_feature(FW_FEATURE_PRRN)) {
263 + if (!prrn_enabled) {
264 + prrn_enabled = 1;
265 +@@ -1590,6 +1593,9 @@ int stop_topology_update(void)
266 + {
267 + int rc = 0;
268 +
269 ++ if (!topology_updates_enabled)
270 ++ return 0;
271 ++
272 + if (prrn_enabled) {
273 + prrn_enabled = 0;
274 + #ifdef CONFIG_SMP
275 +@@ -1635,11 +1641,13 @@ static ssize_t topology_write(struct file *file, const char __user *buf,
276 +
277 + kbuf[read_len] = '\0';
278 +
279 +- if (!strncmp(kbuf, "on", 2))
280 ++ if (!strncmp(kbuf, "on", 2)) {
281 ++ topology_updates_enabled = true;
282 + start_topology_update();
283 +- else if (!strncmp(kbuf, "off", 3))
284 ++ } else if (!strncmp(kbuf, "off", 3)) {
285 + stop_topology_update();
286 +- else
287 ++ topology_updates_enabled = false;
288 ++ } else
289 + return -EINVAL;
290 +
291 + return count;
292 +@@ -1654,9 +1662,7 @@ static const struct file_operations topology_ops = {
293 +
294 + static int topology_update_init(void)
295 + {
296 +- /* Do not poll for changes if disabled at boot */
297 +- if (topology_updates_enabled)
298 +- start_topology_update();
299 ++ start_topology_update();
300 +
301 + if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
302 + return -ENOMEM;
303 +diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
304 +index b73961b95c34..994e4392cac5 100644
305 +--- a/arch/powerpc/perf/imc-pmu.c
306 ++++ b/arch/powerpc/perf/imc-pmu.c
307 +@@ -481,6 +481,11 @@ static int nest_imc_event_init(struct perf_event *event)
308 + * Get the base memory addresss for this cpu.
309 + */
310 + chip_id = cpu_to_chip_id(event->cpu);
311 ++
312 ++ /* Return, if chip_id is not valid */
313 ++ if (chip_id < 0)
314 ++ return -ENODEV;
315 ++
316 + pcni = pmu->mem_info;
317 + do {
318 + if (pcni->id == chip_id) {
319 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
320 +index eb1f8f249dc3..b4c72da8a7ad 100644
321 +--- a/arch/x86/Makefile
322 ++++ b/arch/x86/Makefile
323 +@@ -48,7 +48,7 @@ export REALMODE_CFLAGS
324 + export BITS
325 +
326 + ifdef CONFIG_X86_NEED_RELOCS
327 +- LDFLAGS_vmlinux := --emit-relocs
328 ++ LDFLAGS_vmlinux := --emit-relocs --discard-none
329 + endif
330 +
331 + #
332 +diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
333 +index 41c671854642..789284d19b55 100644
334 +--- a/arch/x86/ia32/ia32_signal.c
335 ++++ b/arch/x86/ia32/ia32_signal.c
336 +@@ -62,9 +62,8 @@
337 + } while (0)
338 +
339 + #define RELOAD_SEG(seg) { \
340 +- unsigned int pre = GET_SEG(seg); \
341 ++ unsigned int pre = (seg) | 3; \
342 + unsigned int cur = get_user_seg(seg); \
343 +- pre |= 3; \
344 + if (pre != cur) \
345 + set_user_seg(seg, pre); \
346 + }
347 +@@ -73,6 +72,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
348 + struct sigcontext_32 __user *sc)
349 + {
350 + unsigned int tmpflags, err = 0;
351 ++ u16 gs, fs, es, ds;
352 + void __user *buf;
353 + u32 tmp;
354 +
355 +@@ -80,16 +80,10 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
356 + current->restart_block.fn = do_no_restart_syscall;
357 +
358 + get_user_try {
359 +- /*
360 +- * Reload fs and gs if they have changed in the signal
361 +- * handler. This does not handle long fs/gs base changes in
362 +- * the handler, but does not clobber them at least in the
363 +- * normal case.
364 +- */
365 +- RELOAD_SEG(gs);
366 +- RELOAD_SEG(fs);
367 +- RELOAD_SEG(ds);
368 +- RELOAD_SEG(es);
369 ++ gs = GET_SEG(gs);
370 ++ fs = GET_SEG(fs);
371 ++ ds = GET_SEG(ds);
372 ++ es = GET_SEG(es);
373 +
374 + COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
375 + COPY(dx); COPY(cx); COPY(ip); COPY(ax);
376 +@@ -107,6 +101,17 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
377 + buf = compat_ptr(tmp);
378 + } get_user_catch(err);
379 +
380 ++ /*
381 ++ * Reload fs and gs if they have changed in the signal
382 ++ * handler. This does not handle long fs/gs base changes in
383 ++ * the handler, but does not clobber them at least in the
384 ++ * normal case.
385 ++ */
386 ++ RELOAD_SEG(gs);
387 ++ RELOAD_SEG(fs);
388 ++ RELOAD_SEG(ds);
389 ++ RELOAD_SEG(es);
390 ++
391 + err |= fpu__restore_sig(buf, 1);
392 +
393 + force_iret();
394 +diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h
395 +index ab3b9887e140..12dd61dc3c79 100644
396 +--- a/arch/x86/include/asm/text-patching.h
397 ++++ b/arch/x86/include/asm/text-patching.h
398 +@@ -38,6 +38,7 @@ extern void *text_poke(void *addr, const void *opcode, size_t len);
399 + extern int poke_int3_handler(struct pt_regs *regs);
400 + extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler);
401 +
402 ++#ifndef CONFIG_UML_X86
403 + static inline void int3_emulate_jmp(struct pt_regs *regs, unsigned long ip)
404 + {
405 + regs->ip = ip;
406 +@@ -64,6 +65,7 @@ static inline void int3_emulate_call(struct pt_regs *regs, unsigned long func)
407 + int3_emulate_push(regs, regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE);
408 + int3_emulate_jmp(regs, func);
409 + }
410 +-#endif
411 ++#endif /* CONFIG_X86_64 */
412 ++#endif /* !CONFIG_UML_X86 */
413 +
414 + #endif /* _ASM_X86_TEXT_PATCHING_H */
415 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
416 +index 54874e2b1d32..4f3be91f0b0b 100644
417 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
418 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
419 +@@ -701,19 +701,49 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
420 +
421 + barrier();
422 + m.status = mce_rdmsrl(msr_ops.status(i));
423 ++
424 ++ /* If this entry is not valid, ignore it */
425 + if (!(m.status & MCI_STATUS_VAL))
426 + continue;
427 +
428 + /*
429 +- * Uncorrected or signalled events are handled by the exception
430 +- * handler when it is enabled, so don't process those here.
431 +- *
432 +- * TBD do the same check for MCI_STATUS_EN here?
433 ++ * If we are logging everything (at CPU online) or this
434 ++ * is a corrected error, then we must log it.
435 + */
436 +- if (!(flags & MCP_UC) &&
437 +- (m.status & (mca_cfg.ser ? MCI_STATUS_S : MCI_STATUS_UC)))
438 +- continue;
439 ++ if ((flags & MCP_UC) || !(m.status & MCI_STATUS_UC))
440 ++ goto log_it;
441 ++
442 ++ /*
443 ++ * Newer Intel systems that support software error
444 ++ * recovery need to make additional checks. Other
445 ++ * CPUs should skip over uncorrected errors, but log
446 ++ * everything else.
447 ++ */
448 ++ if (!mca_cfg.ser) {
449 ++ if (m.status & MCI_STATUS_UC)
450 ++ continue;
451 ++ goto log_it;
452 ++ }
453 ++
454 ++ /* Log "not enabled" (speculative) errors */
455 ++ if (!(m.status & MCI_STATUS_EN))
456 ++ goto log_it;
457 ++
458 ++ /*
459 ++ * Log UCNA (SDM: 15.6.3 "UCR Error Classification")
460 ++ * UC == 1 && PCC == 0 && S == 0
461 ++ */
462 ++ if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S))
463 ++ goto log_it;
464 ++
465 ++ /*
466 ++ * Skip anything else. Presumption is that our read of this
467 ++ * bank is racing with a machine check. Leave the log alone
468 ++ * for do_machine_check() to deal with it.
469 ++ */
470 ++ continue;
471 +
472 ++log_it:
473 + error_seen = true;
474 +
475 + mce_read_aux(&m, i);
476 +diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
477 +index 387a8f44fba1..b6b44017cf16 100644
478 +--- a/arch/x86/kernel/cpu/microcode/core.c
479 ++++ b/arch/x86/kernel/cpu/microcode/core.c
480 +@@ -418,8 +418,9 @@ static int do_microcode_update(const void __user *buf, size_t size)
481 + if (ustate == UCODE_ERROR) {
482 + error = -1;
483 + break;
484 +- } else if (ustate == UCODE_OK)
485 ++ } else if (ustate == UCODE_NEW) {
486 + apply_microcode_on_target(cpu);
487 ++ }
488 + }
489 +
490 + return error;
491 +diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
492 +index 0469cd078db1..b50ac9c7397b 100644
493 +--- a/arch/x86/kernel/irq_64.c
494 ++++ b/arch/x86/kernel/irq_64.c
495 +@@ -26,9 +26,18 @@ int sysctl_panic_on_stackoverflow;
496 + /*
497 + * Probabilistic stack overflow check:
498 + *
499 +- * Only check the stack in process context, because everything else
500 +- * runs on the big interrupt stacks. Checking reliably is too expensive,
501 +- * so we just check from interrupts.
502 ++ * Regular device interrupts can enter on the following stacks:
503 ++ *
504 ++ * - User stack
505 ++ *
506 ++ * - Kernel task stack
507 ++ *
508 ++ * - Interrupt stack if a device driver reenables interrupts
509 ++ * which should only happen in really old drivers.
510 ++ *
511 ++ * - Debug IST stack
512 ++ *
513 ++ * All other contexts are invalid.
514 + */
515 + static inline void stack_overflow_check(struct pt_regs *regs)
516 + {
517 +@@ -53,8 +62,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
518 + return;
519 +
520 + oist = this_cpu_ptr(&orig_ist);
521 +- estack_top = (u64)oist->ist[0] - EXCEPTION_STKSZ + STACK_TOP_MARGIN;
522 +- estack_bottom = (u64)oist->ist[N_EXCEPTION_STACKS - 1];
523 ++ estack_bottom = (u64)oist->ist[DEBUG_STACK];
524 ++ estack_top = estack_bottom - DEBUG_STKSZ + STACK_TOP_MARGIN;
525 + if (regs->sp >= estack_top && regs->sp <= estack_bottom)
526 + return;
527 +
528 +diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
529 +index 4cdc0b27ec82..01741834fd6a 100644
530 +--- a/arch/x86/kernel/signal.c
531 ++++ b/arch/x86/kernel/signal.c
532 +@@ -131,16 +131,6 @@ static int restore_sigcontext(struct pt_regs *regs,
533 + COPY_SEG_CPL3(cs);
534 + COPY_SEG_CPL3(ss);
535 +
536 +-#ifdef CONFIG_X86_64
537 +- /*
538 +- * Fix up SS if needed for the benefit of old DOSEMU and
539 +- * CRIU.
540 +- */
541 +- if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) &&
542 +- user_64bit_mode(regs)))
543 +- force_valid_ss(regs);
544 +-#endif
545 +-
546 + get_user_ex(tmpflags, &sc->flags);
547 + regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
548 + regs->orig_ax = -1; /* disable syscall checks */
549 +@@ -149,6 +139,15 @@ static int restore_sigcontext(struct pt_regs *regs,
550 + buf = (void __user *)buf_val;
551 + } get_user_catch(err);
552 +
553 ++#ifdef CONFIG_X86_64
554 ++ /*
555 ++ * Fix up SS if needed for the benefit of old DOSEMU and
556 ++ * CRIU.
557 ++ */
558 ++ if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && user_64bit_mode(regs)))
559 ++ force_valid_ss(regs);
560 ++#endif
561 ++
562 + err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
563 +
564 + force_iret();
565 +@@ -460,6 +459,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
566 + {
567 + struct rt_sigframe __user *frame;
568 + void __user *fp = NULL;
569 ++ unsigned long uc_flags;
570 + int err = 0;
571 +
572 + frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
573 +@@ -472,9 +472,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
574 + return -EFAULT;
575 + }
576 +
577 ++ uc_flags = frame_uc_flags(regs);
578 ++
579 + put_user_try {
580 + /* Create the ucontext. */
581 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
582 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
583 + put_user_ex(0, &frame->uc.uc_link);
584 + save_altstack_ex(&frame->uc.uc_stack, regs->sp);
585 +
586 +@@ -540,6 +542,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
587 + {
588 + #ifdef CONFIG_X86_X32_ABI
589 + struct rt_sigframe_x32 __user *frame;
590 ++ unsigned long uc_flags;
591 + void __user *restorer;
592 + int err = 0;
593 + void __user *fpstate = NULL;
594 +@@ -554,9 +557,11 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
595 + return -EFAULT;
596 + }
597 +
598 ++ uc_flags = frame_uc_flags(regs);
599 ++
600 + put_user_try {
601 + /* Create the ucontext. */
602 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
603 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
604 + put_user_ex(0, &frame->uc.uc_link);
605 + compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
606 + put_user_ex(0, &frame->uc.uc__pad0);
607 +diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
608 +index 2384a2ae5ec3..23df6eebe82f 100644
609 +--- a/arch/x86/kernel/vmlinux.lds.S
610 ++++ b/arch/x86/kernel/vmlinux.lds.S
611 +@@ -131,11 +131,11 @@ SECTIONS
612 + *(.text.__x86.indirect_thunk)
613 + __indirect_thunk_end = .;
614 + #endif
615 +-
616 +- /* End of text section */
617 +- _etext = .;
618 + } :text = 0x9090
619 +
620 ++ /* End of text section */
621 ++ _etext = .;
622 ++
623 + NOTES :text :note
624 +
625 + EXCEPTION_TABLE(16) :text = 0x9090
626 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
627 +index 1296e44fd969..3a7e79f6cc77 100644
628 +--- a/arch/x86/kvm/svm.c
629 ++++ b/arch/x86/kvm/svm.c
630 +@@ -1567,7 +1567,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
631 + if (!kvm_vcpu_apicv_active(vcpu))
632 + return;
633 +
634 +- if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT))
635 ++ /*
636 ++ * Since the host physical APIC id is 8 bits,
637 ++ * we can support host APIC ID upto 255.
638 ++ */
639 ++ if (WARN_ON(h_physical_id > AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
640 + return;
641 +
642 + entry = READ_ONCE(*(svm->avic_physical_id_cache));
643 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
644 +index 40b1e7ec2399..00d383e3d87a 100644
645 +--- a/arch/x86/kvm/x86.c
646 ++++ b/arch/x86/kvm/x86.c
647 +@@ -1133,7 +1133,7 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
648 + u64 efer = msr_info->data;
649 +
650 + if (efer & efer_reserved_bits)
651 +- return false;
652 ++ return 1;
653 +
654 + if (!msr_info->host_initiated) {
655 + if (!__kvm_valid_efer(vcpu, efer))
656 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
657 +index 794c35c4ca73..b162f92fd55c 100644
658 +--- a/arch/x86/mm/fault.c
659 ++++ b/arch/x86/mm/fault.c
660 +@@ -426,8 +426,6 @@ static noinline int vmalloc_fault(unsigned long address)
661 + if (!(address >= VMALLOC_START && address < VMALLOC_END))
662 + return -1;
663 +
664 +- WARN_ON_ONCE(in_nmi());
665 +-
666 + /*
667 + * Copy kernel mappings over when needed. This can also
668 + * happen within a race in page table update. In the later
669 +diff --git a/block/sed-opal.c b/block/sed-opal.c
670 +index 4f5e70d4abc3..c64011cda9fc 100644
671 +--- a/block/sed-opal.c
672 ++++ b/block/sed-opal.c
673 +@@ -2078,13 +2078,16 @@ static int opal_erase_locking_range(struct opal_dev *dev,
674 + static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
675 + struct opal_mbr_data *opal_mbr)
676 + {
677 ++ u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ?
678 ++ OPAL_TRUE : OPAL_FALSE;
679 ++
680 + const struct opal_step mbr_steps[] = {
681 + { opal_discovery0, },
682 + { start_admin1LSP_opal_session, &opal_mbr->key },
683 +- { set_mbr_done, &opal_mbr->enable_disable },
684 ++ { set_mbr_done, &enable_disable },
685 + { end_opal_session, },
686 + { start_admin1LSP_opal_session, &opal_mbr->key },
687 +- { set_mbr_enable_disable, &opal_mbr->enable_disable },
688 ++ { set_mbr_enable_disable, &enable_disable },
689 + { end_opal_session, },
690 + { NULL, }
691 + };
692 +@@ -2204,7 +2207,7 @@ static int __opal_lock_unlock(struct opal_dev *dev,
693 +
694 + static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
695 + {
696 +- u8 mbr_done_tf = 1;
697 ++ u8 mbr_done_tf = OPAL_TRUE;
698 + const struct opal_step mbrdone_step [] = {
699 + { opal_discovery0, },
700 + { start_admin1LSP_opal_session, key },
701 +diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
702 +index e26ea209b63e..7a3194e2e090 100644
703 +--- a/drivers/acpi/property.c
704 ++++ b/drivers/acpi/property.c
705 +@@ -943,6 +943,14 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
706 + const struct acpi_data_node *data = to_acpi_data_node(fwnode);
707 + struct acpi_data_node *dn;
708 +
709 ++ /*
710 ++ * We can have a combination of device and data nodes, e.g. with
711 ++ * hierarchical _DSD properties. Make sure the adev pointer is
712 ++ * restored before going through data nodes, otherwise we will
713 ++ * be looking for data_nodes below the last device found instead
714 ++ * of the common fwnode shared by device_nodes and data_nodes.
715 ++ */
716 ++ adev = to_acpi_device_node(fwnode);
717 + if (adev)
718 + head = &adev->data.subnodes;
719 + else if (data)
720 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
721 +index d16b40cd26cc..a30ff97632a5 100644
722 +--- a/drivers/base/power/main.c
723 ++++ b/drivers/base/power/main.c
724 +@@ -1485,6 +1485,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
725 + if (dev->power.syscore)
726 + goto Complete;
727 +
728 ++ /* Avoid direct_complete to let wakeup_path propagate. */
729 ++ if (device_may_wakeup(dev) || dev->power.wakeup_path)
730 ++ dev->power.direct_complete = false;
731 ++
732 + if (dev->power.direct_complete) {
733 + if (pm_runtime_status_suspended(dev)) {
734 + pm_runtime_disable(dev);
735 +diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
736 +index 74d11ae6abe9..25173454efa3 100644
737 +--- a/drivers/char/hw_random/omap-rng.c
738 ++++ b/drivers/char/hw_random/omap-rng.c
739 +@@ -442,6 +442,7 @@ static int omap_rng_probe(struct platform_device *pdev)
740 + priv->rng.read = omap_rng_do_read;
741 + priv->rng.init = omap_rng_init;
742 + priv->rng.cleanup = omap_rng_cleanup;
743 ++ priv->rng.quality = 900;
744 +
745 + priv->rng.priv = (unsigned long)priv;
746 + platform_set_drvdata(pdev, priv);
747 +diff --git a/drivers/char/random.c b/drivers/char/random.c
748 +index ea4dbfa30657..e6efa07e9f9e 100644
749 +--- a/drivers/char/random.c
750 ++++ b/drivers/char/random.c
751 +@@ -2188,8 +2188,8 @@ struct batched_entropy {
752 + u32 entropy_u32[CHACHA20_BLOCK_SIZE / sizeof(u32)];
753 + };
754 + unsigned int position;
755 ++ spinlock_t batch_lock;
756 + };
757 +-static rwlock_t batched_entropy_reset_lock = __RW_LOCK_UNLOCKED(batched_entropy_reset_lock);
758 +
759 + /*
760 + * Get a random word for internal kernel use only. The quality of the random
761 +@@ -2199,12 +2199,14 @@ static rwlock_t batched_entropy_reset_lock = __RW_LOCK_UNLOCKED(batched_entropy_
762 + * wait_for_random_bytes() should be called and return 0 at least once
763 + * at any point prior.
764 + */
765 +-static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64);
766 ++static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64) = {
767 ++ .batch_lock = __SPIN_LOCK_UNLOCKED(batched_entropy_u64.lock),
768 ++};
769 ++
770 + u64 get_random_u64(void)
771 + {
772 + u64 ret;
773 +- bool use_lock;
774 +- unsigned long flags = 0;
775 ++ unsigned long flags;
776 + struct batched_entropy *batch;
777 + static void *previous;
778 +
779 +@@ -2219,28 +2221,25 @@ u64 get_random_u64(void)
780 +
781 + warn_unseeded_randomness(&previous);
782 +
783 +- use_lock = READ_ONCE(crng_init) < 2;
784 +- batch = &get_cpu_var(batched_entropy_u64);
785 +- if (use_lock)
786 +- read_lock_irqsave(&batched_entropy_reset_lock, flags);
787 ++ batch = raw_cpu_ptr(&batched_entropy_u64);
788 ++ spin_lock_irqsave(&batch->batch_lock, flags);
789 + if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) {
790 + extract_crng((u8 *)batch->entropy_u64);
791 + batch->position = 0;
792 + }
793 + ret = batch->entropy_u64[batch->position++];
794 +- if (use_lock)
795 +- read_unlock_irqrestore(&batched_entropy_reset_lock, flags);
796 +- put_cpu_var(batched_entropy_u64);
797 ++ spin_unlock_irqrestore(&batch->batch_lock, flags);
798 + return ret;
799 + }
800 + EXPORT_SYMBOL(get_random_u64);
801 +
802 +-static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32);
803 ++static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32) = {
804 ++ .batch_lock = __SPIN_LOCK_UNLOCKED(batched_entropy_u32.lock),
805 ++};
806 + u32 get_random_u32(void)
807 + {
808 + u32 ret;
809 +- bool use_lock;
810 +- unsigned long flags = 0;
811 ++ unsigned long flags;
812 + struct batched_entropy *batch;
813 + static void *previous;
814 +
815 +@@ -2249,18 +2248,14 @@ u32 get_random_u32(void)
816 +
817 + warn_unseeded_randomness(&previous);
818 +
819 +- use_lock = READ_ONCE(crng_init) < 2;
820 +- batch = &get_cpu_var(batched_entropy_u32);
821 +- if (use_lock)
822 +- read_lock_irqsave(&batched_entropy_reset_lock, flags);
823 ++ batch = raw_cpu_ptr(&batched_entropy_u32);
824 ++ spin_lock_irqsave(&batch->batch_lock, flags);
825 + if (batch->position % ARRAY_SIZE(batch->entropy_u32) == 0) {
826 + extract_crng((u8 *)batch->entropy_u32);
827 + batch->position = 0;
828 + }
829 + ret = batch->entropy_u32[batch->position++];
830 +- if (use_lock)
831 +- read_unlock_irqrestore(&batched_entropy_reset_lock, flags);
832 +- put_cpu_var(batched_entropy_u32);
833 ++ spin_unlock_irqrestore(&batch->batch_lock, flags);
834 + return ret;
835 + }
836 + EXPORT_SYMBOL(get_random_u32);
837 +@@ -2274,12 +2269,19 @@ static void invalidate_batched_entropy(void)
838 + int cpu;
839 + unsigned long flags;
840 +
841 +- write_lock_irqsave(&batched_entropy_reset_lock, flags);
842 + for_each_possible_cpu (cpu) {
843 +- per_cpu_ptr(&batched_entropy_u32, cpu)->position = 0;
844 +- per_cpu_ptr(&batched_entropy_u64, cpu)->position = 0;
845 ++ struct batched_entropy *batched_entropy;
846 ++
847 ++ batched_entropy = per_cpu_ptr(&batched_entropy_u32, cpu);
848 ++ spin_lock_irqsave(&batched_entropy->batch_lock, flags);
849 ++ batched_entropy->position = 0;
850 ++ spin_unlock(&batched_entropy->batch_lock);
851 ++
852 ++ batched_entropy = per_cpu_ptr(&batched_entropy_u64, cpu);
853 ++ spin_lock(&batched_entropy->batch_lock);
854 ++ batched_entropy->position = 0;
855 ++ spin_unlock_irqrestore(&batched_entropy->batch_lock, flags);
856 + }
857 +- write_unlock_irqrestore(&batched_entropy_reset_lock, flags);
858 + }
859 +
860 + /**
861 +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
862 +index a089474cb046..65454acd4b97 100644
863 +--- a/drivers/char/virtio_console.c
864 ++++ b/drivers/char/virtio_console.c
865 +@@ -75,7 +75,7 @@ struct ports_driver_data {
866 + /* All the console devices handled by this driver */
867 + struct list_head consoles;
868 + };
869 +-static struct ports_driver_data pdrvdata;
870 ++static struct ports_driver_data pdrvdata = { .next_vtermno = 1};
871 +
872 + static DEFINE_SPINLOCK(pdrvdata_lock);
873 + static DECLARE_COMPLETION(early_console_added);
874 +@@ -1422,6 +1422,7 @@ static int add_port(struct ports_device *portdev, u32 id)
875 + port->async_queue = NULL;
876 +
877 + port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
878 ++ port->cons.vtermno = 0;
879 +
880 + port->host_connected = port->guest_connected = false;
881 + port->stats = (struct port_stats) { 0 };
882 +diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
883 +index 450de24a1b42..64191694ff6e 100644
884 +--- a/drivers/clk/rockchip/clk-rk3288.c
885 ++++ b/drivers/clk/rockchip/clk-rk3288.c
886 +@@ -198,7 +198,7 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" };
887 + PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" };
888 + PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" };
889 +
890 +-PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vepu", "aclk_vdpu" };
891 ++PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vdpu", "aclk_vepu" };
892 + PNAME(mux_usbphy480m_p) = { "sclk_otgphy1_480m", "sclk_otgphy2_480m",
893 + "sclk_otgphy0_480m" };
894 + PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" };
895 +@@ -292,13 +292,13 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
896 + COMPOSITE_NOMUX(0, "aclk_core_mp", "armclk", CLK_IGNORE_UNUSED,
897 + RK3288_CLKSEL_CON(0), 4, 4, DFLAGS | CLK_DIVIDER_READ_ONLY,
898 + RK3288_CLKGATE_CON(12), 6, GFLAGS),
899 +- COMPOSITE_NOMUX(0, "atclk", "armclk", CLK_IGNORE_UNUSED,
900 ++ COMPOSITE_NOMUX(0, "atclk", "armclk", 0,
901 + RK3288_CLKSEL_CON(37), 4, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
902 + RK3288_CLKGATE_CON(12), 7, GFLAGS),
903 + COMPOSITE_NOMUX(0, "pclk_dbg_pre", "armclk", CLK_IGNORE_UNUSED,
904 + RK3288_CLKSEL_CON(37), 9, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
905 + RK3288_CLKGATE_CON(12), 8, GFLAGS),
906 +- GATE(0, "pclk_dbg", "pclk_dbg_pre", CLK_IGNORE_UNUSED,
907 ++ GATE(0, "pclk_dbg", "pclk_dbg_pre", 0,
908 + RK3288_CLKGATE_CON(12), 9, GFLAGS),
909 + GATE(0, "cs_dbg", "pclk_dbg_pre", CLK_IGNORE_UNUSED,
910 + RK3288_CLKGATE_CON(12), 10, GFLAGS),
911 +@@ -399,7 +399,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
912 + COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb480m_p, 0,
913 + RK3288_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS,
914 + RK3288_CLKGATE_CON(3), 11, GFLAGS),
915 +- MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, 0,
916 ++ MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, CLK_SET_RATE_PARENT,
917 + RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS),
918 + GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0,
919 + RK3288_CLKGATE_CON(9), 0, GFLAGS),
920 +@@ -626,7 +626,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
921 + INVERTER(SCLK_HSADC, "sclk_hsadc", "sclk_hsadc_out",
922 + RK3288_CLKSEL_CON(22), 7, IFLAGS),
923 +
924 +- GATE(0, "jtag", "ext_jtag", CLK_IGNORE_UNUSED,
925 ++ GATE(0, "jtag", "ext_jtag", 0,
926 + RK3288_CLKGATE_CON(4), 14, GFLAGS),
927 +
928 + COMPOSITE_NODIV(SCLK_USBPHY480M_SRC, "usbphy480m_src", mux_usbphy480m_p, 0,
929 +@@ -635,7 +635,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
930 + COMPOSITE_NODIV(SCLK_HSICPHY480M, "sclk_hsicphy480m", mux_hsicphy480m_p, 0,
931 + RK3288_CLKSEL_CON(29), 0, 2, MFLAGS,
932 + RK3288_CLKGATE_CON(3), 6, GFLAGS),
933 +- GATE(0, "hsicphy12m_xin12m", "xin12m", CLK_IGNORE_UNUSED,
934 ++ GATE(0, "hsicphy12m_xin12m", "xin12m", 0,
935 + RK3288_CLKGATE_CON(13), 9, GFLAGS),
936 + DIV(0, "hsicphy12m_usbphy", "sclk_hsicphy480m", 0,
937 + RK3288_CLKSEL_CON(11), 8, 6, DFLAGS),
938 +@@ -676,7 +676,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
939 + GATE(PCLK_TZPC, "pclk_tzpc", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 3, GFLAGS),
940 + GATE(PCLK_UART2, "pclk_uart2", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 9, GFLAGS),
941 + GATE(PCLK_EFUSE256, "pclk_efuse_256", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 10, GFLAGS),
942 +- GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 11, GFLAGS),
943 ++ GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 11, GFLAGS),
944 +
945 + /* ddrctrl [DDR Controller PHY clock] gates */
946 + GATE(0, "nclk_ddrupctl0", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 4, GFLAGS),
947 +@@ -816,12 +816,9 @@ static const char *const rk3288_critical_clocks[] __initconst = {
948 + "pclk_alive_niu",
949 + "pclk_pd_pmu",
950 + "pclk_pmu_niu",
951 +- "pclk_core_niu",
952 +- "pclk_ddrupctl0",
953 +- "pclk_publ0",
954 +- "pclk_ddrupctl1",
955 +- "pclk_publ1",
956 + "pmu_hclk_otg0",
957 ++ /* pwm-regulators on some boards, so handoff-critical later */
958 ++ "pclk_rkpwm",
959 + };
960 +
961 + static void __iomem *rk3288_cru_base;
962 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
963 +index 9f5c51cd67ad..fceb18d26db8 100644
964 +--- a/drivers/cpufreq/cpufreq.c
965 ++++ b/drivers/cpufreq/cpufreq.c
966 +@@ -1101,6 +1101,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
967 + cpufreq_global_kobject, "policy%u", cpu);
968 + if (ret) {
969 + pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
970 ++ kobject_put(&policy->kobj);
971 + goto err_free_real_cpus;
972 + }
973 +
974 +diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
975 +index 6a16d22bc604..146237aab395 100644
976 +--- a/drivers/cpufreq/cpufreq_governor.c
977 ++++ b/drivers/cpufreq/cpufreq_governor.c
978 +@@ -459,6 +459,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
979 + /* Failure, so roll back. */
980 + pr_err("initialization failed (dbs_data kobject init error %d)\n", ret);
981 +
982 ++ kobject_put(&dbs_data->attr_set.kobj);
983 ++
984 + policy->governor_data = NULL;
985 +
986 + if (!have_governor_per_policy())
987 +diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
988 +index c2dd43f3f5d8..8d63a6dc8383 100644
989 +--- a/drivers/cpufreq/kirkwood-cpufreq.c
990 ++++ b/drivers/cpufreq/kirkwood-cpufreq.c
991 +@@ -124,13 +124,14 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
992 + priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
993 + if (IS_ERR(priv.cpu_clk)) {
994 + dev_err(priv.dev, "Unable to get cpuclk\n");
995 +- return PTR_ERR(priv.cpu_clk);
996 ++ err = PTR_ERR(priv.cpu_clk);
997 ++ goto out_node;
998 + }
999 +
1000 + err = clk_prepare_enable(priv.cpu_clk);
1001 + if (err) {
1002 + dev_err(priv.dev, "Unable to prepare cpuclk\n");
1003 +- return err;
1004 ++ goto out_node;
1005 + }
1006 +
1007 + kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
1008 +@@ -161,20 +162,22 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
1009 + goto out_ddr;
1010 + }
1011 +
1012 +- of_node_put(np);
1013 +- np = NULL;
1014 +-
1015 + err = cpufreq_register_driver(&kirkwood_cpufreq_driver);
1016 +- if (!err)
1017 +- return 0;
1018 ++ if (err) {
1019 ++ dev_err(priv.dev, "Failed to register cpufreq driver\n");
1020 ++ goto out_powersave;
1021 ++ }
1022 +
1023 +- dev_err(priv.dev, "Failed to register cpufreq driver\n");
1024 ++ of_node_put(np);
1025 ++ return 0;
1026 +
1027 ++out_powersave:
1028 + clk_disable_unprepare(priv.powersave_clk);
1029 + out_ddr:
1030 + clk_disable_unprepare(priv.ddr_clk);
1031 + out_cpu:
1032 + clk_disable_unprepare(priv.cpu_clk);
1033 ++out_node:
1034 + of_node_put(np);
1035 +
1036 + return err;
1037 +diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
1038 +index b257fc7d5204..8456492124f0 100644
1039 +--- a/drivers/cpufreq/pasemi-cpufreq.c
1040 ++++ b/drivers/cpufreq/pasemi-cpufreq.c
1041 +@@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
1042 +
1043 + cpu = of_get_cpu_node(policy->cpu, NULL);
1044 +
1045 ++ of_node_put(cpu);
1046 + if (!cpu)
1047 + goto out;
1048 +
1049 +diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
1050 +index 61ae06ca008e..e225edb5c359 100644
1051 +--- a/drivers/cpufreq/pmac32-cpufreq.c
1052 ++++ b/drivers/cpufreq/pmac32-cpufreq.c
1053 +@@ -552,6 +552,7 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
1054 + volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
1055 + if (volt_gpio_np)
1056 + voltage_gpio = read_gpio(volt_gpio_np);
1057 ++ of_node_put(volt_gpio_np);
1058 + if (!voltage_gpio){
1059 + pr_err("missing cpu-vcore-select gpio\n");
1060 + return 1;
1061 +@@ -588,6 +589,7 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
1062 + if (volt_gpio_np)
1063 + voltage_gpio = read_gpio(volt_gpio_np);
1064 +
1065 ++ of_node_put(volt_gpio_np);
1066 + pvr = mfspr(SPRN_PVR);
1067 + has_cpu_l2lve = !((pvr & 0xf00) == 0x100);
1068 +
1069 +diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
1070 +index 5a4c5a639f61..2eaeebcc93af 100644
1071 +--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
1072 ++++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
1073 +@@ -86,6 +86,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
1074 + if (!cbe_get_cpu_pmd_regs(policy->cpu) ||
1075 + !cbe_get_cpu_mic_tm_regs(policy->cpu)) {
1076 + pr_info("invalid CBE regs pointers for cpufreq\n");
1077 ++ of_node_put(cpu);
1078 + return -EINVAL;
1079 + }
1080 +
1081 +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1082 +index a4b5ff2b72f8..f6936bb3b7be 100644
1083 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1084 ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1085 +@@ -240,7 +240,10 @@ static int sun4i_hash(struct ahash_request *areq)
1086 + }
1087 + } else {
1088 + /* Since we have the flag final, we can go up to modulo 4 */
1089 +- end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
1090 ++ if (areq->nbytes < 4)
1091 ++ end = 0;
1092 ++ else
1093 ++ end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
1094 + }
1095 +
1096 + /* TODO if SGlen % 4 and !op->len then DMA */
1097 +diff --git a/drivers/crypto/vmx/aesp8-ppc.pl b/drivers/crypto/vmx/aesp8-ppc.pl
1098 +index d9281a28818d..930a3f1e3ec0 100644
1099 +--- a/drivers/crypto/vmx/aesp8-ppc.pl
1100 ++++ b/drivers/crypto/vmx/aesp8-ppc.pl
1101 +@@ -1318,7 +1318,7 @@ Loop_ctr32_enc:
1102 + addi $idx,$idx,16
1103 + bdnz Loop_ctr32_enc
1104 +
1105 +- vadduwm $ivec,$ivec,$one
1106 ++ vadduqm $ivec,$ivec,$one
1107 + vmr $dat,$inptail
1108 + lvx $inptail,0,$inp
1109 + addi $inp,$inp,16
1110 +diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
1111 +index 4db2cd1c611d..22764cd30cc3 100644
1112 +--- a/drivers/dma/at_xdmac.c
1113 ++++ b/drivers/dma/at_xdmac.c
1114 +@@ -1606,7 +1606,11 @@ static void at_xdmac_tasklet(unsigned long data)
1115 + struct at_xdmac_desc,
1116 + xfer_node);
1117 + dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
1118 +- BUG_ON(!desc->active_xfer);
1119 ++ if (!desc->active_xfer) {
1120 ++ dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
1121 ++ spin_unlock_bh(&atchan->lock);
1122 ++ return;
1123 ++ }
1124 +
1125 + txd = &desc->tx_dma_desc;
1126 +
1127 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
1128 +index 6afd42cfbf5d..b4fa555a243f 100644
1129 +--- a/drivers/dma/pl330.c
1130 ++++ b/drivers/dma/pl330.c
1131 +@@ -960,6 +960,7 @@ static void _stop(struct pl330_thread *thrd)
1132 + {
1133 + void __iomem *regs = thrd->dmac->base;
1134 + u8 insn[6] = {0, 0, 0, 0, 0, 0};
1135 ++ u32 inten = readl(regs + INTEN);
1136 +
1137 + if (_state(thrd) == PL330_STATE_FAULT_COMPLETING)
1138 + UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING);
1139 +@@ -972,10 +973,13 @@ static void _stop(struct pl330_thread *thrd)
1140 +
1141 + _emit_KILL(0, insn);
1142 +
1143 +- /* Stop generating interrupts for SEV */
1144 +- writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN);
1145 +-
1146 + _execute_DBGINSN(thrd, insn, is_manager(thrd));
1147 ++
1148 ++ /* clear the event */
1149 ++ if (inten & (1 << thrd->ev))
1150 ++ writel(1 << thrd->ev, regs + INTCLR);
1151 ++ /* Stop generating interrupts for SEV */
1152 ++ writel(inten & ~(1 << thrd->ev), regs + INTEN);
1153 + }
1154 +
1155 + /* Start doing req 'idx' of thread 'thrd' */
1156 +diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
1157 +index b26256f23d67..09b6756366c3 100644
1158 +--- a/drivers/dma/tegra210-adma.c
1159 ++++ b/drivers/dma/tegra210-adma.c
1160 +@@ -22,7 +22,6 @@
1161 + #include <linux/of_device.h>
1162 + #include <linux/of_dma.h>
1163 + #include <linux/of_irq.h>
1164 +-#include <linux/pm_clock.h>
1165 + #include <linux/pm_runtime.h>
1166 + #include <linux/slab.h>
1167 +
1168 +@@ -141,6 +140,7 @@ struct tegra_adma {
1169 + struct dma_device dma_dev;
1170 + struct device *dev;
1171 + void __iomem *base_addr;
1172 ++ struct clk *ahub_clk;
1173 + unsigned int nr_channels;
1174 + unsigned long rx_requests_reserved;
1175 + unsigned long tx_requests_reserved;
1176 +@@ -637,8 +637,9 @@ static int tegra_adma_runtime_suspend(struct device *dev)
1177 + struct tegra_adma *tdma = dev_get_drvdata(dev);
1178 +
1179 + tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD);
1180 ++ clk_disable_unprepare(tdma->ahub_clk);
1181 +
1182 +- return pm_clk_suspend(dev);
1183 ++ return 0;
1184 + }
1185 +
1186 + static int tegra_adma_runtime_resume(struct device *dev)
1187 +@@ -646,10 +647,11 @@ static int tegra_adma_runtime_resume(struct device *dev)
1188 + struct tegra_adma *tdma = dev_get_drvdata(dev);
1189 + int ret;
1190 +
1191 +- ret = pm_clk_resume(dev);
1192 +- if (ret)
1193 ++ ret = clk_prepare_enable(tdma->ahub_clk);
1194 ++ if (ret) {
1195 ++ dev_err(dev, "ahub clk_enable failed: %d\n", ret);
1196 + return ret;
1197 +-
1198 ++ }
1199 + tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd);
1200 +
1201 + return 0;
1202 +@@ -692,13 +694,11 @@ static int tegra_adma_probe(struct platform_device *pdev)
1203 + if (IS_ERR(tdma->base_addr))
1204 + return PTR_ERR(tdma->base_addr);
1205 +
1206 +- ret = pm_clk_create(&pdev->dev);
1207 +- if (ret)
1208 +- return ret;
1209 +-
1210 +- ret = of_pm_clk_add_clk(&pdev->dev, "d_audio");
1211 +- if (ret)
1212 +- goto clk_destroy;
1213 ++ tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio");
1214 ++ if (IS_ERR(tdma->ahub_clk)) {
1215 ++ dev_err(&pdev->dev, "Error: Missing ahub controller clock\n");
1216 ++ return PTR_ERR(tdma->ahub_clk);
1217 ++ }
1218 +
1219 + pm_runtime_enable(&pdev->dev);
1220 +
1221 +@@ -775,8 +775,6 @@ rpm_put:
1222 + pm_runtime_put_sync(&pdev->dev);
1223 + rpm_disable:
1224 + pm_runtime_disable(&pdev->dev);
1225 +-clk_destroy:
1226 +- pm_clk_destroy(&pdev->dev);
1227 +
1228 + return ret;
1229 + }
1230 +@@ -786,6 +784,7 @@ static int tegra_adma_remove(struct platform_device *pdev)
1231 + struct tegra_adma *tdma = platform_get_drvdata(pdev);
1232 + int i;
1233 +
1234 ++ of_dma_controller_free(pdev->dev.of_node);
1235 + dma_async_device_unregister(&tdma->dma_dev);
1236 +
1237 + for (i = 0; i < tdma->nr_channels; ++i)
1238 +@@ -793,7 +792,6 @@ static int tegra_adma_remove(struct platform_device *pdev)
1239 +
1240 + pm_runtime_put_sync(&pdev->dev);
1241 + pm_runtime_disable(&pdev->dev);
1242 +- pm_clk_destroy(&pdev->dev);
1243 +
1244 + return 0;
1245 + }
1246 +diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
1247 +index f84da4a17724..4937a404fee8 100644
1248 +--- a/drivers/extcon/extcon-arizona.c
1249 ++++ b/drivers/extcon/extcon-arizona.c
1250 +@@ -1726,6 +1726,16 @@ static int arizona_extcon_remove(struct platform_device *pdev)
1251 + struct arizona_extcon_info *info = platform_get_drvdata(pdev);
1252 + struct arizona *arizona = info->arizona;
1253 + int jack_irq_rise, jack_irq_fall;
1254 ++ bool change;
1255 ++
1256 ++ regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
1257 ++ ARIZONA_MICD_ENA, 0,
1258 ++ &change);
1259 ++
1260 ++ if (change) {
1261 ++ regulator_disable(info->micvdd);
1262 ++ pm_runtime_put(info->dev);
1263 ++ }
1264 +
1265 + gpiod_put(info->micd_pol_gpio);
1266 +
1267 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1268 +index 333bad749067..415e9a384799 100644
1269 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1270 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1271 +@@ -135,8 +135,9 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
1272 + {
1273 + struct amdgpu_device *adev = ring->adev;
1274 + struct amdgpu_fence *fence;
1275 +- struct dma_fence *old, **ptr;
1276 ++ struct dma_fence __rcu **ptr;
1277 + uint32_t seq;
1278 ++ int r;
1279 +
1280 + fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL);
1281 + if (fence == NULL)
1282 +@@ -152,15 +153,24 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
1283 + seq, AMDGPU_FENCE_FLAG_INT);
1284 +
1285 + ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
1286 ++ if (unlikely(rcu_dereference_protected(*ptr, 1))) {
1287 ++ struct dma_fence *old;
1288 ++
1289 ++ rcu_read_lock();
1290 ++ old = dma_fence_get_rcu_safe(ptr);
1291 ++ rcu_read_unlock();
1292 ++
1293 ++ if (old) {
1294 ++ r = dma_fence_wait(old, false);
1295 ++ dma_fence_put(old);
1296 ++ if (r)
1297 ++ return r;
1298 ++ }
1299 ++ }
1300 ++
1301 + /* This function can't be called concurrently anyway, otherwise
1302 + * emitting the fence would mess up the hardware ring buffer.
1303 + */
1304 +- old = rcu_dereference_protected(*ptr, 1);
1305 +- if (old && !dma_fence_is_signaled(old)) {
1306 +- DRM_INFO("rcu slot is busy\n");
1307 +- dma_fence_wait(old, false);
1308 +- }
1309 +-
1310 + rcu_assign_pointer(*ptr, dma_fence_get(&fence->base));
1311 +
1312 + *f = &fence->base;
1313 +diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
1314 +index a7b6734bc3c3..340440febf9a 100644
1315 +--- a/drivers/gpu/drm/drm_drv.c
1316 ++++ b/drivers/gpu/drm/drm_drv.c
1317 +@@ -505,7 +505,7 @@ int drm_dev_init(struct drm_device *dev,
1318 + }
1319 +
1320 + kref_init(&dev->ref);
1321 +- dev->dev = parent;
1322 ++ dev->dev = get_device(parent);
1323 + dev->driver = driver;
1324 +
1325 + INIT_LIST_HEAD(&dev->filelist);
1326 +@@ -572,6 +572,7 @@ err_minors:
1327 + drm_minor_free(dev, DRM_MINOR_CONTROL);
1328 + drm_fs_inode_free(dev->anon_inode);
1329 + err_free:
1330 ++ put_device(dev->dev);
1331 + mutex_destroy(&dev->master_mutex);
1332 + mutex_destroy(&dev->ctxlist_mutex);
1333 + mutex_destroy(&dev->filelist_mutex);
1334 +@@ -607,6 +608,8 @@ void drm_dev_fini(struct drm_device *dev)
1335 + drm_minor_free(dev, DRM_MINOR_RENDER);
1336 + drm_minor_free(dev, DRM_MINOR_CONTROL);
1337 +
1338 ++ put_device(dev->dev);
1339 ++
1340 + mutex_destroy(&dev->master_mutex);
1341 + mutex_destroy(&dev->ctxlist_mutex);
1342 + mutex_destroy(&dev->filelist_mutex);
1343 +diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
1344 +index 03244b3c985d..3cf07f5063ff 100644
1345 +--- a/drivers/gpu/drm/drm_file.c
1346 ++++ b/drivers/gpu/drm/drm_file.c
1347 +@@ -525,6 +525,7 @@ put_back_event:
1348 + file_priv->event_space -= length;
1349 + list_add(&e->link, &file_priv->event_list);
1350 + spin_unlock_irq(&dev->event_lock);
1351 ++ wake_up_interruptible(&file_priv->event_wait);
1352 + break;
1353 + }
1354 +
1355 +diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1356 +index 17c59d839e6f..f1aaa76cc2e4 100644
1357 +--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1358 ++++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1359 +@@ -29,7 +29,7 @@ static void a5xx_dump(struct msm_gpu *gpu);
1360 + static int zap_shader_load_mdt(struct device *dev, const char *fwname)
1361 + {
1362 + const struct firmware *fw;
1363 +- struct device_node *np;
1364 ++ struct device_node *np, *mem_np;
1365 + struct resource r;
1366 + phys_addr_t mem_phys;
1367 + ssize_t mem_size;
1368 +@@ -43,11 +43,13 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname)
1369 + if (!np)
1370 + return -ENODEV;
1371 +
1372 +- np = of_parse_phandle(np, "memory-region", 0);
1373 +- if (!np)
1374 ++ mem_np = of_parse_phandle(np, "memory-region", 0);
1375 ++ of_node_put(np);
1376 ++ if (!mem_np)
1377 + return -EINVAL;
1378 +
1379 +- ret = of_address_to_resource(np, 0, &r);
1380 ++ ret = of_address_to_resource(mem_np, 0, &r);
1381 ++ of_node_put(mem_np);
1382 + if (ret)
1383 + return ret;
1384 +
1385 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1386 +index a306493e2e97..7c8049a5bd99 100644
1387 +--- a/drivers/hid/hid-core.c
1388 ++++ b/drivers/hid/hid-core.c
1389 +@@ -199,13 +199,14 @@ static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
1390 + * Add a usage to the temporary parser table.
1391 + */
1392 +
1393 +-static int hid_add_usage(struct hid_parser *parser, unsigned usage)
1394 ++static int hid_add_usage(struct hid_parser *parser, unsigned usage, u8 size)
1395 + {
1396 + if (parser->local.usage_index >= HID_MAX_USAGES) {
1397 + hid_err(parser->device, "usage index exceeded\n");
1398 + return -1;
1399 + }
1400 + parser->local.usage[parser->local.usage_index] = usage;
1401 ++ parser->local.usage_size[parser->local.usage_index] = size;
1402 + parser->local.collection_index[parser->local.usage_index] =
1403 + parser->collection_stack_ptr ?
1404 + parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
1405 +@@ -462,10 +463,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1406 + return 0;
1407 + }
1408 +
1409 +- if (item->size <= 2)
1410 +- data = (parser->global.usage_page << 16) + data;
1411 +-
1412 +- return hid_add_usage(parser, data);
1413 ++ return hid_add_usage(parser, data, item->size);
1414 +
1415 + case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
1416 +
1417 +@@ -474,9 +472,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1418 + return 0;
1419 + }
1420 +
1421 +- if (item->size <= 2)
1422 +- data = (parser->global.usage_page << 16) + data;
1423 +-
1424 + parser->local.usage_minimum = data;
1425 + return 0;
1426 +
1427 +@@ -487,9 +482,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1428 + return 0;
1429 + }
1430 +
1431 +- if (item->size <= 2)
1432 +- data = (parser->global.usage_page << 16) + data;
1433 +-
1434 + count = data - parser->local.usage_minimum;
1435 + if (count + parser->local.usage_index >= HID_MAX_USAGES) {
1436 + /*
1437 +@@ -509,7 +501,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1438 + }
1439 +
1440 + for (n = parser->local.usage_minimum; n <= data; n++)
1441 +- if (hid_add_usage(parser, n)) {
1442 ++ if (hid_add_usage(parser, n, item->size)) {
1443 + dbg_hid("hid_add_usage failed\n");
1444 + return -1;
1445 + }
1446 +@@ -523,6 +515,22 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1447 + return 0;
1448 + }
1449 +
1450 ++/*
1451 ++ * Concatenate Usage Pages into Usages where relevant:
1452 ++ * As per specification, 6.2.2.8: "When the parser encounters a main item it
1453 ++ * concatenates the last declared Usage Page with a Usage to form a complete
1454 ++ * usage value."
1455 ++ */
1456 ++
1457 ++static void hid_concatenate_usage_page(struct hid_parser *parser)
1458 ++{
1459 ++ int i;
1460 ++
1461 ++ for (i = 0; i < parser->local.usage_index; i++)
1462 ++ if (parser->local.usage_size[i] <= 2)
1463 ++ parser->local.usage[i] += parser->global.usage_page << 16;
1464 ++}
1465 ++
1466 + /*
1467 + * Process a main item.
1468 + */
1469 +@@ -532,6 +540,8 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
1470 + __u32 data;
1471 + int ret;
1472 +
1473 ++ hid_concatenate_usage_page(parser);
1474 ++
1475 + data = item_udata(item);
1476 +
1477 + switch (item->tag) {
1478 +@@ -741,6 +751,8 @@ static int hid_scan_main(struct hid_parser *parser, struct hid_item *item)
1479 + __u32 data;
1480 + int i;
1481 +
1482 ++ hid_concatenate_usage_page(parser);
1483 ++
1484 + data = item_udata(item);
1485 +
1486 + switch (item->tag) {
1487 +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
1488 +index b83d4173fc7f..b705cbb58ca6 100644
1489 +--- a/drivers/hid/hid-logitech-hidpp.c
1490 ++++ b/drivers/hid/hid-logitech-hidpp.c
1491 +@@ -725,13 +725,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
1492 +
1493 + static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1494 + {
1495 ++ const u8 ping_byte = 0x5a;
1496 ++ u8 ping_data[3] = { 0, 0, ping_byte };
1497 + struct hidpp_report response;
1498 + int ret;
1499 +
1500 +- ret = hidpp_send_fap_command_sync(hidpp,
1501 ++ ret = hidpp_send_rap_command_sync(hidpp,
1502 ++ REPORT_ID_HIDPP_SHORT,
1503 + HIDPP_PAGE_ROOT_IDX,
1504 + CMD_ROOT_GET_PROTOCOL_VERSION,
1505 +- NULL, 0, &response);
1506 ++ ping_data, sizeof(ping_data), &response);
1507 +
1508 + if (ret == HIDPP_ERROR_INVALID_SUBID) {
1509 + hidpp->protocol_major = 1;
1510 +@@ -751,8 +754,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1511 + if (ret)
1512 + return ret;
1513 +
1514 +- hidpp->protocol_major = response.fap.params[0];
1515 +- hidpp->protocol_minor = response.fap.params[1];
1516 ++ if (response.rap.params[2] != ping_byte) {
1517 ++ hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n",
1518 ++ __func__, response.rap.params[2], ping_byte);
1519 ++ return -EPROTO;
1520 ++ }
1521 ++
1522 ++ hidpp->protocol_major = response.rap.params[0];
1523 ++ hidpp->protocol_minor = response.rap.params[1];
1524 +
1525 + return ret;
1526 + }
1527 +@@ -901,7 +910,11 @@ static int hidpp_map_battery_level(int capacity)
1528 + {
1529 + if (capacity < 11)
1530 + return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
1531 +- else if (capacity < 31)
1532 ++ /*
1533 ++ * The spec says this should be < 31 but some devices report 30
1534 ++ * with brand new batteries and Windows reports 30 as "Good".
1535 ++ */
1536 ++ else if (capacity < 30)
1537 + return POWER_SUPPLY_CAPACITY_LEVEL_LOW;
1538 + else if (capacity < 81)
1539 + return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
1540 +diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
1541 +index 73c681162653..623736d2a7c1 100644
1542 +--- a/drivers/hwmon/f71805f.c
1543 ++++ b/drivers/hwmon/f71805f.c
1544 +@@ -96,17 +96,23 @@ superio_select(int base, int ld)
1545 + outb(ld, base + 1);
1546 + }
1547 +
1548 +-static inline void
1549 ++static inline int
1550 + superio_enter(int base)
1551 + {
1552 ++ if (!request_muxed_region(base, 2, DRVNAME))
1553 ++ return -EBUSY;
1554 ++
1555 + outb(0x87, base);
1556 + outb(0x87, base);
1557 ++
1558 ++ return 0;
1559 + }
1560 +
1561 + static inline void
1562 + superio_exit(int base)
1563 + {
1564 + outb(0xaa, base);
1565 ++ release_region(base, 2);
1566 + }
1567 +
1568 + /*
1569 +@@ -1561,7 +1567,7 @@ exit:
1570 + static int __init f71805f_find(int sioaddr, unsigned short *address,
1571 + struct f71805f_sio_data *sio_data)
1572 + {
1573 +- int err = -ENODEV;
1574 ++ int err;
1575 + u16 devid;
1576 +
1577 + static const char * const names[] = {
1578 +@@ -1569,8 +1575,11 @@ static int __init f71805f_find(int sioaddr, unsigned short *address,
1579 + "F71872F/FG or F71806F/FG",
1580 + };
1581 +
1582 +- superio_enter(sioaddr);
1583 ++ err = superio_enter(sioaddr);
1584 ++ if (err)
1585 ++ return err;
1586 +
1587 ++ err = -ENODEV;
1588 + devid = superio_inw(sioaddr, SIO_REG_MANID);
1589 + if (devid != SIO_FINTEK_ID)
1590 + goto exit;
1591 +diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
1592 +index dc5a9d5ada51..81a05cd1a512 100644
1593 +--- a/drivers/hwmon/pc87427.c
1594 ++++ b/drivers/hwmon/pc87427.c
1595 +@@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
1596 + #define LD_IN 1
1597 + #define LD_TEMP 1
1598 +
1599 ++static inline int superio_enter(int sioaddr)
1600 ++{
1601 ++ if (!request_muxed_region(sioaddr, 2, DRVNAME))
1602 ++ return -EBUSY;
1603 ++ return 0;
1604 ++}
1605 ++
1606 + static inline void superio_outb(int sioaddr, int reg, int val)
1607 + {
1608 + outb(reg, sioaddr);
1609 +@@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
1610 + {
1611 + outb(0x02, sioaddr);
1612 + outb(0x02, sioaddr + 1);
1613 ++ release_region(sioaddr, 2);
1614 + }
1615 +
1616 + /*
1617 +@@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
1618 + {
1619 + u16 val;
1620 + u8 cfg, cfg_b;
1621 +- int i, err = 0;
1622 ++ int i, err;
1623 ++
1624 ++ err = superio_enter(sioaddr);
1625 ++ if (err)
1626 ++ return err;
1627 +
1628 + /* Identify device */
1629 + val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);
1630 +diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
1631 +index 6bd200756560..cbdb5c4991ae 100644
1632 +--- a/drivers/hwmon/smsc47b397.c
1633 ++++ b/drivers/hwmon/smsc47b397.c
1634 +@@ -72,14 +72,19 @@ static inline void superio_select(int ld)
1635 + superio_outb(0x07, ld);
1636 + }
1637 +
1638 +-static inline void superio_enter(void)
1639 ++static inline int superio_enter(void)
1640 + {
1641 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1642 ++ return -EBUSY;
1643 ++
1644 + outb(0x55, REG);
1645 ++ return 0;
1646 + }
1647 +
1648 + static inline void superio_exit(void)
1649 + {
1650 + outb(0xAA, REG);
1651 ++ release_region(REG, 2);
1652 + }
1653 +
1654 + #define SUPERIO_REG_DEVID 0x20
1655 +@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
1656 + u8 id, rev;
1657 + char *name;
1658 + unsigned short addr;
1659 ++ int err;
1660 ++
1661 ++ err = superio_enter();
1662 ++ if (err)
1663 ++ return err;
1664 +
1665 +- superio_enter();
1666 + id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1667 +
1668 + switch (id) {
1669 +diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
1670 +index c7b6a425e2c0..5eeac9853d0a 100644
1671 +--- a/drivers/hwmon/smsc47m1.c
1672 ++++ b/drivers/hwmon/smsc47m1.c
1673 +@@ -73,16 +73,21 @@ superio_inb(int reg)
1674 + /* logical device for fans is 0x0A */
1675 + #define superio_select() superio_outb(0x07, 0x0A)
1676 +
1677 +-static inline void
1678 ++static inline int
1679 + superio_enter(void)
1680 + {
1681 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1682 ++ return -EBUSY;
1683 ++
1684 + outb(0x55, REG);
1685 ++ return 0;
1686 + }
1687 +
1688 + static inline void
1689 + superio_exit(void)
1690 + {
1691 + outb(0xAA, REG);
1692 ++ release_region(REG, 2);
1693 + }
1694 +
1695 + #define SUPERIO_REG_ACT 0x30
1696 +@@ -531,8 +536,12 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1697 + {
1698 + u8 val;
1699 + unsigned short addr;
1700 ++ int err;
1701 ++
1702 ++ err = superio_enter();
1703 ++ if (err)
1704 ++ return err;
1705 +
1706 +- superio_enter();
1707 + val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1708 +
1709 + /*
1710 +@@ -608,13 +617,14 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1711 + static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
1712 + {
1713 + if ((sio_data->activate & 0x01) == 0) {
1714 +- superio_enter();
1715 +- superio_select();
1716 +-
1717 +- pr_info("Disabling device\n");
1718 +- superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1719 +-
1720 +- superio_exit();
1721 ++ if (!superio_enter()) {
1722 ++ superio_select();
1723 ++ pr_info("Disabling device\n");
1724 ++ superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1725 ++ superio_exit();
1726 ++ } else {
1727 ++ pr_warn("Failed to disable device\n");
1728 ++ }
1729 + }
1730 + }
1731 +
1732 +diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
1733 +index 3a6bfa51cb94..95d5e8ec8b7f 100644
1734 +--- a/drivers/hwmon/vt1211.c
1735 ++++ b/drivers/hwmon/vt1211.c
1736 +@@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
1737 + outb(ldn, sio_cip + 1);
1738 + }
1739 +
1740 +-static inline void superio_enter(int sio_cip)
1741 ++static inline int superio_enter(int sio_cip)
1742 + {
1743 ++ if (!request_muxed_region(sio_cip, 2, DRVNAME))
1744 ++ return -EBUSY;
1745 ++
1746 + outb(0x87, sio_cip);
1747 + outb(0x87, sio_cip);
1748 ++
1749 ++ return 0;
1750 + }
1751 +
1752 + static inline void superio_exit(int sio_cip)
1753 + {
1754 + outb(0xaa, sio_cip);
1755 ++ release_region(sio_cip, 2);
1756 + }
1757 +
1758 + /* ---------------------------------------------------------------------
1759 +@@ -1282,11 +1288,14 @@ EXIT:
1760 +
1761 + static int __init vt1211_find(int sio_cip, unsigned short *address)
1762 + {
1763 +- int err = -ENODEV;
1764 ++ int err;
1765 + int devid;
1766 +
1767 +- superio_enter(sio_cip);
1768 ++ err = superio_enter(sio_cip);
1769 ++ if (err)
1770 ++ return err;
1771 +
1772 ++ err = -ENODEV;
1773 + devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
1774 + if (devid != SIO_VT1211_ID)
1775 + goto EXIT;
1776 +diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
1777 +index a1d072ecb717..30f200ad6b97 100644
1778 +--- a/drivers/iio/adc/ad_sigma_delta.c
1779 ++++ b/drivers/iio/adc/ad_sigma_delta.c
1780 +@@ -62,7 +62,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
1781 + struct spi_transfer t = {
1782 + .tx_buf = data,
1783 + .len = size + 1,
1784 +- .cs_change = sigma_delta->bus_locked,
1785 ++ .cs_change = sigma_delta->keep_cs_asserted,
1786 + };
1787 + struct spi_message m;
1788 + int ret;
1789 +@@ -217,6 +217,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1790 +
1791 + spi_bus_lock(sigma_delta->spi->master);
1792 + sigma_delta->bus_locked = true;
1793 ++ sigma_delta->keep_cs_asserted = true;
1794 + reinit_completion(&sigma_delta->completion);
1795 +
1796 + ret = ad_sigma_delta_set_mode(sigma_delta, mode);
1797 +@@ -234,9 +235,10 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1798 + ret = 0;
1799 + }
1800 + out:
1801 ++ sigma_delta->keep_cs_asserted = false;
1802 ++ ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1803 + sigma_delta->bus_locked = false;
1804 + spi_bus_unlock(sigma_delta->spi->master);
1805 +- ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1806 +
1807 + return ret;
1808 + }
1809 +@@ -288,6 +290,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1810 +
1811 + spi_bus_lock(sigma_delta->spi->master);
1812 + sigma_delta->bus_locked = true;
1813 ++ sigma_delta->keep_cs_asserted = true;
1814 + reinit_completion(&sigma_delta->completion);
1815 +
1816 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_SINGLE);
1817 +@@ -297,9 +300,6 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1818 + ret = wait_for_completion_interruptible_timeout(
1819 + &sigma_delta->completion, HZ);
1820 +
1821 +- sigma_delta->bus_locked = false;
1822 +- spi_bus_unlock(sigma_delta->spi->master);
1823 +-
1824 + if (ret == 0)
1825 + ret = -EIO;
1826 + if (ret < 0)
1827 +@@ -315,7 +315,10 @@ out:
1828 + sigma_delta->irq_dis = true;
1829 + }
1830 +
1831 ++ sigma_delta->keep_cs_asserted = false;
1832 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1833 ++ sigma_delta->bus_locked = false;
1834 ++ spi_bus_unlock(sigma_delta->spi->master);
1835 + mutex_unlock(&indio_dev->mlock);
1836 +
1837 + if (ret)
1838 +@@ -352,6 +355,8 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
1839 +
1840 + spi_bus_lock(sigma_delta->spi->master);
1841 + sigma_delta->bus_locked = true;
1842 ++ sigma_delta->keep_cs_asserted = true;
1843 ++
1844 + ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS);
1845 + if (ret)
1846 + goto err_unlock;
1847 +@@ -380,6 +385,7 @@ static int ad_sd_buffer_postdisable(struct iio_dev *indio_dev)
1848 + sigma_delta->irq_dis = true;
1849 + }
1850 +
1851 ++ sigma_delta->keep_cs_asserted = false;
1852 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1853 +
1854 + sigma_delta->bus_locked = false;
1855 +diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
1856 +index 645f2e3975db..e38f704d88b7 100644
1857 +--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
1858 ++++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
1859 +@@ -81,7 +81,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
1860 + unsigned int len, int64_t timestamp)
1861 + {
1862 + __le32 time;
1863 +- int64_t calculated_time;
1864 ++ int64_t calculated_time = 0;
1865 + struct ssp_sensor_data *spd = iio_priv(indio_dev);
1866 +
1867 + if (indio_dev->scan_bytes == 0)
1868 +diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
1869 +index 3de7f4426ac4..86abba5827a2 100644
1870 +--- a/drivers/iio/magnetometer/hmc5843_i2c.c
1871 ++++ b/drivers/iio/magnetometer/hmc5843_i2c.c
1872 +@@ -58,8 +58,13 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
1873 + static int hmc5843_i2c_probe(struct i2c_client *cli,
1874 + const struct i2c_device_id *id)
1875 + {
1876 ++ struct regmap *regmap = devm_regmap_init_i2c(cli,
1877 ++ &hmc5843_i2c_regmap_config);
1878 ++ if (IS_ERR(regmap))
1879 ++ return PTR_ERR(regmap);
1880 ++
1881 + return hmc5843_common_probe(&cli->dev,
1882 +- devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
1883 ++ regmap,
1884 + id->driver_data, id->name);
1885 + }
1886 +
1887 +diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
1888 +index 535f03a70d63..79b2b707f90e 100644
1889 +--- a/drivers/iio/magnetometer/hmc5843_spi.c
1890 ++++ b/drivers/iio/magnetometer/hmc5843_spi.c
1891 +@@ -58,6 +58,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = {
1892 + static int hmc5843_spi_probe(struct spi_device *spi)
1893 + {
1894 + int ret;
1895 ++ struct regmap *regmap;
1896 + const struct spi_device_id *id = spi_get_device_id(spi);
1897 +
1898 + spi->mode = SPI_MODE_3;
1899 +@@ -67,8 +68,12 @@ static int hmc5843_spi_probe(struct spi_device *spi)
1900 + if (ret)
1901 + return ret;
1902 +
1903 ++ regmap = devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config);
1904 ++ if (IS_ERR(regmap))
1905 ++ return PTR_ERR(regmap);
1906 ++
1907 + return hmc5843_common_probe(&spi->dev,
1908 +- devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
1909 ++ regmap,
1910 + id->driver_data, id->name);
1911 + }
1912 +
1913 +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
1914 +index e17f11782821..d87f08cd78ad 100644
1915 +--- a/drivers/infiniband/hw/cxgb4/cm.c
1916 ++++ b/drivers/infiniband/hw/cxgb4/cm.c
1917 +@@ -456,6 +456,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp)
1918 + skb_reset_transport_header(skb);
1919 + } else {
1920 + skb = alloc_skb(len, gfp);
1921 ++ if (!skb)
1922 ++ return NULL;
1923 + }
1924 + t4_set_arp_err_handler(skb, NULL, NULL);
1925 + return skb;
1926 +diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
1927 +index b7481701542e..27e7de4c4a34 100644
1928 +--- a/drivers/infiniband/hw/hfi1/init.c
1929 ++++ b/drivers/infiniband/hw/hfi1/init.c
1930 +@@ -769,7 +769,8 @@ static int create_workqueues(struct hfi1_devdata *dd)
1931 + ppd->hfi1_wq =
1932 + alloc_workqueue(
1933 + "hfi%d_%d",
1934 +- WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE,
1935 ++ WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE |
1936 ++ WQ_MEM_RECLAIM,
1937 + HFI1_MAX_ACTIVE_WORKQUEUE_ENTRIES,
1938 + dd->unit, pidx);
1939 + if (!ppd->hfi1_wq)
1940 +diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
1941 +index d545302b8ef8..0cdd4492811b 100644
1942 +--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
1943 ++++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
1944 +@@ -91,7 +91,7 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
1945 + HNS_ROCE_VLAN_SL_BIT_MASK) <<
1946 + HNS_ROCE_VLAN_SL_SHIFT;
1947 +
1948 +- ah->av.port_pd = cpu_to_be32(to_hr_pd(ibpd)->pdn |
1949 ++ ah->av.port_pd = cpu_to_le32(to_hr_pd(ibpd)->pdn |
1950 + (rdma_ah_get_port_num(ah_attr) <<
1951 + HNS_ROCE_PORT_NUM_SHIFT));
1952 + ah->av.gid_index = grh->sgid_index;
1953 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
1954 +index 8c13a9036d07..ada94a01e142 100644
1955 +--- a/drivers/md/bcache/alloc.c
1956 ++++ b/drivers/md/bcache/alloc.c
1957 +@@ -325,10 +325,11 @@ static int bch_allocator_thread(void *arg)
1958 + * possibly issue discards to them, then we add the bucket to
1959 + * the free list:
1960 + */
1961 +- while (!fifo_empty(&ca->free_inc)) {
1962 ++ while (1) {
1963 + long bucket;
1964 +
1965 +- fifo_pop(&ca->free_inc, bucket);
1966 ++ if (!fifo_pop(&ca->free_inc, bucket))
1967 ++ break;
1968 +
1969 + if (ca->discard) {
1970 + mutex_unlock(&ca->set->bucket_lock);
1971 +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
1972 +index c02394c3181f..6394be5ee9a8 100644
1973 +--- a/drivers/md/bcache/journal.c
1974 ++++ b/drivers/md/bcache/journal.c
1975 +@@ -310,6 +310,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list)
1976 + }
1977 + }
1978 +
1979 ++bool is_discard_enabled(struct cache_set *s)
1980 ++{
1981 ++ struct cache *ca;
1982 ++ unsigned int i;
1983 ++
1984 ++ for_each_cache(ca, s, i)
1985 ++ if (ca->discard)
1986 ++ return true;
1987 ++
1988 ++ return false;
1989 ++}
1990 ++
1991 + int bch_journal_replay(struct cache_set *s, struct list_head *list)
1992 + {
1993 + int ret = 0, keys = 0, entries = 0;
1994 +@@ -323,9 +335,17 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
1995 + list_for_each_entry(i, list, list) {
1996 + BUG_ON(i->pin && atomic_read(i->pin) != 1);
1997 +
1998 +- cache_set_err_on(n != i->j.seq, s,
1999 +-"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
2000 +- n, i->j.seq - 1, start, end);
2001 ++ if (n != i->j.seq) {
2002 ++ if (n == start && is_discard_enabled(s))
2003 ++ pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)",
2004 ++ n, i->j.seq - 1, start, end);
2005 ++ else {
2006 ++ pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
2007 ++ n, i->j.seq - 1, start, end);
2008 ++ ret = -EIO;
2009 ++ goto err;
2010 ++ }
2011 ++ }
2012 +
2013 + for (k = i->j.start;
2014 + k < bset_bkey_last(&i->j);
2015 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
2016 +index 175bab2d7206..85a5afe01d39 100644
2017 +--- a/drivers/md/bcache/super.c
2018 ++++ b/drivers/md/bcache/super.c
2019 +@@ -1560,7 +1560,7 @@ err:
2020 + return NULL;
2021 + }
2022 +
2023 +-static void run_cache_set(struct cache_set *c)
2024 ++static int run_cache_set(struct cache_set *c)
2025 + {
2026 + const char *err = "cannot allocate memory";
2027 + struct cached_dev *dc, *t;
2028 +@@ -1652,7 +1652,9 @@ static void run_cache_set(struct cache_set *c)
2029 + if (j->version < BCACHE_JSET_VERSION_UUID)
2030 + __uuid_write(c);
2031 +
2032 +- bch_journal_replay(c, &journal);
2033 ++ err = "bcache: replay journal failed";
2034 ++ if (bch_journal_replay(c, &journal))
2035 ++ goto err;
2036 + } else {
2037 + pr_notice("invalidating existing data");
2038 +
2039 +@@ -1720,11 +1722,13 @@ static void run_cache_set(struct cache_set *c)
2040 + flash_devs_run(c);
2041 +
2042 + set_bit(CACHE_SET_RUNNING, &c->flags);
2043 +- return;
2044 ++ return 0;
2045 + err:
2046 + closure_sync(&cl);
2047 + /* XXX: test this, it's broken */
2048 + bch_cache_set_error(c, "%s", err);
2049 ++
2050 ++ return -EIO;
2051 + }
2052 +
2053 + static bool can_attach_cache(struct cache *ca, struct cache_set *c)
2054 +@@ -1788,8 +1792,11 @@ found:
2055 + ca->set->cache[ca->sb.nr_this_dev] = ca;
2056 + c->cache_by_alloc[c->caches_loaded++] = ca;
2057 +
2058 +- if (c->caches_loaded == c->sb.nr_in_set)
2059 +- run_cache_set(c);
2060 ++ if (c->caches_loaded == c->sb.nr_in_set) {
2061 ++ err = "failed to run cache set";
2062 ++ if (run_cache_set(c) < 0)
2063 ++ goto err;
2064 ++ }
2065 +
2066 + return NULL;
2067 + err:
2068 +diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
2069 +index 65d157fe76d1..b4bd1af34745 100644
2070 +--- a/drivers/media/dvb-frontends/m88ds3103.c
2071 ++++ b/drivers/media/dvb-frontends/m88ds3103.c
2072 +@@ -309,6 +309,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
2073 + u16 u16tmp;
2074 + u32 tuner_frequency_khz, target_mclk;
2075 + s32 s32tmp;
2076 ++ static const struct reg_sequence reset_buf[] = {
2077 ++ {0x07, 0x80}, {0x07, 0x00}
2078 ++ };
2079 +
2080 + dev_dbg(&client->dev,
2081 + "delivery_system=%d modulation=%d frequency=%u symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n",
2082 +@@ -321,11 +324,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
2083 + }
2084 +
2085 + /* reset */
2086 +- ret = regmap_write(dev->regmap, 0x07, 0x80);
2087 +- if (ret)
2088 +- goto err;
2089 +-
2090 +- ret = regmap_write(dev->regmap, 0x07, 0x00);
2091 ++ ret = regmap_multi_reg_write(dev->regmap, reset_buf, 2);
2092 + if (ret)
2093 + goto err;
2094 +
2095 +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
2096 +index 122dd6c5eb38..ce23f436e130 100644
2097 +--- a/drivers/media/i2c/ov2659.c
2098 ++++ b/drivers/media/i2c/ov2659.c
2099 +@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
2100 + if (ov2659_formats[index].code == mf->code)
2101 + break;
2102 +
2103 +- if (index < 0)
2104 +- return -EINVAL;
2105 ++ if (index < 0) {
2106 ++ index = 0;
2107 ++ mf->code = ov2659_formats[index].code;
2108 ++ }
2109 +
2110 + mf->colorspace = V4L2_COLORSPACE_SRGB;
2111 + mf->field = V4L2_FIELD_NONE;
2112 +diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
2113 +index 07bc819f5819..025869eec2ac 100644
2114 +--- a/drivers/media/i2c/ov6650.c
2115 ++++ b/drivers/media/i2c/ov6650.c
2116 +@@ -822,9 +822,16 @@ static int ov6650_video_probe(struct i2c_client *client)
2117 + u8 pidh, pidl, midh, midl;
2118 + int ret;
2119 +
2120 ++ priv->clk = v4l2_clk_get(&client->dev, NULL);
2121 ++ if (IS_ERR(priv->clk)) {
2122 ++ ret = PTR_ERR(priv->clk);
2123 ++ dev_err(&client->dev, "v4l2_clk request err: %d\n", ret);
2124 ++ return ret;
2125 ++ }
2126 ++
2127 + ret = ov6650_s_power(&priv->subdev, 1);
2128 + if (ret < 0)
2129 +- return ret;
2130 ++ goto eclkput;
2131 +
2132 + msleep(20);
2133 +
2134 +@@ -861,6 +868,11 @@ static int ov6650_video_probe(struct i2c_client *client)
2135 +
2136 + done:
2137 + ov6650_s_power(&priv->subdev, 0);
2138 ++ if (!ret)
2139 ++ return 0;
2140 ++eclkput:
2141 ++ v4l2_clk_put(priv->clk);
2142 ++
2143 + return ret;
2144 + }
2145 +
2146 +@@ -1006,18 +1018,9 @@ static int ov6650_probe(struct i2c_client *client,
2147 + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
2148 + priv->colorspace = V4L2_COLORSPACE_JPEG;
2149 +
2150 +- priv->clk = v4l2_clk_get(&client->dev, NULL);
2151 +- if (IS_ERR(priv->clk)) {
2152 +- ret = PTR_ERR(priv->clk);
2153 +- goto eclkget;
2154 +- }
2155 +-
2156 + ret = ov6650_video_probe(client);
2157 +- if (ret) {
2158 +- v4l2_clk_put(priv->clk);
2159 +-eclkget:
2160 ++ if (ret)
2161 + v4l2_ctrl_handler_free(&priv->hdl);
2162 +- }
2163 +
2164 + return ret;
2165 + }
2166 +diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
2167 +index f708cab01fef..934332f1fd8e 100644
2168 +--- a/drivers/media/pci/saa7146/hexium_gemini.c
2169 ++++ b/drivers/media/pci/saa7146/hexium_gemini.c
2170 +@@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
2171 + /* enable i2c-port pins */
2172 + saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
2173 +
2174 +- hexium->i2c_adapter = (struct i2c_adapter) {
2175 +- .name = "hexium gemini",
2176 +- };
2177 ++ strscpy(hexium->i2c_adapter.name, "hexium gemini",
2178 ++ sizeof(hexium->i2c_adapter.name));
2179 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
2180 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
2181 + DEB_S("cannot register i2c-device. skipping.\n");
2182 +diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
2183 +index 01f01580c7ca..cb71653a6669 100644
2184 +--- a/drivers/media/pci/saa7146/hexium_orion.c
2185 ++++ b/drivers/media/pci/saa7146/hexium_orion.c
2186 +@@ -232,9 +232,8 @@ static int hexium_probe(struct saa7146_dev *dev)
2187 + saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2188 + saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2189 +
2190 +- hexium->i2c_adapter = (struct i2c_adapter) {
2191 +- .name = "hexium orion",
2192 +- };
2193 ++ strscpy(hexium->i2c_adapter.name, "hexium orion",
2194 ++ sizeof(hexium->i2c_adapter.name));
2195 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
2196 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
2197 + DEB_S("cannot register i2c-device. skipping.\n");
2198 +diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
2199 +index 3457a5f1c8a8..6eee55430d46 100644
2200 +--- a/drivers/media/platform/coda/coda-bit.c
2201 ++++ b/drivers/media/platform/coda/coda-bit.c
2202 +@@ -1948,6 +1948,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
2203 + /* Clear decode success flag */
2204 + coda_write(dev, 0, CODA_RET_DEC_PIC_SUCCESS);
2205 +
2206 ++ /* Clear error return value */
2207 ++ coda_write(dev, 0, CODA_RET_DEC_PIC_ERR_MB);
2208 ++
2209 + trace_coda_dec_pic_run(ctx, meta);
2210 +
2211 + coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
2212 +diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
2213 +index 35ba6f211b79..4281f3f76ab1 100644
2214 +--- a/drivers/media/platform/stm32/stm32-dcmi.c
2215 ++++ b/drivers/media/platform/stm32/stm32-dcmi.c
2216 +@@ -775,6 +775,9 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f,
2217 +
2218 + sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
2219 + if (!sd_fmt) {
2220 ++ if (!dcmi->num_of_sd_formats)
2221 ++ return -ENODATA;
2222 ++
2223 + sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
2224 + pix->pixelformat = sd_fmt->fourcc;
2225 + }
2226 +@@ -946,6 +949,9 @@ static int dcmi_set_sensor_format(struct stm32_dcmi *dcmi,
2227 +
2228 + sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
2229 + if (!sd_fmt) {
2230 ++ if (!dcmi->num_of_sd_formats)
2231 ++ return -ENODATA;
2232 ++
2233 + sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
2234 + pix->pixelformat = sd_fmt->fourcc;
2235 + }
2236 +diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
2237 +index ee89ad76bee2..eedc0b99a891 100644
2238 +--- a/drivers/media/platform/video-mux.c
2239 ++++ b/drivers/media/platform/video-mux.c
2240 +@@ -242,9 +242,14 @@ static int video_mux_probe(struct platform_device *pdev)
2241 + vmux->active = -1;
2242 + vmux->pads = devm_kcalloc(dev, num_pads, sizeof(*vmux->pads),
2243 + GFP_KERNEL);
2244 ++ if (!vmux->pads)
2245 ++ return -ENOMEM;
2246 ++
2247 + vmux->format_mbus = devm_kcalloc(dev, num_pads,
2248 + sizeof(*vmux->format_mbus),
2249 + GFP_KERNEL);
2250 ++ if (!vmux->format_mbus)
2251 ++ return -ENOMEM;
2252 +
2253 + for (i = 0; i < num_pads - 1; i++)
2254 + vmux->pads[i].flags = MEDIA_PAD_FL_SINK;
2255 +diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
2256 +index 51c0eee61ca6..57e5d6a020b0 100644
2257 +--- a/drivers/media/platform/vimc/vimc-core.c
2258 ++++ b/drivers/media/platform/vimc/vimc-core.c
2259 +@@ -302,6 +302,8 @@ static int vimc_probe(struct platform_device *pdev)
2260 +
2261 + dev_dbg(&pdev->dev, "probe");
2262 +
2263 ++ memset(&vimc->mdev, 0, sizeof(vimc->mdev));
2264 ++
2265 + /* Create platform_device for each entity in the topology*/
2266 + vimc->subdevs = devm_kcalloc(&vimc->pdev.dev, vimc->pipe_cfg->num_ents,
2267 + sizeof(*vimc->subdevs), GFP_KERNEL);
2268 +diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c
2269 +index fcc897fb247b..392754c18046 100644
2270 +--- a/drivers/media/platform/vimc/vimc-streamer.c
2271 ++++ b/drivers/media/platform/vimc/vimc-streamer.c
2272 +@@ -120,7 +120,6 @@ static int vimc_streamer_thread(void *data)
2273 + int i;
2274 +
2275 + set_freezable();
2276 +- set_current_state(TASK_UNINTERRUPTIBLE);
2277 +
2278 + for (;;) {
2279 + try_to_freeze();
2280 +@@ -137,6 +136,7 @@ static int vimc_streamer_thread(void *data)
2281 + break;
2282 + }
2283 + //wait for 60hz
2284 ++ set_current_state(TASK_UNINTERRUPTIBLE);
2285 + schedule_timeout(HZ / 60);
2286 + }
2287 +
2288 +diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
2289 +index a7a366093524..4ca3d600aa84 100644
2290 +--- a/drivers/media/platform/vivid/vivid-vid-cap.c
2291 ++++ b/drivers/media/platform/vivid/vivid-vid-cap.c
2292 +@@ -1007,7 +1007,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selection
2293 + v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect);
2294 + if (dev->bitmap_cap && (compose->width != s->r.width ||
2295 + compose->height != s->r.height)) {
2296 +- kfree(dev->bitmap_cap);
2297 ++ vfree(dev->bitmap_cap);
2298 + dev->bitmap_cap = NULL;
2299 + }
2300 + *compose = s->r;
2301 +diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
2302 +index ab3428bf63fe..26895ae42fcf 100644
2303 +--- a/drivers/media/radio/wl128x/fmdrv_common.c
2304 ++++ b/drivers/media/radio/wl128x/fmdrv_common.c
2305 +@@ -489,7 +489,8 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload,
2306 + return -EIO;
2307 + }
2308 + /* Send response data to caller */
2309 +- if (response != NULL && response_len != NULL && evt_hdr->dlen) {
2310 ++ if (response != NULL && response_len != NULL && evt_hdr->dlen &&
2311 ++ evt_hdr->dlen <= payload_len) {
2312 + /* Skip header info and copy only response data */
2313 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
2314 + memcpy(response, skb->data, evt_hdr->dlen);
2315 +@@ -583,6 +584,8 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev)
2316 + return;
2317 +
2318 + fm_evt_hdr = (void *)skb->data;
2319 ++ if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag))
2320 ++ return;
2321 +
2322 + /* Skip header info and copy only response data */
2323 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
2324 +@@ -1308,7 +1311,7 @@ static int load_default_rx_configuration(struct fmdev *fmdev)
2325 + static int fm_power_up(struct fmdev *fmdev, u8 mode)
2326 + {
2327 + u16 payload;
2328 +- __be16 asic_id, asic_ver;
2329 ++ __be16 asic_id = 0, asic_ver = 0;
2330 + int resp_len, ret;
2331 + u8 fw_name[50];
2332 +
2333 +diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
2334 +index 8b66926bc16a..842c121dca2d 100644
2335 +--- a/drivers/media/rc/serial_ir.c
2336 ++++ b/drivers/media/rc/serial_ir.c
2337 +@@ -774,8 +774,6 @@ static void serial_ir_exit(void)
2338 +
2339 + static int __init serial_ir_init_module(void)
2340 + {
2341 +- int result;
2342 +-
2343 + switch (type) {
2344 + case IR_HOMEBREW:
2345 + case IR_IRDEO:
2346 +@@ -803,12 +801,7 @@ static int __init serial_ir_init_module(void)
2347 + if (sense != -1)
2348 + sense = !!sense;
2349 +
2350 +- result = serial_ir_init();
2351 +- if (!result)
2352 +- return 0;
2353 +-
2354 +- serial_ir_exit();
2355 +- return result;
2356 ++ return serial_ir_init();
2357 + }
2358 +
2359 + static void __exit serial_ir_exit_module(void)
2360 +diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
2361 +index 9342402b92f7..067f46c4f61a 100644
2362 +--- a/drivers/media/usb/au0828/au0828-video.c
2363 ++++ b/drivers/media/usb/au0828/au0828-video.c
2364 +@@ -758,6 +758,9 @@ static int au0828_analog_stream_enable(struct au0828_dev *d)
2365 +
2366 + dprintk(1, "au0828_analog_stream_enable called\n");
2367 +
2368 ++ if (test_bit(DEV_DISCONNECTED, &d->dev_state))
2369 ++ return -ENODEV;
2370 ++
2371 + iface = usb_ifnum_to_if(d->usbdev, 0);
2372 + if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) {
2373 + dprintk(1, "Changing intf#0 to alt 5\n");
2374 +@@ -839,9 +842,9 @@ int au0828_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
2375 + return rc;
2376 + }
2377 +
2378 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1);
2379 ++
2380 + if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
2381 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video,
2382 +- s_stream, 1);
2383 + dev->vid_timeout_running = 1;
2384 + mod_timer(&dev->vid_timeout, jiffies + (HZ / 10));
2385 + } else if (vq->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
2386 +@@ -861,10 +864,11 @@ static void au0828_stop_streaming(struct vb2_queue *vq)
2387 +
2388 + dprintk(1, "au0828_stop_streaming called %d\n", dev->streaming_users);
2389 +
2390 +- if (dev->streaming_users-- == 1)
2391 ++ if (dev->streaming_users-- == 1) {
2392 + au0828_uninit_isoc(dev);
2393 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2394 ++ }
2395 +
2396 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2397 + dev->vid_timeout_running = 0;
2398 + del_timer_sync(&dev->vid_timeout);
2399 +
2400 +@@ -893,8 +897,10 @@ void au0828_stop_vbi_streaming(struct vb2_queue *vq)
2401 + dprintk(1, "au0828_stop_vbi_streaming called %d\n",
2402 + dev->streaming_users);
2403 +
2404 +- if (dev->streaming_users-- == 1)
2405 ++ if (dev->streaming_users-- == 1) {
2406 + au0828_uninit_isoc(dev);
2407 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2408 ++ }
2409 +
2410 + spin_lock_irqsave(&dev->slock, flags);
2411 + if (dev->isoc_ctl.vbi_buf != NULL) {
2412 +diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
2413 +index a1c59f19cf2d..1e3da414319b 100644
2414 +--- a/drivers/media/usb/cpia2/cpia2_v4l.c
2415 ++++ b/drivers/media/usb/cpia2/cpia2_v4l.c
2416 +@@ -1244,8 +1244,7 @@ static int __init cpia2_init(void)
2417 + LOG("%s v%s\n",
2418 + ABOUT, CPIA_VERSION);
2419 + check_parameters();
2420 +- cpia2_usb_init();
2421 +- return 0;
2422 ++ return cpia2_usb_init();
2423 + }
2424 +
2425 +
2426 +diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c
2427 +index 60bf5f0644d1..a5efcd4f7b4f 100644
2428 +--- a/drivers/media/usb/go7007/go7007-fw.c
2429 ++++ b/drivers/media/usb/go7007/go7007-fw.c
2430 +@@ -1499,8 +1499,8 @@ static int modet_to_package(struct go7007 *go, __le16 *code, int space)
2431 + return cnt;
2432 + }
2433 +
2434 +-static int do_special(struct go7007 *go, u16 type, __le16 *code, int space,
2435 +- int *framelen)
2436 ++static noinline_for_stack int do_special(struct go7007 *go, u16 type,
2437 ++ __le16 *code, int space, int *framelen)
2438 + {
2439 + switch (type) {
2440 + case SPECIAL_FRM_HEAD:
2441 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2442 +index 44975061b953..ddededc4ced4 100644
2443 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2444 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2445 +@@ -666,6 +666,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
2446 +
2447 + static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
2448 + {
2449 ++ if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
2450 ++ return 0;
2451 + return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
2452 + }
2453 +
2454 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2455 +index 25648add77e5..bd2b7a67b732 100644
2456 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2457 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2458 +@@ -50,6 +50,7 @@
2459 + #define PVR2_CVAL_INPUT_COMPOSITE 2
2460 + #define PVR2_CVAL_INPUT_SVIDEO 3
2461 + #define PVR2_CVAL_INPUT_RADIO 4
2462 ++#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
2463 +
2464 + enum pvr2_config {
2465 + pvr2_config_empty, /* No configuration */
2466 +diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c
2467 +index efb8a7965dd4..154f4204d58c 100644
2468 +--- a/drivers/mmc/core/pwrseq_emmc.c
2469 ++++ b/drivers/mmc/core/pwrseq_emmc.c
2470 +@@ -30,19 +30,14 @@ struct mmc_pwrseq_emmc {
2471 +
2472 + #define to_pwrseq_emmc(p) container_of(p, struct mmc_pwrseq_emmc, pwrseq)
2473 +
2474 +-static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq)
2475 +-{
2476 +- gpiod_set_value(pwrseq->reset_gpio, 1);
2477 +- udelay(1);
2478 +- gpiod_set_value(pwrseq->reset_gpio, 0);
2479 +- udelay(200);
2480 +-}
2481 +-
2482 + static void mmc_pwrseq_emmc_reset(struct mmc_host *host)
2483 + {
2484 + struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(host->pwrseq);
2485 +
2486 +- __mmc_pwrseq_emmc_reset(pwrseq);
2487 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
2488 ++ udelay(1);
2489 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
2490 ++ udelay(200);
2491 + }
2492 +
2493 + static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
2494 +@@ -50,8 +45,11 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
2495 + {
2496 + struct mmc_pwrseq_emmc *pwrseq = container_of(this,
2497 + struct mmc_pwrseq_emmc, reset_nb);
2498 ++ gpiod_set_value(pwrseq->reset_gpio, 1);
2499 ++ udelay(1);
2500 ++ gpiod_set_value(pwrseq->reset_gpio, 0);
2501 ++ udelay(200);
2502 +
2503 +- __mmc_pwrseq_emmc_reset(pwrseq);
2504 + return NOTIFY_DONE;
2505 + }
2506 +
2507 +@@ -72,14 +70,18 @@ static int mmc_pwrseq_emmc_probe(struct platform_device *pdev)
2508 + if (IS_ERR(pwrseq->reset_gpio))
2509 + return PTR_ERR(pwrseq->reset_gpio);
2510 +
2511 +- /*
2512 +- * register reset handler to ensure emmc reset also from
2513 +- * emergency_reboot(), priority 255 is the highest priority
2514 +- * so it will be executed before any system reboot handler.
2515 +- */
2516 +- pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
2517 +- pwrseq->reset_nb.priority = 255;
2518 +- register_restart_handler(&pwrseq->reset_nb);
2519 ++ if (!gpiod_cansleep(pwrseq->reset_gpio)) {
2520 ++ /*
2521 ++ * register reset handler to ensure emmc reset also from
2522 ++ * emergency_reboot(), priority 255 is the highest priority
2523 ++ * so it will be executed before any system reboot handler.
2524 ++ */
2525 ++ pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
2526 ++ pwrseq->reset_nb.priority = 255;
2527 ++ register_restart_handler(&pwrseq->reset_nb);
2528 ++ } else {
2529 ++ dev_notice(dev, "EMMC reset pin tied to a sleepy GPIO driver; reset on emergency-reboot disabled\n");
2530 ++ }
2531 +
2532 + pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops;
2533 + pwrseq->pwrseq.dev = dev;
2534 +diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
2535 +index eb9de2134967..fe2ef52135b6 100644
2536 +--- a/drivers/mmc/core/sd.c
2537 ++++ b/drivers/mmc/core/sd.c
2538 +@@ -216,6 +216,14 @@ static int mmc_decode_scr(struct mmc_card *card)
2539 +
2540 + if (scr->sda_spec3)
2541 + scr->cmds = UNSTUFF_BITS(resp, 32, 2);
2542 ++
2543 ++ /* SD Spec says: any SD Card shall set at least bits 0 and 2 */
2544 ++ if (!(scr->bus_widths & SD_SCR_BUS_WIDTH_1) ||
2545 ++ !(scr->bus_widths & SD_SCR_BUS_WIDTH_4)) {
2546 ++ pr_err("%s: invalid bus width\n", mmc_hostname(card->host));
2547 ++ return -EINVAL;
2548 ++ }
2549 ++
2550 + return 0;
2551 + }
2552 +
2553 +diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
2554 +index 67f6bd24a9d0..ea254d00541f 100644
2555 +--- a/drivers/mmc/host/mmc_spi.c
2556 ++++ b/drivers/mmc/host/mmc_spi.c
2557 +@@ -819,6 +819,10 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
2558