Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Sun, 25 Mar 2018 13:40:00
Message-Id: 1521985185.24600d34f199cfd7595b909b420a363d0b42d34a.mpagano@gentoo
1 commit: 24600d34f199cfd7595b909b420a363d0b42d34a
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sun Mar 25 13:39:45 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 25 13:39:45 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=24600d34
7
8 Linux patch 4.9.90
9
10 0000_README | 4 +
11 1089_linux-4.9.90.patch | 6281 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 6285 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index bb64a79..d488776 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -399,6 +399,10 @@ Patch: 1088_linux-4.9.89.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.9.89
21
22 +Patch: 1089_linux-4.9.90.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.9.90
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/1089_linux-4.9.90.patch b/1089_linux-4.9.90.patch
31 new file mode 100644
32 index 0000000..8db892c
33 --- /dev/null
34 +++ b/1089_linux-4.9.90.patch
35 @@ -0,0 +1,6281 @@
36 +diff --git a/Documentation/devicetree/bindings/display/panel/toppoly,td028ttec1.txt b/Documentation/devicetree/bindings/display/panel/toppoly,td028ttec1.txt
37 +deleted file mode 100644
38 +index 7175dc3740ac..000000000000
39 +--- a/Documentation/devicetree/bindings/display/panel/toppoly,td028ttec1.txt
40 ++++ /dev/null
41 +@@ -1,30 +0,0 @@
42 +-Toppoly TD028TTEC1 Panel
43 +-========================
44 +-
45 +-Required properties:
46 +-- compatible: "toppoly,td028ttec1"
47 +-
48 +-Optional properties:
49 +-- label: a symbolic name for the panel
50 +-
51 +-Required nodes:
52 +-- Video port for DPI input
53 +-
54 +-Example
55 +--------
56 +-
57 +-lcd-panel: td028ttec1@0 {
58 +- compatible = "toppoly,td028ttec1";
59 +- reg = <0>;
60 +- spi-max-frequency = <100000>;
61 +- spi-cpol;
62 +- spi-cpha;
63 +-
64 +- label = "lcd";
65 +- port {
66 +- lcd_in: endpoint {
67 +- remote-endpoint = <&dpi_out>;
68 +- };
69 +- };
70 +-};
71 +-
72 +diff --git a/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt b/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt
73 +new file mode 100644
74 +index 000000000000..ed34253d9fb1
75 +--- /dev/null
76 ++++ b/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt
77 +@@ -0,0 +1,30 @@
78 ++Toppoly TD028TTEC1 Panel
79 ++========================
80 ++
81 ++Required properties:
82 ++- compatible: "tpo,td028ttec1"
83 ++
84 ++Optional properties:
85 ++- label: a symbolic name for the panel
86 ++
87 ++Required nodes:
88 ++- Video port for DPI input
89 ++
90 ++Example
91 ++-------
92 ++
93 ++lcd-panel: td028ttec1@0 {
94 ++ compatible = "tpo,td028ttec1";
95 ++ reg = <0>;
96 ++ spi-max-frequency = <100000>;
97 ++ spi-cpol;
98 ++ spi-cpha;
99 ++
100 ++ label = "lcd";
101 ++ port {
102 ++ lcd_in: endpoint {
103 ++ remote-endpoint = <&dpi_out>;
104 ++ };
105 ++ };
106 ++};
107 ++
108 +diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
109 +index 8f3ad9ab4637..b41d2601c6ba 100644
110 +--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
111 ++++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
112 +@@ -28,6 +28,9 @@ Optional properties:
113 + regulator to drive the OTG VBus, rather then as an input pin
114 + which signals whether the board is driving OTG VBus or not.
115 +
116 ++- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
117 ++ wired for master mode. The default is slave mode.
118 ++
119 + - <input>-supply: a phandle to the regulator supply node. May be omitted if
120 + inputs are unregulated, such as using the IPSOUT output
121 + from the PMIC.
122 +diff --git a/Makefile b/Makefile
123 +index 16dca98900e7..df3b20af0fdb 100644
124 +--- a/Makefile
125 ++++ b/Makefile
126 +@@ -1,6 +1,6 @@
127 + VERSION = 4
128 + PATCHLEVEL = 9
129 +-SUBLEVEL = 89
130 ++SUBLEVEL = 90
131 + EXTRAVERSION =
132 + NAME = Roaring Lionus
133 +
134 +diff --git a/arch/alpha/kernel/console.c b/arch/alpha/kernel/console.c
135 +index 6a61deed4a85..ab228ed45945 100644
136 +--- a/arch/alpha/kernel/console.c
137 ++++ b/arch/alpha/kernel/console.c
138 +@@ -20,6 +20,7 @@
139 + struct pci_controller *pci_vga_hose;
140 + static struct resource alpha_vga = {
141 + .name = "alpha-vga+",
142 ++ .flags = IORESOURCE_IO,
143 + .start = 0x3C0,
144 + .end = 0x3DF
145 + };
146 +diff --git a/arch/arm/boot/dts/aspeed-ast2500-evb.dts b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
147 +index 1b7a5ff0e533..d7774d35e466 100644
148 +--- a/arch/arm/boot/dts/aspeed-ast2500-evb.dts
149 ++++ b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
150 +@@ -15,7 +15,7 @@
151 + bootargs = "console=ttyS4,115200 earlyprintk";
152 + };
153 +
154 +- memory {
155 ++ memory@80000000 {
156 + reg = <0x80000000 0x20000000>;
157 + };
158 + };
159 +diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
160 +index 3f1759411d51..414e60ed0257 100644
161 +--- a/arch/arm/kernel/ftrace.c
162 ++++ b/arch/arm/kernel/ftrace.c
163 +@@ -29,11 +29,6 @@
164 + #endif
165 +
166 + #ifdef CONFIG_DYNAMIC_FTRACE
167 +-#ifdef CONFIG_OLD_MCOUNT
168 +-#define OLD_MCOUNT_ADDR ((unsigned long) mcount)
169 +-#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old)
170 +-
171 +-#define OLD_NOP 0xe1a00000 /* mov r0, r0 */
172 +
173 + static int __ftrace_modify_code(void *data)
174 + {
175 +@@ -51,6 +46,12 @@ void arch_ftrace_update_code(int command)
176 + stop_machine(__ftrace_modify_code, &command, NULL);
177 + }
178 +
179 ++#ifdef CONFIG_OLD_MCOUNT
180 ++#define OLD_MCOUNT_ADDR ((unsigned long) mcount)
181 ++#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old)
182 ++
183 ++#define OLD_NOP 0xe1a00000 /* mov r0, r0 */
184 ++
185 + static unsigned long ftrace_nop_replace(struct dyn_ftrace *rec)
186 + {
187 + return rec->arch.old_mcount ? OLD_NOP : NOP;
188 +diff --git a/arch/arm/mach-omap2/clockdomains7xx_data.c b/arch/arm/mach-omap2/clockdomains7xx_data.c
189 +index ef9ed36e8a61..e3416b40e82b 100644
190 +--- a/arch/arm/mach-omap2/clockdomains7xx_data.c
191 ++++ b/arch/arm/mach-omap2/clockdomains7xx_data.c
192 +@@ -524,7 +524,7 @@ static struct clockdomain pcie_7xx_clkdm = {
193 + .dep_bit = DRA7XX_PCIE_STATDEP_SHIFT,
194 + .wkdep_srcs = pcie_wkup_sleep_deps,
195 + .sleepdep_srcs = pcie_wkup_sleep_deps,
196 +- .flags = CLKDM_CAN_HWSUP_SWSUP,
197 ++ .flags = CLKDM_CAN_SWSUP,
198 + };
199 +
200 + static struct clockdomain atl_7xx_clkdm = {
201 +diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
202 +index 6ab0ae7d6535..d1d945c6bd05 100644
203 +--- a/arch/ia64/kernel/module.c
204 ++++ b/arch/ia64/kernel/module.c
205 +@@ -153,7 +153,7 @@ slot (const struct insn *insn)
206 + static int
207 + apply_imm64 (struct module *mod, struct insn *insn, uint64_t val)
208 + {
209 +- if (slot(insn) != 2) {
210 ++ if (slot(insn) != 1 && slot(insn) != 2) {
211 + printk(KERN_ERR "%s: invalid slot number %d for IMM64\n",
212 + mod->name, slot(insn));
213 + return 0;
214 +@@ -165,7 +165,7 @@ apply_imm64 (struct module *mod, struct insn *insn, uint64_t val)
215 + static int
216 + apply_imm60 (struct module *mod, struct insn *insn, uint64_t val)
217 + {
218 +- if (slot(insn) != 2) {
219 ++ if (slot(insn) != 1 && slot(insn) != 2) {
220 + printk(KERN_ERR "%s: invalid slot number %d for IMM60\n",
221 + mod->name, slot(insn));
222 + return 0;
223 +diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
224 +index ab68d0ee7725..4e54282c29b4 100644
225 +--- a/arch/powerpc/include/asm/cputable.h
226 ++++ b/arch/powerpc/include/asm/cputable.h
227 +@@ -474,7 +474,8 @@ enum {
228 + CPU_FTR_ICSWX | CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
229 + CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \
230 + CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP | CPU_FTR_ARCH_300)
231 +-#define CPU_FTRS_POWER9_DD1 (CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1)
232 ++#define CPU_FTRS_POWER9_DD1 ((CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1) & \
233 ++ (~CPU_FTR_SAO))
234 + #define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
235 + CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
236 + CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
237 +diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
238 +index a587e8f4fd26..4b4e927c4822 100644
239 +--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
240 ++++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
241 +@@ -177,12 +177,15 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
242 + ret = mmu_hash_ops.hpte_insert(hpteg, vpn, hpaddr, rflags, vflags,
243 + hpsize, hpsize, MMU_SEGSIZE_256M);
244 +
245 +- if (ret < 0) {
246 ++ if (ret == -1) {
247 + /* If we couldn't map a primary PTE, try a secondary */
248 + hash = ~hash;
249 + vflags ^= HPTE_V_SECONDARY;
250 + attempt++;
251 + goto map_again;
252 ++ } else if (ret < 0) {
253 ++ r = -EIO;
254 ++ goto out_unlock;
255 + } else {
256 + trace_kvm_book3s_64_mmu_map(rflags, hpteg,
257 + vpn, hpaddr, orig_pte);
258 +diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
259 +index 826c541a12af..e0d88d0890aa 100644
260 +--- a/arch/powerpc/kvm/book3s_pr.c
261 ++++ b/arch/powerpc/kvm/book3s_pr.c
262 +@@ -627,7 +627,11 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
263 + kvmppc_mmu_unmap_page(vcpu, &pte);
264 + }
265 + /* The guest's PTE is not mapped yet. Map on the host */
266 +- kvmppc_mmu_map_page(vcpu, &pte, iswrite);
267 ++ if (kvmppc_mmu_map_page(vcpu, &pte, iswrite) == -EIO) {
268 ++ /* Exit KVM if mapping failed */
269 ++ run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
270 ++ return RESUME_HOST;
271 ++ }
272 + if (data)
273 + vcpu->stat.sp_storage++;
274 + else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
275 +diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
276 +index 6de58f1bd7ec..eb5ff66b4d7a 100644
277 +--- a/arch/x86/boot/compressed/kaslr.c
278 ++++ b/arch/x86/boot/compressed/kaslr.c
279 +@@ -460,10 +460,17 @@ void choose_random_location(unsigned long input,
280 + add_identity_map(random_addr, output_size);
281 + *output = random_addr;
282 + }
283 ++
284 ++ /*
285 ++ * This loads the identity mapping page table.
286 ++ * This should only be done if a new physical address
287 ++ * is found for the kernel, otherwise we should keep
288 ++ * the old page table to make it be like the "nokaslr"
289 ++ * case.
290 ++ */
291 ++ finalize_identity_maps();
292 + }
293 +
294 +- /* This actually loads the identity pagetable on x86_64. */
295 +- finalize_identity_maps();
296 +
297 + /* Pick random virtual address starting from LOAD_PHYSICAL_ADDR. */
298 + if (IS_ENABLED(CONFIG_X86_64))
299 +diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
300 +index be22f5a2192e..4e3b8a587c88 100644
301 +--- a/arch/x86/kernel/i8259.c
302 ++++ b/arch/x86/kernel/i8259.c
303 +@@ -418,6 +418,7 @@ struct legacy_pic default_legacy_pic = {
304 + };
305 +
306 + struct legacy_pic *legacy_pic = &default_legacy_pic;
307 ++EXPORT_SYMBOL(legacy_pic);
308 +
309 + static int __init i8259A_init_ops(void)
310 + {
311 +diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
312 +index ca699677e288..ea217caa731c 100644
313 +--- a/arch/x86/kernel/smp.c
314 ++++ b/arch/x86/kernel/smp.c
315 +@@ -33,6 +33,7 @@
316 + #include <asm/mce.h>
317 + #include <asm/trace/irq_vectors.h>
318 + #include <asm/kexec.h>
319 ++#include <asm/virtext.h>
320 +
321 + /*
322 + * Some notes on x86 processor bugs affecting SMP operation:
323 +@@ -162,6 +163,7 @@ static int smp_stop_nmi_callback(unsigned int val, struct pt_regs *regs)
324 + if (raw_smp_processor_id() == atomic_read(&stopping_cpu))
325 + return NMI_HANDLED;
326 +
327 ++ cpu_emergency_vmxoff();
328 + stop_this_cpu(NULL);
329 +
330 + return NMI_HANDLED;
331 +@@ -174,6 +176,7 @@ static int smp_stop_nmi_callback(unsigned int val, struct pt_regs *regs)
332 + asmlinkage __visible void smp_reboot_interrupt(void)
333 + {
334 + ipi_entering_ack_irq();
335 ++ cpu_emergency_vmxoff();
336 + stop_this_cpu(NULL);
337 + irq_exit();
338 + }
339 +diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
340 +index 137afbbd0590..a11540e51f62 100644
341 +--- a/arch/x86/xen/smp.c
342 ++++ b/arch/x86/xen/smp.c
343 +@@ -299,35 +299,46 @@ static void __init xen_filter_cpu_maps(void)
344 +
345 + }
346 +
347 +-static void __init xen_smp_prepare_boot_cpu(void)
348 ++static void __init xen_pv_smp_prepare_boot_cpu(void)
349 + {
350 + BUG_ON(smp_processor_id() != 0);
351 + native_smp_prepare_boot_cpu();
352 +
353 +- if (xen_pv_domain()) {
354 +- if (!xen_feature(XENFEAT_writable_page_tables))
355 +- /* We've switched to the "real" per-cpu gdt, so make
356 +- * sure the old memory can be recycled. */
357 +- make_lowmem_page_readwrite(xen_initial_gdt);
358 ++ if (!xen_feature(XENFEAT_writable_page_tables))
359 ++ /* We've switched to the "real" per-cpu gdt, so make
360 ++ * sure the old memory can be recycled. */
361 ++ make_lowmem_page_readwrite(xen_initial_gdt);
362 +
363 + #ifdef CONFIG_X86_32
364 +- /*
365 +- * Xen starts us with XEN_FLAT_RING1_DS, but linux code
366 +- * expects __USER_DS
367 +- */
368 +- loadsegment(ds, __USER_DS);
369 +- loadsegment(es, __USER_DS);
370 ++ /*
371 ++ * Xen starts us with XEN_FLAT_RING1_DS, but linux code
372 ++ * expects __USER_DS
373 ++ */
374 ++ loadsegment(ds, __USER_DS);
375 ++ loadsegment(es, __USER_DS);
376 + #endif
377 +
378 +- xen_filter_cpu_maps();
379 +- xen_setup_vcpu_info_placement();
380 +- }
381 ++ xen_filter_cpu_maps();
382 ++ xen_setup_vcpu_info_placement();
383 ++
384 ++ /*
385 ++ * The alternative logic (which patches the unlock/lock) runs before
386 ++ * the smp bootup up code is activated. Hence we need to set this up
387 ++ * the core kernel is being patched. Otherwise we will have only
388 ++ * modules patched but not core code.
389 ++ */
390 ++ xen_init_spinlocks();
391 ++}
392 ++
393 ++static void __init xen_hvm_smp_prepare_boot_cpu(void)
394 ++{
395 ++ BUG_ON(smp_processor_id() != 0);
396 ++ native_smp_prepare_boot_cpu();
397 +
398 + /*
399 + * Setup vcpu_info for boot CPU.
400 + */
401 +- if (xen_hvm_domain())
402 +- xen_vcpu_setup(0);
403 ++ xen_vcpu_setup(0);
404 +
405 + /*
406 + * The alternative logic (which patches the unlock/lock) runs before
407 +@@ -733,7 +744,7 @@ static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id)
408 + }
409 +
410 + static const struct smp_ops xen_smp_ops __initconst = {
411 +- .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
412 ++ .smp_prepare_boot_cpu = xen_pv_smp_prepare_boot_cpu,
413 + .smp_prepare_cpus = xen_smp_prepare_cpus,
414 + .smp_cpus_done = xen_smp_cpus_done,
415 +
416 +@@ -772,5 +783,5 @@ void __init xen_hvm_smp_init(void)
417 + smp_ops.cpu_die = xen_cpu_die;
418 + smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
419 + smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
420 +- smp_ops.smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu;
421 ++ smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
422 + }
423 +diff --git a/block/blk-mq.c b/block/blk-mq.c
424 +index 10f8f94b7f20..c6572ffc1e87 100644
425 +--- a/block/blk-mq.c
426 ++++ b/block/blk-mq.c
427 +@@ -2014,15 +2014,15 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
428 +
429 + blk_mq_init_cpu_queues(q, set->nr_hw_queues);
430 +
431 +- get_online_cpus();
432 + mutex_lock(&all_q_mutex);
433 ++ get_online_cpus();
434 +
435 + list_add_tail(&q->all_q_node, &all_q_list);
436 + blk_mq_add_queue_tag_set(set, q);
437 + blk_mq_map_swqueue(q, cpu_online_mask);
438 +
439 +- mutex_unlock(&all_q_mutex);
440 + put_online_cpus();
441 ++ mutex_unlock(&all_q_mutex);
442 +
443 + return q;
444 +
445 +diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
446 +index e6e991ac20f3..0c6874e6a9b6 100644
447 +--- a/drivers/acpi/pmic/intel_pmic_xpower.c
448 ++++ b/drivers/acpi/pmic/intel_pmic_xpower.c
449 +@@ -28,97 +28,97 @@ static struct pmic_table power_table[] = {
450 + .address = 0x00,
451 + .reg = 0x13,
452 + .bit = 0x05,
453 +- },
454 ++ }, /* ALD1 */
455 + {
456 + .address = 0x04,
457 + .reg = 0x13,
458 + .bit = 0x06,
459 +- },
460 ++ }, /* ALD2 */
461 + {
462 + .address = 0x08,
463 + .reg = 0x13,
464 + .bit = 0x07,
465 +- },
466 ++ }, /* ALD3 */
467 + {
468 + .address = 0x0c,
469 + .reg = 0x12,
470 + .bit = 0x03,
471 +- },
472 ++ }, /* DLD1 */
473 + {
474 + .address = 0x10,
475 + .reg = 0x12,
476 + .bit = 0x04,
477 +- },
478 ++ }, /* DLD2 */
479 + {
480 + .address = 0x14,
481 + .reg = 0x12,
482 + .bit = 0x05,
483 +- },
484 ++ }, /* DLD3 */
485 + {
486 + .address = 0x18,
487 + .reg = 0x12,
488 + .bit = 0x06,
489 +- },
490 ++ }, /* DLD4 */
491 + {
492 + .address = 0x1c,
493 + .reg = 0x12,
494 + .bit = 0x00,
495 +- },
496 ++ }, /* ELD1 */
497 + {
498 + .address = 0x20,
499 + .reg = 0x12,
500 + .bit = 0x01,
501 +- },
502 ++ }, /* ELD2 */
503 + {
504 + .address = 0x24,
505 + .reg = 0x12,
506 + .bit = 0x02,
507 +- },
508 ++ }, /* ELD3 */
509 + {
510 + .address = 0x28,
511 + .reg = 0x13,
512 + .bit = 0x02,
513 +- },
514 ++ }, /* FLD1 */
515 + {
516 + .address = 0x2c,
517 + .reg = 0x13,
518 + .bit = 0x03,
519 +- },
520 ++ }, /* FLD2 */
521 + {
522 + .address = 0x30,
523 + .reg = 0x13,
524 + .bit = 0x04,
525 +- },
526 ++ }, /* FLD3 */
527 + {
528 +- .address = 0x38,
529 ++ .address = 0x34,
530 + .reg = 0x10,
531 + .bit = 0x03,
532 +- },
533 ++ }, /* BUC1 */
534 + {
535 +- .address = 0x3c,
536 ++ .address = 0x38,
537 + .reg = 0x10,
538 + .bit = 0x06,
539 +- },
540 ++ }, /* BUC2 */
541 + {
542 +- .address = 0x40,
543 ++ .address = 0x3c,
544 + .reg = 0x10,
545 + .bit = 0x05,
546 +- },
547 ++ }, /* BUC3 */
548 + {
549 +- .address = 0x44,
550 ++ .address = 0x40,
551 + .reg = 0x10,
552 + .bit = 0x04,
553 +- },
554 ++ }, /* BUC4 */
555 + {
556 +- .address = 0x48,
557 ++ .address = 0x44,
558 + .reg = 0x10,
559 + .bit = 0x01,
560 +- },
561 ++ }, /* BUC5 */
562 + {
563 +- .address = 0x4c,
564 ++ .address = 0x48,
565 + .reg = 0x10,
566 + .bit = 0x00
567 +- },
568 ++ }, /* BUC6 */
569 + };
570 +
571 + /* TMP0 - TMP5 are the same, all from GPADC */
572 +diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
573 +index 1c2b846c5776..3a6c9b741b23 100644
574 +--- a/drivers/acpi/power.c
575 ++++ b/drivers/acpi/power.c
576 +@@ -864,6 +864,16 @@ void acpi_resume_power_resources(void)
577 +
578 + mutex_unlock(&resource->resource_lock);
579 + }
580 ++
581 ++ mutex_unlock(&power_resource_list_lock);
582 ++}
583 ++
584 ++void acpi_turn_off_unused_power_resources(void)
585 ++{
586 ++ struct acpi_power_resource *resource;
587 ++
588 ++ mutex_lock(&power_resource_list_lock);
589 ++
590 + list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) {
591 + int result, state;
592 +
593 +diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
594 +index 9d5f0c7ed3f7..8697a82bd465 100644
595 +--- a/drivers/acpi/processor_driver.c
596 ++++ b/drivers/acpi/processor_driver.c
597 +@@ -251,6 +251,9 @@ static int __acpi_processor_start(struct acpi_device *device)
598 + if (ACPI_SUCCESS(status))
599 + return 0;
600 +
601 ++ result = -ENODEV;
602 ++ acpi_pss_perf_exit(pr, device);
603 ++
604 + err_power_exit:
605 + acpi_processor_power_exit(pr);
606 + return result;
607 +@@ -259,11 +262,16 @@ static int __acpi_processor_start(struct acpi_device *device)
608 + static int acpi_processor_start(struct device *dev)
609 + {
610 + struct acpi_device *device = ACPI_COMPANION(dev);
611 ++ int ret;
612 +
613 + if (!device)
614 + return -ENODEV;
615 +
616 +- return __acpi_processor_start(device);
617 ++ /* Protect against concurrent CPU hotplug operations */
618 ++ get_online_cpus();
619 ++ ret = __acpi_processor_start(device);
620 ++ put_online_cpus();
621 ++ return ret;
622 + }
623 +
624 + static int acpi_processor_stop(struct device *dev)
625 +diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
626 +index d51ca1c05619..207e9bbb9490 100644
627 +--- a/drivers/acpi/processor_throttling.c
628 ++++ b/drivers/acpi/processor_throttling.c
629 +@@ -62,8 +62,8 @@ struct acpi_processor_throttling_arg {
630 + #define THROTTLING_POSTCHANGE (2)
631 +
632 + static int acpi_processor_get_throttling(struct acpi_processor *pr);
633 +-int acpi_processor_set_throttling(struct acpi_processor *pr,
634 +- int state, bool force);
635 ++static int __acpi_processor_set_throttling(struct acpi_processor *pr,
636 ++ int state, bool force, bool direct);
637 +
638 + static int acpi_processor_update_tsd_coord(void)
639 + {
640 +@@ -891,7 +891,8 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
641 + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
642 + "Invalid throttling state, reset\n"));
643 + state = 0;
644 +- ret = acpi_processor_set_throttling(pr, state, true);
645 ++ ret = __acpi_processor_set_throttling(pr, state, true,
646 ++ true);
647 + if (ret)
648 + return ret;
649 + }
650 +@@ -901,36 +902,31 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
651 + return 0;
652 + }
653 +
654 +-static int acpi_processor_get_throttling(struct acpi_processor *pr)
655 ++static long __acpi_processor_get_throttling(void *data)
656 + {
657 +- cpumask_var_t saved_mask;
658 +- int ret;
659 ++ struct acpi_processor *pr = data;
660 ++
661 ++ return pr->throttling.acpi_processor_get_throttling(pr);
662 ++}
663 +
664 ++static int acpi_processor_get_throttling(struct acpi_processor *pr)
665 ++{
666 + if (!pr)
667 + return -EINVAL;
668 +
669 + if (!pr->flags.throttling)
670 + return -ENODEV;
671 +
672 +- if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
673 +- return -ENOMEM;
674 +-
675 + /*
676 +- * Migrate task to the cpu pointed by pr.
677 ++ * This is either called from the CPU hotplug callback of
678 ++ * processor_driver or via the ACPI probe function. In the latter
679 ++ * case the CPU is not guaranteed to be online. Both call sites are
680 ++ * protected against CPU hotplug.
681 + */
682 +- cpumask_copy(saved_mask, &current->cpus_allowed);
683 +- /* FIXME: use work_on_cpu() */
684 +- if (set_cpus_allowed_ptr(current, cpumask_of(pr->id))) {
685 +- /* Can't migrate to the target pr->id CPU. Exit */
686 +- free_cpumask_var(saved_mask);
687 ++ if (!cpu_online(pr->id))
688 + return -ENODEV;
689 +- }
690 +- ret = pr->throttling.acpi_processor_get_throttling(pr);
691 +- /* restore the previous state */
692 +- set_cpus_allowed_ptr(current, saved_mask);
693 +- free_cpumask_var(saved_mask);
694 +
695 +- return ret;
696 ++ return work_on_cpu(pr->id, __acpi_processor_get_throttling, pr);
697 + }
698 +
699 + static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
700 +@@ -1080,8 +1076,15 @@ static long acpi_processor_throttling_fn(void *data)
701 + arg->target_state, arg->force);
702 + }
703 +
704 +-int acpi_processor_set_throttling(struct acpi_processor *pr,
705 +- int state, bool force)
706 ++static int call_on_cpu(int cpu, long (*fn)(void *), void *arg, bool direct)
707 ++{
708 ++ if (direct)
709 ++ return fn(arg);
710 ++ return work_on_cpu(cpu, fn, arg);
711 ++}
712 ++
713 ++static int __acpi_processor_set_throttling(struct acpi_processor *pr,
714 ++ int state, bool force, bool direct)
715 + {
716 + int ret = 0;
717 + unsigned int i;
718 +@@ -1130,7 +1133,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
719 + arg.pr = pr;
720 + arg.target_state = state;
721 + arg.force = force;
722 +- ret = work_on_cpu(pr->id, acpi_processor_throttling_fn, &arg);
723 ++ ret = call_on_cpu(pr->id, acpi_processor_throttling_fn, &arg,
724 ++ direct);
725 + } else {
726 + /*
727 + * When the T-state coordination is SW_ALL or HW_ALL,
728 +@@ -1163,8 +1167,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
729 + arg.pr = match_pr;
730 + arg.target_state = state;
731 + arg.force = force;
732 +- ret = work_on_cpu(pr->id, acpi_processor_throttling_fn,
733 +- &arg);
734 ++ ret = call_on_cpu(pr->id, acpi_processor_throttling_fn,
735 ++ &arg, direct);
736 + }
737 + }
738 + /*
739 +@@ -1182,6 +1186,12 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
740 + return ret;
741 + }
742 +
743 ++int acpi_processor_set_throttling(struct acpi_processor *pr, int state,
744 ++ bool force)
745 ++{
746 ++ return __acpi_processor_set_throttling(pr, state, force, false);
747 ++}
748 ++
749 + int acpi_processor_get_throttling_info(struct acpi_processor *pr)
750 + {
751 + int result = 0;
752 +diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
753 +index a4327af676fe..097d630ab886 100644
754 +--- a/drivers/acpi/sleep.c
755 ++++ b/drivers/acpi/sleep.c
756 +@@ -474,6 +474,7 @@ static void acpi_pm_start(u32 acpi_state)
757 + */
758 + static void acpi_pm_end(void)
759 + {
760 ++ acpi_turn_off_unused_power_resources();
761 + acpi_scan_lock_release();
762 + /*
763 + * This is necessary in case acpi_pm_finish() is not called during a
764 +diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
765 +index a9cc34e663f9..a82ff74faf7a 100644
766 +--- a/drivers/acpi/sleep.h
767 ++++ b/drivers/acpi/sleep.h
768 +@@ -6,6 +6,7 @@ extern struct list_head acpi_wakeup_device_list;
769 + extern struct mutex acpi_device_lock;
770 +
771 + extern void acpi_resume_power_resources(void);
772 ++extern void acpi_turn_off_unused_power_resources(void);
773 +
774 + static inline acpi_status acpi_set_waking_vector(u32 wakeup_address)
775 + {
776 +diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
777 +index 3cfd879267b2..b86273fdf48e 100644
778 +--- a/drivers/block/mtip32xx/mtip32xx.c
779 ++++ b/drivers/block/mtip32xx/mtip32xx.c
780 +@@ -169,6 +169,25 @@ static bool mtip_check_surprise_removal(struct pci_dev *pdev)
781 + return false; /* device present */
782 + }
783 +
784 ++/* we have to use runtime tag to setup command header */
785 ++static void mtip_init_cmd_header(struct request *rq)
786 ++{
787 ++ struct driver_data *dd = rq->q->queuedata;
788 ++ struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
789 ++ u32 host_cap_64 = readl(dd->mmio + HOST_CAP) & HOST_CAP_64;
790 ++
791 ++ /* Point the command headers at the command tables. */
792 ++ cmd->command_header = dd->port->command_list +
793 ++ (sizeof(struct mtip_cmd_hdr) * rq->tag);
794 ++ cmd->command_header_dma = dd->port->command_list_dma +
795 ++ (sizeof(struct mtip_cmd_hdr) * rq->tag);
796 ++
797 ++ if (host_cap_64)
798 ++ cmd->command_header->ctbau = __force_bit2int cpu_to_le32((cmd->command_dma >> 16) >> 16);
799 ++
800 ++ cmd->command_header->ctba = __force_bit2int cpu_to_le32(cmd->command_dma & 0xFFFFFFFF);
801 ++}
802 ++
803 + static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd)
804 + {
805 + struct request *rq;
806 +@@ -180,6 +199,9 @@ static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd)
807 + if (IS_ERR(rq))
808 + return NULL;
809 +
810 ++ /* Internal cmd isn't submitted via .queue_rq */
811 ++ mtip_init_cmd_header(rq);
812 ++
813 + return blk_mq_rq_to_pdu(rq);
814 + }
815 +
816 +@@ -3811,6 +3833,8 @@ static int mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
817 + struct request *rq = bd->rq;
818 + int ret;
819 +
820 ++ mtip_init_cmd_header(rq);
821 ++
822 + if (unlikely(mtip_check_unal_depth(hctx, rq)))
823 + return BLK_MQ_RQ_QUEUE_BUSY;
824 +
825 +@@ -3842,7 +3866,6 @@ static int mtip_init_cmd(void *data, struct request *rq, unsigned int hctx_idx,
826 + {
827 + struct driver_data *dd = data;
828 + struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
829 +- u32 host_cap_64 = readl(dd->mmio + HOST_CAP) & HOST_CAP_64;
830 +
831 + /*
832 + * For flush requests, request_idx starts at the end of the
833 +@@ -3859,17 +3882,6 @@ static int mtip_init_cmd(void *data, struct request *rq, unsigned int hctx_idx,
834 +
835 + memset(cmd->command, 0, CMD_DMA_ALLOC_SZ);
836 +
837 +- /* Point the command headers at the command tables. */
838 +- cmd->command_header = dd->port->command_list +
839 +- (sizeof(struct mtip_cmd_hdr) * request_idx);
840 +- cmd->command_header_dma = dd->port->command_list_dma +
841 +- (sizeof(struct mtip_cmd_hdr) * request_idx);
842 +-
843 +- if (host_cap_64)
844 +- cmd->command_header->ctbau = __force_bit2int cpu_to_le32((cmd->command_dma >> 16) >> 16);
845 +-
846 +- cmd->command_header->ctba = __force_bit2int cpu_to_le32(cmd->command_dma & 0xFFFFFFFF);
847 +-
848 + sg_init_table(cmd->sg, MTIP_MAX_SG);
849 + return 0;
850 + }
851 +diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
852 +index 08c2c93887c1..3aac78a5091b 100644
853 +--- a/drivers/bluetooth/btqcomsmd.c
854 ++++ b/drivers/bluetooth/btqcomsmd.c
855 +@@ -85,7 +85,8 @@ static int btqcomsmd_send(struct hci_dev *hdev, struct sk_buff *skb)
856 + break;
857 + }
858 +
859 +- kfree_skb(skb);
860 ++ if (!ret)
861 ++ kfree_skb(skb);
862 +
863 + return ret;
864 + }
865 +diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
866 +index 9497c469efd2..2230f9368c21 100644
867 +--- a/drivers/bluetooth/hci_ldisc.c
868 ++++ b/drivers/bluetooth/hci_ldisc.c
869 +@@ -113,16 +113,21 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
870 + {
871 + struct sk_buff *skb = hu->tx_skb;
872 +
873 +- if (!skb)
874 +- skb = hu->proto->dequeue(hu);
875 +- else
876 ++ if (!skb) {
877 ++ if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
878 ++ skb = hu->proto->dequeue(hu);
879 ++ } else {
880 + hu->tx_skb = NULL;
881 ++ }
882 +
883 + return skb;
884 + }
885 +
886 + int hci_uart_tx_wakeup(struct hci_uart *hu)
887 + {
888 ++ if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
889 ++ return 0;
890 ++
891 + if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
892 + set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
893 + return 0;
894 +diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
895 +index 6c867fbc56a7..74b2f4a14643 100644
896 +--- a/drivers/bluetooth/hci_qca.c
897 ++++ b/drivers/bluetooth/hci_qca.c
898 +@@ -936,6 +936,9 @@ static int qca_setup(struct hci_uart *hu)
899 + if (!ret) {
900 + set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
901 + qca_debugfs_init(hdev);
902 ++ } else if (ret == -ENOENT) {
903 ++ /* No patch/nvm-config found, run with original fw/config */
904 ++ ret = 0;
905 + }
906 +
907 + /* Setup bdaddr */
908 +diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
909 +index 909311016108..055d2ce378a7 100644
910 +--- a/drivers/char/ipmi/ipmi_watchdog.c
911 ++++ b/drivers/char/ipmi/ipmi_watchdog.c
912 +@@ -515,7 +515,7 @@ static void panic_halt_ipmi_heartbeat(void)
913 + msg.cmd = IPMI_WDOG_RESET_TIMER;
914 + msg.data = NULL;
915 + msg.data_len = 0;
916 +- atomic_add(2, &panic_done_count);
917 ++ atomic_add(1, &panic_done_count);
918 + rv = ipmi_request_supply_msgs(watchdog_user,
919 + (struct ipmi_addr *) &addr,
920 + 0,
921 +@@ -525,7 +525,7 @@ static void panic_halt_ipmi_heartbeat(void)
922 + &panic_halt_heartbeat_recv_msg,
923 + 1);
924 + if (rv)
925 +- atomic_sub(2, &panic_done_count);
926 ++ atomic_sub(1, &panic_done_count);
927 + }
928 +
929 + static struct ipmi_smi_msg panic_halt_smi_msg = {
930 +@@ -549,12 +549,12 @@ static void panic_halt_ipmi_set_timeout(void)
931 + /* Wait for the messages to be free. */
932 + while (atomic_read(&panic_done_count) != 0)
933 + ipmi_poll_interface(watchdog_user);
934 +- atomic_add(2, &panic_done_count);
935 ++ atomic_add(1, &panic_done_count);
936 + rv = i_ipmi_set_timeout(&panic_halt_smi_msg,
937 + &panic_halt_recv_msg,
938 + &send_heartbeat_now);
939 + if (rv) {
940 +- atomic_sub(2, &panic_done_count);
941 ++ atomic_sub(1, &panic_done_count);
942 + printk(KERN_WARNING PFX
943 + "Unable to extend the watchdog timeout.");
944 + } else {
945 +diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
946 +index d0ac2d56520f..830d7e30e508 100644
947 +--- a/drivers/char/tpm/tpm-interface.c
948 ++++ b/drivers/char/tpm/tpm-interface.c
949 +@@ -1078,6 +1078,11 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
950 + break;
951 +
952 + recd = be32_to_cpu(tpm_cmd.params.getrandom_out.rng_data_len);
953 ++ if (recd > num_bytes) {
954 ++ total = -EFAULT;
955 ++ break;
956 ++ }
957 ++
958 + memcpy(dest, tpm_cmd.params.getrandom_out.rng_data, recd);
959 +
960 + dest += recd;
961 +diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
962 +index 17896d654033..a5780ebe15ef 100644
963 +--- a/drivers/char/tpm/tpm2-cmd.c
964 ++++ b/drivers/char/tpm/tpm2-cmd.c
965 +@@ -668,6 +668,11 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip,
966 + if (!rc) {
967 + data_len = be16_to_cpup(
968 + (__be16 *) &buf.data[TPM_HEADER_SIZE + 4]);
969 ++ if (data_len < MIN_KEY_SIZE || data_len > MAX_KEY_SIZE + 1) {
970 ++ rc = -EFAULT;
971 ++ goto out;
972 ++ }
973 ++
974 + data = &buf.data[TPM_HEADER_SIZE + 6];
975 +
976 + memcpy(payload->key, data, data_len - 1);
977 +@@ -675,6 +680,7 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip,
978 + payload->migratable = data[data_len - 1];
979 + }
980 +
981 ++out:
982 + tpm_buf_destroy(&buf);
983 + return rc;
984 + }
985 +diff --git a/drivers/clk/bcm/clk-ns2.c b/drivers/clk/bcm/clk-ns2.c
986 +index a564e9248814..adc14145861a 100644
987 +--- a/drivers/clk/bcm/clk-ns2.c
988 ++++ b/drivers/clk/bcm/clk-ns2.c
989 +@@ -103,7 +103,7 @@ CLK_OF_DECLARE(ns2_genpll_src_clk, "brcm,ns2-genpll-scr",
990 +
991 + static const struct iproc_pll_ctrl genpll_sw = {
992 + .flags = IPROC_CLK_AON | IPROC_CLK_PLL_SPLIT_STAT_CTRL,
993 +- .aon = AON_VAL(0x0, 2, 9, 8),
994 ++ .aon = AON_VAL(0x0, 1, 11, 10),
995 + .reset = RESET_VAL(0x4, 2, 1),
996 + .dig_filter = DF_VAL(0x0, 9, 3, 5, 4, 2, 3),
997 + .ndiv_int = REG_VAL(0x8, 4, 10),
998 +diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
999 +index 5e918e7afaba..95a6e9834392 100644
1000 +--- a/drivers/clk/clk-axi-clkgen.c
1001 ++++ b/drivers/clk/clk-axi-clkgen.c
1002 +@@ -40,6 +40,10 @@
1003 + #define MMCM_REG_FILTER1 0x4e
1004 + #define MMCM_REG_FILTER2 0x4f
1005 +
1006 ++#define MMCM_CLKOUT_NOCOUNT BIT(6)
1007 ++
1008 ++#define MMCM_CLK_DIV_NOCOUNT BIT(12)
1009 ++
1010 + struct axi_clkgen {
1011 + void __iomem *base;
1012 + struct clk_hw clk_hw;
1013 +@@ -315,12 +319,27 @@ static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
1014 + unsigned int reg;
1015 + unsigned long long tmp;
1016 +
1017 +- axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
1018 +- dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1019 ++ axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_2, &reg);
1020 ++ if (reg & MMCM_CLKOUT_NOCOUNT) {
1021 ++ dout = 1;
1022 ++ } else {
1023 ++ axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
1024 ++ dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1025 ++ }
1026 ++
1027 + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_DIV, &reg);
1028 +- d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1029 +- axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
1030 +- m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1031 ++ if (reg & MMCM_CLK_DIV_NOCOUNT)
1032 ++ d = 1;
1033 ++ else
1034 ++ d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1035 ++
1036 ++ axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB2, &reg);
1037 ++ if (reg & MMCM_CLKOUT_NOCOUNT) {
1038 ++ m = 1;
1039 ++ } else {
1040 ++ axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
1041 ++ m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
1042 ++ }
1043 +
1044 + if (d == 0 || dout == 0)
1045 + return 0;
1046 +diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c
1047 +index b051db43fae1..136a86094c53 100644
1048 +--- a/drivers/clk/clk-si5351.c
1049 ++++ b/drivers/clk/clk-si5351.c
1050 +@@ -72,7 +72,7 @@ static const char * const si5351_input_names[] = {
1051 + "xtal", "clkin"
1052 + };
1053 + static const char * const si5351_pll_names[] = {
1054 +- "plla", "pllb", "vxco"
1055 ++ "si5351_plla", "si5351_pllb", "si5351_vxco"
1056 + };
1057 + static const char * const si5351_msynth_names[] = {
1058 + "ms0", "ms1", "ms2", "ms3", "ms4", "ms5", "ms6", "ms7"
1059 +diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
1060 +index 0fb39fe217d1..0cdb8550729d 100644
1061 +--- a/drivers/clk/clk.c
1062 ++++ b/drivers/clk/clk.c
1063 +@@ -2437,6 +2437,21 @@ static int __clk_core_init(struct clk_core *core)
1064 + rate = 0;
1065 + core->rate = core->req_rate = rate;
1066 +
1067 ++ /*
1068 ++ * Enable CLK_IS_CRITICAL clocks so newly added critical clocks
1069 ++ * don't get accidentally disabled when walking the orphan tree and
1070 ++ * reparenting clocks
1071 ++ */
1072 ++ if (core->flags & CLK_IS_CRITICAL) {
1073 ++ unsigned long flags;
1074 ++
1075 ++ clk_core_prepare(core);
1076 ++
1077 ++ flags = clk_enable_lock();
1078 ++ clk_core_enable(core);
1079 ++ clk_enable_unlock(flags);
1080 ++ }
1081 ++
1082 + /*
1083 + * walk the list of orphan clocks and reparent any that newly finds a
1084 + * parent.
1085 +@@ -2445,10 +2460,13 @@ static int __clk_core_init(struct clk_core *core)
1086 + struct clk_core *parent = __clk_init_parent(orphan);
1087 +
1088 + /*
1089 +- * we could call __clk_set_parent, but that would result in a
1090 +- * redundant call to the .set_rate op, if it exists
1091 ++ * We need to use __clk_set_parent_before() and _after() to
1092 ++ * to properly migrate any prepare/enable count of the orphan
1093 ++ * clock. This is important for CLK_IS_CRITICAL clocks, which
1094 ++ * are enabled during init but might not have a parent yet.
1095 + */
1096 + if (parent) {
1097 ++ /* update the clk tree topology */
1098 + __clk_set_parent_before(orphan, parent);
1099 + __clk_set_parent_after(orphan, parent, NULL);
1100 + __clk_recalc_accuracies(orphan);
1101 +@@ -2467,16 +2485,6 @@ static int __clk_core_init(struct clk_core *core)
1102 + if (core->ops->init)
1103 + core->ops->init(core->hw);
1104 +
1105 +- if (core->flags & CLK_IS_CRITICAL) {
1106 +- unsigned long flags;
1107 +-
1108 +- clk_core_prepare(core);
1109 +-
1110 +- flags = clk_enable_lock();
1111 +- clk_core_enable(core);
1112 +- clk_enable_unlock(flags);
1113 +- }
1114 +-
1115 + kref_init(&core->ref);
1116 + out:
1117 + clk_prepare_unlock();
1118 +diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
1119 +index 86628e22b2a3..719c3d9f07fb 100644
1120 +--- a/drivers/cpufreq/sh-cpufreq.c
1121 ++++ b/drivers/cpufreq/sh-cpufreq.c
1122 +@@ -30,54 +30,63 @@
1123 +
1124 + static DEFINE_PER_CPU(struct clk, sh_cpuclk);
1125 +
1126 ++struct cpufreq_target {
1127 ++ struct cpufreq_policy *policy;
1128 ++ unsigned int freq;
1129 ++};
1130 ++
1131 + static unsigned int sh_cpufreq_get(unsigned int cpu)
1132 + {
1133 + return (clk_get_rate(&per_cpu(sh_cpuclk, cpu)) + 500) / 1000;
1134 + }
1135 +
1136 +-/*
1137 +- * Here we notify other drivers of the proposed change and the final change.
1138 +- */
1139 +-static int sh_cpufreq_target(struct cpufreq_policy *policy,
1140 +- unsigned int target_freq,
1141 +- unsigned int relation)
1142 ++static long __sh_cpufreq_target(void *arg)
1143 + {
1144 +- unsigned int cpu = policy->cpu;
1145 ++ struct cpufreq_target *target = arg;
1146 ++ struct cpufreq_policy *policy = target->policy;
1147 ++ int cpu = policy->cpu;
1148 + struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu);
1149 +- cpumask_t cpus_allowed;
1150 + struct cpufreq_freqs freqs;
1151 + struct device *dev;
1152 + long freq;
1153 +
1154 +- cpus_allowed = current->cpus_allowed;
1155 +- set_cpus_allowed_ptr(current, cpumask_of(cpu));
1156 +-
1157 +- BUG_ON(smp_processor_id() != cpu);
1158 ++ if (smp_processor_id() != cpu)
1159 ++ return -ENODEV;
1160 +
1161 + dev = get_cpu_device(cpu);
1162 +
1163 + /* Convert target_freq from kHz to Hz */
1164 +- freq = clk_round_rate(cpuclk, target_freq * 1000);
1165 ++ freq = clk_round_rate(cpuclk, target->freq * 1000);
1166 +
1167 + if (freq < (policy->min * 1000) || freq > (policy->max * 1000))
1168 + return -EINVAL;
1169 +
1170 +- dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000);
1171 ++ dev_dbg(dev, "requested frequency %u Hz\n", target->freq * 1000);
1172 +
1173 + freqs.old = sh_cpufreq_get(cpu);
1174 + freqs.new = (freq + 500) / 1000;
1175 + freqs.flags = 0;
1176 +
1177 +- cpufreq_freq_transition_begin(policy, &freqs);
1178 +- set_cpus_allowed_ptr(current, &cpus_allowed);
1179 ++ cpufreq_freq_transition_begin(target->policy, &freqs);
1180 + clk_set_rate(cpuclk, freq);
1181 +- cpufreq_freq_transition_end(policy, &freqs, 0);
1182 ++ cpufreq_freq_transition_end(target->policy, &freqs, 0);
1183 +
1184 + dev_dbg(dev, "set frequency %lu Hz\n", freq);
1185 +-
1186 + return 0;
1187 + }
1188 +
1189 ++/*
1190 ++ * Here we notify other drivers of the proposed change and the final change.
1191 ++ */
1192 ++static int sh_cpufreq_target(struct cpufreq_policy *policy,
1193 ++ unsigned int target_freq,
1194 ++ unsigned int relation)
1195 ++{
1196 ++ struct cpufreq_target data = { .policy = policy, .freq = target_freq };
1197 ++
1198 ++ return work_on_cpu(policy->cpu, __sh_cpufreq_target, &data);
1199 ++}
1200 ++
1201 + static int sh_cpufreq_verify(struct cpufreq_policy *policy)
1202 + {
1203 + struct clk *cpuclk = &per_cpu(sh_cpuclk, policy->cpu);
1204 +diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
1205 +index 43e88d85129e..8c3c588834d2 100644
1206 +--- a/drivers/dma/ti-dma-crossbar.c
1207 ++++ b/drivers/dma/ti-dma-crossbar.c
1208 +@@ -54,7 +54,15 @@ struct ti_am335x_xbar_map {
1209 +
1210 + static inline void ti_am335x_xbar_write(void __iomem *iomem, int event, u8 val)
1211 + {
1212 +- writeb_relaxed(val, iomem + event);
1213 ++ /*
1214 ++ * TPCC_EVT_MUX_60_63 register layout is different than the
1215 ++ * rest, in the sense, that event 63 is mapped to lowest byte
1216 ++ * and event 60 is mapped to highest, handle it separately.
1217 ++ */
1218 ++ if (event >= 60 && event <= 63)
1219 ++ writeb_relaxed(val, iomem + (63 - event % 4));
1220 ++ else
1221 ++ writeb_relaxed(val, iomem + event);
1222 + }
1223 +
1224 + static void ti_am335x_xbar_free(struct device *dev, void *route_data)
1225 +diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
1226 +index 6d221e5c72ee..22658057fe27 100644
1227 +--- a/drivers/dma/xilinx/zynqmp_dma.c
1228 ++++ b/drivers/dma/xilinx/zynqmp_dma.c
1229 +@@ -933,7 +933,8 @@ static void zynqmp_dma_chan_remove(struct zynqmp_dma_chan *chan)
1230 + if (!chan)
1231 + return;
1232 +
1233 +- devm_free_irq(chan->zdev->dev, chan->irq, chan);
1234 ++ if (chan->irq)
1235 ++ devm_free_irq(chan->zdev->dev, chan->irq, chan);
1236 + tasklet_kill(&chan->tasklet);
1237 + list_del(&chan->common.device_node);
1238 + clk_disable_unprepare(chan->clk_apb);
1239 +diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
1240 +index d0ddba7a9d08..5ef4980f3f14 100644
1241 +--- a/drivers/gpio/gpio-wcove.c
1242 ++++ b/drivers/gpio/gpio-wcove.c
1243 +@@ -51,6 +51,8 @@
1244 + #define GROUP1_NR_IRQS 6
1245 + #define IRQ_MASK_BASE 0x4e19
1246 + #define IRQ_STATUS_BASE 0x4e0b
1247 ++#define GPIO_IRQ0_MASK GENMASK(6, 0)
1248 ++#define GPIO_IRQ1_MASK GENMASK(5, 0)
1249 + #define UPDATE_IRQ_TYPE BIT(0)
1250 + #define UPDATE_IRQ_MASK BIT(1)
1251 +
1252 +@@ -310,7 +312,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data)
1253 + return IRQ_NONE;
1254 + }
1255 +
1256 +- pending = p[0] | (p[1] << 8);
1257 ++ pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7);
1258 + if (!pending)
1259 + return IRQ_NONE;
1260 +
1261 +@@ -318,7 +320,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data)
1262 + while (pending) {
1263 + /* One iteration is for all pending bits */
1264 + for_each_set_bit(gpio, (const unsigned long *)&pending,
1265 +- GROUP0_NR_IRQS) {
1266 ++ WCOVE_GPIO_NUM) {
1267 + offset = (gpio > GROUP0_NR_IRQS) ? 1 : 0;
1268 + mask = (offset == 1) ? BIT(gpio - GROUP0_NR_IRQS) :
1269 + BIT(gpio);
1270 +@@ -334,7 +336,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data)
1271 + break;
1272 + }
1273 +
1274 +- pending = p[0] | (p[1] << 8);
1275 ++ pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7);
1276 + }
1277 +
1278 + return IRQ_HANDLED;
1279 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
1280 +index 50f18f666d67..d0c3e56ece74 100644
1281 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
1282 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
1283 +@@ -2237,7 +2237,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
1284 + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
1285 + struct amdgpu_ring *ring = adev->rings[i];
1286 +
1287 +- if (!ring)
1288 ++ if (!ring || !ring->sched.thread)
1289 + continue;
1290 + kthread_park(ring->sched.thread);
1291 + amd_sched_hw_job_reset(&ring->sched);
1292 +@@ -2326,7 +2326,8 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
1293 + }
1294 + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
1295 + struct amdgpu_ring *ring = adev->rings[i];
1296 +- if (!ring)
1297 ++
1298 ++ if (!ring || !ring->sched.thread)
1299 + continue;
1300 +
1301 + amd_sched_job_recovery(&ring->sched);
1302 +@@ -2335,7 +2336,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
1303 + } else {
1304 + dev_err(adev->dev, "asic resume failed (%d).\n", r);
1305 + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
1306 +- if (adev->rings[i]) {
1307 ++ if (adev->rings[i] && adev->rings[i]->sched.thread) {
1308 + kthread_unpark(adev->rings[i]->sched.thread);
1309 + }
1310 + }
1311 +diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
1312 +index b6ac27e31929..797d1f8340b9 100644
1313 +--- a/drivers/gpu/drm/msm/msm_gem.c
1314 ++++ b/drivers/gpu/drm/msm/msm_gem.c
1315 +@@ -91,14 +91,17 @@ static struct page **get_pages(struct drm_gem_object *obj)
1316 + return p;
1317 + }
1318 +
1319 ++ msm_obj->pages = p;
1320 ++
1321 + msm_obj->sgt = drm_prime_pages_to_sg(p, npages);
1322 + if (IS_ERR(msm_obj->sgt)) {
1323 ++ void *ptr = ERR_CAST(msm_obj->sgt);
1324 ++
1325 + dev_err(dev->dev, "failed to allocate sgt\n");
1326 +- return ERR_CAST(msm_obj->sgt);
1327 ++ msm_obj->sgt = NULL;
1328 ++ return ptr;
1329 + }
1330 +
1331 +- msm_obj->pages = p;
1332 +-
1333 + /* For non-cached buffers, ensure the new pages are clean
1334 + * because display controller, GPU, etc. are not coherent:
1335 + */
1336 +@@ -121,7 +124,10 @@ static void put_pages(struct drm_gem_object *obj)
1337 + if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED))
1338 + dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl,
1339 + msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
1340 +- sg_free_table(msm_obj->sgt);
1341 ++
1342 ++ if (msm_obj->sgt)
1343 ++ sg_free_table(msm_obj->sgt);
1344 ++
1345 + kfree(msm_obj->sgt);
1346 +
1347 + if (use_pages(obj))
1348 +diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
1349 +index 2c2b86d68129..6526a3366087 100644
1350 +--- a/drivers/gpu/drm/nouveau/nouveau_display.c
1351 ++++ b/drivers/gpu/drm/nouveau/nouveau_display.c
1352 +@@ -106,7 +106,7 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
1353 + };
1354 + struct nouveau_display *disp = nouveau_display(crtc->dev);
1355 + struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
1356 +- int ret, retry = 1;
1357 ++ int ret, retry = 20;
1358 +
1359 + do {
1360 + ret = nvif_mthd(&disp->disp, 0, &args, sizeof(args));
1361 +diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
1362 +index e859b3f893f7..6112c32b994f 100644
1363 +--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
1364 ++++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
1365 +@@ -456,6 +456,8 @@ static int td028ttec1_panel_remove(struct spi_device *spi)
1366 + }
1367 +
1368 + static const struct of_device_id td028ttec1_of_match[] = {
1369 ++ { .compatible = "omapdss,tpo,td028ttec1", },
1370 ++ /* keep to not break older DTB */
1371 + { .compatible = "omapdss,toppoly,td028ttec1", },
1372 + {},
1373 + };
1374 +@@ -475,6 +477,7 @@ static struct spi_driver td028ttec1_spi_driver = {
1375 +
1376 + module_spi_driver(td028ttec1_spi_driver);
1377 +
1378 ++MODULE_ALIAS("spi:tpo,td028ttec1");
1379 + MODULE_ALIAS("spi:toppoly,td028ttec1");
1380 + MODULE_AUTHOR("H. Nikolaus Schaller <hns@×××××××××.com>");
1381 + MODULE_DESCRIPTION("Toppoly TD028TTEC1 panel driver");
1382 +diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
1383 +index 4b83e9eeab06..7def04049498 100644
1384 +--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
1385 ++++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
1386 +@@ -298,7 +298,12 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
1387 + msecs_to_jiffies(100))) {
1388 + dev_err(dmm->dev, "timed out waiting for done\n");
1389 + ret = -ETIMEDOUT;
1390 ++ goto cleanup;
1391 + }
1392 ++
1393 ++ /* Check the engine status before continue */
1394 ++ ret = wait_status(engine, DMM_PATSTATUS_READY |
1395 ++ DMM_PATSTATUS_VALID | DMM_PATSTATUS_DONE);
1396 + }
1397 +
1398 + cleanup:
1399 +diff --git a/drivers/gpu/drm/tilcdc/tilcdc_regs.h b/drivers/gpu/drm/tilcdc/tilcdc_regs.h
1400 +index f57c0d62c76a..19d8dc3cdd40 100644
1401 +--- a/drivers/gpu/drm/tilcdc/tilcdc_regs.h
1402 ++++ b/drivers/gpu/drm/tilcdc/tilcdc_regs.h
1403 +@@ -124,7 +124,7 @@ static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
1404 + struct tilcdc_drm_private *priv = dev->dev_private;
1405 + volatile void __iomem *addr = priv->mmio + reg;
1406 +
1407 +-#ifdef iowrite64
1408 ++#if defined(iowrite64) && !defined(iowrite64_is_nonatomic)
1409 + iowrite64(data, addr);
1410 + #else
1411 + __iowmb();
1412 +diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
1413 +index 6031cd146556..802afc98e8bd 100644
1414 +--- a/drivers/hsi/clients/ssi_protocol.c
1415 ++++ b/drivers/hsi/clients/ssi_protocol.c
1416 +@@ -989,7 +989,7 @@ static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev)
1417 + goto drop;
1418 + /* Pad to 32-bits - FIXME: Revisit*/
1419 + if ((skb->len & 3) && skb_pad(skb, 4 - (skb->len & 3)))
1420 +- goto drop;
1421 ++ goto inc_dropped;
1422 +
1423 + /*
1424 + * Modem sends Phonet messages over SSI with its own endianess...
1425 +@@ -1041,8 +1041,9 @@ static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev)
1426 + drop2:
1427 + hsi_free_msg(msg);
1428 + drop:
1429 +- dev->stats.tx_dropped++;
1430 + dev_kfree_skb(skb);
1431 ++inc_dropped:
1432 ++ dev->stats.tx_dropped++;
1433 +
1434 + return 0;
1435 + }
1436 +diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
1437 +index 0673baf0f2f5..ff579a7c6d00 100644
1438 +--- a/drivers/hwtracing/coresight/coresight-tpiu.c
1439 ++++ b/drivers/hwtracing/coresight/coresight-tpiu.c
1440 +@@ -46,8 +46,11 @@
1441 + #define TPIU_ITATBCTR0 0xef8
1442 +
1443 + /** register definition **/
1444 ++/* FFSR - 0x300 */
1445 ++#define FFSR_FT_STOPPED BIT(1)
1446 + /* FFCR - 0x304 */
1447 + #define FFCR_FON_MAN BIT(6)
1448 ++#define FFCR_STOP_FI BIT(12)
1449 +
1450 + /**
1451 + * @base: memory mapped base address for this component.
1452 +@@ -85,10 +88,14 @@ static void tpiu_disable_hw(struct tpiu_drvdata *drvdata)
1453 + {
1454 + CS_UNLOCK(drvdata->base);
1455 +
1456 +- /* Clear formatter controle reg. */
1457 +- writel_relaxed(0x0, drvdata->base + TPIU_FFCR);
1458 ++ /* Clear formatter and stop on flush */
1459 ++ writel_relaxed(FFCR_STOP_FI, drvdata->base + TPIU_FFCR);
1460 + /* Generate manual flush */
1461 +- writel_relaxed(FFCR_FON_MAN, drvdata->base + TPIU_FFCR);
1462 ++ writel_relaxed(FFCR_STOP_FI | FFCR_FON_MAN, drvdata->base + TPIU_FFCR);
1463 ++ /* Wait for flush to complete */
1464 ++ coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN, 0);
1465 ++ /* Wait for formatter to stop */
1466 ++ coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED, 1);
1467 +
1468 + CS_LOCK(drvdata->base);
1469 + }
1470 +diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
1471 +index dfc98df7b1b6..7aa7b9cb6203 100644
1472 +--- a/drivers/i2c/busses/i2c-scmi.c
1473 ++++ b/drivers/i2c/busses/i2c-scmi.c
1474 +@@ -18,6 +18,9 @@
1475 + #define ACPI_SMBUS_HC_CLASS "smbus"
1476 + #define ACPI_SMBUS_HC_DEVICE_NAME "cmi"
1477 +
1478 ++/* SMBUS HID definition as supported by Microsoft Windows */
1479 ++#define ACPI_SMBUS_MS_HID "SMB0001"
1480 ++
1481 + ACPI_MODULE_NAME("smbus_cmi");
1482 +
1483 + struct smbus_methods_t {
1484 +@@ -51,6 +54,7 @@ static const struct smbus_methods_t ibm_smbus_methods = {
1485 + static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
1486 + {"SMBUS01", (kernel_ulong_t)&smbus_methods},
1487 + {ACPI_SMBUS_IBM_HID, (kernel_ulong_t)&ibm_smbus_methods},
1488 ++ {ACPI_SMBUS_MS_HID, (kernel_ulong_t)&smbus_methods},
1489 + {"", 0}
1490 + };
1491 + MODULE_DEVICE_TABLE(acpi, acpi_smbus_cmi_ids);
1492 +diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
1493 +index 3a557e3181ea..fe94415a0bc7 100644
1494 +--- a/drivers/iio/accel/st_accel_core.c
1495 ++++ b/drivers/iio/accel/st_accel_core.c
1496 +@@ -827,6 +827,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
1497 + int st_accel_common_probe(struct iio_dev *indio_dev)
1498 + {
1499 + struct st_sensor_data *adata = iio_priv(indio_dev);
1500 ++ struct st_sensors_platform_data *pdata =
1501 ++ (struct st_sensors_platform_data *)adata->dev->platform_data;
1502 + int irq = adata->get_irq_data_ready(indio_dev);
1503 + int err;
1504 +
1505 +@@ -853,9 +855,8 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
1506 + &adata->sensor_settings->fs.fs_avl[0];
1507 + adata->odr = adata->sensor_settings->odr.odr_avl[0].hz;
1508 +
1509 +- if (!adata->dev->platform_data)
1510 +- adata->dev->platform_data =
1511 +- (struct st_sensors_platform_data *)&default_accel_pdata;
1512 ++ if (!pdata)
1513 ++ pdata = (struct st_sensors_platform_data *)&default_accel_pdata;
1514 +
1515 + err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data);
1516 + if (err < 0)
1517 +diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1518 +index ab646a90e3da..af85db50412e 100644
1519 +--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1520 ++++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1521 +@@ -215,7 +215,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
1522 + ret = sensor_hub_set_feature(st->hsdev, st->poll.report_id,
1523 + st->poll.index, sizeof(value), &value);
1524 + if (ret < 0 || value < 0)
1525 +- ret = -EINVAL;
1526 ++ return -EINVAL;
1527 +
1528 + ret = sensor_hub_get_feature(st->hsdev,
1529 + st->poll.report_id,
1530 +@@ -265,7 +265,7 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
1531 + st->sensitivity.index, sizeof(value),
1532 + &value);
1533 + if (ret < 0 || value < 0)
1534 +- ret = -EINVAL;
1535 ++ return -EINVAL;
1536 +
1537 + ret = sensor_hub_get_feature(st->hsdev,
1538 + st->sensitivity.report_id,
1539 +diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
1540 +index 44e46c159a7e..bec60299b6ec 100644
1541 +--- a/drivers/iio/pressure/st_pressure_core.c
1542 ++++ b/drivers/iio/pressure/st_pressure_core.c
1543 +@@ -638,6 +638,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = {
1544 + int st_press_common_probe(struct iio_dev *indio_dev)
1545 + {
1546 + struct st_sensor_data *press_data = iio_priv(indio_dev);
1547 ++ struct st_sensors_platform_data *pdata =
1548 ++ (struct st_sensors_platform_data *)press_data->dev->platform_data;
1549 + int irq = press_data->get_irq_data_ready(indio_dev);
1550 + int err;
1551 +
1552 +@@ -673,10 +675,8 @@ int st_press_common_probe(struct iio_dev *indio_dev)
1553 + press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz;
1554 +
1555 + /* Some devices don't support a data ready pin. */
1556 +- if (!press_data->dev->platform_data &&
1557 +- press_data->sensor_settings->drdy_irq.addr)
1558 +- press_data->dev->platform_data =
1559 +- (struct st_sensors_platform_data *)&default_press_pdata;
1560 ++ if (!pdata && press_data->sensor_settings->drdy_irq.addr)
1561 ++ pdata = (struct st_sensors_platform_data *)&default_press_pdata;
1562 +
1563 + err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data);
1564 + if (err < 0)
1565 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
1566 +index 30f01613b518..cbe5324c4331 100644
1567 +--- a/drivers/infiniband/core/cma.c
1568 ++++ b/drivers/infiniband/core/cma.c
1569 +@@ -4039,6 +4039,9 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
1570 + struct cma_multicast *mc;
1571 + int ret;
1572 +
1573 ++ if (!id->device)
1574 ++ return -EINVAL;
1575 ++
1576 + id_priv = container_of(id, struct rdma_id_private, id);
1577 + if (!cma_comp(id_priv, RDMA_CM_ADDR_BOUND) &&
1578 + !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED))
1579 +@@ -4336,7 +4339,7 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb)
1580 + RDMA_NL_RDMA_CM_ATTR_SRC_ADDR))
1581 + goto out;
1582 + if (ibnl_put_attr(skb, nlh,
1583 +- rdma_addr_size(cma_src_addr(id_priv)),
1584 ++ rdma_addr_size(cma_dst_addr(id_priv)),
1585 + cma_dst_addr(id_priv),
1586 + RDMA_NL_RDMA_CM_ATTR_DST_ADDR))
1587 + goto out;
1588 +diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
1589 +index ade71e7f0131..2fe4c2c921de 100644
1590 +--- a/drivers/infiniband/core/iwpm_util.c
1591 ++++ b/drivers/infiniband/core/iwpm_util.c
1592 +@@ -664,6 +664,7 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)
1593 + }
1594 + skb_num++;
1595 + spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
1596 ++ ret = -EINVAL;
1597 + for (i = 0; i < IWPM_MAPINFO_HASH_SIZE; i++) {
1598 + hlist_for_each_entry(map_info, &iwpm_hash_bucket[i],
1599 + hlist_node) {
1600 +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
1601 +index 6840d3c5cd64..017a09ceba3f 100644
1602 +--- a/drivers/infiniband/core/ucma.c
1603 ++++ b/drivers/infiniband/core/ucma.c
1604 +@@ -1330,7 +1330,7 @@ static ssize_t ucma_process_join(struct ucma_file *file,
1605 + return -ENOSPC;
1606 +
1607 + addr = (struct sockaddr *) &cmd->addr;
1608 +- if (!cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr)))
1609 ++ if (cmd->addr_size != rdma_addr_size(addr))
1610 + return -EINVAL;
1611 +
1612 + if (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER)
1613 +@@ -1398,6 +1398,9 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
1614 + join_cmd.uid = cmd.uid;
1615 + join_cmd.id = cmd.id;
1616 + join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr);
1617 ++ if (!join_cmd.addr_size)
1618 ++ return -EINVAL;
1619 ++
1620 + join_cmd.join_flags = RDMA_MC_JOIN_FLAG_FULLMEMBER;
1621 + memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size);
1622 +
1623 +@@ -1413,6 +1416,9 @@ static ssize_t ucma_join_multicast(struct ucma_file *file,
1624 + if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
1625 + return -EFAULT;
1626 +
1627 ++ if (!rdma_addr_size((struct sockaddr *)&cmd.addr))
1628 ++ return -EINVAL;
1629 ++
1630 + return ucma_process_join(file, &cmd, out_len);
1631 + }
1632 +
1633 +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
1634 +index 8e973a2993a6..e74aa1d60fdb 100644
1635 +--- a/drivers/infiniband/core/umem.c
1636 ++++ b/drivers/infiniband/core/umem.c
1637 +@@ -357,7 +357,7 @@ int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
1638 + return -EINVAL;
1639 + }
1640 +
1641 +- ret = sg_pcopy_to_buffer(umem->sg_head.sgl, umem->nmap, dst, length,
1642 ++ ret = sg_pcopy_to_buffer(umem->sg_head.sgl, umem->npages, dst, length,
1643 + offset + ib_umem_offset(umem));
1644 +
1645 + if (ret < 0)
1646 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
1647 +index d118ffe0bfb6..4b717cf50d27 100644
1648 +--- a/drivers/infiniband/core/uverbs_cmd.c
1649 ++++ b/drivers/infiniband/core/uverbs_cmd.c
1650 +@@ -2491,9 +2491,13 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1651 +
1652 + static void *alloc_wr(size_t wr_size, __u32 num_sge)
1653 + {
1654 ++ if (num_sge >= (U32_MAX - ALIGN(wr_size, sizeof (struct ib_sge))) /
1655 ++ sizeof (struct ib_sge))
1656 ++ return NULL;
1657 ++
1658 + return kmalloc(ALIGN(wr_size, sizeof (struct ib_sge)) +
1659 + num_sge * sizeof (struct ib_sge), GFP_KERNEL);
1660 +-};
1661 ++}
1662 +
1663 + ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1664 + struct ib_device *ib_dev,
1665 +@@ -2720,6 +2724,13 @@ static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
1666 + goto err;
1667 + }
1668 +
1669 ++ if (user_wr->num_sge >=
1670 ++ (U32_MAX - ALIGN(sizeof *next, sizeof (struct ib_sge))) /
1671 ++ sizeof (struct ib_sge)) {
1672 ++ ret = -EINVAL;
1673 ++ goto err;
1674 ++ }
1675 ++
1676 + next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
1677 + user_wr->num_sge * sizeof (struct ib_sge),
1678 + GFP_KERNEL);
1679 +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
1680 +index 3be62ef154d1..7853b0caad32 100644
1681 +--- a/drivers/infiniband/hw/hfi1/chip.c
1682 ++++ b/drivers/infiniband/hw/hfi1/chip.c
1683 +@@ -6379,18 +6379,17 @@ static void lcb_shutdown(struct hfi1_devdata *dd, int abort)
1684 + *
1685 + * The expectation is that the caller of this routine would have taken
1686 + * care of properly transitioning the link into the correct state.
1687 ++ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
1688 ++ * before calling this function.
1689 + */
1690 +-static void dc_shutdown(struct hfi1_devdata *dd)
1691 ++static void _dc_shutdown(struct hfi1_devdata *dd)
1692 + {
1693 +- unsigned long flags;
1694 ++ lockdep_assert_held(&dd->dc8051_lock);
1695 +
1696 +- spin_lock_irqsave(&dd->dc8051_lock, flags);
1697 +- if (dd->dc_shutdown) {
1698 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1699 ++ if (dd->dc_shutdown)
1700 + return;
1701 +- }
1702 ++
1703 + dd->dc_shutdown = 1;
1704 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1705 + /* Shutdown the LCB */
1706 + lcb_shutdown(dd, 1);
1707 + /*
1708 +@@ -6401,35 +6400,45 @@ static void dc_shutdown(struct hfi1_devdata *dd)
1709 + write_csr(dd, DC_DC8051_CFG_RST, 0x1);
1710 + }
1711 +
1712 ++static void dc_shutdown(struct hfi1_devdata *dd)
1713 ++{
1714 ++ mutex_lock(&dd->dc8051_lock);
1715 ++ _dc_shutdown(dd);
1716 ++ mutex_unlock(&dd->dc8051_lock);
1717 ++}
1718 ++
1719 + /*
1720 + * Calling this after the DC has been brought out of reset should not
1721 + * do any damage.
1722 ++ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
1723 ++ * before calling this function.
1724 + */
1725 +-static void dc_start(struct hfi1_devdata *dd)
1726 ++static void _dc_start(struct hfi1_devdata *dd)
1727 + {
1728 +- unsigned long flags;
1729 +- int ret;
1730 ++ lockdep_assert_held(&dd->dc8051_lock);
1731 +
1732 +- spin_lock_irqsave(&dd->dc8051_lock, flags);
1733 + if (!dd->dc_shutdown)
1734 +- goto done;
1735 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1736 ++ return;
1737 ++
1738 + /* Take the 8051 out of reset */
1739 + write_csr(dd, DC_DC8051_CFG_RST, 0ull);
1740 + /* Wait until 8051 is ready */
1741 +- ret = wait_fm_ready(dd, TIMEOUT_8051_START);
1742 +- if (ret) {
1743 ++ if (wait_fm_ready(dd, TIMEOUT_8051_START))
1744 + dd_dev_err(dd, "%s: timeout starting 8051 firmware\n",
1745 + __func__);
1746 +- }
1747 ++
1748 + /* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
1749 + write_csr(dd, DCC_CFG_RESET, 0x10);
1750 + /* lcb_shutdown() with abort=1 does not restore these */
1751 + write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
1752 +- spin_lock_irqsave(&dd->dc8051_lock, flags);
1753 + dd->dc_shutdown = 0;
1754 +-done:
1755 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1756 ++}
1757 ++
1758 ++static void dc_start(struct hfi1_devdata *dd)
1759 ++{
1760 ++ mutex_lock(&dd->dc8051_lock);
1761 ++ _dc_start(dd);
1762 ++ mutex_unlock(&dd->dc8051_lock);
1763 + }
1764 +
1765 + /*
1766 +@@ -8418,16 +8427,11 @@ static int do_8051_command(
1767 + {
1768 + u64 reg, completed;
1769 + int return_code;
1770 +- unsigned long flags;
1771 + unsigned long timeout;
1772 +
1773 + hfi1_cdbg(DC8051, "type %d, data 0x%012llx", type, in_data);
1774 +
1775 +- /*
1776 +- * Alternative to holding the lock for a long time:
1777 +- * - keep busy wait - have other users bounce off
1778 +- */
1779 +- spin_lock_irqsave(&dd->dc8051_lock, flags);
1780 ++ mutex_lock(&dd->dc8051_lock);
1781 +
1782 + /* We can't send any commands to the 8051 if it's in reset */
1783 + if (dd->dc_shutdown) {
1784 +@@ -8453,10 +8457,8 @@ static int do_8051_command(
1785 + return_code = -ENXIO;
1786 + goto fail;
1787 + }
1788 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1789 +- dc_shutdown(dd);
1790 +- dc_start(dd);
1791 +- spin_lock_irqsave(&dd->dc8051_lock, flags);
1792 ++ _dc_shutdown(dd);
1793 ++ _dc_start(dd);
1794 + }
1795 +
1796 + /*
1797 +@@ -8534,8 +8536,7 @@ static int do_8051_command(
1798 + write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, 0);
1799 +
1800 + fail:
1801 +- spin_unlock_irqrestore(&dd->dc8051_lock, flags);
1802 +-
1803 ++ mutex_unlock(&dd->dc8051_lock);
1804 + return return_code;
1805 + }
1806 +
1807 +@@ -11849,6 +11850,10 @@ static void free_cntrs(struct hfi1_devdata *dd)
1808 + dd->scntrs = NULL;
1809 + kfree(dd->cntrnames);
1810 + dd->cntrnames = NULL;
1811 ++ if (dd->update_cntr_wq) {
1812 ++ destroy_workqueue(dd->update_cntr_wq);
1813 ++ dd->update_cntr_wq = NULL;
1814 ++ }
1815 + }
1816 +
1817 + static u64 read_dev_port_cntr(struct hfi1_devdata *dd, struct cntr_entry *entry,
1818 +@@ -12004,7 +12009,7 @@ u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data)
1819 + return write_dev_port_cntr(ppd->dd, entry, sval, ppd, vl, data);
1820 + }
1821 +
1822 +-static void update_synth_timer(unsigned long opaque)
1823 ++static void do_update_synth_timer(struct work_struct *work)
1824 + {
1825 + u64 cur_tx;
1826 + u64 cur_rx;
1827 +@@ -12013,8 +12018,8 @@ static void update_synth_timer(unsigned long opaque)
1828 + int i, j, vl;
1829 + struct hfi1_pportdata *ppd;
1830 + struct cntr_entry *entry;
1831 +-
1832 +- struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
1833 ++ struct hfi1_devdata *dd = container_of(work, struct hfi1_devdata,
1834 ++ update_cntr_work);
1835 +
1836 + /*
1837 + * Rather than keep beating on the CSRs pick a minimal set that we can
1838 +@@ -12097,7 +12102,13 @@ static void update_synth_timer(unsigned long opaque)
1839 + } else {
1840 + hfi1_cdbg(CNTR, "[%d] No update necessary", dd->unit);
1841 + }
1842 ++}
1843 ++
1844 ++static void update_synth_timer(unsigned long opaque)
1845 ++{
1846 ++ struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
1847 +
1848 ++ queue_work(dd->update_cntr_wq, &dd->update_cntr_work);
1849 + mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
1850 + }
1851 +
1852 +@@ -12333,6 +12344,13 @@ static int init_cntrs(struct hfi1_devdata *dd)
1853 + if (init_cpu_counters(dd))
1854 + goto bail;
1855 +
1856 ++ dd->update_cntr_wq = alloc_ordered_workqueue("hfi1_update_cntr_%d",
1857 ++ WQ_MEM_RECLAIM, dd->unit);
1858 ++ if (!dd->update_cntr_wq)
1859 ++ goto bail;
1860 ++
1861 ++ INIT_WORK(&dd->update_cntr_work, do_update_synth_timer);
1862 ++
1863 + mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
1864 + return 0;
1865 + bail:
1866 +diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
1867 +index cc87fd4e534b..a3279f3d2578 100644
1868 +--- a/drivers/infiniband/hw/hfi1/hfi.h
1869 ++++ b/drivers/infiniband/hw/hfi1/hfi.h
1870 +@@ -475,7 +475,7 @@ struct rvt_sge_state;
1871 + #define HFI1_PART_ENFORCE_OUT 0x2
1872 +
1873 + /* how often we check for synthetic counter wrap around */
1874 +-#define SYNTH_CNT_TIME 2
1875 ++#define SYNTH_CNT_TIME 3
1876 +
1877 + /* Counter flags */
1878 + #define CNTR_NORMAL 0x0 /* Normal counters, just read register */
1879 +@@ -929,8 +929,9 @@ struct hfi1_devdata {
1880 + spinlock_t rcvctrl_lock; /* protect changes to RcvCtrl */
1881 + /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
1882 + spinlock_t uctxt_lock; /* rcd and user context changes */
1883 +- /* exclusive access to 8051 */
1884 +- spinlock_t dc8051_lock;
1885 ++ struct mutex dc8051_lock; /* exclusive access to 8051 */
1886 ++ struct workqueue_struct *update_cntr_wq;
1887 ++ struct work_struct update_cntr_work;
1888 + /* exclusive access to 8051 memory */
1889 + spinlock_t dc8051_memlock;
1890 + int dc8051_timed_out; /* remember if the 8051 timed out */
1891 +diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
1892 +index a3dd27b1305d..84a97f3f9299 100644
1893 +--- a/drivers/infiniband/hw/hfi1/init.c
1894 ++++ b/drivers/infiniband/hw/hfi1/init.c
1895 +@@ -1078,11 +1078,11 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra)
1896 + spin_lock_init(&dd->uctxt_lock);
1897 + spin_lock_init(&dd->hfi1_diag_trans_lock);
1898 + spin_lock_init(&dd->sc_init_lock);
1899 +- spin_lock_init(&dd->dc8051_lock);
1900 + spin_lock_init(&dd->dc8051_memlock);
1901 + seqlock_init(&dd->sc2vl_lock);
1902 + spin_lock_init(&dd->sde_map_lock);
1903 + spin_lock_init(&dd->pio_map_lock);
1904 ++ mutex_init(&dd->dc8051_lock);
1905 + init_waitqueue_head(&dd->event_queue);
1906 +
1907 + dd->int_counter = alloc_percpu(u64);
1908 +diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
1909 +index c41c8d0a4ac0..19bc1c2186ff 100644
1910 +--- a/drivers/infiniband/hw/mlx4/main.c
1911 ++++ b/drivers/infiniband/hw/mlx4/main.c
1912 +@@ -1168,7 +1168,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
1913 + /* need to protect from a race on closing the vma as part of
1914 + * mlx4_ib_vma_close().
1915 + */
1916 +- down_read(&owning_mm->mmap_sem);
1917 ++ down_write(&owning_mm->mmap_sem);
1918 + for (i = 0; i < HW_BAR_COUNT; i++) {
1919 + vma = context->hw_bar_info[i].vma;
1920 + if (!vma)
1921 +@@ -1182,11 +1182,13 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
1922 + BUG_ON(1);
1923 + }
1924 +
1925 ++ context->hw_bar_info[i].vma->vm_flags &=
1926 ++ ~(VM_SHARED | VM_MAYSHARE);
1927 + /* context going to be destroyed, should not access ops any more */
1928 + context->hw_bar_info[i].vma->vm_ops = NULL;
1929 + }
1930 +
1931 +- up_read(&owning_mm->mmap_sem);
1932 ++ up_write(&owning_mm->mmap_sem);
1933 + mmput(owning_mm);
1934 + put_task_struct(owning_process);
1935 + }
1936 +diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
1937 +index 9cdcff77b9a8..fc62a7ded734 100644
1938 +--- a/drivers/infiniband/hw/mlx5/cq.c
1939 ++++ b/drivers/infiniband/hw/mlx5/cq.c
1940 +@@ -172,6 +172,8 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
1941 + struct mlx5_ib_srq *srq;
1942 + struct mlx5_ib_wq *wq;
1943 + u16 wqe_ctr;
1944 ++ u8 roce_packet_type;
1945 ++ bool vlan_present;
1946 + u8 g;
1947 +
1948 + if (qp->ibqp.srq || qp->ibqp.xrcd) {
1949 +@@ -223,7 +225,6 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
1950 + break;
1951 + }
1952 + wc->slid = be16_to_cpu(cqe->slid);
1953 +- wc->sl = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0xf;
1954 + wc->src_qp = be32_to_cpu(cqe->flags_rqpn) & 0xffffff;
1955 + wc->dlid_path_bits = cqe->ml_path;
1956 + g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
1957 +@@ -237,10 +238,22 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
1958 + wc->pkey_index = 0;
1959 + }
1960 +
1961 +- if (ll != IB_LINK_LAYER_ETHERNET)
1962 ++ if (ll != IB_LINK_LAYER_ETHERNET) {
1963 ++ wc->sl = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0xf;
1964 + return;
1965 ++ }
1966 ++
1967 ++ vlan_present = cqe->l4_l3_hdr_type & 0x1;
1968 ++ roce_packet_type = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0x3;
1969 ++ if (vlan_present) {
1970 ++ wc->vlan_id = (be16_to_cpu(cqe->vlan_info)) & 0xfff;
1971 ++ wc->sl = (be16_to_cpu(cqe->vlan_info) >> 13) & 0x7;
1972 ++ wc->wc_flags |= IB_WC_WITH_VLAN;
1973 ++ } else {
1974 ++ wc->sl = 0;
1975 ++ }
1976 +
1977 +- switch (wc->sl & 0x3) {
1978 ++ switch (roce_packet_type) {
1979 + case MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH:
1980 + wc->network_hdr_type = RDMA_NETWORK_IB;
1981 + break;
1982 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
1983 +index 5e29fbd3a5a0..d7da1dca765f 100644
1984 +--- a/drivers/infiniband/hw/mlx5/main.c
1985 ++++ b/drivers/infiniband/hw/mlx5/main.c
1986 +@@ -1313,7 +1313,7 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
1987 + /* need to protect from a race on closing the vma as part of
1988 + * mlx5_ib_vma_close.
1989 + */
1990 +- down_read(&owning_mm->mmap_sem);
1991 ++ down_write(&owning_mm->mmap_sem);
1992 + list_for_each_entry_safe(vma_private, n, &context->vma_private_list,
1993 + list) {
1994 + vma = vma_private->vma;
1995 +@@ -1323,11 +1323,12 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
1996 + /* context going to be destroyed, should
1997 + * not access ops any more.
1998 + */
1999 ++ vma->vm_flags &= ~(VM_SHARED | VM_MAYSHARE);
2000 + vma->vm_ops = NULL;
2001 + list_del(&vma_private->list);
2002 + kfree(vma_private);
2003 + }
2004 +- up_read(&owning_mm->mmap_sem);
2005 ++ up_write(&owning_mm->mmap_sem);
2006 + mmput(owning_mm);
2007 + put_task_struct(owning_process);
2008 + }
2009 +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
2010 +index fdd156101a72..403df3591d29 100644
2011 +--- a/drivers/infiniband/hw/mlx5/qp.c
2012 ++++ b/drivers/infiniband/hw/mlx5/qp.c
2013 +@@ -1130,7 +1130,7 @@ static void destroy_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
2014 + ib_umem_release(sq->ubuffer.umem);
2015 + }
2016 +
2017 +-static int get_rq_pas_size(void *qpc)
2018 ++static size_t get_rq_pas_size(void *qpc)
2019 + {
2020 + u32 log_page_size = MLX5_GET(qpc, qpc, log_page_size) + 12;
2021 + u32 log_rq_stride = MLX5_GET(qpc, qpc, log_rq_stride);
2022 +@@ -1146,7 +1146,8 @@ static int get_rq_pas_size(void *qpc)
2023 + }
2024 +
2025 + static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
2026 +- struct mlx5_ib_rq *rq, void *qpin)
2027 ++ struct mlx5_ib_rq *rq, void *qpin,
2028 ++ size_t qpinlen)
2029 + {
2030 + struct mlx5_ib_qp *mqp = rq->base.container_mibqp;
2031 + __be64 *pas;
2032 +@@ -1155,9 +1156,12 @@ static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
2033 + void *rqc;
2034 + void *wq;
2035 + void *qpc = MLX5_ADDR_OF(create_qp_in, qpin, qpc);
2036 +- int inlen;
2037 ++ size_t rq_pas_size = get_rq_pas_size(qpc);
2038 ++ size_t inlen;
2039 + int err;
2040 +- u32 rq_pas_size = get_rq_pas_size(qpc);
2041 ++
2042 ++ if (qpinlen < rq_pas_size + MLX5_BYTE_OFF(create_qp_in, pas))
2043 ++ return -EINVAL;
2044 +
2045 + inlen = MLX5_ST_SZ_BYTES(create_rq_in) + rq_pas_size;
2046 + in = mlx5_vzalloc(inlen);
2047 +@@ -1235,7 +1239,7 @@ static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
2048 + }
2049 +
2050 + static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
2051 +- u32 *in,
2052 ++ u32 *in, size_t inlen,
2053 + struct ib_pd *pd)
2054 + {
2055 + struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
2056 +@@ -1262,7 +1266,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
2057 + if (qp->rq.wqe_cnt) {
2058 + rq->base.container_mibqp = qp;
2059 +
2060 +- err = create_raw_packet_qp_rq(dev, rq, in);
2061 ++ err = create_raw_packet_qp_rq(dev, rq, in, inlen);
2062 + if (err)
2063 + goto err_destroy_sq;
2064 +
2065 +@@ -1753,10 +1757,15 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
2066 + qp->flags |= MLX5_IB_QP_LSO;
2067 + }
2068 +
2069 ++ if (inlen < 0) {
2070 ++ err = -EINVAL;
2071 ++ goto err;
2072 ++ }
2073 ++
2074 + if (init_attr->qp_type == IB_QPT_RAW_PACKET) {
2075 + qp->raw_packet_qp.sq.ubuffer.buf_addr = ucmd.sq_buf_addr;
2076 + raw_packet_qp_copy_info(qp, &qp->raw_packet_qp);
2077 +- err = create_raw_packet_qp(dev, qp, in, pd);
2078 ++ err = create_raw_packet_qp(dev, qp, in, inlen, pd);
2079 + } else {
2080 + err = mlx5_core_create_qp(dev->mdev, &base->mqp, in, inlen);
2081 + }
2082 +@@ -1796,6 +1805,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
2083 + else if (qp->create_type == MLX5_QP_KERNEL)
2084 + destroy_qp_kernel(dev, qp);
2085 +
2086 ++err:
2087 + kvfree(in);
2088 + return err;
2089 + }
2090 +diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
2091 +index d61fd2c727c0..5c1dbe2f8757 100644
2092 +--- a/drivers/infiniband/hw/mlx5/srq.c
2093 ++++ b/drivers/infiniband/hw/mlx5/srq.c
2094 +@@ -243,8 +243,8 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
2095 + {
2096 + struct mlx5_ib_dev *dev = to_mdev(pd->device);
2097 + struct mlx5_ib_srq *srq;
2098 +- int desc_size;
2099 +- int buf_size;
2100 ++ size_t desc_size;
2101 ++ size_t buf_size;
2102 + int err;
2103 + struct mlx5_srq_attr in = {0};
2104 + __u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz);
2105 +@@ -268,15 +268,18 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
2106 +
2107 + desc_size = sizeof(struct mlx5_wqe_srq_next_seg) +
2108 + srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg);
2109 ++ if (desc_size == 0 || srq->msrq.max_gs > desc_size)
2110 ++ return ERR_PTR(-EINVAL);
2111 + desc_size = roundup_pow_of_two(desc_size);
2112 +- desc_size = max_t(int, 32, desc_size);
2113 ++ desc_size = max_t(size_t, 32, desc_size);
2114 ++ if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg))
2115 ++ return ERR_PTR(-EINVAL);
2116 + srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) /
2117 + sizeof(struct mlx5_wqe_data_seg);
2118 + srq->msrq.wqe_shift = ilog2(desc_size);
2119 + buf_size = srq->msrq.max * desc_size;
2120 +- mlx5_ib_dbg(dev, "desc_size 0x%x, req wr 0x%x, srq size 0x%x, max_gs 0x%x, max_avail_gather 0x%x\n",
2121 +- desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs,
2122 +- srq->msrq.max_avail_gather);
2123 ++ if (buf_size < desc_size)
2124 ++ return ERR_PTR(-EINVAL);
2125 + in.type = init_attr->srq_type;
2126 +
2127 + if (pd->uobject)
2128 +diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
2129 +index 8bef09a8c49f..265943069b35 100644
2130 +--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
2131 ++++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
2132 +@@ -836,7 +836,7 @@ void ocrdma_add_port_stats(struct ocrdma_dev *dev)
2133 +
2134 + dev->reset_stats.type = OCRDMA_RESET_STATS;
2135 + dev->reset_stats.dev = dev;
2136 +- if (!debugfs_create_file("reset_stats", S_IRUSR, dev->dir,
2137 ++ if (!debugfs_create_file("reset_stats", 0200, dev->dir,
2138 + &dev->reset_stats, &ocrdma_dbg_ops))
2139 + goto err;
2140 +
2141 +diff --git a/drivers/infiniband/sw/rdmavt/ah.c b/drivers/infiniband/sw/rdmavt/ah.c
2142 +index 16c446142c2a..b0f09fb45c72 100644
2143 +--- a/drivers/infiniband/sw/rdmavt/ah.c
2144 ++++ b/drivers/infiniband/sw/rdmavt/ah.c
2145 +@@ -119,7 +119,7 @@ struct ib_ah *rvt_create_ah(struct ib_pd *pd,
2146 +
2147 + spin_lock_irqsave(&dev->n_ahs_lock, flags);
2148 + if (dev->n_ahs_allocated == dev->dparms.props.max_ah) {
2149 +- spin_unlock(&dev->n_ahs_lock);
2150 ++ spin_unlock_irqrestore(&dev->n_ahs_lock, flags);
2151 + kfree(ah);
2152 + return ERR_PTR(-ENOMEM);
2153 + }
2154 +diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
2155 +index 8c0ddd7165ae..0d25dc84d294 100644
2156 +--- a/drivers/infiniband/sw/rxe/rxe_resp.c
2157 ++++ b/drivers/infiniband/sw/rxe/rxe_resp.c
2158 +@@ -471,8 +471,6 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
2159 + state = RESPST_ERR_LENGTH;
2160 + goto err;
2161 + }
2162 +-
2163 +- qp->resp.resid = mtu;
2164 + } else {
2165 + if (pktlen != resid) {
2166 + state = RESPST_ERR_LENGTH;
2167 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
2168 +index 335bd2c9e16e..34122c96522b 100644
2169 +--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
2170 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
2171 +@@ -974,6 +974,19 @@ static inline int update_parent_pkey(struct ipoib_dev_priv *priv)
2172 + */
2173 + priv->dev->broadcast[8] = priv->pkey >> 8;
2174 + priv->dev->broadcast[9] = priv->pkey & 0xff;
2175 ++
2176 ++ /*
2177 ++ * Update the broadcast address in the priv->broadcast object,
2178 ++ * in case it already exists, otherwise no one will do that.
2179 ++ */
2180 ++ if (priv->broadcast) {
2181 ++ spin_lock_irq(&priv->lock);
2182 ++ memcpy(priv->broadcast->mcmember.mgid.raw,
2183 ++ priv->dev->broadcast + 4,
2184 ++ sizeof(union ib_gid));
2185 ++ spin_unlock_irq(&priv->lock);
2186 ++ }
2187 ++
2188 + return 0;
2189 + }
2190 +
2191 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
2192 +index e37e918cb935..0df7d4504c06 100644
2193 +--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
2194 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
2195 +@@ -799,6 +799,22 @@ static void path_rec_completion(int status,
2196 + spin_lock_irqsave(&priv->lock, flags);
2197 +
2198 + if (!IS_ERR_OR_NULL(ah)) {
2199 ++ /*
2200 ++ * pathrec.dgid is used as the database key from the LLADDR,
2201 ++ * it must remain unchanged even if the SA returns a different
2202 ++ * GID to use in the AH.
2203 ++ */
2204 ++ if (memcmp(pathrec->dgid.raw, path->pathrec.dgid.raw,
2205 ++ sizeof(union ib_gid))) {
2206 ++ ipoib_dbg(
2207 ++ priv,
2208 ++ "%s got PathRec for gid %pI6 while asked for %pI6\n",
2209 ++ dev->name, pathrec->dgid.raw,
2210 ++ path->pathrec.dgid.raw);
2211 ++ memcpy(pathrec->dgid.raw, path->pathrec.dgid.raw,
2212 ++ sizeof(union ib_gid));
2213 ++ }
2214 ++
2215 + path->pathrec = *pathrec;
2216 +
2217 + old_ah = path->ah;
2218 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
2219 +index 6b6826f3e446..8f79caedf905 100644
2220 +--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
2221 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
2222 +@@ -487,6 +487,9 @@ static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
2223 + !test_bit(IPOIB_FLAG_OPER_UP, &priv->flags))
2224 + return -EINVAL;
2225 +
2226 ++ init_completion(&mcast->done);
2227 ++ set_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
2228 ++
2229 + ipoib_dbg_mcast(priv, "joining MGID %pI6\n", mcast->mcmember.mgid.raw);
2230 +
2231 + rec.mgid = mcast->mcmember.mgid;
2232 +@@ -645,8 +648,6 @@ void ipoib_mcast_join_task(struct work_struct *work)
2233 + if (mcast->backoff == 1 ||
2234 + time_after_eq(jiffies, mcast->delay_until)) {
2235 + /* Found the next unjoined group */
2236 +- init_completion(&mcast->done);
2237 +- set_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
2238 + if (ipoib_mcast_join(dev, mcast)) {
2239 + spin_unlock_irq(&priv->lock);
2240 + return;
2241 +@@ -666,11 +667,9 @@ void ipoib_mcast_join_task(struct work_struct *work)
2242 + queue_delayed_work(priv->wq, &priv->mcast_task,
2243 + delay_until - jiffies);
2244 + }
2245 +- if (mcast) {
2246 +- init_completion(&mcast->done);
2247 +- set_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
2248 ++ if (mcast)
2249 + ipoib_mcast_join(dev, mcast);
2250 +- }
2251 ++
2252 + spin_unlock_irq(&priv->lock);
2253 + }
2254 +
2255 +diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
2256 +index 0983470929bd..b879d21b7548 100644
2257 +--- a/drivers/infiniband/ulp/isert/ib_isert.c
2258 ++++ b/drivers/infiniband/ulp/isert/ib_isert.c
2259 +@@ -2098,6 +2098,9 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,
2260 + u32 rkey, offset;
2261 + int ret;
2262 +
2263 ++ if (cmd->ctx_init_done)
2264 ++ goto rdma_ctx_post;
2265 ++
2266 + if (dir == DMA_FROM_DEVICE) {
2267 + addr = cmd->write_va;
2268 + rkey = cmd->write_stag;
2269 +@@ -2125,11 +2128,15 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,
2270 + se_cmd->t_data_sg, se_cmd->t_data_nents,
2271 + offset, addr, rkey, dir);
2272 + }
2273 ++
2274 + if (ret < 0) {
2275 + isert_err("Cmd: %p failed to prepare RDMA res\n", cmd);
2276 + return ret;
2277 + }
2278 +
2279 ++ cmd->ctx_init_done = true;
2280 ++
2281 ++rdma_ctx_post:
2282 + ret = rdma_rw_ctx_post(&cmd->rw, conn->qp, port_num, cqe, chain_wr);
2283 + if (ret < 0)
2284 + isert_err("Cmd: %p failed to post RDMA res\n", cmd);
2285 +diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
2286 +index c02ada57d7f5..85bd19753d55 100644
2287 +--- a/drivers/infiniband/ulp/isert/ib_isert.h
2288 ++++ b/drivers/infiniband/ulp/isert/ib_isert.h
2289 +@@ -124,6 +124,7 @@ struct isert_cmd {
2290 + struct rdma_rw_ctx rw;
2291 + struct work_struct comp_work;
2292 + struct scatterlist sg;
2293 ++ bool ctx_init_done;
2294 + };
2295 +
2296 + static inline struct isert_cmd *tx_desc_to_cmd(struct iser_tx_desc *desc)
2297 +diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
2298 +index 603fc2fadf05..12b20840fb74 100644
2299 +--- a/drivers/input/misc/twl4030-pwrbutton.c
2300 ++++ b/drivers/input/misc/twl4030-pwrbutton.c
2301 +@@ -70,7 +70,7 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
2302 + pwr->phys = "twl4030_pwrbutton/input0";
2303 + pwr->dev.parent = &pdev->dev;
2304 +
2305 +- err = devm_request_threaded_irq(&pwr->dev, irq, NULL, powerbutton_irq,
2306 ++ err = devm_request_threaded_irq(&pdev->dev, irq, NULL, powerbutton_irq,
2307 + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
2308 + IRQF_ONESHOT,
2309 + "twl4030_pwrbutton", pwr);
2310 +diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c
2311 +index 71b5a634cf6d..e7bb155911d0 100644
2312 +--- a/drivers/input/touchscreen/ar1021_i2c.c
2313 ++++ b/drivers/input/touchscreen/ar1021_i2c.c
2314 +@@ -152,7 +152,7 @@ static int __maybe_unused ar1021_i2c_resume(struct device *dev)
2315 + static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume);
2316 +
2317 + static const struct i2c_device_id ar1021_i2c_id[] = {
2318 +- { "MICROCHIP_AR1021_I2C", 0 },
2319 ++ { "ar1021", 0 },
2320 + { },
2321 + };
2322 + MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id);
2323 +diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
2324 +index cb72e0011310..3a1c40684213 100644
2325 +--- a/drivers/iommu/intel-svm.c
2326 ++++ b/drivers/iommu/intel-svm.c
2327 +@@ -127,6 +127,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu)
2328 + pr_err("IOMMU: %s: Failed to request IRQ for page request queue\n",
2329 + iommu->name);
2330 + dmar_free_hwirq(irq);
2331 ++ iommu->pr_irq = 0;
2332 + goto err;
2333 + }
2334 + dmar_writeq(iommu->reg + DMAR_PQH_REG, 0ULL);
2335 +@@ -142,9 +143,11 @@ int intel_svm_finish_prq(struct intel_iommu *iommu)
2336 + dmar_writeq(iommu->reg + DMAR_PQT_REG, 0ULL);
2337 + dmar_writeq(iommu->reg + DMAR_PQA_REG, 0ULL);
2338 +
2339 +- free_irq(iommu->pr_irq, iommu);
2340 +- dmar_free_hwirq(iommu->pr_irq);
2341 +- iommu->pr_irq = 0;
2342 ++ if (iommu->pr_irq) {
2343 ++ free_irq(iommu->pr_irq, iommu);
2344 ++ dmar_free_hwirq(iommu->pr_irq);
2345 ++ iommu->pr_irq = 0;
2346 ++ }
2347 +
2348 + free_pages((unsigned long)iommu->prq, PRQ_ORDER);
2349 + iommu->prq = NULL;
2350 +diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
2351 +index e2583cce2cc1..54556713c8d1 100644
2352 +--- a/drivers/iommu/omap-iommu.c
2353 ++++ b/drivers/iommu/omap-iommu.c
2354 +@@ -1299,6 +1299,7 @@ static int __init omap_iommu_init(void)
2355 + const unsigned long flags = SLAB_HWCACHE_ALIGN;
2356 + size_t align = 1 << 10; /* L2 pagetable alignement */
2357 + struct device_node *np;
2358 ++ int ret;
2359 +
2360 + np = of_find_matching_node(NULL, omap_iommu_of_match);
2361 + if (!np)
2362 +@@ -1312,11 +1313,25 @@ static int __init omap_iommu_init(void)
2363 + return -ENOMEM;
2364 + iopte_cachep = p;
2365 +
2366 +- bus_set_iommu(&platform_bus_type, &omap_iommu_ops);
2367 +-
2368 + omap_iommu_debugfs_init();
2369 +
2370 +- return platform_driver_register(&omap_iommu_driver);
2371 ++ ret = platform_driver_register(&omap_iommu_driver);
2372 ++ if (ret) {
2373 ++ pr_err("%s: failed to register driver\n", __func__);
2374 ++ goto fail_driver;
2375 ++ }
2376 ++
2377 ++ ret = bus_set_iommu(&platform_bus_type, &omap_iommu_ops);
2378 ++ if (ret)
2379 ++ goto fail_bus;
2380 ++
2381 ++ return 0;
2382 ++
2383 ++fail_bus:
2384 ++ platform_driver_unregister(&omap_iommu_driver);
2385 ++fail_driver:
2386 ++ kmem_cache_destroy(iopte_cachep);
2387 ++ return ret;
2388 + }
2389 + subsys_initcall(omap_iommu_init);
2390 + /* must be ready before omap3isp is probed */
2391 +diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
2392 +index d74374f25392..abf696b49dd7 100644
2393 +--- a/drivers/irqchip/irq-mips-gic.c
2394 ++++ b/drivers/irqchip/irq-mips-gic.c
2395 +@@ -55,6 +55,7 @@ static unsigned int gic_cpu_pin;
2396 + static unsigned int timer_cpu_pin;
2397 + static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller;
2398 + DECLARE_BITMAP(ipi_resrv, GIC_MAX_INTRS);
2399 ++DECLARE_BITMAP(ipi_available, GIC_MAX_INTRS);
2400 +
2401 + static void __gic_irq_dispatch(void);
2402 +
2403 +@@ -746,17 +747,17 @@ static int gic_irq_domain_alloc(struct irq_domain *d, unsigned int virq,
2404 +
2405 + return gic_setup_dev_chip(d, virq, spec->hwirq);
2406 + } else {
2407 +- base_hwirq = find_first_bit(ipi_resrv, gic_shared_intrs);
2408 ++ base_hwirq = find_first_bit(ipi_available, gic_shared_intrs);
2409 + if (base_hwirq == gic_shared_intrs) {
2410 + return -ENOMEM;
2411 + }
2412 +
2413 + /* check that we have enough space */
2414 + for (i = base_hwirq; i < nr_irqs; i++) {
2415 +- if (!test_bit(i, ipi_resrv))
2416 ++ if (!test_bit(i, ipi_available))
2417 + return -EBUSY;
2418 + }
2419 +- bitmap_clear(ipi_resrv, base_hwirq, nr_irqs);
2420 ++ bitmap_clear(ipi_available, base_hwirq, nr_irqs);
2421 +
2422 + /* map the hwirq for each cpu consecutively */
2423 + i = 0;
2424 +@@ -787,7 +788,7 @@ static int gic_irq_domain_alloc(struct irq_domain *d, unsigned int virq,
2425 +
2426 + return 0;
2427 + error:
2428 +- bitmap_set(ipi_resrv, base_hwirq, nr_irqs);
2429 ++ bitmap_set(ipi_available, base_hwirq, nr_irqs);
2430 + return ret;
2431 + }
2432 +
2433 +@@ -802,7 +803,7 @@ void gic_irq_domain_free(struct irq_domain *d, unsigned int virq,
2434 + return;
2435 +
2436 + base_hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(data));
2437 +- bitmap_set(ipi_resrv, base_hwirq, nr_irqs);
2438 ++ bitmap_set(ipi_available, base_hwirq, nr_irqs);
2439 + }
2440 +
2441 + int gic_irq_domain_match(struct irq_domain *d, struct device_node *node,
2442 +@@ -1066,6 +1067,7 @@ static void __init __gic_init(unsigned long gic_base_addr,
2443 + 2 * gic_vpes);
2444 + }
2445 +
2446 ++ bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS);
2447 + gic_basic_init();
2448 + }
2449 +
2450 +diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
2451 +index d70d4a5273b8..454ed4dc6ec1 100644
2452 +--- a/drivers/leds/led-core.c
2453 ++++ b/drivers/leds/led-core.c
2454 +@@ -186,8 +186,9 @@ void led_blink_set(struct led_classdev *led_cdev,
2455 + unsigned long *delay_on,
2456 + unsigned long *delay_off)
2457 + {
2458 +- led_stop_software_blink(led_cdev);
2459 ++ del_timer_sync(&led_cdev->blink_timer);
2460 +
2461 ++ led_cdev->flags &= ~LED_BLINK_SW;
2462 + led_cdev->flags &= ~LED_BLINK_ONESHOT;
2463 + led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP;
2464 +
2465 +diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
2466 +index b19b551bb34b..18a4271bf569 100644
2467 +--- a/drivers/md/raid10.c
2468 ++++ b/drivers/md/raid10.c
2469 +@@ -2704,6 +2704,11 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
2470 + list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
2471 + conf->nr_queued++;
2472 + spin_unlock_irq(&conf->device_lock);
2473 ++ /*
2474 ++ * In case freeze_array() is waiting for condition
2475 ++ * nr_pending == nr_queued + extra to be true.
2476 ++ */
2477 ++ wake_up(&conf->wait_barrier);
2478 + md_wakeup_thread(conf->mddev->thread);
2479 + } else {
2480 + if (test_bit(R10BIO_WriteError,
2481 +@@ -4084,6 +4089,7 @@ static int raid10_start_reshape(struct mddev *mddev)
2482 + diff = 0;
2483 + if (first || diff < min_offset_diff)
2484 + min_offset_diff = diff;
2485 ++ first = 0;
2486 + }
2487 + }
2488 +
2489 +diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
2490 +index b5b5b195ea7f..42ce88ceac66 100644
2491 +--- a/drivers/media/dvb-core/dvb_ca_en50221.c
2492 ++++ b/drivers/media/dvb-core/dvb_ca_en50221.c
2493 +@@ -779,6 +779,29 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
2494 + goto exit;
2495 + }
2496 +
2497 ++ /*
2498 ++ * It may need some time for the CAM to settle down, or there might
2499 ++ * be a race condition between the CAM, writing HC and our last
2500 ++ * check for DA. This happens, if the CAM asserts DA, just after
2501 ++ * checking DA before we are setting HC. In this case it might be
2502 ++ * a bug in the CAM to keep the FR bit, the lower layer/HW
2503 ++ * communication requires a longer timeout or the CAM needs more
2504 ++ * time internally. But this happens in reality!
2505 ++ * We need to read the status from the HW again and do the same
2506 ++ * we did for the previous check for DA
2507 ++ */
2508 ++ status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
2509 ++ if (status < 0)
2510 ++ goto exit;
2511 ++
2512 ++ if (status & (STATUSREG_DA | STATUSREG_RE)) {
2513 ++ if (status & STATUSREG_DA)
2514 ++ dvb_ca_en50221_thread_wakeup(ca);
2515 ++
2516 ++ status = -EAGAIN;
2517 ++ goto exit;
2518 ++ }
2519 ++
2520 + /* send the amount of data */
2521 + if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0)
2522 + goto exit;
2523 +diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
2524 +index 20b4a659e2e4..0fe69f79a24d 100644
2525 +--- a/drivers/media/dvb-frontends/si2168.c
2526 ++++ b/drivers/media/dvb-frontends/si2168.c
2527 +@@ -14,6 +14,8 @@
2528 + * GNU General Public License for more details.
2529 + */
2530 +
2531 ++#include <linux/delay.h>
2532 ++
2533 + #include "si2168_priv.h"
2534 +
2535 + static const struct dvb_frontend_ops si2168_ops;
2536 +@@ -378,6 +380,7 @@ static int si2168_init(struct dvb_frontend *fe)
2537 + if (ret)
2538 + goto err;
2539 +
2540 ++ udelay(100);
2541 + memcpy(cmd.args, "\x85", 1);
2542 + cmd.wlen = 1;
2543 + cmd.rlen = 1;
2544 +diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
2545 +index 8aa726651630..90fcccc05b56 100644
2546 +--- a/drivers/media/pci/bt8xx/bt878.c
2547 ++++ b/drivers/media/pci/bt8xx/bt878.c
2548 +@@ -422,8 +422,7 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
2549 + bt878_num);
2550 + if (bt878_num >= BT878_MAX) {
2551 + printk(KERN_ERR "bt878: Too many devices inserted\n");
2552 +- result = -ENOMEM;
2553 +- goto fail0;
2554 ++ return -ENOMEM;
2555 + }
2556 + if (pci_enable_device(dev))
2557 + return -EIO;
2558 +diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
2559 +index 30c148b9d65e..06e2cfd09855 100644
2560 +--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
2561 ++++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
2562 +@@ -83,7 +83,7 @@ static void c8sectpfe_timer_interrupt(unsigned long ac8sectpfei)
2563 + static void channel_swdemux_tsklet(unsigned long data)
2564 + {
2565 + struct channel_info *channel = (struct channel_info *)data;
2566 +- struct c8sectpfei *fei = channel->fei;
2567 ++ struct c8sectpfei *fei;
2568 + unsigned long wp, rp;
2569 + int pos, num_packets, n, size;
2570 + u8 *buf;
2571 +@@ -91,6 +91,8 @@ static void channel_swdemux_tsklet(unsigned long data)
2572 + if (unlikely(!channel || !channel->irec))
2573 + return;
2574 +
2575 ++ fei = channel->fei;
2576 ++
2577 + wp = readl(channel->irec + DMA_PRDS_BUSWP_TP(0));
2578 + rp = readl(channel->irec + DMA_PRDS_BUSRP_TP(0));
2579 +
2580 +diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
2581 +index 8f8bacb67a15..a6b5259ffbdd 100644
2582 +--- a/drivers/mfd/palmas.c
2583 ++++ b/drivers/mfd/palmas.c
2584 +@@ -430,6 +430,20 @@ static void palmas_power_off(void)
2585 + {
2586 + unsigned int addr;
2587 + int ret, slave;
2588 ++ struct device_node *np = palmas_dev->dev->of_node;
2589 ++
2590 ++ if (of_property_read_bool(np, "ti,palmas-override-powerhold")) {
2591 ++ addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
2592 ++ PALMAS_PRIMARY_SECONDARY_PAD2);
2593 ++ slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
2594 ++
2595 ++ ret = regmap_update_bits(palmas_dev->regmap[slave], addr,
2596 ++ PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_7_MASK, 0);
2597 ++ if (ret)
2598 ++ dev_err(palmas_dev->dev,
2599 ++ "Unable to write PRIMARY_SECONDARY_PAD2 %d\n",
2600 ++ ret);
2601 ++ }
2602 +
2603 + if (!palmas_dev)
2604 + return;
2605 +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
2606 +index 2553d903a82b..cff5829790c9 100644
2607 +--- a/drivers/mmc/core/core.c
2608 ++++ b/drivers/mmc/core/core.c
2609 +@@ -2974,6 +2974,14 @@ static int mmc_pm_notify(struct notifier_block *notify_block,
2610 + if (!err)
2611 + break;
2612 +
2613 ++ if (!mmc_card_is_removable(host)) {
2614 ++ dev_warn(mmc_dev(host),
2615 ++ "pre_suspend failed for non-removable host: "
2616 ++ "%d\n", err);
2617 ++ /* Avoid removing non-removable hosts */
2618 ++ break;
2619 ++ }
2620 ++
2621 + /* Calling bus_ops->remove() with a claimed host can deadlock */
2622 + host->bus_ops->remove(host);
2623 + mmc_claim_host(host);
2624 +diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
2625 +index 5f2f24a7360d..a082aa330f47 100644
2626 +--- a/drivers/mmc/host/omap_hsmmc.c
2627 ++++ b/drivers/mmc/host/omap_hsmmc.c
2628 +@@ -1762,8 +1762,8 @@ static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host)
2629 + */
2630 + if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) {
2631 + struct pinctrl *p = devm_pinctrl_get(host->dev);
2632 +- if (!p) {
2633 +- ret = -ENODEV;
2634 ++ if (IS_ERR(p)) {
2635 ++ ret = PTR_ERR(p);
2636 + goto err_free_irq;
2637 + }
2638 + if (IS_ERR(pinctrl_lookup_state(p, PINCTRL_STATE_DEFAULT))) {
2639 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
2640 +index 3c27401cf7fe..a51d636c2312 100644
2641 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
2642 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
2643 +@@ -432,6 +432,20 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
2644 + if (esdhc->vendor_ver < VENDOR_V_23)
2645 + pre_div = 2;
2646 +
2647 ++ /*
2648 ++ * Limit SD clock to 167MHz for ls1046a according to its datasheet
2649 ++ */
2650 ++ if (clock > 167000000 &&
2651 ++ of_find_compatible_node(NULL, NULL, "fsl,ls1046a-esdhc"))
2652 ++ clock = 167000000;
2653 ++
2654 ++ /*
2655 ++ * Limit SD clock to 125MHz for ls1012a according to its datasheet
2656 ++ */
2657 ++ if (clock > 125000000 &&
2658 ++ of_find_compatible_node(NULL, NULL, "fsl,ls1012a-esdhc"))
2659 ++ clock = 125000000;
2660 ++
2661 + /* Workaround to reduce the clock frequency for p1010 esdhc */
2662 + if (of_find_compatible_node(NULL, NULL, "fsl,p1010-esdhc")) {
2663 + if (clock > 20000000)
2664 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
2665 +index c3f3096b24ae..4907c9b57565 100644
2666 +--- a/drivers/net/bonding/bond_main.c
2667 ++++ b/drivers/net/bonding/bond_main.c
2668 +@@ -2067,6 +2067,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2669 + (bond->params.downdelay - slave->delay) *
2670 + bond->params.miimon,
2671 + slave->dev->name);
2672 ++ commit++;
2673 + continue;
2674 + }
2675 +
2676 +@@ -2104,7 +2105,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2677 + (bond->params.updelay - slave->delay) *
2678 + bond->params.miimon,
2679 + slave->dev->name);
2680 +-
2681 ++ commit++;
2682 + continue;
2683 + }
2684 +
2685 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2686 +index 596f88b693ef..ca6c4718000f 100644
2687 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2688 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2689 +@@ -2026,6 +2026,7 @@ static void bnx2x_set_rx_buf_size(struct bnx2x *bp)
2690 + ETH_OVREHEAD +
2691 + mtu +
2692 + BNX2X_FW_RX_ALIGN_END;
2693 ++ fp->rx_buf_size = SKB_DATA_ALIGN(fp->rx_buf_size);
2694 + /* Note : rx_buf_size doesn't take into account NET_SKB_PAD */
2695 + if (fp->rx_buf_size + NET_SKB_PAD <= PAGE_SIZE)
2696 + fp->rx_frag_size = fp->rx_buf_size + NET_SKB_PAD;
2697 +diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
2698 +index f76d33279454..ef9bc26ebc1a 100644
2699 +--- a/drivers/net/ethernet/freescale/ucc_geth.c
2700 ++++ b/drivers/net/ethernet/freescale/ucc_geth.c
2701 +@@ -2594,11 +2594,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2702 + } else if (ugeth->ug_info->uf_info.bd_mem_part ==
2703 + MEM_PART_MURAM) {
2704 + out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base,
2705 +- (u32) immrbar_virt_to_phys(ugeth->
2706 +- p_tx_bd_ring[i]));
2707 ++ (u32)qe_muram_dma(ugeth->p_tx_bd_ring[i]));
2708 + out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].
2709 + last_bd_completed_address,
2710 +- (u32) immrbar_virt_to_phys(endOfRing));
2711 ++ (u32)qe_muram_dma(endOfRing));
2712 + }
2713 + }
2714 +
2715 +@@ -2844,8 +2843,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2716 + } else if (ugeth->ug_info->uf_info.bd_mem_part ==
2717 + MEM_PART_MURAM) {
2718 + out_be32(&ugeth->p_rx_bd_qs_tbl[i].externalbdbaseptr,
2719 +- (u32) immrbar_virt_to_phys(ugeth->
2720 +- p_rx_bd_ring[i]));
2721 ++ (u32)qe_muram_dma(ugeth->p_rx_bd_ring[i]));
2722 + }
2723 + /* rest of fields handled by QE */
2724 + }
2725 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
2726 +index 02a03bccde7b..34b5e699a1d5 100644
2727 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
2728 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
2729 +@@ -671,7 +671,7 @@ static void hns_gmac_get_strings(u32 stringset, u8 *data)
2730 +
2731 + static int hns_gmac_get_sset_count(int stringset)
2732 + {
2733 +- if (stringset == ETH_SS_STATS)
2734 ++ if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
2735 + return ARRAY_SIZE(g_gmac_stats_string);
2736 +
2737 + return 0;
2738 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
2739 +index 6ea872287307..4ecb809785f9 100644
2740 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
2741 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
2742 +@@ -422,7 +422,7 @@ void hns_ppe_update_stats(struct hns_ppe_cb *ppe_cb)
2743 +
2744 + int hns_ppe_get_sset_count(int stringset)
2745 + {
2746 +- if (stringset == ETH_SS_STATS)
2747 ++ if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
2748 + return ETH_PPE_STATIC_NUM;
2749 + return 0;
2750 + }
2751 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
2752 +index f3be9ac47bfb..fbbbbffd58dc 100644
2753 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
2754 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
2755 +@@ -798,7 +798,7 @@ void hns_rcb_get_stats(struct hnae_queue *queue, u64 *data)
2756 + */
2757 + int hns_rcb_get_ring_sset_count(int stringset)
2758 + {
2759 +- if (stringset == ETH_SS_STATS)
2760 ++ if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
2761 + return HNS_RING_STATIC_REG_NUM;
2762 +
2763 + return 0;
2764 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
2765 +index 8f4f0e8da984..d1c868c800f9 100644
2766 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
2767 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
2768 +@@ -776,7 +776,7 @@ static void hns_xgmac_get_strings(u32 stringset, u8 *data)
2769 + */
2770 + static int hns_xgmac_get_sset_count(int stringset)
2771 + {
2772 +- if (stringset == ETH_SS_STATS)
2773 ++ if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
2774 + return ARRAY_SIZE(g_xgmac_stats_string);
2775 +
2776 + return 0;
2777 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
2778 +index 7c6c1468628b..49094c965697 100644
2779 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
2780 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
2781 +@@ -511,6 +511,23 @@ static int ibmvnic_open(struct net_device *netdev)
2782 + return -ENOMEM;
2783 + }
2784 +
2785 ++static void disable_sub_crqs(struct ibmvnic_adapter *adapter)
2786 ++{
2787 ++ int i;
2788 ++
2789 ++ if (adapter->tx_scrq) {
2790 ++ for (i = 0; i < adapter->req_tx_queues; i++)
2791 ++ if (adapter->tx_scrq[i])
2792 ++ disable_irq(adapter->tx_scrq[i]->irq);
2793 ++ }
2794 ++
2795 ++ if (adapter->rx_scrq) {
2796 ++ for (i = 0; i < adapter->req_rx_queues; i++)
2797 ++ if (adapter->rx_scrq[i])
2798 ++ disable_irq(adapter->rx_scrq[i]->irq);
2799 ++ }
2800 ++}
2801 ++
2802 + static int ibmvnic_close(struct net_device *netdev)
2803 + {
2804 + struct ibmvnic_adapter *adapter = netdev_priv(netdev);
2805 +@@ -519,6 +536,7 @@ static int ibmvnic_close(struct net_device *netdev)
2806 + int i;
2807 +
2808 + adapter->closing = true;
2809 ++ disable_sub_crqs(adapter);
2810 +
2811 + for (i = 0; i < adapter->req_rx_queues; i++)
2812 + napi_disable(&adapter->napi[i]);
2813 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
2814 +index 0feddf3393f9..528a926dd979 100644
2815 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
2816 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
2817 +@@ -3528,6 +3528,12 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
2818 +
2819 + switch (hw->mac.type) {
2820 + case e1000_pch2lan:
2821 ++ /* Stable 96MHz frequency */
2822 ++ incperiod = INCPERIOD_96MHz;
2823 ++ incvalue = INCVALUE_96MHz;
2824 ++ shift = INCVALUE_SHIFT_96MHz;
2825 ++ adapter->cc.shift = shift + INCPERIOD_SHIFT_96MHz;
2826 ++ break;
2827 + case e1000_pch_lpt:
2828 + if (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI) {
2829 + /* Stable 96MHz frequency */
2830 +diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
2831 +index 508e72c5f1c2..d665de8849a2 100644
2832 +--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
2833 ++++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
2834 +@@ -80,7 +80,7 @@ static struct ixgbe_stats ixgbevf_gstrings_stats[] = {
2835 + #define IXGBEVF_QUEUE_STATS_LEN ( \
2836 + (((struct ixgbevf_adapter *)netdev_priv(netdev))->num_tx_queues + \
2837 + ((struct ixgbevf_adapter *)netdev_priv(netdev))->num_rx_queues) * \
2838 +- (sizeof(struct ixgbe_stats) / sizeof(u64)))
2839 ++ (sizeof(struct ixgbevf_stats) / sizeof(u64)))
2840 + #define IXGBEVF_GLOBAL_STATS_LEN ARRAY_SIZE(ixgbevf_gstrings_stats)
2841 +
2842 + #define IXGBEVF_STATS_LEN (IXGBEVF_GLOBAL_STATS_LEN + IXGBEVF_QUEUE_STATS_LEN)
2843 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
2844 +index abf5bf11f865..0645124a887b 100644
2845 +--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
2846 ++++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
2847 +@@ -204,7 +204,7 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn)
2848 + /* send acquire request */
2849 + rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
2850 + if (rc)
2851 +- return rc;
2852 ++ goto exit;
2853 +
2854 + /* copy acquire response from buffer to p_hwfn */
2855 + memcpy(&p_iov->acquire_resp, resp, sizeof(p_iov->acquire_resp));
2856 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2857 +index d7107055ec60..2f656f395f39 100644
2858 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2859 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
2860 +@@ -128,6 +128,8 @@ static int qlcnic_sriov_virtid_fn(struct qlcnic_adapter *adapter, int vf_id)
2861 + return 0;
2862 +
2863 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV);
2864 ++ if (!pos)
2865 ++ return 0;
2866 + pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
2867 + pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);
2868 +
2869 +diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
2870 +index c2ac39a940f7..14f58b60d1b5 100644
2871 +--- a/drivers/net/hyperv/netvsc.c
2872 ++++ b/drivers/net/hyperv/netvsc.c
2873 +@@ -151,6 +151,13 @@ static void netvsc_destroy_buf(struct hv_device *device)
2874 + sizeof(struct nvsp_message),
2875 + (unsigned long)revoke_packet,
2876 + VM_PKT_DATA_INBAND, 0);
2877 ++ /* If the failure is because the channel is rescinded;
2878 ++ * ignore the failure since we cannot send on a rescinded
2879 ++ * channel. This would allow us to properly cleanup
2880 ++ * even when the channel is rescinded.
2881 ++ */
2882 ++ if (device->channel->rescind)
2883 ++ ret = 0;
2884 + /*
2885 + * If we failed here, we might as well return and
2886 + * have a leak rather than continue and a bugchk
2887 +@@ -211,6 +218,15 @@ static void netvsc_destroy_buf(struct hv_device *device)
2888 + sizeof(struct nvsp_message),
2889 + (unsigned long)revoke_packet,
2890 + VM_PKT_DATA_INBAND, 0);
2891 ++
2892 ++ /* If the failure is because the channel is rescinded;
2893 ++ * ignore the failure since we cannot send on a rescinded
2894 ++ * channel. This would allow us to properly cleanup
2895 ++ * even when the channel is rescinded.
2896 ++ */
2897 ++ if (device->channel->rescind)
2898 ++ ret = 0;
2899 ++
2900 + /* If we failed here, we might as well return and
2901 + * have a leak rather than continue and a bugchk
2902 + */
2903 +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
2904 +index a30d6a6dbd95..973e90fb4a24 100644
2905 +--- a/drivers/net/usb/qmi_wwan.c
2906 ++++ b/drivers/net/usb/qmi_wwan.c
2907 +@@ -531,7 +531,7 @@ static int qmi_wwan_resume(struct usb_interface *intf)
2908 +
2909 + static const struct driver_info qmi_wwan_info = {
2910 + .description = "WWAN/QMI device",
2911 +- .flags = FLAG_WWAN,
2912 ++ .flags = FLAG_WWAN | FLAG_SEND_ZLP,
2913 + .bind = qmi_wwan_bind,
2914 + .unbind = qmi_wwan_unbind,
2915 + .manage_power = qmi_wwan_manage_power,
2916 +@@ -540,7 +540,7 @@ static const struct driver_info qmi_wwan_info = {
2917 +
2918 + static const struct driver_info qmi_wwan_info_quirk_dtr = {
2919 + .description = "WWAN/QMI device",
2920 +- .flags = FLAG_WWAN,
2921 ++ .flags = FLAG_WWAN | FLAG_SEND_ZLP,
2922 + .bind = qmi_wwan_bind,
2923 + .unbind = qmi_wwan_unbind,
2924 + .manage_power = qmi_wwan_manage_power,
2925 +diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
2926 +index 50570d779b01..0f5dfb8a545d 100644
2927 +--- a/drivers/net/vxlan.c
2928 ++++ b/drivers/net/vxlan.c
2929 +@@ -2816,17 +2816,21 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6)
2930 +
2931 + static int vxlan_sock_add(struct vxlan_dev *vxlan)
2932 + {
2933 +- bool ipv6 = vxlan->flags & VXLAN_F_IPV6;
2934 + bool metadata = vxlan->flags & VXLAN_F_COLLECT_METADATA;
2935 ++ bool ipv6 = vxlan->flags & VXLAN_F_IPV6 || metadata;
2936 ++ bool ipv4 = !ipv6 || metadata;
2937 + int ret = 0;
2938 +
2939 + RCU_INIT_POINTER(vxlan->vn4_sock, NULL);
2940 + #if IS_ENABLED(CONFIG_IPV6)
2941 + RCU_INIT_POINTER(vxlan->vn6_sock, NULL);
2942 +- if (ipv6 || metadata)
2943 ++ if (ipv6) {
2944 + ret = __vxlan_sock_add(vxlan, true);
2945 ++ if (ret < 0 && ret != -EAFNOSUPPORT)
2946 ++ ipv4 = false;
2947 ++ }
2948 + #endif
2949 +- if (!ret && (!ipv6 || metadata))
2950 ++ if (ipv4)
2951 + ret = __vxlan_sock_add(vxlan, false);
2952 + if (ret < 0)
2953 + vxlan_sock_release(vxlan);
2954 +diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
2955 +index db363856e0b5..2b064998915f 100644
2956 +--- a/drivers/net/wan/pc300too.c
2957 ++++ b/drivers/net/wan/pc300too.c
2958 +@@ -347,6 +347,7 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
2959 + card->rambase == NULL) {
2960 + pr_err("ioremap() failed\n");
2961 + pc300_pci_remove_one(pdev);
2962 ++ return -ENOMEM;
2963 + }
2964 +
2965 + /* PLX PCI 9050 workaround for local configuration register read bug */
2966 +diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
2967 +index 6aa2b93497dd..0dadc6044dba 100644
2968 +--- a/drivers/net/wireless/ath/ath10k/debug.c
2969 ++++ b/drivers/net/wireless/ath/ath10k/debug.c
2970 +@@ -624,17 +624,21 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
2971 + size_t count, loff_t *ppos)
2972 + {
2973 + struct ath10k *ar = file->private_data;
2974 +- char buf[32];
2975 ++ char buf[32] = {0};
2976 ++ ssize_t rc;
2977 + int ret;
2978 +
2979 +- simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
2980 ++ /* filter partial writes and invalid commands */
2981 ++ if (*ppos != 0 || count >= sizeof(buf) || count == 0)
2982 ++ return -EINVAL;
2983 +
2984 +- /* make sure that buf is null terminated */
2985 +- buf[sizeof(buf) - 1] = 0;
2986 ++ rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
2987 ++ if (rc < 0)
2988 ++ return rc;
2989 +
2990 + /* drop the possible '\n' from the end */
2991 +- if (buf[count - 1] == '\n')
2992 +- buf[count - 1] = 0;
2993 ++ if (buf[*ppos - 1] == '\n')
2994 ++ buf[*ppos - 1] = '\0';
2995 +
2996 + mutex_lock(&ar->conf_mutex);
2997 +
2998 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
2999 +index 1e6e63dbd61c..a497bf31953d 100644
3000 +--- a/drivers/net/wireless/ath/ath10k/mac.c
3001 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
3002 +@@ -2505,7 +2505,7 @@ static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
3003 + }
3004 + break;
3005 + case WMI_VDEV_TYPE_STA:
3006 +- if (vif->bss_conf.qos)
3007 ++ if (sta->wme)
3008 + arg->peer_flags |= arvif->ar->wmi.peer_flags->qos;
3009 + break;
3010 + case WMI_VDEV_TYPE_IBSS:
3011 +diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
3012 +index f8506037736f..404fc306cb2a 100644
3013 +--- a/drivers/net/wireless/ath/regd.c
3014 ++++ b/drivers/net/wireless/ath/regd.c
3015 +@@ -254,8 +254,12 @@ bool ath_is_49ghz_allowed(u16 regdomain)
3016 + EXPORT_SYMBOL(ath_is_49ghz_allowed);
3017 +
3018 + /* Frequency is one where radar detection is required */
3019 +-static bool ath_is_radar_freq(u16 center_freq)
3020 ++static bool ath_is_radar_freq(u16 center_freq,
3021 ++ struct ath_regulatory *reg)
3022 ++
3023 + {
3024 ++ if (reg->country_code == CTRY_INDIA)
3025 ++ return (center_freq >= 5500 && center_freq <= 5700);
3026 + return (center_freq >= 5260 && center_freq <= 5700);
3027 + }
3028 +
3029 +@@ -306,7 +310,7 @@ __ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
3030 + enum nl80211_reg_initiator initiator,
3031 + struct ieee80211_channel *ch)
3032 + {
3033 +- if (ath_is_radar_freq(ch->center_freq) ||
3034 ++ if (ath_is_radar_freq(ch->center_freq, reg) ||
3035 + (ch->flags & IEEE80211_CHAN_RADAR))
3036 + return;
3037 +
3038 +@@ -395,8 +399,9 @@ ath_reg_apply_ir_flags(struct wiphy *wiphy,
3039 + }
3040 + }
3041 +
3042 +-/* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
3043 +-static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
3044 ++/* Always apply Radar/DFS rules on freq range 5500 MHz - 5700 MHz */
3045 ++static void ath_reg_apply_radar_flags(struct wiphy *wiphy,
3046 ++ struct ath_regulatory *reg)
3047 + {
3048 + struct ieee80211_supported_band *sband;
3049 + struct ieee80211_channel *ch;
3050 +@@ -409,7 +414,7 @@ static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
3051 +
3052 + for (i = 0; i < sband->n_channels; i++) {
3053 + ch = &sband->channels[i];
3054 +- if (!ath_is_radar_freq(ch->center_freq))
3055 ++ if (!ath_is_radar_freq(ch->center_freq, reg))
3056 + continue;
3057 + /* We always enable radar detection/DFS on this
3058 + * frequency range. Additionally we also apply on
3059 +@@ -505,7 +510,7 @@ void ath_reg_notifier_apply(struct wiphy *wiphy,
3060 + struct ath_common *common = container_of(reg, struct ath_common,
3061 + regulatory);
3062 + /* We always apply this */
3063 +- ath_reg_apply_radar_flags(wiphy);
3064 ++ ath_reg_apply_radar_flags(wiphy, reg);
3065 +
3066 + /*
3067 + * This would happen when we have sent a custom regulatory request
3068 +@@ -653,7 +658,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,
3069 + }
3070 +
3071 + wiphy_apply_custom_regulatory(wiphy, regd);
3072 +- ath_reg_apply_radar_flags(wiphy);
3073 ++ ath_reg_apply_radar_flags(wiphy, reg);
3074 + ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
3075 + return 0;
3076 + }
3077 +diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-a000.c b/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
3078 +index ea1618525878..e267377edbe7 100644
3079 +--- a/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
3080 ++++ b/drivers/net/wireless/intel/iwlwifi/iwl-a000.c
3081 +@@ -65,12 +65,12 @@
3082 + #define IWL_A000_TX_POWER_VERSION 0xffff /* meaningless */
3083 +
3084 + /* Memory offsets and lengths */
3085 +-#define IWL_A000_DCCM_OFFSET 0x800000
3086 +-#define IWL_A000_DCCM_LEN 0x18000
3087 ++#define IWL_A000_DCCM_OFFSET 0x800000 /* LMAC1 */
3088 ++#define IWL_A000_DCCM_LEN 0x10000 /* LMAC1 */
3089 + #define IWL_A000_DCCM2_OFFSET 0x880000
3090 + #define IWL_A000_DCCM2_LEN 0x8000
3091 + #define IWL_A000_SMEM_OFFSET 0x400000
3092 +-#define IWL_A000_SMEM_LEN 0x68000
3093 ++#define IWL_A000_SMEM_LEN 0xD0000
3094 +
3095 + #define IWL_A000_FW_PRE "iwlwifi-Qu-a0-jf-b0-"
3096 + #define IWL_A000_MODULE_FIRMWARE(api) \
3097 +diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
3098 +index 88f260db3744..68412ff2112e 100644
3099 +--- a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
3100 ++++ b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
3101 +@@ -76,8 +76,8 @@ void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_wait)
3102 + }
3103 + IWL_EXPORT_SYMBOL(iwl_notification_wait_init);
3104 +
3105 +-void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_wait,
3106 +- struct iwl_rx_packet *pkt)
3107 ++bool iwl_notification_wait(struct iwl_notif_wait_data *notif_wait,
3108 ++ struct iwl_rx_packet *pkt)
3109 + {
3110 + bool triggered = false;
3111 +
3112 +@@ -118,13 +118,11 @@ void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_wait,
3113 + }
3114 + }
3115 + spin_unlock(&notif_wait->notif_wait_lock);
3116 +-
3117 + }
3118 +
3119 +- if (triggered)
3120 +- wake_up_all(&notif_wait->notif_waitq);
3121 ++ return triggered;
3122 + }
3123 +-IWL_EXPORT_SYMBOL(iwl_notification_wait_notify);
3124 ++IWL_EXPORT_SYMBOL(iwl_notification_wait);
3125 +
3126 + void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_wait)
3127 + {
3128 +diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.h b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.h
3129 +index 0f9995ed71cd..368884be4e7c 100644
3130 +--- a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.h
3131 ++++ b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.h
3132 +@@ -6,7 +6,7 @@
3133 + * GPL LICENSE SUMMARY
3134 + *
3135 + * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
3136 +- * Copyright(c) 2015 Intel Deutschland GmbH
3137 ++ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
3138 + *
3139 + * This program is free software; you can redistribute it and/or modify
3140 + * it under the terms of version 2 of the GNU General Public License as
3141 +@@ -32,6 +32,7 @@
3142 + * BSD LICENSE
3143 + *
3144 + * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
3145 ++ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
3146 + * All rights reserved.
3147 + *
3148 + * Redistribution and use in source and binary forms, with or without
3149 +@@ -89,10 +90,10 @@ struct iwl_notif_wait_data {
3150 + *
3151 + * This structure is not used directly, to wait for a
3152 + * notification declare it on the stack, and call
3153 +- * iwlagn_init_notification_wait() with appropriate
3154 ++ * iwl_init_notification_wait() with appropriate
3155 + * parameters. Then do whatever will cause the ucode
3156 + * to notify the driver, and to wait for that then
3157 +- * call iwlagn_wait_notification().
3158 ++ * call iwl_wait_notification().
3159 + *
3160 + * Each notification is one-shot. If at some point we
3161 + * need to support multi-shot notifications (which
3162 +@@ -114,10 +115,24 @@ struct iwl_notification_wait {
3163 +
3164 + /* caller functions */
3165 + void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_data);
3166 +-void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data,
3167 +- struct iwl_rx_packet *pkt);
3168 ++bool iwl_notification_wait(struct iwl_notif_wait_data *notif_data,
3169 ++ struct iwl_rx_packet *pkt);
3170 + void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_data);
3171 +
3172 ++static inline void
3173 ++iwl_notification_notify(struct iwl_notif_wait_data *notif_data)
3174 ++{
3175 ++ wake_up_all(&notif_data->notif_waitq);
3176 ++}
3177 ++
3178 ++static inline void
3179 ++iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data,
3180 ++ struct iwl_rx_packet *pkt)
3181 ++{
3182 ++ if (iwl_notification_wait(notif_data, pkt))
3183 ++ iwl_notification_notify(notif_data);
3184 ++}
3185 ++
3186 + /* user functions */
3187 + void __acquires(wait_entry)
3188 + iwl_init_notification_wait(struct iwl_notif_wait_data *notif_data,
3189 +diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c b/drivers/net/wireless/marvell/libertas/if_spi.c
3190 +index c3a53cd6988e..7b4955cc38db 100644
3191 +--- a/drivers/net/wireless/marvell/libertas/if_spi.c
3192 ++++ b/drivers/net/wireless/marvell/libertas/if_spi.c
3193 +@@ -1181,6 +1181,10 @@ static int if_spi_probe(struct spi_device *spi)
3194 +
3195 + /* Initialize interrupt handling stuff. */
3196 + card->workqueue = alloc_workqueue("libertas_spi", WQ_MEM_RECLAIM, 0);
3197 ++ if (!card->workqueue) {
3198 ++ err = -ENOMEM;
3199 ++ goto remove_card;
3200 ++ }
3201 + INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
3202 + INIT_WORK(&card->resume_work, if_spi_resume_worker);
3203 +
3204 +@@ -1209,6 +1213,7 @@ static int if_spi_probe(struct spi_device *spi)
3205 + free_irq(spi->irq, card);
3206 + terminate_workqueue:
3207 + destroy_workqueue(card->workqueue);
3208 ++remove_card:
3209 + lbs_remove_card(priv); /* will call free_netdev */
3210 + free_card:
3211 + free_if_spi_card(card);
3212 +diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
3213 +index 2478ccd6f2d9..1e36f11831a9 100644
3214 +--- a/drivers/net/wireless/marvell/mwifiex/main.c
3215 ++++ b/drivers/net/wireless/marvell/mwifiex/main.c
3216 +@@ -146,7 +146,6 @@ static int mwifiex_unregister(struct mwifiex_adapter *adapter)
3217 +
3218 + kfree(adapter->regd);
3219 +
3220 +- vfree(adapter->chan_stats);
3221 + kfree(adapter);
3222 + return 0;
3223 + }
3224 +@@ -636,6 +635,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
3225 + goto done;
3226 +
3227 + err_add_intf:
3228 ++ vfree(adapter->chan_stats);
3229 + wiphy_unregister(adapter->wiphy);
3230 + wiphy_free(adapter->wiphy);
3231 + err_init_fw:
3232 +@@ -1429,6 +1429,7 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter, struct semaphore *sem)
3233 + mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
3234 + rtnl_unlock();
3235 + }
3236 ++ vfree(adapter->chan_stats);
3237 +
3238 + up(sem);
3239 + exit_sem_err:
3240 +@@ -1729,6 +1730,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
3241 + mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
3242 + rtnl_unlock();
3243 + }
3244 ++ vfree(adapter->chan_stats);
3245 +
3246 + wiphy_unregister(adapter->wiphy);
3247 + wiphy_free(adapter->wiphy);
3248 +diff --git a/drivers/net/wireless/mediatek/mt7601u/mcu.c b/drivers/net/wireless/mediatek/mt7601u/mcu.c
3249 +index dbdfb3f5c507..a9f5f398b2f8 100644
3250 +--- a/drivers/net/wireless/mediatek/mt7601u/mcu.c
3251 ++++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
3252 +@@ -66,8 +66,10 @@ mt7601u_mcu_msg_alloc(struct mt7601u_dev *dev, const void *data, int len)
3253 + WARN_ON(len % 4); /* if length is not divisible by 4 we need to pad */
3254 +
3255 + skb = alloc_skb(len + MT_DMA_HDR_LEN + 4, GFP_KERNEL);
3256 +- skb_reserve(skb, MT_DMA_HDR_LEN);
3257 +- memcpy(skb_put(skb, len), data, len);
3258 ++ if (skb) {
3259 ++ skb_reserve(skb, MT_DMA_HDR_LEN);
3260 ++ memcpy(skb_put(skb, len), data, len);
3261 ++ }
3262 +
3263 + return skb;
3264 + }
3265 +@@ -170,6 +172,8 @@ static int mt7601u_mcu_function_select(struct mt7601u_dev *dev,
3266 + };
3267 +
3268 + skb = mt7601u_mcu_msg_alloc(dev, &msg, sizeof(msg));
3269 ++ if (!skb)
3270 ++ return -ENOMEM;
3271 + return mt7601u_mcu_msg_send(dev, skb, CMD_FUN_SET_OP, func == 5);
3272 + }
3273 +
3274 +@@ -205,6 +209,8 @@ mt7601u_mcu_calibrate(struct mt7601u_dev *dev, enum mcu_calibrate cal, u32 val)
3275 + };
3276 +
3277 + skb = mt7601u_mcu_msg_alloc(dev, &msg, sizeof(msg));
3278 ++ if (!skb)
3279 ++ return -ENOMEM;
3280 + return mt7601u_mcu_msg_send(dev, skb, CMD_CALIBRATION_OP, true);
3281 + }
3282 +
3283 +diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
3284 +index 75ffeaa54ed8..e15b462d096b 100644
3285 +--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
3286 ++++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
3287 +@@ -1572,7 +1572,14 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
3288 + dev_kfree_skb_irq(skb);
3289 + ring->idx = (ring->idx + 1) % ring->entries;
3290 + }
3291 ++
3292 ++ if (rtlpriv->use_new_trx_flow) {
3293 ++ rtlpci->tx_ring[i].cur_tx_rp = 0;
3294 ++ rtlpci->tx_ring[i].cur_tx_wp = 0;
3295 ++ }
3296 ++
3297 + ring->idx = 0;
3298 ++ ring->entries = rtlpci->txringcount[i];
3299 + }
3300 + }
3301 + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
3302 +diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
3303 +index 603c90470225..15b2350d9f45 100644
3304 +--- a/drivers/net/wireless/rndis_wlan.c
3305 ++++ b/drivers/net/wireless/rndis_wlan.c
3306 +@@ -3427,6 +3427,10 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
3307 +
3308 + /* because rndis_command() sleeps we need to use workqueue */
3309 + priv->workqueue = create_singlethread_workqueue("rndis_wlan");
3310 ++ if (!priv->workqueue) {
3311 ++ wiphy_free(wiphy);
3312 ++ return -ENOMEM;
3313 ++ }
3314 + INIT_WORK(&priv->work, rndis_wlan_worker);
3315 + INIT_DELAYED_WORK(&priv->dev_poller_work, rndis_device_poller);
3316 + INIT_DELAYED_WORK(&priv->scan_work, rndis_get_scan_results);
3317 +diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
3318 +index fb38e208f32d..735d8f7f9d71 100644
3319 +--- a/drivers/pinctrl/core.c
3320 ++++ b/drivers/pinctrl/core.c
3321 +@@ -992,19 +992,16 @@ struct pinctrl_state *pinctrl_lookup_state(struct pinctrl *p,
3322 + EXPORT_SYMBOL_GPL(pinctrl_lookup_state);
3323 +
3324 + /**
3325 +- * pinctrl_select_state() - select/activate/program a pinctrl state to HW
3326 ++ * pinctrl_commit_state() - select/activate/program a pinctrl state to HW
3327 + * @p: the pinctrl handle for the device that requests configuration
3328 + * @state: the state handle to select/activate/program
3329 + */
3330 +-int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
3331 ++static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
3332 + {
3333 + struct pinctrl_setting *setting, *setting2;
3334 + struct pinctrl_state *old_state = p->state;
3335 + int ret;
3336 +
3337 +- if (p->state == state)
3338 +- return 0;
3339 +-
3340 + if (p->state) {
3341 + /*
3342 + * For each pinmux setting in the old state, forget SW's record
3343 +@@ -1068,6 +1065,19 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
3344 +
3345 + return ret;
3346 + }
3347 ++
3348 ++/**
3349 ++ * pinctrl_select_state() - select/activate/program a pinctrl state to HW
3350 ++ * @p: the pinctrl handle for the device that requests configuration
3351 ++ * @state: the state handle to select/activate/program
3352 ++ */
3353 ++int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
3354 ++{
3355 ++ if (p->state == state)
3356 ++ return 0;
3357 ++
3358 ++ return pinctrl_commit_state(p, state);
3359 ++}
3360 + EXPORT_SYMBOL_GPL(pinctrl_select_state);
3361 +
3362 + static void devm_pinctrl_release(struct device *dev, void *res)
3363 +@@ -1236,7 +1246,7 @@ void pinctrl_unregister_map(struct pinctrl_map const *map)
3364 + int pinctrl_force_sleep(struct pinctrl_dev *pctldev)
3365 + {
3366 + if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_sleep))
3367 +- return pinctrl_select_state(pctldev->p, pctldev->hog_sleep);
3368 ++ return pinctrl_commit_state(pctldev->p, pctldev->hog_sleep);
3369 + return 0;
3370 + }
3371 + EXPORT_SYMBOL_GPL(pinctrl_force_sleep);
3372 +@@ -1248,7 +1258,7 @@ EXPORT_SYMBOL_GPL(pinctrl_force_sleep);
3373 + int pinctrl_force_default(struct pinctrl_dev *pctldev)
3374 + {
3375 + if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_default))
3376 +- return pinctrl_select_state(pctldev->p, pctldev->hog_default);
3377 ++ return pinctrl_commit_state(pctldev->p, pctldev->hog_default);
3378 + return 0;
3379 + }
3380 + EXPORT_SYMBOL_GPL(pinctrl_force_default);
3381 +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
3382 +index 49bf7dcb7ed8..f826793e972c 100644
3383 +--- a/drivers/pinctrl/pinctrl-rockchip.c
3384 ++++ b/drivers/pinctrl/pinctrl-rockchip.c
3385 +@@ -1278,8 +1278,16 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
3386 + {
3387 + struct rockchip_pin_bank *bank = gpiochip_get_data(chip);
3388 + u32 data;
3389 ++ int ret;
3390 +
3391 ++ ret = clk_enable(bank->clk);
3392 ++ if (ret < 0) {
3393 ++ dev_err(bank->drvdata->dev,
3394 ++ "failed to enable clock for bank %s\n", bank->name);
3395 ++ return ret;
3396 ++ }
3397 + data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
3398 ++ clk_disable(bank->clk);
3399 +
3400 + return !(data & BIT(offset));
3401 + }
3402 +diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
3403 +index 04053fe1e980..cfa3e850c49f 100644
3404 +--- a/drivers/platform/chrome/cros_ec_proto.c
3405 ++++ b/drivers/platform/chrome/cros_ec_proto.c
3406 +@@ -60,12 +60,14 @@ static int send_command(struct cros_ec_device *ec_dev,
3407 + struct cros_ec_command *msg)
3408 + {
3409 + int ret;
3410 ++ int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
3411 +
3412 + if (ec_dev->proto_version > 2)
3413 +- ret = ec_dev->pkt_xfer(ec_dev, msg);
3414 ++ xfer_fxn = ec_dev->pkt_xfer;
3415 + else
3416 +- ret = ec_dev->cmd_xfer(ec_dev, msg);
3417 ++ xfer_fxn = ec_dev->cmd_xfer;
3418 +
3419 ++ ret = (*xfer_fxn)(ec_dev, msg);
3420 + if (msg->result == EC_RES_IN_PROGRESS) {
3421 + int i;
3422 + struct cros_ec_command *status_msg;
3423 +@@ -88,7 +90,7 @@ static int send_command(struct cros_ec_device *ec_dev,
3424 + for (i = 0; i < EC_COMMAND_RETRIES; i++) {
3425 + usleep_range(10000, 11000);
3426 +
3427 +- ret = ec_dev->cmd_xfer(ec_dev, status_msg);
3428 ++ ret = (*xfer_fxn)(ec_dev, status_msg);
3429 + if (ret < 0)
3430 + break;
3431 +
3432 +diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
3433 +index f3baf9973989..24f1630a8b3f 100644
3434 +--- a/drivers/platform/chrome/cros_ec_sysfs.c
3435 ++++ b/drivers/platform/chrome/cros_ec_sysfs.c
3436 +@@ -187,7 +187,7 @@ static ssize_t show_ec_version(struct device *dev,
3437 + count += scnprintf(buf + count, PAGE_SIZE - count,
3438 + "Build info: EC error %d\n", msg->result);
3439 + else {
3440 +- msg->data[sizeof(msg->data) - 1] = '\0';
3441 ++ msg->data[EC_HOST_PARAM_SIZE - 1] = '\0';
3442 + count += scnprintf(buf + count, PAGE_SIZE - count,
3443 + "Build info: %s\n", msg->data);
3444 + }
3445 +diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
3446 +index 6eb2837f6b89..687cc5b922ee 100644
3447 +--- a/drivers/platform/x86/asus-nb-wmi.c
3448 ++++ b/drivers/platform/x86/asus-nb-wmi.c
3449 +@@ -120,6 +120,10 @@ static struct quirk_entry quirk_asus_x550lb = {
3450 + .xusb2pr = 0x01D9,
3451 + };
3452 +
3453 ++static struct quirk_entry quirk_asus_ux330uak = {
3454 ++ .wmi_force_als_set = true,
3455 ++};
3456 ++
3457 + static int dmi_matched(const struct dmi_system_id *dmi)
3458 + {
3459 + quirks = dmi->driver_data;
3460 +@@ -150,6 +154,15 @@ static const struct dmi_system_id asus_quirks[] = {
3461 + */
3462 + .driver_data = &quirk_asus_wapf4,
3463 + },
3464 ++ {
3465 ++ .callback = dmi_matched,
3466 ++ .ident = "ASUSTeK COMPUTER INC. X302UA",
3467 ++ .matches = {
3468 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
3469 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X302UA"),
3470 ++ },
3471 ++ .driver_data = &quirk_asus_wapf4,
3472 ++ },
3473 + {
3474 + .callback = dmi_matched,
3475 + .ident = "ASUSTeK COMPUTER INC. X401U",
3476 +@@ -411,6 +424,15 @@ static const struct dmi_system_id asus_quirks[] = {
3477 + },
3478 + .driver_data = &quirk_asus_ux303ub,
3479 + },
3480 ++ {
3481 ++ .callback = dmi_matched,
3482 ++ .ident = "ASUSTeK COMPUTER INC. UX330UAK",
3483 ++ .matches = {
3484 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
3485 ++ DMI_MATCH(DMI_PRODUCT_NAME, "UX330UAK"),
3486 ++ },
3487 ++ .driver_data = &quirk_asus_ux330uak,
3488 ++ },
3489 + {
3490 + .callback = dmi_matched,
3491 + .ident = "ASUSTeK COMPUTER INC. X550LB",
3492 +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
3493 +index 8499d3ae4257..8a1bfd489c26 100644
3494 +--- a/drivers/platform/x86/asus-wmi.c
3495 ++++ b/drivers/platform/x86/asus-wmi.c
3496 +@@ -1108,6 +1108,15 @@ static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
3497 + orig_ports_available, ports_available);
3498 + }
3499 +
3500 ++/*
3501 ++ * Some devices dont support or have borcken get_als method
3502 ++ * but still support set method.
3503 ++ */
3504 ++static void asus_wmi_set_als(void)
3505 ++{
3506 ++ asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL);
3507 ++}
3508 ++
3509 + /*
3510 + * Hwmon device
3511 + */
3512 +@@ -2120,6 +2129,9 @@ static int asus_wmi_add(struct platform_device *pdev)
3513 + goto fail_rfkill;
3514 + }
3515 +
3516 ++ if (asus->driver->quirks->wmi_force_als_set)
3517 ++ asus_wmi_set_als();
3518 ++
3519 + /* Some Asus desktop boards export an acpi-video backlight interface,
3520 + stop this from showing up */
3521 + chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
3522 +diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
3523 +index fdff626c3b51..5db052d1de1e 100644
3524 +--- a/drivers/platform/x86/asus-wmi.h
3525 ++++ b/drivers/platform/x86/asus-wmi.h
3526 +@@ -45,6 +45,7 @@ struct quirk_entry {
3527 + bool store_backlight_power;
3528 + bool wmi_backlight_power;
3529 + bool wmi_backlight_native;
3530 ++ bool wmi_force_als_set;
3531 + int wapf;
3532 + /*
3533 + * For machines with AMD graphic chips, it will send out WMI event
3534 +diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
3535 +index 78080763df51..a74340dff530 100644
3536 +--- a/drivers/platform/x86/intel-vbtn.c
3537 ++++ b/drivers/platform/x86/intel-vbtn.c
3538 +@@ -37,6 +37,10 @@ static const struct acpi_device_id intel_vbtn_ids[] = {
3539 + static const struct key_entry intel_vbtn_keymap[] = {
3540 + { KE_IGNORE, 0xC0, { KEY_POWER } }, /* power key press */
3541 + { KE_KEY, 0xC1, { KEY_POWER } }, /* power key release */
3542 ++ { KE_KEY, 0xC4, { KEY_VOLUMEUP } }, /* volume-up key press */
3543 ++ { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */
3544 ++ { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */
3545 ++ { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */
3546 + { KE_END },
3547 + };
3548 +
3549 +diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
3550 +index 50171fd3cc6d..8ed2782d1bb1 100644
3551 +--- a/drivers/power/supply/bq24190_charger.c
3552 ++++ b/drivers/power/supply/bq24190_charger.c
3553 +@@ -506,6 +506,9 @@ static int bq24190_register_reset(struct bq24190_dev_info *bdi)
3554 + int ret, limit = 100;
3555 + u8 v;
3556 +
3557 ++ if (device_property_read_bool(bdi->dev, "disable-reset"))
3558 ++ return 0;
3559 ++
3560 + /* Reset the registers */
3561 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
3562 + BQ24190_REG_POC_RESET_MASK,
3563 +@@ -1184,8 +1187,13 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
3564 + }
3565 + } while (f_reg && ++i < 2);
3566 +
3567 ++ /* ignore over/under voltage fault after disconnect */
3568 ++ if (f_reg == (1 << BQ24190_REG_F_CHRG_FAULT_SHIFT) &&
3569 ++ !(ss_reg & BQ24190_REG_SS_PG_STAT_MASK))
3570 ++ f_reg = 0;
3571 ++
3572 + if (f_reg != bdi->f_reg) {
3573 +- dev_info(bdi->dev,
3574 ++ dev_warn(bdi->dev,
3575 + "Fault: boost %d, charge %d, battery %d, ntc %d\n",
3576 + !!(f_reg & BQ24190_REG_F_BOOST_FAULT_MASK),
3577 + !!(f_reg & BQ24190_REG_F_CHRG_FAULT_MASK),
3578 +diff --git a/drivers/power/supply/isp1704_charger.c b/drivers/power/supply/isp1704_charger.c
3579 +index 4cd6899b961e..95af5f305838 100644
3580 +--- a/drivers/power/supply/isp1704_charger.c
3581 ++++ b/drivers/power/supply/isp1704_charger.c
3582 +@@ -418,6 +418,10 @@ static int isp1704_charger_probe(struct platform_device *pdev)
3583 +
3584 + pdata = devm_kzalloc(&pdev->dev,
3585 + sizeof(struct isp1704_charger_data), GFP_KERNEL);
3586 ++ if (!pdata) {
3587 ++ ret = -ENOMEM;
3588 ++ goto fail0;
3589 ++ }
3590 + pdata->enable_gpio = gpio;
3591 +
3592 + dev_info(&pdev->dev, "init gpio %d\n", pdata->enable_gpio);
3593 +diff --git a/drivers/power/supply/pda_power.c b/drivers/power/supply/pda_power.c
3594 +index dfe1ee89f7c7..922a86787c5c 100644
3595 +--- a/drivers/power/supply/pda_power.c
3596 ++++ b/drivers/power/supply/pda_power.c
3597 +@@ -30,9 +30,9 @@ static inline unsigned int get_irq_flags(struct resource *res)
3598 + static struct device *dev;
3599 + static struct pda_power_pdata *pdata;
3600 + static struct resource *ac_irq, *usb_irq;
3601 +-static struct timer_list charger_timer;
3602 +-static struct timer_list supply_timer;
3603 +-static struct timer_list polling_timer;
3604 ++static struct delayed_work charger_work;
3605 ++static struct delayed_work polling_work;
3606 ++static struct delayed_work supply_work;
3607 + static int polling;
3608 + static struct power_supply *pda_psy_ac, *pda_psy_usb;
3609 +
3610 +@@ -140,7 +140,7 @@ static void update_charger(void)
3611 + }
3612 + }
3613 +
3614 +-static void supply_timer_func(unsigned long unused)
3615 ++static void supply_work_func(struct work_struct *work)
3616 + {
3617 + if (ac_status == PDA_PSY_TO_CHANGE) {
3618 + ac_status = new_ac_status;
3619 +@@ -161,11 +161,12 @@ static void psy_changed(void)
3620 + * Okay, charger set. Now wait a bit before notifying supplicants,
3621 + * charge power should stabilize.
3622 + */
3623 +- mod_timer(&supply_timer,
3624 +- jiffies + msecs_to_jiffies(pdata->wait_for_charger));
3625 ++ cancel_delayed_work(&supply_work);
3626 ++ schedule_delayed_work(&supply_work,
3627 ++ msecs_to_jiffies(pdata->wait_for_charger));
3628 + }
3629 +
3630 +-static void charger_timer_func(unsigned long unused)
3631 ++static void charger_work_func(struct work_struct *work)
3632 + {
3633 + update_status();
3634 + psy_changed();
3635 +@@ -184,13 +185,14 @@ static irqreturn_t power_changed_isr(int irq, void *power_supply)
3636 + * Wait a bit before reading ac/usb line status and setting charger,
3637 + * because ac/usb status readings may lag from irq.
3638 + */
3639 +- mod_timer(&charger_timer,
3640 +- jiffies + msecs_to_jiffies(pdata->wait_for_status));
3641 ++ cancel_delayed_work(&charger_work);
3642 ++ schedule_delayed_work(&charger_work,
3643 ++ msecs_to_jiffies(pdata->wait_for_status));
3644 +
3645 + return IRQ_HANDLED;
3646 + }
3647 +
3648 +-static void polling_timer_func(unsigned long unused)
3649 ++static void polling_work_func(struct work_struct *work)
3650 + {
3651 + int changed = 0;
3652 +
3653 +@@ -211,8 +213,9 @@ static void polling_timer_func(unsigned long unused)
3654 + if (changed)
3655 + psy_changed();
3656 +
3657 +- mod_timer(&polling_timer,
3658 +- jiffies + msecs_to_jiffies(pdata->polling_interval));
3659 ++ cancel_delayed_work(&polling_work);
3660 ++ schedule_delayed_work(&polling_work,
3661 ++ msecs_to_jiffies(pdata->polling_interval));
3662 + }
3663 +
3664 + #if IS_ENABLED(CONFIG_USB_PHY)
3665 +@@ -250,8 +253,9 @@ static int otg_handle_notification(struct notifier_block *nb,
3666 + * Wait a bit before reading ac/usb line status and setting charger,
3667 + * because ac/usb status readings may lag from irq.
3668 + */
3669 +- mod_timer(&charger_timer,
3670 +- jiffies + msecs_to_jiffies(pdata->wait_for_status));
3671 ++ cancel_delayed_work(&charger_work);
3672 ++ schedule_delayed_work(&charger_work,
3673 ++ msecs_to_jiffies(pdata->wait_for_status));
3674 +
3675 + return NOTIFY_OK;
3676 + }
3677 +@@ -300,8 +304,8 @@ static int pda_power_probe(struct platform_device *pdev)
3678 + if (!pdata->ac_max_uA)
3679 + pdata->ac_max_uA = 500000;
3680 +
3681 +- setup_timer(&charger_timer, charger_timer_func, 0);
3682 +- setup_timer(&supply_timer, supply_timer_func, 0);
3683 ++ INIT_DELAYED_WORK(&charger_work, charger_work_func);
3684 ++ INIT_DELAYED_WORK(&supply_work, supply_work_func);
3685 +
3686 + ac_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ac");
3687 + usb_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "usb");
3688 +@@ -385,9 +389,10 @@ static int pda_power_probe(struct platform_device *pdev)
3689 +
3690 + if (polling) {
3691 + dev_dbg(dev, "will poll for status\n");
3692 +- setup_timer(&polling_timer, polling_timer_func, 0);
3693 +- mod_timer(&polling_timer,
3694 +- jiffies + msecs_to_jiffies(pdata->polling_interval));
3695 ++ INIT_DELAYED_WORK(&polling_work, polling_work_func);
3696 ++ cancel_delayed_work(&polling_work);
3697 ++ schedule_delayed_work(&polling_work,
3698 ++ msecs_to_jiffies(pdata->polling_interval));
3699 + }
3700 +
3701 + if (ac_irq || usb_irq)
3702 +@@ -433,9 +438,9 @@ static int pda_power_remove(struct platform_device *pdev)
3703 + free_irq(ac_irq->start, pda_psy_ac);
3704 +
3705 + if (polling)
3706 +- del_timer_sync(&polling_timer);
3707 +- del_timer_sync(&charger_timer);
3708 +- del_timer_sync(&supply_timer);
3709 ++ cancel_delayed_work_sync(&polling_work);
3710 ++ cancel_delayed_work_sync(&charger_work);
3711 ++ cancel_delayed_work_sync(&supply_work);
3712 +
3713 + if (pdata->is_usb_online)
3714 + power_supply_unregister(pda_psy_usb);
3715 +diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
3716 +index 86280b7e41f3..2aa5b37cc6d2 100644
3717 +--- a/drivers/ptp/ptp_clock.c
3718 ++++ b/drivers/ptp/ptp_clock.c
3719 +@@ -97,30 +97,26 @@ static s32 scaled_ppm_to_ppb(long ppm)
3720 +
3721 + /* posix clock implementation */
3722 +
3723 +-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
3724 ++static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
3725 + {
3726 + tp->tv_sec = 0;
3727 + tp->tv_nsec = 1;
3728 + return 0;
3729 + }
3730 +
3731 +-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
3732 ++static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 *tp)
3733 + {
3734 + struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
3735 +- struct timespec64 ts = timespec_to_timespec64(*tp);
3736 +
3737 +- return ptp->info->settime64(ptp->info, &ts);
3738 ++ return ptp->info->settime64(ptp->info, tp);
3739 + }
3740 +
3741 +-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
3742 ++static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
3743 + {
3744 + struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
3745 +- struct timespec64 ts;
3746 + int err;
3747 +
3748 +- err = ptp->info->gettime64(ptp->info, &ts);
3749 +- if (!err)
3750 +- *tp = timespec64_to_timespec(ts);
3751 ++ err = ptp->info->gettime64(ptp->info, tp);
3752 + return err;
3753 + }
3754 +
3755 +@@ -133,7 +129,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
3756 + ops = ptp->info;
3757 +
3758 + if (tx->modes & ADJ_SETOFFSET) {
3759 +- struct timespec ts;
3760 ++ struct timespec64 ts;
3761 + ktime_t kt;
3762 + s64 delta;
3763 +
3764 +@@ -146,7 +142,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
3765 + if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
3766 + return -EINVAL;
3767 +
3768 +- kt = timespec_to_ktime(ts);
3769 ++ kt = timespec64_to_ktime(ts);
3770 + delta = ktime_to_ns(kt);
3771 + err = ops->adjtime(ops, delta);
3772 + } else if (tx->modes & ADJ_FREQUENCY) {
3773 +diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
3774 +index 3a6d0290c54c..c5e272ea4372 100644
3775 +--- a/drivers/regulator/anatop-regulator.c
3776 ++++ b/drivers/regulator/anatop-regulator.c
3777 +@@ -296,6 +296,11 @@ static int anatop_regulator_probe(struct platform_device *pdev)
3778 + if (!sreg->sel && !strcmp(sreg->name, "vddpu"))
3779 + sreg->sel = 22;
3780 +
3781 ++ /* set the default voltage of the pcie phy to be 1.100v */
3782 ++ if (!sreg->sel && rdesc->name &&
3783 ++ !strcmp(rdesc->name, "vddpcie"))
3784 ++ sreg->sel = 0x10;
3785 ++
3786 + if (!sreg->bypass && !sreg->sel) {
3787 + dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n");
3788 + return -EINVAL;
3789 +diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
3790 +index 7030d7cd3861..c554e529fc4e 100644
3791 +--- a/drivers/rtc/rtc-cmos.c
3792 ++++ b/drivers/rtc/rtc-cmos.c
3793 +@@ -41,6 +41,9 @@
3794 + #include <linux/pm.h>
3795 + #include <linux/of.h>
3796 + #include <linux/of_platform.h>
3797 ++#ifdef CONFIG_X86
3798 ++#include <asm/i8259.h>
3799 ++#endif
3800 +
3801 + /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
3802 + #include <linux/mc146818rtc.h>
3803 +@@ -1117,17 +1120,23 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
3804 + {
3805 + cmos_wake_setup(&pnp->dev);
3806 +
3807 +- if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0))
3808 ++ if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) {
3809 ++ unsigned int irq = 0;
3810 ++#ifdef CONFIG_X86
3811 + /* Some machines contain a PNP entry for the RTC, but
3812 + * don't define the IRQ. It should always be safe to
3813 +- * hardcode it in these cases
3814 ++ * hardcode it on systems with a legacy PIC.
3815 + */
3816 ++ if (nr_legacy_irqs())
3817 ++ irq = 8;
3818 ++#endif
3819 + return cmos_do_probe(&pnp->dev,
3820 +- pnp_get_resource(pnp, IORESOURCE_IO, 0), 8);
3821 +- else
3822 ++ pnp_get_resource(pnp, IORESOURCE_IO, 0), irq);
3823 ++ } else {
3824 + return cmos_do_probe(&pnp->dev,
3825 + pnp_get_resource(pnp, IORESOURCE_IO, 0),
3826 + pnp_irq(pnp, 0));
3827 ++ }
3828 + }
3829 +
3830 + static void cmos_pnp_remove(struct pnp_dev *pnp)
3831 +diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
3832 +index 3b3049c8c9e0..c0eb113588ff 100644
3833 +--- a/drivers/rtc/rtc-ds1374.c
3834 ++++ b/drivers/rtc/rtc-ds1374.c
3835 +@@ -527,6 +527,10 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd,
3836 + if (get_user(new_margin, (int __user *)arg))
3837 + return -EFAULT;
3838 +
3839 ++ /* the hardware's tick rate is 4096 Hz, so
3840 ++ * the counter value needs to be scaled accordingly
3841 ++ */
3842 ++ new_margin <<= 12;
3843 + if (new_margin < 1 || new_margin > 16777216)
3844 + return -EINVAL;
3845 +
3846 +@@ -535,7 +539,8 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd,
3847 + ds1374_wdt_ping();
3848 + /* fallthrough */
3849 + case WDIOC_GETTIMEOUT:
3850 +- return put_user(wdt_margin, (int __user *)arg);
3851 ++ /* when returning ... inverse is true */
3852 ++ return put_user((wdt_margin >> 12), (int __user *)arg);
3853 + case WDIOC_SETOPTIONS:
3854 + if (copy_from_user(&options, (int __user *)arg, sizeof(int)))
3855 + return -EFAULT;
3856 +@@ -543,14 +548,15 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd,
3857 + if (options & WDIOS_DISABLECARD) {
3858 + pr_info("disable watchdog\n");
3859 + ds1374_wdt_disable();
3860 ++ return 0;
3861 + }
3862 +
3863 + if (options & WDIOS_ENABLECARD) {
3864 + pr_info("enable watchdog\n");
3865 + ds1374_wdt_settimeout(wdt_margin);
3866 + ds1374_wdt_ping();
3867 ++ return 0;
3868 + }
3869 +-
3870 + return -EINVAL;
3871 + }
3872 + return -ENOTTY;
3873 +diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
3874 +index f7e3f27bb5c5..e9ea8f4ea2c9 100644
3875 +--- a/drivers/scsi/lpfc/lpfc_init.c
3876 ++++ b/drivers/scsi/lpfc/lpfc_init.c
3877 +@@ -11312,6 +11312,7 @@ int
3878 + lpfc_fof_queue_create(struct lpfc_hba *phba)
3879 + {
3880 + struct lpfc_queue *qdesc;
3881 ++ uint32_t wqesize;
3882 +
3883 + /* Create FOF EQ */
3884 + qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.eq_esize,
3885 +@@ -11332,8 +11333,11 @@ lpfc_fof_queue_create(struct lpfc_hba *phba)
3886 + phba->sli4_hba.oas_cq = qdesc;
3887 +
3888 + /* Create OAS WQ */
3889 +- qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.wq_esize,
3890 ++ wqesize = (phba->fcp_embed_io) ?
3891 ++ LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize;
3892 ++ qdesc = lpfc_sli4_queue_alloc(phba, wqesize,
3893 + phba->sli4_hba.wq_ecount);
3894 ++
3895 + if (!qdesc)
3896 + goto out_error;
3897 +
3898 +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3899 +index 8f1df76a77b6..0902ed204ba8 100644
3900 +--- a/drivers/scsi/lpfc/lpfc_sli.c
3901 ++++ b/drivers/scsi/lpfc/lpfc_sli.c
3902 +@@ -13696,6 +13696,9 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
3903 + case LPFC_Q_CREATE_VERSION_1:
3904 + bf_set(lpfc_mbx_wq_create_wqe_count, &wq_create->u.request_1,
3905 + wq->entry_count);
3906 ++ bf_set(lpfc_mbox_hdr_version, &shdr->request,
3907 ++ LPFC_Q_CREATE_VERSION_1);
3908 ++
3909 + switch (wq->entry_size) {
3910 + default:
3911 + case 64:
3912 +diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
3913 +index 14c0334f41e4..26c67c42985c 100644
3914 +--- a/drivers/scsi/mac_esp.c
3915 ++++ b/drivers/scsi/mac_esp.c
3916 +@@ -55,6 +55,7 @@ struct mac_esp_priv {
3917 + int error;
3918 + };
3919 + static struct esp *esp_chips[2];
3920 ++static DEFINE_SPINLOCK(esp_chips_lock);
3921 +
3922 + #define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \
3923 + platform_get_drvdata((struct platform_device *) \
3924 +@@ -562,15 +563,18 @@ static int esp_mac_probe(struct platform_device *dev)
3925 + }
3926 +
3927 + host->irq = IRQ_MAC_SCSI;
3928 +- esp_chips[dev->id] = esp;
3929 +- mb();
3930 +- if (esp_chips[!dev->id] == NULL) {
3931 +- err = request_irq(host->irq, mac_scsi_esp_intr, 0, "ESP", NULL);
3932 +- if (err < 0) {
3933 +- esp_chips[dev->id] = NULL;
3934 +- goto fail_free_priv;
3935 +- }
3936 ++
3937 ++ /* The request_irq() call is intended to succeed for the first device
3938 ++ * and fail for the second device.
3939 ++ */
3940 ++ err = request_irq(host->irq, mac_scsi_esp_intr, 0, "ESP", NULL);
3941 ++ spin_lock(&esp_chips_lock);
3942 ++ if (err < 0 && esp_chips[!dev->id] == NULL) {
3943 ++ spin_unlock(&esp_chips_lock);
3944 ++ goto fail_free_priv;
3945 + }
3946 ++ esp_chips[dev->id] = esp;
3947 ++ spin_unlock(&esp_chips_lock);
3948 +
3949 + err = scsi_esp_register(esp, &dev->dev);
3950 + if (err)
3951 +@@ -579,8 +583,13 @@ static int esp_mac_probe(struct platform_device *dev)
3952 + return 0;
3953 +
3954 + fail_free_irq:
3955 +- if (esp_chips[!dev->id] == NULL)
3956 ++ spin_lock(&esp_chips_lock);
3957 ++ esp_chips[dev->id] = NULL;
3958 ++ if (esp_chips[!dev->id] == NULL) {
3959 ++ spin_unlock(&esp_chips_lock);
3960 + free_irq(host->irq, esp);
3961 ++ } else
3962 ++ spin_unlock(&esp_chips_lock);
3963 + fail_free_priv:
3964 + kfree(mep);
3965 + fail_free_command_block:
3966 +@@ -599,9 +608,13 @@ static int esp_mac_remove(struct platform_device *dev)
3967 +
3968 + scsi_esp_unregister(esp);
3969 +
3970 ++ spin_lock(&esp_chips_lock);
3971 + esp_chips[dev->id] = NULL;
3972 +- if (!(esp_chips[0] || esp_chips[1]))
3973 ++ if (esp_chips[!dev->id] == NULL) {
3974 ++ spin_unlock(&esp_chips_lock);
3975 + free_irq(irq, NULL);
3976 ++ } else
3977 ++ spin_unlock(&esp_chips_lock);
3978 +
3979 + kfree(mep);
3980 +
3981 +diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
3982 +index c680d7641311..8f4adc1d9588 100644
3983 +--- a/drivers/scsi/virtio_scsi.c
3984 ++++ b/drivers/scsi/virtio_scsi.c
3985 +@@ -28,6 +28,7 @@
3986 + #include <scsi/scsi_device.h>
3987 + #include <scsi/scsi_cmnd.h>
3988 + #include <scsi/scsi_tcq.h>
3989 ++#include <scsi/scsi_devinfo.h>
3990 + #include <linux/seqlock.h>
3991 +
3992 + #define VIRTIO_SCSI_MEMPOOL_SZ 64
3993 +@@ -705,6 +706,28 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
3994 + return virtscsi_tmf(vscsi, cmd);
3995 + }
3996 +
3997 ++static int virtscsi_device_alloc(struct scsi_device *sdevice)
3998 ++{
3999 ++ /*
4000 ++ * Passed through SCSI targets (e.g. with qemu's 'scsi-block')
4001 ++ * may have transfer limits which come from the host SCSI
4002 ++ * controller or something on the host side other than the
4003 ++ * target itself.
4004 ++ *
4005 ++ * To make this work properly, the hypervisor can adjust the
4006 ++ * target's VPD information to advertise these limits. But
4007 ++ * for that to work, the guest has to look at the VPD pages,
4008 ++ * which we won't do by default if it is an SPC-2 device, even
4009 ++ * if it does actually support it.
4010 ++ *
4011 ++ * So, set the blist to always try to read the VPD pages.
4012 ++ */
4013 ++ sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES;
4014 ++
4015 ++ return 0;
4016 ++}
4017 ++
4018 ++
4019 + /**
4020 + * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth
4021 + * @sdev: Virtscsi target whose queue depth to change
4022 +@@ -776,6 +799,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
4023 + .change_queue_depth = virtscsi_change_queue_depth,
4024 + .eh_abort_handler = virtscsi_abort,
4025 + .eh_device_reset_handler = virtscsi_device_reset,
4026 ++ .slave_alloc = virtscsi_device_alloc,
4027 +
4028 + .can_queue = 1024,
4029 + .dma_boundary = UINT_MAX,
4030 +diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
4031 +index 2707a827261b..5482302d3d9e 100644
4032 +--- a/drivers/soc/fsl/qe/qe.c
4033 ++++ b/drivers/soc/fsl/qe/qe.c
4034 +@@ -163,11 +163,15 @@ EXPORT_SYMBOL(qe_issue_cmd);
4035 + */
4036 + static unsigned int brg_clk = 0;
4037 +
4038 ++#define CLK_GRAN (1000)
4039 ++#define CLK_GRAN_LIMIT (5)
4040 ++
4041 + unsigned int qe_get_brg_clk(void)
4042 + {
4043 + struct device_node *qe;
4044 + int size;
4045 + const u32 *prop;
4046 ++ unsigned int mod;
4047 +
4048 + if (brg_clk)
4049 + return brg_clk;
4050 +@@ -185,6 +189,15 @@ unsigned int qe_get_brg_clk(void)
4051 +
4052 + of_node_put(qe);
4053 +
4054 ++ /* round this if near to a multiple of CLK_GRAN */
4055 ++ mod = brg_clk % CLK_GRAN;
4056 ++ if (mod) {
4057 ++ if (mod < CLK_GRAN_LIMIT)
4058 ++ brg_clk -= mod;
4059 ++ else if (mod > (CLK_GRAN - CLK_GRAN_LIMIT))
4060 ++ brg_clk += CLK_GRAN - mod;
4061 ++ }
4062 ++
4063 + return brg_clk;
4064 + }
4065 + EXPORT_SYMBOL(qe_get_brg_clk);
4066 +diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
4067 +index 447497e9124c..d25cc4037e23 100644
4068 +--- a/drivers/spi/spi-dw-mmio.c
4069 ++++ b/drivers/spi/spi-dw-mmio.c
4070 +@@ -115,8 +115,8 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
4071 + {
4072 + struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
4073 +
4074 +- clk_disable_unprepare(dwsmmio->clk);
4075 + dw_spi_remove_host(&dwsmmio->dws);
4076 ++ clk_disable_unprepare(dwsmmio->clk);
4077 +
4078 + return 0;
4079 + }
4080 +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
4081 +index db100154f85c..6d690e5fa9bb 100644
4082 +--- a/drivers/staging/android/ashmem.c
4083 ++++ b/drivers/staging/android/ashmem.c
4084 +@@ -718,16 +718,14 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
4085 + size_t pgstart, pgend;
4086 + int ret = -EINVAL;
4087 +
4088 ++ if (unlikely(copy_from_user(&pin, p, sizeof(pin))))
4089 ++ return -EFAULT;
4090 ++
4091 + mutex_lock(&ashmem_mutex);
4092 +
4093 + if (unlikely(!asma->file))
4094 + goto out_unlock;
4095 +
4096 +- if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) {
4097 +- ret = -EFAULT;
4098 +- goto out_unlock;
4099 +- }
4100 +-
4101 + /* per custom, you can pass zero for len to mean "everything onward" */
4102 + if (!pin.len)
4103 + pin.len = PAGE_ALIGN(asma->size) - pin.offset;
4104 +diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
4105 +index 5a7a87efed27..28b5392153a8 100644
4106 +--- a/drivers/staging/unisys/visorhba/visorhba_main.c
4107 ++++ b/drivers/staging/unisys/visorhba/visorhba_main.c
4108 +@@ -842,7 +842,7 @@ static void
4109 + do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
4110 + {
4111 + struct scsi_device *scsidev;
4112 +- unsigned char buf[36];
4113 ++ unsigned char *buf;
4114 + struct scatterlist *sg;
4115 + unsigned int i;
4116 + char *this_page;
4117 +@@ -857,6 +857,10 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
4118 + if (cmdrsp->scsi.no_disk_result == 0)
4119 + return;
4120 +
4121 ++ buf = kzalloc(sizeof(char) * 36, GFP_KERNEL);
4122 ++ if (!buf)
4123 ++ return;
4124 ++
4125 + /* Linux scsi code wants a device at Lun 0
4126 + * to issue report luns, but we don't want
4127 + * a disk there so we'll present a processor
4128 +@@ -868,6 +872,7 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
4129 + if (scsi_sg_count(scsicmd) == 0) {
4130 + memcpy(scsi_sglist(scsicmd), buf,
4131 + cmdrsp->scsi.bufflen);
4132 ++ kfree(buf);
4133 + return;
4134 + }
4135 +
4136 +@@ -879,6 +884,7 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
4137 + memcpy(this_page, buf + bufind, sg[i].length);
4138 + kunmap_atomic(this_page_orig);
4139 + }
4140 ++ kfree(buf);
4141 + } else {
4142 + devdata = (struct visorhba_devdata *)scsidev->host->hostdata;
4143 + for_each_vdisk_match(vdisk, devdata, scsidev) {
4144 +diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
4145 +index 242f82f4d24f..d8ab4cb11289 100644
4146 +--- a/drivers/staging/wilc1000/linux_mon.c
4147 ++++ b/drivers/staging/wilc1000/linux_mon.c
4148 +@@ -197,6 +197,8 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
4149 +
4150 + if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) {
4151 + skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
4152 ++ if (!skb2)
4153 ++ return -ENOMEM;
4154 +
4155 + memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
4156 +
4157 +diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
4158 +index 97928b42ad62..57a3d3936364 100644
4159 +--- a/drivers/target/target_core_file.c
4160 ++++ b/drivers/target/target_core_file.c
4161 +@@ -276,12 +276,11 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,
4162 + else
4163 + ret = vfs_iter_read(fd, &iter, &pos);
4164 +
4165 +- kfree(bvec);
4166 +-
4167 + if (is_write) {
4168 + if (ret < 0 || ret != data_length) {
4169 + pr_err("%s() write returned %d\n", __func__, ret);
4170 +- return (ret < 0 ? ret : -EINVAL);
4171 ++ if (ret >= 0)
4172 ++ ret = -EINVAL;
4173 + }
4174 + } else {
4175 + /*
4176 +@@ -294,17 +293,29 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,
4177 + pr_err("%s() returned %d, expecting %u for "
4178 + "S_ISBLK\n", __func__, ret,
4179 + data_length);
4180 +- return (ret < 0 ? ret : -EINVAL);
4181 ++ if (ret >= 0)
4182 ++ ret = -EINVAL;
4183 + }
4184 + } else {
4185 + if (ret < 0) {
4186 + pr_err("%s() returned %d for non S_ISBLK\n",
4187 + __func__, ret);
4188 +- return ret;
4189 ++ } else if (ret != data_length) {
4190 ++ /*
4191 ++ * Short read case:
4192 ++ * Probably some one truncate file under us.
4193 ++ * We must explicitly zero sg-pages to prevent
4194 ++ * expose uninizialized pages to userspace.
4195 ++ */
4196 ++ if (ret < data_length)
4197 ++ ret += iov_iter_zero(data_length - ret, &iter);
4198 ++ else
4199 ++ ret = -EINVAL;
4200 + }
4201 + }
4202 + }
4203 +- return 1;
4204 ++ kfree(bvec);
4205 ++ return ret;
4206 + }
4207 +
4208 + static sense_reason_t
4209 +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
4210 +index 459d726f9d59..3eb01a719d22 100644
4211 +--- a/drivers/tty/serial/8250/8250_dw.c
4212 ++++ b/drivers/tty/serial/8250/8250_dw.c
4213 +@@ -464,7 +464,8 @@ static int dw8250_probe(struct platform_device *pdev)
4214 + /* If no clock rate is defined, fail. */
4215 + if (!p->uartclk) {
4216 + dev_err(dev, "clock rate not defined\n");
4217 +- return -EINVAL;
4218 ++ err = -EINVAL;
4219 ++ goto err_clk;
4220 + }
4221 +
4222 + data->pclk = devm_clk_get(dev, "apb_pclk");
4223 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
4224 +index 8d9f9a803b42..fb9bada5f1d5 100644
4225 +--- a/drivers/tty/tty_io.c
4226 ++++ b/drivers/tty/tty_io.c
4227 +@@ -1702,6 +1702,8 @@ static void release_tty(struct tty_struct *tty, int idx)
4228 + if (tty->link)
4229 + tty->link->port->itty = NULL;
4230 + tty_buffer_cancel_work(tty->port);
4231 ++ if (tty->link)
4232 ++ tty_buffer_cancel_work(tty->link->port);
4233 +
4234 + tty_kref_put(tty->link);
4235 + tty_kref_put(tty);
4236 +diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
4237 +index b6d4b484c51a..5815120c0402 100644
4238 +--- a/drivers/usb/gadget/function/f_hid.c
4239 ++++ b/drivers/usb/gadget/function/f_hid.c
4240 +@@ -284,6 +284,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
4241 + size_t count, loff_t *offp)
4242 + {
4243 + struct f_hidg *hidg = file->private_data;
4244 ++ struct usb_request *req;
4245 + unsigned long flags;
4246 + ssize_t status = -ENOMEM;
4247 +
4248 +@@ -293,7 +294,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
4249 + spin_lock_irqsave(&hidg->write_spinlock, flags);
4250 +
4251 + #define WRITE_COND (!hidg->write_pending)
4252 +-
4253 ++try_again:
4254 + /* write queue */
4255 + while (!WRITE_COND) {
4256 + spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4257 +@@ -308,6 +309,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
4258 + }
4259 +
4260 + hidg->write_pending = 1;
4261 ++ req = hidg->req;
4262 + count = min_t(unsigned, count, hidg->report_length);
4263 +
4264 + spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4265 +@@ -320,24 +322,38 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
4266 + goto release_write_pending;
4267 + }
4268 +
4269 +- hidg->req->status = 0;
4270 +- hidg->req->zero = 0;
4271 +- hidg->req->length = count;
4272 +- hidg->req->complete = f_hidg_req_complete;
4273 +- hidg->req->context = hidg;
4274 ++ spin_lock_irqsave(&hidg->write_spinlock, flags);
4275 ++
4276 ++ /* we our function has been disabled by host */
4277 ++ if (!hidg->req) {
4278 ++ free_ep_req(hidg->in_ep, hidg->req);
4279 ++ /*
4280 ++ * TODO
4281 ++ * Should we fail with error here?
4282 ++ */
4283 ++ goto try_again;
4284 ++ }
4285 ++
4286 ++ req->status = 0;
4287 ++ req->zero = 0;
4288 ++ req->length = count;
4289 ++ req->complete = f_hidg_req_complete;
4290 ++ req->context = hidg;
4291 +
4292 + status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC);
4293 + if (status < 0) {
4294 + ERROR(hidg->func.config->cdev,
4295 + "usb_ep_queue error on int endpoint %zd\n", status);
4296 +- goto release_write_pending;
4297 ++ goto release_write_pending_unlocked;
4298 + } else {
4299 + status = count;
4300 + }
4301 ++ spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4302 +
4303 + return status;
4304 + release_write_pending:
4305 + spin_lock_irqsave(&hidg->write_spinlock, flags);
4306 ++release_write_pending_unlocked:
4307 + hidg->write_pending = 0;
4308 + spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4309 +
4310 +@@ -541,12 +557,23 @@ static void hidg_disable(struct usb_function *f)
4311 + kfree(list);
4312 + }
4313 + spin_unlock_irqrestore(&hidg->read_spinlock, flags);
4314 ++
4315 ++ spin_lock_irqsave(&hidg->write_spinlock, flags);
4316 ++ if (!hidg->write_pending) {
4317 ++ free_ep_req(hidg->in_ep, hidg->req);
4318 ++ hidg->write_pending = 1;
4319 ++ }
4320 ++
4321 ++ hidg->req = NULL;
4322 ++ spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4323 + }
4324 +
4325 + static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
4326 + {
4327 + struct usb_composite_dev *cdev = f->config->cdev;
4328 + struct f_hidg *hidg = func_to_hidg(f);
4329 ++ struct usb_request *req_in = NULL;
4330 ++ unsigned long flags;
4331 + int i, status = 0;
4332 +
4333 + VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt);
4334 +@@ -567,6 +594,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
4335 + goto fail;
4336 + }
4337 + hidg->in_ep->driver_data = hidg;
4338 ++
4339 ++ req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length);
4340 ++ if (!req_in) {
4341 ++ status = -ENOMEM;
4342 ++ goto disable_ep_in;
4343 ++ }
4344 + }
4345 +
4346 +
4347 +@@ -578,12 +611,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
4348 + hidg->out_ep);
4349 + if (status) {
4350 + ERROR(cdev, "config_ep_by_speed FAILED!\n");
4351 +- goto fail;
4352 ++ goto free_req_in;
4353 + }
4354 + status = usb_ep_enable(hidg->out_ep);
4355 + if (status < 0) {
4356 + ERROR(cdev, "Enable OUT endpoint FAILED!\n");
4357 +- goto fail;
4358 ++ goto free_req_in;
4359 + }
4360 + hidg->out_ep->driver_data = hidg;
4361 +
4362 +@@ -599,17 +632,37 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
4363 + req->context = hidg;
4364 + status = usb_ep_queue(hidg->out_ep, req,
4365 + GFP_ATOMIC);
4366 +- if (status)
4367 ++ if (status) {
4368 + ERROR(cdev, "%s queue req --> %d\n",
4369 + hidg->out_ep->name, status);
4370 ++ free_ep_req(hidg->out_ep, req);
4371 ++ }
4372 + } else {
4373 +- usb_ep_disable(hidg->out_ep);
4374 + status = -ENOMEM;
4375 +- goto fail;
4376 ++ goto disable_out_ep;
4377 + }
4378 + }
4379 + }
4380 +
4381 ++ if (hidg->in_ep != NULL) {
4382 ++ spin_lock_irqsave(&hidg->write_spinlock, flags);
4383 ++ hidg->req = req_in;
4384 ++ hidg->write_pending = 0;
4385 ++ spin_unlock_irqrestore(&hidg->write_spinlock, flags);
4386 ++
4387 ++ wake_up(&hidg->write_queue);
4388 ++ }
4389 ++ return 0;
4390 ++disable_out_ep:
4391 ++ usb_ep_disable(hidg->out_ep);
4392 ++free_req_in:
4393 ++ if (req_in)
4394 ++ free_ep_req(hidg->in_ep, req_in);
4395 ++
4396 ++disable_ep_in:
4397 ++ if (hidg->in_ep)
4398 ++ usb_ep_disable(hidg->in_ep);
4399 ++
4400 + fail:
4401 + return status;
4402 + }
4403 +@@ -658,12 +711,6 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
4404 + goto fail;
4405 + hidg->out_ep = ep;
4406 +
4407 +- /* preallocate request and buffer */
4408 +- status = -ENOMEM;
4409 +- hidg->req = alloc_ep_req(hidg->in_ep, hidg->report_length);
4410 +- if (!hidg->req)
4411 +- goto fail;
4412 +-
4413 + /* set descriptor dynamic values */
4414 + hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
4415 + hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
4416 +@@ -690,6 +737,8 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
4417 + goto fail;
4418 +
4419 + spin_lock_init(&hidg->write_spinlock);
4420 ++ hidg->write_pending = 1;
4421 ++ hidg->req = NULL;
4422 + spin_lock_init(&hidg->read_spinlock);
4423 + init_waitqueue_head(&hidg->write_queue);
4424 + init_waitqueue_head(&hidg->read_queue);
4425 +@@ -954,10 +1003,6 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
4426 + device_destroy(hidg_class, MKDEV(major, hidg->minor));
4427 + cdev_del(&hidg->cdev);
4428 +
4429 +- /* disable/free request and end point */
4430 +- usb_ep_disable(hidg->in_ep);
4431 +- free_ep_req(hidg->in_ep, hidg->req);
4432 +-
4433 + usb_free_all_descriptors(f);
4434 + }
4435 +
4436 +diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
4437 +index 11576611a974..dda1c4b3a229 100644
4438 +--- a/drivers/video/console/vgacon.c
4439 ++++ b/drivers/video/console/vgacon.c
4440 +@@ -405,7 +405,10 @@ static const char *vgacon_startup(void)
4441 + vga_video_port_val = VGA_CRT_DM;
4442 + if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) {
4443 + static struct resource ega_console_resource =
4444 +- { .name = "ega", .start = 0x3B0, .end = 0x3BF };
4445 ++ { .name = "ega",
4446 ++ .flags = IORESOURCE_IO,
4447 ++ .start = 0x3B0,
4448 ++ .end = 0x3BF };
4449 + vga_video_type = VIDEO_TYPE_EGAM;
4450 + vga_vram_size = 0x8000;
4451 + display_desc = "EGA+";
4452 +@@ -413,9 +416,15 @@ static const char *vgacon_startup(void)
4453 + &ega_console_resource);
4454 + } else {
4455 + static struct resource mda1_console_resource =
4456 +- { .name = "mda", .start = 0x3B0, .end = 0x3BB };
4457 ++ { .name = "mda",
4458 ++ .flags = IORESOURCE_IO,
4459 ++ .start = 0x3B0,
4460 ++ .end = 0x3BB };
4461 + static struct resource mda2_console_resource =
4462 +- { .name = "mda", .start = 0x3BF, .end = 0x3BF };
4463 ++ { .name = "mda",
4464 ++ .flags = IORESOURCE_IO,
4465 ++ .start = 0x3BF,
4466 ++ .end = 0x3BF };
4467 + vga_video_type = VIDEO_TYPE_MDA;
4468 + vga_vram_size = 0x2000;
4469 + display_desc = "*MDA";
4470 +@@ -437,15 +446,21 @@ static const char *vgacon_startup(void)
4471 + vga_vram_size = 0x8000;
4472 +
4473 + if (!screen_info.orig_video_isVGA) {
4474 +- static struct resource ega_console_resource
4475 +- = { .name = "ega", .start = 0x3C0, .end = 0x3DF };
4476 ++ static struct resource ega_console_resource =
4477 ++ { .name = "ega",
4478 ++ .flags = IORESOURCE_IO,
4479 ++ .start = 0x3C0,
4480 ++ .end = 0x3DF };
4481 + vga_video_type = VIDEO_TYPE_EGAC;
4482 + display_desc = "EGA";
4483 + request_resource(&ioport_resource,
4484 + &ega_console_resource);
4485 + } else {
4486 +- static struct resource vga_console_resource
4487 +- = { .name = "vga+", .start = 0x3C0, .end = 0x3DF };
4488 ++ static struct resource vga_console_resource =
4489 ++ { .name = "vga+",
4490 ++ .flags = IORESOURCE_IO,
4491 ++ .start = 0x3C0,
4492 ++ .end = 0x3DF };
4493 + vga_video_type = VIDEO_TYPE_VGAC;
4494 + display_desc = "VGA+";
4495 + request_resource(&ioport_resource,
4496 +@@ -489,7 +504,10 @@ static const char *vgacon_startup(void)
4497 + }
4498 + } else {
4499 + static struct resource cga_console_resource =
4500 +- { .name = "cga", .start = 0x3D4, .end = 0x3D5 };
4501 ++ { .name = "cga",
4502 ++ .flags = IORESOURCE_IO,
4503 ++ .start = 0x3D4,
4504 ++ .end = 0x3D5 };
4505 + vga_video_type = VIDEO_TYPE_CGA;
4506 + vga_vram_size = 0x2000;
4507 + display_desc = "*CGA";
4508 +diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c
4509 +index b529a8c2b652..3984716096aa 100644
4510 +--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c
4511 ++++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c
4512 +@@ -455,6 +455,8 @@ static int td028ttec1_panel_remove(struct spi_device *spi)
4513 + }
4514 +
4515 + static const struct of_device_id td028ttec1_of_match[] = {
4516 ++ { .compatible = "omapdss,tpo,td028ttec1", },
4517 ++ /* keep to not break older DTB */
4518 + { .compatible = "omapdss,toppoly,td028ttec1", },
4519 + {},
4520 + };
4521 +@@ -474,6 +476,7 @@ static struct spi_driver td028ttec1_spi_driver = {
4522 +
4523 + module_spi_driver(td028ttec1_spi_driver);
4524 +
4525 ++MODULE_ALIAS("spi:tpo,td028ttec1");
4526 + MODULE_ALIAS("spi:toppoly,td028ttec1");
4527 + MODULE_AUTHOR("H. Nikolaus Schaller <hns@×××××××××.com>");
4528 + MODULE_DESCRIPTION("Toppoly TD028TTEC1 panel driver");
4529 +diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
4530 +index d0a4e2f79a57..d215faacce04 100644
4531 +--- a/drivers/video/fbdev/sm501fb.c
4532 ++++ b/drivers/video/fbdev/sm501fb.c
4533 +@@ -1600,6 +1600,7 @@ static int sm501fb_start(struct sm501fb_info *info,
4534 + info->fbmem = ioremap(res->start, resource_size(res));
4535 + if (info->fbmem == NULL) {
4536 + dev_err(dev, "cannot remap framebuffer\n");
4537 ++ ret = -ENXIO;
4538 + goto err_mem_res;
4539 + }
4540 +
4541 +diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
4542 +index 53326badfb61..2add8def83be 100644
4543 +--- a/drivers/video/fbdev/udlfb.c
4544 ++++ b/drivers/video/fbdev/udlfb.c
4545 +@@ -1487,15 +1487,25 @@ static struct device_attribute fb_device_attrs[] = {
4546 + static int dlfb_select_std_channel(struct dlfb_data *dev)
4547 + {
4548 + int ret;
4549 +- u8 set_def_chn[] = { 0x57, 0xCD, 0xDC, 0xA7,
4550 ++ void *buf;
4551 ++ static const u8 set_def_chn[] = {
4552 ++ 0x57, 0xCD, 0xDC, 0xA7,
4553 + 0x1C, 0x88, 0x5E, 0x15,
4554 + 0x60, 0xFE, 0xC6, 0x97,
4555 + 0x16, 0x3D, 0x47, 0xF2 };
4556 +
4557 ++ buf = kmemdup(set_def_chn, sizeof(set_def_chn), GFP_KERNEL);
4558 ++
4559 ++ if (!buf)
4560 ++ return -ENOMEM;
4561 ++
4562 + ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
4563 + NR_USB_REQUEST_CHANNEL,
4564 + (USB_DIR_OUT | USB_TYPE_VENDOR), 0, 0,
4565 +- set_def_chn, sizeof(set_def_chn), USB_CTRL_SET_TIMEOUT);
4566 ++ buf, sizeof(set_def_chn), USB_CTRL_SET_TIMEOUT);
4567 ++
4568 ++ kfree(buf);
4569 ++
4570 + return ret;
4571 + }
4572 +
4573 +diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
4574 +index 32930a073a12..977fe74e5abe 100644
4575 +--- a/drivers/watchdog/watchdog_dev.c
4576 ++++ b/drivers/watchdog/watchdog_dev.c
4577 +@@ -760,6 +760,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
4578 + {
4579 + struct watchdog_core_data *wd_data;
4580 + struct watchdog_device *wdd;
4581 ++ bool hw_running;
4582 + int err;
4583 +
4584 + /* Get the corresponding watchdog device */
4585 +@@ -779,7 +780,8 @@ static int watchdog_open(struct inode *inode, struct file *file)
4586 + * If the /dev/watchdog device is open, we don't want the module
4587 + * to be unloaded.
4588 + */
4589 +- if (!watchdog_hw_running(wdd) && !try_module_get(wdd->ops->owner)) {
4590 ++ hw_running = watchdog_hw_running(wdd);
4591 ++ if (!hw_running && !try_module_get(wdd->ops->owner)) {
4592 + err = -EBUSY;
4593 + goto out_clear;
4594 + }
4595 +@@ -790,7 +792,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
4596 +
4597 + file->private_data = wd_data;
4598 +
4599 +- if (!watchdog_hw_running(wdd))
4600 ++ if (!hw_running)
4601 + kref_get(&wd_data->kref);
4602 +
4603 + /* dev/watchdog is a virtual (and thus non-seekable) filesystem */
4604 +diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
4605 +index 3286a6e47ff0..c95ff096cd24 100644
4606 +--- a/fs/btrfs/file.c
4607 ++++ b/fs/btrfs/file.c
4608 +@@ -2817,8 +2817,10 @@ static long btrfs_fallocate(struct file *file, int mode,
4609 + }
4610 + ret = btrfs_qgroup_reserve_data(inode, cur_offset,
4611 + last_byte - cur_offset);
4612 +- if (ret < 0)
4613 ++ if (ret < 0) {
4614 ++ free_extent_map(em);
4615 + break;
4616 ++ }
4617 + } else {
4618 + /*
4619 + * Do not need to reserve unwritten extent for this
4620 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
4621 +index d196ce4be31c..ffd5831ca15c 100644
4622 +--- a/fs/btrfs/inode.c
4623 ++++ b/fs/btrfs/inode.c
4624 +@@ -567,8 +567,10 @@ static noinline void compress_file_range(struct inode *inode,
4625 + PAGE_SET_WRITEBACK |
4626 + page_error_op |
4627 + PAGE_END_WRITEBACK);
4628 +- btrfs_free_reserved_data_space_noquota(inode, start,
4629 +- end - start + 1);
4630 ++ if (ret == 0)
4631 ++ btrfs_free_reserved_data_space_noquota(inode,
4632 ++ start,
4633 ++ end - start + 1);
4634 + goto free_pages_out;
4635 + }
4636 + }
4637 +diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
4638 +index 9a47b5598df7..d040afc966fe 100644
4639 +--- a/fs/btrfs/send.c
4640 ++++ b/fs/btrfs/send.c
4641 +@@ -5156,13 +5156,19 @@ static int is_extent_unchanged(struct send_ctx *sctx,
4642 + while (key.offset < ekey->offset + left_len) {
4643 + ei = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item);
4644 + right_type = btrfs_file_extent_type(eb, ei);
4645 +- if (right_type != BTRFS_FILE_EXTENT_REG) {
4646 ++ if (right_type != BTRFS_FILE_EXTENT_REG &&
4647 ++ right_type != BTRFS_FILE_EXTENT_INLINE) {
4648 + ret = 0;
4649 + goto out;
4650 + }
4651 +
4652 + right_disknr = btrfs_file_extent_disk_bytenr(eb, ei);
4653 +- right_len = btrfs_file_extent_num_bytes(eb, ei);
4654 ++ if (right_type == BTRFS_FILE_EXTENT_INLINE) {
4655 ++ right_len = btrfs_file_extent_inline_len(eb, slot, ei);
4656 ++ right_len = PAGE_ALIGN(right_len);
4657 ++ } else {
4658 ++ right_len = btrfs_file_extent_num_bytes(eb, ei);
4659 ++ }
4660 + right_offset = btrfs_file_extent_offset(eb, ei);
4661 + right_gen = btrfs_file_extent_generation(eb, ei);
4662 +
4663 +@@ -5176,6 +5182,19 @@ static int is_extent_unchanged(struct send_ctx *sctx,
4664 + goto out;
4665 + }
4666 +
4667 ++ /*
4668 ++ * We just wanted to see if when we have an inline extent, what
4669 ++ * follows it is a regular extent (wanted to check the above
4670 ++ * condition for inline extents too). This should normally not
4671 ++ * happen but it's possible for example when we have an inline
4672 ++ * compressed extent representing data with a size matching
4673 ++ * the page size (currently the same as sector size).
4674 ++ */
4675 ++ if (right_type == BTRFS_FILE_EXTENT_INLINE) {
4676 ++ ret = 0;
4677 ++ goto out;
4678 ++ }
4679 ++
4680 + left_offset_fixed = left_offset;
4681 + if (key.offset < ekey->offset) {
4682 + /* Fix the right offset for 2a and 7. */
4683 +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
4684 +index 5900508ca6ed..4730ba2cc049 100644
4685 +--- a/fs/btrfs/volumes.c
4686 ++++ b/fs/btrfs/volumes.c
4687 +@@ -3765,6 +3765,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
4688 + struct btrfs_ioctl_balance_args *bargs)
4689 + {
4690 + struct btrfs_fs_info *fs_info = bctl->fs_info;
4691 ++ u64 meta_target, data_target;
4692 + u64 allowed;
4693 + int mixed = 0;
4694 + int ret;
4695 +@@ -3861,11 +3862,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
4696 + }
4697 + } while (read_seqretry(&fs_info->profiles_lock, seq));
4698 +
4699 +- if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
4700 +- btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
4701 ++ /* if we're not converting, the target field is uninitialized */
4702 ++ meta_target = (bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT) ?
4703 ++ bctl->meta.target : fs_info->avail_metadata_alloc_bits;
4704 ++ data_target = (bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) ?
4705 ++ bctl->data.target : fs_info->avail_data_alloc_bits;
4706 ++ if (btrfs_get_num_tolerated_disk_barrier_failures(meta_target) <
4707 ++ btrfs_get_num_tolerated_disk_barrier_failures(data_target)) {
4708 + btrfs_warn(fs_info,
4709 + "metadata profile 0x%llx has lower redundancy than data profile 0x%llx",
4710 +- bctl->meta.target, bctl->data.target);
4711 ++ meta_target, data_target);
4712 + }
4713 +
4714 + if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) {
4715 +diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
4716 +index abae6dd2c6b9..cc88f4f0325e 100644
4717 +--- a/fs/cifs/netmisc.c
4718 ++++ b/fs/cifs/netmisc.c
4719 +@@ -980,10 +980,10 @@ struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
4720 + cifs_dbg(VFS, "illegal hours %d\n", st->Hours);
4721 + days = sd->Day;
4722 + month = sd->Month;
4723 +- if ((days > 31) || (month > 12)) {
4724 ++ if (days < 1 || days > 31 || month < 1 || month > 12) {
4725 + cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days);
4726 +- if (month > 12)
4727 +- month = 12;
4728 ++ days = clamp(days, 1, 31);
4729 ++ month = clamp(month, 1, 12);
4730 + }
4731 + month -= 1;
4732 + days += total_days_of_prev_months[month];
4733 +diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
4734 +index 538d9b55699a..c3db2a882aee 100644
4735 +--- a/fs/cifs/sess.c
4736 ++++ b/fs/cifs/sess.c
4737 +@@ -344,13 +344,12 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
4738 + /* BB is NTLMV2 session security format easier to use here? */
4739 + flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET |
4740 + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE |
4741 +- NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC;
4742 +- if (ses->server->sign) {
4743 ++ NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC |
4744 ++ NTLMSSP_NEGOTIATE_SEAL;
4745 ++ if (ses->server->sign)
4746 + flags |= NTLMSSP_NEGOTIATE_SIGN;
4747 +- if (!ses->server->session_estab ||
4748 +- ses->ntlmssp->sesskey_per_smbsess)
4749 +- flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
4750 +- }
4751 ++ if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess)
4752 ++ flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
4753 +
4754 + sec_blob->NegotiateFlags = cpu_to_le32(flags);
4755 +
4756 +@@ -407,13 +406,12 @@ int build_ntlmssp_auth_blob(unsigned char **pbuffer,
4757 + flags = NTLMSSP_NEGOTIATE_56 |
4758 + NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO |
4759 + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE |
4760 +- NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC;
4761 +- if (ses->server->sign) {
4762 ++ NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC |
4763 ++ NTLMSSP_NEGOTIATE_SEAL;
4764 ++ if (ses->server->sign)
4765 + flags |= NTLMSSP_NEGOTIATE_SIGN;
4766 +- if (!ses->server->session_estab ||
4767 +- ses->ntlmssp->sesskey_per_smbsess)
4768 +- flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
4769 +- }
4770 ++ if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess)
4771 ++ flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
4772 +
4773 + tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE);
4774 + sec_blob->NegotiateFlags = cpu_to_le32(flags);
4775 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
4776 +index 94c4c1901222..7c26286a525d 100644
4777 +--- a/fs/cifs/smb2pdu.c
4778 ++++ b/fs/cifs/smb2pdu.c
4779 +@@ -707,15 +707,13 @@ SMB2_sess_establish_session(struct SMB2_sess_data *sess_data)
4780 + struct cifs_ses *ses = sess_data->ses;
4781 +
4782 + mutex_lock(&ses->server->srv_mutex);
4783 +- if (ses->server->sign && ses->server->ops->generate_signingkey) {
4784 ++ if (ses->server->ops->generate_signingkey) {
4785 + rc = ses->server->ops->generate_signingkey(ses);
4786 +- kfree(ses->auth_key.response);
4787 +- ses->auth_key.response = NULL;
4788 + if (rc) {
4789 + cifs_dbg(FYI,
4790 + "SMB3 session key generation failed\n");
4791 + mutex_unlock(&ses->server->srv_mutex);
4792 +- goto keygen_exit;
4793 ++ return rc;
4794 + }
4795 + }
4796 + if (!ses->server->session_estab) {
4797 +@@ -729,12 +727,6 @@ SMB2_sess_establish_session(struct SMB2_sess_data *sess_data)
4798 + ses->status = CifsGood;
4799 + ses->need_reconnect = false;
4800 + spin_unlock(&GlobalMid_Lock);
4801 +-
4802 +-keygen_exit:
4803 +- if (!ses->server->sign) {
4804 +- kfree(ses->auth_key.response);
4805 +- ses->auth_key.response = NULL;
4806 +- }
4807 + return rc;
4808 + }
4809 +
4810 +@@ -1712,6 +1704,9 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
4811 + } else
4812 + iov[0].iov_len = get_rfc1002_length(req) + 4;
4813 +
4814 ++ /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */
4815 ++ if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO)
4816 ++ req->hdr.Flags |= SMB2_FLAGS_SIGNED;
4817 +
4818 + rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
4819 + rsp = (struct smb2_ioctl_rsp *)iov[0].iov_base;
4820 +diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
4821 +index 7d4b557f1962..047c8ef620fe 100644
4822 +--- a/fs/jbd2/journal.c
4823 ++++ b/fs/jbd2/journal.c
4824 +@@ -691,8 +691,21 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
4825 + {
4826 + int err = 0;
4827 +
4828 +- jbd2_might_wait_for_commit(journal);
4829 + read_lock(&journal->j_state_lock);
4830 ++#ifdef CONFIG_PROVE_LOCKING
4831 ++ /*
4832 ++ * Some callers make sure transaction is already committing and in that
4833 ++ * case we cannot block on open handles anymore. So don't warn in that
4834 ++ * case.
4835 ++ */
4836 ++ if (tid_gt(tid, journal->j_commit_sequence) &&
4837 ++ (!journal->j_committing_transaction ||
4838 ++ journal->j_committing_transaction->t_tid != tid)) {
4839 ++ read_unlock(&journal->j_state_lock);
4840 ++ jbd2_might_wait_for_commit(journal);
4841 ++ read_lock(&journal->j_state_lock);
4842 ++ }
4843 ++#endif
4844 + #ifdef CONFIG_JBD2_DEBUG
4845 + if (!tid_geq(journal->j_commit_request, tid)) {
4846 + printk(KERN_ERR
4847 +diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
4848 +index 3d17fc82b9fe..892c88542ebd 100644
4849 +--- a/fs/nfs/pagelist.c
4850 ++++ b/fs/nfs/pagelist.c
4851 +@@ -1262,8 +1262,10 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index)
4852 + mirror = &desc->pg_mirrors[midx];
4853 + if (!list_empty(&mirror->pg_list)) {
4854 + prev = nfs_list_entry(mirror->pg_list.prev);
4855 +- if (index != prev->wb_index + 1)
4856 +- nfs_pageio_complete_mirror(desc, midx);
4857 ++ if (index != prev->wb_index + 1) {
4858 ++ nfs_pageio_complete(desc);
4859 ++ break;
4860 ++ }
4861 + }
4862 + }
4863 + }
4864 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
4865 +index b8e44746f761..0e008db16b16 100644
4866 +--- a/fs/nfs/pnfs.c
4867 ++++ b/fs/nfs/pnfs.c
4868 +@@ -1953,8 +1953,6 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,
4869 +
4870 + spin_lock(&inode->i_lock);
4871 + pnfs_set_plh_return_info(lo, range.iomode, 0);
4872 +- /* Block LAYOUTGET */
4873 +- set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
4874 + /*
4875 + * mark all matching lsegs so that we are sure to have no live
4876 + * segments at hand when sending layoutreturn. See pnfs_put_lseg()
4877 +@@ -2308,10 +2306,20 @@ pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr)
4878 + enum pnfs_try_status trypnfs;
4879 +
4880 + trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg);
4881 +- if (trypnfs == PNFS_TRY_AGAIN)
4882 +- pnfs_read_resend_pnfs(hdr);
4883 +- if (trypnfs == PNFS_NOT_ATTEMPTED || hdr->task.tk_status)
4884 ++ switch (trypnfs) {
4885 ++ case PNFS_NOT_ATTEMPTED:
4886 + pnfs_read_through_mds(desc, hdr);
4887 ++ case PNFS_ATTEMPTED:
4888 ++ break;
4889 ++ case PNFS_TRY_AGAIN:
4890 ++ /* cleanup hdr and prepare to redo pnfs */
4891 ++ if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
4892 ++ struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
4893 ++ list_splice_init(&hdr->pages, &mirror->pg_list);
4894 ++ mirror->pg_recoalesce = 1;
4895 ++ }
4896 ++ hdr->mds_ops->rpc_release(hdr);
4897 ++ }
4898 + }
4899 +
4900 + static void pnfs_readhdr_free(struct nfs_pgio_header *hdr)
4901 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
4902 +index 022d95886d66..eef0caf6e67d 100644
4903 +--- a/fs/nfsd/nfs4proc.c
4904 ++++ b/fs/nfsd/nfs4proc.c
4905 +@@ -1338,14 +1338,14 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
4906 + const struct nfsd4_layout_ops *ops;
4907 + struct nfs4_layout_stateid *ls;
4908 + __be32 nfserr;
4909 +- int accmode;
4910 ++ int accmode = NFSD_MAY_READ_IF_EXEC;
4911 +
4912 + switch (lgp->lg_seg.iomode) {
4913 + case IOMODE_READ:
4914 +- accmode = NFSD_MAY_READ;
4915 ++ accmode |= NFSD_MAY_READ;
4916 + break;
4917 + case IOMODE_RW:
4918 +- accmode = NFSD_MAY_READ | NFSD_MAY_WRITE;
4919 ++ accmode |= NFSD_MAY_READ | NFSD_MAY_WRITE;
4920 + break;
4921 + default:
4922 + dprintk("%s: invalid iomode %d\n",
4923 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
4924 +index b829cc9a9b39..8f0b19a3ca81 100644
4925 +--- a/fs/nfsd/vfs.c
4926 ++++ b/fs/nfsd/vfs.c
4927 +@@ -94,6 +94,12 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
4928 + err = follow_down(&path);
4929 + if (err < 0)
4930 + goto out;
4931 ++ if (path.mnt == exp->ex_path.mnt && path.dentry == dentry &&
4932 ++ nfsd_mountpoint(dentry, exp) == 2) {
4933 ++ /* This is only a mountpoint in some other namespace */
4934 ++ path_put(&path);
4935 ++ goto out;
4936 ++ }
4937 +
4938 + exp2 = rqst_exp_get_by_name(rqstp, &path);
4939 + if (IS_ERR(exp2)) {
4940 +@@ -167,16 +173,26 @@ static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, st
4941 + /*
4942 + * For nfsd purposes, we treat V4ROOT exports as though there was an
4943 + * export at *every* directory.
4944 ++ * We return:
4945 ++ * '1' if this dentry *must* be an export point,
4946 ++ * '2' if it might be, if there is really a mount here, and
4947 ++ * '0' if there is no chance of an export point here.
4948 + */
4949 + int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp)
4950 + {
4951 +- if (d_mountpoint(dentry))
4952 ++ if (!d_inode(dentry))
4953 ++ return 0;
4954 ++ if (exp->ex_flags & NFSEXP_V4ROOT)
4955 + return 1;
4956 + if (nfsd4_is_junction(dentry))
4957 + return 1;
4958 +- if (!(exp->ex_flags & NFSEXP_V4ROOT))
4959 +- return 0;
4960 +- return d_inode(dentry) != NULL;
4961 ++ if (d_mountpoint(dentry))
4962 ++ /*
4963 ++ * Might only be a mountpoint in a different namespace,
4964 ++ * but we need to check.
4965 ++ */
4966 ++ return 2;
4967 ++ return 0;
4968 + }
4969 +
4970 + __be32
4971 +diff --git a/fs/orangefs/waitqueue.c b/fs/orangefs/waitqueue.c
4972 +index f61b00887481..cbca58ba008a 100644
4973 +--- a/fs/orangefs/waitqueue.c
4974 ++++ b/fs/orangefs/waitqueue.c
4975 +@@ -124,7 +124,14 @@ int service_operation(struct orangefs_kernel_op_s *op,
4976 + gossip_debug(GOSSIP_WAIT_DEBUG,
4977 + "%s:client core is NOT in service.\n",
4978 + __func__);
4979 +- timeout = op_timeout_secs * HZ;
4980 ++ /*
4981 ++ * Don't wait for the userspace component to return if
4982 ++ * the filesystem is being umounted anyway.
4983 ++ */
4984 ++ if (op->upcall.type == ORANGEFS_VFS_OP_FS_UMOUNT)
4985 ++ timeout = 0;
4986 ++ else
4987 ++ timeout = op_timeout_secs * HZ;
4988 + }
4989 + spin_unlock(&orangefs_request_list_lock);
4990 +
4991 +diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
4992 +index c93dbadfc71d..db7d15b6a580 100644
4993 +--- a/include/acpi/actbl2.h
4994 ++++ b/include/acpi/actbl2.h
4995 +@@ -783,6 +783,15 @@ struct acpi_iort_smmu {
4996 + #define ACPI_IORT_SMMU_DVM_SUPPORTED (1)
4997 + #define ACPI_IORT_SMMU_COHERENT_WALK (1<<1)
4998 +
4999 ++/* Global interrupt format */
5000 ++
5001 ++struct acpi_iort_smmu_gsi {
5002 ++ u32 nsg_irpt;
5003 ++ u32 nsg_irpt_flags;
5004 ++ u32 nsg_cfg_irpt;
5005 ++ u32 nsg_cfg_irpt_flags;
5006 ++};
5007 ++
5008 + struct acpi_iort_smmu_v3 {
5009 + u64 base_address; /* SMMUv3 base address */
5010 + u32 flags;
5011 +diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
5012 +index 6a620e01b040..7751d72a6a40 100644
5013 +--- a/include/linux/mlx5/driver.h
5014 ++++ b/include/linux/mlx5/driver.h
5015 +@@ -380,8 +380,8 @@ struct mlx5_core_srq {
5016 + struct mlx5_core_rsc_common common; /* must be first */
5017 + u32 srqn;
5018 + int max;
5019 +- int max_gs;
5020 +- int max_avail_gather;
5021 ++ size_t max_gs;
5022 ++ size_t max_avail_gather;
5023 + int wqe_shift;
5024 + void (*event) (struct mlx5_core_srq *, enum mlx5_event);
5025 +
5026 +diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
5027 +index 34c4498b800f..83b22ae9ae12 100644
5028 +--- a/include/linux/posix-clock.h
5029 ++++ b/include/linux/posix-clock.h
5030 +@@ -59,23 +59,23 @@ struct posix_clock_operations {
5031 +
5032 + int (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
5033 +
5034 +- int (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
5035 ++ int (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
5036 +
5037 +- int (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
5038 ++ int (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
5039 +
5040 + int (*clock_settime)(struct posix_clock *pc,
5041 +- const struct timespec *ts);
5042 ++ const struct timespec64 *ts);
5043 +
5044 + int (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
5045 +
5046 + int (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
5047 +
5048 + void (*timer_gettime)(struct posix_clock *pc,
5049 +- struct k_itimer *kit, struct itimerspec *tsp);
5050 ++ struct k_itimer *kit, struct itimerspec64 *tsp);
5051 +
5052 + int (*timer_settime)(struct posix_clock *pc,
5053 + struct k_itimer *kit, int flags,
5054 +- struct itimerspec *tsp, struct itimerspec *old);
5055 ++ struct itimerspec64 *tsp, struct itimerspec64 *old);
5056 + /*
5057 + * Optional character device methods:
5058 + */
5059 +diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
5060 +index 70339d7958c0..0cd4c11479b1 100644
5061 +--- a/include/soc/fsl/qe/qe.h
5062 ++++ b/include/soc/fsl/qe/qe.h
5063 +@@ -243,6 +243,7 @@ static inline int qe_alive_during_sleep(void)
5064 + #define qe_muram_free cpm_muram_free
5065 + #define qe_muram_addr cpm_muram_addr
5066 + #define qe_muram_offset cpm_muram_offset
5067 ++#define qe_muram_dma cpm_muram_dma
5068 +
5069 + #define qe_setbits32(_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr))
5070 + #define qe_clrbits32(_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr))
5071 +diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
5072 +index ea41820ab12e..ed18aa4dceab 100644
5073 +--- a/kernel/irq/manage.c
5074 ++++ b/kernel/irq/manage.c
5075 +@@ -1210,8 +1210,10 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
5076 + * set the trigger type must match. Also all must
5077 + * agree on ONESHOT.
5078 + */
5079 ++ unsigned int oldtype = irqd_get_trigger_type(&desc->irq_data);
5080 ++
5081 + if (!((old->flags & new->flags) & IRQF_SHARED) ||
5082 +- ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
5083 ++ (oldtype != (new->flags & IRQF_TRIGGER_MASK)) ||
5084 + ((old->flags ^ new->flags) & IRQF_ONESHOT))
5085 + goto mismatch;
5086 +
5087 +diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
5088 +index 9cff0ab82b63..e24008c098c6 100644
5089 +--- a/kernel/time/posix-clock.c
5090 ++++ b/kernel/time/posix-clock.c
5091 +@@ -300,14 +300,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex *tx)
5092 + static int pc_clock_gettime(clockid_t id, struct timespec *ts)
5093 + {
5094 + struct posix_clock_desc cd;
5095 ++ struct timespec64 ts64;
5096 + int err;
5097 +
5098 + err = get_clock_desc(id, &cd);
5099 + if (err)
5100 + return err;
5101 +
5102 +- if (cd.clk->ops.clock_gettime)
5103 +- err = cd.clk->ops.clock_gettime(cd.clk, ts);
5104 ++ if (cd.clk->ops.clock_gettime) {
5105 ++ err = cd.clk->ops.clock_gettime(cd.clk, &ts64);
5106 ++ *ts = timespec64_to_timespec(ts64);
5107 ++ }
5108 + else
5109 + err = -EOPNOTSUPP;
5110 +
5111 +@@ -319,14 +322,17 @@ static int pc_clock_gettime(clockid_t id, struct timespec *ts)
5112 + static int pc_clock_getres(clockid_t id, struct timespec *ts)
5113 + {
5114 + struct posix_clock_desc cd;
5115 ++ struct timespec64 ts64;
5116 + int err;
5117 +
5118 + err = get_clock_desc(id, &cd);
5119 + if (err)
5120 + return err;
5121 +
5122 +- if (cd.clk->ops.clock_getres)
5123 +- err = cd.clk->ops.clock_getres(cd.clk, ts);
5124 ++ if (cd.clk->ops.clock_getres) {
5125 ++ err = cd.clk->ops.clock_getres(cd.clk, &ts64);
5126 ++ *ts = timespec64_to_timespec(ts64);
5127 ++ }
5128 + else
5129 + err = -EOPNOTSUPP;
5130 +
5131 +@@ -337,6 +343,7 @@ static int pc_clock_getres(clockid_t id, struct timespec *ts)
5132 +
5133 + static int pc_clock_settime(clockid_t id, const struct timespec *ts)
5134 + {
5135 ++ struct timespec64 ts64 = timespec_to_timespec64(*ts);
5136 + struct posix_clock_desc cd;
5137 + int err;
5138 +
5139 +@@ -350,7 +357,7 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts)
5140 + }
5141 +
5142 + if (cd.clk->ops.clock_settime)
5143 +- err = cd.clk->ops.clock_settime(cd.clk, ts);
5144 ++ err = cd.clk->ops.clock_settime(cd.clk, &ts64);
5145 + else
5146 + err = -EOPNOTSUPP;
5147 + out:
5148 +@@ -403,29 +410,36 @@ static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec *ts)
5149 + {
5150 + clockid_t id = kit->it_clock;
5151 + struct posix_clock_desc cd;
5152 ++ struct itimerspec64 ts64;
5153 +
5154 + if (get_clock_desc(id, &cd))
5155 + return;
5156 +
5157 +- if (cd.clk->ops.timer_gettime)
5158 +- cd.clk->ops.timer_gettime(cd.clk, kit, ts);
5159 +-
5160 ++ if (cd.clk->ops.timer_gettime) {
5161 ++ cd.clk->ops.timer_gettime(cd.clk, kit, &ts64);
5162 ++ *ts = itimerspec64_to_itimerspec(&ts64);
5163 ++ }
5164 + put_clock_desc(&cd);
5165 + }
5166 +
5167 + static int pc_timer_settime(struct k_itimer *kit, int flags,
5168 + struct itimerspec *ts, struct itimerspec *old)
5169 + {
5170 ++ struct itimerspec64 ts64 = itimerspec_to_itimerspec64(ts);
5171 + clockid_t id = kit->it_clock;
5172 + struct posix_clock_desc cd;
5173 ++ struct itimerspec64 old64;
5174 + int err;
5175 +
5176 + err = get_clock_desc(id, &cd);
5177 + if (err)
5178 + return err;
5179 +
5180 +- if (cd.clk->ops.timer_settime)
5181 +- err = cd.clk->ops.timer_settime(cd.clk, kit, flags, ts, old);
5182 ++ if (cd.clk->ops.timer_settime) {
5183 ++ err = cd.clk->ops.timer_settime(cd.clk, kit, flags, &ts64, &old64);
5184 ++ if (old)
5185 ++ *old = itimerspec64_to_itimerspec(&old64);
5186 ++ }
5187 + else
5188 + err = -EOPNOTSUPP;
5189 +
5190 +diff --git a/mm/memory-failure.c b/mm/memory-failure.c
5191 +index 5aa71a82ca73..851efb004857 100644
5192 +--- a/mm/memory-failure.c
5193 ++++ b/mm/memory-failure.c
5194 +@@ -921,6 +921,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
5195 + int ret;
5196 + int kill = 1, forcekill;
5197 + struct page *hpage = *hpagep;
5198 ++ bool mlocked = PageMlocked(hpage);
5199 +
5200 + /*
5201 + * Here we are interested only in user-mapped pages, so skip any
5202 +@@ -984,6 +985,13 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
5203 + pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n",
5204 + pfn, page_mapcount(hpage));
5205 +
5206 ++ /*
5207 ++ * try_to_unmap() might put mlocked page in lru cache, so call
5208 ++ * shake_page() again to ensure that it's flushed.
5209 ++ */
5210 ++ if (mlocked)
5211 ++ shake_page(hpage, 0);
5212 ++
5213 + /*
5214 + * Now that the dirty bit has been propagated to the
5215 + * struct page and all unmaps done we can decide if
5216 +diff --git a/mm/vmscan.c b/mm/vmscan.c
5217 +index 4365de74bdb0..cdd5c3b5c357 100644
5218 +--- a/mm/vmscan.c
5219 ++++ b/mm/vmscan.c
5220 +@@ -2841,8 +2841,10 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)
5221 +
5222 + for (i = 0; i <= ZONE_NORMAL; i++) {
5223 + zone = &pgdat->node_zones[i];
5224 +- if (!managed_zone(zone) ||
5225 +- pgdat_reclaimable_pages(pgdat) == 0)
5226 ++ if (!managed_zone(zone))
5227 ++ continue;
5228 ++
5229 ++ if (!zone_reclaimable_pages(zone))
5230 + continue;
5231 +
5232 + pfmemalloc_reserve += min_wmark_pages(zone);
5233 +diff --git a/mm/vmstat.c b/mm/vmstat.c
5234 +index 3863b5d6d598..68b3193e4493 100644
5235 +--- a/mm/vmstat.c
5236 ++++ b/mm/vmstat.c
5237 +@@ -1387,18 +1387,24 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
5238 + zone->present_pages,
5239 + zone->managed_pages);
5240 +
5241 +- for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
5242 +- seq_printf(m, "\n %-12s %lu", vmstat_text[i],
5243 +- zone_page_state(zone, i));
5244 +-
5245 + seq_printf(m,
5246 + "\n protection: (%ld",
5247 + zone->lowmem_reserve[0]);
5248 + for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
5249 + seq_printf(m, ", %ld", zone->lowmem_reserve[i]);
5250 +- seq_printf(m,
5251 +- ")"
5252 +- "\n pagesets");
5253 ++ seq_putc(m, ')');
5254 ++
5255 ++ /* If unpopulated, no other information is useful */
5256 ++ if (!populated_zone(zone)) {
5257 ++ seq_putc(m, '\n');
5258 ++ return;
5259 ++ }
5260 ++
5261 ++ for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
5262 ++ seq_printf(m, "\n %-12s %lu", vmstat_text[i],
5263 ++ zone_page_state(zone, i));
5264 ++
5265 ++ seq_printf(m, "\n pagesets");
5266 + for_each_online_cpu(i) {
5267 + struct per_cpu_pageset *pageset;
5268 +
5269 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
5270 +index 2f107e46355c..b5f264ae3bff 100644
5271 +--- a/net/ipv4/tcp_input.c
5272 ++++ b/net/ipv4/tcp_input.c
5273 +@@ -5606,10 +5606,6 @@ void tcp_finish_connect(struct sock *sk, struct sk_buff *skb)
5274 + else
5275 + tp->pred_flags = 0;
5276 +
5277 +- if (!sock_flag(sk, SOCK_DEAD)) {
5278 +- sk->sk_state_change(sk);
5279 +- sk_wake_async(sk, SOCK_WAKE_IO, POLL_OUT);
5280 +- }
5281 + }
5282 +
5283 + static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
5284 +@@ -5678,6 +5674,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
5285 + struct tcp_sock *tp = tcp_sk(sk);
5286 + struct tcp_fastopen_cookie foc = { .len = -1 };
5287 + int saved_clamp = tp->rx_opt.mss_clamp;
5288 ++ bool fastopen_fail;
5289 +
5290 + tcp_parse_options(skb, &tp->rx_opt, 0, &foc);
5291 + if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr)
5292 +@@ -5781,10 +5778,15 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
5293 +
5294 + tcp_finish_connect(sk, skb);
5295 +
5296 +- if ((tp->syn_fastopen || tp->syn_data) &&
5297 +- tcp_rcv_fastopen_synack(sk, skb, &foc))
5298 +- return -1;
5299 ++ fastopen_fail = (tp->syn_fastopen || tp->syn_data) &&
5300 ++ tcp_rcv_fastopen_synack(sk, skb, &foc);
5301 +
5302 ++ if (!sock_flag(sk, SOCK_DEAD)) {
5303 ++ sk->sk_state_change(sk);
5304 ++ sk_wake_async(sk, SOCK_WAKE_IO, POLL_OUT);
5305 ++ }
5306 ++ if (fastopen_fail)
5307 ++ return -1;
5308 + if (sk->sk_write_pending ||
5309 + icsk->icsk_accept_queue.rskq_defer_accept ||
5310 + icsk->icsk_ack.pingpong) {
5311 +diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
5312 +index 912333586de6..345efeb887ef 100644
5313 +--- a/net/ipv6/ip6_vti.c
5314 ++++ b/net/ipv6/ip6_vti.c
5315 +@@ -625,6 +625,7 @@ static void vti6_link_config(struct ip6_tnl *t)
5316 + {
5317 + struct net_device *dev = t->dev;
5318 + struct __ip6_tnl_parm *p = &t->parms;
5319 ++ struct net_device *tdev = NULL;
5320 +
5321 + memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
5322 + memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
5323 +@@ -637,6 +638,25 @@ static void vti6_link_config(struct ip6_tnl *t)
5324 + dev->flags |= IFF_POINTOPOINT;
5325 + else
5326 + dev->flags &= ~IFF_POINTOPOINT;
5327 ++
5328 ++ if (p->flags & IP6_TNL_F_CAP_XMIT) {
5329 ++ int strict = (ipv6_addr_type(&p->raddr) &
5330 ++ (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
5331 ++ struct rt6_info *rt = rt6_lookup(t->net,
5332 ++ &p->raddr, &p->laddr,
5333 ++ p->link, strict);
5334 ++
5335 ++ if (rt)
5336 ++ tdev = rt->dst.dev;
5337 ++ ip6_rt_put(rt);
5338 ++ }
5339 ++
5340 ++ if (!tdev && p->link)
5341 ++ tdev = __dev_get_by_index(t->net, p->link);
5342 ++
5343 ++ if (tdev)
5344 ++ dev->mtu = max_t(int, tdev->mtu - dev->hard_header_len,
5345 ++ IPV6_MIN_MTU);
5346 + }
5347 +
5348 + /**
5349 +diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
5350 +index d8e671457d10..41c22cb33424 100644
5351 +--- a/net/ipv6/ndisc.c
5352 ++++ b/net/ipv6/ndisc.c
5353 +@@ -1723,6 +1723,8 @@ static int ndisc_netdev_event(struct notifier_block *this, unsigned long event,
5354 + case NETDEV_CHANGEADDR:
5355 + neigh_changeaddr(&nd_tbl, dev);
5356 + fib6_run_gc(0, net, false);
5357 ++ /* fallthrough */
5358 ++ case NETDEV_UP:
5359 + idev = in6_dev_get(dev);
5360 + if (!idev)
5361 + break;
5362 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
5363 +index dee60428c78c..efa2a2fcae72 100644
5364 +--- a/net/mac80211/cfg.c
5365 ++++ b/net/mac80211/cfg.c
5366 +@@ -620,10 +620,11 @@ void sta_set_rate_info_tx(struct sta_info *sta,
5367 + int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
5368 + u16 brate;
5369 +
5370 +- sband = sta->local->hw.wiphy->bands[
5371 +- ieee80211_get_sdata_band(sta->sdata)];
5372 +- brate = sband->bitrates[rate->idx].bitrate;
5373 +- rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
5374 ++ sband = ieee80211_get_sband(sta->sdata);
5375 ++ if (sband) {
5376 ++ brate = sband->bitrates[rate->idx].bitrate;
5377 ++ rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
5378 ++ }
5379 + }
5380 + if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
5381 + rinfo->bw = RATE_INFO_BW_40;
5382 +@@ -1218,10 +1219,11 @@ static int sta_apply_parameters(struct ieee80211_local *local,
5383 + int ret = 0;
5384 + struct ieee80211_supported_band *sband;
5385 + struct ieee80211_sub_if_data *sdata = sta->sdata;
5386 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5387 + u32 mask, set;
5388 +
5389 +- sband = local->hw.wiphy->bands[band];
5390 ++ sband = ieee80211_get_sband(sdata);
5391 ++ if (!sband)
5392 ++ return -EINVAL;
5393 +
5394 + mask = params->sta_flags_mask;
5395 + set = params->sta_flags_set;
5396 +@@ -1354,7 +1356,7 @@ static int sta_apply_parameters(struct ieee80211_local *local,
5397 + ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
5398 + sband, params->supported_rates,
5399 + params->supported_rates_len,
5400 +- &sta->sta.supp_rates[band]);
5401 ++ &sta->sta.supp_rates[sband->band]);
5402 + }
5403 +
5404 + if (params->ht_capa)
5405 +@@ -1370,8 +1372,8 @@ static int sta_apply_parameters(struct ieee80211_local *local,
5406 + /* returned value is only needed for rc update, but the
5407 + * rc isn't initialized here yet, so ignore it
5408 + */
5409 +- __ieee80211_vht_handle_opmode(sdata, sta,
5410 +- params->opmode_notif, band);
5411 ++ __ieee80211_vht_handle_opmode(sdata, sta, params->opmode_notif,
5412 ++ sband->band);
5413 + }
5414 +
5415 + if (params->support_p2p_ps >= 0)
5416 +@@ -2017,13 +2019,15 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
5417 + struct bss_parameters *params)
5418 + {
5419 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5420 +- enum nl80211_band band;
5421 ++ struct ieee80211_supported_band *sband;
5422 + u32 changed = 0;
5423 +
5424 + if (!sdata_dereference(sdata->u.ap.beacon, sdata))
5425 + return -ENOENT;
5426 +
5427 +- band = ieee80211_get_sdata_band(sdata);
5428 ++ sband = ieee80211_get_sband(sdata);
5429 ++ if (!sband)
5430 ++ return -EINVAL;
5431 +
5432 + if (params->use_cts_prot >= 0) {
5433 + sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
5434 +@@ -2036,7 +2040,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
5435 + }
5436 +
5437 + if (!sdata->vif.bss_conf.use_short_slot &&
5438 +- band == NL80211_BAND_5GHZ) {
5439 ++ sband->band == NL80211_BAND_5GHZ) {
5440 + sdata->vif.bss_conf.use_short_slot = true;
5441 + changed |= BSS_CHANGED_ERP_SLOT;
5442 + }
5443 +@@ -2049,7 +2053,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
5444 +
5445 + if (params->basic_rates) {
5446 + ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
5447 +- wiphy->bands[band],
5448 ++ wiphy->bands[sband->band],
5449 + params->basic_rates,
5450 + params->basic_rates_len,
5451 + &sdata->vif.bss_conf.basic_rates);
5452 +diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
5453 +index 62d13eabe17f..d31818e7d10c 100644
5454 +--- a/net/mac80211/ibss.c
5455 ++++ b/net/mac80211/ibss.c
5456 +@@ -994,7 +994,7 @@ static void ieee80211_update_sta_info(struct ieee80211_sub_if_data *sdata,
5457 + enum nl80211_band band = rx_status->band;
5458 + enum nl80211_bss_scan_width scan_width;
5459 + struct ieee80211_local *local = sdata->local;
5460 +- struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
5461 ++ struct ieee80211_supported_band *sband;
5462 + bool rates_updated = false;
5463 + u32 supp_rates = 0;
5464 +
5465 +@@ -1004,6 +1004,10 @@ static void ieee80211_update_sta_info(struct ieee80211_sub_if_data *sdata,
5466 + if (!ether_addr_equal(mgmt->bssid, sdata->u.ibss.bssid))
5467 + return;
5468 +
5469 ++ sband = local->hw.wiphy->bands[band];
5470 ++ if (WARN_ON(!sband))
5471 ++ return;
5472 ++
5473 + rcu_read_lock();
5474 + sta = sta_info_get(sdata, mgmt->sa);
5475 +
5476 +diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
5477 +index 03dbc6bd8598..7fd544d970d9 100644
5478 +--- a/net/mac80211/ieee80211_i.h
5479 ++++ b/net/mac80211/ieee80211_i.h
5480 +@@ -991,21 +991,6 @@ sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
5481 + lockdep_assert_held(&sdata->wdev.mtx);
5482 + }
5483 +
5484 +-static inline enum nl80211_band
5485 +-ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
5486 +-{
5487 +- enum nl80211_band band = NL80211_BAND_2GHZ;
5488 +- struct ieee80211_chanctx_conf *chanctx_conf;
5489 +-
5490 +- rcu_read_lock();
5491 +- chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
5492 +- if (!WARN_ON(!chanctx_conf))
5493 +- band = chanctx_conf->def.chan->band;
5494 +- rcu_read_unlock();
5495 +-
5496 +- return band;
5497 +-}
5498 +-
5499 + static inline int
5500 + ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
5501 + {
5502 +@@ -1410,6 +1395,27 @@ IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
5503 + return container_of(wdev, struct ieee80211_sub_if_data, wdev);
5504 + }
5505 +
5506 ++static inline struct ieee80211_supported_band *
5507 ++ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
5508 ++{
5509 ++ struct ieee80211_local *local = sdata->local;
5510 ++ struct ieee80211_chanctx_conf *chanctx_conf;
5511 ++ enum nl80211_band band;
5512 ++
5513 ++ rcu_read_lock();
5514 ++ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
5515 ++
5516 ++ if (WARN_ON(!chanctx_conf)) {
5517 ++ rcu_read_unlock();
5518 ++ return NULL;
5519 ++ }
5520 ++
5521 ++ band = chanctx_conf->def.chan->band;
5522 ++ rcu_read_unlock();
5523 ++
5524 ++ return local->hw.wiphy->bands[band];
5525 ++}
5526 ++
5527 + /* this struct represents 802.11n's RA/TID combination */
5528 + struct ieee80211_ra_tid {
5529 + u8 ra[ETH_ALEN];
5530 +diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
5531 +index b4b3fe078868..b2a27263d6ff 100644
5532 +--- a/net/mac80211/mesh.c
5533 ++++ b/net/mac80211/mesh.c
5534 +@@ -63,6 +63,7 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
5535 + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
5536 + u32 basic_rates = 0;
5537 + struct cfg80211_chan_def sta_chan_def;
5538 ++ struct ieee80211_supported_band *sband;
5539 +
5540 + /*
5541 + * As support for each feature is added, check for matching
5542 +@@ -83,7 +84,11 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
5543 + (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)))
5544 + return false;
5545 +
5546 +- ieee80211_sta_get_rates(sdata, ie, ieee80211_get_sdata_band(sdata),
5547 ++ sband = ieee80211_get_sband(sdata);
5548 ++ if (!sband)
5549 ++ return false;
5550 ++
5551 ++ ieee80211_sta_get_rates(sdata, ie, sband->band,
5552 + &basic_rates);
5553 +
5554 + if (sdata->vif.bss_conf.basic_rates != basic_rates)
5555 +@@ -399,12 +404,13 @@ static int mesh_add_ds_params_ie(struct ieee80211_sub_if_data *sdata,
5556 + int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
5557 + struct sk_buff *skb)
5558 + {
5559 +- struct ieee80211_local *local = sdata->local;
5560 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5561 + struct ieee80211_supported_band *sband;
5562 + u8 *pos;
5563 +
5564 +- sband = local->hw.wiphy->bands[band];
5565 ++ sband = ieee80211_get_sband(sdata);
5566 ++ if (!sband)
5567 ++ return -EINVAL;
5568 ++
5569 + if (!sband->ht_cap.ht_supported ||
5570 + sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
5571 + sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
5572 +@@ -462,12 +468,13 @@ int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
5573 + int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
5574 + struct sk_buff *skb)
5575 + {
5576 +- struct ieee80211_local *local = sdata->local;
5577 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5578 + struct ieee80211_supported_band *sband;
5579 + u8 *pos;
5580 +
5581 +- sband = local->hw.wiphy->bands[band];
5582 ++ sband = ieee80211_get_sband(sdata);
5583 ++ if (!sband)
5584 ++ return -EINVAL;
5585 ++
5586 + if (!sband->vht_cap.vht_supported ||
5587 + sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
5588 + sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
5589 +@@ -916,12 +923,16 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
5590 + struct cfg80211_csa_settings params;
5591 + struct ieee80211_csa_ie csa_ie;
5592 + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
5593 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5594 ++ struct ieee80211_supported_band *sband;
5595 + int err;
5596 + u32 sta_flags;
5597 +
5598 + sdata_assert_lock(sdata);
5599 +
5600 ++ sband = ieee80211_get_sband(sdata);
5601 ++ if (!sband)
5602 ++ return false;
5603 ++
5604 + sta_flags = IEEE80211_STA_DISABLE_VHT;
5605 + switch (sdata->vif.bss_conf.chandef.width) {
5606 + case NL80211_CHAN_WIDTH_20_NOHT:
5607 +@@ -935,7 +946,7 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
5608 +
5609 + memset(&params, 0, sizeof(params));
5610 + memset(&csa_ie, 0, sizeof(csa_ie));
5611 +- err = ieee80211_parse_ch_switch_ie(sdata, elems, band,
5612 ++ err = ieee80211_parse_ch_switch_ie(sdata, elems, sband->band,
5613 + sta_flags, sdata->vif.addr,
5614 + &csa_ie);
5615 + if (err < 0)
5616 +diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
5617 +index fcba70e57073..2d3c4695e75b 100644
5618 +--- a/net/mac80211/mesh_plink.c
5619 ++++ b/net/mac80211/mesh_plink.c
5620 +@@ -93,19 +93,23 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta)
5621 + static u32 mesh_set_short_slot_time(struct ieee80211_sub_if_data *sdata)
5622 + {
5623 + struct ieee80211_local *local = sdata->local;
5624 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5625 +- struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
5626 ++ struct ieee80211_supported_band *sband;
5627 + struct sta_info *sta;
5628 + u32 erp_rates = 0, changed = 0;
5629 + int i;
5630 + bool short_slot = false;
5631 +
5632 +- if (band == NL80211_BAND_5GHZ) {
5633 ++ sband = ieee80211_get_sband(sdata);
5634 ++ if (!sband)
5635 ++ return changed;
5636 ++
5637 ++ if (sband->band == NL80211_BAND_5GHZ) {
5638 + /* (IEEE 802.11-2012 19.4.5) */
5639 + short_slot = true;
5640 + goto out;
5641 +- } else if (band != NL80211_BAND_2GHZ)
5642 ++ } else if (sband->band != NL80211_BAND_2GHZ) {
5643 + goto out;
5644 ++ }
5645 +
5646 + for (i = 0; i < sband->n_bitrates; i++)
5647 + if (sband->bitrates[i].flags & IEEE80211_RATE_ERP_G)
5648 +@@ -121,7 +125,7 @@ static u32 mesh_set_short_slot_time(struct ieee80211_sub_if_data *sdata)
5649 + continue;
5650 +
5651 + short_slot = false;
5652 +- if (erp_rates & sta->sta.supp_rates[band])
5653 ++ if (erp_rates & sta->sta.supp_rates[sband->band])
5654 + short_slot = true;
5655 + else
5656 + break;
5657 +@@ -247,7 +251,15 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
5658 + mgmt->u.action.u.self_prot.action_code = action;
5659 +
5660 + if (action != WLAN_SP_MESH_PEERING_CLOSE) {
5661 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5662 ++ struct ieee80211_supported_band *sband;
5663 ++ enum nl80211_band band;
5664 ++
5665 ++ sband = ieee80211_get_sband(sdata);
5666 ++ if (!sband) {
5667 ++ err = -EINVAL;
5668 ++ goto free;
5669 ++ }
5670 ++ band = sband->band;
5671 +
5672 + /* capability info */
5673 + pos = skb_put(skb, 2);
5674 +@@ -393,13 +405,16 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
5675 + struct ieee802_11_elems *elems, bool insert)
5676 + {
5677 + struct ieee80211_local *local = sdata->local;
5678 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5679 + struct ieee80211_supported_band *sband;
5680 + u32 rates, basic_rates = 0, changed = 0;
5681 + enum ieee80211_sta_rx_bandwidth bw = sta->sta.bandwidth;
5682 +
5683 +- sband = local->hw.wiphy->bands[band];
5684 +- rates = ieee80211_sta_get_rates(sdata, elems, band, &basic_rates);
5685 ++ sband = ieee80211_get_sband(sdata);
5686 ++ if (!sband)
5687 ++ return;
5688 ++
5689 ++ rates = ieee80211_sta_get_rates(sdata, elems, sband->band,
5690 ++ &basic_rates);
5691 +
5692 + spin_lock_bh(&sta->mesh->plink_lock);
5693 + sta->rx_stats.last_rx = jiffies;
5694 +@@ -410,9 +425,9 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
5695 + goto out;
5696 + sta->mesh->processed_beacon = true;
5697 +
5698 +- if (sta->sta.supp_rates[band] != rates)
5699 ++ if (sta->sta.supp_rates[sband->band] != rates)
5700 + changed |= IEEE80211_RC_SUPP_RATES_CHANGED;
5701 +- sta->sta.supp_rates[band] = rates;
5702 ++ sta->sta.supp_rates[sband->band] = rates;
5703 +
5704 + if (ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
5705 + elems->ht_cap_elem, sta))
5706 +diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
5707 +index 1118c61f835d..fdab4f1390d2 100644
5708 +--- a/net/mac80211/mlme.c
5709 ++++ b/net/mac80211/mlme.c
5710 +@@ -1851,11 +1851,16 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
5711 + u16 capab, bool erp_valid, u8 erp)
5712 + {
5713 + struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
5714 ++ struct ieee80211_supported_band *sband;
5715 + u32 changed = 0;
5716 + bool use_protection;
5717 + bool use_short_preamble;
5718 + bool use_short_slot;
5719 +
5720 ++ sband = ieee80211_get_sband(sdata);
5721 ++ if (!sband)
5722 ++ return changed;
5723 ++
5724 + if (erp_valid) {
5725 + use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
5726 + use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
5727 +@@ -1865,7 +1870,7 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
5728 + }
5729 +
5730 + use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
5731 +- if (ieee80211_get_sdata_band(sdata) == NL80211_BAND_5GHZ)
5732 ++ if (sband->band == NL80211_BAND_5GHZ)
5733 + use_short_slot = true;
5734 +
5735 + if (use_protection != bss_conf->use_cts_prot) {
5736 +@@ -2994,7 +2999,12 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
5737 + goto out;
5738 + }
5739 +
5740 +- sband = local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)];
5741 ++ sband = ieee80211_get_sband(sdata);
5742 ++ if (!sband) {
5743 ++ mutex_unlock(&sdata->local->sta_mtx);
5744 ++ ret = false;
5745 ++ goto out;
5746 ++ }
5747 +
5748 + /* Set up internal HT/VHT capabilities */
5749 + if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_HT))
5750 +diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
5751 +index 206698bc93f4..dbceb42c2a8e 100644
5752 +--- a/net/mac80211/rate.c
5753 ++++ b/net/mac80211/rate.c
5754 +@@ -875,7 +875,9 @@ int rate_control_set_rates(struct ieee80211_hw *hw,
5755 + struct ieee80211_sta_rates *old;
5756 + struct ieee80211_supported_band *sband;
5757 +
5758 +- sband = hw->wiphy->bands[ieee80211_get_sdata_band(sta->sdata)];
5759 ++ sband = ieee80211_get_sband(sta->sdata);
5760 ++ if (!sband)
5761 ++ return -EINVAL;
5762 + rate_control_apply_mask_ratetbl(sta, sband, rates);
5763 + /*
5764 + * mac80211 guarantees that this function will not be called
5765 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
5766 +index 348700b424ea..1ecf3d07d1f5 100644
5767 +--- a/net/mac80211/sta_info.c
5768 ++++ b/net/mac80211/sta_info.c
5769 +@@ -395,10 +395,15 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
5770 + sta->sta.smps_mode = IEEE80211_SMPS_OFF;
5771 + if (sdata->vif.type == NL80211_IFTYPE_AP ||
5772 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
5773 +- struct ieee80211_supported_band *sband =
5774 +- hw->wiphy->bands[ieee80211_get_sdata_band(sdata)];
5775 +- u8 smps = (sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >>
5776 +- IEEE80211_HT_CAP_SM_PS_SHIFT;
5777 ++ struct ieee80211_supported_band *sband;
5778 ++ u8 smps;
5779 ++
5780 ++ sband = ieee80211_get_sband(sdata);
5781 ++ if (!sband)
5782 ++ goto free_txq;
5783 ++
5784 ++ smps = (sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >>
5785 ++ IEEE80211_HT_CAP_SM_PS_SHIFT;
5786 + /*
5787 + * Assume that hostapd advertises our caps in the beacon and
5788 + * this is the known_smps_mode for a station that just assciated
5789 +diff --git a/net/mac80211/status.c b/net/mac80211/status.c
5790 +index ad37b4e58c2f..72fe9bc7a1f9 100644
5791 +--- a/net/mac80211/status.c
5792 ++++ b/net/mac80211/status.c
5793 +@@ -200,6 +200,7 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
5794 + }
5795 +
5796 + if (ieee80211_is_action(mgmt->frame_control) &&
5797 ++ !ieee80211_has_protected(mgmt->frame_control) &&
5798 + mgmt->u.action.category == WLAN_CATEGORY_HT &&
5799 + mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS &&
5800 + ieee80211_sdata_running(sdata)) {
5801 +diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
5802 +index afca7d103684..f20dcf1b1830 100644
5803 +--- a/net/mac80211/tdls.c
5804 ++++ b/net/mac80211/tdls.c
5805 +@@ -47,8 +47,7 @@ static void ieee80211_tdls_add_ext_capab(struct ieee80211_sub_if_data *sdata,
5806 + NL80211_FEATURE_TDLS_CHANNEL_SWITCH;
5807 + bool wider_band = ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
5808 + !ifmgd->tdls_wider_bw_prohibited;
5809 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5810 +- struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
5811 ++ struct ieee80211_supported_band *sband = ieee80211_get_sband(sdata);
5812 + bool vht = sband && sband->vht_cap.vht_supported;
5813 + u8 *pos = (void *)skb_put(skb, 10);
5814 +
5815 +@@ -180,11 +179,14 @@ static void ieee80211_tdls_add_bss_coex_ie(struct sk_buff *skb)
5816 + static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata,
5817 + u16 status_code)
5818 + {
5819 ++ struct ieee80211_supported_band *sband;
5820 ++
5821 + /* The capability will be 0 when sending a failure code */
5822 + if (status_code != 0)
5823 + return 0;
5824 +
5825 +- if (ieee80211_get_sdata_band(sdata) == NL80211_BAND_2GHZ) {
5826 ++ sband = ieee80211_get_sband(sdata);
5827 ++ if (sband && sband->band == NL80211_BAND_2GHZ) {
5828 + return WLAN_CAPABILITY_SHORT_SLOT_TIME |
5829 + WLAN_CAPABILITY_SHORT_PREAMBLE;
5830 + }
5831 +@@ -358,17 +360,20 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata,
5832 + u8 action_code, bool initiator,
5833 + const u8 *extra_ies, size_t extra_ies_len)
5834 + {
5835 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5836 +- struct ieee80211_local *local = sdata->local;
5837 + struct ieee80211_supported_band *sband;
5838 ++ struct ieee80211_local *local = sdata->local;
5839 + struct ieee80211_sta_ht_cap ht_cap;
5840 + struct ieee80211_sta_vht_cap vht_cap;
5841 + struct sta_info *sta = NULL;
5842 + size_t offset = 0, noffset;
5843 + u8 *pos;
5844 +
5845 +- ieee80211_add_srates_ie(sdata, skb, false, band);
5846 +- ieee80211_add_ext_srates_ie(sdata, skb, false, band);
5847 ++ sband = ieee80211_get_sband(sdata);
5848 ++ if (!sband)
5849 ++ return;
5850 ++
5851 ++ ieee80211_add_srates_ie(sdata, skb, false, sband->band);
5852 ++ ieee80211_add_ext_srates_ie(sdata, skb, false, sband->band);
5853 + ieee80211_tdls_add_supp_channels(sdata, skb);
5854 +
5855 + /* add any custom IEs that go before Extended Capabilities */
5856 +@@ -439,7 +444,6 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata,
5857 + * the same on all bands. The specification limits the setup to a
5858 + * single HT-cap, so use the current band for now.
5859 + */
5860 +- sband = local->hw.wiphy->bands[band];
5861 + memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap));
5862 +
5863 + if ((action_code == WLAN_TDLS_SETUP_REQUEST ||
5864 +@@ -545,9 +549,13 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata,
5865 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
5866 + size_t offset = 0, noffset;
5867 + struct sta_info *sta, *ap_sta;
5868 +- enum nl80211_band band = ieee80211_get_sdata_band(sdata);
5869 ++ struct ieee80211_supported_band *sband;
5870 + u8 *pos;
5871 +
5872 ++ sband = ieee80211_get_sband(sdata);
5873 ++ if (!sband)
5874 ++ return;
5875 ++
5876 + mutex_lock(&local->sta_mtx);
5877 +
5878 + sta = sta_info_get(sdata, peer);
5879 +@@ -612,7 +620,8 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata,
5880 + ieee80211_tdls_add_link_ie(sdata, skb, peer, initiator);
5881 +
5882 + /* only include VHT-operation if not on the 2.4GHz band */
5883 +- if (band != NL80211_BAND_2GHZ && sta->sta.vht_cap.vht_supported) {
5884 ++ if (sband->band != NL80211_BAND_2GHZ &&
5885 ++ sta->sta.vht_cap.vht_supported) {
5886 + /*
5887 + * if both peers support WIDER_BW, we can expand the chandef to
5888 + * a wider compatible one, up to 80MHz
5889 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
5890 +index 1ffd1e145c13..84582998f65f 100644
5891 +--- a/net/mac80211/tx.c
5892 ++++ b/net/mac80211/tx.c
5893 +@@ -4182,7 +4182,10 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
5894 + return bcn;
5895 +
5896 + shift = ieee80211_vif_get_shift(vif);
5897 +- sband = hw->wiphy->bands[ieee80211_get_sdata_band(vif_to_sdata(vif))];
5898 ++ sband = ieee80211_get_sband(vif_to_sdata(vif));
5899 ++ if (!sband)
5900 ++ return bcn;
5901 ++
5902 + ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, false);
5903 +
5904 + return bcn;
5905 +diff --git a/net/mac80211/util.c b/net/mac80211/util.c
5906 +index 545c79a42a77..a2756096b94a 100644
5907 +--- a/net/mac80211/util.c
5908 ++++ b/net/mac80211/util.c
5909 +@@ -1590,14 +1590,14 @@ u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
5910 + size_t num_rates;
5911 + u32 supp_rates, rate_flags;
5912 + int i, j, shift;
5913 ++
5914 + sband = sdata->local->hw.wiphy->bands[band];
5915 ++ if (WARN_ON(!sband))
5916 ++ return 1;
5917 +
5918 + rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef);
5919 + shift = ieee80211_vif_get_shift(&sdata->vif);
5920 +
5921 +- if (WARN_ON(!sband))
5922 +- return 1;
5923 +-
5924 + num_rates = sband->n_bitrates;
5925 + supp_rates = 0;
5926 + for (i = 0; i < elems->supp_rates_len +
5927 +diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
5928 +index 2155c2498aed..74d119512d96 100644
5929 +--- a/net/netfilter/ipvs/ip_vs_ctl.c
5930 ++++ b/net/netfilter/ipvs/ip_vs_ctl.c
5931 +@@ -3092,6 +3092,17 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb,
5932 + return skb->len;
5933 + }
5934 +
5935 ++static bool ip_vs_is_af_valid(int af)
5936 ++{
5937 ++ if (af == AF_INET)
5938 ++ return true;
5939 ++#ifdef CONFIG_IP_VS_IPV6
5940 ++ if (af == AF_INET6 && ipv6_mod_enabled())
5941 ++ return true;
5942 ++#endif
5943 ++ return false;
5944 ++}
5945 ++
5946 + static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs,
5947 + struct ip_vs_service_user_kern *usvc,
5948 + struct nlattr *nla, int full_entry,
5949 +@@ -3118,11 +3129,7 @@ static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs,
5950 + memset(usvc, 0, sizeof(*usvc));
5951 +
5952 + usvc->af = nla_get_u16(nla_af);
5953 +-#ifdef CONFIG_IP_VS_IPV6
5954 +- if (usvc->af != AF_INET && usvc->af != AF_INET6)
5955 +-#else
5956 +- if (usvc->af != AF_INET)
5957 +-#endif
5958 ++ if (!ip_vs_is_af_valid(usvc->af))
5959 + return -EAFNOSUPPORT;
5960 +
5961 + if (nla_fwmark) {
5962 +@@ -3624,6 +3631,11 @@ static int ip_vs_genl_set_cmd(struct sk_buff *skb, struct genl_info *info)
5963 + if (udest.af == 0)
5964 + udest.af = svc->af;
5965 +
5966 ++ if (!ip_vs_is_af_valid(udest.af)) {
5967 ++ ret = -EAFNOSUPPORT;
5968 ++ goto out;
5969 ++ }
5970 ++
5971 + if (udest.af != svc->af && cmd != IPVS_CMD_DEL_DEST) {
5972 + /* The synchronization protocol is incompatible
5973 + * with mixed family services
5974 +diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
5975 +index 6dc44d9b4190..92e69af41656 100644
5976 +--- a/net/netfilter/nf_conntrack_helper.c
5977 ++++ b/net/netfilter/nf_conntrack_helper.c
5978 +@@ -379,17 +379,33 @@ int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
5979 + struct nf_conntrack_tuple_mask mask = { .src.u.all = htons(0xFFFF) };
5980 + unsigned int h = helper_hash(&me->tuple);
5981 + struct nf_conntrack_helper *cur;
5982 +- int ret = 0;
5983 ++ int ret = 0, i;
5984 +
5985 + BUG_ON(me->expect_policy == NULL);
5986 + BUG_ON(me->expect_class_max >= NF_CT_MAX_EXPECT_CLASSES);
5987 + BUG_ON(strlen(me->name) > NF_CT_HELPER_NAME_LEN - 1);
5988 +
5989 + mutex_lock(&nf_ct_helper_mutex);
5990 +- hlist_for_each_entry(cur, &nf_ct_helper_hash[h], hnode) {
5991 +- if (nf_ct_tuple_src_mask_cmp(&cur->tuple, &me->tuple, &mask)) {
5992 +- ret = -EEXIST;
5993 +- goto out;
5994 ++ for (i = 0; i < nf_ct_helper_hsize; i++) {
5995 ++ hlist_for_each_entry(cur, &nf_ct_helper_hash[i], hnode) {
5996 ++ if (!strcmp(cur->name, me->name) &&
5997 ++ (cur->tuple.src.l3num == NFPROTO_UNSPEC ||
5998 ++ cur->tuple.src.l3num == me->tuple.src.l3num) &&
5999 ++ cur->tuple.dst.protonum == me->tuple.dst.protonum) {
6000 ++ ret = -EEXIST;
6001 ++ goto out;
6002 ++ }
6003 ++ }
6004 ++ }
6005 ++
6006 ++ /* avoid unpredictable behaviour for auto_assign_helper */
6007 ++ if (!(me->flags & NF_CT_HELPER_F_USERSPACE)) {
6008 ++ hlist_for_each_entry(cur, &nf_ct_helper_hash[h], hnode) {
6009 ++ if (nf_ct_tuple_src_mask_cmp(&cur->tuple, &me->tuple,
6010 ++ &mask)) {
6011 ++ ret = -EEXIST;
6012 ++ goto out;
6013 ++ }
6014 + }
6015 + }
6016 + hlist_add_head_rcu(&me->hnode, &nf_ct_helper_hash[h]);
6017 +diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
6018 +index 31ca94793aa9..b9dd4e960426 100644
6019 +--- a/net/netfilter/nft_dynset.c
6020 ++++ b/net/netfilter/nft_dynset.c
6021 +@@ -82,8 +82,7 @@ static void nft_dynset_eval(const struct nft_expr *expr,
6022 + nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) {
6023 + timeout = priv->timeout ? : set->timeout;
6024 + *nft_set_ext_expiration(ext) = jiffies + timeout;
6025 +- } else if (sexpr == NULL)
6026 +- goto out;
6027 ++ }
6028 +
6029 + if (sexpr != NULL)
6030 + sexpr->ops->eval(sexpr, regs, pkt);
6031 +@@ -92,7 +91,7 @@ static void nft_dynset_eval(const struct nft_expr *expr,
6032 + regs->verdict.code = NFT_BREAK;
6033 + return;
6034 + }
6035 +-out:
6036 ++
6037 + if (!priv->invert)
6038 + regs->verdict.code = NFT_BREAK;
6039 + }
6040 +diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
6041 +index ac26b71d900e..7ad1a863587a 100644
6042 +--- a/net/netfilter/x_tables.c
6043 ++++ b/net/netfilter/x_tables.c
6044 +@@ -1006,8 +1006,10 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
6045 + list_for_each_entry(t, &init_net.xt.tables[af], list) {
6046 + if (strcmp(t->name, name))
6047 + continue;
6048 +- if (!try_module_get(t->me))
6049 ++ if (!try_module_get(t->me)) {
6050 ++ mutex_unlock(&xt[af].mutex);
6051 + return NULL;
6052 ++ }
6053 +
6054 + mutex_unlock(&xt[af].mutex);
6055 + if (t->table_init(net) != 0) {
6056 +diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
6057 +index 6669e68d589e..00ef8243d48d 100644
6058 +--- a/net/netfilter/xt_CT.c
6059 ++++ b/net/netfilter/xt_CT.c
6060 +@@ -168,8 +168,10 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par,
6061 + goto err_put_timeout;
6062 + }
6063 + timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC);
6064 +- if (timeout_ext == NULL)
6065 ++ if (!timeout_ext) {
6066 + ret = -ENOMEM;
6067 ++ goto err_put_timeout;
6068 ++ }
6069 +
6070 + rcu_read_unlock();
6071 + return ret;
6072 +@@ -201,6 +203,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
6073 + struct xt_ct_target_info_v1 *info)
6074 + {
6075 + struct nf_conntrack_zone zone;
6076 ++ struct nf_conn_help *help;
6077 + struct nf_conn *ct;
6078 + int ret = -EOPNOTSUPP;
6079 +
6080 +@@ -249,7 +252,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
6081 + if (info->timeout[0]) {
6082 + ret = xt_ct_set_timeout(ct, par, info->timeout);
6083 + if (ret < 0)
6084 +- goto err3;
6085 ++ goto err4;
6086 + }
6087 + __set_bit(IPS_CONFIRMED_BIT, &ct->status);
6088 + nf_conntrack_get(&ct->ct_general);
6089 +@@ -257,6 +260,10 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
6090 + info->ct = ct;
6091 + return 0;
6092 +
6093 ++err4:
6094 ++ help = nfct_help(ct);
6095 ++ if (help)
6096 ++ module_put(help->helper->me);
6097 + err3:
6098 + nf_ct_tmpl_free(ct);
6099 + err2:
6100 +diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
6101 +index b28e45b691de..466393936db9 100644
6102 +--- a/net/openvswitch/conntrack.c
6103 ++++ b/net/openvswitch/conntrack.c
6104 +@@ -396,10 +396,38 @@ ovs_ct_expect_find(struct net *net, const struct nf_conntrack_zone *zone,
6105 + u16 proto, const struct sk_buff *skb)
6106 + {
6107 + struct nf_conntrack_tuple tuple;
6108 ++ struct nf_conntrack_expect *exp;
6109 +
6110 + if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), proto, net, &tuple))
6111 + return NULL;
6112 +- return __nf_ct_expect_find(net, zone, &tuple);
6113 ++
6114 ++ exp = __nf_ct_expect_find(net, zone, &tuple);
6115 ++ if (exp) {
6116 ++ struct nf_conntrack_tuple_hash *h;
6117 ++
6118 ++ /* Delete existing conntrack entry, if it clashes with the
6119 ++ * expectation. This can happen since conntrack ALGs do not
6120 ++ * check for clashes between (new) expectations and existing
6121 ++ * conntrack entries. nf_conntrack_in() will check the
6122 ++ * expectations only if a conntrack entry can not be found,
6123 ++ * which can lead to OVS finding the expectation (here) in the
6124 ++ * init direction, but which will not be removed by the
6125 ++ * nf_conntrack_in() call, if a matching conntrack entry is
6126 ++ * found instead. In this case all init direction packets
6127 ++ * would be reported as new related packets, while reply
6128 ++ * direction packets would be reported as un-related
6129 ++ * established packets.
6130 ++ */
6131 ++ h = nf_conntrack_find_get(net, zone, &tuple);
6132 ++ if (h) {
6133 ++ struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
6134 ++
6135 ++ nf_ct_delete(ct, 0, 0);
6136 ++ nf_conntrack_put(&ct->ct_general);
6137 ++ }
6138 ++ }
6139 ++
6140 ++ return exp;
6141 + }
6142 +
6143 + /* This replicates logic from nf_conntrack_core.c that is not exported. */
6144 +diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
6145 +index 69502fa68a3c..1a2b1f61ed26 100644
6146 +--- a/net/sunrpc/xprtrdma/verbs.c
6147 ++++ b/net/sunrpc/xprtrdma/verbs.c
6148 +@@ -1054,6 +1054,7 @@ void
6149 + rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
6150 + {
6151 + cancel_delayed_work_sync(&buf->rb_recovery_worker);
6152 ++ cancel_delayed_work_sync(&buf->rb_refresh_worker);
6153 +
6154 + while (!list_empty(&buf->rb_recv_bufs)) {
6155 + struct rpcrdma_rep *rep;
6156 +diff --git a/net/tipc/node.c b/net/tipc/node.c
6157 +index 5b3e1ea37b6d..db8fbc076e1a 100644
6158 +--- a/net/tipc/node.c
6159 ++++ b/net/tipc/node.c
6160 +@@ -2094,6 +2094,8 @@ int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info)
6161 + int err;
6162 +
6163 + msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
6164 ++ if (!msg.skb)
6165 ++ return -ENOMEM;
6166 + msg.portid = info->snd_portid;
6167 + msg.seq = info->snd_seq;
6168 +
6169 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
6170 +index cd427ea8861d..dae0021f39c3 100644
6171 +--- a/sound/pci/hda/patch_realtek.c
6172 ++++ b/sound/pci/hda/patch_realtek.c
6173 +@@ -6780,6 +6780,7 @@ enum {
6174 + ALC668_FIXUP_DELL_DISABLE_AAMIX,
6175 + ALC668_FIXUP_DELL_XPS13,
6176 + ALC662_FIXUP_ASUS_Nx50,
6177 ++ ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
6178 + ALC668_FIXUP_ASUS_Nx51,
6179 + ALC891_FIXUP_HEADSET_MODE,
6180 + ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
6181 +@@ -7031,14 +7032,21 @@ static const struct hda_fixup alc662_fixups[] = {
6182 + .chained = true,
6183 + .chain_id = ALC662_FIXUP_BASS_1A
6184 + },
6185 ++ [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
6186 ++ .type = HDA_FIXUP_FUNC,
6187 ++ .v.func = alc_fixup_headset_mode_alc668,
6188 ++ .chain_id = ALC662_FIXUP_BASS_CHMAP
6189 ++ },
6190 + [ALC668_FIXUP_ASUS_Nx51] = {
6191 + .type = HDA_FIXUP_PINS,
6192 + .v.pins = (const struct hda_pintbl[]) {
6193 +- {0x1a, 0x90170151}, /* bass speaker */
6194 ++ { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
6195 ++ { 0x1a, 0x90170151 }, /* bass speaker */
6196 ++ { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
6197 + {}
6198 + },
6199 + .chained = true,
6200 +- .chain_id = ALC662_FIXUP_BASS_CHMAP,
6201 ++ .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
6202 + },
6203 + [ALC891_FIXUP_HEADSET_MODE] = {
6204 + .type = HDA_FIXUP_FUNC,
6205 +diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c
6206 +index 0bfa68862460..cd16b431d1bd 100644
6207 +--- a/sound/soc/intel/atom/sst/sst_acpi.c
6208 ++++ b/sound/soc/intel/atom/sst/sst_acpi.c
6209 +@@ -420,7 +420,21 @@ static const struct dmi_system_id byt_table[] = {
6210 + .callback = byt_thinkpad10_quirk_cb,
6211 + .matches = {
6212 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
6213 +- DMI_MATCH(DMI_PRODUCT_NAME, "20C3001VHH"),
6214 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 10"),
6215 ++ },
6216 ++ },
6217 ++ {
6218 ++ .callback = byt_thinkpad10_quirk_cb,
6219 ++ .matches = {
6220 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
6221 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Tablet B"),
6222 ++ },
6223 ++ },
6224 ++ {
6225 ++ .callback = byt_thinkpad10_quirk_cb,
6226 ++ .matches = {
6227 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
6228 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
6229 + },
6230 + },
6231 + { }
6232 +diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
6233 +index 06fa5e85dd0e..3e526fbd267e 100644
6234 +--- a/sound/soc/intel/skylake/skl.c
6235 ++++ b/sound/soc/intel/skylake/skl.c
6236 +@@ -457,7 +457,7 @@ static int probe_codec(struct hdac_ext_bus *ebus, int addr)
6237 + struct hdac_bus *bus = ebus_to_hbus(ebus);
6238 + unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
6239 + (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
6240 +- unsigned int res;
6241 ++ unsigned int res = -1;
6242 +
6243 + mutex_lock(&bus->cmd_mutex);
6244 + snd_hdac_bus_send_cmd(bus, cmd);
6245 +diff --git a/sound/soc/sh/rcar/cmd.c b/sound/soc/sh/rcar/cmd.c
6246 +index 7d92a24b7cfa..98835e9d1d7d 100644
6247 +--- a/sound/soc/sh/rcar/cmd.c
6248 ++++ b/sound/soc/sh/rcar/cmd.c
6249 +@@ -82,6 +82,9 @@ static int rsnd_cmd_init(struct rsnd_mod *mod,
6250 + [9] = 0x2,
6251 + };
6252 +
6253 ++ if (unlikely(!src))
6254 ++ return -EIO;
6255 ++
6256 + data = path[rsnd_mod_id(src)] |
6257 + cmd_case[rsnd_mod_id(src)] << 16;
6258 + }
6259 +diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
6260 +index 76f41f249944..6cd9e5107f77 100644
6261 +--- a/tools/perf/tests/kmod-path.c
6262 ++++ b/tools/perf/tests/kmod-path.c
6263 +@@ -61,6 +61,7 @@ int test__kmod_path__parse(int subtest __maybe_unused)
6264 + M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
6265 + M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
6266 +
6267 ++#ifdef HAVE_ZLIB_SUPPORT
6268 + /* path alloc_name alloc_ext kmod comp name ext */
6269 + T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz");
6270 + T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz");
6271 +@@ -96,6 +97,7 @@ int test__kmod_path__parse(int subtest __maybe_unused)
6272 + M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
6273 + M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
6274 + M("x.ko.gz", PERF_RECORD_MISC_USER, false);
6275 ++#endif
6276 +
6277 + /* path alloc_name alloc_ext kmod comp name ext */
6278 + T("[test_module]", true , true , true, false, "[test_module]", NULL);
6279 +diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
6280 +index 71620fa95953..d025eafc09c2 100644
6281 +--- a/tools/testing/nvdimm/test/nfit.c
6282 ++++ b/tools/testing/nvdimm/test/nfit.c
6283 +@@ -1908,6 +1908,7 @@ static __init int nfit_test_init(void)
6284 + put_device(&pdev->dev);
6285 + goto err_register;
6286 + }
6287 ++ get_device(&pdev->dev);
6288 +
6289 + rc = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
6290 + if (rc)
6291 +@@ -1926,6 +1927,10 @@ static __init int nfit_test_init(void)
6292 + if (instances[i])
6293 + platform_device_unregister(&instances[i]->pdev);
6294 + nfit_test_teardown();
6295 ++ for (i = 0; i < NUM_NFITS; i++)
6296 ++ if (instances[i])
6297 ++ put_device(&instances[i]->pdev.dev);
6298 ++
6299 + return rc;
6300 + }
6301 +
6302 +@@ -1933,10 +1938,13 @@ static __exit void nfit_test_exit(void)
6303 + {
6304 + int i;
6305 +
6306 +- platform_driver_unregister(&nfit_test_driver);
6307 + for (i = 0; i < NUM_NFITS; i++)
6308 + platform_device_unregister(&instances[i]->pdev);
6309 ++ platform_driver_unregister(&nfit_test_driver);
6310 + nfit_test_teardown();
6311 ++
6312 ++ for (i = 0; i < NUM_NFITS; i++)
6313 ++ put_device(&instances[i]->pdev.dev);
6314 + class_destroy(nfit_test_dimm);
6315 + }
6316 +