Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Wed, 22 Sep 2021 11:41:49
Message-Id: 1632310890.5dd1a2433fa52a82d6e09d6b4c24f1b6c1bdc1d2.mpagano@gentoo
1 commit: 5dd1a2433fa52a82d6e09d6b4c24f1b6c1bdc1d2
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 22 11:41:30 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 22 11:41:30 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5dd1a243
7
8 Linux patch 4.14.247
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1246_linux-4.14.247.patch | 5786 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 5790 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 3b5939c..606bd7e 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -1031,6 +1031,10 @@ Patch: 1245_linux-4.14.246.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.246
23
24 +Patch: 1246_linux-4.14.247.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.247
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1246_linux-4.14.247.patch b/1246_linux-4.14.247.patch
33 new file mode 100644
34 index 0000000..a578bf0
35 --- /dev/null
36 +++ b/1246_linux-4.14.247.patch
37 @@ -0,0 +1,5786 @@
38 +diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt
39 +index 4ec843123cc3b..361bff6d3053e 100644
40 +--- a/Documentation/admin-guide/devices.txt
41 ++++ b/Documentation/admin-guide/devices.txt
42 +@@ -2989,10 +2989,10 @@
43 + 65 = /dev/infiniband/issm1 Second InfiniBand IsSM device
44 + ...
45 + 127 = /dev/infiniband/issm63 63rd InfiniBand IsSM device
46 +- 128 = /dev/infiniband/uverbs0 First InfiniBand verbs device
47 +- 129 = /dev/infiniband/uverbs1 Second InfiniBand verbs device
48 ++ 192 = /dev/infiniband/uverbs0 First InfiniBand verbs device
49 ++ 193 = /dev/infiniband/uverbs1 Second InfiniBand verbs device
50 + ...
51 +- 159 = /dev/infiniband/uverbs31 31st InfiniBand verbs device
52 ++ 223 = /dev/infiniband/uverbs31 31st InfiniBand verbs device
53 +
54 + 232 char Biometric Devices
55 + 0 = /dev/biometric/sensor0/fingerprint first fingerprint sensor on first device
56 +diff --git a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
57 +index dd559045593d7..d2d1bae63a362 100644
58 +--- a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
59 ++++ b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
60 +@@ -123,7 +123,7 @@ on various other factors also like;
61 + so the device should have enough free bytes available its OOB/Spare
62 + area to accommodate ECC for entire page. In general following expression
63 + helps in determining if given device can accommodate ECC syndrome:
64 +- "2 + (PAGESIZE / 512) * ECC_BYTES" >= OOBSIZE"
65 ++ "2 + (PAGESIZE / 512) * ECC_BYTES" <= OOBSIZE"
66 + where
67 + OOBSIZE number of bytes in OOB/spare area
68 + PAGESIZE number of bytes in main-area of device page
69 +diff --git a/Makefile b/Makefile
70 +index 11f0d1f637c40..b05401adeaf57 100644
71 +--- a/Makefile
72 ++++ b/Makefile
73 +@@ -1,7 +1,7 @@
74 + # SPDX-License-Identifier: GPL-2.0
75 + VERSION = 4
76 + PATCHLEVEL = 14
77 +-SUBLEVEL = 246
78 ++SUBLEVEL = 247
79 + EXTRAVERSION =
80 + NAME = Petit Gorille
81 +
82 +diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
83 +index d14499500106d..bf02efbee5e1a 100644
84 +--- a/arch/arc/mm/cache.c
85 ++++ b/arch/arc/mm/cache.c
86 +@@ -1118,7 +1118,7 @@ void clear_user_page(void *to, unsigned long u_vaddr, struct page *page)
87 + clear_page(to);
88 + clear_bit(PG_dc_clean, &page->flags);
89 + }
90 +-
91 ++EXPORT_SYMBOL(clear_user_page);
92 +
93 + /**********************************************************************
94 + * Explicit Cache flush request from user space via syscall
95 +diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
96 +index 746c8c575f987..a61b7e4d06668 100644
97 +--- a/arch/arm/boot/compressed/Makefile
98 ++++ b/arch/arm/boot/compressed/Makefile
99 +@@ -87,6 +87,8 @@ $(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
100 + $(addprefix $(obj)/,$(libfdt_hdrs))
101 +
102 + ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
103 ++CFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN}
104 ++CFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280
105 + OBJS += $(libfdt_objs) atags_to_fdt.o
106 + endif
107 +
108 +diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
109 +index 6089c8d56cd54..eef243998392d 100644
110 +--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
111 ++++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
112 +@@ -1228,9 +1228,9 @@
113 + <&mmcc DSI1_BYTE_CLK>,
114 + <&mmcc DSI_PIXEL_CLK>,
115 + <&mmcc DSI1_ESC_CLK>;
116 +- clock-names = "iface_clk", "bus_clk", "core_mmss_clk",
117 +- "src_clk", "byte_clk", "pixel_clk",
118 +- "core_clk";
119 ++ clock-names = "iface", "bus", "core_mmss",
120 ++ "src", "byte", "pixel",
121 ++ "core";
122 +
123 + assigned-clocks = <&mmcc DSI1_BYTE_SRC>,
124 + <&mmcc DSI1_ESC_SRC>,
125 +diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi
126 +index 872046d48709a..4d69d67792d17 100644
127 +--- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
128 ++++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
129 +@@ -185,8 +185,9 @@
130 + nvidia,pins = "ata", "atb", "atc", "atd", "ate",
131 + "cdev1", "cdev2", "dap1", "dtb", "gma",
132 + "gmb", "gmc", "gmd", "gme", "gpu7",
133 +- "gpv", "i2cp", "pta", "rm", "slxa",
134 +- "slxk", "spia", "spib", "uac";
135 ++ "gpv", "i2cp", "irrx", "irtx", "pta",
136 ++ "rm", "slxa", "slxk", "spia", "spib",
137 ++ "uac";
138 + nvidia,pull = <TEGRA_PIN_PULL_NONE>;
139 + nvidia,tristate = <TEGRA_PIN_DISABLE>;
140 + };
141 +@@ -211,7 +212,7 @@
142 + conf_ddc {
143 + nvidia,pins = "ddc", "dta", "dtd", "kbca",
144 + "kbcb", "kbcc", "kbcd", "kbce", "kbcf",
145 +- "sdc";
146 ++ "sdc", "uad", "uca";
147 + nvidia,pull = <TEGRA_PIN_PULL_UP>;
148 + nvidia,tristate = <TEGRA_PIN_DISABLE>;
149 + };
150 +@@ -221,10 +222,9 @@
151 + "lvp0", "owc", "sdb";
152 + nvidia,tristate = <TEGRA_PIN_ENABLE>;
153 + };
154 +- conf_irrx {
155 +- nvidia,pins = "irrx", "irtx", "sdd", "spic",
156 +- "spie", "spih", "uaa", "uab", "uad",
157 +- "uca", "ucb";
158 ++ conf_sdd {
159 ++ nvidia,pins = "sdd", "spic", "spie", "spih",
160 ++ "uaa", "uab", "ucb";
161 + nvidia,pull = <TEGRA_PIN_PULL_UP>;
162 + nvidia,tristate = <TEGRA_PIN_ENABLE>;
163 + };
164 +diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
165 +index 50de918252b71..3939ad1784051 100644
166 +--- a/arch/arm/kernel/Makefile
167 ++++ b/arch/arm/kernel/Makefile
168 +@@ -17,10 +17,14 @@ CFLAGS_REMOVE_return_address.o = -pg
169 + # Object file lists.
170 +
171 + obj-y := elf.o entry-common.o irq.o opcodes.o \
172 +- process.o ptrace.o reboot.o return_address.o \
173 ++ process.o ptrace.o reboot.o \
174 + setup.o signal.o sigreturn_codes.o \
175 + stacktrace.o sys_arm.o time.o traps.o
176 +
177 ++ifneq ($(CONFIG_ARM_UNWIND),y)
178 ++obj-$(CONFIG_FRAME_POINTER) += return_address.o
179 ++endif
180 ++
181 + obj-$(CONFIG_ATAGS) += atags_parse.o
182 + obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
183 + obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o
184 +diff --git a/arch/arm/kernel/return_address.c b/arch/arm/kernel/return_address.c
185 +index 36ed35073289b..f945742dea449 100644
186 +--- a/arch/arm/kernel/return_address.c
187 ++++ b/arch/arm/kernel/return_address.c
188 +@@ -10,8 +10,6 @@
189 + */
190 + #include <linux/export.h>
191 + #include <linux/ftrace.h>
192 +-
193 +-#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
194 + #include <linux/sched.h>
195 +
196 + #include <asm/stacktrace.h>
197 +@@ -56,6 +54,4 @@ void *return_address(unsigned int level)
198 + return NULL;
199 + }
200 +
201 +-#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
202 +-
203 + EXPORT_SYMBOL_GPL(return_address);
204 +diff --git a/arch/arm64/boot/dts/exynos/exynos7.dtsi b/arch/arm64/boot/dts/exynos/exynos7.dtsi
205 +index 875297a470dab..331dcf94acf06 100644
206 +--- a/arch/arm64/boot/dts/exynos/exynos7.dtsi
207 ++++ b/arch/arm64/boot/dts/exynos/exynos7.dtsi
208 +@@ -94,7 +94,7 @@
209 + #address-cells = <0>;
210 + interrupt-controller;
211 + reg = <0x11001000 0x1000>,
212 +- <0x11002000 0x1000>,
213 ++ <0x11002000 0x2000>,
214 + <0x11004000 0x2000>,
215 + <0x11006000 0x2000>;
216 + };
217 +diff --git a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
218 +index 6a838b5d321e3..1ab7deeb24974 100644
219 +--- a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
220 ++++ b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
221 +@@ -27,7 +27,7 @@
222 + stdout-path = "serial0";
223 + };
224 +
225 +- memory {
226 ++ memory@40000000 {
227 + device_type = "memory";
228 + reg = <0x0 0x40000000 0x0 0x20000000>;
229 + };
230 +diff --git a/arch/m68k/emu/nfeth.c b/arch/m68k/emu/nfeth.c
231 +index e45ce4243aaa3..76262dc40e791 100644
232 +--- a/arch/m68k/emu/nfeth.c
233 ++++ b/arch/m68k/emu/nfeth.c
234 +@@ -258,8 +258,8 @@ static void __exit nfeth_cleanup(void)
235 +
236 + for (i = 0; i < MAX_UNIT; i++) {
237 + if (nfeth_dev[i]) {
238 +- unregister_netdev(nfeth_dev[0]);
239 +- free_netdev(nfeth_dev[0]);
240 ++ unregister_netdev(nfeth_dev[i]);
241 ++ free_netdev(nfeth_dev[i]);
242 + }
243 + }
244 + free_irq(nfEtherIRQ, nfeth_interrupt);
245 +diff --git a/arch/mips/mti-malta/malta-dtshim.c b/arch/mips/mti-malta/malta-dtshim.c
246 +index 7859b6e498634..5b5d78a7882a4 100644
247 +--- a/arch/mips/mti-malta/malta-dtshim.c
248 ++++ b/arch/mips/mti-malta/malta-dtshim.c
249 +@@ -26,7 +26,7 @@
250 + #define ROCIT_CONFIG_GEN1_MEMMAP_SHIFT 8
251 + #define ROCIT_CONFIG_GEN1_MEMMAP_MASK (0xf << 8)
252 +
253 +-static unsigned char fdt_buf[16 << 10] __initdata;
254 ++static unsigned char fdt_buf[16 << 10] __initdata __aligned(8);
255 +
256 + /* determined physical memory size, not overridden by command line args */
257 + extern unsigned long physical_memsize;
258 +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
259 +index 0fdfa7142f4b3..272eda8d63680 100644
260 +--- a/arch/openrisc/kernel/entry.S
261 ++++ b/arch/openrisc/kernel/entry.S
262 +@@ -495,6 +495,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
263 + l.bnf 1f // ext irq enabled, all ok.
264 + l.nop
265 +
266 ++#ifdef CONFIG_PRINTK
267 + l.addi r1,r1,-0x8
268 + l.movhi r3,hi(42f)
269 + l.ori r3,r3,lo(42f)
270 +@@ -508,6 +509,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
271 + .string "\n\rESR interrupt bug: in _external_irq_handler (ESR %x)\n\r"
272 + .align 4
273 + .previous
274 ++#endif
275 +
276 + l.ori r4,r4,SPR_SR_IEE // fix the bug
277 + // l.sw PT_SR(r1),r4
278 +diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
279 +index f2a4038e275b1..99b1479792f0a 100644
280 +--- a/arch/parisc/kernel/signal.c
281 ++++ b/arch/parisc/kernel/signal.c
282 +@@ -242,6 +242,12 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
283 + #endif
284 +
285 + usp = (regs->gr[30] & ~(0x01UL));
286 ++#ifdef CONFIG_64BIT
287 ++ if (is_compat_task()) {
288 ++ /* The gcc alloca implementation leaves garbage in the upper 32 bits of sp */
289 ++ usp = (compat_uint_t)usp;
290 ++ }
291 ++#endif
292 + /*FIXME: frame_size parameter is unused, remove it. */
293 + frame = get_sigframe(&ksig->ka, usp, sizeof(*frame));
294 +
295 +diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
296 +index 9b9d17437373b..0247b8e6cb1b7 100644
297 +--- a/arch/powerpc/boot/crt0.S
298 ++++ b/arch/powerpc/boot/crt0.S
299 +@@ -49,9 +49,6 @@ p_end: .long _end
300 + p_pstack: .long _platform_stack_top
301 + #endif
302 +
303 +- .globl _zimage_start
304 +- /* Clang appears to require the .weak directive to be after the symbol
305 +- * is defined. See https://bugs.llvm.org/show_bug.cgi?id=38921 */
306 + .weak _zimage_start
307 + _zimage_start:
308 + .globl _zimage_start_lib
309 +diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
310 +index 4d8f6291b7661..bbf033bda55d2 100644
311 +--- a/arch/powerpc/kernel/module_64.c
312 ++++ b/arch/powerpc/kernel/module_64.c
313 +@@ -695,7 +695,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
314 + /*
315 + * If found, replace it with:
316 + * addis r2, r12, (.TOC.-func)@ha
317 +- * addi r2, r12, (.TOC.-func)@l
318 ++ * addi r2, r2, (.TOC.-func)@l
319 + */
320 + ((uint32_t *)location)[0] = 0x3c4c0000 + PPC_HA(value);
321 + ((uint32_t *)location)[1] = 0x38420000 + PPC_LO(value);
322 +diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
323 +index 43fabb3cae0fa..160b86d9d8199 100644
324 +--- a/arch/powerpc/perf/hv-gpci.c
325 ++++ b/arch/powerpc/perf/hv-gpci.c
326 +@@ -168,7 +168,7 @@ static unsigned long single_gpci_request(u32 req, u32 starting_index,
327 + */
328 + count = 0;
329 + for (i = offset; i < offset + length; i++)
330 +- count |= arg->bytes[i] << (i - offset);
331 ++ count |= (u64)(arg->bytes[i]) << ((length - 1 - (i - offset)) * 8);
332 +
333 + *value = count;
334 + out:
335 +diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
336 +index dec2ece4af28d..b6168c6abd3a5 100644
337 +--- a/arch/s390/kernel/dis.c
338 ++++ b/arch/s390/kernel/dis.c
339 +@@ -2018,7 +2018,7 @@ void show_code(struct pt_regs *regs)
340 + start += opsize;
341 + pr_cont("%s", buffer);
342 + ptr = buffer;
343 +- ptr += sprintf(ptr, "\n\t ");
344 ++ ptr += sprintf(ptr, "\n ");
345 + hops++;
346 + }
347 + pr_cont("\n");
348 +diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
349 +index 43f8430fb67d5..608b363cd35b7 100644
350 +--- a/arch/s390/kernel/jump_label.c
351 ++++ b/arch/s390/kernel/jump_label.c
352 +@@ -43,7 +43,7 @@ static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
353 + unsigned char *ipe = (unsigned char *)expected;
354 + unsigned char *ipn = (unsigned char *)new;
355 +
356 +- pr_emerg("Jump label code mismatch at %pS [%p]\n", ipc, ipc);
357 ++ pr_emerg("Jump label code mismatch at %pS [%px]\n", ipc, ipc);
358 + pr_emerg("Found: %6ph\n", ipc);
359 + pr_emerg("Expected: %6ph\n", ipe);
360 + pr_emerg("New: %6ph\n", ipn);
361 +diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
362 +index bb3710e7ad9c2..1241e365af5d2 100644
363 +--- a/arch/s390/net/bpf_jit_comp.c
364 ++++ b/arch/s390/net/bpf_jit_comp.c
365 +@@ -626,8 +626,13 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i
366 + case BPF_ALU64 | BPF_SUB | BPF_K: /* dst = dst - imm */
367 + if (!imm)
368 + break;
369 +- /* agfi %dst,-imm */
370 +- EMIT6_IMM(0xc2080000, dst_reg, -imm);
371 ++ if (imm == -0x80000000) {
372 ++ /* algfi %dst,0x80000000 */
373 ++ EMIT6_IMM(0xc20a0000, dst_reg, 0x80000000);
374 ++ } else {
375 ++ /* agfi %dst,-imm */
376 ++ EMIT6_IMM(0xc2080000, dst_reg, -imm);
377 ++ }
378 + break;
379 + /*
380 + * BPF_MUL
381 +diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
382 +index 3fe68f7f9d5e1..5043425ced6b6 100644
383 +--- a/arch/x86/events/amd/ibs.c
384 ++++ b/arch/x86/events/amd/ibs.c
385 +@@ -90,6 +90,7 @@ struct perf_ibs {
386 + unsigned long offset_mask[1];
387 + int offset_max;
388 + unsigned int fetch_count_reset_broken : 1;
389 ++ unsigned int fetch_ignore_if_zero_rip : 1;
390 + struct cpu_perf_ibs __percpu *pcpu;
391 +
392 + struct attribute **format_attrs;
393 +@@ -674,6 +675,10 @@ fail:
394 + if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
395 + regs.flags &= ~PERF_EFLAGS_EXACT;
396 + } else {
397 ++ /* Workaround for erratum #1197 */
398 ++ if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
399 ++ goto out;
400 ++
401 + set_linear_ip(&regs, ibs_data.regs[1]);
402 + regs.flags |= PERF_EFLAGS_EXACT;
403 + }
404 +@@ -767,6 +772,9 @@ static __init void perf_event_ibs_init(void)
405 + if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
406 + perf_ibs_fetch.fetch_count_reset_broken = 1;
407 +
408 ++ if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10)
409 ++ perf_ibs_fetch.fetch_ignore_if_zero_rip = 1;
410 ++
411 + perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
412 +
413 + if (ibs_caps & IBS_CAPS_OPCNT) {
414 +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
415 +index 0661227d935c4..990ca9614b231 100644
416 +--- a/arch/x86/events/intel/pt.c
417 ++++ b/arch/x86/events/intel/pt.c
418 +@@ -69,7 +69,7 @@ static struct pt_cap_desc {
419 + PT_CAP(topa_multiple_entries, 0, CPUID_ECX, BIT(1)),
420 + PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),
421 + PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),
422 +- PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x3),
423 ++ PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x7),
424 + PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),
425 + PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),
426 + PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),
427 +diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c
428 +index 2d324cd1dea70..1c4be5dcd4746 100644
429 +--- a/arch/x86/kernel/cpu/intel_rdt_monitor.c
430 ++++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c
431 +@@ -244,6 +244,12 @@ static u64 __mon_event_count(u32 rmid, struct rmid_read *rr)
432 + case QOS_L3_MBM_LOCAL_EVENT_ID:
433 + m = &rr->d->mbm_local[rmid];
434 + break;
435 ++ default:
436 ++ /*
437 ++ * Code would never reach here because an invalid
438 ++ * event id would fail the __rmid_read.
439 ++ */
440 ++ return RMID_VAL_ERROR;
441 + }
442 +
443 + if (rr->first) {
444 +diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
445 +index 729e288718ccb..aa08b7614ab06 100644
446 +--- a/arch/x86/kernel/reboot.c
447 ++++ b/arch/x86/kernel/reboot.c
448 +@@ -388,10 +388,11 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = {
449 + },
450 + { /* Handle problems with rebooting on the OptiPlex 990. */
451 + .callback = set_pci_reboot,
452 +- .ident = "Dell OptiPlex 990",
453 ++ .ident = "Dell OptiPlex 990 BIOS A0x",
454 + .matches = {
455 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
456 + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"),
457 ++ DMI_MATCH(DMI_BIOS_VERSION, "A0"),
458 + },
459 + },
460 + { /* Handle problems with rebooting on Dell 300's */
461 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
462 +index d77caab7ad5e4..0690155f42b2a 100644
463 +--- a/arch/x86/kvm/x86.c
464 ++++ b/arch/x86/kvm/x86.c
465 +@@ -2355,6 +2355,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
466 + if (!msr_info->host_initiated) {
467 + s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr;
468 + adjust_tsc_offset_guest(vcpu, adj);
469 ++ /* Before back to guest, tsc_timestamp must be adjusted
470 ++ * as well, otherwise guest's percpu pvclock time could jump.
471 ++ */
472 ++ kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
473 + }
474 + vcpu->arch.ia32_tsc_adjust_msr = data;
475 + }
476 +diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
477 +index 624edfbff02de..8c02da40931a1 100644
478 +--- a/arch/x86/mm/init_64.c
479 ++++ b/arch/x86/mm/init_64.c
480 +@@ -1282,18 +1282,18 @@ int kern_addr_valid(unsigned long addr)
481 + return 0;
482 +
483 + p4d = p4d_offset(pgd, addr);
484 +- if (p4d_none(*p4d))
485 ++ if (!p4d_present(*p4d))
486 + return 0;
487 +
488 + pud = pud_offset(p4d, addr);
489 +- if (pud_none(*pud))
490 ++ if (!pud_present(*pud))
491 + return 0;
492 +
493 + if (pud_large(*pud))
494 + return pfn_valid(pud_pfn(*pud));
495 +
496 + pmd = pmd_offset(pud, addr);
497 +- if (pmd_none(*pmd))
498 ++ if (!pmd_present(*pmd))
499 + return 0;
500 +
501 + if (pmd_large(*pmd))
502 +diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
503 +index 7d90a46455117..3e6a08068b25b 100644
504 +--- a/arch/x86/xen/enlighten_pv.c
505 ++++ b/arch/x86/xen/enlighten_pv.c
506 +@@ -1214,6 +1214,11 @@ static void __init xen_dom0_set_legacy_features(void)
507 + x86_platform.legacy.rtc = 1;
508 + }
509 +
510 ++static void __init xen_domu_set_legacy_features(void)
511 ++{
512 ++ x86_platform.legacy.rtc = 0;
513 ++}
514 ++
515 + /* First C function to be called on Xen boot */
516 + asmlinkage __visible void __init xen_start_kernel(void)
517 + {
518 +@@ -1375,6 +1380,8 @@ asmlinkage __visible void __init xen_start_kernel(void)
519 + add_preferred_console("hvc", 0, NULL);
520 + if (pci_xen)
521 + x86_init.pci.arch_init = pci_xen_init;
522 ++ x86_platform.set_legacy_features =
523 ++ xen_domu_set_legacy_features;
524 + } else {
525 + const struct dom0_vga_console_info *info =
526 + (void *)((char *)xen_start_info +
527 +diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
528 +index e031b7e7272a4..0d83f25ac8ace 100644
529 +--- a/arch/x86/xen/p2m.c
530 ++++ b/arch/x86/xen/p2m.c
531 +@@ -613,8 +613,8 @@ int xen_alloc_p2m_entry(unsigned long pfn)
532 + }
533 +
534 + /* Expanded the p2m? */
535 +- if (pfn > xen_p2m_last_pfn) {
536 +- xen_p2m_last_pfn = pfn;
537 ++ if (pfn >= xen_p2m_last_pfn) {
538 ++ xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE);
539 + HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
540 + }
541 +
542 +diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
543 +index eb1f196c3f6e5..2ad174fdc8ab4 100644
544 +--- a/arch/xtensa/Kconfig
545 ++++ b/arch/xtensa/Kconfig
546 +@@ -20,7 +20,7 @@ config XTENSA
547 + select HAVE_DMA_CONTIGUOUS
548 + select HAVE_EXIT_THREAD
549 + select HAVE_FUNCTION_TRACER
550 +- select HAVE_FUTEX_CMPXCHG if !MMU
551 ++ select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
552 + select HAVE_HW_BREAKPOINT if PERF_EVENTS
553 + select HAVE_IRQ_TIME_ACCOUNTING
554 + select HAVE_MEMBLOCK
555 +diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
556 +index 0140a22551c84..63d6d043af169 100644
557 +--- a/arch/xtensa/platforms/iss/console.c
558 ++++ b/arch/xtensa/platforms/iss/console.c
559 +@@ -182,9 +182,13 @@ static const struct tty_operations serial_ops = {
560 +
561 + int __init rs_init(void)
562 + {
563 +- tty_port_init(&serial_port);
564 ++ int ret;
565 +
566 + serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
567 ++ if (!serial_driver)
568 ++ return -ENOMEM;
569 ++
570 ++ tty_port_init(&serial_port);
571 +
572 + printk ("%s %s\n", serial_name, serial_version);
573 +
574 +@@ -204,8 +208,15 @@ int __init rs_init(void)
575 + tty_set_operations(serial_driver, &serial_ops);
576 + tty_port_link_device(&serial_port, serial_driver, 0);
577 +
578 +- if (tty_register_driver(serial_driver))
579 +- panic("Couldn't register serial driver\n");
580 ++ ret = tty_register_driver(serial_driver);
581 ++ if (ret) {
582 ++ pr_err("Couldn't register serial driver\n");
583 ++ tty_driver_kref_put(serial_driver);
584 ++ tty_port_destroy(&serial_port);
585 ++
586 ++ return ret;
587 ++ }
588 ++
589 + return 0;
590 + }
591 +
592 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
593 +index 959bee9fa9118..f8c6b898f6378 100644
594 +--- a/block/bfq-iosched.c
595 ++++ b/block/bfq-iosched.c
596 +@@ -3825,7 +3825,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
597 + if (bfqq->new_ioprio >= IOPRIO_BE_NR) {
598 + pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n",
599 + bfqq->new_ioprio);
600 +- bfqq->new_ioprio = IOPRIO_BE_NR;
601 ++ bfqq->new_ioprio = IOPRIO_BE_NR - 1;
602 + }
603 +
604 + bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio);
605 +diff --git a/block/blk-zoned.c b/block/blk-zoned.c
606 +index 77fce6f09f781..96cd65c22ec2e 100644
607 +--- a/block/blk-zoned.c
608 ++++ b/block/blk-zoned.c
609 +@@ -277,9 +277,6 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
610 + if (!blk_queue_is_zoned(q))
611 + return -ENOTTY;
612 +
613 +- if (!capable(CAP_SYS_ADMIN))
614 +- return -EACCES;
615 +-
616 + if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
617 + return -EFAULT;
618 +
619 +@@ -338,9 +335,6 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
620 + if (!blk_queue_is_zoned(q))
621 + return -ENOTTY;
622 +
623 +- if (!capable(CAP_SYS_ADMIN))
624 +- return -EACCES;
625 +-
626 + if (!(mode & FMODE_WRITE))
627 + return -EBADF;
628 +
629 +diff --git a/certs/Makefile b/certs/Makefile
630 +index 5d0999b9e21b1..ca3c71e3a3d9f 100644
631 +--- a/certs/Makefile
632 ++++ b/certs/Makefile
633 +@@ -46,11 +46,19 @@ endif
634 + redirect_openssl = 2>&1
635 + quiet_redirect_openssl = 2>&1
636 + silent_redirect_openssl = 2>/dev/null
637 ++openssl_available = $(shell openssl help 2>/dev/null && echo yes)
638 +
639 + # We do it this way rather than having a boolean option for enabling an
640 + # external private key, because 'make randconfig' might enable such a
641 + # boolean option and we unfortunately can't make it depend on !RANDCONFIG.
642 + ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
643 ++
644 ++ifeq ($(openssl_available),yes)
645 ++X509TEXT=$(shell openssl x509 -in "certs/signing_key.pem" -text 2>/dev/null)
646 ++
647 ++$(if $(findstring rsaEncryption,$(X509TEXT)),,$(shell rm -f "certs/signing_key.pem"))
648 ++endif
649 ++
650 + $(obj)/signing_key.pem: $(obj)/x509.genkey
651 + @$(kecho) "###"
652 + @$(kecho) "### Now generating an X.509 key pair to be used for signing modules."
653 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
654 +index c28b0ca249075..8310beab6b2f8 100644
655 +--- a/drivers/ata/libata-core.c
656 ++++ b/drivers/ata/libata-core.c
657 +@@ -4564,6 +4564,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
658 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
659 + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
660 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
661 ++ { "Samsung SSD 860*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
662 ++ ATA_HORKAGE_ZERO_AFTER_TRIM, },
663 ++ { "Samsung SSD 870*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
664 ++ ATA_HORKAGE_ZERO_AFTER_TRIM, },
665 + { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
666 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
667 +
668 +@@ -6339,7 +6343,7 @@ int ata_host_start(struct ata_host *host)
669 + have_stop = 1;
670 + }
671 +
672 +- if (host->ops->host_stop)
673 ++ if (host->ops && host->ops->host_stop)
674 + have_stop = 1;
675 +
676 + if (have_stop) {
677 +diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
678 +index ce128d5a6ded2..ed301dee200dc 100644
679 +--- a/drivers/ata/sata_dwc_460ex.c
680 ++++ b/drivers/ata/sata_dwc_460ex.c
681 +@@ -1253,24 +1253,20 @@ static int sata_dwc_probe(struct platform_device *ofdev)
682 + irq = irq_of_parse_and_map(np, 0);
683 + if (irq == NO_IRQ) {
684 + dev_err(&ofdev->dev, "no SATA DMA irq\n");
685 +- err = -ENODEV;
686 +- goto error_out;
687 ++ return -ENODEV;
688 + }
689 +
690 + #ifdef CONFIG_SATA_DWC_OLD_DMA
691 + if (!of_find_property(np, "dmas", NULL)) {
692 + err = sata_dwc_dma_init_old(ofdev, hsdev);
693 + if (err)
694 +- goto error_out;
695 ++ return err;
696 + }
697 + #endif
698 +
699 + hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
700 +- if (IS_ERR(hsdev->phy)) {
701 +- err = PTR_ERR(hsdev->phy);
702 +- hsdev->phy = NULL;
703 +- goto error_out;
704 +- }
705 ++ if (IS_ERR(hsdev->phy))
706 ++ return PTR_ERR(hsdev->phy);
707 +
708 + err = phy_init(hsdev->phy);
709 + if (err)
710 +diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
711 +index 1cda505d6a852..9664cce49109b 100644
712 +--- a/drivers/base/power/trace.c
713 ++++ b/drivers/base/power/trace.c
714 +@@ -11,6 +11,7 @@
715 + #include <linux/export.h>
716 + #include <linux/rtc.h>
717 + #include <linux/suspend.h>
718 ++#include <linux/init.h>
719 +
720 + #include <linux/mc146818rtc.h>
721 +
722 +@@ -165,6 +166,9 @@ void generate_pm_trace(const void *tracedata, unsigned int user)
723 + const char *file = *(const char **)(tracedata + 2);
724 + unsigned int user_hash_value, file_hash_value;
725 +
726 ++ if (!x86_platform.legacy.rtc)
727 ++ return;
728 ++
729 + user_hash_value = user % USERHASH;
730 + file_hash_value = hash_string(lineno, file, FILEHASH);
731 + set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
732 +@@ -267,6 +271,9 @@ static struct notifier_block pm_trace_nb = {
733 +
734 + static int early_resume_init(void)
735 + {
736 ++ if (!x86_platform.legacy.rtc)
737 ++ return 0;
738 ++
739 + hash_value_early_read = read_magic_time();
740 + register_pm_notifier(&pm_trace_nb);
741 + return 0;
742 +@@ -277,6 +284,9 @@ static int late_resume_init(void)
743 + unsigned int val = hash_value_early_read;
744 + unsigned int user, file, dev;
745 +
746 ++ if (!x86_platform.legacy.rtc)
747 ++ return 0;
748 ++
749 + user = val % USERHASH;
750 + val = val / USERHASH;
751 + file = val % FILEHASH;
752 +diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
753 +index 4e0cc40ad9ceb..1c5ff22d92f19 100644
754 +--- a/drivers/base/regmap/regmap.c
755 ++++ b/drivers/base/regmap/regmap.c
756 +@@ -1378,7 +1378,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
757 + if (ret) {
758 + dev_err(map->dev,
759 + "Error in caching of register: %x ret: %d\n",
760 +- reg + i, ret);
761 ++ reg + regmap_get_offset(map, i), ret);
762 + return ret;
763 + }
764 + }
765 +diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
766 +index e6986c7608f1e..b1783f5b5cb51 100644
767 +--- a/drivers/bcma/main.c
768 ++++ b/drivers/bcma/main.c
769 +@@ -236,6 +236,7 @@ EXPORT_SYMBOL(bcma_core_irq);
770 +
771 + void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
772 + {
773 ++ device_initialize(&core->dev);
774 + core->dev.release = bcma_release_core_dev;
775 + core->dev.bus = &bcma_bus_type;
776 + dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
777 +@@ -299,11 +300,10 @@ static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
778 + {
779 + int err;
780 +
781 +- err = device_register(&core->dev);
782 ++ err = device_add(&core->dev);
783 + if (err) {
784 + bcma_err(bus, "Could not register dev for core 0x%03X\n",
785 + core->id.id);
786 +- put_device(&core->dev);
787 + return;
788 + }
789 + core->dev_registered = true;
790 +@@ -394,7 +394,7 @@ void bcma_unregister_cores(struct bcma_bus *bus)
791 + /* Now noone uses internally-handled cores, we can free them */
792 + list_for_each_entry_safe(core, tmp, &bus->cores, list) {
793 + list_del(&core->list);
794 +- kfree(core);
795 ++ put_device(&core->dev);
796 + }
797 + }
798 +
799 +diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
800 +index 01091c08e9999..ef702fdb2f92a 100644
801 +--- a/drivers/block/Kconfig
802 ++++ b/drivers/block/Kconfig
803 +@@ -234,7 +234,7 @@ config BLK_DEV_LOOP_MIN_COUNT
804 + dynamically allocated with the /dev/loop-control interface.
805 +
806 + config BLK_DEV_CRYPTOLOOP
807 +- tristate "Cryptoloop Support"
808 ++ tristate "Cryptoloop Support (DEPRECATED)"
809 + select CRYPTO
810 + select CRYPTO_CBC
811 + depends on BLK_DEV_LOOP
812 +@@ -246,7 +246,7 @@ config BLK_DEV_CRYPTOLOOP
813 + WARNING: This device is not safe for journaled file systems like
814 + ext3 or Reiserfs. Please use the Device Mapper crypto module
815 + instead, which can be configured to be on-disk compatible with the
816 +- cryptoloop device.
817 ++ cryptoloop device. cryptoloop support will be removed in Linux 5.16.
818 +
819 + source "drivers/block/drbd/Kconfig"
820 +
821 +diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
822 +index 74e03aa537ad7..32363816cb04d 100644
823 +--- a/drivers/block/cryptoloop.c
824 ++++ b/drivers/block/cryptoloop.c
825 +@@ -203,6 +203,8 @@ init_cryptoloop(void)
826 +
827 + if (rc)
828 + printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
829 ++ else
830 ++ pr_warn("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n");
831 + return rc;
832 + }
833 +
834 +diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
835 +index 971a9a5006af0..0813cc259f0fa 100644
836 +--- a/drivers/clk/clk.c
837 ++++ b/drivers/clk/clk.c
838 +@@ -45,11 +45,6 @@ static struct hlist_head *all_lists[] = {
839 + NULL,
840 + };
841 +
842 +-static struct hlist_head *orphan_list[] = {
843 +- &clk_orphan_list,
844 +- NULL,
845 +-};
846 +-
847 + /*** private data structures ***/
848 +
849 + struct clk_core {
850 +@@ -2004,6 +1999,11 @@ static int inited = 0;
851 + static DEFINE_MUTEX(clk_debug_lock);
852 + static HLIST_HEAD(clk_debug_list);
853 +
854 ++static struct hlist_head *orphan_list[] = {
855 ++ &clk_orphan_list,
856 ++ NULL,
857 ++};
858 ++
859 + static void clk_summary_show_one(struct seq_file *s, struct clk_core *c,
860 + int level)
861 + {
862 +diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c
863 +index 890ebf623261b..38612cd9092eb 100644
864 +--- a/drivers/clk/mvebu/kirkwood.c
865 ++++ b/drivers/clk/mvebu/kirkwood.c
866 +@@ -254,6 +254,7 @@ static const char *powersave_parents[] = {
867 + static const struct clk_muxing_soc_desc kirkwood_mux_desc[] __initconst = {
868 + { "powersave", powersave_parents, ARRAY_SIZE(powersave_parents),
869 + 11, 1, 0 },
870 ++ { }
871 + };
872 +
873 + static struct clk *clk_muxing_get_src(
874 +diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
875 +index 3cd62f7c33e30..48eeee53a5862 100644
876 +--- a/drivers/clocksource/sh_cmt.c
877 ++++ b/drivers/clocksource/sh_cmt.c
878 +@@ -570,7 +570,8 @@ static int sh_cmt_start(struct sh_cmt_channel *ch, unsigned long flag)
879 + ch->flags |= flag;
880 +
881 + /* setup timeout if no clockevent */
882 +- if ((flag == FLAG_CLOCKSOURCE) && (!(ch->flags & FLAG_CLOCKEVENT)))
883 ++ if (ch->cmt->num_channels == 1 &&
884 ++ flag == FLAG_CLOCKSOURCE && (!(ch->flags & FLAG_CLOCKEVENT)))
885 + __sh_cmt_set_next(ch, ch->max_match_value);
886 + out:
887 + raw_spin_unlock_irqrestore(&ch->lock, flags);
888 +@@ -606,20 +607,25 @@ static struct sh_cmt_channel *cs_to_sh_cmt(struct clocksource *cs)
889 + static u64 sh_cmt_clocksource_read(struct clocksource *cs)
890 + {
891 + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
892 +- unsigned long flags;
893 + u32 has_wrapped;
894 +- u64 value;
895 +- u32 raw;
896 +
897 +- raw_spin_lock_irqsave(&ch->lock, flags);
898 +- value = ch->total_cycles;
899 +- raw = sh_cmt_get_counter(ch, &has_wrapped);
900 ++ if (ch->cmt->num_channels == 1) {
901 ++ unsigned long flags;
902 ++ u64 value;
903 ++ u32 raw;
904 +
905 +- if (unlikely(has_wrapped))
906 +- raw += ch->match_value + 1;
907 +- raw_spin_unlock_irqrestore(&ch->lock, flags);
908 ++ raw_spin_lock_irqsave(&ch->lock, flags);
909 ++ value = ch->total_cycles;
910 ++ raw = sh_cmt_get_counter(ch, &has_wrapped);
911 ++
912 ++ if (unlikely(has_wrapped))
913 ++ raw += ch->match_value + 1;
914 ++ raw_spin_unlock_irqrestore(&ch->lock, flags);
915 ++
916 ++ return value + raw;
917 ++ }
918 +
919 +- return value + raw;
920 ++ return sh_cmt_get_counter(ch, &has_wrapped);
921 + }
922 +
923 + static int sh_cmt_clocksource_enable(struct clocksource *cs)
924 +@@ -682,7 +688,7 @@ static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch,
925 + cs->disable = sh_cmt_clocksource_disable;
926 + cs->suspend = sh_cmt_clocksource_suspend;
927 + cs->resume = sh_cmt_clocksource_resume;
928 +- cs->mask = CLOCKSOURCE_MASK(sizeof(u64) * 8);
929 ++ cs->mask = CLOCKSOURCE_MASK(ch->cmt->info->width);
930 + cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
931 +
932 + dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",
933 +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
934 +index 56c3d86e5b9de..7ec5bc4548aac 100644
935 +--- a/drivers/cpufreq/powernv-cpufreq.c
936 ++++ b/drivers/cpufreq/powernv-cpufreq.c
937 +@@ -44,6 +44,7 @@
938 + #define MAX_PSTATE_SHIFT 32
939 + #define LPSTATE_SHIFT 48
940 + #define GPSTATE_SHIFT 56
941 ++#define MAX_NR_CHIPS 32
942 +
943 + #define MAX_RAMP_DOWN_TIME 5120
944 + /*
945 +@@ -1011,12 +1012,20 @@ static int init_chip_info(void)
946 + unsigned int *chip;
947 + unsigned int cpu, i;
948 + unsigned int prev_chip_id = UINT_MAX;
949 ++ cpumask_t *chip_cpu_mask;
950 + int ret = 0;
951 +
952 + chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL);
953 + if (!chip)
954 + return -ENOMEM;
955 +
956 ++ /* Allocate a chip cpu mask large enough to fit mask for all chips */
957 ++ chip_cpu_mask = kcalloc(MAX_NR_CHIPS, sizeof(cpumask_t), GFP_KERNEL);
958 ++ if (!chip_cpu_mask) {
959 ++ ret = -ENOMEM;
960 ++ goto free_and_return;
961 ++ }
962 ++
963 + for_each_possible_cpu(cpu) {
964 + unsigned int id = cpu_to_chip_id(cpu);
965 +
966 +@@ -1024,22 +1033,25 @@ static int init_chip_info(void)
967 + prev_chip_id = id;
968 + chip[nr_chips++] = id;
969 + }
970 ++ cpumask_set_cpu(cpu, &chip_cpu_mask[nr_chips-1]);
971 + }
972 +
973 + chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL);
974 + if (!chips) {
975 + ret = -ENOMEM;
976 +- goto free_and_return;
977 ++ goto out_free_chip_cpu_mask;
978 + }
979 +
980 + for (i = 0; i < nr_chips; i++) {
981 + chips[i].id = chip[i];
982 +- cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i]));
983 ++ cpumask_copy(&chips[i].mask, &chip_cpu_mask[i]);
984 + INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn);
985 + for_each_cpu(cpu, &chips[i].mask)
986 + per_cpu(chip_info, cpu) = &chips[i];
987 + }
988 +
989 ++out_free_chip_cpu_mask:
990 ++ kfree(chip_cpu_mask);
991 + free_and_return:
992 + kfree(chip);
993 + return ret;
994 +diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
995 +index eb569cf063095..e986be405411a 100644
996 +--- a/drivers/crypto/mxs-dcp.c
997 ++++ b/drivers/crypto/mxs-dcp.c
998 +@@ -167,15 +167,19 @@ static struct dcp *global_sdcp;
999 +
1000 + static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
1001 + {
1002 ++ int dma_err;
1003 + struct dcp *sdcp = global_sdcp;
1004 + const int chan = actx->chan;
1005 + uint32_t stat;
1006 + unsigned long ret;
1007 + struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
1008 +-
1009 + dma_addr_t desc_phys = dma_map_single(sdcp->dev, desc, sizeof(*desc),
1010 + DMA_TO_DEVICE);
1011 +
1012 ++ dma_err = dma_mapping_error(sdcp->dev, desc_phys);
1013 ++ if (dma_err)
1014 ++ return dma_err;
1015 ++
1016 + reinit_completion(&sdcp->completion[chan]);
1017 +
1018 + /* Clear status register. */
1019 +@@ -213,18 +217,29 @@ static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
1020 + static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
1021 + struct ablkcipher_request *req, int init)
1022 + {
1023 ++ dma_addr_t key_phys, src_phys, dst_phys;
1024 + struct dcp *sdcp = global_sdcp;
1025 + struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
1026 + struct dcp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);
1027 + int ret;
1028 +
1029 +- dma_addr_t key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
1030 +- 2 * AES_KEYSIZE_128,
1031 +- DMA_TO_DEVICE);
1032 +- dma_addr_t src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
1033 +- DCP_BUF_SZ, DMA_TO_DEVICE);
1034 +- dma_addr_t dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
1035 +- DCP_BUF_SZ, DMA_FROM_DEVICE);
1036 ++ key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
1037 ++ 2 * AES_KEYSIZE_128, DMA_TO_DEVICE);
1038 ++ ret = dma_mapping_error(sdcp->dev, key_phys);
1039 ++ if (ret)
1040 ++ return ret;
1041 ++
1042 ++ src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
1043 ++ DCP_BUF_SZ, DMA_TO_DEVICE);
1044 ++ ret = dma_mapping_error(sdcp->dev, src_phys);
1045 ++ if (ret)
1046 ++ goto err_src;
1047 ++
1048 ++ dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
1049 ++ DCP_BUF_SZ, DMA_FROM_DEVICE);
1050 ++ ret = dma_mapping_error(sdcp->dev, dst_phys);
1051 ++ if (ret)
1052 ++ goto err_dst;
1053 +
1054 + if (actx->fill % AES_BLOCK_SIZE) {
1055 + dev_err(sdcp->dev, "Invalid block size!\n");
1056 +@@ -262,10 +277,12 @@ static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
1057 + ret = mxs_dcp_start_dma(actx);
1058 +
1059 + aes_done_run:
1060 ++ dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
1061 ++err_dst:
1062 ++ dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
1063 ++err_src:
1064 + dma_unmap_single(sdcp->dev, key_phys, 2 * AES_KEYSIZE_128,
1065 + DMA_TO_DEVICE);
1066 +- dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
1067 +- dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
1068 +
1069 + return ret;
1070 + }
1071 +@@ -280,21 +297,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
1072 +
1073 + struct scatterlist *dst = req->dst;
1074 + struct scatterlist *src = req->src;
1075 +- const int nents = sg_nents(req->src);
1076 ++ int dst_nents = sg_nents(dst);
1077 +
1078 + const int out_off = DCP_BUF_SZ;
1079 + uint8_t *in_buf = sdcp->coh->aes_in_buf;
1080 + uint8_t *out_buf = sdcp->coh->aes_out_buf;
1081 +
1082 +- uint8_t *out_tmp, *src_buf, *dst_buf = NULL;
1083 + uint32_t dst_off = 0;
1084 ++ uint8_t *src_buf = NULL;
1085 + uint32_t last_out_len = 0;
1086 +
1087 + uint8_t *key = sdcp->coh->aes_key;
1088 +
1089 + int ret = 0;
1090 +- int split = 0;
1091 +- unsigned int i, len, clen, rem = 0, tlen = 0;
1092 ++ unsigned int i, len, clen, tlen = 0;
1093 + int init = 0;
1094 + bool limit_hit = false;
1095 +
1096 +@@ -312,7 +328,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
1097 + memset(key + AES_KEYSIZE_128, 0, AES_KEYSIZE_128);
1098 + }
1099 +
1100 +- for_each_sg(req->src, src, nents, i) {
1101 ++ for_each_sg(req->src, src, sg_nents(src), i) {
1102 + src_buf = sg_virt(src);
1103 + len = sg_dma_len(src);
1104 + tlen += len;
1105 +@@ -337,34 +353,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
1106 + * submit the buffer.
1107 + */
1108 + if (actx->fill == out_off || sg_is_last(src) ||
1109 +- limit_hit) {
1110 ++ limit_hit) {
1111 + ret = mxs_dcp_run_aes(actx, req, init);
1112 + if (ret)
1113 + return ret;
1114 + init = 0;
1115 +
1116 +- out_tmp = out_buf;
1117 ++ sg_pcopy_from_buffer(dst, dst_nents, out_buf,
1118 ++ actx->fill, dst_off);
1119 ++ dst_off += actx->fill;
1120 + last_out_len = actx->fill;
1121 +- while (dst && actx->fill) {
1122 +- if (!split) {
1123 +- dst_buf = sg_virt(dst);
1124 +- dst_off = 0;
1125 +- }
1126 +- rem = min(sg_dma_len(dst) - dst_off,
1127 +- actx->fill);
1128 +-
1129 +- memcpy(dst_buf + dst_off, out_tmp, rem);
1130 +- out_tmp += rem;
1131 +- dst_off += rem;
1132 +- actx->fill -= rem;
1133 +-
1134 +- if (dst_off == sg_dma_len(dst)) {
1135 +- dst = sg_next(dst);
1136 +- split = 0;
1137 +- } else {
1138 +- split = 1;
1139 +- }
1140 +- }
1141 ++ actx->fill = 0;
1142 + }
1143 + } while (len);
1144 +
1145 +@@ -565,6 +564,10 @@ static int mxs_dcp_run_sha(struct ahash_request *req)
1146 + dma_addr_t buf_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_in_buf,
1147 + DCP_BUF_SZ, DMA_TO_DEVICE);
1148 +
1149 ++ ret = dma_mapping_error(sdcp->dev, buf_phys);
1150 ++ if (ret)
1151 ++ return ret;
1152 ++
1153 + /* Fill in the DMA descriptor. */
1154 + desc->control0 = MXS_DCP_CONTROL0_DECR_SEMAPHORE |
1155 + MXS_DCP_CONTROL0_INTERRUPT |
1156 +@@ -597,6 +600,10 @@ static int mxs_dcp_run_sha(struct ahash_request *req)
1157 + if (rctx->fini) {
1158 + digest_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_out_buf,
1159 + DCP_SHA_PAY_SZ, DMA_FROM_DEVICE);
1160 ++ ret = dma_mapping_error(sdcp->dev, digest_phys);
1161 ++ if (ret)
1162 ++ goto done_run;
1163 ++
1164 + desc->control0 |= MXS_DCP_CONTROL0_HASH_TERM;
1165 + desc->payload = digest_phys;
1166 + }
1167 +diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
1168 +index e34e9561e77d6..adf958956982c 100644
1169 +--- a/drivers/crypto/omap-sham.c
1170 ++++ b/drivers/crypto/omap-sham.c
1171 +@@ -1746,7 +1746,7 @@ static void omap_sham_done_task(unsigned long data)
1172 + if (test_and_clear_bit(FLAGS_OUTPUT_READY, &dd->flags))
1173 + goto finish;
1174 + } else if (test_bit(FLAGS_DMA_READY, &dd->flags)) {
1175 +- if (test_and_clear_bit(FLAGS_DMA_ACTIVE, &dd->flags)) {
1176 ++ if (test_bit(FLAGS_DMA_ACTIVE, &dd->flags)) {
1177 + omap_sham_update_dma_stop(dd);
1178 + if (dd->err) {
1179 + err = dd->err;
1180 +diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
1181 +index d2d0ae445fd89..7c7d49a8a4034 100644
1182 +--- a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
1183 ++++ b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
1184 +@@ -123,10 +123,10 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
1185 + hw_data->enable_error_correction = adf_vf_void_noop;
1186 + hw_data->init_admin_comms = adf_vf_int_noop;
1187 + hw_data->exit_admin_comms = adf_vf_void_noop;
1188 +- hw_data->send_admin_init = adf_vf2pf_init;
1189 ++ hw_data->send_admin_init = adf_vf2pf_notify_init;
1190 + hw_data->init_arb = adf_vf_int_noop;
1191 + hw_data->exit_arb = adf_vf_void_noop;
1192 +- hw_data->disable_iov = adf_vf2pf_shutdown;
1193 ++ hw_data->disable_iov = adf_vf2pf_notify_shutdown;
1194 + hw_data->get_accel_mask = get_accel_mask;
1195 + hw_data->get_ae_mask = get_ae_mask;
1196 + hw_data->get_num_accels = get_num_accels;
1197 +diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
1198 +index 38e4bc04f407b..90e8a7564756b 100644
1199 +--- a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
1200 ++++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
1201 +@@ -123,10 +123,10 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
1202 + hw_data->enable_error_correction = adf_vf_void_noop;
1203 + hw_data->init_admin_comms = adf_vf_int_noop;
1204 + hw_data->exit_admin_comms = adf_vf_void_noop;
1205 +- hw_data->send_admin_init = adf_vf2pf_init;
1206 ++ hw_data->send_admin_init = adf_vf2pf_notify_init;
1207 + hw_data->init_arb = adf_vf_int_noop;
1208 + hw_data->exit_arb = adf_vf_void_noop;
1209 +- hw_data->disable_iov = adf_vf2pf_shutdown;
1210 ++ hw_data->disable_iov = adf_vf2pf_notify_shutdown;
1211 + hw_data->get_accel_mask = get_accel_mask;
1212 + hw_data->get_ae_mask = get_ae_mask;
1213 + hw_data->get_num_accels = get_num_accels;
1214 +diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
1215 +index d78f8d5c89c3f..289dd7e48d4a4 100644
1216 +--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
1217 ++++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
1218 +@@ -239,8 +239,8 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
1219 + void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
1220 + void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
1221 +
1222 +-int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
1223 +-void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
1224 ++int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev);
1225 ++void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev);
1226 + int adf_init_pf_wq(void);
1227 + void adf_exit_pf_wq(void);
1228 + int adf_init_vf_wq(void);
1229 +@@ -263,12 +263,12 @@ static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
1230 + {
1231 + }
1232 +
1233 +-static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
1234 ++static inline int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
1235 + {
1236 + return 0;
1237 + }
1238 +
1239 +-static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
1240 ++static inline void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
1241 + {
1242 + }
1243 +
1244 +diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c
1245 +index 26556c7130497..7a7d43c475342 100644
1246 +--- a/drivers/crypto/qat/qat_common/adf_init.c
1247 ++++ b/drivers/crypto/qat/qat_common/adf_init.c
1248 +@@ -105,6 +105,7 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
1249 + struct service_hndl *service;
1250 + struct list_head *list_itr;
1251 + struct adf_hw_device_data *hw_data = accel_dev->hw_device;
1252 ++ int ret;
1253 +
1254 + if (!hw_data) {
1255 + dev_err(&GET_DEV(accel_dev),
1256 +@@ -171,9 +172,9 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
1257 + }
1258 +
1259 + hw_data->enable_error_correction(accel_dev);
1260 +- hw_data->enable_vf2pf_comms(accel_dev);
1261 ++ ret = hw_data->enable_vf2pf_comms(accel_dev);
1262 +
1263 +- return 0;
1264 ++ return ret;
1265 + }
1266 + EXPORT_SYMBOL_GPL(adf_dev_init);
1267 +
1268 +diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
1269 +index 2c0be14309cfa..7877ba6772203 100644
1270 +--- a/drivers/crypto/qat/qat_common/adf_isr.c
1271 ++++ b/drivers/crypto/qat/qat_common/adf_isr.c
1272 +@@ -59,6 +59,8 @@
1273 + #include "adf_transport_access_macros.h"
1274 + #include "adf_transport_internal.h"
1275 +
1276 ++#define ADF_MAX_NUM_VFS 32
1277 ++
1278 + static int adf_enable_msix(struct adf_accel_dev *accel_dev)
1279 + {
1280 + struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev;
1281 +@@ -111,7 +113,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
1282 + struct adf_bar *pmisc =
1283 + &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
1284 + void __iomem *pmisc_bar_addr = pmisc->virt_addr;
1285 +- u32 vf_mask;
1286 ++ unsigned long vf_mask;
1287 +
1288 + /* Get the interrupt sources triggered by VFs */
1289 + vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
1290 +@@ -132,8 +134,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
1291 + * unless the VF is malicious and is attempting to
1292 + * flood the host OS with VF2PF interrupts.
1293 + */
1294 +- for_each_set_bit(i, (const unsigned long *)&vf_mask,
1295 +- (sizeof(vf_mask) * BITS_PER_BYTE)) {
1296 ++ for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) {
1297 + vf_info = accel_dev->pf.vf_info + i;
1298 +
1299 + if (!__ratelimit(&vf_info->vf2pf_ratelimit)) {
1300 +diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1301 +index b3875fdf6cd72..c64481160b711 100644
1302 +--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1303 ++++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1304 +@@ -231,7 +231,6 @@ int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
1305 +
1306 + return ret;
1307 + }
1308 +-EXPORT_SYMBOL_GPL(adf_iov_putmsg);
1309 +
1310 + void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
1311 + {
1312 +@@ -361,6 +360,8 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
1313 + msg |= ADF_PFVF_COMPATIBILITY_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
1314 + BUILD_BUG_ON(ADF_PFVF_COMPATIBILITY_VERSION > 255);
1315 +
1316 ++ reinit_completion(&accel_dev->vf.iov_msg_completion);
1317 ++
1318 + /* Send request from VF to PF */
1319 + ret = adf_iov_putmsg(accel_dev, msg, 0);
1320 + if (ret) {
1321 +diff --git a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1322 +index cd5f37dffe8a6..1830194567e84 100644
1323 +--- a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1324 ++++ b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1325 +@@ -49,14 +49,14 @@
1326 + #include "adf_pf2vf_msg.h"
1327 +
1328 + /**
1329 +- * adf_vf2pf_init() - send init msg to PF
1330 ++ * adf_vf2pf_notify_init() - send init msg to PF
1331 + * @accel_dev: Pointer to acceleration VF device.
1332 + *
1333 + * Function sends an init messge from the VF to a PF
1334 + *
1335 + * Return: 0 on success, error code otherwise.
1336 + */
1337 +-int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
1338 ++int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
1339 + {
1340 + u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
1341 + (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
1342 +@@ -69,17 +69,17 @@ int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
1343 + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
1344 + return 0;
1345 + }
1346 +-EXPORT_SYMBOL_GPL(adf_vf2pf_init);
1347 ++EXPORT_SYMBOL_GPL(adf_vf2pf_notify_init);
1348 +
1349 + /**
1350 +- * adf_vf2pf_shutdown() - send shutdown msg to PF
1351 ++ * adf_vf2pf_notify_shutdown() - send shutdown msg to PF
1352 + * @accel_dev: Pointer to acceleration VF device.
1353 + *
1354 + * Function sends a shutdown messge from the VF to a PF
1355 + *
1356 + * Return: void
1357 + */
1358 +-void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
1359 ++void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
1360 + {
1361 + u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
1362 + (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
1363 +@@ -89,4 +89,4 @@ void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
1364 + dev_err(&GET_DEV(accel_dev),
1365 + "Failed to send Shutdown event to PF\n");
1366 + }
1367 +-EXPORT_SYMBOL_GPL(adf_vf2pf_shutdown);
1368 ++EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown);
1369 +diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1370 +index df9a1f35b8320..ef90902c8200d 100644
1371 +--- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
1372 ++++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1373 +@@ -203,6 +203,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1374 + struct adf_bar *pmisc =
1375 + &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
1376 + void __iomem *pmisc_bar_addr = pmisc->virt_addr;
1377 ++ bool handled = false;
1378 + u32 v_int;
1379 +
1380 + /* Read VF INT source CSR to determine the source of VF interrupt */
1381 +@@ -215,7 +216,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1382 +
1383 + /* Schedule tasklet to handle interrupt BH */
1384 + tasklet_hi_schedule(&accel_dev->vf.pf2vf_bh_tasklet);
1385 +- return IRQ_HANDLED;
1386 ++ handled = true;
1387 + }
1388 +
1389 + /* Check bundle interrupt */
1390 +@@ -227,10 +228,10 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1391 + WRITE_CSR_INT_FLAG_AND_COL(bank->csr_addr, bank->bank_number,
1392 + 0);
1393 + tasklet_hi_schedule(&bank->resp_handler);
1394 +- return IRQ_HANDLED;
1395 ++ handled = true;
1396 + }
1397 +
1398 +- return IRQ_NONE;
1399 ++ return handled ? IRQ_HANDLED : IRQ_NONE;
1400 + }
1401 +
1402 + static int adf_request_msi_irq(struct adf_accel_dev *accel_dev)
1403 +diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1404 +index a3b4dd8099a7b..3a8361c83f0b1 100644
1405 +--- a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1406 ++++ b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1407 +@@ -123,10 +123,10 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
1408 + hw_data->enable_error_correction = adf_vf_void_noop;
1409 + hw_data->init_admin_comms = adf_vf_int_noop;
1410 + hw_data->exit_admin_comms = adf_vf_void_noop;
1411 +- hw_data->send_admin_init = adf_vf2pf_init;
1412 ++ hw_data->send_admin_init = adf_vf2pf_notify_init;
1413 + hw_data->init_arb = adf_vf_int_noop;
1414 + hw_data->exit_arb = adf_vf_void_noop;
1415 +- hw_data->disable_iov = adf_vf2pf_shutdown;
1416 ++ hw_data->disable_iov = adf_vf2pf_notify_shutdown;
1417 + hw_data->get_accel_mask = get_accel_mask;
1418 + hw_data->get_ae_mask = get_ae_mask;
1419 + hw_data->get_num_accels = get_num_accels;
1420 +diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
1421 +index 8028fbd5cda47..830d03115efbc 100644
1422 +--- a/drivers/crypto/talitos.c
1423 ++++ b/drivers/crypto/talitos.c
1424 +@@ -816,7 +816,11 @@ static void talitos_unregister_rng(struct device *dev)
1425 + * HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP
1426 + */
1427 + #define TALITOS_CRA_PRIORITY_AEAD_HSNA (TALITOS_CRA_PRIORITY - 1)
1428 ++#ifdef CONFIG_CRYPTO_DEV_TALITOS_SEC2
1429 + #define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA512_BLOCK_SIZE)
1430 ++#else
1431 ++#define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA256_BLOCK_SIZE)
1432 ++#endif
1433 + #define TALITOS_MAX_IV_LENGTH 16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
1434 +
1435 + struct talitos_ctx {
1436 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1437 +index f2739995c335a..199eccee0b0bb 100644
1438 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1439 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1440 +@@ -338,7 +338,7 @@ static void amdgpu_i2c_put_byte(struct amdgpu_i2c_chan *i2c_bus,
1441 + void
1442 + amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connector)
1443 + {
1444 +- u8 val;
1445 ++ u8 val = 0;
1446 +
1447 + if (!amdgpu_connector->router.ddc_valid)
1448 + return;
1449 +diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
1450 +index 98742d7af6dcb..bacb33eec0fa9 100644
1451 +--- a/drivers/gpu/drm/msm/dsi/dsi.c
1452 ++++ b/drivers/gpu/drm/msm/dsi/dsi.c
1453 +@@ -34,8 +34,10 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
1454 + }
1455 +
1456 + phy_pdev = of_find_device_by_node(phy_node);
1457 +- if (phy_pdev)
1458 ++ if (phy_pdev) {
1459 + msm_dsi->phy = platform_get_drvdata(phy_pdev);
1460 ++ msm_dsi->phy_dev = &phy_pdev->dev;
1461 ++ }
1462 +
1463 + of_node_put(phy_node);
1464 +
1465 +@@ -44,8 +46,6 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
1466 + return -EPROBE_DEFER;
1467 + }
1468 +
1469 +- msm_dsi->phy_dev = get_device(&phy_pdev->dev);
1470 +-
1471 + return 0;
1472 + }
1473 +
1474 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
1475 +index 0e63cedcc3b51..96bf221ba572e 100644
1476 +--- a/drivers/hid/hid-input.c
1477 ++++ b/drivers/hid/hid-input.c
1478 +@@ -425,8 +425,6 @@ static int hidinput_get_battery_property(struct power_supply *psy,
1479 +
1480 + if (dev->battery_status == HID_BATTERY_UNKNOWN)
1481 + val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
1482 +- else if (dev->battery_capacity == 100)
1483 +- val->intval = POWER_SUPPLY_STATUS_FULL;
1484 + else
1485 + val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
1486 + break;
1487 +diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
1488 +index 56dc69e7349fc..9ad031ea33009 100644
1489 +--- a/drivers/i2c/busses/i2c-highlander.c
1490 ++++ b/drivers/i2c/busses/i2c-highlander.c
1491 +@@ -382,7 +382,7 @@ static int highlander_i2c_probe(struct platform_device *pdev)
1492 + platform_set_drvdata(pdev, dev);
1493 +
1494 + dev->irq = platform_get_irq(pdev, 0);
1495 +- if (iic_force_poll)
1496 ++ if (dev->irq < 0 || iic_force_poll)
1497 + dev->irq = 0;
1498 +
1499 + if (dev->irq) {
1500 +diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
1501 +index 85cbe4b555786..d4fe7ccccb226 100644
1502 +--- a/drivers/i2c/busses/i2c-iop3xx.c
1503 ++++ b/drivers/i2c/busses/i2c-iop3xx.c
1504 +@@ -456,16 +456,14 @@ iop3xx_i2c_probe(struct platform_device *pdev)
1505 +
1506 + irq = platform_get_irq(pdev, 0);
1507 + if (irq < 0) {
1508 +- ret = -ENXIO;
1509 ++ ret = irq;
1510 + goto unmap;
1511 + }
1512 + ret = request_irq(irq, iop3xx_i2c_irq_handler, 0,
1513 + pdev->name, adapter_data);
1514 +
1515 +- if (ret) {
1516 +- ret = -EIO;
1517 ++ if (ret)
1518 + goto unmap;
1519 +- }
1520 +
1521 + memcpy(new_adapter->name, pdev->name, strlen(pdev->name));
1522 + new_adapter->owner = THIS_MODULE;
1523 +diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
1524 +index 09d288ce0ddbc..cbcf76ea9c190 100644
1525 +--- a/drivers/i2c/busses/i2c-mt65xx.c
1526 ++++ b/drivers/i2c/busses/i2c-mt65xx.c
1527 +@@ -740,7 +740,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
1528 + return PTR_ERR(i2c->pdmabase);
1529 +
1530 + irq = platform_get_irq(pdev, 0);
1531 +- if (irq <= 0)
1532 ++ if (irq < 0)
1533 + return irq;
1534 +
1535 + init_completion(&i2c->msg_complete);
1536 +diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
1537 +index de10ca40aebc7..911f8628128ed 100644
1538 +--- a/drivers/i2c/busses/i2c-s3c2410.c
1539 ++++ b/drivers/i2c/busses/i2c-s3c2410.c
1540 +@@ -1181,7 +1181,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1541 + */
1542 + if (!(i2c->quirks & QUIRK_POLL)) {
1543 + i2c->irq = ret = platform_get_irq(pdev, 0);
1544 +- if (ret <= 0) {
1545 ++ if (ret < 0) {
1546 + dev_err(&pdev->dev, "cannot find IRQ\n");
1547 + clk_unprepare(i2c->clk);
1548 + return ret;
1549 +diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
1550 +index 5489ec43b95d7..e5cefdb674f80 100644
1551 +--- a/drivers/iio/dac/ad5624r_spi.c
1552 ++++ b/drivers/iio/dac/ad5624r_spi.c
1553 +@@ -231,7 +231,7 @@ static int ad5624r_probe(struct spi_device *spi)
1554 + if (!indio_dev)
1555 + return -ENOMEM;
1556 + st = iio_priv(indio_dev);
1557 +- st->reg = devm_regulator_get(&spi->dev, "vcc");
1558 ++ st->reg = devm_regulator_get_optional(&spi->dev, "vref");
1559 + if (!IS_ERR(st->reg)) {
1560 + ret = regulator_enable(st->reg);
1561 + if (ret)
1562 +@@ -242,6 +242,22 @@ static int ad5624r_probe(struct spi_device *spi)
1563 + goto error_disable_reg;
1564 +
1565 + voltage_uv = ret;
1566 ++ } else {
1567 ++ if (PTR_ERR(st->reg) != -ENODEV)
1568 ++ return PTR_ERR(st->reg);
1569 ++ /* Backwards compatibility. This naming is not correct */
1570 ++ st->reg = devm_regulator_get_optional(&spi->dev, "vcc");
1571 ++ if (!IS_ERR(st->reg)) {
1572 ++ ret = regulator_enable(st->reg);
1573 ++ if (ret)
1574 ++ return ret;
1575 ++
1576 ++ ret = regulator_get_voltage(st->reg);
1577 ++ if (ret < 0)
1578 ++ goto error_disable_reg;
1579 ++
1580 ++ voltage_uv = ret;
1581 ++ }
1582 + }
1583 +
1584 + spi_set_drvdata(spi, indio_dev);
1585 +diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
1586 +index 16b0c10348e84..66204e08ce5ac 100644
1587 +--- a/drivers/infiniband/core/iwcm.c
1588 ++++ b/drivers/infiniband/core/iwcm.c
1589 +@@ -1176,29 +1176,34 @@ static int __init iw_cm_init(void)
1590 +
1591 + ret = iwpm_init(RDMA_NL_IWCM);
1592 + if (ret)
1593 +- pr_err("iw_cm: couldn't init iwpm\n");
1594 +- else
1595 +- rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
1596 ++ return ret;
1597 ++
1598 + iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", 0);
1599 + if (!iwcm_wq)
1600 +- return -ENOMEM;
1601 ++ goto err_alloc;
1602 +
1603 + iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
1604 + iwcm_ctl_table);
1605 + if (!iwcm_ctl_table_hdr) {
1606 + pr_err("iw_cm: couldn't register sysctl paths\n");
1607 +- destroy_workqueue(iwcm_wq);
1608 +- return -ENOMEM;
1609 ++ goto err_sysctl;
1610 + }
1611 +
1612 ++ rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
1613 + return 0;
1614 ++
1615 ++err_sysctl:
1616 ++ destroy_workqueue(iwcm_wq);
1617 ++err_alloc:
1618 ++ iwpm_exit(RDMA_NL_IWCM);
1619 ++ return -ENOMEM;
1620 + }
1621 +
1622 + static void __exit iw_cm_cleanup(void)
1623 + {
1624 ++ rdma_nl_unregister(RDMA_NL_IWCM);
1625 + unregister_net_sysctl_table(iwcm_ctl_table_hdr);
1626 + destroy_workqueue(iwcm_wq);
1627 +- rdma_nl_unregister(RDMA_NL_IWCM);
1628 + iwpm_exit(RDMA_NL_IWCM);
1629 + }
1630 +
1631 +diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
1632 +index 5e38ceb360004..b8a9695af1416 100644
1633 +--- a/drivers/md/dm-crypt.c
1634 ++++ b/drivers/md/dm-crypt.c
1635 +@@ -2188,7 +2188,12 @@ static void *crypt_page_alloc(gfp_t gfp_mask, void *pool_data)
1636 + struct crypt_config *cc = pool_data;
1637 + struct page *page;
1638 +
1639 +- if (unlikely(percpu_counter_compare(&cc->n_allocated_pages, dm_crypt_pages_per_client) >= 0) &&
1640 ++ /*
1641 ++ * Note, percpu_counter_read_positive() may over (and under) estimate
1642 ++ * the current usage by at most (batch - 1) * num_online_cpus() pages,
1643 ++ * but avoids potential spinlock contention of an exact result.
1644 ++ */
1645 ++ if (unlikely(percpu_counter_read_positive(&cc->n_allocated_pages) >= dm_crypt_pages_per_client) &&
1646 + likely(gfp_mask & __GFP_NORETRY))
1647 + return NULL;
1648 +
1649 +diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
1650 +index 5d9381509b079..59ab01dc62b19 100644
1651 +--- a/drivers/media/dvb-frontends/dib8000.c
1652 ++++ b/drivers/media/dvb-frontends/dib8000.c
1653 +@@ -2110,32 +2110,55 @@ static void dib8000_load_ana_fe_coefs(struct dib8000_state *state, const s16 *an
1654 + dib8000_write_word(state, 117 + mode, ana_fe[mode]);
1655 + }
1656 +
1657 +-static const u16 lut_prbs_2k[14] = {
1658 +- 0, 0x423, 0x009, 0x5C7, 0x7A6, 0x3D8, 0x527, 0x7FF, 0x79B, 0x3D6, 0x3A2, 0x53B, 0x2F4, 0x213
1659 ++static const u16 lut_prbs_2k[13] = {
1660 ++ 0x423, 0x009, 0x5C7,
1661 ++ 0x7A6, 0x3D8, 0x527,
1662 ++ 0x7FF, 0x79B, 0x3D6,
1663 ++ 0x3A2, 0x53B, 0x2F4,
1664 ++ 0x213
1665 + };
1666 +-static const u16 lut_prbs_4k[14] = {
1667 +- 0, 0x208, 0x0C3, 0x7B9, 0x423, 0x5C7, 0x3D8, 0x7FF, 0x3D6, 0x53B, 0x213, 0x029, 0x0D0, 0x48E
1668 ++
1669 ++static const u16 lut_prbs_4k[13] = {
1670 ++ 0x208, 0x0C3, 0x7B9,
1671 ++ 0x423, 0x5C7, 0x3D8,
1672 ++ 0x7FF, 0x3D6, 0x53B,
1673 ++ 0x213, 0x029, 0x0D0,
1674 ++ 0x48E
1675 + };
1676 +-static const u16 lut_prbs_8k[14] = {
1677 +- 0, 0x740, 0x069, 0x7DD, 0x208, 0x7B9, 0x5C7, 0x7FF, 0x53B, 0x029, 0x48E, 0x4C4, 0x367, 0x684
1678 ++
1679 ++static const u16 lut_prbs_8k[13] = {
1680 ++ 0x740, 0x069, 0x7DD,
1681 ++ 0x208, 0x7B9, 0x5C7,
1682 ++ 0x7FF, 0x53B, 0x029,
1683 ++ 0x48E, 0x4C4, 0x367,
1684 ++ 0x684
1685 + };
1686 +
1687 + static u16 dib8000_get_init_prbs(struct dib8000_state *state, u16 subchannel)
1688 + {
1689 + int sub_channel_prbs_group = 0;
1690 ++ int prbs_group;
1691 +
1692 +- sub_channel_prbs_group = (subchannel / 3) + 1;
1693 +- dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x\n", sub_channel_prbs_group, subchannel, lut_prbs_8k[sub_channel_prbs_group]);
1694 ++ sub_channel_prbs_group = subchannel / 3;
1695 ++ if (sub_channel_prbs_group >= ARRAY_SIZE(lut_prbs_2k))
1696 ++ return 0;
1697 +
1698 + switch (state->fe[0]->dtv_property_cache.transmission_mode) {
1699 + case TRANSMISSION_MODE_2K:
1700 +- return lut_prbs_2k[sub_channel_prbs_group];
1701 ++ prbs_group = lut_prbs_2k[sub_channel_prbs_group];
1702 ++ break;
1703 + case TRANSMISSION_MODE_4K:
1704 +- return lut_prbs_4k[sub_channel_prbs_group];
1705 ++ prbs_group = lut_prbs_4k[sub_channel_prbs_group];
1706 ++ break;
1707 + default:
1708 + case TRANSMISSION_MODE_8K:
1709 +- return lut_prbs_8k[sub_channel_prbs_group];
1710 ++ prbs_group = lut_prbs_8k[sub_channel_prbs_group];
1711 + }
1712 ++
1713 ++ dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x\n",
1714 ++ sub_channel_prbs_group, subchannel, prbs_group);
1715 ++
1716 ++ return prbs_group;
1717 + }
1718 +
1719 + static void dib8000_set_13seg_channel(struct dib8000_state *state)
1720 +@@ -2412,10 +2435,8 @@ static void dib8000_set_isdbt_common_channel(struct dib8000_state *state, u8 seq
1721 + /* TSB or ISDBT ? apply it now */
1722 + if (c->isdbt_sb_mode) {
1723 + dib8000_set_sb_channel(state);
1724 +- if (c->isdbt_sb_subchannel < 14)
1725 +- init_prbs = dib8000_get_init_prbs(state, c->isdbt_sb_subchannel);
1726 +- else
1727 +- init_prbs = 0;
1728 ++ init_prbs = dib8000_get_init_prbs(state,
1729 ++ c->isdbt_sb_subchannel);
1730 + } else {
1731 + dib8000_set_13seg_channel(state);
1732 + init_prbs = 0xfff;
1733 +@@ -3007,6 +3028,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
1734 +
1735 + unsigned long *timeout = &state->timeout;
1736 + unsigned long now = jiffies;
1737 ++ u16 init_prbs;
1738 + #ifdef DIB8000_AGC_FREEZE
1739 + u16 agc1, agc2;
1740 + #endif
1741 +@@ -3305,8 +3327,10 @@ static int dib8000_tune(struct dvb_frontend *fe)
1742 + break;
1743 +
1744 + case CT_DEMOD_STEP_11: /* 41 : init prbs autosearch */
1745 +- if (state->subchannel <= 41) {
1746 +- dib8000_set_subchannel_prbs(state, dib8000_get_init_prbs(state, state->subchannel));
1747 ++ init_prbs = dib8000_get_init_prbs(state, state->subchannel);
1748 ++
1749 ++ if (init_prbs) {
1750 ++ dib8000_set_subchannel_prbs(state, init_prbs);
1751 + *tune_state = CT_DEMOD_STEP_9;
1752 + } else {
1753 + *tune_state = CT_DEMOD_STOP;
1754 +diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
1755 +index 3822d9ebcb46c..5abbde7e5d5b3 100644
1756 +--- a/drivers/media/rc/rc-loopback.c
1757 ++++ b/drivers/media/rc/rc-loopback.c
1758 +@@ -52,7 +52,7 @@ static int loop_set_tx_mask(struct rc_dev *dev, u32 mask)
1759 +
1760 + if ((mask & (RXMASK_REGULAR | RXMASK_LEARNING)) != mask) {
1761 + dprintk("invalid tx mask: %u\n", mask);
1762 +- return -EINVAL;
1763 ++ return 2;
1764 + }
1765 +
1766 + dprintk("setting tx mask: %u\n", mask);
1767 +diff --git a/drivers/media/usb/dvb-usb/nova-t-usb2.c b/drivers/media/usb/dvb-usb/nova-t-usb2.c
1768 +index 1babd33419106..016a6d1ad279b 100644
1769 +--- a/drivers/media/usb/dvb-usb/nova-t-usb2.c
1770 ++++ b/drivers/media/usb/dvb-usb/nova-t-usb2.c
1771 +@@ -133,7 +133,7 @@ ret:
1772 +
1773 + static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
1774 + {
1775 +- int i;
1776 ++ int i, ret;
1777 + u8 b;
1778 +
1779 + mac[0] = 0x00;
1780 +@@ -142,7 +142,9 @@ static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
1781 +
1782 + /* this is a complete guess, but works for my box */
1783 + for (i = 136; i < 139; i++) {
1784 +- dibusb_read_eeprom_byte(d,i, &b);
1785 ++ ret = dibusb_read_eeprom_byte(d, i, &b);
1786 ++ if (ret)
1787 ++ return ret;
1788 +
1789 + mac[5 - (i - 136)] = b;
1790 + }
1791 +diff --git a/drivers/media/usb/dvb-usb/vp702x.c b/drivers/media/usb/dvb-usb/vp702x.c
1792 +index 40de33de90a7a..5c3b0a7ca27e1 100644
1793 +--- a/drivers/media/usb/dvb-usb/vp702x.c
1794 ++++ b/drivers/media/usb/dvb-usb/vp702x.c
1795 +@@ -294,16 +294,22 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1796 + static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
1797 + {
1798 + u8 i, *buf;
1799 ++ int ret;
1800 + struct vp702x_device_state *st = d->priv;
1801 +
1802 + mutex_lock(&st->buf_mutex);
1803 + buf = st->buf;
1804 +- for (i = 6; i < 12; i++)
1805 +- vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1);
1806 ++ for (i = 6; i < 12; i++) {
1807 ++ ret = vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1,
1808 ++ &buf[i - 6], 1);
1809 ++ if (ret < 0)
1810 ++ goto err;
1811 ++ }
1812 +
1813 + memcpy(mac, buf, 6);
1814 ++err:
1815 + mutex_unlock(&st->buf_mutex);
1816 +- return 0;
1817 ++ return ret;
1818 + }
1819 +
1820 + static int vp702x_frontend_attach(struct dvb_usb_adapter *adap)
1821 +diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
1822 +index b8c94b4ad2327..0be2fb7517057 100644
1823 +--- a/drivers/media/usb/em28xx/em28xx-input.c
1824 ++++ b/drivers/media/usb/em28xx/em28xx-input.c
1825 +@@ -839,7 +839,6 @@ error:
1826 + kfree(ir);
1827 + ref_put:
1828 + em28xx_shutdown_buttons(dev);
1829 +- kref_put(&dev->ref, em28xx_free_device);
1830 + return err;
1831 + }
1832 +
1833 +diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
1834 +index 05b1126f263ef..d861d7225f49d 100644
1835 +--- a/drivers/media/usb/go7007/go7007-driver.c
1836 ++++ b/drivers/media/usb/go7007/go7007-driver.c
1837 +@@ -698,49 +698,23 @@ struct go7007 *go7007_alloc(const struct go7007_board_info *board,
1838 + struct device *dev)
1839 + {
1840 + struct go7007 *go;
1841 +- int i;
1842 +
1843 + go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
1844 + if (go == NULL)
1845 + return NULL;
1846 + go->dev = dev;
1847 + go->board_info = board;
1848 +- go->board_id = 0;
1849 + go->tuner_type = -1;
1850 +- go->channel_number = 0;
1851 +- go->name[0] = 0;
1852 + mutex_init(&go->hw_lock);
1853 + init_waitqueue_head(&go->frame_waitq);
1854 + spin_lock_init(&go->spinlock);
1855 + go->status = STATUS_INIT;
1856 +- memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter));
1857 +- go->i2c_adapter_online = 0;
1858 +- go->interrupt_available = 0;
1859 + init_waitqueue_head(&go->interrupt_waitq);
1860 +- go->input = 0;
1861 + go7007_update_board(go);
1862 +- go->encoder_h_halve = 0;
1863 +- go->encoder_v_halve = 0;
1864 +- go->encoder_subsample = 0;
1865 + go->format = V4L2_PIX_FMT_MJPEG;
1866 + go->bitrate = 1500000;
1867 + go->fps_scale = 1;
1868 +- go->pali = 0;
1869 + go->aspect_ratio = GO7007_RATIO_1_1;
1870 +- go->gop_size = 0;
1871 +- go->ipb = 0;
1872 +- go->closed_gop = 0;
1873 +- go->repeat_seqhead = 0;
1874 +- go->seq_header_enable = 0;
1875 +- go->gop_header_enable = 0;
1876 +- go->dvd_mode = 0;
1877 +- go->interlace_coding = 0;
1878 +- for (i = 0; i < 4; ++i)
1879 +- go->modet[i].enable = 0;
1880 +- for (i = 0; i < 1624; ++i)
1881 +- go->modet_map[i] = 0;
1882 +- go->audio_deliver = NULL;
1883 +- go->audio_enabled = 0;
1884 +
1885 + return go;
1886 + }
1887 +diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
1888 +index 6992e84f8a8bb..2058742c556e1 100644
1889 +--- a/drivers/media/usb/stkwebcam/stk-webcam.c
1890 ++++ b/drivers/media/usb/stkwebcam/stk-webcam.c
1891 +@@ -1355,7 +1355,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1892 + if (!dev->isoc_ep) {
1893 + pr_err("Could not find isoc-in endpoint\n");
1894 + err = -ENODEV;
1895 +- goto error;
1896 ++ goto error_put;
1897 + }
1898 + dev->vsettings.palette = V4L2_PIX_FMT_RGB565;
1899 + dev->vsettings.mode = MODE_VGA;
1900 +@@ -1368,10 +1368,12 @@ static int stk_camera_probe(struct usb_interface *interface,
1901 +
1902 + err = stk_register_video_device(dev);
1903 + if (err)
1904 +- goto error;
1905 ++ goto error_put;
1906 +
1907 + return 0;
1908 +
1909 ++error_put:
1910 ++ usb_put_intf(interface);
1911 + error:
1912 + v4l2_ctrl_handler_free(hdl);
1913 + v4l2_device_unregister(&dev->v4l2_dev);
1914 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
1915 +index 08a3a8ad79d75..fae811b9cde96 100644
1916 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
1917 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
1918 +@@ -876,8 +876,8 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
1919 + {
1920 + struct uvc_fh *handle = fh;
1921 + struct uvc_video_chain *chain = handle->chain;
1922 ++ u8 *buf;
1923 + int ret;
1924 +- u8 i;
1925 +
1926 + if (chain->selector == NULL ||
1927 + (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
1928 +@@ -885,22 +885,27 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
1929 + return 0;
1930 + }
1931 +
1932 ++ buf = kmalloc(1, GFP_KERNEL);
1933 ++ if (!buf)
1934 ++ return -ENOMEM;
1935 ++
1936 + ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id,
1937 + chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1938 +- &i, 1);
1939 +- if (ret < 0)
1940 +- return ret;
1941 ++ buf, 1);
1942 ++ if (!ret)
1943 ++ *input = *buf - 1;
1944 +
1945 +- *input = i - 1;
1946 +- return 0;
1947 ++ kfree(buf);
1948 ++
1949 ++ return ret;
1950 + }
1951 +
1952 + static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
1953 + {
1954 + struct uvc_fh *handle = fh;
1955 + struct uvc_video_chain *chain = handle->chain;
1956 ++ u8 *buf;
1957 + int ret;
1958 +- u32 i;
1959 +
1960 + ret = uvc_acquire_privileges(handle);
1961 + if (ret < 0)
1962 +@@ -916,10 +921,17 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
1963 + if (input >= chain->selector->bNrInPins)
1964 + return -EINVAL;
1965 +
1966 +- i = input + 1;
1967 +- return uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
1968 +- chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1969 +- &i, 1);
1970 ++ buf = kmalloc(1, GFP_KERNEL);
1971 ++ if (!buf)
1972 ++ return -ENOMEM;
1973 ++
1974 ++ *buf = input + 1;
1975 ++ ret = uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
1976 ++ chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1977 ++ buf, 1);
1978 ++ kfree(buf);
1979 ++
1980 ++ return ret;
1981 + }
1982 +
1983 + static int uvc_ioctl_queryctrl(struct file *file, void *fh,
1984 +diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
1985 +index 5c8c49d240d14..bed6b7db43f54 100644
1986 +--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
1987 ++++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
1988 +@@ -207,7 +207,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
1989 + if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle))
1990 + return false;
1991 +
1992 +- for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
1993 ++ for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
1994 + if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap,
1995 + fnc, fnc_handle) &&
1996 + v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i,
1997 +@@ -229,7 +229,7 @@ bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic)
1998 + {
1999 + unsigned int i;
2000 +
2001 +- for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
2002 ++ for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
2003 + const struct v4l2_bt_timings *bt =
2004 + &v4l2_dv_timings_presets[i].bt;
2005 +
2006 +diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
2007 +index 11ab17f64c649..f0527e7698677 100644
2008 +--- a/drivers/mfd/ab8500-core.c
2009 ++++ b/drivers/mfd/ab8500-core.c
2010 +@@ -493,7 +493,7 @@ static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500,
2011 + if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F)
2012 + line += 1;
2013 +
2014 +- handle_nested_irq(irq_create_mapping(ab8500->domain, line));
2015 ++ handle_nested_irq(irq_find_mapping(ab8500->domain, line));
2016 + }
2017 +
2018 + return 0;
2019 +diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
2020 +index 566caca4efd8e..722ad2c368a56 100644
2021 +--- a/drivers/mfd/stmpe.c
2022 ++++ b/drivers/mfd/stmpe.c
2023 +@@ -1035,7 +1035,7 @@ static irqreturn_t stmpe_irq(int irq, void *data)
2024 +
2025 + if (variant->id_val == STMPE801_ID ||
2026 + variant->id_val == STMPE1600_ID) {
2027 +- int base = irq_create_mapping(stmpe->domain, 0);
2028 ++ int base = irq_find_mapping(stmpe->domain, 0);
2029 +
2030 + handle_nested_irq(base);
2031 + return IRQ_HANDLED;
2032 +@@ -1063,7 +1063,7 @@ static irqreturn_t stmpe_irq(int irq, void *data)
2033 + while (status) {
2034 + int bit = __ffs(status);
2035 + int line = bank * 8 + bit;
2036 +- int nestedirq = irq_create_mapping(stmpe->domain, line);
2037 ++ int nestedirq = irq_find_mapping(stmpe->domain, line);
2038 +
2039 + handle_nested_irq(nestedirq);
2040 + status &= ~(1 << bit);
2041 +diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
2042 +index cc9e563f23aa6..7062baf606858 100644
2043 +--- a/drivers/mfd/tc3589x.c
2044 ++++ b/drivers/mfd/tc3589x.c
2045 +@@ -187,7 +187,7 @@ again:
2046 +
2047 + while (status) {
2048 + int bit = __ffs(status);
2049 +- int virq = irq_create_mapping(tc3589x->domain, bit);
2050 ++ int virq = irq_find_mapping(tc3589x->domain, bit);
2051 +
2052 + handle_nested_irq(virq);
2053 + status &= ~(1 << bit);
2054 +diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c
2055 +index 18710f3b5c534..2c58d9b99a394 100644
2056 +--- a/drivers/mfd/wm8994-irq.c
2057 ++++ b/drivers/mfd/wm8994-irq.c
2058 +@@ -159,7 +159,7 @@ static irqreturn_t wm8994_edge_irq(int irq, void *data)
2059 + struct wm8994 *wm8994 = data;
2060 +
2061 + while (gpio_get_value_cansleep(wm8994->pdata.irq_gpio))
2062 +- handle_nested_irq(irq_create_mapping(wm8994->edge_irq, 0));
2063 ++ handle_nested_irq(irq_find_mapping(wm8994->edge_irq, 0));
2064 +
2065 + return IRQ_HANDLED;
2066 + }
2067 +diff --git a/drivers/misc/aspeed-lpc-ctrl.c b/drivers/misc/aspeed-lpc-ctrl.c
2068 +index b5439643f54b2..f3cc3167f1ef7 100644
2069 +--- a/drivers/misc/aspeed-lpc-ctrl.c
2070 ++++ b/drivers/misc/aspeed-lpc-ctrl.c
2071 +@@ -44,7 +44,7 @@ static int aspeed_lpc_ctrl_mmap(struct file *file, struct vm_area_struct *vma)
2072 + unsigned long vsize = vma->vm_end - vma->vm_start;
2073 + pgprot_t prot = vma->vm_page_prot;
2074 +
2075 +- if (vma->vm_pgoff + vsize > lpc_ctrl->mem_base + lpc_ctrl->mem_size)
2076 ++ if (vma->vm_pgoff + vma_pages(vma) > lpc_ctrl->mem_size >> PAGE_SHIFT)
2077 + return -EINVAL;
2078 +
2079 + /* ast2400/2500 AHB accesses are not cache coherent */
2080 +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
2081 +index 7a7de85406e5e..8394f4d039346 100644
2082 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
2083 ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
2084 +@@ -2338,7 +2338,8 @@ int vmci_qp_broker_map(struct vmci_handle handle,
2085 + is_local = entry->qp.flags & VMCI_QPFLAG_LOCAL;
2086 + result = VMCI_SUCCESS;
2087 +
2088 +- if (context_id != VMCI_HOST_CONTEXT_ID) {
2089 ++ if (context_id != VMCI_HOST_CONTEXT_ID &&
2090 ++ !QPBROKERSTATE_HAS_MEM(entry)) {
2091 + struct vmci_qp_page_store page_store;
2092 +
2093 + page_store.pages = guest_mem;
2094 +@@ -2448,7 +2449,8 @@ int vmci_qp_broker_unmap(struct vmci_handle handle,
2095 +
2096 + is_local = entry->qp.flags & VMCI_QPFLAG_LOCAL;
2097 +
2098 +- if (context_id != VMCI_HOST_CONTEXT_ID) {
2099 ++ if (context_id != VMCI_HOST_CONTEXT_ID &&
2100 ++ QPBROKERSTATE_HAS_MEM(entry)) {
2101 + qp_acquire_queue_mutex(entry->produce_q);
2102 + result = qp_save_headers(entry);
2103 + if (result < VMCI_SUCCESS)
2104 +diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
2105 +index bd994a8fce149..44d317d71b4ce 100644
2106 +--- a/drivers/mmc/host/dw_mmc.c
2107 ++++ b/drivers/mmc/host/dw_mmc.c
2108 +@@ -832,6 +832,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
2109 + int ret = 0;
2110 +
2111 + /* Set external dma config: burst size, burst width */
2112 ++ memset(&cfg, 0, sizeof(cfg));
2113 + cfg.dst_addr = host->phy_regs + fifo_offset;
2114 + cfg.src_addr = cfg.dst_addr;
2115 + cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
2116 +diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
2117 +index a0670e9cd0127..5553a5643f405 100644
2118 +--- a/drivers/mmc/host/moxart-mmc.c
2119 ++++ b/drivers/mmc/host/moxart-mmc.c
2120 +@@ -631,6 +631,7 @@ static int moxart_probe(struct platform_device *pdev)
2121 + host->dma_chan_tx, host->dma_chan_rx);
2122 + host->have_dma = true;
2123 +
2124 ++ memset(&cfg, 0, sizeof(cfg));
2125 + cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
2126 + cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
2127 +
2128 +diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
2129 +index 41b57713b620a..9de6a32f0c9fc 100644
2130 +--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
2131 ++++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
2132 +@@ -551,9 +551,22 @@ static int sd_write_long_data(struct realtek_pci_sdmmc *host,
2133 + return 0;
2134 + }
2135 +
2136 ++static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
2137 ++{
2138 ++ rtsx_pci_write_register(host->pcr, SD_CFG1,
2139 ++ SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
2140 ++}
2141 ++
2142 ++static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
2143 ++{
2144 ++ rtsx_pci_write_register(host->pcr, SD_CFG1,
2145 ++ SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
2146 ++}
2147 ++
2148 + static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
2149 + {
2150 + struct mmc_data *data = mrq->data;
2151 ++ int err;
2152 +
2153 + if (host->sg_count < 0) {
2154 + data->error = host->sg_count;
2155 +@@ -562,22 +575,19 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
2156 + return data->error;
2157 + }
2158 +
2159 +- if (data->flags & MMC_DATA_READ)
2160 +- return sd_read_long_data(host, mrq);
2161 ++ if (data->flags & MMC_DATA_READ) {
2162 ++ if (host->initial_mode)
2163 ++ sd_disable_initial_mode(host);
2164 +
2165 +- return sd_write_long_data(host, mrq);
2166 +-}
2167 ++ err = sd_read_long_data(host, mrq);
2168 +
2169 +-static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
2170 +-{
2171 +- rtsx_pci_write_register(host->pcr, SD_CFG1,
2172 +- SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
2173 +-}
2174 ++ if (host->initial_mode)
2175 ++ sd_enable_initial_mode(host);
2176 +
2177 +-static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
2178 +-{
2179 +- rtsx_pci_write_register(host->pcr, SD_CFG1,
2180 +- SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
2181 ++ return err;
2182 ++ }
2183 ++
2184 ++ return sd_write_long_data(host, mrq);
2185 + }
2186 +
2187 + static void sd_normal_rw(struct realtek_pci_sdmmc *host,
2188 +diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
2189 +index e033ad4777151..0a2bfd034df35 100644
2190 +--- a/drivers/mmc/host/sdhci-of-arasan.c
2191 ++++ b/drivers/mmc/host/sdhci-of-arasan.c
2192 +@@ -179,7 +179,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
2193 + * through low speeds without power cycling.
2194 + */
2195 + sdhci_set_clock(host, host->max_clk);
2196 +- phy_power_on(sdhci_arasan->phy);
2197 ++ if (phy_power_on(sdhci_arasan->phy)) {
2198 ++ pr_err("%s: Cannot power on phy.\n",
2199 ++ mmc_hostname(host->mmc));
2200 ++ return;
2201 ++ }
2202 ++
2203 + sdhci_arasan->is_phy_on = true;
2204 +
2205 + /*
2206 +@@ -205,7 +210,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
2207 + sdhci_set_clock(host, clock);
2208 +
2209 + if (ctrl_phy) {
2210 +- phy_power_on(sdhci_arasan->phy);
2211 ++ if (phy_power_on(sdhci_arasan->phy)) {
2212 ++ pr_err("%s: Cannot power on phy.\n",
2213 ++ mmc_hostname(host->mmc));
2214 ++ return;
2215 ++ }
2216 ++
2217 + sdhci_arasan->is_phy_on = true;
2218 + }
2219 + }
2220 +@@ -305,7 +315,9 @@ static int sdhci_arasan_suspend(struct device *dev)
2221 + ret = phy_power_off(sdhci_arasan->phy);
2222 + if (ret) {
2223 + dev_err(dev, "Cannot power off phy.\n");
2224 +- sdhci_resume_host(host);
2225 ++ if (sdhci_resume_host(host))
2226 ++ dev_err(dev, "Cannot resume host.\n");
2227 ++
2228 + return ret;
2229 + }
2230 + sdhci_arasan->is_phy_on = false;
2231 +diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
2232 +index 98c013094fa23..ffc4ca1872e2f 100644
2233 +--- a/drivers/mtd/nand/cafe_nand.c
2234 ++++ b/drivers/mtd/nand/cafe_nand.c
2235 +@@ -702,7 +702,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
2236 + "CAFE NAND", mtd);
2237 + if (err) {
2238 + dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq);
2239 +- goto out_ior;
2240 ++ goto out_free_rs;
2241 + }
2242 +
2243 + /* Disable master reset, enable NAND clock */
2244 +@@ -809,6 +809,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
2245 + /* Disable NAND IRQ in global IRQ mask register */
2246 + cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
2247 + free_irq(pdev->irq, mtd);
2248 ++ out_free_rs:
2249 ++ free_rs(cafe->rs);
2250 + out_ior:
2251 + pci_iounmap(pdev, cafe->mmio);
2252 + out_free_mtd:
2253 +diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
2254 +index 820aed3e23522..9fff492294352 100644
2255 +--- a/drivers/net/dsa/b53/b53_common.c
2256 ++++ b/drivers/net/dsa/b53/b53_common.c
2257 +@@ -1843,9 +1843,8 @@ static int b53_switch_init(struct b53_device *dev)
2258 + dev->cpu_port = 5;
2259 + }
2260 +
2261 +- /* cpu port is always last */
2262 +- dev->num_ports = dev->cpu_port + 1;
2263 + dev->enabled_ports |= BIT(dev->cpu_port);
2264 ++ dev->num_ports = fls(dev->enabled_ports);
2265 +
2266 + dev->ports = devm_kzalloc(dev->dev,
2267 + sizeof(struct b53_port) * dev->num_ports,
2268 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
2269 +index e4d1aaf838a43..c87b5b5089939 100644
2270 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
2271 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
2272 +@@ -1243,7 +1243,7 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
2273 +
2274 + /* SR-IOV capability was enabled but there are no VFs*/
2275 + if (iov->total == 0) {
2276 +- err = -EINVAL;
2277 ++ err = 0;
2278 + goto failed;
2279 + }
2280 +
2281 +diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
2282 +index f1f07e9d53f8c..07d6472dd149f 100755
2283 +--- a/drivers/net/ethernet/cadence/macb_ptp.c
2284 ++++ b/drivers/net/ethernet/cadence/macb_ptp.c
2285 +@@ -286,6 +286,12 @@ void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb,
2286 +
2287 + if (GEM_BFEXT(DMA_RXVALID, desc->addr)) {
2288 + desc_ptp = macb_ptp_desc(bp, desc);
2289 ++ /* Unlikely but check */
2290 ++ if (!desc_ptp) {
2291 ++ dev_warn_ratelimited(&bp->pdev->dev,
2292 ++ "Timestamp not supported in BD\n");
2293 ++ return;
2294 ++ }
2295 + gem_hw_timestamp(bp, desc_ptp->ts_1, desc_ptp->ts_2, &ts);
2296 + memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
2297 + shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
2298 +@@ -318,8 +324,11 @@ int gem_ptp_txstamp(struct macb_queue *queue, struct sk_buff *skb,
2299 + if (CIRC_SPACE(head, tail, PTP_TS_BUFFER_SIZE) == 0)
2300 + return -ENOMEM;
2301 +
2302 +- skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
2303 + desc_ptp = macb_ptp_desc(queue->bp, desc);
2304 ++ /* Unlikely but check */
2305 ++ if (!desc_ptp)
2306 ++ return -EINVAL;
2307 ++ skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
2308 + tx_timestamp = &queue->tx_timestamps[head];
2309 + tx_timestamp->skb = skb;
2310 + tx_timestamp->desc_ptp.ts_1 = desc_ptp->ts_1;
2311 +diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
2312 +index 8623be13bf86f..eef8fa1008890 100644
2313 +--- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
2314 ++++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
2315 +@@ -1157,6 +1157,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2316 + if (!adapter->registered_device_map) {
2317 + pr_err("%s: could not register any net devices\n",
2318 + pci_name(pdev));
2319 ++ err = -EINVAL;
2320 + goto out_release_adapter_res;
2321 + }
2322 +
2323 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
2324 +index 52e747fd9c839..62d514b60e23e 100644
2325 +--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
2326 ++++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
2327 +@@ -437,7 +437,12 @@ static int qed_enable_msix(struct qed_dev *cdev,
2328 + rc = cnt;
2329 + }
2330 +
2331 +- if (rc > 0) {
2332 ++ /* For VFs, we should return with an error in case we didn't get the
2333 ++ * exact number of msix vectors as we requested.
2334 ++ * Not doing that will lead to a crash when starting queues for
2335 ++ * this VF.
2336 ++ */
2337 ++ if ((IS_PF(cdev) && rc > 0) || (IS_VF(cdev) && rc == cnt)) {
2338 + /* MSI-x configuration was achieved */
2339 + int_params->out.int_mode = QED_INT_MODE_MSIX;
2340 + int_params->out.num_vectors = rc;
2341 +diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
2342 +index 8bb734486bf3c..99de923728ec5 100644
2343 +--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
2344 ++++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
2345 +@@ -1590,6 +1590,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
2346 + }
2347 +
2348 + edev->int_info.used_cnt = 0;
2349 ++ edev->int_info.msix_cnt = 0;
2350 + }
2351 +
2352 + static int qede_req_msix_irqs(struct qede_dev *edev)
2353 +@@ -2088,7 +2089,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
2354 + goto out;
2355 + err4:
2356 + qede_sync_free_irqs(edev);
2357 +- memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
2358 + err3:
2359 + qede_napi_disable_remove(edev);
2360 + err2:
2361 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
2362 +index c48a0e2d4d7ef..6a009d51ec510 100644
2363 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
2364 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
2365 +@@ -440,7 +440,6 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
2366 + QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c, 1);
2367 + msleep(20);
2368 +
2369 +- qlcnic_rom_unlock(adapter);
2370 + /* big hammer don't reset CAM block on reset */
2371 + QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff);
2372 +
2373 +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
2374 +index 1c87178fc4858..1ca1f72474abe 100644
2375 +--- a/drivers/net/ethernet/qualcomm/qca_spi.c
2376 ++++ b/drivers/net/ethernet/qualcomm/qca_spi.c
2377 +@@ -413,7 +413,7 @@ qcaspi_receive(struct qcaspi *qca)
2378 + skb_put(qca->rx_skb, retcode);
2379 + qca->rx_skb->protocol = eth_type_trans(
2380 + qca->rx_skb, qca->rx_skb->dev);
2381 +- qca->rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
2382 ++ skb_checksum_none_assert(qca->rx_skb);
2383 + netif_rx_ni(qca->rx_skb);
2384 + qca->rx_skb = netdev_alloc_skb_ip_align(net_dev,
2385 + net_dev->mtu + VLAN_ETH_HLEN);
2386 +diff --git a/drivers/net/ethernet/qualcomm/qca_uart.c b/drivers/net/ethernet/qualcomm/qca_uart.c
2387 +index db6068cd7a1f2..466e9d07697a1 100644
2388 +--- a/drivers/net/ethernet/qualcomm/qca_uart.c
2389 ++++ b/drivers/net/ethernet/qualcomm/qca_uart.c
2390 +@@ -107,7 +107,7 @@ qca_tty_receive(struct serdev_device *serdev, const unsigned char *data,
2391 + skb_put(qca->rx_skb, retcode);
2392 + qca->rx_skb->protocol = eth_type_trans(
2393 + qca->rx_skb, qca->rx_skb->dev);
2394 +- qca->rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
2395 ++ skb_checksum_none_assert(qca->rx_skb);
2396 + netif_rx_ni(qca->rx_skb);
2397 + qca->rx_skb = netdev_alloc_skb_ip_align(netdev,
2398 + netdev->mtu +
2399 +diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
2400 +index aa11b70b9ca48..2199bd08f4d6a 100644
2401 +--- a/drivers/net/ethernet/rdc/r6040.c
2402 ++++ b/drivers/net/ethernet/rdc/r6040.c
2403 +@@ -133,6 +133,8 @@
2404 + #define PHY_ST 0x8A /* PHY status register */
2405 + #define MAC_SM 0xAC /* MAC status machine */
2406 + #define MAC_SM_RST 0x0002 /* MAC status machine reset */
2407 ++#define MD_CSC 0xb6 /* MDC speed control register */
2408 ++#define MD_CSC_DEFAULT 0x0030
2409 + #define MAC_ID 0xBE /* Identifier register */
2410 +
2411 + #define TX_DCNT 0x80 /* TX descriptor count */
2412 +@@ -368,8 +370,9 @@ static void r6040_reset_mac(struct r6040_private *lp)
2413 + {
2414 + void __iomem *ioaddr = lp->base;
2415 + int limit = MAC_DEF_TIMEOUT;
2416 +- u16 cmd;
2417 ++ u16 cmd, md_csc;
2418 +
2419 ++ md_csc = ioread16(ioaddr + MD_CSC);
2420 + iowrite16(MAC_RST, ioaddr + MCR1);
2421 + while (limit--) {
2422 + cmd = ioread16(ioaddr + MCR1);
2423 +@@ -381,6 +384,10 @@ static void r6040_reset_mac(struct r6040_private *lp)
2424 + iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
2425 + iowrite16(0, ioaddr + MAC_SM);
2426 + mdelay(5);
2427 ++
2428 ++ /* Restore MDIO clock frequency */
2429 ++ if (md_csc != MD_CSC_DEFAULT)
2430 ++ iowrite16(md_csc, ioaddr + MD_CSC);
2431 + }
2432 +
2433 + static void r6040_init_mac_regs(struct net_device *dev)
2434 +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
2435 +index 36f1019809ea6..0fa6403ab085a 100644
2436 +--- a/drivers/net/ethernet/renesas/sh_eth.c
2437 ++++ b/drivers/net/ethernet/renesas/sh_eth.c
2438 +@@ -2442,6 +2442,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
2439 + else
2440 + txdesc->status |= cpu_to_le32(TD_TACT);
2441 +
2442 ++ wmb(); /* cur_tx must be incremented after TACT bit was set */
2443 + mdp->cur_tx++;
2444 +
2445 + if (!(sh_eth_read(ndev, EDTRR) & sh_eth_get_edtrr_trns(mdp)))
2446 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2447 +index f4ff43a1b5ba0..d8c40b68bc96f 100644
2448 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2449 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2450 +@@ -300,10 +300,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
2451 + val &= ~NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL;
2452 + break;
2453 + default:
2454 +- dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
2455 +- phy_modes(gmac->phy_mode));
2456 +- err = -EINVAL;
2457 +- goto err_remove_config_dt;
2458 ++ goto err_unsupported_phy;
2459 + }
2460 + regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
2461 +
2462 +@@ -320,10 +317,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
2463 + NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
2464 + break;
2465 + default:
2466 +- dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
2467 +- phy_modes(gmac->phy_mode));
2468 +- err = -EINVAL;
2469 +- goto err_remove_config_dt;
2470 ++ goto err_unsupported_phy;
2471 + }
2472 + regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
2473 +
2474 +@@ -340,8 +334,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
2475 + NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
2476 + break;
2477 + default:
2478 +- /* We don't get here; the switch above will have errored out */
2479 +- unreachable();
2480 ++ goto err_unsupported_phy;
2481 + }
2482 + regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val);
2483 +
2484 +@@ -372,6 +365,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
2485 +
2486 + return 0;
2487 +
2488 ++err_unsupported_phy:
2489 ++ dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
2490 ++ phy_modes(gmac->phy_mode));
2491 ++ err = -EINVAL;
2492 ++
2493 + err_remove_config_dt:
2494 + stmmac_remove_config_dt(pdev, plat_dat);
2495 +
2496 +diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
2497 +index 2bdfb39215e9c..87610d8b34624 100644
2498 +--- a/drivers/net/ethernet/wiznet/w5100.c
2499 ++++ b/drivers/net/ethernet/wiznet/w5100.c
2500 +@@ -1059,6 +1059,8 @@ static int w5100_mmio_probe(struct platform_device *pdev)
2501 + mac_addr = data->mac_addr;
2502 +
2503 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2504 ++ if (!mem)
2505 ++ return -EINVAL;
2506 + if (resource_size(mem) < W5100_BUS_DIRECT_SIZE)
2507 + ops = &w5100_mmio_indirect_ops;
2508 + else
2509 +diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
2510 +index 939de185bc6b8..178234e94cd16 100644
2511 +--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
2512 ++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
2513 +@@ -736,10 +736,8 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
2514 + /* Kick off the transfer */
2515 + lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
2516 +
2517 +- if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {
2518 +- netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);
2519 ++ if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
2520 + netif_stop_queue(ndev);
2521 +- }
2522 +
2523 + return NETDEV_TX_OK;
2524 + }
2525 +diff --git a/drivers/net/phy/dp83640_reg.h b/drivers/net/phy/dp83640_reg.h
2526 +index 21aa24c741b96..daae7fa58fb82 100644
2527 +--- a/drivers/net/phy/dp83640_reg.h
2528 ++++ b/drivers/net/phy/dp83640_reg.h
2529 +@@ -5,7 +5,7 @@
2530 + #ifndef HAVE_DP83640_REGISTERS
2531 + #define HAVE_DP83640_REGISTERS
2532 +
2533 +-#define PAGE0 0x0000
2534 ++/* #define PAGE0 0x0000 */
2535 + #define PHYCR2 0x001c /* PHY Control Register 2 */
2536 +
2537 + #define PAGE4 0x0004
2538 +diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
2539 +index 0362acd5cdcaa..cdd1b193fd4fe 100644
2540 +--- a/drivers/net/usb/cdc_mbim.c
2541 ++++ b/drivers/net/usb/cdc_mbim.c
2542 +@@ -655,6 +655,11 @@ static const struct usb_device_id mbim_devs[] = {
2543 + .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
2544 + },
2545 +
2546 ++ /* Telit LN920 */
2547 ++ { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1061, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
2548 ++ .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
2549 ++ },
2550 ++
2551 + /* default entry */
2552 + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
2553 + .driver_info = (unsigned long)&cdc_mbim_info_zlp,
2554 +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
2555 +index ad64ec2e04b5c..cda57104d5ba4 100644
2556 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
2557 ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
2558 +@@ -613,6 +613,28 @@ struct amsdu_subframe_hdr {
2559 +
2560 + #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
2561 +
2562 ++static inline u8 ath10k_bw_to_mac80211_bw(u8 bw)
2563 ++{
2564 ++ u8 ret = 0;
2565 ++
2566 ++ switch (bw) {
2567 ++ case 0:
2568 ++ ret = RATE_INFO_BW_20;
2569 ++ break;
2570 ++ case 1:
2571 ++ ret = RATE_INFO_BW_40;
2572 ++ break;
2573 ++ case 2:
2574 ++ ret = RATE_INFO_BW_80;
2575 ++ break;
2576 ++ case 3:
2577 ++ ret = RATE_INFO_BW_160;
2578 ++ break;
2579 ++ }
2580 ++
2581 ++ return ret;
2582 ++}
2583 ++
2584 + static void ath10k_htt_rx_h_rates(struct ath10k *ar,
2585 + struct ieee80211_rx_status *status,
2586 + struct htt_rx_desc *rxd)
2587 +@@ -721,23 +743,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
2588 + if (sgi)
2589 + status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
2590 +
2591 +- switch (bw) {
2592 +- /* 20MHZ */
2593 +- case 0:
2594 +- break;
2595 +- /* 40MHZ */
2596 +- case 1:
2597 +- status->bw = RATE_INFO_BW_40;
2598 +- break;
2599 +- /* 80MHZ */
2600 +- case 2:
2601 +- status->bw = RATE_INFO_BW_80;
2602 +- break;
2603 +- case 3:
2604 +- status->bw = RATE_INFO_BW_160;
2605 +- break;
2606 +- }
2607 +-
2608 ++ status->bw = ath10k_bw_to_mac80211_bw(bw);
2609 + status->encoding = RX_ENC_VHT;
2610 + break;
2611 + default:
2612 +@@ -2436,7 +2442,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
2613 + arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
2614 +
2615 + arsta->txrate.nss = txrate.nss;
2616 +- arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
2617 ++ arsta->txrate.bw = ath10k_bw_to_mac80211_bw(txrate.bw);
2618 + }
2619 +
2620 + static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
2621 +diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
2622 +index f80f1757b58fc..66df6f8bc0deb 100644
2623 +--- a/drivers/net/wireless/ath/ath6kl/wmi.c
2624 ++++ b/drivers/net/wireless/ath/ath6kl/wmi.c
2625 +@@ -2513,8 +2513,10 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
2626 + goto free_data_skb;
2627 +
2628 + for (index = 0; index < num_pri_streams; index++) {
2629 +- if (WARN_ON(!data_sync_bufs[index].skb))
2630 ++ if (WARN_ON(!data_sync_bufs[index].skb)) {
2631 ++ ret = -ENOMEM;
2632 + goto free_data_skb;
2633 ++ }
2634 +
2635 + ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2636 + data_sync_bufs[index].
2637 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2638 +index 76385834a7def..694a58b1e9950 100644
2639 +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2640 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2641 +@@ -3346,7 +3346,8 @@ found:
2642 + "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
2643 + cptr, code, reference, length, major, minor);
2644 + if ((!AR_SREV_9485(ah) && length >= 1024) ||
2645 +- (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
2646 ++ (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485) ||
2647 ++ (length > cptr)) {
2648 + ath_dbg(common, EEPROM, "Skipping bad header\n");
2649 + cptr -= COMP_HDR_LEN;
2650 + continue;
2651 +diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
2652 +index 933d4f49d6b05..9e3db55a86846 100644
2653 +--- a/drivers/net/wireless/ath/ath9k/hw.c
2654 ++++ b/drivers/net/wireless/ath/ath9k/hw.c
2655 +@@ -1595,7 +1595,6 @@ static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
2656 + ath9k_hw_gpio_request_out(ah, i, NULL,
2657 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
2658 + ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
2659 +- ath9k_hw_gpio_free(ah, i);
2660 + }
2661 + }
2662 +
2663 +@@ -2702,14 +2701,17 @@ static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah, u32 gpio, u32 type)
2664 + static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
2665 + const char *label)
2666 + {
2667 ++ int err;
2668 ++
2669 + if (ah->caps.gpio_requested & BIT(gpio))
2670 + return;
2671 +
2672 +- /* may be requested by BSP, free anyway */
2673 +- gpio_free(gpio);
2674 +-
2675 +- if (gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label))
2676 ++ err = gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label);
2677 ++ if (err) {
2678 ++ ath_err(ath9k_hw_common(ah), "request GPIO%d failed:%d\n",
2679 ++ gpio, err);
2680 + return;
2681 ++ }
2682 +
2683 + ah->caps.gpio_requested |= BIT(gpio);
2684 + }
2685 +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
2686 +index 57e1c0dd63c45..11fd3a7484acd 100644
2687 +--- a/drivers/nvme/host/rdma.c
2688 ++++ b/drivers/nvme/host/rdma.c
2689 +@@ -654,13 +654,13 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
2690 + if (ret)
2691 + return ret;
2692 +
2693 +- ctrl->ctrl.queue_count = nr_io_queues + 1;
2694 +- if (ctrl->ctrl.queue_count < 2) {
2695 ++ if (nr_io_queues == 0) {
2696 + dev_err(ctrl->ctrl.device,
2697 + "unable to set any I/O queues\n");
2698 + return -ENOMEM;
2699 + }
2700 +
2701 ++ ctrl->ctrl.queue_count = nr_io_queues + 1;
2702 + dev_info(ctrl->ctrl.device,
2703 + "creating %d I/O queues.\n", nr_io_queues);
2704 +
2705 +diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c
2706 +index 5d41dda6da4e7..75daa16f38b7f 100644
2707 +--- a/drivers/parport/ieee1284_ops.c
2708 ++++ b/drivers/parport/ieee1284_ops.c
2709 +@@ -535,7 +535,7 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
2710 + goto out;
2711 +
2712 + /* Yield the port for a while. */
2713 +- if (count && dev->port->irq != PARPORT_IRQ_NONE) {
2714 ++ if (dev->port->irq != PARPORT_IRQ_NONE) {
2715 + parport_release (dev);
2716 + schedule_timeout_interruptible(msecs_to_jiffies(40));
2717 + parport_claim_or_block (dev);
2718 +diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
2719 +index a3a28e38430aa..f84166f995179 100644
2720 +--- a/drivers/pci/host/pci-aardvark.c
2721 ++++ b/drivers/pci/host/pci-aardvark.c
2722 +@@ -185,7 +185,7 @@
2723 + (PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn)) | \
2724 + PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where))
2725 +
2726 +-#define PIO_RETRY_CNT 500
2727 ++#define PIO_RETRY_CNT 750000 /* 1.5 s */
2728 + #define PIO_RETRY_DELAY 2 /* 2 us*/
2729 +
2730 + #define LINK_WAIT_MAX_RETRIES 10
2731 +@@ -200,6 +200,7 @@ struct advk_pcie {
2732 + struct list_head resources;
2733 + struct irq_domain *irq_domain;
2734 + struct irq_chip irq_chip;
2735 ++ raw_spinlock_t irq_lock;
2736 + struct irq_domain *msi_domain;
2737 + struct irq_domain *msi_inner_domain;
2738 + struct irq_chip msi_bottom_irq_chip;
2739 +@@ -638,22 +639,28 @@ static void advk_pcie_irq_mask(struct irq_data *d)
2740 + {
2741 + struct advk_pcie *pcie = d->domain->host_data;
2742 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
2743 ++ unsigned long flags;
2744 + u32 mask;
2745 +
2746 ++ raw_spin_lock_irqsave(&pcie->irq_lock, flags);
2747 + mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
2748 + mask |= PCIE_ISR1_INTX_ASSERT(hwirq);
2749 + advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
2750 ++ raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
2751 + }
2752 +
2753 + static void advk_pcie_irq_unmask(struct irq_data *d)
2754 + {
2755 + struct advk_pcie *pcie = d->domain->host_data;
2756 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
2757 ++ unsigned long flags;
2758 + u32 mask;
2759 +
2760 ++ raw_spin_lock_irqsave(&pcie->irq_lock, flags);
2761 + mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
2762 + mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq);
2763 + advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
2764 ++ raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
2765 + }
2766 +
2767 + static int advk_pcie_irq_map(struct irq_domain *h,
2768 +@@ -736,6 +743,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
2769 + struct device_node *pcie_intc_node;
2770 + struct irq_chip *irq_chip;
2771 +
2772 ++ raw_spin_lock_init(&pcie->irq_lock);
2773 ++
2774 + pcie_intc_node = of_get_next_child(node, NULL);
2775 + if (!pcie_intc_node) {
2776 + dev_err(dev, "No PCIe Intc node found\n");
2777 +diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
2778 +index 981a5195686f3..6812a1b49fa8a 100644
2779 +--- a/drivers/pci/host/pcie-xilinx-nwl.c
2780 ++++ b/drivers/pci/host/pcie-xilinx-nwl.c
2781 +@@ -10,6 +10,7 @@
2782 + * (at your option) any later version.
2783 + */
2784 +
2785 ++#include <linux/clk.h>
2786 + #include <linux/delay.h>
2787 + #include <linux/interrupt.h>
2788 + #include <linux/irq.h>
2789 +@@ -171,6 +172,7 @@ struct nwl_pcie {
2790 + u8 root_busno;
2791 + struct nwl_msi msi;
2792 + struct irq_domain *legacy_irq_domain;
2793 ++ struct clk *clk;
2794 + raw_spinlock_t leg_mask_lock;
2795 + };
2796 +
2797 +@@ -852,6 +854,16 @@ static int nwl_pcie_probe(struct platform_device *pdev)
2798 + return err;
2799 + }
2800 +
2801 ++ pcie->clk = devm_clk_get(dev, NULL);
2802 ++ if (IS_ERR(pcie->clk))
2803 ++ return PTR_ERR(pcie->clk);
2804 ++
2805 ++ err = clk_prepare_enable(pcie->clk);
2806 ++ if (err) {
2807 ++ dev_err(dev, "can't enable PCIe ref clock\n");
2808 ++ return err;
2809 ++ }
2810 ++
2811 + err = nwl_pcie_bridge_init(pcie);
2812 + if (err) {
2813 + dev_err(dev, "HW Initialization failed\n");
2814 +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
2815 +index 1473697732801..2d7b06cfc6064 100644
2816 +--- a/drivers/pci/msi.c
2817 ++++ b/drivers/pci/msi.c
2818 +@@ -754,6 +754,9 @@ static void msix_mask_all(void __iomem *base, int tsize)
2819 + u32 ctrl = PCI_MSIX_ENTRY_CTRL_MASKBIT;
2820 + int i;
2821 +
2822 ++ if (pci_msi_ignore_mask)
2823 ++ return;
2824 ++
2825 + for (i = 0; i < tsize; i++, base += PCI_MSIX_ENTRY_SIZE)
2826 + writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
2827 + }
2828 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2829 +index c847b5554db6d..4ff7f2575d28a 100644
2830 +--- a/drivers/pci/pci.c
2831 ++++ b/drivers/pci/pci.c
2832 +@@ -1384,11 +1384,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
2833 + * so that things like MSI message writing will behave as expected
2834 + * (e.g. if the device really is in D0 at enable time).
2835 + */
2836 +- if (dev->pm_cap) {
2837 +- u16 pmcsr;
2838 +- pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
2839 +- dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
2840 +- }
2841 ++ pci_update_current_state(dev, dev->current_state);
2842 +
2843 + if (atomic_inc_return(&dev->enable_cnt) > 1)
2844 + return 0; /* already enabled */
2845 +@@ -1950,7 +1946,14 @@ static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable
2846 + if (enable) {
2847 + int error;
2848 +
2849 +- if (pci_pme_capable(dev, state))
2850 ++ /*
2851 ++ * Enable PME signaling if the device can signal PME from
2852 ++ * D3cold regardless of whether or not it can signal PME from
2853 ++ * the current target state, because that will allow it to
2854 ++ * signal PME when the hierarchy above it goes into D3cold and
2855 ++ * the device itself ends up in D3cold as a result of that.
2856 ++ */
2857 ++ if (pci_pme_capable(dev, state) || pci_pme_capable(dev, PCI_D3cold))
2858 + pci_pme_active(dev, true);
2859 + else
2860 + ret = 1;
2861 +@@ -2054,17 +2057,21 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
2862 + if (dev->current_state == PCI_D3cold)
2863 + target_state = PCI_D3cold;
2864 +
2865 +- if (wakeup) {
2866 ++ if (wakeup && dev->pme_support) {
2867 ++ pci_power_t state = target_state;
2868 ++
2869 + /*
2870 + * Find the deepest state from which the device can generate
2871 + * wake-up events, make it the target state and enable device
2872 + * to generate PME#.
2873 + */
2874 +- if (dev->pme_support) {
2875 +- while (target_state
2876 +- && !(dev->pme_support & (1 << target_state)))
2877 +- target_state--;
2878 +- }
2879 ++ while (state && !(dev->pme_support & (1 << state)))
2880 ++ state--;
2881 ++
2882 ++ if (state)
2883 ++ return state;
2884 ++ else if (dev->pme_support & 1)
2885 ++ return PCI_D0;
2886 + }
2887 +
2888 + return target_state;
2889 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2890 +index db1ec8209b568..eff361af792ad 100644
2891 +--- a/drivers/pci/quirks.c
2892 ++++ b/drivers/pci/quirks.c
2893 +@@ -3034,12 +3034,13 @@ static void fixup_mpss_256(struct pci_dev *dev)
2894 + {
2895 + dev->pcie_mpss = 1; /* 256 bytes */
2896 + }
2897 +-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2898 +- PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
2899 +-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2900 +- PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
2901 +-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2902 +- PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
2903 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2904 ++ PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
2905 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2906 ++ PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
2907 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2908 ++ PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
2909 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ASMEDIA, 0x0612, fixup_mpss_256);
2910 +
2911 + /* Intel 5000 and 5100 Memory controllers have an errata with read completion
2912 + * coalescing (which is enabled by default on some BIOSes) and MPS of 256B.
2913 +@@ -4738,6 +4739,10 @@ static const struct pci_dev_acs_enabled {
2914 + { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
2915 + /* Cavium ThunderX */
2916 + { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs },
2917 ++ /* Cavium multi-function devices */
2918 ++ { PCI_VENDOR_ID_CAVIUM, 0xA026, pci_quirk_mf_endpoint_acs },
2919 ++ { PCI_VENDOR_ID_CAVIUM, 0xA059, pci_quirk_mf_endpoint_acs },
2920 ++ { PCI_VENDOR_ID_CAVIUM, 0xA060, pci_quirk_mf_endpoint_acs },
2921 + /* APM X-Gene */
2922 + { PCI_VENDOR_ID_AMCC, 0xE004, pci_quirk_xgene_acs },
2923 + /* Ampere Computing */
2924 +diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
2925 +index 7445f895ecd1a..18345d4643d79 100644
2926 +--- a/drivers/pci/syscall.c
2927 ++++ b/drivers/pci/syscall.c
2928 +@@ -24,8 +24,10 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
2929 + long err;
2930 + int cfg_ret;
2931 +
2932 ++ err = -EPERM;
2933 ++ dev = NULL;
2934 + if (!capable(CAP_SYS_ADMIN))
2935 +- return -EPERM;
2936 ++ goto error;
2937 +
2938 + err = -ENODEV;
2939 + dev = pci_get_bus_and_slot(bus, dfn);
2940 +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
2941 +index f751b5c3bf7e8..e33972c3a420e 100644
2942 +--- a/drivers/pinctrl/pinctrl-single.c
2943 ++++ b/drivers/pinctrl/pinctrl-single.c
2944 +@@ -1161,6 +1161,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
2945 +
2946 + if (PCS_HAS_PINCONF) {
2947 + dev_err(pcs->dev, "pinconf not supported\n");
2948 ++ res = -ENOTSUPP;
2949 + goto free_pingroups;
2950 + }
2951 +
2952 +diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
2953 +index 7c0f5d4e89f3a..ab04d4c4941d0 100644
2954 +--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
2955 ++++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
2956 +@@ -891,7 +891,7 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
2957 + pin_bank->grange.pin_base = drvdata->pin_base
2958 + + pin_bank->pin_base;
2959 + pin_bank->grange.base = pin_bank->grange.pin_base;
2960 +- pin_bank->grange.npins = pin_bank->gpio_chip.ngpio;
2961 ++ pin_bank->grange.npins = pin_bank->nr_pins;
2962 + pin_bank->grange.gc = &pin_bank->gpio_chip;
2963 + pinctrl_add_gpio_range(drvdata->pctl_dev, &pin_bank->grange);
2964 + }
2965 +diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
2966 +index dbad14716da49..b8e90c1a5e266 100644
2967 +--- a/drivers/platform/chrome/cros_ec_proto.c
2968 ++++ b/drivers/platform/chrome/cros_ec_proto.c
2969 +@@ -217,6 +217,15 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev,
2970 + msg->insize = sizeof(struct ec_response_get_protocol_info);
2971 +
2972 + ret = send_command(ec_dev, msg);
2973 ++ /*
2974 ++ * Send command once again when timeout occurred.
2975 ++ * Fingerprint MCU (FPMCU) is restarted during system boot which
2976 ++ * introduces small window in which FPMCU won't respond for any
2977 ++ * messages sent by kernel. There is no need to wait before next
2978 ++ * attempt because we waited at least EC_MSG_DEADLINE_MS.
2979 ++ */
2980 ++ if (ret == -ETIMEDOUT)
2981 ++ ret = send_command(ec_dev, msg);
2982 +
2983 + if (ret < 0) {
2984 + dev_dbg(ec_dev->dev,
2985 +diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
2986 +index a8dcabc32721d..1fe18c365c874 100644
2987 +--- a/drivers/power/supply/axp288_fuel_gauge.c
2988 ++++ b/drivers/power/supply/axp288_fuel_gauge.c
2989 +@@ -142,7 +142,7 @@ static int fuel_gauge_reg_readb(struct axp288_fg_info *info, int reg)
2990 + }
2991 +
2992 + if (ret < 0) {
2993 +- dev_err(&info->pdev->dev, "axp288 reg read err:%d\n", ret);
2994 ++ dev_err(&info->pdev->dev, "Error reading reg 0x%02x err: %d\n", reg, ret);
2995 + return ret;
2996 + }
2997 +
2998 +@@ -156,7 +156,7 @@ static int fuel_gauge_reg_writeb(struct axp288_fg_info *info, int reg, u8 val)
2999 + ret = regmap_write(info->regmap, reg, (unsigned int)val);
3000 +
3001 + if (ret < 0)
3002 +- dev_err(&info->pdev->dev, "axp288 reg write err:%d\n", ret);
3003 ++ dev_err(&info->pdev->dev, "Error writing reg 0x%02x err: %d\n", reg, ret);
3004 +
3005 + return ret;
3006 + }
3007 +diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
3008 +index 911d42366ef1f..fe5331b23a948 100644
3009 +--- a/drivers/power/supply/max17042_battery.c
3010 ++++ b/drivers/power/supply/max17042_battery.c
3011 +@@ -717,7 +717,7 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
3012 + struct max17042_config_data *config = chip->pdata->config_data;
3013 +
3014 + max17042_override_por(map, MAX17042_TGAIN, config->tgain);
3015 +- max17042_override_por(map, MAx17042_TOFF, config->toff);
3016 ++ max17042_override_por(map, MAX17042_TOFF, config->toff);
3017 + max17042_override_por(map, MAX17042_CGAIN, config->cgain);
3018 + max17042_override_por(map, MAX17042_COFF, config->coff);
3019 +
3020 +@@ -833,8 +833,12 @@ static irqreturn_t max17042_thread_handler(int id, void *dev)
3021 + {
3022 + struct max17042_chip *chip = dev;
3023 + u32 val;
3024 ++ int ret;
3025 ++
3026 ++ ret = regmap_read(chip->regmap, MAX17042_STATUS, &val);
3027 ++ if (ret)
3028 ++ return IRQ_HANDLED;
3029 +
3030 +- regmap_read(chip->regmap, MAX17042_STATUS, &val);
3031 + if ((val & STATUS_INTR_SOCMIN_BIT) ||
3032 + (val & STATUS_INTR_SOCMAX_BIT)) {
3033 + dev_info(&chip->client->dev, "SOC threshold INTR\n");
3034 +diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
3035 +index a56b526db89a4..33c56a1d34569 100644
3036 +--- a/drivers/rtc/rtc-tps65910.c
3037 ++++ b/drivers/rtc/rtc-tps65910.c
3038 +@@ -480,6 +480,6 @@ static struct platform_driver tps65910_rtc_driver = {
3039 + };
3040 +
3041 + module_platform_driver(tps65910_rtc_driver);
3042 +-MODULE_ALIAS("platform:rtc-tps65910");
3043 ++MODULE_ALIAS("platform:tps65910-rtc");
3044 + MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@××××××.com>");
3045 + MODULE_LICENSE("GPL");
3046 +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
3047 +index e2026d54dd375..435e804b6b8b1 100644
3048 +--- a/drivers/s390/cio/css.c
3049 ++++ b/drivers/s390/cio/css.c
3050 +@@ -330,9 +330,26 @@ static ssize_t pimpampom_show(struct device *dev,
3051 + }
3052 + static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL);
3053 +
3054 ++static ssize_t dev_busid_show(struct device *dev,
3055 ++ struct device_attribute *attr,
3056 ++ char *buf)
3057 ++{
3058 ++ struct subchannel *sch = to_subchannel(dev);
3059 ++ struct pmcw *pmcw = &sch->schib.pmcw;
3060 ++
3061 ++ if ((pmcw->st == SUBCHANNEL_TYPE_IO ||
3062 ++ pmcw->st == SUBCHANNEL_TYPE_MSG) && pmcw->dnv)
3063 ++ return sysfs_emit(buf, "0.%x.%04x\n", sch->schid.ssid,
3064 ++ pmcw->dev);
3065 ++ else
3066 ++ return sysfs_emit(buf, "none\n");
3067 ++}
3068 ++static DEVICE_ATTR_RO(dev_busid);
3069 ++
3070 + static struct attribute *io_subchannel_type_attrs[] = {
3071 + &dev_attr_chpids.attr,
3072 + &dev_attr_pimpampom.attr,
3073 ++ &dev_attr_dev_busid.attr,
3074 + NULL,
3075 + };
3076 + ATTRIBUTE_GROUPS(io_subchannel_type);
3077 +diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
3078 +index 48c1b590415de..92fbc0d6b1857 100644
3079 +--- a/drivers/scsi/BusLogic.c
3080 ++++ b/drivers/scsi/BusLogic.c
3081 +@@ -3605,7 +3605,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
3082 + if (buf[0] != '\n' || len > 1)
3083 + printk("%sscsi%d: %s", blogic_msglevelmap[msglevel], adapter->host_no, buf);
3084 + } else
3085 +- printk("%s", buf);
3086 ++ pr_cont("%s", buf);
3087 + } else {
3088 + if (begin) {
3089 + if (adapter != NULL && adapter->adapter_initd)
3090 +@@ -3613,7 +3613,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
3091 + else
3092 + printk("%s%s", blogic_msglevelmap[msglevel], buf);
3093 + } else
3094 +- printk("%s", buf);
3095 ++ pr_cont("%s", buf);
3096 + }
3097 + begin = (buf[len - 1] == '\n');
3098 + }
3099 +diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
3100 +index 06958a192a5bd..09f57ef35990c 100644
3101 +--- a/drivers/scsi/qedi/qedi_main.c
3102 ++++ b/drivers/scsi/qedi/qedi_main.c
3103 +@@ -1302,7 +1302,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
3104 + {
3105 + u32 *list;
3106 + int i;
3107 +- int status = 0, rc;
3108 ++ int status;
3109 + u32 *pbl;
3110 + dma_addr_t page;
3111 + int num_pages;
3112 +@@ -1313,14 +1313,14 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
3113 + */
3114 + if (!qedi->num_queues) {
3115 + QEDI_ERR(&qedi->dbg_ctx, "No MSI-X vectors available!\n");
3116 +- return 1;
3117 ++ return -ENOMEM;
3118 + }
3119 +
3120 + /* Make sure we allocated the PBL that will contain the physical
3121 + * addresses of our queues
3122 + */
3123 + if (!qedi->p_cpuq) {
3124 +- status = 1;
3125 ++ status = -EINVAL;
3126 + goto mem_alloc_failure;
3127 + }
3128 +
3129 +@@ -1335,13 +1335,13 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
3130 + "qedi->global_queues=%p.\n", qedi->global_queues);
3131 +
3132 + /* Allocate DMA coherent buffers for BDQ */
3133 +- rc = qedi_alloc_bdq(qedi);
3134 +- if (rc)
3135 ++ status = qedi_alloc_bdq(qedi);
3136 ++ if (status)
3137 + goto mem_alloc_failure;
3138 +
3139 + /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */
3140 +- rc = qedi_alloc_nvm_iscsi_cfg(qedi);
3141 +- if (rc)
3142 ++ status = qedi_alloc_nvm_iscsi_cfg(qedi);
3143 ++ if (status)
3144 + goto mem_alloc_failure;
3145 +
3146 + /* Allocate a CQ and an associated PBL for each MSI-X
3147 +diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3148 +index 6b33a1f24f561..c756298c05624 100644
3149 +--- a/drivers/scsi/qla2xxx/qla_nvme.c
3150 ++++ b/drivers/scsi/qla2xxx/qla_nvme.c
3151 +@@ -88,8 +88,9 @@ static int qla_nvme_alloc_queue(struct nvme_fc_local_port *lport,
3152 + struct qla_hw_data *ha;
3153 + struct qla_qpair *qpair;
3154 +
3155 +- if (!qidx)
3156 +- qidx++;
3157 ++ /* Map admin queue and 1st IO queue to index 0 */
3158 ++ if (qidx)
3159 ++ qidx--;
3160 +
3161 + vha = (struct scsi_qla_host *)lport->private;
3162 + ha = vha->hw;
3163 +diff --git a/drivers/soc/qcom/smsm.c b/drivers/soc/qcom/smsm.c
3164 +index 50214b620865e..2b49d2c212dab 100644
3165 +--- a/drivers/soc/qcom/smsm.c
3166 ++++ b/drivers/soc/qcom/smsm.c
3167 +@@ -117,7 +117,7 @@ struct smsm_entry {
3168 + DECLARE_BITMAP(irq_enabled, 32);
3169 + DECLARE_BITMAP(irq_rising, 32);
3170 + DECLARE_BITMAP(irq_falling, 32);
3171 +- u32 last_value;
3172 ++ unsigned long last_value;
3173 +
3174 + u32 *remote_state;
3175 + u32 *subscription;
3176 +@@ -212,8 +212,7 @@ static irqreturn_t smsm_intr(int irq, void *data)
3177 + u32 val;
3178 +
3179 + val = readl(entry->remote_state);
3180 +- changed = val ^ entry->last_value;
3181 +- entry->last_value = val;
3182 ++ changed = val ^ xchg(&entry->last_value, val);
3183 +
3184 + for_each_set_bit(i, entry->irq_enabled, 32) {
3185 + if (!(changed & BIT(i)))
3186 +@@ -274,6 +273,12 @@ static void smsm_unmask_irq(struct irq_data *irqd)
3187 + struct qcom_smsm *smsm = entry->smsm;
3188 + u32 val;
3189 +
3190 ++ /* Make sure our last cached state is up-to-date */
3191 ++ if (readl(entry->remote_state) & BIT(irq))
3192 ++ set_bit(irq, &entry->last_value);
3193 ++ else
3194 ++ clear_bit(irq, &entry->last_value);
3195 ++
3196 + set_bit(irq, entry->irq_enabled);
3197 +
3198 + if (entry->subscription) {
3199 +diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
3200 +index 20da55d9cbb1e..d483b0e29b81f 100644
3201 +--- a/drivers/soc/rockchip/Kconfig
3202 ++++ b/drivers/soc/rockchip/Kconfig
3203 +@@ -5,8 +5,8 @@ if ARCH_ROCKCHIP || COMPILE_TEST
3204 + #
3205 +
3206 + config ROCKCHIP_GRF
3207 +- bool
3208 +- default y
3209 ++ bool "Rockchip General Register Files support" if COMPILE_TEST
3210 ++ default y if ARCH_ROCKCHIP
3211 + help
3212 + The General Register Files are a central component providing
3213 + special additional settings registers for a lot of soc-components.
3214 +diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
3215 +index ed114f00a6d11..59f18e344bfb9 100644
3216 +--- a/drivers/spi/spi-fsl-dspi.c
3217 ++++ b/drivers/spi/spi-fsl-dspi.c
3218 +@@ -394,6 +394,7 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
3219 + goto err_rx_dma_buf;
3220 + }
3221 +
3222 ++ memset(&cfg, 0, sizeof(cfg));
3223 + cfg.src_addr = phy_addr + SPI_POPR;
3224 + cfg.dst_addr = phy_addr + SPI_PUSHR;
3225 + cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
3226 +diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c
3227 +index 661a40c653e90..d8cdb13ce3e4a 100644
3228 +--- a/drivers/spi/spi-pic32.c
3229 ++++ b/drivers/spi/spi-pic32.c
3230 +@@ -369,6 +369,7 @@ static int pic32_spi_dma_config(struct pic32_spi *pic32s, u32 dma_width)
3231 + struct dma_slave_config cfg;
3232 + int ret;
3233 +
3234 ++ memset(&cfg, 0, sizeof(cfg));
3235 + cfg.device_fc = true;
3236 + cfg.src_addr = pic32s->dma_base + buf_offset;
3237 + cfg.dst_addr = pic32s->dma_base + buf_offset;
3238 +diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
3239 +index 86dc411016105..1e2b33912a8a4 100644
3240 +--- a/drivers/staging/board/board.c
3241 ++++ b/drivers/staging/board/board.c
3242 +@@ -139,6 +139,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
3243 + static int board_staging_add_dev_domain(struct platform_device *pdev,
3244 + const char *domain)
3245 + {
3246 ++ struct device *dev = &pdev->dev;
3247 + struct of_phandle_args pd_args;
3248 + struct device_node *np;
3249 +
3250 +@@ -151,7 +152,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev,
3251 + pd_args.np = np;
3252 + pd_args.args_count = 0;
3253 +
3254 +- return of_genpd_add_device(&pd_args, &pdev->dev);
3255 ++ /* Initialization similar to device_pm_init_common() */
3256 ++ spin_lock_init(&dev->power.lock);
3257 ++ dev->power.early_init = true;
3258 ++
3259 ++ return of_genpd_add_device(&pd_args, dev);
3260 + }
3261 + #else
3262 + static inline int board_staging_add_dev_domain(struct platform_device *pdev,
3263 +diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
3264 +index 8cfdff198334b..84a5b6ebfd074 100644
3265 +--- a/drivers/staging/ks7010/ks7010_sdio.c
3266 ++++ b/drivers/staging/ks7010/ks7010_sdio.c
3267 +@@ -904,9 +904,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,
3268 + memset(&priv->wstats, 0, sizeof(priv->wstats));
3269 +
3270 + /* sleep mode */
3271 ++ atomic_set(&priv->sleepstatus.status, 0);
3272 + atomic_set(&priv->sleepstatus.doze_request, 0);
3273 + atomic_set(&priv->sleepstatus.wakeup_request, 0);
3274 +- atomic_set(&priv->sleepstatus.wakeup_request, 0);
3275 +
3276 + trx_device_init(priv);
3277 + hostif_init(priv);
3278 +diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c
3279 +index a401b13f5f5e4..c46ac0e5e852e 100644
3280 +--- a/drivers/staging/rts5208/rtsx_scsi.c
3281 ++++ b/drivers/staging/rts5208/rtsx_scsi.c
3282 +@@ -3026,10 +3026,10 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
3283 + }
3284 +
3285 + if (dev_info_id == 0x15) {
3286 +- buf_len = 0x3A;
3287 ++ buf_len = 0x3C;
3288 + data_len = 0x3A;
3289 + } else {
3290 +- buf_len = 0x6A;
3291 ++ buf_len = 0x6C;
3292 + data_len = 0x6A;
3293 + }
3294 +
3295 +@@ -3081,11 +3081,7 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
3296 + }
3297 +
3298 + rtsx_stor_set_xfer_buf(buf, buf_len, srb);
3299 +-
3300 +- if (dev_info_id == 0x15)
3301 +- scsi_set_resid(srb, scsi_bufflen(srb) - 0x3C);
3302 +- else
3303 +- scsi_set_resid(srb, scsi_bufflen(srb) - 0x6C);
3304 ++ scsi_set_resid(srb, scsi_bufflen(srb) - buf_len);
3305 +
3306 + kfree(buf);
3307 + return STATUS_SUCCESS;
3308 +diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
3309 +index 2e578d6433af9..7d7fdfc578a93 100644
3310 +--- a/drivers/tty/hvc/hvsi.c
3311 ++++ b/drivers/tty/hvc/hvsi.c
3312 +@@ -1051,7 +1051,7 @@ static const struct tty_operations hvsi_ops = {
3313 +
3314 + static int __init hvsi_init(void)
3315 + {
3316 +- int i;
3317 ++ int i, ret;
3318 +
3319 + hvsi_driver = alloc_tty_driver(hvsi_count);
3320 + if (!hvsi_driver)
3321 +@@ -1082,12 +1082,25 @@ static int __init hvsi_init(void)
3322 + }
3323 + hvsi_wait = wait_for_state; /* irqs active now */
3324 +
3325 +- if (tty_register_driver(hvsi_driver))
3326 +- panic("Couldn't register hvsi console driver\n");
3327 ++ ret = tty_register_driver(hvsi_driver);
3328 ++ if (ret) {
3329 ++ pr_err("Couldn't register hvsi console driver\n");
3330 ++ goto err_free_irq;
3331 ++ }
3332 +
3333 + printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
3334 +
3335 + return 0;
3336 ++err_free_irq:
3337 ++ hvsi_wait = poll_for_state;
3338 ++ for (i = 0; i < hvsi_count; i++) {
3339 ++ struct hvsi_struct *hp = &hvsi_ports[i];
3340 ++
3341 ++ free_irq(hp->virq, hp);
3342 ++ }
3343 ++ tty_driver_kref_put(hvsi_driver);
3344 ++
3345 ++ return ret;
3346 + }
3347 + device_initcall(hvsi_init);
3348 +
3349 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
3350 +index 071ee37399b7d..72015cc7b33f0 100644
3351 +--- a/drivers/tty/serial/8250/8250_pci.c
3352 ++++ b/drivers/tty/serial/8250/8250_pci.c
3353 +@@ -73,7 +73,7 @@ static void moan_device(const char *str, struct pci_dev *dev)
3354 +
3355 + static int
3356 + setup_port(struct serial_private *priv, struct uart_8250_port *port,
3357 +- int bar, int offset, int regshift)
3358 ++ u8 bar, unsigned int offset, int regshift)
3359 + {
3360 + struct pci_dev *dev = priv->dev;
3361 +
3362 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
3363 +index 20f58e9da2fb0..7ac6bb38948f0 100644
3364 +--- a/drivers/tty/serial/8250/8250_port.c
3365 ++++ b/drivers/tty/serial/8250/8250_port.c
3366 +@@ -136,7 +136,8 @@ static const struct serial8250_config uart_config[] = {
3367 + .name = "16C950/954",
3368 + .fifo_size = 128,
3369 + .tx_loadsz = 128,
3370 +- .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
3371 ++ .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01,
3372 ++ .rxtrig_bytes = {16, 32, 112, 120},
3373 + /* UART_CAP_EFR breaks billionon CF bluetooth card. */
3374 + .flags = UART_CAP_FIFO | UART_CAP_SLEEP,
3375 + },
3376 +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
3377 +index 3d5fe53988e51..62d1e46079120 100644
3378 +--- a/drivers/tty/serial/fsl_lpuart.c
3379 ++++ b/drivers/tty/serial/fsl_lpuart.c
3380 +@@ -2170,7 +2170,7 @@ static int lpuart_probe(struct platform_device *pdev)
3381 + return PTR_ERR(sport->port.membase);
3382 +
3383 + sport->port.membase += sdata->reg_off;
3384 +- sport->port.mapbase = res->start;
3385 ++ sport->port.mapbase = res->start + sdata->reg_off;
3386 + sport->port.dev = &pdev->dev;
3387 + sport->port.type = PORT_LPUART;
3388 + ret = platform_get_irq(pdev, 0);
3389 +diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
3390 +index c6fdd6369534c..96e01bf4599c9 100644
3391 +--- a/drivers/tty/serial/jsm/jsm_neo.c
3392 ++++ b/drivers/tty/serial/jsm/jsm_neo.c
3393 +@@ -827,7 +827,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
3394 + /* Parse any modem signal changes */
3395 + jsm_dbg(INTR, &ch->ch_bd->pci_dev,
3396 + "MOD_STAT: sending to parse_modem_sigs\n");
3397 ++ spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
3398 + neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
3399 ++ spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
3400 + }
3401 + }
3402 +
3403 +diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
3404 +index ec7d8383900fc..7c790ff6b5116 100644
3405 +--- a/drivers/tty/serial/jsm/jsm_tty.c
3406 ++++ b/drivers/tty/serial/jsm/jsm_tty.c
3407 +@@ -195,6 +195,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
3408 +
3409 + static int jsm_tty_open(struct uart_port *port)
3410 + {
3411 ++ unsigned long lock_flags;
3412 + struct jsm_board *brd;
3413 + struct jsm_channel *channel =
3414 + container_of(port, struct jsm_channel, uart_port);
3415 +@@ -248,6 +249,7 @@ static int jsm_tty_open(struct uart_port *port)
3416 + channel->ch_cached_lsr = 0;
3417 + channel->ch_stops_sent = 0;
3418 +
3419 ++ spin_lock_irqsave(&port->lock, lock_flags);
3420 + termios = &port->state->port.tty->termios;
3421 + channel->ch_c_cflag = termios->c_cflag;
3422 + channel->ch_c_iflag = termios->c_iflag;
3423 +@@ -267,6 +269,7 @@ static int jsm_tty_open(struct uart_port *port)
3424 + jsm_carrier(channel);
3425 +
3426 + channel->ch_open_count++;
3427 ++ spin_unlock_irqrestore(&port->lock, lock_flags);
3428 +
3429 + jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
3430 + return 0;
3431 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
3432 +index ae3af8debf673..463f35273365b 100644
3433 +--- a/drivers/tty/tty_io.c
3434 ++++ b/drivers/tty/tty_io.c
3435 +@@ -2165,8 +2165,6 @@ static int tty_fasync(int fd, struct file *filp, int on)
3436 + * Locking:
3437 + * Called functions take tty_ldiscs_lock
3438 + * current->signal->tty check is safe without locks
3439 +- *
3440 +- * FIXME: may race normal receive processing
3441 + */
3442 +
3443 + static int tiocsti(struct tty_struct *tty, char __user *p)
3444 +@@ -2182,8 +2180,10 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
3445 + ld = tty_ldisc_ref_wait(tty);
3446 + if (!ld)
3447 + return -EIO;
3448 ++ tty_buffer_lock_exclusive(tty->port);
3449 + if (ld->ops->receive_buf)
3450 + ld->ops->receive_buf(tty, &ch, &mbz, 1);
3451 ++ tty_buffer_unlock_exclusive(tty->port);
3452 + tty_ldisc_deref(ld);
3453 + return 0;
3454 + }
3455 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
3456 +index 6696fdd97530f..49806837b98bd 100644
3457 +--- a/drivers/usb/gadget/composite.c
3458 ++++ b/drivers/usb/gadget/composite.c
3459 +@@ -484,7 +484,7 @@ static u8 encode_bMaxPower(enum usb_device_speed speed,
3460 + {
3461 + unsigned val;
3462 +
3463 +- if (c->MaxPower)
3464 ++ if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
3465 + val = c->MaxPower;
3466 + else
3467 + val = CONFIG_USB_GADGET_VBUS_DRAW;
3468 +@@ -894,7 +894,11 @@ static int set_config(struct usb_composite_dev *cdev,
3469 + }
3470 +
3471 + /* when we return, be sure our power usage is valid */
3472 +- power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
3473 ++ if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
3474 ++ power = c->MaxPower;
3475 ++ else
3476 ++ power = CONFIG_USB_GADGET_VBUS_DRAW;
3477 ++
3478 + if (gadget->speed < USB_SPEED_SUPER)
3479 + power = min(power, 500U);
3480 + else
3481 +diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
3482 +index 989682cc86868..38a35f57b22c0 100644
3483 +--- a/drivers/usb/gadget/function/u_ether.c
3484 ++++ b/drivers/usb/gadget/function/u_ether.c
3485 +@@ -495,8 +495,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
3486 + }
3487 + spin_unlock_irqrestore(&dev->lock, flags);
3488 +
3489 +- if (skb && !in) {
3490 +- dev_kfree_skb_any(skb);
3491 ++ if (!in) {
3492 ++ if (skb)
3493 ++ dev_kfree_skb_any(skb);
3494 + return NETDEV_TX_OK;
3495 + }
3496 +
3497 +diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
3498 +index 8bc78418d40e4..cd92cda03d710 100644
3499 +--- a/drivers/usb/gadget/udc/at91_udc.c
3500 ++++ b/drivers/usb/gadget/udc/at91_udc.c
3501 +@@ -1895,7 +1895,9 @@ static int at91udc_probe(struct platform_device *pdev)
3502 + clk_disable(udc->iclk);
3503 +
3504 + /* request UDC and maybe VBUS irqs */
3505 +- udc->udp_irq = platform_get_irq(pdev, 0);
3506 ++ udc->udp_irq = retval = platform_get_irq(pdev, 0);
3507 ++ if (retval < 0)
3508 ++ goto err_unprepare_iclk;
3509 + retval = devm_request_irq(dev, udc->udp_irq, at91_udc_irq, 0,
3510 + driver_name, udc);
3511 + if (retval) {
3512 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
3513 +index 58ba04d858bab..23a27eb33c42d 100644
3514 +--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
3515 ++++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
3516 +@@ -573,7 +573,8 @@ static int bdc_probe(struct platform_device *pdev)
3517 + if (ret) {
3518 + dev_err(dev,
3519 + "No suitable DMA config available, abort\n");
3520 +- return -ENOTSUPP;
3521 ++ ret = -ENOTSUPP;
3522 ++ goto phycleanup;
3523 + }
3524 + dev_dbg(dev, "Using 32-bit address\n");
3525 + }
3526 +diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
3527 +index 772049afe1666..83c6c776a371c 100644
3528 +--- a/drivers/usb/gadget/udc/mv_u3d_core.c
3529 ++++ b/drivers/usb/gadget/udc/mv_u3d_core.c
3530 +@@ -1925,14 +1925,6 @@ static int mv_u3d_probe(struct platform_device *dev)
3531 + goto err_get_irq;
3532 + }
3533 + u3d->irq = r->start;
3534 +- if (request_irq(u3d->irq, mv_u3d_irq,
3535 +- IRQF_SHARED, driver_name, u3d)) {
3536 +- u3d->irq = 0;
3537 +- dev_err(&dev->dev, "Request irq %d for u3d failed\n",
3538 +- u3d->irq);
3539 +- retval = -ENODEV;
3540 +- goto err_request_irq;
3541 +- }
3542 +
3543 + /* initialize gadget structure */
3544 + u3d->gadget.ops = &mv_u3d_ops; /* usb_gadget_ops */
3545 +@@ -1945,6 +1937,15 @@ static int mv_u3d_probe(struct platform_device *dev)
3546 +
3547 + mv_u3d_eps_init(u3d);
3548 +
3549 ++ if (request_irq(u3d->irq, mv_u3d_irq,
3550 ++ IRQF_SHARED, driver_name, u3d)) {
3551 ++ u3d->irq = 0;
3552 ++ dev_err(&dev->dev, "Request irq %d for u3d failed\n",
3553 ++ u3d->irq);
3554 ++ retval = -ENODEV;
3555 ++ goto err_request_irq;
3556 ++ }
3557 ++
3558 + /* external vbus detection */
3559 + if (u3d->vbus) {
3560 + u3d->clock_gating = 1;
3561 +@@ -1968,8 +1969,8 @@ static int mv_u3d_probe(struct platform_device *dev)
3562 +
3563 + err_unregister:
3564 + free_irq(u3d->irq, u3d);
3565 +-err_request_irq:
3566 + err_get_irq:
3567 ++err_request_irq:
3568 + kfree(u3d->status_req);
3569 + err_alloc_status_req:
3570 + kfree(u3d->eps);
3571 +diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
3572 +index 1aec87ec68df6..753c73624fb68 100644
3573 +--- a/drivers/usb/host/ehci-orion.c
3574 ++++ b/drivers/usb/host/ehci-orion.c
3575 +@@ -253,8 +253,11 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
3576 + * the clock does not exists.
3577 + */
3578 + priv->clk = devm_clk_get(&pdev->dev, NULL);
3579 +- if (!IS_ERR(priv->clk))
3580 +- clk_prepare_enable(priv->clk);
3581 ++ if (!IS_ERR(priv->clk)) {
3582 ++ err = clk_prepare_enable(priv->clk);
3583 ++ if (err)
3584 ++ goto err_put_hcd;
3585 ++ }
3586 +
3587 + priv->phy = devm_phy_optional_get(&pdev->dev, "usb");
3588 + if (IS_ERR(priv->phy)) {
3589 +@@ -315,6 +318,7 @@ err_phy_init:
3590 + err_phy_get:
3591 + if (!IS_ERR(priv->clk))
3592 + clk_disable_unprepare(priv->clk);
3593 ++err_put_hcd:
3594 + usb_put_hcd(hcd);
3595 + err:
3596 + dev_err(&pdev->dev, "init %s fail, %d\n",
3597 +diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
3598 +index bbe1ea00d8879..3008d692000ae 100644
3599 +--- a/drivers/usb/host/fotg210-hcd.c
3600 ++++ b/drivers/usb/host/fotg210-hcd.c
3601 +@@ -2536,11 +2536,6 @@ retry_xacterr:
3602 + return count;
3603 + }
3604 +
3605 +-/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
3606 +-#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
3607 +-/* ... and packet size, for any kind of endpoint descriptor */
3608 +-#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
3609 +-
3610 + /* reverse of qh_urb_transaction: free a list of TDs.
3611 + * used for cleanup after errors, before HC sees an URB's TDs.
3612 + */
3613 +@@ -2626,7 +2621,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
3614 + token |= (1 /* "in" */ << 8);
3615 + /* else it's already initted to "out" pid (0 << 8) */
3616 +
3617 +- maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
3618 ++ maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input);
3619 +
3620 + /*
3621 + * buffer gets wrapped in one or more qtds;
3622 +@@ -2740,9 +2735,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
3623 + gfp_t flags)
3624 + {
3625 + struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
3626 ++ struct usb_host_endpoint *ep;
3627 + u32 info1 = 0, info2 = 0;
3628 + int is_input, type;
3629 + int maxp = 0;
3630 ++ int mult;
3631 + struct usb_tt *tt = urb->dev->tt;
3632 + struct fotg210_qh_hw *hw;
3633 +
3634 +@@ -2757,14 +2754,15 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
3635 +
3636 + is_input = usb_pipein(urb->pipe);
3637 + type = usb_pipetype(urb->pipe);
3638 +- maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input);
3639 ++ ep = usb_pipe_endpoint(urb->dev, urb->pipe);
3640 ++ maxp = usb_endpoint_maxp(&ep->desc);
3641 ++ mult = usb_endpoint_maxp_mult(&ep->desc);
3642 +
3643 + /* 1024 byte maxpacket is a hardware ceiling. High bandwidth
3644 + * acts like up to 3KB, but is built from smaller packets.
3645 + */
3646 +- if (max_packet(maxp) > 1024) {
3647 +- fotg210_dbg(fotg210, "bogus qh maxpacket %d\n",
3648 +- max_packet(maxp));
3649 ++ if (maxp > 1024) {
3650 ++ fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
3651 + goto done;
3652 + }
3653 +
3654 +@@ -2778,8 +2776,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
3655 + */
3656 + if (type == PIPE_INTERRUPT) {
3657 + qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
3658 +- is_input, 0,
3659 +- hb_mult(maxp) * max_packet(maxp)));
3660 ++ is_input, 0, mult * maxp));
3661 + qh->start = NO_FRAME;
3662 +
3663 + if (urb->dev->speed == USB_SPEED_HIGH) {
3664 +@@ -2816,7 +2813,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
3665 + think_time = tt ? tt->think_time : 0;
3666 + qh->tt_usecs = NS_TO_US(think_time +
3667 + usb_calc_bus_time(urb->dev->speed,
3668 +- is_input, 0, max_packet(maxp)));
3669 ++ is_input, 0, maxp));
3670 + qh->period = urb->interval;
3671 + if (qh->period > fotg210->periodic_size) {
3672 + qh->period = fotg210->periodic_size;
3673 +@@ -2879,11 +2876,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
3674 + * to help them do so. So now people expect to use
3675 + * such nonconformant devices with Linux too; sigh.
3676 + */
3677 +- info1 |= max_packet(maxp) << 16;
3678 ++ info1 |= maxp << 16;
3679 + info2 |= (FOTG210_TUNE_MULT_HS << 30);
3680 + } else { /* PIPE_INTERRUPT */
3681 +- info1 |= max_packet(maxp) << 16;
3682 +- info2 |= hb_mult(maxp) << 30;
3683 ++ info1 |= maxp << 16;
3684 ++ info2 |= mult << 30;
3685 + }
3686 + break;
3687 + default:
3688 +@@ -3953,6 +3950,7 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
3689 + int is_input;
3690 + long bandwidth;
3691 + unsigned multi;
3692 ++ struct usb_host_endpoint *ep;
3693 +
3694 + /*
3695 + * this might be a "high bandwidth" highspeed endpoint,
3696 +@@ -3960,14 +3958,14 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
3697 + */
3698 + epnum = usb_pipeendpoint(pipe);
3699 + is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
3700 +- maxp = usb_maxpacket(dev, pipe, !is_input);
3701 ++ ep = usb_pipe_endpoint(dev, pipe);
3702 ++ maxp = usb_endpoint_maxp(&ep->desc);
3703 + if (is_input)
3704 + buf1 = (1 << 11);
3705 + else
3706 + buf1 = 0;
3707 +
3708 +- maxp = max_packet(maxp);
3709 +- multi = hb_mult(maxp);
3710 ++ multi = usb_endpoint_maxp_mult(&ep->desc);
3711 + buf1 |= maxp;
3712 + maxp *= multi;
3713 +
3714 +@@ -4489,13 +4487,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
3715 +
3716 + /* HC need not update length with this error */
3717 + if (!(t & FOTG210_ISOC_BABBLE)) {
3718 +- desc->actual_length =
3719 +- fotg210_itdlen(urb, desc, t);
3720 ++ desc->actual_length = FOTG210_ITD_LENGTH(t);
3721 + urb->actual_length += desc->actual_length;
3722 + }
3723 + } else if (likely((t & FOTG210_ISOC_ACTIVE) == 0)) {
3724 + desc->status = 0;
3725 +- desc->actual_length = fotg210_itdlen(urb, desc, t);
3726 ++ desc->actual_length = FOTG210_ITD_LENGTH(t);
3727 + urb->actual_length += desc->actual_length;
3728 + } else {
3729 + /* URB was too late */
3730 +diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
3731 +index 7fcd785c7bc85..0f1da9503bc67 100644
3732 +--- a/drivers/usb/host/fotg210.h
3733 ++++ b/drivers/usb/host/fotg210.h
3734 +@@ -683,11 +683,6 @@ static inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210)
3735 + return fotg210_readl(fotg210, &fotg210->regs->frame_index);
3736 + }
3737 +
3738 +-#define fotg210_itdlen(urb, desc, t) ({ \
3739 +- usb_pipein((urb)->pipe) ? \
3740 +- (desc)->length - FOTG210_ITD_LENGTH(t) : \
3741 +- FOTG210_ITD_LENGTH(t); \
3742 +-})
3743 + /*-------------------------------------------------------------------------*/
3744 +
3745 + #endif /* __LINUX_FOTG210_H */
3746 +diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
3747 +index 16d081a093bb0..0cf4b6dc89720 100644
3748 +--- a/drivers/usb/host/ohci-tmio.c
3749 ++++ b/drivers/usb/host/ohci-tmio.c
3750 +@@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
3751 + if (!cell)
3752 + return -EINVAL;
3753 +
3754 ++ if (irq < 0)
3755 ++ return irq;
3756 ++
3757 + hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
3758 + if (!hcd) {
3759 + ret = -ENOMEM;
3760 +diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
3761 +index 08eea4c402eeb..9b6de7f083c0b 100644
3762 +--- a/drivers/usb/host/xhci-rcar.c
3763 ++++ b/drivers/usb/host/xhci-rcar.c
3764 +@@ -152,6 +152,13 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd)
3765 + const struct soc_device_attribute *attr;
3766 + const char *firmware_name;
3767 +
3768 ++ /*
3769 ++ * According to the datasheet, "Upon the completion of FW Download,
3770 ++ * there is no need to write or reload FW".
3771 ++ */
3772 ++ if (readl(regs + RCAR_USB3_DL_CTRL) & RCAR_USB3_DL_CTRL_FW_SUCCESS)
3773 ++ return 0;
3774 ++
3775 + attr = soc_device_match(rcar_quirks_match);
3776 + if (attr)
3777 + quirks = (uintptr_t)attr->data;
3778 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
3779 +index 3cab64f2e8615..e4a82da434c25 100644
3780 +--- a/drivers/usb/host/xhci.c
3781 ++++ b/drivers/usb/host/xhci.c
3782 +@@ -4400,19 +4400,19 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci,
3783 + {
3784 + unsigned long long timeout_ns;
3785 +
3786 +- if (xhci->quirks & XHCI_INTEL_HOST)
3787 +- timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
3788 +- else
3789 +- timeout_ns = udev->u1_params.sel;
3790 +-
3791 + /* Prevent U1 if service interval is shorter than U1 exit latency */
3792 + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
3793 +- if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
3794 ++ if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
3795 + dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
3796 + return USB3_LPM_DISABLED;
3797 + }
3798 + }
3799 +
3800 ++ if (xhci->quirks & XHCI_INTEL_HOST)
3801 ++ timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
3802 ++ else
3803 ++ timeout_ns = udev->u1_params.sel;
3804 ++
3805 + /* The U1 timeout is encoded in 1us intervals.
3806 + * Don't return a timeout of zero, because that's USB3_LPM_DISABLED.
3807 + */
3808 +@@ -4464,19 +4464,19 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci,
3809 + {
3810 + unsigned long long timeout_ns;
3811 +
3812 +- if (xhci->quirks & XHCI_INTEL_HOST)
3813 +- timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
3814 +- else
3815 +- timeout_ns = udev->u2_params.sel;
3816 +-
3817 + /* Prevent U2 if service interval is shorter than U2 exit latency */
3818 + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
3819 +- if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
3820 ++ if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
3821 + dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
3822 + return USB3_LPM_DISABLED;
3823 + }
3824 + }
3825 +
3826 ++ if (xhci->quirks & XHCI_INTEL_HOST)
3827 ++ timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
3828 ++ else
3829 ++ timeout_ns = udev->u2_params.sel;
3830 ++
3831 + /* The U2 timeout is encoded in 256us intervals */
3832 + timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000);
3833 + /* If the necessary timeout value is bigger than what we can set in the
3834 +diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
3835 +index b7d460adaa613..a582c3847dc2d 100644
3836 +--- a/drivers/usb/musb/musb_dsps.c
3837 ++++ b/drivers/usb/musb/musb_dsps.c
3838 +@@ -930,23 +930,22 @@ static int dsps_probe(struct platform_device *pdev)
3839 + if (!glue->usbss_base)
3840 + return -ENXIO;
3841 +
3842 +- if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
3843 +- ret = dsps_setup_optional_vbus_irq(pdev, glue);
3844 +- if (ret)
3845 +- goto err_iounmap;
3846 +- }
3847 +-
3848 + platform_set_drvdata(pdev, glue);
3849 + pm_runtime_enable(&pdev->dev);
3850 + ret = dsps_create_musb_pdev(glue, pdev);
3851 + if (ret)
3852 + goto err;
3853 +
3854 ++ if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
3855 ++ ret = dsps_setup_optional_vbus_irq(pdev, glue);
3856 ++ if (ret)
3857 ++ goto err;
3858 ++ }
3859 ++
3860 + return 0;
3861 +
3862 + err:
3863 + pm_runtime_disable(&pdev->dev);
3864 +-err_iounmap:
3865 + iounmap(glue->usbss_base);
3866 + return ret;
3867 + }
3868 +diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
3869 +index 9b4354a00ca71..968900c364510 100644
3870 +--- a/drivers/usb/phy/phy-fsl-usb.c
3871 ++++ b/drivers/usb/phy/phy-fsl-usb.c
3872 +@@ -886,6 +886,8 @@ int usb_otg_start(struct platform_device *pdev)
3873 +
3874 + /* request irq */
3875 + p_otg->irq = platform_get_irq(pdev, 0);
3876 ++ if (p_otg->irq < 0)
3877 ++ return p_otg->irq;
3878 + status = request_irq(p_otg->irq, fsl_otg_isr,
3879 + IRQF_SHARED, driver_name, p_otg);
3880 + if (status) {
3881 +diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
3882 +index 1ec00eae339a2..e4fc73bf6ee9b 100644
3883 +--- a/drivers/usb/phy/phy-tahvo.c
3884 ++++ b/drivers/usb/phy/phy-tahvo.c
3885 +@@ -404,7 +404,9 @@ static int tahvo_usb_probe(struct platform_device *pdev)
3886 +
3887 + dev_set_drvdata(&pdev->dev, tu);
3888 +
3889 +- tu->irq = platform_get_irq(pdev, 0);
3890 ++ tu->irq = ret = platform_get_irq(pdev, 0);
3891 ++ if (ret < 0)
3892 ++ return ret;
3893 + ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
3894 + IRQF_ONESHOT,
3895 + "tahvo-vbus", tu);
3896 +diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
3897 +index 8e14fa2211912..4884c4238b7b0 100644
3898 +--- a/drivers/usb/phy/phy-twl6030-usb.c
3899 ++++ b/drivers/usb/phy/phy-twl6030-usb.c
3900 +@@ -355,6 +355,11 @@ static int twl6030_usb_probe(struct platform_device *pdev)
3901 + twl->irq2 = platform_get_irq(pdev, 1);
3902 + twl->linkstat = MUSB_UNKNOWN;
3903 +
3904 ++ if (twl->irq1 < 0)
3905 ++ return twl->irq1;
3906 ++ if (twl->irq2 < 0)
3907 ++ return twl->irq2;
3908 ++
3909 + twl->comparator.set_vbus = twl6030_set_vbus;
3910 + twl->comparator.start_srp = twl6030_start_srp;
3911 +
3912 +diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
3913 +index b36de65a0e12b..1d3a945907125 100644
3914 +--- a/drivers/usb/serial/mos7720.c
3915 ++++ b/drivers/usb/serial/mos7720.c
3916 +@@ -229,8 +229,10 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
3917 + int status;
3918 +
3919 + buf = kmalloc(1, GFP_KERNEL);
3920 +- if (!buf)
3921 ++ if (!buf) {
3922 ++ *data = 0;
3923 + return -ENOMEM;
3924 ++ }
3925 +
3926 + status = usb_control_msg(usbdev, pipe, request, requesttype, value,
3927 + index, buf, 1, MOS_WDR_TIMEOUT);
3928 +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
3929 +index 9833f307d70e4..22e8cda7a137d 100644
3930 +--- a/drivers/usb/usbip/vhci_hcd.c
3931 ++++ b/drivers/usb/usbip/vhci_hcd.c
3932 +@@ -469,8 +469,14 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
3933 + vhci_hcd->port_status[rhport] &= ~(1 << USB_PORT_FEAT_RESET);
3934 + vhci_hcd->re_timeout = 0;
3935 +
3936 ++ /*
3937 ++ * A few drivers do usb reset during probe when
3938 ++ * the device could be in VDEV_ST_USED state
3939 ++ */
3940 + if (vhci_hcd->vdev[rhport].ud.status ==
3941 +- VDEV_ST_NOTASSIGNED) {
3942 ++ VDEV_ST_NOTASSIGNED ||
3943 ++ vhci_hcd->vdev[rhport].ud.status ==
3944 ++ VDEV_ST_USED) {
3945 + usbip_dbg_vhci_rh(
3946 + " enable rhport %d (status %u)\n",
3947 + rhport,
3948 +@@ -971,8 +977,32 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
3949 + spin_lock(&vdev->priv_lock);
3950 +
3951 + list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
3952 ++ struct urb *urb;
3953 ++
3954 ++ /* give back urb of unsent unlink request */
3955 + pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
3956 ++
3957 ++ urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
3958 ++ if (!urb) {
3959 ++ list_del(&unlink->list);
3960 ++ kfree(unlink);
3961 ++ continue;
3962 ++ }
3963 ++
3964 ++ urb->status = -ENODEV;
3965 ++
3966 ++ usb_hcd_unlink_urb_from_ep(hcd, urb);
3967 ++
3968 + list_del(&unlink->list);
3969 ++
3970 ++ spin_unlock(&vdev->priv_lock);
3971 ++ spin_unlock_irqrestore(&vhci->lock, flags);
3972 ++
3973 ++ usb_hcd_giveback_urb(hcd, urb, urb->status);
3974 ++
3975 ++ spin_lock_irqsave(&vhci->lock, flags);
3976 ++ spin_lock(&vdev->priv_lock);
3977 ++
3978 + kfree(unlink);
3979 + }
3980 +
3981 +diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig
3982 +index c84333eb5eb59..b7765271d0fb6 100644
3983 +--- a/drivers/vfio/Kconfig
3984 ++++ b/drivers/vfio/Kconfig
3985 +@@ -29,7 +29,7 @@ menuconfig VFIO
3986 +
3987 + If you don't know what to do here, say N.
3988 +
3989 +-menuconfig VFIO_NOIOMMU
3990 ++config VFIO_NOIOMMU
3991 + bool "VFIO No-IOMMU support"
3992 + depends on VFIO
3993 + help
3994 +diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
3995 +index 2a0ce0c68302b..67497a46d0785 100644
3996 +--- a/drivers/video/backlight/pwm_bl.c
3997 ++++ b/drivers/video/backlight/pwm_bl.c
3998 +@@ -199,6 +199,33 @@ static int pwm_backlight_parse_dt(struct device *dev,
3999 + static int pwm_backlight_initial_power_state(const struct pwm_bl_data *pb)
4000 + {
4001 + struct device_node *node = pb->dev->of_node;
4002 ++ bool active = true;
4003 ++
4004 ++ /*
4005 ++ * If the enable GPIO is present, observable (either as input
4006 ++ * or output) and off then the backlight is not currently active.
4007 ++ * */
4008 ++ if (pb->enable_gpio && gpiod_get_value_cansleep(pb->enable_gpio) == 0)
4009 ++ active = false;
4010 ++
4011 ++ if (!regulator_is_enabled(pb->power_supply))
4012 ++ active = false;
4013 ++
4014 ++ if (!pwm_is_enabled(pb->pwm))
4015 ++ active = false;
4016 ++
4017 ++ /*
4018 ++ * Synchronize the enable_gpio with the observed state of the
4019 ++ * hardware.
4020 ++ */
4021 ++ if (pb->enable_gpio)
4022 ++ gpiod_direction_output(pb->enable_gpio, active);
4023 ++
4024 ++ /*
4025 ++ * Do not change pb->enabled here! pb->enabled essentially
4026 ++ * tells us if we own one of the regulator's use counts and
4027 ++ * right now we do not.
4028 ++ */
4029 +
4030 + /* Not booted with device tree or no phandle link to the node */
4031 + if (!node || !node->phandle)
4032 +@@ -210,20 +237,7 @@ static int pwm_backlight_initial_power_state(const struct pwm_bl_data *pb)
4033 + * assume that another driver will enable the backlight at the
4034 + * appropriate time. Therefore, if it is disabled, keep it so.
4035 + */
4036 +-
4037 +- /* if the enable GPIO is disabled, do not enable the backlight */
4038 +- if (pb->enable_gpio && gpiod_get_value_cansleep(pb->enable_gpio) == 0)
4039 +- return FB_BLANK_POWERDOWN;
4040 +-
4041 +- /* The regulator is disabled, do not enable the backlight */
4042 +- if (!regulator_is_enabled(pb->power_supply))
4043 +- return FB_BLANK_POWERDOWN;
4044 +-
4045 +- /* The PWM is disabled, keep it like this */
4046 +- if (!pwm_is_enabled(pb->pwm))
4047 +- return FB_BLANK_POWERDOWN;
4048 +-
4049 +- return FB_BLANK_UNBLANK;
4050 ++ return active ? FB_BLANK_UNBLANK: FB_BLANK_POWERDOWN;
4051 + }
4052 +
4053 + static int pwm_backlight_probe(struct platform_device *pdev)
4054 +@@ -300,18 +314,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
4055 + pb->enable_gpio = gpio_to_desc(data->enable_gpio);
4056 + }
4057 +
4058 +- /*
4059 +- * If the GPIO is not known to be already configured as output, that
4060 +- * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
4061 +- * direction to output and set the GPIO as active.
4062 +- * Do not force the GPIO to active when it was already output as it
4063 +- * could cause backlight flickering or we would enable the backlight too
4064 +- * early. Leave the decision of the initial backlight state for later.
4065 +- */
4066 +- if (pb->enable_gpio &&
4067 +- gpiod_get_direction(pb->enable_gpio) != 0)
4068 +- gpiod_direction_output(pb->enable_gpio, 1);
4069 +-
4070 + pb->power_supply = devm_regulator_get(&pdev->dev, "power");
4071 + if (IS_ERR(pb->power_supply)) {
4072 + ret = PTR_ERR(pb->power_supply);
4073 +diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c
4074 +index ea31054a28ca8..c1d6e63362259 100644
4075 +--- a/drivers/video/fbdev/asiliantfb.c
4076 ++++ b/drivers/video/fbdev/asiliantfb.c
4077 +@@ -227,6 +227,9 @@ static int asiliantfb_check_var(struct fb_var_screeninfo *var,
4078 + {
4079 + unsigned long Ftarget, ratio, remainder;
4080 +
4081 ++ if (!var->pixclock)
4082 ++ return -EINVAL;
4083 ++
4084 + ratio = 1000000 / var->pixclock;
4085 + remainder = 1000000 % var->pixclock;
4086 + Ftarget = 1000000 * ratio + (1000000 * remainder) / var->pixclock;
4087 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
4088 +index 4938ca1f4b637..9087d467cc465 100644
4089 +--- a/drivers/video/fbdev/core/fbmem.c
4090 ++++ b/drivers/video/fbdev/core/fbmem.c
4091 +@@ -34,6 +34,7 @@
4092 + #include <linux/fb.h>
4093 + #include <linux/fbcon.h>
4094 + #include <linux/mem_encrypt.h>
4095 ++#include <linux/overflow.h>
4096 +
4097 + #include <asm/fb.h>
4098 +
4099 +@@ -983,6 +984,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
4100 + if ((var->activate & FB_ACTIVATE_FORCE) ||
4101 + memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
4102 + u32 activate = var->activate;
4103 ++ u32 unused;
4104 +
4105 + /* When using FOURCC mode, make sure the red, green, blue and
4106 + * transp fields are set to 0.
4107 +@@ -1007,6 +1009,11 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
4108 + if (var->xres < 8 || var->yres < 8)
4109 + return -EINVAL;
4110 +
4111 ++ /* Too huge resolution causes multiplication overflow. */
4112 ++ if (check_mul_overflow(var->xres, var->yres, &unused) ||
4113 ++ check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))
4114 ++ return -EINVAL;
4115 ++
4116 + ret = info->fbops->fb_check_var(var, info);
4117 +
4118 + if (ret)
4119 +diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
4120 +index a7bd9f25911b5..74bf26b527b91 100644
4121 +--- a/drivers/video/fbdev/kyro/fbdev.c
4122 ++++ b/drivers/video/fbdev/kyro/fbdev.c
4123 +@@ -372,6 +372,11 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight
4124 + /* probably haven't called CreateOverlay yet */
4125 + return -EINVAL;
4126 +
4127 ++ if (ulWidth == 0 || ulWidth == 0xffffffff ||
4128 ++ ulHeight == 0 || ulHeight == 0xffffffff ||
4129 ++ (x < 2 && ulWidth + 2 == 0))
4130 ++ return -EINVAL;
4131 ++
4132 + /* Stop Ramdac Output */
4133 + DisableRamdacOutput(deviceInfo.pSTGReg);
4134 +
4135 +@@ -394,6 +399,9 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
4136 + {
4137 + struct kyrofb_info *par = info->par;
4138 +
4139 ++ if (!var->pixclock)
4140 ++ return -EINVAL;
4141 ++
4142 + if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
4143 + printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
4144 + return -EINVAL;
4145 +diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c
4146 +index 1ea78bb911fbb..c080d14f9d2a2 100644
4147 +--- a/drivers/video/fbdev/riva/fbdev.c
4148 ++++ b/drivers/video/fbdev/riva/fbdev.c
4149 +@@ -1088,6 +1088,9 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
4150 + int mode_valid = 0;
4151 +
4152 + NVTRACE_ENTER();
4153 ++ if (!var->pixclock)
4154 ++ return -EINVAL;
4155 ++
4156 + switch (var->bits_per_pixel) {
4157 + case 1 ... 8:
4158 + var->red.offset = var->green.offset = var->blue.offset = 0;
4159 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
4160 +index 275a89b8e4b8b..692d0d71e8c53 100644
4161 +--- a/fs/btrfs/inode.c
4162 ++++ b/fs/btrfs/inode.c
4163 +@@ -540,7 +540,7 @@ again:
4164 + * inode has not been flagged as nocompress. This flag can
4165 + * change at any time if we discover bad compression ratios.
4166 + */
4167 +- if (nr_pages > 1 && inode_need_compress(inode, start, end)) {
4168 ++ if (inode_need_compress(inode, start, end)) {
4169 + WARN_ON(pages);
4170 + pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
4171 + if (!pages) {
4172 +diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
4173 +index 9986817532b10..7932e20555d2b 100644
4174 +--- a/fs/cifs/cifs_unicode.c
4175 ++++ b/fs/cifs/cifs_unicode.c
4176 +@@ -371,14 +371,9 @@ cifs_strndup_from_utf16(const char *src, const int maxlen,
4177 + if (!dst)
4178 + return NULL;
4179 + cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage,
4180 +- NO_MAP_UNI_RSVD);
4181 ++ NO_MAP_UNI_RSVD);
4182 + } else {
4183 +- len = strnlen(src, maxlen);
4184 +- len++;
4185 +- dst = kmalloc(len, GFP_KERNEL);
4186 +- if (!dst)
4187 +- return NULL;
4188 +- strlcpy(dst, src, len);
4189 ++ dst = kstrndup(src, maxlen, GFP_KERNEL);
4190 + }
4191 +
4192 + return dst;
4193 +diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
4194 +index aa23c00367ec4..0113dba28eb09 100644
4195 +--- a/fs/cifs/sess.c
4196 ++++ b/fs/cifs/sess.c
4197 +@@ -602,7 +602,7 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)
4198 + return 0;
4199 +
4200 + out_free_smb_buf:
4201 +- kfree(smb_buf);
4202 ++ cifs_small_buf_release(smb_buf);
4203 + sess_data->iov[0].iov_base = NULL;
4204 + sess_data->iov[0].iov_len = 0;
4205 + sess_data->buf0_type = CIFS_NO_BUFFER;
4206 +diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
4207 +index 89a4ac83cbcd9..034b5d0a05044 100644
4208 +--- a/fs/ext4/inline.c
4209 ++++ b/fs/ext4/inline.c
4210 +@@ -756,6 +756,12 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
4211 + ext4_write_lock_xattr(inode, &no_expand);
4212 + BUG_ON(!ext4_has_inline_data(inode));
4213 +
4214 ++ /*
4215 ++ * ei->i_inline_off may have changed since ext4_write_begin()
4216 ++ * called ext4_try_to_write_inline_data()
4217 ++ */
4218 ++ (void) ext4_find_inline_data_nolock(inode);
4219 ++
4220 + kaddr = kmap_atomic(page);
4221 + ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
4222 + kunmap_atomic(kaddr);
4223 +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
4224 +index 2cd0d126ef8fa..4307f8db6c8fb 100644
4225 +--- a/fs/f2fs/segment.c
4226 ++++ b/fs/f2fs/segment.c
4227 +@@ -3337,14 +3337,17 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
4228 + } else {
4229 + memcpy(se->discard_map, se->cur_valid_map,
4230 + SIT_VBLOCK_MAP_SIZE);
4231 +- sbi->discard_blks += old_valid_blocks -
4232 +- se->valid_blocks;
4233 ++ sbi->discard_blks += old_valid_blocks;
4234 ++ sbi->discard_blks -= se->valid_blocks;
4235 + }
4236 + }
4237 +
4238 +- if (sbi->segs_per_sec > 1)
4239 ++ if (sbi->segs_per_sec > 1) {
4240 + get_sec_entry(sbi, start)->valid_blocks +=
4241 +- se->valid_blocks - old_valid_blocks;
4242 ++ se->valid_blocks;
4243 ++ get_sec_entry(sbi, start)->valid_blocks -=
4244 ++ old_valid_blocks;
4245 ++ }
4246 + }
4247 + up_read(&curseg->journal_rwsem);
4248 +
4249 +diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
4250 +index de733a6c30bb4..f3c16a504c8d0 100644
4251 +--- a/fs/gfs2/lock_dlm.c
4252 ++++ b/fs/gfs2/lock_dlm.c
4253 +@@ -295,6 +295,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
4254 + gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
4255 + gfs2_update_request_times(gl);
4256 +
4257 ++ /* don't want to call dlm if we've unmounted the lock protocol */
4258 ++ if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) {
4259 ++ gfs2_glock_free(gl);
4260 ++ return;
4261 ++ }
4262 + /* don't want to skip dlm_unlock writing the lvb when lock has one */
4263 +
4264 + if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
4265 +diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
4266 +index a4994e25e19e7..f1134752cea33 100644
4267 +--- a/fs/isofs/inode.c
4268 ++++ b/fs/isofs/inode.c
4269 +@@ -157,7 +157,6 @@ struct iso9660_options{
4270 + unsigned int overriderockperm:1;
4271 + unsigned int uid_set:1;
4272 + unsigned int gid_set:1;
4273 +- unsigned int utf8:1;
4274 + unsigned char map;
4275 + unsigned char check;
4276 + unsigned int blocksize;
4277 +@@ -357,7 +356,6 @@ static int parse_options(char *options, struct iso9660_options *popt)
4278 + popt->gid = GLOBAL_ROOT_GID;
4279 + popt->uid = GLOBAL_ROOT_UID;
4280 + popt->iocharset = NULL;
4281 +- popt->utf8 = 0;
4282 + popt->overriderockperm = 0;
4283 + popt->session=-1;
4284 + popt->sbsector=-1;
4285 +@@ -390,10 +388,13 @@ static int parse_options(char *options, struct iso9660_options *popt)
4286 + case Opt_cruft:
4287 + popt->cruft = 1;
4288 + break;
4289 ++#ifdef CONFIG_JOLIET
4290 + case Opt_utf8:
4291 +- popt->utf8 = 1;
4292 ++ kfree(popt->iocharset);
4293 ++ popt->iocharset = kstrdup("utf8", GFP_KERNEL);
4294 ++ if (!popt->iocharset)
4295 ++ return 0;
4296 + break;
4297 +-#ifdef CONFIG_JOLIET
4298 + case Opt_iocharset:
4299 + kfree(popt->iocharset);
4300 + popt->iocharset = match_strdup(&args[0]);
4301 +@@ -496,7 +497,6 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
4302 + if (sbi->s_nocompress) seq_puts(m, ",nocompress");
4303 + if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm");
4304 + if (sbi->s_showassoc) seq_puts(m, ",showassoc");
4305 +- if (sbi->s_utf8) seq_puts(m, ",utf8");
4306 +
4307 + if (sbi->s_check) seq_printf(m, ",check=%c", sbi->s_check);
4308 + if (sbi->s_mapping) seq_printf(m, ",map=%c", sbi->s_mapping);
4309 +@@ -519,9 +519,10 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
4310 + seq_printf(m, ",fmode=%o", sbi->s_fmode);
4311 +
4312 + #ifdef CONFIG_JOLIET
4313 +- if (sbi->s_nls_iocharset &&
4314 +- strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0)
4315 ++ if (sbi->s_nls_iocharset)
4316 + seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset);
4317 ++ else
4318 ++ seq_puts(m, ",iocharset=utf8");
4319 + #endif
4320 + return 0;
4321 + }
4322 +@@ -865,14 +866,13 @@ root_found:
4323 + sbi->s_nls_iocharset = NULL;
4324 +
4325 + #ifdef CONFIG_JOLIET
4326 +- if (joliet_level && opt.utf8 == 0) {
4327 ++ if (joliet_level) {
4328 + char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT;
4329 +- sbi->s_nls_iocharset = load_nls(p);
4330 +- if (! sbi->s_nls_iocharset) {
4331 +- /* Fail only if explicit charset specified */
4332 +- if (opt.iocharset)
4333 ++ if (strcmp(p, "utf8") != 0) {
4334 ++ sbi->s_nls_iocharset = opt.iocharset ?
4335 ++ load_nls(opt.iocharset) : load_nls_default();
4336 ++ if (!sbi->s_nls_iocharset)
4337 + goto out_freesbi;
4338 +- sbi->s_nls_iocharset = load_nls_default();
4339 + }
4340 + }
4341 + #endif
4342 +@@ -888,7 +888,6 @@ root_found:
4343 + sbi->s_gid = opt.gid;
4344 + sbi->s_uid_set = opt.uid_set;
4345 + sbi->s_gid_set = opt.gid_set;
4346 +- sbi->s_utf8 = opt.utf8;
4347 + sbi->s_nocompress = opt.nocompress;
4348 + sbi->s_overriderockperm = opt.overriderockperm;
4349 + /*
4350 +diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
4351 +index 8e42b4fbefdc3..b4b9d4861c9da 100644
4352 +--- a/fs/isofs/isofs.h
4353 ++++ b/fs/isofs/isofs.h
4354 +@@ -44,7 +44,6 @@ struct isofs_sb_info {
4355 + unsigned char s_session;
4356 + unsigned int s_high_sierra:1;
4357 + unsigned int s_rock:2;
4358 +- unsigned int s_utf8:1;
4359 + unsigned int s_cruft:1; /* Broken disks with high byte of length
4360 + * containing junk */
4361 + unsigned int s_nocompress:1;
4362 +diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c
4363 +index be8b6a9d0b926..c0f04a1e7f695 100644
4364 +--- a/fs/isofs/joliet.c
4365 ++++ b/fs/isofs/joliet.c
4366 +@@ -41,14 +41,12 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)
4367 + int
4368 + get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode)
4369 + {
4370 +- unsigned char utf8;
4371 + struct nls_table *nls;
4372 + unsigned char len = 0;
4373 +
4374 +- utf8 = ISOFS_SB(inode->i_sb)->s_utf8;
4375 + nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset;
4376 +
4377 +- if (utf8) {
4378 ++ if (!nls) {
4379 + len = utf16s_to_utf8s((const wchar_t *) de->name,
4380 + de->name_len[0] >> 1, UTF16_BIG_ENDIAN,
4381 + outname, PAGE_SIZE);
4382 +diff --git a/fs/udf/misc.c b/fs/udf/misc.c
4383 +index 3949c4bec3a3f..e5f4dcde309f7 100644
4384 +--- a/fs/udf/misc.c
4385 ++++ b/fs/udf/misc.c
4386 +@@ -173,13 +173,22 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
4387 + else
4388 + offset = le32_to_cpu(eahd->appAttrLocation);
4389 +
4390 +- while (offset < iinfo->i_lenEAttr) {
4391 ++ while (offset + sizeof(*gaf) < iinfo->i_lenEAttr) {
4392 ++ uint32_t attrLength;
4393 ++
4394 + gaf = (struct genericFormat *)&ea[offset];
4395 ++ attrLength = le32_to_cpu(gaf->attrLength);
4396 ++
4397 ++ /* Detect undersized elements and buffer overflows */
4398 ++ if ((attrLength < sizeof(*gaf)) ||
4399 ++ (attrLength > (iinfo->i_lenEAttr - offset)))
4400 ++ break;
4401 ++
4402 + if (le32_to_cpu(gaf->attrType) == type &&
4403 + gaf->attrSubtype == subtype)
4404 + return gaf;
4405 + else
4406 +- offset += le32_to_cpu(gaf->attrLength);
4407 ++ offset += attrLength;
4408 + }
4409 + }
4410 +
4411 +diff --git a/fs/udf/super.c b/fs/udf/super.c
4412 +index 2b8147ecd97fb..70b56011b8237 100644
4413 +--- a/fs/udf/super.c
4414 ++++ b/fs/udf/super.c
4415 +@@ -113,16 +113,10 @@ struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_block *sb)
4416 + return NULL;
4417 + lvid = (struct logicalVolIntegrityDesc *)UDF_SB(sb)->s_lvid_bh->b_data;
4418 + partnum = le32_to_cpu(lvid->numOfPartitions);
4419 +- if ((sb->s_blocksize - sizeof(struct logicalVolIntegrityDescImpUse) -
4420 +- offsetof(struct logicalVolIntegrityDesc, impUse)) /
4421 +- (2 * sizeof(uint32_t)) < partnum) {
4422 +- udf_err(sb, "Logical volume integrity descriptor corrupted "
4423 +- "(numOfPartitions = %u)!\n", partnum);
4424 +- return NULL;
4425 +- }
4426 + /* The offset is to skip freeSpaceTable and sizeTable arrays */
4427 + offset = partnum * 2 * sizeof(uint32_t);
4428 +- return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]);
4429 ++ return (struct logicalVolIntegrityDescImpUse *)
4430 ++ (((uint8_t *)(lvid + 1)) + offset);
4431 + }
4432 +
4433 + /* UDF filesystem type */
4434 +@@ -1565,6 +1559,7 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_
4435 + struct udf_sb_info *sbi = UDF_SB(sb);
4436 + struct logicalVolIntegrityDesc *lvid;
4437 + int indirections = 0;
4438 ++ u32 parts, impuselen;
4439 +
4440 + while (++indirections <= UDF_MAX_LVID_NESTING) {
4441 + final_bh = NULL;
4442 +@@ -1591,15 +1586,27 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_
4443 +
4444 + lvid = (struct logicalVolIntegrityDesc *)final_bh->b_data;
4445 + if (lvid->nextIntegrityExt.extLength == 0)
4446 +- return;
4447 ++ goto check;
4448 +
4449 + loc = leea_to_cpu(lvid->nextIntegrityExt);
4450 + }
4451 +
4452 + udf_warn(sb, "Too many LVID indirections (max %u), ignoring.\n",
4453 + UDF_MAX_LVID_NESTING);
4454 ++out_err:
4455 + brelse(sbi->s_lvid_bh);
4456 + sbi->s_lvid_bh = NULL;
4457 ++ return;
4458 ++check:
4459 ++ parts = le32_to_cpu(lvid->numOfPartitions);
4460 ++ impuselen = le32_to_cpu(lvid->lengthOfImpUse);
4461 ++ if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize ||
4462 ++ sizeof(struct logicalVolIntegrityDesc) + impuselen +
4463 ++ 2 * parts * sizeof(u32) > sb->s_blocksize) {
4464 ++ udf_warn(sb, "Corrupted LVID (parts=%u, impuselen=%u), "
4465 ++ "ignoring.\n", parts, impuselen);
4466 ++ goto out_err;
4467 ++ }
4468 + }
4469 +
4470 +
4471 +diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
4472 +index e0b681a717bac..052e26fda2e6c 100644
4473 +--- a/include/crypto/public_key.h
4474 ++++ b/include/crypto/public_key.h
4475 +@@ -35,9 +35,9 @@ extern void public_key_free(struct public_key *key);
4476 + struct public_key_signature {
4477 + struct asymmetric_key_id *auth_ids[2];
4478 + u8 *s; /* Signature */
4479 +- u32 s_size; /* Number of bytes in signature */
4480 + u8 *digest;
4481 +- u8 digest_size; /* Number of bytes in digest */
4482 ++ u32 s_size; /* Number of bytes in signature */
4483 ++ u32 digest_size; /* Number of bytes in digest */
4484 + const char *pkey_algo;
4485 + const char *hash_algo;
4486 + };
4487 +diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
4488 +index d2b5cc8ce54f9..26dddc03b35c5 100644
4489 +--- a/include/linux/hugetlb.h
4490 ++++ b/include/linux/hugetlb.h
4491 +@@ -503,6 +503,11 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
4492 +
4493 + void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm);
4494 +
4495 ++static inline void hugetlb_count_init(struct mm_struct *mm)
4496 ++{
4497 ++ atomic_long_set(&mm->hugetlb_usage, 0);
4498 ++}
4499 ++
4500 + static inline void hugetlb_count_add(long l, struct mm_struct *mm)
4501 + {
4502 + atomic_long_add(l, &mm->hugetlb_usage);
4503 +@@ -583,6 +588,10 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
4504 + return &mm->page_table_lock;
4505 + }
4506 +
4507 ++static inline void hugetlb_count_init(struct mm_struct *mm)
4508 ++{
4509 ++}
4510 ++
4511 + static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m)
4512 + {
4513 + }
4514 +diff --git a/include/linux/list.h b/include/linux/list.h
4515 +index de04cc5ed5367..d2c12ef7a4e32 100644
4516 +--- a/include/linux/list.h
4517 ++++ b/include/linux/list.h
4518 +@@ -484,6 +484,15 @@ static inline void list_splice_tail_init(struct list_head *list,
4519 + pos != (head); \
4520 + pos = n, n = pos->prev)
4521 +
4522 ++/**
4523 ++ * list_entry_is_head - test if the entry points to the head of the list
4524 ++ * @pos: the type * to cursor
4525 ++ * @head: the head for your list.
4526 ++ * @member: the name of the list_head within the struct.
4527 ++ */
4528 ++#define list_entry_is_head(pos, head, member) \
4529 ++ (&pos->member == (head))
4530 ++
4531 + /**
4532 + * list_for_each_entry - iterate over list of given type
4533 + * @pos: the type * to use as a loop cursor.
4534 +@@ -492,7 +501,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4535 + */
4536 + #define list_for_each_entry(pos, head, member) \
4537 + for (pos = list_first_entry(head, typeof(*pos), member); \
4538 +- &pos->member != (head); \
4539 ++ !list_entry_is_head(pos, head, member); \
4540 + pos = list_next_entry(pos, member))
4541 +
4542 + /**
4543 +@@ -503,7 +512,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4544 + */
4545 + #define list_for_each_entry_reverse(pos, head, member) \
4546 + for (pos = list_last_entry(head, typeof(*pos), member); \
4547 +- &pos->member != (head); \
4548 ++ !list_entry_is_head(pos, head, member); \
4549 + pos = list_prev_entry(pos, member))
4550 +
4551 + /**
4552 +@@ -528,7 +537,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4553 + */
4554 + #define list_for_each_entry_continue(pos, head, member) \
4555 + for (pos = list_next_entry(pos, member); \
4556 +- &pos->member != (head); \
4557 ++ !list_entry_is_head(pos, head, member); \
4558 + pos = list_next_entry(pos, member))
4559 +
4560 + /**
4561 +@@ -542,7 +551,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4562 + */
4563 + #define list_for_each_entry_continue_reverse(pos, head, member) \
4564 + for (pos = list_prev_entry(pos, member); \
4565 +- &pos->member != (head); \
4566 ++ !list_entry_is_head(pos, head, member); \
4567 + pos = list_prev_entry(pos, member))
4568 +
4569 + /**
4570 +@@ -554,7 +563,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4571 + * Iterate over list of given type, continuing from current position.
4572 + */
4573 + #define list_for_each_entry_from(pos, head, member) \
4574 +- for (; &pos->member != (head); \
4575 ++ for (; !list_entry_is_head(pos, head, member); \
4576 + pos = list_next_entry(pos, member))
4577 +
4578 + /**
4579 +@@ -567,7 +576,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4580 + * Iterate backwards over list of given type, continuing from current position.
4581 + */
4582 + #define list_for_each_entry_from_reverse(pos, head, member) \
4583 +- for (; &pos->member != (head); \
4584 ++ for (; !list_entry_is_head(pos, head, member); \
4585 + pos = list_prev_entry(pos, member))
4586 +
4587 + /**
4588 +@@ -580,7 +589,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4589 + #define list_for_each_entry_safe(pos, n, head, member) \
4590 + for (pos = list_first_entry(head, typeof(*pos), member), \
4591 + n = list_next_entry(pos, member); \
4592 +- &pos->member != (head); \
4593 ++ !list_entry_is_head(pos, head, member); \
4594 + pos = n, n = list_next_entry(n, member))
4595 +
4596 + /**
4597 +@@ -596,7 +605,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4598 + #define list_for_each_entry_safe_continue(pos, n, head, member) \
4599 + for (pos = list_next_entry(pos, member), \
4600 + n = list_next_entry(pos, member); \
4601 +- &pos->member != (head); \
4602 ++ !list_entry_is_head(pos, head, member); \
4603 + pos = n, n = list_next_entry(n, member))
4604 +
4605 + /**
4606 +@@ -611,7 +620,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4607 + */
4608 + #define list_for_each_entry_safe_from(pos, n, head, member) \
4609 + for (n = list_next_entry(pos, member); \
4610 +- &pos->member != (head); \
4611 ++ !list_entry_is_head(pos, head, member); \
4612 + pos = n, n = list_next_entry(n, member))
4613 +
4614 + /**
4615 +@@ -627,7 +636,7 @@ static inline void list_splice_tail_init(struct list_head *list,
4616 + #define list_for_each_entry_safe_reverse(pos, n, head, member) \
4617 + for (pos = list_last_entry(head, typeof(*pos), member), \
4618 + n = list_prev_entry(pos, member); \
4619 +- &pos->member != (head); \
4620 ++ !list_entry_is_head(pos, head, member); \
4621 + pos = n, n = list_prev_entry(n, member))
4622 +
4623 + /**
4624 +diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
4625 +index d36a029353915..8c48d9e0ca222 100644
4626 +--- a/include/linux/memory_hotplug.h
4627 ++++ b/include/linux/memory_hotplug.h
4628 +@@ -332,6 +332,6 @@ extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
4629 + unsigned long pnum);
4630 + extern bool allow_online_pfn_range(int nid, unsigned long pfn, unsigned long nr_pages,
4631 + int online_type);
4632 +-extern struct zone *zone_for_pfn_range(int online_type, int nid, unsigned start_pfn,
4633 +- unsigned long nr_pages);
4634 ++extern struct zone *zone_for_pfn_range(int online_type, int nid,
4635 ++ unsigned long start_pfn, unsigned long nr_pages);
4636 + #endif /* __LINUX_MEMORY_HOTPLUG_H */
4637 +diff --git a/include/linux/pci.h b/include/linux/pci.h
4638 +index 59f4d10568c65..66c0d5fad0cb3 100644
4639 +--- a/include/linux/pci.h
4640 ++++ b/include/linux/pci.h
4641 +@@ -1633,8 +1633,9 @@ static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
4642 + static inline void pci_disable_device(struct pci_dev *dev) { }
4643 + static inline int pci_assign_resource(struct pci_dev *dev, int i)
4644 + { return -EBUSY; }
4645 +-static inline int __pci_register_driver(struct pci_driver *drv,
4646 +- struct module *owner)
4647 ++static inline int __must_check __pci_register_driver(struct pci_driver *drv,
4648 ++ struct module *owner,
4649 ++ const char *mod_name)
4650 + { return 0; }
4651 + static inline int pci_register_driver(struct pci_driver *drv)
4652 + { return 0; }
4653 +diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
4654 +index a7ed29baf44a6..86e5ad8aeee4e 100644
4655 +--- a/include/linux/power/max17042_battery.h
4656 ++++ b/include/linux/power/max17042_battery.h
4657 +@@ -82,7 +82,7 @@ enum max17042_register {
4658 + MAX17042_RelaxCFG = 0x2A,
4659 + MAX17042_MiscCFG = 0x2B,
4660 + MAX17042_TGAIN = 0x2C,
4661 +- MAx17042_TOFF = 0x2D,
4662 ++ MAX17042_TOFF = 0x2D,
4663 + MAX17042_CGAIN = 0x2E,
4664 + MAX17042_COFF = 0x2F,
4665 +
4666 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
4667 +index 2f303454a3233..33b6d3ba49a7e 100644
4668 +--- a/include/linux/skbuff.h
4669 ++++ b/include/linux/skbuff.h
4670 +@@ -1758,7 +1758,7 @@ static inline void __skb_insert(struct sk_buff *newsk,
4671 + WRITE_ONCE(newsk->prev, prev);
4672 + WRITE_ONCE(next->prev, newsk);
4673 + WRITE_ONCE(prev->next, newsk);
4674 +- list->qlen++;
4675 ++ WRITE_ONCE(list->qlen, list->qlen + 1);
4676 + }
4677 +
4678 + static inline void __skb_queue_splice(const struct sk_buff_head *list,
4679 +diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h
4680 +index 619fe6111dc94..a31ae32161f3f 100644
4681 +--- a/include/uapi/linux/serial_reg.h
4682 ++++ b/include/uapi/linux/serial_reg.h
4683 +@@ -62,6 +62,7 @@
4684 + * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654
4685 + * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750
4686 + * TI16C752: 8 16 56 60 8 16 32 56
4687 ++ * OX16C950: 16 32 112 120 16 32 64 112 PORT_16C950
4688 + * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA
4689 + */
4690 + #define UART_FCR_R_TRIG_00 0x00
4691 +diff --git a/kernel/events/core.c b/kernel/events/core.c
4692 +index 1aa094c5dedb4..236e7900e3fca 100644
4693 +--- a/kernel/events/core.c
4694 ++++ b/kernel/events/core.c
4695 +@@ -8435,7 +8435,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
4696 + if (!ifh->nr_file_filters)
4697 + return;
4698 +
4699 +- mm = get_task_mm(event->ctx->task);
4700 ++ mm = get_task_mm(task);
4701 + if (!mm)
4702 + goto restart;
4703 +
4704 +diff --git a/kernel/fork.c b/kernel/fork.c
4705 +index 783eae426a866..5e44c062244f4 100644
4706 +--- a/kernel/fork.c
4707 ++++ b/kernel/fork.c
4708 +@@ -837,6 +837,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
4709 + mm->pmd_huge_pte = NULL;
4710 + #endif
4711 + mm_init_uprobes_state(mm);
4712 ++ hugetlb_count_init(mm);
4713 +
4714 + if (current->mm) {
4715 + mm->flags = current->mm->flags & MMF_INIT_MASK;
4716 +diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
4717 +index 22091c88b3bb7..93ed69037ae9d 100644
4718 +--- a/kernel/pid_namespace.c
4719 ++++ b/kernel/pid_namespace.c
4720 +@@ -55,7 +55,7 @@ static struct kmem_cache *create_pid_cachep(int nr_ids)
4721 + snprintf(pcache->name, sizeof(pcache->name), "pid_%d", nr_ids);
4722 + cachep = kmem_cache_create(pcache->name,
4723 + sizeof(struct pid) + (nr_ids - 1) * sizeof(struct upid),
4724 +- 0, SLAB_HWCACHE_ALIGN, NULL);
4725 ++ 0, SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
4726 + if (cachep == NULL)
4727 + goto err_cachep;
4728 +
4729 +diff --git a/lib/test_bpf.c b/lib/test_bpf.c
4730 +index 75ebf2bbc2eeb..9a8f957ad86e9 100644
4731 +--- a/lib/test_bpf.c
4732 ++++ b/lib/test_bpf.c
4733 +@@ -4395,8 +4395,8 @@ static struct bpf_test tests[] = {
4734 + .u.insns_int = {
4735 + BPF_LD_IMM64(R0, 0),
4736 + BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4737 +- BPF_STX_MEM(BPF_W, R10, R1, -40),
4738 +- BPF_LDX_MEM(BPF_W, R0, R10, -40),
4739 ++ BPF_STX_MEM(BPF_DW, R10, R1, -40),
4740 ++ BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4741 + BPF_EXIT_INSN(),
4742 + },
4743 + INTERNAL,
4744 +@@ -6306,7 +6306,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
4745 + u64 duration;
4746 + u32 ret;
4747 +
4748 +- if (test->test[i].data_size == 0 &&
4749 ++ /*
4750 ++ * NOTE: Several sub-tests may be present, in which case
4751 ++ * a zero {data_size, result} tuple indicates the end of
4752 ++ * the sub-test array. The first test is always run,
4753 ++ * even if both data_size and result happen to be zero.
4754 ++ */
4755 ++ if (i > 0 &&
4756 ++ test->test[i].data_size == 0 &&
4757 + test->test[i].result == 0)
4758 + break;
4759 +
4760 +diff --git a/mm/kmemleak.c b/mm/kmemleak.c
4761 +index 706f705c2e0a4..0b842160168be 100644
4762 +--- a/mm/kmemleak.c
4763 ++++ b/mm/kmemleak.c
4764 +@@ -1520,7 +1520,7 @@ static void kmemleak_scan(void)
4765 + if (page_count(page) == 0)
4766 + continue;
4767 + scan_block(page, page + 1, NULL);
4768 +- if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page))))
4769 ++ if (!(pfn & 63))
4770 + cond_resched();
4771 + }
4772 + }
4773 +diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
4774 +index 2d6626ab29d15..c2878d48b8b17 100644
4775 +--- a/mm/memory_hotplug.c
4776 ++++ b/mm/memory_hotplug.c
4777 +@@ -842,8 +842,8 @@ static inline struct zone *default_zone_for_pfn(int nid, unsigned long start_pfn
4778 + return movable_node_enabled ? movable_zone : kernel_zone;
4779 + }
4780 +
4781 +-struct zone * zone_for_pfn_range(int online_type, int nid, unsigned start_pfn,
4782 +- unsigned long nr_pages)
4783 ++struct zone *zone_for_pfn_range(int online_type, int nid,
4784 ++ unsigned long start_pfn, unsigned long nr_pages)
4785 + {
4786 + if (online_type == MMOP_ONLINE_KERNEL)
4787 + return default_kernel_zone_for_pfn(nid, start_pfn, nr_pages);
4788 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
4789 +index 7183807d494fe..9c467ac4b72d7 100644
4790 +--- a/mm/page_alloc.c
4791 ++++ b/mm/page_alloc.c
4792 +@@ -815,7 +815,7 @@ static inline void __free_one_page(struct page *page,
4793 + struct page *buddy;
4794 + unsigned int max_order;
4795 +
4796 +- max_order = min_t(unsigned int, MAX_ORDER, pageblock_order + 1);
4797 ++ max_order = min_t(unsigned int, MAX_ORDER - 1, pageblock_order);
4798 +
4799 + VM_BUG_ON(!zone_is_initialized(zone));
4800 + VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);
4801 +@@ -828,7 +828,7 @@ static inline void __free_one_page(struct page *page,
4802 + VM_BUG_ON_PAGE(bad_range(zone, page), page);
4803 +
4804 + continue_merging:
4805 +- while (order < max_order - 1) {
4806 ++ while (order < max_order) {
4807 + buddy_pfn = __find_buddy_pfn(pfn, order);
4808 + buddy = page + (buddy_pfn - pfn);
4809 +
4810 +@@ -852,7 +852,7 @@ continue_merging:
4811 + pfn = combined_pfn;
4812 + order++;
4813 + }
4814 +- if (max_order < MAX_ORDER) {
4815 ++ if (order < MAX_ORDER - 1) {
4816 + /* If we are here, it means order is >= pageblock_order.
4817 + * We want to prevent merge between freepages on isolate
4818 + * pageblock and normal pageblock. Without this, pageblock
4819 +@@ -873,7 +873,7 @@ continue_merging:
4820 + is_migrate_isolate(buddy_mt)))
4821 + goto done_merging;
4822 + }
4823 +- max_order++;
4824 ++ max_order = order + 1;
4825 + goto continue_merging;
4826 + }
4827 +
4828 +diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
4829 +index ea9f1773abc8f..da843b68cdeb1 100644
4830 +--- a/net/9p/trans_xen.c
4831 ++++ b/net/9p/trans_xen.c
4832 +@@ -139,7 +139,7 @@ static bool p9_xen_write_todo(struct xen_9pfs_dataring *ring, RING_IDX size)
4833 +
4834 + static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
4835 + {
4836 +- struct xen_9pfs_front_priv *priv = NULL;
4837 ++ struct xen_9pfs_front_priv *priv;
4838 + RING_IDX cons, prod, masked_cons, masked_prod;
4839 + unsigned long flags;
4840 + u32 size = p9_req->tc->size;
4841 +@@ -152,7 +152,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
4842 + break;
4843 + }
4844 + read_unlock(&xen_9pfs_lock);
4845 +- if (!priv || priv->client != client)
4846 ++ if (list_entry_is_head(priv, &xen_9pfs_devs, list))
4847 + return -EINVAL;
4848 +
4849 + num = p9_req->tc->tag % priv->num_rings;
4850 +diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h
4851 +index c32638dddbf94..f6b9dc4e408f2 100644
4852 +--- a/net/bluetooth/cmtp/cmtp.h
4853 ++++ b/net/bluetooth/cmtp/cmtp.h
4854 +@@ -26,7 +26,7 @@
4855 + #include <linux/types.h>
4856 + #include <net/bluetooth/bluetooth.h>
4857 +
4858 +-#define BTNAMSIZ 18
4859 ++#define BTNAMSIZ 21
4860 +
4861 + /* CMTP ioctl defines */
4862 + #define CMTPCONNADD _IOW('C', 200, int)
4863 +diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
4864 +index 3b2dd98e9fd6b..1906adfd553ad 100644
4865 +--- a/net/bluetooth/hci_core.c
4866 ++++ b/net/bluetooth/hci_core.c
4867 +@@ -1258,6 +1258,12 @@ int hci_inquiry(void __user *arg)
4868 + goto done;
4869 + }
4870 +
4871 ++ /* Restrict maximum inquiry length to 60 seconds */
4872 ++ if (ir.length > 60) {
4873 ++ err = -EINVAL;
4874 ++ goto done;
4875 ++ }
4876 ++
4877 + hci_dev_lock(hdev);
4878 + if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
4879 + inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) {
4880 +@@ -1582,6 +1588,14 @@ int hci_dev_do_close(struct hci_dev *hdev)
4881 + hci_request_cancel_all(hdev);
4882 + hci_req_sync_lock(hdev);
4883 +
4884 ++ if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
4885 ++ !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
4886 ++ test_bit(HCI_UP, &hdev->flags)) {
4887 ++ /* Execute vendor specific shutdown routine */
4888 ++ if (hdev->shutdown)
4889 ++ hdev->shutdown(hdev);
4890 ++ }
4891 ++
4892 + if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
4893 + cancel_delayed_work_sync(&hdev->cmd_timer);
4894 + hci_req_sync_unlock(hdev);
4895 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
4896 +index b3253f2e11af1..5186f199d892c 100644
4897 +--- a/net/bluetooth/hci_event.c
4898 ++++ b/net/bluetooth/hci_event.c
4899 +@@ -3761,6 +3761,21 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
4900 +
4901 + switch (ev->status) {
4902 + case 0x00:
4903 ++ /* The synchronous connection complete event should only be
4904 ++ * sent once per new connection. Receiving a successful
4905 ++ * complete event when the connection status is already
4906 ++ * BT_CONNECTED means that the device is misbehaving and sent
4907 ++ * multiple complete event packets for the same new connection.
4908 ++ *
4909 ++ * Registering the device more than once can corrupt kernel
4910 ++ * memory, hence upon detecting this invalid event, we report
4911 ++ * an error and ignore the packet.
4912 ++ */
4913 ++ if (conn->state == BT_CONNECTED) {
4914 ++ bt_dev_err(hdev, "Ignoring connect complete event for existing connection");
4915 ++ goto unlock;
4916 ++ }
4917 ++
4918 + conn->handle = __le16_to_cpu(ev->handle);
4919 + conn->state = BT_CONNECTED;
4920 + conn->type = ev->link_type;
4921 +diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
4922 +index 2d23b29ce00df..f681e7ce89457 100644
4923 +--- a/net/bluetooth/sco.c
4924 ++++ b/net/bluetooth/sco.c
4925 +@@ -84,7 +84,6 @@ static void sco_sock_timeout(unsigned long arg)
4926 + sk->sk_state_change(sk);
4927 + bh_unlock_sock(sk);
4928 +
4929 +- sco_sock_kill(sk);
4930 + sock_put(sk);
4931 + }
4932 +
4933 +@@ -176,7 +175,6 @@ static void sco_conn_del(struct hci_conn *hcon, int err)
4934 + sco_sock_clear_timer(sk);
4935 + sco_chan_del(sk, err);
4936 + bh_unlock_sock(sk);
4937 +- sco_sock_kill(sk);
4938 + sock_put(sk);
4939 + }
4940 +
4941 +@@ -211,44 +209,32 @@ static int sco_chan_add(struct sco_conn *conn, struct sock *sk,
4942 + return err;
4943 + }
4944 +
4945 +-static int sco_connect(struct sock *sk)
4946 ++static int sco_connect(struct hci_dev *hdev, struct sock *sk)
4947 + {
4948 + struct sco_conn *conn;
4949 + struct hci_conn *hcon;
4950 +- struct hci_dev *hdev;
4951 + int err, type;
4952 +
4953 + BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
4954 +
4955 +- hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, BDADDR_BREDR);
4956 +- if (!hdev)
4957 +- return -EHOSTUNREACH;
4958 +-
4959 +- hci_dev_lock(hdev);
4960 +-
4961 + if (lmp_esco_capable(hdev) && !disable_esco)
4962 + type = ESCO_LINK;
4963 + else
4964 + type = SCO_LINK;
4965 +
4966 + if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
4967 +- (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
4968 +- err = -EOPNOTSUPP;
4969 +- goto done;
4970 +- }
4971 ++ (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)))
4972 ++ return -EOPNOTSUPP;
4973 +
4974 + hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
4975 + sco_pi(sk)->setting);
4976 +- if (IS_ERR(hcon)) {
4977 +- err = PTR_ERR(hcon);
4978 +- goto done;
4979 +- }
4980 ++ if (IS_ERR(hcon))
4981 ++ return PTR_ERR(hcon);
4982 +
4983 + conn = sco_conn_add(hcon);
4984 + if (!conn) {
4985 + hci_conn_drop(hcon);
4986 +- err = -ENOMEM;
4987 +- goto done;
4988 ++ return -ENOMEM;
4989 + }
4990 +
4991 + /* Update source addr of the socket */
4992 +@@ -256,7 +242,7 @@ static int sco_connect(struct sock *sk)
4993 +
4994 + err = sco_chan_add(conn, sk, NULL);
4995 + if (err)
4996 +- goto done;
4997 ++ return err;
4998 +
4999 + if (hcon->state == BT_CONNECTED) {
5000 + sco_sock_clear_timer(sk);
5001 +@@ -266,9 +252,6 @@ static int sco_connect(struct sock *sk)
5002 + sco_sock_set_timer(sk, sk->sk_sndtimeo);
5003 + }
5004 +
5005 +-done:
5006 +- hci_dev_unlock(hdev);
5007 +- hci_dev_put(hdev);
5008 + return err;
5009 + }
5010 +
5011 +@@ -393,8 +376,7 @@ static void sco_sock_cleanup_listen(struct sock *parent)
5012 + */
5013 + static void sco_sock_kill(struct sock *sk)
5014 + {
5015 +- if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket ||
5016 +- sock_flag(sk, SOCK_DEAD))
5017 ++ if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
5018 + return;
5019 +
5020 + BT_DBG("sk %p state %d", sk, sk->sk_state);
5021 +@@ -446,7 +428,6 @@ static void sco_sock_close(struct sock *sk)
5022 + lock_sock(sk);
5023 + __sco_sock_close(sk);
5024 + release_sock(sk);
5025 +- sco_sock_kill(sk);
5026 + }
5027 +
5028 + static void sco_sock_init(struct sock *sk, struct sock *parent)
5029 +@@ -554,6 +535,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
5030 + {
5031 + struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
5032 + struct sock *sk = sock->sk;
5033 ++ struct hci_dev *hdev;
5034 + int err;
5035 +
5036 + BT_DBG("sk %p", sk);
5037 +@@ -568,12 +550,19 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
5038 + if (sk->sk_type != SOCK_SEQPACKET)
5039 + return -EINVAL;
5040 +
5041 ++ hdev = hci_get_route(&sa->sco_bdaddr, &sco_pi(sk)->src, BDADDR_BREDR);
5042 ++ if (!hdev)
5043 ++ return -EHOSTUNREACH;
5044 ++ hci_dev_lock(hdev);
5045 ++
5046 + lock_sock(sk);
5047 +
5048 + /* Set destination address and psm */
5049 + bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
5050 +
5051 +- err = sco_connect(sk);
5052 ++ err = sco_connect(hdev, sk);
5053 ++ hci_dev_unlock(hdev);
5054 ++ hci_dev_put(hdev);
5055 + if (err)
5056 + goto done;
5057 +
5058 +@@ -762,6 +751,11 @@ static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
5059 + cp.max_latency = cpu_to_le16(0xffff);
5060 + cp.retrans_effort = 0xff;
5061 + break;
5062 ++ default:
5063 ++ /* use CVSD settings as fallback */
5064 ++ cp.max_latency = cpu_to_le16(0xffff);
5065 ++ cp.retrans_effort = 0xff;
5066 ++ break;
5067 + }
5068 +
5069 + hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ,
5070 +diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
5071 +index 922ac1d605b34..7f0d20b692896 100644
5072 +--- a/net/caif/chnl_net.c
5073 ++++ b/net/caif/chnl_net.c
5074 +@@ -54,20 +54,6 @@ struct chnl_net {
5075 + enum caif_states state;
5076 + };
5077 +
5078 +-static void robust_list_del(struct list_head *delete_node)
5079 +-{
5080 +- struct list_head *list_node;
5081 +- struct list_head *n;
5082 +- ASSERT_RTNL();
5083 +- list_for_each_safe(list_node, n, &chnl_net_list) {
5084 +- if (list_node == delete_node) {
5085 +- list_del(list_node);
5086 +- return;
5087 +- }
5088 +- }
5089 +- WARN_ON(1);
5090 +-}
5091 +-
5092 + static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
5093 + {
5094 + struct sk_buff *skb;
5095 +@@ -369,6 +355,7 @@ static int chnl_net_init(struct net_device *dev)
5096 + ASSERT_RTNL();
5097 + priv = netdev_priv(dev);
5098 + strncpy(priv->name, dev->name, sizeof(priv->name));
5099 ++ INIT_LIST_HEAD(&priv->list_field);
5100 + return 0;
5101 + }
5102 +
5103 +@@ -377,7 +364,7 @@ static void chnl_net_uninit(struct net_device *dev)
5104 + struct chnl_net *priv;
5105 + ASSERT_RTNL();
5106 + priv = netdev_priv(dev);
5107 +- robust_list_del(&priv->list_field);
5108 ++ list_del_init(&priv->list_field);
5109 + }
5110 +
5111 + static const struct net_device_ops netdev_ops = {
5112 +@@ -542,7 +529,7 @@ static void __exit chnl_exit_module(void)
5113 + rtnl_lock();
5114 + list_for_each_safe(list_node, _tmp, &chnl_net_list) {
5115 + dev = list_entry(list_node, struct chnl_net, list_field);
5116 +- list_del(list_node);
5117 ++ list_del_init(list_node);
5118 + delete_device(dev);
5119 + }
5120 + rtnl_unlock();
5121 +diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
5122 +index 071de30133645..b4dddb685fc2f 100644
5123 +--- a/net/core/flow_dissector.c
5124 ++++ b/net/core/flow_dissector.c
5125 +@@ -514,8 +514,10 @@ proto_again:
5126 + FLOW_DISSECTOR_KEY_IPV4_ADDRS,
5127 + target_container);
5128 +
5129 +- memcpy(&key_addrs->v4addrs, &iph->saddr,
5130 +- sizeof(key_addrs->v4addrs));
5131 ++ memcpy(&key_addrs->v4addrs.src, &iph->saddr,
5132 ++ sizeof(key_addrs->v4addrs.src));
5133 ++ memcpy(&key_addrs->v4addrs.dst, &iph->daddr,
5134 ++ sizeof(key_addrs->v4addrs.dst));
5135 + key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
5136 + }
5137 +
5138 +@@ -564,8 +566,10 @@ proto_again:
5139 + FLOW_DISSECTOR_KEY_IPV6_ADDRS,
5140 + target_container);
5141 +
5142 +- memcpy(&key_addrs->v6addrs, &iph->saddr,
5143 +- sizeof(key_addrs->v6addrs));
5144 ++ memcpy(&key_addrs->v6addrs.src, &iph->saddr,
5145 ++ sizeof(key_addrs->v6addrs.src));
5146 ++ memcpy(&key_addrs->v6addrs.dst, &iph->daddr,
5147 ++ sizeof(key_addrs->v6addrs.dst));
5148 + key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
5149 + }
5150 +
5151 +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
5152 +index 1af25d53f63ca..37f4313e82d2e 100644
5153 +--- a/net/core/net_namespace.c
5154 ++++ b/net/core/net_namespace.c
5155 +@@ -181,9 +181,9 @@ static int net_eq_idr(int id, void *net, void *peer)
5156 + return 0;
5157 + }
5158 +
5159 +-/* Should be called with nsid_lock held. If a new id is assigned, the bool alloc
5160 +- * is set to true, thus the caller knows that the new id must be notified via
5161 +- * rtnl.
5162 ++/* Must be called from RCU-critical section or with nsid_lock held. If
5163 ++ * a new id is assigned, the bool alloc is set to true, thus the
5164 ++ * caller knows that the new id must be notified via rtnl.
5165 + */
5166 + static int __peernet2id_alloc(struct net *net, struct net *peer, bool *alloc)
5167 + {
5168 +@@ -207,7 +207,7 @@ static int __peernet2id_alloc(struct net *net, struct net *peer, bool *alloc)
5169 + return NETNSA_NSID_NOT_ASSIGNED;
5170 + }
5171 +
5172 +-/* should be called with nsid_lock held */
5173 ++/* Must be called from RCU-critical section or with nsid_lock held */
5174 + static int __peernet2id(struct net *net, struct net *peer)
5175 + {
5176 + bool no = false;
5177 +@@ -240,9 +240,10 @@ int peernet2id(struct net *net, struct net *peer)
5178 + {
5179 + int id;
5180 +
5181 +- spin_lock_bh(&net->nsid_lock);
5182 ++ rcu_read_lock();
5183 + id = __peernet2id(net, peer);
5184 +- spin_unlock_bh(&net->nsid_lock);
5185 ++ rcu_read_unlock();
5186 ++
5187 + return id;
5188 + }
5189 + EXPORT_SYMBOL(peernet2id);
5190 +@@ -761,6 +762,7 @@ struct rtnl_net_dump_cb {
5191 + int s_idx;
5192 + };
5193 +
5194 ++/* Runs in RCU-critical section. */
5195 + static int rtnl_net_dumpid_one(int id, void *peer, void *data)
5196 + {
5197 + struct rtnl_net_dump_cb *net_cb = (struct rtnl_net_dump_cb *)data;
5198 +@@ -791,9 +793,9 @@ static int rtnl_net_dumpid(struct sk_buff *skb, struct netlink_callback *cb)
5199 + .s_idx = cb->args[0],
5200 + };
5201 +
5202 +- spin_lock_bh(&net->nsid_lock);
5203 ++ rcu_read_lock();
5204 + idr_for_each(&net->netns_ids, rtnl_net_dumpid_one, &net_cb);
5205 +- spin_unlock_bh(&net->nsid_lock);
5206 ++ rcu_read_unlock();
5207 +
5208 + cb->args[0] = net_cb.idx;
5209 + return skb->len;
5210 +diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
5211 +index 178bb9833311f..f6092536de034 100644
5212 +--- a/net/dccp/minisocks.c
5213 ++++ b/net/dccp/minisocks.c
5214 +@@ -98,6 +98,8 @@ struct sock *dccp_create_openreq_child(const struct sock *sk,
5215 + newdp->dccps_role = DCCP_ROLE_SERVER;
5216 + newdp->dccps_hc_rx_ackvec = NULL;
5217 + newdp->dccps_service_list = NULL;
5218 ++ newdp->dccps_hc_rx_ccid = NULL;
5219 ++ newdp->dccps_hc_tx_ccid = NULL;
5220 + newdp->dccps_service = dreq->dreq_service;
5221 + newdp->dccps_timestamp_echo = dreq->dreq_timestamp_echo;
5222 + newdp->dccps_timestamp_time = dreq->dreq_timestamp_time;
5223 +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
5224 +index ba07f128d7ad1..dc99b40da48d7 100644
5225 +--- a/net/ipv4/icmp.c
5226 ++++ b/net/ipv4/icmp.c
5227 +@@ -468,6 +468,23 @@ out_bh_enable:
5228 + local_bh_enable();
5229 + }
5230 +
5231 ++/*
5232 ++ * The device used for looking up which routing table to use for sending an ICMP
5233 ++ * error is preferably the source whenever it is set, which should ensure the
5234 ++ * icmp error can be sent to the source host, else lookup using the routing
5235 ++ * table of the destination device, else use the main routing table (index 0).
5236 ++ */
5237 ++static struct net_device *icmp_get_route_lookup_dev(struct sk_buff *skb)
5238 ++{
5239 ++ struct net_device *route_lookup_dev = NULL;
5240 ++
5241 ++ if (skb->dev)
5242 ++ route_lookup_dev = skb->dev;
5243 ++ else if (skb_dst(skb))
5244 ++ route_lookup_dev = skb_dst(skb)->dev;
5245 ++ return route_lookup_dev;
5246 ++}
5247 ++
5248 + static struct rtable *icmp_route_lookup(struct net *net,
5249 + struct flowi4 *fl4,
5250 + struct sk_buff *skb_in,
5251 +@@ -476,6 +493,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
5252 + int type, int code,
5253 + struct icmp_bxm *param)
5254 + {
5255 ++ struct net_device *route_lookup_dev;
5256 + struct rtable *rt, *rt2;
5257 + struct flowi4 fl4_dec;
5258 + int err;
5259 +@@ -490,7 +508,8 @@ static struct rtable *icmp_route_lookup(struct net *net,
5260 + fl4->flowi4_proto = IPPROTO_ICMP;
5261 + fl4->fl4_icmp_type = type;
5262 + fl4->fl4_icmp_code = code;
5263 +- fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
5264 ++ route_lookup_dev = icmp_get_route_lookup_dev(skb_in);
5265 ++ fl4->flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);
5266 +
5267 + security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
5268 + rt = ip_route_output_key_hash(net, fl4, skb_in);
5269 +@@ -514,7 +533,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
5270 + if (err)
5271 + goto relookup_failed;
5272 +
5273 +- if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,
5274 ++ if (inet_addr_type_dev_table(net, route_lookup_dev,
5275 + fl4_dec.saddr) == RTN_LOCAL) {
5276 + rt2 = __ip_route_output_key(net, &fl4_dec);
5277 + if (IS_ERR(rt2))
5278 +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
5279 +index a6b048ff30e6a..eac0013809c9b 100644
5280 +--- a/net/ipv4/igmp.c
5281 ++++ b/net/ipv4/igmp.c
5282 +@@ -2695,6 +2695,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
5283 + rv = 1;
5284 + } else if (im) {
5285 + if (src_addr) {
5286 ++ spin_lock_bh(&im->lock);
5287 + for (psf = im->sources; psf; psf = psf->sf_next) {
5288 + if (psf->sf_inaddr == src_addr)
5289 + break;
5290 +@@ -2705,6 +2706,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
5291 + im->sfcount[MCAST_EXCLUDE];
5292 + else
5293 + rv = im->sfcount[MCAST_EXCLUDE] != 0;
5294 ++ spin_unlock_bh(&im->lock);
5295 + } else
5296 + rv = 1; /* unspecified source; tentatively allow */
5297 + }
5298 +diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
5299 +index 5ec185a9dcaba..c9f82525bfa45 100644
5300 +--- a/net/ipv4/ip_output.c
5301 ++++ b/net/ipv4/ip_output.c
5302 +@@ -419,8 +419,9 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
5303 + {
5304 + BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) !=
5305 + offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr));
5306 +- memcpy(&iph->saddr, &fl4->saddr,
5307 +- sizeof(fl4->saddr) + sizeof(fl4->daddr));
5308 ++
5309 ++ iph->saddr = fl4->saddr;
5310 ++ iph->daddr = fl4->daddr;
5311 + }
5312 +
5313 + /* Note: skb->sk can be different from sk, in case of tunnels */
5314 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
5315 +index 81901b0529077..d67d424be9192 100644
5316 +--- a/net/ipv4/route.c
5317 ++++ b/net/ipv4/route.c
5318 +@@ -619,18 +619,25 @@ static void fnhe_flush_routes(struct fib_nh_exception *fnhe)
5319 + }
5320 + }
5321 +
5322 +-static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash)
5323 ++static void fnhe_remove_oldest(struct fnhe_hash_bucket *hash)
5324 + {
5325 +- struct fib_nh_exception *fnhe, *oldest;
5326 ++ struct fib_nh_exception __rcu **fnhe_p, **oldest_p;
5327 ++ struct fib_nh_exception *fnhe, *oldest = NULL;
5328 +
5329 +- oldest = rcu_dereference(hash->chain);
5330 +- for (fnhe = rcu_dereference(oldest->fnhe_next); fnhe;
5331 +- fnhe = rcu_dereference(fnhe->fnhe_next)) {
5332 +- if (time_before(fnhe->fnhe_stamp, oldest->fnhe_stamp))
5333 ++ for (fnhe_p = &hash->chain; ; fnhe_p = &fnhe->fnhe_next) {
5334 ++ fnhe = rcu_dereference_protected(*fnhe_p,
5335 ++ lockdep_is_held(&fnhe_lock));
5336 ++ if (!fnhe)
5337 ++ break;
5338 ++ if (!oldest ||
5339 ++ time_before(fnhe->fnhe_stamp, oldest->fnhe_stamp)) {
5340 + oldest = fnhe;
5341 ++ oldest_p = fnhe_p;
5342 ++ }
5343 + }
5344 + fnhe_flush_routes(oldest);
5345 +- return oldest;
5346 ++ *oldest_p = oldest->fnhe_next;
5347 ++ kfree_rcu(oldest, rcu);
5348 + }
5349 +
5350 + static inline u32 fnhe_hashfun(__be32 daddr)
5351 +@@ -707,16 +714,21 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
5352 + if (rt)
5353 + fill_route_from_fnhe(rt, fnhe);
5354 + } else {
5355 +- if (depth > FNHE_RECLAIM_DEPTH)
5356 +- fnhe = fnhe_oldest(hash);
5357 +- else {
5358 +- fnhe = kzalloc(sizeof(*fnhe), GFP_ATOMIC);
5359 +- if (!fnhe)
5360 +- goto out_unlock;
5361 +-
5362 +- fnhe->fnhe_next = hash->chain;
5363 +- rcu_assign_pointer(hash->chain, fnhe);
5364 ++ /* Randomize max depth to avoid some side channels attacks. */
5365 ++ int max_depth = FNHE_RECLAIM_DEPTH +
5366 ++ prandom_u32_max(FNHE_RECLAIM_DEPTH);
5367 ++
5368 ++ while (depth > max_depth) {
5369 ++ fnhe_remove_oldest(hash);
5370 ++ depth--;
5371 + }
5372 ++
5373 ++ fnhe = kzalloc(sizeof(*fnhe), GFP_ATOMIC);
5374 ++ if (!fnhe)
5375 ++ goto out_unlock;
5376 ++
5377 ++ fnhe->fnhe_next = hash->chain;
5378 ++
5379 + fnhe->fnhe_genid = genid;
5380 + fnhe->fnhe_daddr = daddr;
5381 + fnhe->fnhe_gw = gw;
5382 +@@ -724,6 +736,8 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
5383 + fnhe->fnhe_mtu_locked = lock;
5384 + fnhe->fnhe_expires = max(1UL, expires);
5385 +
5386 ++ rcu_assign_pointer(hash->chain, fnhe);
5387 ++
5388 + /* Exception created; mark the cached routes for the nexthop
5389 + * stale, so anyone caching it rechecks if this exception
5390 + * applies to them.
5391 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
5392 +index eb062fab62579..9382caeb721a8 100644
5393 +--- a/net/ipv4/tcp_input.c
5394 ++++ b/net/ipv4/tcp_input.c
5395 +@@ -1225,7 +1225,7 @@ static u8 tcp_sacktag_one(struct sock *sk,
5396 + if (dup_sack && (sacked & TCPCB_RETRANS)) {
5397 + if (tp->undo_marker && tp->undo_retrans > 0 &&
5398 + after(end_seq, tp->undo_marker))
5399 +- tp->undo_retrans--;
5400 ++ tp->undo_retrans = max_t(int, 0, tp->undo_retrans - pcount);
5401 + if (sacked & TCPCB_SACKED_ACKED)
5402 + state->reord = min(fack_count, state->reord);
5403 + }
5404 +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
5405 +index 146a137ee7ef6..744479c8b91f3 100644
5406 +--- a/net/ipv4/tcp_ipv4.c
5407 ++++ b/net/ipv4/tcp_ipv4.c
5408 +@@ -2087,6 +2087,7 @@ static void *tcp_get_idx(struct seq_file *seq, loff_t pos)
5409 + static void *tcp_seek_last_pos(struct seq_file *seq)
5410 + {
5411 + struct tcp_iter_state *st = seq->private;
5412 ++ int bucket = st->bucket;
5413 + int offset = st->offset;
5414 + int orig_num = st->num;
5415 + void *rc = NULL;
5416 +@@ -2097,7 +2098,7 @@ static void *tcp_seek_last_pos(struct seq_file *seq)
5417 + break;
5418 + st->state = TCP_SEQ_STATE_LISTENING;
5419 + rc = listening_get_next(seq, NULL);
5420 +- while (offset-- && rc)
5421 ++ while (offset-- && rc && bucket == st->bucket)
5422 + rc = listening_get_next(seq, rc);
5423 + if (rc)
5424 + break;
5425 +@@ -2108,7 +2109,7 @@ static void *tcp_seek_last_pos(struct seq_file *seq)
5426 + if (st->bucket > tcp_hashinfo.ehash_mask)
5427 + break;
5428 + rc = established_get_first(seq);
5429 +- while (offset-- && rc)
5430 ++ while (offset-- && rc && bucket == st->bucket)
5431 + rc = established_get_next(seq, rc);
5432 + }
5433 +
5434 +diff --git a/net/ipv6/netfilter/nf_socket_ipv6.c b/net/ipv6/netfilter/nf_socket_ipv6.c
5435 +index f14de4b6d639d..58e839e2ce1d3 100644
5436 +--- a/net/ipv6/netfilter/nf_socket_ipv6.c
5437 ++++ b/net/ipv6/netfilter/nf_socket_ipv6.c
5438 +@@ -104,7 +104,7 @@ struct sock *nf_sk_lookup_slow_v6(struct net *net, const struct sk_buff *skb,
5439 + {
5440 + __be16 uninitialized_var(dport), uninitialized_var(sport);
5441 + const struct in6_addr *daddr = NULL, *saddr = NULL;
5442 +- struct ipv6hdr *iph = ipv6_hdr(skb);
5443 ++ struct ipv6hdr *iph = ipv6_hdr(skb), ipv6_var;
5444 + struct sk_buff *data_skb = NULL;
5445 + int doff = 0;
5446 + int thoff = 0, tproto;
5447 +@@ -134,8 +134,6 @@ struct sock *nf_sk_lookup_slow_v6(struct net *net, const struct sk_buff *skb,
5448 + thoff + sizeof(*hp);
5449 +
5450 + } else if (tproto == IPPROTO_ICMPV6) {
5451 +- struct ipv6hdr ipv6_var;
5452 +-
5453 + if (extract_icmp6_fields(skb, thoff, &tproto, &saddr, &daddr,
5454 + &sport, &dport, &ipv6_var))
5455 + return NULL;
5456 +diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
5457 +index 36512fbea1309..84d5650239d92 100644
5458 +--- a/net/l2tp/l2tp_core.c
5459 ++++ b/net/l2tp/l2tp_core.c
5460 +@@ -994,8 +994,10 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
5461 + }
5462 +
5463 + if (tunnel->version == L2TP_HDR_VER_3 &&
5464 +- l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr))
5465 ++ l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) {
5466 ++ l2tp_session_dec_refcount(session);
5467 + goto error;
5468 ++ }
5469 +
5470 + l2tp_recv_common(session, skb, ptr, optr, hdrflags, length, payload_hook);
5471 + l2tp_session_dec_refcount(session);
5472 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
5473 +index c7e8935224c02..e7b63ba8c184b 100644
5474 +--- a/net/mac80211/tx.c
5475 ++++ b/net/mac80211/tx.c
5476 +@@ -3080,7 +3080,9 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
5477 + if (info->control.flags & IEEE80211_TX_CTRL_AMSDU)
5478 + return true;
5479 +
5480 +- if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(*amsdu_hdr)))
5481 ++ if (!ieee80211_amsdu_realloc_pad(local, skb,
5482 ++ sizeof(*amsdu_hdr) +
5483 ++ local->hw.extra_tx_headroom))
5484 + return false;
5485 +
5486 + data = skb_push(skb, sizeof(*amsdu_hdr));
5487 +diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
5488 +index 3e3494c8d42f8..e252f62bb8c20 100644
5489 +--- a/net/netlabel/netlabel_cipso_v4.c
5490 ++++ b/net/netlabel/netlabel_cipso_v4.c
5491 +@@ -156,8 +156,8 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
5492 + return -ENOMEM;
5493 + doi_def->map.std = kzalloc(sizeof(*doi_def->map.std), GFP_KERNEL);
5494 + if (doi_def->map.std == NULL) {
5495 +- ret_val = -ENOMEM;
5496 +- goto add_std_failure;
5497 ++ kfree(doi_def);
5498 ++ return -ENOMEM;
5499 + }
5500 + doi_def->type = CIPSO_V4_MAP_TRANS;
5501 +
5502 +@@ -198,14 +198,14 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
5503 + }
5504 + doi_def->map.std->lvl.local = kcalloc(doi_def->map.std->lvl.local_size,
5505 + sizeof(u32),
5506 +- GFP_KERNEL);
5507 ++ GFP_KERNEL | __GFP_NOWARN);
5508 + if (doi_def->map.std->lvl.local == NULL) {
5509 + ret_val = -ENOMEM;
5510 + goto add_std_failure;
5511 + }
5512 + doi_def->map.std->lvl.cipso = kcalloc(doi_def->map.std->lvl.cipso_size,
5513 + sizeof(u32),
5514 +- GFP_KERNEL);
5515 ++ GFP_KERNEL | __GFP_NOWARN);
5516 + if (doi_def->map.std->lvl.cipso == NULL) {
5517 + ret_val = -ENOMEM;
5518 + goto add_std_failure;
5519 +@@ -273,7 +273,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
5520 + doi_def->map.std->cat.local = kcalloc(
5521 + doi_def->map.std->cat.local_size,
5522 + sizeof(u32),
5523 +- GFP_KERNEL);
5524 ++ GFP_KERNEL | __GFP_NOWARN);
5525 + if (doi_def->map.std->cat.local == NULL) {
5526 + ret_val = -ENOMEM;
5527 + goto add_std_failure;
5528 +@@ -281,7 +281,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
5529 + doi_def->map.std->cat.cipso = kcalloc(
5530 + doi_def->map.std->cat.cipso_size,
5531 + sizeof(u32),
5532 +- GFP_KERNEL);
5533 ++ GFP_KERNEL | __GFP_NOWARN);
5534 + if (doi_def->map.std->cat.cipso == NULL) {
5535 + ret_val = -ENOMEM;
5536 + goto add_std_failure;
5537 +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
5538 +index 140bec3568ec2..955041c547025 100644
5539 +--- a/net/netlink/af_netlink.c
5540 ++++ b/net/netlink/af_netlink.c
5541 +@@ -2476,13 +2476,15 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
5542 + /* errors reported via destination sk->sk_err, but propagate
5543 + * delivery errors if NETLINK_BROADCAST_ERROR flag is set */
5544 + err = nlmsg_multicast(sk, skb, exclude_portid, group, flags);
5545 ++ if (err == -ESRCH)
5546 ++ err = 0;
5547 + }
5548 +
5549 + if (report) {
5550 + int err2;
5551 +
5552 + err2 = nlmsg_unicast(sk, skb, portid);
5553 +- if (!err || err == -ESRCH)
5554 ++ if (!err)
5555 + err = err2;
5556 + }
5557 +
5558 +diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
5559 +index 40fd1ee0095c0..dea125d8aac70 100644
5560 +--- a/net/sched/sch_cbq.c
5561 ++++ b/net/sched/sch_cbq.c
5562 +@@ -1590,7 +1590,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
5563 + err = tcf_block_get(&cl->block, &cl->filter_list);
5564 + if (err) {
5565 + kfree(cl);
5566 +- return err;
5567 ++ goto failure;
5568 + }
5569 +
5570 + if (tca[TCA_RATE]) {
5571 +diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
5572 +index 27dfd85830d82..4f41a1bc59bfe 100644
5573 +--- a/net/sunrpc/auth_gss/svcauth_gss.c
5574 ++++ b/net/sunrpc/auth_gss/svcauth_gss.c
5575 +@@ -1861,7 +1861,7 @@ gss_svc_init_net(struct net *net)
5576 + goto out2;
5577 + return 0;
5578 + out2:
5579 +- destroy_use_gss_proxy_proc_entry(net);
5580 ++ rsi_cache_destroy_net(net);
5581 + out1:
5582 + rsc_cache_destroy_net(net);
5583 + return rv;
5584 +diff --git a/net/tipc/socket.c b/net/tipc/socket.c
5585 +index 2e4d892768f9d..94e74987fe654 100644
5586 +--- a/net/tipc/socket.c
5587 ++++ b/net/tipc/socket.c
5588 +@@ -1775,7 +1775,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
5589 + static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
5590 + u32 dport, struct sk_buff_head *xmitq)
5591 + {
5592 +- unsigned long time_limit = jiffies + 2;
5593 ++ unsigned long time_limit = jiffies + usecs_to_jiffies(20000);
5594 + struct sk_buff *skb;
5595 + unsigned int lim;
5596 + atomic_t *dcnt;
5597 +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
5598 +index 59009739d324b..f30509ff302e9 100644
5599 +--- a/net/unix/af_unix.c
5600 ++++ b/net/unix/af_unix.c
5601 +@@ -2742,7 +2742,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
5602 +
5603 + other = unix_peer(sk);
5604 + if (other && unix_peer(other) != sk &&
5605 +- unix_recvq_full(other) &&
5606 ++ unix_recvq_full_lockless(other) &&
5607 + unix_dgram_peer_wake_me(sk, other))
5608 + writable = 0;
5609 +
5610 +diff --git a/security/integrity/ima/ima_mok.c b/security/integrity/ima/ima_mok.c
5611 +index 3e7a1523663b8..daad75ee74d9f 100644
5612 +--- a/security/integrity/ima/ima_mok.c
5613 ++++ b/security/integrity/ima/ima_mok.c
5614 +@@ -26,7 +26,7 @@ struct key *ima_blacklist_keyring;
5615 + /*
5616 + * Allocate the IMA blacklist keyring
5617 + */
5618 +-__init int ima_mok_init(void)
5619 ++static __init int ima_mok_init(void)
5620 + {
5621 + struct key_restriction *restriction;
5622 +
5623 +diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
5624 +index a9c20821a726c..c8e82d6a12b52 100644
5625 +--- a/security/smack/smack_access.c
5626 ++++ b/security/smack/smack_access.c
5627 +@@ -85,23 +85,22 @@ int log_policy = SMACK_AUDIT_DENIED;
5628 + int smk_access_entry(char *subject_label, char *object_label,
5629 + struct list_head *rule_list)
5630 + {
5631 +- int may = -ENOENT;
5632 + struct smack_rule *srp;
5633 +
5634 + list_for_each_entry_rcu(srp, rule_list, list) {
5635 + if (srp->smk_object->smk_known == object_label &&
5636 + srp->smk_subject->smk_known == subject_label) {
5637 +- may = srp->smk_access;
5638 +- break;
5639 ++ int may = srp->smk_access;
5640 ++ /*
5641 ++ * MAY_WRITE implies MAY_LOCK.
5642 ++ */
5643 ++ if ((may & MAY_WRITE) == MAY_WRITE)
5644 ++ may |= MAY_LOCK;
5645 ++ return may;
5646 + }
5647 + }
5648 +
5649 +- /*
5650 +- * MAY_WRITE implies MAY_LOCK.
5651 +- */
5652 +- if ((may & MAY_WRITE) == MAY_WRITE)
5653 +- may |= MAY_LOCK;
5654 +- return may;
5655 ++ return -ENOENT;
5656 + }
5657 +
5658 + /**
5659 +diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
5660 +index c412f2a909c9c..82a7387ba9d24 100644
5661 +--- a/sound/core/pcm_lib.c
5662 ++++ b/sound/core/pcm_lib.c
5663 +@@ -1757,7 +1757,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
5664 + channels = params_channels(params);
5665 + frame_size = snd_pcm_format_size(format, channels);
5666 + if (frame_size > 0)
5667 +- params->fifo_size /= (unsigned)frame_size;
5668 ++ params->fifo_size /= frame_size;
5669 + }
5670 + return 0;
5671 + }
5672 +diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
5673 +index 4a76b099a5089..e389ecf06e633 100644
5674 +--- a/sound/soc/intel/boards/bytcr_rt5640.c
5675 ++++ b/sound/soc/intel/boards/bytcr_rt5640.c
5676 +@@ -226,9 +226,6 @@ static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = {
5677 + static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
5678 + {"Headphone", NULL, "Platform Clock"},
5679 + {"Headset Mic", NULL, "Platform Clock"},
5680 +- {"Internal Mic", NULL, "Platform Clock"},
5681 +- {"Speaker", NULL, "Platform Clock"},
5682 +-
5683 + {"Headset Mic", NULL, "MICBIAS1"},
5684 + {"IN2P", NULL, "Headset Mic"},
5685 + {"Headphone", NULL, "HPOL"},
5686 +@@ -236,19 +233,23 @@ static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
5687 + };
5688 +
5689 + static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = {
5690 ++ {"Internal Mic", NULL, "Platform Clock"},
5691 + {"DMIC1", NULL, "Internal Mic"},
5692 + };
5693 +
5694 + static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = {
5695 ++ {"Internal Mic", NULL, "Platform Clock"},
5696 + {"DMIC2", NULL, "Internal Mic"},
5697 + };
5698 +
5699 + static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = {
5700 ++ {"Internal Mic", NULL, "Platform Clock"},
5701 + {"Internal Mic", NULL, "MICBIAS1"},
5702 + {"IN1P", NULL, "Internal Mic"},
5703 + };
5704 +
5705 + static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = {
5706 ++ {"Internal Mic", NULL, "Platform Clock"},
5707 + {"Internal Mic", NULL, "MICBIAS1"},
5708 + {"IN3P", NULL, "Internal Mic"},
5709 + };
5710 +@@ -290,6 +291,7 @@ static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = {
5711 + };
5712 +
5713 + static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
5714 ++ {"Speaker", NULL, "Platform Clock"},
5715 + {"Speaker", NULL, "SPOLP"},
5716 + {"Speaker", NULL, "SPOLN"},
5717 + {"Speaker", NULL, "SPORP"},
5718 +@@ -297,6 +299,7 @@ static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
5719 + };
5720 +
5721 + static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = {
5722 ++ {"Speaker", NULL, "Platform Clock"},
5723 + {"Speaker", NULL, "SPOLP"},
5724 + {"Speaker", NULL, "SPOLN"},
5725 + };
5726 +diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
5727 +index 0e07e3dea7de4..8d1a7114f6c28 100644
5728 +--- a/sound/soc/rockchip/rockchip_i2s.c
5729 ++++ b/sound/soc/rockchip/rockchip_i2s.c
5730 +@@ -188,7 +188,9 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
5731 + {
5732 + struct rk_i2s_dev *i2s = to_info(cpu_dai);
5733 + unsigned int mask = 0, val = 0;
5734 ++ int ret = 0;
5735 +
5736 ++ pm_runtime_get_sync(cpu_dai->dev);
5737 + mask = I2S_CKR_MSS_MASK;
5738 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
5739 + case SND_SOC_DAIFMT_CBS_CFS:
5740 +@@ -201,7 +203,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
5741 + i2s->is_master_mode = false;
5742 + break;
5743 + default:
5744 +- return -EINVAL;
5745 ++ ret = -EINVAL;
5746 ++ goto err_pm_put;
5747 + }
5748 +
5749 + regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
5750 +@@ -215,7 +218,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
5751 + val = I2S_CKR_CKP_POS;
5752 + break;
5753 + default:
5754 +- return -EINVAL;
5755 ++ ret = -EINVAL;
5756 ++ goto err_pm_put;
5757 + }
5758 +
5759 + regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
5760 +@@ -231,14 +235,15 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
5761 + case SND_SOC_DAIFMT_I2S:
5762 + val = I2S_TXCR_IBM_NORMAL;
5763 + break;
5764 +- case SND_SOC_DAIFMT_DSP_A: /* PCM no delay mode */
5765 +- val = I2S_TXCR_TFS_PCM;
5766 +- break;
5767 +- case SND_SOC_DAIFMT_DSP_B: /* PCM delay 1 mode */
5768 ++ case SND_SOC_DAIFMT_DSP_A: /* PCM delay 1 bit mode */
5769 + val = I2S_TXCR_TFS_PCM | I2S_TXCR_PBM_MODE(1);
5770 + break;
5771 ++ case SND_SOC_DAIFMT_DSP_B: /* PCM no delay mode */
5772 ++ val = I2S_TXCR_TFS_PCM;
5773 ++ break;
5774 + default:
5775 +- return -EINVAL;
5776 ++ ret = -EINVAL;
5777 ++ goto err_pm_put;
5778 + }
5779 +
5780 + regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val);
5781 +@@ -254,19 +259,23 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
5782 + case SND_SOC_DAIFMT_I2S:
5783 + val = I2S_RXCR_IBM_NORMAL;
5784 + break;
5785 +- case SND_SOC_DAIFMT_DSP_A: /* PCM no delay mode */
5786 +- val = I2S_RXCR_TFS_PCM;
5787 +- break;
5788 +- case SND_SOC_DAIFMT_DSP_B: /* PCM delay 1 mode */
5789 ++ case SND_SOC_DAIFMT_DSP_A: /* PCM delay 1 bit mode */
5790 + val = I2S_RXCR_TFS_PCM | I2S_RXCR_PBM_MODE(1);
5791 + break;
5792 ++ case SND_SOC_DAIFMT_DSP_B: /* PCM no delay mode */
5793 ++ val = I2S_RXCR_TFS_PCM;
5794 ++ break;
5795 + default:
5796 +- return -EINVAL;
5797 ++ ret = -EINVAL;
5798 ++ goto err_pm_put;
5799 + }
5800 +
5801 + regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val);
5802 +
5803 +- return 0;
5804 ++err_pm_put:
5805 ++ pm_runtime_put(cpu_dai->dev);
5806 ++
5807 ++ return ret;
5808 + }
5809 +
5810 + static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
5811 +diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
5812 +index 96c6238a4a1f4..3f503ad37a2ba 100644
5813 +--- a/tools/testing/selftests/bpf/test_maps.c
5814 ++++ b/tools/testing/selftests/bpf/test_maps.c
5815 +@@ -730,7 +730,7 @@ static void test_sockmap(int tasks, void *data)
5816 +
5817 + FD_ZERO(&w);
5818 + FD_SET(sfd[3], &w);
5819 +- to.tv_sec = 1;
5820 ++ to.tv_sec = 30;
5821 + to.tv_usec = 0;
5822 + s = select(sfd[3] + 1, &w, NULL, NULL, &to);
5823 + if (s == -1) {