Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.19 commit in: /
Date: Wed, 08 May 2019 10:06:21
Message-Id: 1557309960.af12f60dec7a14cd24cf8f9f064b310ac3a90b68.mpagano@gentoo
1 commit: af12f60dec7a14cd24cf8f9f064b310ac3a90b68
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 8 10:06:00 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed May 8 10:06:00 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=af12f60d
7
8 Linux patch 4.19.41
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1040_linux-4.19.41.patch | 3563 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 3567 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 27107b1..ba19d17 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -203,6 +203,10 @@ Patch: 1039_linux-4.19.40.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.19.40
23
24 +Patch: 1040_linux-4.19.41.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.19.41
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/1040_linux-4.19.41.patch b/1040_linux-4.19.41.patch
33 new file mode 100644
34 index 0000000..6dabf37
35 --- /dev/null
36 +++ b/1040_linux-4.19.41.patch
37 @@ -0,0 +1,3563 @@
38 +diff --git a/Documentation/driver-api/usb/power-management.rst b/Documentation/driver-api/usb/power-management.rst
39 +index 79beb807996b..4a74cf6f2797 100644
40 +--- a/Documentation/driver-api/usb/power-management.rst
41 ++++ b/Documentation/driver-api/usb/power-management.rst
42 +@@ -370,11 +370,15 @@ autosuspend the interface's device. When the usage counter is = 0
43 + then the interface is considered to be idle, and the kernel may
44 + autosuspend the device.
45 +
46 +-Drivers need not be concerned about balancing changes to the usage
47 +-counter; the USB core will undo any remaining "get"s when a driver
48 +-is unbound from its interface. As a corollary, drivers must not call
49 +-any of the ``usb_autopm_*`` functions after their ``disconnect``
50 +-routine has returned.
51 ++Drivers must be careful to balance their overall changes to the usage
52 ++counter. Unbalanced "get"s will remain in effect when a driver is
53 ++unbound from its interface, preventing the device from going into
54 ++runtime suspend should the interface be bound to a driver again. On
55 ++the other hand, drivers are allowed to achieve this balance by calling
56 ++the ``usb_autopm_*`` functions even after their ``disconnect`` routine
57 ++has returned -- say from within a work-queue routine -- provided they
58 ++retain an active reference to the interface (via ``usb_get_intf`` and
59 ++``usb_put_intf``).
60 +
61 + Drivers using the async routines are responsible for their own
62 + synchronization and mutual exclusion.
63 +diff --git a/Makefile b/Makefile
64 +index 3822720a8a1c..ba3b8504b689 100644
65 +--- a/Makefile
66 ++++ b/Makefile
67 +@@ -1,7 +1,7 @@
68 + # SPDX-License-Identifier: GPL-2.0
69 + VERSION = 4
70 + PATCHLEVEL = 19
71 +-SUBLEVEL = 40
72 ++SUBLEVEL = 41
73 + EXTRAVERSION =
74 + NAME = "People's Front"
75 +
76 +diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
77 +index e6a36a792bae..c706adf4aed2 100644
78 +--- a/arch/arm/boot/dts/rk3288.dtsi
79 ++++ b/arch/arm/boot/dts/rk3288.dtsi
80 +@@ -1261,27 +1261,27 @@
81 + gpu_opp_table: gpu-opp-table {
82 + compatible = "operating-points-v2";
83 +
84 +- opp@100000000 {
85 ++ opp-100000000 {
86 + opp-hz = /bits/ 64 <100000000>;
87 + opp-microvolt = <950000>;
88 + };
89 +- opp@200000000 {
90 ++ opp-200000000 {
91 + opp-hz = /bits/ 64 <200000000>;
92 + opp-microvolt = <950000>;
93 + };
94 +- opp@300000000 {
95 ++ opp-300000000 {
96 + opp-hz = /bits/ 64 <300000000>;
97 + opp-microvolt = <1000000>;
98 + };
99 +- opp@400000000 {
100 ++ opp-400000000 {
101 + opp-hz = /bits/ 64 <400000000>;
102 + opp-microvolt = <1100000>;
103 + };
104 +- opp@500000000 {
105 ++ opp-500000000 {
106 + opp-hz = /bits/ 64 <500000000>;
107 + opp-microvolt = <1200000>;
108 + };
109 +- opp@600000000 {
110 ++ opp-600000000 {
111 + opp-hz = /bits/ 64 <600000000>;
112 + opp-microvolt = <1250000>;
113 + };
114 +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
115 +index 32fae4dbd63b..0921e2c10edf 100644
116 +--- a/arch/arm/mach-at91/pm.c
117 ++++ b/arch/arm/mach-at91/pm.c
118 +@@ -594,13 +594,13 @@ static int __init at91_pm_backup_init(void)
119 +
120 + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
121 + if (!np)
122 +- goto securam_fail;
123 ++ goto securam_fail_no_ref_dev;
124 +
125 + pdev = of_find_device_by_node(np);
126 + of_node_put(np);
127 + if (!pdev) {
128 + pr_warn("%s: failed to find securam device!\n", __func__);
129 +- goto securam_fail;
130 ++ goto securam_fail_no_ref_dev;
131 + }
132 +
133 + sram_pool = gen_pool_get(&pdev->dev, NULL);
134 +@@ -623,6 +623,8 @@ static int __init at91_pm_backup_init(void)
135 + return 0;
136 +
137 + securam_fail:
138 ++ put_device(&pdev->dev);
139 ++securam_fail_no_ref_dev:
140 + iounmap(pm_data.sfrbu);
141 + pm_data.sfrbu = NULL;
142 + return ret;
143 +diff --git a/arch/arm/mach-iop13xx/setup.c b/arch/arm/mach-iop13xx/setup.c
144 +index 53c316f7301e..fe4932fda01d 100644
145 +--- a/arch/arm/mach-iop13xx/setup.c
146 ++++ b/arch/arm/mach-iop13xx/setup.c
147 +@@ -300,7 +300,7 @@ static struct resource iop13xx_adma_2_resources[] = {
148 + }
149 + };
150 +
151 +-static u64 iop13xx_adma_dmamask = DMA_BIT_MASK(64);
152 ++static u64 iop13xx_adma_dmamask = DMA_BIT_MASK(32);
153 + static struct iop_adma_platform_data iop13xx_adma_0_data = {
154 + .hw_id = 0,
155 + .pool_size = PAGE_SIZE,
156 +@@ -324,7 +324,7 @@ static struct platform_device iop13xx_adma_0_channel = {
157 + .resource = iop13xx_adma_0_resources,
158 + .dev = {
159 + .dma_mask = &iop13xx_adma_dmamask,
160 +- .coherent_dma_mask = DMA_BIT_MASK(64),
161 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
162 + .platform_data = (void *) &iop13xx_adma_0_data,
163 + },
164 + };
165 +@@ -336,7 +336,7 @@ static struct platform_device iop13xx_adma_1_channel = {
166 + .resource = iop13xx_adma_1_resources,
167 + .dev = {
168 + .dma_mask = &iop13xx_adma_dmamask,
169 +- .coherent_dma_mask = DMA_BIT_MASK(64),
170 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
171 + .platform_data = (void *) &iop13xx_adma_1_data,
172 + },
173 + };
174 +@@ -348,7 +348,7 @@ static struct platform_device iop13xx_adma_2_channel = {
175 + .resource = iop13xx_adma_2_resources,
176 + .dev = {
177 + .dma_mask = &iop13xx_adma_dmamask,
178 +- .coherent_dma_mask = DMA_BIT_MASK(64),
179 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
180 + .platform_data = (void *) &iop13xx_adma_2_data,
181 + },
182 + };
183 +diff --git a/arch/arm/mach-iop13xx/tpmi.c b/arch/arm/mach-iop13xx/tpmi.c
184 +index db511ec2b1df..116feb6b261e 100644
185 +--- a/arch/arm/mach-iop13xx/tpmi.c
186 ++++ b/arch/arm/mach-iop13xx/tpmi.c
187 +@@ -152,7 +152,7 @@ static struct resource iop13xx_tpmi_3_resources[] = {
188 + }
189 + };
190 +
191 +-u64 iop13xx_tpmi_mask = DMA_BIT_MASK(64);
192 ++u64 iop13xx_tpmi_mask = DMA_BIT_MASK(32);
193 + static struct platform_device iop13xx_tpmi_0_device = {
194 + .name = "iop-tpmi",
195 + .id = 0,
196 +@@ -160,7 +160,7 @@ static struct platform_device iop13xx_tpmi_0_device = {
197 + .resource = iop13xx_tpmi_0_resources,
198 + .dev = {
199 + .dma_mask = &iop13xx_tpmi_mask,
200 +- .coherent_dma_mask = DMA_BIT_MASK(64),
201 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
202 + },
203 + };
204 +
205 +@@ -171,7 +171,7 @@ static struct platform_device iop13xx_tpmi_1_device = {
206 + .resource = iop13xx_tpmi_1_resources,
207 + .dev = {
208 + .dma_mask = &iop13xx_tpmi_mask,
209 +- .coherent_dma_mask = DMA_BIT_MASK(64),
210 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
211 + },
212 + };
213 +
214 +@@ -182,7 +182,7 @@ static struct platform_device iop13xx_tpmi_2_device = {
215 + .resource = iop13xx_tpmi_2_resources,
216 + .dev = {
217 + .dma_mask = &iop13xx_tpmi_mask,
218 +- .coherent_dma_mask = DMA_BIT_MASK(64),
219 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
220 + },
221 + };
222 +
223 +@@ -193,7 +193,7 @@ static struct platform_device iop13xx_tpmi_3_device = {
224 + .resource = iop13xx_tpmi_3_resources,
225 + .dev = {
226 + .dma_mask = &iop13xx_tpmi_mask,
227 +- .coherent_dma_mask = DMA_BIT_MASK(64),
228 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
229 + },
230 + };
231 +
232 +diff --git a/arch/arm/plat-iop/adma.c b/arch/arm/plat-iop/adma.c
233 +index a4d1f8de3b5b..d9612221e484 100644
234 +--- a/arch/arm/plat-iop/adma.c
235 ++++ b/arch/arm/plat-iop/adma.c
236 +@@ -143,7 +143,7 @@ struct platform_device iop3xx_dma_0_channel = {
237 + .resource = iop3xx_dma_0_resources,
238 + .dev = {
239 + .dma_mask = &iop3xx_adma_dmamask,
240 +- .coherent_dma_mask = DMA_BIT_MASK(64),
241 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
242 + .platform_data = (void *) &iop3xx_dma_0_data,
243 + },
244 + };
245 +@@ -155,7 +155,7 @@ struct platform_device iop3xx_dma_1_channel = {
246 + .resource = iop3xx_dma_1_resources,
247 + .dev = {
248 + .dma_mask = &iop3xx_adma_dmamask,
249 +- .coherent_dma_mask = DMA_BIT_MASK(64),
250 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
251 + .platform_data = (void *) &iop3xx_dma_1_data,
252 + },
253 + };
254 +@@ -167,7 +167,7 @@ struct platform_device iop3xx_aau_channel = {
255 + .resource = iop3xx_aau_resources,
256 + .dev = {
257 + .dma_mask = &iop3xx_adma_dmamask,
258 +- .coherent_dma_mask = DMA_BIT_MASK(64),
259 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
260 + .platform_data = (void *) &iop3xx_aau_data,
261 + },
262 + };
263 +diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
264 +index a2399fd66e97..1e970873439c 100644
265 +--- a/arch/arm/plat-orion/common.c
266 ++++ b/arch/arm/plat-orion/common.c
267 +@@ -622,7 +622,7 @@ static struct platform_device orion_xor0_shared = {
268 + .resource = orion_xor0_shared_resources,
269 + .dev = {
270 + .dma_mask = &orion_xor_dmamask,
271 +- .coherent_dma_mask = DMA_BIT_MASK(64),
272 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
273 + .platform_data = &orion_xor0_pdata,
274 + },
275 + };
276 +@@ -683,7 +683,7 @@ static struct platform_device orion_xor1_shared = {
277 + .resource = orion_xor1_shared_resources,
278 + .dev = {
279 + .dma_mask = &orion_xor_dmamask,
280 +- .coherent_dma_mask = DMA_BIT_MASK(64),
281 ++ .coherent_dma_mask = DMA_BIT_MASK(32),
282 + .platform_data = &orion_xor1_pdata,
283 + },
284 + };
285 +diff --git a/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts b/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts
286 +index 246c317f6a68..91061d9cf78b 100644
287 +--- a/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts
288 ++++ b/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts
289 +@@ -94,8 +94,8 @@
290 + snps,reset-gpio = <&gpio1 RK_PC2 GPIO_ACTIVE_LOW>;
291 + snps,reset-active-low;
292 + snps,reset-delays-us = <0 10000 50000>;
293 +- tx_delay = <0x25>;
294 +- rx_delay = <0x11>;
295 ++ tx_delay = <0x24>;
296 ++ rx_delay = <0x18>;
297 + status = "okay";
298 + };
299 +
300 +diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
301 +index 5ba4465e44f0..ea94cf8f9dc6 100644
302 +--- a/arch/arm64/kernel/sdei.c
303 ++++ b/arch/arm64/kernel/sdei.c
304 +@@ -94,6 +94,9 @@ static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
305 + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
306 + unsigned long high = low + SDEI_STACK_SIZE;
307 +
308 ++ if (!low)
309 ++ return false;
310 ++
311 + if (sp < low || sp >= high)
312 + return false;
313 +
314 +@@ -111,6 +114,9 @@ static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info)
315 + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
316 + unsigned long high = low + SDEI_STACK_SIZE;
317 +
318 ++ if (!low)
319 ++ return false;
320 ++
321 + if (sp < low || sp >= high)
322 + return false;
323 +
324 +diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
325 +index 683b5b3805bd..cd381e2291df 100644
326 +--- a/arch/powerpc/kernel/kvm.c
327 ++++ b/arch/powerpc/kernel/kvm.c
328 +@@ -22,6 +22,7 @@
329 + #include <linux/kvm_host.h>
330 + #include <linux/init.h>
331 + #include <linux/export.h>
332 ++#include <linux/kmemleak.h>
333 + #include <linux/kvm_para.h>
334 + #include <linux/slab.h>
335 + #include <linux/of.h>
336 +@@ -712,6 +713,12 @@ static void kvm_use_magic_page(void)
337 +
338 + static __init void kvm_free_tmp(void)
339 + {
340 ++ /*
341 ++ * Inform kmemleak about the hole in the .bss section since the
342 ++ * corresponding pages will be unmapped with DEBUG_PAGEALLOC=y.
343 ++ */
344 ++ kmemleak_free_part(&kvm_tmp[kvm_tmp_index],
345 ++ ARRAY_SIZE(kvm_tmp) - kvm_tmp_index);
346 + free_reserved_area(&kvm_tmp[kvm_tmp_index],
347 + &kvm_tmp[ARRAY_SIZE(kvm_tmp)], -1, NULL);
348 + }
349 +diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
350 +index 4f213ba33491..53e9b58e83c2 100644
351 +--- a/arch/powerpc/mm/slice.c
352 ++++ b/arch/powerpc/mm/slice.c
353 +@@ -31,6 +31,7 @@
354 + #include <linux/spinlock.h>
355 + #include <linux/export.h>
356 + #include <linux/hugetlb.h>
357 ++#include <linux/security.h>
358 + #include <asm/mman.h>
359 + #include <asm/mmu.h>
360 + #include <asm/copro.h>
361 +@@ -376,6 +377,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
362 + int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT);
363 + unsigned long addr, found, prev;
364 + struct vm_unmapped_area_info info;
365 ++ unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr);
366 +
367 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
368 + info.length = len;
369 +@@ -392,7 +394,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
370 + if (high_limit > DEFAULT_MAP_WINDOW)
371 + addr += mm->context.slb_addr_limit - DEFAULT_MAP_WINDOW;
372 +
373 +- while (addr > PAGE_SIZE) {
374 ++ while (addr > min_addr) {
375 + info.high_limit = addr;
376 + if (!slice_scan_available(addr - 1, available, 0, &addr))
377 + continue;
378 +@@ -404,8 +406,8 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
379 + * Check if we need to reduce the range, or if we can
380 + * extend it to cover the previous available slice.
381 + */
382 +- if (addr < PAGE_SIZE)
383 +- addr = PAGE_SIZE;
384 ++ if (addr < min_addr)
385 ++ addr = min_addr;
386 + else if (slice_scan_available(addr - 1, available, 0, &prev)) {
387 + addr = prev;
388 + goto prev_slice;
389 +@@ -527,7 +529,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
390 + addr = _ALIGN_UP(addr, page_size);
391 + slice_dbg(" aligned addr=%lx\n", addr);
392 + /* Ignore hint if it's too large or overlaps a VMA */
393 +- if (addr > high_limit - len ||
394 ++ if (addr > high_limit - len || addr < mmap_min_addr ||
395 + !slice_area_is_free(mm, addr, len))
396 + addr = 0;
397 + }
398 +diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
399 +index 8c3e3e3c8be1..f0ea3156192d 100644
400 +--- a/arch/riscv/include/asm/uaccess.h
401 ++++ b/arch/riscv/include/asm/uaccess.h
402 +@@ -307,7 +307,7 @@ do { \
403 + " .balign 4\n" \
404 + "4:\n" \
405 + " li %0, %6\n" \
406 +- " jump 2b, %1\n" \
407 ++ " jump 3b, %1\n" \
408 + " .previous\n" \
409 + " .section __ex_table,\"a\"\n" \
410 + " .balign " RISCV_SZPTR "\n" \
411 +diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
412 +index 26789ad28193..cb99df514a1c 100644
413 +--- a/arch/sh/boards/of-generic.c
414 ++++ b/arch/sh/boards/of-generic.c
415 +@@ -175,10 +175,10 @@ static struct sh_machine_vector __initmv sh_of_generic_mv = {
416 +
417 + struct sh_clk_ops;
418 +
419 +-void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
420 ++void __init __weak arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
421 + {
422 + }
423 +
424 +-void __init plat_irq_setup(void)
425 ++void __init __weak plat_irq_setup(void)
426 + {
427 + }
428 +diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
429 +index 263af6312329..27ade3cb6482 100644
430 +--- a/arch/x86/events/amd/core.c
431 ++++ b/arch/x86/events/amd/core.c
432 +@@ -116,6 +116,110 @@ static __initconst const u64 amd_hw_cache_event_ids
433 + },
434 + };
435 +
436 ++static __initconst const u64 amd_hw_cache_event_ids_f17h
437 ++ [PERF_COUNT_HW_CACHE_MAX]
438 ++ [PERF_COUNT_HW_CACHE_OP_MAX]
439 ++ [PERF_COUNT_HW_CACHE_RESULT_MAX] = {
440 ++[C(L1D)] = {
441 ++ [C(OP_READ)] = {
442 ++ [C(RESULT_ACCESS)] = 0x0040, /* Data Cache Accesses */
443 ++ [C(RESULT_MISS)] = 0xc860, /* L2$ access from DC Miss */
444 ++ },
445 ++ [C(OP_WRITE)] = {
446 ++ [C(RESULT_ACCESS)] = 0,
447 ++ [C(RESULT_MISS)] = 0,
448 ++ },
449 ++ [C(OP_PREFETCH)] = {
450 ++ [C(RESULT_ACCESS)] = 0xff5a, /* h/w prefetch DC Fills */
451 ++ [C(RESULT_MISS)] = 0,
452 ++ },
453 ++},
454 ++[C(L1I)] = {
455 ++ [C(OP_READ)] = {
456 ++ [C(RESULT_ACCESS)] = 0x0080, /* Instruction cache fetches */
457 ++ [C(RESULT_MISS)] = 0x0081, /* Instruction cache misses */
458 ++ },
459 ++ [C(OP_WRITE)] = {
460 ++ [C(RESULT_ACCESS)] = -1,
461 ++ [C(RESULT_MISS)] = -1,
462 ++ },
463 ++ [C(OP_PREFETCH)] = {
464 ++ [C(RESULT_ACCESS)] = 0,
465 ++ [C(RESULT_MISS)] = 0,
466 ++ },
467 ++},
468 ++[C(LL)] = {
469 ++ [C(OP_READ)] = {
470 ++ [C(RESULT_ACCESS)] = 0,
471 ++ [C(RESULT_MISS)] = 0,
472 ++ },
473 ++ [C(OP_WRITE)] = {
474 ++ [C(RESULT_ACCESS)] = 0,
475 ++ [C(RESULT_MISS)] = 0,
476 ++ },
477 ++ [C(OP_PREFETCH)] = {
478 ++ [C(RESULT_ACCESS)] = 0,
479 ++ [C(RESULT_MISS)] = 0,
480 ++ },
481 ++},
482 ++[C(DTLB)] = {
483 ++ [C(OP_READ)] = {
484 ++ [C(RESULT_ACCESS)] = 0xff45, /* All L2 DTLB accesses */
485 ++ [C(RESULT_MISS)] = 0xf045, /* L2 DTLB misses (PT walks) */
486 ++ },
487 ++ [C(OP_WRITE)] = {
488 ++ [C(RESULT_ACCESS)] = 0,
489 ++ [C(RESULT_MISS)] = 0,
490 ++ },
491 ++ [C(OP_PREFETCH)] = {
492 ++ [C(RESULT_ACCESS)] = 0,
493 ++ [C(RESULT_MISS)] = 0,
494 ++ },
495 ++},
496 ++[C(ITLB)] = {
497 ++ [C(OP_READ)] = {
498 ++ [C(RESULT_ACCESS)] = 0x0084, /* L1 ITLB misses, L2 ITLB hits */
499 ++ [C(RESULT_MISS)] = 0xff85, /* L1 ITLB misses, L2 misses */
500 ++ },
501 ++ [C(OP_WRITE)] = {
502 ++ [C(RESULT_ACCESS)] = -1,
503 ++ [C(RESULT_MISS)] = -1,
504 ++ },
505 ++ [C(OP_PREFETCH)] = {
506 ++ [C(RESULT_ACCESS)] = -1,
507 ++ [C(RESULT_MISS)] = -1,
508 ++ },
509 ++},
510 ++[C(BPU)] = {
511 ++ [C(OP_READ)] = {
512 ++ [C(RESULT_ACCESS)] = 0x00c2, /* Retired Branch Instr. */
513 ++ [C(RESULT_MISS)] = 0x00c3, /* Retired Mispredicted BI */
514 ++ },
515 ++ [C(OP_WRITE)] = {
516 ++ [C(RESULT_ACCESS)] = -1,
517 ++ [C(RESULT_MISS)] = -1,
518 ++ },
519 ++ [C(OP_PREFETCH)] = {
520 ++ [C(RESULT_ACCESS)] = -1,
521 ++ [C(RESULT_MISS)] = -1,
522 ++ },
523 ++},
524 ++[C(NODE)] = {
525 ++ [C(OP_READ)] = {
526 ++ [C(RESULT_ACCESS)] = 0,
527 ++ [C(RESULT_MISS)] = 0,
528 ++ },
529 ++ [C(OP_WRITE)] = {
530 ++ [C(RESULT_ACCESS)] = -1,
531 ++ [C(RESULT_MISS)] = -1,
532 ++ },
533 ++ [C(OP_PREFETCH)] = {
534 ++ [C(RESULT_ACCESS)] = -1,
535 ++ [C(RESULT_MISS)] = -1,
536 ++ },
537 ++},
538 ++};
539 ++
540 + /*
541 + * AMD Performance Monitor K7 and later, up to and including Family 16h:
542 + */
543 +@@ -861,9 +965,10 @@ __init int amd_pmu_init(void)
544 + x86_pmu.amd_nb_constraints = 0;
545 + }
546 +
547 +- /* Events are common for all AMDs */
548 +- memcpy(hw_cache_event_ids, amd_hw_cache_event_ids,
549 +- sizeof(hw_cache_event_ids));
550 ++ if (boot_cpu_data.x86 >= 0x17)
551 ++ memcpy(hw_cache_event_ids, amd_hw_cache_event_ids_f17h, sizeof(hw_cache_event_ids));
552 ++ else
553 ++ memcpy(hw_cache_event_ids, amd_hw_cache_event_ids, sizeof(hw_cache_event_ids));
554 +
555 + return 0;
556 + }
557 +diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
558 +index f34d89c01edc..06f7c04a44e2 100644
559 +--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
560 ++++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
561 +@@ -165,6 +165,11 @@ static struct severity {
562 + SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_DATA),
563 + KERNEL
564 + ),
565 ++ MCESEV(
566 ++ PANIC, "Instruction fetch error in kernel",
567 ++ SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_INSTR),
568 ++ KERNEL
569 ++ ),
570 + #endif
571 + MCESEV(
572 + PANIC, "Action required: unknown MCACOD",
573 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
574 +index 813cb60eb401..8dd9208ae4de 100644
575 +--- a/arch/x86/kvm/svm.c
576 ++++ b/arch/x86/kvm/svm.c
577 +@@ -6789,7 +6789,8 @@ static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec)
578 + struct page **src_p, **dst_p;
579 + struct kvm_sev_dbg debug;
580 + unsigned long n;
581 +- int ret, size;
582 ++ unsigned int size;
583 ++ int ret;
584 +
585 + if (!sev_guest(kvm))
586 + return -ENOTTY;
587 +@@ -6797,6 +6798,11 @@ static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec)
588 + if (copy_from_user(&debug, (void __user *)(uintptr_t)argp->data, sizeof(debug)))
589 + return -EFAULT;
590 +
591 ++ if (!debug.len || debug.src_uaddr + debug.len < debug.src_uaddr)
592 ++ return -EINVAL;
593 ++ if (!debug.dst_uaddr)
594 ++ return -EINVAL;
595 ++
596 + vaddr = debug.src_uaddr;
597 + size = debug.len;
598 + vaddr_end = vaddr + size;
599 +@@ -6847,8 +6853,8 @@ static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec)
600 + dst_vaddr,
601 + len, &argp->error);
602 +
603 +- sev_unpin_memory(kvm, src_p, 1);
604 +- sev_unpin_memory(kvm, dst_p, 1);
605 ++ sev_unpin_memory(kvm, src_p, n);
606 ++ sev_unpin_memory(kvm, dst_p, n);
607 +
608 + if (ret)
609 + goto err;
610 +diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
611 +index d883869437b5..fb5f29c60019 100644
612 +--- a/arch/x86/mm/init.c
613 ++++ b/arch/x86/mm/init.c
614 +@@ -6,6 +6,7 @@
615 + #include <linux/bootmem.h> /* for max_low_pfn */
616 + #include <linux/swapfile.h>
617 + #include <linux/swapops.h>
618 ++#include <linux/kmemleak.h>
619 +
620 + #include <asm/set_memory.h>
621 + #include <asm/e820/api.h>
622 +@@ -767,6 +768,11 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
623 + if (debug_pagealloc_enabled()) {
624 + pr_info("debug: unmapping init [mem %#010lx-%#010lx]\n",
625 + begin, end - 1);
626 ++ /*
627 ++ * Inform kmemleak about the hole in the memory since the
628 ++ * corresponding pages will be unmapped.
629 ++ */
630 ++ kmemleak_free_part((void *)begin, end - begin);
631 + set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
632 + } else {
633 + /*
634 +diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
635 +index 61db77b0eda9..0988971069c9 100644
636 +--- a/arch/x86/mm/kaslr.c
637 ++++ b/arch/x86/mm/kaslr.c
638 +@@ -93,7 +93,7 @@ void __init kernel_randomize_memory(void)
639 + if (!kaslr_memory_enabled())
640 + return;
641 +
642 +- kaslr_regions[0].size_tb = 1 << (__PHYSICAL_MASK_SHIFT - TB_SHIFT);
643 ++ kaslr_regions[0].size_tb = 1 << (MAX_PHYSMEM_BITS - TB_SHIFT);
644 + kaslr_regions[1].size_tb = VMALLOC_SIZE_TB;
645 +
646 + /*
647 +diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
648 +index a6d1b0241aea..a6836ab0fcc7 100644
649 +--- a/arch/x86/mm/tlb.c
650 ++++ b/arch/x86/mm/tlb.c
651 +@@ -694,7 +694,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
652 + {
653 + int cpu;
654 +
655 +- struct flush_tlb_info info __aligned(SMP_CACHE_BYTES) = {
656 ++ struct flush_tlb_info info = {
657 + .mm = mm,
658 + };
659 +
660 +diff --git a/block/blk-core.c b/block/blk-core.c
661 +index eb8b52241453..33488b1426b7 100644
662 +--- a/block/blk-core.c
663 ++++ b/block/blk-core.c
664 +@@ -980,6 +980,10 @@ static void blk_rq_timed_out_timer(struct timer_list *t)
665 + kblockd_schedule_work(&q->timeout_work);
666 + }
667 +
668 ++static void blk_timeout_work_dummy(struct work_struct *work)
669 ++{
670 ++}
671 ++
672 + /**
673 + * blk_alloc_queue_node - allocate a request queue
674 + * @gfp_mask: memory allocation flags
675 +@@ -1034,7 +1038,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id,
676 + timer_setup(&q->backing_dev_info->laptop_mode_wb_timer,
677 + laptop_mode_timer_fn, 0);
678 + timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
679 +- INIT_WORK(&q->timeout_work, NULL);
680 ++ INIT_WORK(&q->timeout_work, blk_timeout_work_dummy);
681 + INIT_LIST_HEAD(&q->timeout_list);
682 + INIT_LIST_HEAD(&q->icq_list);
683 + #ifdef CONFIG_BLK_CGROUP
684 +diff --git a/block/blk-mq.c b/block/blk-mq.c
685 +index 7d53f2314d7c..414656796ecf 100644
686 +--- a/block/blk-mq.c
687 ++++ b/block/blk-mq.c
688 +@@ -2236,7 +2236,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
689 + return 0;
690 +
691 + free_fq:
692 +- kfree(hctx->fq);
693 ++ blk_free_flush_queue(hctx->fq);
694 + exit_hctx:
695 + if (set->ops->exit_hctx)
696 + set->ops->exit_hctx(hctx, hctx_idx);
697 +diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
698 +index c24589414c75..0f36db0cf74a 100644
699 +--- a/drivers/block/xsysace.c
700 ++++ b/drivers/block/xsysace.c
701 +@@ -1063,6 +1063,8 @@ static int ace_setup(struct ace_device *ace)
702 + return 0;
703 +
704 + err_read:
705 ++ /* prevent double queue cleanup */
706 ++ ace->gd->queue = NULL;
707 + put_disk(ace->gd);
708 + err_alloc_disk:
709 + blk_cleanup_queue(ace->queue);
710 +diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c
711 +index 4593baff2bc9..19eecf198321 100644
712 +--- a/drivers/bluetooth/btmtkuart.c
713 ++++ b/drivers/bluetooth/btmtkuart.c
714 +@@ -115,11 +115,13 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, u8 op, u8 flag, u16 plen,
715 + TASK_INTERRUPTIBLE, HCI_INIT_TIMEOUT);
716 + if (err == -EINTR) {
717 + bt_dev_err(hdev, "Execution of wmt command interrupted");
718 ++ clear_bit(BTMTKUART_TX_WAIT_VND_EVT, &bdev->tx_state);
719 + return err;
720 + }
721 +
722 + if (err) {
723 + bt_dev_err(hdev, "Execution of wmt command timed out");
724 ++ clear_bit(BTMTKUART_TX_WAIT_VND_EVT, &bdev->tx_state);
725 + return -ETIMEDOUT;
726 + }
727 +
728 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
729 +index 77b67a5f21ee..40a4f95f6178 100644
730 +--- a/drivers/bluetooth/btusb.c
731 ++++ b/drivers/bluetooth/btusb.c
732 +@@ -2888,6 +2888,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
733 + return 0;
734 + }
735 +
736 ++ irq_set_status_flags(irq, IRQ_NOAUTOEN);
737 + ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler,
738 + 0, "OOB Wake-on-BT", data);
739 + if (ret) {
740 +@@ -2902,7 +2903,6 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
741 + }
742 +
743 + data->oob_wake_irq = irq;
744 +- disable_irq(irq);
745 + bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq);
746 + return 0;
747 + }
748 +diff --git a/drivers/clk/qcom/gcc-msm8998.c b/drivers/clk/qcom/gcc-msm8998.c
749 +index 9f0ae403d5f5..cd937ce6aaaf 100644
750 +--- a/drivers/clk/qcom/gcc-msm8998.c
751 ++++ b/drivers/clk/qcom/gcc-msm8998.c
752 +@@ -1101,6 +1101,7 @@ static struct clk_rcg2 ufs_axi_clk_src = {
753 +
754 + static const struct freq_tbl ftbl_usb30_master_clk_src[] = {
755 + F(19200000, P_XO, 1, 0, 0),
756 ++ F(60000000, P_GPLL0_OUT_MAIN, 10, 0, 0),
757 + F(120000000, P_GPLL0_OUT_MAIN, 5, 0, 0),
758 + F(150000000, P_GPLL0_OUT_MAIN, 4, 0, 0),
759 + { }
760 +diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c
761 +index d977193842df..19174835693b 100644
762 +--- a/drivers/clk/x86/clk-pmc-atom.c
763 ++++ b/drivers/clk/x86/clk-pmc-atom.c
764 +@@ -165,7 +165,7 @@ static const struct clk_ops plt_clk_ops = {
765 + };
766 +
767 + static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
768 +- void __iomem *base,
769 ++ const struct pmc_clk_data *pmc_data,
770 + const char **parent_names,
771 + int num_parents)
772 + {
773 +@@ -184,9 +184,17 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
774 + init.num_parents = num_parents;
775 +
776 + pclk->hw.init = &init;
777 +- pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
778 ++ pclk->reg = pmc_data->base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
779 + spin_lock_init(&pclk->lock);
780 +
781 ++ /*
782 ++ * On some systems, the pmc_plt_clocks already enabled by the
783 ++ * firmware are being marked as critical to avoid them being
784 ++ * gated by the clock framework.
785 ++ */
786 ++ if (pmc_data->critical && plt_clk_is_enabled(&pclk->hw))
787 ++ init.flags |= CLK_IS_CRITICAL;
788 ++
789 + ret = devm_clk_hw_register(&pdev->dev, &pclk->hw);
790 + if (ret) {
791 + pclk = ERR_PTR(ret);
792 +@@ -332,7 +340,7 @@ static int plt_clk_probe(struct platform_device *pdev)
793 + return PTR_ERR(parent_names);
794 +
795 + for (i = 0; i < PMC_CLK_NUM; i++) {
796 +- data->clks[i] = plt_clk_register(pdev, i, pmc_data->base,
797 ++ data->clks[i] = plt_clk_register(pdev, i, pmc_data,
798 + parent_names, data->nparents);
799 + if (IS_ERR(data->clks[i])) {
800 + err = PTR_ERR(data->clks[i]);
801 +diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
802 +index b0aeffd4e269..1606abead22c 100644
803 +--- a/drivers/firmware/efi/runtime-wrappers.c
804 ++++ b/drivers/firmware/efi/runtime-wrappers.c
805 +@@ -95,7 +95,7 @@ struct efi_runtime_work {
806 + efi_rts_work.status = EFI_ABORTED; \
807 + \
808 + init_completion(&efi_rts_work.efi_rts_comp); \
809 +- INIT_WORK_ONSTACK(&efi_rts_work.work, efi_call_rts); \
810 ++ INIT_WORK(&efi_rts_work.work, efi_call_rts); \
811 + efi_rts_work.arg1 = _arg1; \
812 + efi_rts_work.arg2 = _arg2; \
813 + efi_rts_work.arg3 = _arg3; \
814 +diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
815 +index 2d1dfa1e0745..e86e61dda4b7 100644
816 +--- a/drivers/gpio/gpio-mxc.c
817 ++++ b/drivers/gpio/gpio-mxc.c
818 +@@ -438,8 +438,11 @@ static int mxc_gpio_probe(struct platform_device *pdev)
819 +
820 + /* the controller clock is optional */
821 + port->clk = devm_clk_get(&pdev->dev, NULL);
822 +- if (IS_ERR(port->clk))
823 ++ if (IS_ERR(port->clk)) {
824 ++ if (PTR_ERR(port->clk) == -EPROBE_DEFER)
825 ++ return -EPROBE_DEFER;
826 + port->clk = NULL;
827 ++ }
828 +
829 + err = clk_prepare_enable(port->clk);
830 + if (err) {
831 +diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
832 +index ebc9ffde41e9..a353a011fbdf 100644
833 +--- a/drivers/hid/hid-debug.c
834 ++++ b/drivers/hid/hid-debug.c
835 +@@ -1060,10 +1060,15 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p)
836 + seq_printf(f, "\n\n");
837 +
838 + /* dump parsed data and input mappings */
839 ++ if (down_interruptible(&hdev->driver_input_lock))
840 ++ return 0;
841 ++
842 + hid_dump_device(hdev, f);
843 + seq_printf(f, "\n");
844 + hid_dump_input_mapping(hdev, f);
845 +
846 ++ up(&hdev->driver_input_lock);
847 ++
848 + return 0;
849 + }
850 +
851 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
852 +index a3916e58dbf5..e649940e065d 100644
853 +--- a/drivers/hid/hid-input.c
854 ++++ b/drivers/hid/hid-input.c
855 +@@ -982,6 +982,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
856 + case 0x1b8: map_key_clear(KEY_VIDEO); break;
857 + case 0x1bc: map_key_clear(KEY_MESSENGER); break;
858 + case 0x1bd: map_key_clear(KEY_INFO); break;
859 ++ case 0x1cb: map_key_clear(KEY_ASSISTANT); break;
860 + case 0x201: map_key_clear(KEY_NEW); break;
861 + case 0x202: map_key_clear(KEY_OPEN); break;
862 + case 0x203: map_key_clear(KEY_CLOSE); break;
863 +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
864 +index 19cc980eebce..8425d3548a41 100644
865 +--- a/drivers/hid/hid-logitech-hidpp.c
866 ++++ b/drivers/hid/hid-logitech-hidpp.c
867 +@@ -1907,6 +1907,13 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
868 + kfree(data);
869 + return -ENOMEM;
870 + }
871 ++ data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue");
872 ++ if (!data->wq) {
873 ++ kfree(data->effect_ids);
874 ++ kfree(data);
875 ++ return -ENOMEM;
876 ++ }
877 ++
878 + data->hidpp = hidpp;
879 + data->feature_index = feature_index;
880 + data->version = version;
881 +@@ -1951,7 +1958,6 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
882 + /* ignore boost value at response.fap.params[2] */
883 +
884 + /* init the hardware command queue */
885 +- data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue");
886 + atomic_set(&data->workqueue_size, 0);
887 +
888 + /* initialize with zero autocenter to get wheel in usable state */
889 +diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
890 +index 94088c0ed68a..e24790c988c0 100644
891 +--- a/drivers/hid/hid-quirks.c
892 ++++ b/drivers/hid/hid-quirks.c
893 +@@ -744,7 +744,6 @@ static const struct hid_device_id hid_ignore_list[] = {
894 + { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
895 + { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
896 + { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
897 +- { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0400) },
898 + { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
899 + { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
900 + { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
901 +@@ -1025,6 +1024,10 @@ bool hid_ignore(struct hid_device *hdev)
902 + if (hdev->product == 0x0401 &&
903 + strncmp(hdev->name, "ELAN0800", 8) != 0)
904 + return true;
905 ++ /* Same with product id 0x0400 */
906 ++ if (hdev->product == 0x0400 &&
907 ++ strncmp(hdev->name, "QTEC0001", 8) != 0)
908 ++ return true;
909 + break;
910 + }
911 +
912 +diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
913 +index c406700789e1..7bd409eaf0ac 100644
914 +--- a/drivers/i2c/busses/i2c-imx.c
915 ++++ b/drivers/i2c/busses/i2c-imx.c
916 +@@ -510,9 +510,9 @@ static int i2c_imx_clk_notifier_call(struct notifier_block *nb,
917 + unsigned long action, void *data)
918 + {
919 + struct clk_notifier_data *ndata = data;
920 +- struct imx_i2c_struct *i2c_imx = container_of(&ndata->clk,
921 ++ struct imx_i2c_struct *i2c_imx = container_of(nb,
922 + struct imx_i2c_struct,
923 +- clk);
924 ++ clk_change_nb);
925 +
926 + if (action & POST_RATE_CHANGE)
927 + i2c_imx_set_clk(i2c_imx, ndata->new_rate);
928 +diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
929 +index 62d023e737d9..a492da9fd0d3 100644
930 +--- a/drivers/i2c/busses/i2c-stm32f7.c
931 ++++ b/drivers/i2c/busses/i2c-stm32f7.c
932 +@@ -424,7 +424,7 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
933 + STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
934 + dnf_delay = setup->dnf * i2cclk;
935 +
936 +- sdadel_min = setup->fall_time - i2c_specs[setup->speed].hddat_min -
937 ++ sdadel_min = i2c_specs[setup->speed].hddat_min + setup->fall_time -
938 + af_delay_min - (setup->dnf + 3) * i2cclk;
939 +
940 + sdadel_max = i2c_specs[setup->speed].vddat_max - setup->rise_time -
941 +diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
942 +index 915f5edbab33..e6c554e6ba58 100644
943 +--- a/drivers/i2c/busses/i2c-synquacer.c
944 ++++ b/drivers/i2c/busses/i2c-synquacer.c
945 +@@ -602,6 +602,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
946 + i2c->adapter = synquacer_i2c_ops;
947 + i2c_set_adapdata(&i2c->adapter, i2c);
948 + i2c->adapter.dev.parent = &pdev->dev;
949 ++ i2c->adapter.dev.of_node = pdev->dev.of_node;
950 ++ ACPI_COMPANION_SET(&i2c->adapter.dev, ACPI_COMPANION(&pdev->dev));
951 + i2c->adapter.nr = pdev->id;
952 + init_completion(&i2c->completion);
953 +
954 +diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
955 +index 9200e349f29e..5b0e1d9e5adc 100644
956 +--- a/drivers/i2c/i2c-core-base.c
957 ++++ b/drivers/i2c/i2c-core-base.c
958 +@@ -306,10 +306,7 @@ static int i2c_smbus_host_notify_to_irq(const struct i2c_client *client)
959 + if (client->flags & I2C_CLIENT_TEN)
960 + return -EINVAL;
961 +
962 +- irq = irq_find_mapping(adap->host_notify_domain, client->addr);
963 +- if (!irq)
964 +- irq = irq_create_mapping(adap->host_notify_domain,
965 +- client->addr);
966 ++ irq = irq_create_mapping(adap->host_notify_domain, client->addr);
967 +
968 + return irq > 0 ? irq : -ENXIO;
969 + }
970 +@@ -330,6 +327,8 @@ static int i2c_device_probe(struct device *dev)
971 +
972 + if (client->flags & I2C_CLIENT_HOST_NOTIFY) {
973 + dev_dbg(dev, "Using Host Notify IRQ\n");
974 ++ /* Keep adapter active when Host Notify is required */
975 ++ pm_runtime_get_sync(&client->adapter->dev);
976 + irq = i2c_smbus_host_notify_to_irq(client);
977 + } else if (dev->of_node) {
978 + irq = of_irq_get_byname(dev->of_node, "irq");
979 +@@ -433,6 +432,10 @@ static int i2c_device_remove(struct device *dev)
980 + dev_pm_clear_wake_irq(&client->dev);
981 + device_init_wakeup(&client->dev, false);
982 +
983 ++ client->irq = client->init_irq;
984 ++ if (client->flags & I2C_CLIENT_HOST_NOTIFY)
985 ++ pm_runtime_put(&client->adapter->dev);
986 ++
987 + return status;
988 + }
989 +
990 +@@ -742,10 +745,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
991 + client->flags = info->flags;
992 + client->addr = info->addr;
993 +
994 +- client->irq = info->irq;
995 +- if (!client->irq)
996 +- client->irq = i2c_dev_irq_from_resources(info->resources,
997 ++ client->init_irq = info->irq;
998 ++ if (!client->init_irq)
999 ++ client->init_irq = i2c_dev_irq_from_resources(info->resources,
1000 + info->num_resources);
1001 ++ client->irq = client->init_irq;
1002 +
1003 + strlcpy(client->name, info->type, sizeof(client->name));
1004 +
1005 +diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c
1006 +index 9b0bea8303e0..b79b61bd6ee4 100644
1007 +--- a/drivers/infiniband/core/security.c
1008 ++++ b/drivers/infiniband/core/security.c
1009 +@@ -711,16 +711,20 @@ int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
1010 + agent->device->name,
1011 + agent->port_num);
1012 + if (ret)
1013 +- return ret;
1014 ++ goto free_security;
1015 +
1016 + agent->lsm_nb.notifier_call = ib_mad_agent_security_change;
1017 + ret = register_lsm_notifier(&agent->lsm_nb);
1018 + if (ret)
1019 +- return ret;
1020 ++ goto free_security;
1021 +
1022 + agent->smp_allowed = true;
1023 + agent->lsm_nb_reg = true;
1024 + return 0;
1025 ++
1026 ++free_security:
1027 ++ security_ib_free_security(agent->security);
1028 ++ return ret;
1029 + }
1030 +
1031 + void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
1032 +@@ -728,9 +732,10 @@ void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
1033 + if (!rdma_protocol_ib(agent->device, agent->port_num))
1034 + return;
1035 +
1036 +- security_ib_free_security(agent->security);
1037 + if (agent->lsm_nb_reg)
1038 + unregister_lsm_notifier(&agent->lsm_nb);
1039 ++
1040 ++ security_ib_free_security(agent->security);
1041 + }
1042 +
1043 + int ib_mad_enforce_security(struct ib_mad_agent_private *map, u16 pkey_index)
1044 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
1045 +index 6ee03d6089eb..82f309fb3ce5 100644
1046 +--- a/drivers/infiniband/core/verbs.c
1047 ++++ b/drivers/infiniband/core/verbs.c
1048 +@@ -1087,8 +1087,8 @@ struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd,
1049 + }
1050 + EXPORT_SYMBOL(ib_open_qp);
1051 +
1052 +-static struct ib_qp *ib_create_xrc_qp(struct ib_qp *qp,
1053 +- struct ib_qp_init_attr *qp_init_attr)
1054 ++static struct ib_qp *create_xrc_qp(struct ib_qp *qp,
1055 ++ struct ib_qp_init_attr *qp_init_attr)
1056 + {
1057 + struct ib_qp *real_qp = qp;
1058 +
1059 +@@ -1103,10 +1103,10 @@ static struct ib_qp *ib_create_xrc_qp(struct ib_qp *qp,
1060 +
1061 + qp = __ib_open_qp(real_qp, qp_init_attr->event_handler,
1062 + qp_init_attr->qp_context);
1063 +- if (!IS_ERR(qp))
1064 +- __ib_insert_xrcd_qp(qp_init_attr->xrcd, real_qp);
1065 +- else
1066 +- real_qp->device->destroy_qp(real_qp);
1067 ++ if (IS_ERR(qp))
1068 ++ return qp;
1069 ++
1070 ++ __ib_insert_xrcd_qp(qp_init_attr->xrcd, real_qp);
1071 + return qp;
1072 + }
1073 +
1074 +@@ -1137,10 +1137,8 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
1075 + return qp;
1076 +
1077 + ret = ib_create_qp_security(qp, device);
1078 +- if (ret) {
1079 +- ib_destroy_qp(qp);
1080 +- return ERR_PTR(ret);
1081 +- }
1082 ++ if (ret)
1083 ++ goto err;
1084 +
1085 + qp->real_qp = qp;
1086 + qp->qp_type = qp_init_attr->qp_type;
1087 +@@ -1153,8 +1151,15 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
1088 + INIT_LIST_HEAD(&qp->sig_mrs);
1089 + qp->port = 0;
1090 +
1091 +- if (qp_init_attr->qp_type == IB_QPT_XRC_TGT)
1092 +- return ib_create_xrc_qp(qp, qp_init_attr);
1093 ++ if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) {
1094 ++ struct ib_qp *xrc_qp = create_xrc_qp(qp, qp_init_attr);
1095 ++
1096 ++ if (IS_ERR(xrc_qp)) {
1097 ++ ret = PTR_ERR(xrc_qp);
1098 ++ goto err;
1099 ++ }
1100 ++ return xrc_qp;
1101 ++ }
1102 +
1103 + qp->event_handler = qp_init_attr->event_handler;
1104 + qp->qp_context = qp_init_attr->qp_context;
1105 +@@ -1181,11 +1186,8 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
1106 +
1107 + if (qp_init_attr->cap.max_rdma_ctxs) {
1108 + ret = rdma_rw_init_mrs(qp, qp_init_attr);
1109 +- if (ret) {
1110 +- pr_err("failed to init MR pool ret= %d\n", ret);
1111 +- ib_destroy_qp(qp);
1112 +- return ERR_PTR(ret);
1113 +- }
1114 ++ if (ret)
1115 ++ goto err;
1116 + }
1117 +
1118 + /*
1119 +@@ -1198,6 +1200,11 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
1120 + device->attrs.max_sge_rd);
1121 +
1122 + return qp;
1123 ++
1124 ++err:
1125 ++ ib_destroy_qp(qp);
1126 ++ return ERR_PTR(ret);
1127 ++
1128 + }
1129 + EXPORT_SYMBOL(ib_create_qp);
1130 +
1131 +diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
1132 +index f4bce5aa0ff8..ea4afdeb06a4 100644
1133 +--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
1134 ++++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
1135 +@@ -2793,8 +2793,19 @@ static void srpt_queue_tm_rsp(struct se_cmd *cmd)
1136 + srpt_queue_response(cmd);
1137 + }
1138 +
1139 ++/*
1140 ++ * This function is called for aborted commands if no response is sent to the
1141 ++ * initiator. Make sure that the credits freed by aborting a command are
1142 ++ * returned to the initiator the next time a response is sent by incrementing
1143 ++ * ch->req_lim_delta.
1144 ++ */
1145 + static void srpt_aborted_task(struct se_cmd *cmd)
1146 + {
1147 ++ struct srpt_send_ioctx *ioctx = container_of(cmd,
1148 ++ struct srpt_send_ioctx, cmd);
1149 ++ struct srpt_rdma_ch *ch = ioctx->ch;
1150 ++
1151 ++ atomic_inc(&ch->req_lim_delta);
1152 + }
1153 +
1154 + static int srpt_queue_status(struct se_cmd *cmd)
1155 +diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
1156 +index effb63205d3d..4c67cf30a5d9 100644
1157 +--- a/drivers/input/keyboard/snvs_pwrkey.c
1158 ++++ b/drivers/input/keyboard/snvs_pwrkey.c
1159 +@@ -148,6 +148,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
1160 + return error;
1161 + }
1162 +
1163 ++ pdata->input = input;
1164 ++ platform_set_drvdata(pdev, pdata);
1165 ++
1166 + error = devm_request_irq(&pdev->dev, pdata->irq,
1167 + imx_snvs_pwrkey_interrupt,
1168 + 0, pdev->name, pdev);
1169 +@@ -163,9 +166,6 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
1170 + return error;
1171 + }
1172 +
1173 +- pdata->input = input;
1174 +- platform_set_drvdata(pdev, pdata);
1175 +-
1176 + device_init_wakeup(&pdev->dev, pdata->wakeup);
1177 +
1178 + return 0;
1179 +diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
1180 +index 704e99046916..b6f95f20f924 100644
1181 +--- a/drivers/input/touchscreen/stmfts.c
1182 ++++ b/drivers/input/touchscreen/stmfts.c
1183 +@@ -106,27 +106,29 @@ struct stmfts_data {
1184 + bool running;
1185 + };
1186 +
1187 +-static void stmfts_brightness_set(struct led_classdev *led_cdev,
1188 ++static int stmfts_brightness_set(struct led_classdev *led_cdev,
1189 + enum led_brightness value)
1190 + {
1191 + struct stmfts_data *sdata = container_of(led_cdev,
1192 + struct stmfts_data, led_cdev);
1193 + int err;
1194 +
1195 +- if (value == sdata->led_status || !sdata->ledvdd)
1196 +- return;
1197 +-
1198 +- if (!value) {
1199 +- regulator_disable(sdata->ledvdd);
1200 +- } else {
1201 +- err = regulator_enable(sdata->ledvdd);
1202 +- if (err)
1203 +- dev_warn(&sdata->client->dev,
1204 +- "failed to disable ledvdd regulator: %d\n",
1205 +- err);
1206 ++ if (value != sdata->led_status && sdata->ledvdd) {
1207 ++ if (!value) {
1208 ++ regulator_disable(sdata->ledvdd);
1209 ++ } else {
1210 ++ err = regulator_enable(sdata->ledvdd);
1211 ++ if (err) {
1212 ++ dev_warn(&sdata->client->dev,
1213 ++ "failed to disable ledvdd regulator: %d\n",
1214 ++ err);
1215 ++ return err;
1216 ++ }
1217 ++ }
1218 ++ sdata->led_status = value;
1219 + }
1220 +
1221 +- sdata->led_status = value;
1222 ++ return 0;
1223 + }
1224 +
1225 + static enum led_brightness stmfts_brightness_get(struct led_classdev *led_cdev)
1226 +@@ -608,7 +610,7 @@ static int stmfts_enable_led(struct stmfts_data *sdata)
1227 + sdata->led_cdev.name = STMFTS_DEV_NAME;
1228 + sdata->led_cdev.max_brightness = LED_ON;
1229 + sdata->led_cdev.brightness = LED_OFF;
1230 +- sdata->led_cdev.brightness_set = stmfts_brightness_set;
1231 ++ sdata->led_cdev.brightness_set_blocking = stmfts_brightness_set;
1232 + sdata->led_cdev.brightness_get = stmfts_brightness_get;
1233 +
1234 + err = devm_led_classdev_register(&sdata->client->dev, &sdata->led_cdev);
1235 +diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
1236 +index 64d1402882c8..1f71c14c8aab 100644
1237 +--- a/drivers/media/i2c/ov7670.c
1238 ++++ b/drivers/media/i2c/ov7670.c
1239 +@@ -159,10 +159,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
1240 + #define REG_GFIX 0x69 /* Fix gain control */
1241 +
1242 + #define REG_DBLV 0x6b /* PLL control an debugging */
1243 +-#define DBLV_BYPASS 0x00 /* Bypass PLL */
1244 +-#define DBLV_X4 0x01 /* clock x4 */
1245 +-#define DBLV_X6 0x10 /* clock x6 */
1246 +-#define DBLV_X8 0x11 /* clock x8 */
1247 ++#define DBLV_BYPASS 0x0a /* Bypass PLL */
1248 ++#define DBLV_X4 0x4a /* clock x4 */
1249 ++#define DBLV_X6 0x8a /* clock x6 */
1250 ++#define DBLV_X8 0xca /* clock x8 */
1251 +
1252 + #define REG_SCALING_XSC 0x70 /* Test pattern and horizontal scale factor */
1253 + #define TEST_PATTTERN_0 0x80
1254 +@@ -862,7 +862,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd,
1255 + if (ret < 0)
1256 + return ret;
1257 +
1258 +- return ov7670_write(sd, REG_DBLV, DBLV_X4);
1259 ++ return 0;
1260 + }
1261 +
1262 + static void ov7670_get_framerate_legacy(struct v4l2_subdev *sd,
1263 +@@ -1797,11 +1797,7 @@ static int ov7670_probe(struct i2c_client *client,
1264 + if (config->clock_speed)
1265 + info->clock_speed = config->clock_speed;
1266 +
1267 +- /*
1268 +- * It should be allowed for ov7670 too when it is migrated to
1269 +- * the new frame rate formula.
1270 +- */
1271 +- if (config->pll_bypass && id->driver_data != MODEL_OV7670)
1272 ++ if (config->pll_bypass)
1273 + info->pll_bypass = true;
1274 +
1275 + if (config->pclk_hb_disable)
1276 +diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
1277 +index 299016bc46d9..104477b512a2 100644
1278 +--- a/drivers/mfd/twl-core.c
1279 ++++ b/drivers/mfd/twl-core.c
1280 +@@ -1245,6 +1245,28 @@ free:
1281 + return status;
1282 + }
1283 +
1284 ++static int __maybe_unused twl_suspend(struct device *dev)
1285 ++{
1286 ++ struct i2c_client *client = to_i2c_client(dev);
1287 ++
1288 ++ if (client->irq)
1289 ++ disable_irq(client->irq);
1290 ++
1291 ++ return 0;
1292 ++}
1293 ++
1294 ++static int __maybe_unused twl_resume(struct device *dev)
1295 ++{
1296 ++ struct i2c_client *client = to_i2c_client(dev);
1297 ++
1298 ++ if (client->irq)
1299 ++ enable_irq(client->irq);
1300 ++
1301 ++ return 0;
1302 ++}
1303 ++
1304 ++static SIMPLE_DEV_PM_OPS(twl_dev_pm_ops, twl_suspend, twl_resume);
1305 ++
1306 + static const struct i2c_device_id twl_ids[] = {
1307 + { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */
1308 + { "twl5030", 0 }, /* T2 updated */
1309 +@@ -1262,6 +1284,7 @@ static const struct i2c_device_id twl_ids[] = {
1310 + /* One Client Driver , 4 Clients */
1311 + static struct i2c_driver twl_driver = {
1312 + .driver.name = DRIVER_NAME,
1313 ++ .driver.pm = &twl_dev_pm_ops,
1314 + .id_table = twl_ids,
1315 + .probe = twl_probe,
1316 + .remove = twl_remove,
1317 +diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
1318 +index 2f120b2ffef0..4985268e2273 100644
1319 +--- a/drivers/net/bonding/bond_sysfs_slave.c
1320 ++++ b/drivers/net/bonding/bond_sysfs_slave.c
1321 +@@ -55,7 +55,9 @@ static SLAVE_ATTR_RO(link_failure_count);
1322 +
1323 + static ssize_t perm_hwaddr_show(struct slave *slave, char *buf)
1324 + {
1325 +- return sprintf(buf, "%pM\n", slave->perm_hwaddr);
1326 ++ return sprintf(buf, "%*phC\n",
1327 ++ slave->dev->addr_len,
1328 ++ slave->perm_hwaddr);
1329 + }
1330 + static SLAVE_ATTR_RO(perm_hwaddr);
1331 +
1332 +diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
1333 +index 74849be5f004..e2919005ead3 100644
1334 +--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
1335 ++++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
1336 +@@ -354,7 +354,10 @@ static struct cxgbi_ppm_pool *ppm_alloc_cpu_pool(unsigned int *total,
1337 + ppmax = max;
1338 +
1339 + /* pool size must be multiple of unsigned long */
1340 +- bmap = BITS_TO_LONGS(ppmax);
1341 ++ bmap = ppmax / BITS_PER_TYPE(unsigned long);
1342 ++ if (!bmap)
1343 ++ return NULL;
1344 ++
1345 + ppmax = (bmap * sizeof(unsigned long)) << 3;
1346 +
1347 + alloc_sz = sizeof(*pools) + sizeof(unsigned long) * bmap;
1348 +@@ -402,6 +405,10 @@ int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev,
1349 + if (reserve_factor) {
1350 + ppmax_pool = ppmax / reserve_factor;
1351 + pool = ppm_alloc_cpu_pool(&ppmax_pool, &pool_index_max);
1352 ++ if (!pool) {
1353 ++ ppmax_pool = 0;
1354 ++ reserve_factor = 0;
1355 ++ }
1356 +
1357 + pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n",
1358 + ndev->name, ppmax, ppmax_pool, pool_index_max);
1359 +diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
1360 +index 79d03f8ee7b1..c7fa97a7e1f4 100644
1361 +--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
1362 ++++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
1363 +@@ -150,7 +150,6 @@ out_buffer_fail:
1364 + /* free desc along with its attached buffer */
1365 + static void hnae_free_desc(struct hnae_ring *ring)
1366 + {
1367 +- hnae_free_buffers(ring);
1368 + dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr,
1369 + ring->desc_num * sizeof(ring->desc[0]),
1370 + ring_to_dma_dir(ring));
1371 +@@ -183,6 +182,9 @@ static int hnae_alloc_desc(struct hnae_ring *ring)
1372 + /* fini ring, also free the buffer for the ring */
1373 + static void hnae_fini_ring(struct hnae_ring *ring)
1374 + {
1375 ++ if (is_rx_ring(ring))
1376 ++ hnae_free_buffers(ring);
1377 ++
1378 + hnae_free_desc(ring);
1379 + kfree(ring->desc_cb);
1380 + ring->desc_cb = NULL;
1381 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
1382 +index b8155f5e71b4..fdff5526d2e8 100644
1383 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
1384 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
1385 +@@ -2750,6 +2750,17 @@ int hns_dsaf_get_regs_count(void)
1386 + return DSAF_DUMP_REGS_NUM;
1387 + }
1388 +
1389 ++static int hns_dsaf_get_port_id(u8 port)
1390 ++{
1391 ++ if (port < DSAF_SERVICE_NW_NUM)
1392 ++ return port;
1393 ++
1394 ++ if (port >= DSAF_BASE_INNER_PORT_NUM)
1395 ++ return port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM;
1396 ++
1397 ++ return -EINVAL;
1398 ++}
1399 ++
1400 + static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port)
1401 + {
1402 + struct dsaf_tbl_tcam_ucast_cfg tbl_tcam_ucast = {0, 1, 0, 0, 0x80};
1403 +@@ -2815,23 +2826,33 @@ static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port)
1404 + memset(&temp_key, 0x0, sizeof(temp_key));
1405 + mask_entry.addr[0] = 0x01;
1406 + hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id,
1407 +- port, mask_entry.addr);
1408 ++ 0xf, mask_entry.addr);
1409 + tbl_tcam_mcast.tbl_mcast_item_vld = 1;
1410 + tbl_tcam_mcast.tbl_mcast_old_en = 0;
1411 +
1412 +- if (port < DSAF_SERVICE_NW_NUM) {
1413 +- mskid = port;
1414 +- } else if (port >= DSAF_BASE_INNER_PORT_NUM) {
1415 +- mskid = port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM;
1416 +- } else {
1417 ++ /* set MAC port to handle multicast */
1418 ++ mskid = hns_dsaf_get_port_id(port);
1419 ++ if (mskid == -EINVAL) {
1420 + dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n",
1421 + dsaf_dev->ae_dev.name, port,
1422 + mask_key.high.val, mask_key.low.val);
1423 + return;
1424 + }
1425 ++ dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32],
1426 ++ mskid % 32, 1);
1427 +
1428 ++ /* set pool bit map to handle multicast */
1429 ++ mskid = hns_dsaf_get_port_id(port_num);
1430 ++ if (mskid == -EINVAL) {
1431 ++ dev_err(dsaf_dev->dev,
1432 ++ "%s, pool bit map pnum(%d)error,key(%#x:%#x)\n",
1433 ++ dsaf_dev->ae_dev.name, port_num,
1434 ++ mask_key.high.val, mask_key.low.val);
1435 ++ return;
1436 ++ }
1437 + dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32],
1438 + mskid % 32, 1);
1439 ++
1440 + memcpy(&temp_key, &mask_key, sizeof(mask_key));
1441 + hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc,
1442 + (struct dsaf_tbl_tcam_data *)(&mask_key),
1443 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
1444 +index ba4316910dea..a60f207768fc 100644
1445 +--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
1446 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
1447 +@@ -129,7 +129,7 @@ static void hns_xgmac_lf_rf_control_init(struct mac_driver *mac_drv)
1448 + dsaf_set_bit(val, XGMAC_UNIDIR_EN_B, 0);
1449 + dsaf_set_bit(val, XGMAC_RF_TX_EN_B, 1);
1450 + dsaf_set_field(val, XGMAC_LF_RF_INSERT_M, XGMAC_LF_RF_INSERT_S, 0);
1451 +- dsaf_write_reg(mac_drv, XGMAC_MAC_TX_LF_RF_CONTROL_REG, val);
1452 ++ dsaf_write_dev(mac_drv, XGMAC_MAC_TX_LF_RF_CONTROL_REG, val);
1453 + }
1454 +
1455 + /**
1456 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1457 +index cc84133c184d..1c70f9aa0aa7 100644
1458 +--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1459 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1460 +@@ -29,9 +29,6 @@
1461 +
1462 + #define SERVICE_TIMER_HZ (1 * HZ)
1463 +
1464 +-#define NIC_TX_CLEAN_MAX_NUM 256
1465 +-#define NIC_RX_CLEAN_MAX_NUM 64
1466 +-
1467 + #define RCB_IRQ_NOT_INITED 0
1468 + #define RCB_IRQ_INITED 1
1469 + #define HNS_BUFFER_SIZE_2048 2048
1470 +@@ -376,8 +373,6 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
1471 + wmb(); /* commit all data before submit */
1472 + assert(skb->queue_mapping < priv->ae_handle->q_num);
1473 + hnae_queue_xmit(priv->ae_handle->qs[skb->queue_mapping], buf_num);
1474 +- ring->stats.tx_pkts++;
1475 +- ring->stats.tx_bytes += skb->len;
1476 +
1477 + return NETDEV_TX_OK;
1478 +
1479 +@@ -999,6 +994,9 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,
1480 + /* issue prefetch for next Tx descriptor */
1481 + prefetch(&ring->desc_cb[ring->next_to_clean]);
1482 + }
1483 ++ /* update tx ring statistics. */
1484 ++ ring->stats.tx_pkts += pkts;
1485 ++ ring->stats.tx_bytes += bytes;
1486 +
1487 + NETIF_TX_UNLOCK(ring);
1488 +
1489 +@@ -2150,7 +2148,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv)
1490 + hns_nic_tx_fini_pro_v2;
1491 +
1492 + netif_napi_add(priv->netdev, &rd->napi,
1493 +- hns_nic_common_poll, NIC_TX_CLEAN_MAX_NUM);
1494 ++ hns_nic_common_poll, NAPI_POLL_WEIGHT);
1495 + rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED;
1496 + }
1497 + for (i = h->q_num; i < h->q_num * 2; i++) {
1498 +@@ -2163,7 +2161,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv)
1499 + hns_nic_rx_fini_pro_v2;
1500 +
1501 + netif_napi_add(priv->netdev, &rd->napi,
1502 +- hns_nic_common_poll, NIC_RX_CLEAN_MAX_NUM);
1503 ++ hns_nic_common_poll, NAPI_POLL_WEIGHT);
1504 + rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED;
1505 + }
1506 +
1507 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile b/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile
1508 +index cb8ddd043476..d278fc7ea3ed 100644
1509 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile
1510 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile
1511 +@@ -3,7 +3,7 @@
1512 + # Makefile for the HISILICON network device drivers.
1513 + #
1514 +
1515 +-ccflags-y := -Idrivers/net/ethernet/hisilicon/hns3
1516 ++ccflags-y := -I $(srctree)/drivers/net/ethernet/hisilicon/hns3
1517 +
1518 + obj-$(CONFIG_HNS3_HCLGE) += hclge.o
1519 + hclge-objs = hclge_main.o hclge_cmd.o hclge_mdio.o hclge_tm.o hclge_mbx.o
1520 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile b/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile
1521 +index fb93bbd35845..6193f8fa7cf3 100644
1522 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile
1523 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile
1524 +@@ -3,7 +3,7 @@
1525 + # Makefile for the HISILICON network device drivers.
1526 + #
1527 +
1528 +-ccflags-y := -Idrivers/net/ethernet/hisilicon/hns3
1529 ++ccflags-y := -I $(srctree)/drivers/net/ethernet/hisilicon/hns3
1530 +
1531 + obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o
1532 + hclgevf-objs = hclgevf_main.o hclgevf_cmd.o hclgevf_mbx.o
1533 +\ No newline at end of file
1534 +diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
1535 +index 8a28f3388f69..dca671591ef6 100644
1536 +--- a/drivers/net/ethernet/intel/igb/e1000_defines.h
1537 ++++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
1538 +@@ -194,6 +194,8 @@
1539 + /* enable link status from external LINK_0 and LINK_1 pins */
1540 + #define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
1541 + #define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
1542 ++#define E1000_CTRL_ADVD3WUC 0x00100000 /* D3 WUC */
1543 ++#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 /* PHY PM enable */
1544 + #define E1000_CTRL_SDP0_DIR 0x00400000 /* SDP0 Data direction */
1545 + #define E1000_CTRL_SDP1_DIR 0x00800000 /* SDP1 Data direction */
1546 + #define E1000_CTRL_RST 0x04000000 /* Global reset */
1547 +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
1548 +index ffaa6e031632..aa39a068858e 100644
1549 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
1550 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
1551 +@@ -8754,9 +8754,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
1552 + struct e1000_hw *hw = &adapter->hw;
1553 + u32 ctrl, rctl, status;
1554 + u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
1555 +-#ifdef CONFIG_PM
1556 +- int retval = 0;
1557 +-#endif
1558 ++ bool wake;
1559 +
1560 + rtnl_lock();
1561 + netif_device_detach(netdev);
1562 +@@ -8769,14 +8767,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
1563 + igb_clear_interrupt_scheme(adapter);
1564 + rtnl_unlock();
1565 +
1566 +-#ifdef CONFIG_PM
1567 +- if (!runtime) {
1568 +- retval = pci_save_state(pdev);
1569 +- if (retval)
1570 +- return retval;
1571 +- }
1572 +-#endif
1573 +-
1574 + status = rd32(E1000_STATUS);
1575 + if (status & E1000_STATUS_LU)
1576 + wufc &= ~E1000_WUFC_LNKC;
1577 +@@ -8793,10 +8783,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
1578 + }
1579 +
1580 + ctrl = rd32(E1000_CTRL);
1581 +- /* advertise wake from D3Cold */
1582 +- #define E1000_CTRL_ADVD3WUC 0x00100000
1583 +- /* phy power management enable */
1584 +- #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
1585 + ctrl |= E1000_CTRL_ADVD3WUC;
1586 + wr32(E1000_CTRL, ctrl);
1587 +
1588 +@@ -8810,12 +8796,15 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
1589 + wr32(E1000_WUFC, 0);
1590 + }
1591 +
1592 +- *enable_wake = wufc || adapter->en_mng_pt;
1593 +- if (!*enable_wake)
1594 ++ wake = wufc || adapter->en_mng_pt;
1595 ++ if (!wake)
1596 + igb_power_down_link(adapter);
1597 + else
1598 + igb_power_up_link(adapter);
1599 +
1600 ++ if (enable_wake)
1601 ++ *enable_wake = wake;
1602 ++
1603 + /* Release control of h/w to f/w. If f/w is AMT enabled, this
1604 + * would have already happened in close and is redundant.
1605 + */
1606 +@@ -8858,22 +8847,7 @@ static void igb_deliver_wake_packet(struct net_device *netdev)
1607 +
1608 + static int __maybe_unused igb_suspend(struct device *dev)
1609 + {
1610 +- int retval;
1611 +- bool wake;
1612 +- struct pci_dev *pdev = to_pci_dev(dev);
1613 +-
1614 +- retval = __igb_shutdown(pdev, &wake, 0);
1615 +- if (retval)
1616 +- return retval;
1617 +-
1618 +- if (wake) {
1619 +- pci_prepare_to_sleep(pdev);
1620 +- } else {
1621 +- pci_wake_from_d3(pdev, false);
1622 +- pci_set_power_state(pdev, PCI_D3hot);
1623 +- }
1624 +-
1625 +- return 0;
1626 ++ return __igb_shutdown(to_pci_dev(dev), NULL, 0);
1627 + }
1628 +
1629 + static int __maybe_unused igb_resume(struct device *dev)
1630 +@@ -8944,22 +8918,7 @@ static int __maybe_unused igb_runtime_idle(struct device *dev)
1631 +
1632 + static int __maybe_unused igb_runtime_suspend(struct device *dev)
1633 + {
1634 +- struct pci_dev *pdev = to_pci_dev(dev);
1635 +- int retval;
1636 +- bool wake;
1637 +-
1638 +- retval = __igb_shutdown(pdev, &wake, 1);
1639 +- if (retval)
1640 +- return retval;
1641 +-
1642 +- if (wake) {
1643 +- pci_prepare_to_sleep(pdev);
1644 +- } else {
1645 +- pci_wake_from_d3(pdev, false);
1646 +- pci_set_power_state(pdev, PCI_D3hot);
1647 +- }
1648 +-
1649 +- return 0;
1650 ++ return __igb_shutdown(to_pci_dev(dev), NULL, 1);
1651 + }
1652 +
1653 + static int __maybe_unused igb_runtime_resume(struct device *dev)
1654 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
1655 +index 26c9f9421901..55ccd90beeb0 100644
1656 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
1657 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
1658 +@@ -80,8 +80,7 @@ static int arm_vport_context_events_cmd(struct mlx5_core_dev *dev, u16 vport,
1659 + opcode, MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
1660 + MLX5_SET(modify_nic_vport_context_in, in, field_select.change_event, 1);
1661 + MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
1662 +- if (vport)
1663 +- MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
1664 ++ MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
1665 + nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
1666 + in, nic_vport_context);
1667 +
1668 +@@ -109,8 +108,7 @@ static int modify_esw_vport_context_cmd(struct mlx5_core_dev *dev, u16 vport,
1669 + MLX5_SET(modify_esw_vport_context_in, in, opcode,
1670 + MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT);
1671 + MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport);
1672 +- if (vport)
1673 +- MLX5_SET(modify_esw_vport_context_in, in, other_vport, 1);
1674 ++ MLX5_SET(modify_esw_vport_context_in, in, other_vport, 1);
1675 + return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
1676 + }
1677 +
1678 +diff --git a/drivers/net/ethernet/stmicro/stmmac/descs_com.h b/drivers/net/ethernet/stmicro/stmmac/descs_com.h
1679 +index 40d6356a7e73..3dfb07a78952 100644
1680 +--- a/drivers/net/ethernet/stmicro/stmmac/descs_com.h
1681 ++++ b/drivers/net/ethernet/stmicro/stmmac/descs_com.h
1682 +@@ -29,11 +29,13 @@
1683 + /* Specific functions used for Ring mode */
1684 +
1685 + /* Enhanced descriptors */
1686 +-static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end)
1687 ++static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end,
1688 ++ int bfsize)
1689 + {
1690 +- p->des1 |= cpu_to_le32((BUF_SIZE_8KiB
1691 +- << ERDES1_BUFFER2_SIZE_SHIFT)
1692 +- & ERDES1_BUFFER2_SIZE_MASK);
1693 ++ if (bfsize == BUF_SIZE_16KiB)
1694 ++ p->des1 |= cpu_to_le32((BUF_SIZE_8KiB
1695 ++ << ERDES1_BUFFER2_SIZE_SHIFT)
1696 ++ & ERDES1_BUFFER2_SIZE_MASK);
1697 +
1698 + if (end)
1699 + p->des1 |= cpu_to_le32(ERDES1_END_RING);
1700 +@@ -59,11 +61,15 @@ static inline void enh_set_tx_desc_len_on_ring(struct dma_desc *p, int len)
1701 + }
1702 +
1703 + /* Normal descriptors */
1704 +-static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end)
1705 ++static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end, int bfsize)
1706 + {
1707 +- p->des1 |= cpu_to_le32(((BUF_SIZE_2KiB - 1)
1708 +- << RDES1_BUFFER2_SIZE_SHIFT)
1709 +- & RDES1_BUFFER2_SIZE_MASK);
1710 ++ if (bfsize >= BUF_SIZE_2KiB) {
1711 ++ int bfsize2;
1712 ++
1713 ++ bfsize2 = min(bfsize - BUF_SIZE_2KiB + 1, BUF_SIZE_2KiB - 1);
1714 ++ p->des1 |= cpu_to_le32((bfsize2 << RDES1_BUFFER2_SIZE_SHIFT)
1715 ++ & RDES1_BUFFER2_SIZE_MASK);
1716 ++ }
1717 +
1718 + if (end)
1719 + p->des1 |= cpu_to_le32(RDES1_END_RING);
1720 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
1721 +index 736e29635b77..313a58b68fee 100644
1722 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
1723 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
1724 +@@ -296,7 +296,7 @@ exit:
1725 + }
1726 +
1727 + static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
1728 +- int mode, int end)
1729 ++ int mode, int end, int bfsize)
1730 + {
1731 + dwmac4_set_rx_owner(p, disable_rx_ic);
1732 + }
1733 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
1734 +index 1d858fdec997..98fa471da7c0 100644
1735 +--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
1736 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
1737 +@@ -123,7 +123,7 @@ static int dwxgmac2_get_rx_timestamp_status(void *desc, void *next_desc,
1738 + }
1739 +
1740 + static void dwxgmac2_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
1741 +- int mode, int end)
1742 ++ int mode, int end, int bfsize)
1743 + {
1744 + dwxgmac2_set_rx_owner(p, disable_rx_ic);
1745 + }
1746 +diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
1747 +index 5ef91a790f9d..5202d6ad7919 100644
1748 +--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
1749 ++++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
1750 +@@ -201,6 +201,11 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
1751 + if (unlikely(rdes0 & RDES0_OWN))
1752 + return dma_own;
1753 +
1754 ++ if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) {
1755 ++ stats->rx_length_errors++;
1756 ++ return discard_frame;
1757 ++ }
1758 ++
1759 + if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) {
1760 + if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) {
1761 + x->rx_desc++;
1762 +@@ -231,9 +236,10 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
1763 + * It doesn't match with the information reported into the databook.
1764 + * At any rate, we need to understand if the CSUM hw computation is ok
1765 + * and report this info to the upper layers. */
1766 +- ret = enh_desc_coe_rdes0(!!(rdes0 & RDES0_IPC_CSUM_ERROR),
1767 +- !!(rdes0 & RDES0_FRAME_TYPE),
1768 +- !!(rdes0 & ERDES0_RX_MAC_ADDR));
1769 ++ if (likely(ret == good_frame))
1770 ++ ret = enh_desc_coe_rdes0(!!(rdes0 & RDES0_IPC_CSUM_ERROR),
1771 ++ !!(rdes0 & RDES0_FRAME_TYPE),
1772 ++ !!(rdes0 & ERDES0_RX_MAC_ADDR));
1773 +
1774 + if (unlikely(rdes0 & RDES0_DRIBBLING))
1775 + x->dribbling_bit++;
1776 +@@ -259,15 +265,19 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
1777 + }
1778 +
1779 + static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
1780 +- int mode, int end)
1781 ++ int mode, int end, int bfsize)
1782 + {
1783 ++ int bfsize1;
1784 ++
1785 + p->des0 |= cpu_to_le32(RDES0_OWN);
1786 +- p->des1 |= cpu_to_le32(BUF_SIZE_8KiB & ERDES1_BUFFER1_SIZE_MASK);
1787 ++
1788 ++ bfsize1 = min(bfsize, BUF_SIZE_8KiB);
1789 ++ p->des1 |= cpu_to_le32(bfsize1 & ERDES1_BUFFER1_SIZE_MASK);
1790 +
1791 + if (mode == STMMAC_CHAIN_MODE)
1792 + ehn_desc_rx_set_on_chain(p);
1793 + else
1794 +- ehn_desc_rx_set_on_ring(p, end);
1795 ++ ehn_desc_rx_set_on_ring(p, end, bfsize);
1796 +
1797 + if (disable_rx_ic)
1798 + p->des1 |= cpu_to_le32(ERDES1_DISABLE_IC);
1799 +diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
1800 +index 92b8944f26e3..5bb00234d961 100644
1801 +--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
1802 ++++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
1803 +@@ -33,7 +33,7 @@ struct dma_extended_desc;
1804 + struct stmmac_desc_ops {
1805 + /* DMA RX descriptor ring initialization */
1806 + void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode,
1807 +- int end);
1808 ++ int end, int bfsize);
1809 + /* DMA TX descriptor ring initialization */
1810 + void (*init_tx_desc)(struct dma_desc *p, int mode, int end);
1811 + /* Invoked by the xmit function to prepare the tx descriptor */
1812 +diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
1813 +index de65bb29feba..b7dd4e3c760d 100644
1814 +--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
1815 ++++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
1816 +@@ -91,8 +91,6 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x,
1817 + return dma_own;
1818 +
1819 + if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) {
1820 +- pr_warn("%s: Oversized frame spanned multiple buffers\n",
1821 +- __func__);
1822 + stats->rx_length_errors++;
1823 + return discard_frame;
1824 + }
1825 +@@ -135,15 +133,19 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x,
1826 + }
1827 +
1828 + static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
1829 +- int end)
1830 ++ int end, int bfsize)
1831 + {
1832 ++ int bfsize1;
1833 ++
1834 + p->des0 |= cpu_to_le32(RDES0_OWN);
1835 +- p->des1 |= cpu_to_le32((BUF_SIZE_2KiB - 1) & RDES1_BUFFER1_SIZE_MASK);
1836 ++
1837 ++ bfsize1 = min(bfsize, BUF_SIZE_2KiB - 1);
1838 ++ p->des1 |= cpu_to_le32(bfsize & RDES1_BUFFER1_SIZE_MASK);
1839 +
1840 + if (mode == STMMAC_CHAIN_MODE)
1841 + ndesc_rx_set_on_chain(p, end);
1842 + else
1843 +- ndesc_rx_set_on_ring(p, end);
1844 ++ ndesc_rx_set_on_ring(p, end, bfsize);
1845 +
1846 + if (disable_rx_ic)
1847 + p->des1 |= cpu_to_le32(RDES1_DISABLE_IC);
1848 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
1849 +index 39c105092214..5debe93ea4eb 100644
1850 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
1851 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
1852 +@@ -1111,11 +1111,13 @@ static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv, u32 queue)
1853 + if (priv->extend_desc)
1854 + stmmac_init_rx_desc(priv, &rx_q->dma_erx[i].basic,
1855 + priv->use_riwt, priv->mode,
1856 +- (i == DMA_RX_SIZE - 1));
1857 ++ (i == DMA_RX_SIZE - 1),
1858 ++ priv->dma_buf_sz);
1859 + else
1860 + stmmac_init_rx_desc(priv, &rx_q->dma_rx[i],
1861 + priv->use_riwt, priv->mode,
1862 +- (i == DMA_RX_SIZE - 1));
1863 ++ (i == DMA_RX_SIZE - 1),
1864 ++ priv->dma_buf_sz);
1865 + }
1866 +
1867 + /**
1868 +@@ -3331,9 +3333,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1869 + {
1870 + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
1871 + struct stmmac_channel *ch = &priv->channel[queue];
1872 +- unsigned int entry = rx_q->cur_rx;
1873 ++ unsigned int next_entry = rx_q->cur_rx;
1874 + int coe = priv->hw->rx_csum;
1875 +- unsigned int next_entry;
1876 + unsigned int count = 0;
1877 + bool xmac;
1878 +
1879 +@@ -3351,10 +3352,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1880 + stmmac_display_ring(priv, rx_head, DMA_RX_SIZE, true);
1881 + }
1882 + while (count < limit) {
1883 +- int status;
1884 ++ int entry, status;
1885 + struct dma_desc *p;
1886 + struct dma_desc *np;
1887 +
1888 ++ entry = next_entry;
1889 ++
1890 + if (priv->extend_desc)
1891 + p = (struct dma_desc *)(rx_q->dma_erx + entry);
1892 + else
1893 +@@ -3410,11 +3413,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1894 + * ignored
1895 + */
1896 + if (frame_len > priv->dma_buf_sz) {
1897 +- netdev_err(priv->dev,
1898 +- "len %d larger than size (%d)\n",
1899 +- frame_len, priv->dma_buf_sz);
1900 ++ if (net_ratelimit())
1901 ++ netdev_err(priv->dev,
1902 ++ "len %d larger than size (%d)\n",
1903 ++ frame_len, priv->dma_buf_sz);
1904 + priv->dev->stats.rx_length_errors++;
1905 +- break;
1906 ++ continue;
1907 + }
1908 +
1909 + /* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
1910 +@@ -3449,7 +3453,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1911 + dev_warn(priv->device,
1912 + "packet dropped\n");
1913 + priv->dev->stats.rx_dropped++;
1914 +- break;
1915 ++ continue;
1916 + }
1917 +
1918 + dma_sync_single_for_cpu(priv->device,
1919 +@@ -3469,11 +3473,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1920 + } else {
1921 + skb = rx_q->rx_skbuff[entry];
1922 + if (unlikely(!skb)) {
1923 +- netdev_err(priv->dev,
1924 +- "%s: Inconsistent Rx chain\n",
1925 +- priv->dev->name);
1926 ++ if (net_ratelimit())
1927 ++ netdev_err(priv->dev,
1928 ++ "%s: Inconsistent Rx chain\n",
1929 ++ priv->dev->name);
1930 + priv->dev->stats.rx_dropped++;
1931 +- break;
1932 ++ continue;
1933 + }
1934 + prefetch(skb->data - NET_IP_ALIGN);
1935 + rx_q->rx_skbuff[entry] = NULL;
1936 +@@ -3508,7 +3513,6 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
1937 + priv->dev->stats.rx_packets++;
1938 + priv->dev->stats.rx_bytes += frame_len;
1939 + }
1940 +- entry = next_entry;
1941 + }
1942 +
1943 + stmmac_rx_refill(priv, queue);
1944 +diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/5000.c b/drivers/net/wireless/intel/iwlwifi/cfg/5000.c
1945 +index 36151e61a26f..c04d934b23b4 100644
1946 +--- a/drivers/net/wireless/intel/iwlwifi/cfg/5000.c
1947 ++++ b/drivers/net/wireless/intel/iwlwifi/cfg/5000.c
1948 +@@ -1,7 +1,7 @@
1949 + /******************************************************************************
1950 + *
1951 + * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
1952 +- * Copyright(c) 2018 Intel Corporation
1953 ++ * Copyright(c) 2018 - 2019 Intel Corporation
1954 + *
1955 + * This program is free software; you can redistribute it and/or modify it
1956 + * under the terms of version 2 of the GNU General Public License as
1957 +@@ -140,6 +140,7 @@ const struct iwl_cfg iwl5350_agn_cfg = {
1958 + .ht_params = &iwl5000_ht_params,
1959 + .led_mode = IWL_LED_BLINK,
1960 + .internal_wimax_coex = true,
1961 ++ .csr = &iwl_csr_v1,
1962 + };
1963 +
1964 + #define IWL_DEVICE_5150 \
1965 +diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
1966 +index d49fbd58afa7..bfbe3aa058d9 100644
1967 +--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
1968 ++++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
1969 +@@ -181,7 +181,7 @@ static int mwifiex_sdio_resume(struct device *dev)
1970 +
1971 + adapter = card->adapter;
1972 +
1973 +- if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
1974 ++ if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
1975 + mwifiex_dbg(adapter, WARN,
1976 + "device already resumed\n");
1977 + return 0;
1978 +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
1979 +index b5ec96abd048..776b7e9e23b9 100644
1980 +--- a/drivers/nvme/target/core.c
1981 ++++ b/drivers/nvme/target/core.c
1982 +@@ -921,6 +921,15 @@ bool nvmet_host_allowed(struct nvmet_req *req, struct nvmet_subsys *subsys,
1983 + return __nvmet_host_allowed(subsys, hostnqn);
1984 + }
1985 +
1986 ++static void nvmet_fatal_error_handler(struct work_struct *work)
1987 ++{
1988 ++ struct nvmet_ctrl *ctrl =
1989 ++ container_of(work, struct nvmet_ctrl, fatal_err_work);
1990 ++
1991 ++ pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
1992 ++ ctrl->ops->delete_ctrl(ctrl);
1993 ++}
1994 ++
1995 + u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
1996 + struct nvmet_req *req, u32 kato, struct nvmet_ctrl **ctrlp)
1997 + {
1998 +@@ -962,6 +971,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
1999 +
2000 + INIT_WORK(&ctrl->async_event_work, nvmet_async_event_work);
2001 + INIT_LIST_HEAD(&ctrl->async_events);
2002 ++ INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
2003 +
2004 + memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
2005 + memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
2006 +@@ -1076,21 +1086,11 @@ void nvmet_ctrl_put(struct nvmet_ctrl *ctrl)
2007 + kref_put(&ctrl->ref, nvmet_ctrl_free);
2008 + }
2009 +
2010 +-static void nvmet_fatal_error_handler(struct work_struct *work)
2011 +-{
2012 +- struct nvmet_ctrl *ctrl =
2013 +- container_of(work, struct nvmet_ctrl, fatal_err_work);
2014 +-
2015 +- pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
2016 +- ctrl->ops->delete_ctrl(ctrl);
2017 +-}
2018 +-
2019 + void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl)
2020 + {
2021 + mutex_lock(&ctrl->lock);
2022 + if (!(ctrl->csts & NVME_CSTS_CFS)) {
2023 + ctrl->csts |= NVME_CSTS_CFS;
2024 +- INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
2025 + schedule_work(&ctrl->fatal_err_work);
2026 + }
2027 + mutex_unlock(&ctrl->lock);
2028 +diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
2029 +index e0dcdb3cc070..088d1c2047e6 100644
2030 +--- a/drivers/platform/x86/intel_pmc_core.c
2031 ++++ b/drivers/platform/x86/intel_pmc_core.c
2032 +@@ -185,7 +185,7 @@ static const struct pmc_bit_map cnp_pfear_map[] = {
2033 + {"CNVI", BIT(3)},
2034 + {"UFS0", BIT(4)},
2035 + {"EMMC", BIT(5)},
2036 +- {"Res_6", BIT(6)},
2037 ++ {"SPF", BIT(6)},
2038 + {"SBR6", BIT(7)},
2039 +
2040 + {"SBR7", BIT(0)},
2041 +@@ -682,7 +682,7 @@ static int __init pmc_core_probe(void)
2042 + * Sunrisepoint PCH regmap can't be used. Use Cannonlake PCH regmap
2043 + * in this case.
2044 + */
2045 +- if (!pci_dev_present(pmc_pci_ids))
2046 ++ if (pmcdev->map == &spt_reg_map && !pci_dev_present(pmc_pci_ids))
2047 + pmcdev->map = &cnp_reg_map;
2048 +
2049 + if (lpit_read_residency_count_address(&slp_s0_addr))
2050 +diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
2051 +index 8f018b3f3cd4..eaec2d306481 100644
2052 +--- a/drivers/platform/x86/pmc_atom.c
2053 ++++ b/drivers/platform/x86/pmc_atom.c
2054 +@@ -17,6 +17,7 @@
2055 +
2056 + #include <linux/debugfs.h>
2057 + #include <linux/device.h>
2058 ++#include <linux/dmi.h>
2059 + #include <linux/init.h>
2060 + #include <linux/io.h>
2061 + #include <linux/platform_data/x86/clk-pmc-atom.h>
2062 +@@ -391,11 +392,27 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
2063 + }
2064 + #endif /* CONFIG_DEBUG_FS */
2065 +
2066 ++/*
2067 ++ * Some systems need one or more of their pmc_plt_clks to be
2068 ++ * marked as critical.
2069 ++ */
2070 ++static const struct dmi_system_id critclk_systems[] __initconst = {
2071 ++ {
2072 ++ .ident = "MPL CEC1x",
2073 ++ .matches = {
2074 ++ DMI_MATCH(DMI_SYS_VENDOR, "MPL AG"),
2075 ++ DMI_MATCH(DMI_PRODUCT_NAME, "CEC10 Family"),
2076 ++ },
2077 ++ },
2078 ++ { /*sentinel*/ }
2079 ++};
2080 ++
2081 + static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap,
2082 + const struct pmc_data *pmc_data)
2083 + {
2084 + struct platform_device *clkdev;
2085 + struct pmc_clk_data *clk_data;
2086 ++ const struct dmi_system_id *d = dmi_first_match(critclk_systems);
2087 +
2088 + clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
2089 + if (!clk_data)
2090 +@@ -403,6 +420,10 @@ static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap,
2091 +
2092 + clk_data->base = pmc_regmap; /* offset is added by client */
2093 + clk_data->clks = pmc_data->clks;
2094 ++ if (d) {
2095 ++ clk_data->critical = true;
2096 ++ pr_info("%s critclks quirk enabled\n", d->ident);
2097 ++ }
2098 +
2099 + clkdev = platform_device_register_data(&pdev->dev, "clk-pmc-atom",
2100 + PLATFORM_DEVID_NONE,
2101 +diff --git a/drivers/reset/reset-meson-audio-arb.c b/drivers/reset/reset-meson-audio-arb.c
2102 +index 91751617b37a..c53a2185a039 100644
2103 +--- a/drivers/reset/reset-meson-audio-arb.c
2104 ++++ b/drivers/reset/reset-meson-audio-arb.c
2105 +@@ -130,6 +130,7 @@ static int meson_audio_arb_probe(struct platform_device *pdev)
2106 + arb->rstc.nr_resets = ARRAY_SIZE(axg_audio_arb_reset_bits);
2107 + arb->rstc.ops = &meson_audio_arb_rstc_ops;
2108 + arb->rstc.of_node = dev->of_node;
2109 ++ arb->rstc.owner = THIS_MODULE;
2110 +
2111 + /*
2112 + * Enable general :
2113 +diff --git a/drivers/rtc/rtc-cros-ec.c b/drivers/rtc/rtc-cros-ec.c
2114 +index e5444296075e..4d6bf9304ceb 100644
2115 +--- a/drivers/rtc/rtc-cros-ec.c
2116 ++++ b/drivers/rtc/rtc-cros-ec.c
2117 +@@ -298,7 +298,7 @@ static int cros_ec_rtc_suspend(struct device *dev)
2118 + struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(&pdev->dev);
2119 +
2120 + if (device_may_wakeup(dev))
2121 +- enable_irq_wake(cros_ec_rtc->cros_ec->irq);
2122 ++ return enable_irq_wake(cros_ec_rtc->cros_ec->irq);
2123 +
2124 + return 0;
2125 + }
2126 +@@ -309,7 +309,7 @@ static int cros_ec_rtc_resume(struct device *dev)
2127 + struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(&pdev->dev);
2128 +
2129 + if (device_may_wakeup(dev))
2130 +- disable_irq_wake(cros_ec_rtc->cros_ec->irq);
2131 ++ return disable_irq_wake(cros_ec_rtc->cros_ec->irq);
2132 +
2133 + return 0;
2134 + }
2135 +diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c
2136 +index b4e054c64bad..69b54e5556c0 100644
2137 +--- a/drivers/rtc/rtc-da9063.c
2138 ++++ b/drivers/rtc/rtc-da9063.c
2139 +@@ -480,6 +480,13 @@ static int da9063_rtc_probe(struct platform_device *pdev)
2140 + da9063_data_to_tm(data, &rtc->alarm_time, rtc);
2141 + rtc->rtc_sync = false;
2142 +
2143 ++ /*
2144 ++ * TODO: some models have alarms on a minute boundary but still support
2145 ++ * real hardware interrupts. Add this once the core supports it.
2146 ++ */
2147 ++ if (config->rtc_data_start != RTC_SEC)
2148 ++ rtc->rtc_dev->uie_unsupported = 1;
2149 ++
2150 + irq_alarm = platform_get_irq_byname(pdev, "ALARM");
2151 + ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
2152 + da9063_alarm_event,
2153 +diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
2154 +index 51ba414798a8..3d7414e5ed35 100644
2155 +--- a/drivers/rtc/rtc-sh.c
2156 ++++ b/drivers/rtc/rtc-sh.c
2157 +@@ -377,7 +377,7 @@ static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)
2158 + static inline int sh_rtc_read_alarm_value(struct sh_rtc *rtc, int reg_off)
2159 + {
2160 + unsigned int byte;
2161 +- int value = 0xff; /* return 0xff for ignored values */
2162 ++ int value = -1; /* return -1 for ignored values */
2163 +
2164 + byte = readb(rtc->regbase + reg_off);
2165 + if (byte & AR_ENB) {
2166 +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
2167 +index c4cbfd07b916..a08ff3bd6310 100644
2168 +--- a/drivers/scsi/scsi_devinfo.c
2169 ++++ b/drivers/scsi/scsi_devinfo.c
2170 +@@ -238,6 +238,7 @@ static struct {
2171 + {"NETAPP", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
2172 + {"LSI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
2173 + {"ENGENIO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
2174 ++ {"LENOVO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
2175 + {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
2176 + {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
2177 + {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */
2178 +diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
2179 +index 5a58cbf3a75d..c14006ac98f9 100644
2180 +--- a/drivers/scsi/scsi_dh.c
2181 ++++ b/drivers/scsi/scsi_dh.c
2182 +@@ -75,6 +75,7 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
2183 + {"NETAPP", "INF-01-00", "rdac", },
2184 + {"LSI", "INF-01-00", "rdac", },
2185 + {"ENGENIO", "INF-01-00", "rdac", },
2186 ++ {"LENOVO", "DE_Series", "rdac", },
2187 + {NULL, NULL, NULL },
2188 + };
2189 +
2190 +diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
2191 +index f03dc03a42c3..0c2ba075bc71 100644
2192 +--- a/drivers/scsi/storvsc_drv.c
2193 ++++ b/drivers/scsi/storvsc_drv.c
2194 +@@ -664,13 +664,22 @@ static void handle_sc_creation(struct vmbus_channel *new_sc)
2195 + static void handle_multichannel_storage(struct hv_device *device, int max_chns)
2196 + {
2197 + struct storvsc_device *stor_device;
2198 +- int num_cpus = num_online_cpus();
2199 + int num_sc;
2200 + struct storvsc_cmd_request *request;
2201 + struct vstor_packet *vstor_packet;
2202 + int ret, t;
2203 +
2204 +- num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns);
2205 ++ /*
2206 ++ * If the number of CPUs is artificially restricted, such as
2207 ++ * with maxcpus=1 on the kernel boot line, Hyper-V could offer
2208 ++ * sub-channels >= the number of CPUs. These sub-channels
2209 ++ * should not be created. The primary channel is already created
2210 ++ * and assigned to one CPU, so check against # CPUs - 1.
2211 ++ */
2212 ++ num_sc = min((int)(num_online_cpus() - 1), max_chns);
2213 ++ if (!num_sc)
2214 ++ return;
2215 ++
2216 + stor_device = get_out_stor_device(device);
2217 + if (!stor_device)
2218 + return;
2219 +diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
2220 +index 3f22d1088713..68866f552290 100644
2221 +--- a/drivers/staging/iio/addac/adt7316.c
2222 ++++ b/drivers/staging/iio/addac/adt7316.c
2223 +@@ -47,6 +47,8 @@
2224 + #define ADT7516_MSB_AIN3 0xA
2225 + #define ADT7516_MSB_AIN4 0xB
2226 + #define ADT7316_DA_DATA_BASE 0x10
2227 ++#define ADT7316_DA_10_BIT_LSB_SHIFT 6
2228 ++#define ADT7316_DA_12_BIT_LSB_SHIFT 4
2229 + #define ADT7316_DA_MSB_DATA_REGS 4
2230 + #define ADT7316_LSB_DAC_A 0x10
2231 + #define ADT7316_MSB_DAC_A 0x11
2232 +@@ -1086,7 +1088,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev,
2233 + ldac_config = chip->ldac_config & (~ADT7516_DAC_IN_VREF_MASK);
2234 + if (data & 0x1)
2235 + ldac_config |= ADT7516_DAC_AB_IN_VREF;
2236 +- else if (data & 0x2)
2237 ++ if (data & 0x2)
2238 + ldac_config |= ADT7516_DAC_CD_IN_VREF;
2239 + } else {
2240 + ret = kstrtou8(buf, 16, &data);
2241 +@@ -1408,7 +1410,7 @@ static IIO_DEVICE_ATTR(ex_analog_temp_offset, 0644,
2242 + static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip,
2243 + int channel, char *buf)
2244 + {
2245 +- u16 data;
2246 ++ u16 data = 0;
2247 + u8 msb, lsb, offset;
2248 + int ret;
2249 +
2250 +@@ -1433,7 +1435,11 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip,
2251 + if (ret)
2252 + return -EIO;
2253 +
2254 +- data = (msb << offset) + (lsb & ((1 << offset) - 1));
2255 ++ if (chip->dac_bits == 12)
2256 ++ data = lsb >> ADT7316_DA_12_BIT_LSB_SHIFT;
2257 ++ else if (chip->dac_bits == 10)
2258 ++ data = lsb >> ADT7316_DA_10_BIT_LSB_SHIFT;
2259 ++ data |= msb << offset;
2260 +
2261 + return sprintf(buf, "%d\n", data);
2262 + }
2263 +@@ -1441,7 +1447,7 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip,
2264 + static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,
2265 + int channel, const char *buf, size_t len)
2266 + {
2267 +- u8 msb, lsb, offset;
2268 ++ u8 msb, lsb, lsb_reg, offset;
2269 + u16 data;
2270 + int ret;
2271 +
2272 +@@ -1459,9 +1465,13 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,
2273 + return -EINVAL;
2274 +
2275 + if (chip->dac_bits > 8) {
2276 +- lsb = data & (1 << offset);
2277 ++ lsb = data & ((1 << offset) - 1);
2278 ++ if (chip->dac_bits == 12)
2279 ++ lsb_reg = lsb << ADT7316_DA_12_BIT_LSB_SHIFT;
2280 ++ else
2281 ++ lsb_reg = lsb << ADT7316_DA_10_BIT_LSB_SHIFT;
2282 + ret = chip->bus.write(chip->bus.client,
2283 +- ADT7316_DA_DATA_BASE + channel * 2, lsb);
2284 ++ ADT7316_DA_DATA_BASE + channel * 2, lsb_reg);
2285 + if (ret)
2286 + return -EIO;
2287 + }
2288 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
2289 +index ef47c226e1d2..3255b2bb0fd5 100644
2290 +--- a/drivers/usb/core/driver.c
2291 ++++ b/drivers/usb/core/driver.c
2292 +@@ -473,11 +473,6 @@ static int usb_unbind_interface(struct device *dev)
2293 + pm_runtime_disable(dev);
2294 + pm_runtime_set_suspended(dev);
2295 +
2296 +- /* Undo any residual pm_autopm_get_interface_* calls */
2297 +- for (r = atomic_read(&intf->pm_usage_cnt); r > 0; --r)
2298 +- usb_autopm_put_interface_no_suspend(intf);
2299 +- atomic_set(&intf->pm_usage_cnt, 0);
2300 +-
2301 + if (!error)
2302 + usb_autosuspend_device(udev);
2303 +
2304 +@@ -1636,7 +1631,6 @@ void usb_autopm_put_interface(struct usb_interface *intf)
2305 + int status;
2306 +
2307 + usb_mark_last_busy(udev);
2308 +- atomic_dec(&intf->pm_usage_cnt);
2309 + status = pm_runtime_put_sync(&intf->dev);
2310 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
2311 + __func__, atomic_read(&intf->dev.power.usage_count),
2312 +@@ -1665,7 +1659,6 @@ void usb_autopm_put_interface_async(struct usb_interface *intf)
2313 + int status;
2314 +
2315 + usb_mark_last_busy(udev);
2316 +- atomic_dec(&intf->pm_usage_cnt);
2317 + status = pm_runtime_put(&intf->dev);
2318 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
2319 + __func__, atomic_read(&intf->dev.power.usage_count),
2320 +@@ -1687,7 +1680,6 @@ void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
2321 + struct usb_device *udev = interface_to_usbdev(intf);
2322 +
2323 + usb_mark_last_busy(udev);
2324 +- atomic_dec(&intf->pm_usage_cnt);
2325 + pm_runtime_put_noidle(&intf->dev);
2326 + }
2327 + EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend);
2328 +@@ -1718,8 +1710,6 @@ int usb_autopm_get_interface(struct usb_interface *intf)
2329 + status = pm_runtime_get_sync(&intf->dev);
2330 + if (status < 0)
2331 + pm_runtime_put_sync(&intf->dev);
2332 +- else
2333 +- atomic_inc(&intf->pm_usage_cnt);
2334 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
2335 + __func__, atomic_read(&intf->dev.power.usage_count),
2336 + status);
2337 +@@ -1753,8 +1743,6 @@ int usb_autopm_get_interface_async(struct usb_interface *intf)
2338 + status = pm_runtime_get(&intf->dev);
2339 + if (status < 0 && status != -EINPROGRESS)
2340 + pm_runtime_put_noidle(&intf->dev);
2341 +- else
2342 +- atomic_inc(&intf->pm_usage_cnt);
2343 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
2344 + __func__, atomic_read(&intf->dev.power.usage_count),
2345 + status);
2346 +@@ -1778,7 +1766,6 @@ void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
2347 + struct usb_device *udev = interface_to_usbdev(intf);
2348 +
2349 + usb_mark_last_busy(udev);
2350 +- atomic_inc(&intf->pm_usage_cnt);
2351 + pm_runtime_get_noresume(&intf->dev);
2352 + }
2353 + EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume);
2354 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
2355 +index 4f33eb632a88..4020ce8db6ce 100644
2356 +--- a/drivers/usb/core/message.c
2357 ++++ b/drivers/usb/core/message.c
2358 +@@ -820,9 +820,11 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
2359 +
2360 + if (dev->state == USB_STATE_SUSPENDED)
2361 + return -EHOSTUNREACH;
2362 +- if (size <= 0 || !buf || !index)
2363 ++ if (size <= 0 || !buf)
2364 + return -EINVAL;
2365 + buf[0] = 0;
2366 ++ if (index <= 0 || index >= 256)
2367 ++ return -EINVAL;
2368 + tbuf = kmalloc(256, GFP_NOIO);
2369 + if (!tbuf)
2370 + return -ENOMEM;
2371 +diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
2372 +index baf72f95f0f1..213b52508621 100644
2373 +--- a/drivers/usb/gadget/udc/dummy_hcd.c
2374 ++++ b/drivers/usb/gadget/udc/dummy_hcd.c
2375 +@@ -979,8 +979,18 @@ static int dummy_udc_start(struct usb_gadget *g,
2376 + struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g);
2377 + struct dummy *dum = dum_hcd->dum;
2378 +
2379 +- if (driver->max_speed == USB_SPEED_UNKNOWN)
2380 ++ switch (g->speed) {
2381 ++ /* All the speeds we support */
2382 ++ case USB_SPEED_LOW:
2383 ++ case USB_SPEED_FULL:
2384 ++ case USB_SPEED_HIGH:
2385 ++ case USB_SPEED_SUPER:
2386 ++ break;
2387 ++ default:
2388 ++ dev_err(dummy_dev(dum_hcd), "Unsupported driver max speed %d\n",
2389 ++ driver->max_speed);
2390 + return -EINVAL;
2391 ++ }
2392 +
2393 + /*
2394 + * SLAVE side init ... the layer above hardware, which
2395 +@@ -1784,9 +1794,10 @@ static void dummy_timer(struct timer_list *t)
2396 + /* Bus speed is 500000 bytes/ms, so use a little less */
2397 + total = 490000;
2398 + break;
2399 +- default:
2400 ++ default: /* Can't happen */
2401 + dev_err(dummy_dev(dum_hcd), "bogus device speed\n");
2402 +- return;
2403 ++ total = 0;
2404 ++ break;
2405 + }
2406 +
2407 + /* FIXME if HZ != 1000 this will probably misbehave ... */
2408 +@@ -1828,7 +1839,7 @@ restart:
2409 +
2410 + /* Used up this frame's bandwidth? */
2411 + if (total <= 0)
2412 +- break;
2413 ++ continue;
2414 +
2415 + /* find the gadget's ep for this request (if configured) */
2416 + address = usb_pipeendpoint (urb->pipe);
2417 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
2418 +index 6d9fd5f64903..7b306aa22d25 100644
2419 +--- a/drivers/usb/misc/yurex.c
2420 ++++ b/drivers/usb/misc/yurex.c
2421 +@@ -314,6 +314,7 @@ static void yurex_disconnect(struct usb_interface *interface)
2422 + usb_deregister_dev(interface, &yurex_class);
2423 +
2424 + /* prevent more I/O from starting */
2425 ++ usb_poison_urb(dev->urb);
2426 + mutex_lock(&dev->io_mutex);
2427 + dev->interface = NULL;
2428 + mutex_unlock(&dev->io_mutex);
2429 +diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
2430 +index 31b024441938..cc794e25a0b6 100644
2431 +--- a/drivers/usb/storage/realtek_cr.c
2432 ++++ b/drivers/usb/storage/realtek_cr.c
2433 +@@ -763,18 +763,16 @@ static void rts51x_suspend_timer_fn(struct timer_list *t)
2434 + break;
2435 + case RTS51X_STAT_IDLE:
2436 + case RTS51X_STAT_SS:
2437 +- usb_stor_dbg(us, "RTS51X_STAT_SS, intf->pm_usage_cnt:%d, power.usage:%d\n",
2438 +- atomic_read(&us->pusb_intf->pm_usage_cnt),
2439 ++ usb_stor_dbg(us, "RTS51X_STAT_SS, power.usage:%d\n",
2440 + atomic_read(&us->pusb_intf->dev.power.usage_count));
2441 +
2442 +- if (atomic_read(&us->pusb_intf->pm_usage_cnt) > 0) {
2443 ++ if (atomic_read(&us->pusb_intf->dev.power.usage_count) > 0) {
2444 + usb_stor_dbg(us, "Ready to enter SS state\n");
2445 + rts51x_set_stat(chip, RTS51X_STAT_SS);
2446 + /* ignore mass storage interface's children */
2447 + pm_suspend_ignore_children(&us->pusb_intf->dev, true);
2448 + usb_autopm_put_interface_async(us->pusb_intf);
2449 +- usb_stor_dbg(us, "RTS51X_STAT_SS 01, intf->pm_usage_cnt:%d, power.usage:%d\n",
2450 +- atomic_read(&us->pusb_intf->pm_usage_cnt),
2451 ++ usb_stor_dbg(us, "RTS51X_STAT_SS 01, power.usage:%d\n",
2452 + atomic_read(&us->pusb_intf->dev.power.usage_count));
2453 + }
2454 + break;
2455 +@@ -807,11 +805,10 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
2456 + int ret;
2457 +
2458 + if (working_scsi(srb)) {
2459 +- usb_stor_dbg(us, "working scsi, intf->pm_usage_cnt:%d, power.usage:%d\n",
2460 +- atomic_read(&us->pusb_intf->pm_usage_cnt),
2461 ++ usb_stor_dbg(us, "working scsi, power.usage:%d\n",
2462 + atomic_read(&us->pusb_intf->dev.power.usage_count));
2463 +
2464 +- if (atomic_read(&us->pusb_intf->pm_usage_cnt) <= 0) {
2465 ++ if (atomic_read(&us->pusb_intf->dev.power.usage_count) <= 0) {
2466 + ret = usb_autopm_get_interface(us->pusb_intf);
2467 + usb_stor_dbg(us, "working scsi, ret=%d\n", ret);
2468 + }
2469 +diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
2470 +index 97b09a42a10c..dbfb2f24d71e 100644
2471 +--- a/drivers/usb/usbip/stub_rx.c
2472 ++++ b/drivers/usb/usbip/stub_rx.c
2473 +@@ -361,16 +361,10 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
2474 + }
2475 +
2476 + if (usb_endpoint_xfer_isoc(epd)) {
2477 +- /* validate packet size and number of packets */
2478 +- unsigned int maxp, packets, bytes;
2479 +-
2480 +- maxp = usb_endpoint_maxp(epd);
2481 +- maxp *= usb_endpoint_maxp_mult(epd);
2482 +- bytes = pdu->u.cmd_submit.transfer_buffer_length;
2483 +- packets = DIV_ROUND_UP(bytes, maxp);
2484 +-
2485 ++ /* validate number of packets */
2486 + if (pdu->u.cmd_submit.number_of_packets < 0 ||
2487 +- pdu->u.cmd_submit.number_of_packets > packets) {
2488 ++ pdu->u.cmd_submit.number_of_packets >
2489 ++ USBIP_MAX_ISO_PACKETS) {
2490 + dev_err(&sdev->udev->dev,
2491 + "CMD_SUBMIT: isoc invalid num packets %d\n",
2492 + pdu->u.cmd_submit.number_of_packets);
2493 +diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
2494 +index bf8afe9b5883..8be857a4fa13 100644
2495 +--- a/drivers/usb/usbip/usbip_common.h
2496 ++++ b/drivers/usb/usbip/usbip_common.h
2497 +@@ -121,6 +121,13 @@ extern struct device_attribute dev_attr_usbip_debug;
2498 + #define USBIP_DIR_OUT 0x00
2499 + #define USBIP_DIR_IN 0x01
2500 +
2501 ++/*
2502 ++ * Arbitrary limit for the maximum number of isochronous packets in an URB,
2503 ++ * compare for example the uhci_submit_isochronous function in
2504 ++ * drivers/usb/host/uhci-q.c
2505 ++ */
2506 ++#define USBIP_MAX_ISO_PACKETS 1024
2507 ++
2508 + /**
2509 + * struct usbip_header_basic - data pertinent to every request
2510 + * @command: the usbip request type
2511 +diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
2512 +index cddb453a1ba5..6cf00d9f512b 100644
2513 +--- a/drivers/vfio/pci/vfio_pci.c
2514 ++++ b/drivers/vfio/pci/vfio_pci.c
2515 +@@ -1443,11 +1443,11 @@ static void __init vfio_pci_fill_ids(void)
2516 + rc = pci_add_dynid(&vfio_pci_driver, vendor, device,
2517 + subvendor, subdevice, class, class_mask, 0);
2518 + if (rc)
2519 +- pr_warn("failed to add dynamic id [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x (%d)\n",
2520 ++ pr_warn("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n",
2521 + vendor, device, subvendor, subdevice,
2522 + class, class_mask, rc);
2523 + else
2524 +- pr_info("add [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x\n",
2525 ++ pr_info("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n",
2526 + vendor, device, subvendor, subdevice,
2527 + class, class_mask);
2528 + }
2529 +diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
2530 +index 0f4ecfcdb549..a9fb77585272 100644
2531 +--- a/drivers/w1/masters/ds2490.c
2532 ++++ b/drivers/w1/masters/ds2490.c
2533 +@@ -1016,15 +1016,15 @@ static int ds_probe(struct usb_interface *intf,
2534 + /* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */
2535 + alt = 3;
2536 + err = usb_set_interface(dev->udev,
2537 +- intf->altsetting[alt].desc.bInterfaceNumber, alt);
2538 ++ intf->cur_altsetting->desc.bInterfaceNumber, alt);
2539 + if (err) {
2540 + dev_err(&dev->udev->dev, "Failed to set alternative setting %d "
2541 + "for %d interface: err=%d.\n", alt,
2542 +- intf->altsetting[alt].desc.bInterfaceNumber, err);
2543 ++ intf->cur_altsetting->desc.bInterfaceNumber, err);
2544 + goto err_out_clear;
2545 + }
2546 +
2547 +- iface_desc = &intf->altsetting[alt];
2548 ++ iface_desc = intf->cur_altsetting;
2549 + if (iface_desc->desc.bNumEndpoints != NUM_EP-1) {
2550 + pr_info("Num endpoints=%d. It is not DS9490R.\n",
2551 + iface_desc->desc.bNumEndpoints);
2552 +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
2553 +index c3e201025ef0..0782ff3c2273 100644
2554 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
2555 ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
2556 +@@ -622,9 +622,7 @@ static int xenbus_file_open(struct inode *inode, struct file *filp)
2557 + if (xen_store_evtchn == 0)
2558 + return -ENOENT;
2559 +
2560 +- nonseekable_open(inode, filp);
2561 +-
2562 +- filp->f_mode &= ~FMODE_ATOMIC_POS; /* cdev-style semantics */
2563 ++ stream_open(inode, filp);
2564 +
2565 + u = kzalloc(sizeof(*u), GFP_KERNEL);
2566 + if (u == NULL)
2567 +diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
2568 +index 41ef452c1fcf..e5126fad57c5 100644
2569 +--- a/fs/debugfs/inode.c
2570 ++++ b/fs/debugfs/inode.c
2571 +@@ -163,19 +163,24 @@ static int debugfs_show_options(struct seq_file *m, struct dentry *root)
2572 + return 0;
2573 + }
2574 +
2575 +-static void debugfs_evict_inode(struct inode *inode)
2576 ++static void debugfs_i_callback(struct rcu_head *head)
2577 + {
2578 +- truncate_inode_pages_final(&inode->i_data);
2579 +- clear_inode(inode);
2580 ++ struct inode *inode = container_of(head, struct inode, i_rcu);
2581 + if (S_ISLNK(inode->i_mode))
2582 + kfree(inode->i_link);
2583 ++ free_inode_nonrcu(inode);
2584 ++}
2585 ++
2586 ++static void debugfs_destroy_inode(struct inode *inode)
2587 ++{
2588 ++ call_rcu(&inode->i_rcu, debugfs_i_callback);
2589 + }
2590 +
2591 + static const struct super_operations debugfs_super_operations = {
2592 + .statfs = simple_statfs,
2593 + .remount_fs = debugfs_remount,
2594 + .show_options = debugfs_show_options,
2595 +- .evict_inode = debugfs_evict_inode,
2596 ++ .destroy_inode = debugfs_destroy_inode,
2597 + };
2598 +
2599 + static void debugfs_release_dentry(struct dentry *dentry)
2600 +diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
2601 +index a7fa037b876b..a3a3d256fb0e 100644
2602 +--- a/fs/hugetlbfs/inode.c
2603 ++++ b/fs/hugetlbfs/inode.c
2604 +@@ -741,11 +741,17 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
2605 + umode_t mode, dev_t dev)
2606 + {
2607 + struct inode *inode;
2608 +- struct resv_map *resv_map;
2609 ++ struct resv_map *resv_map = NULL;
2610 +
2611 +- resv_map = resv_map_alloc();
2612 +- if (!resv_map)
2613 +- return NULL;
2614 ++ /*
2615 ++ * Reserve maps are only needed for inodes that can have associated
2616 ++ * page allocations.
2617 ++ */
2618 ++ if (S_ISREG(mode) || S_ISLNK(mode)) {
2619 ++ resv_map = resv_map_alloc();
2620 ++ if (!resv_map)
2621 ++ return NULL;
2622 ++ }
2623 +
2624 + inode = new_inode(sb);
2625 + if (inode) {
2626 +@@ -780,8 +786,10 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
2627 + break;
2628 + }
2629 + lockdep_annotate_inode_mutex_key(inode);
2630 +- } else
2631 +- kref_put(&resv_map->refs, resv_map_release);
2632 ++ } else {
2633 ++ if (resv_map)
2634 ++ kref_put(&resv_map->refs, resv_map_release);
2635 ++ }
2636 +
2637 + return inode;
2638 + }
2639 +diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
2640 +index 389ea53ea487..bccfc40b3a74 100644
2641 +--- a/fs/jffs2/readinode.c
2642 ++++ b/fs/jffs2/readinode.c
2643 +@@ -1414,11 +1414,6 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
2644 +
2645 + jffs2_kill_fragtree(&f->fragtree, deleted?c:NULL);
2646 +
2647 +- if (f->target) {
2648 +- kfree(f->target);
2649 +- f->target = NULL;
2650 +- }
2651 +-
2652 + fds = f->dents;
2653 + while(fds) {
2654 + fd = fds;
2655 +diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
2656 +index bb6ae387469f..05d892c79339 100644
2657 +--- a/fs/jffs2/super.c
2658 ++++ b/fs/jffs2/super.c
2659 +@@ -47,7 +47,10 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)
2660 + static void jffs2_i_callback(struct rcu_head *head)
2661 + {
2662 + struct inode *inode = container_of(head, struct inode, i_rcu);
2663 +- kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
2664 ++ struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
2665 ++
2666 ++ kfree(f->target);
2667 ++ kmem_cache_free(jffs2_inode_cachep, f);
2668 + }
2669 +
2670 + static void jffs2_destroy_inode(struct inode *inode)
2671 +diff --git a/fs/open.c b/fs/open.c
2672 +index f1c2f855fd43..a00350018a47 100644
2673 +--- a/fs/open.c
2674 ++++ b/fs/open.c
2675 +@@ -1215,3 +1215,21 @@ int nonseekable_open(struct inode *inode, struct file *filp)
2676 + }
2677 +
2678 + EXPORT_SYMBOL(nonseekable_open);
2679 ++
2680 ++/*
2681 ++ * stream_open is used by subsystems that want stream-like file descriptors.
2682 ++ * Such file descriptors are not seekable and don't have notion of position
2683 ++ * (file.f_pos is always 0). Contrary to file descriptors of other regular
2684 ++ * files, .read() and .write() can run simultaneously.
2685 ++ *
2686 ++ * stream_open never fails and is marked to return int so that it could be
2687 ++ * directly used as file_operations.open .
2688 ++ */
2689 ++int stream_open(struct inode *inode, struct file *filp)
2690 ++{
2691 ++ filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE | FMODE_ATOMIC_POS);
2692 ++ filp->f_mode |= FMODE_STREAM;
2693 ++ return 0;
2694 ++}
2695 ++
2696 ++EXPORT_SYMBOL(stream_open);
2697 +diff --git a/fs/read_write.c b/fs/read_write.c
2698 +index 562974a0616c..85fd7a8ee29e 100644
2699 +--- a/fs/read_write.c
2700 ++++ b/fs/read_write.c
2701 +@@ -560,12 +560,13 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
2702 +
2703 + static inline loff_t file_pos_read(struct file *file)
2704 + {
2705 +- return file->f_pos;
2706 ++ return file->f_mode & FMODE_STREAM ? 0 : file->f_pos;
2707 + }
2708 +
2709 + static inline void file_pos_write(struct file *file, loff_t pos)
2710 + {
2711 +- file->f_pos = pos;
2712 ++ if ((file->f_mode & FMODE_STREAM) == 0)
2713 ++ file->f_pos = pos;
2714 + }
2715 +
2716 + ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count)
2717 +diff --git a/include/linux/fs.h b/include/linux/fs.h
2718 +index 111c94c4baa1..d4e1b43a53c3 100644
2719 +--- a/include/linux/fs.h
2720 ++++ b/include/linux/fs.h
2721 +@@ -153,6 +153,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
2722 + #define FMODE_OPENED ((__force fmode_t)0x80000)
2723 + #define FMODE_CREATED ((__force fmode_t)0x100000)
2724 +
2725 ++/* File is stream-like */
2726 ++#define FMODE_STREAM ((__force fmode_t)0x200000)
2727 ++
2728 + /* File was opened by fanotify and shouldn't generate fanotify events */
2729 + #define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
2730 +
2731 +@@ -3019,6 +3022,7 @@ extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t);
2732 + extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
2733 + extern int generic_file_open(struct inode * inode, struct file * filp);
2734 + extern int nonseekable_open(struct inode * inode, struct file * filp);
2735 ++extern int stream_open(struct inode * inode, struct file * filp);
2736 +
2737 + #ifdef CONFIG_BLOCK
2738 + typedef void (dio_submit_t)(struct bio *bio, struct inode *inode,
2739 +diff --git a/include/linux/i2c.h b/include/linux/i2c.h
2740 +index 65b4eaed1d96..7e748648c7d3 100644
2741 +--- a/include/linux/i2c.h
2742 ++++ b/include/linux/i2c.h
2743 +@@ -333,6 +333,7 @@ struct i2c_client {
2744 + char name[I2C_NAME_SIZE];
2745 + struct i2c_adapter *adapter; /* the adapter we sit on */
2746 + struct device dev; /* the device structure */
2747 ++ int init_irq; /* irq set at initialization */
2748 + int irq; /* irq issued by device */
2749 + struct list_head detected;
2750 + #if IS_ENABLED(CONFIG_I2C_SLAVE)
2751 +diff --git a/include/linux/platform_data/x86/clk-pmc-atom.h b/include/linux/platform_data/x86/clk-pmc-atom.h
2752 +index 3ab892208343..7a37ac27d0fb 100644
2753 +--- a/include/linux/platform_data/x86/clk-pmc-atom.h
2754 ++++ b/include/linux/platform_data/x86/clk-pmc-atom.h
2755 +@@ -35,10 +35,13 @@ struct pmc_clk {
2756 + *
2757 + * @base: PMC clock register base offset
2758 + * @clks: pointer to set of registered clocks, typically 0..5
2759 ++ * @critical: flag to indicate if firmware enabled pmc_plt_clks
2760 ++ * should be marked as critial or not
2761 + */
2762 + struct pmc_clk_data {
2763 + void __iomem *base;
2764 + const struct pmc_clk *clks;
2765 ++ bool critical;
2766 + };
2767 +
2768 + #endif /* __PLATFORM_DATA_X86_CLK_PMC_ATOM_H */
2769 +diff --git a/include/linux/usb.h b/include/linux/usb.h
2770 +index 5e49e82c4368..ff010d1fd1c7 100644
2771 +--- a/include/linux/usb.h
2772 ++++ b/include/linux/usb.h
2773 +@@ -200,7 +200,6 @@ usb_find_last_int_out_endpoint(struct usb_host_interface *alt,
2774 + * @dev: driver model's view of this device
2775 + * @usb_dev: if an interface is bound to the USB major, this will point
2776 + * to the sysfs representation for that device.
2777 +- * @pm_usage_cnt: PM usage counter for this interface
2778 + * @reset_ws: Used for scheduling resets from atomic context.
2779 + * @resetting_device: USB core reset the device, so use alt setting 0 as
2780 + * current; needs bandwidth alloc after reset.
2781 +@@ -257,7 +256,6 @@ struct usb_interface {
2782 +
2783 + struct device dev; /* interface specific device info */
2784 + struct device *usb_dev;
2785 +- atomic_t pm_usage_cnt; /* usage counter for autosuspend */
2786 + struct work_struct reset_ws; /* for resets in atomic context */
2787 + };
2788 + #define to_usb_interface(d) container_of(d, struct usb_interface, dev)
2789 +diff --git a/mm/kmemleak.c b/mm/kmemleak.c
2790 +index 17dd883198ae..72e3fb3bb037 100644
2791 +--- a/mm/kmemleak.c
2792 ++++ b/mm/kmemleak.c
2793 +@@ -1373,6 +1373,7 @@ static void scan_block(void *_start, void *_end,
2794 + /*
2795 + * Scan a large memory block in MAX_SCAN_SIZE chunks to reduce the latency.
2796 + */
2797 ++#ifdef CONFIG_SMP
2798 + static void scan_large_block(void *start, void *end)
2799 + {
2800 + void *next;
2801 +@@ -1384,6 +1385,7 @@ static void scan_large_block(void *start, void *end)
2802 + cond_resched();
2803 + }
2804 + }
2805 ++#endif
2806 +
2807 + /*
2808 + * Scan a memory block corresponding to a kmemleak_object. A condition is
2809 +@@ -1501,11 +1503,6 @@ static void kmemleak_scan(void)
2810 + }
2811 + rcu_read_unlock();
2812 +
2813 +- /* data/bss scanning */
2814 +- scan_large_block(_sdata, _edata);
2815 +- scan_large_block(__bss_start, __bss_stop);
2816 +- scan_large_block(__start_ro_after_init, __end_ro_after_init);
2817 +-
2818 + #ifdef CONFIG_SMP
2819 + /* per-cpu sections scanning */
2820 + for_each_possible_cpu(i)
2821 +@@ -2036,6 +2033,17 @@ void __init kmemleak_init(void)
2822 + }
2823 + local_irq_restore(flags);
2824 +
2825 ++ /* register the data/bss sections */
2826 ++ create_object((unsigned long)_sdata, _edata - _sdata,
2827 ++ KMEMLEAK_GREY, GFP_ATOMIC);
2828 ++ create_object((unsigned long)__bss_start, __bss_stop - __bss_start,
2829 ++ KMEMLEAK_GREY, GFP_ATOMIC);
2830 ++ /* only register .data..ro_after_init if not within .data */
2831 ++ if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
2832 ++ create_object((unsigned long)__start_ro_after_init,
2833 ++ __end_ro_after_init - __start_ro_after_init,
2834 ++ KMEMLEAK_GREY, GFP_ATOMIC);
2835 ++
2836 + /*
2837 + * This is the point where tracking allocations is safe. Automatic
2838 + * scanning is started during the late initcall. Add the early logged
2839 +diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
2840 +index ef0dec20c7d8..5da183b2f4c9 100644
2841 +--- a/net/batman-adv/bat_v_elp.c
2842 ++++ b/net/batman-adv/bat_v_elp.c
2843 +@@ -104,8 +104,10 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
2844 +
2845 + ret = cfg80211_get_station(real_netdev, neigh->addr, &sinfo);
2846 +
2847 +- /* free the TID stats immediately */
2848 +- cfg80211_sinfo_release_content(&sinfo);
2849 ++ if (!ret) {
2850 ++ /* free the TID stats immediately */
2851 ++ cfg80211_sinfo_release_content(&sinfo);
2852 ++ }
2853 +
2854 + dev_put(real_netdev);
2855 + if (ret == -ENOENT) {
2856 +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
2857 +index 5f1aeeded0e3..85faf25c2912 100644
2858 +--- a/net/batman-adv/bridge_loop_avoidance.c
2859 ++++ b/net/batman-adv/bridge_loop_avoidance.c
2860 +@@ -803,6 +803,8 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
2861 + const u8 *mac, const unsigned short vid)
2862 + {
2863 + struct batadv_bla_claim search_claim, *claim;
2864 ++ struct batadv_bla_claim *claim_removed_entry;
2865 ++ struct hlist_node *claim_removed_node;
2866 +
2867 + ether_addr_copy(search_claim.addr, mac);
2868 + search_claim.vid = vid;
2869 +@@ -813,10 +815,18 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
2870 + batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): %pM, vid %d\n", __func__,
2871 + mac, batadv_print_vid(vid));
2872 +
2873 +- batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim,
2874 +- batadv_choose_claim, claim);
2875 +- batadv_claim_put(claim); /* reference from the hash is gone */
2876 ++ claim_removed_node = batadv_hash_remove(bat_priv->bla.claim_hash,
2877 ++ batadv_compare_claim,
2878 ++ batadv_choose_claim, claim);
2879 ++ if (!claim_removed_node)
2880 ++ goto free_claim;
2881 +
2882 ++ /* reference from the hash is gone */
2883 ++ claim_removed_entry = hlist_entry(claim_removed_node,
2884 ++ struct batadv_bla_claim, hash_entry);
2885 ++ batadv_claim_put(claim_removed_entry);
2886 ++
2887 ++free_claim:
2888 + /* don't need the reference from hash_find() anymore */
2889 + batadv_claim_put(claim);
2890 + }
2891 +diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
2892 +index d21624c44665..359ec1a6e822 100644
2893 +--- a/net/batman-adv/translation-table.c
2894 ++++ b/net/batman-adv/translation-table.c
2895 +@@ -616,14 +616,26 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
2896 + struct batadv_tt_global_entry *tt_global,
2897 + const char *message)
2898 + {
2899 ++ struct batadv_tt_global_entry *tt_removed_entry;
2900 ++ struct hlist_node *tt_removed_node;
2901 ++
2902 + batadv_dbg(BATADV_DBG_TT, bat_priv,
2903 + "Deleting global tt entry %pM (vid: %d): %s\n",
2904 + tt_global->common.addr,
2905 + batadv_print_vid(tt_global->common.vid), message);
2906 +
2907 +- batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt,
2908 +- batadv_choose_tt, &tt_global->common);
2909 +- batadv_tt_global_entry_put(tt_global);
2910 ++ tt_removed_node = batadv_hash_remove(bat_priv->tt.global_hash,
2911 ++ batadv_compare_tt,
2912 ++ batadv_choose_tt,
2913 ++ &tt_global->common);
2914 ++ if (!tt_removed_node)
2915 ++ return;
2916 ++
2917 ++ /* drop reference of remove hash entry */
2918 ++ tt_removed_entry = hlist_entry(tt_removed_node,
2919 ++ struct batadv_tt_global_entry,
2920 ++ common.hash_entry);
2921 ++ batadv_tt_global_entry_put(tt_removed_entry);
2922 + }
2923 +
2924 + /**
2925 +@@ -1332,9 +1344,10 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
2926 + unsigned short vid, const char *message,
2927 + bool roaming)
2928 + {
2929 ++ struct batadv_tt_local_entry *tt_removed_entry;
2930 + struct batadv_tt_local_entry *tt_local_entry;
2931 + u16 flags, curr_flags = BATADV_NO_FLAGS;
2932 +- void *tt_entry_exists;
2933 ++ struct hlist_node *tt_removed_node;
2934 +
2935 + tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
2936 + if (!tt_local_entry)
2937 +@@ -1363,15 +1376,18 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
2938 + */
2939 + batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
2940 +
2941 +- tt_entry_exists = batadv_hash_remove(bat_priv->tt.local_hash,
2942 ++ tt_removed_node = batadv_hash_remove(bat_priv->tt.local_hash,
2943 + batadv_compare_tt,
2944 + batadv_choose_tt,
2945 + &tt_local_entry->common);
2946 +- if (!tt_entry_exists)
2947 ++ if (!tt_removed_node)
2948 + goto out;
2949 +
2950 +- /* extra call to free the local tt entry */
2951 +- batadv_tt_local_entry_put(tt_local_entry);
2952 ++ /* drop reference of remove hash entry */
2953 ++ tt_removed_entry = hlist_entry(tt_removed_node,
2954 ++ struct batadv_tt_local_entry,
2955 ++ common.hash_entry);
2956 ++ batadv_tt_local_entry_put(tt_removed_entry);
2957 +
2958 + out:
2959 + if (tt_local_entry)
2960 +diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
2961 +index c813207bb123..d37d4acafebf 100644
2962 +--- a/net/mac80211/debugfs_netdev.c
2963 ++++ b/net/mac80211/debugfs_netdev.c
2964 +@@ -838,7 +838,7 @@ void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
2965 +
2966 + dir = sdata->vif.debugfs_dir;
2967 +
2968 +- if (!dir)
2969 ++ if (IS_ERR_OR_NULL(dir))
2970 + return;
2971 +
2972 + sprintf(buf, "netdev:%s", sdata->name);
2973 +diff --git a/net/mac80211/key.c b/net/mac80211/key.c
2974 +index c054ac85793c..f20bb39f492d 100644
2975 +--- a/net/mac80211/key.c
2976 ++++ b/net/mac80211/key.c
2977 +@@ -167,8 +167,10 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
2978 + * The driver doesn't know anything about VLAN interfaces.
2979 + * Hence, don't send GTKs for VLAN interfaces to the driver.
2980 + */
2981 +- if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
2982 ++ if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
2983 ++ ret = 1;
2984 + goto out_unsupported;
2985 ++ }
2986 + }
2987 +
2988 + ret = drv_set_key(key->local, SET_KEY, sdata,
2989 +@@ -213,11 +215,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
2990 + /* all of these we can do in software - if driver can */
2991 + if (ret == 1)
2992 + return 0;
2993 +- if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) {
2994 +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
2995 +- return 0;
2996 ++ if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL))
2997 + return -EINVAL;
2998 +- }
2999 + return 0;
3000 + default:
3001 + return -EINVAL;
3002 +diff --git a/scripts/coccinelle/api/stream_open.cocci b/scripts/coccinelle/api/stream_open.cocci
3003 +new file mode 100644
3004 +index 000000000000..350145da7669
3005 +--- /dev/null
3006 ++++ b/scripts/coccinelle/api/stream_open.cocci
3007 +@@ -0,0 +1,363 @@
3008 ++// SPDX-License-Identifier: GPL-2.0
3009 ++// Author: Kirill Smelkov (kirr@××××××.com)
3010 ++//
3011 ++// Search for stream-like files that are using nonseekable_open and convert
3012 ++// them to stream_open. A stream-like file is a file that does not use ppos in
3013 ++// its read and write. Rationale for the conversion is to avoid deadlock in
3014 ++// between read and write.
3015 ++
3016 ++virtual report
3017 ++virtual patch
3018 ++virtual explain // explain decisions in the patch (SPFLAGS="-D explain")
3019 ++
3020 ++// stream-like reader & writer - ones that do not depend on f_pos.
3021 ++@ stream_reader @
3022 ++identifier readstream, ppos;
3023 ++identifier f, buf, len;
3024 ++type loff_t;
3025 ++@@
3026 ++ ssize_t readstream(struct file *f, char *buf, size_t len, loff_t *ppos)
3027 ++ {
3028 ++ ... when != ppos
3029 ++ }
3030 ++
3031 ++@ stream_writer @
3032 ++identifier writestream, ppos;
3033 ++identifier f, buf, len;
3034 ++type loff_t;
3035 ++@@
3036 ++ ssize_t writestream(struct file *f, const char *buf, size_t len, loff_t *ppos)
3037 ++ {
3038 ++ ... when != ppos
3039 ++ }
3040 ++
3041 ++
3042 ++// a function that blocks
3043 ++@ blocks @
3044 ++identifier block_f;
3045 ++identifier wait_event =~ "^wait_event_.*";
3046 ++@@
3047 ++ block_f(...) {
3048 ++ ... when exists
3049 ++ wait_event(...)
3050 ++ ... when exists
3051 ++ }
3052 ++
3053 ++// stream_reader that can block inside.
3054 ++//
3055 ++// XXX wait_* can be called not directly from current function (e.g. func -> f -> g -> wait())
3056 ++// XXX currently reader_blocks supports only direct and 1-level indirect cases.
3057 ++@ reader_blocks_direct @
3058 ++identifier stream_reader.readstream;
3059 ++identifier wait_event =~ "^wait_event_.*";
3060 ++@@
3061 ++ readstream(...)
3062 ++ {
3063 ++ ... when exists
3064 ++ wait_event(...)
3065 ++ ... when exists
3066 ++ }
3067 ++
3068 ++@ reader_blocks_1 @
3069 ++identifier stream_reader.readstream;
3070 ++identifier blocks.block_f;
3071 ++@@
3072 ++ readstream(...)
3073 ++ {
3074 ++ ... when exists
3075 ++ block_f(...)
3076 ++ ... when exists
3077 ++ }
3078 ++
3079 ++@ reader_blocks depends on reader_blocks_direct || reader_blocks_1 @
3080 ++identifier stream_reader.readstream;
3081 ++@@
3082 ++ readstream(...) {
3083 ++ ...
3084 ++ }
3085 ++
3086 ++
3087 ++// file_operations + whether they have _any_ .read, .write, .llseek ... at all.
3088 ++//
3089 ++// XXX add support for file_operations xxx[N] = ... (sound/core/pcm_native.c)
3090 ++@ fops0 @
3091 ++identifier fops;
3092 ++@@
3093 ++ struct file_operations fops = {
3094 ++ ...
3095 ++ };
3096 ++
3097 ++@ has_read @
3098 ++identifier fops0.fops;
3099 ++identifier read_f;
3100 ++@@
3101 ++ struct file_operations fops = {
3102 ++ .read = read_f,
3103 ++ };
3104 ++
3105 ++@ has_read_iter @
3106 ++identifier fops0.fops;
3107 ++identifier read_iter_f;
3108 ++@@
3109 ++ struct file_operations fops = {
3110 ++ .read_iter = read_iter_f,
3111 ++ };
3112 ++
3113 ++@ has_write @
3114 ++identifier fops0.fops;
3115 ++identifier write_f;
3116 ++@@
3117 ++ struct file_operations fops = {
3118 ++ .write = write_f,
3119 ++ };
3120 ++
3121 ++@ has_write_iter @
3122 ++identifier fops0.fops;
3123 ++identifier write_iter_f;
3124 ++@@
3125 ++ struct file_operations fops = {
3126 ++ .write_iter = write_iter_f,
3127 ++ };
3128 ++
3129 ++@ has_llseek @
3130 ++identifier fops0.fops;
3131 ++identifier llseek_f;
3132 ++@@
3133 ++ struct file_operations fops = {
3134 ++ .llseek = llseek_f,
3135 ++ };
3136 ++
3137 ++@ has_no_llseek @
3138 ++identifier fops0.fops;
3139 ++@@
3140 ++ struct file_operations fops = {
3141 ++ .llseek = no_llseek,
3142 ++ };
3143 ++
3144 ++@ has_mmap @
3145 ++identifier fops0.fops;
3146 ++identifier mmap_f;
3147 ++@@
3148 ++ struct file_operations fops = {
3149 ++ .mmap = mmap_f,
3150 ++ };
3151 ++
3152 ++@ has_copy_file_range @
3153 ++identifier fops0.fops;
3154 ++identifier copy_file_range_f;
3155 ++@@
3156 ++ struct file_operations fops = {
3157 ++ .copy_file_range = copy_file_range_f,
3158 ++ };
3159 ++
3160 ++@ has_remap_file_range @
3161 ++identifier fops0.fops;
3162 ++identifier remap_file_range_f;
3163 ++@@
3164 ++ struct file_operations fops = {
3165 ++ .remap_file_range = remap_file_range_f,
3166 ++ };
3167 ++
3168 ++@ has_splice_read @
3169 ++identifier fops0.fops;
3170 ++identifier splice_read_f;
3171 ++@@
3172 ++ struct file_operations fops = {
3173 ++ .splice_read = splice_read_f,
3174 ++ };
3175 ++
3176 ++@ has_splice_write @
3177 ++identifier fops0.fops;
3178 ++identifier splice_write_f;
3179 ++@@
3180 ++ struct file_operations fops = {
3181 ++ .splice_write = splice_write_f,
3182 ++ };
3183 ++
3184 ++
3185 ++// file_operations that is candidate for stream_open conversion - it does not
3186 ++// use mmap and other methods that assume @offset access to file.
3187 ++//
3188 ++// XXX for simplicity require no .{read/write}_iter and no .splice_{read/write} for now.
3189 ++// XXX maybe_steam.fops cannot be used in other rules - it gives "bad rule maybe_stream or bad variable fops".
3190 ++@ maybe_stream depends on (!has_llseek || has_no_llseek) && !has_mmap && !has_copy_file_range && !has_remap_file_range && !has_read_iter && !has_write_iter && !has_splice_read && !has_splice_write @
3191 ++identifier fops0.fops;
3192 ++@@
3193 ++ struct file_operations fops = {
3194 ++ };
3195 ++
3196 ++
3197 ++// ---- conversions ----
3198 ++
3199 ++// XXX .open = nonseekable_open -> .open = stream_open
3200 ++// XXX .open = func -> openfunc -> nonseekable_open
3201 ++
3202 ++// read & write
3203 ++//
3204 ++// if both are used in the same file_operations together with an opener -
3205 ++// under that conditions we can use stream_open instead of nonseekable_open.
3206 ++@ fops_rw depends on maybe_stream @
3207 ++identifier fops0.fops, openfunc;
3208 ++identifier stream_reader.readstream;
3209 ++identifier stream_writer.writestream;
3210 ++@@
3211 ++ struct file_operations fops = {
3212 ++ .open = openfunc,
3213 ++ .read = readstream,
3214 ++ .write = writestream,
3215 ++ };
3216 ++
3217 ++@ report_rw depends on report @
3218 ++identifier fops_rw.openfunc;
3219 ++position p1;
3220 ++@@
3221 ++ openfunc(...) {
3222 ++ <...
3223 ++ nonseekable_open@p1
3224 ++ ...>
3225 ++ }
3226 ++
3227 ++@ script:python depends on report && reader_blocks @
3228 ++fops << fops0.fops;
3229 ++p << report_rw.p1;
3230 ++@@
3231 ++coccilib.report.print_report(p[0],
3232 ++ "ERROR: %s: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix." % (fops,))
3233 ++
3234 ++@ script:python depends on report && !reader_blocks @
3235 ++fops << fops0.fops;
3236 ++p << report_rw.p1;
3237 ++@@
3238 ++coccilib.report.print_report(p[0],
3239 ++ "WARNING: %s: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open." % (fops,))
3240 ++
3241 ++
3242 ++@ explain_rw_deadlocked depends on explain && reader_blocks @
3243 ++identifier fops_rw.openfunc;
3244 ++@@
3245 ++ openfunc(...) {
3246 ++ <...
3247 ++- nonseekable_open
3248 +++ nonseekable_open /* read & write (was deadlock) */
3249 ++ ...>
3250 ++ }
3251 ++
3252 ++
3253 ++@ explain_rw_nodeadlock depends on explain && !reader_blocks @
3254 ++identifier fops_rw.openfunc;
3255 ++@@
3256 ++ openfunc(...) {
3257 ++ <...
3258 ++- nonseekable_open
3259 +++ nonseekable_open /* read & write (no direct deadlock) */
3260 ++ ...>
3261 ++ }
3262 ++
3263 ++@ patch_rw depends on patch @
3264 ++identifier fops_rw.openfunc;
3265 ++@@
3266 ++ openfunc(...) {
3267 ++ <...
3268 ++- nonseekable_open
3269 +++ stream_open
3270 ++ ...>
3271 ++ }
3272 ++
3273 ++
3274 ++// read, but not write
3275 ++@ fops_r depends on maybe_stream && !has_write @
3276 ++identifier fops0.fops, openfunc;
3277 ++identifier stream_reader.readstream;
3278 ++@@
3279 ++ struct file_operations fops = {
3280 ++ .open = openfunc,
3281 ++ .read = readstream,
3282 ++ };
3283 ++
3284 ++@ report_r depends on report @
3285 ++identifier fops_r.openfunc;
3286 ++position p1;
3287 ++@@
3288 ++ openfunc(...) {
3289 ++ <...
3290 ++ nonseekable_open@p1
3291 ++ ...>
3292 ++ }
3293 ++
3294 ++@ script:python depends on report @
3295 ++fops << fops0.fops;
3296 ++p << report_r.p1;
3297 ++@@
3298 ++coccilib.report.print_report(p[0],
3299 ++ "WARNING: %s: .read() has stream semantic; safe to change nonseekable_open -> stream_open." % (fops,))
3300 ++
3301 ++@ explain_r depends on explain @
3302 ++identifier fops_r.openfunc;
3303 ++@@
3304 ++ openfunc(...) {
3305 ++ <...
3306 ++- nonseekable_open
3307 +++ nonseekable_open /* read only */
3308 ++ ...>
3309 ++ }
3310 ++
3311 ++@ patch_r depends on patch @
3312 ++identifier fops_r.openfunc;
3313 ++@@
3314 ++ openfunc(...) {
3315 ++ <...
3316 ++- nonseekable_open
3317 +++ stream_open
3318 ++ ...>
3319 ++ }
3320 ++
3321 ++
3322 ++// write, but not read
3323 ++@ fops_w depends on maybe_stream && !has_read @
3324 ++identifier fops0.fops, openfunc;
3325 ++identifier stream_writer.writestream;
3326 ++@@
3327 ++ struct file_operations fops = {
3328 ++ .open = openfunc,
3329 ++ .write = writestream,
3330 ++ };
3331 ++
3332 ++@ report_w depends on report @
3333 ++identifier fops_w.openfunc;
3334 ++position p1;
3335 ++@@
3336 ++ openfunc(...) {
3337 ++ <...
3338 ++ nonseekable_open@p1
3339 ++ ...>
3340 ++ }
3341 ++
3342 ++@ script:python depends on report @
3343 ++fops << fops0.fops;
3344 ++p << report_w.p1;
3345 ++@@
3346 ++coccilib.report.print_report(p[0],
3347 ++ "WARNING: %s: .write() has stream semantic; safe to change nonseekable_open -> stream_open." % (fops,))
3348 ++
3349 ++@ explain_w depends on explain @
3350 ++identifier fops_w.openfunc;
3351 ++@@
3352 ++ openfunc(...) {
3353 ++ <...
3354 ++- nonseekable_open
3355 +++ nonseekable_open /* write only */
3356 ++ ...>
3357 ++ }
3358 ++
3359 ++@ patch_w depends on patch @
3360 ++identifier fops_w.openfunc;
3361 ++@@
3362 ++ openfunc(...) {
3363 ++ <...
3364 ++- nonseekable_open
3365 +++ stream_open
3366 ++ ...>
3367 ++ }
3368 ++
3369 ++
3370 ++// no read, no write - don't change anything
3371 +diff --git a/security/selinux/avc.c b/security/selinux/avc.c
3372 +index 635e5c1e3e48..5de18a6d5c3f 100644
3373 +--- a/security/selinux/avc.c
3374 ++++ b/security/selinux/avc.c
3375 +@@ -838,6 +838,7 @@ out:
3376 + * @ssid,@tsid,@tclass : identifier of an AVC entry
3377 + * @seqno : sequence number when decision was made
3378 + * @xpd: extended_perms_decision to be added to the node
3379 ++ * @flags: the AVC_* flags, e.g. AVC_NONBLOCKING, AVC_EXTENDED_PERMS, or 0.
3380 + *
3381 + * if a valid AVC entry doesn't exist,this function returns -ENOENT.
3382 + * if kmalloc() called internal returns NULL, this function returns -ENOMEM.
3383 +@@ -856,6 +857,23 @@ static int avc_update_node(struct selinux_avc *avc,
3384 + struct hlist_head *head;
3385 + spinlock_t *lock;
3386 +
3387 ++ /*
3388 ++ * If we are in a non-blocking code path, e.g. VFS RCU walk,
3389 ++ * then we must not add permissions to a cache entry
3390 ++ * because we cannot safely audit the denial. Otherwise,
3391 ++ * during the subsequent blocking retry (e.g. VFS ref walk), we
3392 ++ * will find the permissions already granted in the cache entry
3393 ++ * and won't audit anything at all, leading to silent denials in
3394 ++ * permissive mode that only appear when in enforcing mode.
3395 ++ *
3396 ++ * See the corresponding handling in slow_avc_audit(), and the
3397 ++ * logic in selinux_inode_follow_link and selinux_inode_permission
3398 ++ * for the VFS MAY_NOT_BLOCK flag, which is transliterated into
3399 ++ * AVC_NONBLOCKING for avc_has_perm_noaudit().
3400 ++ */
3401 ++ if (flags & AVC_NONBLOCKING)
3402 ++ return 0;
3403 ++
3404 + node = avc_alloc_node(avc);
3405 + if (!node) {
3406 + rc = -ENOMEM;
3407 +@@ -1115,7 +1133,7 @@ decision:
3408 + * @tsid: target security identifier
3409 + * @tclass: target security class
3410 + * @requested: requested permissions, interpreted based on @tclass
3411 +- * @flags: AVC_STRICT or 0
3412 ++ * @flags: AVC_STRICT, AVC_NONBLOCKING, or 0
3413 + * @avd: access vector decisions
3414 + *
3415 + * Check the AVC to determine whether the @requested permissions are granted
3416 +@@ -1199,7 +1217,8 @@ int avc_has_perm_flags(struct selinux_state *state,
3417 + struct av_decision avd;
3418 + int rc, rc2;
3419 +
3420 +- rc = avc_has_perm_noaudit(state, ssid, tsid, tclass, requested, 0,
3421 ++ rc = avc_has_perm_noaudit(state, ssid, tsid, tclass, requested,
3422 ++ (flags & MAY_NOT_BLOCK) ? AVC_NONBLOCKING : 0,
3423 + &avd);
3424 +
3425 + rc2 = avc_audit(state, ssid, tsid, tclass, requested, &avd, rc,
3426 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
3427 +index 4337b6d9369e..cba19b8c3e51 100644
3428 +--- a/security/selinux/hooks.c
3429 ++++ b/security/selinux/hooks.c
3430 +@@ -497,16 +497,10 @@ static int may_context_mount_inode_relabel(u32 sid,
3431 + return rc;
3432 + }
3433 +
3434 +-static int selinux_is_sblabel_mnt(struct super_block *sb)
3435 ++static int selinux_is_genfs_special_handling(struct super_block *sb)
3436 + {
3437 +- struct superblock_security_struct *sbsec = sb->s_security;
3438 +-
3439 +- return sbsec->behavior == SECURITY_FS_USE_XATTR ||
3440 +- sbsec->behavior == SECURITY_FS_USE_TRANS ||
3441 +- sbsec->behavior == SECURITY_FS_USE_TASK ||
3442 +- sbsec->behavior == SECURITY_FS_USE_NATIVE ||
3443 +- /* Special handling. Genfs but also in-core setxattr handler */
3444 +- !strcmp(sb->s_type->name, "sysfs") ||
3445 ++ /* Special handling. Genfs but also in-core setxattr handler */
3446 ++ return !strcmp(sb->s_type->name, "sysfs") ||
3447 + !strcmp(sb->s_type->name, "pstore") ||
3448 + !strcmp(sb->s_type->name, "debugfs") ||
3449 + !strcmp(sb->s_type->name, "tracefs") ||
3450 +@@ -516,6 +510,34 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
3451 + !strcmp(sb->s_type->name, "cgroup2")));
3452 + }
3453 +
3454 ++static int selinux_is_sblabel_mnt(struct super_block *sb)
3455 ++{
3456 ++ struct superblock_security_struct *sbsec = sb->s_security;
3457 ++
3458 ++ /*
3459 ++ * IMPORTANT: Double-check logic in this function when adding a new
3460 ++ * SECURITY_FS_USE_* definition!
3461 ++ */
3462 ++ BUILD_BUG_ON(SECURITY_FS_USE_MAX != 7);
3463 ++
3464 ++ switch (sbsec->behavior) {
3465 ++ case SECURITY_FS_USE_XATTR:
3466 ++ case SECURITY_FS_USE_TRANS:
3467 ++ case SECURITY_FS_USE_TASK:
3468 ++ case SECURITY_FS_USE_NATIVE:
3469 ++ return 1;
3470 ++
3471 ++ case SECURITY_FS_USE_GENFS:
3472 ++ return selinux_is_genfs_special_handling(sb);
3473 ++
3474 ++ /* Never allow relabeling on context mounts */
3475 ++ case SECURITY_FS_USE_MNTPOINT:
3476 ++ case SECURITY_FS_USE_NONE:
3477 ++ default:
3478 ++ return 0;
3479 ++ }
3480 ++}
3481 ++
3482 + static int sb_finish_set_opts(struct super_block *sb)
3483 + {
3484 + struct superblock_security_struct *sbsec = sb->s_security;
3485 +@@ -3199,7 +3221,9 @@ static int selinux_inode_permission(struct inode *inode, int mask)
3486 + return PTR_ERR(isec);
3487 +
3488 + rc = avc_has_perm_noaudit(&selinux_state,
3489 +- sid, isec->sid, isec->sclass, perms, 0, &avd);
3490 ++ sid, isec->sid, isec->sclass, perms,
3491 ++ (flags & MAY_NOT_BLOCK) ? AVC_NONBLOCKING : 0,
3492 ++ &avd);
3493 + audited = avc_audit_required(perms, &avd, rc,
3494 + from_access ? FILE__AUDIT_ACCESS : 0,
3495 + &denied);
3496 +diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
3497 +index ef899bcfd2cb..74ea50977c20 100644
3498 +--- a/security/selinux/include/avc.h
3499 ++++ b/security/selinux/include/avc.h
3500 +@@ -142,6 +142,7 @@ static inline int avc_audit(struct selinux_state *state,
3501 +
3502 + #define AVC_STRICT 1 /* Ignore permissive mode. */
3503 + #define AVC_EXTENDED_PERMS 2 /* update extended permissions */
3504 ++#define AVC_NONBLOCKING 4 /* non blocking */
3505 + int avc_has_perm_noaudit(struct selinux_state *state,
3506 + u32 ssid, u32 tsid,
3507 + u16 tclass, u32 requested,
3508 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3509 +index 0a745d677b1c..75a0be2aa9c2 100644
3510 +--- a/sound/pci/hda/patch_realtek.c
3511 ++++ b/sound/pci/hda/patch_realtek.c
3512 +@@ -5448,6 +5448,8 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec,
3513 + return;
3514 +
3515 + spec->gen.preferred_dacs = preferred_pairs;
3516 ++ spec->gen.auto_mute_via_amp = 1;
3517 ++ codec->power_save_node = 0;
3518 + }
3519 +
3520 + /* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
3521 +@@ -7172,6 +7174,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
3522 + {0x21, 0x02211020}),
3523 + SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
3524 + {0x21, 0x02211020}),
3525 ++ SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
3526 ++ {0x12, 0x40000000},
3527 ++ {0x14, 0x90170110},
3528 ++ {0x21, 0x02211020}),
3529 + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
3530 + {0x14, 0x90170110},
3531 + {0x21, 0x02211020}),
3532 +@@ -7445,6 +7451,13 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
3533 + {0x12, 0x90a60130},
3534 + {0x17, 0x90170110},
3535 + {0x21, 0x04211020}),
3536 ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
3537 ++ {0x12, 0x90a60130},
3538 ++ {0x17, 0x90170110},
3539 ++ {0x21, 0x03211020}),
3540 ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
3541 ++ {0x14, 0x90170110},
3542 ++ {0x21, 0x04211020}),
3543 + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
3544 + ALC295_STANDARD_PINS,
3545 + {0x17, 0x21014020},
3546 +diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
3547 +index 4d3ec295679d..a651fed62a27 100644
3548 +--- a/sound/soc/codecs/wm_adsp.c
3549 ++++ b/sound/soc/codecs/wm_adsp.c
3550 +@@ -3441,8 +3441,6 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
3551 + }
3552 + }
3553 +
3554 +- wm_adsp_buffer_clear(compr->buf);
3555 +-
3556 + /* Trigger the IRQ at one fragment of data */
3557 + ret = wm_adsp_buffer_write(compr->buf,
3558 + HOST_BUFFER_FIELD(high_water_mark),
3559 +@@ -3454,6 +3452,8 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
3560 + }
3561 + break;
3562 + case SNDRV_PCM_TRIGGER_STOP:
3563 ++ if (wm_adsp_compr_attached(compr))
3564 ++ wm_adsp_buffer_clear(compr->buf);
3565 + break;
3566 + default:
3567 + ret = -EINVAL;
3568 +diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
3569 +index f8a68bdb3885..b74bbee111c6 100644
3570 +--- a/sound/soc/intel/boards/bytcr_rt5651.c
3571 ++++ b/sound/soc/intel/boards/bytcr_rt5651.c
3572 +@@ -267,7 +267,7 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
3573 + static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic_map[] = {
3574 + {"DMIC L1", NULL, "Internal Mic"},
3575 + {"DMIC R1", NULL, "Internal Mic"},
3576 +- {"IN3P", NULL, "Headset Mic"},
3577 ++ {"IN2P", NULL, "Headset Mic"},
3578 + };
3579 +
3580 + static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = {
3581 +diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
3582 +index 06fba9650ac4..85c4b6d8e89d 100644
3583 +--- a/sound/soc/stm/stm32_sai_sub.c
3584 ++++ b/sound/soc/stm/stm32_sai_sub.c
3585 +@@ -1194,7 +1194,6 @@ static int stm32_sai_sub_dais_init(struct platform_device *pdev,
3586 + if (!sai->cpu_dai_drv)
3587 + return -ENOMEM;
3588 +
3589 +- sai->cpu_dai_drv->name = dev_name(&pdev->dev);
3590 + if (STM_SAI_IS_PLAYBACK(sai)) {
3591 + memcpy(sai->cpu_dai_drv, &stm32_sai_playback_dai,
3592 + sizeof(stm32_sai_playback_dai));
3593 +@@ -1204,6 +1203,7 @@ static int stm32_sai_sub_dais_init(struct platform_device *pdev,
3594 + sizeof(stm32_sai_capture_dai));
3595 + sai->cpu_dai_drv->capture.stream_name = sai->cpu_dai_drv->name;
3596 + }
3597 ++ sai->cpu_dai_drv->name = dev_name(&pdev->dev);
3598 +
3599 + return 0;
3600 + }