Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Thu, 30 Nov 2017 12:19:28
Message-Id: 1512043986.c76265ce51a4f08cd3ac3598b0896bb2adf153d5.alicef@gentoo
1 commit: c76265ce51a4f08cd3ac3598b0896bb2adf153d5
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 30 12:13:06 2017 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 30 12:13:06 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c76265ce
7
8 linux kernel 4.9.66
9
10 0000_README | 4 +
11 1065_linux-4.9.66.patch | 4726 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 4730 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 98ea34c..045a3d8 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -303,6 +303,10 @@ Patch: 1064_linux-4.9.65.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.9.65
21
22 +Patch: 1065_linux-4.9.66.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.9.66
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1065_linux-4.9.66.patch b/1065_linux-4.9.66.patch
31 new file mode 100644
32 index 0000000..f277f12
33 --- /dev/null
34 +++ b/1065_linux-4.9.66.patch
35 @@ -0,0 +1,4726 @@
36 +diff --git a/Makefile b/Makefile
37 +index 87a641515e9c..8e62f9e2a08c 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,6 +1,6 @@
41 + VERSION = 4
42 + PATCHLEVEL = 9
43 +-SUBLEVEL = 65
44 ++SUBLEVEL = 66
45 + EXTRAVERSION =
46 + NAME = Roaring Lionus
47 +
48 +diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
49 +index 9fe8e241335c..e1f6f0daa847 100644
50 +--- a/arch/arm/mm/dump.c
51 ++++ b/arch/arm/mm/dump.c
52 +@@ -126,8 +126,8 @@ static const struct prot_bits section_bits[] = {
53 + .val = PMD_SECT_USER,
54 + .set = "USR",
55 + }, {
56 +- .mask = L_PMD_SECT_RDONLY,
57 +- .val = L_PMD_SECT_RDONLY,
58 ++ .mask = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
59 ++ .val = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
60 + .set = "ro",
61 + .clear = "RW",
62 + #elif __LINUX_ARM_ARCH__ >= 6
63 +diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
64 +index 370581aeb871..4c587ad8bfe3 100644
65 +--- a/arch/arm/mm/init.c
66 ++++ b/arch/arm/mm/init.c
67 +@@ -619,8 +619,8 @@ static struct section_perm ro_perms[] = {
68 + .start = (unsigned long)_stext,
69 + .end = (unsigned long)__init_begin,
70 + #ifdef CONFIG_ARM_LPAE
71 +- .mask = ~L_PMD_SECT_RDONLY,
72 +- .prot = L_PMD_SECT_RDONLY,
73 ++ .mask = ~(L_PMD_SECT_RDONLY | PMD_SECT_AP2),
74 ++ .prot = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
75 + #else
76 + .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
77 + .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,
78 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
79 +index 61e214015b38..7acd3c5c7643 100644
80 +--- a/arch/arm64/include/asm/pgtable.h
81 ++++ b/arch/arm64/include/asm/pgtable.h
82 +@@ -91,6 +91,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
83 + ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == (PTE_VALID | PTE_UXN))
84 + #define pte_valid_young(pte) \
85 + ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
86 ++#define pte_valid_user(pte) \
87 ++ ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
88 +
89 + /*
90 + * Could the pte be present in the TLB? We must check mm_tlb_flush_pending
91 +@@ -100,6 +102,18 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
92 + #define pte_accessible(mm, pte) \
93 + (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte))
94 +
95 ++/*
96 ++ * p??_access_permitted() is true for valid user mappings (subject to the
97 ++ * write permission check) other than user execute-only which do not have the
98 ++ * PTE_USER bit set. PROT_NONE mappings do not have the PTE_VALID bit set.
99 ++ */
100 ++#define pte_access_permitted(pte, write) \
101 ++ (pte_valid_user(pte) && (!(write) || pte_write(pte)))
102 ++#define pmd_access_permitted(pmd, write) \
103 ++ (pte_access_permitted(pmd_pte(pmd), (write)))
104 ++#define pud_access_permitted(pud, write) \
105 ++ (pte_access_permitted(pud_pte(pud), (write)))
106 ++
107 + static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
108 + {
109 + pte_val(pte) &= ~pgprot_val(prot);
110 +diff --git a/arch/mips/bcm47xx/leds.c b/arch/mips/bcm47xx/leds.c
111 +index d20ae63eb3c2..46abe9e4e0e0 100644
112 +--- a/arch/mips/bcm47xx/leds.c
113 ++++ b/arch/mips/bcm47xx/leds.c
114 +@@ -330,7 +330,7 @@ bcm47xx_leds_linksys_wrt54g3gv2[] __initconst = {
115 + /* Verified on: WRT54GS V1.0 */
116 + static const struct gpio_led
117 + bcm47xx_leds_linksys_wrt54g_type_0101[] __initconst = {
118 +- BCM47XX_GPIO_LED(0, "green", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF),
119 ++ BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
120 + BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON),
121 + BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),
122 + };
123 +diff --git a/arch/mips/boot/dts/brcm/Makefile b/arch/mips/boot/dts/brcm/Makefile
124 +index d61bc2aebf69..7d90a8710425 100644
125 +--- a/arch/mips/boot/dts/brcm/Makefile
126 ++++ b/arch/mips/boot/dts/brcm/Makefile
127 +@@ -22,7 +22,6 @@ dtb-$(CONFIG_DT_NONE) += \
128 + bcm63268-comtrend-vr-3032u.dtb \
129 + bcm93384wvg.dtb \
130 + bcm93384wvg_viper.dtb \
131 +- bcm96358nb4ser.dtb \
132 + bcm96368mvwg.dtb \
133 + bcm9ejtagprb.dtb \
134 + bcm97125cbmb.dtb \
135 +diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
136 +index 83054f79f72a..8333ce90b172 100644
137 +--- a/arch/mips/include/asm/asmmacro.h
138 ++++ b/arch/mips/include/asm/asmmacro.h
139 +@@ -19,6 +19,9 @@
140 + #include <asm/asmmacro-64.h>
141 + #endif
142 +
143 ++/* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
144 ++#undef fp
145 ++
146 + /*
147 + * Helper macros for generating raw instruction encodings.
148 + */
149 +@@ -105,6 +108,7 @@
150 + .macro fpu_save_16odd thread
151 + .set push
152 + .set mips64r2
153 ++ .set fp=64
154 + SET_HARDFLOAT
155 + sdc1 $f1, THREAD_FPR1(\thread)
156 + sdc1 $f3, THREAD_FPR3(\thread)
157 +@@ -163,6 +167,7 @@
158 + .macro fpu_restore_16odd thread
159 + .set push
160 + .set mips64r2
161 ++ .set fp=64
162 + SET_HARDFLOAT
163 + ldc1 $f1, THREAD_FPR1(\thread)
164 + ldc1 $f3, THREAD_FPR3(\thread)
165 +@@ -234,9 +239,6 @@
166 + .endm
167 +
168 + #ifdef TOOLCHAIN_SUPPORTS_MSA
169 +-/* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
170 +-#undef fp
171 +-
172 + .macro _cfcmsa rd, cs
173 + .set push
174 + .set mips32r2
175 +diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
176 +index 3de026034c35..11890e6e4093 100644
177 +--- a/arch/mips/kernel/ptrace.c
178 ++++ b/arch/mips/kernel/ptrace.c
179 +@@ -647,6 +647,19 @@ static const struct user_regset_view user_mips64_view = {
180 + .n = ARRAY_SIZE(mips64_regsets),
181 + };
182 +
183 ++#ifdef CONFIG_MIPS32_N32
184 ++
185 ++static const struct user_regset_view user_mipsn32_view = {
186 ++ .name = "mipsn32",
187 ++ .e_flags = EF_MIPS_ABI2,
188 ++ .e_machine = ELF_ARCH,
189 ++ .ei_osabi = ELF_OSABI,
190 ++ .regsets = mips64_regsets,
191 ++ .n = ARRAY_SIZE(mips64_regsets),
192 ++};
193 ++
194 ++#endif /* CONFIG_MIPS32_N32 */
195 ++
196 + #endif /* CONFIG_64BIT */
197 +
198 + const struct user_regset_view *task_user_regset_view(struct task_struct *task)
199 +@@ -657,6 +670,10 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
200 + #ifdef CONFIG_MIPS32_O32
201 + if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
202 + return &user_mips_view;
203 ++#endif
204 ++#ifdef CONFIG_MIPS32_N32
205 ++ if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
206 ++ return &user_mipsn32_view;
207 + #endif
208 + return &user_mips64_view;
209 + #endif
210 +diff --git a/arch/mips/pci/pci-mt7620.c b/arch/mips/pci/pci-mt7620.c
211 +index 628c5132b3d8..a7962f79c4fe 100644
212 +--- a/arch/mips/pci/pci-mt7620.c
213 ++++ b/arch/mips/pci/pci-mt7620.c
214 +@@ -121,7 +121,7 @@ static int wait_pciephy_busy(void)
215 + else
216 + break;
217 + if (retry++ > WAITRETRY_MAX) {
218 +- printk(KERN_WARN "PCIE-PHY retry failed.\n");
219 ++ pr_warn("PCIE-PHY retry failed.\n");
220 + return -1;
221 + }
222 + }
223 +diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c
224 +index 6f892c1f3ad7..0696142048d5 100644
225 +--- a/arch/mips/ralink/mt7620.c
226 ++++ b/arch/mips/ralink/mt7620.c
227 +@@ -141,8 +141,8 @@ static struct rt2880_pmx_func i2c_grp_mt7628[] = {
228 + FUNC("i2c", 0, 4, 2),
229 + };
230 +
231 +-static struct rt2880_pmx_func refclk_grp_mt7628[] = { FUNC("reclk", 0, 36, 1) };
232 +-static struct rt2880_pmx_func perst_grp_mt7628[] = { FUNC("perst", 0, 37, 1) };
233 ++static struct rt2880_pmx_func refclk_grp_mt7628[] = { FUNC("refclk", 0, 37, 1) };
234 ++static struct rt2880_pmx_func perst_grp_mt7628[] = { FUNC("perst", 0, 36, 1) };
235 + static struct rt2880_pmx_func wdt_grp_mt7628[] = { FUNC("wdt", 0, 38, 1) };
236 + static struct rt2880_pmx_func spi_grp_mt7628[] = { FUNC("spi", 0, 7, 4) };
237 +
238 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
239 +index 41e60a9c7db2..e775f80ae28c 100644
240 +--- a/arch/parisc/kernel/syscall.S
241 ++++ b/arch/parisc/kernel/syscall.S
242 +@@ -690,15 +690,15 @@ cas_action:
243 + /* ELF32 Process entry path */
244 + lws_compare_and_swap_2:
245 + #ifdef CONFIG_64BIT
246 +- /* Clip the input registers */
247 ++ /* Clip the input registers. We don't need to clip %r23 as we
248 ++ only use it for word operations */
249 + depdi 0, 31, 32, %r26
250 + depdi 0, 31, 32, %r25
251 + depdi 0, 31, 32, %r24
252 +- depdi 0, 31, 32, %r23
253 + #endif
254 +
255 + /* Check the validity of the size pointer */
256 +- subi,>>= 4, %r23, %r0
257 ++ subi,>>= 3, %r23, %r0
258 + b,n lws_exit_nosys
259 +
260 + /* Jump to the functions which will load the old and new values into
261 +diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
262 +index bbe77aed198d..3600c0d99ae9 100644
263 +--- a/arch/powerpc/kernel/signal.c
264 ++++ b/arch/powerpc/kernel/signal.c
265 +@@ -102,7 +102,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
266 + static void do_signal(struct task_struct *tsk)
267 + {
268 + sigset_t *oldset = sigmask_to_save();
269 +- struct ksignal ksig;
270 ++ struct ksignal ksig = { .sig = 0 };
271 + int ret;
272 + int is32 = is_32bit_task();
273 +
274 +diff --git a/arch/s390/include/asm/asm-prototypes.h b/arch/s390/include/asm/asm-prototypes.h
275 +new file mode 100644
276 +index 000000000000..2c3413b0ca52
277 +--- /dev/null
278 ++++ b/arch/s390/include/asm/asm-prototypes.h
279 +@@ -0,0 +1,8 @@
280 ++#ifndef _ASM_S390_PROTOTYPES_H
281 ++
282 ++#include <linux/kvm_host.h>
283 ++#include <linux/ftrace.h>
284 ++#include <asm/fpu/api.h>
285 ++#include <asm-generic/asm-prototypes.h>
286 ++
287 ++#endif /* _ASM_S390_PROTOTYPES_H */
288 +diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h
289 +index 12d45f0cfdd9..dde6b52359c5 100644
290 +--- a/arch/s390/include/asm/switch_to.h
291 ++++ b/arch/s390/include/asm/switch_to.h
292 +@@ -34,8 +34,8 @@ static inline void restore_access_regs(unsigned int *acrs)
293 + save_access_regs(&prev->thread.acrs[0]); \
294 + save_ri_cb(prev->thread.ri_cb); \
295 + } \
296 ++ update_cr_regs(next); \
297 + if (next->mm) { \
298 +- update_cr_regs(next); \
299 + set_cpu_flag(CIF_FPU); \
300 + restore_access_regs(&next->thread.acrs[0]); \
301 + restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
302 +diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
303 +index c74c59236f44..aaf9dab3c193 100644
304 +--- a/arch/s390/kernel/dis.c
305 ++++ b/arch/s390/kernel/dis.c
306 +@@ -1548,6 +1548,7 @@ static struct s390_insn opcode_e7[] = {
307 + { "vfsq", 0xce, INSTR_VRR_VV000MM },
308 + { "vfs", 0xe2, INSTR_VRR_VVV00MM },
309 + { "vftci", 0x4a, INSTR_VRI_VVIMM },
310 ++ { "", 0, INSTR_INVALID }
311 + };
312 +
313 + static struct s390_insn opcode_eb[] = {
314 +@@ -1953,7 +1954,7 @@ void show_code(struct pt_regs *regs)
315 + {
316 + char *mode = user_mode(regs) ? "User" : "Krnl";
317 + unsigned char code[64];
318 +- char buffer[64], *ptr;
319 ++ char buffer[128], *ptr;
320 + mm_segment_t old_fs;
321 + unsigned long addr;
322 + int start, end, opsize, hops, i;
323 +@@ -2016,7 +2017,7 @@ void show_code(struct pt_regs *regs)
324 + start += opsize;
325 + pr_cont("%s", buffer);
326 + ptr = buffer;
327 +- ptr += sprintf(ptr, "\n ");
328 ++ ptr += sprintf(ptr, "\n\t ");
329 + hops++;
330 + }
331 + pr_cont("\n");
332 +diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
333 +index 0c196861bc38..29d87444a655 100644
334 +--- a/arch/s390/kernel/early.c
335 ++++ b/arch/s390/kernel/early.c
336 +@@ -345,8 +345,10 @@ static __init void detect_machine_facilities(void)
337 + S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE;
338 + if (test_facility(40))
339 + S390_lowcore.machine_flags |= MACHINE_FLAG_LPP;
340 +- if (test_facility(50) && test_facility(73))
341 ++ if (test_facility(50) && test_facility(73)) {
342 + S390_lowcore.machine_flags |= MACHINE_FLAG_TE;
343 ++ __ctl_set_bit(0, 55);
344 ++ }
345 + if (test_facility(51))
346 + S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_LC;
347 + if (test_facility(129)) {
348 +diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
349 +index bba4fa74b321..172fe1121d99 100644
350 +--- a/arch/s390/kernel/process.c
351 ++++ b/arch/s390/kernel/process.c
352 +@@ -120,6 +120,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
353 + memset(&p->thread.per_user, 0, sizeof(p->thread.per_user));
354 + memset(&p->thread.per_event, 0, sizeof(p->thread.per_event));
355 + clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
356 ++ p->thread.per_flags = 0;
357 + /* Initialize per thread user and system timer values */
358 + ti = task_thread_info(p);
359 + ti->user_timer = 0;
360 +diff --git a/arch/s390/kernel/runtime_instr.c b/arch/s390/kernel/runtime_instr.c
361 +index fffa0e5462af..70cdb03d4acd 100644
362 +--- a/arch/s390/kernel/runtime_instr.c
363 ++++ b/arch/s390/kernel/runtime_instr.c
364 +@@ -47,11 +47,13 @@ void exit_thread_runtime_instr(void)
365 + {
366 + struct task_struct *task = current;
367 +
368 ++ preempt_disable();
369 + if (!task->thread.ri_cb)
370 + return;
371 + disable_runtime_instr();
372 + kfree(task->thread.ri_cb);
373 + task->thread.ri_cb = NULL;
374 ++ preempt_enable();
375 + }
376 +
377 + SYSCALL_DEFINE1(s390_runtime_instr, int, command)
378 +@@ -62,9 +64,7 @@ SYSCALL_DEFINE1(s390_runtime_instr, int, command)
379 + return -EOPNOTSUPP;
380 +
381 + if (command == S390_RUNTIME_INSTR_STOP) {
382 +- preempt_disable();
383 + exit_thread_runtime_instr();
384 +- preempt_enable();
385 + return 0;
386 + }
387 +
388 +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
389 +index e7b0e7ff4c58..be9df513141e 100644
390 +--- a/arch/x86/entry/entry_64.S
391 ++++ b/arch/x86/entry/entry_64.S
392 +@@ -54,15 +54,19 @@ ENTRY(native_usergs_sysret64)
393 + ENDPROC(native_usergs_sysret64)
394 + #endif /* CONFIG_PARAVIRT */
395 +
396 +-.macro TRACE_IRQS_IRETQ
397 ++.macro TRACE_IRQS_FLAGS flags:req
398 + #ifdef CONFIG_TRACE_IRQFLAGS
399 +- bt $9, EFLAGS(%rsp) /* interrupts off? */
400 ++ bt $9, \flags /* interrupts off? */
401 + jnc 1f
402 + TRACE_IRQS_ON
403 + 1:
404 + #endif
405 + .endm
406 +
407 ++.macro TRACE_IRQS_IRETQ
408 ++ TRACE_IRQS_FLAGS EFLAGS(%rsp)
409 ++.endm
410 ++
411 + /*
412 + * When dynamic function tracer is enabled it will add a breakpoint
413 + * to all locations that it is about to modify, sync CPUs, update
414 +@@ -868,11 +872,13 @@ idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0
415 + ENTRY(native_load_gs_index)
416 + pushfq
417 + DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
418 ++ TRACE_IRQS_OFF
419 + SWAPGS
420 + .Lgs_change:
421 + movl %edi, %gs
422 + 2: ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
423 + SWAPGS
424 ++ TRACE_IRQS_FLAGS (%rsp)
425 + popfq
426 + ret
427 + END(native_load_gs_index)
428 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
429 +index 8ca1eca5038d..4fbf0c94f2d1 100644
430 +--- a/arch/x86/kvm/svm.c
431 ++++ b/arch/x86/kvm/svm.c
432 +@@ -3583,6 +3583,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
433 + u32 ecx = msr->index;
434 + u64 data = msr->data;
435 + switch (ecx) {
436 ++ case MSR_IA32_CR_PAT:
437 ++ if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
438 ++ return 1;
439 ++ vcpu->arch.pat = data;
440 ++ svm->vmcb->save.g_pat = data;
441 ++ mark_dirty(svm->vmcb, VMCB_NPT);
442 ++ break;
443 + case MSR_IA32_TSC:
444 + kvm_write_tsc(vcpu, msr);
445 + break;
446 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
447 +index a8ae57acb6f6..0f0b27d96f27 100644
448 +--- a/arch/x86/kvm/vmx.c
449 ++++ b/arch/x86/kvm/vmx.c
450 +@@ -10715,6 +10715,8 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
451 + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->host_ia32_sysenter_eip);
452 + vmcs_writel(GUEST_IDTR_BASE, vmcs12->host_idtr_base);
453 + vmcs_writel(GUEST_GDTR_BASE, vmcs12->host_gdtr_base);
454 ++ vmcs_write32(GUEST_IDTR_LIMIT, 0xFFFF);
455 ++ vmcs_write32(GUEST_GDTR_LIMIT, 0xFFFF);
456 +
457 + /* If not VM_EXIT_CLEAR_BNDCFGS, the L2 value propagates to L1. */
458 + if (vmcs12->vm_exit_controls & VM_EXIT_CLEAR_BNDCFGS)
459 +diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
460 +index 767be7c76034..1754e094bc28 100644
461 +--- a/arch/x86/lib/x86-opcode-map.txt
462 ++++ b/arch/x86/lib/x86-opcode-map.txt
463 +@@ -896,7 +896,7 @@ EndTable
464 +
465 + GrpTable: Grp3_1
466 + 0: TEST Eb,Ib
467 +-1:
468 ++1: TEST Eb,Ib
469 + 2: NOT Eb
470 + 3: NEG Eb
471 + 4: MUL AL,Eb
472 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
473 +index 1dd796025472..8b5ff88aa4f8 100644
474 +--- a/arch/x86/mm/fault.c
475 ++++ b/arch/x86/mm/fault.c
476 +@@ -1393,7 +1393,17 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
477 + * make sure we exit gracefully rather than endlessly redo
478 + * the fault. Since we never set FAULT_FLAG_RETRY_NOWAIT, if
479 + * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked.
480 ++ *
481 ++ * Note that handle_userfault() may also release and reacquire mmap_sem
482 ++ * (and not return with VM_FAULT_RETRY), when returning to userland to
483 ++ * repeat the page fault later with a VM_FAULT_NOPAGE retval
484 ++ * (potentially after handling any pending signal during the return to
485 ++ * userland). The return to userland is identified whenever
486 ++ * FAULT_FLAG_USER|FAULT_FLAG_KILLABLE are both set in flags.
487 ++ * Thus we have to be careful about not touching vma after handling the
488 ++ * fault, so we read the pkey beforehand.
489 + */
490 ++ pkey = vma_pkey(vma);
491 + fault = handle_mm_fault(vma, address, flags);
492 + major |= fault & VM_FAULT_MAJOR;
493 +
494 +@@ -1420,7 +1430,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
495 + return;
496 + }
497 +
498 +- pkey = vma_pkey(vma);
499 + up_read(&mm->mmap_sem);
500 + if (unlikely(fault & VM_FAULT_ERROR)) {
501 + mm_fault_error(regs, error_code, address, &pkey, fault);
502 +diff --git a/block/blk-core.c b/block/blk-core.c
503 +index 95379fc83805..b1c76aa73492 100644
504 +--- a/block/blk-core.c
505 ++++ b/block/blk-core.c
506 +@@ -282,6 +282,7 @@ EXPORT_SYMBOL(blk_stop_queue);
507 + void blk_sync_queue(struct request_queue *q)
508 + {
509 + del_timer_sync(&q->timeout);
510 ++ cancel_work_sync(&q->timeout_work);
511 +
512 + if (q->mq_ops) {
513 + struct blk_mq_hw_ctx *hctx;
514 +@@ -720,6 +721,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
515 + setup_timer(&q->backing_dev_info.laptop_mode_wb_timer,
516 + laptop_mode_timer_fn, (unsigned long) q);
517 + setup_timer(&q->timeout, blk_rq_timed_out_timer, (unsigned long) q);
518 ++ INIT_WORK(&q->timeout_work, NULL);
519 + INIT_LIST_HEAD(&q->queue_head);
520 + INIT_LIST_HEAD(&q->timeout_list);
521 + INIT_LIST_HEAD(&q->icq_list);
522 +diff --git a/block/blk-timeout.c b/block/blk-timeout.c
523 +index a30441a200c0..220661a50f58 100644
524 +--- a/block/blk-timeout.c
525 ++++ b/block/blk-timeout.c
526 +@@ -135,8 +135,6 @@ void blk_timeout_work(struct work_struct *work)
527 + struct request *rq, *tmp;
528 + int next_set = 0;
529 +
530 +- if (blk_queue_enter(q, true))
531 +- return;
532 + spin_lock_irqsave(q->queue_lock, flags);
533 +
534 + list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list)
535 +@@ -146,7 +144,6 @@ void blk_timeout_work(struct work_struct *work)
536 + mod_timer(&q->timeout, round_jiffies_up(next));
537 +
538 + spin_unlock_irqrestore(q->queue_lock, flags);
539 +- blk_queue_exit(q);
540 + }
541 +
542 + /**
543 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
544 +index 51874695a730..c3bcb7f5986e 100644
545 +--- a/drivers/acpi/ec.c
546 ++++ b/drivers/acpi/ec.c
547 +@@ -482,8 +482,11 @@ static inline void __acpi_ec_enable_event(struct acpi_ec *ec)
548 + {
549 + if (!test_and_set_bit(EC_FLAGS_QUERY_ENABLED, &ec->flags))
550 + ec_log_drv("event unblocked");
551 +- if (!test_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
552 +- advance_transaction(ec);
553 ++ /*
554 ++ * Unconditionally invoke this once after enabling the event
555 ++ * handling mechanism to detect the pending events.
556 ++ */
557 ++ advance_transaction(ec);
558 + }
559 +
560 + static inline void __acpi_ec_disable_event(struct acpi_ec *ec)
561 +@@ -1458,11 +1461,10 @@ static int ec_install_handlers(struct acpi_ec *ec, bool handle_events)
562 + if (test_bit(EC_FLAGS_STARTED, &ec->flags) &&
563 + ec->reference_count >= 1)
564 + acpi_ec_enable_gpe(ec, true);
565 +-
566 +- /* EC is fully operational, allow queries */
567 +- acpi_ec_enable_event(ec);
568 + }
569 + }
570 ++ /* EC is fully operational, allow queries */
571 ++ acpi_ec_enable_event(ec);
572 +
573 + return 0;
574 + }
575 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
576 +index 0e1ec37070d1..6475a1343483 100644
577 +--- a/drivers/ata/libata-eh.c
578 ++++ b/drivers/ata/libata-eh.c
579 +@@ -2329,8 +2329,8 @@ static void ata_eh_link_autopsy(struct ata_link *link)
580 + if (dev->flags & ATA_DFLAG_DUBIOUS_XFER)
581 + eflags |= ATA_EFLAG_DUBIOUS_XFER;
582 + ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask);
583 ++ trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
584 + }
585 +- trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
586 + DPRINTK("EXIT\n");
587 + }
588 +
589 +diff --git a/drivers/base/power/opp/of.c b/drivers/base/power/opp/of.c
590 +index b52c617947ad..69379443e5eb 100644
591 +--- a/drivers/base/power/opp/of.c
592 ++++ b/drivers/base/power/opp/of.c
593 +@@ -348,6 +348,7 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
594 + if (ret) {
595 + dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
596 + ret);
597 ++ of_node_put(np);
598 + goto free_table;
599 + }
600 + }
601 +diff --git a/drivers/clk/qcom/gcc-ipq4019.c b/drivers/clk/qcom/gcc-ipq4019.c
602 +index b593065de8db..8ab6ce4d976f 100644
603 +--- a/drivers/clk/qcom/gcc-ipq4019.c
604 ++++ b/drivers/clk/qcom/gcc-ipq4019.c
605 +@@ -525,10 +525,20 @@ static struct clk_rcg2 sdcc1_apps_clk_src = {
606 + };
607 +
608 + static const struct freq_tbl ftbl_gcc_apps_clk[] = {
609 +- F(48000000, P_XO, 1, 0, 0),
610 ++ F(48000000, P_XO, 1, 0, 0),
611 + F(200000000, P_FEPLL200, 1, 0, 0),
612 ++ F(384000000, P_DDRPLLAPSS, 1, 0, 0),
613 ++ F(413000000, P_DDRPLLAPSS, 1, 0, 0),
614 ++ F(448000000, P_DDRPLLAPSS, 1, 0, 0),
615 ++ F(488000000, P_DDRPLLAPSS, 1, 0, 0),
616 + F(500000000, P_FEPLL500, 1, 0, 0),
617 +- F(626000000, P_DDRPLLAPSS, 1, 0, 0),
618 ++ F(512000000, P_DDRPLLAPSS, 1, 0, 0),
619 ++ F(537000000, P_DDRPLLAPSS, 1, 0, 0),
620 ++ F(565000000, P_DDRPLLAPSS, 1, 0, 0),
621 ++ F(597000000, P_DDRPLLAPSS, 1, 0, 0),
622 ++ F(632000000, P_DDRPLLAPSS, 1, 0, 0),
623 ++ F(672000000, P_DDRPLLAPSS, 1, 0, 0),
624 ++ F(716000000, P_DDRPLLAPSS, 1, 0, 0),
625 + { }
626 + };
627 +
628 +diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
629 +index 0cca3601d99e..df97e25aec76 100644
630 +--- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
631 ++++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
632 +@@ -468,8 +468,8 @@ static SUNXI_CCU_MUX_WITH_GATE(daudio0_clk, "daudio0", daudio_parents,
633 + static SUNXI_CCU_MUX_WITH_GATE(daudio1_clk, "daudio1", daudio_parents,
634 + 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
635 +
636 +-static SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
637 +- 0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
638 ++static SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", daudio_parents,
639 ++ 0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
640 +
641 + static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M",
642 + 0x0cc, BIT(8), 0);
643 +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
644 +index 9bd1f78a0547..e1dc4e5b34e1 100644
645 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
646 ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
647 +@@ -752,6 +752,13 @@ static const struct sunxi_ccu_desc sun8i_a33_ccu_desc = {
648 + .num_resets = ARRAY_SIZE(sun8i_a33_ccu_resets),
649 + };
650 +
651 ++static struct ccu_mux_nb sun8i_a33_cpu_nb = {
652 ++ .common = &cpux_clk.common,
653 ++ .cm = &cpux_clk.mux,
654 ++ .delay_us = 1, /* > 8 clock cycles at 24 MHz */
655 ++ .bypass_index = 1, /* index of 24 MHz oscillator */
656 ++};
657 ++
658 + static void __init sun8i_a33_ccu_setup(struct device_node *node)
659 + {
660 + void __iomem *reg;
661 +@@ -775,6 +782,9 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node)
662 + writel(val, reg + SUN8I_A33_PLL_MIPI_REG);
663 +
664 + sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc);
665 ++
666 ++ ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
667 ++ &sun8i_a33_cpu_nb);
668 + }
669 + CLK_OF_DECLARE(sun8i_a33_ccu, "allwinner,sun8i-a33-ccu",
670 + sun8i_a33_ccu_setup);
671 +diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c
672 +index c77333230bdf..7d060ffe8975 100644
673 +--- a/drivers/clk/ti/clk-dra7-atl.c
674 ++++ b/drivers/clk/ti/clk-dra7-atl.c
675 +@@ -265,8 +265,7 @@ static int of_dra7_atl_clk_probe(struct platform_device *pdev)
676 +
677 + /* Get configuration for the ATL instances */
678 + snprintf(prop, sizeof(prop), "atl%u", i);
679 +- of_node_get(node);
680 +- cfg_node = of_find_node_by_name(node, prop);
681 ++ cfg_node = of_get_child_by_name(node, prop);
682 + if (cfg_node) {
683 + ret = of_property_read_u32(cfg_node, "bws",
684 + &cdesc->bws);
685 +diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h
686 +index e423d33decd4..36291840a12c 100644
687 +--- a/drivers/crypto/marvell/cesa.h
688 ++++ b/drivers/crypto/marvell/cesa.h
689 +@@ -273,7 +273,8 @@ struct mv_cesa_op_ctx {
690 + #define CESA_TDMA_SRC_IN_SRAM BIT(30)
691 + #define CESA_TDMA_END_OF_REQ BIT(29)
692 + #define CESA_TDMA_BREAK_CHAIN BIT(28)
693 +-#define CESA_TDMA_TYPE_MSK GENMASK(27, 0)
694 ++#define CESA_TDMA_SET_STATE BIT(27)
695 ++#define CESA_TDMA_TYPE_MSK GENMASK(26, 0)
696 + #define CESA_TDMA_DUMMY 0
697 + #define CESA_TDMA_DATA 1
698 + #define CESA_TDMA_OP 2
699 +diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
700 +index 77712b375b84..662cf4ddb04b 100644
701 +--- a/drivers/crypto/marvell/hash.c
702 ++++ b/drivers/crypto/marvell/hash.c
703 +@@ -280,13 +280,32 @@ static void mv_cesa_ahash_std_prepare(struct ahash_request *req)
704 + sreq->offset = 0;
705 + }
706 +
707 ++static void mv_cesa_ahash_dma_step(struct ahash_request *req)
708 ++{
709 ++ struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
710 ++ struct mv_cesa_req *base = &creq->base;
711 ++
712 ++ /* We must explicitly set the digest state. */
713 ++ if (base->chain.first->flags & CESA_TDMA_SET_STATE) {
714 ++ struct mv_cesa_engine *engine = base->engine;
715 ++ int i;
716 ++
717 ++ /* Set the hash state in the IVDIG regs. */
718 ++ for (i = 0; i < ARRAY_SIZE(creq->state); i++)
719 ++ writel_relaxed(creq->state[i], engine->regs +
720 ++ CESA_IVDIG(i));
721 ++ }
722 ++
723 ++ mv_cesa_dma_step(base);
724 ++}
725 ++
726 + static void mv_cesa_ahash_step(struct crypto_async_request *req)
727 + {
728 + struct ahash_request *ahashreq = ahash_request_cast(req);
729 + struct mv_cesa_ahash_req *creq = ahash_request_ctx(ahashreq);
730 +
731 + if (mv_cesa_req_get_type(&creq->base) == CESA_DMA_REQ)
732 +- mv_cesa_dma_step(&creq->base);
733 ++ mv_cesa_ahash_dma_step(ahashreq);
734 + else
735 + mv_cesa_ahash_std_step(ahashreq);
736 + }
737 +@@ -562,11 +581,15 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
738 + struct mv_cesa_ahash_dma_iter iter;
739 + struct mv_cesa_op_ctx *op = NULL;
740 + unsigned int frag_len;
741 ++ bool set_state = false;
742 + int ret;
743 +
744 + basereq->chain.first = NULL;
745 + basereq->chain.last = NULL;
746 +
747 ++ if (!mv_cesa_mac_op_is_first_frag(&creq->op_tmpl))
748 ++ set_state = true;
749 ++
750 + if (creq->src_nents) {
751 + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
752 + DMA_TO_DEVICE);
753 +@@ -650,6 +673,15 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
754 + basereq->chain.last->flags |= (CESA_TDMA_END_OF_REQ |
755 + CESA_TDMA_BREAK_CHAIN);
756 +
757 ++ if (set_state) {
758 ++ /*
759 ++ * Put the CESA_TDMA_SET_STATE flag on the first tdma desc to
760 ++ * let the step logic know that the IVDIG registers should be
761 ++ * explicitly set before launching a TDMA chain.
762 ++ */
763 ++ basereq->chain.first->flags |= CESA_TDMA_SET_STATE;
764 ++ }
765 ++
766 + return 0;
767 +
768 + err_free_tdma:
769 +diff --git a/drivers/crypto/marvell/tdma.c b/drivers/crypto/marvell/tdma.c
770 +index 9fd7a5fbaa1b..0cda6e3f2b4b 100644
771 +--- a/drivers/crypto/marvell/tdma.c
772 ++++ b/drivers/crypto/marvell/tdma.c
773 +@@ -112,7 +112,14 @@ void mv_cesa_tdma_chain(struct mv_cesa_engine *engine,
774 + last->next = dreq->chain.first;
775 + engine->chain.last = dreq->chain.last;
776 +
777 +- if (!(last->flags & CESA_TDMA_BREAK_CHAIN))
778 ++ /*
779 ++ * Break the DMA chain if the CESA_TDMA_BREAK_CHAIN is set on
780 ++ * the last element of the current chain, or if the request
781 ++ * being queued needs the IV regs to be set before lauching
782 ++ * the request.
783 ++ */
784 ++ if (!(last->flags & CESA_TDMA_BREAK_CHAIN) &&
785 ++ !(dreq->chain.first->flags & CESA_TDMA_SET_STATE))
786 + last->next_dma = dreq->chain.first->cur_dma;
787 + }
788 + }
789 +diff --git a/drivers/dma/zx296702_dma.c b/drivers/dma/zx296702_dma.c
790 +index 245d759d5ffc..6059d81e701a 100644
791 +--- a/drivers/dma/zx296702_dma.c
792 ++++ b/drivers/dma/zx296702_dma.c
793 +@@ -813,6 +813,7 @@ static int zx_dma_probe(struct platform_device *op)
794 + INIT_LIST_HEAD(&d->slave.channels);
795 + dma_cap_set(DMA_SLAVE, d->slave.cap_mask);
796 + dma_cap_set(DMA_MEMCPY, d->slave.cap_mask);
797 ++ dma_cap_set(DMA_CYCLIC, d->slave.cap_mask);
798 + dma_cap_set(DMA_PRIVATE, d->slave.cap_mask);
799 + d->slave.dev = &op->dev;
800 + d->slave.device_free_chan_resources = zx_dma_free_chan_resources;
801 +diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
802 +index 1ef85b0c2b1f..d27e9361e236 100644
803 +--- a/drivers/gpio/gpio-mockup.c
804 ++++ b/drivers/gpio/gpio-mockup.c
805 +@@ -126,7 +126,7 @@ static int mockup_gpio_probe(struct platform_device *pdev)
806 + int i;
807 + int base;
808 + int ngpio;
809 +- char chip_name[sizeof(GPIO_NAME) + 3];
810 ++ char *chip_name;
811 +
812 + if (gpio_mockup_params_nr < 2)
813 + return -EINVAL;
814 +@@ -146,8 +146,12 @@ static int mockup_gpio_probe(struct platform_device *pdev)
815 + ngpio = gpio_mockup_ranges[i * 2 + 1] - base;
816 +
817 + if (ngpio >= 0) {
818 +- sprintf(chip_name, "%s-%c", GPIO_NAME,
819 +- pins_name_start + i);
820 ++ chip_name = devm_kasprintf(dev, GFP_KERNEL,
821 ++ "%s-%c", GPIO_NAME,
822 ++ pins_name_start + i);
823 ++ if (!chip_name)
824 ++ return -ENOMEM;
825 ++
826 + ret = mockup_gpio_add(dev, &cntr[i],
827 + chip_name, base, ngpio);
828 + } else {
829 +diff --git a/drivers/gpu/drm/armada/Makefile b/drivers/gpu/drm/armada/Makefile
830 +index ffd673615772..26412d2f8c98 100644
831 +--- a/drivers/gpu/drm/armada/Makefile
832 ++++ b/drivers/gpu/drm/armada/Makefile
833 +@@ -4,3 +4,5 @@ armada-y += armada_510.o
834 + armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o
835 +
836 + obj-$(CONFIG_DRM_ARMADA) := armada.o
837 ++
838 ++CFLAGS_armada_trace.o := -I$(src)
839 +diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
840 +index ee07bb4a57b7..11f54df0c19b 100644
841 +--- a/drivers/gpu/drm/drm_mm.c
842 ++++ b/drivers/gpu/drm/drm_mm.c
843 +@@ -348,14 +348,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
844 +
845 + BUG_ON(!hole_node->hole_follows || node->allocated);
846 +
847 +- if (adj_start < start)
848 +- adj_start = start;
849 +- if (adj_end > end)
850 +- adj_end = end;
851 +-
852 + if (mm->color_adjust)
853 + mm->color_adjust(hole_node, color, &adj_start, &adj_end);
854 +
855 ++ adj_start = max(adj_start, start);
856 ++ adj_end = min(adj_end, end);
857 ++
858 + if (flags & DRM_MM_CREATE_TOP)
859 + adj_start = adj_end - size;
860 +
861 +@@ -566,17 +564,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
862 + flags & DRM_MM_SEARCH_BELOW) {
863 + u64 hole_size = adj_end - adj_start;
864 +
865 +- if (adj_start < start)
866 +- adj_start = start;
867 +- if (adj_end > end)
868 +- adj_end = end;
869 +-
870 + if (mm->color_adjust) {
871 + mm->color_adjust(entry, color, &adj_start, &adj_end);
872 + if (adj_end <= adj_start)
873 + continue;
874 + }
875 +
876 ++ adj_start = max(adj_start, start);
877 ++ adj_end = min(adj_end, end);
878 ++
879 + if (!check_free_hole(adj_start, adj_end, size, alignment))
880 + continue;
881 +
882 +diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
883 +index 3ce9ba30d827..a19ec06f9e42 100644
884 +--- a/drivers/gpu/drm/i915/intel_drv.h
885 ++++ b/drivers/gpu/drm/i915/intel_drv.h
886 +@@ -457,6 +457,7 @@ struct intel_crtc_scaler_state {
887 +
888 + struct intel_pipe_wm {
889 + struct intel_wm_level wm[5];
890 ++ struct intel_wm_level raw_wm[5];
891 + uint32_t linetime;
892 + bool fbc_wm_enabled;
893 + bool pipe_enabled;
894 +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
895 +index 277a8026460b..49de4760cc16 100644
896 +--- a/drivers/gpu/drm/i915/intel_pm.c
897 ++++ b/drivers/gpu/drm/i915/intel_pm.c
898 +@@ -27,7 +27,6 @@
899 +
900 + #include <linux/cpufreq.h>
901 + #include <drm/drm_plane_helper.h>
902 +-#include <drm/drm_atomic_helper.h>
903 + #include "i915_drv.h"
904 + #include "intel_drv.h"
905 + #include "../../../platform/x86/intel_ips.h"
906 +@@ -2018,9 +2017,9 @@ static void ilk_compute_wm_level(const struct drm_i915_private *dev_priv,
907 + const struct intel_crtc *intel_crtc,
908 + int level,
909 + struct intel_crtc_state *cstate,
910 +- const struct intel_plane_state *pristate,
911 +- const struct intel_plane_state *sprstate,
912 +- const struct intel_plane_state *curstate,
913 ++ struct intel_plane_state *pristate,
914 ++ struct intel_plane_state *sprstate,
915 ++ struct intel_plane_state *curstate,
916 + struct intel_wm_level *result)
917 + {
918 + uint16_t pri_latency = dev_priv->wm.pri_latency[level];
919 +@@ -2342,24 +2341,28 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
920 + struct intel_pipe_wm *pipe_wm;
921 + struct drm_device *dev = state->dev;
922 + const struct drm_i915_private *dev_priv = to_i915(dev);
923 +- struct drm_plane *plane;
924 +- const struct drm_plane_state *plane_state;
925 +- const struct intel_plane_state *pristate = NULL;
926 +- const struct intel_plane_state *sprstate = NULL;
927 +- const struct intel_plane_state *curstate = NULL;
928 ++ struct intel_plane *intel_plane;
929 ++ struct intel_plane_state *pristate = NULL;
930 ++ struct intel_plane_state *sprstate = NULL;
931 ++ struct intel_plane_state *curstate = NULL;
932 + int level, max_level = ilk_wm_max_level(dev), usable_level;
933 + struct ilk_wm_maximums max;
934 +
935 + pipe_wm = &cstate->wm.ilk.optimal;
936 +
937 +- drm_atomic_crtc_state_for_each_plane_state(plane, plane_state, &cstate->base) {
938 +- const struct intel_plane_state *ps = to_intel_plane_state(plane_state);
939 ++ for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
940 ++ struct intel_plane_state *ps;
941 +
942 +- if (plane->type == DRM_PLANE_TYPE_PRIMARY)
943 ++ ps = intel_atomic_get_existing_plane_state(state,
944 ++ intel_plane);
945 ++ if (!ps)
946 ++ continue;
947 ++
948 ++ if (intel_plane->base.type == DRM_PLANE_TYPE_PRIMARY)
949 + pristate = ps;
950 +- else if (plane->type == DRM_PLANE_TYPE_OVERLAY)
951 ++ else if (intel_plane->base.type == DRM_PLANE_TYPE_OVERLAY)
952 + sprstate = ps;
953 +- else if (plane->type == DRM_PLANE_TYPE_CURSOR)
954 ++ else if (intel_plane->base.type == DRM_PLANE_TYPE_CURSOR)
955 + curstate = ps;
956 + }
957 +
958 +@@ -2381,9 +2384,11 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
959 + if (pipe_wm->sprites_scaled)
960 + usable_level = 0;
961 +
962 +- memset(&pipe_wm->wm, 0, sizeof(pipe_wm->wm));
963 + ilk_compute_wm_level(dev_priv, intel_crtc, 0, cstate,
964 +- pristate, sprstate, curstate, &pipe_wm->wm[0]);
965 ++ pristate, sprstate, curstate, &pipe_wm->raw_wm[0]);
966 ++
967 ++ memset(&pipe_wm->wm, 0, sizeof(pipe_wm->wm));
968 ++ pipe_wm->wm[0] = pipe_wm->raw_wm[0];
969 +
970 + if (IS_HASWELL(dev) || IS_BROADWELL(dev))
971 + pipe_wm->linetime = hsw_compute_linetime_wm(cstate);
972 +@@ -2393,8 +2398,8 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
973 +
974 + ilk_compute_wm_reg_maximums(dev, 1, &max);
975 +
976 +- for (level = 1; level <= usable_level; level++) {
977 +- struct intel_wm_level *wm = &pipe_wm->wm[level];
978 ++ for (level = 1; level <= max_level; level++) {
979 ++ struct intel_wm_level *wm = &pipe_wm->raw_wm[level];
980 +
981 + ilk_compute_wm_level(dev_priv, intel_crtc, level, cstate,
982 + pristate, sprstate, curstate, wm);
983 +@@ -2404,10 +2409,13 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
984 + * register maximums since such watermarks are
985 + * always invalid.
986 + */
987 +- if (!ilk_validate_wm_level(level, &max, wm)) {
988 +- memset(wm, 0, sizeof(*wm));
989 +- break;
990 +- }
991 ++ if (level > usable_level)
992 ++ continue;
993 ++
994 ++ if (ilk_validate_wm_level(level, &max, wm))
995 ++ pipe_wm->wm[level] = *wm;
996 ++ else
997 ++ usable_level = level;
998 + }
999 +
1000 + return 0;
1001 +diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
1002 +index cf83f6507ec8..48dfc163233e 100644
1003 +--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
1004 ++++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
1005 +@@ -321,7 +321,8 @@ static void mtk_drm_unbind(struct device *dev)
1006 + {
1007 + struct mtk_drm_private *private = dev_get_drvdata(dev);
1008 +
1009 +- drm_put_dev(private->drm);
1010 ++ drm_dev_unregister(private->drm);
1011 ++ drm_dev_unref(private->drm);
1012 + private->drm = NULL;
1013 + }
1014 +
1015 +diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
1016 +index 6e6c59a661b6..223944a3ba18 100644
1017 +--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
1018 ++++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
1019 +@@ -172,7 +172,7 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
1020 + ret = sun4i_backend_drm_format_to_layer(plane, fb->pixel_format, &val);
1021 + if (ret) {
1022 + DRM_DEBUG_DRIVER("Invalid format\n");
1023 +- return val;
1024 ++ return ret;
1025 + }
1026 +
1027 + regmap_update_bits(backend->regs, SUN4I_BACKEND_ATTCTL_REG1(layer),
1028 +diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
1029 +index fe89b6823217..263e97235ea0 100644
1030 +--- a/drivers/iio/light/cm3232.c
1031 ++++ b/drivers/iio/light/cm3232.c
1032 +@@ -119,7 +119,7 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
1033 + if (ret < 0)
1034 + dev_err(&chip->client->dev, "Error writing reg_cmd\n");
1035 +
1036 +- return 0;
1037 ++ return ret;
1038 + }
1039 +
1040 + /**
1041 +diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
1042 +index 1eee8f7e75ca..84f91858b5e6 100644
1043 +--- a/drivers/infiniband/ulp/srp/ib_srp.c
1044 ++++ b/drivers/infiniband/ulp/srp/ib_srp.c
1045 +@@ -648,12 +648,19 @@ static void srp_path_rec_completion(int status,
1046 + static int srp_lookup_path(struct srp_rdma_ch *ch)
1047 + {
1048 + struct srp_target_port *target = ch->target;
1049 +- int ret;
1050 ++ int ret = -ENODEV;
1051 +
1052 + ch->path.numb_path = 1;
1053 +
1054 + init_completion(&ch->done);
1055 +
1056 ++ /*
1057 ++ * Avoid that the SCSI host can be removed by srp_remove_target()
1058 ++ * before srp_path_rec_completion() is called.
1059 ++ */
1060 ++ if (!scsi_host_get(target->scsi_host))
1061 ++ goto out;
1062 ++
1063 + ch->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
1064 + target->srp_host->srp_dev->dev,
1065 + target->srp_host->port,
1066 +@@ -667,18 +674,24 @@ static int srp_lookup_path(struct srp_rdma_ch *ch)
1067 + GFP_KERNEL,
1068 + srp_path_rec_completion,
1069 + ch, &ch->path_query);
1070 +- if (ch->path_query_id < 0)
1071 +- return ch->path_query_id;
1072 ++ ret = ch->path_query_id;
1073 ++ if (ret < 0)
1074 ++ goto put;
1075 +
1076 + ret = wait_for_completion_interruptible(&ch->done);
1077 + if (ret < 0)
1078 +- return ret;
1079 ++ goto put;
1080 +
1081 +- if (ch->status < 0)
1082 ++ ret = ch->status;
1083 ++ if (ret < 0)
1084 + shost_printk(KERN_WARNING, target->scsi_host,
1085 + PFX "Path record query failed\n");
1086 +
1087 +- return ch->status;
1088 ++put:
1089 ++ scsi_host_put(target->scsi_host);
1090 ++
1091 ++out:
1092 ++ return ret;
1093 + }
1094 +
1095 + static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
1096 +diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
1097 +index 0b1f69ed2e92..b9748970df4a 100644
1098 +--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
1099 ++++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
1100 +@@ -2750,7 +2750,7 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
1101 + {
1102 + const char *p;
1103 + unsigned len, count, leading_zero_bytes;
1104 +- int ret, rc;
1105 ++ int ret;
1106 +
1107 + p = name;
1108 + if (strncasecmp(p, "0x", 2) == 0)
1109 +@@ -2762,10 +2762,9 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
1110 + count = min(len / 2, 16U);
1111 + leading_zero_bytes = 16 - count;
1112 + memset(i_port_id, 0, leading_zero_bytes);
1113 +- rc = hex2bin(i_port_id + leading_zero_bytes, p, count);
1114 +- if (rc < 0)
1115 +- pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc);
1116 +- ret = 0;
1117 ++ ret = hex2bin(i_port_id + leading_zero_bytes, p, count);
1118 ++ if (ret < 0)
1119 ++ pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret);
1120 + out:
1121 + return ret;
1122 + }
1123 +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
1124 +index 24d388d74011..a37576a1798d 100644
1125 +--- a/drivers/irqchip/irq-gic-v3.c
1126 ++++ b/drivers/irqchip/irq-gic-v3.c
1127 +@@ -1022,18 +1022,18 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
1128 + int nr_parts;
1129 + struct partition_affinity *parts;
1130 +
1131 +- parts_node = of_find_node_by_name(gic_node, "ppi-partitions");
1132 ++ parts_node = of_get_child_by_name(gic_node, "ppi-partitions");
1133 + if (!parts_node)
1134 + return;
1135 +
1136 + nr_parts = of_get_child_count(parts_node);
1137 +
1138 + if (!nr_parts)
1139 +- return;
1140 ++ goto out_put_node;
1141 +
1142 + parts = kzalloc(sizeof(*parts) * nr_parts, GFP_KERNEL);
1143 + if (WARN_ON(!parts))
1144 +- return;
1145 ++ goto out_put_node;
1146 +
1147 + for_each_child_of_node(parts_node, child_part) {
1148 + struct partition_affinity *part;
1149 +@@ -1100,6 +1100,9 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
1150 +
1151 + gic_data.ppi_descs[i] = desc;
1152 + }
1153 ++
1154 ++out_put_node:
1155 ++ of_node_put(parts_node);
1156 + }
1157 +
1158 + static void __init gic_of_setup_kvm_info(struct device_node *node)
1159 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
1160 +index ca4abe1ccd8d..3fba31cea66e 100644
1161 +--- a/drivers/md/bcache/alloc.c
1162 ++++ b/drivers/md/bcache/alloc.c
1163 +@@ -404,7 +404,8 @@ long bch_bucket_alloc(struct cache *ca, unsigned reserve, bool wait)
1164 +
1165 + finish_wait(&ca->set->bucket_wait, &w);
1166 + out:
1167 +- wake_up_process(ca->alloc_thread);
1168 ++ if (ca->alloc_thread)
1169 ++ wake_up_process(ca->alloc_thread);
1170 +
1171 + trace_bcache_alloc(ca, reserve);
1172 +
1173 +diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
1174 +index 8bf9667ff46b..7643f72adb1c 100644
1175 +--- a/drivers/md/dm-bufio.c
1176 ++++ b/drivers/md/dm-bufio.c
1177 +@@ -937,7 +937,8 @@ static void __get_memory_limit(struct dm_bufio_client *c,
1178 + buffers = c->minimum_buffers;
1179 +
1180 + *limit_buffers = buffers;
1181 +- *threshold_buffers = buffers * DM_BUFIO_WRITEBACK_PERCENT / 100;
1182 ++ *threshold_buffers = mult_frac(buffers,
1183 ++ DM_BUFIO_WRITEBACK_PERCENT, 100);
1184 + }
1185 +
1186 + /*
1187 +@@ -1856,19 +1857,15 @@ static int __init dm_bufio_init(void)
1188 + memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
1189 + memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
1190 +
1191 +- mem = (__u64)((totalram_pages - totalhigh_pages) *
1192 +- DM_BUFIO_MEMORY_PERCENT / 100) << PAGE_SHIFT;
1193 ++ mem = (__u64)mult_frac(totalram_pages - totalhigh_pages,
1194 ++ DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT;
1195 +
1196 + if (mem > ULONG_MAX)
1197 + mem = ULONG_MAX;
1198 +
1199 + #ifdef CONFIG_MMU
1200 +- /*
1201 +- * Get the size of vmalloc space the same way as VMALLOC_TOTAL
1202 +- * in fs/proc/internal.h
1203 +- */
1204 +- if (mem > (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100)
1205 +- mem = (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100;
1206 ++ if (mem > mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100))
1207 ++ mem = mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100);
1208 + #endif
1209 +
1210 + dm_bufio_default_cache_size = mem;
1211 +diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
1212 +index 40ceba1fe8be..1609d4971104 100644
1213 +--- a/drivers/md/dm-core.h
1214 ++++ b/drivers/md/dm-core.h
1215 +@@ -29,7 +29,6 @@ struct dm_kobject_holder {
1216 + * DM targets must _not_ deference a mapped_device to directly access its members!
1217 + */
1218 + struct mapped_device {
1219 +- struct srcu_struct io_barrier;
1220 + struct mutex suspend_lock;
1221 +
1222 + /*
1223 +@@ -127,6 +126,8 @@ struct mapped_device {
1224 + struct blk_mq_tag_set *tag_set;
1225 + bool use_blk_mq:1;
1226 + bool init_tio_pdu:1;
1227 ++
1228 ++ struct srcu_struct io_barrier;
1229 + };
1230 +
1231 + void dm_init_md_queue(struct mapped_device *md);
1232 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
1233 +index e66f4040d84b..c5522551122f 100644
1234 +--- a/drivers/md/dm.c
1235 ++++ b/drivers/md/dm.c
1236 +@@ -21,6 +21,7 @@
1237 + #include <linux/delay.h>
1238 + #include <linux/wait.h>
1239 + #include <linux/pr.h>
1240 ++#include <linux/vmalloc.h>
1241 +
1242 + #define DM_MSG_PREFIX "core"
1243 +
1244 +@@ -1511,7 +1512,7 @@ static struct mapped_device *alloc_dev(int minor)
1245 + struct mapped_device *md;
1246 + void *old_md;
1247 +
1248 +- md = kzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id);
1249 ++ md = vzalloc_node(sizeof(*md), numa_node_id);
1250 + if (!md) {
1251 + DMWARN("unable to allocate device, out of memory.");
1252 + return NULL;
1253 +@@ -1605,7 +1606,7 @@ static struct mapped_device *alloc_dev(int minor)
1254 + bad_minor:
1255 + module_put(THIS_MODULE);
1256 + bad_module_get:
1257 +- kfree(md);
1258 ++ kvfree(md);
1259 + return NULL;
1260 + }
1261 +
1262 +@@ -1624,7 +1625,7 @@ static void free_dev(struct mapped_device *md)
1263 + free_minor(minor);
1264 +
1265 + module_put(THIS_MODULE);
1266 +- kfree(md);
1267 ++ kvfree(md);
1268 + }
1269 +
1270 + static void __bind_mempools(struct mapped_device *md, struct dm_table *t)
1271 +@@ -2514,11 +2515,15 @@ struct mapped_device *dm_get_from_kobject(struct kobject *kobj)
1272 +
1273 + md = container_of(kobj, struct mapped_device, kobj_holder.kobj);
1274 +
1275 +- if (test_bit(DMF_FREEING, &md->flags) ||
1276 +- dm_deleting_md(md))
1277 +- return NULL;
1278 +-
1279 ++ spin_lock(&_minor_lock);
1280 ++ if (test_bit(DMF_FREEING, &md->flags) || dm_deleting_md(md)) {
1281 ++ md = NULL;
1282 ++ goto out;
1283 ++ }
1284 + dm_get(md);
1285 ++out:
1286 ++ spin_unlock(&_minor_lock);
1287 ++
1288 + return md;
1289 + }
1290 +
1291 +diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
1292 +index b49f80cb49c9..d9a5710532f4 100644
1293 +--- a/drivers/media/rc/ir-lirc-codec.c
1294 ++++ b/drivers/media/rc/ir-lirc-codec.c
1295 +@@ -286,11 +286,14 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
1296 + if (!dev->max_timeout)
1297 + return -ENOSYS;
1298 +
1299 ++ /* Check for multiply overflow */
1300 ++ if (val > U32_MAX / 1000)
1301 ++ return -EINVAL;
1302 ++
1303 + tmp = val * 1000;
1304 +
1305 +- if (tmp < dev->min_timeout ||
1306 +- tmp > dev->max_timeout)
1307 +- return -EINVAL;
1308 ++ if (tmp < dev->min_timeout || tmp > dev->max_timeout)
1309 ++ return -EINVAL;
1310 +
1311 + if (dev->s_timeout)
1312 + ret = dev->s_timeout(dev, tmp);
1313 +diff --git a/drivers/media/usb/as102/as102_fw.c b/drivers/media/usb/as102/as102_fw.c
1314 +index 5a28ce3a1d49..38dbc128340d 100644
1315 +--- a/drivers/media/usb/as102/as102_fw.c
1316 ++++ b/drivers/media/usb/as102/as102_fw.c
1317 +@@ -101,18 +101,23 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
1318 + unsigned char *cmd,
1319 + const struct firmware *firmware) {
1320 +
1321 +- struct as10x_fw_pkt_t fw_pkt;
1322 ++ struct as10x_fw_pkt_t *fw_pkt;
1323 + int total_read_bytes = 0, errno = 0;
1324 + unsigned char addr_has_changed = 0;
1325 +
1326 ++ fw_pkt = kmalloc(sizeof(*fw_pkt), GFP_KERNEL);
1327 ++ if (!fw_pkt)
1328 ++ return -ENOMEM;
1329 ++
1330 ++
1331 + for (total_read_bytes = 0; total_read_bytes < firmware->size; ) {
1332 + int read_bytes = 0, data_len = 0;
1333 +
1334 + /* parse intel hex line */
1335 + read_bytes = parse_hex_line(
1336 + (u8 *) (firmware->data + total_read_bytes),
1337 +- fw_pkt.raw.address,
1338 +- fw_pkt.raw.data,
1339 ++ fw_pkt->raw.address,
1340 ++ fw_pkt->raw.data,
1341 + &data_len,
1342 + &addr_has_changed);
1343 +
1344 +@@ -122,28 +127,28 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
1345 + /* detect the end of file */
1346 + total_read_bytes += read_bytes;
1347 + if (total_read_bytes == firmware->size) {
1348 +- fw_pkt.u.request[0] = 0x00;
1349 +- fw_pkt.u.request[1] = 0x03;
1350 ++ fw_pkt->u.request[0] = 0x00;
1351 ++ fw_pkt->u.request[1] = 0x03;
1352 +
1353 + /* send EOF command */
1354 + errno = bus_adap->ops->upload_fw_pkt(bus_adap,
1355 + (uint8_t *)
1356 +- &fw_pkt, 2, 0);
1357 ++ fw_pkt, 2, 0);
1358 + if (errno < 0)
1359 + goto error;
1360 + } else {
1361 + if (!addr_has_changed) {
1362 + /* prepare command to send */
1363 +- fw_pkt.u.request[0] = 0x00;
1364 +- fw_pkt.u.request[1] = 0x01;
1365 ++ fw_pkt->u.request[0] = 0x00;
1366 ++ fw_pkt->u.request[1] = 0x01;
1367 +
1368 +- data_len += sizeof(fw_pkt.u.request);
1369 +- data_len += sizeof(fw_pkt.raw.address);
1370 ++ data_len += sizeof(fw_pkt->u.request);
1371 ++ data_len += sizeof(fw_pkt->raw.address);
1372 +
1373 + /* send cmd to device */
1374 + errno = bus_adap->ops->upload_fw_pkt(bus_adap,
1375 + (uint8_t *)
1376 +- &fw_pkt,
1377 ++ fw_pkt,
1378 + data_len,
1379 + 0);
1380 + if (errno < 0)
1381 +@@ -152,6 +157,7 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
1382 + }
1383 + }
1384 + error:
1385 ++ kfree(fw_pkt);
1386 + return (errno == 0) ? total_read_bytes : errno;
1387 + }
1388 +
1389 +diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
1390 +index be9e3335dcb7..921cf1edb3b1 100644
1391 +--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
1392 ++++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
1393 +@@ -1622,7 +1622,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1394 + nr = dev->devno;
1395 +
1396 + assoc_desc = udev->actconfig->intf_assoc[0];
1397 +- if (assoc_desc->bFirstInterface != ifnum) {
1398 ++ if (!assoc_desc || assoc_desc->bFirstInterface != ifnum) {
1399 + dev_err(d, "Not found matching IAD interface\n");
1400 + retval = -ENODEV;
1401 + goto err_if;
1402 +diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
1403 +index adc2147fcff7..bd6884223a0d 100644
1404 +--- a/drivers/media/v4l2-core/v4l2-ctrls.c
1405 ++++ b/drivers/media/v4l2-core/v4l2-ctrls.c
1406 +@@ -1219,6 +1219,16 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1407 + }
1408 + EXPORT_SYMBOL(v4l2_ctrl_fill);
1409 +
1410 ++static u32 user_flags(const struct v4l2_ctrl *ctrl)
1411 ++{
1412 ++ u32 flags = ctrl->flags;
1413 ++
1414 ++ if (ctrl->is_ptr)
1415 ++ flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
1416 ++
1417 ++ return flags;
1418 ++}
1419 ++
1420 + static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
1421 + {
1422 + memset(ev->reserved, 0, sizeof(ev->reserved));
1423 +@@ -1226,7 +1236,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 change
1424 + ev->id = ctrl->id;
1425 + ev->u.ctrl.changes = changes;
1426 + ev->u.ctrl.type = ctrl->type;
1427 +- ev->u.ctrl.flags = ctrl->flags;
1428 ++ ev->u.ctrl.flags = user_flags(ctrl);
1429 + if (ctrl->is_ptr)
1430 + ev->u.ctrl.value64 = 0;
1431 + else
1432 +@@ -2550,10 +2560,8 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr
1433 + else
1434 + qc->id = ctrl->id;
1435 + strlcpy(qc->name, ctrl->name, sizeof(qc->name));
1436 +- qc->flags = ctrl->flags;
1437 ++ qc->flags = user_flags(ctrl);
1438 + qc->type = ctrl->type;
1439 +- if (ctrl->is_ptr)
1440 +- qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
1441 + qc->elem_size = ctrl->elem_size;
1442 + qc->elems = ctrl->elems;
1443 + qc->nr_of_dims = ctrl->nr_of_dims;
1444 +diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
1445 +index dbf256217b3e..ada2d88fd4c7 100644
1446 +--- a/drivers/mtd/nand/mtk_ecc.c
1447 ++++ b/drivers/mtd/nand/mtk_ecc.c
1448 +@@ -116,6 +116,11 @@ static irqreturn_t mtk_ecc_irq(int irq, void *id)
1449 + op = ECC_DECODE;
1450 + dec = readw(ecc->regs + ECC_DECDONE);
1451 + if (dec & ecc->sectors) {
1452 ++ /*
1453 ++ * Clear decode IRQ status once again to ensure that
1454 ++ * there will be no extra IRQ.
1455 ++ */
1456 ++ readw(ecc->regs + ECC_DECIRQ_STA);
1457 + ecc->sectors = 0;
1458 + complete(&ecc->done);
1459 + } else {
1460 +@@ -131,8 +136,6 @@ static irqreturn_t mtk_ecc_irq(int irq, void *id)
1461 + }
1462 + }
1463 +
1464 +- writel(0, ecc->regs + ECC_IRQ_REG(op));
1465 +-
1466 + return IRQ_HANDLED;
1467 + }
1468 +
1469 +@@ -342,6 +345,12 @@ void mtk_ecc_disable(struct mtk_ecc *ecc)
1470 +
1471 + /* disable it */
1472 + mtk_ecc_wait_idle(ecc, op);
1473 ++ if (op == ECC_DECODE)
1474 ++ /*
1475 ++ * Clear decode IRQ status in case there is a timeout to wait
1476 ++ * decode IRQ.
1477 ++ */
1478 ++ readw(ecc->regs + ECC_DECIRQ_STA);
1479 + writew(0, ecc->regs + ECC_IRQ_REG(op));
1480 + writew(ECC_OP_DISABLE, ecc->regs + ECC_CTL_REG(op));
1481 +
1482 +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
1483 +index 31a6ee307d80..a77cfd74a92e 100644
1484 +--- a/drivers/mtd/nand/nand_base.c
1485 ++++ b/drivers/mtd/nand/nand_base.c
1486 +@@ -2935,15 +2935,18 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
1487 + size_t *retlen, const uint8_t *buf)
1488 + {
1489 + struct nand_chip *chip = mtd_to_nand(mtd);
1490 ++ int chipnr = (int)(to >> chip->chip_shift);
1491 + struct mtd_oob_ops ops;
1492 + int ret;
1493 +
1494 +- /* Wait for the device to get ready */
1495 +- panic_nand_wait(mtd, chip, 400);
1496 +-
1497 + /* Grab the device */
1498 + panic_nand_get_device(chip, mtd, FL_WRITING);
1499 +
1500 ++ chip->select_chip(mtd, chipnr);
1501 ++
1502 ++ /* Wait for the device to get ready */
1503 ++ panic_nand_wait(mtd, chip, 400);
1504 ++
1505 + memset(&ops, 0, sizeof(ops));
1506 + ops.len = len;
1507 + ops.datbuf = (uint8_t *)buf;
1508 +diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
1509 +index c178cb0dd219..f3a516b3f108 100644
1510 +--- a/drivers/mtd/nand/omap2.c
1511 ++++ b/drivers/mtd/nand/omap2.c
1512 +@@ -1133,129 +1133,172 @@ static u8 bch8_polynomial[] = {0xef, 0x51, 0x2e, 0x09, 0xed, 0x93, 0x9a, 0xc2,
1513 + 0x97, 0x79, 0xe5, 0x24, 0xb5};
1514 +
1515 + /**
1516 +- * omap_calculate_ecc_bch - Generate bytes of ECC bytes
1517 ++ * _omap_calculate_ecc_bch - Generate ECC bytes for one sector
1518 + * @mtd: MTD device structure
1519 + * @dat: The pointer to data on which ecc is computed
1520 + * @ecc_code: The ecc_code buffer
1521 ++ * @i: The sector number (for a multi sector page)
1522 + *
1523 +- * Support calculating of BCH4/8 ecc vectors for the page
1524 ++ * Support calculating of BCH4/8/16 ECC vectors for one sector
1525 ++ * within a page. Sector number is in @i.
1526 + */
1527 +-static int __maybe_unused omap_calculate_ecc_bch(struct mtd_info *mtd,
1528 +- const u_char *dat, u_char *ecc_calc)
1529 ++static int _omap_calculate_ecc_bch(struct mtd_info *mtd,
1530 ++ const u_char *dat, u_char *ecc_calc, int i)
1531 + {
1532 + struct omap_nand_info *info = mtd_to_omap(mtd);
1533 + int eccbytes = info->nand.ecc.bytes;
1534 + struct gpmc_nand_regs *gpmc_regs = &info->reg;
1535 + u8 *ecc_code;
1536 +- unsigned long nsectors, bch_val1, bch_val2, bch_val3, bch_val4;
1537 ++ unsigned long bch_val1, bch_val2, bch_val3, bch_val4;
1538 + u32 val;
1539 +- int i, j;
1540 ++ int j;
1541 ++
1542 ++ ecc_code = ecc_calc;
1543 ++ switch (info->ecc_opt) {
1544 ++ case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
1545 ++ case OMAP_ECC_BCH8_CODE_HW:
1546 ++ bch_val1 = readl(gpmc_regs->gpmc_bch_result0[i]);
1547 ++ bch_val2 = readl(gpmc_regs->gpmc_bch_result1[i]);
1548 ++ bch_val3 = readl(gpmc_regs->gpmc_bch_result2[i]);
1549 ++ bch_val4 = readl(gpmc_regs->gpmc_bch_result3[i]);
1550 ++ *ecc_code++ = (bch_val4 & 0xFF);
1551 ++ *ecc_code++ = ((bch_val3 >> 24) & 0xFF);
1552 ++ *ecc_code++ = ((bch_val3 >> 16) & 0xFF);
1553 ++ *ecc_code++ = ((bch_val3 >> 8) & 0xFF);
1554 ++ *ecc_code++ = (bch_val3 & 0xFF);
1555 ++ *ecc_code++ = ((bch_val2 >> 24) & 0xFF);
1556 ++ *ecc_code++ = ((bch_val2 >> 16) & 0xFF);
1557 ++ *ecc_code++ = ((bch_val2 >> 8) & 0xFF);
1558 ++ *ecc_code++ = (bch_val2 & 0xFF);
1559 ++ *ecc_code++ = ((bch_val1 >> 24) & 0xFF);
1560 ++ *ecc_code++ = ((bch_val1 >> 16) & 0xFF);
1561 ++ *ecc_code++ = ((bch_val1 >> 8) & 0xFF);
1562 ++ *ecc_code++ = (bch_val1 & 0xFF);
1563 ++ break;
1564 ++ case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
1565 ++ case OMAP_ECC_BCH4_CODE_HW:
1566 ++ bch_val1 = readl(gpmc_regs->gpmc_bch_result0[i]);
1567 ++ bch_val2 = readl(gpmc_regs->gpmc_bch_result1[i]);
1568 ++ *ecc_code++ = ((bch_val2 >> 12) & 0xFF);
1569 ++ *ecc_code++ = ((bch_val2 >> 4) & 0xFF);
1570 ++ *ecc_code++ = ((bch_val2 & 0xF) << 4) |
1571 ++ ((bch_val1 >> 28) & 0xF);
1572 ++ *ecc_code++ = ((bch_val1 >> 20) & 0xFF);
1573 ++ *ecc_code++ = ((bch_val1 >> 12) & 0xFF);
1574 ++ *ecc_code++ = ((bch_val1 >> 4) & 0xFF);
1575 ++ *ecc_code++ = ((bch_val1 & 0xF) << 4);
1576 ++ break;
1577 ++ case OMAP_ECC_BCH16_CODE_HW:
1578 ++ val = readl(gpmc_regs->gpmc_bch_result6[i]);
1579 ++ ecc_code[0] = ((val >> 8) & 0xFF);
1580 ++ ecc_code[1] = ((val >> 0) & 0xFF);
1581 ++ val = readl(gpmc_regs->gpmc_bch_result5[i]);
1582 ++ ecc_code[2] = ((val >> 24) & 0xFF);
1583 ++ ecc_code[3] = ((val >> 16) & 0xFF);
1584 ++ ecc_code[4] = ((val >> 8) & 0xFF);
1585 ++ ecc_code[5] = ((val >> 0) & 0xFF);
1586 ++ val = readl(gpmc_regs->gpmc_bch_result4[i]);
1587 ++ ecc_code[6] = ((val >> 24) & 0xFF);
1588 ++ ecc_code[7] = ((val >> 16) & 0xFF);
1589 ++ ecc_code[8] = ((val >> 8) & 0xFF);
1590 ++ ecc_code[9] = ((val >> 0) & 0xFF);
1591 ++ val = readl(gpmc_regs->gpmc_bch_result3[i]);
1592 ++ ecc_code[10] = ((val >> 24) & 0xFF);
1593 ++ ecc_code[11] = ((val >> 16) & 0xFF);
1594 ++ ecc_code[12] = ((val >> 8) & 0xFF);
1595 ++ ecc_code[13] = ((val >> 0) & 0xFF);
1596 ++ val = readl(gpmc_regs->gpmc_bch_result2[i]);
1597 ++ ecc_code[14] = ((val >> 24) & 0xFF);
1598 ++ ecc_code[15] = ((val >> 16) & 0xFF);
1599 ++ ecc_code[16] = ((val >> 8) & 0xFF);
1600 ++ ecc_code[17] = ((val >> 0) & 0xFF);
1601 ++ val = readl(gpmc_regs->gpmc_bch_result1[i]);
1602 ++ ecc_code[18] = ((val >> 24) & 0xFF);
1603 ++ ecc_code[19] = ((val >> 16) & 0xFF);
1604 ++ ecc_code[20] = ((val >> 8) & 0xFF);
1605 ++ ecc_code[21] = ((val >> 0) & 0xFF);
1606 ++ val = readl(gpmc_regs->gpmc_bch_result0[i]);
1607 ++ ecc_code[22] = ((val >> 24) & 0xFF);
1608 ++ ecc_code[23] = ((val >> 16) & 0xFF);
1609 ++ ecc_code[24] = ((val >> 8) & 0xFF);
1610 ++ ecc_code[25] = ((val >> 0) & 0xFF);
1611 ++ break;
1612 ++ default:
1613 ++ return -EINVAL;
1614 ++ }
1615 ++
1616 ++ /* ECC scheme specific syndrome customizations */
1617 ++ switch (info->ecc_opt) {
1618 ++ case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
1619 ++ /* Add constant polynomial to remainder, so that
1620 ++ * ECC of blank pages results in 0x0 on reading back
1621 ++ */
1622 ++ for (j = 0; j < eccbytes; j++)
1623 ++ ecc_calc[j] ^= bch4_polynomial[j];
1624 ++ break;
1625 ++ case OMAP_ECC_BCH4_CODE_HW:
1626 ++ /* Set 8th ECC byte as 0x0 for ROM compatibility */
1627 ++ ecc_calc[eccbytes - 1] = 0x0;
1628 ++ break;
1629 ++ case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
1630 ++ /* Add constant polynomial to remainder, so that
1631 ++ * ECC of blank pages results in 0x0 on reading back
1632 ++ */
1633 ++ for (j = 0; j < eccbytes; j++)
1634 ++ ecc_calc[j] ^= bch8_polynomial[j];
1635 ++ break;
1636 ++ case OMAP_ECC_BCH8_CODE_HW:
1637 ++ /* Set 14th ECC byte as 0x0 for ROM compatibility */
1638 ++ ecc_calc[eccbytes - 1] = 0x0;
1639 ++ break;
1640 ++ case OMAP_ECC_BCH16_CODE_HW:
1641 ++ break;
1642 ++ default:
1643 ++ return -EINVAL;
1644 ++ }
1645 ++
1646 ++ return 0;
1647 ++}
1648 ++
1649 ++/**
1650 ++ * omap_calculate_ecc_bch_sw - ECC generator for sector for SW based correction
1651 ++ * @mtd: MTD device structure
1652 ++ * @dat: The pointer to data on which ecc is computed
1653 ++ * @ecc_code: The ecc_code buffer
1654 ++ *
1655 ++ * Support calculating of BCH4/8/16 ECC vectors for one sector. This is used
1656 ++ * when SW based correction is required as ECC is required for one sector
1657 ++ * at a time.
1658 ++ */
1659 ++static int omap_calculate_ecc_bch_sw(struct mtd_info *mtd,
1660 ++ const u_char *dat, u_char *ecc_calc)
1661 ++{
1662 ++ return _omap_calculate_ecc_bch(mtd, dat, ecc_calc, 0);
1663 ++}
1664 ++
1665 ++/**
1666 ++ * omap_calculate_ecc_bch_multi - Generate ECC for multiple sectors
1667 ++ * @mtd: MTD device structure
1668 ++ * @dat: The pointer to data on which ecc is computed
1669 ++ * @ecc_code: The ecc_code buffer
1670 ++ *
1671 ++ * Support calculating of BCH4/8/16 ecc vectors for the entire page in one go.
1672 ++ */
1673 ++static int omap_calculate_ecc_bch_multi(struct mtd_info *mtd,
1674 ++ const u_char *dat, u_char *ecc_calc)
1675 ++{
1676 ++ struct omap_nand_info *info = mtd_to_omap(mtd);
1677 ++ int eccbytes = info->nand.ecc.bytes;
1678 ++ unsigned long nsectors;
1679 ++ int i, ret;
1680 +
1681 + nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1;
1682 + for (i = 0; i < nsectors; i++) {
1683 +- ecc_code = ecc_calc;
1684 +- switch (info->ecc_opt) {
1685 +- case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
1686 +- case OMAP_ECC_BCH8_CODE_HW:
1687 +- bch_val1 = readl(gpmc_regs->gpmc_bch_result0[i]);
1688 +- bch_val2 = readl(gpmc_regs->gpmc_bch_result1[i]);
1689 +- bch_val3 = readl(gpmc_regs->gpmc_bch_result2[i]);
1690 +- bch_val4 = readl(gpmc_regs->gpmc_bch_result3[i]);
1691 +- *ecc_code++ = (bch_val4 & 0xFF);
1692 +- *ecc_code++ = ((bch_val3 >> 24) & 0xFF);
1693 +- *ecc_code++ = ((bch_val3 >> 16) & 0xFF);
1694 +- *ecc_code++ = ((bch_val3 >> 8) & 0xFF);
1695 +- *ecc_code++ = (bch_val3 & 0xFF);
1696 +- *ecc_code++ = ((bch_val2 >> 24) & 0xFF);
1697 +- *ecc_code++ = ((bch_val2 >> 16) & 0xFF);
1698 +- *ecc_code++ = ((bch_val2 >> 8) & 0xFF);
1699 +- *ecc_code++ = (bch_val2 & 0xFF);
1700 +- *ecc_code++ = ((bch_val1 >> 24) & 0xFF);
1701 +- *ecc_code++ = ((bch_val1 >> 16) & 0xFF);
1702 +- *ecc_code++ = ((bch_val1 >> 8) & 0xFF);
1703 +- *ecc_code++ = (bch_val1 & 0xFF);
1704 +- break;
1705 +- case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
1706 +- case OMAP_ECC_BCH4_CODE_HW:
1707 +- bch_val1 = readl(gpmc_regs->gpmc_bch_result0[i]);
1708 +- bch_val2 = readl(gpmc_regs->gpmc_bch_result1[i]);
1709 +- *ecc_code++ = ((bch_val2 >> 12) & 0xFF);
1710 +- *ecc_code++ = ((bch_val2 >> 4) & 0xFF);
1711 +- *ecc_code++ = ((bch_val2 & 0xF) << 4) |
1712 +- ((bch_val1 >> 28) & 0xF);
1713 +- *ecc_code++ = ((bch_val1 >> 20) & 0xFF);
1714 +- *ecc_code++ = ((bch_val1 >> 12) & 0xFF);
1715 +- *ecc_code++ = ((bch_val1 >> 4) & 0xFF);
1716 +- *ecc_code++ = ((bch_val1 & 0xF) << 4);
1717 +- break;
1718 +- case OMAP_ECC_BCH16_CODE_HW:
1719 +- val = readl(gpmc_regs->gpmc_bch_result6[i]);
1720 +- ecc_code[0] = ((val >> 8) & 0xFF);
1721 +- ecc_code[1] = ((val >> 0) & 0xFF);
1722 +- val = readl(gpmc_regs->gpmc_bch_result5[i]);
1723 +- ecc_code[2] = ((val >> 24) & 0xFF);
1724 +- ecc_code[3] = ((val >> 16) & 0xFF);
1725 +- ecc_code[4] = ((val >> 8) & 0xFF);
1726 +- ecc_code[5] = ((val >> 0) & 0xFF);
1727 +- val = readl(gpmc_regs->gpmc_bch_result4[i]);
1728 +- ecc_code[6] = ((val >> 24) & 0xFF);
1729 +- ecc_code[7] = ((val >> 16) & 0xFF);
1730 +- ecc_code[8] = ((val >> 8) & 0xFF);
1731 +- ecc_code[9] = ((val >> 0) & 0xFF);
1732 +- val = readl(gpmc_regs->gpmc_bch_result3[i]);
1733 +- ecc_code[10] = ((val >> 24) & 0xFF);
1734 +- ecc_code[11] = ((val >> 16) & 0xFF);
1735 +- ecc_code[12] = ((val >> 8) & 0xFF);
1736 +- ecc_code[13] = ((val >> 0) & 0xFF);
1737 +- val = readl(gpmc_regs->gpmc_bch_result2[i]);
1738 +- ecc_code[14] = ((val >> 24) & 0xFF);
1739 +- ecc_code[15] = ((val >> 16) & 0xFF);
1740 +- ecc_code[16] = ((val >> 8) & 0xFF);
1741 +- ecc_code[17] = ((val >> 0) & 0xFF);
1742 +- val = readl(gpmc_regs->gpmc_bch_result1[i]);
1743 +- ecc_code[18] = ((val >> 24) & 0xFF);
1744 +- ecc_code[19] = ((val >> 16) & 0xFF);
1745 +- ecc_code[20] = ((val >> 8) & 0xFF);
1746 +- ecc_code[21] = ((val >> 0) & 0xFF);
1747 +- val = readl(gpmc_regs->gpmc_bch_result0[i]);
1748 +- ecc_code[22] = ((val >> 24) & 0xFF);
1749 +- ecc_code[23] = ((val >> 16) & 0xFF);
1750 +- ecc_code[24] = ((val >> 8) & 0xFF);
1751 +- ecc_code[25] = ((val >> 0) & 0xFF);
1752 +- break;
1753 +- default:
1754 +- return -EINVAL;
1755 +- }
1756 +-
1757 +- /* ECC scheme specific syndrome customizations */
1758 +- switch (info->ecc_opt) {
1759 +- case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
1760 +- /* Add constant polynomial to remainder, so that
1761 +- * ECC of blank pages results in 0x0 on reading back */
1762 +- for (j = 0; j < eccbytes; j++)
1763 +- ecc_calc[j] ^= bch4_polynomial[j];
1764 +- break;
1765 +- case OMAP_ECC_BCH4_CODE_HW:
1766 +- /* Set 8th ECC byte as 0x0 for ROM compatibility */
1767 +- ecc_calc[eccbytes - 1] = 0x0;
1768 +- break;
1769 +- case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
1770 +- /* Add constant polynomial to remainder, so that
1771 +- * ECC of blank pages results in 0x0 on reading back */
1772 +- for (j = 0; j < eccbytes; j++)
1773 +- ecc_calc[j] ^= bch8_polynomial[j];
1774 +- break;
1775 +- case OMAP_ECC_BCH8_CODE_HW:
1776 +- /* Set 14th ECC byte as 0x0 for ROM compatibility */
1777 +- ecc_calc[eccbytes - 1] = 0x0;
1778 +- break;
1779 +- case OMAP_ECC_BCH16_CODE_HW:
1780 +- break;
1781 +- default:
1782 +- return -EINVAL;
1783 +- }
1784 ++ ret = _omap_calculate_ecc_bch(mtd, dat, ecc_calc, i);
1785 ++ if (ret)
1786 ++ return ret;
1787 +
1788 +- ecc_calc += eccbytes;
1789 ++ ecc_calc += eccbytes;
1790 + }
1791 +
1792 + return 0;
1793 +@@ -1496,7 +1539,7 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1794 + chip->write_buf(mtd, buf, mtd->writesize);
1795 +
1796 + /* Update ecc vector from GPMC result registers */
1797 +- chip->ecc.calculate(mtd, buf, &ecc_calc[0]);
1798 ++ omap_calculate_ecc_bch_multi(mtd, buf, &ecc_calc[0]);
1799 +
1800 + ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
1801 + chip->ecc.total);
1802 +@@ -1508,6 +1551,72 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1803 + return 0;
1804 + }
1805 +
1806 ++/**
1807 ++ * omap_write_subpage_bch - BCH hardware ECC based subpage write
1808 ++ * @mtd: mtd info structure
1809 ++ * @chip: nand chip info structure
1810 ++ * @offset: column address of subpage within the page
1811 ++ * @data_len: data length
1812 ++ * @buf: data buffer
1813 ++ * @oob_required: must write chip->oob_poi to OOB
1814 ++ * @page: page number to write
1815 ++ *
1816 ++ * OMAP optimized subpage write method.
1817 ++ */
1818 ++static int omap_write_subpage_bch(struct mtd_info *mtd,
1819 ++ struct nand_chip *chip, u32 offset,
1820 ++ u32 data_len, const u8 *buf,
1821 ++ int oob_required, int page)
1822 ++{
1823 ++ u8 *ecc_calc = chip->buffers->ecccalc;
1824 ++ int ecc_size = chip->ecc.size;
1825 ++ int ecc_bytes = chip->ecc.bytes;
1826 ++ int ecc_steps = chip->ecc.steps;
1827 ++ u32 start_step = offset / ecc_size;
1828 ++ u32 end_step = (offset + data_len - 1) / ecc_size;
1829 ++ int step, ret = 0;
1830 ++
1831 ++ /*
1832 ++ * Write entire page at one go as it would be optimal
1833 ++ * as ECC is calculated by hardware.
1834 ++ * ECC is calculated for all subpages but we choose
1835 ++ * only what we want.
1836 ++ */
1837 ++
1838 ++ /* Enable GPMC ECC engine */
1839 ++ chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
1840 ++
1841 ++ /* Write data */
1842 ++ chip->write_buf(mtd, buf, mtd->writesize);
1843 ++
1844 ++ for (step = 0; step < ecc_steps; step++) {
1845 ++ /* mask ECC of un-touched subpages by padding 0xFF */
1846 ++ if (step < start_step || step > end_step)
1847 ++ memset(ecc_calc, 0xff, ecc_bytes);
1848 ++ else
1849 ++ ret = _omap_calculate_ecc_bch(mtd, buf, ecc_calc, step);
1850 ++
1851 ++ if (ret)
1852 ++ return ret;
1853 ++
1854 ++ buf += ecc_size;
1855 ++ ecc_calc += ecc_bytes;
1856 ++ }
1857 ++
1858 ++ /* copy calculated ECC for whole page to chip->buffer->oob */
1859 ++ /* this include masked-value(0xFF) for unwritten subpages */
1860 ++ ecc_calc = chip->buffers->ecccalc;
1861 ++ ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
1862 ++ chip->ecc.total);
1863 ++ if (ret)
1864 ++ return ret;
1865 ++
1866 ++ /* write OOB buffer to NAND device */
1867 ++ chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
1868 ++
1869 ++ return 0;
1870 ++}
1871 ++
1872 + /**
1873 + * omap_read_page_bch - BCH ecc based page read function for entire page
1874 + * @mtd: mtd info structure
1875 +@@ -1544,7 +1653,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1876 + chip->ecc.total);
1877 +
1878 + /* Calculate ecc bytes */
1879 +- chip->ecc.calculate(mtd, buf, ecc_calc);
1880 ++ omap_calculate_ecc_bch_multi(mtd, buf, ecc_calc);
1881 +
1882 + ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
1883 + chip->ecc.total);
1884 +@@ -2044,7 +2153,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1885 + nand_chip->ecc.strength = 4;
1886 + nand_chip->ecc.hwctl = omap_enable_hwecc_bch;
1887 + nand_chip->ecc.correct = nand_bch_correct_data;
1888 +- nand_chip->ecc.calculate = omap_calculate_ecc_bch;
1889 ++ nand_chip->ecc.calculate = omap_calculate_ecc_bch_sw;
1890 + mtd_set_ooblayout(mtd, &omap_sw_ooblayout_ops);
1891 + /* Reserve one byte for the OMAP marker */
1892 + oobbytes_per_step = nand_chip->ecc.bytes + 1;
1893 +@@ -2066,9 +2175,9 @@ static int omap_nand_probe(struct platform_device *pdev)
1894 + nand_chip->ecc.strength = 4;
1895 + nand_chip->ecc.hwctl = omap_enable_hwecc_bch;
1896 + nand_chip->ecc.correct = omap_elm_correct_data;
1897 +- nand_chip->ecc.calculate = omap_calculate_ecc_bch;
1898 + nand_chip->ecc.read_page = omap_read_page_bch;
1899 + nand_chip->ecc.write_page = omap_write_page_bch;
1900 ++ nand_chip->ecc.write_subpage = omap_write_subpage_bch;
1901 + mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
1902 + oobbytes_per_step = nand_chip->ecc.bytes;
1903 +
1904 +@@ -2087,7 +2196,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1905 + nand_chip->ecc.strength = 8;
1906 + nand_chip->ecc.hwctl = omap_enable_hwecc_bch;
1907 + nand_chip->ecc.correct = nand_bch_correct_data;
1908 +- nand_chip->ecc.calculate = omap_calculate_ecc_bch;
1909 ++ nand_chip->ecc.calculate = omap_calculate_ecc_bch_sw;
1910 + mtd_set_ooblayout(mtd, &omap_sw_ooblayout_ops);
1911 + /* Reserve one byte for the OMAP marker */
1912 + oobbytes_per_step = nand_chip->ecc.bytes + 1;
1913 +@@ -2109,9 +2218,9 @@ static int omap_nand_probe(struct platform_device *pdev)
1914 + nand_chip->ecc.strength = 8;
1915 + nand_chip->ecc.hwctl = omap_enable_hwecc_bch;
1916 + nand_chip->ecc.correct = omap_elm_correct_data;
1917 +- nand_chip->ecc.calculate = omap_calculate_ecc_bch;
1918 + nand_chip->ecc.read_page = omap_read_page_bch;
1919 + nand_chip->ecc.write_page = omap_write_page_bch;
1920 ++ nand_chip->ecc.write_subpage = omap_write_subpage_bch;
1921 + mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
1922 + oobbytes_per_step = nand_chip->ecc.bytes;
1923 +
1924 +@@ -2131,9 +2240,9 @@ static int omap_nand_probe(struct platform_device *pdev)
1925 + nand_chip->ecc.strength = 16;
1926 + nand_chip->ecc.hwctl = omap_enable_hwecc_bch;
1927 + nand_chip->ecc.correct = omap_elm_correct_data;
1928 +- nand_chip->ecc.calculate = omap_calculate_ecc_bch;
1929 + nand_chip->ecc.read_page = omap_read_page_bch;
1930 + nand_chip->ecc.write_page = omap_write_page_bch;
1931 ++ nand_chip->ecc.write_subpage = omap_write_subpage_bch;
1932 + mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
1933 + oobbytes_per_step = nand_chip->ecc.bytes;
1934 +
1935 +diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
1936 +index 8f8418d2ac4a..a0012c3cb4f6 100644
1937 +--- a/drivers/net/ethernet/3com/typhoon.c
1938 ++++ b/drivers/net/ethernet/3com/typhoon.c
1939 +@@ -2366,9 +2366,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1940 + * 4) Get the hardware address.
1941 + * 5) Put the card to sleep.
1942 + */
1943 +- if (typhoon_reset(ioaddr, WaitSleep) < 0) {
1944 ++ err = typhoon_reset(ioaddr, WaitSleep);
1945 ++ if (err < 0) {
1946 + err_msg = "could not reset 3XP";
1947 +- err = -EIO;
1948 + goto error_out_dma;
1949 + }
1950 +
1951 +@@ -2382,24 +2382,25 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1952 + typhoon_init_interface(tp);
1953 + typhoon_init_rings(tp);
1954 +
1955 +- if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
1956 ++ err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
1957 ++ if (err < 0) {
1958 + err_msg = "cannot boot 3XP sleep image";
1959 +- err = -EIO;
1960 + goto error_out_reset;
1961 + }
1962 +
1963 + INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
1964 +- if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) {
1965 ++ err = typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp);
1966 ++ if (err < 0) {
1967 + err_msg = "cannot read MAC address";
1968 +- err = -EIO;
1969 + goto error_out_reset;
1970 + }
1971 +
1972 + *(__be16 *)&dev->dev_addr[0] = htons(le16_to_cpu(xp_resp[0].parm1));
1973 + *(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2));
1974 +
1975 +- if(!is_valid_ether_addr(dev->dev_addr)) {
1976 ++ if (!is_valid_ether_addr(dev->dev_addr)) {
1977 + err_msg = "Could not obtain valid ethernet address, aborting";
1978 ++ err = -EIO;
1979 + goto error_out_reset;
1980 + }
1981 +
1982 +@@ -2407,7 +2408,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1983 + * later when we print out the version reported.
1984 + */
1985 + INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
1986 +- if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
1987 ++ err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
1988 ++ if (err < 0) {
1989 + err_msg = "Could not get Sleep Image version";
1990 + goto error_out_reset;
1991 + }
1992 +@@ -2424,9 +2426,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1993 + if(xp_resp[0].numDesc != 0)
1994 + tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
1995 +
1996 +- if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
1997 ++ err = typhoon_sleep(tp, PCI_D3hot, 0);
1998 ++ if (err < 0) {
1999 + err_msg = "cannot put adapter to sleep";
2000 +- err = -EIO;
2001 + goto error_out_reset;
2002 + }
2003 +
2004 +@@ -2449,7 +2451,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2005 + dev->features = dev->hw_features |
2006 + NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
2007 +
2008 +- if(register_netdev(dev) < 0) {
2009 ++ err = register_netdev(dev);
2010 ++ if (err < 0) {
2011 + err_msg = "unable to register netdev";
2012 + goto error_out_reset;
2013 + }
2014 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2015 +index 333df540b375..5d2cf56aed0e 100644
2016 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2017 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2018 +@@ -3800,6 +3800,30 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
2019 + return rc;
2020 + }
2021 +
2022 ++static int bnxt_hwrm_set_async_event_cr(struct bnxt *bp, int idx)
2023 ++{
2024 ++ int rc;
2025 ++
2026 ++ if (BNXT_PF(bp)) {
2027 ++ struct hwrm_func_cfg_input req = {0};
2028 ++
2029 ++ bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
2030 ++ req.fid = cpu_to_le16(0xffff);
2031 ++ req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR);
2032 ++ req.async_event_cr = cpu_to_le16(idx);
2033 ++ rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
2034 ++ } else {
2035 ++ struct hwrm_func_vf_cfg_input req = {0};
2036 ++
2037 ++ bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1);
2038 ++ req.enables =
2039 ++ cpu_to_le32(FUNC_VF_CFG_REQ_ENABLES_ASYNC_EVENT_CR);
2040 ++ req.async_event_cr = cpu_to_le16(idx);
2041 ++ rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
2042 ++ }
2043 ++ return rc;
2044 ++}
2045 ++
2046 + static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
2047 + {
2048 + int i, rc = 0;
2049 +@@ -3816,6 +3840,12 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
2050 + goto err_out;
2051 + BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons);
2052 + bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id;
2053 ++
2054 ++ if (!i) {
2055 ++ rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id);
2056 ++ if (rc)
2057 ++ netdev_warn(bp->dev, "Failed to set async event completion ring.\n");
2058 ++ }
2059 + }
2060 +
2061 + for (i = 0; i < bp->tx_nr_rings; i++) {
2062 +diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
2063 +index 0641c0098738..afb7ebe20b24 100644
2064 +--- a/drivers/net/ethernet/intel/e1000e/defines.h
2065 ++++ b/drivers/net/ethernet/intel/e1000e/defines.h
2066 +@@ -398,6 +398,7 @@
2067 + #define E1000_ICR_LSC 0x00000004 /* Link Status Change */
2068 + #define E1000_ICR_RXSEQ 0x00000008 /* Rx sequence error */
2069 + #define E1000_ICR_RXDMT0 0x00000010 /* Rx desc min. threshold (0) */
2070 ++#define E1000_ICR_RXO 0x00000040 /* Receiver Overrun */
2071 + #define E1000_ICR_RXT0 0x00000080 /* Rx timer intr (ring 0) */
2072 + #define E1000_ICR_ECCER 0x00400000 /* Uncorrectable ECC Error */
2073 + /* If this bit asserted, the driver should claim the interrupt */
2074 +diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
2075 +index b322011ec282..f457c5703d0c 100644
2076 +--- a/drivers/net/ethernet/intel/e1000e/mac.c
2077 ++++ b/drivers/net/ethernet/intel/e1000e/mac.c
2078 +@@ -410,6 +410,9 @@ void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw)
2079 + * Checks to see of the link status of the hardware has changed. If a
2080 + * change in link status has been detected, then we read the PHY registers
2081 + * to get the current speed/duplex if link exists.
2082 ++ *
2083 ++ * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link
2084 ++ * up).
2085 + **/
2086 + s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
2087 + {
2088 +@@ -423,7 +426,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
2089 + * Change or Rx Sequence Error interrupt.
2090 + */
2091 + if (!mac->get_link_status)
2092 +- return 0;
2093 ++ return 1;
2094 +
2095 + /* First we want to see if the MII Status Register reports
2096 + * link. If so, then we want to get the current speed/duplex
2097 +@@ -461,10 +464,12 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
2098 + * different link partner.
2099 + */
2100 + ret_val = e1000e_config_fc_after_link_up(hw);
2101 +- if (ret_val)
2102 ++ if (ret_val) {
2103 + e_dbg("Error configuring flow control\n");
2104 ++ return ret_val;
2105 ++ }
2106 +
2107 +- return ret_val;
2108 ++ return 1;
2109 + }
2110 +
2111 + /**
2112 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
2113 +index 7017281ba2dc..0feddf3393f9 100644
2114 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
2115 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
2116 +@@ -1905,14 +1905,30 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data)
2117 + struct net_device *netdev = data;
2118 + struct e1000_adapter *adapter = netdev_priv(netdev);
2119 + struct e1000_hw *hw = &adapter->hw;
2120 ++ u32 icr;
2121 ++ bool enable = true;
2122 ++
2123 ++ icr = er32(ICR);
2124 ++ if (icr & E1000_ICR_RXO) {
2125 ++ ew32(ICR, E1000_ICR_RXO);
2126 ++ enable = false;
2127 ++ /* napi poll will re-enable Other, make sure it runs */
2128 ++ if (napi_schedule_prep(&adapter->napi)) {
2129 ++ adapter->total_rx_bytes = 0;
2130 ++ adapter->total_rx_packets = 0;
2131 ++ __napi_schedule(&adapter->napi);
2132 ++ }
2133 ++ }
2134 ++ if (icr & E1000_ICR_LSC) {
2135 ++ ew32(ICR, E1000_ICR_LSC);
2136 ++ hw->mac.get_link_status = true;
2137 ++ /* guard against interrupt when we're going down */
2138 ++ if (!test_bit(__E1000_DOWN, &adapter->state))
2139 ++ mod_timer(&adapter->watchdog_timer, jiffies + 1);
2140 ++ }
2141 +
2142 +- hw->mac.get_link_status = true;
2143 +-
2144 +- /* guard against interrupt when we're going down */
2145 +- if (!test_bit(__E1000_DOWN, &adapter->state)) {
2146 +- mod_timer(&adapter->watchdog_timer, jiffies + 1);
2147 ++ if (enable && !test_bit(__E1000_DOWN, &adapter->state))
2148 + ew32(IMS, E1000_IMS_OTHER);
2149 +- }
2150 +
2151 + return IRQ_HANDLED;
2152 + }
2153 +@@ -2683,7 +2699,8 @@ static int e1000e_poll(struct napi_struct *napi, int weight)
2154 + napi_complete_done(napi, work_done);
2155 + if (!test_bit(__E1000_DOWN, &adapter->state)) {
2156 + if (adapter->msix_entries)
2157 +- ew32(IMS, adapter->rx_ring->ims_val);
2158 ++ ew32(IMS, adapter->rx_ring->ims_val |
2159 ++ E1000_IMS_OTHER);
2160 + else
2161 + e1000_irq_enable(adapter);
2162 + }
2163 +@@ -4178,7 +4195,7 @@ static void e1000e_trigger_lsc(struct e1000_adapter *adapter)
2164 + struct e1000_hw *hw = &adapter->hw;
2165 +
2166 + if (adapter->msix_entries)
2167 +- ew32(ICS, E1000_ICS_OTHER);
2168 ++ ew32(ICS, E1000_ICS_LSC | E1000_ICS_OTHER);
2169 + else
2170 + ew32(ICS, E1000_ICS_LSC);
2171 + }
2172 +@@ -5056,7 +5073,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter)
2173 + case e1000_media_type_copper:
2174 + if (hw->mac.get_link_status) {
2175 + ret_val = hw->mac.ops.check_for_link(hw);
2176 +- link_active = !hw->mac.get_link_status;
2177 ++ link_active = ret_val > 0;
2178 + } else {
2179 + link_active = true;
2180 + }
2181 +@@ -5074,7 +5091,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter)
2182 + break;
2183 + }
2184 +
2185 +- if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
2186 ++ if ((ret_val == -E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
2187 + (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
2188 + /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
2189 + e_info("Gigabit has been disabled, downgrading speed\n");
2190 +diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
2191 +index d78d47b41a71..86ff0969efb6 100644
2192 +--- a/drivers/net/ethernet/intel/e1000e/phy.c
2193 ++++ b/drivers/net/ethernet/intel/e1000e/phy.c
2194 +@@ -1744,6 +1744,7 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
2195 + s32 ret_val = 0;
2196 + u16 i, phy_status;
2197 +
2198 ++ *success = false;
2199 + for (i = 0; i < iterations; i++) {
2200 + /* Some PHYs require the MII_BMSR register to be read
2201 + * twice due to the link bit being sticky. No harm doing
2202 +@@ -1763,16 +1764,16 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
2203 + ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
2204 + if (ret_val)
2205 + break;
2206 +- if (phy_status & BMSR_LSTATUS)
2207 ++ if (phy_status & BMSR_LSTATUS) {
2208 ++ *success = true;
2209 + break;
2210 ++ }
2211 + if (usec_interval >= 1000)
2212 + msleep(usec_interval / 1000);
2213 + else
2214 + udelay(usec_interval);
2215 + }
2216 +
2217 +- *success = (i < iterations);
2218 +-
2219 + return ret_val;
2220 + }
2221 +
2222 +diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
2223 +index 5de937852436..2aae6f88dca0 100644
2224 +--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
2225 ++++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
2226 +@@ -1225,7 +1225,7 @@ static bool fm10k_clean_tx_irq(struct fm10k_q_vector *q_vector,
2227 + break;
2228 +
2229 + /* prevent any other reads prior to eop_desc */
2230 +- read_barrier_depends();
2231 ++ smp_rmb();
2232 +
2233 + /* if DD is not set pending work has not been completed */
2234 + if (!(eop_desc->flags & FM10K_TXD_FLAG_DONE))
2235 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
2236 +index 31c97e3937a4..2caafebb0295 100644
2237 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
2238 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
2239 +@@ -3604,7 +3604,7 @@ static bool i40e_clean_fdir_tx_irq(struct i40e_ring *tx_ring, int budget)
2240 + break;
2241 +
2242 + /* prevent any other reads prior to eop_desc */
2243 +- read_barrier_depends();
2244 ++ smp_rmb();
2245 +
2246 + /* if the descriptor isn't done, no work yet to do */
2247 + if (!(eop_desc->cmd_type_offset_bsz &
2248 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
2249 +index 6287bf63c43c..c5430394fac9 100644
2250 +--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
2251 ++++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
2252 +@@ -679,7 +679,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
2253 + break;
2254 +
2255 + /* prevent any other reads prior to eop_desc */
2256 +- read_barrier_depends();
2257 ++ smp_rmb();
2258 +
2259 + /* we have caught up to head, no work left to do */
2260 + if (tx_head == tx_desc)
2261 +diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
2262 +index 75f2a2cdd738..c03800d1000a 100644
2263 +--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
2264 ++++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
2265 +@@ -184,7 +184,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
2266 + break;
2267 +
2268 + /* prevent any other reads prior to eop_desc */
2269 +- read_barrier_depends();
2270 ++ smp_rmb();
2271 +
2272 + /* we have caught up to head, no work left to do */
2273 + if (tx_head == tx_desc)
2274 +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
2275 +index c6c2562d9df3..16839600fb78 100644
2276 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
2277 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
2278 +@@ -6660,7 +6660,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget)
2279 + break;
2280 +
2281 + /* prevent any other reads prior to eop_desc */
2282 +- read_barrier_depends();
2283 ++ smp_rmb();
2284 +
2285 + /* if DD is not set pending work has not been completed */
2286 + if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)))
2287 +diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
2288 +index 7dff7f6239cd..5428e39fa4e5 100644
2289 +--- a/drivers/net/ethernet/intel/igbvf/netdev.c
2290 ++++ b/drivers/net/ethernet/intel/igbvf/netdev.c
2291 +@@ -810,7 +810,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
2292 + break;
2293 +
2294 + /* prevent any other reads prior to eop_desc */
2295 +- read_barrier_depends();
2296 ++ smp_rmb();
2297 +
2298 + /* if DD is not set pending work has not been completed */
2299 + if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)))
2300 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
2301 +index 334eb96ecda3..a5428b6abdac 100644
2302 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
2303 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
2304 +@@ -1171,7 +1171,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
2305 + break;
2306 +
2307 + /* prevent any other reads prior to eop_desc */
2308 +- read_barrier_depends();
2309 ++ smp_rmb();
2310 +
2311 + /* if DD is not set pending work has not been completed */
2312 + if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)))
2313 +diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2314 +index cbf70fe4028a..1499ce2bf9f6 100644
2315 +--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2316 ++++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2317 +@@ -325,7 +325,7 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_q_vector *q_vector,
2318 + break;
2319 +
2320 + /* prevent any other reads prior to eop_desc */
2321 +- read_barrier_depends();
2322 ++ smp_rmb();
2323 +
2324 + /* if DD is not set pending work has not been completed */
2325 + if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)))
2326 +diff --git a/drivers/net/wireless/admtek/adm8211.c b/drivers/net/wireless/admtek/adm8211.c
2327 +index 70ecd82d674d..098c814e22c8 100644
2328 +--- a/drivers/net/wireless/admtek/adm8211.c
2329 ++++ b/drivers/net/wireless/admtek/adm8211.c
2330 +@@ -413,6 +413,13 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
2331 + skb_tail_pointer(newskb),
2332 + RX_PKT_SIZE,
2333 + PCI_DMA_FROMDEVICE);
2334 ++ if (pci_dma_mapping_error(priv->pdev,
2335 ++ priv->rx_buffers[entry].mapping)) {
2336 ++ priv->rx_buffers[entry].skb = NULL;
2337 ++ dev_kfree_skb(newskb);
2338 ++ skb = NULL;
2339 ++ /* TODO: update rx dropped stats */
2340 ++ }
2341 + } else {
2342 + skb = NULL;
2343 + /* TODO: update rx dropped stats */
2344 +@@ -1450,6 +1457,12 @@ static int adm8211_init_rings(struct ieee80211_hw *dev)
2345 + skb_tail_pointer(rx_info->skb),
2346 + RX_PKT_SIZE,
2347 + PCI_DMA_FROMDEVICE);
2348 ++ if (pci_dma_mapping_error(priv->pdev, rx_info->mapping)) {
2349 ++ dev_kfree_skb(rx_info->skb);
2350 ++ rx_info->skb = NULL;
2351 ++ break;
2352 ++ }
2353 ++
2354 + desc->buffer1 = cpu_to_le32(rx_info->mapping);
2355 + desc->status = cpu_to_le32(RDES0_STATUS_OWN | RDES0_STATUS_SQL);
2356 + }
2357 +@@ -1613,7 +1626,7 @@ static void adm8211_calc_durations(int *dur, int *plcp, size_t payload_len, int
2358 + }
2359 +
2360 + /* Transmit skb w/adm8211_tx_hdr (802.11 header created by hardware) */
2361 +-static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
2362 ++static int adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
2363 + u16 plcp_signal,
2364 + size_t hdrlen)
2365 + {
2366 +@@ -1625,6 +1638,8 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
2367 +
2368 + mapping = pci_map_single(priv->pdev, skb->data, skb->len,
2369 + PCI_DMA_TODEVICE);
2370 ++ if (pci_dma_mapping_error(priv->pdev, mapping))
2371 ++ return -ENOMEM;
2372 +
2373 + spin_lock_irqsave(&priv->lock, flags);
2374 +
2375 +@@ -1657,6 +1672,8 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
2376 +
2377 + /* Trigger transmit poll */
2378 + ADM8211_CSR_WRITE(TDR, 0);
2379 ++
2380 ++ return 0;
2381 + }
2382 +
2383 + /* Put adm8211_tx_hdr on skb and transmit */
2384 +@@ -1710,7 +1727,10 @@ static void adm8211_tx(struct ieee80211_hw *dev,
2385 +
2386 + txhdr->retry_limit = info->control.rates[0].count;
2387 +
2388 +- adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
2389 ++ if (adm8211_tx_raw(dev, skb, plcp_signal, hdrlen)) {
2390 ++ /* Drop packet */
2391 ++ ieee80211_free_txskb(dev, skb);
2392 ++ }
2393 + }
2394 +
2395 + static int adm8211_alloc_rings(struct ieee80211_hw *dev)
2396 +@@ -1843,7 +1863,8 @@ static int adm8211_probe(struct pci_dev *pdev,
2397 + priv->rx_ring_size = rx_ring_size;
2398 + priv->tx_ring_size = tx_ring_size;
2399 +
2400 +- if (adm8211_alloc_rings(dev)) {
2401 ++ err = adm8211_alloc_rings(dev);
2402 ++ if (err) {
2403 + printk(KERN_ERR "%s (adm8211): Cannot allocate TX/RX ring\n",
2404 + pci_name(pdev));
2405 + goto err_iounmap;
2406 +diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
2407 +index 366d3dcb8e9d..7b3017f55e3d 100644
2408 +--- a/drivers/net/wireless/ath/ath10k/core.c
2409 ++++ b/drivers/net/wireless/ath/ath10k/core.c
2410 +@@ -691,8 +691,11 @@ static int ath10k_core_get_board_id_from_otp(struct ath10k *ar)
2411 + "boot get otp board id result 0x%08x board_id %d chip_id %d\n",
2412 + result, board_id, chip_id);
2413 +
2414 +- if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0)
2415 ++ if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0 ||
2416 ++ (board_id == 0)) {
2417 ++ ath10k_warn(ar, "board id is not exist in otp, ignore it\n");
2418 + return -EOPNOTSUPP;
2419 ++ }
2420 +
2421 + ar->id.bmi_ids_valid = true;
2422 + ar->id.bmi_board_id = board_id;
2423 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
2424 +index 30e98afa2e68..17ab8efdac35 100644
2425 +--- a/drivers/net/wireless/ath/ath10k/mac.c
2426 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
2427 +@@ -1224,6 +1224,36 @@ static int ath10k_monitor_recalc(struct ath10k *ar)
2428 + return ath10k_monitor_stop(ar);
2429 + }
2430 +
2431 ++static bool ath10k_mac_can_set_cts_prot(struct ath10k_vif *arvif)
2432 ++{
2433 ++ struct ath10k *ar = arvif->ar;
2434 ++
2435 ++ lockdep_assert_held(&ar->conf_mutex);
2436 ++
2437 ++ if (!arvif->is_started) {
2438 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "defer cts setup, vdev is not ready yet\n");
2439 ++ return false;
2440 ++ }
2441 ++
2442 ++ return true;
2443 ++}
2444 ++
2445 ++static int ath10k_mac_set_cts_prot(struct ath10k_vif *arvif)
2446 ++{
2447 ++ struct ath10k *ar = arvif->ar;
2448 ++ u32 vdev_param;
2449 ++
2450 ++ lockdep_assert_held(&ar->conf_mutex);
2451 ++
2452 ++ vdev_param = ar->wmi.vdev_param->protection_mode;
2453 ++
2454 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_protection %d\n",
2455 ++ arvif->vdev_id, arvif->use_cts_prot);
2456 ++
2457 ++ return ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2458 ++ arvif->use_cts_prot ? 1 : 0);
2459 ++}
2460 ++
2461 + static int ath10k_recalc_rtscts_prot(struct ath10k_vif *arvif)
2462 + {
2463 + struct ath10k *ar = arvif->ar;
2464 +@@ -4668,7 +4698,8 @@ static int ath10k_mac_txpower_recalc(struct ath10k *ar)
2465 + lockdep_assert_held(&ar->conf_mutex);
2466 +
2467 + list_for_each_entry(arvif, &ar->arvifs, list) {
2468 +- WARN_ON(arvif->txpower < 0);
2469 ++ if (arvif->txpower <= 0)
2470 ++ continue;
2471 +
2472 + if (txpower == -1)
2473 + txpower = arvif->txpower;
2474 +@@ -4676,8 +4707,8 @@ static int ath10k_mac_txpower_recalc(struct ath10k *ar)
2475 + txpower = min(txpower, arvif->txpower);
2476 + }
2477 +
2478 +- if (WARN_ON(txpower == -1))
2479 +- return -EINVAL;
2480 ++ if (txpower == -1)
2481 ++ return 0;
2482 +
2483 + ret = ath10k_mac_txpower_setup(ar, txpower);
2484 + if (ret) {
2485 +@@ -5321,20 +5352,18 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2486 +
2487 + if (changed & BSS_CHANGED_ERP_CTS_PROT) {
2488 + arvif->use_cts_prot = info->use_cts_prot;
2489 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n",
2490 +- arvif->vdev_id, info->use_cts_prot);
2491 +
2492 + ret = ath10k_recalc_rtscts_prot(arvif);
2493 + if (ret)
2494 + ath10k_warn(ar, "failed to recalculate rts/cts prot for vdev %d: %d\n",
2495 + arvif->vdev_id, ret);
2496 +
2497 +- vdev_param = ar->wmi.vdev_param->protection_mode;
2498 +- ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2499 +- info->use_cts_prot ? 1 : 0);
2500 +- if (ret)
2501 +- ath10k_warn(ar, "failed to set protection mode %d on vdev %i: %d\n",
2502 +- info->use_cts_prot, arvif->vdev_id, ret);
2503 ++ if (ath10k_mac_can_set_cts_prot(arvif)) {
2504 ++ ret = ath10k_mac_set_cts_prot(arvif);
2505 ++ if (ret)
2506 ++ ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
2507 ++ arvif->vdev_id, ret);
2508 ++ }
2509 + }
2510 +
2511 + if (changed & BSS_CHANGED_ERP_SLOT) {
2512 +@@ -7355,6 +7384,13 @@ ath10k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
2513 + arvif->is_up = true;
2514 + }
2515 +
2516 ++ if (ath10k_mac_can_set_cts_prot(arvif)) {
2517 ++ ret = ath10k_mac_set_cts_prot(arvif);
2518 ++ if (ret)
2519 ++ ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
2520 ++ arvif->vdev_id, ret);
2521 ++ }
2522 ++
2523 + mutex_unlock(&ar->conf_mutex);
2524 + return 0;
2525 +
2526 +diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
2527 +index e64f59300a7c..0e4d49adddd0 100644
2528 +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
2529 ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
2530 +@@ -1105,8 +1105,10 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
2531 + struct ath10k_fw_stats_pdev *dst;
2532 +
2533 + src = data;
2534 +- if (data_len < sizeof(*src))
2535 ++ if (data_len < sizeof(*src)) {
2536 ++ kfree(tb);
2537 + return -EPROTO;
2538 ++ }
2539 +
2540 + data += sizeof(*src);
2541 + data_len -= sizeof(*src);
2542 +@@ -1126,8 +1128,10 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
2543 + struct ath10k_fw_stats_vdev *dst;
2544 +
2545 + src = data;
2546